53 lines
1000 B
Go
53 lines
1000 B
Go
package jobs
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
_ "git.ipao.vip/rogeecn/atom"
|
|
_ "git.ipao.vip/rogeecn/atom/contracts"
|
|
. "github.com/riverqueue/river"
|
|
)
|
|
|
|
var (
|
|
_ JobArgs = VideoCut{}
|
|
_ JobArgsWithInsertOpts = VideoCut{}
|
|
)
|
|
|
|
type VideoCut struct {
|
|
PostID int64 `json:"post_id"`
|
|
Hash string `json:"hash"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
UserID int64 `json:"user_id"`
|
|
}
|
|
|
|
// InsertOpts implements JobArgsWithInsertOpts.
|
|
func (s VideoCut) InsertOpts() InsertOpts {
|
|
return InsertOpts{
|
|
Queue: QueueDefault,
|
|
Priority: PriorityDefault,
|
|
UniqueOpts: UniqueOpts{
|
|
ByArgs: true,
|
|
},
|
|
}
|
|
}
|
|
|
|
func (VideoCut) Kind() string {
|
|
return "VideoCut"
|
|
}
|
|
|
|
var _ Worker[VideoCut] = (*VideoCutWorker)(nil)
|
|
|
|
// @provider(job)
|
|
type VideoCutWorker struct {
|
|
WorkerDefaults[VideoCut]
|
|
}
|
|
|
|
func (w *VideoCutWorker) NextRetry(job *Job[VideoCut]) time.Time {
|
|
return time.Now().Add(5 * time.Second)
|
|
}
|
|
|
|
func (w *VideoCutWorker) Work(ctx context.Context, job *Job[VideoCut]) error {
|
|
return nil
|
|
}
|