app

package
v0.0.0-...-d6aa3a3 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2019 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppShutdownFunc

type AppShutdownFunc func(notifyEmail string)

type DatabaseShutdownFunc

type DatabaseShutdownFunc func(d *sql.DB)

type DbData

type DbData struct {
	ID   int       `json:"id"`
	Date time.Time `json:"date"`
	Name string    `json:"name"`
}

DbData ...

type NetworkShutdownFunc

type NetworkShutdownFunc func(hostaddresses []string)

type RouterShutdownFunc

type RouterShutdownFunc func(r *mux.Router)

type ServerApp

type ServerApp struct {
	Router        *mux.Router
	Database      *sql.DB
	ShutdownFuncs ShutdownFuncs
	// contains filtered or unexported fields
}

App is the main application object and must implement all methods of ServerApp

var Svr *ServerApp

func (*ServerApp) InitDatabase

func (app *ServerApp) InitDatabase()

InitDatabase called by Startup to initialize the apps database (if any)

func (*ServerApp) InitRouter

func (app *ServerApp) InitRouter()

InitRouter called by Startup to initialize all routes handled by app

func (*ServerApp) Main

func (app *ServerApp) Main()

type ServerAppInterface

type ServerAppInterface interface {
	// Startup calls Init* methods and displays standard app header
	Startup()
	// InitEnvironment called by Startup to intiialize apps environment variables
	InitEnvironment()
	// InitConfig called by Startup to load the apps configuration
	InitConfig()
	// InitFlags called by Startup to process the apps flags which can be used to override
	// Environment and Config
	InitFlags()
	// InitDatabase called by Startup to initialize the apps database (if any)
	InitDatabase()
	// InitRouter called by Startup to initialize all routes handled by app
	InitRouter()
	// Listen Invoke after Startup with no errors to handle the main loop as well as
	// a graceful shutdown
	Listen()
	// Shutdown is called from Listen does not need to be called directly
	Shutdown()
}

ServerApp defines the reguired functions that need to be implemented

type ServerAppState

type ServerAppState int
const (
	AppStateUnknown      ServerAppState = 0
	AppStateInitializing ServerAppState = 1
	AppStateInitialized  ServerAppState = 2
	AppStateOnline       ServerAppState = 3
	AppStateOffline      ServerAppState = 4
	AppStateShuttingDown ServerAppState = 5
	AppStateShutdown     ServerAppState = 6
	AppStateExiting      ServerAppState = 7
)

type ServerConfig

type ServerConfig struct {
	Name    string
	Version string
}

type ShutdownFuncs

type ShutdownFuncs struct {
	RouterFunc  RouterShutdownFunc
	Database    DatabaseShutdownFunc
	Network     NetworkShutdownFunc
	Application AppShutdownFunc
}

type ShutdownMethods

type ShutdownMethods interface {
	NiceRouterShudown(r *mux.Router)
	NiceDatbaseShutdown(d *sql.DB)
	NiceNetworkShutdown(hostaddresses []string)
	NiceAppShutdown(notifyEmail string)
}

Jump to

Keyboard shortcuts

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