Documentation
¶
Index ¶
- type SqliteConnection
- func (c *SqliteConnection) Close(ctx context.Context, correlationId string) error
- func (c *SqliteConnection) Configure(ctx context.Context, config *cconf.ConfigParams)
- func (c *SqliteConnection) GetConnection() *sql.DB
- func (c *SqliteConnection) GetDatabase() *sql.DB
- func (c *SqliteConnection) GetDatabaseName() string
- func (c *SqliteConnection) IsOpen() bool
- func (c *SqliteConnection) Open(ctx context.Context, correlationId string) error
- func (c *SqliteConnection) SetReferences(ctx context.Context, references crefer.IReferences)
- type SqliteConnectionResolver
- func (c *SqliteConnectionResolver) Configure(ctx context.Context, config *cconf.ConfigParams)
- func (c *SqliteConnectionResolver) Resolve(ctx context.Context, correlationId string) (uri string, err error)
- func (c *SqliteConnectionResolver) SetReferences(ctx context.Context, references crefer.IReferences)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SqliteConnection ¶
type SqliteConnection struct { // The logger. Logger *clog.CompositeLogger // The connection resolver. ConnectionResolver *SqliteConnectionResolver // The configuration options. Options *cconf.ConfigParams // The SQLite connection object. Connection *sql.DB // The SQLite database name. DatabaseName string // contains filtered or unexported fields }
SqliteConnection struct help creates new connections to SQLite SQLite connection using plain driver.
By defining a connection and sharing it through multiple persistence components you can reduce number of used database connections.
Configuration parameters: - connection(s): - discovery_key: (optional) a key to retrieve the connection from IDiscovery - host: host name or IP address - port: port number (default: 8082) - uri: resource URI or connection string with all parameters in it - credential(s): - store_key: (optional) a key to retrieve the credentials from ICredentialStore - username: (optional) user name - password: (optional) user password - options: - max_pool_size: (optional) maximum connection pool size (default: 2) - keep_alive: (optional) enable connection keep alive in ms, if zero connection are keeped indefinitely (default: 0) - connect_timeout: (optional) connection timeout in milliseconds (default: 5000) - socket_timeout: (optional) socket timeout in milliseconds (default: 360000) - auto_reconnect: (optional) enable auto reconnection (default: true) (Not used) - reconnect_interval: (optional) reconnection interval in milliseconds (default: 1000) (Not used) - max_page_size: (optional) maximum page size (default: 100) - replica_set: (optional) name of replica set - ssl: (optional) enable SSL connection (default: false) (Not release in this version) - auth_source: (optional) authentication source - debug: (optional) enable debug output (default: false). (Not used) References: - *:logger:*:*:1.0 (optional) ILogger components to pass log messages - *:discovery:*:*:1.0 (optional) IDiscovery services - *:credential-store:*:*:1.0 (optional) Credential stores to resolve credentials
func NewSqliteConnection ¶
func NewSqliteConnection() *SqliteConnection
NewSqliteConnection are creates a new instance of the connection component. Returns *SqliteConnection with default config
func (*SqliteConnection) Close ¶
func (c *SqliteConnection) Close(ctx context.Context, correlationId string) error
Close method is closes component and frees used resources.
Parameters: - ctx context.Context - correlationId string(optional) transaction id to trace execution through call chain. Returns: error or nil when no errors occurred.
func (*SqliteConnection) Configure ¶
func (c *SqliteConnection) Configure(ctx context.Context, config *cconf.ConfigParams)
Configure is configures component by passing configuration parameters.
Parameters: - ctx context.Context - config *cconf.ConfigParams configuration parameters to be set.
func (*SqliteConnection) GetConnection ¶
func (c *SqliteConnection) GetConnection() *sql.DB
GetConnection method return work connection object
Returns: *sql.DB
func (*SqliteConnection) GetDatabase ¶
func (c *SqliteConnection) GetDatabase() *sql.DB
GetDatabase method retrun work database object
Returns: *sql.DB
func (*SqliteConnection) GetDatabaseName ¶
func (c *SqliteConnection) GetDatabaseName() string
GetDatabaseName method reruns name of work database
Returns: string
func (*SqliteConnection) IsOpen ¶
func (c *SqliteConnection) IsOpen() bool
IsOpen method is checks if the component is opened.
Returns: true if the component has been opened and false otherwise.
func (*SqliteConnection) Open ¶
func (c *SqliteConnection) Open(ctx context.Context, correlationId string) error
Open method is opens the component.
Parameters: - ctx context.Context - correlationId string (optional) transaction id to trace execution through call chain. Returns: error or nil when no errors occurred.
func (*SqliteConnection) SetReferences ¶
func (c *SqliteConnection) SetReferences(ctx context.Context, references crefer.IReferences)
SetReferences are sets references to dependent components.
Parameters: - ctx context.Context - references crefer.IReferences references to locate the component dependencies.
type SqliteConnectionResolver ¶
type SqliteConnectionResolver struct { //The connections resolver. ConnectionResolver ccon.ConnectionResolver //The credentials resolver. CredentialResolver auth.CredentialResolver }
SqliteConnectionResolver a helper struct that resolves SQLite connection and credential parameters, validates them and generates a connection URI. It is able to process multiple connections to SQLite cluster nodes.
Configuration parameters - connection(s): - discovery_key: (optional) a key to retrieve the connection from IDiscovery - host: host name or IP address - port: port number (default: 8082) - database: database name - uri: resource URI or connection string with all parameters in it - credential(s): - store_key: (optional) a key to retrieve the credentials from ICredentialStore - username: user name - password: user password References - *:discovery:*:*:1.0 (optional) IDiscovery services - *:credential-store:*:*:1.0 (optional) Credential stores to resolve credentials
func NewSqliteConnectionResolver ¶
func NewSqliteConnectionResolver() *SqliteConnectionResolver
NewSqliteConnectionResolver creates new connection resolver
Returns: *SqliteConnectionResolver
func (*SqliteConnectionResolver) Configure ¶
func (c *SqliteConnectionResolver) Configure(ctx context.Context, config *cconf.ConfigParams)
Configure is configures component by passing configuration parameters.
Parameters: - ctx context.Context - config *cconf.ConfigParams configuration parameters to be set.
func (*SqliteConnectionResolver) Resolve ¶
func (c *SqliteConnectionResolver) Resolve(ctx context.Context, correlationId string) (uri string, err error)
Resolve method are resolves SQLite connection URI from connection and credential parameters.
Parameters: - ctx context.Context - correlationId string (optional) transaction id to trace execution through call chain. Returns: uri string, err error resolved URI and error, if this occured.
func (*SqliteConnectionResolver) SetReferences ¶
func (c *SqliteConnectionResolver) SetReferences(ctx context.Context, references crefer.IReferences)
SetReferences is sets references to dependent components.
Parameters: - ctx context.Context, - references crefer.IReferences references to locate the component dependencies.