Skip to content

Commit 2b04e84

Browse files
chore: Update module github.com/sony/sonyflake to v2 (#135)
* chore: Update module github.com/sony/sonyflake to v2 * fix --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: MuZhou233 <muzhou233@outlook.com>
1 parent d2d62af commit 2b04e84

File tree

4 files changed

+26
-18
lines changed

4 files changed

+26
-18
lines changed

cmd/wire_gen.go

Lines changed: 10 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -718,8 +718,8 @@ github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4k
718718
github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY=
719719
github.com/sony/gobreaker v1.0.0 h1:feX5fGGXSl3dYd4aHZItw+FpHLvvoaqkawKjVNiFMNQ=
720720
github.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=
723723
github.com/spf13/afero v1.2.1/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
724724
github.com/spf13/afero v1.14.0 h1:9tH6MapGnn/j0eb0yIXiLjERO8RB6xIVZRDCX7PtqWA=
725725
github.com/spf13/afero v1.14.0/go.mod h1:acJQ8t0ohCGuMN3O+Pv0V0hgMxNYDlvdk+VTfyZmbYo=

internal/lib/libidgenerator/libidgenerator.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package libidgenerator
22

33
import (
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

1210
var 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

3030
func (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

3535
func (i *IDGenerator) BatchNew(n int) ([]model.InternalID, error) {

0 commit comments

Comments
 (0)