agent

package
v0.0.0-...-2f584b8 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 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
y or Y : Canonical URL