function

package
v0.2.2 Latest Latest
Warning

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

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

Documentation

Overview

Package golang provides an interface to write UDF in golang which will be exposed over HTTP. It accepts a handler of the following definition

func(ctx context.Context, key, msg []byte) (messages Messages, err error)

which will be invoked for message. If error is returned, the HTTP StatusCode will be set to 500.

Index

Constants

This section is empty.

Variables

View Source
var (
	DROP = fmt.Sprintf("%U__DROP__", '\\') // U+005C__DROP__
	ALL  = fmt.Sprintf("%U__ALL__", '\\')  // U+005C__ALL__
)

Functions

func Start

func Start(ctx context.Context, handler Handle, opts ...Option)

Start starts the HTTP Server after registering the handler at `/messages` endpoint.

Types

type Handle

type Handle func(ctx context.Context, key, msg []byte) (Messages, error)

type Message

type Message struct {
	Key   []byte
	Value []byte
}

Message is used to wrap the data return by UDF functions

func MessageTo

func MessageTo(to string, value []byte) Message

MessageTo creates a Message that will forward to specified "to"

func MessageToAll

func MessageToAll(value []byte) Message

MessageToAll creates a Message that will forward to all

func MessageToDrop

func MessageToDrop() Message

MessageToDrop creates a Message to be dropped

type Messages

type Messages []Message

func MessagesBuilder

func MessagesBuilder() Messages

MessagesBuilder returns an empty instance of Messages

func (Messages) Append

func (m Messages) Append(msg Message) Messages

Append appends a Message

func (Messages) Items

func (m Messages) Items() []Message

Items returns the message list

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option to apply different options

func WithDrainTimeout

func WithDrainTimeout(f time.Duration) Option

WithDrainTimeout sets a max drain timeout time. It is the maximum time we will wait for the connection to drain out once we have initiated the shutdown sequence. Default is 1 minute.

Jump to

Keyboard shortcuts

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