From 4c545fc25058c17ebfe00faed6482528e755d6a5 Mon Sep 17 00:00:00 2001 From: Pavol Loffay Date: Fri, 16 Jul 2021 08:48:54 +0200 Subject: [PATCH] Use type for encoding Signed-off-by: Pavol Loffay --- storage/config.go | 9 ++++++++- storage/store.go | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/storage/config.go b/storage/config.go index c8a894f0..84010918 100644 --- a/storage/config.go +++ b/storage/config.go @@ -2,6 +2,13 @@ package storage import "time" +type EncodingType string + +const ( + JsonEncoding EncodingType = "json" + ProtobufEncoding EncodingType = "protobuf" +) + type Configuration struct { // ClickHouse address e.g. tcp://localhost:9000. Address string `yaml:"address"` @@ -12,5 +19,5 @@ type Configuration struct { // Batch flush interval. Default is 5s. BatchFlushInterval time.Duration `yaml:"batch_flush_interval"` // Encoding either json or protobuf. Default is json. - Encoding string `yaml:"encoding"` + Encoding EncodingType `yaml:"encoding"` } diff --git a/storage/store.go b/storage/store.go index be50ff29..6876efa6 100644 --- a/storage/store.go +++ b/storage/store.go @@ -52,7 +52,7 @@ func NewStore(logger hclog.Logger, cfg Configuration, embeddedSQLScripts embed.F cfg.BatchFlushInterval = defaultBatchDelay } if cfg.Encoding == "" { - cfg.Encoding = string(clickhousespanstore.EncodingJSON) + cfg.Encoding = JsonEncoding } return &Store{ db: db,