flam

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2025 License: MIT Imports: 10 Imported by: 11

README

flam

Go-linter Go-test

flam-in-go is a base application framework package using the Ubeg dig dependency injection package

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilReference = errors.New("nil reference")

	ErrBagInvalidPath = errors.New("invalid bag path")

	ErrUnknownResource       = errors.New("unknown resource")
	ErrInvalidResourceConfig = errors.New("invalid resource config")
	ErrDuplicateResource     = errors.New("duplicate resource")

	ErrDuplicateProvider = errors.New("duplicate provider")
)

Functions

This section is empty.

Types

type Application

type Application interface {
	Container() *dig.Container
	Register(provider Provider) error
	Boot() error
	Run() error
	Close() error
}

func NewApplication

func NewApplication() Application

type Bag

type Bag map[string]any

func (*Bag) Bag

func (bag *Bag) Bag(
	path string,
	def ...Bag,
) Bag

func (*Bag) Bool

func (bag *Bag) Bool(
	path string,
	def ...bool,
) bool

func (*Bag) Clone

func (bag *Bag) Clone() Bag

func (*Bag) Duration

func (bag *Bag) Duration(
	path string,
	def ...time.Duration,
) time.Duration

func (*Bag) Entries

func (bag *Bag) Entries() []string

func (*Bag) Float32

func (bag *Bag) Float32(
	path string,
	def ...float32,
) float32

func (*Bag) Float64

func (bag *Bag) Float64(
	path string,
	def ...float64,
) float64

func (*Bag) Get

func (bag *Bag) Get(
	path string,
	def ...any,
) any

func (*Bag) Has

func (bag *Bag) Has(
	path string,
) bool

func (*Bag) Int

func (bag *Bag) Int(
	path string,
	def ...int,
) int

func (*Bag) Int8

func (bag *Bag) Int8(
	path string,
	def ...int8,
) int8

func (*Bag) Int16

func (bag *Bag) Int16(
	path string,
	def ...int16,
) int16

func (*Bag) Int32

func (bag *Bag) Int32(
	path string,
	def ...int32,
) int32

func (*Bag) Int64

func (bag *Bag) Int64(
	path string,
	def ...int64,
) int64

func (*Bag) Merge

func (bag *Bag) Merge(
	src Bag,
) *Bag

func (*Bag) Populate

func (bag *Bag) Populate(
	target any,
	path ...string,
) error

func (*Bag) Set

func (bag *Bag) Set(
	path string,
	value any,
) error

func (*Bag) Slice

func (bag *Bag) Slice(
	path string,
	def ...[]any,
) []any

func (*Bag) String

func (bag *Bag) String(
	path string,
	def ...string,
) string

func (*Bag) StringMap

func (bag *Bag) StringMap(
	path string,
	def ...map[string]any,
) map[string]any

func (*Bag) StringMapString

func (bag *Bag) StringMapString(
	path string,
	def ...map[string]string,
) map[string]string

func (*Bag) StringSlice

func (bag *Bag) StringSlice(
	path string,
	def ...[]string,
) []string

func (*Bag) Uint

func (bag *Bag) Uint(
	path string,
	def ...uint,
) uint

func (*Bag) Uint8

func (bag *Bag) Uint8(
	path string,
	def ...uint8,
) uint8

func (*Bag) Uint16

func (bag *Bag) Uint16(
	path string,
	def ...uint16,
) uint16

func (*Bag) Uint32

func (bag *Bag) Uint32(
	path string,
	def ...uint32,
) uint32

func (*Bag) Uint64

func (bag *Bag) Uint64(
	path string,
	def ...uint64,
) uint64

type BootableProvider

type BootableProvider interface {
	Boot(container *dig.Container) error
}

type Channel

type Channel interface {
	int | int8 | int16 | int32 | int64 |
		uint | uint8 | uint16 | uint32 | uint64 |
		float32 | float64 |
		string
}

type ClosableProvider

type ClosableProvider interface {
	Close(container *dig.Container) error
}

type Error

type Error interface {
	error

	Unwrap() error
	GetCode() int
	SetCode(code int) Error
	Context() *Bag
	Set(path string, value any) Error
	Get(path string, def ...any) any
}

func NewError

func NewError(
	msg string,
	ctx ...Bag,
) Error

func NewErrorFrom

func NewErrorFrom(
	e error,
	msg string,
	ctx ...Bag,
) Error

type Executor added in v0.2.0

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

func NewExecutor added in v0.2.0

func NewExecutor() *Executor

func (*Executor) Queue added in v0.2.0

func (executor *Executor) Queue(
	callback any,
) *Executor

func (*Executor) Run added in v0.2.0

func (executor *Executor) Run(
	container *dig.Container,
) error

type Factory

type Factory[R Resource] interface {
	Close() error
	List() []string
	Has(id string) bool
	Get(id string) (R, error)
	Generate(id string) (R, error)
	Add(id string, value R) error
}

func NewFactory

func NewFactory[R Resource](
	creators []ResourceCreator[R],
	configPath string,
	config FactoryConfig,
	configValidator FactoryConfigValidator,
) (Factory[R], error)

type FactoryConfig

type FactoryConfig interface {
	Get(path string, def ...any) Bag
}

type FactoryConfigValidator

type FactoryConfigValidator func(config Bag) error

type ID

type ID comparable

type Provider

type Provider interface {
	Id() string
	Register(container *dig.Container) error
}

type PubSub

type PubSub[I ID, C Channel] interface {
	Subscribe(id I, channel C, handler PubSubHandlerType[I, C]) PubSub[I, C]
	Unsubscribe(id I, channel C) PubSub[I, C]
	Publish(channel C, data ...any) error
}

func NewPubSub

func NewPubSub[I ID, C Channel]() PubSub[I, C]

type PubSubHandlerType

type PubSubHandlerType[I ID, C Channel] func(channel C, data ...any) error

type Registerer added in v0.2.0

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

func NewRegisterer added in v0.2.0

func NewRegisterer() *Registerer

func (*Registerer) Queue added in v0.2.0

func (registerer *Registerer) Queue(
	constructor any,
	opts ...dig.ProvideOption,
) *Registerer

func (*Registerer) Run added in v0.2.0

func (registerer *Registerer) Run(
	container *dig.Container,
) error

type Resource

type Resource any

type ResourceCreator

type ResourceCreator[R Resource] interface {
	Accept(config Bag) bool
	Create(config Bag) (R, error)
}

type RunnableProvider

type RunnableProvider interface {
	Run(container *dig.Container) error
}

Jump to

Keyboard shortcuts

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