Skip to content

Commit

Permalink
feat(logger): use "/" as a delimiter between an actor's group and key
Browse files Browse the repository at this point in the history
Closes #74
  • Loading branch information
loyd committed Oct 1, 2024
1 parent b35a97b commit 7712af8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- core/envelope: add `Envelope::request_id()`.
- core/config: impl `FromStr` for `Secret` ([#135]).
- core/init: emit the `elfo_start_time_seconds` metric.
- core/actor: implement `Display` for `ActorMeta` ([#74]).

### Changed
- **BREAKING** core/node: remove `node` module, `NodeNo` is moved to `addr`.
- logger: use `/` as a delimiter between an actor's group and key ([#74]).
- core/addr: expose the `addr` module.
- core: generate `NodeNo` randomly if not provided.
- network: don't force `safe-*` features of lz4_flex ([#136]).

### Fixed
- core: update the `idr-ebr` crate to v0.3 to fix possible crash in `Context::finished()`.

[#74]: https://github.com/elfo-rs/elfo/issues/74
[#135]: https://github.com/elfo-rs/elfo/pull/135
[#136]: https://github.com/elfo-rs/elfo/pull/136

Expand Down
17 changes: 16 additions & 1 deletion elfo-core/src/actor.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::{
mem,
fmt, mem,
sync::{atomic, Arc},
};

Expand Down Expand Up @@ -29,10 +29,25 @@ use crate::{
/// Represents meta information about actor: his group and key.
#[derive(Debug, Hash, PartialEq, Eq, Serialize, Deserialize)]
pub struct ActorMeta {
/// Actor's group name set in the topology.
pub group: String,
/// Actor's key set by the router.
pub key: String,
}

impl fmt::Display for ActorMeta {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(&self.group)?;

if !self.key.is_empty() {
f.write_str("/")?;
f.write_str(&self.key)?;
}

Ok(())
}
}

// === ActorStartInfo ===

/// A struct holding information related to an actor start.
Expand Down
7 changes: 1 addition & 6 deletions elfo-logger/src/formatters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,7 @@ impl Formatter<TraceId> for TraceId {

impl Formatter<Arc<ActorMeta>> for Arc<ActorMeta> {
fn fmt(out: &mut String, v: &Arc<ActorMeta>) {
out.push_str(&v.group);

if !v.key.is_empty() {
out.push('.');
out.push_str(&v.key);
}
let _ = write!(out, "{v}");
}
}

Expand Down

0 comments on commit 7712af8

Please sign in to comment.