Documentation
¶
Index ¶
Constants ¶
const (
// PublishService - Client service method
PublishService = "ClientService.PushEvent"
)
const (
// RegisterService - Server subscribe service method
RegisterService = "ServerService.Register"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BusPublisher ¶
type BusPublisher interface {
Publish(key string, args ...any)
HasCallback(key string) bool
WaitAsync()
}
发布标准
type BusSubscriber ¶
type BusSubscriber interface {
Subscribe(key string, fn any) error
SubscribeAsync(key string, fn any) error
SubscribeOnce(key string, fn any) error
SubscribeOnceAsync(key string, fn any) error
Unsubscribe(key string, fn any)
}
订阅标准
type ClientArg ¶
type ClientArg struct {
Args []interface{}
Topic string
}
ClientArg - object containing event for client to publish locally
type ClientBus ¶
type ClientService ¶
type ClientService struct {
// contains filtered or unexported fields
}
ClientService - service object listening to events published in a remote event bus
type EventBus ¶
type EventBus interface {
BusSubscriber
BusPublisher
}
func NewEventBus ¶
func NewEventBus() EventBus
type NetworkBus ¶
func NewNetworkBus ¶
func NewNetworkBus(address, path string) NetworkBus
NewNetworkBus - returns a new network bus object at the server address and path
type NetworkService ¶
type NetworkService struct {
// contains filtered or unexported fields
}
NetworkBusService - object capable of serving the network bus
type ServerBus ¶
type ServerBus interface {
RpcBus
RegisterType(param any)
HasClientSubscribed(arg *SubscribeArg) bool
ClientSubscribed() *mymap.MultiMap[string, *SubscribeArg]
RPCCallback(arg *SubscribeArg) func(args ...interface{})
ServerService() *ServerService
}
type ServerService ¶
type ServerService struct {
// contains filtered or unexported fields
}
ServerService - service object to listen to remote subscriptions
func (*ServerService) Register ¶
func (service *ServerService) Register(arg *SubscribeArg, success *bool) error
Register - Registers a remote handler to this event bus for a remote subscribe - a given client address only needs to subscribe once event will be republished in local event bus
type SubscribeArg ¶
type SubscribeArg struct {
ClientAddr string
ClientPath string
ServiceMethod string
SubscribeType SubscribeType
Topic string
}
SubscribeArg - object to hold subscribe arguments from remote event handlers
type SubscribeType ¶
type SubscribeType int
SubscribeType - how the client intends to subscribe
const ( // Subscribe - subscribe to all events Subscribe SubscribeType = iota // SubscribeOnce - subscribe to only one event SubscribeOnce )