X Tutup
Skip to content

Support for Objectify-context bound completeAllPendingFutures() calls (see https://github.com/objectify/objectify/issues/326)#398

Open
nbali wants to merge 3 commits intoobjectify:v5from
aliz-ai:objectify_context_bound_completeAllPendingFutures
Open

Support for Objectify-context bound completeAllPendingFutures() calls (see https://github.com/objectify/objectify/issues/326)#398
nbali wants to merge 3 commits intoobjectify:v5from
aliz-ai:objectify_context_bound_completeAllPendingFutures

Conversation

@nbali
Copy link

@nbali nbali commented Aug 14, 2018

No description provided.

@nbali
Copy link
Author

nbali commented Aug 14, 2018

@stickfigure fyi do not close #326 yet, I'm planning on adding evict functionality eventually as well

…f we are closing the last Objectify instance
@nbali nbali force-pushed the objectify_context_bound_completeAllPendingFutures branch from a1b92ac to 68cdc05 Compare August 14, 2018 15:31
@nbali
Copy link
Author

nbali commented Aug 29, 2018

@stickfigure fyi

@stickfigure
Copy link
Contributor

Under a deadline, gonna take a deeper look at it this weekend.

@nbali
Copy link
Author

nbali commented Sep 17, 2018

@stickfigure gently reminder :)

@stickfigure
Copy link
Contributor

I've taken a look at this patch and there's just something not quite right with it - information seems to be in the wrong place. Maybe we can restructure the data to accomplish your goal though.

You want all pending futures to be 'attached' to an Objectify instance, right? What if we just store them in the ObjectifyImpl and clear them on flush() instead of tracking them in a thread local? Would that work for your purposes?

@nbali
Copy link
Author

nbali commented Sep 20, 2018

That was my first instinct as well. Then I checked the code. PendingFutures might have been used without any Objectify instance present at all. If we would do that change it would break that functionality. For example "it is possible that CachingAsyncDatastoreService gets used - which utilizes this functionality - without any Objectify context".

@stickfigure
Copy link
Contributor

Oh good point. Let me ponder this for a day.

@nbali
Copy link
Author

nbali commented Oct 2, 2018

@stickfigure Have you come to any conclusion?

@stickfigure
Copy link
Contributor

Unfortunately I just fundamentally don't like this patch. The trigger future stuff was an ugly hack to begin with and this makes it waaaaay worse, to accommodate a use case that kinda seems like an abuse of the system to begin with.

That said, I'd like to accommodate you somehow. We just need to find another way, even if it means changing APIs. One possibility (that I haven't had the time to consider in depth) is that we can put the pending futures inside the AsyncCachingDatastoreService and give it a close() method. We'd need to permanently associate ACDS instances with Objectify instances rather than creating them ad hoc as they are right now, and it would require a minor version change (5.2) because the API changes (for folks using the cache directly).

What do you think? And are you interested in taking a stab at it? I am severely short of time right now.

@nbali
Copy link
Author

nbali commented Oct 18, 2018

That would limit the usability of TriggerFuture and PendingFutures. Right now they can be used without anything objectify related. I'm sure it wasn't an intended functionality, but it's not hard to imagine that people use it for every kind of async action that has a Future to ensure it finishes before the request does. So a complete revamp would break/remove this functionality.

On the other hand I see no issue with keeping a general TriggerFuture as it is now with the PendingFutures, and having ACDS-related trigger futures separated. So those would be closed when the Ofy instance/ACDS gets closed. The rest when the AsyncCacheFilter finishes.

What I can't see how it would be viable is that the ACDS wasn't a closeable until now. Ppl most likely used it like any other datastore service. So in order to make this work the ACDS should have an objectify-bound subclass that is closeable, and uses an internal list of futures to wait for, and the "original" general implementation, that would use the general pending future pool.

So based on this TBH I'm not convinced it would be cleaner without dropping functionality.

@stickfigure
Copy link
Contributor

TriggerFuture/PendingFutures has never been part of the "public" API of Objectify and can be eliminated without remorse.

I don't think there are very many people using the Objectify cache outside of Objectify. And for those that are, I wouldn't feel terrible about adding a close() requirement and removing the "you must install the AsyncCacheFilter" requirement. It would require a version bump to 5.2 but that's not terrible.

At any rate, it's a solution that would accommodate your use case without adding excessive technical debt.

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

Successfully merging this pull request may close these issues.

2 participants

X Tutup