Documentation ¶
Overview ¶
Adapted from https://github.com/openfaas/templates-sdk/blob/master/go-http/handler.go Original license: MIT
Index ¶
- Constants
- Variables
- func IsErrExecuteAgain(err error) bool
- func IsErrFailed(err error) bool
- func IsErrFunction(err error) bool
- func IsErrTransient(err error) bool
- func NewActivityLogWriter(ctx context.Context, logger *slog.Logger, url, token string, ...) io.WriteCloser
- func NewErrExecuteAgain(msg string, data map[string]any) error
- func NewErrFailed(msg string) error
- func NewErrTransient(msg string) error
- type ErrFunction
- type FunctionHandler
- type FunctionSDK
- type Handler
- type Logger
- type Object
- func (r Object) GetAsString(key string) (string, bool)
- func (r Object) GetBool(keys ...string) (bool, error)
- func (r Object) GetFloat64(keys ...string) (float64, error)
- func (r Object) GetInt(keys ...string) (int, error)
- func (r Object) GetInt64(keys ...string) (int64, error)
- func (r Object) GetSlice(keys ...string) ([]interface{}, error)
- func (r Object) GetString(keys ...string) (string, error)
- func (r Object) GetStringMap(keys ...string) (Object, error)
- type ReadyResponse
- type Request
- type Response
- type SDKOption
- func WithHandler(handler Handler) SDKOption
- func WithHealthInterval(healthInterval time.Duration) SDKOption
- func WithListener(listener net.Listener) SDKOption
- func WithLogFlushRate(logFlushRate time.Duration) SDKOption
- func WithLogLevel(logLevel slog.Level) SDKOption
- func WithLogUploadRetryCount(logUploadRetryCount int) SDKOption
- func WithLogWriteTimeout(logWriteTimeout time.Duration) SDKOption
- func WithPort(port int) SDKOption
- func WithReadTimeout(readTimeout time.Duration) SDKOption
- func WithServerSkipTLSVerify(skipTLSVerify bool) SDKOption
- func WithShutdownTimeout(shutdownTimeout time.Duration) SDKOption
- func WithWriteTimeout(writeTimeout time.Duration) SDKOption
- type SDKOptions
- type WriterOption
Constants ¶
View Source
const ( ErrCodeUnspecified errorCode = iota ErrCodeExecuteAgain ErrCodeFailed ErrCodeTransient )
View Source
const ( ActivityIDHeader = "X-Activity-ID" EnvironmentIDHeader = "X-Environment-ID" EnvironmentNameHeader = "X-Environment-Name" WorkflowTokenHeader = "X-Workflow-Token" EngineAPIEndpointHeader = "X-Engine-Endpoint" ActivityFileUploadHeader = "X-Activity-File-Upload" )
Variables ¶
View Source
var WithLogReqTimeout = func(reqTimeout time.Duration) WriterOption {
return func(w *writer) {
w.reqTimeout = reqTimeout
}
}
View Source
var WithSkipTLSVerify = func(skipTLSVerify bool) WriterOption {
return func(w *writer) {
w.skipTLSVerify = skipTLSVerify
}
}
View Source
var WithWriteFlushTickRate = func(tickRate time.Duration) WriterOption {
return func(w *writer) {
w.flushTickRate = tickRate
}
}
Functions ¶
func IsErrExecuteAgain ¶
func IsErrFailed ¶
func IsErrFunction ¶
func IsErrTransient ¶
func NewActivityLogWriter ¶
func NewActivityLogWriter(ctx context.Context, logger *slog.Logger, url, token string, opts ...WriterOption) io.WriteCloser
func NewErrFailed ¶
func NewErrTransient ¶
Types ¶
type ErrFunction ¶
type ErrFunction struct { ErrCode errorCode `json:"error_code"` Message string `json:"message"` StackTrace []stackFrame `json:"stack_trace"` Data map[string]any `json:"data"` }
func AsErrFunction ¶
func AsErrFunction(err error) (*ErrFunction, bool)
func (*ErrFunction) Error ¶
func (e *ErrFunction) Error() string
type FunctionHandler ¶
type FunctionHandler interface {
Handle(ctx context.Context, logger Logger, req Request) (Response, error)
}
FunctionHandler used for a serverless Go method invocation
type FunctionSDK ¶
type FunctionSDK struct {
// contains filtered or unexported fields
}
func NewFunctionSDK ¶
func NewFunctionSDK(opts ...SDKOption) (*FunctionSDK, error)
type ReadyResponse ¶
type SDKOption ¶
type SDKOption func(*SDKOptions)
func WithHandler ¶
func WithHealthInterval ¶
func WithListener ¶
func WithLogFlushRate ¶
func WithLogLevel ¶
func WithLogUploadRetryCount ¶
func WithLogWriteTimeout ¶
func WithReadTimeout ¶
func WithServerSkipTLSVerify ¶
func WithShutdownTimeout ¶
func WithWriteTimeout ¶
type SDKOptions ¶
type SDKOptions struct { Port int Listener net.Listener Handler Handler ReadTimeout time.Duration WriteTimeout time.Duration ShutdownTimeout time.Duration HealthInterval time.Duration LogLevel slog.Level LogUploadRetryCount int LogFlushRate time.Duration LogWriteTimeout time.Duration SkipTLSVerify bool }
type WriterOption ¶
type WriterOption func(*writer)
Click to show internal directories.
Click to hide internal directories.