commandbus

package
v0.0.0-...-da8027b Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package commandbus is a generated GoMock package.

Package commandbus is a generated GoMock package.

Package commandbus is a generated GoMock package.

Package commandbus is a generated GoMock package.

Index

Constants

View Source
const WildcardCorrelationID = stream.CorrelationID("*")

Variables

View Source
var (
	ErrUnknownStreamType = errors.New("unknown stream type")
	ErrReplyTimeout      = errors.New("reply timeout")
	ErrNoCorrelationID   = errors.New("no correlation id")
	ErrNoCommand         = errors.New("no command")
	ErrFailedToSendReply = errors.New("failed to send a reply")
)

Functions

func ChannelBuilder

func ChannelBuilder(st stream.Type) string

func ReplyChannelBuilder

func ReplyChannelBuilder(st stream.Type) string

Types

type Bus

type Bus interface {
	Sender
	Replier
	Receiver
}

func New

func New(s Sender, r Receiver, rr Replier, o ...Option) Bus

type Duplicator

type Duplicator interface {
	Has(context.Context, stream.Command) bool
	Ensure(context.Context, stream.Command) error
}

func NewNopDuplicator

func NewNopDuplicator() Duplicator

type Envelope

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

func NewEnvelope

func NewEnvelope(command codec.Codec, reply codec.Codec) *Envelope

func (*Envelope) DecodeCommand

func (e *Envelope) DecodeCommand(ctx context.Context, bytes []byte) (stream.Command, error)

func (*Envelope) DecodeReply

func (e *Envelope) DecodeReply(ctx context.Context, bytes []byte) (*stream.Reply, error)

func (*Envelope) EncodeCommand

func (e *Envelope) EncodeCommand(ctx context.Context, cmd stream.Command) ([]byte, error)

func (*Envelope) EncodeReply

func (e *Envelope) EncodeReply(ctx context.Context, r *stream.Reply) ([]byte, error)

type Error

type Error struct {
	StreamType  stream.Type
	StreamID    stream.ID
	CommandType stream.CommandType
	Err         error
	Context     error
}

func (*Error) Error

func (e *Error) Error() string

type MockDuplicator

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

MockDuplicator is a mock of Duplicator interface

func NewMockDuplicator

func NewMockDuplicator(ctrl *gomock.Controller) *MockDuplicator

NewMockDuplicator creates a new mock instance

func (*MockDuplicator) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockDuplicator) Ensure

func (m *MockDuplicator) Ensure(arg0 context.Context, arg1 stream.Command) error

Ensure mocks base method

func (*MockDuplicator) Has

func (m *MockDuplicator) Has(arg0 context.Context, arg1 stream.Command) bool

Has mocks base method

type MockDuplicatorMockRecorder

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

MockDuplicatorMockRecorder is the mock recorder for MockDuplicator

func (*MockDuplicatorMockRecorder) Ensure

func (mr *MockDuplicatorMockRecorder) Ensure(arg0, arg1 interface{}) *gomock.Call

Ensure indicates an expected call of Ensure

func (*MockDuplicatorMockRecorder) Has

func (mr *MockDuplicatorMockRecorder) Has(arg0, arg1 interface{}) *gomock.Call

Has indicates an expected call of Has

type MockReceiver

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

MockReceiver is a mock of Receiver interface

func NewMockReceiver

func NewMockReceiver(ctrl *gomock.Controller) *MockReceiver

NewMockReceiver creates a new mock instance

func (*MockReceiver) Close

func (m *MockReceiver) Close() error

Close mocks base method

func (*MockReceiver) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockReceiver) ListReceivers

func (m *MockReceiver) ListReceivers() []string

ListReceivers mocks base method

func (*MockReceiver) Receive

func (m *MockReceiver) Receive(arg0 context.Context, arg1 stream.Type, arg2 ReceiverHandler) error

Receive mocks base method

func (*MockReceiver) UnReceive

func (m *MockReceiver) UnReceive(arg0 context.Context, arg1 stream.Type) error

UnReceive mocks base method

