Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add request timeout #96

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ This README will provide directions for building, testing, and debugging that co

* NSM_NAME - A string value of network service client name (default "nsc")
* NSM_CONNECT_TO - A Network service Manager connectTo URL (default "unix:///var/lib/networkservicemesh/nsm.io.sock")
* NSM_CONNECT_TIMEOUT - A timeout to connect to Network service Manager (default 5s)
* NSM_CONNECT_TIMEOUT - A timeout to connect to Network Service Manager (default 5s)
denis-tingaikin marked this conversation as resolved.
Show resolved Hide resolved
* NSM_REQUEST_TIMEOUT - A timeout to request Network Service Endpoint (default 5m)
* NSM_MAX_TOKEN_LIFETIME - A token lifetime duration (default 24h)
* NSM_LABELS - A list of client labels with format key1=val1,key2=val2, will be used a primary list for network services
* NSM_MECHANISM - Default Mechanism to use, supported values "kernel", "vfio"
Expand Down
3 changes: 2 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020 Doc.ai and/or its affiliates.
// Copyright (c) 2020-2021 Doc.ai and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -38,6 +38,7 @@ type Config struct {
Name string `default:"nsc" desc:"Name of Network Service Client"`
ConnectTo url.URL `default:"unix:///var/lib/networkservicemesh/nsm.io.sock" desc:"url to connect to NSM" split_words:"true"`
ConnectTimeout time.Duration `default:"5s" desc:"timeout to connect to NSMgr" split_words:"true"`
RequestTimeout time.Duration `default:"5m" desc:"timeout to request NSE" split_words:"true"`
denis-tingaikin marked this conversation as resolved.
Show resolved Hide resolved
MaxTokenLifetime time.Duration `default:"24h" desc:"maximum lifetime of tokens" split_words:"true"`

Labels []string `default:"" desc:"A list of client labels with format key1=val1,key2=val2, will be used a primary list for network services" split_words:"true"`
Expand Down
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020 Doc.ai and/or its affiliates.
// Copyright (c) 2020-2021 Doc.ai and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -231,6 +231,10 @@ func RunClient(
}
nsmClient := nsmClientFactory(clients...)

var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(ctx, rootConf.RequestTimeout)
defer cancel()

// Performing nsmClient connection request
conn, err := nsmClient.Request(ctx, request)
if err != nil {
Expand Down