types

package
v1.4.2-prerelease09 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: Apache-2.0 Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package types is a generated GoMock package.

Package types is a generated GoMock package.

Package types is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Enqueue adds an item to the queue
	Enqueue(context.Context, []Item) ([]ItemToPersist, error)

	// Ack marks the item as processed.
	// Out of order acks are supported.
	// Acking an item that has not been dequeued will have no effect.
	// Queue's committed offset is updated to the last ack'ed item's offset periodically until there's a gap (un-acked item).
	// In other words, all items up to the committed offset are ack'ed.
	// Ack'ed item might still be returned from Dequeue if its offset is higher than last committed offset before process restarts.
	Ack(context.Context, Item) error

	// Nack negatively acknowledges an item in the queue
	// Nack'ing an already ack'ed item will have no effect.
	Nack(context.Context, Item) error

	// Start the client. It will
	// - fetch the last committed offsets from the persister,
	// - start corresponding consumers
	// - dispatch items starting from those offsets.
	Start(context.Context) error

	// Stop the client. It will
	// - stop all consumers
	// - persist the last committed offsets
	Stop(context.Context) error
}

type Consumer

type Consumer interface {
	Start(context.Context) error
	Stop(context.Context) error
	Process(context.Context, Item) error
}

type ConsumerFactory

type ConsumerFactory interface {
	// New creates a new consumer with the given partitions or returns an existing consumer
	// to process the given partitions
	// Consumer lifecycle is managed by the factory so the returned consumer must be started.
	New(ItemPartitions) (Consumer, error)

	// Stop stops all consumers created by this factory
	Stop(context.Context) error
}

type DispatchPolicy

type DispatchPolicy struct {
	// DispatchRPS is the rate limit for items dequeued from the node to be pushed to processors.
	// All nodes inherit the DispatchRPS from the parent node as is (not distributed to children).
	// If parent has 100 rps limit, then all curent and to-be-created children will have 100 rps limit.
	DispatchRPS int64 `json:"dispatchRPS,omitempty"`

	// Concurrency is the maximum number of items to be processed concurrently.
	Concurrency int `json:"concurrency,omitempty"`
}

func (DispatchPolicy) String

func (dp DispatchPolicy) String() string

type Item

type Item interface {
	// GetAttribute returns the value of the attribute key.
	// Value can be any type. It's up to the client to interpret the value.
	// Attribute keys used as partition keys will be converted to string because they are used as node
	// identifiers in the queue tree.
	GetAttribute(key string) any

	// Offset returns the offset of the item in the queue. e.g. monotonically increasing sequence number or a timestamp
	Offset() int64

	// String returns a human friendly representation of the item for logging purposes
	String() string
}

type ItemPartitions

type ItemPartitions interface {
	// GetPartitionKeys returns the partition keys ordered by their level in the tree
	GetPartitionKeys() []string

	// GetPartitionValue returns the partition value to determine the target queue
	// e.g.
	//  Below example demonstrates that item is in a catch-all queue for sub-type
	//  	Item.GetAttribute("sub-type") returns "timer"
	//  	ItemPartitions.GetPartitionValue("sub-type") returns "*"
	//
	GetPartitionValue(key string) any

	// String returns a human friendly representation of the item for logging purposes
	String() string
}

func NewItemPartitions

func NewItemPartitions(partitionKeys []string, partitionMap map[string]any) ItemPartitions

type ItemToPersist

type ItemToPersist interface {
	Item
	ItemPartitions
}

func NewItemToPersist

func NewItemToPersist(item Item, itemPartitions ItemPartitions) ItemToPersist

type MockConsumer

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

MockConsumer is a mock of Consumer interface.

func NewMockConsumer

func NewMockConsumer(ctrl *gomock.Controller) *MockConsumer

NewMockConsumer creates a new mock instance.

func (*MockConsumer) EXPECT

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

func (*MockConsumer) Process

func (m *MockConsumer) Process(arg0 context.Context, arg1 Item) error

Process mocks base method.

func (*MockConsumer) Start

func (m *MockConsumer) Start(arg0 context.Context) error

Start mocks base method.

func (*MockConsumer) Stop

func (m *MockConsumer) Stop(arg0 context.Context) error

Stop mocks base method.

type MockConsumerFactory

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

MockConsumerFactory is a mock of ConsumerFactory interface.

func NewMockConsumerFactory

func NewMockConsumerFactory(ctrl *gomock.Controller) *MockConsumerFactory

NewMockConsumerFactory creates a new mock instance.

func (*MockConsumerFactory) EXPECT

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

func (*MockConsumerFactory) New

New mocks base method.

func (*MockConsumerFactory) Stop

func (m *MockConsumerFactory) Stop(arg0 context.Context) error

Stop mocks base method.

type MockConsumerFactoryMockRecorder

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

