Documentation
¶
Index ¶
- func ColumnQualValue(qv *proto.QualValue, column *Column) interface{}
- func DiagsToError(prefix string, diags hcl.Diagnostics) error
- func GetMatrixItem(ctx context.Context) map[string]interface{}
- func Logger(ctx context.Context) hclog.Logger
- func RetryHydrate(ctx context.Context, d *QueryData, hydrateData *HydrateData, ...) (interface{}, error)
- func Serve(opts *ServeOpts)
- func ToError(val interface{}) error
- type Column
- type ConcurrencyManager
- type Connection
- type ConnectionConfigInstanceFunc
- type ConnectionConfigSchema
- type DefaultConcurrencyConfig
- type ErrorPredicate
- type GetConfig
- type HydrateCall
- type HydrateConfig
- type HydrateData
- type HydrateDependencies
- type HydrateFunc
- type KeyColumnSet
- type ListConfig
- type MatrixItemFunc
- type Plugin
- func (p *Plugin) Execute(req *proto.ExecuteRequest, stream proto.WrapperPlugin_ExecuteServer) (err error)
- func (p *Plugin) GetSchema() (map[string]*proto.TableSchema, error)
- func (p *Plugin) Initialise()
- func (p *Plugin) SetConnectionConfig(connectionName, connectionConfigString string) (err error)
- func (p *Plugin) Validate() string
- type PluginFunc
- type QueryData
- type RetryConfig
- type RowData
- type ServeOpts
- type Table
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ColumnQualValue ¶ added in v0.2.0
ColumnQualValue converts a qual value into the underlying value - based on out knowledge of the column type which the qual is applying to
func DiagsToError ¶ added in v0.2.0
func DiagsToError(prefix string, diags hcl.Diagnostics) error
DiagsToError converts hcl diags into an error
func GetMatrixItem ¶ added in v0.2.0
func RetryHydrate ¶ added in v0.2.8
func RetryHydrate(ctx context.Context, d *QueryData, hydrateData *HydrateData, hydrateFunc HydrateFunc, retryConfig *RetryConfig) (interface{}, error)
RetryHydrate function invokes the hydrate function with retryable errors and retries the function until the maximum attemptes before throwing error
Types ¶
type Column ¶
type Column struct {
// column name
Name string
// column type
Type proto.ColumnType
// column description
Description string
// explicitly specify the function which populates this data
// - this is only needed if any of the default hydrate functions wil NOT return this column
Hydrate HydrateFunc
// the default column value
Default interface{}
// a list of transforms to generate the column value
Transform *transform.ColumnTransforms
// contains filtered or unexported fields
}
Column contains column data, in a format compatible with proto ColumnDefinition
type ConcurrencyManager ¶ added in v0.1.1
type ConcurrencyManager struct {
// contains filtered or unexported fields
}
ConcurrencyManager struct ensures that hydrate functions stay within concurrency limits
func (*ConcurrencyManager) Close ¶ added in v0.2.0
func (c *ConcurrencyManager) Close()
Close executs when the query is complete and dumps out the concurrency stats
func (*ConcurrencyManager) DisplayConcurrencyStats ¶ added in v0.2.0
func (c *ConcurrencyManager) DisplayConcurrencyStats()
DisplayConcurrencyStats displays the the summary of all the concurrent hydrate calls
func (*ConcurrencyManager) Finished ¶ added in v0.1.1
func (c *ConcurrencyManager) Finished(name string)
Finished decrements the counter for the named function
func (*ConcurrencyManager) StartIfAllowed ¶ added in v0.1.1
func (c *ConcurrencyManager) StartIfAllowed(name string, maxCallConcurrency int) (res bool)
StartIfAllowed checks whether the named hydrate call is permitted to start based on the number of running instances of that call, and the total calls in progress
type Connection ¶ added in v0.2.0
type Connection struct {
Name string
// the connection config
// NOTE: we always pass and store connection config BY VALUE
Config interface{}
}
type ConnectionConfigInstanceFunc ¶ added in v0.2.0
type ConnectionConfigInstanceFunc func() interface{}
type ConnectionConfigSchema ¶ added in v0.2.0
type ConnectionConfigSchema struct {
Schema map[string]*schema.Attribute
// function which returns an instance of a connection config struct
NewInstance ConnectionConfigInstanceFunc
}
ConnectionConfigSchema struct is used to define the connection config schema and store the config for each plugin connection
func NewConnectionConfigSchema ¶ added in v0.2.0
func NewConnectionConfigSchema() *ConnectionConfigSchema
func (*ConnectionConfigSchema) Parse ¶ added in v0.2.0
func (c *ConnectionConfigSchema) Parse(configString string) (config interface{}, err error)
Parse function parses the hcl string into a connection config struct. The schema and the struct to parse into are provided by the plugin
func (*ConnectionConfigSchema) Validate ¶ added in v0.2.0
func (c *ConnectionConfigSchema) Validate() []string
Validate validates the connection config
type DefaultConcurrencyConfig ¶ added in v0.2.0
type DefaultConcurrencyConfig struct {
// max number of ALL hydrate calls in progress
TotalMaxConcurrency int
DefaultMaxConcurrency int
}
DefaultConcurrencyConfig contains plugin level config to define default hydrate concurrency - this is used if no HydrateConfig is specified for a specific call
type ErrorPredicate ¶
type GetConfig ¶
type GetConfig struct {
// key or keys which are used to uniquely identify rows - used to determine whether a query is a 'get' call
KeyColumns *KeyColumnSet
ItemFromKey HydrateFunc
// the hydrate function which is called first when performing a 'get' call.
// if this returns 'not found', no further hydrate functions are called
Hydrate HydrateFunc
// a function which will return whenther to ignore a given error
ShouldIgnoreError ErrorPredicate
RetryConfig *RetryConfig
}
type HydrateCall ¶
type HydrateCall struct {
Func HydrateFunc
// the dependencies expressed using function name
Depends []string
Config *HydrateConfig
}
HydrateCall struct encapsulates a hydrate call, its config and dependencies
func (HydrateCall) CanStart ¶
func (h HydrateCall) CanStart(rowData *RowData, name string, concurrencyManager *ConcurrencyManager) bool
func (*HydrateCall) Start ¶ added in v0.1.1
func (h *HydrateCall) Start(ctx context.Context, r *RowData, hydrateFuncName string, concurrencyManager *ConcurrencyManager)
Start starts a hydrate call
type HydrateConfig ¶ added in v0.1.1
type HydrateConfig struct {
Func HydrateFunc
MaxConcurrency int
RetryConfig *RetryConfig
ShouldIgnoreError ErrorPredicate
Depends []HydrateFunc
}
HydrateConfig defines the hydrate function configurations, Name, Maximum number of concurrent calls to be allowed, dependencies
type HydrateData ¶
type HydrateData struct {
// if there was a parent-child list call, store the parent list item
ParentItem interface{}
Item interface{}
HydrateResults map[string]interface{}
}
HydrateData contains the input data passed to every hydrate function
type HydrateDependencies ¶
type HydrateDependencies struct {
Func HydrateFunc
Depends []HydrateFunc
}
HydrateDependencies defines the hydrate function dependencies - other hydrate functions which must be run first Deprecated: used HydrateConfig
type HydrateFunc ¶
type HydrateFunc func(context.Context, *QueryData, *HydrateData) (interface{}, error)
HydrateFunc is a function which retrieves some or all row data for a single row item.
func WrapHydrate ¶ added in v0.2.8
func WrapHydrate(hydrateFunc HydrateFunc, shouldIgnoreError ErrorPredicate) HydrateFunc
WrapHydrate is a higher order function which returns a HydrateFunc which handles Ignorable errors
type KeyColumnSet ¶
KeyColumnSet is a set of columns which form the key of a table (i.e. may be used to get a single item) may specify: - a Single column - a set of columns which together All form the key - a set of columns Any of which which form the key
func AllColumns ¶
func AllColumns(columns []string) *KeyColumnSet
func AnyColumn ¶
func AnyColumn(columns []string) *KeyColumnSet
func SingleColumn ¶
func SingleColumn(column string) *KeyColumnSet
func (*KeyColumnSet) ToString ¶
func (k *KeyColumnSet) ToString() string
type ListConfig ¶
type ListConfig struct {
KeyColumns *KeyColumnSet
// the list function, this should stream the list results back using the QueryData object, and return nil
Hydrate HydrateFunc
// the parent list function - if we list items with a parent-child relationship, this will list the parent items
ParentHydrate HydrateFunc
ShouldIgnoreError ErrorPredicate
RetryConfig *RetryConfig
}
type MatrixItemFunc ¶ added in v0.2.0
type MatrixItemFunc func(context.Context, *Connection) []map[string]interface{}
type Plugin ¶
type Plugin struct {
Name string
Logger hclog.Logger
TableMap map[string]*Table
DefaultTransform *transform.ColumnTransforms
DefaultGetConfig *GetConfig
DefaultConcurrency *DefaultConcurrencyConfig
DefaultRetryConfig *RetryConfig
// every table must implement these columns
RequiredColumns []*Column
ConnectionConfigSchema *ConnectionConfigSchema
// a map of connection name to connection structs
Connections map[string]*Connection
// object to handle caching of connection specific data
ConnectionManager *connection_manager.Manager
}
Plugin is an object used to build all necessary data for a given query
func (*Plugin) Execute ¶
func (p *Plugin) Execute(req *proto.ExecuteRequest, stream proto.WrapperPlugin_ExecuteServer) (err error)
Execute executes a query and stream the results
func (*Plugin) Initialise ¶ added in v0.2.0
func (p *Plugin) Initialise()
Initialise initialises the connection config map, set plugin pointer on all tables and setup logger
func (*Plugin) SetConnectionConfig ¶ added in v0.2.0
SetConnectionConfig parses the connection config string, and populate the connection data for this connection NOTE: we always pass and store connection config BY VALUE
type PluginFunc ¶
type QueryData ¶
type QueryData struct {
// The table this query is associated with
Table *Table
// if this is a get call (or a list call if list key columns are specified)
// this will be populated with the quals as a map of column name to quals
KeyColumnQuals map[string]*proto.QualValue
// columns which have a single equals qual
// is this a 'get' or a 'list' call
FetchType fetchType
// query context data passed from postgres - this includes the requested columns and the quals
QueryContext *proto.QueryContext
// connection details - the connection name and any config declared in the connection config file
Connection *Connection
// Matrix is an array of parameter maps (MatrixItems)
// the list/get calls with be executed for each element of this array
Matrix []map[string]interface{}
// object to handle caching of connection specific data
ConnectionManager *connection_manager.Manager
// streaming funcs
StreamListItem func(ctx context.Context, item interface{})
// deprecated - plugins should no longer call StreamLeafListItem directly and should just call StreamListItem
// event for the child list of a parent child list call
StreamLeafListItem func(ctx context.Context, item interface{})
// contains filtered or unexported fields
}
func (*QueryData) SetFetchType ¶
SetFetchType determines whether this is a get or a list call, and populates the keyColumnQualValues map
func (*QueryData) ShallowCopy ¶ added in v0.2.4
ShallowCopy creates a shallow copy of the QueryData this is used to pass different quals to multiple list/get calls, when an in() clause is specified
type RetryConfig ¶ added in v0.2.8
type RetryConfig struct {
ShouldRetryError ErrorPredicate
}
type RowData ¶
type RowData struct {
// the output of the get/list call which is passed to all other hydrate calls
Item interface{}
// if there was a parent-child list call, store the parent list item
ParentItem interface{}
// contains filtered or unexported fields
}
RowData contains the row data
func (*RowData) GetColumnData ¶
GetColumnData returns the root item, and, if this column has a hydrate function registered, the associated hydrate data
type ServeOpts ¶
type ServeOpts struct {
PluginName string
PluginFunc PluginFunc
}
ServeOpts are the configurations to serve a plugin.
type Table ¶
type Table struct {
Name string
// table description
Description string
// column definitions
Columns []*Column
List *ListConfig
Get *GetConfig
GetMatrixItem MatrixItemFunc
DefaultTransform *transform.ColumnTransforms
// the parent plugin object
Plugin *Plugin
// definitions of dependencies between hydrate functions
HydrateDependencies []HydrateDependencies
HydrateConfig []HydrateConfig
}
Table represents a plugin table
func (Table) GetSchema ¶
func (t Table) GetSchema() *proto.TableSchema
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Transform package provides the ability to transform data from APIs.
|
Transform package provides the ability to transform data from APIs. |