module

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const INJECT_TAG = "inject"

Variables

View Source
var BuiltinModules = []*Module{
	&Module{Name: "Utility", Module: &utility.Instance{}},
	&Module{Name: "Logger", Module: &logger.Instance{}},
	&Module{Name: "Config", Module: &config.Instance{}},
}
View Source
var Modules = []*Module{
	&Module{Name: "Database", Module: &database.Instance{}},
	&Module{Name: "Cache", Module: &cache.Instance{}},
	&Module{Name: "Queue", Module: &queue.Instance{}},
}

Functions

func SortModules

func SortModules(modules map[string]interface{}) []string

SortModules - Sort user modules.

Types

type Instance

type Instance struct {
	BuiltinModules       map[string]interface{}
	SortedBuiltinModules []string
	UserModules          map[string]interface{}
	SortedUserModules    []string
	Modules              map[string]interface{}
	SortedModules        []string
	Values               map[string]interface{}
}

func NewInstance

func NewInstance(ctx context.Context) (context.Context, *Instance, error)

func (*Instance) GetBuiltinModule

func (this *Instance) GetBuiltinModule(moduleName string) (interface{}, error)

func (*Instance) GetBuiltinModules

func (this *Instance) GetBuiltinModules() map[string]interface{}

func (*Instance) GetModule

func (this *Instance) GetModule(moduleName string) (interface{}, error)

func (*Instance) GetModules

func (this *Instance) GetModules() map[string]interface{}

func (*Instance) GetSortedBuiltinModules

func (this *Instance) GetSortedBuiltinModules(reverses ...bool) []interface{}

func (*Instance) GetSortedModules

func (this *Instance) GetSortedModules(reverses ...bool) []interface{}

func (*Instance) GetSortedUserModules

func (this *Instance) GetSortedUserModules(reverses ...bool) []interface{}

func (*Instance) GetUserModule

func (this *Instance) GetUserModule(moduleName string) (interface{}, error)

func (*Instance) GetUserModules

func (this *Instance) GetUserModules() map[string]interface{}

func (*Instance) GetValue

func (this *Instance) GetValue(key string) (interface{}, error)

func (*Instance) GetValues

func (this *Instance) GetValues() map[string]interface{}

func (*Instance) InjectModule

func (this *Instance) InjectModule() error

func (*Instance) InjectModuleByName

func (this *Instance) InjectModuleByName(moduleNames []string) error

func (*Instance) InjectModuleTo

func (this *Instance) InjectModuleTo(injectTargets []interface{}) error

func (*Instance) LoadModuleFileConfig

func (this *Instance) LoadModuleFileConfig(moduleName string, configFile string, configProviders map[string]interface{}, configTag ...string) (err error)

func (*Instance) LoadModuleJsonConfig

func (this *Instance) LoadModuleJsonConfig(moduleName string, configData []byte, configProviders map[string]interface{}, configTag ...string) (err error)

Register As Module

func (*Instance) RegisterUserModule

func (this *Instance) RegisterUserModule(ctx context.Context, moduleName string, module ModuleInterface, ignoreIfExistses ...bool) (context.Context, error)

*************** User Module *************** Register As User Module

func (*Instance) RegisterValue

func (this *Instance) RegisterValue(ctx context.Context, key string, value interface{}, forceOverwrites ...bool) (context.Context, error)

Register As Value

func (*Instance) SetSortedUserModules

func (this *Instance) SetSortedUserModules()

func (*Instance) UnregisterUserModule

func (this *Instance) UnregisterUserModule(ctx context.Context, moduleNames ...string) (context.Context, error)

Unregister As User Module

func (*Instance) UnregisterValue

func (this *Instance) UnregisterValue(ctx context.Context, keys ...string) (context.Context, error)

Unregister As Value

func (*Instance) UseModule

func (this *Instance) UseModule(ctx context.Context, moduleNames ...string) (context.Context, error)

type Module

type Module struct {
	Name   string
	Module ModuleInterface
}

type ModuleInterface

type ModuleInterface interface {
	Initiate(ctx context.Context) (context.Context, error)
	OnStartup(ctx context.Context) (context.Context, error)
	OnShutdown(ctx context.Context) (context.Context, error)
	OnRequestStartup(c *routing.Context) error
	OnRequestShutdown(c *routing.Context) error
}

type ModuleNode

type ModuleNode struct {
	Name  string
	Nodes []ModuleNode
}

ModuleNode - Module node.

func (*ModuleNode) NodesMap

func (node *ModuleNode) NodesMap(modules map[string][]string)

NodesMap - Map nodes.

func (*ModuleNode) NodesWithLabel

func (node *ModuleNode) NodesWithLabel(m map[int][]string, label int)

NodesWithLabel - Return nodes with lable.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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