Skip to content

Commit 9822378

Browse files
authored
refactor(mcs): remove global service registration (#9718)
ref #9707 This change removes the global `ServerServiceRegistry` and the auto-registration `install` packages for microservices, as they are no longer used. Signed-off-by: JmPotato <[email protected]>
1 parent 9b4433d commit 9822378

File tree

11 files changed

+2
-254
lines changed

11 files changed

+2
-254
lines changed

cmd/pd-server/main.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ import (
4343
"github.com/tikv/pd/server/apiv2"
4444
"github.com/tikv/pd/server/config"
4545
"github.com/tikv/pd/server/join"
46-
47-
// register microservice API
48-
_ "github.com/tikv/pd/pkg/mcs/resourcemanager/server/install"
49-
_ "github.com/tikv/pd/pkg/mcs/scheduling/server/install"
50-
_ "github.com/tikv/pd/pkg/mcs/tso/server/install"
5146
)
5247

5348
const (

pkg/mcs/metastorage/server/install/install.go

Lines changed: 0 additions & 29 deletions
This file was deleted.

pkg/mcs/registry/registry.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ import (
2828
bs "github.com/tikv/pd/pkg/basicserver"
2929
)
3030

31-
var (
32-
// ServerServiceRegistry is the global grpc service registry.
33-
ServerServiceRegistry = NewServerServiceRegistry()
34-
)
35-
3631
// ServiceBuilder is a function that creates a grpc service.
3732
type ServiceBuilder func(bs.Server) RegistrableService
3833

pkg/mcs/resourcemanager/server/install/install.go

Lines changed: 0 additions & 32 deletions
This file was deleted.

pkg/mcs/scheduling/server/grpc_service.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,13 @@ func (dummyRestService) ServeHTTP(w http.ResponseWriter, _ *http.Request) {
5252
w.Write([]byte("not implemented"))
5353
}
5454

55-
// ConfigProvider is used to get scheduling config from the given
56-
// `bs.server` without modifying its interface.
57-
type ConfigProvider any
58-
5955
// Service is the scheduling grpc service.
6056
type Service struct {
6157
*Server
6258
}
6359

6460
// NewService creates a new scheduling service.
65-
func NewService[T ConfigProvider](svr bs.Server) registry.RegistrableService {
61+
func NewService(svr bs.Server) registry.RegistrableService {
6662
server, ok := svr.(*Server)
6763
if !ok {
6864
log.Fatal("create scheduling server failed")

pkg/mcs/scheduling/server/install/install.go

Lines changed: 0 additions & 32 deletions
This file was deleted.

pkg/mcs/tso/server/grpc_service.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,13 @@ func (dummyRestService) ServeHTTP(w http.ResponseWriter, _ *http.Request) {
4848
w.Write([]byte("not implemented"))
4949
}
5050

51-
// ConfigProvider is used to get tso config from the given
52-
// `bs.server` without modifying its interface.
53-
type ConfigProvider any
54-
5551
// Service is the TSO grpc service.
5652
type Service struct {
5753
*Server
5854
}
5955

6056
// NewService creates a new TSO service.
61-
func NewService[T ConfigProvider](svr bs.Server) registry.RegistrableService {
57+
func NewService(svr bs.Server) registry.RegistrableService {
6258
server, ok := svr.(*Server)
6359
if !ok {
6460
log.Fatal("create tso server failed")

pkg/mcs/tso/server/install/install.go

Lines changed: 0 additions & 32 deletions
This file was deleted.

server/server.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,6 @@ func CreateServer(ctx context.Context, cfg *config.Config, services []string, le
296296
}
297297
// New way to register services.
298298
s.registry = registry.NewServerServiceRegistry()
299-
failpoint.Inject("useGlobalRegistry", func() {
300-
s.registry = registry.ServerServiceRegistry
301-
})
302299
s.registry.RegisterService("MetaStorage", ms_server.NewService)
303300
s.registry.RegisterService("ResourceManager", rm_server.NewService[*Server])
304301
// Register the microservices REST path.

tests/integrations/mcs/resourcemanager/resource_manager_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ import (
4848
"github.com/tikv/pd/pkg/utils/typeutil"
4949
"github.com/tikv/pd/tests"
5050
"github.com/tikv/pd/tests/integrations/mcs/utils"
51-
52-
// Register Service
53-
_ "github.com/tikv/pd/pkg/mcs/registry"
54-
_ "github.com/tikv/pd/pkg/mcs/resourcemanager/server/install"
5551
)
5652

5753
func TestMain(m *testing.M) {

0 commit comments

Comments
 (0)