2017-11-27 11:54:15 +00:00
|
|
|
package client
|
|
|
|
|
2017-11-29 10:07:49 +00:00
|
|
|
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)
|
|
|
|
}
|