MockConsumerFactoryMockRecorder is the mock recorder for MockConsumerFactory.

func (*MockConsumerFactoryMockRecorder) New

New indicates an expected call of New.

func (*MockConsumerFactoryMockRecorder) Stop

Stop indicates an expected call of Stop.

type MockConsumerMockRecorder

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

MockConsumerMockRecorder is the mock recorder for MockConsumer.

func (*MockConsumerMockRecorder) Process

func (mr *MockConsumerMockRecorder) Process(arg0, arg1 any) *gomock.Call

Process indicates an expected call of Process.

func (*MockConsumerMockRecorder) Start

func (mr *MockConsumerMockRecorder) Start(arg0 any) *gomock.Call

Start indicates an expected call of Start.

func (*MockConsumerMockRecorder) Stop

func (mr *MockConsumerMockRecorder) Stop(arg0 any) *gomock.Call

Stop indicates an expected call of Stop.

type MockItem

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

MockItem is a mock of Item interface.

func NewMockItem

func NewMockItem(ctrl *gomock.Controller) *MockItem

NewMockItem creates a new mock instance.

func (*MockItem) EXPECT

func (m *MockItem) EXPECT() *MockItemMockRecorder

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

func (*MockItem) GetAttribute

func (m *MockItem) GetAttribute(key string) any

GetAttribute mocks base method.

func (*MockItem) Offset

func (m *MockItem) Offset() int64

Offset mocks base method.

func (*MockItem) String

func (m *MockItem) String() string

String mocks base method.

type MockItemMockRecorder

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

MockItemMockRecorder is the mock recorder for MockItem.

func (*MockItemMockRecorder) GetAttribute

func (mr *MockItemMockRecorder) GetAttribute(key any) *gomock.Call

GetAttribute indicates an expected call of GetAttribute.

func (*MockItemMockRecorder) Offset

func (mr *MockItemMockRecorder) Offset() *gomock.Call

Offset indicates an expected call of Offset.

func (*MockItemMockRecorder) String

func (mr *MockItemMockRecorder) String() *gomock.Call

String indicates an expected call of String.

type MockItemPartitions

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

MockItemPartitions is a mock of ItemPartitions interface.

func NewMockItemPartitions

func NewMockItemPartitions(ctrl *gomock.Controller) *MockItemPartitions

NewMockItemPartitions creates a new mock instance.

func (*MockItemPartitions) EXPECT

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

func (*MockItemPartitions) GetPartitionKeys

func (m *MockItemPartitions) GetPartitionKeys() []string

GetPartitionKeys mocks base method.

func (*MockItemPartitions) GetPartitionValue

func (m *MockItemPartitions) GetPartitionValue(key string) any

GetPartitionValue mocks base method.

func (*MockItemPartitions) String

func (m *MockItemPartitions) String() string

String mocks base method.

type MockItemPartitionsMockRecorder

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

MockItemPartitionsMockRecorder is the mock recorder for MockItemPartitions.

func (*MockItemPartitionsMockRecorder) GetPartitionKeys

func (mr *MockItemPartitionsMockRecorder) GetPartitionKeys() *gomock.Call

GetPartitionKeys indicates an expected call of GetPartitionKeys.

func (*MockItemPartitionsMockRecorder) GetPartitionValue

func (mr *MockItemPartitionsMockRecorder) GetPartitionValue(key any) *gomock.Call

GetPartitionValue indicates an expected call of GetPartitionValue.

func (*MockItemPartitionsMockRecorder) String

String indicates an expected call of String.

type MockItemToPersist

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

MockItemToPersist is a mock of ItemToPersist interface.

func NewMockItemToPersist

func NewMockItemToPersist(ctrl *gomock.Controller) *MockItemToPersist

NewMockItemToPersist creates a new mock instance.

func (*MockItemToPersist) EXPECT

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

func (*MockItemToPersist) GetAttribute

func (m *MockItemToPersist) GetAttribute(key string) any

GetAttribute mocks base method.

func (*MockItemToPersist) GetPartitionKeys

func (m *MockItemToPersist) GetPartitionKeys() []string

GetPartitionKeys mocks base method.

func (*MockItemToPersist) GetPartitionValue

func (m *MockItemToPersist) GetPartitionValue(key string) any

GetPartitionValue mocks base method.

func (*MockItemToPersist) Offset

func (m *MockItemToPersist) Offset() int64

Offset mocks base method.

func (*MockItemToPersist) String

func (m *MockItemToPersist) String() string

String mocks base method.

type MockItemToPersistMockRecorder

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

MockItemToPersistMockRecorder is the mock recorder for MockItemToPersist.

func (*MockItemToPersistMockRecorder) GetAttribute

func (mr *MockItemToPersistMockRecorder) GetAttribute(key any) *gomock.Call

GetAttribute indicates an expected call of GetAttribute.

func (*MockItemToPersistMockRecorder) GetPartitionKeys

func (mr *MockItemToPersistMockRecorder) GetPartitionKeys() *gomock.Call

GetPartitionKeys indicates an expected call of GetPartitionKeys.

func (*MockItemToPersistMockRecorder) GetPartitionValue

func (mr *MockItemToPersistMockRecorder) GetPartitionValue(key any) *gomock.Call

GetPartitionValue indicates an expected call of GetPartitionValue.

func (*MockItemToPersistMockRecorder) Offset

Offset indicates an expected call of Offset.

func (*MockItemToPersistMockRecorder) String

String indicates an expected call of String.

type MockPersister

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

MockPersister is a mock of Persister interface.

func NewMockPersister

func NewMockPersister(ctrl *gomock.Controller) *MockPersister

NewMockPersister creates a new mock instance.

func (*MockPersister) CommitOffsets

func (m *MockPersister) CommitOffsets(ctx context.Context, offsets *Offsets) error

CommitOffsets mocks base method.

func (*MockPersister) EXPECT

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

func (*MockPersister) Fetch

func (m *MockPersister) Fetch(ctx context.Context, partitions ItemPartitions, pageInfo PageInfo) ([]Item, error)

Fetch mocks base method.

func (*MockPersister) GetOffsets

func (m *MockPersister) GetOffsets(ctx context.Context) (*Offsets, error)

GetOffsets mocks base method.

func (*MockPersister) Persist

func (m *MockPersister) Persist(ctx context.Context, items []ItemToPersist) error

Persist mocks base method.

type MockPersisterMockRecorder

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

MockPersisterMockRecorder is the mock recorder for MockPersister.

func (*MockPersisterMockRecorder) CommitOffsets

func (mr *MockPersisterMockRecorder) CommitOffsets(ctx, offsets any) *gomock.Call

CommitOffsets indicates an expected call of CommitOffsets.

func (*MockPersisterMockRecorder) Fetch

func (mr *MockPersisterMockRecorder) Fetch(ctx, partitions, pageInfo any) *gomock.Call

Fetch indicates an expected call of Fetch.

func (*MockPersisterMockRecorder) GetOffsets

func (mr *MockPersisterMockRecorder) GetOffsets(ctx any) *gomock.Call

GetOffsets indicates an expected call of GetOffsets.

func (*MockPersisterMockRecorder) Persist

func (mr *MockPersisterMockRecorder) Persist(ctx, items any) *gomock.Call

Persist indicates an expected call of Persist.

type NodePolicy

type NodePolicy struct {
	// The path to the node
	// Root node has empty path "".
	// "/" is used as path separator.
	// "*" means the policy applies to the special catch-all node
	// "." means the policy applies to all nodes in the specified level except the catch-all node
	Path string `json:"path,omitempty"`

	SplitPolicy *SplitPolicy `json:"splitPolicy,omitempty"`

	// DispatchPolicy is enforced at the leaf node level.
	DispatchPolicy *DispatchPolicy `json:"dispatchPolicy,omitempty"`
}

func (NodePolicy) Merge

func (np NodePolicy) Merge(other NodePolicy) (NodePolicy, error)

Merge merges two NodePolicy objects by marshalling/unmarshalling them. Any field in the other policy will override the field in the current policy.

func (NodePolicy) String

func (np NodePolicy) String() string

type NodePolicyCollection

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

func NewNodePolicyCollection

func NewNodePolicyCollection(policies []NodePolicy) NodePolicyCollection

func (NodePolicyCollection) GetMergedPolicyForNode

func (npc NodePolicyCollection) GetMergedPolicyForNode(path string) (NodePolicy, error)

func (NodePolicyCollection) GetPolicies

func (npc NodePolicyCollection) GetPolicies() []NodePolicy

type Offsets

type Offsets struct {
}

Offsets encapsulates the whole queue tree state including the offsets of each leaf node

type PageInfo

type PageInfo struct {
}

type Persister

type Persister interface {
	Persist(ctx context.Context, items []ItemToPersist) error
	GetOffsets(ctx context.Context) (*Offsets, error)
	CommitOffsets(ctx context.Context, offsets *Offsets) error
	Fetch(ctx context.Context, partitions ItemPartitions, pageInfo PageInfo) ([]Item, error)
}

type SplitPolicy

type SplitPolicy struct {
	// Disabled is used to disable the split policy for the node.
	Disabled bool `json:"disabled,omitempty"`

	// PredefinedSplits is a list of predefined splits for the attribute key
	// Child nodes for these attributes will be created during initialization
	PredefinedSplits []any `json:"predefinedSplits,omitempty"`
}

func (SplitPolicy) String

func (sp SplitPolicy) String() string

Jump to

Keyboard shortcuts

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