Documentation
¶
Index ¶
- Constants
- Variables
- func StdProtocolEmitter(format MessageFormat, protocol string, payload []byte) []byte
- type AppBase
- type Application
- func (ap *Application) MessageClientManager() *MessageClientManager
- func (ap *Application) SessionState(id string) SessionState
- func (ap *Application) Start(ctx context.Context) error
- func (ap *Application) Stop(ctx context.Context) error
- func (ap *Application) TextMapPropagator() propagation.TextMapPropagator
- func (ap *Application) TracerProvider() *trace.SeverityTracerProvider
- type ApplicationBuildingOption
- func WithDefaultEventHandler(handler EventHandler) ApplicationBuildingOption
- func WithDefaultMessageHandler(handler MessageHandler) ApplicationBuildingOption
- func WithErrorHandler(handler ErrorHandler) ApplicationBuildingOption
- func WithEventClient(source EventClient) ApplicationBuildingOption
- func WithEventRouter(router EventRouter) ApplicationBuildingOption
- func WithInvalidEventHandler(handler EventHandler) ApplicationBuildingOption
- func WithInvalidMessageHandler(handler MessageHandler) ApplicationBuildingOption
- func WithLoggerFlags(flags int) ApplicationBuildingOption
- func WithLoggerOutput(w io.Writer) ApplicationBuildingOption
- func WithMessageRouter(router MessageRouter) ApplicationBuildingOption
- func WithProtocolEmitter(emitter ProtocolEmitter) ApplicationBuildingOption
- func WithProtocolResolver(resolver ProtocolResolver) ApplicationBuildingOption
- func WithSessionStateManager(manager SessionStateManager) ApplicationBuildingOption
- func WithTextMapPropagator(p propagation.TextMapPropagator) ApplicationBuildingOption
- func WithTracerProvider(tp *trace.SeverityTracerProvider) ApplicationBuildingOption
- type ApplicationWorker
- type ClientIDValidator
- type Context
- func (ctx *Context) CloseSend() error
- func (*Context) Deadline() (deadline time.Time, ok bool)
- func (*Context) Done() <-chan struct{}
- func (*Context) Err() error
- func (ctx *Context) Forward(channel string, payload []byte)
- func (ctx *Context) InvalidEvent(event *Event)
- func (ctx *Context) InvalidMessage(message *Message)
- func (ctx *Context) IsCloseSend() bool
- func (ctx *Context) Logger() *log.Logger
- func (ctx *Context) Send(format MessageFormat, protocol string, body []byte) error
- func (ctx *Context) SetValue(key interface{}, value interface{})
- func (ctx *Context) Value(key any) any
- type ErrorHandler
- type Event
- type EventClient
- type EventDelegate
- type EventForwarder
- type EventHandler
- type EventPipe
- type EventRouter
- type GenericApplicationBuildingOption
- type LoggingWriter
- type Message
- type MessageClient
- type MessageClientInfo
- type MessageClientInfoImpl
- type MessageClientManager
- type MessageContent
- type MessageError
- type MessageFormat
- type MessageHandler
- type MessagePipe
- type MessageRouter
- type MessageSender
- type MessageSource
- type MessageWorker
- type Module
- type ModuleBindingOption
- type ModuleBindingOptionFunc
- type ModuleOptionCollection
- type MultiEventClient
- type NoopEventClient
- type ProtocolEmitter
- type ProtocolResolver
- type RestrictedMessageClient
- type SessionState
- type SessionStateManager
- type StdSessionState
- func (state *StdSessionState) CanVisit() bool
- func (state *StdSessionState) Lock()
- func (state *StdSessionState) SetValue(k interface{}, v interface{})
- func (state *StdSessionState) Unlock()
- func (state *StdSessionState) Value(k interface{}) interface{}
- func (state *StdSessionState) Visit(fn func(k interface{}, v interface{}))
- type StdSessionStateManager
- type TargetValueRole
Constants ¶
const ( APP_BUILDING_OPT_SESSION_STATE_MANAGER = "WithSessionStateManager" APP_BUILDING_OPT_PROTOCOL_RESOLVER = "WithProtocolResolver" APP_BUILDING_OPT_PROTOCOL_EMITTER = "WithProtocolEmitter" APP_BUILDING_OPT_LOGGER_OUTPUT = "WithLoggerOutput" APP_BUILDING_OPT_LOGGER_FLAGS = "WithLoggerFlags" APP_BUILDING_OPT_TRACER_PROVIDER = "WithTracerProvider" APP_BUILDING_OPT_TEXT_MAP_PROPAGATOR = "WithTextMapPropagator" APP_BUILDING_OPT_EVENT_CLIENT = "WithEventClient" APP_BUILDING_OPT_MESSAGE_ROUTER = "WithMessageRouter" APP_BUILDING_OPT_EVENT_ROUTER = "WithEventRouter" APP_BUILDING_OPT_INVALID_MESSAGE_HANDLER = "WithInvalidMessageHandler" APP_BUILDING_OPT_INVALID_EVENT_HANDLER = "WithInvalidEventHandler" APP_BUILDING_OPT_DEFAULT_MESSAGE_HANDLER = "WithDefaultMessageHandler" APP_BUILDING_OPT_DEFAULT_EVENT_HANDLER = "WithDefaultEventHandler" APP_BUILDING_OPT_ERROR_HANDLER = "WithErrorHandler" )
const ( InvalidChannel string = "?" TAG_PROTOCOL = "protocol" TAG_CHANNEL = "channel" TAG_OPT_EXPAND_ENV = "@ExpandEnv" OPT_ON = "on" OPT_OFF = "off" )
const ( Nop = appError("Nop") ErrJoinClosedMessageClientManager = appError("Join() MessageClient with a stopped MessageClientManager") ErrSendMessageToClosedWriter = appError("MessageClient send message to closed writer") )
Variables ¶
var ( AllMessageFormats = []MessageFormat{ TEXT_MESSAGE, BINARY_MESSAGE, CLOSE_MESSAGE, PING_MESSAGE, PONG_MESSAGE, } )
Functions ¶
func StdProtocolEmitter ¶
func StdProtocolEmitter(format MessageFormat, protocol string, payload []byte) []byte
Types ¶
type AppBase ¶ added in v0.2.5
type AppBase struct {
// contains filtered or unexported fields
}
func (*AppBase) EnableStackTrace ¶ added in v0.2.5
func (*AppBase) TextMapPropagator ¶ added in v0.2.5
func (app *AppBase) TextMapPropagator() propagation.TextMapPropagator
func (*AppBase) TracerProvider ¶ added in v0.2.5
func (app *AppBase) TracerProvider() *trace.SeverityTracerProvider
type Application ¶
type Application struct { Name string // contains filtered or unexported fields }
func Build ¶
func Build(appName string, opts ...ApplicationBuildingOption) (*Application, error)
func Init ¶
func Init(v Module, opts ...ModuleBindingOption) *Application
func (*Application) MessageClientManager ¶
func (ap *Application) MessageClientManager() *MessageClientManager
func (*Application) SessionState ¶ added in v0.2.6
func (ap *Application) SessionState(id string) SessionState
func (*Application) TextMapPropagator ¶
func (ap *Application) TextMapPropagator() propagation.TextMapPropagator
func (*Application) TracerProvider ¶
func (ap *Application) TracerProvider() *trace.SeverityTracerProvider
type ApplicationBuildingOption ¶
type ApplicationBuildingOption interface {
// contains filtered or unexported methods
}
func WithDefaultEventHandler ¶
func WithDefaultEventHandler(handler EventHandler) ApplicationBuildingOption
func WithDefaultMessageHandler ¶
func WithDefaultMessageHandler(handler MessageHandler) ApplicationBuildingOption
func WithErrorHandler ¶
func WithErrorHandler(handler ErrorHandler) ApplicationBuildingOption
func WithEventClient ¶
func WithEventClient(source EventClient) ApplicationBuildingOption
func WithEventRouter ¶
func WithEventRouter(router EventRouter) ApplicationBuildingOption
func WithInvalidEventHandler ¶
func WithInvalidEventHandler(handler EventHandler) ApplicationBuildingOption
func WithInvalidMessageHandler ¶
func WithInvalidMessageHandler(handler MessageHandler) ApplicationBuildingOption
func WithLoggerFlags ¶
func WithLoggerFlags(flags int) ApplicationBuildingOption
func WithLoggerOutput ¶ added in v0.2.1
func WithLoggerOutput(w io.Writer) ApplicationBuildingOption
func WithMessageRouter ¶
func WithMessageRouter(router MessageRouter) ApplicationBuildingOption
func WithProtocolEmitter ¶
func WithProtocolEmitter(emitter ProtocolEmitter) ApplicationBuildingOption
func WithProtocolResolver ¶
func WithProtocolResolver(resolver ProtocolResolver) ApplicationBuildingOption
func WithSessionStateManager ¶
func WithSessionStateManager(manager SessionStateManager) ApplicationBuildingOption
func WithTextMapPropagator ¶
func WithTextMapPropagator(p propagation.TextMapPropagator) ApplicationBuildingOption
func WithTracerProvider ¶
func WithTracerProvider(tp *trace.SeverityTracerProvider) ApplicationBuildingOption
type ApplicationWorker ¶
type ApplicationWorker struct {
// contains filtered or unexported fields
}
type ClientIDValidator ¶
type Context ¶
type Context struct { SessionID string SessionState SessionState GlobalState SessionState // contains filtered or unexported fields }
func (*Context) InvalidEvent ¶
func (*Context) InvalidMessage ¶
func (*Context) IsCloseSend ¶ added in v0.2.4
type ErrorHandler ¶
type ErrorHandler func(err error)
type Event ¶
type Event struct { Channel string Payload []byte Delegate EventDelegate // contains filtered or unexported fields }
type EventClient ¶
type EventClient interface { Start(*EventPipe) Stop() Close() error EventForwarder }
type EventDelegate ¶
type EventForwarder ¶
type EventHandler ¶
type EventRouter ¶
type EventRouter map[string]EventHandler
func (EventRouter) Add ¶
func (r EventRouter) Add(channel string, handler EventHandler)
func (EventRouter) Get ¶
func (r EventRouter) Get(channel string) EventHandler
func (EventRouter) Has ¶
func (r EventRouter) Has(channel string) bool
func (EventRouter) Remove ¶
func (r EventRouter) Remove(channel string)
type GenericApplicationBuildingOption ¶ added in v0.2.5
type GenericApplicationBuildingOption struct {
// contains filtered or unexported fields
}
type LoggingWriter ¶ added in v0.2.5
type LoggingWriter struct { EnableStackTrace bool // contains filtered or unexported fields }
func NewLoggingWriter ¶ added in v0.2.5
func NewLoggingWriter(writer io.Writer) *LoggingWriter
func (*LoggingWriter) Write ¶ added in v0.2.5
func (w *LoggingWriter) Write(p []byte) (n int, err error)
Write implements io.Writer.
func (*LoggingWriter) Writter ¶ added in v0.2.5
func (w *LoggingWriter) Writter() io.Writer
type Message ¶
type Message struct { Format MessageFormat Protocol string Body []byte }
func (*Message) DecodeContent ¶
func (m *Message) DecodeContent(v MessageContent) error
type MessageClient ¶
type MessageClient interface { Start(*MessagePipe) Stop() Close() error RegisterCloseHandler(func(MessageClient)) MessageSender MessageClientInfoImpl }
type MessageClientInfo ¶ added in v0.2.2
type MessageClientInfo struct {
// contains filtered or unexported fields
}
func NewMessageClientInfo ¶ added in v0.2.2
func NewMessageClientInfo() *MessageClientInfo
func (*MessageClientInfo) ID ¶ added in v0.2.2
func (info *MessageClientInfo) ID() string
ID implements MessageClientInfoImpl.
func (*MessageClientInfo) Logger ¶ added in v0.2.2
func (info *MessageClientInfo) Logger() *log.Logger
Logger implements MessageClientInfoImpl.
func (*MessageClientInfo) StartAt ¶ added in v0.2.2
func (info *MessageClientInfo) StartAt() time.Time
StartAt implements MessageClientInfoImpl.
type MessageClientInfoImpl ¶ added in v0.2.2
type MessageClientManager ¶
type MessageClientManager struct {
// contains filtered or unexported fields
}
func (*MessageClientManager) Expel ¶
func (manager *MessageClientManager) Expel(client MessageClient) error
func (*MessageClientManager) Join ¶
func (manager *MessageClientManager) Join(client MessageClient) error
type MessageContent ¶
type MessageContent interface { Decode(format MessageFormat, body []byte) error Encode() (MessageFormat, []byte) Validate() error }
type MessageError ¶
type MessageError error
type MessageFormat ¶
type MessageFormat uint
const ( UNKNOWN_MESSAGE MessageFormat = 0 TEXT_MESSAGE MessageFormat = 1 BINARY_MESSAGE MessageFormat = 2 CLOSE_MESSAGE MessageFormat = 8 PING_MESSAGE MessageFormat = 9 PONG_MESSAGE MessageFormat = 10 )
func (MessageFormat) IsControl ¶
func (format MessageFormat) IsControl() bool
func (MessageFormat) IsData ¶
func (format MessageFormat) IsData() bool
type MessageHandler ¶
type MessagePipe ¶
type MessagePipe struct {
// contains filtered or unexported fields
}
func (*MessagePipe) Error ¶
func (pipe *MessagePipe) Error(err error)
func (*MessagePipe) Forward ¶
func (pipe *MessagePipe) Forward(client MessageClient, message *Message)
type MessageRouter ¶
type MessageRouter map[string]MessageHandler
func (MessageRouter) Add ¶
func (r MessageRouter) Add(code string, handler MessageHandler)
func (MessageRouter) Get ¶
func (r MessageRouter) Get(code string) MessageHandler
func (MessageRouter) Has ¶
func (r MessageRouter) Has(code string) bool
func (MessageRouter) Remove ¶
func (r MessageRouter) Remove(code string)
type MessageSender ¶
type MessageSender interface {
Send(format MessageFormat, payload []byte) error
}
type MessageSource ¶
type MessageSource struct { Message *Message Client MessageClient }
type MessageWorker ¶
type MessageWorker struct { }
type Module ¶
type Module interface {
ModuleOptions() []ApplicationBuildingOption
}
type ModuleBindingOption ¶
type ModuleBindingOption interface {
// contains filtered or unexported methods
}
func BindConfig ¶
func BindConfig(v interface{}) ModuleBindingOption
func BindEventClient ¶
func BindEventClient(v interface{}) ModuleBindingOption
func BindServiceProvider ¶
func BindServiceProvider(v interface{}) ModuleBindingOption
type ModuleBindingOptionFunc ¶
type ModuleBindingOptionFunc func(reflect.Value, TargetValueRole) error
type ModuleOptionCollection ¶
type ModuleOptionCollection []ApplicationBuildingOption
func ModuleOptions ¶
func ModuleOptions(opts ...ApplicationBuildingOption) ModuleOptionCollection
func (ModuleOptionCollection) ModuleOptions ¶
func (c ModuleOptionCollection) ModuleOptions() []ApplicationBuildingOption
type MultiEventClient ¶
type MultiEventClient map[string]EventClient
func (MultiEventClient) Close ¶
func (hub MultiEventClient) Close() error
Close implements EventBroker.
func (MultiEventClient) Forward ¶
func (hub MultiEventClient) Forward(channel string, payload []byte) error
Forward implements EventBroker.
func (MultiEventClient) Start ¶
func (hub MultiEventClient) Start(pipe *EventPipe)
Start implements EventBroker.
type NoopEventClient ¶
type NoopEventClient struct{}
func (NoopEventClient) Forward ¶
func (NoopEventClient) Forward(channel string, payload []byte) error
Forward implements EventSource.
func (NoopEventClient) Start ¶
func (NoopEventClient) Start(*EventPipe)
Start implements EventSource.
type ProtocolEmitter ¶
type ProtocolEmitter func(format MessageFormat, protocol string, body []byte) []byte
type ProtocolResolver ¶
type ProtocolResolver func(format MessageFormat, payload []byte) (string, []byte)
type RestrictedMessageClient ¶ added in v0.2.2
type RestrictedMessageClient struct {
// contains filtered or unexported fields
}
func NewRestrictedMessageClient ¶ added in v0.2.2
func NewRestrictedMessageClient(client MessageClient) *RestrictedMessageClient
func (*RestrictedMessageClient) Close ¶ added in v0.2.2
func (*RestrictedMessageClient) Close() error
Close implements MessageClient.
func (*RestrictedMessageClient) RegisterCloseHandler ¶ added in v0.2.2
func (*RestrictedMessageClient) RegisterCloseHandler(func(MessageClient))
RegisterCloseHandler implements MessageClient.
func (*RestrictedMessageClient) Start ¶ added in v0.2.2
func (*RestrictedMessageClient) Start(*MessagePipe)
Start implements MessageClient.
func (*RestrictedMessageClient) Stop ¶ added in v0.2.2
func (*RestrictedMessageClient) Stop()
Stop implements MessageClient.
type SessionState ¶
type SessionState interface { CanVisit() bool Visit(func(k, v interface{})) Value(k interface{}) interface{} SetValue(k, v interface{}) Lock() Unlock() }
type SessionStateManager ¶
type SessionStateManager interface { Load(id string) SessionState Update(id string, state SessionState) Delete(id string) TryCreate(id string) bool }
type StdSessionState ¶
type StdSessionState struct {
// contains filtered or unexported fields
}
func NewStdSessionState ¶
func NewStdSessionState() *StdSessionState
func (*StdSessionState) CanVisit ¶
func (state *StdSessionState) CanVisit() bool
CanVisit implements SessionState.
func (*StdSessionState) SetValue ¶
func (state *StdSessionState) SetValue(k interface{}, v interface{})
SetValue implements SessionState.
func (*StdSessionState) Unlock ¶
func (state *StdSessionState) Unlock()
Unlock implements SessionState.
func (*StdSessionState) Value ¶
func (state *StdSessionState) Value(k interface{}) interface{}
Value implements SessionState.
func (*StdSessionState) Visit ¶
func (state *StdSessionState) Visit(fn func(k interface{}, v interface{}))
Visit implements SessionState.
type StdSessionStateManager ¶
type StdSessionStateManager struct {
// contains filtered or unexported fields
}
func NewStdSessionStateManager ¶
func NewStdSessionStateManager() *StdSessionStateManager
func (*StdSessionStateManager) Delete ¶
func (m *StdSessionStateManager) Delete(id string)
Delete implements SessionStateManager.
func (*StdSessionStateManager) Load ¶
func (m *StdSessionStateManager) Load(id string) SessionState
Load implements SessionStateManager.
func (*StdSessionStateManager) TryCreate ¶
func (m *StdSessionStateManager) TryCreate(id string) bool
TryCreate implements SessionStateManager.
func (*StdSessionStateManager) Update ¶
func (m *StdSessionStateManager) Update(id string, state SessionState)
Update implements SessionStateManager.
type TargetValueRole ¶
type TargetValueRole string
const ( APP TargetValueRole = "APP" MODULE_OPTIONS TargetValueRole = "MODULE_OPTIONS" )
Source Files
¶
- app.go
- appBase.go
- application.go
- applicationBuildingOptions.go
- applicationWorker.go
- context.go
- def.go
- errors.go
- event.go
- eventPipe.go
- eventRouter.go
- loggingWriter.go
- message.go
- messageClientInfo.go
- messageClientManager.go
- messageFormat.go
- messagePipe.go
- messageRouter.go
- messageSource.go
- moduleBindingOptions.go
- moduleOptionCollection.go
- multiEventClient.go
- noopEventClient.go
- restrictedMessageClient.go
- stdProtocolEmitter.go
- stdSessionState.go
- stdSessionStateManager.go
- util.go