config

package
v0.2.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: Apache-2.0 Imports: 12 Imported by: 23

Documentation

Index

Constants

View Source
const (
	// SyncReplicationMode enables sync replication mode which means that the caller is blocked
	// until write/delete operation is applied by replica owners. The default mode is SyncReplicationMode
	SyncReplicationMode = 0

	// AsyncReplicationMode enables async replication mode which means that write/delete operations
	// are done in a background task.
	AsyncReplicationMode = 1
)
View Source
const (
	// DefaultPartitionCount determines default partition count in the cluster.
	DefaultPartitionCount = 271

	// DefaultLoadFactor is used by the consistent hashing function. Keep it small.
	DefaultLoadFactor = 1.25

	// DefaultLogLevel determines the log level without extra configuration. It's DEBUG.
	DefaultLogLevel = "DEBUG"

	DefaultLogVerbosity = 2

	// MinimumReplicaCount determines the default and minimum replica count in an Olric cluster.
	MinimumReplicaCount = 1

	DefaultRequestTimeout = 10 * time.Second

	DefaultJoinRetryInterval = time.Second

	DefaultMaxJoinAttempts = 10

	MinimumMemberCountQuorum = 1

	DefaultTableSize = 1 << 20
)
View Source
const (
	DefaultLRUSamples int            = 5
	LRUEviction       EvictionPolicy = "LRU"
)

Variables

This section is empty.

Functions

func NewMemberlistConfig

func NewMemberlistConfig(env string) (*memberlist.Config, error)

NewMemberlistConfig returns a new memberlist.Config from vendored version of that package. It takes an env parameter: local, lan and wan.

local: DefaultLocalConfig works like DefaultConfig, however it returns a configuration that is optimized for a local loopback environments. The default configuration is still very conservative and errs on the side of caution.

lan: DefaultLANConfig returns a sane set of configurations for Memberlist. It uses the hostname as the node name, and otherwise sets very conservative values that are sane for most LAN environments. The default configuration errs on the side of caution, choosing values that are optimized for higher convergence at the cost of higher bandwidth usage. Regardless, these values are a good starting point when getting started with memberlist.

wan: DefaultWANConfig works like DefaultConfig, however it returns a configuration that is optimized for most WAN environments. The default configuration is still very conservative and errs on the side of caution.

Types

type CacheConfig

type CacheConfig struct {
	NumEvictionWorkers int64
	MaxIdleDuration    time.Duration
	TTLDuration        time.Duration
	MaxKeys            int
	MaxInuse           int
	LRUSamples         int
	EvictionPolicy     EvictionPolicy
	DMapConfigs        map[string]DMapCacheConfig // For fine grained configuration.
}

type Config

type Config struct {
	LogVerbosity int32
	LogLevel     string
	// Name of this node in the cluster. This must be unique in the cluster. If this is not set,
	// Olric will set it to the hostname of the running machine. Example: node1.my-cluster.net
	//
	// Name is also used by the TCP server as Addr. It should be an IP address or domain name of the server.
	Name string

	KeepAlivePeriod time.Duration

	DialTimeout time.Duration

	RequestTimeout time.Duration

	// The list of host:port which are used by memberlist for discovery. Don't confuse it with Name.
	Peers []string

	// PartitionCount is 271, by default.
	PartitionCount uint64

	// ReplicaCount is 1, by default.
	ReplicaCount int

	ReadQuorum        int
	WriteQuorum       int
	MemberCountQuorum int32

	ReadRepair bool

	// Default value is SyncReplicationMode.
	ReplicationMode int

	// LoadFactor is used by consistent hashing function. It determines the maximum load
	// for a server in the cluster. Keep it small.
	LoadFactor float64

	// Default hasher is github.com/cespare/xxhash. You may want to use a different
	// hasher which implements Hasher interface.
	Hasher hasher.Hasher

	// Default Serializer implementation uses gob for encoding/decoding.
	Serializer serializer.Serializer

	// LogOutput is the writer where logs should be sent. If this is not
	// set, logging will go to stderr by default. You cannot specify both LogOutput
	// and Logger at the same time.
	LogOutput io.Writer

	// Logger is a custom logger which you provide. If Logger is set, it will use
	// this for the internal logger. If Logger is not set, it will fall back to the
	// behavior for using LogOutput. You cannot specify both LogOutput and Logger
	// at the same time.
	Logger *log.Logger

	Cache     *CacheConfig
	TableSize int

	JoinRetryInterval time.Duration
	MaxJoinAttempts   int

	// MemberlistConfig is the memberlist configuration that Olric will
	// use to do the underlying membership management and gossip. Some
	// fields in the MemberlistConfig will be overwritten by Olric no
	// matter what:
	//
	//   * Name - This will always be set to the same as the NodeName
	//     in this configuration.
	//
	//   * ClusterEvents - Olric uses a custom event delegate.
	//
	//   * Delegate - Olric uses a custom delegate.
	//
	// You have to use NewMemberlistConfig to create a new one.
	// Then, you may need to modify it to tune for your environment.
	MemberlistConfig *memberlist.Config
}

Config is the configuration to create a Olric instance.

func (*Config) Sanitize

func (c *Config) Sanitize() error

Sanitize sanitizes the given configuration. It returns an error if there is something very bad in the configuration.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the given configuration.

type DMapCacheConfig

type DMapCacheConfig struct {
	MaxIdleDuration time.Duration
	TTLDuration     time.Duration
	MaxKeys         int
	MaxInuse        int
	LRUSamples      int
	EvictionPolicy  EvictionPolicy
}

type EvictionPolicy

type EvictionPolicy string

Jump to

Keyboard shortcuts

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