This commit is contained in:
crusader 2018-03-22 22:57:27 +09:00
parent df4f9465fc
commit 5f10acb5e9

View File

@ -4,10 +4,13 @@ import (
"context"
"fmt"
"strings"
"sync"
ooas "git.loafle.net/overflow/overflow_api_server/golang"
)
var execMtx sync.RWMutex
func Exec(ctx context.Context, method string, params []string) (string, error) {
if nil == grpcClient {
return "", fmt.Errorf("App: GRPC Client is not initialized")
@ -26,10 +29,14 @@ func Exec(ctx context.Context, method string, params []string) (string, error) {
Method: sm[1],
Params: params,
}
var so *ooas.ServerOutput
if so, err = grpcClient.(ooas.OverflowApiServerClient).Exec(ctx, si); nil != err {
execMtx.RLock()
so, err := grpcClient.(ooas.OverflowApiServerClient).Exec(ctx, si)
if nil != err {
execMtx.RUnlock()
return "", err
}
execMtx.RUnlock()
return so.Result, nil
}