Skip to content
This repository has been archived by the owner on Sep 12, 2019. It is now read-only.

Commit

Permalink
Use http.Client with Timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekn committed Jul 19, 2017
1 parent c9a8f7a commit 5465f31
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
20 changes: 14 additions & 6 deletions src/github.com/stellar/gateway/bridge/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,28 @@ func NewApp(config config.Config, migrateFlag bool) (app *App, err error) {

requestHandler := handlers.RequestHandler{}

federationClient := &federation.Client{
HTTP: http.DefaultClient,
StellarTOML: stellartoml.DefaultClient,
httpClientWithTimeout := http.Client{
Timeout: 10 * time.Second,
}

stellartomlClient := stellartoml.Client{
HTTP: &httpClientWithTimeout,
}

federationClient := federation.Client{
HTTP: &httpClientWithTimeout,
StellarTOML: &stellartomlClient,
}

err = g.Provide(
&inject.Object{Value: &requestHandler},
&inject.Object{Value: &config},
&inject.Object{Value: stellartoml.DefaultClient},
&inject.Object{Value: federationClient},
&inject.Object{Value: &stellartomlClient},
&inject.Object{Value: &federationClient},
&inject.Object{Value: &h},
&inject.Object{Value: &ts},
&inject.Object{Value: &paymentListener},
&inject.Object{Value: &http.Client{}},
&inject.Object{Value: &httpClientWithTimeout},
)

if err != nil {
Expand Down
21 changes: 15 additions & 6 deletions src/github.com/stellar/gateway/compliance/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
log "github.com/Sirupsen/logrus"
"net/http"
"os"
"time"

"github.com/facebookgo/inject"
"github.com/stellar/gateway/compliance/config"
Expand Down Expand Up @@ -62,9 +63,17 @@ func NewApp(config config.Config, migrateFlag bool) (app *App, err error) {

requestHandler := handlers.RequestHandler{}

federationClient := &federation.Client{
HTTP: http.DefaultClient,
StellarTOML: stellartoml.DefaultClient,
httpClientWithTimeout := http.Client{
Timeout: 10 * time.Second,
}

stellartomlClient := stellartoml.Client{
HTTP: &httpClientWithTimeout,
}

federationClient := federation.Client{
HTTP: &httpClientWithTimeout,
StellarTOML: &stellartomlClient,
}

err = g.Provide(
Expand All @@ -73,9 +82,9 @@ func NewApp(config config.Config, migrateFlag bool) (app *App, err error) {
&inject.Object{Value: &entityManager},
&inject.Object{Value: &repository},
&inject.Object{Value: &crypto.SignerVerifier{}},
&inject.Object{Value: stellartoml.DefaultClient},
&inject.Object{Value: federationClient},
&inject.Object{Value: &http.Client{}},
&inject.Object{Value: &stellartomlClient},
&inject.Object{Value: &federationClient},
&inject.Object{Value: &httpClientWithTimeout},
&inject.Object{Value: &handlers.NonceGenerator{}},
)

Expand Down

0 comments on commit 5465f31

Please sign in to comment.