db_common

package
v0.8.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const TagColumn = "column"

TagColumn :: tag used to specify the column name and type in the reflection tables

Variables

This section is empty.

Functions

func CreateMetadataTables

func CreateMetadataTables(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 PgEscapeName

func PgEscapeName(name string) string

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 UpdateMetadataTables

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

func UpdatePreparedStatements

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

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

Types

type Client

type Client interface {
	Close() error
	GetCurrentSearchPath() ([]string, error)
	SetClientSearchPath() 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)
	SchemaMetadata() *schema.Metadata

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

	// todo share this between locan and remote client?
	LoadSchema()

	ConnectionMap() *steampipeconfig.ConnectionMap
	RefreshConnectionAndSearchPaths() *RefreshConnectionResult
}

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
	PreparedStatementProviders *modconfig.WorkspaceResourceMaps
	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 :: interface encapsulating named query searching capability - 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