Skip to content

Commit

Permalink
fix(fmc): handle too many requests performed
Browse files Browse the repository at this point in the history
  • Loading branch information
bl4ko committed Feb 18, 2025
1 parent 29aa06a commit 45c855b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/source/fmc/client/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,15 @@ func (fmcc *FMCClient) MakeRequest(
}
defer resp.Body.Close()

if resp.StatusCode == http.StatusTooManyRequests {
fmcc.Logger.Info(
fmcc.Ctx,
"Too many requests performed. FMC allows only 120 requests per miniute. Sleeping for a minute",
)
time.Sleep(1 * time.Minute)
continue
}

// Process the response if it's not a 401
if resp.StatusCode != http.StatusOK {
// Extract and include the response body in the error message
Expand Down
2 changes: 2 additions & 0 deletions internal/source/fmc/fmc.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ func (fmcs *FMCSource) Init() error {
return fmt.Errorf("create FMC client: %s", err)
}

fmcs.Name2NBInterface = make(map[string]*objects.Interface)

initFunctions := []func(*client.FMCClient) error{
fmcs.initObjects,
}
Expand Down

0 comments on commit 45c855b

Please sign in to comment.