producer: Integrate context.Context with publishing #365
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.
This PR sets out to resolve #360 with the integration of context.Context in the
nsq.Producer
. In order to maintain backwards compatibility, new methods were added that have names with the suffixWithContext
. These new methods mostly correspond to those that a client would use to publish messages and they adhere to context timeouts/deadlines. Once the deadline has been reached, an error will be returned to the client and the givenProducerTransaction
will be dropped/not published, all while keeping the connection tonsqd
alive.An overview of the new methods added are below:
nsq.Conn
nsq.Producer
The idea here being that these
WithContext
methods would essentially replace the existing ones eventually, which would be a breaking/major version change forgo-nsq
.