forked from kubernetes-sigs/aws-load-balancer-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
condition.go
32 lines (27 loc) · 788 Bytes
/
condition.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
package throttle
import (
"github.com/aws/aws-sdk-go/aws/request"
"regexp"
)
type Condition func(r *request.Request) bool
func matchService(serviceID string) Condition {
return func(r *request.Request) bool {
return r.ClientInfo.ServiceID == serviceID
}
}
func matchServiceOperation(serviceID string, operation string) Condition {
return func(r *request.Request) bool {
if r.Operation == nil {
return false
}
return r.ClientInfo.ServiceID == serviceID && r.Operation.Name == operation
}
}
func matchServiceOperationPattern(serviceID string, operationPtn *regexp.Regexp) Condition {
return func(r *request.Request) bool {
if r.Operation == nil {
return false
}
return r.ClientInfo.ServiceID == serviceID && operationPtn.Match([]byte(r.Operation.Name))
}
}