repository

package
v0.11.17 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package repository is the package that defines neuron repositories and it's factories. A repository is a structure that gives an access with well known interfaces to the models databases, datastores. A factory is the structure with unique name that is responsible of creating new repository instances of given type. The package is used to register, get and close (finish) factory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseAll added in v0.2.1

func CloseAll(ctx context.Context) error

CloseAll closes all repositoriy instances for all registered factories.

func RegisterFactory

func RegisterFactory(f Factory) error

RegisterFactory registers provided Factory within the container.

Types

type Controller added in v0.2.2

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

Controller gets the model struct from the given model.

type Factory

type Factory interface {
	// Namer gets the repository name for given factory.
	DriverName() string
	// New creates new instance of the Repository for given 'model'.
	New(c Controller, model *mapping.ModelStruct) (Repository, error)
	// Close should close all the repository instances for this factory.
	Close(ctx context.Context, done chan<- interface{})
}

Factory is the interface used for creating the repositories.

func GetFactory

func GetFactory(name string) Factory

GetFactory gets the factory with given driver 'name'.

type Repository

type Repository interface {
	FactoryName() string
	Close(ctx context.Context) error
}

Repository is the interface that defines the base neuron Repository.

Jump to

Keyboard shortcuts

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