options

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: MIT Imports: 42 Imported by: 0

Documentation

Overview

Package options is the public flags and options used by a generic api server. It takes a minimal set of dependencies and does not reference implementations, in order to ensure it may be reused by multiple components (such as CLI commands that wish to generate or validate config).

Index

Constants

View Source
const (
	KiB = 1 << (10 * iota)
	MiB
	GiB
	TiB
)

Define unit constant.

Variables

This section is empty.

Functions

func CreateListener

func CreateListener(addr string) (net.Listener, int, error)

CreateListener create net listener by given address and returns it and port.

func ValidateAddress

func ValidateAddress(addr string) error

ValidateAddress takes an address as a string and validates it. If the input address is not in a valid :port or IP:port format, it returns an error. It also checks if the host part of the address is a valid IP address and if the port number is valid.

Types

type CertKey

type CertKey struct {
	// CertFile is a file containing a PEM-encoded certificate, and possibly the complete certificate chain
	CertFile string `json:"cert-file"`
	// KeyFile is a file containing a PEM-encoded private key for the certificate specified by CertFile
	KeyFile string `json:"private-key-file"`
}

CertKey contains configuration items related to certificate.

type ClientCertAuthenticationOptions

type ClientCertAuthenticationOptions struct {
	// ClientCA is the certificate bundle for all the signers that you'll recognize for incoming client certificates
	ClientCA string `json:"client-ca-file" mapstructure:"client-ca-file"`
}

ClientCertAuthenticationOptions provides different options for client cert auth.

func NewClientCertAuthenticationOptions

func NewClientCertAuthenticationOptions() *ClientCertAuthenticationOptions

NewClientCertAuthenticationOptions creates a ClientCertAuthenticationOptions object with default parameters.

func (*ClientCertAuthenticationOptions) AddFlags

func (o *ClientCertAuthenticationOptions) AddFlags(fs *pflag.FlagSet, prefixs ...string)

AddFlags adds flags related to ClientCertAuthenticationOptions for a specific server to the specified FlagSet.

func (*ClientCertAuthenticationOptions) Validate

func (o *ClientCertAuthenticationOptions) Validate() []error

Validate is used to parse and validate the parameters entered by the user at the command line when the program starts.

type ConsulOptions

type ConsulOptions struct {
	// Address is the address of the Consul server
	Addr string `json:"addr,omitempty" mapstructure:"addr"`

	// Scheme is the URI scheme for the Consul server
	Scheme string `json:"scheme,omitempty" mapstructure:"scheme"`
}

ConsulOptions defines options for consul client.

func NewConsulOptions

func NewConsulOptions() *ConsulOptions

NewConsulOptions create a `zero` value instance.

func (*ConsulOptions) AddFlags

func (o *ConsulOptions) AddFlags(fs *pflag.FlagSet, prefixs ...string)

AddFlags adds flags related to mysql storage for a specific APIServer to the specified FlagSet.

func (*ConsulOptions) Validate

func (o *ConsulOptions) Validate() []error

Validate verifies flags passed to ConsulOptions.

type EtcdOptions

type EtcdOptions struct {
	Endpoints   []string      `json:"endpoints"               mapstructure:"endpoints"`
	DialTimeout time.Duration `json:"dial-timeout"         mapstructure:"dial-timeout"`
	Username    string        `json:"username"                mapstructure:"username"`
	Password    string        `json:"password"                mapstructure:"password"`
	TLSOptions  *TLSOptions   `json:"tls"               mapstructure:"tls"`
}

EtcdOptions defines options for etcd cluster.

func NewEtcdOptions

func NewEtcdOptions() *EtcdOptions

NewEtcdOptions create a `zero` value instance.

func (*EtcdOptions) AddFlags

func (o *EtcdOptions) AddFlags(fs *pflag.FlagSet, prefixs ...string)

AddFlags adds flags related to redis storage for a specific APIServer to the specified FlagSet.

func (*EtcdOptions) Validate

func (o *EtcdOptions) Validate() []error

Validate verifies flags passed to EtcdOptions.

type GRPCOptions

type GRPCOptions struct {
	// Network with server network.
	Network string `json:"network" mapstructure:"network"`

	// Address with server address.
	Addr string `json:"addr" mapstructure:"addr"`

	// Timeout with server timeout. Used by grpc client side.
	Timeout time.Duration `json:"timeout" mapstructure:"timeout"`
}

GRPCOptions are for creating an unauthenticated, unauthorized, insecure port. No one should be using these anymore.

func NewGRPCOptions

func NewGRPCOptions() *GRPCOptions

NewGRPCOptions is for creating an unauthenticated, unauthorized, insecure port. No one should be using these anymore.

func (*GRPCOptions) AddFlags

func (o *GRPCOptions) AddFlags(fs *pflag.FlagSet, prefixs ...string)

AddFlags adds flags related to features for a specific api server to the specified FlagSet.

func (*GRPCOptions) Validate

func (o *GRPCOptions) Validate() []error

Validate is used to parse and validate the parameters entered by the user at the command line when the program starts.

type GeneratableKeyCert

type GeneratableKeyCert struct {
	// CertKey allows setting an explicit cert/key file to use.
	CertKey CertKey `json:"cert-key"`

	// CertDirectory specifies a directory to write generated certificates to if CertFile/KeyFile aren't explicitly set.
	// PairName is used to determine the filenames within CertDirectory.
	// If CertDirectory and PairName are not set, an in-memory certificate will be generated.
	CertDirectory string `json:"cert-dir"`
	// PairName is the name which will be used with CertDirectory to make a cert and key filenames.
	// It becomes CertDirectory/PairName.crt and CertDirectory/PairName.key
	PairName string `json:"pair-name"`
}

GeneratableKeyCert contains configuration items related to certificate.

type HTTPOptions

type HTTPOptions struct {
	// Network with server network.
	Network string `json:"network" mapstructure:"network"`

	// Address with server address.
	Addr string `json:"addr" mapstructure:"addr"`

	// Timeout with server timeout. Used by http client side.
	Timeout time.Duration `json:"timeout" mapstructure:"timeout"`
}

HTTPOptions contains configuration items related to HTTP server startup.

func NewHTTPOptions

func NewHTTPOptions() *HTTPOptions

NewHTTPOptions creates a HTTPOptions object with default parameters.

func (*HTTPOptions) AddFlags

func (o *HTTPOptions) AddFlags(fs *pflag.FlagSet, prefixs ...string)

AddFlags adds flags related to HTTPS server for a specific APIServer to the specified FlagSet.

func (*HTTPOptions) Complete

func (s *HTTPOptions) Complete() error

Complete fills in any fields not set that are required to have valid data.

func (*HTTPOptions) Validate

func (o *HTTPOptions) Validate() []error

Validate is used to parse and validate the parameters entered by the user at the command line when the program starts.

type HealthOptions

type HealthOptions struct {
	// Enable debugging by exposing profiling information.
	HTTPProfile        bool   `json:"enable-http-profiler" mapstructure:"enable-http-profiler"`
	HealthCheckPath    string `json:"check-path" mapstructure:"check-path"`
	HealthCheckAddress string `json:"check-address" mapstructure:"check-address"`
}

HealthOptions defines options for redis cluster.

func NewHealthOptions

func NewHealthOptions() *HealthOptions

NewHealthOptions create a `zero` value instance.

func (*HealthOptions) AddFlags

func (o *HealthOptions) AddFlags(fs *pflag.FlagSet, prefixs ...string)

AddFlags adds flags related to redis storage for a specific APIServer to the specified FlagSet.

func (*HealthOptions) ServeHealthCheck

func (o *HealthOptions) ServeHealthCheck()

func (*HealthOptions) Validate

func (o *HealthOptions) Validate() []error

Validate verifies flags passed to HealthOptions.

