core

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2022 License: MIT Imports: 15 Imported by: 1

README

Azugo Core

Azugo framework core.

Features

  • Structured logger go.uber.org/zap
  • Extendable configuration viper and command line cobra support
  • Caching using memory or Redis

Special Environment variables used by the Azugo framework

  • ENVIRONMENT - An App environment setting (allowed values are Development, Staging and Production).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(a Runnable)

Run starts an application and waits for it to finish

Types

type App

type App struct {

	// App settings
	AppVer       string
	AppBuiltWith string
	AppName      string
	// contains filtered or unexported fields
}

func New

func New() *App

func (*App) BackgroundContext

func (a *App) BackgroundContext() context.Context

BackgroundContext returns global background context

func (*App) Cache

func (a *App) Cache() *cache.Cache

func (*App) Config

func (a *App) Config() *config.Configuration

Config returns application configuration.

Panics if configuration is not loaded.

func (*App) Env

func (a *App) Env() Environment

Env returns the current application environment

func (*App) Log

func (a *App) Log() *zap.Logger

func (*App) SetConfig

func (a *App) SetConfig(cmd *cobra.Command, conf *config.Configuration)

SetConfig binds application configuration to the application

func (*App) SetVersion

func (a *App) SetVersion(version, builtWith string)

SetVersion sets application version and built with tags

func (*App) Start

func (a *App) Start() error

Start web application.

func (*App) Stop

func (a *App) Stop()

Stop application and its services

func (*App) String

func (a *App) String() string

func (*App) Validate

func (a *App) Validate() *validation.Validate

Validate returns validation service instance.

type Environment

type Environment string

Environment type.

const (
	EnvironmentDevelopment Environment = "Development"
	EnvironmentStaging     Environment = "Staging"
	EnvironmentProduction  Environment = "Production"
)

func NewEnvironment

func NewEnvironment(defaultMode Environment) Environment

NewEnvironment creates new Environment instance.

func (Environment) IsDevelopment

func (e Environment) IsDevelopment() bool

IsDevelopment checks if current environment is development.

func (Environment) IsProduction

func (e Environment) IsProduction() bool

IsProduction checks if current environment is production.

func (Environment) IsStaging

func (e Environment) IsStaging() bool

IsStaging checks if current environment is staging.

type Runnable

type Runnable interface {
	Start() error
	Log() *zap.Logger
	Stop()
}

Runnable provides methods to run application that will gracefully stop

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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