Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove the serenity runtime #549

Merged
merged 1 commit into from
Dec 22, 2022
Merged
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
13 changes: 0 additions & 13 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ cap-std = "0.26.0"
clap ={ version = "4.0.18", features = ["derive"] }
hyper = { version = "0.14.23", features = ["full"] }
rmp-serde = { version = "1.1.1" }
serenity = { version = "0.11.5", default-features = false, features = ["client", "gateway", "rustls_backend", "model"] }
thiserror = { workspace = true }
tokio = { version = "=1.22.0", features = ["full"] }
tokio-stream = "0.1.11"
Expand Down
10 changes: 3 additions & 7 deletions runtime/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
.PHONY: axum serenity
.PHONY: axum

all: axum serenity
all: axum

axum:
cd ../tmp/axum-wasm; cargo build --target wasm32-wasi
cp ../tmp/axum-wasm/target/wasm32-wasi/debug/shuttle_axum.wasm axum.wasm

serenity:
cd ../tmp/wasm; cargo build --target wasm32-wasi
cp ../tmp/wasm/target/wasm32-wasi/debug/shuttle_serenity.wasm serenity.wasm

test: serenity axum
test: axum
cargo test --all-features -- --nocapture

runtime:
Expand Down
45 changes: 1 addition & 44 deletions runtime/README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,5 @@
# How to run

## serenity-wasm

Build and run:

## shuttle-next

Compile the shuttle-next serenity runtime:

```bash
make serenity
```

Run the test:

```bash
cargo test serenity -- --nocapture

# or, run tests for both axum and serenity:
make test
```

Start the shuttle-next runtime:

```bash
DISCORD_TOKEN=xxx cargo run
```

In another terminal:

``` bash
# load wasm module
grpcurl -plaintext -import-path ../proto -proto runtime.proto -d '{"service_name": "Tonic", "path": "/home/<path to shuttle>/runtime/serenity.wasm"}' localhost:6001 runtime.Runtime/Load

# start bot (the deployment ID is needed in the StartRequest, but it isn't used by the serenity bot currently)
grpcurl -plaintext -import-path ../proto -proto runtime.proto -d '{"service_name": "Tonic", "deployment_id": "MDAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDAw"}' localhost:6001 runtime.Runtime/Start

# subscribe to logs (unimplemented)
grpcurl -plaintext -import-path ../proto -proto runtime.proto localhost:6001 runtime.Runtime/SubscribeLogs

# stop (the deployment ID is needed in the StopRequest, but it isn't used by the serenity bot currently)
grpcurl -plaintext -import-path ../proto -proto runtime.proto -d '{"service_name": "Tonic", "deployment_id": "MDAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDAw"}' localhost:6001 runtime.Runtime/Stop
```

## axum-wasm

Compile the wasm axum router:
Expand All @@ -56,7 +13,7 @@ Run the test:
```bash
cargo test axum -- --nocapture

# or, run tests for both axum and serenity:
# or, run tests
make test
```

Expand Down
2 changes: 0 additions & 2 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
mod args;
mod axum;
mod legacy;
mod next;
pub mod provisioner_factory;

pub use args::Args;
pub use axum::AxumWasm;
pub use legacy::Legacy;
pub use next::Next;
6 changes: 2 additions & 4 deletions runtime/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{

use clap::Parser;
use shuttle_proto::runtime::runtime_server::RuntimeServer;
use shuttle_runtime::{Args, AxumWasm, Legacy, Next};
use shuttle_runtime::{Args, AxumWasm, Legacy};
use tonic::transport::Server;
use tracing::trace;
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
Expand Down Expand Up @@ -41,9 +41,7 @@ async fn main() {
let svc = RuntimeServer::new(axum);
server_builder.add_service(svc)
} else {
let next = Next::default();
let svc = RuntimeServer::new(next);
server_builder.add_service(svc)
panic!("No runtime was selected");
};

router.serve(addr).await.unwrap();
Expand Down
Loading