Optimistic Concurrency in DynamoDb using AWS SDK for JavaScript v3 - aws-sdk

I'm using AWS SDK for JavaScript v3 (#aws-sdk/client-dynamodb)
to work with DynamoDb and need to implement some form of optimistic concurrency. I have multiple lambdas often reading and sometimes writing to a single DDb document. I need to block a Lambda from updating a document if another process has updated it.
I've seen this, but think that it relates to the Java SDK.
Is there a way to do this via the JavaScript SDK? Even if I build it myself with lower level constructs? I've been looking for ways to "update where property = ...." etc without success.

Related

Authentication with AWS Cognito

I've been trying to implement AWS Cognito as an authentication strategy with #feathersjs/authentication but haven't had much luck with the libraries available.
What would be a good starting point to develop this integration? Cognito generates the appropriate JWTs, and the verification can happen offline by parsing the JSON Web Key (jwk.json) file and validating the key. I can get this to happen fine without using the #feathersjs/authentication library, but I'd like to take advantage of the features within that library (user lookup, error handling, etc.)
I've gotten this to work using cogito-express as an Express middleware, but that doesn't have the deeper integration that #feathersjs/authentication offers.
https://github.com/ghdna/cognito-express

Hybrid app development: How to separate HTML5 + CSS3 + JS from PHP + SQL?

I'm used to the full stack approach of developing where PHP can be used to create dynamic HTML and to handle SQL as well. However, I'm now considering creating an hybrid app that can be used across platforms.
So my questions are: should I separate the app into HTML5 + CSS3 + JS and PHP + SQL webservice? If so, how should the connection be done? with ajax requests to the webservice? Is this the correct approach?
Any suggestions, pointers or names of concepts that I should/could read regarding the topic are appreciated.
I'd recommend a microservice approach. Using docker and some other container orchestration tool.
What I mean is that you could have a RESTful API written in php fetching data from a MySQL db (or any other db). Then simply write your front end app, using plain JavaScript, HTML and CSS, or a JavaScript framework (angularjs, react, etc). Then you could make your front end communicate with your back end through your API's endpoints.
The idea behind creating microservices or 12 factor apps, is to separate your apps in components or microservices. Then with some configuration and using the right tools you could have them all communicating between them. This way scaling is way easier, and maintaining the code even more.
Id recommend you read a bit more on JavaScript frameworks and microservices. There's a free course at Udacity on microservices using docker and kubernetes that I know will be extremely helpful. Link here
For front end JavaScript frameworks there's a ton of resources out there. Try CodeSchool free courses or codeacademy's.

Flex realtime polyfill

I'm developing a service in flex which requires realtime invalidations and I was wondering which is the recommended method to add realtime support to Flex applications (any change to data models should be reflected to all subscribed clients).
Here are some concerns:
My server is written in python3 (tornado, sqlalchemy, redis) although I don't care adding another service written in other language as long at it is simple and not a resource hog (no java please :)). My client is written in Flex and this must be supported
I want to have multiple servers\processes to handle realtime
connections and I don't want to use sticky sessions (SPOF?). All of the processes will be behind a Load Balancer.
I don't
care about the transport method as long as it is not proprietary (no RTMP), it has fallbacks and it is well supported (mostly IE9 and above)
Currently, I use Tornadio2 and FlashSocket.IO but both are not maintained and not recommended.
I thought about using SockJS though It doesn't have Flex support (can I use it through the browser?), and it seems that beside FlashSocket.IO, there are no other libraries available. It should also be noted that this library doesn't have fallback capabilities.
During my research, I saw several relevant questions:
Real-Time communication between PHP and Flex application
Realtime update and Push Data in AS3
But they are 4 years old, and doesn't provide a good answer.
Any thoughts on the subject would be appreciated.
It seems that this topic is not hot (to say the least), but in case someone is interested, I managed to get around it by using SockJS on the flex html wrapper and communicating with it using external interface
I am doing something similar in Flex by using WebSockets (sockets.io) on the serverside. On the client side, I am using the AS3WebSockets library from https://github.com/theturtle32/AS3WebSocket
Works exceedingly well!

Can I use a local path to json with Google Maps API

Per the documentation here:
Can I replace:
map.data.loadGeoJson('https://storage.googleapis.com/maps-devrel/google.json');
with a local path such as:
C:\path\file.json ?
or must it be hosted on a server?
Thanks
In general, this used to be not allowed by design. It's a violation of the sandbox.
From Wikipedia -> Javascript -> Security:
JavaScript and the DOM provide the potential for malicious authors to deliver scripts to run on a client computer via the web. Browser authors contain this risk using two restrictions. First, scripts run in a sandbox in which they can only perform web-relatedactions, not general-purpose programming tasks like creating files.
However, it's now possible in current browsers using the FILE API specification.
This should in theory allow you to read it using the FileReader interface, although you might need to use something like JSON.parse() (or $.parseJSON if you're using JQuery) to then interpret it in the way you need. Lots more detail and examples of how to do this are here:
http://www.html5rocks.com/en/tutorials/file/dndfiles/

MVVMCross View blocked by sqlite call

I am trying to build a fairly simple sqlite database based mobile app using mvvmcross and Portable class libraries. The database I have running is fairly large so querying it takes enough time where I don't want the UI to get blocked while running queries.
The way I currently have it set up is in a few classes based on the mvvmcross n+1 tutorials n=10 tutorial. I have two services that manage the look-ups for the two entities.
How can I perform these database calls on a separate thread and have the view be updated when completed. I assume that this capability exists within mvvmcross I just haven't been able to track down the documentation or any tutorials on it specifically.
Any help pointing me to the right direction would be much appreciated.
Thanks,
JH
Portable class libraries do give you access to the ThreadPool - so you could use that to marshall the work onto a background thread? http://msdn.microsoft.com/en-us/library/system.threading.threadpool.queueuserworkitem.aspx
Alternatively, if you have a setup/configuration which allows the TPL to be used in your library, then you could use the TaskFactory or async and await to provide some background threading - this is probably the better long-term route, but getting this setup and working initially may take longer as Xamarin's async support is very new and it's PCL support is changing.