Validate method validates ConsumerGroupConfig properties and sets relevant defaults.
()
| 168 | // Validate method validates ConsumerGroupConfig properties and sets relevant |
| 169 | // defaults. |
| 170 | func (config *ConsumerGroupConfig) Validate() error { |
| 171 | |
| 172 | if len(config.Brokers) == 0 { |
| 173 | return errors.New("cannot create a consumer group with an empty list of broker addresses") |
| 174 | } |
| 175 | |
| 176 | if len(config.Topics) == 0 { |
| 177 | return errors.New("cannot create a consumer group without a topic") |
| 178 | } |
| 179 | |
| 180 | if config.ID == "" { |
| 181 | return errors.New("cannot create a consumer group without an ID") |
| 182 | } |
| 183 | |
| 184 | if config.Dialer == nil { |
| 185 | config.Dialer = DefaultDialer |
| 186 | } |
| 187 | |
| 188 | if len(config.GroupBalancers) == 0 { |
| 189 | config.GroupBalancers = []GroupBalancer{ |
| 190 | RangeGroupBalancer{}, |
| 191 | RoundRobinGroupBalancer{}, |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | if config.HeartbeatInterval == 0 { |
| 196 | config.HeartbeatInterval = defaultHeartbeatInterval |
| 197 | } |
| 198 | |
| 199 | if config.SessionTimeout == 0 { |
| 200 | config.SessionTimeout = defaultSessionTimeout |
| 201 | } |
| 202 | |
| 203 | if config.PartitionWatchInterval == 0 { |
| 204 | config.PartitionWatchInterval = defaultPartitionWatchTime |
| 205 | } |
| 206 | |
| 207 | if config.RebalanceTimeout == 0 { |
| 208 | config.RebalanceTimeout = defaultRebalanceTimeout |
| 209 | } |
| 210 | |
| 211 | if config.JoinGroupBackoff == 0 { |
| 212 | config.JoinGroupBackoff = defaultJoinGroupBackoff |
| 213 | } |
| 214 | |
| 215 | if config.RetentionTime == 0 { |
| 216 | config.RetentionTime = defaultRetentionTime |
| 217 | } |
| 218 | |
| 219 | if config.HeartbeatInterval < 0 || (config.HeartbeatInterval/time.Millisecond) >= math.MaxInt32 { |
| 220 | return fmt.Errorf("HeartbeatInterval out of bounds: %d", config.HeartbeatInterval) |
| 221 | } |
| 222 | |
| 223 | if config.SessionTimeout < 0 || (config.SessionTimeout/time.Millisecond) >= math.MaxInt32 { |
| 224 | return fmt.Errorf("SessionTimeout out of bounds: %d", config.SessionTimeout) |
| 225 | } |
| 226 | |
| 227 | if config.RebalanceTimeout < 0 || (config.RebalanceTimeout/time.Millisecond) >= math.MaxInt32 { |
no test coverage detected