mirror of
https://github.com/foomo/gotsrpc.git
synced 2025-10-16 12:35:35 +00:00
132 lines
3.0 KiB
Go
132 lines
3.0 KiB
Go
// this file was auto generated by gotsrpc https://github.com/foomo/gotsrpc
|
|
package demo
|
|
|
|
import (
|
|
tls "crypto/tls"
|
|
nested "github.com/foomo/gotsrpc/demo/nested"
|
|
gorpc "github.com/valyala/gorpc"
|
|
)
|
|
|
|
type FooGoRPCClient struct {
|
|
client *gorpc.Client
|
|
}
|
|
|
|
func NewFooGoRPCClient(addr string, tlsConfig *tls.Config) *FooGoRPCClient {
|
|
client := &FooGoRPCClient{}
|
|
if tlsConfig == nil {
|
|
client.client = gorpc.NewTCPClient(addr)
|
|
} else {
|
|
client.client = gorpc.NewTLSClient(addr, tlsConfig)
|
|
}
|
|
client.Start()
|
|
return client
|
|
}
|
|
|
|
func (c *FooGoRPCClient) Start() {
|
|
c.client.Start()
|
|
}
|
|
|
|
func (c *FooGoRPCClient) Stop() {
|
|
c.client.Stop()
|
|
}
|
|
|
|
func (c *FooGoRPCClient) Hello(number int64) (retHello_0 int, clientErr error) {
|
|
req := HelloRequest{Number: number}
|
|
res, err := c.client.Call(req)
|
|
if err != nil {
|
|
clientErr = err
|
|
return
|
|
}
|
|
response := res.(HelloResponse)
|
|
return response.RetHello_0, nil
|
|
}
|
|
|
|
type DemoGoRPCClient struct {
|
|
client *gorpc.Client
|
|
}
|
|
|
|
func NewDemoGoRPCClient(addr string, tlsConfig *tls.Config) *DemoGoRPCClient {
|
|
client := &DemoGoRPCClient{}
|
|
if tlsConfig == nil {
|
|
client.client = gorpc.NewTCPClient(addr)
|
|
} else {
|
|
client.client = gorpc.NewTLSClient(addr, tlsConfig)
|
|
}
|
|
client.Start()
|
|
return client
|
|
}
|
|
|
|
func (c *DemoGoRPCClient) Start() {
|
|
c.client.Start()
|
|
}
|
|
|
|
func (c *DemoGoRPCClient) Stop() {
|
|
c.client.Stop()
|
|
}
|
|
|
|
func (c *DemoGoRPCClient) ExtractAddress(person *Person) (addr *Address, e *Err, clientErr error) {
|
|
req := ExtractAddressRequest{Person: person}
|
|
res, err := c.client.Call(req)
|
|
if err != nil {
|
|
clientErr = err
|
|
return
|
|
}
|
|
response := res.(ExtractAddressResponse)
|
|
return response.Addr, response.E, nil
|
|
}
|
|
|
|
func (c *DemoGoRPCClient) GiveMeAScalar() (amount nested.Amount, wahr nested.True, hier ScalarInPlace, clientErr error) {
|
|
req := GiveMeAScalarRequest{}
|
|
res, err := c.client.Call(req)
|
|
if err != nil {
|
|
clientErr = err
|
|
return
|
|
}
|
|
response := res.(GiveMeAScalarResponse)
|
|
return response.Amount, response.Wahr, response.Hier, nil
|
|
}
|
|
|
|
func (c *DemoGoRPCClient) Hello(name string) (reply string, err *Err, clientErr error) {
|
|
req := HelloRequest{Name: name}
|
|
res, err := c.client.Call(req)
|
|
if err != nil {
|
|
clientErr = err
|
|
return
|
|
}
|
|
response := res.(HelloResponse)
|
|
return response.Reply, response.Err, nil
|
|
}
|
|
|
|
func (c *DemoGoRPCClient) MapCrap() (crap map[string][]int, clientErr error) {
|
|
req := MapCrapRequest{}
|
|
res, err := c.client.Call(req)
|
|
if err != nil {
|
|
clientErr = err
|
|
return
|
|
}
|
|
response := res.(MapCrapResponse)
|
|
return response.Crap, nil
|
|
}
|
|
|
|
func (c *DemoGoRPCClient) Nest() (retNest_0 *nested.Nested, clientErr error) {
|
|
req := NestRequest{}
|
|
res, err := c.client.Call(req)
|
|
if err != nil {
|
|
clientErr = err
|
|
return
|
|
}
|
|
response := res.(NestResponse)
|
|
return response.RetNest_0, nil
|
|
}
|
|
|
|
func (c *DemoGoRPCClient) TestScalarInPlace() (retTestScalarInPlace_0 ScalarInPlace, clientErr error) {
|
|
req := TestScalarInPlaceRequest{}
|
|
res, err := c.client.Call(req)
|
|
if err != nil {
|
|
clientErr = err
|
|
return
|
|
}
|
|
response := res.(TestScalarInPlaceResponse)
|
|
return response.RetTestScalarInPlace_0, nil
|
|
}
|