@@ -31,10 +31,10 @@ func (f Factory) NewRateLimiter(rate settings.Setting[config.Rate]) (RateLimiter
3131
3232// MakeRateLimiter creates a RateLimiter for the given rate and configured by the Factory.
3333// If Meter is set, the following metrics will be emitted
34- // - rate.*.limit - float gauge
35- // - rate.*.burst - int gauge
36- // - rate.*.usage - int counter
37- // - rate.*.denied - int histogram
34+ // - rate.*.limit - float gauge
35+ // - rate.*.burst - int gauge
36+ // - rate.*.usage - int counter
37+ // - rate.*.denied - int histogram
3838func (f Factory ) MakeRateLimiter (rate settings.Setting [config.Rate ]) (RateLimiter , error ) {
3939 if rate .Scope == settings .ScopeGlobal {
4040 return f .globalRateLimiter (rate )
@@ -49,10 +49,11 @@ func (f Factory) NewTimeLimiter(timeout settings.Setting[time.Duration]) (TimeLi
4949
5050// MakeTimeLimiter returns a TimeLimiter for given timeout, and configured by the Factory.
5151// If Meter is set, the following metrics will be emitted
52- // - time.*.limit - float gauge
53- // - time.*.runtime - float gauge
54- // - time.*.success - int counter
55- // - time.*.timeout - int counter
52+ // - time.*.limit - float gauge
53+ // - time.*.runtime - float gauge
54+ // - time.*.success - int counter
55+ // - time.*.timeout - int counter
56+ //
5657// Note: Unit will be ignored. All TimeLimiters emit seconds as "s".
5758func (f Factory ) MakeTimeLimiter (timeout settings.Setting [time.Duration ]) (TimeLimiter , error ) {
5859 return f .newTimeLimiter (timeout )
@@ -65,10 +66,10 @@ func NewResourcePoolLimiter[N Number](f Factory, limit settings.Setting[N]) (Res
6566
6667// MakeResourcePoolLimiter returns a ResourcePoolLimiter for the given limit, and configured by the Factory.
6768// If Meter is set, the following metrics will be emitted
68- // - resource.*.limit - gauge
69- // - resource.*.usage - gauge
70- // - resource.*.amount - histogram
71- // - resource.*.denied - histogram
69+ // - resource.*.limit - gauge
70+ // - resource.*.usage - gauge
71+ // - resource.*.amount - histogram
72+ // - resource.*.denied - histogram
7273func MakeResourcePoolLimiter [N Number ](f Factory , limit settings.Setting [N ]) (ResourcePoolLimiter [N ], error ) {
7374 if limit .Scope == settings .ScopeGlobal {
7475 return newGlobalResourcePoolLimiter (f , limit )
@@ -78,21 +79,32 @@ func MakeResourcePoolLimiter[N Number](f Factory, limit settings.Setting[N]) (Re
7879
7980// MakeBoundLimiter returns a BoundLimiter for the given bound and configured by the Factory.
8081// If Meter is set, the following metrics will be emitted
81- // - bound.*.limit - gauge
82- // - bound.*.usage - histogram
83- // - bound.*.denied - histogram
82+ // - bound.*.limit - gauge
83+ // - bound.*.usage - histogram
84+ // - bound.*.denied - histogram
8485func MakeBoundLimiter [N Number ](f Factory , bound settings.Setting [N ]) (BoundLimiter [N ], error ) {
8586 return newBoundLimiter (f , bound )
8687}
8788
8889// MakeQueueLimiter returns a QueueLimiter for the given limit and configured by the Factory.
8990// If Meter is set, the following metrics will be emitted
90- // - queue.*.limit - int gauge
91- // - queue.*.usage - int gauge
92- // - queue.*.denied - int histogram
91+ // - queue.*.limit - int gauge
92+ // - queue.*.usage - int gauge
93+ // - queue.*.denied - int histogram
9394func MakeQueueLimiter [T any ](f Factory , limit settings.Setting [int ]) (QueueLimiter [T ], error ) {
9495 if limit .Scope == settings .ScopeGlobal {
9596 return newUnscopedQueue [T ](f , limit )
9697 }
9798 return newScopedQueue [T ](f , limit )
9899}
100+
101+ // MakeGateLimiter returns a GateLimiter for the given limit and configured by the factory.
102+ // If Meter is set, the following metrics will be emitted
103+ // - gate.*.limit - int gauge
104+ // - gate.*.usage - int counter
105+ // - gate.*.denied - int counter
106+ //
107+ // OPT: accept an interface for limit
108+ func MakeGateLimiter (f Factory , limit settings.SettingMap [bool ]) (GateLimiter , error ) {
109+ return newGateLimiter (f , limit )
110+ }
0 commit comments