util

package
v0.0.0-...-06616b8 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AtomicBool

type AtomicBool int32

func (*AtomicBool) CompareAndSwap

func (b *AtomicBool) CompareAndSwap(oldVal, newVal bool) (swapped bool)

CompareAndSwap sets the value to newVal iff the current value is oldVal. If the comparison was successful, returns true.

func (*AtomicBool) Value

func (b *AtomicBool) Value() bool

type Clock

type Clock interface {
	Now() time.Time
}

type DirtyTimestamp

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

DirtyTimestamp is a boolean flag that knows the last time it was set from false to true. Zero value is unset.

func NewDirtyTimestamp

func NewDirtyTimestamp(clock Clock) *DirtyTimestamp

func (*DirtyTimestamp) Clear

func (ts *DirtyTimestamp) Clear()

func (*DirtyTimestamp) HasBeenDirtyFor

func (ts *DirtyTimestamp) HasBeenDirtyFor(d time.Duration) bool

func (*DirtyTimestamp) IsSet

func (ts *DirtyTimestamp) IsSet() bool

func (*DirtyTimestamp) Set

func (ts *DirtyTimestamp) Set()

type GrowableByteSlice

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

Buffer is used to hold file data in memory. Slightly different and simpler behavior than bytes.Buffer. Wraps a byte slice, and can grow it preserving existing data, truncate it larger or smaller.

Indices are specified in int64s, not ints. Currently the slice is implemented as a single underlying byte slice, so math.IntMax is the maximum length.

func (*GrowableByteSlice) GoString

func (s *GrowableByteSlice) GoString() string

func (*GrowableByteSlice) Len

func (s *GrowableByteSlice) Len() int64

func (*GrowableByteSlice) ReadAt

func (s *GrowableByteSlice) ReadAt(buf []byte, off int64) (n int, err error)

ReadAt implements the io.ReaderAt interface.

func (*GrowableByteSlice) ReadFrom

func (s *GrowableByteSlice) ReadFrom(r io.Reader) (int64, error)

ReadFrom resizes the slice to 0 then reads all of r.

func (*GrowableByteSlice) Resize

func (s *GrowableByteSlice) Resize(newLen64 int64)

Resize changes the len of the slice, re-allocating if necessary, to be newLen. If the new len is larger, the "new" bytes at the end of the buffer will always be zeroed out.

func (*GrowableByteSlice) String

func (s *GrowableByteSlice) String() string

func (*GrowableByteSlice) WriteAt

func (s *GrowableByteSlice) WriteAt(data []byte, off int64) (int, error)

WriteAt implements the io.WriterAt interface.

func (*GrowableByteSlice) WriteTo

func (s *GrowableByteSlice) WriteTo(w io.Writer) (int64, error)

type MockClock

type MockClock time.Time
var (
	// Wraps time.Now().
	SystemClock = systemClock{}

	// A mock Clock object that can be used for tests.
	// Every call to Now() will advance time by 1 nanosecond.
	// Every test that relies on this should call TestClock.Reset() before using it.
	TestClock MockClock
)

func (*MockClock) Advance

func (c *MockClock) Advance(d time.Duration)

func (*MockClock) Now

func (c *MockClock) Now() (now time.Time)

func (*MockClock) Reset

func (c *MockClock) Reset()

Jump to

Keyboard shortcuts

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