Documentation
¶
Overview ¶
Package notify implements the switchboard /v1/messages HTTP client used by monitor.notify to post, replace, and thread-append monitoring digests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrSendFullText is returned by Replace when text exceeds MaxChunkRunes; // switchboard PUT replaces a single message and cannot split across chunks, // so the caller must fall back to posting a fresh message. ErrSendFullText = errors.New("notify: message exceeds single-message edit limit") // ErrEditUnsupported is returned by Replace when the gateway responds 501 // Not Implemented (platform does not support message editing). ErrEditUnsupported = errors.New("notify: message edit unsupported by gateway (501)") // ErrNoSuchMessage is returned by Replace when the gateway responds 404 Not // Found (the referenced message was deleted). ErrNoSuchMessage = errors.New("notify: referenced message not found (404)") // ErrDenied is returned when the gateway rejects the request with 401 or 403. ErrDenied = errors.New("notify: request denied by gateway") )
Sentinel errors returned by Client methods so callers (such as monitor.notify replace mode) can branch on upstream capabilities without inspecting raw status codes.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a switchboard /v1/messages client.
func (*Client) Append ¶
Append posts text into an existing message's thread ("<channel>:<id>") via POST /v1/messages. Multi-chunk messages are posted sequentially to the same thread conversation key.
func (*Client) Post ¶
Post sends text to the configured channel via POST /v1/messages. If text exceeds MaxChunkRunes, the first chunk is posted to c.channel and remaining chunks are appended to the returned message's thread (or c.channel if the gateway returned no message ID).
When sessionID is non-empty, Post sets the X-Agent-Session header on the initial POST so switchboard can bind replies in the thread back to that session.
type Config ¶
type Config struct {
// Endpoint is the base URL of the switchboard gateway (e.g.
// "http://switchboard.Namespace.svc:8080").
Endpoint string
// Channel is the default conversation key passed to Post when no thread
// parent is specified.
Channel string
// Token is the bearer token sent in Authorization: Bearer <token>.
Token string
// HTTPClient is the underlying HTTP client; defaults to a 15s timeout client.
HTTPClient *http.Client
// MaxChunkRunes caps the rune length of each POSTed message chunk. Defaults
// to 3500.
MaxChunkRunes int
// MaxRetries is the number of retry attempts on HTTP 429 or 5xx responses
// (excluding 501). Defaults to 3.
MaxRetries int
// BaseBackoff is the initial backoff before the first retry (doubled each
// attempt). Defaults to 200ms.
BaseBackoff time.Duration
// Sleep is an optional hook for tests to intercept backoff sleeps.
Sleep func(ctx context.Context, d time.Duration) error
}
Config configures a switchboard /v1/messages Client.