broker

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2021 License: MIT Imports: 5 Imported by: 5

README

CloudEvents

Broker implementation provides queuing, backpressure, filtering

CloudEvents has multiple transports (http, pubsub, kafka...) available

Concepts

Actors
  • Event Source
  • Event Sink
  • Broker
Messaging patterns
  • Fire and Forgot
  • Request and Response

Documentation

Index

Constants

View Source
const (
	DefaultName = "mkit.broker.default"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

type Broker interface {
	Options() Options
	NewPublisher(topic string, opts ...PublishOption) (pub Publisher, err error)
	NewSubscriber(subscription string, hdlr Handler, opts ...SubscribeOption) (sub Subscriber, err error)
	Start() error
	Shutdown() error
}

func NewBroker

func NewBroker(opts ...Option) Broker

NewBroker creates and returns a new Broker based on the packages within.

type Handler added in v0.1.2

type Option

type Option func(*Options)

func Context

func Context(ctx context.Context) Option

Context specifies a context for the service. Can be used to signal shutdown of the service Can be used for extra option values.

func Name

func Name(n string) Option

Name of the service

type Options

type Options struct {
	Name string

	// Alternative options
	Context context.Context
}

type PublishOption added in v0.1.2

type PublishOption func(*PublishOptions)

func PublishAsync added in v0.1.2

func PublishAsync(b bool) PublishOption

func PublishContext added in v0.1.2

func PublishContext(ctx context.Context) PublishOption

PublishContext set context

type PublishOptions added in v0.1.2

type PublishOptions struct {
	// publishes msg to the topic asynchronously if set to true.
	// Default false. i.e., publishes synchronously(blocking)
	Async bool
	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context
}

type Publisher added in v0.1.2

type Publisher interface {
	Publish(ctx context.Context, event event.Event) error
	Stop()
}

type SubscribeOption added in v0.1.2

type SubscribeOption func(*SubscribeOptions)

func SubscribeContext added in v0.1.2

func SubscribeContext(ctx context.Context) SubscribeOption

SubscribeContext set context

type SubscribeOptions added in v0.1.2

type SubscribeOptions struct {
	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context
}

type Subscriber added in v0.1.2

type Subscriber interface {
	Start()
	Stop()
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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