-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_retention_policy.go
55 lines (45 loc) · 1.5 KB
/
create_retention_policy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package influxqb
import (
"github.com/influxdata/influxql"
"time"
)
type CreateRetentionPolicyBuilder struct {
ret *influxql.CreateRetentionPolicyStatement
}
func (b *CreateRetentionPolicyBuilder) WithDatabase(database string) *CreateRetentionPolicyBuilder {
b.ret.Database = database
return b
}
func (b *CreateRetentionPolicyBuilder) WithPolicyName(policyName string) *CreateRetentionPolicyBuilder {
b.ret.Name = policyName
return b
}
func (b *CreateRetentionPolicyBuilder) WithDuration(duration time.Duration) *CreateRetentionPolicyBuilder {
b.ret.Duration = duration
return b
}
func (b *CreateRetentionPolicyBuilder) WithDurationString(durationStr string) *CreateRetentionPolicyBuilder {
duration, _ := time.ParseDuration(durationStr)
b.WithDuration(duration)
return b
}
func (b *CreateRetentionPolicyBuilder) WithShardDuration(duration time.Duration) *CreateRetentionPolicyBuilder {
b.ret.ShardGroupDuration = duration
return b
}
func (b *CreateRetentionPolicyBuilder) WithShardDurationString(durationStr string) *CreateRetentionPolicyBuilder {
duration, _ := time.ParseDuration(durationStr)
b.WithShardDuration(duration)
return b
}
func (b *CreateRetentionPolicyBuilder) WithReplicationFactor(replication int) *CreateRetentionPolicyBuilder {
b.ret.Replication = replication
return b
}
func (b *CreateRetentionPolicyBuilder) SetAsDefault() *CreateRetentionPolicyBuilder {
b.ret.Default = true
return b
}
func (b *CreateRetentionPolicyBuilder) Build() (string, error) {
return b.ret.String(), nil
}