-
Notifications
You must be signed in to change notification settings - Fork 0
/
alter_retention_policy.go
89 lines (73 loc) · 2.45 KB
/
alter_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
78
79
80
81
82
83
84
85
86
87
88
89
package influxqb
import (
"github.com/influxdata/influxql"
"time"
)
/*
// Duration of the Shard.
ShardGroupDuration *time.Duration
*/
type AlterRetentionPolicyBuilder struct {
alterStm *influxql.AlterRetentionPolicyStatement
}
func (b *AlterRetentionPolicyBuilder) WithDatabase(database string) *AlterRetentionPolicyBuilder {
b.alterStm.Database = database
return b
}
func (b *AlterRetentionPolicyBuilder) WithPolicyName(policyName string) *AlterRetentionPolicyBuilder {
b.alterStm.Name = policyName
return b
}
func (b *AlterRetentionPolicyBuilder) WithDuration(duration *time.Duration) *AlterRetentionPolicyBuilder {
b.alterStm.Duration = duration
return b
}
func (b *AlterRetentionPolicyBuilder) WithDurationString(durationStr string) *AlterRetentionPolicyBuilder {
duration := new(time.Duration)
*duration, _ = time.ParseDuration(durationStr)
b.WithDuration(duration)
return b
}
func (b *AlterRetentionPolicyBuilder) WithShardDuration(duration *time.Duration) *AlterRetentionPolicyBuilder {
b.alterStm.ShardGroupDuration = duration
return b
}
func (b *AlterRetentionPolicyBuilder) WithShardDurationString(durationStr string) *AlterRetentionPolicyBuilder {
duration := new(time.Duration)
*duration, _ = time.ParseDuration(durationStr)
b.WithShardDuration(duration)
return b
}
func (b *AlterRetentionPolicyBuilder) WithReplicationFactor(replication int) *AlterRetentionPolicyBuilder {
n := new(int)
*n = replication
b.alterStm.Replication = n
return b
}
func (b *AlterRetentionPolicyBuilder) WithFutureLimit(futureLimit *time.Duration) *AlterRetentionPolicyBuilder {
b.alterStm.FutureWriteLimit = futureLimit
return b
}
func (b *AlterRetentionPolicyBuilder) WithFutureLimitString(futureLimit string) *AlterRetentionPolicyBuilder {
duration := new(time.Duration)
*duration, _ = time.ParseDuration(futureLimit)
b.WithFutureLimit(duration)
return b
}
func (b *AlterRetentionPolicyBuilder) WithPastLimit(pastLimit *time.Duration) *AlterRetentionPolicyBuilder {
b.alterStm.PastWriteLimit = pastLimit
return b
}
func (b *AlterRetentionPolicyBuilder) WithPastLimitString(pastLimitStr string) *AlterRetentionPolicyBuilder {
duration := new(time.Duration)
*duration, _ = time.ParseDuration(pastLimitStr)
b.WithPastLimit(duration)
return b
}
func (b *AlterRetentionPolicyBuilder) SetAsDefault() *AlterRetentionPolicyBuilder {
b.alterStm.Default = true
return b
}
func (b *AlterRetentionPolicyBuilder) Build() (string, error) {
return b.alterStm.String(), nil
}