-
Notifications
You must be signed in to change notification settings - Fork 1
Home
The Iris service is called after the Greek personification of the rainbow, as a representation a bridge between mortals and gods and a way of communication between them.
Iris will provides operations to ask and receive information without the need of knowing who is providing it. For that Iris would be using an exchange queue in RabitMQ full of requests identified by a pattern. Iris then will check witch of the services could response to that request to do it and send back an answer to the origin.
Steps:
-
Setup Iris: Provide to iris the basic information for it to work by using the
setup(options: LibOptions)
.
export interface LibOptions {url:string; exchange: string;}
url
: Path to RabbitMQ.
exchange
: Name of the exchange queue.
It would return the functions {act, add}
-
Add a service as provider using
add(pattern: string, implementation: (msg: Buffer) => Promise<Buffer>, opts: AddOptions = {})
:
pattern
: Pattern to which this service will response.
implementation
: Logic to manage the message to return a proper response.
opts
:{queue_namespace?: string;}
It will return Promise<void>
.
-
Get responses from services using
act(pattern: string, opts: ActOptions = {}):
pattern
: Pattern to which this service will response.
opts
:{sync?:boolean, timeout?: number, multi?: boolean}
It will return the proper implementation to get the response needed((payload: Buffer) => Promise<Buffer>)