Skip to content

Commit daabbfa

Browse files
author
Patryk Lesiewicz
authored
Merge pull request #352 from FirebasePrivate/patryk/mod-param-rename
Rename MOD_METADATA_DOC to INTERNAL_STATE_PATH.
2 parents 48a41b3 + 54521c9 commit daabbfa

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

firestore-counter/POSTINSTALL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ gcloud scheduler jobs create http firestore-sharded-counter-controller --schedul
5555
// Initialize the sharded counter.
5656
var views = new sharded.Counter(db.doc("pages/hello-world"), "stats.views");
5757
58-
// Increment by 3 the field "stats.views" of the document: ${param:MOD_METADATA_DOC}.
58+
// Increment by 3 the field "stats.views" of the document: ${param:INTERNAL_STATE_PATH}.
5959
// (use your desired increment amount)
6060
views.incrementBy(3);
6161

firestore-counter/extension.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ resources:
7373
location: ${LOCATION}
7474
eventTrigger:
7575
eventType: providers/cloud.firestore/eventTypes/document.write
76-
resource: projects/${PROJECT_ID}/databases/(default)/documents/${MOD_METADATA_DOC}/workers/{workerId}
76+
resource: projects/${PROJECT_ID}/databases/(default)/documents/${INTERNAL_STATE_PATH}/workers/{workerId}
7777

7878
params:
7979
- param: LOCATION
@@ -101,7 +101,7 @@ params:
101101
default: us-central1
102102
required: true
103103

104-
- param: MOD_METADATA_DOC
104+
- param: INTERNAL_STATE_PATH
105105
label: Document path for internal state
106106
description: >-
107107
What is the path to the document where the extension can keep its internal state?

firestore-counter/functions/lib/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const WORKERS_COLLECTION_ID = "_counter_workers_";
3939
* workers to do the aggregation.
4040
*/
4141
exports.controller = functions.https.onRequest((req, res) => __awaiter(void 0, void 0, void 0, function* () {
42-
const metadocRef = firestore.doc(process.env.MOD_METADATA_DOC);
42+
const metadocRef = firestore.doc(process.env.INTERNAL_STATE_PATH);
4343
const controller = new controller_1.ShardedCounterController(metadocRef, SHARDS_COLLECTION_ID);
4444
let status = yield controller.aggregateOnce({ start: "", end: "" }, 200);
4545
if (status === controller_1.ControllerStatus.WORKERS_RUNNING ||
@@ -58,7 +58,7 @@ exports.controller = functions.https.onRequest((req, res) => __awaiter(void 0, v
5858
* resharding and to detect failed workers that need poking.
5959
*/
6060
exports.worker = functions.firestore
61-
.document(process.env.MOD_METADATA_DOC + WORKERS_COLLECTION_ID + "/{workerId}")
61+
.document(process.env.INTERNAL_STATE_PATH + WORKERS_COLLECTION_ID + "/{workerId}")
6262
.onWrite((change, context) => __awaiter(void 0, void 0, void 0, function* () {
6363
// stop worker if document got deleted
6464
if (!change.after.exists)
@@ -74,7 +74,7 @@ exports.worker = functions.firestore
7474
exports.onWrite = functions.firestore
7575
.document("/{collection}/{**}/_counter_shards_/{shardId}")
7676
.onWrite((change, context) => __awaiter(void 0, void 0, void 0, function* () {
77-
const metadocRef = firestore.doc(process.env.MOD_METADATA_DOC);
77+
const metadocRef = firestore.doc(process.env.INTERNAL_STATE_PATH);
7878
const controller = new controller_1.ShardedCounterController(metadocRef, SHARDS_COLLECTION_ID);
7979
yield controller.aggregateContinuously({ start: "", end: "" }, 200, 60000);
8080
}));

firestore-counter/functions/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const WORKERS_COLLECTION_ID = "_counter_workers_";
3232
* workers to do the aggregation.
3333
*/
3434
export const controller = functions.https.onRequest(async (req, res) => {
35-
const metadocRef = firestore.doc(process.env.MOD_METADATA_DOC);
35+
const metadocRef = firestore.doc(process.env.INTERNAL_STATE_PATH);
3636
const controller = new ShardedCounterController(
3737
metadocRef,
3838
SHARDS_COLLECTION_ID
@@ -58,7 +58,7 @@ export const controller = functions.https.onRequest(async (req, res) => {
5858
*/
5959
export const worker = functions.firestore
6060
.document(
61-
process.env.MOD_METADATA_DOC + WORKERS_COLLECTION_ID + "/{workerId}"
61+
process.env.INTERNAL_STATE_PATH + WORKERS_COLLECTION_ID + "/{workerId}"
6262
)
6363
.onWrite(async (change, context) => {
6464
// stop worker if document got deleted
@@ -76,7 +76,7 @@ export const worker = functions.firestore
7676
export const onWrite = functions.firestore
7777
.document("/{collection}/{**}/_counter_shards_/{shardId}")
7878
.onWrite(async (change, context) => {
79-
const metadocRef = firestore.doc(process.env.MOD_METADATA_DOC);
79+
const metadocRef = firestore.doc(process.env.INTERNAL_STATE_PATH);
8080
const controller = new ShardedCounterController(
8181
metadocRef,
8282
SHARDS_COLLECTION_ID

0 commit comments

Comments
 (0)