Documentation
¶
Overview ¶
Package neuron is the cloud-native, distributed ORM implementation.
It's design allows to use the separate repository for each model, with a possibility to have different relationships types between them.
neuron consists of following packages:
config - contains the configurations for all packages.
controller - is the neuron's core, that registers and stores the models and contains configurations required by other packages.
errors - classified errors.
query - used to create queries, filters, sort, pagination on base of mapped models.
mapping - contains the information about the mapped models their fields and settings.
log - is the neuron service logging interface structure for the neuron based applications.
repository - is a package used to store and register the repositories.
It is also used to get the repository/factory per model. A modular design allows to use and compile only required repositories.
Index ¶
- func Begin() *query.Tx
- func BeginCtx(ctx context.Context, opts *query.TxOptions) *query.Tx
- func RunInTransaction(ctx context.Context, orm query.DB, txFn TxFn) (err error)
- type Neuron
- func (n *Neuron) CloseAll(ctx context.Context) error
- func (n *Neuron) Controller() *controller.Controller
- func (n *Neuron) DialAll(ctx context.Context) error
- func (n *Neuron) HealthCheck(ctx context.Context) (*repository.HealthResponse, error)
- func (n *Neuron) MigrateModels(ctx context.Context, models ...interface{}) error
- func (n *Neuron) RegisterModels(models ...interface{}) error
- func (n *Neuron) RegisterRepository(name string, repo *config.Repository) error
- type TxFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Neuron ¶
type Neuron struct {
// contains filtered or unexported fields
}
Neuron is the main structure that stores the controller, create queries, registers models and repositories.
func NewC ¶
func NewC(c *controller.Controller) *Neuron
NewC creates new Neuron service with the provided 'c' controller.
func (*Neuron) Controller ¶
func (n *Neuron) Controller() *controller.Controller
Controller gets neuron controller.
func (*Neuron) HealthCheck ¶
func (n *Neuron) HealthCheck(ctx context.Context) (*repository.HealthResponse, error)
HealthCheck checks all repositories health for the default controller.
func (*Neuron) MigrateModels ¶
MigrateModels updates or creates provided models representation in their related repositories. A representation of model might be a database table, collection etc. Model's repository must implement repository.Migrator.
func (*Neuron) RegisterModels ¶
RegisterModels registers all models into default controller. This function requires repositories to be registered before. Returns error if the model was already registered.
func (*Neuron) RegisterRepository ¶
func (n *Neuron) RegisterRepository(name string, repo *config.Repository) error
RegisterRepository registers repository into default controller. Returns error if the repository with given name was already registered. By default the first registered repository is set to the default repository for all models that doesn't define their repositories, unless default controller's config DisallowDefaultRepository is set to false.
Directories
¶
Path | Synopsis |
---|---|
Package annotation contains constants used as mapping annotations.
|
Package annotation contains constants used as mapping annotations. |
Package config contains configuration structures used by all neuron packages.
|
Package config contains configuration structures used by all neuron packages. |
Package controller contains root neuron structure.
|
Package controller contains root neuron structure. |
errors
module
|
|
Package log contains default neuron logger interface with it's subcomponents.
|
Package log contains default neuron logger interface with it's subcomponents. |
Package mapping contains neuron models mapped structures.
|
Package mapping contains neuron models mapped structures. |
Package query is the package used that defines the neuron query it's structure, processor, transactions.
|
Package query is the package used that defines the neuron query it's structure, processor, transactions. |
Package repository is the package that defines neuron repositories and it's factories.
|
Package repository is the package that defines neuron repositories and it's factories. |