Skip to content
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

Shared streams: Allow subscribing after reflector is created #1630

Open
howardjohn opened this issue Nov 7, 2024 · 0 comments
Open

Shared streams: Allow subscribing after reflector is created #1630

howardjohn opened this issue Nov 7, 2024 · 0 comments

Comments

@howardjohn
Copy link

Would you like to work on this feature?

maybe

What problem are you trying to solve?

I would like to subscribe to a shared stream after a reflector is created. Unlike the example here, I do not know ahead of times how many times I will need to subscribe, and I may want to subscribe later on in the process (for instance, after I win leader election for a subcontroller).

This is how client-go informers behave, for instance, which can register multiple event handlers dynamically. Note they can also de-register them, which his something we may need to consider (presumably by Dropping them?)

Describe the solution you'd like

Either reflect_shared returns an object (not impl stream) that can subscribe(), reflect_shared doesn't take ownership of Writer, or writer has a fn get_subscriber(&self) -> ThingICanCallSubscriberOn

Describe alternatives you've considered

Build my own abstraction on top. This is tricky because we need the ability for the stream to consist of [objects that already exist,..., new events coming in after we started].

In theory you could do this by doing store.state() and getting the initial snapshot, then adding any updates after that. However, there is a race condition here. client-go does this, but they are able to lock the primary stream/store while they do this.

Documentation, Adoption, Migration Strategy

No response

Target crate for feature

kube-runtime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant