db_client

package
v0.20.0-rc.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2023 License: AGPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRelationNotFoundError added in v0.20.0

func IsRelationNotFoundError(err error) (string, string, bool)

Types

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) (*DbClient, error)

func (*DbClient) AcquireConnection added in v0.20.0

func (c *DbClient) AcquireConnection(ctx context.Context) (*pgxpool.Conn, error)

func (*DbClient) AcquireSession

func (c *DbClient) AcquireSession(ctx context.Context) (sessionResult *db_common.AcquireSessionResult)

func (*DbClient) Close

func (c *DbClient) Close(context.Context) error

Close implements Client closes the connection to the database and shuts down the backend

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 (c *DbClient) GetCustomSearchPath() []string

func (*DbClient) GetDatabaseConnectionWithRetries added in v0.20.0

func (c *DbClient) GetDatabaseConnectionWithRetries(ctx context.Context) (*pgxpool.Conn, uint32, error)

func (*DbClient) GetRequiredSessionSearchPath

func (c *DbClient) GetRequiredSessionSearchPath() []string

GetRequiredSessionSearchPath implements Client

func (*DbClient) GetSchemaFromDB

func (c *DbClient) GetSchemaFromDB(ctx context.Context) (*db_common.SchemaMetadata, error)

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 (c *DbClient) GetSchemaFromDBLegacy(ctx context.Context, conn *pgxpool.Conn) (*db_common.SchemaMetadata, error)

func (*DbClient) LoadUserSearchPath added in v0.20.0

func (c *DbClient) LoadUserSearchPath(ctx context.Context) error

func (*DbClient) RefreshSessions

func (c *DbClient) RefreshSessions(ctx context.Context) (res *db_common.AcquireSessionResult)

RefreshSessions terminates the current connections and creates a new one - repopulating session data

func (*DbClient) SetRequiredSessionSearchPath

func (c *DbClient) SetRequiredSessionSearchPath(ctx context.Context) error

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

type DbConnectionCallback added in v0.17.0

type DbConnectionCallback func(context.Context, *pgx.Conn) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL