From b4012a01f7dd89afb973f60098a65173afa75204 Mon Sep 17 00:00:00 2001 From: Ohki Nozomu Date: Wed, 22 Nov 2023 18:55:56 +0900 Subject: [PATCH] Remove monoton (#85) --- go.mod | 2 -- go.sum | 2 -- internal/hub/bus.go | 23 +++++++++++++++++++++++ internal/hub/server.go | 20 -------------------- 4 files changed, 23 insertions(+), 24 deletions(-) create mode 100644 internal/hub/bus.go diff --git a/go.mod b/go.mod index 0f72896..00e7014 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,6 @@ require ( github.com/gorilla/mux v1.8.1 github.com/klauspost/compress v1.17.3 github.com/mustafaturan/bus/v3 v3.0.3 - github.com/mustafaturan/monoton/v3 v3.0.0 github.com/ohkinozomu/neutral-cp v0.1.4 github.com/prometheus/client_golang v1.17.0 github.com/spf13/cobra v1.8.0 @@ -109,7 +108,6 @@ require ( github.com/spf13/afero v1.10.0 // indirect github.com/spf13/cast v1.5.1 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/stretchr/objx v0.5.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/tencentyun/cos-go-sdk-v5 v0.7.40 // indirect go.opencensus.io v0.24.0 // indirect diff --git a/go.sum b/go.sum index 1fc7c73..7686039 100644 --- a/go.sum +++ b/go.sum @@ -304,8 +304,6 @@ github.com/mozillazg/go-httpheader v0.2.1 h1:geV7TrjbL8KXSyvghnFm+NyTux/hxwueTSr github.com/mozillazg/go-httpheader v0.2.1/go.mod h1:jJ8xECTlalr6ValeXYdOF8fFUISeBAdw6E61aqQma60= github.com/mustafaturan/bus/v3 v3.0.3 h1:PMEUVKpfI9FOUw32o3wAHRaBS1XGxh6cFCy/VHktPfo= github.com/mustafaturan/bus/v3 v3.0.3/go.mod h1:JVCyq6Pb6S/IGI6LrzKH5vlBZ9ifsd1Js+wd4Y2+7Xg= -github.com/mustafaturan/monoton/v3 v3.0.0 h1:dHVuOo/zO+8OoaOe/dBQxPs+BKOk8wLmbbP9FAnsThI= -github.com/mustafaturan/monoton/v3 v3.0.0/go.mod h1:sMF2N+NFxAMPTD6trDO9pj6ngqwptxFGVL1vIf2cF0U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/ncw/swift v1.0.53 h1:luHjjTNtekIEvHg5KdAFIBaH7bWfNkefwFnpDffSIks= diff --git a/internal/hub/bus.go b/internal/hub/bus.go new file mode 100644 index 0000000..b67acee --- /dev/null +++ b/internal/hub/bus.go @@ -0,0 +1,23 @@ +package hub + +import ( + "github.com/google/uuid" + "github.com/mustafaturan/bus/v3" +) + +type uuidGenerator struct{} + +func (g uuidGenerator) Generate() string { + return uuid.New().String() +} + +var _ bus.IDGenerator = (*uuidGenerator)(nil) + +func newBus() *bus.Bus { + b, err := bus.NewBus(uuidGenerator{}) + if err != nil { + panic(err) + } + + return b +} diff --git a/internal/hub/server.go b/internal/hub/server.go index 445f4ef..67c5dc8 100644 --- a/internal/hub/server.go +++ b/internal/hub/server.go @@ -21,8 +21,6 @@ import ( "github.com/gorilla/mux" "github.com/klauspost/compress/zstd" "github.com/mustafaturan/bus/v3" - "github.com/mustafaturan/monoton/v3" - "github.com/mustafaturan/monoton/v3/sequencer" "github.com/ohkinozomu/fuyuu-router/internal/common" "github.com/ohkinozomu/fuyuu-router/internal/common/split" "github.com/ohkinozomu/fuyuu-router/pkg/data" @@ -137,24 +135,6 @@ func newClient(c HubConfig, payloadCh chan []byte) *autopaho.ConnectionManager { return cm } -func newBus() *bus.Bus { - node := uint64(1) - initialTime := uint64(time.Now().Unix()) - m, err := monoton.New(sequencer.NewMillisecond(), node, initialTime) - if err != nil { - panic(err) - } - - var idGenerator bus.Next = m.Next - - b, err := bus.NewBus(idGenerator) - if err != nil { - panic(err) - } - - return b -} - func newServer(c HubConfig) server { decoder, err := zstd.NewReader(nil) if err != nil {