type MockReceiverHandler

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

MockReceiverHandler is a mock of ReceiverHandler interface

func NewMockReceiverHandler

func NewMockReceiverHandler(ctrl *gomock.Controller) *MockReceiverHandler

NewMockReceiverHandler creates a new mock instance

func (*MockReceiverHandler) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockReceiverHandler) Receive

func (m *MockReceiverHandler) Receive(arg0 context.Context, arg1 stream.Command) (*stream.Reply, error)

Receive mocks base method

type MockReceiverHandlerMockRecorder

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

MockReceiverHandlerMockRecorder is the mock recorder for MockReceiverHandler

func (*MockReceiverHandlerMockRecorder) Receive

func (mr *MockReceiverHandlerMockRecorder) Receive(arg0, arg1 interface{}) *gomock.Call

Receive indicates an expected call of Receive

type MockReceiverMockRecorder

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

MockReceiverMockRecorder is the mock recorder for MockReceiver

func (*MockReceiverMockRecorder) Close

func (mr *MockReceiverMockRecorder) Close() *gomock.Call

Close indicates an expected call of Close

func (*MockReceiverMockRecorder) ListReceivers

func (mr *MockReceiverMockRecorder) ListReceivers() *gomock.Call

ListReceivers indicates an expected call of ListReceivers

func (*MockReceiverMockRecorder) Receive

func (mr *MockReceiverMockRecorder) Receive(arg0, arg1, arg2 interface{}) *gomock.Call

Receive indicates an expected call of Receive

func (*MockReceiverMockRecorder) UnReceive

func (mr *MockReceiverMockRecorder) UnReceive(arg0, arg1 interface{}) *gomock.Call

UnReceive indicates an expected call of UnReceive

type MockReplier

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

MockReplier is a mock of Replier interface

func NewMockReplier

func NewMockReplier(ctrl *gomock.Controller) *MockReplier

NewMockReplier creates a new mock instance

func (*MockReplier) Close

func (m *MockReplier) Close() error

Close mocks base method

func (*MockReplier) EXPECT

func (m *MockReplier) EXPECT() *MockReplierMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockReplier) HasReplyReceiver

func (m *MockReplier) HasReplyReceiver(ctx context.Context, cid stream.CorrelationID) bool

HasReplyReceiver mocks base method

func (*MockReplier) ListenReply

func (m *MockReplier) ListenReply(arg0 context.Context) error

ListenReply mocks base method

func (*MockReplier) ReceiveReply

func (m *MockReplier) ReceiveReply(arg0 context.Context, arg1 stream.CorrelationID, arg2 ReplyReceiver)

ReceiveReply mocks base method

func (*MockReplier) RemoveReplyReceiver

func (m *MockReplier) RemoveReplyReceiver(ctx context.Context, cid stream.CorrelationID)

RemoveReplyReceiver mocks base method

func (*MockReplier) SendAndWaitReply

func (m *MockReplier) SendAndWaitReply(arg0 context.Context, arg1 stream.Command) (*stream.Reply, error)

SendAndWaitReply mocks base method

func (*MockReplier) SendCommandWithReply

func (m *MockReplier) SendCommandWithReply(arg0 context.Context, arg1 stream.Command) error

SendCommandWithReply mocks base method

func (*MockReplier) SendReply

func (m *MockReplier) SendReply(arg0 context.Context, arg1 *stream.Reply) error

SendReply mocks base method

type MockReplierMockRecorder

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

MockReplierMockRecorder is the mock recorder for MockReplier

func (*MockReplierMockRecorder) Close

func (mr *MockReplierMockRecorder) Close() *gomock.Call

Close indicates an expected call of Close

func (*MockReplierMockRecorder) HasReplyReceiver

func (mr *MockReplierMockRecorder) HasReplyReceiver(ctx, cid interface{}) *gomock.Call

HasReplyReceiver indicates an expected call of HasReplyReceiver

func (*MockReplierMockRecorder) ListenReply

func (mr *MockReplierMockRecorder) ListenReply(arg0 interface{}) *gomock.Call

