Allow stan protocol to set native *stan.Msg as a context value#658
Conversation
v2/client/invoker.go
Outdated
| return fallback | ||
| } | ||
|
|
||
| return ctx |
There was a problem hiding this comment.
changes to this function means that if MessageContext.Context() returns nil, then fallback is returned, whereas previously it would return nil.
Not sure if we can do this as it may be a breaking change, however I'd say this is safer since using a nil context is typically a bad idea anyway.
There was a problem hiding this comment.
I'm ok with this change, thus as you outlined before, using another context is a breaking change
|
An alternative approach, but not sure of the consequences: Is there a reason why Lines 45 to 52 in 93f9fa1 |
AFAIR I pass |
v2/client/invoker.go
Outdated
| return fallback | ||
| } | ||
|
|
||
| return ctx |
There was a problem hiding this comment.
I'm ok with this change, thus as you outlined before, using another context is a breaking change
|
I think we should not propagate the whole stan messages, but only the metadata we're interested in. How does it sounds? |
Sure, the three things which come to mind are: Do you think these should be standard context options and the getters/setters somewhere in the core SDK, or keep them contained within the |
Let's keep them in the stan package, since they are very protocol specific |
d377766 to
6565456
Compare
|
OK, I've updated this PR to expose a new context decorator which can be used with your new Thoughts? |
slinkydeveloper
left a comment
There was a problem hiding this comment.
That's good! Can you add the godocs to the methods?
6565456 to
e3bda64
Compare
slinkydeveloper
left a comment
There was a problem hiding this comment.
One last thing, can you add a small fancy test for it? Just add it to the actual test an "assert" that MsgMetadata is not empty
…ge metadata Signed-off-by: dan-j <5727701+dan-j@users.noreply.github.com>
e3bda64 to
6fbcac0
Compare
|
Added tests with a valid |
…ge metadata (cloudevents#658) Signed-off-by: dan-j <5727701+dan-j@users.noreply.github.com> Signed-off-by: Aneesh Puttur <aneeshputtur@gmail.com>
See #657
This is an approach which doesn't introduce any breaking changes, if users do nothing their
.Receive()functions will receive the samectxobject they always have, however using the newPropogateContext()option will override it.I'm going to add some comments to other parts of the codebase in this MR because I think I have an alternative approach, but needs discussion
Signed-off-by: dan-j 5727701+dan-j@users.noreply.github.com