chore (backend-rs): publish -> publish_to_stream
This commit is contained in:
parent
9b91035a79
commit
ec940bb068
2 changed files with 8 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
|||
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 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 {
|
||||
id: antenna_id.to_string(),
|
||||
};
|
||||
publish(
|
||||
publish_to_stream(
|
||||
&stream,
|
||||
Some("note"),
|
||||
Some(format!("{{ \"id\": \"{}\" }}", note_id)),
|
||||
|
|
|
@ -42,7 +42,11 @@ pub enum Error {
|
|||
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 {
|
||||
format!(
|
||||
"{{ \"type\": \"{}\", \"body\": {} }}",
|
||||
|
@ -60,7 +64,7 @@ pub fn publish(channel: &Stream, kind: Option<&str>, value: Option<String>) -> R
|
|||
&CONFIG.host,
|
||||
format!(
|
||||
"{{ \"channel\": \"{}\", \"message\": {} }}",
|
||||
channel, message,
|
||||
stream, message,
|
||||
),
|
||||
)?;
|
||||
|
||||
|
|
Loading…
Reference in a new issue