Skip to content

Commit

Permalink
Merge pull request #971 from ellemouton/sql13Sessions5
Browse files Browse the repository at this point in the history
[sql-13] sessions: set up for atomic session creation
  • Loading branch information
ellemouton authored Feb 19, 2025
2 parents 1a389d1 + aafeacd commit fff0a73
Show file tree
Hide file tree
Showing 11 changed files with 260 additions and 81 deletions.
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
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

0 comments on commit fff0a73

Please sign in to comment.