-
Notifications
You must be signed in to change notification settings - Fork 219
feat: add resource fetcher to CachingInboundEventSource #1428
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
The implementation looks good to me, could you add unit tests pls?
(Used in PerResourcePollingEventSource) This might be an interesting aspect of it, so the cleanup is called if custom resource is deleted. But the first fetching (maybe event an optional periodic fetching in the background might be some nice addition. But probably in an other PR :) |
That's already there.
Indeed, I make another PR but it's more complicated than it appears. Doing a period fetching will become no more than a PerResourcePolling (with inbound event on top to maybe get fresh date quicker) and it's not really what this event source should do IMHO. It should only fetch data in the cache when required and not update the cache proactively when it become stale. |
I know you will ask for but as there wasn't yet, I secretly hope you will not :) |
It should, I think operator should not deal at this point with servlets. |
Ahh nice.
Ok, agree, let's stay with the simple approach for now. |
It will be fetched by the getSecondaryResources ? What would be the race condition in this case ? Will it wait for the parrallel fetch to complete ?
|
verify(supplier, times(1)).fetchResources(eq(testCustomResource)); | ||
verify(eventHandler, never()).handleEvent(any()); | ||
|
||
source.handleResourceEvent(ResourceID.fromResource(testCustomResource), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@csviri Had to use the Set.of overload to avoid replacing the existing secondary. I guess the correct behavior should be additive.
source.handleResourceEvent(primaryID, a)
source.handleResourceEvent(primaryID, b)
source.handleResourceEvent(primaryID, c)
source.handleResourceDeleteEvent(primaryID, c)
source.getSecondaryResources(testCustomResource) // should return (a, b)
source.handleResourceEvent(primaryID, Set.of(x,y))
source.getSecondaryResources(testCustomResource) // should return (x,y)
Wait for your confirmation and will add javadoc so it's more clear to the user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it should not be. At least that is not what I had on my mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably that would be good to document.
We could add overloaded or rather differerently named versions for additiveness, that would be useful for sure. But this is on purpose, now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@metacosm this LGTM, pls take a look if you will find some time. |
@scrocquesel could you rebase this to the next branch? and target next with the PR. |
Refs: #1424
Signature change but I doubt anyone use this event source as it is not currently working well.
Expiration needs a single fetcher by secondary, So I prefered seperating the behavior in a another event source as not everyone will need this.