Skip to content

Commit 4086507

Browse files
Add rules for recurring dispatches (#57)
Fixes #9 Some examples: Every 6 months: ``` message RecurrenceRule { Frequency freq = FREQUENCY_MONTHLY; uint32 interval = 6; } ``` Weekends only: ``` message RecurrenceRule { Frequency freq = FREQUENCY_WEEKLY; repeated Weekday byweekdays = [WEEKDAY_SATURDAY, WEEKDAY_SUNDAY]; } ``` Every day at midnight: ``` message RecurrenceRule { Frequency freq = FREQUENCY_DAILY; repeated uint32 byhours = [0]; } ``` Nightly, assuming "night" means from 8 PM to 6 AM: ``` message RecurrenceRule { Frequency freq = FREQUENCY_DAILY; repeated uint32 byhours = [20, 21, 22, 23, 0, 1, 2, 3, 4, 5]; } ```
2 parents 8d3d23d + cfa3009 commit 4086507

File tree

2 files changed

+135
-1
lines changed

2 files changed

+135
-1
lines changed

RELEASE_NOTES.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Summary
44

5-
<!-- Here goes a general summary of what this release is about -->
5+
This release is mainly about creating a ruleset for recurring dispatches.
66

77
## Upgrading
88

@@ -11,6 +11,39 @@
1111
## New Features
1212

1313
- Package-based versioning has been introduced.
14+
- Rules for recurring dispatches have been added.
15+
Examples:
16+
Every 6 months:
17+
```
18+
message RecurrenceRule {
19+
Frequency freq = FREQUENCY_MONTHLY;
20+
uint32 interval = 6;
21+
}
22+
```
23+
24+
Weekends only:
25+
```
26+
message RecurrenceRule {
27+
Frequency freq = FREQUENCY_WEEKLY;
28+
repeated Weekday byweekdays = [WEEKDAY_SATURDAY, WEEKDAY_SUNDAY];
29+
}
30+
```
31+
32+
Every day at midnight:
33+
```
34+
message RecurrenceRule {
35+
Frequency freq = FREQUENCY_DAILY;
36+
repeated uint32 byhours = [0];
37+
}
38+
```
39+
40+
Nightly, assuming "night" means from 8 PM to 6 AM:
41+
```
42+
message RecurrenceRule {
43+
Frequency freq = FREQUENCY_DAILY;
44+
repeated uint32 byhours = [20, 21, 22, 23, 0, 1, 2, 3, 4, 5];
45+
}
46+
```
1447
1548
## Bug Fixes
1649

proto/frequenz/dispatch/v1/dispatch.proto

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ message Dispatch {
7878

7979
// The dispatch payload
8080
google.protobuf.Struct payload = 11;
81+
82+
// The recurrence rule
83+
RecurrenceRule recurrence = 12;
8184
}
8285

8386
// Filter parameter for specifying multiple time intervals
@@ -113,6 +116,98 @@ message DispatchComponentIDs {
113116
repeated uint64 component_ids = 1;
114117
}
115118

119+
// Ruleset governing when and how a dispatch should re-occur
120+
//
121+
// This definition tries to adhere closely to the iCalendar specification (RFC 5545),
122+
// particularly for recurrence rules. For advanced use-cases or further clarifications,
123+
// refer to RFC 5545.
124+
//
125+
// Examples:
126+
//
127+
// Every 6 months:
128+
// ```
129+
// message RecurrenceRule {
130+
// Frequency freq = FREQUENCY_MONTHLY;
131+
// uint32 interval = 6;
132+
// }
133+
// ```
134+
//
135+
// Weekends only:
136+
// ```
137+
// message RecurrenceRule {
138+
// Frequency freq = FREQUENCY_WEEKLY;
139+
// repeated Weekday byweekdays = [WEEKDAY_SATURDAY, WEEKDAY_SUNDAY];
140+
// }
141+
// ```
142+
//
143+
// Every day at midnight:
144+
// ```
145+
// message RecurrenceRule {
146+
// Frequency freq = FREQUENCY_DAILY;
147+
// repeated uint32 byhours = [0];
148+
// }
149+
// ```
150+
//
151+
// Nightly, assuming "night" means from 8 PM to 6 AM:
152+
// ```
153+
// message RecurrenceRule {
154+
// Frequency freq = FREQUENCY_DAILY;
155+
// repeated uint32 byhours = [20, 21, 22, 23, 0, 1, 2, 3, 4, 5];
156+
// }
157+
// ```
158+
message RecurrenceRule {
159+
// Enum representing the day of the week
160+
enum Weekday {
161+
WEEKDAY_UNSPECIFIED = 0;
162+
WEEKDAY_MONDAY = 1;
163+
WEEKDAY_TUESDAY = 2;
164+
WEEKDAY_WEDNESDAY = 3;
165+
WEEKDAY_THURSDAY = 4;
166+
WEEKDAY_FRIDAY = 5;
167+
WEEKDAY_SATURDAY = 6;
168+
WEEKDAY_SUNDAY = 7;
169+
}
170+
171+
// Enum representing the frequency of the recurrence
172+
enum Frequency {
173+
FREQUENCY_UNSPECIFIED = 0;
174+
FREQUENCY_MINUTELY = 1;
175+
FREQUENCY_HOURLY = 2;
176+
FREQUENCY_DAILY = 3;
177+
FREQUENCY_WEEKLY = 4;
178+
FREQUENCY_MONTHLY = 5;
179+
}
180+
181+
// The frequency specifier of this recurring dispatch
182+
Frequency freq = 1;
183+
184+
// How often this dispatch should recur, based on the frequency
185+
// Example:
186+
// - Every 2 hours:
187+
// freq = FREQUENCY_HOURLY
188+
// interval = 2
189+
uint32 interval = 2;
190+
191+
// (Optional) limit the number of occurences
192+
// If this field is not set, the dispatch will recur indefinitely
193+
optional uint32 count = 3;
194+
195+
// On which minute(s) of the hour does the event occur
196+
repeated uint32 byminutes = 4;
197+
198+
// On which hour(s) of the day does the event occur
199+
repeated uint32 byhours = 5;
200+
201+
// On which day(s) of the week does the event occur
202+
repeated Weekday byweekdays = 6;
203+
204+
// On which day(s) of the month does the event occur
205+
repeated uint32 bymonthdays = 7;
206+
207+
// On which month(s) of the year does the event occur
208+
repeated uint32 bymonths = 8;
209+
}
210+
116211
// Message for listing dispatches for a given microgrid, and an optional filter
117212
message DispatchListRequest {
118213
// The microgrid ID
@@ -167,6 +262,9 @@ message DispatchCreateRequest {
167262

168263
// The dispatch payload
169264
google.protobuf.Struct payload = 8;
265+
266+
// The recurrence rule
267+
RecurrenceRule recurrence = 9;
170268
}
171269

172270
// Message to update the dispatch with the given ID, with the given attributes
@@ -194,6 +292,9 @@ message DispatchUpdateRequest {
194292

195293
// The dispatch payload
196294
google.protobuf.Struct payload = 7;
295+
296+
// The recurrence rule
297+
RecurrenceRule recurrence = 8;
197298
}
198299

199300
// Message to get a single dispatch by its ID

0 commit comments

Comments
 (0)