cockroach: github.com/abhinavdahiya/cockroach/util Index | Files | Directories

package util

import "github.com/abhinavdahiya/cockroach/util"

Package util is a generated protocol buffer package.

It is generated from these files:

cockroach/util/unresolved_addr.proto

It has these top-level messages:

UnresolvedAddr

Index

Package Files

duration.go error.go http.go jsonpb_marshal.go pluralize.go proto_marshal.go reflect.go testing.go topk.go unresolved_addr.go unresolved_addr.pb.go

Constants

const (
    // AcceptHeader is the canonical header name for accept.
    AcceptHeader = "Accept"
    // AcceptEncodingHeader is the canonical header name for accept encoding.
    AcceptEncodingHeader = "Accept-Encoding"
    // ContentEncodingHeader is the canonical header name for content type.
    ContentEncodingHeader = "Content-Encoding"
    // ContentTypeHeader is the canonical header name for content type.
    ContentTypeHeader = "Content-Type"
    // 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"
    // PlaintextContentType is the plaintext content type.
    PlaintextContentType = "text/plain"
    // GzipEncoding is the gzip encoding.
    GzipEncoding = "gzip"
)

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.

func CleanupDir Uses

func CleanupDir(dir string)

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

func CreateRestrictedFile Uses

func CreateRestrictedFile(t Tester, contents []byte, tempdir, name string) string

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 Uses

func CreateTempDir(t Tester, prefix string) string

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

func EqualPtrFields Uses

func EqualPtrFields(src, dst reflect.Value, prefix string) []string

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 GetJSON Uses

func GetJSON(httpClient http.Client, path string, response proto.Message) error

GetJSON uses the supplied client to GET the URL specified by the parameters and unmarshals the result into response.

func MoveTopKToFront Uses

func MoveTopKToFront(data sort.Interface, k int)

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 Uses

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 Pluralize Uses

func Pluralize(n int64) string

Pluralize returns a single character 's' unless n == 1.

func PostJSON Uses

func PostJSON(httpClient http.Client, path string, request, response proto.Message) error

PostJSON uses the supplied client to POST request to the URL specified by the parameters and unmarshals the result into response .

func RetryForDuration Uses

func RetryForDuration(duration time.Duration, fn func() error) error

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 StreamJSON Uses

func StreamJSON(
    httpClient http.Client,
    path string,
    request proto.Message,
    dest proto.Message,
    callback func(proto.Message),
) error

StreamJSON uses the supplied client to POST the given proto request as JSON to the supplied streaming grpc-gw endpoint; the response type serves only to create the values passed to the callback (which is invoked for every message in the stream with a value of the supplied response type masqueraded as an interface).

func SucceedsSoon Uses

func SucceedsSoon(t Tester, fn func() error)

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 Uses

func SucceedsSoonDepth(depth int, t Tester, fn func() error)

SucceedsSoonDepth is like SucceedsSoon() but with an additional stack depth offset.

func TruncateDuration Uses

func TruncateDuration(d time.Duration, r time.Duration) time.Duration

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 Uses

func UnimplementedWithIssueErrorf(issue int, msg string, args ...interface{}) error

UnimplementedWithIssueErrorf constructs an UnimplementedWithIssueError with the provided issue and formatted message.

type JSONPb Uses

type JSONPb jsonpb.Marshaler

JSONPb is a gwruntime.Marshaler that uses github.com/gogo/protobuf/jsonpb.

func (*JSONPb) ContentType Uses

func (*JSONPb) ContentType() string

ContentType implements gwruntime.Marshaler.

func (*JSONPb) Marshal Uses

func (j *JSONPb) Marshal(v interface{}) ([]byte, error)

Marshal implements gwruntime.Marshaler.

func (*JSONPb) NewDecoder Uses

func (j *JSONPb) NewDecoder(r io.Reader) gwruntime.Decoder

NewDecoder implements gwruntime.Marshaler.

func (*JSONPb) NewEncoder Uses

