zig-healthchecks #
A Zig client library for the Healthchecks.io ping API, for signaling that a scheduled job started, finished, or failed. It works against the hosted service and against a self-hosted instance, since the base URL is whatever you pass in.
Requirements #
Zig 0.16.0 or later. The only dependency is zig-uuid, fetched by the Zig build system; non-Zig tooling comes from the Nix flake.
Using it as a library #
Add it to your build.zig.zon:
zig fetch --save git+https://git.jcollie.dev/jeff/zig-healthchecks.git
and wire the module up in build.zig:
const healthchecks_dep = b.dependency("healthchecks", .{
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("healthchecks", healthchecks_dep.module("healthchecks"));
A client owns the HTTP connection and the allocator; a check is identified by its UUID, and each run of that check gets its own run ID so that overlapping runs stay distinguishable in the Healthchecks UI:
const hc = @import("healthchecks");
var client: hc.Client = try .init(io, gpa, "https://hc-ping.com/");
defer client.deinit();
var check = client.check(check_uuid);
var run = check.run();
_ = try run.start(null);
// ...do the work...
_ = try run.success(null);
Run carries one method per ping the API understands — start, success,
fail, log, and exitStatus for reporting a process exit code. Each takes
an optional payload, which is sent as the body of a POST when present and
omitted in favor of a GET when it is null, and each returns the
std.http.Status the server answered with.
Using the executable #
The bundled healthchecks binary pings a check directly:
zig build run -- https://hc-ping.com/ <check-uuid>
Development #
Everything the project needs is in the Nix devshell:
nix develop
zig build test
reuse lint
zig fmt --check .
Where this lives #
The canonical repository is on Forgejo, mirrored to Tangled, and seeded on Radicle:
git clone https://git.jcollie.dev/jeff/zig-healthchecks.git
- Forgejo — https://git.jcollie.dev/jeff/zig-healthchecks
- Tangled — https://tangled.org/jcollie.dev/zig-healthchecks
- Radicle —
rad:zk6FntxLJT8j1WoAPDcFWQibtZiv
A Radicle repository is findable only by its ID, so to seed or clone it from the network:
rad clone rad:zk6FntxLJT8j1WoAPDcFWQibtZiv
License #
MIT — see LICENSES/MIT.txt. The project follows the
REUSE specification, so every file carries its own
copyright and licensing information and reuse lint passes.
- Zig 92%
- Nix 8%