emulation

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventEmulator azlog.Event = "emulator"
)

Variables

This section is empty.

Functions

func RequireNoLeaks

func RequireNoLeaks(t *testing.T, events *Events)

Types

type CreditEvent

type CreditEvent struct {
	LinkEvent
	Credit uint32
}

type DispositionEvent

type DispositionEvent struct {
	LinkEvent
	DispType DispositionType
	*amqp.Message
}

type DispositionType

type DispositionType string
const (
	DispositionTypeAccept  DispositionType = "accept"
	DispositionTypeReject  DispositionType = "reject"
	DispositionTypeRelease DispositionType = "release"
	DispositionTypeModify  DispositionType = "modify" // used for abandoning a message
)

type Event

type Event struct {
	Type EventType
	Data any
}

type EventType

type EventType string
const (
	EventTypeConnOpen  EventType = "conn-open"
	EventTypeConnClose EventType = "conn-close"

	EventTypeLinkOpen   EventType = "link-attach"
	EventTypeLinkCredit EventType = "link-issue-credit"
	EventTypeLinkClose  EventType = "link-detach"

	EventTypeLinkDisposition EventType = "link-disposition"

	EventTypeReceive EventType = "link-receive"
	EventTypeSend    EventType = "link-send"
)

type Events

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

func NewEvents

func NewEvents() *Events

func (*Events) All

func (e *Events) All() []Event

func (*Events) Chan

func (e *Events) Chan() <-chan Event

func (*Events) Clear

func (e *Events) Clear()

func (*Events) CloseConnection

func (e *Events) CloseConnection(name string)
func (e *Events) CloseLink(args LinkEvent)

func (*Events) Custom

func (e *Events) Custom(name string, data any)

func (*Events) Disposition

func (e *Events) Disposition(args DispositionEvent)

func (*Events) GetOpenConns

func (e *Events) GetOpenConns() []string
func (e *Events) GetOpenLinks() []string

func (*Events) IssueCredit

func (e *Events) IssueCredit(args CreditEvent)

func (*Events) OpenConnection

func (e *Events) OpenConnection(name string)
func (e *Events) OpenLink(args LinkEvent)

func (*Events) Receive

func (e *Events) Receive(args ReceiveEvent)

func (*Events) Send

func (e *Events) Send(args SendEvent)

type LinkEvent

type LinkEvent struct {
	ConnID        string
	SessID        string
	Entity        string
	Name          string
	Role          LinkRole
	TargetAddress string
}

type LinkRole

type LinkRole string
const (
	LinkRoleReceiver LinkRole = "receiver"
	LinkRoleSender   LinkRole = "sender"
)

type MockConnection

type MockConnection struct {
	Status *Status
	*mock.MockAMQPClient
}

type MockData

type MockData struct {
	Ctrl *gomock.Controller

	Events *Events
	// contains filtered or unexported fields
}

func NewMockData

func NewMockData(t *testing.T, options *MockDataOptions) *MockData

func (*MockData) AllQueues

func (md *MockData) AllQueues() map[string]*Queue

func (*MockData) Close

func (md *MockData) Close()

func (*MockData) DetachReceivers

func (md *MockData) DetachReceivers(entityName string)

func (*MockData) DetachSenders

func (md *MockData) DetachSenders(entityName string)

func (*MockData) NewConnection

func (md *MockData) NewConnection(ctx context.Context) (amqpwrap.AMQPClient, error)

func (*MockData) NewReceiver

func (md *MockData) NewReceiver(ctx context.Context, source string, opts *amqp.ReceiverOptions, sess *MockSession) (amqpwrap.AMQPReceiverCloser, error)

func (*MockData) NewSender

func (md *MockData) NewSender(ctx context.Context, target string, opts *amqp.SenderOptions, sess *MockSession) (amqpwrap.AMQPSenderCloser, error)

func (*MockData) NewTokenProvider

func (md *MockData) NewTokenProvider() auth.TokenProvider

type MockDataOptions

