go-control-plane icon indicating copy to clipboard operation
go-control-plane copied to clipboard

Move the cache watch API from channels to interfaces

Open jpeach opened this issue 3 years ago • 4 comments

When you register a watch on a cache entry using CreateWatch the caller has to pass in a channel to receive the notification. This approach makes both the caller and the cache responsible for channel buffer management (i.e. it will deadlock if the buffer fiils), and precludes notification designs that aren't channels (e.g. appending to a queue).

Consider changing the API to allow the caller to pass in a notification interface. This means that if a caller chooses to implement notifications using channels it can, and the cache doesn't need to care about that. If a caller needs a different kind of notification, it can do that too.

UInfortunately, this would break everyone's code, so needs some thought about migration and perhaps a default implementation.

xref #503

jpeach avatar Oct 21 '21 22:10 jpeach

I like the thought @jpeach. Can you drop a comment here with what the notification interface might look like?

alecholmez avatar Oct 26 '21 15:10 alecholmez

I like the thought @jpeach. Can you drop a comment here with what the notification interface might look like?

Sure, probably next week. In the slack commentary someone mentioned that the Java xDS library used a notification interface, so it might be worth following that.

jpeach avatar Oct 27 '21 22:10 jpeach

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

github-actions[bot] avatar Nov 27 '21 00:11 github-actions[bot]

This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.

github-actions[bot] avatar Dec 04 '21 00:12 github-actions[bot]