Skip to content

Commit

Permalink
Remove monoton (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
ohkinozomu authored Nov 22, 2023
1 parent 27d0dac commit b4012a0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
23 changes: 23 additions & 0 deletions internal/hub/bus.go
Original file line number Diff line number Diff line change
@@ -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
}
20 changes: 0 additions & 20 deletions internal/hub/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit b4012a0

Please sign in to comment.