xpubsub

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2021 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// SubscriptionSubjectCtxKey is the key for the subscription topic.
	SubscriptionSubjectCtxKey = subscriptionCtx("pubsub:subject")
	// SubscriptionIdCtxKey is the key for the subscription id.
	SubscriptionIdCtxKey = subscriptionCtx("pubsub:id")
	// MessageTimestampKey is the key for the message timestamp.
	MessageTimestampKey = subscriptionCtx("pubsub:msg.timestamp")
	// MessageSequenceKey is the key for the message timestamp.
	MessageSequenceKey = subscriptionCtx("pubsub:msg.sequence")
)

Functions

func CtxGetMessageSequence added in v0.0.19

func CtxGetMessageSequence(ctx context.Context) (int64, bool)

CtxGetMessageSequence gets the message sequence from the context.

func CtxGetMessageTimestamp added in v0.0.19

func CtxGetMessageTimestamp(ctx context.Context) (time.Time, bool)

CtxGetMessageTimestamp gets the message timestamp from the context.

func CtxSetMessageSequence added in v0.0.19

func CtxSetMessageSequence(ctx context.Context, seq int64) context.Context

CtxSetMessageSequence sets the message sequence in the context,

func CtxSetMessageTimestamp added in v0.0.19

func CtxSetMessageTimestamp(ctx context.Context, timestamp time.Time) context.Context

CtxSetMessageTimestamp sets the message timestamp in the context.

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 SubjectSubscription added in v0.0.27

type SubjectSubscription struct {
	Subject      string
	Subscription *pubsub.Subscription
}

SubjectSubscription is the structure that contains both the subject and related subscription. It is used by the mux to define a human-readable version of the subscription. The subject should be the URL formatted subject of specific pubsub driver that matches given subscription.

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.
pubsubmiddleware

Jump to

Keyboard shortcuts

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