script

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: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DestinationNamespace = "destination"
	DummyStorageType     = "dummy"
	RedisStorageType     = "redis"
)

Variables

View Source
var DummyFactory = dummyFactory{}

Functions

func Exec

func Exec(dir string, path string, args ...string) error

Types

type Args

type Args = []interface{}

type Dummy

type Dummy struct{}

func (*Dummy) Close

func (d *Dummy) Close() error

func (*Dummy) DeleteTransformValue

func (d *Dummy) DeleteTransformValue(namespace, entityId, key string) error

func (*Dummy) GetTransformValue

func (d *Dummy) GetTransformValue(namespace string, entityId string, key string) (*string, error)

func (*Dummy) SetTransformValue

func (d *Dummy) SetTransformValue(namespace, entityId, key, value string, ttlSec *int64) error

func (*Dummy) Type

func (d *Dummy) Type() string

type Executable

type Executable interface {
	// contains filtered or unexported methods
}

Executable is an entity which can be loaded as Interface. This is an algebraic type with no logic of its own. Factory implementations are responsible for implementing processing logic for relevant Executables.

type Expression

type Expression string

Expression is a piece of code with no external requirements, generally representing a function body. Implements Executable interface.

type Factory

type Factory interface {

	// CreateScript loads an Executable and returns an Interface instance for using it.
	// `variables` are the global variables to be made available for Executable.
	// `includes` are code snippets to embed into script.
	CreateScript(executable Executable, variables map[string]interface{}, standalone bool, includes ...string) (Interface, error)
}

Factory loads an Executable.

type File

type File string

File is the executable script path. This exists mainly for tests to emulate the Package, but without the hassle of providing a valid package. Implements Executable interface.

type Interface

type Interface interface {

	// Describe returns exported Symbols.
	Describe() (Symbols, error)

	// Execute executes a function with the provided `name` and `args` and collects the execution result into `result`.
	// Execution result maybe multiline stream that will be written into provided Listener.
	Execute(name string, args Args, result interface{}, listener Listener) error

	// Close disposes of the instance and releases associated resources.
	Close()
}

Interface defines the loaded Executable.

type Listener

type Listener interface {

	// Data is executed on each line of resulting multiline stream.
	Data(data []byte)

	// Log is executed for each log record generated during execution.
	Log(level, message string)

	// Timeout to use for execution.
	Timeout() time.Duration
}

Listener interface is used to collect execution "side-effects".

type Package

type Package string

Package is an external package which should be obtained before loading. Package format specification depends on the Factory implementation. Implements Executable interface.

type Redis

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

func NewRedis

func NewRedis(pool *meta.RedisPool, keyvalueDefaultTTLMs int64) *Redis

func (*Redis) Close

func (r *Redis) Close() error

func (*Redis) DeleteTransformValue

func (r *Redis) DeleteTransformValue(namespace, entityId, key string) error

func (*Redis) GetTransformValue

func (r *Redis) GetTransformValue(namespace string, entityId string, key string) (*string, error)

func (*Redis) SetTransformValue

func (r *Redis) SetTransformValue(namespace, entityId, key, value string, ttlMs *int64) error

func (*Redis) Type

func (r *Redis) Type() string

type Storage

type Storage interface {
	io.Closer
	//** Transformation Key Value **
	GetTransformValue(namespace string, entityId string, key string) (*string, error)
	SetTransformValue(namespace, entityId, key, value string, ttlMs *int64) error
	DeleteTransformValue(namespace, entityId, key string) error
	Type() string
}

func InitializeStorage

func InitializeStorage(enabled bool, metaStorageConfiguration *viper.Viper) (Storage, error)

InitializeStorage returns configured users.Storage (redis or dummy)

type Symbol

type Symbol struct {

	// Type is the symbol type and corresponds to JavaScript's `typeof`.
	Type string `json:"type"`

	// Value is the symbol value.
	// It is nil when the symbol is a function.
	Value json.RawMessage `json:"value,omitempty"`
}

Symbol represents a JavaScript value.

func (Symbol) As

func (s Symbol) As(value interface{}) error

As unmarshals the symbol Value into a value.

type Symbols

type Symbols map[string]Symbol

Symbols is a named Symbol map.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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