Add context timeouts for third-party requests
Some checks failed
/ golint (push) Failing after 3m56s
Some checks failed
/ golint (push) Failing after 3m56s
Avoid hanging a goroutine for a long time.
This commit is contained in:
parent
2093ea74c4
commit
15d8966971
11 changed files with 80 additions and 5 deletions
|
|
@ -3,6 +3,7 @@ package geocode
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/stadia"
|
||||
|
|
@ -17,6 +18,9 @@ type AutocompleteResult struct {
|
|||
}
|
||||
|
||||
func Autocomplete(ctx context.Context, org *models.Organization, address string) ([]*AutocompleteResult, error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, 15*time.Second)
|
||||
defer cancel()
|
||||
|
||||
req := stadia.RequestGeocodeAutocomplete{
|
||||
Text: address,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue