config

package
v0.2.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultConcurrentProcessorConfig added in v0.2.1

func DefaultConcurrentProcessorConfig() map[string]interface{}

DefaultConcurrentProcessorConfig creates default concurrent config for the Processor.

func DefaultProcessorConfig added in v0.2.1

func DefaultProcessorConfig() map[string]interface{}

DefaultProcessorConfig creates default config for the Processor.

func ViperSetDefaults

func ViperSetDefaults(v *viper.Viper)

ViperSetDefaults sets the default values for the viper config.

Types

type Connection

type Connection struct {
	// Host defines the access hostname or the ip address
	Host string `mapstructure:"host" validate:"hostname|ip"`

	// Path is the connection path, just after the protocol and
	Path string `mapstructure:"path" validate:"isdefault|uri"`

	// Port is the connection port
	Port interface{} `mapstructure:"port"`

	// Protocol is the protocol used in the connection
	Protocol string `mapstructure:"protocol"`

	// RawURL is the raw connection url. If set it must define the protocol ('http://',
	// 'rpc://'...)
	RawURL string `mapstructure:"raw_url" validate:"isdefault|url"`

	// Username is the username used to get connection credential
	Username string `mapstructure:"username"`

	// Password is the password used to get connection credentials
	Password string `mapstructure:"password"`

	// Options contains connection dependent specific options
	Options map[string]interface{} `mapstructure:"options"`

	// MaxTimeout defines the maximum timeout for the given repository connection
	MaxTimeout *time.Duration `mapstructure:"max_timeout"`
}

Connection is the configuration for non local schemas credentials. The connection config can be set by providing raw_url or with host,path,protocol.

type Controller

type Controller struct {
	// NamingConvention is the naming convention used while preparing the models.
	// Allowed values:
	// - camel
	// - lowercamel
	// - snake
	// - kebab
	NamingConvention string `mapstructure:"naming_convention" validate:"isdefault|oneof=camel lowercamel snake kebab"`

	// Models defines the model's configurations.
	Models map[string]*ModelConfig `mapstructure:"models"`

	// StrictUnmarshalMode is the flag that defines if the unmarshaling should be in a
	// strict mode that checks if incoming values are all known to the controller
	// As well as the query builder doesn't allow unknown queries
	StrictUnmarshalMode bool `mapstructure:"strict_unmarshal"`

	// EncodeLinks is the boolean used for encoding the links in the jsonapi encoder
	EncodeLinks bool `mapstructure:"encode_links"`

	// LogLevel is the current logging level
	LogLevel string `mapstructure:"log_level" validate:"isdefault|oneof=debug3 debug2 debug info warning error critical"`

	// Repositories contains the connection configs for the given repository instance name
	Repositories map[string]*Repository `mapstructure:"repositories" validate:"-"`

	// DefaultRepositoryName defines default repositoy name
	DefaultRepositoryName string `mapstructure:"default_repository_name"`

	// DefaultRepository defines controller default repository
	DefaultRepository *Repository `mapstructure:"default_repository" validate:"-"`

	// Processor is the config used for the scope processor
	Processor *Processor `mapstructure:"processor" validate:"required"`

	// CreateValidatorAlias is the alias for the create validators
	CreateValidatorAlias string `mapstructure:"create_validator_alias"`

	// PatchValidatorAlias is the alis used for the Patch validator
	PatchValidatorAlias string `mapstructure:"patch_validator_alias"`

	// DefaultValidatorAlias is the alias used as a default validator alias
	DefaultValidatorAlias string `mapstructure:"default_validator_alias"`
}

Controller defines the configuration for the Controller.

func ReadConfig

func ReadConfig() (*Controller, error)

ReadConfig reads the config for given path.

func ReadControllerConfig

func ReadControllerConfig(name, path string) (*Controller, error)

ReadControllerConfig reads the config for the controller.

func ReadDefaultConfig

func ReadDefaultConfig() *Controller

ReadDefaultConfig reads the default configuration.

