-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathoptions.go
41 lines (32 loc) · 1.19 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* Copyright (c) New Cloud Technologies, Ltd. 2013-2022.
* Author: Vitaly Isaev <vitaly.isaev@myoffice.team>
* License: https://github.com/newcloudtechnologies/memlimiter/blob/master/LICENSE
*/
package memlimiter
import (
"github.com/newcloudtechnologies/memlimiter/backpressure"
"github.com/newcloudtechnologies/memlimiter/stats"
)
// Option - MemLimiter constructor options.
type Option interface {
anchor()
}
type backpressureOperatorOption struct {
val backpressure.Operator
}
func (b *backpressureOperatorOption) anchor() {}
// WithBackpressureOperator allows client to provide customized backpressure.Operator;
// that's especially useful when implementing backpressure logic on the application side.
func WithBackpressureOperator(val backpressure.Operator) Option {
return &backpressureOperatorOption{val: val}
}
type serviceStatsSubscriptionOption struct {
val stats.ServiceStatsSubscription
}
func (s serviceStatsSubscriptionOption) anchor() {
}
// WithServiceStatsSubscription allows client to provide own implementation of service stats subscription.
func WithServiceStatsSubscription(val stats.ServiceStatsSubscription) Option {
return &serviceStatsSubscriptionOption{val: val}
}