Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 130 additions & 33 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,19 @@ license = "Apache-2.0"

[workspace.dependencies]
# Lut99 Crates
humanlog = { git = "https://github.com/Lut99/humanlog-rs", tag = "v0.2.0" }
enum-debug = { git = "https://github.com/Lut99/enum-debug", tag = "v1.1.0", features = ["derive"] }
error-trace = { git = "https://github.com/Lut99/error-trace-rs", tag = "v3.0.0" }
transform = { git = "https://github.com/Lut99/transform-rs", tag = "v0.2.0" }
names = { git = "https://github.com/Lut99/names-rs", tag = "v0.1.0", default-features = false, features = [ "rand", "three-lowercase" ]}
download = { git = "https://github.com/Lut99/download-rs", tag = "v0.1.0", default-features = false, features = ["download"] }

# Other crates
clap = { version = "4.4.0", features = ["derive", "env"] }
strum = "0.27.0"
thiserror = { version = "2.0.0" }
tracing = { version = "0.1.36" }
tracing-subscriber = { version = "0.3.10", features = ["env-filter"] }

[workspace.lints.clippy]
result_large_err = { level = "allow", priority = 1 }
suspicious = "deny"
12 changes: 7 additions & 5 deletions brane-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@ authors.workspace = true
async-compression = { version = "0.4.0", features = ["tokio","gzip"] }
bytes = "1.2.0"
chrono = "0.4.35"
clap = { version = "4.5.6", features = ["derive","env"] }
dotenvy = "0.15"
enum-debug.workspace = true
env_logger = "0.11.0"
error-trace.workspace = true
juniper = { version = "0.16.1", features = ["chrono"] }
juniper_warp = "0.8.0"
# k8s-openapi = { version = "0.14", default-features = false, features = ["v1_23"] }
log = "0.4.22"
rand = "0.9.0"
# rdkafka = { version = "0.31", features = ["cmake-build"] }
reqwest = { version = "0.12.0", features = ["rustls-tls-manual-roots"] }
Expand All @@ -34,6 +29,13 @@ tokio-tar = "0.3.0"
uuid = { version = "1.7.0", features = ["serde", "v4"] }
warp = "0.3.2"

# Workspace dependencies
clap.workspace = true
enum-debug.workspace = true
error-trace.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true

