视频转码接入队列(asynq)

This commit is contained in:
kenneth
2023-12-22 16:51:09 +08:00
parent 17d3d8540d
commit 4e15e3a29e
16 changed files with 373 additions and 51 deletions

View File

@@ -14,6 +14,8 @@ type Store interface {
IsUniqueViolation(err error) bool
IsForeignKeyViolation(err error) bool
IsNoRows(err error) bool
CreateVideoTx(ctx context.Context, arg CreateVideoTxParam) (CreateVideoTxResult, error)
}
type SQLStore struct {

View File

@@ -0,0 +1,29 @@
package db
import "context"
type CreateVideoTxParam struct {
CreateVideoParams
AfterCreate func(video Video) error
}
type CreateVideoTxResult struct {
Video Video
}
func (store *SQLStore) CreateVideoTx(ctx context.Context, arg CreateVideoTxParam) (CreateVideoTxResult, error) {
var result CreateVideoTxResult
err := store.ExecTx(ctx, func(q *Queries) error {
var err error
result.Video, err = q.CreateVideo(ctx, arg.CreateVideoParams)
if err != nil {
return err
}
return arg.AfterCreate(result.Video)
})
return result, err
}