runtime

package
v0.26.2 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: Apache-2.0 Imports: 48 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MinRequestTTL    = 5 * time.Second
	MaxResponseTTL   = 1 * time.Hour
	HTTPTimeout      = 5 * time.Second
	MaxResponseBytes = 20 * 1024 * 1024 // 20MB
	HTTPCachePrefix  = "httpcache"
)
View Source
const DefaultExpirationSeconds = 60

Variables

This section is empty.

Functions

func DetermineTTL added in v0.26.0

func DetermineTTL(req *http.Request, resp *http.Response) time.Duration

DetermineTTL determines the TTL for a request based on the request and response. We first check request method / response status code to determine if we should actually cache the response. Then we check the headers passed in from starlark to see if the user configured a TTL. Finally, if the response is cachable but the developer didn't configure a TTL, we check the response to get a hint at what the TTL should be.

func InitCache

func InitCache(c Cache)

func InitHTTP added in v0.26.0

func InitHTTP(cache Cache)

func LoadCacheModule

func LoadCacheModule() (starlark.StringDict, error)

func LoadSecretModule added in v0.13.2

func LoadSecretModule() (starlark.StringDict, error)

Types

type Applet

type Applet struct {
	Filename            string
	Id                  string
	Globals             starlark.StringDict
	SecretDecryptionKey *SecretDecryptionKey
	// contains filtered or unexported fields
}

func (*Applet) Call

func (a *Applet) Call(callable *starlark.Function, args starlark.Tuple, initializers ...ThreadInitializer) (val starlark.Value, err error)

Calls any callable from Applet.Globals. Pass args and receive a starlark Value, or an error if you're unlucky.

func (*Applet) CallSchemaHandler added in v0.10.0

func (app *Applet) CallSchemaHandler(ctx context.Context, handlerName, parameter string) (result string, err error)

CallSchemaHandler calls a schema handler, passing it a single string parameter and returning a single string value.

func (*Applet) GetSchema added in v0.10.0

func (app *Applet) GetSchema() string

GetSchema returns the config for the applet.

func (*Applet) Load

func (a *Applet) Load(filename string, src []byte, loader ModuleLoader) (err error)

Loads an applet. The script filename is used as a descriptor only, and the actual code should be passed in src. Optionally also pass loader to make additional starlark modules available to the script.

func (*Applet) Run

func (a *Applet) Run(config map[string]string, initializers ...ThreadInitializer) (roots []render.Root, err error)

Runs the applet's main function, passing it configuration as a starlark dict.

type AppletConfig added in v0.12.0

type AppletConfig map[string]string

func (AppletConfig) Attr added in v0.12.0

func (a AppletConfig) Attr(name string) (starlark.Value, error)

func (AppletConfig) AttrNames added in v0.12.0

func (a AppletConfig) AttrNames() []string

func (AppletConfig) Freeze added in v0.12.0

func (a AppletConfig) Freeze()

func (AppletConfig) Get added in v0.12.0

func (AppletConfig) Hash added in v0.12.0

func (a AppletConfig) Hash() (uint32, error)

func (AppletConfig) String added in v0.12.0

func (a AppletConfig) String() string

func (AppletConfig) Truth added in v0.12.0

func (a AppletConfig) Truth() starlark.Bool

func (AppletConfig) Type added in v0.12.0

func (a AppletConfig) Type() string

type Cache

type Cache interface {
	Set(thread *starlark.Thread, key string, value []byte, ttl int64) error
	Get(thread *starlark.Thread, key string) ([]byte, bool, error)
}

type InMemoryCache

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

func NewInMemoryCache

func NewInMemoryCache() *InMemoryCache

func (*InMemoryCache) Get

func (c *InMemoryCache) Get(_ *starlark.Thread, key string) (value []byte, found bool, err error)

func (*InMemoryCache) Set

func (c *InMemoryCache) Set(_ *starlark.Thread, key string, value []byte, ttl int64) error

type InMemoryCacheRecord

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

type ModuleLoader

type ModuleLoader func(*starlark.Thread, string) (starlark.StringDict, error)

type SecretDecryptionKey added in v0.13.0

type SecretDecryptionKey struct {
	// EncryptedKeysetJSON is the encrypted JSON representation of a Tink keyset.
	EncryptedKeysetJSON []byte

	// KeyEncryptionKey is a Tink key that can be used to decrypt the keyset.
	KeyEncryptionKey tink.AEAD
}

SecretDecryptionKey is a key that can be used to decrypt secrets.

type SecretEncryptionKey added in v0.13.0

type SecretEncryptionKey struct {
	// PublicKeysetJSON is the serialized JSON representation of a Tink keyset.
	PublicKeysetJSON []byte
}

SecretEncryptionKey is a key that can be used to encrypt secrets, but not decrypt them.

func (*SecretEncryptionKey) Encrypt added in v0.13.0

func (sek *SecretEncryptionKey) Encrypt(appName, plaintext string) (string, error)

Encrypt encrypts a value for use as a secret in an app. Provide both a value and the name of the app the encrypted secret will be used in. The value will only be usable with the specified app.

type ThreadInitializer added in v0.5.1

type ThreadInitializer func(thread *starlark.Thread) *starlark.Thread

ThreadInitializer is called when building a Starlark thread to run an applet on. It can customize the thread by overriding behavior or attaching thread local data.

Directories

Path Synopsis
modules

Jump to

Keyboard shortcuts

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