Extract core lib into a standalone crate (#3423)
Co-authored-by: Gerard Guillemas Martos <gerard.guillemas@surrealdb.com>
This commit is contained in:
parent
0bc284b6dd
commit
690dd55a86
1158 changed files with 37701 additions and 1033 deletions
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
@ -383,6 +383,8 @@ jobs:
|
|||
run: cargo install --debug --locked cargo-make
|
||||
|
||||
- name: Test workspace for experimental_parser
|
||||
env:
|
||||
RUSTFLAGS: "--cfg surrealdb_unstable"
|
||||
run: cargo make test-experimental-parser
|
||||
|
||||
ws-engine:
|
||||
|
|
88
Cargo.lock
generated
88
Cargo.lock
generated
|
@ -652,17 +652,6 @@ dependencies = [
|
|||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "axum-client-ip"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f5ffe4637708b326c621d5494ab6c91dcf62ee440fa6ee967d289315a9c6f81"
|
||||
dependencies = [
|
||||
"axum 0.7.4",
|
||||
"forwarded-header-value",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "axum-core"
|
||||
version = "0.3.4"
|
||||
|
@ -1917,16 +1906,6 @@ dependencies = [
|
|||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "forwarded-header-value"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8835f84f38484cc86f110a805655697908257fb9a7af005234060891557198e9"
|
||||
dependencies = [
|
||||
"nonempty",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foundationdb"
|
||||
version = "0.8.0"
|
||||
|
@ -3278,12 +3257,6 @@ dependencies = [
|
|||
"minimal-lexical",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nonempty"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e9e591e719385e6ebaeb5ce5d3887f7d5676fceca6411d1925ccc95745f3d6f7"
|
||||
|
||||
[[package]]
|
||||
name = "nu-ansi-term"
|
||||
version = "0.46.0"
|
||||
|
@ -5283,7 +5256,6 @@ dependencies = [
|
|||
"argon2",
|
||||
"assert_fs",
|
||||
"axum 0.6.20",
|
||||
"axum-client-ip",
|
||||
"axum-extra",
|
||||
"axum-server",
|
||||
"base64 0.21.7",
|
||||
|
@ -5297,10 +5269,8 @@ dependencies = [
|
|||
"http 0.2.11",
|
||||
"http-body 0.4.6",
|
||||
"hyper 0.14.28",
|
||||
"ipnet",
|
||||
"jemallocator",
|
||||
"mimalloc",
|
||||
"ndarray",
|
||||
"nix 0.27.1",
|
||||
"once_cell",
|
||||
"opentelemetry",
|
||||
|
@ -5318,7 +5288,6 @@ dependencies = [
|
|||
"serde_json",
|
||||
"serial_test",
|
||||
"surrealdb",
|
||||
"surrealml-core",
|
||||
"temp-env",
|
||||
"tempfile",
|
||||
"test-log",
|
||||
|
@ -5342,6 +5311,56 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "surrealdb"
|
||||
version = "1.1.1"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"bincode",
|
||||
"chrono",
|
||||
"criterion",
|
||||
"dmp",
|
||||
"env_logger",
|
||||
"flume",
|
||||
"futures",
|
||||
"futures-concurrency",
|
||||
"geo 0.27.0",
|
||||
"indexmap 2.1.0",
|
||||
"native-tls",
|
||||
"once_cell",
|
||||
"path-clean",
|
||||
"pharos",
|
||||
"pprof",
|
||||
"rand 0.8.5",
|
||||
"regex",
|
||||
"reqwest",
|
||||
"ring 0.17.7",
|
||||
"rust_decimal",
|
||||
"rustls",
|
||||
"semver",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serial_test",
|
||||
"surrealdb-core",
|
||||
"temp-dir",
|
||||
"test-log",
|
||||
"thiserror",
|
||||
"time",
|
||||
"tokio",
|
||||
"tokio-tungstenite",
|
||||
"tokio-util",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"trice",
|
||||
"ulid",
|
||||
"url",
|
||||
"uuid",
|
||||
"wasm-bindgen-futures",
|
||||
"wasmtimer",
|
||||
"wiremock",
|
||||
"ws_stream_wasm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "surrealdb-core"
|
||||
version = "1.1.1"
|
||||
dependencies = [
|
||||
"addr",
|
||||
"any_ascii",
|
||||
|
@ -5361,28 +5380,23 @@ dependencies = [
|
|||
"dmp",
|
||||
"echodb",
|
||||
"env_logger",
|
||||
"flume",
|
||||
"foundationdb",
|
||||
"fst",
|
||||
"futures",
|
||||
"futures-concurrency",
|
||||
"fuzzy-matcher",
|
||||
"geo 0.27.0",
|
||||
"geo-types",
|
||||
"hex",
|
||||
"indexmap 2.1.0",
|
||||
"indxdb",
|
||||
"ipnet",
|
||||
"lexicmp",
|
||||
"md-5",
|
||||
"nanoid",
|
||||
"native-tls",
|
||||
"ndarray",
|
||||
"nom",
|
||||
"num_cpus",
|
||||
"object_store",
|
||||
"once_cell",
|
||||
"path-clean",
|
||||
"pbkdf2",
|
||||
"pharos",
|
||||
"phf",
|
||||
|
@ -5401,7 +5415,6 @@ dependencies = [
|
|||
"rquickjs",
|
||||
"rust-stemmers",
|
||||
"rust_decimal",
|
||||
"rustls",
|
||||
"scrypt",
|
||||
"semver",
|
||||
"serde",
|
||||
|
@ -5422,7 +5435,6 @@ dependencies = [
|
|||
"time",
|
||||
"tokio",
|
||||
"tokio-tungstenite",
|
||||
"tokio-util",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"trice",
|
||||
|
|
11
Cargo.toml
11
Cargo.toml
|
@ -17,12 +17,13 @@ storage-fdb = ["surrealdb/kv-fdb-7_1"]
|
|||
scripting = ["surrealdb/scripting"]
|
||||
http = ["surrealdb/http"]
|
||||
http-compression = []
|
||||
ml = ["surrealdb/ml", "surrealml-core"]
|
||||
experimental-parser = ["surrealdb/experimental-parser"]
|
||||
ml = ["surrealdb/ml"]
|
||||
jwks = ["surrealdb/jwks"]
|
||||
sql2 = ["surrealdb/sql2"]
|
||||
parser2 = ["surrealdb/parser2"]
|
||||
|
||||
[workspace]
|
||||
members = ["lib", "lib/examples/actix", "lib/examples/axum"]
|
||||
members = ["core", "lib", "lib/examples/actix", "lib/examples/axum"]
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
|
@ -37,7 +38,6 @@ strip = false
|
|||
[dependencies]
|
||||
argon2 = "0.5.2"
|
||||
axum = { version = "0.6.20", features = ["tracing", "ws", "headers"] }
|
||||
axum-client-ip = "0.5.0"
|
||||
axum-extra = { version = "0.7.7", features = ["query", "typed-routing"] }
|
||||
axum-server = { version = "0.5.1", features = ["tls-rustls"] }
|
||||
base64 = "0.21.5"
|
||||
|
@ -55,8 +55,6 @@ glob = "0.3.1"
|
|||
http = "0.2.11"
|
||||
http-body = "0.4.5"
|
||||
hyper = "0.14.27"
|
||||
ipnet = "2.9.0"
|
||||
ndarray = { version = "0.15.6", optional = true }
|
||||
once_cell = "1.18.0"
|
||||
opentelemetry = { version = "0.19", features = ["rt-tokio"] }
|
||||
opentelemetry-otlp = { version = "0.12.0", features = ["metrics"] }
|
||||
|
@ -76,7 +74,6 @@ surrealdb = { version = "1", path = "lib", features = [
|
|||
"protocol-ws",
|
||||
"rustls",
|
||||
] }
|
||||
surrealml-core = { version = "0.0.7", optional = true }
|
||||
tempfile = "3.8.1"
|
||||
thiserror = "1.0.50"
|
||||
tokio = { version = "1.34.0", features = ["macros", "signal"] }
|
||||
|
|
|
@ -10,11 +10,13 @@ args = ["check", "--locked", "--workspace"]
|
|||
[tasks.ci-check-wasm]
|
||||
category = "CI - CHECK"
|
||||
command = "cargo"
|
||||
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||
args = ["check", "--locked", "--package", "surrealdb", "--features", "protocol-ws,protocol-http,kv-mem,kv-indxdb,http,jwks", "--target", "wasm32-unknown-unknown"]
|
||||
|
||||
[tasks.ci-clippy]
|
||||
category = "CI - CHECK"
|
||||
command = "cargo"
|
||||
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||
args = ["clippy", "--all-targets", "--features", "storage-mem,storage-rocksdb,storage-speedb,storage-tikv,storage-fdb,scripting,http,jwks", "--tests", "--benches", "--examples","--bins", "--", "-D", "warnings"]
|
||||
|
||||
#
|
||||
|
@ -24,30 +26,31 @@ args = ["clippy", "--all-targets", "--features", "storage-mem,storage-rocksdb,st
|
|||
[tasks.ci-cli-integration]
|
||||
category = "CI - INTEGRATION TESTS"
|
||||
command = "cargo"
|
||||
env = { RUST_LOG={ value = "cli_integration=debug", condition = { env_not_set = ["RUST_LOG"] } } }
|
||||
env = { RUSTFLAGS = "--cfg surrealdb_unstable", RUST_LOG={ value = "cli_integration=debug", condition = { env_not_set = ["RUST_LOG"] } } }
|
||||
args = ["test", "--locked", "--no-default-features", "--features", "storage-mem,http,scripting,jwks", "--workspace", "--test", "cli_integration", "--", "cli_integration", "--nocapture"]
|
||||
|
||||
[tasks.ci-http-integration]
|
||||
category = "CI - INTEGRATION TESTS"
|
||||
command = "cargo"
|
||||
env = { RUST_LOG={ value = "http_integration=debug", condition = { env_not_set = ["RUST_LOG"] } } }
|
||||
env = { RUSTFLAGS = "--cfg surrealdb_unstable", RUST_LOG={ value = "http_integration=debug", condition = { env_not_set = ["RUST_LOG"] } } }
|
||||
args = ["test", "--locked", "--no-default-features", "--features", "storage-mem,http-compression,jwks", "--workspace", "--test", "http_integration", "--", "http_integration", "--nocapture"]
|
||||
|
||||
[tasks.ci-ws-integration]
|
||||
category = "WS - INTEGRATION TESTS"
|
||||
command = "cargo"
|
||||
env = { RUST_LOG={ value = "ws_integration=debug", condition = { env_not_set = ["RUST_LOG"] } } }
|
||||
args = ["test", "--locked", "--no-default-features", "--features", "storage-mem", "--workspace", "--test", "ws_integration", "--", "ws_integration", "--nocapture"]
|
||||
env = { RUSTFLAGS = "--cfg surrealdb_unstable", RUST_LOG={ value = "ws_integration=debug", condition = { env_not_set = ["RUST_LOG"] } } }
|
||||
args = ["test", "--locked", "--no-default-features", "--features", "storage-mem,sql2", "--workspace", "--test", "ws_integration", "--", "ws_integration", "--nocapture"]
|
||||
|
||||
[tasks.ci-ml-integration]
|
||||
category = "ML - INTEGRATION TESTS"
|
||||
command = "cargo"
|
||||
env = { RUST_LOG={ value = "cli_integration::common=debug", condition = { env_not_set = ["RUST_LOG"] } } }
|
||||
args = ["test", "--locked", "--features", "storage-mem,ml", "--workspace", "--test", "ml_integration", "--", "ml_integration", "--nocapture"]
|
||||
env = { RUSTFLAGS = "--cfg surrealdb_unstable", RUST_LOG={ value = "cli_integration::common=debug", condition = { env_not_set = ["RUST_LOG"] } } }
|
||||
args = ["test", "--locked", "--features", "storage-mem,ml,sql2", "--workspace", "--test", "ml_integration", "--", "ml_integration", "--nocapture"]
|
||||
|
||||
[tasks.ci-workspace-coverage]
|
||||
category = "CI - INTEGRATION TESTS"
|
||||
command = "cargo"
|
||||
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||
args = [
|
||||
"llvm-cov", "--html", "--locked", "--no-default-features", "--features", "storage-mem,scripting,http,jwks", "--workspace", "--",
|
||||
"--skip", "api_integration",
|
||||
|
@ -60,8 +63,9 @@ args = [
|
|||
[tasks.test-experimental-parser]
|
||||
category = "CI - INTEGRATION TESTS"
|
||||
command = "cargo"
|
||||
env = { RUSTFLAGS = "--cfg surrealdb_unstable", RUSTDOCFLAGS="--cfg surrealdb_unstable" }
|
||||
args = [
|
||||
"test", "--locked", "--no-default-features", "--features", "storage-mem,scripting,http,experimental-parser", "--workspace", "--",
|
||||
"test", "--locked", "--no-default-features", "--features", "storage-mem,scripting,http,parser2", "--workspace", "--",
|
||||
"--skip", "api_integration",
|
||||
"--skip", "cli_integration",
|
||||
"--skip", "http_integration",
|
||||
|
@ -71,7 +75,8 @@ args = [
|
|||
[tasks.test-workspace-coverage-complete]
|
||||
category = "CI - INTEGRATION TESTS"
|
||||
command = "cargo"
|
||||
args = ["llvm-cov", "--html", "--locked", "--no-default-features", "--features", "protocol-ws,protocol-http,kv-mem,kv-rocksdb", "--workspace"]
|
||||
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||
args = ["llvm-cov", "--html", "--locked", "--no-default-features", "--features", "sql2,protocol-ws,protocol-http,kv-mem,kv-rocksdb", "--workspace"]
|
||||
|
||||
[tasks.ci-workspace-coverage-complete]
|
||||
env = { _START_SURREALDB_PATH = "memory" }
|
||||
|
@ -85,16 +90,18 @@ run_task = { name = ["start-surrealdb", "test-workspace-coverage-complete", "sto
|
|||
[tasks.test-kvs]
|
||||
private = true
|
||||
command = "cargo"
|
||||
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||
args = ["test", "--locked", "--package", "surrealdb", "--no-default-features", "--features", "${_TEST_FEATURES}", "--lib", "kvs"]
|
||||
|
||||
|
||||
[tasks.test-api-integration]
|
||||
private = true
|
||||
command = "cargo"
|
||||
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||
args = ["test", "--locked", "--package", "surrealdb", "--no-default-features", "--features", "${_TEST_FEATURES}", "--test", "api", "api_integration::${_TEST_API_ENGINE}"]
|
||||
|
||||
[tasks.ci-api-integration]
|
||||
env = { _START_SURREALDB_PATH = "memory" }
|
||||
env = { _START_SURREALDB_PATH = "memory", RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||
private = true
|
||||
run_task = { name = ["start-surrealdb", "test-api-integration", "stop-surrealdb"], fork = true }
|
||||
|
||||
|
@ -109,7 +116,7 @@ run_task = "ci-api-integration"
|
|||
|
||||
[tasks.ci-api-integration-ws]
|
||||
category = "CI - INTEGRATION TESTS"
|
||||
env = { _TEST_API_ENGINE = "ws", _TEST_FEATURES = "protocol-ws" }
|
||||
env = { _TEST_API_ENGINE = "ws", _TEST_FEATURES = "protocol-ws,sql2", RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||
run_task = "ci-api-integration"
|
||||
|
||||
[tasks.ci-api-integration-any]
|
||||
|
@ -232,7 +239,8 @@ script = "kill $(cat /tmp/tiup.pid) || true"
|
|||
[tasks.build-surrealdb]
|
||||
category = "CI - BUILD"
|
||||
command = "cargo"
|
||||
args = ["build", "--locked", "--no-default-features", "--features", "storage-mem"]
|
||||
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||
args = ["build", "--locked", "--no-default-features", "--features", "storage-mem,sql2"]
|
||||
|
||||
#
|
||||
# Benchmarks - Common
|
||||
|
@ -240,6 +248,7 @@ args = ["build", "--locked", "--no-default-features", "--features", "storage-mem
|
|||
[tasks.ci-bench]
|
||||
category = "CI - BENCHMARK"
|
||||
command = "cargo"
|
||||
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||
args = ["bench", "--quiet", "--package", "surrealdb", "--no-default-features", "--features", "kv-mem,scripting,http,jwks", "${@}"]
|
||||
|
||||
#
|
||||
|
@ -251,11 +260,13 @@ BENCH_NUM_OPS = { value = "1000", condition = { env_not_set = ["BENCH_NUM_OPS"]
|
|||
BENCH_DURATION = { value = "30", condition = { env_not_set = ["BENCH_DURATION"] } }
|
||||
BENCH_SAMPLE_SIZE = { value = "10", condition = { env_not_set = ["BENCH_SAMPLE_SIZE"] } }
|
||||
BENCH_FEATURES = { value = "protocol-ws,kv-mem,kv-rocksdb,kv-fdb-7_1", condition = { env_not_set = ["BENCH_FEATURES"] } }
|
||||
RUSTFLAGS = "--cfg surrealdb_unstable"
|
||||
|
||||
[tasks.bench-target]
|
||||
private = true
|
||||
category = "CI - BENCHMARK - SurrealDB Target"
|
||||
command = "cargo"
|
||||
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||
args = ["bench", "--package", "surrealdb", "--bench", "sdb", "--no-default-features", "--features", "${BENCH_FEATURES}", "${@}"]
|
||||
|
||||
[tasks.bench-lib-mem]
|
||||
|
|
|
@ -17,19 +17,21 @@ dependencies = ["cargo-upgrade", "cargo-update"]
|
|||
[tasks.docs]
|
||||
category = "LOCAL USAGE"
|
||||
command = "cargo"
|
||||
args = ["doc", "--open", "--no-deps", "--package", "surrealdb", "--features", "rustls,native-tls,protocol-ws,protocol-http,kv-mem,kv-indxdb,kv-speedb,kv-rocksdb,kv-tikv,http,scripting,jwks"]
|
||||
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||
args = ["doc", "--open", "--no-deps", "--package", "surrealdb", "--features", "rustls,native-tls,protocol-ws,protocol-http,kv-mem,kv-speedb,kv-rocksdb,kv-tikv,http,scripting,jwks"]
|
||||
|
||||
# Test
|
||||
[tasks.test]
|
||||
category = "LOCAL USAGE"
|
||||
command = "cargo"
|
||||
env = { RUST_MIN_STACK={ value = "4194304", condition = { env_not_set = ["RUST_MIN_STACK"] } } }
|
||||
env = { RUSTFLAGS = "--cfg surrealdb_unstable", RUST_MIN_STACK={ value = "4194304", condition = { env_not_set = ["RUST_MIN_STACK"] } } }
|
||||
args = ["test", "--workspace", "--no-fail-fast"]
|
||||
|
||||
# Check
|
||||
[tasks.cargo-check]
|
||||
category = "LOCAL USAGE"
|
||||
command = "cargo"
|
||||
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||
args = ["check", "--workspace", "--features", "${DEV_FEATURES}"]
|
||||
|
||||
[tasks.cargo-fmt]
|
||||
|
@ -42,12 +44,13 @@ category = "LOCAL USAGE"
|
|||
script = """
|
||||
set -e
|
||||
cd ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/
|
||||
cargo fmt --all --check -- ./lib/tests/**/*.rs ./lib/src/kvs/tests/*.rs
|
||||
cargo fmt --all --check -- ./lib/tests/**/*.rs ./core/src/kvs/tests/*.rs
|
||||
"""
|
||||
|
||||
[tasks.cargo-clippy]
|
||||
category = "LOCAL USAGE"
|
||||
command = "cargo"
|
||||
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||
args = ["clippy", "--all-targets", "--all-features", "--", "-D", "warnings"]
|
||||
|
||||
[tasks.check]
|
||||
|
@ -68,24 +71,28 @@ args = ["clean"]
|
|||
[tasks.bench]
|
||||
category = "LOCAL USAGE"
|
||||
command = "cargo"
|
||||
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||
args = ["bench", "--package", "surrealdb", "--no-default-features", "--features", "kv-mem,http,scripting,jwks", "--", "${@}"]
|
||||
|
||||
# Run
|
||||
[tasks.run]
|
||||
category = "LOCAL USAGE"
|
||||
command = "cargo"
|
||||
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||
args = ["run", "--no-default-features", "--features", "${DEV_FEATURES}", "--", "${@}"]
|
||||
|
||||
# Serve
|
||||
[tasks.serve]
|
||||
category = "LOCAL USAGE"
|
||||
command = "cargo"
|
||||
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||
args = ["run", "--no-default-features", "--features", "${DEV_FEATURES}", "--", "start", "--allow-all", "${@}"]
|
||||
|
||||
# SQL
|
||||
[tasks.sql]
|
||||
category = "LOCAL USAGE"
|
||||
command = "cargo"
|
||||
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||
args = ["run", "--no-default-features", "--features", "${DEV_FEATURES}", "--", "sql", "--conn", "ws://0.0.0.0:8000", "--multi", "--pretty", "${@}"]
|
||||
|
||||
# Quick
|
||||
|
@ -98,6 +105,7 @@ args = ["build", "${@}"]
|
|||
[tasks.build]
|
||||
category = "LOCAL USAGE"
|
||||
command = "cargo"
|
||||
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||
args = ["build", "--release", "${@}"]
|
||||
|
||||
# Default
|
||||
|
|
14
cackle.toml
14
cackle.toml
|
@ -29,6 +29,7 @@ include = [
|
|||
"mio::net",
|
||||
"surreal::net",
|
||||
"surrealdb",
|
||||
"surrealdb_core",
|
||||
"tokio::net",
|
||||
"tracing",
|
||||
"tracing_core",
|
||||
|
@ -80,6 +81,12 @@ build.allow_build_instructions = [
|
|||
]
|
||||
allow_unsafe = true
|
||||
|
||||
[pkg.lru]
|
||||
allow_unsafe = true
|
||||
allow_apis = [
|
||||
"net",
|
||||
]
|
||||
|
||||
[pkg.bzip2-sys]
|
||||
build.allow_apis = [
|
||||
"fs",
|
||||
|
@ -1151,11 +1158,16 @@ allow_apis = [
|
|||
]
|
||||
|
||||
[pkg.surrealdb]
|
||||
allow_unsafe = true
|
||||
allow_apis = [
|
||||
"fs",
|
||||
]
|
||||
|
||||
[pkg.surrealdb-core]
|
||||
allow_unsafe = true
|
||||
allow_apis = [
|
||||
"net",
|
||||
]
|
||||
|
||||
[pkg.assert_fs]
|
||||
from.test.allow_apis = [
|
||||
"fs",
|
||||
|
|
187
core/Cargo.toml
Normal file
187
core/Cargo.toml
Normal file
|
@ -0,0 +1,187 @@
|
|||
[package]
|
||||
name = "surrealdb-core"
|
||||
publish = true
|
||||
edition = "2021"
|
||||
version = "1.1.1"
|
||||
rust-version = "1.70.0"
|
||||
readme = "../lib/CARGO.md"
|
||||
authors = ["Tobie Morgan Hitchcock <tobie@surrealdb.com>"]
|
||||
description = "A scalable, distributed, collaborative, document-graph database, for the realtime web"
|
||||
repository = "https://github.com/surrealdb/surrealdb"
|
||||
homepage = "https://github.com/surrealdb/surrealdb"
|
||||
documentation = "https://docs.rs/surrealdb-core/"
|
||||
keywords = [
|
||||
"database",
|
||||
"embedded-database",
|
||||
"key-value",
|
||||
"key-value-store",
|
||||
"kv-store",
|
||||
]
|
||||
categories = ["database-implementations", "data-structures", "embedded"]
|
||||
license-file = "../LICENSE"
|
||||
resolver = "2"
|
||||
|
||||
[features]
|
||||
# Public features
|
||||
default = ["kv-mem"]
|
||||
kv-mem = ["dep:echodb", "tokio/time"]
|
||||
kv-indxdb = ["dep:indxdb"]
|
||||
kv-speedb = ["dep:speedb", "tokio/time"]
|
||||
kv-rocksdb = ["dep:rocksdb", "tokio/time"]
|
||||
kv-tikv = ["dep:tikv"]
|
||||
kv-fdb-5_1 = ["foundationdb/fdb-5_1", "kv-fdb"]
|
||||
kv-fdb-5_2 = ["foundationdb/fdb-5_2", "kv-fdb"]
|
||||
kv-fdb-6_0 = ["foundationdb/fdb-6_0", "kv-fdb"]
|
||||
kv-fdb-6_1 = ["foundationdb/fdb-6_1", "kv-fdb"]
|
||||
kv-fdb-6_2 = ["foundationdb/fdb-6_2", "kv-fdb"]
|
||||
kv-fdb-6_3 = ["foundationdb/fdb-6_3", "kv-fdb"]
|
||||
kv-fdb-7_0 = ["foundationdb/fdb-7_0", "kv-fdb"]
|
||||
kv-fdb-7_1 = ["foundationdb/fdb-7_1", "kv-fdb"]
|
||||
scripting = ["dep:js"]
|
||||
http = ["dep:reqwest"]
|
||||
ml = ["dep:surrealml-core", "dep:ndarray"]
|
||||
jwks = ["dep:reqwest"]
|
||||
arbitrary = [
|
||||
"dep:arbitrary",
|
||||
"dep:regex-syntax",
|
||||
"rust_decimal/rust-fuzz",
|
||||
"geo-types/arbitrary",
|
||||
"uuid/arbitrary",
|
||||
]
|
||||
experimental-parser = ["dep:phf", "dep:unicase"]
|
||||
sql2 = []
|
||||
# Private features
|
||||
kv-fdb = ["tokio/time"]
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
features = [
|
||||
"kv-mem",
|
||||
"kv-indxdb",
|
||||
"kv-rocksdb",
|
||||
"http",
|
||||
"scripting",
|
||||
"jwks",
|
||||
]
|
||||
targets = []
|
||||
|
||||
[dependencies]
|
||||
addr = { version = "0.15.6", default-features = false, features = ["std"] }
|
||||
argon2 = "0.5.2"
|
||||
ascii = { version = "0.3.2", package = "any_ascii" }
|
||||
async-recursion = "1.0.5"
|
||||
base64_lib = { version = "0.21.5", package = "base64" }
|
||||
bcrypt = "0.15.0"
|
||||
bincode = "1.3.3"
|
||||
bytes = "1.5.0"
|
||||
cedar-policy = "2.4.2"
|
||||
channel = { version = "1.9.0", package = "async-channel" }
|
||||
chrono = { version = "0.4.31", features = ["serde"] }
|
||||
derive = { version = "0.12.0", package = "surrealdb-derive" }
|
||||
deunicode = "1.4.1"
|
||||
dmp = "0.2.0"
|
||||
echodb = { version = "0.4.0", optional = true }
|
||||
executor = { version = "1.8.0", package = "async-executor" }
|
||||
foundationdb = { version = "0.8.0", default-features = false, features = [
|
||||
"embedded-fdb-include",
|
||||
], optional = true }
|
||||
fst = "0.4.7"
|
||||
futures = "0.3.29"
|
||||
fuzzy-matcher = "0.3.7"
|
||||
geo = { version = "0.27.0", features = ["use-serde"] }
|
||||
hex = { version = "0.4.3" }
|
||||
indxdb = { version = "0.4.0", optional = true }
|
||||
ipnet = "2.9.0"
|
||||
js = { version = "0.4.2", package = "rquickjs", features = [
|
||||
"array-buffer",
|
||||
"bindgen",
|
||||
"classes",
|
||||
"futures",
|
||||
"loader",
|
||||
"macro",
|
||||
"parallel",
|
||||
"properties",
|
||||
"rust-alloc",
|
||||
], optional = true }
|
||||
jsonwebtoken = { version = "8.3.0-surreal.1", package = "surrealdb-jsonwebtoken" }
|
||||
lexicmp = "0.1.0"
|
||||
md-5 = "0.10.6"
|
||||
nanoid = "0.4.0"
|
||||
ndarray = { version = "0.15.6", optional = true }
|
||||
nom = { version = "7.1.3", features = ["alloc"] }
|
||||
num_cpus = "1.16.0"
|
||||
object_store = { version = "0.8.0", optional = false }
|
||||
once_cell = "1.18.0"
|
||||
pbkdf2 = { version = "0.12.2", features = ["simple"] }
|
||||
pin-project-lite = "0.2.13"
|
||||
quick_cache = "0.4.0"
|
||||
radix_trie = { version = "0.2.1", features = ["serde"] }
|
||||
rand = "0.8.5"
|
||||
regex = "1.10.2"
|
||||
reqwest = { version = "0.11.22", default-features = false, features = [
|
||||
"json",
|
||||
"stream",
|
||||
"multipart",
|
||||
], optional = true }
|
||||
revision = "0.5.0"
|
||||
roaring = { version = "0.10.2", features = ["serde"] }
|
||||
rocksdb = { version = "0.21.0", features = ["lz4", "snappy"], optional = true }
|
||||
rust_decimal = { version = "1.33.1", features = ["maths", "serde-str"] }
|
||||
rust-stemmers = "1.2.0"
|
||||
scrypt = "0.11.0"
|
||||
semver = { version = "1.0.20", features = ["serde"] }
|
||||
serde = { version = "1.0.193", features = ["derive"] }
|
||||
serde_json = "1.0.108"
|
||||
sha1 = "0.10.6"
|
||||
sha2 = "0.10.8"
|
||||
snap = "1.1.0"
|
||||
speedb = { version = "0.0.4", features = ["lz4", "snappy"], optional = true }
|
||||
storekey = "0.5.0"
|
||||
surrealml-core = { version = "0.0.7", optional = true }
|
||||
thiserror = "1.0.50"
|
||||
tikv = { version = "0.2.0-surreal.2", default-features = false, package = "surrealdb-tikv-client", optional = true }
|
||||
tracing = "0.1.40"
|
||||
trice = "0.4.0"
|
||||
ulid = { version = "1.1.0", features = ["serde"] }
|
||||
url = "2.5.0"
|
||||
phf = { version = "0.11.2", features = ["macros", "unicase"], optional = true }
|
||||
unicase = { version = "2.7.0", optional = true }
|
||||
arbitrary = { version = "1.3.2", features = ["derive"], optional = true }
|
||||
regex-syntax = { version = "0.8.2", optional = true, features = ["arbitrary"] }
|
||||
geo-types = { version = "0.7.12", features = ["arbitrary"] }
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = { version = "0.5.1", features = ["async_tokio"] }
|
||||
env_logger = "0.10.1"
|
||||
pprof = { version = "0.13.0", features = ["flamegraph", "criterion"] }
|
||||
serial_test = "2.0.0"
|
||||
temp-dir = "0.1.11"
|
||||
test-log = { version = "0.2.13", features = ["trace"] }
|
||||
time = { version = "0.3.30", features = ["serde"] }
|
||||
tokio = { version = "1.34.0", features = ["macros", "sync", "rt-multi-thread"] }
|
||||
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
||||
wiremock = "0.5.22"
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
pharos = "0.5.3"
|
||||
ring = { version = "0.17.7", features = ["wasm32_unknown_unknown_js"] } # Make ring-based dependencies work on Wasm
|
||||
tokio = { version = "1.34.0", default-features = false, features = ["rt", "sync"] }
|
||||
uuid = { version = "1.6.1", features = ["serde", "js", "v4", "v7"] }
|
||||
wasm-bindgen-futures = "0.4.39"
|
||||
wasmtimer = { version = "0.2.0", default-features = false, features = [
|
||||
"tokio",
|
||||
] }
|
||||
ws_stream_wasm = "0.7.4"
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
tokio = { version = "1.34.0", default-features = false, features = [
|
||||
"macros",
|
||||
"io-util",
|
||||
"io-std",
|
||||
"fs",
|
||||
"rt-multi-thread",
|
||||
"time",
|
||||
"sync",
|
||||
] }
|
||||
tokio-tungstenite = { version = "0.20.1", optional = true }
|
||||
uuid = { version = "1.6.1", features = ["serde", "v4", "v7"] }
|
|
@ -6,7 +6,7 @@ use once_cell::sync::Lazy;
|
|||
pub const MAX_CONCURRENT_TASKS: usize = 64;
|
||||
|
||||
/// Specifies how deep various forms of computation will go before the query fails
|
||||
/// with [`crate::error::Db::ComputationDepthExceeded`].
|
||||
/// with [`crate::err::Error::ComputationDepthExceeded`].
|
||||
///
|
||||
/// For reference, use ~15 per MiB of stack in release mode.
|
||||
///
|
|
@ -153,67 +153,6 @@ impl<T: Target + Hash + Eq + PartialEq + std::fmt::Display> std::fmt::Display fo
|
|||
}
|
||||
}
|
||||
|
||||
/// Capabilities are used to limit what a user can do to the system.
|
||||
///
|
||||
/// Capabilities are split into 4 categories:
|
||||
/// - Scripting: Whether or not the user can execute scripts
|
||||
/// - Guest access: Whether or not a non-authenticated user can execute queries on the system when authentication is enabled.
|
||||
/// - Functions: Whether or not the user can execute certain functions
|
||||
/// - Network: Whether or not the user can access certain network addresses
|
||||
///
|
||||
/// Capabilities are configured globally. By default, capabilities are configured as:
|
||||
/// - Scripting: false
|
||||
/// - Guest access: false
|
||||
/// - Functions: All functions are allowed
|
||||
/// - Network: No network address is allowed nor denied, hence all network addresses are denied unless explicitly allowed
|
||||
///
|
||||
/// The capabilities are defined using allow/deny lists for fine-grained control.
|
||||
///
|
||||
/// Examples:
|
||||
/// - Allow all functions: `--allow-funcs`
|
||||
/// - Allow all functions except `http.*`: `--allow-funcs --deny-funcs 'http.*'`
|
||||
/// - Allow all network addresses except AWS metadata endpoint: `--allow-net --deny-net='169.254.169.254'`
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Create a new instance, and allow all capabilities
|
||||
#[cfg_attr(feature = "kv-rocksdb", doc = "```no_run")]
|
||||
#[cfg_attr(not(feature = "kv-rocksdb"), doc = "```ignore")]
|
||||
/// # use surrealdb::opt::capabilities::Capabilities;
|
||||
/// # use surrealdb::opt::Config;
|
||||
/// # use surrealdb::Surreal;
|
||||
/// # use surrealdb::engine::local::File;
|
||||
/// # #[tokio::main]
|
||||
/// # async fn main() -> surrealdb::Result<()> {
|
||||
/// let capabilities = Capabilities::all();
|
||||
/// let config = Config::default().capabilities(capabilities);
|
||||
/// let db = Surreal::new::<File>(("temp.db", config)).await?;
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
///
|
||||
/// Create a new instance, and allow certain functions
|
||||
#[cfg_attr(feature = "kv-rocksdb", doc = "```no_run")]
|
||||
#[cfg_attr(not(feature = "kv-rocksdb"), doc = "```ignore")]
|
||||
/// # use std::str::FromStr;
|
||||
/// # use surrealdb::engine::local::File;
|
||||
/// # use surrealdb::opt::capabilities::Capabilities;
|
||||
/// # use surrealdb::opt::capabilities::FuncTarget;
|
||||
/// # use surrealdb::opt::capabilities::Targets;
|
||||
/// # use surrealdb::opt::Config;
|
||||
/// # use surrealdb::Surreal;
|
||||
/// # #[tokio::main]
|
||||
/// # async fn main() -> surrealdb::Result<()> {
|
||||
/// let capabilities = Capabilities::default()
|
||||
/// .with_functions(Targets::<FuncTarget>::All)
|
||||
/// .without_functions(Targets::<FuncTarget>::Some(
|
||||
/// [FuncTarget::from_str("http::*").unwrap()].into(),
|
||||
/// ));
|
||||
/// let config = Config::default().capabilities(capabilities);
|
||||
/// let db = Surreal::new::<File>(("temp.db", config)).await?;
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Capabilities {
|
||||
scripting: bool,
|
|
@ -40,7 +40,8 @@ impl Response {
|
|||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "UPPERCASE")]
|
||||
pub(crate) enum Status {
|
||||
#[doc(hidden)]
|
||||
pub enum Status {
|
||||
Ok,
|
||||
Err,
|
||||
}
|
0
lib/src/env/mod.rs → core/src/env/mod.rs
vendored
0
lib/src/env/mod.rs → core/src/env/mod.rs
vendored
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue