jtl

package
v1.42.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Overview

*

  • Copyright 2015 Comcast Cable Communications Management, LLC *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

Index

Constants

View Source
const (
	JPathWildcard = "*"
	JPathPrefix   = "{{"
	JPathSuffix   = "}}"
	JPathSimple   = "(\\/[a-zA-Z0-9\\.,:_\\-]*)+"
	JPathOr       = "||"
)
View Source
const (
	OAUTH_VERSION              = "1.0"
	SIGNATURE_METHOD_HMAC_SHA1 = "HMAC-SHA1"
	SIGNATURE_METHOD_RSA_SHA1  = "RSA-SHA1"

	CALLBACK_PARAM         = "oauth_callback"
	CONSUMER_KEY_PARAM     = "oauth_consumer_key"
	NONCE_PARAM            = "oauth_nonce"
	SESSION_HANDLE_PARAM   = "oauth_session_handle"
	SIGNATURE_METHOD_PARAM = "oauth_signature_method"
	SIGNATURE_PARAM        = "oauth_signature"
	TIMESTAMP_PARAM        = "oauth_timestamp"
	TOKEN_PARAM            = "oauth_token"
	TOKEN_SECRET_PARAM     = "oauth_token_secret"
	VERIFIER_PARAM         = "oauth_verifier"
	VERSION_PARAM          = "oauth_version"
)

Variables

View Source
var (
	JPathSimpleReg *regexp.Regexp
)

Functions

func DummyEventHandler

func DummyEventHandler(w http.ResponseWriter, r *http.Request)

DummyEventHandler http handler to accept any JSON payload. Performs some basic validations and otherwise does nothing.

func EventHandler

func EventHandler(w http.ResponseWriter, r *http.Request)

EventHandler processes incoming events (arbitrary JSON payloads) and places them on the worker pool queue. If certain headers are set (X-Debug, X-Sync) a response will be returned immediately bypassing the worker pool queue.

func FortyTwoHandler

func FortyTwoHandler(w http.ResponseWriter, r *http.Request)

FortyTwoHandler http handler providing 42 as a service.

func FortyTwoJsonHandler

func FortyTwoJsonHandler(w http.ResponseWriter, r *http.Request)

FortyTwoHandler http handler providing 42 as a service (in JSON encoding).

func GetASTJsonHandler

func GetASTJsonHandler(w http.ResponseWriter, r *http.Request)

GetASTJsonHandler http handler for step debugging of jpath expressions. Processes iter number of iterations of collapsing the AST of a jpath expression given as part of the URL. The jpath expression operates against a JSON document stored at test/data/test01/in.json and writes D3 JSON results to w.

func GetApiBasePath added in v1.34.0

func GetApiBasePath() string

func HandleEvent added in v1.42.0

func HandleEvent(ctx Context, w http.ResponseWriter, r *http.Request) error

func HandlersTestHandler

func HandlersTestHandler(w http.ResponseWriter, r *http.Request)

HandlersTestHandler http handler for Web Form based transformation testing

func LoadInboundPlugins

func LoadInboundPlugins(ctx Context, enablePlugins bool)

func ManagePluginsHandler

func ManagePluginsHandler(w http.ResponseWriter, r *http.Request)

func ManagePluginsUIHandler

func ManagePluginsUIHandler(w http.ResponseWriter, r *http.Request)

func NilHandler

func NilHandler(w http.ResponseWriter, r *http.Request)

NilHandler http handler to to do almost nothing.

func ParserDebugHandler

func ParserDebugHandler(w http.ResponseWriter, r *http.Request)

ParserDebugHandler http handler to display HTML version of AST for jpath expression

func ParserDebugVizHandler

func ParserDebugVizHandler(w http.ResponseWriter, r *http.Request)

ParserDebugVizHandler http handler for D3 visualization of jpath expression AST

func PluginConfigHandler

func PluginConfigHandler(w http.ResponseWriter, r *http.Request)

func PostHandler

func PostHandler(w http.ResponseWriter, r *http.Request)

PostHandler http handler accepts any http POST and sticks body into global context under the key 'debug_post_body'.

func ProcessExpressionHandler

func ProcessExpressionHandler(w http.ResponseWriter, r *http.Request)

ProcessExpressionHandler http handler to process jpath expression given as part of the URL and writes results to w.

func RegisterEventPublisher

func RegisterEventPublisher(newPublisher NewPublisher, protocol string)

RegisterEventPublisher registers an external event publisher implementation for a new protocol

func RegisterInboundPluginType

func RegisterInboundPluginType(newPlugin NewInboundPlugin, pluginType string)

RegisterInboundPlugin registers an (external) plugin implementation by plugin type

func ReloadConfig

func ReloadConfig()

ReloadConfig reloads config.json as well as all handler configs from disk.

func ReloadConfigHandler

func ReloadConfigHandler(w http.ResponseWriter, r *http.Request)

ReloadConfigHandler http handler to relaod all configs from disk. Response is similar to StatusHandler.

func SetApiBasePath added in v1.34.0

func SetApiBasePath(basePath string)

func StatusHandler

func StatusHandler(w http.ResponseWriter, r *http.Request)

StatusHandler http handler for health and status checks. Writes JSON containing config.json, handler configs and basic stats to w.

func TopicTestHandler

func TopicTestHandler(w http.ResponseWriter, r *http.Request)

TopicTestHandler http handler for Web Form based transformation testing

func TraceLogConfigHandler

func TraceLogConfigHandler(w http.ResponseWriter, r *http.Request)

func UnregisterEventPublisher

func UnregisterEventPublisher(protocol string)

UnregisterEventPublisher removes a publisher implementation

func VersionHandler added in v1.33.0

func VersionHandler(w http.ResponseWriter, r *http.Request)

VersionHandler http handler to return nothing but version info.

func VetHandler

func VetHandler(w http.ResponseWriter, r *http.Request)

VetHandler http handler for vetting all handler configurations. Writes JSON with list of warnings (if any) to w.

Types

type AllTopicHandlersTest

type AllTopicHandlersTest struct {
	TopicHandlerTest
	AllHandlers     map[string]*HandlerConfiguration
	AllHandlerNames []string
	CurrentHandler  *HandlerConfiguration
	SelectedHandler string
	Headers         string
	HeadersOut      string
	BasePath        string
}

type AstTest

type AstTest struct {
	Message          string
	Expression       string
	Result           string
	ErrorMessage     string
	Transformations  string
	CustomProperties string
	Lists            [][][]string
	BasePath         string
}

type EventPublisher

type EventPublisher interface {
	// Publish sends the transformed event payload to the desired endpoint using the appropriate protocol (for example, HTTP POST).
	Publish() (string, error)
	SetEndpoint(endpoint string)
	GetEndpoint() string
	SetDebug(debug bool)
	GetDebug() bool
	SetPayload(payload string)
	GetPayload() string
	SetAuthInfo(auth map[string]string)
	GetProtocol() string
	GetApi() string
	SetHeaders(headers map[string]string)
	GetHeaders() map[string]string
	SetVerb(verb string)
	GetVerb() string
	SetPath(path string)
	GetPath() string
	GetUrl() string
	SetPayloadParsed(event *JDoc)
	GetPayloadParsed() *JDoc
	GetErrors() []error
	SetPublisherConfigs(configs map[string]string) error
	GetPublisherConfigs() map[string]string
}

EventPublisher is the common interface for all event publishers

func NewEventPublisher

func NewEventPublisher(ctx Context, protocol string) EventPublisher

NewEventPublisher factory method to return matching publisher for a given protocol

func NewHttpPublisher

func NewHttpPublisher(ctx Context) EventPublisher

NewHttpPublisher creates a new HTTP publisher.

func NewNullPublisher

func NewNullPublisher(ctx Context) EventPublisher

NewNullPublisher creates a new HTTP publisher.

type Filter

type Filter struct {
	Filter                    map[string]interface{} // only forward event if event matches this pattern (by path or by example)
	IsFilterByExample         bool                   // choose syntax style by path or by example for event filtering
	IsFilterInverted          bool                   // true: filter if event matches pattern, false: filter if event does not match pattern
	FilterAfterTransformation bool                   // true: apply filters after transformation, false (default): apply filter before transformation on raw event
	LogParams                 map[string]string      // extra log parameters
	// contains filtered or unexported fields
}

type HandlerConfiguration

