frequenz-floss / frequenz-api-dispatch

gRPC+protobuf specification and Python bindings for the Frequenz Dispatch API
https://frequenz-floss.github.io/frequenz-api-dispatch/
MIT License
1 stars 6 forks source link

Extend `ListMicrogridDispatches` to support receiving dispatches by last modification time #151

Closed thomas-nicolai-frequenz closed 5 months ago

thomas-nicolai-frequenz commented 7 months ago

What's needed?

Currently there is no way to just receive dispatches by their last update time. @Marenz requested the following: "It would also be useful to receive dispatches once they have been updated"

Proposed solution

Extending the DispatchFilter so it would also support querying by update_time:

// Message for listing dispatches for a given microgrid, and an optional filter
message DispatchListRequest {
  // The microgrid ID
  uint64 microgrid_id = 1;

  // Additional filter parameters
  DispatchFilter filter = 2;
}

// Parameters for filtering the dispatch list
message DispatchFilter {
-  // Filter by component ID or category
+ // Optional filter by component ID or category
  repeated ComponentSelector selectors = 1;

-  // Filter by dispatch start time interval
-  // If no interval is provided, all dispatches starting from the
-  // current timestamp will be included.
+  // Optional filter by time interval
+  // Dispatches will be filtered based on the start_time of the dispatch request. 
+  // If no interval is provided, all dispatches starting from the current timestamp will be included.
-  TimeIntervalFilter time_interval = 2;
+  TimeIntervalFilter start_time_interval = 2;

-  // Filter by active status
+  // Optional filter by active status
  // If this field is not set, dispatches of any active status will be included.
  optional bool is_active = 3;

-  // Filter by dry run status
+  // Optional filter by dry run status  
  // If this field is not set, dispatches of any dry run status will be included.
  optional bool is_dry_run = 4;

+  // Optional filter by update time.
+  // Include only dispatches updated after this UTC timestamp.
+  google.protobuf.Timestamp modified_since = 5;
}

Use cases

To ensure users don't miss updates, such as changes to a dispatch's start time, it's essential to allow filtering by the last update time. The update_time_interval filter addresses this need by enabling users to identify dispatches recently modified.

Alternatives and workarounds

No response

Additional context

No response

thomas-nicolai-frequenz commented 5 months ago

This will require improving as update_time_interval references TimeIntervalFilter which in fact exposes a start and end time. However to receive the last updates since a certain time only requires the "start time" but no "end time" as the end time would always be empty anyhow.

Marenz commented 5 months ago

I think it might be enough to have a

// Optional filter by dispatches newer than this timestamp
// If not given, no update_time filter will be applied
optional Timestamp modified_since
thomas-nicolai-frequenz commented 5 months ago

@Marenz I've updated the proposal above. Should hopefully be in line with what you had in mind.

ktickner commented 5 months ago

Is this a duplicate of https://github.com/frequenz-floss/frequenz-api-dispatch/issues/161 In particular the following:

+  // Optional filter by update time
+  TimeIntervalFilter update_time_interval = 7;

FWIW I like the update_time_interval API better, it is consistent with other time based filters, and the naming convention matches the data field better.

thomas-nicolai-frequenz commented 5 months ago

True, this is superseded by https://github.com/frequenz-floss/frequenz-api-dispatch/issues/161