@@ -42,6 +42,7 @@ const logger = winston.createLogger({
4242} ) ;
4343
4444// [START cloud_sql_server_mssql_create]
45+ // [START cloud_sql_sqlserver_mssql_create]
4546const createPool = async ( ) => {
4647 let config = { pool : { } } ;
4748 config . user = process . env . DB_USER ; // e.g. 'my-db-user'
@@ -54,6 +55,7 @@ const createPool = async () => {
5455 // [START_EXCLUDE]
5556
5657 // [START cloud_sql_server_mssql_timeout]
58+ // [START cloud_sql_sqlserver_mssql_timeout]
5759 // 'connectionTimeout` is the maximum number of milliseconds to wait trying to establish an
5860 // initial connection. After the specified amount of time, an exception will be thrown.
5961 config . connectionTimeout = 30000 ;
@@ -63,26 +65,32 @@ const createPool = async () => {
6365 // 'idleTimeoutMillis' is the number of milliseconds a connection must sit idle in the pool
6466 // and not be checked out before it is automatically closed
6567 config . pool . idleTimeoutMillis = 600000 ,
68+ // [END cloud_sql_sqlserver_mssql_timeout]
6669 // [END cloud_sql_server_mssql_timeout]
6770
6871 // [START cloud_sql_server_mssql_limit]
72+ // [START cloud_sql_sqlserver_mssql_limit]
6973 // 'max' limits the total number of concurrent connections this pool will keep. Ideal
7074 // values for this setting are highly variable on app design, infrastructure, and database.
7175 config . pool . max = 5 ;
7276 // 'min' is the minimum number of idle connections maintained in the pool.
7377 // Additional connections will be established to meet this value unless the pool is full.
7478 config . pool . min = 1 ;
79+ // [END cloud_sql_sqlserver_mssql_limit]
7580 // [END cloud_sql_server_mssql_limit]
7681
7782 // [START cloud_sql_server_mssql_backoff]
83+ // [START cloud_sql_sqlserver_mssql_backoff]
7884 // The node-mssql module uses a built-in retry strategy which does not implement backoff.
7985 // 'createRetryIntervalMillis' is the number of milliseconds to wait in between retries.
8086 config . pool . createRetryIntervalMillis = 200 ;
87+ // [END cloud_sql_sqlserver_mssql_backoff]
8188 // [END cloud_sql_server_mssql_backoff]
8289
8390 // [END_EXCLUDE]
8491 return await mssql . connect ( config ) ;
8592} ;
93+ // [END cloud_sql_sqlserver_mssql_create]
8694// [END cloud_sql_server_mssql_create]
8795
8896const ensureSchema = async ( pool ) => {
@@ -179,6 +187,7 @@ app.post('/', async (req, res, next) => {
179187 }
180188
181189 // [START cloud_sql_server_mssql_connection]
190+ // [START cloud_sql_sqlserver_mssql_connection]
182191 try {
183192 const stmt = 'INSERT INTO votes (time_cast, candidate) VALUES (@timestamp, @team)' ;
184193 // Using a prepared statement protects against SQL injection attacks.
@@ -207,6 +216,7 @@ app.post('/', async (req, res, next) => {
207216 . end ( ) ;
208217 // [END_EXCLUDE]
209218 }
219+ // [END cloud_sql_sqlserver_mssql_connection]
210220 // [END cloud_sql_server_mssql_connection]
211221
212222 res . status ( 200 ) . send ( `Successfully voted for ${ team } at ${ timestamp } ` ) . end ( ) ;
0 commit comments