type IOptions

type IOptions interface {
	// Validate validates all the required options. It can also used to complete options if needed.
	Validate() []error

	// AddFlags adds flags related to given flagset.
	AddFlags(fs *pflag.FlagSet, prefixs ...string)
}

IOptions defines methods to implement a generic options.

type InsecureServingOptions

type InsecureServingOptions struct {
	Addr string `json:"addr" mapstructure:"addr"`
}

InsecureServingOptions are for creating an unauthenticated, unauthorized, insecure port. No one should be using these anymore.

func NewInsecureServingOptions

func NewInsecureServingOptions() *InsecureServingOptions

NewInsecureServingOptions is for creating an unauthenticated, unauthorized, insecure port. No one should be using these anymore.

func (*InsecureServingOptions) AddFlags

func (s *InsecureServingOptions) AddFlags(fs *pflag.FlagSet, prefixs ...string)

AddFlags adds flags related to features for a specific api server to the specified FlagSet.

func (*InsecureServingOptions) Validate

func (s *InsecureServingOptions) Validate() []error

Validate is used to parse and validate the parameters entered by the user at the command line when the program starts.

type JWTOptions

type JWTOptions struct {
	Key           string        `json:"key" mapstructure:"key"`
	Expired       time.Duration `json:"expired" mapstructure:"expired"`
	MaxRefresh    time.Duration `json:"max-refresh" mapstructure:"max-refresh"`
	SigningMethod string        `json:"signing-method" mapstructure:"signing-method"`
}

JWTOptions contains configuration items related to API server features.

func NewJWTOptions

func NewJWTOptions() *JWTOptions

NewJWTOptions creates a JWTOptions object with default parameters.

func (*JWTOptions) AddFlags

func (s *JWTOptions) AddFlags(fs *pflag.FlagSet, prefixs ...string)

AddFlags adds flags related to features for a specific api server to the specified FlagSet.

func (*JWTOptions) Validate

func (s *JWTOptions) Validate() []error

Validate is used to parse and validate the parameters entered by the user at the command line when the program starts.

type JaegerOptions

type JaegerOptions struct {
	// Server is the url of the Jaeger server
	Server      string `json:"server,omitempty" mapstructure:"server"`
	ServiceName string `json:"service-name,omitempty" mapstructure:"service-name"`
	Env         string `json:"env,omitempty" mapstructure:"env"`
}

JaegerOptions defines options for consul client.

func NewJaegerOptions

func NewJaegerOptions() *JaegerOptions

NewJaegerOptions create a `zero` value instance.

func (*JaegerOptions) AddFlags

func (o *JaegerOptions) AddFlags(fs *pflag.FlagSet, prefixs ...string)

AddFlags adds flags related to mysql storage for a specific APIServer to the specified FlagSet.

func (*JaegerOptions) SetTracerProvider

func (o *JaegerOptions) SetTracerProvider() error

func (*JaegerOptions) Validate

func (o *JaegerOptions) Validate() []error

Validate verifies flags passed to JaegerOptions.

type KafkaOptions

type KafkaOptions struct {
	// kafka-go reader and writer common options
	Brokers       []string      `mapstructure:"brokers"`
	Topic         string        `mapstructure:"topic"`
	ClientID      string        `mapstructure:"client-id"`
	Timeout       time.Duration `mapstructure:"timeout"`
	TLSOptions    *TLSOptions   `mapstructure:"tls"`
	SASLMechanism string        `mapstructure:"mechanism"`
	Username      string        `mapstructure:"username"`
	Password      string        `mapstructure:"password"`
	Algorithm     string        `mapstructure:"algorithm"`
	Compressed    bool          `mapstructure:"compressed"`

	// kafka-go writer options
	WriterOptions WriterOptions `mapstructure:"writer"`

	// kafka-go reader options
	ReaderOptions ReaderOptions `mapstructure:"reader"`
}

KafkaOptions defines options for kafka cluster. Common options for kafka-go reader and writer.

