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
}

func NewBroker Uses

func NewBroker() *Broker

create new broker

func (*Broker) Attach Uses

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

Create a new subscriber and register it into our main broker

func (*Broker) Broadcast Uses

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

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

func (*Broker) Detach Uses

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

remove the specified subscriber from the broker

func (*Broker) Subscribe Uses

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

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

func (*Broker) Subscribers Uses

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

get the subscribers count

func (*Broker) Unsubscribe Uses

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

unsubscribes the specified subscriber from the specified topic(s)

type Message Uses

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

func (*Message) GetCreatedAt Uses

func (m *Message) GetCreatedAt() int64

get the creation time of this message

func (*Message) GetPayload Uses

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

to get the payload of the current message

func (*Message) GetTopic Uses

func (m *Message) GetTopic() string

to return the topic of the current message

type Subscriber Uses

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

func (*Subscriber) GetCreatedAt Uses

func (s *Subscriber) GetCreatedAt() int64

return `time.Time` of the creation time

func (*Subscriber) GetID Uses

func (s *Subscriber) GetID() string

return the subscriber id

func (*Subscriber) GetMessages Uses

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

returns a channel of *Message to listen on

func (*Subscriber) GetTopics Uses

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

return slice of subscriber topics

func (*Subscriber) Signal Uses

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

sends a message to subscriber

type Subscribers Uses

type Subscribers map[string]*Subscriber

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