fireshttp

package
v1.137.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package fireshttp serves when script schedules fire, for the Schedules tab of the scripts page (#1891). It lays the fires out on the three time axes the page draws them on: a day for the schedules that fire more than once a day, a week for those that fire at least once a week, and three months for the rest.

Every fire comes from script.Cron, the parse the materializer advances a schedule with. The browser draws what this returns and computes no fire of its own, so the page and the scheduler cannot disagree about a DST transition, an @every descriptor or a day-of-month-or-day-of-week expression.

It is mounted by scripthttp, which resolves the caller. Visibility is the run listing's: a caller sees the schedules of the scripts they own and an administrator sees every schedule.

Index

Constants

View Source
const (
	// SectionIntraday is the viewer's day, for schedules that fire more than
	// once a day.
	SectionIntraday = "intraday"
	// SectionMultiDay is the viewer's week, Monday to Monday, for schedules
	// that fire at most once a day and at least once a week.
	SectionMultiDay = "multi_day"
	// SectionLongTerm is three calendar months from the first of the viewer's
	// month, for schedules that fire less than once a week.
	SectionLongTerm = "long_term"
)

The three axes a schedule is drawn on, in the order the page draws them. They are plain strings because they are wire values and nothing else.

View Source
const (
	RhythmMinutes = "minutes"
	RhythmHours   = "hours"
	RhythmDays    = "days"
	RhythmWeeks   = "weeks"
	RhythmMonths  = "months"
)

A row's rhythm is what kind of schedule it is, read off the typical gap between its fires rather than off the expression's text, so an @every descriptor and a hand-written expression are classified like the forms a builder produces. It is what the drawing colors a row by. Fastest first.

View Source
const MaxFiresPerRow = 500

MaxFiresPerRow caps the fires one row carries. A schedule at the one-minute floor fires 1,440 times in a day, and at that density the drawing is a solid band whatever the exact count; the row's FireCount still states it.

View Source
const Route = "GET /api/v1/portal/scripts/fires"

Route is where the layout is served. A literal segment outranks the {id} wildcard, so a script whose id is "fires" cannot shadow it.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deps

type Deps struct {
	Scripts   ScriptLister
	Schedules ScheduleLister
	// Caller is who is asking, as the owner address a script records, or
	// ok=false after writing the refusal.
	Caller func(w http.ResponseWriter, r *http.Request) (owner string, isAdmin, ok bool)
}

Deps carries the two stores and the caller.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler serves the layout.

func New

func New(deps Deps) *Handler

New builds the handler.

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.

type ScheduleLister

type ScheduleLister interface {
	ListSchedules(ctx context.Context, filter script.ScheduleFilter) ([]script.Schedule, error)
}

ScheduleLister reads the schedules of a set of scripts.

type ScriptLister

type ScriptLister interface {
	List(ctx context.Context, filter script.ListFilter) ([]script.Script, error)
}

ScriptLister reads the scripts a caller may see.

type Timeline

type Timeline struct {
	// Timezone is the zone the windows were cut in: the viewer's.
	Timezone   string       `json:"timezone" example:"America/Los_Angeles"`
	Sections   []window     `json:"sections"`
	Unreadable []unreadable `json:"unreadable"`
}

Timeline is every schedule laid out for one viewer.

func Build

func Build(schedules []script.Schedule, names map[string]string, viewer *time.Location, now time.Time) Timeline

Build lays every schedule out for a viewer in viewer at now, each row named by names[ScriptID]. The three windows are cut in the viewer's zone and each schedule is expanded in its own, so a 7 AM New York job and a 7 AM Los Angeles job land three hours apart.

Jump to

Keyboard shortcuts

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