From 5f10acb5e970c464be213b54e7f2570392ad432b Mon Sep 17 00:00:00 2001 From: crusader Date: Thu, 22 Mar 2018 22:57:27 +0900 Subject: [PATCH] ing --- external/grpc/client.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/external/grpc/client.go b/external/grpc/client.go index 9733c58..a4e4624 100644 --- a/external/grpc/client.go +++ b/external/grpc/client.go @@ -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 }