Documentation
¶
Index ¶
- type Subscriber
- func (s *Subscriber) AddSubscription(topics ...string) (uint32, error)
- func (s *Subscriber) Connected() bool
- func (s *Subscriber) Disconnect() error
- func (s *Subscriber) Next() *ops.PushedMessage
- func (s *Subscriber) Queued() bool
- func (s *Subscriber) Unsubscribe(topics ...string) (uint32, error)
- func (s *Subscriber) UnsubscribeAll() (uint32, error)
- func (s *Subscriber) Watch() chan struct{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
Subscriber - Abstraction layer at which subscriber interacts, while all underlying networking details are kept hidden
func New ¶
func New(ctx context.Context, proto, addr string, cap uint64, topics ...string) (*Subscriber, error)
New - First time subscribing to a non-empty set of topics, for first time subscription use this function & then keep using obtained subscriber handle for further communication with HUB
func (*Subscriber) AddSubscription ¶
func (s *Subscriber) AddSubscription(topics ...string) (uint32, error)
AddSubscription - After a subscriber has been registered ( knows its ID ), more topics can be subscribed to
func (*Subscriber) Connected ¶
func (s *Subscriber) Connected() bool
Connected - Concurrent safe check for connection aliveness with HUB
func (*Subscriber) Disconnect ¶
func (s *Subscriber) Disconnect() error
Disconnect - Disconnects subscriber by closing network connection
Invoking this method also unblocks read attempt in `listen`-er go routine if that's blocked
func (*Subscriber) Next ¶
func (s *Subscriber) Next() *ops.PushedMessage
Next - Pulls out oldest queued message from buffer
func (*Subscriber) Queued ¶
func (s *Subscriber) Queued() bool
Queued - Checks existance of any consumable message in buffer
func (*Subscriber) Unsubscribe ¶
func (s *Subscriber) Unsubscribe(topics ...string) (uint32, error)
Unsubscribe - Unsubscribe from a non-empty set of topics, no message to be received from those anymore
func (*Subscriber) UnsubscribeAll ¶
func (s *Subscriber) UnsubscribeAll() (uint32, error)
UnsubscribeAll - Client not interested in receiving any messages from any of currently subscribed topics
func (*Subscriber) Watch ¶
func (s *Subscriber) Watch() chan struct{}
Watch - Watch if new message has arrived in mailbox
Note: If subscriber is slow & more messages come in, some notifications may be missed ( not sent to be clear )