db

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: MPL-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// InvokerService :: Invoker - when invoked by `service start`
	InvokerService Invoker = "service"
	// InvokerQuery :: Invoker - when invoked by `query`
	InvokerQuery = "query"
	// InvokerInstaller :: Invoker - when invoked by the `installer`
	InvokerInstaller = "installer"
	// InvokerPlugin :: Invoker - when invoked by the `pluginmanager`
	InvokerPlugin = "plugin"
)

Variables

This section is empty.

Functions

func EnsureDBInstalled

func EnsureDBInstalled()

EnsureDBInstalled makes sure that the embedded pg database is installed and running

func IsInstalled

func IsInstalled() bool

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

func PgEscapeName

func PgEscapeName(name string) string

func PgEscapeString

func PgEscapeString(str string) string

func RefreshConnections added in v0.2.0

func RefreshConnections(client *Client) error

func Shutdown added in v0.2.0

func Shutdown(client *Client, invoker Invoker)

func StartService

func StartService(invoker Invoker)

StartService :: invokes `steampipe service start --listen local --refresh=false --invoker query`

func TrimLogs added in v0.0.17

func TrimLogs()

Types

type Client

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

Client wraps over `sql.DB` and gives an interface to the database

func GetClient

func GetClient(autoRefreshConnections bool) (*Client, error)

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

func (*Client) ConnectionMap

func (c *Client) ConnectionMap() *connection_config.ConnectionMap

ConnectionMap :: returns the latest connection map

func (*Client) ExecuteSync

func (c *Client) ExecuteSync(query string) (*SyncQueryResult, error)

ExecuteSync :: execute a query against this client and wait for the result

func (*Client) SchemaMetadata

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

SchemaMetadata :: returns the latest schema metadata

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) InteractiveQuery

func (c *InteractiveClient) InteractiveQuery(resultsStreamer *ResultStreamer, onCompleteCallback func())

InteractiveQuery :: start an interactive prompt and return

type Invoker

type Invoker string

Invoker :: pseudoEnum for what starts the service

func (Invoker) IsValid

func (slt Invoker) IsValid() error

IsValid :: validator for Invoker known values

type Passwords added in v0.0.16

type Passwords struct {
	Root      string
	Steampipe string
}

Passwords :: structure for working with DB passwords

type QueryResult

type QueryResult struct {
	RowChan   *chan []interface{}
	ErrorChan *chan error
	ColTypes  []*sql.ColumnType
	Duration  chan time.Duration
}

func (QueryResult) Close added in v0.2.1

func (r QueryResult) Close()

close the channels

func (QueryResult) StreamError added in v0.2.1

func (r QueryResult) StreamError(err error)

func (QueryResult) StreamRow added in v0.2.1

func (r QueryResult) StreamRow(rowResult []interface{})

type ResultStreamer

type ResultStreamer struct {
	Results chan *QueryResult
	// contains filtered or unexported fields
}

func ExecuteQuery

func ExecuteQuery(queryString string) (*ResultStreamer, error)

ExecuteQuery :: entry point for executing ad-hoc queries from outside the package

func (*ResultStreamer) Done

func (q *ResultStreamer) Done()

Done :: signals that the next QueryResult has been processed

func (*ResultStreamer) Wait

func (q *ResultStreamer) Wait()

Wait :: waits for the next QueryResult to get processed

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

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) (StartResult, 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
)

func StopDB

func StopDB(force bool) (StopStatus, error)

StopDB :: search and stop the running instance. Does nothing if an instance was not found

type SyncQueryResult

type SyncQueryResult struct {
	Rows     []interface{}
	ColTypes []*sql.ColumnType
	Duration time.Duration
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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