-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(spooler): Add initialization of stacks (#3967)
- Loading branch information
1 parent
a7f5714
commit ec1cb2a
Showing
14 changed files
with
396 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use relay_base_schema::project::ProjectKey; | ||
|
||
use crate::Envelope; | ||
|
||
/// Struct that represents two project keys. | ||
#[derive(Debug, Clone, Copy, Eq, Hash, Ord, PartialOrd, PartialEq)] | ||
pub struct ProjectKeyPair { | ||
pub own_key: ProjectKey, | ||
pub sampling_key: ProjectKey, | ||
} | ||
|
||
impl ProjectKeyPair { | ||
pub fn new(own_key: ProjectKey, sampling_key: ProjectKey) -> Self { | ||
Self { | ||
own_key, | ||
sampling_key, | ||
} | ||
} | ||
|
||
pub fn from_envelope(envelope: &Envelope) -> Self { | ||
let own_key = envelope.meta().public_key(); | ||
let sampling_key = envelope.sampling_key().unwrap_or(own_key); | ||
Self::new(own_key, sampling_key) | ||
} | ||
|
||
pub fn iter(&self) -> impl Iterator<Item = ProjectKey> { | ||
let Self { | ||
own_key, | ||
sampling_key, | ||
} = self; | ||
std::iter::once(*own_key).chain((own_key != sampling_key).then_some(*sampling_key)) | ||
} | ||
} |
Oops, something went wrong.