1234567891011121314151617181920212223242526272829 |
- package clientImpl
- import (
- "../example"
- "context"
- "google.golang.org/grpc"
- "time"
- )
- func Call(c example.FormatDataClient, input string) (string, error) {
- ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
- defer cancel()
- r, err := c.DoFormat(ctx, &example.Data{Text: input})
- if err != nil {
- println("could not greet", err.Error())
- return "", err
- }
- return r.Text, nil
- }
- func MakeCalls(cc *grpc.ClientConn, n int) {
- hwc := example.NewFormatDataClient(cc)
- for i := 0; i < n; i++ {
- r, err := Call(hwc, "this is load balancing example")
- if nil == err {
- println(r)
- }
- }
- }
|