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
|
run: cargo install --debug --locked cargo-make
|
||||||
|
|
||||||
- name: Test workspace for experimental_parser
|
- name: Test workspace for experimental_parser
|
||||||
|
env:
|
||||||
|
RUSTFLAGS: "--cfg surrealdb_unstable"
|
||||||
run: cargo make test-experimental-parser
|
run: cargo make test-experimental-parser
|
||||||
|
|
||||||
ws-engine:
|
ws-engine:
|
||||||
|
|
88
Cargo.lock
generated
88
Cargo.lock
generated
|
@ -652,17 +652,6 @@ dependencies = [
|
||||||
"tracing",
|
"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]]
|
[[package]]
|
||||||
name = "axum-core"
|
name = "axum-core"
|
||||||
version = "0.3.4"
|
version = "0.3.4"
|
||||||
|
@ -1917,16 +1906,6 @@ dependencies = [
|
||||||
"percent-encoding",
|
"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]]
|
[[package]]
|
||||||
name = "foundationdb"
|
name = "foundationdb"
|
||||||
version = "0.8.0"
|
version = "0.8.0"
|
||||||
|
@ -3278,12 +3257,6 @@ dependencies = [
|
||||||
"minimal-lexical",
|
"minimal-lexical",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "nonempty"
|
|
||||||
version = "0.7.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e9e591e719385e6ebaeb5ce5d3887f7d5676fceca6411d1925ccc95745f3d6f7"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-ansi-term"
|
name = "nu-ansi-term"
|
||||||
version = "0.46.0"
|
version = "0.46.0"
|
||||||
|
@ -5283,7 +5256,6 @@ dependencies = [
|
||||||
"argon2",
|
"argon2",
|
||||||
"assert_fs",
|
"assert_fs",
|
||||||
"axum 0.6.20",
|
"axum 0.6.20",
|
||||||
"axum-client-ip",
|
|
||||||
"axum-extra",
|
"axum-extra",
|
||||||
"axum-server",
|
"axum-server",
|
||||||
"base64 0.21.7",
|
"base64 0.21.7",
|
||||||
|
@ -5297,10 +5269,8 @@ dependencies = [
|
||||||
"http 0.2.11",
|
"http 0.2.11",
|
||||||
"http-body 0.4.6",
|
"http-body 0.4.6",
|
||||||
"hyper 0.14.28",
|
"hyper 0.14.28",
|
||||||
"ipnet",
|
|
||||||
"jemallocator",
|
"jemallocator",
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
"ndarray",
|
|
||||||
"nix 0.27.1",
|
"nix 0.27.1",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"opentelemetry",
|
"opentelemetry",
|
||||||
|
@ -5318,7 +5288,6 @@ dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serial_test",
|
"serial_test",
|
||||||
"surrealdb",
|
"surrealdb",
|
||||||
"surrealml-core",
|
|
||||||
"temp-env",
|
"temp-env",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"test-log",
|
"test-log",
|
||||||
|
@ -5342,6 +5311,56 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "surrealdb"
|
name = "surrealdb"
|
||||||
version = "1.1.1"
|
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 = [
|
dependencies = [
|
||||||
"addr",
|
"addr",
|
||||||
"any_ascii",
|
"any_ascii",
|
||||||
|
@ -5361,28 +5380,23 @@ dependencies = [
|
||||||
"dmp",
|
"dmp",
|
||||||
"echodb",
|
"echodb",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"flume",
|
|
||||||
"foundationdb",
|
"foundationdb",
|
||||||
"fst",
|
"fst",
|
||||||
"futures",
|
"futures",
|
||||||
"futures-concurrency",
|
|
||||||
"fuzzy-matcher",
|
"fuzzy-matcher",
|
||||||
"geo 0.27.0",
|
"geo 0.27.0",
|
||||||
"geo-types",
|
"geo-types",
|
||||||
"hex",
|
"hex",
|
||||||
"indexmap 2.1.0",
|
|
||||||
"indxdb",
|
"indxdb",
|
||||||
"ipnet",
|
"ipnet",
|
||||||
"lexicmp",
|
"lexicmp",
|
||||||
"md-5",
|
"md-5",
|
||||||
"nanoid",
|
"nanoid",
|
||||||
"native-tls",
|
|
||||||
"ndarray",
|
"ndarray",
|
||||||
"nom",
|
"nom",
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
"object_store",
|
"object_store",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"path-clean",
|
|
||||||
"pbkdf2",
|
"pbkdf2",
|
||||||
"pharos",
|
"pharos",
|
||||||
"phf",
|
"phf",
|
||||||
|
@ -5401,7 +5415,6 @@ dependencies = [
|
||||||
"rquickjs",
|
"rquickjs",
|
||||||
"rust-stemmers",
|
"rust-stemmers",
|
||||||
"rust_decimal",
|
"rust_decimal",
|
||||||
"rustls",
|
|
||||||
"scrypt",
|
"scrypt",
|
||||||
"semver",
|
"semver",
|
||||||
"serde",
|
"serde",
|
||||||
|
@ -5422,7 +5435,6 @@ dependencies = [
|
||||||
"time",
|
"time",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-tungstenite",
|
"tokio-tungstenite",
|
||||||
"tokio-util",
|
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
"trice",
|
"trice",
|
||||||
|
|
11
Cargo.toml
11
Cargo.toml
|
@ -17,12 +17,13 @@ storage-fdb = ["surrealdb/kv-fdb-7_1"]
|
||||||
scripting = ["surrealdb/scripting"]
|
scripting = ["surrealdb/scripting"]
|
||||||
http = ["surrealdb/http"]
|
http = ["surrealdb/http"]
|
||||||
http-compression = []
|
http-compression = []
|
||||||
ml = ["surrealdb/ml", "surrealml-core"]
|
ml = ["surrealdb/ml"]
|
||||||
experimental-parser = ["surrealdb/experimental-parser"]
|
|
||||||
jwks = ["surrealdb/jwks"]
|
jwks = ["surrealdb/jwks"]
|
||||||
|
sql2 = ["surrealdb/sql2"]
|
||||||
|
parser2 = ["surrealdb/parser2"]
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["lib", "lib/examples/actix", "lib/examples/axum"]
|
members = ["core", "lib", "lib/examples/actix", "lib/examples/axum"]
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = true
|
lto = true
|
||||||
|
@ -37,7 +38,6 @@ strip = false
|
||||||
[dependencies]
|
[dependencies]
|
||||||
argon2 = "0.5.2"
|
argon2 = "0.5.2"
|
||||||
axum = { version = "0.6.20", features = ["tracing", "ws", "headers"] }
|
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-extra = { version = "0.7.7", features = ["query", "typed-routing"] }
|
||||||
axum-server = { version = "0.5.1", features = ["tls-rustls"] }
|
axum-server = { version = "0.5.1", features = ["tls-rustls"] }
|
||||||
base64 = "0.21.5"
|
base64 = "0.21.5"
|
||||||
|
@ -55,8 +55,6 @@ glob = "0.3.1"
|
||||||
http = "0.2.11"
|
http = "0.2.11"
|
||||||
http-body = "0.4.5"
|
http-body = "0.4.5"
|
||||||
hyper = "0.14.27"
|
hyper = "0.14.27"
|
||||||
ipnet = "2.9.0"
|
|
||||||
ndarray = { version = "0.15.6", optional = true }
|
|
||||||
once_cell = "1.18.0"
|
once_cell = "1.18.0"
|
||||||
opentelemetry = { version = "0.19", features = ["rt-tokio"] }
|
opentelemetry = { version = "0.19", features = ["rt-tokio"] }
|
||||||
opentelemetry-otlp = { version = "0.12.0", features = ["metrics"] }
|
opentelemetry-otlp = { version = "0.12.0", features = ["metrics"] }
|
||||||
|
@ -76,7 +74,6 @@ surrealdb = { version = "1", path = "lib", features = [
|
||||||
"protocol-ws",
|
"protocol-ws",
|
||||||
"rustls",
|
"rustls",
|
||||||
] }
|
] }
|
||||||
surrealml-core = { version = "0.0.7", optional = true }
|
|
||||||
tempfile = "3.8.1"
|
tempfile = "3.8.1"
|
||||||
thiserror = "1.0.50"
|
thiserror = "1.0.50"
|
||||||
tokio = { version = "1.34.0", features = ["macros", "signal"] }
|
tokio = { version = "1.34.0", features = ["macros", "signal"] }
|
||||||
|
|
|
@ -10,11 +10,13 @@ args = ["check", "--locked", "--workspace"]
|
||||||
[tasks.ci-check-wasm]
|
[tasks.ci-check-wasm]
|
||||||
category = "CI - CHECK"
|
category = "CI - CHECK"
|
||||||
command = "cargo"
|
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"]
|
args = ["check", "--locked", "--package", "surrealdb", "--features", "protocol-ws,protocol-http,kv-mem,kv-indxdb,http,jwks", "--target", "wasm32-unknown-unknown"]
|
||||||
|
|
||||||
[tasks.ci-clippy]
|
[tasks.ci-clippy]
|
||||||
category = "CI - CHECK"
|
category = "CI - CHECK"
|
||||||
command = "cargo"
|
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"]
|
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]
|
[tasks.ci-cli-integration]
|
||||||
category = "CI - INTEGRATION TESTS"
|
category = "CI - INTEGRATION TESTS"
|
||||||
command = "cargo"
|
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"]
|
args = ["test", "--locked", "--no-default-features", "--features", "storage-mem,http,scripting,jwks", "--workspace", "--test", "cli_integration", "--", "cli_integration", "--nocapture"]
|
||||||
|
|
||||||
[tasks.ci-http-integration]
|
[tasks.ci-http-integration]
|
||||||
category = "CI - INTEGRATION TESTS"
|
category = "CI - INTEGRATION TESTS"
|
||||||
command = "cargo"
|
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"]
|
args = ["test", "--locked", "--no-default-features", "--features", "storage-mem,http-compression,jwks", "--workspace", "--test", "http_integration", "--", "http_integration", "--nocapture"]
|
||||||
|
|
||||||
[tasks.ci-ws-integration]
|
[tasks.ci-ws-integration]
|
||||||
category = "WS - INTEGRATION TESTS"
|
category = "WS - INTEGRATION TESTS"
|
||||||
command = "cargo"
|
command = "cargo"
|
||||||
env = { RUST_LOG={ value = "ws_integration=debug", condition = { env_not_set = ["RUST_LOG"] } } }
|
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", "--workspace", "--test", "ws_integration", "--", "ws_integration", "--nocapture"]
|
args = ["test", "--locked", "--no-default-features", "--features", "storage-mem,sql2", "--workspace", "--test", "ws_integration", "--", "ws_integration", "--nocapture"]
|
||||||
|
|
||||||
[tasks.ci-ml-integration]
|
[tasks.ci-ml-integration]
|
||||||
category = "ML - INTEGRATION TESTS"
|
category = "ML - INTEGRATION TESTS"
|
||||||
command = "cargo"
|
command = "cargo"
|
||||||
env = { RUST_LOG={ value = "cli_integration::common=debug", condition = { env_not_set = ["RUST_LOG"] } } }
|
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", "--workspace", "--test", "ml_integration", "--", "ml_integration", "--nocapture"]
|
args = ["test", "--locked", "--features", "storage-mem,ml,sql2", "--workspace", "--test", "ml_integration", "--", "ml_integration", "--nocapture"]
|
||||||
|
|
||||||
[tasks.ci-workspace-coverage]
|
[tasks.ci-workspace-coverage]
|
||||||
category = "CI - INTEGRATION TESTS"
|
category = "CI - INTEGRATION TESTS"
|
||||||
command = "cargo"
|
command = "cargo"
|
||||||
|
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||||
args = [
|
args = [
|
||||||
"llvm-cov", "--html", "--locked", "--no-default-features", "--features", "storage-mem,scripting,http,jwks", "--workspace", "--",
|
"llvm-cov", "--html", "--locked", "--no-default-features", "--features", "storage-mem,scripting,http,jwks", "--workspace", "--",
|
||||||
"--skip", "api_integration",
|
"--skip", "api_integration",
|
||||||
|
@ -60,8 +63,9 @@ args = [
|
||||||
[tasks.test-experimental-parser]
|
[tasks.test-experimental-parser]
|
||||||
category = "CI - INTEGRATION TESTS"
|
category = "CI - INTEGRATION TESTS"
|
||||||
command = "cargo"
|
command = "cargo"
|
||||||
|
env = { RUSTFLAGS = "--cfg surrealdb_unstable", RUSTDOCFLAGS="--cfg surrealdb_unstable" }
|
||||||
args = [
|
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", "api_integration",
|
||||||
"--skip", "cli_integration",
|
"--skip", "cli_integration",
|
||||||
"--skip", "http_integration",
|
"--skip", "http_integration",
|
||||||
|
@ -71,7 +75,8 @@ args = [
|
||||||
[tasks.test-workspace-coverage-complete]
|
[tasks.test-workspace-coverage-complete]
|
||||||
category = "CI - INTEGRATION TESTS"
|
category = "CI - INTEGRATION TESTS"
|
||||||
command = "cargo"
|
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]
|
[tasks.ci-workspace-coverage-complete]
|
||||||
env = { _START_SURREALDB_PATH = "memory" }
|
env = { _START_SURREALDB_PATH = "memory" }
|
||||||
|
@ -85,16 +90,18 @@ run_task = { name = ["start-surrealdb", "test-workspace-coverage-complete", "sto
|
||||||
[tasks.test-kvs]
|
[tasks.test-kvs]
|
||||||
private = true
|
private = true
|
||||||
command = "cargo"
|
command = "cargo"
|
||||||
|
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||||
args = ["test", "--locked", "--package", "surrealdb", "--no-default-features", "--features", "${_TEST_FEATURES}", "--lib", "kvs"]
|
args = ["test", "--locked", "--package", "surrealdb", "--no-default-features", "--features", "${_TEST_FEATURES}", "--lib", "kvs"]
|
||||||
|
|
||||||
|
|
||||||
[tasks.test-api-integration]
|
[tasks.test-api-integration]
|
||||||
private = true
|
private = true
|
||||||
command = "cargo"
|
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}"]
|
args = ["test", "--locked", "--package", "surrealdb", "--no-default-features", "--features", "${_TEST_FEATURES}", "--test", "api", "api_integration::${_TEST_API_ENGINE}"]
|
||||||
|
|
||||||
[tasks.ci-api-integration]
|
[tasks.ci-api-integration]
|
||||||
env = { _START_SURREALDB_PATH = "memory" }
|
env = { _START_SURREALDB_PATH = "memory", RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||||
private = true
|
private = true
|
||||||
run_task = { name = ["start-surrealdb", "test-api-integration", "stop-surrealdb"], fork = 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]
|
[tasks.ci-api-integration-ws]
|
||||||
category = "CI - INTEGRATION TESTS"
|
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"
|
run_task = "ci-api-integration"
|
||||||
|
|
||||||
[tasks.ci-api-integration-any]
|
[tasks.ci-api-integration-any]
|
||||||
|
@ -232,7 +239,8 @@ script = "kill $(cat /tmp/tiup.pid) || true"
|
||||||
[tasks.build-surrealdb]
|
[tasks.build-surrealdb]
|
||||||
category = "CI - BUILD"
|
category = "CI - BUILD"
|
||||||
command = "cargo"
|
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
|
# Benchmarks - Common
|
||||||
|
@ -240,6 +248,7 @@ args = ["build", "--locked", "--no-default-features", "--features", "storage-mem
|
||||||
[tasks.ci-bench]
|
[tasks.ci-bench]
|
||||||
category = "CI - BENCHMARK"
|
category = "CI - BENCHMARK"
|
||||||
command = "cargo"
|
command = "cargo"
|
||||||
|
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||||
args = ["bench", "--quiet", "--package", "surrealdb", "--no-default-features", "--features", "kv-mem,scripting,http,jwks", "${@}"]
|
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_DURATION = { value = "30", condition = { env_not_set = ["BENCH_DURATION"] } }
|
||||||
BENCH_SAMPLE_SIZE = { value = "10", condition = { env_not_set = ["BENCH_SAMPLE_SIZE"] } }
|
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"] } }
|
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]
|
[tasks.bench-target]
|
||||||
private = true
|
private = true
|
||||||
category = "CI - BENCHMARK - SurrealDB Target"
|
category = "CI - BENCHMARK - SurrealDB Target"
|
||||||
command = "cargo"
|
command = "cargo"
|
||||||
|
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||||
args = ["bench", "--package", "surrealdb", "--bench", "sdb", "--no-default-features", "--features", "${BENCH_FEATURES}", "${@}"]
|
args = ["bench", "--package", "surrealdb", "--bench", "sdb", "--no-default-features", "--features", "${BENCH_FEATURES}", "${@}"]
|
||||||
|
|
||||||
[tasks.bench-lib-mem]
|
[tasks.bench-lib-mem]
|
||||||
|
|
|
@ -17,19 +17,21 @@ dependencies = ["cargo-upgrade", "cargo-update"]
|
||||||
[tasks.docs]
|
[tasks.docs]
|
||||||
category = "LOCAL USAGE"
|
category = "LOCAL USAGE"
|
||||||
command = "cargo"
|
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
|
# Test
|
||||||
[tasks.test]
|
[tasks.test]
|
||||||
category = "LOCAL USAGE"
|
category = "LOCAL USAGE"
|
||||||
command = "cargo"
|
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"]
|
args = ["test", "--workspace", "--no-fail-fast"]
|
||||||
|
|
||||||
# Check
|
# Check
|
||||||
[tasks.cargo-check]
|
[tasks.cargo-check]
|
||||||
category = "LOCAL USAGE"
|
category = "LOCAL USAGE"
|
||||||
command = "cargo"
|
command = "cargo"
|
||||||
|
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||||
args = ["check", "--workspace", "--features", "${DEV_FEATURES}"]
|
args = ["check", "--workspace", "--features", "${DEV_FEATURES}"]
|
||||||
|
|
||||||
[tasks.cargo-fmt]
|
[tasks.cargo-fmt]
|
||||||
|
@ -42,12 +44,13 @@ category = "LOCAL USAGE"
|
||||||
script = """
|
script = """
|
||||||
set -e
|
set -e
|
||||||
cd ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/
|
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]
|
[tasks.cargo-clippy]
|
||||||
category = "LOCAL USAGE"
|
category = "LOCAL USAGE"
|
||||||
command = "cargo"
|
command = "cargo"
|
||||||
|
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||||
args = ["clippy", "--all-targets", "--all-features", "--", "-D", "warnings"]
|
args = ["clippy", "--all-targets", "--all-features", "--", "-D", "warnings"]
|
||||||
|
|
||||||
[tasks.check]
|
[tasks.check]
|
||||||
|
@ -68,24 +71,28 @@ args = ["clean"]
|
||||||
[tasks.bench]
|
[tasks.bench]
|
||||||
category = "LOCAL USAGE"
|
category = "LOCAL USAGE"
|
||||||
command = "cargo"
|
command = "cargo"
|
||||||
|
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||||
args = ["bench", "--package", "surrealdb", "--no-default-features", "--features", "kv-mem,http,scripting,jwks", "--", "${@}"]
|
args = ["bench", "--package", "surrealdb", "--no-default-features", "--features", "kv-mem,http,scripting,jwks", "--", "${@}"]
|
||||||
|
|
||||||
# Run
|
# Run
|
||||||
[tasks.run]
|
[tasks.run]
|
||||||
category = "LOCAL USAGE"
|
category = "LOCAL USAGE"
|
||||||
command = "cargo"
|
command = "cargo"
|
||||||
|
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||||
args = ["run", "--no-default-features", "--features", "${DEV_FEATURES}", "--", "${@}"]
|
args = ["run", "--no-default-features", "--features", "${DEV_FEATURES}", "--", "${@}"]
|
||||||
|
|
||||||
# Serve
|
# Serve
|
||||||
[tasks.serve]
|
[tasks.serve]
|
||||||
category = "LOCAL USAGE"
|
category = "LOCAL USAGE"
|
||||||
command = "cargo"
|
command = "cargo"
|
||||||
|
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||||
args = ["run", "--no-default-features", "--features", "${DEV_FEATURES}", "--", "start", "--allow-all", "${@}"]
|
args = ["run", "--no-default-features", "--features", "${DEV_FEATURES}", "--", "start", "--allow-all", "${@}"]
|
||||||
|
|
||||||
# SQL
|
# SQL
|
||||||
[tasks.sql]
|
[tasks.sql]
|
||||||
category = "LOCAL USAGE"
|
category = "LOCAL USAGE"
|
||||||
command = "cargo"
|
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", "${@}"]
|
args = ["run", "--no-default-features", "--features", "${DEV_FEATURES}", "--", "sql", "--conn", "ws://0.0.0.0:8000", "--multi", "--pretty", "${@}"]
|
||||||
|
|
||||||
# Quick
|
# Quick
|
||||||
|
@ -98,6 +105,7 @@ args = ["build", "${@}"]
|
||||||
[tasks.build]
|
[tasks.build]
|
||||||
category = "LOCAL USAGE"
|
category = "LOCAL USAGE"
|
||||||
command = "cargo"
|
command = "cargo"
|
||||||
|
env = { RUSTFLAGS = "--cfg surrealdb_unstable" }
|
||||||
args = ["build", "--release", "${@}"]
|
args = ["build", "--release", "${@}"]
|
||||||
|
|
||||||
# Default
|
# Default
|
||||||
|
|
14
cackle.toml
14
cackle.toml
|
@ -29,6 +29,7 @@ include = [
|
||||||
"mio::net",
|
"mio::net",
|
||||||
"surreal::net",
|
"surreal::net",
|
||||||
"surrealdb",
|
"surrealdb",
|
||||||
|
"surrealdb_core",
|
||||||
"tokio::net",
|
"tokio::net",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing_core",
|
"tracing_core",
|
||||||
|
@ -80,6 +81,12 @@ build.allow_build_instructions = [
|
||||||
]
|
]
|
||||||
allow_unsafe = true
|
allow_unsafe = true
|
||||||
|
|
||||||
|
[pkg.lru]
|
||||||
|
allow_unsafe = true
|
||||||
|
allow_apis = [
|
||||||
|
"net",
|
||||||
|
]
|
||||||
|
|
||||||
[pkg.bzip2-sys]
|
[pkg.bzip2-sys]
|
||||||
build.allow_apis = [
|
build.allow_apis = [
|
||||||
"fs",
|
"fs",
|
||||||
|
@ -1151,11 +1158,16 @@ allow_apis = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[pkg.surrealdb]
|
[pkg.surrealdb]
|
||||||
allow_unsafe = true
|
|
||||||
allow_apis = [
|
allow_apis = [
|
||||||
"fs",
|
"fs",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[pkg.surrealdb-core]
|
||||||
|
allow_unsafe = true
|
||||||
|
allow_apis = [
|
||||||
|
"net",
|
||||||
|
]
|
||||||
|
|
||||||
[pkg.assert_fs]
|
[pkg.assert_fs]
|
||||||
from.test.allow_apis = [
|
from.test.allow_apis = [
|
||||||
"fs",
|
"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;
|
pub const MAX_CONCURRENT_TASKS: usize = 64;
|
||||||
|
|
||||||
/// Specifies how deep various forms of computation will go before the query fails
|
/// 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.
|
/// 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)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Capabilities {
|
pub struct Capabilities {
|
||||||
scripting: bool,
|
scripting: bool,
|
|
@ -40,7 +40,8 @@ impl Response {
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "UPPERCASE")]
|
#[serde(rename_all = "UPPERCASE")]
|
||||||
pub(crate) enum Status {
|
#[doc(hidden)]
|
||||||
|
pub enum Status {
|
||||||
Ok,
|
Ok,
|
||||||
Err,
|
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