topic

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: Apache-2.0 Imports: 11 Imported by: 6 modules, 10 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 topic is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConsumerServiceToProto

func ConsumerServiceToProto(cs ConsumerService) (*topicpb.ConsumerService, error)

ConsumerServiceToProto creates proto from a ConsumerService.

func ConsumptionTypeToProto

func ConsumptionTypeToProto(ct ConsumptionType) (topicpb.ConsumptionType, error)

ConsumptionTypeToProto creates proto from a ConsumptionType.

func DynamicFilterConfigToProto added in v1.6.0

func DynamicFilterConfigToProto(filter FilterConfig) *topicpb.Filters

DynamicFilterConfigToProto creates proto from a filter config.

func NewServiceIDFromProto

func NewServiceIDFromProto(sid *topicpb.ServiceID) services.ServiceID

NewServiceIDFromProto creates service id from a proto.

func PercentageFilterToProto added in v1.6.0

func PercentageFilterToProto(filter PercentageFilter) *topicpb.PercentageFilter

PercentageFilterToProto creates proto from a percentage filter.

func RoutingPolicyFilterToProto added in v1.6.0

func RoutingPolicyFilterToProto(filter RoutingPolicyFilter) *topicpb.RoutingPolicyFilter

RoutingPolicyFilterToProto creates proto from a routing policy filter.

func ServiceIDToProto

func ServiceIDToProto(sid services.ServiceID) *topicpb.ServiceID

ServiceIDToProto creates proto from a service id.

func ShardSetFilterToProto added in v1.6.0

func ShardSetFilterToProto(filter ShardSetFilter) *topicpb.ShardSetFilter

ShardSetFilterToProto creates proto from a shard set filter.

func StoragePolicyFilterToProto added in v1.6.0

func StoragePolicyFilterToProto(filter StoragePolicyFilter) *topicpb.StoragePolicyFilter

StoragePolicyFilterToProto creates proto from a storage policy filter.

func ToProto

func ToProto(t Topic) (*topicpb.Topic, error)

ToProto creates proto from a topic.

Types

type ConsumerService

type ConsumerService interface {
	// ServiceID returns the service id of the consumer service.
	ServiceID() services.ServiceID

	// SetServiceID sets the service id of the consumer service.
	SetServiceID(value services.ServiceID) ConsumerService

	// ConsumptionType returns the consumption type of the consumer service.
	ConsumptionType() ConsumptionType

	// SetConsumptionType sets the consumption type of the consumer service.
	SetConsumptionType(value ConsumptionType) ConsumerService

	// MessageTTLNanos returns ttl for each message in nanoseconds.
	MessageTTLNanos() int64

	// SetMessageTTLNanos sets ttl for each message in nanoseconds.
	SetMessageTTLNanos(value int64) ConsumerService

	// DynamicFilterConfigs returns the dynamic filters for the consumer service.
	DynamicFilterConfigs() FilterConfig

	// SetDynamicFilterConfigs sets the dynamic filters for the consumer service.
	SetDynamicFilterConfigs(value FilterConfig) ConsumerService

	// String returns the string representation of the consumer service.
	String() string
}

ConsumerService is a service that consumes the messages in a topic.

func NewConsumerService

func NewConsumerService() ConsumerService

NewConsumerService creates a ConsumerService.

func NewConsumerServiceFromProto

func NewConsumerServiceFromProto(cs *topicpb.ConsumerService) (ConsumerService, error)

NewConsumerServiceFromProto creates a ConsumerService from a proto.

type ConsumptionType

type ConsumptionType string

ConsumptionType defines how the consumer consumes messages.

const (
	// Unknown is the unknown consumption type.
	Unknown ConsumptionType = "unknown"

	// Shared means the messages for each shard will be
	// shared by all the responsible instances.
	Shared ConsumptionType = "shared"

	// Replicated means the messages for each shard will be
	// replicated to all the responsible instances.
	Replicated ConsumptionType = "replicated"
)

func NewConsumptionType

func NewConsumptionType(str string) (ConsumptionType, error)

NewConsumptionType creates a consumption type from a string.

func NewConsumptionTypeFromProto

func NewConsumptionTypeFromProto(ct topicpb.ConsumptionType) (ConsumptionType, error)

NewConsumptionTypeFromProto creates ConsumptionType from a proto.

func (ConsumptionType) String

func (t ConsumptionType) String() string

type FilterConfig added in v1.6.0

type FilterConfig interface {
	// StoragePolicyFilter returns the storage policy data filter of the consumer service.
	StoragePolicyFilter() StoragePolicyFilter

	// SetStoragePolicyFilter sets the storage policy data filter of the consumer service.
	SetStoragePolicyFilter(value StoragePolicyFilter) FilterConfig

	// PercentageFilter returns the percentage data filter of the consumer service.
	PercentageFilter() PercentageFilter

	// SetPercentageFilter sets the percentage data filter of the consumer service.
	SetPercentageFilter(value PercentageFilter) FilterConfig

	// ShardSetFilter returns the shard set data filter of the consumer service.
	ShardSetFilter() ShardSetFilter

	// SetShardSetFilter sets the shard set data filter of the consumer service.
	SetShardSetFilter(value ShardSetFilter) FilterConfig

	// RoutingPolicyFilter returns the route policy data filter of the consumer service.
	RoutingPolicyFilter() RoutingPolicyFilter

	// SetRoutingPolicyFilter sets the route policy data filter of the consumer service.
	SetRoutingPolicyFilter(value RoutingPolicyFilter) FilterConfig
}

FilterConfig is the filter configuration for a consumer service.

func NewDynamicFilterConfigFromProto added in v1.6.0

func NewDynamicFilterConfigFromProto(filterProto *topicpb.Filters) FilterConfig

NewDynamicFilterConfigFromProto creates filter config from a proto.

func NewFilterConfig added in v1.6.0

func NewFilterConfig() FilterConfig

NewFilterConfig creates a new filter config.

type MockService

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

MockService is a mock of Service interface.

func NewMockService

func NewMockService(ctrl *gomock.Controller) *MockService

NewMockService creates a new mock instance.

func (*MockService) CheckAndSet

func (m *MockService) CheckAndSet(arg0 Topic, arg1 int) (Topic, error)

CheckAndSet mocks base method.

func (*MockService) Delete

func (m *MockService) Delete(arg0 string) error

Delete mocks base method.

func (*MockService) EXPECT

func (m *MockService) EXPECT() *MockServiceMockRecorder

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

func (*MockService) Get

func (m *MockService) Get(arg0 string) (Topic, error)

Get mocks base method.

func (*MockService) Watch

func (m *MockService) Watch(arg0 string) (Watch, error)

Watch mocks base method.

type MockServiceMockRecorder

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

MockServiceMockRecorder is the mock recorder for MockService.

func (*MockServiceMockRecorder) CheckAndSet

func (mr *MockServiceMockRecorder) CheckAndSet(arg0, arg1 interface{}) *gomock.Call

CheckAndSet indicates an expected call of CheckAndSet.

func (*MockServiceMockRecorder) Delete

func (mr *MockServiceMockRecorder) Delete(arg0 interface{}) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockServiceMockRecorder) Get

func (mr *MockServiceMockRecorder) Get(arg0 interface{}) *gomock.Call

Get indicates an expected call of Get.

func (*MockServiceMockRecorder) Watch

func (mr *MockServiceMockRecorder) Watch(arg0 interface{}) *gomock.Call

Watch indicates an expected call of Watch.

type PercentageFilter added in v1.6.0

type PercentageFilter interface {
	Percentage() float64
}

PercentageFilter is sampling percentage filter for a consumer service.

func NewPercentageFilter added in v1.6.0

func NewPercentageFilter(percentage float64) PercentageFilter

NewPercentageFilter creates a new percentage filter.

type RoutingPolicyFilter added in v1.6.0

type RoutingPolicyFilter interface {
	AllowedTrafficTypes() []string
	IsDefault() bool
}

