Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sql-13] sessions: set up for atomic session creation #971

Merged
merged 3 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/src/types/generated/lit-sessions_pb.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion app/src/types/generated/lit-sessions_pb.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion litrpc/lit-autopilot.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,8 @@
"STATE_CREATED",
"STATE_IN_USE",
"STATE_REVOKED",
"STATE_EXPIRED"
"STATE_EXPIRED",
"STATE_RESERVED"
],
"default": "STATE_CREATED"
},
Expand Down
62 changes: 33 additions & 29 deletions litrpc/lit-sessions.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions litrpc/lit-sessions.proto
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ enum SessionState {
STATE_IN_USE = 1;
STATE_REVOKED = 2;
STATE_EXPIRED = 3;
STATE_RESERVED = 4;
}

message AddSessionResponse {
Expand Down
3 changes: 2 additions & 1 deletion litrpc/lit-sessions.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,8 @@
"STATE_CREATED",
"STATE_IN_USE",
"STATE_REVOKED",
"STATE_EXPIRED"
"STATE_EXPIRED",
"STATE_RESERVED"
],
"default": "STATE_CREATED"
},
Expand Down
1 change: 1 addition & 0 deletions proto/lit-sessions.proto
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ enum SessionState {
STATE_IN_USE = 1;
STATE_REVOKED = 2;
STATE_EXPIRED = 3;
STATE_RESERVED = 4;
}

message AddSessionResponse {
Expand Down
32 changes: 31 additions & 1 deletion session/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,37 @@ const (
// State represents the state of a session.
type State uint8

/*
/---> StateExpired
StateCreated ---
\---> StateRevoked
*/

const (
// StateCreated is the state of a session once it has been fully
// committed to the Store and is ready to be used. This is the first
// state of a session.
StateCreated State = 0
Comment on lines +36 to 39
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment says that StateCreated is the first state for a session but StateReserved also says that it is the temporary initial state. This feels a bit confusing. After reading #979, I understand what these states mean but I don't think these comments alone are clear.

Also, the diagram comment on line 29 is missing StateReserved. Do you plan on fixing these up in the next PR that makes use of the reserved state?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah so this is sort of an intermediary commit that doesnt use the Reserved state yet which is why the diagram does not include it (since it is not possible for a session to be in this state yet). See this commit in the follow up PR which both updates the diagram and the comments :)

StateInUse State = 1

// StateInUse is the state of a session that is currently being used.
//
// NOTE: this state is not currently used, but we keep it around for now
// since old sessions might still have this state persisted.
StateInUse State = 1

// StateRevoked is the state of a session that has been revoked before
// its expiry date.
StateRevoked State = 2

// StateExpired is the state of a session that has passed its expiry
// date.
StateExpired State = 3

// StateReserved is a temporary initial state of a session. On start-up,
// any sessions in this state should be cleaned up.
//
// NOTE: this isn't used yet.
StateReserved State = 4
)

// MacaroonRecipe defines the permissions and caveats that should be used
Expand Down Expand Up @@ -195,5 +221,9 @@ type Store interface {
CheckSessionGroupPredicate(groupID ID,
fn func(s *Session) bool) (bool, error)

// DeleteReservedSessions deletes all sessions that are in the
// StateReserved state.
DeleteReservedSessions() error

IDToGroupIndex
}
Loading
Loading