Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterRoutes ¶
func RegisterRoutes(e *echo.Echo, db *mgo.Database, basePieURL string, service service.RiskService, fnDelayer *FunctionDelayer)
RegisterRoutes sets up the http request handlers with Echo
Types ¶
type FunctionDelayer ¶
type FunctionDelayer struct { sync.Mutex Duration time.Duration // contains filtered or unexported fields }
FunctionDelayer manages functions, identified by keys, such that they are called after a set period of time. If a request to schedule a function call uses a key for a function that has already been scheduled, it resets the delay for that call. For example, consider a FunctionDelayer f with a configured delay of 3 seconds. If f.Delay("foo", myFunc) is invoked only once, myFunc() will be called 3 seconds later. If f.Delay("bar", myFunc) is invoked once, and then invoked again 2 seconds later, myFunc() will be called 3 seconds after the second f.Delay invocation (for a total of 5 seconds after the first f.Delay invocation).
func NewFunctionDelayer ¶
func NewFunctionDelayer(duration time.Duration) *FunctionDelayer
NewFunctionDelayer creates a new FunctionDelayer with the specified duration.
func (*FunctionDelayer) Delay ¶
func (f *FunctionDelayer) Delay(key string, fn func())
Delay schedules a function to be called after FunctionDelayer's Duration has elapsed. Subsequent calls to Delay with the same key will reset the duration timer if it is still active. Note that on these subsequent calls, the passed in function is ignored (and only the original function is invoked when the timer expires).