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

Upgrade graphql-ws-client to v0.8.0 #4491

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
191 changes: 133 additions & 58 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ comfy-table = "7.0.1"
# Used by tuntap and connect
futures-util = { version = "0.3", optional = true }
mio = { version = "0.8", optional = true }
tokio-tungstenite = { version = "0.20.1", features = [
tokio-tungstenite = { version = "0.21", features = [
"rustls-tls-webpki-roots",
], optional = true }
mac_address = { version = "1.1.5", optional = true }
Expand Down
6 changes: 3 additions & 3 deletions lib/registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ filetime = "0.2.19"
flate2 = "1.0.24"
futures = "0.3"
futures-util = "0.3.25"
graphql-ws-client = {version = "0.6.0", features = ["client-graphql-client"]}
graphql-ws-client = {version = "0.8.0", features = ["client-graphql-client", "tungstenite"]}
graphql_client = "0.13.0"
hex = "0.4.3"
indexmap = { version = "1.9.3", optional = true }
Expand All @@ -43,8 +43,8 @@ tempfile = "3.6.0"
thiserror = "1.0.37"
time = { version = "0.3.17", default-features = false, features = ["parsing", "std", "formatting"], optional = true }
tldextract = "0.6.0"
tokio = {version = "1"}
tokio-tungstenite = {version = "0.20", features = ["rustls-tls-native-roots"]}
tokio = {version = "1", features = ["rt-multi-thread"]}
tokio-tungstenite = {version = "0.21", features = ["rustls-tls-native-roots"]}
toml = "0.5.9"
tracing = "0.1.40"
url = "2.3.1"
Expand Down
1 change: 0 additions & 1 deletion lib/registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ pub mod login;
pub mod package;
pub mod publish;
pub mod subscriptions;
pub(crate) mod tokio_spawner;
pub mod types;
pub mod utils;
pub mod wasmer_env;
Expand Down
2 changes: 1 addition & 1 deletion lib/registry/src/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ async fn wait_for_package_version_to_become_ready(
quiet: bool,
mut conditions: PublishWait,
) -> Result<()> {
let (mut stream, _client) =
let mut stream =
subscribe_package_version_ready(registry, token, package_version_id.as_ref()).await?;

let state = PackageVersionReadySharedState::new();
Expand Down
38 changes: 10 additions & 28 deletions lib/registry/src/subscriptions.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
use std::env;

use crate::{
graphql::subscriptions::{package_version_ready, PackageVersionReady},
tokio_spawner::TokioSpawner,
};

use futures_util::StreamExt;
use crate::graphql::subscriptions::{package_version_ready, PackageVersionReady};

use graphql_client::GraphQLQuery;
use graphql_ws_client::{
graphql::{GraphQLClient, StreamingOperation},
GraphQLClientClient, SubscriptionStream,
};
use graphql_ws_client::{graphql::StreamingOperation, Subscription};

use tokio_tungstenite::{
connect_async,
tungstenite::{client::IntoClientRequest, http::HeaderValue, Message},
tungstenite::{client::IntoClientRequest, http::HeaderValue},
};

async fn subscribe_graphql<Q: GraphQLQuery + Send + Sync + Unpin + 'static>(
registry_url: &str,
login_token: &str,
variables: Q::Variables,
) -> anyhow::Result<(
SubscriptionStream<GraphQLClient, StreamingOperation<Q>>,
GraphQLClientClient<Message>,
)>
) -> anyhow::Result<Subscription<StreamingOperation<Q>>>
where
<Q as GraphQLQuery>::Variables: Send + Sync + Unpin,
{
Expand All @@ -46,35 +35,28 @@ where
.or_else(|| env::var("WAPM_REGISTRY_TOKEN").ok())
.unwrap_or_else(|| login_token.to_string());
req.headers_mut().insert(
reqwest::header::AUTHORIZATION,
tokio_tungstenite::tungstenite::http::header::AUTHORIZATION,
HeaderValue::from_str(&format!("Bearer {}", token))?,
);
let user_agent = crate::client::RegistryClient::default_user_agent();
req.headers_mut().insert(
reqwest::header::USER_AGENT,
tokio_tungstenite::tungstenite::http::header::USER_AGENT,
HeaderValue::from_str(&user_agent)?,
);
let (ws_con, _resp) = connect_async(req).await?;
let (sink, stream) = ws_con.split();

let mut client = graphql_ws_client::GraphQLClientClientBuilder::new()
.build(stream, sink, TokioSpawner::current())
.await?;
let stream = client
.streaming_operation(StreamingOperation::<Q>::new(variables))
let stream = graphql_ws_client::Client::build(ws_con)
.subscribe(StreamingOperation::<Q>::new(variables))
.await?;

Ok((stream, client))
Ok(stream)
}

pub async fn subscribe_package_version_ready(
registry_url: &str,
login_token: &str,
package_version_id: &str,
) -> anyhow::Result<(
SubscriptionStream<GraphQLClient, StreamingOperation<PackageVersionReady>>,
GraphQLClientClient<Message>,
)> {
) -> anyhow::Result<Subscription<StreamingOperation<PackageVersionReady>>> {
subscribe_graphql(
registry_url,
login_token,
Expand Down
22 changes: 0 additions & 22 deletions lib/registry/src/tokio_spawner.rs

This file was deleted.

4 changes: 2 additions & 2 deletions lib/virtual-net/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ futures-util = { version = "0.3" }
anyhow = "1.0"
tokio-serde = { version = "0.8", features = [ "bincode" ], optional = true }
tokio-util = { version = "0.7.8", features = ["codec"], optional = true }
hyper-tungstenite = { version = "0.11", optional = true }
hyper-tungstenite = { version = "0.13.0", optional = true }
hyper = { version = "0.14", optional = true }
tokio-tungstenite = { version = "0.20", optional = true }
tokio-tungstenite = { version = "0.21", optional = true }
rkyv = { version = "0.7.40", features = ["indexmap", "validation", "strict"], optional = true }
bytecheck = { version = "0.6.8", optional = true }

Expand Down
Loading