bootstrap

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

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        = "dev"
	DefaultWorkDir    = "."
)

Constants for default paths and environment

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

Variables

This section is empty.

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 RandomTimeID added in v0.0.7

func RandomTimeID() 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 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