runner

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExitTimeout     = -1
	ExitACK         = 0
	ExitFailed      = 1
	ExitNACK        = 3
	ExitNACKRequeue = 4
	ExitRetry       = 5
)

Exit constants used to know how handle the message. The consumer runnig is the responsible to understand this status and handle them properly.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Type         string        `mapstructure:"type"`
	IgnoreOutput bool          `mapstructure:"ignore-output"`
	Options      Options       `mapstructure:"options"`
	Timeout      time.Duration `mapstructure:"timeout"`
}

Config is an composition of options and configurations used by this runnables.

type Error added in v0.6.0

type Error struct {
	Err        error
	StatusCode int
	Output     []byte
}

Error describes an error during the Process phase.

func (*Error) Error added in v0.6.0

func (e *Error) Error() string

type Headers added in v0.7.0

type Headers map[string]interface{}

Headers are a map with key and values used do pass parameters to runners Every runner can choose how to handle the headers values but they will only support these types:

bool
float32
float64
int
int16
int32
int64
string
time.Time
[]byte

type Message added in v0.6.0

type Message struct {
	Body    []byte
	Headers Headers
}

Message is an container struct with an body and headers

type Options

type Options struct {
	// Command options
	Path string   `mapstructure:"path"`
	Args []string `mapstructure:"args"`
	// HTTP options
	URL         string            `mapstructure:"url"`
	ReturnOn5xx int               `mapstructure:"return-on-5xx" default:"4"`
	Headers     map[string]string `mapstructure:"headers" default:"{}"`
}

Options is a composition os all options used internally by runners. options not needed by one runner will be ignored.

type Runnable

type Runnable interface {
	Process(context.Context, Message) (int, error)
}

Runnable represent an runnable used by consumers to handle messages.

func New

func New(c Config, h *hub.Hub) (Runnable, error)

New create and return a Runnable based on the config type. if the type didn't exist an error is returned.

Jump to

Keyboard shortcuts

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