Expand description
libbarto is the shared library for the barto
distributed job scheduling system. It is consumed by all three barto components:
bartos— central WebSocket server; owns schedule definitions and persists all results toMariaDBbartoc— remote worker client; executes scheduled commands and streams output back tobartosbarto-cli— command-line interface for querying and managing a runningbartosinstance
§Key Types
| Type | Description |
|---|---|
Realtime | Parse and evaluate cron-like schedule expressions |
Data | Output or status payload streamed from bartoc to bartos |
BartosToBartoc | Schedule initialization message sent from bartos to bartoc |
BartoCli | Command messages sent from barto-cli to bartos |
load | Load a component’s TOML configuration with env-var overrides |
init_tracing | Initialize file and stdout tracing layers |
§Realtime Scheduling
Realtime parses systemd-inspired calendar expressions and evaluates whether a given
time::OffsetDateTime matches the schedule:
use std::str::FromStr;
use libbarto::Realtime;
// Built-in shortcuts
let daily = Realtime::from_str("daily").unwrap();
// Full syntax: "[DOW] YEAR,MONTH,DAY HH:MM:SS"
// '*' matches any value; 'R' picks a random value within the valid range
let schedule = Realtime::from_str("Mon *,*,01 00:00:00").unwrap();
let now = time::OffsetDateTime::now_utc();
let _ = daily.is_now(now);Built-in shortcuts: minutely, hourly, daily, weekly, monthly,
quarterly, semiannually, yearly.
§Features
unstable— enables additional nightly-only language features when building on a nightly compiler (detected automatically via therustversioncrate).
Structs§
- Actix
- Configuration for the Actix web server
- Bartoc
Info - bartoc client system information
- Bartos
- Used in bartoc configuration to define the bartos instance to connect to
- Bincode
- A generic newtype to handle redb keys and values that implement
bincode_next::Encodeandbincode_next::Decode - Client
Data - bartoc client data
- Command
- A command to run on a worker
- DayOf
Month - Represents a day of the month (1-31)
- Dow
- A day-of-week constraint for
Realtimeschedules. - Failed
Output - The output of a
Failedrequest - File
Layer - Tracing configuration
- Garuda
- A garuda-update message
- Hour
OfDay - Represents an hour of the day (0-23)
- Initialize
- An initialization message from bartos to a named bartoc client.
- Layer
- Tracing configuration
- List
Output - The output of a
Listrequest, containing the names of all registered bartoc clients - Mariadb
- The
MariaDBconfiguration - Minute
OfHour - Represents a minute of the hour (0-59)
- Month
OfYear - A month of the year (1-12)
- Offset
Data Time Wrapper - An
OffsetDateTimewrapper that implementsbincode_next::Encodeandbincode_next::Decode - Output
- An output record from a bartoc client
- Pacman
- A garuda-update message
- Realtime
- A realtime schedule definition
- Schedule
- A schedule
- Schedules
- The schedule to run commands on a given worker client
- Second
OfMinute - Represents a second of the minute (0-59)
- Signing
Key - ed25519 signing key which can be used to produce signatures.
- Status
- An output record from a bartoc client
- Tls
- TLS configuration for the Actix web server
- Tracing
- Tracing configuration
- Uuid
Wrapper - A
Uuidwrapper that implementsbincode_next::Encodeandbincode_next::Decode - Verifying
Key - An ed25519 public key.
Enums§
- Barto
Cli - Messages from barto-cli to bartos
- Bartoc
- A websocket binary message from bartoc to bartos
- Bartoc
Ws - A supported websocket message from bartoc to bartos
- Bartos
ToBarto Cli - A message from bartos to barto-cli
- Bartos
ToBartoc - A message from bartos to bartoc
- CliUpdate
Kind - The update kind we are requesting
- Constrained
Value - A value constrained by specific rules (such as the day of the month)
- Data
- A record of data from a bartoc client
- Error
- Error types for the barto library
- Missed
Tick - The output table name
- Output
Kind - The kind of output (stdout or stderr)
- Update
Kind - The update kind
Constants§
- HMAC_
HEADER_ LEN - Number of bytes in the HMAC envelope header: 8 (timestamp) + 8 (nonce) + 32 (MAC).
Traits§
- Constrainable
- A trait for types that can be constrained
- Constrained
Value Matcher - A trait for matching constrained values
- Constrained
Value Parser - A trait for parsing constrained values
- Path
Defaults - Trait to allow default paths to be supplied to
load - TlsConfig
- A trait for types that provide TLS configuration details.
- Tracing
Config Ext - Extension trait for
TracingConfigto add additional configuration options
Functions§
- clap_
or_ error - Converts an
anyhow::Errorinto a suitable exit code or clap message for a CLI application. - clean_
output_ string - Clean an output string by removing tabs, new lines, carriage returns, and ANSI escape codes.
- header
- Generate a pretty header
- hmac_
sign - Wrap
payloadin an HMAC-SHA256 authenticated envelope. - hmac_
verify_ and_ extract - Verify an HMAC-SHA256 envelope and return
(payload, timestamp, nonce). - init_
tracing - Initialize tracing
- key_
fingerprint - Return a short fingerprint of a verifying key: first 8 bytes of its SHA-256 hash, hex-encoded.
- load
- Load the configuration
- load_
client_ cert_ and_ key - Loads a client certificate chain and private key from PEM files.
- load_
pinned_ root_ store - Loads a
RootCertStorecontaining only the certificates from the given PEM file. - load_
tls_ config - Generates a
ServerConfigfor TLS using the provided configuration. - midnight
- The cutoff timestamp used for date-based cleanup: today’s local midnight.
- parse_
hmac_ key - Parse an HMAC key from a plain string — the raw UTF-8 bytes become the key.
- parse_
signing_ key - Parse a base64-encoded Ed25519 signing (private) key.
- parse_
ts_ ping - Parse a received timestamp ping
- parse_
verifying_ key - Parse a base64-encoded Ed25519 verifying (public) key.
- public_
key_ b64 - Return the base64-encoded public key corresponding to a signing key.
- resolve_
config_ path - Returns the resolved path to the config file for the given defaults.
- send_
ts_ ping - Send a timestamp ping
- sign_
payload - Sign a payload, returning
[64-byte signature][payload]as aVec<u8>. - success
- Indicates successful execution of a function, returning exit code 0.
- to_
path_ buf - Convert a string to a
PathBuf - verify_
and_ extract - Verify the 64-byte signature prefix of
dataand return the payload slice.
Type Aliases§
- Day
- Represents a constrained value for the day of the month (1-31)
- Hour
- Represents a constrained value matcher for hours of the day
- Minute
- Represents a constrained value matcher for minutes of the hour
- Month
- A constrained value representing a month of the year (1-12)
- Second
- Represents a constrained value matcher for seconds of the minute
- Year
- A year constraint for realtime schedules (
i32::MIN..=i32::MAX)