bootstrap

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: MIT Imports: 16 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.

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

Index

Constants

View Source
const (
	DefaultConfigPath = "configs/config.toml"
	DefaultEnv        = "release"
	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 LoadPathSourceConfig added in v0.0.2

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

LoadPathSourceConfig loads the config file from the given path

func LoadRemoteConfig

func LoadRemoteConfig(bootstrap *Bootstrap, v any, ss ...config.SourceOptionSetting) error

LoadRemoteConfig 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 RandomID added in v0.0.8

func RandomID() string

func SaveConfig added in v0.0.2

func SaveConfig(path string, data any, opts ...SaveOption) error

SaveConfig saves the configuration data to the specified file path.

Types

type Bootstrap

type Bootstrap struct {
	Flags      Flags
	WorkDir    string
	ConfigPath string
	Env        string
	Daemon     bool
}

Bootstrap struct to hold bootstrap information

func DefaultBootstrap

func DefaultBootstrap() *Bootstrap

DefaultBootstrap returns a default bootstrap

func New

func New(dir, path string) *Bootstrap

New returns a new bootstrap

func WithFlags added in v0.0.2

func WithFlags(name string, version string) *Bootstrap

func (*Bootstrap) ID

func (b *Bootstrap) ID() string

ID returns the ID

func (*Bootstrap) Metadata

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

Metadata returns the metadata

func (*Bootstrap) ServiceID

func (b *Bootstrap) ServiceID() string

ServiceID returns the service ID

func (*Bootstrap) ServiceName

func (b *Bootstrap) ServiceName() string

ServiceName returns the service name

func (*Bootstrap) SetFlags

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

SetFlags sets the flags for the bootstrap

func (*Bootstrap) StartTime

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

StartTime returns the start time

func (*Bootstrap) Version

func (b *Bootstrap) Version() string

Version returns the version

func (*Bootstrap) WorkPath

func (b *Bootstrap) WorkPath() string

WorkPath returns the work path

type Flags

type Flags struct {
	ID          string
	Version     string
	ServiceName string
	StartTime   time.Time
	Metadata    map[string]string
}

Flags is a struct that holds the flags for the service

func DefaultFlags

func DefaultFlags() Flags

DefaultFlags returns the default flags for the service

func NewFlags

func NewFlags(name string, version string) Flags

NewFlags returns a new set of flags for the service

func (Flags) ServiceID

func (f Flags) ServiceID() string

ServiceID returns the ID of the service

type Option added in v0.1.0

type Option struct {
	EnvPrefix string
	Service   *service.Option
	Selector  *selector.Option
	Customize *customize.Option
	Source    config.SourceOption
}

type OptionSetting added in v0.1.0

type OptionSetting = func(option *Option)

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

func WithEnvPrefix added in v0.1.0

func WithEnvPrefix(prefix string) OptionSetting

type SaveOption added in v0.0.2

type SaveOption = func(*protojson.MarshalOptions)

SaveOption represents an option for saving configuration data.

Jump to

Keyboard shortcuts

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