pubsub

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DocEvent

type DocEvent struct {
	Type      types.EventType
	DocKey    string
	Publisher *time.ActorID
}

DocEvent represents events that occur related to the document.

type PubSub

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

PubSub is a structure to support event publishing/subscription. TODO: Temporary Memory PubSub.

  • We will need to replace this with distributed pubSub.

func New

func New() *PubSub

New creates an instance of Pubsub.

func (*PubSub) Publish

func (m *PubSub) Publish(
	publisher *time.ActorID,
	topic string,
	event DocEvent,
)

Publish publishes the given event to the given Topic.

func (*PubSub) Subscribe

func (m *PubSub) Subscribe(
	subscriber *time.ActorID,
	topics []string,
) (*Subscription, map[string][]string, error)

Subscribe subscribes to the given topics.

func (*PubSub) Unsubscribe

func (m *PubSub) Unsubscribe(topics []string, sub *Subscription)

Unsubscribe unsubscribes the given topics.

type Subscription

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

Subscription represents the subscription of a subscriber. It is used across several topics.

func (*Subscription) Close

func (s *Subscription) Close()

Close closes all resources of this Subscription.

func (*Subscription) Events

func (s *Subscription) Events() <-chan DocEvent

Events returns the DocEvent channel of this subscription.

func (*Subscription) Subscriber

func (s *Subscription) Subscriber() *time.ActorID

Subscriber returns the subscriber of this subscription.

func (*Subscription) SubscriberID

func (s *Subscription) SubscriberID() string

SubscriberID returns string representation of the subscriber.

type Subscriptions

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

Subscriptions is a collection of subscriptions that subscribe to a specific topic.

func (*Subscriptions) Add

func (s *Subscriptions) Add(sub *Subscription)

Add adds the given subscription.

func (*Subscriptions) Delete

func (s *Subscriptions) Delete(id string)

Delete deletes the subscription of the given id.

func (*Subscriptions) Map

func (s *Subscriptions) Map() map[string]*Subscription

Map returns the internal map of this Subscriptions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL