framework

package module
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: MIT Imports: 17 Imported by: 1

README

A golang framework for web artisan.

Components

TODO

  • Authentication (component incomplete)
  • Message queue (component)
  • Filesystem (component)
  • Logging (component)
  • Database (component, using gorm for now, waiting generics)
  • CLI application
  • Task scheduling

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AppConfigName = "app"

AppConfigName: default app config name

View Source
var ConfigExt = ".yaml"

ConfigExt: default config extension

View Source
var (
	LabelKey = "label"
)

Functions

This section is empty.

Types

type App added in v0.0.5

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

App: framework application

func NewApp added in v0.0.5

func NewApp(configFs fs.FS, logDir string) *App

NewApp: new application instance

func (*App) Bind added in v0.0.7

func (app *App) Bind(bf BindFunc)

Bind instance to global ioc-container

func (*App) Bootstrap added in v0.0.5

func (app *App) Bootstrap() (e error)

Bootstrap application, will call before app run

func (*App) Configure added in v0.0.5

func (app *App) Configure(name string, value interface{}) error

Configure: load config instance and add to config service

func (*App) ConfigureFS added in v0.0.7

func (app *App) ConfigureFS(fs fs.FS, name string, value interface{}) error

ConfigureFS: load config from filesystem

func (*App) Container added in v0.0.7

func (app *App) Container() container.Interface

Container get global ioc-container

func (*App) Daemon added in v0.0.7

func (app *App) Daemon(f DaemonFn) *App

Daemon run function, start daemon service before http service started

func (*App) Defer added in v0.0.7

func (app *App) Defer(f func()) *App

Defer run function, run after server shutdown

func (*App) GetConfig added in v0.0.5

func (app *App) GetConfig() Config

GetConfig: get app config instance

func (*App) GetEnv added in v0.0.7

func (app *App) GetEnv() string

GetEnv: get app env

func (*App) Register added in v0.0.5

func (app *App) Register(service Service) *App

Register application service provider service

func (*App) RegisterRoutes added in v0.0.7

func (app *App) RegisterRoutes(rr RouterRegister) *App

RegisterRoutes: register routes of http service

func (*App) Resolving added in v0.1.0

func (app *App) Resolving(fn interface{})

Resolving call fn after all services registered, fn paramters can be injected from global ioc-container

func (*App) Run added in v0.0.5

func (app *App) Run() error

Run application service

func (*App) RunDaemons added in v0.0.7

func (app *App) RunDaemons(wg *sync.WaitGroup, daemon ...bool)

RunDaemons, run background services

func (*App) RunDefers added in v0.0.7

func (app *App) RunDefers()

func (*App) Services added in v0.0.7

func (app *App) Services() []Service

type BindFunc added in v0.0.7

type BindFunc func(ioc container.Interface)

type Config added in v0.0.5

type Config struct {
	Env      string `yaml:"env" env:"APP_ENV" default:"production"`
	Debug    bool   `yaml:"debug" env:"APP_DEBUG" default:"false"`
	Locale   string `yaml:"locale" env:"APP_LOCALE" default:"en"`
	Timezone string `yaml:"timezone" env:"APP_TIMEZONE" default:"UTC"`
	Key      string `yaml:"key" env:"APP_KEY" default:"somerandomkey!!!"`
}

Config of application

var AppConfig Config

AppConfig global var

type ConfigService added in v0.0.5

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

ConfigService of application

func (*ConfigService) Add added in v0.0.5

func (cs *ConfigService) Add(name string, config interface{}) *ConfigService

Add config instance to service

func (*ConfigService) Register added in v0.0.5

func (cs *ConfigService) Register(app *App) error

Register config service when app starting

type DaemonFn added in v0.0.7

type DaemonFn func(exit chan struct{})

type LogChannelConfig added in v0.1.0

type LogChannelConfig struct {
	Outputs    []string `yaml:"outputs"`
	Errouts    []string `yaml:"errouts"`
	Encoding   string   `yaml:"encoding" default:"json"`
	TimeFormat string   `yaml:"time_format" default:"2006-01-02T15:04:05.999"`
	Label      string   `yaml:"label"`
}

type LoggingConfig added in v0.1.0

type LoggingConfig struct {
	Default  string `yaml:"default" env:"LOGGING_CHANNEL" default:"default"`
	Channels map[string]LogChannelConfig
}

type LoggingService added in v0.1.0

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

func NewLoggingService added in v0.1.0

func NewLoggingService(baseDir string) *LoggingService

func (*LoggingService) Register added in v0.1.0

func (s *LoggingService) Register(app *App) error

Register service when app starting, before http server start you can configure service, prepare global vars etc. running at main goroutine

type RouterRegister added in v0.0.7

type RouterRegister func(rw *router.Wrapper)

type Service added in v0.0.5

type Service interface {
	//Register service when app starting, before http server start
	// you can configure service, prepare global vars etc.
	// running at main goroutine
	Register(app *App) error
}

Jump to

Keyboard shortcuts

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