func NewKafkaOptions

func NewKafkaOptions() *KafkaOptions

NewKafkaOptions create a `zero` value instance.

func (*KafkaOptions) AddFlags

func (o *KafkaOptions) AddFlags(fs *pflag.FlagSet, prefixs ...string)

AddFlags adds flags related to redis storage for a specific APIServer to the specified FlagSet.

func (*KafkaOptions) Dialer

func (o *KafkaOptions) Dialer() (*kafka.Dialer, error)

func (*KafkaOptions) GetMechanism

func (o *KafkaOptions) GetMechanism() (sasl.Mechanism, error)

func (*KafkaOptions) Validate

func (o *KafkaOptions) Validate() []error

Validate verifies flags passed to KafkaOptions.

func (*KafkaOptions) Writer

func (o *KafkaOptions) Writer() (*kafka.Writer, error)

type LogsOptions

type LogsOptions struct {
	// Format Flag specifies the structure of log messages.
	// default value of format is `text`
	Format string `json:"format,omitempty" mapstructure:"format"`
	// Maximum number of nanoseconds (i.e. 1s = 1000000000) between log
	// flushes. Ignored if the selected logging backend writes log
	// messages without buffering.
	FlushFrequency time.Duration `json:"flush-frequency" mapstructure:"flush-frequency"`
	// Verbosity is the threshold that determines which log messages are
	// logged. Default is zero which logs only the most important
	// messages. Higher values enable additional messages. Error messages
	// are always logged.
	Verbosity logsapi.VerbosityLevel `json:"verbosity" mapstructure:"verbosity"`
	// VModule overrides the verbosity threshold for individual files.
	// Only supported for "text" log format.
	VModule logsapi.VModuleConfiguration `json:"vmodule,omitempty" mapstructure:"vmodule"`
	// [Alpha] Options holds additional parameters that are specific
	// to the different logging formats. Only the options for the selected
	// format get used, but all of them get validated.
	// Only available when the LoggingAlphaOptions feature gate is enabled.
	Options logsapi.FormatOptions `json:"-,omitempty" mapstructure:"-"`
}

LogsOptions contains configuration items related to log.

func NewLogsOptions

func NewLogsOptions() *LogsOptions

NewLogsOptions creates an Options object with default parameters.

func (*LogsOptions) AddFlags

func (o *LogsOptions) AddFlags(fs *pflag.FlagSet, prefixs ...string)

AddFlags adds command line flags for the configuration.

func (*LogsOptions) Native

func (*LogsOptions) Validate

func (o *LogsOptions) Validate() []error

Validate verifies flags passed to LogsOptions.

type MetricsOptions

type MetricsOptions struct {
	ShowHiddenMetricsForVersion string            `json:"show-hidden-metrics-for-version" mapstructure:"show-hidden-metrics-for-version"`
	DisabledMetrics             []string          `json:"disabled-metrics" mapstructure:"disabled-metrics"`
	AllowListMapping            map[string]string `json:"allow-metric-labels" mapstructure:"allow-metric-labels"`
}

MetricsOptions has all parameters needed for exposing metrics from components.

func NewMetricsOptions

func NewMetricsOptions() *MetricsOptions

NewMetricsOptions returns default metrics options.

func (*MetricsOptions) AddFlags

func (o *MetricsOptions) AddFlags(fs *pflag.FlagSet, prefixs ...string)

AddFlags adds flags for exposing component metrics.

func (*MetricsOptions) Native

func (o *MetricsOptions) Native() *metrics.Options

func (*MetricsOptions) Validate

func (o *MetricsOptions) Validate() []error

Validate validates metrics flags options.

type MongoOptions

type MongoOptions struct {
	URL        string        `json:"url" mapstructure:"url"`
	Database   string        `json:"database" mapstructure:"database"`
	Collection string        `json:"collection" mapstructure:"collection"`
	Username   string        `json:"username" mapstructure:"username"`
	Password   string        `json:"password" mapstructure:"password"`
	Timeout    time.Duration `json:"timeout" mapstructure:"timeout"`
	TLSOptions *TLSOptions   `json:"tls" mapstructure:"tls"`
}

