ing
This commit is contained in:
parent
df4f9465fc
commit
5f10acb5e9
11
external/grpc/client.go
vendored
11
external/grpc/client.go
vendored
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user