2.5 KiB
2.5 KiB
WS-C — docker source
| Field | Value |
|---|---|
| Status | Done |
| Owner | — |
| Phase | 1 (parallel) |
| Depends on | P0 |
| Blocks | WS-E, WS-F, WS-G (to finish) |
| Owned files | src/sources/docker.rs, examples/docker_ps.rs |
Goal
Implement DockerSource over the Docker or Podman API with bollard on a unix socket. A missing Docker never breaks the rest of the service.
Tasks
Tick these in TODO.md.
- C1 Construct with
Docker::connect_with_unix(socket, timeout, API_DEFAULT_VERSION). Construction must not fail when the socket is absent (review G9). Map connection-refused, not-found and permission-denied toAppError::Unavailablewith a clear message on each call. - C2
ps():list_containers(all = true).- Then
inspect_containerfor each one concurrently, bounded withbuffer_unordered(8). - Map
State.Health.Status,State.StartedAt(to uptime seconds),RestartCount, image, and status.
- C3
container_status(name)uses inspect only. A 404 maps toNotFound. - C4
logs(name, follow, tail, since, token)returns a boxedStream<Item = Result<LogLine>>. Usestdout,stderrandtimestamps = true, parse the timestamp prefix, and keep the stream type (stdout or stderr). The stream ends when dropped or when the token fires. - C5 Clamp
tailtolimits.max_tail. - C6
examples/docker_ps.rsprintspsas JSON.--logs NAME [--follow]streams logs. - C7 (nice-to-have) Run the example against
/run/podman/podman.sockand note any field differences.
Done when
- The example matches
docker ps -aand shows health and uptime for containers with healthchecks. - Following logs streams live, and Ctrl-C exits cleanly.
- With
docker_socketpointed at a missing path, every call returnsUnavailableand nothing panics.
Notes
- Container names from the API have a leading
/. Strip it in DTOs and accept names with or without it. docker logsonly works for thejson-file,localandjournaldlog drivers. Others return an API error, which should map toBadRequestwith the driver named.
Log
- 2026-10-15: Card created.
- 2026-10-15: Implemented C1-C6 on branch
ws-c/docker-source. Verified against the real docker socket (ps, logs, follow). C7 skipped: no Podman socket on this host.psusesbuffered(8)(ordered) instead ofbuffer_unordered. Names are validated to[A-Za-z0-9_.-]. Non-readable log drivers are rejected up front from inspect (BadRequest naming the driver).