Documentation
¶
Index ¶
- type MgoService
- func (service *MgoService) ApplyConfiguration(configuration interface{}) error
- func (service *MgoService) LoadConfiguration() (interface{}, error)
- func (service *MgoService) Restart() error
- func (service *MgoService) RunWithSession(handler func(session *mgo.Session) error) error
- func (service *MgoService) Start() error
- func (service *MgoService) Stop() error
- type MgoServiceConfiguration
- type MgoServiceMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MgoService ¶
type MgoService struct {
Configuration MgoServiceConfiguration
// contains filtered or unexported fields
}
MgoService implements the mgo service itself.
func (*MgoService) ApplyConfiguration ¶
func (service *MgoService) ApplyConfiguration(configuration interface{}) error
ApplyConfiguration implements the type verification of the given `configuration` and applies it to the service.
func (*MgoService) LoadConfiguration ¶
func (service *MgoService) LoadConfiguration() (interface{}, error)
LoadConfiguration is an abstract method that should be overwritten on the actual usage of this service.
func (*MgoService) Restart ¶
func (service *MgoService) Restart() error
Restart restarts the service.
func (*MgoService) RunWithSession ¶
func (service *MgoService) RunWithSession(handler func(session *mgo.Session) error) error
RunWithSession runs a handler passing a new instance of the a session.
func (*MgoService) Start ¶
func (service *MgoService) Start() error
Start initialize the mongo connection and saves the session.
type MgoServiceConfiguration ¶
type MgoServiceConfiguration struct {
Addresses []string `yaml:"addresses"`
Database string `yaml:"database"`
Username string `yaml:"username"`
Password string `yaml:"password"`
PoolSize int `yaml:"pool_size"`
Timeout int `yaml:"timeout"`
Mode *MgoServiceMode `yaml:"mode"`
UseTLS bool `yaml:"use_tls"`
}
MgoServiceConfiguration describes the `MgoService` configuration.
type MgoServiceMode ¶
MgoServiceMode is an alias for the `mgo.Mode` that implements Unmarshaling from the YAML.
func (*MgoServiceMode) UnmarshalYAML ¶
func (mode *MgoServiceMode) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements the marshaling a `mgo.Mode` to string.