Laravel - Multiple jobs with same rate limit with double time constrains

Viewed 26

I'm trying to setup a queue with two jobs (ImportAthleteActivitiesList,ProcessAthleteActivity) that are consuming the same 3rd party API. This API has both a 15min limits (100 requests) and a daily limit (1000 requests).

I was trying with no success two alternatives:

a) use the the RateLimiter facade's for method, in this case I will be able to configure the double time constrains but only for one job

RateLimiter::for('ProcessAthleteActivity', function ($job) { return [ Limit::perMinutes(1,2), // function perMinutes($decayMinutes, $maxAttempts) Limit::perDay(3), ]; });

I don't know how I would apply the same RateLimiter for both ImportAthleteActivitiesList andProcessAthleteActivity

b) use a job middleware for both jobs using Redis::throttle() but in this case I don't know how to apply a double time constrain to the throttle.

Can you please help me out?

Thanks

0 Answers
Related