pubsub

package
v0.0.0-...-c8fab7d Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

type Broker struct {
	pb.UnimplementedPubSubServiceServer
	// contains filtered or unexported fields
}

func NewBroker

func NewBroker(port string) *Broker

func (*Broker) Publish

func (b *Broker) Publish(ctx context.Context, in *pb.PublishRequest) (*pb.PublishResponse, error)

func (*Broker) Start

func (b *Broker) Start() error

func (*Broker) Stop

func (b *Broker) Stop() error

func (*Broker) Subscribe

func (b *Broker) Subscribe(in *pb.SubscribeRequest, stream pb.PubSubService_SubscribeServer) error

func (*Broker) Unsubscribe

func (b *Broker) Unsubscribe(ctx context.Context, in *pb.UnsubscribeRequest) (*pb.UnsubscribeResponse, error)

type Consumer

type Consumer struct {
	ID uint32

	Messages chan *pb.Message // Channel to receive messages from the broker.
	// contains filtered or unexported fields
}

func NewConsumer

func NewConsumer(brokerAddress string) (*Consumer, error)

NewConsumer creates a new consumer which connects to the broker at the given address.

func (*Consumer) Close

func (c *Consumer) Close() error

func (*Consumer) Subscribe

func (c *Consumer) Subscribe(topic string) error

Subscribe subscribes to the given topic.

func (*Consumer) Unsubscribe

func (c *Consumer) Unsubscribe(topic string) error

Unsubscribe unsubscribes from the given topic.

type Publisher

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

func NewPublisher

func NewPublisher(brokerAddress string) (*Publisher, error)

NewPublisher creates a new publisher which connects to the broker at the given address.

func (*Publisher) Close

func (p *Publisher) Close() error

Close closes the publisher connection.

func (*Publisher) Publish

func (p *Publisher) Publish(topic string, message []byte) error

Publish publishes a message to the given topic.

Jump to

Keyboard shortcuts

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