Comments (3)
Reviewing this yesterday, I think that this is fine, and may even solve another issue. Here's a quick explanation of how Lambda works. It has event
, context
and callback
objects. In the current version of the SDK, when it's done it calls context.succeed()
(or similar.) In our RequestResponse model, this sends off a response. It then closes off the event loop and stops any async actions going on. However, because context.callbackWaitsForEmptyEventLoop === true
, the lambda function does then run whatever the callback
is. In our case it's undefined.
However, if context.callbackWaitsForEmptyEventLoop === false
, it treats callback
in pretty much the same way as context.succeed()
. The nice part about this for us is that you can more easily edit and rewrite callback, and in testing you can make it do what you want; you can't do this with context.succeed()
. More specifically, lambda-local automatically sets the context object, but it lets you edit the callback function.
Currently, the SDK always calls context.succeed()
, and usually doesn't have a callback defined. However, PRs from me and other people will very likely change this, so it uses just callback
instead of context.succeed()
.
Anyway, what does this mean for my testing? Well currently what my testing does it it runs the SDK code, which calls context.succeed()
, and then a callback (defined by me) happens. This callback is where it confirms that the response we sent off was good. However, in the new version, the SDK itself will directly call the callback. I was concerned this might cause breaks, but it will actually be a much neater way to do it, as it means I'm directly editing the function that usually sends the response to Alexa. This will mean our tests no longer unintentionally log every single response, and I can customise the checks quite a bit better.
I'm also mildly hopeful (though it's unlikely) that this might fix #14. We'll see.
from alexa-room-finder.
Note that the above is theoretical, I plan to test it more extensively today.
from alexa-room-finder.
Having done some further research, it turns out that lambda-local actually just uses context.done
as its callback, which then calls callback
itself, if it's present. This means that pretty much no change occurs with this new change...
from alexa-room-finder.
Related Issues (20)
- Add calendar owner name functionality
- 'No rooms available' detection too hacky
- Check and improve docs
- Improve testing to check responses
- Improve testing to give better errors HOT 1
- Improve testing section of README
- Add Node file to test authentication/get tokens
- New room names HOT 1
- Copying ARN
- Security Model HOT 2
- Server-side paging
- How to get token
- Microsoft/Amazon Incompatibility HOT 1
- Shared Calendars HOT 2
- Images for ReadMe HOT 4
- Wrong response or crash if no rooms are available HOT 1
- Handling of request errors
- Undiagnosed issues with StartOverIntent. HOT 1
- Test whether inviting rooms to events from the API actually works HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alexa-room-finder.