bootstrap

package
v0.1.60 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package bootstrap is a package that provides the bootstrap information for the service.

Package bootstrap implements the functions, types, and interfaces for the module.

Package bootstrap implements the functions, types, and interfaces for the module.

Index

Constants

View Source
const (
	EnvRelease        = "release"
	EnvDebug          = "debug"
	DefaultConfigPath = "configs/config.toml"

	DefaultWorkDir = "."
)

Constants for default paths and environment

View Source
const (
	DefaultServiceName = "origadmin.service.v1"
	DefaultVersion     = "v1.0.0"
)

Variables

View Source
var (
	RandomSuffix = fmt.Sprintf("%08d", time.Now().UnixNano()%(1<<32))
)

Functions

func LoadLocalConfig

func LoadLocalConfig(bs *Bootstrap, v any) error

LoadLocalConfig loads the config file from the given path

func LoadSourceConfig

func LoadSourceConfig(bootstrap *Bootstrap) (*configv1.SourceConfig, error)

LoadSourceConfig loads the config file from the given path

func LoadSourceConfigFromPath

func LoadSourceConfigFromPath(path string) (*configv1.SourceConfig, error)

LoadSourceConfigFromPath loads the config file from the given path

func RandomID added in v0.0.8

func RandomID() string

Types

type Bootstrap

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

Bootstrap struct to hold bootstrap information

func New

func New() *Bootstrap

New returns a new bootstrap

func WithFlags added in v0.0.2

func WithFlags(name string, version string) *Bootstrap

func (*Bootstrap) ConfigFilePath added in v0.1.57

func (b *Bootstrap) ConfigFilePath() string

func (*Bootstrap) ConfigPath

func (b *Bootstrap) ConfigPath() string

func (*Bootstrap) Daemon

func (b *Bootstrap) Daemon() bool

func (*Bootstrap) Env

func (b *Bootstrap) Env() string

func (*Bootstrap) IsDebug added in v0.1.60

func (b *Bootstrap) IsDebug() bool

func (*Bootstrap) Metadata

func (b *Bootstrap) Metadata() map[string]string

func (*Bootstrap) ServiceID

func (b *Bootstrap) ServiceID() string

func (*Bootstrap) ServiceInfo added in v0.1.59

func (b *Bootstrap) ServiceInfo() ServiceInfo

func (*Bootstrap) ServiceName

func (b *Bootstrap) ServiceName() string

func (*Bootstrap) SetConfigPath added in v0.1.57

func (b *Bootstrap) SetConfigPath(configPath string)

func (*Bootstrap) SetDaemon added in v0.1.57

func (b *Bootstrap) SetDaemon(daemon bool)

func (*Bootstrap) SetEnv added in v0.1.57

func (b *Bootstrap) SetEnv(env string)

func (*Bootstrap) SetMetadata added in v0.1.57

func (b *Bootstrap) SetMetadata(metadata map[string]string)

func (*Bootstrap) SetPath added in v0.1.59

func (b *Bootstrap) SetPath(dir, configPath string)

func (*Bootstrap) SetServiceID added in v0.1.57

func (b *Bootstrap) SetServiceID(serviceID string)

func (*Bootstrap) SetServiceInfo added in v0.1.57

func (b *Bootstrap) SetServiceInfo(name, version string)

func (*Bootstrap) SetServiceName added in v0.1.57

func (b *Bootstrap) SetServiceName(serviceName string)

func (*Bootstrap) SetStartTime added in v0.1.57

func (b *Bootstrap) SetStartTime(startTime time.Time)

func (*Bootstrap) SetVersion added in v0.1.57

func (b *Bootstrap) SetVersion(version string)

func (*Bootstrap) SetWorkDir added in v0.1.57

func (b *Bootstrap) SetWorkDir(workDir string)

func (*Bootstrap) StartTime

func (b *Bootstrap) StartTime() time.Time

func (*Bootstrap) Version

func (b *Bootstrap) Version() string

func (*Bootstrap) WorkDir

func (b *Bootstrap) WorkDir() string

type Loader added in v0.1.57

type Loader interface {
	Load() (*configv1.SourceConfig, error)
	Reload() error
}

type Option added in v0.1.0

type Option = func(option *Options)

Option is a function that takes a pointer to a Options struct and modifies it.

func WithEnvPrefix added in v0.1.0

func WithEnvPrefix(prefix string) Option

type Options added in v0.1.56

type Options struct {
	EnvPrefix string
	Selector  *selector.Options
	Customize *customize.Options
	Source    config.KOption
}

type ServiceInfo added in v0.1.59

type ServiceInfo struct {
	ID        string
	Name      string
	Version   string
	StartTime time.Time
}

ServiceInfo is a struct that holds the flags for the service

func NewServiceInfo added in v0.1.59

func NewServiceInfo(name, version string) ServiceInfo

func (ServiceInfo) ServiceID added in v0.1.59

func (si ServiceInfo) ServiceID() string

ServiceID returns the ID of the service

Jump to

Keyboard shortcuts

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