module

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

type Module interface {
	// Basic module information
	Name() string
	Version() string
	Dependencies() []string

	// Lifecycle methods
	Initialize(ctx context.Context, db *gorm.DB, router *gin.Engine) error
	NewConfig() config.Config
	Configure(config config.Config) error
	Shutdown(ctx context.Context) error

	// Namespace returns the module's namespace (public or tenant)
	Namespace() ModuleNamespace

	// Optional methods - modules can implement these interfaces if needed
	// MigrationProvider for modules that need database migrations
	ProvidesMigrations() bool
	MigrationsDir() string
	GetMigrationSources(projectRoot string) []migrationRunner.Source
}

type ModuleNamespace

type ModuleNamespace string

Module defines the interface that all modules must implement ModuleNamespace defines the type of schema a module operates in

const (
	// PublicNamespace represents modules that operate in the public schema
	PublicNamespace ModuleNamespace = "public"
	// TenantNamespace represents modules that operate in tenant-specific schemas
	TenantNamespace ModuleNamespace = "tenant"
)

type OrderedModule

type OrderedModule struct {
	Name   string
	Module Module
}

OrderedModule represents a module with its registration position

type Registry

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

Registry manages module registration and dependencies

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Get

func (r *Registry) Get(name string) (Module, bool)

Get retrieves a module by name from either namespace

func (*Registry) GetByNamespace

func (r *Registry) GetByNamespace(name string, namespace ModuleNamespace) (Module, bool)

GetByNamespace retrieves a module by name from a specific namespace

func (*Registry) GetModules

func (r *Registry) GetModules() map[string]Module

GetModules returns all modules from both namespaces

func (*Registry) GetModulesByNamespace

func (r *Registry) GetModulesByNamespace(namespace ModuleNamespace) map[string]Module

GetModulesByNamespace returns modules for a specific namespace in registration order

func (*Registry) GetModulesInOrder

func (r *Registry) GetModulesInOrder(namespace ModuleNamespace) []OrderedModule

GetModulesInOrder returns modules for a specific namespace in initialization order (respecting dependencies)

func (*Registry) InitOrder

func (r *Registry) InitOrder() []string

func (*Registry) Register

func (r *Registry) Register(m Module) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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