ing
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"log"
|
||||
)
|
||||
|
||||
type DiscoveryService struct {
|
||||
}
|
||||
|
||||
func (ds *DiscoveryService) Start() {
|
||||
log.Print("DiscoveryService.Start")
|
||||
}
|
||||
@@ -2,16 +2,10 @@ package server
|
||||
|
||||
import (
|
||||
"git.loafle.net/commons_go/rpc"
|
||||
"git.loafle.net/commons_go/rpc/protocol/json"
|
||||
"git.loafle.net/commons_go/server"
|
||||
|
||||
dRPC "git.loafle.net/overflow/overflow_discovery/server/rpc"
|
||||
)
|
||||
|
||||
func New(addr string) server.Server {
|
||||
registry := rpc.NewRegistry()
|
||||
registry.RegisterCodec(json.NewCodec(), "json")
|
||||
registry.RegisterService(new(dRPC.DiscoveryService), "")
|
||||
func New(addr string, registry rpc.Registry) server.Server {
|
||||
|
||||
sh := NewServerHandler(addr, registry)
|
||||
sh.workersChan = make(chan struct{}, 10)
|
||||
|
||||
@@ -26,12 +26,17 @@ type ServerHandlers struct {
|
||||
func (sh *ServerHandlers) Handle(remoteAddr string, rwc io.ReadWriteCloser, stopChan chan struct{}) {
|
||||
contentType := "json"
|
||||
|
||||
Loop:
|
||||
for {
|
||||
sh.registry.Invoke(contentType, rwc, rwc, nil, nil)
|
||||
if err := sh.registry.Invoke(contentType, rwc, rwc, nil, nil); nil != err && sh.IsClientDisconnect(err) {
|
||||
stopChan <- struct{}{}
|
||||
break Loop
|
||||
}
|
||||
|
||||
select {
|
||||
case <-stopChan:
|
||||
return
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user