Skip to content

chore: ~bump ver v0.4.0 #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "watcher"
description = "subscribe data changes"
version = "0.3.0"
version = "0.4.0"
authors = ["Databend Authors <opensource@datafuselabs.com>"]
license = "Apache-2.0"
edition = "2021"
Expand Down
2 changes: 1 addition & 1 deletion src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl TypeConfig for UTTypes {
type Response = (String, Option<String>, Option<String>);
type Error = io::Error;

fn new_flush_response(key: KeyOf<Self>, value: ValueOf<Self>) -> Self::Response {
fn new_initialize_response(key: KeyOf<Self>, value: ValueOf<Self>) -> Self::Response {
(key, None, Some(value))
}

Expand Down
4 changes: 2 additions & 2 deletions src/type_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ where Self: Debug + Clone + Copy + Sized + 'static
/// The type of errors returned to watchers.
type Error: Error + Send + 'static;

/// Create a new response instance from existent key value pair.
fn new_flush_response(key: KeyOf<Self>, value: ValueOf<Self>) -> Self::Response;
/// Create a new response instance from existent key value pair, for initialization.
fn new_initialize_response(key: KeyOf<Self>, value: ValueOf<Self>) -> Self::Response;

/// Create a response instance from a key-value change.
fn new_change_response(change: KVChange<Self>) -> Self::Response;
Expand Down
12 changes: 6 additions & 6 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ use crate::WatchResult;
/// Wraps a tokio mpsc Sender in a Sink that can receive `KeySeqVResult` items.
/// Each item is converted before being sent.
///
/// This function is used for initial-flush, not for actual key-value change, i.e.,
/// This function is used for initialization-flush, not for actual key-value change, i.e.,
/// an actual key-value change contains 3 element: key, before-value and after-value.
pub fn new_flush_sink<C>(
pub fn new_initialization_sink<C>(
tx: mpsc::Sender<WatchResult<C>>,
ctx: &'static str,
) -> impl Sink<KVResult<C>, Error = PollSendError<WatchResult<C>>> + Send + 'static
Expand All @@ -50,7 +50,7 @@ where
let snk = assert_sink::<WatchResult<C>, _, _>(snk);

let snk = snk.with(move |res: KVResult<C>| {
let watch_result = kv_result_to_flush_result::<C>(res, ctx);
let watch_result = kv_result_to_initialization_result::<C>(res, ctx);
futures::future::ready(Ok::<_, PollSendError<_>>(watch_result))
});

Expand Down Expand Up @@ -86,15 +86,15 @@ where
}
}

/// Converts a key-value result to a initial-flush watch result.
/// Converts a key-value result to an initialization-flush watch result.
///
/// Transforms a [`KVResult`] into a [`WatchResult`].
/// Error is converted by the application defined method `data_error`
fn kv_result_to_flush_result<C>(input: KVResult<C>, ctx: &'static str) -> WatchResult<C>
fn kv_result_to_initialization_result<C>(input: KVResult<C>, ctx: &'static str) -> WatchResult<C>
where C: TypeConfig {
match input {
Ok((key, value)) => {
let resp = C::new_flush_response(key, value);
let resp = C::new_initialize_response(key, value);
Ok(resp)
}
Err(err) => {
Expand Down
2 changes: 1 addition & 1 deletion tests/it/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl TypeConfig for Types {
type Response = (String, Option<String>, Option<String>);
type Error = io::Error;

fn new_flush_response(key: KeyOf<Self>, value: ValueOf<Self>) -> Self::Response {
fn new_initialize_response(key: KeyOf<Self>, value: ValueOf<Self>) -> Self::Response {
(key, None, Some(value))
}

Expand Down
Loading