1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-06-16 04:24:56 +02:00

internal/config: skip creating a Config struct with default values. those should be set by flags or viper in the builder

This commit is contained in:
Henrik Hautakoski 2024-02-18 16:11:32 +01:00
parent e54a4fa929
commit 69a36e016c
3 changed files with 1 additions and 64 deletions

View file

@ -81,7 +81,7 @@ func (b *Builder) Build() (*Config, error) {
return nil, errors.New("Config not set")
}
conf := New()
conf := Config{}
v := viper.New()
v.SetConfigType("yaml")

View file

@ -1,11 +1,7 @@
package config
import (
"time"
"github.com/eosswedenorg/thalos/internal/log"
shipclient "github.com/eosswedenorg-go/antelope-ship-client"
)
type RedisConfig struct {
@ -42,24 +38,3 @@ type Config struct {
Telegram TelegramConfig `yaml:"telegram" mapstructure:"telegram"`
}
// Create a new Config object with default values
func New() Config {
return Config{
MessageCodec: "json",
Log: log.Config{
MaxFileSize: 10 * 1000 * 1000, // 10 mb
MaxTime: time.Hour * 24,
},
Ship: ShipConfig{
StartBlockNum: shipclient.NULL_BLOCK_NUMBER,
EndBlockNum: shipclient.NULL_BLOCK_NUMBER,
MaxMessagesInFlight: 10,
IrreversibleOnly: false,
},
Redis: RedisConfig{
Addr: "localhost:6379",
Prefix: "ship",
},
}
}

View file

@ -1,38 +0,0 @@
package config
import (
"testing"
"time"
"github.com/eosswedenorg/thalos/internal/log"
"github.com/stretchr/testify/require"
shipclient "github.com/eosswedenorg-go/antelope-ship-client"
)
func TestNew(t *testing.T) {
expected := Config{
MessageCodec: "json",
Log: log.Config{
MaxFileSize: 10 * 1000 * 1000, // 10 mb
MaxTime: time.Hour * 24,
},
Ship: ShipConfig{
StartBlockNum: shipclient.NULL_BLOCK_NUMBER,
EndBlockNum: shipclient.NULL_BLOCK_NUMBER,
MaxMessagesInFlight: 10,
IrreversibleOnly: false,
},
Redis: RedisConfig{
Addr: "localhost:6379",
Password: "",
DB: 0,
Prefix: "ship",
},
}
require.Equal(t, expected, New())
}