Documentation
¶
Overview ¶
Package bundriver provides a goncordia driver that accepts *bun.Tx transactions.
It is a thin adapter over driver/stdlib: bun.DB embeds *sql.DB and bun.Tx embeds *sql.Tx, so no reflection or internal field access is needed.
Usage:
sqlDB, _ := sql.Open("pgx", os.Getenv("DATABASE_URL"))
db := bun.NewDB(sqlDB, pgdialect.New())
d := bundriver.New(db)
d.Migrate(ctx)
client := bundriver.NewClient(d, goncordia.ClientConfig{})
// Transactional insert:
bunTx, _ := db.BeginTx(ctx, nil)
db.NewInsert().Model(&order).Exec(ctx) // or bunTx.NewInsert()...
client.EnqueueTx(ctx, bunTx, SendConfirmationArgs{OrderID: order.ID}, nil)
bunTx.Commit()
Index ¶
- func FetchParams(queue string, limit int) driver.FetchParams
- type Client
- type Driver
- func (d *Driver) Capabilities() driver.Capabilities
- func (d *Driver) Close() error
- func (d *Driver) Executor() driver.Executor
- func (d *Driver) Listener() driver.Listener
- func (d *Driver) Migrate(ctx context.Context) error
- func (d *Driver) Name() string
- func (d *Driver) UnwrapTx(tx bun.Tx) driver.ExecutorTx
- type Option
- type WorkerPool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FetchParams ¶
func FetchParams(queue string, limit int) driver.FetchParams
FetchParams is a convenience constructor for driver.FetchParams used in tests.
Types ¶
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver implements driver.Driver[bun.Tx]. Internally it delegates to the stdlib driver using the same SQL logic.
func New ¶
New creates a Driver from a *bun.DB. The dialect is detected automatically from db.Dialect().Name(). Call Migrate before starting workers.
func (*Driver) Capabilities ¶
func (d *Driver) Capabilities() driver.Capabilities
type WorkerPool ¶
type WorkerPool = goncordia.WorkerPool[bun.Tx]
WorkerPool is a type alias so callers never write goncordia.WorkerPool[bun.Tx].
func NewWorkerPool ¶
func NewWorkerPool(d *Driver, r *core.Registry, cfg goncordia.WorkerConfig) *WorkerPool
NewWorkerPool creates a WorkerPool bound to this bun driver.