|
17 | 17 | package config |
18 | 18 |
|
19 | 19 | import ( |
20 | | - "gopkg.in/yaml.v3" |
21 | 20 | "os" |
22 | 21 | "strings" |
| 22 | + |
| 23 | + "gopkg.in/yaml.v3" |
23 | 24 | ) |
24 | 25 |
|
25 | 26 | // MetaConfig stores the metadata storage configuration. |
@@ -80,6 +81,31 @@ type RetentionPolicyConfig struct { |
80 | 81 | TTL int `yaml:"ttl"` // Time to live for truncated segments before eligible for GC |
81 | 82 | } |
82 | 83 |
|
| 84 | +// FencePolicyConfig stores the fence policy configuration. |
| 85 | +type FencePolicyConfig struct { |
| 86 | + ConditionWrite string `yaml:"conditionWrite"` |
| 87 | +} |
| 88 | + |
| 89 | +func (f *FencePolicyConfig) IsConditionWriteEnabled() bool { |
| 90 | + return strings.EqualFold(f.ConditionWrite, "enable") |
| 91 | +} |
| 92 | + |
| 93 | +func (f *FencePolicyConfig) IsConditionWriteDisabled() bool { |
| 94 | + return strings.EqualFold(f.ConditionWrite, "disable") |
| 95 | +} |
| 96 | + |
| 97 | +func (f *FencePolicyConfig) IsConditionWriteAuto() bool { |
| 98 | + return strings.EqualFold(f.ConditionWrite, "auto") |
| 99 | +} |
| 100 | + |
| 101 | +func (f *FencePolicyConfig) SetConditionWriteEnableOrNot(enable bool) { |
| 102 | + if enable { |
| 103 | + f.ConditionWrite = "enable" |
| 104 | + } else { |
| 105 | + f.ConditionWrite = "disable" |
| 106 | + } |
| 107 | +} |
| 108 | + |
83 | 109 | // LogFileConfig stores the log file configuration. |
84 | 110 | type LogFileConfig struct { |
85 | 111 | RootPath string `yaml:"rootPath"` |
@@ -203,6 +229,7 @@ type LogstoreConfig struct { |
203 | 229 | SegmentCompactionPolicy SegmentCompactionPolicy `yaml:"segmentCompactionPolicy"` |
204 | 230 | SegmentReadPolicy SegmentReadPolicyConfig `yaml:"segmentReadPolicy"` |
205 | 231 | RetentionPolicy RetentionPolicyConfig `yaml:"retentionPolicy"` |
| 232 | + FencePolicy FencePolicyConfig `yaml:"fencePolicy"` |
206 | 233 | } |
207 | 234 |
|
208 | 235 | type StorageConfig struct { |
@@ -316,6 +343,9 @@ func getDefaultWoodpeckerConfig() WoodpeckerConfig { |
316 | 343 | RetentionPolicy: RetentionPolicyConfig{ |
317 | 344 | TTL: 259200, // 72 hours |
318 | 345 | }, |
| 346 | + FencePolicy: FencePolicyConfig{ |
| 347 | + ConditionWrite: "auto", |
| 348 | + }, |
319 | 349 | }, |
320 | 350 | Storage: StorageConfig{ |
321 | 351 | Type: "default", |
|
0 commit comments