-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_retention_policy.go
77 lines (63 loc) · 2.21 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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) WithFutureLimit(futureLimit time.Duration) *CreateRetentionPolicyBuilder {
b.ret.FutureWriteLimit = futureLimit
return b
}
func (b *CreateRetentionPolicyBuilder) WithFutureLimitString(futureLimit string) *CreateRetentionPolicyBuilder {
duration, _ := time.ParseDuration(futureLimit)
b.WithFutureLimit(duration)
return b
}
func (b *CreateRetentionPolicyBuilder) WithPastLimit(pastLimit time.Duration) *CreateRetentionPolicyBuilder {
b.ret.PastWriteLimit = pastLimit
return b
}
func (b *CreateRetentionPolicyBuilder) WithPastLimitString(pastLimitStr string) *CreateRetentionPolicyBuilder {
duration, _ := time.ParseDuration(pastLimitStr)
b.WithPastLimit(duration)
return b
}
func (b *CreateRetentionPolicyBuilder) SetAsDefault() *CreateRetentionPolicyBuilder {
b.ret.Default = true
return b
}
func (b *CreateRetentionPolicyBuilder) Build() (string, error) {
return b.ret.String(), nil
}