Skip to content

Commit 5e00551

Browse files
authored
dep upgrades 1 (#190)
* Upgrade deps * Modernize
1 parent 6027094 commit 5e00551

File tree

15 files changed

+130
-149
lines changed

15 files changed

+130
-149
lines changed

actor.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,14 @@ type Actor interface {
2424
// to start, its type will be equal to its name
2525
// unless its changed:
2626
//
27-
// start := NewActorStart("worker")
27+
// start := NewActorStart("worker")
2828
//
2929
// Format names can also be used for more complicated
3030
// names, just remember to override the type:
3131
//
32-
// start := NewActorStart("worker-%d-group-%d", i, j)
33-
// start.Type = "worker"
34-
//
35-
func NewActorStart(name string, v ...interface{}) *ActorStart {
32+
// start := NewActorStart("worker-%d-group-%d", i, j)
33+
// start.Type = "worker"
34+
func NewActorStart(name string, v ...any) *ActorStart {
3635
fullName := name
3736
if len(v) > 0 {
3837
fullName = fmt.Sprintf(name, v...)

cfg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
// Logger hides the logging function Printf behind a simple
99
// interface so libraries such as logrus can be used.
1010
type Logger interface {
11-
Printf(string, ...interface{})
11+
Printf(string, ...any)
1212
}
1313

1414
// ClientCfg where the only required argument is Namespace,

client.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66
"errors"
77
"fmt"
8+
"maps"
89
"math/rand"
910
"strconv"
1011
"strings"
@@ -32,7 +33,7 @@ import (
3233
//
3334
// Register(MyMsg{}) // Correct
3435
// Register(&MyMsg{}) // Incorrect
35-
func Register(v interface{}) error {
36+
func Register(v any) error {
3637
return codec.Register(v)
3738
}
3839

@@ -152,7 +153,7 @@ func (c *Client) Close() error {
152153
}
153154

154155
// Request a response for the given message. The context can be used to control cancelation or timeouts.
155-
func (c *Client) Request(ctx context.Context, receiver string, msg interface{}) (interface{}, error) {
156+
func (c *Client) Request(ctx context.Context, receiver string, msg any) (any, error) {
156157
if c == nil {
157158
return nil, ErrNilClient
158159
}
@@ -278,8 +279,7 @@ func (c *Client) getCCLocked(ctx context.Context, nsReceiver string) (*clientAnd
278279
Backoff: grpcBackoff.Config{MaxDelay: 20 * time.Second},
279280
MinConnectTimeout: 1 * time.Second,
280281
}),
281-
grpc.WithUnaryInterceptor(otelgrpc.UnaryClientInterceptor()),
282-
grpc.WithStreamInterceptor(otelgrpc.StreamClientInterceptor()),
282+
grpc.WithStatsHandler(otelgrpc.NewClientHandler()),
283283
)
284284
if err != nil {
285285
return nil, noID, err
@@ -383,15 +383,15 @@ func (c *Client) handleGRPCErrs(ctx context.Context, err error, nsReceiver strin
383383
return false
384384
}
385385

386-
func (c *Client) logf(format string, v ...interface{}) {
386+
func (c *Client) logf(format string, v ...any) {
387387
if c.cfg.Logger != nil {
388388
c.cfg.Logger.Printf(format, v...)
389389
}
390390
}
391391

392392
// BroadcastC (broadcast) a message to all members in a Group. The context can be used to control
393393
// cancellations or timeouts
394-
func (c *Client) Broadcast(ctx context.Context, g *Group, msg interface{}) (BroadcastResult, error) {
394+
func (c *Client) Broadcast(ctx context.Context, g *Group, msg any) (BroadcastResult, error) {
395395
if c == nil {
396396
return nil, ErrNilClient
397397
}
@@ -404,7 +404,7 @@ func (c *Client) Broadcast(ctx context.Context, g *Group, msg interface{}) (Broa
404404
return c.broadcast(cont, cancel, g, msg)
405405
}
406406

407-
func (c *Client) broadcast(ctx context.Context, cancel context.CancelFunc, g *Group, msg interface{}) (BroadcastResult, error) {
407+
func (c *Client) broadcast(ctx context.Context, cancel context.CancelFunc, g *Group, msg any) (BroadcastResult, error) {
408408
res := make(BroadcastResult)
409409
receivers := g.Members()
410410

@@ -496,15 +496,13 @@ type BroadcastResult map[string]*Result
496496
// Result stores the result of a Request
497497
type Result struct {
498498
Err error
499-
Val interface{}
499+
Val any
500500
}
501501

502502
// Add combines two BroadcastResults, by overwriting previous
503503
// results if they exist
504504
func (b BroadcastResult) Add(other BroadcastResult) {
505-
for k, v := range other {
506-
b[k] = v
507-
}
505+
maps.Copy(b, other)
508506
}
509507

510508
// statName of interesting statistic to track

client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func TestClientBroadcast(t *testing.T) {
217217

218218
// start up the actors
219219
const numActors = 2
220-
for i := 0; i < numActors; i++ {
220+
for i := range numActors {
221221
startEchoActor(fmt.Sprintf("echo-%d", i))
222222
}
223223

@@ -232,7 +232,7 @@ func TestClientBroadcast(t *testing.T) {
232232
} else if len(res) != numActors {
233233
t.Fatal("expected response")
234234
}
235-
for i := 0; i < numActors; i++ {
235+
for i := range numActors {
236236
actor := fmt.Sprintf("echo-%d", i)
237237
r, ok := res[actor]
238238
if !ok {

codec/registry.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ var (
2222

2323
var (
2424
mu = &sync.RWMutex{}
25-
registry = map[string]interface{}{}
25+
registry = map[string]any{}
2626
)
2727

2828
// Register a type for marshalling and unmarshalling.
2929
// The type must currently implement proto.Message.
30-
func Register(v interface{}) error {
30+
func Register(v any) error {
3131
mu.Lock()
3232
defer mu.Unlock()
3333

@@ -45,9 +45,9 @@ func Register(v interface{}) error {
4545
name := TypeName(v)
4646
registry[name] = v
4747
// TODO(aj) Temporary migration solution for go module upgrade
48-
if strings.HasPrefix(name, "github.com/lytics/lio/vendor/") {
48+
if after, ok0 := strings.CutPrefix(name, "github.com/lytics/lio/vendor/"); ok0 {
4949
// If we're the pre go.mod, register the other namespace
50-
otherName := strings.TrimPrefix(name, "github.com/lytics/lio/vendor/")
50+
otherName := after
5151
registry[otherName] = v
5252
} else {
5353
// If we're using go.mod, register the old namespace
@@ -59,7 +59,7 @@ func Register(v interface{}) error {
5959

6060
// Marshal the value into bytes. The function returns
6161
// the type name, the bytes, or an error.
62-
func Marshal(v interface{}) (string, []byte, error) {
62+
func Marshal(v any) (string, []byte, error) {
6363
mu.RLock()
6464
defer mu.RUnlock()
6565

@@ -78,7 +78,7 @@ func Marshal(v interface{}) (string, []byte, error) {
7878

7979
// Unmarshal the bytes into a value whos type is given,
8080
// or return an error.
81-
func Unmarshal(buf []byte, name string) (interface{}, error) {
81+
func Unmarshal(buf []byte, name string) (any, error) {
8282
mu.RLock()
8383
defer mu.RUnlock()
8484

@@ -96,7 +96,7 @@ func Unmarshal(buf []byte, name string) (interface{}, error) {
9696

9797
// TypeName of a value. This name is used in the registry
9898
// to distinguish types.
99-
func TypeName(v interface{}) string {
99+
func TypeName(v any) string {
100100
rt := reflect.TypeOf(v)
101101
pkg := rt.PkgPath()
102102
name := rt.Name()
@@ -108,12 +108,12 @@ func TypeName(v interface{}) string {
108108
return pkg + "/" + name
109109
}
110110

111-
func protoMarshal(v interface{}) ([]byte, error) {
111+
func protoMarshal(v any) ([]byte, error) {
112112
pb := v.(proto.Message)
113113
return proto.Marshal(pb)
114114
}
115115

116-
func protoUnmarshal(buf []byte, v interface{}) error {
116+
func protoUnmarshal(buf []byte, v any) error {
117117
pb := v.(proto.Message)
118118
return proto.Unmarshal(buf, pb)
119119
}

go.mod

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,41 @@
11
module github.com/lytics/grid/v3
22

3-
go 1.18
3+
go 1.23.0
4+
5+
toolchain go1.24.4
46

57
require (
68
github.com/lytics/retry v1.2.0
7-
github.com/stretchr/testify v1.8.4
8-
go.etcd.io/etcd/client/v3 v3.5.7
9-
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.44.0
10-
google.golang.org/grpc v1.58.0
11-
google.golang.org/protobuf v1.31.0
9+
github.com/stretchr/testify v1.10.0
10+
go.etcd.io/etcd/client/v3 v3.6.1
11+
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.62.0
12+
google.golang.org/grpc v1.73.0
13+
google.golang.org/protobuf v1.36.6
1214
)
1315

1416
require (
1517
github.com/coreos/go-semver v0.3.1 // indirect
1618
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
1719
github.com/davecgh/go-spew v1.1.1 // indirect
18-
github.com/go-logr/logr v1.2.4 // indirect
20+
github.com/go-logr/logr v1.4.3 // indirect
1921
github.com/go-logr/stdr v1.2.2 // indirect
2022
github.com/gogo/protobuf v1.3.2 // indirect
21-
github.com/golang/protobuf v1.5.3 // indirect
22-
github.com/kr/text v0.2.0 // indirect
23-
github.com/pkg/errors v0.9.1 // indirect
23+
github.com/golang/protobuf v1.5.4 // indirect
24+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.1 // indirect
2425
github.com/pmezard/go-difflib v1.0.0 // indirect
25-
go.etcd.io/etcd/api/v3 v3.5.7 // indirect
26-
go.etcd.io/etcd/client/pkg/v3 v3.5.7 // indirect
27-
go.opentelemetry.io/otel v1.18.0 // indirect
28-
go.opentelemetry.io/otel/metric v1.18.0 // indirect
29-
go.opentelemetry.io/otel/trace v1.18.0 // indirect
30-
go.uber.org/atomic v1.10.0 // indirect
31-
go.uber.org/goleak v1.2.1 // indirect
32-
go.uber.org/multierr v1.10.0 // indirect
33-
go.uber.org/zap v1.24.0 // indirect
34-
golang.org/x/net v0.15.0 // indirect
35-
golang.org/x/sys v0.12.0 // indirect
36-
golang.org/x/text v0.13.0 // indirect
37-
google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 // indirect
38-
google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 // indirect
39-
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
40-
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
26+
go.etcd.io/etcd/api/v3 v3.6.1 // indirect
27+
go.etcd.io/etcd/client/pkg/v3 v3.6.1 // indirect
28+
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
29+
go.opentelemetry.io/otel v1.37.0 // indirect
30+
go.opentelemetry.io/otel/metric v1.37.0 // indirect
31+
go.opentelemetry.io/otel/trace v1.37.0 // indirect
32+
go.uber.org/multierr v1.11.0 // indirect
33+
go.uber.org/zap v1.27.0 // indirect
34+
golang.org/x/net v0.41.0 // indirect
35+
golang.org/x/sys v0.33.0 // indirect
36+
golang.org/x/text v0.26.0 // indirect
37+
google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822 // indirect
38+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 // indirect
4139
gopkg.in/yaml.v3 v3.0.1 // indirect
4240
)
4341

0 commit comments

Comments
 (0)