Skip to content

[sql-22] session: sessions CRUD #996

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

Merged
merged 2 commits into from
Mar 25, 2025

Conversation

ellemouton
Copy link
Member

@ellemouton ellemouton commented Mar 6, 2025

In this PR, the SQL implementation of the sessions.Store is added.

part of #917

@ellemouton ellemouton marked this pull request as draft March 6, 2025 11:11
@ellemouton ellemouton self-assigned this Mar 6, 2025
@ellemouton ellemouton added the no-changelog This PR is does not require a release notes entry label Mar 10, 2025
@ellemouton ellemouton force-pushed the sql22Sessions14 branch 2 times, most recently from d2de94b to 71cdc5a Compare March 11, 2025 18:32
@ellemouton ellemouton marked this pull request as ready for review March 11, 2025 19:16
Copy link
Contributor

@bitromortac bitromortac left a comment

Choose a reason for hiding this comment

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

Very exiting 🎉. Will do another pass, this looks very clean! 🙏

}

var macRecipe *MacaroonRecipe
if perms != nil || caveats != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

is it ok to check only for whether one one them is present?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes - look at the calls that follow

Copy link
Contributor

@ViktorTigerstrom ViktorTigerstrom left a comment

Choose a reason for hiding this comment

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

Generally looks great 🚀!!

Just leaving some comments mainly regarding differences in results between the original kvdb logic and the new sql implementation :).

Comment on lines +643 to +656
sessIDs, err := db.GetSessionAliasesInGroup(
ctx, sql.NullInt64{
Int64: groupID,
Valid: true,
},
)
if err != nil {
return fmt.Errorf("unable to get session IDs: %v", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Just noting that original logic actually seems to error if no sessions for the legacyGroupID is found, while this would return an emprty list. But given that I think the new logic is actually more correct, and I don't see a scenario where we'd hit that anyways, I think we should probably keep as is.

@lightninglabs-deploy
Copy link

@ellemouton, remember to re-request review from reviewers when ready

Copy link
Member Author

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

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

thanks yall 🙏

}

var macRecipe *MacaroonRecipe
if perms != nil || caveats != nil {
Copy link
Member Author

Choose a reason for hiding this comment

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

yes - look at the calls that follow

Copy link
Contributor

@bitromortac bitromortac left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

Copy link
Contributor

@ViktorTigerstrom ViktorTigerstrom left a comment

Choose a reason for hiding this comment

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

Looks great! Adding a few more comments in regards to error handling, but feel free to ignore these if you'd like :)

This commit adds the SQL implementation of the session.Store interface.
This can be run against all session unit tests via `make unit
pkg=session tags=test_db_sqlite` and `make unit pkg=session
tags=test_db_postgres`.
Let LiTd support a SQL db for the sessions store under the `dev` build
tag. This can be used via itests.
Copy link
Member Author

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

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

addressed, thanks @ViktorTigerstrom 🙏

@ellemouton ellemouton merged commit e49a1c3 into lightninglabs:master Mar 25, 2025
21 checks passed
@ellemouton ellemouton deleted the sql22Sessions14 branch March 25, 2025 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog This PR is does not require a release notes entry sql-ize
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants