1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-06-17 04:30:03 +02:00

app/config/config.go: Adding MessageCodec field.

This commit is contained in:
Henrik Hautakoski 2023-04-24 16:02:58 +02:00
parent b221b0415a
commit b5eb602e7d
2 changed files with 12 additions and 5 deletions

View file

@ -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,

View file

@ -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,