Skip to content

Commit 9a7549f

Browse files
committed
Revert "runtime agnostic register"
This reverts commit d3e8d05.
1 parent d3e8d05 commit 9a7549f

File tree

3 files changed

+11
-25
lines changed

3 files changed

+11
-25
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ uuid = { version = "1.7", features = ["v4"] } # A library to ge
3939
# Non-feature optional dependencies
4040
libflate = { version = "2", optional = true }
4141
tokio = { version = "1", features = ["full"], optional = true }
42-
async-std = { version = "1", features = ["default", "tokio1"], optional = true }
42+
async-std = { version = "1", features = ["default"], optional = true }
4343

4444
[build-dependencies]
4545
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls"] }

src/register.rs

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn sha_dynamic(schema: &dynamic::Schema) -> String {
4949
/// * `user_version` - An arbitrary string you can set to distinguish data sent by different versions of your edge server. For example, this can be the SHA of the Git commit for your deployed server code. We plan to make this value visible in Apollo Studio.
5050
/// * `platform` - The infrastructure environment that your edge server is running in (localhost, kubernetes/deployment, aws lambda, google cloud run, google cloud function, AWS ECS, etc.)
5151
#[instrument(err, skip(authorization_token, schema))]
52-
pub fn register<
52+
pub async fn register<
5353
Q: ObjectType + 'static,
5454
M: ObjectType + 'static,
5555
S: SubscriptionType + 'static,
@@ -120,9 +120,8 @@ pub fn register<
120120
}))
121121
.header("content-type", "application/json")
122122
.header("X-Api-Key", authorization_token)
123-
.send();
124-
125-
let result = eval_future(result);
123+
.send()
124+
.await;
126125

127126
match result {
128127
Ok(data) => {
@@ -131,7 +130,7 @@ pub fn register<
131130
message = "Schema correctly registered",
132131
response = &tracing::field::debug(&data)
133132
);
134-
let text = eval_future(data.text());
133+
let text = data.text().await;
135134
debug!(target: TARGET_LOG, data = ?text);
136135
Ok(())
137136
}
@@ -152,7 +151,7 @@ pub fn register<
152151
/// * `user_version` - An arbitrary string you can set to distinguish data sent by different versions of your edge server. For example, this can be the SHA of the Git commit for your deployed server code. We plan to make this value visible in Apollo Studio.
153152
/// * `platform` - The infrastructure environment that your edge server is running in (localhost, kubernetes/deployment, aws lambda, google cloud run, google cloud function, AWS ECS, etc.)
154153
#[instrument(err, skip(authorization_token, schema))]
155-
pub fn register_dynamic(
154+
pub async fn register_dynamic(
156155
authorization_token: &str,
157156
schema: &dynamic::Schema,
158157
server_id: &str,
@@ -219,9 +218,8 @@ pub fn register_dynamic(
219218
}))
220219
.header("content-type", "application/json")
221220
.header("X-Api-Key", authorization_token)
222-
.send();
223-
224-
let result = eval_future(result);
221+
.send()
222+
.await;
225223

226224
match result {
227225
Ok(data) => {
@@ -230,7 +228,7 @@ pub fn register_dynamic(
230228
message = "Schema correctly registered",
231229
response = &tracing::field::debug(&data)
232230
);
233-
let text = eval_future(data.text());
231+
let text = data.text().await;
234232
debug!(target: TARGET_LOG, data = ?text);
235233
Ok(())
236234
}
@@ -241,15 +239,3 @@ pub fn register_dynamic(
241239
}
242240
}
243241
}
244-
245-
fn eval_future<T>(fut: impl std::future::Future<Output = T>) -> T {
246-
cfg_if::cfg_if! {
247-
if #[cfg(feature = "tokio-comp")] {
248-
tokio::runtime::Runtime::new().unwrap().block_on(fut)
249-
} else if #[cfg(feature = "async-std-comp")] {
250-
async_std::task::block_on(result)
251-
} else {
252-
compile_error!("tokio-comp or async-std-comp features required");
253-
}
254-
}
255-
}

0 commit comments

Comments
 (0)