Files
tasks/common/persistence/faultinjection/gowrap_template
Stephan BehnkeandGitHub 6dc37be79e Remove one more WithFxOptionsForService from tests/dlq_test.go (#10336)
## What changed

Replaced one `WithFxOptionsForService` with fault injection.

## Why

We want to eliminate `WithFxOptionsForService` as it is blocking us from
migrating away from the `onebox.go` approach (which duplicates the fx
setup) since we don't want to expose an equivalent method in
`temporal/fx.go`.
2026-05-28 10:12:51 -07:00

36 lines
1.2 KiB
Plaintext

{{ $decorator := (or .Vars.DecoratorName (printf "faultInjection%s" .Interface.Name)) }}
type (
// {{$decorator}} implements {{.Interface.Name}} interface with fault injection.
{{$decorator}} struct {
{{.Interface.Type}}
generator faultGenerator
}
)
// new{{upFirst $decorator}} returns {{$decorator}}.
func new{{upFirst $decorator}} (
baseStore {{.Interface.Type}},
generator faultGenerator,
) *{{$decorator}} {
return &{{$decorator}} {
{{.Interface.Name}}: baseStore,
generator: generator,
}
}
{{range $method := .Interface.Methods}}
{{if (and $method.AcceptsContext (gt (len $method.Params) 1)) }}
{{ $methodIdent := (printf "%s.%s" $.Interface.Name $method.Name) }}
// {{$method.Name}} wraps {{ (printf "%s.%s" $.Interface.Name $method.Name) }}.
func (d {{$decorator}}) {{$method.Declaration}} {
{{- $request := (index $method.Params 1) }}
err = d.generator.generate("{{ $method.Name }}", {{ $request.Name }}).inject(func() error {
{{$method.ResultsNames}} = d.{{$.Interface.Name}}.{{$method.Call}}
return err
})
return
}
{{end}}
{{end}}