Async Contracts

Mapa atual das filas BullMQ e das operacoes assíncronas internas do servico.

Canais

reminders.scanreminders.dispatchnotifications.scannotifications.dispatchpush.dispatchcommunications.delivery.status_changedcommunications.message.received

Operacoes

enqueueReminderScanenqueueReminderDispatchenqueueNotificationScanenqueueNotificationDispatchenqueuePushDispatchpublishDeliveryStatusChangedpublishMessageReceived

Modelo operacional

O contrato async documenta os jobs internos que trafegam por BullMQ/Redis. Nao e um broker publico, mas serve para registrar payloads, responsabilidade e observabilidade do fluxo.

  • reminders.scan: procura reminders elegiveis
  • reminders.dispatch: processa deliveries de reminders
  • notifications.scan: identifica deliveries pendentes
  • notifications.dispatch: prepara dispatch por canal/provider
  • push.dispatch: executa envio web push

Contrato bruto

Baixar AsyncAPI YAML

asyncapi: 3.0.0
info:
  title: Communications Service Async Contracts
  version: 0.1.0
  description: Internal asynchronous contracts represented over BullMQ/Redis queues.
channels:
  reminders.scan:
    address: reminders.scan
    messages:
      queueReminderScan:
        $ref: '#/components/messages/QueueReminderScan'
  reminders.dispatch:
    address: reminders.dispatch
    messages:
      queueReminderDispatch:
        $ref: '#/components/messages/QueueReminderDispatch'
  notifications.scan:
    address: notifications.scan
    messages:
      queueNotificationScan:
        $ref: '#/components/messages/QueueNotificationScan'
  notifications.dispatch:
    address: notifications.dispatch
    messages:
      queueNotificationDispatch:
        $ref: '#/components/messages/QueueNotificationDispatch'
  push.dispatch:
    address: push.dispatch
    messages:
      queuePushDispatch:
        $ref: '#/components/messages/QueuePushDispatch'
  communications.delivery.status_changed:
    address: communications.delivery.status_changed
    messages:
      deliveryStatusChanged:
        $ref: '#/components/messages/DeliveryStatusChanged'
  communications.message.received:
    address: communications.message.received
    messages:
      messageReceived:
        $ref: '#/components/messages/MessageReceived'
operations:
  enqueueReminderScan:
    action: send
    channel:
      $ref: '#/channels/reminders.scan'
    messages:
      - $ref: '#/channels/reminders.scan/messages/queueReminderScan'
  enqueueReminderDispatch:
    action: send
    channel:
      $ref: '#/channels/reminders.dispatch'
    messages:
      - $ref: '#/channels/reminders.dispatch/messages/queueReminderDispatch'
  enqueueNotificationScan:
    action: send
    channel:
      $ref: '#/channels/notifications.scan'
    messages:
      - $ref: '#/channels/notifications.scan/messages/queueNotificationScan'
  enqueueNotificationDispatch:
    action: send
    channel:
      $ref: '#/channels/notifications.dispatch'
    messages:
      - $ref: '#/channels/notifications.dispatch/messages/queueNotificationDispatch'
  enqueuePushDispatch:
    action: send
    channel:
      $ref: '#/channels/push.dispatch'
    messages:
      - $ref: '#/channels/push.dispatch/messages/queuePushDispatch'
  publishDeliveryStatusChanged:
    action: send
    channel:
      $ref: '#/channels/communications.delivery.status_changed'
    messages:
      - $ref: '#/channels/communications.delivery.status_changed/messages/deliveryStatusChanged'
  publishMessageReceived:
    action: send
    channel:
      $ref: '#/channels/communications.message.received'
    messages:
      - $ref: '#/channels/communications.message.received/messages/messageReceived'
components:
  messages:
    QueueReminderScan:
      payload:
        type: object
        additionalProperties: false
    QueueReminderDispatch:
      payload:
        type: object
        required: [deliveryId]
        properties:
          deliveryId:
            type: string
    QueueNotificationScan:
      payload:
        type: object
        additionalProperties: false
    QueueNotificationDispatch:
      payload:
        type: object
        required: [deliveryId]
        properties:
          deliveryId:
            type: string
    QueuePushDispatch:
      payload:
        type: object
        required: [deliveryId]
        properties:
          deliveryId:
            type: string
    DeliveryStatusChanged:
      payload:
        type: object
        required: [event_type, subject, correlation_id, occurred_at, payload]
        properties:
          event_type:
            const: communications.delivery.status_changed
          subject:
            $ref: '#/components/schemas/CrmSubject'
          correlation_id:
            type: string
          occurred_at:
            type: string
            format: date-time
          payload:
            type: object
            required: [status, channel]
            properties:
              status:
                type: string
                enum: [queued, sent, delivered, failed, bounced, unsubscribed]
              channel:
                type: string
                enum: [email, realtime, push, whatsapp, webhook]
              provider:
                type: string
              notification_id:
                type: string
              notification_delivery_id:
                type: string
              recipient_id:
                type: string
              provider_message_id:
                type: string
              recipient:
                type: string
              error_message:
                type: string
    MessageReceived:
      payload:
        type: object
        required: [event_type, subject, correlation_id, occurred_at, payload]
        properties:
          event_type:
            const: communications.message.received
          subject:
            $ref: '#/components/schemas/CrmSubject'
          correlation_id:
            type: string
          occurred_at:
            type: string
            format: date-time
          payload:
            type: object
            required: [channel, from]
            properties:
              channel:
                const: email
              from:
                type: string
              to:
                type: string
              subject:
                type: string
              body_text:
                type: string
              body_html:
                type: string
              provider_message_id:
                type: string
              in_reply_to:
                type: string
              references:
                type: string
  schemas:
    CrmSubject:
      type: object
      required: [type, id]
      properties:
        type:
          type: string
        id:
          type: string