Help us shape the future of Go! Take the 2026 Go Developer Survey

costimport

command
v0.0.0-...-6f603c3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Command wg-costimport copies AI Gateway spend into usage_records.

Cloudflare is the only place spend exists today, and it is the wrong place to keep it: the log rotates on DELETE_OLDEST, so the evidence for any cost claim disappears on Cloudflare's schedule rather than ours, and a log entry carries no project, so "what did this project cost" cannot be asked at all. This program answers both by making the record durable and joinable.

One pass per invocation on a systemd timer, for the reasons wg-monitor is built the same way: the timer is externally visible, a crash needs no supervision logic here, and a missed run is something the operating system records.

Re-running is always safe. Every entry carries the gateway's own id and the write is ON CONFLICT DO NOTHING, so an overlapping window costs a few wasted round trips and nothing else. The import therefore deliberately re-reads a window behind the watermark instead of resuming exactly at it: an entry that arrives out of order would otherwise be skipped forever.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL