mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-10-28 03:54:04 -04:00
decouple commander interface from grpc
This commit is contained in:
19
commander.go
19
commander.go
@@ -2,19 +2,11 @@ package core
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// ServiceRegistryCallback is a callback function for registering services.
|
||||
type ServiceRegistryCallback func(s *grpc.Server)
|
||||
|
||||
// Commander is a feature that accepts commands from external source.
|
||||
type Commander interface {
|
||||
Feature
|
||||
|
||||
// RegisterService registers a service into this Commander.
|
||||
RegisterService(ServiceRegistryCallback)
|
||||
}
|
||||
|
||||
type syncCommander struct {
|
||||
@@ -22,17 +14,6 @@ type syncCommander struct {
|
||||
Commander
|
||||
}
|
||||
|
||||
func (c *syncCommander) RegisterService(callback ServiceRegistryCallback) {
|
||||
c.RLock()
|
||||
defer c.RUnlock()
|
||||
|
||||
if c.Commander == nil {
|
||||
return
|
||||
}
|
||||
|
||||
c.Commander.RegisterService(callback)
|
||||
}
|
||||
|
||||
func (c *syncCommander) Start() error {
|
||||
c.RLock()
|
||||
defer c.RUnlock()
|
||||
|
||||
Reference in New Issue
Block a user