Steroids is a framework I have developed which will enable the developer to develop Microservices using TypeScript which can be deployed in AWS lambda, AWS Fargate, or any other platform. I did this tech talk to share the internals, various design patterns and my design decisions behind this framework.
More information can be found in the following repositories;
https://github.com/99xt/steroidslibrary
https://github.com/99xt/steroidsruntime
2. Some of the features of Steroids
• Write Serverless in Typescript.
• Code synchronously execute asynchronously.
• Write Unit Tests in synchronous style.
• Has its own IoC container for dependency injection - Flask.
• Optimized for GitFlow.
• Deploy anywhere (even inside dockers).
3. Some of the Internals I cover today
• How the dispatcher works.
• Internal Structure of Steroids Services.
• How the IoC container works.
4. Service Container (AWS Lambda, Steroids Runtime, or Test Executor)
Steroids Services
3Rd Party Applications
Extension Manager
Relational Database Storage Caching
Flask IoC
ContainerMSSQL
MySql
S3
FTP
Redis
Elastic Cache
Dispatcher
Service Invoker
Test Runner
Unit Test Cases
VS Code (that run unit tests)
Capsules
Configuration
Manager
Helpers
REST/HTTP npm test
5. The purpose of having a dispatcher
• Reduce merge conflicts.
• Easily migrate Steroids Services to a microservice project.
• Increase modularity.
• Configure Flask (IoC container used for Dependecy Injection).
7. The handler function is different in steroids
Steroids Service 2
Container in Lambda
HelloService
(HelloService.js)
Steroids Service 3
Service
Dispatcher
(handler.js)
1. /hello/world 2. helloLambda 3. handler.hello
8. Dispatcher is an ES6 Proxy object
• Proxy object is used to define custom behavior for fundamental operations (i.e.
property lookup, function invocation, etc).
• The dispatcher uses a Proxy object for property lookup.
• When any property is accesses from the Proxy object, a handler function is called
every time.
9. Proxy objects can also return functions
• Returning function can also be a lambda
function.
• Steroids services can be invoked inside
lambda that lambda function.
• Partial.yml consists of the filename of the
Steroid Service.
• The dispatcher creates an instance of the
steroids service from partial.yml.
10. How the Dispatcher Works
ServiceInvokerDispatcher
2. invokeByFilename()
HelloService
3. <<require>>
4. handle()
1. HelloService
(event,context,callback)
handler.js HelloService.js
12. Why having steroids services?
• Abstract out reusable code
• Keep a common format for HTTP responses
• Keep the code consistent
• Make it easier to migrate
• Make it easier to use synchronous style of coding.
partial.yml service.ts
A single Steroids Service should consist of these two files;
13. Example of a Steroid Service
AbstractService
HelloService
Flask
14. Template Method Design pattern
• Template method pattern defines the program skeleton of an
algorithm , deferring some steps to subclasses
• Steroids Services are based on the template method design pattern
15. The ‘Steroid’ object
• Consists of the core features available in Steroids Framework.
• New instance of the ‘steroid’ object is created in each
AbstractService.
23. What's planned to cover in the Future
• How Unit Testing works.
• How Steroids plugins work.
• How Steroids Runtime works.
• How Data Manipulation works.