brane-cfg = { path = "../brane-cfg" }
brane-prx = { path = "../brane-prx" }
brane-shr = { path = "../brane-shr" }
Expand Down
5 changes: 2 additions & 3 deletions brane-api/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ use clap::Parser;
#[derive(Parser)]
#[clap(version = env!("CARGO_PKG_VERSION"))]
pub(crate) struct Cli {
/// Print debug info
#[clap(short, long, env = "DEBUG")]
pub(crate) debug: bool,
#[clap(flatten)]
pub(crate) logging: specifications::cli::Tracing,

/// Load everything from the node.yml file
#[clap(
Expand Down
2 changes: 1 addition & 1 deletion brane-api/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ use brane_cfg::info::Info as _;
use brane_cfg::infra::InfraFile;
use brane_cfg::node::NodeConfig;
use brane_prx::spec::NewPathRequestTlsOptions;
use log::{debug, error};
use reqwest::StatusCode;
use specifications::data::{AssetInfo, DataInfo};
use tracing::{debug, error};
use warp::http::{HeaderValue, Response};
use warp::hyper::Body;
use warp::{Rejection, Reply};
Expand Down
2 changes: 1 addition & 1 deletion brane-api/src/infra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ use brane_cfg::info::Info as _;
use brane_cfg::infra::{InfraFile, InfraLocation};
use brane_cfg::node::NodeConfig;
use brane_prx::spec::NewPathRequestTlsOptions;
use log::{debug, error};
use specifications::address::Address;
use specifications::package::Capability;
use tracing::{debug, error};
use warp::hyper::header::HeaderValue;
use warp::hyper::{Body, Response};
use warp::{Rejection, Reply};
Expand Down
20 changes: 9 additions & 11 deletions brane-api/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,26 @@ use clap::Parser;
use dotenvy::dotenv;
use error_trace::trace;
use juniper::EmptySubscription;
use log::{LevelFilter, debug, error, info, warn};
use scylla::{Session, SessionBuilder};
use tokio::signal::unix::{Signal, SignalKind, signal};
use tracing::{debug, error, info, warn};
use warp::Filter;


/***** CONSTANTS *****/
/// The default log level for tracing_subscriber. Levels higher than this will be discarded.
const DEFAULT_LOG_LEVEL: tracing::level_filters::LevelFilter = tracing::level_filters::LevelFilter::INFO;
/// The environment variable used by env-filter in tracing subscriber
const LOG_LEVEL_ENV_VAR: &str = "BRANE_API_LOG";

/***** ENTRYPOINT *****/
#[tokio::main]
async fn main() {
dotenv().ok();
let opts = cli::Cli::parse();

// Configure logger.
let mut logger = env_logger::builder();
logger.format_module_path(false);
let cli_log_level = opts.logging.log_level(DEFAULT_LOG_LEVEL);
specifications::tracing::setup_subscriber(LOG_LEVEL_ENV_VAR, cli_log_level);

if opts.debug {
logger.filter_level(LevelFilter::Debug).init();
} else {
logger.filter_level(LevelFilter::Info).init();
}
info!("Initializing brane-job v{}...", env!("CARGO_PKG_VERSION"));

// Load the config, making sure it's a worker config
Expand Down Expand Up @@ -168,7 +166,7 @@ async fn main() {
let version = warp::path("version").and(warp::path::end()).and_then(version::handle);

// Construct the final routes
let routes = data.or(packages.or(infra.or(health.or(version.or(graphql))))).with(warp::log("brane-api"));
let routes = data.or(packages.or(infra.or(health.or(version.or(graphql))))).with(warp::trace::request());

// Run the server
let handle = warp::serve(routes).try_bind_with_graceful_shutdown(central.services.api.bind, async {
Expand Down
2 changes: 1 addition & 1 deletion brane-api/src/packages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use async_compression::tokio::bufread::GzipDecoder;
use brane_cfg::info::Info as _;
use brane_cfg::node::{CentralConfig, NodeConfig, NodeKind};
use bytes::Buf;
use log::{debug, error, info, warn};
use rand::Rng;
use rand::distr::Alphanumeric;
use scylla::macros::{FromUserType, IntoUserType};
Expand All @@ -35,6 +34,7 @@ use tokio::fs as tfs;
use tokio::io::{AsyncReadExt, AsyncWriteExt, BufReader};
use tokio_stream::StreamExt;
use tokio_tar::{Archive, Entries, Entry};
use tracing::{debug, error, info, warn};
use uuid::Uuid;
use warp::http::{HeaderValue, StatusCode};
use warp::hyper::Body;
Expand Down
2 changes: 1 addition & 1 deletion brane-api/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ use std::str::FromStr;

use chrono::{DateTime, TimeZone, Utc};
use juniper::{EmptySubscription, FieldResult, GraphQLObject, RootNode, graphql_object};
use log::{debug, info};
use scylla::IntoTypedRows;
use specifications::version::Version;
use tracing::{debug, info};

use crate::packages::PackageUdt;
use crate::spec::Context;
Expand Down
9 changes: 6 additions & 3 deletions brane-ast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ license.workspace = true
console = "0.15.5"
enum-debug.workspace = true
lazy_static = "1.4.0"
log = "0.4.22"
rand = "0.9.0"
num-traits = "0.2.18"
serde = { version = "1.0.204", features = ["rc"] }
serde_json_any_key = "2.0.0"
strum = { version = "0.27.0", features = ["derive"] }
thiserror = "2.0.0"
uuid = { version = "1.7.0", features = ["serde", "v4"] }

# Workspace dependencies
strum = { workspace = true, features = ["derive"] }
thiserror.workspace = true
tracing.workspace = true

# Intra workspace dependencies
brane-dsl = { path = "../brane-dsl" }
brane-shr = { path = "../brane-shr" }
specifications = { path = "../specifications" }
Expand Down
9 changes: 5 additions & 4 deletions brane-ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use brane_dsl::ParserOptions;
use brane_dsl::spec::MergeStrategy;
use enum_debug::EnumDebug;
use log::debug;
use rand::Rng as _;
use rand::distr::Alphanumeric;
use serde::de::{self, Deserializer, Visitor};
Expand All @@ -35,6 +34,7 @@
use specifications::data::{AvailabilityKind, DataIndex, DataName};
use specifications::package::{Capability, PackageIndex};
use specifications::version::Version;
use tracing::debug;

use crate::data_type::DataType;
use crate::errors::CompileError;
Expand Down Expand Up @@ -197,9 +197,10 @@
},
};
debug!("Compiled to workflow:\n\n");
if log::max_level() == log::LevelFilter::Debug {
crate::traversals::print::ast::do_traversal(&workflow, std::io::stdout()).unwrap();
}
// TODO: Implement tracing

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note

Suspicious comment
// if tracing::max_level() == tracing::LevelFilter::Debug {
// crate::traversals::print::ast::do_traversal(&workflow, std::io::stdout()).unwrap();
// }

// Return
Ok(workflow)
Expand Down
2 changes: 1 addition & 1 deletion brane-ast/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ use std::fmt::{Display, Formatter, Result as FResult};

use brane_dsl::ast::Program;
use brane_dsl::{Error as ParseError, ParserOptions};
use log::trace;
use specifications::data::DataIndex;
use specifications::package::PackageIndex;
use tracing::trace;

use crate::ast::Workflow;
use crate::ast_unresolved::UnresolvedWorkflow;
Expand Down
2 changes: 1 addition & 1 deletion brane-ast/src/fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use std::error::Error;

use brane_dsl::TextPos;
use log::error;
use tracing::error;


/***** LIBRARY *****/
Expand Down
2 changes: 1 addition & 1 deletion brane-ast/src/traversals/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ use brane_dsl::ast as dsl;
use brane_dsl::spec::MergeStrategy;
use brane_dsl::symbol_table::{FunctionEntry, VarEntry};
use enum_debug::EnumDebug as _;
use log::warn;
use specifications::data::DataName;
use tracing::warn;

use crate::ast;
use crate::ast_unresolved::UnresolvedWorkflow;
Expand Down
2 changes: 1 addition & 1 deletion brane-ast/src/traversals/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use brane_dsl::ast::{Block, Data, Expr, Program, Stmt};
use brane_dsl::symbol_table::{ClassEntry, FunctionEntry, SymbolTableEntry, VarEntry};
use brane_dsl::{DataType, SymbolTable};
use enum_debug::EnumDebug as _;
use log::debug;
use tracing::debug;
use uuid::Uuid;

use crate::errors::AstError;
Expand Down
2 changes: 1 addition & 1 deletion brane-ast/src/traversals/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ use brane_dsl::spec::MergeStrategy;
use brane_dsl::symbol_table::{ClassEntry, FunctionEntry, SymbolTableEntry, VarEntry};
use brane_dsl::{DataType, SymbolTable, TextRange};
use enum_debug::EnumDebug as _;
use log::trace;
use specifications::data::DataIndex;
use specifications::package::{PackageIndex, PackageInfo};
use specifications::version::Version;
use tracing::trace;

use crate::errors::AstError;
pub use crate::errors::ResolveError as Error;
Expand Down
2 changes: 1 addition & 1 deletion brane-ast/src/traversals/workflow_resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use std::cell::Ref;
use std::collections::HashMap;

use log::debug;
use tracing::debug;

use crate::ast::{Edge, SymTable, Workflow};
use crate::ast_unresolved::UnresolvedWorkflow;
Expand Down
10 changes: 6 additions & 4 deletions brane-cc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ name = "branec"
path = "src/main.rs"

[dependencies]
clap = { version = "4.5.6", features = ["derive","env"] }
dotenvy = "0.15.0"
enum-debug.workspace = true
humanlog.workspace = true
human-panic = "2.0.0"
log = "0.4.22"
thiserror = "2.0.0"
tokio = { version = "1.38.0", features = ["rt","macros"] }
url = "2.5.0"

# Workspace dependencies
clap.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
enum-debug.workspace = true

brane-ast = { path = "../brane-ast" }
brane-dsl = { path = "../brane-dsl" }
brane-shr = { path = "../brane-shr" }
Expand Down
8 changes: 2 additions & 6 deletions brane-cc/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ use clap::Parser;
#[derive(Parser)]
#[clap(name = "branec", author, about = "An offline compiler for BraneScript/Bakery to Workflows.")]
pub(crate) struct Cli {
/// If given, shows debug prints.
#[clap(long, help = "If given, shows INFO- and DEBUG-level prints in the log.", env = "DEBUG")]
pub(crate) debug: bool,
/// If given, shows additional trace prints.
#[clap(long, help = "If given, shows TRACE-level prints in the log. Implies '--debug'", env = "TRACE")]
pub(crate) trace: bool,
#[clap(flatten)]
pub(crate) logging: specifications::cli::Tracing,

/// The file(s) to compile. May be '-' to compile from stdin.
#[clap(name = "FILES", help = "The input files to compile. Use '-' to read from stdin.")]
Expand Down
2 changes: 1 addition & 1 deletion brane-cc/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::fs::File;
use std::io::{Read, Write};
use std::path::{Path, PathBuf};

use log::debug;
use tracing::debug;

use brane_dsl::Language;
use brane_ast::{compile_snippet, CompileResult, ParserOptions, Workflow};
Expand Down
16 changes: 10 additions & 6 deletions brane-cc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@ use dotenvy::dotenv;
#[cfg(unix)]
use expanduser::expanduser;
use human_panic::setup_panic;
use humanlog::{DebugMode, HumanLogger};
use log::{debug, error, info, warn};
use specifications::data::DataIndex;
use specifications::package::PackageIndex;
use tracing::{debug, error, info, warn};

/***** CONSTANTS *****/
/// The default log level for tracing_subscriber. Levels higher than this will be discarded.
const DEFAULT_LOG_LEVEL: tracing::level_filters::LevelFilter = tracing::level_filters::LevelFilter::INFO;
/// The environment variable used by env-filter in tracing subscriber
const LOG_LEVEL_ENV_VAR: &str = "BRANE_CC_LOG";


/***** ENTRYPOINT *****/
Expand All @@ -47,13 +51,13 @@ async fn main() {
let mut args = cli::Cli::parse();

// Setup the logger
if let Err(err) = HumanLogger::terminal(DebugMode::from_flags(args.trace, args.debug)).init() {
eprintln!("WARNING: Failed to setup logger: {err} (logging disabled for this session)");
}
let cli_log_level = args.logging.log_level(DEFAULT_LOG_LEVEL);
specifications::tracing::setup_subscriber(LOG_LEVEL_ENV_VAR, cli_log_level);

info!("Initializing branec v{}", env!("CARGO_PKG_VERSION"));

// Setup the panic mode
if !args.trace && !args.debug {
if !args.logging.trace && !args.logging.debug {
setup_panic!();
}

Expand Down
4 changes: 3 additions & 1 deletion brane-cfg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ license.workspace = true
[dependencies]
async-trait = "0.1.67"
enum-debug.workspace = true
log = "0.4.22"
rustls = "0.21.6"
rustls-pemfile = "1.0.1"
serde = { version = "1.0.204", features = ["derive"] }
Expand All @@ -19,6 +18,9 @@ thiserror = "2.0.0"
tokio = { version = "1.38.0", features = [] }
x509-parser = "0.17.0"

# Workspace dependencies
tracing.workspace = true

specifications = { path = "../specifications" }

[lints]
Expand Down
2 changes: 1 addition & 1 deletion brane-cfg/src/certs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
use std::path::Path;
use std::{fs, io};

use log::debug;
use rustls::{Certificate, PrivateKey, RootCertStore};
use rustls_pemfile::{Item, certs, rsa_private_keys};
use tracing::debug;
use x509_parser::certificate::X509Certificate;
use x509_parser::prelude::FromDer;

Expand Down
5 changes: 3 additions & 2 deletions brane-cli-c/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ doc = false

[dependencies]
console = "0.15.5"
humanlog.workspace = true
libc = "0.2.154"
log = "0.4.22"
parking_lot = "0.12.1"
tokio = "1.38.0"

# Workspace dependencies
tracing.workspace = true

brane-ast = { path = "../brane-ast" }
brane-cli = { path = "../brane-cli" }
brane-exe = { path = "../brane-exe" }
Expand Down
Loading
Loading