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

ref(server): Manually control concurrent upstream requests #678

Merged
merged 20 commits into from
Aug 18, 2020
Merged
Show file tree
Hide file tree
Changes from 14 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
8 changes: 7 additions & 1 deletion relay-server/src/actors/outcome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use relay_general::protocol::EventId;
use relay_quotas::{ReasonCode, Scoping};

use crate::actors::upstream::SendQuery;
use crate::actors::upstream::{UpstreamQuery, UpstreamRelay};
use crate::actors::upstream::{RequestPriority, UpstreamQuery, UpstreamRelay, WithRequestPriority};
use crate::ServerError;

// Choose the outcome module implementation (either processing or non-processing).
Expand Down Expand Up @@ -55,6 +55,12 @@ impl UpstreamQuery for SendOutcomes {
}
}

impl WithRequestPriority for SendOutcomes {
fn priority() -> RequestPriority {
RequestPriority::Low
}
}

/// Defines the structure of the HTTP outcomes responses for successful requests
#[derive(Debug, Deserialize, Serialize)]
pub struct SendOutcomesResponse {
Expand Down
10 changes: 9 additions & 1 deletion relay-server/src/actors/project_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ use serde::{Deserialize, Serialize};
use relay_common::{metric, LogError, ProjectId};
use relay_config::Config;

use crate::actors::upstream::{SendQuery, UpstreamQuery, UpstreamRelay};
use crate::actors::upstream::{
RequestPriority, SendQuery, UpstreamQuery, UpstreamRelay, WithRequestPriority,
};
use crate::metrics::{RelayCounters, RelayTimers};
use crate::utils::Response;

Expand Down Expand Up @@ -47,6 +49,12 @@ impl UpstreamQuery for GetProjectIds {
}
}

impl WithRequestPriority for GetProjectIds {
fn priority() -> RequestPriority {
RequestPriority::High
}
}

#[derive(Debug)]
struct ProjectIdChannel {
sender: oneshot::Sender<Option<ProjectId>>,
Expand Down
10 changes: 9 additions & 1 deletion relay-server/src/actors/project_upstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ use relay_config::Config;

use crate::actors::project::ProjectState;
use crate::actors::project_cache::{FetchProjectState, ProjectError, ProjectStateResponse};
use crate::actors::upstream::{SendQuery, UpstreamQuery, UpstreamRelay};
use crate::actors::upstream::{
RequestPriority, SendQuery, UpstreamQuery, UpstreamRelay, WithRequestPriority,
};
use crate::metrics::{RelayCounters, RelayHistograms, RelayTimers};
use crate::utils::{self, ErrorBoundary};

Expand All @@ -27,6 +29,12 @@ pub struct GetProjectStates {
pub full_config: bool,
}

impl WithRequestPriority for GetProjectStates {
fn priority() -> RequestPriority {
RequestPriority::High
}
}

#[derive(Debug, Deserialize, Serialize)]
pub struct GetProjectStatesResponse {
pub configs: HashMap<ProjectId, ErrorBoundary<Option<ProjectState>>>,
Expand Down
10 changes: 9 additions & 1 deletion relay-server/src/actors/relays.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ use relay_auth::{PublicKey, RelayId};
use relay_common::{LogError, RetryBackoff};
use relay_config::Config;

use crate::actors::upstream::{SendQuery, UpstreamQuery, UpstreamRelay};
use crate::actors::upstream::{
RequestPriority, SendQuery, UpstreamQuery, UpstreamRelay, WithRequestPriority,
};
use crate::utils::{self, ApiErrorResponse, Response};

#[derive(Fail, Debug)]
Expand Down Expand Up @@ -334,6 +336,12 @@ impl UpstreamQuery for GetRelays {
}
}

impl WithRequestPriority for GetRelays {
fn priority() -> RequestPriority {
RequestPriority::High
}
}

impl Handler<GetRelays> for RelayCache {
type Result = Response<GetRelaysResult, KeyError>;

Expand Down
Loading