MongoOptions contains options for connecting to a MongoDB server.

func NewMongoOptions

func NewMongoOptions() *MongoOptions

NewMongoOptions create a `zero` value instance.

func (*MongoOptions) AddFlags

func (o *MongoOptions) AddFlags(fs *pflag.FlagSet, prefixs ...string)

AddFlags adds flags related to redis storage for a specific APIServer to the specified FlagSet.

func (*MongoOptions) NewClient

func (o *MongoOptions) NewClient() (*mongo.Client, error)

NewClient creates a new MongoDB client based on the provided options.

func (*MongoOptions) Validate

func (o *MongoOptions) Validate() []error

Validate verifies flags passed to MongoOptions.

type MySQLOptions

type MySQLOptions struct {
	Host                  string        `json:"host,omitempty" mapstructure:"host"`
	Username              string        `json:"username,omitempty" mapstructure:"username"`
	Password              string        `json:"-" mapstructure:"password"`
	Database              string        `json:"database" mapstructure:"database"`
	MaxIdleConnections    int           `json:"max-idle-connections,omitempty" mapstructure:"max-idle-connections,omitempty"`
	MaxOpenConnections    int           `json:"max-open-connections,omitempty" mapstructure:"max-open-connections"`
	MaxConnectionLifeTime time.Duration `json:"max-connection-life-time,omitempty" mapstructure:"max-connection-life-time"`
	LogLevel              int           `json:"log-level" mapstructure:"log-level"`
}

MySQLOptions defines options for mysql database.

func NewMySQLOptions

func NewMySQLOptions() *MySQLOptions

NewMySQLOptions create a `zero` value instance.

func (*MySQLOptions) AddFlags

func (o *MySQLOptions) AddFlags(fs *pflag.FlagSet, prefixs ...string)

AddFlags adds flags related to mysql storage for a specific APIServer to the specified FlagSet.

func (*MySQLOptions) NewDB

func (o *MySQLOptions) NewDB() (*gorm.DB, error)

NewDB create mysql store with the given config.

func (*MySQLOptions) Validate

func (o *MySQLOptions) Validate() []error

Validate verifies flags passed to MySQLOptions.

type PolarisOptions

type PolarisOptions struct {
	Addr         string        `json:"addr" mapstructure:"addr"`
	ReadTimeout  time.Duration `json:"read-timeout" mapstructure:"read-timeout"`
	WriteTimeout time.Duration `json:"write-timeout" mapstructure:"write-timeout"`
}

PolarisOptions defines options for Polaris service.

func NewPolarisOptions

func NewPolarisOptions() *PolarisOptions

NewPolarisOptions create a `zero` value instance.

func (*PolarisOptions) AddFlags

func (o *PolarisOptions) AddFlags(fs *pflag.FlagSet, prefixs ...string)

AddFlags adds flags related to Polaris service to the specified FlagSet.

func (*PolarisOptions) Validate

func (o *PolarisOptions) Validate() []error

Validate verifies flags passed to PolarisOptions.

type ReaderOptions

type ReaderOptions struct {
	// GroupID holds the optional consumer group id. If GroupID is specified, then
	// Partition should NOT be specified e.g. 0
	GroupID string `mapstructure:"group-id"`

	// Partition to read messages from.  Either Partition or GroupID may
	// be assigned, but not both
	Partition int `mapstructure:"partition"`

	// The capacity of the internal message queue, defaults to 100 if none is
	// set.
	QueueCapacity int `mapstructure:"queue-capacity"`

	// MinBytes indicates to the broker the minimum batch size that the consumer
	// will accept. Setting a high minimum when consuming from a low-volume topic
	// may result in delayed delivery when the broker does not have enough data to
	// satisfy the defined minimum.
	//
	// Default: 1
	MinBytes int `mapstructure:"min-bytes"`

	// MaxBytes indicates to the broker the maximum batch size that the consumer
	// will accept. The broker will truncate a message to satisfy this maximum, so
	// choose a value that is high enough for your largest message size.
	//
	// Default: 1MB
	MaxBytes int `mapstructure:"max-bytes"`

	// Maximum amount of time to wait for new data to come when fetching batches
	// of messages from kafka.
	//
	// Default: 10s
	MaxWait time.Duration `mapstructure:"max-wait"`

	// ReadBatchTimeout amount of time to wait to fetch message from kafka messages batch.
	//
	// Default: 10s
	ReadBatchTimeout time.Duration `mapstructure:"read-batch-timeout"`

	// HeartbeatInterval sets the optional frequency at which the reader sends the consumer
	// group heartbeat update.
	//
	// Default: 3s
	//
	// Only used when GroupID is set
	HeartbeatInterval time.Duration `mapstructure:"heartbeat-interval"`

	// CommitInterval indicates the interval at which offsets are committed to
	// the broker.  If 0, commits will be handled synchronously.
	//
	// Default: 0
	//
	// Only used when GroupID is set
	CommitInterval time.Duration `mapstructure:"commit-interval"`

	// RebalanceTimeout optionally sets the length of time the coordinator will wait
	// for members to join as part of a rebalance.  For kafka servers under higher
	// load, it may be useful to set this value higher.
	//
	// Default: 30s
	//
	// Only used when GroupID is set
	RebalanceTimeout time.Duration `mapstructure:"rebalance-timeout"`

	// StartOffset determines from whence the consumer group should begin
	// consuming when it finds a partition without a committed offset.  If
	// non-zero, it must be set to one of FirstOffset or LastOffset.
	//
	// Default: FirstOffset
	//
	// Only used when GroupID is set
	StartOffset int64 `mapstructure:"start-offset"`

	// Limit of how many attempts will be made before delivering the error.
	//
	// The default is to try 3 times.
	MaxAttempts int `mapstructure:"max-attempts"`
}

type RedisOptions

type RedisOptions struct {
	Addr         string        `json:"addr" mapstructure:"addr"`
	Username     string        `json:"username" mapstructure:"username"`
	Password     string        `json:"password" mapstructure:"password"`
	Database     int           `json:"database" mapstructure:"database"`
	MaxRetries   int           `json:"max-retries" mapstructure:"max-retries"`
	MinIdleConns int           `json:"min-idle-conns" mapstructure:"min-idle-conns"`
	DialTimeout  time.Duration `json:"dial-timeout" mapstructure:"dial-timeout"`
	ReadTimeout  time.Duration `json:"read-timeout" mapstructure:"read-timeout"`
	WriteTimeout time.Duration `json:"write-timeout" mapstructure:"write-timeout"`
	PoolTimeout  time.Duration `json:"pool-time" mapstructure:"pool-time"`
	PoolSize     int           `json:"pool-size" mapstructure:"pool-size"`
	// tracing switch
	EnableTrace bool `json:"enable-trace" mapstructure:"enable-trace"`
}

RedisOptions defines options for redis cluster.

func NewRedisOptions

func NewRedisOptions() *RedisOptions

NewRedisOptions create a `zero` value instance.

func (*RedisOptions) AddFlags

func (o *RedisOptions) AddFlags(fs *pflag.FlagSet, prefixs ...string)

AddFlags adds flags related to redis storage for a specific APIServer to the specified FlagSet.

func (*RedisOptions) NewClient

func (o *RedisOptions) NewClient() (*redis.Client, error)

func (*RedisOptions) Validate

func (o *RedisOptions) Validate() []error

Validate verifies flags passed to RedisOptions.

type SecureServingOptions

