mirror of
https://github.com/foomo/gotsrpc.git
synced 2025-10-16 12:35:35 +00:00
made gorpc client public
This commit is contained in:
parent
c78f00ba6c
commit
99830b9e50
15
go.go
15
go.go
@ -632,7 +632,7 @@ func renderGoRPCServiceClients(services map[string]*Service, fullPackageName str
|
|||||||
// Client type
|
// Client type
|
||||||
g.l(`
|
g.l(`
|
||||||
type ` + clientName + ` struct {
|
type ` + clientName + ` struct {
|
||||||
client *gorpc.Client
|
Client *gorpc.Client
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
// Constructor
|
// Constructor
|
||||||
@ -640,20 +640,19 @@ func renderGoRPCServiceClients(services map[string]*Service, fullPackageName str
|
|||||||
func New` + clientName + `(addr string, tlsConfig *tls.Config) *` + clientName + ` {
|
func New` + clientName + `(addr string, tlsConfig *tls.Config) *` + clientName + ` {
|
||||||
client := &` + clientName + `{}
|
client := &` + clientName + `{}
|
||||||
if tlsConfig == nil {
|
if tlsConfig == nil {
|
||||||
client.client = gorpc.NewTCPClient(addr)
|
client.Client = gorpc.NewTCPClient(addr)
|
||||||
} else {
|
} else {
|
||||||
client.client = gorpc.NewTLSClient(addr, tlsConfig)
|
client.Client = gorpc.NewTLSClient(addr, tlsConfig)
|
||||||
}
|
}
|
||||||
client.Start()
|
|
||||||
return client
|
return client
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *` + clientName + `) Start() {
|
func (c *` + clientName + `) Start() {
|
||||||
c.client.Start()
|
c.Client.Start()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *` + clientName + `) Stop() {
|
func (c *` + clientName + `) Stop() {
|
||||||
c.client.Stop()
|
c.Client.Stop()
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
g.nl()
|
g.nl()
|
||||||
@ -679,9 +678,9 @@ func renderGoRPCServiceClients(services map[string]*Service, fullPackageName str
|
|||||||
g.l(`func (c *` + clientName + `) ` + method.Name + `(` + strings.Join(params, ", ") + `) (` + strings.Join(returns, ", ") + `) {`)
|
g.l(`func (c *` + clientName + `) ` + method.Name + `(` + strings.Join(params, ", ") + `) (` + strings.Join(returns, ", ") + `) {`)
|
||||||
g.l(`req := ` + service.Name + method.Name + `Request{` + strings.Join(args, ", ") + `}`)
|
g.l(`req := ` + service.Name + method.Name + `Request{` + strings.Join(args, ", ") + `}`)
|
||||||
if len(rets) > 0 {
|
if len(rets) > 0 {
|
||||||
g.l(`rpcCallRes, rpcCallErr := c.client.Call(req)`)
|
g.l(`rpcCallRes, rpcCallErr := c.Client.Call(req)`)
|
||||||
} else {
|
} else {
|
||||||
g.l(`_, rpcCallErr := c.client.Call(req)`)
|
g.l(`_, rpcCallErr := c.Client.Call(req)`)
|
||||||
}
|
}
|
||||||
g.l(`if rpcCallErr != nil {`)
|
g.l(`if rpcCallErr != nil {`)
|
||||||
g.l(`clientErr = rpcCallErr`)
|
g.l(`clientErr = rpcCallErr`)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user