Documentation ¶
Overview ¶
Package util is a generated protocol buffer package.
It is generated from these files:
cockroach/pkg/util/unresolved_addr.proto
It has these top-level messages:
UnresolvedAddr
Index ¶
- Constants
- Variables
- func CleanupDir(dir string)
- func CreateRestrictedFile(t Tester, contents []byte, tempdir, name string) string
- func CreateTempDir(t Tester, prefix string) string
- func EqualPtrFields(src, dst reflect.Value, prefix string) []string
- func GetSmallTrace(skip int) string
- func MoveTopKToFront(data sort.Interface, k int)
- func NoZeroField(v interface{}) error
- func Pluralize(n int64) string
- func RetryForDuration(duration time.Duration, fn func() error) error
- func RoundUpPowerOfTwo(x int64) int64
- func SucceedsSoon(t Tester, fn func() error)
- func SucceedsSoonDepth(depth int, t Tester, fn func() error)
- func TruncateDuration(d time.Duration, r time.Duration) time.Duration
- func UnimplementedWithIssueErrorf(issue int, msg string, args ...interface{}) error
- type NoCopy
- type Tester
- type UnimplementedWithIssueError
- type UnresolvedAddr
- func (*UnresolvedAddr) Descriptor() ([]byte, []int)
- func (a UnresolvedAddr) IsEmpty() bool
- func (m *UnresolvedAddr) Marshal() (dAtA []byte, err error)
- func (m *UnresolvedAddr) MarshalTo(dAtA []byte) (int, error)
- func (a *UnresolvedAddr) Network() string
- func (*UnresolvedAddr) ProtoMessage()
- func (m *UnresolvedAddr) Reset()
- func (a UnresolvedAddr) Resolve() (net.Addr, error)
- func (m *UnresolvedAddr) Size() (n int)
- func (a *UnresolvedAddr) String() string
- func (m *UnresolvedAddr) Unmarshal(dAtA []byte) error
Constants ¶
const DefaultSucceedsSoonDuration = 45 * time.Second
DefaultSucceedsSoonDuration is the maximum amount of time unittests will wait for a condition to become true. See SucceedsSoon().
Variables ¶
var ( ErrInvalidLengthUnresolvedAddr = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowUnresolvedAddr = fmt.Errorf("proto: integer overflow") )
var PanicTester = panicTesterImpl{}
PanicTester is a Tester which panics.
var TestAddr = NewUnresolvedAddr("tcp", "127.0.0.1:0")
TestAddr is an address to use for test servers. Listening on port 0 causes the kernel to allocate an unused port.
Functions ¶
func CleanupDir ¶
func CleanupDir(dir string)
CleanupDir removes the passed-in directory and all contents. Errors are ignored.
func CreateRestrictedFile ¶
CreateRestrictedFile creates a file on disk which contains the supplied byte string as its content. The resulting file will have restrictive permissions; specifically, u=rw (0600). Returns the path of the created file along with a function that will delete the created file.
This is needed for some Go libraries (e.g. postgres SQL driver) which will refuse to open certificate files that have overly permissive permissions.
func CreateTempDir ¶
CreateTempDir creates a temporary directory and returns its path. You should usually call defer CleanupDir(dir) right after.
func EqualPtrFields ¶
EqualPtrFields uses reflection to check two "mirror" structures for matching pointer fields that point to the same object. Used to verify cloning/deep copy functions.
func GetSmallTrace ¶
GetSmallTrace produces a ":"-separated single line containing the topmost 5 callers from a given skip level.
func MoveTopKToFront ¶
MoveTopKToFront moves the top K elements to the front. It makes O(n) calls to data.Less and data.Swap (with very high probability). It uses Hoare's selection algorithm (aka quickselect).
func NoZeroField ¶
func NoZeroField(v interface{}) error
NoZeroField returns nil if none of the fields of the struct underlying the interface are equal to the zero value, and an error otherwise. It will panic if the struct has unexported fields and for any non-struct.
func RetryForDuration ¶
RetryForDuration will retry the given function until it either returns without error, or the given duration has elapsed. The function is invoked immediately at first and then successively with an exponential backoff starting at 1ns and ending at the specified duration.
func RoundUpPowerOfTwo ¶
RoundUpPowerOfTwo returns the first power of 2 greater or equal to the number. Source: http://graphics.stanford.edu/%7Eseander/bithacks.html#RoundUpPowerOf2
func SucceedsSoon ¶
SucceedsSoon fails the test (with t.Fatal) unless the supplied function runs without error within a preset maximum duration. The function is invoked immediately at first and then successively with an exponential backoff starting at 1ns and ending at the maximum duration (currently 15s).
func SucceedsSoonDepth ¶
SucceedsSoonDepth is like SucceedsSoon() but with an additional stack depth offset.
func TruncateDuration ¶
TruncateDuration returns a new duration obtained from the first argument by discarding the portions at finer resolution than that given by the second argument. Example: TruncateDuration(time.Second+1, time.Second) == time.Second.
func UnimplementedWithIssueErrorf ¶
UnimplementedWithIssueErrorf constructs an UnimplementedWithIssueError with the provided issue and formatted message.
Types ¶
type NoCopy ¶
type NoCopy struct{}
NoCopy may be embedded into structs which must not be copied after the first use.
See https://github.com/golang/go/issues/8005#issuecomment-190753527 for details.
type Tester ¶
type Tester interface { Error(args ...interface{}) Errorf(format string, args ...interface{}) Failed() bool Fatal(args ...interface{}) Fatalf(format string, args ...interface{}) }
Tester is a proxy for e.g. testing.T which does not introduce a dependency on "testing".
type UnimplementedWithIssueError ¶
type UnimplementedWithIssueError struct {
// contains filtered or unexported fields
}
UnimplementedWithIssueError is an error that links unimplemented functionality back to its issue on GitHub.
func (UnimplementedWithIssueError) Error ¶
func (e UnimplementedWithIssueError) Error() string
type UnresolvedAddr ¶
type UnresolvedAddr struct { NetworkField string `protobuf:"bytes,1,opt,name=network_field,json=networkField" json:"network_field"` AddressField string `protobuf:"bytes,2,opt,name=address_field,json=addressField" json:"address_field"` }
/ UnresolvedAddr is an unresolved version of net.Addr.
var IsolatedTestAddr *UnresolvedAddr
IsolatedTestAddr is an address to use for tests that need extra isolation by using more addresses than 127.0.0.1 (support for this is platform-specific and only enabled on Linux). Both TestAddr and IsolatedTestAddr guarantee that the chosen port is not in use when allocated, but IsolatedTestAddr draws from a larger pool of addresses so that when tests are run in a tight loop the system is less likely to run out of available ports or give a port to one test immediately after it was closed by another.
IsolatedTestAddr should be used for tests that open and close a large number of sockets, or tests which stop a server and rely on seeing a "connection refused" error afterwards. It cannot be used with tests that operate in secure mode since our test certificates are only valid for 127.0.0.1.
func MakeUnresolvedAddr ¶
func MakeUnresolvedAddr(network, addr string) UnresolvedAddr
MakeUnresolvedAddr populates an UnresolvedAddr from a network and raw address string.
func NewUnresolvedAddr ¶
func NewUnresolvedAddr(network, addr string) *UnresolvedAddr
NewUnresolvedAddr creates a new UnresolvedAddr from a network and raw address string.
func (*UnresolvedAddr) Descriptor ¶
func (*UnresolvedAddr) Descriptor() ([]byte, []int)
func (UnresolvedAddr) IsEmpty ¶
func (a UnresolvedAddr) IsEmpty() bool
IsEmpty returns true if the address has no network or address specified.
func (*UnresolvedAddr) Marshal ¶
func (m *UnresolvedAddr) Marshal() (dAtA []byte, err error)
func (*UnresolvedAddr) Network ¶
func (a *UnresolvedAddr) Network() string
Network returns the address's network name.
func (*UnresolvedAddr) ProtoMessage ¶
func (*UnresolvedAddr) ProtoMessage()
func (*UnresolvedAddr) Reset ¶
func (m *UnresolvedAddr) Reset()
func (UnresolvedAddr) Resolve ¶
func (a UnresolvedAddr) Resolve() (net.Addr, error)
Resolve attempts to resolve a into a net.Addr.
func (*UnresolvedAddr) Size ¶
func (m *UnresolvedAddr) Size() (n int)
func (*UnresolvedAddr) String ¶
func (a *UnresolvedAddr) String() string
String returns the address's string form.
func (*UnresolvedAddr) Unmarshal ¶
func (m *UnresolvedAddr) Unmarshal(dAtA []byte) error
Source Files ¶
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 interval implements an interval tree based on an augmented Left-Leaning Red Black tree.
|
Package interval implements an interval tree based on an augmented Left-Leaning Red Black tree. |
Package leaktest provides tools to detect leaked goroutines in tests.
|
Package leaktest provides tools to detect leaked goroutines in tests. |
Package log implements logging analogous to the Google-internal C++ INFO/ERROR/V setup.
|
Package log implements logging analogous to the Google-internal C++ INFO/ERROR/V setup. |
Package metric provides server metrics (a.k.a.
|
Package metric provides server metrics (a.k.a. |
Package sdnotify implements both sides of the systemd readiness protocol.
|
Package sdnotify implements both sides of the systemd readiness protocol. |
Package tracing is a generated protocol buffer package.
|
Package tracing is a generated protocol buffer package. |