Skip to content

Refactor afterCommit from pointer argument to return value #21

Description

@jrsmroz

Description:
Currently, the Set, Delete, and related helper methods (setWithTransaction, setWithBatch, setDirect, etc.) use an afterCommit function as a pointer argument to communicate post-commit hooks back to the caller. This pattern is a bit confusing and makes the function signatures less clear.

Proposal:
Refactor these methods to return the afterCommit function as a return value instead of using a pointer argument. This will make the code easier to read and maintain, and clarify the intent of these functions.

Benefits:

  • Clearer function signatures.
  • More idiomatic Go code.
  • Easier to reason about post-commit hook execution.

Example:
Change from:

func setWithTransaction(..., afterCommit *func()) error

to:

func setWithTransaction(...) (afterCommit func(), err error)

and update all call sites accordingly.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions