Documentation
¶
Index ¶
- Variables
- func ConfigInstance() interface{}
- func IsNotNil(input any) bool
- func JSONString(data interface{}) (string, error)
- func ListRawResults(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error)
- func ListTableRecords(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error)
- func MakeRawSQLQuery(ctx context.Context, connectionString, schema string, table string, ...) ([]map[string]any, error)
- func MakeSQLQuery(ctx context.Context, connectionString, schema string, table string, ...) ([]map[string]any, error)
- func Plugin(ctx context.Context) *plugin.Plugin
- func PluginTables(ctx context.Context, d *plugin.TableMapData) (map[string]*plugin.Table, error)
- func PostgresColTypeToSteampipeColType(ctx context.Context, col Column) proto.ColumnType
- func UnmarshalJSON(data []byte) (interface{}, error)
- type Cache
- type CacheEntry
- type CacheManager
- func (cm *CacheManager) GetCacheStats() map[string]int
- func (cm *CacheManager) GetCachedQueryResult(ctx context.Context, connectionString, query string) ([]map[string]any, bool)
- func (cm *CacheManager) GetCachedViews(ctx context.Context, connectionString, schema string) ([]View, bool)
- func (cm *CacheManager) InvalidateQueryCache()
- func (cm *CacheManager) InvalidateViewsCache(connectionString, schema string)
- func (cm *CacheManager) SetCachedQueryResult(ctx context.Context, connectionString, query string, result []map[string]any)
- func (cm *CacheManager) SetCachedViews(ctx context.Context, connectionString, schema string, views []View)
- type Column
- type ConnectionManager
- type PostgresConfig
- func (c PostgresConfig) GetConnectionString() (string, error)
- func (c PostgresConfig) GetPoolHealthCheckMinutes() int
- func (c PostgresConfig) GetPoolMaxConnIdleMinutes() int
- func (c PostgresConfig) GetPoolMaxConnLifetimeMinutes() int
- func (c PostgresConfig) GetPoolMaxConns() int32
- func (c PostgresConfig) GetPoolMinConns() int32
- func (c PostgresConfig) GetSchema() string
- func (c PostgresConfig) GetViewsToExpose() []string
- func (c PostgresConfig) String() string
- type View
Constants ¶
This section is empty.
Variables ¶
var ConfigSchema = map[string]*schema.Attribute{ "connection_string": {Type: schema.TypeString}, "schema": {Type: schema.TypeString}, "views_to_expose": {Type: schema.TypeList, Elem: &schema.Attribute{Type: schema.TypeString}}, "pool_max_conns": {Type: schema.TypeInt}, "pool_min_conns": {Type: schema.TypeInt}, "pool_max_conn_lifetime_minutes": {Type: schema.TypeInt}, "pool_max_conn_idle_minutes": {Type: schema.TypeInt}, "pool_health_check_minutes": {Type: schema.TypeInt}, }
Functions ¶
func ConfigInstance ¶
func ConfigInstance() interface{}
func JSONString ¶
JSONString takes a generic interface{} and returns it as a JSON string.
func ListRawResults ¶
func ListTableRecords ¶
func MakeRawSQLQuery ¶
func MakeRawSQLQuery(ctx context.Context, connectionString, schema string, table string, query string, config PostgresConfig) ([]map[string]any, error)
MakeRawSQLQuery sends a raw SQL query to a remote DB, and returns any results
func MakeSQLQuery ¶
func MakeSQLQuery(ctx context.Context, connectionString, schema string, table string, quals plugin.KeyColumnQualMap, config PostgresConfig) ([]map[string]any, error)
MakeSQLQuery composes a SQL query from a set of quals, sends it to a remote DB, and returns any results
func PluginTables ¶
func PostgresColTypeToSteampipeColType ¶
func PostgresColTypeToSteampipeColType(ctx context.Context, col Column) proto.ColumnType
func UnmarshalJSON ¶
UnmarshalJSON unmarshals the input byte slice into a generic interface{}.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache provides thread-safe caching with TTL
type CacheEntry ¶
CacheEntry represents a cached item with expiration
func (*CacheEntry) IsExpired ¶
func (ce *CacheEntry) IsExpired() bool
IsExpired checks if the cache entry has expired
type CacheManager ¶
type CacheManager struct {
// contains filtered or unexported fields
}
CacheManager manages different types of caches
func GetCacheManager ¶
func GetCacheManager() *CacheManager
GetCacheManager returns the singleton instance of CacheManager
func (*CacheManager) GetCacheStats ¶
func (cm *CacheManager) GetCacheStats() map[string]int
GetCacheStats returns statistics about all caches
func (*CacheManager) GetCachedQueryResult ¶
func (cm *CacheManager) GetCachedQueryResult(ctx context.Context, connectionString, query string) ([]map[string]any, bool)
GetCachedQueryResult retrieves cached query result
func (*CacheManager) GetCachedViews ¶
func (cm *CacheManager) GetCachedViews(ctx context.Context, connectionString, schema string) ([]View, bool)
GetCachedViews retrieves cached views for a schema
func (*CacheManager) InvalidateQueryCache ¶
func (cm *CacheManager) InvalidateQueryCache()
InvalidateQueryCache removes all cached query results
func (*CacheManager) InvalidateViewsCache ¶
func (cm *CacheManager) InvalidateViewsCache(connectionString, schema string)
InvalidateViewsCache removes cached views for a specific schema
func (*CacheManager) SetCachedQueryResult ¶
func (cm *CacheManager) SetCachedQueryResult(ctx context.Context, connectionString, query string, result []map[string]any)
SetCachedQueryResult stores query result in cache
func (*CacheManager) SetCachedViews ¶
func (cm *CacheManager) SetCachedViews(ctx context.Context, connectionString, schema string, views []View)
SetCachedViews stores views in cache
type ConnectionManager ¶
type ConnectionManager struct {
// contains filtered or unexported fields
}
ConnectionManager manages database connection pools for different connection strings
func GetConnectionManager ¶
func GetConnectionManager() *ConnectionManager
GetConnectionManager returns the singleton instance of ConnectionManager
func (*ConnectionManager) CloseAll ¶
func (cm *ConnectionManager) CloseAll()
CloseAll closes all connection pools
func (*ConnectionManager) GetPool ¶
func (cm *ConnectionManager) GetPool(ctx context.Context, connectionString string, postgresConfig PostgresConfig) (*pgxpool.Pool, error)
GetPool returns a connection pool for the given connection string Creates a new pool if one doesn't exist, otherwise returns the existing pool
func (*ConnectionManager) GetPoolStats ¶
func (cm *ConnectionManager) GetPoolStats() map[string]*pgxpool.Stat
GetPoolStats returns statistics for all pools (for monitoring/debugging)
type PostgresConfig ¶
type PostgresConfig struct {
ConnectionString *string `cty:"connection_string"`
Schema *string `cty:"schema"`
ViewsToExpose []string `cty:"views_to_expose"`
PoolMaxConns *int `cty:"pool_max_conns"`
PoolMinConns *int `cty:"pool_min_conns"`
PoolMaxConnLifetimeMinutes *int `cty:"pool_max_conn_lifetime_minutes"`
PoolMaxConnIdleMinutes *int `cty:"pool_max_conn_idle_minutes"`
PoolHealthCheckMinutes *int `cty:"pool_health_check_minutes"`
}
func GetConfig ¶
func GetConfig(connection *plugin.Connection) PostgresConfig
GetConfig :: retrieve and cast connection config from query data
func (PostgresConfig) GetConnectionString ¶
func (c PostgresConfig) GetConnectionString() (string, error)
func (PostgresConfig) GetPoolHealthCheckMinutes ¶
func (c PostgresConfig) GetPoolHealthCheckMinutes() int
GetPoolHealthCheckMinutes returns the health check interval in minutes, defaulting to 1 minute
func (PostgresConfig) GetPoolMaxConnIdleMinutes ¶
func (c PostgresConfig) GetPoolMaxConnIdleMinutes() int
GetPoolMaxConnIdleMinutes returns the maximum connection idle time in minutes, defaulting to 1 minute
func (PostgresConfig) GetPoolMaxConnLifetimeMinutes ¶
func (c PostgresConfig) GetPoolMaxConnLifetimeMinutes() int
GetPoolMaxConnLifetimeMinutes returns the maximum connection lifetime in minutes, defaulting to 15 minutes
func (PostgresConfig) GetPoolMaxConns ¶
func (c PostgresConfig) GetPoolMaxConns() int32
GetPoolMaxConns returns the maximum number of connections in the pool, defaulting to 2 for conservative resource usage
func (PostgresConfig) GetPoolMinConns ¶
func (c PostgresConfig) GetPoolMinConns() int32
GetPoolMinConns returns the minimum number of connections to maintain in the pool, defaulting to 0 (on-demand only)
func (PostgresConfig) GetSchema ¶
func (c PostgresConfig) GetSchema() string
GetSchema returns the schema that was configured in the .spc file, if available, and "public" otherwise
func (PostgresConfig) GetViewsToExpose ¶
func (c PostgresConfig) GetViewsToExpose() []string
GetViewsToExpose returns the slice of view patterns that was configured in the .spc file, if set, and ["*"] otherwise (which will expose every view)
func (PostgresConfig) String ¶
func (c PostgresConfig) String() string
type View ¶
func GetViewsForDBSchema ¶
func GetViewsFromPooledConnection ¶
func GetViewsFromPooledConnection(ctx context.Context, conn *pgx.Conn, schema string) ([]View, error)
GetViewsFromPooledConnection gets views using a pooled pgx connection to prevent connection exhaustion OPTIMIZED: Uses a single JOIN query to eliminate N+1 query performance problem