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