Skip to content

Commit

Permalink
no-transport mode
Browse files Browse the repository at this point in the history
Signed-off-by: pstlouis <[email protected]>
  • Loading branch information
PatStLouis committed May 27, 2024
1 parent dca3ef7 commit 7ddb88d
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 80 deletions.
45 changes: 32 additions & 13 deletions aries_cloudagent/config/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,9 @@ def get_settings(self, args: Namespace) -> dict:
if args.storage_type:
settings["storage_type"] = args.storage_type

if args.endpoint:
if args.no_transport:
pass
elif args.endpoint:
settings["default_endpoint"] = args.endpoint[0]
settings["additional_endpoints"] = args.endpoint[1:]
else:
Expand Down Expand Up @@ -777,13 +779,13 @@ def get_settings(self, args: Namespace) -> dict:
if args.notify_revocation:
settings["revocation.notify"] = args.notify_revocation
if args.monitor_revocation_notification:
settings["revocation.monitor_notification"] = (
args.monitor_revocation_notification
)
settings[
"revocation.monitor_notification"
] = args.monitor_revocation_notification
if args.anoncreds_legacy_revocation:
settings["revocation.anoncreds_legacy_support"] = (
args.anoncreds_legacy_revocation
)
settings[
"revocation.anoncreds_legacy_support"
] = args.anoncreds_legacy_revocation
return settings


Expand Down Expand Up @@ -1273,6 +1275,19 @@ class TransportGroup(ArgumentGroup):

def add_arguments(self, parser: ArgumentParser):
"""Add transport-specific command line arguments to the parser."""
parser.add_argument(
"--no-transport",
dest="no_transport",
action="store_true",
env_var="ACAPY_NO_TRANSPORT",
help=(
"Specifies that aca-py will run with no transport configured. "
"This must be set if running in no-transport mode. Overrides any "
"specified transport or endpoint configurations. "
"Either this parameter or the "
"'--endpoint' parameter MUST be specified. Default: false."
),
)
parser.add_argument(
"-it",
"--inbound-transport",
Expand Down Expand Up @@ -1381,6 +1396,10 @@ def add_arguments(self, parser: ArgumentParser):
def get_settings(self, args: Namespace):
"""Extract transport settings."""
settings = {}
if args.no_transport:
settings["transport.no_transport"] = args.no_transport
return settings

if args.inbound_transports:
settings["transport.inbound_configs"] = args.inbound_transports
else:
Expand Down Expand Up @@ -1799,9 +1818,9 @@ def get_settings(self, args: Namespace):
)

if multitenancy_config.get("key_derivation_method"):
settings["multitenant.key_derivation_method"] = (
multitenancy_config.get("key_derivation_method")
)
settings[
"multitenant.key_derivation_method"
] = multitenancy_config.get("key_derivation_method")

else:
for value_str in args.multitenancy_config:
Expand Down Expand Up @@ -1949,9 +1968,9 @@ def get_settings(self, args: Namespace):

