Skip to content

Commit

Permalink
Remove ephemeral agent sample + update region tag (#650)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ace Nassri authored Jul 23, 2018
1 parent c5188bf commit d615ac8
Showing 1 changed file with 4 additions and 37 deletions.
41 changes: 4 additions & 37 deletions functions/tips/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,50 +70,17 @@ exports.lazyGlobals = (req, res) => {
};
// [END functions_tips_lazy_globals]

// [START functions_tips_ephemeral_agent]
// [START functions_tips_cached_agent]
// [START functions_tips_connection_pooling]
const http = require('http');
// [END functions_tips_ephemeral_agent]
const agent = new http.Agent({keepAlive: true});
// [END functions_tips_cached_agent]

// [START functions_tips_ephemeral_agent]

/**
* HTTP Cloud Function that uses an ephemeral HTTP agent
*
* @param {Object} req Cloud Function request context.
* @param {Object} res Cloud Function response context.
*/
exports.ephemeralAgent = (req, res) => {
req = http.request({
host: '<HOST>',
port: 80,
path: '<PATH>',
method: 'GET'
}, resInner => {
let rawData = '';
resInner.setEncoding('utf8');
resInner.on('data', chunk => { rawData += chunk; });
resInner.on('end', () => {
res.status(200).send(`Data: ${rawData}`);
});
});
req.on('error', (e) => {
res.status(500).send(`Error: ${e.message}`);
});
req.end();
};
// [END functions_tips_ephemeral_agent]

// [START functions_tips_cached_agent]
/**
* HTTP Cloud Function that uses a cached HTTP agent
* HTTP Cloud Function that caches an HTTP agent to pool HTTP connections.
*
* @param {Object} req Cloud Function request context.
* @param {Object} res Cloud Function response context.
*/
exports.cachedAgent = (req, res) => {
exports.connectionPooling = (req, res) => {
req = http.request({
host: '',
port: 80,
Expand All @@ -133,7 +100,7 @@ exports.cachedAgent = (req, res) => {
});
req.end();
};
// [END functions_tips_cached_agent]
// [END functions_tips_connection_pooling]

// [START functions_tips_infinite_retries]
/**
Expand Down

0 comments on commit d615ac8

Please sign in to comment.