Skip to content

Commit

Permalink
Merge pull request #25 from DaanDD/no-static-str
Browse files Browse the repository at this point in the history
Allow for regular strings instead of only static strings
  • Loading branch information
johnmanjiro13 committed Jul 14, 2023
2 parents 6e04289 + 4ac20ae commit 2e22a30
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
15 changes: 5 additions & 10 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl Default for Config {

#[async_trait]
pub trait FluentClient: Send + Sync {
fn send(&self, tag: &'static str, record: Map) -> Result<(), SendError>;
fn send(&self, tag: &str, record: Map) -> Result<(), SendError>;
async fn stop(self) -> Result<(), SendError>;
}

Expand Down Expand Up @@ -114,14 +114,9 @@ impl Client {
Ok(Self { sender })
}

fn send_with_time(
&self,
tag: &'static str,
record: Map,
timestamp: i64,
) -> Result<(), SendError> {
fn send_with_time(&self, tag: &str, record: Map, timestamp: i64) -> Result<(), SendError> {
let record = Record {
tag,
tag: tag.into(),
record,
timestamp,
options: Options {
Expand All @@ -144,7 +139,7 @@ impl FluentClient for Client {
/// `tag` - Event category of a record to send.
///
/// `record` - Map object to send as a fluent record.
fn send(&self, tag: &'static str, record: Map) -> Result<(), SendError> {
fn send(&self, tag: &str, record: Map) -> Result<(), SendError> {
self.send_with_time(tag, record, chrono::Local::now().timestamp())
}

Expand All @@ -169,7 +164,7 @@ pub struct NopClient;

#[async_trait]
impl FluentClient for NopClient {
fn send(&self, _tag: &'static str, _record: Map) -> Result<(), SendError> {
fn send(&self, _tag: &str, _record: Map) -> Result<(), SendError> {
Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl std::fmt::Display for Error {

#[derive(Debug, Serialize)]
pub struct Record {
pub tag: &'static str,
pub tag: String,
pub timestamp: i64,
pub record: Map,
pub options: Options,
Expand Down

0 comments on commit 2e22a30

Please sign in to comment.