if args.endorser_endorse_with_did:
if settings["endorser.endorser"]:
settings["endorser.endorser_endorse_with_did"] = (
args.endorser_endorse_with_did
)
settings[
"endorser.endorser_endorse_with_did"
] = args.endorser_endorse_with_did
else:
raise ArgsParseError(
"Parameter --endorser-endorse-with-did should only be set for "
Expand Down
72 changes: 37 additions & 35 deletions aries_cloudagent/config/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,45 +324,47 @@ def print_banner(
# Title
banner.title(agent_label or "ACA")
# Inbound transports
banner.subtitle("Inbound Transports")
internal_in_transports = [
f"{transport.scheme}://{transport.host}:{transport.port}"
for transport in inbound_transports.values()
if not transport.is_external
]
if internal_in_transports:
banner.list(internal_in_transports)
external_in_transports = [
f"{transport.scheme}://{transport.host}:{transport.port}"
for transport in inbound_transports.values()
if transport.is_external
]
if external_in_transports:
banner.subtitle(" External Plugin")
banner.list(external_in_transports)
if inbound_transports:
banner.subtitle("Inbound Transports")
internal_in_transports = [
f"{transport.scheme}://{transport.host}:{transport.port}"
for transport in inbound_transports.values()
if not transport.is_external
]
if internal_in_transports:
banner.list(internal_in_transports)
external_in_transports = [
f"{transport.scheme}://{transport.host}:{transport.port}"
for transport in inbound_transports.values()
if transport.is_external
]
if external_in_transports:
banner.subtitle(" External Plugin")
banner.list(external_in_transports)

# Outbound transports
banner.subtitle("Outbound Transports")
internal_schemes = set().union(
*(
transport.schemes
for transport in outbound_transports.values()
if not transport.is_external
if outbound_transports:
banner.subtitle("Outbound Transports")
internal_schemes = set().union(
*(
transport.schemes
for transport in outbound_transports.values()
if not transport.is_external
)
)
)
if internal_schemes:
banner.list([f"{scheme}" for scheme in sorted(internal_schemes)])

external_schemes = set().union(
*(
transport.schemes
for transport in outbound_transports.values()
if transport.is_external
if internal_schemes:
banner.list([f"{scheme}" for scheme in sorted(internal_schemes)])

external_schemes = set().union(
*(
transport.schemes
for transport in outbound_transports.values()
if transport.is_external
)
)
)
if external_schemes:
banner.subtitle(" External Plugin")
banner.list([f"{scheme}" for scheme in sorted(external_schemes)])
if external_schemes:
banner.subtitle(" External Plugin")
banner.list([f"{scheme}" for scheme in sorted(external_schemes)])

# DID info
if public_did:
Expand Down
76 changes: 44 additions & 32 deletions aries_cloudagent/core/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,20 +191,21 @@ async def setup(self):
):
LOGGER.warning("No ledger configured")

# Register all inbound transports
self.inbound_transport_manager = InboundTransportManager(
self.root_profile, self.inbound_message_router, self.handle_not_returned
)
await self.inbound_transport_manager.setup()
context.injector.bind_instance(
InboundTransportManager, self.inbound_transport_manager
)
if not context.settings.get("transport.no_transport"):
# Register all inbound transports if enabled
self.inbound_transport_manager = InboundTransportManager(
self.root_profile, self.inbound_message_router, self.handle_not_returned
)
await self.inbound_transport_manager.setup()
context.injector.bind_instance(
InboundTransportManager, self.inbound_transport_manager
)

# Register all outbound transports
self.outbound_transport_manager = OutboundTransportManager(
self.root_profile, self.handle_not_delivered
)
await self.outbound_transport_manager.setup()
# Register all outbound transports if enabled
self.outbound_transport_manager = OutboundTransportManager(
self.root_profile, self.handle_not_delivered
)
await self.outbound_transport_manager.setup()

# Initialize dispatcher
self.dispatcher = Dispatcher(self.root_profile)
Expand Down Expand Up @@ -286,17 +287,18 @@ async def start(self) -> None:
context = self.root_profile.context
await self.check_for_valid_wallet_type(self.root_profile)

# Start up transports
try:
await self.inbound_transport_manager.start()
except Exception:
LOGGER.exception("Unable to start inbound transports")
raise
try:
await self.outbound_transport_manager.start()
except Exception:
LOGGER.exception("Unable to start outbound transports")
raise
if not context.settings.get("transport.no_transport"):
# Start up transports if enabled
try:
await self.inbound_transport_manager.start()
except Exception:
LOGGER.exception("Unable to start inbound transports")
raise
try:
await self.outbound_transport_manager.start()
except Exception:
LOGGER.exception("Unable to start outbound transports")
raise

# Start up Admin server
if self.admin_server:
Expand All @@ -317,14 +319,24 @@ async def start(self) -> None:
default_label = context.settings.get("default_label")

# Show some details about the configuration to the user
LoggingConfigurator.print_banner(
default_label,
self.inbound_transport_manager.registered_transports,
self.outbound_transport_manager.registered_transports,
self.setup_public_did and self.setup_public_did.did,
self.admin_server,
)
LoggingConfigurator.print_notices(context.settings)
if not context.settings.get("transport.no_transport"):
LoggingConfigurator.print_banner(
default_label,
self.inbound_transport_manager.registered_transports,
self.outbound_transport_manager.registered_transports,
self.setup_public_did and self.setup_public_did.did,
self.admin_server,
)
LoggingConfigurator.print_notices(context.settings)
else:
LoggingConfigurator.print_banner(
default_label,
None,
None,
self.setup_public_did and self.setup_public_did.did,
self.admin_server,
)
LoggingConfigurator.print_notices(context.settings)

# record ACA-Py version in Wallet, if needed
from_version_storage = None
Expand Down

0 comments on commit 7ddb88d

Please sign in to comment.