config

package
v0.0.0-...-89699de Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 10 Imported by: 0

Documentation

Overview

Package config defines the all the TubeMQ configuration options.

Index

Constants

View Source
const (
	MaxRPCTimeout              = 300000 * time.Millisecond
	MinRPCTimeout              = 8000 * time.Millisecond
	MaxSessionKeyLen           = 1024
	MaxGroupLen                = 1024
	MaxTopicLen                = 64
	MaxFilterLen               = 256
	MaxFilterItemCount         = 500
	ConsumeFromFirstOffset     = -1
	ConsumeFromLatestOffset    = 0
	ConsumeFromMaxOffsetAlways = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Net is the namespace for network-level properties used by broker and Master.
	Net struct {
		// ReadTimeout represents how long to wait for a response.
		ReadTimeout time.Duration
		// TLS based authentication with broker and master.
		TLS struct {
			// Enable represents whether or not to use TLS.
			Enable bool
			// CACertFile for TLS.
			CACertFile string
			// TLSCertFile for TLS.
			TLSCertFile string
			// TLSKeyFile for TLS.
			TLSKeyFile string
			// TTSServerName for TLS.
			TLSServerName string
		}
		// Auth represents the account based authentication with broker and master.
		Auth struct {
			// Enable represents whether or not to use authentication.
			Enable bool
			// Username for authentication.
			UserName string
			// Password for authentication.
			Password string
		}
	}

	// Producer is the namespace for configuration related to produce messages,
	// used by the producer
	Producer struct {
		// Masters is the addresses of master.
		Masters string
		// Topics of the production.
		Topics []string
		// MaxPubInfoReportInterval is maximum interval for the client to report publish information.
		MaxPubInfoInterval int
	}

	// Consumer is the namespace for configuration related to consume messages,
	// used by the consumer
	Consumer struct {
		// Masters is the addresses of master.
		Masters string
		// Topics of the consumption.
		Topics []string
		// TopicFilters is the map of topic to filters.
		TopicFilters map[string][]string
		// PartitionOffset is the map of partition to its corresponding offset.
		PartitionOffset map[string]int64
		// ConsumerPosition is the initial offset to use if no offset was previously committed.
		ConsumePosition int
		// Group is the consumer group name.
		Group string
		// BoundConsume represents whether or not to specify the offset.
		BoundConsume bool
		// SessionKey is defined by the client.
		// The session key will be the same in a batch.
		SessionKey string
		// SourceCount is the number of consumers in a batch.
		SourceCount int
		// SelectBig specifies if multiple consumers want to reset the offset of the same partition,
		// whether or not to use the biggest offset.
		// The server will use the biggest offset if set, otherwise the server will use the smallest offset.
		SelectBig bool
		// RollbackIfConfirmTimeout represents if the confirm request timeouts,
		// whether or not this batch of data should be considered as successful.
		// This batch of data will not be considered as successful if set.
		RollbackIfConfirmTimeout bool
		// MaxSubInfoReportInterval is maximum interval for the client to report subscription information.
		MaxSubInfoReportInterval int
		// MaxPartCheckPeriod is the maximum interval to check the partition.
		MaxPartCheckPeriod time.Duration
		// PartCheckSlice is the interval to check the partition.
		PartCheckSlice time.Duration
		// MsgNotFoundWait is the maximum wait time the offset of a partition has reached the maximum offset.
		MsgNotFoundWait time.Duration
		// RebConfirmWait represents how long to wait
		// when the server is rebalancing and the partition is being occupied by the client.
		RebConfirmWait time.Duration
		// MaxConfirmWait is the maximum wait time a partition consumption command is released.
		MaxConfirmWait time.Duration
		// ShutdownRebWait represents how long to wait when shutdown is called and the server is rebalancing.
		ShutdownRebWait time.Duration
	}

	// Heartbeat is the namespace for configuration related to heartbeat messages,
	// used by the consumer
	Heartbeat struct {
		// Interval represents how frequently to send heartbeat.
		Interval time.Duration
		// MaxRetryTimes is the total number of times to retry sending heartbeat.
		MaxRetryTimes int
		// AfterFail is the heartbeat timeout after a heartbeat failure.
		AfterFail time.Duration
	}

	// Log is the namespace for configuration related to log messages,
	// used by the logger
	Log struct {
		// LogPath represents the path where the log save in
		LogPath string
		// LogLevel represents the level of log
		LogLevel string
	}
}

Config defines multiple configuration options. Refer to: https://github.com/apache/inlong/blob/3249de37acf054a9c43677131cfbb09fc6d366d1/tubemq-client/src/main/java/org/apache/tubemq/client/config/ConsumerConfig.java

func New

func New(opts ...Option) *Config

New returns a config by the options.

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig returns a default config of the client.

func ParseAddress

func ParseAddress(address string) (config *Config, err error)

ParseAddress parses the address to user-defined config.

func (*Config) String

func (c *Config) String() string

String returns the config as a string.

func (*Config) ValidateConsumer

func (c *Config) ValidateConsumer() error

ValidateConsumer validates the config of the consumer.

func (*Config) ValidateProducer

func (c *Config) ValidateProducer() error

ValidateProducer valiates the config of the producer.

type Option

type Option func(*Config)

func WithAuth

func WithAuth(enable bool, userName string, password string) Option

func WithBoundConsume

func WithBoundConsume(sessionKey string, sourceCount int, selectBig bool, partOffset map[string]int64) Option

func WithConsumePosition

func WithConsumePosition(consumePosition int) Option

func WithConsumerMasters

func WithConsumerMasters(masters string) Option

func WithGroup

func WithGroup(group string) Option

func WithLogLevel

func WithLogLevel(level string) Option

WithLogLevel set log level

func WithLogPath

func WithLogPath(path string) Option

WithLogPath set log path

func WithMaxConfirmWait

func WithMaxConfirmWait(d time.Duration) Option

func WithMaxPartCheckPeriod

func WithMaxPartCheckPeriod(d time.Duration) Option

func WithMaxSubInfoReportInterval

func WithMaxSubInfoReportInterval(i int) Option

func WithMsgNotFoundWait

func WithMsgNotFoundWait(d time.Duration) Option

func WithPartCheckSlice

func WithPartCheckSlice(d time.Duration) Option

func WithPartOffsets

func WithPartOffsets(partOffsets map[string]int64) Option

func WithRPCReadTimeout

func WithRPCReadTimeout(d time.Duration) Option

func WithRebConfirmWait

func WithRebConfirmWait(d time.Duration) Option

func WithSelectBig

func WithSelectBig(selectBig bool) Option

func WithShutdownRebWait

func WithShutdownRebWait(d time.Duration) Option

func WithSourceCount

func WithSourceCount(count int) Option

func WithTLS

func WithTLS(enable bool, certFile, keyFile, caFile, serverName string) Option

func WithTopicFilters

func WithTopicFilters(topicFilters map[string][]string) Option

func WithTopics

func WithTopics(topics []string) Option

Jump to

Keyboard shortcuts

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