blasphem/pkg/blas/core/core.go

49 lines
965 B
Go
Raw Normal View History

2022-12-20 16:26:04 -05:00
package core
import (
"context"
"dynatron.me/x/blasphem/pkg/auth"
"dynatron.me/x/blasphem/pkg/bus"
"dynatron.me/x/blasphem/pkg/components"
"dynatron.me/x/blasphem/pkg/config"
"dynatron.me/x/blasphem/pkg/storage"
)
2022-12-20 19:05:45 -05:00
type Blas interface {
2022-12-20 16:26:04 -05:00
auth.Authenticator
bus.Bus
storage.Store
config.Configured
2022-12-20 19:05:45 -05:00
components.Componenter
WebSocketManager
2022-12-20 16:26:04 -05:00
Shutdowner
Versioner
}
2022-12-20 19:05:45 -05:00
type WebSocketManager interface {
// Register registers a websocket command.
// cmd is the first part, before first slash
// dataNew is a function to create a new message datatype
RegisterWSCommand(cmd string, hnd Handler, dataNew NewData)
WSCommandHandler(cmd string) (NewData, Handler, error)
}
type WebSocketSession interface {
Go() error
Blas() Blas
}
2022-12-20 20:11:11 -05:00
type Handler func(wss WebSocketSession, msgID int, msg interface{}) error
2022-12-20 19:05:45 -05:00
type NewData func() interface{}
2022-12-20 16:26:04 -05:00
type Shutdowner interface {
ShutdownBlas(context.Context) error
}
type Versioner interface {
Version() string
}