ListenReply indicates an expected call of ListenReply

func (*MockReplierMockRecorder) ReceiveReply

func (mr *MockReplierMockRecorder) ReceiveReply(arg0, arg1, arg2 interface{}) *gomock.Call

ReceiveReply indicates an expected call of ReceiveReply

func (*MockReplierMockRecorder) RemoveReplyReceiver

func (mr *MockReplierMockRecorder) RemoveReplyReceiver(ctx, cid interface{}) *gomock.Call

RemoveReplyReceiver indicates an expected call of RemoveReplyReceiver

func (*MockReplierMockRecorder) SendAndWaitReply

func (mr *MockReplierMockRecorder) SendAndWaitReply(arg0, arg1 interface{}) *gomock.Call

SendAndWaitReply indicates an expected call of SendAndWaitReply

func (*MockReplierMockRecorder) SendCommandWithReply

func (mr *MockReplierMockRecorder) SendCommandWithReply(arg0, arg1 interface{}) *gomock.Call

SendCommandWithReply indicates an expected call of SendCommandWithReply

func (*MockReplierMockRecorder) SendReply

func (mr *MockReplierMockRecorder) SendReply(arg0, arg1 interface{}) *gomock.Call

SendReply indicates an expected call of SendReply

type MockReplyReceiver

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

MockReplyReceiver is a mock of ReplyReceiver interface

func NewMockReplyReceiver

func NewMockReplyReceiver(ctrl *gomock.Controller) *MockReplyReceiver

NewMockReplyReceiver creates a new mock instance

func (*MockReplyReceiver) Close

func (m *MockReplyReceiver) Close() error

Close mocks base method

func (*MockReplyReceiver) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockReplyReceiver) ReceiveReply

func (m *MockReplyReceiver) ReceiveReply(arg0 context.Context, arg1 *stream.Reply) error

ReceiveReply mocks base method

type MockReplyReceiverMockRecorder

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

MockReplyReceiverMockRecorder is the mock recorder for MockReplyReceiver

func (*MockReplyReceiverMockRecorder) Close

Close indicates an expected call of Close

func (*MockReplyReceiverMockRecorder) ReceiveReply

func (mr *MockReplyReceiverMockRecorder) ReceiveReply(arg0, arg1 interface{}) *gomock.Call

ReceiveReply indicates an expected call of ReceiveReply

type MockSender

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

MockSender is a mock of Sender interface

func NewMockSender

func NewMockSender(ctrl *gomock.Controller) *MockSender

NewMockSender creates a new mock instance

func (*MockSender) Close

func (m *MockSender) Close() error

Close mocks base method

func (*MockSender) EXPECT

func (m *MockSender) EXPECT() *MockSenderMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockSender) SendCommand

func (m *MockSender) SendCommand(arg0 context.Context, arg1 stream.Command) error

SendCommand mocks base method

type MockSenderMockRecorder

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

MockSenderMockRecorder is the mock recorder for MockSender

func (*MockSenderMockRecorder) Close

func (mr *MockSenderMockRecorder) Close() *gomock.Call

Close indicates an expected call of Close

func (*MockSenderMockRecorder) SendCommand

func (mr *MockSenderMockRecorder) SendCommand(arg0, arg1 interface{}) *gomock.Call

SendCommand indicates an expected call of SendCommand

type Option

type Option func(*bus)

func WithReceiverMiddleware

func WithReceiverMiddleware(m ...ReceiverMiddleware) Option

func WithReplierMiddleware

func WithReplierMiddleware(m ...ReplierMiddleware) Option

func WithReplyReceiverMiddleware

func WithReplyReceiverMiddleware(m ...ReplyReceiverMiddleware) Option

func WithSenderMiddleware

func WithSenderMiddleware(m ...SenderMiddleware) Option

type Receiver

type Receiver interface {
	ListReceivers() []string
	Receive(context.Context, stream.Type, ReceiverHandler) error
	UnReceive(context.Context, stream.Type) error
	Close() error
}

func NewReceiver

func NewReceiver(
	s messaging.Sender,
	r messaging.Receiver,
	e *Envelope,
	o ...ReceiverOption,
) Receiver

type ReceiverCollector

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

func (*ReceiverCollector) Receive

func (rc *ReceiverCollector) Receive(ctx context.Context, cmd stream.Command) (r *stream.Reply, err error)

type ReceiverHandler

type ReceiverHandler interface {
	Receive(context.Context, stream.Command) (*stream.Reply, error)
}

func Endpoint

func Endpoint(e endpoint.Endpoint) ReceiverHandler

type ReceiverHandlerFunc

type ReceiverHandlerFunc func(context.Context, stream.Command) (*stream.Reply, error)

func (ReceiverHandlerFunc) Receive

type ReceiverLogging

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

func (*ReceiverLogging) Receive

func (l *ReceiverLogging) Receive(ctx context.Context, cmd stream.Command) (r *stream.Reply, err error)

type ReceiverMetrics

type ReceiverMetrics struct {
	Counter   metrics.Counter
	Histogram metrics.Histogram
}

func (*ReceiverMetrics) Observe

func (r *ReceiverMetrics) Observe(st stream.Type, ct stream.CommandType, start time.Time)

type ReceiverMiddleware

type ReceiverMiddleware func(ReceiverHandler) ReceiverHandler

func NewReceiverCollector

func NewReceiverCollector(m *ReceiverMetrics) ReceiverMiddleware

func NewReceiverLogging

func NewReceiverLogging(l log.Logger) ReceiverMiddleware

type ReceiverOption

type ReceiverOption func(*receiver)

func ReceiverDuplicator

func ReceiverDuplicator(d Duplicator) ReceiverOption

func ReceiverErrorHandler

func ReceiverErrorHandler(h messaging.ErrorHandler) ReceiverOption

type Replier

type Replier interface {
	ReceiveReply(context.Context, stream.CorrelationID, ReplyReceiver)
	SendReply(context.Context, *stream.Reply) error
	SendAndWaitReply(context.Context, stream.Command) (*stream.Reply, error)
	SendCommandWithReply(context.Context, stream.Command) error
	RemoveReplyReceiver(ctx context.Context, cid stream.CorrelationID)
	HasReplyReceiver(ctx context.Context, cid stream.CorrelationID) bool
	ListenReply(context.Context) error
	Close() error
}

func NewReplier

func NewReplier(
	s messaging.Sender,
	r messaging.Receiver,
	replyTo stream.Type,
	e *Envelope,
	o ...ReplierOption,
) Replier

type ReplierCollector

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

func (*ReplierCollector) Close

func (c *ReplierCollector) Close() error

func (*ReplierCollector) HasReplyReceiver

func (c *ReplierCollector) HasReplyReceiver(ctx context.Context, cid stream.CorrelationID) bool

func (*ReplierCollector) ListenReply

func (c *ReplierCollector) ListenReply(ctx context.Context) error

func (*ReplierCollector) ReceiveReply

func (c *ReplierCollector) ReceiveReply(ctx context.Context, cid stream.CorrelationID, r ReplyReceiver)

func (*ReplierCollector) RemoveReplyReceiver

func (c *ReplierCollector) RemoveReplyReceiver(ctx context.Context, cid stream.CorrelationID)

func (*ReplierCollector) SendAndWaitReply

func (c *ReplierCollector) SendAndWaitReply(ctx context.Context, cmd stream.Command) (r *stream.Reply, err error)

func (*ReplierCollector) SendCommandWithReply

func (c *ReplierCollector) SendCommandWithReply(ctx context.Context, cmd stream.Command) (err error)

func (*ReplierCollector) SendReply

func (c *ReplierCollector) SendReply(ctx context.Context, r *stream.Reply) (err error)

type ReplierMetrics

type ReplierMetrics struct {
	TimeoutCounter   metrics.Counter
	TimeoutHistogram metrics.Histogram

	Counter   metrics.Counter
	Histogram metrics.Histogram

	SendReplyCounter   metrics.Counter
	SendReplyHistogram metrics.Histogram
}

