Comments (5)
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.
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.
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.
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.
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)
- panicked when working with tokio async HOT 10
- Support using "blocking" and "async_impl" features at the same time HOT 3
- New maintainance release with at least Tokio 1.0
- Have a way to leave out the full_name for the Proto Encoder HOT 1
- Implement std::error::Error for SRCError HOT 1
- Move Ci to Github Actions
- Have an easy way to use the async variants
- Improve readme
- multiple values encoding/decoding HOT 8
- Doubt regarding deserialization HOT 9
- Move caches to dashmap::DashMap
- Listing subjects and versions HOT 4
- Switch to apache-avro HOT 11
- Support for schema reference validation HOT 5
- Provide access to the schema in a DecodeResult ? HOT 4
- Remove or replace failure dependency HOT 1
- Support additional local protobuf definitions HOT 8
- Support Fetching Protobuf Field Names HOT 5
- Not all types are supported. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from schema_registry_converter.