Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #125 from aandryashin/master
Browse files Browse the repository at this point in the history
Fixed hardcoded timeout
  • Loading branch information
vania-pooh authored Aug 27, 2018
2 parents e242370 + d8d82f5 commit 185dedd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
var (
listen string
selenoidUri string
timeout time.Duration
period time.Duration

startTime = time.Now()
Expand Down Expand Up @@ -86,6 +87,7 @@ func showVersion() {
func init() {
flag.StringVar(&listen, "listen", ":8080", "host and port to listen on")
flag.StringVar(&selenoidUri, "selenoid-uri", "http://localhost:4444", "selenoid uri to fetch data from")
flag.DurationVar(&timeout, "timeout", 3*time.Second, "response timeout, e.g. 5s or 1m")
flag.DurationVar(&period, "period", 5*time.Second, "data refresh period, e.g. 5s or 1m")
flag.BoolVar(&version, "version", false, "Show version and exit")
flag.Parse()
Expand All @@ -102,7 +104,9 @@ func main() {
signal.Notify(stop, syscall.SIGTERM, syscall.SIGINT)

go sse.Tick(broker, func(ctx context.Context, br sse.Broker) {
status, err := selenoid.Status(ctx, selenoidUri)
timedCtx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
status, err := selenoid.Status(timedCtx, selenoidUri)
if err != nil {
log.Printf("can't get status (%s)\n", err)
br.Notify([]byte(`{ "errors": [{"msg": "can't get status"}] }`))
Expand Down
6 changes: 1 addition & 5 deletions selenoid/selenoid.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"net/http"
"time"
)

/* -------------- *
Expand Down Expand Up @@ -102,11 +101,8 @@ func Status(ctx context.Context, baseUrl string) ([]byte, error) {
return nil, err
}

timedCtx, cancel := context.WithTimeout(ctx, 1*time.Second)
defer cancel()

var state State
if err = httpDo(ctx, req.WithContext(timedCtx), func(resp *http.Response, err error) error {
if err = httpDo(ctx, req.WithContext(ctx), func(resp *http.Response, err error) error {
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion web/src/containers/Capabilities/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ driver = Selenium::WebDriver.for(:remote,
caps := selenium.Capabilities{"browserName": "${browser}", "version": "${version}"}
driver, err := selenium.NewRemote(caps, "${origin}/wd/hub")
if err != nil {
panic("create selenium session: %v\\n", err)
panic("create selenium session: %v\n", err)
}
defer driver.Quit()
`
Expand Down

0 comments on commit 185dedd

Please sign in to comment.