Documentation
¶
Index ¶
- Constants
- Variables
- func AugmentedValFromEnv(original string) string
- type AuthCapability
- type AuthConfig
- type AuthHeader
- type CacheCapability
- type CacheConfig
- type CacheRules
- type CapabilityConfig
- func DefaultCapabilityConfig() CapabilityConfig
- func DefaultConfigWithDB(logger *vlog.Logger, dbType, dbConnString string, queries []Query) CapabilityConfig
- func DefaultConfigWithLogger(logger *vlog.Logger) CapabilityConfig
- func NewConfig(logger *vlog.Logger, dbType, dbConnString string, queries []Query) CapabilityConfig
- type DatabaseCapability
- type DatabaseConfig
- type FileCapability
- type FileConfig
- type GraphQLCapability
- type GraphQLConfig
- type GraphQLError
- type GraphQLRequest
- type GraphQLResponse
- type HTTPCapability
- type HTTPConfig
- type HTTPRules
- type LoggerCapability
- type LoggerConfig
- type Query
- type QueryType
- type RedisCache
- type RedisConfig
- type RequestHandlerCapability
- type RequestHandlerConfig
- type SqlDatabase
- type StaticFileFunc
Constants ¶
const ( DBTypeMySQL = "mysql" DBTypePostgres = "pgx" )
Variables ¶
var ( ErrDatabaseTypeInvalid = errors.New("database type invalid") ErrQueryNotFound = errors.New("query not found") ErrQueryNotPrepared = errors.New("query not prepared") ErrQueryTypeMismatch = errors.New("query type incorrect") ErrQueryTypeInvalid = errors.New("query type invalid") ErrQueryVarsMismatch = errors.New("number of variables incorrect") )
var ( ErrHttpDisallowed = errors.New("requests to insecure HTTP endpoints is disallowed") ErrIPsDisallowed = errors.New("requests to IP addresses are disallowed") ErrPrivateDisallowed = errors.New("requests to private IP address ranges are disallowed") ErrDomainDisallowed = errors.New("requests to this domain are disallowed") ErrPortDisallowed = errors.New("requests to this port are disallowed") )
var ( ErrReqNotSet = errors.New("req is not set") ErrInvalidFieldType = errors.New("invalid field type") ErrKeyNotFound = errors.New("key not found") )
var ErrCacheKeyNotFound = errors.New("key not found")
ErrCacheKeyNotFound is returned when a non-existent cache key is requested
var ErrCapabilityNotEnabled = errors.New("capability is not enabled")
Functions ¶
func AugmentedValFromEnv ¶ added in v0.13.0
Types ¶
type AuthCapability ¶ added in v0.11.1
type AuthCapability interface {
HeaderForDomain(string) *AuthHeader
}
AuthCapability is a provider for various kinds of auth
func DefaultAuthProvider ¶
func DefaultAuthProvider(config AuthConfig) AuthCapability
DefaultAuthProvider creates the default static auth provider
type AuthConfig ¶ added in v0.11.1
type AuthConfig struct { Enabled bool `json:"enabled" yaml:"enabled"` // Headers is a map between domains and auth header that should be added to requests to those domains Headers map[string]AuthHeader `json:"headers" yaml:"headers"` }
AuthConfig is a config for the default auth provider
type AuthHeader ¶
type AuthHeader struct { HeaderType string `json:"headerType" yaml:"headerType"` Value string `json:"value" yaml:"value"` }
AuthHeader is an HTTP header designed to authenticate requests
type CacheCapability ¶ added in v0.11.1
type CacheCapability interface { Set(key string, val []byte, ttl int) error Get(key string) ([]byte, error) Delete(key string) error }
CacheCapability gives Runnables access to a key/value cache
func SetupCache ¶ added in v0.12.0
func SetupCache(config CacheConfig) CacheCapability
type CacheConfig ¶ added in v0.11.1
type CacheConfig struct { Enabled bool `json:"enabled" yaml:"enabled"` Rules CacheRules `json:"rules" yaml:"rules"` RedisConfig *RedisConfig `json:"redis,omitempty" yaml:"redis,omitempty"` }
CacheConfig is configuration for the cache capability
type CacheRules ¶ added in v0.12.0
type CapabilityConfig ¶ added in v0.11.1
type CapabilityConfig struct { Logger *LoggerConfig `json:"logger,omitempty" yaml:"logger,omitempty"` HTTP *HTTPConfig `json:"http,omitempty" yaml:"http,omitempty"` GraphQL *GraphQLConfig `json:"graphql,omitempty" yaml:"graphql,omitempty"` Auth *AuthConfig `json:"auth,omitempty" yaml:"auth,omitempty"` Cache *CacheConfig `json:"cache,omitempty" yaml:"cache,omitempty"` File *FileConfig `json:"file,omitempty" yaml:"file,omitempty"` DB *DatabaseConfig `json:"db" yaml:"db"` RequestHandler *RequestHandlerConfig `json:"requestHandler,omitempty" yaml:"requestHandler,omitempty"` }
CapabilityConfig is configuration for a Runnable's capabilities NOTE: if any of the individual configs are nil, it will cause a crash, but we need to be able to determine if they're set or not, hence the pointers we are going to leave capabilities undocumented until we come up with a more elegant solution
func DefaultCapabilityConfig ¶ added in v0.11.1
func DefaultCapabilityConfig() CapabilityConfig
DefaultCapabilityConfig returns the default all-enabled config (with a default logger)
func DefaultConfigWithDB ¶ added in v0.13.0
func DefaultConfigWithDB(logger *vlog.Logger, dbType, dbConnString string, queries []Query) CapabilityConfig
DefaultConfigWithDB returns a capability config with a custom logger and database configured
func DefaultConfigWithLogger ¶ added in v0.11.1
func DefaultConfigWithLogger(logger *vlog.Logger) CapabilityConfig
DefaultConfigWithLogger returns a capability config with a custom logger
type DatabaseCapability ¶ added in v0.13.0
type DatabaseCapability interface { ExecQuery(queryType int32, name string, vars []interface{}) ([]byte, error) Prepare(q *Query) error }
func NewSqlDatabase ¶ added in v0.13.0
func NewSqlDatabase(config *DatabaseConfig) (DatabaseCapability, error)
NewSqlDatabase creates a new SQL database
type DatabaseConfig ¶ added in v0.13.0
type FileCapability ¶ added in v0.11.1
FileCapability gives runnables access to various kinds of files
func DefaultFileSource ¶
func DefaultFileSource(config FileConfig) FileCapability
type FileConfig ¶ added in v0.11.1
type FileConfig struct { Enabled bool `json:"enabled" yaml:"enabled"` FileFunc StaticFileFunc `json:"-" yaml:"-"` }
FileConfig is configuration for the File capability
type GraphQLCapability ¶ added in v0.11.1
type GraphQLCapability interface {
Do(auth AuthCapability, endpoint, query string) (*GraphQLResponse, error)
}
GraphQLCapability is a GraphQL capability for Reactr Modules
func DefaultGraphQLClient ¶
func DefaultGraphQLClient(config GraphQLConfig) GraphQLCapability
DefaultGraphQLClient creates a GraphQLClient object
type GraphQLConfig ¶ added in v0.11.1
type GraphQLConfig struct { Enabled bool `json:"enabled" yaml:"enabled"` Rules HTTPRules `json:"rules" yaml:"rules"` }
GraphQLConfig is configuration for the GraphQL capability
type GraphQLError ¶
GraphQLError is a GraphQL error
type GraphQLRequest ¶
type GraphQLRequest struct { Query string `json:"query"` Variables map[string]string `json:"variables,omitempty"` OperationName string `json:"operationName,omitempty"` }
GraphQLRequest is a request to a GraphQL endpoint
type GraphQLResponse ¶
type GraphQLResponse struct { Data map[string]interface{} `json:"data"` Errors []GraphQLError `json:"errors,omitempty"` }
GraphQLResponse is a GraphQL response
type HTTPCapability ¶ added in v0.11.1
type HTTPCapability interface {
Do(auth AuthCapability, method, urlString string, body []byte, headers http.Header) (*http.Response, error)
}
HTTPCapability gives Runnables the ability to make HTTP requests
func DefaultHTTPClient ¶
func DefaultHTTPClient(config HTTPConfig) HTTPCapability
DefaultHTTPClient creates an HTTP client with no restrictions
type HTTPConfig ¶ added in v0.11.1
type HTTPConfig struct { Enabled bool `json:"enabled" yaml:"enabled"` Rules HTTPRules `json:"rules" yaml:"rules"` }
HTTPConfig is configuration for the HTTP capability
type HTTPRules ¶ added in v0.12.0
type HTTPRules struct { AllowedDomains []string `json:"allowedDomains" yaml:"allowedDomains"` BlockedDomains []string `json:"blockedDomains" yaml:"blockedDomains"` AllowedPorts []int `json:"allowedPorts" yaml:"allowedPorts"` BlockedPorts []int `json:"blockedPorts" yaml:"blockedPorts"` AllowIPs bool `json:"allowIPs" yaml:"allowIPs"` AllowPrivate bool `json:"allowPrivate" yaml:"allowPrivate"` AllowHTTP bool `json:"allowHTTP" yaml:"allowHTTP"` }
HTTPRules is a set of rules that governs use of the HTTP capability
type LoggerCapability ¶ added in v0.11.1
LoggerCapability provides a logger to Runnables
func DefaultLoggerSource ¶
func DefaultLoggerSource(config LoggerConfig) LoggerCapability
DefaultLoggerSource returns a LoggerSource that provides vlog.Default
type LoggerConfig ¶ added in v0.11.1
type LoggerConfig struct { Enabled bool `json:"enabled" yaml:"enabled"` Logger *vlog.Logger `json:"-" yaml:"-"` }
LoggerConfig is configuration for the logger capability
type RedisCache ¶ added in v0.12.0
type RedisCache struct {
// contains filtered or unexported fields
}
func (*RedisCache) Delete ¶ added in v0.12.0
func (r *RedisCache) Delete(key string) error
Delete deletes a key
type RedisConfig ¶ added in v0.12.0
type RequestHandlerCapability ¶ added in v0.11.1
type RequestHandlerCapability interface { GetField(fieldType int32, key string) ([]byte, error) SetField(fieldType int32, key string, val string) error SetResponseHeader(key, val string) error }
RequestHandlerCapability allows runnables to handle HTTP requests
func NewRequestHandler ¶
func NewRequestHandler(config RequestHandlerConfig, req *request.CoordinatedRequest) RequestHandlerCapability
NewRequestHandler provides a handler for the given request
type RequestHandlerConfig ¶ added in v0.11.1
type RequestHandlerConfig struct { Enabled bool `json:"enabled" yaml:"enabled"` AllowGetField bool `json:"allowGetField" yaml:"allowGetField"` AllowSetField bool `json:"allowSetField" yaml:"allowSetField"` }
RequestHandlerConfig is configuration for the request capability
type SqlDatabase ¶ added in v0.13.0
type SqlDatabase struct {
// contains filtered or unexported fields
}
SqlDatabase is an SQL implementation of DatabaseCapability
func (*SqlDatabase) ExecQuery ¶ added in v0.13.0
func (s *SqlDatabase) ExecQuery(queryType int32, name string, vars []interface{}) ([]byte, error)
func (*SqlDatabase) Prepare ¶ added in v0.13.0
func (s *SqlDatabase) Prepare(q *Query) error
type StaticFileFunc ¶
StaticFileFunc is a function that returns the contents of a requested file