SCALE DYNAMICALLY

What is HoS?

HoS is a micro-service based, dynamically scalable operating environment that can be used both as a web framework or service base operations.

Specifications :


About HoS:

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.

Example:

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 implementation  
serviceContract1 = require('./serviceContract1')
 
HoSService1 = new HosCom serviceContract1
HoSService1.connect().then ()=>
    HoSService1.sendMessage {foo: "1"} "/ServiceName"{task: '/TaskName'method: 'method'}
    .then (reply)=>
        console.log reply
    .catch (reply)=>
        console.log reply
 
    HoSService1.sendMessage {bar: "1"} "/ServiceName"{task: '/TaskName'method: 'method'}
    .then (reply)=>
        console.log reply
    .catch (reply)=>
        console.log reply
 
# service 2 implementation  
serviceContract2 = require('./serviceContract2')
 
HoSService2 = new HosCom serviceContract2
HoSService2.connect()
HoSService2.on '/TaskName.method'(msg)=>
    msg.content.foo = 2
    msg.reply msg.content.foo
 
# authentication service  
HoSAuth = require('hos-auth')
 
authenticationService = new HoSAuth()
HoSService.connect()
 
@HoSAuth.on 'message'(msg)=>
    if msg.content.foo
        msg.accept()
    else
        msg.reject()