scalefunc

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: Apache-2.0 Imports: 11 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 (
	// 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 *V1BetaSchema) error

func WriteV1Alpha deprecated added in v0.4.6

func WriteV1Alpha(path string, scaleFunc *V1AlphaSchema) error

WriteV1Alpha opens a file at the given path and writes the given WriteV1Alpha to it

Deprecated: Use V1BetaSchema instead

func WriteV1Beta added in v0.4.6

func WriteV1Beta(path string, scaleFunc *V1BetaSchema) error

WriteV1Beta opens a file at the given path and writes the given V1BetaSchema to it

Types

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 V1AlphaDependency added in v0.4.6

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

V1AlphaDependency is a dependency of a compiled Scale Function

type V1AlphaSchema added in v0.4.6

type V1AlphaSchema struct {
	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    []V1AlphaDependency     `json:"dependencies" yaml:"dependencies"`
	Function        []byte                  `json:"function" yaml:"function"`
	Size            uint32                  `json:"size" yaml:"size"`
	Hash            string                  `json:"hash" yaml:"hash"`
}

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

func ReadV1Alpha deprecated added in v0.4.6

func ReadV1Alpha(path string) (*V1AlphaSchema, error)

ReadV1Alpha opens a file at the given path and returns a *WriteV1Alpha

Deprecated: Use V1BetaSchema instead

func (*V1AlphaSchema) Decode added in v0.4.6

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

Decode decodes the Schema from a byte array

func (*V1AlphaSchema) Encode deprecated added in v0.4.6

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

Encode encodes the Schema into a byte array

Deprecated: Use V1BetaSchema instead

func (*V1AlphaSchema) GetHash added in v0.4.6

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

GetHash returns the hash of the Schema

type V1BetaExtension added in v0.4.6

type V1BetaExtension struct {
	Name         string                  `json:"name" yaml:"name"`
	Organization string                  `json:"organization" yaml:"organization"`
	Tag          string                  `json:"tag" yaml:"tag"`
	Schema       *extensionSchema.Schema `json:"schema" yaml:"schema"`
	Hash         string                  `json:"hash" yaml:"hash"`
}

V1BetaExtension defines the extensions used by a Scale Function

type V1BetaSchema added in v0.4.6

type V1BetaSchema struct {
	Name       string            `json:"name" yaml:"name"`
	Tag        string            `json:"tag" yaml:"tag"`
	Signature  V1BetaSignature   `json:"signature" yaml:"signature"`
	Extensions []V1BetaExtension `json:"extensions" yaml:"extensions"`
	Language   Language          `json:"language" yaml:"language"`
	Manifest   []byte            `json:"manifest" yaml:"manifest"`
	Stateless  bool              `json:"stateless" yaml:"stateless"`
	Function   []byte            `json:"function" yaml:"function"`
	Size       uint32            `json:"size" yaml:"size"`
	Hash       string            `json:"hash" yaml:"hash"`
}

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

func Read

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

func ReadV1Beta added in v0.4.6

func ReadV1Beta(path string) (*V1BetaSchema, error)

ReadV1Beta opens a file at the given path and returns a *V1BetaSchema

func (*V1BetaSchema) Decode added in v0.4.6

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

Decode decodes the Schema from a byte array

func (*V1BetaSchema) Encode added in v0.4.6

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

Encode encodes the Schema into a byte array

func (*V1BetaSchema) GetHash added in v0.4.6

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

GetHash returns the hash of the Schema

type V1BetaSignature added in v0.4.6

type V1BetaSignature struct {
	Name         string                  `json:"name" yaml:"name"`
	Organization string                  `json:"organization" yaml:"organization"`
	Tag          string                  `json:"tag" yaml:"tag"`
	Schema       *signatureSchema.Schema `json:"schema" yaml:"schema"`
	Hash         string                  `json:"hash" yaml:"hash"`
}

V1BetaSignature defines the signature used by a Scale Function

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"

	// V1Beta is the V1 Beta definition of a Schema
	V1Beta Version = "v1beta"
)

Jump to

Keyboard shortcuts

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