Skip to content

Commit

Permalink
set timeout to farmerbot rmb calls
Browse files Browse the repository at this point in the history
  • Loading branch information
rawdaGastan committed Jul 2, 2024
1 parent 5f4abcc commit 6a4d007
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/provider/scheduler/farmer_bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ import (
)

const (
rmbTimeout = 40
FarmerBotVersionAction = "farmerbot.farmmanager.version"
FarmerBotFindNodeAction = "farmerbot.nodemanager.findnode"
)

func (s *Scheduler) hasFarmerBot(ctx context.Context, farmID uint32) bool {
ctx, cancel := context.WithTimeout(ctx, rmbTimeout)
defer cancel()

info, err := s.getFarmInfo(ctx, farmID)
if err != nil {
return false
Expand All @@ -32,6 +36,9 @@ func (s *Scheduler) hasFarmerBot(ctx context.Context, farmID uint32) bool {
}

func (n *Scheduler) farmerBotSchedule(ctx context.Context, r *Request) (uint32, error) {
ctx, cancel := context.WithTimeout(ctx, rmbTimeout)
defer cancel()

info, err := n.getFarmInfo(ctx, r.FarmID)
if err != nil {
return 0, errors.Wrapf(err, "failed to get farm %d info", r.FarmID)
Expand Down

0 comments on commit 6a4d007

Please sign in to comment.