type HandlerConfiguration struct {
	// core handler settings
	Version  string // arbitrary version
	Name     string // short name (should be unique within a tenant)
	File     string // file location
	Info     string // description
	TenantId string // tenant id (the tenant id in the match section, if present, is just a meaningless custom match value!)
	Active   bool   // only used if set to true
	// matching events to handlers
	TerminateOnMatch bool                   // terminate looking for further topic handlers if set to true and this handler matches
	Topic            string                 // for matching input events to handler configs using hierarchical topic pattern, e.g. "/a/b/c" or "a/*/c" or "" (only Topic or Match can be used!)
	Match            map[string]interface{} // for matching input events to handler configs, based on matching key-value pairs (by path or by example)
	IsMatchByExample bool                   // choose syntax style by path or by example for handler matching
	// payload generation
	Transformation            interface{}                // main transformation (by path or by example)
	IsTransformationByExample bool                       // choose syntax style by path or by example for event transformation
	Transformations           map[string]*Transformation // optional - named transformations, used by transform() function
	// custom properties
	CustomProperties map[string]interface{} // optional - overrides custom properties in config.json, in addition, map values can be jpath expessions
	// filtering by pattern
	Filter                    map[string]interface{} // optional - only forward event if event matches this pattern (by path or by example)
	IsFilterByExample         bool                   // optional - choose syntax style by path or by example for event filtering
	IsFilterInverted          bool                   // optional - true: filter if event matches pattern, false: filter if event does not match pattern
	FilterAfterTransformation bool                   // optional - true: apply filters after transformation, false (default): apply filter before transformation on raw event
	// filtering by boolean expression
	FilterIfTrue  string // optional - filter event if this expression resolves to true
	FilterIfFalse string // optional - filter event if this expression resolves to false
	// several filters if desired
	Filters []*Filter
	// outgoing HTTP config
	Path        interface{}       // relative path added to endpoint URL, if array of multiple paths, event will be fanned out to endpoint/path1, endpoint/path2 etc.
	Verb        string            // otpional - HTTP verb like PUT, POST
	AuthInfo    map[string]string // optional - to overwrite default auth info, example: {"type":"basic","username":"foo","password":"bar"}
	Protocol    string            // optional - if omitted defaults to http, other valid values: x1, emo, email, sms (the protocol in the match section, if present, is just a meaningless custom match value!)
	Endpoint    interface{}       // optional - overwrite default endpoint from config.json, if array of multiple endpoints, event will be fanned out to endpoint1, endpoint2 etc.
	HttpHeaders map[string]string // optional - http headers
	// extra publisher config
	PublisherConfigs map[string]string //optional - any extra publisher configuration parameters should go here
	// contains filtered or unexported fields
}

HandlerConfiguration is the central configuration structure for topic handlers as well as custom match handlers.

func GetCurrentHandlerConfig

func GetCurrentHandlerConfig(ctx Context) *HandlerConfiguration

GetConfig is a helper function to obtain the global config from the context.

func GetHandlerConfigurationFromFile added in v1.42.0

func GetHandlerConfigurationFromFile(ctx Context, filepath string) (*HandlerConfiguration, []error)

GetHandlerConfigurationFromFile loads a single handler config from disk and returns a handler and a (hopefully empty) list of warning strings.

func GetHandlerConfigurationFromJson added in v1.42.0

func GetHandlerConfigurationFromJson(ctx Context, filepath string, handler HandlerConfiguration) (*HandlerConfiguration, []error)

GetHandlerConfigurationFromJson parses and vets handler configuration from a partially populated HandlerConfiguration struct.

func (*HandlerConfiguration) DeepCopy added in v1.32.0

func (*HandlerConfiguration) GetFilter

func (h *HandlerConfiguration) GetFilter() *JDoc

func (*HandlerConfiguration) GetNamedTransformation

func (h *HandlerConfiguration) GetNamedTransformation() map[string]*Transformation

func (*HandlerConfiguration) GetTransformation

func (h *HandlerConfiguration) GetTransformation() *JDoc

func (*HandlerConfiguration) IsValidTransformation

func (h *HandlerConfiguration) IsValidTransformation(ctx Context, t *JDoc, istbe bool) (bool, string)

IsValidTransformation helper function to check if a transformation given as parameter is valid.

func (*HandlerConfiguration) ProcessEvent

func (h *HandlerConfiguration) ProcessEvent(ctx Context, event *JDoc) ([]EventPublisher, error)

ProcessEvent lets a single handler process an event and returns a list of prepopulates publishers (typically one publisher).

func (*HandlerConfiguration) Save

func (h *HandlerConfiguration) Save() error

type HandlerFactory

type HandlerFactory struct {
	CustomHandlerMap map[string]map[string]*HandlerConfiguration   // tenant_id -> handler_name ->  handler config
	TopicHandlerMap  map[string]map[string][]*HandlerConfiguration // tenant_id -> topic_name -> list of topic handlers
}

