This commit is contained in:
a 2024-05-04 16:42:44 -05:00
parent 978310c0d8
commit a56422b4d9
Signed by: a
GPG Key ID: 374BC539FE795AF0
5 changed files with 76 additions and 64 deletions

View File

@ -1,4 +1,6 @@
package {{Package}} {{- $pkg := env "PWD" | base | coalesce Package -}}
package {{$pkg}}
import ( import (
"context" "context"
@ -8,26 +10,27 @@ import (
"gfx.cafe/util/go/fxplus" "gfx.cafe/util/go/fxplus"
) )
type {{title Package}} struct { type {{title $pkg}} struct {
log *slog.Logger log *slog.Logger
} }
type Params struct { type Params struct {
fx.In fx.In
Lc fx.Lifecycle Ctx context.Context
Lc fx.Lifecycle
Log *slog.Logger Log *slog.Logger
} }
type Result struct { type Result struct {
fx.Out fx.Out
Output *{{title Package}} Output *{{title $pkg}}
Healther fxplus.Healther Healther fxplus.Healther `group:"fxplus"`
} }
func New(p Params) (r Result, err error) { func New(p Params) (r Result, err error) {
o := &{{title Package}}{} o := &{{title $pkg}}{}
o.log = p.Log o.log = p.Log
r.Output = o r.Output = o
@ -35,6 +38,6 @@ func New(p Params) (r Result, err error) {
return return
} }
func (o *{{title Package}}) Health(ctx context.Context) (error) { func (o *{{title $pkg}}) Health(ctx context.Context) (error) {
return nil return nil
} }

View File

@ -0,0 +1,5 @@
{
"Name": "river",
"Description": "create an river component",
"Package":""
}

View File

@ -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
}

View File

@ -3,7 +3,7 @@
git add -A git add -A
if [ "$#" -eq 0 ]; then if [ "$#" -eq 0 ]; then
git commit -m "a" git commit -m "noot"
else else
array=("$@") array=("$@")
str="${array[@]}" str="${array[@]}"

View File

@ -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 <get|goto> <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