Skip to content

Commit

Permalink
feat(core/envelope): add Envelope::request_id()
Browse files Browse the repository at this point in the history
  • Loading branch information
loyd committed Aug 13, 2024
1 parent 1c97751 commit 0f43874
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] - ReleaseDate
### Added
- core/topology: add `Topology::set_node_no()` and `Topology::node_no()`.
- core/envelope: add `Envelope::request_id()`.

### Changed
- **BREAKING** core/node: remove `node` module, `NodeNo` is moved to `addr`.
Expand Down
10 changes: 10 additions & 0 deletions elfo-core/src/envelope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ impl Envelope {
}
}

#[inline]
pub fn request_id(&self) -> Option<RequestId> {
match self.message_kind() {
MessageKind::Regular { .. } => None,
MessageKind::RequestAny(token) => Some(token.request_id()),
MessageKind::RequestAll(token) => Some(token.request_id()),
MessageKind::Response { request_id, .. } => Some(*request_id),
}
}

#[doc(hidden)]
#[inline]
pub fn type_id(&self) -> MessageTypeId {
Expand Down
3 changes: 1 addition & 2 deletions elfo-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub use crate::{
group::{ActorGroup, Blueprint, TerminationPolicy},
local::{Local, MoveOwnership},
message::{AnyMessage, AnyMessageRef, Message, Request},
request_table::ResponseToken,
request_table::{RequestId, ResponseToken},
restarting::{RestartParams, RestartPolicy},
source::{SourceHandle, UnattachedSource},
topology::Topology,
Expand Down Expand Up @@ -86,7 +86,6 @@ pub mod _priv {
message::*,
object::{GroupVisitor, Object, OwnedObject},
permissions::{AtomicPermissions, Permissions},
request_table::RequestId,
};
pub use erased_serde;
pub use idr_ebr::EbrGuard;
Expand Down
6 changes: 1 addition & 5 deletions elfo-network/src/codec/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ use byteorder::{LittleEndian, ReadBytesExt};
use eyre::{ensure, eyre, Error, WrapErr};
use tracing::error;

use elfo_core::{
_priv::{AnyMessage, RequestId},
errors::RequestError,
tracing::TraceId,
};
use elfo_core::{errors::RequestError, tracing::TraceId, AnyMessage, RequestId};
use elfo_utils::likely;

use crate::codec::format::{
Expand Down
3 changes: 1 addition & 2 deletions elfo-network/src/codec/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ use elfo_core::{
addr::{Addr, NodeNo},
errors::RequestError,
tracing::TraceId,
AnyMessage, Message,
_priv::RequestId,
AnyMessage, Message, RequestId,
};
use elfo_utils::likely;

Expand Down
2 changes: 1 addition & 1 deletion elfo-network/src/worker/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use fxhash::FxHashMap;
use metrics::{decrement_gauge, increment_gauge};
use tracing::error;

use elfo_core::{Addr, ResponseToken, _priv::RequestId};
use elfo_core::{Addr, RequestId, ResponseToken};

#[derive(Default)]
pub(super) struct OutgoingRequests {
Expand Down

0 comments on commit 0f43874

Please sign in to comment.