Skip to content

Commit

Permalink
feat: Add RPC and statuses for session lifecycle management (#467)
Browse files Browse the repository at this point in the history
  • Loading branch information
aneojgurhem authored Jan 10, 2024
2 parents b10ac28 + 56ea8e9 commit 0cb3902
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Protos/V1/session_status.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
}
64 changes: 64 additions & 0 deletions Protos/V1/sessions_common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
}
20 changes: 20 additions & 0 deletions Protos/V1/sessions_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
36 changes: 36 additions & 0 deletions packages/csharp/ArmoniK.Api.Mock/Services/Sessions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,40 @@ public override Task<ListSessionsResponse> ListSessions(ListSessionsRequest requ
PageSize = request.PageSize,
Total = 0,
});

/// <inheritdoc />
[Count]
public override Task<CloseSessionResponse> CloseSession(CloseSessionRequest request,
ServerCallContext context)
=> Task.FromResult(new CloseSessionResponse
{
Session = MockSession,
});

/// <inheritdoc />
[Count]
public override Task<DeleteSessionResponse> DeleteSession(DeleteSessionRequest request,
ServerCallContext context)
=> Task.FromResult(new DeleteSessionResponse
{
Session = MockSession,
});

/// <inheritdoc />
[Count]
public override Task<PauseSessionResponse> PauseSession(PauseSessionRequest request,
ServerCallContext context)
=> Task.FromResult(new PauseSessionResponse
{
Session = MockSession,
});

/// <inheritdoc />
[Count]
public override Task<ResumeSessionResponse> ResumeSession(ResumeSessionRequest request,
ServerCallContext context)
=> Task.FromResult(new ResumeSessionResponse
{
Session = MockSession,
});
}

0 comments on commit 0cb3902

Please sign in to comment.