├── vendor ├── github.com │ ├── mkevac │ │ ├── gopinba │ │ │ ├── .travis.yml │ │ │ ├── Pinba │ │ │ │ ├── Makefile │ │ │ │ └── pinba.proto │ │ │ ├── monotime_go19.go │ │ │ ├── monotime_goold.go │ │ │ ├── README.md │ │ │ ├── .gitignore │ │ │ └── LICENSE │ │ └── monotime │ │ │ ├── issue15006.s │ │ │ └── monotime.go │ ├── prometheus │ │ ├── procfs │ │ │ ├── .gitignore │ │ │ ├── go.mod │ │ │ ├── MAINTAINERS.md │ │ │ ├── NOTICE │ │ │ ├── README.md │ │ │ ├── CONTRIBUTING.md │ │ │ ├── Makefile │ │ │ ├── doc.go │ │ │ ├── internal │ │ │ │ └── util │ │ │ │ │ ├── sysreadfile_linux.go │ │ │ │ │ └── parse.go │ │ │ ├── proc_io.go │ │ │ ├── nfs │ │ │ │ ├── parse_nfs.go │ │ │ │ └── parse_nfsd.go │ │ │ ├── proc_ns.go │ │ │ ├── fs.go │ │ │ └── buddyinfo.go │ │ ├── client_golang │ │ │ ├── prometheus │ │ │ │ ├── .gitignore │ │ │ │ ├── README.md │ │ │ │ ├── promhttp │ │ │ │ │ └── delegator_pre_1_8.go │ │ │ │ ├── fnv.go │ │ │ │ ├── untyped.go │ │ │ │ ├── timer.go │ │ │ │ ├── observer.go │ │ │ │ ├── labels.go │ │ │ │ └── internal │ │ │ │ │ └── metric.go │ │ │ └── NOTICE │ │ ├── client_model │ │ │ └── NOTICE │ │ └── common │ │ │ ├── NOTICE │ │ │ ├── model │ │ │ ├── model.go │ │ │ ├── fnv.go │ │ │ ├── fingerprinting.go │ │ │ ├── silence.go │ │ │ └── metric.go │ │ │ ├── expfmt │ │ │ ├── fuzz.go │ │ │ ├── expfmt.go │ │ │ └── encode.go │ │ │ └── internal │ │ │ └── bitbucket.org │ │ │ └── ww │ │ │ └── goautoneg │ │ │ └── README.txt │ ├── matttproud │ │ └── golang_protobuf_extensions │ │ │ ├── pbutil │ │ │ ├── .gitignore │ │ │ ├── Makefile │ │ │ ├── doc.go │ │ │ ├── encode.go │ │ │ └── decode.go │ │ │ └── NOTICE │ ├── cloudflare │ │ └── golz4 │ │ │ ├── README.md │ │ │ ├── doc.go │ │ │ ├── Makefile │ │ │ ├── .gitignore │ │ │ ├── lz4_hc.go │ │ │ ├── LICENSE │ │ │ └── lz4.go │ ├── kshvakov │ │ └── clickhouse │ │ │ ├── lib │ │ │ ├── protocol │ │ │ │ ├── README.md │ │ │ │ └── protocol.go │ │ │ ├── cityhash102 │ │ │ │ ├── doc.go │ │ │ │ └── city64.go │ │ │ ├── lz4 │ │ │ │ ├── doc.go │ │ │ │ ├── fuzz.go │ │ │ │ └── LICENSE │ │ │ ├── leakypool │ │ │ │ └── leaky_pool.go │ │ │ ├── binary │ │ │ │ ├── compress_settings.go │ │ │ │ ├── compress_writer_clz4.go │ │ │ │ ├── compress_writer.go │ │ │ │ ├── compress_reader_clz4.go │ │ │ │ └── compress_reader.go │ │ │ ├── column │ │ │ │ ├── string.go │ │ │ │ ├── float32.go │ │ │ │ ├── float64.go │ │ │ │ ├── int16.go │ │ │ │ ├── int32.go │ │ │ │ ├── int64.go │ │ │ │ ├── uint16.go │ │ │ │ ├── uint32.go │ │ │ │ ├── uint8.go │ │ │ │ ├── uint64.go │ │ │ │ ├── int8.go │ │ │ │ ├── common.go │ │ │ │ ├── ip.go │ │ │ │ ├── fixed_string.go │ │ │ │ ├── datetime.go │ │ │ │ ├── date.go │ │ │ │ ├── nullable.go │ │ │ │ └── array.go │ │ │ ├── data │ │ │ │ ├── client_info.go │ │ │ │ ├── server_info.go │ │ │ │ └── block_write_column.go │ │ │ ├── types │ │ │ │ ├── date.go │ │ │ │ └── uuid.go │ │ │ └── writebuffer │ │ │ │ └── buffer.go │ │ │ ├── Makefile │ │ │ ├── CONTRIBUTING.md │ │ │ ├── docker-compose.yml │ │ │ ├── result.go │ │ │ ├── go.test.sh │ │ │ ├── array.go │ │ │ ├── .gitignore │ │ │ ├── clickhouse_read_block.go │ │ │ ├── clickhouse_progress.go │ │ │ ├── .travis.yml │ │ │ ├── clickhouse_ping.go │ │ │ ├── word_matcher.go │ │ │ ├── clickhouse_profile_info.go │ │ │ ├── clickhouse_exception.go │ │ │ ├── LICENSE │ │ │ ├── write_column.go │ │ │ ├── clickhouse_send_query.go │ │ │ ├── clickhouse_write_block.go │ │ │ ├── clickhouse_read_meta.go │ │ │ └── helpers.go │ ├── golang │ │ └── protobuf │ │ │ ├── AUTHORS │ │ │ ├── CONTRIBUTORS │ │ │ ├── LICENSE │ │ │ └── proto │ │ │ └── deprecated.go │ ├── gogo │ │ └── protobuf │ │ │ ├── AUTHORS │ │ │ ├── CONTRIBUTORS │ │ │ ├── gogoproto │ │ │ ├── gogo.pb.golden │ │ │ └── Makefile │ │ │ ├── proto │ │ │ ├── encode_gogo.go │ │ │ ├── properties_gogo.go │ │ │ ├── custom_gogo.go │ │ │ ├── Makefile │ │ │ ├── lib_gogo.go │ │ │ ├── duration_gogo.go │ │ │ ├── timestamp_gogo.go │ │ │ ├── text_gogo.go │ │ │ ├── pointer_unsafe_gogo.go │ │ │ ├── pointer_reflect_gogo.go │ │ │ └── deprecated.go │ │ │ ├── LICENSE │ │ │ └── protoc-gen-gogo │ │ │ └── descriptor │ │ │ └── Makefile │ └── beorn7 │ │ └── perks │ │ └── LICENSE └── modules.txt ├── package ├── etc │ └── proton-server │ │ └── options ├── scripts │ ├── postinstall.sh │ └── preremove.sh └── systemd │ └── proton-server.service ├── assets └── grafana-basic-reports.png ├── .gitignore ├── src └── server │ ├── types_test.go │ ├── func.go │ ├── server_dictionary.go │ ├── server_requests.go │ └── types.go ├── go.mod ├── Makefile ├── nfpm.yaml ├── examples └── clickhouse-server │ └── proton_dictionary.xml ├── LICENSE ├── proto └── pinba │ └── request.proto ├── schema └── schema.sql ├── cmd ├── proton-server │ └── main.go └── test.go └── README.md /vendor/github.com/mkevac/gopinba/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/.gitignore: -------------------------------------------------------------------------------- 1 | /fixtures/ 2 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/prometheus/procfs 2 | -------------------------------------------------------------------------------- /vendor/github.com/matttproud/golang_protobuf_extensions/pbutil/.gitignore: -------------------------------------------------------------------------------- 1 | cover.dat 2 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/MAINTAINERS.md: -------------------------------------------------------------------------------- 1 | * Tobias Schmidt 2 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_golang/prometheus/.gitignore: -------------------------------------------------------------------------------- 1 | command-line-arguments.test 2 | -------------------------------------------------------------------------------- /vendor/github.com/cloudflare/golz4/README.md: -------------------------------------------------------------------------------- 1 | golz4 2 | ===== 3 | 4 | Golang interface to LZ4 compression 5 | -------------------------------------------------------------------------------- /package/etc/proton-server/options: -------------------------------------------------------------------------------- 1 | OPTIONS="-addr=:30002 -dsn=native://127.0.0.1:9000 -backlog=10000 -concurrency=2" -------------------------------------------------------------------------------- /vendor/github.com/matttproud/golang_protobuf_extensions/NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2012 Matt T. Proud (matt.proud@gmail.com) 2 | -------------------------------------------------------------------------------- /assets/grafana-basic-reports.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClickHouse-Ninja/Proton/HEAD/assets/grafana-basic-reports.png -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/protocol/README.md: -------------------------------------------------------------------------------- 1 | # ClickHouse Native protocol 2 | 3 | # Handshake 4 | 5 | -------------------------------------------------------------------------------- /vendor/github.com/cloudflare/golz4/doc.go: -------------------------------------------------------------------------------- 1 | // Package lz4 implements compression using lz4.c and lz4hc.c 2 | // 3 | // Copyright (c) 2013 CloudFlare, Inc. 4 | package lz4 5 | -------------------------------------------------------------------------------- /package/scripts/postinstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | if [ "$1" = configure ]; then 5 | /bin/systemctl daemon-reload 6 | /bin/systemctl enable proton-server 7 | fi -------------------------------------------------------------------------------- /vendor/github.com/mkevac/gopinba/Pinba/Makefile: -------------------------------------------------------------------------------- 1 | regenerate: 2 | (protoc --proto_path=${GOPATH}/src:${GOPATH}/src/github.com/gogo/protobuf/protobuf:. --gogo_out=. pinba.proto) 3 | -------------------------------------------------------------------------------- /vendor/github.com/mkevac/gopinba/monotime_go19.go: -------------------------------------------------------------------------------- 1 | // +build go1.9 2 | 3 | package gopinba 4 | 5 | import "time" 6 | 7 | func now() time.Time { 8 | return time.Now() 9 | } 10 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /package/scripts/preremove.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | if [ "$1" = remove ]; then 4 | /bin/systemctl stop proton-server 5 | /bin/systemctl disable proton-server 6 | /bin/systemctl daemon-reload 7 | fi -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/Makefile: -------------------------------------------------------------------------------- 1 | test: 2 | go install -race -v 3 | go test -i -v 4 | go test -race -v . 5 | 6 | coverage: 7 | go test -coverprofile=coverage.out -v . 8 | go tool cover -html=coverage.out 9 | -------------------------------------------------------------------------------- /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/kshvakov/clickhouse/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing notes 2 | 3 | ## Local setup 4 | 5 | The easiest way to run tests is to use Docker Compose: 6 | 7 | ``` 8 | docker-compose up 9 | make 10 | ``` 11 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/cityhash102/doc.go: -------------------------------------------------------------------------------- 1 | /** COPY from https://github.com/zentures/cityhash/ 2 | 3 | NOTE: The code is modified to be compatible with CityHash128 used in ClickHouse 4 | */ 5 | package cityhash102 6 | -------------------------------------------------------------------------------- /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/mkevac/gopinba/monotime_goold.go: -------------------------------------------------------------------------------- 1 | // +build !go1.9 2 | 3 | package gopinba 4 | 5 | import ( 6 | "github.com/mkevac/monotime" 7 | "time" 8 | ) 9 | 10 | func now() time.Time { 11 | return monotime.Now() 12 | } 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | 8 | # Test binary, build with `go test -c` 9 | *.test 10 | 11 | # Output of the go coverage tool, specifically when used with LiteIDE 12 | *.out 13 | 14 | .build/* -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/docker-compose.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: '3' 3 | services: 4 | clickhouse: 5 | image: yandex/clickhouse-server 6 | ports: 7 | - 127.0.0.1:8123:8123 8 | - 127.0.0.1:9000:9000 9 | - 127.0.0.1:9009:9009 10 | -------------------------------------------------------------------------------- /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/mkevac/gopinba/README.md: -------------------------------------------------------------------------------- 1 | gopinba [![Build Status](https://travis-ci.org/mkevac/gopinba.svg?branch=master)](https://travis-ci.org/mkevac/gopinba) 2 | ======= 3 | 4 | Pinba (http://pinba.org) Go client. 5 | 6 | Documentation can be found [here](https://godoc.org/github.com/mkevac/gopinba). 7 | -------------------------------------------------------------------------------- /vendor/github.com/mkevac/monotime/issue15006.s: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 Arista Networks, Inc. 2 | // Use of this source code is governed by the Apache License 2.0 3 | // that can be found in the COPYING file. 4 | 5 | // This file is intentionally empty. 6 | // It's a workaround for https://github.com/golang/go/issues/15006 7 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/lz4/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011-2012 Branimir Karadzic. All rights reserved. 2 | // Copyright 2013 Damian Gryski. All rights reserved. 3 | 4 | // @LINK: https://github.com/bkaradzic/go-lz4 5 | // @NOTE: The code is modified to be high performance and less memory usage 6 | 7 | package lz4 8 | -------------------------------------------------------------------------------- /vendor/github.com/cloudflare/golz4/Makefile: -------------------------------------------------------------------------------- 1 | GCFLAGS := 2 | LDFLAGS := 3 | 4 | .PHONY: install 5 | install: 6 | @go install -v . 7 | 8 | .PHONY: test 9 | test: 10 | @go test -gcflags='$(GCFLAGS)' -ldflags='$(LDFLAGS)' . 11 | 12 | .PHONY: bench 13 | bench: 14 | @go test -gcflags='$(GCFLAGS)' -ldflags='$(LDFLAGS)' -bench . 15 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/result.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | import "errors" 4 | 5 | type result struct{} 6 | 7 | func (*result) LastInsertId() (int64, error) { return 0, errors.New("LastInsertId is not supported") } 8 | func (*result) RowsAffected() (int64, error) { return 0, errors.New("RowsAffected is not supported") } 9 | -------------------------------------------------------------------------------- /src/server/types_test.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "sort" 5 | "testing" 6 | ) 7 | 8 | func TestTagSort(t *testing.T) { 9 | name, value := []string{"b name", "c name", "a name"}, []string{"b value", "c value", "a value"} 10 | sort.Sort(&tagSort{ 11 | name: name, 12 | value: value, 13 | }) 14 | t.Log(name, value) 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/go.test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | echo "" > coverage.txt 5 | 6 | for d in $(go list ./... | grep -v vendor | grep -v examples); do 7 | go test -race -coverprofile=profile.out -covermode=atomic $d 8 | if [ -f profile.out ]; then 9 | cat profile.out >> coverage.txt 10 | rm profile.out 11 | fi 12 | done -------------------------------------------------------------------------------- /vendor/github.com/cloudflare/golz4/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | -------------------------------------------------------------------------------- /vendor/github.com/mkevac/gopinba/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/array.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | func Array(v interface{}) interface{} { 8 | return v 9 | } 10 | 11 | func ArrayFixedString(len int, v interface{}) interface{} { 12 | return v 13 | } 14 | 15 | func ArrayDate(v []time.Time) interface{} { 16 | return v 17 | } 18 | 19 | func ArrayDateTime(v []time.Time) interface{} { 20 | return v 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/lz4/fuzz.go: -------------------------------------------------------------------------------- 1 | // +build gofuzz 2 | 3 | package lz4 4 | 5 | import "encoding/binary" 6 | 7 | func Fuzz(data []byte) int { 8 | 9 | if len(data) < 4 { 10 | return 0 11 | } 12 | 13 | ln := binary.LittleEndian.Uint32(data) 14 | if ln > (1 << 21) { 15 | return 0 16 | } 17 | 18 | if _, err := Decode(nil, data); err != nil { 19 | return 0 20 | } 21 | 22 | return 1 23 | } 24 | -------------------------------------------------------------------------------- /package/systemd/proton-server.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Proton - high performance Pinba storage server. 3 | Wants=network-online.target 4 | After=network-online.target 5 | 6 | [Service] 7 | Type=simple 8 | 9 | EnvironmentFile=/etc/proton-server/options 10 | ExecStart=/usr/bin/proton-server $OPTIONS 11 | 12 | Restart=always 13 | RestartSec=10 14 | 15 | MemoryLimit=200M 16 | MemoryAccounting=true 17 | 18 | [Install] 19 | WantedBy=multi-user.target -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.out 23 | *.exe 24 | *.test 25 | *.prof 26 | 27 | coverage.txt 28 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/leakypool/leaky_pool.go: -------------------------------------------------------------------------------- 1 | package leakypool 2 | 3 | var pool chan []byte 4 | 5 | func InitBytePool(size int) { 6 | pool = make(chan []byte, size) 7 | } 8 | 9 | func GetBytes(size, capacity int) (b []byte) { 10 | select { 11 | case b = <-pool: 12 | default: 13 | b = make([]byte, size, capacity) 14 | } 15 | return 16 | } 17 | 18 | func PutBytes(b []byte) { 19 | select { 20 | case pool <- b: 21 | default: 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/clickhouse_read_block.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | import ( 4 | "github.com/kshvakov/clickhouse/lib/data" 5 | ) 6 | 7 | func (ch *clickhouse) readBlock() (*data.Block, error) { 8 | if _, err := ch.decoder.String(); err != nil { // temporary table 9 | return nil, err 10 | } 11 | 12 | ch.decoder.SelectCompress(ch.compress) 13 | var block data.Block 14 | if err := block.Read(&ch.ServerInfo, ch.decoder); err != nil { 15 | return nil, err 16 | } 17 | ch.decoder.SelectCompress(false) 18 | return &block, nil 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/binary/compress_settings.go: -------------------------------------------------------------------------------- 1 | package binary 2 | 3 | type CompressionMethodByte byte 4 | 5 | const ( 6 | NONE CompressionMethodByte = 0x02 7 | LZ4 = 0x82 8 | ZSTD = 0x90 9 | ) 10 | 11 | const ( 12 | // ChecksumSize is 128bits for cityhash102 checksum 13 | ChecksumSize = 16 14 | // CompressHeader magic + compressed_size + uncompressed_size 15 | CompressHeaderSize = 1 + 4 + 4 16 | 17 | // HeaderSize 18 | HeaderSize = ChecksumSize + CompressHeaderSize 19 | // BlockMaxSize 1MB 20 | BlockMaxSize = 1 << 10 21 | ) 22 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/clickhouse_progress.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | type progress struct { 4 | rows uint64 5 | bytes uint64 6 | totalRows uint64 7 | } 8 | 9 | func (ch *clickhouse) progress() (*progress, error) { 10 | var ( 11 | p progress 12 | err error 13 | ) 14 | if p.rows, err = ch.decoder.Uvarint(); err != nil { 15 | return nil, err 16 | } 17 | if p.bytes, err = ch.decoder.Uvarint(); err != nil { 18 | return nil, err 19 | } 20 | 21 | if p.totalRows, err = ch.decoder.Uvarint(); err != nil { 22 | return nil, err 23 | } 24 | 25 | return &p, nil 26 | } 27 | -------------------------------------------------------------------------------- /src/server/func.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "sync/atomic" 5 | "time" 6 | 7 | "github.com/kshvakov/clickhouse/lib/cityhash102" 8 | ) 9 | 10 | var timestamp = uint32(time.Now().Unix()) 11 | 12 | func init() { 13 | go func() { 14 | for tick := time.Tick(time.Second); ; { 15 | select { 16 | case t := <-tick: 17 | atomic.StoreUint32(×tamp, uint32(t.Unix())) 18 | } 19 | } 20 | }() 21 | } 22 | 23 | func now() uint32 { 24 | return atomic.LoadUint32(×tamp) 25 | } 26 | 27 | func cityHash64(str string) uint64 { 28 | cityhash := cityhash102.New64() 29 | cityhash.Write([]byte(str)) 30 | return cityhash.Sum64() 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of GoGo authors for copyright purposes. 2 | # This file is distinct from the CONTRIBUTORS file, which 3 | # lists people. For example, employees are listed in CONTRIBUTORS, 4 | # but not in AUTHORS, because the employer holds the copyright. 5 | 6 | # Names should be added to this file as one of 7 | # Organization's name 8 | # Individual's name 9 | # Individual's name 10 | 11 | # Please keep the list sorted. 12 | 13 | Sendgrid, Inc 14 | Vastech SA (PTY) LTD 15 | Walter Schulze 16 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/ClickHouse-Ninja/Proton 2 | 3 | go 1.12 4 | 5 | require ( 6 | github.com/bkaradzic/go-lz4 v1.0.0 // indirect 7 | github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 // indirect 8 | github.com/gogo/protobuf v1.2.1 // indirect 9 | github.com/golang/protobuf v1.3.1 10 | github.com/kshvakov/clickhouse v1.3.6 11 | github.com/mkevac/gopinba v0.0.0-20171206104754-471ad6b3e951 12 | github.com/mkevac/monotime v0.0.0-20161125163931-92ece95d55b6 // indirect 13 | github.com/pierrec/lz4 v2.0.5+incompatible // indirect 14 | github.com/prometheus/client_golang v0.9.2 15 | github.com/stretchr/testify v1.3.0 // indirect 16 | ) 17 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | GIT_BRANCH=$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null) 2 | GIT_COMMIT=$(shell git rev-parse --short HEAD) 3 | LDFLAGS=-ldflags "-s -w -X main.GitBranch=${GIT_BRANCH} -X main.GitCommit=${GIT_COMMIT} -X main.BuildDate=`date -u +%Y-%m-%d.%H:%M:%S`" 4 | 5 | proto: 6 | @echo "Make Pinba proto" 7 | @protoc --gofast_out=. proto/pinba/*.proto 8 | 9 | build: 10 | @[ -d .build ] || mkdir -p .build 11 | CGO_ENABLED=0 go build ${LDFLAGS} -o .build/proton-server cmd/proton-server/main.go 12 | @file .build/proton-server 13 | @du -h .build/proton-server 14 | 15 | deb: build 16 | @nfpm pkg --target .build/proton-server.deb 17 | @dpkg-deb -I .build/proton-server.deb 18 | 19 | .PHONY: proto -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | language: go 3 | go: 4 | - 1.10.x 5 | - 1.11.x 6 | - master 7 | go_import_path: github.com/kshvakov/clickhouse 8 | services: 9 | - docker 10 | install: 11 | - go get github.com/mattn/goveralls 12 | - go get golang.org/x/tools/cmd/cover 13 | - go get github.com/stretchr/testify/assert 14 | - go get github.com/cloudflare/golz4 15 | - go get github.com/bkaradzic/go-lz4 16 | - go get github.com/pierrec/lz4 17 | 18 | before_install: 19 | - docker --version 20 | - docker-compose --version 21 | - docker-compose up -d 22 | script: 23 | - ./go.test.sh 24 | after_success: 25 | - bash <(curl -s https://codecov.io/bash) 26 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/clickhouse_ping.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | import ( 4 | "context" 5 | "database/sql/driver" 6 | 7 | "github.com/kshvakov/clickhouse/lib/protocol" 8 | ) 9 | 10 | func (ch *clickhouse) Ping(ctx context.Context) error { 11 | return ch.ping(ctx) 12 | } 13 | 14 | func (ch *clickhouse) ping(ctx context.Context) error { 15 | if ch.conn.closed { 16 | return driver.ErrBadConn 17 | } 18 | ch.logf("-> ping") 19 | finish := ch.watchCancel(ctx) 20 | defer finish() 21 | if err := ch.encoder.Uvarint(protocol.ClientPing); err != nil { 22 | return err 23 | } 24 | if err := ch.encoder.Flush(); err != nil { 25 | return err 26 | } 27 | return ch.process() 28 | } 29 | -------------------------------------------------------------------------------- /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/kshvakov/clickhouse/lib/protocol/protocol.go: -------------------------------------------------------------------------------- 1 | package protocol 2 | 3 | const ( 4 | DBMS_MIN_REVISION_WITH_SERVER_TIMEZONE = 54058 5 | DBMS_MIN_REVISION_WITH_QUOTA_KEY_IN_CLIENT_INFO = 54060 6 | ) 7 | 8 | const ( 9 | ClientHello = 0 10 | ClientQuery = 1 11 | ClientData = 2 12 | ClientCancel = 3 13 | ClientPing = 4 14 | ) 15 | 16 | const ( 17 | CompressEnable uint64 = 1 18 | CompressDisable uint64 = 0 19 | ) 20 | 21 | const ( 22 | StateComplete = 2 23 | ) 24 | 25 | const ( 26 | ServerHello = 0 27 | ServerData = 1 28 | ServerException = 2 29 | ServerProgress = 3 30 | ServerPong = 4 31 | ServerEndOfStream = 5 32 | ServerProfileInfo = 6 33 | ServerTotals = 7 34 | ServerExtremes = 8 35 | ) 36 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/word_matcher.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | import ( 4 | "strings" 5 | "unicode" 6 | ) 7 | 8 | // wordMatcher is a simple automata to match a single word (case insensitive) 9 | type wordMatcher struct { 10 | word []rune 11 | position uint8 12 | } 13 | 14 | // newMatcher returns matcher for word needle 15 | func newMatcher(needle string) *wordMatcher { 16 | return &wordMatcher{word: []rune(strings.ToUpper(needle)), 17 | position: 0} 18 | } 19 | 20 | func (m *wordMatcher) matchRune(r rune) bool { 21 | if m.word[m.position] == unicode.ToUpper(r) { 22 | if m.position == uint8(len(m.word)-1) { 23 | m.position = 0 24 | return true 25 | } 26 | m.position++ 27 | } else { 28 | m.position = 0 29 | } 30 | return false 31 | } 32 | -------------------------------------------------------------------------------- /nfpm.yaml: -------------------------------------------------------------------------------- 1 | name: "proton-server" 2 | arch: "amd64" 3 | platform: "linux" 4 | version: "v0.2.1" 5 | section: "default" 6 | priority: "extra" 7 | maintainer: "Kirill Shvakov " 8 | description: "Proton - high performance Pinba storage server." 9 | vendor: "ClickHouse-Ninja" 10 | homepage: "https://github.com/ClickHouse-Ninja/Proton" 11 | license: "MIT" 12 | bindir: "/usr/bin" 13 | files: 14 | ./.build/proton-server: "/usr/bin/proton-server" 15 | config_files: 16 | ./package/etc/proton-server/options: "/etc/proton-server/options" 17 | ./package/systemd/proton-server.service: "/etc/systemd/system/proton-server.service" 18 | overrides: 19 | deb: 20 | scripts: 21 | postinstall: ./package/scripts/postinstall.sh 22 | preremove: ./package/scripts/preremove.sh 23 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/column/string.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "github.com/kshvakov/clickhouse/lib/binary" 5 | ) 6 | 7 | type String struct{ base } 8 | 9 | func (String) Read(decoder *binary.Decoder) (interface{}, error) { 10 | v, err := decoder.String() 11 | if err != nil { 12 | return "", err 13 | } 14 | return v, nil 15 | } 16 | 17 | func (str *String) Write(encoder *binary.Encoder, v interface{}) error { 18 | switch v := v.(type) { 19 | case string: 20 | return encoder.String(v) 21 | case []byte: 22 | return encoder.RawString(v) 23 | 24 | // this relies on Nullable never sending nil values through 25 | case *string: 26 | return encoder.String(*v) 27 | } 28 | 29 | return &ErrUnexpectedType{ 30 | T: v, 31 | Column: str, 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /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/kshvakov/clickhouse/lib/data/client_info.go: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/kshvakov/clickhouse/lib/binary" 7 | ) 8 | 9 | const ClientName = "Golang SQLDriver" 10 | 11 | const ( 12 | ClickHouseRevision = 54213 13 | ClickHouseDBMSVersionMajor = 1 14 | ClickHouseDBMSVersionMinor = 1 15 | ) 16 | 17 | type ClientInfo struct{} 18 | 19 | func (ClientInfo) Write(encoder *binary.Encoder) error { 20 | encoder.String(ClientName) 21 | encoder.Uvarint(ClickHouseDBMSVersionMajor) 22 | encoder.Uvarint(ClickHouseDBMSVersionMinor) 23 | encoder.Uvarint(ClickHouseRevision) 24 | return nil 25 | } 26 | 27 | func (ClientInfo) String() string { 28 | return fmt.Sprintf("%s %d.%d.%d", ClientName, ClickHouseDBMSVersionMajor, ClickHouseDBMSVersionMinor, ClickHouseRevision) 29 | } 30 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /examples/clickhouse-server/proton_dictionary.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Proton 5 | 6 | 7 | 127.0.0.1 8 | 9000 9 | default 10 | 11 | proton 12 | dictionary
13 |
14 | 15 | 600 16 | 17 | 18 | ID 19 | 20 | Value 21 | String 22 | 23 | 24 | 25 |
26 |
-------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/column/float32.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "github.com/kshvakov/clickhouse/lib/binary" 5 | ) 6 | 7 | type Float32 struct{ base } 8 | 9 | func (Float32) Read(decoder *binary.Decoder) (interface{}, error) { 10 | v, err := decoder.Float32() 11 | if err != nil { 12 | return float32(0), err 13 | } 14 | return v, nil 15 | } 16 | 17 | func (float *Float32) Write(encoder *binary.Encoder, v interface{}) error { 18 | switch v := v.(type) { 19 | case float32: 20 | return encoder.Float32(v) 21 | case float64: 22 | return encoder.Float32(float32(v)) 23 | 24 | // this relies on Nullable never sending nil values through 25 | case *float32: 26 | return encoder.Float32(*v) 27 | case *float64: 28 | return encoder.Float32(float32(*v)) 29 | } 30 | 31 | return &ErrUnexpectedType{ 32 | T: v, 33 | Column: float, 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/column/float64.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "github.com/kshvakov/clickhouse/lib/binary" 5 | ) 6 | 7 | type Float64 struct{ base } 8 | 9 | func (Float64) Read(decoder *binary.Decoder) (interface{}, error) { 10 | v, err := decoder.Float64() 11 | if err != nil { 12 | return float64(0), err 13 | } 14 | return v, nil 15 | } 16 | 17 | func (float *Float64) Write(encoder *binary.Encoder, v interface{}) error { 18 | switch v := v.(type) { 19 | case float32: 20 | return encoder.Float64(float64(v)) 21 | case float64: 22 | return encoder.Float64(v) 23 | 24 | // this relies on Nullable never sending nil values through 25 | case *float32: 26 | return encoder.Float64(float64(*v)) 27 | case *float64: 28 | return encoder.Float64(*v) 29 | } 30 | 31 | return &ErrUnexpectedType{ 32 | T: v, 33 | Column: float, 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/column/int16.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "github.com/kshvakov/clickhouse/lib/binary" 5 | ) 6 | 7 | type Int16 struct{ base } 8 | 9 | func (Int16) Read(decoder *binary.Decoder) (interface{}, error) { 10 | v, err := decoder.Int16() 11 | if err != nil { 12 | return int16(0), err 13 | } 14 | return v, nil 15 | } 16 | 17 | func (i *Int16) Write(encoder *binary.Encoder, v interface{}) error { 18 | switch v := v.(type) { 19 | case int16: 20 | return encoder.Int16(v) 21 | case int64: 22 | return encoder.Int16(int16(v)) 23 | case int: 24 | return encoder.Int16(int16(v)) 25 | 26 | // this relies on Nullable never sending nil values through 27 | case *int16: 28 | return encoder.Int16(*v) 29 | case *int64: 30 | return encoder.Int16(int16(*v)) 31 | case *int: 32 | return encoder.Int16(int16(*v)) 33 | } 34 | 35 | return &ErrUnexpectedType{ 36 | T: v, 37 | Column: i, 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/column/int32.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "github.com/kshvakov/clickhouse/lib/binary" 5 | ) 6 | 7 | type Int32 struct{ base } 8 | 9 | func (Int32) Read(decoder *binary.Decoder) (interface{}, error) { 10 | v, err := decoder.Int32() 11 | if err != nil { 12 | return int32(0), err 13 | } 14 | return v, nil 15 | } 16 | 17 | func (i *Int32) Write(encoder *binary.Encoder, v interface{}) error { 18 | switch v := v.(type) { 19 | case int32: 20 | return encoder.Int32(v) 21 | case int64: 22 | return encoder.Int32(int32(v)) 23 | case int: 24 | return encoder.Int32(int32(v)) 25 | 26 | // this relies on Nullable never sending nil values through 27 | case *int32: 28 | return encoder.Int32(*v) 29 | case *int64: 30 | return encoder.Int32(int32(*v)) 31 | case *int: 32 | return encoder.Int32(int32(*v)) 33 | } 34 | 35 | return &ErrUnexpectedType{ 36 | T: v, 37 | Column: i, 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/column/int64.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "github.com/kshvakov/clickhouse/lib/binary" 5 | ) 6 | 7 | type Int64 struct{ base } 8 | 9 | func (Int64) Read(decoder *binary.Decoder) (interface{}, error) { 10 | v, err := decoder.Int64() 11 | if err != nil { 12 | return int64(0), err 13 | } 14 | return v, nil 15 | } 16 | 17 | func (i *Int64) Write(encoder *binary.Encoder, v interface{}) error { 18 | switch v := v.(type) { 19 | case int: 20 | return encoder.Int64(int64(v)) 21 | case int64: 22 | return encoder.Int64(v) 23 | case []byte: 24 | if _, err := encoder.Write(v); err != nil { 25 | return err 26 | } 27 | return nil 28 | 29 | // this relies on Nullable never sending nil values through 30 | case *int: 31 | return encoder.Int64(int64(*v)) 32 | case *int64: 33 | return encoder.Int64(*v) 34 | } 35 | 36 | return &ErrUnexpectedType{ 37 | T: v, 38 | Column: i, 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/server/server_dictionary.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "log" 5 | "time" 6 | ) 7 | 8 | type dict struct { 9 | id uint64 10 | column, value string 11 | } 12 | 13 | func (server *server) backgroundDictionary() { 14 | for tick := time.Tick(time.Second); ; { 15 | block := server.dictBlock.Copy() 16 | loop: 17 | for block.Reserve(); ; { 18 | select { 19 | case dict := <-server.dictBacklog: 20 | block.NumRows++ 21 | block.WriteUInt64(0, dict.id) 22 | block.WriteString(1, dict.value) 23 | block.WriteString(2, dict.column) 24 | case <-tick: 25 | break loop 26 | } 27 | } 28 | if err := server.writeBlock(insertIntoDictionarySQL, block); err != nil { 29 | log.Println("dictionary write error: ", err) 30 | } 31 | } 32 | } 33 | 34 | const ( 35 | insertIntoDictionarySQL = ` 36 | INSERT INTO proton.dictionary ( 37 | ID 38 | , Value 39 | , Column 40 | ) VALUES ( 41 | ?, ?, ? 42 | ) 43 | ` 44 | ) 45 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/cityhash102/city64.go: -------------------------------------------------------------------------------- 1 | package cityhash102 2 | 3 | import ( 4 | "encoding/binary" 5 | "hash" 6 | ) 7 | 8 | type City64 struct { 9 | s []byte 10 | } 11 | 12 | var _ hash.Hash64 = (*City64)(nil) 13 | var _ hash.Hash = (*City64)(nil) 14 | 15 | func New64() hash.Hash64 { 16 | return &City64{} 17 | } 18 | 19 | func (this *City64) Sum(b []byte) []byte { 20 | b2 := make([]byte, 8) 21 | binary.BigEndian.PutUint64(b2, this.Sum64()) 22 | b = append(b, b2...) 23 | return b 24 | } 25 | 26 | func (this *City64) Sum64() uint64 { 27 | return CityHash64(this.s, uint32(len(this.s))) 28 | } 29 | 30 | func (this *City64) Reset() { 31 | this.s = this.s[0:0] 32 | } 33 | 34 | func (this *City64) BlockSize() int { 35 | return 1 36 | } 37 | 38 | func (this *City64) Write(s []byte) (n int, err error) { 39 | this.s = append(this.s, s...) 40 | return len(s), nil 41 | } 42 | 43 | func (this *City64) Size() int { 44 | return 8 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | Anton Povarov 2 | Brian Goff 3 | Clayton Coleman 4 | Denis Smirnov 5 | DongYun Kang 6 | Dwayne Schultz 7 | Georg Apitz 8 | Gustav Paul 9 | Johan Brandhorst 10 | John Shahid 11 | John Tuley 12 | Laurent 13 | Patrick Lee 14 | Peter Edge 15 | Roger Johansson 16 | Sam Nguyen 17 | Sergio Arbeo 18 | Stephen J Day 19 | Tamir Duberstein 20 | Todd Eisenberger 21 | Tormod Erevik Lea 22 | Vyacheslav Kim 23 | Walter Schulze 24 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/column/uint16.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "github.com/kshvakov/clickhouse/lib/binary" 5 | ) 6 | 7 | type UInt16 struct{ base } 8 | 9 | func (UInt16) Read(decoder *binary.Decoder) (interface{}, error) { 10 | v, err := decoder.UInt16() 11 | if err != nil { 12 | return uint16(0), err 13 | } 14 | return v, nil 15 | } 16 | 17 | func (u *UInt16) Write(encoder *binary.Encoder, v interface{}) error { 18 | switch v := v.(type) { 19 | case uint16: 20 | return encoder.UInt16(v) 21 | case int64: 22 | return encoder.UInt16(uint16(v)) 23 | case int: 24 | return encoder.UInt16(uint16(v)) 25 | 26 | // this relies on Nullable never sending nil values through 27 | case *uint16: 28 | return encoder.UInt16(*v) 29 | case *int64: 30 | return encoder.UInt16(uint16(*v)) 31 | case *int: 32 | return encoder.UInt16(uint16(*v)) 33 | } 34 | 35 | return &ErrUnexpectedType{ 36 | T: v, 37 | Column: u, 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/column/uint32.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "github.com/kshvakov/clickhouse/lib/binary" 5 | ) 6 | 7 | type UInt32 struct{ base } 8 | 9 | func (UInt32) Read(decoder *binary.Decoder) (interface{}, error) { 10 | v, err := decoder.UInt32() 11 | if err != nil { 12 | return uint32(0), err 13 | } 14 | return v, nil 15 | } 16 | 17 | func (u *UInt32) Write(encoder *binary.Encoder, v interface{}) error { 18 | switch v := v.(type) { 19 | case uint32: 20 | return encoder.UInt32(v) 21 | case int64: 22 | return encoder.UInt32(uint32(v)) 23 | case int: 24 | return encoder.UInt32(uint32(v)) 25 | 26 | // this relies on Nullable never sending nil values through 27 | case *uint32: 28 | return encoder.UInt32(*v) 29 | case *int64: 30 | return encoder.UInt32(uint32(*v)) 31 | case *int: 32 | return encoder.UInt32(uint32(*v)) 33 | } 34 | 35 | return &ErrUnexpectedType{ 36 | T: v, 37 | Column: u, 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_golang/NOTICE: -------------------------------------------------------------------------------- 1 | Prometheus instrumentation library for Go applications 2 | Copyright 2012-2015 The Prometheus Authors 3 | 4 | This product includes software developed at 5 | SoundCloud Ltd. (http://soundcloud.com/). 6 | 7 | 8 | The following components are included in this product: 9 | 10 | perks - a fork of https://github.com/bmizerany/perks 11 | https://github.com/beorn7/perks 12 | Copyright 2013-2015 Blake Mizerany, Björn Rabenstein 13 | See https://github.com/beorn7/perks/blob/master/README.md for license details. 14 | 15 | Go support for Protocol Buffers - Google's data interchange format 16 | http://github.com/golang/protobuf/ 17 | Copyright 2010 The Go Authors 18 | See source code for license details. 19 | 20 | Support for streaming Protocol Buffer messages for the Go language (golang). 21 | https://github.com/matttproud/golang_protobuf_extensions 22 | Copyright 2013 Matt T. Proud 23 | Licensed under the Apache License, Version 2.0 24 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Prometheus uses GitHub to manage reviews of pull requests. 4 | 5 | * If you have a trivial fix or improvement, go ahead and create a pull request, 6 | addressing (with `@...`) the maintainer of this repository (see 7 | [MAINTAINERS.md](MAINTAINERS.md)) in the description of the pull request. 8 | 9 | * If you plan to do something more involved, first discuss your ideas 10 | on our [mailing list](https://groups.google.com/forum/?fromgroups#!forum/prometheus-developers). 11 | This will avoid unnecessary work and surely give you and us a good deal 12 | of inspiration. 13 | 14 | * Relevant coding style guidelines are the [Go Code Review 15 | Comments](https://code.google.com/p/go-wiki/wiki/CodeReviewComments) 16 | and the _Formatting and style_ section of Peter Bourgon's [Go: Best 17 | Practices for Production 18 | Environments](http://peter.bourgon.org/go-in-production/#formatting-and-style). 19 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/column/uint8.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "github.com/kshvakov/clickhouse/lib/binary" 5 | ) 6 | 7 | type UInt8 struct{ base } 8 | 9 | func (UInt8) Read(decoder *binary.Decoder) (interface{}, error) { 10 | v, err := decoder.UInt8() 11 | if err != nil { 12 | return uint8(0), err 13 | } 14 | return v, nil 15 | } 16 | 17 | func (u *UInt8) Write(encoder *binary.Encoder, v interface{}) error { 18 | switch v := v.(type) { 19 | case bool: 20 | return encoder.Bool(v) 21 | case uint8: 22 | return encoder.UInt8(v) 23 | case int64: 24 | return encoder.UInt8(uint8(v)) 25 | case int: 26 | return encoder.UInt8(uint8(v)) 27 | 28 | // this relies on Nullable never sending nil values through 29 | case *bool: 30 | return encoder.Bool(*v) 31 | case *uint8: 32 | return encoder.UInt8(*v) 33 | case *int64: 34 | return encoder.UInt8(uint8(*v)) 35 | case *int: 36 | return encoder.UInt8(uint8(*v)) 37 | } 38 | 39 | return &ErrUnexpectedType{ 40 | T: v, 41 | Column: u, 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/clickhouse_profile_info.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | type profileInfo struct { 4 | rows uint64 5 | bytes uint64 6 | blocks uint64 7 | appliedLimit bool 8 | rowsBeforeLimit uint64 9 | calculatedRowsBeforeLimit bool 10 | } 11 | 12 | func (ch *clickhouse) profileInfo() (*profileInfo, error) { 13 | var ( 14 | p profileInfo 15 | err error 16 | ) 17 | if p.rows, err = ch.decoder.Uvarint(); err != nil { 18 | return nil, err 19 | } 20 | if p.blocks, err = ch.decoder.Uvarint(); err != nil { 21 | return nil, err 22 | } 23 | if p.bytes, err = ch.decoder.Uvarint(); err != nil { 24 | return nil, err 25 | } 26 | 27 | if p.appliedLimit, err = ch.decoder.Bool(); err != nil { 28 | return nil, err 29 | } 30 | if p.rowsBeforeLimit, err = ch.decoder.Uvarint(); err != nil { 31 | return nil, err 32 | } 33 | if p.calculatedRowsBeforeLimit, err = ch.decoder.Bool(); err != nil { 34 | return nil, err 35 | } 36 | return &p, nil 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/column/uint64.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "github.com/kshvakov/clickhouse/lib/binary" 5 | ) 6 | 7 | type UInt64 struct{ base } 8 | 9 | func (UInt64) Read(decoder *binary.Decoder) (interface{}, error) { 10 | v, err := decoder.UInt64() 11 | if err != nil { 12 | return uint64(0), err 13 | } 14 | return v, nil 15 | } 16 | 17 | func (u *UInt64) Write(encoder *binary.Encoder, v interface{}) error { 18 | switch v := v.(type) { 19 | case []byte: 20 | if _, err := encoder.Write(v); err != nil { 21 | return err 22 | } 23 | return nil 24 | case uint64: 25 | return encoder.UInt64(v) 26 | case int64: 27 | return encoder.UInt64(uint64(v)) 28 | case int: 29 | return encoder.UInt64(uint64(v)) 30 | 31 | // this relies on Nullable never sending nil values through 32 | case *uint64: 33 | return encoder.UInt64(*v) 34 | case *int64: 35 | return encoder.UInt64(uint64(*v)) 36 | case *int: 37 | return encoder.UInt64(uint64(*v)) 38 | } 39 | 40 | return &ErrUnexpectedType{ 41 | T: v, 42 | Column: u, 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2018 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 | include Makefile.common 15 | 16 | %/.unpacked: %.ttar 17 | ./ttar -C $(dir $*) -x -f $*.ttar 18 | touch $@ 19 | 20 | update_fixtures: fixtures.ttar sysfs/fixtures.ttar 21 | 22 | %fixtures.ttar: %/fixtures 23 | rm -v $(dir $*)fixtures/.unpacked 24 | ./ttar -C $(dir $*) -c -f $*fixtures.ttar fixtures/ 25 | 26 | .PHONY: build 27 | build: 28 | 29 | .PHONY: test 30 | test: fixtures/.unpacked sysfs/fixtures/.unpacked common-test 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 ClickHouse Ninja 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 | -------------------------------------------------------------------------------- /proto/pinba/request.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package pinba; 4 | option optimize_for = LITE_RUNTIME; 5 | 6 | message Request { 7 | required string hostname = 1; 8 | required string server_name = 2; 9 | required string script_name = 3; 10 | required uint32 request_count = 4; 11 | required uint32 document_size = 5; 12 | required uint32 memory_peak = 6; 13 | required float request_time = 7; 14 | required float ru_utime = 8; 15 | required float ru_stime = 9; 16 | 17 | repeated uint32 timer_hit_count = 10; 18 | repeated float timer_value = 11; 19 | repeated uint32 timer_tag_count = 12; 20 | repeated uint32 timer_tag_name = 13; 21 | repeated uint32 timer_tag_value = 14; 22 | repeated string dictionary = 15; 23 | optional uint32 status = 16; 24 | optional uint32 memory_footprint = 17; 25 | repeated Request requests = 18; 26 | optional string schema = 19; 27 | repeated uint32 tag_name = 20; 28 | repeated uint32 tag_value = 21; 29 | repeated float timer_ru_utime = 22; 30 | repeated float timer_ru_stime = 23; 31 | } -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/clickhouse_exception.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | type Exception struct { 9 | Code int32 10 | Name string 11 | Message string 12 | StackTrace string 13 | nested error 14 | } 15 | 16 | func (e *Exception) Error() string { 17 | return fmt.Sprintf("code: %d, message: %s", e.Code, e.Message) 18 | } 19 | 20 | func (ch *clickhouse) exception() error { 21 | defer ch.conn.Close() 22 | var ( 23 | e Exception 24 | err error 25 | hasNested bool 26 | ) 27 | if e.Code, err = ch.decoder.Int32(); err != nil { 28 | return err 29 | } 30 | if e.Name, err = ch.decoder.String(); err != nil { 31 | return err 32 | } 33 | if e.Message, err = ch.decoder.String(); err != nil { 34 | return err 35 | } 36 | e.Message = strings.TrimSpace(strings.TrimPrefix(e.Message, e.Name+":")) 37 | if e.StackTrace, err = ch.decoder.String(); err != nil { 38 | return err 39 | } 40 | if hasNested, err = ch.decoder.Bool(); err != nil { 41 | return err 42 | } 43 | if hasNested { 44 | e.nested = ch.exception() 45 | } 46 | return &e 47 | } 48 | -------------------------------------------------------------------------------- /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/kshvakov/clickhouse/lib/column/int8.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "github.com/kshvakov/clickhouse/lib/binary" 5 | ) 6 | 7 | type Int8 struct{ base } 8 | 9 | func (Int8) Read(decoder *binary.Decoder) (interface{}, error) { 10 | v, err := decoder.Int8() 11 | if err != nil { 12 | return int8(0), err 13 | } 14 | return v, nil 15 | } 16 | 17 | func (i *Int8) Write(encoder *binary.Encoder, v interface{}) error { 18 | switch v := v.(type) { 19 | case int8: 20 | return encoder.Int8(v) 21 | case int64: 22 | return encoder.Int8(int8(v)) 23 | case int: 24 | return encoder.Int8(int8(v)) 25 | case bool: 26 | if v { 27 | return encoder.Int8(int8(1)) 28 | } 29 | return encoder.Int8(int8(0)) 30 | 31 | // this relies on Nullable never sending nil values through 32 | case *int8: 33 | return encoder.Int8(*v) 34 | case *int64: 35 | return encoder.Int8(int8(*v)) 36 | case *int: 37 | return encoder.Int8(int8(*v)) 38 | case *bool: 39 | if *v { 40 | return encoder.Int8(int8(1)) 41 | } 42 | return encoder.Int8(int8(0)) 43 | } 44 | 45 | return &ErrUnexpectedType{ 46 | T: v, 47 | Column: i, 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/mkevac/gopinba/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Marko Kevac 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. -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Kirill Shvakov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/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/kshvakov/clickhouse/lib/types/date.go: -------------------------------------------------------------------------------- 1 | // Timezoneless date/datetime types 2 | 3 | package types 4 | 5 | import ( 6 | "database/sql/driver" 7 | "time" 8 | ) 9 | 10 | // Truncate timezone 11 | // 12 | // clickhouse.Date(time.Date(2017, 1, 1, 0, 0, 0, 0, time.Local)) -> time.Date(2017, 1, 1, 0, 0, 0, 0, time.UTC) 13 | type Date time.Time 14 | 15 | func (date Date) Value() (driver.Value, error) { 16 | return date.convert(), nil 17 | } 18 | 19 | func (date Date) convert() time.Time { 20 | return time.Date(time.Time(date).Year(), time.Time(date).Month(), time.Time(date).Day(), 0, 0, 0, 0, time.UTC) 21 | } 22 | 23 | // Truncate timezone 24 | // 25 | // clickhouse.DateTime(time.Date(2017, 1, 1, 0, 0, 0, 0, time.Local)) -> time.Date(2017, 1, 1, 0, 0, 0, 0, time.UTC) 26 | type DateTime time.Time 27 | 28 | func (datetime DateTime) Value() (driver.Value, error) { 29 | return datetime.convert(), nil 30 | } 31 | 32 | func (datetime DateTime) convert() time.Time { 33 | return time.Date( 34 | time.Time(datetime).Year(), 35 | time.Time(datetime).Month(), 36 | time.Time(datetime).Day(), 37 | time.Time(datetime).Hour(), 38 | time.Time(datetime).Minute(), 39 | time.Time(datetime).Second(), 40 | 0, 41 | time.UTC, 42 | ) 43 | } 44 | 45 | var ( 46 | _ driver.Valuer = Date{} 47 | _ driver.Valuer = DateTime{} 48 | ) 49 | -------------------------------------------------------------------------------- /schema/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS proton; 2 | 3 | CREATE TABLE IF NOT EXISTS proton.requests ( 4 | Hostname String 5 | , Schema String 6 | , Status Int16 7 | , ServerName String 8 | , ScriptName String 9 | , RequestCount UInt32 10 | , RequestTime Float32 11 | , DocumentSize UInt32 12 | , MemoryPeak UInt32 13 | , MemoryFootprint UInt32 14 | , Utime Float32 15 | , Stime Float32 16 | , Tags Nested ( 17 | Name String 18 | , Value String 19 | ) 20 | , Timers Nested ( 21 | HitCount UInt32 22 | , Value Float32 23 | , Utime Float32 24 | , Stime Float32 25 | , TagsName Array(String) 26 | , TagsValue Array(String) 27 | ) 28 | , Timestamp DateTime 29 | ) Engine = MergeTree 30 | PARTITION BY toYYYYMM(Timestamp) 31 | PRIMARY KEY ( 32 | Schema 33 | , toStartOfHour(Timestamp) 34 | ) 35 | ORDER BY ( 36 | Schema 37 | , toStartOfHour(Timestamp) 38 | , Hostname 39 | , ServerName 40 | , ScriptName 41 | ); 42 | 43 | CREATE TABLE IF NOT EXISTS proton.dictionary ( 44 | ID UInt64 45 | , Value String 46 | , Column String 47 | ) Engine ReplacingMergeTree 48 | PARTITION BY Column 49 | ORDER BY ID; -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_golang/prometheus/promhttp/delegator_pre_1_8.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 | // +build !go1.8 15 | 16 | package promhttp 17 | 18 | import ( 19 | "io" 20 | "net/http" 21 | ) 22 | 23 | func newDelegator(w http.ResponseWriter, observeWriteHeaderFunc func(int)) delegator { 24 | d := &responseWriterDelegator{ 25 | ResponseWriter: w, 26 | observeWriteHeader: observeWriteHeaderFunc, 27 | } 28 | 29 | id := 0 30 | if _, ok := w.(http.CloseNotifier); ok { 31 | id += closeNotifier 32 | } 33 | if _, ok := w.(http.Flusher); ok { 34 | id += flusher 35 | } 36 | if _, ok := w.(http.Hijacker); ok { 37 | id += hijacker 38 | } 39 | if _, ok := w.(io.ReaderFrom); ok { 40 | id += readerFrom 41 | } 42 | 43 | return pickDelegator[id](d) 44 | } 45 | -------------------------------------------------------------------------------- /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/client_golang/prometheus/fnv.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 | // 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/mkevac/monotime/monotime.go: -------------------------------------------------------------------------------- 1 | // Based on code from: https://github.com/aristanetworks/goarista/blob/46272bfb1c042fc2825d312fe33d494e9d13dd6b/atime/nanotime.go 2 | 3 | // Copyright (C) 2016 Arista Networks, Inc. 4 | // Use of this source code is governed by the Apache License 2.0 5 | // that can be found in the COPYING file. 6 | 7 | // Package monotime provides a fast monotonic clock source. 8 | package monotime 9 | 10 | import ( 11 | "time" 12 | "unsafe" 13 | ) 14 | 15 | // Make goimports import the unsafe package, which is required to be able 16 | // to use //go:linkname 17 | var _ = unsafe.Sizeof(0) 18 | 19 | //go:noescape 20 | //go:linkname nanotime runtime.nanotime 21 | func nanotime() int64 22 | 23 | // Nanoseconds returns the current time in nanoseconds from a monotonic clock. 24 | // The time returned is based on some arbitrary platform-specific point in the 25 | // past. The time returned is guaranteed to increase monotonically at a 26 | // constant rate, unlike time.Now() from the Go standard library, which may 27 | // slow down, speed up, jump forward or backward, due to NTP activity or leap 28 | // seconds. 29 | func Nanoseconds() uint64 { 30 | return uint64(nanotime()) 31 | } 32 | 33 | // Now returns current time from a monotonic clock 34 | // i.e. the result of Nanoseconds() as time.Time 35 | func Now() time.Time { 36 | t := time.Time{} 37 | return t.Add(time.Duration(Nanoseconds()) * time.Nanosecond) 38 | } 39 | -------------------------------------------------------------------------------- /cmd/proton-server/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "log" 7 | 8 | "github.com/ClickHouse-Ninja/Proton/src/server" 9 | 10 | "net/http" 11 | _ "net/http/pprof" 12 | ) 13 | 14 | var ( 15 | options server.Options 16 | pprof string 17 | ) 18 | 19 | var ( 20 | BuildDate string 21 | GitBranch, GitCommit string 22 | ) 23 | 24 | func init() { 25 | flag.StringVar(&options.DSN, "dsn", "native://127.0.0.1:9000", "ClickHouse DSN") 26 | flag.StringVar(&options.Address, "addr", ":30002", "listen address") 27 | flag.StringVar(&options.MetricsAddress, "metrics_addr", ":2112", "address on which to expose metrics") 28 | flag.IntVar(&options.BacklogSize, "backlog", 10000, "backlog size") 29 | flag.IntVar(&options.Concurrency, "concurrency", 2, "number of the background processes") 30 | flag.StringVar(&pprof, "pprof", "", "pprof address. If set to start the pprof server") 31 | } 32 | 33 | func main() { 34 | flag.Usage = func() { 35 | fmt.Println("NAME:") 36 | fmt.Println(" Proton - high performance Pinba storage server.") 37 | fmt.Println("VERSION:") 38 | fmt.Printf(" 0.2 rev[%s] %s (%s UTC).\n", GitCommit, GitBranch, BuildDate) 39 | fmt.Println("USAGE:") 40 | flag.PrintDefaults() 41 | } 42 | flag.Parse() 43 | if len(pprof) != 0 { 44 | go func() { 45 | log.Println(http.ListenAndServe(pprof, nil)) 46 | }() 47 | } 48 | if err := server.RunServer(options); err != nil { 49 | log.Fatal(err) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/lz4/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2011-2012 Branimir Karadzic. All rights reserved. 2 | Copyright 2013 Damian Gryski. 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 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | 2. 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 | THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR 15 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 19 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 21 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 22 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 | THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/gogoproto/gogo.pb.golden: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: gogo.proto 3 | // DO NOT EDIT! 4 | 5 | package gogoproto 6 | 7 | import proto "github.com/gogo/protobuf/proto" 8 | import json "encoding/json" 9 | import math "math" 10 | import google_protobuf "github.com/gogo/protobuf/protoc-gen-gogo/descriptor" 11 | 12 | // Reference proto, json, and math imports to suppress error if they are not otherwise used. 13 | var _ = proto.Marshal 14 | var _ = &json.SyntaxError{} 15 | var _ = math.Inf 16 | 17 | var E_Nullable = &proto.ExtensionDesc{ 18 | ExtendedType: (*google_protobuf.FieldOptions)(nil), 19 | ExtensionType: (*bool)(nil), 20 | Field: 51235, 21 | Name: "gogoproto.nullable", 22 | Tag: "varint,51235,opt,name=nullable", 23 | } 24 | 25 | var E_Embed = &proto.ExtensionDesc{ 26 | ExtendedType: (*google_protobuf.FieldOptions)(nil), 27 | ExtensionType: (*bool)(nil), 28 | Field: 51236, 29 | Name: "gogoproto.embed", 30 | Tag: "varint,51236,opt,name=embed", 31 | } 32 | 33 | var E_Customtype = &proto.ExtensionDesc{ 34 | ExtendedType: (*google_protobuf.FieldOptions)(nil), 35 | ExtensionType: (*string)(nil), 36 | Field: 51237, 37 | Name: "gogoproto.customtype", 38 | Tag: "bytes,51237,opt,name=customtype", 39 | } 40 | 41 | func init() { 42 | proto.RegisterExtension(E_Nullable) 43 | proto.RegisterExtension(E_Embed) 44 | proto.RegisterExtension(E_Customtype) 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/cloudflare/golz4/lz4_hc.go: -------------------------------------------------------------------------------- 1 | package lz4 2 | 3 | // #cgo CFLAGS: -O3 4 | // #include "src/lz4hc.h" 5 | // #include "src/lz4hc.c" 6 | import "C" 7 | 8 | import ( 9 | "fmt" 10 | ) 11 | 12 | // CompressHC compresses in and puts the content in out. len(out) 13 | // should have enough space for the compressed data (use CompressBound 14 | // to calculate). Returns the number of bytes in the out slice. Determines 15 | // the compression level automatically. 16 | func CompressHC(in, out []byte) (int, error) { 17 | // 0 automatically sets the compression level. 18 | return CompressHCLevel(in, out, 0) 19 | } 20 | 21 | // CompressHCLevel compresses in at the given compression level and puts the 22 | // content in out. len(out) should have enough space for the compressed data 23 | // (use CompressBound to calculate). Returns the number of bytes in the out 24 | // slice. To automatically choose the compression level, use 0. Otherwise, use 25 | // any value in the inclusive range 1 (worst) through 16 (best). Most 26 | // applications will prefer CompressHC. 27 | func CompressHCLevel(in, out []byte, level int) (outSize int, err error) { 28 | // LZ4HC does not handle empty buffers. Pass through to Compress. 29 | if len(in) == 0 || len(out) == 0 { 30 | return Compress(in, out) 31 | } 32 | 33 | outSize = int(C.LZ4_compressHC2_limitedOutput(p(in), p(out), clen(in), clen(out), C.int(level))) 34 | if outSize == 0 { 35 | err = fmt.Errorf("insufficient space for compression") 36 | } 37 | return 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/column/common.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | "time" 7 | ) 8 | 9 | type ErrUnexpectedType struct { 10 | Column Column 11 | T interface{} 12 | } 13 | 14 | func (err *ErrUnexpectedType) Error() string { 15 | return fmt.Sprintf("%s: unexpected type %T", err.Column, err.T) 16 | } 17 | 18 | var baseTypes = map[interface{}]reflect.Value{ 19 | int8(0): reflect.ValueOf(int8(0)), 20 | int16(0): reflect.ValueOf(int16(0)), 21 | int32(0): reflect.ValueOf(int32(0)), 22 | int64(0): reflect.ValueOf(int64(0)), 23 | uint8(0): reflect.ValueOf(uint8(0)), 24 | uint16(0): reflect.ValueOf(uint16(0)), 25 | uint32(0): reflect.ValueOf(uint32(0)), 26 | uint64(0): reflect.ValueOf(uint64(0)), 27 | float32(0): reflect.ValueOf(float32(0)), 28 | float64(0): reflect.ValueOf(float64(0)), 29 | string(""): reflect.ValueOf(string("")), 30 | time.Time{}: reflect.ValueOf(time.Time{}), 31 | } 32 | 33 | type base struct { 34 | name, chType string 35 | valueOf reflect.Value 36 | } 37 | 38 | func (base *base) Name() string { 39 | return base.name 40 | } 41 | 42 | func (base *base) CHType() string { 43 | return base.chType 44 | } 45 | 46 | func (base *base) ScanType() reflect.Type { 47 | return base.valueOf.Type() 48 | } 49 | 50 | func (base *base) defaultValue() interface{} { 51 | return base.valueOf.Interface() 52 | } 53 | 54 | func (base *base) String() string { 55 | return fmt.Sprintf("%s (%s)", base.name, base.chType) 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/write_column.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | import ( 4 | "database/sql" 5 | "database/sql/driver" 6 | "time" 7 | 8 | "github.com/kshvakov/clickhouse/lib/data" 9 | ) 10 | 11 | // Interface for Clickhouse driver 12 | type Clickhouse interface { 13 | Block() (*data.Block, error) 14 | Prepare(query string) (driver.Stmt, error) 15 | Begin() (driver.Tx, error) 16 | Commit() error 17 | Rollback() error 18 | Close() error 19 | WriteBlock(block *data.Block) error 20 | } 21 | 22 | // Interface for Block allowing writes to individual columns 23 | type ColumnWriter interface { 24 | WriteDate(c int, v time.Time) error 25 | WriteDateTime(c int, v time.Time) error 26 | WriteUInt8(c int, v uint8) error 27 | WriteUInt16(c int, v uint16) error 28 | WriteUInt32(c int, v uint32) error 29 | WriteUInt64(c int, v uint64) error 30 | WriteFloat32(c int, v float32) error 31 | WriteFloat64(c int, v float64) error 32 | WriteBytes(c int, v []byte) error 33 | WriteArray(c int, v interface{}) error 34 | WriteString(c int, v string) error 35 | WriteFixedString(c int, v []byte) error 36 | } 37 | 38 | func OpenDirect(dsn string) (Clickhouse, error) { 39 | return open(dsn) 40 | } 41 | 42 | func (ch *clickhouse) Block() (*data.Block, error) { 43 | if ch.block == nil { 44 | return nil, sql.ErrTxDone 45 | } 46 | return ch.block, nil 47 | } 48 | 49 | func (ch *clickhouse) WriteBlock(block *data.Block) error { 50 | if block == nil { 51 | return sql.ErrTxDone 52 | } 53 | return ch.writeBlock(block) 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/clickhouse_send_query.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | import ( 4 | "github.com/kshvakov/clickhouse/lib/data" 5 | "github.com/kshvakov/clickhouse/lib/protocol" 6 | ) 7 | 8 | func (ch *clickhouse) sendQuery(query string) error { 9 | ch.logf("[send query] %s", query) 10 | if err := ch.encoder.Uvarint(protocol.ClientQuery); err != nil { 11 | return err 12 | } 13 | if err := ch.encoder.String(""); err != nil { 14 | return err 15 | } 16 | { // client info 17 | ch.encoder.Uvarint(1) 18 | ch.encoder.String("") 19 | ch.encoder.String("") //initial_query_id 20 | ch.encoder.String("[::ffff:127.0.0.1]:0") 21 | ch.encoder.Uvarint(1) // iface type TCP 22 | ch.encoder.String(hostname) 23 | ch.encoder.String(hostname) 24 | } 25 | if err := ch.ClientInfo.Write(ch.encoder); err != nil { 26 | return err 27 | } 28 | if ch.ServerInfo.Revision >= protocol.DBMS_MIN_REVISION_WITH_QUOTA_KEY_IN_CLIENT_INFO { 29 | ch.encoder.String("") 30 | } 31 | 32 | if err := ch.encoder.String(""); err != nil { // settings 33 | return err 34 | } 35 | if err := ch.encoder.Uvarint(protocol.StateComplete); err != nil { 36 | return err 37 | } 38 | compress := protocol.CompressDisable 39 | if ch.compress { 40 | compress = protocol.CompressEnable 41 | } 42 | if err := ch.encoder.Uvarint(compress); err != nil { 43 | return err 44 | } 45 | if err := ch.encoder.String(query); err != nil { 46 | return err 47 | } 48 | if err := ch.writeBlock(&data.Block{}); err != nil { 49 | return err 50 | } 51 | return ch.encoder.Flush() 52 | } 53 | -------------------------------------------------------------------------------- /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/kshvakov/clickhouse/clickhouse_write_block.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | import ( 4 | "github.com/kshvakov/clickhouse/lib/data" 5 | "github.com/kshvakov/clickhouse/lib/protocol" 6 | ) 7 | 8 | func (ch *clickhouse) writeBlock(block *data.Block) error { 9 | ch.Lock() 10 | defer ch.Unlock() 11 | if err := ch.encoder.Uvarint(protocol.ClientData); err != nil { 12 | return err 13 | } 14 | 15 | if err := ch.encoder.String(""); err != nil { // temporary table 16 | return err 17 | } 18 | 19 | // implement CityHash v 1.0.2 and add LZ4 compression 20 | /* 21 | From Alexey Milovidov 22 | Насколько я помню, сжимаются блоки с данными Native формата, а всё остальное (всякие номера пакетов и т. п.) передаётся без сжатия. 23 | 24 | Сжатые данные устроены так. Они представляют собой набор сжатых фреймов. 25 | Каждый фрейм имеет следующий вид: 26 | чексумма (16 байт), 27 | идентификатор алгоритма сжатия (1 байт), 28 | размер сжатых данных (4 байта, little endian, размер не включает в себя чексумму, но включает в себя остальные 9 байт заголовка), 29 | размер несжатых данных (4 байта, little endian), затем сжатые данные. 30 | Идентификатор алгоритма: 0x82 - lz4, 0x90 - zstd. 31 | Чексумма - CityHash128 из CityHash версии 1.0.2, вычисленный от сжатых данных с учётом 9 байт заголовка. 32 | 33 | См. CompressedReadBufferBase, CompressedWriteBuffer, 34 | utils/compressor, TCPHandler. 35 | */ 36 | ch.encoder.SelectCompress(ch.compress) 37 | err := block.Write(&ch.ServerInfo, ch.encoder) 38 | ch.encoder.SelectCompress(false) 39 | return err 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/data/server_info.go: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | import ( 4 | "fmt" 5 | //"io" 6 | "time" 7 | 8 | "github.com/kshvakov/clickhouse/lib/binary" 9 | "github.com/kshvakov/clickhouse/lib/protocol" 10 | ) 11 | 12 | type ServerInfo struct { 13 | Name string 14 | Revision uint64 15 | MinorVersion uint64 16 | MajorVersion uint64 17 | Timezone *time.Location 18 | } 19 | 20 | func (srv *ServerInfo) Read(decoder *binary.Decoder) (err error) { 21 | if srv.Name, err = decoder.String(); err != nil { 22 | return fmt.Errorf("could not read server name: %v", err) 23 | } 24 | if srv.MajorVersion, err = decoder.Uvarint(); err != nil { 25 | return fmt.Errorf("could not read server major version: %v", err) 26 | } 27 | if srv.MinorVersion, err = decoder.Uvarint(); err != nil { 28 | return fmt.Errorf("could not read server minor version: %v", err) 29 | } 30 | if srv.Revision, err = decoder.Uvarint(); err != nil { 31 | return fmt.Errorf("could not read server revision: %v", err) 32 | } 33 | if srv.Revision >= protocol.DBMS_MIN_REVISION_WITH_SERVER_TIMEZONE { 34 | timezone, err := decoder.String() 35 | if err != nil { 36 | return fmt.Errorf("could not read server timezone: %v", err) 37 | } 38 | if srv.Timezone, err = time.LoadLocation(timezone); err != nil { 39 | return fmt.Errorf("could not load time location: %v", err) 40 | } 41 | } 42 | return nil 43 | } 44 | 45 | func (srv ServerInfo) String() string { 46 | return fmt.Sprintf("%s %d.%d.%d (%s)", srv.Name, srv.MajorVersion, srv.MinorVersion, srv.Revision, srv.Timezone) 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/internal/util/sysreadfile_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 !windows 15 | 16 | package util 17 | 18 | import ( 19 | "bytes" 20 | "os" 21 | "syscall" 22 | ) 23 | 24 | // SysReadFile is a simplified ioutil.ReadFile that invokes syscall.Read directly. 25 | // https://github.com/prometheus/node_exporter/pull/728/files 26 | func SysReadFile(file string) (string, error) { 27 | f, err := os.Open(file) 28 | if err != nil { 29 | return "", err 30 | } 31 | defer f.Close() 32 | 33 | // On some machines, hwmon drivers are broken and return EAGAIN. This causes 34 | // Go's ioutil.ReadFile implementation to poll forever. 35 | // 36 | // Since we either want to read data or bail immediately, do the simplest 37 | // possible read using syscall directly. 38 | b := make([]byte, 128) 39 | n, err := syscall.Read(int(f.Fd()), b) 40 | if err != nil { 41 | return "", err 42 | } 43 | 44 | return string(bytes.TrimSpace(b[:n])), nil 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2010 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 | 29 | -------------------------------------------------------------------------------- /vendor/github.com/cloudflare/golz4/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 CloudFlare, 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, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, this 11 | list of conditions and the following disclaimer in the documentation and/or 12 | other materials provided with the distribution. 13 | 14 | * Neither the name of the CloudFlare, 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 "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 HOLDER 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/kshvakov/clickhouse/clickhouse_read_meta.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/kshvakov/clickhouse/lib/data" 7 | "github.com/kshvakov/clickhouse/lib/protocol" 8 | ) 9 | 10 | func (ch *clickhouse) readMeta() (*data.Block, error) { 11 | for { 12 | packet, err := ch.decoder.Uvarint() 13 | if err != nil { 14 | return nil, err 15 | } 16 | 17 | switch packet { 18 | case protocol.ServerException: 19 | ch.logf("[read meta] <- exception") 20 | return nil, ch.exception() 21 | case protocol.ServerProgress: 22 | progress, err := ch.progress() 23 | if err != nil { 24 | return nil, err 25 | } 26 | ch.logf("[read meta] <- progress: rows=%d, bytes=%d, total rows=%d", 27 | progress.rows, 28 | progress.bytes, 29 | progress.totalRows, 30 | ) 31 | case protocol.ServerProfileInfo: 32 | profileInfo, err := ch.profileInfo() 33 | if err != nil { 34 | return nil, err 35 | } 36 | ch.logf("[read meta] <- profiling: rows=%d, bytes=%d, blocks=%d", profileInfo.rows, profileInfo.bytes, profileInfo.blocks) 37 | case protocol.ServerData: 38 | block, err := ch.readBlock() 39 | if err != nil { 40 | return nil, err 41 | } 42 | ch.logf("[read meta] <- data: packet=%d, columns=%d, rows=%d", packet, block.NumColumns, block.NumRows) 43 | return block, nil 44 | case protocol.ServerEndOfStream: 45 | _, err := ch.readBlock() 46 | ch.logf("[process] <- end of stream") 47 | return nil, err 48 | default: 49 | ch.conn.Close() 50 | return nil, fmt.Errorf("[read meta] unexpected packet [%d] from server", packet) 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /cmd/test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "time" 6 | 7 | "github.com/mkevac/gopinba" 8 | ) 9 | 10 | func main() { 11 | pc, err := gopinba.NewClient("127.0.0.1:30002") 12 | if err != nil { 13 | log.Fatalf("NewClient() returned error: %v", err) 14 | } 15 | var ( 16 | os = []string{"Windows", "Linux", "Mac OS"} 17 | device = []string{"Mobile", "Desktop", "TV"} 18 | browser = []string{"Chrome", "FF"} 19 | ) 20 | for i := 0; i < 2; i++ { 21 | req := gopinba.Request{ 22 | Tags: map[string]string{ 23 | "OS": os[i%len(os)], 24 | "Device": device[i%len(device)], 25 | "Browser": browser[i%len(browser)], 26 | }, 27 | } 28 | req.Hostname = "hostname" 29 | req.ServerName = "servername" 30 | req.ScriptName = "scriptname" 31 | req.Schema = "https" 32 | req.Status = 200 33 | req.RequestCount = 1 34 | req.RequestTime = 145987 * time.Microsecond 35 | req.DocumentSize = 1024 36 | { 37 | timer := gopinba.TimerStart(map[string]string{"mysql": "server_1", "db_connect": "server_1"}) 38 | time.Sleep(time.Millisecond * 5) 39 | timer.Stop() 40 | req.AddTimer(timer) 41 | } 42 | { 43 | timer := gopinba.TimerStart(map[string]string{"mysql": "server_1", "db_connect": "server_1"}) 44 | time.Sleep(time.Millisecond * 5) 45 | timer.Stop() 46 | req.AddTimer(timer) 47 | } 48 | { 49 | timer := gopinba.TimerStart(map[string]string{"mysql": "server_1", "postgresql": "server_1"}) 50 | time.Sleep(time.Millisecond * 5) 51 | timer.Stop() 52 | req.AddTimer(timer) 53 | } 54 | err = pc.SendRequest(&req) 55 | if err != nil { 56 | log.Fatalf("SendRequest() returned error: %v", err) 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /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 + `; charset=utf-8` 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/kshvakov/clickhouse/lib/column/ip.go: -------------------------------------------------------------------------------- 1 | /* 2 | IP type supporting for clickhouse as FixedString(16) 3 | */ 4 | 5 | package column 6 | 7 | import ( 8 | "database/sql/driver" 9 | "errors" 10 | "net" 11 | ) 12 | 13 | var ( 14 | errInvalidScanType = errors.New("Invalid scan types") 15 | errInvalidScanValue = errors.New("Invalid scan value") 16 | ) 17 | 18 | // IP column type 19 | type IP net.IP 20 | 21 | // Value implements the driver.Valuer interface, json field interface 22 | // Alignment on the right side 23 | func (ip IP) Value() (driver.Value, error) { 24 | return ip.MarshalBinary() 25 | } 26 | 27 | func (ip IP) MarshalBinary() ([]byte, error) { 28 | if len(ip) < 16 { 29 | var ( 30 | buff = make([]byte, 16) 31 | j = 0 32 | ) 33 | for i := 16 - len(ip); i < 16; i++ { 34 | buff[i] = ip[j] 35 | j++ 36 | } 37 | for i := 0; i < 16-len(ip); i++ { 38 | buff[i] = '\x00' 39 | } 40 | if len(ip) == 4 { 41 | buff[11] = '\xff' 42 | buff[10] = '\xff' 43 | } 44 | return buff, nil 45 | } 46 | return []byte(ip), nil 47 | } 48 | 49 | // Scan implements the driver.Valuer interface, json field interface 50 | func (ip *IP) Scan(value interface{}) (err error) { 51 | switch v := value.(type) { 52 | case []byte: 53 | if len(v) == 4 || len(v) == 16 { 54 | *ip = IP(v) 55 | } else { 56 | err = errInvalidScanValue 57 | } 58 | case string: 59 | if len(v) == 4 || len(v) == 16 { 60 | *ip = IP([]byte(v)) 61 | } else { 62 | err = errInvalidScanValue 63 | } 64 | default: 65 | err = errInvalidScanType 66 | } 67 | return 68 | } 69 | 70 | // String implements the fmt.Stringer interface 71 | func (ip IP) String() string { 72 | return net.IP(ip).String() 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/proto/encode_gogo.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/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 | // 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 | 29 | package proto 30 | 31 | func NewRequiredNotSetError(field string) *RequiredNotSetError { 32 | return &RequiredNotSetError{field} 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/cloudflare/golz4/lz4.go: -------------------------------------------------------------------------------- 1 | package lz4 2 | 3 | // #cgo CFLAGS: -O3 4 | // #include "src/lz4.h" 5 | // #include "src/lz4.c" 6 | import "C" 7 | 8 | import ( 9 | "errors" 10 | "fmt" 11 | "unsafe" 12 | ) 13 | 14 | // p gets a char pointer to the first byte of a []byte slice 15 | func p(in []byte) *C.char { 16 | if len(in) == 0 { 17 | return (*C.char)(unsafe.Pointer(nil)) 18 | } 19 | return (*C.char)(unsafe.Pointer(&in[0])) 20 | } 21 | 22 | // clen gets the length of a []byte slice as a char * 23 | func clen(s []byte) C.int { 24 | return C.int(len(s)) 25 | } 26 | 27 | // Uncompress with a known output size. len(out) should be equal to 28 | // the length of the uncompressed out. 29 | func Uncompress(in, out []byte) (error) { 30 | if int(C.LZ4_decompress_safe(p(in), p(out), clen(in), clen(out))) < 0 { 31 | return errors.New("Malformed compression stream") 32 | } 33 | 34 | return nil 35 | } 36 | 37 | // CompressBound calculates the size of the output buffer needed by 38 | // Compress. This is based on the following macro: 39 | // 40 | // #define LZ4_COMPRESSBOUND(isize) 41 | // ((unsigned int)(isize) > (unsigned int)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16) 42 | func CompressBound(in []byte) int { 43 | return len(in) + ((len(in) / 255) + 16) 44 | } 45 | 46 | // Compress compresses in and puts the content in out. len(out) 47 | // should have enough space for the compressed data (use CompressBound 48 | // to calculate). Returns the number of bytes in the out slice. 49 | func Compress(in, out []byte) (outSize int, err error) { 50 | outSize = int(C.LZ4_compress_limitedOutput(p(in), p(out), clen(in), clen(out))) 51 | if outSize == 0 { 52 | err = fmt.Errorf("insufficient space for compression") 53 | } 54 | return 55 | } 56 | -------------------------------------------------------------------------------- /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/gogo/protobuf/proto/properties_gogo.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2018, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/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 | // 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 | 29 | package proto 30 | 31 | import ( 32 | "reflect" 33 | ) 34 | 35 | var sizerType = reflect.TypeOf((*Sizer)(nil)).Elem() 36 | var protosizerType = reflect.TypeOf((*ProtoSizer)(nil)).Elem() 37 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/column/fixed_string.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "encoding" 5 | "fmt" 6 | "reflect" 7 | 8 | "github.com/kshvakov/clickhouse/lib/binary" 9 | ) 10 | 11 | type FixedString struct { 12 | base 13 | len int 14 | scanType reflect.Type 15 | } 16 | 17 | func (str *FixedString) Read(decoder *binary.Decoder) (interface{}, error) { 18 | v, err := decoder.Fixed(str.len) 19 | if err != nil { 20 | return "", err 21 | } 22 | return string(v), nil 23 | } 24 | 25 | func (str *FixedString) Write(encoder *binary.Encoder, v interface{}) error { 26 | var fixedString []byte 27 | switch v := v.(type) { 28 | case string: 29 | fixedString = binary.Str2Bytes(v) 30 | case []byte: 31 | fixedString = v 32 | case encoding.BinaryMarshaler: 33 | bytes, err := v.MarshalBinary() 34 | if err != nil { 35 | return err 36 | } 37 | fixedString = bytes 38 | default: 39 | return &ErrUnexpectedType{ 40 | T: v, 41 | Column: str, 42 | } 43 | } 44 | switch { 45 | case len(fixedString) > str.len: 46 | return fmt.Errorf("too large value '%s' (expected %d, got %d)", fixedString, str.len, len(fixedString)) 47 | case len(fixedString) < str.len: 48 | tmp := make([]byte, str.len) 49 | copy(tmp, fixedString) 50 | fixedString = tmp 51 | } 52 | if _, err := encoder.Write(fixedString); err != nil { 53 | return err 54 | } 55 | return nil 56 | } 57 | 58 | func parseFixedString(name, chType string) (*FixedString, error) { 59 | var strLen int 60 | if _, err := fmt.Sscanf(chType, "FixedString(%d)", &strLen); err != nil { 61 | return nil, err 62 | } 63 | return &FixedString{ 64 | base: base{ 65 | name: name, 66 | chType: chType, 67 | valueOf: baseTypes[string("")], 68 | }, 69 | len: strLen, 70 | }, nil 71 | } 72 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/proto/custom_gogo.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2018, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/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 | // 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 | 29 | package proto 30 | 31 | import "reflect" 32 | 33 | type custom interface { 34 | Marshal() ([]byte, error) 35 | Unmarshal(data []byte) error 36 | Size() int 37 | } 38 | 39 | var customType = reflect.TypeOf((*custom)(nil)).Elem() 40 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/internal/util/parse.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 util 15 | 16 | import ( 17 | "io/ioutil" 18 | "strconv" 19 | "strings" 20 | ) 21 | 22 | // ParseUint32s parses a slice of strings into a slice of uint32s. 23 | func ParseUint32s(ss []string) ([]uint32, error) { 24 | us := make([]uint32, 0, len(ss)) 25 | for _, s := range ss { 26 | u, err := strconv.ParseUint(s, 10, 32) 27 | if err != nil { 28 | return nil, err 29 | } 30 | 31 | us = append(us, uint32(u)) 32 | } 33 | 34 | return us, nil 35 | } 36 | 37 | // ParseUint64s parses a slice of strings into a slice of uint64s. 38 | func ParseUint64s(ss []string) ([]uint64, error) { 39 | us := make([]uint64, 0, len(ss)) 40 | for _, s := range ss { 41 | u, err := strconv.ParseUint(s, 10, 64) 42 | if err != nil { 43 | return nil, err 44 | } 45 | 46 | us = append(us, u) 47 | } 48 | 49 | return us, nil 50 | } 51 | 52 | // ReadUintFromFile reads a file and attempts to parse a uint64 from it. 53 | func ReadUintFromFile(path string) (uint64, error) { 54 | data, err := ioutil.ReadFile(path) 55 | if err != nil { 56 | return 0, err 57 | } 58 | return strconv.ParseUint(strings.TrimSpace(string(data)), 10, 64) 59 | } 60 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, The GoGo Authors. All rights reserved. 2 | 3 | Protocol Buffers for Go with Gadgets 4 | 5 | Go support for Protocol Buffers - Google's data interchange format 6 | 7 | Copyright 2010 The Go Authors. All rights reserved. 8 | https://github.com/golang/protobuf 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are 12 | met: 13 | 14 | * Redistributions of source code must retain the above copyright 15 | notice, this list of conditions and the following disclaimer. 16 | * Redistributions in binary form must reproduce the above 17 | copyright notice, this list of conditions and the following disclaimer 18 | in the documentation and/or other materials provided with the 19 | distribution. 20 | * Neither the name of Google Inc. nor the names of its 21 | contributors may be used to endorse or promote products derived from 22 | this software without specific prior written permission. 23 | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | 36 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_golang/prometheus/untyped.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 | package prometheus 15 | 16 | // UntypedOpts is an alias for Opts. See there for doc comments. 17 | type UntypedOpts Opts 18 | 19 | // UntypedFunc works like GaugeFunc but the collected metric is of type 20 | // "Untyped". UntypedFunc is useful to mirror an external metric of unknown 21 | // type. 22 | // 23 | // To create UntypedFunc instances, use NewUntypedFunc. 24 | type UntypedFunc interface { 25 | Metric 26 | Collector 27 | } 28 | 29 | // NewUntypedFunc creates a new UntypedFunc based on the provided 30 | // UntypedOpts. The value reported is determined by calling the given function 31 | // from within the Write method. Take into account that metric collection may 32 | // happen concurrently. If that results in concurrent calls to Write, like in 33 | // the case where an UntypedFunc is directly registered with Prometheus, the 34 | // provided function must be concurrency-safe. 35 | func NewUntypedFunc(opts UntypedOpts, function func() float64) UntypedFunc { 36 | return newValueFunc(NewDesc( 37 | BuildFQName(opts.Namespace, opts.Subsystem, opts.Name), 38 | opts.Help, 39 | nil, 40 | opts.ConstLabels, 41 | ), UntypedValue, function) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/gogoproto/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/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 | # 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 | 29 | regenerate: 30 | go install github.com/gogo/protobuf/protoc-gen-gogo 31 | protoc --gogo_out=Mgoogle/protobuf/descriptor.proto=github.com/gogo/protobuf/protoc-gen-gogo/descriptor:../../../../ --proto_path=../../../../:../protobuf/:. *.proto 32 | 33 | restore: 34 | cp gogo.pb.golden gogo.pb.go 35 | 36 | preserve: 37 | cp gogo.pb.go gogo.pb.golden 38 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/column/datetime.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/kshvakov/clickhouse/lib/binary" 7 | ) 8 | 9 | type DateTime struct { 10 | base 11 | Timezone *time.Location 12 | } 13 | 14 | func (dt *DateTime) Read(decoder *binary.Decoder) (interface{}, error) { 15 | sec, err := decoder.Int32() 16 | if err != nil { 17 | return nil, err 18 | } 19 | return time.Unix(int64(sec), 0).In(dt.Timezone), nil 20 | } 21 | 22 | func (dt *DateTime) Write(encoder *binary.Encoder, v interface{}) error { 23 | var timestamp int64 24 | switch value := v.(type) { 25 | case time.Time: 26 | timestamp = value.Unix() 27 | case int16: 28 | timestamp = int64(value) 29 | case int32: 30 | timestamp = int64(value) 31 | case int64: 32 | timestamp = value 33 | case string: 34 | var err error 35 | timestamp, err = dt.parse(value) 36 | if err != nil { 37 | return err 38 | } 39 | 40 | // this relies on Nullable never sending nil values through 41 | case *time.Time: 42 | timestamp = (*value).Unix() 43 | case *int16: 44 | timestamp = int64(*value) 45 | case *int32: 46 | timestamp = int64(*value) 47 | case *int64: 48 | timestamp = *value 49 | case *string: 50 | var err error 51 | timestamp, err = dt.parse(*value) 52 | if err != nil { 53 | return err 54 | } 55 | 56 | default: 57 | return &ErrUnexpectedType{ 58 | T: v, 59 | Column: dt, 60 | } 61 | } 62 | 63 | return encoder.Int32(int32(timestamp)) 64 | } 65 | 66 | func (dt *DateTime) parse(value string) (int64, error) { 67 | tv, err := time.Parse("2006-01-02 15:04:05", value) 68 | if err != nil { 69 | return 0, err 70 | } 71 | return time.Date( 72 | time.Time(tv).Year(), 73 | time.Time(tv).Month(), 74 | time.Time(tv).Day(), 75 | time.Time(tv).Hour(), 76 | time.Time(tv).Minute(), 77 | time.Time(tv).Second(), 78 | 0, time.UTC, 79 | ).Unix(), nil 80 | } 81 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/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 test_proto 42 | make -C proto3_proto 43 | make 44 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/proto/lib_gogo.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/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 | // 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 | 29 | package proto 30 | 31 | import ( 32 | "encoding/json" 33 | "strconv" 34 | ) 35 | 36 | type Sizer interface { 37 | Size() int 38 | } 39 | 40 | type ProtoSizer interface { 41 | ProtoSize() int 42 | } 43 | 44 | func MarshalJSONEnum(m map[int32]string, value int32) ([]byte, error) { 45 | s, ok := m[value] 46 | if !ok { 47 | s = strconv.Itoa(int(value)) 48 | } 49 | return json.Marshal(s) 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/column/date.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/kshvakov/clickhouse/lib/binary" 7 | ) 8 | 9 | type Date struct { 10 | base 11 | Timezone *time.Location 12 | offset int64 13 | } 14 | 15 | func (dt *Date) Read(decoder *binary.Decoder) (interface{}, error) { 16 | sec, err := decoder.Int16() 17 | if err != nil { 18 | return nil, err 19 | } 20 | return time.Unix(int64(sec)*24*3600-dt.offset, 0).In(dt.Timezone), nil 21 | } 22 | 23 | func (dt *Date) Write(encoder *binary.Encoder, v interface{}) error { 24 | var timestamp int64 25 | switch value := v.(type) { 26 | case time.Time: 27 | _, offset := value.Zone() 28 | timestamp = value.Unix() + int64(offset) 29 | case int16: 30 | return encoder.Int16(value) 31 | case int32: 32 | timestamp = int64(value) + dt.offset 33 | case int64: 34 | timestamp = value + dt.offset 35 | case string: 36 | var err error 37 | timestamp, err = dt.parse(value) 38 | if err != nil { 39 | return err 40 | } 41 | 42 | // this relies on Nullable never sending nil values through 43 | case *time.Time: 44 | _, offset := value.Zone() 45 | timestamp = (*value).Unix() + int64(offset) 46 | case *int16: 47 | return encoder.Int16(*value) 48 | case *int32: 49 | timestamp = int64(*value) + dt.offset 50 | case *int64: 51 | timestamp = *value + dt.offset 52 | case *string: 53 | var err error 54 | timestamp, err = dt.parse(*value) 55 | if err != nil { 56 | return err 57 | } 58 | 59 | default: 60 | return &ErrUnexpectedType{ 61 | T: v, 62 | Column: dt, 63 | } 64 | } 65 | 66 | return encoder.Int16(int16(timestamp / 24 / 3600)) 67 | } 68 | 69 | func (dt *Date) parse(value string) (int64, error) { 70 | tv, err := time.Parse("2006-01-02", value) 71 | if err != nil { 72 | return 0, err 73 | } 74 | return time.Date( 75 | time.Time(tv).Year(), 76 | time.Time(tv).Month(), 77 | time.Time(tv).Day(), 78 | 0, 0, 0, 0, time.UTC, 79 | ).Unix(), nil 80 | } 81 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/proc_io.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 | "fmt" 18 | "io/ioutil" 19 | "os" 20 | ) 21 | 22 | // ProcIO models the content of /proc//io. 23 | type ProcIO struct { 24 | // Chars read. 25 | RChar uint64 26 | // Chars written. 27 | WChar uint64 28 | // Read syscalls. 29 | SyscR uint64 30 | // Write syscalls. 31 | SyscW uint64 32 | // Bytes read. 33 | ReadBytes uint64 34 | // Bytes written. 35 | WriteBytes uint64 36 | // Bytes written, but taking into account truncation. See 37 | // Documentation/filesystems/proc.txt in the kernel sources for 38 | // detailed explanation. 39 | CancelledWriteBytes int64 40 | } 41 | 42 | // NewIO creates a new ProcIO instance from a given Proc instance. 43 | func (p Proc) NewIO() (ProcIO, error) { 44 | pio := ProcIO{} 45 | 46 | f, err := os.Open(p.path("io")) 47 | if err != nil { 48 | return pio, err 49 | } 50 | defer f.Close() 51 | 52 | data, err := ioutil.ReadAll(f) 53 | if err != nil { 54 | return pio, err 55 | } 56 | 57 | ioFormat := "rchar: %d\nwchar: %d\nsyscr: %d\nsyscw: %d\n" + 58 | "read_bytes: %d\nwrite_bytes: %d\n" + 59 | "cancelled_write_bytes: %d\n" 60 | 61 | _, err = fmt.Sscanf(string(data), ioFormat, &pio.RChar, &pio.WChar, &pio.SyscR, 62 | &pio.SyscW, &pio.ReadBytes, &pio.WriteBytes, &pio.CancelledWriteBytes) 63 | 64 | return pio, err 65 | } 66 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_golang/prometheus/timer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package prometheus 15 | 16 | import "time" 17 | 18 | // Timer is a helper type to time functions. Use NewTimer to create new 19 | // instances. 20 | type Timer struct { 21 | begin time.Time 22 | observer Observer 23 | } 24 | 25 | // NewTimer creates a new Timer. The provided Observer is used to observe a 26 | // duration in seconds. Timer is usually used to time a function call in the 27 | // following way: 28 | // func TimeMe() { 29 | // timer := NewTimer(myHistogram) 30 | // defer timer.ObserveDuration() 31 | // // Do actual work. 32 | // } 33 | func NewTimer(o Observer) *Timer { 34 | return &Timer{ 35 | begin: time.Now(), 36 | observer: o, 37 | } 38 | } 39 | 40 | // ObserveDuration records the duration passed since the Timer was created with 41 | // NewTimer. It calls the Observe method of the Observer provided during 42 | // construction with the duration in seconds as an argument. The observed 43 | // duration is also returned. ObserveDuration is usually called with a defer 44 | // statement. 45 | // 46 | // Note that this method is only guaranteed to never observe negative durations 47 | // if used with Go1.9+. 48 | func (t *Timer) ObserveDuration() time.Duration { 49 | d := time.Since(t.begin) 50 | if t.observer != nil { 51 | t.observer.Observe(d.Seconds()) 52 | } 53 | return d 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_golang/prometheus/observer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package prometheus 15 | 16 | // Observer is the interface that wraps the Observe method, which is used by 17 | // Histogram and Summary to add observations. 18 | type Observer interface { 19 | Observe(float64) 20 | } 21 | 22 | // The ObserverFunc type is an adapter to allow the use of ordinary 23 | // functions as Observers. If f is a function with the appropriate 24 | // signature, ObserverFunc(f) is an Observer that calls f. 25 | // 26 | // This adapter is usually used in connection with the Timer type, and there are 27 | // two general use cases: 28 | // 29 | // The most common one is to use a Gauge as the Observer for a Timer. 30 | // See the "Gauge" Timer example. 31 | // 32 | // The more advanced use case is to create a function that dynamically decides 33 | // which Observer to use for observing the duration. See the "Complex" Timer 34 | // example. 35 | type ObserverFunc func(float64) 36 | 37 | // Observe calls f(value). It implements Observer. 38 | func (f ObserverFunc) Observe(value float64) { 39 | f(value) 40 | } 41 | 42 | // ObserverVec is an interface implemented by `HistogramVec` and `SummaryVec`. 43 | type ObserverVec interface { 44 | GetMetricWith(Labels) (Observer, error) 45 | GetMetricWithLabelValues(lvs ...string) (Observer, error) 46 | With(Labels) Observer 47 | WithLabelValues(...string) Observer 48 | CurryWith(Labels) (ObserverVec, error) 49 | MustCurryWith(Labels) ObserverVec 50 | 51 | Collector 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/binary/compress_writer_clz4.go: -------------------------------------------------------------------------------- 1 | // +build clz4 2 | 3 | package binary 4 | 5 | import ( 6 | "encoding/binary" 7 | "io" 8 | 9 | lz4 "github.com/cloudflare/golz4" 10 | "github.com/kshvakov/clickhouse/lib/cityhash102" 11 | ) 12 | 13 | type compressWriter struct { 14 | writer io.Writer 15 | // data uncompressed 16 | data []byte 17 | // data position 18 | pos int 19 | // data compressed 20 | zdata []byte 21 | } 22 | 23 | // NewCompressWriter wrap the io.Writer 24 | func NewCompressWriter(w io.Writer) *compressWriter { 25 | p := &compressWriter{writer: w} 26 | p.data = make([]byte, BlockMaxSize, BlockMaxSize) 27 | 28 | zlen := lz4.CompressBound(p.data) + HeaderSize 29 | p.zdata = make([]byte, zlen, zlen) 30 | return p 31 | } 32 | 33 | func (cw *compressWriter) Write(buf []byte) (int, error) { 34 | var n int 35 | for len(buf) > 0 { 36 | // Accumulate the data to be compressed. 37 | m := copy(cw.data[cw.pos:], buf) 38 | cw.pos += m 39 | buf = buf[m:] 40 | 41 | if cw.pos == len(cw.data) { 42 | err := cw.Flush() 43 | if err != nil { 44 | return n, err 45 | } 46 | } 47 | n += m 48 | } 49 | return n, nil 50 | } 51 | 52 | func (cw *compressWriter) Flush() (err error) { 53 | if cw.pos == 0 { 54 | return 55 | } 56 | // write the headers 57 | compressedSize, err := lz4.Compress(cw.data[:cw.pos], cw.zdata[HeaderSize:]) 58 | if err != nil { 59 | return err 60 | } 61 | compressedSize += CompressHeaderSize 62 | // fill the header, compressed_size_32 + uncompressed_size_32 63 | cw.zdata[16] = LZ4 64 | binary.LittleEndian.PutUint32(cw.zdata[17:], uint32(compressedSize)) 65 | binary.LittleEndian.PutUint32(cw.zdata[21:], uint32(cw.pos)) 66 | 67 | // fill the checksum 68 | checkSum := cityhash102.CityHash128(cw.zdata[16:], uint32(compressedSize)) 69 | binary.LittleEndian.PutUint64(cw.zdata[0:], checkSum.Lower64()) 70 | binary.LittleEndian.PutUint64(cw.zdata[8:], checkSum.Higher64()) 71 | 72 | cw.writer.Write(cw.zdata[:compressedSize+ChecksumSize]) 73 | if w, ok := cw.writer.(WriteFlusher); ok { 74 | err = w.Flush() 75 | } 76 | cw.pos = 0 77 | return 78 | } 79 | -------------------------------------------------------------------------------- /vendor/modules.txt: -------------------------------------------------------------------------------- 1 | # github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 2 | github.com/beorn7/perks/quantile 3 | # github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 4 | github.com/cloudflare/golz4 5 | # github.com/gogo/protobuf v1.2.1 6 | github.com/gogo/protobuf/gogoproto 7 | github.com/gogo/protobuf/proto 8 | github.com/gogo/protobuf/protoc-gen-gogo/descriptor 9 | # github.com/golang/protobuf v1.3.1 10 | github.com/golang/protobuf/proto 11 | # github.com/kshvakov/clickhouse v1.3.6 12 | github.com/kshvakov/clickhouse 13 | github.com/kshvakov/clickhouse/lib/cityhash102 14 | github.com/kshvakov/clickhouse/lib/data 15 | github.com/kshvakov/clickhouse/lib/binary 16 | github.com/kshvakov/clickhouse/lib/column 17 | github.com/kshvakov/clickhouse/lib/leakypool 18 | github.com/kshvakov/clickhouse/lib/protocol 19 | github.com/kshvakov/clickhouse/lib/types 20 | github.com/kshvakov/clickhouse/lib/writebuffer 21 | github.com/kshvakov/clickhouse/lib/lz4 22 | # github.com/matttproud/golang_protobuf_extensions v1.0.1 23 | github.com/matttproud/golang_protobuf_extensions/pbutil 24 | # github.com/mkevac/gopinba v0.0.0-20171206104754-471ad6b3e951 25 | github.com/mkevac/gopinba 26 | github.com/mkevac/gopinba/Pinba 27 | # github.com/mkevac/monotime v0.0.0-20161125163931-92ece95d55b6 28 | github.com/mkevac/monotime 29 | # github.com/prometheus/client_golang v0.9.2 30 | github.com/prometheus/client_golang/prometheus 31 | github.com/prometheus/client_golang/prometheus/promauto 32 | github.com/prometheus/client_golang/prometheus/promhttp 33 | github.com/prometheus/client_golang/prometheus/internal 34 | # github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 35 | github.com/prometheus/client_model/go 36 | # github.com/prometheus/common v0.0.0-20181126121408-4724e9255275 37 | github.com/prometheus/common/expfmt 38 | github.com/prometheus/common/model 39 | github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg 40 | # github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a 41 | github.com/prometheus/procfs 42 | github.com/prometheus/procfs/nfs 43 | github.com/prometheus/procfs/xfs 44 | github.com/prometheus/procfs/internal/util 45 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/binary/compress_writer.go: -------------------------------------------------------------------------------- 1 | // +build !clz4 2 | 3 | package binary 4 | 5 | import ( 6 | "encoding/binary" 7 | "io" 8 | 9 | "github.com/kshvakov/clickhouse/lib/cityhash102" 10 | "github.com/kshvakov/clickhouse/lib/lz4" 11 | ) 12 | 13 | type compressWriter struct { 14 | writer io.Writer 15 | // data uncompressed 16 | data []byte 17 | // data position 18 | pos int 19 | // data compressed 20 | zdata []byte 21 | } 22 | 23 | // NewCompressWriter wrap the io.Writer 24 | func NewCompressWriter(w io.Writer) *compressWriter { 25 | p := &compressWriter{writer: w} 26 | p.data = make([]byte, BlockMaxSize, BlockMaxSize) 27 | 28 | zlen := lz4.CompressBound(BlockMaxSize) + HeaderSize 29 | p.zdata = make([]byte, zlen, zlen) 30 | return p 31 | } 32 | 33 | func (cw *compressWriter) Write(buf []byte) (int, error) { 34 | var n int 35 | for len(buf) > 0 { 36 | // Accumulate the data to be compressed. 37 | m := copy(cw.data[cw.pos:], buf) 38 | cw.pos += m 39 | buf = buf[m:] 40 | 41 | if cw.pos == len(cw.data) { 42 | err := cw.Flush() 43 | if err != nil { 44 | return n, err 45 | } 46 | } 47 | n += m 48 | } 49 | return n, nil 50 | } 51 | 52 | func (cw *compressWriter) Flush() (err error) { 53 | if cw.pos == 0 { 54 | return 55 | } 56 | 57 | // write the headers 58 | compressedSize, err := lz4.Encode(cw.zdata[HeaderSize:], cw.data[:cw.pos]) 59 | if err != nil { 60 | return err 61 | } 62 | compressedSize += CompressHeaderSize 63 | // fill the header, compressed_size_32 + uncompressed_size_32 64 | cw.zdata[16] = LZ4 65 | binary.LittleEndian.PutUint32(cw.zdata[17:], uint32(compressedSize)) 66 | binary.LittleEndian.PutUint32(cw.zdata[21:], uint32(cw.pos)) 67 | 68 | // fill the checksum 69 | checkSum := cityhash102.CityHash128(cw.zdata[16:], uint32(compressedSize)) 70 | binary.LittleEndian.PutUint64(cw.zdata[0:], checkSum.Lower64()) 71 | binary.LittleEndian.PutUint64(cw.zdata[8:], checkSum.Higher64()) 72 | 73 | cw.writer.Write(cw.zdata[:compressedSize+ChecksumSize]) 74 | if w, ok := cw.writer.(WriteFlusher); ok { 75 | err = w.Flush() 76 | } 77 | cw.pos = 0 78 | return 79 | } 80 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/protoc-gen-gogo/descriptor/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 | regenerate: 33 | go install github.com/gogo/protobuf/protoc-gen-gogo 34 | go install github.com/gogo/protobuf/protoc-gen-gostring 35 | protoc --gogo_out=. -I=../../protobuf/google/protobuf ../../protobuf/google/protobuf/descriptor.proto 36 | protoc --gostring_out=. -I=../../protobuf/google/protobuf ../../protobuf/google/protobuf/descriptor.proto 37 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/proto/duration_gogo.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2016, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/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 | // 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 | 29 | package proto 30 | 31 | import ( 32 | "reflect" 33 | "time" 34 | ) 35 | 36 | var durationType = reflect.TypeOf((*time.Duration)(nil)).Elem() 37 | 38 | type duration struct { 39 | Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"` 40 | Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"` 41 | } 42 | 43 | func (m *duration) Reset() { *m = duration{} } 44 | func (*duration) ProtoMessage() {} 45 | func (*duration) String() string { return "duration" } 46 | 47 | func init() { 48 | RegisterType((*duration)(nil), "gogo.protobuf.proto.duration") 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/proto/timestamp_gogo.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2016, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/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 | // 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 | 29 | package proto 30 | 31 | import ( 32 | "reflect" 33 | "time" 34 | ) 35 | 36 | var timeType = reflect.TypeOf((*time.Time)(nil)).Elem() 37 | 38 | type timestamp struct { 39 | Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"` 40 | Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"` 41 | } 42 | 43 | func (m *timestamp) Reset() { *m = timestamp{} } 44 | func (*timestamp) ProtoMessage() {} 45 | func (*timestamp) String() string { return "timestamp" } 46 | 47 | func init() { 48 | RegisterType((*timestamp)(nil), "gogo.protobuf.proto.timestamp") 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/proto/text_gogo.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/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 | // 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 | 29 | package proto 30 | 31 | import ( 32 | "fmt" 33 | "reflect" 34 | ) 35 | 36 | func (tm *TextMarshaler) writeEnum(w *textWriter, v reflect.Value, props *Properties) error { 37 | m, ok := enumStringMaps[props.Enum] 38 | if !ok { 39 | if err := tm.writeAny(w, v, props); err != nil { 40 | return err 41 | } 42 | } 43 | key := int32(0) 44 | if v.Kind() == reflect.Ptr { 45 | key = int32(v.Elem().Int()) 46 | } else { 47 | key = int32(v.Int()) 48 | } 49 | s, ok := m[key] 50 | if !ok { 51 | if err := tm.writeAny(w, v, props); err != nil { 52 | return err 53 | } 54 | } 55 | _, err := fmt.Fprint(w, s) 56 | return err 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/nfs/parse_nfs.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 nfs 15 | 16 | import ( 17 | "bufio" 18 | "fmt" 19 | "io" 20 | "strings" 21 | 22 | "github.com/prometheus/procfs/internal/util" 23 | ) 24 | 25 | // ParseClientRPCStats returns stats read from /proc/net/rpc/nfs 26 | func ParseClientRPCStats(r io.Reader) (*ClientRPCStats, error) { 27 | stats := &ClientRPCStats{} 28 | 29 | scanner := bufio.NewScanner(r) 30 | for scanner.Scan() { 31 | line := scanner.Text() 32 | parts := strings.Fields(scanner.Text()) 33 | // require at least 34 | if len(parts) < 2 { 35 | return nil, fmt.Errorf("invalid NFS metric line %q", line) 36 | } 37 | 38 | values, err := util.ParseUint64s(parts[1:]) 39 | if err != nil { 40 | return nil, fmt.Errorf("error parsing NFS metric line: %s", err) 41 | } 42 | 43 | switch metricLine := parts[0]; metricLine { 44 | case "net": 45 | stats.Network, err = parseNetwork(values) 46 | case "rpc": 47 | stats.ClientRPC, err = parseClientRPC(values) 48 | case "proc2": 49 | stats.V2Stats, err = parseV2Stats(values) 50 | case "proc3": 51 | stats.V3Stats, err = parseV3Stats(values) 52 | case "proc4": 53 | stats.ClientV4Stats, err = parseClientV4Stats(values) 54 | default: 55 | return nil, fmt.Errorf("unknown NFS metric line %q", metricLine) 56 | } 57 | if err != nil { 58 | return nil, fmt.Errorf("errors parsing NFS metric line: %s", err) 59 | } 60 | } 61 | 62 | if err := scanner.Err(); err != nil { 63 | return nil, fmt.Errorf("error scanning NFS file: %s", err) 64 | } 65 | 66 | return stats, nil 67 | } 68 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/column/nullable.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | "time" 7 | 8 | "github.com/kshvakov/clickhouse/lib/binary" 9 | ) 10 | 11 | type Nullable struct { 12 | base 13 | column Column 14 | } 15 | 16 | func (null *Nullable) ScanType() reflect.Type { 17 | return null.column.ScanType() 18 | } 19 | 20 | func (null *Nullable) Read(decoder *binary.Decoder) (interface{}, error) { 21 | return null.column.Read(decoder) 22 | } 23 | 24 | func (null *Nullable) Write(encoder *binary.Encoder, v interface{}) error { 25 | return nil 26 | } 27 | 28 | func (null *Nullable) ReadNull(decoder *binary.Decoder, rows int) (_ []interface{}, err error) { 29 | var ( 30 | isNull byte 31 | value interface{} 32 | nulls = make([]byte, rows) 33 | values = make([]interface{}, rows) 34 | ) 35 | for i := 0; i < rows; i++ { 36 | if isNull, err = decoder.ReadByte(); err != nil { 37 | return nil, err 38 | } 39 | nulls[i] = isNull 40 | } 41 | for i, isNull := range nulls { 42 | switch value, err = null.column.Read(decoder); true { 43 | case err != nil: 44 | return nil, err 45 | case isNull == 0: 46 | values[i] = value 47 | default: 48 | values[i] = nil 49 | } 50 | } 51 | return values, nil 52 | } 53 | func (null *Nullable) WriteNull(nulls, encoder *binary.Encoder, v interface{}) error { 54 | if value := reflect.ValueOf(v); v == nil || (value.Kind() == reflect.Ptr && value.IsNil()) { 55 | if _, err := nulls.Write([]byte{1}); err != nil { 56 | return err 57 | } 58 | return null.column.Write(encoder, null.column.defaultValue()) 59 | } 60 | if _, err := nulls.Write([]byte{0}); err != nil { 61 | return err 62 | } 63 | return null.column.Write(encoder, v) 64 | } 65 | 66 | func parseNullable(name, chType string, timezone *time.Location) (*Nullable, error) { 67 | if len(chType) < 14 { 68 | return nil, fmt.Errorf("invalid Nullable column type: %s", chType) 69 | } 70 | column, err := Factory(name, chType[9:][:len(chType)-10], timezone) 71 | if err != nil { 72 | return nil, fmt.Errorf("Nullable(T): %v", err) 73 | } 74 | return &Nullable{ 75 | base: base{ 76 | name: name, 77 | chType: chType, 78 | }, 79 | column: column, 80 | }, nil 81 | } 82 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/proc_ns.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 | "fmt" 18 | "os" 19 | "strconv" 20 | "strings" 21 | ) 22 | 23 | // Namespace represents a single namespace of a process. 24 | type Namespace struct { 25 | Type string // Namespace type. 26 | Inode uint32 // Inode number of the namespace. If two processes are in the same namespace their inodes will match. 27 | } 28 | 29 | // Namespaces contains all of the namespaces that the process is contained in. 30 | type Namespaces map[string]Namespace 31 | 32 | // NewNamespaces reads from /proc/[pid/ns/* to get the namespaces of which the 33 | // process is a member. 34 | func (p Proc) NewNamespaces() (Namespaces, error) { 35 | d, err := os.Open(p.path("ns")) 36 | if err != nil { 37 | return nil, err 38 | } 39 | defer d.Close() 40 | 41 | names, err := d.Readdirnames(-1) 42 | if err != nil { 43 | return nil, fmt.Errorf("failed to read contents of ns dir: %v", err) 44 | } 45 | 46 | ns := make(Namespaces, len(names)) 47 | for _, name := range names { 48 | target, err := os.Readlink(p.path("ns", name)) 49 | if err != nil { 50 | return nil, err 51 | } 52 | 53 | fields := strings.SplitN(target, ":", 2) 54 | if len(fields) != 2 { 55 | return nil, fmt.Errorf("failed to parse namespace type and inode from '%v'", target) 56 | } 57 | 58 | typ := fields[0] 59 | inode, err := strconv.ParseUint(strings.Trim(fields[1], "[]"), 10, 32) 60 | if err != nil { 61 | return nil, fmt.Errorf("failed to parse inode from '%v': %v", fields[1], err) 62 | } 63 | 64 | ns[name] = Namespace{typ, uint32(inode)} 65 | } 66 | 67 | return ns, nil 68 | } 69 | -------------------------------------------------------------------------------- /vendor/github.com/mkevac/gopinba/Pinba/pinba.proto: -------------------------------------------------------------------------------- 1 | package Pinba; 2 | option optimize_for = LITE_RUNTIME; 3 | 4 | // to generate .pb.go, run something like this 5 | // $ cd pinba/proto 6 | // $ protoc --gogo_out=. -I$GOPATH/src:$GOPATH/src/github.com/gogo/protobuf/protobuf:. pinba.proto 7 | 8 | // gogoprotobuf page and build instructions: https://github.com/gogo/protobuf 9 | // options we use: 10 | // sizer_all, unsafe_marshaler_all, unsafe_unmarshaler_all - generate marshal/unmarshal code for each message (fast fast!) 11 | // (gogoproto.nullable) = false - generate non pointer fields (reduces GC pressure, most fields are of primitive type anyway) 12 | 13 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 14 | option (gogoproto.sizer_all) = true; 15 | option (gogoproto.unsafe_marshaler_all) = true; 16 | option (gogoproto.unsafe_unmarshaler_all) = true; 17 | 18 | message Request { 19 | required string hostname = 1 [(gogoproto.nullable) = false]; 20 | required string server_name = 2 [(gogoproto.nullable) = false]; 21 | required string script_name = 3 [(gogoproto.nullable) = false]; 22 | required uint32 request_count = 4 [(gogoproto.nullable) = false]; 23 | required uint32 document_size = 5 [(gogoproto.nullable) = false]; 24 | required uint32 memory_peak = 6 [(gogoproto.nullable) = false]; 25 | required float request_time = 7 [(gogoproto.nullable) = false]; 26 | required float ru_utime = 8 [(gogoproto.nullable) = false]; 27 | required float ru_stime = 9 [(gogoproto.nullable) = false]; 28 | 29 | repeated uint32 timer_hit_count = 10; 30 | repeated float timer_value = 11; 31 | repeated uint32 timer_tag_count = 12; 32 | repeated uint32 timer_tag_name = 13; 33 | repeated uint32 timer_tag_value = 14; 34 | repeated string dictionary = 15; 35 | optional uint32 status = 16 [(gogoproto.nullable) = false]; 36 | optional uint32 memory_footprint = 17 [(gogoproto.nullable) = false]; // allow nullable maybe? 37 | repeated Request requests = 18 [(gogoproto.nullable) = false]; // allow nullable maybe? 38 | optional string schema = 19 [(gogoproto.nullable) = false]; // allow nullable maybe? 39 | repeated uint32 tag_name = 20; 40 | repeated uint32 tag_value = 21; 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/proto/pointer_unsafe_gogo.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2018, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/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 | // 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 | 29 | // +build !purego,!appengine,!js 30 | 31 | // This file contains the implementation of the proto field accesses using package unsafe. 32 | 33 | package proto 34 | 35 | import ( 36 | "reflect" 37 | "unsafe" 38 | ) 39 | 40 | func (p pointer) getRef() pointer { 41 | return pointer{p: (unsafe.Pointer)(&p.p)} 42 | } 43 | 44 | func (p pointer) appendRef(v pointer, typ reflect.Type) { 45 | slice := p.getSlice(typ) 46 | elem := v.asPointerTo(typ).Elem() 47 | newSlice := reflect.Append(slice, elem) 48 | slice.Set(newSlice) 49 | } 50 | 51 | func (p pointer) getSlice(typ reflect.Type) reflect.Value { 52 | sliceTyp := reflect.SliceOf(typ) 53 | slice := p.asPointerTo(sliceTyp) 54 | slice = slice.Elem() 55 | return slice 56 | } 57 | -------------------------------------------------------------------------------- /src/server/server_requests.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "log" 5 | "time" 6 | ) 7 | 8 | func (server *server) background() { 9 | for tick := time.Tick(time.Second); ; { 10 | block := server.block.Copy() 11 | loop: 12 | for block.Reserve(); ; { 13 | select { 14 | case request := <-server.reqBacklog: 15 | block.NumRows++ 16 | block.WriteString(0, request.GetHostname()) 17 | block.WriteString(1, request.GetSchema()) 18 | block.WriteInt16(2, int16(request.GetStatus())) 19 | block.WriteString(3, request.GetServerName()) 20 | block.WriteString(4, request.GetScriptName()) 21 | block.WriteUInt32(5, request.GetRequestCount()) 22 | block.WriteFloat32(6, request.GetRequestTime()) 23 | block.WriteUInt32(7, request.GetDocumentSize()) 24 | block.WriteUInt32(8, request.GetMemoryPeak()) 25 | block.WriteUInt32(9, request.GetMemoryFootprint()) 26 | block.WriteFloat32(10, request.GetRuUtime()) 27 | block.WriteFloat32(11, request.GetRuStime()) 28 | tagName, tagValue := request.tags() 29 | { 30 | block.WriteArray(12, tagName) 31 | block.WriteArray(13, tagValue) 32 | } 33 | // timer 34 | block.WriteArray(14, request.TimerHitCount) 35 | block.WriteArray(15, request.GetTimerValue()) 36 | block.WriteArray(16, request.GetTimerRuStime()) 37 | block.WriteArray(17, request.GetTimerRuUtime()) 38 | timerTagName, timerTagValue := request.timerTags() 39 | { 40 | block.WriteArray(18, timerTagName) 41 | block.WriteArray(19, timerTagValue) 42 | } 43 | block.WriteUInt32(20, request.timestamp) 44 | case <-tick: 45 | break loop 46 | } 47 | } 48 | opsReqProcessed.Add(float64(block.NumRows)) 49 | if err := server.writeBlock(insertIntoRequestsSQL, block); err != nil { 50 | log.Println("request write error: ", err) 51 | } 52 | } 53 | } 54 | 55 | const ( 56 | insertIntoRequestsSQL = ` 57 | INSERT INTO proton.requests ( 58 | Hostname 59 | , Schema 60 | , Status 61 | , ServerName 62 | , ScriptName 63 | , RequestCount 64 | , RequestTime 65 | , DocumentSize 66 | , MemoryPeak 67 | , MemoryFootprint 68 | , Utime 69 | , Stime 70 | , Tags.Name 71 | , Tags.Value 72 | , Timers.HitCount 73 | , Timers.Value 74 | , Timers.Utime 75 | , Timers.Stime 76 | , Timers.TagsName 77 | , Timers.TagsValue 78 | , Timestamp 79 | ) VALUES ( 80 | ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 81 | ?, ?, ?, ?, ?, ?, ?, ?, 82 | ?, ?, ? 83 | ) 84 | ` 85 | ) 86 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/proto/pointer_reflect_gogo.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2018, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/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 | // 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 | 29 | // +build purego appengine js 30 | 31 | // This file contains an implementation of proto field accesses using package reflect. 32 | // It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can 33 | // be used on App Engine. 34 | 35 | package proto 36 | 37 | import ( 38 | "reflect" 39 | ) 40 | 41 | // TODO: untested, so probably incorrect. 42 | 43 | func (p pointer) getRef() pointer { 44 | return pointer{v: p.v.Addr()} 45 | } 46 | 47 | func (p pointer) appendRef(v pointer, typ reflect.Type) { 48 | slice := p.getSlice(typ) 49 | elem := v.asPointerTo(typ).Elem() 50 | newSlice := reflect.Append(slice, elem) 51 | slice.Set(newSlice) 52 | } 53 | 54 | func (p pointer) getSlice(typ reflect.Type) reflect.Value { 55 | sliceTyp := reflect.SliceOf(typ) 56 | slice := p.asPointerTo(sliceTyp) 57 | slice = slice.Elem() 58 | return slice 59 | } 60 | -------------------------------------------------------------------------------- /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/procfs/fs.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 | "fmt" 18 | "os" 19 | "path" 20 | 21 | "github.com/prometheus/procfs/nfs" 22 | "github.com/prometheus/procfs/xfs" 23 | ) 24 | 25 | // FS represents the pseudo-filesystem proc, which provides an interface to 26 | // kernel data structures. 27 | type FS string 28 | 29 | // DefaultMountPoint is the common mount point of the proc filesystem. 30 | const DefaultMountPoint = "/proc" 31 | 32 | // NewFS returns a new FS mounted under the given mountPoint. It will error 33 | // if the mount point can't be read. 34 | func NewFS(mountPoint string) (FS, error) { 35 | info, err := os.Stat(mountPoint) 36 | if err != nil { 37 | return "", fmt.Errorf("could not read %s: %s", mountPoint, err) 38 | } 39 | if !info.IsDir() { 40 | return "", fmt.Errorf("mount point %s is not a directory", mountPoint) 41 | } 42 | 43 | return FS(mountPoint), nil 44 | } 45 | 46 | // Path returns the path of the given subsystem relative to the procfs root. 47 | func (fs FS) Path(p ...string) string { 48 | return path.Join(append([]string{string(fs)}, p...)...) 49 | } 50 | 51 | // XFSStats retrieves XFS filesystem runtime statistics. 52 | func (fs FS) XFSStats() (*xfs.Stats, error) { 53 | f, err := os.Open(fs.Path("fs/xfs/stat")) 54 | if err != nil { 55 | return nil, err 56 | } 57 | defer f.Close() 58 | 59 | return xfs.ParseStats(f) 60 | } 61 | 62 | // NFSClientRPCStats retrieves NFS client RPC statistics. 63 | func (fs FS) NFSClientRPCStats() (*nfs.ClientRPCStats, error) { 64 | f, err := os.Open(fs.Path("net/rpc/nfs")) 65 | if err != nil { 66 | return nil, err 67 | } 68 | defer f.Close() 69 | 70 | return nfs.ParseClientRPCStats(f) 71 | } 72 | 73 | // NFSdServerRPCStats retrieves NFS daemon RPC statistics. 74 | func (fs FS) NFSdServerRPCStats() (*nfs.ServerRPCStats, error) { 75 | f, err := os.Open(fs.Path("net/rpc/nfsd")) 76 | if err != nil { 77 | return nil, err 78 | } 79 | defer f.Close() 80 | 81 | return nfs.ParseServerRPCStats(f) 82 | } 83 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/binary/compress_reader_clz4.go: -------------------------------------------------------------------------------- 1 | // +build clz4 2 | 3 | package binary 4 | 5 | import ( 6 | "encoding/binary" 7 | "fmt" 8 | "io" 9 | 10 | lz4 "github.com/cloudflare/golz4" 11 | ) 12 | 13 | type compressReader struct { 14 | reader io.Reader 15 | // data uncompressed 16 | data []byte 17 | // data position 18 | pos int 19 | // data compressed 20 | zdata []byte 21 | // lz4 headers 22 | header []byte 23 | } 24 | 25 | // NewCompressReader wrap the io.Reader 26 | func NewCompressReader(r io.Reader) *compressReader { 27 | p := &compressReader{ 28 | reader: r, 29 | header: make([]byte, HeaderSize), 30 | } 31 | p.data = make([]byte, BlockMaxSize, BlockMaxSize) 32 | 33 | zlen := lz4.CompressBound(p.data) + HeaderSize 34 | p.zdata = make([]byte, zlen, zlen) 35 | 36 | p.pos = len(p.data) 37 | return p 38 | } 39 | 40 | func (cr *compressReader) Read(buf []byte) (n int, err error) { 41 | var bytesRead = 0 42 | n = len(buf) 43 | 44 | if cr.pos < len(cr.data) { 45 | copyedSize := copy(buf, cr.data[cr.pos:]) 46 | 47 | bytesRead += copyedSize 48 | cr.pos += copyedSize 49 | } 50 | 51 | for bytesRead < n { 52 | if err = cr.readCompressedData(); err != nil { 53 | return bytesRead, err 54 | } 55 | if len(cr.data) < n-bytesRead { 56 | bytesRead += len(cr.data) 57 | } else { 58 | bytesRead += n - bytesRead 59 | cr.pos += n - bytesRead 60 | break 61 | } 62 | } 63 | return n, nil 64 | } 65 | 66 | func (cr *compressReader) readCompressedData() (err error) { 67 | cr.pos = 0 68 | var n int 69 | n, err = cr.reader.Read(cr.header) 70 | if err != nil { 71 | return 72 | } 73 | if n != len(cr.header) { 74 | return fmt.Errorf("Lz4 decompression header EOF") 75 | } 76 | 77 | compressedSize := int(binary.LittleEndian.Uint32(cr.header[17:])) - 9 78 | decompressedSize := int(binary.LittleEndian.Uint32(cr.header[21:])) 79 | 80 | if compressedSize > cap(cr.zdata) { 81 | cr.zdata = make([]byte, compressedSize) 82 | } 83 | if decompressedSize > cap(cr.data) { 84 | cr.data = make([]byte, decompressedSize) 85 | } 86 | 87 | cr.zdata = cr.zdata[:compressedSize] 88 | cr.data = cr.data[:decompressedSize] 89 | 90 | // @TODO checksum 91 | if cr.header[16] == LZ4 { 92 | n, err = cr.reader.Read(cr.zdata) 93 | if err != nil { 94 | return 95 | } 96 | 97 | if n != len(cr.zdata) { 98 | return fmt.Errorf("Decompress read size not match") 99 | } 100 | 101 | err = lz4.Uncompress(cr.zdata, cr.data) 102 | if err != nil { 103 | return 104 | } 105 | } else { 106 | return fmt.Errorf("Unknown compression method: %d ", cr.header[0]) 107 | } 108 | 109 | return nil 110 | } 111 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/binary/compress_reader.go: -------------------------------------------------------------------------------- 1 | // +build !clz4 2 | 3 | package binary 4 | 5 | import ( 6 | "encoding/binary" 7 | "fmt" 8 | "io" 9 | 10 | "github.com/kshvakov/clickhouse/lib/lz4" 11 | ) 12 | 13 | type compressReader struct { 14 | reader io.Reader 15 | // data uncompressed 16 | data []byte 17 | // data position 18 | pos int 19 | // data compressed 20 | zdata []byte 21 | // lz4 headers 22 | header []byte 23 | } 24 | 25 | // NewCompressReader wrap the io.Reader 26 | func NewCompressReader(r io.Reader) *compressReader { 27 | p := &compressReader{ 28 | reader: r, 29 | header: make([]byte, HeaderSize), 30 | } 31 | p.data = make([]byte, BlockMaxSize, BlockMaxSize) 32 | 33 | zlen := lz4.CompressBound(BlockMaxSize) + HeaderSize 34 | p.zdata = make([]byte, zlen, zlen) 35 | 36 | p.pos = len(p.data) 37 | return p 38 | } 39 | 40 | func (cr *compressReader) Read(buf []byte) (n int, err error) { 41 | var bytesRead = 0 42 | n = len(buf) 43 | 44 | if cr.pos < len(cr.data) { 45 | copyedSize := copy(buf, cr.data[cr.pos:]) 46 | 47 | bytesRead += copyedSize 48 | cr.pos += copyedSize 49 | } 50 | 51 | for bytesRead < n { 52 | if err = cr.readCompressedData(); err != nil { 53 | return bytesRead, err 54 | } 55 | if len(cr.data) < n-bytesRead { 56 | bytesRead += len(cr.data) 57 | } else { 58 | bytesRead += n - bytesRead 59 | cr.pos += n - bytesRead 60 | break 61 | } 62 | } 63 | return n, nil 64 | } 65 | 66 | func (cr *compressReader) readCompressedData() (err error) { 67 | cr.pos = 0 68 | var n int 69 | n, err = cr.reader.Read(cr.header) 70 | if err != nil { 71 | return 72 | } 73 | if n != len(cr.header) { 74 | return fmt.Errorf("Lz4 decompression header EOF") 75 | } 76 | 77 | compressedSize := int(binary.LittleEndian.Uint32(cr.header[17:])) - 9 78 | decompressedSize := int(binary.LittleEndian.Uint32(cr.header[21:])) 79 | 80 | if compressedSize > cap(cr.zdata) { 81 | cr.zdata = make([]byte, compressedSize) 82 | } 83 | if decompressedSize > cap(cr.data) { 84 | cr.data = make([]byte, decompressedSize) 85 | } 86 | 87 | cr.zdata = cr.zdata[:compressedSize] 88 | cr.data = cr.data[:decompressedSize] 89 | 90 | // @TODO checksum 91 | if cr.header[16] == LZ4 { 92 | n, err = cr.reader.Read(cr.zdata) 93 | if err != nil { 94 | return 95 | } 96 | 97 | if n != len(cr.zdata) { 98 | return fmt.Errorf("Decompress read size not match") 99 | } 100 | 101 | _, err = lz4.Decode(cr.data, cr.zdata) 102 | if err != nil { 103 | return 104 | } 105 | } else { 106 | return fmt.Errorf("Unknown compression method: %d ", cr.header[0]) 107 | } 108 | 109 | return nil 110 | } 111 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/proto/deprecated.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2018 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 | package proto 33 | 34 | import "errors" 35 | 36 | // Deprecated: do not use. 37 | type Stats struct{ Emalloc, Dmalloc, Encode, Decode, Chit, Cmiss, Size uint64 } 38 | 39 | // Deprecated: do not use. 40 | func GetStats() Stats { return Stats{} } 41 | 42 | // Deprecated: do not use. 43 | func MarshalMessageSet(interface{}) ([]byte, error) { 44 | return nil, errors.New("proto: not implemented") 45 | } 46 | 47 | // Deprecated: do not use. 48 | func UnmarshalMessageSet([]byte, interface{}) error { 49 | return errors.New("proto: not implemented") 50 | } 51 | 52 | // Deprecated: do not use. 53 | func MarshalMessageSetJSON(interface{}) ([]byte, error) { 54 | return nil, errors.New("proto: not implemented") 55 | } 56 | 57 | // Deprecated: do not use. 58 | func UnmarshalMessageSetJSON([]byte, interface{}) error { 59 | return errors.New("proto: not implemented") 60 | } 61 | 62 | // Deprecated: do not use. 63 | func RegisterMessageSetType(Message, int32, string) {} 64 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/deprecated.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2018 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 | package proto 33 | 34 | import "errors" 35 | 36 | // Deprecated: do not use. 37 | type Stats struct{ Emalloc, Dmalloc, Encode, Decode, Chit, Cmiss, Size uint64 } 38 | 39 | // Deprecated: do not use. 40 | func GetStats() Stats { return Stats{} } 41 | 42 | // Deprecated: do not use. 43 | func MarshalMessageSet(interface{}) ([]byte, error) { 44 | return nil, errors.New("proto: not implemented") 45 | } 46 | 47 | // Deprecated: do not use. 48 | func UnmarshalMessageSet([]byte, interface{}) error { 49 | return errors.New("proto: not implemented") 50 | } 51 | 52 | // Deprecated: do not use. 53 | func MarshalMessageSetJSON(interface{}) ([]byte, error) { 54 | return nil, errors.New("proto: not implemented") 55 | } 56 | 57 | // Deprecated: do not use. 58 | func UnmarshalMessageSetJSON([]byte, interface{}) error { 59 | return errors.New("proto: not implemented") 60 | } 61 | 62 | // Deprecated: do not use. 63 | func RegisterMessageSetType(Message, int32, string) {} 64 | -------------------------------------------------------------------------------- /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(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/kshvakov/clickhouse/lib/data/block_write_column.go: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | "time" 7 | 8 | "github.com/kshvakov/clickhouse/lib/binary" 9 | ) 10 | 11 | func (block *Block) WriteDate(c int, v time.Time) error { 12 | _, offset := v.Zone() 13 | nday := (v.Unix() + int64(offset)) / 24 / 3600 14 | return block.buffers[c].Column.UInt16(uint16(nday)) 15 | } 16 | 17 | func (block *Block) WriteDateTime(c int, v time.Time) error { 18 | return block.buffers[c].Column.UInt32(uint32(v.Unix())) 19 | } 20 | 21 | func (block *Block) WriteBool(c int, v bool) error { 22 | if v { 23 | return block.buffers[c].Column.UInt8(1) 24 | } 25 | return block.buffers[c].Column.UInt8(0) 26 | } 27 | 28 | func (block *Block) WriteInt8(c int, v int8) error { 29 | return block.buffers[c].Column.Int8(v) 30 | } 31 | 32 | func (block *Block) WriteInt16(c int, v int16) error { 33 | return block.buffers[c].Column.Int16(v) 34 | } 35 | 36 | func (block *Block) WriteInt32(c int, v int32) error { 37 | return block.buffers[c].Column.Int32(v) 38 | } 39 | 40 | func (block *Block) WriteInt64(c int, v int64) error { 41 | return block.buffers[c].Column.Int64(v) 42 | } 43 | 44 | func (block *Block) WriteUInt8(c int, v uint8) error { 45 | return block.buffers[c].Column.UInt8(v) 46 | } 47 | 48 | func (block *Block) WriteUInt16(c int, v uint16) error { 49 | return block.buffers[c].Column.UInt16(v) 50 | } 51 | 52 | func (block *Block) WriteUInt32(c int, v uint32) error { 53 | return block.buffers[c].Column.UInt32(v) 54 | } 55 | 56 | func (block *Block) WriteUInt64(c int, v uint64) error { 57 | return block.buffers[c].Column.UInt64(v) 58 | } 59 | 60 | func (block *Block) WriteFloat32(c int, v float32) error { 61 | return block.buffers[c].Column.Float32(v) 62 | } 63 | 64 | func (block *Block) WriteFloat64(c int, v float64) error { 65 | return block.buffers[c].Column.Float64(v) 66 | } 67 | 68 | func (block *Block) WriteBytes(c int, v []byte) error { 69 | if err := block.buffers[c].Column.Uvarint(uint64(len(v))); err != nil { 70 | return err 71 | } 72 | if _, err := block.buffers[c].Column.Write(v); err != nil { 73 | return err 74 | } 75 | return nil 76 | } 77 | 78 | func (block *Block) WriteString(c int, v string) error { 79 | if err := block.buffers[c].Column.Uvarint(uint64(len(v))); err != nil { 80 | return err 81 | } 82 | if _, err := block.buffers[c].Column.Write(binary.Str2Bytes(v)); err != nil { 83 | return err 84 | } 85 | return nil 86 | } 87 | 88 | func (block *Block) WriteFixedString(c int, v []byte) error { 89 | return block.Columns[c].Write(block.buffers[c].Column, v) 90 | } 91 | 92 | func (block *Block) WriteArray(c int, v interface{}) error { 93 | value := reflect.ValueOf(v) 94 | if value.Kind() != reflect.Slice { 95 | return fmt.Errorf("unsupported Array(T) type [%T]", value.Interface()) 96 | } 97 | return block.writeArray(block.Columns[c], value, c, 1) 98 | } 99 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/lib/writebuffer/buffer.go: -------------------------------------------------------------------------------- 1 | package writebuffer 2 | 3 | import ( 4 | "io" 5 | 6 | "github.com/kshvakov/clickhouse/lib/leakypool" 7 | ) 8 | 9 | const InitialSize = 256 * 1024 10 | 11 | func New(initSize int) *WriteBuffer { 12 | wb := &WriteBuffer{} 13 | wb.addChunk(0, initSize) 14 | return wb 15 | } 16 | 17 | type WriteBuffer struct { 18 | chunks [][]byte 19 | } 20 | 21 | func (wb *WriteBuffer) Write(data []byte) (int, error) { 22 | var ( 23 | chunkIdx = len(wb.chunks) - 1 24 | dataSize = len(data) 25 | ) 26 | for { 27 | freeSize := cap(wb.chunks[chunkIdx]) - len(wb.chunks[chunkIdx]) 28 | if freeSize >= dataSize { 29 | wb.chunks[chunkIdx] = append(wb.chunks[chunkIdx], data...) 30 | return dataSize, nil 31 | } 32 | wb.chunks[chunkIdx] = append(wb.chunks[chunkIdx], data[:freeSize]...) 33 | data = data[freeSize:] 34 | wb.addChunk(0, wb.calcCap(dataSize)) 35 | chunkIdx++ 36 | } 37 | } 38 | 39 | func (wb *WriteBuffer) WriteTo(w io.Writer) (int64, error) { 40 | var size int64 41 | for _, chunk := range wb.chunks { 42 | ln, err := w.Write(chunk) 43 | if err != nil { 44 | wb.Reset() 45 | return 0, err 46 | } 47 | size += int64(ln) 48 | } 49 | wb.Reset() 50 | return size, nil 51 | } 52 | 53 | func (wb *WriteBuffer) Bytes() []byte { 54 | if len(wb.chunks) == 1 { 55 | return wb.chunks[0] 56 | } 57 | bytes := make([]byte, 0, wb.len()) 58 | for _, chunk := range wb.chunks { 59 | bytes = append(bytes, chunk...) 60 | } 61 | return bytes 62 | } 63 | 64 | func (wb *WriteBuffer) addChunk(size, capacity int) { 65 | chunk := leakypool.GetBytes(size, capacity) 66 | if cap(chunk) >= size { 67 | chunk = chunk[:size] 68 | } 69 | wb.chunks = append(wb.chunks, chunk) 70 | } 71 | 72 | func (wb *WriteBuffer) len() int { 73 | var v int 74 | for _, chunk := range wb.chunks { 75 | v += len(chunk) 76 | } 77 | return v 78 | } 79 | 80 | func (wb *WriteBuffer) calcCap(dataSize int) int { 81 | dataSize = max(dataSize, 64) 82 | if len(wb.chunks) == 0 { 83 | return dataSize 84 | } 85 | // Always double the size of the last chunk 86 | return max(dataSize, cap(wb.chunks[len(wb.chunks)-1])*2) 87 | } 88 | 89 | func (wb *WriteBuffer) Reset() { 90 | if len(wb.chunks) == 0 { 91 | return 92 | } 93 | // Recycle all chunks except the last one 94 | chunkSizeThreshold := cap(wb.chunks[0]) 95 | for _, chunk := range wb.chunks[:len(wb.chunks)-1] { 96 | // Drain chunks smaller than the initial size 97 | if cap(chunk) >= chunkSizeThreshold { 98 | leakypool.PutBytes(chunk[:0]) 99 | } else { 100 | chunkSizeThreshold = cap(chunk) 101 | } 102 | } 103 | // Keep the largest chunk 104 | wb.chunks[0] = wb.chunks[len(wb.chunks)-1][:0] 105 | wb.chunks = wb.chunks[:1] 106 | } 107 | 108 | func max(a, b int) int { 109 | if b > a { 110 | return b 111 | } 112 | return a 113 | } 114 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/nfs/parse_nfsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 nfs 15 | 16 | import ( 17 | "bufio" 18 | "fmt" 19 | "io" 20 | "strings" 21 | 22 | "github.com/prometheus/procfs/internal/util" 23 | ) 24 | 25 | // ParseServerRPCStats returns stats read from /proc/net/rpc/nfsd 26 | func ParseServerRPCStats(r io.Reader) (*ServerRPCStats, error) { 27 | stats := &ServerRPCStats{} 28 | 29 | scanner := bufio.NewScanner(r) 30 | for scanner.Scan() { 31 | line := scanner.Text() 32 | parts := strings.Fields(scanner.Text()) 33 | // require at least 34 | if len(parts) < 2 { 35 | return nil, fmt.Errorf("invalid NFSd metric line %q", line) 36 | } 37 | label := parts[0] 38 | 39 | var values []uint64 40 | var err error 41 | if label == "th" { 42 | if len(parts) < 3 { 43 | return nil, fmt.Errorf("invalid NFSd th metric line %q", line) 44 | } 45 | values, err = util.ParseUint64s(parts[1:3]) 46 | } else { 47 | values, err = util.ParseUint64s(parts[1:]) 48 | } 49 | if err != nil { 50 | return nil, fmt.Errorf("error parsing NFSd metric line: %s", err) 51 | } 52 | 53 | switch metricLine := parts[0]; metricLine { 54 | case "rc": 55 | stats.ReplyCache, err = parseReplyCache(values) 56 | case "fh": 57 | stats.FileHandles, err = parseFileHandles(values) 58 | case "io": 59 | stats.InputOutput, err = parseInputOutput(values) 60 | case "th": 61 | stats.Threads, err = parseThreads(values) 62 | case "ra": 63 | stats.ReadAheadCache, err = parseReadAheadCache(values) 64 | case "net": 65 | stats.Network, err = parseNetwork(values) 66 | case "rpc": 67 | stats.ServerRPC, err = parseServerRPC(values) 68 | case "proc2": 69 | stats.V2Stats, err = parseV2Stats(values) 70 | case "proc3": 71 | stats.V3Stats, err = parseV3Stats(values) 72 | case "proc4": 73 | stats.ServerV4Stats, err = parseServerV4Stats(values) 74 | case "proc4ops": 75 | stats.V4Ops, err = parseV4Ops(values) 76 | default: 77 | return nil, fmt.Errorf("unknown NFSd metric line %q", metricLine) 78 | } 79 | if err != nil { 80 | return nil, fmt.Errorf("errors parsing NFSd metric line: %s", err) 81 | } 82 | } 83 | 84 | if err := scanner.Err(); err != nil { 85 | return nil, fmt.Errorf("error scanning NFSd file: %s", err) 86 | } 87 | 88 | return stats, nil 89 | } 90 | -------------------------------------------------------------------------------- /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/client_golang/prometheus/labels.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 ( 17 | "errors" 18 | "fmt" 19 | "strings" 20 | "unicode/utf8" 21 | 22 | "github.com/prometheus/common/model" 23 | ) 24 | 25 | // Labels represents a collection of label name -> value mappings. This type is 26 | // commonly used with the With(Labels) and GetMetricWith(Labels) methods of 27 | // metric vector Collectors, e.g.: 28 | // myVec.With(Labels{"code": "404", "method": "GET"}).Add(42) 29 | // 30 | // The other use-case is the specification of constant label pairs in Opts or to 31 | // create a Desc. 32 | type Labels map[string]string 33 | 34 | // reservedLabelPrefix is a prefix which is not legal in user-supplied 35 | // label names. 36 | const reservedLabelPrefix = "__" 37 | 38 | var errInconsistentCardinality = errors.New("inconsistent label cardinality") 39 | 40 | func makeInconsistentCardinalityError(fqName string, labels, labelValues []string) error { 41 | return fmt.Errorf( 42 | "%s: %q has %d variable labels named %q but %d values %q were provided", 43 | errInconsistentCardinality, fqName, 44 | len(labels), labels, 45 | len(labelValues), labelValues, 46 | ) 47 | } 48 | 49 | func validateValuesInLabels(labels Labels, expectedNumberOfValues int) error { 50 | if len(labels) != expectedNumberOfValues { 51 | return fmt.Errorf( 52 | "%s: expected %d label values but got %d in %#v", 53 | errInconsistentCardinality, expectedNumberOfValues, 54 | len(labels), labels, 55 | ) 56 | } 57 | 58 | for name, val := range labels { 59 | if !utf8.ValidString(val) { 60 | return fmt.Errorf("label %s: value %q is not valid UTF-8", name, val) 61 | } 62 | } 63 | 64 | return nil 65 | } 66 | 67 | func validateLabelValues(vals []string, expectedNumberOfValues int) error { 68 | if len(vals) != expectedNumberOfValues { 69 | return fmt.Errorf( 70 | "%s: expected %d label values but got %d in %#v", 71 | errInconsistentCardinality, expectedNumberOfValues, 72 | len(vals), vals, 73 | ) 74 | } 75 | 76 | for _, val := range vals { 77 | if !utf8.ValidString(val) { 78 | return fmt.Errorf("label value %q is not valid UTF-8", val) 79 | } 80 | } 81 | 82 | return nil 83 | } 84 | 85 | func checkLabelName(l string) bool { 86 | return model.LabelName(l).IsValid() && !strings.HasPrefix(l, reservedLabelPrefix) 87 | } 88 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Proton - is the new home for your Pinba metrics. 2 | 3 | - Grafana dashboards [basic reports](examples/grafana/report.json), [Proton Server](examples/grafana/proton-server.json) 4 | - reports (materialized views and queries) [basic reports](examples/reports/basic.md), [tags reports](examples/reports/tags.md) 5 | - [timers](https://github.com/tony2001/pinba_engine/wiki/PHP-extension#pinba_timer_start) 6 | 7 | # Installation 8 | 9 | ### Install ClickHouse server 10 | 11 | ```sh 12 | sudo apt-key adv --keyserver keyserver.ubuntu.com --recv E0C56BD4 # optional 13 | 14 | echo "deb http://repo.yandex.ru/clickhouse/deb/stable/ main/" | sudo tee /etc/apt/sources.list.d/clickhouse.list 15 | sudo apt-get update 16 | 17 | sudo apt-get install -y clickhouse-server clickhouse-client 18 | 19 | sudo service clickhouse-server start 20 | clickhouse-client 21 | ``` 22 | 23 | ### Create Proton schema and the raw request table 24 | 25 | ```sh 26 | clickhouse-client -n < schema/schema.sql 27 | ``` 28 | 29 | and then create the base report table and materialize view 30 | 31 | ```sh 32 | clickhouse-client -n < schema/reports/base.sql 33 | ``` 34 | 35 | ### Add Proton dictionary to ClickHouse server 36 | 37 | Example: 38 | 39 | ```xml 40 | 41 | 42 | 43 | Proton 44 | 45 | 46 | 127.0.0.1 47 | 9000 48 | default 49 | 50 | proton 51 | dictionary
52 |
53 | 54 | 600 55 | 56 | 57 | ID 58 | 59 | Value 60 | String 61 | 62 | 63 | 64 |
65 |
66 | ``` 67 | 68 | ### Download [latest](https://github.com/ClickHouse-Ninja/Proton/releases) Proton server 69 | 70 | And run it. 71 | 72 | # Usage: 73 | 74 | ``` 75 | NAME: 76 | Proton - high performance Pinba storage server. 77 | VERSION: 78 | 0.2 rev[f2e5ae4] master (2019-03-20.12:40:46 UTC). 79 | USAGE: 80 | -addr string 81 | listen address (default ":30002") 82 | -backlog int 83 | backlog size (default 10000) 84 | -concurrency int 85 | number of the background processes (default 2) 86 | -dsn string 87 | ClickHouse DSN (default "native://127.0.0.1:9000") 88 | -metrics_addr string 89 | address on which to expose metrics (default ":2112") 90 | -pprof string 91 | pprof address. If set to start the pprof server 92 | ``` 93 | 94 | If you are using the `deb` package, change the startup options in `/etc/proton-server/options`. 95 | 96 | ![Grafana basic reports](/assets/grafana-basic-reports.png) 97 | -------------------------------------------------------------------------------- /src/server/types.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "sort" 5 | 6 | "github.com/ClickHouse-Ninja/Proton/proto/pinba" 7 | ) 8 | 9 | type Options struct { 10 | DSN string 11 | Address string 12 | MetricsAddress string 13 | BacklogSize int 14 | Concurrency int 15 | } 16 | 17 | type request struct { 18 | pinba.Request 19 | timestamp uint32 20 | } 21 | 22 | func (req *request) tags() ([]string, []string) { 23 | var ( 24 | name = make([]string, 0, len(req.TagValue)) 25 | value = make([]string, 0, len(req.TagValue)) 26 | ) 27 | if len(req.TagName) == len(req.TagValue) && len(req.TagValue) <= len(req.Dictionary) { 28 | for _, k := range req.TagName { 29 | name = append(name, req.Dictionary[int(k)]) 30 | } 31 | for _, k := range req.TagValue { 32 | value = append(value, req.Dictionary[int(k)]) 33 | } 34 | } 35 | sort.Sort(&tagSort{ 36 | name: name, 37 | value: value, 38 | }) 39 | return name, value 40 | } 41 | 42 | func (req *request) timerTags() ([][]string, [][]string) { 43 | var ( 44 | name = make([][]string, len(req.TimerTagCount)) 45 | value = make([][]string, len(req.TimerTagCount)) 46 | ) 47 | 48 | if len(req.TimerTagName) == len(req.TimerTagValue) && len(req.TimerTagValue) <= len(req.Dictionary) { 49 | var names, values []string 50 | for _, k := range req.TimerTagName { 51 | names = append(names, req.Dictionary[int(k)]) 52 | } 53 | for _, k := range req.TimerTagValue { 54 | values = append(values, req.Dictionary[int(k)]) 55 | } 56 | 57 | var start uint32 58 | for idx, ln := range req.TimerTagCount { 59 | name[idx] = names[start : start+ln] 60 | value[idx] = values[start : start+ln] 61 | sort.Sort(&tagSort{ 62 | name: name[idx], 63 | value: value[idx], 64 | }) 65 | start += ln 66 | } 67 | } 68 | return name, value 69 | } 70 | 71 | func (req *request) GetTimerValue() (value []float32) { 72 | if value = req.Request.TimerValue; len(value) != len(req.TimerTagCount) { 73 | return make([]float32, len(req.TimerTagCount)) 74 | } 75 | return value 76 | } 77 | 78 | func (req *request) GetTimerRuStime() (value []float32) { 79 | if value = req.Request.TimerRuStime; len(value) != len(req.TimerTagCount) { 80 | return make([]float32, len(req.TimerTagCount)) 81 | } 82 | return value 83 | } 84 | 85 | func (req *request) GetTimerRuUtime() (value []float32) { 86 | if value = req.Request.TimerRuUtime; len(value) != len(req.TimerTagCount) { 87 | return make([]float32, len(req.TimerTagCount)) 88 | } 89 | return value 90 | } 91 | 92 | type tagSort struct { 93 | name, value []string 94 | } 95 | 96 | func (t *tagSort) Len() int { return len(t.name) } 97 | 98 | func (t *tagSort) Less(i, j int) bool { return t.name[i] < t.name[j] } 99 | 100 | func (t *tagSort) Swap(i, j int) { 101 | t.name[i], t.name[j] = t.name[j], t.name[i] 102 | t.value[i], t.value[j] = t.value[j], t.value[i] 103 | } 104 | 105 | var _ sort.Interface = (*tagSort)(nil) 106 | -------------------------------------------------------------------------------- /vendor/github.com/kshvakov/clickhouse/helpers.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | import ( 4 | "bytes" 5 | "database/sql/driver" 6 | "fmt" 7 | "reflect" 8 | "regexp" 9 | "strings" 10 | "time" 11 | ) 12 | 13 | func numInput(query string) int { 14 | 15 | var ( 16 | count int 17 | args = make(map[string]struct{}) 18 | reader = bytes.NewReader([]byte(query)) 19 | quote, keyword bool 20 | limit = newMatcher("limit") 21 | ) 22 | for { 23 | if char, _, err := reader.ReadRune(); err == nil { 24 | switch char { 25 | case '\'', '`': 26 | quote = !quote 27 | } 28 | if quote { 29 | continue 30 | } 31 | switch { 32 | case char == '?' && keyword: 33 | count++ 34 | case char == '@': 35 | if param := paramParser(reader); len(param) != 0 { 36 | if _, found := args[param]; !found { 37 | args[param] = struct{}{} 38 | count++ 39 | } 40 | } 41 | case 42 | char == '=', 43 | char == '<', 44 | char == '>', 45 | char == '(', 46 | char == ',', 47 | char == '%', 48 | char == '[': 49 | keyword = true 50 | default: 51 | if limit.matchRune(char) { 52 | keyword = true 53 | } else { 54 | keyword = keyword && (char == ' ' || char == '\t' || char == '\n') 55 | } 56 | } 57 | } else { 58 | break 59 | } 60 | } 61 | return count 62 | } 63 | 64 | func paramParser(reader *bytes.Reader) string { 65 | var name bytes.Buffer 66 | for { 67 | if char, _, err := reader.ReadRune(); err == nil { 68 | if char == '_' || char >= '0' && char <= '9' || 'a' <= char && char <= 'z' || 'A' <= char && char <= 'Z' { 69 | name.WriteRune(char) 70 | } else { 71 | reader.UnreadRune() 72 | break 73 | } 74 | } else { 75 | break 76 | } 77 | } 78 | return name.String() 79 | } 80 | 81 | var selectRe = regexp.MustCompile(`\s+SELECT\s+`) 82 | 83 | func isInsert(query string) bool { 84 | if f := strings.Fields(query); len(f) > 2 { 85 | return strings.EqualFold("INSERT", f[0]) && strings.EqualFold("INTO", f[1]) && !selectRe.MatchString(strings.ToUpper(query)) 86 | } 87 | return false 88 | } 89 | 90 | func quote(v driver.Value) string { 91 | switch v := reflect.ValueOf(v); v.Kind() { 92 | case reflect.Slice: 93 | values := make([]string, 0, v.Len()) 94 | for i := 0; i < v.Len(); i++ { 95 | values = append(values, quote(v.Index(i).Interface())) 96 | } 97 | return strings.Join(values, ", ") 98 | } 99 | switch v := v.(type) { 100 | case string: 101 | return "'" + strings.NewReplacer(`\`, `\\`, `'`, `\'`).Replace(v) + "'" 102 | case time.Time: 103 | return formatTime(v) 104 | } 105 | return fmt.Sprint(v) 106 | } 107 | 108 | func formatTime(value time.Time) string { 109 | if (value.Hour() + value.Minute() + value.Second() + value.Nanosecond()) == 0 { 110 | return fmt.Sprintf("toDate(%d)", int(int16(value.Unix()/24/3600))) 111 | } 112 | return fmt.Sprintf("toDateTime(%d)", int(uint32(value.Unix()))) 113 | } 114 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_golang/prometheus/internal/metric.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 internal 15 | 16 | import ( 17 | "sort" 18 | 19 | dto "github.com/prometheus/client_model/go" 20 | ) 21 | 22 | // metricSorter is a sortable slice of *dto.Metric. 23 | type metricSorter []*dto.Metric 24 | 25 | func (s metricSorter) Len() int { 26 | return len(s) 27 | } 28 | 29 | func (s metricSorter) Swap(i, j int) { 30 | s[i], s[j] = s[j], s[i] 31 | } 32 | 33 | func (s metricSorter) Less(i, j int) bool { 34 | if len(s[i].Label) != len(s[j].Label) { 35 | // This should not happen. The metrics are 36 | // inconsistent. However, we have to deal with the fact, as 37 | // people might use custom collectors or metric family injection 38 | // to create inconsistent metrics. So let's simply compare the 39 | // number of labels in this case. That will still yield 40 | // reproducible sorting. 41 | return len(s[i].Label) < len(s[j].Label) 42 | } 43 | for n, lp := range s[i].Label { 44 | vi := lp.GetValue() 45 | vj := s[j].Label[n].GetValue() 46 | if vi != vj { 47 | return vi < vj 48 | } 49 | } 50 | 51 | // We should never arrive here. Multiple metrics with the same 52 | // label set in the same scrape will lead to undefined ingestion 53 | // behavior. However, as above, we have to provide stable sorting 54 | // here, even for inconsistent metrics. So sort equal metrics 55 | // by their timestamp, with missing timestamps (implying "now") 56 | // coming last. 57 | if s[i].TimestampMs == nil { 58 | return false 59 | } 60 | if s[j].TimestampMs == nil { 61 | return true 62 | } 63 | return s[i].GetTimestampMs() < s[j].GetTimestampMs() 64 | } 65 | 66 | // NormalizeMetricFamilies returns a MetricFamily slice with empty 67 | // MetricFamilies pruned and the remaining MetricFamilies sorted by name within 68 | // the slice, with the contained Metrics sorted within each MetricFamily. 69 | func NormalizeMetricFamilies(metricFamiliesByName map[string]*dto.MetricFamily) []*dto.MetricFamily { 70 | for _, mf := range metricFamiliesByName { 71 | sort.Sort(metricSorter(mf.Metric)) 72 | } 73 | names := make([]string, 0, len(metricFamiliesByName)) 74 | for name, mf := range metricFamiliesByName { 75 | if len(mf.Metric) > 0 { 76 | names = append(names, name) 77 | } 78 | } 79 | sort.Strings(names) 80 | result := make([]*dto.MetricFamily, 0, len(names)) 81 | for _, name := range names { 82 | result = append(result, metricFamiliesByName[name]) 83 | } 84 | return result 85 | } 86 | -------------------------------------------------------------------------------- /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/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/kshvakov/clickhouse/lib/column/array.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | "strings" 7 | "time" 8 | 9 | "github.com/kshvakov/clickhouse/lib/binary" 10 | ) 11 | 12 | type Array struct { 13 | base 14 | depth int 15 | column Column 16 | } 17 | 18 | func (array *Array) Read(decoder *binary.Decoder) (interface{}, error) { 19 | return nil, fmt.Errorf("do not use Read method for Array(T) column") 20 | } 21 | 22 | func (array *Array) Write(encoder *binary.Encoder, v interface{}) error { 23 | return array.column.Write(encoder, v) 24 | } 25 | 26 | func (array *Array) ReadArray(decoder *binary.Decoder, rows int) (_ []interface{}, err error) { 27 | var ( 28 | values = make([]interface{}, rows) 29 | offsets = make([]uint64, rows) 30 | ) 31 | for i := 0; i < rows; i++ { 32 | offset, err := decoder.UInt64() 33 | if err != nil { 34 | return nil, err 35 | } 36 | offsets[i] = offset 37 | } 38 | for n, offset := range offsets { 39 | ln := offset 40 | if n != 0 { 41 | ln = ln - offsets[n-1] 42 | } 43 | if values[n], err = array.read(decoder, int(ln)); err != nil { 44 | return nil, err 45 | } 46 | } 47 | return values, nil 48 | } 49 | 50 | func (array *Array) read(decoder *binary.Decoder, ln int) (interface{}, error) { 51 | slice := reflect.MakeSlice(array.valueOf.Type(), 0, ln) 52 | for i := 0; i < ln; i++ { 53 | value, err := array.column.Read(decoder) 54 | if err != nil { 55 | return nil, err 56 | } 57 | slice = reflect.Append(slice, reflect.ValueOf(value)) 58 | } 59 | return slice.Interface(), nil 60 | } 61 | 62 | func parseArray(name, chType string, timezone *time.Location) (*Array, error) { 63 | if len(chType) < 11 { 64 | return nil, fmt.Errorf("invalid Array column type: %s", chType) 65 | } 66 | var ( 67 | depth int 68 | columnType = chType 69 | ) 70 | 71 | loop: 72 | for _, str := range strings.Split(chType, "Array(") { 73 | switch { 74 | case len(str) == 0: 75 | depth++ 76 | default: 77 | chType = str[:len(str)-depth] 78 | break loop 79 | } 80 | } 81 | column, err := Factory(name, chType, timezone) 82 | if err != nil { 83 | return nil, fmt.Errorf("Array(T): %v", err) 84 | } 85 | 86 | var scanType interface{} 87 | switch t := column.ScanType().Kind(); t { 88 | case reflect.Int8: 89 | scanType = []int8{} 90 | case reflect.Int16: 91 | scanType = []int16{} 92 | case reflect.Int32: 93 | scanType = []int32{} 94 | case reflect.Int64: 95 | scanType = []int64{} 96 | case reflect.Uint8: 97 | scanType = []uint8{} 98 | case reflect.Uint16: 99 | scanType = []uint16{} 100 | case reflect.Uint32: 101 | scanType = []uint32{} 102 | case reflect.Uint64: 103 | scanType = []uint64{} 104 | case reflect.Float32: 105 | scanType = []float32{} 106 | case reflect.Float64: 107 | scanType = []float64{} 108 | case reflect.String: 109 | scanType = []string{} 110 | case baseTypes[time.Time{}].Kind(): 111 | scanType = []time.Time{} 112 | default: 113 | return nil, fmt.Errorf("unsupported Array type '%s'", column.ScanType().Name()) 114 | } 115 | return &Array{ 116 | base: base{ 117 | name: name, 118 | chType: columnType, 119 | valueOf: reflect.ValueOf(scanType), 120 | }, 121 | depth: depth, 122 | column: column, 123 | }, nil 124 | } 125 | -------------------------------------------------------------------------------- /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 definition in the Prometheus 63 | // 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/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/kshvakov/clickhouse/lib/types/uuid.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "database/sql/driver" 5 | "encoding/hex" 6 | "errors" 7 | "fmt" 8 | ) 9 | 10 | var InvalidUUIDFormatError = errors.New("invalid UUID format") 11 | 12 | // this type will be deprecated because the ClickHouse server (>=1.1.54276) has a built-in type UUID 13 | type UUID string 14 | 15 | func (str UUID) Value() (driver.Value, error) { 16 | return uuid2bytes(string(str)) 17 | } 18 | 19 | func (str UUID) MarshalBinary() ([]byte, error) { 20 | return uuid2bytes(string(str)) 21 | } 22 | 23 | func (str *UUID) Scan(v interface{}) error { 24 | var src []byte 25 | switch v := v.(type) { 26 | case string: 27 | src = []byte(v) 28 | case []byte: 29 | src = v 30 | } 31 | 32 | if len(src) != 16 { 33 | return fmt.Errorf("invalid UUID length: %d", len(src)) 34 | } 35 | 36 | var uuid [36]byte 37 | { 38 | hex.Encode(uuid[:], src[:4]) 39 | uuid[8] = '-' 40 | hex.Encode(uuid[9:13], src[4:6]) 41 | uuid[13] = '-' 42 | hex.Encode(uuid[14:18], src[6:8]) 43 | uuid[18] = '-' 44 | hex.Encode(uuid[19:23], src[8:10]) 45 | uuid[23] = '-' 46 | hex.Encode(uuid[24:], src[10:]) 47 | } 48 | *str = UUID(uuid[:]) 49 | return nil 50 | } 51 | 52 | func uuid2bytes(str string) ([]byte, error) { 53 | var uuid [16]byte 54 | if str[8] != '-' || str[13] != '-' || str[18] != '-' || str[23] != '-' { 55 | return nil, InvalidUUIDFormatError 56 | } 57 | for i, x := range [16]int{ 58 | 0, 2, 4, 6, 59 | 9, 11, 14, 16, 60 | 19, 21, 24, 26, 61 | 28, 30, 32, 34, 62 | } { 63 | if v, ok := xtob(str[x], str[x+1]); !ok { 64 | return nil, InvalidUUIDFormatError 65 | } else { 66 | uuid[i] = v 67 | } 68 | } 69 | return uuid[:], nil 70 | } 71 | 72 | // xvalues returns the value of a byte as a hexadecimal digit or 255. 73 | var xvalues = [256]byte{ 74 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 75 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 76 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 77 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 255, 255, 255, 255, 255, 255, 78 | 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, 79 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 80 | 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, 81 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 82 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 83 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 84 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 85 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 86 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 87 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 88 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 89 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 90 | } 91 | 92 | // xtob converts hex characters x1 and x2 into a byte. 93 | func xtob(x1, x2 byte) (byte, bool) { 94 | b1 := xvalues[x1] 95 | b2 := xvalues[x2] 96 | return (b1 << 4) | b2, b1 != 255 && b2 != 255 97 | } 98 | 99 | var _ driver.Valuer = UUID("") 100 | --------------------------------------------------------------------------------