util

package
v0.0.0-...-ef8ae41 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2017 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigfwdProxyPortURL = "configcompletefwdp"

Variables

This section is empty.

Functions

func Contains

func Contains(slice []string, target string) bool

Contains return whether the target string is found in the slice.

func Debounce

func Debounce(inChan chan interface{}, outChan chan []interface{}, window time.Duration)

Debounce() packs all elements received from channel `inChan` within the specified time window to one slice, and send it to channel `outChan` periodically. If nothing is received in the time window, nothing will be sent to `outChan`.

func DistributeEvents

func DistributeEvents(deliverChan <-chan interface{}, addSubscriber chan chan interface{})

distributeEvents() receives elements from deliverChan, and send them to subscribers Sending a `chan interface{}` to addSubscriber adds a new subscriber. It closes the subscriber channel after sending the element. `go DistributeEvents(deliverChan, addSubscriber)` should be called during API initialization. Any subscriber sent to `addSubscriber` should be buffered chan.

func GenerateUUID

func GenerateUUID() string

func IsValidUUID

func IsValidUUID(id string) bool

func LongPolling

func LongPolling(w http.ResponseWriter, timeout time.Duration, addSubscriber chan chan interface{}, successHandler func(interface{}, http.ResponseWriter), timeoutHandler func(http.ResponseWriter))

LongPolling() subscribes to `addSubscriber`, and do long-polling until anything is delivered. It calls `successHandler` if receives a notification. It calls `timeoutHandler` if there's a timeout. `go DistributeEvents(deliverChan, addSubscriber)` must have been called during API initialization.

func Transport

func Transport(pURL string) *http.Transport

Helper method that initializes the roundtripper based on the configuration parameters.

Types

This section is empty.

Jump to

Keyboard shortcuts

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