2017-10-26 12:55:55 +00:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
2017-11-15 06:59:43 +00:00
|
|
|
crpj "git.loafle.net/commons_go/rpc/protocol/json"
|
2017-12-01 08:29:54 +00:00
|
|
|
crr "git.loafle.net/commons_go/rpc/registry"
|
2017-10-26 12:55:55 +00:00
|
|
|
"git.loafle.net/commons_go/server"
|
2017-11-15 06:59:43 +00:00
|
|
|
|
2017-12-04 09:37:39 +00:00
|
|
|
"git.loafle.net/overflow/overflow_discovery/service"
|
2017-10-26 12:55:55 +00:00
|
|
|
)
|
|
|
|
|
2017-11-15 06:59:43 +00:00
|
|
|
func New(addr string) server.Server {
|
2017-12-01 08:29:54 +00:00
|
|
|
rpcRegistry := crr.NewRPCRegistry()
|
2017-12-04 09:37:39 +00:00
|
|
|
service.RegisterRPC(rpcRegistry)
|
2017-11-15 06:59:43 +00:00
|
|
|
|
2017-11-29 05:19:36 +00:00
|
|
|
rpcSH := newRPCServletHandler(rpcRegistry)
|
|
|
|
rpcSH.RegisterCodec(crpj.Name, crpj.NewServerCodec())
|
2017-10-26 12:55:55 +00:00
|
|
|
|
2017-11-29 05:19:36 +00:00
|
|
|
socketHandler := newSocketHandler(rpcSH)
|
2017-10-26 12:55:55 +00:00
|
|
|
|
2017-11-29 05:19:36 +00:00
|
|
|
sh := newServerHandler(addr, socketHandler)
|
2017-11-01 06:35:03 +00:00
|
|
|
s := server.New(sh)
|
2017-10-26 12:55:55 +00:00
|
|
|
|
|
|
|
return s
|
|
|
|
}
|