Skip to content

sdks

SDKs

Every port ships the same numbered scenarios in the same order, so a concept you learn in one language transfers directly to the next. Pick a language once below and the whole page follows it.

Each snippet on this page is extracted from a program in sdk/<lang>/examples/ that the test suite runs end to end on every CI pass — not copied into the docs by hand.

The one thing curl already does well: say “I ran and I succeeded”. Everything after this is something a one-line HTTP request can’t express.

import deadpost
rotate_logs()
deadpost.ping() # "I ran and succeeded"

A heartbeat says the job finished. A run says when it started, when it finished, and how long it took — so you can alert on a backup that still succeeds but has quietly gone from four minutes to forty.

import deadpost
with deadpost.run() as run:
rebuild_search_index()

An exception marks the run failed and is then re-raised unchanged. Your error handling keeps working exactly as it did; deadpost just learns about it.

import deadpost
try:
with deadpost.run() as run:
dump_database()
except ConnectionError as exc:
# deadpost already reported the failure. This is your own handling —
# the exception reached you exactly as it was raised.
print(f"backup failed: {exc}")

Attach numbers to a run — rows processed, bytes written — and read them back per run in the dashboard.

import deadpost
with deadpost.run(env="prod", region="eu-central") as run:
rows, size = dump_database()
run.tag(rows=rows, bytes=size)

One client, several monitors addressed by name. The common shape once a single process owns more than one scheduled job.

from deadpost import Deadpost
# Reads DEADPOST_TOKEN_DAILY_BACKUP and DEADPOST_TOKEN_NIGHTLY_ETL — one
# environment variable per monitor, the shape secret managers already have.
dp = Deadpost()
take_backup()
dp.ping("daily-backup")
with dp.run("nightly-etl") as run:
run.tag(rows=run_etl())

Pings are buffered to disk through a network blip and replayed when the connection returns, so a flaky link doesn’t read as a dead job.

from deadpost import Deadpost
dp = Deadpost(
spool=True,
max_replay_age=300, # 5 minutes — keep it under the monitor's grace period
)
result = dp.ping(rows=17)
if result.spooled:
print("network is down; check-in buffered, will replay on the next success")

The last scenario is deliberately different in each port — Python gets a decorator, Node gets a Lambda handler — because the point is to show what the SDK feels like when it fits the language it lives in.

import deadpost
@deadpost.monitor(env="prod")
def nightly_etl() -> int:
rows = fetch_rows()
return rows
nightly_etl()