Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Adding timeout setting to snaptel
Browse files Browse the repository at this point in the history
  • Loading branch information
Iwan (Maciej Iwanowski) committed Jan 27, 2017
1 parent 8080135 commit bd290fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion cmd/snaptel/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ limitations under the License.

package main

import "github.com/urfave/cli"
import (
"time"

"github.com/urfave/cli"
)

var (

Expand Down Expand Up @@ -53,6 +57,11 @@ var (
Usage: "Path to a config file",
Value: "",
}
flTimeout = cli.DurationFlag{
Name: "timeout, t",
Usage: "Timeout to be set on HTTP request to the server",
Value: 10 * time.Second,
}

// Plugin flags
flPluginAsc = cli.StringFlag{
Expand Down
4 changes: 2 additions & 2 deletions cmd/snaptel/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func main() {
app.Name = "snaptel"
app.Version = gitversion
app.Usage = "The open telemetry framework"
app.Flags = []cli.Flag{flURL, flSecure, flAPIVer, flPassword, flConfig}
app.Flags = []cli.Flag{flURL, flSecure, flAPIVer, flPassword, flConfig, flTimeout}
app.Commands = append(commands, tribeCommands...)
sort.Sort(ByCommand(app.Commands))
app.Before = beforeAction
Expand All @@ -79,7 +79,7 @@ func main() {
// Run before every command
func beforeAction(ctx *cli.Context) error {
username, password := checkForAuth(ctx)
pClient, err = client.New(ctx.String("url"), ctx.String("api-version"), ctx.Bool("insecure"))
pClient, err = client.New(ctx.String("url"), ctx.String("api-version"), ctx.Bool("insecure"), client.Timeout(ctx.Duration("timeout")))
if err != nil {
return fmt.Errorf("%v", err)
}
Expand Down

0 comments on commit bd290fb

Please sign in to comment.