scalefunc

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 9 Imported by: 8

Documentation

Overview

Package scalefunc implements the Schema type, as well as any helper functions for interacting with Schema types

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrVersion  = errors.New("unknown or invalid version")
	ErrLanguage = errors.New("unknown or invalid language")
	ErrHash     = errors.New("error while verifying hash")
)
View Source
var (
	// AcceptedVersions is an array of acceptable Versions
	AcceptedVersions = []Version{V1Alpha}

	// AcceptedLanguages is an array of acceptable Languages
	AcceptedLanguages = []Language{Go, Rust, TypeScript}
)
View Source
var (
	InvalidStringRegex = regexp.MustCompile(`[^A-Za-z0-9-.]`)
)

Functions

func ValidString

func ValidString(str string) bool

ValidString returns true if the string is valid for use with Scale Functions

func Write

func Write(path string, scaleFunc *Schema) error

Write opens a file at the given path and writes the given scalefile to it

Types

type Dependency

type Dependency struct {
	Name     string            `json:"name" yaml:"name"`
	Version  string            `json:"version" yaml:"version"`
	Metadata map[string]string `json:"metadata" yaml:"metadata"`
}

Dependency is a dependency of a compiled Scale Function

type Language

type Language string

Language is the Language the Scale Function's Source Language

const (
	// Go is the Golang Source Language for Scale Functions
	Go Language = "go"

	// Rust is the Rust Source Language for Scale Functions
	Rust Language = "rust"

	// TypeScript is the TypeScript Source Language for Scale Functions
	TypeScript Language = "ts"
)

type Schema

type Schema struct {
	Version         Version                 `json:"version" yaml:"version"`
	Name            string                  `json:"name" yaml:"name"`
	Tag             string                  `json:"tag" yaml:"tag"`
	SignatureName   string                  `json:"signature_name" yaml:"signature_name"`
	SignatureSchema *signatureSchema.Schema `json:"signature_schema" yaml:"signature_schema"`
	SignatureHash   string                  `json:"signature_hash" yaml:"signature_hash"`
	Language        Language                `json:"language" yaml:"language"`
	Stateless       bool                    `json:"stateless" yaml:"stateless"`
	Dependencies    []Dependency            `json:"dependencies" yaml:"dependencies"`
	Function        []byte                  `json:"function" yaml:"function"`
	Size            uint32                  `json:"size" yaml:"size"`
	Hash            string                  `json:"hash" yaml:"hash"`
}

Schema is the type used to define the requirements of a scale function for a Scale Runtime

func Read

func Read(path string) (*Schema, error)

Read opens a file at the given path and returns a *ScaleFile

func (*Schema) Decode

func (s *Schema) Decode(data []byte) error

Decode decodes the Schema from a byte array

func (*Schema) Encode

func (s *Schema) Encode() []byte

Encode encodes the Schema into a byte array

func (*Schema) GetHash

func (s *Schema) GetHash() []byte

GetHash returns the hash of the Schema

type Version

type Version string

Version is the Version of the Schema definition

const (
	// V1Alpha is the V1 Alpha definition of a Schema
	V1Alpha Version = "v1alpha"
)

Jump to

Keyboard shortcuts

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