feat: add workflow rpc server command
This commit is contained in:
@@ -21,6 +21,7 @@ dependencies = [
|
|||||||
[project.scripts]
|
[project.scripts]
|
||||||
wf = "wf_cli.app:main"
|
wf = "wf_cli.app:main"
|
||||||
wf-mcp = "wf_mcp.cli:main"
|
wf-mcp = "wf_mcp.cli:main"
|
||||||
|
wf-rpc-server = "wf_transport_rpc_http.cli:main"
|
||||||
|
|
||||||
[dependency-groups]
|
[dependency-groups]
|
||||||
dev = [
|
dev = [
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import typer
|
||||||
|
import uvicorn
|
||||||
|
|
||||||
|
from wf_server import build_local_static_workflow_server
|
||||||
|
|
||||||
|
from .app import create_rpc_app
|
||||||
|
|
||||||
|
app = typer.Typer(add_completion=False)
|
||||||
|
|
||||||
|
|
||||||
|
@app.callback(invoke_without_command=True)
|
||||||
|
def serve(
|
||||||
|
store_root: Path = typer.Option(
|
||||||
|
...,
|
||||||
|
"--store-root",
|
||||||
|
help="Directory containing workflow artifact, draft, and run stores.",
|
||||||
|
),
|
||||||
|
host: str = typer.Option("127.0.0.1", "--host"),
|
||||||
|
port: int = typer.Option(8765, "--port", min=1, max=65535),
|
||||||
|
) -> None:
|
||||||
|
"""Serve the local/static WorkflowApi over JSON-RPC HTTP."""
|
||||||
|
server = build_local_static_workflow_server(store_root)
|
||||||
|
rpc_app = create_rpc_app(server)
|
||||||
|
uvicorn.run(rpc_app, host=host, port=port, access_log=False)
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
app()
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typer.testing import CliRunner
|
||||||
|
|
||||||
|
from wf_transport_rpc_http.cli import app
|
||||||
|
|
||||||
|
|
||||||
|
def test_rpc_server_cli_help_mentions_store_root() -> None:
|
||||||
|
result = CliRunner().invoke(app, ["--help"])
|
||||||
|
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert "--store-root" in result.output
|
||||||
|
assert "--host" in result.output
|
||||||
|
assert "--port" in result.output
|
||||||
Reference in New Issue
Block a user