Skip to content

Commit

Permalink
[admin_api] nomap
Browse files Browse the repository at this point in the history
  • Loading branch information
menghanl committed Mar 22, 2021
1 parent c67edde commit 4df6f32
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
func init() {
// Add a list of default services to admin here. Optional services, like
// CSDS, will be added by other packages.
internaladmin.AddService("channelz", func(registrar grpc.ServiceRegistrar) (func(), error) {
internaladmin.AddService(func(registrar grpc.ServiceRegistrar) (func(), error) {
channelzservice.RegisterChannelzServiceToServer(registrar)
return nil, nil
})
Expand Down
16 changes: 8 additions & 8 deletions internal/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ package admin

import "google.golang.org/grpc"

var (
// services is a map from name to service register functions.
services = make(map[string]func(grpc.ServiceRegistrar) (func(), error))
)
// services is a map from name to service register functions.
var services []func(grpc.ServiceRegistrar) (func(), error)

// AddService adds a service to the list of admin services.
//
// NOTE: this function must only be called during initialization time (i.e. in
// an init() function), and is not thread-safe. If multiple services are added
// with the same name, the one added last will take effect.
func AddService(name string, f func(grpc.ServiceRegistrar) (func(), error)) {
services[name] = f
// an init() function), and is not thread-safe.
//
// If multiple services with the same service name are added (e.g. two services
// for `grpc.channelz.v1.Channelz`), the server will panic on `Register()`.
func AddService(f func(grpc.ServiceRegistrar) (func(), error)) {
services = append(services, f)
}

// Register registers the set of admin services to the given server.
Expand Down
2 changes: 1 addition & 1 deletion xds/xds.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import (
)

func init() {
internaladmin.AddService("csds", func(registrar grpc.ServiceRegistrar) (func(), error) {
internaladmin.AddService(func(registrar grpc.ServiceRegistrar) (func(), error) {
var grpcServer *grpc.Server
switch ss := registrar.(type) {
case *grpc.Server:
Expand Down

0 comments on commit 4df6f32

Please sign in to comment.