Merge pull request #343 from mrd0ll4r/storage-defaults
storage: update config defaults
This commit is contained in:
commit
153ad325b7
3 changed files with 49 additions and 21 deletions
|
@ -1,7 +1,7 @@
|
|||
chihaya:
|
||||
# The interval communicated with BitTorrent clients informing them how
|
||||
# frequently they should announce in between client events.
|
||||
announce_interval: 15m
|
||||
announce_interval: 30m
|
||||
|
||||
# The network interface that will bind to an HTTP endpoint that can be
|
||||
# scraped by an instance of the Prometheus time series database.
|
||||
|
@ -70,11 +70,11 @@ chihaya:
|
|||
name: memory
|
||||
config:
|
||||
# The frequency which stale peers are removed.
|
||||
gc_interval: 14m
|
||||
gc_interval: 3m
|
||||
|
||||
# The amount of time until a peer is considered stale.
|
||||
# To avoid churn, keep this slightly larger than `announce_interval`
|
||||
peer_lifetime: 16m
|
||||
peer_lifetime: 31m
|
||||
|
||||
# The number of partitions data will be divided into in order to provide a
|
||||
# higher degree of parallelism.
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"encoding/binary"
|
||||
"net"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
@ -21,6 +20,14 @@ import (
|
|||
// Name is the name by which this peer store is registered with Chihaya.
|
||||
const Name = "memory"
|
||||
|
||||
// Default config constants.
|
||||
const (
|
||||
defaultShardCount = 1024
|
||||
defaultPrometheusReportingInterval = time.Second * 1
|
||||
defaultGarbageCollectionInterval = time.Minute * 3
|
||||
defaultPeerLifetime = time.Minute * 30
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Register the storage driver.
|
||||
storage.RegisterDriver(Name, driver{})
|
||||
|
@ -70,19 +77,17 @@ func (cfg Config) LogFields() log.Fields {
|
|||
// This function warns to the logger when a value is changed.
|
||||
func (cfg Config) Validate() Config {
|
||||
validcfg := cfg
|
||||
if cfg.ShardCount > 0 {
|
||||
validcfg.ShardCount = cfg.ShardCount
|
||||
} else {
|
||||
validcfg.ShardCount = 1024
|
||||
if cfg.ShardCount <= 0 {
|
||||
validcfg.ShardCount = defaultShardCount
|
||||
log.WithFields(log.Fields{
|
||||
"name": Name + ".ShardCount",
|
||||
"provided": strconv.Itoa(cfg.ShardCount),
|
||||
"default": strconv.Itoa(validcfg.ShardCount),
|
||||
"provided": cfg.ShardCount,
|
||||
"default": validcfg.ShardCount,
|
||||
}).Warnln("falling back to default configuration")
|
||||
}
|
||||
|
||||
if cfg.GarbageCollectionInterval <= 0 {
|
||||
validcfg.GarbageCollectionInterval = time.Minute * 14
|
||||
validcfg.GarbageCollectionInterval = defaultGarbageCollectionInterval
|
||||
log.WithFields(log.Fields{
|
||||
"name": Name + ".GarbageCollectionInterval",
|
||||
"provided": cfg.GarbageCollectionInterval,
|
||||
|
@ -91,7 +96,7 @@ func (cfg Config) Validate() Config {
|
|||
}
|
||||
|
||||
if cfg.PrometheusReportingInterval <= 0 {
|
||||
validcfg.PrometheusReportingInterval = time.Second * 1
|
||||
validcfg.PrometheusReportingInterval = defaultPrometheusReportingInterval
|
||||
log.WithFields(log.Fields{
|
||||
"name": Name + ".PrometheusReportingInterval",
|
||||
"provided": cfg.PrometheusReportingInterval,
|
||||
|
@ -99,6 +104,15 @@ func (cfg Config) Validate() Config {
|
|||
}).Warnln("falling back to default configuration")
|
||||
}
|
||||
|
||||
if cfg.PeerLifetime <= 0 {
|
||||
validcfg.PeerLifetime = defaultPeerLifetime
|
||||
log.WithFields(log.Fields{
|
||||
"name": Name + ".PeerLifetime",
|
||||
"provided": cfg.PeerLifetime,
|
||||
"default": validcfg.PeerLifetime,
|
||||
}).Warnln("falling back to default configuration")
|
||||
}
|
||||
|
||||
return validcfg
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
"encoding/binary"
|
||||
"net"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
@ -22,6 +21,14 @@ import (
|
|||
// Name is the name by which this peer store is registered with Chihaya.
|
||||
const Name = "memorybysubnet"
|
||||
|
||||
// Default config constants.
|
||||
const (
|
||||
defaultShardCount = 1024
|
||||
defaultPrometheusReportingInterval = time.Second * 1
|
||||
defaultGarbageCollectionInterval = time.Minute * 3
|
||||
defaultPeerLifetime = time.Minute * 30
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Register the storage driver.
|
||||
storage.RegisterDriver(Name, driver{})
|
||||
|
@ -75,19 +82,17 @@ func (cfg Config) LogFields() log.Fields {
|
|||
// This function warns to the logger when a value is changed.
|
||||
func (cfg Config) Validate() Config {
|
||||
validcfg := cfg
|
||||
if cfg.ShardCount > 0 {
|
||||
validcfg.ShardCount = cfg.ShardCount
|
||||
} else {
|
||||
validcfg.ShardCount = 1024
|
||||
if cfg.ShardCount <= 0 {
|
||||
validcfg.ShardCount = defaultShardCount
|
||||
log.WithFields(log.Fields{
|
||||
"name": Name + ".ShardCount",
|
||||
"provided": strconv.Itoa(cfg.ShardCount),
|
||||
"default": strconv.Itoa(validcfg.ShardCount),
|
||||
"provided": cfg.ShardCount,
|
||||
"default": validcfg.ShardCount,
|
||||
}).Warnln("falling back to default configuration")
|
||||
}
|
||||
|
||||
if cfg.GarbageCollectionInterval <= 0 {
|
||||
validcfg.GarbageCollectionInterval = time.Minute * 14
|
||||
validcfg.GarbageCollectionInterval = defaultGarbageCollectionInterval
|
||||
log.WithFields(log.Fields{
|
||||
"name": Name + ".GarbageCollectionInterval",
|
||||
"provided": cfg.GarbageCollectionInterval,
|
||||
|
@ -96,7 +101,7 @@ func (cfg Config) Validate() Config {
|
|||
}
|
||||
|
||||
if cfg.PrometheusReportingInterval <= 0 {
|
||||
validcfg.PrometheusReportingInterval = time.Second * 1
|
||||
validcfg.PrometheusReportingInterval = defaultPrometheusReportingInterval
|
||||
log.WithFields(log.Fields{
|
||||
"name": Name + ".PrometheusReportingInterval",
|
||||
"provided": cfg.PrometheusReportingInterval,
|
||||
|
@ -104,6 +109,15 @@ func (cfg Config) Validate() Config {
|
|||
}).Warnln("falling back to default configuration")
|
||||
}
|
||||
|
||||
if cfg.PeerLifetime <= 0 {
|
||||
validcfg.PeerLifetime = defaultPeerLifetime
|
||||
log.WithFields(log.Fields{
|
||||
"name": Name + ".PeerLifetime",
|
||||
"provided": cfg.PeerLifetime,
|
||||
"default": validcfg.PeerLifetime,
|
||||
}).Warnln("falling back to default configuration")
|
||||
}
|
||||
|
||||
return validcfg
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue