Skip to content

Commit 6ae4f43

Browse files
ardatandotansimha
authored andcommitted
New shared cargo package: hive-console-client
1 parent 0c62149 commit 6ae4f43

28 files changed

+732
-521
lines changed

.cargo/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# The following are aliases you can use with "cargo command_name"
2+
[alias]
3+
"clippy:fix" = "clippy --all --fix --allow-dirty --allow-staged"

.changeset/funny-rockets-speak.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'hive-console-sdk-rs': patch
3+
'hive-apollo-router-plugin': minor
4+
---
5+
6+
Extract Hive Console integration implementation into a new package `hive-console-sdk` which can
7+
be used by any Rust library for Hive Console integration
8+
9+
It also includes a refactor to use less Mutexes like replacing `lru` + `Mutex` with the thread-safe `moka` package.
10+
Only one place that handles queueing uses `Mutex` now.
11+
12+
13+
Fixes a bug when Persisted Operations are enabled by default which should be explicitly enabled

.github/workflows/apollo-router-release.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- main
77
paths:
88
- 'packages/libraries/router/**'
9+
- 'packages/libraries/sdk-rs/**'
910
- 'docker/router.dockerfile'
1011
- 'scripts/compress/**'
1112
- 'configs/cargo/Cargo.lock'
@@ -16,6 +17,7 @@ on:
1617
push:
1718
paths:
1819
- 'packages/libraries/router/**'
20+
- 'packages/libraries/sdk-rs/**'
1921
- 'docker/router.dockerfile'
2022
- 'scripts/compress/**'
2123
- 'configs/cargo/Cargo.lock'
@@ -60,7 +62,7 @@ jobs:
6062
github_org="graphql-hive"
6163
router_version=$(cargo tree -i apollo-router --quiet | head -n 1 | awk -F" v" '{print $2}')
6264
plugin_version=$(jq -r '.version' packages/libraries/router/package.json)
63-
has_changes=$(git diff HEAD~ HEAD --name-only -- 'packages/libraries/router/Cargo.toml' 'Cargo.lock' 'configs/cargo/Cargo.lock' 'packages/libraries/router/package.json')
65+
has_changes=$(git diff HEAD~ HEAD --name-only -- 'packages/libraries/router/Cargo.toml' 'packages/libraries/router/package.json' 'packages/libraries/sdk-rs/Cargo.toml' 'packages/libraries/sdk-rs/package.json' 'Cargo.lock' 'configs/cargo/Cargo.lock')
6466
6567
if [ "$has_changes" ]; then
6668
image_tag_version="router${router_version}-plugin${plugin_version}"

.github/workflows/publish-rust.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Look for changes
2828
id: rust_changed
2929
run: |
30-
lines=$( git diff HEAD~ HEAD --name-only -- 'packages/libraries/router' 'Cargo.toml' 'configs/cargo/Cargo.lock' | wc -l )
30+
lines=$( git diff HEAD~ HEAD --name-only -- 'packages/libraries/router' 'packages/libraries/sdk-rs' 'Cargo.toml' 'configs/cargo/Cargo.lock' | wc -l )
3131
if [ $lines -gt 0 ]; then
3232
echo 'rust_changed=true' >> $GITHUB_OUTPUT
3333
fi

.github/workflows/release-stable.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,8 @@ jobs:
123123
echo "crate_version=$VERSION" >> $GITHUB_OUTPUT
124124
echo "crate_publish=true" >> $GITHUB_OUTPUT
125125
126-
- name: release hive-apollo-router-plugin to Crates.io
126+
- name: release to Crates.io
127127
if: steps.rust-crate.outputs.crate_publish == 'true'
128128
run: |
129-
cd packages/libraries/router
130129
cargo login ${{ secrets.CARGO_REGISTRY_TOKEN }}
131130
cargo publish --allow-dirty --no-verify

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,11 @@
3939
],
4040
"[typescript]": {
4141
"editor.defaultFormatter": "esbenp.prettier-vscode"
42+
},
43+
"[yaml]": {
44+
"editor.defaultFormatter": "esbenp.prettier-vscode"
45+
},
46+
"[rust]": {
47+
"editor.defaultFormatter": "rust-lang.rust-analyzer"
4248
}
4349
}

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[workspace]
22
resolver = "2"
3-
members = ["packages/libraries/router", "scripts/compress"]
3+
members = ["packages/libraries/router", "scripts/compress", "packages/libraries/sdk-rs"]

configs/cargo/Cargo.lock

Lines changed: 30 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker/docker.hcl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,8 @@ target "app" {
361361
target "apollo-router" {
362362
inherits = ["router-base", get_target()]
363363
contexts = {
364-
pkg = "${PWD}/packages/libraries/router"
364+
router_pkg = "${PWD}/packages/libraries/router"
365+
sdk_rs_pkg = "${PWD}/packages/libraries/sdk-rs"
365366
config = "${PWD}/configs/cargo"
366367
}
367368
args = {

docker/router.dockerfile

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# syntax=docker/dockerfile:1
2-
FROM scratch AS pkg
2+
FROM scratch AS router_pkg
3+
FROM scratch AS sdk_rs_pkg
34
FROM scratch AS config
45

56
FROM rust:1.90-slim-bookworm AS build
@@ -12,21 +13,34 @@ RUN update-ca-certificates
1213
RUN rustup component add rustfmt
1314

1415
WORKDIR /usr/src
15-
# Create blank project
16+
# Create blank projects
1617
RUN USER=root cargo new router
18+
RUN USER=root cargo new sdk-rs
1719

1820
# Copy Cargo files
19-
COPY --from=pkg Cargo.toml /usr/src/router/
21+
COPY --from=router_pkg Cargo.toml /usr/src/router/
22+
COPY --from=sdk_rs_pkg Cargo.toml /usr/src/sdk-rs/
2023
COPY --from=config Cargo.lock /usr/src/router/
2124

25+
WORKDIR /usr/src/sdk-rs
26+
# Get the dependencies cached, so we can use dummy input files so Cargo wont fail
27+
RUN echo 'fn main() { println!(""); }' > ./src/main.rs
28+
RUN echo 'fn main() { println!(""); }' > ./src/lib.rs
29+
RUN cargo build --release
30+
31+
# Copy in the actual source code
32+
COPY --from=sdk_rs_pkg src ./src
33+
RUN touch ./src/main.rs
34+
RUN touch ./src/lib.rs
35+
2236
WORKDIR /usr/src/router
2337
# Get the dependencies cached, so we can use dummy input files so Cargo wont fail
2438
RUN echo 'fn main() { println!(""); }' > ./src/main.rs
2539
RUN echo 'fn main() { println!(""); }' > ./src/lib.rs
2640
RUN cargo build --release
2741

2842
# Copy in the actual source code
29-
COPY --from=pkg src ./src
43+
COPY --from=router_pkg src ./src
3044
RUN touch ./src/main.rs
3145
RUN touch ./src/lib.rs
3246

@@ -53,7 +67,7 @@ RUN mkdir /dist/schema
5367

5468
# Copy in the required files from our build image
5569
COPY --from=build --chown=root:root /usr/src/router/target/release/router /dist
56-
COPY --from=pkg router.yaml /dist/config/router.yaml
70+
COPY --from=router_pkg router.yaml /dist/config/router.yaml
5771

5872
WORKDIR /dist
5973

0 commit comments

Comments
 (0)