├── .gitignore ├── vendor ├── github.com │ ├── hashicorp │ │ ├── go-hclog │ │ │ ├── .gitignore │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── global.go │ │ │ ├── LICENSE │ │ │ ├── context.go │ │ │ ├── nulllogger.go │ │ │ ├── writer.go │ │ │ ├── stdlog.go │ │ │ └── stacktrace.go │ │ ├── go-immutable-radix │ │ │ ├── .travis.yml │ │ │ ├── go.mod │ │ │ ├── edges.go │ │ │ ├── go.sum │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── raw_iter.go │ │ │ └── iter.go │ │ ├── raft-boltdb │ │ │ ├── .travis.yml │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ └── util.go │ │ ├── raft │ │ │ ├── .gitignore │ │ │ ├── go.mod │ │ │ ├── tag.sh │ │ │ ├── stable.go │ │ │ ├── .travis.yml │ │ │ ├── testing_batch.go │ │ │ ├── .golangci-lint.yml │ │ │ ├── log_cache.go │ │ │ ├── discard_snapshot.go │ │ │ ├── Makefile │ │ │ ├── peersjson.go │ │ │ ├── inmem_snapshot.go │ │ │ ├── log.go │ │ │ ├── inmem_store.go │ │ │ ├── util.go │ │ │ ├── tcp_transport.go │ │ │ ├── commitment.go │ │ │ └── CHANGELOG.md │ │ ├── golang-lru │ │ │ └── simplelru │ │ │ │ └── lru_interface.go │ │ └── go-msgpack │ │ │ └── LICENSE │ ├── boltdb │ │ └── bolt │ │ │ ├── .gitignore │ │ │ ├── boltsync_unix.go │ │ │ ├── bolt_linux.go │ │ │ ├── bolt_ppc.go │ │ │ ├── bolt_386.go │ │ │ ├── bolt_amd64.go │ │ │ ├── appveyor.yml │ │ │ ├── bolt_arm64.go │ │ │ ├── bolt_ppc64.go │ │ │ ├── bolt_ppc64le.go │ │ │ ├── bolt_s390x.go │ │ │ ├── Makefile │ │ │ ├── bolt_openbsd.go │ │ │ ├── bolt_arm.go │ │ │ ├── LICENSE │ │ │ ├── doc.go │ │ │ ├── bolt_unix_solaris.go │ │ │ ├── bolt_unix.go │ │ │ └── errors.go │ └── armon │ │ └── go-metrics │ │ ├── .travis.yml │ │ ├── const_unix.go │ │ ├── const_windows.go │ │ ├── .gitignore │ │ ├── go.mod │ │ ├── LICENSE │ │ └── inmem_signal.go ├── golang.org │ └── x │ │ └── sys │ │ ├── unix │ │ ├── .gitignore │ │ ├── endian_big.go │ │ ├── endian_little.go │ │ ├── constants.go │ │ ├── syscall_linux_amd64_gc.go │ │ ├── aliases.go │ │ ├── pagesize_unix.go │ │ ├── fcntl_linux_32bit.go │ │ ├── asm_aix_ppc64.s │ │ ├── asm_solaris_amd64.s │ │ ├── gccgo_linux_amd64.go │ │ ├── syscall_linux_gc.go │ │ ├── race0.go │ │ ├── syscall_solaris_amd64.go │ │ ├── syscall_linux_gc_386.go │ │ ├── fcntl_darwin.go │ │ ├── dirent.go │ │ ├── syscall_linux_gccgo_arm.go │ │ ├── syscall_unix_gc.go │ │ ├── str.go │ │ ├── race.go │ │ ├── env_unix.go │ │ ├── asm_freebsd_arm.s │ │ ├── asm_netbsd_arm.s │ │ ├── asm_openbsd_arm.s │ │ ├── asm_netbsd_arm64.s │ │ ├── asm_darwin_386.s │ │ ├── asm_freebsd_386.s │ │ ├── asm_netbsd_386.s │ │ ├── asm_openbsd_386.s │ │ ├── asm_darwin_amd64.s │ │ ├── asm_freebsd_amd64.s │ │ ├── asm_freebsd_arm64.s │ │ ├── asm_netbsd_amd64.s │ │ ├── asm_openbsd_amd64.s │ │ ├── asm_openbsd_arm64.s │ │ ├── asm_dragonfly_amd64.s │ │ ├── asm_darwin_arm.s │ │ ├── bluetooth_linux.go │ │ ├── asm_darwin_arm64.s │ │ ├── dev_darwin.go │ │ ├── dev_aix_ppc.go │ │ ├── syscall_netbsd_amd64.go │ │ ├── syscall_netbsd_arm64.go │ │ ├── syscall_netbsd_386.go │ │ ├── syscall_netbsd_arm.go │ │ ├── syscall_unix_gc_ppc64x.go │ │ ├── dev_aix_ppc64.go │ │ ├── dev_netbsd.go │ │ ├── dev_openbsd.go │ │ ├── ioctl.go │ │ ├── syscall_openbsd_amd64.go │ │ ├── syscall_openbsd_arm64.go │ │ ├── syscall_openbsd_386.go │ │ ├── syscall_openbsd_arm.go │ │ ├── fcntl.go │ │ ├── asm_linux_ppc64x.s │ │ ├── syscall_linux_gccgo_386.go │ │ ├── dev_freebsd.go │ │ ├── dev_dragonfly.go │ │ ├── sockcmsg_linux.go │ │ ├── gccgo_c.c │ │ ├── unveil_openbsd.go │ │ ├── asm_linux_arm64.s │ │ ├── asm_linux_arm.s │ │ ├── asm_linux_s390x.s │ │ ├── zptracearm_linux.go │ │ ├── asm_linux_mipsx.s │ │ ├── asm_linux_mips64x.s │ │ ├── syscall_darwin_libSystem.go │ │ ├── syscall_dragonfly_amd64.go │ │ ├── syscall_freebsd_amd64.go │ │ ├── syscall_freebsd_arm64.go │ │ ├── asm_linux_amd64.s │ │ ├── syscall_freebsd_arm.go │ │ ├── syscall_freebsd_386.go │ │ ├── syscall_aix_ppc.go │ │ ├── zptracemips_linux.go │ │ ├── zptracemipsle_linux.go │ │ ├── asm_linux_386.s │ │ ├── dev_linux.go │ │ ├── mkasm_darwin.go │ │ ├── syscall_darwin_arm.go │ │ ├── syscall_darwin_arm64.go │ │ ├── syscall.go │ │ ├── zptrace386_linux.go │ │ ├── syscall_darwin_amd64.go │ │ ├── gccgo.go │ │ ├── syscall_darwin_386.go │ │ ├── syscall_aix_ppc64.go │ │ └── timestruct.go │ │ ├── AUTHORS │ │ ├── CONTRIBUTORS │ │ ├── PATENTS │ │ └── LICENSE └── modules.txt ├── image ├── safety.jpg ├── election.png ├── log_replicate.jpg ├── machine_state.png ├── request_process.png └── election_timeout.jpeg ├── go.mod ├── fsm └── fsm.go ├── myraft └── my_raft.go ├── README.md └── main.go /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | node*/ 3 | raft-demo -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-hclog/.gitignore: -------------------------------------------------------------------------------- 1 | .idea* -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/.gitignore: -------------------------------------------------------------------------------- 1 | _obj/ 2 | unix.test 3 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/.gitignore: -------------------------------------------------------------------------------- 1 | *.prof 2 | *.test 3 | *.swp 4 | /bin/ 5 | -------------------------------------------------------------------------------- /image/safety.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vision9527/raft-demo/HEAD/image/safety.jpg -------------------------------------------------------------------------------- /image/election.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vision9527/raft-demo/HEAD/image/election.png -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-immutable-radix/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - tip 4 | -------------------------------------------------------------------------------- /image/log_replicate.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vision9527/raft-demo/HEAD/image/log_replicate.jpg -------------------------------------------------------------------------------- /image/machine_state.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vision9527/raft-demo/HEAD/image/machine_state.png -------------------------------------------------------------------------------- /image/request_process.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vision9527/raft-demo/HEAD/image/request_process.png -------------------------------------------------------------------------------- /image/election_timeout.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vision9527/raft-demo/HEAD/image/election_timeout.jpeg -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/raft-boltdb/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.6 5 | - 1.7 6 | - tip 7 | 8 | install: make deps 9 | script: 10 | - make test 11 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/vision9527/raft-demo 2 | 3 | go 1.13 4 | 5 | require ( 6 | github.com/hashicorp/raft v1.1.2 7 | github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea 8 | ) 9 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-immutable-radix/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/hashicorp/go-immutable-radix 2 | 3 | require ( 4 | github.com/hashicorp/go-uuid v1.0.0 5 | github.com/hashicorp/golang-lru v0.5.0 6 | ) 7 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/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/golang.org/x/sys/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/armon/go-metrics/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - "1.x" 5 | 6 | env: 7 | - GO111MODULE=on 8 | 9 | install: 10 | - go get ./... 11 | 12 | script: 13 | - go test ./... 14 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/boltsync_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows,!plan9,!linux,!openbsd 2 | 3 | package bolt 4 | 5 | // fdatasync flushes written data to a file descriptor. 6 | func fdatasync(db *DB) error { 7 | return db.file.Sync() 8 | } 9 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-hclog/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/hashicorp/go-hclog 2 | 3 | require ( 4 | github.com/davecgh/go-spew v1.1.1 // indirect 5 | github.com/pmezard/go-difflib v1.0.0 // indirect 6 | github.com/stretchr/testify v1.2.2 7 | ) 8 | -------------------------------------------------------------------------------- /vendor/github.com/armon/go-metrics/const_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package metrics 4 | 5 | import ( 6 | "syscall" 7 | ) 8 | 9 | const ( 10 | // DefaultSignal is used with DefaultInmemSignal 11 | DefaultSignal = syscall.SIGUSR1 12 | ) 13 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/bolt_linux.go: -------------------------------------------------------------------------------- 1 | package bolt 2 | 3 | import ( 4 | "syscall" 5 | ) 6 | 7 | // fdatasync flushes written data to a file descriptor. 8 | func fdatasync(db *DB) error { 9 | return syscall.Fdatasync(int(db.file.Fd())) 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/raft-boltdb/Makefile: -------------------------------------------------------------------------------- 1 | DEPS = $(go list -f '{{range .TestImports}}{{.}} {{end}}' ./...) 2 | 3 | .PHONY: test deps 4 | 5 | test: 6 | go test -timeout=30s ./... 7 | 8 | deps: 9 | go get -d -v ./... 10 | echo $(DEPS) | xargs -n1 go get -d 11 | 12 | -------------------------------------------------------------------------------- /vendor/github.com/armon/go-metrics/const_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package metrics 4 | 5 | import ( 6 | "syscall" 7 | ) 8 | 9 | const ( 10 | // DefaultSignal is used with DefaultInmemSignal 11 | // Windows has no SIGUSR1, use SIGBREAK 12 | DefaultSignal = syscall.Signal(21) 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/bolt_ppc.go: -------------------------------------------------------------------------------- 1 | // +build ppc 2 | 3 | package bolt 4 | 5 | // maxMapSize represents the largest mmap size supported by Bolt. 6 | const maxMapSize = 0x7FFFFFFF // 2GB 7 | 8 | // maxAllocSize is the size used when creating array pointers. 9 | const maxAllocSize = 0xFFFFFFF 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_big.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build ppc64 s390x mips mips64 6 | 7 | package unix 8 | 9 | const isBigEndian = true 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_little.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le 6 | 7 | package unix 8 | 9 | const isBigEndian = false 10 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/bolt_386.go: -------------------------------------------------------------------------------- 1 | package bolt 2 | 3 | // maxMapSize represents the largest mmap size supported by Bolt. 4 | const maxMapSize = 0x7FFFFFFF // 2GB 5 | 6 | // maxAllocSize is the size used when creating array pointers. 7 | const maxAllocSize = 0xFFFFFFF 8 | 9 | // Are unaligned load/stores broken on this arch? 10 | var brokenUnaligned = false 11 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/bolt_amd64.go: -------------------------------------------------------------------------------- 1 | package bolt 2 | 3 | // maxMapSize represents the largest mmap size supported by Bolt. 4 | const maxMapSize = 0xFFFFFFFFFFFF // 256TB 5 | 6 | // maxAllocSize is the size used when creating array pointers. 7 | const maxAllocSize = 0x7FFFFFFF 8 | 9 | // Are unaligned load/stores broken on this arch? 10 | var brokenUnaligned = false 11 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: "{build}" 2 | 3 | os: Windows Server 2012 R2 4 | 5 | clone_folder: c:\gopath\src\github.com\boltdb\bolt 6 | 7 | environment: 8 | GOPATH: c:\gopath 9 | 10 | install: 11 | - echo %PATH% 12 | - echo %GOPATH% 13 | - go version 14 | - go env 15 | - go get -v -t ./... 16 | 17 | build_script: 18 | - go test -v ./... 19 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/constants.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | const ( 10 | R_OK = 0x4 11 | W_OK = 0x2 12 | X_OK = 0x1 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/raft/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,linux 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | //go:noescape 13 | func gettimeofday(tv *Timeval) (err syscall.Errno) 14 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/bolt_arm64.go: -------------------------------------------------------------------------------- 1 | // +build arm64 2 | 3 | package bolt 4 | 5 | // maxMapSize represents the largest mmap size supported by Bolt. 6 | const maxMapSize = 0xFFFFFFFFFFFF // 256TB 7 | 8 | // maxAllocSize is the size used when creating array pointers. 9 | const maxAllocSize = 0x7FFFFFFF 10 | 11 | // Are unaligned load/stores broken on this arch? 12 | var brokenUnaligned = false 13 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/bolt_ppc64.go: -------------------------------------------------------------------------------- 1 | // +build ppc64 2 | 3 | package bolt 4 | 5 | // maxMapSize represents the largest mmap size supported by Bolt. 6 | const maxMapSize = 0xFFFFFFFFFFFF // 256TB 7 | 8 | // maxAllocSize is the size used when creating array pointers. 9 | const maxAllocSize = 0x7FFFFFFF 10 | 11 | // Are unaligned load/stores broken on this arch? 12 | var brokenUnaligned = false 13 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/bolt_ppc64le.go: -------------------------------------------------------------------------------- 1 | // +build ppc64le 2 | 3 | package bolt 4 | 5 | // maxMapSize represents the largest mmap size supported by Bolt. 6 | const maxMapSize = 0xFFFFFFFFFFFF // 256TB 7 | 8 | // maxAllocSize is the size used when creating array pointers. 9 | const maxAllocSize = 0x7FFFFFFF 10 | 11 | // Are unaligned load/stores broken on this arch? 12 | var brokenUnaligned = false 13 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/bolt_s390x.go: -------------------------------------------------------------------------------- 1 | // +build s390x 2 | 3 | package bolt 4 | 5 | // maxMapSize represents the largest mmap size supported by Bolt. 6 | const maxMapSize = 0xFFFFFFFFFFFF // 256TB 7 | 8 | // maxAllocSize is the size used when creating array pointers. 9 | const maxAllocSize = 0x7FFFFFFF 10 | 11 | // Are unaligned load/stores broken on this arch? 12 | var brokenUnaligned = false 13 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-immutable-radix/edges.go: -------------------------------------------------------------------------------- 1 | package iradix 2 | 3 | import "sort" 4 | 5 | type edges []edge 6 | 7 | func (e edges) Len() int { 8 | return len(e) 9 | } 10 | 11 | func (e edges) Less(i, j int) bool { 12 | return e[i].label < e[j].label 13 | } 14 | 15 | func (e edges) Swap(i, j int) { 16 | e[i], e[j] = e[j], e[i] 17 | } 18 | 19 | func (e edges) Sort() { 20 | sort.Sort(e) 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-immutable-radix/go.sum: -------------------------------------------------------------------------------- 1 | github.com/hashicorp/go-uuid v1.0.0 h1:RS8zrF7PhGwyNPOtxSClXXj9HA8feRnJzgnI1RJCSnM= 2 | github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= 3 | github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= 4 | github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 5 | -------------------------------------------------------------------------------- /vendor/github.com/armon/go-metrics/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | 24 | /metrics.out 25 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-immutable-radix/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/aliases.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build go1.9 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | type Signal = syscall.Signal 13 | type Errno = syscall.Errno 14 | type SysProcAttr = syscall.SysProcAttr 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/pagesize_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // For Unix, get the pagesize from the runtime. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getpagesize() int { 14 | return syscall.Getpagesize() 15 | } 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm linux,mips linux,mipsle 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package unix 8 | 9 | func init() { 10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 12 | fcntl64Syscall = SYS_FCNTL64 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/raft/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/hashicorp/raft 2 | 3 | go 1.12 4 | 5 | require ( 6 | github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878 7 | github.com/boltdb/bolt v1.3.1 // indirect 8 | github.com/hashicorp/go-hclog v0.9.1 9 | github.com/hashicorp/go-msgpack v0.5.5 10 | github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea 11 | github.com/stretchr/testify v1.3.0 12 | golang.org/x/sys v0.0.0-20190523142557-0e01d883c5c5 // indirect 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/raft/tag.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | # The version must be supplied from the environment. Do not include the 5 | # leading "v". 6 | if [ -z $VERSION ]; then 7 | echo "Please specify a version." 8 | exit 1 9 | fi 10 | 11 | # Generate the tag. 12 | echo "==> Tagging version $VERSION..." 13 | git commit --allow-empty -a --gpg-sign=348FFC4C -m "Release v$VERSION" 14 | git tag -a -m "Version $VERSION" -s -u 348FFC4C "v${VERSION}" master 15 | 16 | exit 0 17 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/raft-boltdb/README.md: -------------------------------------------------------------------------------- 1 | raft-boltdb 2 | =========== 3 | 4 | This repository provides the `raftboltdb` package. The package exports the 5 | `BoltStore` which is an implementation of both a `LogStore` and `StableStore`. 6 | 7 | It is meant to be used as a backend for the `raft` [package 8 | here](https://github.com/hashicorp/raft). 9 | 10 | This implementation uses [BoltDB](https://github.com/boltdb/bolt). BoltDB is 11 | a simple key/value store implemented in pure Go, and inspired by LMDB. 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_aix_ppc64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for ppc64, AIX are implemented in runtime/syscall_aix.go 11 | // 12 | 13 | TEXT ·syscall6(SB),NOSPLIT,$0-88 14 | JMP syscall·syscall6(SB) 15 | 16 | TEXT ·rawSyscall6(SB),NOSPLIT,$0-88 17 | JMP syscall·rawSyscall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/Makefile: -------------------------------------------------------------------------------- 1 | BRANCH=`git rev-parse --abbrev-ref HEAD` 2 | COMMIT=`git rev-parse --short HEAD` 3 | GOLDFLAGS="-X main.branch $(BRANCH) -X main.commit $(COMMIT)" 4 | 5 | default: build 6 | 7 | race: 8 | @go test -v -race -test.run="TestSimulate_(100op|1000op)" 9 | 10 | # go get github.com/kisielk/errcheck 11 | errcheck: 12 | @errcheck -ignorepkg=bytes -ignore=os:Remove github.com/boltdb/bolt 13 | 14 | test: 15 | @go test -v -cover . 16 | @go test -v ./cmd/bolt 17 | 18 | .PHONY: fmt test 19 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_solaris_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 11 | // 12 | 13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-88 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/raft/stable.go: -------------------------------------------------------------------------------- 1 | package raft 2 | 3 | // StableStore is used to provide stable storage 4 | // of key configurations to ensure safety. 5 | type StableStore interface { 6 | Set(key []byte, val []byte) error 7 | 8 | // Get returns the value for key, or an empty byte slice if key was not found. 9 | Get(key []byte) ([]byte, error) 10 | 11 | SetUint64(key []byte, val uint64) error 12 | 13 | // GetUint64 returns the uint64 value for key, or 0 if key was not found. 14 | GetUint64(key []byte) (uint64, error) 15 | } 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo,linux,amd64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern gettimeofday 12 | func realGettimeofday(*Timeval, *byte) int32 13 | 14 | func gettimeofday(tv *Timeval) (err syscall.Errno) { 15 | r := realGettimeofday(tv, nil) 16 | if r < 0 { 17 | return syscall.GetErrno() 18 | } 19 | return 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-hclog/go.sum: -------------------------------------------------------------------------------- 1 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 2 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 3 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 4 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 5 | github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= 6 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 7 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux,!gccgo 6 | 7 | package unix 8 | 9 | // SyscallNoError may be used instead of Syscall for syscalls that don't fail. 10 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 11 | 12 | // RawSyscallNoError may be used instead of RawSyscall for syscalls that don't 13 | // fail. 14 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race0.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const raceenabled = false 14 | 15 | func raceAcquire(addr unsafe.Pointer) { 16 | } 17 | 18 | func raceReleaseMerge(addr unsafe.Pointer) { 19 | } 20 | 21 | func raceReadRange(addr unsafe.Pointer, len int) { 22 | } 23 | 24 | func raceWriteRange(addr unsafe.Pointer, len int) { 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func (iov *Iovec) SetLen(length int) { 18 | iov.Len = uint64(length) 19 | } 20 | 21 | func (cmsg *Cmsghdr) SetLen(length int) { 22 | cmsg.Len = uint32(length) 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/raft/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | # Disabled until https://github.com/armon/go-metrics/issues/59 is fixed 5 | # - 1.6 6 | - 1.8 7 | - 1.9 8 | - 1.12 9 | - tip 10 | 11 | install: 12 | - make deps 13 | - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin latest 14 | 15 | script: 16 | - make integ 17 | 18 | notifications: 19 | flowdock: 20 | secure: fZrcf9rlh2IrQrlch1sHkn3YI7SKvjGnAl/zyV5D6NROe1Bbr6d3QRMuCXWWdhJHzjKmXk5rIzbqJhUc0PNF7YjxGNKSzqWMQ56KcvN1k8DzlqxpqkcA3Jbs6fXCWo2fssRtZ7hj/wOP1f5n6cc7kzHDt9dgaYJ6nO2fqNPJiTc= 21 | 22 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/bolt_openbsd.go: -------------------------------------------------------------------------------- 1 | package bolt 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | const ( 9 | msAsync = 1 << iota // perform asynchronous writes 10 | msSync // perform synchronous writes 11 | msInvalidate // invalidate cached data 12 | ) 13 | 14 | func msync(db *DB) error { 15 | _, _, errno := syscall.Syscall(syscall.SYS_MSYNC, uintptr(unsafe.Pointer(db.data)), uintptr(db.datasz), msInvalidate) 16 | if errno != 0 { 17 | return errno 18 | } 19 | return nil 20 | } 21 | 22 | func fdatasync(db *DB) error { 23 | if db.data != nil { 24 | return msync(db) 25 | } 26 | return db.file.Sync() 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/armon/go-metrics/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/armon/go-metrics 2 | 3 | go 1.12 4 | 5 | require ( 6 | github.com/DataDog/datadog-go v2.2.0+incompatible 7 | github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible 8 | github.com/circonus-labs/circonusllhist v0.1.3 // indirect 9 | github.com/hashicorp/go-immutable-radix v1.0.0 10 | github.com/hashicorp/go-retryablehttp v0.5.3 // indirect 11 | github.com/pascaldekloe/goe v0.1.0 12 | github.com/pkg/errors v0.8.1 // indirect 13 | github.com/prometheus/client_golang v0.9.2 14 | github.com/stretchr/testify v1.3.0 // indirect 15 | github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926 // indirect 16 | ) 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gc_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux,!gccgo,386 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // Underlying system call writes to newoffset via pointer. 12 | // Implemented in assembly to avoid allocation. 13 | func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) 14 | 15 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) 16 | func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fcntl_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | import "unsafe" 8 | 9 | // FcntlInt performs a fcntl syscall on fd with the provided command and argument. 10 | func FcntlInt(fd uintptr, cmd, arg int) (int, error) { 11 | return fcntl(int(fd), cmd, arg) 12 | } 13 | 14 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 15 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 16 | _, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(lk)))) 17 | return err 18 | } 19 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dirent.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // ParseDirent parses up to max directory entries in buf, 12 | // appending the names to names. It returns the number of 13 | // bytes consumed from buf, the number of entries added 14 | // to names, and the new names slice. 15 | func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) { 16 | return syscall.ParseDirent(buf, max, names) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gccgo_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux,gccgo,arm 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func seek(fd int, offset int64, whence int) (int64, syscall.Errno) { 15 | var newoffset int64 16 | offsetLow := uint32(offset & 0xffffffff) 17 | offsetHigh := uint32((offset >> 32) & 0xffffffff) 18 | _, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) 19 | return newoffset, err 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_unix_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build !gccgo,!ppc64le,!ppc64 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 13 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 14 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 15 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/str.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + uitoa(uint(-val)) 12 | } 13 | return uitoa(uint(val)) 14 | } 15 | 16 | func uitoa(val uint) string { 17 | var buf [32]byte // big enough for int64 18 | i := len(buf) - 1 19 | for val >= 10 { 20 | buf[i] = byte(val%10 + '0') 21 | i-- 22 | val /= 10 23 | } 24 | buf[i] = byte(val + '0') 25 | return string(buf[i:]) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/raft/testing_batch.go: -------------------------------------------------------------------------------- 1 | // +build batchtest 2 | 3 | package raft 4 | 5 | func init() { 6 | userSnapshotErrorsOnNoData = false 7 | } 8 | 9 | // ApplyBatch enables MockFSM to satisfy the BatchingFSM interface. This 10 | // function is gated by the batchtest build flag. 11 | // 12 | // NOTE: This is exposed for middleware testing purposes and is not a stable API 13 | func (m *MockFSM) ApplyBatch(logs []*Log) []interface{} { 14 | m.Lock() 15 | defer m.Unlock() 16 | 17 | ret := make([]interface{}, len(logs)) 18 | for i, log := range logs { 19 | switch log.Type { 20 | case LogCommand: 21 | m.logs = append(m.logs, log.Data) 22 | ret[i] = len(m.logs) 23 | default: 24 | ret[i] = nil 25 | } 26 | } 27 | 28 | return ret 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin,race linux,race freebsd,race 6 | 7 | package unix 8 | 9 | import ( 10 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Unix environment variables. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | 29 | func Unsetenv(key string) error { 30 | return syscall.Unsetenv(key) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/modules.txt: -------------------------------------------------------------------------------- 1 | # github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878 2 | github.com/armon/go-metrics 3 | # github.com/boltdb/bolt v1.3.1 4 | github.com/boltdb/bolt 5 | # github.com/hashicorp/go-hclog v0.9.1 6 | github.com/hashicorp/go-hclog 7 | # github.com/hashicorp/go-immutable-radix v1.0.0 8 | github.com/hashicorp/go-immutable-radix 9 | # github.com/hashicorp/go-msgpack v0.5.5 10 | github.com/hashicorp/go-msgpack/codec 11 | # github.com/hashicorp/golang-lru v0.5.0 12 | github.com/hashicorp/golang-lru/simplelru 13 | # github.com/hashicorp/raft v1.1.2 14 | github.com/hashicorp/raft 15 | # github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea 16 | github.com/hashicorp/raft-boltdb 17 | # golang.org/x/sys v0.0.0-20190523142557-0e01d883c5c5 18 | golang.org/x/sys/unix 19 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for arm64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, DragonFly 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for ARM, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-28 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | ) 27 | 28 | // Socketoption Level 29 | const ( 30 | SOL_BLUETOOTH = 0x112 31 | SOL_HCI = 0x0 32 | SOL_L2CAP = 0x6 33 | SOL_RFCOMM = 0x12 34 | SOL_SCO = 0x11 35 | ) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm64,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for AMD64, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-hclog/global.go: -------------------------------------------------------------------------------- 1 | package hclog 2 | 3 | import ( 4 | "sync" 5 | ) 6 | 7 | var ( 8 | protect sync.Once 9 | def Logger 10 | 11 | // DefaultOptions is used to create the Default logger. These are read 12 | // only when the Default logger is created, so set them as soon as the 13 | // process starts. 14 | DefaultOptions = &LoggerOptions{ 15 | Level: DefaultLevel, 16 | Output: DefaultOutput, 17 | } 18 | ) 19 | 20 | // Default returns a globally held logger. This can be a good starting 21 | // place, and then you can use .With() and .Name() to create sub-loggers 22 | // to be used in more specific contexts. 23 | func Default() Logger { 24 | protect.Do(func() { 25 | def = New(DefaultOptions) 26 | }) 27 | 28 | return def 29 | } 30 | 31 | // L is a short alias for Default(). 32 | func L() Logger { 33 | return Default() 34 | } 35 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Darwin's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of a Darwin device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev >> 24) & 0xff) 13 | } 14 | 15 | // Minor returns the minor component of a Darwin device number. 16 | func Minor(dev uint64) uint32 { 17 | return uint32(dev & 0xffffff) 18 | } 19 | 20 | // Mkdev returns a Darwin device number generated from the given major and minor 21 | // components. 22 | func Mkdev(major, minor uint32) uint64 { 23 | return (uint64(major) << 24) | uint64(minor) 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_aix_ppc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix 6 | // +build ppc 7 | 8 | // Functions to access/create device major and minor numbers matching the 9 | // encoding used by AIX. 10 | 11 | package unix 12 | 13 | // Major returns the major component of a Linux device number. 14 | func Major(dev uint64) uint32 { 15 | return uint32((dev >> 16) & 0xffff) 16 | } 17 | 18 | // Minor returns the minor component of a Linux device number. 19 | func Minor(dev uint64) uint32 { 20 | return uint32(dev & 0xffff) 21 | } 22 | 23 | // Mkdev returns a Linux device number generated from the given major and minor 24 | // components. 25 | func Mkdev(major, minor uint32) uint64 { 26 | return uint64(((major) << 16) | (minor)) 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm64,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build ppc64le ppc64 7 | // +build !gccgo 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 14 | return syscall.Syscall(trap, a1, a2, a3) 15 | } 16 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 17 | return syscall.Syscall6(trap, a1, a2, a3, a4, a5, a6) 18 | } 19 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 20 | return syscall.RawSyscall(trap, a1, a2, a3) 21 | } 22 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 23 | return syscall.RawSyscall6(trap, a1, a2, a3, a4, a5, a6) 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/bolt_arm.go: -------------------------------------------------------------------------------- 1 | package bolt 2 | 3 | import "unsafe" 4 | 5 | // maxMapSize represents the largest mmap size supported by Bolt. 6 | const maxMapSize = 0x7FFFFFFF // 2GB 7 | 8 | // maxAllocSize is the size used when creating array pointers. 9 | const maxAllocSize = 0xFFFFFFF 10 | 11 | // Are unaligned load/stores broken on this arch? 12 | var brokenUnaligned bool 13 | 14 | func init() { 15 | // Simple check to see whether this arch handles unaligned load/stores 16 | // correctly. 17 | 18 | // ARM9 and older devices require load/stores to be from/to aligned 19 | // addresses. If not, the lower 2 bits are cleared and that address is 20 | // read in a jumbled up order. 21 | 22 | // See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka15414.html 23 | 24 | raw := [6]byte{0xfe, 0xef, 0x11, 0x22, 0x22, 0x11} 25 | val := *(*uint32)(unsafe.Pointer(uintptr(unsafe.Pointer(&raw)) + 2)) 26 | 27 | brokenUnaligned = val != 0x11222211 28 | } 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_aix_ppc64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix 6 | // +build ppc64 7 | 8 | // Functions to access/create device major and minor numbers matching the 9 | // encoding used AIX. 10 | 11 | package unix 12 | 13 | // Major returns the major component of a Linux device number. 14 | func Major(dev uint64) uint32 { 15 | return uint32((dev & 0x3fffffff00000000) >> 32) 16 | } 17 | 18 | // Minor returns the minor component of a Linux device number. 19 | func Minor(dev uint64) uint32 { 20 | return uint32((dev & 0x00000000ffffffff) >> 0) 21 | } 22 | 23 | // Mkdev returns a Linux device number generated from the given major and minor 24 | // components. 25 | func Mkdev(major, minor uint32) uint64 { 26 | var DEVNO64 uint64 27 | DEVNO64 = 0x8000000000000000 28 | return ((uint64(major) << 32) | (uint64(minor) & 0x00000000FFFFFFFF) | DEVNO64) 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/raft-boltdb/util.go: -------------------------------------------------------------------------------- 1 | package raftboltdb 2 | 3 | import ( 4 | "bytes" 5 | "encoding/binary" 6 | 7 | "github.com/hashicorp/go-msgpack/codec" 8 | ) 9 | 10 | // Decode reverses the encode operation on a byte slice input 11 | func decodeMsgPack(buf []byte, out interface{}) error { 12 | r := bytes.NewBuffer(buf) 13 | hd := codec.MsgpackHandle{} 14 | dec := codec.NewDecoder(r, &hd) 15 | return dec.Decode(out) 16 | } 17 | 18 | // Encode writes an encoded object to a new bytes buffer 19 | func encodeMsgPack(in interface{}) (*bytes.Buffer, error) { 20 | buf := bytes.NewBuffer(nil) 21 | hd := codec.MsgpackHandle{} 22 | enc := codec.NewEncoder(buf, &hd) 23 | err := enc.Encode(in) 24 | return buf, err 25 | } 26 | 27 | // Converts bytes to an integer 28 | func bytesToUint64(b []byte) uint64 { 29 | return binary.BigEndian.Uint64(b) 30 | } 31 | 32 | // Converts a uint to a byte slice 33 | func uint64ToBytes(u uint64) []byte { 34 | buf := make([]byte, 8) 35 | binary.BigEndian.PutUint64(buf, u) 36 | return buf 37 | } 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_netbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in NetBSD's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of a NetBSD device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev & 0x000fff00) >> 8) 13 | } 14 | 15 | // Minor returns the minor component of a NetBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xfff00000) >> 12) 19 | return minor 20 | } 21 | 22 | // Mkdev returns a NetBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x000fff00 26 | dev |= (uint64(minor) << 12) & 0xfff00000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_openbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in OpenBSD's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of an OpenBSD device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev & 0x0000ff00) >> 8) 13 | } 14 | 15 | // Minor returns the minor component of an OpenBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xffff0000) >> 8) 19 | return minor 20 | } 21 | 22 | // Mkdev returns an OpenBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x0000ff00 26 | dev |= (uint64(minor) << 8) & 0xffff0000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ioctl.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import "runtime" 10 | 11 | // IoctlSetWinsize performs an ioctl on fd with a *Winsize argument. 12 | // 13 | // To change fd's window size, the req argument should be TIOCSWINSZ. 14 | func IoctlSetWinsize(fd int, req uint, value *Winsize) error { 15 | // TODO: if we get the chance, remove the req parameter and 16 | // hardcode TIOCSWINSZ. 17 | err := ioctlSetWinsize(fd, req, value) 18 | runtime.KeepAlive(value) 19 | return err 20 | } 21 | 22 | // IoctlSetTermios performs an ioctl on fd with a *Termios. 23 | // 24 | // The req value will usually be TCSETA or TIOCSETA. 25 | func IoctlSetTermios(fd int, req uint, value *Termios) error { 26 | // TODO: if we get the chance, remove the req parameter. 27 | err := ioctlSetTermios(fd, req, value) 28 | runtime.KeepAlive(value) 29 | return err 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | 35 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 36 | // of openbsd/amd64 the syscall is called sysctl instead of __sysctl. 37 | const SYS___SYSCTL = SYS_SYSCTL 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm64,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | 35 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 36 | // of openbsd/amd64 the syscall is called sysctl instead of __sysctl. 37 | const SYS___SYSCTL = SYS_SYSCTL 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | 35 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 36 | // of openbsd/386 the syscall is called sysctl instead of __sysctl. 37 | const SYS___SYSCTL = SYS_SYSCTL 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | 35 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 36 | // of openbsd/arm the syscall is called sysctl instead of __sysctl. 37 | const SYS___SYSCTL = SYS_SYSCTL 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fcntl.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build dragonfly freebsd linux netbsd openbsd 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 12 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 13 | var fcntl64Syscall uintptr = SYS_FCNTL 14 | 15 | // FcntlInt performs a fcntl syscall on fd with the provided command and argument. 16 | func FcntlInt(fd uintptr, cmd, arg int) (int, error) { 17 | valptr, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(arg)) 18 | var err error 19 | if errno != 0 { 20 | err = errno 21 | } 22 | return int(valptr), err 23 | } 24 | 25 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 26 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 27 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 28 | if errno == 0 { 29 | return nil 30 | } 31 | return errno 32 | } 33 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build ppc64 ppc64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for ppc64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 19 | BL runtime·entersyscall(SB) 20 | MOVD a1+8(FP), R3 21 | MOVD a2+16(FP), R4 22 | MOVD a3+24(FP), R5 23 | MOVD R0, R6 24 | MOVD R0, R7 25 | MOVD R0, R8 26 | MOVD trap+0(FP), R9 // syscall entry 27 | SYSCALL R9 28 | MOVD R3, r1+32(FP) 29 | MOVD R4, r2+40(FP) 30 | BL runtime·exitsyscall(SB) 31 | RET 32 | 33 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 34 | MOVD a1+8(FP), R3 35 | MOVD a2+16(FP), R4 36 | MOVD a3+24(FP), R5 37 | MOVD R0, R6 38 | MOVD R0, R7 39 | MOVD R0, R8 40 | MOVD trap+0(FP), R9 // syscall entry 41 | SYSCALL R9 42 | MOVD R3, r1+32(FP) 43 | MOVD R4, r2+40(FP) 44 | RET 45 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gccgo_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux,gccgo,386 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func seek(fd int, offset int64, whence int) (int64, syscall.Errno) { 15 | var newoffset int64 16 | offsetLow := uint32(offset & 0xffffffff) 17 | offsetHigh := uint32((offset >> 32) & 0xffffffff) 18 | _, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) 19 | return newoffset, err 20 | } 21 | 22 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) { 23 | fd, _, err := Syscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0) 24 | return int(fd), err 25 | } 26 | 27 | func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) { 28 | fd, _, err := RawSyscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0) 29 | return int(fd), err 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_freebsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in FreeBSD's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a FreeBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a FreeBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a FreeBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Ben Johnson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | 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, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-hclog/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 HashiCorp 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/armon/go-metrics/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Armon Dadgar 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | 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, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_dragonfly.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Dragonfly's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a DragonFlyBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a DragonFlyBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a DragonFlyBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Socket control messages 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // UnixCredentials encodes credentials into a socket control message 12 | // for sending to another process. This can be used for 13 | // authentication. 14 | func UnixCredentials(ucred *Ucred) []byte { 15 | b := make([]byte, CmsgSpace(SizeofUcred)) 16 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 17 | h.Level = SOL_SOCKET 18 | h.Type = SCM_CREDENTIALS 19 | h.SetLen(CmsgLen(SizeofUcred)) 20 | *((*Ucred)(cmsgData(h))) = *ucred 21 | return b 22 | } 23 | 24 | // ParseUnixCredentials decodes a socket control message that contains 25 | // credentials in a Ucred structure. To receive such a message, the 26 | // SO_PASSCRED option must be enabled on the socket. 27 | func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) { 28 | if m.Header.Level != SOL_SOCKET { 29 | return nil, EINVAL 30 | } 31 | if m.Header.Type != SCM_CREDENTIALS { 32 | return nil, EINVAL 33 | } 34 | ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0])) 35 | return &ucred, nil 36 | } 37 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_c.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | // +build !aix 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #define _STRINGIFY2_(x) #x 13 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 14 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 15 | 16 | // Call syscall from C code because the gccgo support for calling from 17 | // Go to C does not support varargs functions. 18 | 19 | struct ret { 20 | uintptr_t r; 21 | uintptr_t err; 22 | }; 23 | 24 | struct ret 25 | gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 26 | { 27 | struct ret r; 28 | 29 | errno = 0; 30 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 31 | r.err = errno; 32 | return r; 33 | } 34 | 35 | uintptr_t 36 | gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 37 | { 38 | return syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 39 | } 40 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/unveil_openbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | // Unveil implements the unveil syscall. 13 | // For more information see unveil(2). 14 | // Note that the special case of blocking further 15 | // unveil calls is handled by UnveilBlock. 16 | func Unveil(path string, flags string) error { 17 | pathPtr, err := syscall.BytePtrFromString(path) 18 | if err != nil { 19 | return err 20 | } 21 | flagsPtr, err := syscall.BytePtrFromString(flags) 22 | if err != nil { 23 | return err 24 | } 25 | _, _, e := syscall.Syscall(SYS_UNVEIL, uintptr(unsafe.Pointer(pathPtr)), uintptr(unsafe.Pointer(flagsPtr)), 0) 26 | if e != 0 { 27 | return e 28 | } 29 | return nil 30 | } 31 | 32 | // UnveilBlock blocks future unveil calls. 33 | // For more information see unveil(2). 34 | func UnveilBlock() error { 35 | // Both pointers must be nil. 36 | var pathUnsafe, flagsUnsafe unsafe.Pointer 37 | _, _, e := syscall.Syscall(SYS_UNVEIL, uintptr(pathUnsafe), uintptr(flagsUnsafe), 0) 38 | if e != 0 { 39 | return e 40 | } 41 | return nil 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/golang-lru/simplelru/lru_interface.go: -------------------------------------------------------------------------------- 1 | package simplelru 2 | 3 | // LRUCache is the interface for simple LRU cache. 4 | type LRUCache interface { 5 | // Adds a value to the cache, returns true if an eviction occurred and 6 | // updates the "recently used"-ness of the key. 7 | Add(key, value interface{}) bool 8 | 9 | // Returns key's value from the cache and 10 | // updates the "recently used"-ness of the key. #value, isFound 11 | Get(key interface{}) (value interface{}, ok bool) 12 | 13 | // Check if a key exsists in cache without updating the recent-ness. 14 | Contains(key interface{}) (ok bool) 15 | 16 | // Returns key's value without updating the "recently used"-ness of the key. 17 | Peek(key interface{}) (value interface{}, ok bool) 18 | 19 | // Removes a key from the cache. 20 | Remove(key interface{}) bool 21 | 22 | // Removes the oldest entry from cache. 23 | RemoveOldest() (interface{}, interface{}, bool) 24 | 25 | // Returns the oldest entry from the cache. #key, value, isFound 26 | GetOldest() (interface{}, interface{}, bool) 27 | 28 | // Returns a slice of the keys in the cache, from oldest to newest. 29 | Keys() []interface{} 30 | 31 | // Returns the number of items in the cache. 32 | Len() int 33 | 34 | // Clear all cache entries 35 | Purge() 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-hclog/context.go: -------------------------------------------------------------------------------- 1 | package hclog 2 | 3 | import ( 4 | "context" 5 | ) 6 | 7 | // WithContext inserts a logger into the context and is retrievable 8 | // with FromContext. The optional args can be set with the same syntax as 9 | // Logger.With to set fields on the inserted logger. This will not modify 10 | // the logger argument in-place. 11 | func WithContext(ctx context.Context, logger Logger, args ...interface{}) context.Context { 12 | // While we could call logger.With even with zero args, we have this 13 | // check to avoid unnecessary allocations around creating a copy of a 14 | // logger. 15 | if len(args) > 0 { 16 | logger = logger.With(args...) 17 | } 18 | 19 | return context.WithValue(ctx, contextKey, logger) 20 | } 21 | 22 | // FromContext returns a logger from the context. This will return L() 23 | // (the default logger) if no logger is found in the context. Therefore, 24 | // this will never return a nil value. 25 | func FromContext(ctx context.Context) Logger { 26 | logger, _ := ctx.Value(contextKey).(Logger) 27 | if logger == nil { 28 | return L() 29 | } 30 | 31 | return logger 32 | } 33 | 34 | // Unexported new type so that our context key never collides with another. 35 | type contextKeyType struct{} 36 | 37 | // contextKey is the key used for the context to store the logger. 38 | var contextKey = contextKeyType{} 39 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build arm64 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | B syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | B syscall·Syscall6(SB) 19 | 20 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 21 | BL runtime·entersyscall(SB) 22 | MOVD a1+8(FP), R0 23 | MOVD a2+16(FP), R1 24 | MOVD a3+24(FP), R2 25 | MOVD $0, R3 26 | MOVD $0, R4 27 | MOVD $0, R5 28 | MOVD trap+0(FP), R8 // syscall entry 29 | SVC 30 | MOVD R0, r1+32(FP) // r1 31 | MOVD R1, r2+40(FP) // r2 32 | BL runtime·exitsyscall(SB) 33 | RET 34 | 35 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 36 | B syscall·RawSyscall(SB) 37 | 38 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 39 | B syscall·RawSyscall6(SB) 40 | 41 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 42 | MOVD a1+8(FP), R0 43 | MOVD a2+16(FP), R1 44 | MOVD a3+24(FP), R2 45 | MOVD $0, R3 46 | MOVD $0, R4 47 | MOVD $0, R5 48 | MOVD trap+0(FP), R8 // syscall entry 49 | SVC 50 | MOVD R0, r1+32(FP) 51 | MOVD R1, r2+40(FP) 52 | RET 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for arm, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 23 | BL runtime·entersyscall(SB) 24 | MOVW trap+0(FP), R7 25 | MOVW a1+4(FP), R0 26 | MOVW a2+8(FP), R1 27 | MOVW a3+12(FP), R2 28 | MOVW $0, R3 29 | MOVW $0, R4 30 | MOVW $0, R5 31 | SWI $0 32 | MOVW R0, r1+16(FP) 33 | MOVW $0, R0 34 | MOVW R0, r2+20(FP) 35 | BL runtime·exitsyscall(SB) 36 | RET 37 | 38 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 39 | B syscall·RawSyscall(SB) 40 | 41 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 42 | B syscall·RawSyscall6(SB) 43 | 44 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 45 | MOVW trap+0(FP), R7 // syscall entry 46 | MOVW a1+4(FP), R0 47 | MOVW a2+8(FP), R1 48 | MOVW a3+12(FP), R2 49 | SWI $0 50 | MOVW R0, r1+16(FP) 51 | MOVW $0, R0 52 | MOVW R0, r2+20(FP) 53 | RET 54 | 55 | TEXT ·seek(SB),NOSPLIT,$0-28 56 | B syscall·seek(SB) 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_s390x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build s390x 6 | // +build linux 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for s390x, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 25 | BL runtime·entersyscall(SB) 26 | MOVD a1+8(FP), R2 27 | MOVD a2+16(FP), R3 28 | MOVD a3+24(FP), R4 29 | MOVD $0, R5 30 | MOVD $0, R6 31 | MOVD $0, R7 32 | MOVD trap+0(FP), R1 // syscall entry 33 | SYSCALL 34 | MOVD R2, r1+32(FP) 35 | MOVD R3, r2+40(FP) 36 | BL runtime·exitsyscall(SB) 37 | RET 38 | 39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 40 | BR syscall·RawSyscall(SB) 41 | 42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 43 | BR syscall·RawSyscall6(SB) 44 | 45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 46 | MOVD a1+8(FP), R2 47 | MOVD a2+16(FP), R3 48 | MOVD a3+24(FP), R4 49 | MOVD $0, R5 50 | MOVD $0, R6 51 | MOVD $0, R7 52 | MOVD trap+0(FP), R1 // syscall entry 53 | SYSCALL 54 | MOVD R2, r1+32(FP) 55 | MOVD R3, r2+40(FP) 56 | RET 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptracearm_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(arm, arm64). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build arm arm64 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegsArm is the registers used by arm binaries. 11 | type PtraceRegsArm struct { 12 | Uregs [18]uint32 13 | } 14 | 15 | // PtraceGetRegsArm fetches the registers used by arm binaries. 16 | func PtraceGetRegsArm(pid int, regsout *PtraceRegsArm) error { 17 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 18 | } 19 | 20 | // PtraceSetRegsArm sets the registers used by arm binaries. 21 | func PtraceSetRegsArm(pid int, regs *PtraceRegsArm) error { 22 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 23 | } 24 | 25 | // PtraceRegsArm64 is the registers used by arm64 binaries. 26 | type PtraceRegsArm64 struct { 27 | Regs [31]uint64 28 | Sp uint64 29 | Pc uint64 30 | Pstate uint64 31 | } 32 | 33 | // PtraceGetRegsArm64 fetches the registers used by arm64 binaries. 34 | func PtraceGetRegsArm64(pid int, regsout *PtraceRegsArm64) error { 35 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 36 | } 37 | 38 | // PtraceSetRegsArm64 sets the registers used by arm64 binaries. 39 | func PtraceSetRegsArm64(pid int, regs *PtraceRegsArm64) error { 40 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 41 | } 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mipsx.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips mipsle 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-28 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 25 | JMP syscall·Syscall9(SB) 26 | 27 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 28 | JAL runtime·entersyscall(SB) 29 | MOVW a1+4(FP), R4 30 | MOVW a2+8(FP), R5 31 | MOVW a3+12(FP), R6 32 | MOVW R0, R7 33 | MOVW trap+0(FP), R2 // syscall entry 34 | SYSCALL 35 | MOVW R2, r1+16(FP) // r1 36 | MOVW R3, r2+20(FP) // r2 37 | JAL runtime·exitsyscall(SB) 38 | RET 39 | 40 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 41 | JMP syscall·RawSyscall(SB) 42 | 43 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 44 | JMP syscall·RawSyscall6(SB) 45 | 46 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 47 | MOVW a1+4(FP), R4 48 | MOVW a2+8(FP), R5 49 | MOVW a3+12(FP), R6 50 | MOVW trap+0(FP), R2 // syscall entry 51 | SYSCALL 52 | MOVW R2, r1+16(FP) 53 | MOVW R3, r2+20(FP) 54 | RET 55 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mips64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips64 mips64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 25 | JAL runtime·entersyscall(SB) 26 | MOVV a1+8(FP), R4 27 | MOVV a2+16(FP), R5 28 | MOVV a3+24(FP), R6 29 | MOVV R0, R7 30 | MOVV R0, R8 31 | MOVV R0, R9 32 | MOVV trap+0(FP), R2 // syscall entry 33 | SYSCALL 34 | MOVV R2, r1+32(FP) 35 | MOVV R3, r2+40(FP) 36 | JAL runtime·exitsyscall(SB) 37 | RET 38 | 39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 40 | JMP syscall·RawSyscall(SB) 41 | 42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 43 | JMP syscall·RawSyscall6(SB) 44 | 45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 46 | MOVV a1+8(FP), R4 47 | MOVV a2+16(FP), R5 48 | MOVV a3+24(FP), R6 49 | MOVV R0, R7 50 | MOVV R0, R8 51 | MOVV R0, R9 52 | MOVV trap+0(FP), R2 // syscall entry 53 | SYSCALL 54 | MOVV R2, r1+32(FP) 55 | MOVV R3, r2+40(FP) 56 | RET 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin,go1.12 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // Implemented in the runtime package (runtime/sys_darwin.go) 12 | func syscall_syscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 13 | func syscall_syscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 14 | func syscall_syscall6X(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 15 | func syscall_syscall9(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno) // 32-bit only 16 | func syscall_rawSyscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 17 | func syscall_rawSyscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 18 | 19 | //go:linkname syscall_syscall syscall.syscall 20 | //go:linkname syscall_syscall6 syscall.syscall6 21 | //go:linkname syscall_syscall6X syscall.syscall6X 22 | //go:linkname syscall_syscall9 syscall.syscall9 23 | //go:linkname syscall_rawSyscall syscall.rawSyscall 24 | //go:linkname syscall_rawSyscall6 syscall.rawSyscall6 25 | 26 | // Find the entry point for f. See comments in runtime/proc.go for the 27 | // function of the same name. 28 | //go:nosplit 29 | func funcPC(f func()) uintptr { 30 | return **(**uintptr)(unsafe.Pointer(&f)) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: usec} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint64(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint64(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: usec} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint64(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint64(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm64,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: usec} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint64(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint64(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for AMD64, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 23 | CALL runtime·entersyscall(SB) 24 | MOVQ a1+8(FP), DI 25 | MOVQ a2+16(FP), SI 26 | MOVQ a3+24(FP), DX 27 | MOVQ $0, R10 28 | MOVQ $0, R8 29 | MOVQ $0, R9 30 | MOVQ trap+0(FP), AX // syscall entry 31 | SYSCALL 32 | MOVQ AX, r1+32(FP) 33 | MOVQ DX, r2+40(FP) 34 | CALL runtime·exitsyscall(SB) 35 | RET 36 | 37 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 38 | JMP syscall·RawSyscall(SB) 39 | 40 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 41 | JMP syscall·RawSyscall6(SB) 42 | 43 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 44 | MOVQ a1+8(FP), DI 45 | MOVQ a2+16(FP), SI 46 | MOVQ a3+24(FP), DX 47 | MOVQ $0, R10 48 | MOVQ $0, R8 49 | MOVQ $0, R9 50 | MOVQ trap+0(FP), AX // syscall entry 51 | SYSCALL 52 | MOVQ AX, r1+32(FP) 53 | MOVQ DX, r2+40(FP) 54 | RET 55 | 56 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 57 | JMP syscall·gettimeofday(SB) 58 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: int32(usec)} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint32(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint32(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_aix_ppc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix 6 | // +build ppc 7 | 8 | package unix 9 | 10 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = getrlimit64 11 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) = setrlimit64 12 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek64 13 | 14 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 15 | 16 | func setTimespec(sec, nsec int64) Timespec { 17 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 18 | } 19 | 20 | func setTimeval(sec, usec int64) Timeval { 21 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint32(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (cmsg *Cmsghdr) SetLen(length int) { 33 | cmsg.Len = uint32(length) 34 | } 35 | 36 | func Fstat(fd int, stat *Stat_t) error { 37 | return fstat(fd, stat) 38 | } 39 | 40 | func Fstatat(dirfd int, path string, stat *Stat_t, flags int) error { 41 | return fstatat(dirfd, path, stat, flags) 42 | } 43 | 44 | func Lstat(path string, stat *Stat_t) error { 45 | return lstat(path, stat) 46 | } 47 | 48 | func Stat(path string, statptr *Stat_t) error { 49 | return stat(path, statptr) 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-immutable-radix/README.md: -------------------------------------------------------------------------------- 1 | go-immutable-radix [![Build Status](https://travis-ci.org/hashicorp/go-immutable-radix.png)](https://travis-ci.org/hashicorp/go-immutable-radix) 2 | ========= 3 | 4 | Provides the `iradix` package that implements an immutable [radix tree](http://en.wikipedia.org/wiki/Radix_tree). 5 | The package only provides a single `Tree` implementation, optimized for sparse nodes. 6 | 7 | As a radix tree, it provides the following: 8 | * O(k) operations. In many cases, this can be faster than a hash table since 9 | the hash function is an O(k) operation, and hash tables have very poor cache locality. 10 | * Minimum / Maximum value lookups 11 | * Ordered iteration 12 | 13 | A tree supports using a transaction to batch multiple updates (insert, delete) 14 | in a more efficient manner than performing each operation one at a time. 15 | 16 | For a mutable variant, see [go-radix](https://github.com/armon/go-radix). 17 | 18 | Documentation 19 | ============= 20 | 21 | The full documentation is available on [Godoc](http://godoc.org/github.com/hashicorp/go-immutable-radix). 22 | 23 | Example 24 | ======= 25 | 26 | Below is a simple example of usage 27 | 28 | ```go 29 | // Create a tree 30 | r := iradix.New() 31 | r, _, _ = r.Insert([]byte("foo"), 1) 32 | r, _, _ = r.Insert([]byte("bar"), 2) 33 | r, _, _ = r.Insert([]byte("foobar"), 2) 34 | 35 | // Find the longest prefix match 36 | m, _, _ := r.Root().LongestPrefix([]byte("foozip")) 37 | if string(m) != "foo" { 38 | panic("should be foo") 39 | } 40 | ``` 41 | 42 | -------------------------------------------------------------------------------- /fsm/fsm.go: -------------------------------------------------------------------------------- 1 | package fsm 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "io" 7 | "strings" 8 | "sync" 9 | 10 | "github.com/hashicorp/raft" 11 | ) 12 | 13 | type Fsm struct { 14 | DataBase database 15 | } 16 | 17 | func NewFsm() *Fsm { 18 | fsm := &Fsm{ 19 | DataBase: NewDatabase(), 20 | } 21 | return fsm 22 | } 23 | 24 | func (f *Fsm) Apply(l *raft.Log) interface{} { 25 | fmt.Println("apply data:", string(l.Data)) 26 | data := strings.Split(string(l.Data), ",") 27 | op := data[0] 28 | if op == "set" { 29 | key := data[1] 30 | value := data[2] 31 | f.DataBase.Set(key, value) 32 | } 33 | 34 | return nil 35 | } 36 | 37 | func (f *Fsm) Snapshot() (raft.FSMSnapshot, error) { 38 | return &f.DataBase, nil 39 | } 40 | 41 | func (f *Fsm) Restore(io.ReadCloser) error { 42 | return nil 43 | } 44 | 45 | type database struct { 46 | Data map[string]string 47 | mu sync.Mutex 48 | } 49 | 50 | func NewDatabase() database { 51 | return database{ 52 | Data: make(map[string]string), 53 | } 54 | } 55 | 56 | func (d *database) Get(key string) string { 57 | d.mu.Lock() 58 | value := d.Data[key] 59 | d.mu.Unlock() 60 | return value 61 | } 62 | 63 | func (d *database) Set(key, value string) { 64 | d.mu.Lock() 65 | d.Data[key] = value 66 | d.mu.Unlock() 67 | } 68 | 69 | func (d *database) Persist(sink raft.SnapshotSink) error { 70 | d.mu.Lock() 71 | data, err := json.Marshal(d.Data) 72 | d.mu.Unlock() 73 | if err != nil { 74 | return err 75 | } 76 | sink.Write(data) 77 | sink.Close() 78 | return nil 79 | } 80 | 81 | func (d *database) Release() {} 82 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-hclog/nulllogger.go: -------------------------------------------------------------------------------- 1 | package hclog 2 | 3 | import ( 4 | "io" 5 | "io/ioutil" 6 | "log" 7 | ) 8 | 9 | // NewNullLogger instantiates a Logger for which all calls 10 | // will succeed without doing anything. 11 | // Useful for testing purposes. 12 | func NewNullLogger() Logger { 13 | return &nullLogger{} 14 | } 15 | 16 | type nullLogger struct{} 17 | 18 | func (l *nullLogger) Trace(msg string, args ...interface{}) {} 19 | 20 | func (l *nullLogger) Debug(msg string, args ...interface{}) {} 21 | 22 | func (l *nullLogger) Info(msg string, args ...interface{}) {} 23 | 24 | func (l *nullLogger) Warn(msg string, args ...interface{}) {} 25 | 26 | func (l *nullLogger) Error(msg string, args ...interface{}) {} 27 | 28 | func (l *nullLogger) IsTrace() bool { return false } 29 | 30 | func (l *nullLogger) IsDebug() bool { return false } 31 | 32 | func (l *nullLogger) IsInfo() bool { return false } 33 | 34 | func (l *nullLogger) IsWarn() bool { return false } 35 | 36 | func (l *nullLogger) IsError() bool { return false } 37 | 38 | func (l *nullLogger) With(args ...interface{}) Logger { return l } 39 | 40 | func (l *nullLogger) Named(name string) Logger { return l } 41 | 42 | func (l *nullLogger) ResetNamed(name string) Logger { return l } 43 | 44 | func (l *nullLogger) SetLevel(level Level) {} 45 | 46 | func (l *nullLogger) StandardLogger(opts *StandardLoggerOptions) *log.Logger { 47 | return log.New(l.StandardWriter(opts), "", log.LstdFlags) 48 | } 49 | 50 | func (l *nullLogger) StandardWriter(opts *StandardLoggerOptions) io.Writer { 51 | return ioutil.Discard 52 | } 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-msgpack/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012, 2013 Ugorji Nwoke. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | * Neither the name of the author nor the names of its contributors may be used 13 | to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptracemips_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(mips, mips64). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build mips mips64 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegsMips is the registers used by mips binaries. 11 | type PtraceRegsMips struct { 12 | Regs [32]uint64 13 | Lo uint64 14 | Hi uint64 15 | Epc uint64 16 | Badvaddr uint64 17 | Status uint64 18 | Cause uint64 19 | } 20 | 21 | // PtraceGetRegsMips fetches the registers used by mips binaries. 22 | func PtraceGetRegsMips(pid int, regsout *PtraceRegsMips) error { 23 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 24 | } 25 | 26 | // PtraceSetRegsMips sets the registers used by mips binaries. 27 | func PtraceSetRegsMips(pid int, regs *PtraceRegsMips) error { 28 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 29 | } 30 | 31 | // PtraceRegsMips64 is the registers used by mips64 binaries. 32 | type PtraceRegsMips64 struct { 33 | Regs [32]uint64 34 | Lo uint64 35 | Hi uint64 36 | Epc uint64 37 | Badvaddr uint64 38 | Status uint64 39 | Cause uint64 40 | } 41 | 42 | // PtraceGetRegsMips64 fetches the registers used by mips64 binaries. 43 | func PtraceGetRegsMips64(pid int, regsout *PtraceRegsMips64) error { 44 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 45 | } 46 | 47 | // PtraceSetRegsMips64 sets the registers used by mips64 binaries. 48 | func PtraceSetRegsMips64(pid int, regs *PtraceRegsMips64) error { 49 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 50 | } 51 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptracemipsle_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(mipsle, mips64le). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build mipsle mips64le 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegsMipsle is the registers used by mipsle binaries. 11 | type PtraceRegsMipsle struct { 12 | Regs [32]uint64 13 | Lo uint64 14 | Hi uint64 15 | Epc uint64 16 | Badvaddr uint64 17 | Status uint64 18 | Cause uint64 19 | } 20 | 21 | // PtraceGetRegsMipsle fetches the registers used by mipsle binaries. 22 | func PtraceGetRegsMipsle(pid int, regsout *PtraceRegsMipsle) error { 23 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 24 | } 25 | 26 | // PtraceSetRegsMipsle sets the registers used by mipsle binaries. 27 | func PtraceSetRegsMipsle(pid int, regs *PtraceRegsMipsle) error { 28 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 29 | } 30 | 31 | // PtraceRegsMips64le is the registers used by mips64le binaries. 32 | type PtraceRegsMips64le struct { 33 | Regs [32]uint64 34 | Lo uint64 35 | Hi uint64 36 | Epc uint64 37 | Badvaddr uint64 38 | Status uint64 39 | Cause uint64 40 | } 41 | 42 | // PtraceGetRegsMips64le fetches the registers used by mips64le binaries. 43 | func PtraceGetRegsMips64le(pid int, regsout *PtraceRegsMips64le) error { 44 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 45 | } 46 | 47 | // PtraceSetRegsMips64le sets the registers used by mips64le binaries. 48 | func PtraceSetRegsMips64le(pid int, regs *PtraceRegsMips64le) error { 49 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 50 | } 51 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for 386, Linux 11 | // 12 | 13 | // See ../runtime/sys_linux_386.s for the reason why we always use int 0x80 14 | // instead of the glibc-specific "CALL 0x10(GS)". 15 | #define INVOKE_SYSCALL INT $0x80 16 | 17 | // Just jump to package syscall's implementation for all these functions. 18 | // The runtime may know about them. 19 | 20 | TEXT ·Syscall(SB),NOSPLIT,$0-28 21 | JMP syscall·Syscall(SB) 22 | 23 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 24 | JMP syscall·Syscall6(SB) 25 | 26 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 27 | CALL runtime·entersyscall(SB) 28 | MOVL trap+0(FP), AX // syscall entry 29 | MOVL a1+4(FP), BX 30 | MOVL a2+8(FP), CX 31 | MOVL a3+12(FP), DX 32 | MOVL $0, SI 33 | MOVL $0, DI 34 | INVOKE_SYSCALL 35 | MOVL AX, r1+16(FP) 36 | MOVL DX, r2+20(FP) 37 | CALL runtime·exitsyscall(SB) 38 | RET 39 | 40 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 41 | JMP syscall·RawSyscall(SB) 42 | 43 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 44 | JMP syscall·RawSyscall6(SB) 45 | 46 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 47 | MOVL trap+0(FP), AX // syscall entry 48 | MOVL a1+4(FP), BX 49 | MOVL a2+8(FP), CX 50 | MOVL a3+12(FP), DX 51 | MOVL $0, SI 52 | MOVL $0, DI 53 | INVOKE_SYSCALL 54 | MOVL AX, r1+16(FP) 55 | MOVL DX, r2+20(FP) 56 | RET 57 | 58 | TEXT ·socketcall(SB),NOSPLIT,$0-36 59 | JMP syscall·socketcall(SB) 60 | 61 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 62 | JMP syscall·rawsocketcall(SB) 63 | 64 | TEXT ·seek(SB),NOSPLIT,$0-28 65 | JMP syscall·seek(SB) 66 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used by the Linux kernel and glibc. 7 | // 8 | // The information below is extracted and adapted from bits/sysmacros.h in the 9 | // glibc sources: 10 | // 11 | // dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's 12 | // default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major 13 | // number and m is a hex digit of the minor number. This is backward compatible 14 | // with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also 15 | // backward compatible with the Linux kernel, which for some architectures uses 16 | // 32-bit dev_t, encoded as mmmM MMmm. 17 | 18 | package unix 19 | 20 | // Major returns the major component of a Linux device number. 21 | func Major(dev uint64) uint32 { 22 | major := uint32((dev & 0x00000000000fff00) >> 8) 23 | major |= uint32((dev & 0xfffff00000000000) >> 32) 24 | return major 25 | } 26 | 27 | // Minor returns the minor component of a Linux device number. 28 | func Minor(dev uint64) uint32 { 29 | minor := uint32((dev & 0x00000000000000ff) >> 0) 30 | minor |= uint32((dev & 0x00000ffffff00000) >> 12) 31 | return minor 32 | } 33 | 34 | // Mkdev returns a Linux device number generated from the given major and minor 35 | // components. 36 | func Mkdev(major, minor uint32) uint64 { 37 | dev := (uint64(major) & 0x00000fff) << 8 38 | dev |= (uint64(major) & 0xfffff000) << 32 39 | dev |= (uint64(minor) & 0x000000ff) << 0 40 | dev |= (uint64(minor) & 0xffffff00) << 12 41 | return dev 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package bolt implements a low-level key/value store in pure Go. It supports 3 | fully serializable transactions, ACID semantics, and lock-free MVCC with 4 | multiple readers and a single writer. Bolt can be used for projects that 5 | want a simple data store without the need to add large dependencies such as 6 | Postgres or MySQL. 7 | 8 | Bolt is a single-level, zero-copy, B+tree data store. This means that Bolt is 9 | optimized for fast read access and does not require recovery in the event of a 10 | system crash. Transactions which have not finished committing will simply be 11 | rolled back in the event of a crash. 12 | 13 | The design of Bolt is based on Howard Chu's LMDB database project. 14 | 15 | Bolt currently works on Windows, Mac OS X, and Linux. 16 | 17 | 18 | Basics 19 | 20 | There are only a few types in Bolt: DB, Bucket, Tx, and Cursor. The DB is 21 | a collection of buckets and is represented by a single file on disk. A bucket is 22 | a collection of unique keys that are associated with values. 23 | 24 | Transactions provide either read-only or read-write access to the database. 25 | Read-only transactions can retrieve key/value pairs and can use Cursors to 26 | iterate over the dataset sequentially. Read-write transactions can create and 27 | delete buckets and can insert and remove keys. Only one read-write transaction 28 | is allowed at a time. 29 | 30 | 31 | Caveats 32 | 33 | The database uses a read-only, memory-mapped data file to ensure that 34 | applications cannot corrupt the database, however, this means that keys and 35 | values returned from Bolt cannot be changed. Writing to a read-only byte slice 36 | will cause Go to panic. 37 | 38 | Keys and values retrieved from the database are only valid for the life of 39 | the transaction. When used outside the transaction, these byte slices can 40 | point to different data or can point to invalid memory which will cause a panic. 41 | 42 | 43 | */ 44 | package bolt 45 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-hclog/writer.go: -------------------------------------------------------------------------------- 1 | package hclog 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | ) 7 | 8 | type writer struct { 9 | b bytes.Buffer 10 | w io.Writer 11 | } 12 | 13 | func newWriter(w io.Writer) *writer { 14 | return &writer{w: w} 15 | } 16 | 17 | func (w *writer) Flush(level Level) (err error) { 18 | if lw, ok := w.w.(LevelWriter); ok { 19 | _, err = lw.LevelWrite(level, w.b.Bytes()) 20 | } else { 21 | _, err = w.w.Write(w.b.Bytes()) 22 | } 23 | w.b.Reset() 24 | return err 25 | } 26 | 27 | func (w *writer) Write(p []byte) (int, error) { 28 | return w.b.Write(p) 29 | } 30 | 31 | func (w *writer) WriteByte(c byte) error { 32 | return w.b.WriteByte(c) 33 | } 34 | 35 | func (w *writer) WriteString(s string) (int, error) { 36 | return w.b.WriteString(s) 37 | } 38 | 39 | // LevelWriter is the interface that wraps the LevelWrite method. 40 | type LevelWriter interface { 41 | LevelWrite(level Level, p []byte) (n int, err error) 42 | } 43 | 44 | // LeveledWriter writes all log messages to the standard writer, 45 | // except for log levels that are defined in the overrides map. 46 | type LeveledWriter struct { 47 | standard io.Writer 48 | overrides map[Level]io.Writer 49 | } 50 | 51 | // NewLeveledWriter returns an initialized LeveledWriter. 52 | // 53 | // standard will be used as the default writer for all log levels, 54 | // except for log levels that are defined in the overrides map. 55 | func NewLeveledWriter(standard io.Writer, overrides map[Level]io.Writer) *LeveledWriter { 56 | return &LeveledWriter{ 57 | standard: standard, 58 | overrides: overrides, 59 | } 60 | } 61 | 62 | // Write implements io.Writer. 63 | func (lw *LeveledWriter) Write(p []byte) (int, error) { 64 | return lw.standard.Write(p) 65 | } 66 | 67 | // LevelWrite implements LevelWriter. 68 | func (lw *LeveledWriter) LevelWrite(level Level, p []byte) (int, error) { 69 | w, ok := lw.overrides[level] 70 | if !ok { 71 | w = lw.standard 72 | } 73 | return w.Write(p) 74 | } 75 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mkasm_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | // mkasm_darwin.go generates assembly trampolines to call libSystem routines from Go. 8 | //This program must be run after mksyscall.go. 9 | package main 10 | 11 | import ( 12 | "bytes" 13 | "fmt" 14 | "io/ioutil" 15 | "log" 16 | "os" 17 | "strings" 18 | ) 19 | 20 | func main() { 21 | in1, err := ioutil.ReadFile("syscall_darwin.go") 22 | if err != nil { 23 | log.Fatalf("can't open syscall_darwin.go: %s", err) 24 | } 25 | arch := os.Args[1] 26 | in2, err := ioutil.ReadFile(fmt.Sprintf("syscall_darwin_%s.go", arch)) 27 | if err != nil { 28 | log.Fatalf("can't open syscall_darwin_%s.go: %s", arch, err) 29 | } 30 | in3, err := ioutil.ReadFile(fmt.Sprintf("zsyscall_darwin_%s.go", arch)) 31 | if err != nil { 32 | log.Fatalf("can't open zsyscall_darwin_%s.go: %s", arch, err) 33 | } 34 | in := string(in1) + string(in2) + string(in3) 35 | 36 | trampolines := map[string]bool{} 37 | 38 | var out bytes.Buffer 39 | 40 | fmt.Fprintf(&out, "// go run mkasm_darwin.go %s\n", strings.Join(os.Args[1:], " ")) 41 | fmt.Fprintf(&out, "// Code generated by the command above; DO NOT EDIT.\n") 42 | fmt.Fprintf(&out, "\n") 43 | fmt.Fprintf(&out, "// +build go1.12\n") 44 | fmt.Fprintf(&out, "\n") 45 | fmt.Fprintf(&out, "#include \"textflag.h\"\n") 46 | for _, line := range strings.Split(in, "\n") { 47 | if !strings.HasPrefix(line, "func ") || !strings.HasSuffix(line, "_trampoline()") { 48 | continue 49 | } 50 | fn := line[5 : len(line)-13] 51 | if !trampolines[fn] { 52 | trampolines[fn] = true 53 | fmt.Fprintf(&out, "TEXT ·%s_trampoline(SB),NOSPLIT,$0-0\n", fn) 54 | fmt.Fprintf(&out, "\tJMP\t%s(SB)\n", fn) 55 | } 56 | } 57 | err = ioutil.WriteFile(fmt.Sprintf("zsyscall_darwin_%s.s", arch), out.Bytes(), 0644) 58 | if err != nil { 59 | log.Fatalf("can't write zsyscall_darwin_%s.s: %s", arch, err) 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/raft/.golangci-lint.yml: -------------------------------------------------------------------------------- 1 | run: 2 | deadline: 5m 3 | 4 | linters-settings: 5 | govet: 6 | check-shadowing: true 7 | golint: 8 | min-confidence: 0 9 | 10 | linters: 11 | disable-all: true 12 | enable: 13 | - gofmt 14 | #- golint 15 | - govet 16 | #- varcheck 17 | #- typecheck 18 | #- gosimple 19 | 20 | issues: 21 | exclude-use-default: false 22 | exclude: 23 | # ignore the false positive erros resulting from not including a comment above every `package` keyword 24 | - should have a package comment, unless it's in another file for this package (golint) 25 | # golint: Annoying issue about not having a comment. The rare codebase has such comments 26 | # - (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form) 27 | # errcheck: Almost all programs ignore errors on these functions and in most cases it's ok 28 | - Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked 29 | 30 | # golint: False positive when tests are defined in package 'test' 31 | - func name will be used as test\.Test.* by other packages, and that stutters; consider calling this 32 | 33 | # staticcheck: Developers tend to write in C-style with an 34 | # explicit 'break' in a 'switch', so it's ok to ignore 35 | - ineffective break statement. Did you mean to break out of the outer loop 36 | # gosec: Too many false-positives on 'unsafe' usage 37 | - Use of unsafe calls should be audited 38 | 39 | # gosec: Too many false-positives for parametrized shell calls 40 | - Subprocess launch(ed with variable|ing should be audited) 41 | 42 | # gosec: Duplicated errcheck checks 43 | - G104 44 | 45 | # gosec: Too many issues in popular repos 46 | - (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less) 47 | 48 | # gosec: False positive is triggered by 'src, err := ioutil.ReadFile(filename)' 49 | - Potential file inclusion via variable 50 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/raft/log_cache.go: -------------------------------------------------------------------------------- 1 | package raft 2 | 3 | import ( 4 | "fmt" 5 | "sync" 6 | ) 7 | 8 | // LogCache wraps any LogStore implementation to provide an 9 | // in-memory ring buffer. This is used to cache access to 10 | // the recently written entries. For implementations that do not 11 | // cache themselves, this can provide a substantial boost by 12 | // avoiding disk I/O on recent entries. 13 | type LogCache struct { 14 | store LogStore 15 | 16 | cache []*Log 17 | l sync.RWMutex 18 | } 19 | 20 | // NewLogCache is used to create a new LogCache with the 21 | // given capacity and backend store. 22 | func NewLogCache(capacity int, store LogStore) (*LogCache, error) { 23 | if capacity <= 0 { 24 | return nil, fmt.Errorf("capacity must be positive") 25 | } 26 | c := &LogCache{ 27 | store: store, 28 | cache: make([]*Log, capacity), 29 | } 30 | return c, nil 31 | } 32 | 33 | func (c *LogCache) GetLog(idx uint64, log *Log) error { 34 | // Check the buffer for an entry 35 | c.l.RLock() 36 | cached := c.cache[idx%uint64(len(c.cache))] 37 | c.l.RUnlock() 38 | 39 | // Check if entry is valid 40 | if cached != nil && cached.Index == idx { 41 | *log = *cached 42 | return nil 43 | } 44 | 45 | // Forward request on cache miss 46 | return c.store.GetLog(idx, log) 47 | } 48 | 49 | func (c *LogCache) StoreLog(log *Log) error { 50 | return c.StoreLogs([]*Log{log}) 51 | } 52 | 53 | func (c *LogCache) StoreLogs(logs []*Log) error { 54 | // Insert the logs into the ring buffer 55 | c.l.Lock() 56 | for _, l := range logs { 57 | c.cache[l.Index%uint64(len(c.cache))] = l 58 | } 59 | c.l.Unlock() 60 | 61 | return c.store.StoreLogs(logs) 62 | } 63 | 64 | func (c *LogCache) FirstIndex() (uint64, error) { 65 | return c.store.FirstIndex() 66 | } 67 | 68 | func (c *LogCache) LastIndex() (uint64, error) { 69 | return c.store.LastIndex() 70 | } 71 | 72 | func (c *LogCache) DeleteRange(min, max uint64) error { 73 | // Invalidate the cache on deletes 74 | c.l.Lock() 75 | c.cache = make([]*Log, len(c.cache)) 76 | c.l.Unlock() 77 | 78 | return c.store.DeleteRange(min, max) 79 | } 80 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | import ( 8 | "syscall" 9 | ) 10 | 11 | func setTimespec(sec, nsec int64) Timespec { 12 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 13 | } 14 | 15 | func setTimeval(sec, usec int64) Timeval { 16 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 17 | } 18 | 19 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 20 | func Gettimeofday(tv *Timeval) (err error) { 21 | // The tv passed to gettimeofday must be non-nil 22 | // but is otherwise unused. The answers come back 23 | // in the two registers. 24 | sec, usec, err := gettimeofday(tv) 25 | tv.Sec = int32(sec) 26 | tv.Usec = int32(usec) 27 | return err 28 | } 29 | 30 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 31 | k.Ident = uint32(fd) 32 | k.Filter = int16(mode) 33 | k.Flags = uint16(flags) 34 | } 35 | 36 | func (iov *Iovec) SetLen(length int) { 37 | iov.Len = uint32(length) 38 | } 39 | 40 | func (msghdr *Msghdr) SetControllen(length int) { 41 | msghdr.Controllen = uint32(length) 42 | } 43 | 44 | func (cmsg *Cmsghdr) SetLen(length int) { 45 | cmsg.Len = uint32(length) 46 | } 47 | 48 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 49 | 50 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 51 | // of darwin/arm the syscall is called sysctl instead of __sysctl. 52 | const SYS___SYSCTL = SYS_SYSCTL 53 | 54 | //sys Fstat(fd int, stat *Stat_t) (err error) 55 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) 56 | //sys Fstatfs(fd int, stat *Statfs_t) (err error) 57 | //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT 58 | //sys Lstat(path string, stat *Stat_t) (err error) 59 | //sys Stat(path string, stat *Stat_t) (err error) 60 | //sys Statfs(path string, stat *Statfs_t) (err error) 61 | 62 | func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { 63 | return 0, ENOSYS 64 | } 65 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | ) 12 | 13 | func setTimespec(sec, nsec int64) Timespec { 14 | return Timespec{Sec: sec, Nsec: nsec} 15 | } 16 | 17 | func setTimeval(sec, usec int64) Timeval { 18 | return Timeval{Sec: sec, Usec: int32(usec)} 19 | } 20 | 21 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 22 | func Gettimeofday(tv *Timeval) (err error) { 23 | // The tv passed to gettimeofday must be non-nil 24 | // but is otherwise unused. The answers come back 25 | // in the two registers. 26 | sec, usec, err := gettimeofday(tv) 27 | tv.Sec = sec 28 | tv.Usec = usec 29 | return err 30 | } 31 | 32 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 33 | k.Ident = uint64(fd) 34 | k.Filter = int16(mode) 35 | k.Flags = uint16(flags) 36 | } 37 | 38 | func (iov *Iovec) SetLen(length int) { 39 | iov.Len = uint64(length) 40 | } 41 | 42 | func (msghdr *Msghdr) SetControllen(length int) { 43 | msghdr.Controllen = uint32(length) 44 | } 45 | 46 | func (cmsg *Cmsghdr) SetLen(length int) { 47 | cmsg.Len = uint32(length) 48 | } 49 | 50 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 51 | 52 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 53 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl. 54 | const SYS___SYSCTL = SYS_SYSCTL 55 | 56 | //sys Fstat(fd int, stat *Stat_t) (err error) 57 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) 58 | //sys Fstatfs(fd int, stat *Statfs_t) (err error) 59 | //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT 60 | //sys Lstat(path string, stat *Stat_t) (err error) 61 | //sys Stat(path string, stat *Stat_t) (err error) 62 | //sys Statfs(path string, stat *Statfs_t) (err error) 63 | 64 | func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { 65 | return 0, ENOSYS 66 | } 67 | -------------------------------------------------------------------------------- /myraft/my_raft.go: -------------------------------------------------------------------------------- 1 | package myraft 2 | 3 | import ( 4 | "net" 5 | "os" 6 | "path/filepath" 7 | "strings" 8 | "time" 9 | 10 | fsm "github.com/vision9527/raft-demo/fsm" 11 | 12 | "github.com/hashicorp/raft" 13 | raftboltdb "github.com/hashicorp/raft-boltdb" 14 | ) 15 | 16 | func NewMyRaft(raftAddr, raftId, raftDir string) (*raft.Raft, *fsm.Fsm, error) { 17 | config := raft.DefaultConfig() 18 | config.LocalID = raft.ServerID(raftId) 19 | // config.HeartbeatTimeout = 1000 * time.Millisecond 20 | // config.ElectionTimeout = 1000 * time.Millisecond 21 | // config.CommitTimeout = 1000 * time.Millisecond 22 | 23 | addr, err := net.ResolveTCPAddr("tcp", raftAddr) 24 | if err != nil { 25 | return nil, nil, err 26 | } 27 | transport, err := raft.NewTCPTransport(raftAddr, addr, 2, 5*time.Second, os.Stderr) 28 | if err != nil { 29 | return nil, nil, err 30 | } 31 | snapshots, err := raft.NewFileSnapshotStore(raftDir, 2, os.Stderr) 32 | if err != nil { 33 | return nil, nil, err 34 | } 35 | logStore, err := raftboltdb.NewBoltStore(filepath.Join(raftDir, "raft-log.db")) 36 | if err != nil { 37 | return nil, nil, err 38 | } 39 | stableStore, err := raftboltdb.NewBoltStore(filepath.Join(raftDir, "raft-stable.db")) 40 | if err != nil { 41 | return nil, nil, err 42 | } 43 | fm := fsm.NewFsm() 44 | rf, err := raft.NewRaft(config, fm, logStore, stableStore, snapshots, transport) 45 | if err != nil { 46 | return nil, nil, err 47 | } 48 | 49 | return rf, fm, nil 50 | } 51 | 52 | func Bootstrap(rf *raft.Raft, raftId, raftAddr, raftCluster string) { 53 | servers := rf.GetConfiguration().Configuration().Servers 54 | if len(servers) > 0 { 55 | return 56 | } 57 | peerArray := strings.Split(raftCluster, ",") 58 | if len(peerArray) == 0 { 59 | return 60 | } 61 | 62 | var configuration raft.Configuration 63 | for _, peerInfo := range peerArray { 64 | peer := strings.Split(peerInfo, "/") 65 | id := peer[0] 66 | addr := peer[1] 67 | server := raft.Server{ 68 | ID: raft.ServerID(id), 69 | Address: raft.ServerAddress(addr), 70 | } 71 | configuration.Servers = append(configuration.Servers, server) 72 | } 73 | rf.BootstrapCluster(configuration) 74 | return 75 | } 76 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-immutable-radix/raw_iter.go: -------------------------------------------------------------------------------- 1 | package iradix 2 | 3 | // rawIterator visits each of the nodes in the tree, even the ones that are not 4 | // leaves. It keeps track of the effective path (what a leaf at a given node 5 | // would be called), which is useful for comparing trees. 6 | type rawIterator struct { 7 | // node is the starting node in the tree for the iterator. 8 | node *Node 9 | 10 | // stack keeps track of edges in the frontier. 11 | stack []rawStackEntry 12 | 13 | // pos is the current position of the iterator. 14 | pos *Node 15 | 16 | // path is the effective path of the current iterator position, 17 | // regardless of whether the current node is a leaf. 18 | path string 19 | } 20 | 21 | // rawStackEntry is used to keep track of the cumulative common path as well as 22 | // its associated edges in the frontier. 23 | type rawStackEntry struct { 24 | path string 25 | edges edges 26 | } 27 | 28 | // Front returns the current node that has been iterated to. 29 | func (i *rawIterator) Front() *Node { 30 | return i.pos 31 | } 32 | 33 | // Path returns the effective path of the current node, even if it's not actually 34 | // a leaf. 35 | func (i *rawIterator) Path() string { 36 | return i.path 37 | } 38 | 39 | // Next advances the iterator to the next node. 40 | func (i *rawIterator) Next() { 41 | // Initialize our stack if needed. 42 | if i.stack == nil && i.node != nil { 43 | i.stack = []rawStackEntry{ 44 | rawStackEntry{ 45 | edges: edges{ 46 | edge{node: i.node}, 47 | }, 48 | }, 49 | } 50 | } 51 | 52 | for len(i.stack) > 0 { 53 | // Inspect the last element of the stack. 54 | n := len(i.stack) 55 | last := i.stack[n-1] 56 | elem := last.edges[0].node 57 | 58 | // Update the stack. 59 | if len(last.edges) > 1 { 60 | i.stack[n-1].edges = last.edges[1:] 61 | } else { 62 | i.stack = i.stack[:n-1] 63 | } 64 | 65 | // Push the edges onto the frontier. 66 | if len(elem.edges) > 0 { 67 | path := last.path + string(elem.prefix) 68 | i.stack = append(i.stack, rawStackEntry{path, elem.edges}) 69 | } 70 | 71 | i.pos = elem 72 | i.path = last.path + string(elem.prefix) 73 | return 74 | } 75 | 76 | i.pos = nil 77 | i.path = "" 78 | } 79 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-immutable-radix/iter.go: -------------------------------------------------------------------------------- 1 | package iradix 2 | 3 | import "bytes" 4 | 5 | // Iterator is used to iterate over a set of nodes 6 | // in pre-order 7 | type Iterator struct { 8 | node *Node 9 | stack []edges 10 | } 11 | 12 | // SeekPrefixWatch is used to seek the iterator to a given prefix 13 | // and returns the watch channel of the finest granularity 14 | func (i *Iterator) SeekPrefixWatch(prefix []byte) (watch <-chan struct{}) { 15 | // Wipe the stack 16 | i.stack = nil 17 | n := i.node 18 | watch = n.mutateCh 19 | search := prefix 20 | for { 21 | // Check for key exhaution 22 | if len(search) == 0 { 23 | i.node = n 24 | return 25 | } 26 | 27 | // Look for an edge 28 | _, n = n.getEdge(search[0]) 29 | if n == nil { 30 | i.node = nil 31 | return 32 | } 33 | 34 | // Update to the finest granularity as the search makes progress 35 | watch = n.mutateCh 36 | 37 | // Consume the search prefix 38 | if bytes.HasPrefix(search, n.prefix) { 39 | search = search[len(n.prefix):] 40 | 41 | } else if bytes.HasPrefix(n.prefix, search) { 42 | i.node = n 43 | return 44 | } else { 45 | i.node = nil 46 | return 47 | } 48 | } 49 | } 50 | 51 | // SeekPrefix is used to seek the iterator to a given prefix 52 | func (i *Iterator) SeekPrefix(prefix []byte) { 53 | i.SeekPrefixWatch(prefix) 54 | } 55 | 56 | // Next returns the next node in order 57 | func (i *Iterator) Next() ([]byte, interface{}, bool) { 58 | // Initialize our stack if needed 59 | if i.stack == nil && i.node != nil { 60 | i.stack = []edges{ 61 | edges{ 62 | edge{node: i.node}, 63 | }, 64 | } 65 | } 66 | 67 | for len(i.stack) > 0 { 68 | // Inspect the last element of the stack 69 | n := len(i.stack) 70 | last := i.stack[n-1] 71 | elem := last[0].node 72 | 73 | // Update the stack 74 | if len(last) > 1 { 75 | i.stack[n-1] = last[1:] 76 | } else { 77 | i.stack = i.stack[:n-1] 78 | } 79 | 80 | // Push the edges onto the frontier 81 | if len(elem.edges) > 0 { 82 | i.stack = append(i.stack, elem.edges) 83 | } 84 | 85 | // Return the leaf values if any 86 | if elem.leaf != nil { 87 | return elem.leaf.key, elem.leaf.val, true 88 | } 89 | } 90 | return nil, nil, false 91 | } 92 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Package unix contains an interface to the low-level operating system 8 | // primitives. OS details vary depending on the underlying system, and 9 | // by default, godoc will display OS-specific documentation for the current 10 | // system. If you want godoc to display OS documentation for another 11 | // system, set $GOOS and $GOARCH to the desired system. For example, if 12 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS 13 | // to freebsd and $GOARCH to arm. 14 | // 15 | // The primary use of this package is inside other packages that provide a more 16 | // portable interface to the system, such as "os", "time" and "net". Use 17 | // those packages rather than this one if you can. 18 | // 19 | // For details of the functions and data types in this package consult 20 | // the manuals for the appropriate operating system. 21 | // 22 | // These calls return err == nil to indicate success; otherwise 23 | // err represents an operating system error describing the failure and 24 | // holds a value of type syscall.Errno. 25 | package unix // import "golang.org/x/sys/unix" 26 | 27 | import "strings" 28 | 29 | // ByteSliceFromString returns a NUL-terminated slice of bytes 30 | // containing the text of s. If s contains a NUL byte at any 31 | // location, it returns (nil, EINVAL). 32 | func ByteSliceFromString(s string) ([]byte, error) { 33 | if strings.IndexByte(s, 0) != -1 { 34 | return nil, EINVAL 35 | } 36 | a := make([]byte, len(s)+1) 37 | copy(a, s) 38 | return a, nil 39 | } 40 | 41 | // BytePtrFromString returns a pointer to a NUL-terminated array of 42 | // bytes containing the text of s. If s contains a NUL byte at any 43 | // location, it returns (nil, EINVAL). 44 | func BytePtrFromString(s string) (*byte, error) { 45 | a, err := ByteSliceFromString(s) 46 | if err != nil { 47 | return nil, err 48 | } 49 | return &a[0], nil 50 | } 51 | 52 | // Single-word zero for use when we need a valid pointer to 0 bytes. 53 | var _zero uintptr 54 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptrace386_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(386, amd64). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build 386 amd64 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegs386 is the registers used by 386 binaries. 11 | type PtraceRegs386 struct { 12 | Ebx int32 13 | Ecx int32 14 | Edx int32 15 | Esi int32 16 | Edi int32 17 | Ebp int32 18 | Eax int32 19 | Xds int32 20 | Xes int32 21 | Xfs int32 22 | Xgs int32 23 | Orig_eax int32 24 | Eip int32 25 | Xcs int32 26 | Eflags int32 27 | Esp int32 28 | Xss int32 29 | } 30 | 31 | // PtraceGetRegs386 fetches the registers used by 386 binaries. 32 | func PtraceGetRegs386(pid int, regsout *PtraceRegs386) error { 33 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 34 | } 35 | 36 | // PtraceSetRegs386 sets the registers used by 386 binaries. 37 | func PtraceSetRegs386(pid int, regs *PtraceRegs386) error { 38 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 39 | } 40 | 41 | // PtraceRegsAmd64 is the registers used by amd64 binaries. 42 | type PtraceRegsAmd64 struct { 43 | R15 uint64 44 | R14 uint64 45 | R13 uint64 46 | R12 uint64 47 | Rbp uint64 48 | Rbx uint64 49 | R11 uint64 50 | R10 uint64 51 | R9 uint64 52 | R8 uint64 53 | Rax uint64 54 | Rcx uint64 55 | Rdx uint64 56 | Rsi uint64 57 | Rdi uint64 58 | Orig_rax uint64 59 | Rip uint64 60 | Cs uint64 61 | Eflags uint64 62 | Rsp uint64 63 | Ss uint64 64 | Fs_base uint64 65 | Gs_base uint64 66 | Ds uint64 67 | Es uint64 68 | Fs uint64 69 | Gs uint64 70 | } 71 | 72 | // PtraceGetRegsAmd64 fetches the registers used by amd64 binaries. 73 | func PtraceGetRegsAmd64(pid int, regsout *PtraceRegsAmd64) error { 74 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 75 | } 76 | 77 | // PtraceSetRegsAmd64 sets the registers used by amd64 binaries. 78 | func PtraceSetRegsAmd64(pid int, regs *PtraceRegsAmd64) error { 79 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 80 | } 81 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | ) 12 | 13 | func setTimespec(sec, nsec int64) Timespec { 14 | return Timespec{Sec: sec, Nsec: nsec} 15 | } 16 | 17 | func setTimeval(sec, usec int64) Timeval { 18 | return Timeval{Sec: sec, Usec: int32(usec)} 19 | } 20 | 21 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 22 | func Gettimeofday(tv *Timeval) (err error) { 23 | // The tv passed to gettimeofday must be non-nil 24 | // but is otherwise unused. The answers come back 25 | // in the two registers. 26 | sec, usec, err := gettimeofday(tv) 27 | tv.Sec = sec 28 | tv.Usec = usec 29 | return err 30 | } 31 | 32 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 33 | k.Ident = uint64(fd) 34 | k.Filter = int16(mode) 35 | k.Flags = uint16(flags) 36 | } 37 | 38 | func (iov *Iovec) SetLen(length int) { 39 | iov.Len = uint64(length) 40 | } 41 | 42 | func (msghdr *Msghdr) SetControllen(length int) { 43 | msghdr.Controllen = uint32(length) 44 | } 45 | 46 | func (cmsg *Cmsghdr) SetLen(length int) { 47 | cmsg.Len = uint32(length) 48 | } 49 | 50 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 51 | 52 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 53 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 54 | const SYS___SYSCTL = SYS_SYSCTL 55 | 56 | //sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 57 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64 58 | //sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64 59 | //sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) = SYS_GETDIRENTRIES64 60 | //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64 61 | //sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 62 | //sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 63 | //sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64 64 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-hclog/stdlog.go: -------------------------------------------------------------------------------- 1 | package hclog 2 | 3 | import ( 4 | "bytes" 5 | "strings" 6 | ) 7 | 8 | // Provides a io.Writer to shim the data out of *log.Logger 9 | // and back into our Logger. This is basically the only way to 10 | // build upon *log.Logger. 11 | type stdlogAdapter struct { 12 | log Logger 13 | inferLevels bool 14 | forceLevel Level 15 | } 16 | 17 | // Take the data, infer the levels if configured, and send it through 18 | // a regular Logger. 19 | func (s *stdlogAdapter) Write(data []byte) (int, error) { 20 | str := string(bytes.TrimRight(data, " \t\n")) 21 | 22 | if s.forceLevel != NoLevel { 23 | // Use pickLevel to strip log levels included in the line since we are 24 | // forcing the level 25 | _, str := s.pickLevel(str) 26 | 27 | // Log at the forced level 28 | switch s.forceLevel { 29 | case Trace: 30 | s.log.Trace(str) 31 | case Debug: 32 | s.log.Debug(str) 33 | case Info: 34 | s.log.Info(str) 35 | case Warn: 36 | s.log.Warn(str) 37 | case Error: 38 | s.log.Error(str) 39 | default: 40 | s.log.Info(str) 41 | } 42 | } else if s.inferLevels { 43 | level, str := s.pickLevel(str) 44 | switch level { 45 | case Trace: 46 | s.log.Trace(str) 47 | case Debug: 48 | s.log.Debug(str) 49 | case Info: 50 | s.log.Info(str) 51 | case Warn: 52 | s.log.Warn(str) 53 | case Error: 54 | s.log.Error(str) 55 | default: 56 | s.log.Info(str) 57 | } 58 | } else { 59 | s.log.Info(str) 60 | } 61 | 62 | return len(data), nil 63 | } 64 | 65 | // Detect, based on conventions, what log level this is. 66 | func (s *stdlogAdapter) pickLevel(str string) (Level, string) { 67 | switch { 68 | case strings.HasPrefix(str, "[DEBUG]"): 69 | return Debug, strings.TrimSpace(str[7:]) 70 | case strings.HasPrefix(str, "[TRACE]"): 71 | return Trace, strings.TrimSpace(str[7:]) 72 | case strings.HasPrefix(str, "[INFO]"): 73 | return Info, strings.TrimSpace(str[6:]) 74 | case strings.HasPrefix(str, "[WARN]"): 75 | return Warn, strings.TrimSpace(str[7:]) 76 | case strings.HasPrefix(str, "[ERROR]"): 77 | return Error, strings.TrimSpace(str[7:]) 78 | case strings.HasPrefix(str, "[ERR]"): 79 | return Error, strings.TrimSpace(str[5:]) 80 | default: 81 | return Info, str 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | // +build !aix 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | // We can't use the gc-syntax .s files for gccgo. On the plus side 13 | // much of the functionality can be written directly in Go. 14 | 15 | //extern gccgoRealSyscallNoError 16 | func realSyscallNoError(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r uintptr) 17 | 18 | //extern gccgoRealSyscall 19 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 20 | 21 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) { 22 | syscall.Entersyscall() 23 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 24 | syscall.Exitsyscall() 25 | return r, 0 26 | } 27 | 28 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 29 | syscall.Entersyscall() 30 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 31 | syscall.Exitsyscall() 32 | return r, 0, syscall.Errno(errno) 33 | } 34 | 35 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 36 | syscall.Entersyscall() 37 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 38 | syscall.Exitsyscall() 39 | return r, 0, syscall.Errno(errno) 40 | } 41 | 42 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 43 | syscall.Entersyscall() 44 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 45 | syscall.Exitsyscall() 46 | return r, 0, syscall.Errno(errno) 47 | } 48 | 49 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) { 50 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 51 | return r, 0 52 | } 53 | 54 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 55 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 56 | return r, 0, syscall.Errno(errno) 57 | } 58 | 59 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 60 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 61 | return r, 0, syscall.Errno(errno) 62 | } 63 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | ) 12 | 13 | func setTimespec(sec, nsec int64) Timespec { 14 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 15 | } 16 | 17 | func setTimeval(sec, usec int64) Timeval { 18 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 19 | } 20 | 21 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 22 | func Gettimeofday(tv *Timeval) (err error) { 23 | // The tv passed to gettimeofday must be non-nil 24 | // but is otherwise unused. The answers come back 25 | // in the two registers. 26 | sec, usec, err := gettimeofday(tv) 27 | tv.Sec = int32(sec) 28 | tv.Usec = int32(usec) 29 | return err 30 | } 31 | 32 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 33 | k.Ident = uint32(fd) 34 | k.Filter = int16(mode) 35 | k.Flags = uint16(flags) 36 | } 37 | 38 | func (iov *Iovec) SetLen(length int) { 39 | iov.Len = uint32(length) 40 | } 41 | 42 | func (msghdr *Msghdr) SetControllen(length int) { 43 | msghdr.Controllen = uint32(length) 44 | } 45 | 46 | func (cmsg *Cmsghdr) SetLen(length int) { 47 | cmsg.Len = uint32(length) 48 | } 49 | 50 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 51 | 52 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 53 | // of darwin/386 the syscall is called sysctl instead of __sysctl. 54 | const SYS___SYSCTL = SYS_SYSCTL 55 | 56 | //sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 57 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64 58 | //sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64 59 | //sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) = SYS_GETDIRENTRIES64 60 | //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64 61 | //sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 62 | //sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 63 | //sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64 64 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix 6 | // +build ppc64 7 | 8 | package unix 9 | 10 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 11 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 12 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek 13 | 14 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) = mmap64 15 | 16 | func setTimespec(sec, nsec int64) Timespec { 17 | return Timespec{Sec: sec, Nsec: nsec} 18 | } 19 | 20 | func setTimeval(sec, usec int64) Timeval { 21 | return Timeval{Sec: int64(sec), Usec: int32(usec)} 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (cmsg *Cmsghdr) SetLen(length int) { 33 | cmsg.Len = uint32(length) 34 | } 35 | 36 | // In order to only have Timespec structure, type of Stat_t's fields 37 | // Atim, Mtim and Ctim is changed from StTimespec to Timespec during 38 | // ztypes generation. 39 | // On ppc64, Timespec.Nsec is an int64 while StTimespec.Nsec is an 40 | // int32, so the fields' value must be modified. 41 | func fixStatTimFields(stat *Stat_t) { 42 | stat.Atim.Nsec >>= 32 43 | stat.Mtim.Nsec >>= 32 44 | stat.Ctim.Nsec >>= 32 45 | } 46 | 47 | func Fstat(fd int, stat *Stat_t) error { 48 | err := fstat(fd, stat) 49 | if err != nil { 50 | return err 51 | } 52 | fixStatTimFields(stat) 53 | return nil 54 | } 55 | 56 | func Fstatat(dirfd int, path string, stat *Stat_t, flags int) error { 57 | err := fstatat(dirfd, path, stat, flags) 58 | if err != nil { 59 | return err 60 | } 61 | fixStatTimFields(stat) 62 | return nil 63 | } 64 | 65 | func Lstat(path string, stat *Stat_t) error { 66 | err := lstat(path, stat) 67 | if err != nil { 68 | return err 69 | } 70 | fixStatTimFields(stat) 71 | return nil 72 | } 73 | 74 | func Stat(path string, statptr *Stat_t) error { 75 | err := stat(path, statptr) 76 | if err != nil { 77 | return err 78 | } 79 | fixStatTimFields(statptr) 80 | return nil 81 | } 82 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/raft/discard_snapshot.go: -------------------------------------------------------------------------------- 1 | package raft 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | ) 7 | 8 | // DiscardSnapshotStore is used to successfully snapshot while 9 | // always discarding the snapshot. This is useful for when the 10 | // log should be truncated but no snapshot should be retained. 11 | // This should never be used for production use, and is only 12 | // suitable for testing. 13 | type DiscardSnapshotStore struct{} 14 | 15 | // DiscardSnapshotSink is used to fulfill the SnapshotSink interface 16 | // while always discarding the . This is useful for when the log 17 | // should be truncated but no snapshot should be retained. This 18 | // should never be used for production use, and is only suitable 19 | // for testing. 20 | type DiscardSnapshotSink struct{} 21 | 22 | // NewDiscardSnapshotStore is used to create a new DiscardSnapshotStore. 23 | func NewDiscardSnapshotStore() *DiscardSnapshotStore { 24 | return &DiscardSnapshotStore{} 25 | } 26 | 27 | // Create returns a valid type implementing the SnapshotSink which 28 | // always discards the snapshot. 29 | func (d *DiscardSnapshotStore) Create(version SnapshotVersion, index, term uint64, 30 | configuration Configuration, configurationIndex uint64, trans Transport) (SnapshotSink, error) { 31 | return &DiscardSnapshotSink{}, nil 32 | } 33 | 34 | // List returns successfully with a nil for []*SnapshotMeta. 35 | func (d *DiscardSnapshotStore) List() ([]*SnapshotMeta, error) { 36 | return nil, nil 37 | } 38 | 39 | // Open returns an error since the DiscardSnapshotStore does not 40 | // support opening snapshots. 41 | func (d *DiscardSnapshotStore) Open(id string) (*SnapshotMeta, io.ReadCloser, error) { 42 | return nil, nil, fmt.Errorf("open is not supported") 43 | } 44 | 45 | // Write returns successfully with the length of the input byte slice 46 | // to satisfy the WriteCloser interface 47 | func (d *DiscardSnapshotSink) Write(b []byte) (int, error) { 48 | return len(b), nil 49 | } 50 | 51 | // Close returns a nil error 52 | func (d *DiscardSnapshotSink) Close() error { 53 | return nil 54 | } 55 | 56 | // ID returns "discard" for DiscardSnapshotSink 57 | func (d *DiscardSnapshotSink) ID() string { 58 | return "discard" 59 | } 60 | 61 | // Cancel returns successfully with a nil error 62 | func (d *DiscardSnapshotSink) Cancel() error { 63 | return nil 64 | } 65 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/raft/Makefile: -------------------------------------------------------------------------------- 1 | DEPS = $(go list -f '{{range .TestImports}}{{.}} {{end}}' ./...) 2 | ENV = $(shell go env GOPATH) 3 | GO_VERSION = $(shell go version) 4 | GOLANG_CI_VERSION = v1.19.0 5 | 6 | # Look for versions prior to 1.10 which have a different fmt output 7 | # and don't lint with gofmt against them. 8 | ifneq (,$(findstring go version go1.8, $(GO_VERSION))) 9 | FMT= 10 | else ifneq (,$(findstring go version go1.9, $(GO_VERSION))) 11 | FMT= 12 | else 13 | FMT=--enable gofmt 14 | endif 15 | 16 | TEST_RESULTS_DIR?=/tmp/test-results 17 | 18 | test: 19 | go test $(TESTARGS) -timeout=60s -race . 20 | go test $(TESTARGS) -timeout=60s -tags batchtest -race . 21 | 22 | integ: test 23 | INTEG_TESTS=yes go test $(TESTARGS) -timeout=25s -run=Integ . 24 | INTEG_TESTS=yes go test $(TESTARGS) -timeout=25s -tags batchtest -run=Integ . 25 | 26 | ci.test-norace: 27 | gotestsum --format=short-verbose --junitfile $(TEST_RESULTS_DIR)/gotestsum-report-test.xml -- -timeout=60s 28 | gotestsum --format=short-verbose --junitfile $(TEST_RESULTS_DIR)/gotestsum-report-test.xml -- -timeout=60s -tags batchtest 29 | 30 | ci.test: 31 | gotestsum --format=short-verbose --junitfile $(TEST_RESULTS_DIR)/gotestsum-report-test.xml -- -timeout=60s -race . 32 | gotestsum --format=short-verbose --junitfile $(TEST_RESULTS_DIR)/gotestsum-report-test.xml -- -timeout=60s -race -tags batchtest . 33 | 34 | ci.integ: ci.test 35 | INTEG_TESTS=yes gotestsum --format=short-verbose --junitfile $(TEST_RESULTS_DIR)/gotestsum-report-integ.xml -- -timeout=25s -run=Integ . 36 | INTEG_TESTS=yes gotestsum --format=short-verbose --junitfile $(TEST_RESULTS_DIR)/gotestsum-report-integ.xml -- -timeout=25s -run=Integ -tags batchtest . 37 | 38 | fuzz: 39 | go test $(TESTARGS) -timeout=20m ./fuzzy 40 | go test $(TESTARGS) -timeout=20m -tags batchtest ./fuzzy 41 | 42 | deps: 43 | go get -t -d -v ./... 44 | echo $(DEPS) | xargs -n1 go get -d 45 | 46 | lint: 47 | gofmt -s -w . 48 | golangci-lint run -c .golangci-lint.yml $(FMT) . 49 | 50 | dep-linter: 51 | curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(ENV)/bin $(GOLANG_CI_VERSION) 52 | 53 | cov: 54 | INTEG_TESTS=yes gocov test github.com/hashicorp/raft | gocov-html > /tmp/coverage.html 55 | open /tmp/coverage.html 56 | 57 | .PHONY: test cov integ deps dep-linter lint 58 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/bolt_unix_solaris.go: -------------------------------------------------------------------------------- 1 | package bolt 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "syscall" 7 | "time" 8 | "unsafe" 9 | 10 | "golang.org/x/sys/unix" 11 | ) 12 | 13 | // flock acquires an advisory lock on a file descriptor. 14 | func flock(db *DB, mode os.FileMode, exclusive bool, timeout time.Duration) error { 15 | var t time.Time 16 | for { 17 | // If we're beyond our timeout then return an error. 18 | // This can only occur after we've attempted a flock once. 19 | if t.IsZero() { 20 | t = time.Now() 21 | } else if timeout > 0 && time.Since(t) > timeout { 22 | return ErrTimeout 23 | } 24 | var lock syscall.Flock_t 25 | lock.Start = 0 26 | lock.Len = 0 27 | lock.Pid = 0 28 | lock.Whence = 0 29 | lock.Pid = 0 30 | if exclusive { 31 | lock.Type = syscall.F_WRLCK 32 | } else { 33 | lock.Type = syscall.F_RDLCK 34 | } 35 | err := syscall.FcntlFlock(db.file.Fd(), syscall.F_SETLK, &lock) 36 | if err == nil { 37 | return nil 38 | } else if err != syscall.EAGAIN { 39 | return err 40 | } 41 | 42 | // Wait for a bit and try again. 43 | time.Sleep(50 * time.Millisecond) 44 | } 45 | } 46 | 47 | // funlock releases an advisory lock on a file descriptor. 48 | func funlock(db *DB) error { 49 | var lock syscall.Flock_t 50 | lock.Start = 0 51 | lock.Len = 0 52 | lock.Type = syscall.F_UNLCK 53 | lock.Whence = 0 54 | return syscall.FcntlFlock(uintptr(db.file.Fd()), syscall.F_SETLK, &lock) 55 | } 56 | 57 | // mmap memory maps a DB's data file. 58 | func mmap(db *DB, sz int) error { 59 | // Map the data file to memory. 60 | b, err := unix.Mmap(int(db.file.Fd()), 0, sz, syscall.PROT_READ, syscall.MAP_SHARED|db.MmapFlags) 61 | if err != nil { 62 | return err 63 | } 64 | 65 | // Advise the kernel that the mmap is accessed randomly. 66 | if err := unix.Madvise(b, syscall.MADV_RANDOM); err != nil { 67 | return fmt.Errorf("madvise: %s", err) 68 | } 69 | 70 | // Save the original byte slice and convert to a byte array pointer. 71 | db.dataref = b 72 | db.data = (*[maxMapSize]byte)(unsafe.Pointer(&b[0])) 73 | db.datasz = sz 74 | return nil 75 | } 76 | 77 | // munmap unmaps a DB's data file from memory. 78 | func munmap(db *DB) error { 79 | // Ignore the unmap if we have no mapped data. 80 | if db.dataref == nil { 81 | return nil 82 | } 83 | 84 | // Unmap using the original byte slice. 85 | err := unix.Munmap(db.dataref) 86 | db.dataref = nil 87 | db.data = nil 88 | db.datasz = 0 89 | return err 90 | } 91 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/bolt_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows,!plan9,!solaris 2 | 3 | package bolt 4 | 5 | import ( 6 | "fmt" 7 | "os" 8 | "syscall" 9 | "time" 10 | "unsafe" 11 | ) 12 | 13 | // flock acquires an advisory lock on a file descriptor. 14 | func flock(db *DB, mode os.FileMode, exclusive bool, timeout time.Duration) error { 15 | var t time.Time 16 | for { 17 | // If we're beyond our timeout then return an error. 18 | // This can only occur after we've attempted a flock once. 19 | if t.IsZero() { 20 | t = time.Now() 21 | } else if timeout > 0 && time.Since(t) > timeout { 22 | return ErrTimeout 23 | } 24 | flag := syscall.LOCK_SH 25 | if exclusive { 26 | flag = syscall.LOCK_EX 27 | } 28 | 29 | // Otherwise attempt to obtain an exclusive lock. 30 | err := syscall.Flock(int(db.file.Fd()), flag|syscall.LOCK_NB) 31 | if err == nil { 32 | return nil 33 | } else if err != syscall.EWOULDBLOCK { 34 | return err 35 | } 36 | 37 | // Wait for a bit and try again. 38 | time.Sleep(50 * time.Millisecond) 39 | } 40 | } 41 | 42 | // funlock releases an advisory lock on a file descriptor. 43 | func funlock(db *DB) error { 44 | return syscall.Flock(int(db.file.Fd()), syscall.LOCK_UN) 45 | } 46 | 47 | // mmap memory maps a DB's data file. 48 | func mmap(db *DB, sz int) error { 49 | // Map the data file to memory. 50 | b, err := syscall.Mmap(int(db.file.Fd()), 0, sz, syscall.PROT_READ, syscall.MAP_SHARED|db.MmapFlags) 51 | if err != nil { 52 | return err 53 | } 54 | 55 | // Advise the kernel that the mmap is accessed randomly. 56 | if err := madvise(b, syscall.MADV_RANDOM); err != nil { 57 | return fmt.Errorf("madvise: %s", err) 58 | } 59 | 60 | // Save the original byte slice and convert to a byte array pointer. 61 | db.dataref = b 62 | db.data = (*[maxMapSize]byte)(unsafe.Pointer(&b[0])) 63 | db.datasz = sz 64 | return nil 65 | } 66 | 67 | // munmap unmaps a DB's data file from memory. 68 | func munmap(db *DB) error { 69 | // Ignore the unmap if we have no mapped data. 70 | if db.dataref == nil { 71 | return nil 72 | } 73 | 74 | // Unmap using the original byte slice. 75 | err := syscall.Munmap(db.dataref) 76 | db.dataref = nil 77 | db.data = nil 78 | db.datasz = 0 79 | return err 80 | } 81 | 82 | // NOTE: This function is copied from stdlib because it is not available on darwin. 83 | func madvise(b []byte, advice int) (err error) { 84 | _, _, e1 := syscall.Syscall(syscall.SYS_MADVISE, uintptr(unsafe.Pointer(&b[0])), uintptr(len(b)), uintptr(advice)) 85 | if e1 != 0 { 86 | err = e1 87 | } 88 | return 89 | } 90 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/timestruct.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import "time" 10 | 11 | // TimespecToNsec converts a Timespec value into a number of 12 | // nanoseconds since the Unix epoch. 13 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 14 | 15 | // NsecToTimespec takes a number of nanoseconds since the Unix epoch 16 | // and returns the corresponding Timespec value. 17 | func NsecToTimespec(nsec int64) Timespec { 18 | sec := nsec / 1e9 19 | nsec = nsec % 1e9 20 | if nsec < 0 { 21 | nsec += 1e9 22 | sec-- 23 | } 24 | return setTimespec(sec, nsec) 25 | } 26 | 27 | // TimeToTimespec converts t into a Timespec. 28 | // On some 32-bit systems the range of valid Timespec values are smaller 29 | // than that of time.Time values. So if t is out of the valid range of 30 | // Timespec, it returns a zero Timespec and ERANGE. 31 | func TimeToTimespec(t time.Time) (Timespec, error) { 32 | sec := t.Unix() 33 | nsec := int64(t.Nanosecond()) 34 | ts := setTimespec(sec, nsec) 35 | 36 | // Currently all targets have either int32 or int64 for Timespec.Sec. 37 | // If there were a new target with floating point type for it, we have 38 | // to consider the rounding error. 39 | if int64(ts.Sec) != sec { 40 | return Timespec{}, ERANGE 41 | } 42 | return ts, nil 43 | } 44 | 45 | // TimevalToNsec converts a Timeval value into a number of nanoseconds 46 | // since the Unix epoch. 47 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 48 | 49 | // NsecToTimeval takes a number of nanoseconds since the Unix epoch 50 | // and returns the corresponding Timeval value. 51 | func NsecToTimeval(nsec int64) Timeval { 52 | nsec += 999 // round up to microsecond 53 | usec := nsec % 1e9 / 1e3 54 | sec := nsec / 1e9 55 | if usec < 0 { 56 | usec += 1e6 57 | sec-- 58 | } 59 | return setTimeval(sec, usec) 60 | } 61 | 62 | // Unix returns ts as the number of seconds and nanoseconds elapsed since the 63 | // Unix epoch. 64 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 65 | return int64(ts.Sec), int64(ts.Nsec) 66 | } 67 | 68 | // Unix returns tv as the number of seconds and nanoseconds elapsed since the 69 | // Unix epoch. 70 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 71 | return int64(tv.Sec), int64(tv.Usec) * 1000 72 | } 73 | 74 | // Nano returns ts as the number of nanoseconds elapsed since the Unix epoch. 75 | func (ts *Timespec) Nano() int64 { 76 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 77 | } 78 | 79 | // Nano returns tv as the number of nanoseconds elapsed since the Unix epoch. 80 | func (tv *Timeval) Nano() int64 { 81 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 82 | } 83 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/errors.go: -------------------------------------------------------------------------------- 1 | package bolt 2 | 3 | import "errors" 4 | 5 | // These errors can be returned when opening or calling methods on a DB. 6 | var ( 7 | // ErrDatabaseNotOpen is returned when a DB instance is accessed before it 8 | // is opened or after it is closed. 9 | ErrDatabaseNotOpen = errors.New("database not open") 10 | 11 | // ErrDatabaseOpen is returned when opening a database that is 12 | // already open. 13 | ErrDatabaseOpen = errors.New("database already open") 14 | 15 | // ErrInvalid is returned when both meta pages on a database are invalid. 16 | // This typically occurs when a file is not a bolt database. 17 | ErrInvalid = errors.New("invalid database") 18 | 19 | // ErrVersionMismatch is returned when the data file was created with a 20 | // different version of Bolt. 21 | ErrVersionMismatch = errors.New("version mismatch") 22 | 23 | // ErrChecksum is returned when either meta page checksum does not match. 24 | ErrChecksum = errors.New("checksum error") 25 | 26 | // ErrTimeout is returned when a database cannot obtain an exclusive lock 27 | // on the data file after the timeout passed to Open(). 28 | ErrTimeout = errors.New("timeout") 29 | ) 30 | 31 | // These errors can occur when beginning or committing a Tx. 32 | var ( 33 | // ErrTxNotWritable is returned when performing a write operation on a 34 | // read-only transaction. 35 | ErrTxNotWritable = errors.New("tx not writable") 36 | 37 | // ErrTxClosed is returned when committing or rolling back a transaction 38 | // that has already been committed or rolled back. 39 | ErrTxClosed = errors.New("tx closed") 40 | 41 | // ErrDatabaseReadOnly is returned when a mutating transaction is started on a 42 | // read-only database. 43 | ErrDatabaseReadOnly = errors.New("database is in read-only mode") 44 | ) 45 | 46 | // These errors can occur when putting or deleting a value or a bucket. 47 | var ( 48 | // ErrBucketNotFound is returned when trying to access a bucket that has 49 | // not been created yet. 50 | ErrBucketNotFound = errors.New("bucket not found") 51 | 52 | // ErrBucketExists is returned when creating a bucket that already exists. 53 | ErrBucketExists = errors.New("bucket already exists") 54 | 55 | // ErrBucketNameRequired is returned when creating a bucket with a blank name. 56 | ErrBucketNameRequired = errors.New("bucket name required") 57 | 58 | // ErrKeyRequired is returned when inserting a zero-length key. 59 | ErrKeyRequired = errors.New("key required") 60 | 61 | // ErrKeyTooLarge is returned when inserting a key that is larger than MaxKeySize. 62 | ErrKeyTooLarge = errors.New("key too large") 63 | 64 | // ErrValueTooLarge is returned when inserting a value that is larger than MaxValueSize. 65 | ErrValueTooLarge = errors.New("value too large") 66 | 67 | // ErrIncompatibleValue is returned when trying create or delete a bucket 68 | // on an existing non-bucket key or when trying to create or delete a 69 | // non-bucket key on an existing bucket key. 70 | ErrIncompatibleValue = errors.New("incompatible value") 71 | ) 72 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 另外一篇关于paxos协议的分享地址:https://github.com/vision9527/paxos 2 | 3 | ### 一、Raft协议简介 4 | 5 | * Raft 是一种为了管理复制日志的一致性协议 6 | 7 | * 复制状态机概念,复制状态机是指每个状态机或系统如果初始状态一致,然后接受的改变状态的命令也一致,最后产生的结果状态也是相同。 8 | 9 | * 中英文论文地址:https://github.com/maemual/raft-zh_cn 10 | 11 | * go夜读分享bilibili地址:https://www.bilibili.com/video/BV1tV411m7ir 12 | * go夜读分享youtube地址:https://www.youtube.com/watch?v=EjGNtHrq4UQ 13 | 14 | 15 | ### 二、Raft选举过程 16 | 17 | * 选举过程图1(单个节点视角) 18 | 19 | ![选举流程](./image/election.png) 20 | 21 | * 选举过程图2(整体视角) 22 | 23 | ![选举流程2](./image/election_timeout.jpeg) 24 | 25 | ### 三、Raft日志复制流程 26 | 27 | * 日志格式:term + index + cmd + type 28 | 29 | ![日志流程](./image/log_replicate.jpg) 30 | 31 | * 请求处理整体流程 32 | 33 | ![日志流程](./image/machine_state.png) 34 | 35 | * 请求处理详细流程(重点) 36 | 37 | ![日志流程](./image/request_process.png) 38 | 39 | 注:这里7. commit log 应该是在5. commit之后,但是因为commit策略的原因有一定延迟,所以从日志上看是在回复客户端以后 40 | 41 | ### 四、Raft协议动画演示 42 | 43 | * Raft系统运行可视化1 [http://thesecretlivesofdata.com/raft](http://thesecretlivesofdata.com/raft/) 44 | 45 | * Raft系统运行可视化2 [https://raft.github.io/#implementations](https://raft.github.io/#implementations) 46 | 47 | ### 五、hashicorp/raft源码讲解 48 | 49 | * hashicorp/raft库 [https://github.com/hashicorp/raft](https://github.com/hashicorp/raft) 50 | 51 | * raft启动流程 52 | 53 | * raft监听事件 54 | 55 | ### 六、运行hashicorp/raft库搭建的简单kv服务 56 | 57 | * 编译:go build -mod vendor 58 | 59 | * 启动node1: ./raft-demo --http_addr=127.0.0.1:7001 --raft_addr=127.0.0.1:7000 --raft_id=1 --raft_cluster=1/127.0.0.1:7000,2/127.0.0.1:8000,3/127.0.0.1:9000 60 | 61 | * 启动node2: ./raft-demo --http_addr=127.0.0.1:8001 --raft_addr=127.0.0.1:8000 --raft_id=2 --raft_cluster=1/127.0.0.1:7000,2/127.0.0.1:8000,3/127.0.0.1:9000 62 | 63 | * 启动node3: ./raft-demo --http_addr=127.0.0.1:9001 --raft_addr=127.0.0.1:9000 --raft_id=3 --raft_cluster=1/127.0.0.1:7000,2/127.0.0.1:8000,3/127.0.0.1:9000 64 | 65 | * set请求:curl http://127.0.0.1:7001/set?key=test_key&value=test_value 66 | 67 | * get请求:curl http://127.0.0.1:7001/get?key=test_key 68 | 69 | ### 七、调试场景 70 | 71 | ##### 选举变化相关 72 | 73 | 1. 集群启动后,follower等待一个随机election timeout时间变成candidate,然后发起投票,如果不能获得majority票数,则任期term会一直增加(未pre-vote情况)(branch: election-1) 74 | 75 | 2. 集群启动后,follower等待一个随机election timeout时间变成candidate,然后发起投票,获得majority票数的节点变成leader (branch: election-2) 76 | 77 | 3. leader选举成功后发送heartbeat保持leader的地位(branch: election-3) 78 | 79 | 4. leader失去majority节点的heartbeat响应,退回到follower(branch: election-4) 80 | 81 | ##### 日志复制相关 82 | 83 | 1. leader接收客户端请求,向集群内所有节点发送复制RPC,所有都正常响应 -> 正常commit,然后apply到状态机,最后返回客户端处理成功(branch: replicate-log-1) 84 | 85 | 2. leader接收客户端请求,向集群内所有节点发送复制RPC,majority正常响应 -> 正常commit,然后apply到状态机,最后返回客户端处理成功(branch: replicate-log-2) 86 | 87 | 3. leader接收客户端请求,向集群内所有节点发送复制RPC,少于majority正常响应 -> 不能commit(branch: replicate-log-3) 88 | 89 | ### 八、收获 90 | 91 | * hashicorp/raft源码 92 | 93 | * raft选举与日志复制 94 | 95 | ### 九、QA 96 | 97 | 纠正:3个节点宕机2个,剩下一个不可用,怎么处理请求的强一致? 98 | 99 | 答:这个时候服务应该是不可用的,当然如果要强行提供查询的服务,强一致肯定是无法保证的。 100 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "net/http" 7 | "os" 8 | "sync/atomic" 9 | "time" 10 | 11 | "github.com/hashicorp/raft" 12 | "github.com/vision9527/raft-demo/fsm" 13 | "github.com/vision9527/raft-demo/myraft" 14 | ) 15 | 16 | var ( 17 | httpAddr string 18 | raftAddr string 19 | raftId string 20 | raftCluster string 21 | raftDir string 22 | ) 23 | 24 | var ( 25 | isLeader int64 26 | ) 27 | 28 | func init() { 29 | flag.StringVar(&httpAddr, "http_addr", "127.0.0.1:7001", "http listen addr") 30 | flag.StringVar(&raftAddr, "raft_addr", "127.0.0.1:7000", "raft listen addr") 31 | flag.StringVar(&raftId, "raft_id", "1", "raft id") 32 | flag.StringVar(&raftCluster, "raft_cluster", "1/127.0.0.1:7000,2/127.0.0.1:8000,3/127.0.0.1:9000", "cluster info") 33 | } 34 | 35 | func main() { 36 | flag.Parse() 37 | // 初始化配置 38 | if httpAddr == "" || raftAddr == "" || raftId == "" || raftCluster == "" { 39 | fmt.Println("config error") 40 | os.Exit(1) 41 | return 42 | } 43 | raftDir := "node/raft_" + raftId 44 | os.MkdirAll(raftDir, 0700) 45 | 46 | // 初始化raft 47 | myRaft, fm, err := myraft.NewMyRaft(raftAddr, raftId, raftDir) 48 | if err != nil { 49 | fmt.Println("NewMyRaft error ", err) 50 | os.Exit(1) 51 | return 52 | } 53 | 54 | // 启动raft 55 | myraft.Bootstrap(myRaft, raftId, raftAddr, raftCluster) 56 | 57 | // 监听leader变化(使用此方法无法保证强一致性读,仅做leader变化过程观察) 58 | go func() { 59 | for leader := range myRaft.LeaderCh() { 60 | if leader { 61 | atomic.StoreInt64(&isLeader, 1) 62 | } else { 63 | atomic.StoreInt64(&isLeader, 0) 64 | } 65 | } 66 | }() 67 | 68 | // 启动http server 69 | httpServer := HttpServer{ 70 | ctx: myRaft, 71 | fsm: fm, 72 | } 73 | 74 | http.HandleFunc("/set", httpServer.Set) 75 | http.HandleFunc("/get", httpServer.Get) 76 | http.ListenAndServe(httpAddr, nil) 77 | 78 | // 关闭raft 79 | shutdownFuture := myRaft.Shutdown() 80 | if err := shutdownFuture.Error(); err != nil { 81 | fmt.Printf("shutdown raft error:%v \n", err) 82 | } 83 | 84 | // 退出http server 85 | fmt.Println("shutdown kv http server") 86 | } 87 | 88 | type HttpServer struct { 89 | ctx *raft.Raft 90 | fsm *fsm.Fsm 91 | } 92 | 93 | func (h HttpServer) Set(w http.ResponseWriter, r *http.Request) { 94 | if atomic.LoadInt64(&isLeader) == 0 { 95 | fmt.Fprintf(w, "not leader") 96 | return 97 | } 98 | vars := r.URL.Query() 99 | key := vars.Get("key") 100 | value := vars.Get("value") 101 | if key == "" || value == "" { 102 | fmt.Fprintf(w, "error key or value") 103 | return 104 | } 105 | 106 | data := "set" + "," + key + "," + value 107 | future := h.ctx.Apply([]byte(data), 5*time.Second) 108 | if err := future.Error(); err != nil { 109 | fmt.Fprintf(w, "error:"+err.Error()) 110 | return 111 | } 112 | fmt.Fprintf(w, "ok") 113 | return 114 | } 115 | 116 | func (h HttpServer) Get(w http.ResponseWriter, r *http.Request) { 117 | vars := r.URL.Query() 118 | key := vars.Get("key") 119 | if key == "" { 120 | fmt.Fprintf(w, "error key") 121 | return 122 | } 123 | value := h.fsm.DataBase.Get(key) 124 | fmt.Fprintf(w, value) 125 | return 126 | } 127 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/raft/peersjson.go: -------------------------------------------------------------------------------- 1 | package raft 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "io/ioutil" 7 | ) 8 | 9 | // ReadPeersJSON consumes a legacy peers.json file in the format of the old JSON 10 | // peer store and creates a new-style configuration structure. This can be used 11 | // to migrate this data or perform manual recovery when running protocol versions 12 | // that can interoperate with older, unversioned Raft servers. This should not be 13 | // used once server IDs are in use, because the old peers.json file didn't have 14 | // support for these, nor non-voter suffrage types. 15 | func ReadPeersJSON(path string) (Configuration, error) { 16 | // Read in the file. 17 | buf, err := ioutil.ReadFile(path) 18 | if err != nil { 19 | return Configuration{}, err 20 | } 21 | 22 | // Parse it as JSON. 23 | var peers []string 24 | dec := json.NewDecoder(bytes.NewReader(buf)) 25 | if err := dec.Decode(&peers); err != nil { 26 | return Configuration{}, err 27 | } 28 | 29 | // Map it into the new-style configuration structure. We can only specify 30 | // voter roles here, and the ID has to be the same as the address. 31 | var configuration Configuration 32 | for _, peer := range peers { 33 | server := Server{ 34 | Suffrage: Voter, 35 | ID: ServerID(peer), 36 | Address: ServerAddress(peer), 37 | } 38 | configuration.Servers = append(configuration.Servers, server) 39 | } 40 | 41 | // We should only ingest valid configurations. 42 | if err := checkConfiguration(configuration); err != nil { 43 | return Configuration{}, err 44 | } 45 | return configuration, nil 46 | } 47 | 48 | // configEntry is used when decoding a new-style peers.json. 49 | type configEntry struct { 50 | // ID is the ID of the server (a UUID, usually). 51 | ID ServerID `json:"id"` 52 | 53 | // Address is the host:port of the server. 54 | Address ServerAddress `json:"address"` 55 | 56 | // NonVoter controls the suffrage. We choose this sense so people 57 | // can leave this out and get a Voter by default. 58 | NonVoter bool `json:"non_voter"` 59 | } 60 | 61 | // ReadConfigJSON reads a new-style peers.json and returns a configuration 62 | // structure. This can be used to perform manual recovery when running protocol 63 | // versions that use server IDs. 64 | func ReadConfigJSON(path string) (Configuration, error) { 65 | // Read in the file. 66 | buf, err := ioutil.ReadFile(path) 67 | if err != nil { 68 | return Configuration{}, err 69 | } 70 | 71 | // Parse it as JSON. 72 | var peers []configEntry 73 | dec := json.NewDecoder(bytes.NewReader(buf)) 74 | if err := dec.Decode(&peers); err != nil { 75 | return Configuration{}, err 76 | } 77 | 78 | // Map it into the new-style configuration structure. 79 | var configuration Configuration 80 | for _, peer := range peers { 81 | suffrage := Voter 82 | if peer.NonVoter { 83 | suffrage = Nonvoter 84 | } 85 | server := Server{ 86 | Suffrage: suffrage, 87 | ID: peer.ID, 88 | Address: peer.Address, 89 | } 90 | configuration.Servers = append(configuration.Servers, server) 91 | } 92 | 93 | // We should only ingest valid configurations. 94 | if err := checkConfiguration(configuration); err != nil { 95 | return Configuration{}, err 96 | } 97 | return configuration, nil 98 | } 99 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/raft/inmem_snapshot.go: -------------------------------------------------------------------------------- 1 | package raft 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "io" 7 | "io/ioutil" 8 | "sync" 9 | ) 10 | 11 | // InmemSnapshotStore implements the SnapshotStore interface and 12 | // retains only the most recent snapshot 13 | type InmemSnapshotStore struct { 14 | latest *InmemSnapshotSink 15 | hasSnapshot bool 16 | sync.RWMutex 17 | } 18 | 19 | // InmemSnapshotSink implements SnapshotSink in memory 20 | type InmemSnapshotSink struct { 21 | meta SnapshotMeta 22 | contents *bytes.Buffer 23 | } 24 | 25 | // NewInmemSnapshotStore creates a blank new InmemSnapshotStore 26 | func NewInmemSnapshotStore() *InmemSnapshotStore { 27 | return &InmemSnapshotStore{ 28 | latest: &InmemSnapshotSink{ 29 | contents: &bytes.Buffer{}, 30 | }, 31 | } 32 | } 33 | 34 | // Create replaces the stored snapshot with a new one using the given args 35 | func (m *InmemSnapshotStore) Create(version SnapshotVersion, index, term uint64, 36 | configuration Configuration, configurationIndex uint64, trans Transport) (SnapshotSink, error) { 37 | // We only support version 1 snapshots at this time. 38 | if version != 1 { 39 | return nil, fmt.Errorf("unsupported snapshot version %d", version) 40 | } 41 | 42 | name := snapshotName(term, index) 43 | 44 | m.Lock() 45 | defer m.Unlock() 46 | 47 | sink := &InmemSnapshotSink{ 48 | meta: SnapshotMeta{ 49 | Version: version, 50 | ID: name, 51 | Index: index, 52 | Term: term, 53 | Peers: encodePeers(configuration, trans), 54 | Configuration: configuration, 55 | ConfigurationIndex: configurationIndex, 56 | }, 57 | contents: &bytes.Buffer{}, 58 | } 59 | m.hasSnapshot = true 60 | m.latest = sink 61 | 62 | return sink, nil 63 | } 64 | 65 | // List returns the latest snapshot taken 66 | func (m *InmemSnapshotStore) List() ([]*SnapshotMeta, error) { 67 | m.RLock() 68 | defer m.RUnlock() 69 | 70 | if !m.hasSnapshot { 71 | return []*SnapshotMeta{}, nil 72 | } 73 | return []*SnapshotMeta{&m.latest.meta}, nil 74 | } 75 | 76 | // Open wraps an io.ReadCloser around the snapshot contents 77 | func (m *InmemSnapshotStore) Open(id string) (*SnapshotMeta, io.ReadCloser, error) { 78 | m.RLock() 79 | defer m.RUnlock() 80 | 81 | if m.latest.meta.ID != id { 82 | return nil, nil, fmt.Errorf("[ERR] snapshot: failed to open snapshot id: %s", id) 83 | } 84 | 85 | // Make a copy of the contents, since a bytes.Buffer can only be read 86 | // once. 87 | contents := bytes.NewBuffer(m.latest.contents.Bytes()) 88 | return &m.latest.meta, ioutil.NopCloser(contents), nil 89 | } 90 | 91 | // Write appends the given bytes to the snapshot contents 92 | func (s *InmemSnapshotSink) Write(p []byte) (n int, err error) { 93 | written, err := io.Copy(s.contents, bytes.NewReader(p)) 94 | s.meta.Size += written 95 | return int(written), err 96 | } 97 | 98 | // Close updates the Size and is otherwise a no-op 99 | func (s *InmemSnapshotSink) Close() error { 100 | return nil 101 | } 102 | 103 | // ID returns the ID of the SnapshotMeta 104 | func (s *InmemSnapshotSink) ID() string { 105 | return s.meta.ID 106 | } 107 | 108 | // Cancel returns successfully with a nil error 109 | func (s *InmemSnapshotSink) Cancel() error { 110 | return nil 111 | } 112 | -------------------------------------------------------------------------------- /vendor/github.com/armon/go-metrics/inmem_signal.go: -------------------------------------------------------------------------------- 1 | package metrics 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "io" 7 | "os" 8 | "os/signal" 9 | "strings" 10 | "sync" 11 | "syscall" 12 | ) 13 | 14 | // InmemSignal is used to listen for a given signal, and when received, 15 | // to dump the current metrics from the InmemSink to an io.Writer 16 | type InmemSignal struct { 17 | signal syscall.Signal 18 | inm *InmemSink 19 | w io.Writer 20 | sigCh chan os.Signal 21 | 22 | stop bool 23 | stopCh chan struct{} 24 | stopLock sync.Mutex 25 | } 26 | 27 | // NewInmemSignal creates a new InmemSignal which listens for a given signal, 28 | // and dumps the current metrics out to a writer 29 | func NewInmemSignal(inmem *InmemSink, sig syscall.Signal, w io.Writer) *InmemSignal { 30 | i := &InmemSignal{ 31 | signal: sig, 32 | inm: inmem, 33 | w: w, 34 | sigCh: make(chan os.Signal, 1), 35 | stopCh: make(chan struct{}), 36 | } 37 | signal.Notify(i.sigCh, sig) 38 | go i.run() 39 | return i 40 | } 41 | 42 | // DefaultInmemSignal returns a new InmemSignal that responds to SIGUSR1 43 | // and writes output to stderr. Windows uses SIGBREAK 44 | func DefaultInmemSignal(inmem *InmemSink) *InmemSignal { 45 | return NewInmemSignal(inmem, DefaultSignal, os.Stderr) 46 | } 47 | 48 | // Stop is used to stop the InmemSignal from listening 49 | func (i *InmemSignal) Stop() { 50 | i.stopLock.Lock() 51 | defer i.stopLock.Unlock() 52 | 53 | if i.stop { 54 | return 55 | } 56 | i.stop = true 57 | close(i.stopCh) 58 | signal.Stop(i.sigCh) 59 | } 60 | 61 | // run is a long running routine that handles signals 62 | func (i *InmemSignal) run() { 63 | for { 64 | select { 65 | case <-i.sigCh: 66 | i.dumpStats() 67 | case <-i.stopCh: 68 | return 69 | } 70 | } 71 | } 72 | 73 | // dumpStats is used to dump the data to output writer 74 | func (i *InmemSignal) dumpStats() { 75 | buf := bytes.NewBuffer(nil) 76 | 77 | data := i.inm.Data() 78 | // Skip the last period which is still being aggregated 79 | for j := 0; j < len(data)-1; j++ { 80 | intv := data[j] 81 | intv.RLock() 82 | for _, val := range intv.Gauges { 83 | name := i.flattenLabels(val.Name, val.Labels) 84 | fmt.Fprintf(buf, "[%v][G] '%s': %0.3f\n", intv.Interval, name, val.Value) 85 | } 86 | for name, vals := range intv.Points { 87 | for _, val := range vals { 88 | fmt.Fprintf(buf, "[%v][P] '%s': %0.3f\n", intv.Interval, name, val) 89 | } 90 | } 91 | for _, agg := range intv.Counters { 92 | name := i.flattenLabels(agg.Name, agg.Labels) 93 | fmt.Fprintf(buf, "[%v][C] '%s': %s\n", intv.Interval, name, agg.AggregateSample) 94 | } 95 | for _, agg := range intv.Samples { 96 | name := i.flattenLabels(agg.Name, agg.Labels) 97 | fmt.Fprintf(buf, "[%v][S] '%s': %s\n", intv.Interval, name, agg.AggregateSample) 98 | } 99 | intv.RUnlock() 100 | } 101 | 102 | // Write out the bytes 103 | i.w.Write(buf.Bytes()) 104 | } 105 | 106 | // Flattens the key for formatting along with its labels, removes spaces 107 | func (i *InmemSignal) flattenLabels(name string, labels []Label) string { 108 | buf := bytes.NewBufferString(name) 109 | replacer := strings.NewReplacer(" ", "_", ":", "_") 110 | 111 | for _, label := range labels { 112 | replacer.WriteString(buf, ".") 113 | replacer.WriteString(buf, label.Value) 114 | } 115 | 116 | return buf.String() 117 | } 118 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/raft/log.go: -------------------------------------------------------------------------------- 1 | package raft 2 | 3 | // LogType describes various types of log entries. 4 | type LogType uint8 5 | 6 | const ( 7 | // LogCommand is applied to a user FSM. 8 | LogCommand LogType = iota 9 | 10 | // LogNoop is used to assert leadership. 11 | LogNoop 12 | 13 | // LogAddPeerDeprecated is used to add a new peer. This should only be used with 14 | // older protocol versions designed to be compatible with unversioned 15 | // Raft servers. See comments in config.go for details. 16 | LogAddPeerDeprecated 17 | 18 | // LogRemovePeerDeprecated is used to remove an existing peer. This should only be 19 | // used with older protocol versions designed to be compatible with 20 | // unversioned Raft servers. See comments in config.go for details. 21 | LogRemovePeerDeprecated 22 | 23 | // LogBarrier is used to ensure all preceding operations have been 24 | // applied to the FSM. It is similar to LogNoop, but instead of returning 25 | // once committed, it only returns once the FSM manager acks it. Otherwise 26 | // it is possible there are operations committed but not yet applied to 27 | // the FSM. 28 | LogBarrier 29 | 30 | // LogConfiguration establishes a membership change configuration. It is 31 | // created when a server is added, removed, promoted, etc. Only used 32 | // when protocol version 1 or greater is in use. 33 | LogConfiguration 34 | ) 35 | 36 | // Log entries are replicated to all members of the Raft cluster 37 | // and form the heart of the replicated state machine. 38 | type Log struct { 39 | // Index holds the index of the log entry. 40 | Index uint64 41 | 42 | // Term holds the election term of the log entry. 43 | Term uint64 44 | 45 | // Type holds the type of the log entry. 46 | Type LogType 47 | 48 | // Data holds the log entry's type-specific data. 49 | Data []byte 50 | 51 | // Extensions holds an opaque byte slice of information for middleware. It 52 | // is up to the client of the library to properly modify this as it adds 53 | // layers and remove those layers when appropriate. This value is a part of 54 | // the log, so very large values could cause timing issues. 55 | // 56 | // N.B. It is _up to the client_ to handle upgrade paths. For instance if 57 | // using this with go-raftchunking, the client should ensure that all Raft 58 | // peers are using a version that can handle that extension before ever 59 | // actually triggering chunking behavior. It is sometimes sufficient to 60 | // ensure that non-leaders are upgraded first, then the current leader is 61 | // upgraded, but a leader changeover during this process could lead to 62 | // trouble, so gating extension behavior via some flag in the client 63 | // program is also a good idea. 64 | Extensions []byte 65 | } 66 | 67 | // LogStore is used to provide an interface for storing 68 | // and retrieving logs in a durable fashion. 69 | type LogStore interface { 70 | // FirstIndex returns the first index written. 0 for no entries. 71 | FirstIndex() (uint64, error) 72 | 73 | // LastIndex returns the last index written. 0 for no entries. 74 | LastIndex() (uint64, error) 75 | 76 | // GetLog gets a log entry at a given index. 77 | GetLog(index uint64, log *Log) error 78 | 79 | // StoreLog stores a log entry. 80 | StoreLog(log *Log) error 81 | 82 | // StoreLogs stores multiple log entries. 83 | StoreLogs(logs []*Log) error 84 | 85 | // DeleteRange deletes a range of log entries. The range is inclusive. 86 | DeleteRange(min, max uint64) error 87 | } 88 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/raft/inmem_store.go: -------------------------------------------------------------------------------- 1 | package raft 2 | 3 | import ( 4 | "errors" 5 | "sync" 6 | ) 7 | 8 | // InmemStore implements the LogStore and StableStore interface. 9 | // It should NOT EVER be used for production. It is used only for 10 | // unit tests. Use the MDBStore implementation instead. 11 | type InmemStore struct { 12 | l sync.RWMutex 13 | lowIndex uint64 14 | highIndex uint64 15 | logs map[uint64]*Log 16 | kv map[string][]byte 17 | kvInt map[string]uint64 18 | } 19 | 20 | // NewInmemStore returns a new in-memory backend. Do not ever 21 | // use for production. Only for testing. 22 | func NewInmemStore() *InmemStore { 23 | i := &InmemStore{ 24 | logs: make(map[uint64]*Log), 25 | kv: make(map[string][]byte), 26 | kvInt: make(map[string]uint64), 27 | } 28 | return i 29 | } 30 | 31 | // FirstIndex implements the LogStore interface. 32 | func (i *InmemStore) FirstIndex() (uint64, error) { 33 | i.l.RLock() 34 | defer i.l.RUnlock() 35 | return i.lowIndex, nil 36 | } 37 | 38 | // LastIndex implements the LogStore interface. 39 | func (i *InmemStore) LastIndex() (uint64, error) { 40 | i.l.RLock() 41 | defer i.l.RUnlock() 42 | return i.highIndex, nil 43 | } 44 | 45 | // GetLog implements the LogStore interface. 46 | func (i *InmemStore) GetLog(index uint64, log *Log) error { 47 | i.l.RLock() 48 | defer i.l.RUnlock() 49 | l, ok := i.logs[index] 50 | if !ok { 51 | return ErrLogNotFound 52 | } 53 | *log = *l 54 | return nil 55 | } 56 | 57 | // StoreLog implements the LogStore interface. 58 | func (i *InmemStore) StoreLog(log *Log) error { 59 | return i.StoreLogs([]*Log{log}) 60 | } 61 | 62 | // StoreLogs implements the LogStore interface. 63 | func (i *InmemStore) StoreLogs(logs []*Log) error { 64 | i.l.Lock() 65 | defer i.l.Unlock() 66 | for _, l := range logs { 67 | i.logs[l.Index] = l 68 | if i.lowIndex == 0 { 69 | i.lowIndex = l.Index 70 | } 71 | if l.Index > i.highIndex { 72 | i.highIndex = l.Index 73 | } 74 | } 75 | return nil 76 | } 77 | 78 | // DeleteRange implements the LogStore interface. 79 | func (i *InmemStore) DeleteRange(min, max uint64) error { 80 | i.l.Lock() 81 | defer i.l.Unlock() 82 | for j := min; j <= max; j++ { 83 | delete(i.logs, j) 84 | } 85 | if min <= i.lowIndex { 86 | i.lowIndex = max + 1 87 | } 88 | if max >= i.highIndex { 89 | i.highIndex = min - 1 90 | } 91 | if i.lowIndex > i.highIndex { 92 | i.lowIndex = 0 93 | i.highIndex = 0 94 | } 95 | return nil 96 | } 97 | 98 | // Set implements the StableStore interface. 99 | func (i *InmemStore) Set(key []byte, val []byte) error { 100 | i.l.Lock() 101 | defer i.l.Unlock() 102 | i.kv[string(key)] = val 103 | return nil 104 | } 105 | 106 | // Get implements the StableStore interface. 107 | func (i *InmemStore) Get(key []byte) ([]byte, error) { 108 | i.l.RLock() 109 | defer i.l.RUnlock() 110 | val := i.kv[string(key)] 111 | if val == nil { 112 | return nil, errors.New("not found") 113 | } 114 | return val, nil 115 | } 116 | 117 | // SetUint64 implements the StableStore interface. 118 | func (i *InmemStore) SetUint64(key []byte, val uint64) error { 119 | i.l.Lock() 120 | defer i.l.Unlock() 121 | i.kvInt[string(key)] = val 122 | return nil 123 | } 124 | 125 | // GetUint64 implements the StableStore interface. 126 | func (i *InmemStore) GetUint64(key []byte) (uint64, error) { 127 | i.l.RLock() 128 | defer i.l.RUnlock() 129 | return i.kvInt[string(key)], nil 130 | } 131 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/raft/util.go: -------------------------------------------------------------------------------- 1 | package raft 2 | 3 | import ( 4 | "bytes" 5 | crand "crypto/rand" 6 | "fmt" 7 | "math" 8 | "math/big" 9 | "math/rand" 10 | "time" 11 | 12 | "github.com/hashicorp/go-msgpack/codec" 13 | ) 14 | 15 | func init() { 16 | // Ensure we use a high-entropy seed for the pseudo-random generator 17 | rand.Seed(newSeed()) 18 | } 19 | 20 | // returns an int64 from a crypto random source 21 | // can be used to seed a source for a math/rand. 22 | func newSeed() int64 { 23 | r, err := crand.Int(crand.Reader, big.NewInt(math.MaxInt64)) 24 | if err != nil { 25 | panic(fmt.Errorf("failed to read random bytes: %v", err)) 26 | } 27 | return r.Int64() 28 | } 29 | 30 | // randomTimeout returns a value that is between the minVal and 2x minVal. 31 | func randomTimeout(minVal time.Duration) <-chan time.Time { 32 | if minVal == 0 { 33 | return nil 34 | } 35 | extra := (time.Duration(rand.Int63()) % minVal) 36 | return time.After(minVal + extra) 37 | } 38 | 39 | // min returns the minimum. 40 | func min(a, b uint64) uint64 { 41 | if a <= b { 42 | return a 43 | } 44 | return b 45 | } 46 | 47 | // max returns the maximum. 48 | func max(a, b uint64) uint64 { 49 | if a >= b { 50 | return a 51 | } 52 | return b 53 | } 54 | 55 | // generateUUID is used to generate a random UUID. 56 | func generateUUID() string { 57 | buf := make([]byte, 16) 58 | if _, err := crand.Read(buf); err != nil { 59 | panic(fmt.Errorf("failed to read random bytes: %v", err)) 60 | } 61 | 62 | return fmt.Sprintf("%08x-%04x-%04x-%04x-%12x", 63 | buf[0:4], 64 | buf[4:6], 65 | buf[6:8], 66 | buf[8:10], 67 | buf[10:16]) 68 | } 69 | 70 | // asyncNotifyCh is used to do an async channel send 71 | // to a single channel without blocking. 72 | func asyncNotifyCh(ch chan struct{}) { 73 | select { 74 | case ch <- struct{}{}: 75 | default: 76 | } 77 | } 78 | 79 | // drainNotifyCh empties out a single-item notification channel without 80 | // blocking, and returns whether it received anything. 81 | func drainNotifyCh(ch chan struct{}) bool { 82 | select { 83 | case <-ch: 84 | return true 85 | default: 86 | return false 87 | } 88 | } 89 | 90 | // asyncNotifyBool is used to do an async notification 91 | // on a bool channel. 92 | func asyncNotifyBool(ch chan bool, v bool) { 93 | select { 94 | case ch <- v: 95 | default: 96 | } 97 | } 98 | 99 | // Decode reverses the encode operation on a byte slice input. 100 | func decodeMsgPack(buf []byte, out interface{}) error { 101 | r := bytes.NewBuffer(buf) 102 | hd := codec.MsgpackHandle{} 103 | dec := codec.NewDecoder(r, &hd) 104 | return dec.Decode(out) 105 | } 106 | 107 | // Encode writes an encoded object to a new bytes buffer. 108 | func encodeMsgPack(in interface{}) (*bytes.Buffer, error) { 109 | buf := bytes.NewBuffer(nil) 110 | hd := codec.MsgpackHandle{} 111 | enc := codec.NewEncoder(buf, &hd) 112 | err := enc.Encode(in) 113 | return buf, err 114 | } 115 | 116 | // backoff is used to compute an exponential backoff 117 | // duration. Base time is scaled by the current round, 118 | // up to some maximum scale factor. 119 | func backoff(base time.Duration, round, limit uint64) time.Duration { 120 | power := min(round, limit) 121 | for power > 2 { 122 | base *= 2 123 | power-- 124 | } 125 | return base 126 | } 127 | 128 | // Needed for sorting []uint64, used to determine commitment 129 | type uint64Slice []uint64 130 | 131 | func (p uint64Slice) Len() int { return len(p) } 132 | func (p uint64Slice) Less(i, j int) bool { return p[i] < p[j] } 133 | func (p uint64Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } 134 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/raft/tcp_transport.go: -------------------------------------------------------------------------------- 1 | package raft 2 | 3 | import ( 4 | "errors" 5 | "github.com/hashicorp/go-hclog" 6 | "io" 7 | "net" 8 | "time" 9 | ) 10 | 11 | var ( 12 | errNotAdvertisable = errors.New("local bind address is not advertisable") 13 | errNotTCP = errors.New("local address is not a TCP address") 14 | ) 15 | 16 | // TCPStreamLayer implements StreamLayer interface for plain TCP. 17 | type TCPStreamLayer struct { 18 | advertise net.Addr 19 | listener *net.TCPListener 20 | } 21 | 22 | // NewTCPTransport returns a NetworkTransport that is built on top of 23 | // a TCP streaming transport layer. 24 | func NewTCPTransport( 25 | bindAddr string, 26 | advertise net.Addr, 27 | maxPool int, 28 | timeout time.Duration, 29 | logOutput io.Writer, 30 | ) (*NetworkTransport, error) { 31 | return newTCPTransport(bindAddr, advertise, func(stream StreamLayer) *NetworkTransport { 32 | return NewNetworkTransport(stream, maxPool, timeout, logOutput) 33 | }) 34 | } 35 | 36 | // NewTCPTransportWithLogger returns a NetworkTransport that is built on top of 37 | // a TCP streaming transport layer, with log output going to the supplied Logger 38 | func NewTCPTransportWithLogger( 39 | bindAddr string, 40 | advertise net.Addr, 41 | maxPool int, 42 | timeout time.Duration, 43 | logger hclog.Logger, 44 | ) (*NetworkTransport, error) { 45 | return newTCPTransport(bindAddr, advertise, func(stream StreamLayer) *NetworkTransport { 46 | return NewNetworkTransportWithLogger(stream, maxPool, timeout, logger) 47 | }) 48 | } 49 | 50 | // NewTCPTransportWithConfig returns a NetworkTransport that is built on top of 51 | // a TCP streaming transport layer, using the given config struct. 52 | func NewTCPTransportWithConfig( 53 | bindAddr string, 54 | advertise net.Addr, 55 | config *NetworkTransportConfig, 56 | ) (*NetworkTransport, error) { 57 | return newTCPTransport(bindAddr, advertise, func(stream StreamLayer) *NetworkTransport { 58 | config.Stream = stream 59 | return NewNetworkTransportWithConfig(config) 60 | }) 61 | } 62 | 63 | func newTCPTransport(bindAddr string, 64 | advertise net.Addr, 65 | transportCreator func(stream StreamLayer) *NetworkTransport) (*NetworkTransport, error) { 66 | // Try to bind 67 | list, err := net.Listen("tcp", bindAddr) 68 | if err != nil { 69 | return nil, err 70 | } 71 | 72 | // Create stream 73 | stream := &TCPStreamLayer{ 74 | advertise: advertise, 75 | listener: list.(*net.TCPListener), 76 | } 77 | 78 | // Verify that we have a usable advertise address 79 | addr, ok := stream.Addr().(*net.TCPAddr) 80 | if !ok { 81 | list.Close() 82 | return nil, errNotTCP 83 | } 84 | if addr.IP.IsUnspecified() { 85 | list.Close() 86 | return nil, errNotAdvertisable 87 | } 88 | 89 | // Create the network transport 90 | trans := transportCreator(stream) 91 | return trans, nil 92 | } 93 | 94 | // Dial implements the StreamLayer interface. 95 | func (t *TCPStreamLayer) Dial(address ServerAddress, timeout time.Duration) (net.Conn, error) { 96 | return net.DialTimeout("tcp", string(address), timeout) 97 | } 98 | 99 | // Accept implements the net.Listener interface. 100 | func (t *TCPStreamLayer) Accept() (c net.Conn, err error) { 101 | return t.listener.Accept() 102 | } 103 | 104 | // Close implements the net.Listener interface. 105 | func (t *TCPStreamLayer) Close() (err error) { 106 | return t.listener.Close() 107 | } 108 | 109 | // Addr implements the net.Listener interface. 110 | func (t *TCPStreamLayer) Addr() net.Addr { 111 | // Use an advertise addr if provided 112 | if t.advertise != nil { 113 | return t.advertise 114 | } 115 | return t.listener.Addr() 116 | } 117 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/raft/commitment.go: -------------------------------------------------------------------------------- 1 | package raft 2 | 3 | import ( 4 | "sort" 5 | "sync" 6 | ) 7 | 8 | // Commitment is used to advance the leader's commit index. The leader and 9 | // replication goroutines report in newly written entries with Match(), and 10 | // this notifies on commitCh when the commit index has advanced. 11 | type commitment struct { 12 | // protects matchIndexes and commitIndex 13 | sync.Mutex 14 | // notified when commitIndex increases 15 | commitCh chan struct{} 16 | // voter ID to log index: the server stores up through this log entry 17 | matchIndexes map[ServerID]uint64 18 | // a quorum stores up through this log entry. monotonically increases. 19 | commitIndex uint64 20 | // the first index of this leader's term: this needs to be replicated to a 21 | // majority of the cluster before this leader may mark anything committed 22 | // (per Raft's commitment rule) 23 | startIndex uint64 24 | } 25 | 26 | // newCommitment returns an commitment struct that notifies the provided 27 | // channel when log entries have been committed. A new commitment struct is 28 | // created each time this server becomes leader for a particular term. 29 | // 'configuration' is the servers in the cluster. 30 | // 'startIndex' is the first index created in this term (see 31 | // its description above). 32 | func newCommitment(commitCh chan struct{}, configuration Configuration, startIndex uint64) *commitment { 33 | matchIndexes := make(map[ServerID]uint64) 34 | for _, server := range configuration.Servers { 35 | if server.Suffrage == Voter { 36 | matchIndexes[server.ID] = 0 37 | } 38 | } 39 | return &commitment{ 40 | commitCh: commitCh, 41 | matchIndexes: matchIndexes, 42 | commitIndex: 0, 43 | startIndex: startIndex, 44 | } 45 | } 46 | 47 | // Called when a new cluster membership configuration is created: it will be 48 | // used to determine commitment from now on. 'configuration' is the servers in 49 | // the cluster. 50 | func (c *commitment) setConfiguration(configuration Configuration) { 51 | c.Lock() 52 | defer c.Unlock() 53 | oldMatchIndexes := c.matchIndexes 54 | c.matchIndexes = make(map[ServerID]uint64) 55 | for _, server := range configuration.Servers { 56 | if server.Suffrage == Voter { 57 | c.matchIndexes[server.ID] = oldMatchIndexes[server.ID] // defaults to 0 58 | } 59 | } 60 | c.recalculate() 61 | } 62 | 63 | // Called by leader after commitCh is notified 64 | func (c *commitment) getCommitIndex() uint64 { 65 | c.Lock() 66 | defer c.Unlock() 67 | return c.commitIndex 68 | } 69 | 70 | // Match is called once a server completes writing entries to disk: either the 71 | // leader has written the new entry or a follower has replied to an 72 | // AppendEntries RPC. The given server's disk agrees with this server's log up 73 | // through the given index. 74 | func (c *commitment) match(server ServerID, matchIndex uint64) { 75 | c.Lock() 76 | defer c.Unlock() 77 | if prev, hasVote := c.matchIndexes[server]; hasVote && matchIndex > prev { 78 | c.matchIndexes[server] = matchIndex 79 | c.recalculate() 80 | } 81 | } 82 | 83 | // Internal helper to calculate new commitIndex from matchIndexes. 84 | // Must be called with lock held. 85 | func (c *commitment) recalculate() { 86 | if len(c.matchIndexes) == 0 { 87 | return 88 | } 89 | 90 | matched := make([]uint64, 0, len(c.matchIndexes)) 91 | for _, idx := range c.matchIndexes { 92 | matched = append(matched, idx) 93 | } 94 | sort.Sort(uint64Slice(matched)) 95 | quorumMatchIndex := matched[(len(matched)-1)/2] 96 | 97 | if quorumMatchIndex > c.commitIndex && quorumMatchIndex >= c.startIndex { 98 | c.commitIndex = quorumMatchIndex 99 | asyncNotifyCh(c.commitCh) 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-hclog/stacktrace.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package hclog 22 | 23 | import ( 24 | "bytes" 25 | "runtime" 26 | "strconv" 27 | "strings" 28 | "sync" 29 | ) 30 | 31 | var ( 32 | _stacktraceIgnorePrefixes = []string{ 33 | "runtime.goexit", 34 | "runtime.main", 35 | } 36 | _stacktracePool = sync.Pool{ 37 | New: func() interface{} { 38 | return newProgramCounters(64) 39 | }, 40 | } 41 | ) 42 | 43 | // CapturedStacktrace represents a stacktrace captured by a previous call 44 | // to log.Stacktrace. If passed to a logging function, the stacktrace 45 | // will be appended. 46 | type CapturedStacktrace string 47 | 48 | // Stacktrace captures a stacktrace of the current goroutine and returns 49 | // it to be passed to a logging function. 50 | func Stacktrace() CapturedStacktrace { 51 | return CapturedStacktrace(takeStacktrace()) 52 | } 53 | 54 | func takeStacktrace() string { 55 | programCounters := _stacktracePool.Get().(*programCounters) 56 | defer _stacktracePool.Put(programCounters) 57 | 58 | var buffer bytes.Buffer 59 | 60 | for { 61 | // Skip the call to runtime.Counters and takeStacktrace so that the 62 | // program counters start at the caller of takeStacktrace. 63 | n := runtime.Callers(2, programCounters.pcs) 64 | if n < cap(programCounters.pcs) { 65 | programCounters.pcs = programCounters.pcs[:n] 66 | break 67 | } 68 | // Don't put the too-short counter slice back into the pool; this lets 69 | // the pool adjust if we consistently take deep stacktraces. 70 | programCounters = newProgramCounters(len(programCounters.pcs) * 2) 71 | } 72 | 73 | i := 0 74 | frames := runtime.CallersFrames(programCounters.pcs) 75 | for frame, more := frames.Next(); more; frame, more = frames.Next() { 76 | if shouldIgnoreStacktraceFunction(frame.Function) { 77 | continue 78 | } 79 | if i != 0 { 80 | buffer.WriteByte('\n') 81 | } 82 | i++ 83 | buffer.WriteString(frame.Function) 84 | buffer.WriteByte('\n') 85 | buffer.WriteByte('\t') 86 | buffer.WriteString(frame.File) 87 | buffer.WriteByte(':') 88 | buffer.WriteString(strconv.Itoa(int(frame.Line))) 89 | } 90 | 91 | return buffer.String() 92 | } 93 | 94 | func shouldIgnoreStacktraceFunction(function string) bool { 95 | for _, prefix := range _stacktraceIgnorePrefixes { 96 | if strings.HasPrefix(function, prefix) { 97 | return true 98 | } 99 | } 100 | return false 101 | } 102 | 103 | type programCounters struct { 104 | pcs []uintptr 105 | } 106 | 107 | func newProgramCounters(size int) *programCounters { 108 | return &programCounters{make([]uintptr, size)} 109 | } 110 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/raft/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 1.1.2 (January 17th, 2020) 2 | 3 | FEATURES 4 | 5 | * Improve FSM apply performance through batching. Implementing the `BatchingFSM` interface enables this new feature [[GH-364](https://github.com/hashicorp/raft/pull/364)] 6 | * Add ability to obtain Raft configuration before Raft starts with GetConfiguration [[GH-369](https://github.com/hashicorp/raft/pull/369)] 7 | 8 | IMPROVEMENTS 9 | 10 | * Remove lint violations and add a `make` rule for running the linter. 11 | * Replace logger with hclog [[GH-360](https://github.com/hashicorp/raft/pull/360)] 12 | * Read latest configuration independently from main loop [[GH-379](https://github.com/hashicorp/raft/pull/379)] 13 | 14 | BUG FIXES 15 | 16 | * Export the leader field in LeaderObservation [[GH-357](https://github.com/hashicorp/raft/pull/357)] 17 | * Fix snapshot to not attempt to truncate a negative range [[GH-358](https://github.com/hashicorp/raft/pull/358)] 18 | * Check for shutdown in inmemPipeline before sending RPCs [[GH-276](https://github.com/hashicorp/raft/pull/276)] 19 | 20 | # 1.1.1 (July 23rd, 2019) 21 | 22 | FEATURES 23 | 24 | * Add support for extensions to be sent on log entries [[GH-353](https://github.com/hashicorp/raft/pull/353)] 25 | * Add config option to skip snapshot restore on startup [[GH-340](https://github.com/hashicorp/raft/pull/340)] 26 | * Add optional configuration store interface [[GH-339](https://github.com/hashicorp/raft/pull/339)] 27 | 28 | IMPROVEMENTS 29 | 30 | * Break out of group commit early when no logs are present [[GH-341](https://github.com/hashicorp/raft/pull/341)] 31 | 32 | BUGFIXES 33 | 34 | * Fix 64-bit counters on 32-bit platforms [[GH-344](https://github.com/hashicorp/raft/pull/344)] 35 | * Don't defer closing source in recover/restore operations since it's in a loop [[GH-337](https://github.com/hashicorp/raft/pull/337)] 36 | 37 | # 1.1.0 (May 23rd, 2019) 38 | 39 | FEATURES 40 | 41 | * Add transfer leadership extension [[GH-306](https://github.com/hashicorp/raft/pull/306)] 42 | 43 | IMPROVEMENTS 44 | 45 | * Move to `go mod` [[GH-323](https://github.com/hashicorp/consul/pull/323)] 46 | * Leveled log [[GH-321](https://github.com/hashicorp/consul/pull/321)] 47 | * Add peer changes to observations [[GH-326](https://github.com/hashicorp/consul/pull/326)] 48 | 49 | BUGFIXES 50 | 51 | * Copy the contents of an InmemSnapshotStore when opening a snapshot [[GH-270](https://github.com/hashicorp/consul/pull/270)] 52 | * Fix logging panic when converting parameters to strings [[GH-332](https://github.com/hashicorp/consul/pull/332)] 53 | 54 | # 1.0.1 (April 12th, 2019) 55 | 56 | IMPROVEMENTS 57 | 58 | * InMemTransport: Add timeout for sending a message [[GH-313](https://github.com/hashicorp/raft/pull/313)] 59 | * ensure 'make deps' downloads test dependencies like testify [[GH-310](https://github.com/hashicorp/raft/pull/310)] 60 | * Clarifies function of CommitTimeout [[GH-309](https://github.com/hashicorp/raft/pull/309)] 61 | * Add additional metrics regarding log dispatching and committal [[GH-316](https://github.com/hashicorp/raft/pull/316)] 62 | 63 | # 1.0.0 (October 3rd, 2017) 64 | 65 | v1.0.0 takes the changes that were staged in the library-v2-stage-one branch. This version manages server identities using a UUID, so introduces some breaking API changes. It also versions the Raft protocol, and requires some special steps when interoperating with Raft servers running older versions of the library (see the detailed comment in config.go about version compatibility). You can reference https://github.com/hashicorp/consul/pull/2222 for an idea of what was required to port Consul to these new interfaces. 66 | 67 | # 0.1.0 (September 29th, 2017) 68 | 69 | v0.1.0 is the original stable version of the library that was in master and has been maintained with no breaking API changes. This was in use by Consul prior to version 0.7.0. 70 | --------------------------------------------------------------------------------