@procedures/store 0.18.0 → 0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @procedures/store
2
2
 
3
+ ## 0.18.1
4
+
5
+ ### Patch Changes
6
+
7
+ - d2713c5: Changed: a `TabCoordinator` whose setup of the sync fails asks for the lock again after a backoff (roadmap CLI-67). Before, it released the lock and never asked again.
8
+
9
+ - A tab becomes the leader only after its `HybridStorage` loaded the queue. Until then, the tab is a follower.
10
+ - When `remote()` throws or the load of the queue fails, the tab gives the error to `onError` and releases the lock. Another tab can lead.
11
+ - The tab stays a follower and asks again after the wait. `close()` stops the wait. In the single mode, the tab tries its setup again.
12
+ - The new option `retry` sets the backoff: `delay` (1 second), `factor` (2), `maxDelay` (1 minute) and `jitter` (0.5). The options `clock` and `random` serve a test.
13
+
14
+ Added: the status of the sync in each tab (roadmap CLI-65).
15
+
16
+ - `TabCoordinator.getStatus()` gives the `SyncStatus` of the leader in each tab, or `undefined` before the first status.
17
+ - `TabCoordinator.onStatus()` tells each new status to a listener, one time.
18
+ - The leader sends each change of its status to the followers, and it answers the hello of a new tab with its status.
19
+ - In a follower, `error.error` is an `Error` with the `name`, the `message` and the `code` of the error of the leader, because a message keeps only the values that a structured clone copies.
20
+ - The new message type `status` keeps the version 1 of the messages. A tab of an older release ignores it and still copies the batches.
21
+
22
+ PATCH: new methods, a new option with a default and a new message type that are backward compatible, before 1.0.0 (decision D13).
23
+ - Updated dependencies [d69c8cb]
24
+ - Updated dependencies [0379278]
25
+ - @procedures/client@0.18.1
26
+ - @procedures/collections@0.18.1
27
+
3
28
  ## 0.18.0
4
29
 
5
30
  ### Patch Changes
package/README.md CHANGED
@@ -349,6 +349,26 @@ A new leader and a closed tab:
349
349
  - The load of the queue writes the queued operations to the local copy again. Thus the observers can get them again, with the origin `syncOrigin`.
350
350
  - `close()` of a follower stops its lock request. `close()` does not close the local copy, because the application owns it.
351
351
 
352
+ A setup that fails (roadmap CLI-67):
353
+
354
+ - A tab becomes the leader only after its `HybridStorage` loaded the queue. Until then, the tab is a follower.
355
+ - When `remote()` throws or the load of the queue fails, the tab gives the error to `onError`. Then it releases the lock, and another tab can lead.
356
+ - The tab stays a follower, and it asks for the lock again after a backoff. Thus a short failure does not leave the browser without a sync.
357
+ - The option `retry` sets the backoff: `delay` (1 second), `factor` (2), `maxDelay` (1 minute) and `jitter` (0.5).
358
+ - After `n` failures in a row, the wait is `delay × factor^(n − 1)`, at most `maxDelay`. The jitter makes each wait shorter by up to its fraction.
359
+ - A setup that succeeds sets the wait back to `delay`. `close()` stops a wait.
360
+ - In the single mode, the tab tries its setup again after the same backoff.
361
+ - The options `clock` and `random` take the clock and the random numbers of the backoff, for example `fakeClock` of `@mark1russell7/service/testing` in a test.
362
+
363
+ The status of the sync (roadmap CLI-65):
364
+
365
+ - `getStatus()` gives the `SyncStatus` in each tab. Before the first status and after `close()`, it gives `undefined`.
366
+ - `onStatus()` tells each new status to a listener, one time.
367
+ - The leader gives the status of its own `HybridStorage`. It sends each change to the followers, and it answers the hello of a new tab with its status.
368
+ - After a change of the leader, a follower keeps the last status until the new leader sends its status.
369
+ - A message keeps only values that a structured clone can copy. Thus in a follower, `error.error` is an `Error` with the `name`, the `message` and the `code` of the error of the leader.
370
+ - A tab of an older release ignores the status messages. It still copies the batches, because the version of the messages stays 1.
371
+
352
372
  Without the Web Locks API or `BroadcastChannel`, the coordinator is in the single mode. The tab does its own sync, and it opens no channel. A browser has the Web Locks API only in a secure context, for example HTTPS or `localhost`.
353
373
 
354
374
  ```ts
@@ -368,8 +388,9 @@ const users = new TabCoordinator<User>({
368
388
  });
369
389
 
370
390
  users.observe((batch) => render(batch));
391
+ users.onStatus((status) => showSync(status)); // The status of the sync, in each tab
371
392
  await local.set("1", { name: "Ada" });
372
- users.syncStorage?.getStatus(); // In the leader only
393
+ users.getStatus(); // The last status, in each tab
373
394
  ```
374
395
 
375
396
  - `role` is `follower`, `leader`, `single` or `closed`. `onRole()` tells each change.