Skip to content

Implement Refresh Lifecycle Hooks #31

@niteshpurohit

Description

@niteshpurohit

Feature Request

Description:

Provide lifecycle hooks (before_refresh, after_refresh) that can be configured to run before and after a materialized view is refreshed.

Use Case:

This allows developers to inject custom logic into the refresh process, such as logging to an audit trail, busting external caches, or triggering other downstream processes.

Proposed Solution:

  • In the initializer, allow configuration of global before_refresh and after_refresh lambdas that receive the view definition as an argument.
  • Allow these to be defined on a per-view basis as well, perhaps as serialized attributes on the model.
  • The MatViewRefreshJob will execute these hooks at the appropriate times.

RSpec Tests:

  • Configure a before_refresh hook that sets a flag.
  • Run a refresh and verify the flag was set before the refresh SQL was executed.
  • Configure an after_refresh hook.
  • Run a successful refresh and a failed refresh, and verify the hook is called in both cases with the correct status.

Checklist:

  • I have searched for a similar feature request and didn't find any duplicates.
  • I have included all the required information.
  • I have tagged the issue with the label "enhancement".

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions