client

package
v0.35.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package client is a generated GoMock package.

Index

Constants

View Source
const (
	// JSONContentType represents the json content type of queue message.
	JSONContentType = "application/json"
)

Variables

View Source
var (
	// ErrDequeuedMessage represents the error when message has already been dequeued.
	ErrDequeuedMessage = errors.New("message was dequeued by the other client")

	// ErrMessageNotFound represents the error when queue is empty or all messages are leased by clients.
	ErrMessageNotFound = errors.New("queue is empty or messages are leased")

	// ErrInvalidMessage represents the error when the message has already been requeued.
	ErrInvalidMessage = errors.New("this message has been requeued or deleted")

	// ErrUnsupportedContentType represents the error when the content type is unsupported.
	ErrUnsupportedContentType = errors.New("this message content type is unsupported")

	// ErrEmptyMessage represents nil or empty Message.
	ErrEmptyMessage = errors.New("message must not be nil or message is empty")
)

Functions

func StartDequeuer

func StartDequeuer(ctx context.Context, cli Client, opts ...DequeueOptions) (<-chan *Message, error)

StartDequeuer starts a dequeuer to consume the message from the queue and return the output channel.

Types

type Client

type Client interface {
	// Enqueue enqueues message to queue.
	Enqueue(ctx context.Context, msg *Message, opts ...EnqueueOptions) error

	// Dequeue dequeues message from queue.
	Dequeue(ctx context.Context, cfg QueueClientConfig) (*Message, error)

	// FinishMessage finishes or deletes the message in the queue.
	FinishMessage(ctx context.Context, msg *Message) error

	// ExtendMessage extends the message lock.
	ExtendMessage(ctx context.Context, msg *Message) error
}

Client is an interface to implement queue operations.

type DequeueOptions

type DequeueOptions interface {
	// ApplyDequeueOption applies DequeueOptions to QueueClientConfig.
	ApplyDequeueOption(QueueClientConfig) QueueClientConfig
	// contains filtered or unexported methods
}

func WithDequeueInterval

func WithDequeueInterval(t time.Duration) DequeueOptions

WithDequeueInterval sets dequeueing interval.

type EnqueueOptions

type EnqueueOptions interface {
	// contains filtered or unexported methods
}

EnqueueOptions applies an option to Enqueue().

type Message

type Message struct {
	Metadata

	ContentType string
	Data        []byte
}

Message represents message managed by queue.

func NewMessage

func NewMessage(data any) *Message

NewMessage creates Message.

type Metadata

type Metadata struct {
	// ID represents the unique id of message.
	ID string
	// DequeueCount represents the number of dequeue.
	DequeueCount int
	// EnqueueAt represents the time when enqueuing the message
	EnqueueAt time.Time
	// ExpireAt represents the expiry of the message.
	ExpireAt time.Time
	// NextVisibleAt represents the next visible time after dequeuing the message.
	NextVisibleAt time.Time
}

Metadata represents the metadata of queue message.

type MockClient

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

MockClient is a mock of Client interface.

func NewMockClient

func NewMockClient(ctrl *gomock.Controller) *MockClient

NewMockClient creates a new mock instance.

func (*MockClient) Dequeue

func (m *MockClient) Dequeue(arg0 context.Context, arg1 QueueClientConfig) (*Message, error)

Dequeue mocks base method.

func (*MockClient) EXPECT

func (m *MockClient) EXPECT() *MockClientMockRecorder

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

func (*MockClient) Enqueue

func (m *MockClient) Enqueue(arg0 context.Context, arg1 *Message, arg2 ...EnqueueOptions) error

Enqueue mocks base method.

func (*MockClient) ExtendMessage

func (m *MockClient) ExtendMessage(arg0 context.Context, arg1 *Message) error

ExtendMessage mocks base method.

func (*MockClient) FinishMessage

func (m *MockClient) FinishMessage(arg0 context.Context, arg1 *Message) error

FinishMessage mocks base method.

type MockClientDequeueCall added in v0.35.0

type MockClientDequeueCall struct {
	*gomock.Call
}

MockClientDequeueCall wrap *gomock.Call

func (*MockClientDequeueCall) Do added in v0.35.0

Do rewrite *gomock.Call.Do

func (*MockClientDequeueCall) DoAndReturn added in v0.35.0

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockClientDequeueCall) Return added in v0.35.0

func (c *MockClientDequeueCall) Return(arg0 *Message, arg1 error) *MockClientDequeueCall

Return rewrite *gomock.Call.Return

type MockClientEnqueueCall added in v0.35.0

type MockClientEnqueueCall struct {
	*gomock.Call
}

MockClientEnqueueCall wrap *gomock.Call

func (*MockClientEnqueueCall) Do added in v0.35.0

Do rewrite *gomock.Call.Do

func (*MockClientEnqueueCall) DoAndReturn added in v0.35.0

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockClientEnqueueCall) Return added in v0.35.0

Return rewrite *gomock.Call.Return

type MockClientExtendMessageCall added in v0.35.0

type MockClientExtendMessageCall struct {
	*gomock.Call
}

MockClientExtendMessageCall wrap *gomock.Call

func (*MockClientExtendMessageCall) Do added in v0.35.0

Do rewrite *gomock.Call.Do

func (*MockClientExtendMessageCall) DoAndReturn added in v0.35.0

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockClientExtendMessageCall) Return added in v0.35.0

Return rewrite *gomock.Call.Return

type MockClientFinishMessageCall added in v0.35.0

type MockClientFinishMessageCall struct {
	*gomock.Call
}

MockClientFinishMessageCall wrap *gomock.Call

func (*MockClientFinishMessageCall) Do added in v0.35.0

Do rewrite *gomock.Call.Do

func (*MockClientFinishMessageCall) DoAndReturn added in v0.35.0

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockClientFinishMessageCall) Return added in v0.35.0

Return rewrite *gomock.Call.Return

type MockClientMockRecorder

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

MockClientMockRecorder is the mock recorder for MockClient.

func (*MockClientMockRecorder) Dequeue

func (mr *MockClientMockRecorder) Dequeue(arg0, arg1 any) *MockClientDequeueCall

Dequeue indicates an expected call of Dequeue.

func (*MockClientMockRecorder) Enqueue

func (mr *MockClientMockRecorder) Enqueue(arg0, arg1 any, arg2 ...any) *MockClientEnqueueCall

Enqueue indicates an expected call of Enqueue.

func (*MockClientMockRecorder) ExtendMessage

func (mr *MockClientMockRecorder) ExtendMessage(arg0, arg1 any) *MockClientExtendMessageCall

ExtendMessage indicates an expected call of ExtendMessage.

func (*MockClientMockRecorder) FinishMessage

func (mr *MockClientMockRecorder) FinishMessage(arg0, arg1 any) *MockClientFinishMessageCall

FinishMessage indicates an expected call of FinishMessage.

type QueueClientConfig

type QueueClientConfig struct {
	// DequeueIntervalDuration is the time duration between 2 successive dequeue attempts on the queue
	DequeueIntervalDuration time.Duration
}

QueueClientConfig is a configuration for queue client APIs.

func NewDequeueConfig

func NewDequeueConfig(opts ...DequeueOptions) QueueClientConfig

NewDequeueConfig returns new queue config for StartDequeuer().

Jump to

Keyboard shortcuts

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