db_local

package
v0.9.0-tx-hang.debug.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
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

func EnsureDbAndStartService(invoker constants.Invoker) error

EnsureDbAndStartService ensures db is installed and starts service if necessary

func FindAllSteampipePostgresInstances

func FindAllSteampipePostgresInstances() ([]*psutils.Process, error)

func GetCountOfConnectedClients

func GetCountOfConnectedClients() (int, error)

GetCountOfConnectedClients returns the number of clients currently connected to the service

func GetLocalClient

func GetLocalClient(invoker constants.Invoker) (db_common.Client, error)

GetLocalClient starts service if needed and creates a new LocalDbClient

func IsInstalled

func IsInstalled() bool

IsInstalled checks and reports whether the embedded database is installed and setup

func PidExists

func PidExists(targetPid int) (bool, error)

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 PrepareDb

func PrepareDb(spinner *spinner.Spinner) error

PrepareDb updates the FDW if needed, and inits the database if required

func RefreshConnectionAndSearchPaths

func RefreshConnectionAndSearchPaths(invoker constants.Invoker) error

RefreshConnectionAndSearchPaths creates a local client and refreshed connections and search paths

func ShutdownService

func ShutdownService(invoker constants.Invoker)

ShutdownService stops the database instance if the given `invoker` matches

func SslMode

func SslMode() string

func SslStatus

func SslStatus() string

func TrimLogs

func TrimLogs()

Types

type LocalDbClient

type LocalDbClient struct {
	// contains filtered or unexported fields
}

LocalDbClient wraps over DbClient

func NewLocalClient

func NewLocalClient(invoker constants.Invoker) (*LocalDbClient, error)

NewLocalClient ensures that the database instance is running and returns a `Client` to interact with it

func (*LocalDbClient) CacheClear

func (c *LocalDbClient) CacheClear() error

CacheClear implements Client

func (*LocalDbClient) CacheOff

func (c *LocalDbClient) CacheOff() error

CacheOff implements Client

func (*LocalDbClient) CacheOn

func (c *LocalDbClient) CacheOn() error

CacheOn implements Client

func (*LocalDbClient) Close

func (c *LocalDbClient) Close() error

Close implements Client close the connection to the database and shuts down the backend

func (*LocalDbClient) ConnectionMap

func (c *LocalDbClient) ConnectionMap() *steampipeconfig.ConnectionDataMap

func (*LocalDbClient) Execute

func (c *LocalDbClient) Execute(ctx context.Context, query string, disableSpinner bool) (res *queryresult.Result, err error)

Execute implements Client

func (*LocalDbClient) ExecuteSync

func (c *LocalDbClient) ExecuteSync(ctx context.Context, query string, disableSpinner bool) (*queryresult.SyncQueryResult, error)

ExecuteSync implements Client

func (*LocalDbClient) GetCurrentSearchPath

func (c *LocalDbClient) GetCurrentSearchPath() ([]string, error)

GetCurrentSearchPath implements Client

func (*LocalDbClient) LoadSchema

func (c *LocalDbClient) LoadSchema()

LoadSchema implements Client

func (*LocalDbClient) RefreshConnectionAndSearchPaths

func (c *LocalDbClient) RefreshConnectionAndSearchPaths() *db_common.RefreshConnectionResult

func (*LocalDbClient) SchemaMetadata

func (c *LocalDbClient) SchemaMetadata() *schema.Metadata

SchemaMetadata implements Client

func (*LocalDbClient) SetEnsureSessionStateFunc

func (c *LocalDbClient) SetEnsureSessionStateFunc(f db_common.EnsureSessionStateCallback)

EnsureSessionState implements Client

func (*LocalDbClient) SetSessionSearchPath

func (c *LocalDbClient) SetSessionSearchPath(currentSearchPath ...string) error

SetSessionSearchPath implements Client

type Passwords

type Passwords struct {
	Root      string
	Steampipe string
}

Passwords :: structure for working with DB passwords

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

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
	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 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 + 10
	// ServiceNotRunning indicates service was not running
	ServiceNotRunning
	// ServiceStopFailed indicates service could not be stopped
	ServiceStopFailed
	// ServiceStopTimedOut indicates service stop attempt timed out
	ServiceStopTimedOut
)

func StopDB

func StopDB(force bool, invoker constants.Invoker, spinner *spinner.Spinner) (StopStatus, error)

StopDB searches for and stops the running instance. Does nothing if an instance was not found

Jump to

Keyboard shortcuts

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