[#50] Allow to set timeouts for native scenario

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
(cherry picked from commit 1337eed6df45492f1045541021e8b14a42c5a286)
This commit is contained in:
Evgenii Stratonikov 2022-12-21 13:04:08 +03:00 committed by Alex Vanin
parent d2541486ae
commit 88b2129b54
2 changed files with 5 additions and 3 deletions

View file

@ -51,7 +51,7 @@ func (n *Native) Exports() modules.Exports {
return modules.Exports{Default: n}
}
func (n *Native) Connect(endpoint, hexPrivateKey string) (*Client, error) {
func (n *Native) Connect(endpoint, hexPrivateKey string, dialTimeout, streamTimeout int) (*Client, error) {
var (
cli client.Client
pk *keys.PrivateKey
@ -73,7 +73,9 @@ func (n *Native) Connect(endpoint, hexPrivateKey string) (*Client, error) {
var prmDial client.PrmDial
prmDial.SetServerURI(endpoint)
prmDial.SetTimeout(5 * time.Second)
prmDial.SetTimeout(time.Duration(dialTimeout) * time.Second)
prmDial.SetStreamTimeout(time.Duration(streamTimeout) * time.Second)
err = cli.Dial(prmDial)
if err != nil {

View file

@ -17,7 +17,7 @@ const read_size = JSON.parse(open(__ENV.PREGEN_JSON)).obj_size;
// Select random gRPC endpoint for current VU
const grpc_endpoints = __ENV.GRPC_ENDPOINTS.split(',');
const grpc_endpoint = grpc_endpoints[Math.floor(Math.random() * grpc_endpoints.length)];
const grpc_client = native.connect(grpc_endpoint, '');
const grpc_client = native.connect(grpc_endpoint, '', __ENV.DIAL_TIMEOUT ? parseInt(__ENV.DIAL_TIMEOUT) : 5, __ENV.STREAM_TIMEOUT ? parseInt(__ENV.STREAM_TIMEOUT) : 15);
const registry_enabled = !!__ENV.REGISTRY_FILE;
const obj_registry = registry_enabled ? registry.open(__ENV.REGISTRY_FILE) : undefined;