HandlerFactory factory providing correct handler(s) for a given document

func GetHandlerFactory

func GetHandlerFactory(ctx Context) *HandlerFactory

GetHandlerFactory get current instance of handler factory from context.

func NewHandlerFactory

func NewHandlerFactory(ctx Context, configFolders []string) (*HandlerFactory, []error)

NewHandlerFactory creates new handler factory and loads handler files from all config folders.

func (*HandlerFactory) GetAllHandlers

func (hf *HandlerFactory) GetAllHandlers(ctx Context) []*HandlerConfiguration

GetAllHandlers obtains list of all handlers.

func (*HandlerFactory) GetHandlerByName

func (hf *HandlerFactory) GetHandlerByName(ctx Context, tenant string, name string) *HandlerConfiguration

GetHandlersByName obtains handler by name

func (*HandlerFactory) GetHandlersForEvent

func (hf *HandlerFactory) GetHandlersForEvent(ctx Context, event *JDoc) []*HandlerConfiguration

GetHandlersForEvent obtains matching list of handlers for a given JSON document.

func (*HandlerFactory) GetTopicHandlersForTenant

func (hf *HandlerFactory) GetTopicHandlersForTenant(tenantId string, topic string) []*HandlerConfiguration

GetTopicHandlersForTenant retrieves topic handlers by tenant id and topic

type HttpPublisher

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

func (*HttpPublisher) GetApi

func (p *HttpPublisher) GetApi() string

func (*HttpPublisher) GetDebug

func (p *HttpPublisher) GetDebug() bool

func (*HttpPublisher) GetEndpoint

func (p *HttpPublisher) GetEndpoint() string

func (*HttpPublisher) GetErrors

func (p *HttpPublisher) GetErrors() []error

func (*HttpPublisher) GetHeaders

func (p *HttpPublisher) GetHeaders() map[string]string

func (*HttpPublisher) GetPath

func (p *HttpPublisher) GetPath() string

func (*HttpPublisher) GetPayload

func (p *HttpPublisher) GetPayload() string

func (*HttpPublisher) GetPayloadParsed

func (p *HttpPublisher) GetPayloadParsed() *JDoc

func (*HttpPublisher) GetProtocol

func (p *HttpPublisher) GetProtocol() string

func (*HttpPublisher) GetPublisherConfigs added in v1.31.0

func (p *HttpPublisher) GetPublisherConfigs() map[string]string

func (*HttpPublisher) GetUrl

func (p *HttpPublisher) GetUrl() string

func (*HttpPublisher) GetVerb

func (p *HttpPublisher) GetVerb() string

func (*HttpPublisher) Publish

func (p *HttpPublisher) Publish() (string, error)

func (*HttpPublisher) SetAuthInfo

func (p *HttpPublisher) SetAuthInfo(auth map[string]string)

func (*HttpPublisher) SetDebug

func (p *HttpPublisher) SetDebug(debug bool)

func (*HttpPublisher) SetEndpoint

func (p *HttpPublisher) SetEndpoint(endpoint string)

func (*HttpPublisher) SetHeaders

func (p *HttpPublisher) SetHeaders(headers map[string]string)

func (*HttpPublisher) SetPath

func (p *HttpPublisher) SetPath(path string)

func (*HttpPublisher) SetPayload

func (p *HttpPublisher) SetPayload(payload string)

func (*HttpPublisher) SetPayloadParsed

func (p *HttpPublisher) SetPayloadParsed(event *JDoc)

func (*HttpPublisher) SetPublisherConfigs added in v1.31.0

func (p *HttpPublisher) SetPublisherConfigs(configs map[string]string) error

func (*HttpPublisher) SetVerb

func (p *HttpPublisher) SetVerb(verb string)

type InboundPlugin

type InboundPlugin interface {
	StartPlugin(Context)
	GetSettings() *PluginSettings
	StopPlugin(Context)
	IsActive() bool
}

func GetInboundPluginByName

func GetInboundPluginByName(name string) InboundPlugin

func GetInboundPluginByType

func GetInboundPluginByType(pluginType string) InboundPlugin

func NewStdinPlugin

func NewStdinPlugin(settings *PluginSettings) InboundPlugin

func NewWebhookPlugin

func NewWebhookPlugin(settings *PluginSettings) InboundPlugin

type JDoc

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

func NewJDocFromFile

func NewJDocFromFile(filePath string) (*JDoc, error)

NewJDocFromFile returns handle to JSON document given as a path to a file.

func NewJDocFromInterface

func NewJDocFromInterface(o interface{}) (*JDoc, error)

NewJDocFromInterface returns handle to JSON document given as a map.

func NewJDocFromMap

func NewJDocFromMap(m map[string]interface{}) (*JDoc, error)

NewJDocFromMap returns handle to JSON document given as a map.

func NewJDocFromString

func NewJDocFromString(doc string) (*JDoc, error)

NewJDocFromString returns handle to JSON document given as a string.

func (*JDoc) ApplyTransformation

func (j *JDoc) ApplyTransformation(ctx Context, transformation *JDoc) *JDoc

ApplyTransformation uses a collection of jpath expressions on the left hand side and constants or jpath expressions on the right hand side as a basis for the transformation result. This allows for arbitrarily complex / nested map structures to be created but arrays can not be expressed. This turns out too be an unacceptable limitation which is why there is ApplyTransformationByExample() as an alternative. Syntax examples for path values in transformation.pmap: {{/}} -> copy entire document {{/a/b/c}} -> copy contents from location /a/b/c in source document {{/a/b[0]}} -> copy array element "abc" -> create string field with value "abc" 123 -> create number field with value 123

func (*JDoc) ApplyTransformationByExample

func (j *JDoc) ApplyTransformationByExample(ctx Context, tf *JDoc) *JDoc

ApplyTransformationByExample uses a valid JSON document as a basis for the transformation result. All keys have to be constants (strings), values can be either constants or jpath expressions. This allows for arbitrarily complex JSON documents including maps and arrays. tf contains the transformation and j the document to select values from.

func (*JDoc) Equals

func (j *JDoc) Equals(j2 *JDoc) bool

Equals performs a deep equal test for two JSON documents.

func (*JDoc) EvalPath

func (j *JDoc) EvalPath(ctx Context, path string) interface{}

EvalPath evaluates any jpath expression (with or without array selectors). Example path: "/content/deviceId"

func (*JDoc) GetFlatObject

func (j *JDoc) GetFlatObject() map[string]interface{}

GetFlatObject returns exploded version of original document.

func (*JDoc) GetFloatValue

func (j *JDoc) GetFloatValue(path string) float64

func (*JDoc) GetFloatValueForExpression

func (j *JDoc) GetFloatValueForExpression(ctx Context, expr string) float64

func (*JDoc) GetIntValue

func (j *JDoc) GetIntValue(path string) int

func (*JDoc) GetIntValueForExpression

func (j *JDoc) GetIntValueForExpression(ctx Context, expr string) int

func (*JDoc) GetMapValue

func (j *JDoc) GetMapValue(path string) map[string]interface{}

func (*JDoc) GetMapValueForExpression

func (j *JDoc) GetMapValueForExpression(ctx Context, expr string) map[string]interface{}

func (*JDoc) GetNumberValue

func (j *JDoc) GetNumberValue(path string) float64

func (*JDoc) GetNumberValueForExpression

func (j *JDoc) GetNumberValueForExpression(ctx Context, expr string) float64

func (*JDoc) GetOriginalObject

func (j *JDoc) GetOriginalObject() interface{}

GetOriginalObject returns original document as map.

func (*JDoc) GetSliceValue

func (j *JDoc) GetSliceValue(path string) []interface{}

func (*JDoc) GetSliceValueForExpression

func (j *JDoc) GetSliceValueForExpression(ctx Context, expr string) []interface{}

func (*JDoc) GetStringMapValueForExpression added in v1.29.0

func (j *JDoc) GetStringMapValueForExpression(ctx Context, path string) map[string]string

func (*JDoc) GetStringSliceValue

func (j *JDoc) GetStringSliceValue(path string) []string

func (*JDoc) GetStringSliceValueForExpression

func (j *JDoc) GetStringSliceValueForExpression(ctx Context, expr string) []string

func (*JDoc) GetStringValue

func (j *JDoc) GetStringValue(path string) string

func (*JDoc) GetStringValueForExpression

func (j *JDoc) GetStringValueForExpression(ctx Context, expr string) string

func (*JDoc) GetValue

func (j *JDoc) GetValue(path string) interface{}

func (*JDoc) GetValueForExpression

func (j *JDoc) GetValueForExpression(ctx Context, expr string) interface{}

func (*JDoc) HasPath

func (j *JDoc) HasPath(path string) bool

HasPath checks if a path exists in a given document. Example path: "/content/siteId".

func (*JDoc) IsValidPath

func (j *JDoc) IsValidPath(expr string) bool

IsValidPath checks if a given jath is valid or not (does not check if the path exists in a given document). Example path: "/content/deviceId"

func (*JDoc) IsValidPathExpression

func (j *JDoc) IsValidPathExpression(ctx Context, expr string) bool

IsValidPathExpression checks if a given jpath expression is valid. This includes function calls. Examples: "{{/content/deviceId}}" or "{{uuid()}}" etc.

func (*JDoc) ListAllPaths

func (j *JDoc) ListAllPaths() []string

ListAllPaths list all possible path expressions in document as string slice.

func (*JDoc) MatchesPattern

func (j *JDoc) MatchesPattern(pattern *JDoc) (bool, int)

MatchesPattern checks if given document matches given pattern. Wildcards are expressed as '*' and boolean or is expressed as '||'.

func (*JDoc) ParseExpression

func (j *JDoc) ParseExpression(ctx Context, expr interface{}) interface{}

ParseExpression parsed and evaluates a given jpath expression. Results are returned as interface. Examples: "{{/content/deviceId}}" or "{{uuid()}}" etc.

func (*JDoc) String

func (j *JDoc) String() string

String converts document to single line JSON string representation.

func (*JDoc) StringPretty

func (j *JDoc) StringPretty() string

StringPretty converts document to pretty JSON string representation.

func (*JDoc) VetExpression

func (j *JDoc) VetExpression(ctx Context, expr interface{}) string

VetExpression checks if a given jpath expression is valid and returns an error string if it isn't. Examples: "{{/content/deviceId}}" or "{{uuid()}}" etc.

type JExprD3Node

type JExprD3Node struct {
	Name     string         `json:"name"`
	Parent   string         `json:"parent"`
	Children []*JExprD3Node `json:"children"`
}

JExprD3Node represents a simplified version of a node on the abstract syntax tree for debug and visulaization purposes.

type JExprItem

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

JExprItem represents a node in an abstract syntax tree of a parsed jpath expression. Pointer to root node also used as handle for a parser instance.

func NewJExpr

func NewJExpr(expr string) (*JExprItem, error)

NewJExpr parses (but does not execute) a jpath expression and returns handle.

func (*JExprItem) CollapseNextLeafDebug

func (a *JExprItem) CollapseNextLeafDebug(ctx Context, doc *JDoc) bool

CollapseNextLeafDebug is used for step-debugging of a jpath expression.

func (*JExprItem) Execute

func (a *JExprItem) Execute(ctx Context, doc *JDoc) interface{}

Execute executes parsed jpath expression and returns result as interface.

func (*JExprItem) ExecuteDebug

func (a *JExprItem) ExecuteDebug(ctx Context, doc *JDoc) (interface{}, [][][]string)

ExecuteDebug executes parsed jpath expression in debug mode and returns result as interface as well as detailed tabular debug information.

func (*JExprItem) GetD3Json

func (a *JExprItem) GetD3Json(cur *JExprD3Node) *JExprD3Node

GetD3Json returns a simplified AST for display with D3

type JFunction

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

JFunction represents built-in functions that can be used in jpath expressions.

func NewFunction

func NewFunction(fn string) *JFunction

NewFunction gets function implementation by name.

func (*JFunction) ExecuteFunction

func (f *JFunction) ExecuteFunction(ctx Context, doc *JDoc, params []string) interface{}

ExecuteFunction executes a function on a given JSON document with given parameters.

type NewInboundPlugin

type NewInboundPlugin func(*PluginSettings) InboundPlugin

type NewPublisher

type NewPublisher func(ctx Context) EventPublisher

type NullPublisher

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

func (*NullPublisher) GetApi

func (p *NullPublisher) GetApi() string

func (*NullPublisher) GetDebug

func (p *NullPublisher) GetDebug() bool

func (*NullPublisher) GetEndpoint

func (p *NullPublisher) GetEndpoint() string

func (*NullPublisher) GetErrors

func (p *NullPublisher) GetErrors() []error

func (*NullPublisher) GetHeaders

func (p *NullPublisher) GetHeaders() map[string]string

func (*NullPublisher) GetPath

func (p *NullPublisher) GetPath() string

