From 75b7a57f84d7593e3ca945ec653665b1063e888b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gurhem?= Date: Wed, 10 Jan 2024 08:37:29 +0100 Subject: [PATCH 1/2] feat: Add RPC and statuses for session lifecycle management --- Protos/V1/session_status.proto | 3 ++ Protos/V1/sessions_common.proto | 64 ++++++++++++++++++++++++++++++++ Protos/V1/sessions_service.proto | 20 ++++++++++ 3 files changed, 87 insertions(+) diff --git a/Protos/V1/session_status.proto b/Protos/V1/session_status.proto index ab9a8d903..4f59479ca 100644 --- a/Protos/V1/session_status.proto +++ b/Protos/V1/session_status.proto @@ -14,4 +14,7 @@ enum SessionStatus { SESSION_STATUS_UNSPECIFIED = 0; /** Session is in an unknown state. */ SESSION_STATUS_RUNNING = 1; /** Session is open and accepting tasks for execution. */ SESSION_STATUS_CANCELLED = 2; /** Session is cancelled. No more tasks can be submitted and no more tasks will be executed. */ + SESSION_STATUS_PAUSED = 3; /** Session is paused. Tasks can be submitted but no more new tasks will be executed. Already running tasks will continue until they finish. */ + SESSION_STATUS_CLOSED = 4; /** Session is closed. No more tasks can be submitted and executed. Results data will be deleted. */ + SESSION_STATUS_DELETED = 5; /** Session is deleted. Sessions, tasks and results metadata associated to the session will be deleted. */ } diff --git a/Protos/V1/sessions_common.proto b/Protos/V1/sessions_common.proto index 15609538e..079a48972 100644 --- a/Protos/V1/sessions_common.proto +++ b/Protos/V1/sessions_common.proto @@ -122,3 +122,67 @@ message CreateSessionRequest { message CreateSessionReply { string session_id = 1; /** Session id of the created session if successful */ } + +/** + * Request for pausing a single session. + */ +message PauseSessionRequest { + string session_id = 1; /** The session ID. */ +} + +/** + * Response for pausing a single session. + * + * Return a raw session. + */ +message PauseSessionResponse { + SessionRaw session = 1; /** The session. */ +} + +/** + * Request for resuming a single session. + */ +message ResumeSessionRequest { + string session_id = 1; /** The session ID. */ +} + +/** + * Response for resuming a single session. + * + * Return a raw session. + */ +message ResumeSessionResponse { + SessionRaw session = 1; /** The session. */ +} + +/** + * Request for closing a single session. + */ +message CloseSessionRequest { + string session_id = 1; /** The session ID. */ +} + +/** + * Response for closing a single session. + * + * Return a raw session. + */ +message CloseSessionResponse { + SessionRaw session = 1; /** The session. */ +} + +/** + * Request for deleting a single session. + */ +message DeleteSessionRequest { + string session_id = 1; /** The session ID. */ +} + +/** + * Response for deleting a single session. + * + * Return a raw session. + */ +message DeleteSessionResponse { + SessionRaw session = 1; /** The session. */ +} diff --git a/Protos/V1/sessions_service.proto b/Protos/V1/sessions_service.proto index e44433f3a..f3ad8ed78 100644 --- a/Protos/V1/sessions_service.proto +++ b/Protos/V1/sessions_service.proto @@ -32,4 +32,24 @@ service Sessions { * Create a session */ rpc CreateSession(CreateSessionRequest) returns (CreateSessionReply); + + /** + * Pause a session by its id. + */ + rpc PauseSession(PauseSessionRequest) returns (PauseSessionResponse); + + /** + * Resume a paused session by its id. + */ + rpc ResumeSession(ResumeSessionRequest) returns (ResumeSessionResponse); + + /** + * Close a session by its id. Removes Results data. + */ + rpc CloseSession(CloseSessionRequest) returns (CloseSessionResponse); + + /** + * Delete a session by its id. Removes metadata from Results, Sessions and Tasks associated to the session. + */ + rpc DeleteSession(DeleteSessionRequest) returns (DeleteSessionResponse); } From 56ea8e9330a09bc30e8d6b35a57dd7a9a2e1b77b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gurhem?= Date: Wed, 10 Jan 2024 09:59:31 +0100 Subject: [PATCH 2/2] test: add session rpc in mock --- .../ArmoniK.Api.Mock/Services/Sessions.cs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/packages/csharp/ArmoniK.Api.Mock/Services/Sessions.cs b/packages/csharp/ArmoniK.Api.Mock/Services/Sessions.cs index 3b3533717..5ee65b5e5 100644 --- a/packages/csharp/ArmoniK.Api.Mock/Services/Sessions.cs +++ b/packages/csharp/ArmoniK.Api.Mock/Services/Sessions.cs @@ -69,4 +69,40 @@ public override Task ListSessions(ListSessionsRequest requ PageSize = request.PageSize, Total = 0, }); + + /// + [Count] + public override Task CloseSession(CloseSessionRequest request, + ServerCallContext context) + => Task.FromResult(new CloseSessionResponse + { + Session = MockSession, + }); + + /// + [Count] + public override Task DeleteSession(DeleteSessionRequest request, + ServerCallContext context) + => Task.FromResult(new DeleteSessionResponse + { + Session = MockSession, + }); + + /// + [Count] + public override Task PauseSession(PauseSessionRequest request, + ServerCallContext context) + => Task.FromResult(new PauseSessionResponse + { + Session = MockSession, + }); + + /// + [Count] + public override Task ResumeSession(ResumeSessionRequest request, + ServerCallContext context) + => Task.FromResult(new ResumeSessionResponse + { + Session = MockSession, + }); }