This commit is contained in:
crusader
2017-11-29 19:07:49 +09:00
parent 8aa9dce840
commit 6ac6a2c21b
4 changed files with 39 additions and 30 deletions

View File

@@ -3,20 +3,13 @@ package client
import (
"git.loafle.net/commons_go/rpc"
"git.loafle.net/commons_go/rpc/client"
"git.loafle.net/commons_go/rpc/protocol"
)
func NewClientHandler(addr string, codec protocol.ClientCodec, notifyRegistry rpc.Registry) ClientHandler {
ch := &ClientHandlers{}
ch.addr = addr
ch.RPCRegistry = notifyRegistry
ch.Codec = codec
func New(addr string, registry rpc.Registry) client.Client {
return ch
}
type ClientHandlers struct {
client.ClientHandlers
addr string
ch := NewClientHandler(addr, registry)
c := client.New(ch)
return c
}

View File

@@ -1,2 +1,28 @@
package client
import (
"net"
"git.loafle.net/commons_go/rpc"
"git.loafle.net/commons_go/rpc/client"
"git.loafle.net/commons_go/rpc/protocol/json"
)
func NewClientHandler(addr string, registry rpc.Registry) ClientHandler {
ch := &ClientHandlers{}
ch.addr = addr
ch.RPCRegistry = registry
ch.Codec = json.NewClientCodec()
return ch
}
type ClientHandlers struct {
client.ClientHandlers
addr string
}
func (ch *ClientHandlers) Connect() (net.Conn, error) {
return net.Dial("unix", ch.addr)
}