@@ -31,14 +31,14 @@ import (
31
31
// GCERateLimiter implements cloud.RateLimiter
32
32
type GCERateLimiter struct {
33
33
// Map a RateLimitKey to its rate limiter implementation.
34
- rateLimitImpls map [* cloud.RateLimitKey ]flowcontrol.RateLimiter
34
+ rateLimitImpls map [cloud.RateLimitKey ]flowcontrol.RateLimiter
35
35
}
36
36
37
37
// NewGCERateLimiter parses the list of rate limiting specs passed in and
38
38
// returns a properly configured cloud.RateLimiter implementation.
39
39
// Expected format of specs: {"[version].[service].[operation],[type],[param1],[param2],..", "..."}
40
40
func NewGCERateLimiter (specs []string ) (* GCERateLimiter , error ) {
41
- rateLimitImpls := make (map [* cloud.RateLimitKey ]flowcontrol.RateLimiter )
41
+ rateLimitImpls := make (map [cloud.RateLimitKey ]flowcontrol.RateLimiter )
42
42
// Within each specification, split on comma to get the operation,
43
43
// rate limiter type, and extra parameters.
44
44
for _ , spec := range specs {
@@ -91,7 +91,7 @@ func (l *GCERateLimiter) rateLimitImpl(key *cloud.RateLimitKey) flowcontrol.Rate
91
91
// Since the passed in key will have the ProjectID field filled in, we need to
92
92
// create a copy which does not, so that retreiving the rate limiter implementation
93
93
// through the map works as expected.
94
- keyCopy := & cloud.RateLimitKey {
94
+ keyCopy := cloud.RateLimitKey {
95
95
ProjectID : "" ,
96
96
Operation : key .Operation ,
97
97
Version : key .Version ,
@@ -101,21 +101,23 @@ func (l *GCERateLimiter) rateLimitImpl(key *cloud.RateLimitKey) flowcontrol.Rate
101
101
}
102
102
103
103
// Expected format of param is [version].[service].[operation]
104
- func constructRateLimitKey (param string ) (* cloud.RateLimitKey , error ) {
104
+ func constructRateLimitKey (param string ) (cloud.RateLimitKey , error ) {
105
+ var retVal cloud.RateLimitKey
105
106
params := strings .Split (param , "." )
106
107
if len (params ) != 3 {
107
- return nil , fmt .Errorf ("Must specify operation in [version].[service].[operation] format." )
108
+ return retVal , fmt .Errorf ("Must specify rate limit in [version].[service].[operation] format: %v" , param )
108
109
}
109
110
// TODO(rramkumar): Add another layer of validation here?
110
111
version := meta .Version (params [0 ])
111
112
service := params [1 ]
112
113
operation := params [2 ]
113
- return & cloud.RateLimitKey {
114
+ retVal = cloud.RateLimitKey {
114
115
ProjectID : "" ,
115
116
Operation : operation ,
116
117
Version : version ,
117
118
Service : service ,
118
- }, nil
119
+ }
120
+ return retVal , nil
119
121
}
120
122
121
123
// constructRateLimitImpl parses the slice and returns a flowcontrol.RateLimiter
0 commit comments