Documentation ¶
Index ¶
Constants ¶
const ( DefaultDialTimeout = 5 * time.Second DefaultReadTimeout = 3 * time.Second DefaultWriteTimeout = 3 * time.Second )
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 )
const ( // DefaultPort is for Olric DefaultPort = 3320 // DefaultDiscoveryPort is for memberlist DefaultDiscoveryPort = 3322 // DefaultPartitionCount denotes 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 denotes default log verbosity level. // // * flog.V(1) - Generally useful for this to ALWAYS be visible to an operator // * Programmer errors // * Logging extra info about a panic // * CLI argument handling // * flog.V(2) - A reasonable default log level if you don't want verbosity. // * Information about config (listening on X, watching Y) // * Errors that repeat frequently that relate to conditions that can be corrected (pod detected as unhealthy) // * flog.V(3) - Useful steady state information about the service and important log messages that may correlate to // significant changes in the system. This is the recommended default log level for most systems. // * Logging HTTP requests and their exit code // * System state changing (killing pod) // * Controller state change events (starting pods) // * Scheduler log messages // * flog.V(4) - Extended information about changes // * More info about system state changes // * flog.V(5) - Debug level verbosity // * Logging in particularly thorny parts of code where you may want to come back later and check it // * flog.V(6) - Trace level verbosity // * Context to understand the steps leading up to errors and warnings // * More information for troubleshooting reported issues DefaultLogVerbosity = 3 // MinimumReplicaCount denotes default and minimum replica count in an Olric cluster. MinimumReplicaCount = 1 // DefaultBootstrapTimeout denotes default timeout value to check bootstrapping status. DefaultBootstrapTimeout = 10 * time.Second // DefaultJoinRetryInterval denotes a time gap between sequential join attempts. DefaultJoinRetryInterval = time.Second // DefaultMaxJoinAttempts denotes a maximum number of failed join attempts // before forming a standalone cluster. DefaultMaxJoinAttempts = 10 // MinimumMemberCountQuorum denotes minimum required count of members to form a cluster. MinimumMemberCountQuorum = 1 DefaultLRUSamples int = 5 // Assign this as EvictionPolicy in order to enable LRU eviction algorithm. LRUEviction EvictionPolicy = "LRU" DefaultStorageEngine = "olric.kvstore" )
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 Client ¶ added in v0.3.0
type Client struct { // Timeout for TCP dial. // // The timeout includes name resolution, if required. When using TCP, and the host in the address parameter // resolves to multiple IP addresses, the timeout is spread over each consecutive dial, such that each is // given an appropriate fraction of the time to connect. DialTimeout time.Duration // 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 DefaultReadTimeout ReadTimeout time.Duration // Timeout for socket writes. If reached, commands will fail // with a timeout instead of blocking. // Default is DefaultWriteTimeout WriteTimeout time.Duration // KeepAlive specifies the interval between keep-alive // probes for an active network connection. // If zero, keep-alive probes are sent with a default value // (currently 15 seconds), if supported by the protocol and operating // system. Network protocols or operating systems that do // not support keep-alives ignore this field. // If negative, keep-alive probes are disabled. KeepAlive time.Duration // Minimum TCP connection count in the pool for a host:port MinConn int // Maximum TCP connection count in the pool for a host:port MaxConn int }
Configuration for TCP clients in Olric and the official Golang client.
func NewClient ¶ added in v0.3.0
func NewClient() *Client
NewClient returns a new configuration object for clients.
func (*Client) HasTimeout ¶ added in v0.3.0
type Config ¶
type Config struct { // Interface denotes a binding interface. It can be used instead of BindAddr if the interface is known but not the address. // If both are provided, then Olric verifies that the interface has the bind address that is provided. Interface string // LogVerbosity denotes the level of message verbosity. The default value is 3. Valid values are between 1 to 6. LogVerbosity int32 // Default LogLevel is DEBUG. Valid ones: "DEBUG", "WARN", "ERROR", "INFO" LogLevel string // BindAddr denotes the address that Olric will bind to for communication with other Olric nodes. BindAddr string // BindPort denotes the address that Olric will bind to for communication with other Olric nodes. BindPort int Client *Client // KeepAlivePeriod denotes whether the operating system should send keep-alive messages on the connection. KeepAlivePeriod time.Duration // Timeout for bootstrap control // // An Olric node checks operation status before taking any action for the cluster events, responding incoming requests // and running API functions. Bootstrapping status is one of the most important checkpoints for an "operable" Olric node. // BootstrapTimeout sets a deadline to check bootstrapping status without blocking indefinitely. BootstrapTimeout 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 // Minimum number of successful reads to return a response for a read request. ReadQuorum int // Minimum number of successful writes to return a response for a write request. WriteQuorum int // Minimum number of members to form a cluster and run any query on the cluster. MemberCountQuorum int32 // Switch to control read-repair algorithm which helps to reduce entropy. 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 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 DMaps *DMaps JoinRetryInterval time.Duration MaxJoinAttempts int // Callback function. Olric calls this after // the server is ready to accept new connections. Started func() ServiceDiscovery map[string]interface{} // Interface denotes a binding interface. It can be used instead of memberlist.Loader.BindAddr if the interface is // known but not the address. If both are provided, then Olric verifies that the interface has the bind address that // is provided. MemberlistInterface string // 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 StorageEngines *StorageEngines }
Config is the configuration to create a Olric instance.
func New ¶
DefaultConfig returns a Config with sane defaults. It takes an env parameter used by memberlist: 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.
func (*Config) Sanitize ¶
Sanitize sanitizes the given configuration. It returns an error if there is something very bad in the configuration.
func (*Config) SetupNetworkConfig ¶
SetupNetworkConfig tries to find an appropriate bindIP to bind and propagate.
type DMap ¶ added in v0.4.0
type DMap struct { // MaxIdleDuration denotes maximum time for each entry to stay idle in the dmap. // It limits the lifetime of the entries relative to the time of the last // read or write access performed on them. The entries whose idle period exceeds // this limit are expired and evicted automatically. An entry is idle if no Get, // Put, PutEx, Expire, PutIf, PutIfEx on it. Configuration of MaxIdleDuration // feature varies by preferred deployment method. MaxIdleDuration time.Duration // TTLDuration is useful to set a default TTL for every key/value pair a dmap instance. TTLDuration time.Duration // MaxKeys denotes maximum key count on a particular node. So if you have 10 nodes with // MaxKeys=100000, your key count in the cluster should be around MaxKeys*10=1000000 MaxKeys int // MaxInuse denotes maximum amount of in-use memory on a particular node. So if you have 10 nodes with // MaxInuse=100M (it has to be in bytes), amount of in-use memory should be around MaxInuse*10=1G MaxInuse int // LRUSamples denotes amount of randomly selected key count by the aproximate LRU implementation. // Lower values are better for high performance. It's 5 by default. LRUSamples int // EvictionPolicy determines the eviction policy in use. It's NONE by default. // Set as LRU to enable LRU eviction policy. EvictionPolicy EvictionPolicy StorageEngine string }
DMap denotes cache configuration for a particular dmap.
type DMaps ¶ added in v0.4.0
type DMaps struct { // NumEvictionWorkers denotes the number of goroutines that's used to find keys for eviction. NumEvictionWorkers int64 // MaxIdleDuration denotes maximum time for each entry to stay idle in the dmap. // It limits the lifetime of the entries relative to the time of the last // read or write access performed on them. The entries whose idle period exceeds // this limit are expired and evicted automatically. An entry is idle if no Get, // Put, PutEx, Expire, PutIf, PutIfEx on it. Configuration of MaxIdleDuration // feature varies by preferred deployment method. MaxIdleDuration time.Duration // TTLDuration is useful to set a default TTL for every key/value pair a dmap instance. TTLDuration time.Duration // MaxKeys denotes maximum key count on a particular node. So if you have 10 nodes with // MaxKeys=100000, your key count in the cluster should be around MaxKeys*10=1000000 MaxKeys int // MaxInuse denotes maximum amount of in-use memory on a particular node. So if you have 10 nodes with // MaxInuse=100M (it has to be in bytes), amount of in-use memory should be around MaxInuse*10=1G MaxInuse int // LRUSamples denotes amount of randomly selected key count by the aproximate LRU implementation. // Lower values are better for high performance. It's 5 by default. LRUSamples int // EvictionPolicy determines the eviction policy in use. It's NONE by default. // Set as LRU to enable LRU eviction policy. EvictionPolicy EvictionPolicy StorageEngine string // Custom is useful to set custom cache config per DMap instance. Custom map[string]DMap }
DMaps denotes a global configuration for DMaps. You can still overwrite it by setting a DMap for a particular dmap. Don't set this if you use Olric as an ordinary key/value store.
type EvictionPolicy ¶
type EvictionPolicy string
EvictionPolicy denotes eviction policy. Currently: LRU or NONE.
type StorageEngines ¶ added in v0.4.0
type StorageEngines struct { Plugins []string Impls map[string]storage.Engine Config map[string]map[string]interface{} }
func NewStorageEngine ¶ added in v0.4.0
func NewStorageEngine() *StorageEngines