Skip to content

Commit 95f8493

Browse files
authored
refactor: change gateway to router, install.sh script (#368)
1 parent a39b05f commit 95f8493

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+311
-226
lines changed

.cargo/config.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# The following are aliases you can use with "cargo command_name"
22
[alias]
3-
gateway = "run --package gateway"
3+
router = "run --package router"
44
dev = "run --package qp-dev-cli"
55
subgraphs = "run --package subgraphs"
66
test_all = "test --workspace"
77
test_qp = "test --package query-planner -- --nocapture"
88
test_qpe = "test --package query-plan-executor -- --nocapture"
99
"clippy:fix" = "clippy --all --fix --allow-dirty --allow-staged"
10-
"router-config" = "run --release -p gateway-config router-config.schema.json"
10+
"router-config" = "run --release -p router-config router-config.schema.json"

.github/workflows/build.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ env:
2626
DOCKER_VENDOR: theguild
2727
DOCKER_PLATFORMS: linux/amd64,linux/arm64
2828
ZIG_VERSION: 0.14.1
29-
BINARY_NAME: gateway
29+
BINARY_NAME: hive_router
3030

3131
jobs:
3232
config:
@@ -90,7 +90,7 @@ jobs:
9090
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
9191
name: upload build artifact
9292
with:
93-
name: gateway_${{ matrix.name }}
93+
name: hive_router_${{ matrix.name }}
9494
path: target/${{ matrix.rust_target }}/release/${{ env.BINARY_NAME }}
9595
if-no-files-found: error
9696
- name: Upload binaries to release
@@ -99,7 +99,7 @@ jobs:
9999
with:
100100
repo_token: ${{ secrets.GITHUB_TOKEN }}
101101
file: target/${{ matrix.rust_target }}/release/${{ env.BINARY_NAME }}
102-
asset_name: gateway_${{ matrix.name }}
102+
asset_name: hive_router_${{ matrix.name }}
103103
tag: ${{ github.ref }}
104104
docker:
105105
runs-on: ubuntu-latest
@@ -129,14 +129,14 @@ jobs:
129129
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5
130130
with:
131131
path: artifacts
132-
pattern: gateway_*
132+
pattern: hive_router_*
133133
- name: prepare artifacts
134134
run: |
135135
mkdir -p ./target/linux/arm64
136136
mkdir -p ./target/linux/amd64
137137
138-
mv ./artifacts/gateway_linux_arm64/gateway ./target/linux/arm64/gateway
139-
mv ./artifacts/gateway_linux_amd64/gateway ./target/linux/amd64/gateway
138+
mv ./artifacts/${{ env.BINARY_NAME }}_linux_arm64/${{ env.BINARY_NAME }} ./target/linux/arm64/${{ env.BINARY_NAME }}
139+
mv ./artifacts/${{ env.BINARY_NAME }}_linux_amd64/${{ env.BINARY_NAME }} ./target/linux/amd64/${{ env.BINARY_NAME }}
140140
ls -ltra ./target/linux/arm64/
141141
ls -ltra ./target/linux/amd64/
142142
- uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
@@ -148,7 +148,7 @@ jobs:
148148
id: docker
149149
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
150150
with:
151-
file: ./docker/gateway.Dockerfile
151+
file: ./docker/router.Dockerfile
152152
context: .
153153
platforms: ${{ env.DOCKER_PLATFORMS }}
154154
push: true

.github/workflows/ci.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ jobs:
7070
- name: cargo clippy
7171
run: cargo clippy --all
7272

73-
unit-benchmark:
73+
benchmark:
7474
strategy:
7575
matrix:
7676
include:
77-
- name: "Query Planner"
77+
- name: "query-planner"
7878
package: "./lib/query-planner"
79-
- name: "Executor"
79+
- name: "executor"
8080
package: "./lib/executor"
81-
name: ${{ matrix.name }} Benchmark
81+
name: benchmark / ${{ matrix.name }}
8282
runs-on: ubuntu-latest
8383
steps:
8484
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
@@ -99,8 +99,8 @@ jobs:
9999
name: ${{matrix.package}}-benchmark-results
100100
path: ${{matrix.package}}/target/criterion
101101

102-
k6-benchmark:
103-
name: Overall K6 Benchmark
102+
router-benchmark:
103+
name: benchmark / router
104104
runs-on: ubuntu-latest
105105
env:
106106
NODE_NO_WARNINGS: true
@@ -120,10 +120,10 @@ jobs:
120120
run: cargo build --release -p subgraphs
121121
- name: Run subgraphs
122122
run: ./target/release/subgraphs & sleep 5
123-
- name: Build gateway
124-
run: cargo build --release -p gateway
125-
- name: Run gateway
126-
run: ./target/release/gateway & sleep 5
123+
- name: Build router
124+
run: cargo build --release -p router
125+
- name: Run router
126+
run: ./target/release/hive_router & sleep 5
127127
env:
128128
HIVE_SUPERGRAPH_SOURCE: file
129129
HIVE_SUPERGRAPH_PATH: bench/supergraph.graphql
@@ -179,7 +179,7 @@ jobs:
179179
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
180180
with:
181181
node-version-file: audits/.node-version
182-
- run: cargo build --package gateway
182+
- run: cargo build --package router
183183
- run: npm install
184184
working-directory: audits
185185
- run: npm run test:federation-all

.zed/debug.json

Lines changed: 0 additions & 28 deletions
This file was deleted.

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
[workspace]
22
members = [
33
"lib/query-planner",
4-
"lib/gateway-config",
4+
"lib/router-config",
55
"lib/wasm-lib",
66
"lib/executor",
77
"bin/dev-cli",
8-
"bin/gateway",
8+
"bin/router",
99
"bench/subgraphs",
1010
]
1111
resolver = "2"
12-
default-members = ["bin/gateway"]
12+
default-members = ["bin/router"]
1313

1414
[profile.dev]
1515
debug = 2

PROFILING.md

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,9 @@
1-
## Profiling using Samply
2-
3-
4-
1. Configure `gateway/src/main.rs` to use `#[tokio::main(flavor = "current_thread")]` for better reading of the flamegraph.
5-
2. Install `samply` by following: https://github.com/mstange/samply#installation
6-
3. Build the gateway in profiling mode using: `cargo build --profile profiling -p gateway`
7-
4. Run `samply` with your dev-cli args, for example:
8-
9-
```
10-
samply record ./target/profiling/gateway SUPERGRAPH_PATH
11-
```
12-
131
## Profiling using Flamegraph
142

153
1. Install `flamegraph` by following: https://github.com/flamegraph-rs/flamegraph?tab=readme-ov-file#installation
16-
2. Run `gateway` with the example command.
4+
2. Run `router` with the example command.
175
3. Open the `flamegraph.svg` file
186

197
```
20-
cargo flamegraph -p gateway --profile profiling -- SUPERGRAPH_PATH
8+
cargo flamegraph -p router --profile profiling -- SUPERGRAPH_PATH
219
```
22-
23-
## Profiling with perfetto
24-
25-
1. Build GW in release mode: `cargo build --release -p gateway`
26-
2. Run gateway in release mode with the following flag: `PERFETTO_OUT="1" RUST_LOG="trace" ./target/release/gateway bench/supergraph.graphql`
27-
3. Use the generated `trace-*.json` file and load it into https://ui.perfetto.dev

README.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,23 @@
22

33
# Hive Router (Rust)
44

5-
A fully open-source MIT-licensed GraphQL API gateway that can act as a [GraphQL federation](https://the-guild.dev/graphql/hive/federation) Gateway, built with Rust for maximum performance and robustness.
5+
A fully open-source MIT-licensed GraphQL API router that can act as a [GraphQL federation](https://the-guild.dev/graphql/hive/federation) Router, built with Rust for maximum performance and robustness.
66

77
It can be run as a standalone binary or a Docker Image. Query planner can be used as a standalone Crate library.
88

9-
[Binary Releases](https://github.com/graphql-hive/gateway-rs/releases) | [Docker Releases](https://github.com/graphql-hive/router/pkgs/container/router) | [Configuration reference](./docs/README.md)
9+
[Binary Releases](https://github.com/graphql-hive/router/releases) | [Docker Releases](https://github.com/graphql-hive/router/pkgs/container/router) | [Configuration reference](./docs/README.md)
1010

1111
## Try it out
1212

13-
Start by creating a simple configuration file. You may use YAML or JSON formats.
13+
Download Hive Router using the following install script:
14+
15+
```
16+
curl -o- https://raw.githubusercontent.com/graphql-hive/router/main/install.sh | sh
17+
```
18+
19+
> At the moment, only Linux runtimes are supported using a binary, see Docker option below if you are using a different OS.
20+
21+
Create a simple configuration file that points to your supergraph schema file:
1422

1523
```yaml
1624
# hive-router.config.yaml
@@ -26,18 +34,18 @@ HIVE_SUPERGRAPH_SOURCE=file
2634
HIVE_SUPERGRAPH_PATH=./supergraph.graphql
2735
```
2836

29-
Then, pick your preferred runtime:
30-
31-
### Binary
32-
33-
See [GitHub Releases](https://github.com/graphql-hive/gateway-rs/releases) and use the artifacts published to each release.
37+
Then, run the router:
3438

3539
```bash
3640
# By default, "hive-router.config.yaml" is used for configuration. Override it by setting "HIVE_CONFIG_FILE_PATH=some-custom-file.yaml"
37-
# If you are using env vars, make sure to set the variables before running the gateway.
38-
./gateway
41+
# If you are using env vars, make sure to set the variables before running the router.
42+
./hive_router
3943
```
4044

45+
### Binary
46+
47+
See [GitHub Releases](https://github.com/graphql-hive/router/releases) to the full list of release and versions.
48+
4149
### Docker
4250

4351
The router image is being published to [Docker to GitHub Container Registry](). You may use it directly using the following command:

audits/package-lock.json

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

0 commit comments

Comments
 (0)