func ReadDefaultControllerConfig

func ReadDefaultControllerConfig() *Controller

ReadDefaultControllerConfig returns the default controller config.

func ReadNamedConfig

func ReadNamedConfig(name string) (*Controller, error)

ReadNamedConfig reads the config with the provided name.

func (*Controller) MapRepositories

func (c *Controller) MapRepositories() error

MapRepositories maps the repositories definitions from the controller with the model's repositories.

type I18nConfig

type I18nConfig struct {
	// SupportedLanguages represent supported languages tags
	SupportedLanguages []string
}

I18nConfig defines i18n configuration support.

type ModelConfig

type ModelConfig struct {
	// Collection is the model's collection name
	Collection string `mapstructure:"collection"`

	// RepositoryName is the model's repository name, with the name provided in the initialization
	// process...
	RepositoryName string `mapstructure:"repository_name"`

	// Map sets the model's Store values
	Map map[string]interface{} `mapstructure:"map"`

	// Repository defines the model's repository connection config
	Repository *Repository `mapstructure:"repository"`

	// AutoMigrate automatically migrates the model into the given repository structuring
	// I.e. sql creates or updates the table
	AutoMigrate bool `mapstructure:"automigrate"`
}

ModelConfig defines single model configurations.

type ProcessList

type ProcessList []string

ProcessList is a list of the processes.

type Processor

type Processor struct {
	DefaultTimeout time.Duration `mapstructure:"default_timeout"`

	// CreateProcesses are the default processes used in the create method.
	CreateProcesses ProcessList `mapstructure:"create_processes"`

	// DeleteProcesses are the default processes used in the delete method.
	DeleteProcesses ProcessList `mapstructure:"delete_processes"`

	// GetProcesses are the default processes used in the get method.
	GetProcesses ProcessList `mapstructure:"get_processes"`

	// ListProcesses are the default processes used in the list method.
	ListProcesses ProcessList `mapstructure:"list_processes"`

	// PatchProcesses are the default processes used in the patch method.
	PatchProcesses ProcessList `mapstructure:"patch_processes"`
}

Processor is the config used for the scope processor.

func (*Processor) Validate

func (p *Processor) Validate() error

Validate validates the processor values.

type Repository

type Repository struct {
	// DriverName defines the name for the repository driver
	DriverName string `mapstructure:"driver_name" validate:"required"`

	// Host defines the access hostname or the ip address
	Host string `mapstructure:"host" validate:"isdefault|hostname|ip"`

	// Path is the connection path, just after the protocol and
	Path string `mapstructure:"path" validate:"isdefault|uri"`

	// Port is the connection port
	Port interface{} `mapstructure:"port"`

	// Protocol is the protocol used in the connection
	Protocol string `mapstructure:"protocol"`

	// RawURL is the raw connection url. If set it must define the protocol ('http://',
	// 'rpc://'...)
	RawURL string `mapstructure:"raw_url" validate:"isdefault|url"`

	// Username is the username used to get connection credential
	Username string `mapstructure:"username"`

	// Password is the password used to get connection credentials
	Password string `mapstructure:"password"`

	// Options contains connection dependent specific options
	Options map[string]interface{} `mapstructure:"options"`

	// MaxTimeout defines the maximum timeout for the given repository connection
	MaxTimeout *time.Duration `mapstructure:"max_timeout"`

	// DBName gets the database name
	DBName string `mapstructure:"dbname"`

	// SSLMode defines if the ssl is enabled
	SSLMode string `mapstructure:"sslmode"`
}

Repository defines the repository configuration variables.

func (*Repository) Parse added in v0.2.1

func (r *Repository) Parse(s string) error

Parse parses the repository configuration from the whitespace seperated key value string. I.e. 'host=172.16.1.1 port=5432 username=some password=pass drivername=pq'

func (*Repository) Validate added in v0.2.1

func (r *Repository) Validate() error

Validate validates the repository config.

Jump to

Keyboard shortcuts

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