Skip to content

Commit b175701

Browse files
committed
add new sample
1 parent 7f520c6 commit b175701

File tree

1 file changed

+14
-0
lines changed
  • quickstarts/runtime-options/functions

1 file changed

+14
-0
lines changed

quickstarts/runtime-options/functions/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ exports.getAutocompleteResponse = functions
1111
});
1212
// [END runtimeMinInstances]
1313

14+
// [START runtimeMinInstancesDynamic]
15+
// Get Firebase project id from `FIREBASE_CONFIG` environment variable
16+
const envProjectId = JSON.parse(process.env.FIREBASE_CONFIG).projectId;
17+
18+
exports.renderProfilePage = functions
19+
.runWith({
20+
// Keep 5 instances warm for this latency-critical function
21+
// in production only. Default to 0 for test projects.
22+
minInstances: envProjectId === "my-production-project" ? 5 : 0,
23+
})
24+
.https.onRequest((req, res) => {
25+
// render some html
26+
});
27+
// [END runtimeMinInstancesDynamic]
1428

1529
// [START runtimeMaxInstances]
1630
exports.mirrorOrdersToLegacyDatabase = functions

0 commit comments

Comments
 (0)