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
497497type 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
504504func (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
0 commit comments