go-redis icon indicating copy to clipboard operation
go-redis copied to clipboard

support for more flexible before & after process hook

Open bluesky1024 opened this issue 2 years ago • 0 comments

the basic hook is given as

type Hook interface {
	BeforeProcess(ctx context.Context, cmd Cmder) (context.Context, error)
	AfterProcess(ctx context.Context, cmd Cmder) error

	BeforeProcessPipeline(ctx context.Context, cmds []Cmder) (context.Context, error)
	AfterProcessPipeline(ctx context.Context, cmds []Cmder) error
}

however, the before process and after process is Indivisible in my condition for some framework reasons.

So, is it possible that goredis open the WrapProcess ability to others. like this

WrapProcess(ctx context.Context, cmd Cmder, fn func(context.Context, Cmder) error) error {
    before custom action
    fn(ctx,cmd)
    after custom action
}

bluesky1024 avatar Dec 14 '21 07:12 bluesky1024