templates

package
v0.0.0-...-8aeb8a1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const TableNameParameter = "JITSU_TABLE_NAME"
View Source
const TransformDefaultTemplate = "return $"

Variables

View Source
var JSONSerializeFuncs = template.FuncMap{
	"json": func(v interface{}) (string, error) {
		return marshal(v, false, false)
	},

	"json_indent": func(v interface{}) (string, error) {
		return marshal(v, true, false)
	},

	"json_indent_quote": func(v interface{}) (string, error) {
		return marshal(v, true, true)
	},

	"get": func(v interface{}, path string, defaultValue interface{}) (interface{}, error) {
		return get_impl(v, path, defaultValue)
	},

	"TABLE_NAME": TableNameParameter,
}

JSONSerializeFuncs are additional funcs for using from text/template. for example for embedding whole object as JSON into another JSON

Functions

func EnrichedFuncMap

func EnrichedFuncMap(extraVars map[string]interface{}) template.FuncMap

func NewGoTemplateExecutor

func NewGoTemplateExecutor(name string, expression string, extraFunctions template.FuncMap) (*goTemplateExecutor, error)

func SetScriptFactory

func SetScriptFactory(newScriptFactory script.Factory)

func ToJSONorStringBytes

func ToJSONorStringBytes(responseObject interface{}) ([]byte, error)

func ToString

func ToString(responseObject interface{}, allowArray bool, allowObject bool, truncateDate bool) string

Types

type DestinationPlugin

type DestinationPlugin struct {
	Package string
	ID      string
	Type    string
	Config  map[string]interface{}
	// contains filtered or unexported fields
}

func (*DestinationPlugin) String

func (p *DestinationPlugin) String() string

type Expression

type Expression string

func (Expression) String

func (e Expression) String() string

type NodeExecutor

type NodeExecutor struct {
	script.Interface
	// contains filtered or unexported fields
}

func NewScriptExecutor

func NewScriptExecutor(nodeScript nodeScript, variables map[string]interface{}, includes ...string) (*NodeExecutor, error)

func (*NodeExecutor) Expression

func (e *NodeExecutor) Expression() string

func (*NodeExecutor) Format

func (e *NodeExecutor) Format() string

func (*NodeExecutor) ProcessEvent

func (e *NodeExecutor) ProcessEvent(event events.Event, listener script.Listener) (interface{}, error)

func (*NodeExecutor) Validate

func (e *NodeExecutor) Validate() error

type SourceExecutor

type SourceExecutor struct {
	script.Interface
	*SourcePlugin
}

func NewSourceExecutor

func NewSourceExecutor(sourcePlugin *SourcePlugin) (*SourceExecutor, error)

func (*SourceExecutor) Catalog

func (e *SourceExecutor) Catalog() (interface{}, error)

func (*SourceExecutor) Spec

func (e *SourceExecutor) Spec() map[string]interface{}

func (*SourceExecutor) Stream

func (e *SourceExecutor) Stream(streamName string, configuration interface{}, state interface{}, listener script.Listener) (interface{}, error)

func (*SourceExecutor) Validate

func (e *SourceExecutor) Validate() error

type SourcePlugin

type SourcePlugin struct {
	Package string
	ID      string
	Type    string
	Config  map[string]interface{}
	// contains filtered or unexported fields
}

func (*SourcePlugin) String

func (s *SourcePlugin) String() string

type TemplateExecutor

type TemplateExecutor interface {
	ProcessEvent(events.Event, script.Listener) (interface{}, error)
	Format() string
	Expression() string
	Close()
}

func SmartParse

func SmartParse(name string, expression string, extraFunctions template.FuncMap) (TemplateExecutor, error)

SmartParse is a factory method that returns TemplateExecutor implementation based on provided expression language

Jump to

Keyboard shortcuts

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