transformers

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEFAULT_DEADLINE = 5 * time.Second
View Source
var ErrTransformerTimeout = fmt.Errorf("Transformer exceeded deadline")

Functions

This section is empty.

Types

type BaseTransformer

type BaseTransformer struct {
	gvk.GroupVersionKind
	Spec   interface{} `json:"spec"`
	Status []Status    `json:"status"`
}

type ITransformer

type ITransformer interface {
	//Prepare() error
	//Transform(base interface{}) error
	WithSpec(spec interface{}, params map[string]interface{}) (ITransformer, error)
	Execute(ctx context.Context, base map[string]interface{}) (map[string]interface{}, error)
	Result() interface{}
	Status() []Status
	Params() map[string]interface{}
	CreditsConsumed() int
	Deadline() time.Duration
}

type ManifestInfo

type ManifestInfo struct {
	GeneratedAt      time.Time `json:"generatedAt"`
	TransformerCount int       `json:"transformerCount"`
	Runtime          int64     `json:"runtime"`
	ManifestCID      string    `json:"manifestCID"`
}

type NewTransformerFunc

type NewTransformerFunc = func(spec interface{}, params map[string]interface{}) (ITransformer, error)

type Status

type Status struct {
	Name  string      `json:"name"`
	Value interface{} `json:"value"`
}

type TransformerInfo

type TransformerInfo struct {
	New      NewTransformerFunc
	Credits  int
	Deadline time.Duration
}

type Transformers

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

func NewTransformerManager

func NewTransformerManager() (*Transformers, error)

func (Transformers) CalculateCredits

func (t Transformers) CalculateCredits(transformers []BaseTransformer) int

func (Transformers) Execute

func (t Transformers) Execute(transformers []BaseTransformer, params map[string]interface{}) (result map[string]interface{}, err error)

func (Transformers) Get

func (Transformers) Register

func (t Transformers) Register(gvk gvk.GroupVersionKind, transformer NewTransformerFunc) error

func (Transformers) UpdateParams

func (t Transformers) UpdateParams(params *map[string]interface{}, toUpdate map[string]interface{}) error

Directories

Path Synopsis
core

Jump to

Keyboard shortcuts

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