Commit graph

125 commits

Author SHA1 Message Date
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
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
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
b72122a5e5 fix tests 2019-06-30 12:38:46 -04: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
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
fabioCollini
fddea54d32 Never returns cached data on fetch 2019-05-28 09:54:15 +02:00
Brian Plummer
7981500102
Merge pull request #3 from friendlyrobotnyc/feature/remove-getWithResult
Remove getWithResult and freshWithResult
2019-05-27 15:58:29 -04:00
Fabio Collini
7480d5a9c4 Convert filesystem classes to Kotlin (#4) 2019-05-27 15:41:04 -04:00
fabioCollini
e65f18a4f4 Remove getWithResult and freshWithResult 2019-05-27 20:47:58 +02:00
Fabio Collini
a7edcf2aca Flow<Pair<V, T>> as stream result (#2) 2019-05-27 12:26:55 -04:00
fabioCollini
b50c41a5f3 Merge branch 'feature/coroutines' into feature/flow
# Conflicts:
#	store/src/main/java/com/nytimes/android/external/store3/base/impl/RealInternalStore.kt
2019-05-27 16:55:48 +02:00
fabioCollini
ca62ca14a1 Restore code format 2019-05-27 16:55:09 +02:00
fabioCollini
c3c2055047 Invalidate inFlightRequests on errors 2019-05-27 16:28:51 +02:00
fabioCollini
141908e42f Fix duplicated fetch call on error 2019-05-27 16:08:02 +02:00
fabioCollini
e038fc991d Stream methods returning flows instead of ReceiveChannel 2019-05-27 15:52:25 +02:00
fabioCollini
927e77954a Coroutines 1.2.1 2019-05-21 22:57:14 +02:00
fabioCollini
015140fbf0 Fix some tests 2019-05-21 21:32:54 +02:00
fabioCollini
d4ce82c468 Convert classes to kotlin 2019-02-23 17:59:29 +01:00
fabioCollini
664f60b0d0 Removed rxjava usages 2019-02-23 16:59:01 +01:00
fabioCollini
7c2bbae59f Removed rxjava on store module 2019-02-23 15:50:31 +01:00
fabioCollini
e0cf396a10 Removed StoreRoom 2019-02-23 15:46:15 +01:00
fabioCollini
4b27b64d0e Convert classes to kotlin 2019-02-23 08:49:28 -05:00
fabioCollini
0ad60262f1 Convert CacheFactory to Kotlin 2019-02-23 08:37:56 -05:00
fabioCollini
34d028337e Fix tests 2019-02-23 08:24:55 -05:00
fabioCollini
fb4ee1992d Removed rx classes and fixed tests 2019-02-22 22:17:45 -05:00
fabioCollini
b2976719c1 Don't cache errors 2019-02-22 20:49:43 -05:00
fabioCollini
b7e77512cd Fix some tests 2019-02-20 23:38:49 -05:00
fabioCollini
e2c0460964 Replaced Channel with BroadcastChannel 2019-02-20 23:23:35 -05:00
Mike Nakhimovich
c072f1532b Merge remote-tracking branch 'origin/feature/coroutines' into feature/coroutines 2019-02-12 11:41:01 -05:00
Mike Nakhimovich
e024b64e11 WIP 2019-02-12 11:40:39 -05:00
fabioCollini
77dfdd97fa Restored MultiParser 2019-02-11 17:40:53 -05:00