type MockDataOptions struct {
	NewConnectionFn func(orig *mock.MockAMQPClient, ctx context.Context) error

	// PreReceiverMock is called with the mock Receiver instance before we instrument it with
	// our defaults.
	PreReceiverMock func(mr *MockReceiver, ctx context.Context) error

	// PreSenderMock is called with the mock Sender instance before we instrument it with
	// our defaults.
	PreSenderMock func(ms *MockSender, ctx context.Context) error

	// PreSessionMock is called with the mock Session instance before we instrument it with
	// our defaults.
	PreSessionMock func(msess *MockSession, ctx context.Context, opts *amqp.SessionOptions) error
}

type MockReceiver

type MockReceiver struct {
	*mock.MockAMQPReceiverCloser
	Opts          *amqp.ReceiverOptions
	Session       *MockSession
	Source        string
	Status        *Status
	TargetAddress string

	// InternalReceive will receive from our default mock. Useful if you want to
	// change the default EXPECT() for AMQPReceiver.Receive().
	InternalReceive func(ctx context.Context, o *amqp.ReceiveOptions) (*amqp.Message, error)

	// InternalIssueCredit will issue credit for our default mock. Useful if you
	// want to change the default EXPECT() for AMQPReceiver.IssueCredit().
	InternalIssueCredit func(credit uint32) error
}

func (*MockReceiver) Done

func (rcvr *MockReceiver) Done() <-chan error

func (*MockReceiver) LinkEvent

func (rcvr *MockReceiver) LinkEvent() LinkEvent

type MockSender

type MockSender struct {
	*mock.MockAMQPSenderCloser
	Opts    *amqp.SenderOptions
	Session *MockSession
	Status  *Status
	Target  string
}

func (*MockSender) LinkEvent

func (m *MockSender) LinkEvent() LinkEvent

type MockSession

type MockSession struct {
	Status *Status
	*mock.MockAMQPSession

	ID   string
	Conn *MockConnection
}

func (*MockSession) Done

func (sess *MockSession) Done() <-chan error

type Operation

type Operation struct {
	Op       string
	Entity   string
	LinkName string
	Role     string

	Credits uint32
	M       *amqp.Message
}

func (*Operation) String

func (op *Operation) String() string

type Queue

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

func NewQueue

func NewQueue(name string, events *Events) *Queue

func (*Queue) AcceptMessage

func (q *Queue) AcceptMessage(ctx context.Context, msg *amqp.Message, evt LinkEvent, status *Status) error

func (*Queue) Close

func (q *Queue) Close()

func (*Queue) IssueCredit

func (q *Queue) IssueCredit(credit uint32, evt LinkEvent, status *Status) error

func (*Queue) ModifyMessage

func (q *Queue) ModifyMessage(ctx context.Context, msg *amqp.Message, options *amqp.ModifyMessageOptions, evt LinkEvent) error

func (*Queue) Receive

func (q *Queue) Receive(ctx context.Context, evt LinkEvent, status *Status) (*amqp.Message, error)

func (*Queue) RejectMessage

func (q *Queue) RejectMessage(ctx context.Context, msg *amqp.Message, e *amqp.Error, evt LinkEvent, status *Status) error

func (*Queue) ReleaseMessage

func (q *Queue) ReleaseMessage(ctx context.Context, msg *amqp.Message, evt LinkEvent) error

func (*Queue) Send

func (q *Queue) Send(ctx context.Context, tempMsg *amqp.Message, evt LinkEvent, status *Status) error

type ReceiveEvent

type ReceiveEvent struct {
	LinkEvent
	*amqp.Message
}

type SendEvent

type SendEvent struct {
	LinkEvent
	*amqp.Message
}

type Status

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

func NewStatus

func NewStatus(parent *Status) *Status

func (*Status) CloseWithError

func (s *Status) CloseWithError(err error)

func (*Status) Done

func (s *Status) Done() <-chan struct{}

func (*Status) Err

func (s *Status) Err() error

Jump to

Keyboard shortcuts

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