Skip to content

Commit

Permalink
Adjust plugin structure and add docs
Browse files Browse the repository at this point in the history
Signed-off-by: jamshale <jamiehalebc@gmail.com>
  • Loading branch information
jamshale committed Nov 17, 2023
1 parent db04291 commit 66d8129
Show file tree
Hide file tree
Showing 59 changed files with 223 additions and 290 deletions.
48 changes: 0 additions & 48 deletions kafka-events/.github/workflows/code-quality-check.yml

This file was deleted.

55 changes: 0 additions & 55 deletions kafka-events/.github/workflows/publish-release.yml

This file was deleted.

73 changes: 0 additions & 73 deletions kafka-events/.github/workflows/tests.yml

This file was deleted.

31 changes: 0 additions & 31 deletions kafka-events/pyproject.toml

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ services:
relay:
image: http-kafka-relay
build:
context: ../http_kafka_relay
context: ../kafka_events/v1_0/http_kafka_relay
environment:
- BOOTSTRAP_SERVER=kafka
- INBOUND_TOPIC=acapy-inbound-message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ services:
deliverer:
image: kafka-http-deliverer
build:
context: ../deliverer
context: ../kafka_events/v1_0/deliverer
environment:
- BOOTSTRAP_SERVER=kafka
- OUTBOUND_TOPIC=acapy-outbound-message
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
"""Automate setup of Agency + Mediator:
1. Create invitation from mediator
2. Receive invitation in Agency
3. Request mediation from mediator
4. Set mediator as default
"""

"""Automate setup of Agency + Mediator."""
import asyncio
from os import getenv
from typing import Any, Callable, TypeVar
Expand All @@ -27,6 +20,13 @@
from acapy_client.models.mediation_create_request import MediationCreateRequest
from acapy_client.models.mediation_record import MediationRecord
from acapy_client.models.receive_invitation_request import ReceiveInvitationRequest
"""
1. Create invitation from mediator.
2. Receive invitation in Agency.
3. Request mediation from mediator.
4. Set mediator as default.
"""


AGENT = getenv("AGENT_ADMIN_URL")
MEDIATOR = getenv("MEDIATOR_ADMIN_URL")
Expand All @@ -38,6 +38,7 @@
async def wait_for_state(
record: RecordType, state: str, retrieve: Callable
) -> RecordType:
"""Wait for record to reach state."""
while record.state != state:
await asyncio.sleep(1)
record = await retrieve(record)
Expand All @@ -47,6 +48,7 @@ async def wait_for_state(


async def get_mediator_invite(mediator: Client) -> dict:
"""Retrieve invitation from mediator."""
invite = await create_invitation.asyncio(
client=mediator, json_body=CreateInvitationRequest()
)
Expand All @@ -58,6 +60,7 @@ async def get_mediator_invite(mediator: Client) -> dict:


async def agent_receive_invitation(agent: Client, invite: dict) -> ConnRecord:
"""Receive invitation on agent."""
conn_record = await receive_invitation.asyncio(
client=agent, json_body=ReceiveInvitationRequest.from_dict(invite)
)
Expand All @@ -72,6 +75,7 @@ async def _retrieve(record: ConnRecord):


async def agent_request_mediation(agent: Client, conn_id: str):
"""Request mediation from mediator."""
mediation_record = await post_mediation_request_conn_id.asyncio(
conn_id=conn_id, client=agent, json_body=MediationCreateRequest()
)
Expand All @@ -88,6 +92,7 @@ async def _retrieve(record: MediationRecord):


async def agent_set_default_mediator(agent: Client, mediation_id: str):
"""Set mediator as default."""
result = await put_mediation_mediation_id_default_mediator.asyncio(
mediation_id, client=agent
)
Expand All @@ -97,6 +102,7 @@ async def agent_set_default_mediator(agent: Client, mediation_id: str):


async def main():
"""Automate setup of Agency + Mediator."""
if not AGENT or not MEDIATOR:
raise RuntimeError(
"Must set environment variables AGENT_ADMIN_URL and MEDIATOR_ADMIN_URL"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ RUN poetry install --no-dev
# Make site packages location more accessible (for use with volumes)
RUN ln -s $(poetry env info -p)/lib/python3.6/site-packages site-packages

COPY kafka_queue kafka_queue
COPY kafka_events/v1_0/kafka_queue kafka_queue
COPY ./docker/default.yml .
COPY ./docker/plugins-config.yaml .

ENTRYPOINT ["/bin/sh", "-c", "/wait && poetry run aca-py \"$@\"", "--"]
CMD ["start", "--plugin", "kafka_queue", "--arg-file", "default.yml"]
CMD ["start", "--arg-file", "default.yml"]
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ admin-insecure-mode: true

# Load toolbox plugin
plugin:
- kafka_queue
- kafka_queue.v1_0

plugin-config: plugins-config.yaml

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ services:
relay:
image: http-kafka-relay
build:
context: ../http_kafka_relay
context: ../kafka_events/v1_0/http_kafka_relay
ports:
- 3000:80
environment:
Expand All @@ -65,7 +65,7 @@ services:
deliverer:
image: kafka-http-deliverer
build:
context: ../deliverer
context: ../kafka_events/v1_0/deliverer
environment:
- BOOTSTRAP_SERVER=kafka
- OUTBOUND_TOPIC=acapy-outbound-message
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions kafka_events/kafka_events/definition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""Version definitions for this plugin."""

versions = [
{
"major_version": 1,
"minimum_minor_version": 0,
"current_minor_version": 0,
"path": "v1_0",
}
]
File renamed without changes.
Loading

0 comments on commit 66d8129

Please sign in to comment.