├── .gitignore ├── vendor ├── github.com │ ├── prometheus │ │ ├── procfs │ │ │ ├── .gitignore │ │ │ ├── go.mod │ │ │ ├── MAINTAINERS.md │ │ │ ├── .golangci.yml │ │ │ ├── go.sum │ │ │ ├── NOTICE │ │ │ ├── CONTRIBUTING.md │ │ │ ├── Makefile │ │ │ ├── fs.go │ │ │ ├── doc.go │ │ │ ├── internal │ │ │ │ └── fs │ │ │ │ │ └── fs.go │ │ │ ├── proc_io.go │ │ │ ├── proc_ns.go │ │ │ ├── README.md │ │ │ └── buddyinfo.go │ │ ├── client_golang │ │ │ ├── prometheus │ │ │ │ ├── .gitignore │ │ │ │ ├── README.md │ │ │ │ ├── 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 │ │ │ ├── expfmt │ │ │ ├── fuzz.go │ │ │ ├── expfmt.go │ │ │ └── encode.go │ │ │ └── internal │ │ │ └── bitbucket.org │ │ │ └── ww │ │ │ └── goautoneg │ │ │ └── README.txt │ ├── aerospike │ │ └── aerospike-client-go │ │ │ ├── aerospike.go │ │ │ ├── pkg │ │ │ └── bcrypt │ │ │ │ ├── .gitignore │ │ │ │ ├── README │ │ │ │ └── LICENSE │ │ │ ├── .gitignore │ │ │ ├── udf.go │ │ │ ├── types │ │ │ ├── epoc.go │ │ │ ├── types.go │ │ │ ├── particle_type │ │ │ │ └── particle_type.go │ │ │ ├── atomic │ │ │ │ ├── sync_val.go │ │ │ │ ├── bool.go │ │ │ │ ├── array.go │ │ │ │ └── queue.go │ │ │ ├── error.go │ │ │ ├── rand │ │ │ │ └── xor_shift128.go │ │ │ ├── pool.go │ │ │ ├── buffer_pool.go │ │ │ └── message.go │ │ │ ├── .build.yml │ │ │ ├── compat_after_go1.8.go │ │ │ ├── language.go │ │ │ ├── user_roles.go │ │ │ ├── query_policy.go │ │ │ ├── index_type.go │ │ │ ├── admin_policy.go │ │ │ ├── query_record_command.go │ │ │ ├── priority.go │ │ │ ├── commit_policy.go │ │ │ ├── bytes_buffer.go │ │ │ ├── consistency_level.go │ │ │ ├── generation_policy.go │ │ │ ├── query_objects_command.go │ │ │ ├── bin.go │ │ │ ├── node_error.go │ │ │ ├── host.go │ │ │ ├── index_collection_type.go │ │ │ ├── compat_before_go1.8.go │ │ │ ├── role.go │ │ │ ├── execute_command.go │ │ │ ├── query_command.go │ │ │ ├── field_type.go │ │ │ ├── record_exists_action.go │ │ │ ├── value_reflect.go │ │ │ ├── operate_command.go │ │ │ ├── internal │ │ │ └── lua │ │ │ │ ├── lua_aerospike.go │ │ │ │ └── instance.go │ │ │ ├── record.go │ │ │ ├── replica_policy.go │ │ │ ├── task_remove.go │ │ │ ├── single_command.go │ │ │ ├── value_helpers.go │ │ │ ├── task_register.go │ │ │ ├── scan_command.go │ │ │ ├── task_drop_index.go │ │ │ ├── multi_policy.go │ │ │ ├── scan_policy.go │ │ │ ├── scan_objects_command.go │ │ │ ├── task.go │ │ │ ├── partition.go │ │ │ ├── touch_command.go │ │ │ ├── task_index.go │ │ │ ├── delete_command.go │ │ │ ├── exists_command.go │ │ │ ├── write_command.go │ │ │ ├── packer_reflect.go │ │ │ ├── batch_command_get_reflect.go │ │ │ ├── peers.go │ │ │ ├── read_header_command.go │ │ │ ├── batch_command_reflect.go │ │ │ ├── .travis.yml │ │ │ ├── server_command.go │ │ │ └── logger │ │ │ └── logger.go │ ├── matttproud │ │ └── golang_protobuf_extensions │ │ │ ├── pbutil │ │ │ ├── .gitignore │ │ │ ├── Makefile │ │ │ ├── doc.go │ │ │ └── encode.go │ │ │ └── NOTICE │ ├── yuin │ │ └── gopher-lua │ │ │ ├── go.mod │ │ │ ├── parse │ │ │ └── Makefile │ │ │ ├── go.sum │ │ │ ├── ast │ │ │ ├── misc.go │ │ │ ├── token.go │ │ │ ├── ast.go │ │ │ ├── stmt.go │ │ │ └── expr.go │ │ │ ├── Makefile │ │ │ ├── package.go │ │ │ ├── .travis.yml │ │ │ ├── config.go │ │ │ ├── LICENSE │ │ │ ├── linit.go │ │ │ ├── tablelib.go │ │ │ ├── alloc.go │ │ │ └── coroutinelib.go │ ├── golang │ │ └── protobuf │ │ │ ├── AUTHORS │ │ │ ├── CONTRIBUTORS │ │ │ ├── LICENSE │ │ │ └── proto │ │ │ └── deprecated.go │ └── beorn7 │ │ └── perks │ │ └── LICENSE └── modules.txt ├── .travis.yml ├── Makefile ├── .goreleaser.yml ├── go.mod ├── LICENSE ├── Dockerfile ├── README.md ├── sets.go └── xdr.go /.gitignore: -------------------------------------------------------------------------------- 1 | asprom 2 | dist/ 3 | .*.swp 4 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/.gitignore: -------------------------------------------------------------------------------- 1 | /fixtures/ 2 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/aerospike.go: -------------------------------------------------------------------------------- 1 | package aerospike 2 | -------------------------------------------------------------------------------- /vendor/github.com/matttproud/golang_protobuf_extensions/pbutil/.gitignore: -------------------------------------------------------------------------------- 1 | cover.dat 2 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_golang/prometheus/.gitignore: -------------------------------------------------------------------------------- 1 | command-line-arguments.test 2 | -------------------------------------------------------------------------------- /vendor/github.com/matttproud/golang_protobuf_extensions/NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2012 Matt T. Proud (matt.proud@gmail.com) 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | script: GOPATH="" make test build 4 | 5 | sudo: false 6 | 7 | go: 8 | - "1.14" 9 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/pkg/bcrypt/.gitignore: -------------------------------------------------------------------------------- 1 | 6.out 2 | *.6 3 | _obj 4 | _test 5 | _testmain.go 6 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/prometheus/procfs 2 | 3 | require golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 4 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/MAINTAINERS.md: -------------------------------------------------------------------------------- 1 | * Johannes 'fish' Ziemke @discordianfish 2 | * Paul Gier @pgier 3 | -------------------------------------------------------------------------------- /vendor/github.com/yuin/gopher-lua/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/yuin/gopher-lua 2 | 3 | require github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect 4 | -------------------------------------------------------------------------------- /vendor/github.com/yuin/gopher-lua/parse/Makefile: -------------------------------------------------------------------------------- 1 | all : parser.go 2 | 3 | parser.go : parser.go.y 4 | goyacc -o $@ parser.go.y; [ -f y.output ] && ( rm -f y.output ) 5 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/.gitignore: -------------------------------------------------------------------------------- 1 | *.prof 2 | *.test 3 | *.coverprofile* 4 | tools/benchmark/benchmark 5 | tools/asinfo/asinfo 6 | tools/debug/ 7 | tmp/ 8 | .DS_Store 9 | TODO -------------------------------------------------------------------------------- /vendor/github.com/matttproud/golang_protobuf_extensions/pbutil/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | 3 | cover: 4 | go test -cover -v -coverprofile=cover.dat ./... 5 | go tool cover -func cover.dat 6 | 7 | .PHONY: cover 8 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/.golangci.yml: -------------------------------------------------------------------------------- 1 | # Run only staticcheck for now. Additional linters will be enabled one-by-one. 2 | linters: 3 | enable: 4 | - staticcheck 5 | - govet 6 | disable-all: true 7 | -------------------------------------------------------------------------------- /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/prometheus/client_golang/prometheus/README.md: -------------------------------------------------------------------------------- 1 | See [![go-doc](https://godoc.org/github.com/prometheus/client_golang/prometheus?status.svg)](https://godoc.org/github.com/prometheus/client_golang/prometheus). 2 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_model/NOTICE: -------------------------------------------------------------------------------- 1 | Data model artifacts for Prometheus. 2 | Copyright 2012-2015 The Prometheus Authors 3 | 4 | This product includes software developed at 5 | SoundCloud Ltd. (http://soundcloud.com/). 6 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/common/NOTICE: -------------------------------------------------------------------------------- 1 | Common libraries shared by Prometheus Go components. 2 | Copyright 2015 The Prometheus Authors 3 | 4 | This product includes software developed at 5 | SoundCloud Ltd. (http://soundcloud.com/). 6 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all build test vendor release 2 | 3 | all: build test 4 | 5 | build: 6 | go build -mod=vendor 7 | 8 | test: 9 | go test -mod=vendor 10 | 11 | vendor: 12 | go mod vendor 13 | 14 | release: 15 | goreleaser --rm-dist 16 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/go.sum: -------------------------------------------------------------------------------- 1 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= 2 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 3 | -------------------------------------------------------------------------------- /vendor/github.com/yuin/gopher-lua/go.sum: -------------------------------------------------------------------------------- 1 | github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8= 2 | github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= 3 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /.goreleaser.yml: -------------------------------------------------------------------------------- 1 | builds: 2 | - binary: asprom 3 | goos: 4 | - linux 5 | - darwin 6 | goarch: 7 | - amd64 8 | archive: 9 | files: 10 | - LICENSE 11 | wrap_in_directory: true 12 | release: 13 | github: 14 | owner: alicebob 15 | name: asprom 16 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/udf.go: -------------------------------------------------------------------------------- 1 | package aerospike 2 | 3 | // UDF carries information about UDFs on the server 4 | type UDF struct { 5 | // Filename of the UDF 6 | Filename string 7 | // Hash digest of the UDF 8 | Hash string 9 | // Language of UDF 10 | Language Language 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/yuin/gopher-lua/ast/misc.go: -------------------------------------------------------------------------------- 1 | package ast 2 | 3 | type Field struct { 4 | Key Expr 5 | Value Expr 6 | } 7 | 8 | type ParList struct { 9 | HasVargs bool 10 | Names []string 11 | } 12 | 13 | type FuncName struct { 14 | Func Expr 15 | Receiver Expr 16 | Method string 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/yuin/gopher-lua/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build test glua 2 | 3 | build: 4 | ./_tools/go-inline *.go && go fmt . && go build 5 | 6 | glua: *.go pm/*.go cmd/glua/glua.go 7 | ./_tools/go-inline *.go && go fmt . && go build cmd/glua/glua.go 8 | 9 | test: 10 | ./_tools/go-inline *.go && go fmt . && go test 11 | -------------------------------------------------------------------------------- /vendor/github.com/yuin/gopher-lua/package.go: -------------------------------------------------------------------------------- 1 | // GopherLua: VM and compiler for Lua in Go 2 | package lua 3 | 4 | const PackageName = "GopherLua" 5 | const PackageVersion = "0.1" 6 | const PackageAuthors = "Yusuke Inuzuka" 7 | const PackageCopyRight = PackageName + " " + PackageVersion + " Copyright (C) 2015 -2017 " + PackageAuthors 8 | -------------------------------------------------------------------------------- /vendor/github.com/yuin/gopher-lua/ast/token.go: -------------------------------------------------------------------------------- 1 | package ast 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | type Position struct { 8 | Source string 9 | Line int 10 | Column int 11 | } 12 | 13 | type Token struct { 14 | Type int 15 | Name string 16 | Str string 17 | Pos Position 18 | } 19 | 20 | func (self *Token) String() string { 21 | return fmt.Sprintf("", self.Name, self.Str) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/yuin/gopher-lua/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - "1.9.x" 5 | - "1.10.x" 6 | - "1.11.x" 7 | 8 | before_install: 9 | - go get github.com/axw/gocov/gocov 10 | - go get github.com/mattn/goveralls 11 | - if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi 12 | install: 13 | - go get -u -v $(go list -f '{{join .Imports "\n"}}{{"\n"}}{{join .TestImports "\n"}}' ./... | sort | uniq | grep -v gopher-lua) 14 | script: 15 | - $HOME/gopath/bin/goveralls -service=travis-ci 16 | -------------------------------------------------------------------------------- /vendor/github.com/yuin/gopher-lua/ast/ast.go: -------------------------------------------------------------------------------- 1 | package ast 2 | 3 | type PositionHolder interface { 4 | Line() int 5 | SetLine(int) 6 | LastLine() int 7 | SetLastLine(int) 8 | } 9 | 10 | type Node struct { 11 | line int 12 | lastline int 13 | } 14 | 15 | func (self *Node) Line() int { 16 | return self.line 17 | } 18 | 19 | func (self *Node) SetLine(line int) { 20 | self.line = line 21 | } 22 | 23 | func (self *Node) LastLine() int { 24 | return self.lastline 25 | } 26 | 27 | func (self *Node) SetLastLine(line int) { 28 | self.lastline = line 29 | } 30 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/alicebob/asprom 2 | 3 | go 1.12 4 | 5 | require ( 6 | github.com/aerospike/aerospike-client-go v1.29.0 7 | github.com/onsi/ginkgo v1.8.0 // indirect 8 | github.com/onsi/gomega v1.5.0 // indirect 9 | github.com/prometheus/client_golang v0.9.3 10 | github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 11 | github.com/prometheus/procfs v0.0.0-20190519111021-9935e8e0588d // indirect 12 | github.com/yuin/gopher-lua v0.0.0-20181214045814-db9ae37725ec // indirect 13 | golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 // indirect 14 | golang.org/x/text v0.3.0 15 | ) 16 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/types/epoc.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "math" 5 | "time" 6 | ) 7 | 8 | const ( 9 | // citrusleaf epoc: Jan 01 2010 00:00:00 GMT 10 | CITRUSLEAF_EPOCH = 1262304000 11 | ) 12 | 13 | // TTL converts an Expiration time from citrusleaf epoc to TTL in seconds. 14 | func TTL(secsFromCitrusLeafEpoc uint32) uint32 { 15 | switch secsFromCitrusLeafEpoc { 16 | // don't convert magic values 17 | case 0: // when set to don't expire, this value is returned 18 | return math.MaxUint32 19 | default: 20 | return uint32(int64(CITRUSLEAF_EPOCH+secsFromCitrusLeafEpoc) - time.Now().Unix()) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/types/types.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 types 16 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/.build.yml: -------------------------------------------------------------------------------- 1 | name: aerospike-client-go 2 | dir: src/github.com/aerospike/aerospike-client-go 3 | 4 | container: 5 | - base: 6 | - docker.qe.aerospike.com/build/aerospike-client-go:golang-1.5 7 | - docker.qe.aerospike.com/build/aerospike-client-go:golang-1.6 8 | 9 | build: 10 | - name: build 11 | script: 12 | - go get -v github.com/aerospike/aerospike-client-go 13 | - go build -v -x github.com/aerospike/aerospike-client-go 14 | - go install -v -x github.com/aerospike/aerospike-client-go/tools/cli 15 | - go install -v -x github.com/aerospike/aerospike-client-go/tools/benchmark 16 | - go install -v -x github.com/aerospike/aerospike-client-go/tools/asinfo 17 | -------------------------------------------------------------------------------- /vendor/github.com/matttproud/golang_protobuf_extensions/pbutil/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Matt T. Proud 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package pbutil provides record length-delimited Protocol Buffer streaming. 16 | package pbutil 17 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/common/model/model.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | // Package model contains common data structures that are shared across 15 | // Prometheus components and libraries. 16 | package model 17 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/compat_after_go1.8.go: -------------------------------------------------------------------------------- 1 | // +build go1.8 2 | 3 | // Copyright 2013-2017 Aerospike, Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package aerospike 18 | 19 | import ( 20 | "crypto/tls" 21 | ) 22 | 23 | func cloneTlsConfig(c *tls.Config) *tls.Config { 24 | return c.Clone() 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/language.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | // Language specifies User defined function languages. 18 | type Language string 19 | 20 | const ( 21 | 22 | // LUA embedded programming language. 23 | LUA Language = "LUA" 24 | ) 25 | -------------------------------------------------------------------------------- /vendor/github.com/yuin/gopher-lua/config.go: -------------------------------------------------------------------------------- 1 | package lua 2 | 3 | import ( 4 | "os" 5 | ) 6 | 7 | var CompatVarArg = true 8 | var FieldsPerFlush = 50 9 | var RegistrySize = 256 * 20 10 | var CallStackSize = 256 11 | var MaxTableGetLoop = 100 12 | var MaxArrayIndex = 67108864 13 | 14 | type LNumber float64 15 | 16 | const LNumberBit = 64 17 | const LNumberScanFormat = "%f" 18 | const LuaVersion = "Lua 5.1" 19 | 20 | var LuaPath = "LUA_PATH" 21 | var LuaLDir string 22 | var LuaPathDefault string 23 | var LuaOS string 24 | 25 | func init() { 26 | if os.PathSeparator == '/' { // unix-like 27 | LuaOS = "unix" 28 | LuaLDir = "/usr/local/share/lua/5.1" 29 | LuaPathDefault = "./?.lua;" + LuaLDir + "/?.lua;" + LuaLDir + "/?/init.lua" 30 | } else { // windows 31 | LuaOS = "windows" 32 | LuaLDir = "!\\lua" 33 | LuaPathDefault = ".\\?.lua;" + LuaLDir + "\\?.lua;" + LuaLDir + "\\?\\init.lua" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /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/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 | @echo ">> extracting fixtures" 18 | ./ttar -C $(dir $*) -x -f $*.ttar 19 | touch $@ 20 | 21 | update_fixtures: 22 | rm -vf fixtures/.unpacked 23 | ./ttar -c -f fixtures.ttar fixtures/ 24 | 25 | .PHONY: build 26 | build: 27 | 28 | .PHONY: test 29 | test: fixtures/.unpacked common-test 30 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/user_roles.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 2 | // 3 | // Portions may be licensed to Aerospike, Inc. under one or more contributor 4 | // license agreements. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 7 | // use this file except in compliance with the License. You may obtain a copy of 8 | // the License at http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | // License for the specific language governing permissions and limitations under 14 | // the License. 15 | 16 | package aerospike 17 | 18 | // UserRoles contains information about a user. 19 | type UserRoles struct { 20 | // User name. 21 | User string 22 | 23 | // Roles is a list of assigned roles. 24 | Roles []string 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/query_policy.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | // QueryPolicy encapsulates parameters for policy attributes used in query operations. 18 | type QueryPolicy struct { 19 | *MultiPolicy 20 | } 21 | 22 | // NewQueryPolicy generates a new QueryPolicy instance with default values. 23 | func NewQueryPolicy() *QueryPolicy { 24 | return &QueryPolicy{ 25 | MultiPolicy: NewMultiPolicy(), 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/index_type.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | // IndexType the type of the secondary index. 18 | type IndexType string 19 | 20 | const ( 21 | // NUMERIC specifies an index on numeric values. 22 | NUMERIC IndexType = "NUMERIC" 23 | 24 | // STRING specifies an index on string values. 25 | STRING IndexType = "STRING" 26 | 27 | // 2-dimensional spherical geospatial index. 28 | GEO2DSPHERE IndexType = "GEO2DSPHERE" 29 | ) 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Harmen 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/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/yuin/gopher-lua/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Yusuke Inuzuka 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/aerospike/aerospike-client-go/admin_policy.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | import "time" 18 | 19 | // AdminPolicy contains attributes used for user administration commands. 20 | type AdminPolicy struct { 21 | 22 | // User administration command socket timeout in milliseconds. 23 | // Default is one second timeout. 24 | Timeout time.Duration 25 | } 26 | 27 | // NewAdminPolicy generates a new AdminPolicy with default values. 28 | func NewAdminPolicy() *AdminPolicy { 29 | return &AdminPolicy{ 30 | Timeout: 1 * time.Second, 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/query_record_command.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | import . "github.com/aerospike/aerospike-client-go/types" 18 | 19 | type queryRecordCommand struct { 20 | queryCommand 21 | } 22 | 23 | func newQueryRecordCommand(node *Node, policy *QueryPolicy, statement *Statement, recordset *Recordset) *queryRecordCommand { 24 | cmd := &queryRecordCommand{ 25 | queryCommand: *newQueryCommand(node, policy, statement, recordset), 26 | } 27 | 28 | cmd.terminationErrorType = QUERY_TERMINATED 29 | 30 | return cmd 31 | } 32 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Accept the Go version for the image to be set as a build argument. 2 | ARG GO_VERSION=1.13 3 | ARG ASPROM_VERSION=1.8.0 4 | 5 | # First stage: build the executable. 6 | FROM golang:${GO_VERSION}-alpine AS build 7 | 8 | # Create the user and group files that will be used in the running container to 9 | # run the process as an unprivileged user. 10 | RUN mkdir /user && \ 11 | echo '1000:x:65534:65534:1000:/:' > /user/passwd && \ 12 | echo '1000:x:65534:' > /user/group 13 | 14 | # Install the Certificate-Authority certificates for the app to be able to make 15 | # calls to HTTPS endpoints. 16 | RUN apk add --no-cache ca-certificates git curl 17 | 18 | WORKDIR /src 19 | 20 | COPY . . 21 | 22 | RUN CGO_ENABLED=0 GOOS=linux go build -mod=vendor -o asprom . 23 | 24 | # Final stage: the running container. 25 | FROM scratch AS final 26 | 27 | # Import the user and group files from the build stage. 28 | COPY --from=build /user/group /user/passwd /etc/ 29 | 30 | # Import the Certificate-Authority certificates for enabling HTTPS. 31 | COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ 32 | 33 | COPY --from=build /src/asprom . 34 | 35 | EXPOSE 9145 36 | 37 | CMD ["./asprom"] 38 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/priority.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | // Priority of operations on database server. 18 | type Priority int 19 | 20 | const ( 21 | 22 | // DEFAULT determines that the server defines the priority. 23 | DEFAULT Priority = iota 24 | 25 | // LOW determines that the server should run the operation in a background thread. 26 | LOW 27 | 28 | // MEDIUM determines that the server should run the operation at medium priority. 29 | MEDIUM 30 | 31 | // HIGH determines that the server should run the operation at the highest priority. 32 | HIGH 33 | ) 34 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/commit_policy.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2017 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | 18 | package aerospike 19 | 20 | // CommitLevel indicates the desired consistency guarantee when committing a transaction on the server. 21 | type CommitLevel int 22 | 23 | const ( 24 | // COMMIT_ALL indicates the server should wait until successfully committing master and all replicas. 25 | COMMIT_ALL CommitLevel = iota 26 | 27 | // COMMIT_MASTER indicates the server should wait until successfully committing master only. 28 | COMMIT_MASTER 29 | ) 30 | -------------------------------------------------------------------------------- /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/aerospike/aerospike-client-go/bytes_buffer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | // BufferEx is a specialized buffer interface for aerospike client. 18 | type BufferEx interface { 19 | WriteInt64(num int64) (int, error) 20 | WriteUint64(num uint64) (int, error) 21 | WriteInt32(num int32) (int, error) 22 | WriteUint32(num uint32) (int, error) 23 | WriteInt16(num int16) (int, error) 24 | WriteUint16(num uint16) (int, error) 25 | WriteFloat32(float float32) (int, error) 26 | WriteFloat64(float float64) (int, error) 27 | WriteByte(b byte) error 28 | WriteString(s string) (int, error) 29 | Write(b []byte) (int, error) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/consistency_level.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2017 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | 18 | package aerospike 19 | 20 | // ConsistencyLevel indicates how replicas should be consulted in a read 21 | // operation to provide the desired consistency guarantee. 22 | type ConsistencyLevel int 23 | 24 | const ( 25 | // CONSISTENCY_ONE indicates only a single replica should be consulted in 26 | // the read operation. 27 | CONSISTENCY_ONE = iota 28 | 29 | // CONSISTENCY_ALL indicates that all replicas should be consulted in 30 | // the read operation. 31 | CONSISTENCY_ALL 32 | ) 33 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/generation_policy.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | // GenerationPolicy determines how to handle record writes based on record generation. 18 | type GenerationPolicy int 19 | 20 | const ( 21 | // NONE means: Do not use record generation to restrict writes. 22 | NONE GenerationPolicy = iota 23 | 24 | // EXPECT_GEN_EQUAL means: Update/Delete record if expected generation is equal to server generation. Otherwise, fail. 25 | EXPECT_GEN_EQUAL 26 | 27 | // EXPECT_GEN_GT means: Update/Delete record if expected generation greater than the server generation. Otherwise, fail. 28 | // This is useful for restore after backup. 29 | EXPECT_GEN_GT 30 | ) 31 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/types/particle_type/particle_type.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 particleType 16 | 17 | const ( 18 | // Server particle types. Unsupported types are commented out. 19 | NULL = 0 20 | INTEGER = 1 21 | FLOAT = 2 22 | STRING = 3 23 | BLOB = 4 24 | // TIMESTAMP = 5 25 | DIGEST = 6 26 | // JBLOB = 7 27 | // CSHARP_BLOB = 8 28 | // PYTHON_BLOB = 9 29 | // RUBY_BLOB = 10 30 | // PHP_BLOB = 11 31 | // ERLANG_BLOB = 12 32 | // SEGMENT_POINTER = 13 33 | // RTA_LIST = 14 34 | // RTA_DICT = 15 35 | // RTA_APPEND_DICT = 16 36 | // RTA_APPEND_LIST = 17 37 | // LUA_BLOB = 18 38 | MAP = 19 39 | LIST = 20 40 | LDT = 21 41 | GEOJSON = 23 42 | ) 43 | -------------------------------------------------------------------------------- /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 | "github.com/prometheus/procfs/internal/fs" 18 | ) 19 | 20 | // FS represents the pseudo-filesystem sys, which provides an interface to 21 | // kernel data structures. 22 | type FS struct { 23 | proc fs.FS 24 | } 25 | 26 | // DefaultMountPoint is the common mount point of the proc filesystem. 27 | const DefaultMountPoint = fs.DefaultProcMountPoint 28 | 29 | // NewFS returns a new proc FS mounted under the given proc mountPoint. It will error 30 | // if the mount point dirctory can't be read or is a file. 31 | func NewFS(mountPoint string) (FS, error) { 32 | fs, err := fs.NewFS(mountPoint) 33 | if err != nil { 34 | return FS{}, err 35 | } 36 | return FS{fs}, nil 37 | } 38 | -------------------------------------------------------------------------------- /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/aerospike/aerospike-client-go/query_objects_command.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | import . "github.com/aerospike/aerospike-client-go/types" 18 | 19 | type queryObjectsCommand struct { 20 | queryCommand 21 | } 22 | 23 | func newQueryObjectsCommand(node *Node, policy *QueryPolicy, statement *Statement, recordset *Recordset) *queryObjectsCommand { 24 | cmd := &queryObjectsCommand{ 25 | queryCommand: *newQueryCommand(node, policy, statement, recordset), 26 | } 27 | 28 | cmd.terminationErrorType = QUERY_TERMINATED 29 | 30 | return cmd 31 | } 32 | 33 | func (cmd *queryObjectsCommand) Execute() error { 34 | defer cmd.recordset.signalEnd() 35 | err := cmd.execute(cmd) 36 | if err != nil { 37 | cmd.recordset.sendError(err) 38 | } 39 | return err 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/types/atomic/sync_val.go: -------------------------------------------------------------------------------- 1 | package atomic 2 | 3 | import "sync" 4 | 5 | type SyncVal struct { 6 | val interface{} 7 | lock sync.RWMutex 8 | } 9 | 10 | // NewSyncVal creates a new instance of SyncVal 11 | func NewSyncVal(val interface{}) *SyncVal { 12 | return &SyncVal{val: val} 13 | } 14 | 15 | // Set updates the value of SyncVal with the passed argument 16 | func (sv *SyncVal) Set(val interface{}) { 17 | sv.lock.Lock() 18 | sv.val = val 19 | sv.lock.Unlock() 20 | } 21 | 22 | // Get returns the value inside the SyncVal 23 | func (sv *SyncVal) Get() interface{} { 24 | sv.lock.RLock() 25 | val := sv.val 26 | sv.lock.RUnlock() 27 | return val 28 | } 29 | 30 | // GetSyncedVia returns the value returned by the function f. 31 | func (sv *SyncVal) GetSyncedVia(f func(interface{}) (interface{}, error)) (interface{}, error) { 32 | sv.lock.RLock() 33 | defer sv.lock.RUnlock() 34 | 35 | val, err := f(sv.val) 36 | return val, err 37 | } 38 | 39 | // Update gets a function and passes the value of SyncVal to it. 40 | // If the resulting err is nil, it will update the value of SyncVal. 41 | // It will return the resulting error to the caller. 42 | func (sv *SyncVal) Update(f func(interface{}) (interface{}, error)) error { 43 | sv.lock.Lock() 44 | defer sv.lock.Unlock() 45 | 46 | val, err := f(sv.val) 47 | if err == nil { 48 | sv.val = val 49 | } 50 | return err 51 | } 52 | -------------------------------------------------------------------------------- /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/aerospike/aerospike-client-go/pkg/bcrypt/README: -------------------------------------------------------------------------------- 1 | Installation: 2 | goinstall github.com/jameskeane/bcrypt 3 | 4 | Example use: 5 | package main 6 | 7 | import ( 8 | "fmt" 9 | "github.com/jameskeane/bcrypt" 10 | ) 11 | 12 | var password = "WyWihatdyd?frub1" 13 | var bad_password = "just a wild guess" 14 | 15 | func main() { 16 | // generate a random salt with default rounds of complexity 17 | salt, _ := bcrypt.Salt() 18 | 19 | // generate a random salt with 10 rounds of complexity 20 | salt, _ = bcrypt.Salt(10) 21 | 22 | // hash and verify a password with random salt 23 | hash, _ := bcrypt.Hash(password) 24 | if bcrypt.Match(password, hash) { 25 | fmt.Println("They match") 26 | } 27 | 28 | // hash and verify a password with a static salt 29 | hash, _ = bcrypt.Hash(password, salt) 30 | if bcrypt.Match(password, hash) { 31 | fmt.Println("They match") 32 | } 33 | 34 | // verify a random password fails to match the hashed password 35 | if !bcrypt.Match(bad_password, hash) { 36 | fmt.Println("They don't match") 37 | } 38 | } 39 | 40 | Todo: 41 | grep 'TODO' * -r 42 | 43 | Notes: 44 | * This library is derived from jBcrypt by Damien Miller 45 | * bcrypt_test.go is from ZooWar.com 46 | 47 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/bin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | // BinMap is used to define a map of bin names to values. 18 | type BinMap map[string]interface{} 19 | 20 | // Bin encapsulates a field name/value pair. 21 | type Bin struct { 22 | // Bin name. Current limit is 14 characters. 23 | Name string 24 | 25 | // Bin value. 26 | Value Value 27 | } 28 | 29 | // NewBin generates a new Bin instance, specifying bin name and string value. 30 | // For servers configured as "single-bin", enter an empty name. 31 | func NewBin(name string, value interface{}) *Bin { 32 | return &Bin{ 33 | Name: name, 34 | Value: NewValue(value), 35 | } 36 | } 37 | 38 | // String implements Stringer interface. 39 | func (bn *Bin) String() string { 40 | return bn.Name + ":" + bn.Value.String() 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/yuin/gopher-lua/ast/stmt.go: -------------------------------------------------------------------------------- 1 | package ast 2 | 3 | type Stmt interface { 4 | PositionHolder 5 | stmtMarker() 6 | } 7 | 8 | type StmtBase struct { 9 | Node 10 | } 11 | 12 | func (stmt *StmtBase) stmtMarker() {} 13 | 14 | type AssignStmt struct { 15 | StmtBase 16 | 17 | Lhs []Expr 18 | Rhs []Expr 19 | } 20 | 21 | type LocalAssignStmt struct { 22 | StmtBase 23 | 24 | Names []string 25 | Exprs []Expr 26 | } 27 | 28 | type FuncCallStmt struct { 29 | StmtBase 30 | 31 | Expr Expr 32 | } 33 | 34 | type DoBlockStmt struct { 35 | StmtBase 36 | 37 | Stmts []Stmt 38 | } 39 | 40 | type WhileStmt struct { 41 | StmtBase 42 | 43 | Condition Expr 44 | Stmts []Stmt 45 | } 46 | 47 | type RepeatStmt struct { 48 | StmtBase 49 | 50 | Condition Expr 51 | Stmts []Stmt 52 | } 53 | 54 | type IfStmt struct { 55 | StmtBase 56 | 57 | Condition Expr 58 | Then []Stmt 59 | Else []Stmt 60 | } 61 | 62 | type NumberForStmt struct { 63 | StmtBase 64 | 65 | Name string 66 | Init Expr 67 | Limit Expr 68 | Step Expr 69 | Stmts []Stmt 70 | } 71 | 72 | type GenericForStmt struct { 73 | StmtBase 74 | 75 | Names []string 76 | Exprs []Expr 77 | Stmts []Stmt 78 | } 79 | 80 | type FuncDefStmt struct { 81 | StmtBase 82 | 83 | Name *FuncName 84 | Func *FunctionExpr 85 | } 86 | 87 | type ReturnStmt struct { 88 | StmtBase 89 | 90 | Exprs []Expr 91 | } 92 | 93 | type BreakStmt struct { 94 | StmtBase 95 | } 96 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/node_error.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | import ( 18 | . "github.com/aerospike/aerospike-client-go/types" 19 | ) 20 | 21 | // NodeError is a type to encapsulate the node that the error occurred in. 22 | type NodeError struct { 23 | error 24 | 25 | node *Node 26 | } 27 | 28 | func newNodeError(node *Node, err error) *NodeError { 29 | return &NodeError{ 30 | error: err, 31 | node: node, 32 | } 33 | } 34 | 35 | func newAerospikeNodeError(node *Node, code ResultCode, messages ...string) *NodeError { 36 | return &NodeError{ 37 | error: NewAerospikeError(code, messages...), 38 | node: node, 39 | } 40 | } 41 | 42 | // Node returns the node where the error occurred. 43 | func (ne *NodeError) Node() *Node { return ne.node } 44 | 45 | // Err returns the error 46 | func (ne *NodeError) Err() error { return ne.error } 47 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/host.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | import ( 18 | "net" 19 | "strconv" 20 | ) 21 | 22 | // Host name/port of database server. 23 | type Host struct { 24 | 25 | // Host name or IP address of database server. 26 | Name string 27 | 28 | //TLSName defines the TLS certificate name used for secure connections. 29 | TLSName string 30 | 31 | // Port of database server. 32 | Port int 33 | } 34 | 35 | // NewHost initializes new host instance. 36 | func NewHost(name string, port int) *Host { 37 | return &Host{Name: name, Port: port} 38 | } 39 | 40 | // Implements stringer interface 41 | func (h *Host) String() string { 42 | return net.JoinHostPort(h.Name, strconv.Itoa(h.Port)) 43 | } 44 | 45 | // Implements stringer interface 46 | func (h *Host) equals(other *Host) bool { 47 | return h.Name == other.Name && h.Port == other.Port 48 | } 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Project status 2 | 3 | Since Aerospike 4.5 (beginning 2020) the Aerospike team have their own Prometheus exporter. It's likely a better choice if you run version 4.5 or higher of Aerospike, especially if you run the Enterprise Edition. The exporter here might be a better choice is you run an older version. PRs are still welcome, but don't expect active maintenance to stay up to date with the current Aerospike. 4 | 5 | https://github.com/aerospike/aerospike-prometheus-exporter 6 | 7 | 8 | # Aerospike Prometheus exporter 9 | 10 | This follows the logic from [asgraphite](https://github.com/aerospike/aerospike-graphite). Run a `asprom` collector against every node in the aerospike cluster. 11 | 12 | Statistics collected: 13 | 14 | * aerospike_node_*: node wide statistics. e.g. memory usage, cluster state. 15 | * aerospike_ns_*: per namespace. e.g. objects, migrations. 16 | * aerospike_sets_*: statistics per set: objects, memory usage 17 | * aerospike_latency_*: read/write/etc latency rates(!), per namespace 18 | * aerospike_ops_*: read/write/etc ops per second, per namespace 19 | 20 | ## Binaries 21 | 22 | The [releases](https://github.com/alicebob/asprom/releases) page has binaries. 23 | 24 | ## Building 25 | 26 | - install the [Go compiler](https://golang.org/dl) 27 | - run `make` 28 | - copy the `./asprom` binary to where you need it 29 | 30 | It's also easy to crosscompile with Go. You can build asprom for Linux on a Mac with: `GOOS=linux GOARCH=amd64 go build` and then copy the `asprom` binary over to your Linux machines. 31 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/index_collection_type.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | import "fmt" 18 | 19 | // IndexCollectionType is the secondary index collection type. 20 | type IndexCollectionType int 21 | 22 | const ( 23 | 24 | // Normal scalar index. 25 | ICT_DEFAULT IndexCollectionType = iota 26 | 27 | // LIST is Index list elements. 28 | ICT_LIST 29 | 30 | // MAPKEYS is Index map keys. 31 | ICT_MAPKEYS 32 | 33 | // MAPVALUES is Index map values. 34 | ICT_MAPVALUES 35 | ) 36 | 37 | // ictToString converts IndexCollectionType to string representations 38 | func ictToString(ict IndexCollectionType) string { 39 | switch ict { 40 | 41 | case ICT_LIST: 42 | return "LIST" 43 | 44 | case ICT_MAPKEYS: 45 | return "MAPKEYS" 46 | 47 | case ICT_MAPVALUES: 48 | return "MAPVALUES" 49 | 50 | default: 51 | panic(fmt.Sprintf("Unknown IndexCollectionType value %v", ict)) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /sets.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "strings" 5 | 6 | as "github.com/aerospike/aerospike-client-go" 7 | "github.com/prometheus/client_golang/prometheus" 8 | ) 9 | 10 | var ( 11 | // SetMetrics lists the keys we report from aero's sets 12 | // command. 13 | // See `asinfo -l -v sets` for the full list. 14 | SetMetrics = []metric{ 15 | gauge("memory_data_bytes", "memory data bytes"), 16 | gauge("objects", "objects"), 17 | gauge("truncate_lut", "The most covering truncate_lut for this set"), 18 | counter("stop-writes-count", "stop writes count"), 19 | } 20 | ) 21 | 22 | type setCollector cmetrics 23 | 24 | func newSetCollector() setCollector { 25 | set := map[string]cmetric{} 26 | for _, m := range SetMetrics { 27 | set[m.aeroName] = cmetric{ 28 | typ: m.typ, 29 | desc: prometheus.NewDesc( 30 | promkey(systemSet, m.aeroName), 31 | m.desc, 32 | []string{"namespace", "set"}, 33 | nil, 34 | ), 35 | } 36 | } 37 | return set 38 | } 39 | 40 | func (setc setCollector) describe(ch chan<- *prometheus.Desc) { 41 | for _, s := range setc { 42 | ch <- s.desc 43 | } 44 | } 45 | 46 | func (setc setCollector) collect(conn *as.Connection) ([]prometheus.Metric, error) { 47 | var metrics []prometheus.Metric 48 | info, err := as.RequestInfo(conn, "sets") 49 | if err != nil { 50 | return nil, err 51 | } 52 | for _, setInfo := range strings.Split(info["sets"], ";") { 53 | if setInfo == "" { 54 | continue 55 | } 56 | setStats := parseInfo(setInfo) 57 | metrics = append( 58 | metrics, 59 | infoCollect(cmetrics(setc), setInfo, setStats["ns"], setStats["set"])..., 60 | ) 61 | } 62 | return metrics, nil 63 | } 64 | -------------------------------------------------------------------------------- /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/aerospike/aerospike-client-go/compat_before_go1.8.go: -------------------------------------------------------------------------------- 1 | // +build !go1.8 2 | 3 | // Copyright 2013-2017 Aerospike, Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package aerospike 18 | 19 | import ( 20 | "crypto/tls" 21 | ) 22 | 23 | func cloneTlsConfig(c *tls.Config) *tls.Config { 24 | // .Clone() method is not available in go versions before 1.8 25 | return &tls.Config{ 26 | Certificates: c.Certificates, 27 | CipherSuites: c.CipherSuites, 28 | ClientAuth: c.ClientAuth, 29 | ClientCAs: c.ClientCAs, 30 | ClientSessionCache: c.ClientSessionCache, 31 | CurvePreferences: c.CurvePreferences, 32 | GetCertificate: c.GetCertificate, 33 | InsecureSkipVerify: c.InsecureSkipVerify, 34 | MaxVersion: c.MaxVersion, 35 | MinVersion: c.MinVersion, 36 | NameToCertificate: c.NameToCertificate, 37 | NextProtos: c.NextProtos, 38 | PreferServerCipherSuites: c.PreferServerCipherSuites, 39 | Rand: c.Rand, 40 | RootCAs: c.RootCAs, 41 | ServerName: c.ServerName, 42 | Time: c.Time, 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/role.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 2 | // 3 | // Portions may be licensed to Aerospike, Inc. under one or more contributor 4 | // license agreements. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 7 | // use this file except in compliance with the License. You may obtain a copy of 8 | // the License at http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | // License for the specific language governing permissions and limitations under 14 | // the License. 15 | 16 | package aerospike 17 | 18 | // Role allows granular access to database entities for users. 19 | type Role struct { 20 | Name string 21 | 22 | Privileges []Privilege 23 | } 24 | 25 | // Pre-defined user roles. 26 | const ( 27 | // UserAdmin allows to manages users and their roles. 28 | UserAdmin privilegeCode = "user-admin" 29 | 30 | // SysAdmin allows to manage indexes, user defined functions and server configuration. 31 | SysAdmin privilegeCode = "sys-admin" 32 | 33 | // DataAdmin allows to manage indicies and user defined functions. 34 | DataAdmin privilegeCode = "data-admin" 35 | 36 | // ReadWriteUDF allows read, write and UDF transactions with the database. 37 | ReadWriteUDF privilegeCode = "read-write-udf" 38 | 39 | // ReadWrite allows read and write transactions with the database. 40 | ReadWrite privilegeCode = "read-write" 41 | 42 | // Read allows read transactions with the database. 43 | Read privilegeCode = "read" 44 | ) 45 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/execute_command.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | type executeCommand struct { 18 | readCommand 19 | 20 | // overwrite 21 | policy *WritePolicy 22 | packageName string 23 | functionName string 24 | args *ValueArray 25 | } 26 | 27 | func newExecuteCommand( 28 | cluster *Cluster, 29 | policy *WritePolicy, 30 | key *Key, 31 | packageName string, 32 | functionName string, 33 | args *ValueArray, 34 | ) executeCommand { 35 | return executeCommand{ 36 | readCommand: newReadCommand(cluster, &policy.BasePolicy, key, nil), 37 | policy: policy, 38 | packageName: packageName, 39 | functionName: functionName, 40 | args: args, 41 | } 42 | } 43 | 44 | func (cmd *executeCommand) writeBuffer(ifc command) error { 45 | return cmd.setUdf(cmd.policy, cmd.key, cmd.packageName, cmd.functionName, cmd.args) 46 | } 47 | 48 | func (cmd *executeCommand) getNode(ifc command) (*Node, error) { 49 | return cmd.cluster.getMasterNode(&cmd.partition) 50 | } 51 | 52 | func (cmd *executeCommand) Execute() error { 53 | return cmd.execute(cmd) 54 | } 55 | -------------------------------------------------------------------------------- /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/aerospike/aerospike-client-go/pkg/bcrypt/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 James Keane . All rights reserved. 2 | Copyright (c) 2006 Damien Miller . 3 | Copyright (c) 2011 ZooWar.com, All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above 12 | copyright notice, this list of conditions and the following disclaimer 13 | in the documentation and/or other materials provided with the 14 | distribution. 15 | * Neither the name of weekendlogic nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/query_command.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | type queryCommand struct { 18 | baseMultiCommand 19 | 20 | policy *QueryPolicy 21 | statement *Statement 22 | } 23 | 24 | func newQueryCommand(node *Node, policy *QueryPolicy, statement *Statement, recordset *Recordset) *queryCommand { 25 | return &queryCommand{ 26 | baseMultiCommand: *newMultiCommand(node, recordset), 27 | policy: policy, 28 | statement: statement, 29 | } 30 | } 31 | 32 | func (cmd *queryCommand) getPolicy(ifc command) Policy { 33 | return cmd.policy 34 | } 35 | 36 | func (cmd *queryCommand) writeBuffer(ifc command) (err error) { 37 | return cmd.setQuery(cmd.policy, cmd.statement, false) 38 | } 39 | 40 | func (cmd *queryCommand) parseResult(ifc command, conn *Connection) error { 41 | return cmd.baseMultiCommand.parseResult(ifc, conn) 42 | } 43 | 44 | // Execute will run the query. 45 | func (cmd *queryCommand) Execute() error { 46 | defer cmd.recordset.signalEnd() 47 | err := cmd.execute(cmd) 48 | if err != nil { 49 | cmd.recordset.sendError(err) 50 | } 51 | return err 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/field_type.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | // FieldType represents the type of the field in Aerospike Wire Protocol 18 | type FieldType int 19 | 20 | // FieldType constants used in the Aerospike Wire Protocol. 21 | const ( 22 | NAMESPACE FieldType = 0 23 | TABLE FieldType = 1 24 | KEY FieldType = 2 25 | 26 | //BIN FieldType = 3; 27 | 28 | DIGEST_RIPE FieldType = 4 29 | 30 | //GU_TID FieldType = 5; 31 | 32 | DIGEST_RIPE_ARRAY FieldType = 6 33 | TRAN_ID FieldType = 7 // user supplied transaction id, which is simply passed back 34 | SCAN_OPTIONS FieldType = 8 35 | SCAN_TIMEOUT FieldType = 9 36 | INDEX_NAME FieldType = 21 37 | INDEX_RANGE FieldType = 22 38 | INDEX_FILTER FieldType = 23 39 | INDEX_LIMIT FieldType = 24 40 | INDEX_ORDER_BY FieldType = 25 41 | INDEX_TYPE = 26 42 | UDF_PACKAGE_NAME FieldType = 30 43 | UDF_FUNCTION FieldType = 31 44 | UDF_ARGLIST FieldType = 32 45 | UDF_OP FieldType = 33 46 | QUERY_BINLIST FieldType = 40 47 | PREDEXP FieldType = 43 48 | ) 49 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/record_exists_action.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | // RecordExistsAction determines how to handle writes when 18 | // the record already exists. 19 | type RecordExistsAction int 20 | 21 | const ( 22 | 23 | // UPDATE means: Create or update record. 24 | // Merge write command bins with existing bins. 25 | UPDATE RecordExistsAction = iota 26 | 27 | // UPDATE_ONLY means: Update record only. Fail if record does not exist. 28 | // Merge write command bins with existing bins. 29 | UPDATE_ONLY 30 | 31 | // REPLACE means: Create or replace record. 32 | // Delete existing bins not referenced by write command bins. 33 | // Supported by Aerospike 2 server versions >= 2.7.5 and 34 | // Aerospike 3 server versions >= 3.1.6. 35 | REPLACE 36 | 37 | // REPLACE_ONLY means: Replace record only. Fail if record does not exist. 38 | // Delete existing bins not referenced by write command bins. 39 | // Supported by Aerospike 2 server versions >= 2.7.5 and 40 | // Aerospike 3 server versions >= 3.1.6. 41 | REPLACE_ONLY 42 | 43 | // CREATE_ONLY means: Create only. Fail if record exists. 44 | CREATE_ONLY 45 | ) 46 | -------------------------------------------------------------------------------- /vendor/modules.txt: -------------------------------------------------------------------------------- 1 | # github.com/aerospike/aerospike-client-go v1.29.0 2 | github.com/aerospike/aerospike-client-go 3 | github.com/aerospike/aerospike-client-go/pkg/bcrypt 4 | github.com/aerospike/aerospike-client-go/internal/lua 5 | github.com/aerospike/aerospike-client-go/logger 6 | github.com/aerospike/aerospike-client-go/pkg/ripemd160 7 | github.com/aerospike/aerospike-client-go/types 8 | github.com/aerospike/aerospike-client-go/types/atomic 9 | github.com/aerospike/aerospike-client-go/types/particle_type 10 | github.com/aerospike/aerospike-client-go/types/rand 11 | github.com/aerospike/aerospike-client-go/utils/buffer 12 | github.com/aerospike/aerospike-client-go/internal/lua/resources 13 | # github.com/beorn7/perks v1.0.0 14 | github.com/beorn7/perks/quantile 15 | # github.com/golang/protobuf v1.3.1 16 | github.com/golang/protobuf/proto 17 | # github.com/matttproud/golang_protobuf_extensions v1.0.1 18 | github.com/matttproud/golang_protobuf_extensions/pbutil 19 | # github.com/prometheus/client_golang v0.9.3 20 | github.com/prometheus/client_golang/prometheus 21 | github.com/prometheus/client_golang/prometheus/promhttp 22 | github.com/prometheus/client_golang/prometheus/internal 23 | # github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 24 | github.com/prometheus/client_model/go 25 | # github.com/prometheus/common v0.4.0 26 | github.com/prometheus/common/expfmt 27 | github.com/prometheus/common/model 28 | github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg 29 | # github.com/prometheus/procfs v0.0.0-20190519111021-9935e8e0588d 30 | github.com/prometheus/procfs 31 | github.com/prometheus/procfs/internal/fs 32 | # github.com/yuin/gopher-lua v0.0.0-20181214045814-db9ae37725ec 33 | github.com/yuin/gopher-lua 34 | github.com/yuin/gopher-lua/ast 35 | github.com/yuin/gopher-lua/parse 36 | github.com/yuin/gopher-lua/pm 37 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/value_reflect.go: -------------------------------------------------------------------------------- 1 | // +build !as_performance 2 | 3 | // Copyright 2013-2017 Aerospike, Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package aerospike 18 | 19 | import ( 20 | "reflect" 21 | ) 22 | 23 | func init() { 24 | newValueReflect = concreteNewValueReflect 25 | } 26 | 27 | func concreteNewValueReflect(v interface{}) Value { 28 | // check for array and map 29 | rv := reflect.ValueOf(v) 30 | switch rv.Kind() { 31 | case reflect.Array, reflect.Slice: 32 | l := rv.Len() 33 | arr := make([]interface{}, l) 34 | for i := 0; i < l; i++ { 35 | arr[i] = rv.Index(i).Interface() 36 | } 37 | 38 | return NewListValue(arr) 39 | case reflect.Map: 40 | l := rv.Len() 41 | amap := make(map[interface{}]interface{}, l) 42 | for _, i := range rv.MapKeys() { 43 | amap[i.Interface()] = rv.MapIndex(i).Interface() 44 | } 45 | 46 | return NewMapValue(amap) 47 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: 48 | return NewLongValue(reflect.ValueOf(v).Int()) 49 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32: 50 | return NewLongValue(int64(reflect.ValueOf(v).Uint())) 51 | case reflect.String: 52 | return NewStringValue(rv.String()) 53 | } 54 | 55 | return nil 56 | } 57 | -------------------------------------------------------------------------------- /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/aerospike/aerospike-client-go/operate_command.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | import ( 18 | . "github.com/aerospike/aerospike-client-go/types" 19 | ) 20 | 21 | type operateCommand struct { 22 | readCommand 23 | 24 | policy *WritePolicy 25 | operations []*Operation 26 | 27 | hasWrite bool 28 | } 29 | 30 | func newOperateCommand(cluster *Cluster, policy *WritePolicy, key *Key, operations []*Operation) operateCommand { 31 | return operateCommand{ 32 | readCommand: newReadCommand(cluster, &policy.BasePolicy, key, nil), 33 | policy: policy, 34 | operations: operations, 35 | } 36 | } 37 | 38 | func (cmd *operateCommand) writeBuffer(ifc command) (err error) { 39 | cmd.hasWrite, err = cmd.setOperate(cmd.policy, cmd.key, cmd.operations) 40 | return err 41 | } 42 | 43 | func (cmd *operateCommand) getNode(ifc command) (*Node, error) { 44 | return cmd.cluster.getMasterNode(&cmd.partition) 45 | } 46 | 47 | func (cmd *operateCommand) Execute() error { 48 | return cmd.execute(cmd) 49 | } 50 | 51 | func (cmd *operateCommand) handleWriteKeyNotFoundError(resultCode ResultCode) error { 52 | if cmd.hasWrite { 53 | return NewAerospikeError(resultCode) 54 | } 55 | return nil 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/internal/fs/fs.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 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 fs 15 | 16 | import ( 17 | "fmt" 18 | "os" 19 | "path/filepath" 20 | ) 21 | 22 | const ( 23 | // DefaultProcMountPoint is the common mount point of the proc filesystem. 24 | DefaultProcMountPoint = "/proc" 25 | 26 | // DefaultSysMountPoint is the common mount point of the sys filesystem. 27 | DefaultSysMountPoint = "/sys" 28 | ) 29 | 30 | // FS represents a pseudo-filesystem, normally /proc or /sys, which provides an 31 | // interface to kernel data structures. 32 | type FS string 33 | 34 | // NewFS returns a new FS mounted under the given mountPoint. It will error 35 | // if the mount point can't be read. 36 | func NewFS(mountPoint string) (FS, error) { 37 | info, err := os.Stat(mountPoint) 38 | if err != nil { 39 | return "", fmt.Errorf("could not read %s: %s", mountPoint, err) 40 | } 41 | if !info.IsDir() { 42 | return "", fmt.Errorf("mount point %s is not a directory", mountPoint) 43 | } 44 | 45 | return FS(mountPoint), nil 46 | } 47 | 48 | // Path appends the given path elements to the filesystem path, adding separators 49 | // as necessary. 50 | func (fs FS) Path(p ...string) string { 51 | return filepath.Join(append([]string{string(fs)}, p...)...) 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/internal/lua/lua_aerospike.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 lua 16 | 17 | import ( 18 | "github.com/aerospike/aerospike-client-go/logger" 19 | "github.com/yuin/gopher-lua" 20 | ) 21 | 22 | type LuaAerospike struct { 23 | s chan interface{} 24 | } 25 | 26 | const luaLuaAerospikeTypeName = "LuaAerospike" 27 | 28 | // Registers my luaAerospike type to given L. 29 | func registerLuaAerospikeType(L *lua.LState) { 30 | mt := L.NewTypeMetatable(luaLuaAerospikeTypeName) 31 | 32 | L.SetGlobal("aerospike", mt) 33 | 34 | // static attributes 35 | L.SetField(mt, "log", L.NewFunction(luaAerospikeLog)) 36 | 37 | L.SetMetatable(mt, mt) 38 | } 39 | 40 | func luaAerospikeLog(L *lua.LState) int { 41 | if L.GetTop() < 2 || L.GetTop() > 3 { 42 | L.ArgError(1, "2 arguments are expected for aerospike:log method") 43 | return 0 44 | } 45 | 46 | // account for calling it on a table 47 | paramIdx := 1 48 | if L.GetTop() == 3 { 49 | paramIdx = 2 50 | } 51 | 52 | level := L.CheckInt(paramIdx) 53 | str := L.CheckString(paramIdx + 1) 54 | 55 | switch level { 56 | case 1: 57 | logger.Logger.Warn(str) 58 | case 2: 59 | logger.Logger.Info(str) 60 | case 3, 4: 61 | logger.Logger.Debug(str) 62 | } 63 | 64 | return 0 65 | } 66 | -------------------------------------------------------------------------------- /vendor/github.com/yuin/gopher-lua/linit.go: -------------------------------------------------------------------------------- 1 | package lua 2 | 3 | const ( 4 | // BaseLibName is here for consistency; the base functions have no namespace/library. 5 | BaseLibName = "" 6 | // LoadLibName is here for consistency; the loading system has no namespace/library. 7 | LoadLibName = "package" 8 | // TabLibName is the name of the table Library. 9 | TabLibName = "table" 10 | // IoLibName is the name of the io Library. 11 | IoLibName = "io" 12 | // OsLibName is the name of the os Library. 13 | OsLibName = "os" 14 | // StringLibName is the name of the string Library. 15 | StringLibName = "string" 16 | // MathLibName is the name of the math Library. 17 | MathLibName = "math" 18 | // DebugLibName is the name of the debug Library. 19 | DebugLibName = "debug" 20 | // ChannelLibName is the name of the channel Library. 21 | ChannelLibName = "channel" 22 | // CoroutineLibName is the name of the coroutine Library. 23 | CoroutineLibName = "coroutine" 24 | ) 25 | 26 | type luaLib struct { 27 | libName string 28 | libFunc LGFunction 29 | } 30 | 31 | var luaLibs = []luaLib{ 32 | luaLib{LoadLibName, OpenPackage}, 33 | luaLib{BaseLibName, OpenBase}, 34 | luaLib{TabLibName, OpenTable}, 35 | luaLib{IoLibName, OpenIo}, 36 | luaLib{OsLibName, OpenOs}, 37 | luaLib{StringLibName, OpenString}, 38 | luaLib{MathLibName, OpenMath}, 39 | luaLib{DebugLibName, OpenDebug}, 40 | luaLib{ChannelLibName, OpenChannel}, 41 | luaLib{CoroutineLibName, OpenCoroutine}, 42 | } 43 | 44 | // OpenLibs loads the built-in libraries. It is equivalent to running OpenLoad, 45 | // then OpenBase, then iterating over the other OpenXXX functions in any order. 46 | func (ls *LState) OpenLibs() { 47 | // NB: Map iteration order in Go is deliberately randomised, so must open Load/Base 48 | // prior to iterating. 49 | for _, lib := range luaLibs { 50 | ls.Push(ls.NewFunction(lib.libFunc)) 51 | ls.Push(LString(lib.libName)) 52 | ls.Call(1, 0) 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/record.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | import "fmt" 18 | 19 | // Record is the container struct for database records. 20 | // Records are equivalent to rows. 21 | type Record struct { 22 | // Key is the record's key. 23 | // Might be empty, or may only consist of digest value. 24 | Key *Key 25 | 26 | // Node from which the Record is originating from. 27 | Node *Node 28 | 29 | // Bins is the map of requested name/value bins. 30 | Bins BinMap 31 | 32 | // Generation shows record modification count. 33 | Generation uint32 34 | 35 | // Expiration is TTL (Time-To-Live). 36 | // Number of seconds until record expires. 37 | Expiration uint32 38 | } 39 | 40 | func newRecord(node *Node, key *Key, bins BinMap, generation, expiration uint32) *Record { 41 | r := &Record{ 42 | Node: node, 43 | Key: key, 44 | Bins: bins, 45 | Generation: generation, 46 | Expiration: expiration, 47 | } 48 | 49 | // always assign a map of length zero if Bins is nil 50 | if r.Bins == nil { 51 | r.Bins = make(BinMap, 0) 52 | } 53 | 54 | return r 55 | } 56 | 57 | // String implements the Stringer interface. 58 | // Returns string representation of record. 59 | func (rc *Record) String() string { 60 | return fmt.Sprintf("%s %v", rc.Key, rc.Bins) 61 | } 62 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/types/error.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 types 16 | 17 | import ( 18 | "errors" 19 | "strings" 20 | ) 21 | 22 | // AerospikeError implements error interface for aerospike specific errors. 23 | // All errors returning from the library are of this type. 24 | // Errors resulting from Go's stdlib are not translated to this type, unless 25 | // they are a net.Timeout error. 26 | type AerospikeError struct { 27 | error 28 | 29 | resultCode ResultCode 30 | } 31 | 32 | // ResultCode returns the ResultCode from AerospikeError object. 33 | func (ase AerospikeError) ResultCode() ResultCode { 34 | return ase.resultCode 35 | } 36 | 37 | // New AerospikeError generates a new AerospikeError instance. 38 | // If no message is provided, the result code will be translated into the default 39 | // error message automatically. 40 | func NewAerospikeError(code ResultCode, messages ...string) error { 41 | if len(messages) == 0 { 42 | messages = []string{ResultCodeToString(code)} 43 | } 44 | 45 | err := errors.New(strings.Join(messages, " ")) 46 | return AerospikeError{error: err, resultCode: code} 47 | } 48 | 49 | var ErrRecordsetClosed = NewAerospikeError(RECORDSET_CLOSED, "Recordset has already been closed.") 50 | var ErrConnectionPoolEmpty = NewAerospikeError(NO_AVAILABLE_CONNECTIONS_TO_NODE) 51 | -------------------------------------------------------------------------------- /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/aerospike/aerospike-client-go/types/rand/xor_shift128.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 rand 16 | 17 | import ( 18 | "encoding/binary" 19 | "sync/atomic" 20 | "time" 21 | ) 22 | 23 | const ( 24 | poolSize = 512 25 | ) 26 | 27 | // random number generator pool 28 | var pool = make([]*Xor128Rand, poolSize) 29 | var pos uint64 30 | 31 | func init() { 32 | for i := range pool { 33 | pool[i] = NewXorRand() 34 | // to guarantee a different number on less accurate system clocks 35 | time.Sleep(time.Microsecond + 31*time.Nanosecond) 36 | } 37 | } 38 | 39 | func Int64() int64 { 40 | apos := int(atomic.AddUint64(&pos, 1) % poolSize) 41 | return pool[apos].Int64() 42 | } 43 | 44 | type Xor128Rand struct { 45 | src [2]uint64 46 | } 47 | 48 | func NewXorRand() *Xor128Rand { 49 | t := time.Now().UnixNano() 50 | return &Xor128Rand{[2]uint64{uint64(t), uint64(t)}} 51 | } 52 | 53 | func (r *Xor128Rand) Int64() int64 { 54 | return int64(r.Uint64()) 55 | } 56 | 57 | func (r *Xor128Rand) Uint64() uint64 { 58 | s1 := r.src[0] 59 | s0 := r.src[1] 60 | r.src[0] = s0 61 | s1 ^= s1 << 23 62 | r.src[1] = (s1 ^ s0 ^ (s1 >> 17) ^ (s0 >> 26)) 63 | return r.src[1] + s0 64 | } 65 | 66 | func (r *Xor128Rand) Read(p []byte) (n int, err error) { 67 | l := len(p) / 8 68 | for i := 0; i < l; i += 8 { 69 | binary.PutUvarint(p[i:], r.Uint64()) 70 | } 71 | return len(p), nil 72 | } 73 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/types/atomic/bool.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 atomic 16 | 17 | import "sync/atomic" 18 | 19 | //AtomicBool implements a synchronized boolean value 20 | type AtomicBool struct { 21 | val int32 22 | } 23 | 24 | // NewAtomicBool generates a new AtomicBoolean instance. 25 | func NewAtomicBool(value bool) *AtomicBool { 26 | var i int32 27 | if value { 28 | i = 1 29 | } 30 | return &AtomicBool{ 31 | val: i, 32 | } 33 | } 34 | 35 | // Get atomically retrieves the boolean value. 36 | func (ab *AtomicBool) Get() bool { 37 | return atomic.LoadInt32(&(ab.val)) != 0 38 | } 39 | 40 | // Set atomically sets the boolean value. 41 | func (ab *AtomicBool) Set(newVal bool) { 42 | var i int32 43 | if newVal { 44 | i = 1 45 | } 46 | atomic.StoreInt32(&(ab.val), int32(i)) 47 | } 48 | 49 | // Or atomically applies OR operation to the boolean value. 50 | func (ab *AtomicBool) Or(newVal bool) bool { 51 | if !newVal { 52 | return ab.Get() 53 | } 54 | atomic.StoreInt32(&(ab.val), int32(1)) 55 | return true 56 | } 57 | 58 | //CompareAndToggle atomically sets the boolean value if the current value is equal to updated value. 59 | func (ab *AtomicBool) CompareAndToggle(expect bool) bool { 60 | updated := 1 61 | if expect { 62 | updated = 0 63 | } 64 | res := atomic.CompareAndSwapInt32(&ab.val, int32(1-updated), int32(updated)) 65 | return res 66 | } 67 | -------------------------------------------------------------------------------- /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/aerospike/aerospike-client-go/replica_policy.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2017 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | 18 | package aerospike 19 | 20 | // ReplicaPolicy defines type of node partition targeted by read commands. 21 | type ReplicaPolicy int 22 | 23 | const ( 24 | // MASTER reads from node containing key's master partition. 25 | // This is the default behavior. 26 | MASTER ReplicaPolicy = iota 27 | 28 | // MASTER_PROLES Distributes reads across nodes containing key's master and replicated partitions 29 | // in round-robin fashion. This option requires ClientPolicy.RequestProleReplicas 30 | // to be enabled in order to function properly. 31 | MASTER_PROLES 32 | 33 | // Distribute reads across all nodes in cluster in round-robin fashion. 34 | // This option is useful when the replication factor equals the number 35 | // of nodes in the cluster and the overhead of requesting proles is not desired. 36 | RANDOM 37 | 38 | // SEQUENCE Tries node containing master partition first. 39 | // If connection fails, all commands try nodes containing replicated partitions. 40 | // If socketTimeout is reached, reads also try nodes containing replicated partitions, 41 | // but writes remain on master node. 42 | // 43 | // This option requires ClientPolicy.RequestProleReplicas to be enabled 44 | // in order to function properly. 45 | SEQUENCE 46 | ) 47 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/internal/lua/instance.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 lua 16 | 17 | import ( 18 | "github.com/aerospike/aerospike-client-go/internal/lua/resources" 19 | "github.com/aerospike/aerospike-client-go/logger" 20 | "github.com/aerospike/aerospike-client-go/types" 21 | "github.com/yuin/gopher-lua" 22 | ) 23 | 24 | // SetPath sets the interpreter's current Lua Path 25 | func SetPath(lpath string) { 26 | lua.LuaPath = lpath 27 | } 28 | 29 | // LuaPath returns the interpreter's current Lua Path 30 | func LuaPath() string { 31 | return lua.LuaPath 32 | } 33 | 34 | type LuaInstance struct { 35 | instance *lua.LState 36 | } 37 | 38 | // Global LState pool 39 | var LuaPool = types.NewPool(64) 40 | 41 | func newInstance(params ...interface{}) interface{} { 42 | L := lua.NewState() 43 | 44 | registerLuaAerospikeType(L) 45 | registerLuaStreamType(L) 46 | registerLuaListType(L) 47 | registerLuaMapType(L) 48 | 49 | if err := L.DoString(luaLib.LibStreamOps); err != nil { 50 | logger.Logger.Error(err.Error()) 51 | return nil 52 | } 53 | 54 | if err := L.DoString(luaLib.LibAerospike); err != nil { 55 | logger.Logger.Error(err.Error()) 56 | return nil 57 | } 58 | 59 | return L 60 | } 61 | 62 | func finalizeInstance(instance interface{}) { 63 | if instance != nil { 64 | instance.(*lua.LState).Close() 65 | } 66 | } 67 | 68 | func init() { 69 | LuaPool.New = newInstance 70 | LuaPool.Finalize = finalizeInstance 71 | } 72 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/task_remove.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | import ( 18 | "strings" 19 | ) 20 | 21 | // RemoveTask is used to poll for UDF registration completion. 22 | type RemoveTask struct { 23 | *baseTask 24 | 25 | packageName string 26 | } 27 | 28 | // NewRemoveTask initializes a RemoveTask with fields needed to query server nodes. 29 | func NewRemoveTask(cluster *Cluster, packageName string) *RemoveTask { 30 | return &RemoveTask{ 31 | baseTask: newTask(cluster, false), 32 | packageName: packageName, 33 | } 34 | } 35 | 36 | // IsDone will query all nodes for task completion status. 37 | func (tskr *RemoveTask) IsDone() (bool, error) { 38 | command := "udf-list" 39 | nodes := tskr.cluster.GetNodes() 40 | done := false 41 | 42 | for _, node := range nodes { 43 | responseMap, err := node.requestInfoWithRetry(5, command) 44 | if err != nil { 45 | return false, err 46 | } 47 | 48 | for _, response := range responseMap { 49 | find := "filename=" + tskr.packageName 50 | index := strings.Index(response, find) 51 | 52 | if index >= 0 { 53 | return false, nil 54 | } 55 | done = true 56 | } 57 | } 58 | return done, nil 59 | } 60 | 61 | // OnComplete returns a channel that will be closed as soon as the task is finished. 62 | // If an error is encountered during operation, an error will be sent on the channel. 63 | func (tskr *RemoveTask) OnComplete() chan error { 64 | return tskr.onComplete(tskr) 65 | } 66 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/single_command.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | import ( 18 | "time" 19 | 20 | Buffer "github.com/aerospike/aerospike-client-go/utils/buffer" 21 | ) 22 | 23 | type singleCommand struct { 24 | baseCommand 25 | 26 | cluster *Cluster 27 | key *Key 28 | partition Partition 29 | } 30 | 31 | func newSingleCommand(cluster *Cluster, key *Key) singleCommand { 32 | return singleCommand{ 33 | baseCommand: baseCommand{}, 34 | cluster: cluster, 35 | key: key, 36 | partition: newPartitionByKey(key), 37 | } 38 | } 39 | 40 | func (cmd *singleCommand) getConnection(timeout time.Duration) (*Connection, error) { 41 | return cmd.node.getConnectionWithHint(timeout, cmd.key.digest[0]) 42 | } 43 | 44 | func (cmd *singleCommand) putConnection(conn *Connection) { 45 | cmd.node.putConnectionWithHint(conn, cmd.key.digest[0]) 46 | } 47 | 48 | func (cmd *singleCommand) emptySocket(conn *Connection) error { 49 | // There should not be any more bytes. 50 | // Empty the socket to be safe. 51 | sz := Buffer.BytesToInt64(cmd.dataBuffer, 0) 52 | headerLength := cmd.dataBuffer[8] 53 | receiveSize := int(sz&0xFFFFFFFFFFFF) - int(headerLength) 54 | 55 | // Read remaining message bytes. 56 | if receiveSize > 0 { 57 | if err := cmd.sizeBufferSz(receiveSize); err != nil { 58 | return err 59 | } 60 | if _, err := conn.Read(cmd.dataBuffer, receiveSize); err != nil { 61 | return err 62 | } 63 | } 64 | return nil 65 | } 66 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/value_helpers.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | // MapIter allows to define general maps of your own type to be used in the Go client 18 | // without the use of reflection. 19 | // function PackMap should be exactly Like the following (Do not change, just copy/paste and adapt PackXXX methods): 20 | // func (cm *CustomMap) PackMap(buf aerospike.BufferEx) (int, error) { 21 | // size := 0 22 | // for k, v := range cm { 23 | // n, err := PackXXX(buf, k) 24 | // size += n 25 | // if err != nil { 26 | // return size, err 27 | // } 28 | 29 | // n, err = PackXXX(buf, v) 30 | // size += n 31 | // if err != nil { 32 | // return size, err 33 | // } 34 | // } 35 | // return size, nil 36 | // } 37 | type MapIter interface { 38 | PackMap(buf BufferEx) (int, error) 39 | Len() int 40 | } 41 | 42 | // ListIter allows to define general maps of your own type to be used in the Go client 43 | // without the use of reflection. 44 | // function PackList should be exactly Like the following (Do not change, just copy/paste and adapt PackXXX methods): 45 | // func (cs *CustomSlice) PackList(buf aerospike.BufferEx) (int, error) { 46 | // size := 0 47 | // for _, elem := range cs { 48 | // n, err := PackXXX(buf, elem) 49 | // size += n 50 | // if err != nil { 51 | // return size, err 52 | // } 53 | // } 54 | // return size, nil 55 | // } 56 | type ListIter interface { 57 | PackList(buf BufferEx) (int, error) 58 | Len() int 59 | } 60 | -------------------------------------------------------------------------------- /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/aerospike/aerospike-client-go/task_register.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | import ( 18 | "strings" 19 | ) 20 | 21 | // RegisterTask is used to poll for UDF registration completion. 22 | type RegisterTask struct { 23 | *baseTask 24 | 25 | packageName string 26 | } 27 | 28 | // NewRegisterTask initializes a RegisterTask with fields needed to query server nodes. 29 | func NewRegisterTask(cluster *Cluster, packageName string) *RegisterTask { 30 | return &RegisterTask{ 31 | baseTask: newTask(cluster, false), 32 | packageName: packageName, 33 | } 34 | } 35 | 36 | // IsDone will query all nodes for task completion status. 37 | func (tskr *RegisterTask) IsDone() (bool, error) { 38 | command := "udf-list" 39 | nodes := tskr.cluster.GetNodes() 40 | done := false 41 | 42 | for _, node := range nodes { 43 | responseMap, err := node.requestInfoWithRetry(5, command) 44 | if err != nil { 45 | return false, err 46 | } 47 | 48 | for _, response := range responseMap { 49 | find := "filename=" + tskr.packageName 50 | index := strings.Index(response, find) 51 | 52 | if index < 0 { 53 | return false, nil 54 | } 55 | done = true 56 | } 57 | } 58 | return done, nil 59 | } 60 | 61 | // OnComplete returns a channel that will be closed as soon as the task is finished. 62 | // If an error is encountered during operation, an error will be sent on the channel. 63 | func (tskr *RegisterTask) OnComplete() chan error { 64 | return tskr.onComplete(tskr) 65 | } 66 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/scan_command.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | import . "github.com/aerospike/aerospike-client-go/types" 18 | 19 | type scanCommand struct { 20 | baseMultiCommand 21 | 22 | policy *ScanPolicy 23 | namespace string 24 | setName string 25 | binNames []string 26 | taskId uint64 27 | } 28 | 29 | func newScanCommand( 30 | node *Node, 31 | policy *ScanPolicy, 32 | namespace string, 33 | setName string, 34 | binNames []string, 35 | recordset *Recordset, 36 | taskId uint64, 37 | ) *scanCommand { 38 | cmd := &scanCommand{ 39 | baseMultiCommand: *newMultiCommand(node, recordset), 40 | policy: policy, 41 | namespace: namespace, 42 | setName: setName, 43 | binNames: binNames, 44 | taskId: taskId, 45 | } 46 | 47 | cmd.terminationErrorType = SCAN_TERMINATED 48 | 49 | return cmd 50 | } 51 | 52 | func (cmd *scanCommand) getPolicy(ifc command) Policy { 53 | return cmd.policy 54 | } 55 | 56 | func (cmd *scanCommand) writeBuffer(ifc command) error { 57 | return cmd.setScan(cmd.policy, &cmd.namespace, &cmd.setName, cmd.binNames, cmd.taskId) 58 | } 59 | 60 | func (cmd *scanCommand) parseResult(ifc command, conn *Connection) error { 61 | return cmd.baseMultiCommand.parseResult(cmd, conn) 62 | } 63 | 64 | func (cmd *scanCommand) Execute() error { 65 | defer cmd.recordset.signalEnd() 66 | err := cmd.execute(cmd) 67 | if err != nil { 68 | cmd.recordset.sendError(err) 69 | } 70 | return err 71 | } 72 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/types/atomic/array.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 atomic 16 | 17 | import ( 18 | "fmt" 19 | "sync" 20 | ) 21 | 22 | // AtomicArray implement a fixed width array with atomic semantics 23 | type AtomicArray struct { 24 | items []interface{} 25 | length int 26 | mutex sync.RWMutex 27 | } 28 | 29 | // NewAtomicArray generates a new AtomicArray instance. 30 | func NewAtomicArray(length int) *AtomicArray { 31 | return &AtomicArray{ 32 | length: length, 33 | items: make([]interface{}, length), 34 | } 35 | } 36 | 37 | // Get atomically retrieves an element from the Array. 38 | // If idx is out of range, it will return nil 39 | func (aa *AtomicArray) Get(idx int) interface{} { 40 | // do not lock if not needed 41 | if idx < 0 || idx >= aa.length { 42 | return nil 43 | } 44 | 45 | aa.mutex.RLock() 46 | res := aa.items[idx] 47 | aa.mutex.RUnlock() 48 | return res 49 | } 50 | 51 | // Set atomically sets an element in the Array. 52 | // If idx is out of range, it will return an error 53 | func (aa *AtomicArray) Set(idx int, node interface{}) error { 54 | // do not lock if not needed 55 | if idx < 0 || idx >= aa.length { 56 | return fmt.Errorf("index %d is larger than array size (%d)", idx, aa.length) 57 | } 58 | 59 | aa.mutex.Lock() 60 | aa.items[idx] = node 61 | aa.mutex.Unlock() 62 | return nil 63 | } 64 | 65 | // Length returns the array size. 66 | func (aa *AtomicArray) Length() int { 67 | aa.mutex.RLock() 68 | res := aa.length 69 | aa.mutex.RUnlock() 70 | 71 | return res 72 | } 73 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/task_drop_index.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | import "strings" 18 | 19 | // DropIndexTask is used to poll for long running create index completion. 20 | type DropIndexTask struct { 21 | *baseTask 22 | 23 | namespace string 24 | indexName string 25 | } 26 | 27 | // NewDropIndexTask initializes a task with fields needed to query server nodes. 28 | func NewDropIndexTask(cluster *Cluster, namespace string, indexName string) *DropIndexTask { 29 | return &DropIndexTask{ 30 | baseTask: newTask(cluster, false), 31 | namespace: namespace, 32 | indexName: indexName, 33 | } 34 | } 35 | 36 | // IsDone queries all nodes for task completion status. 37 | func (tski *DropIndexTask) IsDone() (bool, error) { 38 | command := "sindex/" + tski.namespace + "/" + tski.indexName 39 | nodes := tski.cluster.GetNodes() 40 | complete := false 41 | 42 | for _, node := range nodes { 43 | responseMap, err := node.requestInfoWithRetry(5, command) 44 | if err != nil { 45 | return false, err 46 | } 47 | 48 | for _, response := range responseMap { 49 | if strings.Contains(response, "FAIL:201") { 50 | complete = true 51 | continue 52 | } 53 | 54 | return false, nil 55 | } 56 | } 57 | return complete, nil 58 | } 59 | 60 | // OnComplete returns a channel that will be closed as soon as the task is finished. 61 | // If an error is encountered during operation, an error will be sent on the channel. 62 | func (tski *DropIndexTask) OnComplete() chan error { 63 | return tski.onComplete(tski) 64 | } 65 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/multi_policy.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | // MultiPolicy contains parameters for policy attributes used in 18 | // query and scan operations. 19 | type MultiPolicy struct { 20 | *BasePolicy 21 | 22 | // Maximum number of concurrent requests to server nodes at any poin int time. 23 | // If there are 16 nodes in the cluster and maxConcurrentNodes is 8, then queries 24 | // will be made to 8 nodes in parallel. When a query completes, a new query will 25 | // be issued until all 16 nodes have been queried. 26 | // Default (0) is to issue requests to all server nodes in parallel. 27 | MaxConcurrentNodes int 28 | 29 | // Number of records to place in queue before blocking. 30 | // Records received from multiple server nodes will be placed in a queue. 31 | // A separate goroutine consumes these records in parallel. 32 | // If the queue is full, the producer goroutines will block until records are consumed. 33 | RecordQueueSize int //= 5000 34 | 35 | // Indicates if bin data is retrieved. If false, only record digests are retrieved. 36 | IncludeBinData bool //= true; 37 | 38 | // Blocks until on-going migrations are over 39 | WaitUntilMigrationsAreOver bool //=false 40 | } 41 | 42 | // NewMultiPolicy initializes a MultiPolicy instance with default values. 43 | func NewMultiPolicy() *MultiPolicy { 44 | return &MultiPolicy{ 45 | BasePolicy: NewPolicy(), 46 | MaxConcurrentNodes: 0, 47 | RecordQueueSize: 50, 48 | IncludeBinData: true, 49 | WaitUntilMigrationsAreOver: false, 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/scan_policy.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | import "time" 18 | 19 | // ScanPolicy encapsulates parameters used in scan operations. 20 | type ScanPolicy struct { 21 | *MultiPolicy 22 | 23 | // ScanPercent determines percent of data to scan. 24 | // Valid integer range is 1 to 100. 25 | // Default is 100. 26 | ScanPercent int //= 100; 27 | 28 | // ServerSocketTimeout defines maximum time that the server will before droping an idle socket. 29 | // Zero means there is no socket timeout. 30 | // Default is 10 seconds. 31 | ServerSocketTimeout time.Duration //= 10 seconds 32 | 33 | // ConcurrentNodes determines how to issue scan requests (in parallel or sequentially). 34 | ConcurrentNodes bool //= true; 35 | 36 | // Include large data type bin values in addition to large data type bin names. 37 | // If false, LDT bin names will be returned, but LDT bin values will be empty. 38 | // If true, LDT bin names and the entire LDT bin values will be returned. 39 | // Warning: LDT values may consume huge of amounts of memory depending on LDT size. 40 | IncludeLDT bool 41 | 42 | // FailOnClusterChange determines scan termination if cluster is in fluctuating state. 43 | FailOnClusterChange bool 44 | } 45 | 46 | // NewScanPolicy creates a new ScanPolicy instance with default values. 47 | func NewScanPolicy() *ScanPolicy { 48 | return &ScanPolicy{ 49 | MultiPolicy: NewMultiPolicy(), 50 | ScanPercent: 100, 51 | ServerSocketTimeout: 10 * time.Second, 52 | ConcurrentNodes: true, 53 | IncludeLDT: false, 54 | FailOnClusterChange: true, 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /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//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/aerospike/aerospike-client-go/scan_objects_command.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | import . "github.com/aerospike/aerospike-client-go/types" 18 | 19 | // . "github.com/aerospike/aerospike-client-go/types/atomic" 20 | 21 | type scanObjectsCommand struct { 22 | baseMultiCommand 23 | 24 | policy *ScanPolicy 25 | namespace string 26 | setName string 27 | binNames []string 28 | taskId uint64 29 | } 30 | 31 | func newScanObjectsCommand( 32 | node *Node, 33 | policy *ScanPolicy, 34 | namespace string, 35 | setName string, 36 | binNames []string, 37 | recordset *Recordset, 38 | taskId uint64, 39 | ) *scanObjectsCommand { 40 | cmd := &scanObjectsCommand{ 41 | baseMultiCommand: *newMultiCommand(node, recordset), 42 | policy: policy, 43 | namespace: namespace, 44 | setName: setName, 45 | binNames: binNames, 46 | taskId: taskId, 47 | } 48 | 49 | cmd.terminationErrorType = SCAN_TERMINATED 50 | 51 | return cmd 52 | } 53 | 54 | func (cmd *scanObjectsCommand) getPolicy(ifc command) Policy { 55 | return cmd.policy 56 | } 57 | 58 | func (cmd *scanObjectsCommand) writeBuffer(ifc command) error { 59 | return cmd.setScan(cmd.policy, &cmd.namespace, &cmd.setName, cmd.binNames, cmd.taskId) 60 | } 61 | 62 | func (cmd *scanObjectsCommand) parseResult(ifc command, conn *Connection) error { 63 | return cmd.baseMultiCommand.parseResult(ifc, conn) 64 | } 65 | 66 | func (cmd *scanObjectsCommand) Execute() error { 67 | defer cmd.recordset.signalEnd() 68 | err := cmd.execute(cmd) 69 | if err != nil { 70 | cmd.recordset.sendError(err) 71 | } 72 | return err 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/yuin/gopher-lua/ast/expr.go: -------------------------------------------------------------------------------- 1 | package ast 2 | 3 | type Expr interface { 4 | PositionHolder 5 | exprMarker() 6 | } 7 | 8 | type ExprBase struct { 9 | Node 10 | } 11 | 12 | func (expr *ExprBase) exprMarker() {} 13 | 14 | /* ConstExprs {{{ */ 15 | 16 | type ConstExpr interface { 17 | Expr 18 | constExprMarker() 19 | } 20 | 21 | type ConstExprBase struct { 22 | ExprBase 23 | } 24 | 25 | func (expr *ConstExprBase) constExprMarker() {} 26 | 27 | type TrueExpr struct { 28 | ConstExprBase 29 | } 30 | 31 | type FalseExpr struct { 32 | ConstExprBase 33 | } 34 | 35 | type NilExpr struct { 36 | ConstExprBase 37 | } 38 | 39 | type NumberExpr struct { 40 | ConstExprBase 41 | 42 | Value string 43 | } 44 | 45 | type StringExpr struct { 46 | ConstExprBase 47 | 48 | Value string 49 | } 50 | 51 | /* ConstExprs }}} */ 52 | 53 | type Comma3Expr struct { 54 | ExprBase 55 | } 56 | 57 | type IdentExpr struct { 58 | ExprBase 59 | 60 | Value string 61 | } 62 | 63 | type AttrGetExpr struct { 64 | ExprBase 65 | 66 | Object Expr 67 | Key Expr 68 | } 69 | 70 | type TableExpr struct { 71 | ExprBase 72 | 73 | Fields []*Field 74 | } 75 | 76 | type FuncCallExpr struct { 77 | ExprBase 78 | 79 | Func Expr 80 | Receiver Expr 81 | Method string 82 | Args []Expr 83 | AdjustRet bool 84 | } 85 | 86 | type LogicalOpExpr struct { 87 | ExprBase 88 | 89 | Operator string 90 | Lhs Expr 91 | Rhs Expr 92 | } 93 | 94 | type RelationalOpExpr struct { 95 | ExprBase 96 | 97 | Operator string 98 | Lhs Expr 99 | Rhs Expr 100 | } 101 | 102 | type StringConcatOpExpr struct { 103 | ExprBase 104 | 105 | Lhs Expr 106 | Rhs Expr 107 | } 108 | 109 | type ArithmeticOpExpr struct { 110 | ExprBase 111 | 112 | Operator string 113 | Lhs Expr 114 | Rhs Expr 115 | } 116 | 117 | type UnaryMinusOpExpr struct { 118 | ExprBase 119 | Expr Expr 120 | } 121 | 122 | type UnaryNotOpExpr struct { 123 | ExprBase 124 | Expr Expr 125 | } 126 | 127 | type UnaryLenOpExpr struct { 128 | ExprBase 129 | Expr Expr 130 | } 131 | 132 | type FunctionExpr struct { 133 | ExprBase 134 | 135 | ParList *ParList 136 | Stmts []Stmt 137 | } 138 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/task.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | import ( 18 | "time" 19 | ) 20 | 21 | // Task interface defines methods for asynchronous tasks. 22 | type Task interface { 23 | IsDone() (bool, error) 24 | 25 | onComplete(ifc Task) chan error 26 | OnComplete() chan error 27 | } 28 | 29 | // baseTask is used to poll for server task completion. 30 | type baseTask struct { 31 | retries int 32 | cluster *Cluster 33 | done bool 34 | onCompleteChan chan error 35 | } 36 | 37 | // newTask initializes task with fields needed to query server nodes. 38 | func newTask(cluster *Cluster, done bool) *baseTask { 39 | return &baseTask{ 40 | cluster: cluster, 41 | done: done, 42 | } 43 | } 44 | 45 | // Wait for asynchronous task to complete using default sleep interval. 46 | func (btsk *baseTask) onComplete(ifc Task) chan error { 47 | // create the channel if it doesn't exist yet 48 | if btsk.onCompleteChan != nil { 49 | // channel and goroutine already exists; just return the channel 50 | return btsk.onCompleteChan 51 | } 52 | 53 | btsk.onCompleteChan = make(chan error) 54 | 55 | // goroutine will loop every until IsDone() returns true or error 56 | const interval = 1 * time.Second 57 | go func() { 58 | // always close the channel on return 59 | defer close(btsk.onCompleteChan) 60 | 61 | for { 62 | select { 63 | case <-time.After(interval): 64 | done, err := ifc.IsDone() 65 | btsk.retries++ 66 | if err != nil { 67 | btsk.onCompleteChan <- err 68 | return 69 | } else if done { 70 | btsk.onCompleteChan <- nil 71 | return 72 | } 73 | } // select 74 | } // for 75 | }() 76 | 77 | return btsk.onCompleteChan 78 | } 79 | -------------------------------------------------------------------------------- /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-filesystems /proc and /sys. 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 | 13 | ## Usage 14 | 15 | The procfs library is organized by packages based on whether the gathered data is coming from 16 | /proc, /sys, or both. Each package contains an `FS` type which represents the path to either /proc, /sys, or both. For example, current cpu statistics are gathered from 17 | `/proc/stat` and are available via the root procfs package. First, the proc filesystem mount 18 | point is initialized, and then the stat information is read. 19 | 20 | ```go 21 | fs, err := procfs.NewFS("/proc") 22 | stats, err := fs.NewStat() 23 | ``` 24 | 25 | ## Building and Testing 26 | 27 | The procfs library is normally built as part of another application. However, when making 28 | changes to the library, the `make test` command can be used to run the API test suite. 29 | 30 | ### Updating Test Fixtures 31 | 32 | The procfs library includes a set of test fixtures which include many example files from 33 | the `/proc` and `/sys` filesystems. These fixtures are included as a ttar (text tar) file 34 | which is extracted automatically during testing. To add/update the test fixtures, first 35 | ensure the `fixtures` directory is up to date by removing the existing directory and then 36 | extracting the ttar file using `make fixtures/.unpacked` or just `make test`. 37 | 38 | ```bash 39 | rm -rf fixtures 40 | make test 41 | ``` 42 | 43 | Next, make the required changes to the extracted files in the `fixtures` directory. When 44 | the changes are complete, run `make update-fixtures` to create a new `fixtures.ttar` file 45 | based on the updated `fixtures` directory. And finally, verify the changes using 46 | `git diff fixtures.ttar`. 47 | -------------------------------------------------------------------------------- /vendor/github.com/yuin/gopher-lua/tablelib.go: -------------------------------------------------------------------------------- 1 | package lua 2 | 3 | import ( 4 | "sort" 5 | ) 6 | 7 | func OpenTable(L *LState) int { 8 | tabmod := L.RegisterModule(TabLibName, tableFuncs) 9 | L.Push(tabmod) 10 | return 1 11 | } 12 | 13 | var tableFuncs = map[string]LGFunction{ 14 | "getn": tableGetN, 15 | "concat": tableConcat, 16 | "insert": tableInsert, 17 | "maxn": tableMaxN, 18 | "remove": tableRemove, 19 | "sort": tableSort, 20 | } 21 | 22 | func tableSort(L *LState) int { 23 | tbl := L.CheckTable(1) 24 | sorter := lValueArraySorter{L, nil, tbl.array} 25 | if L.GetTop() != 1 { 26 | sorter.Fn = L.CheckFunction(2) 27 | } 28 | sort.Sort(sorter) 29 | return 0 30 | } 31 | 32 | func tableGetN(L *LState) int { 33 | L.Push(LNumber(L.CheckTable(1).Len())) 34 | return 1 35 | } 36 | 37 | func tableMaxN(L *LState) int { 38 | L.Push(LNumber(L.CheckTable(1).MaxN())) 39 | return 1 40 | } 41 | 42 | func tableRemove(L *LState) int { 43 | tbl := L.CheckTable(1) 44 | if L.GetTop() == 1 { 45 | L.Push(tbl.Remove(-1)) 46 | } else { 47 | L.Push(tbl.Remove(L.CheckInt(2))) 48 | } 49 | return 1 50 | } 51 | 52 | func tableConcat(L *LState) int { 53 | tbl := L.CheckTable(1) 54 | sep := LString(L.OptString(2, "")) 55 | i := L.OptInt(3, 1) 56 | j := L.OptInt(4, tbl.Len()) 57 | if L.GetTop() == 3 { 58 | if i > tbl.Len() || i < 1 { 59 | L.Push(emptyLString) 60 | return 1 61 | } 62 | } 63 | i = intMax(intMin(i, tbl.Len()), 1) 64 | j = intMin(intMin(j, tbl.Len()), tbl.Len()) 65 | if i > j { 66 | L.Push(emptyLString) 67 | return 1 68 | } 69 | //TODO should flushing? 70 | retbottom := L.GetTop() 71 | for ; i <= j; i++ { 72 | v := tbl.RawGetInt(i) 73 | if !LVCanConvToString(v) { 74 | L.RaiseError("invalid value (%s) at index %d in table for concat", v.Type().String(), i) 75 | } 76 | L.Push(v) 77 | if i != j { 78 | L.Push(sep) 79 | } 80 | } 81 | L.Push(stringConcat(L, L.GetTop()-retbottom, L.reg.Top()-1)) 82 | return 1 83 | } 84 | 85 | func tableInsert(L *LState) int { 86 | tbl := L.CheckTable(1) 87 | nargs := L.GetTop() 88 | if nargs == 1 { 89 | L.RaiseError("wrong number of arguments") 90 | } 91 | 92 | if L.GetTop() == 2 { 93 | tbl.Append(L.Get(2)) 94 | return 0 95 | } 96 | tbl.Insert(int(L.CheckInt(2)), L.CheckAny(3)) 97 | return 0 98 | } 99 | 100 | // 101 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/types/atomic/queue.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 atomic 16 | 17 | import "sync" 18 | 19 | // AtomicQueue is a non-blocking FIFO queue. 20 | // If the queue is empty, nil is returned. 21 | // if the queue is full, offer will return false 22 | type AtomicQueue struct { 23 | head, tail uint32 24 | data []interface{} 25 | size uint32 26 | wrapped bool 27 | mutex sync.Mutex 28 | } 29 | 30 | // NewQueue creates a new queue with initial size. 31 | func NewAtomicQueue(size int) *AtomicQueue { 32 | if size <= 0 { 33 | panic("Queue size cannot be less than 1") 34 | } 35 | 36 | return &AtomicQueue{ 37 | wrapped: false, 38 | data: make([]interface{}, uint32(size)), 39 | size: uint32(size), 40 | } 41 | } 42 | 43 | // Offer adds an item to the queue unless the queue is full. 44 | // In case the queue is full, the item will not be added to the queue 45 | // and false will be returned 46 | func (q *AtomicQueue) Offer(obj interface{}) bool { 47 | q.mutex.Lock() 48 | 49 | // make sure queue is not full 50 | if q.tail == q.head && q.wrapped { 51 | q.mutex.Unlock() 52 | return false 53 | } 54 | 55 | if q.head+1 == q.size { 56 | q.wrapped = true 57 | } 58 | 59 | q.head = (q.head + 1) % q.size 60 | q.data[q.head] = obj 61 | q.mutex.Unlock() 62 | return true 63 | } 64 | 65 | // Poll removes and returns an item from the queue. 66 | // If the queue is empty, nil will be returned. 67 | func (q *AtomicQueue) Poll() (res interface{}) { 68 | q.mutex.Lock() 69 | 70 | // if queue is not empty 71 | if q.wrapped || (q.tail != q.head) { 72 | if q.tail+1 == q.size { 73 | q.wrapped = false 74 | } 75 | q.tail = (q.tail + 1) % q.size 76 | res = q.data[q.tail] 77 | } 78 | 79 | q.mutex.Unlock() 80 | return res 81 | } 82 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/partition.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | import ( 18 | "fmt" 19 | 20 | Buffer "github.com/aerospike/aerospike-client-go/utils/buffer" 21 | ) 22 | 23 | // Partition encapsulates partition information. 24 | type Partition struct { 25 | Namespace string 26 | PartitionId int 27 | } 28 | 29 | // NewPartitionByKey initializes a partition and determines the Partition Id 30 | // from key digest automatically. 31 | func NewPartitionByKey(key *Key) *Partition { 32 | partition := newPartitionByKey(key) 33 | return &partition 34 | } 35 | 36 | // newPartitionByKey initializes a partition and determines the Partition Id 37 | // from key digest automatically. It return the struct itself, and not the address 38 | func newPartitionByKey(key *Key) Partition { 39 | return Partition{ 40 | Namespace: key.namespace, 41 | 42 | // CAN'T USE MOD directly - mod will give negative numbers. 43 | // First AND makes positive and negative correctly, then mod. 44 | // For any x, y : x % 2^y = x & (2^y - 1); the second method is twice as fast 45 | PartitionId: int(Buffer.LittleBytesToInt32(key.digest[:], 0)&0xFFFF) & (_PARTITIONS - 1), 46 | } 47 | } 48 | 49 | // NewPartition generates a partition instance. 50 | func NewPartition(namespace string, partitionId int) *Partition { 51 | return &Partition{ 52 | Namespace: namespace, 53 | PartitionId: partitionId, 54 | } 55 | } 56 | 57 | // String implements the Stringer interface. 58 | func (ptn *Partition) String() string { 59 | return fmt.Sprintf("%s:%d", ptn.Namespace, ptn.PartitionId) 60 | } 61 | 62 | // Equals checks equality of two partitions. 63 | func (ptn *Partition) Equals(other *Partition) bool { 64 | return ptn.PartitionId == other.PartitionId && ptn.Namespace == other.Namespace 65 | } 66 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/touch_command.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | import ( 18 | . "github.com/aerospike/aerospike-client-go/types" 19 | Buffer "github.com/aerospike/aerospike-client-go/utils/buffer" 20 | ) 21 | 22 | // guarantee touchCommand implements command interface 23 | var _ command = &touchCommand{} 24 | 25 | type touchCommand struct { 26 | singleCommand 27 | 28 | policy *WritePolicy 29 | } 30 | 31 | func newTouchCommand(cluster *Cluster, policy *WritePolicy, key *Key) *touchCommand { 32 | newTouchCmd := &touchCommand{ 33 | singleCommand: newSingleCommand(cluster, key), 34 | policy: policy, 35 | } 36 | 37 | return newTouchCmd 38 | } 39 | 40 | func (cmd *touchCommand) getPolicy(ifc command) Policy { 41 | return cmd.policy 42 | } 43 | 44 | func (cmd *touchCommand) writeBuffer(ifc command) error { 45 | return cmd.setTouch(cmd.policy, cmd.key) 46 | } 47 | 48 | func (cmd *touchCommand) getNode(ifc command) (*Node, error) { 49 | return cmd.cluster.getMasterNode(&cmd.partition) 50 | } 51 | 52 | func (cmd *touchCommand) parseResult(ifc command, conn *Connection) error { 53 | // Read header. 54 | if _, err := conn.Read(cmd.dataBuffer, int(_MSG_TOTAL_HEADER_SIZE)); err != nil { 55 | return err 56 | } 57 | 58 | header := Buffer.BytesToInt64(cmd.dataBuffer, 0) 59 | 60 | // Validate header to make sure we are at the beginning of a message 61 | if err := cmd.validateHeader(header); err != nil { 62 | return err 63 | } 64 | 65 | resultCode := cmd.dataBuffer[13] & 0xFF 66 | 67 | if resultCode != 0 { 68 | return NewAerospikeError(ResultCode(resultCode)) 69 | } 70 | if err := cmd.emptySocket(conn); err != nil { 71 | return err 72 | } 73 | return nil 74 | } 75 | 76 | func (cmd *touchCommand) Execute() error { 77 | return cmd.execute(cmd) 78 | } 79 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/types/pool.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 types 16 | 17 | import ( 18 | . "github.com/aerospike/aerospike-client-go/types/atomic" 19 | ) 20 | 21 | // Pool implements a general purpose fixed-size pool. 22 | type Pool struct { 23 | pool *AtomicQueue 24 | 25 | // New will create a new object 26 | New func(params ...interface{}) interface{} 27 | // IsUsable checks if the object polled from the pool is still fresh and usable 28 | IsUsable func(obj interface{}, params ...interface{}) bool 29 | // CanReturn checkes if the object is eligible to go back to the pool 30 | CanReturn func(obj interface{}) bool 31 | // Finalize will be called when an object is not eligible to go back to the pool. 32 | // Usable to close connections, file handles, ... 33 | Finalize func(obj interface{}) 34 | } 35 | 36 | // NewPool creates a new fixed size pool. 37 | func NewPool(poolSize int) *Pool { 38 | return &Pool{ 39 | pool: NewAtomicQueue(poolSize), 40 | } 41 | } 42 | 43 | // Get returns an element from the pool. 44 | // If the pool is empty, or the returned element is not usable, 45 | // nil or the result of the New function will be returned 46 | func (bp *Pool) Get(params ...interface{}) interface{} { 47 | res := bp.pool.Poll() 48 | if res == nil || (bp.IsUsable != nil && !bp.IsUsable(res, params...)) { 49 | // not usable, so finalize 50 | if res != nil && bp.Finalize != nil { 51 | bp.Finalize(res) 52 | } 53 | 54 | if bp.New != nil { 55 | res = bp.New(params...) 56 | } 57 | } 58 | 59 | return res 60 | } 61 | 62 | // Put will add the elem back to the pool, unless the pool is full. 63 | func (bp *Pool) Put(obj interface{}) { 64 | finalize := true 65 | if bp.CanReturn == nil || bp.CanReturn(obj) { 66 | finalize = !bp.pool.Offer(obj) 67 | } 68 | 69 | if finalize && bp.Finalize != nil { 70 | bp.Finalize(obj) 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/types/buffer_pool.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 types 16 | 17 | import "sync" 18 | 19 | // BufferPool implements a specialized buffer pool. 20 | // Pool size will be limited, and each buffer size will be 21 | // constrained to the init and max buffer sizes. 22 | type BufferPool struct { 23 | pool [][]byte 24 | poolSize int 25 | 26 | pos int64 27 | 28 | maxBufSize int 29 | initBufSize int 30 | 31 | mutex sync.Mutex 32 | } 33 | 34 | // NewBufferPool creates a new buffer pool. 35 | // New buffers will be created with size and capacity of initBufferSize. 36 | // If cap(buffer) is larger than maxBufferSize when it is put back in the buffer, 37 | // it will be thrown away. This will prevent unwanted memory bloat and 38 | // set a deterministic maximum-size for the pool which will not be exceeded. 39 | func NewBufferPool(poolSize, initBufferSize, maxBufferSize int) *BufferPool { 40 | return &BufferPool{ 41 | pool: make([][]byte, poolSize), 42 | pos: -1, 43 | poolSize: poolSize, 44 | maxBufSize: maxBufferSize, 45 | initBufSize: initBufferSize, 46 | } 47 | } 48 | 49 | // Get returns a buffer from the pool. If pool is empty, a new buffer of 50 | // size initBufSize will be created and returned. 51 | func (bp *BufferPool) Get() (res []byte) { 52 | bp.mutex.Lock() 53 | if bp.pos >= 0 { 54 | res = bp.pool[bp.pos] 55 | bp.pos-- 56 | } else { 57 | res = make([]byte, bp.initBufSize, bp.initBufSize) 58 | } 59 | 60 | bp.mutex.Unlock() 61 | return res 62 | } 63 | 64 | // Put will put the buffer back in the pool, unless cap(buf) is bigger than 65 | // initBufSize, in which case it will be thrown away 66 | func (bp *BufferPool) Put(buf []byte) { 67 | if len(buf) <= bp.maxBufSize { 68 | bp.mutex.Lock() 69 | if bp.pos < int64(bp.poolSize-1) { 70 | bp.pos++ 71 | bp.pool[bp.pos] = buf 72 | } 73 | bp.mutex.Unlock() 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/task_index.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | import ( 18 | "regexp" 19 | "strconv" 20 | "strings" 21 | ) 22 | 23 | // IndexTask is used to poll for long running create index completion. 24 | type IndexTask struct { 25 | *baseTask 26 | 27 | namespace string 28 | indexName string 29 | } 30 | 31 | // NewIndexTask initializes a task with fields needed to query server nodes. 32 | func NewIndexTask(cluster *Cluster, namespace string, indexName string) *IndexTask { 33 | return &IndexTask{ 34 | baseTask: newTask(cluster, false), 35 | namespace: namespace, 36 | indexName: indexName, 37 | } 38 | } 39 | 40 | // IsDone queries all nodes for task completion status. 41 | func (tski *IndexTask) IsDone() (bool, error) { 42 | command := "sindex/" + tski.namespace + "/" + tski.indexName 43 | nodes := tski.cluster.GetNodes() 44 | complete := false 45 | 46 | r := regexp.MustCompile(`\.*load_pct=(\d+)\.*`) 47 | 48 | for _, node := range nodes { 49 | responseMap, err := node.requestInfoWithRetry(5, command) 50 | if err != nil { 51 | return false, err 52 | } 53 | 54 | for _, response := range responseMap { 55 | find := "load_pct=" 56 | index := strings.Index(response, find) 57 | 58 | if index < 0 { 59 | if tski.retries > 2 { 60 | complete = true 61 | } 62 | continue 63 | } 64 | 65 | matchRes := r.FindStringSubmatch(response) 66 | // we know it exists and is a valid number 67 | pct, _ := strconv.Atoi(matchRes[1]) 68 | 69 | if pct >= 0 && pct < 100 { 70 | return false, nil 71 | } 72 | complete = true 73 | } 74 | } 75 | return complete, nil 76 | } 77 | 78 | // OnComplete returns a channel that will be closed as soon as the task is finished. 79 | // If an error is encountered during operation, an error will be sent on the channel. 80 | func (tski *IndexTask) OnComplete() chan error { 81 | return tski.onComplete(tski) 82 | } 83 | -------------------------------------------------------------------------------- /vendor/github.com/yuin/gopher-lua/alloc.go: -------------------------------------------------------------------------------- 1 | package lua 2 | 3 | import ( 4 | "reflect" 5 | "unsafe" 6 | ) 7 | 8 | // iface is an internal representation of the go-interface. 9 | type iface struct { 10 | itab unsafe.Pointer 11 | word unsafe.Pointer 12 | } 13 | 14 | const preloadLimit LNumber = 128 15 | 16 | var _fv float64 17 | var _uv uintptr 18 | 19 | var preloads [int(preloadLimit)]LValue 20 | 21 | func init() { 22 | for i := 0; i < int(preloadLimit); i++ { 23 | preloads[i] = LNumber(i) 24 | } 25 | } 26 | 27 | // allocator is a fast bulk memory allocator for the LValue. 28 | type allocator struct { 29 | size int 30 | fptrs []float64 31 | fheader *reflect.SliceHeader 32 | 33 | scratchValue LValue 34 | scratchValueP *iface 35 | } 36 | 37 | func newAllocator(size int) *allocator { 38 | al := &allocator{ 39 | size: size, 40 | fptrs: make([]float64, 0, size), 41 | fheader: nil, 42 | } 43 | al.fheader = (*reflect.SliceHeader)(unsafe.Pointer(&al.fptrs)) 44 | al.scratchValue = LNumber(0) 45 | al.scratchValueP = (*iface)(unsafe.Pointer(&al.scratchValue)) 46 | 47 | return al 48 | } 49 | 50 | // LNumber2I takes a number value and returns an interface LValue representing the same number. 51 | // Converting an LNumber to a LValue naively, by doing: 52 | // `var val LValue = myLNumber` 53 | // will result in an individual heap alloc of 8 bytes for the float value. LNumber2I amortizes the cost and memory 54 | // overhead of these allocs by allocating blocks of floats instead. 55 | // The downside of this is that all of the floats on a given block have to become eligible for gc before the block 56 | // as a whole can be gc-ed. 57 | func (al *allocator) LNumber2I(v LNumber) LValue { 58 | // first check for shared preloaded numbers 59 | if v >= 0 && v < preloadLimit && float64(v) == float64(int64(v)) { 60 | return preloads[int(v)] 61 | } 62 | 63 | // check if we need a new alloc page 64 | if cap(al.fptrs) == len(al.fptrs) { 65 | al.fptrs = make([]float64, 0, al.size) 66 | al.fheader = (*reflect.SliceHeader)(unsafe.Pointer(&al.fptrs)) 67 | } 68 | 69 | // alloc a new float, and store our value into it 70 | al.fptrs = append(al.fptrs, float64(v)) 71 | fptr := (*float64)(unsafe.Pointer(al.fheader.Data + uintptr(len(al.fptrs)-1)*unsafe.Sizeof(_fv))) 72 | 73 | // hack our scratch LValue to point to our allocated value 74 | // this scratch lvalue is copied when this function returns meaning the scratch value can be reused 75 | // on the next call 76 | al.scratchValueP.word = unsafe.Pointer(fptr) 77 | 78 | return al.scratchValue 79 | } 80 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/delete_command.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | import ( 18 | . "github.com/aerospike/aerospike-client-go/types" 19 | Buffer "github.com/aerospike/aerospike-client-go/utils/buffer" 20 | ) 21 | 22 | // guarantee deleteCommand implements command interface 23 | var _ command = &deleteCommand{} 24 | 25 | type deleteCommand struct { 26 | singleCommand 27 | 28 | policy *WritePolicy 29 | existed bool 30 | } 31 | 32 | func newDeleteCommand(cluster *Cluster, policy *WritePolicy, key *Key) *deleteCommand { 33 | newDeleteCmd := &deleteCommand{ 34 | singleCommand: newSingleCommand(cluster, key), 35 | policy: policy, 36 | } 37 | 38 | return newDeleteCmd 39 | } 40 | 41 | func (cmd *deleteCommand) getPolicy(ifc command) Policy { 42 | return cmd.policy 43 | } 44 | 45 | func (cmd *deleteCommand) writeBuffer(ifc command) error { 46 | return cmd.setDelete(cmd.policy, cmd.key) 47 | } 48 | 49 | func (cmd *deleteCommand) getNode(ifc command) (*Node, error) { 50 | return cmd.cluster.getMasterNode(&cmd.partition) 51 | } 52 | 53 | func (cmd *deleteCommand) parseResult(ifc command, conn *Connection) error { 54 | // Read header. 55 | if _, err := conn.Read(cmd.dataBuffer, int(_MSG_TOTAL_HEADER_SIZE)); err != nil { 56 | return err 57 | } 58 | 59 | header := Buffer.BytesToInt64(cmd.dataBuffer, 0) 60 | 61 | // Validate header to make sure we are at the beginning of a message 62 | if err := cmd.validateHeader(header); err != nil { 63 | return err 64 | } 65 | 66 | resultCode := cmd.dataBuffer[13] & 0xFF 67 | 68 | if resultCode != 0 && ResultCode(resultCode) != KEY_NOT_FOUND_ERROR { 69 | return NewAerospikeError(ResultCode(resultCode)) 70 | } 71 | cmd.existed = resultCode == 0 72 | 73 | return cmd.emptySocket(conn) 74 | } 75 | 76 | func (cmd *deleteCommand) Existed() bool { 77 | return cmd.existed 78 | } 79 | 80 | func (cmd *deleteCommand) Execute() error { 81 | return cmd.execute(cmd) 82 | } 83 | -------------------------------------------------------------------------------- /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/aerospike/aerospike-client-go/exists_command.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | import ( 18 | . "github.com/aerospike/aerospike-client-go/types" 19 | Buffer "github.com/aerospike/aerospike-client-go/utils/buffer" 20 | ) 21 | 22 | // guarantee existsCommand implements command interface 23 | var _ command = &existsCommand{} 24 | 25 | type existsCommand struct { 26 | singleCommand 27 | 28 | policy *BasePolicy 29 | exists bool 30 | 31 | replicaSequence int 32 | } 33 | 34 | func newExistsCommand(cluster *Cluster, policy *BasePolicy, key *Key) *existsCommand { 35 | return &existsCommand{ 36 | singleCommand: newSingleCommand(cluster, key), 37 | policy: policy, 38 | } 39 | } 40 | 41 | func (cmd *existsCommand) getPolicy(ifc command) Policy { 42 | return cmd.policy 43 | } 44 | 45 | func (cmd *existsCommand) writeBuffer(ifc command) error { 46 | return cmd.setExists(cmd.policy, cmd.key) 47 | } 48 | 49 | func (cmd *existsCommand) getNode(ifc command) (*Node, error) { 50 | return cmd.cluster.getReadNode(&cmd.partition, cmd.policy.ReplicaPolicy, &cmd.replicaSequence) 51 | } 52 | 53 | func (cmd *existsCommand) parseResult(ifc command, conn *Connection) error { 54 | // Read header. 55 | if _, err := conn.Read(cmd.dataBuffer, int(_MSG_TOTAL_HEADER_SIZE)); err != nil { 56 | return err 57 | } 58 | 59 | header := Buffer.BytesToInt64(cmd.dataBuffer, 0) 60 | 61 | // Validate header to make sure we are at the beginning of a message 62 | if err := cmd.validateHeader(header); err != nil { 63 | return err 64 | } 65 | 66 | resultCode := cmd.dataBuffer[13] & 0xFF 67 | 68 | if resultCode != 0 && ResultCode(resultCode) != KEY_NOT_FOUND_ERROR { 69 | return NewAerospikeError(ResultCode(resultCode)) 70 | } 71 | cmd.exists = resultCode == 0 72 | return cmd.emptySocket(conn) 73 | } 74 | 75 | func (cmd *existsCommand) Exists() bool { 76 | return cmd.exists 77 | } 78 | 79 | func (cmd *existsCommand) Execute() error { 80 | return cmd.execute(cmd) 81 | } 82 | -------------------------------------------------------------------------------- /vendor/github.com/yuin/gopher-lua/coroutinelib.go: -------------------------------------------------------------------------------- 1 | package lua 2 | 3 | func OpenCoroutine(L *LState) int { 4 | // TODO: Tie module name to contents of linit.go? 5 | mod := L.RegisterModule(CoroutineLibName, coFuncs) 6 | L.Push(mod) 7 | return 1 8 | } 9 | 10 | var coFuncs = map[string]LGFunction{ 11 | "create": coCreate, 12 | "yield": coYield, 13 | "resume": coResume, 14 | "running": coRunning, 15 | "status": coStatus, 16 | "wrap": coWrap, 17 | } 18 | 19 | func coCreate(L *LState) int { 20 | fn := L.CheckFunction(1) 21 | newthread, _ := L.NewThread() 22 | base := 0 23 | newthread.stack.Push(callFrame{ 24 | Fn: fn, 25 | Pc: 0, 26 | Base: base, 27 | LocalBase: base + 1, 28 | ReturnBase: base, 29 | NArgs: 0, 30 | NRet: MultRet, 31 | Parent: nil, 32 | TailCall: 0, 33 | }) 34 | L.Push(newthread) 35 | return 1 36 | } 37 | 38 | func coYield(L *LState) int { 39 | return -1 40 | } 41 | 42 | func coResume(L *LState) int { 43 | th := L.CheckThread(1) 44 | if L.G.CurrentThread == th { 45 | msg := "can not resume a running thread" 46 | if th.wrapped { 47 | L.RaiseError(msg) 48 | return 0 49 | } 50 | L.Push(LFalse) 51 | L.Push(LString(msg)) 52 | return 2 53 | } 54 | if th.Dead { 55 | msg := "can not resume a dead thread" 56 | if th.wrapped { 57 | L.RaiseError(msg) 58 | return 0 59 | } 60 | L.Push(LFalse) 61 | L.Push(LString(msg)) 62 | return 2 63 | } 64 | th.Parent = L 65 | L.G.CurrentThread = th 66 | if !th.isStarted() { 67 | cf := th.stack.Last() 68 | th.currentFrame = cf 69 | th.SetTop(0) 70 | nargs := L.GetTop() - 1 71 | L.XMoveTo(th, nargs) 72 | cf.NArgs = nargs 73 | th.initCallFrame(cf) 74 | th.Panic = panicWithoutTraceback 75 | } else { 76 | nargs := L.GetTop() - 1 77 | L.XMoveTo(th, nargs) 78 | } 79 | top := L.GetTop() 80 | threadRun(th) 81 | return L.GetTop() - top 82 | } 83 | 84 | func coRunning(L *LState) int { 85 | if L.G.MainThread == L { 86 | L.Push(LNil) 87 | return 1 88 | } 89 | L.Push(L.G.CurrentThread) 90 | return 1 91 | } 92 | 93 | func coStatus(L *LState) int { 94 | L.Push(LString(L.Status(L.CheckThread(1)))) 95 | return 1 96 | } 97 | 98 | func wrapaux(L *LState) int { 99 | L.Insert(L.ToThread(UpvalueIndex(1)), 1) 100 | return coResume(L) 101 | } 102 | 103 | func coWrap(L *LState) int { 104 | coCreate(L) 105 | L.CheckThread(L.GetTop()).wrapped = true 106 | v := L.Get(L.GetTop()) 107 | L.Pop(1) 108 | L.Push(L.NewClosure(wrapaux, v)) 109 | return 1 110 | } 111 | 112 | // 113 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/write_command.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | import ( 18 | . "github.com/aerospike/aerospike-client-go/types" 19 | Buffer "github.com/aerospike/aerospike-client-go/utils/buffer" 20 | ) 21 | 22 | // guarantee writeCommand implements command interface 23 | var _ command = &writeCommand{} 24 | 25 | type writeCommand struct { 26 | singleCommand 27 | 28 | policy *WritePolicy 29 | bins []*Bin 30 | binMap BinMap 31 | operation OperationType 32 | } 33 | 34 | func newWriteCommand(cluster *Cluster, 35 | policy *WritePolicy, 36 | key *Key, 37 | bins []*Bin, 38 | binMap BinMap, 39 | operation OperationType) *writeCommand { 40 | 41 | newWriteCmd := &writeCommand{ 42 | singleCommand: newSingleCommand(cluster, key), 43 | policy: policy, 44 | bins: bins, 45 | binMap: binMap, 46 | operation: operation, 47 | } 48 | 49 | return newWriteCmd 50 | } 51 | 52 | func (cmd *writeCommand) getPolicy(ifc command) Policy { 53 | return cmd.policy 54 | } 55 | 56 | func (cmd *writeCommand) writeBuffer(ifc command) error { 57 | return cmd.setWrite(cmd.policy, cmd.operation, cmd.key, cmd.bins, cmd.binMap) 58 | } 59 | 60 | func (cmd *writeCommand) getNode(ifc command) (*Node, error) { 61 | return cmd.cluster.getMasterNode(&cmd.partition) 62 | } 63 | 64 | func (cmd *writeCommand) parseResult(ifc command, conn *Connection) error { 65 | // Read header. 66 | if _, err := conn.Read(cmd.dataBuffer, int(_MSG_TOTAL_HEADER_SIZE)); err != nil { 67 | return err 68 | } 69 | 70 | header := Buffer.BytesToInt64(cmd.dataBuffer, 0) 71 | 72 | // Validate header to make sure we are at the beginning of a message 73 | if err := cmd.validateHeader(header); err != nil { 74 | return err 75 | } 76 | 77 | resultCode := cmd.dataBuffer[13] & 0xFF 78 | 79 | if resultCode != 0 { 80 | return NewAerospikeError(ResultCode(resultCode)) 81 | } 82 | if err := cmd.emptySocket(conn); err != nil { 83 | return err 84 | } 85 | return nil 86 | } 87 | 88 | func (cmd *writeCommand) Execute() error { 89 | return cmd.execute(cmd) 90 | } 91 | -------------------------------------------------------------------------------- /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.proc.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/aerospike/aerospike-client-go/packer_reflect.go: -------------------------------------------------------------------------------- 1 | // +build !as_performance 2 | 3 | // Copyright 2013-2017 Aerospike, Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package aerospike 18 | 19 | import ( 20 | "fmt" 21 | "reflect" 22 | ) 23 | 24 | func init() { 25 | __packObjectReflect = __concretePackObjectReflect 26 | } 27 | 28 | func __concretePackObjectReflect(cmd BufferEx, obj interface{}, mapKey bool) (int, error) { 29 | // check for array and map 30 | rv := reflect.ValueOf(obj) 31 | switch reflect.TypeOf(obj).Kind() { 32 | case reflect.Array, reflect.Slice: 33 | if mapKey && reflect.TypeOf(obj).Kind() == reflect.Slice { 34 | panic(fmt.Sprintf("Maps, Slices, and bounded arrays other than Bounded Byte Arrays are not supported as Map keys. Value: %#v", obj)) 35 | } 36 | // pack bounded array of bytes differently 37 | if reflect.TypeOf(obj).Kind() == reflect.Array && reflect.TypeOf(obj).Elem().Kind() == reflect.Uint8 { 38 | l := rv.Len() 39 | arr := make([]byte, l) 40 | for i := 0; i < l; i++ { 41 | arr[i] = rv.Index(i).Interface().(uint8) 42 | } 43 | return __PackBytes(cmd, arr) 44 | } 45 | 46 | l := rv.Len() 47 | arr := make([]interface{}, l) 48 | for i := 0; i < l; i++ { 49 | arr[i] = rv.Index(i).Interface() 50 | } 51 | return __PackIfcList(cmd, arr) 52 | case reflect.Map: 53 | if mapKey { 54 | panic(fmt.Sprintf("Maps, Slices, and bounded arrays other than Bounded Byte Arrays are not supported as Map keys. Value: %#v", obj)) 55 | } 56 | l := rv.Len() 57 | amap := make(map[interface{}]interface{}, l) 58 | for _, i := range rv.MapKeys() { 59 | amap[i.Interface()] = rv.MapIndex(i).Interface() 60 | } 61 | return __PackIfcMap(cmd, amap) 62 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: 63 | return __PackObject(cmd, rv.Int(), false) 64 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: 65 | return __PackObject(cmd, rv.Uint(), false) 66 | case reflect.Bool: 67 | return __PackObject(cmd, rv.Bool(), false) 68 | case reflect.String: 69 | return __PackObject(cmd, rv.String(), false) 70 | case reflect.Float32, reflect.Float64: 71 | return __PackObject(cmd, rv.Float(), false) 72 | } 73 | 74 | panic(fmt.Sprintf("Type `%#v` not supported to pack.", obj)) 75 | } 76 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/batch_command_get_reflect.go: -------------------------------------------------------------------------------- 1 | // +build !as_performance 2 | 3 | // Copyright 2013-2017 Aerospike, Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package aerospike 18 | 19 | import ( 20 | "errors" 21 | "reflect" 22 | 23 | . "github.com/aerospike/aerospike-client-go/types" 24 | Buffer "github.com/aerospike/aerospike-client-go/utils/buffer" 25 | ) 26 | 27 | // if this file is included in the build, it will include this method 28 | func init() { 29 | batchObjectParser = parseBatchObject 30 | } 31 | 32 | func parseBatchObject( 33 | cmd *batchCommandGet, 34 | offset int, 35 | opCount int, 36 | fieldCount int, 37 | generation uint32, 38 | expiration uint32, 39 | ) error { 40 | if opCount > 0 { 41 | rv := *cmd.objects[offset] 42 | 43 | if rv.Kind() != reflect.Ptr { 44 | return errors.New("Invalid type for result object. It should be of type Struct Pointer.") 45 | } 46 | rv = rv.Elem() 47 | 48 | if !rv.CanAddr() { 49 | return errors.New("Invalid type for object. It should be addressable (a pointer)") 50 | } 51 | 52 | if rv.Kind() != reflect.Struct { 53 | return errors.New("Invalid type for object. It should be a pointer to a struct.") 54 | } 55 | 56 | // find the name based on tag mapping 57 | iobj := indirect(rv) 58 | mappings := objectMappings.getMapping(iobj.Type()) 59 | 60 | if err := setObjectMetaFields(iobj, TTL(expiration), generation); err != nil { 61 | return err 62 | } 63 | 64 | for i := 0; i < opCount; i++ { 65 | if err := cmd.readBytes(8); err != nil { 66 | return err 67 | } 68 | opSize := int(Buffer.BytesToUint32(cmd.dataBuffer, 0)) 69 | particleType := int(cmd.dataBuffer[5]) 70 | nameSize := int(cmd.dataBuffer[7]) 71 | 72 | if err := cmd.readBytes(nameSize); err != nil { 73 | return err 74 | } 75 | name := string(cmd.dataBuffer[:nameSize]) 76 | 77 | particleBytesSize := int(opSize - (4 + nameSize)) 78 | if err := cmd.readBytes(particleBytesSize); err != nil { 79 | return err 80 | } 81 | value, err := bytesToParticle(particleType, cmd.dataBuffer, 0, particleBytesSize) 82 | if err != nil { 83 | return err 84 | } 85 | if err := setObjectField(mappings, iobj, name, value); err != nil { 86 | return err 87 | } 88 | } 89 | } 90 | 91 | return nil 92 | } 93 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/peers.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | import ( 18 | "sync" 19 | 20 | // . "github.com/aerospike/aerospike-client-go/logger" 21 | . "github.com/aerospike/aerospike-client-go/types/atomic" 22 | ) 23 | 24 | type peers struct { 25 | _peers map[string]*peer 26 | _hosts map[Host]struct{} 27 | _nodes map[string]*Node 28 | refreshCount AtomicInt 29 | usePeers AtomicBool 30 | genChanged AtomicBool 31 | 32 | mutex sync.RWMutex 33 | } 34 | 35 | func newPeers(peerCapacity int, addCapacity int) *peers { 36 | return &peers{ 37 | _peers: make(map[string]*peer, peerCapacity), 38 | _hosts: make(map[Host]struct{}, addCapacity), 39 | _nodes: make(map[string]*Node, addCapacity), 40 | usePeers: *NewAtomicBool(true), 41 | genChanged: *NewAtomicBool(true), 42 | } 43 | } 44 | 45 | func (ps *peers) hostExists(host Host) bool { 46 | ps.mutex.RLock() 47 | defer ps.mutex.RUnlock() 48 | _, exists := ps._hosts[host] 49 | return exists 50 | } 51 | 52 | func (ps *peers) addHost(host Host) { 53 | ps.mutex.Lock() 54 | defer ps.mutex.Unlock() 55 | ps._hosts[host] = struct{}{} 56 | } 57 | 58 | func (ps *peers) addNode(name string, node *Node) { 59 | ps.mutex.Lock() 60 | defer ps.mutex.Unlock() 61 | ps._nodes[name] = node 62 | } 63 | 64 | func (ps *peers) nodeByName(name string) *Node { 65 | ps.mutex.RLock() 66 | defer ps.mutex.RUnlock() 67 | return ps._nodes[name] 68 | } 69 | 70 | func (ps *peers) appendPeers(peers []*peer) { 71 | ps.mutex.Lock() 72 | defer ps.mutex.Unlock() 73 | 74 | for _, peer := range peers { 75 | ps._peers[peer.nodeName] = peer 76 | } 77 | 78 | } 79 | 80 | func (ps *peers) peers() []*peer { 81 | ps.mutex.RLock() 82 | defer ps.mutex.RUnlock() 83 | 84 | res := make([]*peer, 0, len(ps._peers)) 85 | for _, peer := range ps._peers { 86 | res = append(res, peer) 87 | } 88 | return res 89 | } 90 | 91 | func (ps *peers) nodes() map[string]*Node { 92 | ps.mutex.RLock() 93 | defer ps.mutex.RUnlock() 94 | return ps._nodes 95 | } 96 | 97 | type peer struct { 98 | nodeName string 99 | tlsName string 100 | hosts []*Host 101 | } 102 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/types/message.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 types 16 | 17 | import ( 18 | "bytes" 19 | "encoding/binary" 20 | "fmt" 21 | ) 22 | 23 | type messageType uint8 24 | 25 | const ( 26 | MSG_HEADER_SIZE = 8 //sizeof(MessageHeader) 27 | 28 | MSG_INFO messageType = 1 29 | MSG_MESSAGE = 3 30 | ) 31 | 32 | type MessageHeader struct { 33 | Version uint8 34 | Type uint8 35 | DataLen [6]byte 36 | } 37 | 38 | // Length returns the length of the message 39 | func (msg *MessageHeader) Length() int64 { 40 | return msgLenFromBytes(msg.DataLen) 41 | } 42 | 43 | type Message struct { 44 | MessageHeader 45 | 46 | Data []byte 47 | } 48 | 49 | // NewMessage generates a new Message instance. 50 | func NewMessage(mtype messageType, data []byte) *Message { 51 | return &Message{ 52 | MessageHeader: MessageHeader{ 53 | Version: uint8(2), 54 | Type: uint8(mtype), 55 | DataLen: msgLenToBytes(int64(len(data))), 56 | }, 57 | Data: data, 58 | } 59 | } 60 | 61 | const maxAllowedBufferSize = 1024 * 1024 62 | 63 | // Resize changes the internal buffer size for the message. 64 | func (msg *Message) Resize(newSize int64) error { 65 | if newSize > maxAllowedBufferSize || newSize < 0 { 66 | return fmt.Errorf("Requested new buffer size is invalid. Requested: %d, allowed: 0..%d", newSize, maxAllowedBufferSize) 67 | } 68 | if int64(len(msg.Data)) == newSize { 69 | return nil 70 | } 71 | msg.Data = make([]byte, newSize) 72 | return nil 73 | } 74 | 75 | // Serialize returns a byte slice containing the message. 76 | func (msg *Message) Serialize() []byte { 77 | msg.DataLen = msgLenToBytes(int64(len(msg.Data))) 78 | buf := bytes.NewBuffer([]byte{}) 79 | binary.Write(buf, binary.BigEndian, msg.MessageHeader) 80 | binary.Write(buf, binary.BigEndian, msg.Data[:]) 81 | 82 | return buf.Bytes() 83 | } 84 | 85 | func msgLenFromBytes(buf [6]byte) int64 { 86 | nbytes := append([]byte{0, 0}, buf[:]...) 87 | DataLen := binary.BigEndian.Uint64(nbytes) 88 | return int64(DataLen) 89 | } 90 | 91 | // converts a 92 | func msgLenToBytes(DataLen int64) [6]byte { 93 | b := make([]byte, 8) 94 | binary.BigEndian.PutUint64(b, uint64(DataLen)) 95 | res := [6]byte{} 96 | copy(res[:], b[2:]) 97 | return res 98 | } 99 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/read_header_command.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | import ( 18 | . "github.com/aerospike/aerospike-client-go/types" 19 | Buffer "github.com/aerospike/aerospike-client-go/utils/buffer" 20 | ) 21 | 22 | type readHeaderCommand struct { 23 | singleCommand 24 | 25 | policy *BasePolicy 26 | record *Record 27 | 28 | replicaSequence int 29 | } 30 | 31 | func newReadHeaderCommand(cluster *Cluster, policy *BasePolicy, key *Key) *readHeaderCommand { 32 | newReadHeaderCmd := &readHeaderCommand{ 33 | singleCommand: newSingleCommand(cluster, key), 34 | policy: policy, 35 | } 36 | 37 | return newReadHeaderCmd 38 | } 39 | 40 | func (cmd *readHeaderCommand) getPolicy(ifc command) Policy { 41 | return cmd.policy 42 | } 43 | 44 | func (cmd *readHeaderCommand) writeBuffer(ifc command) error { 45 | return cmd.setReadHeader(cmd.policy, cmd.key) 46 | } 47 | 48 | func (cmd *readHeaderCommand) getNode(ifc command) (*Node, error) { 49 | return cmd.cluster.getReadNode(&cmd.partition, cmd.policy.ReplicaPolicy, &cmd.replicaSequence) 50 | } 51 | 52 | func (cmd *readHeaderCommand) parseResult(ifc command, conn *Connection) error { 53 | // Read header. 54 | if _, err := conn.Read(cmd.dataBuffer, int(_MSG_TOTAL_HEADER_SIZE)); err != nil { 55 | return err 56 | } 57 | 58 | header := Buffer.BytesToInt64(cmd.dataBuffer, 0) 59 | 60 | // Validate header to make sure we are at the beginning of a message 61 | if err := cmd.validateHeader(header); err != nil { 62 | return err 63 | } 64 | 65 | resultCode := cmd.dataBuffer[13] & 0xFF 66 | 67 | if resultCode == 0 { 68 | generation := Buffer.BytesToUint32(cmd.dataBuffer, 14) 69 | expiration := TTL(Buffer.BytesToUint32(cmd.dataBuffer, 18)) 70 | cmd.record = newRecord(cmd.node, cmd.key, nil, generation, expiration) 71 | } else { 72 | if ResultCode(resultCode) == KEY_NOT_FOUND_ERROR { 73 | cmd.record = nil 74 | } else { 75 | return NewAerospikeError(ResultCode(resultCode)) 76 | } 77 | } 78 | if err := cmd.emptySocket(conn); err != nil { 79 | return err 80 | } 81 | return nil 82 | } 83 | 84 | func (cmd *readHeaderCommand) GetRecord() *Record { 85 | return cmd.record 86 | } 87 | 88 | func (cmd *readHeaderCommand) Execute() error { 89 | return cmd.execute(cmd) 90 | } 91 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/batch_command_reflect.go: -------------------------------------------------------------------------------- 1 | // +build !as_performance 2 | 3 | // Copyright 2013-2017 Aerospike, Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package aerospike 18 | 19 | import ( 20 | "reflect" 21 | 22 | Buffer "github.com/aerospike/aerospike-client-go/utils/buffer" 23 | ) 24 | 25 | // this function will only be set if the performance flag is not passed for build 26 | func init() { 27 | multiObjectParser = batchParseObject 28 | prepareReflectionData = concretePrepareReflectionData 29 | } 30 | 31 | func concretePrepareReflectionData(cmd *baseMultiCommand) { 32 | // if a channel is assigned, assign its value type 33 | if cmd.recordset != nil && !cmd.recordset.objChan.IsNil() { 34 | // this channel must be of type chan *T 35 | cmd.resObjType = cmd.recordset.objChan.Type().Elem().Elem() 36 | cmd.resObjMappings = objectMappings.getMapping(cmd.recordset.objChan.Type().Elem().Elem()) 37 | 38 | cmd.selectCases = []reflect.SelectCase{ 39 | {Dir: reflect.SelectSend, Chan: cmd.recordset.objChan}, 40 | {Dir: reflect.SelectRecv, Chan: reflect.ValueOf(cmd.recordset.cancelled)}, 41 | } 42 | } 43 | } 44 | 45 | func batchParseObject( 46 | cmd *baseMultiCommand, 47 | obj reflect.Value, 48 | opCount int, 49 | fieldCount int, 50 | generation uint32, 51 | expiration uint32, 52 | ) error { 53 | for i := 0; i < opCount; i++ { 54 | if err := cmd.readBytes(8); err != nil { 55 | err = newNodeError(cmd.node, err) 56 | return err 57 | } 58 | 59 | opSize := int(Buffer.BytesToUint32(cmd.dataBuffer, 0)) 60 | particleType := int(cmd.dataBuffer[5]) 61 | nameSize := int(cmd.dataBuffer[7]) 62 | 63 | if err := cmd.readBytes(nameSize); err != nil { 64 | err = newNodeError(cmd.node, err) 65 | return err 66 | } 67 | name := string(cmd.dataBuffer[:nameSize]) 68 | 69 | particleBytesSize := int((opSize - (4 + nameSize))) 70 | if err := cmd.readBytes(particleBytesSize); err != nil { 71 | err = newNodeError(cmd.node, err) 72 | return err 73 | } 74 | value, err := bytesToParticle(particleType, cmd.dataBuffer, 0, particleBytesSize) 75 | if err != nil { 76 | err = newNodeError(cmd.node, err) 77 | return err 78 | } 79 | 80 | iobj := indirect(obj) 81 | if err := setObjectField(cmd.resObjMappings, iobj, name, value); err != nil { 82 | return err 83 | } 84 | } 85 | 86 | return nil 87 | } 88 | -------------------------------------------------------------------------------- /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/aerospike/aerospike-client-go/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | # - 1.4 4 | - 1.5 5 | - 1.6 6 | - 1.7 7 | - 1.8 8 | - tip 9 | matrix: 10 | allow_failures: 11 | - go: tip 12 | install: 13 | - ifconfig 14 | - if [ -d "$HOME/gopath/src/github.com/citrusleaf" ]; then mv $HOME/gopath/src/github.com/citrusleaf 15 | $HOME/gopath/src/github.com/aerospike; fi 16 | - export PATH=$PATH:$HOME/gopath/bin 17 | - go get github.com/onsi/ginkgo/ginkgo 18 | - go get github.com/onsi/gomega 19 | - go get . 20 | - if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; 21 | fi 22 | - wget -O aerospike-server.tgz http://aerospike.com/download/server/latest/artifact/tgz 23 | - tar xvzf aerospike-server.tgz 24 | - cp -f .travis/aerospike.conf ./aerospike-server/share/etc 25 | - cd aerospike-server 26 | - mkdir instance1 27 | - mkdir instance2 28 | - ./bin/aerospike init --home instance1 --instance 1 --service-port 3000 29 | - ./bin/aerospike init --home instance2 --instance 2 --service-port 3010 30 | - cd instance1 31 | - sudo ./bin/aerospike start 32 | - ../../.travis/wait_for_node.sh var/log/aerospike.log 33 | - cd ../.. 34 | - pwd 35 | script: 36 | - ginkgo -cover -race -r -keepGoing -succinct -randomizeSuites internal/lua 37 | - ginkgo -cover -race -r -keepGoing -succinct -randomizeSuites types 38 | - ginkgo -cover -race -r -keepGoing -succinct -randomizeSuites pkg 39 | - find tools -name "*.go" -type f -print0 | xargs -0 -n1 go build 40 | - find examples -name "*.go" -type f -print0 | xargs -0 -n1 go build 41 | - ginkgo -race -keepGoing -succinct -randomizeSuites -slowSpecThreshold=15 42 | - ginkgo -race -keepGoing -succinct -randomizeSuites -slowSpecThreshold=15 -- -use-replicas 43 | - ginkgo -race -keepGoing -succinct -randomizeSuites -slowSpecThreshold=15 -tags="as_performance" 44 | - cd aerospike-server/instance1 45 | - sudo ./bin/aerospike stop 46 | - cat /dev/null > var/log/aerospike.log 47 | - sudo ./bin/aerospike start 48 | - ../../.travis/wait_for_node.sh var/log/aerospike.log 49 | - cd ../instance2 50 | - sudo ./bin/aerospike start 51 | - ../../.travis/wait_for_node.sh var/log/aerospike.log 52 | - cd ../.. 53 | - ginkgo -race -keepGoing -succinct -randomizeSuites -slowSpecThreshold=15 54 | - ginkgo -race -keepGoing -succinct -randomizeSuites -slowSpecThreshold=15 -- -use-replicas 55 | - ginkgo -race -keepGoing -succinct -randomizeSuites -slowSpecThreshold=15 -tags="as_performance" 56 | - .travis/proxy_check.sh 57 | notifications: 58 | hipchat: 59 | rooms: 60 | secure: mGFpOr8JWxK0bYj6wK3ur5+qtsfK+Im1njfPgoQ2b/Sudlii/mr2QiHyQRHtstw7tr79nyoMYgQ1lc53pTxUNAVSI/PkTJTBaDE4ZkyUG5+UW8NgMsC6FYhRfgu0xq+SBNn5a6KbrL8puQq0FH6fjEDYC00QqmN5L/967WCxF8g= 61 | email: 62 | - qe-notices@aerospike.com 63 | - qe-notices-clients@aerospike.com 64 | slack: 65 | secure: FwRNnmQZLVD3ygwu66ujNTsy1rHKFAV01wZJCad+L0r5I54lxFWZxsO0JtRbhFyZ0yb4fhls4dPpczTqQrtlRgUzWW55u2i5T/bkTWxOik8QPJW35n9EvSOMYgiTQs1PQeSYwRmiqn0aDd8Fu1RAvB71nLKeyccYbVMHGyhpAq8= 66 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /vendor/github.com/aerospike/aerospike-client-go/server_command.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 aerospike 16 | 17 | import ( 18 | // "fmt" 19 | 20 | // . "github.com/aerospike/aerospike-client-go/logger" 21 | . "github.com/aerospike/aerospike-client-go/types" 22 | Buffer "github.com/aerospike/aerospike-client-go/utils/buffer" 23 | ) 24 | 25 | type serverCommand struct { 26 | queryCommand 27 | } 28 | 29 | func newServerCommand(node *Node, policy *QueryPolicy, statement *Statement) *serverCommand { 30 | return &serverCommand{ 31 | queryCommand: *newQueryCommand(node, policy, statement, nil), 32 | } 33 | } 34 | 35 | func (cmd *serverCommand) parseRecordResults(ifc command, receiveSize int) (bool, error) { 36 | // Server commands (Query/Execute UDF) should only send back a return code. 37 | // Keep parsing logic to empty socket buffer just in case server does 38 | // send records back. 39 | cmd.dataOffset = 0 40 | 41 | for cmd.dataOffset < receiveSize { 42 | if err := cmd.readBytes(int(_MSG_REMAINING_HEADER_SIZE)); err != nil { 43 | return false, err 44 | } 45 | resultCode := ResultCode(cmd.dataBuffer[5] & 0xFF) 46 | 47 | if resultCode != 0 { 48 | if resultCode == KEY_NOT_FOUND_ERROR { 49 | return false, nil 50 | } 51 | return false, NewAerospikeError(resultCode) 52 | } 53 | 54 | info3 := int(cmd.dataBuffer[3]) 55 | 56 | // If cmd is the end marker of the response, do not proceed further 57 | if (info3 & _INFO3_LAST) == _INFO3_LAST { 58 | return false, nil 59 | } 60 | 61 | fieldCount := int(Buffer.BytesToUint16(cmd.dataBuffer, 18)) 62 | opCount := int(Buffer.BytesToUint16(cmd.dataBuffer, 20)) 63 | 64 | if _, err := cmd.parseKey(fieldCount); err != nil { 65 | return false, err 66 | } 67 | 68 | for i := 0; i < opCount; i++ { 69 | if err := cmd.readBytes(8); err != nil { 70 | return false, err 71 | } 72 | opSize := int(Buffer.BytesToUint32(cmd.dataBuffer, 0)) 73 | nameSize := int(cmd.dataBuffer[7]) 74 | 75 | if err := cmd.readBytes(nameSize); err != nil { 76 | return false, err 77 | } 78 | 79 | particleBytesSize := int((opSize - (4 + nameSize))) 80 | if err := cmd.readBytes(particleBytesSize); err != nil { 81 | return false, err 82 | } 83 | } 84 | } 85 | return true, nil 86 | } 87 | 88 | func (cmd *serverCommand) Execute() error { 89 | return cmd.execute(cmd) 90 | } 91 | -------------------------------------------------------------------------------- /xdr.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "strings" 5 | 6 | as "github.com/aerospike/aerospike-client-go" 7 | "github.com/prometheus/client_golang/prometheus" 8 | ) 9 | 10 | var ( 11 | // DCMetrics lists the keys we report from aero's dc statistics command. 12 | // See `asinfo -l -v dcs` for a list of XDR DCs. 13 | // See `asinfo -l -v dc/` for detailed metrics for a given DC. 14 | DCMetrics = []metric{ 15 | gauge("dc_as_open_conn", "Number of open connection to the Aerospike DC."), 16 | gauge("dc_as_size", "The cluster size of the destination Aerospike DC."), 17 | gauge("dc_http_good_locations", "Number of URLs that are considered healthy."), 18 | gauge("dc_http_locations", "Number of URLs configured for the HTTP destination."), 19 | counter("dc_ship_attempt", "Number of records that have been attempted to be shipped."), 20 | counter("dc_ship_bytes", "Number of bytes shipped for this DC."), 21 | counter("dc_ship_delete_success", "Number of delete transactions that have been successfully shipped."), 22 | counter("dc_ship_destination_error", "Number of errors from the remote cluster(s) while shipping records for this DC."), 23 | gauge("dc_ship_idle_avg", "Average number of ms of sleep for each record being shipped."), 24 | gauge("dc_ship_idle_avg_pct", "Representation in percent of total time spent for dc_ship_idle_avg."), 25 | gauge("dc_ship_inflight_objects", "Number of records that are inflight."), 26 | gauge("dc_ship_latency_avg", "Moving average of shipping latency for the specific DC."), 27 | counter("dc_ship_source_error", "Number of client layer errors while shipping records for this DC."), 28 | counter("dc_ship_success", "Number of records that have been successfully shipped."), 29 | // dc_state https://www.aerospike.com/docs/reference/metrics/?show-removed=0#dc_state 30 | gauge("dc_timelag", "Time lag for this specific DC."), 31 | } 32 | ) 33 | 34 | type XdrDCCollector cmetrics 35 | 36 | func newXdrDCCollector() XdrDCCollector { 37 | dc := map[string]cmetric {} 38 | for _, m := range DCMetrics { 39 | dc[m.aeroName] = cmetric{ 40 | typ: m.typ, 41 | desc: prometheus.NewDesc( 42 | promkey(xdrDC, m.aeroName), 43 | m.desc, 44 | []string{"dc"}, 45 | nil, 46 | ), 47 | } 48 | } 49 | return dc 50 | } 51 | 52 | func (dcc XdrDCCollector) describe(ch chan<- *prometheus.Desc) { 53 | for _, s := range dcc { 54 | ch <- s.desc 55 | } 56 | } 57 | 58 | func (sic XdrDCCollector) collect(conn *as.Connection) ([]prometheus.Metric, error) { 59 | info, err := as.RequestInfo(conn, "dcs") 60 | if err != nil { 61 | return nil, err 62 | } 63 | 64 | var metrics []prometheus.Metric 65 | for _, dc := range strings.Split(info["dcs"], ";") { 66 | dcInfo, err := as.RequestInfo(conn, "dc/"+dc) 67 | if err != nil { 68 | return nil, err 69 | } 70 | 71 | metrics = append( 72 | metrics, 73 | infoCollect( 74 | cmetrics(sic), 75 | dcInfo["dc/"+dc], 76 | dc, 77 | )..., 78 | ) 79 | } 80 | return metrics, nil 81 | } 82 | -------------------------------------------------------------------------------- /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/aerospike/aerospike-client-go/logger/logger.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2017 Aerospike, Inc. 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 logger 16 | 17 | import ( 18 | "log" 19 | "os" 20 | "sync" 21 | ) 22 | 23 | // LogPriority specifies the logging level for the client 24 | type LogPriority int 25 | 26 | const ( 27 | DEBUG LogPriority = iota - 1 28 | INFO 29 | WARNING 30 | ERR 31 | OFF LogPriority = 999 32 | ) 33 | 34 | type genericLogger interface { 35 | Printf(format string, v ...interface{}) 36 | } 37 | 38 | type logger struct { 39 | Logger genericLogger 40 | 41 | level LogPriority 42 | mutex sync.RWMutex 43 | } 44 | 45 | // Logger is the default logger instance 46 | var Logger = newLogger() 47 | 48 | func newLogger() *logger { 49 | return &logger{ 50 | Logger: log.New(os.Stdout, "", log.LstdFlags), 51 | level: OFF, 52 | } 53 | } 54 | 55 | // SetLogger sets the *log.Logger object where log messages should be sent to. 56 | func (lgr *logger) SetLogger(l genericLogger) { 57 | lgr.mutex.Lock() 58 | defer lgr.mutex.Unlock() 59 | 60 | lgr.Logger = l 61 | } 62 | 63 | // SetLevel sets logging level. Default is ERR. 64 | func (lgr *logger) SetLevel(level LogPriority) { 65 | lgr.mutex.Lock() 66 | defer lgr.mutex.Unlock() 67 | 68 | lgr.level = level 69 | } 70 | 71 | // Error logs a message if log level allows to do so. 72 | func (lgr *logger) LogAtLevel(level LogPriority, format string, v ...interface{}) { 73 | switch level { 74 | case DEBUG: 75 | lgr.Debug(format, v) 76 | case INFO: 77 | lgr.Info(format, v) 78 | case WARNING: 79 | lgr.Warn(format, v) 80 | case ERR: 81 | lgr.Error(format, v) 82 | } 83 | } 84 | 85 | // Debug logs a message if log level allows to do so. 86 | func (lgr *logger) Debug(format string, v ...interface{}) { 87 | if lgr.level <= DEBUG { 88 | lgr.Logger.Printf(format, v...) 89 | } 90 | } 91 | 92 | // Info logs a message if log level allows to do so. 93 | func (lgr *logger) Info(format string, v ...interface{}) { 94 | if lgr.level <= INFO { 95 | lgr.Logger.Printf(format, v...) 96 | } 97 | } 98 | 99 | // Warn logs a message if log level allows to do so. 100 | func (lgr *logger) Warn(format string, v ...interface{}) { 101 | if lgr.level <= WARNING { 102 | lgr.Logger.Printf(format, v...) 103 | } 104 | } 105 | 106 | // Error logs a message if log level allows to do so. 107 | func (lgr *logger) Error(format string, v ...interface{}) { 108 | if lgr.level <= ERR { 109 | lgr.Logger.Printf(format, v...) 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------