gaarx

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

README

GAARX

This is the small framework for fast start new services on golang. Already added GORM, logrus and own internal storage and event system.

For start new project use this template for repository: gaarx-skeleton

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Finish func()
	// contains filtered or unexported fields
}

func (*App) CallMethod

func (app *App) CallMethod(name string) error

Call concrete method (should be defined in Initialize.WithMethods)

func (*App) Config

func (c *App) Config() interface{}

func (*App) Event

func (app *App) Event(name string) *Event

Return concrete event

func (*App) GetDB

func (app *App) GetDB() interface{}

func (*App) GetLog

func (app *App) GetLog() *logrus.Logger

Return logrus instance

func (*App) GetMeta

func (app *App) GetMeta() *Meta

Return Meta information

func (*App) GetService

func (app *App) GetService(name string) (Service, bool)

Return service and flag provide that service isset or not

func (*App) Initialize

func (app *App) Initialize(options ...Option) *App

Initialize application with option. Logger and Database should be initialized yet

func (*App) InitializeLogger

func (app *App) InitializeLogger(way LogWay, path string, formatter logrus.Formatter) error

Initialize logger with given settings

func (*App) LoadConfig

func (app *App) LoadConfig(configFile, configType string, configStruct interface{}) error

Load configuration from file

func (*App) SetDatabase

func (app *App) SetDatabase(db interface{})

func (*App) Start

func (app *App) Start()

Start application, all services and wait for calling Stop() method

func (*App) Stop

func (app *App) Stop()

Stop all services and application

func (*App) Storage

func (app *App) Storage() *storage

Return all of application storage

func (*App) Work

func (app *App) Work()

Alias for Start

type ConfigSource

type ConfigSource string

type Event

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

func (*Event) Close

func (e *Event) Close()

func (*Event) Dispatch

func (e *Event) Dispatch(data ...interface{})

func (*Event) Listen

func (e *Event) Listen() <-chan interface{}

type LogWay

type LogWay string
const (
	FileLog LogWay = "file"
	GrayLog LogWay = "graylog"
)

type Meta

type Meta struct {
	Version   string
	Build     string
	BuildTime string
	Branch    string
	Commit    string
}

type Method

type Method struct {
	Name string
	Func func(app *App) error
}

type Option

type Option func(app *App) error

func WithContext

func WithContext(ctx context.Context) Option

func WithDebug

func WithDebug(debug bool) Option

func WithMetaInformation

func WithMetaInformation(version, build, buildTime, branch, commit string) Option

func WithMethods

func WithMethods(functions ...Method) Option

func WithServices

func WithServices(services ...Service) Option

func WithStorage

func WithStorage(scopes ...string) Option

type Service

type Service interface {
	Start(app *App) error
	Stop()
	GetName() string
}

Jump to

Keyboard shortcuts

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