Conversation
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.
| Benchmark suite | Current: c22b13c | Previous: 1fa2c00 | Ratio |
|---|---|---|---|
Benchmark_EncryptString |
5144 ns/op 2152 B/op 14 allocs/op |
1603 ns/op 2152 B/op 14 allocs/op |
3.21 |
Benchmark_EncryptString - ns/op |
5144 ns/op |
1603 ns/op |
3.21 |
Benchmark_DecryptString |
6680 ns/op 2032 B/op 16 allocs/op |
2110 ns/op 2032 B/op 16 allocs/op |
3.17 |
Benchmark_DecryptString - ns/op |
6680 ns/op |
2110 ns/op |
3.17 |
This comment was automatically generated by workflow using github-action-benchmark.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #987 +/- ##
==========================================
- Coverage 71.10% 70.19% -0.92%
==========================================
Files 172 176 +4
Lines 11833 12376 +543
==========================================
+ Hits 8414 8687 +273
- Misses 3064 3310 +246
- Partials 355 379 +24 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
d7a3cd3 to
fb29765
Compare
f5908be to
5c11a57
Compare
61ffc58 to
c176cb4
Compare
f5c23b2 to
b9e1411
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR aims to optimize the queue module by updating job creation methods, argument types, and associated error messages while standardizing JSON instantiation. Key changes include:
- Refactoring job argument types from []any to []Arg and updating related interfaces.
- Renaming json.NewJson() to json.New() across application and test files.
- Updating error messages and refining API signatures in the queue contracts.
Reviewed Changes
Copilot reviewed 68 out of 69 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| mail/application.go | Updated job creation to use a structured slice of arguments instead of generic []any. |
| log/, http/, foundation/, crypt/ | Standardized JSON initialization following the renaming from NewJson() to New(). |
| event/task*.go | Updated task dispatch processing to use new argument types and updated queue interface usage. |
| errors/list.go | Revised error messages and added new error constants for various queue-related errors. |
| contracts/queue/* | Updated API design in the queue contracts including method signatures and type changes. |
Files not reviewed (1)
- go.mod: Language not supported
Comments suppressed due to low confidence (1)
errors/list.go:128
- [nitpick] The error message 'the driver of queue %s is sync, not need to run' has awkward phrasing. Consider rephrasing it to something like 'the driver of queue %s is synchronous and does not require running'.
QueueDriverSyncNotNeedToRun = New("the driver of queue %s is sync, not need to run")
krishankumar01
left a comment
There was a problem hiding this comment.
Added a few minor points
| }, | ||
| { | ||
| Type: "[]string", | ||
| Value: convertMapHeadersToSlice(r.headers), |
There was a problem hiding this comment.
Why are we converting Headers to a slice here? Since SendMailJob converts it back to a map[string]string, this seems like an unnecessary round-trip.
There was a problem hiding this comment.
Queue doesn't support map[string]string for now. We can implement it in another PR.
| } | ||
|
|
||
| return SendMail(r.config, from, subject, body, recipient, cc, bcc, replyTo, attachments, headers) | ||
| return SendMail(r.config, from, subject, body, recipient, cc, bcc, replyTo, attachments, convertSliceHeadersToMap(headers)) |
There was a problem hiding this comment.
Here, we are converting it back to the map
| Exception string // The exception that caused the job to fail. | ||
| FailedAt carbon.DateTime // The timestamp when the job failed. | ||
| ID uint `gorm:"primaryKey" db:"id"` | ||
| UUID string `db:"uuid"` |
There was a problem hiding this comment.
If this is related to job's id, we can rename it to JobId since UUID doesn't convey any information specific to the column.
There was a problem hiding this comment.
If this is related to job's id, we can rename it to
JobIdsinceUUIDdoesn't convey any information specific to the column.
Laravel use UUID, see https://github.com/laravel/framework/blob/12.x/src/Illuminate/Queue/Console/stubs/failed_jobs.stub
There was a problem hiding this comment.
UUID is fine, the same with Laravel.
queue/utils.go
Outdated
|
|
||
| type Task struct { | ||
| Job | ||
| Uuid string `json:"uuid"` |
| return payload, nil | ||
| } | ||
|
|
||
| func JsonToTask(payload string, queue contractsqueue.Queue, json foundation.Json) (contractsqueue.Task, error) { |
There was a problem hiding this comment.
We can remove this if it's not being used.
There was a problem hiding this comment.
It's used by the Redis driver, and will be used by the DB driver.
| } | ||
| } | ||
|
|
||
| // TODO: print success log |
There was a problem hiding this comment.
Good catch, I vaguely remember missing something.
| r.log.Error(errors.QueueFailedToSaveFailedJob.Args(err, job)) | ||
| } | ||
|
|
||
| // TODO: print failed log |
c83afb9 to
6fbcc56
Compare
| Config() config.Config | ||
| Debug() bool | ||
| DefaultConnection() string | ||
| Default() (connection, queue string, concurrent int) |
There was a problem hiding this comment.
In Go's standard library, it's highly uncommon to see functions with three return values. Typically, the second return value is designated for either an error or a bool, adhering to Go's simplicity and clarity principles. Considering this, the Default method could be split into multiple methods to better align with Go conventions and improve code readability.
There was a problem hiding this comment.
Good point, will optimize it in another PR.
📑 Description
✅ Checks