Documentation
¶
Overview ¶
Package client provides the Nahook ingestion client for sending webhooks.
Index ¶
- type Client
- func (c *Client) Close()
- func (c *Client) HTTPClient() *http.Client
- func (c *Client) Send(ctx context.Context, endpointID string, opts nahook.SendOptions) (*nahook.SendResult, error)
- func (c *Client) SendBatch(ctx context.Context, items []nahook.SendBatchItem) (*nahook.BatchResult, error)
- func (c *Client) Trigger(ctx context.Context, eventType string, opts nahook.TriggerOptions) (*nahook.TriggerResult, error)
- func (c *Client) TriggerBatch(ctx context.Context, items []nahook.TriggerBatchItem) (*nahook.BatchResult, error)
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the Nahook ingestion client.
func (*Client) Close ¶ added in v0.2.1
func (c *Client) Close()
Close drains the SDK-owned *http.Transport's idle connection pool. Useful for clean test teardown, graceful shutdown, or explicit reset before recycling long-lived clients. Idempotent. No-op when a caller-owned *http.Client was supplied via WithHTTPClient — that transport's lifecycle belongs to the caller.
func (*Client) HTTPClient ¶ added in v0.2.0
HTTPClient returns the underlying *http.Client used by the SDK. Useful for introspection or attaching instrumentation. Mutating the returned client affects all subsequent SDK requests.
func (*Client) Send ¶
func (c *Client) Send(ctx context.Context, endpointID string, opts nahook.SendOptions) (*nahook.SendResult, error)
Send sends a payload to a specific endpoint. If IdempotencyKey is not set in opts, a UUID v4 is generated automatically.
func (*Client) SendBatch ¶
func (c *Client) SendBatch(ctx context.Context, items []nahook.SendBatchItem) (*nahook.BatchResult, error)
SendBatch sends payloads to multiple specific endpoints in a single request (max 20 items).
func (*Client) Trigger ¶
func (c *Client) Trigger(ctx context.Context, eventType string, opts nahook.TriggerOptions) (*nahook.TriggerResult, error)
Trigger fans out a payload by event type to all subscribed endpoints.
func (*Client) TriggerBatch ¶
func (c *Client) TriggerBatch(ctx context.Context, items []nahook.TriggerBatchItem) (*nahook.BatchResult, error)
TriggerBatch fans out payloads by event types in a single request (max 20 items).
type Option ¶
type Option func(*options)
Option configures the Client.
func WithHTTPClient ¶ added in v0.2.0
WithHTTPClient supplies a caller-owned *http.Client to use for all requests. The SDK uses it verbatim and does not mutate it. The caller's HTTPClient.Timeout governs request timeouts and is what TimeoutError.TimeoutMs reports — note that Go's zero-value Timeout means "no timeout", which propagates to TimeoutMs as 0. Pair this with a *http.Transport tuned for your workload, OpenTelemetry round-trippers, mTLS, or any custom RoundTripper pipeline.
func WithRetries ¶
WithRetries sets the maximum number of retries for retryable errors.
func WithTimeout ¶
WithTimeout sets the HTTP request timeout. Ignored when WithHTTPClient is also supplied — the caller-owned *http.Client's Timeout governs in that case.