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

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 broker 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) GetTopics Uses

func (b *Broker) GetTopics() []string

GetTopics Returns a slice of topics

func (*Broker) Subscribe Uses

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

Subscribe subscribes the specified 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 Unsubscribe 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 NewSubscriber Uses

func NewSubscriber() (*Subscriber, error)

NewSubscriber returns a new subscriber

func (*Subscriber) AddTopic Uses

func (s *Subscriber) AddTopic(topic string)

AddTopic Adds a new topic to the 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) RemoveTopic Uses

func (s *Subscriber) RemoveTopic(topic string)

RemoveTopic Removes a topic from the subscriber

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 ...

Directories

PathSynopsis
example

Package pubsub imports 4 packages (graph) and is imported by 4 packages. Updated 2020-04-14. Refresh now. Tools for package owners.