Skip to content

Commit

Permalink
feat: add rate limit middlewares for job (#3481)
Browse files Browse the repository at this point in the history
Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi authored Sep 4, 2024
1 parent 75d6242 commit c463f7f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions manager/config/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ const (
DefaultJobRateLimitFillInterval = 1 * time.Minute

// DefaultJobRateLimitCapacity is the default capacity for job rate limit.
DefaultJobRateLimitCapacity = 100
DefaultJobRateLimitCapacity = 10

// DefaultJobRateLimitQuantum is the default quantum for job rate limit.
DefaultJobRateLimitQuantum = 100
DefaultJobRateLimitQuantum = 10

// DefaultJobPreheatRegistryTimeout is the default timeout for requesting registry to get token and manifest.
DefaultJobPreheatRegistryTimeout = 1 * time.Minute
Expand Down
2 changes: 1 addition & 1 deletion manager/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func Init(cfg *config.Config, logDir string, service service.Service, database *
// TODO Add auth to the following routes and fix the tests.
// Job.
job := apiv1.Group("/jobs")
job.POST("", h.CreateJob)
job.POST("", middlewares.RateLimit(cfg.Job.RateLimit.FillInterval, cfg.Job.RateLimit.Capacity, cfg.Job.RateLimit.Quantum), h.CreateJob)
job.DELETE(":id", h.DestroyJob)
job.PATCH(":id", h.UpdateJob)
job.GET(":id", h.GetJob)
Expand Down

0 comments on commit c463f7f

Please sign in to comment.