SCALE DYNAMICALLY
HoS is a micro-service based, dynamically scalable operating environment that can be used both as a web framework or service base operations.
In order to start with HoS you need to define a basic contract for each of your services in the environment. Check out our example of a service contract.
You can then simply require HoS communication and provide it with your service contract. For more information please check HoSCom. Authentication service is the other part that needs to be running in order for the packages to be delivered. Check out information about HoSAuth in its repo.
In HoS we love swagger. before developing your service you need to write your documentation ether in swagger or other tools like API bluepring and convert it to swagger JSON and includes it in your service contract, note that other service will send messages to each other base on basePath
they should start with /
, which in each service should be unique, tasks are in paths
and also should start with /
.
Every single call in HoS environment should be verified by authentication service according to the type of the call and requirement of its content. You can simply run multiple instances of a service to scale to the higher request rate, just as simple as that. There is a RESTfull web API that translats HTTP and HTTPS calls into rabbitMq messages, delivers them into their destination after the message has been verified, and sends the reply back as a response to the same call.
This example runs two services and one authentication service. Then it will send two messages that one of them will fail with code 401:
HoSCom = require'hos-com'# service 1 implementationserviceContract1 = require'./serviceContract1'HoSService1 = serviceContract1HoSService1connectthenHoSService1sendMessage foo: "1" "/ServiceName"task: '/TaskName'method: 'method'thenconsolelog replycatchconsolelog replyHoSService1sendMessage bar: "1" "/ServiceName"task: '/TaskName'method: 'method'thenconsolelog replycatchconsolelog reply# service 2 implementationserviceContract2 = require'./serviceContract2'HoSService2 = serviceContract2HoSService2connectHoSService2on '/TaskName.method'msg.content.foo = 2msgreply msgcontentfoo# authentication serviceHoSAuth = require'hos-auth'authenticationService =HoSServiceconnect@HoSAuthon 'message'if msgcontentfoomsgacceptelsemsgreject