Skip to main content

impl_fixed_key_processor

Macro impl_fixed_key_processor 

Source
macro_rules! impl_fixed_key_processor {
    (
        impl $processor:ty: ($kin:ty, $vin:ty) -> $vout:ty {
            async fn process(&mut self, $ctx:ident, $record:ident) $process_body:block
        }
    ) => { ... };
}
Expand description

Implement FixedKeyProcessor with a compact (key, input_value) -> output_value declaration.

use crabka_client_streams::impl_fixed_key_processor;

struct UpperValue;
impl_fixed_key_processor! {
    impl UpperValue: (String, String) -> String {
        async fn process(&mut self, ctx, r) {
            let v = r.value.clone();
            ctx.forward(r.with_value(v.to_uppercase()));
        }
    }
}