mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-05-08 04:20:59 -05:00
feat: limit concurrent processing of thumbnail requests
This commit is contained in:
@@ -16,13 +16,14 @@ type Option func(o *Options)
|
||||
|
||||
// Options defines the available options for this package.
|
||||
type Options struct {
|
||||
Namespace string
|
||||
Logger log.Logger
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
Metrics *metrics.Metrics
|
||||
Flags []cli.Flag
|
||||
TraceProvider trace.TracerProvider
|
||||
Namespace string
|
||||
Logger log.Logger
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
Metrics *metrics.Metrics
|
||||
Flags []cli.Flag
|
||||
TraceProvider trace.TracerProvider
|
||||
MaxConcurrentRequests int
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
@@ -81,3 +82,10 @@ func TraceProvider(traceProvider trace.TracerProvider) Option {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MaxConcurrentRequests provides a function to set the MaxConcurrentRequests option.
|
||||
func MaxConcurrentRequests(val int) Option {
|
||||
return func(o *Options) {
|
||||
o.MaxConcurrentRequests = val
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ func Server(opts ...Option) (http.Service, error) {
|
||||
svc.Middleware(
|
||||
middleware.RealIP,
|
||||
middleware.RequestID,
|
||||
ocismiddleware.Throttle(options.MaxConcurrentRequests),
|
||||
ocismiddleware.Version(
|
||||
options.Config.Service.Name,
|
||||
version.GetString(),
|
||||
|
||||
Reference in New Issue
Block a user