go-pubsub: github.com/alash3al/go-pubsub Index | Files

package pubsub

import "github.com/alash3al/go-pubsub"

Index

Package Files

broker.go message.go subscriber.go

type Broker Uses

type Broker struct {
    // contains filtered or unexported fields
}

Broker the brocker related meta data

func NewBroker Uses

func NewBroker() *Broker

NewBroker create new broker

func (*Broker) Attach Uses

func (b *Broker) Attach() (*Subscriber, error)

Attach Create a new subscriber and register it into our main broker

func (*Broker) Broadcast Uses

func (b *Broker) Broadcast(payload interface{}, topics ...string)

Broadcast broadcast the specified payload to all the topic(s) subscribers

func (*Broker) Detach Uses

func (b *Broker) Detach(s *Subscriber)

Detach remove the specified subscriber from the broker

func (*Broker) Subscribe Uses

func (b *Broker) Subscribe(s *Subscriber, topics ...string)

Subscribe subscribes the speicifed subscriber "s" to the specified list of topic(s)

func (*Broker) Subscribers Uses

func (b *Broker) Subscribers(topic string) int

Subscribers get the subscribers count

func (*Broker) Unsubscribe Uses

func (b *Broker) Unsubscribe(s *Subscriber, topics ...string)

Unsubscribe unsubscribes the specified subscriber from the specified topic(s)

type Message Uses

type Message struct {
    // contains filtered or unexported fields
}

Message the message metadata

func (*Message) GetCreatedAt Uses

func (m *Message) GetCreatedAt() int64

GetCreatedAt get the creation time of this message

func (*Message) GetPayload Uses

func (m *Message) GetPayload() interface{}

GetPayload get the payload of the current message

func (*Message) GetTopic Uses

func (m *Message) GetTopic() string

GetTopic return the topic of the current message

type Subscriber Uses

type Subscriber struct {
    // contains filtered or unexported fields
}

Subscriber ...

func (*Subscriber) GetCreatedAt Uses

func (s *Subscriber) GetCreatedAt() int64

GetCreatedAt return `time.Time` of the creation time

func (*Subscriber) GetID Uses

func (s *Subscriber) GetID() string

GetID return the subscriber id

func (*Subscriber) GetMessages Uses

func (s *Subscriber) GetMessages() <-chan *Message

GetMessages returns a channel of *Message to listen on

func (*Subscriber) GetTopics Uses

func (s *Subscriber) GetTopics() []string

GetTopics return slice of subscriber topics

func (*Subscriber) Signal Uses

func (s *Subscriber) Signal(m *Message) *Subscriber

Signal sends a message to subscriber

type Subscribers Uses

type Subscribers map[string]*Subscriber

Subscribers ...

Package pubsub imports 4 packages (graph) and is imported by 1 packages. Updated 2018-10-05. Refresh now. Tools for package owners.