chore (backend-rs): publish -> publish_to_stream
This commit is contained in:
parent
9b91035a79
commit
ec940bb068
|
@ -1,5 +1,5 @@
|
||||||
use crate::database::{redis_conn, redis_key};
|
use crate::database::{redis_conn, redis_key};
|
||||||
use crate::service::stream::{publish, Error, Stream};
|
use crate::service::stream::{publish_to_stream, Error, Stream};
|
||||||
use crate::util::id::get_timestamp;
|
use crate::util::id::get_timestamp;
|
||||||
use redis::{streams::StreamMaxlen, Commands};
|
use redis::{streams::StreamMaxlen, Commands};
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ pub fn add_note_to_antenna(antenna_id: &str, note_id: &str) -> Result<(), Error>
|
||||||
let stream = Stream::Antenna {
|
let stream = Stream::Antenna {
|
||||||
id: antenna_id.to_string(),
|
id: antenna_id.to_string(),
|
||||||
};
|
};
|
||||||
publish(
|
publish_to_stream(
|
||||||
&stream,
|
&stream,
|
||||||
Some("note"),
|
Some("note"),
|
||||||
Some(format!("{{ \"id\": \"{}\" }}", note_id)),
|
Some(format!("{{ \"id\": \"{}\" }}", note_id)),
|
||||||
|
|
|
@ -42,7 +42,11 @@ pub enum Error {
|
||||||
ValueError(String),
|
ValueError(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn publish(channel: &Stream, kind: Option<&str>, value: Option<String>) -> Result<(), Error> {
|
pub fn publish_to_stream(
|
||||||
|
stream: &Stream,
|
||||||
|
kind: Option<&str>,
|
||||||
|
value: Option<String>,
|
||||||
|
) -> Result<(), Error> {
|
||||||
let message = if let Some(kind) = kind {
|
let message = if let Some(kind) = kind {
|
||||||
format!(
|
format!(
|
||||||
"{{ \"type\": \"{}\", \"body\": {} }}",
|
"{{ \"type\": \"{}\", \"body\": {} }}",
|
||||||
|
@ -60,7 +64,7 @@ pub fn publish(channel: &Stream, kind: Option<&str>, value: Option<String>) -> R
|
||||||
&CONFIG.host,
|
&CONFIG.host,
|
||||||
format!(
|
format!(
|
||||||
"{{ \"channel\": \"{}\", \"message\": {} }}",
|
"{{ \"channel\": \"{}\", \"message\": {} }}",
|
||||||
channel, message,
|
stream, message,
|
||||||
),
|
),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue