mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-10 16:44:10 +00:00
decouple commander interface from grpc
This commit is contained in:
6 files changed
+66
-56
No files matched your search
@@ -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