overflow_server_app/external/grpc/client.go
crusader 24f1d2c389 ing
2018-03-26 23:47:55 +09:00

36 lines
707 B
Go

package grpc
import (
"context"
"fmt"
"strings"
ooas "git.loafle.net/overflow/overflow_api_server/golang"
)
func Exec(ctx context.Context, method string, params []string) (string, error) {
if nil == grpcClient {
return "", fmt.Errorf("App: GRPC Pool is not initialized")
}
// var client interface{}
var err error
// if client, err = grpcPool.Get(); nil != err {
// return "", err
// }
// defer grpcPool.Put(client)
sm := strings.Split(method, ".")
si := &ooas.ServerInput{
Target: sm[0],
Method: sm[1],
Params: params,
}
var so *ooas.ServerOutput
if so, err = grpcClient.(ooas.OverflowApiServerClient).Exec(ctx, si); nil != err {
return "", err
}
return so.Result, nil
}