Skip to content

Commit

Permalink
feat: migrate Watch Result rpc in results service (#406)
Browse files Browse the repository at this point in the history
  • Loading branch information
lemaitre-aneo authored Sep 4, 2023
2 parents 33003b4 + dc1a6e7 commit 10db83f
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Protos/V1/results_common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,32 @@ message DeleteResultsDataResponse {
string session_id = 1; /** The session of the results. */
repeated string result_id = 2; /** The ID of the deleted results. */
}

/**
* Request to watch result states
* It contains the list of result ids you want to watch
* and some options to filter out some events.
* Chunking is achieved by sending multiple messages with different result ids.
* It is the responsability of the client to chunk the messages properly and avoid messages too large.
*/
message WatchResultRequest {
// list of statuses to check results against for the initial fetch
repeated result_status.ResultStatus fetch_statuses = 1;
// list of statuses to check results against for the watch
repeated result_status.ResultStatus watch_statuses = 2;
// result ids to fetch/watch
repeated string result_ids = 3;
}

/**
* List of Result statuses
* Result Ids are grouped by status. One message contains result Ids that have the same status.
* Chunking is achieved by receiving several messages with the same status and the list of ids in multiple parts.
* As chunking is implicit, there is no way to distinguish between chunked messages and actually separate messages.
*/
message WatchResultResponse {
// Status of the results
result_status.ResultStatus status = 1;
// List of result ids that triggered the event
repeated string result_ids = 2;
}
11 changes: 11 additions & 0 deletions Protos/V1/results_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,15 @@ service Results {
* Get the configuration of the service
*/
rpc GetServiceConfiguration(Empty) returns (ResultsServiceConfigurationResponse);

/**
* This endpoint allows a user to watch a list of results and be notified when there is any change.
* The user sends the list of ids they want to watch.
* The submitter will then send the statuses for all requested ids immediately and keep the stream open.
* Ids not present in DB will be returned at that time with the special state NOTFOUND.
* The submitter will send updates to the client via the opened stream.
* Any reply can be implicitely chunked if there are too many event to report at the same time (or for the first reply).
* It is possible to filter out specific statuses from events.
*/
rpc WatchResults(stream WatchResultRequest) returns (stream WatchResultResponse);
}
16 changes: 16 additions & 0 deletions packages/csharp/ArmoniK.Api.Mock/Services/Results.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,20 @@ public override Task<GetResultResponse> GetResult(GetResultRequest request,
{
Result = MockResult,
});

/// <inheritdocs />
[Count]
public override async Task WatchResults(IAsyncStreamReader<WatchResultRequest> requestStream,
IServerStreamWriter<WatchResultResponse> responseStream,
ServerCallContext context)
{
await foreach (var _ in requestStream.ReadAllAsync())
{
await responseStream.WriteAsync(new WatchResultResponse
{
Status = ResultStatus.Unspecified,
})
.ConfigureAwait(false);
}
}
}

0 comments on commit 10db83f

Please sign in to comment.