messages

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2025 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

View Source
const (

	//MaxPayloadSize is hard coded max size of each event can carray
	MaxPayloadSize = 6 << 20 // 6 MB
	// MaxTimeout is max execution time enfoced by runtime
	MaxTimeout = 4 * time.Hour
	// DefaultJobTimeout is hard coded max timeout for a task, same as AWS
	DefaultJobTimeout = 9 * time.Minute
)

Variables

View Source
var (
	// PingMsg bytes of ping action message
	PingMsg = []byte("{\"a\":\"_ping\"}\r\n")

	// TokenCRLF is token of \r\n
	TokenCRLF = []byte{'\r', '\n'}
)

Functions

func GetErrActionBytes

func GetErrActionBytes(err error) (bts []byte)

GetErrActionBytes create action bytes of a error

func MustFromObject

func MustFromObject(obj interface{}) json.RawMessage

MustFromObject creates new from a object

Types

type Action

type Action struct {
	Type    MessageType     `json:"a"`
	Payload json.RawMessage `json:"p,omitempty"`
}

Action is basic unit between loader and a func {"a":"req","p":"hello world"}\r\n

type ErrorMessage

type ErrorMessage struct {
	Message    string        `json:"errorMessage"`
	Type       string        `json:"errorType,omitempty"`
	StackTrace []interface{} `json:"stackTrace,omitempty"`
	Fatal      bool          `json:"fatal"`
}

ErrorMessage wraps error information during a invocation

func GetErrorMessage

func GetErrorMessage(err error) *ErrorMessage

GetErrorMessage creates ErrorMessage from given golang error

func (ErrorMessage) Error

func (em ErrorMessage) Error() string

Error implements error interface

type InvokeRequest

type InvokeRequest struct {
	Args      json.RawMessage        `json:"args"`
	RequestID string                 `json:"rid,omitempty"`
	TraceID   string                 `json:"tid,omitempty"`
	Deadline  time.Time              `json:"deadline,omitempty"`
	User      string                 `json:"user,omitempty"`
	Options   map[string]interface{} `json:"options,omitempty"`
}

InvokeRequest wraps data pass to function invocation

type InvokeResponse

type InvokeResponse struct {
	Payload json.RawMessage `json:"payload,omitempty"`
	Error   *ErrorMessage   `json:"error,omitempty"`
	// Content type of payload
	ContentType string `json:"ContentType,omitempty"`
}

InvokeResponse is the message returns from a function

type MessageType

type MessageType string

MessageType alias type for event's type

const (
	// The payload is a request object
	Request MessageType = "req"
	// The payload is a response object
	Response MessageType = "rsp"
	// The payload is a emitted message
	Emit MessageType = "emit"
	// The payload is a logging line
	Log MessageType = "log"
	// Indicates the communication end with a error
	Error MessageType = "err"
	// Ping action
	Ping MessageType = "_ping"
)

Predefined actions

type StackFrame

type StackFrame struct {
	Path  string      `json:"path"`
	Line  json.Number `json:"line"`
	Label string      `json:"label,omitempty"`
}

StackFrame is frame information of a exception

Jump to

Keyboard shortcuts

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