-
Notifications
You must be signed in to change notification settings - Fork 194
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 simple Streams on DatabaseViews, fix multi-dao changelistener #320
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #320 +/- ##
===========================================
- Coverage 81.47% 81.43% -0.04%
===========================================
Files 59 59
Lines 1506 1503 -3
===========================================
- Hits 1227 1224 -3
Misses 279 279
Continue to review full report at Codecov.
|
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.
Thanks for these changes! Until we have proper query parsing in place, this seems to be a good solution!
Can you please mark the area for the fix? I had trouble finding it 🙏
7fd841c
to
d2539a0
Compare
Do you have an estimative when streams on views will be released? |
Not exactly but maybe soon. There are just some tests left to do which I will try to tackle tomorrow. vitusortner will review again afterwards, although there shouldn't be major issues left, so this would then be ready to be merged. I don't know if there are plans for a new release. But as mentioned, this is just a (possibly runtime-intensive)stopgap solution until I'm finished with integrating the sqlparser, which will do query-analysis to be more efficient when updating the Stream. |
Query-analysis will be awesome! I am waiting for it! |
@vitusortner I noticed that we actually don't test streams quite the right way. Floor's Streams will re-execute the query as soon someone will start to Listen (which is right this way), but that also means that each expect(actual, emits([anything])); in the tests just starts listening and reexecutes the query, not actually looking if an event was fired independently. Previously fired events will be discarded if no-one is actually listening. This means that our Stream tests are just checking if the insert/update/delete query got executed, not if the stream fired. For the new tests added here I'm using expect(actual, emitsInOrder([firstResult,secondResult])); at the start of the test, which will keep the stream open and actually checks the stream output. When doing this I noticed that some queries will be executed together before the re-execution of the Stream Query fires, meaning that some events get "lost" and other events will then get a double update. For that I introduced a new helper function that will introduce artificial wait times to let floor reexecute the SELECT query before the test starts the next database action. I'll push that soon. |
e1d8d7c
to
b0b237f
Compare
The last commit is not really necessary... you decide if you want it :) |
Good find! Thanks |
some quick fixes Co-authored-by: Vitus <[email protected]>
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.
Looking good 🥇 I'm excited to see this getting merged into the main branch. I'll also create a new release containing these changes in the next days.
As Codecov is blocking this PR from getting merged, I suggest that I'll merge it if you give your go?
yes please :) |
Like I explained on the slack, here is a prototype for Queries with the result
Stream<X>
where X is a@DatabaseView
.As it won't detect the dependencies of each
DatabaseView
, it simply updates theStream
s of all views if any entity was updated. If a library user is frequently changing his entities while having one particularly intensive view (like a join) as aStream
, it will get quite resource-heavy even if the entity and theDatabaseView
of theStream
are not related at all. But its better than nothing.Of course, I think we should strive to make the
Stream
s ofDatabaseView
s better by making them aware of the entities they depend on but as mentioned previously this can get very complex.I also fixed a related issue where
Stream
s ofEntity
E in DAO B were only updated by insert/update/delete methods in DAO C if there was another query of a Stream of E in C because Streams were only tracked separately for each DAO even if thechangeListener
was database-global.TODO:
I'll finish this up if you agree on the concept, @vitusortner .