Skip to content
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

Support use of Serde derive for fluvio protocol #3799

Open
sehz opened this issue Dec 27, 2023 · 0 comments
Open

Support use of Serde derive for fluvio protocol #3799

sehz opened this issue Dec 27, 2023 · 0 comments
Labels
help wanted Good issue for community involvement protocol support technical debt

Comments

@sehz
Copy link
Contributor

sehz commented Dec 27, 2023

It would be nice to use Serde for encoding/decoding fluvio protocol. The core encoder/encoder trait doesn't need to be changed; it's about writing Serde Serializer/Deserialize so we can leverage Serde procedure macro instead of maintaining our own. Tricky is to add support for Fluvio metadata, such as versions and default behavior.

So instead of this:

use fluvio_protocol::{Decoder, DecoderVarInt};
use serde::{Serialize,Deserialize}

#[derive(Encoder, Decoder, Default, Debug,Serialize,Deserialize)]
pub struct SimpleRecord {
    #[fluvio(min_version = 1)]
    len: i64,
    attributes: i8,
}

It can be written as this.

use fluvio_protocol::{Metadata};
use serde::{Serialize,Deserialize}

#[derive(Metadata, Default, Debug,Serialize,Deserialize)]
pub struct SimpleRecord {
    #[fluvio(min_version = 1)]
    len: i64,
    attributes: i8,
}

https://github.com/unegare/rust-notes/blob/master/serde-custom-derive-deserialize-synthetic-fields/src/main.rs
https://github.com/bincode-org/bincode/tree/trunk/src

@sehz sehz added help wanted Good issue for community involvement protocol support technical debt labels Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Good issue for community involvement protocol support technical debt
Projects
None yet
Development

No branches or pull requests

1 participant