Documentation ¶
Index ¶
- type BaseService
- func (s *BaseService) AddSubscription(sub *nats.Subscription)
- func (s *BaseService) GetName() string
- func (s *BaseService) HandlerQueueSubscribe(handler NRPCHandler, queue string) SubscriptionDef
- func (s *BaseService) SafeTaskDone()
- func (s *BaseService) Shutdown() error
- func (s *BaseService) SubscribeAll(subdefs ...SubscriptionDef) error
- func (s *BaseService) TaskAdd()
- func (s *BaseService) TaskDone()
- func (s *BaseService) UnsubscribeAll() error
- type Manager
- type NRPCHandler
- type Options
- type Service
- type SubscriptionDef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseService ¶
type BaseService struct { Name string Log xbus.Logger Conn *nats.Conn Tasks sync.WaitGroup // contains filtered or unexported fields }
BaseService is a base struct for implementing services.
func NewBaseService ¶
func NewBaseService(name string, o Options) BaseService
NewBaseService initialize a BaseService
func (*BaseService) AddSubscription ¶
func (s *BaseService) AddSubscription(sub *nats.Subscription)
AddSubscription save a subscription to be unsubscribed with UnsubscribeAll
func (*BaseService) GetName ¶
func (s *BaseService) GetName() string
GetName returns the service nams
func (*BaseService) HandlerQueueSubscribe ¶
func (s *BaseService) HandlerQueueSubscribe(handler NRPCHandler, queue string) SubscriptionDef
HandlerQueueSubscribe returnes a SubscriptionDef for a nrpc queue subscription
func (*BaseService) SafeTaskDone ¶
func (s *BaseService) SafeTaskDone()
SafeTaskDone is a version of TaskDone that recover panics and log them.
func (*BaseService) Shutdown ¶
func (s *BaseService) Shutdown() error
Shutdown is a default implementation that calls UnsubscribeAll()
func (*BaseService) SubscribeAll ¶
func (s *BaseService) SubscribeAll(subdefs ...SubscriptionDef) error
SubscribeAll do multiple subscriptions at once and returns immediately on the first failing subscription.
func (*BaseService) TaskAdd ¶
func (s *BaseService) TaskAdd()
TaskAdd signal that a task just started. It will block service shutdown until TaskDone is called.
func (*BaseService) TaskDone ¶
func (s *BaseService) TaskDone()
TaskDone signal the end of a task, allowing the service to shutdown if no other task is running.
func (*BaseService) UnsubscribeAll ¶
func (s *BaseService) UnsubscribeAll() error
UnsubscribeAll unsubscribe and forget all the subscriptions
type Manager ¶
type Manager struct { Log xbus.Logger // contains filtered or unexported fields }
Manager ...
type NRPCHandler ¶
type NRPCHandler interface { Subject() string Handler(*nats.Msg) }
NRPCHandler ...
type Options ¶
type Options struct { Conn *nats.Conn Logger xbus.Logger }
Options is the common options of xbus services
type Service ¶
type Service interface { // GetName returns the service name GetName() string // Startup will do what is necessary for the service to be up and running Startup() error // Shutdown should stop the service and release any resource allocated by // Startup Shutdown() error }
Service is the common interface of all the services
type SubscriptionDef ¶
SubscriptionDef is a definition of a nats subscription
func QueueSubscribe ¶
func QueueSubscribe(subject, queue string, handler nats.MsgHandler) SubscriptionDef
QueueSubscribe returns a SubscriptionDef for queue subscription
func Subscribe ¶
func Subscribe(subject string, handler nats.MsgHandler) SubscriptionDef
Subscribe returns a SubscriptionDef for simple subscription
Directories ¶
Path | Synopsis |
---|---|
Package core provides the 'core' service, which must be started once and only once in every server process
|
Package core provides the 'core' service, which must be started once and only once in every server process |
Package ravencapture provides the 'core' service, which must be started once and only once in every server process
|
Package ravencapture provides the 'core' service, which must be started once and only once in every server process |