This commit is contained in:
crusader
2017-10-26 21:55:55 +09:00
parent 1481ab4a7f
commit 44bc4f51d8
12 changed files with 310 additions and 38 deletions

View File

@@ -0,0 +1,12 @@
package rpc
import (
"log"
)
type DiscoveryService struct {
}
func (ds *DiscoveryService) Start() {
log.Print("DiscoveryService.Start")
}

21
server/server.go Normal file
View File

@@ -0,0 +1,21 @@
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), "")
sh := NewServerHandler(addr, registry)
s := server.NewServer(sh)
return s
}

32
server/server_handlers.go Normal file
View File

@@ -0,0 +1,32 @@
package server
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 {
sh := &ServerHandlers{
registry: registry,
}
sh.Addr = addr
return sh
}
type ServerHandler interface {
server.ServerHandler
}
type ServerHandlers struct {
ipc.ServerHandlers
registry rpc.Registry
}
func (sh *ServerHandlers) Handle(remoteAddr string, rwc io.ReadWriteCloser, stopChan chan struct{}) {
}