func (j *JSONPb) NewEncoder(w io.Writer) gwruntime.Encoder

NewEncoder implements gwruntime.Marshaler.

func (*JSONPb) Unmarshal Uses

func (j *JSONPb) Unmarshal(data []byte, v interface{}) error

Unmarshal implements gwruntime.Marshaler.

type ProtoPb Uses

type ProtoPb struct{}

ProtoPb is a gwruntime.Marshaler that uses github.com/gogo/protobuf/proto.

func (*ProtoPb) ContentType Uses

func (*ProtoPb) ContentType() string

ContentType implements gwruntime.Marshaler.

func (*ProtoPb) Marshal Uses

func (*ProtoPb) Marshal(v interface{}) ([]byte, error)

Marshal implements gwruntime.Marshaler.

func (*ProtoPb) NewDecoder Uses

func (*ProtoPb) NewDecoder(r io.Reader) gwruntime.Decoder

NewDecoder implements gwruntime.Marshaler.

func (*ProtoPb) NewEncoder Uses

func (*ProtoPb) NewEncoder(w io.Writer) gwruntime.Encoder

NewEncoder implements gwruntime.Marshaler.

func (*ProtoPb) Unmarshal Uses

func (*ProtoPb) Unmarshal(data []byte, v interface{}) error

Unmarshal implements gwruntime.Marshaler.

type Tester Uses

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 Uses

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 Uses

func (e UnimplementedWithIssueError) Error() string

type UnresolvedAddr Uses

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.

func MakeUnresolvedAddr Uses

func MakeUnresolvedAddr(network, addr string) UnresolvedAddr

MakeUnresolvedAddr populates an UnresolvedAddr from a network and raw address string.

func NewUnresolvedAddr Uses

func NewUnresolvedAddr(network, addr string) *UnresolvedAddr

NewUnresolvedAddr creates a new UnresolvedAddr from a network and raw address string.

func (*UnresolvedAddr) Descriptor Uses

func (*UnresolvedAddr) Descriptor() ([]byte, []int)

func (*UnresolvedAddr) Marshal Uses

func (m *UnresolvedAddr) Marshal() (data []byte, err error)

func (*UnresolvedAddr) MarshalTo Uses

func (m *UnresolvedAddr) MarshalTo(data []byte) (int, error)

func (*UnresolvedAddr) Network Uses

func (a *UnresolvedAddr) Network() string

Network returns the address's network name.

func (*UnresolvedAddr) ProtoMessage Uses

func (*UnresolvedAddr) ProtoMessage()

func (*UnresolvedAddr) Reset Uses

func (m *UnresolvedAddr) Reset()

func (UnresolvedAddr) Resolve Uses

func (a UnresolvedAddr) Resolve() (net.Addr, error)

Resolve attempts to resolve a into a net.Addr.

func (*UnresolvedAddr) Size Uses

func (m *UnresolvedAddr) Size() (n int)

func (*UnresolvedAddr) String Uses

func (a *UnresolvedAddr) String() string

String returns the address's string form.

func (*UnresolvedAddr) Unmarshal Uses

func (m *UnresolvedAddr) Unmarshal(data []byte) error

Directories

PathSynopsis
bufalloc
cache
caller
decimal
duration
encoding
envutil
grpcutil
hlcPackage 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.
humanizeutil
intervalPackage interval implements an interval tree based on an augmented Left-Leaning Red Black tree.
leaktestPackage leaktest provides tools to detect leaked goroutines in tests.
logPackage log implements logging analogous to the Google-internal C++ INFO/ERROR/V setup.
log/logflags
metricPackage metric provides server metrics (a.k.a.
netutil
protoutil
randutil
retry
sdnotifyPackage sdnotify implements both sides of the systemd readiness protocol.
stop
timeutil
tracingPackage tracing is a generated protocol buffer package.
uuid

Package util imports 22 packages (graph). Updated 2017-03-13. Refresh now. Tools for package owners. This is a dead-end fork (no commits since the fork).