Documentation
¶
Overview ¶
Package server is the HTTP API that `ingestion serve` answers. Every route but the probes and the RFC 9728 metadata answers only a request carrying a bearer token the identity provider signed. A person's token reaches every route. A service's token reaches only the routes its scopes list.
Index ¶
- Constants
- Variables
- func GateConfig(issuer string) goapiauth.Config
- func Handler(cfg Config, routes ...Routes) http.Handler
- func JSON(w http.ResponseWriter, status int, body any)
- func Refuse(w http.ResponseWriter, status int, code, format string, args ...any)
- func ValidCause(cause string) bool
- type AfterStage
- type BlobAnswer
- type ClaimAnswer
- type ClaimRequest
- type Config
- type ConnectorConfig
- type ConnectorView
- type ConnectorsAnswer
- type DecisionView
- type DeclarationsAnswer
- type DeclarationsRequest
- type DeliveryView
- type DropRequest
- type FindingView
- type FirstFillAnswer
- type FirstFillRequest
- type FirstFillView
- type HeartbeatRequest
- type HomeView
- type ItemAnswer
- type ItemListed
- type ItemView
- type ItemsAnswer
- type LeasedTask
- type OutputView
- type ParseAnswer
- type ParseFinding
- type PlaceRequest
- type PlacementAnswer
- type PushAnswer
- type PushedItem
- type Repeat
- type ReplayAnswer
- type ReplayRequest
- type Replayable
- type ReportDelivery
- type ReportOutput
- type ReportRequest
- type ReviewAnswer
- type ReviewDestination
- type ReviewGuess
- type ReviewItem
- type ReviewSighting
- type Route
- type Router
- type Routes
- func BlobRoutes(l *landing.Lander, log *slog.Logger) Routes
- func ConnectorRoutes(cfg ConnectorConfig) Routes
- func ItemRoutes(st *store.Store, log *slog.Logger) Routes
- func ReplayRoutes(st *store.Store, stages map[string]Replayable, log *slog.Logger) Routes
- func ReviewRoutes(st *store.Store, log *slog.Logger) Routes
- func TaskRoutes(st *store.Store, log *slog.Logger, after AfterStage) Routes
- type RunAnswer
- type SectionView
- type SightingView
- type StageOutput
- type SuggestionFindingView
- type SuggestionView
- type TaskParseAnswer
- type TaskRetryAnswer
- type TaskView
- type TasksAnswer
- type TokenGate
- type UndeliveredView
- type UnpairedAnswer
- type UnpairedFile
- type WaitingView
Constants ¶
const ( // ScopeDeclarationsApply admits a caller to apply a set of declarations. ScopeDeclarationsApply = "ingestion.declarations.apply" // ScopeConnectorsRead admits a caller to read each connector's state. ScopeConnectorsRead = "ingestion.connectors.read" // ScopeConnectorsRun admits a caller to run a connector now. ScopeConnectorsRun = "ingestion.connectors.run" // ScopeFirstFillsRelease admits a caller to release a connector's first // fill, which sends every item it held on to the model stages. ScopeFirstFillsRelease = "ingestion.first-fills.release" // ScopeItemsDrop admits a caller to drop a file into a drop connector. ScopeItemsDrop = "ingestion.items.drop" )
Scopes of the connector routes.
const ( CodeConnectorNotFound = "connector_not_found" CodeConnectorMode = "connector_mode" CodeInvalidDeclarations = "invalid_declarations" CodeDeclarationsMoved = "declarations_moved" CodeDropTooLarge = "drop_too_large" CodeInvalidDrop = "invalid_drop" )
Refusal codes of the connector routes.
const ( DefaultItemsListed = 100 MaxItemsListed = 1000 )
DefaultItemsListed bounds a list whose caller names no limit, and MaxItemsListed bounds every page. A larger limit answers a page of MaxItemsListed and its next cursor, so a caller pages on without knowing it.
const ( FoundInSource = "source" FoundInSentence = "sentence" )
Where a suggestion's finding was found.
const ( // WaitingFirstFill is a task that a connector's first fill holds. WaitingFirstFill = "first-fill" // WaitingUnclaimed is a task that no worker heard from lately claims. WaitingUnclaimed = "unclaimed" // WaitingQueued is a task that a worker claims next. WaitingQueued = "queued" // WaitingDispatched is a run that the model port started and that has // not answered. WaitingDispatched = "dispatched" )
Why an item waits at a model stage.
const ( CodeIdempotencyKeyMissing = "idempotency_key_missing" CodeIdempotencyKeyReused = "idempotency_key_reused" CodeStageNotReplayable = "stage_not_replayable" CodeNoItemFromConnector = "no_item_from_connector" // CodePlacedByNotReplayable is a replay over the labeled items, of a // stage that holds no such replay. CodePlacedByNotReplayable = "placed_by_not_replayable" // CodeModelNotReplayable is a replay that names a model, of a stage that // runs on the model its worker's config names. CodeModelNotReplayable = "model_not_replayable" // CodeModelMissing is a replay of a measurement arm that names no model. CodeModelMissing = "model_missing" )
Refusal codes of a replay.
const ( ScopeReviewRead = "ingestion.review.read" ScopeReviewPlace = "ingestion.review.place" )
ScopeReviewRead admits a caller to read the items that wait on a person's placement. ScopeReviewPlace admits it to place or drop an item for the person whose login its body names.
const ( CodeDestinationNotDeclared = "destination_not_declared" CodeActingForAnother = "acting_for_another" CodeChapterOfBook = "chapter_of_book" )
CodeDestinationNotDeclared refuses a placement on a destination that the set in force does not declare. CodeActingForAnother refuses a person's token whose body names another person's login. CodeChapterOfBook refuses a placement of a book's chapter, which takes its book's placement.
const ( CodeInvalidBody = "invalid_body" CodeInvalidQuery = "invalid_query" CodeRouteNotFound = "route_not_found" CodeTaskNotFound = "task_not_found" CodeItemNotFound = "item_not_found" CodeParseNotFound = "parse_not_found" CodeStaleLease = "stale_lease" CodeTaskDone = "task_done" CodeInternal = "internal" CodeUnknownField = "unknown_field" CodeInvalidKey = "invalid_key" CodeInvalidBlob = "invalid_blob" CodeBlobNotFound = "blob_not_found" // CodeBlobBytesMissing is a blob whose row holds and whose bytes are gone, // which the unpaired report also names. CodeBlobBytesMissing = "blob_bytes_missing" CodeDigestMismatch = "digest_mismatch" )
Refusal codes, by the status each answers with. A client branches on the code, and the message is for a person.
const ( OutcomeDone = "done" OutcomeFailed = "failed" OutcomeRetry = "retry" )
Report outcomes.
const IdempotencyKey = "Idempotency-Key"
IdempotencyKey is the header that a keyed route finds an earlier request's work by, so a retry after a lost answer never starts it twice.
const MaxBlobBytes = 4 << 30
MaxBlobBytes bounds one blob that a worker writes.
const MaxDropBytes = 256 << 20
MaxDropBytes bounds one dropped file. A folder connector takes larger files, such as books, by reference.
const MaxListed = 1000
MaxListed is the most tasks one list answers.
const Product = "ingestion"
Product names the client id prefixes the API accepts: ingestion-cli- for a person's device login, ingestion-svc- for a service.
const ScopeItemsRead = "ingestion.items.read"
ScopeItemsRead admits a caller to read items and their records.
const ScopeItemsReplay = "ingestion.items.replay"
ScopeItemsReplay admits a caller to run a stage again over landed items.
const ScopeTasksClaim = "ingestion.tasks.claim"
ScopeTasksClaim admits a worker to claim tasks, extend their leases and report them.
const WorkersHeardWithin = 10 * time.Minute
WorkersHeardWithin is how recently a worker was heard from for the list to show it by default. Each process start is a worker of its own, so the workers that stopped outnumber the live ones within a few releases.
Variables ¶
var ( RouteVersion = Route{"GET /api/v1/version", ScopeTasksClaim, RepeatRead} RouteTaskClaims = Route{"POST /api/v1/tasks/claims", ScopeTasksClaim, RepeatOnce} RouteTaskHeartbeats = Route{"POST /api/v1/tasks/{id}/heartbeats", ScopeTasksClaim, RepeatByContent} RouteTaskReports = Route{"POST /api/v1/tasks/{id}/reports", ScopeTasksClaim, RepeatByContent} RouteTaskParse = Route{"GET /api/v1/tasks/{id}/parse", ScopeTasksClaim, RepeatRead} RouteTaskRetries = Route{"POST /api/v1/tasks/{id}/retries", "", RepeatByContent} RouteTasks = Route{"GET /api/v1/tasks", "", RepeatRead} RouteBlob = Route{"GET /api/v1/blobs/{sha256}", ScopeTasksClaim, RepeatRead} RouteBlobWrite = Route{"PUT /api/v1/blobs/{sha256}", ScopeTasksClaim, RepeatByContent} RouteBlobsUnpaired = Route{"GET /api/v1/blobs/unpaired", "", RepeatRead} RouteItems = Route{"GET /api/v1/items", ScopeItemsRead, RepeatRead} RouteItem = Route{"GET /api/v1/items/{key}", ScopeItemsRead, RepeatRead} RouteItemParse = Route{"GET /api/v1/items/{key}/parse", ScopeItemsRead, RepeatRead} RouteReplays = Route{"POST /api/v1/replays", ScopeItemsReplay, RepeatKeyed} RouteDeclarations = Route{"PUT /api/v1/declarations", ScopeDeclarationsApply, RepeatByContent} RouteConnectors = Route{"GET /api/v1/connectors", ScopeConnectorsRead, RepeatRead} RouteConnector = Route{"GET /api/v1/connectors/{name}", ScopeConnectorsRead, RepeatRead} RouteConnectorRuns = Route{"POST /api/v1/connectors/{name}/runs", ScopeConnectorsRun, RepeatKeyed} RouteFirstFill = Route{"PATCH /api/v1/connectors/{name}/first-fill", ScopeFirstFillsRelease, RepeatByContent} RouteConnectorDrops = Route{"POST /api/v1/connectors/{name}/drops", ScopeItemsDrop, RepeatKeyed} RouteReview = Route{"GET /api/v1/review", ScopeReviewRead, RepeatRead} RouteReviewPlace = Route{"POST /api/v1/review/{key}/place", ScopeReviewPlace, RepeatByContent} RouteReviewDrop = Route{"POST /api/v1/review/{key}/drop", ScopeReviewPlace, RepeatByContent} RouteGateAgreement = Route{"GET /api/v1/gates/agreement", ScopeItemsRead, RepeatRead} )
The route table. Each package registers its rows with Router.Handle, and a client sends through the row of the route it calls.
var ReplayStages = []string{ store.StageParse, store.StageStructure, store.StageContents, store.StageScan, store.StageQuality, store.StageQualityArm, store.StageModelRead, store.StageDeliver, }
ReplayStages are the stages that a replay request may name, as schemas/replay.schema.json's stage enum holds them. ReplayRoutes takes the stages that the service replays.
Functions ¶
func GateConfig ¶
GateConfig is the token check for issuer, accepting this product's person and service clients.
func Handler ¶
Handler is every route: the probes, which answer with no token so a kubelet can call them, the metadata, and each of routes behind the token check.
func JSON ¶
func JSON(w http.ResponseWriter, status int, body any)
JSON answers status with body encoded as JSON.
func Refuse ¶
func Refuse(w http.ResponseWriter, status int, code, format string, args ...any)
Refuse answers status with a refusal carrying code and the sentence that format and args make.
func ValidCause ¶
ValidCause reports whether cause is spelled as the place and drop routes take one.
Types ¶
type AfterStage ¶
AfterStage runs in the write that ends an item's task done, after the stage's outputs, such as the scan and the gates that follow an item's parse. An error rolls the whole report back, so the task stays leased.
type BlobAnswer ¶
type BlobAnswer struct {
SchemaVersion int `json:"schema_version"`
SHA256 string `json:"sha256"`
MD5 string `json:"md5"`
SizeBytes int64 `json:"size_bytes"`
MediaType string `json:"media_type"`
CreatedTS string `json:"created_ts"`
}
BlobAnswer is what a blob write answers: schemas/blob.schema.json.
type ClaimAnswer ¶
type ClaimAnswer struct {
Tasks []LeasedTask `json:"tasks"`
}
ClaimAnswer is every task that the claim leased, and none where nothing waits.
type ClaimRequest ¶
type ClaimRequest struct {
WorkerID string `json:"worker_id"`
Capabilities []string `json:"capabilities"`
Version string `json:"version"`
StartedTS string `json:"started_ts"`
Max int `json:"max"`
MaxByCapability map[string]int `json:"max_by_capability,omitempty"`
LeaseSeconds int `json:"lease_seconds"`
}
ClaimRequest is a worker asking for up to Max tasks whose capability it holds, each leased for LeaseSeconds. MaxByCapability bounds how many of each capability it names the claim leases, such as a worker whose slot limit for one capability holds one of its slots free for the rest.
type Config ¶
type Config struct {
Store *store.Store
Gate TokenGate
// Issuer is the identity provider whose tokens the API accepts.
Issuer string
// PublicURL is where callers reach the API. Where it is set, the
// API serves RFC 9728 metadata there, from which `ingestion auth login`
// learns the issuer.
PublicURL string
Version string
Log *slog.Logger
}
Config is what the API serves from.
type ConnectorConfig ¶
type ConnectorConfig struct {
Store *store.Store
Lander *landing.Lander
Scheduler *connectors.Scheduler
// Roots names each [serve.homes] root a folder connector may read.
Roots []string
// AfterApply runs in the write that applies a changed set.
AfterApply connectors.AfterApply
Log *slog.Logger
}
ConnectorConfig is what the connector routes serve from.
type ConnectorView ¶
type ConnectorView struct {
Name string `json:"name"`
Mode string `json:"mode"`
Zone store.Zone `json:"zone"`
Source string `json:"source"`
Tags []string `json:"tags"`
AppliedCommit string `json:"applied_commit"`
LastRunTS *string `json:"last_run_ts"`
LastDeliveryTS *string `json:"last_delivery_ts"`
// LastError is why the last run failed, null since one succeeded, and
// Failures counts the failed runs since then.
LastError *string `json:"last_error"`
LastErrorTS *string `json:"last_error_ts"`
Failures int `json:"failures"`
Items int `json:"items"`
Waiting int `json:"waiting"`
Review int `json:"review"`
Failed int `json:"failed"`
Schedule *string `json:"schedule"`
DueInterval *string `json:"due_interval"`
Freshness *string `json:"freshness"`
DueAt string `json:"due_at"`
Overdue bool `json:"overdue"`
// OverdueSince is when the connector went overdue, and null while it is not.
OverdueSince *string `json:"overdue_since"`
// FirstFill is answered on one connector alone.
FirstFill *FirstFillView `json:"first_fill,omitempty"`
}
ConnectorView is one applied connector, its counts and its due time.
type ConnectorsAnswer ¶
type ConnectorsAnswer struct {
SchemaVersion int `json:"schema_version"`
// AppliedCommit is the commit of the set in force, and null where no set
// has been applied.
AppliedCommit *string `json:"applied_commit"`
Connectors []ConnectorView `json:"connectors"`
}
ConnectorsAnswer is what GET /api/v1/connectors answers: schemas/connectors-list.schema.json.
type DecisionView ¶
type DecisionView struct {
Gate string `json:"gate"`
Verdict string `json:"verdict"`
DecidedBy string `json:"decided_by"`
Confidence *float64 `json:"confidence"`
Cause string `json:"cause"`
Destination *string `json:"destination"`
Note *string `json:"note"`
Lens *string `json:"lens"`
ClientID *string `json:"client_id"`
DecidedTS string `json:"decided_ts"`
}
DecisionView is one gate's decision.
type DeclarationsAnswer ¶
type DeclarationsAnswer struct {
SchemaVersion int `json:"schema_version"`
Commit string `json:"commit"`
AppliedTS string `json:"applied_ts"`
AppliedBy string `json:"applied_by"`
Unchanged bool `json:"unchanged"`
Connectors int `json:"connectors"`
RoutingRules int `json:"routing_rules"`
Destinations int `json:"destinations"`
}
DeclarationsAnswer is what an apply answers: schemas/declarations-applied.schema.json.
type DeclarationsRequest ¶
type DeclarationsRequest struct {
Commit string `json:"commit"`
// Replaces is the commit the caller saw in force, and null where it saw
// none. An apply that replaces another commit is refused.
Replaces *string `json:"replaces"`
connectors.Set
}
DeclarationsRequest is what PUT /api/v1/declarations reads: schemas/declarations.schema.json.
type DeliveryView ¶
type DeliveryView struct {
Destination string `json:"destination"`
DestinationID *string `json:"destination_id"`
Outcome string `json:"outcome"`
Attempts int `json:"attempts"`
LastError *string `json:"last_error"`
// UnclaimedCapability is the capability of the delivery's queued task
// where no worker heard from lately holds it, and null otherwise.
UnclaimedCapability *string `json:"unclaimed_capability"`
}
DeliveryView is one delivery to one destination.
type DropRequest ¶
type DropRequest struct {
Cause string `json:"cause,omitempty"`
Note *string `json:"note,omitempty"`
Login string `json:"login,omitempty"`
}
DropRequest drops an item, which keeps its row. Cause names the aspect that decided it, and a drop that names none is kept as unstated.
type FindingView ¶
FindingView is one scanner finding and the text it matched.
type FirstFillAnswer ¶
type FirstFillAnswer struct {
SchemaVersion int `json:"schema_version"`
Connector string `json:"connector"`
State string `json:"state"`
// Released counts the held queued tasks that this request returned to the
// claims, which is 0 for a fill already released.
Released int `json:"released"`
}
FirstFillAnswer is what the PATCH answers: schemas/first-fill.schema.json.
type FirstFillRequest ¶
type FirstFillRequest struct {
State string `json:"state"`
}
FirstFillRequest is what PATCH /api/v1/connectors/{name}/first-fill reads. Released is the one state a person sets.
type FirstFillView ¶
type FirstFillView struct {
State string `json:"state"`
ItemKey *string `json:"item_key"`
Held int `json:"held"`
Tokens map[string]store.Tokens `json:"tokens"`
}
FirstFillView is a connector's first fill: its state, the one item it ran end to end, the items held behind it, and that item's tokens by model stage.
type HeartbeatRequest ¶
HeartbeatRequest extends a lease by LeaseSeconds from now.
type HomeView ¶
type HomeView struct {
Root string `json:"root"`
Path string `json:"path"`
ModifiedTS *string `json:"modified_ts"`
FoundTS string `json:"found_ts"`
GoneTS *string `json:"gone_ts"`
}
HomeView names where the item's file lives under a named root.
type ItemAnswer ¶
type ItemAnswer struct {
SchemaVersion int `json:"schema_version"`
Item ItemView `json:"item"`
Homes []HomeView `json:"homes"`
Sightings []SightingView `json:"sightings"`
Outputs []OutputView `json:"outputs"`
Decisions []DecisionView `json:"decisions"`
Deliveries []DeliveryView `json:"deliveries"`
// Sections are the item's sections, each producer version's in order.
Sections []SectionView `json:"sections"`
// Undelivered says why an item placed on a side and read as is reaches
// no deliverer, and is null where it does.
Undelivered *UndeliveredView `json:"undelivered"`
// Waiting says why the item waits at a model stage, and is null where it
// waits at none.
Waiting *WaitingView `json:"waiting"`
// Suggestion is the item's latest suggestion, and null where no model
// read holds a sentence.
Suggestion *SuggestionView `json:"suggestion"`
}
ItemAnswer is what GET /api/v1/items/{key} answers: schemas/item.schema.json.
type ItemListed ¶
type ItemListed struct {
Key string `json:"key"`
Zone store.Zone `json:"zone"`
MediaType string `json:"media_type"`
Title *string `json:"title"`
URL *string `json:"url"`
Connectors []string `json:"connectors"`
Phase string `json:"phase"`
WaitingAt *string `json:"waiting_at"`
Side *string `json:"side"`
CreatedTS string `json:"created_ts"`
}
ItemListed is one item as the list shows it.
type ItemView ¶
type ItemView struct {
Key string `json:"key"`
Zone store.Zone `json:"zone"`
MediaType string `json:"media_type"`
Title *string `json:"title"`
URL *string `json:"url"`
SourceTS *string `json:"source_ts"`
BlobSHA256 *string `json:"blob_sha256"`
SizeBytes *int64 `json:"size_bytes"`
MD5 *string `json:"md5"`
ParentKey *string `json:"parent_key"`
FlowID string `json:"flow_id"`
Phase string `json:"phase"`
WaitingAt *string `json:"waiting_at"`
CreatedTS string `json:"created_ts"`
}
ItemView is the item, with its bytes' size and MD5 and its derived phase.
type ItemsAnswer ¶
type ItemsAnswer struct {
SchemaVersion int `json:"schema_version"`
Items []ItemListed `json:"items"`
Next *string `json:"next"`
}
ItemsAnswer is what GET /api/v1/items answers: schemas/items-list.schema.json. Next is the cursor of the next page, and null where none is left.
type LeasedTask ¶
type LeasedTask struct {
ID string `json:"id"`
ItemKey *string `json:"item_key"`
Connector *string `json:"connector"`
Stage string `json:"stage"`
Capability string `json:"capability"`
Attempts int `json:"attempts"`
LeaseToken int64 `json:"lease_token"`
LeaseExpiresTS string `json:"lease_expires_ts"`
// MediaType and BlobSHA256 are the item's, so a worker reads its bytes
// holding no scope to read items. A poll carries neither, and BlobSHA256
// is null where the item holds no bytes.
MediaType string `json:"media_type"`
BlobSHA256 *string `json:"blob_sha256"`
// Zone, Title, URL and LandedTS are the item's too, so a deliverer writes
// it holding no scope to read items. A deliver task's Title, URL and
// SourceTS are its delivery's, as they were when it was first queued, so
// a retry sends what the first attempt sent. SourceTS is when the item
// was made at its source, and null where its source gave no time. Path
// is a deliver task's file below its deliverer's root, kept the same way,
// and absent for a deliverer that writes no file. A poll carries none of
// them.
Zone store.Zone `json:"zone,omitempty"`
Title *string `json:"title"`
URL *string `json:"url"`
LandedTS string `json:"landed_ts,omitempty"`
SourceTS *string `json:"source_ts,omitempty"`
Path *string `json:"path,omitempty"`
// Destination names where a deliver task writes its item, and is null
// for every other task.
Destination *string `json:"destination"`
// StageOutputs are the item's outputs at a model stage's task's stage,
// so a task whose run is already dispatched follows that run rather than
// starting another. Every other task carries none.
StageOutputs []StageOutput `json:"stage_outputs,omitempty"`
// Lens and Note are a model read's task's: the lens of the item's newest
// read decision, and the note that a person wrote, which the read
// answers. Every other task carries neither.
Lens *string `json:"lens,omitempty"`
Note *string `json:"note,omitempty"`
// Model is a measurement arm's task's. The task asks its run for this
// model in place of the worker's configured one. Every other task
// carries none.
Model *string `json:"model,omitempty"`
}
LeasedTask is one leased task, with the token for every heartbeat and report on it. A stage's task names its item. A poll names its connector, and its capability is poll:<source>, so each source's handler claims its own.
type OutputView ¶
type OutputView struct {
Stage string `json:"stage"`
Producer string `json:"producer"`
ProducerVersion string `json:"producer_version"`
Lens *string `json:"lens"`
LensVersion *string `json:"lens_version"`
NoteDigest *string `json:"note_digest"`
State string `json:"state"`
Units *int `json:"units"`
Findings []FindingView `json:"findings"`
RulesVersion *string `json:"rules_version"`
Answer json.RawMessage `json:"answer"`
RunID *string `json:"run_id"`
DispatchID *string `json:"dispatch_id"`
Model *string `json:"model"`
Effort *string `json:"effort"`
AnsweredModel *string `json:"answered_model"`
Tokens *store.Tokens `json:"tokens"`
Error *string `json:"error"`
}
OutputView is one stage's output, with a parse's units counted and each finding beside its span.
type ParseAnswer ¶
type ParseAnswer struct {
SchemaVersion int `json:"schema_version"`
Key string `json:"key"`
Zone store.Zone `json:"zone"`
Title *string `json:"title"`
URL *string `json:"url"`
MediaType string `json:"media_type"`
Extractor string `json:"extractor"`
ExtractorVersion string `json:"extractor_version"`
Text string `json:"text"`
Units []store.Unit `json:"units"`
RulesVersion *string `json:"rules_version"`
Findings []ParseFinding `json:"findings"`
}
ParseAnswer is what GET /api/v1/items/{key}/parse answers: schemas/item-parse.schema.json. Text is the units' text in order, joined by a blank line.
type ParseFinding ¶
ParseFinding is one finding of the newest scan of the parse, with the text it matched. Its offset counts bytes from its unit's start.
type PlaceRequest ¶
type PlaceRequest struct {
Destination string `json:"destination"`
Cause string `json:"cause,omitempty"`
Note *string `json:"note,omitempty"`
Login string `json:"login,omitempty"`
}
PlaceRequest places an item on Destination, one the set in force declares. Cause names the aspect that decided it, such as subreddit, channel, theme or title, and Note the questions and why the item was saved. A service placing for a person names the person's Login, since its token carries none.
type PlacementAnswer ¶
type PlacementAnswer struct {
SchemaVersion int `json:"schema_version"`
Key string `json:"key"`
Decisions []DecisionView `json:"decisions"`
}
PlacementAnswer is what a placement or a drop answers: schemas/review-placement.schema.json. Decisions are the side decision and, where it places the item on a side, the read decision after it.
type PushAnswer ¶
type PushAnswer struct {
SchemaVersion int `json:"schema_version"`
Items []PushedItem `json:"items"`
}
PushAnswer is what a push or a drop answers: schemas/push.schema.json.
type PushedItem ¶
type PushedItem struct {
Key string `json:"key"`
Zone store.Zone `json:"zone"`
// Created is false where the item was already landed, and this was one
// more sighting of it.
Created bool `json:"created"`
}
PushedItem is one item a push or a drop landed.
type Repeat ¶
type Repeat string
Repeat says what a second copy of a route's request does, so a client's retry and a handler's dedupe read one answer.
const ( // RepeatRead reads, so a second copy changes nothing. RepeatRead Repeat = "read" // RepeatKeyed writes once per Idempotency-Key. The client sets one key // per call and sends it on every retry of that call, and the router // refuses a request that carries none. RepeatKeyed Repeat = "keyed" // RepeatByContent writes what its body names, so a second copy of one // body leaves the state as the first copy left it. RepeatByContent Repeat = "byContent" // RepeatOnce may do its work twice when sent twice, so a client sends it // again only where the first copy never reached the server. RepeatOnce Repeat = "once" )
type ReplayAnswer ¶
type ReplayAnswer struct {
SchemaVersion int `json:"schema_version"`
Stage string `json:"stage"`
Connector *string `json:"connector"`
Key *string `json:"key"`
PlacedBy *string `json:"placed_by"`
Model *string `json:"model"`
Items int `json:"items"`
Queued bool `json:"queued"`
Estimate *store.Tokens `json:"estimate"`
}
ReplayAnswer is what POST /api/v1/replays answers: schemas/replay.schema.json.
type ReplayRequest ¶
type ReplayRequest struct {
Stage string `json:"stage"`
Connector *string `json:"connector"`
Key *string `json:"key"`
PlacedBy *string `json:"placed_by,omitempty"`
Model *string `json:"model,omitempty"`
Confirm bool `json:"confirm"`
}
ReplayRequest asks to run Stage again over the items that Connector and Key select, each absent selecting every item. PlacedBy store.PlacedByPerson narrows them to the labeled items. Model names the model that a measurement arm asks. Confirm runs a model stage once a person has read its estimate.
type Replayable ¶
type Replayable struct {
// Capability is the capability of the stage's task on item, and false
// where the stage does not run on item. A replay queues one task of that
// capability for each item it covers.
Capability func(item store.Item) (string, bool)
// Queue, where it is set, queues the stage's tasks for one item instead,
// and answers whether it queued any. A stage whose task names more than
// its item, such as a delivery's destination, sets it.
Queue store.ReplayQueue
// Estimate is how many of items a model stage would run on, and its
// tokens by kind over them. Where it is set, a replay answers the
// estimate and queues nothing until a request confirms it. A model-free
// stage leaves it nil, and queues at once.
// Its tokens are nil where it holds no stored run to estimate from.
Estimate func(ctx context.Context, items []store.Item) (int, *store.Tokens, error)
// PlacedByPerson, where it is set, is the stage run only over the
// labeled items, as a measurement of the stage against each placement. A
// request asks for it with placed_by person.
PlacedByPerson *Replayable
// OnModel, where it is set, is a measurement arm: the stage asked of the
// model that a request names. A request to such a stage names its model,
// and one to any other stage names none.
OnModel func(model string) Replayable
}
Replayable is one stage that a replay runs again.
type ReportDelivery ¶
type ReportDelivery struct {
Outcome string `json:"outcome"`
DestinationID *string `json:"destination_id,omitempty"`
Error *string `json:"error,omitempty"`
}
ReportDelivery is how one write of a deliver task's item ended: its outcome, the destination's id for the record that holds the item, and the destination's answer where the delivery is pending or refused.
type ReportOutput ¶
type ReportOutput struct {
Producer string `json:"producer"`
ProducerVersion string `json:"producer_version"`
Lens *string `json:"lens,omitempty"`
LensVersion *string `json:"lens_version,omitempty"`
// NoteDigest is store.NoteDigest of the note that a model read answered.
NoteDigest *string `json:"note_digest,omitempty"`
State string `json:"state"`
BlobSHA256 *string `json:"blob_sha256,omitempty"`
DispatchID *string `json:"dispatch_id,omitempty"`
RunID *string `json:"run_id,omitempty"`
Model *string `json:"model,omitempty"`
Effort *string `json:"effort,omitempty"`
AnsweredModel *string `json:"answered_model,omitempty"`
Tokens *store.Tokens `json:"tokens,omitempty"`
// InputProducer and InputVersion name the parse that a later stage read.
InputProducer *string `json:"input_producer,omitempty"`
InputVersion *string `json:"input_version,omitempty"`
// Findings and Spans are a scan's, and a model read's over its
// suggestion sentence. A scan that found nothing sends an empty list,
// which reads apart from a stage that sends none. RulesVersion is the
// version of the rules that made them.
Findings []store.Finding `json:"findings"`
RulesVersion *string `json:"rules_version,omitempty"`
Quality *int `json:"quality,omitempty"`
SideGuess *string `json:"side_guess,omitempty"`
SideConfidence *float64 `json:"side_confidence,omitempty"`
// Units are a parse's, numbered from 1 in order, which the service writes
// as rows of parse_units under the producer and its version.
Units []store.Unit `json:"units,omitempty"`
Spans []store.Span `json:"spans"`
Answer json.RawMessage `json:"answer,omitempty"`
Error *string `json:"error,omitempty"`
}
ReportOutput is one output a worker reports: each field of an outputs row that the stage's work decides, and a parse's units. The service takes the item and stage from the task and stamps the row, so a column the store adds for itself never changes what a worker sends.
type ReportRequest ¶
type ReportRequest struct {
Token int64 `json:"token"`
Outcome string `json:"outcome"`
Error *string `json:"error,omitempty"`
RetryAfterSeconds int `json:"retry_after_seconds,omitempty"`
Outputs []ReportOutput `json:"outputs,omitempty"`
Delivery *ReportDelivery `json:"delivery,omitempty"`
}
ReportRequest ends a lease. Outputs are the stage's records for the task's item, and Delivery is how a deliver task's write ended, each written in the same transaction that ends the lease.
type ReviewAnswer ¶
type ReviewAnswer struct {
SchemaVersion int `json:"schema_version"`
Items []ReviewItem `json:"items"`
Destinations []ReviewDestination `json:"destinations"`
}
ReviewAnswer is what GET /api/v1/review answers: schemas/review-list.schema.json. Destinations are those a placement takes, in the order the set in force declares them, and nil where the set in force could not be read.
type ReviewDestination ¶
ReviewDestination is a declared destination and the side it gives an item. Side is null where the destination drops what it takes.
type ReviewGuess ¶
ReviewGuess is the quality gate's side guess on an item.
type ReviewItem ¶
type ReviewItem struct {
Key string `json:"key"`
Zone store.Zone `json:"zone"`
Title *string `json:"title"`
URL *string `json:"url"`
// Reason is why the item waits, as schemas/review-list.schema.json
// enumerates it.
Reason string `json:"reason"`
Guess *ReviewGuess `json:"guess"`
// QualityAnswer is the quality gate's newest done answer as the store
// keeps it, and null where the gate gave none.
QualityAnswer json.RawMessage `json:"quality_answer"`
Connectors []string `json:"connectors"`
Sightings []ReviewSighting `json:"sightings"`
WaitingSinceTS string `json:"waiting_since_ts"`
}
ReviewItem is one item that waits on a person's placement, and why.
type ReviewSighting ¶
type ReviewSighting struct {
Connector string `json:"connector"`
Tags []string `json:"tags"`
Fields map[string]string `json:"fields"`
}
ReviewSighting is one connector's arrival of a waiting item: the tags the side gate read and the source's fields, such as a Reddit save's subreddit.
type Route ¶
Route is one row of the API's route table: its pattern as ServeMux reads it ("POST /api/v1/x"), the scope a service's token needs, and what a repeat does. An empty scope admits a person's token alone.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is where a package registers a handler for each of its rows in the route table.
type Routes ¶
type Routes func(*Router)
Routes registers one package's routes.
func BlobRoutes ¶
BlobRoutes are the routes for a worker to read and write bytes through, and the report for a person of where the volume and the blob rows disagree.
func ConnectorRoutes ¶
func ConnectorRoutes(cfg ConnectorConfig) Routes
ConnectorRoutes are the routes for a person to apply the declarations, read and run each connector, release a first fill, and drop a file.
func ItemRoutes ¶
ItemRoutes are the routes for a person or a service holding ingestion.items.read to read items. A key in the path is one escaped segment, such as reddit%2Ft3_aq7ggd, and a URL there resolves to its key. The parse route answers the item's newest done parse, or the newest of the extractor and at the version that its query names.
func ReplayRoutes ¶
ReplayRoutes is the route for a person to run one of stages again over landed items. It is keyed: a request carries an Idempotency-Key, and a repeat under the same key answers the replay that the first one queued.
func ReviewRoutes ¶
ReviewRoutes are the routes for a person, or a service acting for one, to read the review queue and place or drop an item. A placement or a drop sent again with the same body appends nothing.
func TaskRoutes ¶
TaskRoutes are the routes for a worker to lease tasks through and read a task's input, and the list for a person to read. after runs in the write that ends each item's task done, and nil runs nothing.
type RunAnswer ¶
type RunAnswer struct {
SchemaVersion int `json:"schema_version"`
Connector string `json:"connector"`
Mode string `json:"mode"`
TaskID *string `json:"task_id"`
DueAt string `json:"due_at"`
}
RunAnswer is what POST /api/v1/connectors/{name}/runs answers: schemas/connector-run.schema.json. A poll answers its task, and a folder the due time that the scheduler scans it at.
type SectionView ¶ added in v0.20.0
type SectionView struct {
Producer string `json:"producer"`
ProducerVersion string `json:"producer_version"`
N int `json:"n"`
ParentN *int `json:"parent_n"`
Level int `json:"level"`
Kind string `json:"kind"`
Title *string `json:"title"`
PDFPageStart int `json:"pdf_page_start"`
PDFPageEnd int `json:"pdf_page_end"`
PrintedPageStart *string `json:"printed_page_start"`
PrintedPageEnd *string `json:"printed_page_end"`
StartPlacedBy string `json:"start_placed_by"`
ChildKey *string `json:"child_key"`
}
SectionView is one entry of an item's sections, as the sections table holds it.
type SightingView ¶
type SightingView struct {
Connector string `json:"connector"`
ExternalKey string `json:"external_key"`
Tags []string `json:"tags"`
Fields map[string]string `json:"fields"`
Zone store.Zone `json:"zone"`
CursorPosition *string `json:"cursor_position"`
FirstSeenTS string `json:"first_seen_ts"`
LastSeenTS string `json:"last_seen_ts"`
}
SightingView is one connector's arrival of the item.
type StageOutput ¶
type StageOutput struct {
Producer string `json:"producer"`
ProducerVersion string `json:"producer_version"`
NoteDigest *string `json:"note_digest"`
State string `json:"state"`
DispatchID *string `json:"dispatch_id"`
Model *string `json:"model"`
Effort *string `json:"effort"`
Error *string `json:"error"`
}
StageOutput is one output that a model stage's task carries: which prompt wrote it, how far it got, and the dispatch it waits on. Error is why a waiting one has not started, or why a failed one failed.
type SuggestionFindingView ¶
type SuggestionFindingView struct {
Rule string `json:"rule"`
Severity string `json:"severity"`
In string `json:"in"`
Span *string `json:"span"`
}
SuggestionFindingView is one scanner finding beside a suggestion, in its source or in its sentence.
type SuggestionView ¶
type SuggestionView struct {
SchemaVersion int `json:"schema_version"`
ItemKey string `json:"item_key"`
Sentence string `json:"sentence"`
Title *string `json:"title"`
URL *string `json:"url"`
Zone store.Zone `json:"zone"`
Findings []SuggestionFindingView `json:"findings"`
PromptVersion string `json:"prompt_version"`
// Lens names the read's lens and its version, as "fleet 1-9dcd3940".
Lens *string `json:"lens"`
SuggestedTS string `json:"suggested_ts"`
}
SuggestionView is an item's latest suggestion, as schemas/suggestion.schema.json publishes it: its newest done model read whose answer holds a sentence, with the scanner's findings first.
type TaskParseAnswer ¶
type TaskParseAnswer struct {
SchemaVersion int `json:"schema_version"`
Key string `json:"key"`
Extractor string `json:"extractor"`
ExtractorVersion string `json:"extractor_version"`
Units []store.Unit `json:"units"`
}
TaskParseAnswer is what GET /api/v1/tasks/{id}/parse answers: schemas/task-parse.schema.json. It carries the units alone, because the parse's whole text is the units joined.
type TaskRetryAnswer ¶
type TaskRetryAnswer struct {
SchemaVersion int `json:"schema_version"`
Task TaskView `json:"task"`
}
TaskRetryAnswer is what POST /api/v1/tasks/{id}/retries answers: schemas/task-retry.schema.json.
type TaskView ¶
type TaskView struct {
ID string `json:"id"`
ItemKey *string `json:"item_key"`
Connector *string `json:"connector"`
Destination *string `json:"destination"`
Model *string `json:"model"`
Stage string `json:"stage"`
Capability string `json:"capability"`
State string `json:"state"`
HeldBy *string `json:"held_by"`
Lapsed bool `json:"lapsed"`
LeaseHolder *string `json:"lease_holder"`
LeaseExpiresTS *string `json:"lease_expires_ts"`
Attempts int `json:"attempts"`
HasError bool `json:"has_error"`
NotBeforeTS *string `json:"not_before_ts"`
CreatedTS string `json:"created_ts"`
UpdatedTS string `json:"updated_ts"`
}
TaskView is one task as the list shows it. It leaves out the lease token and the task's error, which can quote outsider text, and says in has_error whether one is kept.
type TasksAnswer ¶
type TasksAnswer struct {
Tasks []TaskView `json:"tasks"`
Workers []store.Worker `json:"workers"`
// WorkersHidden counts the workers not heard from within
// WorkersHeardWithin, which the list leaves out unless asked for all.
WorkersHidden int `json:"workers_hidden"`
}
TasksAnswer is what GET /api/v1/tasks answers: schemas/tasks-list.schema.json.
type TokenGate ¶
type TokenGate interface {
goapiauth.TokenVerifier
Ready() error
}
TokenGate verifies a bearer token, and says why it cannot yet.
type UndeliveredView ¶
type UndeliveredView struct {
Reason string `json:"reason"`
Side string `json:"side"`
Destination *string `json:"destination"`
Message string `json:"message"`
}
UndeliveredView is why an item reaches no deliverer, in the words of connectors.Undelivered.
type UnpairedAnswer ¶
type UnpairedAnswer struct {
SchemaVersion int `json:"schema_version"`
Files int `json:"files"`
Rows int `json:"rows"`
Unrowed []UnpairedFile `json:"unrowed"`
Missing []BlobAnswer `json:"missing"`
Leftovers []UnpairedFile `json:"leftovers"`
}
UnpairedAnswer is what GET /api/v1/blobs/unpaired answers: schemas/blobs-unpaired.schema.json.
type UnpairedFile ¶
type UnpairedFile struct {
SHA256 *string `json:"sha256"`
Path *string `json:"path"`
SizeBytes int64 `json:"size_bytes"`
ModifiedTS string `json:"modified_ts"`
}
UnpairedFile is one file in the volume that no row pairs with.
type WaitingView ¶
type WaitingView struct {
Stage string `json:"stage"`
Reason string `json:"reason"`
Capability string `json:"capability"`
// HeldBy is the connector whose first fill holds the task.
HeldBy *string `json:"held_by"`
// DispatchID is the run's dispatch, where the port started one.
DispatchID *string `json:"dispatch_id"`
// LastError is why the task's last try did not go through, such as a
// dispatch service that did not answer, where it ended so.
LastError *string `json:"last_error"`
Message string `json:"message"`
}
WaitingView is why an item waits at a model stage.