conf

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 11, 2021 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AloneConfig

type AloneConfig struct {
	// The network type, either tcp or unix.
	// Default is tcp.
	Network string `json:"network"`
	// host:port address.
	Addr     string `json:"addr"`
	Username string `json:"username"`
	Password string `json:"password"`
	DB       int    `json:"db"`

	MaxRetries int `json:"max_retries"`
	// Minimum backoff between each retry.
	// Default is 8 milliseconds; -1 disables backoff.
	MinRetryBackoff int64 `json:"min_retry_backoff"`
	// Maximum backoff between each retry.
	// Default is 512 milliseconds; -1 disables backoff.
	MaxRetryBackoff int64 `json:"max_retry_backoff"`

	// Dial timeout for establishing new connections.
	// Default is 5 seconds.
	DialTimeout int64 `json:"dial_timeout"`
	// Timeout for socket reads. If reached, commands will fail
	// with a timeout instead of blocking. Use value -1 for no timeout and 0 for default.
	// Default is 3 seconds.
	ReadTimeout int64 `json:"read_timeout"`
	// Timeout for socket writes. If reached, commands will fail
	// with a timeout instead of blocking.
	// Default is ReadTimeout.
	WriteTimeout int64 `json:"write_timeout"`

	// Maximum number of socket connections.
	// Default is 10 connections per every CPU as reported by runtime.NumCPU.
	PoolSize int `json:"pool_size"`
	// Minimum number of idle connections which is useful when establishing
	// new connection is slow.
	MinIdleConns int `json:"min_idle_conns"`
	// Connection age at which client retires (closes) the connection.
	// Default is to not close aged connections.
	MaxConnAge int64 `json:"max_conn_age"`
	// Amount of time client waits for connection if all connections
	// are busy before returning an error.
	// Default is ReadTimeout + 1 second.
	PoolTimeout int64 `json:"pool_timeout"`
	// Amount of time after which client closes idle connections.
	// Should be less than server's timeout.
	// Default is 5 minutes. -1 disables idle timeout check.
	IdleTimeout int64 `json:"idle_timeout"`
	// Frequency of idle checks made by idle connections reaper.
	// Default is 1 minute. -1 disables idle connections reaper,
	// but idle connections are still discarded by the client
	// if IdleTimeout is set.
	IdleCheckFrequency int64 `json:"idle_check_frequency"`
}

type ClusterConfig

type ClusterConfig struct {
	// A seed list of host:port addresses of cluster nodes.
	Addrs []string `json:"addrs"`

	// The maximum number of retries before giving up. Command is retried
	// on network errors and MOVED/ASK redirects.
	// Default is 8 retries.
	MaxRedirects int `json:"max_redirects"`

	// Enables read-only commands on slave nodes.
	ReadOnly bool `json:"read_only"`
	// Allows routing read-only commands to the closest master or slave node.
	// It automatically enables ReadOnly.
	RouteByLatency bool `json:"route_by_latency"`
	// Allows routing read-only commands to the random master or slave node.
	// It automatically enables ReadOnly.
	RouteRandomly bool `json:"route_randomly"`

	Username string `json:"username"`
	Password string `json:"password"`

	MaxRetries      int   `json:"max_retries"`
	MinRetryBackoff int64 `json:"min_retry_backoff"`
	MaxRetryBackoff int64 `json:"max_retry_backoff"`

	DialTimeout  int64 `json:"dial_timeout"`
	ReadTimeout  int64 `json:"read_timeout"`
	WriteTimeout int64 `json:"write_timeout"`

	// PoolSize applies per cluster node and not for the whole cluster.
	PoolSize           int   `json:"pool_size"`
	MinIdleConns       int   `json:"min_idle_conns"`
	MaxConnAge         int64 `json:"max_conn_age"`
	PoolTimeout        int64 `json:"pool_timeout"`
	IdleTimeout        int64 `json:"idle_timeout"`
	IdleCheckFrequency int64 `json:"idle_check_frequency"`
}

type Config

type Config struct {
	ConnType string         `json:"conn_type"` // cluster alone  sentinel
	Alone    AloneConfig    `json:"alone"`
	Cluster  ClusterConfig  `json:"cluster"`
	Sentinel SentinelConfig `json:"sentinel"`
}

type SentinelConfig

type SentinelConfig struct {
	// Map of name => host:port addresses of ring shards.
	Addrs map[string]string `json:"addrs"`

	// Map of name => password of ring shards, to allow different shards to have
	// different passwords. It will be ignored if the Password field is set.
	Passwords string `json:"passwords"`

	// Frequency of PING commands sent to check shards availability.
	// Shard is considered down after 3 subsequent failed checks.
	HeartbeatFrequency int64 `json:"heartbeat_frequency"`

	HashReplicas int `json:"hash_replicas"`

	DB       int    `json:"db"`
	Password string `json:"password"`

	MaxRetries      int   `json:"max_retries"`
	MinRetryBackoff int64 `json:"min_retry_backoff"`
	MaxRetryBackoff int64 `json:"max_retry_backoff"`

	DialTimeout  int64 `json:"dial_timeout"`
	ReadTimeout  int64 `json:"read_timeout"`
	WriteTimeout int64 `json:"write_timeout"`

	PoolSize           int   `json:"pool_size"`
	MinIdleConns       int   `json:"min_idle_conns"`
	MaxConnAge         int64 `json:"max_conn_age"`
	PoolTimeout        int64 `json:"pool_timeout"`
	IdleTimeout        int64 `json:"idle_timeout"`
	IdleCheckFrequency int64 `json:"idle_check_frequency"`
}

Jump to

Keyboard shortcuts

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