RoutingPolicyFilter is the route policy filter for a consumer service, filters metrics based on specified route policies.

type Service

type Service interface {
	// Get returns the topic and version for the given name.
	Get(name string) (Topic, error)

	// CheckAndSet sets the topic for the name if the version matches.
	CheckAndSet(t Topic, version int) (Topic, error)

	// Delete deletes the topic with the name.
	Delete(name string) error

	// Watch returns a topic watch.
	Watch(name string) (Watch, error)
}

Service provides accessibility to topics.

func NewService

func NewService(sOpts ServiceOptions) (Service, error)

NewService creates a topic service.

type ServiceOptions

type ServiceOptions interface {
	// ConfigService returns the client of config service.
	ConfigService() client.Client

	// SetConfigService sets the client of config service.
	SetConfigService(c client.Client) ServiceOptions

	// KVOverrideOptions returns the override options for KV store.
	KVOverrideOptions() kv.OverrideOptions

	// SetKVOverrideOptions sets the override options for KV store.
	SetKVOverrideOptions(value kv.OverrideOptions) ServiceOptions
}

ServiceOptions configures the topic service.

func NewServiceOptions

func NewServiceOptions() ServiceOptions

NewServiceOptions returns new ServiceOptions.

type ShardSetFilter added in v1.6.0

type ShardSetFilter interface {
	ShardSet() string
}

ShardSetFilter is the shard set filter for a consumer service, filters metrics based on specified shard sets.

func NewShardSetFilter added in v1.6.0

func NewShardSetFilter(shardSet string) ShardSetFilter

NewShardSetFilter creates a new shard set filter.

type StoragePolicyFilter added in v1.6.0

type StoragePolicyFilter interface {
	StoragePolicies() []string
}

StoragePolicyFilter is the storage policy filter for a consumer service, filters metrics based on their storage policies.

func NewStoragePolicyFilter added in v1.6.0

func NewStoragePolicyFilter(storagePolicies []string) StoragePolicyFilter

NewStoragePolicyFilter creates a new storage policy filter.

type Topic

type Topic interface {
	// Name returns the name of the topic.
	Name() string

	// SetName sets the name of the topic.
	SetName(value string) Topic

	// NumberOfShards returns the total number of shards of the topic.
	NumberOfShards() uint32

	// SetNumberOfShards sets the total number of shards of the topic.
	SetNumberOfShards(value uint32) Topic

	// ConsumerServices returns the consumers of the topic.
	ConsumerServices() []ConsumerService

	// SetConsumerServices sets the consumers of the topic.
	SetConsumerServices(value []ConsumerService) Topic

	// Version returns the version of the topic.
	Version() int

	// SetVersion sets the version of the topic.
	SetVersion(value int) Topic

	// AddConsumerService adds a consumer to the topic.
	AddConsumerService(value ConsumerService) (Topic, error)

	// RemoveConsumerService removes a consumer from the topic.
	RemoveConsumerService(value services.ServiceID) (Topic, error)

	// UpdateConsumerService updates a consumer in the topic.
	UpdateConsumerService(value ConsumerService) (Topic, error)

	// String returns the string representation of the topic.
	String() string

	// Validate validates the topic.
	Validate() error
}

Topic defines the topic of messages.

func NewTopic

func NewTopic() Topic

NewTopic creates a new topic.

func NewTopicFromProto

func NewTopicFromProto(t *topicpb.Topic) (Topic, error)

NewTopicFromProto creates a topic from a proto.

func NewTopicFromValue

func NewTopicFromValue(v kv.Value) (Topic, error)

NewTopicFromValue creates a topic from a kv.Value.

type Watch

type Watch interface {
	// C returns the notification channel.
	C() <-chan struct{}

	// Get returns the latest version of the topic.
	Get() (Topic, error)

	// Close stops watching for topic updates.
	Close()
}

Watch watches the updates of a topic.

func NewWatch

func NewWatch(w kv.ValueWatch) Watch

NewWatch creates a new topic watch.

Jump to

Keyboard shortcuts

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