Documentation ¶
Index ¶
- func Get(ctx context.Context) (db.Provider, error)
- func GetEnity(ctx context.Context, enityName string) (interface{}, error)
- func Registrate(ctx context.Context) (context.Context, error)
- func RegistrateEnity(ctx context.Context, enityName string, options interface{}) (context.Context, error)
- type Config
- type Enity
- type Provider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { // DSN is a connection string in form of DSN. Example: // host:port. // Default: "localhost:9080" DSN string `envconfig:"optional"` // StartWatcher indicates to connection controller that it should // also start asynchronous connection watcher. StartWatcher bool `envconfig:"optional"` // Timeout is a timeout in seconds for connection checking. Every // this count of seconds database connection will be checked for // aliveness and, if it dies, attempt to reestablish connection // will be made. Default timeout is 10 seconds. Timeout time.Duration `envconfig:"optional"` }
Config represents configuration structure for every connection.
func (*Config) SetDefault ¶
SetDefault checks connection config. If required field is empty - it will be filled with some default value. Returns a copy of config.
type Enity ¶
type Enity struct { // Metrics stats.Service // DB connection Conn *dgo.Dgraph // contains filtered or unexported fields }
Enity is a connection controlling structure. It controls connection, asynchronous queue and everything that related to specified connection.
func GetEnityTypeCast ¶ added in v0.4.1
func (*Enity) GetMetrics ¶
func (c *Enity) GetMetrics(prefix string) stats.MapMetricsOptions
GetMetrics return map of the metrics from database connection
func (*Enity) GetReadyHandlers ¶
func (c *Enity) GetReadyHandlers(prefix string) stats.MapCheckFunc
GetReadyHandlers return array of the readyHandlers from database connection
func (*Enity) Shutdown ¶
Shutdown shutdowns queue worker and connection watcher. Later will also close connection to database. This is a blocking call.
func (*Enity) WaitForEstablishing ¶
func (c *Enity) WaitForEstablishing()
WaitForEstablishing will block execution until connection will be successfully established and database migrations will be applied (or rolled back).
type Provider ¶ added in v0.4.1
type Provider struct {
*providerwithmetrics.Provider
}
Provider for database mongo
func NewProvider ¶ added in v0.4.1
NewProvider creates new provider.
func (*Provider) CreateEnity ¶ added in v0.4.1
CreateEnity should create enity using passed parameters.