Skip to content

Commit

Permalink
[databases]: use int for big values in Kafka advanced config
Browse files Browse the repository at this point in the history
  • Loading branch information
loosla committed Sep 24, 2024
1 parent 57fbfeb commit 17766f7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 27 deletions.
35 changes: 17 additions & 18 deletions databases.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package godo
import (
"context"
"fmt"
"math/big"
"net/http"
"strings"
"time"
Expand Down Expand Up @@ -664,23 +663,23 @@ type MongoDBConfig struct {

// KafkaConfig holds advanced configurations for Kafka database clusters.
type KafkaConfig struct {
GroupInitialRebalanceDelayMs *int `json:"group_initial_rebalance_delay_ms,omitempty"`
GroupMinSessionTimeoutMs *int `json:"group_min_session_timeout_ms,omitempty"`
GroupMaxSessionTimeoutMs *int `json:"group_max_session_timeout_ms,omitempty"`
MessageMaxBytes *int `json:"message_max_bytes,omitempty"`
LogCleanerDeleteRetentionMs *int64 `json:"log_cleaner_delete_retention_ms,omitempty"`
LogCleanerMinCompactionLagMs *uint64 `json:"log_cleaner_min_compaction_lag_ms,omitempty"`
LogFlushIntervalMs *uint64 `json:"log_flush_interval_ms,omitempty"`
LogIndexIntervalBytes *int `json:"log_index_interval_bytes,omitempty"`
LogMessageDownconversionEnable *bool `json:"log_message_downconversion_enable,omitempty"`
LogMessageTimestampDifferenceMaxMs *uint64 `json:"log_message_timestamp_difference_max_ms,omitempty"`
LogPreallocate *bool `json:"log_preallocate,omitempty"`
LogRetentionBytes *big.Int `json:"log_retention_bytes,omitempty"`
LogRetentionHours *int `json:"log_retention_hours,omitempty"`
LogRetentionMs *big.Int `json:"log_retention_ms,omitempty"`
LogRollJitterMs *uint64 `json:"log_roll_jitter_ms,omitempty"`
LogSegmentDeleteDelayMs *int `json:"log_segment_delete_delay_ms,omitempty"`
AutoCreateTopicsEnable *bool `json:"auto_create_topics_enable,omitempty"`
GroupInitialRebalanceDelayMs *int `json:"group_initial_rebalance_delay_ms,omitempty"`
GroupMinSessionTimeoutMs *int `json:"group_min_session_timeout_ms,omitempty"`
GroupMaxSessionTimeoutMs *int `json:"group_max_session_timeout_ms,omitempty"`
MessageMaxBytes *int `json:"message_max_bytes,omitempty"`
LogCleanerDeleteRetentionMs *int64 `json:"log_cleaner_delete_retention_ms,omitempty"`
LogCleanerMinCompactionLagMs *int64 `json:"log_cleaner_min_compaction_lag_ms,omitempty"`
LogFlushIntervalMs *int64 `json:"log_flush_interval_ms,omitempty"`
LogIndexIntervalBytes *int `json:"log_index_interval_bytes,omitempty"`
LogMessageDownconversionEnable *bool `json:"log_message_downconversion_enable,omitempty"`
LogMessageTimestampDifferenceMaxMs *int64 `json:"log_message_timestamp_difference_max_ms,omitempty"`
LogPreallocate *bool `json:"log_preallocate,omitempty"`
LogRetentionBytes *int64 `json:"log_retention_bytes,omitempty"`
LogRetentionHours *int `json:"log_retention_hours,omitempty"`
LogRetentionMs *int64 `json:"log_retention_ms,omitempty"`
LogRollJitterMs *int64 `json:"log_roll_jitter_ms,omitempty"`
LogSegmentDeleteDelayMs *int `json:"log_segment_delete_delay_ms,omitempty"`
AutoCreateTopicsEnable *bool `json:"auto_create_topics_enable,omitempty"`
}

type databaseUserRoot struct {
Expand Down
17 changes: 8 additions & 9 deletions databases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package godo
import (
"encoding/json"
"fmt"
"math/big"
"net/http"
"testing"
"time"
Expand Down Expand Up @@ -3101,16 +3100,16 @@ func TestDatabases_GetConfigKafka(t *testing.T) {
GroupMaxSessionTimeoutMs: PtrTo(1800000),
MessageMaxBytes: PtrTo(1048588),
LogCleanerDeleteRetentionMs: PtrTo(int64(86400000)),
LogCleanerMinCompactionLagMs: PtrTo(uint64(0)),
LogFlushIntervalMs: PtrTo(uint64(60000)),
LogCleanerMinCompactionLagMs: PtrTo(int64(0)),
LogFlushIntervalMs: PtrTo(int64(60000)),
LogIndexIntervalBytes: PtrTo(4096),
LogMessageDownconversionEnable: PtrTo(true),
LogMessageTimestampDifferenceMaxMs: PtrTo(uint64(120000)),
LogMessageTimestampDifferenceMaxMs: PtrTo(int64(120000)),
LogPreallocate: PtrTo(false),
LogRetentionBytes: big.NewInt(int64(-1)),
LogRetentionBytes: PtrTo(int64(-1)),
LogRetentionHours: PtrTo(168),
LogRetentionMs: big.NewInt(int64(604800000)),
LogRollJitterMs: PtrTo(uint64(0)),
LogRetentionMs: PtrTo(int64(604800000)),
LogRollJitterMs: PtrTo(int64(0)),
LogSegmentDeleteDelayMs: PtrTo(60000),
AutoCreateTopicsEnable: PtrTo(true),
}
Expand Down Expand Up @@ -3139,7 +3138,7 @@ func TestDatabases_UpdateConfigKafka(t *testing.T) {
GroupMaxSessionTimeoutMs: PtrTo(1800000),
MessageMaxBytes: PtrTo(1048588),
LogCleanerDeleteRetentionMs: PtrTo(int64(86400000)),
LogCleanerMinCompactionLagMs: PtrTo(uint64(0)),
LogCleanerMinCompactionLagMs: PtrTo(int64(0)),
}
)

Expand All @@ -3152,7 +3151,7 @@ func TestDatabases_UpdateConfigKafka(t *testing.T) {
require.NoError(t, err)

assert.Equal(t, b.Config, kafkaConfig)
assert.Equal(t, uint64(0), *b.Config.LogCleanerMinCompactionLagMs, "pointers to zero value should be sent")
assert.Equal(t, int64(0), *b.Config.LogCleanerMinCompactionLagMs, "pointers to zero value should be sent")
assert.Nil(t, b.Config.LogFlushIntervalMs, "excluded value should not be sent")

w.WriteHeader(http.StatusNoContent)
Expand Down

0 comments on commit 17766f7

Please sign in to comment.