rgw/admin: use shared AWS SigV4 signer in API client - #1314
Conversation
Instantiating a single-use signer per request is wasteful, resulting in an additional 35 allocs per request, in addition to a small speed overhead. Signed-off-by: Daniel Swarbrick <daniel.swarbrick@gmail.com>
|
I would also highly recommend moving the However, this would effectively constitute a breaking change, as it would no longer be possible to change the access key / secret key after instantiating the API client. To this I would argue that it was never a very good idea to export credentials on the API struct in the first place. |
| SecretKey string | ||
| Endpoint string | ||
| HTTPClient HTTPClient | ||
| signer *v4.Signer |
There was a problem hiding this comment.
All other fields in this struct are public. For consistency, should this field also be public?
(You could argue that the other fields should have been private but unfortunately that's in the past)
There was a problem hiding this comment.
I think it's fairly standard practice in Go to only export struct members if necessary. It's generally a bad idea to export pointers.
Can we provide a new "preferred" function that does this w/o removing the old way and breaking the API? Regardless, this comment feels like it deserves it's own issue where we can discuss ideas w/o further distracting from the current topic. |
If we're going to make a bigger departure from the current implementation, then I would suggest adding the auth via a I see that this |
anoopcs9
left a comment
There was a problem hiding this comment.
The change itself lgtm.
One minor note: since signer is only set in New(), anyone building API{} directly via the exported fields will now panic on the first request. Probably a non-issue since New() is the intended path and I don't see anyone constructing it directly - but if we want to be safe, either a lazy if api.signer == nil fallback in call() or a short doc comment on API noting New() is required would cover it.
I've created #1325 for further discussions. |
Instantiating a single-use signer per request is wasteful, resulting in an additional 35 allocs per request, in addition to a small speed overhead.
Checklist
//go:build ceph_previewmake api-updateto record new APIs