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"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
ooas "git.loafle.net/overflow/overflow_api_server/golang"
|
ooas "git.loafle.net/overflow/overflow_api_server/golang"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var execMtx sync.RWMutex
|
||||||
|
|
||||||
func Exec(ctx context.Context, method string, params []string) (string, error) {
|
func Exec(ctx context.Context, method string, params []string) (string, error) {
|
||||||
if nil == grpcClient {
|
if nil == grpcClient {
|
||||||
return "", fmt.Errorf("App: GRPC Client is not initialized")
|
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],
|
Method: sm[1],
|
||||||
Params: params,
|
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
|
return "", err
|
||||||
}
|
}
|
||||||
|
execMtx.RUnlock()
|
||||||
|
|
||||||
return so.Result, nil
|
return so.Result, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user