ing
This commit is contained in:
parent
1e66dddf55
commit
62cb95bd15
|
@ -1,14 +1,14 @@
|
||||||
package client
|
package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.loafle.net/commons_go/rpc"
|
|
||||||
crc "git.loafle.net/commons_go/rpc/client"
|
crc "git.loafle.net/commons_go/rpc/client"
|
||||||
"git.loafle.net/commons_go/rpc/protocol/json"
|
"git.loafle.net/commons_go/rpc/protocol/json"
|
||||||
|
crr "git.loafle.net/commons_go/rpc/registry"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewClientHandler(registry rpc.Registry) ClientHandler {
|
func NewClientHandler(rpcInvoker crr.RPCInvoker) ClientHandler {
|
||||||
ch := &ClientHandlers{}
|
ch := &ClientHandlers{}
|
||||||
ch.RPCRegistry = registry
|
ch.RPCInvoker = rpcInvoker
|
||||||
ch.Codec = json.NewClientCodec()
|
ch.Codec = json.NewClientCodec()
|
||||||
|
|
||||||
return ch
|
return ch
|
||||||
|
|
|
@ -16,6 +16,8 @@ func newSocketBuilder(address string) csc.SocketBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *SocketBuilders) Dial(network, address string) (net.Conn, error) {
|
func (sb *SocketBuilders) Dial(network, address string) (net.Conn, error) {
|
||||||
|
if 0 == sb.HandshakeTimeout {
|
||||||
|
return npipe.Dial(`\\.\pipe\` + address)
|
||||||
|
}
|
||||||
return npipe.DialTimeout(`\\.\pipe\`+address, sb.HandshakeTimeout)
|
return npipe.DialTimeout(`\\.\pipe\`+address, sb.HandshakeTimeout)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
import "git.loafle.net/commons_go/rpc"
|
import (
|
||||||
|
crr "git.loafle.net/commons_go/rpc/registry"
|
||||||
|
)
|
||||||
|
|
||||||
func RegisterRPC(registry rpc.Registry) {
|
func RegisterRPC(registry crr.RPCRegistry) {
|
||||||
registry.RegisterService(&DiscoveryService{}, "")
|
registry.RegisterService(&DiscoveryService{}, "")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.loafle.net/commons_go/rpc"
|
crr "git.loafle.net/commons_go/rpc/registry"
|
||||||
"git.loafle.net/commons_go/rpc/server"
|
"git.loafle.net/commons_go/rpc/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newRPCServletHandler(rpcRegistry rpc.Registry) server.ServletHandler {
|
func newRPCServletHandler(rpcInvoker crr.RPCInvoker) server.ServletHandler {
|
||||||
sh := &RPCServletHandlers{}
|
sh := &RPCServletHandlers{}
|
||||||
sh.RPCRegistry = rpcRegistry
|
sh.RPCInvoker = rpcInvoker
|
||||||
|
|
||||||
return sh
|
return sh
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
cr "git.loafle.net/commons_go/rpc"
|
|
||||||
crpj "git.loafle.net/commons_go/rpc/protocol/json"
|
crpj "git.loafle.net/commons_go/rpc/protocol/json"
|
||||||
|
crr "git.loafle.net/commons_go/rpc/registry"
|
||||||
"git.loafle.net/commons_go/server"
|
"git.loafle.net/commons_go/server"
|
||||||
|
|
||||||
"git.loafle.net/overflow/overflow_discovery/rpc"
|
"git.loafle.net/overflow/overflow_discovery/rpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func New(addr string) server.Server {
|
func New(addr string) server.Server {
|
||||||
rpcRegistry := cr.NewRegistry()
|
rpcRegistry := crr.NewRPCRegistry()
|
||||||
rpc.RegisterRPC(rpcRegistry)
|
rpc.RegisterRPC(rpcRegistry)
|
||||||
|
|
||||||
rpcSH := newRPCServletHandler(rpcRegistry)
|
rpcSH := newRPCServletHandler(rpcRegistry)
|
||||||
|
|
|
@ -38,7 +38,7 @@ func (sh *SocketHandlers) Init(serverCTX server.ServerContext) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sh *SocketHandlers) Handshake(serverCTX server.ServerContext, conn net.Conn) (id string) {
|
func (sh *SocketHandlers) Handshake(socketCTX server.SocketContext, conn net.Conn) (id string) {
|
||||||
return "discovery"
|
return "discovery"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user