mirror of
https://github.com/foomo/gotsrpc.git
synced 2025-10-16 12:35:35 +00:00
43 lines
928 B
Go
43 lines
928 B
Go
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
|
|
|
|
package service
|
|
|
|
import (
|
|
tls "crypto/tls"
|
|
|
|
gorpc "github.com/valyala/gorpc"
|
|
)
|
|
|
|
type ServiceGoRPCClient struct {
|
|
Client *gorpc.Client
|
|
}
|
|
|
|
func NewServiceGoRPCClient(addr string, tlsConfig *tls.Config) *ServiceGoRPCClient {
|
|
client := &ServiceGoRPCClient{}
|
|
if tlsConfig == nil {
|
|
client.Client = gorpc.NewTCPClient(addr)
|
|
} else {
|
|
client.Client = gorpc.NewTLSClient(addr, tlsConfig)
|
|
}
|
|
return client
|
|
}
|
|
|
|
func (tsc *ServiceGoRPCClient) Start() {
|
|
tsc.Client.Start()
|
|
}
|
|
|
|
func (tsc *ServiceGoRPCClient) Stop() {
|
|
tsc.Client.Stop()
|
|
}
|
|
|
|
func (tsc *ServiceGoRPCClient) Hello(v string) (retHello_0 string, clientErr error) {
|
|
req := ServiceHelloRequest{V: v}
|
|
rpcCallRes, rpcCallErr := tsc.Client.Call(req)
|
|
if rpcCallErr != nil {
|
|
clientErr = rpcCallErr
|
|
return
|
|
}
|
|
response := rpcCallRes.(ServiceHelloResponse)
|
|
return response.RetHello_0, nil
|
|
}
|