module

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package module defines the core types for modkit's module system.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidModuleDef = errors.New("invalid module definition")

ErrInvalidModuleDef indicates a module definition is invalid.

Functions

func Get added in v0.9.0

func Get[T any](r Resolver, token Token) (T, error)

Get resolves a provider of type T from the resolver. It returns an error if the resolution fails or if the resolved value is not of type T.

Types

type ControllerDef

type ControllerDef struct {
	Name  string
	Build func(r Resolver) (any, error)
}

ControllerDef describes how to build a controller instance.

type Module

type Module interface {
	Definition() ModuleDef
}

Module provides its definition for graph construction.

type ModuleDef

type ModuleDef struct {
	Name        string
	Imports     []Module
	Providers   []ProviderDef
	Controllers []ControllerDef
	Exports     []Token
}

ModuleDef declares metadata for a module, including its dependencies, providers, controllers, and exported tokens. The name should be unique within the module graph.

type ProviderDef

type ProviderDef struct {
	Token   Token
	Build   func(r Resolver) (any, error)
	Cleanup func(ctx context.Context) error
}

ProviderDef describes how to build a provider for a token.

type Resolver

type Resolver interface {
	Get(Token) (any, error)
}

Resolver provides access to resolved provider instances.

type Token

type Token string

Token identifies a provider for resolution.

Jump to

Keyboard shortcuts

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