Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
11 changes: 10 additions & 1 deletion plugin/storage/memory/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@

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 to store in memory.
// If MaxTraces is set to 0 (default), the number of traces stored 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)
})
}
}