procedure

package
v0.0.0-...-03ee3a8 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package procedure provides functionality to call of external programs to process file objects throught STDIN or TMPFILE interfaces.

All subprograms have to implement JSON api interface throught STDOUT pipelines or pure file response. JSON will be detected automaticly

Example STDOUT file:

procedure resize-image.sh

Example STOUT json:

[4]byte{JSON_SIZE_BIGENDING}
{
	"field1": "value1",
	"field2": "value2",
}
[...FILE_STREAM_RESPONSE...]

Example STDOUT tmpfile:

shell exec magick {{input_tmp_file}} {{output_tmp_file}}
STDOUT: optional as JSON

Index

Constants

View Source
const (
	ParamName         = "name"
	ParamArguments    = "args"
	ParamTargetMeta   = "target-meta"
	ParamToJSONString = "tojson"
	ParamOutputFile   = "output-file"
	ParamInputFile    = "input-file"
)

Command parameters

View Source
const ActionName = "procedure"

ActionName of command

Variables

View Source
var (
	ErrInvalidProcedureParameter = errors.New("[procedure] invalid procedure arguments")
	ErrCantCreateTmpFile         = errors.New("[procedure] invalid tmp file creation")
)

Error list...

Functions

func NewAction

func NewAction(procedure, outFile string, toJSON bool, args ...string) *models.Action

NewAction procedure defenition

func NewActionAsFile

func NewActionAsFile(procedure, outFile string, toJSON bool, args ...string) *models.Action

NewActionAsFile procedure defenition of processing as input file

func NewActionMeta

func NewActionMeta(procedure, outputTag string, toJSON bool, args ...string) *models.Action

NewActionMeta extraction data

Types

type Converter

type Converter struct {
	shell.Converter
	// contains filtered or unexported fields
}

Converter contains whole functions to convert image

func New

func New(procedureDirecory string) *Converter

New procedure converter executor

func (*Converter) Name

func (ic *Converter) Name() string

Name of the converter

func (*Converter) Process

func (ic *Converter) Process(in converters.Input, out converters.Output) error

Process input file by procedure command execution Example:

{
  "name": "procedure",
  "values": {
	 	 "name": "test.sh",
    "args": ["arg1", "arg2"],
    "tojson": true,
    "output-file": "..."
	 }
}

{{tmp}} – new file on the disk automaticaly removes after processing By default it works as STDOUT file stream

func (*Converter) Test

func (ic *Converter) Test(action *models.Action) bool

Test if action is suitable to perform

Jump to

Keyboard shortcuts

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