Init HTTP client on first use instead of module init #30
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ref: #29
This PR does not necessarily solve #29, but it will eliminate the problem for those who have azure-pipeline-go as a compile time dependency, but don't actually end up using it.
When assigning a variable at the module scope like:
The
createFunc()
call will be executed when your module is initialized anytime anybody imports your module before main() even gets called. IfcreateFunc()
is doing something that might hang or block, a downstream dependency will hang before their own main() even gets called simply by virtue of them taking a compile time dependency on you, whether or not they end up actually using your module or not.This patch removes this behavior for the default pipelineHTTPClient, instead opting to initialize this once the first time it is needed.