Coder Social home page Coder Social logo

balasan-kelinci's Introduction

Balasan sang Kelinci

Proof of concept, using Koa as API Gateway that encapsulate pub/sub messaging system using RabbitMQ

Why

I want to have microservices which is literally decoupled from each others. Thus, the API Gateway doesn't have to know the location of other services. All communication are handled by the messaging system.

However, this introduce a new problem as most clients are already built to handle request/reply protocol.

The Approach

I make 2 services. resepsionis, that act as API Gateway, and koki that act as internal service.

Whenever the resepsionis got any http request from client, it will publish a message Es teh dua to pesanMakanan queue.

koki listen to pesanMakanan queue and publish the reply (i.e: Es teh dua maPuluhRebu which is literally goban) to pesananDiterima queue.

Still in the same request handler, resepsionis listen to the pesananDiterima queue and yield the message as http response.

Thus, koki and resepsionis doesn't have to know each other. Furthermore, the client doesn't have to implement pub/sub mechanism by itself (i.e: the old-school AJAX Jquery will serve well).

Try it

  • Invoke npm install
  • Create pesanMakanan and pesananDiterima queue in your rabbitMq. (I use this connection string: amqp://root:toor@localhost:5672, but feel free to change it).
  • Run koki by invoking node koki.js
  • Run resepsionis by invoking resepsionis.js
  • Open browser/postman, send any http request to http://localhost:3000, and you will get Es teh dua maPuluhRebu which is literally goban

balasan-kelinci's People

Contributors

gofrendiasgard avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.