pub struct Store { /* private fields */ }Expand description
The job history. Cloning shares it.
Implementations§
Source§impl Store
impl Store
Sourcepub fn open(path: &Path) -> Result<Store, StoreError>
pub fn open(path: &Path) -> Result<Store, StoreError>
Opens the database at path, creating it and its directory (mode 0700) if missing, with the schema when it
is new, and brings it to the schema this build reads. Refuses a database from before 0.0.19 or from a newer
runnerd. The time since the history’s last sign of life is taken as time no runnerd ran: the jobs queued in
it leave it out of their waits.
Sourcepub fn queued(&self, repository: &str, job: &QueuedJob, seen_at: u64)
pub fn queued(&self, repository: &str, job: &QueuedJob, seen_at: u64)
Records a queued job the repository’s runners may run, which a listing answered at seen_at (ms) showed;
announces it the first time, and keeps the first listing’s time. A job a runner claimed first keeps its state
and gets seen_at if no listing showed it before and this one answered before it started.
Sourcepub fn runner_started(&self, runner: RunnerRecord)
pub fn runner_started(&self, runner: RunnerRecord)
Records a runner container that started, or one an earlier daemon started and this one adopted.
Sourcepub fn runner_removed(&self, runner: &str, at: u64)
pub fn runner_removed(&self, runner: &str, at: u64)
Records that a runner’s container and registration were removed at at (ms).
Sourcepub fn runners_gone(&self, running: Vec<String>, at: u64)
pub fn runners_gone(&self, running: Vec<String>, at: u64)
Records every runner the history holds open, except the running ones, removed at at (ms): what recovery
found gone, so it stops counting as holding a slot.
Sourcepub fn claimed(&self, job: u64, run_id: u64, runner: &str, at: u64)
pub fn claimed(&self, job: u64, run_id: u64, runner: &str, at: u64)
Records that a runner took a job at at (ms).
Sourcepub fn details(&self, details: JobDetails)
pub fn details(&self, details: JobDetails)
Records a running job’s progress and steps as GitHub reports them; announces changed steps.
Sourcepub fn workflow_named(&self, named: NamedRun)
pub fn workflow_named(&self, named: NamedRun)
Names the workflow of a run’s jobs, which were recorded under GitHub’s name for the run because the workflow’s could not be read then (ADR 0140).
Sourcepub fn elsewhere(&self, details: JobDetails)
pub fn elsewhere(&self, details: JobDetails)
Closes a queued job that left the queue without a runner of this daemon: another machine’s runner took it, or none did and it has no start.
Sourcepub fn unanswered(&self, job: u64, at: u64)
pub fn unanswered(&self, job: u64, at: u64)
Closes a queued job that left the queue and that GitHub no longer answers for, at at: none of this daemon’s
runners took it, so it reads as run elsewhere, with no conclusion.
Sourcepub fn lost(&self, job: u64, at: u64)
pub fn lost(&self, job: u64, at: u64)
Closes a job whose container is gone and that GitHub did not report completed in time.
Sourcepub async fn log(
&self,
job: u64,
lines: Vec<String>,
position: LogPosition,
max_bytes: u64,
)
pub async fn log( &self, job: u64, lines: Vec<String>, position: LogPosition, max_bytes: u64, )
Appends log lines to a job, up to max_bytes per job, and records where the capture continues. Waits while
LOG_BACKLOG bytes of lines are waiting to be stored; a larger batch goes in parts, each waiting its turn.
Sourcepub fn samples(&self, samples: Vec<SampleRecord>)
pub fn samples(&self, samples: Vec<SampleRecord>)
Records samples of runner containers.
Sourcepub fn host_sample(&self, sample: HostSample)
pub fn host_sample(&self, sample: HostSample)
Records a sample of the slice and sends it to every subscriber at once; it is stored with the next ones, a
minute’s worth in one transaction, or at flush.
Sourcepub fn latest_sample(&self, runner: &str) -> Option<SampleRecord>
pub fn latest_sample(&self, runner: &str) -> Option<SampleRecord>
A runner’s last sample, stored or not; None before its first sample or once it is removed.
Sourcepub fn containers_gone(&self, runners: Vec<String>)
pub fn containers_gone(&self, runners: Vec<String>)
Notes that the cgroups of these runners’ containers are gone (metrics::Sampled::gone), for admission to read
until they are removed. Kept in memory only: a restart finds such a container stopped.
Sourcepub fn containers_ended(&self, runners: Vec<String>, at: u64)
pub fn containers_ended(&self, runners: Vec<String>, at: u64)
Records that these runners’ containers’ cgroups were gone at at (ms), one sample after they were last read
(metrics::Sampled::ended): what they wrote is measured to their end (ADR 0143). A job already closed gets
its figure again.
Sourcepub fn disk_window(&self, window: Window)
pub fn disk_window(&self, window: Window)
Records a window of what the disks under Docker’s root wrote.
Sourcepub fn containers_read(&self, runners: &[String])
pub fn containers_read(&self, runners: &[String])
Notes that these runners’ containers’ cgroups were read (metrics::Sampled::read): one marked gone came back,
as a docker restart brings it, and holds memory again.
Sourcepub fn container_gone(&self, runner: &str) -> bool
pub fn container_gone(&self, runner: &str) -> bool
Whether a runner’s container’s cgroup is gone, though its slot may hold it a while yet.
Sourcepub fn runner_admission(&self, runner: &str, admission: Admission)
pub fn runner_admission(&self, runner: &str, admission: Admission)
Records what a runner reserves now, when measured admission changed it after the start.
Sourcepub fn runner_oom_killed(&self, runner: &str)
pub fn runner_oom_killed(&self, runner: &str)
Records that Docker saw the kernel kill a process in a runner’s container for memory, which its samples may have missed: one in the last interval before the container stopped.
Sourcepub fn runner_probe(&self, runner: &str, probe: RunnerProbe)
pub fn runner_probe(&self, runner: &str, probe: RunnerProbe)
Records what the probe after a runner exited found (ADR 0155), as its stopped container says.
Sourcepub fn runner_cancel_by(&self, runner: &str, at: u64)
pub fn runner_cancel_by(&self, runner: &str, at: u64)
Records when a forced pause that cancelled a runner’s run removes it if it still runs, in ms since the epoch, so a restart keeps that deadline.
Sourcepub fn runner_stopped_for(&self, runner: &str, reason: &'static str)
pub fn runner_stopped_for(&self, runner: &str, reason: &'static str)
Records why an idle runner was removed, as scheduler::StopReason::as_str names it.
Sourcepub fn build_cache(&self, runner: &str, counts: BuildCacheCounts)
pub fn build_cache(&self, runner: &str, counts: BuildCacheCounts)
Adds what the shared build cache served a runner and took from it, and records whether its job could write.
Sourcepub fn host_memory(&self, memory: HostMemory)
pub fn host_memory(&self, memory: HostMemory)
Keeps the latest reading of the host’s memory for admission and the status; it is not stored.
Sourcepub fn latest_host_memory(&self) -> Option<HostMemory>
pub fn latest_host_memory(&self) -> Option<HostMemory>
The latest reading of the host’s memory; None before the first.
Sourcepub fn host_waiting(&self, jobs: BTreeSet<u64>, at: u64)
pub fn host_waiting(&self, jobs: BTreeSet<u64>, at: u64)
Keeps which jobs the plan at at (ms) had waiting for memory the host lacks (ADR 0103), for insights to read
with the reading; it is not stored. A plan that finds none replaces the last one’s.
Sourcepub fn host_waited(&self, jobs: Vec<u64>, ms: u64)
pub fn host_waited(&self, jobs: Vec<u64>, ms: u64)
Adds ms to how long each of jobs waited because the host’s memory could not take its runner, which
sizing does not read as a wait for a slot.
Sourcepub fn slot_waited(&self, jobs: Vec<u64>, ms: u64)
pub fn slot_waited(&self, jobs: Vec<u64>, ms: u64)
Adds ms to how long each of jobs waited with no slot of its profile free while the budgets had room for
its runner: what auto sizing reads as a wait for a slot (ADR 0090).
Sourcepub fn causes_waited(&self, waits: Vec<CauseWait>)
pub fn causes_waited(&self, waits: Vec<CauseWait>)
Adds what each wait in waits lasted to its job’s time for its cause (ADR 0154), all in one transaction and
with one write of each job’s row. A job whose row is from before schema 26 keeps counting none, so it never
reads as a wait of 0.
Sourcepub fn reran(&self, jobs: Vec<u64>, at: u64)
pub fn reran(&self, jobs: Vec<u64>, at: u64)
Notes that runnerd asked GitHub to re-run the failed jobs of the run jobs are of because their runner failed
them, and GitHub accepted, at at ms (ADR 0153). A job noted already keeps its first time.
Sourcepub async fn claim_rerun(
&self,
repository: &str,
run: u64,
attempt: u32,
at: u64,
) -> Claim
pub async fn claim_rerun( &self, repository: &str, run: u64, attempt: u32, at: u64, ) -> Claim
Claims the automatic re-run of repository’s run run from attempt attempt, at at ms, before runnerd sends
it (ADR 0153), synced to disk: a restart reads no fault of a claimed attempt back, and a second claim of it is
Claim::Taken. A claim outlives the history’s mark, which only a re-run GitHub accepted writes. Claims a day
older than at go with it: no fault that old is read back.
Sourcepub fn release_rerun(&self, repository: &str, run: u64, attempt: u32)
pub fn release_rerun(&self, repository: &str, run: u64, attempt: u32)
Releases the claim Store::claim_rerun made, once nothing of the re-run reached GitHub: the permit stopped
it, or GitHub refused it. A release lost to a crash leaves the attempt claimed, never sent.
Sourcepub fn latest_host_sample(&self) -> Option<HostSample>
pub fn latest_host_sample(&self) -> Option<HostSample>
The last host sample sent, stored or not; None before the first.
Sourcepub async fn mirror_bytes(
&self,
bytes: Vec<(String, u64)>,
until: MirrorPosition,
) -> bool
pub async fn mirror_bytes( &self, bytes: Vec<(String, u64)>, until: MirrorPosition, ) -> bool
Adds bytes the mirror served to runners, counted from its log up to until, and says whether that was
stored: if not, the caller counts the same lines again.
Sourcepub fn cache_sizes(&self, at: u64, sizes: BTreeMap<String, u64>)
pub fn cache_sizes(&self, at: u64, sizes: BTreeMap<String, u64>)
Records volume sizes in bytes, by name, measured at at (ms).
Sourcepub fn event(&self, event: Event)
pub fn event(&self, event: Event)
Stores a durable event, or sends a live one, to every subscriber.
Sourcepub fn record_made(&self, record: Record)
pub fn record_made(&self, record: Record)
Records that a failed job’s runner was kept as record, and announces it.
Sourcepub fn record_skipped(&self, job: u64, why: String)
pub fn record_skipped(&self, job: u64, why: String)
Records why a failed job’s runner was not kept.
Sourcepub fn record_removed(&self, job: u64, at: u64, by: RecordRemoval)
pub fn record_removed(&self, job: u64, at: u64, by: RecordRemoval)
Records that a job’s record was removed at at (ms), and why, and announces it.
Sourcepub fn records_listed(&self, jobs: Vec<u64>, at: u64)
pub fn records_listed(&self, jobs: Vec<u64>, at: u64)
Records that Docker listed the records of jobs, and no others, at at (ms): a record the history notes as
kept whose job is not among them was removed outside runnerd, and is noted gone and announced as
record.gone. Only an inventory Docker answered is sent; one it did not changes nothing.
Sourcepub fn paused(
&self,
repositories: Vec<String>,
) -> impl Future<Output = bool> + use<>
pub fn paused( &self, repositories: Vec<String>, ) -> impl Future<Output = bool> + use<>
Records the paused repositories, all of them, in place of the ones recorded before. The write is sent at once, in order with every other; the future says whether it committed.
Sourcepub async fn runner_named(&self, secs: u64) -> bool
pub async fn runner_named(&self, secs: u64) -> bool
Records that this machine named a runner for secs, the second its name ends in, before GitHub or Docker
knows the name: a restart names the next runner later even when nothing else recorded this one. Says whether
it committed.
Sourcepub fn visibility(&self, repository: String, visibility: Visibility, at: u64)
pub fn visibility(&self, repository: String, visibility: Visibility, at: u64)
Records a repository’s visibility as GitHub gave it at at (ms), in place of the one recorded before.
Sourcepub fn sizing_intent(
&self,
change: SizingChange,
) -> impl Future<Output = Option<i64>> + use<>
pub fn sizing_intent( &self, change: SizingChange, ) -> impl Future<Output = Option<i64>> + use<>
Records a change auto sizing is about to write, as pending, before the file is, synced to disk. The future
has its row once it committed, None if it did not: then nothing may be written.
Sourcepub fn sizing_resolved(
&self,
id: i64,
resolution: Resolution,
) -> impl Future<Output = bool> + use<>
pub fn sizing_resolved( &self, id: i64, resolution: Resolution, ) -> impl Future<Output = bool> + use<>
Records what became of a pending change, synced to disk; a done one is announced as sizing.changed in the
same transaction. The future says whether it committed.
Sourcepub fn notify_record(
&self,
target: &str,
set: Vec<(String, u64)>,
remove: Vec<String>,
) -> impl Future<Output = bool> + use<>
pub fn notify_record( &self, target: &str, set: Vec<(String, u64)>, remove: Vec<String>, ) -> impl Future<Output = bool> + use<>
Records what the notifier delivered to a target: sets set’s keys and removes remove’s, in one
transaction. The future says whether it committed.
Sourcepub fn notify_keep(
&self,
targets: Vec<String>,
) -> impl Future<Output = bool> + use<>
pub fn notify_keep( &self, targets: Vec<String>, ) -> impl Future<Output = bool> + use<>
Forgets what the notifier kept for every target but targets. The future says whether it committed.
Sourcepub fn prune(&self, now: u64, history: &History) -> JoinHandle<()> ⓘ
pub fn prune(&self, now: u64, history: &History) -> JoinHandle<()> ⓘ
Deletes what is older than history keeps, at now (ms), off the writer, in batches the writer’s
transactions fit between. A prune while the last one runs does nothing. The handle finishes with it; dropping
it lets it run.
Sourcepub fn close(&self)
pub fn close(&self)
Stops a running prune after its batch, and any later one before it starts, so a shutdown does not wait for one. What a stopped prune left, the next daemon’s deletes. Writes go on as before.
Sourcepub fn subscribe(&self) -> Receiver<Arc<EventEnvelope>>
pub fn subscribe(&self) -> Receiver<Arc<EventEnvelope>>
Every event from now on, durable or live. Subscribe before reading what was stored, then skip what the read returned, and nothing is missed or sent twice.
Sourcepub async fn jobs(&self, query: JobQuery) -> Result<JobList, StoreError>
pub async fn jobs(&self, query: JobQuery) -> Result<JobList, StoreError>
One page of jobs as query asks, which api::JobQuery::check passed (ADR 0135).
Sourcepub async fn timeline(&self, window: Span) -> Result<SlotTimeline, StoreError>
pub async fn timeline(&self, window: Span) -> Result<SlotTimeline, StoreError>
What each slot ran over window (ADR 0135), with the host samples not yet stored counted as watched time.
Sourcepub async fn compare(
&self,
id: u64,
with: Option<u64>,
) -> Result<Option<JobComparison>, StoreError>
pub async fn compare( &self, id: u64, with: Option<u64>, ) -> Result<Option<JobComparison>, StoreError>
Job id beside the job with names, or its baseline (ADR 0135); None without either job.
Sourcepub async fn runner_faults(
&self,
since: u64,
) -> Result<Vec<RunnerFault>, StoreError>
pub async fn runner_faults( &self, since: u64, ) -> Result<Vec<RunnerFault>, StoreError>
The jobs their runner failed (runner_fault) whose records became final at or after since ms and whose
attempt runnerd has neither re-run nor claimed, oldest first: what a restarted daemon may still re-run (ADR 0153).
Sourcepub async fn run_jobs(
&self,
repository: &str,
run: u64,
except: u64,
limit: usize,
) -> Result<RunJobs, StoreError>
pub async fn run_jobs( &self, repository: &str, run: u64, except: u64, limit: usize, ) -> Result<RunJobs, StoreError>
Up to limit other jobs of repository’s run run than except, newest attempt first (ADR 0134).
Sourcepub async fn job_samples(
&self,
id: u64,
interval: Duration,
) -> Result<Option<SampleSeries>, StoreError>
pub async fn job_samples( &self, id: u64, interval: Duration, ) -> Result<Option<SampleSeries>, StoreError>
A job’s samples, oldest first; None if there is no such job.
Sourcepub async fn log_lines(
&self,
job: u64,
from: u64,
limit: u64,
) -> Result<Vec<(u64, String)>, StoreError>
pub async fn log_lines( &self, job: u64, from: u64, limit: u64, ) -> Result<Vec<(u64, String)>, StoreError>
Up to limit log lines of a job from line from, with their numbers.
Sourcepub async fn log_outline(
&self,
job: u64,
) -> Result<Option<LogOutline>, StoreError>
pub async fn log_outline( &self, job: u64, ) -> Result<Option<LogOutline>, StoreError>
A job’s log as structure (ADR 0133); None without the job.
Sourcepub async fn styled_lines(
&self,
job: u64,
from: u64,
limit: u64,
) -> Result<Vec<StyledLine>, StoreError>
pub async fn styled_lines( &self, job: u64, from: u64, limit: u64, ) -> Result<Vec<StyledLine>, StoreError>
Up to limit styled lines of a job’s log from line from, fewer once they hold 4 MiB of text; each shows at most
api::LINE_BYTES_MAX bytes of its line.
Sourcepub async fn search_log(
&self,
job: u64,
search: Search,
) -> Result<LogSearch, StoreError>
pub async fn search_log( &self, job: u64, search: Search, ) -> Result<LogSearch, StoreError>
One page of a search of a job’s log, each batch of lines its own read, so the search never holds the reader for a whole log.
Sourcepub async fn events_after(
&self,
after: u64,
limit: u64,
) -> Result<Vec<EventEnvelope>, StoreError>
pub async fn events_after( &self, after: u64, limit: u64, ) -> Result<Vec<EventEnvelope>, StoreError>
Up to limit durable events after after, oldest first.
Sourcepub async fn sizing_changes(
&self,
since: u64,
) -> Result<Vec<SizingChange>, StoreError>
pub async fn sizing_changes( &self, since: u64, ) -> Result<Vec<SizingChange>, StoreError>
The changes auto sizing wrote since since (ms), oldest first.
Sourcepub async fn auto_sizing(&self) -> Result<AutoSizing, StoreError>
pub async fn auto_sizing(&self) -> Result<AutoSizing, StoreError>
When each profile last changed, and the changes still pending.
Sourcepub fn announced(&self) -> Result<Announced, StoreError>
pub fn announced(&self) -> Result<Announced, StoreError>
The profiles and repositories as the stored events last announced them, so a restarted daemon announces only what changed since, including what its config no longer has. Blocks on the database: for startup.
Sourcepub fn paused_repositories(&self) -> Result<Vec<String>, StoreError>
pub fn paused_repositories(&self) -> Result<Vec<String>, StoreError>
The repositories recorded paused, for the engine to start with. Blocks on the database: for startup.
Sourcepub async fn host_samples(
&self,
since: u64,
) -> Result<Vec<HostSample>, StoreError>
pub async fn host_samples( &self, since: u64, ) -> Result<Vec<HostSample>, StoreError>
The slice’s samples since since (seconds), oldest first, the ones not yet stored included.
Sourcepub async fn activity(
&self,
since: u64,
now: u64,
) -> Result<Activity, StoreError>
pub async fn activity( &self, since: u64, now: u64, ) -> Result<Activity, StoreError>
The jobs runnerd’s runners started and finished from since until now (seconds).
Sourcepub async fn stats(
&self,
query: StatsQuery,
now: u64,
) -> Result<Stats, StoreError>
pub async fn stats( &self, query: StatsQuery, now: u64, ) -> Result<Stats, StoreError>
Finished jobs per repository and bucket.
Sourcepub async fn sizing(&self, since: u64) -> Result<History, StoreError>
pub async fn sizing(&self, since: u64) -> Result<History, StoreError>
What sizing reads: the finished jobs queued at or after since (ms) and the runners since.
Sourcepub async fn pricing(&self, since: u64) -> Result<PricingHistory, StoreError>
pub async fn pricing(&self, since: u64) -> Result<PricingHistory, StoreError>
What pricing at GitHub’s rates reads: the completed and lost jobs dated at or after since (ms), each
repository’s visibility and since when the history holds every final job.
Sourcepub async fn insights(&self, since: u64) -> Result<History, StoreError>
pub async fn insights(&self, since: u64) -> Result<History, StoreError>
The jobs completed or lost that were queued at or after since (ms), as insights read them, from when the
history holds every job, and the queued jobs the last plan had waiting for the host’s memory.
Sourcepub async fn last_event(&self) -> Result<u64, StoreError>
pub async fn last_event(&self) -> Result<u64, StoreError>
The newest durable event’s ID; 0 before the first.
Sourcepub async fn notify_state(
&self,
) -> Result<BTreeMap<String, BTreeMap<String, u64>>, StoreError>
pub async fn notify_state( &self, ) -> Result<BTreeMap<String, BTreeMap<String, u64>>, StoreError>
What the notifier kept for each target, by target, then key.
Sourcepub async fn warm(&self, since: u64) -> Result<Vec<Seen>, StoreError>
pub async fn warm(&self, since: u64) -> Result<Vec<Seen>, StoreError>
The jobs queued at or after since (ms), whatever became of them, as warm runners learn from them.
Sourcepub async fn cache_sizes_now(&self) -> Result<Measured, StoreError>
pub async fn cache_sizes_now(&self) -> Result<Measured, StoreError>
The last measurement of every volume, with its time (seconds), by name.
Sourcepub async fn build_cache_since(
&self,
since: u64,
) -> Result<BuildCacheCounts, StoreError>
pub async fn build_cache_since( &self, since: u64, ) -> Result<BuildCacheCounts, StoreError>
What the build cache served and took from the runners started since since (ms), summed.
Sourcepub async fn cache_history(
&self,
since: u64,
) -> Result<Vec<CacheSize>, StoreError>
pub async fn cache_history( &self, since: u64, ) -> Result<Vec<CacheSize>, StoreError>
Every volume measurement since since (seconds).
Sourcepub async fn open_jobs(&self) -> Result<Vec<OpenJob>, StoreError>
pub async fn open_jobs(&self) -> Result<Vec<OpenJob>, StoreError>
The jobs not yet closed, for the engine after a restart.
Sourcepub async fn slot_jobs(&self) -> Result<Vec<SlotJob>, StoreError>
pub async fn slot_jobs(&self) -> Result<Vec<SlotJob>, StoreError>
The newest named job each slot ran, for the engine after a restart.
Sourcepub async fn last_runner_second(
&self,
prefix: String,
) -> Result<Option<u64>, StoreError>
pub async fn last_runner_second( &self, prefix: String, ) -> Result<Option<u64>, StoreError>
The latest second a runner was named for (runner_named), or any runner name starting with prefix carries,
of a runner or of a job’s runner: the engine names runners later after a restart, so no name it used before
is used twice.
Sourcepub async fn runner_job(&self, runner: &str) -> Result<Option<u64>, StoreError>
pub async fn runner_job(&self, runner: &str) -> Result<Option<u64>, StoreError>
The job a runner took, if the history knows it.
Sourcepub async fn runner_admitted(
&self,
runner: &str,
) -> Result<Option<Admission>, StoreError>
pub async fn runner_admitted( &self, runner: &str, ) -> Result<Option<Admission>, StoreError>
How a runner was admitted, with what it reserves since, if the history knows it.
Sourcepub async fn runner_cancel_deadline(
&self,
runner: &str,
) -> Result<Option<u64>, StoreError>
pub async fn runner_cancel_deadline( &self, runner: &str, ) -> Result<Option<u64>, StoreError>
When a forced pause that cancelled a runner’s run removes it if it still runs, in ms since the epoch, if one did.
Sourcepub async fn runner_memory_cap(
&self,
runner: &str,
) -> Result<Option<u64>, StoreError>
pub async fn runner_memory_cap( &self, runner: &str, ) -> Result<Option<u64>, StoreError>
The memory cap a runner started with, as its record kept it, for when Docker cannot tell.
Sourcepub async fn log_position(&self, job: u64) -> Result<LogPosition, StoreError>
pub async fn log_position(&self, job: u64) -> Result<LogPosition, StoreError>
Where a job’s log capture continues.
Sourcepub async fn mirror_log_until(&self) -> Result<MirrorPosition, StoreError>
pub async fn mirror_log_until(&self) -> Result<MirrorPosition, StoreError>
How far the mirror’s log was counted.