Skip to content

Commit

Permalink
Improve
Browse files Browse the repository at this point in the history
  • Loading branch information
iambriccardo committed Jul 30, 2024
1 parent a822832 commit 8325990
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
5 changes: 4 additions & 1 deletion relay-server/src/services/buffer/envelope_buffer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ impl EnvelopesBuffer {
#[derive(Debug)]
struct InnerEnvelopesBuffer<S: EnvelopeStack> {
/// The central priority queue.
priority_queue: priority_queue::PriorityQueue<QueueItem<StackKey, S>, Priority>,
priority_queue: priority_queue::PriorityQueue<
QueueItem<StackKey, <<S as EnvelopeStack>::Provider as StackProvider>::Stack>,
Priority,
>,
/// A lookup table to find all stacks involving a project.
stacks_by_project: hashbrown::HashMap<ProjectKey, BTreeSet<StackKey>>,
stack_provider: S::Provider,
Expand Down
4 changes: 2 additions & 2 deletions relay-server/src/services/buffer/envelope_stack/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub mod memory;
pub mod sqlite;

/// A stack-like data structure that holds [`Envelope`]s.
pub trait EnvelopeStack: Send {
pub trait EnvelopeStack: Send + std::fmt::Debug {
/// The error type that is returned when an error is encountered during reading or writing the
/// [`EnvelopeStack`].
type Error: std::fmt::Debug;
Expand All @@ -27,7 +27,7 @@ pub trait EnvelopeStack: Send {
fn pop(&mut self) -> impl Future<Output = Result<Option<Box<Envelope>>, Self::Error>>;
}

pub trait StackProvider {
pub trait StackProvider: std::fmt::Debug {
type Stack: EnvelopeStack;

fn create_stack(&self, envelope: Box<Envelope>) -> Self::Stack;
Expand Down
9 changes: 1 addition & 8 deletions relay-server/src/services/buffer/envelope_stack/sqlite.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
use std::collections::VecDeque;
use std::error::Error;
use std::fmt::Debug;
use std::num::NonZeroUsize;
use std::path::Path;

use futures::StreamExt;
use sqlx::sqlite::{SqliteConnectOptions, SqliteJournalMode, SqlitePoolOptions};
use sqlx::{Pool, Row, Sqlite};
use tokio::fs::DirBuilder;

use relay_base_schema::project::ProjectKey;

use crate::envelope::Envelope;
use crate::services::buffer::envelope_stack::{EnvelopeStack, StackProvider};
use crate::services::buffer::envelope_stack::EnvelopeStack;
use crate::services::buffer::sqlite_envelope_store::SqliteEnvelopeStore;
use crate::services::buffer::stack_provider::sqlite::SqliteStackProvider;

Expand Down
2 changes: 1 addition & 1 deletion relay-server/src/services/buffer/sqlite_envelope_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::extractors::StartTime;
use crate::services::buffer::envelope_stack::sqlite::SqliteEnvelopeStackError;
use crate::Envelope;

struct InsertEnvelope {
pub struct InsertEnvelope {
received_at: i64,
own_key: ProjectKey,
sampling_key: ProjectKey,
Expand Down

0 comments on commit 8325990

Please sign in to comment.