Commit graph

638 commits

Author SHA1 Message Date
Yang
613a5c8296 Add support for purging all store entries (#79)
* Fix typos.

* Gradle 6.1, AGP 4.0.0-alpha09, lifecycle 2.2.0.

* Add experimental invalidateAll() support and @ExperimentalStoreAPI annotation.

* Update sample with deleteAll function.

* Update README.md with deleteAll function.

* Add a section to README.md on clearing store entries.

* Rewrite tests without mocking. Move test utils / helpers to a single package.

* Code formatting and cleanups.

* Use StoreResponse.Data instead of DataWithOrigin in ClearAllStoreTest and ClearStoreByKeyTest.

* Simplified samples. Refactor tests.

* Gradle 6.1.1.
2020-01-28 09:02:28 -08:00
Eyal Guthmann
86f7b1b060
introduce piggyback only downstreams to multicaster and fix #59 (#75)
* patched-from-yigit

* piggyback only channels

* cleanup docs and tests

* add yigit's test. piggyback now acks upstreams, pr comments

* tests names

* fix test name

* comments

* Update store/src/test/java/com/dropbox/android/external/store4/impl/FlowStoreTest.kt

Co-Authored-By: Yigit Boyar <yboyar@google.com>

* remove import

Co-authored-by: Yigit Boyar <yboyar@gmail.com>
2020-01-25 13:13:12 -08:00
Yigit Boyar
929b4c40a4 Change flow collection util to drain the flow (#64)
* Change flow collection util to drain the flow

This PR changes the assertItems util method in tests to drain the
flow to ensure we don't produce unwated items.

* reformat code

* Use a test subject for flow assertions

* update test subject messsages, add tests for it (so meta :p)

* Apply suggestions from code review

Co-Authored-By: Eyal Guthmann <eyalgu@users.noreply.github.com>

* fix code style

* Don't try to get exception unless collection finished

This fixes a bug in FlowSubject where it would try to get the cancelation
exception from an unfinished job. Also added a test.

Co-authored-by: Eyal Guthmann <eyalgu@users.noreply.github.com>
2020-01-19 10:56:16 -08:00
ychescale9
ccf9a66f07 Improve README.md. (#70)
* Improve README.md.

* Fix typo, add maven central badge, remove brackets around Store version.
2020-01-18 18:06:59 -08:00
ychescale9
42effd8bd5 Add README.md for new cache module. (#72)
* Add README.md for cache module.

* Update intro.
2020-01-18 07:32:21 -08:00
ychescale9
c29ed5583d Fix an inconsistency between Store's MemoryPolicy and Cache where the default MemoryPolicy created has a maxSize of 1. (#71) 2020-01-18 09:25:05 -05:00
Eyal Guthmann
5f2fb35da9
Avoid illegal cast in RealStore.stream (#69)
* Avoid illegal cast in

* remove commented out code

* remove wildecards

* ktlint

* optimize imports

* don't print  in exception message to avoid PII leak
2020-01-17 16:29:17 -08:00
Stephen Bain
bc6c47833d added docs to MemoryPolicy.setMemorySize (#67) (#68) 2020-01-17 16:45:58 -05:00
ychescale9
7ee32a7468 Clean up build configs (#62)
* Update dependencies, clean up unused dependencies.

* Remove unused checkstyle and pmd rulesets.

* Use `plugins` block.

* Fix compiler warnings.
2020-01-13 12:43:41 -05:00
William Clausen
351f534579 Update README to reflect availability of alpha artifacts in Maven (#61) 2020-01-10 21:13:16 -05:00
William Clausen
c227221b23 Increment version for 4.0.0-alpha01 release and prep next development version (#58)
* Prepare for release 4.0.0-alpha01

* Prepare next development version

* Update build.gradle

Co-Authored-By: Mike Nakhimovich <digitalbuddha@users.noreply.github.com>

Co-authored-by: Mike Nakhimovich <digitalbuddha@users.noreply.github.com>
2020-01-10 16:46:02 -05:00
Masataka Hirano
c99db1f05f Refactor README sample code (#60) 2020-01-10 11:01:56 -05:00
ychescale9
062deda898 Cache Rewrite (#49)
* Rewrite cache module in Kotlin.

* Migrate RealStore to use new cache.

* Migrate FileSystemImpl to use new cache.

* Migrate StoreTest to new cache.

* Remove Guava Cache.

* Migrate remaining Java file to Kotlin.

* Fix ktlint error.

* Fix package.

* Add support for CacheLoader.

* Remove unnecessary mockito-inline.

* Remove volatile keyword from CacheEntry fields and add docs re. cache entry reuse and thread-safty assumption.

* - Refactor CacheBuilder.
- Update docs.
- Update Key, Value, Input, Output generic types to be bound by Any.
- Replace spy with TestLoader for asserting invocation.

* Support key-based synchronization for get(key: Key, loader: () -> Value): Value.

* Document loader exception propagation.

* Small clean ups.

* Make CacheEntry's Key and Value bound to Any, move CacheEntry to RealCache.kt as a private class.

* Add reference counting key-based synchronization for cache loader.

* Improve KeyedSynchronizer and docs.

* Refactor tests and add a missing test case to reach 100% coverage.

* Add memory barrier after updating access time in cache entry.

* Only process access queue if expiresAfterAccess == true.

* Support configurable concurrency level.

* Increase delay for concurrency test.

* Explicitly set concurrency level for concurrency tests.

* Only add memory barrier after recordRead if expiresAfterAccess is enabled.

* Fix a potential memory leak caused by thread preemption.

* Allow retries (3 times) for concurrency tests.

* Move performMaintenance function to bottom of the class.

* Fix typos, rename performMaintenance() to cleanUpDeadEntries(), improve docs.

* Fix more typos.

* Only remove entries in map but not in queue.

* Replace memory barrier with @Volatile fields in CacheEntry.

* Fix deadlock while iterating sets.

* Remove stale cache/README.md, remove commented out java file.
2020-01-08 06:56:02 -05:00
Mike Nakhimovich
267f803db0
fix dokka, update comments, integrate persister (#56)
* fix dokka, update comments, integrate persister
2020-01-07 14:08:53 -05:00
ychescale9
0cd21be2ee Switch POM packaging format to jar for cache, filesystem and store. (#54) 2020-01-07 13:31:19 -05:00
Eyal Guthmann
54c7ad5113
Add an optional param to Multicaster to keep the fetches alive even if all downstreams are closed. (#40) 2020-01-02 13:14:18 -08:00
Andrey Beryukhov
dab29bd166 Replace Store.fetch() on fresh() methods in ReadMe (#52) 2020-01-02 14:47:08 -05:00
Yigit Boyar
8819cedc2a Properly implement multicast closing (#48)
* Properly implement multicast closing

This PR defines the behavior of Multicast Flow.
Previously, it could crash if new observers are added to the
multicaster or if it is closed while there is an active
collector. Now, both of these operations complete without
an error. Collecting on a closed multicaster receives 0
values and closes immediately.

Fixes: #45
Test: ChannelManagerTest, MulticastTest

* remove empty line to fix lint error

* improve tests
2020-01-02 13:29:53 -05:00
ychescale9
ba3bf9fd2e Misc improvements and cleanups (#47)
* Add kotlin plugin to cache module

* Remove custom accessors in StoreDefaults as default values are effectively constant.

* Update JUnit to 4.13 RC2 to enable  asserting specific error message on expected exception.

* Remove custom accessors in MemoryPolicy as all values are calculated from constants.

* Remove checkstyle and pmd as the codebase will be 100% Kotlin.

* Fix IDE warning in build.gradle by removing static imports.

* Remove unused guava dependencies.

* Improve StoreDefaults docs.
2019-12-26 13:21:52 -05:00
Fabio Collini
3b43bc6283 New sample with a ViewModel and multiple stores (#44)
* New sample with a ViewModel and multiple stores

* Fix warnings
2019-12-25 10:30:01 -05:00
Nuh Koca
14b0646202 Fix README typos (#46) 2019-12-23 12:31:37 -05:00
Yigit Boyar
1dbe5a75c2 unblock upstream when a new downstream arrives (#43)
* Failing test for downstream closing w/o ack

Add test case that fails when a downstream closes w/o acking the message
and indefinitely suspending the stream for other active downstreams

Issue: #41

* add test with buffer

* ack latest message when a new upsteam arrives

Previously, a new downstream would be suspended on the ack of
messages that arrived before it, even when buffer is 0.

This PR changes that behavior such that if there is no buffer,
we ack latest message immediately so that new downstream can
get values instead of waiting for values that it'll never receive

* re-apply ktlint
2019-12-20 20:19:41 -05:00
Pavlos-Petros Tournaris
6827619744 [Kotlinization] Misc refactors for more Kotlin friendlier code (#37)
* Make MemoryPolicy Kotlin friendlier

* Make MemoryPolicy usage more Kotlin like

* Format code in FSReader

* Format code in FSWriter

* Format code in FileSystemRecordPersister

* Format code in FileSystemPersister

* Convert BarCodeReadAllPathResolver to Object instead of Class

* Convert BarCodePathResolver to Object instead of Class

* Fix wrong control flow conversion
2019-12-18 10:36:36 -08:00
Pavlos-Petros Tournaris
8c435edca0 Simplify few things in root build.gradle (#38) 2019-12-17 14:39:08 -08:00
Eyal Guthmann
1a1eb00673 Hide use of actor in ChannelManager (#33)
* Have ChannelManager delegate to an actor rather then implementing one

* update documentation

* Update multicast/src/main/kotlin/com/dropbox/flow/multicast/ChannelManager.kt
2019-12-17 17:15:14 -05:00
Burak Eregar
a5f0a29d97 Migrate the rest of the module and remove AssertJ dependency (#32) 2019-12-16 13:04:03 -08:00
Eyal Guthmann
689812a7bb
Clean up ChannelManager's interface to make it easier to add more tests (and add some) (#29)
* Clean up ChannelManager's interface to make it easier to add more tests (and add them)

Main changes:
* ~`ChannelManager` no longer inherits from `StoreRealActor` but rather
delegates to one.~ - Moved to followup PR
* messages coming from the upstream were placed under `Message.Dispach`
rather than `Message`. These are the only messages accepted from outside
`ChannelManager`
* `ChannelManager` now only exposes `plusAsign`, `minusAsign` for
adding/removing channels, close for closing  and send(msg, Message.Dispatch)
for upstream events
* `SharedFlowProducer` no longer has a back dependency on
`ChannelManager`, rather it accepts a `suspend (Message.Dispatch) ->
Unit`
* `ChannelManager` is now built with the upstream flow rather than a
flow factory. Given that a flow is stateless, passing in a flow that can
be re-consumed seems like the simpler API.
* New `ChannelManager` tests

* make changes to existing test minimal

* revert actor delegation to reduce PR size

* comments

* clean up tests

* Bump travis

* lint

* rename `channelManagerInbox` ->``sendUpsteamMessage`
2019-12-16 08:50:57 -08:00
Burak Eregar
ee30afb0c9 Implement Truth and migrate store module. (#30) 2019-12-15 16:30:34 -05:00
Yigit Boyar
2b70a2f721 Fix multiple collections on Multicast (#28)
* Fix multiple collections on Multicast

Multicast implementation had a bug where the returned flow could
not be collected multiple times as it was using the same channel
it created when  was called.

This PR changes it to create per collection to avoid this issue.

I've also replaced  function with a  field as there
is no reason to keep creating a new one, it can be just a flow

Test: MultiplexTest#multipleCollections
Fixes: #26

* remove create function
2019-12-13 13:08:35 -05:00
Eyal Guthmann
fa10e84623
Cleanup StoreBuilder interface and add some documentation (#24)
* Cleanup StoreBuilder interface and add some documentation

* Update store/src/main/java/com/dropbox/android/external/store4/StoreBuilder.kt

Co-Authored-By: Mike Nakhimovich <digitalbuddha@users.noreply.github.com>

* A little more docs around persistence
2019-12-11 14:52:11 -08:00
David Algar
98062b155b Update Readme.md with correct artifact id (#23)
The artifact id `store4`, so the current included example dependency line doesn't locate the library.   Changing it to `store4` correctly finds the library in the local repository.
2019-12-11 11:53:33 -05:00
Gert Dingenen
9f7fd1bd17 Replace Retrofit's deprecated Deferred CallAdapter with its built-in suspend support. (#22) 2019-12-11 10:51:48 -05:00
ychescale9
b4c0877732 Fix a bunch of kotlin compiler warnings. (#20) 2019-12-11 09:44:45 -05:00
Mike Nakhimovich
7cb52099f6
Update README.md 2019-12-10 20:46:08 -05:00
ychescale9
1810355341 Update dependencies and clean up unused ones (#16)
* Update dependencies and clean up unused ones.

* Update okio to 2.4.1 and migrate deprecated APIs to extension functions.

* Update platform and build-tools in travis config.
2019-12-10 20:12:51 -05:00
Mike Nakhimovich
02fa6facbe
We are using travis for ci (#17) 2019-12-10 16:10:19 -05:00
Mike Nakhimovich
ff06e28697
Update readme to trigger travis build (#15)
* Update readme to trigger travis build

* fix deploy script to not refer to nytimes

* Update deploy_snapshot.sh
2019-12-10 13:48:43 -05:00
David Chang
a19a9be424 Update Travis secure variables (#18) 2019-12-10 12:43:40 -05:00
ychescale9
8ddbe3c76f Add ktlint and fix all issues. (#11) 2019-12-10 10:51:14 -05:00
David Chang
dd5a5c8a78
Merge pull request #13 from dropbox/changusmc-patch-1
Update README with Store maven gradle dependency
2019-12-09 12:59:05 -08:00
David Chang
03c7ef6267
Update README with Store maven gradle dependency 2019-12-09 12:11:19 -08:00
David Chang
93112069a5
Merge pull request #12 from changusmc/master
Update maven coordinates for Store 4
2019-12-09 11:43:26 -08:00
David Chang
dce8b865c1 Update maven coordinates for Store 4 2019-12-09 11:39:20 -08:00
Yigit Boyar
6d97c399fa move multicast to its own module (#9)
Fixes #8
2019-12-08 19:12:11 +01:00
Mike Nakhimovich
a362c33c0a
Remove parsing blurb from Readme (#4)
Store3 took a parser, store4 doesn't need to due to how easy it is to add transformations to the fetcher or reader flows
2019-12-07 00:51:29 +01:00
Mike Nakhimovich
088be08376
Update license to include Dropbox copyright (#7) 2019-12-07 00:51:17 +01:00
Mike Nakhimovich
fed4430397
Create pull_request_template.md 2019-12-07 00:49:00 +01:00
Mike Nakhimovich
1314546bb9
Update CONTRIBUTING.md 2019-12-07 00:30:10 +01:00
Mike Nakhimovich
59ab3f0889
Add not about missing maven artifact (#6)
Add how to build from source and install into local m2 repo
2019-12-07 00:19:36 +01:00
Júlio Zynger
5d6ccf8422 Fix link in README (#3)
* Fix link in README

* Oops bracket
2019-12-07 00:10:40 +01:00