bcgov / aries-acapy-plugin-redis-events

Apache License 2.0
5 stars 13 forks source link
aries citz digital-trust hyperledger hyperledger-aries trust-over-ip verifiable-credentials verifiable-organizations-network von

ACA-PY Redis Queue Plugin - Has Moved! Lifecycle:Moved

Code Quality Check Tests

:warning: Move Notice :warning:

The ACA-PY Redis Queue Plugin has been donated to the Hyperledger Foundation Aries project and has been moved to its new home in the hyperledger/aries-acapy-plugins repository. You'll find it in the redis_events folder.

We're proud for the code to join the many other code contributions made by the Province of British Columbia to the Hyperledger Foundation.

This repository has been archived and will no longer be maintained.

About the ACA-PY Redis Queue Plugin

This plugin provides mechansim to persists both inbound and outbound messages, deliver messages and webhooks, and dispatch events.

For receiving inbound messages, you have an option to either setup a mediator or a relay [supports direct response].

For the mediator scenario:

  flowchart LR;
      InboundMsg([Inbound Msg])-->Mediator;
      Mediator-->InboundQueue[(Inbound Queue)];
      InboundQueue-->YourAgent{{Your Agent}};

For the relay scenario:

  flowchart LR;
      InboundMsg([Inbound Msg])-->Relay;
      Relay-->InboundQueue[(Inbound Queue)];
      InboundQueue-->YourAgent{{Your Agent}};

The demo directory contains a working example/template for both:

The deliverer service dispatches the outbound messages and webhooks. For the events, the payload is pushed to the relevant Redis LIST [for the topic name, refer to event.event_topic_maps] and further action is delegated to the controllers.

For the outbound scenario:

  flowchart LR;
      YourAgent{{Your Agent}}-->OutboundQueue[(Outbound Queue)];
      OutboundQueue-->Deliverer;
      Deliverer-->OutboundMsg([Outbound Msg]);

Code Structure

The directory structure within this repository is as follows:

│
│
└───redis_deliverer
│   deliver.py
└───redis_queue
│   └───events
│   inbound
│   outbound
│   config
│   utils
└───redis_relay
│   └───relay
|   |   relay
└───status_endpoint
|   status_endpoint
└───int
└───demo
└───docker
|

The code for the Deliverer and Relay processes are in the redis_deliverer and redis_relay directories, respectively. The status_endpoint directory contains code for health endpoints that is used by both of these processes.

The docker directory contains a dockerfile (and instructions) for running aca-py with the redis plugin.

The demo diretory contains example docker-compose files for running aca-py with redis using either of the Relay or Mediator scenarios.

Documentation

Design

Covered in ./redis_queue/README.md

Demo

Covered in ./demo/README.md

Docker

Covered in ./docker/README.md

Installation and Usage

First, install this plugin into your environment:

Note Deployments of the main branch of this repository must be used with ACA-Py artifacts created after ACA-Py PR #2170). If you are using an earlier ACA-Py release (e.g., version 0.8.2 and earlier), you MUST use the v0.0.1 tag of this repository.

$ pip install git+https://github.com/bcgov/aries-acapy-plugin-redis-events.git@v0.1.0

When starting up ACA-Py, load the plugin along with any other startup parameters:

$ aca-py start --arg-file my_config.yml --plugin redis_queue.v1_0.events

Plugin configuration

The redis plugin is configured using an external yaml file. An example yaml configuration is:

redis_queue:
  connection:
    connection_url: "redis://default:test1234@172.28.0.103:6379"

  ### For Inbound ###
  inbound:
    acapy_inbound_topic: "acapy_inbound"
    acapy_direct_resp_topic: "acapy_inbound_direct_resp"

  ### For Outbound ###
  outbound:
    acapy_outbound_topic: "acapy_outbound"
    mediator_mode: false

  ### For Event ###
  event:
    event_topic_maps:
      ^acapy::webhook::(.*)$: acapy-webhook-$wallet_id
      ^acapy::record::([^:]*)::([^:]*)$: acapy-record-with-state-$wallet_id
      ^acapy::record::([^:])?: acapy-record-$wallet_id
      acapy::basicmessage::received: acapy-basicmessage-received
      acapy::problem_report: acapy-problem_report
      acapy::ping::received: acapy-ping-received
      acapy::ping::response_received: acapy-ping-response_received
      acapy::actionmenu::received: acapy-actionmenu-received
      acapy::actionmenu::get-active-menu: acapy-actionmenu-get-active-menu
      acapy::actionmenu::perform-menu-action: acapy-actionmenu-perform-menu-action
      acapy::keylist::updated: acapy-keylist-updated
      acapy::revocation-notification::received: acapy-revocation-notification-received
      acapy::revocation-notification-v2::received: acapy-revocation-notification-v2-received
      acapy::forward::received: acapy-forward-received
    event_webhook_topic_maps:
      acapy::basicmessage::received: basicmessages
      acapy::problem_report: problem_report
      acapy::ping::received: ping
      acapy::ping::response_received: ping
      acapy::actionmenu::received: actionmenu
      acapy::actionmenu::get-active-menu: get-active-menu
      acapy::actionmenu::perform-menu-action: perform-menu-action
      acapy::keylist::updated: keylist
    deliver_webhook: true

The configuration parameters in the above example are:

Connection:

Inbound:

Outbound:

Events:

Plugin deployment

Once the plugin config is defined, it is possible to deploy the plugin inside ACA-Py.

$ aca-py start \
    --plugin redis_queue.v1_0.events \
    --plugin-config plugins-config.yaml \
    -it redis_queue.v1_0.inbound redis 0 -ot redis_queue.v1_0.outbound
    # ... the remainder of your startup arguments

Status Endpoints

Relay and Deliverer service have the following service endpoints available:

The configuration for the endpoint service can be provided as following for relay and deliverer. The API KEY should be provided in the header with access_token as key name.

environment:
    - STATUS_ENDPOINT_HOST=0.0.0.0
    - STATUS_ENDPOINT_PORT=7001
    - STATUS_ENDPOINT_API_KEY=test_api_key_1