Plants
A RIDDL plant
is a definition that combines pipes
with processors to specify a model of how data
should flow. You may define as many plants as needed but each plant is a closed
system without the ability of the RIDDL model to express the sharing of data
between the plants. This is done deliberately to prevent unintentional
contamination of data in large models.
The purpose of a plant definition is to provide the blueprint for how a set of pipes, processors, and entities are joined together so that data may flow end-to-end. This is done by using:
- the names and types of inlets in processors
- the names and types of outlets in processors
- the names and content types of pipes
- the definition of a
joint
to connect pipes and processors
For example, consider this complete plant definition:
domain AnyDomain is {
plant SensorMaintenance is {
source GetWeatherForecast is {
outlet Weather is type Forecast
} described by "This is a source for Forecast data"
flow GetCurrentTemperature is {
inlet Weather is type Forecast
outlet CurrentTemp is type Temperature
} explained as "This is a Flow for the current temperature, when it changes"
pipe WeatherForecast is {
transmit type Forecast
from outlet GetWeatherForecast.Weather
to inlet GetCurrentTemperature.inlet
} explained as "Carries changes in the current weather forecast"
pipe TemperatureChanges is {
transmit type temperature
from outlet GetCurrentTemperature.CurrentTemp
to inlet AttenuateSensor.CurrentTemp from
} explained as "Carries changes in the current temperature"
repository AttenuateSensor is {
inlet CurrentTemp is record Temperature
} explained as "This is a Sink for making sensor adjustments based on temperature"
} explained as
"A complete plant definition for temperature based sensor attenuation."
} explained as "Plants can only be specified in a domain definition"
In other words, the above plant definition produces this kind of data pipeline:
graph LR; subgraph GetWeatherForecast subgraph Weather:outlet end end subgraph GetCurrentTemperature subgraph Weather:inlet end subgraph CurrentTemperature:outlet end end subgraph AttenuateSensor subgraph CurrentTemperature:inlet end end Weather:outlet -->|WeatherForecast| Weather:inlet CurrentTemperature:outlet -->|TemperatureChange| CurrentTemperature:inlet
In the diagram, the arrows represent pipes, yellow boxes represent processors and the grey boxes represent the inlet and outlet connection points.
Plants are entirely type safe. This means the data type that a pipe
transmits must match the data type of the publishing processors (outlets) and
the data types of the consuming processors (inlets). When riddlc
processes
a plant specification, it ensures that all the inlet and outlet data types
match the data types of the connected pipes.
In the above example, note that each inlet/outlet pair has the same type
name (Weather
and CurrentTemperature
).
An entity may also be used as a processor under some special circumstances:
- as a source - An entity may be used as a source of events if a command handler is defined for the entity.
- as a sink - An entity may be used as a sink for events if a reaction handler is defined for the entity.
- as a flow - An entity may be used as a flow to convert commands into events
TBD