Closed johnbywater closed 11 months ago
Replacement for #159.
By the way your linting job isn't working. Look at the "Code formatting checks".
/home/runner/work/_temp/b5f8d893-83e1-4488-bb8d-4457e330c4a1.sh: line 1: goimports: command not found
Thank you @YoEight
Fixed: Fix race condition and overwriting when setting call credentials
I adjusted the way "basic auth" call credentials are implemented, so that (1) the client configuration is not updated, (2) the client configuration is fully processed into a map of headers, (3) the connection is not given any call credentials, (4) call credentials are passed into each call as call options, (5) if credentials are provided in the options when a client method is called by user then a new credentials object is constructed and used as one of the gRPC call options, and (6) otherwise if the client been configured with credentials then those are used as one of the gRPC call options.
This means that the "global" credentials are not overwritten by credentials provided when a client method is called, and there isn't a race condition between concurrent client method calls on the overwriting of the "global" credentials.
I need this because I'm working on a project that has CI which fails on race conditions, and it failed on this race condition. Looking at it I also realised the (likely) issue of overwriting "default" client configured call credentials with credentials passed when a user calls a method (what the race condition is all about).
By the way, this is also how the Python client works, by passing in either the method credentials or otherwise the client credentials, for each call. For example here and here and here etc, 25 times.