├── config ├── test-broken-config.toml ├── doc.go └── config_test.go ├── vendor ├── google.golang.org │ └── grpc │ │ ├── AUTHORS │ │ ├── doc.go │ │ ├── codes │ │ └── code_string.go │ │ ├── codegen.sh │ │ ├── credentials │ │ ├── credentials_util_go18.go │ │ ├── credentials_util_pre_go17.go │ │ └── credentials_util_go17.go │ │ ├── Makefile │ │ ├── coverage.sh │ │ ├── internal │ │ └── internal.go │ │ ├── transport │ │ ├── log.go │ │ ├── go16.go │ │ └── go17.go │ │ ├── tap │ │ └── tap.go │ │ ├── peer │ │ └── peer.go │ │ ├── README.md │ │ ├── naming │ │ └── naming.go │ │ ├── CONTRIBUTING.md │ │ ├── grpclog │ │ └── logger.go │ │ ├── stats │ │ └── handlers.go │ │ ├── go16.go │ │ ├── backoff.go │ │ ├── trace.go │ │ └── go17.go ├── github.com │ ├── prometheus │ │ ├── procfs │ │ │ ├── MAINTAINERS.md │ │ │ ├── NOTICE │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── CONTRIBUTING.md │ │ │ ├── fs.go │ │ │ ├── proc_io.go │ │ │ ├── doc.go │ │ │ └── buddyinfo.go │ │ ├── client_golang │ │ │ ├── prometheus │ │ │ │ ├── README.md │ │ │ │ ├── fnv.go │ │ │ │ ├── timer.go │ │ │ │ └── observer.go │ │ │ └── NOTICE │ │ ├── client_model │ │ │ └── NOTICE │ │ └── common │ │ │ ├── NOTICE │ │ │ ├── model │ │ │ ├── model.go │ │ │ ├── fnv.go │ │ │ └── fingerprinting.go │ │ │ ├── expfmt │ │ │ ├── fuzz.go │ │ │ ├── expfmt.go │ │ │ └── encode.go │ │ │ └── internal │ │ │ └── bitbucket.org │ │ │ └── ww │ │ │ └── goautoneg │ │ │ └── README.txt │ ├── BurntSushi │ │ └── toml │ │ │ ├── session.vim │ │ │ ├── COMPATIBLE │ │ │ ├── Makefile │ │ │ ├── encoding_types_1.1.go │ │ │ ├── encoding_types.go │ │ │ ├── COPYING │ │ │ ├── doc.go │ │ │ └── type_check.go │ ├── matttproud │ │ └── golang_protobuf_extensions │ │ │ ├── NOTICE │ │ │ └── pbutil │ │ │ ├── Makefile │ │ │ ├── doc.go │ │ │ ├── encode.go │ │ │ └── decode.go │ ├── stretchr │ │ └── testify │ │ │ ├── assert │ │ │ ├── assertion_format.go.tmpl │ │ │ ├── assertion_forward.go.tmpl │ │ │ ├── errors.go │ │ │ ├── forward_assertions.go │ │ │ └── doc.go │ │ │ └── LICENSE │ ├── go-kit │ │ └── kit │ │ │ ├── log │ │ │ ├── nop_logger.go │ │ │ ├── level │ │ │ │ └── doc.go │ │ │ ├── logfmt_logger.go │ │ │ └── json_logger.go │ │ │ ├── metrics │ │ │ ├── internal │ │ │ │ └── lv │ │ │ │ │ └── labelvalues.go │ │ │ ├── timer.go │ │ │ ├── metrics.go │ │ │ ├── discard │ │ │ │ └── discard.go │ │ │ └── README.md │ │ │ └── LICENSE │ ├── go-logfmt │ │ └── logfmt │ │ │ ├── doc.go │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ └── fuzz.go │ ├── go-pluto │ │ └── maildir │ │ │ ├── README.mkdn │ │ │ └── LICENSE.txt │ ├── davecgh │ │ └── go-spew │ │ │ ├── LICENSE │ │ │ └── spew │ │ │ └── bypasssafe.go │ ├── beorn7 │ │ └── perks │ │ │ └── LICENSE │ ├── satori │ │ └── go.uuid │ │ │ ├── LICENSE │ │ │ └── README.md │ ├── go-stack │ │ └── stack │ │ │ ├── LICENSE.md │ │ │ └── README.md │ ├── pmezard │ │ └── go-difflib │ │ │ └── LICENSE │ └── golang │ │ └── protobuf │ │ ├── LICENSE │ │ └── proto │ │ └── Makefile ├── golang.org │ └── x │ │ ├── net │ │ ├── http2 │ │ │ ├── Makefile │ │ │ ├── not_go19.go │ │ │ ├── go16.go │ │ │ ├── go19.go │ │ │ ├── not_go16.go │ │ │ ├── README │ │ │ ├── not_go18.go │ │ │ ├── flow.go │ │ │ ├── go17_not18.go │ │ │ ├── go18.go │ │ │ ├── Dockerfile │ │ │ ├── headermap.go │ │ │ ├── writesched_random.go │ │ │ ├── configure_transport.go │ │ │ ├── not_go17.go │ │ │ └── go17.go │ │ ├── trace │ │ │ ├── trace_go17.go │ │ │ └── trace_go16.go │ │ ├── context │ │ │ ├── go19.go │ │ │ ├── context.go │ │ │ └── go17.go │ │ ├── PATENTS │ │ ├── LICENSE │ │ └── idna │ │ │ └── trie.go │ │ └── text │ │ ├── PATENTS │ │ ├── unicode │ │ ├── norm │ │ │ ├── trie.go │ │ │ ├── input.go │ │ │ └── transform.go │ │ └── bidi │ │ │ ├── gen_ranges.go │ │ │ ├── trieval.go │ │ │ └── gen_trieval.go │ │ └── LICENSE └── gopkg.in │ └── jackc │ └── pgx.v2 │ ├── sql.go │ ├── LICENSE │ ├── conn_config_test.go.travis │ ├── conn_config_test.go.example │ ├── pgpass.go │ ├── logger.go │ └── fastpath.go ├── Dockerfile ├── doc.go ├── utils ├── doc.go └── utils.go ├── test-users.txt ├── .codeclimate.yml ├── crypto └── doc.go ├── .travis.yml ├── comm ├── doc.go └── receiver.proto ├── auth └── doc.go ├── .gitignore ├── .codecov.yml ├── .drone.yml ├── crdt └── doc.go ├── imap ├── doc.go ├── session.go └── node.proto ├── Makefile ├── metrics.go └── test-config.toml /config/test-broken-config.toml: -------------------------------------------------------------------------------- 1 | IP = 127.0.0.1 2 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/AUTHORS: -------------------------------------------------------------------------------- 1 | Google Inc. 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.4 2 | 3 | ADD ./pluto /bin/ 4 | 5 | ENTRYPOINT ["/bin/pluto"] 6 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/MAINTAINERS.md: -------------------------------------------------------------------------------- 1 | * Tobias Schmidt 2 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/Makefile: -------------------------------------------------------------------------------- 1 | curlimage: 2 | docker build -t gohttp2/curl . 3 | 4 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/session.vim: -------------------------------------------------------------------------------- 1 | au BufWritePost *.go silent!make tags > /dev/null 2>&1 2 | -------------------------------------------------------------------------------- /vendor/github.com/matttproud/golang_protobuf_extensions/NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2012 Matt T. Proud (matt.proud@gmail.com) 2 | -------------------------------------------------------------------------------- /doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Pluto is a distributed IMAPv4 server based on Conflict-free Replicated Data Types. 3 | */ 4 | package main 5 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/COMPATIBLE: -------------------------------------------------------------------------------- 1 | Compatible with TOML version 2 | [v0.4.0](https://github.com/toml-lang/toml/blob/v0.4.0/versions/en/toml-v0.4.0.md) 3 | 4 | -------------------------------------------------------------------------------- /utils/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package utils provides smaller and independent helper functions which are needed 3 | in various places throughout the code base. 4 | */ 5 | package utils 6 | -------------------------------------------------------------------------------- /vendor/github.com/matttproud/golang_protobuf_extensions/pbutil/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | 3 | cover: 4 | go test -cover -v -coverprofile=cover.dat ./... 5 | go tool cover -func cover.dat 6 | 7 | .PHONY: cover 8 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package grpc implements an RPC system called gRPC. 3 | 4 | See grpc.io for more information about gRPC. 5 | */ 6 | package grpc // import "google.golang.org/grpc" 7 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentFormat}} 2 | func {{.DocInfo.Name}}f(t TestingT, {{.ParamsFormat}}) bool { 3 | return {{.DocInfo.Name}}(t, {{.ForwardedParamsFormat}}) 4 | } 5 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentWithoutT "a"}} 2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) bool { 3 | return {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) 4 | } 5 | -------------------------------------------------------------------------------- /test-users.txt: -------------------------------------------------------------------------------- 1 | user1;password1 2 | user2;password2 3 | user3;password3 4 | user4;password4 5 | user5;password5 6 | user6;password6 7 | user7;password7 8 | user8;password8 9 | user9;password9 10 | user10;password10 11 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_golang/prometheus/README.md: -------------------------------------------------------------------------------- 1 | See [![go-doc](https://godoc.org/github.com/prometheus/client_golang/prometheus?status.svg)](https://godoc.org/github.com/prometheus/client_golang/prometheus). 2 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_model/NOTICE: -------------------------------------------------------------------------------- 1 | Data model artifacts for Prometheus. 2 | Copyright 2012-2015 The Prometheus Authors 3 | 4 | This product includes software developed at 5 | SoundCloud Ltd. (http://soundcloud.com/). 6 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/common/NOTICE: -------------------------------------------------------------------------------- 1 | Common libraries shared by Prometheus Go components. 2 | Copyright 2015 The Prometheus Authors 3 | 4 | This product includes software developed at 5 | SoundCloud Ltd. (http://soundcloud.com/). 6 | -------------------------------------------------------------------------------- /config/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package config provides functions to read in various configuration files into definded types. 3 | This includes the main configuration file specifying all details about a distributed setup of pluto. 4 | */ 5 | package config 6 | -------------------------------------------------------------------------------- /.codeclimate.yml: -------------------------------------------------------------------------------- 1 | engines: 2 | gofmt: 3 | enabled: true 4 | golint: 5 | enabled: true 6 | govet: 7 | enabled: true 8 | 9 | ratings: 10 | paths: 11 | - "**.go" 12 | 13 | exclude_paths: 14 | - "vendor" 15 | - "**.proto" 16 | - "**.pb.go" 17 | -------------------------------------------------------------------------------- /vendor/github.com/go-kit/kit/log/nop_logger.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | type nopLogger struct{} 4 | 5 | // NewNopLogger returns a logger that doesn't do anything. 6 | func NewNopLogger() Logger { return nopLogger{} } 7 | 8 | func (nopLogger) Log(...interface{}) error { return nil } 9 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/NOTICE: -------------------------------------------------------------------------------- 1 | procfs provides functions to retrieve system, kernel and process 2 | metrics from the pseudo-filesystem proc. 3 | 4 | Copyright 2014-2015 The Prometheus Authors 5 | 6 | This product includes software developed at 7 | SoundCloud Ltd. (http://soundcloud.com/). 8 | -------------------------------------------------------------------------------- /crypto/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package crypto provides the basis for secure communication in pluto. Other than defining 3 | proper TLS configurations for public as well as internal use, it also provides a script 4 | to set up major parts of a PKI used internally for secure and authenticated communication 5 | among the pluto nodes. 6 | */ 7 | package crypto 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.8 5 | 6 | script: 7 | - make test-pki 8 | - make test-public 9 | - make build 10 | - make test 11 | 12 | after_success: 13 | - bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports" 14 | 15 | notifications: 16 | email: 17 | on_success: change 18 | on_failure: always 19 | -------------------------------------------------------------------------------- /vendor/github.com/go-logfmt/logfmt/doc.go: -------------------------------------------------------------------------------- 1 | // Package logfmt implements utilities to marshal and unmarshal data in the 2 | // logfmt format. The logfmt format records key/value pairs in a way that 3 | // balances readability for humans and simplicity of computer parsing. It is 4 | // most commonly used as a more human friendly alternative to JSON for 5 | // structured logging. 6 | package logfmt 7 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/Makefile: -------------------------------------------------------------------------------- 1 | install: 2 | go install ./... 3 | 4 | test: install 5 | go test -v 6 | toml-test toml-test-decoder 7 | toml-test -encoder toml-test-encoder 8 | 9 | fmt: 10 | gofmt -w *.go */*.go 11 | colcheck *.go */*.go 12 | 13 | tags: 14 | find ./ -name '*.go' -print0 | xargs -0 gotags > TAGS 15 | 16 | push: 17 | git push origin master 18 | git push github master 19 | 20 | -------------------------------------------------------------------------------- /vendor/github.com/go-pluto/maildir/README.mkdn: -------------------------------------------------------------------------------- 1 | The maildir package provides an interface to mailboxes in the Maildir format. 2 | 3 | Documentation can be found online here: 4 | https://godoc.org/github.com/luksen/maildir 5 | 6 | This is what I used as a reference: 7 | - https://en.wikipedia.org/wiki/Maildir 8 | - http://www.qmail.org/qmail-manual-html/man5/maildir.html 9 | - http://cr.yp.to/proto/maildir.html 10 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/errors.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | // AnError is an error instance useful for testing. If the code does not care 8 | // about error specifics, and only needs to return the error for example, this 9 | // error should be used to make the test code more readable. 10 | var AnError = errors.New("assert.AnError general error for testing") 11 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/Makefile: -------------------------------------------------------------------------------- 1 | ci: fmt lint test 2 | 3 | fmt: 4 | ! gofmt -l *.go | read nothing 5 | go vet 6 | 7 | lint: 8 | go get github.com/golang/lint/golint 9 | golint *.go 10 | 11 | test: sysfs/fixtures/.unpacked 12 | go test -v ./... 13 | 14 | sysfs/fixtures/.unpacked: sysfs/fixtures.ttar 15 | ./ttar -C sysfs -x -f sysfs/fixtures.ttar 16 | touch $@ 17 | 18 | .PHONY: fmt lint test ci 19 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/not_go19.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.9 6 | 7 | package http2 8 | 9 | import ( 10 | "net/http" 11 | ) 12 | 13 | func configureServer19(s *http.Server, conf *Server) error { 14 | // not supported prior to go1.9 15 | return nil 16 | } 17 | -------------------------------------------------------------------------------- /comm/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package comm implements network communication capabilities that are reliable and 3 | causally-ordered among multiple nodes. Vector clocks are used to ensure causality. 4 | Currently, communication is blocking on a sending node that fails to deliver an 5 | earlier message. Numerous message formats and required parses are provided to 6 | transform received marshalled CRDT messages into structured ones. 7 | */ 8 | package comm 9 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/go16.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.6 6 | 7 | package http2 8 | 9 | import ( 10 | "net/http" 11 | "time" 12 | ) 13 | 14 | func transportExpectContinueTimeout(t1 *http.Transport) time.Duration { 15 | return t1.ExpectContinueTimeout 16 | } 17 | -------------------------------------------------------------------------------- /auth/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package auth defines potentially multiple mechanisms to determine whether supplied 3 | user credentials in an IMAP session can be found in a defined user information system. 4 | Examples include an authenticator based on a user table in a PostgreSQL database and 5 | a simple (potentially insecure) plain user text file. It is easily possible to implement 6 | new authenticators that fit specific requirements. 7 | */ 8 | package auth 9 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/go19.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.9 6 | 7 | package http2 8 | 9 | import ( 10 | "net/http" 11 | ) 12 | 13 | func configureServer19(s *http.Server, conf *Server) error { 14 | s.RegisterOnShutdown(conf.state.startGracefulShutdown) 15 | return nil 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/forward_assertions.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | // Assertions provides assertion methods around the 4 | // TestingT interface. 5 | type Assertions struct { 6 | t TestingT 7 | } 8 | 9 | // New makes a new Assertions object for the specified TestingT. 10 | func New(t TestingT) *Assertions { 11 | return &Assertions{ 12 | t: t, 13 | } 14 | } 15 | 16 | //go:generate go run ../_codegen/main.go -output-package=assert -template=assertion_forward.go.tmpl -include-format-funcs 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/not_go16.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.6 6 | 7 | package http2 8 | 9 | import ( 10 | "net/http" 11 | "time" 12 | ) 13 | 14 | func configureTransport(t1 *http.Transport) (*Transport, error) { 15 | return nil, errTransportVersion 16 | } 17 | 18 | func transportExpectContinueTimeout(t1 *http.Transport) time.Duration { 19 | return 0 20 | 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/go-kit/kit/metrics/internal/lv/labelvalues.go: -------------------------------------------------------------------------------- 1 | package lv 2 | 3 | // LabelValues is a type alias that provides validation on its With method. 4 | // Metrics may include it as a member to help them satisfy With semantics and 5 | // save some code duplication. 6 | type LabelValues []string 7 | 8 | // With validates the input, and returns a new aggregate labelValues. 9 | func (lvs LabelValues) With(labelValues ...string) LabelValues { 10 | if len(labelValues)%2 != 0 { 11 | labelValues = append(labelValues, "unknown") 12 | } 13 | return append(lvs, labelValues...) 14 | } 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | 26 | # Pluto specific excludes 27 | private/ 28 | pluto 29 | config.toml 30 | config-us.toml 31 | test-config-aws.toml 32 | users.txt 33 | .env 34 | *.out 35 | *.log 36 | 37 | # Pluto specific includes 38 | !config/.env 39 | time-tracking.md 40 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/encoding_types_1.1.go: -------------------------------------------------------------------------------- 1 | // +build !go1.2 2 | 3 | package toml 4 | 5 | // These interfaces were introduced in Go 1.2, so we add them manually when 6 | // compiling for Go 1.1. 7 | 8 | // TextMarshaler is a synonym for encoding.TextMarshaler. It is defined here 9 | // so that Go 1.1 can be supported. 10 | type TextMarshaler interface { 11 | MarshalText() (text []byte, err error) 12 | } 13 | 14 | // TextUnmarshaler is a synonym for encoding.TextUnmarshaler. It is defined 15 | // here so that Go 1.1 can be supported. 16 | type TextUnmarshaler interface { 17 | UnmarshalText(text []byte) error 18 | } 19 | -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | codecov: 2 | notify: 3 | require_ci_to_pass: true 4 | coverage: 5 | precision: 2 6 | range: 7 | - 70.0 8 | - 100.0 9 | round: down 10 | status: 11 | project: 12 | default: 13 | threshold: 20 14 | patch: false 15 | changes: false 16 | ignore: 17 | - "vendor" 18 | - "**.proto" 19 | - "**.pb.go" 20 | comment: 21 | behavior: default 22 | layout: header, diff 23 | require_changes: false 24 | parsers: 25 | gcov: 26 | branch_detection: 27 | conditional: true 28 | loop: true 29 | macro: false 30 | method: false 31 | javascript: 32 | enable_partials: false 33 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/encoding_types.go: -------------------------------------------------------------------------------- 1 | // +build go1.2 2 | 3 | package toml 4 | 5 | // In order to support Go 1.1, we define our own TextMarshaler and 6 | // TextUnmarshaler types. For Go 1.2+, we just alias them with the 7 | // standard library interfaces. 8 | 9 | import ( 10 | "encoding" 11 | ) 12 | 13 | // TextMarshaler is a synonym for encoding.TextMarshaler. It is defined here 14 | // so that Go 1.1 can be supported. 15 | type TextMarshaler encoding.TextMarshaler 16 | 17 | // TextUnmarshaler is a synonym for encoding.TextUnmarshaler. It is defined 18 | // here so that Go 1.1 can be supported. 19 | type TextUnmarshaler encoding.TextUnmarshaler 20 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/codes/code_string.go: -------------------------------------------------------------------------------- 1 | // generated by stringer -type=Code; DO NOT EDIT 2 | 3 | package codes 4 | 5 | import "fmt" 6 | 7 | const _Code_name = "OKCanceledUnknownInvalidArgumentDeadlineExceededNotFoundAlreadyExistsPermissionDeniedResourceExhaustedFailedPreconditionAbortedOutOfRangeUnimplementedInternalUnavailableDataLossUnauthenticated" 8 | 9 | var _Code_index = [...]uint8{0, 2, 10, 17, 32, 48, 56, 69, 85, 102, 120, 127, 137, 150, 158, 169, 177, 192} 10 | 11 | func (i Code) String() string { 12 | if i+1 >= Code(len(_Code_index)) { 13 | return fmt.Sprintf("Code(%d)", i) 14 | } 15 | return _Code_name[_Code_index[i]:_Code_index[i+1]] 16 | } 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/trace/trace_go17.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.7 6 | 7 | package trace 8 | 9 | import "context" 10 | 11 | // NewContext returns a copy of the parent context 12 | // and associates it with a Trace. 13 | func NewContext(ctx context.Context, tr Trace) context.Context { 14 | return context.WithValue(ctx, contextKey, tr) 15 | } 16 | 17 | // FromContext returns the Trace bound to the context, if any. 18 | func FromContext(ctx context.Context) (tr Trace, ok bool) { 19 | tr, ok = ctx.Value(contextKey).(Trace) 20 | return 21 | } 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/trace/trace_go16.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.7 6 | 7 | package trace 8 | 9 | import "golang.org/x/net/context" 10 | 11 | // NewContext returns a copy of the parent context 12 | // and associates it with a Trace. 13 | func NewContext(ctx context.Context, tr Trace) context.Context { 14 | return context.WithValue(ctx, contextKey, tr) 15 | } 16 | 17 | // FromContext returns the Trace bound to the context, if any. 18 | func FromContext(ctx context.Context) (tr Trace, ok bool) { 19 | tr, ok = ctx.Value(contextKey).(Trace) 20 | return 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/README.md: -------------------------------------------------------------------------------- 1 | # procfs 2 | 3 | This procfs package provides functions to retrieve system, kernel and process 4 | metrics from the pseudo-filesystem proc. 5 | 6 | *WARNING*: This package is a work in progress. Its API may still break in 7 | backwards-incompatible ways without warnings. Use it at your own risk. 8 | 9 | [![GoDoc](https://godoc.org/github.com/prometheus/procfs?status.png)](https://godoc.org/github.com/prometheus/procfs) 10 | [![Build Status](https://travis-ci.org/prometheus/procfs.svg?branch=master)](https://travis-ci.org/prometheus/procfs) 11 | [![Go Report Card](https://goreportcard.com/badge/github.com/prometheus/procfs)](https://goreportcard.com/report/github.com/prometheus/procfs) 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/README: -------------------------------------------------------------------------------- 1 | This is a work-in-progress HTTP/2 implementation for Go. 2 | 3 | It will eventually live in the Go standard library and won't require 4 | any changes to your code to use. It will just be automatic. 5 | 6 | Status: 7 | 8 | * The server support is pretty good. A few things are missing 9 | but are being worked on. 10 | * The client work has just started but shares a lot of code 11 | is coming along much quicker. 12 | 13 | Docs are at https://godoc.org/golang.org/x/net/http2 14 | 15 | Demo test server at https://http2.golang.org/ 16 | 17 | Help & bug reports welcome! 18 | 19 | Contributing: https://golang.org/doc/contribute.html 20 | Bugs: https://golang.org/issue/new?title=x/net/http2:+ 21 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/codegen.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # This script serves as an example to demonstrate how to generate the gRPC-Go 4 | # interface and the related messages from .proto file. 5 | # 6 | # It assumes the installation of i) Google proto buffer compiler at 7 | # https://github.com/google/protobuf (after v2.6.1) and ii) the Go codegen 8 | # plugin at https://github.com/golang/protobuf (after 2015-02-20). If you have 9 | # not, please install them first. 10 | # 11 | # We recommend running this script at $GOPATH/src. 12 | # 13 | # If this is not what you need, feel free to make your own scripts. Again, this 14 | # script is for demonstration purpose. 15 | # 16 | proto=$1 17 | protoc --go_out=plugins=grpc:. $proto 18 | -------------------------------------------------------------------------------- /vendor/github.com/go-kit/kit/metrics/timer.go: -------------------------------------------------------------------------------- 1 | package metrics 2 | 3 | import "time" 4 | 5 | // Timer acts as a stopwatch, sending observations to a wrapped histogram. 6 | // It's a bit of helpful syntax sugar for h.Observe(time.Since(x)). 7 | type Timer struct { 8 | h Histogram 9 | t time.Time 10 | } 11 | 12 | // NewTimer wraps the given histogram and records the current time. 13 | func NewTimer(h Histogram) *Timer { 14 | return &Timer{ 15 | h: h, 16 | t: time.Now(), 17 | } 18 | } 19 | 20 | // ObserveDuration captures the number of seconds since the timer was 21 | // constructed, and forwards that observation to the histogram. 22 | func (t *Timer) ObserveDuration() { 23 | d := time.Since(t.t).Seconds() 24 | if d < 0 { 25 | d = 0 26 | } 27 | t.h.Observe(d) 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_golang/prometheus/fnv.go: -------------------------------------------------------------------------------- 1 | package prometheus 2 | 3 | // Inline and byte-free variant of hash/fnv's fnv64a. 4 | 5 | const ( 6 | offset64 = 14695981039346656037 7 | prime64 = 1099511628211 8 | ) 9 | 10 | // hashNew initializies a new fnv64a hash value. 11 | func hashNew() uint64 { 12 | return offset64 13 | } 14 | 15 | // hashAdd adds a string to a fnv64a hash value, returning the updated hash. 16 | func hashAdd(h uint64, s string) uint64 { 17 | for i := 0; i < len(s); i++ { 18 | h ^= uint64(s[i]) 19 | h *= prime64 20 | } 21 | return h 22 | } 23 | 24 | // hashAddByte adds a byte to a fnv64a hash value, returning the updated hash. 25 | func hashAddByte(h uint64, b byte) uint64 { 26 | h ^= uint64(b) 27 | h *= prime64 28 | return h 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/context/go19.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.9 6 | 7 | package context 8 | 9 | import "context" // standard library's context, as of Go 1.7 10 | 11 | // A Context carries a deadline, a cancelation signal, and other values across 12 | // API boundaries. 13 | // 14 | // Context's methods may be called by multiple goroutines simultaneously. 15 | type Context = context.Context 16 | 17 | // A CancelFunc tells an operation to abandon its work. 18 | // A CancelFunc does not wait for the work to stop. 19 | // After the first call, subsequent calls to a CancelFunc do nothing. 20 | type CancelFunc = context.CancelFunc 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/not_go18.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.8 6 | 7 | package http2 8 | 9 | import ( 10 | "io" 11 | "net/http" 12 | ) 13 | 14 | func configureServer18(h1 *http.Server, h2 *Server) error { 15 | // No IdleTimeout to sync prior to Go 1.8. 16 | return nil 17 | } 18 | 19 | func shouldLogPanic(panicValue interface{}) bool { 20 | return panicValue != nil 21 | } 22 | 23 | func reqGetBody(req *http.Request) func() (io.ReadCloser, error) { 24 | return nil 25 | } 26 | 27 | func reqBodyIsNoBody(io.ReadCloser) bool { return false } 28 | 29 | func go18httpNoBody() io.ReadCloser { return nil } // for tests only 30 | -------------------------------------------------------------------------------- /vendor/gopkg.in/jackc/pgx.v2/sql.go: -------------------------------------------------------------------------------- 1 | package pgx 2 | 3 | import ( 4 | "strconv" 5 | ) 6 | 7 | // QueryArgs is a container for arguments to an SQL query. It is helpful when 8 | // building SQL statements where the number of arguments is variable. 9 | type QueryArgs []interface{} 10 | 11 | var placeholders []string 12 | 13 | func init() { 14 | placeholders = make([]string, 64) 15 | 16 | for i := 1; i < 64; i++ { 17 | placeholders[i] = "$" + strconv.Itoa(i) 18 | } 19 | } 20 | 21 | // Append adds a value to qa and returns the placeholder value for the 22 | // argument. e.g. $1, $2, etc. 23 | func (qa *QueryArgs) Append(v interface{}) string { 24 | *qa = append(*qa, v) 25 | if len(*qa) < len(placeholders) { 26 | return placeholders[len(*qa)] 27 | } 28 | return "$" + strconv.Itoa(len(*qa)) 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/matttproud/golang_protobuf_extensions/pbutil/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Matt T. Proud 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package pbutil provides record length-delimited Protocol Buffer streaming. 16 | package pbutil 17 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/common/model/model.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | // Package model contains common data structures that are shared across 15 | // Prometheus components and libraries. 16 | package model 17 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/LICENSE: -------------------------------------------------------------------------------- 1 | ISC License 2 | 3 | Copyright (c) 2012-2013 Dave Collins 4 | 5 | Permission to use, copy, modify, and distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /.drone.yml: -------------------------------------------------------------------------------- 1 | workspace: 2 | base: /go 3 | path: src/github.com/go-pluto/pluto 4 | 5 | pipeline: 6 | test: 7 | image: golang:1.8 8 | commands: 9 | - make test-pki 10 | - make test-public 11 | - make test 12 | 13 | build: 14 | image: golang:1.8 15 | commands: 16 | - make build 17 | when: 18 | event: [ push, tag ] 19 | 20 | docker: 21 | image: plugins/docker 22 | repo: gopluto/pluto 23 | secrets: [ docker_username, docker_password ] 24 | tag: [ latest ] 25 | when: 26 | branch: master 27 | event: push 28 | 29 | docker: 30 | image: plugins/docker 31 | repo: gopluto/pluto 32 | secrets: [ docker_username, docker_password ] 33 | tag: [ 0.4, 0.4.1 ] 34 | when: 35 | event: tag 36 | 37 | github-release: 38 | image: plugins/github-release 39 | files: pluto 40 | when: 41 | event: tag 42 | -------------------------------------------------------------------------------- /crdt/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package crdt implements the operation-based observed-removed set (ORSet) structure 3 | upon that the CmRDT parts of pluto are built. 4 | 5 | CAUTION! Consider these two requirements: 6 | * For correct operation and results we expect the broadcast communication to all 7 | other replicas to be reliable and causally-ordered as provided by, for example, 8 | pluto's package comm. 9 | * Access to the functions this package provides is expected to be synchronized 10 | explicitly by some outside measures, e.g. by wrapping calls to this package 11 | with a mutex lock if concurrent access is possible. This package does not(!) 12 | synchronize access by itself. 13 | 14 | The operation-based ORSet implementation of this package is a practical derivation 15 | from its specification by Shapiro, Preguiça, Baquero and Zawirski, available under: 16 | https://hal.inria.fr/inria-00555588/document 17 | */ 18 | package crdt 19 | -------------------------------------------------------------------------------- /vendor/github.com/go-kit/kit/metrics/metrics.go: -------------------------------------------------------------------------------- 1 | package metrics 2 | 3 | // Counter describes a metric that accumulates values monotonically. 4 | // An example of a counter is the number of received HTTP requests. 5 | type Counter interface { 6 | With(labelValues ...string) Counter 7 | Add(delta float64) 8 | } 9 | 10 | // Gauge describes a metric that takes specific values over time. 11 | // An example of a gauge is the current depth of a job queue. 12 | type Gauge interface { 13 | With(labelValues ...string) Gauge 14 | Set(value float64) 15 | Add(delta float64) 16 | } 17 | 18 | // Histogram describes a metric that takes repeated observations of the same 19 | // kind of thing, and produces a statistical summary of those observations, 20 | // typically expressed as quantiles or buckets. An example of a histogram is 21 | // HTTP request latencies. 22 | type Histogram interface { 23 | With(labelValues ...string) Histogram 24 | Observe(value float64) 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_golang/NOTICE: -------------------------------------------------------------------------------- 1 | Prometheus instrumentation library for Go applications 2 | Copyright 2012-2015 The Prometheus Authors 3 | 4 | This product includes software developed at 5 | SoundCloud Ltd. (http://soundcloud.com/). 6 | 7 | 8 | The following components are included in this product: 9 | 10 | perks - a fork of https://github.com/bmizerany/perks 11 | https://github.com/beorn7/perks 12 | Copyright 2013-2015 Blake Mizerany, Björn Rabenstein 13 | See https://github.com/beorn7/perks/blob/master/README.md for license details. 14 | 15 | Go support for Protocol Buffers - Google's data interchange format 16 | http://github.com/golang/protobuf/ 17 | Copyright 2010 The Go Authors 18 | See source code for license details. 19 | 20 | Support for streaming Protocol Buffer messages for the Go language (golang). 21 | https://github.com/matttproud/golang_protobuf_extensions 22 | Copyright 2013 Matt T. Proud 23 | Licensed under the Apache License, Version 2.0 24 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Prometheus uses GitHub to manage reviews of pull requests. 4 | 5 | * If you have a trivial fix or improvement, go ahead and create a pull request, 6 | addressing (with `@...`) the maintainer of this repository (see 7 | [MAINTAINERS.md](MAINTAINERS.md)) in the description of the pull request. 8 | 9 | * If you plan to do something more involved, first discuss your ideas 10 | on our [mailing list](https://groups.google.com/forum/?fromgroups#!forum/prometheus-developers). 11 | This will avoid unnecessary work and surely give you and us a good deal 12 | of inspiration. 13 | 14 | * Relevant coding style guidelines are the [Go Code Review 15 | Comments](https://code.google.com/p/go-wiki/wiki/CodeReviewComments) 16 | and the _Formatting and style_ section of Peter Bourgon's [Go: Best 17 | Practices for Production 18 | Environments](http://peter.bourgon.org/go-in-production/#formatting-and-style). 19 | -------------------------------------------------------------------------------- /vendor/github.com/go-kit/kit/log/level/doc.go: -------------------------------------------------------------------------------- 1 | // Package level implements leveled logging on top of package log. To use the 2 | // level package, create a logger as per normal in your func main, and wrap it 3 | // with level.NewFilter. 4 | // 5 | // var logger log.Logger 6 | // logger = log.NewLogfmtLogger(os.Stderr) 7 | // logger = level.NewFilter(logger, level.AllowInfoAndAbove()) // <-- 8 | // logger = log.With(logger, "ts", log.DefaultTimestampUTC) 9 | // 10 | // Then, at the callsites, use one of the level.Debug, Info, Warn, or Error 11 | // helper methods to emit leveled log events. 12 | // 13 | // logger.Log("foo", "bar") // as normal, no level 14 | // level.Debug(logger).Log("request_id", reqID, "trace_data", trace.Get()) 15 | // if value > 100 { 16 | // level.Error(logger).Log("value", value) 17 | // } 18 | // 19 | // NewFilter allows precise control over what happens when a log event is 20 | // emitted without a level key, or if a squelched level is used. Check the 21 | // Option functions for details. 22 | package level 23 | -------------------------------------------------------------------------------- /imap/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package imap implements all three node types a pluto setup consists of: distributor, worker, 3 | and storage. 4 | 5 | Handler functions for the various implemented IMAP commands usually return a boolean value 6 | indicating whether correct communication between pluto and connected clients was achieved 7 | but not whether commands were handled correctly according to IMAP semantics. This means that 8 | if a fatal error occurred during handling e.g. a LOGIN request which prevents the system with 9 | a high probability from handling future commands correctly as well, the responsible handler 10 | function will return false. But in case an user error occurred such as a missing name and/or 11 | password accompanying the LOGIN command and pluto was able to send back a useful error message 12 | to the client, this function returns true because communication went according to planned 13 | handling pipeline. 14 | 15 | Please refer to https://tools.ietf.org/html/rfc3501#section-3 for full documentation 16 | on the states and https://tools.ietf.org/html/rfc3501 for the full IMAP v4 rev1 RFC. 17 | */ 18 | package imap 19 | -------------------------------------------------------------------------------- /vendor/github.com/beorn7/perks/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2013 Blake Mizerany 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/gopkg.in/jackc/pgx.v2/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Jack Christensen 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /vendor/github.com/satori/go.uuid/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2013-2016 by Maxim Bublis 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /imap/session.go: -------------------------------------------------------------------------------- 1 | package imap 2 | 3 | import ( 4 | "github.com/go-pluto/maildir" 5 | "github.com/go-pluto/pluto/comm" 6 | ) 7 | 8 | // Constants 9 | 10 | // Integer counter for IMAP states. 11 | const ( 12 | StateAny State = iota 13 | StateNotAuthenticated 14 | StateAuthenticated 15 | StateMailbox 16 | StateLogout 17 | ) 18 | 19 | // Structs 20 | 21 | // State represents the integer value associated with one 22 | // of the implemented IMAP states a connection can be in. 23 | type State int 24 | 25 | // Session contains all elements needed for tracking 26 | // and performing the actual IMAP operations for an 27 | // authenticated client. 28 | type Session struct { 29 | State State 30 | ClientID string 31 | UserName string 32 | RespWorker string 33 | StorageSubnetChan chan comm.Msg 34 | SelectedMailbox string 35 | AppendInProg *AppendInProg 36 | } 37 | 38 | // AppendInProg captures the important environment 39 | // characteristics handed from AppendBegin to AppendEnd. 40 | type AppendInProg struct { 41 | Tag string 42 | Mailbox string 43 | Maildir maildir.Dir 44 | FlagsRaw string 45 | DateTimeRaw string 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/COPYING: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 TOML authors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/go-kit/kit/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Peter Bourgon 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /vendor/github.com/go-stack/stack/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Chris Hines 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/go-logfmt/logfmt/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 go-logfmt 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /vendor/github.com/go-pluto/maildir/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Lukas Senger 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/credentials/credentials_util_go18.go: -------------------------------------------------------------------------------- 1 | // +build go1.8 2 | 3 | /* 4 | * 5 | * Copyright 2017 gRPC authors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | package credentials 22 | 23 | import ( 24 | "crypto/tls" 25 | ) 26 | 27 | // cloneTLSConfig returns a shallow clone of the exported 28 | // fields of cfg, ignoring the unexported sync.Once, which 29 | // contains a mutex and must not be copied. 30 | // 31 | // If cfg is nil, a new zero tls.Config is returned. 32 | func cloneTLSConfig(cfg *tls.Config) *tls.Config { 33 | if cfg == nil { 34 | return &tls.Config{} 35 | } 36 | 37 | return cfg.Clone() 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package toml provides facilities for decoding and encoding TOML configuration 3 | files via reflection. There is also support for delaying decoding with 4 | the Primitive type, and querying the set of keys in a TOML document with the 5 | MetaData type. 6 | 7 | The specification implemented: https://github.com/toml-lang/toml 8 | 9 | The sub-command github.com/BurntSushi/toml/cmd/tomlv can be used to verify 10 | whether a file is a valid TOML document. It can also be used to print the 11 | type of each key in a TOML document. 12 | 13 | Testing 14 | 15 | There are two important types of tests used for this package. The first is 16 | contained inside '*_test.go' files and uses the standard Go unit testing 17 | framework. These tests are primarily devoted to holistically testing the 18 | decoder and encoder. 19 | 20 | The second type of testing is used to verify the implementation's adherence 21 | to the TOML specification. These tests have been factored into their own 22 | project: https://github.com/BurntSushi/toml-test 23 | 24 | The reason the tests are in a separate project is so that they can be used by 25 | any implementation of TOML. Namely, it is language agnostic. 26 | */ 27 | package toml 28 | -------------------------------------------------------------------------------- /imap/node.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package imap; 4 | 5 | message Context { 6 | string clientID = 1; 7 | string userName = 2; 8 | string respWorker = 3; 9 | } 10 | 11 | message Confirmation { 12 | uint32 status = 1; 13 | } 14 | 15 | message Command { 16 | string text = 1; 17 | string clientID = 2; 18 | } 19 | 20 | message Reply { 21 | string text = 1; 22 | uint32 status = 2; 23 | } 24 | 25 | message Await { 26 | string text = 1; 27 | uint32 status = 2; 28 | uint32 numBytes = 3; 29 | } 30 | 31 | message MailFile { 32 | bytes content = 1; 33 | string clientID = 2; 34 | } 35 | 36 | message Abort { 37 | string clientID = 1; 38 | } 39 | 40 | service Node { 41 | rpc Prepare(Context) returns(Confirmation) {} 42 | rpc Close(Context) returns(Confirmation) {} 43 | rpc Select(Command) returns(Reply) {} 44 | rpc Create(Command) returns(Reply) {} 45 | rpc Delete(Command) returns(Reply) {} 46 | rpc List(Command) returns(Reply) {} 47 | rpc AppendBegin(Command) returns(Await) {} 48 | rpc AppendEnd(MailFile) returns(Reply) {} 49 | rpc AppendAbort(Abort) returns(Confirmation) {} 50 | rpc Expunge(Command) returns(Reply) {} 51 | rpc Store(Command) returns(Reply) {} 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/common/expfmt/fuzz.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | // Build only when actually fuzzing 15 | // +build gofuzz 16 | 17 | package expfmt 18 | 19 | import "bytes" 20 | 21 | // Fuzz text metric parser with with github.com/dvyukov/go-fuzz: 22 | // 23 | // go-fuzz-build github.com/prometheus/common/expfmt 24 | // go-fuzz -bin expfmt-fuzz.zip -workdir fuzz 25 | // 26 | // Further input samples should go in the folder fuzz/corpus. 27 | func Fuzz(in []byte) int { 28 | parser := TextParser{} 29 | _, err := parser.TextToMetricFamilies(bytes.NewReader(in)) 30 | 31 | if err != nil { 32 | return 0 33 | } 34 | 35 | return 1 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell 2 | 3 | Please consider promoting this project if you find it useful. 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 21 | OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 22 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /vendor/github.com/go-kit/kit/metrics/discard/discard.go: -------------------------------------------------------------------------------- 1 | // Package discard provides a no-op metrics backend. 2 | package discard 3 | 4 | import "github.com/go-kit/kit/metrics" 5 | 6 | type counter struct{} 7 | 8 | // NewCounter returns a new no-op counter. 9 | func NewCounter() metrics.Counter { return counter{} } 10 | 11 | // With implements Counter. 12 | func (c counter) With(labelValues ...string) metrics.Counter { return c } 13 | 14 | // Add implements Counter. 15 | func (c counter) Add(delta float64) {} 16 | 17 | type gauge struct{} 18 | 19 | // NewGauge returns a new no-op gauge. 20 | func NewGauge() metrics.Gauge { return gauge{} } 21 | 22 | // With implements Gauge. 23 | func (g gauge) With(labelValues ...string) metrics.Gauge { return g } 24 | 25 | // Set implements Gauge. 26 | func (g gauge) Set(value float64) {} 27 | 28 | // Add implements metrics.Gauge. 29 | func (g gauge) Add(delta float64) {} 30 | 31 | type histogram struct{} 32 | 33 | // NewHistogram returns a new no-op histogram. 34 | func NewHistogram() metrics.Histogram { return histogram{} } 35 | 36 | // With implements Histogram. 37 | func (h histogram) With(labelValues ...string) metrics.Histogram { return h } 38 | 39 | // Observe implements histogram. 40 | func (h histogram) Observe(value float64) {} 41 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/Makefile: -------------------------------------------------------------------------------- 1 | all: test testrace 2 | 3 | deps: 4 | go get -d -v google.golang.org/grpc/... 5 | 6 | updatedeps: 7 | go get -d -v -u -f google.golang.org/grpc/... 8 | 9 | testdeps: 10 | go get -d -v -t google.golang.org/grpc/... 11 | 12 | updatetestdeps: 13 | go get -d -v -t -u -f google.golang.org/grpc/... 14 | 15 | build: deps 16 | go build google.golang.org/grpc/... 17 | 18 | proto: 19 | @ if ! which protoc > /dev/null; then \ 20 | echo "error: protoc not installed" >&2; \ 21 | exit 1; \ 22 | fi 23 | go get -u -v github.com/golang/protobuf/protoc-gen-go 24 | # use $$dir as the root for all proto files in the same directory 25 | for dir in $$(git ls-files '*.proto' | xargs -n1 dirname | uniq); do \ 26 | protoc -I $$dir --go_out=plugins=grpc:$$dir $$dir/*.proto; \ 27 | done 28 | 29 | test: testdeps 30 | go test -v -cpu 1,4 google.golang.org/grpc/... 31 | 32 | testrace: testdeps 33 | go test -v -race -cpu 1,4 google.golang.org/grpc/... 34 | 35 | clean: 36 | go clean -i google.golang.org/grpc/... 37 | 38 | coverage: testdeps 39 | ./coverage.sh --coveralls 40 | 41 | .PHONY: \ 42 | all \ 43 | deps \ 44 | updatedeps \ 45 | testdeps \ 46 | updatetestdeps \ 47 | build \ 48 | proto \ 49 | test \ 50 | testrace \ 51 | clean \ 52 | coverage 53 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/fs.go: -------------------------------------------------------------------------------- 1 | package procfs 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path" 7 | 8 | "github.com/prometheus/procfs/xfs" 9 | ) 10 | 11 | // FS represents the pseudo-filesystem proc, which provides an interface to 12 | // kernel data structures. 13 | type FS string 14 | 15 | // DefaultMountPoint is the common mount point of the proc filesystem. 16 | const DefaultMountPoint = "/proc" 17 | 18 | // NewFS returns a new FS mounted under the given mountPoint. It will error 19 | // if the mount point can't be read. 20 | func NewFS(mountPoint string) (FS, error) { 21 | info, err := os.Stat(mountPoint) 22 | if err != nil { 23 | return "", fmt.Errorf("could not read %s: %s", mountPoint, err) 24 | } 25 | if !info.IsDir() { 26 | return "", fmt.Errorf("mount point %s is not a directory", mountPoint) 27 | } 28 | 29 | return FS(mountPoint), nil 30 | } 31 | 32 | // Path returns the path of the given subsystem relative to the procfs root. 33 | func (fs FS) Path(p ...string) string { 34 | return path.Join(append([]string{string(fs)}, p...)...) 35 | } 36 | 37 | // XFSStats retrieves XFS filesystem runtime statistics. 38 | func (fs FS) XFSStats() (*xfs.Stats, error) { 39 | f, err := os.Open(fs.Path("fs/xfs/stat")) 40 | if err != nil { 41 | return nil, err 42 | } 43 | defer f.Close() 44 | 45 | return xfs.ParseStats(f) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/flow.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Flow control 6 | 7 | package http2 8 | 9 | // flow is the flow control window's size. 10 | type flow struct { 11 | // n is the number of DATA bytes we're allowed to send. 12 | // A flow is kept both on a conn and a per-stream. 13 | n int32 14 | 15 | // conn points to the shared connection-level flow that is 16 | // shared by all streams on that conn. It is nil for the flow 17 | // that's on the conn directly. 18 | conn *flow 19 | } 20 | 21 | func (f *flow) setConnFlow(cf *flow) { f.conn = cf } 22 | 23 | func (f *flow) available() int32 { 24 | n := f.n 25 | if f.conn != nil && f.conn.n < n { 26 | n = f.conn.n 27 | } 28 | return n 29 | } 30 | 31 | func (f *flow) take(n int32) { 32 | if n > f.available() { 33 | panic("internal error: took too much") 34 | } 35 | f.n -= n 36 | if f.conn != nil { 37 | f.conn.n -= n 38 | } 39 | } 40 | 41 | // add adds n bytes (positive or negative) to the flow control window. 42 | // It returns false if the sum would exceed 2^31-1. 43 | func (f *flow) add(n int32) bool { 44 | remain := (1<<31 - 1) - f.n 45 | if n > remain { 46 | return false 47 | } 48 | f.n += n 49 | return true 50 | } 51 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/coverage.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | 4 | set -e 5 | 6 | workdir=.cover 7 | profile="$workdir/cover.out" 8 | mode=set 9 | end2endtest="google.golang.org/grpc/test" 10 | 11 | generate_cover_data() { 12 | rm -rf "$workdir" 13 | mkdir "$workdir" 14 | 15 | for pkg in "$@"; do 16 | if [ $pkg == "google.golang.org/grpc" -o $pkg == "google.golang.org/grpc/transport" -o $pkg == "google.golang.org/grpc/metadata" -o $pkg == "google.golang.org/grpc/credentials" ] 17 | then 18 | f="$workdir/$(echo $pkg | tr / -)" 19 | go test -covermode="$mode" -coverprofile="$f.cover" "$pkg" 20 | go test -covermode="$mode" -coverpkg "$pkg" -coverprofile="$f.e2e.cover" "$end2endtest" 21 | fi 22 | done 23 | 24 | echo "mode: $mode" >"$profile" 25 | grep -h -v "^mode:" "$workdir"/*.cover >>"$profile" 26 | } 27 | 28 | show_cover_report() { 29 | go tool cover -${1}="$profile" 30 | } 31 | 32 | push_to_coveralls() { 33 | goveralls -coverprofile="$profile" 34 | } 35 | 36 | generate_cover_data $(go list ./...) 37 | show_cover_report func 38 | case "$1" in 39 | "") 40 | ;; 41 | --html) 42 | show_cover_report html ;; 43 | --coveralls) 44 | push_to_coveralls ;; 45 | *) 46 | echo >&2 "error: invalid option: $1" ;; 47 | esac 48 | rm -rf "$workdir" 49 | -------------------------------------------------------------------------------- /comm/receiver.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package comm; 4 | 5 | message Msg { 6 | 7 | message CREATE { 8 | string user = 1; 9 | string mailbox = 2; 10 | string addTag = 3; 11 | } 12 | 13 | message DELETE { 14 | string user = 1; 15 | string mailbox = 2; 16 | repeated string rmvTags = 3; 17 | repeated string rmvMails = 4; 18 | } 19 | 20 | message APPEND { 21 | string user = 1; 22 | string mailbox = 2; 23 | string addTag = 3; 24 | bytes addContent = 4; 25 | } 26 | 27 | message EXPUNGE { 28 | string user = 1; 29 | string mailbox = 2; 30 | string rmvTag = 3; 31 | string addTag = 4; 32 | } 33 | 34 | message STORE { 35 | string user = 1; 36 | string mailbox = 2; 37 | string rmvTag = 3; 38 | string addTag = 4; 39 | bytes addContent = 5; 40 | } 41 | 42 | string replica = 1; 43 | map vclock = 2; 44 | string operation = 3; 45 | 46 | CREATE create = 4; 47 | DELETE delete = 5; 48 | APPEND append = 6; 49 | EXPUNGE expunge = 7; 50 | STORE store = 8; 51 | } 52 | 53 | message BinMsgs { 54 | bytes data = 1; 55 | } 56 | 57 | message Conf { 58 | uint32 status = 1; 59 | } 60 | 61 | service Receiver { 62 | rpc Incoming(BinMsgs) returns(Conf) {} 63 | } 64 | -------------------------------------------------------------------------------- /config/config_test.go: -------------------------------------------------------------------------------- 1 | package config_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "path/filepath" 7 | 8 | "github.com/go-pluto/pluto/config" 9 | "github.com/stretchr/testify/assert" 10 | ) 11 | 12 | // Functions 13 | 14 | // TestLoadConfig executes a black-box test on the 15 | // implemented functionalities to load a TOML config file. 16 | func TestLoadConfig(t *testing.T) { 17 | 18 | // Try to load a broken config file. This should fail. 19 | _, err := config.LoadConfig("test-broken-config.toml") 20 | assert.NotNilf(t, err, "expected LoadConfig() to return non-nil error while loading 'test-broken-config.toml' but error was nil") 21 | 22 | // Now load a valid config. 23 | conf, err := config.LoadConfig("../test-config.toml") 24 | assert.Nilf(t, err, "expected LoadConfig() to return nil error while loading valid config but received: %v", err) 25 | 26 | // Retrieve absolute path of pluto directory. 27 | absPlutoPath, err := filepath.Abs("../") 28 | assert.Nilf(t, err, "expected to find absolute pluto path with nil error but received: %v", err) 29 | 30 | // Build correct cert location path. 31 | absCertLoc := filepath.Join(absPlutoPath, "private/public-distributor-cert.pem") 32 | 33 | // Check for test success. 34 | assert.Equalf(t, absCertLoc, conf.Distributor.PublicCertLoc, "expected certificate path to be '%s' but found '%s'", absCertLoc, conf.Distributor.PublicCertLoc) 35 | } 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/common/model/fnv.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package model 15 | 16 | // Inline and byte-free variant of hash/fnv's fnv64a. 17 | 18 | const ( 19 | offset64 = 14695981039346656037 20 | prime64 = 1099511628211 21 | ) 22 | 23 | // hashNew initializies a new fnv64a hash value. 24 | func hashNew() uint64 { 25 | return offset64 26 | } 27 | 28 | // hashAdd adds a string to a fnv64a hash value, returning the updated hash. 29 | func hashAdd(h uint64, s string) uint64 { 30 | for i := 0; i < len(s); i++ { 31 | h ^= uint64(s[i]) 32 | h *= prime64 33 | } 34 | return h 35 | } 36 | 37 | // hashAddByte adds a byte to a fnv64a hash value, returning the updated hash. 38 | func hashAddByte(h uint64, b byte) uint64 { 39 | h ^= uint64(b) 40 | h *= prime64 41 | return h 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/proc_io.go: -------------------------------------------------------------------------------- 1 | package procfs 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "os" 7 | ) 8 | 9 | // ProcIO models the content of /proc//io. 10 | type ProcIO struct { 11 | // Chars read. 12 | RChar uint64 13 | // Chars written. 14 | WChar uint64 15 | // Read syscalls. 16 | SyscR uint64 17 | // Write syscalls. 18 | SyscW uint64 19 | // Bytes read. 20 | ReadBytes uint64 21 | // Bytes written. 22 | WriteBytes uint64 23 | // Bytes written, but taking into account truncation. See 24 | // Documentation/filesystems/proc.txt in the kernel sources for 25 | // detailed explanation. 26 | CancelledWriteBytes int64 27 | } 28 | 29 | // NewIO creates a new ProcIO instance from a given Proc instance. 30 | func (p Proc) NewIO() (ProcIO, error) { 31 | pio := ProcIO{} 32 | 33 | f, err := os.Open(p.path("io")) 34 | if err != nil { 35 | return pio, err 36 | } 37 | defer f.Close() 38 | 39 | data, err := ioutil.ReadAll(f) 40 | if err != nil { 41 | return pio, err 42 | } 43 | 44 | ioFormat := "rchar: %d\nwchar: %d\nsyscr: %d\nsyscw: %d\n" + 45 | "read_bytes: %d\nwrite_bytes: %d\n" + 46 | "cancelled_write_bytes: %d\n" 47 | 48 | _, err = fmt.Sscanf(string(data), ioFormat, &pio.RChar, &pio.WChar, &pio.SyscR, 49 | &pio.SyscW, &pio.ReadBytes, &pio.WriteBytes, &pio.CancelledWriteBytes) 50 | if err != nil { 51 | return pio, err 52 | } 53 | 54 | return pio, nil 55 | } 56 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/internal/internal.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 gRPC authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | // Package internal contains gRPC-internal code for testing, to avoid polluting 19 | // the godoc of the top-level grpc package. 20 | package internal 21 | 22 | // TestingCloseConns closes all existing transports but keeps 23 | // grpcServer.lis accepting new connections. 24 | // 25 | // The provided grpcServer must be of type *grpc.Server. It is untyped 26 | // for circular dependency reasons. 27 | var TestingCloseConns func(grpcServer interface{}) 28 | 29 | // TestingUseHandlerImpl enables the http.Handler-based server implementation. 30 | // It must be called before Serve and requires TLS credentials. 31 | // 32 | // The provided grpcServer must be of type *grpc.Server. It is untyped 33 | // for circular dependency reasons. 34 | var TestingUseHandlerImpl func(grpcServer interface{}) 35 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/unicode/norm/trie.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package norm 6 | 7 | type valueRange struct { 8 | value uint16 // header: value:stride 9 | lo, hi byte // header: lo:n 10 | } 11 | 12 | type sparseBlocks struct { 13 | values []valueRange 14 | offset []uint16 15 | } 16 | 17 | var nfcSparse = sparseBlocks{ 18 | values: nfcSparseValues[:], 19 | offset: nfcSparseOffset[:], 20 | } 21 | 22 | var nfkcSparse = sparseBlocks{ 23 | values: nfkcSparseValues[:], 24 | offset: nfkcSparseOffset[:], 25 | } 26 | 27 | var ( 28 | nfcData = newNfcTrie(0) 29 | nfkcData = newNfkcTrie(0) 30 | ) 31 | 32 | // lookupValue determines the type of block n and looks up the value for b. 33 | // For n < t.cutoff, the block is a simple lookup table. Otherwise, the block 34 | // is a list of ranges with an accompanying value. Given a matching range r, 35 | // the value for b is by r.value + (b - r.lo) * stride. 36 | func (t *sparseBlocks) lookup(n uint32, b byte) uint16 { 37 | offset := t.offset[n] 38 | header := t.values[offset] 39 | lo := offset + 1 40 | hi := lo + uint16(header.lo) 41 | for lo < hi { 42 | m := lo + (hi-lo)/2 43 | r := t.values[m] 44 | if r.lo <= b && b <= r.hi { 45 | return r.value + uint16(b-r.lo)*header.value 46 | } 47 | if b < r.lo { 48 | hi = m 49 | } else { 50 | lo = m + 1 51 | } 52 | } 53 | return 0 54 | } 55 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/transport/log.go: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2017 gRPC authors. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | */ 18 | 19 | // This file contains wrappers for grpclog functions. 20 | // The transport package only logs to verbose level 2 by default. 21 | 22 | package transport 23 | 24 | import "google.golang.org/grpc/grpclog" 25 | 26 | const logLevel = 2 27 | 28 | func infof(format string, args ...interface{}) { 29 | if grpclog.V(logLevel) { 30 | grpclog.Infof(format, args...) 31 | } 32 | } 33 | 34 | func warningf(format string, args ...interface{}) { 35 | if grpclog.V(logLevel) { 36 | grpclog.Warningf(format, args...) 37 | } 38 | } 39 | 40 | func errorf(format string, args ...interface{}) { 41 | if grpclog.V(logLevel) { 42 | grpclog.Errorf(format, args...) 43 | } 44 | } 45 | 46 | func fatalf(format string, args ...interface{}) { 47 | if grpclog.V(logLevel) { 48 | grpclog.Fatalf(format, args...) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/go17_not18.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.7,!go1.8 6 | 7 | package http2 8 | 9 | import "crypto/tls" 10 | 11 | // temporary copy of Go 1.7's private tls.Config.clone: 12 | func cloneTLSConfig(c *tls.Config) *tls.Config { 13 | return &tls.Config{ 14 | Rand: c.Rand, 15 | Time: c.Time, 16 | Certificates: c.Certificates, 17 | NameToCertificate: c.NameToCertificate, 18 | GetCertificate: c.GetCertificate, 19 | RootCAs: c.RootCAs, 20 | NextProtos: c.NextProtos, 21 | ServerName: c.ServerName, 22 | ClientAuth: c.ClientAuth, 23 | ClientCAs: c.ClientCAs, 24 | InsecureSkipVerify: c.InsecureSkipVerify, 25 | CipherSuites: c.CipherSuites, 26 | PreferServerCipherSuites: c.PreferServerCipherSuites, 27 | SessionTicketsDisabled: c.SessionTicketsDisabled, 28 | SessionTicketKey: c.SessionTicketKey, 29 | ClientSessionCache: c.ClientSessionCache, 30 | MinVersion: c.MinVersion, 31 | MaxVersion: c.MaxVersion, 32 | CurvePreferences: c.CurvePreferences, 33 | DynamicRecordSizingDisabled: c.DynamicRecordSizingDisabled, 34 | Renegotiation: c.Renegotiation, 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/transport/go16.go: -------------------------------------------------------------------------------- 1 | // +build go1.6,!go1.7 2 | 3 | /* 4 | * 5 | * Copyright 2016 gRPC authors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | package transport 22 | 23 | import ( 24 | "net" 25 | 26 | "google.golang.org/grpc/codes" 27 | 28 | "golang.org/x/net/context" 29 | ) 30 | 31 | // dialContext connects to the address on the named network. 32 | func dialContext(ctx context.Context, network, address string) (net.Conn, error) { 33 | return (&net.Dialer{Cancel: ctx.Done()}).Dial(network, address) 34 | } 35 | 36 | // ContextErr converts the error from context package into a StreamError. 37 | func ContextErr(err error) StreamError { 38 | switch err { 39 | case context.DeadlineExceeded: 40 | return streamErrorf(codes.DeadlineExceeded, "%v", err) 41 | case context.Canceled: 42 | return streamErrorf(codes.Canceled, "%v", err) 43 | } 44 | return streamErrorf(codes.Internal, "Unexpected error from context packet: %v", err) 45 | } 46 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/go18.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.8 6 | 7 | package http2 8 | 9 | import ( 10 | "crypto/tls" 11 | "io" 12 | "net/http" 13 | ) 14 | 15 | func cloneTLSConfig(c *tls.Config) *tls.Config { 16 | c2 := c.Clone() 17 | c2.GetClientCertificate = c.GetClientCertificate // golang.org/issue/19264 18 | return c2 19 | } 20 | 21 | var _ http.Pusher = (*responseWriter)(nil) 22 | 23 | // Push implements http.Pusher. 24 | func (w *responseWriter) Push(target string, opts *http.PushOptions) error { 25 | internalOpts := pushOptions{} 26 | if opts != nil { 27 | internalOpts.Method = opts.Method 28 | internalOpts.Header = opts.Header 29 | } 30 | return w.push(target, internalOpts) 31 | } 32 | 33 | func configureServer18(h1 *http.Server, h2 *Server) error { 34 | if h2.IdleTimeout == 0 { 35 | if h1.IdleTimeout != 0 { 36 | h2.IdleTimeout = h1.IdleTimeout 37 | } else { 38 | h2.IdleTimeout = h1.ReadTimeout 39 | } 40 | } 41 | return nil 42 | } 43 | 44 | func shouldLogPanic(panicValue interface{}) bool { 45 | return panicValue != nil && panicValue != http.ErrAbortHandler 46 | } 47 | 48 | func reqGetBody(req *http.Request) func() (io.ReadCloser, error) { 49 | return req.GetBody 50 | } 51 | 52 | func reqBodyIsNoBody(body io.ReadCloser) bool { 53 | return body == http.NoBody 54 | } 55 | 56 | func go18httpNoBody() io.ReadCloser { return http.NoBody } // for tests only 57 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Prometheus Team 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | // Package procfs provides functions to retrieve system, kernel and process 15 | // metrics from the pseudo-filesystem proc. 16 | // 17 | // Example: 18 | // 19 | // package main 20 | // 21 | // import ( 22 | // "fmt" 23 | // "log" 24 | // 25 | // "github.com/prometheus/procfs" 26 | // ) 27 | // 28 | // func main() { 29 | // p, err := procfs.Self() 30 | // if err != nil { 31 | // log.Fatalf("could not get process: %s", err) 32 | // } 33 | // 34 | // stat, err := p.NewStat() 35 | // if err != nil { 36 | // log.Fatalf("could not get process stat: %s", err) 37 | // } 38 | // 39 | // fmt.Printf("command: %s\n", stat.Comm) 40 | // fmt.Printf("cpu time: %fs\n", stat.CPUTime()) 41 | // fmt.Printf("vsize: %dB\n", stat.VirtualMemory()) 42 | // fmt.Printf("rss: %dB\n", stat.ResidentMemory()) 43 | // } 44 | // 45 | package procfs 46 | -------------------------------------------------------------------------------- /vendor/github.com/pmezard/go-difflib/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Patrick Mezard 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | The names of its contributors may not be used to endorse or promote 14 | products derived from this software without specific prior written 15 | permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 18 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/transport/go17.go: -------------------------------------------------------------------------------- 1 | // +build go1.7 2 | 3 | /* 4 | * 5 | * Copyright 2016 gRPC authors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | package transport 22 | 23 | import ( 24 | "context" 25 | "net" 26 | 27 | "google.golang.org/grpc/codes" 28 | 29 | netctx "golang.org/x/net/context" 30 | ) 31 | 32 | // dialContext connects to the address on the named network. 33 | func dialContext(ctx context.Context, network, address string) (net.Conn, error) { 34 | return (&net.Dialer{}).DialContext(ctx, network, address) 35 | } 36 | 37 | // ContextErr converts the error from context package into a StreamError. 38 | func ContextErr(err error) StreamError { 39 | switch err { 40 | case context.DeadlineExceeded, netctx.DeadlineExceeded: 41 | return streamErrorf(codes.DeadlineExceeded, "%v", err) 42 | case context.Canceled, netctx.Canceled: 43 | return streamErrorf(codes.Canceled, "%v", err) 44 | } 45 | return streamErrorf(codes.Internal, "Unexpected error from context packet: %v", err) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/doc.go: -------------------------------------------------------------------------------- 1 | // Package assert provides a set of comprehensive testing tools for use with the normal Go testing system. 2 | // 3 | // Example Usage 4 | // 5 | // The following is a complete example using assert in a standard test function: 6 | // import ( 7 | // "testing" 8 | // "github.com/stretchr/testify/assert" 9 | // ) 10 | // 11 | // func TestSomething(t *testing.T) { 12 | // 13 | // var a string = "Hello" 14 | // var b string = "Hello" 15 | // 16 | // assert.Equal(t, a, b, "The two words should be the same.") 17 | // 18 | // } 19 | // 20 | // if you assert many times, use the format below: 21 | // 22 | // import ( 23 | // "testing" 24 | // "github.com/stretchr/testify/assert" 25 | // ) 26 | // 27 | // func TestSomething(t *testing.T) { 28 | // assert := assert.New(t) 29 | // 30 | // var a string = "Hello" 31 | // var b string = "Hello" 32 | // 33 | // assert.Equal(a, b, "The two words should be the same.") 34 | // } 35 | // 36 | // Assertions 37 | // 38 | // Assertions allow you to easily write test code, and are global funcs in the `assert` package. 39 | // All assertion functions take, as the first argument, the `*testing.T` object provided by the 40 | // testing framework. This allows the assertion funcs to write the failings and other details to 41 | // the correct place. 42 | // 43 | // Every assertion function also takes an optional string message as the final argument, 44 | // allowing custom error messages to be appended to the message the assertion method outputs. 45 | package assert 46 | -------------------------------------------------------------------------------- /vendor/gopkg.in/jackc/pgx.v2/conn_config_test.go.travis: -------------------------------------------------------------------------------- 1 | package pgx_test 2 | 3 | import ( 4 | "crypto/tls" 5 | "github.com/jackc/pgx" 6 | "os" 7 | "strconv" 8 | ) 9 | 10 | var defaultConnConfig = &pgx.ConnConfig{Host: "127.0.0.1", User: "pgx_md5", Password: "secret", Database: "pgx_test"} 11 | var tcpConnConfig = &pgx.ConnConfig{Host: "127.0.0.1", User: "pgx_md5", Password: "secret", Database: "pgx_test"} 12 | var unixSocketConnConfig = &pgx.ConnConfig{Host: "/var/run/postgresql", User: "postgres", Database: "pgx_test"} 13 | var md5ConnConfig = &pgx.ConnConfig{Host: "127.0.0.1", User: "pgx_md5", Password: "secret", Database: "pgx_test"} 14 | var plainPasswordConnConfig = &pgx.ConnConfig{Host: "127.0.0.1", User: "pgx_pw", Password: "secret", Database: "pgx_test"} 15 | var invalidUserConnConfig = &pgx.ConnConfig{Host: "127.0.0.1", User: "invalid", Database: "pgx_test"} 16 | var tlsConnConfig = &pgx.ConnConfig{Host: "127.0.0.1", User: "pgx_ssl", Password: "secret", Database: "pgx_test", TLSConfig: &tls.Config{InsecureSkipVerify: true}} 17 | var customDialerConnConfig = &pgx.ConnConfig{Host: "127.0.0.1", User: "pgx_md5", Password: "secret", Database: "pgx_test"} 18 | var replicationConnConfig *pgx.ConnConfig = nil 19 | 20 | func init() { 21 | version := os.Getenv("PGVERSION") 22 | 23 | if len(version) > 0 { 24 | v, err := strconv.ParseFloat(version,64) 25 | if err == nil && v >= 9.6 { 26 | replicationConnConfig = &pgx.ConnConfig{Host: "127.0.0.1", User: "pgx_replication", Password: "secret", Database: "pgx_test"} 27 | } 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/tap/tap.go: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2016 gRPC authors. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | */ 18 | 19 | // Package tap defines the function handles which are executed on the transport 20 | // layer of gRPC-Go and related information. Everything here is EXPERIMENTAL. 21 | package tap 22 | 23 | import ( 24 | "golang.org/x/net/context" 25 | ) 26 | 27 | // Info defines the relevant information needed by the handles. 28 | type Info struct { 29 | // FullMethodName is the string of grpc method (in the format of 30 | // /package.service/method). 31 | FullMethodName string 32 | // TODO: More to be added. 33 | } 34 | 35 | // ServerInHandle defines the function which runs when a new stream is created 36 | // on the server side. Note that it is executed in the per-connection I/O goroutine(s) instead 37 | // of per-RPC goroutine. Therefore, users should NOT have any blocking/time-consuming 38 | // work in this handle. Otherwise all the RPCs would slow down. 39 | type ServerInHandle func(ctx context.Context, info *Info) (context.Context, error) 40 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/common/expfmt/expfmt.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | // Package expfmt contains tools for reading and writing Prometheus metrics. 15 | package expfmt 16 | 17 | // Format specifies the HTTP content type of the different wire protocols. 18 | type Format string 19 | 20 | // Constants to assemble the Content-Type values for the different wire protocols. 21 | const ( 22 | TextVersion = "0.0.4" 23 | ProtoType = `application/vnd.google.protobuf` 24 | ProtoProtocol = `io.prometheus.client.MetricFamily` 25 | ProtoFmt = ProtoType + "; proto=" + ProtoProtocol + ";" 26 | 27 | // The Content-Type values for the different wire protocols. 28 | FmtUnknown Format = `` 29 | FmtText Format = `text/plain; version=` + TextVersion 30 | FmtProtoDelim Format = ProtoFmt + ` encoding=delimited` 31 | FmtProtoText Format = ProtoFmt + ` encoding=text` 32 | FmtProtoCompact Format = ProtoFmt + ` encoding=compact-text` 33 | ) 34 | 35 | const ( 36 | hdrContentType = "Content-Type" 37 | hdrAccept = "Accept" 38 | ) 39 | -------------------------------------------------------------------------------- /vendor/github.com/go-kit/kit/log/logfmt_logger.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | "sync" 7 | 8 | "github.com/go-logfmt/logfmt" 9 | ) 10 | 11 | type logfmtEncoder struct { 12 | *logfmt.Encoder 13 | buf bytes.Buffer 14 | } 15 | 16 | func (l *logfmtEncoder) Reset() { 17 | l.Encoder.Reset() 18 | l.buf.Reset() 19 | } 20 | 21 | var logfmtEncoderPool = sync.Pool{ 22 | New: func() interface{} { 23 | var enc logfmtEncoder 24 | enc.Encoder = logfmt.NewEncoder(&enc.buf) 25 | return &enc 26 | }, 27 | } 28 | 29 | type logfmtLogger struct { 30 | w io.Writer 31 | } 32 | 33 | // NewLogfmtLogger returns a logger that encodes keyvals to the Writer in 34 | // logfmt format. Each log event produces no more than one call to w.Write. 35 | // The passed Writer must be safe for concurrent use by multiple goroutines if 36 | // the returned Logger will be used concurrently. 37 | func NewLogfmtLogger(w io.Writer) Logger { 38 | return &logfmtLogger{w} 39 | } 40 | 41 | func (l logfmtLogger) Log(keyvals ...interface{}) error { 42 | enc := logfmtEncoderPool.Get().(*logfmtEncoder) 43 | enc.Reset() 44 | defer logfmtEncoderPool.Put(enc) 45 | 46 | if err := enc.EncodeKeyvals(keyvals...); err != nil { 47 | return err 48 | } 49 | 50 | // Add newline to the end of the buffer 51 | if err := enc.EndRecord(); err != nil { 52 | return err 53 | } 54 | 55 | // The Logger interface requires implementations to be safe for concurrent 56 | // use by multiple goroutines. For this implementation that means making 57 | // only one call to l.w.Write() for each call to Log. 58 | if _, err := l.w.Write(enc.buf.Bytes()); err != nil { 59 | return err 60 | } 61 | return nil 62 | } 63 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/LICENSE: -------------------------------------------------------------------------------- 1 | Go support for Protocol Buffers - Google's data interchange format 2 | 3 | Copyright 2010 The Go Authors. All rights reserved. 4 | https://github.com/golang/protobuf 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are 8 | met: 9 | 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above 13 | copyright notice, this list of conditions and the following disclaimer 14 | in the documentation and/or other materials provided with the 15 | distribution. 16 | * Neither the name of Google Inc. nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # This Dockerfile builds a recent curl with HTTP/2 client support, using 3 | # a recent nghttp2 build. 4 | # 5 | # See the Makefile for how to tag it. If Docker and that image is found, the 6 | # Go tests use this curl binary for integration tests. 7 | # 8 | 9 | FROM ubuntu:trusty 10 | 11 | RUN apt-get update && \ 12 | apt-get upgrade -y && \ 13 | apt-get install -y git-core build-essential wget 14 | 15 | RUN apt-get install -y --no-install-recommends \ 16 | autotools-dev libtool pkg-config zlib1g-dev \ 17 | libcunit1-dev libssl-dev libxml2-dev libevent-dev \ 18 | automake autoconf 19 | 20 | # The list of packages nghttp2 recommends for h2load: 21 | RUN apt-get install -y --no-install-recommends make binutils \ 22 | autoconf automake autotools-dev \ 23 | libtool pkg-config zlib1g-dev libcunit1-dev libssl-dev libxml2-dev \ 24 | libev-dev libevent-dev libjansson-dev libjemalloc-dev \ 25 | cython python3.4-dev python-setuptools 26 | 27 | # Note: setting NGHTTP2_VER before the git clone, so an old git clone isn't cached: 28 | ENV NGHTTP2_VER 895da9a 29 | RUN cd /root && git clone https://github.com/tatsuhiro-t/nghttp2.git 30 | 31 | WORKDIR /root/nghttp2 32 | RUN git reset --hard $NGHTTP2_VER 33 | RUN autoreconf -i 34 | RUN automake 35 | RUN autoconf 36 | RUN ./configure 37 | RUN make 38 | RUN make install 39 | 40 | WORKDIR /root 41 | RUN wget http://curl.haxx.se/download/curl-7.45.0.tar.gz 42 | RUN tar -zxvf curl-7.45.0.tar.gz 43 | WORKDIR /root/curl-7.45.0 44 | RUN ./configure --with-ssl --with-nghttp2=/usr/local 45 | RUN make 46 | RUN make install 47 | RUN ldconfig 48 | 49 | CMD ["-h"] 50 | ENTRYPOINT ["/usr/local/bin/curl"] 51 | 52 | -------------------------------------------------------------------------------- /vendor/github.com/go-stack/stack/README.md: -------------------------------------------------------------------------------- 1 | [![GoDoc](https://godoc.org/github.com/go-stack/stack?status.svg)](https://godoc.org/github.com/go-stack/stack) 2 | [![Go Report Card](https://goreportcard.com/badge/go-stack/stack)](https://goreportcard.com/report/go-stack/stack) 3 | [![TravisCI](https://travis-ci.org/go-stack/stack.svg?branch=master)](https://travis-ci.org/go-stack/stack) 4 | [![Coverage Status](https://coveralls.io/repos/github/go-stack/stack/badge.svg?branch=master)](https://coveralls.io/github/go-stack/stack?branch=master) 5 | 6 | # stack 7 | 8 | Package stack implements utilities to capture, manipulate, and format call 9 | stacks. It provides a simpler API than package runtime. 10 | 11 | The implementation takes care of the minutia and special cases of interpreting 12 | the program counter (pc) values returned by runtime.Callers. 13 | 14 | ## Versioning 15 | 16 | Package stack publishes releases via [semver](http://semver.org/) compatible Git 17 | tags prefixed with a single 'v'. The master branch always contains the latest 18 | release. The develop branch contains unreleased commits. 19 | 20 | ## Formatting 21 | 22 | Package stack's types implement fmt.Formatter, which provides a simple and 23 | flexible way to declaratively configure formatting when used with logging or 24 | error tracking packages. 25 | 26 | ```go 27 | func DoTheThing() { 28 | c := stack.Caller(0) 29 | log.Print(c) // "source.go:10" 30 | log.Printf("%+v", c) // "pkg/path/source.go:10" 31 | log.Printf("%n", c) // "DoTheThing" 32 | 33 | s := stack.Trace().TrimRuntime() 34 | log.Print(s) // "[source.go:15 caller.go:42 main.go:14]" 35 | } 36 | ``` 37 | 38 | See the docs for all of the supported formatting options. 39 | -------------------------------------------------------------------------------- /vendor/github.com/matttproud/golang_protobuf_extensions/pbutil/encode.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Matt T. Proud 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package pbutil 16 | 17 | import ( 18 | "encoding/binary" 19 | "io" 20 | 21 | "github.com/golang/protobuf/proto" 22 | ) 23 | 24 | // WriteDelimited encodes and dumps a message to the provided writer prefixed 25 | // with a 32-bit varint indicating the length of the encoded message, producing 26 | // a length-delimited record stream, which can be used to chain together 27 | // encoded messages of the same type together in a file. It returns the total 28 | // number of bytes written and any applicable error. This is roughly 29 | // equivalent to the companion Java API's MessageLite#writeDelimitedTo. 30 | func WriteDelimited(w io.Writer, m proto.Message) (n int, err error) { 31 | buffer, err := proto.Marshal(m) 32 | if err != nil { 33 | return 0, err 34 | } 35 | 36 | var buf [binary.MaxVarintLen32]byte 37 | encodedLength := binary.PutUvarint(buf[:], uint64(len(buffer))) 38 | 39 | sync, err := w.Write(buf[:encodedLength]) 40 | if err != nil { 41 | return sync, err 42 | } 43 | 44 | n, err = w.Write(buffer) 45 | return n + sync, err 46 | } 47 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/peer/peer.go: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 gRPC authors. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | */ 18 | 19 | // Package peer defines various peer information associated with RPCs and 20 | // corresponding utils. 21 | package peer 22 | 23 | import ( 24 | "net" 25 | 26 | "golang.org/x/net/context" 27 | "google.golang.org/grpc/credentials" 28 | ) 29 | 30 | // Peer contains the information of the peer for an RPC, such as the address 31 | // and authentication information. 32 | type Peer struct { 33 | // Addr is the peer address. 34 | Addr net.Addr 35 | // AuthInfo is the authentication information of the transport. 36 | // It is nil if there is no transport security being used. 37 | AuthInfo credentials.AuthInfo 38 | } 39 | 40 | type peerKey struct{} 41 | 42 | // NewContext creates a new context with peer information attached. 43 | func NewContext(ctx context.Context, p *Peer) context.Context { 44 | return context.WithValue(ctx, peerKey{}, p) 45 | } 46 | 47 | // FromContext returns the peer information in ctx if it exists. 48 | func FromContext(ctx context.Context) (p *Peer, ok bool) { 49 | p, ok = ctx.Value(peerKey{}).(*Peer) 50 | return 51 | } 52 | -------------------------------------------------------------------------------- /vendor/gopkg.in/jackc/pgx.v2/conn_config_test.go.example: -------------------------------------------------------------------------------- 1 | package pgx_test 2 | 3 | import ( 4 | "github.com/jackc/pgx" 5 | ) 6 | 7 | var defaultConnConfig *pgx.ConnConfig = &pgx.ConnConfig{Host: "127.0.0.1", User: "pgx_md5", Password: "secret", Database: "pgx_test"} 8 | 9 | // To skip tests for specific connection / authentication types set that connection param to nil 10 | var tcpConnConfig *pgx.ConnConfig = nil 11 | var unixSocketConnConfig *pgx.ConnConfig = nil 12 | var md5ConnConfig *pgx.ConnConfig = nil 13 | var plainPasswordConnConfig *pgx.ConnConfig = nil 14 | var invalidUserConnConfig *pgx.ConnConfig = nil 15 | var tlsConnConfig *pgx.ConnConfig = nil 16 | var customDialerConnConfig *pgx.ConnConfig = nil 17 | var replicationConnConfig *pgx.ConnConfig = nil 18 | 19 | // var tcpConnConfig *pgx.ConnConfig = &pgx.ConnConfig{Host: "127.0.0.1", User: "pgx_md5", Password: "secret", Database: "pgx_test"} 20 | // var unixSocketConnConfig *pgx.ConnConfig = &pgx.ConnConfig{Host: "/private/tmp", User: "pgx_none", Database: "pgx_test"} 21 | // var md5ConnConfig *pgx.ConnConfig = &pgx.ConnConfig{Host: "127.0.0.1", User: "pgx_md5", Password: "secret", Database: "pgx_test"} 22 | // var plainPasswordConnConfig *pgx.ConnConfig = &pgx.ConnConfig{Host: "127.0.0.1", User: "pgx_pw", Password: "secret", Database: "pgx_test"} 23 | // var invalidUserConnConfig *pgx.ConnConfig = &pgx.ConnConfig{Host: "127.0.0.1", User: "invalid", Database: "pgx_test"} 24 | // var tlsConnConfig *pgx.ConnConfig = &pgx.ConnConfig{Host: "127.0.0.1", User: "pgx_md5", Password: "secret", Database: "pgx_test", TLSConfig: &tls.Config{InsecureSkipVerify: true}} 25 | // var customDialerConnConfig *pgx.ConnConfig = &pgx.ConnConfig{Host: "127.0.0.1", User: "pgx_md5", Password: "secret", Database: "pgx_test"} 26 | -------------------------------------------------------------------------------- /vendor/github.com/go-logfmt/logfmt/README.md: -------------------------------------------------------------------------------- 1 | [![GoDoc](https://godoc.org/github.com/go-logfmt/logfmt?status.svg)](https://godoc.org/github.com/go-logfmt/logfmt) 2 | [![Go Report Card](https://goreportcard.com/badge/go-logfmt/logfmt)](https://goreportcard.com/report/go-logfmt/logfmt) 3 | [![TravisCI](https://travis-ci.org/go-logfmt/logfmt.svg?branch=master)](https://travis-ci.org/go-logfmt/logfmt) 4 | [![Coverage Status](https://coveralls.io/repos/github/go-logfmt/logfmt/badge.svg?branch=master)](https://coveralls.io/github/go-logfmt/logfmt?branch=master) 5 | 6 | # logfmt 7 | 8 | Package logfmt implements utilities to marshal and unmarshal data in the [logfmt 9 | format](https://brandur.org/logfmt). It provides an API similar to 10 | [encoding/json](http://golang.org/pkg/encoding/json/) and 11 | [encoding/xml](http://golang.org/pkg/encoding/xml/). 12 | 13 | The logfmt format was first documented by Brandur Leach in [this 14 | article](https://brandur.org/logfmt). The format has not been formally 15 | standardized. The most authoritative public specification to date has been the 16 | documentation of a Go Language [package](http://godoc.org/github.com/kr/logfmt) 17 | written by Blake Mizerany and Keith Rarick. 18 | 19 | ## Goals 20 | 21 | This project attempts to conform as closely as possible to the prior art, while 22 | also removing ambiguity where necessary to provide well behaved encoder and 23 | decoder implementations. 24 | 25 | ## Non-goals 26 | 27 | This project does not attempt to formally standardize the logfmt format. In the 28 | event that logfmt is standardized this project would take conforming to the 29 | standard as a goal. 30 | 31 | ## Versioning 32 | 33 | Package logfmt publishes releases via [semver](http://semver.org/) compatible Git tags prefixed with a single 'v'. 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/headermap.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package http2 6 | 7 | import ( 8 | "net/http" 9 | "strings" 10 | ) 11 | 12 | var ( 13 | commonLowerHeader = map[string]string{} // Go-Canonical-Case -> lower-case 14 | commonCanonHeader = map[string]string{} // lower-case -> Go-Canonical-Case 15 | ) 16 | 17 | func init() { 18 | for _, v := range []string{ 19 | "accept", 20 | "accept-charset", 21 | "accept-encoding", 22 | "accept-language", 23 | "accept-ranges", 24 | "age", 25 | "access-control-allow-origin", 26 | "allow", 27 | "authorization", 28 | "cache-control", 29 | "content-disposition", 30 | "content-encoding", 31 | "content-language", 32 | "content-length", 33 | "content-location", 34 | "content-range", 35 | "content-type", 36 | "cookie", 37 | "date", 38 | "etag", 39 | "expect", 40 | "expires", 41 | "from", 42 | "host", 43 | "if-match", 44 | "if-modified-since", 45 | "if-none-match", 46 | "if-unmodified-since", 47 | "last-modified", 48 | "link", 49 | "location", 50 | "max-forwards", 51 | "proxy-authenticate", 52 | "proxy-authorization", 53 | "range", 54 | "referer", 55 | "refresh", 56 | "retry-after", 57 | "server", 58 | "set-cookie", 59 | "strict-transport-security", 60 | "trailer", 61 | "transfer-encoding", 62 | "user-agent", 63 | "vary", 64 | "via", 65 | "www-authenticate", 66 | } { 67 | chk := http.CanonicalHeaderKey(v) 68 | commonLowerHeader[chk] = v 69 | commonCanonHeader[v] = chk 70 | } 71 | } 72 | 73 | func lowerHeader(v string) string { 74 | if s, ok := commonLowerHeader[v]; ok { 75 | return s 76 | } 77 | return strings.ToLower(v) 78 | } 79 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/unicode/bidi/gen_ranges.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | package main 8 | 9 | import ( 10 | "unicode" 11 | 12 | "golang.org/x/text/internal/gen" 13 | "golang.org/x/text/internal/ucd" 14 | "golang.org/x/text/unicode/rangetable" 15 | ) 16 | 17 | // These tables are hand-extracted from: 18 | // http://www.unicode.org/Public/8.0.0/ucd/extracted/DerivedBidiClass.txt 19 | func visitDefaults(fn func(r rune, c Class)) { 20 | // first write default values for ranges listed above. 21 | visitRunes(fn, AL, []rune{ 22 | 0x0600, 0x07BF, // Arabic 23 | 0x08A0, 0x08FF, // Arabic Extended-A 24 | 0xFB50, 0xFDCF, // Arabic Presentation Forms 25 | 0xFDF0, 0xFDFF, 26 | 0xFE70, 0xFEFF, 27 | 0x0001EE00, 0x0001EEFF, // Arabic Mathematical Alpha Symbols 28 | }) 29 | visitRunes(fn, R, []rune{ 30 | 0x0590, 0x05FF, // Hebrew 31 | 0x07C0, 0x089F, // Nko et al. 32 | 0xFB1D, 0xFB4F, 33 | 0x00010800, 0x00010FFF, // Cypriot Syllabary et. al. 34 | 0x0001E800, 0x0001EDFF, 35 | 0x0001EF00, 0x0001EFFF, 36 | }) 37 | visitRunes(fn, ET, []rune{ // European Terminator 38 | 0x20A0, 0x20Cf, // Currency symbols 39 | }) 40 | rangetable.Visit(unicode.Noncharacter_Code_Point, func(r rune) { 41 | fn(r, BN) // Boundary Neutral 42 | }) 43 | ucd.Parse(gen.OpenUCDFile("DerivedCoreProperties.txt"), func(p *ucd.Parser) { 44 | if p.String(1) == "Default_Ignorable_Code_Point" { 45 | fn(p.Rune(0), BN) // Boundary Neutral 46 | } 47 | }) 48 | } 49 | 50 | func visitRunes(fn func(r rune, c Class), c Class, runes []rune) { 51 | for i := 0; i < len(runes); i += 2 { 52 | lo, hi := runes[i], runes[i+1] 53 | for j := lo; j <= hi; j++ { 54 | fn(j, c) 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /vendor/gopkg.in/jackc/pgx.v2/pgpass.go: -------------------------------------------------------------------------------- 1 | package pgx 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "os" 7 | "os/user" 8 | "path/filepath" 9 | "strings" 10 | ) 11 | 12 | func parsepgpass(cfg *ConnConfig, line string) *string { 13 | const ( 14 | backslash = "\r" 15 | colon = "\n" 16 | ) 17 | const ( 18 | host int = iota 19 | port 20 | database 21 | username 22 | pw 23 | ) 24 | line = strings.Replace(line, `\:`, colon, -1) 25 | line = strings.Replace(line, `\\`, backslash, -1) 26 | parts := strings.Split(line, `:`) 27 | if len(parts) != 5 { 28 | return nil 29 | } 30 | for i := range parts { 31 | if parts[i] == `*` { 32 | continue 33 | } 34 | parts[i] = strings.Replace(strings.Replace(parts[i], backslash, `\`, -1), colon, `:`, -1) 35 | switch i { 36 | case host: 37 | if parts[i] != cfg.Host { 38 | return nil 39 | } 40 | case port: 41 | portstr := fmt.Sprintf(`%v`, cfg.Port) 42 | if portstr == "0" { 43 | portstr = "5432" 44 | } 45 | if parts[i] != portstr { 46 | return nil 47 | } 48 | case database: 49 | if parts[i] != cfg.Database { 50 | return nil 51 | } 52 | case username: 53 | if parts[i] != cfg.User { 54 | return nil 55 | } 56 | } 57 | } 58 | return &parts[4] 59 | } 60 | 61 | func pgpass(cfg *ConnConfig) (found bool) { 62 | passfile := os.Getenv("PGPASSFILE") 63 | if passfile == "" { 64 | u, err := user.Current() 65 | if err != nil { 66 | return 67 | } 68 | passfile = filepath.Join(u.HomeDir, ".pgpass") 69 | } 70 | f, err := os.Open(passfile) 71 | if err != nil { 72 | return 73 | } 74 | defer f.Close() 75 | scanner := bufio.NewScanner(f) 76 | var pw *string 77 | for scanner.Scan() { 78 | pw = parsepgpass(cfg, scanner.Text()) 79 | if pw != nil { 80 | cfg.Password = *pw 81 | return true 82 | } 83 | } 84 | return false 85 | } 86 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/spew/bypasssafe.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Dave Collins 2 | // 3 | // Permission to use, copy, modify, and distribute this software for any 4 | // purpose with or without fee is hereby granted, provided that the above 5 | // copyright notice and this permission notice appear in all copies. 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | // NOTE: Due to the following build constraints, this file will only be compiled 16 | // when the code is running on Google App Engine, compiled by GopherJS, or 17 | // "-tags safe" is added to the go build command line. The "disableunsafe" 18 | // tag is deprecated and thus should not be used. 19 | // +build js appengine safe disableunsafe 20 | 21 | package spew 22 | 23 | import "reflect" 24 | 25 | const ( 26 | // UnsafeDisabled is a build-time constant which specifies whether or 27 | // not access to the unsafe package is available. 28 | UnsafeDisabled = true 29 | ) 30 | 31 | // unsafeReflectValue typically converts the passed reflect.Value into a one 32 | // that bypasses the typical safety restrictions preventing access to 33 | // unaddressable and unexported data. However, doing this relies on access to 34 | // the unsafe package. This is a stub version which simply returns the passed 35 | // reflect.Value when the unsafe package is not available. 36 | func unsafeReflectValue(v reflect.Value) reflect.Value { 37 | return v 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_golang/prometheus/timer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package prometheus 15 | 16 | import "time" 17 | 18 | // Timer is a helper type to time functions. Use NewTimer to create new 19 | // instances. 20 | type Timer struct { 21 | begin time.Time 22 | observer Observer 23 | } 24 | 25 | // NewTimer creates a new Timer. The provided Observer is used to observe a 26 | // duration in seconds. Timer is usually used to time a function call in the 27 | // following way: 28 | // func TimeMe() { 29 | // timer := NewTimer(myHistogram) 30 | // defer timer.ObserveDuration() 31 | // // Do actual work. 32 | // } 33 | func NewTimer(o Observer) *Timer { 34 | return &Timer{ 35 | begin: time.Now(), 36 | observer: o, 37 | } 38 | } 39 | 40 | // ObserveDuration records the duration passed since the Timer was created with 41 | // NewTimer. It calls the Observe method of the Observer provided during 42 | // construction with the duration in seconds as an argument. ObserveDuration is 43 | // usually called with a defer statement. 44 | // 45 | // Note that this method is only guaranteed to never observe negative durations 46 | // if used with Go1.9+. 47 | func (t *Timer) ObserveDuration() { 48 | if t.observer != nil { 49 | t.observer.Observe(time.Since(t.begin).Seconds()) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/unicode/bidi/trieval.go: -------------------------------------------------------------------------------- 1 | // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. 2 | 3 | package bidi 4 | 5 | // Class is the Unicode BiDi class. Each rune has a single class. 6 | type Class uint 7 | 8 | const ( 9 | L Class = iota // LeftToRight 10 | R // RightToLeft 11 | EN // EuropeanNumber 12 | ES // EuropeanSeparator 13 | ET // EuropeanTerminator 14 | AN // ArabicNumber 15 | CS // CommonSeparator 16 | B // ParagraphSeparator 17 | S // SegmentSeparator 18 | WS // WhiteSpace 19 | ON // OtherNeutral 20 | BN // BoundaryNeutral 21 | NSM // NonspacingMark 22 | AL // ArabicLetter 23 | Control // Control LRO - PDI 24 | 25 | numClass 26 | 27 | LRO // LeftToRightOverride 28 | RLO // RightToLeftOverride 29 | LRE // LeftToRightEmbedding 30 | RLE // RightToLeftEmbedding 31 | PDF // PopDirectionalFormat 32 | LRI // LeftToRightIsolate 33 | RLI // RightToLeftIsolate 34 | FSI // FirstStrongIsolate 35 | PDI // PopDirectionalIsolate 36 | 37 | unknownClass = ^Class(0) 38 | ) 39 | 40 | var controlToClass = map[rune]Class{ 41 | 0x202D: LRO, // LeftToRightOverride, 42 | 0x202E: RLO, // RightToLeftOverride, 43 | 0x202A: LRE, // LeftToRightEmbedding, 44 | 0x202B: RLE, // RightToLeftEmbedding, 45 | 0x202C: PDF, // PopDirectionalFormat, 46 | 0x2066: LRI, // LeftToRightIsolate, 47 | 0x2067: RLI, // RightToLeftIsolate, 48 | 0x2068: FSI, // FirstStrongIsolate, 49 | 0x2069: PDI, // PopDirectionalIsolate, 50 | } 51 | 52 | // A trie entry has the following bits: 53 | // 7..5 XOR mask for brackets 54 | // 4 1: Bracket open, 0: Bracket close 55 | // 3..0 Class type 56 | 57 | const ( 58 | openMask = 0x10 59 | xorMaskShift = 5 60 | ) 61 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all clean build docker pki test-pki test-public test destroy-test-env 2 | 3 | PACKAGES = $(shell go list ./... | grep -v /vendor/) 4 | 5 | all: clean build 6 | 7 | clean: 8 | go clean -i ./... 9 | find . -name \*.out -type f -delete 10 | find . -name test-\*.log -type f -delete 11 | rm -f generate_pki generate_cert generate_cert.go 12 | 13 | proto: 14 | protoc -I imap/ imap/node.proto --go_out=plugins=grpc:imap 15 | protoc -I comm/ comm/receiver.proto --go_out=plugins=grpc:comm 16 | 17 | build: 18 | CGO_ENABLED=0 go build -ldflags '-extldflags "-static"' 19 | 20 | docker: 21 | GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '-extldflags "-static"' 22 | docker build -t gopluto/pluto . 23 | 24 | pki: 25 | go build crypto/generate_pki.go 26 | ./generate_pki 27 | rm generate_pki 28 | 29 | test-pki: 30 | go build crypto/generate_pki.go 31 | ./generate_pki -pluto-config test-config.toml -rsa-bits 1024 32 | rm generate_pki 33 | 34 | test-public: 35 | if [ ! -d "private" ]; then mkdir private; fi 36 | chmod 0700 private 37 | wget https://raw.githubusercontent.com/golang/go/master/src/crypto/tls/generate_cert.go 38 | go build generate_cert.go 39 | ./generate_cert -ca -duration 2160h -host localhost,127.0.0.1,::1 -rsa-bits 1024 40 | mv cert.pem private/public-distributor-cert.pem && mv key.pem private/public-distributor-key.pem 41 | go clean 42 | rm -f generate_cert.go 43 | 44 | test: destroy-test-env 45 | @echo "mode: atomic" > coverage.out; 46 | @echo "" 47 | @for PKG in $(PACKAGES); do \ 48 | go test -v -race -coverprofile $${GOPATH}/src/$${PKG}/coverage-package.out -covermode=atomic $${PKG} || exit 1; \ 49 | test ! -f $${GOPATH}/src/$${PKG}/coverage-package.out || (cat $${GOPATH}/src/$${PKG}/coverage-package.out | grep -v mode: | sort -r >> coverage.out); \ 50 | done 51 | 52 | destroy-test-env: 53 | if [ -d "private/Maildirs" ]; then rm -rf private/Maildirs; fi 54 | if [ -d "private/crdt-layers" ]; then rm -rf private/crdt-layers; fi 55 | -------------------------------------------------------------------------------- /metrics.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/go-kit/kit/log" 7 | "github.com/go-kit/kit/log/level" 8 | "github.com/go-kit/kit/metrics/discard" 9 | "github.com/go-kit/kit/metrics/prometheus" 10 | "github.com/go-pluto/pluto/distributor" 11 | prom "github.com/prometheus/client_golang/prometheus" 12 | ) 13 | 14 | // PlutoMetrics wraps all metrics for Pluto into one struct. 15 | type PlutoMetrics struct { 16 | Distributor *distributor.Metrics 17 | } 18 | 19 | // NewPlutoMetrics returns Prometheus metrics when addr isn't 20 | // an empty string. Otherwise discard metrics are returned. 21 | func NewPlutoMetrics(distributorAddr string) *PlutoMetrics { 22 | 23 | m := &PlutoMetrics{} 24 | 25 | if distributorAddr == "" { 26 | m.Distributor = &distributor.Metrics{ 27 | Commands: discard.NewCounter(), 28 | Connections: discard.NewCounter(), 29 | } 30 | } else { 31 | m.Distributor = &distributor.Metrics{ 32 | Commands: prometheus.NewCounterFrom( 33 | prom.CounterOpts{ 34 | Namespace: "pluto", 35 | Subsystem: "distributor", 36 | Name: "commands_total", 37 | Help: "Number of commands", 38 | }, []string{"command", "status"}, 39 | ), 40 | Connections: prometheus.NewCounterFrom( 41 | prom.CounterOpts{ 42 | Namespace: "pluto", 43 | Subsystem: "distributor", 44 | Name: "connections_total", 45 | Help: "Number of connections opened to pluto", 46 | }, nil, 47 | ), 48 | } 49 | } 50 | 51 | return m 52 | } 53 | 54 | func runPromHTTP(logger log.Logger, addr string) { 55 | 56 | if addr == "" { 57 | level.Debug(logger).Log("msg", "prometheus addr is empty, not exposing prometheus metrics") 58 | return 59 | } 60 | 61 | http.Handle("/metrics", prom.UninstrumentedHandler()) 62 | 63 | level.Info(logger).Log("msg", "prometheus handler listening", "addr", addr) 64 | if err := http.ListenAndServe(addr, nil); err != nil { 65 | level.Warn(logger).Log("msg", "failed to serve prometheus metrics", "err", err) 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_golang/prometheus/observer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package prometheus 15 | 16 | // Observer is the interface that wraps the Observe method, which is used by 17 | // Histogram and Summary to add observations. 18 | type Observer interface { 19 | Observe(float64) 20 | } 21 | 22 | // The ObserverFunc type is an adapter to allow the use of ordinary 23 | // functions as Observers. If f is a function with the appropriate 24 | // signature, ObserverFunc(f) is an Observer that calls f. 25 | // 26 | // This adapter is usually used in connection with the Timer type, and there are 27 | // two general use cases: 28 | // 29 | // The most common one is to use a Gauge as the Observer for a Timer. 30 | // See the "Gauge" Timer example. 31 | // 32 | // The more advanced use case is to create a function that dynamically decides 33 | // which Observer to use for observing the duration. See the "Complex" Timer 34 | // example. 35 | type ObserverFunc func(float64) 36 | 37 | // Observe calls f(value). It implements Observer. 38 | func (f ObserverFunc) Observe(value float64) { 39 | f(value) 40 | } 41 | 42 | // ObserverVec is an interface implemented by `HistogramVec` and `SummaryVec`. 43 | type ObserverVec interface { 44 | GetMetricWith(Labels) (Observer, error) 45 | GetMetricWithLabelValues(lvs ...string) (Observer, error) 46 | With(Labels) Observer 47 | WithLabelValues(...string) Observer 48 | 49 | Collector 50 | } 51 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/unicode/bidi/gen_trieval.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | package main 8 | 9 | // Class is the Unicode BiDi class. Each rune has a single class. 10 | type Class uint 11 | 12 | const ( 13 | L Class = iota // LeftToRight 14 | R // RightToLeft 15 | EN // EuropeanNumber 16 | ES // EuropeanSeparator 17 | ET // EuropeanTerminator 18 | AN // ArabicNumber 19 | CS // CommonSeparator 20 | B // ParagraphSeparator 21 | S // SegmentSeparator 22 | WS // WhiteSpace 23 | ON // OtherNeutral 24 | BN // BoundaryNeutral 25 | NSM // NonspacingMark 26 | AL // ArabicLetter 27 | Control // Control LRO - PDI 28 | 29 | numClass 30 | 31 | LRO // LeftToRightOverride 32 | RLO // RightToLeftOverride 33 | LRE // LeftToRightEmbedding 34 | RLE // RightToLeftEmbedding 35 | PDF // PopDirectionalFormat 36 | LRI // LeftToRightIsolate 37 | RLI // RightToLeftIsolate 38 | FSI // FirstStrongIsolate 39 | PDI // PopDirectionalIsolate 40 | 41 | unknownClass = ^Class(0) 42 | ) 43 | 44 | var controlToClass = map[rune]Class{ 45 | 0x202D: LRO, // LeftToRightOverride, 46 | 0x202E: RLO, // RightToLeftOverride, 47 | 0x202A: LRE, // LeftToRightEmbedding, 48 | 0x202B: RLE, // RightToLeftEmbedding, 49 | 0x202C: PDF, // PopDirectionalFormat, 50 | 0x2066: LRI, // LeftToRightIsolate, 51 | 0x2067: RLI, // RightToLeftIsolate, 52 | 0x2068: FSI, // FirstStrongIsolate, 53 | 0x2069: PDI, // PopDirectionalIsolate, 54 | } 55 | 56 | // A trie entry has the following bits: 57 | // 7..5 XOR mask for brackets 58 | // 4 1: Bracket open, 0: Bracket close 59 | // 3..0 Class type 60 | 61 | const ( 62 | openMask = 0x10 63 | xorMaskShift = 5 64 | ) 65 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/README.md: -------------------------------------------------------------------------------- 1 | # gRPC-Go 2 | 3 | [![Build Status](https://travis-ci.org/grpc/grpc-go.svg)](https://travis-ci.org/grpc/grpc-go) [![GoDoc](https://godoc.org/google.golang.org/grpc?status.svg)](https://godoc.org/google.golang.org/grpc) 4 | 5 | The Go implementation of [gRPC](https://grpc.io/): A high performance, open source, general RPC framework that puts mobile and HTTP/2 first. For more information see the [gRPC Quick Start: Go](https://grpc.io/docs/quickstart/go.html) guide. 6 | 7 | Installation 8 | ------------ 9 | 10 | To install this package, you need to install Go and setup your Go workspace on your computer. The simplest way to install the library is to run: 11 | 12 | ``` 13 | $ go get google.golang.org/grpc 14 | ``` 15 | 16 | Prerequisites 17 | ------------- 18 | 19 | This requires Go 1.6 or later. 20 | 21 | Constraints 22 | ----------- 23 | The grpc package should only depend on standard Go packages and a small number of exceptions. If your contribution introduces new dependencies which are NOT in the [list](http://godoc.org/google.golang.org/grpc?imports), you need a discussion with gRPC-Go authors and consultants. 24 | 25 | Documentation 26 | ------------- 27 | See [API documentation](https://godoc.org/google.golang.org/grpc) for package and API descriptions and find examples in the [examples directory](examples/). 28 | 29 | Performance 30 | ----------- 31 | See the current benchmarks for some of the languages supported in [this dashboard](https://performance-dot-grpc-testing.appspot.com/explore?dashboard=5652536396611584&widget=490377658&container=1286539696). 32 | 33 | Status 34 | ------ 35 | General Availability [Google Cloud Platform Launch Stages](https://cloud.google.com/terms/launch-stages). 36 | 37 | FAQ 38 | --- 39 | 40 | #### Compiling error, undefined: grpc.SupportPackageIsVersion 41 | 42 | Please update proto package, gRPC package and rebuild the proto files: 43 | - `go get -u github.com/golang/protobuf/{proto,protoc-gen-go}` 44 | - `go get -u google.golang.org/grpc` 45 | - `protoc --go_out=plugins=grpc:. *.proto` 46 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | install: 33 | go install 34 | 35 | test: install generate-test-pbs 36 | go test 37 | 38 | 39 | generate-test-pbs: 40 | make install 41 | make -C testdata 42 | protoc --go_out=Mtestdata/test.proto=github.com/golang/protobuf/proto/testdata,Mgoogle/protobuf/any.proto=github.com/golang/protobuf/ptypes/any:. proto3_proto/proto3.proto 43 | make 44 | -------------------------------------------------------------------------------- /vendor/github.com/satori/go.uuid/README.md: -------------------------------------------------------------------------------- 1 | # UUID package for Go language 2 | 3 | [![Build Status](https://travis-ci.org/satori/go.uuid.png?branch=master)](https://travis-ci.org/satori/go.uuid) 4 | [![Coverage Status](https://coveralls.io/repos/github/satori/go.uuid/badge.svg?branch=master)](https://coveralls.io/github/satori/go.uuid) 5 | [![GoDoc](http://godoc.org/github.com/satori/go.uuid?status.png)](http://godoc.org/github.com/satori/go.uuid) 6 | 7 | This package provides pure Go implementation of Universally Unique Identifier (UUID). Supported both creation and parsing of UUIDs. 8 | 9 | With 100% test coverage and benchmarks out of box. 10 | 11 | Supported versions: 12 | * Version 1, based on timestamp and MAC address (RFC 4122) 13 | * Version 2, based on timestamp, MAC address and POSIX UID/GID (DCE 1.1) 14 | * Version 3, based on MD5 hashing (RFC 4122) 15 | * Version 4, based on random numbers (RFC 4122) 16 | * Version 5, based on SHA-1 hashing (RFC 4122) 17 | 18 | ## Installation 19 | 20 | Use the `go` command: 21 | 22 | $ go get github.com/satori/go.uuid 23 | 24 | ## Requirements 25 | 26 | UUID package requires Go >= 1.2. 27 | 28 | ## Example 29 | 30 | ```go 31 | package main 32 | 33 | import ( 34 | "fmt" 35 | "github.com/satori/go.uuid" 36 | ) 37 | 38 | func main() { 39 | // Creating UUID Version 4 40 | u1 := uuid.NewV4() 41 | fmt.Printf("UUIDv4: %s\n", u1) 42 | 43 | // Parsing UUID from string input 44 | u2, err := uuid.FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8") 45 | if err != nil { 46 | fmt.Printf("Something gone wrong: %s", err) 47 | } 48 | fmt.Printf("Successfully parsed: %s", u2) 49 | } 50 | ``` 51 | 52 | ## Documentation 53 | 54 | [Documentation](http://godoc.org/github.com/satori/go.uuid) is hosted at GoDoc project. 55 | 56 | ## Links 57 | * [RFC 4122](http://tools.ietf.org/html/rfc4122) 58 | * [DCE 1.1: Authentication and Security Services](http://pubs.opengroup.org/onlinepubs/9696989899/chap5.htm#tagcjh_08_02_01_01) 59 | 60 | ## Copyright 61 | 62 | Copyright (C) 2013-2016 by Maxim Bublis . 63 | 64 | UUID package released under MIT License. 65 | See [LICENSE](https://github.com/satori/go.uuid/blob/master/LICENSE) for details. 66 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/credentials/credentials_util_pre_go17.go: -------------------------------------------------------------------------------- 1 | // +build !go1.7 2 | 3 | /* 4 | * 5 | * Copyright 2016 gRPC authors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | package credentials 22 | 23 | import ( 24 | "crypto/tls" 25 | ) 26 | 27 | // cloneTLSConfig returns a shallow clone of the exported 28 | // fields of cfg, ignoring the unexported sync.Once, which 29 | // contains a mutex and must not be copied. 30 | // 31 | // If cfg is nil, a new zero tls.Config is returned. 32 | func cloneTLSConfig(cfg *tls.Config) *tls.Config { 33 | if cfg == nil { 34 | return &tls.Config{} 35 | } 36 | return &tls.Config{ 37 | Rand: cfg.Rand, 38 | Time: cfg.Time, 39 | Certificates: cfg.Certificates, 40 | NameToCertificate: cfg.NameToCertificate, 41 | GetCertificate: cfg.GetCertificate, 42 | RootCAs: cfg.RootCAs, 43 | NextProtos: cfg.NextProtos, 44 | ServerName: cfg.ServerName, 45 | ClientAuth: cfg.ClientAuth, 46 | ClientCAs: cfg.ClientCAs, 47 | InsecureSkipVerify: cfg.InsecureSkipVerify, 48 | CipherSuites: cfg.CipherSuites, 49 | PreferServerCipherSuites: cfg.PreferServerCipherSuites, 50 | SessionTicketsDisabled: cfg.SessionTicketsDisabled, 51 | SessionTicketKey: cfg.SessionTicketKey, 52 | ClientSessionCache: cfg.ClientSessionCache, 53 | MinVersion: cfg.MinVersion, 54 | MaxVersion: cfg.MaxVersion, 55 | CurvePreferences: cfg.CurvePreferences, 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/idna/trie.go: -------------------------------------------------------------------------------- 1 | // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. 2 | 3 | // Copyright 2016 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package idna 8 | 9 | // appendMapping appends the mapping for the respective rune. isMapped must be 10 | // true. A mapping is a categorization of a rune as defined in UTS #46. 11 | func (c info) appendMapping(b []byte, s string) []byte { 12 | index := int(c >> indexShift) 13 | if c&xorBit == 0 { 14 | s := mappings[index:] 15 | return append(b, s[1:s[0]+1]...) 16 | } 17 | b = append(b, s...) 18 | if c&inlineXOR == inlineXOR { 19 | // TODO: support and handle two-byte inline masks 20 | b[len(b)-1] ^= byte(index) 21 | } else { 22 | for p := len(b) - int(xorData[index]); p < len(b); p++ { 23 | index++ 24 | b[p] ^= xorData[index] 25 | } 26 | } 27 | return b 28 | } 29 | 30 | // Sparse block handling code. 31 | 32 | type valueRange struct { 33 | value uint16 // header: value:stride 34 | lo, hi byte // header: lo:n 35 | } 36 | 37 | type sparseBlocks struct { 38 | values []valueRange 39 | offset []uint16 40 | } 41 | 42 | var idnaSparse = sparseBlocks{ 43 | values: idnaSparseValues[:], 44 | offset: idnaSparseOffset[:], 45 | } 46 | 47 | // Don't use newIdnaTrie to avoid unconditional linking in of the table. 48 | var trie = &idnaTrie{} 49 | 50 | // lookup determines the type of block n and looks up the value for b. 51 | // For n < t.cutoff, the block is a simple lookup table. Otherwise, the block 52 | // is a list of ranges with an accompanying value. Given a matching range r, 53 | // the value for b is by r.value + (b - r.lo) * stride. 54 | func (t *sparseBlocks) lookup(n uint32, b byte) uint16 { 55 | offset := t.offset[n] 56 | header := t.values[offset] 57 | lo := offset + 1 58 | hi := lo + uint16(header.lo) 59 | for lo < hi { 60 | m := lo + (hi-lo)/2 61 | r := t.values[m] 62 | if r.lo <= b && b <= r.hi { 63 | return r.value + uint16(b-r.lo)*header.value 64 | } 65 | if b < r.lo { 66 | hi = m 67 | } else { 68 | lo = m + 1 69 | } 70 | } 71 | return 0 72 | } 73 | -------------------------------------------------------------------------------- /vendor/gopkg.in/jackc/pgx.v2/logger.go: -------------------------------------------------------------------------------- 1 | package pgx 2 | 3 | import ( 4 | "encoding/hex" 5 | "errors" 6 | "fmt" 7 | ) 8 | 9 | // The values for log levels are chosen such that the zero value means that no 10 | // log level was specified and we can default to LogLevelDebug to preserve 11 | // the behavior that existed prior to log level introduction. 12 | const ( 13 | LogLevelTrace = 6 14 | LogLevelDebug = 5 15 | LogLevelInfo = 4 16 | LogLevelWarn = 3 17 | LogLevelError = 2 18 | LogLevelNone = 1 19 | ) 20 | 21 | // Logger is the interface used to get logging from pgx internals. 22 | // https://github.com/inconshreveable/log15 is the recommended logging package. 23 | // This logging interface was extracted from there. However, it should be simple 24 | // to adapt any logger to this interface. 25 | type Logger interface { 26 | // Log a message at the given level with context key/value pairs 27 | Debug(msg string, ctx ...interface{}) 28 | Info(msg string, ctx ...interface{}) 29 | Warn(msg string, ctx ...interface{}) 30 | Error(msg string, ctx ...interface{}) 31 | } 32 | 33 | // LogLevelFromString converts log level string to constant 34 | // 35 | // Valid levels: 36 | // trace 37 | // debug 38 | // info 39 | // warn 40 | // error 41 | // none 42 | func LogLevelFromString(s string) (int, error) { 43 | switch s { 44 | case "trace": 45 | return LogLevelTrace, nil 46 | case "debug": 47 | return LogLevelDebug, nil 48 | case "info": 49 | return LogLevelInfo, nil 50 | case "warn": 51 | return LogLevelWarn, nil 52 | case "error": 53 | return LogLevelError, nil 54 | case "none": 55 | return LogLevelNone, nil 56 | default: 57 | return 0, errors.New("invalid log level") 58 | } 59 | } 60 | 61 | func logQueryArgs(args []interface{}) []interface{} { 62 | logArgs := make([]interface{}, 0, len(args)) 63 | 64 | for _, a := range args { 65 | switch v := a.(type) { 66 | case []byte: 67 | if len(v) < 64 { 68 | a = hex.EncodeToString(v) 69 | } else { 70 | a = fmt.Sprintf("%x (truncated %d bytes)", v[:64], len(v)-64) 71 | } 72 | case string: 73 | if len(v) > 64 { 74 | a = fmt.Sprintf("%s (truncated %d bytes)", v[:64], len(v)-64) 75 | } 76 | } 77 | logArgs = append(logArgs, a) 78 | } 79 | 80 | return logArgs 81 | } 82 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/writesched_random.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package http2 6 | 7 | import "math" 8 | 9 | // NewRandomWriteScheduler constructs a WriteScheduler that ignores HTTP/2 10 | // priorities. Control frames like SETTINGS and PING are written before DATA 11 | // frames, but if no control frames are queued and multiple streams have queued 12 | // HEADERS or DATA frames, Pop selects a ready stream arbitrarily. 13 | func NewRandomWriteScheduler() WriteScheduler { 14 | return &randomWriteScheduler{sq: make(map[uint32]*writeQueue)} 15 | } 16 | 17 | type randomWriteScheduler struct { 18 | // zero are frames not associated with a specific stream. 19 | zero writeQueue 20 | 21 | // sq contains the stream-specific queues, keyed by stream ID. 22 | // When a stream is idle or closed, it's deleted from the map. 23 | sq map[uint32]*writeQueue 24 | 25 | // pool of empty queues for reuse. 26 | queuePool writeQueuePool 27 | } 28 | 29 | func (ws *randomWriteScheduler) OpenStream(streamID uint32, options OpenStreamOptions) { 30 | // no-op: idle streams are not tracked 31 | } 32 | 33 | func (ws *randomWriteScheduler) CloseStream(streamID uint32) { 34 | q, ok := ws.sq[streamID] 35 | if !ok { 36 | return 37 | } 38 | delete(ws.sq, streamID) 39 | ws.queuePool.put(q) 40 | } 41 | 42 | func (ws *randomWriteScheduler) AdjustStream(streamID uint32, priority PriorityParam) { 43 | // no-op: priorities are ignored 44 | } 45 | 46 | func (ws *randomWriteScheduler) Push(wr FrameWriteRequest) { 47 | id := wr.StreamID() 48 | if id == 0 { 49 | ws.zero.push(wr) 50 | return 51 | } 52 | q, ok := ws.sq[id] 53 | if !ok { 54 | q = ws.queuePool.get() 55 | ws.sq[id] = q 56 | } 57 | q.push(wr) 58 | } 59 | 60 | func (ws *randomWriteScheduler) Pop() (FrameWriteRequest, bool) { 61 | // Control frames first. 62 | if !ws.zero.empty() { 63 | return ws.zero.shift(), true 64 | } 65 | // Iterate over all non-idle streams until finding one that can be consumed. 66 | for _, q := range ws.sq { 67 | if wr, ok := q.consume(math.MaxInt32); ok { 68 | return wr, true 69 | } 70 | } 71 | return FrameWriteRequest{}, false 72 | } 73 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/naming/naming.go: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 gRPC authors. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | */ 18 | 19 | // Package naming defines the naming API and related data structures for gRPC. 20 | // The interface is EXPERIMENTAL and may be suject to change. 21 | package naming 22 | 23 | // Operation defines the corresponding operations for a name resolution change. 24 | type Operation uint8 25 | 26 | const ( 27 | // Add indicates a new address is added. 28 | Add Operation = iota 29 | // Delete indicates an exisiting address is deleted. 30 | Delete 31 | ) 32 | 33 | // Update defines a name resolution update. Notice that it is not valid having both 34 | // empty string Addr and nil Metadata in an Update. 35 | type Update struct { 36 | // Op indicates the operation of the update. 37 | Op Operation 38 | // Addr is the updated address. It is empty string if there is no address update. 39 | Addr string 40 | // Metadata is the updated metadata. It is nil if there is no metadata update. 41 | // Metadata is not required for a custom naming implementation. 42 | Metadata interface{} 43 | } 44 | 45 | // Resolver creates a Watcher for a target to track its resolution changes. 46 | type Resolver interface { 47 | // Resolve creates a Watcher for target. 48 | Resolve(target string) (Watcher, error) 49 | } 50 | 51 | // Watcher watches for the updates on the specified target. 52 | type Watcher interface { 53 | // Next blocks until an update or error happens. It may return one or more 54 | // updates. The first call should get the full set of the results. It should 55 | // return an error if and only if Watcher cannot recover. 56 | Next() ([]*Update, error) 57 | // Close closes the Watcher. 58 | Close() 59 | } 60 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/credentials/credentials_util_go17.go: -------------------------------------------------------------------------------- 1 | // +build go1.7 2 | // +build !go1.8 3 | 4 | /* 5 | * 6 | * Copyright 2016 gRPC authors. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | */ 21 | 22 | package credentials 23 | 24 | import ( 25 | "crypto/tls" 26 | ) 27 | 28 | // cloneTLSConfig returns a shallow clone of the exported 29 | // fields of cfg, ignoring the unexported sync.Once, which 30 | // contains a mutex and must not be copied. 31 | // 32 | // If cfg is nil, a new zero tls.Config is returned. 33 | func cloneTLSConfig(cfg *tls.Config) *tls.Config { 34 | if cfg == nil { 35 | return &tls.Config{} 36 | } 37 | return &tls.Config{ 38 | Rand: cfg.Rand, 39 | Time: cfg.Time, 40 | Certificates: cfg.Certificates, 41 | NameToCertificate: cfg.NameToCertificate, 42 | GetCertificate: cfg.GetCertificate, 43 | RootCAs: cfg.RootCAs, 44 | NextProtos: cfg.NextProtos, 45 | ServerName: cfg.ServerName, 46 | ClientAuth: cfg.ClientAuth, 47 | ClientCAs: cfg.ClientCAs, 48 | InsecureSkipVerify: cfg.InsecureSkipVerify, 49 | CipherSuites: cfg.CipherSuites, 50 | PreferServerCipherSuites: cfg.PreferServerCipherSuites, 51 | SessionTicketsDisabled: cfg.SessionTicketsDisabled, 52 | SessionTicketKey: cfg.SessionTicketKey, 53 | ClientSessionCache: cfg.ClientSessionCache, 54 | MinVersion: cfg.MinVersion, 55 | MaxVersion: cfg.MaxVersion, 56 | CurvePreferences: cfg.CurvePreferences, 57 | DynamicRecordSizingDisabled: cfg.DynamicRecordSizingDisabled, 58 | Renegotiation: cfg.Renegotiation, 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | We definitely welcome your patches and contributions to gRPC! 4 | 5 | If you are new to github, please start by reading [Pull Request howto](https://help.github.com/articles/about-pull-requests/) 6 | 7 | ## Legal requirements 8 | 9 | In order to protect both you and ourselves, you will need to sign the 10 | [Contributor License Agreement](https://cla.developers.google.com/clas). 11 | 12 | ## Guidelines for Pull Requests 13 | How to get your contributions merged smoothly and quickly. 14 | 15 | - Create **small PRs** that are narrowly focused on **addressing a single concern**. We often times receive PRs that are trying to fix several things at a time, but only one fix is considered acceptable, nothing gets merged and both author's & review's time is wasted. Create more PRs to address different concerns and everyone will be happy. 16 | 17 | - For speculative changes, consider opening an issue and discussing it first. If you are suggesting a behavioral or API change, consider starting with a [gRFC proposal](https://github.com/grpc/proposal). 18 | 19 | - Provide a good **PR description** as a record of **what** change is being made and **why** it was made. Link to a github issue if it exists. 20 | 21 | - Don't fix code style and formatting unless you are already changing that line to address an issue. PRs with irrelevant changes won't be merged. If you do want to fix formatting or style, do that in a separate PR. 22 | 23 | - Unless your PR is trivial, you should expect there will be reviewer comments that you'll need to address before merging. We expect you to be reasonably responsive to those comments, otherwise the PR will be closed after 2-3 weeks of inactivity. 24 | 25 | - Maintain **clean commit history** and use **meaningful commit messages**. PRs with messy commit history are difficult to review and won't be merged. Use `rebase -i upstream/master` to curate your commit history and/or to bring in latest changes from master (but avoid rebasing in the middle of a code review). 26 | 27 | - Keep your PR up to date with upstream/master (if there are merge conflicts, we can't really merge your change). 28 | 29 | - **All tests need to be passing** before your change can be merged. We recommend you **run tests locally** before creating your PR to catch breakages early on. 30 | 31 | - Exceptions to the rules can be made if there's a compelling reason for doing so. 32 | 33 | -------------------------------------------------------------------------------- /vendor/github.com/go-kit/kit/log/json_logger.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "encoding" 5 | "encoding/json" 6 | "fmt" 7 | "io" 8 | "reflect" 9 | ) 10 | 11 | type jsonLogger struct { 12 | io.Writer 13 | } 14 | 15 | // NewJSONLogger returns a Logger that encodes keyvals to the Writer as a 16 | // single JSON object. Each log event produces no more than one call to 17 | // w.Write. The passed Writer must be safe for concurrent use by multiple 18 | // goroutines if the returned Logger will be used concurrently. 19 | func NewJSONLogger(w io.Writer) Logger { 20 | return &jsonLogger{w} 21 | } 22 | 23 | func (l *jsonLogger) Log(keyvals ...interface{}) error { 24 | n := (len(keyvals) + 1) / 2 // +1 to handle case when len is odd 25 | m := make(map[string]interface{}, n) 26 | for i := 0; i < len(keyvals); i += 2 { 27 | k := keyvals[i] 28 | var v interface{} = ErrMissingValue 29 | if i+1 < len(keyvals) { 30 | v = keyvals[i+1] 31 | } 32 | merge(m, k, v) 33 | } 34 | return json.NewEncoder(l.Writer).Encode(m) 35 | } 36 | 37 | func merge(dst map[string]interface{}, k, v interface{}) { 38 | var key string 39 | switch x := k.(type) { 40 | case string: 41 | key = x 42 | case fmt.Stringer: 43 | key = safeString(x) 44 | default: 45 | key = fmt.Sprint(x) 46 | } 47 | if x, ok := v.(error); ok { 48 | v = safeError(x) 49 | } 50 | 51 | // We want json.Marshaler and encoding.TextMarshaller to take priority over 52 | // err.Error() and v.String(). But json.Marshall (called later) does that by 53 | // default so we force a no-op if it's one of those 2 case. 54 | switch x := v.(type) { 55 | case json.Marshaler: 56 | case encoding.TextMarshaler: 57 | case error: 58 | v = safeError(x) 59 | case fmt.Stringer: 60 | v = safeString(x) 61 | } 62 | 63 | dst[key] = v 64 | } 65 | 66 | func safeString(str fmt.Stringer) (s string) { 67 | defer func() { 68 | if panicVal := recover(); panicVal != nil { 69 | if v := reflect.ValueOf(str); v.Kind() == reflect.Ptr && v.IsNil() { 70 | s = "NULL" 71 | } else { 72 | panic(panicVal) 73 | } 74 | } 75 | }() 76 | s = str.String() 77 | return 78 | } 79 | 80 | func safeError(err error) (s interface{}) { 81 | defer func() { 82 | if panicVal := recover(); panicVal != nil { 83 | if v := reflect.ValueOf(err); v.Kind() == reflect.Ptr && v.IsNil() { 84 | s = nil 85 | } else { 86 | panic(panicVal) 87 | } 88 | } 89 | }() 90 | s = err.Error() 91 | return 92 | } 93 | -------------------------------------------------------------------------------- /utils/utils.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "fmt" 5 | 6 | "crypto/tls" 7 | "crypto/x509" 8 | "io/ioutil" 9 | 10 | "github.com/go-pluto/pluto/config" 11 | "github.com/go-pluto/pluto/crypto" 12 | ) 13 | 14 | // Structs 15 | 16 | // TestEnv carries everything needed for a full 17 | // grown test of pluto with multiple nodes. 18 | type TestEnv struct { 19 | Config *config.Config 20 | TLSConfig *tls.Config 21 | Addr string 22 | DownDistr chan struct{} 23 | DownWorker chan struct{} 24 | DownStorage chan struct{} 25 | DoneDistr chan struct{} 26 | DoneWorker chan struct{} 27 | DoneStorage chan struct{} 28 | } 29 | 30 | // CreateTestEnv initializes the needed environment 31 | // for performing various tests against a potentially 32 | // complete pluto setup. 33 | func CreateTestEnv(configFilePath string) (*TestEnv, error) { 34 | 35 | // Read configuration from file. 36 | config, err := config.LoadConfig(configFilePath) 37 | if err != nil { 38 | return nil, err 39 | } 40 | 41 | // Create public TLS config (distributor). 42 | tlsConfig, err := crypto.NewPublicTLSConfig(config.Distributor.PublicCertLoc, config.Distributor.PublicKeyLoc) 43 | if err != nil { 44 | return nil, err 45 | } 46 | 47 | // For tests, we currently need to build a custom 48 | // x509 cert pool to accept the self-signed public 49 | // distributor certificate. 50 | tlsConfig.RootCAs = x509.NewCertPool() 51 | 52 | // Read distributor's public certificate in PEM format 53 | // specified in pluto's main config file into memory. 54 | rootCert, err := ioutil.ReadFile(config.Distributor.PublicCertLoc) 55 | if err != nil { 56 | return nil, fmt.Errorf("reading distributor's public certificate into memory failed with: %v", err) 57 | } 58 | 59 | // Append certificate to test client's root CA pool. 60 | if ok := tlsConfig.RootCAs.AppendCertsFromPEM(rootCert); !ok { 61 | return nil, fmt.Errorf("failed to append certificate to pool: %v", err) 62 | } 63 | 64 | // Return properly initilized and complete struct 65 | // representing a test environment. 66 | return &TestEnv{ 67 | Config: config, 68 | TLSConfig: tlsConfig, 69 | Addr: config.Distributor.PublicMailAddr, 70 | DownDistr: make(chan struct{}), 71 | DownWorker: make(chan struct{}), 72 | DownStorage: make(chan struct{}), 73 | DoneDistr: make(chan struct{}), 74 | DoneWorker: make(chan struct{}), 75 | DoneStorage: make(chan struct{}), 76 | }, nil 77 | } 78 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/grpclog/logger.go: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2015 gRPC authors. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | */ 18 | 19 | package grpclog 20 | 21 | // Logger mimics golang's standard Logger as an interface. 22 | // Deprecated: use LoggerV2. 23 | type Logger interface { 24 | Fatal(args ...interface{}) 25 | Fatalf(format string, args ...interface{}) 26 | Fatalln(args ...interface{}) 27 | Print(args ...interface{}) 28 | Printf(format string, args ...interface{}) 29 | Println(args ...interface{}) 30 | } 31 | 32 | // SetLogger sets the logger that is used in grpc. Call only from 33 | // init() functions. 34 | // Deprecated: use SetLoggerV2. 35 | func SetLogger(l Logger) { 36 | logger = &loggerWrapper{Logger: l} 37 | } 38 | 39 | // loggerWrapper wraps Logger into a LoggerV2. 40 | type loggerWrapper struct { 41 | Logger 42 | } 43 | 44 | func (g *loggerWrapper) Info(args ...interface{}) { 45 | g.Logger.Print(args...) 46 | } 47 | 48 | func (g *loggerWrapper) Infoln(args ...interface{}) { 49 | g.Logger.Println(args...) 50 | } 51 | 52 | func (g *loggerWrapper) Infof(format string, args ...interface{}) { 53 | g.Logger.Printf(format, args...) 54 | } 55 | 56 | func (g *loggerWrapper) Warning(args ...interface{}) { 57 | g.Logger.Print(args...) 58 | } 59 | 60 | func (g *loggerWrapper) Warningln(args ...interface{}) { 61 | g.Logger.Println(args...) 62 | } 63 | 64 | func (g *loggerWrapper) Warningf(format string, args ...interface{}) { 65 | g.Logger.Printf(format, args...) 66 | } 67 | 68 | func (g *loggerWrapper) Error(args ...interface{}) { 69 | g.Logger.Print(args...) 70 | } 71 | 72 | func (g *loggerWrapper) Errorln(args ...interface{}) { 73 | g.Logger.Println(args...) 74 | } 75 | 76 | func (g *loggerWrapper) Errorf(format string, args ...interface{}) { 77 | g.Logger.Printf(format, args...) 78 | } 79 | 80 | func (g *loggerWrapper) V(l int) bool { 81 | // Returns true for all verbose level. 82 | return true 83 | } 84 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/context/context.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package context defines the Context type, which carries deadlines, 6 | // cancelation signals, and other request-scoped values across API boundaries 7 | // and between processes. 8 | // 9 | // Incoming requests to a server should create a Context, and outgoing calls to 10 | // servers should accept a Context. The chain of function calls between must 11 | // propagate the Context, optionally replacing it with a modified copy created 12 | // using WithDeadline, WithTimeout, WithCancel, or WithValue. 13 | // 14 | // Programs that use Contexts should follow these rules to keep interfaces 15 | // consistent across packages and enable static analysis tools to check context 16 | // propagation: 17 | // 18 | // Do not store Contexts inside a struct type; instead, pass a Context 19 | // explicitly to each function that needs it. The Context should be the first 20 | // parameter, typically named ctx: 21 | // 22 | // func DoSomething(ctx context.Context, arg Arg) error { 23 | // // ... use ctx ... 24 | // } 25 | // 26 | // Do not pass a nil Context, even if a function permits it. Pass context.TODO 27 | // if you are unsure about which Context to use. 28 | // 29 | // Use context Values only for request-scoped data that transits processes and 30 | // APIs, not for passing optional parameters to functions. 31 | // 32 | // The same Context may be passed to functions running in different goroutines; 33 | // Contexts are safe for simultaneous use by multiple goroutines. 34 | // 35 | // See http://blog.golang.org/context for example code for a server that uses 36 | // Contexts. 37 | package context // import "golang.org/x/net/context" 38 | 39 | // Background returns a non-nil, empty Context. It is never canceled, has no 40 | // values, and has no deadline. It is typically used by the main function, 41 | // initialization, and tests, and as the top-level Context for incoming 42 | // requests. 43 | func Background() Context { 44 | return background 45 | } 46 | 47 | // TODO returns a non-nil, empty Context. Code should use context.TODO when 48 | // it's unclear which Context to use or it is not yet available (because the 49 | // surrounding function has not yet been extended to accept a Context 50 | // parameter). TODO is recognized by static analysis tools that determine 51 | // whether Contexts are propagated correctly in a program. 52 | func TODO() Context { 53 | return todo 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg/README.txt: -------------------------------------------------------------------------------- 1 | PACKAGE 2 | 3 | package goautoneg 4 | import "bitbucket.org/ww/goautoneg" 5 | 6 | HTTP Content-Type Autonegotiation. 7 | 8 | The functions in this package implement the behaviour specified in 9 | http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html 10 | 11 | Copyright (c) 2011, Open Knowledge Foundation Ltd. 12 | All rights reserved. 13 | 14 | Redistribution and use in source and binary forms, with or without 15 | modification, are permitted provided that the following conditions are 16 | met: 17 | 18 | Redistributions of source code must retain the above copyright 19 | notice, this list of conditions and the following disclaimer. 20 | 21 | Redistributions in binary form must reproduce the above copyright 22 | notice, this list of conditions and the following disclaimer in 23 | the documentation and/or other materials provided with the 24 | distribution. 25 | 26 | Neither the name of the Open Knowledge Foundation Ltd. nor the 27 | names of its contributors may be used to endorse or promote 28 | products derived from this software without specific prior written 29 | permission. 30 | 31 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 34 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 36 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 37 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 38 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 39 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 40 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 41 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 42 | 43 | 44 | FUNCTIONS 45 | 46 | func Negotiate(header string, alternatives []string) (content_type string) 47 | Negotiate the most appropriate content_type given the accept header 48 | and a list of alternatives. 49 | 50 | func ParseAccept(header string) (accept []Accept) 51 | Parse an Accept Header string returning a sorted list 52 | of clauses 53 | 54 | 55 | TYPES 56 | 57 | type Accept struct { 58 | Type, SubType string 59 | Q float32 60 | Params map[string]string 61 | } 62 | Structure to represent a clause in an HTTP Accept Header 63 | 64 | 65 | SUBDIRECTORIES 66 | 67 | .hg 68 | -------------------------------------------------------------------------------- /test-config.toml: -------------------------------------------------------------------------------- 1 | RootCertLoc = "private/root-cert.pem" 2 | 3 | 4 | [IMAP] 5 | Greeting = "Pluto ready." 6 | HierarchySeparator = "." 7 | 8 | 9 | [Distributor] 10 | Name = "eu-west-distributor" 11 | PublicMailAddr = "127.0.0.1:19933" 12 | ListenMailAddr = "127.0.0.1:19933" 13 | PrometheusAddr = "127.0.0.1:9001" 14 | PublicCertLoc = "private/public-distributor-cert.pem" 15 | PublicKeyLoc = "private/public-distributor-key.pem" 16 | InternalCertLoc = "private/internal-distributor-cert.pem" 17 | InternalKeyLoc = "private/internal-distributor-key.pem" 18 | AuthAdapter = "AuthFile" 19 | 20 | [Distributor.AuthFile] 21 | File = "test-users.txt" 22 | Separator = ";" 23 | 24 | 25 | [Workers] 26 | 27 | [Workers.worker-1] 28 | Name = "eu-west-worker-1" 29 | PublicMailAddr = "127.0.0.1:20001" 30 | ListenMailAddr = "127.0.0.1:20001" 31 | PublicSyncAddr = "127.0.0.1:30001" 32 | ListenSyncAddr = "127.0.0.1:30001" 33 | PrometheusAddr = "127.0.0.1:9001" 34 | CertLoc = "private/internal-worker-1-cert.pem" 35 | KeyLoc = "private/internal-worker-1-key.pem" 36 | UserStart = 1 37 | UserEnd = 10 38 | MaildirRoot = "private/Maildirs/worker-1/" 39 | CRDTLayerRoot = "private/crdt-layers/worker-1/" 40 | 41 | [Workers.worker-1.Peers.subnet-1] 42 | us-west-worker-1 = "127.0.0.1:30101" 43 | asia-south-worker-1 = "127.0.0.1:30201" 44 | storage = "127.0.0.1:31000" 45 | 46 | 47 | [Storage] 48 | Name = "storage" 49 | PublicMailAddr = "127.0.0.1:21000" 50 | ListenMailAddr = "127.0.0.1:21000" 51 | PrometheusAddr = "127.0.0.1:9001" 52 | CertLoc = "private/internal-storage-cert.pem" 53 | KeyLoc = "private/internal-storage-key.pem" 54 | MaildirRoot = "private/Maildirs/storage/" 55 | CRDTLayerRoot = "private/crdt-layers/storage/" 56 | 57 | [Storage.SyncAddrs.subnet-1] 58 | Public = "127.0.0.1:31000" 59 | Listen = "127.0.0.1:31000" 60 | 61 | [Storage.Peers.subnet-1] 62 | eu-west-worker-1 = "127.0.0.1:30001" 63 | us-west-worker-1 = "127.0.0.1:30101" 64 | asia-south-worker-1 = "127.0.0.1:30201" 65 | 66 | [Storage.SyncAddrs.subnet-2] 67 | Public = "127.0.0.1:32000" 68 | Listen = "127.0.0.1:32000" 69 | 70 | [Storage.Peers.subnet-2] 71 | eu-west-worker-2 = "127.0.0.1:30002" 72 | us-west-worker-2 = "127.0.0.1:30102" 73 | asia-south-worker-2 = "127.0.0.1:30202" 74 | 75 | [Storage.SyncAddrs.subnet-3] 76 | Public = "127.0.0.1:33000" 77 | Listen = "127.0.0.1:33000" 78 | 79 | [Storage.Peers.subnet-3] 80 | eu-west-worker-3 = "127.0.0.1:30003" 81 | us-west-worker-3 = "127.0.0.1:30103" 82 | asia-south-worker-3 = "127.0.0.1:30203" 83 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/stats/handlers.go: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2016 gRPC authors. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | */ 18 | 19 | package stats 20 | 21 | import ( 22 | "net" 23 | 24 | "golang.org/x/net/context" 25 | ) 26 | 27 | // ConnTagInfo defines the relevant information needed by connection context tagger. 28 | type ConnTagInfo struct { 29 | // RemoteAddr is the remote address of the corresponding connection. 30 | RemoteAddr net.Addr 31 | // LocalAddr is the local address of the corresponding connection. 32 | LocalAddr net.Addr 33 | } 34 | 35 | // RPCTagInfo defines the relevant information needed by RPC context tagger. 36 | type RPCTagInfo struct { 37 | // FullMethodName is the RPC method in the format of /package.service/method. 38 | FullMethodName string 39 | // FailFast indicates if this RPC is failfast. 40 | // This field is only valid on client side, it's always false on server side. 41 | FailFast bool 42 | } 43 | 44 | // Handler defines the interface for the related stats handling (e.g., RPCs, connections). 45 | type Handler interface { 46 | // TagRPC can attach some information to the given context. 47 | // The context used for the rest lifetime of the RPC will be derived from 48 | // the returned context. 49 | TagRPC(context.Context, *RPCTagInfo) context.Context 50 | // HandleRPC processes the RPC stats. 51 | HandleRPC(context.Context, RPCStats) 52 | 53 | // TagConn can attach some information to the given context. 54 | // The returned context will be used for stats handling. 55 | // For conn stats handling, the context used in HandleConn for this 56 | // connection will be derived from the context returned. 57 | // For RPC stats handling, 58 | // - On server side, the context used in HandleRPC for all RPCs on this 59 | // connection will be derived from the context returned. 60 | // - On client side, the context is not derived from the context returned. 61 | TagConn(context.Context, *ConnTagInfo) context.Context 62 | // HandleConn processes the Conn stats. 63 | HandleConn(context.Context, ConnStats) 64 | } 65 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/configure_transport.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.6 6 | 7 | package http2 8 | 9 | import ( 10 | "crypto/tls" 11 | "fmt" 12 | "net/http" 13 | ) 14 | 15 | func configureTransport(t1 *http.Transport) (*Transport, error) { 16 | connPool := new(clientConnPool) 17 | t2 := &Transport{ 18 | ConnPool: noDialClientConnPool{connPool}, 19 | t1: t1, 20 | } 21 | connPool.t = t2 22 | if err := registerHTTPSProtocol(t1, noDialH2RoundTripper{t2}); err != nil { 23 | return nil, err 24 | } 25 | if t1.TLSClientConfig == nil { 26 | t1.TLSClientConfig = new(tls.Config) 27 | } 28 | if !strSliceContains(t1.TLSClientConfig.NextProtos, "h2") { 29 | t1.TLSClientConfig.NextProtos = append([]string{"h2"}, t1.TLSClientConfig.NextProtos...) 30 | } 31 | if !strSliceContains(t1.TLSClientConfig.NextProtos, "http/1.1") { 32 | t1.TLSClientConfig.NextProtos = append(t1.TLSClientConfig.NextProtos, "http/1.1") 33 | } 34 | upgradeFn := func(authority string, c *tls.Conn) http.RoundTripper { 35 | addr := authorityAddr("https", authority) 36 | if used, err := connPool.addConnIfNeeded(addr, t2, c); err != nil { 37 | go c.Close() 38 | return erringRoundTripper{err} 39 | } else if !used { 40 | // Turns out we don't need this c. 41 | // For example, two goroutines made requests to the same host 42 | // at the same time, both kicking off TCP dials. (since protocol 43 | // was unknown) 44 | go c.Close() 45 | } 46 | return t2 47 | } 48 | if m := t1.TLSNextProto; len(m) == 0 { 49 | t1.TLSNextProto = map[string]func(string, *tls.Conn) http.RoundTripper{ 50 | "h2": upgradeFn, 51 | } 52 | } else { 53 | m["h2"] = upgradeFn 54 | } 55 | return t2, nil 56 | } 57 | 58 | // registerHTTPSProtocol calls Transport.RegisterProtocol but 59 | // converting panics into errors. 60 | func registerHTTPSProtocol(t *http.Transport, rt http.RoundTripper) (err error) { 61 | defer func() { 62 | if e := recover(); e != nil { 63 | err = fmt.Errorf("%v", e) 64 | } 65 | }() 66 | t.RegisterProtocol("https", rt) 67 | return nil 68 | } 69 | 70 | // noDialH2RoundTripper is a RoundTripper which only tries to complete the request 71 | // if there's already has a cached connection to the host. 72 | type noDialH2RoundTripper struct{ t *Transport } 73 | 74 | func (rt noDialH2RoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { 75 | res, err := rt.t.RoundTrip(req) 76 | if err == ErrNoCachedConn { 77 | return nil, http.ErrSkipAltProtocol 78 | } 79 | return res, err 80 | } 81 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/unicode/norm/input.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package norm 6 | 7 | import "unicode/utf8" 8 | 9 | type input struct { 10 | str string 11 | bytes []byte 12 | } 13 | 14 | func inputBytes(str []byte) input { 15 | return input{bytes: str} 16 | } 17 | 18 | func inputString(str string) input { 19 | return input{str: str} 20 | } 21 | 22 | func (in *input) setBytes(str []byte) { 23 | in.str = "" 24 | in.bytes = str 25 | } 26 | 27 | func (in *input) setString(str string) { 28 | in.str = str 29 | in.bytes = nil 30 | } 31 | 32 | func (in *input) _byte(p int) byte { 33 | if in.bytes == nil { 34 | return in.str[p] 35 | } 36 | return in.bytes[p] 37 | } 38 | 39 | func (in *input) skipASCII(p, max int) int { 40 | if in.bytes == nil { 41 | for ; p < max && in.str[p] < utf8.RuneSelf; p++ { 42 | } 43 | } else { 44 | for ; p < max && in.bytes[p] < utf8.RuneSelf; p++ { 45 | } 46 | } 47 | return p 48 | } 49 | 50 | func (in *input) skipContinuationBytes(p int) int { 51 | if in.bytes == nil { 52 | for ; p < len(in.str) && !utf8.RuneStart(in.str[p]); p++ { 53 | } 54 | } else { 55 | for ; p < len(in.bytes) && !utf8.RuneStart(in.bytes[p]); p++ { 56 | } 57 | } 58 | return p 59 | } 60 | 61 | func (in *input) appendSlice(buf []byte, b, e int) []byte { 62 | if in.bytes != nil { 63 | return append(buf, in.bytes[b:e]...) 64 | } 65 | for i := b; i < e; i++ { 66 | buf = append(buf, in.str[i]) 67 | } 68 | return buf 69 | } 70 | 71 | func (in *input) copySlice(buf []byte, b, e int) int { 72 | if in.bytes == nil { 73 | return copy(buf, in.str[b:e]) 74 | } 75 | return copy(buf, in.bytes[b:e]) 76 | } 77 | 78 | func (in *input) charinfoNFC(p int) (uint16, int) { 79 | if in.bytes == nil { 80 | return nfcData.lookupString(in.str[p:]) 81 | } 82 | return nfcData.lookup(in.bytes[p:]) 83 | } 84 | 85 | func (in *input) charinfoNFKC(p int) (uint16, int) { 86 | if in.bytes == nil { 87 | return nfkcData.lookupString(in.str[p:]) 88 | } 89 | return nfkcData.lookup(in.bytes[p:]) 90 | } 91 | 92 | func (in *input) hangul(p int) (r rune) { 93 | var size int 94 | if in.bytes == nil { 95 | if !isHangulString(in.str[p:]) { 96 | return 0 97 | } 98 | r, size = utf8.DecodeRuneInString(in.str[p:]) 99 | } else { 100 | if !isHangul(in.bytes[p:]) { 101 | return 0 102 | } 103 | r, size = utf8.DecodeRune(in.bytes[p:]) 104 | } 105 | if size != hangulUTF8Size { 106 | return 0 107 | } 108 | return r 109 | } 110 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/unicode/norm/transform.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package norm 6 | 7 | import ( 8 | "unicode/utf8" 9 | 10 | "golang.org/x/text/transform" 11 | ) 12 | 13 | // Reset implements the Reset method of the transform.Transformer interface. 14 | func (Form) Reset() {} 15 | 16 | // Transform implements the Transform method of the transform.Transformer 17 | // interface. It may need to write segments of up to MaxSegmentSize at once. 18 | // Users should either catch ErrShortDst and allow dst to grow or have dst be at 19 | // least of size MaxTransformChunkSize to be guaranteed of progress. 20 | func (f Form) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) { 21 | n := 0 22 | // Cap the maximum number of src bytes to check. 23 | b := src 24 | eof := atEOF 25 | if ns := len(dst); ns < len(b) { 26 | err = transform.ErrShortDst 27 | eof = false 28 | b = b[:ns] 29 | } 30 | i, ok := formTable[f].quickSpan(inputBytes(b), n, len(b), eof) 31 | n += copy(dst[n:], b[n:i]) 32 | if !ok { 33 | nDst, nSrc, err = f.transform(dst[n:], src[n:], atEOF) 34 | return nDst + n, nSrc + n, err 35 | } 36 | if n < len(src) && !atEOF { 37 | err = transform.ErrShortSrc 38 | } 39 | return n, n, err 40 | } 41 | 42 | func flushTransform(rb *reorderBuffer) bool { 43 | // Write out (must fully fit in dst, or else it is a ErrShortDst). 44 | if len(rb.out) < rb.nrune*utf8.UTFMax { 45 | return false 46 | } 47 | rb.out = rb.out[rb.flushCopy(rb.out):] 48 | return true 49 | } 50 | 51 | var errs = []error{nil, transform.ErrShortDst, transform.ErrShortSrc} 52 | 53 | // transform implements the transform.Transformer interface. It is only called 54 | // when quickSpan does not pass for a given string. 55 | func (f Form) transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) { 56 | // TODO: get rid of reorderBuffer. See CL 23460044. 57 | rb := reorderBuffer{} 58 | rb.init(f, src) 59 | for { 60 | // Load segment into reorder buffer. 61 | rb.setFlusher(dst[nDst:], flushTransform) 62 | end := decomposeSegment(&rb, nSrc, atEOF) 63 | if end < 0 { 64 | return nDst, nSrc, errs[-end] 65 | } 66 | nDst = len(dst) - len(rb.out) 67 | nSrc = end 68 | 69 | // Next quickSpan. 70 | end = rb.nsrc 71 | eof := atEOF 72 | if n := nSrc + len(dst) - nDst; n < end { 73 | err = transform.ErrShortDst 74 | end = n 75 | eof = false 76 | } 77 | end, ok := rb.f.quickSpan(rb.src, nSrc, end, eof) 78 | n := copy(dst[nDst:], rb.src.bytes[nSrc:end]) 79 | nSrc += n 80 | nDst += n 81 | if ok { 82 | if n < rb.nsrc && !atEOF { 83 | err = transform.ErrShortSrc 84 | } 85 | return nDst, nSrc, err 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/not_go17.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.7 6 | 7 | package http2 8 | 9 | import ( 10 | "crypto/tls" 11 | "net" 12 | "net/http" 13 | "time" 14 | ) 15 | 16 | type contextContext interface { 17 | Done() <-chan struct{} 18 | Err() error 19 | } 20 | 21 | type fakeContext struct{} 22 | 23 | func (fakeContext) Done() <-chan struct{} { return nil } 24 | func (fakeContext) Err() error { panic("should not be called") } 25 | 26 | func reqContext(r *http.Request) fakeContext { 27 | return fakeContext{} 28 | } 29 | 30 | func setResponseUncompressed(res *http.Response) { 31 | // Nothing. 32 | } 33 | 34 | type clientTrace struct{} 35 | 36 | func requestTrace(*http.Request) *clientTrace { return nil } 37 | func traceGotConn(*http.Request, *ClientConn) {} 38 | func traceFirstResponseByte(*clientTrace) {} 39 | func traceWroteHeaders(*clientTrace) {} 40 | func traceWroteRequest(*clientTrace, error) {} 41 | func traceGot100Continue(trace *clientTrace) {} 42 | func traceWait100Continue(trace *clientTrace) {} 43 | 44 | func nop() {} 45 | 46 | func serverConnBaseContext(c net.Conn, opts *ServeConnOpts) (ctx contextContext, cancel func()) { 47 | return nil, nop 48 | } 49 | 50 | func contextWithCancel(ctx contextContext) (_ contextContext, cancel func()) { 51 | return ctx, nop 52 | } 53 | 54 | func requestWithContext(req *http.Request, ctx contextContext) *http.Request { 55 | return req 56 | } 57 | 58 | // temporary copy of Go 1.6's private tls.Config.clone: 59 | func cloneTLSConfig(c *tls.Config) *tls.Config { 60 | return &tls.Config{ 61 | Rand: c.Rand, 62 | Time: c.Time, 63 | Certificates: c.Certificates, 64 | NameToCertificate: c.NameToCertificate, 65 | GetCertificate: c.GetCertificate, 66 | RootCAs: c.RootCAs, 67 | NextProtos: c.NextProtos, 68 | ServerName: c.ServerName, 69 | ClientAuth: c.ClientAuth, 70 | ClientCAs: c.ClientCAs, 71 | InsecureSkipVerify: c.InsecureSkipVerify, 72 | CipherSuites: c.CipherSuites, 73 | PreferServerCipherSuites: c.PreferServerCipherSuites, 74 | SessionTicketsDisabled: c.SessionTicketsDisabled, 75 | SessionTicketKey: c.SessionTicketKey, 76 | ClientSessionCache: c.ClientSessionCache, 77 | MinVersion: c.MinVersion, 78 | MaxVersion: c.MaxVersion, 79 | CurvePreferences: c.CurvePreferences, 80 | } 81 | } 82 | 83 | func (cc *ClientConn) Ping(ctx contextContext) error { 84 | return cc.ping(ctx) 85 | } 86 | 87 | func (t *Transport) idleConnTimeout() time.Duration { return 0 } 88 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/buddyinfo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package procfs 15 | 16 | import ( 17 | "bufio" 18 | "fmt" 19 | "io" 20 | "os" 21 | "strconv" 22 | "strings" 23 | ) 24 | 25 | // A BuddyInfo is the details parsed from /proc/buddyinfo. 26 | // The data is comprised of an array of free fragments of each size. 27 | // The sizes are 2^n*PAGE_SIZE, where n is the array index. 28 | type BuddyInfo struct { 29 | Node string 30 | Zone string 31 | Sizes []float64 32 | } 33 | 34 | // NewBuddyInfo reads the buddyinfo statistics. 35 | func NewBuddyInfo() ([]BuddyInfo, error) { 36 | fs, err := NewFS(DefaultMountPoint) 37 | if err != nil { 38 | return nil, err 39 | } 40 | 41 | return fs.NewBuddyInfo() 42 | } 43 | 44 | // NewBuddyInfo reads the buddyinfo statistics from the specified `proc` filesystem. 45 | func (fs FS) NewBuddyInfo() ([]BuddyInfo, error) { 46 | file, err := os.Open(fs.Path("buddyinfo")) 47 | if err != nil { 48 | return nil, err 49 | } 50 | defer file.Close() 51 | 52 | return parseBuddyInfo(file) 53 | } 54 | 55 | func parseBuddyInfo(r io.Reader) ([]BuddyInfo, error) { 56 | var ( 57 | buddyInfo = []BuddyInfo{} 58 | scanner = bufio.NewScanner(r) 59 | bucketCount = -1 60 | ) 61 | 62 | for scanner.Scan() { 63 | var err error 64 | line := scanner.Text() 65 | parts := strings.Fields(string(line)) 66 | 67 | if len(parts) < 4 { 68 | return nil, fmt.Errorf("invalid number of fields when parsing buddyinfo") 69 | } 70 | 71 | node := strings.TrimRight(parts[1], ",") 72 | zone := strings.TrimRight(parts[3], ",") 73 | arraySize := len(parts[4:]) 74 | 75 | if bucketCount == -1 { 76 | bucketCount = arraySize 77 | } else { 78 | if bucketCount != arraySize { 79 | return nil, fmt.Errorf("mismatch in number of buddyinfo buckets, previous count %d, new count %d", bucketCount, arraySize) 80 | } 81 | } 82 | 83 | sizes := make([]float64, arraySize) 84 | for i := 0; i < arraySize; i++ { 85 | sizes[i], err = strconv.ParseFloat(parts[i+4], 64) 86 | if err != nil { 87 | return nil, fmt.Errorf("invalid value in buddyinfo: %s", err) 88 | } 89 | } 90 | 91 | buddyInfo = append(buddyInfo, BuddyInfo{node, zone, sizes}) 92 | } 93 | 94 | return buddyInfo, scanner.Err() 95 | } 96 | -------------------------------------------------------------------------------- /vendor/gopkg.in/jackc/pgx.v2/fastpath.go: -------------------------------------------------------------------------------- 1 | package pgx 2 | 3 | import ( 4 | "encoding/binary" 5 | ) 6 | 7 | func newFastpath(cn *Conn) *fastpath { 8 | return &fastpath{cn: cn, fns: make(map[string]Oid)} 9 | } 10 | 11 | type fastpath struct { 12 | cn *Conn 13 | fns map[string]Oid 14 | } 15 | 16 | func (f *fastpath) functionOID(name string) Oid { 17 | return f.fns[name] 18 | } 19 | 20 | func (f *fastpath) addFunction(name string, oid Oid) { 21 | f.fns[name] = oid 22 | } 23 | 24 | func (f *fastpath) addFunctions(rows *Rows) error { 25 | for rows.Next() { 26 | var name string 27 | var oid Oid 28 | if err := rows.Scan(&name, &oid); err != nil { 29 | return err 30 | } 31 | f.addFunction(name, oid) 32 | } 33 | return rows.Err() 34 | } 35 | 36 | type fpArg []byte 37 | 38 | func fpIntArg(n int32) fpArg { 39 | res := make([]byte, 4) 40 | binary.BigEndian.PutUint32(res, uint32(n)) 41 | return res 42 | } 43 | 44 | func fpInt64Arg(n int64) fpArg { 45 | res := make([]byte, 8) 46 | binary.BigEndian.PutUint64(res, uint64(n)) 47 | return res 48 | } 49 | 50 | func (f *fastpath) Call(oid Oid, args []fpArg) (res []byte, err error) { 51 | wbuf := newWriteBuf(f.cn, 'F') // function call 52 | wbuf.WriteInt32(int32(oid)) // function object id 53 | wbuf.WriteInt16(1) // # of argument format codes 54 | wbuf.WriteInt16(1) // format code: binary 55 | wbuf.WriteInt16(int16(len(args))) // # of arguments 56 | for _, arg := range args { 57 | wbuf.WriteInt32(int32(len(arg))) // length of argument 58 | wbuf.WriteBytes(arg) // argument value 59 | } 60 | wbuf.WriteInt16(1) // response format code (binary) 61 | wbuf.closeMsg() 62 | 63 | if _, err := f.cn.conn.Write(wbuf.buf); err != nil { 64 | return nil, err 65 | } 66 | 67 | for { 68 | var t byte 69 | var r *msgReader 70 | t, r, err = f.cn.rxMsg() 71 | if err != nil { 72 | return nil, err 73 | } 74 | switch t { 75 | case 'V': // FunctionCallResponse 76 | data := r.readBytes(r.readInt32()) 77 | res = make([]byte, len(data)) 78 | copy(res, data) 79 | case 'Z': // Ready for query 80 | f.cn.rxReadyForQuery(r) 81 | // done 82 | return 83 | default: 84 | if err := f.cn.processContextFreeMsg(t, r); err != nil { 85 | return nil, err 86 | } 87 | } 88 | } 89 | } 90 | 91 | func (f *fastpath) CallFn(fn string, args []fpArg) ([]byte, error) { 92 | return f.Call(f.functionOID(fn), args) 93 | } 94 | 95 | func fpInt32(data []byte, err error) (int32, error) { 96 | if err != nil { 97 | return 0, err 98 | } 99 | n := int32(binary.BigEndian.Uint32(data)) 100 | return n, nil 101 | } 102 | 103 | func fpInt64(data []byte, err error) (int64, error) { 104 | if err != nil { 105 | return 0, err 106 | } 107 | return int64(binary.BigEndian.Uint64(data)), nil 108 | } 109 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/type_check.go: -------------------------------------------------------------------------------- 1 | package toml 2 | 3 | // tomlType represents any Go type that corresponds to a TOML type. 4 | // While the first draft of the TOML spec has a simplistic type system that 5 | // probably doesn't need this level of sophistication, we seem to be militating 6 | // toward adding real composite types. 7 | type tomlType interface { 8 | typeString() string 9 | } 10 | 11 | // typeEqual accepts any two types and returns true if they are equal. 12 | func typeEqual(t1, t2 tomlType) bool { 13 | if t1 == nil || t2 == nil { 14 | return false 15 | } 16 | return t1.typeString() == t2.typeString() 17 | } 18 | 19 | func typeIsHash(t tomlType) bool { 20 | return typeEqual(t, tomlHash) || typeEqual(t, tomlArrayHash) 21 | } 22 | 23 | type tomlBaseType string 24 | 25 | func (btype tomlBaseType) typeString() string { 26 | return string(btype) 27 | } 28 | 29 | func (btype tomlBaseType) String() string { 30 | return btype.typeString() 31 | } 32 | 33 | var ( 34 | tomlInteger tomlBaseType = "Integer" 35 | tomlFloat tomlBaseType = "Float" 36 | tomlDatetime tomlBaseType = "Datetime" 37 | tomlString tomlBaseType = "String" 38 | tomlBool tomlBaseType = "Bool" 39 | tomlArray tomlBaseType = "Array" 40 | tomlHash tomlBaseType = "Hash" 41 | tomlArrayHash tomlBaseType = "ArrayHash" 42 | ) 43 | 44 | // typeOfPrimitive returns a tomlType of any primitive value in TOML. 45 | // Primitive values are: Integer, Float, Datetime, String and Bool. 46 | // 47 | // Passing a lexer item other than the following will cause a BUG message 48 | // to occur: itemString, itemBool, itemInteger, itemFloat, itemDatetime. 49 | func (p *parser) typeOfPrimitive(lexItem item) tomlType { 50 | switch lexItem.typ { 51 | case itemInteger: 52 | return tomlInteger 53 | case itemFloat: 54 | return tomlFloat 55 | case itemDatetime: 56 | return tomlDatetime 57 | case itemString: 58 | return tomlString 59 | case itemMultilineString: 60 | return tomlString 61 | case itemRawString: 62 | return tomlString 63 | case itemRawMultilineString: 64 | return tomlString 65 | case itemBool: 66 | return tomlBool 67 | } 68 | p.bug("Cannot infer primitive type of lex item '%s'.", lexItem) 69 | panic("unreachable") 70 | } 71 | 72 | // typeOfArray returns a tomlType for an array given a list of types of its 73 | // values. 74 | // 75 | // In the current spec, if an array is homogeneous, then its type is always 76 | // "Array". If the array is not homogeneous, an error is generated. 77 | func (p *parser) typeOfArray(types []tomlType) tomlType { 78 | // Empty arrays are cool. 79 | if len(types) == 0 { 80 | return tomlArray 81 | } 82 | 83 | theType := types[0] 84 | for _, t := range types[1:] { 85 | if !typeEqual(theType, t) { 86 | p.panicf("Array contains values of type '%s' and '%s', but "+ 87 | "arrays must be homogeneous.", theType, t) 88 | } 89 | } 90 | return tomlArray 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/common/expfmt/encode.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package expfmt 15 | 16 | import ( 17 | "fmt" 18 | "io" 19 | "net/http" 20 | 21 | "github.com/golang/protobuf/proto" 22 | "github.com/matttproud/golang_protobuf_extensions/pbutil" 23 | "github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg" 24 | 25 | dto "github.com/prometheus/client_model/go" 26 | ) 27 | 28 | // Encoder types encode metric families into an underlying wire protocol. 29 | type Encoder interface { 30 | Encode(*dto.MetricFamily) error 31 | } 32 | 33 | type encoder func(*dto.MetricFamily) error 34 | 35 | func (e encoder) Encode(v *dto.MetricFamily) error { 36 | return e(v) 37 | } 38 | 39 | // Negotiate returns the Content-Type based on the given Accept header. 40 | // If no appropriate accepted type is found, FmtText is returned. 41 | func Negotiate(h http.Header) Format { 42 | for _, ac := range goautoneg.ParseAccept(h.Get(hdrAccept)) { 43 | // Check for protocol buffer 44 | if ac.Type+"/"+ac.SubType == ProtoType && ac.Params["proto"] == ProtoProtocol { 45 | switch ac.Params["encoding"] { 46 | case "delimited": 47 | return FmtProtoDelim 48 | case "text": 49 | return FmtProtoText 50 | case "compact-text": 51 | return FmtProtoCompact 52 | } 53 | } 54 | // Check for text format. 55 | ver := ac.Params["version"] 56 | if ac.Type == "text" && ac.SubType == "plain" && (ver == TextVersion || ver == "") { 57 | return FmtText 58 | } 59 | } 60 | return FmtText 61 | } 62 | 63 | // NewEncoder returns a new encoder based on content type negotiation. 64 | func NewEncoder(w io.Writer, format Format) Encoder { 65 | switch format { 66 | case FmtProtoDelim: 67 | return encoder(func(v *dto.MetricFamily) error { 68 | _, err := pbutil.WriteDelimited(w, v) 69 | return err 70 | }) 71 | case FmtProtoCompact: 72 | return encoder(func(v *dto.MetricFamily) error { 73 | _, err := fmt.Fprintln(w, v.String()) 74 | return err 75 | }) 76 | case FmtProtoText: 77 | return encoder(func(v *dto.MetricFamily) error { 78 | _, err := fmt.Fprintln(w, proto.MarshalTextString(v)) 79 | return err 80 | }) 81 | case FmtText: 82 | return encoder(func(v *dto.MetricFamily) error { 83 | _, err := MetricFamilyToText(w, v) 84 | return err 85 | }) 86 | } 87 | panic("expfmt.NewEncoder: unknown format") 88 | } 89 | -------------------------------------------------------------------------------- /vendor/github.com/go-kit/kit/metrics/README.md: -------------------------------------------------------------------------------- 1 | # package metrics 2 | 3 | `package metrics` provides a set of uniform interfaces for service instrumentation. 4 | It has 5 | [counters](http://prometheus.io/docs/concepts/metric_types/#counter), 6 | [gauges](http://prometheus.io/docs/concepts/metric_types/#gauge), and 7 | [histograms](http://prometheus.io/docs/concepts/metric_types/#histogram), 8 | and provides adapters to popular metrics packages, like 9 | [expvar](https://golang.org/pkg/expvar), 10 | [StatsD](https://github.com/etsy/statsd), and 11 | [Prometheus](https://prometheus.io). 12 | 13 | ## Rationale 14 | 15 | Code instrumentation is absolutely essential to achieve 16 | [observability](https://speakerdeck.com/mattheath/observability-in-micro-service-architectures) 17 | into a distributed system. 18 | Metrics and instrumentation tools have coalesced around a few well-defined idioms. 19 | `package metrics` provides a common, minimal interface those idioms for service authors. 20 | 21 | ## Usage 22 | 23 | A simple counter, exported via expvar. 24 | 25 | ```go 26 | import ( 27 | "github.com/go-kit/kit/metrics" 28 | "github.com/go-kit/kit/metrics/expvar" 29 | ) 30 | 31 | func main() { 32 | var myCount metrics.Counter 33 | myCount = expvar.NewCounter("my_count") 34 | myCount.Add(1) 35 | } 36 | ``` 37 | 38 | A histogram for request duration, 39 | exported via a Prometheus summary with dynamically-computed quantiles. 40 | 41 | ```go 42 | import ( 43 | "time" 44 | 45 | stdprometheus "github.com/prometheus/client_golang/prometheus" 46 | 47 | "github.com/go-kit/kit/metrics" 48 | "github.com/go-kit/kit/metrics/prometheus" 49 | ) 50 | 51 | func main() { 52 | var dur metrics.Histogram = prometheus.NewSummaryFrom(stdprometheus.SummaryOpts{ 53 | Namespace: "myservice", 54 | Subsystem: "api", 55 | Name: "request_duration_seconds", 56 | Help: "Total time spent serving requests.", 57 | }, []string{}) 58 | // ... 59 | } 60 | 61 | func handleRequest(dur metrics.Histogram) { 62 | defer func(begin time.Time) { dur.Observe(time.Since(begin).Seconds()) }(time.Now()) 63 | // handle request 64 | } 65 | ``` 66 | 67 | A gauge for the number of goroutines currently running, exported via StatsD. 68 | 69 | ```go 70 | import ( 71 | "net" 72 | "os" 73 | "runtime" 74 | "time" 75 | 76 | "github.com/go-kit/kit/metrics" 77 | "github.com/go-kit/kit/metrics/statsd" 78 | ) 79 | 80 | func main() { 81 | statsd := statsd.New("foo_svc.", log.NewNopLogger()) 82 | report := time.NewTicker(5 * time.Second) 83 | defer report.Stop() 84 | go statsd.SendLoop(report.C, "tcp", "statsd.internal:8125") 85 | goroutines := statsd.NewGauge("goroutine_count") 86 | go exportGoroutines(goroutines) 87 | // ... 88 | } 89 | 90 | func exportGoroutines(g metrics.Gauge) { 91 | for range time.Tick(time.Second) { 92 | g.Set(float64(runtime.NumGoroutine())) 93 | } 94 | } 95 | ``` 96 | 97 | For more information, see [the package documentation](https://godoc.org/github.com/go-kit/kit/metrics). 98 | -------------------------------------------------------------------------------- /vendor/github.com/go-logfmt/logfmt/fuzz.go: -------------------------------------------------------------------------------- 1 | // +build gofuzz 2 | 3 | package logfmt 4 | 5 | import ( 6 | "bufio" 7 | "bytes" 8 | "fmt" 9 | "io" 10 | "reflect" 11 | 12 | kr "github.com/kr/logfmt" 13 | ) 14 | 15 | // Fuzz checks reserialized data matches 16 | func Fuzz(data []byte) int { 17 | parsed, err := parse(data) 18 | if err != nil { 19 | return 0 20 | } 21 | var w1 bytes.Buffer 22 | if err = write(parsed, &w1); err != nil { 23 | panic(err) 24 | } 25 | parsed, err = parse(w1.Bytes()) 26 | if err != nil { 27 | panic(err) 28 | } 29 | var w2 bytes.Buffer 30 | if err = write(parsed, &w2); err != nil { 31 | panic(err) 32 | } 33 | if !bytes.Equal(w1.Bytes(), w2.Bytes()) { 34 | panic(fmt.Sprintf("reserialized data does not match:\n%q\n%q\n", w1.Bytes(), w2.Bytes())) 35 | } 36 | return 1 37 | } 38 | 39 | // FuzzVsKR checks go-logfmt/logfmt against kr/logfmt 40 | func FuzzVsKR(data []byte) int { 41 | parsed, err := parse(data) 42 | parsedKR, errKR := parseKR(data) 43 | 44 | // github.com/go-logfmt/logfmt is a stricter parser. It returns errors for 45 | // more inputs than github.com/kr/logfmt. Ignore any inputs that have a 46 | // stict error. 47 | if err != nil { 48 | return 0 49 | } 50 | 51 | // Fail if the more forgiving parser finds an error not found by the 52 | // stricter parser. 53 | if errKR != nil { 54 | panic(fmt.Sprintf("unmatched error: %v", errKR)) 55 | } 56 | 57 | if !reflect.DeepEqual(parsed, parsedKR) { 58 | panic(fmt.Sprintf("parsers disagree:\n%+v\n%+v\n", parsed, parsedKR)) 59 | } 60 | return 1 61 | } 62 | 63 | type kv struct { 64 | k, v []byte 65 | } 66 | 67 | func parse(data []byte) ([][]kv, error) { 68 | var got [][]kv 69 | dec := NewDecoder(bytes.NewReader(data)) 70 | for dec.ScanRecord() { 71 | var kvs []kv 72 | for dec.ScanKeyval() { 73 | kvs = append(kvs, kv{dec.Key(), dec.Value()}) 74 | } 75 | got = append(got, kvs) 76 | } 77 | return got, dec.Err() 78 | } 79 | 80 | func parseKR(data []byte) ([][]kv, error) { 81 | var ( 82 | s = bufio.NewScanner(bytes.NewReader(data)) 83 | err error 84 | h saveHandler 85 | got [][]kv 86 | ) 87 | for err == nil && s.Scan() { 88 | h.kvs = nil 89 | err = kr.Unmarshal(s.Bytes(), &h) 90 | got = append(got, h.kvs) 91 | } 92 | if err == nil { 93 | err = s.Err() 94 | } 95 | return got, err 96 | } 97 | 98 | type saveHandler struct { 99 | kvs []kv 100 | } 101 | 102 | func (h *saveHandler) HandleLogfmt(key, val []byte) error { 103 | if len(key) == 0 { 104 | key = nil 105 | } 106 | if len(val) == 0 { 107 | val = nil 108 | } 109 | h.kvs = append(h.kvs, kv{key, val}) 110 | return nil 111 | } 112 | 113 | func write(recs [][]kv, w io.Writer) error { 114 | enc := NewEncoder(w) 115 | for _, rec := range recs { 116 | for _, f := range rec { 117 | if err := enc.EncodeKeyval(f.k, f.v); err != nil { 118 | return err 119 | } 120 | } 121 | if err := enc.EndRecord(); err != nil { 122 | return err 123 | } 124 | } 125 | return nil 126 | } 127 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/common/model/fingerprinting.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package model 15 | 16 | import ( 17 | "fmt" 18 | "strconv" 19 | ) 20 | 21 | // Fingerprint provides a hash-capable representation of a Metric. 22 | // For our purposes, FNV-1A 64-bit is used. 23 | type Fingerprint uint64 24 | 25 | // FingerprintFromString transforms a string representation into a Fingerprint. 26 | func FingerprintFromString(s string) (Fingerprint, error) { 27 | num, err := strconv.ParseUint(s, 16, 64) 28 | return Fingerprint(num), err 29 | } 30 | 31 | // ParseFingerprint parses the input string into a fingerprint. 32 | func ParseFingerprint(s string) (Fingerprint, error) { 33 | num, err := strconv.ParseUint(s, 16, 64) 34 | if err != nil { 35 | return 0, err 36 | } 37 | return Fingerprint(num), nil 38 | } 39 | 40 | func (f Fingerprint) String() string { 41 | return fmt.Sprintf("%016x", uint64(f)) 42 | } 43 | 44 | // Fingerprints represents a collection of Fingerprint subject to a given 45 | // natural sorting scheme. It implements sort.Interface. 46 | type Fingerprints []Fingerprint 47 | 48 | // Len implements sort.Interface. 49 | func (f Fingerprints) Len() int { 50 | return len(f) 51 | } 52 | 53 | // Less implements sort.Interface. 54 | func (f Fingerprints) Less(i, j int) bool { 55 | return f[i] < f[j] 56 | } 57 | 58 | // Swap implements sort.Interface. 59 | func (f Fingerprints) Swap(i, j int) { 60 | f[i], f[j] = f[j], f[i] 61 | } 62 | 63 | // FingerprintSet is a set of Fingerprints. 64 | type FingerprintSet map[Fingerprint]struct{} 65 | 66 | // Equal returns true if both sets contain the same elements (and not more). 67 | func (s FingerprintSet) Equal(o FingerprintSet) bool { 68 | if len(s) != len(o) { 69 | return false 70 | } 71 | 72 | for k := range s { 73 | if _, ok := o[k]; !ok { 74 | return false 75 | } 76 | } 77 | 78 | return true 79 | } 80 | 81 | // Intersection returns the elements contained in both sets. 82 | func (s FingerprintSet) Intersection(o FingerprintSet) FingerprintSet { 83 | myLength, otherLength := len(s), len(o) 84 | if myLength == 0 || otherLength == 0 { 85 | return FingerprintSet{} 86 | } 87 | 88 | subSet := s 89 | superSet := o 90 | 91 | if otherLength < myLength { 92 | subSet = o 93 | superSet = s 94 | } 95 | 96 | out := FingerprintSet{} 97 | 98 | for k := range subSet { 99 | if _, ok := superSet[k]; ok { 100 | out[k] = struct{}{} 101 | } 102 | } 103 | 104 | return out 105 | } 106 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/go16.go: -------------------------------------------------------------------------------- 1 | // +build go1.6,!go1.7 2 | 3 | /* 4 | * 5 | * Copyright 2016 gRPC authors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | package grpc 22 | 23 | import ( 24 | "fmt" 25 | "io" 26 | "net" 27 | "net/http" 28 | "os" 29 | 30 | "golang.org/x/net/context" 31 | "google.golang.org/grpc/codes" 32 | "google.golang.org/grpc/status" 33 | "google.golang.org/grpc/transport" 34 | ) 35 | 36 | // dialContext connects to the address on the named network. 37 | func dialContext(ctx context.Context, network, address string) (net.Conn, error) { 38 | return (&net.Dialer{Cancel: ctx.Done()}).Dial(network, address) 39 | } 40 | 41 | func sendHTTPRequest(ctx context.Context, req *http.Request, conn net.Conn) error { 42 | req.Cancel = ctx.Done() 43 | if err := req.Write(conn); err != nil { 44 | return fmt.Errorf("failed to write the HTTP request: %v", err) 45 | } 46 | return nil 47 | } 48 | 49 | // toRPCErr converts an error into an error from the status package. 50 | func toRPCErr(err error) error { 51 | if _, ok := status.FromError(err); ok { 52 | return err 53 | } 54 | switch e := err.(type) { 55 | case transport.StreamError: 56 | return status.Error(e.Code, e.Desc) 57 | case transport.ConnectionError: 58 | return status.Error(codes.Unavailable, e.Desc) 59 | default: 60 | switch err { 61 | case context.DeadlineExceeded: 62 | return status.Error(codes.DeadlineExceeded, err.Error()) 63 | case context.Canceled: 64 | return status.Error(codes.Canceled, err.Error()) 65 | case ErrClientConnClosing: 66 | return status.Error(codes.FailedPrecondition, err.Error()) 67 | } 68 | } 69 | return status.Error(codes.Unknown, err.Error()) 70 | } 71 | 72 | // convertCode converts a standard Go error into its canonical code. Note that 73 | // this is only used to translate the error returned by the server applications. 74 | func convertCode(err error) codes.Code { 75 | switch err { 76 | case nil: 77 | return codes.OK 78 | case io.EOF: 79 | return codes.OutOfRange 80 | case io.ErrClosedPipe, io.ErrNoProgress, io.ErrShortBuffer, io.ErrShortWrite, io.ErrUnexpectedEOF: 81 | return codes.FailedPrecondition 82 | case os.ErrInvalid: 83 | return codes.InvalidArgument 84 | case context.Canceled: 85 | return codes.Canceled 86 | case context.DeadlineExceeded: 87 | return codes.DeadlineExceeded 88 | } 89 | switch { 90 | case os.IsExist(err): 91 | return codes.AlreadyExists 92 | case os.IsNotExist(err): 93 | return codes.NotFound 94 | case os.IsPermission(err): 95 | return codes.PermissionDenied 96 | } 97 | return codes.Unknown 98 | } 99 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/context/go17.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.7 6 | 7 | package context 8 | 9 | import ( 10 | "context" // standard library's context, as of Go 1.7 11 | "time" 12 | ) 13 | 14 | var ( 15 | todo = context.TODO() 16 | background = context.Background() 17 | ) 18 | 19 | // Canceled is the error returned by Context.Err when the context is canceled. 20 | var Canceled = context.Canceled 21 | 22 | // DeadlineExceeded is the error returned by Context.Err when the context's 23 | // deadline passes. 24 | var DeadlineExceeded = context.DeadlineExceeded 25 | 26 | // WithCancel returns a copy of parent with a new Done channel. The returned 27 | // context's Done channel is closed when the returned cancel function is called 28 | // or when the parent context's Done channel is closed, whichever happens first. 29 | // 30 | // Canceling this context releases resources associated with it, so code should 31 | // call cancel as soon as the operations running in this Context complete. 32 | func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { 33 | ctx, f := context.WithCancel(parent) 34 | return ctx, CancelFunc(f) 35 | } 36 | 37 | // WithDeadline returns a copy of the parent context with the deadline adjusted 38 | // to be no later than d. If the parent's deadline is already earlier than d, 39 | // WithDeadline(parent, d) is semantically equivalent to parent. The returned 40 | // context's Done channel is closed when the deadline expires, when the returned 41 | // cancel function is called, or when the parent context's Done channel is 42 | // closed, whichever happens first. 43 | // 44 | // Canceling this context releases resources associated with it, so code should 45 | // call cancel as soon as the operations running in this Context complete. 46 | func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) { 47 | ctx, f := context.WithDeadline(parent, deadline) 48 | return ctx, CancelFunc(f) 49 | } 50 | 51 | // WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)). 52 | // 53 | // Canceling this context releases resources associated with it, so code should 54 | // call cancel as soon as the operations running in this Context complete: 55 | // 56 | // func slowOperationWithTimeout(ctx context.Context) (Result, error) { 57 | // ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) 58 | // defer cancel() // releases resources if slowOperation completes before timeout elapses 59 | // return slowOperation(ctx) 60 | // } 61 | func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { 62 | return WithDeadline(parent, time.Now().Add(timeout)) 63 | } 64 | 65 | // WithValue returns a copy of parent in which the value associated with key is 66 | // val. 67 | // 68 | // Use context Values only for request-scoped data that transits processes and 69 | // APIs, not for passing optional parameters to functions. 70 | func WithValue(parent Context, key interface{}, val interface{}) Context { 71 | return context.WithValue(parent, key, val) 72 | } 73 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/backoff.go: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2017 gRPC authors. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | */ 18 | 19 | package grpc 20 | 21 | import ( 22 | "math/rand" 23 | "time" 24 | ) 25 | 26 | // DefaultBackoffConfig uses values specified for backoff in 27 | // https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md. 28 | var ( 29 | DefaultBackoffConfig = BackoffConfig{ 30 | MaxDelay: 120 * time.Second, 31 | baseDelay: 1.0 * time.Second, 32 | factor: 1.6, 33 | jitter: 0.2, 34 | } 35 | ) 36 | 37 | // backoffStrategy defines the methodology for backing off after a grpc 38 | // connection failure. 39 | // 40 | // This is unexported until the gRPC project decides whether or not to allow 41 | // alternative backoff strategies. Once a decision is made, this type and its 42 | // method may be exported. 43 | type backoffStrategy interface { 44 | // backoff returns the amount of time to wait before the next retry given 45 | // the number of consecutive failures. 46 | backoff(retries int) time.Duration 47 | } 48 | 49 | // BackoffConfig defines the parameters for the default gRPC backoff strategy. 50 | type BackoffConfig struct { 51 | // MaxDelay is the upper bound of backoff delay. 52 | MaxDelay time.Duration 53 | 54 | // TODO(stevvooe): The following fields are not exported, as allowing 55 | // changes would violate the current gRPC specification for backoff. If 56 | // gRPC decides to allow more interesting backoff strategies, these fields 57 | // may be opened up in the future. 58 | 59 | // baseDelay is the amount of time to wait before retrying after the first 60 | // failure. 61 | baseDelay time.Duration 62 | 63 | // factor is applied to the backoff after each retry. 64 | factor float64 65 | 66 | // jitter provides a range to randomize backoff delays. 67 | jitter float64 68 | } 69 | 70 | func setDefaults(bc *BackoffConfig) { 71 | md := bc.MaxDelay 72 | *bc = DefaultBackoffConfig 73 | 74 | if md > 0 { 75 | bc.MaxDelay = md 76 | } 77 | } 78 | 79 | func (bc BackoffConfig) backoff(retries int) time.Duration { 80 | if retries == 0 { 81 | return bc.baseDelay 82 | } 83 | backoff, max := float64(bc.baseDelay), float64(bc.MaxDelay) 84 | for backoff < max && retries > 0 { 85 | backoff *= bc.factor 86 | retries-- 87 | } 88 | if backoff > max { 89 | backoff = max 90 | } 91 | // Randomize backoff delays so that if a cluster of requests start at 92 | // the same time, they won't operate in lockstep. 93 | backoff *= 1 + bc.jitter*(rand.Float64()*2-1) 94 | if backoff < 0 { 95 | return 0 96 | } 97 | return time.Duration(backoff) 98 | } 99 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/http2/go17.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.7 6 | 7 | package http2 8 | 9 | import ( 10 | "context" 11 | "net" 12 | "net/http" 13 | "net/http/httptrace" 14 | "time" 15 | ) 16 | 17 | type contextContext interface { 18 | context.Context 19 | } 20 | 21 | func serverConnBaseContext(c net.Conn, opts *ServeConnOpts) (ctx contextContext, cancel func()) { 22 | ctx, cancel = context.WithCancel(context.Background()) 23 | ctx = context.WithValue(ctx, http.LocalAddrContextKey, c.LocalAddr()) 24 | if hs := opts.baseConfig(); hs != nil { 25 | ctx = context.WithValue(ctx, http.ServerContextKey, hs) 26 | } 27 | return 28 | } 29 | 30 | func contextWithCancel(ctx contextContext) (_ contextContext, cancel func()) { 31 | return context.WithCancel(ctx) 32 | } 33 | 34 | func requestWithContext(req *http.Request, ctx contextContext) *http.Request { 35 | return req.WithContext(ctx) 36 | } 37 | 38 | type clientTrace httptrace.ClientTrace 39 | 40 | func reqContext(r *http.Request) context.Context { return r.Context() } 41 | 42 | func (t *Transport) idleConnTimeout() time.Duration { 43 | if t.t1 != nil { 44 | return t.t1.IdleConnTimeout 45 | } 46 | return 0 47 | } 48 | 49 | func setResponseUncompressed(res *http.Response) { res.Uncompressed = true } 50 | 51 | func traceGotConn(req *http.Request, cc *ClientConn) { 52 | trace := httptrace.ContextClientTrace(req.Context()) 53 | if trace == nil || trace.GotConn == nil { 54 | return 55 | } 56 | ci := httptrace.GotConnInfo{Conn: cc.tconn} 57 | cc.mu.Lock() 58 | ci.Reused = cc.nextStreamID > 1 59 | ci.WasIdle = len(cc.streams) == 0 && ci.Reused 60 | if ci.WasIdle && !cc.lastActive.IsZero() { 61 | ci.IdleTime = time.Now().Sub(cc.lastActive) 62 | } 63 | cc.mu.Unlock() 64 | 65 | trace.GotConn(ci) 66 | } 67 | 68 | func traceWroteHeaders(trace *clientTrace) { 69 | if trace != nil && trace.WroteHeaders != nil { 70 | trace.WroteHeaders() 71 | } 72 | } 73 | 74 | func traceGot100Continue(trace *clientTrace) { 75 | if trace != nil && trace.Got100Continue != nil { 76 | trace.Got100Continue() 77 | } 78 | } 79 | 80 | func traceWait100Continue(trace *clientTrace) { 81 | if trace != nil && trace.Wait100Continue != nil { 82 | trace.Wait100Continue() 83 | } 84 | } 85 | 86 | func traceWroteRequest(trace *clientTrace, err error) { 87 | if trace != nil && trace.WroteRequest != nil { 88 | trace.WroteRequest(httptrace.WroteRequestInfo{Err: err}) 89 | } 90 | } 91 | 92 | func traceFirstResponseByte(trace *clientTrace) { 93 | if trace != nil && trace.GotFirstResponseByte != nil { 94 | trace.GotFirstResponseByte() 95 | } 96 | } 97 | 98 | func requestTrace(req *http.Request) *clientTrace { 99 | trace := httptrace.ContextClientTrace(req.Context()) 100 | return (*clientTrace)(trace) 101 | } 102 | 103 | // Ping sends a PING frame to the server and waits for the ack. 104 | func (cc *ClientConn) Ping(ctx context.Context) error { 105 | return cc.ping(ctx) 106 | } 107 | -------------------------------------------------------------------------------- /vendor/github.com/matttproud/golang_protobuf_extensions/pbutil/decode.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Matt T. Proud 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package pbutil 16 | 17 | import ( 18 | "encoding/binary" 19 | "errors" 20 | "io" 21 | 22 | "github.com/golang/protobuf/proto" 23 | ) 24 | 25 | var errInvalidVarint = errors.New("invalid varint32 encountered") 26 | 27 | // ReadDelimited decodes a message from the provided length-delimited stream, 28 | // where the length is encoded as 32-bit varint prefix to the message body. 29 | // It returns the total number of bytes read and any applicable error. This is 30 | // roughly equivalent to the companion Java API's 31 | // MessageLite#parseDelimitedFrom. As per the reader contract, this function 32 | // calls r.Read repeatedly as required until exactly one message including its 33 | // prefix is read and decoded (or an error has occurred). The function never 34 | // reads more bytes from the stream than required. The function never returns 35 | // an error if a message has been read and decoded correctly, even if the end 36 | // of the stream has been reached in doing so. In that case, any subsequent 37 | // calls return (0, io.EOF). 38 | func ReadDelimited(r io.Reader, m proto.Message) (n int, err error) { 39 | // Per AbstractParser#parsePartialDelimitedFrom with 40 | // CodedInputStream#readRawVarint32. 41 | var headerBuf [binary.MaxVarintLen32]byte 42 | var bytesRead, varIntBytes int 43 | var messageLength uint64 44 | for varIntBytes == 0 { // i.e. no varint has been decoded yet. 45 | if bytesRead >= len(headerBuf) { 46 | return bytesRead, errInvalidVarint 47 | } 48 | // We have to read byte by byte here to avoid reading more bytes 49 | // than required. Each read byte is appended to what we have 50 | // read before. 51 | newBytesRead, err := r.Read(headerBuf[bytesRead : bytesRead+1]) 52 | if newBytesRead == 0 { 53 | if err != nil { 54 | return bytesRead, err 55 | } 56 | // A Reader should not return (0, nil), but if it does, 57 | // it should be treated as no-op (according to the 58 | // Reader contract). So let's go on... 59 | continue 60 | } 61 | bytesRead += newBytesRead 62 | // Now present everything read so far to the varint decoder and 63 | // see if a varint can be decoded already. 64 | messageLength, varIntBytes = proto.DecodeVarint(headerBuf[:bytesRead]) 65 | } 66 | 67 | messageBuf := make([]byte, messageLength) 68 | newBytesRead, err := io.ReadFull(r, messageBuf) 69 | bytesRead += newBytesRead 70 | if err != nil { 71 | return bytesRead, err 72 | } 73 | 74 | return bytesRead, proto.Unmarshal(messageBuf, m) 75 | } 76 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/trace.go: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2015 gRPC authors. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | */ 18 | 19 | package grpc 20 | 21 | import ( 22 | "bytes" 23 | "fmt" 24 | "io" 25 | "net" 26 | "strings" 27 | "time" 28 | 29 | "golang.org/x/net/trace" 30 | ) 31 | 32 | // EnableTracing controls whether to trace RPCs using the golang.org/x/net/trace package. 33 | // This should only be set before any RPCs are sent or received by this program. 34 | var EnableTracing = true 35 | 36 | // methodFamily returns the trace family for the given method. 37 | // It turns "/pkg.Service/GetFoo" into "pkg.Service". 38 | func methodFamily(m string) string { 39 | m = strings.TrimPrefix(m, "/") // remove leading slash 40 | if i := strings.Index(m, "/"); i >= 0 { 41 | m = m[:i] // remove everything from second slash 42 | } 43 | if i := strings.LastIndex(m, "."); i >= 0 { 44 | m = m[i+1:] // cut down to last dotted component 45 | } 46 | return m 47 | } 48 | 49 | // traceInfo contains tracing information for an RPC. 50 | type traceInfo struct { 51 | tr trace.Trace 52 | firstLine firstLine 53 | } 54 | 55 | // firstLine is the first line of an RPC trace. 56 | type firstLine struct { 57 | client bool // whether this is a client (outgoing) RPC 58 | remoteAddr net.Addr 59 | deadline time.Duration // may be zero 60 | } 61 | 62 | func (f *firstLine) String() string { 63 | var line bytes.Buffer 64 | io.WriteString(&line, "RPC: ") 65 | if f.client { 66 | io.WriteString(&line, "to") 67 | } else { 68 | io.WriteString(&line, "from") 69 | } 70 | fmt.Fprintf(&line, " %v deadline:", f.remoteAddr) 71 | if f.deadline != 0 { 72 | fmt.Fprint(&line, f.deadline) 73 | } else { 74 | io.WriteString(&line, "none") 75 | } 76 | return line.String() 77 | } 78 | 79 | // payload represents an RPC request or response payload. 80 | type payload struct { 81 | sent bool // whether this is an outgoing payload 82 | msg interface{} // e.g. a proto.Message 83 | // TODO(dsymonds): add stringifying info to codec, and limit how much we hold here? 84 | } 85 | 86 | func (p payload) String() string { 87 | if p.sent { 88 | return fmt.Sprintf("sent: %v", p.msg) 89 | } 90 | return fmt.Sprintf("recv: %v", p.msg) 91 | } 92 | 93 | type fmtStringer struct { 94 | format string 95 | a []interface{} 96 | } 97 | 98 | func (f *fmtStringer) String() string { 99 | return fmt.Sprintf(f.format, f.a...) 100 | } 101 | 102 | type stringer string 103 | 104 | func (s stringer) String() string { return string(s) } 105 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/go17.go: -------------------------------------------------------------------------------- 1 | // +build go1.7 2 | 3 | /* 4 | * 5 | * Copyright 2016 gRPC authors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | package grpc 22 | 23 | import ( 24 | "context" 25 | "io" 26 | "net" 27 | "net/http" 28 | "os" 29 | 30 | netctx "golang.org/x/net/context" 31 | "google.golang.org/grpc/codes" 32 | "google.golang.org/grpc/status" 33 | "google.golang.org/grpc/transport" 34 | ) 35 | 36 | // dialContext connects to the address on the named network. 37 | func dialContext(ctx context.Context, network, address string) (net.Conn, error) { 38 | return (&net.Dialer{}).DialContext(ctx, network, address) 39 | } 40 | 41 | func sendHTTPRequest(ctx context.Context, req *http.Request, conn net.Conn) error { 42 | req = req.WithContext(ctx) 43 | if err := req.Write(conn); err != nil { 44 | return err 45 | } 46 | return nil 47 | } 48 | 49 | // toRPCErr converts an error into an error from the status package. 50 | func toRPCErr(err error) error { 51 | if _, ok := status.FromError(err); ok { 52 | return err 53 | } 54 | switch e := err.(type) { 55 | case transport.StreamError: 56 | return status.Error(e.Code, e.Desc) 57 | case transport.ConnectionError: 58 | return status.Error(codes.Unavailable, e.Desc) 59 | default: 60 | switch err { 61 | case context.DeadlineExceeded, netctx.DeadlineExceeded: 62 | return status.Error(codes.DeadlineExceeded, err.Error()) 63 | case context.Canceled, netctx.Canceled: 64 | return status.Error(codes.Canceled, err.Error()) 65 | case ErrClientConnClosing: 66 | return status.Error(codes.FailedPrecondition, err.Error()) 67 | } 68 | } 69 | return status.Error(codes.Unknown, err.Error()) 70 | } 71 | 72 | // convertCode converts a standard Go error into its canonical code. Note that 73 | // this is only used to translate the error returned by the server applications. 74 | func convertCode(err error) codes.Code { 75 | switch err { 76 | case nil: 77 | return codes.OK 78 | case io.EOF: 79 | return codes.OutOfRange 80 | case io.ErrClosedPipe, io.ErrNoProgress, io.ErrShortBuffer, io.ErrShortWrite, io.ErrUnexpectedEOF: 81 | return codes.FailedPrecondition 82 | case os.ErrInvalid: 83 | return codes.InvalidArgument 84 | case context.Canceled, netctx.Canceled: 85 | return codes.Canceled 86 | case context.DeadlineExceeded, netctx.DeadlineExceeded: 87 | return codes.DeadlineExceeded 88 | } 89 | switch { 90 | case os.IsExist(err): 91 | return codes.AlreadyExists 92 | case os.IsNotExist(err): 93 | return codes.NotFound 94 | case os.IsPermission(err): 95 | return codes.PermissionDenied 96 | } 97 | return codes.Unknown 98 | } 99 | --------------------------------------------------------------------------------