API Reference
bridge
import "github.com/danmestas/dagnats/bridge"Index
type AckMap
AckMap tracks in-flight tasks for HTTP workers. Maps task_id ({runID}.{stepID}) to the NATS message so the bridge can ack/nak on behalf of the HTTP client when it resolves the task.
Thread-safe: multiple poll/resolve handlers run concurrently. Bounded by the number of in-flight tasks across all HTTP workers.
type AckMap struct {
// contains filtered or unexported fields
}func NewAckMap
func NewAckMap() *AckMapNewAckMap creates an empty AckMap ready for use.
func (*AckMap) Count
func (am *AckMap) Count() int64Count returns the number of in-flight tasks.
func (*AckMap) Delete
func (am *AckMap) Delete(taskID string)Delete removes a task from the map after resolution.
func (*AckMap) Load
func (am *AckMap) Load(taskID string) (jetstream.Msg, bool)Load retrieves the NATS message for the given task ID. Returns (nil, false) if not found.
func (*AckMap) Store
func (am *AckMap) Store(taskID string, msg jetstream.Msg)Store saves a NATS message keyed by task ID. Panics on empty taskID or nil msg — both are programmer errors.
type Bridge
Bridge is an HTTP-to-NATS gateway that lets non-Go workers interact with DagNats over HTTP. Three deep endpoints expose the full worker lifecycle: connect, poll, and resolve.
Authentication: when DAGNATS_BRIDGE_TOKEN env var is set, all requests must include Authorization: Bearer <token>. When unset, all requests are allowed (development mode).
type Bridge struct {
// contains filtered or unexported fields
}func NewBridge
func NewBridge(nc *nats.Conn, tel *observe.Telemetry) *BridgeNewBridge creates a Bridge. Panics on nil nc — a programmer error. Binds optional KV buckets for checkpoints (nil if not present). If tel is nil, uses a noop telemetry provider.
func (*Bridge) Handler
func (b *Bridge) Handler() http.HandlerHandler returns an http.Handler with the three bridge routes. The mux routes are:
- POST /v1/workers/connect
- POST /v1/tasks/poll
- POST /v1/tasks/ (resolve, path includes task ID)
Generated by gomarkdoc