IF is Glued's integration framework, message queue and scheduler.
Implementation Overview:
if microservice
is a set of methods implemented as a separate git projectglued-if-service_name
to interact with a foreign servicedeployment
is a configuration and authorization context of anif microservice
defined by a row/object of theif__deployments
tableaction
is adeployment:microservice.method
map stored as a row in theif__actions
table. actions are triggered by calling an API endpoint (webhook) or by the IF scheduler.action state
makes a stateful history usingif__actions_states
scheduler
is implemented as a set of cron-like rules with some extra sugarcoating (i.e. ttl) stored in theif__scheduler
table and an associated producer that will periodically fill up themessage queue
with work and runner daemons that will subscribe to this queue and launch workers (perform the webhook api calls)message queue
is implemented as theif__mq_queue
table configuring message queues clients can subscribe to.messages
are implemented as theif__mq_messages
table which maps a queue to a message payload and message headers (i.e. ttl, requesting, replies, etc.)notifications
are implemented using the pg_notify capabilities and can be further extended with rabbitmq.logging
is by default implemented using the monolog library.
IF orchestrates if microservices
which facilitate integration with anything thats out there.
- Each
if microservice
implements working with a remote/externalservice
. - Each
if microservice
has associateddeployments
(a set of attributes describing usage of anif microservice
), i.e:- deployment metadata (i.e. name, description, etc.)
- deployment connection (i.e. remote host, auth tokens, rate limits, etc.)
- deployment RBAC rules* (i.e. who can use the if microservice)
- Methods implemented by an
if microservice
(i.e. CRUD operations against an external service) are associated to deployments asactions
(actions are if microservice methods runnable in the context of a deployment configuration). actions- can run on-demand (i.e. provide a caching data transforming interface to external services such as glued-if-ares_gov_cz)
- can run according to a schedule (by the scheduler)
- can interact with each other (via the message queue)
*) RBAC is provided by glued-core's authorization proxy
tbd
The message queue is loosely inspired by RabbitMQ to enable an easy transition between the builtin PostgreSQL based queue and Rabbit. The indented MQ usage is
- to distribute scheduled tasks to workers,
- to facilitate communication between the loosely coupled microservices
- to ensure internal notifications to users are send and individually delivered (with or without user confirmation)
IFMQ, when acting as a RabbitMQ-like message brooker, implements the concepts of
producers
/ code responsible for generating messages - php implementation is part of glued-libqueues
/ 'message destinations' implemented via theif__queues
tableconsumers
/ clients subscribed to queuesexchanges
/ code responsible for delivering messages to queues - direct (unicast), fanout (multicast), header (rule based multicast)
Messges can be