server

package
v0.0.0-...-e2cfa69 Latest Latest
Warning

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

Go to latest
Published: May 6, 2016 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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).

Jump to

Keyboard shortcuts

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