Documentation
¶
Index ¶
- Constants
- func CreateMetadataTables(workspaceResources *modconfig.WorkspaceResourceMaps, client *Client) error
- func EnsureDBInstalled()
- func EnsureDbAndStartService(invoker Invoker, refreshConnections bool) error
- func ExecuteQuery(ctx context.Context, queryString string, client *Client) (*queryresult.ResultStreamer, error)
- func FindAllSteampipePostgresInstances() ([]*psutils.Process, error)
- func GetCountOfConnectedClients() (int, error)
- func IsInstalled() bool
- func PgEscapeName(name string) string
- func PgEscapeString(str string) string
- func PidExists(targetPid int) (bool, error)
- func RunInteractivePrompt(initChan *chan *QueryInitData) (*queryresult.ResultStreamer, error)
- func Shutdown(client *Client, invoker Invoker)
- func SslMode() string
- func SslStatus() string
- func StartImplicitService(invoker Invoker, refreshConnections bool) error
- func TrimLogs()
- func UpdateMetadataTables(workspaceResources *modconfig.WorkspaceResourceMaps, client *Client) error
- type AfterPromptCloseAction
- type Client
- func (c *Client) Close() error
- func (c *Client) ConnectionMap() *steampipeconfig.ConnectionMap
- func (c *Client) Execute(ctx context.Context, query string, disableSpinner bool) (res *queryresult.Result, err error)
- func (c *Client) ExecuteSync(ctx context.Context, query string, disableSpinner bool) (*queryresult.SyncQueryResult, error)
- func (c *Client) GetCurrentSearchPath() ([]string, error)
- func (c *Client) RefreshConnectionAndSearchPaths() *RefreshConnectionResult
- func (c *Client) RefreshConnections() *RefreshConnectionResult
- func (c *Client) SchemaMetadata() *schema.Metadata
- func (c *Client) SetClientSearchPath() error
- func (c *Client) SetServiceSearchPath() error
- type InitResult
- type InteractiveClient
- type Invoker
- type NamedQueryProvider
- type Passwords
- type QueryInitData
- type RefreshConnectionResult
- type RunningDBInstanceInfo
- type StartListenType
- type StartResult
- type StopStatus
- type WorkspaceResourceProvider
Constants ¶
const ( // InvokerService :: Invoker - when invoked by `service start` InvokerService Invoker = "service" // InvokerQuery :: Invoker - when invoked by `query` InvokerQuery = "query" // InvokerCheck :: Invoker - when invoked by `check` InvokerCheck = "check" // InvokerInstaller :: Invoker - when invoked by the `installer` InvokerInstaller = "installer" // InvokerPlugin :: Invoker - when invoked by the `pluginmanager` InvokerPlugin = "plugin" // InvokerReport :: Invoker - when invoked by `report` InvokerReport = "report" )
const ServiceExecutableRelativeLocation = "/db/12.1.0/postgres/bin/postgres"
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 ¶ added in v0.5.0
func CreateMetadataTables(workspaceResources *modconfig.WorkspaceResourceMaps, client *Client) error
func EnsureDBInstalled ¶
func EnsureDBInstalled()
EnsureDBInstalled makes sure that the embedded pg database is installed and running
func EnsureDbAndStartService ¶ added in v0.5.0
EnsureDbAndStartService :: ensure db is installed and start service if necessary
func ExecuteQuery ¶
func ExecuteQuery(ctx context.Context, queryString string, client *Client) (*queryresult.ResultStreamer, error)
ExecuteQuery :: execute a single query. If shutdownAfterCompletion is true, shutdown the client after completion
func FindAllSteampipePostgresInstances ¶ added in v0.7.0
func GetCountOfConnectedClients ¶ added in v0.7.0
func IsInstalled ¶
func IsInstalled() bool
IsInstalled :: checks and reports whether the embedded database is installed and setup IsInstalled checks and reports whether the embedded database is installed and setup
func PgEscapeName ¶
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 PidExists ¶ added in v0.7.0
PidExists scans through the list of PIDs in the system and checks for the `targetPID`.
PidExists uses iteration, instead of signalling, since we have observed that signalling does not always work reliably when the destination of the signal is a child of the source of the signal - which may be the case then starting implicit services
func RunInteractivePrompt ¶ added in v0.4.0
func RunInteractivePrompt(initChan *chan *QueryInitData) (*queryresult.ResultStreamer, error)
RunInteractivePrompt :: start the interactive query prompt
func Shutdown ¶ added in v0.2.0
Shutdown :: closes the client connection and stops the database instance if the given `invoker` matches
func StartImplicitService ¶ added in v0.7.0
StartImplicitService starts up the service in an implicit mode
func UpdateMetadataTables ¶ added in v0.5.0
func UpdateMetadataTables(workspaceResources *modconfig.WorkspaceResourceMaps, client *Client) error
Types ¶
type AfterPromptCloseAction ¶ added in v0.7.0
type AfterPromptCloseAction int
const ( AfterPromptCloseExit AfterPromptCloseAction = iota AfterPromptCloseRestart )
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps over `sql.DB` and gives an interface to the database
func NewClient ¶ added in v0.4.0
NewClient ensures that the database instance is running and returns a `Client` to interact with it
func (*Client) Close ¶ added in v0.4.0
Close closes the connection to the database and shuts down the backend
func (*Client) ConnectionMap ¶
func (c *Client) ConnectionMap() *steampipeconfig.ConnectionMap
ConnectionMap :: returns the latest connection map
func (*Client) Execute ¶ added in v0.7.0
func (c *Client) Execute(ctx context.Context, query string, disableSpinner bool) (res *queryresult.Result, err error)
Execute executes the provided query against the Database in the given context.Context Bear in mind that whenever ExecuteQuery is called, the returned `queryresult.Result` MUST be fully read - otherwise the transaction is left open, which will block the connection and will prevent subsequent communications with the service
func (*Client) ExecuteSync ¶
func (c *Client) ExecuteSync(ctx context.Context, query string, disableSpinner bool) (*queryresult.SyncQueryResult, error)
ExecuteSync :: execute a query against this client and wait for the result
func (*Client) GetCurrentSearchPath ¶ added in v0.4.0
query the database to get the current search path
func (*Client) RefreshConnectionAndSearchPaths ¶ added in v0.7.0
func (c *Client) RefreshConnectionAndSearchPaths() *RefreshConnectionResult
func (*Client) RefreshConnections ¶ added in v0.3.5
func (c *Client) RefreshConnections() *RefreshConnectionResult
RefreshConnections :: load required connections from config and update the database schema and search path to reflect the required connections return whether any changes have been made
func (*Client) SchemaMetadata ¶
SchemaMetadata :: returns the latest schema metadata
func (*Client) SetClientSearchPath ¶ added in v0.4.0
SetClientSearchPath :: set the search path for this client if either a search-path or search-path-prefix is set in config, set the search path (otherwise fall back to service search path)
func (*Client) SetServiceSearchPath ¶ added in v0.5.0
SetServiceSearchPath :: set the search path for the db service (by setting it on the steampipe user)
type InitResult ¶ added in v0.7.0
func (*InitResult) AddMessage ¶ added in v0.7.0
func (r *InitResult) AddMessage(message string)
func (*InitResult) AddWarnings ¶ added in v0.7.0
func (r *InitResult) AddWarnings(warnings []string)
func (*InitResult) DisplayMessages ¶ added in v0.7.0
func (r *InitResult) DisplayMessages()
func (*InitResult) HasMessages ¶ added in v0.7.0
func (r *InitResult) HasMessages() bool
type InteractiveClient ¶
type InteractiveClient struct {
// contains filtered or unexported fields
}
InteractiveClient :: wrapper over *Client and *prompt.Prompt along to facilitate interactive query prompt
func (*InteractiveClient) ClosePrompt ¶ added in v0.7.0
func (c *InteractiveClient) ClosePrompt(afterClose AfterPromptCloseAction)
ClosePrompt cancels the running prompt, setting the action to take after close
func (*InteractiveClient) InteractiveQuery ¶
func (c *InteractiveClient) InteractiveQuery()
InteractiveQuery :: start an interactive prompt and return
type NamedQueryProvider ¶ added in v0.5.0
type NamedQueryProvider interface { GetNamedQueryMap() map[string]*modconfig.Query GetNamedQuery(queryName string) (*modconfig.Query, bool) }
NamedQueryProvider is an interface encapsulating named query searching capability - provided to avoid db needing a reference to workspace
type QueryInitData ¶ added in v0.7.0
type QueryInitData struct { Queries []string Workspace WorkspaceResourceProvider Client *Client Result *InitResult }
func NewInitData ¶ added in v0.7.0
func NewInitData() *QueryInitData
type RefreshConnectionResult ¶ added in v0.7.0
RefreshConnectionResult is a structure used to contain the result of either a RefreshConnections or a NewClient operation
func (*RefreshConnectionResult) ShowWarnings ¶ added in v0.7.0
func (r *RefreshConnectionResult) ShowWarnings()
type RunningDBInstanceInfo ¶
type RunningDBInstanceInfo struct { Pid int Port int Listen []string ListenType StartListenType Invoker Invoker Password string User string Database string }
RunningDBInstanceInfo :: contains data about the running process and it's credentials
func GetStatus ¶
func GetStatus() (*RunningDBInstanceInfo, error)
GetStatus :: check that the db instance is running and returns it's details
func (*RunningDBInstanceInfo) Save ¶ added in v0.7.0
func (r *RunningDBInstanceInfo) Save() error
type StartListenType ¶
type StartListenType string
StartListenType :: pseudoEnum of network binding for postgres
const ( // ListenTypeNetwork :: StartListenType - bind to all known interfaces ListenTypeNetwork StartListenType = "network" // ListenTypeLocal :: StartListenType - bind to localhost only ListenTypeLocal = "local" )
func (StartListenType) IsValid ¶
func (slt StartListenType) IsValid() error
IsValid :: validator for StartListenType known values
type StartResult ¶
type StartResult int
StartResult :: pseudoEnum for outcomes of Start
const ( // ServiceStarted :: StartResult - Service was started ServiceStarted StartResult = iota // ServiceAlreadyRunning :: StartResult - Service was already running ServiceAlreadyRunning // ServiceFailedToStart :: StartResult - Could not start service ServiceFailedToStart )
func StartDB ¶
func StartDB(port int, listen StartListenType, invoker Invoker, refreshConnections bool) (startResult StartResult, err error)
StartDB :: start the database is not already running
type StopStatus ¶
type StopStatus int
StopStatus :: pseudoEnum for service stop result
const ( // ServiceStopped :: StopStatus - service was stopped ServiceStopped StopStatus = iota // ServiceNotRunning :: StopStatus - service was not running ServiceNotRunning // ServiceStopFailed :: StopStatus - service could not be stopped ServiceStopFailed // ServiceStopTimedOut :: StopStatus - service stop attempt timed out ServiceStopTimedOut )
type WorkspaceResourceProvider ¶ added in v0.6.1
type WorkspaceResourceProvider interface { GetQueryMap() map[string]*modconfig.Query GetQuery(queryName string) (*modconfig.Query, bool) GetControlMap() map[string]*modconfig.Control GetControl(controlName string) (*modconfig.Control, bool) SetupWatcher(client *Client) error }
WorkspaceResourceProvider :: interface encapsulating named query searching capability - provided to avoid db needing a reference to workspace
Source Files
¶
- client.go
- client_connections.go
- client_execute.go
- client_search_path.go
- functions.go
- init_data.go
- init_result.go
- install.go
- interactive_client.go
- interactive_client_cancel.go
- interactive_client_init.go
- interactive_helpers.go
- locations.go
- logs.go
- metadata_tables.go
- named_query_provider.go
- password.go
- pid_exists.go
- postgres.go
- query.go
- refresh_connections_result.go
- rows.go
- running_info.go
- schema.go
- ssl.go
- start_database.go
- status.go
- stop_database.go
- workspace_resource_provider.go
- writeCounter.go