eclipse-uprotocol / up-spec

uProtocol Specifications
Apache License 2.0
32 stars 25 forks source link

`up-zenoh-recorder` & `up-zenoh-utwin`: How are they initialized and given the Zenoh `Runtime` they will use? #124

Closed PLeVasseur closed 4 months ago

PLeVasseur commented 4 months ago

Hey folks :wave:

Tagging in @mallets, @evshary, and @stevenhartley in particular.

From what I recall @evshary had started an experiment to see how we can start Zenoh plugins from within C++ or something to that effect. So I'd be interested to hear the parameters and outcome.


Given the topology diagram: image

I wanted to drill down a little deeper:

  1. How will the up-zenoh-utwin and up-zenoh-recorder plugins be initialized? a. From C++? b. From Rust?
  2. Is it even possible to pass the plugins the Zenoh Runtime they will require, from C++?
  3. If the plugins are initialized from C++, would the plugins need to have a C shim wrapped around them?
  4. I suppose we would add a new way to instantiate a UPClientZenoh based on a Zenoh Session?

A first attempt at laying out these components:

classDiagram

    %% Very important to understand the mechanism by which:
    %%  The plugins written in Rust (up-zenoh-recorder &
    %%  up-zenoh-utwin) will be started
    %%
    %% If they are started in a way that they are called into
    %% by Rust code, that is ideal.
    %%
    %% If they are started from C++ code, then it's less clear
    %% how this would work, as the plugins need to be given
    %% an instance of the Zenoh Runtime in order to create their
    %% own Zenoh Session to use

    class z["Zenoh Runtime"] {

    }

    class uzr["up-zenoh-recorder"] {
        +UPClientZenoh up_client
        +new(Zenoh Runtime) Result<>
    }

    class uzu["up-zenoh-utwin"] {
        +UPClientZenoh up_client
        +new(Zenoh Runtime) Result<>
    }

    class usc["up-streamer-cpp"] {

    }

    style usc fill:#647687,color:#fff
    style uzr fill:#A0522D,color:#fff
    style uzu fill:#A0522D,color:#fff
    style z fill:#A0522D,color:#fff

    usc --* z: Initializes
    usc --* uzr: How are these plugins initialized? <br> From Rust or C++?
    usc --* uzu: How are these plugins initialized? <br> From Rust or C++?
    uzr ..> z: Takes copy of Runtime, <br> creates Zenoh Session <br> and uses that to <br> initialize held UPClientZenoh
    uzu ..> z: Takes copy of Runtime, <br> creates Zenoh Session <br> and uses that to <br> initialize held UPClientZenoh
evshary commented 4 months ago

Hi @PLeVasseur

  1. How will the up-zenoh-utwin and up-zenoh-recorder plugins be initialized?
    • The plugins are written in Rust and can be loaded based on our configuration. zenoh-c is just a wrapper of Zenoh and the plugins are loaded in Zenoh.
  2. Is it even possible to pass the plugins the Zenoh Runtime they will require, from C++?
    • While opening a session in C++, it'll load the plugins with its runtime directly.
  3. If the plugins are initialized from C++, would the plugins need to have a C shim wrapped around them?
    • No, plugins are written in Rust in loaded by Zenoh. No need to consider C++.
  4. I suppose we would add a new way to instantiate a UPClientZenoh based on a Zenoh Session?
    • Yes. Since we only have runtime in plugins, we need to get Session based on that runtime and initialize UPClientZenoh with that Session. I can create a PR to update this.

Also, here are some references for you:

@Mallets Please correct me if I'm wrong.

PLeVasseur commented 4 months ago

Sounds to me based on @evshary's comment here and @Mallets's feedback on Slack that up-zenoh-utwin and up-zenoh-recorder can be standard Zenoh plugins written 100% in Rust.

Closing as resolved!