type SecureServingOptions struct {
	BindAddress string `json:"bind-address"`
	// BindPort is ignored when Listener is set, will serve HTTPS even with 0.
	BindPort int `json:"bind-port"`
	// Required set to true means that BindPort cannot be zero.
	Required bool
	// ServerCert is the TLS cert info for serving secure traffic
	ServerCert GeneratableKeyCert `json:"tls"`
}

SecureServingOptions contains configuration items related to HTTPS server startup.

func NewSecureServingOptions

func NewSecureServingOptions() *SecureServingOptions

NewSecureServingOptions creates a SecureServingOptions object with default parameters.

func (*SecureServingOptions) AddFlags

func (s *SecureServingOptions) AddFlags(fs *pflag.FlagSet, prefixs ...string)

AddFlags adds flags related to HTTPS server for a specific APIServer to the specified FlagSet.

func (*SecureServingOptions) Complete

func (s *SecureServingOptions) Complete() error

Complete fills in any fields not set that are required to have valid data.

func (*SecureServingOptions) Validate

func (s *SecureServingOptions) Validate() []error

Validate is used to parse and validate the parameters entered by the user at the command line when the program starts.

type TLSOptions

type TLSOptions struct {
	// UseTLS specifies whether should be encrypted with TLS if possible.
	UseTLS             bool   `json:"use-tls" mapstructure:"use-tls"`
	InsecureSkipVerify bool   `json:"insecure-skip-verify" mapstructure:"insecure-skip-verify"`
	CaCert             string `json:"ca-cert" mapstructure:"ca-cert"`
	Cert               string `json:"cert" mapstructure:"cert"`
	Key                string `json:"key" mapstructure:"key"`
}

TLSOptions is the TLS cert info for serving secure traffic.

func NewTLSOptions

func NewTLSOptions() *TLSOptions

NewTLSOptions create a `zero` value instance.

func (*TLSOptions) AddFlags

func (o *TLSOptions) AddFlags(fs *pflag.FlagSet, prefixs ...string)

AddFlags adds flags related to redis storage for a specific APIServer to the specified FlagSet.

func (*TLSOptions) MustTLSConfig

func (o *TLSOptions) MustTLSConfig() *tls.Config

func (*TLSOptions) TLSConfig

func (o *TLSOptions) TLSConfig() (*tls.Config, error)

func (*TLSOptions) Validate

func (o *TLSOptions) Validate() []error

Validate verifies flags passed to TLSOptions.

type WriterOptions

type WriterOptions struct {
	// Limit on how many attempts will be made to deliver a message.
	//
	// The default is to try at most 10 times.
	MaxAttempts int `mapstructure:"max-attempts"`

	// Number of acknowledges from partition replicas required before receiving
	// a response to a produce request. The default is -1, which means to wait for
	// all replicas, and a value above 0 is required to indicate how many replicas
	// should acknowledge a message to be considered successful.
	//
	// This version of kafka-go (v0.3) does not support 0 required acks, due to
	// some internal complexity implementing this with the Kafka protocol. If you
	// need that functionality specifically, you'll need to upgrade to v0.4.
	RequiredAcks int `mapstructure:"required-acks"`

	// Setting this flag to true causes the WriteMessages method to never block.
	// It also means that errors are ignored since the caller will not receive
	// the returned value. Use this only if you don't care about guarantees of
	// whether the messages were written to kafka.
	Async bool `mapstructure:"async"`

	// Limit on how many messages will be buffered before being sent to a
	// partition.
	//
	// The default is to use a target batch size of 100 messages.
	BatchSize int `mapstructure:"batch-size"`

	// Time limit on how often incomplete message batches will be flushed to
	// kafka.
	//
	// The default is to flush at least every second.
	BatchTimeout time.Duration `mapstructure:"batch-timeout"`

	// Limit the maximum size of a request in bytes before being sent to
	// a partition.
	//
	// The default is to use a kafka default value of 1048576.
	BatchBytes int `mapstructure:"batch-bytes"`
}

Jump to

Keyboard shortcuts

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