Documentation ¶
Overview ¶
It has the responsibility to find the *CloudEnv* where your program run, store *Connector*s and retrieve services from *CloudEnv* which corresponds to one or many *Connector* and finally it will pass to *Connector* the service and store the result from connector.
Index ¶
- Constants
- func NewErrGiveService(content string) error
- func NewErrNoConnectorFound(id string) error
- func NewErrNotInCloud(cloudEnvs []string) error
- func NewErrPtrNotGiven() error
- type ErrGiveService
- type ErrNoConnectorFound
- type ErrNotInCloud
- type ErrPtrNotGiven
- type GautocloudLoader
- func (l *GautocloudLoader) CleanConnectors()
- func (l GautocloudLoader) CloudEnvs() []cloudenv.CloudEnv
- func (l GautocloudLoader) Connectors() map[string]connectors.Connector
- func (l GautocloudLoader) CurrentCloudEnv() cloudenv.CloudEnv
- func (l GautocloudLoader) GetAll(id string) ([]interface{}, error)
- func (l GautocloudLoader) GetAppInfo() cloudenv.AppInfo
- func (l GautocloudLoader) GetFirst(id string) (interface{}, error)
- func (l GautocloudLoader) Inject(service interface{}) error
- func (l GautocloudLoader) InjectFromId(id string, service interface{}) error
- func (l GautocloudLoader) IsInACloudEnv() bool
- func (l GautocloudLoader) LoadCloudEnvs()
- func (l *GautocloudLoader) RegisterConnector(connector connectors.Connector)
- func (l GautocloudLoader) Reload()
- func (l *GautocloudLoader) ReloadConnectors()
- func (l *GautocloudLoader) Store() map[string][]StoredService
- type Loader
- type StoredService
Constants ¶
const ( LOG_MESSAGE_PREFIX = "gautocloud" DEBUG_MODE_ENV_VAR = "GAUTOCLOUD_DEBUG" )
Variables ¶
This section is empty.
Functions ¶
func NewErrGiveService ¶
func NewErrNoConnectorFound ¶
func NewErrNotInCloud ¶
func NewErrPtrNotGiven ¶
func NewErrPtrNotGiven() error
Types ¶
type ErrGiveService ¶
type ErrGiveService struct {
// contains filtered or unexported fields
}
func (ErrGiveService) Error ¶
func (e ErrGiveService) Error() string
type ErrNoConnectorFound ¶
type ErrNoConnectorFound struct {
// contains filtered or unexported fields
}
func (ErrNoConnectorFound) Error ¶
func (e ErrNoConnectorFound) Error() string
type ErrNotInCloud ¶
type ErrNotInCloud struct {
// contains filtered or unexported fields
}
func (ErrNotInCloud) Error ¶
func (e ErrNotInCloud) Error() string
type ErrPtrNotGiven ¶
type ErrPtrNotGiven struct { }
func (ErrPtrNotGiven) Error ¶
func (e ErrPtrNotGiven) Error() string
type GautocloudLoader ¶
type GautocloudLoader struct {
// contains filtered or unexported fields
}
func (*GautocloudLoader) CleanConnectors ¶
func (l *GautocloudLoader) CleanConnectors()
Remove all registered connectors
func (GautocloudLoader) CloudEnvs ¶
func (l GautocloudLoader) CloudEnvs() []cloudenv.CloudEnv
Return all cloud environments loaded
func (GautocloudLoader) Connectors ¶
func (l GautocloudLoader) Connectors() map[string]connectors.Connector
Return all registered connectors
func (GautocloudLoader) CurrentCloudEnv ¶
func (l GautocloudLoader) CurrentCloudEnv() cloudenv.CloudEnv
Return the current cloud env detected
func (GautocloudLoader) GetAll ¶
func (l GautocloudLoader) GetAll(id string) ([]interface{}, error)
Return all services found by a connector id is the id of a connector Example:
var svc []interface{} data, err = gautocloud.GetAll("mysql") svc = data[0].(*dbtype.MysqlDB)
warning: a connector may give you different types that's why GetAll return a slice of interface{} It returns the first service found or an error if no service can be found or if the connector doesn't exists
func (GautocloudLoader) GetAppInfo ¶
func (l GautocloudLoader) GetAppInfo() cloudenv.AppInfo
Return informations about instance of the running application
func (GautocloudLoader) GetFirst ¶
func (l GautocloudLoader) GetFirst(id string) (interface{}, error)
Return the first service found by a connector id is the id of a connector Example:
var svc *dbtype.MysqlDB data, err = gautocloud.GetFirst("mysql") svc = data.(*dbtype.MysqlDB)
It returns the first service found or an error if no service can be found or if the connector doesn't exists
func (GautocloudLoader) Inject ¶
func (l GautocloudLoader) Inject(service interface{}) error
Inject service(s) found by connectors with given type Example:
var svc *dbtype.MysqlDB err = loader.Inject(&svc) // svc will have the value of the first service found with type *dbtype.MysqlDB
If service parameter is not a slice it will give the first service found If you pass a slice of a type in service parameter, it will inject in the slice all services found with this type It returns an error if parameter is not a pointer or if no service(s) can be found
func (GautocloudLoader) InjectFromId ¶
func (l GautocloudLoader) InjectFromId(id string, service interface{}) error
Inject service(s) found by a connector with given type id is the id of a connector Example:
var svc *dbtype.MysqlDB err = gautocloud.InjectFromId("mysql", &svc) // svc will have the value of the first service found with type *dbtype.MysqlDB in this case
If service parameter is not a slice it will give the first service found If you pass a slice of a type in service parameter, it will inject in the slice all services found with this type It returns an error if service parameter is not a pointer, if no service(s) can be found and if connector with given id doesn't exist
func (GautocloudLoader) IsInACloudEnv ¶
func (l GautocloudLoader) IsInACloudEnv() bool
Return true if you are in a cloud environment
func (GautocloudLoader) LoadCloudEnvs ¶
func (l GautocloudLoader) LoadCloudEnvs()
func (*GautocloudLoader) RegisterConnector ¶
func (l *GautocloudLoader) RegisterConnector(connector connectors.Connector)
Register a connector in the loader This is mainly use for connectors creators
func (GautocloudLoader) Reload ¶
func (l GautocloudLoader) Reload()
Reload environment and connectors
func (*GautocloudLoader) ReloadConnectors ¶
func (l *GautocloudLoader) ReloadConnectors()
Reload connectors to find services
func (*GautocloudLoader) Store ¶
func (l *GautocloudLoader) Store() map[string][]StoredService
Return all services loaded
type Loader ¶
type Loader interface { Reload() ReloadConnectors() RegisterConnector(connector connectors.Connector) Inject(service interface{}) error InjectFromId(id string, service interface{}) error GetFirst(id string) (interface{}, error) GetAll(id string) ([]interface{}, error) CloudEnvs() []cloudenv.CloudEnv Connectors() map[string]connectors.Connector Store() map[string][]StoredService CleanConnectors() CurrentCloudEnv() cloudenv.CloudEnv GetAppInfo() cloudenv.AppInfo IsInACloudEnv() bool }
type StoredService ¶
type StoredService struct { Data interface{} ConnectorId string ReflectType reflect.Type Interceptor interceptor.Intercepter }