handler

package
v0.0.0-...-de1ab33 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2019 License: BSD-2-Clause Imports: 20 Imported by: 0

Documentation

Overview

The handler package allows managing Kappa handlers, an abstraction on top of serverless handlers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeCoordCallResult

func EncodeCoordCallResult(res CCResT) ([]byte, error)

Types

type AppEvT

type AppEvT interface{} // Type of application events.

type CCResT

type CCResT interface{} // Return type of coordinator calls.

TODO(zhangwen): using interface{} liberally is worrisome.

type CoordCall

type CoordCall struct {
	Seqno  SeqnoT              `json:"seqno"`
	Op     string              `json:"op"`
	Params easyjson.RawMessage `json:"params"`
}

CoordCall is the format of a single coordinator call inside a request to the coordinator.

func (CoordCall) MarshalEasyJSON

func (v CoordCall) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (CoordCall) MarshalJSON

func (v CoordCall) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*CoordCall) UnmarshalEasyJSON

func (v *CoordCall) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*CoordCall) UnmarshalJSON

func (v *CoordCall) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type CrashedError

type CrashedError struct {
	ErrorMessage string
}

CrashedError is returned when a handler has crashed (e.g., due to an uncaught exception).

func (*CrashedError) Error

func (e *CrashedError) Error() string

type EnvT

type EnvT map[string]string

type Handler

type Handler interface {
	// Returns a channel to read the invocation result from; the channel is closed after the result is written to it.
	InvokeAsync(pid PidT, seqno SeqnoT, chkID string, ccRes CCResT, appEv AppEvT, target InvokeTarget) <-chan InvokeRet

	// Finalize cleans up allocated resources.  Any error encountered during cleanup is logged but ignored.
	Finalize()
}

func Create

func Create(platform string, conf io.Reader, name string, deployedFiles []string, timeoutSecs int,
	env EnvT, logWriter io.Writer) (Handler, error)

type InvokeRet

type InvokeRet struct {
	Req *Request
	Err error
}

type InvokeTarget

type InvokeTarget int
const (
	OnCoordinator InvokeTarget = iota
	OnLambda
)

type PidT

type PidT int // Overflow is unlikely.

type Request

type Request struct {
	Pid     PidT        `json:"pid"`
	Seqno   SeqnoT      `json:"seqno"`
	ChkID   string      `json:"chk_id"`
	Calls   []CoordCall `json:"calls"`
	Blocked bool        `json:"blocked"`
	Err     *string     `json:"err"`
}

Request is the format of a handler's request to the coordinator.

func ParseRequest

func ParseRequest(b []byte) (*Request, error)

func (Request) MarshalEasyJSON

func (v Request) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Request) MarshalJSON

func (v Request) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Request) UnmarshalEasyJSON

func (v *Request) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Request) UnmarshalJSON

func (v *Request) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type SeqnoT

type SeqnoT int

type TimeoutError

type TimeoutError struct{}

TimeoutError is returned when a handler has been killed by timeout.

func (*TimeoutError) Error

func (*TimeoutError) Error() string

Jump to

Keyboard shortcuts

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