config

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	Daemon Daemon `yaml:"daemon" json:"daemon"`

	ControlPlane ControlPlane `yaml:"control_plane" json:"control_plane"`

	FrontierManager FrontierManager `yaml:"frontier_plane" json:"frontier_manager"`

	Redis Redis `yaml:"redis" json:"redis"`
}

func Parse

func Parse() (*Configuration, error)

type ControlPlane

type ControlPlane struct {
	Listen config.Listen `yaml:"listen" json:"listen"`
}

for rest and grpc

type Daemon

type Daemon struct {
	RLimit RLimit `yaml:"rlimit" json:"r_limit"`
	PProf  PProf  `yaml:"pprof" json:"p_prof"`
}

type FrontierManager

type FrontierManager struct {
	Listen     config.Listen `yaml:"listen" json:"listen"`
	Expiration struct {
		ServiceMeta int `yaml:"service_meta" json:"service_meta"` // service meta expiration in redis, in seconds, default 86400s
		EdgeMeta    int `yaml:"edge_meta" json:"edge_meta"`       // edge meta expiration in redis, in seconds, default 86400s
	} `yaml:"expiration,omitempty" json:"expiration"`
}

type PProf

type PProf struct {
	Enable         bool   `yaml:"enable" json:"enable"`
	Addr           string `yaml:"addr" json:"addr"`
	CPUProfileRate int    `yaml:"cpu_profile_rate" json:"cpu_profile_rate"`
}

type RLimit

type RLimit struct {
	Enable  bool `yaml:"enable" json:"enable"`
	NumFile int  `yaml:"nofile" json:"num_file"`
}

daemon related

type Redis

type Redis struct {
	Mode string `yaml:"mode" json:"mode"` // standalone, sentinel or cluster

	// Use the specified Username to authenticate the current connection
	// with one of the connections defined in the ACL list when connecting
	// to a Redis 6.0 instance, or greater, that is using the Redis ACL system.
	Username string `yaml:"username,omitempty" json:"username"`

	// Optional password. Must match the password specified in the
	// requirepass server configuration option (if connecting to a Redis 5.0 instance, or lower),
	// or the User Password when connecting to a Redis 6.0 instance, or greater,
	// that is using the Redis ACL system.
	Password string `yaml:"password,omitempty" json:"password"`

	// Protocol 2 or 3. Use the version to negotiate RESP version with redis-server.
	// Default is 3.
	Protocol int `yaml:"protocol,omitempty" json:"protocol"`

	// ClientName will execute the `CLIENT SETNAME ClientName` command for each conn.
	ClientName string `yaml:"clientname,omitempty" json:"client_name"`

	// connection retry settings
	MaxRetries      int `yaml:"max_retries,omitempty" json:"max_retries"`
	MinRetryBackoff int `yaml:"min_retry_backoff,omitempty" json:"min_retry_backoff"`
	MaxRetryBackoff int `yaml:"max_retry_backoff,omitempty" json:"max_retry_backoff"`
	// connection r/w settings
	DialTimeout  int `yaml:"dial_timeout,omitempty" json:"dial_timeout"`
	ReadTimeout  int `yaml:"read_timeout,omitempty" json:"read_timeout"`
	WriteTimeout int `yaml:"write_timeout,omitempty" json:"write_timeout"`
	// connection pool settings
	PoolFIFO         bool   `yaml:"pool_fifo,omitempty" json:"pool_fifo"`
	PoolSize         int    `yaml:"pool_size,omitempty" json:"pool_size"` // applies per cluster node and not for the whole cluster
	PoolTimeout      int    `yaml:"pool_timeout,omitempty" json:"pool_timeout"`
	MinIdleConns     int    `yaml:"min_idle_conns,omitempty" json:"min_idle_conns"`
	MaxIdleConns     int    `yaml:"max_idle,omitempty" json:"max_idle_conns"`
	MaxActiveConns   int    `yaml:"max_active_conns,omitempty" json:"max_active_conns"` // applies per cluster node and not for the whole cluster
	ConnMaxIdleTime  int    `yaml:"conn_max_idle_time,omitempty" json:"conn_max_idle_time"`
	ConnMaxLifetime  int    `yaml:"conn_max_life_time,omitempty" json:"conn_max_lifetime"`
	DisableIndentity bool   `yaml:"disable_identity,omitempty" json:"disable_indentity"` // Disable set-lib on connect. Default is false.
	IdentitySuffix   string `yaml:"identity_suffix,omitempty" json:"identity_suffix"`    // Add suffix to client name. Default is empty.

	Standalone struct {
		// The network type, either tcp or unix.
		// Default is tcp.
		Network string `yaml:"network" json:"network"`
		// host:port address.
		Addr string `yaml:"addr" json:"addr"`
		// CredentialsProvider allows the username and password to be updated
		// before reconnecting. It should return the current username and password.
		DB int `yaml:"db" json:"db"`
	} `yaml:"standalone,omitempty" json:"standalone"`
	Sentinel struct {
		Addrs      []string `yaml:"addrs" json:"addrs"`
		MasterName string   `yaml:"master_name" json:"master_name"`
		DB         int      `yaml:"db" json:"db"`

		// route settings
		// Allows routing read-only commands to the closest master or replica node.
		// This option only works with NewFailoverClusterClient.
		RouteByLatency bool `yaml:"route_by_latency,omitempty" json:"route_by_latency"`
		// Allows routing read-only commands to the random master or replica node.
		// This option only works with NewFailoverClusterClient.
		RouteRandomly bool `yaml:"route_randomly,omitempty" json:"route_randomly"`
		// Route all commands to replica read-only nodes.
		ReplicaOnly bool `yaml:"replica_only,omitempty" json:"replica_only"`

		// Use replicas disconnected with master when cannot get connected replicas
		// Now, this option only works in RandomReplicaAddr function.
		UseDisconnectedReplicas bool `yaml:"use_disconnected_replicas,omitempty" json:"use_disconnected_replicas"`
	} `yaml:"sentinel,omitempty" json:"sentinel"`
	Cluster struct {
		Addrs []string `yaml:"addrs" json:"addrs"`
		// The maximum number of retries before giving up. Command is retried
		// on network errors and MOVED/ASK redirects.
		// Default is 3 retries.
		MaxRedirects int `yaml:"max_redirects,omitempty" json:"max_redirects"`
		// Allows routing read-only commands to the closest master or slave node.
		// It automatically enables ReadOnly.
		RouteByLatency bool `yaml:"route_by_latency,omitempty" json:"route_by_latency"`
		// Allows routing read-only commands to the random master or slave node.
		// It automatically enables ReadOnly.
		RouteRandomly bool `yaml:"route_randomly,omitempty" json:"route_randomly"`
	} `yaml:"cluster,omitempty" json:"cluster"`
}

TODO tls support

Jump to

Keyboard shortcuts

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