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

update dependencies #2257

Merged
merged 7 commits into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
451 changes: 270 additions & 181 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apollo-router-benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ publish = false

[dev-dependencies]
apollo-router = { path = "../apollo-router" }
criterion = { version = "0.3", features = ["async_tokio", "async_futures"] }
criterion = { version = "0.4", features = ["async_tokio", "async_futures"] }
futures = "0.3"
once_cell = "1"
serde_json = { version = "1", features = ["preserve_order"] }
Expand Down
12 changes: 6 additions & 6 deletions apollo-router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async-trait = "0.1.59"
atty = "0.2.14"
axum = { version = "0.5.17", features = ["headers", "json", "original-uri"] }
backtrace = "0.3.66"
base64 = "0.13.1"
base64 = "0.20.0"
buildstructor = "0.5.1"
bytes = "1.3.0"
clap = { version = "3.2.23", default-features = false, features = [
Expand Down Expand Up @@ -89,7 +89,7 @@ jsonschema = { version = "0.16.1", default-features = false }
lazy_static = "1.4.0"
libc = "0.2.138"
linkme = "0.3.6"
lru = "0.7.8"
lru = "0.8.1"
mediatype = "0.19.11"
mockall = "0.11.3"
miette = { version = "5.5.0", features = ["fancy"] }
Expand Down Expand Up @@ -138,12 +138,12 @@ opentelemetry-prometheus = "0.11.0"
paste = "1.0.10"
pin-project-lite = "0.2.9"
prometheus = "0.13"
prost = "0.11.0"
prost = "0.11.3"
prost-types = "0.11.0"
proteus = "0.5.0"
rand = "0.8.5"
rhai = { version = "1.11.0", features = ["sync", "serde", "internals"] }
redis = { version = "0.21.6", optional = true, features = ["cluster", "tokio-comp"] }
redis = { version = "0.22.1", optional = true, features = ["cluster", "tokio-comp"] }
redis_cluster_async = { version = "0.7.0", optional = true }
regex = "1.7.0"
reqwest = { version = "0.11.13", default-features = false, features = [
Expand All @@ -154,7 +154,7 @@ reqwest = { version = "0.11.13", default-features = false, features = [
router-bridge = "0.1.12"
rust-embed="6.4.2"
schemars = { version = "0.8.11", features = ["url"] }
shellexpand = "2.1.2"
shellexpand = "3.0.0"
sha2 = "0.10.6"
serde = { version = "1.0.150", features = ["derive", "rc"] }
serde_json_bytes = { version = "0.2.0", features = ["preserve_order"] }
Expand Down Expand Up @@ -201,7 +201,7 @@ uname = "0.1.1"

[dev-dependencies]
insta = { version = "1.23.0", features = ["json", "redactions", "yaml"] }
introspector-gadget = "0.1.0"
introspector-gadget = "0.2.0"
maplit = "1.0.2"
memchr = { version = "2.5.0", default-features = false }
mockall = "0.11.3"
Expand Down
14 changes: 9 additions & 5 deletions apollo-router/src/cache/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::collections::HashMap;
use std::num::NonZeroUsize;
use std::sync::Arc;

use tokio::sync::broadcast;
Expand All @@ -14,7 +15,7 @@ mod redis;
pub(crate) mod storage;

type WaitMap<K, V> = Arc<Mutex<HashMap<K, broadcast::Sender<V>>>>;
pub(crate) const DEFAULT_CACHE_CAPACITY: usize = 512;
pub(crate) const DEFAULT_CACHE_CAPACITY: NonZeroUsize = unsafe { NonZeroUsize::new_unchecked(512) };
Geal marked this conversation as resolved.
Show resolved Hide resolved

/// Cache implementation with query deduplication
#[derive(Clone)]
Expand All @@ -34,7 +35,7 @@ where
}

pub(crate) async fn with_capacity(
capacity: usize,
capacity: NonZeroUsize,
redis_urls: Option<Vec<String>>,
caller: &str,
) -> Self {
Expand Down Expand Up @@ -199,6 +200,8 @@ where

#[cfg(test)]
mod tests {
use std::num::NonZeroUsize;

use futures::stream::FuturesUnordered;
use futures::stream::StreamExt;
use mockall::mock;
Expand All @@ -209,7 +212,8 @@ mod tests {
#[tokio::test]
async fn example_cache_usage() {
let k = "key".to_string();
let cache = DeduplicatingCache::with_capacity(1, None, "test").await;
let cache =
DeduplicatingCache::with_capacity(NonZeroUsize::new(1).unwrap(), None, "test").await;

let entry = cache.get(&k).await;

Expand All @@ -226,7 +230,7 @@ mod tests {
#[test(tokio::test)]
async fn it_should_enforce_cache_limits() {
let cache: DeduplicatingCache<usize, usize> =
DeduplicatingCache::with_capacity(13, None, "test").await;
DeduplicatingCache::with_capacity(NonZeroUsize::new(13).unwrap(), None, "test").await;

for i in 0..14 {
let entry = cache.get(&i).await;
Expand All @@ -249,7 +253,7 @@ mod tests {
mock.expect_retrieve().times(1).return_const(1usize);

let cache: DeduplicatingCache<usize, usize> =
DeduplicatingCache::with_capacity(10, None, "test").await;
DeduplicatingCache::with_capacity(NonZeroUsize::new(10).unwrap(), None, "test").await;

// Let's trigger 100 concurrent gets of the same value and ensure only
// one delegated retrieve is made
Expand Down
3 changes: 2 additions & 1 deletion apollo-router/src/cache/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use std::fmt;
use std::hash::Hash;
use std::num::NonZeroUsize;
use std::sync::Arc;

use lru::LruCache;
Expand Down Expand Up @@ -56,7 +57,7 @@ where
V: ValueType,
{
pub(crate) async fn new(
max_capacity: usize,
max_capacity: NonZeroUsize,
_redis_urls: Option<Vec<String>>,
_caller: &str,
) -> Self {
Expand Down
3 changes: 2 additions & 1 deletion apollo-router/src/configuration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mod yaml;
use std::fmt;
use std::net::IpAddr;
use std::net::SocketAddr;
use std::num::NonZeroUsize;
use std::str::FromStr;

use askama::Template;
Expand Down Expand Up @@ -579,7 +580,7 @@ pub(crate) struct Cache {
/// In memory cache configuration
pub(crate) struct InMemoryCache {
/// Number of entries in the Least Recently Used cache
pub(crate) limit: usize,
pub(crate) limit: NonZeroUsize,
}

impl Default for InMemoryCache {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ expression: "&schema"
"description": "Number of entries in the Least Recently Used cache",
"type": "integer",
"format": "uint",
"minimum": 0.0
"minimum": 1.0
}
},
"additionalProperties": false
Expand Down Expand Up @@ -724,7 +724,7 @@ expression: "&schema"
"description": "Number of entries in the Least Recently Used cache",
"type": "integer",
"format": "uint",
"minimum": 0.0
"minimum": 1.0
}
},
"additionalProperties": false
Expand Down Expand Up @@ -789,7 +789,7 @@ expression: "&schema"
"default": 10000,
"type": "integer",
"format": "uint",
"minimum": 0.0
"minimum": 1.0
},
"client_name_header": {
"description": "The name of the header to extract from requests when populating 'client nane' for traces and metrics in Apollo Studio.",
Expand Down
11 changes: 8 additions & 3 deletions apollo-router/src/introspection.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#[cfg(test)]
use std::collections::HashMap;
use std::num::NonZeroUsize;

use router_bridge::introspect;
use router_bridge::introspect::IntrospectionError;
Expand All @@ -10,7 +11,8 @@ use crate::cache::storage::CacheStorage;
use crate::graphql::Response;
use crate::Configuration;

const DEFAULT_INTROSPECTION_CACHE_CAPACITY: usize = 5;
const DEFAULT_INTROSPECTION_CACHE_CAPACITY: NonZeroUsize =
unsafe { NonZeroUsize::new_unchecked(5) };

/// A cache containing our well known introspection queries.
pub(crate) struct Introspection {
Expand All @@ -19,7 +21,10 @@ pub(crate) struct Introspection {
}

impl Introspection {
pub(crate) async fn with_capacity(configuration: &Configuration, capacity: usize) -> Self {
pub(crate) async fn with_capacity(
configuration: &Configuration,
capacity: NonZeroUsize,
) -> Self {
Self {
cache: CacheStorage::new(capacity, None, "introspection").await,
defer_support: configuration.supergraph.preview_defer_support,
Expand All @@ -35,7 +40,7 @@ impl Introspection {
configuration: &Configuration,
cache: HashMap<String, Response>,
) -> Self {
let this = Self::with_capacity(configuration, cache.len()).await;
let this = Self::with_capacity(configuration, cache.len().try_into().unwrap()).await;

for (query, response) in cache.into_iter() {
this.cache.insert(query, response).await;
Expand Down
7 changes: 4 additions & 3 deletions apollo-router/src/plugins/telemetry/apollo.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Configuration for apollo telemetry.
// This entire file is license key functionality
use std::collections::HashMap;
use std::num::NonZeroUsize;
use std::ops::AddAssign;
use std::time::SystemTime;

Expand Down Expand Up @@ -67,7 +68,7 @@ pub(crate) struct Config {

/// The buffer size for sending traces to Apollo. Increase this if you are experiencing lost traces.
#[serde(default = "default_buffer_size")]
pub(crate) buffer_size: usize,
pub(crate) buffer_size: NonZeroUsize,

/// Enable field level instrumentation for subgraphs via ftv1. ftv1 tracing can cause performance issues as it is transmitted in band with subgraph responses.
/// 0.0 will result in no field level instrumentation. 1.0 will result in always instrumentation.
Expand Down Expand Up @@ -136,8 +137,8 @@ const fn client_version_header_default() -> HeaderName {
HeaderName::from_static(client_version_header_default_str())
}

pub(crate) const fn default_buffer_size() -> usize {
10000
pub(crate) const fn default_buffer_size() -> NonZeroUsize {
unsafe { NonZeroUsize::new_unchecked(10000) }
garypen marked this conversation as resolved.
Show resolved Hide resolved
}

impl Default for Config {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::collections::HashMap;
use std::io::Cursor;
use std::num::NonZeroUsize;
use std::sync::Arc;
#[cfg(test)]
use std::sync::Mutex;
Expand Down Expand Up @@ -145,7 +146,7 @@ impl Exporter {
apollo_key: String,
apollo_graph_ref: String,
schema_id: String,
buffer_size: usize,
buffer_size: NonZeroUsize,
field_execution_sampler: Option<SamplerOption>,
) -> Result<Self, BoxError> {
tracing::debug!("creating studio exporter");
Expand Down
3 changes: 1 addition & 2 deletions apollo-router/src/uplink/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ fn test_uplink_schema_is_up_to_date() {
let client = GraphQLClient::new(
"https://uplink.api.apollographql.com/",
reqwest::blocking::Client::new(),
)
.unwrap();
);

let should_retry = true;
let introspection_response = introspect::run(
Expand Down
2 changes: 1 addition & 1 deletion fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cargo-fuzz = true
libfuzzer-sys = "0.4"
apollo-smith = { version = "0.3.1", features = ["parser-impl"] }
apollo-parser = "0.4.0"
env_logger = "0.9.3"
env_logger = "0.10.0"
log = "0.4"
reqwest = { version = "0.11", features = ["json", "blocking"] }
serde_json = "1"
Expand Down
18 changes: 12 additions & 6 deletions xtask/Cargo.lock

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

2 changes: 1 addition & 1 deletion xtask/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ publish = false
[dependencies]
ansi_term = "0.12"
anyhow = "1"
base64 = "0.13"
base64 = "0.20"
camino = "1"
cargo_metadata = "0.15"
chrono = "0.4.23"
Expand Down