Documentation ¶
Index ¶
- Constants
- func BuildSchemaMetadata(rows *sql.Rows) (*schema.Metadata, error)
- func CreateIntrospectionTables(ctx context.Context, workspaceResources *modconfig.WorkspaceResourceMaps, ...) error
- func CreatePreparedStatements(ctx context.Context, resourceMaps *modconfig.WorkspaceResourceMaps, ...) (err error, warnings []string)
- func ExecuteQuery(ctx context.Context, queryString string, client Client) (*queryresult.ResultStreamer, error)
- func GetPreparedStatementsSQL(resourceMaps *modconfig.WorkspaceResourceMaps) map[string]string
- func PgEscapeName(name string) string
- func PgEscapeSearchPath(searchPath []string) []string
- func PgEscapeString(str string) string
- func UpdateIntrospectionTables(workspaceResources *modconfig.WorkspaceResourceMaps, client Client) error
- func WaitForConnection(ctx context.Context, db *sql.DB) (err error)
- type AcquireSessionResult
- type Client
- type ColumnTag
- type DatabaseSession
- type EnsureSessionStateCallback
- type InitResult
- type QueryInitData
- type WorkspaceResourceProvider
Constants ¶
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 CreateIntrospectionTables ¶ added in v0.9.0
func CreateIntrospectionTables(ctx context.Context, workspaceResources *modconfig.WorkspaceResourceMaps, session *DatabaseSession) error
func CreatePreparedStatements ¶
func CreatePreparedStatements(ctx context.Context, resourceMaps *modconfig.WorkspaceResourceMaps, session *DatabaseSession) (err error, warnings []string)
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 GetPreparedStatementsSQL ¶ added in v0.9.0
func GetPreparedStatementsSQL(resourceMaps *modconfig.WorkspaceResourceMaps) map[string]string
func PgEscapeName ¶
func PgEscapeSearchPath ¶ added in v0.9.0
PgEscapeSearchPath applies postgres escaping to search path and remove whitespace
func PgEscapeString ¶
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
Types ¶
type AcquireSessionResult ¶ added in v0.10.0
type AcquireSessionResult struct { Session *DatabaseSession Error error Warnings []string }
type Client ¶
type Client interface { Close() error ForeignSchemas() []string ConnectionMap() *steampipeconfig.ConnectionDataMap GetCurrentSearchPath(context.Context) ([]string, error) SetSessionSearchPath(ctx context.Context, newSearchPath ...string) error ContructSearchPath(ctx context.Context, requiredSearchPath []string, searchPathPrefix []string, currentSearchPath []string) ([]string, error) AcquireSession(context.Context) *AcquireSessionResult ExecuteSync(ctx context.Context, query string, disableSpinner bool) (*queryresult.SyncQueryResult, error) Execute(ctx context.Context, query string, disableSpinner bool) (res *queryresult.Result, err error) ExecuteSyncInSession(ctx context.Context, session *DatabaseSession, query string, disableSpinner bool) (*queryresult.SyncQueryResult, error) ExecuteInSession(ctx context.Context, session *DatabaseSession, query string, onComplete func(), disableSpinner bool) (res *queryresult.Result, err error) CacheOn(context.Context) error CacheOff(context.Context) error CacheClear(context.Context) error SetEnsureSessionDataFunc(EnsureSessionStateCallback) RefreshSessions(ctx context.Context) *AcquireSessionResult GetSchemaFromDB(context.Context, []string) (*schema.Metadata, error) // remote client will have empty implementation RefreshConnectionAndSearchPaths(context.Context) *steampipeconfig.RefreshConnectionResult LoadForeignSchemaNames(context.Context) error }
type DatabaseSession ¶ added in v0.10.0
type DatabaseSession struct { BackendPid uint32 `json:"backend_pid"` LifeCycle *utils.LifecycleTimer `json:"lifecycle"` UsedCount int `json:"used"` LastUsed time.Time `json:"last_used"` SearchPath []string `json:"-"` Initialized bool `json:"-"` // this gets rewritten, since the database/sql gives back a new instance everytime Connection *sql.Conn `json:"-"` }
DatabaseSession wraps over the raw database/sql.Conn and also allows for retaining useful instrumentation
func NewDBSession ¶ added in v0.10.0
func NewDBSession(backendPid uint32) *DatabaseSession
func (*DatabaseSession) Close ¶ added in v0.10.0
func (s *DatabaseSession) Close() error
func (*DatabaseSession) UpdateUsage ¶ added in v0.10.0
func (s *DatabaseSession) UpdateUsage()
UpdateUsage updates the UsedCount of the DatabaseSession and also the lastUsed time
type EnsureSessionStateCallback ¶ added in v0.8.3
type EnsureSessionStateCallback = func(context.Context, *DatabaseSession) (err error, warnings []string)
type InitResult ¶
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 WorkspaceResourceProvider ¶
type WorkspaceResourceProvider interface { ResolveQueryAndArgs(arg string) (string, modconfig.QueryProvider, 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 SetOnFileWatcherEventMessages(f func()) }
WorkspaceResourceProvider is an interface encapsulating workspace functionality - provided to avoid db needing a reference to Workspace