memphis

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateFunction

func CreateFunction(eventHandler HandlerType, options ...PayloadOption)

This function creates a Memphis function and processes events with the passed-in eventHandler function. eventHandler gets the message payload as []byte or as the user specified type, message headers as map[string]string and inputs as map[string]string and should return the modified payload and headers. The modified payload type will either be the user type, or []byte depending on user requirements. error should be returned if the message should be considered failed and go into the dead-letter station. if all returned values are nil the message will be filtered out from the station.

func UnmarshalIntoStruct added in v1.5.0

func UnmarshalIntoStruct(data []byte, userStruct any) error

Types

type HandlerType added in v1.5.0

type HandlerType func(any, map[string]string, map[string]string) (any, map[string]string, error)

HandlerType functions get the message payload as []byte (or any), message headers as map[string]string and inputs as map[string]string and should return the modified payload and headers. error should be returned if the message should be considered failed and go into the dead-letter station. if all returned values are nil the message will be filtered out of the station.

type MemphisEvent

type MemphisEvent struct {
	Inputs   map[string]string `json:"inputs"`
	Messages []MemphisMsg      `json:"messages"`
}

type MemphisMsg

type MemphisMsg struct {
	Headers map[string]string `json:"headers"`
	Payload string            `json:"payload"`
}

type MemphisMsgWithError

type MemphisMsgWithError struct {
	Headers map[string]string `json:"headers"`
	Payload string            `json:"payload"`
	Error   string            `json:"error"`
}

type MemphisOutput

type MemphisOutput struct {
	Messages       []MemphisMsg          `json:"messages"`
	FailedMessages []MemphisMsgWithError `json:"failed_messages"`
}

type PayloadOption added in v1.5.0

type PayloadOption func(*PayloadOptions) error

func PayloadAsJSON added in v1.5.0

func PayloadAsJSON(schema any) PayloadOption

type PayloadOptions added in v1.5.0

type PayloadOptions struct {
	Handler     HandlerType
	UserStruct  any
	PayloadType PayloadTypes
}

type PayloadTypes added in v1.5.0

type PayloadTypes int
const (
	BYTES PayloadTypes = iota + 1
	JSON
)

Jump to

Keyboard shortcuts

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