Documentation ¶
Index ¶
- Constants
- func DetermineTTL(req *http.Request, resp *http.Response) time.Duration
- func ExtractRoots(val starlark.Value) ([]render.Root, error)
- func InitCache(c Cache)
- func InitHTTP(cache Cache)
- func LoadCacheModule() (starlark.StringDict, error)
- func LoadSecretModule() (starlark.StringDict, error)
- type Applet
- func (a *Applet) Call(ctx context.Context, callable *starlark.Function, args ...starlark.Value) (val starlark.Value, err error)
- func (app *Applet) CallSchemaHandler(ctx context.Context, handlerName, parameter string) (result string, err error)
- func (a *Applet) PathsForBundle() []string
- func (a *Applet) Run(ctx context.Context) (roots []render.Root, err error)
- func (app *Applet) RunTests(t *testing.T)
- func (a *Applet) RunWithConfig(ctx context.Context, config map[string]string) (roots []render.Root, err error)
- type AppletConfig
- func (a AppletConfig) Attr(name string) (starlark.Value, error)
- func (a AppletConfig) AttrNames() []string
- func (a AppletConfig) Freeze()
- func (a AppletConfig) Get(key starlark.Value) (starlark.Value, bool, error)
- func (a AppletConfig) Hash() (uint32, error)
- func (a AppletConfig) String() string
- func (a AppletConfig) Truth() starlark.Bool
- func (a AppletConfig) Type() string
- type AppletOption
- type Cache
- type InMemoryCache
- type InMemoryCacheRecord
- type ModuleLoader
- type PrintFunc
- type SecretDecryptionKey
- type SecretEncryptionKey
- type ThreadInitializer
Constants ¶
const ( MinRequestTTL = 5 * time.Second MaxResponseTTL = 1 * time.Hour HTTPTimeout = 5 * time.Second MaxResponseBytes = 20 * 1024 * 1024 // 20MB HTTPCachePrefix = "httpcache" TTLHeader = "X-Tidbyt-Cache-Seconds" )
const DefaultExpirationSeconds = 60
Variables ¶
This section is empty.
Functions ¶
func DetermineTTL ¶ added in v0.26.0
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 ExtractRoots ¶ added in v0.33.4
ExtractRoots extracts render roots from a Starlark value. It expects the value to be either a single render root or a list of render roots.
It's used internally by RunWithConfig to extract the roots returned by the applet.
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 { ID string Globals map[string]starlark.StringDict MainFile string Schema *schema.Schema SchemaJSON []byte // contains filtered or unexported fields }
func NewApplet ¶ added in v0.31.0
func NewApplet(id string, src []byte, opts ...AppletOption) (*Applet, error)
func NewAppletFromFS ¶ added in v0.32.0
func (*Applet) Call ¶
func (a *Applet) Call(ctx context.Context, callable *starlark.Function, args ...starlark.Value) (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) PathsForBundle ¶ added in v0.32.0
PathsForBundle returns a list of all the paths that have been loaded by the applet. This is useful for creating a bundle of the applet.
func (*Applet) Run ¶
Run executes the applet's main function. It returns the render roots that are returned by the applet.
func (*Applet) RunTests ¶ added in v0.31.0
RunTests runs all test functions that are defined in the applet source.
func (*Applet) RunWithConfig ¶ added in v0.31.0
func (a *Applet) RunWithConfig(ctx context.Context, config map[string]string) (roots []render.Root, err error)
RunWithConfig exceutes the applet's main function, passing it configuration as a starlark dict. It returns the render roots that are returned by the applet.
type AppletConfig ¶ added in v0.12.0
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) 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 AppletOption ¶ added in v0.31.0
func WithModuleLoader ¶ added in v0.31.0
func WithModuleLoader(loader ModuleLoader) AppletOption
func WithPrintDisabled ¶ added in v0.31.0
func WithPrintDisabled() AppletOption
func WithPrintFunc ¶ added in v0.31.0
func WithPrintFunc(print PrintFunc) AppletOption
func WithSecretDecryptionKey ¶ added in v0.31.0
func WithSecretDecryptionKey(key *SecretDecryptionKey) AppletOption
func WithThreadInitializer ¶ added in v0.31.0
func WithThreadInitializer(init ThreadInitializer) AppletOption
type InMemoryCache ¶
type InMemoryCache struct {
// contains filtered or unexported fields
}
func NewInMemoryCache ¶
func NewInMemoryCache() *InMemoryCache
type InMemoryCacheRecord ¶
type InMemoryCacheRecord struct {
// contains filtered or unexported fields
}
type ModuleLoader ¶
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(appID, plaintext string) (string, error)
Encrypt encrypts a value for use as a secret in an app. Provide both a value and the ID of the app the encrypted secret will be used in. The value will only be usable with the specified app.