Skip to content

Commit 2f07258

Browse files
committed
docs: Clarify indefinite and recurring dispatches
This commit clarifies the behavior of dispatches with indefinite durations, especially in the context of recurring dispatches. It explains how overlapping dispatches can be handled, either by creating new instances or overwriting existing ones based on type or target. Fixes #221 Signed-off-by: Mathias L. Baumann <[email protected]>
1 parent fb84b0b commit 2f07258

File tree

1 file changed

+53
-6
lines changed

1 file changed

+53
-6
lines changed

proto/frequenz/api/dispatch/v1/dispatch.proto

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,48 @@ message StreamMicrogridDispatchesResponse {
117117
}
118118

119119
// Represents a dispatches data, including its type, start time, duration,
120-
// and target components.
120+
// and target microgrid components.
121+
//
122+
// This `DispatchData` message describes a single dispatch instance. If a dispatch is set to recur,
123+
// each occurrence is defined by `DispatchData` in combination with `RecurrenceRule`.
124+
//
125+
// !!! note "Indefinite Durations"
126+
// This API allows dispatches to have an indefinite duration if the `duration` field
127+
// is not set. Indefinite means:
128+
// - There is no predefined end time known at dispatch creation.
129+
// - The dispatch could, in theory, run indefinitely if no external conditions stop it.
130+
// - External logic or changing conditions may end the dispatch at any time. For example,
131+
// once a certain operational goal is met (like reaching a particular state-of-charge),
132+
// the dispatch may end, or it may be allowed to continue if conditions warrant it.
133+
// - Indefinite durations apply to each occurrence individually—every instance of a recurring
134+
// dispatch can also be indefinite.
135+
//
136+
// For instance, a dispatch might aim to keep a battery’s SoC stable. If conditions never
137+
// change, it could theoretically run forever. Conversely, another indefinite dispatch might
138+
// end as soon as a particular SoC goal is reached.
139+
//
140+
// !!! note "Recurring Indefinite Dispatches"
141+
// How recurring indefinite dispatches are managed is implementation-dependent.
142+
// A key consideration is how to handle overlapping occurrences. For example, if a new
143+
// dispatch is scheduled to start while a previous one is still running, the system
144+
// needs a strategy to manage this.
145+
//
146+
// Commonly used approaches include:
147+
// 1. **Start a new instance:** Each dispatch occurrence creates a new, independent
148+
// instance that runs in parallel with any existing ones. This can lead to
149+
// multiple dispatches "stacking up" if not managed carefully.
150+
// 2. **Overwrite existing instances:** A new dispatch can replace an existing one
151+
// based on certain criteria, such as having the same `type` or `target`
152+
// components. This prevents multiple dispatches from running for the same
153+
// purpose simultaneously.
154+
//
155+
// The chosen strategy is critical for preventing resource contention and ensuring
156+
// predictable behavior, especially with indefinite, recurring dispatches.
157+
//
158+
// !!! note "Timestamps"
159+
// Timestamps are in UTC. It is the responsibility of the receiver to translate UTC
160+
// to respective local timezone.
121161
//
122-
// Timezone Note: Timestamps are in UTC. It is the responsibility of each microgrid to translate UTC
123-
// to its local timezone.
124162
message DispatchData {
125163
// The dispatch type.
126164
// Contains user-defined information about what "type" of dispatch this is.
@@ -136,9 +174,12 @@ message DispatchData {
136174

137175
// Duration in seconds
138176
// The duration of the dispatch in seconds. If the duration is not set, the dispatch
139-
// will be considered to have an infinite duration.
177+
// will be considered to have an indefinite duration.
178+
//
140179
// A duration of 0 seconds is also valid, indicating a dispatch that
141180
// immediately starts and ends, e.g. switching a component on and off.
181+
//
182+
// Indefinite durations do not guarantee an eventual end; they continue until external logic changes it.
142183
optional uint32 duration = 3;
143184

144185
// The components this dispatch should apply to.
@@ -196,9 +237,15 @@ message DispatchMetadata {
196237
google.protobuf.Timestamp update_time = 3;
197238

198239
// UTC Timestamp when the dispatch will stop working.
240+
//
199241
// Will be calculated internally based on the given: start_time,
200-
// duration and RecurenceRule
201-
// None if dispatch duration time is infinite and this value can't be calculated.
242+
// duration and `RecurrenceRule` settings. If the duration is not set (indefinite duration),
243+
// there may be no calculable `end_time`. This means the dispatch does not have a
244+
// predetermined stopping point and might run indefinitely. External logic, changes in
245+
// conditions, or achieving certain operational goals may lead to its termination. If no
246+
// such terminating condition occurs, it may effectively continue "forever."
247+
//
248+
// None if dispatch duration time is unset and this value can't be calculated.
202249
google.protobuf.Timestamp end_time = 4;
203250
}
204251

0 commit comments

Comments
 (0)