Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion plugin/storage/memory/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@

package memory

// Configuration describes the options to customize the storage behavior
import "github.com/asaskevich/govalidator"

// Configuration describes the options to customize the storage behavior.
type Configuration struct {
// MaxTraces is the maximum amount of traces to store in memory.
// If multi-tenancy is enabled, this limit applies per tenant.
// Zero value (default) means no limit (Warning: memory usage will be unbounded).
MaxTraces int `mapstructure:"max_traces"`
}

func (c *Configuration) Validate() error {
_, err := govalidator.ValidateStruct(c)
return err
}
35 changes: 35 additions & 0 deletions plugin/storage/memory/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) 2024 The Jaeger Authors.
// SPDX-License-Identifier: Apache-2.0

package memory

import (
"testing"

"github.com/stretchr/testify/require"
)

func TestValidate_DoesNotReturnErrorWhenValid(t *testing.T) {
tests := []struct {
name string
config *Configuration
}{
{
name: "non-required fields not set",
config: &Configuration{},
},
{
name: "all fields are set",
config: &Configuration{
MaxTraces: 100,
},
},
}

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
err := test.config.Validate()
require.NoError(t, err)
})
}
}