func (*NullPublisher) GetPayload

func (p *NullPublisher) GetPayload() string

func (*NullPublisher) GetPayloadParsed

func (p *NullPublisher) GetPayloadParsed() *JDoc

func (*NullPublisher) GetProtocol

func (p *NullPublisher) GetProtocol() string

func (*NullPublisher) GetPublisherConfigs added in v1.31.0

func (p *NullPublisher) GetPublisherConfigs() map[string]string

func (*NullPublisher) GetUrl

func (p *NullPublisher) GetUrl() string

func (*NullPublisher) GetVerb

func (p *NullPublisher) GetVerb() string

func (*NullPublisher) Publish

func (p *NullPublisher) Publish() (string, error)

func (*NullPublisher) SetAuthInfo

func (p *NullPublisher) SetAuthInfo(auth map[string]string)

func (*NullPublisher) SetDebug

func (p *NullPublisher) SetDebug(debug bool)

func (*NullPublisher) SetEndpoint

func (p *NullPublisher) SetEndpoint(endpoint string)

func (*NullPublisher) SetHeaders

func (p *NullPublisher) SetHeaders(headers map[string]string)

func (*NullPublisher) SetPath

func (p *NullPublisher) SetPath(path string)

func (*NullPublisher) SetPayload

func (p *NullPublisher) SetPayload(payload string)

func (*NullPublisher) SetPayloadParsed

func (p *NullPublisher) SetPayloadParsed(event *JDoc)

func (*NullPublisher) SetPublisherConfigs added in v1.31.0

func (p *NullPublisher) SetPublisherConfigs(configs map[string]string) error

func (*NullPublisher) SetVerb

func (p *NullPublisher) SetVerb(verb string)

type OAuthConsumer added in v1.29.0

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

func NewOAuthConsumer added in v1.29.0

func NewOAuthConsumer(serviceProvider string) *OAuthConsumer

func (*OAuthConsumer) BaseParams added in v1.29.0

func (c *OAuthConsumer) BaseParams(consumerKey string, additionalParams map[string]string) *OrderedParams

func (*OAuthConsumer) GetOAuth1Header added in v1.29.0

func (c *OAuthConsumer) GetOAuth1Header(ctx Context, method string, reqURL string) (string, error)

func (*OAuthConsumer) LoadConfig added in v1.29.0

func (c *OAuthConsumer) LoadConfig(filename string, conf interface{}) error

func (*OAuthConsumer) RequestString added in v1.29.0

func (c *OAuthConsumer) RequestString(method string, url string, params *OrderedParams) string

type OrderedParams added in v1.29.0

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

func NewOrderedParams added in v1.29.0

func NewOrderedParams() *OrderedParams

func (*OrderedParams) Add added in v1.29.0

func (o *OrderedParams) Add(key, value string)

func (*OrderedParams) AddUnescaped added in v1.29.0

func (o *OrderedParams) AddUnescaped(key, value string)

func (*OrderedParams) Clone added in v1.29.0

func (o *OrderedParams) Clone() *OrderedParams

func (*OrderedParams) Get added in v1.29.0

func (o *OrderedParams) Get(key string) string

func (*OrderedParams) Keys added in v1.29.0

func (o *OrderedParams) Keys() []string

func (*OrderedParams) Len added in v1.29.0

func (o *OrderedParams) Len() int

func (*OrderedParams) Less added in v1.29.0

func (o *OrderedParams) Less(i int, j int) bool

func (*OrderedParams) Swap added in v1.29.0

func (o *OrderedParams) Swap(i int, j int)

type PluginConfigList

type PluginConfigList []*PluginSettings

func GetPluginConfigList

func GetPluginConfigList(ctx Context) PluginConfigList

type PluginSettings

type PluginSettings struct {
	Type       string
	Name       string
	Active     bool
	RestartOk  bool
	AutoStart  bool
	ExitOnErr  bool
	Parameters map[string]interface{}
	Stats      PluginStats
}

type PluginStats

type PluginStats struct {
	MessageCount      uint64
	MessagesPerSecond uint64
	MessagesPerMinute uint64
	Misc              map[string]interface{}
	sync.RWMutex
}

type PluginTemplateParams added in v1.34.0

type PluginTemplateParams struct {
	BasePath string
	PluginSettings
}

type SHA1Signer added in v1.29.0

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

func (*SHA1Signer) Debug added in v1.29.0

func (s *SHA1Signer) Debug(enabled bool)

