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 RegisterFactory ¶
RegisterFactory registers provided Factory within the container.
Types ¶
type Factory ¶
type Factory interface { // DriverName gets the driver name for given factory. DriverName() string // New creates new instance of the Repository for given 'model'. New(config *config.Repository) (Repository, error) }
Factory is the interface used for creating the repositories.
func GetFactory ¶
GetFactory gets the factory with given driver 'name'.
type HealthResponse ¶ added in v0.12.0
type HealthResponse struct { Status HealthStatus Output string Notes []string }
HealthResponse is the response for the health check.
type HealthStatus ¶ added in v0.12.0
type HealthStatus int
HealthStatus is the status of the health check
const ( // StatusPass defines healthy status StatusPass HealthStatus = iota // StatusFail defines unhealthy result StatusFail // StatusWarn defines StatusWarn )
enum values for the health statuses
func (HealthStatus) MarshalText ¶ added in v0.12.0
func (s HealthStatus) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler interface.
func (HealthStatus) String ¶ added in v0.12.0
func (s HealthStatus) String() string
type Migrator ¶ added in v0.12.0
type Migrator interface {
MigrateModels(ctx context.Context, models ...*mapping.ModelStruct) error
}
Migrator migrates the models into the repository.
type Repository ¶
type Repository interface { // Dial establish all possible repository connections. Dial(ctx context.Context) error // FactoryName returns the factory name for given repository. FactoryName() string // RegisterModels registers provided 'models' into Repository specific mappings. RegisterModels(models ...*mapping.ModelStruct) error // HealthCheck defines the health status of the repository. HealthCheck(ctx context.Context) (*HealthResponse, error) // Close closes the connection for given repository. Close(ctx context.Context) error }
Repository is the interface that defines the base neuron Repository.