refactor foundry lib structure; add transport classes for db,http,websocket; add action interface instead of multiple function that accepts action classes; add changing foundry status on websocket responses

This commit is contained in:
lbenedar
2026-04-09 18:29:41 +03:00
parent 468e027418
commit fb4e371348
28 changed files with 900 additions and 791 deletions

View File

@@ -0,0 +1,30 @@
package actions
import (
"gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/transport"
"gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/types"
)
type WsShutdownMsg struct {
World string `json:"world"`
UserId *string `json:"userId,omitempty"`
}
func (msg WsShutdownMsg) Action(tr *transport.FoundryTransport, status *types.FoundryStatus) error {
if status.IsActive != false {
newStatus, err := tr.Http.GetStatus()
if err != nil {
return err
}
status.Update(newStatus)
tr.Logger.Info("Status has been changed", "status", status)
}
if tr.IsDbInit {
return nil
}
tr.IsDbInit = true
go tr.FillDBWithFoundryData()
return nil
}