Since Engine API holds different session context (Sync Agent & Web App) it's required to do a commit before doing a query. Improve session handling to avoid this.
start two engine-api instances (one as sync node, one as main node)
post e.g. playlogs to the main node, while the sync node is running --> it should also be logged to the sync node
post e.g. playlogs to the main node, while the sync node is not running --> after the post start the sync node, it should start the background sync job and correctly sync the missing playlog(s) from the main node
If there are not exceptions in the logs and everything synced correctly, you got the session handling right.
Reproduced scenario above - seems to work now after doing some refactoring. There's one thread-related exception left when the database file is not present and must be created first - so merging after fixing that.
Finally got it running using sqlite, postgres and the federation scenario. Playlog is synced as expected* but there's one issue left I can't explain right now:
Seems like the sync node should init the PlayLog with camelCase keys, while the actual implementation provides snake_case keys. So adding the synced Playlog fails until at least trackStart is defined (which is non-null and thus required for successful committing).
To verify the fix of the multithreaded issue, I added* !24 (27c53f54) as a temp workaround.
So just need to resolve why the camelcase conversion doesn't work automatically - and ideas?