Messaging system in Caliopen

Caliopen relies on nats messaging system to communicate between services.
Most of the time, messages sent on nats are small json documents emitted by a service to trigger an action by another service. As a matter of fact, Caliopen needs a nats server up and running to work properly.
All nats modes may be used by services : asynchronous/synchronous, publish/subscribe, request/reply, etc. depending on use case.

List of services making use of nats system


apiv2

function Notifications.SendEmailAdminToUser:
{
    "message_id": "xxxxxxx",
    "order":      "deliver",
    "remote_id":  "xxxxxxx",
    "user_id":    "xxxxxxx"
}
function REST.SendDraft:
{
    "message_id": "xxxxxxx",
    "order":      "deliver",
    "remote_id":  "xxxxxxx",
    "user_id":    "xxxxxxx"
}
function REST.UpdateContact
{
    "order":      "contact_update",
    "contact_id": "xxxxxxx",
    "user_id":    "xxxxxxx"
}
function REST.launchKeyDiscovery
{
    "order":      "discover_key",
    "contact_id": "xxxxxxx",
    "user_id":    "xxxxxxx"
}
function REST.CreateContact
{
    "order":      "contact_update",
    "contact_id": "xxxxxxx",
    "user_id":    "xxxxxxx"
}
function REST.CreatePGPPubKey
{
    "key_id":       "xxxxxxx",
    "order":        "publish_key",
    "resource_id":  "xxxxxxx",
    "user_id":      "xxxxxxx"
}
function REST.DeletePubKey
{
    "key_id":       "xxxxxxx",
    "order":        "delete_key",
    "resource_id":  "xxxxxxx",
    "user_id":      "xxxxxxx"
}
function REST.CreateUserIdentity
{
    "identity_id":  "xxxxxxx",
    "order":        "add_identity",
    "user_id":      "xxxxxxx"
}
function REST.PatchUserIdentity
{
    "identity_id":  "xxxxxxx",
    "order":        "update_identity",
    "user_id":      "xxxxxxx"
}
function REST.DeleteUserIdentity
{
    "identity_id":  "xxxxxxx",
    "order":        "delete_identity",
    "user_id":      "xxxxxxx"
}

twitter-bridge

function WorkerMsgHandler:
{
    "order":      "xxxxxxx",
    "remote_id":  "xxxxxxx",
    "user_id":    "xxxxxxx"
}
function DMmsgHandler:
{
    "message_id": "xxxxxxx",
    "order":      "xxxxxxx",
    "remote_id":  "xxxxxxx",
    "user_id":    "xxxxxxx"
}
{
    "identity_id":    "xxxxxxx",
    "order":          "update_interval",
    "poll_intervall": "xxxxxxx",
    "protocol":       "twitter",
    "user_id":        "xxxxxxx"
}
function processInDM :
{
  "message_id": "xxxxxxx",
  "order":      "process_inbound",
  "remote_id":  "xxxxxxx",
  "user_id":    "xxxxxxx"
}

imap-bridge

function natsMsgHandler:
{
    "order":      "xxxxxxx",
    "remote_id":  "xxxxxxx",
    "user_id":    "xxxxxxx"
}
{
    "identity_id":    "xxxxxxx",
    "order":          "update_interval",
    "poll_intervall": "xxxxxxx",
    "protocol":       "imap",
    "user_id":        "xxxxxxx"
}
function natsMsgHandler:
{
    "message_id": "xxxxxxx",
    "order":      "deliver",
    "remote_id":  "xxxxxxx",
    "user_id":    "xxxxxxx"
}
function WorkerMsgHandler:
{
    "order":      "xxxxxxx",
    "remote_id":  "xxxxxxx",
    "user_id":    "xxxxxxx"
}

smtp-bridge

function natsMsgHandler:
{
    "message_id": "xxxxxxx",
    "order":      "deliver",
    "remote_id":  "xxxxxxx",
    "user_id":    "xxxxxxx"
}
function processInbound:
{
    "message_id": "xxxxxxx",
    "order":      "process_inbound",
    "remote_id":  "xxxxxxx",
    "user_id":    "xxxxxxx"
}

identities-worker

function imapJob.Run:
{
    "order":      "sync",
    "remote_id":  "xxxxxxx",
    "user_id":    "xxxxxxx"
}
function twitterJob.Run:
{
    "order":      "sync",
    "remote_id":  "xxxxxxx",
    "user_id":    "xxxxxxx"
}
function natsOrdersHandler:
{
    "identity_id":    "xxxxxxx",
    "order":          "xxxxxxx",
    "poll_intervall": "xxxxxxx",
    "protocol":       "xxxxxxx",
    "user_id":        "xxxxxxx"
}

mq-worker

class InboundEmail:
{
    "message_id": "xxxxxxx",
    "order":      "process_inbound",
    "remote_id":  "xxxxxxx",
    "user_id":    "xxxxxxx"
}
class InboundTwitter:
{
    "message_id": "xxxxxxx",
    "order":      "process_inbound",
    "remote_id":  "xxxxxxx",
    "user_id":    "xxxxxxx"
}
class ContactAction:
{
    "order":      "contact_update",
    "contact_id": "xxxxxxx",
    "user_id":    "xxxxxxx"
}
class KeyAction:
{
    "order":      "discover_key",
    "contact_id": "xxxxxxx",
    "user_id":    "xxxxxxx"
}