This commit is contained in:
a 2024-05-07 19:25:06 -05:00
parent b9778542e1
commit 3ed27e0a18
Signed by: a
GPG Key ID: 374BC539FE795AF0
1 changed files with 5 additions and 10 deletions

View File

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