本文整理匯總了Golang中github.com/influxdata/influxdb/toml.Duration函數的典型用法代碼示例。如果您正苦於以下問題:Golang Duration函數的具體用法?Golang Duration怎麽用?Golang Duration使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Duration函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: NewConfig
// NewConfig returns the default configuration for tsdb.
func NewConfig() Config {
return Config{
Engine: DefaultEngine,
Enabled: true, // data node enabled by default
MaxWALSize: DefaultMaxWALSize,
WALFlushInterval: toml.Duration(DefaultWALFlushInterval),
WALPartitionFlushDelay: toml.Duration(DefaultWALPartitionFlushDelay),
WALLoggingEnabled: true,
WALReadySeriesSize: DefaultReadySeriesSize,
WALCompactionThreshold: DefaultCompactionThreshold,
WALMaxSeriesSize: DefaultMaxSeriesSize,
WALFlushColdInterval: toml.Duration(DefaultFlushColdInterval),
WALPartitionSizeThreshold: DefaultPartitionSizeThreshold,
QueryLogEnabled: true,
CacheMaxMemorySize: DefaultCacheMaxMemorySize,
CacheSnapshotMemorySize: DefaultCacheSnapshotMemorySize,
CacheSnapshotWriteColdDuration: toml.Duration(DefaultCacheSnapshotWriteColdDuration),
CompactFullWriteColdDuration: toml.Duration(DefaultCompactFullWriteColdDuration),
DataLoggingEnabled: true,
}
}
示例2: NewConfig
// NewConfig returns a new Config with defaults.
func NewConfig() Config {
return Config{
Enabled: true,
CheckInterval: toml.Duration(DefaultCheckInterval),
AdvancePeriod: toml.Duration(DefaultAdvancePeriod),
}
}
示例3: NewConfig
// NewConfig returns an instance of Config with defaults.
func NewConfig() Config {
return Config{
WriteTimeout: toml.Duration(DefaultWriteTimeout),
QueryTimeout: toml.Duration(influxql.DefaultQueryTimeout),
MaxConcurrentQueries: DefaultMaxConcurrentQueries,
MaxSelectPointN: DefaultMaxSelectPointN,
MaxSelectSeriesN: DefaultMaxSelectSeriesN,
}
}
示例4: NewConfig
// NewConfig returns an instance of Config with defaults.
func NewConfig() Config {
return Config{
WriteTimeout: toml.Duration(DefaultWriteTimeout),
ShardWriterTimeout: toml.Duration(DefaultShardWriterTimeout),
ShardMapperTimeout: toml.Duration(DefaultShardMapperTimeout),
QueryTimeout: toml.Duration(DefaultQueryTimeout),
MaxRemoteWriteConnections: DefaultMaxRemoteWriteConnections,
MaxConcurrentQueries: DefaultMaxConcurrentQueries,
MaxSelectSeriesN: DefaultMaxSelectSeriesN,
}
}
示例5: Init
func (c *Config) Init() {
c.Name = "default"
c.URLs = []string{"http://localhost:8086"}
c.ExcludedSubscriptions = map[string][]string{
stats.DefaultDatabse: []string{stats.DefaultRetentionPolicy},
}
c.UDPBuffer = udp.DefaultBuffer
c.StartUpTimeout = toml.Duration(DefaultStartUpTimeout)
c.SubscriptionProtocol = DefaultSubscriptionProtocol
c.SubscriptionSyncInterval = toml.Duration(DefaultSubscriptionSyncInterval)
}
示例6: NewConfig
// NewConfig returns a new Config.
func NewConfig() Config {
return Config{
Enabled: false,
MaxSize: DefaultMaxSize,
MaxAge: toml.Duration(DefaultMaxAge),
RetryRateLimit: DefaultRetryRateLimit,
RetryInterval: toml.Duration(DefaultRetryInterval),
RetryMaxInterval: toml.Duration(DefaultRetryMaxInterval),
PurgeInterval: toml.Duration(DefaultPurgeInterval),
}
}
示例7: SetDefaultValues
func (c *Config) SetDefaultValues() {
if c.UDPBuffer == 0 {
c.UDPBuffer = udp.DefaultBuffer
}
if c.StartUpTimeout == 0 {
c.StartUpTimeout = toml.Duration(DefaultStartUpTimeout)
}
if c.SubscriptionProtocol == "" {
c.SubscriptionProtocol = DefaultSubscriptionProtocol
}
if c.SubscriptionSyncInterval == toml.Duration(0) {
c.SubscriptionSyncInterval = toml.Duration(DefaultSubscriptionSyncInterval)
}
}
示例8: NewConfig
// NewConfig builds a new configuration with default values.
func NewConfig() *Config {
return &Config{
Enabled: true, // enabled by default
BindAddress: DefaultRaftBindAddress,
HTTPBindAddress: DefaultHTTPBindAddress,
RetentionAutoCreate: true,
ElectionTimeout: toml.Duration(DefaultElectionTimeout),
HeartbeatTimeout: toml.Duration(DefaultHeartbeatTimeout),
LeaderLeaseTimeout: toml.Duration(DefaultLeaderLeaseTimeout),
CommitTimeout: toml.Duration(DefaultCommitTimeout),
RaftPromotionEnabled: DefaultRaftPromotionEnabled,
LeaseDuration: toml.Duration(DefaultLeaseDuration),
LoggingEnabled: DefaultLoggingEnabled,
}
}
示例9: NewInfluxDBConfig
// NewInfluxDBConfig returns a new InfluxDBConfig with the default values.
func NewInfluxDBConfig() (*InfluxDBConfig, error) {
// Create the default InfluxDB server configuration.
server, err := influxDBServer.NewDemoConfig()
if err != nil {
return nil, err
}
// Enables retention policies which will be executed within an interval of 30 minutes.
server.Retention.Enabled = true
server.Retention.CheckInterval = toml.Duration(30 * time.Minute)
return &InfluxDBConfig{
Server: server,
// Specify the branch as "appdash" just for identification purposes.
BuildInfo: &influxDBServer.BuildInfo{
Branch: "appdash",
},
// Create a retention policy which keeps data for only three days, this is
// because the Dashboard is hard-coded to displaying a 72hr timeline.
//
// Minimum duration time is 1 hour ("1h") - See: github.com/influxdata/influxdb/issues/5198
DefaultRP: InfluxDBRetentionPolicy{
Name: "three_days_only",
Duration: "3d",
},
MaxBatchSizeBytes: 128 * 1024 * 1024, // 128 MB
BatchFlushInterval: 500 * time.Millisecond,
}, nil
}
示例10: WithDefaults
// WithDefaults takes the given config and returns a new config with any required
// default values set.
func (c *Config) WithDefaults() *Config {
d := *c
if d.BindAddress == "" {
d.BindAddress = DefaultBindAddress
}
if d.Database == "" {
d.Database = DefaultDatabase
}
if d.RetentionPolicy == "" {
d.RetentionPolicy = DefaultRetentionPolicy
}
if d.ConsistencyLevel == "" {
d.ConsistencyLevel = DefaultConsistencyLevel
}
if d.Certificate == "" {
d.Certificate = DefaultCertificate
}
if d.BatchSize == 0 {
d.BatchSize = DefaultBatchSize
}
if d.BatchPending == 0 {
d.BatchPending = DefaultBatchPending
}
if d.BatchTimeout == 0 {
d.BatchTimeout = toml.Duration(DefaultBatchTimeout)
}
return &d
}
示例11: NewConfig
func NewConfig() Config {
return Config{
Host: "localhost",
Port: 25,
IdleTimeout: toml.Duration(time.Second * 30),
}
}
示例12: NewTestService
func NewTestService(batchSize int, batchDuration time.Duration) *TestService {
c := Config{
BindAddress: "127.0.0.1:0",
Database: "collectd_test",
BatchSize: batchSize,
BatchDuration: toml.Duration(batchDuration),
}
s := &TestService{
Config: c,
Service: NewService(c),
MetaClient: &internal.MetaClientMock{},
}
s.MetaClient.CreateDatabaseFn = func(name string) (*meta.DatabaseInfo, error) {
return nil, nil
}
s.Service.PointsWriter = s
s.Service.MetaClient = s.MetaClient
// Set the collectd types using test string.
if err := s.Service.SetTypes(typesDBText); err != nil {
panic(err)
}
if testing.Verbose() {
s.Service.WithLogger(zap.New(
zap.NewTextEncoder(),
zap.Output(os.Stderr),
))
}
return s
}
示例13: WithDefaults
// WithDefaults takes the given config and returns a new config with any required
// default values set.
func (c *Config) WithDefaults() *Config {
d := *c
if d.Database == "" {
d.Database = DefaultDatabase
}
if d.BatchSize == 0 {
d.BatchSize = DefaultBatchSize
}
if d.BatchPending == 0 {
d.BatchPending = DefaultBatchPending
}
if d.BatchTimeout == 0 {
d.BatchTimeout = toml.Duration(DefaultBatchTimeout)
}
if d.Precision == "" {
d.Precision = DefaultPrecision
}
if d.ReadBuffer == 0 {
d.ReadBuffer = DefaultReadBuffer
}
if d.UDPPayloadSize == 0 {
d.UDPPayloadSize = DefaultUDPPayloadSize
}
return &d
}
示例14: TestShardWriter_Write_PoolMax
// Ensure the shard writer returns an error when we can't get a connection.
func TestShardWriter_Write_PoolMax(t *testing.T) {
ts := newTestWriteService(writeShardSlow)
s := cluster.NewService(cluster.Config{
ShardWriterTimeout: toml.Duration(100 * time.Millisecond),
})
s.Listener = ts.muxln
s.TSDBStore = &ts.TSDBStore
if err := s.Open(); err != nil {
t.Fatal(err)
}
defer s.Close()
defer ts.Close()
w := cluster.NewShardWriter(100*time.Millisecond, 1)
w.MetaClient = &metaClient{host: ts.ln.Addr().String()}
now := time.Now()
shardID := uint64(1)
ownerID := uint64(2)
var points []models.Point
points = append(points, models.MustNewPoint(
"cpu", models.Tags{"host": "server01"}, map[string]interface{}{"value": int64(100)}, now,
))
go w.WriteShard(shardID, ownerID, points)
time.Sleep(time.Millisecond)
if err := w.WriteShard(shardID, ownerID, points); err == nil || err.Error() != "timed out waiting for free connection" {
t.Fatalf("unexpected error: %v", err)
}
}
示例15: NewConfig
// NewConfig builds a new configuration with default values.
func NewConfig() *Config {
return &Config{
RetentionAutoCreate: true,
LeaseDuration: toml.Duration(DefaultLeaseDuration),
LoggingEnabled: DefaultLoggingEnabled,
}
}