Documentation ¶
Index ¶
- Constants
- func EnsureDBInstalled() (err error)
- func EnsureDbAndStartService(invoker constants.Invoker) error
- func FindAllSteampipePostgresInstances() ([]*psutils.Process, error)
- func GetCountOfConnectedClients() (int, error)
- func IsInstalled() bool
- func PidExists(targetPid int) (bool, error)
- func PrepareDb(spinner *spinner.Spinner) error
- func RefreshConnectionAndSearchPaths(invoker constants.Invoker) error
- func ShutdownService(invoker constants.Invoker)
- func SslMode() string
- func SslStatus() string
- func TrimLogs()
- type LocalClient
- func (c *LocalClient) CacheClear() error
- func (c *LocalClient) CacheOff() error
- func (c *LocalClient) CacheOn() error
- func (c *LocalClient) Close() error
- func (c *LocalClient) ConnectionMap() *steampipeconfig.ConnectionMap
- func (c *LocalClient) Execute(ctx context.Context, query string, disableSpinner bool) (res *queryresult.Result, err error)
- func (c *LocalClient) ExecuteSync(ctx context.Context, query string, disableSpinner bool) (*queryresult.SyncQueryResult, error)
- func (c *LocalClient) GetCurrentSearchPath() ([]string, error)
- func (c *LocalClient) LoadSchema()
- func (c *LocalClient) RefreshConnectionAndSearchPaths() *db_common.RefreshConnectionResult
- func (c *LocalClient) RefreshConnections() *db_common.RefreshConnectionResult
- func (c *LocalClient) SchemaMetadata() *schema.Metadata
- func (c *LocalClient) SetClientSearchPath() error
- func (c *LocalClient) SetEnsureSessionDataFunc(f db_common.EnsureSessionStateCallback)
- func (c *LocalClient) SetServiceSearchPath() error
- type NamedQueryProvider
- type Passwords
- type RunningDBInstanceInfo
- type StartListenType
- type StartResult
- type StopStatus
Constants ¶
const ServiceExecutableRelativeLocation = "/db/12.1.0/postgres/bin/postgres"
Variables ¶
This section is empty.
Functions ¶
func EnsureDBInstalled ¶
func EnsureDBInstalled() (err error)
EnsureDBInstalled makes sure that the embedded pg database is installed and running
func EnsureDbAndStartService ¶
EnsureDbAndStartService :: ensure db is installed and start service if necessary
func GetCountOfConnectedClients ¶
GetCountOfConnectedClients returns the number of clients currently connected to the service
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 PidExists ¶
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 RefreshConnectionAndSearchPaths ¶
RefreshConnectionAndSearchPaths creates a local client and refreshed connections and search paths
func ShutdownService ¶
ShutdownService stops the database instance if the given `invoker` matches
Types ¶
type LocalClient ¶
type LocalClient struct {
// contains filtered or unexported fields
}
LocalClient wraps over `sql.DB` and gives an interface to the database
func NewLocalClient ¶
func NewLocalClient(invoker constants.Invoker) (*LocalClient, error)
NewLocalClient ensures that the database instance is running and returns a `Client` to interact with it
func (*LocalClient) CacheClear ¶
func (c *LocalClient) CacheClear() error
func (*LocalClient) CacheOff ¶
func (c *LocalClient) CacheOff() error
func (*LocalClient) CacheOn ¶
func (c *LocalClient) CacheOn() error
func (*LocalClient) Close ¶
func (c *LocalClient) Close() error
Close closes the connection to the database and shuts down the backend
func (*LocalClient) ConnectionMap ¶
func (c *LocalClient) ConnectionMap() *steampipeconfig.ConnectionMap
ConnectionMap returns the latest connection map
func (*LocalClient) Execute ¶
func (c *LocalClient) Execute(ctx context.Context, query string, disableSpinner bool) (res *queryresult.Result, err error)
Execute implements DbClient execute 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 (*LocalClient) ExecuteSync ¶
func (c *LocalClient) ExecuteSync(ctx context.Context, query string, disableSpinner bool) (*queryresult.SyncQueryResult, error)
ExecuteSync implements DbClient execute a query against this client and wait for the result
func (*LocalClient) GetCurrentSearchPath ¶
func (c *LocalClient) GetCurrentSearchPath() ([]string, error)
GetCurrentSearchPath implements DbClient query the database to get the current search path
func (*LocalClient) LoadSchema ¶
func (c *LocalClient) LoadSchema()
LoadSchema retrieves both the raw query result and a sanitised version in list form todo share this between local and remote client - make a function not a method??
func (*LocalClient) RefreshConnectionAndSearchPaths ¶
func (c *LocalClient) RefreshConnectionAndSearchPaths() *db_common.RefreshConnectionResult
func (*LocalClient) RefreshConnections ¶
func (c *LocalClient) RefreshConnections() *db_common.RefreshConnectionResult
RefreshConnections loads 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 (*LocalClient) SchemaMetadata ¶
func (c *LocalClient) SchemaMetadata() *schema.Metadata
SchemaMetadata returns the latest schema metadata
func (*LocalClient) SetClientSearchPath ¶
func (c *LocalClient) SetClientSearchPath() error
SetClientSearchPath implements DbClient sets 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 (*LocalClient) SetEnsureSessionDataFunc ¶ added in v0.8.3
func (c *LocalClient) SetEnsureSessionDataFunc(f db_common.EnsureSessionStateCallback)
SetEnsureSessionDataFunc sets the callback function which setups the session data - prepared statements and introspection tables this will be called when there is a client error/timeout
func (*LocalClient) SetServiceSearchPath ¶
func (c *LocalClient) SetServiceSearchPath() error
SetServiceSearchPath sets the search path for the db service (by setting it on the steampipe user)
type NamedQueryProvider ¶
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 RunningDBInstanceInfo ¶
type RunningDBInstanceInfo struct { Pid int Port int Listen []string ListenType StartListenType Invoker constants.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 ¶
func (r *RunningDBInstanceInfo) Save() error
func (*RunningDBInstanceInfo) String ¶ added in v0.8.3
func (r *RunningDBInstanceInfo) String() string
type StartListenType ¶
type StartListenType string
StartListenType is a 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 is a validator for StartListenType known values
type StartResult ¶
type StartResult int
StartResult :: pseudoEnum for outcomes of Start
const ( // ServiceStarted :: StartResult - Service was started // start from 10 to prevent confusion with int zero-value ServiceStarted StartResult = iota + 1 // ServiceAlreadyRunning :: StartResult - Service was already running ServiceAlreadyRunning // ServiceFailedToStart :: StartResult - Could not start service ServiceFailedToStart )
func StartDB ¶
func StartDB(port int, listen StartListenType, invoker constants.Invoker) (startResult StartResult, err error)
StartDB starts the database if not already running
type StopStatus ¶
type StopStatus int
StopStatus :: pseudoEnum for service stop result
const ( // ServiceStopped indicates service was stopped. // start from 10 to prevent confusion with int zero-value ServiceStopped StopStatus = iota + 1 // ServiceNotRunning indicates service was not running ServiceNotRunning // ServiceStopFailed indicates service could not be stopped ServiceStopFailed // ServiceStopTimedOut indicates service stop attempt timed out ServiceStopTimedOut )
Source Files ¶
- functions.go
- install.go
- local_client.go
- local_client_cache_control.go
- local_client_connections.go
- local_client_execute.go
- local_client_search_path.go
- locations.go
- logs.go
- named_query_provider.go
- password.go
- pid_exists.go
- query.go
- refresh_connections.go
- rows.go
- running_info.go
- schema.go
- ssl.go
- start_database.go
- status.go
- stop_database.go
- writeCounter.go