diff --git a/server/server.go b/server/server.go index a4a93de..a4b6cbc 100644 --- a/server/server.go +++ b/server/server.go @@ -14,6 +14,7 @@ func New(addr string) server.Server { registry.RegisterService(new(dRPC.DiscoveryService), "") sh := NewServerHandler(addr, registry) + sh.workersChan = make(chan struct{}, 10) s := server.NewServer(sh) diff --git a/server/server_handlers.go b/server/server_handlers.go index 6044cb7..3dd02fe 100644 --- a/server/server_handlers.go +++ b/server/server_handlers.go @@ -4,11 +4,10 @@ import ( "io" "git.loafle.net/commons_go/rpc" - "git.loafle.net/commons_go/server" "git.loafle.net/commons_go/server/ipc" ) -func NewServerHandler(addr string, registry rpc.Registry) ServerHandler { +func NewServerHandler(addr string, registry rpc.Registry) *ServerHandlers { sh := &ServerHandlers{ registry: registry, } @@ -17,16 +16,23 @@ func NewServerHandler(addr string, registry rpc.Registry) ServerHandler { return sh } -type ServerHandler interface { - server.ServerHandler -} - type ServerHandlers struct { ipc.ServerHandlers - registry rpc.Registry + registry rpc.Registry + workersChan chan struct{} } func (sh *ServerHandlers) Handle(remoteAddr string, rwc io.ReadWriteCloser, stopChan chan struct{}) { + contentType := "json" + + for { + sh.registry.Invoke(contentType, rwc, rwc, nil, nil) + + select { + case <-stopChan: + return + } + } }