probe/client/container/container.go
crusader 92d7926d3f ing
2018-04-17 23:11:13 +09:00

46 lines
1.1 KiB
Go

package container
import (
crc "git.loafle.net/commons/rpc-go/client"
crpj "git.loafle.net/commons/rpc-go/protocol/json"
crr "git.loafle.net/commons/rpc-go/registry"
csc "git.loafle.net/commons/server-go/client"
cssnc "git.loafle.net/commons/server-go/socket/net/client"
)
func newConnector(name string) (*cssnc.Connectors, error) {
connector := &cssnc.Connectors{
Network: "tcp4",
Address: "",
}
connector.ReconnectInterval = 5
connector.ReconnectTryTime = 10
connector.MaxMessageSize = 4096
connector.ReadBufferSize = 4096
connector.WriteBufferSize = 4096
connector.PongTimeout = 60
connector.PingTimeout = 10
connector.PingPeriod = 9
connector.Name = name
return connector, nil
}
func newClient(name string, connector csc.Connector, services []interface{}) *crc.Client {
codec := crpj.NewClientCodec()
var rpcRegistry crr.RPCRegistry
if nil != services && 0 < len(services) {
rpcRegistry = crr.NewRPCRegistry()
rpcRegistry.RegisterServices(services...)
}
return &crc.Client{
Connector: connector,
Codec: codec,
RPCInvoker: rpcRegistry,
Name: name,
}
}