Skip to main content

Crate libbarto

Crate libbarto 

Source
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 to MariaDB
  • bartoc — remote worker client; executes scheduled commands and streams output back to bartos
  • barto-cli — command-line interface for querying and managing a running bartos instance

§Key Types

TypeDescription
RealtimeParse and evaluate cron-like schedule expressions
DataOutput or status payload streamed from bartoc to bartos
BartosToBartocSchedule initialization message sent from bartos to bartoc
BartoCliCommand messages sent from barto-cli to bartos
loadLoad a component’s TOML configuration with env-var overrides
init_tracingInitialize 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 the rustversion crate).

Structs§

Actix
Configuration for the Actix web server
BartocInfo
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::Encode and bincode_next::Decode
ClientData
bartoc client data
Command
A command to run on a worker
DayOfMonth
Represents a day of the month (1-31)
Dow
A day-of-week constraint for Realtime schedules.
FailedOutput
The output of a Failed request
FileLayer
Tracing configuration
Garuda
A garuda-update message
HourOfDay
Represents an hour of the day (0-23)
Initialize
An initialization message from bartos to a named bartoc client.
Layer
Tracing configuration
ListOutput
The output of a List request, containing the names of all registered bartoc clients
Mariadb
The MariaDB configuration
MinuteOfHour
Represents a minute of the hour (0-59)
MonthOfYear
A month of the year (1-12)
OffsetDataTimeWrapper
An OffsetDateTime wrapper that implements bincode_next::Encode and bincode_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
SecondOfMinute
Represents a second of the minute (0-59)
SigningKey
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
UuidWrapper
A Uuid wrapper that implements bincode_next::Encode and bincode_next::Decode
VerifyingKey
An ed25519 public key.

Enums§

BartoCli
Messages from barto-cli to bartos
Bartoc
A websocket binary message from bartoc to bartos
BartocWs
A supported websocket message from bartoc to bartos
BartosToBartoCli
A message from bartos to barto-cli
BartosToBartoc
A message from bartos to bartoc
CliUpdateKind
The update kind we are requesting
ConstrainedValue
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
MissedTick
The output table name
OutputKind
The kind of output (stdout or stderr)
UpdateKind
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
ConstrainedValueMatcher
A trait for matching constrained values
ConstrainedValueParser
A trait for parsing constrained values
PathDefaults
Trait to allow default paths to be supplied to load
TlsConfig
A trait for types that provide TLS configuration details.
TracingConfigExt
Extension trait for TracingConfig to add additional configuration options

Functions§

clap_or_error
Converts an anyhow::Error into 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 payload in 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 RootCertStore containing only the certificates from the given PEM file.
load_tls_config
Generates a ServerConfig for 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 a Vec<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 data and 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)