Skip to content

Commit 95a12ec

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
1 parent 8687fe3 commit 95a12ec

File tree

1 file changed

+55
-6
lines changed

1 file changed

+55
-6
lines changed

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

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

137177
// Duration in seconds
138178
// The duration of the dispatch in seconds. If the duration is not set, the dispatch
139-
// will be considered to have an infinite duration.
179+
// will be considered to have an indefinite duration.
180+
//
140181
// A duration of 0 seconds is also valid, indicating a dispatch that
141182
// immediately starts and ends, e.g. switching a component on and off.
183+
//
184+
// Indefinite durations do not guarantee an eventual end; they continue until external logic changes it.
142185
optional uint32 duration = 3;
143186

144187
// The components this dispatch should apply to.
@@ -196,9 +239,15 @@ message DispatchMetadata {
196239
google.protobuf.Timestamp update_time = 3;
197240

198241
// UTC Timestamp when the dispatch will stop working.
242+
//
199243
// 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.
244+
// duration and RecurrenceRule settings. If the duration is not set (indefinite duration),
245+
// there may be no calculable `end_time`. This means the dispatch does not have a
246+
// predetermined stopping point and might run indefinitely. External logic, changes in
247+
// conditions, or achieving certain operational goals may lead to its termination. If no
248+
// such terminating condition occurs, it may effectively continue "forever."
249+
//
250+
// None if dispatch duration time is unset and this value can't be calculated.
202251
google.protobuf.Timestamp end_time = 4;
203252
}
204253

0 commit comments

Comments
 (0)