broker

package module
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package broker is an interface used for asynchronous messaging

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

type Broker interface {
	// Init initializes the broker
	Init(opts Options) error
	// Options Returns the broker options
	Options() Options
	// Address Returns the broker bind interface
	Address() string
	// Connect connects to the broker
	Connect() error
	// Disconnect disconnects from the broker
	Disconnect() error
	// Publish publishes a message to the topic
	Publish(topic string, m proto.Message) error
	// Publish publishes raw data to the topic
	PublishRaw(topic string, m []byte) error
	// Subscribe subscribes a handler to the topic
	Subscribe(topic string, h interface{}) (Subscriber, error)
	// SubscribeRaw subscribes a raw handler to the topic
	SubscribeRaw(topic string, h func(c context.Context, data []byte) error) (Subscriber, error)
	// Handle returns the raw connection handle to the broker
	Handle() interface{}
}

Broker is an interface used for asynchronous messaging.

type Message added in v1.0.3

type Message struct {
	Data proto.Message
}

type Options

type Options struct {
	Name    string
	Address string
}

Options is the config for the broker

type Subscriber

type Subscriber interface {
	// Topic returns the subscribed topic
	Topic() string
	// Unsubscribe unsubscribes to the topic
	Unsubscribe() error
}

Subscriber is a convenience return type for the Subscribe method

Directories

Path Synopsis
proto

Jump to

Keyboard shortcuts

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