controller

package
v0.4.1 Latest Latest
Warning

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

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

Documentation

Overview

Package controller defines root neuron structure - controller. The Controller contains all the model definitions, their repository instances, configuration, default query processor and validators.

Index

Constants

This section is empty.

Variables

View Source
var DefaultTestingConfig *config.Controller

DefaultTestingConfig is the controllerS default testing config used with the Default function

Functions

func SetDefault

func SetDefault(c *Controller)

SetDefault sets the 'c' Controller as default.

Types

type Controller

type Controller struct {
	// Config is the configuration struct for the controller.
	Config *config.Controller

	// Namer defines the function strategy how the model's and it's fields are being named.
	NamerFunc namer.Namer

	// CreateValidator is used as a validator for the Create processes.
	CreateValidator *validator.Validate

	//PatchValidator is used as a validator for the Patch processes.
	PatchValidator *validator.Validate
	// contains filtered or unexported fields
}

Controller is the root data structure responsible for controlling neuron models, queries and validators.

func Default

func Default() *Controller

Default creates new Controller with default config.

func DefaultTesting

func DefaultTesting(t testing.TB, cfg *config.Controller) *Controller

DefaultTesting is the default controller used for testing.

func New

func New(cfg *config.Controller) (*Controller, error)

New creates and returns new Controller for provided 'cfg' config.

func NewDefault

func NewDefault() *Controller

NewDefault creates new default controller based on the default config.

func (*Controller) GetModelStruct

func (c *Controller) GetModelStruct(model interface{}) (*models.ModelStruct, error)

GetModelStruct returns the *models.ModelStruct for provided 'model' argument. Returns error if provided model does not exists in the models.ModelMap.

func (*Controller) GetRepository added in v0.2.1

func (c *Controller) GetRepository(model interface{}) (repository.Repository, error)

GetRepository gets the repository for the provided 'model'. Allowed 'model' types are: *mapping.ModelStruct, *models.ModelStruct and a model structure instance i.e. &SomeType{}.

func (*Controller) ModelMap added in v0.2.1

func (c *Controller) ModelMap() *models.ModelMap

ModelMap gets the models mapping.

func (*Controller) ModelStruct

func (c *Controller) ModelStruct(model interface{}) (*mapping.ModelStruct, error)

ModelStruct gets the *mapping.ModelStruct for provided 'model'. Implements repository.ModelStructer.

func (*Controller) MustGetModelStruct

func (c *Controller) MustGetModelStruct(model interface{}) *models.ModelStruct

MustGetModelStruct gets the model struct from the cached model Map. Panics if the model does not exists in the map.

func (*Controller) Processor

func (c *Controller) Processor() scope.Processor

Processor returns the query processor for the controller.

func (*Controller) RegisterModels

func (c *Controller) RegisterModels(models ...interface{}) error

RegisterModels registers and sets provided 'models', by creating mapped *models.ModelStruct's for each. Provided model structures are stored within the *models.ModelMap.

func (*Controller) RegisterRepository added in v0.2.1

func (c *Controller) RegisterRepository(name string, cfg *config.Repository) error

RegisterRepository creates and stores the repository configuration with provided 'name' and given 'cfg' configuration.

func (*Controller) SetProcessor

func (c *Controller) SetProcessor(p scope.Processor)

SetProcessor sets the query processor for the controller.

Jump to

Keyboard shortcuts

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