Documentation
¶
Index ¶
- Variables
- func GetEventName(event any) string
- func NewNamedTask(name string, run func(context.Context, Wrapper) error) *task
- func Run(ctx context.Context, options *Options) error
- func WithWrapper(ctx context.Context, wp Wrapper) context.Context
- type ConfigParser
- type Event
- type Hook
- type Map
- type Options
- type ProcessLogEvent
- type Registry
- type ServerState
- type ServerState_Player
- type ServerState_Players
- type ServerState_Status
- type Service
- type StateUpdateEvent
- type States
- type Stopper
- type Task
- type Wrapper
- type WrapperContext
- func (wp *WrapperContext) EmitEvent(event any)
- func (wp *WrapperContext) Files() fs.FS
- func (wp *WrapperContext) GetServerConfig() (Map, error)
- func (wp *WrapperContext) GetState() ServerState
- func (wp *WrapperContext) Logger() *slog.Logger
- func (wp *WrapperContext) SendSignal(signal os.Signal) error
- func (wp *WrapperContext) SubscribeEvents() pubsub.Subscriber[Event]
- func (wp *WrapperContext) SubscribeLogs() pubsub.Subscriber[string]
- func (wp *WrapperContext) SubscribeStates() pubsub.Subscriber[ServerState]
- func (wp *WrapperContext) UpdateState(updateFn func(ServerState) ServerState)
- func (wp *WrapperContext) WriteStdin(command string) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrWrapperContextMissing = errors.New("wrapper context missing")
Functions ¶
func GetEventName ¶ added in v0.4.0
func NewNamedTask ¶ added in v0.5.0
Types ¶
type ConfigParser ¶ added in v0.6.0
type Map ¶ added in v0.6.0
type Map interface {
GetInt8(string, int8) int8
GetUint8(string, uint8) uint8
GetInt16(string, int16) int16
GetUint16(string, uint16) uint16
GetInt32(string, int32) int32
GetUint32(string, uint32) uint32
GetInt64(string, int64) int64
GetUint64(string, uint64) uint64
GetBool(string, bool) bool
GetString(string, string) string
GetMap(string, Map) Map
}
type ProcessLogEvent ¶
type ProcessLogEvent struct {
Message string `json:"message"`
}
type Registry ¶ added in v0.6.0
type Registry struct {
Tasks []Task
Services []Service
Stoppers map[string]func(map[string]any) Stopper
LoggingHandlers map[string]func(map[string]any) slog.Handler
Hooks map[string]func(map[string]any) Hook
ConfigParser map[string]func(map[string]any) ConfigParser
}
func NewRegistry ¶ added in v0.6.0
func NewRegistry() *Registry
type ServerState ¶ added in v0.6.0
type ServerState struct {
Status ServerState_Status `json:"status"`
Players ServerState_Players `json:"players"`
}
type ServerState_Player ¶ added in v0.6.0
type ServerState_Players ¶ added in v0.6.0
type ServerState_Players struct {
Count int `json:"count"`
Max int `json:"max"`
List []ServerState_Player `json:"list"`
}
type ServerState_Status ¶ added in v0.6.0
type ServerState_Status struct {
Description string `json:"description"`
}
type Service ¶ added in v0.4.0
type Service interface {
Register(grpc.ServiceRegistrar)
}
type StateUpdateEvent ¶
type StateUpdateEvent struct {
State ServerState `json:"state"`
}
type States ¶ added in v0.6.0
type States struct {
// contains filtered or unexported fields
}
func NewStates ¶ added in v0.6.0
func NewStates(state ServerState) (*States, error)
func (*States) Get ¶ added in v0.6.0
func (s *States) Get() ServerState
type Wrapper ¶
type Wrapper interface {
Files() fs.FS
WriteStdin(command string) error
SendSignal(signal os.Signal) error
SubscribeLogs() pubsub.Subscriber[string]
SubscribeEvents() pubsub.Subscriber[Event]
EmitEvent(event any)
GetState() ServerState
SubscribeStates() pubsub.Subscriber[ServerState]
UpdateState(func(ServerState) ServerState)
Logger() *slog.Logger
GetServerConfig() (Map, error)
}
type WrapperContext ¶ added in v0.3.0
type WrapperContext struct {
// contains filtered or unexported fields
}
func (*WrapperContext) EmitEvent ¶ added in v0.6.0
func (wp *WrapperContext) EmitEvent(event any)
func (*WrapperContext) Files ¶ added in v0.6.0
func (wp *WrapperContext) Files() fs.FS
func (*WrapperContext) GetServerConfig ¶ added in v0.6.0
func (wp *WrapperContext) GetServerConfig() (Map, error)
func (*WrapperContext) GetState ¶ added in v0.6.0
func (wp *WrapperContext) GetState() ServerState
func (*WrapperContext) Logger ¶ added in v0.6.0
func (wp *WrapperContext) Logger() *slog.Logger
func (*WrapperContext) SendSignal ¶ added in v0.3.0
func (wp *WrapperContext) SendSignal(signal os.Signal) error
func (*WrapperContext) SubscribeEvents ¶ added in v0.3.0
func (wp *WrapperContext) SubscribeEvents() pubsub.Subscriber[Event]
func (*WrapperContext) SubscribeLogs ¶ added in v0.3.0
func (wp *WrapperContext) SubscribeLogs() pubsub.Subscriber[string]
func (*WrapperContext) SubscribeStates ¶ added in v0.3.0
func (wp *WrapperContext) SubscribeStates() pubsub.Subscriber[ServerState]
func (*WrapperContext) UpdateState ¶ added in v0.6.0
func (wp *WrapperContext) UpdateState(updateFn func(ServerState) ServerState)
func (*WrapperContext) WriteStdin ¶ added in v0.6.0
func (wp *WrapperContext) WriteStdin(command string) error
Source Files
¶
Click to show internal directories.
Click to hide internal directories.