eclipse / kuksa.val

kuksa.val
Apache License 2.0
95 stars 51 forks source link

Add iterator access for entries #645

Closed argerus closed 1 year ago

argerus commented 1 year ago

A wrapper function that made it easy to iterate through metadata was already available in the broker interface:

broker
    .map_metadata(|metadata| proto::Metadata::from(metadata))
    .await

This has been generalized to iterate over entries instead (i.e. not only metadata) as that will be useful when in the kuksa.val.v1 interface for example:

broker
    .map_entries(|entry| {
        // Extract stuff from all entries (including metadata)
    }).await

broker
    .filter_map_entries(|entry| {
        // Extract stuff from some entries (including metadata)
    }).await
argerus commented 1 year ago

LGTM just one question. Will filter_map_entries get used cause currently I see not how it gets used. And just to confirm the adaptions get only used in grpc/sdv_databroker_v1 because in the grpc/kuksa_val_v1 the feature is not implemented yet - am I right?

Correct (on both counts). The reason for adding it (filter_map_entries etc) is that it would have made #641 and similar functionality easier to implement. That PR is already merged, and added very interface specific code to broker.rs. That code can be moved out to live along the rest of the interface specific code when this PR is merged.