Skip to content

Commit c1b0501

Browse files
committed
refactor: make V8 runtime required, not optional
V8 is the core of the task executor - it makes no sense without it. - Remove v8 feature flag, make openworkers-runtime-v8 required - Simplify conditional compilation in main.rs - Update tests and README
1 parent 9a444d7 commit c1b0501

5 files changed

Lines changed: 12 additions & 37 deletions

File tree

Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@ license = "MIT"
66
description = "Minimal task executor for OpenWorkers - fetch only, no database"
77

88
[features]
9-
default = ["v8", "nats"]
10-
v8 = ["dep:openworkers-runtime-v8"]
9+
default = ["nats"]
1110
nats = ["dep:async-nats"]
1211
database = ["dep:sqlx", "dep:dotenvy"]
1312

1413
[dependencies]
1514
# Core types
1615
openworkers-core = { git = "https://github.com/openworkers/openworkers-core", tag = "v0.9.0" }
1716

18-
# Runtime backend (V8)
19-
openworkers-runtime-v8 = { git = "https://github.com/openworkers/openworkers-runtime-v8", tag = "v0.9.1", optional = true }
17+
# Runtime backend (V8) - required
18+
openworkers-runtime-v8 = { git = "https://github.com/openworkers/openworkers-runtime-v8", tag = "v0.9.1" }
2019

2120
# Async runtime
2221
tokio = { version = "1.49.0", features = ["full"] }

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,22 @@ Perfect for background jobs, scheduled tasks, or lightweight serverless workload
1212

1313
| Feature | Description | Default |
1414
|---------|-------------|---------|
15-
| `v8` | V8 JavaScript runtime ||
1615
| `nats` | NATS message queue listener ||
1716
| `database` | PostgreSQL queue with pg_notify ||
1817

18+
> V8 runtime is always included (required).
19+
1920
## Installation
2021

2122
```bash
22-
# Clone and build with default features (v8 + nats)
23+
# Build with default features (nats)
2324
cargo build --release
2425

2526
# Build with database support
2627
cargo build --release --features database
2728

2829
# Build with all features
29-
cargo build --release --features v8,nats,database
30+
cargo build --release --features nats,database
3031
```
3132

3233
## Usage
@@ -216,10 +217,10 @@ task-executor db-listen --database-url $DATABASE_URL
216217

217218
```bash
218219
# Run all tests (requires PostgreSQL for db tests)
219-
cargo test --features v8,database
220+
cargo test --features database
220221

221222
# Run only database tests
222-
cargo test --features v8,database db_
223+
cargo test --features database db_
223224
```
224225

225226
Database tests use `.env.test` for configuration:

src/main.rs

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ fn resolve_script_path(root: &PathBuf, script_path: &str) -> Result<PathBuf, Str
314314
}
315315

316316
/// Execute a script and return the result
317-
#[cfg(feature = "v8")]
318317
async fn execute_script(
319318
script_content: &str,
320319
payload: Option<serde_json::Value>,
@@ -368,17 +367,6 @@ async fn execute_script(
368367
}
369368
}
370369

371-
#[cfg(not(feature = "v8"))]
372-
async fn execute_script(
373-
_script_content: &str,
374-
_payload: Option<serde_json::Value>,
375-
_origin: &str,
376-
_timeout: u64,
377-
_quiet: bool,
378-
) -> Result<openworkers_core::TaskResult, Box<dyn std::error::Error>> {
379-
Err("V8 runtime not enabled. Build with --features v8".into())
380-
}
381-
382370
#[cfg(feature = "database")]
383371
async fn listen_database(
384372
database_url: String,
@@ -419,7 +407,8 @@ async fn listen_database(
419407
}
420408

421409
/// Execute script variant for database listener (needs to be Send)
422-
#[cfg(all(feature = "database", feature = "v8"))]
410+
/// Execute script variant for database listener (needs to be Send)
411+
#[cfg(feature = "database")]
423412
async fn execute_script_for_db(
424413
script_content: &str,
425414
payload: Option<serde_json::Value>,
@@ -479,13 +468,3 @@ async fn execute_script_for_db(
479468
Err(reason) => Err(format!("Execution failed: {:?}", reason).into()),
480469
}
481470
}
482-
483-
#[cfg(all(feature = "database", not(feature = "v8")))]
484-
async fn execute_script_for_db(
485-
_script_content: &str,
486-
_payload: Option<serde_json::Value>,
487-
_timeout: u64,
488-
_quiet: bool,
489-
) -> Result<openworkers_core::TaskResult, Box<dyn std::error::Error>> {
490-
Err("V8 runtime not enabled. Build with --features v8,database".into())
491-
}

tests/db_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//!
1111
//! The tests will create and clean up their own tables.
1212
13-
#![cfg(all(feature = "database", feature = "v8"))]
13+
#![cfg(feature = "database")]
1414

1515
use openworkers_task_executor::db::{DbPool, TaskCompletion};
1616
use sqlx::Row;

tests/integration_test.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
//! Integration tests for the task executor
2-
//!
3-
//! These tests require the V8 runtime feature.
4-
5-
#![cfg(feature = "v8")]
62
73
use openworkers_core::{Event, RuntimeLimits, Script, TaskSource, WorkerCode};
84
use openworkers_task_executor::MinimalOps;

0 commit comments

Comments
 (0)