Skip to content

Server

This module provides a FastAPI server for managing commands and replies in a distributed system.

ATTRIBUTE DESCRIPTION
PORT

The port number for the FastAPI server.

TYPE: int

HOST

The host address for the FastAPI server.

TYPE: str

FUNCTION DESCRIPTION
place_command

Place a command in the outbound queue.

place_reply

Place a reply in the outbound queue.

start_server

Start the FastAPI server if it is not already running.

Documentation last updated: 2025-06-11

Command

Bases: BaseModel

Request model for the FastAPI server.

Reply

Bases: BaseModel

Reply model for the FastAPI server.

clear_commands

clear_commands() -> dict

Clear the commands in the outbound queue.

RETURNS DESCRIPTION
dict

A dictionary indicating the status of the clear operation.

TYPE: dict

clear_commands_target

clear_commands_target(target: str) -> dict

Clear the commands in the outbound queue for a specific target.

PARAMETER DESCRIPTION
target

The target worker to clear the commands for.

TYPE: str

RETURNS DESCRIPTION
dict

A dictionary indicating the status of the clear operation.

TYPE: dict

clear_replies

clear_replies() -> dict

Clear the replies in the outbound queue.

RETURNS DESCRIPTION
dict

A dictionary indicating the status of the clear operation.

TYPE: dict

clear_replies_target

clear_replies_target(request_id: str) -> dict

Clear the replies in the outbound queue for a specific request_id.

PARAMETER DESCRIPTION
request_id

The request ID to clear the reply for.

TYPE: str

RETURNS DESCRIPTION
dict

A dictionary indicating the status of the clear operation.

TYPE: dict

commands

commands() -> dict

Get the commands in the outbound queue.

RETURNS DESCRIPTION
dict

A dictionary containing the outbound commands.

TYPE: dict

get_command

get_command(target: str) -> Command

Get a command from the hub.

PARAMETER DESCRIPTION
target

The target worker to get the command for.

TYPE: str

RETURNS DESCRIPTION
Command

The command for the specified target worker.

TYPE: Command

get_reply

get_reply(request_id: str) -> Reply

Get a command from the hub.

PARAMETER DESCRIPTION
request_id

The request ID to get the reply for.

TYPE: str

RETURNS DESCRIPTION
Reply

The reply for the specified request ID.

TYPE: Reply

place_command

place_command(command: Command) -> str

Place a command in the outbound queue.

PARAMETER DESCRIPTION
command

The command to place in the outbound queue.

TYPE: Command

RETURNS DESCRIPTION
str

The request ID of the command.

TYPE: str

place_reply

place_reply(reply: Reply) -> str

Place a reply in the outbound queue.

PARAMETER DESCRIPTION
reply

The reply to place in the outbound queue.

TYPE: Reply

RETURNS DESCRIPTION
str

The reply ID of the reply.

TYPE: str

read_root

read_root() -> dict

Root endpoint for the FastAPI server.

RETURNS DESCRIPTION
dict

A simple greeting message.

TYPE: dict

register_model

register_model(target: str) -> dict

Register the model with the hub.

PARAMETER DESCRIPTION
target

The target worker to register.

TYPE: str

RETURNS DESCRIPTION
dict

A dictionary containing the list of registered workers.

TYPE: dict

registry

registry() -> dict

See the registry of workers.

RETURNS DESCRIPTION
dict

A dictionary containing the worker registry.

TYPE: dict

replies

replies() -> dict

Get the replies in the outbound queue.

RETURNS DESCRIPTION
dict

A dictionary containing the outbound replies.

TYPE: dict

send_command

send_command(command: Command) -> dict

Send a command to the hub.

PARAMETER DESCRIPTION
command

The command to send.

TYPE: Command

RETURNS DESCRIPTION
dict

A dictionary containing the request ID of the command.

TYPE: dict

send_reply

send_reply(reply: Reply) -> dict

Send a command to the hub.

PARAMETER DESCRIPTION
reply

The reply to send.

TYPE: Reply

RETURNS DESCRIPTION
dict

A dictionary containing the reply ID of the reply.

TYPE: dict

start_server

start_server(host: str = HOST, port: int = PORT)

Start the FastAPI server if it is not already running.

PARAMETER DESCRIPTION
host

The host address for the server.

TYPE: str DEFAULT: HOST

port

The port number for the server.

TYPE: int DEFAULT: PORT