File tree Expand file tree Collapse file tree 4 files changed +26
-18
lines changed
internal/lib/libidgenerator Expand file tree Collapse file tree 4 files changed +26
-18
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ require (
4545 github.com/panjf2000/ants/v2 v2.11.3
4646 github.com/redis/go-redis/v9 v9.11.0
4747 github.com/samber/lo v1.51.0
48- github.com/sony/sonyflake v1 .2.1
48+ github.com/sony/sonyflake/v2 v2 .2.0
4949 github.com/spf13/afero v1.14.0
5050 github.com/stretchr/testify v1.10.0
5151 github.com/tuihub/protos v0.5.6
Original file line number Diff line number Diff line change @@ -718,8 +718,8 @@ github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4k
718718github.com/sony/gobreaker v0.4.1 /go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY =
719719github.com/sony/gobreaker v1.0.0 h1:feX5fGGXSl3dYd4aHZItw+FpHLvvoaqkawKjVNiFMNQ =
720720github.com/sony/gobreaker v1.0.0 /go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY =
721- github.com/sony/sonyflake v1 .2.1 h1:Jzo4abS84qVNbYamXZdrZF1/6TzNJjEogRfXv7TsG48 =
722- github.com/sony/sonyflake v1 .2.1 /go.mod h1:LORtCywH/cq10ZbyfhKrHYgAUGH7mOBa76enV9txy/Y =
721+ github.com/sony/sonyflake/v2 v2 .2.0 h1:wSzEoewlWnUtc3SZX/MpT8zsWTuAnjwrprUYfuPl9Jg =
722+ github.com/sony/sonyflake/v2 v2 .2.0 /go.mod h1:09EcfmR846JLupbkgVfzp8QtQwJ+Y8e69VVayHdawzg =
723723github.com/spf13/afero v1.2.1 /go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk =
724724github.com/spf13/afero v1.14.0 h1:9tH6MapGnn/j0eb0yIXiLjERO8RB6xIVZRDCX7PtqWA =
725725github.com/spf13/afero v1.14.0 /go.mod h1:acJQ8t0ohCGuMN3O+Pv0V0hgMxNYDlvdk+VTfyZmbYo =
Original file line number Diff line number Diff line change 11package libidgenerator
22
33import (
4- "time"
5-
64 "github.com/tuihub/librarian/internal/model"
75
86 "github.com/google/wire"
9- "github.com/sony/sonyflake"
7+ "github.com/sony/sonyflake/v2 "
108)
119
1210var ProviderSet = wire .NewSet (NewIDGenerator )
@@ -15,21 +13,23 @@ type IDGenerator struct {
1513 sf * sonyflake.Sonyflake
1614}
1715
18- func NewIDGenerator () * IDGenerator {
19- return & IDGenerator {
20- sf : sonyflake .NewSonyflake (sonyflake.Settings {
21- StartTime : time.Time {},
22- MachineID : func () (uint16 , error ) { // TODO
23- return 0 , nil
24- },
25- CheckMachineID : nil ,
26- }),
16+ func NewIDGenerator () (* IDGenerator , error ) {
17+ sf , err := sonyflake .New (sonyflake.Settings { //nolint:exhaustruct // no need
18+ MachineID : func () (int , error ) { // TODO
19+ return 0 , nil
20+ },
21+ })
22+ if err != nil {
23+ return nil , err
2724 }
25+ return & IDGenerator {
26+ sf : sf ,
27+ }, nil
2828}
2929
3030func (i * IDGenerator ) New () (model.InternalID , error ) {
3131 id , err := i .sf .NextID ()
32- return model .InternalID (id ), err //nolint:gosec // safe
32+ return model .InternalID (id ), err
3333}
3434
3535func (i * IDGenerator ) BatchNew (n int ) ([]model.InternalID , error ) {
You can’t perform that action at this time.
0 commit comments