This commit is contained in:
crusader 2017-10-26 22:18:20 +09:00
parent 44bc4f51d8
commit 97acdddce5
2 changed files with 14 additions and 7 deletions

View File

@ -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)

View File

@ -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
}
}
}