Documentation
¶
Index ¶
- Constants
- func CaptureError(err error)
- func Middleware(apiKey, ingestURL string, opts ...Option) func(http.Handler) http.Handler
- type HTTPDoer
- type OnCaptureFunc
- type OnDropFunc
- type Option
- func WithBaseRetryDelay(d time.Duration) Option
- func WithBufferSize(n int) Option
- func WithHTTPClient(c HTTPDoer) Option
- func WithMaxRetries(n int) Option
- func WithOnCapture(fn OnCaptureFunc) Option
- func WithOnDrop(fn OnDropFunc) Option
- func WithTimeout(d time.Duration) Option
- func WithWorkers(n int) Option
- type Service
Constants ¶
const Version = "0.2.2"
Variables ¶
This section is empty.
Functions ¶
func CaptureError ¶
func CaptureError(err error)
Types ¶
type OnCaptureFunc ¶
type OnCaptureFunc func(payload map[string]interface{})
type OnDropFunc ¶ added in v0.2.0
OnDropFunc is called whenever a captured payload is dropped instead of delivered — either the send buffer was full ("buffer_full"), or the service is paused after a 429 response ("rate_limited"). It runs on a worker goroutine; a panic inside fn is recovered so a misbehaving callback can never kill a worker.
type Option ¶
type Option func(*Service)
func WithBaseRetryDelay ¶
func WithBufferSize ¶
func WithHTTPClient ¶
func WithMaxRetries ¶
func WithOnCapture ¶
func WithOnCapture(fn OnCaptureFunc) Option
func WithOnDrop ¶ added in v0.2.0
func WithOnDrop(fn OnDropFunc) Option
func WithTimeout ¶
func WithWorkers ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) Close ¶
func (s *Service) Close()
Close stops accepting new sends and blocks until all workers exit after draining the queue. If the service is currently paused after a 429, every remaining queued payload drains as an immediate drop rather than being sent — Close does not wait out the pause. The number of payloads dropped this way is logged once as a single aggregate line before Close returns.
func (*Service) Flush ¶
Flush blocks until every payload accepted before this call was resolved -- delivered, permanently dropped (buffer full at capture time, or rate-limited), or failed after exhausting retries -- or until ctx is done. It snapshots the accepted count at call time, so payloads captured concurrently with or after the call are not waited on; that's what makes "before this call" well-defined for concurrent callers.
If the service is currently paused after a 429, payloads dequeued during the call drain immediately as drops rather than being sent — Flush does not wait out the pause, it only waits for that drop itself to be recorded as resolved, which happens essentially immediately (no sleep on that path). A caller that needs an actual pause to clear before exiting should check separately rather than relying on Flush for that.
The number of payloads dropped as rate-limited during the call is logged once as a single aggregate line, not once per payload.