input from tim

This commit is contained in:
adlerhurst
2025-07-30 10:13:25 +02:00
parent fc3e5cf3e3
commit 5c34808ebf
2 changed files with 3 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ type Invoker interface {
// CommandOpts are passed to each command // CommandOpts are passed to each command
// they provide common fields used by commands like the database client. // they provide common fields used by commands like the database client.
// Not thread safe because fields can change state during execution.
type CommandOpts struct { type CommandOpts struct {
DB database.QueryExecutor DB database.QueryExecutor
Invoker Invoker Invoker Invoker

View File

@@ -83,6 +83,7 @@ func newTraceInvoker(next Invoker) *traceInvoker {
} }
// Invoke implements the [Invoker] interface. // Invoke implements the [Invoker] interface.
// TODO(adlerhurst): properly handle call stack, currently you would always get the line of the invoker instead of the code
func (i *traceInvoker) Invoke(ctx context.Context, command Commander, opts *CommandOpts) (err error) { func (i *traceInvoker) Invoke(ctx context.Context, command Commander, opts *CommandOpts) (err error) {
ctx, span := tracer.Start(ctx, fmt.Sprintf("%T", command)) ctx, span := tracer.Start(ctx, fmt.Sprintf("%T", command))
defer func() { defer func() {
@@ -109,6 +110,7 @@ func newLoggingInvoker(next Invoker) *loggingInvoker {
} }
// Invoke implements the [Invoker] interface. // Invoke implements the [Invoker] interface.
// TODO(adlerhurst): properly handle call stack, currently you would always get the line of the invoker instead of the code
func (i *loggingInvoker) Invoke(ctx context.Context, command Commander, opts *CommandOpts) (err error) { func (i *loggingInvoker) Invoke(ctx context.Context, command Commander, opts *CommandOpts) (err error) {
logger.InfoContext(ctx, "Invoking command", "command", command.String()) logger.InfoContext(ctx, "Invoking command", "command", command.String())