-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement a non-blocking best-effort buffered broadcaster #2819
Comments
+1 to using generics here, we just haven't had a reason to use them more widely yet. @faec should we bring this into your current sprint or leave it for a future iteration? |
@cmacknz I think it makes sense to do in this sprint, or at least a solid first draft, since it's so tied in with concurrency issues in the |
Added to sprint 13 as part of the watcher shift, CC @pierrehilbert |
Followup based on preliminary prototyping: by far the largest part of this work will be integrating the new component with the I think it's still feasible and worthwhile, I just want to flag that this is necessarily going to be a significant change for the |
This definitely sounds valuable to me, +1 to getting early feedback before creating a giant review. If you can figure out how to split the review up that would probably also be valuable, maybe one PR for the new component and one for the uses of it? |
Following up on discussion in #2736, in an Agent team meeting it was decided to implement a best-effort buffered broadcast helper, and that
CoordinatorState
's subscription api should be the first client of this new component.Coordinator
orCoordinatorState
, depending on implementation details), and those sends should never(*) block. Values sent to the broadcaster become owned by the broadcaster (thus callers should make a deep copy before forwarding them if needed).(*) Full deterministic blocking prevention isn't possible, because if the provider starts sending new values in a spin lock it can potentially overwhelm the receiving goroutine even if its input channel is buffered. However, the receiver should never block for longer than the time to read the values from its input channel; in particular it should always prioritize receiving new values over sending old ones to subscribers.)
Given the nature of this component as potentially supporting different types (not just
Coordinator
state information), and the technical dependence on golang channels andreflect.Select
, it probably makes sense to implement the helper with a generic parameter. Generics exist but are not yet common in the Agent codebase, but a single-type container object like this is probably a reasonable place to deploy them. (Otherwise all applications of the component would probably have to operate onchan interface{}
and do explicit conversion at every endpoint, which is possible but would be nice to avoid.)The text was updated successfully, but these errors were encountered: