Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc update and some test scripts #2189

Merged
merged 7 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions demo/docker-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Aca-Py Docker Test Scripts

These docker compose files allow you to run an aca-py instance against a postgres database.

There are separate scripts for starting the database and agent to allow you to restart the agent against the same postgres database.

This is useful for - for example - initializing a database with on older aca-py version, and then running an upgrade to a newer version.

To start the database:

```bash
docker-compose -f docker-compose-wallet.yml up
```

To start the agent:

```bash
docker-compose -f docker-compose-agent.yml up
```

Note you can edit the docker-compose file to change the aca-py version.

To stop the agent:

```bash
docker-compose -f docker-compose-agent.yml rm
```

To stop the database

```bash
docker-compose -f docker-compose-wallet.yml rm
```

To remove the database volume:

```bash
docker volume rm docker-test_wallet-db-data
```
3 changes: 3 additions & 0 deletions demo/docker-test/db/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM postgres:14
COPY ./init-postgres-role.sh /docker-entrypoint-initdb.d/init-postgres-role.sh
CMD ["docker-entrypoint.sh", "postgres"]
6 changes: 6 additions & 0 deletions demo/docker-test/db/init-postgres-role.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -e

psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" --set username=$POSTGRES_ADMIN_USER --set password="'$POSTGRES_ADMIN_PASSWORD'"<<-EOSQL
CREATE ROLE :username WITH LOGIN SUPERUSER INHERIT CREATEDB CREATEROLE REPLICATION ENCRYPTED PASSWORD :password;
EOSQL
47 changes: 47 additions & 0 deletions demo/docker-test/docker-compose-agent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
version: "3"
services:
vcr-agent:
#image: bcgovimages/aries-cloudagent:py36-1.16-1_0.7.5
build:
context: ../../
dockerfile: docker/Dockerfile.run
ports:
- 8010:8010
- 8001:8001
networks:
- wallet-net
entrypoint: /bin/bash
command: [
"-c",
"sleep 5; \
aca-py start \
--auto-provision \
--seed '00000000o_faber_secondary_school' \
--inbound-transport http '0.0.0.0' 8001 \
--endpoint 'http://host.docker.internal:8001' \
--outbound-transport http \
--genesis-url 'http://test.bcovrin.vonx.io/genesis' \
--auto-accept-invites \
--auto-accept-requests \
--auto-ping-connection \
--auto-respond-messages \
--auto-respond-credential-proposal \
--auto-respond-credential-offer \
--auto-respond-credential-request \
--auto-verify-presentation \
--wallet-type 'askar' \
--wallet-name 'acapy_agent_wallet' \
--wallet-key 'key' \
--wallet-storage-type 'postgres_storage' \
--wallet-storage-config '{\"url\":\"wallet-db:5432\",\"max_connections\":5}' \
--wallet-storage-creds '{\"account\":\"DB_USER\",\"password\":\"DB_PASSWORD\",\"admin_account\":\"postgres\",\"admin_password\":\"mysecretpassword\"}' \
--admin '0.0.0.0' 8010 \
--admin-insecure-mode \
--label 'tester_agent' \
--log-level 'info' ",
]

networks:
wallet-net:
external:
name: docker-test_wallet-net
21 changes: 21 additions & 0 deletions demo/docker-test/docker-compose-wallet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: "3"
services:
wallet-db:
build: ./db
environment:
- POSTGRES_USER=DB_USER
- POSTGRES_PASSWORD=DB_PASSWORD
- POSTGRES_ADMIN_USER=postgres
- POSTGRES_ADMIN_PASSWORD=mysecretpassword
networks:
- wallet-net
ports:
- 5432:5432
volumes:
- wallet-db-data:/var/lib/pgsql/data

volumes:
wallet-db-data:

networks:
wallet-net:
73 changes: 41 additions & 32 deletions docs/GettingStartedAriesDev/PlugIns.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,50 +78,59 @@ The load sequence for a plug-in (the "Startup" class depends on how Aca-Py is ru

```mermaid
sequenceDiagram
participant Startup
Note right of Startup: Configuration is loaded on startup<br/>from aca-py config params
participant Startup
Note right of Startup: Configuration is loaded on startup<br/>from aca-py config params
Startup->>+ArgParse: configure
ArgParse->>settings: ["external_plugins"]
ArgParse->>settings: ["blocked_plugins"]

Note right of Startup: Each configured plug-in is validated and loaded
Startup->>+DefaultContext: build_context()
Startup->>+Conductor: setup()
Note right of Conductor: Each configured plug-in is validated and loaded
Conductor->>DefaultContext: build_context()
DefaultContext->>DefaultContext: load_plugins()
DefaultContext->>+PluginRegistry: register_package() (for built-in protocols)
PluginRegistry->>PluginRegistry: register_plugin() (for each sub-package)
DefaultContext->>PluginRegistry: register_plugin() (for non-protocol built-ins)
loop for each external plug-in
DefaultContext->>PluginRegistry: register_plugin()
alt if a setup method is provided
PluginRegistry->>ExternalPlugIn: has setup
else if routes and/or message_types are provided
PluginRegistry->>ExternalPlugIn: has routes
PluginRegistry->>ExternalPlugIn: has message_types
end
opt if definition is provided
PluginRegistry->>ExternalPlugIn: definition()
end
DefaultContext->>PluginRegistry: register_plugin()
alt if a setup method is provided
PluginRegistry->>ExternalPlugIn: has setup
else if routes and/or message_types are provided
PluginRegistry->>ExternalPlugIn: has routes
PluginRegistry->>ExternalPlugIn: has message_types
end
opt if definition is provided
PluginRegistry->>ExternalPlugIn: definition()
end
end
DefaultContext->>PluginRegistry: init_context()
loop for each external plug-in
alt if a setup method is provided
PluginRegistry->>ExternalPlugIn: setup()
else if a setup method is NOT provided
PluginRegistry->>PluginRegistry: load_protocols()
PluginRegistry->>PluginRegistry: load_protocol_version()
PluginRegistry->>ProtocolRegistry: register_message_types()
PluginRegistry->>ProtocolRegistry: register_controllers()
end
PluginRegistry->>PluginRegistry: register_protocol_events()
end

Note right of Startup: If the admin server is enabled, plug-in routes are added
Startup->>AdminServer: create admin server if enabled
Startup->>AdminServer: setup_context() (called on each request)
AdminServer->>PluginRegistry: register_admin_routes()
loop for each external plug-in
PluginRegistry->>ExternalPlugIn: routes.register() (to register endpoints)
end
alt if a setup method is provided
PluginRegistry->>ExternalPlugIn: setup()
else if a setup method is NOT provided
PluginRegistry->>PluginRegistry: load_protocols()
PluginRegistry->>PluginRegistry: load_protocol_version()
PluginRegistry->>ProtocolRegistry: register_message_types()
PluginRegistry->>ProtocolRegistry: register_controllers()
end
PluginRegistry->>PluginRegistry: register_protocol_events()
end

Conductor->>Conductor: load_transports()

Note right of Conductor: If the admin server is enabled, plug-in routes are added
Conductor->>AdminServer: create admin server if enabled

Startup->>Conductor: start()
Conductor->>Conductor: start_transports()
Conductor->>AdminServer: start()

Note right of Startup: the following represents an<br/>admin server api request
Startup->>AdminServer: setup_context() (called on each request)
AdminServer->>PluginRegistry: register_admin_routes()
loop for each external plug-in
PluginRegistry->>ExternalPlugIn: routes.register() (to register endpoints)
end
```

## Developing a New Plug-In
Expand Down