Intro
To reduce time & cost of development we develop a new way to call api from mobile to backend system for develop real-time application. That is based on Elixir & Phoenix channel, we call it is general api(gen_api). gen_api supports for distributed system that help us don't need to care too much about a lot of things.
How it's work
For regular type, has several steps to add a api for mobile or web app. Usually, develop internal functions and add to a interface for other service can call. For this way we need to integrate between service & api gateway, this required effort & time.
For real-time system, develop a system with a lot of services is complexity for traditional/regular type. Chain of apis from public to target service is thing that made us think about new way.
gen_api, we develop our system with Elixir/Phoenix then we can use distributed system of Elixir (Erlang cluster) and real-time of Phoenix channel for develop api for frontend. Imagine you can cut down some steps in the chain of api from public to target service or automate it!
Public side, we develop a lib that verify & validate data (from json, go to Phoenix is map type) from public then convert it to Elixir struct for internal use. Request from public need to indicate api that want to call & arguments (all of request is a json object) of its api.
Internal side, we develop a lib that can understand api & its argument from client, after verify data it will call rpc to target node (service) in internal cluster. Lib also support multi nodes with some kind of load balancing for scaling. Chain from api gateway to target service, we can automate this phase by add auto scan (active/passive) & add new api/updated api to api gateway. After api is added gateway can service public without touch from dev then we don't need to care about integrate too much.
Validation & security, With Phoenix channel we verify user for each connection (WebSocket) then we just need to care about permission & validation for api. Actually, api gateway just read declared api function and execute it. Dev who develop api need to declare argument type, size/length or use default config of api. We don't need too much effort to integrate for every new api.
Type of response for gen_api, we support regular request/response style (sync), async call (result will send later) & stream for continuing send result to client.
Benefit of gen_api
For dev, dev doesn't need to care about how complex of api gateway, how client interact with server just think about data need to receive & send. Data in internal is Elixir struct then can help dev can easy to develop. For some special type of Elixir we add a protocol to convert it between json & struct.
For devops, sound bad for them, no more task like integration & configuration (include scaling). Dev help them go to retired early 😎
For startup, save time & cost for build a new system. We don't need to much engineer for build a big system.
The future of lib
We are still developing more feature for lib. We will add macro for more convenience & reduce time for declare configuration of api. We will support for lib can be and a app that can run independence by wrap Phoenix & add some functions for verify security of connection.
We will open source for community can use or contribute to lib.
Conclusion
We hope can bring to community our way for who that develop system by Elixir can have a way to save time & cost.
We hope we can complete & open source gen_api in the near future.
Thank you for reading!
// we will comeback and update more details in the future.
Top comments (0)