Documentation
¶
Overview ¶
Package useraction: handle long running actions initiated from the browser. For example, selecting a file to open. POST returns a token and value if the request times out before a valid value is available the client can poll via GET passing the token until the requested value becomes available.
Index ¶
Constants ¶
const Expiry = 1 * time.Second
max time between an initial request and the attempt to get its results. needed so that unrequested results dont take up memory; shorter seems better.
const Timeout = 120 * time.Second
approximate amount of time an http request should wait to fulfill an action. note: chrome and firefox are both 300 seconds ( 5 minutes )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dispatch ¶
uaRequest to start a new named action. Launched from a go routine, assumed to be blocking so that there's only dispatched action running at a time. For now: no parameters, and only a single string return ( ex. a filename )
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
func Start ¶
func Start(dispatch Dispatch) *Dispatcher
returns a Dispatcher that can be used by multiple http handlers if need be. rus a go routine internally
func (*Dispatcher) Get ¶
func (m *Dispatcher) Get(token Token) (ret string, err error)
given a token returned by post, see if the result is ready. err might be an http Status, or some error from the dispatcher. StatusuaRequestTimeout means the caller should try again.
func (*Dispatcher) Post ¶
func (m *Dispatcher) Post(action string) (ret Result, err error)
request that the dispatch function specified in Start() process the requested action as soon as it can; returns a valid Token if the action is still pending or in progress after some timeout. err might be an http Status, or some error from the dispatcher.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
http endpoints get results from readers.
func MakeReader ¶
result channel could be small, probably size 1 result: make(chan result, 3),