meow
This commit is contained in:
@@ -11,7 +11,7 @@ use chrono::{DateTime, Local, Timelike};
|
||||
use iced::futures::{channel::mpsc, SinkExt};
|
||||
use iced::Subscription;
|
||||
|
||||
use common::{ClockKind, ClockPayload, Endpoint, Inbox, Wire};
|
||||
use common::{ClockPayload, Endpoint, Inbox, Wire};
|
||||
|
||||
/// Route-key namespace owned by this service; keys are `"clock.<kind>"`.
|
||||
pub const NAMESPACE: &str = "clock.";
|
||||
@@ -44,7 +44,7 @@ impl ClockTicker {
|
||||
tokio::select! {
|
||||
_ = interval.tick() => {
|
||||
if let Some(payload) = clock.tick() {
|
||||
tracing::debug!(key, kind = ?payload.kind, "publishing clock");
|
||||
tracing::debug!(key, ?payload, "publishing clock");
|
||||
let wire = Wire::topic(Endpoint::service(key), key, payload);
|
||||
if sender.send(wire).await.is_err() {
|
||||
tracing::warn!(key, "clock send failed; stopping service");
|
||||
@@ -63,16 +63,10 @@ impl ClockTicker {
|
||||
let value = chrono::Local::now();
|
||||
let meow = self.last;
|
||||
if meow.minute() != value.minute() {
|
||||
return Some(ClockPayload {
|
||||
kind: ClockKind::Mins,
|
||||
value: value.format("%H:%M:%S").to_string(),
|
||||
});
|
||||
return Some(ClockPayload::Mins(value.format("%H:%M:%S").to_string()));
|
||||
}
|
||||
if meow.second() != value.second() {
|
||||
return Some(ClockPayload {
|
||||
kind: ClockKind::Seconds,
|
||||
value: value.format("%H:%M:%S").to_string(),
|
||||
});
|
||||
return Some(ClockPayload::Seconds(value.format("%H:%M:%S").to_string()));
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user