|
| 1 | +// Copyright 2024 Redpanda Data, Inc. |
| 2 | +// |
| 3 | +// Use of this software is governed by the Business Source License |
| 4 | +// included in the file licenses/BSL.md |
| 5 | +// |
| 6 | +// As of the Change Date specified in that file, in accordance with |
| 7 | +// the Business Source License, use of this software will be governed |
| 8 | +// by the Apache License, Version 2.0 |
| 9 | + |
| 10 | +package config |
| 11 | + |
| 12 | +import ( |
| 13 | + "errors" |
| 14 | + "time" |
| 15 | +) |
| 16 | + |
| 17 | +// OperationTimeouts contains timeout configurations for various Kafka operations |
| 18 | +// performed by the console service. |
| 19 | +type OperationTimeouts struct { |
| 20 | + // ClusterInfo is the timeout applied when fetching broker metadata and log dir |
| 21 | + // information to build the cluster overview. A shorter timeout avoids long |
| 22 | + // response times when a single broker is temporarily unreachable, but may |
| 23 | + // cause incomplete results on slow clusters. |
| 24 | + ClusterInfo time.Duration `yaml:"clusterInfo"` |
| 25 | + |
| 26 | + // TopicsOverview is the timeout applied when fetching topic metadata and per-topic |
| 27 | + // log dir sizes to build the topics list. A shorter timeout avoids long response |
| 28 | + // times when a single broker is temporarily unreachable, but may cause incomplete |
| 29 | + // results on slow clusters. |
| 30 | + TopicsOverview time.Duration `yaml:"topicsOverview"` |
| 31 | +} |
| 32 | + |
| 33 | +// SetDefaults for ConsoleTimeouts. |
| 34 | +func (c *OperationTimeouts) SetDefaults() { |
| 35 | + c.ClusterInfo = 6 * time.Second |
| 36 | + c.TopicsOverview = 5 * time.Second |
| 37 | +} |
| 38 | + |
| 39 | +// Validate ConsoleTimeouts. |
| 40 | +func (c *OperationTimeouts) Validate() error { |
| 41 | + if c.ClusterInfo <= 0 { |
| 42 | + return errors.New("console.operationTimeouts.clusterInfo must be a positive duration") |
| 43 | + } |
| 44 | + if c.TopicsOverview <= 0 { |
| 45 | + return errors.New("console.operationTimeouts.topicsOverview must be a positive duration") |
| 46 | + } |
| 47 | + return nil |
| 48 | +} |
0 commit comments