diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0aedb1b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM golang:latest + +RUN apt install git + +WORKDIR /app + +ADD . . +RUN go build -o tigerbeetle_api . + +ENTRYPOINT ./tigerbeetle_api \ No newline at end of file diff --git a/config-example.yml b/config-example.yml index 1f09eb3..aafb468 100644 --- a/config-example.yml +++ b/config-example.yml @@ -1,5 +1,5 @@ port: 50051 tb_cluster_id: 0 -tb_addresses: ["3033"] +tb_addresses: "3033" tb_concurrency_max: 2 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 683e36c..dc15ba2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,7 +11,7 @@ services: - 127.0.0.1:3033:3033 environment: - TB_ADDRESSES=0.0.0.0:3033 - command: start /data/0_0.tigerbeetle + command: start --addresses=0.0.0.0:3033 /data/0_0.tigerbeetle volumes: tigerbeetle: diff --git a/main.go b/main.go index d1df6c8..e1b509f 100644 --- a/main.go +++ b/main.go @@ -17,11 +17,11 @@ import ( ) type Config struct { - Port int `default:"50051" yml:"port" env:"PORT"` - Host string `default:"0.0.0.0" yml:"host" env:"HOST"` - TbClusterId int `default:"0" yml:"tb_cluster_id" env:"TB_CLUSTER_ID"` - TbAddresses []string `required:"true" yml:"tb_addresses" env:"TB_ADDRESSES"` - TbConcurrencyMax int `default:"2" yml:"tb_concurrency_max" env:"TB_CONCURRENCY_MAX"` + Port int `default:"50051" yaml:"port" env:"PORT"` + Host string `default:"0.0.0.0" yaml:"host" env:"HOST"` + TbClusterId int `default:"0" yaml:"tb_cluster_id" env:"TB_CLUSTER_ID"` + TbAddresses string `required:"true" yaml:"tb_addresses" env:"TB_ADDRESSES"` + TbConcurrencyMax int `default:"2" yaml:"tb_concurrency_max" env:"TB_CONCURRENCY_MAX"` } func main() { @@ -38,15 +38,16 @@ func main() { slog.Error("fatal error config file:", err) os.Exit(1) } - if len(config.TbAddresses) == 0 { + if config.TbAddresses == "" { slog.Error("tb_addresses is empty") os.Exit(1) } + tbAddresses := strings.Split(config.TbAddresses, ",") - slog.Info("Connecting to tigerbeetle cluster", "addresses:", strings.Join(config.TbAddresses, ", ")) + slog.Info("Connecting to tigerbeetle cluster", "addresses:", strings.Join(tbAddresses, ", ")) // Connect to tigerbeetle - tb, err := tigerbeetle_go.NewClient(types.ToUint128(uint64(config.TbClusterId)), config.TbAddresses, uint(config.TbConcurrencyMax)) + tb, err := tigerbeetle_go.NewClient(types.ToUint128(uint64(config.TbClusterId)), tbAddresses, uint(config.TbConcurrencyMax)) if err != nil { slog.Error("unable to connect to tigerbeetle:", err) os.Exit(1)