brick_offline_first 1.0.0
brick_offline_first: ^1.0.0 copied to clipboard
A Brick domain that routes data fetching through local providers before remote providers.
Unreleased #
1.0.0 #
- Null safety
- Priority for the next job to process from the queue - when processing requests in serial - has changed from
'$HTTP_JOBS_CREATED_AT_COLUMN ASC, $HTTP_JOBS_ATTEMPTS_COLUMN DESC, $HTTP_JOBS_UPDATED_AT ASC'to'$HTTP_JOBS_CREATED_AT_COLUMN ASC'; this uses the job column introduced in 0.0.7 (26 May 2020) and will not affect any implementations using 0.0.7 or higher. RequestSqliteCacheno longer queries cached requests based on headers; requests are rediscovered based on their encoding, URL, request method, and body. Rehydrated (reattempted) requests will be hydrated with headers from the original request.- BREAKING CHANGE Field types in models
Set<Future<OfflineFirstModel>>,List<Future<OfflineFirstModel>>, andFuture<OfflineFirstModel>are no longer supported. Instead, useSet<OfflineFirstModel>,List<OfflineFirstModel>, andOfflineFirstModel(the adapters willawaiteach). - BREAKING CHANGE
StubOfflineFirstWithRestis functionally changed. SQLiteFFI has satisfied much of the original stubbing required for this class, and http's testing.dart library is sufficient to not require Mockito. Therefore,verifycalls will no longer be effective in testing on the client. Instead, passStubOfflineFirstWithRest.clientto yourRestProvider#clientwith the response values.StubOfflineFirstWithRestModelhas been removed. Please review Offline First Testing for implementation examples. - Do not reprocess queue requests during a single attempt. Server response times may be greater than the reattempt timer; in these situations, requests should remain locked.
- Introduce mutex around processing in the
OfflineRequestQueue. This will avoid simultaneous DB writes on different isolates* while a previous operation is still performing.
*Or sub routines? Microtasks? It's unclear how Timer moves its work to the background or how to force it to remain in the original "thread."
0.1.2 #
- Add
mixins.dartfor non essential but still regularly requested features that depend on a specific format of remote data or are useful variations of existing features.DeleteAllMixinandDestructiveLocalSyncFromRemoteMixinare the first two such mixins. - Expose
RequestSqliteCache#findRequestInDatabasefor subclass methods. (#111)
0.1.1 #
- Gracefully handle
SocketExceptionerrors when the application is offline - Call
existsinOfflineFirstRepository#getafter the memory provider has already been queried. This method can query the SqliteProvider which is an unnecessary database call when the model exists in the memory provider. - RequestSqliteCacheManager: access SQLite db safely to avoid race conditions
- RequestSqliteCacheManager: refactor database path. This does not change the database's existing path as the use of
getDatabasesPath()in the implementation was duplicating default functionality
0.1.0 #
- BREAKING CHANGE One-to-many and many-to-many SQLite associations are no longer stored as JSON-encoded strings (i.e.
[1, 2, 3]in a varchar column). Join tables are now generated by Brick. To convert existing data, please refer to the brick_sqlite CHANGELOG notes. If you do not care about existing migration and have not widely distributed your app, simply delete all existing migrations, delete all existing app installs, and runflutter pub run build_runner buildin your project root. - Fixes undefined method when calling
hydrateoffline. The remote provider would return null, and SQLite/memory cache would not adequately store results. Instead, when a null response is returned from the remote provider, subsequent provider updates are skipped. - Adds a configurable option to throw on status codes that are normally swallowed in
OfflineFirstWithRest#upsert(such as 404, 50x).
0.0.7 #
- Add
reattemptForStatusCodeforOfflineFirstWithRestRepository#upsertrequests. When the response matches a reattempt code, an exception is not thrown and the instance is returned instead. - Add
501toOfflineQueueHttpClient#reattemptForStatusCodedefaults - Insert a
created_atcolumn for the OfflineRequestQueue. - Fix a bug where an HTTP request would be immediately duplicated. In some race conditions, the interval timer would immediately recreate the request after it was inserted and before the HTTP response was received.
- Bump sqflite to 1.3.0
- BREAKING CHANGE Remove StubSqlite from StubOfflineFirst. SQLite should be migrated by the repository and data upserted as it would be within the app.
StubOfflineFirstis now only concerned with REST responses. - BREAKING CHANGE Remove interval from
OfflineRequestQueuein favor of declaring it once onRequestSqliteCacheManager. To migrate, pass a customRequestSqliteCacheManagerwith the interval time to theOfflineFirstWithRestRepositoryconstructor. - BREAKING CHANGE
StubOfflineFirstWithRestmust be invoked synchronously (in order to run migrations). When setting up stub in testing, callawait StubOfflineFirstWithRest(...).initialize()or, in a cleaner syntax,final stub = StubOfflineFirstWithRest(...); await stub.initialize().initializewill no longer be automatically invoked.
0.0.6 #
- Remove maximumRequests configuration for the OfflineFirstQueue. One request should be processed at a time in serial
- Optionally ignore Tunnel not found requests (these occur when connectivity exists but the queried endpoint is unreachable) when making repository requests
- Adds argument to repository to reattempt requests based on the status code from the response
OfflineRequestQueue#processbecame a protected method- Added
RequestSqliteCacheManagerto interact with the queue. This new class receives most static methods fromRequestSqliteCache. - Added
OfflineRequestQueue#requestManagerto access queue via aRequestSqliteCacheManagerinstance. - Renamed
RequestSqliteCache.unprocessedRequeststoRequestSqliteCacheManager.prepareNextRequestToProcessas the expected query only returns one locked row at a time. RequestSqliteCacheManager.prepareNextRequestToProcesslocks all unprocessed rows, not just the first one- Add ability to toggle
serialProcessingforOfflineRequestQueue - Private member
OfflineFirstWithRestRepository#offlineRequestQueueis now protected - Remove
isConnectedmember fromOfflineFirstRepositoryand associated Connectivity code. The connection should not matter to the subclass as it, or a supporting class, should track outbound requests.
0.0.5+1 #
- Bump dependencies
0.0.5 #
- Rename
Query#paramstoQuery#providerArgs, reflecting the much narrower purpose of the member
0.0.2 #
- Export REST annotations/classes from
OfflineFirstWithRestRepositoryfor convenient access - Don't require
MemoryCacheProviderinOfflineFirstWithRestRepositoryas it's not required forOfflineFirstRepository - Fix linter hints