func (*ReplierMetrics) Observe

func (r *ReplierMetrics) Observe(st stream.Type, ct stream.CommandType, start time.Time)

func (*ReplierMetrics) SendReplyObserve

func (r *ReplierMetrics) SendReplyObserve(st stream.Type, ct stream.CommandType, rr stream.ReplyType, start time.Time)

func (*ReplierMetrics) TimeoutObserve

func (r *ReplierMetrics) TimeoutObserve(st stream.Type, ct stream.CommandType, start time.Time)

type ReplierMiddleware

type ReplierMiddleware func(Replier) Replier

func NewReplierCollector

func NewReplierCollector(m *ReplierMetrics) ReplierMiddleware

type ReplierOption

type ReplierOption func(r *replier)

func ReplierChannelBuilder

func ReplierChannelBuilder(cb messaging.ChannelBuilderFunc) ReplierOption

func ReplierErrorHandler

func ReplierErrorHandler(h messaging.ErrorHandler) ReplierOption

func ReplierReplyChannelBuilder

func ReplierReplyChannelBuilder(cb messaging.ChannelBuilderFunc) ReplierOption

func ReplierReplyTimeout

func ReplierReplyTimeout(dur time.Duration) ReplierOption

type ReplyReceiver

type ReplyReceiver interface {
	ReceiveReply(context.Context, *stream.Reply) error
	Close() error
}

type ReplyReceiverCollector

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

func (*ReplyReceiverCollector) Close

func (rc *ReplyReceiverCollector) Close() error

func (*ReplyReceiverCollector) ReceiveReply

func (rc *ReplyReceiverCollector) ReceiveReply(ctx context.Context, r *stream.Reply) (err error)

type ReplyReceiverFunc

type ReplyReceiverFunc func(context.Context, *stream.Reply) error

func (ReplyReceiverFunc) Close

func (r ReplyReceiverFunc) Close() error

func (ReplyReceiverFunc) ReceiveReply

func (r ReplyReceiverFunc) ReceiveReply(ctx context.Context, reply *stream.Reply) error

type ReplyReceiverLogging

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

func (*ReplyReceiverLogging) Close

func (l *ReplyReceiverLogging) Close() error

func (*ReplyReceiverLogging) ReceiveReply

func (l *ReplyReceiverLogging) ReceiveReply(ctx context.Context, r *stream.Reply) (err error)

type ReplyReceiverMetrics

type ReplyReceiverMetrics struct {
	Counter   metrics.Counter
	Histogram metrics.Histogram
}

func (*ReplyReceiverMetrics) Observe

func (r *ReplyReceiverMetrics) Observe(st stream.Type, ct stream.CommandType, rr stream.ReplyType, start time.Time)

type SendReplier

type SendReplier interface {
	Sender
	Replier
}

type Sender

type Sender interface {
	SendCommand(context.Context, stream.Command) error
	Close() error
}

func NewSender

func NewSender(s messaging.Sender, e *Envelope, o ...SenderOption) Sender

type SenderCollector

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

func (*SenderCollector) Close

func (s *SenderCollector) Close() error

func (*SenderCollector) SendCommand

func (s *SenderCollector) SendCommand(ctx context.Context, cmd stream.Command) (err error)

type SenderMetrics

type SenderMetrics struct {
	Counter   metrics.Counter
	Histogram metrics.Histogram
}

func (*SenderMetrics) Observe

func (r *SenderMetrics) Observe(st stream.Type, ct stream.CommandType, start time.Time)

type SenderMiddleware

type SenderMiddleware func(Sender) Sender

func NewSenderCollector

func NewSenderCollector(m *SenderMetrics) SenderMiddleware

type SenderOption

type SenderOption func(*sender)

func SenderChannelBuilder

func SenderChannelBuilder(cb messaging.ChannelBuilderFunc) SenderOption

Directories

Path Synopsis
Package pb is a generated protocol buffer package.
Package pb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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