diff --git a/.config/boilr/templates/fx/template/component.go b/.config/boilr/templates/fx/template/component.go index 41783ad..ffd972b 100644 --- a/.config/boilr/templates/fx/template/component.go +++ b/.config/boilr/templates/fx/template/component.go @@ -1,4 +1,6 @@ -package {{Package}} +{{- $pkg := env "PWD" | base | coalesce Package -}} +package {{$pkg}} + import ( "context" @@ -8,26 +10,27 @@ import ( "gfx.cafe/util/go/fxplus" ) -type {{title Package}} struct { +type {{title $pkg}} struct { log *slog.Logger } type Params struct { fx.In - Lc fx.Lifecycle + Ctx context.Context + Lc fx.Lifecycle Log *slog.Logger } type Result struct { fx.Out - Output *{{title Package}} - Healther fxplus.Healther + Output *{{title $pkg}} + Healther fxplus.Healther `group:"fxplus"` } func New(p Params) (r Result, err error) { - o := &{{title Package}}{} + o := &{{title $pkg}}{} o.log = p.Log r.Output = o @@ -35,6 +38,6 @@ func New(p Params) (r Result, err error) { return } -func (o *{{title Package}}) Health(ctx context.Context) (error) { +func (o *{{title $pkg}}) Health(ctx context.Context) (error) { return nil } diff --git a/.config/boilr/templates/river/project.json b/.config/boilr/templates/river/project.json new file mode 100644 index 0000000..d479970 --- /dev/null +++ b/.config/boilr/templates/river/project.json @@ -0,0 +1,5 @@ +{ + "Name": "river", + "Description": "create an river component", + "Package":"" +} diff --git a/.config/boilr/templates/river/template/job.go b/.config/boilr/templates/river/template/job.go new file mode 100644 index 0000000..7dad752 --- /dev/null +++ b/.config/boilr/templates/river/template/job.go @@ -0,0 +1,60 @@ +{{- $pkg := env "PWD" | base | coalesce Package -}} +package {{$pkg}} + +import ( + "context" + "log/slog" + "reflect" + + "github.com/riverqueue/river" + "go.uber.org/fx" +) + +var ( + packageName = reflect.TypeOf(Args{}).PkgPath() +) + +type Args struct { + Block int + Force bool +} + +func (a *Args) Kind() string { + return packageName + ".task" +} + +type Worker struct { + river.WorkerDefaults[*Args] + + log *slog.Logger +} +type Params struct { + fx.In + + Workers *river.Workers + Ctx context.Context + Lc fx.Lifecycle + Log *slog.Logger +} + +type Result struct { + fx.Out + + Output *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 + return +} + +func (o *Worker) Work(ctx context.Context, job *river.Job[*Args]) error { + return nil +} diff --git a/.local/script/gitsave b/.local/script/gitsave index 14f60ac..7965496 100755 --- a/.local/script/gitsave +++ b/.local/script/gitsave @@ -3,7 +3,7 @@ git add -A if [ "$#" -eq 0 ]; then - git commit -m "a" + git commit -m "noot" else array=("$@") str="${array[@]}" diff --git a/.local/script/repotool b/.local/script/repotool deleted file mode 100755 index 093751b..0000000 --- a/.local/script/repotool +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/zsh - -ROOT_PREFIX="${REPO_ROOT_DIR:-$HOME/repo}" -GIT_USER="${REPO_GIT_USER:-git}" - -clean_path() -{ -stripped=$1 -prefix="http://" -stripped="${stripped#"$prefix"}" -prefix="https://" -stripped="${stripped#"$prefix"}" -prefix="git@" -stripped="${stripped#"$prefix"}" -suffix=".git" -stripped="${stripped%"$suffix"}" -stripped=$(echo "$stripped" | sed -e "s/:/\//1") -echo $stripped -} - -show_help() -{ - printf "Usage: repo \n" -} - -do_get() -{ - cleaned=$(clean_path $1) - output_path="$ROOT_PREFIX/$cleaned" - mkdir -p $output_path - if [ ! -d $output_path/.git ]; then - repourl=$(echo "$GIT_USER@$cleaned" | sed -e "s/\//:/1") - git clone $repourl $output_path - fi - cd $output_path -} - -do_goto() -{ -cleaned=$(clean_path $1) -output_path="$ROOT_PREFIX/$cleaned" -cd $output_path -} - - -case "$1" in - 'get' ) - do_get $2 - do_goto $2 - ;; - 'go' | "goto") - do_goto $2 - ;; - 'help' | "-h"| "-help" | "--help") - show_help -esac