Commit graph

56 commits

Author SHA1 Message Date
Mike Nakhimovich
7b7f01a439
Rxbindings (#93)
RxJava2 extensions
2020-02-12 20:36:10 -05:00
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
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
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
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
Burak Eregar
a5f0a29d97 Migrate the rest of the module and remove AssertJ dependency (#32) 2019-12-16 13:04:03 -08:00
Burak Eregar
ee30afb0c9 Implement Truth and migrate store module. (#30) 2019-12-15 16:30:34 -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
ychescale9
8ddbe3c76f Add ktlint and fix all issues. (#11) 2019-12-10 10:51:14 -05:00
Yigit Boyar
d5e7f196d1 faster builds (#58)
enable build cache
enable configure on demand
remove snapshot repo from repositories as we never use it
but it is very slow
2019-11-23 21:34:10 -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
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
d1ac07d8d0
Update the sample to use LifecycleScope and ListAdapter (#29) 2019-08-15 23:22:11 +03: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
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
Yigit Boyar
25ef7dc72d Move dependencies to AndroidX 2019-06-30 06:18:07 -07:00
Fabio Collini
7480d5a9c4 Convert filesystem classes to Kotlin (#4) 2019-05-27 15:41:04 -04:00
fabioCollini
927e77954a Coroutines 1.2.1 2019-05-21 22:57:14 +02:00
Brian Plummer
797b3e2555 remove middleware-jackson 2019-05-17 18:30:24 -04:00
fabioCollini
dda71c4d74 Removed immutables dependencies 2019-02-23 17:39:54 +01:00
fabioCollini
f486829e65 Removed rxjava dependencies 2019-02-23 17:08:22 +01:00
fabioCollini
fb4ee1992d Removed rx classes and fixed tests 2019-02-22 22:17:45 -05:00
fabioCollini
1b9e79a565 Fix some tests 2019-02-11 15:15:08 -05:00
DigitalBuddha
774e9d9c4b Merge remote-tracking branch 'origin/feature/kotlin_conversion' into feature/coroutines
# Conflicts:
#	app/build.gradle
#	app/src/main/java/com/nytimes/android/sample/SampleApp.kt
#	app/src/main/java/com/nytimes/android/sample/activity/PersistingStoreActivity.java
#	app/src/main/java/com/nytimes/android/sample/activity/StoreActivity.java
#	build.gradle
#	buildsystem/dependencies.gradle
#	filesystem/src/test/java/com/nytimes/android/external/fs3/FilePersisterTest.java
#	filesystem/src/test/java/com/nytimes/android/external/fs3/FileSystemRecordPersisterTest.java
#	filesystem/src/test/java/com/nytimes/android/external/fs3/RecordPersisterTest.java
#	filesystem/src/test/java/com/nytimes/android/external/fs3/SourcePersisterTest.java
#	middleware/src/main/java/com/nytimes/android/external/store3/middleware/GsonParserFactory.kt
#	middleware/src/main/java/com/nytimes/android/external/store3/middleware/GsonReaderParser.kt
#	middleware/src/main/java/com/nytimes/android/external/store3/middleware/GsonSourceParser.kt
#	middleware/src/main/java/com/nytimes/android/external/store3/middleware/GsonStringParser.kt
#	middleware/src/test/java/com/nytimes/android/external/store3/GenericParserStoreTest.java
#	middleware/src/test/java/com/nytimes/android/external/store3/GsonParserFactoryTest.java
#	middleware/src/test/java/com/nytimes/android/external/store3/GsonSourceListParserTest.java
#	store/build.gradle
2019-02-10 19:29:48 -05:00
ychescale9
59f9c68342 Update SDK, build tools, gradle, AGP, Kotlin, and library dependencies. (#371)
* Update SDK, build tools, gradle, AGP, Kotlin, and library dependencies.

* Update travis config with new SDK version.
2019-01-07 15:05:05 +01:00
ychescale9
ecea787a3f Remove Deprecated annotation for stream(V key) (#368)
* Remove Deprecated annotation for stream(V key) which was meant to be undeprecated with https://github.com/NYTimes/Store/pull/252.

* Fix CI - remove https://plugins.gradle.org/m2 repository applied to all projects.
2018-10-25 10:43:29 -04:00
Brian Plummer
34ec7d079b
convert jackson middleware tests to kotlin (#355)
* bump jackson rev, include jackson kotlin

* configure jackson for kotlin data classes

* convert tests to kotlin
2018-07-18 21:52:04 +02:00
Brian Plummer
fae3ccc828
Convert sample to kotlin (#347)
* start of sample app conversion to kotlin

* go with moshi kotlin codegen instead of immutables

* pr feedback, use lateinit and make non-null

* pr feedback, unwind method
2018-07-10 14:07:50 +02:00
Mike Nakhimovich
6ac40cd371 StoreRoom (#338)
* roomStore

* kt the app class

* refactor

* fix compilation

* Update .travis.yml

* migrate relevant tests to RoomStore, mark new Room API with @Experimental

* pr feedback

* bump minor rev up

* cleanup store

* create factory, clean up example

* pr comments
2018-05-30 18:56:08 +02:00
Tournaris Pavlos-Petros
e3db18a322 Update BuildTool version
* Version 27.0.3 is already used by AGP 3.1, but I updated the
version in dependencies.gradle as well.
2018-03-29 23:22:59 +03:00
Tournaris Pavlos-Petros
3bf22de815 Add google() repository
* Needed for the lint-gradle dependency in :app project
2018-03-29 23:22:08 +03:00
Pavlos-Petros Tournaris
6f2f1c12fe Fix issues occured from RxJava1 dependency (#314)
* Remove RxJava1 dependencies
* Fixed an ErrorProne warning
2018-02-20 18:05:46 +01:00
Ramona Harrison
2e4b6f734b
Update build tools to 26.0.2 (#283) 2017-10-30 10:46:53 -04:00
Jorge Antonio Díaz-Benito Soriano
dac878e2ce Gradle updates (#266)
* Gradle Wrapper (all) 3.3 -> 4.1

* Gradle plugin for Android 2.3.2 -> 3.0.0-beta2

This requires upgrading the errorprone plugin to 0.0.11. Also, see
https://stackoverflow.com/questions/44196672/aapt2-compile-failed-invalid-dimen-on-android-3-0-canary-1

gradle plugin

* SDK Build Tools 25.0.2 -> 26.0.1

* Remove retrolambda

* Log error from subscription on PersistingStoreActivity for consistency

* Update dependency inclusion directives to those of the 3.0 plugin

Also, jsr305 and javax usages have been taken from compile to compileOnly
since they are not required beyond.

* Add dependencies that previously were resolved through leaked ones from other artifacts

Now dependency leaks are eliminated thanks to 'implementation' from the 3.0 version of the gradle plugin.

* Remove coupling between middlewares and cache

* Replace mockito-all by mockito-core

mockito-all causes problems related to hamcrest when used with JUnit. See
https://tedvinke.wordpress.com/2013/12/17/mixing-junit-hamcrest-and-mockito-explaining-nosuchmethoderror/

* Remove unused dependency.

* Build Tools 26.0.1 on Travis

* Suppress PMD.AvoidThrowingNullPointerException for the time being

* Avoid PMD synthetic accessor warning
2017-08-17 13:48:12 -04:00
Mike Nakhimovich
1ee8d659fb upgrade external dependencies (#257)
* upgrade external dependencies

* update build tools in travis

* put kotlin standardlib back in

* fix build
2017-07-24 16:40:22 -04:00
Eric Cochran
c2d1a038c6 Update to Moshi 1.5.0. (#246) 2017-07-17 14:18:38 -04:00
Jorge Antonio Díaz-Benito Soriano
10d0cf6d07 Add store-kotlin module (#229)
* Add store-kotlin module

* Remove useless file

* Fix package in AndroidManifest

* Refactor module tests to assertJ

* Remove wrong annotation

* Add store-kotlin artifact to README

* Add module README

* Add KDoc to Javadoc jar

* Add Experimental annotation

* Mark all public store-kotlin classes as @Experimental

* Replace use of rx's @Experimental with local one instead
2017-06-22 21:22:34 -04:00
Maksim Moiseikin
a9ed871834 Port to RxJava 2 (#155)
* Port Store artifact to RxJava 2
2017-03-23 16:29:47 -04:00
Amine Laadhari
10eb6ee0a4 Add Inject annotations with the correct dependency 2017-03-07 18:28:38 +01:00
Paul Woitaschek
62c7ca39d7 Cleanup (#127)
* Fixed a race condition that would appear when the read was called but not immediately subscribed to. Defer the whole file check till subscription.

* Diamonds

* General cleanup, missing nullity annotations, missing override annotations

* More key naming conventions

* Dependency update

* More key naming conventions

* Parser, not func

* Name outer key different so cache can be evicted correctly

* Another missing override
2017-02-09 13:04:07 -08:00
Pavlos-Petros Tournaris
d8829d3ac0 Remove duplicate target_sdk (#126) 2017-02-09 12:20:04 -05:00
Eric Cochran
462df5a4be Update to Moshi 1.4.0 (#108) 2017-02-05 08:29:49 -05:00
Plummer
405a15d3b6 start of conversion to javax.annotations 2017-01-30 17:46:05 -05:00
Brian Plummer
be5ba6443a convert store to java, #83 (#85)
convert store to java, #83
2017-01-28 20:52:55 -05:00
digitalbuddha
f7e3fc5566 fix test 2017-01-23 13:27:38 -05:00
Brian Plummer
47aa5da3bf remove maven.em.nytimes.com from repositories block (#62) 2017-01-15 14:29:01 -05:00