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: rename legacy runtime to alpha #713

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
2 changes: 1 addition & 1 deletion cargo-shuttle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ impl Shuttle {

let (is_wasm, executable_path) = match runtime {
Runtime::Next(path) => (true, path),
Runtime::Legacy(path) => (false, path),
Runtime::Alpha(path) => (false, path),
};

let provisioner = LocalProvisioner::new()?;
Expand Down
6 changes: 3 additions & 3 deletions deployer/src/deployment/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ async fn run_pre_deploy_tests(
}

/// This will store the path to the executable for each runtime, which will be the users project with
/// an embedded runtime for legacy, and a .wasm file for shuttle-next.
/// an embedded runtime for alpha, and a .wasm file for shuttle-next.
#[instrument(skip(storage_manager, runtime, id))]
async fn store_executable(
storage_manager: &ArtifactsStorageManager,
Expand All @@ -406,7 +406,7 @@ async fn store_executable(
) -> Result<()> {
let executable_path = match runtime {
Runtime::Next(path) => path,
Runtime::Legacy(path) => path,
Runtime::Alpha(path) => path,
};

let new_executable_path = storage_manager.deployment_executable_path(id)?;
Expand Down Expand Up @@ -559,7 +559,7 @@ ff0e55bda1ff01000000000000000000e0079c01ff12a55500280000",
let build_p = storage_manager.builds_path().unwrap();

let executable_path = build_p.join("xyz");
let runtime = Runtime::Legacy(executable_path.clone());
let runtime = Runtime::Alpha(executable_path.clone());
let id = Uuid::new_v4();

fs::write(&executable_path, "barfoo").await.unwrap();
Expand Down
6 changes: 3 additions & 3 deletions deployer/src/deployment/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl Built {
kill_old_deployments: impl futures::Future<Output = Result<()>>,
cleanup: impl FnOnce(SubscribeStopResponse) + Send + 'static,
) -> Result<()> {
// For legacy this is the path to the users project with an embedded runtime.
// For alpha this is the path to the users project with an embedded runtime.
// For shuttle-next this is the path to the compiled .wasm file, which will be
// used in the load request.
let executable_path = storage_manager.deployment_executable_path(&self.id)?;
Expand All @@ -198,7 +198,7 @@ impl Built {

let address = SocketAddr::new(Ipv4Addr::LOCALHOST.into(), port);

let legacy_runtime_path = if self.is_next {
let alpha_runtime_path = if self.is_next {
// The runtime client for next is the installed shuttle-next bin
None
} else {
Expand All @@ -208,7 +208,7 @@ impl Built {
let runtime_client = runtime_manager
.lock()
.await
.get_runtime_client(self.id, legacy_runtime_path.clone())
.get_runtime_client(self.id, alpha_runtime_path.clone())
.await
.map_err(Error::Runtime)?;

Expand Down
12 changes: 6 additions & 6 deletions deployer/src/runtime_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,24 @@ impl RuntimeManager {
pub async fn get_runtime_client(
&mut self,
id: Uuid,
legacy_runtime_path: Option<PathBuf>,
alpha_runtime_path: Option<PathBuf>,
) -> anyhow::Result<RuntimeClient<Channel>> {
trace!("making new client");

let port = portpicker::pick_unused_port().context("failed to find available port")?;
let is_next = legacy_runtime_path.is_none();
let is_next = alpha_runtime_path.is_none();

let get_runtime_executable = || {
if let Some(legacy_runtime) = legacy_runtime_path {
if let Some(alpha_runtime) = alpha_runtime_path {
debug!(
"Starting legacy runtime at: {}",
legacy_runtime
"Starting alpha runtime at: {}",
alpha_runtime
.clone()
.into_os_string()
.into_string()
.unwrap_or_default()
);
legacy_runtime
alpha_runtime
} else {
if cfg!(debug_assertions) {
debug!("Installing shuttle-next runtime in debug mode from local source");
Expand Down
10 changes: 5 additions & 5 deletions runtime/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# How to run

## The easy way
Both the legacy and next examples can be run using the local client:
Both the alpha and next examples can be run using the local client:

``` bash
cd path/to/example
Expand Down Expand Up @@ -56,7 +56,7 @@ curl localhost:8000/hello
curl localhost:8000/goodbye
```

## shuttle-legacy
## shuttle-alpha

This will no longer load a `.so` file, the code to start the runtime will be
codegened for all services.
Expand Down Expand Up @@ -86,16 +86,16 @@ cargo build
Then in another shell, load the service and start it up:

``` bash
# load
# load the service
grpcurl -plaintext -import-path ../proto -proto runtime.proto -d '{"service_name": "Tonic", "path": "/home/<path to shuttle>/examples/rocket/hello-world/target/debug/libhello_world.so", "secrets": {"MY_API_KEY": "test"}}' localhost:6001 runtime.Runtime/Load

# run (this deployment id is default uuid encoded as base64)
# start the service
grpcurl -plaintext -import-path ../proto -proto runtime.proto -d '{"deployment_id": "MDAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDAw", "ip": "127.0.0.1:8000"}' localhost:6001 runtime.Runtime/Start

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

# stop (the service started in the legacy runtime can't currently be stopped)
# stop the service
grpcurl -plaintext -import-path ../proto -proto runtime.proto -d '{}' localhost:6001 runtime.Runtime/Stop
```

Expand Down
File renamed without changes.
16 changes: 8 additions & 8 deletions runtime/src/legacy/mod.rs → runtime/src/alpha/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub async fn start(loader: impl Loader<ProvisionerFactory> + Send + 'static) {
Server::builder().http2_keepalive_interval(Some(Duration::from_secs(60)));

// We wrap the StorageManager trait object in an Arc rather than a Box, since we need
// to clone it in the `ProvisionerFactory::new` call in the legacy runtime `load` method.
// to clone it in the `ProvisionerFactory::new` call in the alpha runtime `load` method.
// We might be able to optimize this by implementing clone for a Box<dyn StorageManager>
// or by using static dispatch instead.
let storage_manager: Arc<dyn StorageManager> = match args.storage_manager_type {
Expand All @@ -69,21 +69,21 @@ pub async fn start(loader: impl Loader<ProvisionerFactory> + Send + 'static) {
};

let router = {
let legacy = Legacy::new(
let alpha = Alpha::new(
provisioner_address,
loader,
storage_manager,
Environment::Local,
);

let svc = RuntimeServer::new(legacy);
let svc = RuntimeServer::new(alpha);
server_builder.add_service(svc)
};

router.serve(addr).await.unwrap();
}

pub struct Legacy<L, S> {
pub struct Alpha<L, S> {
// Mutexes are for interior mutability
logs_rx: Mutex<Option<UnboundedReceiver<LogItem>>>,
logs_tx: UnboundedSender<LogItem>,
Expand All @@ -96,7 +96,7 @@ pub struct Legacy<L, S> {
env: Environment,
}

impl<L, S> Legacy<L, S> {
impl<L, S> Alpha<L, S> {
pub fn new(
provisioner_address: Endpoint,
loader: L,
Expand Down Expand Up @@ -154,7 +154,7 @@ where
}

#[async_trait]
impl<L, S> Runtime for Legacy<L, S>
impl<L, S> Runtime for Alpha<L, S>
where
L: Loader<ProvisionerFactory, Service = S> + Send + 'static,
S: Service + Send + 'static,
Expand All @@ -165,7 +165,7 @@ where
secrets,
service_name,
} = request.into_inner();
trace!(path, "loading legacy project");
trace!(path, "loading alpha project");

let secrets = BTreeMap::from_iter(secrets.into_iter());

Expand Down Expand Up @@ -255,7 +255,7 @@ where
&self,
request: Request<StartRequest>,
) -> Result<Response<StartResponse>, Status> {
trace!("legacy starting");
trace!("alpha starting");
let service = self.service.lock().unwrap().deref_mut().take();
let service = service.unwrap();

Expand Down
4 changes: 2 additions & 2 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,14 @@
//!
//! You can also [open an issue or a discussion on GitHub](https://github.com/shuttle-hq/shuttle).
//!
mod legacy;
mod alpha;
mod logger;
#[cfg(feature = "next")]
mod next;
mod provisioner_factory;

pub use alpha::{start, Alpha};
pub use async_trait::async_trait;
pub use legacy::{start, Legacy};
pub use logger::Logger;
#[cfg(feature = "next")]
pub use next::{AxumWasm, NextArgs};
Expand Down
2 changes: 1 addition & 1 deletion runtime/tests/integration/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub async fn spawn_runtime(project_path: String, service_name: &str) -> Result<T

let (is_wasm, bin_path) = match runtime {
Runtime::Next(path) => (true, path),
Runtime::Legacy(path) => (false, path),
Runtime::Alpha(path) => (false, path),
};

start_provisioner(DummyProvisioner, provisioner_address);
Expand Down
6 changes: 3 additions & 3 deletions service/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::NEXT_NAME;
/// How to run/build the project
pub enum Runtime {
Next(PathBuf),
Legacy(PathBuf),
Alpha(PathBuf),
}

/// Given a project directory path, builds the crate
Expand Down Expand Up @@ -70,7 +70,7 @@ pub async fn build_crate(
Ok(if is_next {
Runtime::Next(compilation.cdylibs[0].path.clone())
} else {
Runtime::Legacy(compilation.binaries[0].path.clone())
Runtime::Alpha(compilation.binaries[0].path.clone())
})
}

Expand Down Expand Up @@ -176,7 +176,7 @@ fn is_next(summary: &Summary) -> bool {
.any(|dependency| dependency.package_name() == NEXT_NAME)
}

/// Make sure the project is a binary for legacy projects.
/// Make sure the project is a binary for alpha projects.
fn ensure_binary(manifest: &Manifest) -> anyhow::Result<()> {
if manifest.targets().iter().any(|target| target.is_bin()) {
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion service/tests/integration/build_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async fn is_bin() {

assert!(matches!(
build_crate(Path::new(&project_path), false, tx).await,
Ok(Runtime::Legacy(_))
Ok(Runtime::Alpha(_))
));
assert!(PathBuf::from(project_path)
.join("target/debug/is-bin")
Expand Down