You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// WithMessage adds the provided message to the provided context
79
79
// to add additional message that need to be used to context.
@@ -141,21 +141,21 @@ You can find list of returning error types for all existing throttlers in thrott
141
141
| context |`func NewThrottlerContext() Throttler`| Always throttless on *done* context.<br> - could return `ErrorInternal`; |
142
142
| panic |`func NewThrottlerPanic() Throttler`| Always panics with `ErrorInternal`. |
143
143
| each |`func NewThrottlerEach(threshold uint64) Throttler`| Throttles each periodic *i-th* call defined by the specified threshold.<br> - could return `ErrorThreshold`; |
144
-
| before |`func NewThrottlerBefore(threshold uint64) Throttler`| Throttles each call below the *i-th* call defined by the specified threshold.<br> - could return `ErrorThreshold`; |
145
-
| after |`func NewThrottlerAfter(threshold uint64) Throttler`| Throttles each call after the *i-th* call defined by the specified threshold.<br> - could return `ErrorThreshold`; |
144
+
| before |`func NewThrottlerBefore(threshold uint64) Throttler`| Throttles each call below the *i-th* call defined by the specified threshold.<br>Use `WithWeight` to override context call qunatity, 1 by default.<br> - could return `ErrorThreshold`; |
145
+
| after |`func NewThrottlerAfter(threshold uint64) Throttler`| Throttles each call after the *i-th* call defined by the specified threshold.<br>Use `WithWeight` to override context call qunatity, 1 by default.<br> - could return `ErrorThreshold`; |
146
146
| past |`func NewThrottlerPast(threshold time.Time) Throttler`| Throttles each call befor timestamp defined by the specified UTC time threshold.<br> - could return `ErrorThreshold`; |
147
147
| future |`func NewThrottlerFuture(threshold time.Time) Throttler`| Throttles each call after timestamp defined by the specified UTC time threshold.<br> - could return `ErrorThreshold`; |
148
148
| chance |`func NewThrottlerChance(threshold float64) Throttler`| Throttles each call with the chance *p* defined by the specified threshold.<br> Chance value is normalized to *[0.0, 1.0]* range.<br> Implementation uses secure `crypto/rand` as PRNG function.<br> - could return `ErrorThreshold`; |
149
149
| running |`func NewThrottlerRunning(threshold uint64) Throttler`| Throttles each call which exeeds the running quota *acquired - release**q* defined by the specified threshold.<br> - could return `ErrorThreshold`; |
150
150
| buffered |`func NewThrottlerBuffered(threshold uint64) Throttler`| Waits on call which exeeds the running quota *acquired - release**q* defined by the specified threshold until the running quota is available again. |
151
151
| priority |`func NewThrottlerPriority(threshold uint64, levels uint8) Throttler`| Waits on call which exeeds the running quota *acquired - release**q* defined by the specified threshold until the running quota is available again.<br> Running quota is not equally distributed between *n* levels of priority defined by the specified levels.<br> Use `func WithPriority(ctx context.Context, priority uint8) context.Context` to override context call priority, *1* by default. |
152
-
| timed |`func NewThrottlerTimed(threshold uint64, interval time.Duration, quantum time.Duration) Throttler`| Throttles each call which exeeds the running quota *acquired - release**q* defined by the specified threshold in the specified interval.<br> Periodically each specified interval the running quota number is reseted.<br> If quantum is set then quantum will be used instead of interval to provide the running quota delta updates.<br> - could return `ErrorThreshold`; |
152
+
| timed |`func NewThrottlerTimed(threshold uint64, interval time.Duration, quantum time.Duration) Throttler`| Throttles each call which exeeds the running quota *acquired - release**q* defined by the specified threshold in the specified interval.<br> Periodically each specified interval the running quota number is reseted.<br> If quantum is set then quantum will be used instead of interval to provide the running quota delta updates.<br>Use `WithWeight` to override context call qunatity, 1 by default.<br> - could return `ErrorThreshold`; |
153
153
| latency |`func NewThrottlerLatency(threshold time.Duration, retention time.Duration) Throttler`| Throttles each call after the call latency *l* defined by the specified threshold was exeeded once.<br> If retention is set then throttler state will be reseted after retention duration.<br> Use `func WithTimestamp(ctx context.Context, ts time.Time) context.Context` to specify running duration between throttler *acquire* and *release*.<br> - could return `ErrorThreshold`; |
154
154
| percentile |`func NewThrottlerPercentile(threshold time.Duration, capacity uint8, percentile float64, retention time.Duration) Throttler`| Throttles each call after the call latency *l* defined by the specified threshold was exeeded once considering the specified percentile.<br> Percentile values are kept in bounded buffer with capacity *c* defined by the specified capacity. <br> If retention is set then throttler state will be reseted after retention duration.<br> Use `func WithTimestamp(ctx context.Context, ts time.Time) context.Context` to specify running duration between throttler *acquire* and *release*.<br> - could return `ErrorThreshold`; |
155
155
| monitor |`func NewThrottlerMonitor(mnt Monitor, threshold Stats) Throttler`| Throttles call if any of the stats returned by provided monitor exceeds any of the stats defined by the specified threshold or if any internal error occurred.<br> Builtin `Monitor` implementations come with stats caching by default.<br> Use builtin `NewMonitorSystem` to create go system monitor instance.<br> - could return `ErrorInternal`;<br> - could return `ErrorThreshold`; |
156
156
| metric |`func NewThrottlerMetric(mtc Metric) Throttler`| Throttles call if boolean metric defined by the specified boolean metric is reached or if any internal error occurred.<br> Builtin `Metric` implementations come with boolean metric caching by default.<br> Use builtin `NewMetricPrometheus` to create Prometheus metric instance.<br> - could return `ErrorInternal`;<br> - could return `ErrorThreshold`; |
157
157
| enqueuer |`func NewThrottlerEnqueue(enq Enqueuer) Throttler`| Always enqueues message to the specified queue throttles only if any internal error occurred.<br> Use `func WithMessage(ctx context.Context, message interface{}) context.Context` to specify context message for enqueued message and `func WithMarshaler(ctx context.Context, mrsh Marshaler) context.Context` to specify context message marshaler.<br> Builtin `Enqueuer` implementations come with connection reuse and retries by default.<br> Use builtin `func NewEnqueuerRabbit(url string, queue string, retries uint64) Enqueuer` to create RabbitMQ enqueuer instance or `func NewEnqueuerKafka(net string, url string, topic string, retries uint64) Enqueuer` to create Kafka enqueuer instance.<br> - could return `ErrorInternal`; |
158
-
| adaptive |`func NewThrottlerAdaptive(threshold uint64, interval time.Duration, quantum time.Duration, step uint64, thr Throttler) Throttler`| Throttles each call which exeeds the running quota *acquired - release**q* defined by the specified threshold in the specified interval.<br> Periodically each specified interval the running quota number is reseted.<br> If quantum is set then quantum will be used instead of interval to provide the running quota delta updates.<br> Provided adapted throttler adjusts the running quota of adapter throttler by changing the value by *d* defined by the specified step, it subtracts *d^2* from the running quota if adapted throttler throttles or adds *d* to the running quota if it doesn't.<br> - could return `ErrorThreshold`; |
158
+
| adaptive |`func NewThrottlerAdaptive(threshold uint64, interval time.Duration, quantum time.Duration, step uint64, thr Throttler) Throttler`| Throttles each call which exeeds the running quota *acquired - release**q* defined by the specified threshold in the specified interval.<br> Periodically each specified interval the running quota number is reseted.<br> If quantum is set then quantum will be used instead of interval to provide the running quota delta updates.<br> Provided adapted throttler adjusts the running quota of adapter throttler by changing the value by *d* defined by the specified step, it subtracts *d^2* from the running quota if adapted throttler throttles or adds *d* to the running quota if it doesn't.<br>Use `WithWeight` to override context call qunatity, 1 by default.<br> - could return `ErrorThreshold`; |
159
159
| pattern |`func NewThrottlerPattern(patterns ...Pattern) Throttler`| Throttles if matching throttler from provided patterns throttles.<br> Use `func WithKey(ctx context.Context, key string) context.Context` to specify key for regexp pattern throttler matching.<br> `Pattern` defines a pair of regexp and related throttler.<br> - could return `ErrorInternal`;<br> - could return any underlying throttler error; |
160
160
| ring |`func NewThrottlerRing(thrs ...Throttler) Throttler`| Throttles if the *i-th* call throttler from provided list throttle.<br> - could return `ErrorInternal`;<br> - could return any underlying throttler error; |
161
161
| all |`func NewThrottlerAll(thrs ...Throttler) Throttler`| Throttles call if all provided throttlers throttle.<br> - could return `ErrorInternal`; |
0 commit comments