agent

package
Version: v0.0.0-...-5b0139b Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Unauthorized     = makeErrorResponder(401)
	NotFound         = makeErrorResponder(404)
	BadRequest       = makeErrorResponder(400)
	MethodNotAllowed = makeErrorResponder(405)
	InternalError    = makeErrorResponder(500)
	NotImplemented   = makeErrorResponder(501)
	Forbidden        = makeErrorResponder(403)
	Conflict         = makeErrorResponder(409)
)

standard error responses

Functions

This section is empty.

Types

type Command

type Command struct {
	Path string

	GET    ResponseFunc
	PUT    ResponseFunc
	POST   ResponseFunc
	DELETE ResponseFunc
	// contains filtered or unexported fields
}

A Command routes a request to an individual per-verb ResponseFunc

func (*Command) ServeHTTP

func (c *Command) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Response

type Response interface {
	ServeHTTP(w http.ResponseWriter, r *http.Request)
}

Response knows how to serve itself, and how to find itself

func AsyncResponse

func AsyncResponse(result map[string]interface{}) Response

AsyncResponse builds an "async" response from the given *Task

func SyncResponse

func SyncResponse(result interface{}) Response

SyncResponse builds a "sync" response from the given result.

type ResponseFunc

type ResponseFunc func(*Command, *http.Request) Response

A ResponseFunc handles one of the individual verbs for a method

type ResponseType

type ResponseType string

ResponseType is the response type

const (
	ResponseTypeSync  ResponseType = "sync"
	ResponseTypeAsync ResponseType = "async"
	ResponseTypeError ResponseType = "error"
)

"there are three standard return types: Standard return value, Background operation, Error", each returning a JSON object with the following "type" field:

type SessionAgent

type SessionAgent struct {
	Version string

	IdleTimeout time.Duration
	// contains filtered or unexported fields
}

func New

func New() (*SessionAgent, error)

func (*SessionAgent) Dying

func (s *SessionAgent) Dying() <-chan struct{}

func (*SessionAgent) Init

func (s *SessionAgent) Init() error

func (*SessionAgent) Start

func (s *SessionAgent) Start()

func (*SessionAgent) Stop

func (s *SessionAgent) Stop() error

Stop performs a graceful shutdown of the session agent and waits up to 5 seconds for it to complete.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL