xpubsub

package
v0.0.16 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// SubTopicCtxKey is the key for the subscription topic.
	SubTopicCtxKey = subscriptionCtx("sub:topic")
	// SubIdCtxKey is the key for the subscription id.
	SubIdCtxKey = subscriptionCtx("sub:id")
)

Functions

func MarshalMessage

func MarshalMessage(c codec.Codec, msg interface{}) (*pubsub.Message, error)

MarshalMessage is a function that marshals input message structure into the pubsub.Message body.

func UnmarshalMessage

func UnmarshalMessage(c codec.Codec, msg *pubsub.Message, dst interface{}) error

UnmarshalMessage unmarshals message body into provided destination using given codec.

Types

type ChainHandler

type ChainHandler struct {
	Middlewares Middlewares
	Endpoint    Handler
	// contains filtered or unexported fields
}

ChainHandler is a http.Handler with support for handler composition and execution.

func (*ChainHandler) Handle

func (c *ChainHandler) Handle(ctx context.Context, m *pubsub.Message) error

Handle implements Handler interface.

type Handler

type Handler interface {
	Handle(ctx context.Context, m *pubsub.Message) error
}

Handler is an interface used by the Mux that is responsible for handling the Message.

type HandlerFunc

type HandlerFunc func(ctx context.Context, m *pubsub.Message) error

HandlerFunc is a function used to handle messages.

func (HandlerFunc) Handle

func (h HandlerFunc) Handle(ctx context.Context, m *pubsub.Message) error

Handle implements Handler interface.

type MessageTyper added in v0.0.6

type MessageTyper interface {
	MessageType() string
}

MessageTyper is an interface used by the event messages that defines the type of the message.

type Middleware

type Middleware func(next Handler) Handler

Middleware is a middleware function type.

type Middlewares

type Middlewares []Middleware

Middlewares is a slice of middlewares.

func (Middlewares) Handler

func (mws Middlewares) Handler(h Handler) Handler

func (Middlewares) HandlerFunc

func (mws Middlewares) HandlerFunc(h HandlerFunc) Handler

type Topic

type Topic interface {
	Send(ctx context.Context, m *pubsub.Message) error
	Shutdown(ctx context.Context) error
	ErrorAs(err error, i interface{}) bool
	As(i interface{}) bool
}

Topic is the interface implementation of the pubsub.Topic. It allows to easily mockup the pubsub.Topic by replacing direct implementation.

type TopicPublisher added in v0.0.6

type TopicPublisher struct {
	Topic Topic
	Codec codec.Codec
}

TopicPublisher is a structure responsible for publishing new topic messages.

func (*TopicPublisher) Publish added in v0.0.6

func (t *TopicPublisher) Publish(ctx context.Context, msg MessageTyper) error

Publish prepares pubsub.Message with the context stored metadata and publishes into given topic.

Directories

Path Synopsis
Package pubsubmock is a generated GoMock package.
Package pubsubmock is a generated GoMock package.

Jump to

Keyboard shortcuts

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