zamus

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetErrorType

func GetErrorType(err interface{}) string

import (

"reflect"

)

type lambdaError struct {
   ErrorMessage string `json:"errorMessage"`
   ErrorType    string `json:"errorType"`
}
func NewLambdaErrorFrom(err error) *lambdaError {
   switch e := err.(type) {
   case errors.Error:
       return &lambdaError{
           ErrorMessage: e.Error(),
           ErrorType:    e.GetCode(),
       }
   }

   return &lambdaError{
       ErrorType:    GetErrorType(err),
       ErrorMessage: err.Error(),
   }
}
func (e *lambdaError) GetCode() string {
   return e.ErrorType
}
func (e *lambdaError) Error() string {
   return e.ErrorMessage
}

Types

type BatchPostHandler

type BatchPostHandler func(ctx context.Context, payload json.RawMessage, src interface{}, res interface{}, err error) (interface{}, error)

type BatchPreHandler

type BatchPreHandler func(ctx context.Context, payload json.RawMessage, src interface{}) (interface{}, error)

type Handle

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

func New

func New(handle Handler) *Handle

func (*Handle) Invoke added in v1.0.2

func (h *Handle) Invoke(ctx context.Context, payload json.RawMessage) (result interface{}, err error)

func (*Handle) OnPanicHandler added in v1.0.2

func (h *Handle) OnPanicHandler(panicHandler PanicHandler)

func (*Handle) OnRetryFailedHandler added in v1.0.2

func (h *Handle) OnRetryFailedHandler(retryFailedHandler RetryFailedHandler)

func (*Handle) RegisterBatchPostHandler added in v1.0.2

func (h *Handle) RegisterBatchPostHandler(batchPostHandlers ...BatchPostHandler)

func (*Handle) RegisterBatchPreHandler added in v1.0.2

func (h *Handle) RegisterBatchPreHandler(batchPreHandlers ...BatchPreHandler)

func (*Handle) RegisterPostHandler added in v1.0.2

func (h *Handle) RegisterPostHandler(postHandlers ...PostHandler)

func (*Handle) RegisterPreHandler added in v1.0.2

func (h *Handle) RegisterPreHandler(preHandlers ...PreHandler)

func (*Handle) Run added in v1.0.2

func (h *Handle) Run(ctx context.Context, payload json.RawMessage, src interface{}, isBatch bool) (interface{}, error)

func (*Handle) SetRetry added in v1.0.2

func (h *Handle) SetRetry(times int)

type Handler added in v1.0.1

type Handler interface {
	ParseSource(ctx context.Context, payload json.RawMessage) interface{}
	ParseSources(ctx context.Context, payload json.RawMessage) interface{}
	Handler(ctx context.Context, source interface{}) (interface{}, error)
	BatchHandler(ctx context.Context, sources interface{}) (interface{}, error)
}

type PanicHandler

type PanicHandler func(ctx context.Context, payload json.RawMessage, err error) (interface{}, error)

type PostHandler

type PostHandler func(ctx context.Context, payload json.RawMessage, src interface{}, res interface{}, err error) (interface{}, error)

type PreHandler

type PreHandler func(ctx context.Context, payload json.RawMessage, src interface{}) (interface{}, error)

type Retries

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

func NewRetries

func NewRetries(times int) *Retries

func (*Retries) Reset

func (r *Retries) Reset()

func (*Retries) Retry

func (r *Retries) Retry() bool

func (*Retries) SetTimes

func (r *Retries) SetTimes(times int)

type RetryFailedHandler

type RetryFailedHandler func(ctx context.Context, payload json.RawMessage, src interface{}, err error) (interface{}, error)

type SourceList

type SourceList interface{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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