sync
This commit is contained in:
parent
b9778542e1
commit
3ed27e0a18
|
@ -3,9 +3,11 @@ package {{$pkg}}
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"reflect"
|
||||
|
||||
"gfx.cafe/util/go/fxriver"
|
||||
"github.com/riverqueue/river"
|
||||
"go.uber.org/fx"
|
||||
)
|
||||
|
@ -15,8 +17,6 @@ var (
|
|||
)
|
||||
|
||||
type Args struct {
|
||||
Block int
|
||||
Force bool
|
||||
}
|
||||
|
||||
func (a *Args) Kind() string {
|
||||
|
@ -31,7 +31,6 @@ type Worker struct {
|
|||
type Params struct {
|
||||
fx.In
|
||||
|
||||
Workers *river.Workers
|
||||
Ctx context.Context
|
||||
Lc fx.Lifecycle
|
||||
Log *slog.Logger
|
||||
|
@ -40,21 +39,17 @@ type Params struct {
|
|||
type Result struct {
|
||||
fx.Out
|
||||
|
||||
Output *Worker
|
||||
Output fxriver.WorkConfigurer `group:"river_worker"`
|
||||
}
|
||||
|
||||
func New(p Params) (r Result, err error) {
|
||||
o := &Worker{}
|
||||
o.log = p.Log
|
||||
|
||||
err = river.AddWorkerSafely(p.Workers, o)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
r.Output = o
|
||||
r.Output = fxriver.Wrap(o)
|
||||
return
|
||||
}
|
||||
|
||||
func (o *Worker) Work(ctx context.Context, job *river.Job[*Args]) error {
|
||||
return nil
|
||||
return fmt.Errorf("Job %s is not implemented", (&Args{}).Kind())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue