-
Notifications
You must be signed in to change notification settings - Fork 0
Conversation
) | ||
|
||
type serviceQueues struct { | ||
config *Config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: taking a reference to the whole Config
seems unnecessary. Just copying the two limit settings is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was in two minds about it but decided to keep the pointer. It looks like both pointer and int
are 8 bytes on 64bit OS. So it's more efficient to use the pointer instead of two int
types.
This reverts commit 26ae3ab.
type serviceQueues struct { | ||
config *Config | ||
requestStates *sync.Map | ||
requestCount int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requestStates
is a map
. Why not use map's len
function instead of having a separate variable to track the map size?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See golang/go#20680.
Guess a len function on a current map is not preferred by the library developer. Java ConcurrentHashMap has the same concern about performance.
[ch14893]
Limit # of requests per service in addition to rate limiting at a per request level within a service