db_common

package
v0.9.0-dev.2 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2021 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const TagColumn = "column"

TagColumn is the tag used to specify the column name and type in the introspection tables

Variables

This section is empty.

Functions

func BuildSchemaMetadata added in v0.9.0

func BuildSchemaMetadata(rows *sql.Rows) (*schema.Metadata, error)

func CreateIntrospectionTables added in v0.9.0

func CreateIntrospectionTables(ctx context.Context, workspaceResources *modconfig.WorkspaceResourceMaps, client Client) error

func CreatePreparedStatements

func CreatePreparedStatements(ctx context.Context, resourceMaps *modconfig.WorkspaceResourceMaps, client Client) error

func ExecuteQuery

func ExecuteQuery(ctx context.Context, queryString string, client Client) (*queryresult.ResultStreamer, error)

ExecuteQuery executes a single query. If shutdownAfterCompletion is true, shutdown the client after completion

func GetActor added in v0.9.0

func GetActor(bearer string, client *http.Client) (string, error)

func GetConnectionString added in v0.9.0

func GetConnectionString(workspaceHandle, apiKey string) (string, error)

func GetPassword added in v0.9.0

func GetPassword(userHandle, bearer string, client *http.Client) (string, error)

func GetPreparedStatementsSQL added in v0.9.0

func GetPreparedStatementsSQL(resourceMaps *modconfig.WorkspaceResourceMaps) map[string]string

func GetWorkspaceHost added in v0.9.0

func GetWorkspaceHost(userHandle, workspaceHandle, bearer string, client *http.Client) (string, string, error)

func PgEscapeName

func PgEscapeName(name string) string

func PgEscapeSearchPath added in v0.9.0

func PgEscapeSearchPath(searchPath []string) []string

PgEscapeSearchPath applies postgres escaping to search path and remove whitespace

func PgEscapeString

func PgEscapeString(str string) string

PgEscapeString escapes strings which are to be inserted use a custom escape tag to avoid chance of clash with the escaped text https://medium.com/@lnishada/postgres-dollar-quoting-6d23e4f186ec

func UpdateIntrospectionTables added in v0.9.0

func UpdateIntrospectionTables(workspaceResources *modconfig.WorkspaceResourceMaps, client Client) error

func UpdatePreparedStatements

func UpdatePreparedStatements(ctx context.Context, prevResourceMaps, currentResourceMaps *modconfig.WorkspaceResourceMaps, client Client) error

UpdatePreparedStatements first attempts to deallocate all prepared statements in workspace, then recreates them

func WaitForConnection added in v0.8.3

func WaitForConnection(pool *sql.DB) bool

waits for the db to start accepting connections and returns true returns false if the dbClient does not start within a stipulated time,

Types

type Client

type Client interface {
	Close() error
	LoadSchema()

	SchemaMetadata() *schema.Metadata
	ConnectionMap() *steampipeconfig.ConnectionDataMap

	GetCurrentSearchPath() ([]string, error)
	SetSessionSearchPath(...string) error

	ExecuteSync(ctx context.Context, query string, disableSpinner bool) (*queryresult.SyncQueryResult, error)
	Execute(ctx context.Context, query string, disableSpinner bool) (res *queryresult.Result, err error)

	CacheOn() error
	CacheOff() error
	CacheClear() error

	SetEnsureSessionDataFunc(EnsureSessionStateCallback)

	RefreshConnectionAndSearchPaths() *RefreshConnectionResult
}

type ColumnTag added in v0.9.0

type ColumnTag struct {
	Column     string
	ColumnType string
}

type EnsureSessionStateCallback added in v0.8.3

type EnsureSessionStateCallback = func(context.Context, Client) error

type InitResult

type InitResult struct {
	Error    error
	Warnings []string
	Messages []string
}

func (*InitResult) AddMessage

func (r *InitResult) AddMessage(message string)

func (*InitResult) AddWarnings

func (r *InitResult) AddWarnings(warnings ...string)

func (*InitResult) DisplayMessages

func (r *InitResult) DisplayMessages()

func (*InitResult) HasMessages

func (r *InitResult) HasMessages() bool

type QueryInitData

type QueryInitData struct {
	Queries   []string
	Workspace WorkspaceResourceProvider
	Client    Client
	Result    *InitResult
}

func NewQueryInitData

func NewQueryInitData() *QueryInitData

type RefreshConnectionResult

type RefreshConnectionResult struct {
	UpdatedConnections bool
	Warnings           []string
	Error              error
}

RefreshConnectionResult is a structure used to contain the result of either a RefreshConnections or a NewLocalClient operation

func (*RefreshConnectionResult) ShowWarnings

func (r *RefreshConnectionResult) ShowWarnings()

type WorkspaceResourceProvider

type WorkspaceResourceProvider interface {
	ResolveQueryAndArgs(arg string) (string, modconfig.PreparedStatementProvider, error)
	GetQueryMap() map[string]*modconfig.Query
	GetControlMap() map[string]*modconfig.Control
	GetResourceMaps() *modconfig.WorkspaceResourceMaps
	GetControl(controlName string) (*modconfig.Control, bool)
	SetupWatcher(client Client, onError func(err error)) error
}

WorkspaceResourceProvider is an interface encapsulating workspace functionality - provided to avoid db needing a reference to Workspace

Jump to

Keyboard shortcuts

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