Documentation ¶
Overview ¶
Package pubsub is a simple, label-based, thread-safe PubSub implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultPublisher ¶
type DefaultPublisher struct {
// contains filtered or unexported fields
}
func NewPublisher ¶
func NewPublisher() *DefaultPublisher
func (*DefaultPublisher) Close ¶
func (pu *DefaultPublisher) Close() error
func (*DefaultPublisher) Publish ¶
func (pu *DefaultPublisher) Publish(msg Msg) error
func (*DefaultPublisher) Subscribe ¶
func (pu *DefaultPublisher) Subscribe(opts ...SubscriptionOptions) *Subscription
func (*DefaultPublisher) Unsubscribe ¶
func (pu *DefaultPublisher) Unsubscribe(sub *Subscription) error
type GenericMsg ¶
type GenericMsg struct { *EmptyMsg // contains filtered or unexported fields }
func NewGenericMsg ¶
func NewGenericMsg(lbls labels.Labels, createdAt time.Time, payload interface{}) *GenericMsg
func (*GenericMsg) Payload ¶
func (pm *GenericMsg) Payload() interface{}
type Publisher ¶
type Publisher interface { io.Closer Subscribe(opts ...SubscriptionOptions) *Subscription Unsubscribe(sub *Subscription) error Publish(msg Msg) error }
type Subscription ¶
type Subscription struct { SubscriptionOptions Ch chan Msg }
type SubscriptionOptions ¶
type SubscriptionOptions struct { // Buffer is the size of the buffer kept for incoming messages. In case the buffer is full, subsequent messages will // be dropped. The default size of the buffer is 10. Buffer int // LabelMatcher allows subscribers to narrow the selection of messages that they are notified of. // By default there is no matcher; the subscriber will receive all messages published by the publisher. LabelMatcher labels.Matcher }
SubscriptionOptions allow subscribers to customize the type and behaviour of the subscription.
Click to show internal directories.
Click to hide internal directories.