Go API

Links to the package documentation on pkg.go.dev. The site does not copy godoc.

Every exported identifier has a doc comment, enforced by a test (doccomments_test.go). The package documentation is the reference; this page is a map.

PackageImport pathWhat it holds
weirgithub.com/AshwinSathian/weirEngine, Config, Request, Response, Origin, Purge, events, errors
weirhttp.../weir/weirhttpHandler, Middleware, TransportOrigin, HandlerOrigin
store.../weir/storethe Store interface, Entry, optional capability interfaces, the codec
store/memory.../weir/store/memorythe in-process S3-FIFO store
store/storetest.../weir/store/storetestthe conformance suite for store implementations
prom.../weir/observe/prom (own module)Prometheus observer and collector
valkey.../weir/store/valkey (own module)the shared Valkey store
weircaddy.../weir/caddy (own module)the Caddy handler and admin API

The methods you will call

e, err := weir.New(cfg)                       // build an engine
resp, err := e.Serve(ctx, req, origin)        // one request
err = e.Purge(ctx, weir.Purge{...})           // invalidate
stats, err := e.Warm(ctx, reqs, origin)       // prefill at background priority
err = e.SetMode(weir.ModeStaleOnError, ttl)   // incident mode with a time limit
s := e.Stats()                                // gauges
err = e.Close(ctx)                            // stop, wait for fetches, close the store

Stability

From v1.0.0 the exported API of the root module, store, store/memory, store/storetest, weirhttp and observe/prom follows semantic versioning. Construct structs with field names, because fields can be added in a minor release, and match on event kinds and free-text values with a default case.