util

package
v0.0.0-...-3979ca8 Latest Latest
Warning

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

Go to latest
Published: May 5, 2015 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	// ContentTypeHeader is the canonical header name for content type.
	ContentTypeHeader = "Content-Type"
	// AcceptHeader is the canonical header name for accept.
	AcceptHeader = "Accept"
	// JSONContentType is the JSON content type.
	JSONContentType = "application/json"
	// AltJSONContentType is the alternate JSON content type.
	AltJSONContentType = "application/x-json"
	// ProtoContentType is the protobuf content type.
	ProtoContentType = "application/x-protobuf"
	// AltProtoContentType is the alternate protobuf content type.
	AltProtoContentType = "application/x-google-protobuf"
	// YAMLContentType is the YAML content type.
	YAMLContentType = "text/yaml"
	// AltYAMLContentType is the alternate YAML content type.
	AltYAMLContentType = "application/x-yaml"
)
View Source
const (
	// UUIDSize is the size in bytes of a UUID.
	UUIDSize = 16
)

Variables

AllEncodings includes all supported encodings.

Functions

func CleanupDir

func CleanupDir(dir string)

CleanupDir removes the passed-in directory and all contents. Errors are ignored.

func CleanupDirs

func CleanupDirs(dirs []string)

CleanupDirs removes all passed-in directories and their contents.

func CreateNTempDirs

func CreateNTempDirs(t *testing.T, prefix string, n int) []string

CreateNTempDirs creates N temporary directories and returns a slice of paths. You should usually call defer CleanupDirs(dirs) right after.

func CreateTempDir

func CreateTempDir(t *testing.T, prefix string) string

CreateTempDir creates a temporary directory and returns its path. You should usually call defer CleanupDir(dir) right after.

func CreateTestAddr

func CreateTestAddr(network string) net.Addr

CreateTestAddr creates an unused address for testing. The "network" parameter should be one of "tcp" or "unix".

func EnsureHost

func EnsureHost(addr string) string

EnsureHost takes a host:port pair, where the host portion is optional. If a host is present, the output is equal to the input. Otherwise, the output will contain a host portion equal to the hostname (or "127.0.0.1" as a fallback).

func Error

func Error(a ...interface{}) error

Error is a passthrough to fmt.Error, with an additional prefix containing the filename and line number.

func ErrorSkipFrames

func ErrorSkipFrames(skip int, a ...interface{}) error

ErrorSkipFrames allows the skip count for stack frames to be specified. See the comments for ErrorfSkip.

func Errorf

func Errorf(format string, a ...interface{}) error

Errorf is a passthrough to fmt.Errorf, with an additional prefix containing the filename and line number.

func ErrorfSkipFrames

func ErrorfSkipFrames(skip int, format string, a ...interface{}) error

ErrorfSkipFrames allows the skip count for stack frames to be specified. This is useful when generating errors via helper methods. Skip should be specified as the number of additional stack frames between the location at which the error is caused and the location at which the error is generated.

func GetContentType

func GetContentType(request *http.Request) string

GetContentType pulls out the content type from a request header it ignores every value after the first semicolon

func IsTrueWithin

func IsTrueWithin(trueFunc func() bool, duration time.Duration) error

IsTrueWithin returns an error if the supplied function fails to evaluate to true within the specified duration. The function is invoked immediately at first and then successively with an exponential backoff starting at 1ns and ending at the specified duration.

This method is deprecated; use SucceedsWithin instead. TODO(bdarnell): convert existing uses of IsTrueWithin to SucceedsWithin.

func MarshalResponse

func MarshalResponse(r *http.Request, value interface{}, allowed []EncodingType) (
	body []byte, contentType string, err error)

MarshalResponse examines the request Accept header to determine the client's preferred response encoding. Supported content types include JSON, protobuf, and YAML. If the Accept header is not available, the Content-Type header specifying the request encoding is used. The value parameter is marshalled using the response encoding and the resulting body and content type are returned. If the encoding could not be determined by either header, the response is marshalled using JSON. Falls back to JSON when the protobuf format cannot be used for the given value.

func NewPseudoRand

func NewPseudoRand() (*rand.Rand, int64)

NewPseudoRand returns an instance of math/rand.Rand seeded from crypto/rand and its seed so we can easily and cheaply generate unique streams of numbers. The created object is not safe for concurrent access.

func NewPseudoSeed

func NewPseudoSeed() int64

NewPseudoSeed generates a seed from crypto/rand.

func RandBytes

func RandBytes(r *rand.Rand, size int) []byte

RandBytes returns a byte slice of the given length with random data.

func RandIntInRange

func RandIntInRange(r *rand.Rand, min, max int) int

RandIntInRange returns a value in [min, max)

func RetryWithBackoff

func RetryWithBackoff(opts RetryOptions, fn func() (RetryStatus, error)) error

RetryWithBackoff implements retry with exponential backoff using the supplied options as parameters. When fn returns RetryContinue and the number of retry attempts haven't been exhausted, fn is retried. When fn returns RetryBreak, retry ends. As a special case, if fn returns RetryReset, the backoff and retry count are reset to starting values and the next retry occurs immediately. Returns an error if the maximum number of retries is exceeded or if the fn returns an error.

func SucceedsWithin

func SucceedsWithin(t testing.TB, duration time.Duration, fn func() error)

SucceedsWithin fails the test (with t.Fatal) unless the supplied function runs without error within the specified duration. The function is invoked immediately at first and then successively with an exponential backoff starting at 1ns and ending at the specified duration.

func UnmarshalRequest

func UnmarshalRequest(r *http.Request, body []byte, value interface{}, allowed []EncodingType) error

UnmarshalRequest examines the request Content-Type header in order to determine the encoding of the supplied body. Supported content types include:

JSON     - {"application/json", "application/x-json"}
Protobuf - {"application/x-protobuf", "application/x-google-protobuf"}
YAML     - {"text/yaml", "application/x-yaml"}

The body is unmarshalled into the supplied value parameter. An error is returned on an unmarshalling error or on an unsupported content type.

Types

type BuildInfo

type BuildInfo struct {
	Vers string `json:"goVersion"`
	Tag  string `json:"tag"`
	Time string `json:"time"`
	Deps string `json:"dependencies"`
}

BuildInfo ...

func GetBuildInfo

func GetBuildInfo() BuildInfo

GetBuildInfo ...

type CacheConfig

type CacheConfig struct {
	// Policy is one of the consts listed for EvictionPolicy.
	Policy EvictionPolicy

	// ShouldEvict is a callback function executed each time a new entry
	// is added to the cache. It supplies cache size, and potential
	// evictee's key and value. The function should return true if the
	// entry may be evicted; false otherwise. For example, to support a
	// maximum size for the cache, use a method like:
	//
	//   func(size int, key Key, value interface{}) { return size > maxSize }
	//
	// To support max TTL in the cache, use something like:
	//
	//   func(size int, key Key, value interface{}) {
	//     return time.Now().UnixNano() - value.(int64) > maxTTLNanos
	//   }
	ShouldEvict func(size int, key, value interface{}) bool

	// OnEvicted optionally specifies a callback function to be
	// executed when an entry is purged from the cache.
	OnEvicted func(key, value interface{})
}

A CacheConfig specifies the eviction policy, eviction trigger callback, and eviction listener callback.

type Closer

type Closer interface {
	Close()
}

Closer is an interface for objects to attach to the stopper to be closed once the stopper completes.

type EncodingType

type EncodingType int

EncodingType is an enum describing available encodings.

const (
	// JSONEncoding includes application/json and application/x-json.
	JSONEncoding EncodingType = iota
	// ProtoEncoding includes application/x-protobuf and application/x-google-protobuf.
	ProtoEncoding
	// YAMLEncoding includes text/yaml and application/x-yaml.
	YAMLEncoding
)

type EvictionPolicy

type EvictionPolicy int

EvictionPolicy is the cache eviction policy enum.

const (
	CacheLRU  EvictionPolicy = iota // Least recently used
	CacheFIFO                       // First in, first out
	CacheNone                       // No evictions; don't maintain ordering list
)

Constants describing LRU and FIFO, and None cache eviction policies respectively.

type Feed

type Feed struct {
	sync.Mutex
	// contains filtered or unexported fields
}

A Feed is used to publish a stream of events to a set of Subscribers. Events are values of arbitrary type, and are received and published as an empty interface. Each Subscriber will receive, in order, each entry published to the Feed.

Entries are published by via the Publish method of the Feed; this cannot be blocked by Subscriber activities and will always return quickly. Subscribers receive events by reading from their Events channel.

A Feed can be initialized by simply instantiating an empty feed object:

feed := &Feed{}
subscriber := feed.Subscribe()
feed.Publish(someEvent())

The Feed does not keep historical events; individual Subscribers will only receive events published after they Subscribe. Events can be published to a Feed until its Close() method is called.

The non-blocking property of the feed is achieved by giving each Subscriber's Events channel a very large buffer. If a Subscriber does not read from its channel, then its buffer will fill; if a call to Publish() attempts to write to a full Subscriber channel, it will panic.

Example
stopper := NewStopper()
feed := Feed{}

output := make([][]string, 5)
for i := 0; i < len(output); i++ {
	sub := feed.Subscribe()
	index := i
	stopper.RunWorker(func() {
		for event := range sub.Events() {
			// events must be cast from interface{}
			output[index] = append(output[index], event.(string))
		}
	})
}

feed.Publish("Event 1")
feed.Publish("Event 2")
feed.Publish("Event 3")
feed.Close()
stopper.Stop()

<-stopper.IsStopped()
for i, out := range output {
	fmt.Printf("subscriber %d got output %v\n", i+1, out)
}
Output:

subscriber 1 got output [Event 1 Event 2 Event 3]
subscriber 2 got output [Event 1 Event 2 Event 3]
subscriber 3 got output [Event 1 Event 2 Event 3]
subscriber 4 got output [Event 1 Event 2 Event 3]
subscriber 5 got output [Event 1 Event 2 Event 3]

func (*Feed) Close

func (f *Feed) Close()

Close closes the given Feed. All existing Subscribers will be closed immediately when the Feed is closed. After closure, any new Subscribers will be closed immediately and attempts to Publish will be ignored.

func (*Feed) Publish

func (f *Feed) Publish(event interface{})

Publish publishes a event into the Feed, which will eventually be received by all Subscribers to the feed. Events published to a closed feed, or to a feed with no Subscribers, will be ignored.

func (*Feed) Subscribe

func (f *Feed) Subscribe() *Subscription

Subscribe returns a Subscription object which can immediately recieve events which were published to this feed. An event is an arbitrary interface.

Events are read from the Subscription's Events channel. Subscribers cannot block each other from receiving events, but should still attempt to consume events in a timely fashion; if a Subscriber's (very large) Events channel fills up, a panic may result.

type IntervalCache

type IntervalCache struct {
	// contains filtered or unexported fields
}

IntervalCache is a cache which supports querying of intervals which match a key or range of keys. It is backed by an interval tree. See comments in UnorderedCache for more details on cache functionality.

Note that the IntervalCache allow multiple identical segments, as specified by start and end keys.

Keys supplied to the IntervalCache's Get, Add & Del methods must be constructed from IntervalCache.NewKey().

IntervalCache is not safe for concurrent access.

func NewIntervalCache

func NewIntervalCache(config CacheConfig) *IntervalCache

NewIntervalCache creates a new Cache backed by an interval tree. See NewCache() for details on parameters.

func (IntervalCache) Add

func (bc IntervalCache) Add(key, value interface{})

Add adds a value to the cache.

func (IntervalCache) Clear

func (bc IntervalCache) Clear()

Clear clears all entries from the cache.

func (IntervalCache) Del

func (bc IntervalCache) Del(key interface{})

Del removes the provided key from the cache.

func (*IntervalCache) Do

func (ic *IntervalCache) Do(f func(k, v interface{}))

Do invokes f on all of the entries in the cache.

func (IntervalCache) Get

func (bc IntervalCache) Get(key interface{}) (value interface{}, ok bool)

Get looks up a key's value from the cache.

func (*IntervalCache) GetOverlaps

func (ic *IntervalCache) GetOverlaps(start, end interval.Comparable) []Overlap

GetOverlaps returns a slice of values which overlap the specified interval.

func (IntervalCache) Len

func (bc IntervalCache) Len() int

Len returns the number of items in the cache.

func (*IntervalCache) NewKey

func (ic *IntervalCache) NewKey(start, end interval.Comparable) *IntervalKey

NewKey creates a new interval key defined by start and end values.

type IntervalKey

type IntervalKey struct {
	// contains filtered or unexported fields
}

IntervalKey provides uniqueness as well as key interval.

func (*IntervalKey) Contains

func (ik *IntervalKey) Contains(lk *IntervalKey) bool

Contains returns true if the specified IntervalKey is contained within this IntervalKey.

func (*IntervalKey) End

func (ik *IntervalKey) End() interval.Comparable

End .

func (*IntervalKey) Overlap

func (ik *IntervalKey) Overlap(r interval.Range) bool

Overlap .

func (*IntervalKey) SetEnd

func (ik *IntervalKey) SetEnd(c interval.Comparable)

SetEnd .

func (*IntervalKey) SetStart

func (ik *IntervalKey) SetStart(c interval.Comparable)

SetStart .

func (*IntervalKey) Start

func (ik *IntervalKey) Start() interval.Comparable

Start .

func (IntervalKey) String

func (ik IntervalKey) String() string

type Ordered

type Ordered interface {
	// Returns true if the supplied Ordered value
	// is less than this object.
	Less(b Ordered) bool
}

Ordered values can be compared against each other.

type OrderedCache

type OrderedCache struct {
	// contains filtered or unexported fields
}

OrderedCache is a cache which supports binary searches using Ceil and Floor methods. It is backed by a left-leaning red black tree. See comments in UnorderedCache for more details on cache functionality.

OrderedCache requires that keys implement llrb.Comparable.

OrderedCache is not safe for concurrent access.

func NewOrderedCache

func NewOrderedCache(config CacheConfig) *OrderedCache

NewOrderedCache creates a new Cache backed by a left-leaning red black binary tree which supports binary searches via the Ceil() and Floor() methods. See NewUnorderedCache() for details on parameters.

func (OrderedCache) Add

func (bc OrderedCache) Add(key, value interface{})

Add adds a value to the cache.

func (*OrderedCache) Ceil

func (oc *OrderedCache) Ceil(key interface{}) (k, v interface{}, ok bool)

Ceil returns the smallest cache entry greater than or equal to key.

func (OrderedCache) Clear

func (bc OrderedCache) Clear()

Clear clears all entries from the cache.

func (OrderedCache) Del

func (bc OrderedCache) Del(key interface{})

Del removes the provided key from the cache.

func (*OrderedCache) Do

func (oc *OrderedCache) Do(f func(k, v interface{}))

Do invokes f on all of the entries in the cache.

func (*OrderedCache) Floor

func (oc *OrderedCache) Floor(key interface{}) (k, v interface{}, ok bool)

Floor returns the greatest cache entry less than or equal to key.

func (OrderedCache) Get

func (bc OrderedCache) Get(key interface{}) (value interface{}, ok bool)

Get looks up a key's value from the cache.

func (OrderedCache) Len

func (bc OrderedCache) Len() int

Len returns the number of items in the cache.

type Overlap

type Overlap struct {
	Key   *IntervalKey
	Value interface{}
}

Overlap contains the key/value pair for one overlap instance.

type RawAddr

type RawAddr struct {
	// These fields are only exported so that gob can see them.
	NetworkField string
	StringField  string
}

RawAddr is a super-simple implementation of net.Addr.

func MakeRawAddr

func MakeRawAddr(network string, str string) RawAddr

MakeRawAddr creates a new RawAddr from a network and raw address string.

func (RawAddr) Network

func (a RawAddr) Network() string

Network returns the address's network name.

func (RawAddr) String

func (a RawAddr) String() string

String returns the address's string form.

type RetryMaxAttemptsError

type RetryMaxAttemptsError struct {
	MaxAttempts int
}

RetryMaxAttemptsError indicates max attempts were exceeded.

func (*RetryMaxAttemptsError) Error

func (re *RetryMaxAttemptsError) Error() string

Error implements error interface.

type RetryOptions

type RetryOptions struct {
	Tag         string        // Tag for helpful logging of backoffs
	Backoff     time.Duration // Default retry backoff interval
	MaxBackoff  time.Duration // Maximum retry backoff interval
	Constant    float64       // Default backoff constant
	MaxAttempts int           // Maximum number of attempts (0 for infinite)
	UseV1Info   bool          // Use verbose V(1) level for log messages
	Stopper     *Stopper      // Optionally end retry loop on stopper signal
}

RetryOptions provides control of retry loop logic via the RetryWithBackoffOptions method.

type RetryStatus

type RetryStatus int32

RetryStatus is an enum describing the possible statuses of a backoff / retry worker function.

const (
	// RetryBreak indicates the retry loop is finished and should return
	// the result of the retry worker function.
	RetryBreak RetryStatus = iota
	// RetryReset indicates that the retry loop should be reset with
	// no backoff for an immediate retry.
	RetryReset
	// RetryContinue indicates that the retry loop should continue with
	// another iteration of backoff / retry.
	RetryContinue
)

type Retryable

type Retryable interface {
	CanRetry() bool
}

Retryable is an interface for conditions which may be retried.

type Stopper

type Stopper struct {
	// contains filtered or unexported fields
}

A Stopper provides a channel-based mechanism to stop an arbitrary array of workers. Each worker is registered with the stopper via the AddWorker() method. The system further tracks each task which is outstanding by calling StartTask() when a task is started and FinishTask() when completed.

Stopping occurs in two phases: the first is the request to stop, which moves the stopper into a draining phase. While draining, calls to StartTask() return false, meaning the system is draining and new tasks should not be accepted. When all outstanding tasks have been completed via calls to FinishTask(), the stopper closes its stopper channel, which signals all live workers that it's safe to shut down. Once shutdown, each worker invokes SetStopped(). When all workers have shutdown, the stopper is complete.

An arbitrary list of objects implementing the Closer interface may be added to the stopper via AddCloser(), to be closed after the stopper has stopped.

func NewStopper

func NewStopper() *Stopper

NewStopper returns an instance of Stopper.

func (*Stopper) AddCloser

func (s *Stopper) AddCloser(c Closer)

AddCloser adds an object to close after the stopper has been stopped.

func (*Stopper) AddWorker

func (s *Stopper) AddWorker()

AddWorker adds a worker to the stopper.

func (*Stopper) FinishTask

func (s *Stopper) FinishTask()

FinishTask removes one from the count of tasks left to drain in the system. This function must be invoked for every call to StartTask().

func (*Stopper) IsStopped

func (s *Stopper) IsStopped() <-chan struct{}

IsStopped returns a channel which will be closed after Stop() has been invoked to full completion, meaning all workers have completed and all closers have been closed.

func (*Stopper) Quiesce

func (s *Stopper) Quiesce()

Quiesce moves the stopper to state draining, waits until all tasks complete, then moves back to non-draining state. This is used from unittests.

func (*Stopper) RunWorker

func (s *Stopper) RunWorker(f func())

RunWorker runs the supplied function as a "worker" to be stopped by the stopper. The function <f> is run in a goroutine.

func (*Stopper) SetStopped

func (s *Stopper) SetStopped()

SetStopped should be called after the ShouldStop() channel has been closed to confirm the worker has stopped.

func (*Stopper) ShouldStop

func (s *Stopper) ShouldStop() <-chan struct{}

ShouldStop returns a channel which will be closed when Stop() has been invoked. SetStopped() should be called to confirm.

func (*Stopper) StartTask

func (s *Stopper) StartTask() bool

StartTask adds one to the count of tasks left to drain in the system. Any worker which is a "first mover" when starting tasks must call this method before starting work on a new task and must subsequently invoke FinishTask() when the task is complete. First movers include goroutines launched to do periodic work and the kv/db.go gateway which accepts external client requests.

Returns true if the task can be launched or false to indicate the system is currently draining and the task should be refused.

func (*Stopper) Stop

func (s *Stopper) Stop()

Stop signals all live workers to stop and then waits for each to confirm it has stopped (workers do this by calling SetStopped()).

type Subscription

type Subscription struct {
	// contains filtered or unexported fields
}

A Subscription is used to receive events from a specific Feed. A Subscription should only be instantiated via a call to a Feed's Subscribe() method. Once created, events can be read directly from the Events channel provided by this structure.

An example of a typical usage of a Subscription:

subscriber := feed.Subscribe()
for event := range subscriber.Events() {
	// Process event...
}

A Subscription cannot block other Subscriptions to the same feed, and each Subscription will receive all events published by the Feed. The user of a Subscription should not modify Events received over the channel.

A Subscription can be closed via the Unsubscribe() method, which will result in the Events channel being closed. The Events channel will also be closed if the Feed itself is closed.

func (*Subscription) Events

func (s *Subscription) Events() <-chan interface{}

Events returns a recieve only channel for reading events from this Subscriber.

func (*Subscription) Unsubscribe

func (s *Subscription) Unsubscribe()

Unsubscribe stops the Subscriber. This will close the Subscriber's Events channel; however, there may still be unprocessed Events remaining in the channel.

type UUID

type UUID []byte

UUID is a 16 byte UUID.

func NewUUID4

func NewUUID4() UUID

NewUUID4 returns a new UUID (Version 4) using 16 random bytes or panics.

The uniqueness depends on the strength of crypto/rand. Version 4 UUIDs have 122 random bits.

func (UUID) String

func (u UUID) String() string

String formats as hex xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, or "" if u is invalid.

type UnorderedCache

type UnorderedCache struct {
	// contains filtered or unexported fields
}

UnorderedCache is a cache which supports custom eviction triggers and two eviction policies: LRU and FIFO. A listener pattern is available for eviction events. This cache uses a hashmap for storing elements, making it the most performant. Only exact lookups are supported.

UnorderedCache requires that keys are comparable, according to the go specification (http://golang.org/ref/spec#Comparison_operators).

UnorderedCache is not safe for concurrent access.

func NewUnorderedCache

func NewUnorderedCache(config CacheConfig) *UnorderedCache

NewUnorderedCache creates a new UnorderedCache backed by a hash map.

func (UnorderedCache) Add

func (bc UnorderedCache) Add(key, value interface{})

Add adds a value to the cache.

func (UnorderedCache) Clear

func (bc UnorderedCache) Clear()

Clear clears all entries from the cache.

func (UnorderedCache) Del

func (bc UnorderedCache) Del(key interface{})

Del removes the provided key from the cache.

func (UnorderedCache) Get

func (bc UnorderedCache) Get(key interface{}) (value interface{}, ok bool)

Get looks up a key's value from the cache.

func (UnorderedCache) Len

func (bc UnorderedCache) Len() int

Len returns the number of items in the cache.

type WeightedReservoirSample

type WeightedReservoirSample struct {
	Heap heap.Interface
	// contains filtered or unexported fields
}

A WeightedReservoirSample implements the weighted reservoir sampling algorithm as proposed by Efraimidis-Spirakis (2005).

func NewWeightedReservoirSample

func NewWeightedReservoirSample(size int, minHeap heap.Interface) *WeightedReservoirSample

NewWeightedReservoirSample creates a new reservoir sample on the given heap. If minHeap is nil, an in-memory heap is created and used.

func (*WeightedReservoirSample) Consider

func (rs *WeightedReservoirSample) Consider(value interface{})

Consider offers a new value to the underlying reservoir using weight one. Using the same weight for all values considered throughout the lifetime of a sample is equivalent to a non-weighted reservoir sampling algorithm.

func (*WeightedReservoirSample) ConsiderWeighted

func (rs *WeightedReservoirSample) ConsiderWeighted(value interface{}, weight float64)

ConsiderWeighted lets the sample inspect a new value with a positive given weight. A weight of one corresponds to the unweighted reservoir sampling algorithm. A nonpositive weight will lead to the item being rejected without having been observed. To avoid numerical instabilities, it is advisable to stay away from zero and infinity, or more generally from regions in which computing x**1/weight may be ill-behaved.

type WeightedValue

type WeightedValue struct {
	Value interface{}
	// contains filtered or unexported fields
}

A WeightedValue is used to represent the items sampled by WeightedReservoirSample.

func (WeightedValue) Less

func (wv WeightedValue) Less(zv WeightedValue) bool

Less implements the Ordered interface.

type WeightedValueHeap

type WeightedValueHeap []WeightedValue

A WeightedValueHeap implements a heap structure on a slice of weighted values for use in in-memory weighted reservoir sampling.

func (WeightedValueHeap) Len

func (h WeightedValueHeap) Len() int

Len, Less and Swap implement sort.Interface.

func (WeightedValueHeap) Less

func (h WeightedValueHeap) Less(i, j int) bool

func (*WeightedValueHeap) Pop

func (h *WeightedValueHeap) Pop() interface{}

Pop removes the last element of the slice.

func (*WeightedValueHeap) Push

func (h *WeightedValueHeap) Push(x interface{})

Push appends an element to the slice.

func (WeightedValueHeap) Swap

func (h WeightedValueHeap) Swap(i, j int)

Directories

Path Synopsis
Package hlc implements the Hybrid Logical Clock outlined in "Logical Physical Clocks and Consistent Snapshots in Globally Distributed Databases", available online at http://www.cse.buffalo.edu/tech-reports/2014-04.pdf.
Package hlc implements the Hybrid Logical Clock outlined in "Logical Physical Clocks and Consistent Snapshots in Globally Distributed Databases", available online at http://www.cse.buffalo.edu/tech-reports/2014-04.pdf.
Package leaktest provides tools to detect leaked goroutines in tests.
Package leaktest provides tools to detect leaked goroutines in tests.

Jump to

Keyboard shortcuts

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