Skip to content

Commit

Permalink
backend: move maxDeserializationPayload into serde config
Browse files Browse the repository at this point in the history
  • Loading branch information
weeco committed Feb 28, 2025
1 parent 21db193 commit a0f0585
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
6 changes: 2 additions & 4 deletions backend/pkg/config/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@ const DefaultMaxDeserializationPayloadSize = 20_480 // 20 KB
// Console contains all configuration options for features that are generic,
// such as documentation plumbing.
type Console struct {
TopicDocumentation ConsoleTopicDocumentation `yaml:"topicDocumentation"`
MaxDeserializationPayloadSize int `yaml:"maxDeserializationPayloadSize"`
API ConsoleAPI `yaml:"api"`
TopicDocumentation ConsoleTopicDocumentation `yaml:"topicDocumentation"`
API ConsoleAPI `yaml:"api"`
}

// SetDefaults for Console configs.
func (c *Console) SetDefaults() {
c.TopicDocumentation.SetDefaults()
c.MaxDeserializationPayloadSize = DefaultMaxDeserializationPayloadSize
c.API.SetDefaults()
}

Expand Down
22 changes: 12 additions & 10 deletions backend/pkg/config/serde.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,25 @@ import (
// Serde configures all serializers / deserializers that require extra
// configuration.
type Serde struct {
Protobuf Proto `yaml:"protobuf"`
MessagePack Msgpack `yaml:"messagePack"`
Cbor Cbor `yaml:"cbor"`
MaxDeserializationPayloadSize int `yaml:"maxDeserializationPayloadSize"`
Protobuf Proto `yaml:"protobuf"`
MessagePack Msgpack `yaml:"messagePack"`
Cbor Cbor `yaml:"cbor"`
}

// SetDefaults for Serde config
func (c *Serde) SetDefaults() {
c.MaxDeserializationPayloadSize = DefaultMaxDeserializationPayloadSize
c.Protobuf.SetDefaults()
c.MessagePack.SetDefaults()
}

// RegisterFlags registers all nested config flags.
func (c *Serde) RegisterFlags(f *flag.FlagSet) {
c.Protobuf.RegisterFlags(f)
}

// Validate the Protobuf config
// Validate the Serde config
func (c *Serde) Validate() error {
if err := c.Protobuf.Validate(); err != nil {
return fmt.Errorf("failed to validate protobuf config: %w", err)
Expand All @@ -43,9 +51,3 @@ func (c *Serde) Validate() error {

return nil
}

// SetDefaults for Kafka config
func (c *Serde) SetDefaults() {
c.Protobuf.SetDefaults()
c.MessagePack.SetDefaults()
}
2 changes: 1 addition & 1 deletion backend/pkg/console/list_messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ func (s *Service) startMessageWorker(ctx context.Context, wg *sync.WaitGroup,
ctx,
record,
serde.DeserializationOptions{
MaxPayloadSize: s.cfg.Console.MaxDeserializationPayloadSize,
MaxPayloadSize: s.cfg.Serde.MaxDeserializationPayloadSize,
Troubleshoot: consumeReq.Troubleshoot,
IncludeRawData: consumeReq.IncludeRawPayload,
IgnoreMaxSizeLimit: consumeReq.IgnoreMaxSizeLimit,
Expand Down

0 comments on commit a0f0585

Please sign in to comment.