Skip to content

Commit a93d092

Browse files
committed
Add some simple module-documentation
1 parent 8444f11 commit a93d092

File tree

11 files changed

+50
-0
lines changed

11 files changed

+50
-0
lines changed

opsqueue/src/common/chunk.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
//! Dealing with `Chunk``s, the most fine-grained datatype the queue itself works with.
2+
//!
3+
//! While the smallest datatype is the 'Operation', the Opsqueue queue binary itself
4+
//! only deals with _chunks_ of them. The operations inside of them are hidden and only read/written
5+
//! from/to object store all the way in the client.
16
use chrono::{DateTime, Utc};
27

38
use serde::{Deserialize, Serialize};

opsqueue/src/common/errors.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
//! Common error types
2+
//!
3+
//! You might notice in many places in Opsqueue that we use very fine-grained error types,
4+
//! and combine them together using the `E` helper.
5+
//!
6+
//! This is a conscious choice: While it makes some function signatures more complex,
7+
//! it allows us to be super precise in what kind of errors can and cannot occur
8+
//! in certain API calls.
19
use serde::{Deserialize, Serialize};
210
use thiserror::Error;
311

opsqueue/src/common/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Common datatypes and errors shared across all parts of Opsqueue
12
use rustc_hash::FxHashMap;
23

34
pub mod chunk;

opsqueue/src/common/submission.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Dealing with `Submission`s: Collections of (`Chunks`s of) operations.
12
use std::fmt::Display;
23
use std::time::Duration;
34

opsqueue/src/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//! Defines the source of truth for configuring the Opsqueue queue
2+
//!
3+
//! We make use of the excellent `clap` crate to make customizing the configuration
4+
//! with command-line args easier.
15
use std::num::NonZero;
26

37
use clap::Parser;

opsqueue/src/consumer/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! The Consumer side: Interface to reserve, work on, and complete/fail individual Chunks
12
pub mod common;
23
pub mod strategy;
34

opsqueue/src/lib.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
//! Opsqueue: A lightweight batch processing queue for heavy loads
2+
//!
3+
//! Simple 'getting started' instructions can be found [in the repository README](https://github.com/channable/opsqueue/).
4+
//!
5+
//! The Rust codebase defines both the 'server', which makes up the bulk of the Opsqueue binary itself,
6+
//! and the 'client', which is the common part of functionality that clients written in different other programming languages
7+
//! can all use.
8+
//!
9+
//! Many datatypes are shared between this server and client, and therefore their code lives together in the same crate.
10+
//! Instead, we use feature-flags (`client-logic` and `server-logic`) to decide what concrete parts to include when building.
11+
//! The set of dependencies is based on these same feature-flags.
12+
//! Most interestingly, in the test suite we enable both feature-flags so we're able to do a bunch of round-trip testing
13+
//! immediately in Rust code.
14+
//!
15+
//! # Module setup
16+
//! - The basic logic is divided in the `producer` and `consumer` modules. These both have their own `db` submodule.
17+
//! - Common functionality and datatypes exists in the `common` module
18+
//! - Common database helpers live in the `db` module.
19+
//! - Reading/writing to object stores like GCS or S3 is abstracted in the `object_store` module.
20+
//! - Finally, extra modules to have a single source of truth for configuration of the queue, and to nicely do tracing and expose metrics exist.
21+
122
pub mod common;
223
pub mod consumer;
324
pub mod producer;

opsqueue/src/producer/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! The Producer side: Interface to create and read submissions
12
#[cfg(feature = "client-logic")]
23
pub mod client;
34
pub mod common;

opsqueue/src/prometheus.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
//! Define common metrics exposed via a Prometheus endpoint
2+
//!
3+
//! This allows inspection of how well the queue is performing under production load.
4+
//!
5+
//! Note that we explicitly have a separate endpoint to check the queue health,
6+
//! which is more fine-grained than Prometheus' way to check whether a service is 'up'.
17
use axum_prometheus::{
28
metrics::{describe_counter, describe_gauge, describe_histogram, gauge, Unit},
39
metrics_exporter_prometheus::{Matcher, PrometheusBuilder, PrometheusHandle},

opsqueue/src/server.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Defines the HTTP endpoints that are used by both the `producer` and `consumer` APIs
12
use std::{
23
any::Any,
34
sync::{atomic::AtomicBool, Arc},

0 commit comments

Comments
 (0)