You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: firestore-counter/CONTRIBUTING.md
+6-4Lines changed: 6 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,6 @@
2
2
3
3
**DESCRIPTION**: Auto-scalable counters for your app.
4
4
5
-
6
5
**FEATURES**:
7
6
8
7
- Zero configuration, one mod for all your app needs
@@ -13,24 +12,26 @@
13
12
- Works well offline and provides latency compensation
14
13
- Counter updates are immediately visible locally even though the main counter is eventually updated
15
14
16
-
17
15
**DETAILS**: This mod allows you to increment any fields in your documents at arbitrary rate.
18
16
19
17
Client SDK, instead of incrementing the field directly, increments their own shard in `_counter_shards_` subcollection. A background task is periodically aggregating these shards and eventually rolling them up to the main counters.
20
18
21
19
There are three cloud functions that orchestrate shard aggregations:
22
-
1. A `worker` function is responsible for monitoring and aggregating a range of shards. There may be 0 or hundreds of workers running concurrently to scale up to large workloads
20
+
21
+
1. A `worker` function is responsible for monitoring and aggregating a range of shards. There may be 0 or hundreds of workers running concurrently to scale up to large workloads
23
22
2. A `controller` function runs every minute and monitors the health of the workers. It can scale up and down the number of workers as needed and recover a worker on failure.
24
23
3. A `onWrite` function triggers every time a shard is written and runs one-time aggregation. This improves latency for low workloads where no workers is running. To improve efficiency there's only one instance of this function running at any given time (`maxInstances` is set to 1).
25
24
26
25
# Installation
26
+
27
27
```
28
28
firebase mods:install . --project=<my-project-id>
29
29
30
30
Please check the post-install message for the final step to set up your mod.
31
31
```
32
32
33
33
# Web SDK
34
+
34
35
```
35
36
<html>
36
37
<head>
@@ -47,7 +48,7 @@ Please check the post-install message for the final step to set up your mod.
47
48
48
49
// Initialize the sharded counter.
49
50
var views = new sharded.Counter(db.doc("pages/hello-world"), "stats.views");
50
-
51
+
51
52
// This will increment a field "stats.views" of the "pages/hello-world" document by 3.
52
53
views.incrementBy(3);
53
54
@@ -66,6 +67,7 @@ Please check the post-install message for the final step to set up your mod.
0 commit comments