feat: add dead letter queue
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-01-19 11:33:38 +01:00
parent 1cf9d23491
commit 0b042780c3
13 changed files with 234 additions and 2 deletions

View File

@@ -0,0 +1,32 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.23.0
package repositories
import (
"context"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgconn"
)
type DBTX interface {
Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
Query(context.Context, string, ...interface{}) (pgx.Rows, error)
QueryRow(context.Context, string, ...interface{}) pgx.Row
}
func New(db DBTX) *Queries {
return &Queries{db: db}
}
type Queries struct {
db DBTX
}
func (q *Queries) WithTx(tx pgx.Tx) *Queries {
return &Queries{
db: tx,
}
}

View File

@@ -0,0 +1,35 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.23.0
package repositories
import (
"github.com/google/uuid"
"github.com/jackc/pgx/v5/pgtype"
)
type DeadLetter struct {
ScheduleID uuid.UUID `json:"schedule_id"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
type ModelSchedule struct {
ModelName string `json:"model_name"`
LastRun pgtype.Timestamptz `json:"last_run"`
}
type WorkSchedule struct {
ScheduleID uuid.UUID `json:"schedule_id"`
WorkerID uuid.UUID `json:"worker_id"`
StartRun pgtype.Timestamptz `json:"start_run"`
EndRun pgtype.Timestamptz `json:"end_run"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
State string `json:"state"`
}
type WorkerRegister struct {
WorkerID uuid.UUID `json:"worker_id"`
Capacity int32 `json:"capacity"`
HeartBeat pgtype.Timestamptz `json:"heart_beat"`
}

View File

@@ -0,0 +1,18 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.23.0
package repositories
import (
"context"
"github.com/google/uuid"
)
type Querier interface {
InsertDeadLetter(ctx context.Context, scheduleID uuid.UUID) error
Ping(ctx context.Context) (int32, error)
}
var _ Querier = (*Queries)(nil)

View File

@@ -0,0 +1,39 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.23.0
// source: queries.sql
package repositories
import (
"context"
"github.com/google/uuid"
)
const insertDeadLetter = `-- name: InsertDeadLetter :exec
INSERT INTO dead_letter
(
schedule_id
)
VALUES
(
$1
)
`
func (q *Queries) InsertDeadLetter(ctx context.Context, scheduleID uuid.UUID) error {
_, err := q.db.Exec(ctx, insertDeadLetter, scheduleID)
return err
}
const ping = `-- name: Ping :one
SELECT 1
`
func (q *Queries) Ping(ctx context.Context) (int32, error) {
row := q.db.QueryRow(ctx, ping)
var column_1 int32
err := row.Scan(&column_1)
return column_1, err
}