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

Fully overhaul package for modern Swift/Vapor/Fluent #1

Merged
merged 18 commits into from
Apr 28, 2024
Merged

Conversation

gwynne
Copy link
Member

@gwynne gwynne commented Jan 27, 2024

Pretty much what it says. Changes in public API:

  • JobMetadataMigration is no longer configurable
  • QueuesFluentDbType has been removed

Current plan is for these changes to be tagged as 3.0.0-beta.2

@gwynne gwynne requested a review from 0xTim January 27, 2024 12:46
Copy link

@grahamburgsma grahamburgsma left a comment

Choose a reason for hiding this comment

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

Just want to say thanks for giving this package some love! ❤️

Sources/QueuesFluentDriver/JobModel.swift Outdated Show resolved Hide resolved
…. Remove soft-deletion support (Fluent will not support this in the future). Stop hardcoding supported database names altogether, rely on dialect flag instead. Normalize database column names.
Copy link
Member

@0xTim 0xTim left a comment

Choose a reason for hiding this comment

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

Some queries but I really think we should remove all the future APIs these days for a major release

Package.swift Outdated Show resolved Hide resolved
Sources/QueuesFluentDriver/FluentQueue.swift Show resolved Hide resolved
Sources/QueuesFluentDriver/FluentQueue.swift Show resolved Hide resolved
Sources/QueuesFluentDriver/FluentQueue.swift Show resolved Hide resolved
@Patrick-Kladek
Copy link

Hi, is there an ETA when this is released? This PR is still in draft otherwise I would have jumped right into it to try it out. I would love to get rid of my redis instance to simplify the stack & reduce costs. Anyway thanks for the amazing work you do with vapor.

…del. Make `attempts` non-optional in the database. Don't use variable column names in the migration. Consolidate, document, and expand upon the SQLKit/FluentKit extensions.

public struct JobMetadataMigrate: Migration {
public init() {}

Choose a reason for hiding this comment

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

I think we might still need this, otherwise I get this error:

'JobMetadataMigrate' initializer is inaccessible due to 'internal' protection level

@Patrick-Kladek
Copy link

I've tried this branch, however jobs fail with following error:

Printing description of error:
▿ PSQLError(code: server, serverInfo: [sqlState: 42601, file: scan.l, line: 1188, message: syntax error at or near ")", position: 72, routine: scanner_yyerror, localizedSeverity: ERROR, severity: ERROR], triggeredFromRequestInFile: PostgresKit/PostgresDatabase+SQL.swift, line: 60, query: PostgresQuery(sql: UPDATE "_jobs_meta" SET "state" = $1, "updated_at" = current_timestamp() WHERE "_jobs_meta"."id" = (SELECT "_jobs_meta"."id" FROM "_jobs_meta" WHERE "_jobs_meta"."state" = $2 AND "_jobs_meta"."queue" = $3 AND coalesce("_jobs_meta"."delay_until", current_timestamp()) <= current_timestamp() ORDER BY "_jobs_meta"."delay_until" ASC LIMIT 1 FOR UPDATE SKIP LOCKED) RETURNING "_jobs_meta"."id", binds: [(****; TEXT; format: binary), (****; TEXT; format: binary), (****; TEXT; format: binary)]))
  ▿ backing : <Backing: 0x6000010306c0>

This error is not visible in the console (its redacted):

[ ERROR ] Job run failed: PSQLError – Generic description to prevent accidental leakage of sensitive data. For debugging details, use `String(reflecting: error)`.

I added a breakpoint in AsyncAwaitSupport.swift:70 to get the error.

Comment on lines 67 to 73
return try await self.sqlDb.update(JobModel.sqlTable)
.set(\JobModel.$state, to: QueuesFluentJobState.processing)
.set(\JobModel.$updatedAt, to: .now())
.where(\JobModel.$id, .equal, .group(select.query))
.returning(JobModel.sqlColumn(\.$id))
.first(decodingColumn: JobModel.key(for: \.$id), as: String.self)
.map(JobIdentifier.init(string:))

Choose a reason for hiding this comment

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

My investigation shows that the error is thrown in here. However my limited knowledge with sql prevents me from investigating further or fixing it as I have no idea what's going on.

Choose a reason for hiding this comment

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

Not sure if important, the postgres table `_jobs_meta is empty

Bildschirmfoto 2024-02-14 um 23 11 05

@gwynne
Copy link
Member Author

gwynne commented Feb 14, 2024

@Patrick-Kladek This PR is not at all ready for use yet, unfortunately 😰. I had to set it aside for a bit due to time constraints, but I will come back to finish it shortly; I wouldn't recommend trying it out until I've marked it ready for review, as you've seen, it doesn't even properly compile quite yet 😅. Sorry for any confusion!

@Patrick-Kladek
Copy link

@gwynne thanks for the heads up. I thought I'll give it a try as it was sitting here for a while and thought I would document my experience and at least help this way.

Please don't feel pressured to finish this asap, I see you are doing a lot on vapor and wanted to say thank you. If there is anything I could help you with, please let me know.

…roperty from FluentQueuesDriver, simplify error checking in makeQueue(), rename QueuesFluentJobState -> StoredJobState, reorganize JobModel, make JobModelMigration an AsyncSQLMigration, remove unused error cases from QueuesFluentError enum, add additional SQLKit convenience methods
…ng except specifying the database at configuration time and starting transactions. No longer even uses a Fluent model.
@Patrick-Kladek
Copy link

@gwynne can I help you with this task somehow? Maybe we can discuss specific tasks/goals and then I can give this a try. Are we waiting for some other dependency to be finished first?

@gwynne gwynne marked this pull request as ready for review April 28, 2024 18:14
Copy link

codecov bot commented Apr 28, 2024

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@gwynne gwynne merged commit 3720aa6 into main Apr 28, 2024
11 of 12 checks passed
@gwynne gwynne deleted the modernization branch April 28, 2024 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants