component

package
v0.1.23 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package component provides GORM SQLite lifecycle integration for bootstrap.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Component

func Component() bootstrap.IComponent

The SQLite path is read from env key db.sqlite.path during Init(). Typical values:

  • "file:app.db?cache=shared" for file-based databases
  • "file::memory:?cache=shared" for in-memory databases (tests)
Example

ExampleComponent shows how Component() is used in a bootstrap registration chain. It reads the SQLite path from env key db.sqlite.path during Init():

"file:app.db?cache=shared"          — file-based database
"file::memory:?cache=shared"        — in-memory (tests, ephemeral data)

SQLite is an embedded database — Init() never fails due to network issues. Schema migration should be registered as a PreReady step immediately after:

bootstrap.New().
    Add(envComp.Component(...)).
    Add(logComp.Component()).
    Add(dbComp.Component()).
    PreReady(func() error {
        return dbgorm.AutoMigrate(ctx, dbgorm.Default(), dbgorm.MigrateOptions{Enabled: true}, &MyModel{})
    }).
    Run()
package main

import (
	"fmt"

	dbComp "github.com/phcp-tech/common-library-golang/dbgorm/sqlite/component"
)

func main() {
	c := dbComp.Component()
	fmt.Println(c != nil)
}
Output:
true

Types

This section is empty.

Jump to

Keyboard shortcuts

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