Documentation ¶
Index ¶
- Constants
- type ClientOption
- type DbClient
- func (c *DbClient) AcquireManagementConnection(ctx context.Context) (*pgxpool.Conn, error)
- func (c *DbClient) AcquireSession(ctx context.Context) (sessionResult *db_common.AcquireSessionResult)
- func (c *DbClient) Close(context.Context) error
- func (c *DbClient) Execute(ctx context.Context, query string, args ...any) (*queryresult.Result, error)
- func (c *DbClient) ExecuteInSession(ctx context.Context, session *db_common.DatabaseSession, onComplete func(), ...) (res *queryresult.Result, err error)
- func (c *DbClient) ExecuteSync(ctx context.Context, query string, args ...any) (*queryresult.SyncQueryResult, error)
- func (c *DbClient) ExecuteSyncInSession(ctx context.Context, session *db_common.DatabaseSession, query string, ...) (*queryresult.SyncQueryResult, error)
- func (c *DbClient) GetCustomSearchPath() []string
- func (c *DbClient) GetRequiredSessionSearchPath() []string
- func (c *DbClient) GetSchemaFromDB(ctx context.Context) (*db_common.SchemaMetadata, error)
- func (c *DbClient) GetSchemaFromDBLegacy(ctx context.Context, conn *pgxpool.Conn) (*db_common.SchemaMetadata, error)
- func (c *DbClient) LoadUserSearchPath(ctx context.Context) error
- func (c *DbClient) RegisterNotificationListener(func(notification *pgconn.Notification))
- func (c *DbClient) ResetPools(ctx context.Context)
- func (c *DbClient) ServerSettings() *db_common.ServerSettings
- func (c *DbClient) SetRequiredSessionSearchPath(ctx context.Context) error
- type DbConnectionCallback
- type PoolOverrides
Constants ¶
const ( MaxConnLifeTime = 10 * time.Minute MaxConnIdleTime = 1 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientOption ¶ added in v0.21.0
type ClientOption func(*clientConfig)
func WithManagementPoolOverride ¶ added in v0.21.0
func WithManagementPoolOverride(s PoolOverrides) ClientOption
func WithUserPoolOverride ¶ added in v0.21.0
func WithUserPoolOverride(s PoolOverrides) ClientOption
type DbClient ¶
type DbClient struct {
// contains filtered or unexported fields
}
DbClient wraps over `sql.DB` and gives an interface to the database
func NewDbClient ¶
func NewDbClient(ctx context.Context, connectionString string, onConnectionCallback DbConnectionCallback, opts ...ClientOption) (_ *DbClient, err error)
func (*DbClient) AcquireManagementConnection ¶ added in v0.21.0
func (*DbClient) AcquireSession ¶
func (c *DbClient) AcquireSession(ctx context.Context) (sessionResult *db_common.AcquireSessionResult)
func (*DbClient) Execute ¶
func (c *DbClient) Execute(ctx context.Context, query string, args ...any) (*queryresult.Result, error)
Execute implements Client execute the query in the given Context NOTE: The returned Result MUST be fully read - otherwise the connection will block and will prevent further communication
func (*DbClient) ExecuteInSession ¶
func (c *DbClient) ExecuteInSession(ctx context.Context, session *db_common.DatabaseSession, onComplete func(), query string, args ...any) (res *queryresult.Result, err error)
ExecuteInSession implements Client execute the query in the given Context using the provided DatabaseSession ExecuteInSession assumes no responsibility over the lifecycle of the DatabaseSession - that is the responsibility of the caller NOTE: The returned Result MUST be fully read - otherwise the connection will block and will prevent further communication
func (*DbClient) ExecuteSync ¶
func (c *DbClient) ExecuteSync(ctx context.Context, query string, args ...any) (*queryresult.SyncQueryResult, error)
ExecuteSync implements Client execute a query against this client and wait for the result
func (*DbClient) ExecuteSyncInSession ¶
func (c *DbClient) ExecuteSyncInSession(ctx context.Context, session *db_common.DatabaseSession, query string, args ...any) (*queryresult.SyncQueryResult, error)
ExecuteSyncInSession implements Client execute a query against this client and wait for the result
func (*DbClient) GetCustomSearchPath ¶ added in v0.20.0
func (*DbClient) GetRequiredSessionSearchPath ¶
GetRequiredSessionSearchPath implements Client
func (*DbClient) GetSchemaFromDB ¶
GetSchemaFromDB retrieves schemas for all steampipe connections (EXCEPT DISABLED CONNECTIONS) NOTE: it optimises the schema extraction by extracting schema information for connections backed by distinct plugins and then fanning back out.
func (*DbClient) GetSchemaFromDBLegacy ¶ added in v0.20.0
func (*DbClient) LoadUserSearchPath ¶ added in v0.20.0
func (*DbClient) RegisterNotificationListener ¶ added in v0.21.0
func (c *DbClient) RegisterNotificationListener(func(notification *pgconn.Notification))
RegisterNotificationListener has an empty implementation NOTE: we do not (currently) support notifications from remote connections
func (*DbClient) ResetPools ¶ added in v0.21.0
refreshDbClient terminates the current connection and opens up a new connection to the service.
func (*DbClient) ServerSettings ¶ added in v0.21.0
func (c *DbClient) ServerSettings() *db_common.ServerSettings
ServerSettings returns the settings of the steampipe service that this DbClient is connected to
Keep in mind that when connecting to pre-0.21.x servers, the server_settings data is not available. This is expected. Code which read server_settings should take this into account.
func (*DbClient) SetRequiredSessionSearchPath ¶
SetRequiredSessionSearchPath implements Client if either a search-path or search-path-prefix is set in config, set the search path (otherwise fall back to user search path) this just sets the required search path for this client - when creating a database session, we will actually set the searchPath