Documentation
¶
Overview ¶
Package server is a framework for servers of requests and approvals.
The rules of a company's requests (what to fill in, who approves, when it is due) are files in ringi, one of ritsu's languages, and ritsu makes Go code from them. A Server runs that code. For each thing a person does, it asks the Gate whether they may, asks the code what becomes of the request, and saves that in its Store. Then it does what follows: it sends the notices (Notifier), starts the work after an approval (Flows), and rings the timers of the reminders and the deadlines.
In this package, a request type is a kind, and one request that was made is a ticket.
Using it ¶
The command "ritsu ringi init" writes a project that uses the framework, and https://i2y.github.io/ringi-server/ has a tutorial and the guides. A project lists what it gives the server in a Config:
p, err := server.Load(ticketkinds.Contract, ticketkinds.Lang, ticketkinds.Kinds, requests)
…
cfg := server.Config{
Packages: []*server.Package{p}, // the code ritsu made
Gate: gate, // who may do what
Organization: orgfiles.New(org), // the people and the teams
Notifier: notifier, // how the notices are sent
}
Package serve runs a server of it, with flags for the address, the database and the sign-in. In a program of your own, add a Store and an Authenticator to the Config, and make the Server with New. A Server is an http.Handler of the API the project's openapi.json describes, and Server.Do does the same operations from Go. Server.ImportOrganization reads the organization's data, and Server.Run rings the timers and sends the notices. Package web serves the pages in front of a Server.
DESIGN.md says how it works, and why.
Index ¶
- Constants
- Variables
- func AcceptLanguages(header string) []string
- func Busy(err error) bool
- func CheckOwnAnswer(method, path string, status int, body []byte) error
- func FindWords(q string) []string
- func Fold(s string) string
- func KindFailed(err error) bool
- func LogStop(log *slog.Logger, msg string, err error)
- func NewID() string
- func RetryAfter(d time.Duration) string
- func SameJSON(a, b []byte) bool
- func UnfitChar(c rune) bool
- func WholeNumber(n json.Number) (int64, bool)
- type AdminParts
- type Agents
- type Answer
- type Ask
- type AuditEntry
- type AuditLog
- type Authenticator
- type Begun
- type BookAnswer
- type BookCall
- type Books
- type Bundle
- type BundleAct
- type BundleChange
- type BundleFile
- type BundleVectorCount
- type BundleVersion
- type Call
- type Change
- type Checker
- type Choice
- type Clock
- type Config
- type Delivery
- type Draft
- type EffectKey
- type FileInfo
- type Files
- type FindAnswer
- type FindError
- type FindQuery
- type Flows
- type Found
- type Gate
- type GeneratedKind
- type HistoryLine
- type Kind
- type KindVersion
- type LanguageChoice
- type Launch
- type Line
- type MasterLayout
- type Member
- type MineCount
- type MineCounter
- type MineQuery
- type Move
- type MoveRecord
- type Name
- type NamedValue
- type Notice
- type Notifier
- type OperationRecord
- type OrgData
- type OrgLayout
- type OrgPerson
- type OrgProblem
- type OrgProblems
- type OrgSnapshot
- type OrgSource
- type OrgUnread
- type OrgVersion
- type OrgWritten
- type Outcome
- type Package
- type Person
- type Proxy
- type Question
- type Recipient
- type Record
- type RecordQuery
- type Reply
- type Server
- func (s *Server) AddPackageCheck(check func(packages []*Package) error)
- func (s *Server) AdminParts(ctx context.Context, p Person) (AdminParts, error)
- func (s *Server) Administers(ctx context.Context, p Person) bool
- func (s *Server) Answered(ctx context.Context, key EffectKey, a Answer) (Reply, error)
- func (s *Server) Authenticate(r *http.Request) (Person, error)
- func (s *Server) Can(ctx context.Context, p Person, ticket string, events []string) ([]string, error)
- func (s *Server) CheckOrganization(d *OrgData) error
- func (s *Server) CountMine(ctx context.Context, p Person) (map[string]MineCount, error)
- func (s *Server) CountWaiting(ctx context.Context, p Person) (map[string]int, error)
- func (s *Server) Current(kind string, at time.Time) (version int, ok bool)
- func (s *Server) Deliver(ctx context.Context, d Delivery) (Reply, error)
- func (s *Server) Do(ctx context.Context, c Call) (Reply, error)
- func (s *Server) Files() Files
- func (s *Server) FindChoices(ctx context.Context, p Person, among, lang, on string) ([]Choice, error)
- func (s *Server) FindValues(ctx context.Context, p Person, among string, query url.Values, ...) (FindAnswer, error)
- func (s *Server) FormAt(ctx context.Context, p Person, ticket string, revision json.RawMessage) (form json.RawMessage, ok bool, err error)
- func (s *Server) Import(ctx context.Context, ticket json.RawMessage) error
- func (s *Server) ImportOrganization(ctx context.Context) error
- func (s *Server) InOrganization(ctx context.Context, id string) (bool, error)
- func (s *Server) KindsSeen(ctx context.Context, p Person) ([]string, error)
- func (s *Server) MasterRows(ctx context.Context, master string) (MasterLayout, []map[string]string, error)
- func (s *Server) MaxBody() int64
- func (s *Server) MaxBundle() int64
- func (s *Server) MaxOrganization() int64
- func (s *Server) Mine(ctx context.Context, p Person, q MineQuery) ([]json.RawMessage, error)
- func (s *Server) Names(ctx context.Context, ids []string) (map[string]Name, error)
- func (s *Server) Now() time.Time
- func (s *Server) Offered(ctx context.Context, p Person, kind string) (from string, ok bool, err error)
- func (s *Server) OpenAPI() ([]byte, error)
- func (s *Server) Operations() []string
- func (s *Server) Packages() []*Package
- func (s *Server) PackagesChanged() <-chan struct{}
- func (s *Server) People(ctx context.Context) ([]OrgPerson, error)
- func (s *Server) PersonLanguage(ctx context.Context, person string) (string, error)
- func (s *Server) ReadBundles(ctx context.Context) error
- func (s *Server) Replay(ctx context.Context, ticket string) ([]json.RawMessage, error)
- func (s *Server) Replied(ctx context.Context, c Call) (Reply, bool, error)
- func (s *Server) Run(ctx context.Context) error
- func (s *Server) RunTimers(ctx context.Context) (int, error)
- func (s *Server) RunToDo(ctx context.Context) (int, error)
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Server) SignedBundles() bool
- func (s *Server) Submitting(ctx context.Context, p Person, kind string) (Submitting, error)
- func (s *Server) Sweep(ctx context.Context) (files, operations int, err error)
- func (s *Server) TakesBundles() bool
- func (s *Server) Teams(ctx context.Context) ([]Team, error)
- func (s *Server) TicketFiles(ctx context.Context, p Person, ticket string) ([]string, error)
- func (s *Server) Tickets(ctx context.Context, p Person, q TicketsQuery) ([]json.RawMessage, error)
- func (s *Server) Title(kind string, version int, lang string) (title, in string)
- func (s *Server) Try(ctx context.Context, c Call) (Reply, error)
- func (s *Server) Unpackaged(ctx context.Context) ([]TicketCount, error)
- func (s *Server) Upload(ctx context.Context, p Person, info FileInfo, r io.Reader) (string, error)
- func (s *Server) UploadOnce(ctx context.Context, p Person, key string, info FileInfo, r io.Reader) (string, error)
- func (s *Server) VersionPackage(kind string, version int) *Package
- func (s *Server) Waiting(ctx context.Context, p Person, q WaitingQuery) ([]json.RawMessage, error)
- func (s *Server) WorkEnded(ctx context.Context, key EffectKey, o WorkEnd) (Reply, error)
- func (s *Server) Worked(kind string, version int, in json.RawMessage) (out json.RawMessage, problem string, ok bool, err error)
- func (s *Server) Works(ctx context.Context, p Person, ticket string) ([]Work, error)
- func (s *Server) Zone(kind string, version int) *time.Location
- type Start
- type Store
- type Submitting
- type Team
- type TicketCount
- type TicketRecord
- type TicketsQuery
- type Timer
- type TimerKey
- type ToDo
- type TooManyUploads
- type TrialStore
- type UnpackagedError
- type Upload
- type UploadGone
- type VectorCheck
- type VectorCount
- type WaitingCounter
- type WaitingQuery
- type Work
- type WorkEnd
Constants ¶
const ( DefaultMaxOrganization = 64 << 20 DefaultDraftsKept = 24 * time.Hour DefaultImportsPerDay = 20 )
The limits and times of the administration when their settings are 0 (DESIGN 13.3).
const ( DefaultMaxBundle = 64 << 20 // MaxBundleFiles is how many files a bundle may hold. MaxBundleFiles = 10000 // WasmForm is the form of wasm.json the server reads (its key "wasm"). WasmForm = 1 )
The limits of the bundles when their settings are 0, and the form of wasm.json the server reads.
const ( FindShown = 20 FindMost = 100 FindLongest = 200 )
The finds (find_people, find_teams, find_master_<file>_<master>; ringi's DESIGN 13.2): how many values a find answers when its limit is left out, the most it may be asked for, and the most characters (code points) its words may have.
const ( DefaultPage = 50 MaxPage = 100 )
The pages of a list (ringi's DESIGN 12.4): limit is 1 to MaxPage, DefaultPage when left out.
const ( DefaultCommentEvery = 10 * time.Second DefaultCommentsPerTicket = 100 DefaultCommentsPerPerson = 25 )
The comment limits when Config.CommentEvery, Config.CommentsPerTicket and Config.CommentsPerPerson are 0 (DESIGN 7.4).
const ( DefaultUploadsPerPerson = 50 DefaultUploadsKept = 7 * 24 * time.Hour DefaultOperationsKept = 30 * 24 * time.Hour DefaultSweepEvery = time.Hour )
The limits and times of the uploads and the operations' keys when their settings are 0 (DESIGN 2.3, 4.4).
const BundleSignatureHeader = "Bundle-Signature"
BundleSignatureHeader is the header an upload of a bundle sends its signature in: the content of the file `ringi-bundle sign` writes (DESIGN 15.5).
const ( // DefaultMaxCheckTime is how long the whole check of an uploaded bundle may take when // Config.MaxCheckTime is not given: shorter than serve's WriteTimeout, so the answer is // written before the server's own write ends. DefaultMaxCheckTime = 20 * time.Second )
The times the server keeps to.
const MaxOrgFiles = 10000
MaxOrgFiles is how many entries an upload of the organization's data may hold, its directories' among them.
const MaxOrgProblems = 1000
MaxOrgProblems is how many problems the reading and the checks of the organization's data find at the most: past it they stop (OrgProblems.Stopped), so that the problems of a large upload are not all made and kept.
const MaxOutputs = 64 << 10
MaxOutputs is the most bytes of the outputs a work says it ended with (WorkEnd.Outputs).
const MaxReason = 500
MaxReason is the most characters a reason of a switch or an import may have (a line break sent as CR LF counts as one).
const ShownProblems = 100
ShownProblems is how many problems are said one by one: Error writes these, and the administration's answer and page list these; they say how many more were found.
Variables ¶
var ( // ErrNotFound: no such ticket, operation, to-do item or snapshot. ErrNotFound = errors.New("not found") // ErrConflict: the ticket's number is not the one the move read (or a new ticket's ID is // taken). Nothing was written. ErrConflict = errors.New("the ticket moved since it was read") // ErrKeyTaken: the person used the operation's key before. Nothing was written. ErrKeyTaken = errors.New("the operation's key was used before") )
The errors a Store answers.
var Contracts = []int{3}
Contracts are the versions of the contract between ritsu's generated code and a server that this framework reads.
var ErrBundleTooLarge = errors.New("the bundle is too large")
ErrBundleTooLarge is the error of a bundle past its limits: more than MaxBundleFiles files, or more bytes than Config.MaxBundle, as uploaded, in one file or in all once uncompressed. The API answers it 413.
var ErrNoPerson = errors.New("no person")
ErrNoPerson is what an Authenticator answers for a request that names no one it trusts.
var ErrOrganizationTooLarge = errors.New("the organization's data is too large")
ErrOrganizationTooLarge is the error of an upload of the organization's data past its limits: more than MaxOrgFiles entries, or more bytes than Config.MaxOrganization once uncompressed, in one file or in all, by the sizes the zip file records or by the bytes read. The API answers it 413.
var ErrTooManyImports = errors.New("server: the imports are as many as the server takes in a day")
ErrTooManyImports is SaveChange's answer to an import past the imports a day (Change.ImportsMax, Change.ChangesMax).
var ErrTooManyUploads = errors.New("server: the person has as many uploads that no ticket holds as the server keeps")
ErrTooManyUploads is the store's answer to an upload past a person's limit (Store.KeepUpload).
var Statuses = []string{"in_progress", "paused", "with_requester", "approved", "rejected", "withdrawn", "expired"}
Statuses are the statuses a ticket can have, as ringi's contract lists them: list_tickets takes one of them as `status`.
Functions ¶
func AcceptLanguages ¶
AcceptLanguages answers the primary tags of an Accept-Language header, in lower case, the most wanted first: by their q, those of the same q in the header's order, a tag of q=0 and the wildcard left out ("en;q=0.1, ja-JP" is ja, en). The pages, the MCP tools and the pages of signing in choose the language they answer in with it, the first of these they speak, so that one header chooses one language in all of them.
func Busy ¶
Busy reports whether err is a call of a kind that found no instance free in time (wasmkind's ErrBusy): too much work at once, not a failure of the module or another kind of stop. The API and the pages answer it 503 with `Retry-After: 1`, where a stopped call of another kind is the server's failure (500); mcp answers it as a busy outcome the caller may retry. It is read as net.Error is, so the framework does not import the runner: wasmkind's StopError answers Busy for ErrBusy alone.
func CheckOwnAnswer ¶
CheckOwnAnswer checks an answer of the framework's own operations, found by its method and path (/admin/kinds, /files, …; a query is left out), against what framework.openapi.json says the operation answers with that status: an error for a status it does not give the operation, and for a body that is not what it says. It answers nil for an answer with no JSON body (a file, the record as CSV), and for a method and a path that are none of the operations (a path the framework does not serve, a method the path does not take): the tests of the framework check every answer of theirs with it, conformance.Administration each answer of the administration's.
func FindWords ¶
FindWords answers the words a find reads of q: q cut at the characters of White_Space, each folded (Fold), a word that folds to nothing left out. With none, a find answers every value in the order of the values (Find), which the tools' sentence says so.
func Fold ¶
Fold answers a text as a find compares it (ringi's DESIGN 13.2): in NFKC (full-width letters and digits as ASCII, half-width katakana as full-width with their voiced marks joined, "①" as "1", "㈱" as "(株)"), without the characters of Unicode's White_Space (unicode.IsSpace), the hiragana U+3041–U+3096 as the katakana U+30A1–U+30F6, and each character as its simple lowercase mapping (unicode.ToLower: one character to one, with no context and no language's own rules), the final sigma "ς" as "σ". "ΑΛΕΞΗΣ" and "αλεξης" fold alike, "İ" folds to "i" and "ẞ" to "ß", and "ß" is not "ss". It is not golang.org/x/text/cases' Lower, which makes "İ" two characters and a final sigma by the characters around it, nor its Fold, which makes "ß" "ss".
func KindFailed ¶
KindFailed reports whether err is a failure of a kind's own code (a stopped call, a panic, an answer that does not read), and not of the store, the gate or the server's own making.
func LogStop ¶
LogStop logs why a server stopped, at the error level, as msg: each line of err as a record of its own, the first as err and the rest as line, so that a log that writes a record on a line writes each problem of the organization's data at start (OrgProblems) on a line of its own.
func NewID ¶
func NewID() string
NewID makes a ticket's ID: 26 characters, the time in milliseconds (10) then 80 random bits (16), so that IDs sort in the order they were made, to the millisecond (two made in one millisecond sort as their random bits do).
func RetryAfter ¶
RetryAfter writes a wait as the Retry-After header does: whole seconds, rounded up, at least 1.
func SameJSON ¶
SameJSON reports whether two JSON values say the same: a null is the same as a missing key, and the keys of an object may come in any order. This is how the conformance tests compare answers.
func UnfitChar ¶
UnfitChar answers whether a character is one a value the server checks may not hold: a control character; a formatting character, which does not show (Unicode's Cf: the marks that turn the direction the text runs in, the characters of no width, the byte order mark); or a separator of lines or of paragraphs (Zl, Zp), which would make a value look like another or break a line where it is shown. The checks of the organization's data (unfit) refuse all of them; a reason (reasonOf, and the pages' reasonProblem) refuses them apart from a line break.
func WholeNumber ¶
WholeNumber is the whole number a number of JSON is, as the entries and the API's bodies read one: 20, 20.0 and 2e1 are all 20. It is false for a number that is not whole or not inside int64. The adapters read their own whole numbers with it (the MCP tools' limit), so that they take what the API takes.
Types ¶
type AdminParts ¶
type AdminParts struct {
// Kinds: a version of a kind the person may switch; Organization: the organization's page, its
// checks and imports; Records: a line of the record the person may read; Bundles: the bundles,
// which the person may upload or decide (DESIGN 15.8), of a server that takes them.
Kinds, Organization, Records, Bundles bool
}
AdminParts are the parts of the administration a person may use (DESIGN 13.7).
func (AdminParts) Any ¶
func (a AdminParts) Any() bool
Any reports whether the person may use one of the parts.
type Answer ¶
type Answer struct {
// Verdict and Reason are an agent's step's answer.
Verdict string
Reason string
// Outputs are a note's values, as named values of the contract (a JSON array).
Outputs json.RawMessage
// Failed is true when the flow failed; the ticket goes on as its kind says.
Failed bool
}
Answer is what an agent's step or a note answers.
type Ask ¶
type Ask struct {
Key EffectKey
Kind string
Ticket string
// Note is true for a note (ask_note), false for an agent's step (ask_agent).
Note bool
Flow string
Stage string
// Args are the flow's arguments, as named values of the contract.
Args json.RawMessage
}
Ask is an agent's step (ask_agent) or a note (ask_note) a ticket waits for. The answer comes back by Server.Answered with the same key.
type AuditEntry ¶
type AuditEntry struct {
// ID is the entry's key: an entry given again (after a failure) has the same ID.
ID string
At time.Time
Person string
Operation string
Ticket string
Kind string
Key string
// Outcome is "moved" or "refused"; Refused the refusal's kind.
Outcome string
Refused string
Event json.RawMessage
// Via is the way a person's operation came in (Call.Via: "api", "screens", "pages", "mcp"); ""
// for the server's own events (Operation says which: "timer", "answered", "deliver:…").
Via string
}
AuditEntry is one entry of the audit log: an operation that moved a ticket or was refused.
type AuditLog ¶
type AuditLog interface {
Record(ctx context.Context, e AuditEntry) error
}
AuditLog receives the audit log's entries, through the things to do: an entry may be given again after a failure the framework could not tell from a success, with the same ID.
type Authenticator ¶
type Authenticator interface {
// Authenticate answers the person who sends r, or ErrNoPerson (the answer is 401). Any other
// error is a failure of its own (500).
Authenticate(r *http.Request) (Person, error)
}
Authenticator finds who sends a request. The framework reads no sessions, tokens or cookies itself.
type Begun ¶
type Begun struct {
Person string
Key string
Digest string
// Ticket is the ID of the ticket a submit makes; "" for an operation on a ticket.
Ticket string
// Attempt is the name of the try of a submit or a resubmit (ringi's DESIGN 7.1): what the books
// key the try's holds by, with the ticket.
Attempt string
At time.Time
}
Begun is an operation the server began, which it keeps with the operation's key until the key's reply is kept (Store.Begin): who gave the key, the operation's digest, and the names the server gave the operation.
type BookAnswer ¶
BookAnswer is what a book answers a call: Outcome is done, done_before or refused, and Reason says why it was refused. ReasonJa says it in Japanese, for the refusal's text_ja; when it is empty, text_ja is Reason as it is.
type BookCall ¶
type BookCall struct {
Key EffectKey
Kind string
Ticket string
// Call is hold, post or release (a release voids a hold). A release the server makes of a hold
// it did not keep (a try that was not saved: DESIGN 3.2) has the hold's arguments, whose key
// names it.
Call string
Book string
Transfer string
Args []NamedValue
}
BookCall is one call of a book a ticket makes.
type Books ¶
type Books interface {
// Call makes one call. tx is the store's transaction (a pgx.Tx for the PostgreSQL store) when
// the books share the store's database, and nil when they do not (Config.BooksApart). A refusal
// is an answer, not an error.
Call(ctx context.Context, tx any, c BookCall) (BookAnswer, error)
}
Books makes the calls of the books, through the clients chobo generates.
type Bundle ¶
type Bundle struct {
// Digest is the SHA-256 of the archive, in lowercase hexadecimal: the bundle's name.
Digest string
// Adds are the versions it adds: those the server had no package of when it was checked. Holds
// are all the versions it has, Adds among them; the others are the ones the server had, with the
// same description, which the server's own package goes on serving.
Adds []BundleVersion
Holds []KindVersion
// State is "pending" (checked, and waiting for an administrator to decide), "approved" or
// "declined". Hidden says it is not listed.
State string
Hidden bool
// Source is how it came: "upload" (by an administrator, through the API or the pages) or
// "start" (from the directory the server reads as it starts, approved with no one to decide).
Source string
// Size is the archive's size in bytes, and Signed says a key the server takes signed it.
Size int64
Signed bool
// Key names the key that signed it: the key's fingerprint (bundlesign.KeyFingerprint). "" for
// a bundle with no signature, and for one read from the directory at start before the server
// listed keys.
Key string
// Signature is the signature it was uploaded with (the content of the file `ringi-bundle
// sign` writes), kept so that a decision made later verifies it again with the keys the
// process lists then. "" for one with no signature.
Signature string
// Vectors and Worked are how many vectors of the kinds' events and of their forms the checks ran,
// all of which agreed.
Vectors, Worked int
// PerKind is how many of the vectors each kind has, of a ticket's first event (Starts) and of
// the events after it (Nexts), counted at the check and shown on the bundle's page.
PerKind []BundleVectorCount
// Ritsu is the version of ritsu wasm.json names ("0.56.0"), "" for one it does not name. The
// bundle's page shows it beside the key's fingerprint.
Ritsu string
// Uploaded is who uploaded it and when (no person for one read at start); Decided who approved or
// declined it, when and why; Hid who hid it. Decided and Hid are nil while not done.
Uploaded BundleAct
Decided *BundleAct
Hid *BundleAct
}
Bundle is a bundle of kinds of request, as the store keeps it (DESIGN 15): a zip archive of the requests directory `ritsu gen --extra bundle` writes, with the kinds' code as WebAssembly, which an administrator uploads and another approves, or which the server reads from a directory as it starts.
type BundleAct ¶
BundleAct is who did something to a bundle, when, and why ("" for no reason given).
type BundleChange ¶
BundleChange is the bundle part of a Change: the bundle as it is after the change; its archive, which a new bundle is kept with, and which, given again, replaces the one kept (nil keeps it); the state and the hiding it was read with (Was "" for a new bundle); and whether its archive is forgotten (a bundle no ticket can use, hidden: one that was never approved).
type BundleFile ¶
BundleFile is a bundle the server reads as it starts (Config.Bundles): its name (the file's, for what is said of it), its archive, and its signature (the content of the file beside it whose name ends in .sig; nil for none).
type BundleVectorCount ¶
BundleVectorCount is how many vectors of a kind a bundle's check ran: of a ticket's first event (Starts) and of the events after it (Nexts).
type BundleVersion ¶
BundleVersion is a version a bundle adds: the kind, its version, its owner and its title, and whether the kind was new to the server when the bundle was checked.
type Call ¶
type Call struct {
// Operation is the operationId of openapi.json: "submit_leave", "approve", "get_ticket"…
Operation string
// Person is who, as the authenticator found them.
Person Person
// Ticket is the ticket's ID, for an operation on one.
Ticket string
// Body is the body, as the API takes it.
Body []byte
// Key is the operation's idempotency key (every POST has one).
Key string
// Query holds what the operation reads from the query: `on` of the masters, `limit`, `before`
// and `kind` of the lists (`list_waiting`, `list_mine`), and `q`, `limit`, `lang` and `on` of
// the finds (`find_people`, `find_teams`, `find_master_<file>_<master>`).
Query url.Values
// Languages are the languages the caller reads, the most wanted first (the HTTP API's are its
// Accept-Language, AcceptLanguages): a find names its values in the first of them it speaks
// (en or ja) when the query names no `lang`, and in English when there is none.
Languages []string
// Via is the way the call came in, kept in the audit log: "api" (the HTTP API), "screens" (an
// A2UI screen's button), "pages" (a plain HTML page), "mcp" (an agent's tool), or a server's own
// name for another way. "" is "api".
Via string
// Kind and Version name the version of a kind admin_switch_kind switches, and Draft the draft
// admin_get_draft reads (DESIGN 13.6). Upload is the organization's data admin_check_organization
// checks, as a zip archive of its files, read only once the gate allows the person to import
// (DESIGN 13.3): nil when the body names the source. For admin_upload_bundle, Upload is the
// bundle's archive and Signature its signature (nil for none); Bundle names the bundle (its
// digest) of the other operations of the bundles (DESIGN 15.8).
Kind string
Version int
Draft string
Upload io.Reader
Signature []byte
Bundle string
}
Call is one operation of a person: who, on which ticket, what. The HTTP handler makes one from a request; a screen's button makes the same.
type Change ¶
type Change struct {
At time.Time
Record *Record
// Records are the records of a change of a bundle: one for each version it adds (DESIGN 15.7).
Records []*Record
Bundle *BundleChange
Start *Start
// Kept are the starts of the kind's other versions, as the server read them to decide whom the
// switch is allowed for: the store refuses the change (ErrConflict) when the number of one of
// them is not the one it keeps (0 for a version with no start kept).
Kept []Start
Snapshot *OrgSnapshot
Latest string
LastImport *string
ImportsMax int
ChangesMax int
ImportsSince time.Time
Draft string
Person string
Key string
Digest string
Outcome Outcome
Reply json.RawMessage
}
Change is what SaveChange writes, in one write, all or nothing:
- the record (Record), if there is one: a change that changes nothing keeps none;
- for a switch (Start): the version's start, only if its number is still Start.Number, the one the switch read (0 for a version none was decided for; ErrConflict otherwise), and the number of each of Kept is still its Number, with the number raised by one;
- for an import (Snapshot): the snapshot, made the latest, only if the latest is still Latest, the one the import read ("" for none; ErrConflict otherwise), and, when LastImport is not nil, only if the ID of the latest record of an import from Config.Organization (LastImport's record) is still *LastImport ("" for none; ErrConflict otherwise), under a lock that every making of a latest takes (SaveOrganization among them); for one that adds a snapshot (Record.Added), only if fewer than ImportsMax imports that added one were made at or after ImportsSince; for any, only if fewer than ChangesMax records of imports (What "organization", whether they added a snapshot or not) were made at or after ImportsSince (ErrTooManyImports otherwise; ImportsMax and ChangesMax 0 or less: any number); and the person's draft it imports (Draft), forgotten;
- the operation's key with its reply (Key, Digest, Outcome, Reply), at At, only if no reply is kept with the person's key yet (ErrKeyTaken otherwise), as Save keeps them.
- for a bundle (Bundle, with a record of each version it adds in Records): a new bundle, only if the store keeps none of its digest (ErrConflict otherwise), or a bundle's new state, only if its state and whether it is hidden are still the ones read (BundleChange.Was, WasHidden; ErrConflict otherwise); a bundle that becomes approved (or is kept approved), only if no approved bundle adds a version it adds (ErrConflict otherwise); and its archive forgotten when Forget says so.
type Checker ¶
type Checker interface {
Check() error
}
Checker is a part of the configuration that can tell what is wrong with its own settings, with no I/O: web.ProxyHeader tells of a secret too short to trust. New asks each part that is one, so that a server stops before it takes requests, saying what is wrong, instead of failing each request.
type Choice ¶
Choice is a value a find chooses among: a person's or a team's ID or a row's key, its name in the language the find is asked in, and its name in the other ("" for none; a row of a master has one name, the one its name field holds, which a find reads in either language).
func Find ¶
Find answers the choices the words of q find, the closest first, at most limit of them, and whether more are found (ringi's DESIGN 13.2). The words are q cut at the characters of White_Space, each folded (Fold; a word that folds to nothing is none); a choice is found when each word is in its value or one of its names, folded. No words find every choice. The closest is a choice whose value is q as typed, without the white space at its ends; then one whose value folds to q folded (the white space between the words gone too); then one with a name that folds to it; then one whose value or a name begins, folded, with the first word; then the rest. Choices as close come in the order of their values, compared code point by code point (the order of Go's strings).
func PeopleChoices ¶
PeopleChoices answers people as a find chooses among them, named in lang: in Japanese the Japanese name where they have one, else the name, and the name as the other; in English the name, and the Japanese name (else the name) as the other.
func TeamChoices ¶
TeamChoices answers teams as a find chooses among them, named in lang as PeopleChoices names people.
type Config ¶
type Config struct {
// Packages are the generated packages (Load). A kind may be in several, each at its own
// version: a ticket keeps the version it was submitted with to its end.
Packages []*Package
// LoadBundle reads a bundle's requests directory into a package, its kinds' code as WebAssembly
// (package wasmkind's Load, which package serve gives): with it, the server takes bundles, a
// version of a kind or a new kind added while it runs (DESIGN 15). None takes no bundle.
LoadBundle func(ctx context.Context, requests fs.FS) (*Package, error)
// Bundles are the bundles the server reads as it starts (serve's -bundles): each checked and
// served as an approved one is, with no one to approve it (ReadBundles).
Bundles []BundleFile
// BundleKeys are the ed25519 public keys bundles are signed with (serve's -bundle-keys): with
// any, a bundle is taken, uploaded or read at start, only with a signature one of them makes
// (package bundlesign). With none, every upload is refused, and so is every approval of a
// bundle the store keeps (signature): only the bundles of Bundles, read at start, need no
// signature then (DESIGN 15.3).
BundleKeys []ed25519.PublicKey
// MaxBundle is the largest bundle, in bytes, and the most its files may come to once
// uncompressed (default 64 MiB): a larger one is answered 413.
MaxBundle int64
// Store keeps the tickets (required).
Store Store
// Authenticator finds who sends a request (required).
Authenticator Authenticator
// Gate decides who may do what (required; AllowAll allows everything).
Gate Gate
// Organization reads the organization's data (required to import it).
Organization OrgSource
// Notifier sends the notices; none logs them and drops them.
Notifier Notifier
// Flows starts the flows a ticket launches; Agents runs the agents' steps and the notes.
Flows Flows
Agents Agents
// Books makes the calls of the books. BooksApart says they are in a database of their own:
// then an event holds its ticket's lock through every try, holds and posts are made before
// the save, a failed save is tried again from the read, and voids are made after it, as things
// to do. A refusal of a book then stays with its key (DESIGN 3.2).
Books Books
BooksApart bool
// Files keeps the attachments.
Files Files
// AuditLog receives a copy of each move and refusal; none keeps only the moves in the store.
AuditLog AuditLog
// MaxBody is the largest body a request may have, in bytes (default 1 MiB); a larger one is
// answered 413.
MaxBody int64
// MaxCheckTime is how long the whole check of an uploaded bundle may take (default 20
// seconds, shorter than the serve package's WriteTimeout): one past it is refused, and
// nothing of it is kept (DESIGN 15.5).
MaxCheckTime time.Duration
// CommentEvery is how long a person waits between two comments on one ticket (default 10
// seconds; a negative duration, no wait), CommentsPerTicket how many comments one ticket takes
// in all (default 100), and CommentsPerPerson how many of them one person may make (default 25,
// so that no one person fills a ticket's comments for the others); a negative number sets no
// limit. A comment past any is answered 429 (DESIGN 7.4).
CommentEvery time.Duration
CommentsPerTicket int
CommentsPerPerson int
// UploadsPerPerson is how many files one person may have uploaded that no ticket holds (default
// 50; a negative number, any number): an upload past it is refused (Upload answers
// *TooManyUploads, 429). UploadsKept is how long such a file is kept (default 7 days; a negative
// duration, until a ticket holds it): then the server lets go of it and deletes it (DESIGN 2.3).
UploadsPerPerson int
UploadsKept time.Duration
// OperationsKept is how long an operation's key is kept with its reply (default 30 days; a
// negative duration, for ever). DESIGN 7.1 says what a key given again after that does.
OperationsKept time.Duration
// SweepEvery is how often Run lets go of the uploads and forgets the operations and the drafts of
// the organization's data past their times (default 1 hour; Sweep).
SweepEvery time.Duration
// MaxOrganization is the largest upload of the organization's data an administrator checks, and
// the most its files may come to as they are read out (default 64 MiB): an upload past either is
// answered 413 (DESIGN 13.3). DraftsKept is how long a draft of the data checked is kept (default a
// day; a negative duration, until it is imported or one person's sixth replaces it).
// ImportsPerDay is how many imports that add a snapshot of the organization the server takes in 24
// hours (default 20; a negative number, any number), and ten times as many imports of any data
// (one of a snapshot kept before among them): one past either is answered 429.
MaxOrganization int64
DraftsKept time.Duration
ImportsPerDay int
// Clock tells the time (default the system's); NewTicketID makes the tickets' IDs (default 26
// characters, in the order they are made to the millisecond: NewID); NewAttempt makes the names
// of the tries of submits and resubmits (default as NewTicketID), each a name no try of the
// ticket had before (ringi's DESIGN 7.1); NewRecordID makes the IDs of the administration's
// records (default as NewTicketID), each with no "/" and none made before (DESIGN 13.1): the
// store refuses a record of an ID it keeps, and the change is the server's failure.
Clock Clock
NewTicketID func() string
NewAttempt func() string
NewRecordID func() string
// Logger logs what the server does on its own (default slog.Default()).
Logger *slog.Logger
}
Config is what a server is made of. A part of it (the store, the authenticator, the gate…) that is a Checker is asked by New, which refuses the configuration with what it answers.
type Delivery ¶
type Delivery struct {
// Ticket is the ticket's ID; "" for a submit, whose event names its ID.
Ticket string
// Kind is the kind of request of a submit.
Kind string
// Event is the event, as the contract writes it.
Event json.RawMessage
}
Delivery is an event the server gives a ticket as it is, with no gate.
type Draft ¶
type Draft struct {
Person string
ID string
// Source is where it came from: "config" (Config.Organization) or "upload".
Source string
Data json.RawMessage
At time.Time
}
Draft is the organization's data an administrator checked, kept for them to import (DESIGN 13.3): its ID is the ID of the snapshot it would be (the digest of Data).
type EffectKey ¶
type EffectKey struct {
Ticket string `json:"ticket"`
Round int64 `json:"round"`
Serial int64 `json:"serial"`
}
EffectKey is the key of one of the things to do `next` answers: the ticket, its round and the serial of the effect. The same key is the same thing to do.
func ParseEffectKey ¶
ParseEffectKey reads a key as String writes it ("T/1/4"): the ticket's ID, then the round and the serial, whole numbers from 0 written in digits. Another system given a launch's key as text (an Idempotency-Key) gives it back so, for Server.WorkEnded.
type FileInfo ¶
type FileInfo struct {
Name string
ContentType string
Size int64
// By is the person who uploaded it, and At when.
By string
At time.Time
}
FileInfo is what is kept of a file.
type Files ¶
type Files interface {
// Put keeps a file: info's Name, ContentType, By and At (Size is counted; a zero At is the time
// it is put). It answers the file's new ID, one it has not answered before.
Put(ctx context.Context, info FileInfo, r io.Reader) (id string, err error)
// Stat answers what is kept of a file, ErrNotFound for none.
Stat(ctx context.Context, id string) (FileInfo, error)
// Open reads a file, ErrNotFound for none.
Open(ctx context.Context, id string) (io.ReadCloser, FileInfo, error)
// URL answers an address to send a browser to for the file's bytes, once the server has
// allowed the person; "" has the server send them itself, from Open.
URL(ctx context.Context, id string) (string, error)
// Delete deletes a file, ErrNotFound for none. The server deletes only the uploads that no
// ticket held in Config.UploadsKept (Server.Sweep).
Delete(ctx context.Context, id string) error
}
Files keeps the files the forms name by their IDs. A form may name a file the ticket holds, or one the person sending it uploaded (Server.Do holds it to that when Config.Files is set).
Stat and Open answer a file's At in UTC (its Location is time.UTC), as a Store answers every time. They may keep it to any precision: the framework keeps the time of an upload in the store (Store.KeepUpload) and never reads it back from the files to compare. The memory and PostgreSQL files keep it to the microsecond, and web.DiskFiles to the nanosecond.
type FindAnswer ¶
FindAnswer is what a find answers: the values found, the closest first, and whether more are found than it answers.
type FindError ¶
FindError is a parameter of a find that the find does not take (the API's 400): its name (q, limit, lang or on) and why. Its sentence begins with the name, as the lists' does ("limit: a whole number from 1 to 100 is expected, not \"0\"").
type FindQuery ¶
FindQuery is what a find is asked: the words (Q), how many values it answers (Limit, 1 to FindMost), the language of the names (Lang, en or ja), and of a master's rows the day they may be chosen on (On, YYYY-MM-DD; "" for today).
func ReadFind ¶
ReadFind reads what a find is asked from the parameters of its query (ringi's DESIGN 13.2): q, words of at most FindLongest characters of UTF-8, counted in code points; limit, a whole number from 1 to FindMost (FindShown when it is left out); lang, en or ja (when it is left out, the first of languages that is one, else en: languages are the caller's, the most wanted first, as Call.Languages holds them); and, of a master's rows (master), on, a day written YYYY-MM-DD ("" for today when it is left out). A parameter given empty is left out. It answers a *FindError for the first parameter it does not take, in the order q, limit, lang, on: the order in which the vectors (organization/find.jsonl) name the first of q, limit and lang.
func (FindQuery) Answer ¶
func (q FindQuery) Answer(choices []Choice) FindAnswer
Answer answers the find among choices: the ones the words find, the closest first, at most Limit of them, named in Lang, and whether more are found (Find, Choice.Found).
type Flows ¶
Flows starts the flows a ticket launches. What became of a launched flow comes back, when the work says it, by Server.WorkEnded with the same key (Launch.Key).
type Found ¶
type Found struct {
Value string `json:"value"`
Name string `json:"name"`
Label string `json:"label"`
}
Found is a value a find answers: its value (a person's or a team's ID, a row's key), its name in the language of the find ("" for none), and the label a list shows: the name and the value ("Sales staff 3 (e1203)", "営業担当 3(e1203)"), the value alone where the name is empty or the value itself.
type Gate ¶
type Gate interface {
// Allow answers whether the question's person may do its action. An error is a failure, not
// a no: the operation answers 500.
Allow(ctx context.Context, q Question) (bool, error)
}
Gate decides whether a person may do an operation. The framework asks it before `next`.
var AllowAll Gate = allowAll{}
AllowAll is a gate that allows everything: for tests, and for a project that leaves who may do what to the kinds of request alone. It allows `see` too, so everyone may see every ticket (DESIGN 10.3).
type GeneratedKind ¶
type GeneratedKind interface {
~struct {
Name string
Version int
Start func(json.RawMessage, json.RawMessage, int64) (json.RawMessage, error)
Next func(json.RawMessage, json.RawMessage, json.RawMessage, int64) (json.RawMessage, error)
Worked func(json.RawMessage) (json.RawMessage, error)
}
}
GeneratedKind is the shape of the kinds a generated package lists (ticketkinds.Kind). Load takes a list of any type of this shape; if a later ritsu changes the shape, the call stops compiling.
type HistoryLine ¶
type HistoryLine struct {
At int64 `json:"at"`
Did string `json:"did"`
Stage *string `json:"stage"`
By *string `json:"by"`
ProxyOf *string `json:"proxy_of"`
Organization *string `json:"organization"`
OnceWith *string `json:"once_with"`
To []string `json:"to"`
Note *string `json:"note"`
Comment *string `json:"comment"`
Cleared []string `json:"cleared"`
}
HistoryLine is a line of a ticket's history, as get_ticket answers it.
type Kind ¶
type Kind struct {
Name string
Version int
Start func(submit, organization json.RawMessage, now int64) (json.RawMessage, error)
Next func(ticket, event, organization json.RawMessage, now int64) (json.RawMessage, error)
Worked func(in json.RawMessage) (json.RawMessage, error)
}
Kind is one kind of request as ritsu generates it: its name, its version and its three entries, which take and answer the JSON of the contract. Worked answers, for a form filled in so far (and an approver's edits), whether each field shown or asked for on a condition is, and the value of each field the form works out (ringi's DESIGN 13.7): the pages and the API's worked operations answer with it. A kind written by hand may leave it nil if its openapi.json has no worked operation; the pages then show every field as they would before the form is filled in.
type KindVersion ¶
KindVersion names a version of a kind.
type LanguageChoice ¶
type LanguageChoice struct {
// Chosen is the language the person chose (a page's ?lang=, or the pages' cookie); "" for none.
Chosen string
// Accept is the Accept-Language header of the request.
Accept string
// Person is the language the organization's data gives the person (Server.PersonLanguage); ""
// for none, or before anyone is signed in.
Person string
// Kind are the languages of the kind a page or a screen is of, the one it is written in first;
// none for one of no kind.
Kind []string
}
LanguageChoice is what the language a person is answered in is chosen by: the one they chose, their browser's, their own in the organization's data, and the kind's. The pages, the A2UI screens, the administration's pages, the pages of signing in and the MCP tools all choose with it (Choose), so that a person is answered in one language wherever they ask.
func (LanguageChoice) Choose ¶
func (c LanguageChoice) Choose(ok func(string) bool) string
Choose answers the first language of the choice that ok takes, asked in this order: Chosen; the languages of Accept, the most wanted first (AcceptLanguages); Person, unless Accept does not want it (q=0); and Kind's, in their order. "" when ok takes none of them, for the caller's own last language (English, mostly).
type Launch ¶
type Launch struct {
Key EffectKey
Kind string
Ticket string
Flow string
// Args are the flow's arguments, as named values of the contract.
Args json.RawMessage
}
Launch is a flow to start after a ticket ends. Its key is the run's ID: starting the same key twice must start one run.
type Line ¶
type Line struct {
Move *MoveRecord
Record *Record
}
Line is a line of the record: a move of a ticket, or a record.
type MasterLayout ¶
type MasterLayout struct {
// Name is the master's name, masters.master (company_masters.systems).
Name string
// Data is the file of its rows, as the descriptions write it.
Data string
// Key is its key's column, and Fields its columns.
Key string
Fields []string
// Written are the names its file may write a column in besides the field's name, by the
// field's name: the names the .ringi file writes the fields in, as ritsu reads the file. A row
// keeps its cells by the fields' names.
Written map[string]string
// Optional are the fields that may be left empty, whose columns a file may leave out: a row of
// a file without one holds none for it, as one with its cell empty (ritsu reads them so).
Optional map[string]bool
// NameField is the column that names a row to people (types/<name>.json's name_field): the
// screens show a row by it, and the search for rows compares it.
NameField string
}
MasterLayout is one master the kinds read.
type Member ¶
type Member struct {
Person string `json:"person"`
Team string `json:"team"`
Position string `json:"position"`
Primary bool `json:"primary"`
}
Member is a person's place in a team.
type MineCount ¶
type MineCount struct {
// Status is how many are in each status ("in_progress", "with_requester", "approved", …); a
// status none are in is left out.
Status map[string]int
// SentBack is how many of those back with their requester ("with_requester") were sent back: the
// ticket says by whom (sent_back_by). The others the requester's side took back (withdraw).
SentBack int
}
MineCount is how many of a person's own requests of a kind there are.
type MineCounter ¶
type MineCounter interface {
// CountMine answers how many tickets are the person's own, by kind (TicketRecord.Kind): the
// tickets Mine reads for the person, counted. A kind with none is left out.
CountMine(ctx context.Context, person string) (map[string]MineCount, error)
}
MineCounter is a store that counts a person's own requests without reading them: Server.CountMine asks it. memstore and postgres have it. With a store that does not, CountMine reads the person's own requests, as Mine does, to count them.
type MineQuery ¶
type MineQuery struct {
// Kind keeps the tickets of one kind of request; "" keeps all.
Kind string
// Status keeps the tickets of one status ("with_requester", those back with their requester); ""
// keeps all.
Status string
// Before keeps the tickets older than this one (the last of the page before); "" starts from the
// newest. A ticket that is not the person's own keeps none.
Before string
// Limit keeps at most this many; 0 keeps all.
Limit int
}
MineQuery narrows Store.Mine and Server.Mine.
type Move ¶
type Move struct {
Ticket string
Kind string
Version int
Number int64
Body json.RawMessage
Status string
At time.Time
Person string
Event json.RawMessage
Effects json.RawMessage
Org string
// Via is the way the person's operation came in (Call.Via); "" for the server's own move.
Via string
Rang *Timer
Cancel []TimerKey
Set []Timer
ToDo []ToDo
Waiting []string
// Since is when the ticket began to wait for Waiting: when the stage that waits for them started,
// or when the ticket came back to its requester (Store.Waiting lists by it).
Since time.Time
// People are everyone the ticket names after the move: its requester, who made it, who sent it
// back, its approvers and who answered (TicketRecord.People). Own are those of them whose request
// it is: its requester and who made it (Store.Mine), each kept with the move's At the first time
// a move names them.
People []string
Own []string
Key string
Digest string
Outcome Outcome
Reply json.RawMessage
Uploads []string
Books func(ctx context.Context, tx any) error
}
Move is what Save writes, in one transaction, all or nothing:
- the ticket (Body), only if its number is still Number (a new ticket, Number 0: only if no ticket has its ID), with its number raised by one, and the move itself after the ticket's earlier moves (At, Person, Key, Event, Effects, Org, Via); a ticket keeps the Kind and Version of its first move, and each of its moves is kept with them;
- the removal of the timer that rang (Rang), if it is still there at the same time, then the timers the move cancels and sets;
- the things to do (ToDo), each once by its ID, not tried yet and not done (their Tries, LastError and Done are the store's);
- who the ticket now waits for (Waiting, in place of what was there), and since when (Since, kept as the ticket's TicketRecord.Since; zero when Waiting is empty);
- the people the ticket names (People) and whose request it is (Own), added to the ones its earlier moves named, none ever taken away;
- the operation's key with its reply (Key, Digest, Outcome, Reply), only if no reply is kept with the person's key yet; what Begin kept for the key is forgotten;
- the uploads the move's event names that the ticket did not hold (Uploads), recorded as held by a ticket, so that they are never let go; if one of them was let go, nothing is written and Save answers *UploadGone (an ID with no record of an upload is not one);
- the books' calls, by calling Books with the transaction.
A move with no Body changes no ticket: it keeps a refused operation's key and reply, its audit entry, and the removal of a timer that was refused. A move with a Body and a null Event puts a ticket in as it was (an import; the conformance tests use it).
type MoveRecord ¶
type MoveRecord struct {
Ticket string
// Number is the ticket's number after the move: 1 for the first.
Number int64
At time.Time
Person string
Key string
// Event is the event as `start` or `next` was given it; null for a ticket put in as it was, and
// for a move given none.
Event json.RawMessage
// Effects are the things `next` answered, as the move was given them; [] for a move given none.
Effects json.RawMessage
// Org is the ID of the snapshot of the organization the move's part came from.
Org string
// Kind and Version are the ticket's, and Via the way the move came in (Move.Via): "" for the
// server's own, and for a move kept before the store kept it.
Kind string
Version int
Via string
}
MoveRecord is a move as the store keeps it.
type Name ¶
Name is the name of a person or a team, and its Japanese name ("" when the data has none).
type NamedValue ¶
type NamedValue struct {
Name string `json:"name"`
Value json.RawMessage `json:"value"`
}
NamedValue is one argument of a call, as the contract writes it: a name and a value, which is one of {"str":{"v":…}}, {"num":{"v":…}}, {"truth":{"v":…}} and {"rows":{"v":[…]}}.
func NamedNumber ¶
func NamedNumber(name string, n int64) NamedValue
NamedNumber is a whole number a work ended with, under its name.
func NamedText ¶
func NamedText(name, text string) NamedValue
NamedText is a text a work ended with, under its name.
func NamedTruth ¶
func NamedTruth(name string, b bool) NamedValue
NamedTruth is true or false, as a work ended with it, under its name.
func (NamedValue) Num ¶
func (v NamedValue) Num() (int64, bool)
Num answers the value when it is a number.
func (NamedValue) Str ¶
func (v NamedValue) Str() (string, bool)
Str answers the value when it is text.
func (NamedValue) Truth ¶
func (v NamedValue) Truth() (bool, bool)
Truth answers the value when it is true or false.
type Notice ¶
type Notice struct {
// Key is the notice's key: the same key again is the same notice.
Key EffectKey
// Kind is the kind of request and Version the version of it the ticket keeps, whose title
// Server.Title answers in the language of a person told; Ticket is the ticket's ID.
Kind string
Version int
Ticket string
// Notice is which: waiting, reminder, went_up, returned, decided, circulation, paused,
// resumed, stopped or comment.
Notice string
// Stage is the stage it is about; "" for none.
Stage string
// To are the people to tell, with their names, addresses and languages from the organization's
// data.
To []Recipient
// Owner is the team that owns the kind; a `stopped` notice is for its administrators.
Owner string
}
Notice is one notice to send.
type Notifier ¶
Notifier sends notices. It is called again with the same key after a failure the framework could not tell from a success, so it must send a key once.
type OperationRecord ¶
type OperationRecord struct {
Person string
Key string
// Digest is the digest of the operation the key was used for.
Digest string
Outcome Outcome
Body json.RawMessage
// At is when it was answered (the move's At).
At time.Time
}
OperationRecord is what was answered to an operation's key.
type OrgData ¶
type OrgData struct {
Versions []OrgVersion `json:"versions"`
Proxies []Proxy `json:"proxies"`
// Masters are the rows of each master by its name (masters.master); a row is its columns by
// name, valid_from and valid_to among them ("" for none).
Masters map[string][]map[string]string `json:"masters"`
// contains filtered or unexported fields
}
OrgData is the organization's data as it was read once: its versions, its proxies, and the rows of its masters.
func ReadOrgFiles ¶
ReadOrgFiles reads the organization's data from the files ritsu reads, in fsys (the directory ritsu gen was given as --root): in want.Data, a directory for each version, named by the day it takes effect, with teams.csv, people.csv and members.csv or one organization.json, and proxies.csv beside the versions; and the CSV file of each master. ritsu writes their columns in requests/organization/columns.md.
It answers every problem it finds with the files' shape as *OrgProblems: no directory or no version, a directory not named by a day, a version with both kinds of file or with neither, a file that is not UTF-8 or does not read as CSV or JSON, a column missing, there twice or not one of its file's, a row of another number of values than there are columns, a row of a CSV file longer than 1 MiB or of more than 1,000 values, a key of organization.json not read, a `primary` that is not yes, no or empty. A byte order mark at the start of a file is not read. A directory whose name starts with a dot, and a file other than proxies.csv beside the versions, are not read. A file it cannot read is an error of its own (*fs.PathError). It stops at MaxOrgProblems problems.
The data keeps the file and the line of each row, for CheckOrganization to say where a problem is. Its versions are in the order of their days, and its proxies and masters are empty, not nil, where there are none.
type OrgLayout ¶
type OrgLayout struct {
// Name is the organization's name, and Data the directory of its versions, as the kinds'
// descriptions write them.
Name string
Data string
// Positions are the organization's positions, the lowest first, and TeamKinds its kinds of team,
// the widest first, by the names it declares them by.
Positions []string
TeamKinds []string
// Written are the names the organization's files may write a position or a kind of team in
// besides the declared one: the name its .ringi file writes it in, where that is another. The
// checks keep each by its declared name (CheckOrganization).
Written OrgWritten
Masters []MasterLayout
}
OrgLayout is what an OrgSource is asked to read: where ritsu's files say the organization's data is, and the masters the kinds read.
type OrgPerson ¶
type OrgPerson struct {
ID string `json:"id"`
Name string `json:"name"`
NameJa string `json:"name_ja,omitempty"`
Email string `json:"email,omitempty"`
Language string `json:"language,omitempty"`
}
OrgPerson is a person of a version. Language is the language they read their notices and pages in, en or ja; "" for none, which is the language of each kind (a notice's, a page's). A snapshot of data with no language is written as it was before the data had one: the same bytes, the same ID.
type OrgProblem ¶
type OrgProblem struct {
// At is where: a file and a line ("org/2026-04-01/members.csv:4"), a file or a directory, a row of
// data not read from files ("version 2026-04-01, members[3]", "proxies[2]",
// "master company_masters.systems, rows[4]"), or "" for an upload as a whole.
At string `json:"at"`
Text string `json:"text"`
TextJa string `json:"text_ja"`
}
OrgProblem is one thing wrong with the organization's data: where it is, and what, in English and in Japanese.
type OrgProblems ¶
type OrgProblems struct {
Problems []OrgProblem
// Stopped says that the reading or the checks stopped at MaxOrgProblems problems: the data may
// have more.
Stopped bool
}
OrgProblems is the error of data that does not pass the checks (DESIGN 13.3).
func (*OrgProblems) Error ¶
func (e *OrgProblems) Error() string
Error writes the problems one to a line, as a server that stops for them says them: a line that says the data does not pass, a line for each of the first ShownProblems (At, then the text), a line that says how many more were found and one that says the checks stopped, when they did, and a line that says how to check the data.
func (*OrgProblems) Shown ¶
func (e *OrgProblems) Shown() (shown []OrgProblem, more int)
Shown answers the problems said one by one (the first ShownProblems), and how many more were found.
type OrgSnapshot ¶
type OrgSnapshot struct {
ID string
Data json.RawMessage
// At is when the data was read: for a snapshot saved again (the same data read again, made the
// latest again), the last time.
At time.Time
}
OrgSnapshot is the organization's data as it was read once (OrgData as JSON).
type OrgUnread ¶
type OrgUnread struct {
Day string // today, in the first kind's offset
Person string // the person's ID
NoVersion bool
}
OrgUnread is why the organization is not read to a person, the API's 404 of get_organization and of the finds of its people and teams (find_people, find_teams): no version of it is in effect today (NoVersion), or the person is not one of the people of the version in effect (DESIGN 9.1). Its sentence says which.
type OrgVersion ¶
type OrgVersion struct {
// Day is the day it takes effect.
Day string `json:"day"`
Teams []Team `json:"teams"`
People []OrgPerson `json:"people"`
Members []Member `json:"members"`
}
OrgVersion is one version of the organization.
func (*OrgVersion) TeamOf ¶
func (v *OrgVersion) TeamOf(person, kind string) string
TeamOf answers the person's team of the kind: the first team of that kind at or above their primary team in the version, else their primary team; "" when the version has no primary membership of theirs, or v is nil. It goes up at most as many teams as the version has, so that data whose parents lead back to a team below does not keep it going.
type OrgWritten ¶
OrgWritten are the declared names of the positions and the kinds of team, by the names the organization's .ringi file writes them in.
type Outcome ¶
type Outcome string
Outcome is how an operation ended.
const ( OK Outcome = "ok" // 200 Refused Outcome = "refused" // 409 NotFound Outcome = "not_found" // 404 Invalid Outcome = "invalid" // 400 Limited Outcome = "limited" // 429: the server does not take the call now (DESIGN 7.4) TooLarge Outcome = "too_large" // 413: an upload larger than the server takes (DESIGN 13.3) // (DESIGN 8.1): 503, with Retry-After of the seconds of the minute left. Waiting helps, as it // does for Limited, but what is waited for is the entry answering again, not a turn. Unavailable Outcome = "unavailable" )
The outcomes, and the HTTP answers they are.
type Package ¶
type Package struct {
// contains filtered or unexported fields
}
Package is a generated package handed to the framework: its kinds and the files of its contract.
func Load ¶
Load reads a generated package: contract is ticketkinds.Contract, lang is ticketkinds.Lang (the language the entries write the sentences of their errors in), kinds is ticketkinds.Kinds, and requests is the directory `ritsu gen --target requests` wrote (openapi.json, types/, vectors/).
func (*Package) Bundle ¶
Bundle answers the digest of the bundle the package was read from: "" for a package of Config.Packages.
func (*Package) CheckAnswer ¶
CheckAnswer reports whether body has the shape the contract (openapi.json) gives the answer of the operation (its operationId) with the status: the types of its values, the keys each object must and may have, the items of its arrays and its dates, as the bodies the API takes are checked (the words and the lengths of values are not), the bodies of the errors among them (each of the closed schema `error`, and a 404 of no version in effect of `unoffered`). It answers nil for an answer the contract gives no JSON body, and an error for a status the contract does not give the operation. The tests check the framework's answers with it: conformance.Vectors checks each answer the API gives a vector, conformance.Worked each answer of what a form works out.
type Person ¶
type Person struct {
// ID is their ID in the organization's data.
ID string
// Roles are what the sign-in says of them, for the gate.
Roles []string
}
Person is who sends a request, as the authenticator found them.
type Proxy ¶
type Proxy struct {
Person string `json:"person"`
Proxy string `json:"proxy"`
Kind string `json:"kind"`
From string `json:"from"`
To string `json:"to,omitempty"`
Requests []string `json:"requests,omitempty"`
}
Proxy is one row of the proxies: Proxy stands in for Person (Kind approve or submit) from From through To ("" for no end), for the kinds of request in Requests (none for every kind).
type Question ¶
type Question struct {
// Action is the gate's action: submit, withdraw, approve, reject, send_back, pause, retract,
// add_approver, hand_over, comment, or see (whether the person may see a ticket they are not on:
// DESIGN 10.3). see is asked of a version of a kind too, with no ticket: whether the person sees
// its tickets for the kind, whoever is on them, and lists them all (DESIGN 10.5).
Action string
Person Person
// Kind and Version are the kind of request's.
Kind string
Version int
// Ticket is the ticket's ID (for a submit, the ID the new ticket is given). It is "" for see asked
// of a version of a kind, and so are Stage and Requester, with no Requesters or Approvers.
Ticket string
// Stage is the name of the stage the ticket is at; "" while it is at none.
Stage string
// Requester is the ticket's requester (for a submit, the one the request is made for).
Requester string
// Requesters are the requester's side: the requester, the one who made the request for them,
// and the proxies who may submit it for them that day.
Requesters []string
// Approvers are, while the ticket is at a stage, the approvers of that stage and their proxies
// in effect that day; while it is back with the requester, the one who sent it back.
Approvers []string
// Owner is the team that owns the kind.
Owner string
// SelfApproval is whether the kind's route lets a requester approve their own request.
SelfApproval bool
// Now is the time of the event.
Now time.Time
// Org is the version of the organization in effect that day.
Org *OrgVersion
}
Question is what the gate is asked before an event of a person: whether Person may do Action, with the values ritsu decides for the ticket.
type Recipient ¶
Recipient is one person a notice is for, with what the organization's data says of them: their name and address, and Language, the language to tell them in: theirs in the organization's data (en or ja), else the language the notice's kind is written in (the description's language). A notifier writes the notice in it, and says the kind with Server.Title(n.Kind, n.Version, r.Language).
type Record ¶
type Record struct {
// ID is made by Config.NewRecordID; it has no "/".
ID string
At time.Time
// Person is who made it: "" for the server's own (an import at start).
Person string
// Via is the way it came in: "api", "pages" or "start".
Via string
// What is "kind" (a switch of the version Kind, Version), "organization" (an import) or "bundle"
// (a bundle uploaded, approved, declined, hidden or read at start, by a version it adds: Kind,
// Version; DESIGN 15.7).
What string
Kind string
Version int
// Before and After are what was there and what it became, as the record's line shows them.
Before json.RawMessage
After json.RawMessage
// Reason is why, as the administrator wrote it; "" for none.
Reason string
// Of an import: Source is where its data came from ("config": Config.Organization; "upload"),
// Snapshot is the snapshot it made the latest, and Added says the snapshot was not kept before.
Source string
Snapshot string
Added bool
}
Record is a change an administrator made, as the store keeps it (DESIGN 13.1): a version of a kind switched, or a version of the organization imported. A record is never changed or removed.
type RecordQuery ¶
type RecordQuery struct {
// Versions are the versions whose lines may be read (the moves of their tickets, their switches
// and the records of the bundles that add them), and Organization whether the imports may: the
// lines the gate allows (DESIGN 13.4). No other line is read.
Versions []KindVersion
Organization bool
// From and To keep the lines at or after From and before To; a zero time is no bound.
From time.Time
To time.Time
// Kind keeps the lines of one kind; What the moves ("move"), the switches ("kind"), the imports
// ("organization") or the records of the bundles ("bundle"); Person the lines of one person (who
// moved the ticket, who made the record); Ticket the moves of one ticket. "" keeps all.
Kind string
What string
Person string
Ticket string
// Before keeps the lines after this one in the record's order, named by its ID as Line.ID writes
// it: one the query does not keep gives none, and so does an ID no line has (a move's number
// written otherwise, as 01 or +1). "" starts from the newest.
Before string
// Limit keeps at most this many; 0 keeps all.
Limit int
}
RecordQuery says which lines of the record Store.Records may read, and narrows them.
type Reply ¶
type Reply struct {
Outcome Outcome
// Body is what the API answers: a ticket, a list, a refusal.
Body []byte
// Problem says why, for NotFound, Invalid and Limited.
Problem string
// From is, for the NotFound of a kind with no version in effect now (unoffered), the day the
// nearest later version starts (YYYY-MM-DD, the kind's day), said to a person who may submit it;
// "" when no version is to start, and to anyone else.
From string
// RetryAfter is, for Limited and Unavailable, how long to wait before the same call is
// taken; 0 when waiting does not help.
RetryAfter time.Duration
// NotAsked are the books' calls a trial (Try) did not ask, for it could not ask them without
// the books keeping them: the books may still refuse them when the operation is done.
NotAsked []BookCall
// Problems are, for Invalid, what is wrong with the organization's data an administrator checked
// (DESIGN 13.3), each at its place: the first ShownProblems of them. MoreProblems is how many more
// were found, and Stopped says the checks stopped at MaxOrgProblems (OrgProblems.Stopped).
Problems []OrgProblem
MoreProblems int
Stopped bool
// Next is, for a part of the record as CSV that more lines follow (admin_records_csv), the line
// the next part goes on after.
Next string
}
Reply is what an operation answers.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a server of the kinds of request of its packages. It is an http.Handler, and the operation layer under it (Do) is there for any other way in.
func New ¶
New makes a server. It does no I/O: it refuses a configuration that lacks a required part, a part that is a Checker and answers an error, and the kinds' settings that disagree (DESIGN 2.2).
func (*Server) AddPackageCheck ¶
AddPackageCheck adds a check a bundle's package must pass before the server serves it: what is made of the packages (the pages of package web, the agents' tools of package mcp) checks that it can make itself of them, given the packages the server would serve, the new one last. A bundle that fails a check is refused, saying what the check answered.
func (*Server) AdminParts ¶
AdminParts asks the gate which parts of the administration the person may use, as the operations ask it (DESIGN 13.4). An error of the gate is the server's failure.
func (*Server) Administers ¶
Administers reports whether the person may use a part of the administration, asking the gate until its first yes: the start page links to the administration's pages then. An error of the gate is logged and answers false, so that the start page of a gate that does not have the administration's actions still serves (DESIGN 13.4).
func (*Server) Answered ¶
Answered gives a ticket the answer of the agent's step or the note it asked for by key. It is idempotent: once a key is answered, a later call with the same key changes nothing and answers what the first answered, whatever its Answer. A refusal (the ticket went on since it asked: stale) is an answer, not a failure; an error is a failure, and the call may be made again.
func (*Server) Authenticate ¶
Authenticate answers who sends r, as Config.Authenticator says.
func (*Server) Can ¶
func (s *Server) Can(ctx context.Context, p Person, ticket string, events []string) ([]string, error)
Can answers which of the events the person may give the ticket now, in their order: the ones the gate allows (it is asked each event's action, as an operation asks it), and the ticket takes from them as it is (DESIGN 8.1). An event no operation of the kind gives a ticket is left out (a new request's submit, an edit of a kind whose approvers fill in nothing). ErrNotFound when there is no such ticket, or the person may not see it.
func (*Server) CheckOrganization ¶
CheckOrganization checks the organization's data, read from any source, against the server's kinds, and answers every problem it finds as *OrgProblems:
- in each version, a person or a team with no ID or an ID there twice, a person with no name or with a language other than en and ja (empty is none), a team of a kind the organization does not declare, a parent that is not a team of the version, a head who is not a member of the team, parents that lead back to a team below or are more than 30 deep; a member who is not a person of the version, of a team it does not have, of a position not declared, or there twice in a team; a person with no primary team, or with two; an address that is not one (longer than 254 bytes, with no `@` or more than one, nothing before or after it, a space or one of addressSpecials), and two people of one address, compared as the sign-in by address compares them (without the spaces around it and without regard to case);
- a proxy with no person or no proxy, its own proxy, of a kind other than approve and submit, with a first or last day that is no day or a last day before its first, or for a person or by a proxy not in the version in effect on a day of it;
- a master's row with no key, with valid_from or valid_to that is no day or valid_to before valid_from, and two rows of a key that may be chosen on one day;
- an ID or a master's key longer than 255 bytes, a name longer than 200 characters, a master's other value longer than 1,000; an ID, a name, an address or a master's value with a character unfit refuses (a control character, a formatting character that does not show, a separator of lines or paragraphs) or bytes that are not UTF-8;
- for each version of a kind that can be used today or later: a day it can be used on, from today (or its first, if later) through its last (or with no end), that no version of the organization is in effect on, or that no row of a master it reads may be chosen on; the kinds that lack one on one day are said in one problem.
A problem says where it is by the file and the line the row was read from (ReadOrgFiles), else by the version and the row's place. The checks stop at MaxOrgProblems problems (OrgProblems.Stopped). Data that passes has its kinds of team and its positions by the names the organization declares them by (a name its .ringi file writes them in is taken too); it is not changed otherwise.
func (*Server) CountMine ¶
CountMine answers how many of a person's own requests there are, by kind and by state: the tickets Mine answers with no query, counted (the start page of the pages says them). A kind with none is left out. With a store that is a MineCounter, the store counts them; with another store, it reads the tickets Mine answers, and counts them.
func (*Server) CountWaiting ¶
CountWaiting answers how many tickets wait for the person's answer, or for the answer of one they stand in for as a proxy that day, by kind: the tickets Waiting answers with no query, counted (the start page of the pages shows them). A kind with none is left out. With a store that is a WaitingCounter, the store counts the person's own, and only the tickets of the people they stand in for are read: one of them that waits for the person too is the person's own, counted once. With another store, it reads the tickets Waiting answers, and counts them.
func (*Server) Current ¶
Current answers the version of a kind a new request takes at a time: its highest version in effect then, by the start an administrator decided for it, or else its description's (DESIGN 13.2), as the process read the starts last. ok is false when no version is in effect, or the server serves no such kind.
func (*Server) Deliver ¶
Deliver gives a ticket an event as it is: for the server's own events and for tests. It asks no gate; a submit takes the version of its kind in effect at the time.
func (*Server) Do ¶
Do runs one operation: who, on which ticket, what. The HTTP handler calls it, and so can a screen's button or any other way in (Call.Via says which, for the audit log).
func (*Server) FindChoices ¶
func (s *Server) FindChoices(ctx context.Context, p Person, among, lang, on string) ([]Choice, error)
FindChoices answers the values a find chooses among for a person, named in lang (en or ja), in the data's order: the people (among "people") or the teams ("teams") of the version of the organization in effect today, or the rows of a master (among its name, masters.master: "company_masters.vendors") that may be chosen on the day on (YYYY-MM-DD; today for ""), each its key, named by the master's name field ("" for a master with none) in either language. A row with no key is no value. The people and the teams are the organization's, which its people alone read (get_organization): to a person the version in effect does not have, or when no version is in effect, they are an *OrgUnread. A master's rows are read as get_master_<file>_<master> reads them, by anyone signed in. A master no find serves (no kind chooses from it, so the API has no find of its rows) is ErrNotFound. The pages offer these values (web), and find among them with Find.
func (*Server) FindValues ¶
func (s *Server) FindValues(ctx context.Context, p Person, among string, query url.Values, languages []string) (FindAnswer, error)
FindValues answers a find of a person's as the API's finds answer it (find_people, find_teams, find_master_<file>_<master>; ringi's DESIGN 12.4, 13.2): among the people ("people") or the teams ("teams") of the version of the organization in effect today, or the rows of a master (among its name, masters.master) that may be chosen on the day the query asks, by the parameters of the query (ReadFind) and the languages of the caller, the most wanted first. It answers ErrNotFound for a master no find serves, as the API answers a path it does not have, and an *OrgUnread for the people or the teams to a person the version in effect does not have (or when none is in effect), as get_organization answers them (404); both before it reads the parameters, as an operation on a ticket the person may not see is answered whatever its body says. Then it answers a *FindError for a parameter the find does not take (400). The handler of the screens' /find (web) answers with it, so that a renderer's pickers find as the API does.
func (*Server) FormAt ¶
func (s *Server) FormAt(ctx context.Context, p Person, ticket string, revision json.RawMessage) (form json.RawMessage, ok bool, err error)
FormAt answers the form a ticket had at a revision (ringi's DESIGN 7.1), the last time the ticket was at it: the ticket's moves are given to its kind's entries again (Replay), up to there. ok is false for a revision the ticket was never at, and for a ticket the person may not see. A page that showed the ticket then reads its post with it: a request made again and an approver's edit send what they change, and that is of the form the page showed (DESIGN 8.1).
func (*Server) Import ¶
Import puts a ticket in the store as it is, as its first move: for tickets brought from elsewhere, and for the conformance tests. Its timers are not set, and nothing is done for it.
func (*Server) ImportOrganization ¶
ImportOrganization reads the organization's data from Config.Organization, checks it as every import is checked (CheckOrganization), and imports it when it differs from what the source gave at its last import (the latest record of an import from it: at start, or by an administrator), with a record of no person (DESIGN 13.3). Else it leaves the latest snapshot as it is, data an administrator uploaded among them. The store compares the source's last import and the latest it read with its own under its lock (Change.LastImport, Change.Latest), so that of two processes started at once, one imports, and one that read the last import before another imported the source's data does not import it again. Each process looks for a newer snapshot every 30 seconds.
func (*Server) InOrganization ¶
InOrganization reports whether the version of the organization in effect today has a person: what a sign-in asks before it takes someone, as package apikeys does for the person of a key. It is false while no version is in effect.
func (*Server) KindsSeen ¶
KindsSeen answers the kinds of request a person sees the tickets of for the kind (DESIGN 10.5): those with a version the server has whose tickets the gate lets the person see whoever is on them, in the order the server lists its kinds. The start page of the pages links to their lists.
func (*Server) MasterRows ¶
func (s *Server) MasterRows(ctx context.Context, master string) (MasterLayout, []map[string]string, error)
MasterRows answers a master's layout (its key and fields, in the order the kinds' descriptions write them) and the rows of it that may be chosen today, each its columns as the master's data writes them. master is the master's name (masters.master); ErrNotFound for a master no kind reads.
func (*Server) MaxOrganization ¶
MaxOrganization answers the most bytes an upload of the organization's data may have (Config.MaxOrganization).
func (*Server) Mine ¶
Mine answers a person's own requests (list_mine): the tickets they are the requester of, or made for someone else, the newest first (by when they were made, then by ID from the highest), each as its JSON. q narrows them and pages through them (Before is the last ticket of the page before: one that is not the person's own gives none; Limit 0 gives all). A person may always see their own requests.
func (*Server) Names ¶
Names answers the names of these people and teams in the version of the organization in effect today. An ID the version does not have is left out.
func (*Server) Now ¶
Now answers the time of the server's clock (Config.Clock): the time the operations are done at.
func (*Server) Offered ¶
func (s *Server) Offered(ctx context.Context, p Person, kind string) (from string, ok bool, err error)
Offered answers, for a kind with no version in effect now, the day the person may make a request of it from (YYYY-MM-DD, in the zone of the version that starts then), as submit_<name> says it (unoffered): ok is false while a version is in effect, when no version is to start, and when the gate does not let the person submit the kind. A screen asks it to say "This request may be made from …" where a kind has no form to show yet.
func (*Server) OpenAPI ¶
OpenAPI answers the description of the whole API the server serves, as OpenAPI 3.1 (DESIGN 13.6): the operations of each kind (its submit, resubmit, edit and the worked operations) and the schemas named for it, as the package of its newest version describes them; the operations no kind owns (the lists, a ticket and its events, the organization, the masters, the finds) and the other components, of every package together, the lists of choices among them (the kinds a list may be narrowed to) joined; and the framework's own (framework.openapi.json). The head (openapi, info, the contract) is the first package's. A package's path or component that is the framework's own, and a place two packages write differently where no kind owns it, is an error (joinJSON).
func (*Server) Operations ¶
Operations answers the operationIds the server serves.
func (*Server) Packages ¶
Packages answers the packages the server serves now: those of Config.Packages in their order, then the bundles it read, in the order it read them (DESIGN 15). PackagesChanged tells when they change.
func (*Server) PackagesChanged ¶
func (s *Server) PackagesChanged() <-chan struct{}
PackagesChanged answers a channel that is closed once the server serves other packages than Packages answers now: a bundle read (DESIGN 15). What is made of the packages (the pages, the agents' tools) makes itself again then, and asks the channel of the new ones.
func (*Server) People ¶
People answers the people of the version of the organization in effect today (in the first kind's offset, as get_organization answers it), with their names and addresses: for a way of signing in that finds the person by an address. ErrNotFound when no version is in effect.
func (*Server) PersonLanguage ¶
PersonLanguage answers the language a person reads their notices and pages in, as the version of the organization in effect today says (en or ja): "" where it says none, or does not have the person, or no version is in effect. The pages, the screens and the tools choose their language with it after the one the person chose and their browser's (LanguageChoice).
func (*Server) ReadBundles ¶
ReadBundles reads the bundles as the server starts (DESIGN 15.3): those of Config.Bundles, each checked as an upload is (the signature with Config.BundleKeys, the versions, the code, every vector) and kept in the store as approved, with a record of each version it adds (via "start"), the first time the store sees it; then every approved bundle the store keeps. A bundle that does not pass, and an approved one that does not load, stop it. serve calls it before it serves, and Unpackaged calls it when it was not called; a program that starts the server itself calls it the same. Without Config.LoadBundle, the server reads no bundle: it stops when it is given some, or the store keeps an approved one.
func (*Server) Replay ¶
Replay gives a ticket's moves to its kind's entries again, in order, each with the part of the snapshot of the organization it was given, and answers the ticket after each move. It fails at the first move whose answer is not the move the store kept: its effects, or, after the last, the ticket. A move that put a ticket in as it was (an import) starts the replay from that ticket.
func (*Server) Replied ¶
Replied answers what was answered to an operation of a person on a ticket before, and whether it was: the reply kept with the person's key (DESIGN 3), where the key was used for this operation with this body, and the person may see the ticket. It runs nothing. A screen that does not run an operation, as it is not offered now (Can), answers the same operation sent again with it.
func (*Server) Run ¶
Run rings the timers that are due and does the things to do that are due, about once a second and right after a save, until ctx ends. It looks for a newer snapshot of the organization as it goes, reads the bundles another process approved (DESIGN 15.2), and sweeps (Sweep) when it starts and every Config.SweepEvery. Any number of processes may run it on one store.
func (*Server) RunTimers ¶
RunTimers rings the timers that are due, once: it leases them, so that each is given to its ticket by one process, and answers how many it gave.
func (*Server) RunToDo ¶
RunToDo does the things to do that are due, once, and answers how many were done.
func (*Server) ServeHTTP ¶
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP serves the API of openapi.json: it finds who sends the request, reads the path, the body and the Idempotency-Key header, calls Do, and writes the reply. An operation that takes a body takes it as application/json only (415 otherwise): a form another site makes a browser send cannot be one (DESIGN 7.3).
func (*Server) SignedBundles ¶
SignedBundles reports whether the server takes only signed bundles (Config.BundleKeys).
func (*Server) Submitting ¶
Submitting answers who the person may make a new request of the kind for today: themselves, as list_requests decides, and the people whose submit proxy they are that day for the kind, each asked of the kind's start and the gate as the person themselves would be. ErrNotFound when no version of the kind is in effect.
func (*Server) Sweep ¶
Sweep lets go of the uploads that no ticket held in Config.UploadsKept and deletes their files, forgets the operations answered, or begun and never answered, more than Config.OperationsKept ago (DESIGN 4.4), and forgets the drafts of the organization's data kept more than Config.DraftsKept ago (DESIGN 13.9), which it logs. It answers how many files it deleted and how many operations it forgot, of both sorts. Run sweeps every Config.SweepEvery; any number of processes may sweep one store at once. A file the files fail to delete is logged, and tried again at the next sweep.
func (*Server) TakesBundles ¶
TakesBundles reports whether the server takes bundles (Config.LoadBundle).
func (*Server) Teams ¶
Teams answers the teams of the version of the organization in effect today, as People answers its people. ErrNotFound when no version is in effect.
func (*Server) TicketFiles ¶
TicketFiles answers the files the ticket's form holds now (its fields of the type attachment, in its rows too), to a person who may see the ticket: ErrNotFound when there is no such ticket or the person may not see it.
func (*Server) Tickets ¶
func (s *Server) Tickets(ctx context.Context, p Person, q TicketsQuery) ([]json.RawMessage, error)
Tickets answers the requests of a kind a person sees for the kind (list_tickets, DESIGN 10.5), each as its JSON: the tickets of the versions of the kind whose tickets the gate lets the person see whoever is on them (KindsSeen), each one the person may see (DESIGN 10.3), the newest first, by when they were made, then by ID from the highest. q narrows them and pages through them as MineQuery does a person's own (Before is the last ticket of the page before: one that is not in the list gives none; Limit 0 gives all); its Versions are not read. A kind the server does not serve is an error.
func (*Server) Title ¶
Title answers the title of a version of a kind for a person who reads lang, and the language the title is in, as a page in that language says it: the kind's `labels` in that language where its description has one, else its title as written, in the language it is written in (ringi's DESIGN 4.8). lang is read as an Accept-Language header is (AcceptLanguages), and the first of its languages the kind has a title in is taken, as the pages take theirs: "ja", "ja-JP" and "ja, en;q=0.5" are ja, and "fr, ja" is ja where the kind has no title in French. A lang that names none of them ("", "fr") is answered with the title as written. Title answers "", "" when the server has no such kind at that version.
A notifier says a notice's kind with it (Notice.Kind, Notice.Version), in the language of the person it tells, which the notice gives with each person (Recipient.Language): Title(n.Kind, n.Version, r.Language) is the title a page in their language shows. Where in is not that language (a kind with no title in it), a mail of HTML can mark the title with it.
func (*Server) Try ¶
Try runs an operation as Do would, and keeps nothing: it answers what Do would answer now (the moved ticket, or the refusal and why), and the store, the books, the things to do, the notices and the audit log are left as they were. It reads what Do reads (the ticket, its timers, the organization, the key) and gives the ticket, in memory, the timers that are due first, as Do does. The books are asked in a transaction that is rolled back (TrialStore), so a trial sees a book's refusal; with a store that cannot, or with the books apart, the calls are not asked and the reply lists them (NotAsked). Unlike Do, it needs no idempotency key; with one the person has used, it answers what was answered to the key.
func (*Server) Unpackaged ¶
func (s *Server) Unpackaged(ctx context.Context) ([]TicketCount, error)
Unpackaged answers the tickets the store keeps of a version no package of the server has, counted by kind, version and status (DESIGN 11): no package of Config.Packages, no bundle of Config.Bundles and no approved bundle the store keeps (it reads the bundles first: ReadBundles). A ticket is shown and moved by the code of its own version, so none of them could be opened or answered. serve refuses to start while there is any (UnpackagedError); a program that starts the server itself asks it the same before it serves.
func (*Server) Upload ¶
Upload keeps a file a person uploads, for a form to name (DESIGN 2.3, "Files"): it puts the file in Config.Files as the person's, at the server's time, and records it as an upload that no ticket holds yet. A person who has Config.UploadsPerPerson such uploads already is answered *TooManyUploads, and nothing is kept. It answers the file's ID.
func (*Server) UploadOnce ¶
func (s *Server) UploadOnce(ctx context.Context, p Person, key string, info FileInfo, r io.Reader) (string, error)
UploadOnce keeps a file as Upload does, once for a key of the person's: for a key the person gave before, with a file that is not let go, it keeps nothing and answers that file's ID, whether a ticket holds it or not. A post that brings a file, sent again, so names the file it named the first time, and is the same operation. The key is an idempotency key (1 to 255 bytes of visible ASCII), made by the caller from the file among the rest: a key given with another file is answered the first one's ID. With no key it is Upload.
func (*Server) VersionPackage ¶
VersionPackage answers the package the version of the kind is served from: the one that added it (a version a bundle only holds is never taken from it, DESIGN 15.2). nil when no package has it. The pages, the screens, the script and the tools of the version come from this package and nowhere else.
func (*Server) Waiting ¶
func (s *Server) Waiting(ctx context.Context, p Person, q WaitingQuery) ([]json.RawMessage, error)
Waiting answers the tickets that wait for the person's answer, or for the answer of one they stand in for as a proxy that day (list_waiting), each as its JSON: the newest first, by when the stage that waits for it started (or it came back to its requester), then by ID from the highest. q narrows them and pages through them (Before is the last ticket of the page before: one that is not in the list gives none; Limit 0 gives all).
func (*Server) WorkEnded ¶
WorkEnded tells the server what became of the work a ticket launched by key (Launch.Key): it was done, with what it ended with, or it failed, with why. The ticket's card shows it (Works). The ticket does not change: it ended when it launched the work. What a work says replaces what it said before, so that work run again after it failed can say it was done in the end. The work may say it before the server has marked its launch done. A key that launched nothing is answered NotFound, a WorkEnd that does not read Invalid; an error is a failure, and the call may be made again.
func (*Server) Worked ¶
func (s *Server) Worked(kind string, version int, in json.RawMessage) (out json.RawMessage, problem string, ok bool, err error)
Worked answers what a form works out (the kind's Worked entry) by a version of a kind: in is `{"form": …, "edited": …}`, checked as the worked operations check it. A screen asks it to show the fields of a form as its conditions and its computed values decide them. problem says why a body is not taken (in English, or in the entry's language where the entry says it), and is "" otherwise; ok is false when the version has no Worked entry (a kind written by hand), and the screen then shows the form as before it is filled in.
type Start ¶
type Start struct {
Kind string
Version int
// How is "now", "day", "description" (its description's start again) or "never". At is the time
// it starts, for "now" and "day"; Day is that time's day in the kind's offset.
How string
At time.Time
Day string
// Number is raised by one with each record of the version's start: 1 for the first.
Number int64
// Record is the ID of the record that decided it.
Record string
}
Start is the start of a version of a kind as an administrator decided it (DESIGN 13.2).
type Store ¶
type Store interface {
// Ticket reads a ticket with its number, or ErrNotFound.
Ticket(ctx context.Context, id string) (TicketRecord, error)
// Save writes a move, all or nothing (see Move). It answers ErrConflict, ErrKeyTaken, or the
// error the move's Books returned.
Save(ctx context.Context, m *Move) error
// Moves reads a ticket's moves, the first first.
Moves(ctx context.Context, ticket string) ([]MoveRecord, error)
// Operation reads what was answered to a person's key, or ErrNotFound.
Operation(ctx context.Context, person, key string) (OperationRecord, error)
// Begin keeps an operation the server begins (Begun), the first time its person gives its key,
// and answers it as kept (its time cut to the microsecond, in UTC). For a key begun before whose
// reply is not kept yet (an operation given again after it was not saved), it keeps nothing and
// answers what it kept then: the operation goes on as the same try, with the same names (DESIGN
// 3.2). Save forgets it when it keeps the key's reply, and ForgetOperations when it is old.
Begin(ctx context.Context, b Begun) (Begun, error)
// Renew keeps b in place of what Begin kept for its person and key: the names of a new try, once
// the server has voided what the books held for the try that was not saved.
Renew(ctx context.Context, b Begun) error
// Waiting reads the tickets that wait for any of the people, the newest first: by when they
// began to wait (Move.Since), then by ID, from the highest. q narrows them and pages through
// them (WaitingQuery).
Waiting(ctx context.Context, people []string, q WaitingQuery) ([]TicketRecord, error)
// Mine reads the tickets a person requested or made for someone else (Move.Own), the newest
// first: by the time of the move that first named them, then by ID, from the highest. q narrows
// them (MineQuery).
Mine(ctx context.Context, person string, q MineQuery) ([]TicketRecord, error)
// Tickets reads the tickets of some versions of a kind, the newest first: by when they were made
// (the time of their first move), then by ID, from the highest. q names the kind and the versions,
// narrows them and pages through them (TicketsQuery).
Tickets(ctx context.Context, q TicketsQuery) ([]TicketRecord, error)
// Lock takes the ticket's lock, for books in another database: it waits until no one else
// holds it, and holds it until unlock is called. The context it answers carries the lock: the
// framework reads the ticket and saves its move with it, so a store may keep the lock on a
// connection and use that connection for them. It is not taken twice by one caller.
Lock(ctx context.Context, ticket string) (locked context.Context, unlock func(), err error)
// DueTimers leases, for lease, up to limit timers due by now (TryAt up to now) that no one
// else holds, oldest first.
DueTimers(ctx context.Context, now time.Time, lease time.Duration, limit int) ([]Timer, error)
// Timers reads a ticket's timers.
Timers(ctx context.Context, ticket string) ([]Timer, error)
// PutOffTimer keeps a timer, to be tried again at try, and gives up its lease.
PutOffTimer(ctx context.Context, k TimerKey, try time.Time) error
// DueToDo leases, for lease, up to limit things to do due by now that are not done and that no
// one else holds, oldest first.
DueToDo(ctx context.Context, now time.Time, lease time.Duration, limit int) ([]ToDo, error)
// ToDoItem reads one thing to do, or ErrNotFound.
ToDoItem(ctx context.Context, id string) (ToDo, error)
// ToDoList reads a ticket's things to do, done or not, the first first.
ToDoList(ctx context.Context, ticket string) ([]ToDo, error)
// DoneToDo marks one done.
DoneToDo(ctx context.Context, id string, at time.Time) error
// RetryToDo gives up the lease of one that failed, to be tried again at try.
RetryToDo(ctx context.Context, id string, try time.Time, why string) error
// KeepOutcome keeps what the work of a thing to do (a launch) said became of it, said at at, in
// place of what it said before (Server.WorkEnded): ErrNotFound when no thing to do has the ID.
KeepOutcome(ctx context.Context, id string, at time.Time, outcome json.RawMessage) error
// KeepToDo keeps a thing to do that no move holds: the void of a hold the books took for a try
// that was not saved, which the books did not answer when the server asked (DESIGN 3.2), not
// tried yet and not done. One kept before with the same ID is left as it is.
KeepToDo(ctx context.Context, t ToDo) error
// SaveOrganization keeps a snapshot of the organization's data and makes it the latest (a
// snapshot with the same ID is the same data: it is made the latest again).
SaveOrganization(ctx context.Context, s OrgSnapshot) error
// LatestOrganization reads the latest snapshot, or ErrNotFound.
LatestOrganization(ctx context.Context) (OrgSnapshot, error)
// Organization reads a snapshot by its ID, or ErrNotFound.
Organization(ctx context.Context, id string) (OrgSnapshot, error)
// KeepUpload records a file a person uploaded (Server.Upload), which no ticket holds yet, and
// answers the ID recorded. For a key (Upload.Key) the person has an upload of that is not let go
// (UploadOf), it records nothing and answers that one's ID: of two at once with one key, one is
// recorded, and both are answered its ID. When the person has max uploads no ticket holds already
// (max 0 or less: no limit), it records nothing and answers ErrTooManyUploads. An ID recorded
// before is left as it is.
KeepUpload(ctx context.Context, u Upload, max int) (id string, err error)
// UploadOf answers the ID of the upload a person made with a key (Upload.Key, not ""), held by a
// ticket or not, that is not let go; or ErrNotFound.
UploadOf(ctx context.Context, person, key string) (id string, err error)
// OpenUploads counts a person's uploads that no ticket holds and that are not let go.
OpenUploads(ctx context.Context, person string) (int, error)
// LetGoUploads lets go of up to limit uploads made before `before` that no ticket holds, the
// oldest first, and answers them, after the ones let go earlier whose files are not deleted yet.
// A move that names an upload let go is not saved (Save answers *UploadGone). The server
// deletes their files, then calls UploadsDeleted.
LetGoUploads(ctx context.Context, before time.Time, limit int) ([]Upload, error)
// UploadsDeleted records that the files of uploads let go are deleted. The uploads stay
// recorded as let go, so that no move holds them later.
UploadsDeleted(ctx context.Context, ids []string) error
// ForgetOperations forgets up to limit operations answered before `before`, the oldest first:
// their keys and replies (Operation answers ErrNotFound for them); and up to limit operations
// begun before it whose replies were never kept (Begin), the oldest first. Of one time, it
// forgets them by person, then by key, as Go compares strings (byte by byte, not by a
// database's collation), so that every store forgets the same ones; the conformance test
// Keeping checks it. It answers how many of both: an answer under limit means none of either is
// left from before `before`. The server calls it again while the answer is limit or more
// (Server.Sweep).
ForgetOperations(ctx context.Context, before time.Time, limit int) (int, error)
// SaveChange writes a change an administrator made (DESIGN 13.8), all or nothing (see Change).
// It answers ErrConflict, ErrKeyTaken or ErrTooManyImports, and then writes nothing; a record of
// an ID the store keeps (Config.NewRecordID made one twice) is an error too, which writes nothing.
SaveChange(ctx context.Context, c *Change) error
// Starts reads the start of each version of a kind an administrator decided (Change.Start).
Starts(ctx context.Context) ([]Start, error)
// Records reads a page of the record (DESIGN 13.5): the moves of the tickets and the records, the
// newest first, then by the ticket's or the record's ID from the highest (as Go compares
// strings), then by the move's number from the highest. q says which lines may be read and
// narrows them (RecordQuery).
Records(ctx context.Context, q RecordQuery) ([]Line, error)
// Record reads a record by its ID, or ErrNotFound: the one that decided a start (Start.Record).
Record(ctx context.Context, id string) (Record, error)
// CountTickets counts the tickets of the versions given by kind, version and status, each that
// has any once: the versions whose lines the person may read (DESIGN 13.4). No other ticket is
// counted.
CountTickets(ctx context.Context, versions []KindVersion) ([]TicketCount, error)
// KeptVersions counts the tickets of every version the store keeps any of, by kind, version
// and status, in the order CountTickets answers them: what the server compares with the
// versions its packages have when it starts (Server.Unpackaged).
KeptVersions(ctx context.Context) ([]TicketCount, error)
// Imports answers the times of the imports that added a snapshot (Record.Added) at or after
// since, the oldest first.
Imports(ctx context.Context, since time.Time) ([]time.Time, error)
// LastImport reads the latest record of an import from Config.Organization (Record.Source
// "config"), or ErrNotFound.
LastImport(ctx context.Context) (Record, error)
// KeepDraft keeps a draft of the organization's data (Draft). One of the same person and ID is
// kept again, with its new time. When the person has more than max drafts after it, their oldest
// (by time, then by ID, as Go compares strings) are forgotten.
KeepDraft(ctx context.Context, d Draft, max int) error
// Draft reads a person's draft, or ErrNotFound.
Draft(ctx context.Context, person, id string) (Draft, error)
// ForgetDrafts forgets up to limit drafts kept before `before`, the oldest first (by time, then by
// person, then by ID, as Go compares strings), and answers how many.
ForgetDrafts(ctx context.Context, before time.Time, limit int) (int, error)
// Bundles reads every bundle the store keeps (DESIGN 15.6), without their archives, in the order
// they were kept (by Bundle.Uploaded.At, then by digest, as Go compares strings).
Bundles(ctx context.Context) ([]Bundle, error)
// BundleArchive reads a bundle's archive by its digest, or ErrNotFound: for a digest the store
// keeps no bundle of, and for a bundle whose archive it forgot (BundleChange.Forget).
BundleArchive(ctx context.Context, digest string) ([]byte, error)
}
Store keeps the tickets and everything that goes with them. What a store must get right is Save: one move, written all or nothing, only over the ticket it read. The rest reads what Save wrote and leases the timers and the things to do. The conformance tests (package conformance) check a store against all of it. Every method is called from many goroutines at once.
Times are kept to the microsecond: a store keeps each time it is given with what is finer than a microsecond cut off (toward the past), reads it back so, and compares the times it is given (a now, a before, the end of a lease) so. Two times within one microsecond are one time: the lists by time (Waiting, Mine) order such tickets by ID, as they order any tickets of one time, where a store that kept finer times would order them by time. The PostgreSQL store keeps times so (its driver cuts a time to the microsecond before it sends it), and so does the memory store; the conformance test WaitingOrder checks it.
Every time a store answers is in UTC (its Location is time.UTC), whatever the zone of the time it was given and the zone of the process it runs in, so that what it answers is the same on any machine. The PostgreSQL store answers so (its driver reads a time in the process's zone), and so does the memory store; the conformance test Keeping checks it.
type Submitting ¶
type Submitting struct {
// Version is the version of the kind in effect.
Version int
// Self is whether the person may make the request for themselves (DESIGN 10.1).
Self bool
// For are the people the person may make it for as their submit proxy that day, sorted.
For []string
}
Submitting is what a new request's form of a kind needs today.
type Team ¶
type Team struct {
ID string `json:"id"`
Name string `json:"name"`
NameJa string `json:"name_ja,omitempty"`
Kind string `json:"kind"`
Parent string `json:"parent,omitempty"`
Head string `json:"head,omitempty"`
}
Team is a team of a version. Parent and Head are "" for none.
type TicketCount ¶
TicketCount is how many tickets of a version of a kind have a status.
type TicketRecord ¶
type TicketRecord struct {
ID string
Kind string
Version int
// Status is the ticket's status, kept apart to list by.
Status string
// Number is raised by one with each move; a move writes only over the number it read.
Number int64
// Body is the ticket's JSON as `next` answered it.
Body json.RawMessage
Updated time.Time
// People are everyone the ticket's moves named (Move.People), sorted: the people who may see it
// though the ticket no longer names them (an approver of a later stage after a send-back to an
// earlier one). Ticket, Waiting and Mine read them.
People []string
// Since is when the ticket began to wait for the people it waits for (Move.Since); zero when it
// waits for no one.
Since time.Time
}
TicketRecord is a ticket as the store keeps it.
type TicketsQuery ¶
type TicketsQuery struct {
// Kind is the kind of request whose tickets are read.
Kind string
// Versions keeps the tickets of these versions of the kind; none keeps none.
Versions []int
// Status keeps the tickets of one status ("approved", those approved); "" keeps all.
Status string
// Before keeps the tickets older than this one (the last of the page before); "" starts from the
// newest. A ticket that is not of the kind and of one of the versions keeps none.
Before string
// Limit keeps at most this many; 0 keeps all.
Limit int
}
TicketsQuery names the tickets Store.Tickets reads, of some versions of a kind, and narrows them as MineQuery does a person's own. Server.Tickets takes it too, and decides the versions itself.
type Timer ¶
type Timer struct {
TimerKey
// At is the time `next` set it for; TryAt when it is given next (later, once put off).
At time.Time
TryAt time.Time
}
Timer is a timer a ticket set.
type ToDo ¶
type ToDo struct {
// ID is the effect's key (EffectKey.String), an audit entry's key, or, for the void of a hold
// of a try that was not saved, void/<the hold's effect key>/<the try>.
ID string
Ticket string
// What is notify, launch, ask_agent, ask_note, release or audit.
What string
// Body is what to do, as the framework wrote it.
Body json.RawMessage
Created time.Time
TryAt time.Time
Tries int
LastError string
Done bool
// DoneAt is when it was done (DoneToDo); zero while it is not.
DoneAt time.Time
// Outcome is what the work a launch started said became of it (Server.WorkEnded), as the
// server wrote it, and OutcomeAt when it said so (KeepOutcome); nil and zero until it says.
Outcome json.RawMessage
OutcomeAt time.Time
}
ToDo is one thing to do after a save, or the void of a hold of a try that was not saved (Store.KeepToDo).
type TooManyUploads ¶
TooManyUploads is Upload's refusal of a person who has Max uploads that no ticket holds (Config.UploadsPerPerson). Kept is how long such an upload is kept (Config.UploadsKept; a negative duration: until a ticket holds it). errors.Is takes it for ErrTooManyUploads.
func (*TooManyUploads) Error ¶
func (e *TooManyUploads) Error() string
func (*TooManyUploads) Is ¶
func (e *TooManyUploads) Is(target error) bool
type TrialStore ¶
type TrialStore interface {
// Trial begins a transaction of the store's database, of the kind a move's Books is given, that
// is never committed: end rolls it back, and what the books did in it is not kept.
Trial(ctx context.Context) (tx any, end func(), err error)
}
TrialStore is a store that can open a transaction it never commits. Server.Try asks the books in one, so that a trial sees a book's refusal (a budget used up) and the books keep nothing of it. memstore and postgres have it. With a store that does not, or with the books in a database of their own (Config.BooksApart), Try leaves the books unasked and says so (Reply.NotAsked).
type UnpackagedError ¶
type UnpackagedError struct {
Counts []TicketCount
}
UnpackagedError is the refusal to serve while the store keeps tickets of a version no package has (Server.Unpackaged): its error names each version, with how many tickets of each status.
func (*UnpackagedError) Error ¶
func (e *UnpackagedError) Error() string
type Upload ¶
type Upload struct {
ID string
By string
At time.Time
// Key is the key the person gave with the file, to keep it once (Server.UploadOnce); "" for none.
Key string
}
Upload is a file a person uploaded, as the store records it (Store.KeepUpload): its ID in Config.Files, who uploaded it and when.
type UploadGone ¶
type UploadGone struct{ ID string }
UploadGone is Save's answer to a move that names an upload the store let go (Store.LetGoUploads): its file is deleted, or about to be. Nothing of the move is written.
func (*UploadGone) Error ¶
func (e *UploadGone) Error() string
type VectorCheck ¶
type VectorCheck struct {
Kinds []VectorCount
}
VectorCheck is what CheckVectors ran: of each kind, how many vectors and how many of them agreed.
func CheckVectors ¶
func CheckVectors(ctx context.Context, p *Package) VectorCheck
CheckVectors runs every vector of a package's kinds on its entries, as the server takes a bundle (DESIGN 15.5): each event of vectors/<kind>.jsonl given to Start (a ticket's first) or Next, with the vector's part of the organization and time, answers the vector's answer — the same ticket and effects (SameJSON), or a refusal of the same kind at the same place, its texts aside, as the conformance tests compare them —, and each form of vectors/worked/<kind>.jsonl, given to Worked, what the vector says the form works out. A kind with no vectors of its events is Missing. The vectors run on as many goroutines as the process has processors, and stop with ctx.
func (VectorCheck) Agree ¶
func (v VectorCheck) Agree() bool
Agree reports whether every vector ran agreed, and each kind had its vectors.
func (VectorCheck) Vectors ¶
func (v VectorCheck) Vectors() int
Vectors and Worked answer how many vectors of the events and of the forms ran.
func (VectorCheck) Worked ¶
func (v VectorCheck) Worked() int
type VectorCount ¶
type VectorCount struct {
Kind string
Vectors, Worked int
Agree int
Failures []string
// Missing says the package has no vectors of the kind's events.
Missing bool
// Starts and Nexts are how many of the vectors are of a ticket's first event (a submit) and of
// the events after it. A kind is checked only when it has both: the one who uploads a bundle
// could otherwise have it checked against nothing (DESIGN 15.5).
Starts, Nexts int
}
VectorCount is how many vectors of a kind ran (Vectors, of its events; Worked, of its form) and the first shownFailures of those that did not agree, each with where it was written and why.
type WaitingCounter ¶
type WaitingCounter interface {
// CountWaiting answers how many tickets wait for the person, by kind (TicketRecord.Kind): the
// tickets Waiting reads for the person alone, counted. A kind with none is left out.
CountWaiting(ctx context.Context, person string) (map[string]int, error)
}
WaitingCounter is a store that counts the tickets that wait for a person without reading them: Server.CountWaiting asks it for the person's own, and reads only the tickets of the people they stand in for. memstore and postgres have it. With a store that does not, CountWaiting reads the tickets that wait for the person, as Waiting does, to count them.
type WaitingQuery ¶
type WaitingQuery struct {
// Kind keeps the tickets of one kind of request; "" keeps all.
Kind string
// Before keeps the tickets after this one in the list's order (the last of the page before); ""
// starts from the newest. A ticket that does not wait for any of the people keeps none.
Before string
// Limit keeps at most this many; 0 keeps all.
Limit int
}
WaitingQuery narrows the tickets Store.Waiting reads, as MineQuery does a person's own.
type Work ¶
type Work struct {
// Key is the key of its launch (Launch.Key).
Key EffectKey
// Flow is the name the kind gives its flow (`use flow <name>`).
Flow string
// State is waiting (it is not started yet), retrying (starting it failed, and it is tried
// again), started (it is started, and it has not said what became of it), done or failed (as
// it said, with WorkEnded).
State string
// Tries is the times starting it failed.
Tries int
// At is when it was started (started), or when it said what became of it (done, failed); zero
// while it waits or is tried again.
At time.Time
// Reason is why it failed, as it said; "" otherwise.
Reason string
// Outputs are what it ended with, as it said; nil for none.
Outputs []NamedValue
}
Work is a piece of work a ticket launched, as the server knows it (Works).
type WorkEnd ¶
type WorkEnd struct {
// Failed is true when the work failed to the end. Reason says why, in words: at most MaxReason
// characters, with no control or format character but a line break, as a reason of the
// administration.
Failed bool
Reason string
// Outputs are the values the work ended with, such as the number of an order (the outputs its
// flow ends with): NamedText, NamedNumber and NamedTruth make them. Written as JSON, they are at
// most MaxOutputs bytes.
Outputs []NamedValue
}
WorkEnd is what became of the work a ticket launched (an `on … launch` line of its kind), as the work says it (Server.WorkEnded).
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package apikeys finds who sends a request by a key a program sends with it (the header Authorization: Bearer <key>), for a program that uses the API as a person of the organization: another system that makes requests, or says what became of the work an approval started.
|
Package apikeys finds who sends a request by a key a program sends with it (the header Authorization: Bearer <key>), for a program that uses the API as a person of the organization: another system that makes requests, or says what became of the work an approval started. |
|
Package bundlesign signs a bundle of the kinds of request, and verifies such a signature.
|
Package bundlesign signs a bundle of the kinds of request, and verifies such a signature. |
|
cmd
|
|
|
ringi-bundle
command
Command ringi-bundle makes the keys of a bundle of the kinds of request, signs a bundle, and verifies a bundle's signature.
|
Command ringi-bundle makes the keys of a bundle of the kinds of request, signs a bundle, and verifies a bundle's signature. |
|
Package conformance has the tests that check a server against the contract ritsu generates.
|
Package conformance has the tests that check a server against the contract ritsu generates. |
|
Package devlogin signs people in for trying a server on one's own computer, and checks no one's identity: a page that lists the people of the organization, where the one chosen is who sends each request from then on (SignIn), and the header X-Person, for trying the API with a client such as curl (Header).
|
Package devlogin signs people in for trying a server on one's own computer, and checks no one's identity: a page that lists the people of the organization, where the one chosen is who sends each request from then on (SignIn), and the header X-Person, for trying the API with a client such as curl (Header). |
|
internal
|
|
|
jatext
Package jatext sets names in the framework's sentences in Japanese: the words of the pages, the answers of the MCP tools, the refusals the server writes and the words of the pages of signing in.
|
Package jatext sets names in the framework's sentences in Japanese: the words of the pages, the answers of the MCP tools, the refusals the server writes and the words of the pages of signing in. |
|
Package kinddiff compares two versions of a kind of request from their requests directories: the kind's description in types/<kind>.json, and the operations the kind owns in openapi.json.
|
Package kinddiff compares two versions of a kind of request from their requests directories: the kind's description in types/<kind>.json, and the operations the kind owns in openapi.json. |
|
mcp
module
|
|
|
Package memstore keeps a server's tickets (Store) and attachments (Files) in memory: for tests, and for trying the framework out.
|
Package memstore keeps a server's tickets (Store) and attachments (Files) in memory: for tests, and for trying the framework out. |
|
Package oidc signs people in through the organization's OpenID Connect provider.
|
Package oidc signs people in through the organization's OpenID Connect provider. |
|
oidctest
Package oidctest is an OpenID Connect provider for the tests of a server that signs people in with package oidc: its discovery document, a JWK Set, an authorization endpoint that signs in at once the person a test chooses, and a token endpoint that checks the client, the redirect URL, PKCE and that a code is used once, and signs ID tokens with an RSA key (RS256).
|
Package oidctest is an OpenID Connect provider for the tests of a server that signs people in with package oidc: its discovery document, a JWK Set, an authorization endpoint that signs in at once the person a test chooses, and a token endpoint that checks the client, the redirect URL, PKCE and that a code is used once, and signs ID tokens with an RSA key (RS256). |
|
Package orgfiles reads the organization's data from the files ritsu reads: a directory for each version, named by the day it takes effect, with teams.csv, people.csv and members.csv or one organization.json; proxies.csv beside the versions; and a CSV for each master.
|
Package orgfiles reads the organization's data from the files ritsu reads: a directory for each version, named by the day it takes effect, with teams.csv, people.csv and members.csv or one organization.json; proxies.csv beside the versions; and a CSV for each master. |
|
Package postgres is a server.Store on PostgreSQL, through pgx v5.
|
Package postgres is a server.Store on PostgreSQL, through pgx v5. |
|
Package scaffold holds the tests of the first files of a project, the ones `ritsu ringi init` writes: they write them with ritsu, in each language and with each set of options, build them against this repository's modules and run their own tests (DESIGN 2.7).
|
Package scaffold holds the tests of the first files of a project, the ones `ritsu ringi init` writes: they write them with ritsu, in each language and with each set of options, build them against this repository's modules and run their own tests (DESIGN 2.7). |
|
Package screens serves the screens ritsu writes for the kinds of request of a project (A2UI 1.0): it fills a screen's template with a ticket's values for one viewer, and makes the action a renderer sends when a button is pressed into the operation of the API it is.
|
Package screens serves the screens ritsu writes for the kinds of request of a project (A2UI 1.0): it fills a screen's template with a ticket's values for one viewer, and makes the action a renderer sends when a button is pressed into the operation of the API it is. |
|
page
Package page shows the screens of a kind of request as plain HTML (ringi's DESIGN 13.6): the request form, the approval card, the list and the history, for any browser, with JavaScript or without.
|
Package page shows the screens of a kind of request as plain HTML (ringi's DESIGN 13.6): the request form, the approval card, the list and the history, for any browser, with JavaScript or without. |
|
Package serve runs a server of the framework from its command line: the flags every server takes (the address, where the tickets and the attachments are kept, how people sign in, a certificate), the checks of the flags and the environment before anything is read or reached, the stores the flags name, and the HTTP server with the pages in front, until the process is told to stop.
|
Package serve runs a server of the framework from its command line: the flags every server takes (the address, where the tickets and the attachments are kept, how people sign in, a certificate), the checks of the flags and the environment before anything is read or reached, the stores the flags name, and the HTTP server with the pages in front, until the process is told to stop. |
|
Package servertest has the parts of a server for tests and examples: a clock you set, an authenticator that trusts a header, and a notifier, flows, agents, books, files and an audit log that remember what they were given; and, for the tests of a project's pages, a browser with no script (Browser) and the form of a page as a browser holds it (Form).
|
Package servertest has the parts of a server for tests and examples: a clock you set, an authenticator that trusts a header, and a notifier, flows, agents, books, files and an audit log that remember what they were given; and, for the tests of a project's pages, a browser with no script (Browser) and the form of a page as a browser holds it (Form). |
|
temporal
module
|
|
|
Package wasmkind runs the kinds of request of a requests directory that holds them as Wasm: the module ritsu builds from the project's Rust package (kinds.wasm), and how to call it (wasm.json), both written by `ritsu gen --target requests --extra wasm`.
|
Package wasmkind runs the kinds of request of a requests directory that holds them as Wasm: the module ritsu builds from the project's Rust package (kinds.wasm), and how to call it (wasm.json), both written by `ritsu gen --target requests --extra wasm`. |
|
Package web serves the pages people use in a browser, in which they make requests, approve them and see their own.
|
Package web serves the pages people use in a browser, in which they make requests, approve them and see their own. |

