sparse-intern-71089
09/04/2020, 3:05 PMchilly-magazine-6129
09/04/2020, 3:07 PMchilly-magazine-6129
09/04/2020, 3:07 PMgreen-school-95910
09/04/2020, 3:20 PMcallbackFactory creates a callback function, it is used to build the global state of the function during cold starts like initializing clients that will reuse resources.
The type system should have an error there for returning true instead of a Callback<E, R>green-school-95910
09/04/2020, 3:21 PMcallback instead of callbackFactorychilly-magazine-6129
09/04/2020, 3:33 PMgreen-school-95910
09/04/2020, 3:36 PMnew aws.lambda.CallbackFunction("foo", {
callbackFactory: () => {
const s3 = new AWS.S3();
return async (event) => {
// ... save event details on S3 ...
};
},
);green-school-95910
09/04/2020, 3:38 PMaccessMeFromTheCallback value.chilly-magazine-6129
09/04/2020, 3:40 PMgreen-school-95910
09/04/2020, 3:42 PMOutput from somewhere else you don't need the factory:
// Defined from other resources somewhere
const accessMeFromTheCallback: Output<string>
new aws.lambda.CallbackFunction("foo", {
callback: async (event) => {
// .get() is required here to extract the string
// from the `Output` instance
console.log(accessMeFromTheCallback.get());
};
);
If you just need it to be global on the function you use the same as I did for s3 on the example above of callbackFactorychilly-magazine-6129
09/04/2020, 3:46 PMchilly-magazine-6129
09/04/2020, 3:47 PMgreen-school-95910
09/04/2020, 3:48 PMnew aws.lambda.CallbackFunction("foo", {
callbackFactory: () => rookout.wrap(async (event) => {
// ...
});
);chilly-magazine-6129
09/04/2020, 3:48 PMgreen-school-95910
09/04/2020, 3:49 PMcreamy-potato-29402
09/06/2020, 3:05 AMchilly-magazine-6129
09/07/2020, 2:13 AM