This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package models | |
| type MyEvent struct { | |
| Type string | |
| SecondParam string | |
| } | |
| func MyPublicFunc() int { | |
| return 5 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "log" | |
| // Import local 'models' module | |
| "models" | |
| ) | |
| func main() { | |
| // Create new "MyEvent" struct |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module service | |
| go 1.15 | |
| require ( | |
| models v1.0.0 | |
| ) | |
| replace ( | |
| models v1.0.0 => ../models |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function mySlowFunction(baseNumber) { | |
| let result = 0; | |
| for (var i = Math.pow(baseNumber, 7); i >= 0; i--) { | |
| result += Math.atan(i) * Math.tan(i); | |
| }; | |
| } | |
| app.get('/highcpu', (req,res)=>{ | |
| mySlowFunction(10); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.get('/longrunning', (req, res) => { | |
| // Simply wait for 5 seconds before returning. | |
| // Simulating some long but CPU inexpensive Operation. | |
| const sleep = 5000; | |
| setTimeout(() => { | |
| res.status(200).send().end(); | |
| }, sleep) | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| runtime: nodejs14 | |
| service: my-app | |
| instance_class: F2 | |
| automatic_scaling: | |
| # Default 0 | 0 to 1000 | |
| min_instances: 0 | |
| # Default 0 | 0 to 2147483647 | |
| max_instances: 100 | |
| # Default: automatic | 1 to 1000 | |
| max_idle_instances: automatic |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * | |
| * @param {Table} table | |
| * @param {string} rowKey | |
| * @param {RawFilter} filter | |
| * @returns {Promise<Row>} | |
| */ | |
| const getRow = async (table, rowKey, filter) => { | |
| const [singleRow] = await table.row(rowKey).get({ filter }); | |
| return singleRow; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * | |
| * @param {Object} el | |
| * @param {string} el.key | |
| * @param {number} el.value | |
| * @returns | |
| */ | |
| const createSimpleRow = (el) => ({ | |
| key: el.key, | |
| data: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * | |
| * @param {Instance} instance Bigtable instance | |
| * @param {string} tableId ID of the table to create | |
| * @returns {Promise<Table>} | |
| */ | |
| const createTable = async (instance, tableId) => { | |
| const table = instance.table(tableId); | |
| const tableOptions = { | |
| families: [{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Delete the instance provided by the instanceId | |
| * @param {string} instanceId | |
| */ | |
| const deleteInstance = async (instanceId) => { | |
| const instance = bigtable.instance(instanceId); | |
| console.log('Deleting Instance'); | |
| await instance.delete(); | |
| console.log(`Instance deleted: '${instance.id}'`); | |
| } |