Initializing a channel's pipeline in a ChannelFactory
#13687
-
Hello! I'm trying to figure out if it's practical (or advisable) to try to perform non-trivial channel pipeline initialization inside a As a greatly simplified example, let's say I'm working with a third-party library that uses a plaintext protocol, and we'd really strongly prefer to have it use TLS (or, as another example to avoid getting too focused on the specifics of TLS, a proxy). The library doesn't provide a direct way for us to customize channel pipelines, but it does accept a custom I've had some mixed results with early experiments, and I'm realizing that I'm wading into territory where somebody with more experience can just say more about the design intent and whether or not this is a terrible idea. So is this a terrible idea? If it's doable, are there any pitfalls I should avoid or best practices I should adopt? Thanks kindly! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
The ChannelFactory is not a good place to initialise channels, because you'll be modifying the channel before it's registered with the event loop. If any part of the initialisation then wants to do delayed or scheduled work, it might break. You might be interested in something like #13565 as an alternative path forward. Those callbacks get a chance to modify the pipeline after its normal initialisation. |
Beta Was this translation helpful? Give feedback.
The ChannelFactory is not a good place to initialise channels, because you'll be modifying the channel before it's registered with the event loop. If any part of the initialisation then wants to do delayed or scheduled work, it might break. You might be interested in something like #13565 as an alternative path forward. Those callbacks get a chance to modify the pipeline after its normal initialisation.