Documentation ¶
Index ¶
- type PostgresConnection
- func (c *PostgresConnection) Close(correlationId string) error
- func (c *PostgresConnection) Configure(config *cconf.ConfigParams)
- func (c *PostgresConnection) GetConnection() *pgxpool.Pool
- func (c *PostgresConnection) GetDatabaseName() string
- func (c *PostgresConnection) IsOpen() bool
- func (c *PostgresConnection) Open(correlationId string) error
- func (c *PostgresConnection) SetReferences(references cref.IReferences)
- type PostgresConnectionResolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PostgresConnection ¶ added in v1.2.0
type PostgresConnection struct { // The logger. Logger *clog.CompositeLogger // The connection resolver. ConnectionResolver *PostgresConnectionResolver // The configuration options. Options *cconf.ConfigParams // The PostgreSQL connection pool object. Connection *pgxpool.Pool // The PostgreSQL database name. DatabaseName string // contains filtered or unexported fields }
*
PostgreSQL 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: 27017)
- 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
- options:
- connect_timeout: (optional) number of milliseconds to wait before timing out when connecting a new client (default: 0)
- idle_timeout: (optional) number of milliseconds a client must sit idle in the pool and not be checked out (default: 10000)
- max_pool_size: (optional) maximum number of clients the pool should contain (default: 10)
### 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 NewPostgresConnection ¶ added in v1.2.0
func NewPostgresConnection() *PostgresConnection
NewPostgresConnection creates a new instance of the connection component.
func (*PostgresConnection) Close ¶ added in v1.2.0
func (c *PostgresConnection) Close(correlationId string) error
Closes component and frees used resources.
- correlationId (optional) transaction id to trace execution through call chain.
Return error or nil no errors occured
func (*PostgresConnection) Configure ¶ added in v1.2.0
func (c *PostgresConnection) Configure(config *cconf.ConfigParams)
Configures component by passing configuration parameters.
- config configuration parameters to be set.
func (*PostgresConnection) GetConnection ¶ added in v1.2.0
func (c *PostgresConnection) GetConnection() *pgxpool.Pool
func (*PostgresConnection) GetDatabaseName ¶ added in v1.2.0
func (c *PostgresConnection) GetDatabaseName() string
func (*PostgresConnection) IsOpen ¶ added in v1.2.0
func (c *PostgresConnection) IsOpen() bool
Checks if the component is opened. Returns true if the component has been opened and false otherwise.
func (*PostgresConnection) Open ¶ added in v1.2.0
func (c *PostgresConnection) Open(correlationId string) error
Opens the component.
- correlationId (optional) transaction id to trace execution through call chain.
- Return error or nil no errors occured.
func (*PostgresConnection) SetReferences ¶ added in v1.2.0
func (c *PostgresConnection) SetReferences(references cref.IReferences)
Sets references to dependent components.
- references references to locate the component dependencies.
type PostgresConnectionResolver ¶
type PostgresConnectionResolver struct { //The connections resolver. ConnectionResolver ccon.ConnectionResolver //The credentials resolver. CredentialResolver auth.CredentialResolver }
PostgresConnectionResolver a helper struct that resolves Postgres connection and credential parameters, validates them and generates a connection URI. It is able to process multiple connections to Postgres 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: 27017)
- 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 NewPostgresConnectionResolver ¶
func NewPostgresConnectionResolver() *PostgresConnectionResolver
NewPostgresConnectionResolver creates new connection resolver Retruns *PostgresConnectionResolver
func (*PostgresConnectionResolver) Configure ¶
func (c *PostgresConnectionResolver) Configure(config *cconf.ConfigParams)
Configure is configures component by passing configuration parameters. Parameters:
- config *cconf.ConfigParams configuration parameters to be set.
func (*PostgresConnectionResolver) Resolve ¶
func (c *PostgresConnectionResolver) Resolve(correlationId string) (uri string, err error)
Resolve method are resolves Postgres connection URI from connection and credential parameters. Parameters:
- correlationId string (optional) transaction id to trace execution through call chain.
Returns uri string, err error resolved URI and error, if this occured.
func (*PostgresConnectionResolver) SetReferences ¶
func (c *PostgresConnectionResolver) SetReferences(references crefer.IReferences)
SetReferences is sets references to dependent components. Parameters:
- references crefer.IReferences references to locate the component dependencies.