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

refactor: drop Transactional and ConnectionOrTransaction #1069

Merged
merged 1 commit into from
Dec 4, 2024

Conversation

ctron
Copy link
Contributor

@ctron ctron commented Dec 3, 2024

Directly use the ConnectionTrait from sea_orm.

@ctron ctron requested a review from jcrossley3 December 3, 2024 16:42
user: UserInformation,
authorizer: web::Data<Authorizer>,
_: Require<ReadSbom>,
) -> actix_web::Result<impl Responder> {
authorizer.require(&user, Permission::ReadSbom)?;
Ok(HttpResponse::Ok().json(service.status(()).await?))
Ok(HttpResponse::Ok().json(service.status(&**db).await?))
Copy link
Contributor

Choose a reason for hiding this comment

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

I love concise code, but is this a tad too magic? I can't know at a glance what &**db is doing. Are we taking a reference of the result of calling first the Deref impl of web::Data and then that of Database? I'm not a rust noob, and I'm not sure. 😄

Is something like service.status(db.get_ref().connection()) too wordy or less idiomatic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could use db.as_ref() instead. Would do the same. You'd prefer that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are we taking a reference of the result of calling first the Deref impl of web::Data and then that of Database?

Btw, close: The first Deref takes the Arc from web::Data, the second takes T (Database) from the Arc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced this with db.as_ref().

@ctron ctron force-pushed the feature/pass_tx_1 branch from 693f0e7 to 398b96c Compare December 4, 2024 10:51
@ctron ctron marked this pull request as ready for review December 4, 2024 10:52
@ctron ctron added the DB Database aspects. Cross cutting concerns. Ownership of the entire data model. Ensuring it's design w label Dec 4, 2024
Directly use the `ConnectionTrait` from sea_orm.
@ctron ctron force-pushed the feature/pass_tx_1 branch from 398b96c to 864f467 Compare December 4, 2024 12:53
Copy link
Collaborator

@JimFuller-RedHat JimFuller-RedHat left a comment

Choose a reason for hiding this comment

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

took me a little while to get through, LGTM!

@helio-frota helio-frota self-requested a review December 4, 2024 13:24
Copy link
Collaborator

@helio-frota helio-frota left a comment

Choose a reason for hiding this comment

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

it is hard to see upload deadlock #999 using this refactor.

test here

@jcrossley3 jcrossley3 self-requested a review December 4, 2024 13:59
@ctron ctron added this pull request to the merge queue Dec 4, 2024
Merged via the queue into trustification:main with commit bf0f157 Dec 4, 2024
4 checks passed
@ctron ctron deleted the feature/pass_tx_1 branch December 4, 2024 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DB Database aspects. Cross cutting concerns. Ownership of the entire data model. Ensuring it's design w
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants