Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 14 fixes #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions aws-greengrass-core-sdk/stream-manager/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ const removeFromArray = (arr, f) => {
* c.onConnected(async () => {
* // Do work with the client (c) here.
* });
* process.on('unhandledRejection', (reason, promise) => {
* console.log('Unhandled Rejection at:', promise, 'reason:', reason);
* // Application specific logging, throwing an error, or other logic here
* });
*/
class StreamManagerClient {
#closed = false;
Expand Down
3 changes: 2 additions & 1 deletion greengrassExamples/HelloWorld/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ function greengrassHelloWorldRun() {
setInterval(greengrassHelloWorldRun, 5000);

// This is a handler which does nothing for this example
exports.handler = function handler(event, context) {
exports.handler = function handler(event, context, callback) {
console.log(event);
console.log(context);
callback(null, 0);
};
4 changes: 3 additions & 1 deletion greengrassExamples/LambdaInvoke/invokerbinary.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const ggSdk = require('aws-greengrass-core-sdk');

const lambdaClient = new ggSdk.Lambda();

exports.handler = function handler(event, context) {
exports.handler = function handler(event, context, callback) {
console.log(event);
console.log(context);

Expand All @@ -33,8 +33,10 @@ exports.handler = function handler(event, context) {
lambdaClient.invoke(params, (err, data) => {
if (err) {
console.error(err, err.stack);
callback(err);
} else {
console.log(data);
callback(undefined, 0);
}
});
};
4 changes: 3 additions & 1 deletion greengrassExamples/LambdaInvoke/invokerjson.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const ggSdk = require('aws-greengrass-core-sdk');

const lambdaClient = new ggSdk.Lambda();

exports.handler = function handler(event, context) {
exports.handler = function handler(event, context, callback) {
console.log(event);
console.log(context);

Expand All @@ -33,8 +33,10 @@ exports.handler = function handler(event, context) {
lambdaClient.invoke(params, (err, data) => {
if (err) {
console.error(err, err.stack);
callback(err);
} else {
console.log(data);
callback(null, 0);
}
});
};
26 changes: 14 additions & 12 deletions greengrassExamples/ShadowOperations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,28 @@ const shadowGetParams = {
thingName: 'platform',
};

exports.handler = function handler(event, context) {
exports.handler = function handler(event, context, callback) {
console.log(context);

// Update Thing Shadow
console.log('Update Thing Operation');
iotClient.updateThingShadow(shadowUpdateParams, (err, data) => {
if (err) {
console.log(err);
callback(err);
} else {
console.log(data);
// Get Thing Shadow
console.log('Shadow Get Operation');
iotClient.getThingShadow(shadowGetParams, (err, data) => {
if (err) {
console.log(err);
callback(err);
} else {
console.log(data);
callback(null, 0);
}
});
}
});

// Get Thing Shadow
console.log('Shadow Get Operation');
iotClient.getThingShadow(shadowGetParams, (err, data) => {
if (err) {
console.log(err);
} else {
console.log(data);
}
});
});
};
5 changes: 5 additions & 0 deletions greengrassExamples/StreamManagerIoTSiteWise/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ c.onConnected(async () => {
}
});

process.on('unhandledRejection', (reason, promise) => {
console.log('Unhandled Rejection at:', promise, 'reason:', reason);
// Perform the appropriate action based on the reason
});

// Dummy handler because this example should run as a long-lived lambda
module.exports.handler = function handler() {
return '';
Expand Down
5 changes: 5 additions & 0 deletions greengrassExamples/StreamManagerKinesis/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ c.onConnected(async () => {
}
});

process.on('unhandledRejection', (reason, promise) => {
console.log('Unhandled Rejection at:', promise, 'reason:', reason);
// Perform the appropriate action based on the reason
});

// Dummy handler because this example should run as a pinned lambda
module.exports.handler = function handler() {
return '';
Expand Down
5 changes: 5 additions & 0 deletions greengrassExamples/StreamManagerS3/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ c.onConnected(async () => {
}
});

process.on('unhandledRejection', (reason, promise) => {
console.log('Unhandled Rejection at:', promise, 'reason:', reason);
// Perform the appropriate action based on the reason
});

// Dummy handler because this example should run as a pinned lambda
module.exports.handler = function handler() {
return '';
Expand Down
3 changes: 2 additions & 1 deletion greengrassExamples/TES/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ function getCredential(retryInterval) {
getCredential(initialRetryInterval);

// This is a handler which does nothing for this example
exports.handler = function handler(event, context) {
exports.handler = function handler(event, context, callback) {
console.log(event);
console.log(context);
callback(null, 0);
};