coreinit

package
v0.61.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: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ResolvedInitializersKey stores the topologically resolved Initializers.
	ResolvedInitializersKey = typedmap.NewTypedKey[[]*Initializer]("khi.google.com/init/resolved-initializers")
)

Functions

func Get added in v0.58.2

func Get[T any](ctx *InitContext, key typedmap.TypedKey[T]) (T, bool)

Get retrieves a typed value from InitContext.

func GetOrDefault added in v0.58.2

func GetOrDefault[T any](ctx *InitContext, key typedmap.TypedKey[T], defaultValue T) T

GetOrDefault retrieves a typed value or returns defaultValue if not found.

func MustGet added in v0.58.2

func MustGet[T any](ctx *InitContext, key typedmap.TypedKey[T]) T

MustGet retrieves a typed value or panics if not found.

func RegisterConnectServiceHandler added in v0.58.2

func RegisterConnectServiceHandler(router gin.IRouter, basePathWithoutTrailingSlash string, servicePath string, handler http.Handler)

RegisterConnectServiceHandler registers a Connect-RPC service handler to the Gin router, wrapping it to strip the basePath if needed.

func RegisterInitializer added in v0.58.2

func RegisterInitializer(initializer *Initializer)

RegisterInitializer registers an Initializer into the global registry.

func ResetInitializersForTest added in v0.58.2

func ResetInitializersForTest()

ResetInitializersForTest clears registered initializers for unit testing.

func Set added in v0.58.2

func Set[T any](ctx *InitContext, key typedmap.TypedKey[T], val T)

Set stores a typed value in InitContext.

Types

type Engine added in v0.58.2

type Engine struct {
	// contains filtered or unexported fields
}

Engine manages the initialization, execution, and termination lifecycle of KHI.

func NewEngine added in v0.58.2

func NewEngine(parent context.Context) *Engine

NewEngine creates a new Engine wrapping the provided parent context.

func (*Engine) Context added in v0.58.2

func (e *Engine) Context() *InitContext

Context returns the InitContext managed by this engine.

func (*Engine) Init added in v0.58.2

func (e *Engine) Init() error

Init resolves and executes all registered Initializers in topological order.

func (*Engine) Run added in v0.58.2

func (e *Engine) Run() error

Run executes all registered OnRun hooks.

func (*Engine) Terminate added in v0.58.2

func (e *Engine) Terminate() error

Terminate cancels the context and executes all registered termination hooks in reverse order.

type InitContext added in v0.58.2

type InitContext struct {
	context.Context
	// contains filtered or unexported fields
}

InitContext is passed to Initializers to share state and register lifecycle hooks.

func (*InitContext) OnRun added in v0.58.2

func (c *InitContext) OnRun(hook func(ctx context.Context) error)

OnRun registers a runtime hook with the Engine.

func (*InitContext) OnTerminate added in v0.58.2

func (c *InitContext) OnTerminate(hook func() error)

OnTerminate registers a shutdown hook with the Engine.

type Initializer added in v0.58.2

type Initializer struct {
	// ID is the unique identifier of this initializer.
	ID InitializerID

	// Dependencies lists the InitializerIDs that must execute before this initializer.
	Dependencies []InitializerID

	// Before lists the InitializerIDs that this initializer must execute before.
	Before []InitializerID

	// Init executes the initialization logic.
	Init func(ctx *InitContext) error
}

Initializer represents an initialization unit in the DAG.

type InitializerID added in v0.58.2

type InitializerID string

InitializerID identifies an Initializer uniquely.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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