vapp

package
v0.0.0-...-3b984fc Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2020 License: MIT Imports: 19 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultServiceStartCmd

func DefaultServiceStartCmd() *cli.Command

DefaultServiceStartCmd - give default service start command. If nothing special needs to be done during server start this command should be added to app.Commands array

func GetCommands

func GetCommands(app *App) []cli.Command

GetCommands - gives commands related to HTTP networking

Types

type App

type App struct {
	cli.App
	Modules       []*Module    `json:"modules"`
	NetOptions    vnet.Options `json:"netOptions"`
	IsService     bool         `json:"isService"`
	RequiresMongo bool         `json:"requiresMongo"`
}

App - the application itself

func GetVApp

func GetVApp(ctx *cli.Context) (vapp *App)

GetVApp - gets instance of vapp.App which is stored inside cli.App.Metadata

func NewAppWithOptions

func NewAppWithOptions() (app *App)

NewAppWithOptions - creates app with non default options

func NewSimpleApp

func NewSimpleApp(
	name string,
	appVersion vcmn.Version,
	apiVersion string,
	authors []cli.Author,
	requiresMongo bool,
	desc string) (app *App)

NewSimpleApp - an app that is not a service and does not use mongodb

func NewWebApp

func NewWebApp(
	name string,
	appVersion vcmn.Version,
	apiVersion string,
	authors []cli.Author,
	requiresMongo bool, desc string) (app *App)

NewWebApp - creates a new web application with default options

func (*App) AddModule

func (app *App) AddModule(module *Module)

AddModule - registers a module with the app

func (*App) Exec

func (app *App) Exec(args []string) (err error)

Exec - runs the applications

func (*App) FromAppDir

func (app *App) FromAppDir(relPath string) (abs string)

FromAppDir - gives a absolute path from a path relative to app directory

func (*App) Reset

func (app *App) Reset() (err error)

Reset - resets the application and module configuration and data. USE WITH CAUTION

func (*App) Setup

func (app *App) Setup() (err error)

Setup - sets up the application and the registered module. This is not initialization and needs to be called when app/module configuration changes. This is the place where mongoDB indices are expected to be created.

type Factory

type Factory struct {
	DataType string `json:"dataType"`
	Func     vmgo.FactoryFunc
}

Factory - wraps data type name and a function to create an instance of it

type Module

type Module struct {
	Name        string           `json:"name"`
	Description string           `json:"desc"`
	Endpoints   []*vnet.Endpoint `json:"endpoints"`
	Factories   []Factory        `json:"factory"`
	Commands    []cli.Command
	Initialize  ModuleConfigFunc
	Setup       ModuleConfigFunc
	Reset       ModuleConfigFunc
}

Module - represents an application module

type ModuleConfigFunc

type ModuleConfigFunc func(app *App) (err error)

ModuleConfigFunc Signature used by functions that are used to configure a module. Some config callbacks include - initialize, setup, reset etc

Jump to

Keyboard shortcuts

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