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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@
/deps/artifacts/
/deps/curl-*/
/deps/aws-lambda-cpp-*/
/src/native/rust/target/
/src/native/build/
/src/node_modules/
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ The RIC enables communication between your Lambda function code and the Lambda R
npm install aws-lambda-ric
```

### Experimental Rust client on Linux

This branch includes an opt-in Rust implementation of `rapid-client.node`.
The default install still builds the C++ client. To use Rust from this checkout,
install Cargo and a Linux linker, then run

```bash
RIC_NATIVE_CLIENT=rust npm ci
npm run build
npm run test:native
npm run test:stream
```

See the [native client experiment](test/native/README.md) for scope, limitations
and benchmark instructions.

## Usage

### Basic Usage
Expand Down
53 changes: 52 additions & 1 deletion THIRD-PARTY-LICENSES
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,55 @@ OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of a copyright holder shall not
be used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization of the copyright holder.
in this Software without prior written authorization of the copyright holder.

** httparse-1.10.1 (optional Rust addon)

Copyright (c) 2015-2025 Sean McArthur

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.


** libc-0.2.191 (optional Rust addon)

Copyright (c) The Rust Project Developers

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
"scripts": {
"preinstall": "./scripts/preinstall.sh",
"postinstall": "./scripts/postinstall.sh",
"build:rust": "./scripts/build-rust.sh",
"test:native": "node --test test/native/contract.mjs",
"test:stream": "node --test test/native/stream.mjs",
"bench:native": "node test/native/bench.mjs",
"build:gyp": "node-gyp rebuild --directory=src/native",
"clean": "rm -rf dist coverage",
"build": "npm test && npm run compile && npm run pkg",
Expand All @@ -41,6 +45,10 @@
"deps/*.tar.xz",
"src/native/binding.gyp",
"src/native/rapid-client.cc",
"src/native/rust/Cargo.toml",
"src/native/rust/Cargo.lock",
"src/native/rust/src/*.rs",
"scripts/build-rust.sh",
"scripts/preinstall.sh",
"scripts/postinstall.sh",
"LICENSE",
Expand Down
21 changes: 21 additions & 0 deletions scripts/build-rust.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh
set -eu

cd "$(dirname "$0")/.."
if [ "$(uname -s)" != Linux ]; then
echo "The experimental Rust client requires Linux." >&2
exit 1
fi

crate=src/native/rust
target="$crate/target"
case "$PWD" in
*/node_modules/*)
target=$(mktemp -d)
trap 'rm -rf "$target"' EXIT
;;
esac
cargo build --manifest-path "$crate/Cargo.toml" --target-dir "$target" --release --locked
# Rename instead of truncating a shared object that might still be mapped.
cp "$target/release/librapid_client.so" rapid-client.tmp.node
mv rapid-client.tmp.node rapid-client.node
5 changes: 5 additions & 0 deletions scripts/postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ PACKAGE_DIR=$(cd "$SCRIPT_DIR/.." && pwd)
DEPS_DIR="$PACKAGE_DIR/deps"
ARTIFACTS_DIR="$DEPS_DIR/artifacts"

# Opt in at install time. Keep the existing C++ build as the default.
if [ "${RIC_NATIVE_CLIENT:-}" = "rust" ]; then
exec "$SCRIPT_DIR/build-rust.sh"
fi

# OS detection - skip on macOS
if [ "$(uname)" = "Darwin" ]; then
echo "aws-lambda-cpp does not build on OS X. Skipping the postinstall step."
Expand Down
5 changes: 5 additions & 0 deletions scripts/preinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ PACKAGE_DIR=$(cd "$SCRIPT_DIR/.." && pwd)
DEPS_DIR="$PACKAGE_DIR/deps"
ARTIFACTS_DIR="$DEPS_DIR/artifacts"

# Opt in at install time. Keep the existing C++ build as the default.
if [ "${RIC_NATIVE_CLIENT:-}" = "rust" ]; then
exit 0
fi

# OS detection - skip on macOS
if [ "$(uname)" = "Darwin" ]; then
echo "aws-lambda-cpp does not build on OS X. Skipping the preinstall step."
Expand Down
23 changes: 23 additions & 0 deletions src/native/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions src/native/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "rapid-client"
version = "0.1.0"
license = "Apache-2.0"
edition = "2024"
rust-version = "1.85"
publish = false

[lib]
crate-type = ["cdylib"]

[dependencies]
httparse = { version = "1.10.1", default-features = false }
libc = { version = "0.2", default-features = false }

[profile.dev]
panic = "abort"

[profile.release]
panic = "abort"
lto = true
codegen-units = 1
strip = "symbols"
Loading