postshttp

package
v1.146.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

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.

func New

func New(deps Deps) *Handler

New builds the handler from its dependencies.

func (*Handler) Register

func (h *Handler) Register(mux *http.ServeMux, wrap func(http.Handler) http.Handler)

Register mounts the route, wrapped in the portal authentication middleware. A nil handler mounts nothing.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL