Skip to main content

A highlevel interface for the dispatch API

Project description

Dispatch Highlevel Interface

Build Status PyPI Package Docs

Introduction

A highlevel interface for the dispatch API.

See the documentation for more information.

Usage

The Dispatcher class, the main entry point for the API, provides two channels:

  • Lifecycle events: A channel that sends a message whenever a [Dispatch][frequenz.dispatch.Dispatch] is created, updated or deleted.
  • Running status change: Sends a dispatch message whenever a dispatch is ready to be executed according to the schedule or the running status of the dispatch changed in a way that could potentially require the actor to start, stop or reconfigure itself.

Example using the running status change channel

import os
from unittest.mock import MagicMock
from datetime import timedelta

from frequenz.dispatch import Dispatcher, DispatchInfo, MergeByType

async def create_actor(dispatch: DispatchInfo, receiver: Receiver[DispatchInfo]) -> Actor:
    return MagicMock(dispatch=dispatch, receiver=receiver)

async def run():
    url = os.getenv("DISPATCH_API_URL", "grpc://dispatch.url.goes.here.example.com")
    auth_key = os.getenv("DISPATCH_API_AUTH_KEY", "some-key")
    sign_secret = os.getenv("DISPATCH_API_SIGN_SECRET")

    microgrid_id = 1

    async with Dispatcher(
        microgrid_id=microgrid_id,
        server_url=url,
        auth_key=auth_key,
        sign_secret=sign_secret,
    ) as dispatcher:
        await dispatcher.start_managing(
            dispatch_type="EXAMPLE_TYPE",
            actor_factory=create_actor,
            merge_strategy=MergeByType(),
            retry_interval=timedelta(seconds=10)
        )

        await dispatcher

Supported Platforms

The following platforms are officially supported (tested):

  • Python: 3.11
  • Operating System: Ubuntu Linux 20.04
  • Architectures: amd64, arm64

Contributing

If you want to know how to build this project and contribute to it, please check out the Contributing Guide.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

frequenz_dispatch-1.0.2.tar.gz (22.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

frequenz_dispatch-1.0.2-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

File details

Details for the file frequenz_dispatch-1.0.2.tar.gz.

File metadata

  • Download URL: frequenz_dispatch-1.0.2.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for frequenz_dispatch-1.0.2.tar.gz
Algorithm Hash digest
SHA256 9d8d3055dcb09fc93073daade4c74812e1f3eeee7b04c31a12ba0726b1beef9a
MD5 c5de05f456ab9d9bd06888a1f4d0b553
BLAKE2b-256 26e8d0c7b7e53b8718707d99e618d73078d1959a58585a61045acc35a43c1010

See more details on using hashes here.

Provenance

The following attestation bundles were made for frequenz_dispatch-1.0.2.tar.gz:

Publisher: ci.yaml on frequenz-floss/frequenz-dispatch-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file frequenz_dispatch-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for frequenz_dispatch-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4c6faa9253b7094bb35cc223ebb272bf765586a333eb5e447a84f46c1b57ce81
MD5 717e6d7aac021de626348d9f853da92c
BLAKE2b-256 2d1fb0267327fc412ca84a779322b1ca6971af26d652f464ee1bb61a8bde3b3f

See more details on using hashes here.

Provenance

The following attestation bundles were made for frequenz_dispatch-1.0.2-py3-none-any.whl:

Publisher: ci.yaml on frequenz-floss/frequenz-dispatch-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page