Validate checks the consistency of LifecyclerConfig, and fails if this cannot be achieved.
()
| 107 | |
| 108 | // Validate checks the consistency of LifecyclerConfig, and fails if this cannot be achieved. |
| 109 | func (cfg *LifecyclerConfig) Validate() error { |
| 110 | _, ok := cfg.RingTokenGenerator.(*SpreadMinimizingTokenGenerator) |
| 111 | if ok { |
| 112 | // If cfg.RingTokenGenerator is a SpreadMinimizingTokenGenerator, we must ensure that |
| 113 | // the tokens are not loaded from file. |
| 114 | if cfg.TokensFilePath != "" { |
| 115 | return errors.New("you can't configure the tokens file path when using the spread minimizing token strategy. Please set the tokens file path to an empty string") |
| 116 | } |
| 117 | } |
| 118 | if cfg.HeartbeatPeriod == 0 { |
| 119 | return errors.New("heartbeat period must be greater than 0") |
| 120 | } |
| 121 | if cfg.HeartbeatTimeout == 0 { |
| 122 | return errors.New("heartbeat timeout must be greater than 0") |
| 123 | } |
| 124 | return nil |
| 125 | } |
| 126 | |
| 127 | /* |
| 128 | Lifecycler is a Service that is responsible for publishing changes to a ring for a single instance. |