Skip to content

About

Handler SDKs for TaskDaemon in Python, Node.js, Go, Rust, Java, C# and C++

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

17 Commits

Folders and files

Repository files navigation

TaskDaemon SDKs

Handler SDKs for TaskDaemon in Python, Node.js, Go, Rust, Java, C# and C++

What it is

A monorepo of client SDKs for writing TaskDaemon task handlers. Every SDK implements the same protocol, line-delimited JSON over stdin/stdout, with a run(handler) entry point plus Task, Success and Error types. The repository also holds the CI checks that build and test each SDK, the workflow that publishes versioned packages, and a vcpkg overlay for C++.

Stack

Python, TypeScript/Node.js, Go, Rust, Java (Maven), C# (.NET), C++ (CMake, header-only), GitHub Actions.

Installation

Python taskdaemon==0.1.0, Go v0.1.2, npm @taskdaemon/handler 0.1.2, crates.io taskdaemon-handler 0.1.2, Maven Central io.github.jona62:handler 0.1.2, and NuGet TaskDaemon.Handler 0.1.2 are published and verified. For C++, clone the release source into your handler project's build context:

git clone --branch v0.1.2 --depth 1 https://github.com/jona62/taskdaemon-sdks.git vendor/taskdaemon-sdks
Language Installation
Python python3 -m pip install taskdaemon==0.1.0
Node.js npm install --save-exact @taskdaemon/[email protected]; see Node.js
Go go get github.com/jona62/TaskDaemon-Handlers/[email protected]
Rust taskdaemon-handler = "=0.1.2" in Cargo.toml; see Rust
Java Add io.github.jona62:handler:0.1.2 from Maven Central; see Java
C# dotnet add handler/handler.csproj package TaskDaemon.Handler --version 0.1.2; see C#
C++ Header-only: copy vendor/taskdaemon-sdks/cpp/include/taskdaemon.hpp

The published Python 0.1.0 package exports the run API used by these examples. Java uses Maven coordinate io.github.jona62:handler:0.1.2 and package imports under com.taskdaemon.

See Publishing the SDKs for tested artifacts, registry account setup, trusted-publisher configuration, and the release workflow. C++ also has a tested vcpkg overlay.

Quick Start

Python

from taskdaemon import run, Task, Success

def process(task: Task) -> Success:
    return Success({"echoed": task.task_data})

run(process)

Node.js

import { run, success } from '@taskdaemon/handler';

run(task => success({ echoed: task.task_data }));

Go

import "github.com/jona62/TaskDaemon-Handlers/go"

func main() {
    taskdaemon.Run(func(task taskdaemon.Task) taskdaemon.Result {
        return taskdaemon.Success(task.TaskData)
    })
}

Protocol

Handlers communicate via stdin/stdout with line-delimited JSON.

Input:

{"task_id":"uuid","task_type":"name","task_data":{"message":"hello"},"attempt":1}

Output:

{"status":"success","result":{"message":"hello"}}

An error response uses status: "error", an error string, and a retryable boolean. A retry is scheduled only when retryable is true and the task's retry budget remains:

{"status":"error","error":"Temporary failure","retryable":true}

Write exactly one response line for each request and flush it immediately. SDK runners handle the response encoding and flushing. Send application logs to stderr. The daemon skips non-JSON stdout lines, but logs that resemble response JSON can be mistaken for results. Each process handles multiple tasks. attempt starts at 1 and increases on retries.

Execution timeouts are configured in the daemon. Omit timeout in a handler's configuration to inherit DAEMON_TASK_TIMEOUT, which defaults to 30 seconds.

Documentation

Run it

Run the SDK checks from the repository root with the corresponding toolchain installed:

python3 -m unittest discover -s python/tests -v
npm install --prefix nodejs
npm test --prefix nodejs
go -C go test ./...
cargo test --manifest-path rust/Cargo.toml
cargo build --manifest-path rust/Cargo.toml --example echo
mvn -f java/pom.xml test
dotnet build csharp/TaskDaemon/TaskDaemon.Handler.csproj
dotnet run --project csharp/tests/ProtocolSmoke/ProtocolSmoke.csproj

The Python and Node.js tests exercise a persistent stdin/stdout process, response flushing, success/error responses, retryability, and attempt values. Go tests also cover requests larger than 64 KiB and recovery after malformed request lines.

The SDK checks workflow tests all seven SDKs and builds package artifacts, including installed-consumer checks. Run the separate publishing workflow from main; it checks out the requested version's immutable release tag and uploads a selected registry after its account prerequisites are configured.

License

MIT

About

Handler SDKs for TaskDaemon in Python, Node.js, Go, Rust, Java, C# and C++

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages