Service definition examples¶
Here are the service definition files for a few builtin applications:
Dashboard Services¶
services:
- name: "dashboard.router"
description: "Router for the dashboard controllers, shared between different subcontrollers."
type: http_router.Router
arguments:
trim_last_slash: true
- name: "dashboard.controller"
description: "Main controller for the dashboard."
type: harp_apps.dashboard.controllers.DashboardController
arguments:
router: !ref dashboard.router
- name: "dashboard.controller.blobs"
description: "Sub-controller for the blobs-related routes of the dashboard."
type: harp_apps.dashboard.controllers.blobs.BlobsController
arguments:
router: !ref dashboard.router
storage: !ref storage.blobs
- name: "dashboard.controller.overview"
description: "Sub-controller for the overview-related routes of the dashboard."
type: harp_apps.dashboard.controllers.overview.OverviewController
arguments:
router: !ref dashboard.router
storage: !ref storage
- name: "dashboard.controller.system"
description: "Sub-controller for the system-related routes of the dashboard."
type: harp_apps.dashboard.controllers.system.SystemController
arguments:
router: !ref dashboard.router
storage: !ref storage
- name: "dashboard.controller.transactions"
description: "Sub-controller for the transactions-related routes of the dashboard."
type: harp_apps.dashboard.controllers.transactions.TransactionsController
arguments:
router: !ref dashboard.router
storage: !ref storage
Read the service reference for dashboard, generated from this file.
HTTP Client Services¶
services:
# Main http client service, using httpx
- name: "http_client"
type: [!cfg "type", "httpx.AsyncClient"]
defaults:
transport: !ref "http_client.proxy_transport"
arguments: [!cfg "arguments", {}]
# Proxy filter, decorating the regular http transport
- name: "http_client.proxy_transport"
type: [!cfg "proxy_transport.type", "harp_apps.http_client.transports.AsyncFilterableTransport"]
defaults:
- transport: !ref "http_client.transport"
arguments: [!cfg "proxy_transport.arguments", {}]
# Default httpx transport implementation, handling the actual http requests
- name: "http_client.transport"
type: [!cfg "transport.type", "httpx.AsyncHTTPTransport"]
arguments: [!cfg "transport.arguments", {}]
Read the service reference for http_client, generated from this file.
Storage Services¶
services:
- name: "storage"
description: "Main storage facade, most probably based on the underlying sql/sqlalchemy implementation."
base: harp_apps.storage.types.storage.IStorage
type: harp_apps.storage.services.sql.SqlStorage
- name: "storage.blobs"
description: Placeholder for Blob Storage. Will be overriden by specific implementations.
base: harp_apps.storage.types.IBlobStorage
arguments: [!cfg "blobs.arguments", {}]
- name: "storage.engine"
description: "SQLAlchemy Engine."
base: sqlalchemy.ext.asyncio.AsyncEngine
type: harp_apps.storage.engines.SQLAlchemyEngine
constructor: from_url
arguments: { "url": [!cfg "url"] }
- name: "storage.worker"
description: "Storage async worker"
base: harp_apps.storage.worker.StorageAsyncWorkerQueue
- condition: [!cfg "blobs.type == 'sql'", !!bool "true"]
services:
- name: "storage.blobs"
description: "SQL based Blob Storage."
override: "merge"
type: harp_apps.storage.services.blob_storages.sql.SqlBlobStorage
defaults: {} #db: !ref "storage.sql"
- condition: !cfg "blobs.type == 'redis'"
services:
- name: "storage.blobs"
description: "Redis based Blob Storage."
override: "merge"
type: harp_apps.storage.services.blob_storages.redis.RedisBlobStorage
defaults:
client: !ref "storage.redis"
- condition: [!cfg "redis is not None", !cfg "blobs.type == 'redis'"]
services:
- name: "storage.redis"
description: "Asynchronous Redis Client."
base: [!cfg "redis.base", "redis.asyncio.Redis"]
type: [!cfg "redis.type", "harp_apps.storage.services.redis.Redis"]
constructor: [!cfg "redis.constructor", "from_url"]
defaults:
url: !cfg ["redis.url", "redis://localhost:6379/0"]
arguments: [!cfg "redis.arguments", {}]
Read the service reference for storage, generated from this file.