Do you wonder what this Smoke is all about? It is not about the pollution engulfed environment, but this is the new framework written and built in swift language and it has many other benefits related to it. Let’s discuss further with this post…
What Is Smoke?
As the name suggests, this is a light-weight framework, called Amazon Smoke; it is a new open-source light-weight server-side framework, which is written in Swift and aims to build REST-like or RPC-like services. Its architectural mechanism is based upon the ease of use and gives a pure-functional programming style to the request handlers.
Amazon Smoke is built on Apple’s SwiftNIO and is integrated into the Swift Package Manager. Developers can include it in a project by adding the dependency rule to package.swift
How To Create A Service With Amazon Smoke?
Well, this process only requires three simple steps, wherein the developer needs to follow the steps mentioned below:
- Define the operations to help you handle the incoming requests. These actions are further defined by a function, which consumes the Operation Input and a generic Application Context, and returns an Operation Output, either synchronously or asynchronously. However, the input and output types hold the Validatable Codable protocol.
- Select the way to choose the operation handlers to process the incoming requests. With Smoke, developers can attain the StandardSmokeHTTP1HandlerSelector, which can further be used for REST-like services.
- Set the application server to decode requests, dispatch handlers, and encode and send responses back to the client. The process of encoding and decoding involves the responsibilities of a mobile app, which are further escalated to the application server. With Smoke, developers can include a JSON Payload HTTP1 Operation Delegate for JSON requests and responses.
What More Is Special About Smoke?
The key feature of the Smoke framework is the application context, which can be created at launch time and passed to all handlers, on a parallel mode.
However Amazon recommends changing this object strongly-typed and immutable, so the streamlined output can be experienced by eliminating the thread-safe.
Also, with Smoke, by using the context, the handlers can be written as pure-functions and their output would only be dependent on their inputs and the passed context. This eases down the process for the unit test handlers and removes the difference between development and deployment environment to the handlers.
Developers can easily achieve this by using the context to pass any dependency that might differ between development and deployment contexts, such as mocking services, random number generators, etc.
Another exciting feature of Smoke is that by default, any errors thrown from an operation handler would flunk the operation and the framework would return a 500 Internal Server Error to the caller. This would help the developers to secure the leakage of any unintentional error information.
Smoke would definitely turn the testing of operation handlers much easy and without any pain. Albeit, it is advised that operation handlers are pure functions, where the function can be called in unit tests with appropriately constructed input and context instances.
Eventually, this would help the mobile app developers to get the most out of the technology and implement the knowledge in the app platform in much interesting and engaging manner.
On the other hand, if you are looking forward to getting a mobile app developed efficiently, then you must get in touch with a brood of efficient mobile app development in USA to help you get the maximum output of your app concept, as the experienced app developers, hold the relevant exposure to handle the app challenges and turn them into a seamless journey for your targeted audience without a fail.