storehooks

package
v1.11.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package storehooks lets a downstream build observe every runtime database pool the config and logs stores open, at the moment it opens.

GORM compiles its callback chain without a lock, so a plugin registered on a pool that is already serving queries races with those queries. Stores call PoolOpened right after a pool is created and before it is shared, which is the one point where registering callbacks is safe. OSS registers nothing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PoolOpened

func PoolOpened(role Role, db *gorm.DB)

PoolOpened runs every registered hook for a pool that was just opened and is not yet in use. Stores call it for each runtime pool, including one that replaces a refreshed pool.

func RegisterPoolOpened

func RegisterPoolOpened(fn PoolOpenedFn)

RegisterPoolOpened adds fn to the hooks run for every new runtime pool. Call it before the stores are created; pools opened earlier are not replayed.

Types

type PoolOpenedFn

type PoolOpenedFn func(role Role, db *gorm.DB)

PoolOpenedFn is called with each new runtime pool. It must not block.

type Role

type Role string

Role names the store a pool belongs to.

const (
	// RoleConfig is the config store's runtime pool.
	RoleConfig Role = "config"
	// RoleLogs is the logs store's runtime pool.
	RoleLogs Role = "logs"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL