JobListTx missing similar error to JobList on metadata w/ SQLite
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 45/100
Direzione di ricerca
Start in client.go at the JobList implementation around line 2018, then compare it with JobListTx around line 2046. Reproduce the metadata query with the SQLite integration and check issue 570's referenced discussion before deciding whether the same unsupported-metadata error is still needed. Done means JobListTx reports the clear SQLite limitation instead of the driver's token error.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Howdy!
I'm testing out the SQLite integration. We use metadata to provide an easy way to find particular jobs when we don't know the ID ahead of time.
Our code uses JobListTx rather than JobList, and we receive this fun error from the driver:
SQL logic error: unrecognized token: "@" (1)
I went to write a reproducer, and accidentally used JobList. To my surprise, there was a much better error!
JobListResult.Metadata is not supported on SQLite
Looking at the code, it looks like the error was added to JobList but not JobListTx.
Full reproducers below:
NOT GREAT ERROR:
package main
import (
"context"
"database/sql"
"encoding/json"
"log"
"github.com/riverqueue/river"
"github.com/riverqueue/river/riverdriver/riversqlite"
"github.com/riverqueue/river/rivermigrate"
_ "modernc.org/sqlite"
)
type job struct{}
func (j job) Kind() string { return "job" }
func main() {
db, err := sql.Open("sqlite", ":memory:")
if err != nil {
log.Fatal(err)
}
defer db.Close()
db.SetMaxOpenConns(1)
driver := riversqlite.New(db)
migrator, err := rivermigrate.New(driver, nil)
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
if _, err := migrator.Validate(ctx); err != nil {
log.Fatal(err)
}
if _, err := migrator.Migrate(ctx, rivermigrate.DirectionUp, nil); err != nil {
log.Fatal(err)
}
riverClient, err := river.NewClient(driver, &river.Config{})
if err != nil {
log.Fatal(err)
}
metadata, err := json.Marshal(map[string]string{
"foo": "bar",
})
if err != nil {
log.Fatal(err)
}
if _, err := riverClient.Insert(ctx, job{}, &river.InsertOpts{Metadata: metadata}); err != nil {
log.Fatal(err)
}
tx, err := db.Begin()
if err != nil {
log.Fatal(err)
}
defer tx.Rollback()
jobs, err := riverClient.JobListTx(ctx, tx, river.NewJobListParams().Metadata(string(metadata)))
if err != nil {
log.Fatal(err)
}
if err := tx.Commit(); err != nil {
log.Fatal(err)
}
for _, j := range jobs.Jobs {
log.Printf("job: %+v", j)
}
}
VS the GREAT ERROR:
package main
import (
"context"
"database/sql"
"encoding/json"
"log"
"github.com/riverqueue/river"
"github.com/riverqueue/river/riverdriver/riversqlite"
"github.com/riverqueue/river/rivermigrate"
_ "modernc.org/sqlite"
)
type job struct{}
func (j job) Kind() string { return "job" }
func main() {
db, err := sql.Open("sqlite", ":memory:")
if err != nil {
log.Fatal(err)
}
db.SetMaxOpenConns(1)
driver := riversqlite.New(db)
migrator, err := rivermigrate.New(driver, nil)
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
if _, err := migrator.Validate(ctx); err != nil {
log.Fatal(err)
}
if _, err := migrator.Migrate(ctx, rivermigrate.DirectionUp, nil); err != nil {
log.Fatal(err)
}
riverClient, err := river.NewClient(driver, &river.Config{})
if err != nil {
log.Fatal(err)
}
metadata, err := json.Marshal(map[string]string{
"foo": "bar",
})
if err != nil {
log.Fatal(err)
}
if _, err := riverClient.Insert(ctx, job{}, &river.InsertOpts{Metadata: metadata}); err != nil {
log.Fatal(err)
}
jobs, err := riverClient.JobList(ctx, river.NewJobListParams().Metadata(string(metadata)))
if err != nil {
log.Fatal(err)
}
for _, j := range jobs.Jobs {
log.Printf("job: %+v", j)
}
}
[EDIT] depending on how quickly https://github.com/riverqueue/river/issues/570#issuecomment-2869139374 comes into play, this might be a non-issue!
- Lingua principale
- Go
- Stelle
- 5.7k
- Fork
- 179
- Merge medio
- 2g 19h
- PR unite (30g)
- 12
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di riverqueue/river
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 45/100
riverqueue/river#1358 · 1 commento ·
-
River job stuck at running Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
riverqueue/river#1258 · 7 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
riverqueue/river#1225 · 14 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
riverqueue/river#1185 · 2 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
riverqueue/river#1183 · 2 reazioni ·
Tutte le issue di riverqueue/river
Issue simili
-
ai-generated
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
SiaFoundation/indexd#1116 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
wakatime/wakatime-cli#1585 ·