Documentation
¶
Overview ¶
Package postshttp serves the posts a managed-script run made to notification channels (#1723): the run page's list of what the run sent with platform.notify and platform.publish, and what became of each.
The posts are read from the notification queue by the run each post's document records, not from the run's outputs. An output is a file the run wrote; a post is a message, and what the person reading the run page wants to know about it is whether it arrived.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Deps ¶
type Deps struct {
// Run reads the run in the path for a caller entitled to it, or writes
// the refusal.
Run func(w http.ResponseWriter, r *http.Request) (*script.Run, bool)
Posts PostReader
}
Deps are the run lookup the route answers under and where the posts are read from.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves the route.
func ForPortal ¶
func ForPortal(scripts *scripthttp.Handler, deps scripthttp.Deps, posts PostReader) *Handler
ForPortal builds the route over the script routes' own run lookup, so a run is found, and refused, the way every other run route finds it: readable by the script's owner, an administrator, and whoever requested the run.
type Post ¶
type Post struct {
Channel string `json:"channel" example:"ops-alerts"`
Title string `json:"title" example:"Orders feed is 41 minutes behind"`
QueuedAt time.Time `json:"queued_at"`
// Status is sent when every delivery went out, failed when any gave up,
// and queued while any is still waiting.
Status string `json:"status" example:"sent"`
// Deliveries counts what the post became: one for a chat or webhook
// channel, one per recipient for an email channel.
Deliveries int `json:"deliveries" example:"1"`
Sent int `json:"sent" example:"1"`
Failed int `json:"failed" example:"0"`
SentAt *time.Time `json:"sent_at,omitempty"`
LastError string `json:"last_error,omitempty" example:"upstream answered HTTP 403"`
}
Post is one post as the run page shows it.
type PostReader ¶
type PostReader interface {
RunPosts(ctx context.Context, runID string) ([]notification.RunPost, error)
}
PostReader reads one run's posts. notifyqueue.PostgresStore implements it.