-
Notifications
You must be signed in to change notification settings - Fork 1
Share BaggageContext across multiple NIO handlers #48
Comments
Some extra references: This would mirror the Netty feature of "attributes", which are:
In Netty a channel handler context It would seem this would want to be added to Do we want to also expose it form Channel but "make it automatically hop to the EL if needed"? I'm not sure we need it on channel tbh and on the context could be fine. Thanks in advance for any hints @weissi and @slashmo hopefully can have a stab at this. |
I think this sounds reasonable and we will need something like this accessible from SwiftNIO. As described above, I think we want the following properties:
So I could see adding something like Actual users would get it through something like // the code for the extension lives inside SwiftNIO so it can access the "private" `_core` property on channel.
extension ChannelHandlerContext {
var baggage: ... {
get {
return self.channel._core.baggage
}
set {
self.channel._core.baggage = newValue
}
}
Of course that would mean that SwiftNIO will need to depend on the actual My suggestion would be to implement the whole thing in a SwiftNIO draft pull request and to propose it that way. I'm only suggesting to do this as a PR to SwiftNIO because after the BaggageContext type is created, I don't think there's much work in SwiftNIO itself at all actually. If you disagree and think that this would be lots of work to create the PR and you'd like to discuss it before writing the code, that's totally cool too. In that case I'd recommend a forums post or a github issue. Let me also CC @Lukasa, @glbrntt, @Davidde94, @normanmaurer How does that sound to everybody? |
Agreed on all of the above :-) Indeed should not be too much work; and a Draft PR likely good. I'm guessing though it would not be merged for months (at-least end of GSoC + "maturing" + accepting by SSWG of the baggage type etc) -- sanity checking you don't mind such lingering around PR. WIP PR is good enough for us to proceed prototyping -- we can depend on the branch after all :) re:
Just sanity checking on this one (as I don't think we need it AFAICS) so should be fine to skip. @Lukasa mentioned when we chatted that it may be useful to also offer on channel and "make it safe" using the |
Yeah, just gives us something concrete to discuss.
I don't mind it at all, can't speak for the others. But our oldest open PR is from July 2019 in the This is important enough that I'd also be open to make this a branch on
We could but then we'd need to pick one of those options:
Both of those aren't great I think because
If useful, I'd see that as a natural extension that can be done at any time. And also I'd make it read only: Don't think someone outside of the pipeline should just write to it :) |
Nah, private is good enough I think. We'll iterate a bit this way and see how things fit. Good observation about the read only if we ever exposed it on Channel :) Agreed on not adding anything except the minimum as well. |
Is there a schedule for that? :-D I made PoC tracing for AWS Lambda handler, it would be great pass context/baggage in channel, |
What is "that" specifically -- you mean baggage being merged into an actual NIO release? An actual merge can only happen after it goes through SSWG things, NIO team are happy with it and it is stable enough to not cause versioning trouble for NIO, a rough guesstimate would be a few months I guess; One month to finish the GSoC phase, some wiggle time for SSWG and NIO feedback rounds and then it's likely good. What would actually help to make it happen (and quicker, and safer) is real use cases, such as the one you posted, doing the following:
|
awesome, this is exactly what I asked about |
Let me try to use it from Would be great if was synced with NIO master, currently its:
If it works well and given ti will take give or take few months before it will be merged, maybe it could land in |
Currently, there's no way of sharing
BaggageContext
across multiple NIO channel handlers. This means, each handler would have to create a newBaggageContext
(like in this example) which eliminates the ability for context propagation across handlers in the same channel pipeline.@ktoso & I thought about adding a new
baggage
property to theChannelHandlerContext
so that aBaggageContext
can be created in the outer most channel handler, set on theContext
, and then be accessed in later channel handlers. This would probably also mean that NIO itself would have to depend on theBaggageContext
library.cc @weissi I'd love to get your input on this as well. I'm also happy to to move this over to the NIO repo once we have a general idea on how to make this integration happen 😊
The text was updated successfully, but these errors were encountered: