config

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package config contains the configuration structs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArnAsString added in v1.2.0

func ArnAsString(arnPtr *arn.ARN) string

ArnAsString conversion.

func Validate

func Validate(config any) error

Validate the Server config.

Types

type ARN

type ARN struct {
	arn.ARN
}

ARN suitable for JSON unmarshalling.

func (*ARN) UnmarshalJSON

func (a *ARN) UnmarshalJSON(bytes []byte) error

func (*ARN) UnmarshalYAML

func (a *ARN) UnmarshalYAML(value *yaml.Node) error

type AWS added in v1.4.0

type AWS struct {
	// Retry configuration.
	Retry *AWSRetry `json:"retry,omitempty" yaml:"retry,omitempty" validate:"omitempty"`
}

AWS configuration.

func (*AWS) Apply added in v1.4.0

func (a *AWS) Apply(cfg *aws.Config)

type AWSRetry added in v1.4.0

type AWSRetry struct {
	// MaxBackoff Duration for a retry.
	MaxBackoff Duration `json:"maxBackoff,omitempty" yaml:"maxBackoff,omitempty" validate:"omitempty"`
	// MaxAttempts for a request.
	MaxAttempts int `json:"maxAttempts,omitempty" yaml:"maxAttempts,omitempty" validate:"omitempty"`
	// RateLimiter configuration.
	RateLimiter AWSRetryRateLimiter `json:"rateLimiter,omitempty" yaml:"rateLimiter,omitempty" validate:"omitempty"`
}

AWSRetry configuration.

func (*AWSRetry) Apply added in v1.4.0

func (r *AWSRetry) Apply(cfg *aws.Config)

type AWSRetryRateLimiter added in v1.5.0

type AWSRetryRateLimiter struct {
	// RetryCost to deduct from the token bucket per retry.
	RetryCost uint `json:"retryCost,omitempty" yaml:"retryCost,omitempty" validate:"omitempty"`
	// RetryTimeoutCost to deduct from the token bucket per retry caused by timeout error.
	RetryTimeoutCost uint `json:"retryTimeoutCost,omitempty" yaml:"retryTimeoutCost,omitempty" validate:"omitempty"`
	// NoRetryIncrement to pay back to the token bucket for successful attempts.
	NoRetryIncrement uint `json:"noRetryIncrement,omitempty" yaml:"noRetryIncrement,omitempty" validate:"omitempty"`
	// Tokens to be obtained.
	Tokens uint `json:"tokens,omitempty" yaml:"tokens,omitempty" validate:"omitempty" map:"-"`
}

AWSRetryRateLimiter config.

type Duration added in v1.3.0

type Duration struct {
	time.Duration
}

func (*Duration) MarshalJSON added in v1.4.1

func (d *Duration) MarshalJSON() ([]byte, error)

func (*Duration) MarshalYAML added in v1.4.1

func (d *Duration) MarshalYAML() (interface{}, error)

func (*Duration) UnmarshalJSON added in v1.3.0

func (d *Duration) UnmarshalJSON(bytes []byte) error

func (*Duration) UnmarshalYAML added in v1.3.0

func (d *Duration) UnmarshalYAML(value *yaml.Node) error

type Function

type Function struct {
	// Name of the function.
	Name string `json:"name,omitempty" yaml:"name,omitempty" validate:"required_without=ARN,excluded_with=ARN"`
	// ARN of the function to be invoked.
	// Deprecated: use Name.
	ARN *LambdaARN `json:"arn,omitempty" yaml:"arn,omitempty" validate:"required_without=Name,excluded_with=Name"`
	// InvocationRole
	InvocationRole *RoleARN `json:"invocationRole,omitempty" yaml:"invocationRole,omitempty" validate:"omitempty"`
	// Routes to be added for that function.
	Routes []Route `json:"routes" yaml:"routes" validate:"min=1,dive"`
	// Timeout for the function invocation.
	Timeout Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"`
}

Function providing the lambda function and routes.

func (*Function) GetInvocationRoleARN added in v1.2.0

func (f *Function) GetInvocationRoleARN() *arn.ARN

GetInvocationRoleARN of the function.

func (*Function) GetName added in v1.2.0

func (f *Function) GetName() string

GetName of the function.

type HTTP added in v1.3.0

type HTTP struct {
	// ReadTimeout for http.Server
	ReadTimeout Duration `json:"readTimeout,omitempty" yaml:"readTimeout,omitempty"`
	// ReadHeaderTimeout for http.Server
	ReadHeaderTimeout Duration `json:"readHeaderTimeout,omitempty" yaml:"readHeaderTimeout,omitempty"`
	// WriteTimeout for http.Server
	WriteTimeout Duration `json:"writeTimeout,omitempty" yaml:"writeTimeout,omitempty"`
	// EnableTraceparent injects traceparent.
	EnableTraceparent bool `json:"enableTraceparent,omitempty" yaml:"enableTraceparent,omitempty"`
}

HTTP config.

type LambdaARN

type LambdaARN struct{ ARN }

LambdaARN type alias for validation.

type RoleARN added in v1.2.0

type RoleARN struct{ ARN }

RoleARN type alias for validation.

type Route

type Route struct {
	// Name for the route (optional).
	Name string `json:"name,omitempty" yaml:"name,omitempty"`
	// Host for the route (optional)
	Host string `json:"host,omitempty" yaml:"host,omitempty"`
	// Methods for the route (optional)
	Methods []string `json:"methods,omitempty" yaml:"methods,omitempty"`
	// Path for the route (either that or PathPrefix).
	Path string `json:"path,omitempty" yaml:"path,omitempty" validate:"required_without=PathPrefix"`
	// PathPrefix for the route (either that or Path).
	PathPrefix string `json:"pathPrefix,omitempty" yaml:"pathPrefix,omitempty" validate:"required_without=Path"`
	// Headers for the route (optional).
	Headers map[string]string `json:"headers,omitempty" yaml:"headers,omitempty" validate:"dive,keys,required,endkeys"`
	// HeadersRegexp for the route (optional).
	HeadersRegexp map[string]string `json:"headersRegexp" yaml:"headersRegexp" validate:"dive,keys,required,endkeys,required"` //nolint:lll // tags.
}

Route configuration.

type Server

type Server struct {
	// DisableValidation disables the validation of the function using a dry-run invocation.
	DisableValidation bool `json:"disableValidation,omitempty" yaml:"disableValidation,omitempty"`
	// HTTP configuration
	HTTP HTTP `json:"http,omitempty" yaml:"http,omitempty"`
	// AWS configuration
	AWS *AWS `json:"aws,omitempty" yaml:"aws,omitempty"`
	// Functions providing the Function.
	Functions []Function `json:"functions" yaml:"functions" validate:"required,dive"`
}

Server for the handler.

func Read

func Read(ctx context.Context, filename string) (*Server, error)

Read from filename.

Jump to

Keyboard shortcuts

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