Skip to content

Commit

Permalink
feat: add sequencer api component with snowflake algorithm (mosn#767)
Browse files Browse the repository at this point in the history
Co-authored-by: seeflood <[email protected]>
Co-authored-by: Xunzhuo <[email protected]>
  • Loading branch information
3 people authored Oct 20, 2022
1 parent 18ceced commit f70cdc6
Show file tree
Hide file tree
Showing 14 changed files with 1,070 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/layotto/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ import (
sequencer_mongo "mosn.io/layotto/components/sequencer/mongo"
sequencer_mysql "mosn.io/layotto/components/sequencer/mysql"
sequencer_redis "mosn.io/layotto/components/sequencer/redis"
sequencer_snowflake "mosn.io/layotto/components/sequencer/snowflake"
sequencer_zookeeper "mosn.io/layotto/components/sequencer/zookeeper"

// Actuator
Expand Down Expand Up @@ -445,6 +446,9 @@ func NewRuntimeGrpcServer(data json.RawMessage, opts ...grpc.ServerOption) (mgrp
runtime_sequencer.NewFactory("mysql", func() sequencer.Store {
return sequencer_mysql.NewMySQLSequencer(log.DefaultLogger)
}),
runtime_sequencer.NewFactory("snowflake", func() sequencer.Store {
return sequencer_snowflake.NewSnowFlakeSequencer(log.DefaultLogger)
}),
),
// secretstores
runtime.WithSecretStoresFactory(
Expand Down
4 changes: 4 additions & 0 deletions cmd/layotto_multiple_api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ import (
sequencer_mongo "mosn.io/layotto/components/sequencer/mongo"
sequencer_mysql "mosn.io/layotto/components/sequencer/mysql"
sequencer_redis "mosn.io/layotto/components/sequencer/redis"
sequencer_snowflake "mosn.io/layotto/components/sequencer/snowflake"
sequencer_zookeeper "mosn.io/layotto/components/sequencer/zookeeper"

// Actuator
Expand Down Expand Up @@ -460,6 +461,9 @@ func NewRuntimeGrpcServer(data json.RawMessage, opts ...grpc.ServerOption) (mgrp
runtime_sequencer.NewFactory("mysql", func() sequencer.Store {
return sequencer_mysql.NewMySQLSequencer(log.DefaultLogger)
}),
runtime_sequencer.NewFactory("snowflake", func() sequencer.Store {
return sequencer_snowflake.NewSnowFlakeSequencer(log.DefaultLogger)
}),
),
// secretstores
runtime.WithSecretStoresFactory(
Expand Down
4 changes: 4 additions & 0 deletions cmd/layotto_without_xds/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ import (
sequencer_inmemory "mosn.io/layotto/components/sequencer/in-memory"
sequencer_mongo "mosn.io/layotto/components/sequencer/mongo"
sequencer_redis "mosn.io/layotto/components/sequencer/redis"
sequencer_snowflake "mosn.io/layotto/components/sequencer/snowflake"
sequencer_zookeeper "mosn.io/layotto/components/sequencer/zookeeper"

// Actuator
Expand Down Expand Up @@ -430,6 +431,9 @@ func NewRuntimeGrpcServer(data json.RawMessage, opts ...grpc.ServerOption) (mgrp
runtime_sequencer.NewFactory("in-memory", func() sequencer.Store {
return sequencer_inmemory.NewInMemorySequencer()
}),
runtime_sequencer.NewFactory("snowflake", func() sequencer.Store {
return sequencer_snowflake.NewSnowFlakeSequencer(log.DefaultLogger)
}),
),
// secretstores
runtime.WithSecretStoresFactory(
Expand Down
1 change: 1 addition & 0 deletions components/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ require (
github.com/dapr/components-contrib v1.5.2
github.com/dapr/kit v0.0.2-0.20210614175626-b9074b64d233
github.com/go-redis/redis/v8 v8.8.0
github.com/go-sql-driver/mysql v1.5.0
github.com/go-zookeeper/zk v1.0.2
github.com/golang/mock v1.6.0
github.com/google/uuid v1.3.0
Expand Down
1 change: 1 addition & 0 deletions components/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ github.com/go-redis/redis/v8 v8.8.0/go.mod h1:F7resOH5Kdug49Otu24RjHWwgK7u9AmtqW
github.com/go-resty/resty/v2 v2.6.0/go.mod h1:PwvJS6hvaPkjtjNg9ph+VrSD92bi5Zq73w/BIH7cC3Q=
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
Expand Down
Loading

0 comments on commit f70cdc6

Please sign in to comment.