mirror of https://github.com/grpc/grpc-go.git
*: update `interface{}` to `any` and `go.mod` version to `go 1.19` (#6544)
This commit is contained in:
parent
e40da6613d
commit
fbff2abb0f
|
@ -34,26 +34,26 @@ import (
|
|||
// key/value pairs. Keys must be hashable, and users should define their own
|
||||
// types for keys. Values should not be modified after they are added to an
|
||||
// Attributes or if they were received from one. If values implement 'Equal(o
|
||||
// interface{}) bool', it will be called by (*Attributes).Equal to determine
|
||||
// whether two values with the same key should be considered equal.
|
||||
// any) bool', it will be called by (*Attributes).Equal to determine whether
|
||||
// two values with the same key should be considered equal.
|
||||
type Attributes struct {
|
||||
m map[interface{}]interface{}
|
||||
m map[any]any
|
||||
}
|
||||
|
||||
// New returns a new Attributes containing the key/value pair.
|
||||
func New(key, value interface{}) *Attributes {
|
||||
return &Attributes{m: map[interface{}]interface{}{key: value}}
|
||||
func New(key, value any) *Attributes {
|
||||
return &Attributes{m: map[any]any{key: value}}
|
||||
}
|
||||
|
||||
// WithValue returns a new Attributes containing the previous keys and values
|
||||
// and the new key/value pair. If the same key appears multiple times, the
|
||||
// last value overwrites all previous values for that key. To remove an
|
||||
// existing key, use a nil value. value should not be modified later.
|
||||
func (a *Attributes) WithValue(key, value interface{}) *Attributes {
|
||||
func (a *Attributes) WithValue(key, value any) *Attributes {
|
||||
if a == nil {
|
||||
return New(key, value)
|
||||
}
|
||||
n := &Attributes{m: make(map[interface{}]interface{}, len(a.m)+1)}
|
||||
n := &Attributes{m: make(map[any]any, len(a.m)+1)}
|
||||
for k, v := range a.m {
|
||||
n.m[k] = v
|
||||
}
|
||||
|
@ -63,20 +63,19 @@ func (a *Attributes) WithValue(key, value interface{}) *Attributes {
|
|||
|
||||
// Value returns the value associated with these attributes for key, or nil if
|
||||
// no value is associated with key. The returned value should not be modified.
|
||||
func (a *Attributes) Value(key interface{}) interface{} {
|
||||
func (a *Attributes) Value(key any) any {
|
||||
if a == nil {
|
||||
return nil
|
||||
}
|
||||
return a.m[key]
|
||||
}
|
||||
|
||||
// Equal returns whether a and o are equivalent. If 'Equal(o interface{})
|
||||
// bool' is implemented for a value in the attributes, it is called to
|
||||
// determine if the value matches the one stored in the other attributes. If
|
||||
// Equal is not implemented, standard equality is used to determine if the two
|
||||
// values are equal. Note that some types (e.g. maps) aren't comparable by
|
||||
// default, so they must be wrapped in a struct, or in an alias type, with Equal
|
||||
// defined.
|
||||
// Equal returns whether a and o are equivalent. If 'Equal(o any) bool' is
|
||||
// implemented for a value in the attributes, it is called to determine if the
|
||||
// value matches the one stored in the other attributes. If Equal is not
|
||||
// implemented, standard equality is used to determine if the two values are
|
||||
// equal. Note that some types (e.g. maps) aren't comparable by default, so
|
||||
// they must be wrapped in a struct, or in an alias type, with Equal defined.
|
||||
func (a *Attributes) Equal(o *Attributes) bool {
|
||||
if a == nil && o == nil {
|
||||
return true
|
||||
|
@ -93,7 +92,7 @@ func (a *Attributes) Equal(o *Attributes) bool {
|
|||
// o missing element of a
|
||||
return false
|
||||
}
|
||||
if eq, ok := v.(interface{ Equal(o interface{}) bool }); ok {
|
||||
if eq, ok := v.(interface{ Equal(o any) bool }); ok {
|
||||
if !eq.Equal(ov) {
|
||||
return false
|
||||
}
|
||||
|
@ -122,7 +121,7 @@ func (a *Attributes) String() string {
|
|||
return sb.String()
|
||||
}
|
||||
|
||||
func str(x interface{}) string {
|
||||
func str(x any) string {
|
||||
if v, ok := x.(fmt.Stringer); ok {
|
||||
return v.String()
|
||||
} else if v, ok := x.(string); ok {
|
||||
|
|
|
@ -29,7 +29,7 @@ type stringVal struct {
|
|||
s string
|
||||
}
|
||||
|
||||
func (s stringVal) Equal(o interface{}) bool {
|
||||
func (s stringVal) Equal(o any) bool {
|
||||
os, ok := o.(stringVal)
|
||||
return ok && s.s == os.s
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ type logger struct {
|
|||
|
||||
// Log marshals the audit.Event to json and prints it to standard output.
|
||||
func (l *logger) Log(event *audit.Event) {
|
||||
jsonContainer := map[string]interface{}{
|
||||
jsonContainer := map[string]any{
|
||||
"grpc_audit_log": convertEvent(event),
|
||||
}
|
||||
jsonBytes, err := json.Marshal(jsonContainer)
|
||||
|
|
|
@ -72,11 +72,11 @@ func (s) TestStdoutLogger_Log(t *testing.T) {
|
|||
|
||||
auditLogger.Log(test.event)
|
||||
|
||||
var container map[string]interface{}
|
||||
var container map[string]any
|
||||
if err := json.Unmarshal(buf.Bytes(), &container); err != nil {
|
||||
t.Fatalf("Failed to unmarshal audit log event: %v", err)
|
||||
}
|
||||
innerEvent := extractEvent(container["grpc_audit_log"].(map[string]interface{}))
|
||||
innerEvent := extractEvent(container["grpc_audit_log"].(map[string]any))
|
||||
if innerEvent.Timestamp == "" {
|
||||
t.Fatalf("Resulted event has no timestamp: %v", innerEvent)
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ func (s) TestStdoutLoggerBuilder_Registration(t *testing.T) {
|
|||
|
||||
// extractEvent extracts an stdout.event from a map
|
||||
// unmarshalled from a logged json message.
|
||||
func extractEvent(container map[string]interface{}) event {
|
||||
func extractEvent(container map[string]any) event {
|
||||
return event{
|
||||
FullMethodName: container["rpc_method"].(string),
|
||||
Principal: container["principal"].(string),
|
||||
|
|
|
@ -58,7 +58,7 @@ func NewStatic(authzPolicy string) (*StaticInterceptor, error) {
|
|||
// UnaryInterceptor intercepts incoming Unary RPC requests.
|
||||
// Only authorized requests are allowed to pass. Otherwise, an unauthorized
|
||||
// error is returned to the client.
|
||||
func (i *StaticInterceptor) UnaryInterceptor(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
|
||||
func (i *StaticInterceptor) UnaryInterceptor(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
|
||||
err := i.engines.IsAuthorized(ctx)
|
||||
if err != nil {
|
||||
if status.Code(err) == codes.PermissionDenied {
|
||||
|
@ -75,7 +75,7 @@ func (i *StaticInterceptor) UnaryInterceptor(ctx context.Context, req interface{
|
|||
// StreamInterceptor intercepts incoming Stream RPC requests.
|
||||
// Only authorized requests are allowed to pass. Otherwise, an unauthorized
|
||||
// error is returned to the client.
|
||||
func (i *StaticInterceptor) StreamInterceptor(srv interface{}, ss grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
|
||||
func (i *StaticInterceptor) StreamInterceptor(srv any, ss grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
|
||||
err := i.engines.IsAuthorized(ss.Context())
|
||||
if err != nil {
|
||||
if status.Code(err) == codes.PermissionDenied {
|
||||
|
@ -166,13 +166,13 @@ func (i *FileWatcherInterceptor) Close() {
|
|||
// UnaryInterceptor intercepts incoming Unary RPC requests.
|
||||
// Only authorized requests are allowed to pass. Otherwise, an unauthorized
|
||||
// error is returned to the client.
|
||||
func (i *FileWatcherInterceptor) UnaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
|
||||
func (i *FileWatcherInterceptor) UnaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
|
||||
return ((*StaticInterceptor)(atomic.LoadPointer(&i.internalInterceptor))).UnaryInterceptor(ctx, req, info, handler)
|
||||
}
|
||||
|
||||
// StreamInterceptor intercepts incoming Stream RPC requests.
|
||||
// Only authorized requests are allowed to pass. Otherwise, an unauthorized
|
||||
// error is returned to the client.
|
||||
func (i *FileWatcherInterceptor) StreamInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
|
||||
func (i *FileWatcherInterceptor) StreamInterceptor(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
|
||||
return ((*StaticInterceptor)(atomic.LoadPointer(&i.internalInterceptor))).StreamInterceptor(srv, ss, info, handler)
|
||||
}
|
||||
|
|
|
@ -308,7 +308,7 @@ func TestTranslatePolicy(t *testing.T) {
|
|||
AuditLoggingOptions: &v3rbacpb.RBAC_AuditLoggingOptions{
|
||||
AuditCondition: v3rbacpb.RBAC_AuditLoggingOptions_NONE,
|
||||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{Name: "stdout_logger", TypedConfig: anyPbHelper(t, map[string]interface{}{}, "stdout_logger")},
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{Name: "stdout_logger", TypedConfig: anyPbHelper(t, map[string]any{}, "stdout_logger")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -342,7 +342,7 @@ func TestTranslatePolicy(t *testing.T) {
|
|||
AuditLoggingOptions: &v3rbacpb.RBAC_AuditLoggingOptions{
|
||||
AuditCondition: v3rbacpb.RBAC_AuditLoggingOptions_ON_ALLOW,
|
||||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{Name: "stdout_logger", TypedConfig: anyPbHelper(t, map[string]interface{}{}, "stdout_logger")},
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{Name: "stdout_logger", TypedConfig: anyPbHelper(t, map[string]any{}, "stdout_logger")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -404,7 +404,7 @@ func TestTranslatePolicy(t *testing.T) {
|
|||
AuditLoggingOptions: &v3rbacpb.RBAC_AuditLoggingOptions{
|
||||
AuditCondition: v3rbacpb.RBAC_AuditLoggingOptions_ON_DENY,
|
||||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{Name: "stdout_logger", TypedConfig: anyPbHelper(t, map[string]interface{}{}, "stdout_logger")},
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{Name: "stdout_logger", TypedConfig: anyPbHelper(t, map[string]any{}, "stdout_logger")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -438,7 +438,7 @@ func TestTranslatePolicy(t *testing.T) {
|
|||
AuditLoggingOptions: &v3rbacpb.RBAC_AuditLoggingOptions{
|
||||
AuditCondition: v3rbacpb.RBAC_AuditLoggingOptions_ON_DENY_AND_ALLOW,
|
||||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{Name: "stdout_logger", TypedConfig: anyPbHelper(t, map[string]interface{}{}, "stdout_logger")},
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{Name: "stdout_logger", TypedConfig: anyPbHelper(t, map[string]any{}, "stdout_logger")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -500,7 +500,7 @@ func TestTranslatePolicy(t *testing.T) {
|
|||
AuditLoggingOptions: &v3rbacpb.RBAC_AuditLoggingOptions{
|
||||
AuditCondition: v3rbacpb.RBAC_AuditLoggingOptions_NONE,
|
||||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{Name: "stdout_logger", TypedConfig: anyPbHelper(t, map[string]interface{}{}, "stdout_logger")},
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{Name: "stdout_logger", TypedConfig: anyPbHelper(t, map[string]any{}, "stdout_logger")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -534,7 +534,7 @@ func TestTranslatePolicy(t *testing.T) {
|
|||
AuditLoggingOptions: &v3rbacpb.RBAC_AuditLoggingOptions{
|
||||
AuditCondition: v3rbacpb.RBAC_AuditLoggingOptions_NONE,
|
||||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{Name: "stdout_logger", TypedConfig: anyPbHelper(t, map[string]interface{}{}, "stdout_logger")},
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{Name: "stdout_logger", TypedConfig: anyPbHelper(t, map[string]any{}, "stdout_logger")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -596,7 +596,7 @@ func TestTranslatePolicy(t *testing.T) {
|
|||
AuditLoggingOptions: &v3rbacpb.RBAC_AuditLoggingOptions{
|
||||
AuditCondition: v3rbacpb.RBAC_AuditLoggingOptions_NONE,
|
||||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{Name: "stdout_logger", TypedConfig: anyPbHelper(t, map[string]interface{}{"abc": 123, "xyz": "123"}, "stdout_logger")},
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{Name: "stdout_logger", TypedConfig: anyPbHelper(t, map[string]any{"abc": 123, "xyz": "123"}, "stdout_logger")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -630,7 +630,7 @@ func TestTranslatePolicy(t *testing.T) {
|
|||
AuditLoggingOptions: &v3rbacpb.RBAC_AuditLoggingOptions{
|
||||
AuditCondition: v3rbacpb.RBAC_AuditLoggingOptions_NONE,
|
||||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{Name: "stdout_logger", TypedConfig: anyPbHelper(t, map[string]interface{}{"abc": 123, "xyz": "123"}, "stdout_logger")},
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{Name: "stdout_logger", TypedConfig: anyPbHelper(t, map[string]any{"abc": 123, "xyz": "123"}, "stdout_logger")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -688,7 +688,7 @@ func TestTranslatePolicy(t *testing.T) {
|
|||
AuditLoggingOptions: &v3rbacpb.RBAC_AuditLoggingOptions{
|
||||
AuditCondition: v3rbacpb.RBAC_AuditLoggingOptions_NONE,
|
||||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{Name: "stdout_logger", TypedConfig: anyPbHelper(t, map[string]interface{}{"abc": 123, "xyz": map[string]interface{}{"abc": 123}}, "stdout_logger")},
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{Name: "stdout_logger", TypedConfig: anyPbHelper(t, map[string]any{"abc": 123, "xyz": map[string]any{"abc": 123}}, "stdout_logger")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -792,7 +792,7 @@ func TestTranslatePolicy(t *testing.T) {
|
|||
AuditLoggingOptions: &v3rbacpb.RBAC_AuditLoggingOptions{
|
||||
AuditCondition: v3rbacpb.RBAC_AuditLoggingOptions_NONE,
|
||||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{Name: "stdout_logger", TypedConfig: anyPbHelper(t, map[string]interface{}{}, "stdout_logger")},
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{Name: "stdout_logger", TypedConfig: anyPbHelper(t, map[string]any{}, "stdout_logger")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -853,7 +853,7 @@ func TestTranslatePolicy(t *testing.T) {
|
|||
AuditLoggingOptions: &v3rbacpb.RBAC_AuditLoggingOptions{
|
||||
AuditCondition: v3rbacpb.RBAC_AuditLoggingOptions_ON_DENY,
|
||||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{Name: "stdout_logger", TypedConfig: anyPbHelper(t, map[string]interface{}{}, "stdout_logger")},
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{Name: "stdout_logger", TypedConfig: anyPbHelper(t, map[string]any{}, "stdout_logger")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -887,7 +887,7 @@ func TestTranslatePolicy(t *testing.T) {
|
|||
AuditLoggingOptions: &v3rbacpb.RBAC_AuditLoggingOptions{
|
||||
AuditCondition: v3rbacpb.RBAC_AuditLoggingOptions_ON_DENY,
|
||||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{Name: "stdout_logger", TypedConfig: anyPbHelper(t, map[string]interface{}{}, "stdout_logger")},
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{Name: "stdout_logger", TypedConfig: anyPbHelper(t, map[string]any{}, "stdout_logger")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -1034,7 +1034,7 @@ func TestTranslatePolicy(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func anyPbHelper(t *testing.T, in map[string]interface{}, name string) *anypb.Any {
|
||||
func anyPbHelper(t *testing.T, in map[string]any, name string) *anypb.Any {
|
||||
t.Helper()
|
||||
pb, err := structpb.NewStruct(in)
|
||||
typedStruct := &v1xdsudpatypepb.TypedStruct{
|
||||
|
|
|
@ -270,7 +270,7 @@ type DoneInfo struct {
|
|||
// trailing metadata.
|
||||
//
|
||||
// The only supported type now is *orca_v3.LoadReport.
|
||||
ServerLoad interface{}
|
||||
ServerLoad any
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -414,15 +414,14 @@ var ErrBadResolverState = errors.New("bad resolver state")
|
|||
type ProducerBuilder interface {
|
||||
// Build creates a Producer. The first parameter is always a
|
||||
// grpc.ClientConnInterface (a type to allow creating RPCs/streams on the
|
||||
// associated SubConn), but is declared as interface{} to avoid a
|
||||
// dependency cycle. Should also return a close function that will be
|
||||
// called when all references to the Producer have been given up.
|
||||
Build(grpcClientConnInterface interface{}) (p Producer, close func())
|
||||
// associated SubConn), but is declared as `any` to avoid a dependency
|
||||
// cycle. Should also return a close function that will be called when all
|
||||
// references to the Producer have been given up.
|
||||
Build(grpcClientConnInterface any) (p Producer, close func())
|
||||
}
|
||||
|
||||
// A Producer is a type shared among potentially many consumers. It is
|
||||
// associated with a SubConn, and an implementation will typically contain
|
||||
// other methods to provide additional functionality, e.g. configuration or
|
||||
// subscription registration.
|
||||
type Producer interface {
|
||||
}
|
||||
type Producer any
|
||||
|
|
|
@ -109,7 +109,7 @@ func (s) TestLookupFailure(t *testing.T) {
|
|||
// respond within the configured rpc timeout.
|
||||
func (s) TestLookupDeadlineExceeded(t *testing.T) {
|
||||
// A unary interceptor which returns a status error with DeadlineExceeded.
|
||||
interceptor := func(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
|
||||
interceptor := func(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) {
|
||||
return nil, status.Error(codes.DeadlineExceeded, "deadline exceeded")
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ func (f *testPerRPCCredentials) RequireTransportSecurity() bool {
|
|||
|
||||
// Unary server interceptor which validates if the RPC contains call credentials
|
||||
// which match `perRPCCredsData
|
||||
func callCredsValidatingServerInterceptor(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
|
||||
func callCredsValidatingServerInterceptor(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) {
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
if !ok {
|
||||
return nil, status.Error(codes.PermissionDenied, "didn't find metadata in context")
|
||||
|
|
|
@ -158,7 +158,7 @@ func (s) TestPick_DataCacheMiss_PendingEntryExists(t *testing.T) {
|
|||
// also lead to creation of a pending entry, and further RPCs by the
|
||||
// client should not result in RLS requests being sent out.
|
||||
rlsReqCh := make(chan struct{}, 1)
|
||||
interceptor := func(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
|
||||
interceptor := func(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) {
|
||||
rlsReqCh <- struct{}{}
|
||||
<-ctx.Done()
|
||||
return nil, ctx.Err()
|
||||
|
@ -633,7 +633,7 @@ func (s) TestPick_DataCacheHit_PendingEntryExists_StaleEntry(t *testing.T) {
|
|||
// expired entry and a pending entry in the cache.
|
||||
rlsReqCh := make(chan struct{}, 1)
|
||||
firstRPCDone := grpcsync.NewEvent()
|
||||
interceptor := func(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
|
||||
interceptor := func(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) {
|
||||
select {
|
||||
case rlsReqCh <- struct{}{}:
|
||||
default:
|
||||
|
@ -733,7 +733,7 @@ func (s) TestPick_DataCacheHit_PendingEntryExists_ExpiredEntry(t *testing.T) {
|
|||
// expired entry and a pending entry in the cache.
|
||||
rlsReqCh := make(chan struct{}, 1)
|
||||
firstRPCDone := grpcsync.NewEvent()
|
||||
interceptor := func(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
|
||||
interceptor := func(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) {
|
||||
select {
|
||||
case rlsReqCh <- struct{}{}:
|
||||
default:
|
||||
|
|
|
@ -44,7 +44,7 @@ type AddrInfo struct {
|
|||
}
|
||||
|
||||
// Equal allows the values to be compared by Attributes.Equal.
|
||||
func (a AddrInfo) Equal(o interface{}) bool {
|
||||
func (a AddrInfo) Equal(o any) bool {
|
||||
oa, ok := o.(AddrInfo)
|
||||
return ok && oa.Weight == a.Weight
|
||||
}
|
||||
|
|
|
@ -406,7 +406,7 @@ func (acbw *acBalancerWrapper) NewStream(ctx context.Context, desc *StreamDesc,
|
|||
|
||||
// Invoke performs a unary RPC. If the addrConn is not ready, returns
|
||||
// errSubConnNotReady.
|
||||
func (acbw *acBalancerWrapper) Invoke(ctx context.Context, method string, args interface{}, reply interface{}, opts ...CallOption) error {
|
||||
func (acbw *acBalancerWrapper) Invoke(ctx context.Context, method string, args any, reply any, opts ...CallOption) error {
|
||||
cs, err := acbw.NewStream(ctx, unaryStreamDesc, method, opts...)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -425,7 +425,7 @@ func makeFuncStream(bf stats.Features) (rpcCallFunc, rpcCleanupFunc) {
|
|||
if bf.RespPayloadCurve != nil {
|
||||
respSizeBytes = bf.RespPayloadCurve.ChooseRandom()
|
||||
}
|
||||
var req interface{}
|
||||
var req any
|
||||
if bf.EnablePreloader {
|
||||
req = preparedMsg[cn][pos]
|
||||
} else {
|
||||
|
@ -519,7 +519,7 @@ func unaryCaller(client testgrpc.BenchmarkServiceClient, reqSize, respSize int)
|
|||
}
|
||||
}
|
||||
|
||||
func streamCaller(stream testgrpc.BenchmarkService_StreamingCallClient, req interface{}) {
|
||||
func streamCaller(stream testgrpc.BenchmarkService_StreamingCallClient, req any) {
|
||||
if err := bm.DoStreamingRoundTripPreloaded(stream, req); err != nil {
|
||||
logger.Fatalf("DoStreamingRoundTrip failed: %v", err)
|
||||
}
|
||||
|
|
|
@ -248,7 +248,7 @@ type ServerInfo struct {
|
|||
// Metadata is an optional configuration.
|
||||
// For "protobuf", it's ignored.
|
||||
// For "bytebuf", it should be an int representing response size.
|
||||
Metadata interface{}
|
||||
Metadata any
|
||||
|
||||
// Listener is the network listener for the server to use
|
||||
Listener net.Listener
|
||||
|
@ -302,7 +302,7 @@ func DoStreamingRoundTrip(stream testgrpc.BenchmarkService_StreamingCallClient,
|
|||
}
|
||||
|
||||
// DoStreamingRoundTripPreloaded performs a round trip for a single streaming rpc with preloaded payload.
|
||||
func DoStreamingRoundTripPreloaded(stream testgrpc.BenchmarkService_StreamingCallClient, req interface{}) error {
|
||||
func DoStreamingRoundTripPreloaded(stream testgrpc.BenchmarkService_StreamingCallClient, req any) error {
|
||||
// req could be either *testpb.SimpleRequest or *grpc.PreparedMsg
|
||||
if err := stream.SendMsg(req); err != nil {
|
||||
return fmt.Errorf("/BenchmarkService/StreamingCall.Send(_) = %v, want <nil>", err)
|
||||
|
|
|
@ -367,7 +367,7 @@ func BenchmarkInterfaceTypeAssertion(b *testing.B) {
|
|||
runInterfaceTypeAssertion(b, myFooer{})
|
||||
}
|
||||
|
||||
func runInterfaceTypeAssertion(b *testing.B, fer interface{}) {
|
||||
func runInterfaceTypeAssertion(b *testing.B, fer any) {
|
||||
x := 0
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
|
@ -386,7 +386,7 @@ func BenchmarkStructTypeAssertion(b *testing.B) {
|
|||
runStructTypeAssertion(b, myFooer{})
|
||||
}
|
||||
|
||||
func runStructTypeAssertion(b *testing.B, fer interface{}) {
|
||||
func runStructTypeAssertion(b *testing.B, fer any) {
|
||||
x := 0
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
|
|
|
@ -53,7 +53,7 @@ var (
|
|||
type byteBufCodec struct {
|
||||
}
|
||||
|
||||
func (byteBufCodec) Marshal(v interface{}) ([]byte, error) {
|
||||
func (byteBufCodec) Marshal(v any) ([]byte, error) {
|
||||
b, ok := v.(*[]byte)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("failed to marshal: %v is not type of *[]byte", v)
|
||||
|
@ -61,7 +61,7 @@ func (byteBufCodec) Marshal(v interface{}) ([]byte, error) {
|
|||
return *b, nil
|
||||
}
|
||||
|
||||
func (byteBufCodec) Unmarshal(data []byte, v interface{}) error {
|
||||
func (byteBufCodec) Unmarshal(data []byte, v any) error {
|
||||
b, ok := v.(*[]byte)
|
||||
if !ok {
|
||||
return fmt.Errorf("failed to marshal: %v is not type of *[]byte", v)
|
||||
|
|
6
call.go
6
call.go
|
@ -26,7 +26,7 @@ import (
|
|||
// received. This is typically called by generated code.
|
||||
//
|
||||
// All errors returned by Invoke are compatible with the status package.
|
||||
func (cc *ClientConn) Invoke(ctx context.Context, method string, args, reply interface{}, opts ...CallOption) error {
|
||||
func (cc *ClientConn) Invoke(ctx context.Context, method string, args, reply any, opts ...CallOption) error {
|
||||
if err := cc.idlenessMgr.onCallBegin(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -61,13 +61,13 @@ func combine(o1 []CallOption, o2 []CallOption) []CallOption {
|
|||
// received. This is typically called by generated code.
|
||||
//
|
||||
// DEPRECATED: Use ClientConn.Invoke instead.
|
||||
func Invoke(ctx context.Context, method string, args, reply interface{}, cc *ClientConn, opts ...CallOption) error {
|
||||
func Invoke(ctx context.Context, method string, args, reply any, cc *ClientConn, opts ...CallOption) error {
|
||||
return cc.Invoke(ctx, method, args, reply, opts...)
|
||||
}
|
||||
|
||||
var unaryStreamDesc = &StreamDesc{ServerStreams: false, ClientStreams: false}
|
||||
|
||||
func invoke(ctx context.Context, method string, req, reply interface{}, cc *ClientConn, opts ...CallOption) error {
|
||||
func invoke(ctx context.Context, method string, req, reply any, cc *ClientConn, opts ...CallOption) error {
|
||||
cs, err := newClientStream(ctx, unaryStreamDesc, cc, method, opts...)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -492,7 +492,7 @@ func chainUnaryClientInterceptors(cc *ClientConn) {
|
|||
} else if len(interceptors) == 1 {
|
||||
chainedInt = interceptors[0]
|
||||
} else {
|
||||
chainedInt = func(ctx context.Context, method string, req, reply interface{}, cc *ClientConn, invoker UnaryInvoker, opts ...CallOption) error {
|
||||
chainedInt = func(ctx context.Context, method string, req, reply any, cc *ClientConn, invoker UnaryInvoker, opts ...CallOption) error {
|
||||
return interceptors[0](ctx, method, req, reply, cc, getChainUnaryInvoker(interceptors, 0, invoker), opts...)
|
||||
}
|
||||
}
|
||||
|
@ -504,7 +504,7 @@ func getChainUnaryInvoker(interceptors []UnaryClientInterceptor, curr int, final
|
|||
if curr == len(interceptors)-1 {
|
||||
return finalInvoker
|
||||
}
|
||||
return func(ctx context.Context, method string, req, reply interface{}, cc *ClientConn, opts ...CallOption) error {
|
||||
return func(ctx context.Context, method string, req, reply any, cc *ClientConn, opts ...CallOption) error {
|
||||
return interceptors[curr+1](ctx, method, req, reply, cc, getChainUnaryInvoker(interceptors, curr+1, finalInvoker), opts...)
|
||||
}
|
||||
}
|
||||
|
@ -607,7 +607,7 @@ func (csm *connectivityStateManager) getNotifyChan() <-chan struct{} {
|
|||
type ClientConnInterface interface {
|
||||
// Invoke performs a unary RPC and returns after the response is received
|
||||
// into reply.
|
||||
Invoke(ctx context.Context, method string, args interface{}, reply interface{}, opts ...CallOption) error
|
||||
Invoke(ctx context.Context, method string, args any, reply any, opts ...CallOption) error
|
||||
// NewStream begins a streaming RPC.
|
||||
NewStream(ctx context.Context, desc *StreamDesc, method string, opts ...CallOption) (ClientStream, error)
|
||||
}
|
||||
|
@ -1581,7 +1581,7 @@ func (ac *addrConn) startHealthCheck(ctx context.Context) {
|
|||
|
||||
// Set up the health check helper functions.
|
||||
currentTr := ac.transport
|
||||
newStream := func(method string) (interface{}, error) {
|
||||
newStream := func(method string) (any, error) {
|
||||
ac.mu.Lock()
|
||||
if ac.transport != currentTr {
|
||||
ac.mu.Unlock()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module google.golang.org/grpc/cmd/protoc-gen-go-grpc
|
||||
|
||||
go 1.17
|
||||
go 1.19
|
||||
|
||||
require google.golang.org/protobuf v1.31.0
|
||||
|
|
8
codec.go
8
codec.go
|
@ -27,8 +27,8 @@ import (
|
|||
// omits the name/string, which vary between the two and are not needed for
|
||||
// anything besides the registry in the encoding package.
|
||||
type baseCodec interface {
|
||||
Marshal(v interface{}) ([]byte, error)
|
||||
Unmarshal(data []byte, v interface{}) error
|
||||
Marshal(v any) ([]byte, error)
|
||||
Unmarshal(data []byte, v any) error
|
||||
}
|
||||
|
||||
var _ baseCodec = Codec(nil)
|
||||
|
@ -41,9 +41,9 @@ var _ baseCodec = encoding.Codec(nil)
|
|||
// Deprecated: use encoding.Codec instead.
|
||||
type Codec interface {
|
||||
// Marshal returns the wire format of v.
|
||||
Marshal(v interface{}) ([]byte, error)
|
||||
Marshal(v any) ([]byte, error)
|
||||
// Unmarshal parses the wire format into v.
|
||||
Unmarshal(data []byte, v interface{}) error
|
||||
Unmarshal(data []byte, v any) error
|
||||
// String returns the name of the Codec implementation. This is unused by
|
||||
// gRPC.
|
||||
String() string
|
||||
|
|
|
@ -39,7 +39,7 @@ func init() {
|
|||
|
||||
type pluginBuilder struct{}
|
||||
|
||||
func (p *pluginBuilder) ParseConfig(c interface{}) (*certprovider.BuildableConfig, error) {
|
||||
func (p *pluginBuilder) ParseConfig(c any) (*certprovider.BuildableConfig, error) {
|
||||
data, ok := c.(json.RawMessage)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("meshca: unsupported config type: %T", c)
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
func TestParseConfig(t *testing.T) {
|
||||
tests := []struct {
|
||||
desc string
|
||||
input interface{}
|
||||
input any
|
||||
wantOutput string
|
||||
wantErr bool
|
||||
}{
|
||||
|
|
|
@ -66,7 +66,7 @@ func getBuilder(name string) Builder {
|
|||
type Builder interface {
|
||||
// ParseConfig parses the given config, which is in a format specific to individual
|
||||
// implementations, and returns a BuildableConfig on success.
|
||||
ParseConfig(interface{}) (*BuildableConfig, error)
|
||||
ParseConfig(any) (*BuildableConfig, error)
|
||||
|
||||
// Name returns the name of providers built by this builder.
|
||||
Name() string
|
||||
|
|
|
@ -31,8 +31,8 @@ var provStore = &store{
|
|||
// storeKey acts as the key to the map of providers maintained by the store. A
|
||||
// combination of provider name and configuration is used to uniquely identify
|
||||
// every provider instance in the store. Go maps need to be indexed by
|
||||
// comparable types, so the provider configuration is converted from
|
||||
// `interface{}` to string using the ParseConfig method while creating this key.
|
||||
// comparable types, so the provider configuration is converted from `any` to
|
||||
// `string` using the ParseConfig method while creating this key.
|
||||
type storeKey struct {
|
||||
// name of the certificate provider.
|
||||
name string
|
||||
|
@ -137,7 +137,7 @@ func (bc *BuildableConfig) String() string {
|
|||
// ParseConfig is a convenience function to create a BuildableConfig given a
|
||||
// provider name and configuration. Returns an error if there is no registered
|
||||
// builder for the given name or if the config parsing fails.
|
||||
func ParseConfig(name string, config interface{}) (*BuildableConfig, error) {
|
||||
func ParseConfig(name string, config any) (*BuildableConfig, error) {
|
||||
parser := getBuilder(name)
|
||||
if parser == nil {
|
||||
return nil, fmt.Errorf("no certificate provider builder found for %q", name)
|
||||
|
@ -147,7 +147,7 @@ func ParseConfig(name string, config interface{}) (*BuildableConfig, error) {
|
|||
|
||||
// GetProvider is a convenience function to create a provider given the name,
|
||||
// config and build options.
|
||||
func GetProvider(name string, config interface{}, opts BuildOptions) (Provider, error) {
|
||||
func GetProvider(name string, config any, opts BuildOptions) (Provider, error) {
|
||||
bc, err := ParseConfig(name, config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -73,7 +73,7 @@ type fakeProviderBuilder struct {
|
|||
providerChan *testutils.Channel
|
||||
}
|
||||
|
||||
func (b *fakeProviderBuilder) ParseConfig(config interface{}) (*BuildableConfig, error) {
|
||||
func (b *fakeProviderBuilder) ParseConfig(config any) (*BuildableConfig, error) {
|
||||
s, ok := config.(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("providerBuilder %s received config of type %T, want string", b.name, config)
|
||||
|
|
|
@ -90,9 +90,9 @@ func GetCompressor(name string) Compressor {
|
|||
// methods can be called from concurrent goroutines.
|
||||
type Codec interface {
|
||||
// Marshal returns the wire format of v.
|
||||
Marshal(v interface{}) ([]byte, error)
|
||||
Marshal(v any) ([]byte, error)
|
||||
// Unmarshal parses the wire format into v.
|
||||
Unmarshal(data []byte, v interface{}) error
|
||||
Unmarshal(data []byte, v any) error
|
||||
// Name returns the name of the Codec implementation. The returned string
|
||||
// will be used as part of content type in transmission. The result must be
|
||||
// static; the result cannot change between calls.
|
||||
|
|
|
@ -40,7 +40,7 @@ const Name = "gzip"
|
|||
|
||||
func init() {
|
||||
c := &compressor{}
|
||||
c.poolCompressor.New = func() interface{} {
|
||||
c.poolCompressor.New = func() any {
|
||||
return &writer{Writer: gzip.NewWriter(io.Discard), pool: &c.poolCompressor}
|
||||
}
|
||||
encoding.RegisterCompressor(c)
|
||||
|
@ -61,7 +61,7 @@ func SetLevel(level int) error {
|
|||
return fmt.Errorf("grpc: invalid gzip compression level: %d", level)
|
||||
}
|
||||
c := encoding.GetCompressor(Name).(*compressor)
|
||||
c.poolCompressor.New = func() interface{} {
|
||||
c.poolCompressor.New = func() any {
|
||||
w, err := gzip.NewWriterLevel(io.Discard, level)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
|
@ -37,7 +37,7 @@ func init() {
|
|||
// codec is a Codec implementation with protobuf. It is the default codec for gRPC.
|
||||
type codec struct{}
|
||||
|
||||
func (codec) Marshal(v interface{}) ([]byte, error) {
|
||||
func (codec) Marshal(v any) ([]byte, error) {
|
||||
vv, ok := v.(proto.Message)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("failed to marshal, message is %T, want proto.Message", v)
|
||||
|
@ -45,7 +45,7 @@ func (codec) Marshal(v interface{}) ([]byte, error) {
|
|||
return proto.Marshal(vv)
|
||||
}
|
||||
|
||||
func (codec) Unmarshal(data []byte, v interface{}) error {
|
||||
func (codec) Unmarshal(data []byte, v any) error {
|
||||
vv, ok := v.(proto.Message)
|
||||
if !ok {
|
||||
return fmt.Errorf("failed to unmarshal, message is %T, want proto.Message", v)
|
||||
|
|
|
@ -97,7 +97,7 @@ func valid(authorization []string) bool {
|
|||
// the token is missing or invalid, the interceptor blocks execution of the
|
||||
// handler and returns an error. Otherwise, the interceptor invokes the unary
|
||||
// handler.
|
||||
func ensureValidToken(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
|
||||
func ensureValidToken(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
if !ok {
|
||||
return nil, errMissingMetadata
|
||||
|
|
|
@ -140,7 +140,7 @@ func isAuthenticated(authorization []string) (username string, err error) {
|
|||
// authUnaryInterceptor looks up the authorization header from the incoming RPC context,
|
||||
// retrieves the username from it and creates a new context with the username before invoking
|
||||
// the provided handler.
|
||||
func authUnaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
|
||||
func authUnaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
if !ok {
|
||||
return nil, errMissingMetadata
|
||||
|
@ -171,7 +171,7 @@ func newWrappedStream(ctx context.Context, s grpc.ServerStream) grpc.ServerStrea
|
|||
// authStreamInterceptor looks up the authorization header from the incoming RPC context,
|
||||
// retrieves the username from it and creates a new context with the username before invoking
|
||||
// the provided handler.
|
||||
func authStreamInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
|
||||
func authStreamInterceptor(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
|
||||
md, ok := metadata.FromIncomingContext(ss.Context())
|
||||
if !ok {
|
||||
return errMissingMetadata
|
||||
|
|
|
@ -40,12 +40,12 @@ var addr = flag.String("addr", "localhost:50051", "the address to connect to")
|
|||
const fallbackToken = "some-secret-token"
|
||||
|
||||
// logger is to mock a sophisticated logging system. To simplify the example, we just print out the content.
|
||||
func logger(format string, a ...interface{}) {
|
||||
func logger(format string, a ...any) {
|
||||
fmt.Printf("LOG:\t"+format+"\n", a...)
|
||||
}
|
||||
|
||||
// unaryInterceptor is an example unary interceptor.
|
||||
func unaryInterceptor(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
func unaryInterceptor(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
var credsConfigured bool
|
||||
for _, o := range opts {
|
||||
_, ok := o.(grpc.PerRPCCredsCallOption)
|
||||
|
@ -72,12 +72,12 @@ type wrappedStream struct {
|
|||
grpc.ClientStream
|
||||
}
|
||||
|
||||
func (w *wrappedStream) RecvMsg(m interface{}) error {
|
||||
func (w *wrappedStream) RecvMsg(m any) error {
|
||||
logger("Receive a message (Type: %T) at %v", m, time.Now().Format(time.RFC3339))
|
||||
return w.ClientStream.RecvMsg(m)
|
||||
}
|
||||
|
||||
func (w *wrappedStream) SendMsg(m interface{}) error {
|
||||
func (w *wrappedStream) SendMsg(m any) error {
|
||||
logger("Send a message (Type: %T) at %v", m, time.Now().Format(time.RFC3339))
|
||||
return w.ClientStream.SendMsg(m)
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ var (
|
|||
)
|
||||
|
||||
// logger is to mock a sophisticated logging system. To simplify the example, we just print out the content.
|
||||
func logger(format string, a ...interface{}) {
|
||||
func logger(format string, a ...any) {
|
||||
fmt.Printf("LOG:\t"+format+"\n", a...)
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ func valid(authorization []string) bool {
|
|||
return token == "some-secret-token"
|
||||
}
|
||||
|
||||
func unaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
|
||||
func unaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
|
||||
// authentication (token verification)
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
if !ok {
|
||||
|
@ -109,12 +109,12 @@ type wrappedStream struct {
|
|||
grpc.ServerStream
|
||||
}
|
||||
|
||||
func (w *wrappedStream) RecvMsg(m interface{}) error {
|
||||
func (w *wrappedStream) RecvMsg(m any) error {
|
||||
logger("Receive a message (Type: %T) at %s", m, time.Now().Format(time.RFC3339))
|
||||
return w.ServerStream.RecvMsg(m)
|
||||
}
|
||||
|
||||
func (w *wrappedStream) SendMsg(m interface{}) error {
|
||||
func (w *wrappedStream) SendMsg(m any) error {
|
||||
logger("Send a message (Type: %T) at %v", m, time.Now().Format(time.RFC3339))
|
||||
return w.ServerStream.SendMsg(m)
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ func newWrappedStream(s grpc.ServerStream) grpc.ServerStream {
|
|||
return &wrappedStream{s}
|
||||
}
|
||||
|
||||
func streamInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
|
||||
func streamInterceptor(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
|
||||
// authentication (token verification)
|
||||
md, ok := metadata.FromIncomingContext(ss.Context())
|
||||
if !ok {
|
||||
|
|
|
@ -43,7 +43,7 @@ type server struct {
|
|||
pb.UnimplementedEchoServer
|
||||
}
|
||||
|
||||
func unaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
|
||||
func unaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
if !ok {
|
||||
return nil, errMissingMetadata
|
||||
|
@ -83,7 +83,7 @@ func (s *wrappedStream) Context() context.Context {
|
|||
return s.ctx
|
||||
}
|
||||
|
||||
func streamInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
|
||||
func streamInterceptor(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
|
||||
md, ok := metadata.FromIncomingContext(ss.Context())
|
||||
if !ok {
|
||||
return errMissingMetadata
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module google.golang.org/grpc/examples/features/observability
|
||||
|
||||
go 1.17
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
google.golang.org/grpc v1.54.0
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module google.golang.org/grpc/examples
|
||||
|
||||
go 1.17
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module google.golang.org/grpc/gcp/observability
|
||||
|
||||
go 1.17
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
cloud.google.com/go/logging v1.7.0
|
||||
|
|
|
@ -60,8 +60,8 @@ func labelsToMonitoringLabels(labels map[string]string) *stackdriver.Labels {
|
|||
return sdLabels
|
||||
}
|
||||
|
||||
func labelsToTraceAttributes(labels map[string]string) map[string]interface{} {
|
||||
ta := make(map[string]interface{}, len(labels))
|
||||
func labelsToTraceAttributes(labels map[string]string) map[string]any {
|
||||
ta := make(map[string]any, len(labels))
|
||||
for k, v := range labels {
|
||||
ta[k] = v
|
||||
}
|
||||
|
|
2
go.mod
2
go.mod
|
@ -1,6 +1,6 @@
|
|||
module google.golang.org/grpc
|
||||
|
||||
go 1.17
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/cespare/xxhash/v2 v2.2.0
|
||||
|
|
|
@ -31,71 +31,71 @@ type componentData struct {
|
|||
|
||||
var cache = map[string]*componentData{}
|
||||
|
||||
func (c *componentData) InfoDepth(depth int, args ...interface{}) {
|
||||
args = append([]interface{}{"[" + string(c.name) + "]"}, args...)
|
||||
func (c *componentData) InfoDepth(depth int, args ...any) {
|
||||
args = append([]any{"[" + string(c.name) + "]"}, args...)
|
||||
grpclog.InfoDepth(depth+1, args...)
|
||||
}
|
||||
|
||||
func (c *componentData) WarningDepth(depth int, args ...interface{}) {
|
||||
args = append([]interface{}{"[" + string(c.name) + "]"}, args...)
|
||||
func (c *componentData) WarningDepth(depth int, args ...any) {
|
||||
args = append([]any{"[" + string(c.name) + "]"}, args...)
|
||||
grpclog.WarningDepth(depth+1, args...)
|
||||
}
|
||||
|
||||
func (c *componentData) ErrorDepth(depth int, args ...interface{}) {
|
||||
args = append([]interface{}{"[" + string(c.name) + "]"}, args...)
|
||||
func (c *componentData) ErrorDepth(depth int, args ...any) {
|
||||
args = append([]any{"[" + string(c.name) + "]"}, args...)
|
||||
grpclog.ErrorDepth(depth+1, args...)
|
||||
}
|
||||
|
||||
func (c *componentData) FatalDepth(depth int, args ...interface{}) {
|
||||
args = append([]interface{}{"[" + string(c.name) + "]"}, args...)
|
||||
func (c *componentData) FatalDepth(depth int, args ...any) {
|
||||
args = append([]any{"[" + string(c.name) + "]"}, args...)
|
||||
grpclog.FatalDepth(depth+1, args...)
|
||||
}
|
||||
|
||||
func (c *componentData) Info(args ...interface{}) {
|
||||
func (c *componentData) Info(args ...any) {
|
||||
c.InfoDepth(1, args...)
|
||||
}
|
||||
|
||||
func (c *componentData) Warning(args ...interface{}) {
|
||||
func (c *componentData) Warning(args ...any) {
|
||||
c.WarningDepth(1, args...)
|
||||
}
|
||||
|
||||
func (c *componentData) Error(args ...interface{}) {
|
||||
func (c *componentData) Error(args ...any) {
|
||||
c.ErrorDepth(1, args...)
|
||||
}
|
||||
|
||||
func (c *componentData) Fatal(args ...interface{}) {
|
||||
func (c *componentData) Fatal(args ...any) {
|
||||
c.FatalDepth(1, args...)
|
||||
}
|
||||
|
||||
func (c *componentData) Infof(format string, args ...interface{}) {
|
||||
func (c *componentData) Infof(format string, args ...any) {
|
||||
c.InfoDepth(1, fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
func (c *componentData) Warningf(format string, args ...interface{}) {
|
||||
func (c *componentData) Warningf(format string, args ...any) {
|
||||
c.WarningDepth(1, fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
func (c *componentData) Errorf(format string, args ...interface{}) {
|
||||
func (c *componentData) Errorf(format string, args ...any) {
|
||||
c.ErrorDepth(1, fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
func (c *componentData) Fatalf(format string, args ...interface{}) {
|
||||
func (c *componentData) Fatalf(format string, args ...any) {
|
||||
c.FatalDepth(1, fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
func (c *componentData) Infoln(args ...interface{}) {
|
||||
func (c *componentData) Infoln(args ...any) {
|
||||
c.InfoDepth(1, args...)
|
||||
}
|
||||
|
||||
func (c *componentData) Warningln(args ...interface{}) {
|
||||
func (c *componentData) Warningln(args ...any) {
|
||||
c.WarningDepth(1, args...)
|
||||
}
|
||||
|
||||
func (c *componentData) Errorln(args ...interface{}) {
|
||||
func (c *componentData) Errorln(args ...any) {
|
||||
c.ErrorDepth(1, args...)
|
||||
}
|
||||
|
||||
func (c *componentData) Fatalln(args ...interface{}) {
|
||||
func (c *componentData) Fatalln(args ...any) {
|
||||
c.FatalDepth(1, args...)
|
||||
}
|
||||
|
||||
|
|
|
@ -35,67 +35,67 @@ func init() {
|
|||
|
||||
type glogger struct{}
|
||||
|
||||
func (g *glogger) Info(args ...interface{}) {
|
||||
func (g *glogger) Info(args ...any) {
|
||||
glog.InfoDepth(d, args...)
|
||||
}
|
||||
|
||||
func (g *glogger) Infoln(args ...interface{}) {
|
||||
func (g *glogger) Infoln(args ...any) {
|
||||
glog.InfoDepth(d, fmt.Sprintln(args...))
|
||||
}
|
||||
|
||||
func (g *glogger) Infof(format string, args ...interface{}) {
|
||||
func (g *glogger) Infof(format string, args ...any) {
|
||||
glog.InfoDepth(d, fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
func (g *glogger) InfoDepth(depth int, args ...interface{}) {
|
||||
func (g *glogger) InfoDepth(depth int, args ...any) {
|
||||
glog.InfoDepth(depth+d, args...)
|
||||
}
|
||||
|
||||
func (g *glogger) Warning(args ...interface{}) {
|
||||
func (g *glogger) Warning(args ...any) {
|
||||
glog.WarningDepth(d, args...)
|
||||
}
|
||||
|
||||
func (g *glogger) Warningln(args ...interface{}) {
|
||||
func (g *glogger) Warningln(args ...any) {
|
||||
glog.WarningDepth(d, fmt.Sprintln(args...))
|
||||
}
|
||||
|
||||
func (g *glogger) Warningf(format string, args ...interface{}) {
|
||||
func (g *glogger) Warningf(format string, args ...any) {
|
||||
glog.WarningDepth(d, fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
func (g *glogger) WarningDepth(depth int, args ...interface{}) {
|
||||
func (g *glogger) WarningDepth(depth int, args ...any) {
|
||||
glog.WarningDepth(depth+d, args...)
|
||||
}
|
||||
|
||||
func (g *glogger) Error(args ...interface{}) {
|
||||
func (g *glogger) Error(args ...any) {
|
||||
glog.ErrorDepth(d, args...)
|
||||
}
|
||||
|
||||
func (g *glogger) Errorln(args ...interface{}) {
|
||||
func (g *glogger) Errorln(args ...any) {
|
||||
glog.ErrorDepth(d, fmt.Sprintln(args...))
|
||||
}
|
||||
|
||||
func (g *glogger) Errorf(format string, args ...interface{}) {
|
||||
func (g *glogger) Errorf(format string, args ...any) {
|
||||
glog.ErrorDepth(d, fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
func (g *glogger) ErrorDepth(depth int, args ...interface{}) {
|
||||
func (g *glogger) ErrorDepth(depth int, args ...any) {
|
||||
glog.ErrorDepth(depth+d, args...)
|
||||
}
|
||||
|
||||
func (g *glogger) Fatal(args ...interface{}) {
|
||||
func (g *glogger) Fatal(args ...any) {
|
||||
glog.FatalDepth(d, args...)
|
||||
}
|
||||
|
||||
func (g *glogger) Fatalln(args ...interface{}) {
|
||||
func (g *glogger) Fatalln(args ...any) {
|
||||
glog.FatalDepth(d, fmt.Sprintln(args...))
|
||||
}
|
||||
|
||||
func (g *glogger) Fatalf(format string, args ...interface{}) {
|
||||
func (g *glogger) Fatalf(format string, args ...any) {
|
||||
glog.FatalDepth(d, fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
func (g *glogger) FatalDepth(depth int, args ...interface{}) {
|
||||
func (g *glogger) FatalDepth(depth int, args ...any) {
|
||||
glog.FatalDepth(depth+d, args...)
|
||||
}
|
||||
|
||||
|
|
|
@ -42,53 +42,53 @@ func V(l int) bool {
|
|||
}
|
||||
|
||||
// Info logs to the INFO log.
|
||||
func Info(args ...interface{}) {
|
||||
func Info(args ...any) {
|
||||
grpclog.Logger.Info(args...)
|
||||
}
|
||||
|
||||
// Infof logs to the INFO log. Arguments are handled in the manner of fmt.Printf.
|
||||
func Infof(format string, args ...interface{}) {
|
||||
func Infof(format string, args ...any) {
|
||||
grpclog.Logger.Infof(format, args...)
|
||||
}
|
||||
|
||||
// Infoln logs to the INFO log. Arguments are handled in the manner of fmt.Println.
|
||||
func Infoln(args ...interface{}) {
|
||||
func Infoln(args ...any) {
|
||||
grpclog.Logger.Infoln(args...)
|
||||
}
|
||||
|
||||
// Warning logs to the WARNING log.
|
||||
func Warning(args ...interface{}) {
|
||||
func Warning(args ...any) {
|
||||
grpclog.Logger.Warning(args...)
|
||||
}
|
||||
|
||||
// Warningf logs to the WARNING log. Arguments are handled in the manner of fmt.Printf.
|
||||
func Warningf(format string, args ...interface{}) {
|
||||
func Warningf(format string, args ...any) {
|
||||
grpclog.Logger.Warningf(format, args...)
|
||||
}
|
||||
|
||||
// Warningln logs to the WARNING log. Arguments are handled in the manner of fmt.Println.
|
||||
func Warningln(args ...interface{}) {
|
||||
func Warningln(args ...any) {
|
||||
grpclog.Logger.Warningln(args...)
|
||||
}
|
||||
|
||||
// Error logs to the ERROR log.
|
||||
func Error(args ...interface{}) {
|
||||
func Error(args ...any) {
|
||||
grpclog.Logger.Error(args...)
|
||||
}
|
||||
|
||||
// Errorf logs to the ERROR log. Arguments are handled in the manner of fmt.Printf.
|
||||
func Errorf(format string, args ...interface{}) {
|
||||
func Errorf(format string, args ...any) {
|
||||
grpclog.Logger.Errorf(format, args...)
|
||||
}
|
||||
|
||||
// Errorln logs to the ERROR log. Arguments are handled in the manner of fmt.Println.
|
||||
func Errorln(args ...interface{}) {
|
||||
func Errorln(args ...any) {
|
||||
grpclog.Logger.Errorln(args...)
|
||||
}
|
||||
|
||||
// Fatal logs to the FATAL log. Arguments are handled in the manner of fmt.Print.
|
||||
// It calls os.Exit() with exit code 1.
|
||||
func Fatal(args ...interface{}) {
|
||||
func Fatal(args ...any) {
|
||||
grpclog.Logger.Fatal(args...)
|
||||
// Make sure fatal logs will exit.
|
||||
os.Exit(1)
|
||||
|
@ -96,7 +96,7 @@ func Fatal(args ...interface{}) {
|
|||
|
||||
// Fatalf logs to the FATAL log. Arguments are handled in the manner of fmt.Printf.
|
||||
// It calls os.Exit() with exit code 1.
|
||||
func Fatalf(format string, args ...interface{}) {
|
||||
func Fatalf(format string, args ...any) {
|
||||
grpclog.Logger.Fatalf(format, args...)
|
||||
// Make sure fatal logs will exit.
|
||||
os.Exit(1)
|
||||
|
@ -104,7 +104,7 @@ func Fatalf(format string, args ...interface{}) {
|
|||
|
||||
// Fatalln logs to the FATAL log. Arguments are handled in the manner of fmt.Println.
|
||||
// It calle os.Exit()) with exit code 1.
|
||||
func Fatalln(args ...interface{}) {
|
||||
func Fatalln(args ...any) {
|
||||
grpclog.Logger.Fatalln(args...)
|
||||
// Make sure fatal logs will exit.
|
||||
os.Exit(1)
|
||||
|
@ -113,20 +113,20 @@ func Fatalln(args ...interface{}) {
|
|||
// Print prints to the logger. Arguments are handled in the manner of fmt.Print.
|
||||
//
|
||||
// Deprecated: use Info.
|
||||
func Print(args ...interface{}) {
|
||||
func Print(args ...any) {
|
||||
grpclog.Logger.Info(args...)
|
||||
}
|
||||
|
||||
// Printf prints to the logger. Arguments are handled in the manner of fmt.Printf.
|
||||
//
|
||||
// Deprecated: use Infof.
|
||||
func Printf(format string, args ...interface{}) {
|
||||
func Printf(format string, args ...any) {
|
||||
grpclog.Logger.Infof(format, args...)
|
||||
}
|
||||
|
||||
// Println prints to the logger. Arguments are handled in the manner of fmt.Println.
|
||||
//
|
||||
// Deprecated: use Infoln.
|
||||
func Println(args ...interface{}) {
|
||||
func Println(args ...any) {
|
||||
grpclog.Logger.Infoln(args...)
|
||||
}
|
||||
|
|
|
@ -24,12 +24,12 @@ import "google.golang.org/grpc/internal/grpclog"
|
|||
//
|
||||
// Deprecated: use LoggerV2.
|
||||
type Logger interface {
|
||||
Fatal(args ...interface{})
|
||||
Fatalf(format string, args ...interface{})
|
||||
Fatalln(args ...interface{})
|
||||
Print(args ...interface{})
|
||||
Printf(format string, args ...interface{})
|
||||
Println(args ...interface{})
|
||||
Fatal(args ...any)
|
||||
Fatalf(format string, args ...any)
|
||||
Fatalln(args ...any)
|
||||
Print(args ...any)
|
||||
Printf(format string, args ...any)
|
||||
Println(args ...any)
|
||||
}
|
||||
|
||||
// SetLogger sets the logger that is used in grpc. Call only from
|
||||
|
@ -45,39 +45,39 @@ type loggerWrapper struct {
|
|||
Logger
|
||||
}
|
||||
|
||||
func (g *loggerWrapper) Info(args ...interface{}) {
|
||||
func (g *loggerWrapper) Info(args ...any) {
|
||||
g.Logger.Print(args...)
|
||||
}
|
||||
|
||||
func (g *loggerWrapper) Infoln(args ...interface{}) {
|
||||
func (g *loggerWrapper) Infoln(args ...any) {
|
||||
g.Logger.Println(args...)
|
||||
}
|
||||
|
||||
func (g *loggerWrapper) Infof(format string, args ...interface{}) {
|
||||
func (g *loggerWrapper) Infof(format string, args ...any) {
|
||||
g.Logger.Printf(format, args...)
|
||||
}
|
||||
|
||||
func (g *loggerWrapper) Warning(args ...interface{}) {
|
||||
func (g *loggerWrapper) Warning(args ...any) {
|
||||
g.Logger.Print(args...)
|
||||
}
|
||||
|
||||
func (g *loggerWrapper) Warningln(args ...interface{}) {
|
||||
func (g *loggerWrapper) Warningln(args ...any) {
|
||||
g.Logger.Println(args...)
|
||||
}
|
||||
|
||||
func (g *loggerWrapper) Warningf(format string, args ...interface{}) {
|
||||
func (g *loggerWrapper) Warningf(format string, args ...any) {
|
||||
g.Logger.Printf(format, args...)
|
||||
}
|
||||
|
||||
func (g *loggerWrapper) Error(args ...interface{}) {
|
||||
func (g *loggerWrapper) Error(args ...any) {
|
||||
g.Logger.Print(args...)
|
||||
}
|
||||
|
||||
func (g *loggerWrapper) Errorln(args ...interface{}) {
|
||||
func (g *loggerWrapper) Errorln(args ...any) {
|
||||
g.Logger.Println(args...)
|
||||
}
|
||||
|
||||
func (g *loggerWrapper) Errorf(format string, args ...interface{}) {
|
||||
func (g *loggerWrapper) Errorf(format string, args ...any) {
|
||||
g.Logger.Printf(format, args...)
|
||||
}
|
||||
|
||||
|
|
|
@ -33,35 +33,35 @@ import (
|
|||
// LoggerV2 does underlying logging work for grpclog.
|
||||
type LoggerV2 interface {
|
||||
// Info logs to INFO log. Arguments are handled in the manner of fmt.Print.
|
||||
Info(args ...interface{})
|
||||
Info(args ...any)
|
||||
// Infoln logs to INFO log. Arguments are handled in the manner of fmt.Println.
|
||||
Infoln(args ...interface{})
|
||||
Infoln(args ...any)
|
||||
// Infof logs to INFO log. Arguments are handled in the manner of fmt.Printf.
|
||||
Infof(format string, args ...interface{})
|
||||
Infof(format string, args ...any)
|
||||
// Warning logs to WARNING log. Arguments are handled in the manner of fmt.Print.
|
||||
Warning(args ...interface{})
|
||||
Warning(args ...any)
|
||||
// Warningln logs to WARNING log. Arguments are handled in the manner of fmt.Println.
|
||||
Warningln(args ...interface{})
|
||||
Warningln(args ...any)
|
||||
// Warningf logs to WARNING log. Arguments are handled in the manner of fmt.Printf.
|
||||
Warningf(format string, args ...interface{})
|
||||
Warningf(format string, args ...any)
|
||||
// Error logs to ERROR log. Arguments are handled in the manner of fmt.Print.
|
||||
Error(args ...interface{})
|
||||
Error(args ...any)
|
||||
// Errorln logs to ERROR log. Arguments are handled in the manner of fmt.Println.
|
||||
Errorln(args ...interface{})
|
||||
Errorln(args ...any)
|
||||
// Errorf logs to ERROR log. Arguments are handled in the manner of fmt.Printf.
|
||||
Errorf(format string, args ...interface{})
|
||||
Errorf(format string, args ...any)
|
||||
// Fatal logs to ERROR log. Arguments are handled in the manner of fmt.Print.
|
||||
// gRPC ensures that all Fatal logs will exit with os.Exit(1).
|
||||
// Implementations may also call os.Exit() with a non-zero exit code.
|
||||
Fatal(args ...interface{})
|
||||
Fatal(args ...any)
|
||||
// Fatalln logs to ERROR log. Arguments are handled in the manner of fmt.Println.
|
||||
// gRPC ensures that all Fatal logs will exit with os.Exit(1).
|
||||
// Implementations may also call os.Exit() with a non-zero exit code.
|
||||
Fatalln(args ...interface{})
|
||||
Fatalln(args ...any)
|
||||
// Fatalf logs to ERROR log. Arguments are handled in the manner of fmt.Printf.
|
||||
// gRPC ensures that all Fatal logs will exit with os.Exit(1).
|
||||
// Implementations may also call os.Exit() with a non-zero exit code.
|
||||
Fatalf(format string, args ...interface{})
|
||||
Fatalf(format string, args ...any)
|
||||
// V reports whether verbosity level l is at least the requested verbose level.
|
||||
V(l int) bool
|
||||
}
|
||||
|
@ -182,53 +182,53 @@ func (g *loggerT) output(severity int, s string) {
|
|||
g.m[severity].Output(2, string(b))
|
||||
}
|
||||
|
||||
func (g *loggerT) Info(args ...interface{}) {
|
||||
func (g *loggerT) Info(args ...any) {
|
||||
g.output(infoLog, fmt.Sprint(args...))
|
||||
}
|
||||
|
||||
func (g *loggerT) Infoln(args ...interface{}) {
|
||||
func (g *loggerT) Infoln(args ...any) {
|
||||
g.output(infoLog, fmt.Sprintln(args...))
|
||||
}
|
||||
|
||||
func (g *loggerT) Infof(format string, args ...interface{}) {
|
||||
func (g *loggerT) Infof(format string, args ...any) {
|
||||
g.output(infoLog, fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
func (g *loggerT) Warning(args ...interface{}) {
|
||||
func (g *loggerT) Warning(args ...any) {
|
||||
g.output(warningLog, fmt.Sprint(args...))
|
||||
}
|
||||
|
||||
func (g *loggerT) Warningln(args ...interface{}) {
|
||||
func (g *loggerT) Warningln(args ...any) {
|
||||
g.output(warningLog, fmt.Sprintln(args...))
|
||||
}
|
||||
|
||||
func (g *loggerT) Warningf(format string, args ...interface{}) {
|
||||
func (g *loggerT) Warningf(format string, args ...any) {
|
||||
g.output(warningLog, fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
func (g *loggerT) Error(args ...interface{}) {
|
||||
func (g *loggerT) Error(args ...any) {
|
||||
g.output(errorLog, fmt.Sprint(args...))
|
||||
}
|
||||
|
||||
func (g *loggerT) Errorln(args ...interface{}) {
|
||||
func (g *loggerT) Errorln(args ...any) {
|
||||
g.output(errorLog, fmt.Sprintln(args...))
|
||||
}
|
||||
|
||||
func (g *loggerT) Errorf(format string, args ...interface{}) {
|
||||
func (g *loggerT) Errorf(format string, args ...any) {
|
||||
g.output(errorLog, fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
func (g *loggerT) Fatal(args ...interface{}) {
|
||||
func (g *loggerT) Fatal(args ...any) {
|
||||
g.output(fatalLog, fmt.Sprint(args...))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func (g *loggerT) Fatalln(args ...interface{}) {
|
||||
func (g *loggerT) Fatalln(args ...any) {
|
||||
g.output(fatalLog, fmt.Sprintln(args...))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func (g *loggerT) Fatalf(format string, args ...interface{}) {
|
||||
func (g *loggerT) Fatalf(format string, args ...any) {
|
||||
g.output(fatalLog, fmt.Sprintf(format, args...))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
@ -248,11 +248,11 @@ func (g *loggerT) V(l int) bool {
|
|||
type DepthLoggerV2 interface {
|
||||
LoggerV2
|
||||
// InfoDepth logs to INFO log at the specified depth. Arguments are handled in the manner of fmt.Println.
|
||||
InfoDepth(depth int, args ...interface{})
|
||||
InfoDepth(depth int, args ...any)
|
||||
// WarningDepth logs to WARNING log at the specified depth. Arguments are handled in the manner of fmt.Println.
|
||||
WarningDepth(depth int, args ...interface{})
|
||||
WarningDepth(depth int, args ...any)
|
||||
// ErrorDepth logs to ERROR log at the specified depth. Arguments are handled in the manner of fmt.Println.
|
||||
ErrorDepth(depth int, args ...interface{})
|
||||
ErrorDepth(depth int, args ...any)
|
||||
// FatalDepth logs to FATAL log at the specified depth. Arguments are handled in the manner of fmt.Println.
|
||||
FatalDepth(depth int, args ...interface{})
|
||||
FatalDepth(depth int, args ...any)
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ const healthCheckMethod = "/grpc.health.v1.Health/Watch"
|
|||
|
||||
// This function implements the protocol defined at:
|
||||
// https://github.com/grpc/grpc/blob/master/doc/health-checking.md
|
||||
func clientHealthCheck(ctx context.Context, newStream func(string) (interface{}, error), setConnectivityState func(connectivity.State, error), service string) error {
|
||||
func clientHealthCheck(ctx context.Context, newStream func(string) (any, error), setConnectivityState func(connectivity.State, error), service string) error {
|
||||
tryCnt := 0
|
||||
|
||||
retryConnection:
|
||||
|
|
|
@ -39,7 +39,7 @@ func (s) TestClientHealthCheckBackoff(t *testing.T) {
|
|||
}
|
||||
|
||||
var got []time.Duration
|
||||
newStream := func(string) (interface{}, error) {
|
||||
newStream := func(string) (any, error) {
|
||||
if len(got) < maxRetries {
|
||||
return nil, errors.New("backoff")
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
)
|
||||
|
||||
// UnaryInvoker is called by UnaryClientInterceptor to complete RPCs.
|
||||
type UnaryInvoker func(ctx context.Context, method string, req, reply interface{}, cc *ClientConn, opts ...CallOption) error
|
||||
type UnaryInvoker func(ctx context.Context, method string, req, reply any, cc *ClientConn, opts ...CallOption) error
|
||||
|
||||
// UnaryClientInterceptor intercepts the execution of a unary RPC on the client.
|
||||
// Unary interceptors can be specified as a DialOption, using
|
||||
|
@ -40,7 +40,7 @@ type UnaryInvoker func(ctx context.Context, method string, req, reply interface{
|
|||
// defaults from the ClientConn as well as per-call options.
|
||||
//
|
||||
// The returned error must be compatible with the status package.
|
||||
type UnaryClientInterceptor func(ctx context.Context, method string, req, reply interface{}, cc *ClientConn, invoker UnaryInvoker, opts ...CallOption) error
|
||||
type UnaryClientInterceptor func(ctx context.Context, method string, req, reply any, cc *ClientConn, invoker UnaryInvoker, opts ...CallOption) error
|
||||
|
||||
// Streamer is called by StreamClientInterceptor to create a ClientStream.
|
||||
type Streamer func(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, opts ...CallOption) (ClientStream, error)
|
||||
|
@ -66,7 +66,7 @@ type StreamClientInterceptor func(ctx context.Context, desc *StreamDesc, cc *Cli
|
|||
// server side. All per-rpc information may be mutated by the interceptor.
|
||||
type UnaryServerInfo struct {
|
||||
// Server is the service implementation the user provides. This is read-only.
|
||||
Server interface{}
|
||||
Server any
|
||||
// FullMethod is the full RPC method string, i.e., /package.service/method.
|
||||
FullMethod string
|
||||
}
|
||||
|
@ -78,13 +78,13 @@ type UnaryServerInfo struct {
|
|||
// status package, or be one of the context errors. Otherwise, gRPC will use
|
||||
// codes.Unknown as the status code and err.Error() as the status message of the
|
||||
// RPC.
|
||||
type UnaryHandler func(ctx context.Context, req interface{}) (interface{}, error)
|
||||
type UnaryHandler func(ctx context.Context, req any) (any, error)
|
||||
|
||||
// UnaryServerInterceptor provides a hook to intercept the execution of a unary RPC on the server. info
|
||||
// contains all the information of this RPC the interceptor can operate on. And handler is the wrapper
|
||||
// of the service method implementation. It is the responsibility of the interceptor to invoke handler
|
||||
// to complete the RPC.
|
||||
type UnaryServerInterceptor func(ctx context.Context, req interface{}, info *UnaryServerInfo, handler UnaryHandler) (resp interface{}, err error)
|
||||
type UnaryServerInterceptor func(ctx context.Context, req any, info *UnaryServerInfo, handler UnaryHandler) (resp any, err error)
|
||||
|
||||
// StreamServerInfo consists of various information about a streaming RPC on
|
||||
// server side. All per-rpc information may be mutated by the interceptor.
|
||||
|
@ -101,4 +101,4 @@ type StreamServerInfo struct {
|
|||
// info contains all the information of this RPC the interceptor can operate on. And handler is the
|
||||
// service method implementation. It is the responsibility of the interceptor to invoke handler to
|
||||
// complete the RPC.
|
||||
type StreamServerInterceptor func(srv interface{}, ss ServerStream, info *StreamServerInfo, handler StreamHandler) error
|
||||
type StreamServerInterceptor func(srv any, ss ServerStream, info *StreamServerInfo, handler StreamHandler) error
|
||||
|
|
|
@ -50,7 +50,7 @@ type BalancerData struct {
|
|||
// BuildOptions is set by the builder.
|
||||
BuildOptions balancer.BuildOptions
|
||||
// Data may be used to store arbitrary user data.
|
||||
Data interface{}
|
||||
Data any
|
||||
}
|
||||
|
||||
type bal struct {
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
// Parser converts loads from metadata into a concrete type.
|
||||
type Parser interface {
|
||||
// Parse parses loads from metadata.
|
||||
Parse(md metadata.MD) interface{}
|
||||
Parse(md metadata.MD) any
|
||||
}
|
||||
|
||||
var parser Parser
|
||||
|
@ -38,7 +38,7 @@ func SetParser(lr Parser) {
|
|||
}
|
||||
|
||||
// Parse calls parser.Read().
|
||||
func Parse(md metadata.MD) interface{} {
|
||||
func Parse(md metadata.MD) any {
|
||||
if parser == nil {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -230,7 +230,7 @@ type ClientMessage struct {
|
|||
OnClientSide bool
|
||||
// Message can be a proto.Message or []byte. Other messages formats are not
|
||||
// supported.
|
||||
Message interface{}
|
||||
Message any
|
||||
}
|
||||
|
||||
func (c *ClientMessage) toProto() *binlogpb.GrpcLogEntry {
|
||||
|
@ -270,7 +270,7 @@ type ServerMessage struct {
|
|||
OnClientSide bool
|
||||
// Message can be a proto.Message or []byte. Other messages formats are not
|
||||
// supported.
|
||||
Message interface{}
|
||||
Message any
|
||||
}
|
||||
|
||||
func (c *ServerMessage) toProto() *binlogpb.GrpcLogEntry {
|
||||
|
|
|
@ -28,25 +28,25 @@ import "sync"
|
|||
// the underlying mutex used for synchronization.
|
||||
//
|
||||
// Unbounded supports values of any type to be stored in it by using a channel
|
||||
// of `interface{}`. This means that a call to Put() incurs an extra memory
|
||||
// allocation, and also that users need a type assertion while reading. For
|
||||
// performance critical code paths, using Unbounded is strongly discouraged and
|
||||
// defining a new type specific implementation of this buffer is preferred. See
|
||||
// of `any`. This means that a call to Put() incurs an extra memory allocation,
|
||||
// and also that users need a type assertion while reading. For performance
|
||||
// critical code paths, using Unbounded is strongly discouraged and defining a
|
||||
// new type specific implementation of this buffer is preferred. See
|
||||
// internal/transport/transport.go for an example of this.
|
||||
type Unbounded struct {
|
||||
c chan interface{}
|
||||
c chan any
|
||||
closed bool
|
||||
mu sync.Mutex
|
||||
backlog []interface{}
|
||||
backlog []any
|
||||
}
|
||||
|
||||
// NewUnbounded returns a new instance of Unbounded.
|
||||
func NewUnbounded() *Unbounded {
|
||||
return &Unbounded{c: make(chan interface{}, 1)}
|
||||
return &Unbounded{c: make(chan any, 1)}
|
||||
}
|
||||
|
||||
// Put adds t to the unbounded buffer.
|
||||
func (b *Unbounded) Put(t interface{}) {
|
||||
func (b *Unbounded) Put(t any) {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
if b.closed {
|
||||
|
@ -89,7 +89,7 @@ func (b *Unbounded) Load() {
|
|||
//
|
||||
// If the unbounded buffer is closed, the read channel returned by this method
|
||||
// is closed.
|
||||
func (b *Unbounded) Get() <-chan interface{} {
|
||||
func (b *Unbounded) Get() <-chan any {
|
||||
return b.c
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
)
|
||||
|
||||
type cacheEntry struct {
|
||||
item interface{}
|
||||
item any
|
||||
// Note that to avoid deadlocks (potentially caused by lock ordering),
|
||||
// callback can only be called without holding cache's mutex.
|
||||
callback func()
|
||||
|
@ -38,14 +38,14 @@ type cacheEntry struct {
|
|||
type TimeoutCache struct {
|
||||
mu sync.Mutex
|
||||
timeout time.Duration
|
||||
cache map[interface{}]*cacheEntry
|
||||
cache map[any]*cacheEntry
|
||||
}
|
||||
|
||||
// NewTimeoutCache creates a TimeoutCache with the given timeout.
|
||||
func NewTimeoutCache(timeout time.Duration) *TimeoutCache {
|
||||
return &TimeoutCache{
|
||||
timeout: timeout,
|
||||
cache: make(map[interface{}]*cacheEntry),
|
||||
cache: make(map[any]*cacheEntry),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ func NewTimeoutCache(timeout time.Duration) *TimeoutCache {
|
|||
// If the Add was successful, it returns (newly added item, true). If there is
|
||||
// an existing entry for the specified key, the cache entry is not be updated
|
||||
// with the specified item and it returns (existing item, false).
|
||||
func (c *TimeoutCache) Add(key, item interface{}, callback func()) (interface{}, bool) {
|
||||
func (c *TimeoutCache) Add(key, item any, callback func()) (any, bool) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
if e, ok := c.cache[key]; ok {
|
||||
|
@ -88,7 +88,7 @@ func (c *TimeoutCache) Add(key, item interface{}, callback func()) (interface{},
|
|||
// If the specified key exists in the cache, it returns (item associated with
|
||||
// key, true) and the callback associated with the item is guaranteed to be not
|
||||
// called. If the given key is not found in the cache, it returns (nil, false)
|
||||
func (c *TimeoutCache) Remove(key interface{}) (item interface{}, ok bool) {
|
||||
func (c *TimeoutCache) Remove(key any) (item any, ok bool) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
entry, ok := c.removeInternal(key)
|
||||
|
@ -101,7 +101,7 @@ func (c *TimeoutCache) Remove(key interface{}) (item interface{}, ok bool) {
|
|||
// removeInternal removes and returns the item with key.
|
||||
//
|
||||
// caller must hold c.mu.
|
||||
func (c *TimeoutCache) removeInternal(key interface{}) (*cacheEntry, bool) {
|
||||
func (c *TimeoutCache) removeInternal(key any) (*cacheEntry, bool) {
|
||||
entry, ok := c.cache[key]
|
||||
if !ok {
|
||||
return nil, false
|
||||
|
|
|
@ -38,7 +38,7 @@ func Test(t *testing.T) {
|
|||
grpctest.RunSubTests(t, s{})
|
||||
}
|
||||
|
||||
func (c *TimeoutCache) getForTesting(key interface{}) (*cacheEntry, bool) {
|
||||
func (c *TimeoutCache) getForTesting(key any) (*cacheEntry, bool) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
r, ok := c.cache[key]
|
||||
|
|
|
@ -31,7 +31,7 @@ func withParens(id *Identifier) string {
|
|||
}
|
||||
|
||||
// Info logs and adds a trace event if channelz is on.
|
||||
func Info(l grpclog.DepthLoggerV2, id *Identifier, args ...interface{}) {
|
||||
func Info(l grpclog.DepthLoggerV2, id *Identifier, args ...any) {
|
||||
AddTraceEvent(l, id, 1, &TraceEventDesc{
|
||||
Desc: fmt.Sprint(args...),
|
||||
Severity: CtInfo,
|
||||
|
@ -39,7 +39,7 @@ func Info(l grpclog.DepthLoggerV2, id *Identifier, args ...interface{}) {
|
|||
}
|
||||
|
||||
// Infof logs and adds a trace event if channelz is on.
|
||||
func Infof(l grpclog.DepthLoggerV2, id *Identifier, format string, args ...interface{}) {
|
||||
func Infof(l grpclog.DepthLoggerV2, id *Identifier, format string, args ...any) {
|
||||
AddTraceEvent(l, id, 1, &TraceEventDesc{
|
||||
Desc: fmt.Sprintf(format, args...),
|
||||
Severity: CtInfo,
|
||||
|
@ -47,7 +47,7 @@ func Infof(l grpclog.DepthLoggerV2, id *Identifier, format string, args ...inter
|
|||
}
|
||||
|
||||
// Warning logs and adds a trace event if channelz is on.
|
||||
func Warning(l grpclog.DepthLoggerV2, id *Identifier, args ...interface{}) {
|
||||
func Warning(l grpclog.DepthLoggerV2, id *Identifier, args ...any) {
|
||||
AddTraceEvent(l, id, 1, &TraceEventDesc{
|
||||
Desc: fmt.Sprint(args...),
|
||||
Severity: CtWarning,
|
||||
|
@ -55,7 +55,7 @@ func Warning(l grpclog.DepthLoggerV2, id *Identifier, args ...interface{}) {
|
|||
}
|
||||
|
||||
// Warningf logs and adds a trace event if channelz is on.
|
||||
func Warningf(l grpclog.DepthLoggerV2, id *Identifier, format string, args ...interface{}) {
|
||||
func Warningf(l grpclog.DepthLoggerV2, id *Identifier, format string, args ...any) {
|
||||
AddTraceEvent(l, id, 1, &TraceEventDesc{
|
||||
Desc: fmt.Sprintf(format, args...),
|
||||
Severity: CtWarning,
|
||||
|
@ -63,7 +63,7 @@ func Warningf(l grpclog.DepthLoggerV2, id *Identifier, format string, args ...in
|
|||
}
|
||||
|
||||
// Error logs and adds a trace event if channelz is on.
|
||||
func Error(l grpclog.DepthLoggerV2, id *Identifier, args ...interface{}) {
|
||||
func Error(l grpclog.DepthLoggerV2, id *Identifier, args ...any) {
|
||||
AddTraceEvent(l, id, 1, &TraceEventDesc{
|
||||
Desc: fmt.Sprint(args...),
|
||||
Severity: CtError,
|
||||
|
@ -71,7 +71,7 @@ func Error(l grpclog.DepthLoggerV2, id *Identifier, args ...interface{}) {
|
|||
}
|
||||
|
||||
// Errorf logs and adds a trace event if channelz is on.
|
||||
func Errorf(l grpclog.DepthLoggerV2, id *Identifier, format string, args ...interface{}) {
|
||||
func Errorf(l grpclog.DepthLoggerV2, id *Identifier, format string, args ...any) {
|
||||
AddTraceEvent(l, id, 1, &TraceEventDesc{
|
||||
Desc: fmt.Sprintf(format, args...),
|
||||
Severity: CtError,
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
)
|
||||
|
||||
// GetSocketOption gets the socket option info of the conn.
|
||||
func GetSocketOption(socket interface{}) *SocketOptionData {
|
||||
func GetSocketOption(socket any) *SocketOptionData {
|
||||
c, ok := socket.(syscall.Conn)
|
||||
if !ok {
|
||||
return nil
|
||||
|
|
|
@ -22,6 +22,6 @@
|
|||
package channelz
|
||||
|
||||
// GetSocketOption gets the socket option info of the conn.
|
||||
func GetSocketOption(c interface{}) *SocketOptionData {
|
||||
func GetSocketOption(c any) *SocketOptionData {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -25,12 +25,12 @@ import (
|
|||
type requestInfoKey struct{}
|
||||
|
||||
// NewRequestInfoContext creates a context with ri.
|
||||
func NewRequestInfoContext(ctx context.Context, ri interface{}) context.Context {
|
||||
func NewRequestInfoContext(ctx context.Context, ri any) context.Context {
|
||||
return context.WithValue(ctx, requestInfoKey{}, ri)
|
||||
}
|
||||
|
||||
// RequestInfoFromContext extracts the RequestInfo from ctx.
|
||||
func RequestInfoFromContext(ctx context.Context) interface{} {
|
||||
func RequestInfoFromContext(ctx context.Context) any {
|
||||
return ctx.Value(requestInfoKey{})
|
||||
}
|
||||
|
||||
|
@ -39,11 +39,11 @@ func RequestInfoFromContext(ctx context.Context) interface{} {
|
|||
type clientHandshakeInfoKey struct{}
|
||||
|
||||
// ClientHandshakeInfoFromContext extracts the ClientHandshakeInfo from ctx.
|
||||
func ClientHandshakeInfoFromContext(ctx context.Context) interface{} {
|
||||
func ClientHandshakeInfoFromContext(ctx context.Context) any {
|
||||
return ctx.Value(clientHandshakeInfoKey{})
|
||||
}
|
||||
|
||||
// NewClientHandshakeInfoContext creates a context with chi.
|
||||
func NewClientHandshakeInfoContext(ctx context.Context, chi interface{}) context.Context {
|
||||
func NewClientHandshakeInfoContext(ctx context.Context, chi any) context.Context {
|
||||
return context.WithValue(ctx, clientHandshakeInfoKey{}, chi)
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ type handshakeAttrKey struct{}
|
|||
// Equal reports whether the handshake info structs are identical (have the
|
||||
// same pointer). This is sufficient as all subconns from one CDS balancer use
|
||||
// the same one.
|
||||
func (hi *HandshakeInfo) Equal(o interface{}) bool {
|
||||
func (hi *HandshakeInfo) Equal(o any) bool {
|
||||
oh, ok := o.(*HandshakeInfo)
|
||||
return ok && oh == hi
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ var Logger LoggerV2
|
|||
var DepthLogger DepthLoggerV2
|
||||
|
||||
// InfoDepth logs to the INFO log at the specified depth.
|
||||
func InfoDepth(depth int, args ...interface{}) {
|
||||
func InfoDepth(depth int, args ...any) {
|
||||
if DepthLogger != nil {
|
||||
DepthLogger.InfoDepth(depth, args...)
|
||||
} else {
|
||||
|
@ -39,7 +39,7 @@ func InfoDepth(depth int, args ...interface{}) {
|
|||
}
|
||||
|
||||
// WarningDepth logs to the WARNING log at the specified depth.
|
||||
func WarningDepth(depth int, args ...interface{}) {
|
||||
func WarningDepth(depth int, args ...any) {
|
||||
if DepthLogger != nil {
|
||||
DepthLogger.WarningDepth(depth, args...)
|
||||
} else {
|
||||
|
@ -48,7 +48,7 @@ func WarningDepth(depth int, args ...interface{}) {
|
|||
}
|
||||
|
||||
// ErrorDepth logs to the ERROR log at the specified depth.
|
||||
func ErrorDepth(depth int, args ...interface{}) {
|
||||
func ErrorDepth(depth int, args ...any) {
|
||||
if DepthLogger != nil {
|
||||
DepthLogger.ErrorDepth(depth, args...)
|
||||
} else {
|
||||
|
@ -57,7 +57,7 @@ func ErrorDepth(depth int, args ...interface{}) {
|
|||
}
|
||||
|
||||
// FatalDepth logs to the FATAL log at the specified depth.
|
||||
func FatalDepth(depth int, args ...interface{}) {
|
||||
func FatalDepth(depth int, args ...any) {
|
||||
if DepthLogger != nil {
|
||||
DepthLogger.FatalDepth(depth, args...)
|
||||
} else {
|
||||
|
@ -71,35 +71,35 @@ func FatalDepth(depth int, args ...interface{}) {
|
|||
// is defined here to avoid a circular dependency.
|
||||
type LoggerV2 interface {
|
||||
// Info logs to INFO log. Arguments are handled in the manner of fmt.Print.
|
||||
Info(args ...interface{})
|
||||
Info(args ...any)
|
||||
// Infoln logs to INFO log. Arguments are handled in the manner of fmt.Println.
|
||||
Infoln(args ...interface{})
|
||||
Infoln(args ...any)
|
||||
// Infof logs to INFO log. Arguments are handled in the manner of fmt.Printf.
|
||||
Infof(format string, args ...interface{})
|
||||
Infof(format string, args ...any)
|
||||
// Warning logs to WARNING log. Arguments are handled in the manner of fmt.Print.
|
||||
Warning(args ...interface{})
|
||||
Warning(args ...any)
|
||||
// Warningln logs to WARNING log. Arguments are handled in the manner of fmt.Println.
|
||||
Warningln(args ...interface{})
|
||||
Warningln(args ...any)
|
||||
// Warningf logs to WARNING log. Arguments are handled in the manner of fmt.Printf.
|
||||
Warningf(format string, args ...interface{})
|
||||
Warningf(format string, args ...any)
|
||||
// Error logs to ERROR log. Arguments are handled in the manner of fmt.Print.
|
||||
Error(args ...interface{})
|
||||
Error(args ...any)
|
||||
// Errorln logs to ERROR log. Arguments are handled in the manner of fmt.Println.
|
||||
Errorln(args ...interface{})
|
||||
Errorln(args ...any)
|
||||
// Errorf logs to ERROR log. Arguments are handled in the manner of fmt.Printf.
|
||||
Errorf(format string, args ...interface{})
|
||||
Errorf(format string, args ...any)
|
||||
// Fatal logs to ERROR log. Arguments are handled in the manner of fmt.Print.
|
||||
// gRPC ensures that all Fatal logs will exit with os.Exit(1).
|
||||
// Implementations may also call os.Exit() with a non-zero exit code.
|
||||
Fatal(args ...interface{})
|
||||
Fatal(args ...any)
|
||||
// Fatalln logs to ERROR log. Arguments are handled in the manner of fmt.Println.
|
||||
// gRPC ensures that all Fatal logs will exit with os.Exit(1).
|
||||
// Implementations may also call os.Exit() with a non-zero exit code.
|
||||
Fatalln(args ...interface{})
|
||||
Fatalln(args ...any)
|
||||
// Fatalf logs to ERROR log. Arguments are handled in the manner of fmt.Printf.
|
||||
// gRPC ensures that all Fatal logs will exit with os.Exit(1).
|
||||
// Implementations may also call os.Exit() with a non-zero exit code.
|
||||
Fatalf(format string, args ...interface{})
|
||||
Fatalf(format string, args ...any)
|
||||
// V reports whether verbosity level l is at least the requested verbose level.
|
||||
V(l int) bool
|
||||
}
|
||||
|
@ -116,11 +116,11 @@ type LoggerV2 interface {
|
|||
// later release.
|
||||
type DepthLoggerV2 interface {
|
||||
// InfoDepth logs to INFO log at the specified depth. Arguments are handled in the manner of fmt.Println.
|
||||
InfoDepth(depth int, args ...interface{})
|
||||
InfoDepth(depth int, args ...any)
|
||||
// WarningDepth logs to WARNING log at the specified depth. Arguments are handled in the manner of fmt.Println.
|
||||
WarningDepth(depth int, args ...interface{})
|
||||
WarningDepth(depth int, args ...any)
|
||||
// ErrorDepth logs to ERROR log at the specified depth. Arguments are handled in the manner of fmt.Println.
|
||||
ErrorDepth(depth int, args ...interface{})
|
||||
ErrorDepth(depth int, args ...any)
|
||||
// FatalDepth logs to FATAL log at the specified depth. Arguments are handled in the manner of fmt.Println.
|
||||
FatalDepth(depth int, args ...interface{})
|
||||
FatalDepth(depth int, args ...any)
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ type PrefixLogger struct {
|
|||
}
|
||||
|
||||
// Infof does info logging.
|
||||
func (pl *PrefixLogger) Infof(format string, args ...interface{}) {
|
||||
func (pl *PrefixLogger) Infof(format string, args ...any) {
|
||||
if pl != nil {
|
||||
// Handle nil, so the tests can pass in a nil logger.
|
||||
format = pl.prefix + format
|
||||
|
@ -42,7 +42,7 @@ func (pl *PrefixLogger) Infof(format string, args ...interface{}) {
|
|||
}
|
||||
|
||||
// Warningf does warning logging.
|
||||
func (pl *PrefixLogger) Warningf(format string, args ...interface{}) {
|
||||
func (pl *PrefixLogger) Warningf(format string, args ...any) {
|
||||
if pl != nil {
|
||||
format = pl.prefix + format
|
||||
pl.logger.WarningDepth(1, fmt.Sprintf(format, args...))
|
||||
|
@ -52,7 +52,7 @@ func (pl *PrefixLogger) Warningf(format string, args ...interface{}) {
|
|||
}
|
||||
|
||||
// Errorf does error logging.
|
||||
func (pl *PrefixLogger) Errorf(format string, args ...interface{}) {
|
||||
func (pl *PrefixLogger) Errorf(format string, args ...any) {
|
||||
if pl != nil {
|
||||
format = pl.prefix + format
|
||||
pl.logger.ErrorDepth(1, fmt.Sprintf(format, args...))
|
||||
|
@ -62,7 +62,7 @@ func (pl *PrefixLogger) Errorf(format string, args ...interface{}) {
|
|||
}
|
||||
|
||||
// Debugf does info logging at verbose level 2.
|
||||
func (pl *PrefixLogger) Debugf(format string, args ...interface{}) {
|
||||
func (pl *PrefixLogger) Debugf(format string, args ...any) {
|
||||
// TODO(6044): Refactor interfaces LoggerV2 and DepthLogger, and maybe
|
||||
// rewrite PrefixLogger a little to ensure that we don't use the global
|
||||
// `Logger` here, and instead use the `logger` field.
|
||||
|
|
|
@ -29,7 +29,7 @@ import (
|
|||
type Subscriber interface {
|
||||
// OnMessage is invoked when a new message is published. Implementations
|
||||
// must not block in this method.
|
||||
OnMessage(msg interface{})
|
||||
OnMessage(msg any)
|
||||
}
|
||||
|
||||
// PubSub is a simple one-to-many publish-subscribe system that supports
|
||||
|
@ -48,7 +48,7 @@ type PubSub struct {
|
|||
|
||||
// Access to the below fields are guarded by this mutex.
|
||||
mu sync.Mutex
|
||||
msg interface{}
|
||||
msg any
|
||||
subscribers map[Subscriber]bool
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ func (ps *PubSub) Subscribe(sub Subscriber) (cancel func()) {
|
|||
|
||||
// Publish publishes the provided message to the PubSub, and invokes
|
||||
// callbacks registered by subscribers asynchronously.
|
||||
func (ps *PubSub) Publish(msg interface{}) {
|
||||
func (ps *PubSub) Publish(msg any) {
|
||||
ps.mu.Lock()
|
||||
defer ps.mu.Unlock()
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ func newTestSubscriber(chSize int) *testSubscriber {
|
|||
return &testSubscriber{onMsgCh: make(chan int, chSize)}
|
||||
}
|
||||
|
||||
func (ts *testSubscriber) OnMessage(msg interface{}) {
|
||||
func (ts *testSubscriber) OnMessage(msg any) {
|
||||
select {
|
||||
case ts.onMsgCh <- msg.(int):
|
||||
default:
|
||||
|
|
|
@ -34,7 +34,7 @@ type errorer struct {
|
|||
t *testing.T
|
||||
}
|
||||
|
||||
func (e errorer) Errorf(format string, args ...interface{}) {
|
||||
func (e errorer) Errorf(format string, args ...any) {
|
||||
atomic.StoreUint32(&lcFailed, 1)
|
||||
e.t.Errorf(format, args...)
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ func getTestFunc(t *testing.T, xv reflect.Value, name string) func(*testing.T) {
|
|||
// To run a specific test/subtest:
|
||||
//
|
||||
// $ go test -v -run 'TestExample/^Something$' .
|
||||
func RunSubTests(t *testing.T, x interface{}) {
|
||||
func RunSubTests(t *testing.T, x any) {
|
||||
xt := reflect.TypeOf(x)
|
||||
xv := reflect.ValueOf(x)
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ func getCallingPrefix(depth int) (string, error) {
|
|||
}
|
||||
|
||||
// log logs the message with the specified parameters to the tLogger.
|
||||
func (g *tLogger) log(ltype logType, depth int, format string, args ...interface{}) {
|
||||
func (g *tLogger) log(ltype logType, depth int, format string, args ...any) {
|
||||
g.mu.Lock()
|
||||
defer g.mu.Unlock()
|
||||
prefix, err := getCallingPrefix(callingFrame + depth)
|
||||
|
@ -98,7 +98,7 @@ func (g *tLogger) log(ltype logType, depth int, format string, args ...interface
|
|||
g.t.Error(err)
|
||||
return
|
||||
}
|
||||
args = append([]interface{}{ltype.String() + " " + prefix}, args...)
|
||||
args = append([]any{ltype.String() + " " + prefix}, args...)
|
||||
args = append(args, fmt.Sprintf(" (t=+%s)", time.Since(g.start)))
|
||||
|
||||
if format == "" {
|
||||
|
@ -194,67 +194,67 @@ func (g *tLogger) expected(s string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (g *tLogger) Info(args ...interface{}) {
|
||||
func (g *tLogger) Info(args ...any) {
|
||||
g.log(infoLog, 0, "", args...)
|
||||
}
|
||||
|
||||
func (g *tLogger) Infoln(args ...interface{}) {
|
||||
func (g *tLogger) Infoln(args ...any) {
|
||||
g.log(infoLog, 0, "", args...)
|
||||
}
|
||||
|
||||
func (g *tLogger) Infof(format string, args ...interface{}) {
|
||||
func (g *tLogger) Infof(format string, args ...any) {
|
||||
g.log(infoLog, 0, format, args...)
|
||||
}
|
||||
|
||||
func (g *tLogger) InfoDepth(depth int, args ...interface{}) {
|
||||
func (g *tLogger) InfoDepth(depth int, args ...any) {
|
||||
g.log(infoLog, depth, "", args...)
|
||||
}
|
||||
|
||||
func (g *tLogger) Warning(args ...interface{}) {
|
||||
func (g *tLogger) Warning(args ...any) {
|
||||
g.log(warningLog, 0, "", args...)
|
||||
}
|
||||
|
||||
func (g *tLogger) Warningln(args ...interface{}) {
|
||||
func (g *tLogger) Warningln(args ...any) {
|
||||
g.log(warningLog, 0, "", args...)
|
||||
}
|
||||
|
||||
func (g *tLogger) Warningf(format string, args ...interface{}) {
|
||||
func (g *tLogger) Warningf(format string, args ...any) {
|
||||
g.log(warningLog, 0, format, args...)
|
||||
}
|
||||
|
||||
func (g *tLogger) WarningDepth(depth int, args ...interface{}) {
|
||||
func (g *tLogger) WarningDepth(depth int, args ...any) {
|
||||
g.log(warningLog, depth, "", args...)
|
||||
}
|
||||
|
||||
func (g *tLogger) Error(args ...interface{}) {
|
||||
func (g *tLogger) Error(args ...any) {
|
||||
g.log(errorLog, 0, "", args...)
|
||||
}
|
||||
|
||||
func (g *tLogger) Errorln(args ...interface{}) {
|
||||
func (g *tLogger) Errorln(args ...any) {
|
||||
g.log(errorLog, 0, "", args...)
|
||||
}
|
||||
|
||||
func (g *tLogger) Errorf(format string, args ...interface{}) {
|
||||
func (g *tLogger) Errorf(format string, args ...any) {
|
||||
g.log(errorLog, 0, format, args...)
|
||||
}
|
||||
|
||||
func (g *tLogger) ErrorDepth(depth int, args ...interface{}) {
|
||||
func (g *tLogger) ErrorDepth(depth int, args ...any) {
|
||||
g.log(errorLog, depth, "", args...)
|
||||
}
|
||||
|
||||
func (g *tLogger) Fatal(args ...interface{}) {
|
||||
func (g *tLogger) Fatal(args ...any) {
|
||||
g.log(fatalLog, 0, "", args...)
|
||||
}
|
||||
|
||||
func (g *tLogger) Fatalln(args ...interface{}) {
|
||||
func (g *tLogger) Fatalln(args ...any) {
|
||||
g.log(fatalLog, 0, "", args...)
|
||||
}
|
||||
|
||||
func (g *tLogger) Fatalf(format string, args ...interface{}) {
|
||||
func (g *tLogger) Fatalf(format string, args ...any) {
|
||||
g.log(fatalLog, 0, format, args...)
|
||||
}
|
||||
|
||||
func (g *tLogger) FatalDepth(depth int, args ...interface{}) {
|
||||
func (g *tLogger) FatalDepth(depth int, args ...any) {
|
||||
g.log(fatalLog, depth, "", args...)
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ const pathKey = pathKeyType("grpc.internal.address.hierarchical_path")
|
|||
|
||||
type pathValue []string
|
||||
|
||||
func (p pathValue) Equal(o interface{}) bool {
|
||||
func (p pathValue) Equal(o any) bool {
|
||||
op, ok := o.(pathValue)
|
||||
if !ok {
|
||||
return false
|
||||
|
|
|
@ -30,7 +30,7 @@ import (
|
|||
|
||||
var (
|
||||
// WithHealthCheckFunc is set by dialoptions.go
|
||||
WithHealthCheckFunc interface{} // func (HealthChecker) DialOption
|
||||
WithHealthCheckFunc any // func (HealthChecker) DialOption
|
||||
// HealthCheckFunc is used to provide client-side LB channel health checking
|
||||
HealthCheckFunc HealthChecker
|
||||
// BalancerUnregister is exported by package balancer to unregister a balancer.
|
||||
|
@ -39,7 +39,7 @@ var (
|
|||
// default, but tests may wish to set it lower for convenience.
|
||||
KeepaliveMinPingTime = 10 * time.Second
|
||||
// ParseServiceConfig parses a JSON representation of the service config.
|
||||
ParseServiceConfig interface{} // func(string) *serviceconfig.ParseResult
|
||||
ParseServiceConfig any // func(string) *serviceconfig.ParseResult
|
||||
// EqualServiceConfigForTesting is for testing service config generation and
|
||||
// parsing. Both a and b should be returned by ParseServiceConfig.
|
||||
// This function compares the config without rawJSON stripped, in case the
|
||||
|
@ -49,33 +49,33 @@ var (
|
|||
// given name. This is set by package certprovider for use from xDS
|
||||
// bootstrap code while parsing certificate provider configs in the
|
||||
// bootstrap file.
|
||||
GetCertificateProviderBuilder interface{} // func(string) certprovider.Builder
|
||||
GetCertificateProviderBuilder any // func(string) certprovider.Builder
|
||||
// GetXDSHandshakeInfoForTesting returns a pointer to the xds.HandshakeInfo
|
||||
// stored in the passed in attributes. This is set by
|
||||
// credentials/xds/xds.go.
|
||||
GetXDSHandshakeInfoForTesting interface{} // func (*attributes.Attributes) *xds.HandshakeInfo
|
||||
GetXDSHandshakeInfoForTesting any // func (*attributes.Attributes) *xds.HandshakeInfo
|
||||
// GetServerCredentials returns the transport credentials configured on a
|
||||
// gRPC server. An xDS-enabled server needs to know what type of credentials
|
||||
// is configured on the underlying gRPC server. This is set by server.go.
|
||||
GetServerCredentials interface{} // func (*grpc.Server) credentials.TransportCredentials
|
||||
GetServerCredentials any // func (*grpc.Server) credentials.TransportCredentials
|
||||
// CanonicalString returns the canonical string of the code defined here:
|
||||
// https://github.com/grpc/grpc/blob/master/doc/statuscodes.md.
|
||||
//
|
||||
// This is used in the 1.0 release of gcp/observability, and thus must not be
|
||||
// deleted or changed.
|
||||
CanonicalString interface{} // func (codes.Code) string
|
||||
CanonicalString any // func (codes.Code) string
|
||||
// DrainServerTransports initiates a graceful close of existing connections
|
||||
// on a gRPC server accepted on the provided listener address. An
|
||||
// xDS-enabled server invokes this method on a grpc.Server when a particular
|
||||
// listener moves to "not-serving" mode.
|
||||
DrainServerTransports interface{} // func(*grpc.Server, string)
|
||||
DrainServerTransports any // func(*grpc.Server, string)
|
||||
// AddGlobalServerOptions adds an array of ServerOption that will be
|
||||
// effective globally for newly created servers. The priority will be: 1.
|
||||
// user-provided; 2. this method; 3. default values.
|
||||
//
|
||||
// This is used in the 1.0 release of gcp/observability, and thus must not be
|
||||
// deleted or changed.
|
||||
AddGlobalServerOptions interface{} // func(opt ...ServerOption)
|
||||
AddGlobalServerOptions any // func(opt ...ServerOption)
|
||||
// ClearGlobalServerOptions clears the array of extra ServerOption. This
|
||||
// method is useful in testing and benchmarking.
|
||||
//
|
||||
|
@ -88,14 +88,14 @@ var (
|
|||
//
|
||||
// This is used in the 1.0 release of gcp/observability, and thus must not be
|
||||
// deleted or changed.
|
||||
AddGlobalDialOptions interface{} // func(opt ...DialOption)
|
||||
AddGlobalDialOptions any // func(opt ...DialOption)
|
||||
// DisableGlobalDialOptions returns a DialOption that prevents the
|
||||
// ClientConn from applying the global DialOptions (set via
|
||||
// AddGlobalDialOptions).
|
||||
//
|
||||
// This is used in the 1.0 release of gcp/observability, and thus must not be
|
||||
// deleted or changed.
|
||||
DisableGlobalDialOptions interface{} // func() grpc.DialOption
|
||||
DisableGlobalDialOptions any // func() grpc.DialOption
|
||||
// ClearGlobalDialOptions clears the array of extra DialOption. This
|
||||
// method is useful in testing and benchmarking.
|
||||
//
|
||||
|
@ -104,26 +104,26 @@ var (
|
|||
ClearGlobalDialOptions func()
|
||||
// JoinDialOptions combines the dial options passed as arguments into a
|
||||
// single dial option.
|
||||
JoinDialOptions interface{} // func(...grpc.DialOption) grpc.DialOption
|
||||
JoinDialOptions any // func(...grpc.DialOption) grpc.DialOption
|
||||
// JoinServerOptions combines the server options passed as arguments into a
|
||||
// single server option.
|
||||
JoinServerOptions interface{} // func(...grpc.ServerOption) grpc.ServerOption
|
||||
JoinServerOptions any // func(...grpc.ServerOption) grpc.ServerOption
|
||||
|
||||
// WithBinaryLogger returns a DialOption that specifies the binary logger
|
||||
// for a ClientConn.
|
||||
//
|
||||
// This is used in the 1.0 release of gcp/observability, and thus must not be
|
||||
// deleted or changed.
|
||||
WithBinaryLogger interface{} // func(binarylog.Logger) grpc.DialOption
|
||||
WithBinaryLogger any // func(binarylog.Logger) grpc.DialOption
|
||||
// BinaryLogger returns a ServerOption that can set the binary logger for a
|
||||
// server.
|
||||
//
|
||||
// This is used in the 1.0 release of gcp/observability, and thus must not be
|
||||
// deleted or changed.
|
||||
BinaryLogger interface{} // func(binarylog.Logger) grpc.ServerOption
|
||||
BinaryLogger any // func(binarylog.Logger) grpc.ServerOption
|
||||
|
||||
// SubscribeToConnectivityStateChanges adds a grpcsync.Subscriber to a provided grpc.ClientConn
|
||||
SubscribeToConnectivityStateChanges interface{} // func(*grpc.ClientConn, grpcsync.Subscriber)
|
||||
SubscribeToConnectivityStateChanges any // func(*grpc.ClientConn, grpcsync.Subscriber)
|
||||
|
||||
// NewXDSResolverWithConfigForTesting creates a new xds resolver builder using
|
||||
// the provided xds bootstrap config instead of the global configuration from
|
||||
|
@ -134,7 +134,7 @@ var (
|
|||
//
|
||||
// This function should ONLY be used for testing and may not work with some
|
||||
// other features, including the CSDS service.
|
||||
NewXDSResolverWithConfigForTesting interface{} // func([]byte) (resolver.Builder, error)
|
||||
NewXDSResolverWithConfigForTesting any // func([]byte) (resolver.Builder, error)
|
||||
|
||||
// RegisterRLSClusterSpecifierPluginForTesting registers the RLS Cluster
|
||||
// Specifier Plugin for testing purposes, regardless of the XDSRLS environment
|
||||
|
@ -166,7 +166,7 @@ var (
|
|||
UnregisterRBACHTTPFilterForTesting func()
|
||||
|
||||
// ORCAAllowAnyMinReportingInterval is for examples/orca use ONLY.
|
||||
ORCAAllowAnyMinReportingInterval interface{} // func(so *orca.ServiceOptions)
|
||||
ORCAAllowAnyMinReportingInterval any // func(so *orca.ServiceOptions)
|
||||
|
||||
// GRPCResolverSchemeExtraMetadata determines when gRPC will add extra
|
||||
// metadata to RPCs.
|
||||
|
@ -181,7 +181,7 @@ var (
|
|||
//
|
||||
// The health checking protocol is defined at:
|
||||
// https://github.com/grpc/grpc/blob/master/doc/health-checking.md
|
||||
type HealthChecker func(ctx context.Context, newStream func(string) (interface{}, error), setConnectivityState func(connectivity.State, error), serviceName string) error
|
||||
type HealthChecker func(ctx context.Context, newStream func(string) (any, error), setConnectivityState func(connectivity.State, error), serviceName string) error
|
||||
|
||||
const (
|
||||
// CredsBundleModeFallback switches GoogleDefaultCreds to fallback mode.
|
||||
|
|
|
@ -97,7 +97,7 @@ func interestingGoroutines() (gs []string) {
|
|||
// Errorfer is the interface that wraps the Errorf method. It's a subset of
|
||||
// testing.TB to make it easy to use Check.
|
||||
type Errorfer interface {
|
||||
Errorf(format string, args ...interface{})
|
||||
Errorf(format string, args ...any)
|
||||
}
|
||||
|
||||
func check(efer Errorfer, timeout time.Duration) {
|
||||
|
|
|
@ -30,7 +30,7 @@ type testErrorfer struct {
|
|||
errors []string
|
||||
}
|
||||
|
||||
func (e *testErrorfer) Errorf(format string, args ...interface{}) {
|
||||
func (e *testErrorfer) Errorf(format string, args ...any) {
|
||||
e.errors = append(e.errors, fmt.Sprintf(format, args...))
|
||||
e.errorCount++
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ const mdKey = mdKeyType("grpc.internal.address.metadata")
|
|||
|
||||
type mdValue metadata.MD
|
||||
|
||||
func (m mdValue) Equal(o interface{}) bool {
|
||||
func (m mdValue) Equal(o any) bool {
|
||||
om, ok := o.(mdValue)
|
||||
if !ok {
|
||||
return false
|
||||
|
|
|
@ -35,7 +35,7 @@ const jsonIndent = " "
|
|||
// ToJSON marshals the input into a json string.
|
||||
//
|
||||
// If marshal fails, it falls back to fmt.Sprintf("%+v").
|
||||
func ToJSON(e interface{}) string {
|
||||
func ToJSON(e any) string {
|
||||
switch ee := e.(type) {
|
||||
case protov1.Message:
|
||||
mm := jsonpb.Marshaler{Indent: jsonIndent}
|
||||
|
|
|
@ -170,7 +170,7 @@ func NewCircularBuffer(size uint32) (*CircularBuffer, error) {
|
|||
// a finite number of steps (also lock-free). Does not guarantee that push
|
||||
// order will be retained. Does not guarantee that the operation will succeed
|
||||
// if a Drain operation concurrently begins execution.
|
||||
func (cb *CircularBuffer) Push(x interface{}) {
|
||||
func (cb *CircularBuffer) Push(x any) {
|
||||
n := atomic.AddUint32(&cb.qpn, 1) & cb.qpMask
|
||||
qptr := atomic.LoadPointer(&cb.qp[n].q)
|
||||
q := (*queue)(qptr)
|
||||
|
@ -221,10 +221,10 @@ func (cb *CircularBuffer) Push(x interface{}) {
|
|||
// arr that are copied is [from, to). Assumes that the result slice is already
|
||||
// allocated and is large enough to hold all the elements that might be copied.
|
||||
// Also assumes mutual exclusion on the array of pointers.
|
||||
func dereferenceAppend(result []interface{}, arr []unsafe.Pointer, from, to uint32) []interface{} {
|
||||
func dereferenceAppend(result []any, arr []unsafe.Pointer, from, to uint32) []any {
|
||||
for i := from; i < to; i++ {
|
||||
// We have mutual exclusion on arr, there's no need for atomics.
|
||||
x := (*interface{})(arr[i])
|
||||
x := (*any)(arr[i])
|
||||
if x != nil {
|
||||
result = append(result, *x)
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ func dereferenceAppend(result []interface{}, arr []unsafe.Pointer, from, to uint
|
|||
// Drain allocates and returns an array of things Pushed in to the circular
|
||||
// buffer. Push order is not maintained; that is, if B was Pushed after A,
|
||||
// drain may return B at a lower index than A in the returned array.
|
||||
func (cb *CircularBuffer) Drain() []interface{} {
|
||||
func (cb *CircularBuffer) Drain() []any {
|
||||
cb.drainMutex.Lock()
|
||||
|
||||
qs := make([]*queue, len(cb.qp))
|
||||
|
@ -253,7 +253,7 @@ func (cb *CircularBuffer) Drain() []interface{} {
|
|||
}
|
||||
wg.Wait()
|
||||
|
||||
result := make([]interface{}, 0)
|
||||
result := make([]any, 0)
|
||||
for i := 0; i < len(qs); i++ {
|
||||
if acquired := atomic.LoadUint32(&qs[i].acquired); acquired < qs[i].size {
|
||||
result = dereferenceAppend(result, qs[i].arr, 0, acquired)
|
||||
|
|
|
@ -37,7 +37,7 @@ func Test(t *testing.T) {
|
|||
|
||||
func (s) TestCircularBufferSerial(t *testing.T) {
|
||||
var size, i uint32
|
||||
var result []interface{}
|
||||
var result []any
|
||||
|
||||
size = 1 << 15
|
||||
cb, err := NewCircularBuffer(size)
|
||||
|
@ -78,7 +78,7 @@ func (s) TestCircularBufferSerial(t *testing.T) {
|
|||
|
||||
func (s) TestCircularBufferOverflow(t *testing.T) {
|
||||
var size, i uint32
|
||||
var result []interface{}
|
||||
var result []any
|
||||
|
||||
size = 1 << 10
|
||||
cb, err := NewCircularBuffer(size)
|
||||
|
@ -106,7 +106,7 @@ func (s) TestCircularBufferOverflow(t *testing.T) {
|
|||
func (s) TestCircularBufferConcurrent(t *testing.T) {
|
||||
for tn := 0; tn < 2; tn++ {
|
||||
var size uint32
|
||||
var result []interface{}
|
||||
var result []any
|
||||
|
||||
size = 1 << 6
|
||||
cb, err := NewCircularBuffer(size)
|
||||
|
|
|
@ -26,10 +26,10 @@
|
|||
// example, if one wants to profile the load balancing layer, which is
|
||||
// independent of RPC queries, a separate CircularBuffer can be used.
|
||||
//
|
||||
// Note that the circular buffer simply takes any interface{}. In the future,
|
||||
// more types of measurements (such as the number of memory allocations) could
|
||||
// be measured, which might require a different type of object being pushed
|
||||
// into the circular buffer.
|
||||
// Note that the circular buffer simply takes any type. In the future, more
|
||||
// types of measurements (such as the number of memory allocations) could be
|
||||
// measured, which might require a different type of object being pushed into
|
||||
// the circular buffer.
|
||||
package profiling
|
||||
|
||||
import (
|
||||
|
|
|
@ -92,7 +92,7 @@ type ClientStream interface {
|
|||
// calling RecvMsg on the same stream at the same time, but it is not safe
|
||||
// to call SendMsg on the same stream in different goroutines. It is also
|
||||
// not safe to call CloseSend concurrently with SendMsg.
|
||||
SendMsg(m interface{}) error
|
||||
SendMsg(m any) error
|
||||
// RecvMsg blocks until it receives a message into m or the stream is
|
||||
// done. It returns io.EOF when the stream completes successfully. On
|
||||
// any other error, the stream is aborted and the error contains the RPC
|
||||
|
@ -101,7 +101,7 @@ type ClientStream interface {
|
|||
// It is safe to have a goroutine calling SendMsg and another goroutine
|
||||
// calling RecvMsg on the same stream at the same time, but it is not
|
||||
// safe to call RecvMsg on the same stream in different goroutines.
|
||||
RecvMsg(m interface{}) error
|
||||
RecvMsg(m any) error
|
||||
}
|
||||
|
||||
// ClientInterceptor is an interceptor for gRPC client streams.
|
||||
|
|
|
@ -49,7 +49,7 @@ func New(c codes.Code, msg string) *Status {
|
|||
}
|
||||
|
||||
// Newf returns New(c, fmt.Sprintf(format, a...)).
|
||||
func Newf(c codes.Code, format string, a ...interface{}) *Status {
|
||||
func Newf(c codes.Code, format string, a ...any) *Status {
|
||||
return New(c, fmt.Sprintf(format, a...))
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ func Err(c codes.Code, msg string) error {
|
|||
}
|
||||
|
||||
// Errorf returns Error(c, fmt.Sprintf(format, a...)).
|
||||
func Errorf(c codes.Code, format string, a ...interface{}) error {
|
||||
func Errorf(c codes.Code, format string, a ...any) error {
|
||||
return Err(c, fmt.Sprintf(format, a...))
|
||||
}
|
||||
|
||||
|
@ -120,11 +120,11 @@ func (s *Status) WithDetails(details ...proto.Message) (*Status, error) {
|
|||
|
||||
// Details returns a slice of details messages attached to the status.
|
||||
// If a detail cannot be decoded, the error is returned in place of the detail.
|
||||
func (s *Status) Details() []interface{} {
|
||||
func (s *Status) Details() []any {
|
||||
if s == nil || s.s == nil {
|
||||
return nil
|
||||
}
|
||||
details := make([]interface{}, 0, len(s.s.Details))
|
||||
details := make([]any, 0, len(s.s.Details))
|
||||
for _, any := range s.s.Details {
|
||||
detail := &ptypes.DynamicAny{}
|
||||
if err := ptypes.UnmarshalAny(any, detail); err != nil {
|
||||
|
|
|
@ -32,9 +32,9 @@ import (
|
|||
|
||||
// testingLogger wraps the logging methods from testing.T.
|
||||
type testingLogger interface {
|
||||
Log(args ...interface{})
|
||||
Logf(format string, args ...interface{})
|
||||
Errorf(format string, args ...interface{})
|
||||
Log(args ...any)
|
||||
Logf(format string, args ...any)
|
||||
Errorf(format string, args ...any)
|
||||
}
|
||||
|
||||
// TestSubConn implements the SubConn interface, to be used in tests.
|
||||
|
|
|
@ -26,17 +26,17 @@ const DefaultChanBufferSize = 1
|
|||
|
||||
// Channel wraps a generic channel and provides a timed receive operation.
|
||||
type Channel struct {
|
||||
ch chan interface{}
|
||||
ch chan any
|
||||
}
|
||||
|
||||
// Send sends value on the underlying channel.
|
||||
func (c *Channel) Send(value interface{}) {
|
||||
func (c *Channel) Send(value any) {
|
||||
c.ch <- value
|
||||
}
|
||||
|
||||
// SendContext sends value on the underlying channel, or returns an error if
|
||||
// the context expires.
|
||||
func (c *Channel) SendContext(ctx context.Context, value interface{}) error {
|
||||
func (c *Channel) SendContext(ctx context.Context, value any) error {
|
||||
select {
|
||||
case c.ch <- value:
|
||||
return nil
|
||||
|
@ -47,7 +47,7 @@ func (c *Channel) SendContext(ctx context.Context, value interface{}) error {
|
|||
|
||||
// SendOrFail attempts to send value on the underlying channel. Returns true
|
||||
// if successful or false if the channel was full.
|
||||
func (c *Channel) SendOrFail(value interface{}) bool {
|
||||
func (c *Channel) SendOrFail(value any) bool {
|
||||
select {
|
||||
case c.ch <- value:
|
||||
return true
|
||||
|
@ -58,7 +58,7 @@ func (c *Channel) SendOrFail(value interface{}) bool {
|
|||
|
||||
// ReceiveOrFail returns the value on the underlying channel and true, or nil
|
||||
// and false if the channel was empty.
|
||||
func (c *Channel) ReceiveOrFail() (interface{}, bool) {
|
||||
func (c *Channel) ReceiveOrFail() (any, bool) {
|
||||
select {
|
||||
case got := <-c.ch:
|
||||
return got, true
|
||||
|
@ -69,7 +69,7 @@ func (c *Channel) ReceiveOrFail() (interface{}, bool) {
|
|||
|
||||
// Receive returns the value received on the underlying channel, or the error
|
||||
// returned by ctx if it is closed or cancelled.
|
||||
func (c *Channel) Receive(ctx context.Context) (interface{}, error) {
|
||||
func (c *Channel) Receive(ctx context.Context) (any, error) {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil, ctx.Err()
|
||||
|
@ -83,7 +83,7 @@ func (c *Channel) Receive(ctx context.Context) (interface{}, error) {
|
|||
// It's expected to be used with a size-1 channel, to only keep the most
|
||||
// up-to-date item. This method is inherently racy when invoked concurrently
|
||||
// from multiple goroutines.
|
||||
func (c *Channel) Replace(value interface{}) {
|
||||
func (c *Channel) Replace(value any) {
|
||||
for {
|
||||
select {
|
||||
case c.ch <- value:
|
||||
|
@ -100,5 +100,5 @@ func NewChannel() *Channel {
|
|||
|
||||
// NewChannelWithSize returns a new Channel with a buffer of bufSize.
|
||||
func NewChannelWithSize(bufSize int) *Channel {
|
||||
return &Channel{ch: make(chan interface{}, bufSize)}
|
||||
return &Channel{ch: make(chan any, bufSize)}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ import (
|
|||
// With {a: 2, b: 3}, the Next() results will be {a, a, b, b, b}.
|
||||
type testWRR struct {
|
||||
itemsWithWeight []struct {
|
||||
item interface{}
|
||||
item any
|
||||
weight int64
|
||||
}
|
||||
length int
|
||||
|
@ -48,15 +48,15 @@ func NewTestWRR() wrr.WRR {
|
|||
return &testWRR{}
|
||||
}
|
||||
|
||||
func (twrr *testWRR) Add(item interface{}, weight int64) {
|
||||
func (twrr *testWRR) Add(item any, weight int64) {
|
||||
twrr.itemsWithWeight = append(twrr.itemsWithWeight, struct {
|
||||
item interface{}
|
||||
item any
|
||||
weight int64
|
||||
}{item: item, weight: weight})
|
||||
twrr.length++
|
||||
}
|
||||
|
||||
func (twrr *testWRR) Next() interface{} {
|
||||
func (twrr *testWRR) Next() any {
|
||||
twrr.mu.Lock()
|
||||
iww := twrr.itemsWithWeight[twrr.idx]
|
||||
twrr.count++
|
||||
|
|
|
@ -158,8 +158,8 @@ type server struct {
|
|||
}
|
||||
|
||||
type creds struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
Config interface{} `json:"config,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Config any `json:"config,omitempty"`
|
||||
}
|
||||
|
||||
type node struct {
|
||||
|
|
|
@ -30,19 +30,19 @@ var logger = grpclog.Component("xds-e2e")
|
|||
// envoyproxy/go-control-plane/pkg/log. This is passed to the Snapshot cache.
|
||||
type serverLogger struct{}
|
||||
|
||||
func (l serverLogger) Debugf(format string, args ...interface{}) {
|
||||
func (l serverLogger) Debugf(format string, args ...any) {
|
||||
msg := fmt.Sprintf(format, args...)
|
||||
logger.InfoDepth(1, msg)
|
||||
}
|
||||
func (l serverLogger) Infof(format string, args ...interface{}) {
|
||||
func (l serverLogger) Infof(format string, args ...any) {
|
||||
msg := fmt.Sprintf(format, args...)
|
||||
logger.InfoDepth(1, msg)
|
||||
}
|
||||
func (l serverLogger) Warnf(format string, args ...interface{}) {
|
||||
func (l serverLogger) Warnf(format string, args ...any) {
|
||||
msg := fmt.Sprintf(format, args...)
|
||||
logger.WarningDepth(1, msg)
|
||||
}
|
||||
func (l serverLogger) Errorf(format string, args ...interface{}) {
|
||||
func (l serverLogger) Errorf(format string, args ...any) {
|
||||
msg := fmt.Sprintf(format, args...)
|
||||
logger.ErrorDepth(1, msg)
|
||||
}
|
||||
|
|
|
@ -237,7 +237,7 @@ func (s *ManagementServer) Stop() {
|
|||
|
||||
// resourceSlice accepts a slice of any type of proto messages and returns a
|
||||
// slice of types.Resource. Will panic if there is an input type mismatch.
|
||||
func resourceSlice(i interface{}) []types.Resource {
|
||||
func resourceSlice(i any) []types.Resource {
|
||||
v := reflect.ValueOf(i)
|
||||
rs := make([]types.Resource, v.Len())
|
||||
for i := 0; i < v.Len(); i++ {
|
||||
|
|
|
@ -40,7 +40,7 @@ var updateHeaderTblSize = func(e *hpack.Encoder, v uint32) {
|
|||
}
|
||||
|
||||
type itemNode struct {
|
||||
it interface{}
|
||||
it any
|
||||
next *itemNode
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ type itemList struct {
|
|||
tail *itemNode
|
||||
}
|
||||
|
||||
func (il *itemList) enqueue(i interface{}) {
|
||||
func (il *itemList) enqueue(i any) {
|
||||
n := &itemNode{it: i}
|
||||
if il.tail == nil {
|
||||
il.head, il.tail = n, n
|
||||
|
@ -61,11 +61,11 @@ func (il *itemList) enqueue(i interface{}) {
|
|||
|
||||
// peek returns the first item in the list without removing it from the
|
||||
// list.
|
||||
func (il *itemList) peek() interface{} {
|
||||
func (il *itemList) peek() any {
|
||||
return il.head.it
|
||||
}
|
||||
|
||||
func (il *itemList) dequeue() interface{} {
|
||||
func (il *itemList) dequeue() any {
|
||||
if il.head == nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -336,7 +336,7 @@ func (c *controlBuffer) put(it cbItem) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func (c *controlBuffer) executeAndPut(f func(it interface{}) bool, it cbItem) (bool, error) {
|
||||
func (c *controlBuffer) executeAndPut(f func(it any) bool, it cbItem) (bool, error) {
|
||||
var wakeUp bool
|
||||
c.mu.Lock()
|
||||
if c.err != nil {
|
||||
|
@ -373,7 +373,7 @@ func (c *controlBuffer) executeAndPut(f func(it interface{}) bool, it cbItem) (b
|
|||
}
|
||||
|
||||
// Note argument f should never be nil.
|
||||
func (c *controlBuffer) execute(f func(it interface{}) bool, it interface{}) (bool, error) {
|
||||
func (c *controlBuffer) execute(f func(it any) bool, it any) (bool, error) {
|
||||
c.mu.Lock()
|
||||
if c.err != nil {
|
||||
c.mu.Unlock()
|
||||
|
@ -387,7 +387,7 @@ func (c *controlBuffer) execute(f func(it interface{}) bool, it interface{}) (bo
|
|||
return true, nil
|
||||
}
|
||||
|
||||
func (c *controlBuffer) get(block bool) (interface{}, error) {
|
||||
func (c *controlBuffer) get(block bool) (any, error) {
|
||||
for {
|
||||
c.mu.Lock()
|
||||
if c.err != nil {
|
||||
|
@ -830,7 +830,7 @@ func (l *loopyWriter) goAwayHandler(g *goAway) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (l *loopyWriter) handle(i interface{}) error {
|
||||
func (l *loopyWriter) handle(i any) error {
|
||||
switch i := i.(type) {
|
||||
case *incomingWindowUpdate:
|
||||
l.incomingWindowUpdateHandler(i)
|
||||
|
|
|
@ -762,7 +762,7 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (*Stream,
|
|||
firstTry := true
|
||||
var ch chan struct{}
|
||||
transportDrainRequired := false
|
||||
checkForStreamQuota := func(it interface{}) bool {
|
||||
checkForStreamQuota := func(it any) bool {
|
||||
if t.streamQuota <= 0 { // Can go negative if server decreases it.
|
||||
if firstTry {
|
||||
t.waitingStreams++
|
||||
|
@ -800,7 +800,7 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (*Stream,
|
|||
return true
|
||||
}
|
||||
var hdrListSizeErr error
|
||||
checkForHeaderListSize := func(it interface{}) bool {
|
||||
checkForHeaderListSize := func(it any) bool {
|
||||
if t.maxSendHeaderListSize == nil {
|
||||
return true
|
||||
}
|
||||
|
@ -815,7 +815,7 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (*Stream,
|
|||
return true
|
||||
}
|
||||
for {
|
||||
success, err := t.controlBuf.executeAndPut(func(it interface{}) bool {
|
||||
success, err := t.controlBuf.executeAndPut(func(it any) bool {
|
||||
return checkForHeaderListSize(it) && checkForStreamQuota(it)
|
||||
}, hdr)
|
||||
if err != nil {
|
||||
|
@ -927,7 +927,7 @@ func (t *http2Client) closeStream(s *Stream, err error, rst bool, rstCode http2.
|
|||
rst: rst,
|
||||
rstCode: rstCode,
|
||||
}
|
||||
addBackStreamQuota := func(interface{}) bool {
|
||||
addBackStreamQuota := func(any) bool {
|
||||
t.streamQuota++
|
||||
if t.streamQuota > 0 && t.waitingStreams > 0 {
|
||||
select {
|
||||
|
@ -1080,7 +1080,7 @@ func (t *http2Client) updateWindow(s *Stream, n uint32) {
|
|||
// for the transport and the stream based on the current bdp
|
||||
// estimation.
|
||||
func (t *http2Client) updateFlowControl(n uint32) {
|
||||
updateIWS := func(interface{}) bool {
|
||||
updateIWS := func(any) bool {
|
||||
t.initialWindowSize = int32(n)
|
||||
t.mu.Lock()
|
||||
for _, s := range t.activeStreams {
|
||||
|
@ -1233,7 +1233,7 @@ func (t *http2Client) handleSettings(f *http2.SettingsFrame, isFirst bool) {
|
|||
}
|
||||
updateFuncs = append(updateFuncs, updateStreamQuota)
|
||||
}
|
||||
t.controlBuf.executeAndPut(func(interface{}) bool {
|
||||
t.controlBuf.executeAndPut(func(any) bool {
|
||||
for _, f := range updateFuncs {
|
||||
f()
|
||||
}
|
||||
|
|
|
@ -855,7 +855,7 @@ func (t *http2Server) handleSettings(f *http2.SettingsFrame) {
|
|||
}
|
||||
return nil
|
||||
})
|
||||
t.controlBuf.executeAndPut(func(interface{}) bool {
|
||||
t.controlBuf.executeAndPut(func(any) bool {
|
||||
for _, f := range updateFuncs {
|
||||
f()
|
||||
}
|
||||
|
@ -939,7 +939,7 @@ func appendHeaderFieldsFromMD(headerFields []hpack.HeaderField, md metadata.MD)
|
|||
return headerFields
|
||||
}
|
||||
|
||||
func (t *http2Server) checkForHeaderListSize(it interface{}) bool {
|
||||
func (t *http2Server) checkForHeaderListSize(it any) bool {
|
||||
if t.maxSendHeaderListSize == nil {
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -441,7 +441,7 @@ func getWriteBufferPool(writeBufferSize int) *sync.Pool {
|
|||
return pool
|
||||
}
|
||||
pool = &sync.Pool{
|
||||
New: func() interface{} {
|
||||
New: func() any {
|
||||
b := make([]byte, size)
|
||||
return &b
|
||||
},
|
||||
|
|
|
@ -56,7 +56,7 @@ type bufferPool struct {
|
|||
func newBufferPool() *bufferPool {
|
||||
return &bufferPool{
|
||||
pool: sync.Pool{
|
||||
New: func() interface{} {
|
||||
New: func() any {
|
||||
return new(bytes.Buffer)
|
||||
},
|
||||
},
|
||||
|
@ -739,7 +739,7 @@ type ServerTransport interface {
|
|||
}
|
||||
|
||||
// connectionErrorf creates an ConnectionError with the specified error description.
|
||||
func connectionErrorf(temp bool, e error, format string, a ...interface{}) ConnectionError {
|
||||
func connectionErrorf(temp bool, e error, format string, a ...any) ConnectionError {
|
||||
return ConnectionError{
|
||||
Desc: fmt.Sprintf(format, a...),
|
||||
temp: temp,
|
||||
|
|
|
@ -43,7 +43,7 @@ type edfEntry struct {
|
|||
deadline float64
|
||||
weight int64
|
||||
orderOffset uint64
|
||||
item interface{}
|
||||
item any
|
||||
}
|
||||
|
||||
// edfPriorityQueue is a heap.Interface implementation for edfEntry elements.
|
||||
|
@ -55,17 +55,17 @@ func (pq edfPriorityQueue) Less(i, j int) bool {
|
|||
}
|
||||
func (pq edfPriorityQueue) Swap(i, j int) { pq[i], pq[j] = pq[j], pq[i] }
|
||||
|
||||
func (pq *edfPriorityQueue) Push(x interface{}) {
|
||||
func (pq *edfPriorityQueue) Push(x any) {
|
||||
*pq = append(*pq, x.(*edfEntry))
|
||||
}
|
||||
|
||||
func (pq *edfPriorityQueue) Pop() interface{} {
|
||||
func (pq *edfPriorityQueue) Pop() any {
|
||||
old := *pq
|
||||
*pq = old[0 : len(old)-1]
|
||||
return old[len(old)-1]
|
||||
}
|
||||
|
||||
func (edf *edfWrr) Add(item interface{}, weight int64) {
|
||||
func (edf *edfWrr) Add(item any, weight int64) {
|
||||
edf.lock.Lock()
|
||||
defer edf.lock.Unlock()
|
||||
entry := edfEntry{
|
||||
|
@ -78,7 +78,7 @@ func (edf *edfWrr) Add(item interface{}, weight int64) {
|
|||
heap.Push(&edf.items, &entry)
|
||||
}
|
||||
|
||||
func (edf *edfWrr) Next() interface{} {
|
||||
func (edf *edfWrr) Next() any {
|
||||
edf.lock.Lock()
|
||||
defer edf.lock.Unlock()
|
||||
if len(edf.items) == 0 {
|
||||
|
|
|
@ -27,7 +27,7 @@ import (
|
|||
|
||||
// weightedItem is a wrapped weighted item that is used to implement weighted random algorithm.
|
||||
type weightedItem struct {
|
||||
item interface{}
|
||||
item any
|
||||
weight int64
|
||||
accumulatedWeight int64
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ func NewRandom() WRR {
|
|||
|
||||
var grpcrandInt63n = grpcrand.Int63n
|
||||
|
||||
func (rw *randomWRR) Next() (item interface{}) {
|
||||
func (rw *randomWRR) Next() (item any) {
|
||||
rw.mu.RLock()
|
||||
defer rw.mu.RUnlock()
|
||||
if len(rw.items) == 0 {
|
||||
|
@ -71,7 +71,7 @@ func (rw *randomWRR) Next() (item interface{}) {
|
|||
return rw.items[i].item
|
||||
}
|
||||
|
||||
func (rw *randomWRR) Add(item interface{}, weight int64) {
|
||||
func (rw *randomWRR) Add(item any, weight int64) {
|
||||
rw.mu.Lock()
|
||||
defer rw.mu.Unlock()
|
||||
accumulatedWeight := weight
|
||||
|
|
|
@ -24,9 +24,9 @@ type WRR interface {
|
|||
// Add adds an item with weight to the WRR set.
|
||||
//
|
||||
// Add and Next need to be thread safe.
|
||||
Add(item interface{}, weight int64)
|
||||
Add(item any, weight int64)
|
||||
// Next returns the next picked item.
|
||||
//
|
||||
// Add and Next need to be thread safe.
|
||||
Next() interface{}
|
||||
Next() any
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ func (s) TestBuildLoggerErrors(t *testing.T) {
|
|||
loggerConfig: &v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
AuditLogger: &v3corepb.TypedExtensionConfig{
|
||||
Name: "TestAuditLoggerBuffer",
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]interface{}{}, ""),
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]any{}, ""),
|
||||
},
|
||||
},
|
||||
expectedError: "field TypedConfig.TypeURL cannot be an empty string",
|
||||
|
@ -71,7 +71,7 @@ func (s) TestBuildLoggerErrors(t *testing.T) {
|
|||
loggerConfig: &v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
AuditLogger: &v3corepb.TypedExtensionConfig{
|
||||
Name: "UnregisteredLogger",
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]interface{}{}, "UnregisteredLogger"),
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]any{}, "UnregisteredLogger"),
|
||||
},
|
||||
IsOptional: false,
|
||||
},
|
||||
|
@ -82,7 +82,7 @@ func (s) TestBuildLoggerErrors(t *testing.T) {
|
|||
loggerConfig: &v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
AuditLogger: &v3corepb.TypedExtensionConfig{
|
||||
Name: "TestAuditLoggerCustomConfig",
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]interface{}{"abc": "BADVALUE", "xyz": "123"}, "fail to parse custom config_TestAuditLoggerCustomConfig")},
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]any{"abc": "BADVALUE", "xyz": "123"}, "fail to parse custom config_TestAuditLoggerCustomConfig")},
|
||||
IsOptional: false,
|
||||
},
|
||||
expectedError: "custom config could not be parsed",
|
||||
|
@ -92,7 +92,7 @@ func (s) TestBuildLoggerErrors(t *testing.T) {
|
|||
loggerConfig: &v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
AuditLogger: &v3corepb.TypedExtensionConfig{
|
||||
Name: "UnregisteredLogger",
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]interface{}{}, "no registered logger but optional passes_UnregisteredLogger"),
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]any{}, "no registered logger but optional passes_UnregisteredLogger"),
|
||||
},
|
||||
IsOptional: true,
|
||||
},
|
||||
|
@ -137,7 +137,7 @@ func (s) TestBuildLoggerKnownTypes(t *testing.T) {
|
|||
loggerConfig: &v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
AuditLogger: &v3corepb.TypedExtensionConfig{
|
||||
Name: stdout.Name,
|
||||
TypedConfig: createXDSTypedStruct(t, map[string]interface{}{}, stdout.Name),
|
||||
TypedConfig: createXDSTypedStruct(t, map[string]any{}, stdout.Name),
|
||||
},
|
||||
IsOptional: false,
|
||||
},
|
||||
|
|
|
@ -454,7 +454,7 @@ func (s) TestNewChainEngine(t *testing.T) {
|
|||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{
|
||||
Name: "TestAuditLoggerBuffer",
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]interface{}{}, "SimpleAuditLogger_TestAuditLoggerBuffer")},
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]any{}, "SimpleAuditLogger_TestAuditLoggerBuffer")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -482,7 +482,7 @@ func (s) TestNewChainEngine(t *testing.T) {
|
|||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{
|
||||
Name: "TestAuditLoggerCustomConfig",
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]interface{}{"abc": 123, "xyz": "123"}, "AuditLoggerCustomConfig_TestAuditLoggerCustomConfig")},
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]any{"abc": 123, "xyz": "123"}, "AuditLoggerCustomConfig_TestAuditLoggerCustomConfig")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -511,7 +511,7 @@ func (s) TestNewChainEngine(t *testing.T) {
|
|||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{
|
||||
Name: "TestAuditLoggerCustomConfig",
|
||||
TypedConfig: createXDSTypedStruct(t, map[string]interface{}{"abc": 123, "xyz": "123"}, "AuditLoggerCustomConfigXdsTypedStruct_TestAuditLoggerCustomConfig")},
|
||||
TypedConfig: createXDSTypedStruct(t, map[string]any{"abc": 123, "xyz": "123"}, "AuditLoggerCustomConfigXdsTypedStruct_TestAuditLoggerCustomConfig")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -540,7 +540,7 @@ func (s) TestNewChainEngine(t *testing.T) {
|
|||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{
|
||||
Name: "UnsupportedLogger",
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]interface{}{}, "Missing Optional AuditLogger doesn't fail_UnsupportedLogger")},
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]any{}, "Missing Optional AuditLogger doesn't fail_UnsupportedLogger")},
|
||||
IsOptional: true,
|
||||
},
|
||||
},
|
||||
|
@ -568,7 +568,7 @@ func (s) TestNewChainEngine(t *testing.T) {
|
|||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{
|
||||
Name: "UnsupportedLogger",
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]interface{}{}, "Missing Non-Optional AuditLogger fails_UnsupportedLogger")},
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]any{}, "Missing Non-Optional AuditLogger fails_UnsupportedLogger")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -626,7 +626,7 @@ func (s) TestNewChainEngine(t *testing.T) {
|
|||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{
|
||||
Name: "TestAuditLoggerCustomConfig",
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]interface{}{"abc": "BADVALUE", "xyz": "123"}, "Cannot_parse_bad_CustomConfig_TestAuditLoggerCustomConfig")},
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]any{"abc": "BADVALUE", "xyz": "123"}, "Cannot_parse_bad_CustomConfig_TestAuditLoggerCustomConfig")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -655,7 +655,7 @@ func (s) TestNewChainEngine(t *testing.T) {
|
|||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{
|
||||
Name: "TestAuditLoggerCustomConfig",
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]interface{}{"abc": 123, "xyz": "123"}, "")},
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]any{"abc": 123, "xyz": "123"}, "")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -1248,7 +1248,7 @@ func (s) TestChainEngine(t *testing.T) {
|
|||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{
|
||||
Name: "TestAuditLoggerBuffer",
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]interface{}{}, "AuditLoggingAllowAndDenyPolicy_ON_ALLOW_TestAuditLoggerBuffer")},
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]any{}, "AuditLoggingAllowAndDenyPolicy_ON_ALLOW_TestAuditLoggerBuffer")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -1271,7 +1271,7 @@ func (s) TestChainEngine(t *testing.T) {
|
|||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{
|
||||
Name: "TestAuditLoggerBuffer",
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]interface{}{}, "AuditLoggingAllowAndDenyPolicy_ON_ALLOW_TestAuditLoggerBuffer")},
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]any{}, "AuditLoggingAllowAndDenyPolicy_ON_ALLOW_TestAuditLoggerBuffer")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -1374,7 +1374,7 @@ func (s) TestChainEngine(t *testing.T) {
|
|||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{
|
||||
Name: "TestAuditLoggerBuffer",
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]interface{}{}, "AuditLoggingAllowAndDenyPolicy_ON_DENY_TestAuditLoggerBuffer")},
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]any{}, "AuditLoggingAllowAndDenyPolicy_ON_DENY_TestAuditLoggerBuffer")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -1397,7 +1397,7 @@ func (s) TestChainEngine(t *testing.T) {
|
|||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{
|
||||
Name: "TestAuditLoggerBuffer",
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]interface{}{}, "AuditLoggingAllowAndDenyPolicy_ON_DENY_TestAuditLoggerBuffer")},
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]any{}, "AuditLoggingAllowAndDenyPolicy_ON_DENY_TestAuditLoggerBuffer")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -1513,7 +1513,7 @@ func (s) TestChainEngine(t *testing.T) {
|
|||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{
|
||||
Name: "TestAuditLoggerBuffer",
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]interface{}{}, "AuditLoggingAllowAndDenyPolicy_NONE_TestAuditLoggerBuffer")},
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]any{}, "AuditLoggingAllowAndDenyPolicy_NONE_TestAuditLoggerBuffer")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -1536,7 +1536,7 @@ func (s) TestChainEngine(t *testing.T) {
|
|||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{
|
||||
Name: "TestAuditLoggerBuffer",
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]interface{}{}, "AuditLoggingAllowAndDenyPolicy_NONE_TestAuditLoggerBuffer")},
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]any{}, "AuditLoggingAllowAndDenyPolicy_NONE_TestAuditLoggerBuffer")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -1614,7 +1614,7 @@ func (s) TestChainEngine(t *testing.T) {
|
|||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{
|
||||
Name: "TestAuditLoggerBuffer",
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]interface{}{}, "AuditLoggingAllowAndDenyPolicy_ON_DENY_AND_ALLOW_TestAuditLoggerBuffer")},
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]any{}, "AuditLoggingAllowAndDenyPolicy_ON_DENY_AND_ALLOW_TestAuditLoggerBuffer")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -1637,7 +1637,7 @@ func (s) TestChainEngine(t *testing.T) {
|
|||
LoggerConfigs: []*v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{
|
||||
{AuditLogger: &v3corepb.TypedExtensionConfig{
|
||||
Name: "TestAuditLoggerBuffer",
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]interface{}{}, "AuditLoggingAllowAndDenyPolicy_ON_DENY_AND_ALLOW_TestAuditLoggerBuffer")},
|
||||
TypedConfig: createUDPATypedStruct(t, map[string]any{}, "AuditLoggingAllowAndDenyPolicy_ON_DENY_AND_ALLOW_TestAuditLoggerBuffer")},
|
||||
IsOptional: false,
|
||||
},
|
||||
},
|
||||
|
@ -1890,7 +1890,7 @@ func (b *TestAuditLoggerCustomConfigBuilder) Name() string {
|
|||
}
|
||||
|
||||
// Builds custom configs for audit logger RBAC protos.
|
||||
func createUDPATypedStruct(t *testing.T, in map[string]interface{}, name string) *anypb.Any {
|
||||
func createUDPATypedStruct(t *testing.T, in map[string]any, name string) *anypb.Any {
|
||||
t.Helper()
|
||||
pb, err := structpb.NewStruct(in)
|
||||
if err != nil {
|
||||
|
@ -1912,7 +1912,7 @@ func createUDPATypedStruct(t *testing.T, in map[string]interface{}, name string)
|
|||
}
|
||||
|
||||
// Builds custom configs for audit logger RBAC protos.
|
||||
func createXDSTypedStruct(t *testing.T, in map[string]interface{}, name string) *anypb.Any {
|
||||
func createXDSTypedStruct(t *testing.T, in map[string]any, name string) *anypb.Any {
|
||||
t.Helper()
|
||||
pb, err := structpb.NewStruct(in)
|
||||
if err != nil {
|
||||
|
|
|
@ -249,7 +249,7 @@ func main() {
|
|||
opts = append(opts, grpc.WithDisableServiceConfig(), grpc.WithDefaultServiceConfig(*serviceConfigJSON))
|
||||
}
|
||||
if addMd := parseAdditionalMetadataFlag(); addMd != nil {
|
||||
unaryAddMd := func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
unaryAddMd := func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
ctx = metadata.AppendToOutgoingContext(ctx, addMd...)
|
||||
return invoker(ctx, method, req, reply, cc, opts...)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module google.golang.org/grpc/interop/observability
|
||||
|
||||
go 1.17
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
google.golang.org/grpc v1.56.2
|
||||
|
|
|
@ -135,8 +135,8 @@ func CallMetricsServerOption(smp ServerMetricsProvider) grpc.ServerOption {
|
|||
return joinServerOptions(grpc.ChainUnaryInterceptor(unaryInt(smp)), grpc.ChainStreamInterceptor(streamInt(smp)))
|
||||
}
|
||||
|
||||
func unaryInt(smp ServerMetricsProvider) func(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
|
||||
return func(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
|
||||
func unaryInt(smp ServerMetricsProvider) func(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
|
||||
return func(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
|
||||
// We don't allocate the metric recorder here. It will be allocated the
|
||||
// first time the user calls CallMetricsRecorderFromContext().
|
||||
rw := &recorderWrapper{smp: smp}
|
||||
|
@ -155,8 +155,8 @@ func unaryInt(smp ServerMetricsProvider) func(ctx context.Context, req interface
|
|||
}
|
||||
}
|
||||
|
||||
func streamInt(smp ServerMetricsProvider) func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
|
||||
return func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
|
||||
func streamInt(smp ServerMetricsProvider) func(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
|
||||
return func(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
|
||||
// We don't allocate the metric recorder here. It will be allocated the
|
||||
// first time the user calls CallMetricsRecorderFromContext().
|
||||
rw := &recorderWrapper{smp: smp}
|
||||
|
|
|
@ -73,7 +73,7 @@ func (s) TestE2ECallMetricsUnary(t *testing.T) {
|
|||
|
||||
// An interceptor to injects custom backend metrics, added only when
|
||||
// the injectMetrics field in the test is set.
|
||||
injectingInterceptor := func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
|
||||
injectingInterceptor := func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) {
|
||||
recorder := orca.CallMetricsRecorderFromContext(ctx)
|
||||
if recorder == nil {
|
||||
err := errors.New("Failed to retrieve per-RPC custom metrics recorder from the RPC context")
|
||||
|
@ -179,7 +179,7 @@ func (s) TestE2ECallMetricsStreaming(t *testing.T) {
|
|||
|
||||
// An interceptor which injects custom backend metrics, added only
|
||||
// when the injectMetrics field in the test is set.
|
||||
injectingInterceptor := func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
|
||||
injectingInterceptor := func(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
|
||||
recorder := orca.CallMetricsRecorderFromContext(ss.Context())
|
||||
if recorder == nil {
|
||||
err := errors.New("Failed to retrieve per-RPC custom metrics recorder from the RPC context")
|
||||
|
|
|
@ -35,7 +35,7 @@ import (
|
|||
// configured via ServiceOptions, to a minimum of 30s.
|
||||
//
|
||||
// For testing purposes only.
|
||||
var AllowAnyMinReportingInterval interface{} // func(*ServiceOptions)
|
||||
var AllowAnyMinReportingInterval any // func(*ServiceOptions)
|
||||
|
||||
// DefaultBackoffFunc is used by the producer to control its backoff behavior.
|
||||
//
|
||||
|
|
|
@ -44,7 +44,7 @@ var logger = grpclog.Component("orca-backend-metrics")
|
|||
// import cycle. Hence this roundabout method is used.
|
||||
type loadParser struct{}
|
||||
|
||||
func (loadParser) Parse(md metadata.MD) interface{} {
|
||||
func (loadParser) Parse(md metadata.MD) any {
|
||||
lr, err := internal.ToLoadReport(md)
|
||||
if err != nil {
|
||||
logger.Infof("Parse failed: %v", err)
|
||||
|
|
|
@ -37,7 +37,7 @@ import (
|
|||
type producerBuilder struct{}
|
||||
|
||||
// Build constructs and returns a producer and its cleanup function
|
||||
func (*producerBuilder) Build(cci interface{}) (balancer.Producer, func()) {
|
||||
func (*producerBuilder) Build(cci any) (balancer.Producer, func()) {
|
||||
p := &producer{
|
||||
client: v3orcaservicegrpc.NewOpenRcaServiceClient(cci.(grpc.ClientConnInterface)),
|
||||
intervals: make(map[time.Duration]int),
|
||||
|
|
|
@ -212,13 +212,13 @@ type fakeORCAService struct {
|
|||
v3orcaservicegrpc.UnimplementedOpenRcaServiceServer
|
||||
|
||||
reqCh chan *v3orcaservicepb.OrcaLoadReportRequest
|
||||
respCh chan interface{} // either *v3orcapb.OrcaLoadReport or error
|
||||
respCh chan any // either *v3orcapb.OrcaLoadReport or error
|
||||
}
|
||||
|
||||
func newFakeORCAService() *fakeORCAService {
|
||||
return &fakeORCAService{
|
||||
reqCh: make(chan *v3orcaservicepb.OrcaLoadReportRequest),
|
||||
respCh: make(chan interface{}),
|
||||
respCh: make(chan any),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ type PreparedMsg struct {
|
|||
}
|
||||
|
||||
// Encode marshalls and compresses the message using the codec and compressor for the stream.
|
||||
func (p *PreparedMsg) Encode(s Stream, msg interface{}) error {
|
||||
func (p *PreparedMsg) Encode(s Stream, msg any) error {
|
||||
ctx := s.Context()
|
||||
rpcInfo, ok := rpcInfoFromContext(ctx)
|
||||
if !ok {
|
||||
|
|
|
@ -604,7 +604,7 @@ func testListServices(t *testing.T, stream v1reflectiongrpc.ServerReflection_Ser
|
|||
}
|
||||
|
||||
func registerDynamicProto(srv *grpc.Server, fdp *descriptorpb.FileDescriptorProto, fd protoreflect.FileDescriptor) {
|
||||
type emptyInterface interface{}
|
||||
type emptyInterface any
|
||||
|
||||
for i := 0; i < fd.Services().Len(); i++ {
|
||||
s := fd.Services().Get(i)
|
||||
|
|
|
@ -20,7 +20,7 @@ package resolver
|
|||
|
||||
type addressMapEntry struct {
|
||||
addr Address
|
||||
value interface{}
|
||||
value any
|
||||
}
|
||||
|
||||
// AddressMap is a map of addresses to arbitrary values taking into account
|
||||
|
@ -69,7 +69,7 @@ func (l addressMapEntryList) find(addr Address) int {
|
|||
}
|
||||
|
||||
// Get returns the value for the address in the map, if present.
|
||||
func (a *AddressMap) Get(addr Address) (value interface{}, ok bool) {
|
||||
func (a *AddressMap) Get(addr Address) (value any, ok bool) {
|
||||
addrKey := toMapKey(&addr)
|
||||
entryList := a.m[addrKey]
|
||||
if entry := entryList.find(addr); entry != -1 {
|
||||
|
@ -79,7 +79,7 @@ func (a *AddressMap) Get(addr Address) (value interface{}, ok bool) {
|
|||
}
|
||||
|
||||
// Set updates or adds the value to the address in the map.
|
||||
func (a *AddressMap) Set(addr Address, value interface{}) {
|
||||
func (a *AddressMap) Set(addr Address, value any) {
|
||||
addrKey := toMapKey(&addr)
|
||||
entryList := a.m[addrKey]
|
||||
if entry := entryList.find(addr); entry != -1 {
|
||||
|
@ -127,8 +127,8 @@ func (a *AddressMap) Keys() []Address {
|
|||
}
|
||||
|
||||
// Values returns a slice of all current map values.
|
||||
func (a *AddressMap) Values() []interface{} {
|
||||
ret := make([]interface{}, 0, a.Len())
|
||||
func (a *AddressMap) Values() []any {
|
||||
ret := make([]any, 0, a.Len())
|
||||
for _, entryList := range a.m {
|
||||
for _, entry := range entryList {
|
||||
ret = append(ret, entry.value)
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue