├── .gitignore ├── LICENSE ├── README.md ├── server ├── config.go ├── registry.go ├── server.go └── server_test.go └── vendor ├── github.com ├── beorn7 │ └── perks │ │ ├── LICENSE │ │ └── quantile │ │ ├── exampledata.txt │ │ └── stream.go ├── coreos │ └── etcd │ │ ├── LICENSE │ │ ├── NOTICE │ │ ├── auth │ │ └── authpb │ │ │ ├── auth.pb.go │ │ │ └── auth.proto │ │ ├── clientv3 │ │ ├── README.md │ │ ├── auth.go │ │ ├── balancer.go │ │ ├── client.go │ │ ├── cluster.go │ │ ├── compact_op.go │ │ ├── compare.go │ │ ├── config.go │ │ ├── doc.go │ │ ├── kv.go │ │ ├── lease.go │ │ ├── logger.go │ │ ├── maintenance.go │ │ ├── op.go │ │ ├── retry.go │ │ ├── sort.go │ │ ├── txn.go │ │ └── watch.go │ │ ├── etcdserver │ │ ├── api │ │ │ └── v3rpc │ │ │ │ └── rpctypes │ │ │ │ ├── doc.go │ │ │ │ ├── error.go │ │ │ │ └── md.go │ │ └── etcdserverpb │ │ │ ├── etcdserver.pb.go │ │ │ ├── etcdserver.proto │ │ │ ├── raft_internal.pb.go │ │ │ ├── raft_internal.proto │ │ │ ├── rpc.pb.go │ │ │ ├── rpc.pb.gw.go │ │ │ └── rpc.proto │ │ ├── mvcc │ │ └── mvccpb │ │ │ ├── kv.pb.go │ │ │ └── kv.proto │ │ └── pkg │ │ └── tlsutil │ │ ├── doc.go │ │ └── tlsutil.go ├── ghodss │ └── yaml │ │ ├── LICENSE │ │ ├── README.md │ │ ├── fields.go │ │ └── yaml.go ├── golang │ └── protobuf │ │ ├── LICENSE │ │ ├── jsonpb │ │ └── jsonpb.go │ │ └── proto │ │ ├── Makefile │ │ ├── clone.go │ │ ├── decode.go │ │ ├── encode.go │ │ ├── equal.go │ │ ├── extensions.go │ │ ├── lib.go │ │ ├── message_set.go │ │ ├── pointer_reflect.go │ │ ├── pointer_unsafe.go │ │ ├── properties.go │ │ ├── text.go │ │ └── text_parser.go ├── grpc-ecosystem │ ├── go-grpc-prometheus │ │ ├── LICENSE │ │ ├── README.md │ │ ├── client.go │ │ ├── client_reporter.go │ │ ├── server.go │ │ ├── server_reporter.go │ │ └── util.go │ └── grpc-gateway │ │ ├── LICENSE.txt │ │ ├── runtime │ │ ├── context.go │ │ ├── convert.go │ │ ├── doc.go │ │ ├── errors.go │ │ ├── handler.go │ │ ├── internal │ │ │ ├── stream_chunk.pb.go │ │ │ └── stream_chunk.proto │ │ ├── marshal_json.go │ │ ├── marshal_jsonpb.go │ │ ├── marshaler.go │ │ ├── marshaler_registry.go │ │ ├── mux.go │ │ ├── pattern.go │ │ ├── proto2_convert.go │ │ └── query.go │ │ └── utilities │ │ ├── doc.go │ │ ├── pattern.go │ │ └── trie.go ├── matttproud │ └── golang_protobuf_extensions │ │ ├── LICENSE │ │ ├── NOTICE │ │ └── pbutil │ │ ├── Makefile │ │ ├── decode.go │ │ ├── doc.go │ │ └── encode.go ├── prometheus │ ├── client_golang │ │ ├── LICENSE │ │ ├── NOTICE │ │ └── prometheus │ │ │ ├── README.md │ │ │ ├── collector.go │ │ │ ├── counter.go │ │ │ ├── desc.go │ │ │ ├── doc.go │ │ │ ├── expvar_collector.go │ │ │ ├── fnv.go │ │ │ ├── gauge.go │ │ │ ├── go_collector.go │ │ │ ├── histogram.go │ │ │ ├── http.go │ │ │ ├── metric.go │ │ │ ├── process_collector.go │ │ │ ├── registry.go │ │ │ ├── summary.go │ │ │ ├── timer.go │ │ │ ├── untyped.go │ │ │ ├── value.go │ │ │ └── vec.go │ ├── client_model │ │ ├── LICENSE │ │ ├── NOTICE │ │ └── go │ │ │ └── metrics.pb.go │ ├── common │ │ ├── LICENSE │ │ ├── NOTICE │ │ ├── expfmt │ │ │ ├── decode.go │ │ │ ├── encode.go │ │ │ ├── expfmt.go │ │ │ ├── fuzz.go │ │ │ ├── text_create.go │ │ │ └── text_parse.go │ │ ├── internal │ │ │ └── bitbucket.org │ │ │ │ └── ww │ │ │ │ └── goautoneg │ │ │ │ ├── README.txt │ │ │ │ └── autoneg.go │ │ └── model │ │ │ ├── alert.go │ │ │ ├── fingerprinting.go │ │ │ ├── fnv.go │ │ │ ├── labels.go │ │ │ ├── labelset.go │ │ │ ├── metric.go │ │ │ ├── model.go │ │ │ ├── signature.go │ │ │ ├── silence.go │ │ │ ├── time.go │ │ │ └── value.go │ └── procfs │ │ ├── CONTRIBUTING.md │ │ ├── LICENSE │ │ ├── MAINTAINERS.md │ │ ├── Makefile │ │ ├── NOTICE │ │ ├── README.md │ │ ├── buddyinfo.go │ │ ├── doc.go │ │ ├── fs.go │ │ ├── ipvs.go │ │ ├── mdstat.go │ │ ├── mountstats.go │ │ ├── proc.go │ │ ├── proc_io.go │ │ ├── proc_limits.go │ │ ├── proc_stat.go │ │ ├── stat.go │ │ └── xfs │ │ ├── parse.go │ │ └── xfs.go └── rcrowley │ └── go-metrics │ ├── LICENSE │ ├── README.md │ ├── counter.go │ ├── debug.go │ ├── ewma.go │ ├── gauge.go │ ├── gauge_float64.go │ ├── graphite.go │ ├── healthcheck.go │ ├── histogram.go │ ├── json.go │ ├── log.go │ ├── memory.md │ ├── meter.go │ ├── metrics.go │ ├── opentsdb.go │ ├── registry.go │ ├── runtime.go │ ├── runtime_cgo.go │ ├── runtime_gccpufraction.go │ ├── runtime_no_cgo.go │ ├── runtime_no_gccpufraction.go │ ├── sample.go │ ├── syslog.go │ ├── timer.go │ ├── validate.sh │ └── writer.go ├── golang.org └── x │ └── net │ ├── LICENSE │ ├── PATENTS │ ├── context │ ├── context.go │ ├── go17.go │ └── pre_go17.go │ ├── http2 │ ├── Dockerfile │ ├── Makefile │ ├── README │ ├── client_conn_pool.go │ ├── configure_transport.go │ ├── databuffer.go │ ├── errors.go │ ├── flow.go │ ├── frame.go │ ├── go16.go │ ├── go17.go │ ├── go17_not18.go │ ├── go18.go │ ├── gotrack.go │ ├── headermap.go │ ├── hpack │ │ ├── encode.go │ │ ├── hpack.go │ │ ├── huffman.go │ │ └── tables.go │ ├── http2.go │ ├── not_go16.go │ ├── not_go17.go │ ├── not_go18.go │ ├── pipe.go │ ├── server.go │ ├── transport.go │ ├── write.go │ ├── writesched.go │ ├── writesched_priority.go │ └── writesched_random.go │ ├── idna │ ├── idna.go │ └── punycode.go │ ├── internal │ └── timeseries │ │ └── timeseries.go │ ├── lex │ └── httplex │ │ └── httplex.go │ └── trace │ ├── events.go │ ├── histogram.go │ └── trace.go ├── google.golang.org └── grpc │ ├── CONTRIBUTING.md │ ├── LICENSE │ ├── Makefile │ ├── PATENTS │ ├── README.md │ ├── backoff.go │ ├── balancer.go │ ├── call.go │ ├── clientconn.go │ ├── codegen.sh │ ├── codes │ ├── code_string.go │ └── codes.go │ ├── coverage.sh │ ├── credentials │ ├── credentials.go │ ├── credentials_util_go17.go │ ├── credentials_util_go18.go │ └── credentials_util_pre_go17.go │ ├── doc.go │ ├── grpclog │ └── logger.go │ ├── interceptor.go │ ├── internal │ └── internal.go │ ├── metadata │ └── metadata.go │ ├── naming │ └── naming.go │ ├── peer │ └── peer.go │ ├── rpc_util.go │ ├── server.go │ ├── stats │ ├── handlers.go │ └── stats.go │ ├── stream.go │ ├── tap │ └── tap.go │ ├── trace.go │ └── transport │ ├── control.go │ ├── go16.go │ ├── go17.go │ ├── handler_server.go │ ├── http2_client.go │ ├── http2_server.go │ ├── http_util.go │ ├── pre_go16.go │ └── transport.go ├── gopkg.in └── yaml.v2 │ ├── LICENSE │ ├── LICENSE.libyaml │ ├── README.md │ ├── apic.go │ ├── decode.go │ ├── emitterc.go │ ├── encode.go │ ├── parserc.go │ ├── readerc.go │ ├── resolve.go │ ├── scannerc.go │ ├── sorter.go │ ├── writerc.go │ ├── yaml.go │ ├── yamlh.go │ └── yamlprivateh.go └── vendor.json /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.a 3 | *.so 4 | _obj 5 | _test 6 | *.[568vq] 7 | [568vq].out 8 | *.cgo1.go 9 | *.cgo2.c 10 | _cgo_defun.c 11 | _cgo_gotypes.go 12 | _cgo_export.* 13 | _testmain.go 14 | *.exe 15 | *.exe~ 16 | *.test 17 | *.prof 18 | *.rar 19 | *.zip 20 | *.gz 21 | *.psd 22 | *.bmd 23 | *.cfg 24 | *.pptx 25 | *.log 26 | *nohup.out 27 | *.sublime-project 28 | *.sublime-workspace 29 | 30 | server/log/* 31 | server/config/* -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # faygos 2 | A micro service framework developed using 'faygo' and 'etcd' 3 | 4 | # Status 5 | 6 | developing -------------------------------------------------------------------------------- /server/config.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "path" 5 | "strings" 6 | 7 | "github.com/henrylee2cn/faygo" 8 | ) 9 | 10 | type Config struct { 11 | BasePath string `ini:"base_path"` 12 | EtcdUrls []string `ini:"etcd_urls" delim:"|"` 13 | EtcdDialTimeout uint32 `ini:"etcd_dial_timeout"` // second 14 | EtcdUpdateInterval uint32 `ini:"etcd_update_interval"` // second 15 | faygo.Config `ini:"DEFAULT"` 16 | } 17 | 18 | func newConfig(filename string) (Config, error) { 19 | structPointer := &Config{ 20 | EtcdDialTimeout: 10, 21 | EtcdUpdateInterval: 30, 22 | EtcdUrls: []string{"http://127.0.0.1:2379"}, 23 | } 24 | 25 | return *structPointer, faygo.SyncINI( 26 | structPointer, 27 | func(existed bool, saveOnce func() error) error { 28 | if existed && structPointer.BasePath == "" { 29 | structPointer.BasePath = "/faygos" 30 | return saveOnce() 31 | } 32 | structPointer.BasePath = strings.TrimRight(path.Join("/", structPointer.BasePath), "/") 33 | return nil 34 | }, 35 | filename, 36 | ) 37 | } 38 | -------------------------------------------------------------------------------- /server/server.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "net" 5 | "time" 6 | 7 | "github.com/henrylee2cn/faygo" 8 | "github.com/rcrowley/go-metrics" 9 | ) 10 | 11 | type Server struct { 12 | *faygo.Framework 13 | etcdV3Registers []*EtcdV3Register 14 | config Config 15 | } 16 | 17 | // New creates a new Server 18 | func New(name string, version ...string) (*Server, error) { 19 | frame := faygo.New(name, version...) 20 | config, err := newConfig(frame.ConfigFilename()) 21 | if err != nil { 22 | return nil, err 23 | } 24 | etcdV3Registers := make([]*EtcdV3Register, len(config.Addrs)) 25 | for i := range etcdV3Registers { 26 | _, port, _ := net.SplitHostPort(config.Addrs[i]) 27 | etcdV3Registers[i] = &EtcdV3Register{ 28 | Port: port, 29 | EtcdServers: config.EtcdUrls, 30 | BasePath: config.BasePath, 31 | Metrics: metrics.NewRegistry(), 32 | DialEtcdTimeout: time.Duration(config.EtcdDialTimeout) * time.Second, 33 | UpdateInterval: time.Duration(config.EtcdUpdateInterval) * time.Second, 34 | } 35 | } 36 | return &Server{ 37 | Framework: frame, 38 | etcdV3Registers: etcdV3Registers, 39 | config: config, 40 | }, nil 41 | } 42 | 43 | // Run starts all web services. 44 | func (s *Server) Run(metadata ...string) { 45 | for _, reg := range s.etcdV3Registers { 46 | if err := reg.Start(); err != nil { 47 | s.Log().Fatal(err) 48 | } 49 | for _, mux := range s.MuxAPIsForRouter() { 50 | if err := reg.Register(mux.Path(), metadata...); err != nil { 51 | s.Log().Fatal(err) 52 | } 53 | } 54 | } 55 | s.Framework.Run() 56 | } 57 | -------------------------------------------------------------------------------- /server/server_test.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestNew(t *testing.T) { 8 | srv, err := New("testserver", "1.0") 9 | t.Logf("config:%#v\nerror:%v", srv.config, err) 10 | } 11 | -------------------------------------------------------------------------------- /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/github.com/coreos/etcd/NOTICE: -------------------------------------------------------------------------------- 1 | CoreOS Project 2 | Copyright 2014 CoreOS, Inc 3 | 4 | This product includes software developed at CoreOS, Inc. 5 | (http://www.coreos.com/). 6 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/auth/authpb/auth.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package authpb; 3 | 4 | import "gogoproto/gogo.proto"; 5 | 6 | option (gogoproto.marshaler_all) = true; 7 | option (gogoproto.sizer_all) = true; 8 | option (gogoproto.unmarshaler_all) = true; 9 | option (gogoproto.goproto_getters_all) = false; 10 | option (gogoproto.goproto_enum_prefix_all) = false; 11 | 12 | // User is a single entry in the bucket authUsers 13 | message User { 14 | bytes name = 1; 15 | bytes password = 2; 16 | repeated string roles = 3; 17 | } 18 | 19 | // Permission is a single entity 20 | message Permission { 21 | enum Type { 22 | READ = 0; 23 | WRITE = 1; 24 | READWRITE = 2; 25 | } 26 | Type permType = 1; 27 | 28 | bytes key = 2; 29 | bytes range_end = 3; 30 | } 31 | 32 | // Role is a single entry in the bucket authRoles 33 | message Role { 34 | bytes name = 1; 35 | 36 | repeated Permission keyPermission = 2; 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/clientv3/README.md: -------------------------------------------------------------------------------- 1 | # etcd/clientv3 2 | 3 | [![Godoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](https://godoc.org/github.com/coreos/etcd/clientv3) 4 | 5 | `etcd/clientv3` is the official Go etcd client for v3. 6 | 7 | ## Install 8 | 9 | ```bash 10 | go get github.com/coreos/etcd/clientv3 11 | ``` 12 | 13 | ## Get started 14 | 15 | Create client using `clientv3.New`: 16 | 17 | ```go 18 | cli, err := clientv3.New(clientv3.Config{ 19 | Endpoints: []string{"localhost:2379", "localhost:22379", "localhost:32379"}, 20 | DialTimeout: 5 * time.Second, 21 | }) 22 | if err != nil { 23 | // handle error! 24 | } 25 | defer cli.Close() 26 | ``` 27 | 28 | etcd v3 uses [`gRPC`](http://www.grpc.io) for remote procedure calls. And `clientv3` uses 29 | [`grpc-go`](https://github.com/grpc/grpc-go) to connect to etcd. Make sure to close the client after using it. 30 | If the client is not closed, the connection will have leaky goroutines. To specify client request timeout, 31 | pass `context.WithTimeout` to APIs: 32 | 33 | ```go 34 | ctx, cancel := context.WithTimeout(context.Background(), timeout) 35 | resp, err := kvc.Put(ctx, "sample_key", "sample_value") 36 | cancel() 37 | if err != nil { 38 | // handle error! 39 | } 40 | // use the response 41 | ``` 42 | 43 | etcd uses `cmd/vendor` directory to store external dependencies, which are 44 | to be compiled into etcd release binaries. `client` can be imported without 45 | vendoring. For full compatibility, it is recommended to vendor builds using 46 | etcd's vendored packages, using tools like godep, as in 47 | [vendor directories](https://golang.org/cmd/go/#hdr-Vendor_Directories). 48 | For more detail, please read [Go vendor design](https://golang.org/s/go15vendor). 49 | 50 | ## Error Handling 51 | 52 | etcd client returns 2 types of errors: 53 | 54 | 1. context error: canceled or deadline exceeded. 55 | 2. gRPC error: see [api/v3rpc/rpctypes](https://godoc.org/github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes). 56 | 57 | Here is the example code to handle client errors: 58 | 59 | ```go 60 | resp, err := kvc.Put(ctx, "", "") 61 | if err != nil { 62 | switch err { 63 | case context.Canceled: 64 | log.Fatalf("ctx is canceled by another routine: %v", err) 65 | case context.DeadlineExceeded: 66 | log.Fatalf("ctx is attached with a deadline is exceeded: %v", err) 67 | case rpctypes.ErrEmptyKey: 68 | log.Fatalf("client-side error: %v", err) 69 | default: 70 | log.Fatalf("bad cluster endpoints, which are not etcd servers: %v", err) 71 | } 72 | } 73 | ``` 74 | 75 | ## Metrics 76 | 77 | The etcd client optionally exposes RPC metrics through [go-grpc-prometheus](https://github.com/grpc-ecosystem/go-grpc-prometheus). See the [examples](https://github.com/coreos/etcd/blob/master/clientv3/example_metrics_test.go). 78 | 79 | ## Examples 80 | 81 | More code examples can be found at [GoDoc](https://godoc.org/github.com/coreos/etcd/clientv3). 82 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/clientv3/cluster.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 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 clientv3 16 | 17 | import ( 18 | pb "github.com/coreos/etcd/etcdserver/etcdserverpb" 19 | "golang.org/x/net/context" 20 | "google.golang.org/grpc" 21 | ) 22 | 23 | type ( 24 | Member pb.Member 25 | MemberListResponse pb.MemberListResponse 26 | MemberAddResponse pb.MemberAddResponse 27 | MemberRemoveResponse pb.MemberRemoveResponse 28 | MemberUpdateResponse pb.MemberUpdateResponse 29 | ) 30 | 31 | type Cluster interface { 32 | // MemberList lists the current cluster membership. 33 | MemberList(ctx context.Context) (*MemberListResponse, error) 34 | 35 | // MemberAdd adds a new member into the cluster. 36 | MemberAdd(ctx context.Context, peerAddrs []string) (*MemberAddResponse, error) 37 | 38 | // MemberRemove removes an existing member from the cluster. 39 | MemberRemove(ctx context.Context, id uint64) (*MemberRemoveResponse, error) 40 | 41 | // MemberUpdate updates the peer addresses of the member. 42 | MemberUpdate(ctx context.Context, id uint64, peerAddrs []string) (*MemberUpdateResponse, error) 43 | } 44 | 45 | type cluster struct { 46 | remote pb.ClusterClient 47 | } 48 | 49 | func NewCluster(c *Client) Cluster { 50 | return &cluster{remote: RetryClusterClient(c)} 51 | } 52 | 53 | func (c *cluster) MemberAdd(ctx context.Context, peerAddrs []string) (*MemberAddResponse, error) { 54 | r := &pb.MemberAddRequest{PeerURLs: peerAddrs} 55 | resp, err := c.remote.MemberAdd(ctx, r) 56 | if err == nil { 57 | return (*MemberAddResponse)(resp), nil 58 | } 59 | if isHaltErr(ctx, err) { 60 | return nil, toErr(ctx, err) 61 | } 62 | return nil, toErr(ctx, err) 63 | } 64 | 65 | func (c *cluster) MemberRemove(ctx context.Context, id uint64) (*MemberRemoveResponse, error) { 66 | r := &pb.MemberRemoveRequest{ID: id} 67 | resp, err := c.remote.MemberRemove(ctx, r) 68 | if err == nil { 69 | return (*MemberRemoveResponse)(resp), nil 70 | } 71 | if isHaltErr(ctx, err) { 72 | return nil, toErr(ctx, err) 73 | } 74 | return nil, toErr(ctx, err) 75 | } 76 | 77 | func (c *cluster) MemberUpdate(ctx context.Context, id uint64, peerAddrs []string) (*MemberUpdateResponse, error) { 78 | // it is safe to retry on update. 79 | for { 80 | r := &pb.MemberUpdateRequest{ID: id, PeerURLs: peerAddrs} 81 | resp, err := c.remote.MemberUpdate(ctx, r, grpc.FailFast(false)) 82 | if err == nil { 83 | return (*MemberUpdateResponse)(resp), nil 84 | } 85 | if isHaltErr(ctx, err) { 86 | return nil, toErr(ctx, err) 87 | } 88 | } 89 | } 90 | 91 | func (c *cluster) MemberList(ctx context.Context) (*MemberListResponse, error) { 92 | // it is safe to retry on list. 93 | for { 94 | resp, err := c.remote.MemberList(ctx, &pb.MemberListRequest{}, grpc.FailFast(false)) 95 | if err == nil { 96 | return (*MemberListResponse)(resp), nil 97 | } 98 | if isHaltErr(ctx, err) { 99 | return nil, toErr(ctx, err) 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/clientv3/compact_op.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 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 clientv3 16 | 17 | import ( 18 | pb "github.com/coreos/etcd/etcdserver/etcdserverpb" 19 | ) 20 | 21 | // CompactOp represents a compact operation. 22 | type CompactOp struct { 23 | revision int64 24 | physical bool 25 | } 26 | 27 | // CompactOption configures compact operation. 28 | type CompactOption func(*CompactOp) 29 | 30 | func (op *CompactOp) applyCompactOpts(opts []CompactOption) { 31 | for _, opt := range opts { 32 | opt(op) 33 | } 34 | } 35 | 36 | // OpCompact wraps slice CompactOption to create a CompactOp. 37 | func OpCompact(rev int64, opts ...CompactOption) CompactOp { 38 | ret := CompactOp{revision: rev} 39 | ret.applyCompactOpts(opts) 40 | return ret 41 | } 42 | 43 | func (op CompactOp) toRequest() *pb.CompactionRequest { 44 | return &pb.CompactionRequest{Revision: op.revision, Physical: op.physical} 45 | } 46 | 47 | // WithCompactPhysical makes compact RPC call wait until 48 | // the compaction is physically applied to the local database 49 | // such that compacted entries are totally removed from the 50 | // backend database. 51 | func WithCompactPhysical() CompactOption { 52 | return func(op *CompactOp) { op.physical = true } 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/clientv3/compare.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 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 clientv3 16 | 17 | import ( 18 | pb "github.com/coreos/etcd/etcdserver/etcdserverpb" 19 | ) 20 | 21 | type CompareTarget int 22 | type CompareResult int 23 | 24 | const ( 25 | CompareVersion CompareTarget = iota 26 | CompareCreated 27 | CompareModified 28 | CompareValue 29 | ) 30 | 31 | type Cmp pb.Compare 32 | 33 | func Compare(cmp Cmp, result string, v interface{}) Cmp { 34 | var r pb.Compare_CompareResult 35 | 36 | switch result { 37 | case "=": 38 | r = pb.Compare_EQUAL 39 | case "!=": 40 | r = pb.Compare_NOT_EQUAL 41 | case ">": 42 | r = pb.Compare_GREATER 43 | case "<": 44 | r = pb.Compare_LESS 45 | default: 46 | panic("Unknown result op") 47 | } 48 | 49 | cmp.Result = r 50 | switch cmp.Target { 51 | case pb.Compare_VALUE: 52 | val, ok := v.(string) 53 | if !ok { 54 | panic("bad compare value") 55 | } 56 | cmp.TargetUnion = &pb.Compare_Value{Value: []byte(val)} 57 | case pb.Compare_VERSION: 58 | cmp.TargetUnion = &pb.Compare_Version{Version: mustInt64(v)} 59 | case pb.Compare_CREATE: 60 | cmp.TargetUnion = &pb.Compare_CreateRevision{CreateRevision: mustInt64(v)} 61 | case pb.Compare_MOD: 62 | cmp.TargetUnion = &pb.Compare_ModRevision{ModRevision: mustInt64(v)} 63 | default: 64 | panic("Unknown compare type") 65 | } 66 | return cmp 67 | } 68 | 69 | func Value(key string) Cmp { 70 | return Cmp{Key: []byte(key), Target: pb.Compare_VALUE} 71 | } 72 | 73 | func Version(key string) Cmp { 74 | return Cmp{Key: []byte(key), Target: pb.Compare_VERSION} 75 | } 76 | 77 | func CreateRevision(key string) Cmp { 78 | return Cmp{Key: []byte(key), Target: pb.Compare_CREATE} 79 | } 80 | 81 | func ModRevision(key string) Cmp { 82 | return Cmp{Key: []byte(key), Target: pb.Compare_MOD} 83 | } 84 | 85 | func mustInt64(val interface{}) int64 { 86 | if v, ok := val.(int64); ok { 87 | return v 88 | } 89 | if v, ok := val.(int); ok { 90 | return int64(v) 91 | } 92 | panic("bad value") 93 | } 94 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/clientv3/config.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 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 clientv3 16 | 17 | import ( 18 | "crypto/tls" 19 | "crypto/x509" 20 | "io/ioutil" 21 | "time" 22 | 23 | "github.com/coreos/etcd/pkg/tlsutil" 24 | "github.com/ghodss/yaml" 25 | ) 26 | 27 | type Config struct { 28 | // Endpoints is a list of URLs 29 | Endpoints []string 30 | 31 | // AutoSyncInterval is the interval to update endpoints with its latest members. 32 | // 0 disables auto-sync. By default auto-sync is disabled. 33 | AutoSyncInterval time.Duration 34 | 35 | // DialTimeout is the timeout for failing to establish a connection. 36 | DialTimeout time.Duration 37 | 38 | // TLS holds the client secure credentials, if any. 39 | TLS *tls.Config 40 | 41 | // Username is a username for authentication 42 | Username string 43 | 44 | // Password is a password for authentication 45 | Password string 46 | } 47 | 48 | type yamlConfig struct { 49 | Endpoints []string `json:"endpoints"` 50 | AutoSyncInterval time.Duration `json:"auto-sync-interval"` 51 | DialTimeout time.Duration `json:"dial-timeout"` 52 | InsecureTransport bool `json:"insecure-transport"` 53 | InsecureSkipTLSVerify bool `json:"insecure-skip-tls-verify"` 54 | Certfile string `json:"cert-file"` 55 | Keyfile string `json:"key-file"` 56 | CAfile string `json:"ca-file"` 57 | } 58 | 59 | func configFromFile(fpath string) (*Config, error) { 60 | b, err := ioutil.ReadFile(fpath) 61 | if err != nil { 62 | return nil, err 63 | } 64 | 65 | yc := &yamlConfig{} 66 | 67 | err = yaml.Unmarshal(b, yc) 68 | if err != nil { 69 | return nil, err 70 | } 71 | 72 | cfg := &Config{ 73 | Endpoints: yc.Endpoints, 74 | AutoSyncInterval: yc.AutoSyncInterval, 75 | DialTimeout: yc.DialTimeout, 76 | } 77 | 78 | if yc.InsecureTransport { 79 | cfg.TLS = nil 80 | return cfg, nil 81 | } 82 | 83 | var ( 84 | cert *tls.Certificate 85 | cp *x509.CertPool 86 | ) 87 | 88 | if yc.Certfile != "" && yc.Keyfile != "" { 89 | cert, err = tlsutil.NewCert(yc.Certfile, yc.Keyfile, nil) 90 | if err != nil { 91 | return nil, err 92 | } 93 | } 94 | 95 | if yc.CAfile != "" { 96 | cp, err = tlsutil.NewCertPool([]string{yc.CAfile}) 97 | if err != nil { 98 | return nil, err 99 | } 100 | } 101 | 102 | tlscfg := &tls.Config{ 103 | MinVersion: tls.VersionTLS10, 104 | InsecureSkipVerify: yc.InsecureSkipTLSVerify, 105 | RootCAs: cp, 106 | } 107 | if cert != nil { 108 | tlscfg.Certificates = []tls.Certificate{*cert} 109 | } 110 | cfg.TLS = tlscfg 111 | 112 | return cfg, nil 113 | } 114 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/clientv3/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 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 clientv3 implements the official Go etcd client for v3. 16 | // 17 | // Create client using `clientv3.New`: 18 | // 19 | // cli, err := clientv3.New(clientv3.Config{ 20 | // Endpoints: []string{"localhost:2379", "localhost:22379", "localhost:32379"}, 21 | // DialTimeout: 5 * time.Second, 22 | // }) 23 | // if err != nil { 24 | // // handle error! 25 | // } 26 | // defer cli.Close() 27 | // 28 | // Make sure to close the client after using it. If the client is not closed, the 29 | // connection will have leaky goroutines. 30 | // 31 | // To specify client request timeout, pass context.WithTimeout to APIs: 32 | // 33 | // ctx, cancel := context.WithTimeout(context.Background(), timeout) 34 | // resp, err := kvc.Put(ctx, "sample_key", "sample_value") 35 | // cancel() 36 | // if err != nil { 37 | // // handle error! 38 | // } 39 | // // use the response 40 | // 41 | // The Client has internal state (watchers and leases), so Clients should be reused instead of created as needed. 42 | // Clients are safe for concurrent use by multiple goroutines. 43 | // 44 | // etcd client returns 2 types of errors: 45 | // 46 | // 1. context error: canceled or deadline exceeded. 47 | // 2. gRPC error: see https://github.com/coreos/etcd/blob/master/etcdserver/api/v3rpc/rpctypes/error.go 48 | // 49 | // Here is the example code to handle client errors: 50 | // 51 | // resp, err := kvc.Put(ctx, "", "") 52 | // if err != nil { 53 | // if err == context.Canceled { 54 | // // ctx is canceled by another routine 55 | // } else if err == context.DeadlineExceeded { 56 | // // ctx is attached with a deadline and it exceeded 57 | // } else if verr, ok := err.(*v3rpc.ErrEmptyKey); ok { 58 | // // process (verr.Errors) 59 | // } else { 60 | // // bad cluster endpoints, which are not etcd servers 61 | // } 62 | // } 63 | // 64 | package clientv3 65 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/clientv3/logger.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 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 clientv3 16 | 17 | import ( 18 | "io/ioutil" 19 | "log" 20 | "sync" 21 | 22 | "google.golang.org/grpc/grpclog" 23 | ) 24 | 25 | // Logger is the logger used by client library. 26 | // It implements grpclog.Logger interface. 27 | type Logger grpclog.Logger 28 | 29 | var ( 30 | logger settableLogger 31 | ) 32 | 33 | type settableLogger struct { 34 | l grpclog.Logger 35 | mu sync.RWMutex 36 | } 37 | 38 | func init() { 39 | // disable client side logs by default 40 | logger.mu.Lock() 41 | logger.l = log.New(ioutil.Discard, "", 0) 42 | 43 | // logger has to override the grpclog at initialization so that 44 | // any changes to the grpclog go through logger with locking 45 | // instead of through SetLogger 46 | // 47 | // now updates only happen through settableLogger.set 48 | grpclog.SetLogger(&logger) 49 | logger.mu.Unlock() 50 | } 51 | 52 | // SetLogger sets client-side Logger. By default, logs are disabled. 53 | func SetLogger(l Logger) { 54 | logger.set(l) 55 | } 56 | 57 | // GetLogger returns the current logger. 58 | func GetLogger() Logger { 59 | return logger.get() 60 | } 61 | 62 | func (s *settableLogger) set(l Logger) { 63 | s.mu.Lock() 64 | logger.l = l 65 | s.mu.Unlock() 66 | } 67 | 68 | func (s *settableLogger) get() Logger { 69 | s.mu.RLock() 70 | l := logger.l 71 | s.mu.RUnlock() 72 | return l 73 | } 74 | 75 | // implement the grpclog.Logger interface 76 | 77 | func (s *settableLogger) Fatal(args ...interface{}) { s.get().Fatal(args...) } 78 | func (s *settableLogger) Fatalf(format string, args ...interface{}) { s.get().Fatalf(format, args...) } 79 | func (s *settableLogger) Fatalln(args ...interface{}) { s.get().Fatalln(args...) } 80 | func (s *settableLogger) Print(args ...interface{}) { s.get().Print(args...) } 81 | func (s *settableLogger) Printf(format string, args ...interface{}) { s.get().Printf(format, args...) } 82 | func (s *settableLogger) Println(args ...interface{}) { s.get().Println(args...) } 83 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/clientv3/sort.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 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 clientv3 16 | 17 | type SortTarget int 18 | type SortOrder int 19 | 20 | const ( 21 | SortNone SortOrder = iota 22 | SortAscend 23 | SortDescend 24 | ) 25 | 26 | const ( 27 | SortByKey SortTarget = iota 28 | SortByVersion 29 | SortByCreateRevision 30 | SortByModRevision 31 | SortByValue 32 | ) 33 | 34 | type SortOption struct { 35 | Target SortTarget 36 | Order SortOrder 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 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 rpctypes has types and values shared by the etcd server and client for v3 RPC interaction. 16 | package rpctypes 17 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes/md.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 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 rpctypes 16 | 17 | var ( 18 | MetadataRequireLeaderKey = "hasleader" 19 | MetadataHasLeader = "true" 20 | ) 21 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/etcdserver/etcdserverpb/etcdserver.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package etcdserverpb; 3 | 4 | import "gogoproto/gogo.proto"; 5 | 6 | option (gogoproto.marshaler_all) = true; 7 | option (gogoproto.sizer_all) = true; 8 | option (gogoproto.unmarshaler_all) = true; 9 | option (gogoproto.goproto_getters_all) = false; 10 | 11 | message Request { 12 | optional uint64 ID = 1 [(gogoproto.nullable) = false]; 13 | optional string Method = 2 [(gogoproto.nullable) = false]; 14 | optional string Path = 3 [(gogoproto.nullable) = false]; 15 | optional string Val = 4 [(gogoproto.nullable) = false]; 16 | optional bool Dir = 5 [(gogoproto.nullable) = false]; 17 | optional string PrevValue = 6 [(gogoproto.nullable) = false]; 18 | optional uint64 PrevIndex = 7 [(gogoproto.nullable) = false]; 19 | optional bool PrevExist = 8 [(gogoproto.nullable) = true]; 20 | optional int64 Expiration = 9 [(gogoproto.nullable) = false]; 21 | optional bool Wait = 10 [(gogoproto.nullable) = false]; 22 | optional uint64 Since = 11 [(gogoproto.nullable) = false]; 23 | optional bool Recursive = 12 [(gogoproto.nullable) = false]; 24 | optional bool Sorted = 13 [(gogoproto.nullable) = false]; 25 | optional bool Quorum = 14 [(gogoproto.nullable) = false]; 26 | optional int64 Time = 15 [(gogoproto.nullable) = false]; 27 | optional bool Stream = 16 [(gogoproto.nullable) = false]; 28 | optional bool Refresh = 17 [(gogoproto.nullable) = true]; 29 | } 30 | 31 | message Metadata { 32 | optional uint64 NodeID = 1 [(gogoproto.nullable) = false]; 33 | optional uint64 ClusterID = 2 [(gogoproto.nullable) = false]; 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/etcdserver/etcdserverpb/raft_internal.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package etcdserverpb; 3 | 4 | import "gogoproto/gogo.proto"; 5 | import "etcdserver.proto"; 6 | import "rpc.proto"; 7 | 8 | option (gogoproto.marshaler_all) = true; 9 | option (gogoproto.sizer_all) = true; 10 | option (gogoproto.unmarshaler_all) = true; 11 | option (gogoproto.goproto_getters_all) = false; 12 | 13 | message RequestHeader { 14 | uint64 ID = 1; 15 | // username is a username that is associated with an auth token of gRPC connection 16 | string username = 2; 17 | // auth_revision is a revision number of auth.authStore. It is not related to mvcc 18 | uint64 auth_revision = 3; 19 | } 20 | 21 | // An InternalRaftRequest is the union of all requests which can be 22 | // sent via raft. 23 | message InternalRaftRequest { 24 | RequestHeader header = 100; 25 | uint64 ID = 1; 26 | 27 | Request v2 = 2; 28 | 29 | RangeRequest range = 3; 30 | PutRequest put = 4; 31 | DeleteRangeRequest delete_range = 5; 32 | TxnRequest txn = 6; 33 | CompactionRequest compaction = 7; 34 | 35 | LeaseGrantRequest lease_grant = 8; 36 | LeaseRevokeRequest lease_revoke = 9; 37 | 38 | AlarmRequest alarm = 10; 39 | 40 | AuthEnableRequest auth_enable = 1000; 41 | AuthDisableRequest auth_disable = 1011; 42 | 43 | InternalAuthenticateRequest authenticate = 1012; 44 | 45 | AuthUserAddRequest auth_user_add = 1100; 46 | AuthUserDeleteRequest auth_user_delete = 1101; 47 | AuthUserGetRequest auth_user_get = 1102; 48 | AuthUserChangePasswordRequest auth_user_change_password = 1103; 49 | AuthUserGrantRoleRequest auth_user_grant_role = 1104; 50 | AuthUserRevokeRoleRequest auth_user_revoke_role = 1105; 51 | AuthUserListRequest auth_user_list = 1106; 52 | AuthRoleListRequest auth_role_list = 1107; 53 | 54 | AuthRoleAddRequest auth_role_add = 1200; 55 | AuthRoleDeleteRequest auth_role_delete = 1201; 56 | AuthRoleGetRequest auth_role_get = 1202; 57 | AuthRoleGrantPermissionRequest auth_role_grant_permission = 1203; 58 | AuthRoleRevokePermissionRequest auth_role_revoke_permission = 1204; 59 | } 60 | 61 | message EmptyResponse { 62 | } 63 | 64 | // What is the difference between AuthenticateRequest (defined in rpc.proto) and InternalAuthenticateRequest? 65 | // InternalAuthenticateRequest has a member that is filled by etcdserver and shouldn't be user-facing. 66 | // For avoiding misusage the field, we have an internal version of AuthenticateRequest. 67 | message InternalAuthenticateRequest { 68 | string name = 1; 69 | string password = 2; 70 | 71 | // simple_token is generated in API layer (etcdserver/v3_server.go) 72 | string simple_token = 3; 73 | } 74 | 75 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/mvcc/mvccpb/kv.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package mvccpb; 3 | 4 | import "gogoproto/gogo.proto"; 5 | 6 | option (gogoproto.marshaler_all) = true; 7 | option (gogoproto.sizer_all) = true; 8 | option (gogoproto.unmarshaler_all) = true; 9 | option (gogoproto.goproto_getters_all) = false; 10 | option (gogoproto.goproto_enum_prefix_all) = false; 11 | 12 | message KeyValue { 13 | // key is the key in bytes. An empty key is not allowed. 14 | bytes key = 1; 15 | // create_revision is the revision of last creation on this key. 16 | int64 create_revision = 2; 17 | // mod_revision is the revision of last modification on this key. 18 | int64 mod_revision = 3; 19 | // version is the version of the key. A deletion resets 20 | // the version to zero and any modification of the key 21 | // increases its version. 22 | int64 version = 4; 23 | // value is the value held by the key, in bytes. 24 | bytes value = 5; 25 | // lease is the ID of the lease that attached to key. 26 | // When the attached lease expires, the key will be deleted. 27 | // If lease is 0, then no lease is attached to the key. 28 | int64 lease = 6; 29 | } 30 | 31 | message Event { 32 | enum EventType { 33 | PUT = 0; 34 | DELETE = 1; 35 | } 36 | // type is the kind of event. If type is a PUT, it indicates 37 | // new data has been stored to the key. If type is a DELETE, 38 | // it indicates the key was deleted. 39 | EventType type = 1; 40 | // kv holds the KeyValue for the event. 41 | // A PUT event contains current kv pair. 42 | // A PUT event with kv.Version=1 indicates the creation of a key. 43 | // A DELETE/EXPIRE event contains the deleted key with 44 | // its modification revision set to the revision of deletion. 45 | KeyValue kv = 2; 46 | 47 | // prev_kv holds the key-value pair before the event happens. 48 | KeyValue prev_kv = 3; 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/pkg/tlsutil/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 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 tlsutil provides utility functions for handling TLS. 16 | package tlsutil 17 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/pkg/tlsutil/tlsutil.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 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 tlsutil 16 | 17 | import ( 18 | "crypto/tls" 19 | "crypto/x509" 20 | "encoding/pem" 21 | "io/ioutil" 22 | ) 23 | 24 | // NewCertPool creates x509 certPool with provided CA files. 25 | func NewCertPool(CAFiles []string) (*x509.CertPool, error) { 26 | certPool := x509.NewCertPool() 27 | 28 | for _, CAFile := range CAFiles { 29 | pemByte, err := ioutil.ReadFile(CAFile) 30 | if err != nil { 31 | return nil, err 32 | } 33 | 34 | for { 35 | var block *pem.Block 36 | block, pemByte = pem.Decode(pemByte) 37 | if block == nil { 38 | break 39 | } 40 | cert, err := x509.ParseCertificate(block.Bytes) 41 | if err != nil { 42 | return nil, err 43 | } 44 | certPool.AddCert(cert) 45 | } 46 | } 47 | 48 | return certPool, nil 49 | } 50 | 51 | // NewCert generates TLS cert by using the given cert,key and parse function. 52 | func NewCert(certfile, keyfile string, parseFunc func([]byte, []byte) (tls.Certificate, error)) (*tls.Certificate, error) { 53 | cert, err := ioutil.ReadFile(certfile) 54 | if err != nil { 55 | return nil, err 56 | } 57 | 58 | key, err := ioutil.ReadFile(keyfile) 59 | if err != nil { 60 | return nil, err 61 | } 62 | 63 | if parseFunc == nil { 64 | parseFunc = tls.X509KeyPair 65 | } 66 | 67 | tlsCert, err := parseFunc(cert, key) 68 | if err != nil { 69 | return nil, err 70 | } 71 | return &tlsCert, nil 72 | } 73 | -------------------------------------------------------------------------------- /vendor/github.com/ghodss/yaml/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Sam Ghods 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 | 24 | Copyright (c) 2012 The Go Authors. All rights reserved. 25 | 26 | Redistribution and use in source and binary forms, with or without 27 | modification, are permitted provided that the following conditions are 28 | met: 29 | 30 | * Redistributions of source code must retain the above copyright 31 | notice, this list of conditions and the following disclaimer. 32 | * Redistributions in binary form must reproduce the above 33 | copyright notice, this list of conditions and the following disclaimer 34 | in the documentation and/or other materials provided with the 35 | distribution. 36 | * Neither the name of Google Inc. nor the names of its 37 | contributors may be used to endorse or promote products derived from 38 | this software without specific prior written permission. 39 | 40 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 41 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 42 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 43 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 44 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 45 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 46 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 47 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 48 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 49 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 50 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 51 | -------------------------------------------------------------------------------- /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/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/grpc-ecosystem/go-grpc-prometheus/client.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Michal Witkowski. All Rights Reserved. 2 | // See LICENSE for licensing terms. 3 | 4 | // gRPC Prometheus monitoring interceptors for client-side gRPC. 5 | 6 | package grpc_prometheus 7 | 8 | import ( 9 | "io" 10 | 11 | "golang.org/x/net/context" 12 | "google.golang.org/grpc" 13 | "google.golang.org/grpc/codes" 14 | ) 15 | 16 | // UnaryClientInterceptor is a gRPC client-side interceptor that provides Prometheus monitoring for Unary RPCs. 17 | func UnaryClientInterceptor(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { 18 | monitor := newClientReporter(Unary, method) 19 | monitor.SentMessage() 20 | err := invoker(ctx, method, req, reply, cc, opts...) 21 | if err != nil { 22 | monitor.ReceivedMessage() 23 | } 24 | monitor.Handled(grpc.Code(err)) 25 | return err 26 | } 27 | 28 | // StreamServerInterceptor is a gRPC client-side interceptor that provides Prometheus monitoring for Streaming RPCs. 29 | func StreamClientInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) { 30 | monitor := newClientReporter(clientStreamType(desc), method) 31 | clientStream, err := streamer(ctx, desc, cc, method, opts...) 32 | if err != nil { 33 | monitor.Handled(grpc.Code(err)) 34 | return nil, err 35 | } 36 | return &monitoredClientStream{clientStream, monitor}, nil 37 | } 38 | 39 | func clientStreamType(desc *grpc.StreamDesc) grpcType { 40 | if desc.ClientStreams && !desc.ServerStreams { 41 | return ClientStream 42 | } else if !desc.ClientStreams && desc.ServerStreams { 43 | return ServerStream 44 | } 45 | return BidiStream 46 | } 47 | 48 | // monitoredClientStream wraps grpc.ClientStream allowing each Sent/Recv of message to increment counters. 49 | type monitoredClientStream struct { 50 | grpc.ClientStream 51 | monitor *clientReporter 52 | } 53 | 54 | func (s *monitoredClientStream) SendMsg(m interface{}) error { 55 | err := s.ClientStream.SendMsg(m) 56 | if err == nil { 57 | s.monitor.SentMessage() 58 | } 59 | return err 60 | } 61 | 62 | func (s *monitoredClientStream) RecvMsg(m interface{}) error { 63 | err := s.ClientStream.RecvMsg(m) 64 | if err == nil { 65 | s.monitor.ReceivedMessage() 66 | } else if err == io.EOF { 67 | s.monitor.Handled(codes.OK) 68 | } else { 69 | s.monitor.Handled(grpc.Code(err)) 70 | } 71 | return err 72 | } 73 | -------------------------------------------------------------------------------- /vendor/github.com/grpc-ecosystem/go-grpc-prometheus/server.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Michal Witkowski. All Rights Reserved. 2 | // See LICENSE for licensing terms. 3 | 4 | // gRPC Prometheus monitoring interceptors for server-side gRPC. 5 | 6 | package grpc_prometheus 7 | 8 | import ( 9 | "golang.org/x/net/context" 10 | "google.golang.org/grpc" 11 | ) 12 | 13 | // PreregisterServices takes a gRPC server and pre-initializes all counters to 0. 14 | // This allows for easier monitoring in Prometheus (no missing metrics), and should be called *after* all services have 15 | // been registered with the server. 16 | func Register(server *grpc.Server) { 17 | serviceInfo := server.GetServiceInfo() 18 | for serviceName, info := range serviceInfo { 19 | for _, mInfo := range info.Methods { 20 | preRegisterMethod(serviceName, &mInfo) 21 | } 22 | } 23 | } 24 | 25 | // UnaryServerInterceptor is a gRPC server-side interceptor that provides Prometheus monitoring for Unary RPCs. 26 | func UnaryServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { 27 | monitor := newServerReporter(Unary, info.FullMethod) 28 | monitor.ReceivedMessage() 29 | resp, err := handler(ctx, req) 30 | monitor.Handled(grpc.Code(err)) 31 | if err == nil { 32 | monitor.SentMessage() 33 | } 34 | return resp, err 35 | } 36 | 37 | // StreamServerInterceptor is a gRPC server-side interceptor that provides Prometheus monitoring for Streaming RPCs. 38 | func StreamServerInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { 39 | monitor := newServerReporter(streamRpcType(info), info.FullMethod) 40 | err := handler(srv, &monitoredServerStream{ss, monitor}) 41 | monitor.Handled(grpc.Code(err)) 42 | return err 43 | } 44 | 45 | func streamRpcType(info *grpc.StreamServerInfo) grpcType { 46 | if info.IsClientStream && !info.IsServerStream { 47 | return ClientStream 48 | } else if !info.IsClientStream && info.IsServerStream { 49 | return ServerStream 50 | } 51 | return BidiStream 52 | } 53 | 54 | // monitoredStream wraps grpc.ServerStream allowing each Sent/Recv of message to increment counters. 55 | type monitoredServerStream struct { 56 | grpc.ServerStream 57 | monitor *serverReporter 58 | } 59 | 60 | func (s *monitoredServerStream) SendMsg(m interface{}) error { 61 | err := s.ServerStream.SendMsg(m) 62 | if err == nil { 63 | s.monitor.SentMessage() 64 | } 65 | return err 66 | } 67 | 68 | func (s *monitoredServerStream) RecvMsg(m interface{}) error { 69 | err := s.ServerStream.RecvMsg(m) 70 | if err == nil { 71 | s.monitor.ReceivedMessage() 72 | } 73 | return err 74 | } 75 | -------------------------------------------------------------------------------- /vendor/github.com/grpc-ecosystem/go-grpc-prometheus/util.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Michal Witkowski. All Rights Reserved. 2 | // See LICENSE for licensing terms. 3 | 4 | package grpc_prometheus 5 | 6 | import ( 7 | "strings" 8 | 9 | "google.golang.org/grpc/codes" 10 | ) 11 | 12 | var ( 13 | allCodes = []codes.Code{ 14 | codes.OK, codes.Canceled, codes.Unknown, codes.InvalidArgument, codes.DeadlineExceeded, codes.NotFound, 15 | codes.AlreadyExists, codes.PermissionDenied, codes.Unauthenticated, codes.ResourceExhausted, 16 | codes.FailedPrecondition, codes.Aborted, codes.OutOfRange, codes.Unimplemented, codes.Internal, 17 | codes.Unavailable, codes.DataLoss, 18 | } 19 | ) 20 | 21 | func splitMethodName(fullMethodName string) (string, string) { 22 | fullMethodName = strings.TrimPrefix(fullMethodName, "/") // remove leading slash 23 | if i := strings.Index(fullMethodName, "/"); i >= 0 { 24 | return fullMethodName[:i], fullMethodName[i+1:] 25 | } 26 | return "unknown", "unknown" 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/grpc-ecosystem/grpc-gateway/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Gengo, Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of Gengo, Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from this 16 | software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING 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/github.com/grpc-ecosystem/grpc-gateway/runtime/convert.go: -------------------------------------------------------------------------------- 1 | package runtime 2 | 3 | import ( 4 | "strconv" 5 | ) 6 | 7 | // String just returns the given string. 8 | // It is just for compatibility to other types. 9 | func String(val string) (string, error) { 10 | return val, nil 11 | } 12 | 13 | // Bool converts the given string representation of a boolean value into bool. 14 | func Bool(val string) (bool, error) { 15 | return strconv.ParseBool(val) 16 | } 17 | 18 | // Float64 converts the given string representation into representation of a floating point number into float64. 19 | func Float64(val string) (float64, error) { 20 | return strconv.ParseFloat(val, 64) 21 | } 22 | 23 | // Float32 converts the given string representation of a floating point number into float32. 24 | func Float32(val string) (float32, error) { 25 | f, err := strconv.ParseFloat(val, 32) 26 | if err != nil { 27 | return 0, err 28 | } 29 | return float32(f), nil 30 | } 31 | 32 | // Int64 converts the given string representation of an integer into int64. 33 | func Int64(val string) (int64, error) { 34 | return strconv.ParseInt(val, 0, 64) 35 | } 36 | 37 | // Int32 converts the given string representation of an integer into int32. 38 | func Int32(val string) (int32, error) { 39 | i, err := strconv.ParseInt(val, 0, 32) 40 | if err != nil { 41 | return 0, err 42 | } 43 | return int32(i), nil 44 | } 45 | 46 | // Uint64 converts the given string representation of an integer into uint64. 47 | func Uint64(val string) (uint64, error) { 48 | return strconv.ParseUint(val, 0, 64) 49 | } 50 | 51 | // Uint32 converts the given string representation of an integer into uint32. 52 | func Uint32(val string) (uint32, error) { 53 | i, err := strconv.ParseUint(val, 0, 32) 54 | if err != nil { 55 | return 0, err 56 | } 57 | return uint32(i), nil 58 | } 59 | -------------------------------------------------------------------------------- /vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package runtime contains runtime helper functions used by 3 | servers which protoc-gen-grpc-gateway generates. 4 | */ 5 | package runtime 6 | -------------------------------------------------------------------------------- /vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/internal/stream_chunk.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package grpc.gateway.runtime; 3 | option go_package = "internal"; 4 | 5 | // StreamError is a response type which is returned when 6 | // streaming rpc returns an error. 7 | message StreamError { 8 | int32 grpc_code = 1; 9 | int32 http_code = 2; 10 | string message = 3; 11 | string http_status = 4; 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/marshal_json.go: -------------------------------------------------------------------------------- 1 | package runtime 2 | 3 | import ( 4 | "encoding/json" 5 | "io" 6 | ) 7 | 8 | // JSONBuiltin is a Marshaler which marshals/unmarshals into/from JSON 9 | // with the standard "encoding/json" package of Golang. 10 | // Although it is generally faster for simple proto messages than JSONPb, 11 | // it does not support advanced features of protobuf, e.g. map, oneof, .... 12 | type JSONBuiltin struct{} 13 | 14 | // ContentType always Returns "application/json". 15 | func (*JSONBuiltin) ContentType() string { 16 | return "application/json" 17 | } 18 | 19 | // Marshal marshals "v" into JSON 20 | func (j *JSONBuiltin) Marshal(v interface{}) ([]byte, error) { 21 | return json.Marshal(v) 22 | } 23 | 24 | // Unmarshal unmarshals JSON data into "v". 25 | func (j *JSONBuiltin) Unmarshal(data []byte, v interface{}) error { 26 | return json.Unmarshal(data, v) 27 | } 28 | 29 | // NewDecoder returns a Decoder which reads JSON stream from "r". 30 | func (j *JSONBuiltin) NewDecoder(r io.Reader) Decoder { 31 | return json.NewDecoder(r) 32 | } 33 | 34 | // NewEncoder returns an Encoder which writes JSON stream into "w". 35 | func (j *JSONBuiltin) NewEncoder(w io.Writer) Encoder { 36 | return json.NewEncoder(w) 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/marshaler.go: -------------------------------------------------------------------------------- 1 | package runtime 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | // Marshaler defines a conversion between byte sequence and gRPC payloads / fields. 8 | type Marshaler interface { 9 | // Marshal marshals "v" into byte sequence. 10 | Marshal(v interface{}) ([]byte, error) 11 | // Unmarshal unmarshals "data" into "v". 12 | // "v" must be a pointer value. 13 | Unmarshal(data []byte, v interface{}) error 14 | // NewDecoder returns a Decoder which reads byte sequence from "r". 15 | NewDecoder(r io.Reader) Decoder 16 | // NewEncoder returns an Encoder which writes bytes sequence into "w". 17 | NewEncoder(w io.Writer) Encoder 18 | // ContentType returns the Content-Type which this marshaler is responsible for. 19 | ContentType() string 20 | } 21 | 22 | // Decoder decodes a byte sequence 23 | type Decoder interface { 24 | Decode(v interface{}) error 25 | } 26 | 27 | // Encoder encodes gRPC payloads / fields into byte sequence. 28 | type Encoder interface { 29 | Encode(v interface{}) error 30 | } 31 | 32 | // DecoderFunc adapts an decoder function into Decoder. 33 | type DecoderFunc func(v interface{}) error 34 | 35 | // Decode delegates invocations to the underlying function itself. 36 | func (f DecoderFunc) Decode(v interface{}) error { return f(v) } 37 | 38 | // EncoderFunc adapts an encoder function into Encoder 39 | type EncoderFunc func(v interface{}) error 40 | 41 | // Encode delegates invocations to the underlying function itself. 42 | func (f EncoderFunc) Encode(v interface{}) error { return f(v) } 43 | -------------------------------------------------------------------------------- /vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/marshaler_registry.go: -------------------------------------------------------------------------------- 1 | package runtime 2 | 3 | import ( 4 | "errors" 5 | "net/http" 6 | ) 7 | 8 | // MIMEWildcard is the fallback MIME type used for requests which do not match 9 | // a registered MIME type. 10 | const MIMEWildcard = "*" 11 | 12 | var ( 13 | acceptHeader = http.CanonicalHeaderKey("Accept") 14 | contentTypeHeader = http.CanonicalHeaderKey("Content-Type") 15 | 16 | defaultMarshaler = &JSONPb{OrigName: true} 17 | ) 18 | 19 | // MarshalerForRequest returns the inbound/outbound marshalers for this request. 20 | // It checks the registry on the ServeMux for the MIME type set by the Content-Type header. 21 | // If it isn't set (or the request Content-Type is empty), checks for "*". 22 | // If there are multiple Content-Type headers set, choose the first one that it can 23 | // exactly match in the registry. 24 | // Otherwise, it follows the above logic for "*"/InboundMarshaler/OutboundMarshaler. 25 | func MarshalerForRequest(mux *ServeMux, r *http.Request) (inbound Marshaler, outbound Marshaler) { 26 | for _, acceptVal := range r.Header[acceptHeader] { 27 | if m, ok := mux.marshalers.mimeMap[acceptVal]; ok { 28 | outbound = m 29 | break 30 | } 31 | } 32 | 33 | for _, contentTypeVal := range r.Header[contentTypeHeader] { 34 | if m, ok := mux.marshalers.mimeMap[contentTypeVal]; ok { 35 | inbound = m 36 | break 37 | } 38 | } 39 | 40 | if inbound == nil { 41 | inbound = mux.marshalers.mimeMap[MIMEWildcard] 42 | } 43 | if outbound == nil { 44 | outbound = inbound 45 | } 46 | 47 | return inbound, outbound 48 | } 49 | 50 | // marshalerRegistry is a mapping from MIME types to Marshalers. 51 | type marshalerRegistry struct { 52 | mimeMap map[string]Marshaler 53 | } 54 | 55 | // add adds a marshaler for a case-sensitive MIME type string ("*" to match any 56 | // MIME type). 57 | func (m marshalerRegistry) add(mime string, marshaler Marshaler) error { 58 | if len(mime) == 0 { 59 | return errors.New("empty MIME type") 60 | } 61 | 62 | m.mimeMap[mime] = marshaler 63 | 64 | return nil 65 | } 66 | 67 | // makeMarshalerMIMERegistry returns a new registry of marshalers. 68 | // It allows for a mapping of case-sensitive Content-Type MIME type string to runtime.Marshaler interfaces. 69 | // 70 | // For example, you could allow the client to specify the use of the runtime.JSONPb marshaler 71 | // with a "applicaton/jsonpb" Content-Type and the use of the runtime.JSONBuiltin marshaler 72 | // with a "application/json" Content-Type. 73 | // "*" can be used to match any Content-Type. 74 | // This can be attached to a ServerMux with the marshaler option. 75 | func makeMarshalerMIMERegistry() marshalerRegistry { 76 | return marshalerRegistry{ 77 | mimeMap: map[string]Marshaler{ 78 | MIMEWildcard: defaultMarshaler, 79 | }, 80 | } 81 | } 82 | 83 | // WithMarshalerOption returns a ServeMuxOption which associates inbound and outbound 84 | // Marshalers to a MIME type in mux. 85 | func WithMarshalerOption(mime string, marshaler Marshaler) ServeMuxOption { 86 | return func(mux *ServeMux) { 87 | if err := mux.marshalers.add(mime, marshaler); err != nil { 88 | panic(err) 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/proto2_convert.go: -------------------------------------------------------------------------------- 1 | package runtime 2 | 3 | import ( 4 | "github.com/golang/protobuf/proto" 5 | ) 6 | 7 | // StringP returns a pointer to a string whose pointee is same as the given string value. 8 | func StringP(val string) (*string, error) { 9 | return proto.String(val), nil 10 | } 11 | 12 | // BoolP parses the given string representation of a boolean value, 13 | // and returns a pointer to a bool whose value is same as the parsed value. 14 | func BoolP(val string) (*bool, error) { 15 | b, err := Bool(val) 16 | if err != nil { 17 | return nil, err 18 | } 19 | return proto.Bool(b), nil 20 | } 21 | 22 | // Float64P parses the given string representation of a floating point number, 23 | // and returns a pointer to a float64 whose value is same as the parsed number. 24 | func Float64P(val string) (*float64, error) { 25 | f, err := Float64(val) 26 | if err != nil { 27 | return nil, err 28 | } 29 | return proto.Float64(f), nil 30 | } 31 | 32 | // Float32P parses the given string representation of a floating point number, 33 | // and returns a pointer to a float32 whose value is same as the parsed number. 34 | func Float32P(val string) (*float32, error) { 35 | f, err := Float32(val) 36 | if err != nil { 37 | return nil, err 38 | } 39 | return proto.Float32(f), nil 40 | } 41 | 42 | // Int64P parses the given string representation of an integer 43 | // and returns a pointer to a int64 whose value is same as the parsed integer. 44 | func Int64P(val string) (*int64, error) { 45 | i, err := Int64(val) 46 | if err != nil { 47 | return nil, err 48 | } 49 | return proto.Int64(i), nil 50 | } 51 | 52 | // Int32P parses the given string representation of an integer 53 | // and returns a pointer to a int32 whose value is same as the parsed integer. 54 | func Int32P(val string) (*int32, error) { 55 | i, err := Int32(val) 56 | if err != nil { 57 | return nil, err 58 | } 59 | return proto.Int32(i), err 60 | } 61 | 62 | // Uint64P parses the given string representation of an integer 63 | // and returns a pointer to a uint64 whose value is same as the parsed integer. 64 | func Uint64P(val string) (*uint64, error) { 65 | i, err := Uint64(val) 66 | if err != nil { 67 | return nil, err 68 | } 69 | return proto.Uint64(i), err 70 | } 71 | 72 | // Uint32P parses the given string representation of an integer 73 | // and returns a pointer to a uint32 whose value is same as the parsed integer. 74 | func Uint32P(val string) (*uint32, error) { 75 | i, err := Uint32(val) 76 | if err != nil { 77 | return nil, err 78 | } 79 | return proto.Uint32(i), err 80 | } 81 | -------------------------------------------------------------------------------- /vendor/github.com/grpc-ecosystem/grpc-gateway/utilities/doc.go: -------------------------------------------------------------------------------- 1 | // Package utilities provides members for internal use in grpc-gateway. 2 | package utilities 3 | -------------------------------------------------------------------------------- /vendor/github.com/grpc-ecosystem/grpc-gateway/utilities/pattern.go: -------------------------------------------------------------------------------- 1 | package utilities 2 | 3 | // An OpCode is a opcode of compiled path patterns. 4 | type OpCode int 5 | 6 | // These constants are the valid values of OpCode. 7 | const ( 8 | // OpNop does nothing 9 | OpNop = OpCode(iota) 10 | // OpPush pushes a component to stack 11 | OpPush 12 | // OpLitPush pushes a component to stack if it matches to the literal 13 | OpLitPush 14 | // OpPushM concatenates the remaining components and pushes it to stack 15 | OpPushM 16 | // OpConcatN pops N items from stack, concatenates them and pushes it back to stack 17 | OpConcatN 18 | // OpCapture pops an item and binds it to the variable 19 | OpCapture 20 | // OpEnd is the least postive invalid opcode. 21 | OpEnd 22 | ) 23 | -------------------------------------------------------------------------------- /vendor/github.com/matttproud/golang_protobuf_extensions/NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2012 Matt T. Proud (matt.proud@gmail.com) 2 | -------------------------------------------------------------------------------- /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/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/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/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/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/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_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/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 | // Observer is the interface that wraps the Observe method, which is used by 19 | // Histogram and Summary to add observations. 20 | type Observer interface { 21 | Observe(float64) 22 | } 23 | 24 | // The ObserverFunc type is an adapter to allow the use of ordinary 25 | // functions as Observers. If f is a function with the appropriate 26 | // signature, ObserverFunc(f) is an Observer that calls f. 27 | // 28 | // This adapter is usually used in connection with the Timer type, and there are 29 | // two general use cases: 30 | // 31 | // The most common one is to use a Gauge as the Observer for a Timer. 32 | // See the "Gauge" Timer example. 33 | // 34 | // The more advanced use case is to create a function that dynamically decides 35 | // which Observer to use for observing the duration. See the "Complex" Timer 36 | // example. 37 | type ObserverFunc func(float64) 38 | 39 | // Observe calls f(value). It implements Observer. 40 | func (f ObserverFunc) Observe(value float64) { 41 | f(value) 42 | } 43 | 44 | // Timer is a helper type to time functions. Use NewTimer to create new 45 | // instances. 46 | type Timer struct { 47 | begin time.Time 48 | observer Observer 49 | } 50 | 51 | // NewTimer creates a new Timer. The provided Observer is used to observe a 52 | // duration in seconds. Timer is usually used to time a function call in the 53 | // following way: 54 | // func TimeMe() { 55 | // timer := NewTimer(myHistogram) 56 | // defer timer.ObserveDuration() 57 | // // Do actual work. 58 | // } 59 | func NewTimer(o Observer) *Timer { 60 | return &Timer{ 61 | begin: time.Now(), 62 | observer: o, 63 | } 64 | } 65 | 66 | // ObserveDuration records the duration passed since the Timer was created with 67 | // NewTimer. It calls the Observe method of the Observer provided during 68 | // construction with the duration in seconds as an argument. ObserveDuration is 69 | // usually called with a defer statement. 70 | func (t *Timer) ObserveDuration() { 71 | if t.observer != nil { 72 | t.observer.Observe(time.Since(t.begin).Seconds()) 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /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/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/common/model/metric.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 | "regexp" 19 | "sort" 20 | "strings" 21 | ) 22 | 23 | var ( 24 | separator = []byte{0} 25 | // MetricNameRE is a regular expression matching valid metric 26 | // names. Note that the IsValidMetricName function performs the same 27 | // check but faster than a match with this regular expression. 28 | MetricNameRE = regexp.MustCompile(`^[a-zA-Z_:][a-zA-Z0-9_:]*$`) 29 | ) 30 | 31 | // A Metric is similar to a LabelSet, but the key difference is that a Metric is 32 | // a singleton and refers to one and only one stream of samples. 33 | type Metric LabelSet 34 | 35 | // Equal compares the metrics. 36 | func (m Metric) Equal(o Metric) bool { 37 | return LabelSet(m).Equal(LabelSet(o)) 38 | } 39 | 40 | // Before compares the metrics' underlying label sets. 41 | func (m Metric) Before(o Metric) bool { 42 | return LabelSet(m).Before(LabelSet(o)) 43 | } 44 | 45 | // Clone returns a copy of the Metric. 46 | func (m Metric) Clone() Metric { 47 | clone := make(Metric, len(m)) 48 | for k, v := range m { 49 | clone[k] = v 50 | } 51 | return clone 52 | } 53 | 54 | func (m Metric) String() string { 55 | metricName, hasName := m[MetricNameLabel] 56 | numLabels := len(m) - 1 57 | if !hasName { 58 | numLabels = len(m) 59 | } 60 | labelStrings := make([]string, 0, numLabels) 61 | for label, value := range m { 62 | if label != MetricNameLabel { 63 | labelStrings = append(labelStrings, fmt.Sprintf("%s=%q", label, value)) 64 | } 65 | } 66 | 67 | switch numLabels { 68 | case 0: 69 | if hasName { 70 | return string(metricName) 71 | } 72 | return "{}" 73 | default: 74 | sort.Strings(labelStrings) 75 | return fmt.Sprintf("%s{%s}", metricName, strings.Join(labelStrings, ", ")) 76 | } 77 | } 78 | 79 | // Fingerprint returns a Metric's Fingerprint. 80 | func (m Metric) Fingerprint() Fingerprint { 81 | return LabelSet(m).Fingerprint() 82 | } 83 | 84 | // FastFingerprint returns a Metric's Fingerprint calculated by a faster hashing 85 | // algorithm, which is, however, more susceptible to hash collisions. 86 | func (m Metric) FastFingerprint() Fingerprint { 87 | return LabelSet(m).FastFingerprint() 88 | } 89 | 90 | // IsValidMetricName returns true iff name matches the pattern of MetricNameRE. 91 | // This function, however, does not use MetricNameRE for the check but a much 92 | // faster hardcoded implementation. 93 | func IsValidMetricName(n LabelValue) bool { 94 | if len(n) == 0 { 95 | return false 96 | } 97 | for i, b := range n { 98 | if !((b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || b == '_' || b == ':' || (b >= '0' && b <= '9' && i > 0)) { 99 | return false 100 | } 101 | } 102 | return true 103 | } 104 | -------------------------------------------------------------------------------- /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/prometheus/common/model/silence.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 | import ( 17 | "encoding/json" 18 | "fmt" 19 | "regexp" 20 | "time" 21 | ) 22 | 23 | // Matcher describes a matches the value of a given label. 24 | type Matcher struct { 25 | Name LabelName `json:"name"` 26 | Value string `json:"value"` 27 | IsRegex bool `json:"isRegex"` 28 | } 29 | 30 | func (m *Matcher) UnmarshalJSON(b []byte) error { 31 | type plain Matcher 32 | if err := json.Unmarshal(b, (*plain)(m)); err != nil { 33 | return err 34 | } 35 | 36 | if len(m.Name) == 0 { 37 | return fmt.Errorf("label name in matcher must not be empty") 38 | } 39 | if m.IsRegex { 40 | if _, err := regexp.Compile(m.Value); err != nil { 41 | return err 42 | } 43 | } 44 | return nil 45 | } 46 | 47 | // Validate returns true iff all fields of the matcher have valid values. 48 | func (m *Matcher) Validate() error { 49 | if !m.Name.IsValid() { 50 | return fmt.Errorf("invalid name %q", m.Name) 51 | } 52 | if m.IsRegex { 53 | if _, err := regexp.Compile(m.Value); err != nil { 54 | return fmt.Errorf("invalid regular expression %q", m.Value) 55 | } 56 | } else if !LabelValue(m.Value).IsValid() || len(m.Value) == 0 { 57 | return fmt.Errorf("invalid value %q", m.Value) 58 | } 59 | return nil 60 | } 61 | 62 | // Silence defines the representation of a silence definiton 63 | // in the Prometheus eco-system. 64 | type Silence struct { 65 | ID uint64 `json:"id,omitempty"` 66 | 67 | Matchers []*Matcher `json:"matchers"` 68 | 69 | StartsAt time.Time `json:"startsAt"` 70 | EndsAt time.Time `json:"endsAt"` 71 | 72 | CreatedAt time.Time `json:"createdAt,omitempty"` 73 | CreatedBy string `json:"createdBy"` 74 | Comment string `json:"comment,omitempty"` 75 | } 76 | 77 | // Validate returns true iff all fields of the silence have valid values. 78 | func (s *Silence) Validate() error { 79 | if len(s.Matchers) == 0 { 80 | return fmt.Errorf("at least one matcher required") 81 | } 82 | for _, m := range s.Matchers { 83 | if err := m.Validate(); err != nil { 84 | return fmt.Errorf("invalid matcher: %s", err) 85 | } 86 | } 87 | if s.StartsAt.IsZero() { 88 | return fmt.Errorf("start time missing") 89 | } 90 | if s.EndsAt.IsZero() { 91 | return fmt.Errorf("end time missing") 92 | } 93 | if s.EndsAt.Before(s.StartsAt) { 94 | return fmt.Errorf("start time must be before end time") 95 | } 96 | if s.CreatedBy == "" { 97 | return fmt.Errorf("creator information missing") 98 | } 99 | if s.Comment == "" { 100 | return fmt.Errorf("comment missing") 101 | } 102 | if s.CreatedAt.IsZero() { 103 | return fmt.Errorf("creation timestamp missing") 104 | } 105 | return nil 106 | } 107 | -------------------------------------------------------------------------------- /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/prometheus/procfs/MAINTAINERS.md: -------------------------------------------------------------------------------- 1 | * Tobias Schmidt 2 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/Makefile: -------------------------------------------------------------------------------- 1 | ci: 2 | ! gofmt -l *.go | read nothing 3 | go vet 4 | go test -v ./... 5 | go get github.com/golang/lint/golint 6 | golint *.go 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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/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/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/github.com/prometheus/procfs/stat.go: -------------------------------------------------------------------------------- 1 | package procfs 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "os" 7 | "strconv" 8 | "strings" 9 | ) 10 | 11 | // Stat represents kernel/system statistics. 12 | type Stat struct { 13 | // Boot time in seconds since the Epoch. 14 | BootTime int64 15 | } 16 | 17 | // NewStat returns kernel/system statistics read from /proc/stat. 18 | func NewStat() (Stat, error) { 19 | fs, err := NewFS(DefaultMountPoint) 20 | if err != nil { 21 | return Stat{}, err 22 | } 23 | 24 | return fs.NewStat() 25 | } 26 | 27 | // NewStat returns an information about current kernel/system statistics. 28 | func (fs FS) NewStat() (Stat, error) { 29 | f, err := os.Open(fs.Path("stat")) 30 | if err != nil { 31 | return Stat{}, err 32 | } 33 | defer f.Close() 34 | 35 | s := bufio.NewScanner(f) 36 | for s.Scan() { 37 | line := s.Text() 38 | if !strings.HasPrefix(line, "btime") { 39 | continue 40 | } 41 | fields := strings.Fields(line) 42 | if len(fields) != 2 { 43 | return Stat{}, fmt.Errorf("couldn't parse %s line %s", f.Name(), line) 44 | } 45 | i, err := strconv.ParseInt(fields[1], 10, 32) 46 | if err != nil { 47 | return Stat{}, fmt.Errorf("couldn't parse %s: %s", fields[1], err) 48 | } 49 | return Stat{BootTime: i}, nil 50 | } 51 | if err := s.Err(); err != nil { 52 | return Stat{}, fmt.Errorf("couldn't parse %s: %s", f.Name(), err) 53 | } 54 | 55 | return Stat{}, fmt.Errorf("couldn't parse %s, missing btime", f.Name()) 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/rcrowley/go-metrics/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2012 Richard Crowley. 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 | 1. Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following 12 | disclaimer in the documentation and/or other materials provided 13 | with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY RICHARD CROWLEY ``AS IS'' AND ANY EXPRESS 16 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL RICHARD CROWLEY OR CONTRIBUTORS BE LIABLE 19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 25 | THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | The views and conclusions contained in the software and documentation 28 | are those of the authors and should not be interpreted as representing 29 | official policies, either expressed or implied, of Richard Crowley. 30 | -------------------------------------------------------------------------------- /vendor/github.com/rcrowley/go-metrics/counter.go: -------------------------------------------------------------------------------- 1 | package metrics 2 | 3 | import "sync/atomic" 4 | 5 | // Counters hold an int64 value that can be incremented and decremented. 6 | type Counter interface { 7 | Clear() 8 | Count() int64 9 | Dec(int64) 10 | Inc(int64) 11 | Snapshot() Counter 12 | } 13 | 14 | // GetOrRegisterCounter returns an existing Counter or constructs and registers 15 | // a new StandardCounter. 16 | func GetOrRegisterCounter(name string, r Registry) Counter { 17 | if nil == r { 18 | r = DefaultRegistry 19 | } 20 | return r.GetOrRegister(name, NewCounter).(Counter) 21 | } 22 | 23 | // NewCounter constructs a new StandardCounter. 24 | func NewCounter() Counter { 25 | if UseNilMetrics { 26 | return NilCounter{} 27 | } 28 | return &StandardCounter{0} 29 | } 30 | 31 | // NewRegisteredCounter constructs and registers a new StandardCounter. 32 | func NewRegisteredCounter(name string, r Registry) Counter { 33 | c := NewCounter() 34 | if nil == r { 35 | r = DefaultRegistry 36 | } 37 | r.Register(name, c) 38 | return c 39 | } 40 | 41 | // CounterSnapshot is a read-only copy of another Counter. 42 | type CounterSnapshot int64 43 | 44 | // Clear panics. 45 | func (CounterSnapshot) Clear() { 46 | panic("Clear called on a CounterSnapshot") 47 | } 48 | 49 | // Count returns the count at the time the snapshot was taken. 50 | func (c CounterSnapshot) Count() int64 { return int64(c) } 51 | 52 | // Dec panics. 53 | func (CounterSnapshot) Dec(int64) { 54 | panic("Dec called on a CounterSnapshot") 55 | } 56 | 57 | // Inc panics. 58 | func (CounterSnapshot) Inc(int64) { 59 | panic("Inc called on a CounterSnapshot") 60 | } 61 | 62 | // Snapshot returns the snapshot. 63 | func (c CounterSnapshot) Snapshot() Counter { return c } 64 | 65 | // NilCounter is a no-op Counter. 66 | type NilCounter struct{} 67 | 68 | // Clear is a no-op. 69 | func (NilCounter) Clear() {} 70 | 71 | // Count is a no-op. 72 | func (NilCounter) Count() int64 { return 0 } 73 | 74 | // Dec is a no-op. 75 | func (NilCounter) Dec(i int64) {} 76 | 77 | // Inc is a no-op. 78 | func (NilCounter) Inc(i int64) {} 79 | 80 | // Snapshot is a no-op. 81 | func (NilCounter) Snapshot() Counter { return NilCounter{} } 82 | 83 | // StandardCounter is the standard implementation of a Counter and uses the 84 | // sync/atomic package to manage a single int64 value. 85 | type StandardCounter struct { 86 | count int64 87 | } 88 | 89 | // Clear sets the counter to zero. 90 | func (c *StandardCounter) Clear() { 91 | atomic.StoreInt64(&c.count, 0) 92 | } 93 | 94 | // Count returns the current count. 95 | func (c *StandardCounter) Count() int64 { 96 | return atomic.LoadInt64(&c.count) 97 | } 98 | 99 | // Dec decrements the counter by the given amount. 100 | func (c *StandardCounter) Dec(i int64) { 101 | atomic.AddInt64(&c.count, -i) 102 | } 103 | 104 | // Inc increments the counter by the given amount. 105 | func (c *StandardCounter) Inc(i int64) { 106 | atomic.AddInt64(&c.count, i) 107 | } 108 | 109 | // Snapshot returns a read-only copy of the counter. 110 | func (c *StandardCounter) Snapshot() Counter { 111 | return CounterSnapshot(c.Count()) 112 | } 113 | -------------------------------------------------------------------------------- /vendor/github.com/rcrowley/go-metrics/debug.go: -------------------------------------------------------------------------------- 1 | package metrics 2 | 3 | import ( 4 | "runtime/debug" 5 | "time" 6 | ) 7 | 8 | var ( 9 | debugMetrics struct { 10 | GCStats struct { 11 | LastGC Gauge 12 | NumGC Gauge 13 | Pause Histogram 14 | //PauseQuantiles Histogram 15 | PauseTotal Gauge 16 | } 17 | ReadGCStats Timer 18 | } 19 | gcStats debug.GCStats 20 | ) 21 | 22 | // Capture new values for the Go garbage collector statistics exported in 23 | // debug.GCStats. This is designed to be called as a goroutine. 24 | func CaptureDebugGCStats(r Registry, d time.Duration) { 25 | for _ = range time.Tick(d) { 26 | CaptureDebugGCStatsOnce(r) 27 | } 28 | } 29 | 30 | // Capture new values for the Go garbage collector statistics exported in 31 | // debug.GCStats. This is designed to be called in a background goroutine. 32 | // Giving a registry which has not been given to RegisterDebugGCStats will 33 | // panic. 34 | // 35 | // Be careful (but much less so) with this because debug.ReadGCStats calls 36 | // the C function runtime·lock(runtime·mheap) which, while not a stop-the-world 37 | // operation, isn't something you want to be doing all the time. 38 | func CaptureDebugGCStatsOnce(r Registry) { 39 | lastGC := gcStats.LastGC 40 | t := time.Now() 41 | debug.ReadGCStats(&gcStats) 42 | debugMetrics.ReadGCStats.UpdateSince(t) 43 | 44 | debugMetrics.GCStats.LastGC.Update(int64(gcStats.LastGC.UnixNano())) 45 | debugMetrics.GCStats.NumGC.Update(int64(gcStats.NumGC)) 46 | if lastGC != gcStats.LastGC && 0 < len(gcStats.Pause) { 47 | debugMetrics.GCStats.Pause.Update(int64(gcStats.Pause[0])) 48 | } 49 | //debugMetrics.GCStats.PauseQuantiles.Update(gcStats.PauseQuantiles) 50 | debugMetrics.GCStats.PauseTotal.Update(int64(gcStats.PauseTotal)) 51 | } 52 | 53 | // Register metrics for the Go garbage collector statistics exported in 54 | // debug.GCStats. The metrics are named by their fully-qualified Go symbols, 55 | // i.e. debug.GCStats.PauseTotal. 56 | func RegisterDebugGCStats(r Registry) { 57 | debugMetrics.GCStats.LastGC = NewGauge() 58 | debugMetrics.GCStats.NumGC = NewGauge() 59 | debugMetrics.GCStats.Pause = NewHistogram(NewExpDecaySample(1028, 0.015)) 60 | //debugMetrics.GCStats.PauseQuantiles = NewHistogram(NewExpDecaySample(1028, 0.015)) 61 | debugMetrics.GCStats.PauseTotal = NewGauge() 62 | debugMetrics.ReadGCStats = NewTimer() 63 | 64 | r.Register("debug.GCStats.LastGC", debugMetrics.GCStats.LastGC) 65 | r.Register("debug.GCStats.NumGC", debugMetrics.GCStats.NumGC) 66 | r.Register("debug.GCStats.Pause", debugMetrics.GCStats.Pause) 67 | //r.Register("debug.GCStats.PauseQuantiles", debugMetrics.GCStats.PauseQuantiles) 68 | r.Register("debug.GCStats.PauseTotal", debugMetrics.GCStats.PauseTotal) 69 | r.Register("debug.ReadGCStats", debugMetrics.ReadGCStats) 70 | } 71 | 72 | // Allocate an initial slice for gcStats.Pause to avoid allocations during 73 | // normal operation. 74 | func init() { 75 | gcStats.Pause = make([]time.Duration, 11) 76 | } 77 | -------------------------------------------------------------------------------- /vendor/github.com/rcrowley/go-metrics/ewma.go: -------------------------------------------------------------------------------- 1 | package metrics 2 | 3 | import ( 4 | "math" 5 | "sync" 6 | "sync/atomic" 7 | ) 8 | 9 | // EWMAs continuously calculate an exponentially-weighted moving average 10 | // based on an outside source of clock ticks. 11 | type EWMA interface { 12 | Rate() float64 13 | Snapshot() EWMA 14 | Tick() 15 | Update(int64) 16 | } 17 | 18 | // NewEWMA constructs a new EWMA with the given alpha. 19 | func NewEWMA(alpha float64) EWMA { 20 | if UseNilMetrics { 21 | return NilEWMA{} 22 | } 23 | return &StandardEWMA{alpha: alpha} 24 | } 25 | 26 | // NewEWMA1 constructs a new EWMA for a one-minute moving average. 27 | func NewEWMA1() EWMA { 28 | return NewEWMA(1 - math.Exp(-5.0/60.0/1)) 29 | } 30 | 31 | // NewEWMA5 constructs a new EWMA for a five-minute moving average. 32 | func NewEWMA5() EWMA { 33 | return NewEWMA(1 - math.Exp(-5.0/60.0/5)) 34 | } 35 | 36 | // NewEWMA15 constructs a new EWMA for a fifteen-minute moving average. 37 | func NewEWMA15() EWMA { 38 | return NewEWMA(1 - math.Exp(-5.0/60.0/15)) 39 | } 40 | 41 | // EWMASnapshot is a read-only copy of another EWMA. 42 | type EWMASnapshot float64 43 | 44 | // Rate returns the rate of events per second at the time the snapshot was 45 | // taken. 46 | func (a EWMASnapshot) Rate() float64 { return float64(a) } 47 | 48 | // Snapshot returns the snapshot. 49 | func (a EWMASnapshot) Snapshot() EWMA { return a } 50 | 51 | // Tick panics. 52 | func (EWMASnapshot) Tick() { 53 | panic("Tick called on an EWMASnapshot") 54 | } 55 | 56 | // Update panics. 57 | func (EWMASnapshot) Update(int64) { 58 | panic("Update called on an EWMASnapshot") 59 | } 60 | 61 | // NilEWMA is a no-op EWMA. 62 | type NilEWMA struct{} 63 | 64 | // Rate is a no-op. 65 | func (NilEWMA) Rate() float64 { return 0.0 } 66 | 67 | // Snapshot is a no-op. 68 | func (NilEWMA) Snapshot() EWMA { return NilEWMA{} } 69 | 70 | // Tick is a no-op. 71 | func (NilEWMA) Tick() {} 72 | 73 | // Update is a no-op. 74 | func (NilEWMA) Update(n int64) {} 75 | 76 | // StandardEWMA is the standard implementation of an EWMA and tracks the number 77 | // of uncounted events and processes them on each tick. It uses the 78 | // sync/atomic package to manage uncounted events. 79 | type StandardEWMA struct { 80 | uncounted int64 // /!\ this should be the first member to ensure 64-bit alignment 81 | alpha float64 82 | rate float64 83 | init bool 84 | mutex sync.Mutex 85 | } 86 | 87 | // Rate returns the moving average rate of events per second. 88 | func (a *StandardEWMA) Rate() float64 { 89 | a.mutex.Lock() 90 | defer a.mutex.Unlock() 91 | return a.rate * float64(1e9) 92 | } 93 | 94 | // Snapshot returns a read-only copy of the EWMA. 95 | func (a *StandardEWMA) Snapshot() EWMA { 96 | return EWMASnapshot(a.Rate()) 97 | } 98 | 99 | // Tick ticks the clock to update the moving average. It assumes it is called 100 | // every five seconds. 101 | func (a *StandardEWMA) Tick() { 102 | count := atomic.LoadInt64(&a.uncounted) 103 | atomic.AddInt64(&a.uncounted, -count) 104 | instantRate := float64(count) / float64(5e9) 105 | a.mutex.Lock() 106 | defer a.mutex.Unlock() 107 | if a.init { 108 | a.rate += a.alpha * (instantRate - a.rate) 109 | } else { 110 | a.init = true 111 | a.rate = instantRate 112 | } 113 | } 114 | 115 | // Update adds n uncounted events. 116 | func (a *StandardEWMA) Update(n int64) { 117 | atomic.AddInt64(&a.uncounted, n) 118 | } 119 | -------------------------------------------------------------------------------- /vendor/github.com/rcrowley/go-metrics/gauge.go: -------------------------------------------------------------------------------- 1 | package metrics 2 | 3 | import "sync/atomic" 4 | 5 | // Gauges hold an int64 value that can be set arbitrarily. 6 | type Gauge interface { 7 | Snapshot() Gauge 8 | Update(int64) 9 | Value() int64 10 | } 11 | 12 | // GetOrRegisterGauge returns an existing Gauge or constructs and registers a 13 | // new StandardGauge. 14 | func GetOrRegisterGauge(name string, r Registry) Gauge { 15 | if nil == r { 16 | r = DefaultRegistry 17 | } 18 | return r.GetOrRegister(name, NewGauge).(Gauge) 19 | } 20 | 21 | // NewGauge constructs a new StandardGauge. 22 | func NewGauge() Gauge { 23 | if UseNilMetrics { 24 | return NilGauge{} 25 | } 26 | return &StandardGauge{0} 27 | } 28 | 29 | // NewRegisteredGauge constructs and registers a new StandardGauge. 30 | func NewRegisteredGauge(name string, r Registry) Gauge { 31 | c := NewGauge() 32 | if nil == r { 33 | r = DefaultRegistry 34 | } 35 | r.Register(name, c) 36 | return c 37 | } 38 | 39 | // NewFunctionalGauge constructs a new FunctionalGauge. 40 | func NewFunctionalGauge(f func() int64) Gauge { 41 | if UseNilMetrics { 42 | return NilGauge{} 43 | } 44 | return &FunctionalGauge{value: f} 45 | } 46 | 47 | // NewRegisteredFunctionalGauge constructs and registers a new StandardGauge. 48 | func NewRegisteredFunctionalGauge(name string, r Registry, f func() int64) Gauge { 49 | c := NewFunctionalGauge(f) 50 | if nil == r { 51 | r = DefaultRegistry 52 | } 53 | r.Register(name, c) 54 | return c 55 | } 56 | 57 | // GaugeSnapshot is a read-only copy of another Gauge. 58 | type GaugeSnapshot int64 59 | 60 | // Snapshot returns the snapshot. 61 | func (g GaugeSnapshot) Snapshot() Gauge { return g } 62 | 63 | // Update panics. 64 | func (GaugeSnapshot) Update(int64) { 65 | panic("Update called on a GaugeSnapshot") 66 | } 67 | 68 | // Value returns the value at the time the snapshot was taken. 69 | func (g GaugeSnapshot) Value() int64 { return int64(g) } 70 | 71 | // NilGauge is a no-op Gauge. 72 | type NilGauge struct{} 73 | 74 | // Snapshot is a no-op. 75 | func (NilGauge) Snapshot() Gauge { return NilGauge{} } 76 | 77 | // Update is a no-op. 78 | func (NilGauge) Update(v int64) {} 79 | 80 | // Value is a no-op. 81 | func (NilGauge) Value() int64 { return 0 } 82 | 83 | // StandardGauge is the standard implementation of a Gauge and uses the 84 | // sync/atomic package to manage a single int64 value. 85 | type StandardGauge struct { 86 | value int64 87 | } 88 | 89 | // Snapshot returns a read-only copy of the gauge. 90 | func (g *StandardGauge) Snapshot() Gauge { 91 | return GaugeSnapshot(g.Value()) 92 | } 93 | 94 | // Update updates the gauge's value. 95 | func (g *StandardGauge) Update(v int64) { 96 | atomic.StoreInt64(&g.value, v) 97 | } 98 | 99 | // Value returns the gauge's current value. 100 | func (g *StandardGauge) Value() int64 { 101 | return atomic.LoadInt64(&g.value) 102 | } 103 | 104 | // FunctionalGauge returns value from given function 105 | type FunctionalGauge struct { 106 | value func() int64 107 | } 108 | 109 | // Value returns the gauge's current value. 110 | func (g FunctionalGauge) Value() int64 { 111 | return g.value() 112 | } 113 | 114 | // Snapshot returns the snapshot. 115 | func (g FunctionalGauge) Snapshot() Gauge { return GaugeSnapshot(g.Value()) } 116 | 117 | // Update panics. 118 | func (FunctionalGauge) Update(int64) { 119 | panic("Update called on a FunctionalGauge") 120 | } 121 | -------------------------------------------------------------------------------- /vendor/github.com/rcrowley/go-metrics/healthcheck.go: -------------------------------------------------------------------------------- 1 | package metrics 2 | 3 | // Healthchecks hold an error value describing an arbitrary up/down status. 4 | type Healthcheck interface { 5 | Check() 6 | Error() error 7 | Healthy() 8 | Unhealthy(error) 9 | } 10 | 11 | // NewHealthcheck constructs a new Healthcheck which will use the given 12 | // function to update its status. 13 | func NewHealthcheck(f func(Healthcheck)) Healthcheck { 14 | if UseNilMetrics { 15 | return NilHealthcheck{} 16 | } 17 | return &StandardHealthcheck{nil, f} 18 | } 19 | 20 | // NilHealthcheck is a no-op. 21 | type NilHealthcheck struct{} 22 | 23 | // Check is a no-op. 24 | func (NilHealthcheck) Check() {} 25 | 26 | // Error is a no-op. 27 | func (NilHealthcheck) Error() error { return nil } 28 | 29 | // Healthy is a no-op. 30 | func (NilHealthcheck) Healthy() {} 31 | 32 | // Unhealthy is a no-op. 33 | func (NilHealthcheck) Unhealthy(error) {} 34 | 35 | // StandardHealthcheck is the standard implementation of a Healthcheck and 36 | // stores the status and a function to call to update the status. 37 | type StandardHealthcheck struct { 38 | err error 39 | f func(Healthcheck) 40 | } 41 | 42 | // Check runs the healthcheck function to update the healthcheck's status. 43 | func (h *StandardHealthcheck) Check() { 44 | h.f(h) 45 | } 46 | 47 | // Error returns the healthcheck's status, which will be nil if it is healthy. 48 | func (h *StandardHealthcheck) Error() error { 49 | return h.err 50 | } 51 | 52 | // Healthy marks the healthcheck as healthy. 53 | func (h *StandardHealthcheck) Healthy() { 54 | h.err = nil 55 | } 56 | 57 | // Unhealthy marks the healthcheck as unhealthy. The error is stored and 58 | // may be retrieved by the Error method. 59 | func (h *StandardHealthcheck) Unhealthy(err error) { 60 | h.err = err 61 | } 62 | -------------------------------------------------------------------------------- /vendor/github.com/rcrowley/go-metrics/json.go: -------------------------------------------------------------------------------- 1 | package metrics 2 | 3 | import ( 4 | "encoding/json" 5 | "io" 6 | "time" 7 | ) 8 | 9 | // MarshalJSON returns a byte slice containing a JSON representation of all 10 | // the metrics in the Registry. 11 | func (r *StandardRegistry) MarshalJSON() ([]byte, error) { 12 | data := make(map[string]map[string]interface{}) 13 | r.Each(func(name string, i interface{}) { 14 | values := make(map[string]interface{}) 15 | switch metric := i.(type) { 16 | case Counter: 17 | values["count"] = metric.Count() 18 | case Gauge: 19 | values["value"] = metric.Value() 20 | case GaugeFloat64: 21 | values["value"] = metric.Value() 22 | case Healthcheck: 23 | values["error"] = nil 24 | metric.Check() 25 | if err := metric.Error(); nil != err { 26 | values["error"] = metric.Error().Error() 27 | } 28 | case Histogram: 29 | h := metric.Snapshot() 30 | ps := h.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999}) 31 | values["count"] = h.Count() 32 | values["min"] = h.Min() 33 | values["max"] = h.Max() 34 | values["mean"] = h.Mean() 35 | values["stddev"] = h.StdDev() 36 | values["median"] = ps[0] 37 | values["75%"] = ps[1] 38 | values["95%"] = ps[2] 39 | values["99%"] = ps[3] 40 | values["99.9%"] = ps[4] 41 | case Meter: 42 | m := metric.Snapshot() 43 | values["count"] = m.Count() 44 | values["1m.rate"] = m.Rate1() 45 | values["5m.rate"] = m.Rate5() 46 | values["15m.rate"] = m.Rate15() 47 | values["mean.rate"] = m.RateMean() 48 | case Timer: 49 | t := metric.Snapshot() 50 | ps := t.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999}) 51 | values["count"] = t.Count() 52 | values["min"] = t.Min() 53 | values["max"] = t.Max() 54 | values["mean"] = t.Mean() 55 | values["stddev"] = t.StdDev() 56 | values["median"] = ps[0] 57 | values["75%"] = ps[1] 58 | values["95%"] = ps[2] 59 | values["99%"] = ps[3] 60 | values["99.9%"] = ps[4] 61 | values["1m.rate"] = t.Rate1() 62 | values["5m.rate"] = t.Rate5() 63 | values["15m.rate"] = t.Rate15() 64 | values["mean.rate"] = t.RateMean() 65 | } 66 | data[name] = values 67 | }) 68 | return json.Marshal(data) 69 | } 70 | 71 | // WriteJSON writes metrics from the given registry periodically to the 72 | // specified io.Writer as JSON. 73 | func WriteJSON(r Registry, d time.Duration, w io.Writer) { 74 | for _ = range time.Tick(d) { 75 | WriteJSONOnce(r, w) 76 | } 77 | } 78 | 79 | // WriteJSONOnce writes metrics from the given registry to the specified 80 | // io.Writer as JSON. 81 | func WriteJSONOnce(r Registry, w io.Writer) { 82 | json.NewEncoder(w).Encode(r) 83 | } 84 | 85 | func (p *PrefixedRegistry) MarshalJSON() ([]byte, error) { 86 | return json.Marshal(p.underlying) 87 | } 88 | -------------------------------------------------------------------------------- /vendor/github.com/rcrowley/go-metrics/log.go: -------------------------------------------------------------------------------- 1 | package metrics 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | type Logger interface { 8 | Printf(format string, v ...interface{}) 9 | } 10 | 11 | func Log(r Registry, freq time.Duration, l Logger) { 12 | LogScaled(r, freq, time.Nanosecond, l) 13 | } 14 | 15 | // Output each metric in the given registry periodically using the given 16 | // logger. Print timings in `scale` units (eg time.Millisecond) rather than nanos. 17 | func LogScaled(r Registry, freq time.Duration, scale time.Duration, l Logger) { 18 | du := float64(scale) 19 | duSuffix := scale.String()[1:] 20 | 21 | for _ = range time.Tick(freq) { 22 | r.Each(func(name string, i interface{}) { 23 | switch metric := i.(type) { 24 | case Counter: 25 | l.Printf("counter %s\n", name) 26 | l.Printf(" count: %9d\n", metric.Count()) 27 | case Gauge: 28 | l.Printf("gauge %s\n", name) 29 | l.Printf(" value: %9d\n", metric.Value()) 30 | case GaugeFloat64: 31 | l.Printf("gauge %s\n", name) 32 | l.Printf(" value: %f\n", metric.Value()) 33 | case Healthcheck: 34 | metric.Check() 35 | l.Printf("healthcheck %s\n", name) 36 | l.Printf(" error: %v\n", metric.Error()) 37 | case Histogram: 38 | h := metric.Snapshot() 39 | ps := h.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999}) 40 | l.Printf("histogram %s\n", name) 41 | l.Printf(" count: %9d\n", h.Count()) 42 | l.Printf(" min: %9d\n", h.Min()) 43 | l.Printf(" max: %9d\n", h.Max()) 44 | l.Printf(" mean: %12.2f\n", h.Mean()) 45 | l.Printf(" stddev: %12.2f\n", h.StdDev()) 46 | l.Printf(" median: %12.2f\n", ps[0]) 47 | l.Printf(" 75%%: %12.2f\n", ps[1]) 48 | l.Printf(" 95%%: %12.2f\n", ps[2]) 49 | l.Printf(" 99%%: %12.2f\n", ps[3]) 50 | l.Printf(" 99.9%%: %12.2f\n", ps[4]) 51 | case Meter: 52 | m := metric.Snapshot() 53 | l.Printf("meter %s\n", name) 54 | l.Printf(" count: %9d\n", m.Count()) 55 | l.Printf(" 1-min rate: %12.2f\n", m.Rate1()) 56 | l.Printf(" 5-min rate: %12.2f\n", m.Rate5()) 57 | l.Printf(" 15-min rate: %12.2f\n", m.Rate15()) 58 | l.Printf(" mean rate: %12.2f\n", m.RateMean()) 59 | case Timer: 60 | t := metric.Snapshot() 61 | ps := t.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999}) 62 | l.Printf("timer %s\n", name) 63 | l.Printf(" count: %9d\n", t.Count()) 64 | l.Printf(" min: %12.2f%s\n", float64(t.Min())/du, duSuffix) 65 | l.Printf(" max: %12.2f%s\n", float64(t.Max())/du, duSuffix) 66 | l.Printf(" mean: %12.2f%s\n", t.Mean()/du, duSuffix) 67 | l.Printf(" stddev: %12.2f%s\n", t.StdDev()/du, duSuffix) 68 | l.Printf(" median: %12.2f%s\n", ps[0]/du, duSuffix) 69 | l.Printf(" 75%%: %12.2f%s\n", ps[1]/du, duSuffix) 70 | l.Printf(" 95%%: %12.2f%s\n", ps[2]/du, duSuffix) 71 | l.Printf(" 99%%: %12.2f%s\n", ps[3]/du, duSuffix) 72 | l.Printf(" 99.9%%: %12.2f%s\n", ps[4]/du, duSuffix) 73 | l.Printf(" 1-min rate: %12.2f\n", t.Rate1()) 74 | l.Printf(" 5-min rate: %12.2f\n", t.Rate5()) 75 | l.Printf(" 15-min rate: %12.2f\n", t.Rate15()) 76 | l.Printf(" mean rate: %12.2f\n", t.RateMean()) 77 | } 78 | }) 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /vendor/github.com/rcrowley/go-metrics/metrics.go: -------------------------------------------------------------------------------- 1 | // Go port of Coda Hale's Metrics library 2 | // 3 | // 4 | // 5 | // Coda Hale's original work: 6 | package metrics 7 | 8 | // UseNilMetrics is checked by the constructor functions for all of the 9 | // standard metrics. If it is true, the metric returned is a stub. 10 | // 11 | // This global kill-switch helps quantify the observer effect and makes 12 | // for less cluttered pprof profiles. 13 | var UseNilMetrics bool = false 14 | -------------------------------------------------------------------------------- /vendor/github.com/rcrowley/go-metrics/runtime_cgo.go: -------------------------------------------------------------------------------- 1 | // +build cgo 2 | // +build !appengine 3 | 4 | package metrics 5 | 6 | import "runtime" 7 | 8 | func numCgoCall() int64 { 9 | return runtime.NumCgoCall() 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/rcrowley/go-metrics/runtime_gccpufraction.go: -------------------------------------------------------------------------------- 1 | // +build go1.5 2 | 3 | package metrics 4 | 5 | import "runtime" 6 | 7 | func gcCPUFraction(memStats *runtime.MemStats) float64 { 8 | return memStats.GCCPUFraction 9 | } 10 | -------------------------------------------------------------------------------- /vendor/github.com/rcrowley/go-metrics/runtime_no_cgo.go: -------------------------------------------------------------------------------- 1 | // +build !cgo appengine 2 | 3 | package metrics 4 | 5 | func numCgoCall() int64 { 6 | return 0 7 | } 8 | -------------------------------------------------------------------------------- /vendor/github.com/rcrowley/go-metrics/runtime_no_gccpufraction.go: -------------------------------------------------------------------------------- 1 | // +build !go1.5 2 | 3 | package metrics 4 | 5 | import "runtime" 6 | 7 | func gcCPUFraction(memStats *runtime.MemStats) float64 { 8 | return 0 9 | } 10 | -------------------------------------------------------------------------------- /vendor/github.com/rcrowley/go-metrics/syslog.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package metrics 4 | 5 | import ( 6 | "fmt" 7 | "log/syslog" 8 | "time" 9 | ) 10 | 11 | // Output each metric in the given registry to syslog periodically using 12 | // the given syslogger. 13 | func Syslog(r Registry, d time.Duration, w *syslog.Writer) { 14 | for _ = range time.Tick(d) { 15 | r.Each(func(name string, i interface{}) { 16 | switch metric := i.(type) { 17 | case Counter: 18 | w.Info(fmt.Sprintf("counter %s: count: %d", name, metric.Count())) 19 | case Gauge: 20 | w.Info(fmt.Sprintf("gauge %s: value: %d", name, metric.Value())) 21 | case GaugeFloat64: 22 | w.Info(fmt.Sprintf("gauge %s: value: %f", name, metric.Value())) 23 | case Healthcheck: 24 | metric.Check() 25 | w.Info(fmt.Sprintf("healthcheck %s: error: %v", name, metric.Error())) 26 | case Histogram: 27 | h := metric.Snapshot() 28 | ps := h.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999}) 29 | w.Info(fmt.Sprintf( 30 | "histogram %s: count: %d min: %d max: %d mean: %.2f stddev: %.2f median: %.2f 75%%: %.2f 95%%: %.2f 99%%: %.2f 99.9%%: %.2f", 31 | name, 32 | h.Count(), 33 | h.Min(), 34 | h.Max(), 35 | h.Mean(), 36 | h.StdDev(), 37 | ps[0], 38 | ps[1], 39 | ps[2], 40 | ps[3], 41 | ps[4], 42 | )) 43 | case Meter: 44 | m := metric.Snapshot() 45 | w.Info(fmt.Sprintf( 46 | "meter %s: count: %d 1-min: %.2f 5-min: %.2f 15-min: %.2f mean: %.2f", 47 | name, 48 | m.Count(), 49 | m.Rate1(), 50 | m.Rate5(), 51 | m.Rate15(), 52 | m.RateMean(), 53 | )) 54 | case Timer: 55 | t := metric.Snapshot() 56 | ps := t.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999}) 57 | w.Info(fmt.Sprintf( 58 | "timer %s: count: %d min: %d max: %d mean: %.2f stddev: %.2f median: %.2f 75%%: %.2f 95%%: %.2f 99%%: %.2f 99.9%%: %.2f 1-min: %.2f 5-min: %.2f 15-min: %.2f mean-rate: %.2f", 59 | name, 60 | t.Count(), 61 | t.Min(), 62 | t.Max(), 63 | t.Mean(), 64 | t.StdDev(), 65 | ps[0], 66 | ps[1], 67 | ps[2], 68 | ps[3], 69 | ps[4], 70 | t.Rate1(), 71 | t.Rate5(), 72 | t.Rate15(), 73 | t.RateMean(), 74 | )) 75 | } 76 | }) 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /vendor/github.com/rcrowley/go-metrics/validate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # check there are no formatting issues 6 | GOFMT_LINES=`gofmt -l . | wc -l | xargs` 7 | test $GOFMT_LINES -eq 0 || echo "gofmt needs to be run, ${GOFMT_LINES} files have issues" 8 | 9 | # run the tests for the root package 10 | go test . 11 | -------------------------------------------------------------------------------- /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/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/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/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/golang.org/x/net/http2/Makefile: -------------------------------------------------------------------------------- 1 | curlimage: 2 | docker build -t gohttp2/curl . 3 | 4 | -------------------------------------------------------------------------------- /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/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 | // convering 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/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/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 | "crypto/tls" 11 | "net/http" 12 | "time" 13 | ) 14 | 15 | func transportExpectContinueTimeout(t1 *http.Transport) time.Duration { 16 | return t1.ExpectContinueTimeout 17 | } 18 | 19 | // isBadCipher reports whether the cipher is blacklisted by the HTTP/2 spec. 20 | func isBadCipher(cipher uint16) bool { 21 | switch cipher { 22 | case tls.TLS_RSA_WITH_RC4_128_SHA, 23 | tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA, 24 | tls.TLS_RSA_WITH_AES_128_CBC_SHA, 25 | tls.TLS_RSA_WITH_AES_256_CBC_SHA, 26 | tls.TLS_RSA_WITH_AES_128_GCM_SHA256, 27 | tls.TLS_RSA_WITH_AES_256_GCM_SHA384, 28 | tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, 29 | tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, 30 | tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, 31 | tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA, 32 | tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, 33 | tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, 34 | tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA: 35 | // Reject cipher suites from Appendix A. 36 | // "This list includes those cipher suites that do not 37 | // offer an ephemeral key exchange and those that are 38 | // based on the TLS null, stream or block cipher type" 39 | return true 40 | default: 41 | return false 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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/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 | "crypto/tls" 11 | "net/http" 12 | "time" 13 | ) 14 | 15 | func configureTransport(t1 *http.Transport) (*Transport, error) { 16 | return nil, errTransportVersion 17 | } 18 | 19 | func transportExpectContinueTimeout(t1 *http.Transport) time.Duration { 20 | return 0 21 | 22 | } 23 | 24 | // isBadCipher reports whether the cipher is blacklisted by the HTTP/2 spec. 25 | func isBadCipher(cipher uint16) bool { 26 | switch cipher { 27 | case tls.TLS_RSA_WITH_RC4_128_SHA, 28 | tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA, 29 | tls.TLS_RSA_WITH_AES_128_CBC_SHA, 30 | tls.TLS_RSA_WITH_AES_256_CBC_SHA, 31 | tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, 32 | tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, 33 | tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, 34 | tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA, 35 | tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, 36 | tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, 37 | tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA: 38 | // Reject cipher suites from Appendix A. 39 | // "This list includes those cipher suites that do not 40 | // offer an ephemeral key exchange and those that are 41 | // based on the TLS null, stream or block cipher type" 42 | return true 43 | default: 44 | return false 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/golang.org/x/net/idna/idna.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 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 idna implements IDNA2008 (Internationalized Domain Names for 6 | // Applications), defined in RFC 5890, RFC 5891, RFC 5892, RFC 5893 and 7 | // RFC 5894. 8 | package idna // import "golang.org/x/net/idna" 9 | 10 | import ( 11 | "strings" 12 | "unicode/utf8" 13 | ) 14 | 15 | // TODO(nigeltao): specify when errors occur. For example, is ToASCII(".") or 16 | // ToASCII("foo\x00") an error? See also http://www.unicode.org/faq/idn.html#11 17 | 18 | // acePrefix is the ASCII Compatible Encoding prefix. 19 | const acePrefix = "xn--" 20 | 21 | // ToASCII converts a domain or domain label to its ASCII form. For example, 22 | // ToASCII("bücher.example.com") is "xn--bcher-kva.example.com", and 23 | // ToASCII("golang") is "golang". 24 | func ToASCII(s string) (string, error) { 25 | if ascii(s) { 26 | return s, nil 27 | } 28 | labels := strings.Split(s, ".") 29 | for i, label := range labels { 30 | if !ascii(label) { 31 | a, err := encode(acePrefix, label) 32 | if err != nil { 33 | return "", err 34 | } 35 | labels[i] = a 36 | } 37 | } 38 | return strings.Join(labels, "."), nil 39 | } 40 | 41 | // ToUnicode converts a domain or domain label to its Unicode form. For example, 42 | // ToUnicode("xn--bcher-kva.example.com") is "bücher.example.com", and 43 | // ToUnicode("golang") is "golang". 44 | func ToUnicode(s string) (string, error) { 45 | if !strings.Contains(s, acePrefix) { 46 | return s, nil 47 | } 48 | labels := strings.Split(s, ".") 49 | for i, label := range labels { 50 | if strings.HasPrefix(label, acePrefix) { 51 | u, err := decode(label[len(acePrefix):]) 52 | if err != nil { 53 | return "", err 54 | } 55 | labels[i] = u 56 | } 57 | } 58 | return strings.Join(labels, "."), nil 59 | } 60 | 61 | func ascii(s string) bool { 62 | for i := 0; i < len(s); i++ { 63 | if s[i] >= utf8.RuneSelf { 64 | return false 65 | } 66 | } 67 | return true 68 | } 69 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | We definitely welcome patches and contribution to grpc! Here are some guidelines 4 | and information about how to do so. 5 | 6 | ## Sending patches 7 | 8 | ### Getting started 9 | 10 | 1. Check out the code: 11 | 12 | $ go get google.golang.org/grpc 13 | $ cd $GOPATH/src/google.golang.org/grpc 14 | 15 | 1. Create a fork of the grpc-go repository. 16 | 1. Add your fork as a remote: 17 | 18 | $ git remote add fork git@github.com:$YOURGITHUBUSERNAME/grpc-go.git 19 | 20 | 1. Make changes, commit them. 21 | 1. Run the test suite: 22 | 23 | $ make test 24 | 25 | 1. Push your changes to your fork: 26 | 27 | $ git push fork ... 28 | 29 | 1. Open a pull request. 30 | 31 | ## Legal requirements 32 | 33 | In order to protect both you and ourselves, you will need to sign the 34 | [Contributor License Agreement](https://cla.developers.google.com/clas). 35 | 36 | ## Filing Issues 37 | When filing an issue, make sure to answer these five questions: 38 | 39 | 1. What version of Go are you using (`go version`)? 40 | 2. What operating system and processor architecture are you using? 41 | 3. What did you do? 42 | 4. What did you expect to see? 43 | 5. What did you see instead? 44 | 45 | ### Contributing code 46 | Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file. 47 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2014, Google Inc. 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 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /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/google.golang.org/grpc/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the gRPC 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 gRPC, 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 gRPC. 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 gRPC or any code incorporated within this 19 | implementation of gRPC 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 gRPC 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /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](http://www.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](http://www.grpc.io/docs/) 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.5 or later. 20 | 21 | A note on the version used: significant performance improvements in benchmarks 22 | of grpc-go have been seen by upgrading the go version from 1.5 to the latest 23 | 1.7.1. 24 | 25 | From https://golang.org/doc/install, one way to install the latest version of go is: 26 | ``` 27 | $ GO_VERSION=1.7.1 28 | $ OS=linux 29 | $ ARCH=amd64 30 | $ curl -O https://storage.googleapis.com/golang/go${GO_VERSION}.${OS}-${ARCH}.tar.gz 31 | $ sudo tar -C /usr/local -xzf go$GO_VERSION.$OS-$ARCH.tar.gz 32 | $ # Put go on the PATH, keep the usual installation dir 33 | $ sudo ln -s /usr/local/go/bin/go /usr/bin/go 34 | $ rm go$GO_VERSION.$OS-$ARCH.tar.gz 35 | ``` 36 | 37 | Constraints 38 | ----------- 39 | 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. 40 | 41 | Documentation 42 | ------------- 43 | See [API documentation](https://godoc.org/google.golang.org/grpc) for package and API descriptions and find examples in the [examples directory](examples/). 44 | 45 | Status 46 | ------ 47 | GA 48 | 49 | FAQ 50 | --- 51 | 52 | #### Compiling error, undefined: grpc.SupportPackageIsVersion 53 | 54 | Please update proto package, gRPC package and rebuild the proto files: 55 | - `go get -u github.com/golang/protobuf/{proto,protoc-gen-go}` 56 | - `go get -u google.golang.org/grpc` 57 | - `protoc --go_out=plugins=grpc:. *.proto` 58 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/backoff.go: -------------------------------------------------------------------------------- 1 | package grpc 2 | 3 | import ( 4 | "math/rand" 5 | "time" 6 | ) 7 | 8 | // DefaultBackoffConfig uses values specified for backoff in 9 | // https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md. 10 | var ( 11 | DefaultBackoffConfig = BackoffConfig{ 12 | MaxDelay: 120 * time.Second, 13 | baseDelay: 1.0 * time.Second, 14 | factor: 1.6, 15 | jitter: 0.2, 16 | } 17 | ) 18 | 19 | // backoffStrategy defines the methodology for backing off after a grpc 20 | // connection failure. 21 | // 22 | // This is unexported until the gRPC project decides whether or not to allow 23 | // alternative backoff strategies. Once a decision is made, this type and its 24 | // method may be exported. 25 | type backoffStrategy interface { 26 | // backoff returns the amount of time to wait before the next retry given 27 | // the number of consecutive failures. 28 | backoff(retries int) time.Duration 29 | } 30 | 31 | // BackoffConfig defines the parameters for the default gRPC backoff strategy. 32 | type BackoffConfig struct { 33 | // MaxDelay is the upper bound of backoff delay. 34 | MaxDelay time.Duration 35 | 36 | // TODO(stevvooe): The following fields are not exported, as allowing 37 | // changes would violate the current gRPC specification for backoff. If 38 | // gRPC decides to allow more interesting backoff strategies, these fields 39 | // may be opened up in the future. 40 | 41 | // baseDelay is the amount of time to wait before retrying after the first 42 | // failure. 43 | baseDelay time.Duration 44 | 45 | // factor is applied to the backoff after each retry. 46 | factor float64 47 | 48 | // jitter provides a range to randomize backoff delays. 49 | jitter float64 50 | } 51 | 52 | func setDefaults(bc *BackoffConfig) { 53 | md := bc.MaxDelay 54 | *bc = DefaultBackoffConfig 55 | 56 | if md > 0 { 57 | bc.MaxDelay = md 58 | } 59 | } 60 | 61 | func (bc BackoffConfig) backoff(retries int) time.Duration { 62 | if retries == 0 { 63 | return bc.baseDelay 64 | } 65 | backoff, max := float64(bc.baseDelay), float64(bc.MaxDelay) 66 | for backoff < max && retries > 0 { 67 | backoff *= bc.factor 68 | retries-- 69 | } 70 | if backoff > max { 71 | backoff = max 72 | } 73 | // Randomize backoff delays so that if a cluster of requests start at 74 | // the same time, they won't operate in lockstep. 75 | backoff *= 1 + bc.jitter*(rand.Float64()*2-1) 76 | if backoff < 0 { 77 | return 0 78 | } 79 | return time.Duration(backoff) 80 | } 81 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/credentials/credentials_util_go17.go: -------------------------------------------------------------------------------- 1 | // +build go1.7 2 | // +build !go1.8 3 | 4 | /* 5 | * 6 | * Copyright 2016, Google Inc. 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are 11 | * met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following disclaimer 17 | * in the documentation and/or other materials provided with the 18 | * distribution. 19 | * * Neither the name of Google Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 29 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | package credentials 38 | 39 | import ( 40 | "crypto/tls" 41 | ) 42 | 43 | // cloneTLSConfig returns a shallow clone of the exported 44 | // fields of cfg, ignoring the unexported sync.Once, which 45 | // contains a mutex and must not be copied. 46 | // 47 | // If cfg is nil, a new zero tls.Config is returned. 48 | func cloneTLSConfig(cfg *tls.Config) *tls.Config { 49 | if cfg == nil { 50 | return &tls.Config{} 51 | } 52 | return &tls.Config{ 53 | Rand: cfg.Rand, 54 | Time: cfg.Time, 55 | Certificates: cfg.Certificates, 56 | NameToCertificate: cfg.NameToCertificate, 57 | GetCertificate: cfg.GetCertificate, 58 | RootCAs: cfg.RootCAs, 59 | NextProtos: cfg.NextProtos, 60 | ServerName: cfg.ServerName, 61 | ClientAuth: cfg.ClientAuth, 62 | ClientCAs: cfg.ClientCAs, 63 | InsecureSkipVerify: cfg.InsecureSkipVerify, 64 | CipherSuites: cfg.CipherSuites, 65 | PreferServerCipherSuites: cfg.PreferServerCipherSuites, 66 | SessionTicketsDisabled: cfg.SessionTicketsDisabled, 67 | SessionTicketKey: cfg.SessionTicketKey, 68 | ClientSessionCache: cfg.ClientSessionCache, 69 | MinVersion: cfg.MinVersion, 70 | MaxVersion: cfg.MaxVersion, 71 | CurvePreferences: cfg.CurvePreferences, 72 | DynamicRecordSizingDisabled: cfg.DynamicRecordSizingDisabled, 73 | Renegotiation: cfg.Renegotiation, 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/credentials/credentials_util_go18.go: -------------------------------------------------------------------------------- 1 | // +build go1.8 2 | 3 | /* 4 | * 5 | * Copyright 2017, Google Inc. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are 10 | * met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * * Redistributions in binary form must reproduce the above 15 | * copyright notice, this list of conditions and the following disclaimer 16 | * in the documentation and/or other materials provided with the 17 | * distribution. 18 | * * Neither the name of Google Inc. nor the names of its 19 | * contributors may be used to endorse or promote products derived from 20 | * this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | */ 35 | 36 | package credentials 37 | 38 | import ( 39 | "crypto/tls" 40 | ) 41 | 42 | // cloneTLSConfig returns a shallow clone of the exported 43 | // fields of cfg, ignoring the unexported sync.Once, which 44 | // contains a mutex and must not be copied. 45 | // 46 | // If cfg is nil, a new zero tls.Config is returned. 47 | func cloneTLSConfig(cfg *tls.Config) *tls.Config { 48 | if cfg == nil { 49 | return &tls.Config{} 50 | } 51 | 52 | return cfg.Clone() 53 | } 54 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/credentials/credentials_util_pre_go17.go: -------------------------------------------------------------------------------- 1 | // +build !go1.7 2 | 3 | /* 4 | * 5 | * Copyright 2016, Google Inc. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are 10 | * met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * * Redistributions in binary form must reproduce the above 15 | * copyright notice, this list of conditions and the following disclaimer 16 | * in the documentation and/or other materials provided with the 17 | * distribution. 18 | * * Neither the name of Google Inc. nor the names of its 19 | * contributors may be used to endorse or promote products derived from 20 | * this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | */ 35 | 36 | package credentials 37 | 38 | import ( 39 | "crypto/tls" 40 | ) 41 | 42 | // cloneTLSConfig returns a shallow clone of the exported 43 | // fields of cfg, ignoring the unexported sync.Once, which 44 | // contains a mutex and must not be copied. 45 | // 46 | // If cfg is nil, a new zero tls.Config is returned. 47 | func cloneTLSConfig(cfg *tls.Config) *tls.Config { 48 | if cfg == nil { 49 | return &tls.Config{} 50 | } 51 | return &tls.Config{ 52 | Rand: cfg.Rand, 53 | Time: cfg.Time, 54 | Certificates: cfg.Certificates, 55 | NameToCertificate: cfg.NameToCertificate, 56 | GetCertificate: cfg.GetCertificate, 57 | RootCAs: cfg.RootCAs, 58 | NextProtos: cfg.NextProtos, 59 | ServerName: cfg.ServerName, 60 | ClientAuth: cfg.ClientAuth, 61 | ClientCAs: cfg.ClientCAs, 62 | InsecureSkipVerify: cfg.InsecureSkipVerify, 63 | CipherSuites: cfg.CipherSuites, 64 | PreferServerCipherSuites: cfg.PreferServerCipherSuites, 65 | SessionTicketsDisabled: cfg.SessionTicketsDisabled, 66 | SessionTicketKey: cfg.SessionTicketKey, 67 | ClientSessionCache: cfg.ClientSessionCache, 68 | MinVersion: cfg.MinVersion, 69 | MaxVersion: cfg.MaxVersion, 70 | CurvePreferences: cfg.CurvePreferences, 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package grpc implements an RPC system called gRPC. 3 | 4 | See www.grpc.io for more information about gRPC. 5 | */ 6 | package grpc // import "google.golang.org/grpc" 7 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/internal/internal.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016, Google Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above 12 | * copyright notice, this list of conditions and the following disclaimer 13 | * in the documentation and/or other materials provided with the 14 | * distribution. 15 | * * Neither the name of Google Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | // Package internal contains gRPC-internal code for testing, to avoid polluting 34 | // the godoc of the top-level grpc package. 35 | package internal 36 | 37 | // TestingCloseConns closes all existing transports but keeps 38 | // grpcServer.lis accepting new connections. 39 | // 40 | // The provided grpcServer must be of type *grpc.Server. It is untyped 41 | // for circular dependency reasons. 42 | var TestingCloseConns func(grpcServer interface{}) 43 | 44 | // TestingUseHandlerImpl enables the http.Handler-based server implementation. 45 | // It must be called before Serve and requires TLS credentials. 46 | // 47 | // The provided grpcServer must be of type *grpc.Server. It is untyped 48 | // for circular dependency reasons. 49 | var TestingUseHandlerImpl func(grpcServer interface{}) 50 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/naming/naming.go: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014, Google Inc. 4 | * All rights reserved. 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 | */ 33 | 34 | // Package naming defines the naming API and related data structures for gRPC. 35 | // The interface is EXPERIMENTAL and may be suject to change. 36 | package naming 37 | 38 | // Operation defines the corresponding operations for a name resolution change. 39 | type Operation uint8 40 | 41 | const ( 42 | // Add indicates a new address is added. 43 | Add Operation = iota 44 | // Delete indicates an exisiting address is deleted. 45 | Delete 46 | ) 47 | 48 | // Update defines a name resolution update. Notice that it is not valid having both 49 | // empty string Addr and nil Metadata in an Update. 50 | type Update struct { 51 | // Op indicates the operation of the update. 52 | Op Operation 53 | // Addr is the updated address. It is empty string if there is no address update. 54 | Addr string 55 | // Metadata is the updated metadata. It is nil if there is no metadata update. 56 | // Metadata is not required for a custom naming implementation. 57 | Metadata interface{} 58 | } 59 | 60 | // Resolver creates a Watcher for a target to track its resolution changes. 61 | type Resolver interface { 62 | // Resolve creates a Watcher for target. 63 | Resolve(target string) (Watcher, error) 64 | } 65 | 66 | // Watcher watches for the updates on the specified target. 67 | type Watcher interface { 68 | // Next blocks until an update or error happens. It may return one or more 69 | // updates. The first call should get the full set of the results. It should 70 | // return an error if and only if Watcher cannot recover. 71 | Next() ([]*Update, error) 72 | // Close closes the Watcher. 73 | Close() 74 | } 75 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/peer/peer.go: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014, Google Inc. 4 | * All rights reserved. 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 | */ 33 | 34 | // Package peer defines various peer information associated with RPCs and 35 | // corresponding utils. 36 | package peer 37 | 38 | import ( 39 | "net" 40 | 41 | "golang.org/x/net/context" 42 | "google.golang.org/grpc/credentials" 43 | ) 44 | 45 | // Peer contains the information of the peer for an RPC. 46 | type Peer struct { 47 | // Addr is the peer address. 48 | Addr net.Addr 49 | // AuthInfo is the authentication information of the transport. 50 | // It is nil if there is no transport security being used. 51 | AuthInfo credentials.AuthInfo 52 | } 53 | 54 | type peerKey struct{} 55 | 56 | // NewContext creates a new context with peer information attached. 57 | func NewContext(ctx context.Context, p *Peer) context.Context { 58 | return context.WithValue(ctx, peerKey{}, p) 59 | } 60 | 61 | // FromContext returns the peer information in ctx if it exists. 62 | func FromContext(ctx context.Context) (p *Peer, ok bool) { 63 | p, ok = ctx.Value(peerKey{}).(*Peer) 64 | return 65 | } 66 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/stats/handlers.go: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2016, Google Inc. 4 | * All rights reserved. 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 | */ 33 | 34 | package stats 35 | 36 | import ( 37 | "net" 38 | 39 | "golang.org/x/net/context" 40 | ) 41 | 42 | // ConnTagInfo defines the relevant information needed by connection context tagger. 43 | type ConnTagInfo struct { 44 | // RemoteAddr is the remote address of the corresponding connection. 45 | RemoteAddr net.Addr 46 | // LocalAddr is the local address of the corresponding connection. 47 | LocalAddr net.Addr 48 | // TODO add QOS related fields. 49 | } 50 | 51 | // RPCTagInfo defines the relevant information needed by RPC context tagger. 52 | type RPCTagInfo struct { 53 | // FullMethodName is the RPC method in the format of /package.service/method. 54 | FullMethodName string 55 | } 56 | 57 | // Handler defines the interface for the related stats handling (e.g., RPCs, connections). 58 | type Handler interface { 59 | // TagRPC can attach some information to the given context. 60 | // The returned context is used in the rest lifetime of the RPC. 61 | TagRPC(context.Context, *RPCTagInfo) context.Context 62 | // HandleRPC processes the RPC stats. 63 | HandleRPC(context.Context, RPCStats) 64 | 65 | // TagConn can attach some information to the given context. 66 | // The returned context will be used for stats handling. 67 | // For conn stats handling, the context used in HandleConn for this 68 | // connection will be derived from the context returned. 69 | // For RPC stats handling, 70 | // - On server side, the context used in HandleRPC for all RPCs on this 71 | // connection will be derived from the context returned. 72 | // - On client side, the context is not derived from the context returned. 73 | TagConn(context.Context, *ConnTagInfo) context.Context 74 | // HandleConn processes the Conn stats. 75 | HandleConn(context.Context, ConnStats) 76 | } 77 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/tap/tap.go: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2016, Google Inc. 4 | * All rights reserved. 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 | */ 33 | 34 | // Package tap defines the function handles which are executed on the transport 35 | // layer of gRPC-Go and related information. Everything here is EXPERIMENTAL. 36 | package tap 37 | 38 | import ( 39 | "golang.org/x/net/context" 40 | ) 41 | 42 | // Info defines the relevant information needed by the handles. 43 | type Info struct { 44 | // FullMethodName is the string of grpc method (in the format of 45 | // /package.service/method). 46 | FullMethodName string 47 | // TODO: More to be added. 48 | } 49 | 50 | // ServerInHandle defines the function which runs when a new stream is created 51 | // on the server side. Note that it is executed in the per-connection I/O goroutine(s) instead 52 | // of per-RPC goroutine. Therefore, users should NOT have any blocking/time-consuming 53 | // work in this handle. Otherwise all the RPCs would slow down. 54 | type ServerInHandle func(ctx context.Context, info *Info) (context.Context, error) 55 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/transport/go16.go: -------------------------------------------------------------------------------- 1 | // +build go1.6,!go1.7 2 | 3 | /* 4 | * Copyright 2016, Google Inc. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are 9 | * met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * * Neither the name of Google Inc. nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | */ 34 | 35 | package transport 36 | 37 | import ( 38 | "net" 39 | 40 | "golang.org/x/net/context" 41 | ) 42 | 43 | // dialContext connects to the address on the named network. 44 | func dialContext(ctx context.Context, network, address string) (net.Conn, error) { 45 | return (&net.Dialer{Cancel: ctx.Done()}).Dial(network, address) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/transport/go17.go: -------------------------------------------------------------------------------- 1 | // +build go1.7 2 | 3 | /* 4 | * Copyright 2016, Google Inc. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are 9 | * met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * * Neither the name of Google Inc. nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | */ 34 | 35 | package transport 36 | 37 | import ( 38 | "net" 39 | 40 | "golang.org/x/net/context" 41 | ) 42 | 43 | // dialContext connects to the address on the named network. 44 | func dialContext(ctx context.Context, network, address string) (net.Conn, error) { 45 | return (&net.Dialer{}).DialContext(ctx, network, address) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/google.golang.org/grpc/transport/pre_go16.go: -------------------------------------------------------------------------------- 1 | // +build !go1.6 2 | 3 | /* 4 | * Copyright 2016, Google Inc. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are 9 | * met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * * Neither the name of Google Inc. nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | */ 34 | 35 | package transport 36 | 37 | import ( 38 | "net" 39 | "time" 40 | 41 | "golang.org/x/net/context" 42 | ) 43 | 44 | // dialContext connects to the address on the named network. 45 | func dialContext(ctx context.Context, network, address string) (net.Conn, error) { 46 | var dialer net.Dialer 47 | if deadline, ok := ctx.Deadline(); ok { 48 | dialer.Timeout = deadline.Sub(time.Now()) 49 | } 50 | return dialer.Dial(network, address) 51 | } 52 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2011-2016 Canonical Ltd. 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 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/LICENSE.libyaml: -------------------------------------------------------------------------------- 1 | The following files were ported to Go from C files of libyaml, and thus 2 | are still covered by their original copyright and license: 3 | 4 | apic.go 5 | emitterc.go 6 | parserc.go 7 | readerc.go 8 | scannerc.go 9 | writerc.go 10 | yamlh.go 11 | yamlprivateh.go 12 | 13 | Copyright (c) 2006 Kirill Simonov 14 | 15 | Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | this software and associated documentation files (the "Software"), to deal in 17 | the Software without restriction, including without limitation the rights to 18 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | of the Software, and to permit persons to whom the Software is furnished to do 20 | so, subject to the following conditions: 21 | 22 | The above copyright notice and this permission notice shall be included in all 23 | copies or substantial portions of the Software. 24 | 25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 30 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 | SOFTWARE. 32 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/README.md: -------------------------------------------------------------------------------- 1 | # YAML support for the Go language 2 | 3 | Introduction 4 | ------------ 5 | 6 | The yaml package enables Go programs to comfortably encode and decode YAML 7 | values. It was developed within [Canonical](https://www.canonical.com) as 8 | part of the [juju](https://juju.ubuntu.com) project, and is based on a 9 | pure Go port of the well-known [libyaml](http://pyyaml.org/wiki/LibYAML) 10 | C library to parse and generate YAML data quickly and reliably. 11 | 12 | Compatibility 13 | ------------- 14 | 15 | The yaml package supports most of YAML 1.1 and 1.2, including support for 16 | anchors, tags, map merging, etc. Multi-document unmarshalling is not yet 17 | implemented, and base-60 floats from YAML 1.1 are purposefully not 18 | supported since they're a poor design and are gone in YAML 1.2. 19 | 20 | Installation and usage 21 | ---------------------- 22 | 23 | The import path for the package is *gopkg.in/yaml.v2*. 24 | 25 | To install it, run: 26 | 27 | go get gopkg.in/yaml.v2 28 | 29 | API documentation 30 | ----------------- 31 | 32 | If opened in a browser, the import path itself leads to the API documentation: 33 | 34 | * [https://gopkg.in/yaml.v2](https://gopkg.in/yaml.v2) 35 | 36 | API stability 37 | ------------- 38 | 39 | The package API for yaml v2 will remain stable as described in [gopkg.in](https://gopkg.in). 40 | 41 | 42 | License 43 | ------- 44 | 45 | The yaml package is licensed under the Apache License 2.0. Please see the LICENSE file for details. 46 | 47 | 48 | Example 49 | ------- 50 | 51 | ```Go 52 | package main 53 | 54 | import ( 55 | "fmt" 56 | "log" 57 | 58 | "gopkg.in/yaml.v2" 59 | ) 60 | 61 | var data = ` 62 | a: Easy! 63 | b: 64 | c: 2 65 | d: [3, 4] 66 | ` 67 | 68 | type T struct { 69 | A string 70 | B struct { 71 | RenamedC int `yaml:"c"` 72 | D []int `yaml:",flow"` 73 | } 74 | } 75 | 76 | func main() { 77 | t := T{} 78 | 79 | err := yaml.Unmarshal([]byte(data), &t) 80 | if err != nil { 81 | log.Fatalf("error: %v", err) 82 | } 83 | fmt.Printf("--- t:\n%v\n\n", t) 84 | 85 | d, err := yaml.Marshal(&t) 86 | if err != nil { 87 | log.Fatalf("error: %v", err) 88 | } 89 | fmt.Printf("--- t dump:\n%s\n\n", string(d)) 90 | 91 | m := make(map[interface{}]interface{}) 92 | 93 | err = yaml.Unmarshal([]byte(data), &m) 94 | if err != nil { 95 | log.Fatalf("error: %v", err) 96 | } 97 | fmt.Printf("--- m:\n%v\n\n", m) 98 | 99 | d, err = yaml.Marshal(&m) 100 | if err != nil { 101 | log.Fatalf("error: %v", err) 102 | } 103 | fmt.Printf("--- m dump:\n%s\n\n", string(d)) 104 | } 105 | ``` 106 | 107 | This example will generate the following output: 108 | 109 | ``` 110 | --- t: 111 | {Easy! {2 [3 4]}} 112 | 113 | --- t dump: 114 | a: Easy! 115 | b: 116 | c: 2 117 | d: [3, 4] 118 | 119 | 120 | --- m: 121 | map[a:Easy! b:map[c:2 d:[3 4]]] 122 | 123 | --- m dump: 124 | a: Easy! 125 | b: 126 | c: 2 127 | d: 128 | - 3 129 | - 4 130 | ``` 131 | 132 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/sorter.go: -------------------------------------------------------------------------------- 1 | package yaml 2 | 3 | import ( 4 | "reflect" 5 | "unicode" 6 | ) 7 | 8 | type keyList []reflect.Value 9 | 10 | func (l keyList) Len() int { return len(l) } 11 | func (l keyList) Swap(i, j int) { l[i], l[j] = l[j], l[i] } 12 | func (l keyList) Less(i, j int) bool { 13 | a := l[i] 14 | b := l[j] 15 | ak := a.Kind() 16 | bk := b.Kind() 17 | for (ak == reflect.Interface || ak == reflect.Ptr) && !a.IsNil() { 18 | a = a.Elem() 19 | ak = a.Kind() 20 | } 21 | for (bk == reflect.Interface || bk == reflect.Ptr) && !b.IsNil() { 22 | b = b.Elem() 23 | bk = b.Kind() 24 | } 25 | af, aok := keyFloat(a) 26 | bf, bok := keyFloat(b) 27 | if aok && bok { 28 | if af != bf { 29 | return af < bf 30 | } 31 | if ak != bk { 32 | return ak < bk 33 | } 34 | return numLess(a, b) 35 | } 36 | if ak != reflect.String || bk != reflect.String { 37 | return ak < bk 38 | } 39 | ar, br := []rune(a.String()), []rune(b.String()) 40 | for i := 0; i < len(ar) && i < len(br); i++ { 41 | if ar[i] == br[i] { 42 | continue 43 | } 44 | al := unicode.IsLetter(ar[i]) 45 | bl := unicode.IsLetter(br[i]) 46 | if al && bl { 47 | return ar[i] < br[i] 48 | } 49 | if al || bl { 50 | return bl 51 | } 52 | var ai, bi int 53 | var an, bn int64 54 | for ai = i; ai < len(ar) && unicode.IsDigit(ar[ai]); ai++ { 55 | an = an*10 + int64(ar[ai]-'0') 56 | } 57 | for bi = i; bi < len(br) && unicode.IsDigit(br[bi]); bi++ { 58 | bn = bn*10 + int64(br[bi]-'0') 59 | } 60 | if an != bn { 61 | return an < bn 62 | } 63 | if ai != bi { 64 | return ai < bi 65 | } 66 | return ar[i] < br[i] 67 | } 68 | return len(ar) < len(br) 69 | } 70 | 71 | // keyFloat returns a float value for v if it is a number/bool 72 | // and whether it is a number/bool or not. 73 | func keyFloat(v reflect.Value) (f float64, ok bool) { 74 | switch v.Kind() { 75 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: 76 | return float64(v.Int()), true 77 | case reflect.Float32, reflect.Float64: 78 | return v.Float(), true 79 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: 80 | return float64(v.Uint()), true 81 | case reflect.Bool: 82 | if v.Bool() { 83 | return 1, true 84 | } 85 | return 0, true 86 | } 87 | return 0, false 88 | } 89 | 90 | // numLess returns whether a < b. 91 | // a and b must necessarily have the same kind. 92 | func numLess(a, b reflect.Value) bool { 93 | switch a.Kind() { 94 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: 95 | return a.Int() < b.Int() 96 | case reflect.Float32, reflect.Float64: 97 | return a.Float() < b.Float() 98 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: 99 | return a.Uint() < b.Uint() 100 | case reflect.Bool: 101 | return !a.Bool() && b.Bool() 102 | } 103 | panic("not a number") 104 | } 105 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/writerc.go: -------------------------------------------------------------------------------- 1 | package yaml 2 | 3 | // Set the writer error and return false. 4 | func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool { 5 | emitter.error = yaml_WRITER_ERROR 6 | emitter.problem = problem 7 | return false 8 | } 9 | 10 | // Flush the output buffer. 11 | func yaml_emitter_flush(emitter *yaml_emitter_t) bool { 12 | if emitter.write_handler == nil { 13 | panic("write handler not set") 14 | } 15 | 16 | // Check if the buffer is empty. 17 | if emitter.buffer_pos == 0 { 18 | return true 19 | } 20 | 21 | // If the output encoding is UTF-8, we don't need to recode the buffer. 22 | if emitter.encoding == yaml_UTF8_ENCODING { 23 | if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil { 24 | return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) 25 | } 26 | emitter.buffer_pos = 0 27 | return true 28 | } 29 | 30 | // Recode the buffer into the raw buffer. 31 | var low, high int 32 | if emitter.encoding == yaml_UTF16LE_ENCODING { 33 | low, high = 0, 1 34 | } else { 35 | high, low = 1, 0 36 | } 37 | 38 | pos := 0 39 | for pos < emitter.buffer_pos { 40 | // See the "reader.c" code for more details on UTF-8 encoding. Note 41 | // that we assume that the buffer contains a valid UTF-8 sequence. 42 | 43 | // Read the next UTF-8 character. 44 | octet := emitter.buffer[pos] 45 | 46 | var w int 47 | var value rune 48 | switch { 49 | case octet&0x80 == 0x00: 50 | w, value = 1, rune(octet&0x7F) 51 | case octet&0xE0 == 0xC0: 52 | w, value = 2, rune(octet&0x1F) 53 | case octet&0xF0 == 0xE0: 54 | w, value = 3, rune(octet&0x0F) 55 | case octet&0xF8 == 0xF0: 56 | w, value = 4, rune(octet&0x07) 57 | } 58 | for k := 1; k < w; k++ { 59 | octet = emitter.buffer[pos+k] 60 | value = (value << 6) + (rune(octet) & 0x3F) 61 | } 62 | pos += w 63 | 64 | // Write the character. 65 | if value < 0x10000 { 66 | var b [2]byte 67 | b[high] = byte(value >> 8) 68 | b[low] = byte(value & 0xFF) 69 | emitter.raw_buffer = append(emitter.raw_buffer, b[0], b[1]) 70 | } else { 71 | // Write the character using a surrogate pair (check "reader.c"). 72 | var b [4]byte 73 | value -= 0x10000 74 | b[high] = byte(0xD8 + (value >> 18)) 75 | b[low] = byte((value >> 10) & 0xFF) 76 | b[high+2] = byte(0xDC + ((value >> 8) & 0xFF)) 77 | b[low+2] = byte(value & 0xFF) 78 | emitter.raw_buffer = append(emitter.raw_buffer, b[0], b[1], b[2], b[3]) 79 | } 80 | } 81 | 82 | // Write the raw buffer. 83 | if err := emitter.write_handler(emitter, emitter.raw_buffer); err != nil { 84 | return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) 85 | } 86 | emitter.buffer_pos = 0 87 | emitter.raw_buffer = emitter.raw_buffer[:0] 88 | return true 89 | } 90 | --------------------------------------------------------------------------------