diff --git a/app/config/config.go b/app/config/config.go index c351f52..d72b56c 100644 --- a/app/config/config.go +++ b/app/config/config.go @@ -33,13 +33,15 @@ type Config struct { Ship ShipConfig `json:"ship"` Api string `json:"api"` - Redis RedisConfig `json:"redis"` + Redis RedisConfig `json:"redis"` + MessageCodec string `json:"message_codec"` Telegram TelegramConfig `json:"telegram"` } func Parse(data []byte) (*Config, error) { cfg := Config{ + MessageCodec: "json", Ship: ShipConfig{ StartBlockNum: shipclient.NULL_BLOCK_NUMBER, EndBlockNum: shipclient.NULL_BLOCK_NUMBER, diff --git a/app/config/config_test.go b/app/config/config_test.go index c0a6dd0..e87e979 100644 --- a/app/config/config_test.go +++ b/app/config/config_test.go @@ -10,6 +10,8 @@ import ( func TestParse_Default(t *testing.T) { expected := Config{ + MessageCodec: "json", + Ship: ShipConfig{ StartBlockNum: shipclient.NULL_BLOCK_NUMBER, EndBlockNum: shipclient.NULL_BLOCK_NUMBER, @@ -32,8 +34,9 @@ func TestParse_Default(t *testing.T) { func TestParse(t *testing.T) { expected := Config{ - Name: "ship-reader-1", - Api: "http://127.0.0.1:8080", + Name: "ship-reader-1", + Api: "http://127.0.0.1:8080", + MessageCodec: "mojibake", Ship: ShipConfig{ Url: "127.0.0.1:8089", StartBlockNum: 23671836, @@ -56,6 +59,7 @@ func TestParse(t *testing.T) { cfg, err := Parse([]byte(`{ "name": "ship-reader-1", "api": "http://127.0.0.1:8080", + "message_codec": "mojibake", "ship": { "url": "127.0.0.1:8089", "irreversible_only": true, @@ -81,8 +85,9 @@ func TestParse(t *testing.T) { func TestParseShorthandShipUrl(t *testing.T) { expected := Config{ - Name: "ship-reader-1", - Api: "http://127.0.0.1:8080", + Name: "ship-reader-1", + Api: "http://127.0.0.1:8080", + MessageCodec: "json", Ship: ShipConfig{ Url: "127.0.0.1:8089", StartBlockNum: shipclient.NULL_BLOCK_NUMBER,