Commit graph

373 commits

Author SHA1 Message Date
Mike Nakhimovich
b14b307c2c
Miken/kill2 (#43)
* cleanup with no explanation

* collapse interfaces to only Store, remove parsers

* collapse interfaces to only Store, remove parsers
2019-11-03 15:06:12 -05:00
Mike Nakhimovich
ca8c957a2d
cleanup with no explanation (#42) 2019-11-03 14:53:38 -05:00
Yigit Boyar
ba22d0c66c Internal Store 3rd attempt (#35)
* WIP publish test

* add actor based implementation, seems the most promising

* add notes into channel manager as well

* use unlimited channel on the receiver to avoid launching to send

* carry over remaining subscribers into a new flow

* dispatch errors from upstream to all downstreams

* carry over all leftovers at once to avoid starting producer before all is added to the list

* handle swapping channel managers in the consumer

This CL fixes an issue where we wouldn't unsubscribe from the right channel if
the downstream is moved between channel managers due to not receiving any event
after registering.

I've also cleaned up dispatchError to close the channel with error instead of
passing it down as if it is value and throwing again

* allow live buffering

this adds a live buffering functionality to actor publish where
it only buffers if the upstream is still running

* remove logging

* move into src

* code cleanup, more comments

* first shot at new internal store, tests pass, code ugly

* tmp builder for real internal store, starting pipeline tests

* more wip in fixing pipeline store tests, a lot to cleanup

* all tests pass

* code cleanup

* move multiplexer inside store4

* lots of cleanup of unnecessary code

* release barriers that are not used

* don't use pipeline persister.
also fixed a barrier cleanup code in source of truth with barrier

* revert simple persister as flowable change
cleanup for clearstorememorytest

* close multiplexers in fetcher controller when not used

* code style fixes
2019-11-03 10:41:32 -05:00
Yigit Boyar
e9d6a91d83 Merge PersisterPipeline code path (#34)
This CL avoids having two different codepaths based on whether
we skip disk cache or not. It should eventually make it easier
to implement sharing, if we decide to do it here
2019-10-02 13:24:36 -04:00
Yigit Boyar
915bd7d4d7 StoreResponse (#33)
* Introduce StoreResponse

This CL changes Pipeline API to dispatch StoreResponse instead of Output.
It will allow us to add more metadata into it and also handle things like
source attribution and/or loading state.

This CL only makes the tests pass, does not do anything for actually dispatching
loading state

* first shot at adding a loading state

This CL adds proper StoreResponse to the built in pipelines such
that they can merge information between network and disk.

It needs some cleanup and PipelinePersister's merging logic is
fairly complicated but i couldn't yet find a simpler way to achieve it

* Add more tests to pipeline

Also fixed a bug in cached where it would emit cached value as
Loading even if no refresh is requested

* fix room sample after rebase

* Update the room sample to support refresh

Also some code cleanup in PipelinePersister

* code cleanup

* explain network + disk flow

* Change StoreResponse for plan D

This CL changes store response to act like plan D described here:
https://paper.dropbox.com/doc/Streaming-Data-How-To--AkwrNu0A7\~BikNOP2m20\~R2_AQ-oLBV39GrNimqGDe1vNQMb

Now StoreResponse has 3 types: Data, Error, Loading and each of these have an  field.
Loading and Error does not carry over last data anymore, instead, it is expected downstream
to merge them for UI, if desired.

This change makes Store more verbose but i think it is the right direction to allow
developer to expand on it as desired

* update AGP to 3.6-alpha11

* update pipeline store tests to check finite streams

This CL updates PipelineStoreTest to consume the whole stream
when we expect it to finish rather than limiting the number of
dispatched items

* update RoomActivity to respect new StoreResponse

* add search to room activity

* code cleanup
2019-09-22 11:23:59 -04:00
Yigit Boyar
567524380f
Add sample with room (#32)
This sample uses the new pipeline API directly.
To avoid changing Model.kt, the PostEntity is a weird wrapper
but i think it is fine.
2019-08-31 15:33:42 -07:00
Yigit Boyar
d27fb96384
update coroutines to flow stable (#31)
This PR updates coroutines to 1.3.0, kotlin to 1.3.50 and agp to 3.6.alpha08.

I've also cleaned all usage of FlowPreview
2019-08-27 18:43:48 -07:00
Yigit Boyar
92022be61a
let persister flow nullables to understand absense. (#30)
This is possibly temporary until we get a StoreResponse but may still keep
it as we wouldn't want to force everything to support StoreResponse
2019-08-15 23:24:21 +03:00
Yigit Boyar
d1ac07d8d0
Update the sample to use LifecycleScope and ListAdapter (#29) 2019-08-15 23:22:11 +03:00
Mike Nakhimovich
d86c6573da
Yigit fixes another thing (KeyTracker) (#27)
* Updated coroutines to RC02 and fix Flow invariance

This PR fixes an invariance problem in side collect where it was
creating a scope and emitting from there.

* Fix KeyTracker not to lose emissions

KeyTracker would lose some emissions if they happen in rapid succession
between different keys. This new implementation maintains a separate
channel for each key to avoid that. Since we now create a channel per key,
we also need to track and clean them up to avoid consuming too much memory
2019-08-11 21:34:18 -04:00
Mike Nakhimovich
80e834d536
remove clearMemory, upgrade coroutines (#20)
* remove clearMemory, upgrade coroutines

* rebase, pr comments

* fix build

* fix build

* convert more tests to testScope

* few more conversions
2019-08-11 21:27:36 -04:00
Yigit Boyar
9d8aec74e3 Updated coroutines to RC02 and fix Flow invariance (#25)
This PR fixes an invariance problem in side collect where it was
creating a scope and emitting from there.
2019-08-11 07:49:32 -04:00
Yigit Boyar
309b08e176 Move more tests to TestCoroutineScope (#24)
These are tests that worked as is so this is a dummy conversion
2019-08-06 08:24:24 -04:00
Yigit Boyar
33ced189bc
Get rid of unused scope in NoOpPersister (#22)
This PR fixes an issue in NoOpPersister where it was using a CoroutineScope w/o
really needing one as there wasn't any actual deferred work going on. As a side
effect of that, it was flaking the StoreTest.

After this change, the test does not flake aynmore (tried by setting test to be re-run
until failure
2019-08-04 13:10:02 -07:00
Yigit Boyar
1ef805fa73 Stream only (#19)
* try delegaitng get calls to steam

* WIP handle null

This CL changes pipeline persister to handle null reader response to fetch.
This is WIP, need another fix before it can be used

* move StoreTest and StoreWithParserTest to coroutines testing lib

The test coroutine scope checks for any remaining jobs at the end of a test
which helped us find two bugs (#17, #18) both of which were discovered when
i tried to move this tests to the TestCoroutineScope after the streamOnly
change.
This change completes the move to avoid further regressions. Eventually,
we should move all tests

* remove unused get method from PipelineStore
2019-08-03 18:43:54 -04:00
Yigit Boyar
c82421104e
Fix key tracker (#18)
* Fix KeyTracker subscription order

This PR fixes a race condition where if the SimplePersisterAsFlowable's write
is called inside a reader, reader wouldn't be notified again

* Fix StreamOneKeyTest

This test was passing by mistake :/. Right now, when we create the backport
Store from a Pipeline, the  method skips memory cache but uses
disk cache. This test was not initializing the disk cache w/ empty value,
which meant the initial read would get first value as if it is cached and
then would also get the new value.'
The test didn't fail before because KeyTracker had a concurrency but where
it missed 1 invalidation call
2019-08-03 01:37:46 -07:00
Yigit Boyar
550eb18f48
Fix side collect (#17)
This PR fixes a bug in side-collect where it was not cancelling the side
collection when main flow stops.
It still does not handle the case where side collect fails but that can only be fixed when we have error handling.

Needed to move the method to a non-private place to be able to write tests :/
2019-08-02 05:27:03 -07:00
Yigit Boyar
645cbc1ef5
StoreRequest (#15)
StoreRequest to encapsulate the get/stream into an object that can be passed down/modified/scaled.

The suspend cache APIs became a bit weird due to supporting both implementations. We can clean it up once we have only 1 implementation.
2019-07-25 21:04:06 -07:00
Fabio Collini
b7c4dbdebf Removed extra generic (#14) 2019-07-18 09:47:30 -07:00
fabioCollini
e63c6bbef8 Revert "Removed extra generic"
This reverts commit 1d912ea8
2019-07-17 08:43:24 +02:00
fabioCollini
1d912ea898 Removed extra generic 2019-07-17 08:41:41 +02:00
Yigit Boyar
1ba634e7c3 [DO NOT MERGE] Pipeline Implementation (#13)
pipeline API
2019-07-15 21:01:09 -04:00
Yigit Boyar
dc9b1bd51c
Suspend cache (#8)
This PR adds a cache implementation that has all APIs as suspend functions.
It uses guava's cache under the hood and handles query deduplication in a custom
Entry type that we keep in the cache
2019-07-02 07:25:36 -07:00
Fabio Collini
823dbcc3e2
Fix inflight definition and create new builder (#2)
* AGP 3.5.0-beta05

* Inflight as constructor argument

* New builder class

* Rename addPersister to persister

* Rename addParser to parser

* Rename addCache to cache
2019-07-01 08:36:40 +02:00
Yigit Boyar
8cf3ec1dcc
Merge pull request #7 from friendlyrobotnyc/mike/optimizeCacheLoader
make cache  use function in builder rather than  in each call
2019-06-30 20:50:11 -07:00
DigitalBuddha
b560d6d503 make cache use function in builder rather than in each call 2019-06-30 18:01:18 -04:00
Fabio Collini
58cdc5420d REFRESH_ON_STALE managed using a new scope (#6) 2019-06-30 13:14:22 -04:00
DigitalBuddha
7a0398ddf4 Merge remote-tracking branch 'origin/master' 2019-06-30 12:38:52 -04:00
DigitalBuddha
b72122a5e5 fix tests 2019-06-30 12:38:46 -04:00
Brian Plummer
5664208277
Merge pull request #3 from yigit/move-to-androidx
Move dependencies to AndroidX
2019-06-30 11:42:43 -04:00
Brian Plummer
5b3b1b03f2
Merge branch 'master' into move-to-androidx 2019-06-30 11:42:03 -04:00
Brian Plummer
c55bc6708e
Merge pull request #4 from friendlyrobotnyc/tech/circleCISetup
test of circle ci
2019-06-30 11:24:45 -04:00
Brian Plummer
6ebeea26f3 point readme to core repo 2019-06-30 11:20:01 -04:00
Yigit Boyar
25ef7dc72d Move dependencies to AndroidX 2019-06-30 06:18:07 -07:00
Fabio Collini
91217c8fa8 RealInternalStore refactoring (#1)
* AGP 3.5.0-beta04

* Stream implementation defined in the interface

* New class StoreWrapper

* Delete StoreBuilder

* Rename plus methods

* Move stalePolicy to Persister

* Simplify code

* Move inflight request management to a new class

* Move cache management to a new class

* Move wrappers to new package

* Delete StoreWrapper class

* New test

* Restored old versions

* Restored old versions

* Restored old versions

* Restored old versions

* Restored old versions

* Restored old versions

* Add runCatching to ignore exceptions on persisters

* Backward compatible RealStoreBuilder implementation

* Fix tests
2019-06-29 19:49:47 -04:00
Brian Plummer
2f9dc95aa0 Merge remote-tracking branch 'r1remote/feature/coroutines' 2019-06-06 21:03:09 -04:00
Brian Plummer
727a17dd73 remove gitignore 2019-06-06 20:59:22 -04:00
Brian Plummer
2ac2dd1c9c remove license 2019-06-06 20:57:30 -04:00
Brian Plummer
83a07e3b87
Initial commit 2019-06-06 20:36:36 -04:00
Brian Plummer
df98e78043
Merge pull request #8 from friendlyrobotnyc/feature/clear
Remove deprecated and unused methods
2019-05-29 19:32:59 -04:00
fabioCollini
ae2576922c Fix tests 2019-05-29 09:14:21 +02:00
fabioCollini
53f823548c Removed extra RealInternalStore constructor 2019-05-29 08:46:35 +02:00
fabioCollini
1861992d69 Removed class delegates in RealInternalStore 2019-05-29 08:43:28 +02:00
fabioCollini
805b19c533 Removed getRefreshing method 2019-05-29 08:40:20 +02:00
fabioCollini
7958f3a0e0 Removed deprecated clear methods 2019-05-29 08:37:26 +02:00
Mike Nakhimovich
d2f35e48ad
Update PersistingStoreActivity.kt 2019-05-28 22:00:09 -04:00
Brian Plummer
8479076edd
Merge pull request #7 from friendlyrobotnyc/feature/reifiedParsers
Feature/reified parsers
2019-05-28 09:15:09 -04:00
Brian Plummer
e23b13583b comment out testMultiBarcode 2019-05-28 09:11:35 -04:00
Brian Plummer
60245460d7
Merge pull request #6 from friendlyrobotnyc/feature/fresh-only-on-network
Never returns cached data on fresh
2019-05-28 08:30:55 -04:00
Brian Plummer
3d1ebd751a reify gson, use jvm 1.8 for kotlin compile in sample 2019-05-28 08:17:23 -04:00