Code Monkey home page Code Monkey logo

Comments (5)

calvinbrown085 avatar calvinbrown085 commented on June 28, 2024 1
let sr_settings: SrSettings =
        SrSettings::new("http://avro-schemas.kafka.svc.cluster.local".to_string());
let decoder: Arc<Mutex<AvroDecoder>> = Arc::new(Mutex::new(AvroDecoder::new(sr_settings)));

    let stream_processor = consumer.start().try_for_each(|borrowed_message| {
        let decoder: Arc<Mutex<AvroDecoder>> = Arc::clone(&decoder);

        let owned_message = borrowed_message.detach();

        async move {
            let r: Option<Value> = get_value(owned_message, decoder.lock().unwrap()).await;
            });
            consumer.store_offset(&borrowed_message);
            Ok(())
        }
    });

This compiles but i'm not 100% sure that it works.

from schema_registry_converter.

gklijs avatar gklijs commented on June 28, 2024

It's correct you can't copy it, and you don't want to either, since it's containing the cache. I'm working towards a demo project using async and protobuf, but it could be several weeks or more till it's finished.

I know undeflive had it working, see #33, but having an async 'real' example would certainly be an improvement. I think using it would require wrapping the decoder in a mutex, but there might be better or other ways. The idea is whenever the decoder is used, the result is cashed, so no matter from which thread, only the first item handeled with the same id, does the http call to get the schema.

from schema_registry_converter.

calvinbrown085 avatar calvinbrown085 commented on June 28, 2024

Yeah. Okay i'll look into trying a mutex, and yeah I tried the blocking client but ran into the same issue as #33

I'll let you know what I come up with!

from schema_registry_converter.

gklijs avatar gklijs commented on June 28, 2024

I think ideally you might want a decoder for each 'real' thread. In that case you might fetch the same resource a couple of times, but you never need to wait. But I'm not sure something like that exists. I have little experience with async so far. Looking forward to what you come up with.

from schema_registry_converter.

gklijs avatar gklijs commented on June 28, 2024

Since you got an answer and got it to compile again I'm closing this. Would love to know if you got it working.

from schema_registry_converter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.