func (*SHA1Signer) Sign added in v1.29.0

func (s *SHA1Signer) Sign(message string, tokenSecret string) (string, error)

func (*SHA1Signer) SignatureMethod added in v1.29.0

func (s *SHA1Signer) SignatureMethod() string

type StdinPlugin

type StdinPlugin struct {
	Settings     *PluginSettings
	ShuttingDown bool
}

func (*StdinPlugin) GetSettings

func (p *StdinPlugin) GetSettings() *PluginSettings

func (*StdinPlugin) IsActive

func (p *StdinPlugin) IsActive() bool

func (*StdinPlugin) StartPlugin

func (p *StdinPlugin) StartPlugin(ctx Context)

func (*StdinPlugin) StartStdInConsumer

func (p *StdinPlugin) StartStdInConsumer(ctx Context, r io.Reader)

func (*StdinPlugin) StopPlugin

func (p *StdinPlugin) StopPlugin(ctx Context)

type TopicHandlerTest

type TopicHandlerTest struct {
	Response         string
	Message          string
	Transformation   string
	Transformations  string
	CustomProperties string
	Filters          string
	ErrorMessage     string
	Match            string
	Path             interface{}
	PathExpression   string
	IsTBE            bool
	IsMBE            bool
	BasePath         string
}

type TraceLogger

type TraceLogger struct {
	File         *os.File
	Writer       *bufio.Writer
	Settings     *EelTraceLogParams
	EventChannel chan *JDoc
}

func NewTraceLogger

func NewTraceLogger(ctx Context, config *EelSettings) *TraceLogger

func (*TraceLogger) CloseTraceLog

func (t *TraceLogger) CloseTraceLog(ctx Context)

func (*TraceLogger) TraceLog

func (t *TraceLogger) TraceLog(ctx Context, event *JDoc, incoming bool)

type Transformation

type Transformation struct {
	Transformation            interface{}
	IsTransformationByExample bool
	// contains filtered or unexported fields
}

func (*Transformation) GetTransformation

func (t *Transformation) GetTransformation() *JDoc

func (*Transformation) SetTransformation

func (t *Transformation) SetTransformation(tf *JDoc)

type WebhookPlugin

type WebhookPlugin struct {
	Settings     *PluginSettings
	ShuttingDown bool
}

func (*WebhookPlugin) GetSettings

func (p *WebhookPlugin) GetSettings() *PluginSettings

func (*WebhookPlugin) IsActive

func (p *WebhookPlugin) IsActive() bool

func (*WebhookPlugin) StartPlugin

func (p *WebhookPlugin) StartPlugin(ctx Context)

func (*WebhookPlugin) StartWebhookConsumer

func (p *WebhookPlugin) StartWebhookConsumer(ctx Context)

func (*WebhookPlugin) StopPlugin

func (p *WebhookPlugin) StopPlugin(ctx Context)

type WorkDispatcher

type WorkDispatcher struct {
	WorkQueue   chan *WorkRequest
	WorkerQueue chan chan *WorkRequest
	// contains filtered or unexported fields
}

WorkDispatcher dispatches work requests to workers in the pool using channels

func GetWorkDispatcher

func GetWorkDispatcher(ctx Context, tenantId string) *WorkDispatcher

func NewWorkDispatcher

func NewWorkDispatcher(nworkers int, queueDepth int, tenant string) *WorkDispatcher

NewWorkDispatcher creates a new worker pool with nworkers workers and a work queue depth of queueDepth

func (*WorkDispatcher) Start

func (disp *WorkDispatcher) Start(ctx Context)

Start starts the event loop of a new work dispatcher

func (*WorkDispatcher) Stop

func (disp *WorkDispatcher) Stop(ctx Context)

Stop stops the worker pool

type WorkRequest

type WorkRequest struct {
	Raw   string
	Event *JDoc
	Ctx   Context
}

WorkRequest is a work request

type Worker

type Worker struct {
	WorkerQueue chan chan *WorkRequest
	// contains filtered or unexported fields
}

Worker is a worker in the pool

func NewWorker

func NewWorker(id int, workerQueue chan chan *WorkRequest) *Worker

NewWorker creates a new worker

func (*Worker) Start

func (w *Worker) Start()

Start starts a worker which will then listen on its private channel for work requests

func (*Worker) Stop

func (w *Worker) Stop()

Stop stops a worker via quit channel

Jump to

Keyboard shortcuts

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