-
Notifications
You must be signed in to change notification settings - Fork 20
Composite operator
For easy reuse and combination of Operators (and only Operators, for now), Zenoh-Flow supports Composite Operator descriptor. The purpose is to merge several Operators in a single descriptor file, producing a "meta"-Operator that can be used in a data flow descriptor.
For the sake of explanation, let us assume that you already implemented the following two operators:
-
an operator that receives a float and subtract a constant (configured through its
configuration
) to it,id: subtract vars: BASE_PATH: /home/zenoh/dev/nodes LIB_PATH: target/release/lib DLL_EXTENSION: so configuration: constant: 0 inputs: - id: in type: float outputs: - id: out type: float uri: "file://{{ BASE_PATH }}/subtract/{{ LIB_PATH }}subtract.{{ DLL_EXTENSION }}"
-
an operator that receives a float and divides it by a constant (also configured through its
configuration
).id: divide vars: BASE_PATH: /home/zenoh/dev/nodes LIB_PATH: target/release/lib DLL_EXTENSION: so configuration: constant: 1 inputs: - id: in type: float outputs: - id: out type: float uri: "file://{{ BASE_PATH }}/divide/{{ LIB_PATH }}divide.{{ DLL_EXTENSION }}"
Leveraging these two operators, we could easily create an Operator that converts a temperature expressed in Fahrenheit to Celsius:
- we first subtract 32,
- we then divide the result by 1.8.
Which would give the composite operator:
id: fahrenheit-to-celsius
vars:
BASE_PATH: /home/zenoh/dev/nodes
inputs:
- id: in-f2c
node: subtract
input: in
outputs:
- id: out-f2c
node: divide
output: out
operators:
- id: subtract
descriptor: "file://{{ BASE_PATH }}/subtract/subtract.yaml"
configuration:
constant: 32
- id: divide
descriptor: "file://{{ BASE_PATH }}/divide/divide.yaml"
configuration:
constant: 1.8
links:
- from:
node: subtract
output: out
to:
node: divide
input: in
As one can see, the descriptor is a mix between that of a data flow and an Operator:
- like a data flow descriptor, it has an
operators
and alinks
section, - like an Operator descriptor, it has an
inputs
and anoutputs
section.
The inputs
and outputs
sections differ to regular Nodes in that they must specify an id
. These
id
are the ones that must be use in a data flow (or other composite Operator).
-
Descriptor
- Data flow descriptor
-
Node descriptor
- (optional) Vars
- (optional) Configuration
- Inputs and/or Outputs
- URI
- Composite Operator
-
Node Implementation
-
Advanced