├── .gitignore
├── go
├── vendor
│ ├── github.com
│ │ ├── spf13
│ │ │ ├── cobra
│ │ │ │ ├── command_notwin.go
│ │ │ │ └── command_win.go
│ │ │ └── pflag
│ │ │ │ ├── LICENSE
│ │ │ │ ├── int.go
│ │ │ │ └── count.go
│ │ ├── rcrowley
│ │ │ └── go-metrics
│ │ │ │ ├── runtime_no_cgo.go
│ │ │ │ ├── runtime_cgo.go
│ │ │ │ ├── runtime_no_gccpufraction.go
│ │ │ │ ├── runtime_gccpufraction.go
│ │ │ │ ├── validate.sh
│ │ │ │ ├── metrics.go
│ │ │ │ ├── LICENSE
│ │ │ │ ├── healthcheck.go
│ │ │ │ ├── syslog.go
│ │ │ │ ├── json.go
│ │ │ │ ├── debug.go
│ │ │ │ └── counter.go
│ │ ├── Sirupsen
│ │ │ └── logrus
│ │ │ │ ├── terminal_appengine.go
│ │ │ │ ├── terminal_bsd.go
│ │ │ │ ├── terminal_solaris.go
│ │ │ │ ├── terminal_linux.go
│ │ │ │ ├── doc.go
│ │ │ │ ├── terminal_notwindows.go
│ │ │ │ ├── terminal_windows.go
│ │ │ │ ├── LICENSE
│ │ │ │ ├── hooks.go
│ │ │ │ ├── writer.go
│ │ │ │ ├── formatter.go
│ │ │ │ ├── CHANGELOG.md
│ │ │ │ ├── json_formatter.go
│ │ │ │ └── alt_exit.go
│ │ ├── Shopify
│ │ │ └── sarama
│ │ │ │ ├── dev.yml
│ │ │ │ ├── Makefile
│ │ │ │ ├── list_groups_request.go
│ │ │ │ ├── response_header.go
│ │ │ │ ├── api_versions_request.go
│ │ │ │ ├── Vagrantfile
│ │ │ │ ├── consumer_metadata_request.go
│ │ │ │ ├── heartbeat_response.go
│ │ │ │ ├── leave_group_response.go
│ │ │ │ ├── sasl_handshake_request.go
│ │ │ │ ├── describe_groups_request.go
│ │ │ │ ├── length_field.go
│ │ │ │ ├── leave_group_request.go
│ │ │ │ ├── sasl_handshake_response.go
│ │ │ │ ├── crc32_field.go
│ │ │ │ ├── heartbeat_request.go
│ │ │ │ ├── sync_group_response.go
│ │ │ │ ├── metadata_request.go
│ │ │ │ ├── MIT-LICENSE
│ │ │ │ ├── list_groups_response.go
│ │ │ │ ├── packet_decoder.go
│ │ │ │ ├── packet_encoder.go
│ │ │ │ ├── api_versions_response.go
│ │ │ │ ├── README.md
│ │ │ │ ├── offset_fetch_request.go
│ │ │ │ ├── offset_commit_response.go
│ │ │ │ ├── consumer_group_members.go
│ │ │ │ ├── message_set.go
│ │ │ │ ├── consumer_metadata_response.go
│ │ │ │ ├── encoder_decoder.go
│ │ │ │ ├── metrics.go
│ │ │ │ ├── sync_group_request.go
│ │ │ │ ├── join_group_request.go
│ │ │ │ ├── join_group_response.go
│ │ │ │ ├── prep_encoder.go
│ │ │ │ ├── real_encoder.go
│ │ │ │ └── request.go
│ │ ├── golang
│ │ │ └── snappy
│ │ │ │ ├── decode_amd64.go
│ │ │ │ ├── AUTHORS
│ │ │ │ ├── encode_amd64.go
│ │ │ │ ├── CONTRIBUTORS
│ │ │ │ └── LICENSE
│ │ ├── eapache
│ │ │ ├── go-xerial-snappy
│ │ │ │ ├── README.md
│ │ │ │ ├── snappy.go
│ │ │ │ └── LICENSE
│ │ │ ├── queue
│ │ │ │ ├── README.md
│ │ │ │ ├── LICENSE
│ │ │ │ └── queue.go
│ │ │ └── go-resiliency
│ │ │ │ ├── LICENSE
│ │ │ │ └── breaker
│ │ │ │ └── README.md
│ │ ├── davecgh
│ │ │ └── go-spew
│ │ │ │ ├── LICENSE
│ │ │ │ └── spew
│ │ │ │ └── bypasssafe.go
│ │ ├── klauspost
│ │ │ └── crc32
│ │ │ │ ├── crc32_generic.go
│ │ │ │ ├── crc32_amd64p32.go
│ │ │ │ ├── crc32_amd64p32.s
│ │ │ │ ├── LICENSE
│ │ │ │ └── crc32_amd64.go
│ │ └── pierrec
│ │ │ ├── lz4
│ │ │ ├── README.md
│ │ │ └── LICENSE
│ │ │ └── xxHash
│ │ │ └── LICENSE
│ └── gopkg.in
│ │ ├── bsm
│ │ └── sarama-cluster.v2
│ │ │ ├── glide.yaml
│ │ │ ├── doc.go
│ │ │ ├── client.go
│ │ │ ├── Makefile
│ │ │ ├── cluster.go
│ │ │ ├── README.md
│ │ │ └── glide.lock
│ │ └── Shopify
│ │ └── sarama.v1
│ │ ├── dev.yml
│ │ ├── Makefile
│ │ ├── response_header.go
│ │ ├── Vagrantfile
│ │ ├── list_groups_request.go
│ │ ├── api_versions_request.go
│ │ ├── consumer_metadata_request.go
│ │ ├── heartbeat_response.go
│ │ ├── leave_group_response.go
│ │ ├── sasl_handshake_request.go
│ │ ├── describe_groups_request.go
│ │ ├── length_field.go
│ │ ├── leave_group_request.go
│ │ ├── sasl_handshake_response.go
│ │ ├── crc32_field.go
│ │ ├── heartbeat_request.go
│ │ ├── sync_group_response.go
│ │ ├── metadata_request.go
│ │ ├── MIT-LICENSE
│ │ ├── list_groups_response.go
│ │ ├── packet_encoder.go
│ │ ├── packet_decoder.go
│ │ ├── api_versions_response.go
│ │ ├── README.md
│ │ ├── offset_fetch_request.go
│ │ ├── offset_commit_response.go
│ │ ├── consumer_group_members.go
│ │ ├── encoder_decoder.go
│ │ ├── message_set.go
│ │ ├── consumer_metadata_response.go
│ │ ├── prep_encoder.go
│ │ ├── sync_group_request.go
│ │ ├── join_group_request.go
│ │ ├── real_encoder.go
│ │ ├── join_group_response.go
│ │ ├── request.go
│ │ └── offset_request.go
├── Dockerfile
├── package.sh
├── Makefile
├── produce.go
├── consume.go
└── main.go
├── python
├── Dockerfile
└── Makefile
├── java
├── jaas.conf.example
├── src
│ └── main
│ │ ├── resources
│ │ └── logback.xml
│ │ └── java
│ │ └── ovh
│ │ └── queue
│ │ ├── Command.java
│ │ ├── Main.java
│ │ ├── Produce.java
│ │ └── Consume.java
├── Makefile
└── pom.xml
├── nodejs
├── package.json
└── Makefile
├── kafkacat
├── Dockerfile
└── Makefile
└── .travis.yml
/.gitignore:
--------------------------------------------------------------------------------
1 | go/kafka-client*
2 | go/bin
3 |
4 | nodejs/node_modules
5 |
6 | java/target
7 | java/jaas.conf
8 |
9 | .env
10 |
--------------------------------------------------------------------------------
/go/vendor/github.com/spf13/cobra/command_notwin.go:
--------------------------------------------------------------------------------
1 | // +build !windows
2 |
3 | package cobra
4 |
5 | var preExecHookFn func(*Command) = nil
6 |
--------------------------------------------------------------------------------
/go/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM alpine:3.4
2 |
3 | RUN apk --no-cache add ca-certificates
4 |
5 | COPY kafka-client /kafka-client
6 |
7 | ENTRYPOINT ["/kafka-client"]
--------------------------------------------------------------------------------
/go/vendor/github.com/rcrowley/go-metrics/runtime_no_cgo.go:
--------------------------------------------------------------------------------
1 | // +build !cgo appengine
2 |
3 | package metrics
4 |
5 | func numCgoCall() int64 {
6 | return 0
7 | }
8 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/bsm/sarama-cluster.v2/glide.yaml:
--------------------------------------------------------------------------------
1 | package: github.com/bsm/sarama-cluster
2 | import:
3 | - package: github.com/Shopify/sarama
4 | version: ^1.9.0
5 |
--------------------------------------------------------------------------------
/python/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM alpine:3.4
2 |
3 | RUN apk --no-cache add python py-pip
4 |
5 | WORKDIR /ovh-kafka
6 |
7 | RUN pip install kafka-python==1.3.1
8 |
9 | COPY . /ovh-kafka
10 |
11 | ENTRYPOINT ["python", "client.py"]
--------------------------------------------------------------------------------
/go/vendor/github.com/Sirupsen/logrus/terminal_appengine.go:
--------------------------------------------------------------------------------
1 | // +build appengine
2 |
3 | package logrus
4 |
5 | // IsTerminal returns true if stderr's file descriptor is a terminal.
6 | func IsTerminal() bool {
7 | return true
8 | }
9 |
--------------------------------------------------------------------------------
/go/vendor/github.com/rcrowley/go-metrics/runtime_cgo.go:
--------------------------------------------------------------------------------
1 | // +build cgo
2 | // +build !appengine
3 |
4 | package metrics
5 |
6 | import "runtime"
7 |
8 | func numCgoCall() int64 {
9 | return runtime.NumCgoCall()
10 | }
11 |
--------------------------------------------------------------------------------
/go/vendor/github.com/rcrowley/go-metrics/runtime_no_gccpufraction.go:
--------------------------------------------------------------------------------
1 | // +build !go1.5
2 |
3 | package metrics
4 |
5 | import "runtime"
6 |
7 | func gcCPUFraction(memStats *runtime.MemStats) float64 {
8 | return 0
9 | }
10 |
--------------------------------------------------------------------------------
/go/vendor/github.com/rcrowley/go-metrics/runtime_gccpufraction.go:
--------------------------------------------------------------------------------
1 | // +build go1.5
2 |
3 | package metrics
4 |
5 | import "runtime"
6 |
7 | func gcCPUFraction(memStats *runtime.MemStats) float64 {
8 | return memStats.GCCPUFraction
9 | }
10 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/dev.yml:
--------------------------------------------------------------------------------
1 | name: sarama
2 |
3 | up:
4 | - go: 1.7.3
5 |
6 | commands:
7 | test:
8 | run: make test
9 | desc: 'run unit tests'
10 |
11 | packages:
12 | - git@github.com:Shopify/dev-shopify.git
13 |
14 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/dev.yml:
--------------------------------------------------------------------------------
1 | name: sarama
2 |
3 | up:
4 | - go: 1.6.2
5 |
6 | commands:
7 | test:
8 | run: make test
9 | desc: 'run unit tests'
10 |
11 | packages:
12 | - git@github.com:Shopify/dev-shopify.git
13 |
14 |
--------------------------------------------------------------------------------
/java/jaas.conf.example:
--------------------------------------------------------------------------------
1 | KafkaClient {
2 | org.apache.kafka.common.security.plain.PlainLoginModule required
3 | // SASL username, prefixed by your namespace (eg. --username=myns.user)
4 | username="$USERNAME"
5 | // SASL password
6 | password="$PASSWORD";
7 | };
--------------------------------------------------------------------------------
/go/vendor/github.com/Sirupsen/logrus/terminal_bsd.go:
--------------------------------------------------------------------------------
1 | // +build darwin freebsd openbsd netbsd dragonfly
2 | // +build !appengine
3 |
4 | package logrus
5 |
6 | import "syscall"
7 |
8 | const ioctlReadTermios = syscall.TIOCGETA
9 |
10 | type Termios syscall.Termios
11 |
--------------------------------------------------------------------------------
/go/vendor/github.com/rcrowley/go-metrics/validate.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -e
4 |
5 | # check there are no formatting issues
6 | GOFMT_LINES=`gofmt -l . | wc -l | xargs`
7 | test $GOFMT_LINES -eq 0 || echo "gofmt needs to be run, ${GOFMT_LINES} files have issues"
8 |
9 | # run the tests for the root package
10 | go test .
11 |
--------------------------------------------------------------------------------
/nodejs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "kafka-client",
3 | "version": "0.1.0",
4 | "description": "Node.js Kafka client to produce/consume using SASL/SSL",
5 | "main": "client.js",
6 | "dependencies" : {
7 | "node-rdkafka" : "0.6.1",
8 | "cliparse" : "0.2.5"
9 | },
10 | "author": "",
11 | "license": "ISC"
12 | }
13 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/bsm/sarama-cluster.v2/doc.go:
--------------------------------------------------------------------------------
1 | /*
2 | Package cluster provides cluster extensions for Sarama, enabing users
3 | to consume topics across from multiple, balanced nodes.
4 |
5 | It requires Kafka v0.9+ and follows the steps guide, described in:
6 | https://cwiki.apache.org/confluence/display/KAFKA/Kafka+0.9+Consumer+Rewrite+Design
7 | */
8 | package cluster
9 |
--------------------------------------------------------------------------------
/java/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Sirupsen/logrus/terminal_solaris.go:
--------------------------------------------------------------------------------
1 | // +build solaris,!appengine
2 |
3 | package logrus
4 |
5 | import (
6 | "os"
7 |
8 | "golang.org/x/sys/unix"
9 | )
10 |
11 | // IsTerminal returns true if the given file descriptor is a terminal.
12 | func IsTerminal() bool {
13 | _, err := unix.IoctlGetTermios(int(os.Stdout.Fd()), unix.TCGETA)
14 | return err == nil
15 | }
16 |
--------------------------------------------------------------------------------
/java/src/main/java/ovh/queue/Command.java:
--------------------------------------------------------------------------------
1 | package ovh.queue;
2 |
3 | import com.beust.jcommander.Parameter;
4 |
5 | abstract class Command {
6 | @Parameter(names="--broker", description="Kafka broker address", required=true)
7 | public String broker;
8 |
9 | @Parameter(names="--topic", description="Topic, prefixed by your namespace (eg. --topic=myns.topic)", required=true)
10 | public String topic;
11 | }
12 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Sirupsen/logrus/terminal_linux.go:
--------------------------------------------------------------------------------
1 | // Based on ssh/terminal:
2 | // Copyright 2013 The Go Authors. All rights reserved.
3 | // Use of this source code is governed by a BSD-style
4 | // license that can be found in the LICENSE file.
5 |
6 | // +build !appengine
7 |
8 | package logrus
9 |
10 | import "syscall"
11 |
12 | const ioctlReadTermios = syscall.TCGETS
13 |
14 | type Termios syscall.Termios
15 |
--------------------------------------------------------------------------------
/nodejs/Makefile:
--------------------------------------------------------------------------------
1 |
2 | node-install-deps:
3 | npm install
4 |
5 | produce:
6 | node client.js produce \
7 | --broker ${HOST}:9093 \
8 | --username ${SASL_USERNAME} --password ${SASL_PASSWORD} \
9 | --topic ${TOPIC}
10 |
11 | consume:
12 | node client.js consume \
13 | --broker ${HOST}:9093 \
14 | --username ${SASL_USERNAME} --password ${SASL_PASSWORD} \
15 | --topic ${TOPIC} --consumer-group ${SASL_USERNAME}.group-node
16 |
--------------------------------------------------------------------------------
/go/package.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | OS="darwin linux windows"
4 | ARCH="amd64"
5 |
6 | for GOOS in $OS; do
7 | for GOARCH in $ARCH; do
8 | OS="$(tr '[:lower:]' '[:upper:]' <<< ${GOOS:0:1})${GOOS:1}"
9 | architecture="${OS}-${GOARCH}"
10 | echo "Building ${architecture}"
11 | export GOOS=$GOOS
12 | export GOARCH=$GOARCH
13 |
14 | go get
15 | go build -o bin/kafka-client-${architecture}
16 | done
17 | done
18 |
--------------------------------------------------------------------------------
/go/vendor/github.com/golang/snappy/decode_amd64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Snappy-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 !appengine
6 | // +build gc
7 | // +build !noasm
8 |
9 | package snappy
10 |
11 | // decode has the same semantics as in decode_other.go.
12 | //
13 | //go:noescape
14 | func decode(dst, src []byte) int
15 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/Makefile:
--------------------------------------------------------------------------------
1 | default: fmt vet errcheck test
2 |
3 | test:
4 | go test -v -timeout 60s -race ./...
5 |
6 | vet:
7 | go vet ./...
8 |
9 | errcheck:
10 | errcheck github.com/Shopify/sarama/...
11 |
12 | fmt:
13 | @if [ -n "$$(go fmt ./...)" ]; then echo 'Please run go fmt on your code.' && exit 1; fi
14 |
15 | install_dependencies: install_errcheck get
16 |
17 | install_errcheck:
18 | go get github.com/kisielk/errcheck
19 |
20 | get:
21 | go get -t
22 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/Makefile:
--------------------------------------------------------------------------------
1 | default: fmt vet errcheck test
2 |
3 | test:
4 | go test -v -timeout 60s -race ./...
5 |
6 | vet:
7 | go vet ./...
8 |
9 | errcheck:
10 | errcheck github.com/Shopify/sarama/...
11 |
12 | fmt:
13 | @if [ -n "$$(go fmt ./...)" ]; then echo 'Please run go fmt on your code.' && exit 1; fi
14 |
15 | install_dependencies: install_errcheck get
16 |
17 | install_errcheck:
18 | go get github.com/kisielk/errcheck
19 |
20 | get:
21 | go get -t
22 |
--------------------------------------------------------------------------------
/go/vendor/github.com/rcrowley/go-metrics/metrics.go:
--------------------------------------------------------------------------------
1 | // Go port of Coda Hale's Metrics library
2 | //
3 | //
4 | //
5 | // Coda Hale's original work:
6 | package metrics
7 |
8 | // UseNilMetrics is checked by the constructor functions for all of the
9 | // standard metrics. If it is true, the metric returned is a stub.
10 | //
11 | // This global kill-switch helps quantify the observer effect and makes
12 | // for less cluttered pprof profiles.
13 | var UseNilMetrics bool = false
14 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/list_groups_request.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type ListGroupsRequest struct {
4 | }
5 |
6 | func (r *ListGroupsRequest) encode(pe packetEncoder) error {
7 | return nil
8 | }
9 |
10 | func (r *ListGroupsRequest) decode(pd packetDecoder, version int16) (err error) {
11 | return nil
12 | }
13 |
14 | func (r *ListGroupsRequest) key() int16 {
15 | return 16
16 | }
17 |
18 | func (r *ListGroupsRequest) version() int16 {
19 | return 0
20 | }
21 |
22 | func (r *ListGroupsRequest) requiredVersion() KafkaVersion {
23 | return V0_9_0_0
24 | }
25 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/response_header.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | import "fmt"
4 |
5 | type responseHeader struct {
6 | length int32
7 | correlationID int32
8 | }
9 |
10 | func (r *responseHeader) decode(pd packetDecoder) (err error) {
11 | r.length, err = pd.getInt32()
12 | if err != nil {
13 | return err
14 | }
15 | if r.length <= 4 || r.length > MaxResponseSize {
16 | return PacketDecodingError{fmt.Sprintf("message of length %d too large or too small", r.length)}
17 | }
18 |
19 | r.correlationID, err = pd.getInt32()
20 | return err
21 | }
22 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/response_header.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | import "fmt"
4 |
5 | type responseHeader struct {
6 | length int32
7 | correlationID int32
8 | }
9 |
10 | func (r *responseHeader) decode(pd packetDecoder) (err error) {
11 | r.length, err = pd.getInt32()
12 | if err != nil {
13 | return err
14 | }
15 | if r.length <= 4 || r.length > MaxResponseSize {
16 | return PacketDecodingError{fmt.Sprintf("message of length %d too large or too small", r.length)}
17 | }
18 |
19 | r.correlationID, err = pd.getInt32()
20 | return err
21 | }
22 |
--------------------------------------------------------------------------------
/go/vendor/github.com/golang/snappy/AUTHORS:
--------------------------------------------------------------------------------
1 | # This is the official list of Snappy-Go authors for copyright purposes.
2 | # This file is distinct from the CONTRIBUTORS files.
3 | # See the latter for an explanation.
4 |
5 | # Names should be added to this file as
6 | # Name or Organization
7 | # The email address is not required for organizations.
8 |
9 | # Please keep the list sorted.
10 |
11 | Damian Gryski
12 | Google Inc.
13 | Jan Mercl <0xjnml@gmail.com>
14 | Rodolfo Carvalho
15 | Sebastien Binet
16 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/Vagrantfile:
--------------------------------------------------------------------------------
1 | # -*- mode: ruby -*-
2 | # vi: set ft=ruby :
3 |
4 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
5 | VAGRANTFILE_API_VERSION = "2"
6 |
7 | MEMORY = 3072
8 |
9 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
10 | config.vm.box = "ubuntu/trusty64"
11 |
12 | config.vm.provision :shell, path: "vagrant/provision.sh"
13 |
14 | config.vm.network "private_network", ip: "192.168.100.67"
15 |
16 | config.vm.provider "virtualbox" do |v|
17 | v.memory = MEMORY
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/list_groups_request.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type ListGroupsRequest struct {
4 | }
5 |
6 | func (r *ListGroupsRequest) encode(pe packetEncoder) error {
7 | return nil
8 | }
9 |
10 | func (r *ListGroupsRequest) decode(pd packetDecoder, version int16) (err error) {
11 | return nil
12 | }
13 |
14 | func (r *ListGroupsRequest) key() int16 {
15 | return 16
16 | }
17 |
18 | func (r *ListGroupsRequest) version() int16 {
19 | return 0
20 | }
21 |
22 | func (r *ListGroupsRequest) requiredVersion() KafkaVersion {
23 | return V0_9_0_0
24 | }
25 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/api_versions_request.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type ApiVersionsRequest struct {
4 | }
5 |
6 | func (r *ApiVersionsRequest) encode(pe packetEncoder) error {
7 | return nil
8 | }
9 |
10 | func (r *ApiVersionsRequest) decode(pd packetDecoder, version int16) (err error) {
11 | return nil
12 | }
13 |
14 | func (r *ApiVersionsRequest) key() int16 {
15 | return 18
16 | }
17 |
18 | func (r *ApiVersionsRequest) version() int16 {
19 | return 0
20 | }
21 |
22 | func (r *ApiVersionsRequest) requiredVersion() KafkaVersion {
23 | return V0_10_0_0
24 | }
25 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/api_versions_request.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type ApiVersionsRequest struct {
4 | }
5 |
6 | func (r *ApiVersionsRequest) encode(pe packetEncoder) error {
7 | return nil
8 | }
9 |
10 | func (r *ApiVersionsRequest) decode(pd packetDecoder, version int16) (err error) {
11 | return nil
12 | }
13 |
14 | func (r *ApiVersionsRequest) key() int16 {
15 | return 18
16 | }
17 |
18 | func (r *ApiVersionsRequest) version() int16 {
19 | return 0
20 | }
21 |
22 | func (r *ApiVersionsRequest) requiredVersion() KafkaVersion {
23 | return V0_10_0_0
24 | }
25 |
--------------------------------------------------------------------------------
/java/Makefile:
--------------------------------------------------------------------------------
1 |
2 | compile:
3 | mvn compile
4 |
5 | package:
6 | mvn package
7 |
8 | produce:
9 | java \
10 | -cp target/kafka-example-jar-with-dependencies.jar \
11 | -Djava.security.auth.login.config=jaas.conf \
12 | ovh.queue.Main produce \
13 | --broker ${HOST}:9093 \
14 | --topic ${TOPIC} \
15 |
16 | consume:
17 | java \
18 | -cp target/kafka-example-jar-with-dependencies.jar \
19 | -Djava.security.auth.login.config=jaas.conf \
20 | ovh.queue.Main consume \
21 | --broker ${HOST}:9093 \
22 | --topic ${TOPIC} \
23 | --consumer-group ${SASL_USERNAME}.java
24 |
--------------------------------------------------------------------------------
/go/vendor/github.com/eapache/go-xerial-snappy/README.md:
--------------------------------------------------------------------------------
1 | # go-xerial-snappy
2 |
3 | [](https://travis-ci.org/eapache/go-xerial-snappy)
4 |
5 | Xerial-compatible Snappy framing support for golang.
6 |
7 | Packages using Xerial for snappy encoding use a framing format incompatible with
8 | basically everything else in existence. This package wraps Go's built-in snappy
9 | package to support it.
10 |
11 | Apps that use this format include Apache Kafka (see
12 | https://github.com/dpkp/kafka-python/issues/126#issuecomment-35478921 for
13 | details).
14 |
--------------------------------------------------------------------------------
/go/vendor/github.com/spf13/cobra/command_win.go:
--------------------------------------------------------------------------------
1 | // +build windows
2 |
3 | package cobra
4 |
5 | import (
6 | "os"
7 | "time"
8 |
9 | "github.com/inconshreveable/mousetrap"
10 | )
11 |
12 | var preExecHookFn = preExecHook
13 |
14 | // enables an information splash screen on Windows if the CLI is started from explorer.exe.
15 | var MousetrapHelpText string = `This is a command line tool
16 |
17 | You need to open cmd.exe and run it from there.
18 | `
19 |
20 | func preExecHook(c *Command) {
21 | if mousetrap.StartedByExplorer() {
22 | c.Print(MousetrapHelpText)
23 | time.Sleep(5 * time.Second)
24 | os.Exit(1)
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/Vagrantfile:
--------------------------------------------------------------------------------
1 | # -*- mode: ruby -*-
2 | # vi: set ft=ruby :
3 |
4 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
5 | VAGRANTFILE_API_VERSION = "2"
6 |
7 | # We have 5 * 192MB ZK processes and 5 * 320MB Kafka processes => 2560MB
8 | MEMORY = 3072
9 |
10 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
11 | config.vm.box = "ubuntu/trusty64"
12 |
13 | config.vm.provision :shell, path: "vagrant/provision.sh"
14 |
15 | config.vm.network "private_network", ip: "192.168.100.67"
16 |
17 | config.vm.provider "virtualbox" do |v|
18 | v.memory = MEMORY
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/bsm/sarama-cluster.v2/client.go:
--------------------------------------------------------------------------------
1 | package cluster
2 |
3 | import "github.com/Shopify/sarama"
4 |
5 | // Client is a group client
6 | type Client struct {
7 | sarama.Client
8 | config Config
9 | own bool
10 | }
11 |
12 | // NewClient creates a new client instance
13 | func NewClient(addrs []string, config *Config) (*Client, error) {
14 | if config == nil {
15 | config = NewConfig()
16 | }
17 |
18 | if err := config.Validate(); err != nil {
19 | return nil, err
20 | }
21 |
22 | client, err := sarama.NewClient(addrs, &config.Config)
23 | if err != nil {
24 | return nil, err
25 | }
26 |
27 | return &Client{Client: client, config: *config}, nil
28 | }
29 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/consumer_metadata_request.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type ConsumerMetadataRequest struct {
4 | ConsumerGroup string
5 | }
6 |
7 | func (r *ConsumerMetadataRequest) encode(pe packetEncoder) error {
8 | return pe.putString(r.ConsumerGroup)
9 | }
10 |
11 | func (r *ConsumerMetadataRequest) decode(pd packetDecoder, version int16) (err error) {
12 | r.ConsumerGroup, err = pd.getString()
13 | return err
14 | }
15 |
16 | func (r *ConsumerMetadataRequest) key() int16 {
17 | return 10
18 | }
19 |
20 | func (r *ConsumerMetadataRequest) version() int16 {
21 | return 0
22 | }
23 |
24 | func (r *ConsumerMetadataRequest) requiredVersion() KafkaVersion {
25 | return V0_8_2_0
26 | }
27 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/consumer_metadata_request.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type ConsumerMetadataRequest struct {
4 | ConsumerGroup string
5 | }
6 |
7 | func (r *ConsumerMetadataRequest) encode(pe packetEncoder) error {
8 | return pe.putString(r.ConsumerGroup)
9 | }
10 |
11 | func (r *ConsumerMetadataRequest) decode(pd packetDecoder, version int16) (err error) {
12 | r.ConsumerGroup, err = pd.getString()
13 | return err
14 | }
15 |
16 | func (r *ConsumerMetadataRequest) key() int16 {
17 | return 10
18 | }
19 |
20 | func (r *ConsumerMetadataRequest) version() int16 {
21 | return 0
22 | }
23 |
24 | func (r *ConsumerMetadataRequest) requiredVersion() KafkaVersion {
25 | return V0_8_2_0
26 | }
27 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Sirupsen/logrus/doc.go:
--------------------------------------------------------------------------------
1 | /*
2 | Package logrus is a structured logger for Go, completely API compatible with the standard library logger.
3 |
4 |
5 | The simplest way to use Logrus is simply the package-level exported logger:
6 |
7 | package main
8 |
9 | import (
10 | log "github.com/Sirupsen/logrus"
11 | )
12 |
13 | func main() {
14 | log.WithFields(log.Fields{
15 | "animal": "walrus",
16 | "number": 1,
17 | "size": 10,
18 | }).Info("A walrus appears")
19 | }
20 |
21 | Output:
22 | time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10
23 |
24 | For a full guide visit https://github.com/Sirupsen/logrus
25 | */
26 | package logrus
27 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/heartbeat_response.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type HeartbeatResponse struct {
4 | Err KError
5 | }
6 |
7 | func (r *HeartbeatResponse) encode(pe packetEncoder) error {
8 | pe.putInt16(int16(r.Err))
9 | return nil
10 | }
11 |
12 | func (r *HeartbeatResponse) decode(pd packetDecoder, version int16) error {
13 | if kerr, err := pd.getInt16(); err != nil {
14 | return err
15 | } else {
16 | r.Err = KError(kerr)
17 | }
18 |
19 | return nil
20 | }
21 |
22 | func (r *HeartbeatResponse) key() int16 {
23 | return 12
24 | }
25 |
26 | func (r *HeartbeatResponse) version() int16 {
27 | return 0
28 | }
29 |
30 | func (r *HeartbeatResponse) requiredVersion() KafkaVersion {
31 | return V0_9_0_0
32 | }
33 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Sirupsen/logrus/terminal_notwindows.go:
--------------------------------------------------------------------------------
1 | // Based on ssh/terminal:
2 | // Copyright 2011 The Go Authors. All rights reserved.
3 | // Use of this source code is governed by a BSD-style
4 | // license that can be found in the LICENSE file.
5 |
6 | // +build linux darwin freebsd openbsd netbsd dragonfly
7 | // +build !appengine
8 |
9 | package logrus
10 |
11 | import (
12 | "syscall"
13 | "unsafe"
14 | )
15 |
16 | // IsTerminal returns true if stderr's file descriptor is a terminal.
17 | func IsTerminal() bool {
18 | fd := syscall.Stderr
19 | var termios Termios
20 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
21 | return err == 0
22 | }
23 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/heartbeat_response.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type HeartbeatResponse struct {
4 | Err KError
5 | }
6 |
7 | func (r *HeartbeatResponse) encode(pe packetEncoder) error {
8 | pe.putInt16(int16(r.Err))
9 | return nil
10 | }
11 |
12 | func (r *HeartbeatResponse) decode(pd packetDecoder, version int16) error {
13 | if kerr, err := pd.getInt16(); err != nil {
14 | return err
15 | } else {
16 | r.Err = KError(kerr)
17 | }
18 |
19 | return nil
20 | }
21 |
22 | func (r *HeartbeatResponse) key() int16 {
23 | return 12
24 | }
25 |
26 | func (r *HeartbeatResponse) version() int16 {
27 | return 0
28 | }
29 |
30 | func (r *HeartbeatResponse) requiredVersion() KafkaVersion {
31 | return V0_9_0_0
32 | }
33 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/leave_group_response.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type LeaveGroupResponse struct {
4 | Err KError
5 | }
6 |
7 | func (r *LeaveGroupResponse) encode(pe packetEncoder) error {
8 | pe.putInt16(int16(r.Err))
9 | return nil
10 | }
11 |
12 | func (r *LeaveGroupResponse) decode(pd packetDecoder, version int16) (err error) {
13 | if kerr, err := pd.getInt16(); err != nil {
14 | return err
15 | } else {
16 | r.Err = KError(kerr)
17 | }
18 |
19 | return nil
20 | }
21 |
22 | func (r *LeaveGroupResponse) key() int16 {
23 | return 13
24 | }
25 |
26 | func (r *LeaveGroupResponse) version() int16 {
27 | return 0
28 | }
29 |
30 | func (r *LeaveGroupResponse) requiredVersion() KafkaVersion {
31 | return V0_9_0_0
32 | }
33 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/leave_group_response.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type LeaveGroupResponse struct {
4 | Err KError
5 | }
6 |
7 | func (r *LeaveGroupResponse) encode(pe packetEncoder) error {
8 | pe.putInt16(int16(r.Err))
9 | return nil
10 | }
11 |
12 | func (r *LeaveGroupResponse) decode(pd packetDecoder, version int16) (err error) {
13 | if kerr, err := pd.getInt16(); err != nil {
14 | return err
15 | } else {
16 | r.Err = KError(kerr)
17 | }
18 |
19 | return nil
20 | }
21 |
22 | func (r *LeaveGroupResponse) key() int16 {
23 | return 13
24 | }
25 |
26 | func (r *LeaveGroupResponse) version() int16 {
27 | return 0
28 | }
29 |
30 | func (r *LeaveGroupResponse) requiredVersion() KafkaVersion {
31 | return V0_9_0_0
32 | }
33 |
--------------------------------------------------------------------------------
/kafkacat/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu:xenial
2 |
3 | RUN apt-get update && apt-get install -y \
4 | build-essential python curl git openssl \
5 | zlib1g-dev libssl-dev libsasl2-dev
6 |
7 | RUN git clone https://github.com/edenhill/librdkafka
8 | RUN cd librdkafka && \
9 | git checkout tags/v0.9.2 && \
10 | ./configure && \
11 | echo '' >> config.h && \
12 | echo '#define WITH_SSL 1' >> config.h && \
13 | echo '#define WITH_SASL 1' >> config.h && \
14 | make && \
15 | make install
16 |
17 | RUN git clone https://github.com/edenhill/kafkacat
18 | RUN cd kafkacat && \
19 | git checkout tags/1.3.0 && \
20 | ./configure && \
21 | make && \
22 | make install
23 |
24 | ENV LD_LIBRARY_PATH /usr/local/lib
25 | ENTRYPOINT ["kafkacat"]
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/sasl_handshake_request.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type SaslHandshakeRequest struct {
4 | Mechanism string
5 | }
6 |
7 | func (r *SaslHandshakeRequest) encode(pe packetEncoder) error {
8 | if err := pe.putString(r.Mechanism); err != nil {
9 | return err
10 | }
11 |
12 | return nil
13 | }
14 |
15 | func (r *SaslHandshakeRequest) decode(pd packetDecoder, version int16) (err error) {
16 | if r.Mechanism, err = pd.getString(); err != nil {
17 | return err
18 | }
19 |
20 | return nil
21 | }
22 |
23 | func (r *SaslHandshakeRequest) key() int16 {
24 | return 17
25 | }
26 |
27 | func (r *SaslHandshakeRequest) version() int16 {
28 | return 0
29 | }
30 |
31 | func (r *SaslHandshakeRequest) requiredVersion() KafkaVersion {
32 | return V0_10_0_0
33 | }
34 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/sasl_handshake_request.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type SaslHandshakeRequest struct {
4 | Mechanism string
5 | }
6 |
7 | func (r *SaslHandshakeRequest) encode(pe packetEncoder) error {
8 | if err := pe.putString(r.Mechanism); err != nil {
9 | return err
10 | }
11 |
12 | return nil
13 | }
14 |
15 | func (r *SaslHandshakeRequest) decode(pd packetDecoder, version int16) (err error) {
16 | if r.Mechanism, err = pd.getString(); err != nil {
17 | return err
18 | }
19 |
20 | return nil
21 | }
22 |
23 | func (r *SaslHandshakeRequest) key() int16 {
24 | return 17
25 | }
26 |
27 | func (r *SaslHandshakeRequest) version() int16 {
28 | return 0
29 | }
30 |
31 | func (r *SaslHandshakeRequest) requiredVersion() KafkaVersion {
32 | return V0_10_0_0
33 | }
34 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/describe_groups_request.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type DescribeGroupsRequest struct {
4 | Groups []string
5 | }
6 |
7 | func (r *DescribeGroupsRequest) encode(pe packetEncoder) error {
8 | return pe.putStringArray(r.Groups)
9 | }
10 |
11 | func (r *DescribeGroupsRequest) decode(pd packetDecoder, version int16) (err error) {
12 | r.Groups, err = pd.getStringArray()
13 | return
14 | }
15 |
16 | func (r *DescribeGroupsRequest) key() int16 {
17 | return 15
18 | }
19 |
20 | func (r *DescribeGroupsRequest) version() int16 {
21 | return 0
22 | }
23 |
24 | func (r *DescribeGroupsRequest) requiredVersion() KafkaVersion {
25 | return V0_9_0_0
26 | }
27 |
28 | func (r *DescribeGroupsRequest) AddGroup(group string) {
29 | r.Groups = append(r.Groups, group)
30 | }
31 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/describe_groups_request.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type DescribeGroupsRequest struct {
4 | Groups []string
5 | }
6 |
7 | func (r *DescribeGroupsRequest) encode(pe packetEncoder) error {
8 | return pe.putStringArray(r.Groups)
9 | }
10 |
11 | func (r *DescribeGroupsRequest) decode(pd packetDecoder, version int16) (err error) {
12 | r.Groups, err = pd.getStringArray()
13 | return
14 | }
15 |
16 | func (r *DescribeGroupsRequest) key() int16 {
17 | return 15
18 | }
19 |
20 | func (r *DescribeGroupsRequest) version() int16 {
21 | return 0
22 | }
23 |
24 | func (r *DescribeGroupsRequest) requiredVersion() KafkaVersion {
25 | return V0_9_0_0
26 | }
27 |
28 | func (r *DescribeGroupsRequest) AddGroup(group string) {
29 | r.Groups = append(r.Groups, group)
30 | }
31 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Sirupsen/logrus/terminal_windows.go:
--------------------------------------------------------------------------------
1 | // Based on ssh/terminal:
2 | // Copyright 2011 The Go Authors. All rights reserved.
3 | // Use of this source code is governed by a BSD-style
4 | // license that can be found in the LICENSE file.
5 |
6 | // +build windows,!appengine
7 |
8 | package logrus
9 |
10 | import (
11 | "syscall"
12 | "unsafe"
13 | )
14 |
15 | var kernel32 = syscall.NewLazyDLL("kernel32.dll")
16 |
17 | var (
18 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
19 | )
20 |
21 | // IsTerminal returns true if stderr's file descriptor is a terminal.
22 | func IsTerminal() bool {
23 | fd := syscall.Stderr
24 | var st uint32
25 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0)
26 | return r != 0 && e == 0
27 | }
28 |
--------------------------------------------------------------------------------
/python/Makefile:
--------------------------------------------------------------------------------
1 |
2 | python-install-deps:
3 | pip install --upgrade kafka-python==1.3.1
4 |
5 | produce:
6 | python client.py produce \
7 | --broker ${HOST}:9093 \
8 | --username ${SASL_USERNAME} --password ${SASL_PASSWORD} \
9 | --topic ${TOPIC}
10 |
11 | consume:
12 | python client.py consume \
13 | --broker ${HOST}:9093 \
14 | --username ${SASL_USERNAME} --password ${SASL_PASSWORD} \
15 | --topic ${TOPIC} --consumer-group ${SASL_USERNAME}.group-python
16 |
17 | ##
18 |
19 | build-docker:
20 | docker build -t ovhqueue/py-client-example .
21 |
22 | consume-in-docker:
23 | docker run --rm -ti ovhqueue/py-client-example \
24 | consume --broker ${HOST}:9093 \
25 | --username ${SASL_USERNAME} --password ${SASL_PASSWORD} \
26 | --topic ${TOPIC} --consumer-group ${SASL_USERNAME}.group-dpy
27 |
--------------------------------------------------------------------------------
/kafkacat/Makefile:
--------------------------------------------------------------------------------
1 |
2 | build:
3 | docker build -t ovhqueue/kafkacat .
4 |
5 | produce:
6 | docker run --rm -ti ovhqueue/kafkacat \
7 | -b ${HOST}:9093 \
8 | -X ssl.ca.location=/etc/ssl/certs \
9 | -X security.protocol=SASL_SSL \
10 | -X api.version.request=true \
11 | -X sasl.mechanisms=PLAIN \
12 | -X sasl.username=${SASL_USERNAME} \
13 | -X sasl.password=${SASL_PASSWORD} \
14 | -t ${TOPIC} \
15 | -P
16 |
17 | consume:
18 | docker run --rm -ti ovhqueue/kafkacat \
19 | -b ${HOST}:9093 \
20 | -X ssl.ca.location=/etc/ssl/certs \
21 | -X security.protocol=SASL_SSL \
22 | -X api.version.request=true \
23 | -X sasl.mechanisms=PLAIN \
24 | -X sasl.username=${SASL_USERNAME} \
25 | -X sasl.password=${SASL_PASSWORD} \
26 | -t ${TOPIC} \
27 | -G ${SASL_USERNAME}.group-kafkacat \
28 | -C
29 |
--------------------------------------------------------------------------------
/go/vendor/github.com/davecgh/go-spew/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2012-2013 Dave Collins
2 |
3 | Permission to use, copy, modify, and distribute this software for any
4 | purpose with or without fee is hereby granted, provided that the above
5 | copyright notice and this permission notice appear in all copies.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 |
--------------------------------------------------------------------------------
/java/src/main/java/ovh/queue/Main.java:
--------------------------------------------------------------------------------
1 | package ovh.queue;
2 |
3 | import com.beust.jcommander.JCommander;
4 | import ovh.queue.Produce;
5 | import ovh.queue.Consume;
6 |
7 | public class Main {
8 |
9 | public static void main(String []args) {
10 |
11 | JCommander commander = new JCommander();
12 | Produce producer = new Produce();
13 | Consume consumer = new Consume();
14 |
15 | commander.addCommand(Produce.NAME, producer);
16 | commander.addCommand(Consume.NAME, consumer);
17 | commander.parse(args);
18 |
19 | String command = commander.getParsedCommand();
20 |
21 | if (command == null) {
22 | commander.usage();
23 | } else if (command.equals(Produce.NAME)) {
24 | producer.run();
25 | } else if (command.equals(Consume.NAME)) {
26 | consumer.run();
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/length_field.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | import "encoding/binary"
4 |
5 | // LengthField implements the PushEncoder and PushDecoder interfaces for calculating 4-byte lengths.
6 | type lengthField struct {
7 | startOffset int
8 | }
9 |
10 | func (l *lengthField) saveOffset(in int) {
11 | l.startOffset = in
12 | }
13 |
14 | func (l *lengthField) reserveLength() int {
15 | return 4
16 | }
17 |
18 | func (l *lengthField) run(curOffset int, buf []byte) error {
19 | binary.BigEndian.PutUint32(buf[l.startOffset:], uint32(curOffset-l.startOffset-4))
20 | return nil
21 | }
22 |
23 | func (l *lengthField) check(curOffset int, buf []byte) error {
24 | if uint32(curOffset-l.startOffset-4) != binary.BigEndian.Uint32(buf[l.startOffset:]) {
25 | return PacketDecodingError{"length field invalid"}
26 | }
27 |
28 | return nil
29 | }
30 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/length_field.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | import "encoding/binary"
4 |
5 | // LengthField implements the PushEncoder and PushDecoder interfaces for calculating 4-byte lengths.
6 | type lengthField struct {
7 | startOffset int
8 | }
9 |
10 | func (l *lengthField) saveOffset(in int) {
11 | l.startOffset = in
12 | }
13 |
14 | func (l *lengthField) reserveLength() int {
15 | return 4
16 | }
17 |
18 | func (l *lengthField) run(curOffset int, buf []byte) error {
19 | binary.BigEndian.PutUint32(buf[l.startOffset:], uint32(curOffset-l.startOffset-4))
20 | return nil
21 | }
22 |
23 | func (l *lengthField) check(curOffset int, buf []byte) error {
24 | if uint32(curOffset-l.startOffset-4) != binary.BigEndian.Uint32(buf[l.startOffset:]) {
25 | return PacketDecodingError{"length field invalid"}
26 | }
27 |
28 | return nil
29 | }
30 |
--------------------------------------------------------------------------------
/go/vendor/github.com/golang/snappy/encode_amd64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Snappy-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 !appengine
6 | // +build gc
7 | // +build !noasm
8 |
9 | package snappy
10 |
11 | // emitLiteral has the same semantics as in encode_other.go.
12 | //
13 | //go:noescape
14 | func emitLiteral(dst, lit []byte) int
15 |
16 | // emitCopy has the same semantics as in encode_other.go.
17 | //
18 | //go:noescape
19 | func emitCopy(dst []byte, offset, length int) int
20 |
21 | // extendMatch has the same semantics as in encode_other.go.
22 | //
23 | //go:noescape
24 | func extendMatch(src []byte, i, j int) int
25 |
26 | // encodeBlock has the same semantics as in encode_other.go.
27 | //
28 | //go:noescape
29 | func encodeBlock(dst, src []byte) (d int)
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/leave_group_request.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type LeaveGroupRequest struct {
4 | GroupId string
5 | MemberId string
6 | }
7 |
8 | func (r *LeaveGroupRequest) encode(pe packetEncoder) error {
9 | if err := pe.putString(r.GroupId); err != nil {
10 | return err
11 | }
12 | if err := pe.putString(r.MemberId); err != nil {
13 | return err
14 | }
15 |
16 | return nil
17 | }
18 |
19 | func (r *LeaveGroupRequest) decode(pd packetDecoder, version int16) (err error) {
20 | if r.GroupId, err = pd.getString(); err != nil {
21 | return
22 | }
23 | if r.MemberId, err = pd.getString(); err != nil {
24 | return
25 | }
26 |
27 | return nil
28 | }
29 |
30 | func (r *LeaveGroupRequest) key() int16 {
31 | return 13
32 | }
33 |
34 | func (r *LeaveGroupRequest) version() int16 {
35 | return 0
36 | }
37 |
38 | func (r *LeaveGroupRequest) requiredVersion() KafkaVersion {
39 | return V0_9_0_0
40 | }
41 |
--------------------------------------------------------------------------------
/go/vendor/github.com/eapache/queue/README.md:
--------------------------------------------------------------------------------
1 | Queue
2 | =====
3 |
4 | [](https://travis-ci.org/eapache/queue)
5 | [](https://godoc.org/github.com/eapache/queue)
6 | [](https://eapache.github.io/conduct.html)
7 |
8 | A fast Golang queue using a ring-buffer, based on the version suggested by Dariusz Górecki.
9 | Using this instead of other, simpler, queue implementations (slice+append or linked list) provides
10 | substantial memory and time benefits, and fewer GC pauses.
11 |
12 | The queue implemented here is as fast as it is in part because it is *not* thread-safe.
13 |
14 | Follows semantic versioning using https://gopkg.in/ - import from
15 | [`gopkg.in/eapache/queue.v1`](https://gopkg.in/eapache/queue.v1)
16 | for guaranteed API stability.
17 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/leave_group_request.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type LeaveGroupRequest struct {
4 | GroupId string
5 | MemberId string
6 | }
7 |
8 | func (r *LeaveGroupRequest) encode(pe packetEncoder) error {
9 | if err := pe.putString(r.GroupId); err != nil {
10 | return err
11 | }
12 | if err := pe.putString(r.MemberId); err != nil {
13 | return err
14 | }
15 |
16 | return nil
17 | }
18 |
19 | func (r *LeaveGroupRequest) decode(pd packetDecoder, version int16) (err error) {
20 | if r.GroupId, err = pd.getString(); err != nil {
21 | return
22 | }
23 | if r.MemberId, err = pd.getString(); err != nil {
24 | return
25 | }
26 |
27 | return nil
28 | }
29 |
30 | func (r *LeaveGroupRequest) key() int16 {
31 | return 13
32 | }
33 |
34 | func (r *LeaveGroupRequest) version() int16 {
35 | return 0
36 | }
37 |
38 | func (r *LeaveGroupRequest) requiredVersion() KafkaVersion {
39 | return V0_9_0_0
40 | }
41 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/bsm/sarama-cluster.v2/Makefile:
--------------------------------------------------------------------------------
1 | SCALA_VERSION?= 2.11
2 | KAFKA_VERSION?= 0.10.0.0
3 | KAFKA_DIR= kafka_$(SCALA_VERSION)-$(KAFKA_VERSION)
4 | KAFKA_SRC= http://www.mirrorservice.org/sites/ftp.apache.org/kafka/$(KAFKA_VERSION)/$(KAFKA_DIR).tgz
5 | KAFKA_ROOT= testdata/$(KAFKA_DIR)
6 |
7 | PKG:=$(shell glide nv)
8 |
9 | default: vet test
10 |
11 | vet:
12 | go vet $(PKG)
13 |
14 | test: testdeps
15 | KAFKA_DIR=$(KAFKA_DIR) go test $(PKG) -ginkgo.slowSpecThreshold=60
16 |
17 | test-verbose: testdeps
18 | KAFKA_DIR=$(KAFKA_DIR) go test $(PKG) -ginkgo.slowSpecThreshold=60 -v
19 |
20 | test-race: testdeps
21 | KAFKA_DIR=$(KAFKA_DIR) go test $(PKG) -ginkgo.slowSpecThreshold=60 -v -race
22 |
23 | testdeps: $(KAFKA_ROOT)
24 |
25 | .PHONY: test testdeps vet
26 |
27 | # ---------------------------------------------------------------------
28 |
29 | $(KAFKA_ROOT):
30 | @mkdir -p $(dir $@)
31 | cd $(dir $@) && curl $(KAFKA_SRC) | tar xz
32 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/sasl_handshake_response.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type SaslHandshakeResponse struct {
4 | Err KError
5 | EnabledMechanisms []string
6 | }
7 |
8 | func (r *SaslHandshakeResponse) encode(pe packetEncoder) error {
9 | pe.putInt16(int16(r.Err))
10 | return pe.putStringArray(r.EnabledMechanisms)
11 | }
12 |
13 | func (r *SaslHandshakeResponse) decode(pd packetDecoder, version int16) error {
14 | if kerr, err := pd.getInt16(); err != nil {
15 | return err
16 | } else {
17 | r.Err = KError(kerr)
18 | }
19 |
20 | var err error
21 | if r.EnabledMechanisms, err = pd.getStringArray(); err != nil {
22 | return err
23 | }
24 |
25 | return nil
26 | }
27 |
28 | func (r *SaslHandshakeResponse) key() int16 {
29 | return 17
30 | }
31 |
32 | func (r *SaslHandshakeResponse) version() int16 {
33 | return 0
34 | }
35 |
36 | func (r *SaslHandshakeResponse) requiredVersion() KafkaVersion {
37 | return V0_10_0_0
38 | }
39 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/sasl_handshake_response.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type SaslHandshakeResponse struct {
4 | Err KError
5 | EnabledMechanisms []string
6 | }
7 |
8 | func (r *SaslHandshakeResponse) encode(pe packetEncoder) error {
9 | pe.putInt16(int16(r.Err))
10 | return pe.putStringArray(r.EnabledMechanisms)
11 | }
12 |
13 | func (r *SaslHandshakeResponse) decode(pd packetDecoder, version int16) error {
14 | if kerr, err := pd.getInt16(); err != nil {
15 | return err
16 | } else {
17 | r.Err = KError(kerr)
18 | }
19 |
20 | var err error
21 | if r.EnabledMechanisms, err = pd.getStringArray(); err != nil {
22 | return err
23 | }
24 |
25 | return nil
26 | }
27 |
28 | func (r *SaslHandshakeResponse) key() int16 {
29 | return 17
30 | }
31 |
32 | func (r *SaslHandshakeResponse) version() int16 {
33 | return 0
34 | }
35 |
36 | func (r *SaslHandshakeResponse) requiredVersion() KafkaVersion {
37 | return V0_10_0_0
38 | }
39 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/crc32_field.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | import (
4 | "encoding/binary"
5 |
6 | "github.com/klauspost/crc32"
7 | )
8 |
9 | // crc32Field implements the pushEncoder and pushDecoder interfaces for calculating CRC32s.
10 | type crc32Field struct {
11 | startOffset int
12 | }
13 |
14 | func (c *crc32Field) saveOffset(in int) {
15 | c.startOffset = in
16 | }
17 |
18 | func (c *crc32Field) reserveLength() int {
19 | return 4
20 | }
21 |
22 | func (c *crc32Field) run(curOffset int, buf []byte) error {
23 | crc := crc32.ChecksumIEEE(buf[c.startOffset+4 : curOffset])
24 | binary.BigEndian.PutUint32(buf[c.startOffset:], crc)
25 | return nil
26 | }
27 |
28 | func (c *crc32Field) check(curOffset int, buf []byte) error {
29 | crc := crc32.ChecksumIEEE(buf[c.startOffset+4 : curOffset])
30 |
31 | if crc != binary.BigEndian.Uint32(buf[c.startOffset:]) {
32 | return PacketDecodingError{"CRC didn't match"}
33 | }
34 |
35 | return nil
36 | }
37 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/crc32_field.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | import (
4 | "encoding/binary"
5 |
6 | "github.com/klauspost/crc32"
7 | )
8 |
9 | // crc32Field implements the pushEncoder and pushDecoder interfaces for calculating CRC32s.
10 | type crc32Field struct {
11 | startOffset int
12 | }
13 |
14 | func (c *crc32Field) saveOffset(in int) {
15 | c.startOffset = in
16 | }
17 |
18 | func (c *crc32Field) reserveLength() int {
19 | return 4
20 | }
21 |
22 | func (c *crc32Field) run(curOffset int, buf []byte) error {
23 | crc := crc32.ChecksumIEEE(buf[c.startOffset+4 : curOffset])
24 | binary.BigEndian.PutUint32(buf[c.startOffset:], crc)
25 | return nil
26 | }
27 |
28 | func (c *crc32Field) check(curOffset int, buf []byte) error {
29 | crc := crc32.ChecksumIEEE(buf[c.startOffset+4 : curOffset])
30 |
31 | if crc != binary.BigEndian.Uint32(buf[c.startOffset:]) {
32 | return PacketDecodingError{"CRC didn't match"}
33 | }
34 |
35 | return nil
36 | }
37 |
--------------------------------------------------------------------------------
/go/vendor/github.com/klauspost/crc32/crc32_generic.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 | // +build !amd64,!amd64p32 appengine gccgo
6 |
7 | package crc32
8 |
9 | // This file contains the generic version of updateCastagnoli which does
10 | // slicing-by-8, or uses the fallback for very small sizes.
11 |
12 | func updateCastagnoli(crc uint32, p []byte) uint32 {
13 | // only use slicing-by-8 when input is >= 16 Bytes
14 | if len(p) >= 16 {
15 | return updateSlicingBy8(crc, castagnoliTable8, p)
16 | }
17 | return update(crc, castagnoliTable, p)
18 | }
19 |
20 | func updateIEEE(crc uint32, p []byte) uint32 {
21 | // only use slicing-by-8 when input is >= 16 Bytes
22 | if len(p) >= 16 {
23 | ieeeTable8Once.Do(func() {
24 | ieeeTable8 = makeTable8(IEEE)
25 | })
26 | return updateSlicingBy8(crc, ieeeTable8, p)
27 | }
28 | return update(crc, IEEETable, p)
29 | }
30 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: go
2 | go:
3 | - 1.6
4 |
5 | install: true
6 | before_script: cd go
7 | script: make
8 |
9 | deploy:
10 | provider: releases
11 | skip_cleanup: true
12 | api_key:
13 | secure: fQKmahdH8ayPfG0yEZxYnhjAFKUda0vz5Wo9pARAwpwzpCmd3/90LfgtGLZkrhEzjvXG2pR+A05VwVdZELChj1bDG4suWQHzbWOpkEqmAmk3h+YDdYI/zhY/x4IyZnrOClrHQFfdv3DRV/mB307OFPeKLQjJ/yKjPSQ/SlTA9Z6c/zmsK1TpIUVn3jD/7BiFE6uSWoEE5OpSVC3mIW0Wi6txHlj63vYkQgA30cungpagjKRBDWik/Ek/xeXTxrMowDUtoixtHuzEi+YcpnY6IPRVoHcZNz5XrMeV8Mecfu9jjelWzfI6/nms23sIHS492E6HUeCa2cMeQzc7fCFnX85ghJ2/jBp9u6UCwingQ48139xYvj82bNDQ9PAHY49MhRDq4X2DL+ASXZvl8YMO9FVtHAnOxfDE34deBSJDQGh7nsulLpqoGzDIlx8GoGF24e16UrFrA7YO4hg2uZEs/J/akEPE1sqePHV3Gv/0o7JExyTmp4BVDEMvaPvQgfdEioLAAeGbp0oab0xHpWvy3pSwHCU2UeJRQCaiVz1Gx5aA3C62QVsmNzIumFqLqv1bUmDrmWjCkgR/KK67TtNEBqlCjd3d9T8yiEioUeQUOCqw3LB4favIkBQz5QP8UEgGtnMTKwpqZyE/EhFpu63Jpv3wDtxf0LYdXHQPN4pjOSQ=
14 | file:
15 | - bin/kafka-client-Darwin-amd64
16 | - bin/kafka-client-Linux-amd64
17 | - bin/kafka-client-Windows-amd64
18 | on:
19 | repo: runabove/queue-examples
20 | tags: true
21 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/heartbeat_request.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type HeartbeatRequest struct {
4 | GroupId string
5 | GenerationId int32
6 | MemberId string
7 | }
8 |
9 | func (r *HeartbeatRequest) encode(pe packetEncoder) error {
10 | if err := pe.putString(r.GroupId); err != nil {
11 | return err
12 | }
13 |
14 | pe.putInt32(r.GenerationId)
15 |
16 | if err := pe.putString(r.MemberId); err != nil {
17 | return err
18 | }
19 |
20 | return nil
21 | }
22 |
23 | func (r *HeartbeatRequest) decode(pd packetDecoder, version int16) (err error) {
24 | if r.GroupId, err = pd.getString(); err != nil {
25 | return
26 | }
27 | if r.GenerationId, err = pd.getInt32(); err != nil {
28 | return
29 | }
30 | if r.MemberId, err = pd.getString(); err != nil {
31 | return
32 | }
33 |
34 | return nil
35 | }
36 |
37 | func (r *HeartbeatRequest) key() int16 {
38 | return 12
39 | }
40 |
41 | func (r *HeartbeatRequest) version() int16 {
42 | return 0
43 | }
44 |
45 | func (r *HeartbeatRequest) requiredVersion() KafkaVersion {
46 | return V0_9_0_0
47 | }
48 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/heartbeat_request.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type HeartbeatRequest struct {
4 | GroupId string
5 | GenerationId int32
6 | MemberId string
7 | }
8 |
9 | func (r *HeartbeatRequest) encode(pe packetEncoder) error {
10 | if err := pe.putString(r.GroupId); err != nil {
11 | return err
12 | }
13 |
14 | pe.putInt32(r.GenerationId)
15 |
16 | if err := pe.putString(r.MemberId); err != nil {
17 | return err
18 | }
19 |
20 | return nil
21 | }
22 |
23 | func (r *HeartbeatRequest) decode(pd packetDecoder, version int16) (err error) {
24 | if r.GroupId, err = pd.getString(); err != nil {
25 | return
26 | }
27 | if r.GenerationId, err = pd.getInt32(); err != nil {
28 | return
29 | }
30 | if r.MemberId, err = pd.getString(); err != nil {
31 | return
32 | }
33 |
34 | return nil
35 | }
36 |
37 | func (r *HeartbeatRequest) key() int16 {
38 | return 12
39 | }
40 |
41 | func (r *HeartbeatRequest) version() int16 {
42 | return 0
43 | }
44 |
45 | func (r *HeartbeatRequest) requiredVersion() KafkaVersion {
46 | return V0_9_0_0
47 | }
48 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/sync_group_response.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type SyncGroupResponse struct {
4 | Err KError
5 | MemberAssignment []byte
6 | }
7 |
8 | func (r *SyncGroupResponse) GetMemberAssignment() (*ConsumerGroupMemberAssignment, error) {
9 | assignment := new(ConsumerGroupMemberAssignment)
10 | err := decode(r.MemberAssignment, assignment)
11 | return assignment, err
12 | }
13 |
14 | func (r *SyncGroupResponse) encode(pe packetEncoder) error {
15 | pe.putInt16(int16(r.Err))
16 | return pe.putBytes(r.MemberAssignment)
17 | }
18 |
19 | func (r *SyncGroupResponse) decode(pd packetDecoder, version int16) (err error) {
20 | if kerr, err := pd.getInt16(); err != nil {
21 | return err
22 | } else {
23 | r.Err = KError(kerr)
24 | }
25 |
26 | r.MemberAssignment, err = pd.getBytes()
27 | return
28 | }
29 |
30 | func (r *SyncGroupResponse) key() int16 {
31 | return 14
32 | }
33 |
34 | func (r *SyncGroupResponse) version() int16 {
35 | return 0
36 | }
37 |
38 | func (r *SyncGroupResponse) requiredVersion() KafkaVersion {
39 | return V0_9_0_0
40 | }
41 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/sync_group_response.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type SyncGroupResponse struct {
4 | Err KError
5 | MemberAssignment []byte
6 | }
7 |
8 | func (r *SyncGroupResponse) GetMemberAssignment() (*ConsumerGroupMemberAssignment, error) {
9 | assignment := new(ConsumerGroupMemberAssignment)
10 | err := decode(r.MemberAssignment, assignment)
11 | return assignment, err
12 | }
13 |
14 | func (r *SyncGroupResponse) encode(pe packetEncoder) error {
15 | pe.putInt16(int16(r.Err))
16 | return pe.putBytes(r.MemberAssignment)
17 | }
18 |
19 | func (r *SyncGroupResponse) decode(pd packetDecoder, version int16) (err error) {
20 | if kerr, err := pd.getInt16(); err != nil {
21 | return err
22 | } else {
23 | r.Err = KError(kerr)
24 | }
25 |
26 | r.MemberAssignment, err = pd.getBytes()
27 | return
28 | }
29 |
30 | func (r *SyncGroupResponse) key() int16 {
31 | return 14
32 | }
33 |
34 | func (r *SyncGroupResponse) version() int16 {
35 | return 0
36 | }
37 |
38 | func (r *SyncGroupResponse) requiredVersion() KafkaVersion {
39 | return V0_9_0_0
40 | }
41 |
--------------------------------------------------------------------------------
/go/vendor/github.com/eapache/go-xerial-snappy/snappy.go:
--------------------------------------------------------------------------------
1 | package snappy
2 |
3 | import (
4 | "bytes"
5 | "encoding/binary"
6 |
7 | master "github.com/golang/snappy"
8 | )
9 |
10 | var xerialHeader = []byte{130, 83, 78, 65, 80, 80, 89, 0}
11 |
12 | // Encode encodes data as snappy with no framing header.
13 | func Encode(src []byte) []byte {
14 | return master.Encode(nil, src)
15 | }
16 |
17 | // Decode decodes snappy data whether it is traditional unframed
18 | // or includes the xerial framing format.
19 | func Decode(src []byte) ([]byte, error) {
20 | if !bytes.Equal(src[:8], xerialHeader) {
21 | return master.Decode(nil, src)
22 | }
23 |
24 | var (
25 | pos = uint32(16)
26 | max = uint32(len(src))
27 | dst = make([]byte, 0, len(src))
28 | chunk []byte
29 | err error
30 | )
31 | for pos < max {
32 | size := binary.BigEndian.Uint32(src[pos : pos+4])
33 | pos += 4
34 |
35 | chunk, err = master.Decode(chunk, src[pos:pos+size])
36 | if err != nil {
37 | return nil, err
38 | }
39 | pos += size
40 | dst = append(dst, chunk...)
41 | }
42 | return dst, nil
43 | }
44 |
--------------------------------------------------------------------------------
/go/Makefile:
--------------------------------------------------------------------------------
1 |
2 | package:
3 | ./package.sh
4 |
5 | build:
6 | go build -o kafka-client
7 |
8 | consume:
9 | ./kafka-client consume \
10 | --broker ${HOST}:9093 \
11 | --username ${SASL_USERNAME} --password ${SASL_PASSWORD} \
12 | --topic ${TOPIC} --consumer-group ${SASL_USERNAME}.group-go
13 |
14 | produce:
15 | ./kafka-client produce \
16 | --broker ${HOST}:9093 \
17 | --username ${SASL_USERNAME} --password ${SASL_PASSWORD} \
18 | --topic ${TOPIC}
19 |
20 | ##
21 |
22 | build-binary-in-docker:
23 | docker run --rm \
24 | -e GOPATH=/go -e GOBIN=/go/bin/ -e CGO_ENABLED=0 \
25 | -v $$(pwd):/go/src/github.com/runabove/queue-examples/go \
26 | -w /go/src/github.com/runabove/queue-examples/go \
27 | golang:1.7.3 \
28 | go build -o kafka-client
29 |
30 | build-docker: build-binary-in-docker
31 | docker build -t ovhqueue/go-client-example .
32 |
33 | consume-in-docker:
34 | docker run --rm -ti ovhqueue/go-client-example \
35 | consume --broker ${HOST}:9093 \
36 | --username ${SASL_USERNAME} --password ${SASL_PASSWORD} \
37 | --topic ${TOPIC} --consumer-group ${SASL_USERNAME}.group-dgo
38 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/metadata_request.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type MetadataRequest struct {
4 | Topics []string
5 | }
6 |
7 | func (r *MetadataRequest) encode(pe packetEncoder) error {
8 | err := pe.putArrayLength(len(r.Topics))
9 | if err != nil {
10 | return err
11 | }
12 |
13 | for i := range r.Topics {
14 | err = pe.putString(r.Topics[i])
15 | if err != nil {
16 | return err
17 | }
18 | }
19 | return nil
20 | }
21 |
22 | func (r *MetadataRequest) decode(pd packetDecoder, version int16) error {
23 | topicCount, err := pd.getArrayLength()
24 | if err != nil {
25 | return err
26 | }
27 | if topicCount == 0 {
28 | return nil
29 | }
30 |
31 | r.Topics = make([]string, topicCount)
32 | for i := range r.Topics {
33 | topic, err := pd.getString()
34 | if err != nil {
35 | return err
36 | }
37 | r.Topics[i] = topic
38 | }
39 | return nil
40 | }
41 |
42 | func (r *MetadataRequest) key() int16 {
43 | return 3
44 | }
45 |
46 | func (r *MetadataRequest) version() int16 {
47 | return 0
48 | }
49 |
50 | func (r *MetadataRequest) requiredVersion() KafkaVersion {
51 | return minVersion
52 | }
53 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/metadata_request.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type MetadataRequest struct {
4 | Topics []string
5 | }
6 |
7 | func (r *MetadataRequest) encode(pe packetEncoder) error {
8 | err := pe.putArrayLength(len(r.Topics))
9 | if err != nil {
10 | return err
11 | }
12 |
13 | for i := range r.Topics {
14 | err = pe.putString(r.Topics[i])
15 | if err != nil {
16 | return err
17 | }
18 | }
19 | return nil
20 | }
21 |
22 | func (r *MetadataRequest) decode(pd packetDecoder, version int16) error {
23 | topicCount, err := pd.getArrayLength()
24 | if err != nil {
25 | return err
26 | }
27 | if topicCount == 0 {
28 | return nil
29 | }
30 |
31 | r.Topics = make([]string, topicCount)
32 | for i := range r.Topics {
33 | topic, err := pd.getString()
34 | if err != nil {
35 | return err
36 | }
37 | r.Topics[i] = topic
38 | }
39 | return nil
40 | }
41 |
42 | func (r *MetadataRequest) key() int16 {
43 | return 3
44 | }
45 |
46 | func (r *MetadataRequest) version() int16 {
47 | return 0
48 | }
49 |
50 | func (r *MetadataRequest) requiredVersion() KafkaVersion {
51 | return minVersion
52 | }
53 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/MIT-LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013 Evan Huus
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/MIT-LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013 Evan Huus
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/go/vendor/github.com/eapache/queue/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Evan Huus
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.
--------------------------------------------------------------------------------
/go/vendor/github.com/Sirupsen/logrus/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Simon Eskildsen
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/go/vendor/github.com/eapache/go-resiliency/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Evan Huus
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/go/vendor/github.com/eapache/go-xerial-snappy/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Evan Huus
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 |
--------------------------------------------------------------------------------
/go/vendor/github.com/klauspost/crc32/crc32_amd64p32.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 | // +build !appengine,!gccgo
6 |
7 | package crc32
8 |
9 | // This file contains the code to call the SSE 4.2 version of the Castagnoli
10 | // CRC.
11 |
12 | // haveSSE42 is defined in crc_amd64p32.s and uses CPUID to test for SSE 4.2
13 | // support.
14 | func haveSSE42() bool
15 |
16 | // castagnoliSSE42 is defined in crc_amd64.s and uses the SSE4.2 CRC32
17 | // instruction.
18 | //go:noescape
19 | func castagnoliSSE42(crc uint32, p []byte) uint32
20 |
21 | var sse42 = haveSSE42()
22 |
23 | func updateCastagnoli(crc uint32, p []byte) uint32 {
24 | if sse42 {
25 | return castagnoliSSE42(crc, p)
26 | }
27 | return update(crc, castagnoliTable, p)
28 | }
29 |
30 | func updateIEEE(crc uint32, p []byte) uint32 {
31 | // only use slicing-by-8 when input is >= 4KB
32 | if len(p) >= 4096 {
33 | ieeeTable8Once.Do(func() {
34 | ieeeTable8 = makeTable8(IEEE)
35 | })
36 | return updateSlicingBy8(crc, ieeeTable8, p)
37 | }
38 |
39 | return update(crc, IEEETable, p)
40 | }
41 |
--------------------------------------------------------------------------------
/go/vendor/github.com/eapache/go-resiliency/breaker/README.md:
--------------------------------------------------------------------------------
1 | circuit-breaker
2 | ===============
3 |
4 | [](https://travis-ci.org/eapache/go-resiliency)
5 | [](https://godoc.org/github.com/eapache/go-resiliency/breaker)
6 | [](https://eapache.github.io/conduct.html)
7 |
8 | The circuit-breaker resiliency pattern for golang.
9 |
10 | Creating a breaker takes three parameters:
11 | - error threshold (for opening the breaker)
12 | - success threshold (for closing the breaker)
13 | - timeout (how long to keep the breaker open)
14 |
15 | ```go
16 | b := breaker.New(3, 1, 5*time.Second)
17 |
18 | for {
19 | result := b.Run(func() error {
20 | // communicate with some external service and
21 | // return an error if the communication failed
22 | return nil
23 | })
24 |
25 | switch result {
26 | case nil:
27 | // success!
28 | case breaker.ErrBreakerOpen:
29 | // our function wasn't run because the breaker was open
30 | default:
31 | // some other error
32 | }
33 | }
34 | ```
35 |
--------------------------------------------------------------------------------
/go/produce.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "bufio"
5 | "fmt"
6 | "os"
7 | "strings"
8 |
9 | "github.com/Shopify/sarama"
10 | "github.com/spf13/cobra"
11 | )
12 |
13 | // Produce produces messages from stdin to Kafka
14 | func Produce(cmd *cobra.Command, args []string) {
15 |
16 | var config = sarama.NewConfig()
17 | config.Net.TLS.Enable = true
18 | config.Net.SASL.Enable = true
19 | config.Net.SASL.User = Username
20 | config.Net.SASL.Password = Password
21 | config.ClientID = Username
22 | config.Producer.Return.Successes = true
23 |
24 | var err error
25 | Producer, err = sarama.NewSyncProducer(strings.Split(BrokerAddrs, ","), config)
26 | HandleError(err)
27 |
28 | fmt.Println("Ready to produce messages. Write something to stdin...")
29 | stdin := bufio.NewScanner(os.Stdin)
30 | for stdin.Scan() {
31 | value := stdin.Text()
32 |
33 | msg := &sarama.ProducerMessage{Topic: Topic, Value: sarama.StringEncoder(value)}
34 |
35 | partition, offset, err := Producer.SendMessage(msg)
36 | if err != nil {
37 | fmt.Printf("Fail to send message: %s\n", err)
38 | continue
39 | }
40 |
41 | fmt.Printf("> Message '%s' sent to partition %d at offset %d\n", value, partition, offset)
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Sirupsen/logrus/hooks.go:
--------------------------------------------------------------------------------
1 | package logrus
2 |
3 | // A hook to be fired when logging on the logging levels returned from
4 | // `Levels()` on your implementation of the interface. Note that this is not
5 | // fired in a goroutine or a channel with workers, you should handle such
6 | // functionality yourself if your call is non-blocking and you don't wish for
7 | // the logging calls for levels returned from `Levels()` to block.
8 | type Hook interface {
9 | Levels() []Level
10 | Fire(*Entry) error
11 | }
12 |
13 | // Internal type for storing the hooks on a logger instance.
14 | type LevelHooks map[Level][]Hook
15 |
16 | // Add a hook to an instance of logger. This is called with
17 | // `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface.
18 | func (hooks LevelHooks) Add(hook Hook) {
19 | for _, level := range hook.Levels() {
20 | hooks[level] = append(hooks[level], hook)
21 | }
22 | }
23 |
24 | // Fire all the hooks for the passed level. Used by `entry.log` to fire
25 | // appropriate hooks for a log entry.
26 | func (hooks LevelHooks) Fire(level Level, entry *Entry) error {
27 | for _, hook := range hooks[level] {
28 | if err := hook.Fire(entry); err != nil {
29 | return err
30 | }
31 | }
32 |
33 | return nil
34 | }
35 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Sirupsen/logrus/writer.go:
--------------------------------------------------------------------------------
1 | package logrus
2 |
3 | import (
4 | "bufio"
5 | "io"
6 | "runtime"
7 | )
8 |
9 | func (logger *Logger) Writer() *io.PipeWriter {
10 | return logger.WriterLevel(InfoLevel)
11 | }
12 |
13 | func (logger *Logger) WriterLevel(level Level) *io.PipeWriter {
14 | reader, writer := io.Pipe()
15 |
16 | var printFunc func(args ...interface{})
17 | switch level {
18 | case DebugLevel:
19 | printFunc = logger.Debug
20 | case InfoLevel:
21 | printFunc = logger.Info
22 | case WarnLevel:
23 | printFunc = logger.Warn
24 | case ErrorLevel:
25 | printFunc = logger.Error
26 | case FatalLevel:
27 | printFunc = logger.Fatal
28 | case PanicLevel:
29 | printFunc = logger.Panic
30 | default:
31 | printFunc = logger.Print
32 | }
33 |
34 | go logger.writerScanner(reader, printFunc)
35 | runtime.SetFinalizer(writer, writerFinalizer)
36 |
37 | return writer
38 | }
39 |
40 | func (logger *Logger) writerScanner(reader *io.PipeReader, printFunc func(args ...interface{})) {
41 | scanner := bufio.NewScanner(reader)
42 | for scanner.Scan() {
43 | printFunc(scanner.Text())
44 | }
45 | if err := scanner.Err(); err != nil {
46 | logger.Errorf("Error while reading from Writer: %s", err)
47 | }
48 | reader.Close()
49 | }
50 |
51 | func writerFinalizer(writer *io.PipeWriter) {
52 | writer.Close()
53 | }
54 |
--------------------------------------------------------------------------------
/go/vendor/github.com/pierrec/lz4/README.md:
--------------------------------------------------------------------------------
1 | [](https://godoc.org/github.com/pierrec/lz4)
2 | [](https://travis-ci.org/pierrec/lz4)
3 |
4 | # lz4
5 | LZ4 compression and decompression in pure Go
6 |
7 | ## Usage
8 |
9 | ```go
10 | import "github.com/pierrec/lz4"
11 | ```
12 |
13 | ## Description
14 |
15 | Package lz4 implements reading and writing lz4 compressed data (a frame),
16 | as specified in http://fastcompression.blogspot.fr/2013/04/lz4-streaming-format-final.html,
17 | using an io.Reader (decompression) and io.Writer (compression).
18 | It is designed to minimize memory usage while maximizing throughput by being able to
19 | [de]compress data concurrently.
20 |
21 | The Reader and the Writer support concurrent processing provided the supplied buffers are
22 | large enough (in multiples of BlockMaxSize) and there is no block dependency.
23 | Reader.WriteTo and Writer.ReadFrom do leverage the concurrency transparently.
24 | The runtime.GOMAXPROCS() value is used to apply concurrency or not.
25 |
26 | Although the block level compression and decompression functions are exposed and are fully compatible
27 | with the lz4 block format definition, they are low level and should not be used directly.
28 | For a complete description of an lz4 compressed block, see:
29 | http://fastcompression.blogspot.fr/2011/05/lz4-explained.html
30 |
31 | See https://github.com/Cyan4973/lz4 for the reference C implementation.
32 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/list_groups_response.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type ListGroupsResponse struct {
4 | Err KError
5 | Groups map[string]string
6 | }
7 |
8 | func (r *ListGroupsResponse) encode(pe packetEncoder) error {
9 | pe.putInt16(int16(r.Err))
10 |
11 | if err := pe.putArrayLength(len(r.Groups)); err != nil {
12 | return err
13 | }
14 | for groupId, protocolType := range r.Groups {
15 | if err := pe.putString(groupId); err != nil {
16 | return err
17 | }
18 | if err := pe.putString(protocolType); err != nil {
19 | return err
20 | }
21 | }
22 |
23 | return nil
24 | }
25 |
26 | func (r *ListGroupsResponse) decode(pd packetDecoder, version int16) error {
27 | if kerr, err := pd.getInt16(); err != nil {
28 | return err
29 | } else {
30 | r.Err = KError(kerr)
31 | }
32 |
33 | n, err := pd.getArrayLength()
34 | if err != nil {
35 | return err
36 | }
37 | if n == 0 {
38 | return nil
39 | }
40 |
41 | r.Groups = make(map[string]string)
42 | for i := 0; i < n; i++ {
43 | groupId, err := pd.getString()
44 | if err != nil {
45 | return err
46 | }
47 | protocolType, err := pd.getString()
48 | if err != nil {
49 | return err
50 | }
51 |
52 | r.Groups[groupId] = protocolType
53 | }
54 |
55 | return nil
56 | }
57 |
58 | func (r *ListGroupsResponse) key() int16 {
59 | return 16
60 | }
61 |
62 | func (r *ListGroupsResponse) version() int16 {
63 | return 0
64 | }
65 |
66 | func (r *ListGroupsResponse) requiredVersion() KafkaVersion {
67 | return V0_9_0_0
68 | }
69 |
--------------------------------------------------------------------------------
/go/vendor/github.com/klauspost/crc32/crc32_amd64p32.s:
--------------------------------------------------------------------------------
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 | // +build gc
6 |
7 | #define NOSPLIT 4
8 | #define RODATA 8
9 |
10 | // func castagnoliSSE42(crc uint32, p []byte) uint32
11 | TEXT ·castagnoliSSE42(SB), NOSPLIT, $0
12 | MOVL crc+0(FP), AX // CRC value
13 | MOVL p+4(FP), SI // data pointer
14 | MOVL p_len+8(FP), CX // len(p)
15 |
16 | NOTL AX
17 |
18 | // If there's less than 8 bytes to process, we do it byte-by-byte.
19 | CMPQ CX, $8
20 | JL cleanup
21 |
22 | // Process individual bytes until the input is 8-byte aligned.
23 | startup:
24 | MOVQ SI, BX
25 | ANDQ $7, BX
26 | JZ aligned
27 |
28 | CRC32B (SI), AX
29 | DECQ CX
30 | INCQ SI
31 | JMP startup
32 |
33 | aligned:
34 | // The input is now 8-byte aligned and we can process 8-byte chunks.
35 | CMPQ CX, $8
36 | JL cleanup
37 |
38 | CRC32Q (SI), AX
39 | ADDQ $8, SI
40 | SUBQ $8, CX
41 | JMP aligned
42 |
43 | cleanup:
44 | // We may have some bytes left over that we process one at a time.
45 | CMPQ CX, $0
46 | JE done
47 |
48 | CRC32B (SI), AX
49 | INCQ SI
50 | DECQ CX
51 | JMP cleanup
52 |
53 | done:
54 | NOTL AX
55 | MOVL AX, ret+16(FP)
56 | RET
57 |
58 | // func haveSSE42() bool
59 | TEXT ·haveSSE42(SB), NOSPLIT, $0
60 | XORQ AX, AX
61 | INCL AX
62 | CPUID
63 | SHRQ $20, CX
64 | ANDQ $1, CX
65 | MOVB CX, ret+0(FP)
66 | RET
67 |
68 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/list_groups_response.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type ListGroupsResponse struct {
4 | Err KError
5 | Groups map[string]string
6 | }
7 |
8 | func (r *ListGroupsResponse) encode(pe packetEncoder) error {
9 | pe.putInt16(int16(r.Err))
10 |
11 | if err := pe.putArrayLength(len(r.Groups)); err != nil {
12 | return err
13 | }
14 | for groupId, protocolType := range r.Groups {
15 | if err := pe.putString(groupId); err != nil {
16 | return err
17 | }
18 | if err := pe.putString(protocolType); err != nil {
19 | return err
20 | }
21 | }
22 |
23 | return nil
24 | }
25 |
26 | func (r *ListGroupsResponse) decode(pd packetDecoder, version int16) error {
27 | if kerr, err := pd.getInt16(); err != nil {
28 | return err
29 | } else {
30 | r.Err = KError(kerr)
31 | }
32 |
33 | n, err := pd.getArrayLength()
34 | if err != nil {
35 | return err
36 | }
37 | if n == 0 {
38 | return nil
39 | }
40 |
41 | r.Groups = make(map[string]string)
42 | for i := 0; i < n; i++ {
43 | groupId, err := pd.getString()
44 | if err != nil {
45 | return err
46 | }
47 | protocolType, err := pd.getString()
48 | if err != nil {
49 | return err
50 | }
51 |
52 | r.Groups[groupId] = protocolType
53 | }
54 |
55 | return nil
56 | }
57 |
58 | func (r *ListGroupsResponse) key() int16 {
59 | return 16
60 | }
61 |
62 | func (r *ListGroupsResponse) version() int16 {
63 | return 0
64 | }
65 |
66 | func (r *ListGroupsResponse) requiredVersion() KafkaVersion {
67 | return V0_9_0_0
68 | }
69 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Sirupsen/logrus/formatter.go:
--------------------------------------------------------------------------------
1 | package logrus
2 |
3 | import "time"
4 |
5 | const DefaultTimestampFormat = time.RFC3339
6 |
7 | // The Formatter interface is used to implement a custom Formatter. It takes an
8 | // `Entry`. It exposes all the fields, including the default ones:
9 | //
10 | // * `entry.Data["msg"]`. The message passed from Info, Warn, Error ..
11 | // * `entry.Data["time"]`. The timestamp.
12 | // * `entry.Data["level"]. The level the entry was logged at.
13 | //
14 | // Any additional fields added with `WithField` or `WithFields` are also in
15 | // `entry.Data`. Format is expected to return an array of bytes which are then
16 | // logged to `logger.Out`.
17 | type Formatter interface {
18 | Format(*Entry) ([]byte, error)
19 | }
20 |
21 | // This is to not silently overwrite `time`, `msg` and `level` fields when
22 | // dumping it. If this code wasn't there doing:
23 | //
24 | // logrus.WithField("level", 1).Info("hello")
25 | //
26 | // Would just silently drop the user provided level. Instead with this code
27 | // it'll logged as:
28 | //
29 | // {"level": "info", "fields.level": 1, "msg": "hello", "time": "..."}
30 | //
31 | // It's not exported because it's still using Data in an opinionated way. It's to
32 | // avoid code duplication between the two default formatters.
33 | func prefixFieldClashes(data Fields) {
34 | if t, ok := data["time"]; ok {
35 | data["fields.time"] = t
36 | }
37 |
38 | if m, ok := data["msg"]; ok {
39 | data["fields.msg"] = m
40 | }
41 |
42 | if l, ok := data["level"]; ok {
43 | data["fields.level"] = l
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/go/vendor/github.com/golang/snappy/CONTRIBUTORS:
--------------------------------------------------------------------------------
1 | # This is the official list of people who can contribute
2 | # (and typically have contributed) code to the Snappy-Go repository.
3 | # The AUTHORS file lists the copyright holders; this file
4 | # lists people. For example, Google employees are listed here
5 | # but not in AUTHORS, because Google holds the copyright.
6 | #
7 | # The submission process automatically checks to make sure
8 | # that people submitting code are listed in this file (by email address).
9 | #
10 | # Names should be added to this file only after verifying that
11 | # the individual or the individual's organization has agreed to
12 | # the appropriate Contributor License Agreement, found here:
13 | #
14 | # http://code.google.com/legal/individual-cla-v1.0.html
15 | # http://code.google.com/legal/corporate-cla-v1.0.html
16 | #
17 | # The agreement for individuals can be filled out on the web.
18 | #
19 | # When adding J Random Contributor's name to this file,
20 | # either J's name or J's organization's name should be
21 | # added to the AUTHORS file, depending on whether the
22 | # individual or corporate CLA was used.
23 |
24 | # Names should be added to this file like so:
25 | # Name
26 |
27 | # Please keep the list sorted.
28 |
29 | Damian Gryski
30 | Jan Mercl <0xjnml@gmail.com>
31 | Kai Backman
32 | Marc-Antoine Ruel
33 | Nigel Tao
34 | Rob Pike
35 | Rodolfo Carvalho
36 | Russ Cox
37 | Sebastien Binet
38 |
--------------------------------------------------------------------------------
/go/vendor/github.com/pierrec/lz4/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2015, Pierre Curto
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 |
7 | * Redistributions of source code must retain the above copyright notice, this
8 | list of conditions and the following disclaimer.
9 |
10 | * Redistributions in binary form must reproduce the above copyright notice,
11 | this list of conditions and the following disclaimer in the documentation
12 | and/or other materials provided with the distribution.
13 |
14 | * Neither the name of xxHash nor the names of its
15 | contributors may be used to endorse or promote products derived from
16 | this software without specific prior written permission.
17 |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
29 |
--------------------------------------------------------------------------------
/go/vendor/github.com/pierrec/xxHash/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2014, Pierre Curto
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 |
7 | * Redistributions of source code must retain the above copyright notice, this
8 | list of conditions and the following disclaimer.
9 |
10 | * Redistributions in binary form must reproduce the above copyright notice,
11 | this list of conditions and the following disclaimer in the documentation
12 | and/or other materials provided with the distribution.
13 |
14 | * Neither the name of xxHash nor the names of its
15 | contributors may be used to endorse or promote products derived from
16 | this software without specific prior written permission.
17 |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
29 |
--------------------------------------------------------------------------------
/go/vendor/github.com/golang/snappy/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2011 The Snappy-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 |
--------------------------------------------------------------------------------
/go/vendor/github.com/klauspost/crc32/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2012 The Go Authors. All rights reserved.
2 | Copyright (c) 2015 Klaus Post
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are
6 | met:
7 |
8 | * Redistributions of source code must retain the above copyright
9 | notice, this list of conditions and the following disclaimer.
10 | * Redistributions in binary form must reproduce the above
11 | copyright notice, this list of conditions and the following disclaimer
12 | in the documentation and/or other materials provided with the
13 | distribution.
14 | * Neither the name of Google Inc. nor the names of its
15 | contributors may be used to endorse or promote products derived from
16 | this software without specific prior written permission.
17 |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
--------------------------------------------------------------------------------
/go/vendor/github.com/rcrowley/go-metrics/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2012 Richard Crowley. All rights reserved.
2 |
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions are
5 | met:
6 |
7 | 1. Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 |
10 | 2. Redistributions in binary form must reproduce the above
11 | copyright notice, this list of conditions and the following
12 | disclaimer in the documentation and/or other materials provided
13 | with the distribution.
14 |
15 | THIS SOFTWARE IS PROVIDED BY RICHARD CROWLEY ``AS IS'' AND ANY EXPRESS
16 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | DISCLAIMED. IN NO EVENT SHALL RICHARD CROWLEY OR CONTRIBUTORS BE LIABLE
19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
25 | THE POSSIBILITY OF SUCH DAMAGE.
26 |
27 | The views and conclusions contained in the software and documentation
28 | are those of the authors and should not be interpreted as representing
29 | official policies, either expressed or implied, of Richard Crowley.
30 |
--------------------------------------------------------------------------------
/go/vendor/github.com/spf13/pflag/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2012 Alex Ogier. All rights reserved.
2 | Copyright (c) 2012 The Go Authors. All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are
6 | met:
7 |
8 | * Redistributions of source code must retain the above copyright
9 | notice, this list of conditions and the following disclaimer.
10 | * Redistributions in binary form must reproduce the above
11 | copyright notice, this list of conditions and the following disclaimer
12 | in the documentation and/or other materials provided with the
13 | distribution.
14 | * Neither the name of Google Inc. nor the names of its
15 | contributors may be used to endorse or promote products derived from
16 | this software without specific prior written permission.
17 |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/bsm/sarama-cluster.v2/cluster.go:
--------------------------------------------------------------------------------
1 | package cluster
2 |
3 | import "sort"
4 |
5 | // Strategy for partition to consumer assignement
6 | type Strategy string
7 |
8 | const (
9 | // StrategyRange is the default and assigns partition ranges to consumers.
10 | // Example with six partitions and two consumers:
11 | // C1: [0, 1, 2]
12 | // C2: [3, 4, 5]
13 | StrategyRange Strategy = "range"
14 |
15 | // StrategyRoundRobin assigns partitions by alternating over consumers.
16 | // Example with six partitions and two consumers:
17 | // C1: [0, 2, 4]
18 | // C2: [1, 3, 5]
19 | StrategyRoundRobin Strategy = "roundrobin"
20 | )
21 |
22 | // Error instances are wrappers for internal errors with a context and
23 | // may be returned through the consumer's Errors() channel
24 | type Error struct {
25 | Ctx string
26 | error
27 | }
28 |
29 | // --------------------------------------------------------------------
30 |
31 | type none struct{}
32 |
33 | type topicPartition struct {
34 | Topic string
35 | Partition int32
36 | }
37 |
38 | type offsetInfo struct {
39 | Offset int64
40 | Metadata string
41 | }
42 |
43 | func (i offsetInfo) NextOffset(fallback int64) int64 {
44 | if i.Offset > -1 {
45 | return i.Offset + 1
46 | }
47 | return fallback
48 | }
49 |
50 | type int32Slice []int32
51 |
52 | func (p int32Slice) Len() int { return len(p) }
53 | func (p int32Slice) Less(i, j int) bool { return p[i] < p[j] }
54 | func (p int32Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
55 |
56 | func (p int32Slice) Diff(o int32Slice) (res []int32) {
57 | on := len(o)
58 | for _, x := range p {
59 | n := sort.Search(on, func(i int) bool { return o[i] >= x })
60 | if n < on && o[n] == x {
61 | continue
62 | }
63 | res = append(res, x)
64 | }
65 | return
66 | }
67 |
--------------------------------------------------------------------------------
/go/vendor/github.com/rcrowley/go-metrics/healthcheck.go:
--------------------------------------------------------------------------------
1 | package metrics
2 |
3 | // Healthchecks hold an error value describing an arbitrary up/down status.
4 | type Healthcheck interface {
5 | Check()
6 | Error() error
7 | Healthy()
8 | Unhealthy(error)
9 | }
10 |
11 | // NewHealthcheck constructs a new Healthcheck which will use the given
12 | // function to update its status.
13 | func NewHealthcheck(f func(Healthcheck)) Healthcheck {
14 | if UseNilMetrics {
15 | return NilHealthcheck{}
16 | }
17 | return &StandardHealthcheck{nil, f}
18 | }
19 |
20 | // NilHealthcheck is a no-op.
21 | type NilHealthcheck struct{}
22 |
23 | // Check is a no-op.
24 | func (NilHealthcheck) Check() {}
25 |
26 | // Error is a no-op.
27 | func (NilHealthcheck) Error() error { return nil }
28 |
29 | // Healthy is a no-op.
30 | func (NilHealthcheck) Healthy() {}
31 |
32 | // Unhealthy is a no-op.
33 | func (NilHealthcheck) Unhealthy(error) {}
34 |
35 | // StandardHealthcheck is the standard implementation of a Healthcheck and
36 | // stores the status and a function to call to update the status.
37 | type StandardHealthcheck struct {
38 | err error
39 | f func(Healthcheck)
40 | }
41 |
42 | // Check runs the healthcheck function to update the healthcheck's status.
43 | func (h *StandardHealthcheck) Check() {
44 | h.f(h)
45 | }
46 |
47 | // Error returns the healthcheck's status, which will be nil if it is healthy.
48 | func (h *StandardHealthcheck) Error() error {
49 | return h.err
50 | }
51 |
52 | // Healthy marks the healthcheck as healthy.
53 | func (h *StandardHealthcheck) Healthy() {
54 | h.err = nil
55 | }
56 |
57 | // Unhealthy marks the healthcheck as unhealthy. The error is stored and
58 | // may be retrieved by the Error method.
59 | func (h *StandardHealthcheck) Unhealthy(err error) {
60 | h.err = err
61 | }
62 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/packet_encoder.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | // PacketEncoder is the interface providing helpers for writing with Kafka's encoding rules.
4 | // Types implementing Encoder only need to worry about calling methods like PutString,
5 | // not about how a string is represented in Kafka.
6 | type packetEncoder interface {
7 | // Primitives
8 | putInt8(in int8)
9 | putInt16(in int16)
10 | putInt32(in int32)
11 | putInt64(in int64)
12 | putArrayLength(in int) error
13 |
14 | // Collections
15 | putBytes(in []byte) error
16 | putRawBytes(in []byte) error
17 | putString(in string) error
18 | putStringArray(in []string) error
19 | putInt32Array(in []int32) error
20 | putInt64Array(in []int64) error
21 |
22 | // Stacks, see PushEncoder
23 | push(in pushEncoder)
24 | pop() error
25 | }
26 |
27 | // PushEncoder is the interface for encoding fields like CRCs and lengths where the value
28 | // of the field depends on what is encoded after it in the packet. Start them with PacketEncoder.Push() where
29 | // the actual value is located in the packet, then PacketEncoder.Pop() them when all the bytes they
30 | // depend upon have been written.
31 | type pushEncoder interface {
32 | // Saves the offset into the input buffer as the location to actually write the calculated value when able.
33 | saveOffset(in int)
34 |
35 | // Returns the length of data to reserve for the output of this encoder (eg 4 bytes for a CRC32).
36 | reserveLength() int
37 |
38 | // Indicates that all required data is now available to calculate and write the field.
39 | // SaveOffset is guaranteed to have been called first. The implementation should write ReserveLength() bytes
40 | // of data to the saved offset, based on the data between the saved offset and curOffset.
41 | run(curOffset int, buf []byte) error
42 | }
43 |
--------------------------------------------------------------------------------
/go/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015 Dave Collins
2 | //
3 | // Permission to use, copy, modify, and distribute this software for any
4 | // purpose with or without fee is hereby granted, provided that the above
5 | // copyright notice and this permission notice appear in all copies.
6 | //
7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 |
15 | // NOTE: Due to the following build constraints, this file will only be compiled
16 | // when either the code is running on Google App Engine or "-tags disableunsafe"
17 | // is added to the go build command line.
18 | // +build appengine disableunsafe
19 |
20 | package spew
21 |
22 | import "reflect"
23 |
24 | const (
25 | // UnsafeDisabled is a build-time constant which specifies whether or
26 | // not access to the unsafe package is available.
27 | UnsafeDisabled = true
28 | )
29 |
30 | // unsafeReflectValue typically converts the passed reflect.Value into a one
31 | // that bypasses the typical safety restrictions preventing access to
32 | // unaddressable and unexported data. However, doing this relies on access to
33 | // the unsafe package. This is a stub version which simply returns the passed
34 | // reflect.Value when the unsafe package is not available.
35 | func unsafeReflectValue(v reflect.Value) reflect.Value {
36 | return v
37 | }
38 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Sirupsen/logrus/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # 0.10.0
2 |
3 | * feature: Add a test hook (#180)
4 | * feature: `ParseLevel` is now case-insensitive (#326)
5 | * feature: `FieldLogger` interface that generalizes `Logger` and `Entry` (#308)
6 | * performance: avoid re-allocations on `WithFields` (#335)
7 |
8 | # 0.9.0
9 |
10 | * logrus/text_formatter: don't emit empty msg
11 | * logrus/hooks/airbrake: move out of main repository
12 | * logrus/hooks/sentry: move out of main repository
13 | * logrus/hooks/papertrail: move out of main repository
14 | * logrus/hooks/bugsnag: move out of main repository
15 | * logrus/core: run tests with `-race`
16 | * logrus/core: detect TTY based on `stderr`
17 | * logrus/core: support `WithError` on logger
18 | * logrus/core: Solaris support
19 |
20 | # 0.8.7
21 |
22 | * logrus/core: fix possible race (#216)
23 | * logrus/doc: small typo fixes and doc improvements
24 |
25 |
26 | # 0.8.6
27 |
28 | * hooks/raven: allow passing an initialized client
29 |
30 | # 0.8.5
31 |
32 | * logrus/core: revert #208
33 |
34 | # 0.8.4
35 |
36 | * formatter/text: fix data race (#218)
37 |
38 | # 0.8.3
39 |
40 | * logrus/core: fix entry log level (#208)
41 | * logrus/core: improve performance of text formatter by 40%
42 | * logrus/core: expose `LevelHooks` type
43 | * logrus/core: add support for DragonflyBSD and NetBSD
44 | * formatter/text: print structs more verbosely
45 |
46 | # 0.8.2
47 |
48 | * logrus: fix more Fatal family functions
49 |
50 | # 0.8.1
51 |
52 | * logrus: fix not exiting on `Fatalf` and `Fatalln`
53 |
54 | # 0.8.0
55 |
56 | * logrus: defaults to stderr instead of stdout
57 | * hooks/sentry: add special field for `*http.Request`
58 | * formatter/text: ignore Windows for colors
59 |
60 | # 0.7.3
61 |
62 | * formatter/\*: allow configuration of timestamp layout
63 |
64 | # 0.7.2
65 |
66 | * formatter/text: Add configuration option for time format (#158)
67 |
--------------------------------------------------------------------------------
/go/vendor/github.com/klauspost/crc32/crc32_amd64.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 | // +build !appengine,!gccgo
6 |
7 | package crc32
8 |
9 | // This file contains the code to call the SSE 4.2 version of the Castagnoli
10 | // and IEEE CRC.
11 |
12 | // haveSSE41/haveSSE42/haveCLMUL are defined in crc_amd64.s and use
13 | // CPUID to test for SSE 4.1, 4.2 and CLMUL support.
14 | func haveSSE41() bool
15 | func haveSSE42() bool
16 | func haveCLMUL() bool
17 |
18 | // castagnoliSSE42 is defined in crc_amd64.s and uses the SSE4.2 CRC32
19 | // instruction.
20 | //go:noescape
21 | func castagnoliSSE42(crc uint32, p []byte) uint32
22 |
23 | // ieeeCLMUL is defined in crc_amd64.s and uses the PCLMULQDQ
24 | // instruction as well as SSE 4.1.
25 | //go:noescape
26 | func ieeeCLMUL(crc uint32, p []byte) uint32
27 |
28 | var sse42 = haveSSE42()
29 | var useFastIEEE = haveCLMUL() && haveSSE41()
30 |
31 | func updateCastagnoli(crc uint32, p []byte) uint32 {
32 | if sse42 {
33 | return castagnoliSSE42(crc, p)
34 | }
35 | // only use slicing-by-8 when input is >= 16 Bytes
36 | if len(p) >= 16 {
37 | return updateSlicingBy8(crc, castagnoliTable8, p)
38 | }
39 | return update(crc, castagnoliTable, p)
40 | }
41 |
42 | func updateIEEE(crc uint32, p []byte) uint32 {
43 | if useFastIEEE && len(p) >= 64 {
44 | left := len(p) & 15
45 | do := len(p) - left
46 | crc = ^ieeeCLMUL(^crc, p[:do])
47 | if left > 0 {
48 | crc = update(crc, IEEETable, p[do:])
49 | }
50 | return crc
51 | }
52 |
53 | // only use slicing-by-8 when input is >= 16 Bytes
54 | if len(p) >= 16 {
55 | ieeeTable8Once.Do(func() {
56 | ieeeTable8 = makeTable8(IEEE)
57 | })
58 | return updateSlicingBy8(crc, ieeeTable8, p)
59 | }
60 |
61 | return update(crc, IEEETable, p)
62 | }
63 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/bsm/sarama-cluster.v2/README.md:
--------------------------------------------------------------------------------
1 | # Sarama Cluster [](https://travis-ci.org/bsm/sarama-cluster)
2 |
3 | Cluster extensions for [Sarama](https://github.com/Shopify/sarama), the Go client library for Apache Kafka 0.9 (and later).
4 |
5 | ## Documentation
6 |
7 | Documentation and example are available via godoc at http://godoc.org/github.com/bsm/sarama-cluster
8 |
9 | ## Running tests
10 |
11 | You need to install Ginkgo & Gomega to run tests. Please see
12 | http://onsi.github.io/ginkgo for more details.
13 |
14 | To run tests, call:
15 |
16 | $ make test
17 |
18 | ## Licence
19 |
20 | (The MIT License)
21 |
22 | Copyright (c) 2016 Black Square Media Ltd
23 |
24 | Permission is hereby granted, free of charge, to any person obtaining
25 | a copy of this software and associated documentation files (the
26 | 'Software'), to deal in the Software without restriction, including
27 | without limitation the rights to use, copy, modify, merge, publish,
28 | distribute, sublicense, and/or sell copies of the Software, and to
29 | permit persons to whom the Software is furnished to do so, subject to
30 | the following conditions:
31 |
32 | The above copyright notice and this permission notice shall be
33 | included in all copies or substantial portions of the Software.
34 |
35 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
36 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
37 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
38 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
39 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
40 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
41 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 |
--------------------------------------------------------------------------------
/java/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | ovh
4 | kafka-example
5 | 1
6 |
7 |
8 |
9 | org.apache.kafka
10 | kafka-clients
11 | 0.10.0.1
12 |
13 |
14 | com.beust
15 | jcommander
16 | 1.48
17 |
18 |
19 | ch.qos.logback
20 | logback-classic
21 | 1.1.7
22 |
23 |
24 |
25 |
26 |
27 | kafka-example
28 |
29 |
30 | org.apache.maven.plugins
31 | maven-compiler-plugin
32 | 3.5.1
33 |
34 | 1.8
35 | 1.8
36 |
37 |
38 |
39 | org.apache.maven.plugins
40 | maven-assembly-plugin
41 |
42 |
43 | jar-with-dependencies
44 |
45 |
46 |
47 | ovh.queue.Main
48 |
49 |
50 |
51 |
52 |
53 | package
54 |
55 | single
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/packet_decoder.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | // PacketDecoder is the interface providing helpers for reading with Kafka's encoding rules.
4 | // Types implementing Decoder only need to worry about calling methods like GetString,
5 | // not about how a string is represented in Kafka.
6 | type packetDecoder interface {
7 | // Primitives
8 | getInt8() (int8, error)
9 | getInt16() (int16, error)
10 | getInt32() (int32, error)
11 | getInt64() (int64, error)
12 | getArrayLength() (int, error)
13 |
14 | // Collections
15 | getBytes() ([]byte, error)
16 | getString() (string, error)
17 | getInt32Array() ([]int32, error)
18 | getInt64Array() ([]int64, error)
19 | getStringArray() ([]string, error)
20 |
21 | // Subsets
22 | remaining() int
23 | getSubset(length int) (packetDecoder, error)
24 |
25 | // Stacks, see PushDecoder
26 | push(in pushDecoder) error
27 | pop() error
28 | }
29 |
30 | // PushDecoder is the interface for decoding fields like CRCs and lengths where the validity
31 | // of the field depends on what is after it in the packet. Start them with PacketDecoder.Push() where
32 | // the actual value is located in the packet, then PacketDecoder.Pop() them when all the bytes they
33 | // depend upon have been decoded.
34 | type pushDecoder interface {
35 | // Saves the offset into the input buffer as the location to actually read the calculated value when able.
36 | saveOffset(in int)
37 |
38 | // Returns the length of data to reserve for the input of this encoder (eg 4 bytes for a CRC32).
39 | reserveLength() int
40 |
41 | // Indicates that all required data is now available to calculate and check the field.
42 | // SaveOffset is guaranteed to have been called first. The implementation should read ReserveLength() bytes
43 | // of data from the saved offset, and verify it based on the data between the saved offset and curOffset.
44 | check(curOffset int, buf []byte) error
45 | }
46 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/packet_decoder.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | // PacketDecoder is the interface providing helpers for reading with Kafka's encoding rules.
4 | // Types implementing Decoder only need to worry about calling methods like GetString,
5 | // not about how a string is represented in Kafka.
6 | type packetDecoder interface {
7 | // Primitives
8 | getInt8() (int8, error)
9 | getInt16() (int16, error)
10 | getInt32() (int32, error)
11 | getInt64() (int64, error)
12 | getArrayLength() (int, error)
13 |
14 | // Collections
15 | getBytes() ([]byte, error)
16 | getString() (string, error)
17 | getInt32Array() ([]int32, error)
18 | getInt64Array() ([]int64, error)
19 | getStringArray() ([]string, error)
20 |
21 | // Subsets
22 | remaining() int
23 | getSubset(length int) (packetDecoder, error)
24 |
25 | // Stacks, see PushDecoder
26 | push(in pushDecoder) error
27 | pop() error
28 | }
29 |
30 | // PushDecoder is the interface for decoding fields like CRCs and lengths where the validity
31 | // of the field depends on what is after it in the packet. Start them with PacketDecoder.Push() where
32 | // the actual value is located in the packet, then PacketDecoder.Pop() them when all the bytes they
33 | // depend upon have been decoded.
34 | type pushDecoder interface {
35 | // Saves the offset into the input buffer as the location to actually read the calculated value when able.
36 | saveOffset(in int)
37 |
38 | // Returns the length of data to reserve for the input of this encoder (eg 4 bytes for a CRC32).
39 | reserveLength() int
40 |
41 | // Indicates that all required data is now available to calculate and check the field.
42 | // SaveOffset is guaranteed to have been called first. The implementation should read ReserveLength() bytes
43 | // of data from the saved offset, and verify it based on the data between the saved offset and curOffset.
44 | check(curOffset int, buf []byte) error
45 | }
46 |
--------------------------------------------------------------------------------
/go/consume.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "strings"
6 |
7 | "github.com/Shopify/sarama"
8 | log "github.com/Sirupsen/logrus"
9 | "github.com/spf13/cobra"
10 | "gopkg.in/bsm/sarama-cluster.v2"
11 | )
12 |
13 | // Consume consumes messages from Kafka
14 | func Consume(cmd *cobra.Command, args []string) {
15 |
16 | var config = sarama.NewConfig()
17 | config.Net.TLS.Enable = true
18 | config.Net.SASL.Enable = true
19 | config.Net.SASL.User = Username
20 | config.Net.SASL.Password = Password
21 | config.Version = sarama.V0_10_0_1
22 | config.ClientID = Username
23 |
24 | if ConsumerGroup == "" {
25 | ConsumerGroup = Username + ".go"
26 | }
27 |
28 | clusterConfig := cluster.NewConfig()
29 | clusterConfig.Config = *config
30 | clusterConfig.Consumer.Return.Errors = true
31 | clusterConfig.Group.Return.Notifications = true
32 |
33 | var err error
34 | Consumer, err = cluster.NewConsumer(strings.Split(BrokerAddrs, ","), ConsumerGroup, []string{Topic}, clusterConfig)
35 | HandleError(err)
36 |
37 | // Consume errors
38 | go func() {
39 | for err := range Consumer.Errors() {
40 | log.WithError(err).Error("Error during consumption")
41 | }
42 | }()
43 |
44 | // Consume notifications
45 | go func() {
46 | for note := range Consumer.Notifications() {
47 | log.WithField("note", note).Debug("Rebalanced consumer")
48 | }
49 | }()
50 |
51 | fmt.Println("Ready to consume messages...")
52 | // Consume messages
53 | for msg := range Consumer.Messages() {
54 |
55 | log.WithFields(log.Fields{
56 | "consumerGroup": ConsumerGroup,
57 | "topic": Topic,
58 | "timestamp": msg.Timestamp,
59 | "key": string(msg.Key),
60 | "value": string(msg.Value),
61 | "partition": msg.Partition,
62 | "offset": msg.Offset,
63 | }).Debug("Consume message")
64 |
65 | Consumer.MarkOffset(msg, "")
66 |
67 | fmt.Println(string(msg.Value))
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/java/src/main/java/ovh/queue/Produce.java:
--------------------------------------------------------------------------------
1 | package ovh.queue;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.IOException;
5 | import java.io.InputStreamReader;
6 | import java.util.Properties;
7 | import com.beust.jcommander.Parameters;
8 | import org.apache.kafka.clients.producer.KafkaProducer;
9 | import org.apache.kafka.clients.producer.Producer;
10 | import org.apache.kafka.clients.producer.ProducerRecord;
11 | import ovh.queue.Command;
12 |
13 | @Parameters(commandDescription = "Produce messages using TLS/SSL")
14 | public class Produce extends Command {
15 |
16 | public static String NAME = "produce";
17 |
18 | public void run() {
19 | Properties props = new Properties();
20 | props.put("bootstrap.servers", this.broker);
21 | props.put("security.protocol", "SASL_SSL");
22 | props.put("sasl.mechanism", "PLAIN");
23 | props.put("acks", "all");
24 | props.put("retries", 0);
25 | props.put("batch.size",1 );
26 | props.put("linger.ms", 1);
27 | props.put("buffer.memory", 33554432);
28 | props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
29 | props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
30 |
31 | Producer producer = new KafkaProducer<>(props);
32 | BufferedReader br = null;
33 | try {
34 | System.out.println("Ready to produce messages. Write something to stdin...");
35 | br = new BufferedReader(new InputStreamReader(System.in));
36 | while (true) {
37 | String input = br.readLine();
38 | producer.send(new ProducerRecord(this.topic, "", input));
39 | }
40 | } catch (IOException e) {
41 | e.printStackTrace();
42 | } finally {
43 | if (br != null) {
44 | try {
45 | br.close();
46 | } catch (IOException e) {
47 | e.printStackTrace();
48 | }
49 | }
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/java/src/main/java/ovh/queue/Consume.java:
--------------------------------------------------------------------------------
1 | package ovh.queue;
2 |
3 | import java.util.Arrays;
4 | import java.util.Properties;
5 | import com.beust.jcommander.Parameters;
6 | import com.beust.jcommander.Parameter;
7 | import org.apache.kafka.clients.consumer.KafkaConsumer;
8 | import org.apache.kafka.clients.consumer.ConsumerRecords;
9 | import org.apache.kafka.clients.consumer.ConsumerRecord;
10 | import ovh.queue.Command;
11 |
12 | @Parameters(commandDescription = "Consume messages using TLS/SSL")
13 | public class Consume extends Command {
14 |
15 | public static String NAME = "consume";
16 |
17 | @Parameter(names="--consumer-group", description = "Consumer group, prefixed by your SASL username (eg. --consumer-group=myns.user.g1)", required=true)
18 | public String group;
19 |
20 | public void run() {
21 | Properties props = new Properties();
22 | props.put("bootstrap.servers", this.broker);
23 | props.put("security.protocol", "SASL_SSL");
24 | props.put("sasl.mechanism", "PLAIN");
25 | props.put("enable.auto.commit", "true");
26 | props.put("auto.commit.interval.ms", "1000");
27 | props.put("session.timeout.ms", "30000");
28 | props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
29 | props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
30 | props.put("group.id", this.group);
31 |
32 | KafkaConsumer consumer = new KafkaConsumer<>(props);
33 |
34 | try {
35 | consumer.subscribe(Arrays.asList(this.topic));
36 |
37 | System.out.println("Ready to consume messages...");
38 | while (true) {
39 | ConsumerRecords records = consumer.poll(100);
40 | for (ConsumerRecord record : records)
41 | System.out.printf("offset = %d, key = %s, value = %s\n", record.offset(), record.key(), record.value());
42 | }
43 | } finally {
44 | consumer.close();
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/packet_encoder.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | import "github.com/rcrowley/go-metrics"
4 |
5 | // PacketEncoder is the interface providing helpers for writing with Kafka's encoding rules.
6 | // Types implementing Encoder only need to worry about calling methods like PutString,
7 | // not about how a string is represented in Kafka.
8 | type packetEncoder interface {
9 | // Primitives
10 | putInt8(in int8)
11 | putInt16(in int16)
12 | putInt32(in int32)
13 | putInt64(in int64)
14 | putArrayLength(in int) error
15 |
16 | // Collections
17 | putBytes(in []byte) error
18 | putRawBytes(in []byte) error
19 | putString(in string) error
20 | putStringArray(in []string) error
21 | putInt32Array(in []int32) error
22 | putInt64Array(in []int64) error
23 |
24 | // Provide the current offset to record the batch size metric
25 | offset() int
26 |
27 | // Stacks, see PushEncoder
28 | push(in pushEncoder)
29 | pop() error
30 |
31 | // To record metrics when provided
32 | metricRegistry() metrics.Registry
33 | }
34 |
35 | // PushEncoder is the interface for encoding fields like CRCs and lengths where the value
36 | // of the field depends on what is encoded after it in the packet. Start them with PacketEncoder.Push() where
37 | // the actual value is located in the packet, then PacketEncoder.Pop() them when all the bytes they
38 | // depend upon have been written.
39 | type pushEncoder interface {
40 | // Saves the offset into the input buffer as the location to actually write the calculated value when able.
41 | saveOffset(in int)
42 |
43 | // Returns the length of data to reserve for the output of this encoder (eg 4 bytes for a CRC32).
44 | reserveLength() int
45 |
46 | // Indicates that all required data is now available to calculate and write the field.
47 | // SaveOffset is guaranteed to have been called first. The implementation should write ReserveLength() bytes
48 | // of data to the saved offset, based on the data between the saved offset and curOffset.
49 | run(curOffset int, buf []byte) error
50 | }
51 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Sirupsen/logrus/json_formatter.go:
--------------------------------------------------------------------------------
1 | package logrus
2 |
3 | import (
4 | "encoding/json"
5 | "fmt"
6 | )
7 |
8 | type fieldKey string
9 | type FieldMap map[fieldKey]string
10 |
11 | const (
12 | FieldKeyMsg = "msg"
13 | FieldKeyLevel = "level"
14 | FieldKeyTime = "time"
15 | )
16 |
17 | func (f FieldMap) resolve(key fieldKey) string {
18 | if k, ok := f[key]; ok {
19 | return k
20 | }
21 |
22 | return string(key)
23 | }
24 |
25 | type JSONFormatter struct {
26 | // TimestampFormat sets the format used for marshaling timestamps.
27 | TimestampFormat string
28 |
29 | // DisableTimestamp allows disabling automatic timestamps in output
30 | DisableTimestamp bool
31 |
32 | // FieldMap allows users to customize the names of keys for various fields.
33 | // As an example:
34 | // formatter := &JSONFormatter{
35 | // FieldMap: FieldMap{
36 | // FieldKeyTime: "@timestamp",
37 | // FieldKeyLevel: "@level",
38 | // FieldKeyLevel: "@message",
39 | // },
40 | // }
41 | FieldMap FieldMap
42 | }
43 |
44 | func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) {
45 | data := make(Fields, len(entry.Data)+3)
46 | for k, v := range entry.Data {
47 | switch v := v.(type) {
48 | case error:
49 | // Otherwise errors are ignored by `encoding/json`
50 | // https://github.com/Sirupsen/logrus/issues/137
51 | data[k] = v.Error()
52 | default:
53 | data[k] = v
54 | }
55 | }
56 | prefixFieldClashes(data)
57 |
58 | timestampFormat := f.TimestampFormat
59 | if timestampFormat == "" {
60 | timestampFormat = DefaultTimestampFormat
61 | }
62 |
63 | if !f.DisableTimestamp {
64 | data[f.FieldMap.resolve(FieldKeyTime)] = entry.Time.Format(timestampFormat)
65 | }
66 | data[f.FieldMap.resolve(FieldKeyMsg)] = entry.Message
67 | data[f.FieldMap.resolve(FieldKeyLevel)] = entry.Level.String()
68 |
69 | serialized, err := json.Marshal(data)
70 | if err != nil {
71 | return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
72 | }
73 | return append(serialized, '\n'), nil
74 | }
75 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/bsm/sarama-cluster.v2/glide.lock:
--------------------------------------------------------------------------------
1 | hash: 76e38c5c70ece28550aacde5afd4ea321c4986b615e0bd145f899664ffc8888b
2 | updated: 2016-07-25T11:06:46.601987242+01:00
3 | imports:
4 | - name: github.com/davecgh/go-spew
5 | version: 5215b55f46b2b919f50a1df0eaa5886afe4e3b3d
6 | subpackages:
7 | - spew
8 | - name: github.com/eapache/go-resiliency
9 | version: b86b1ec0dd4209a588dc1285cdd471e73525c0b3
10 | subpackages:
11 | - breaker
12 | - name: github.com/eapache/queue
13 | version: ded5959c0d4e360646dc9e9908cff48666781367
14 | - name: github.com/golang/snappy
15 | version: d9eb7a3d35ec988b8585d4a0068e462c27d28380
16 | - name: github.com/klauspost/crc32
17 | version: 19b0b332c9e4516a6370a0456e6182c3b5036720
18 | - name: github.com/Shopify/sarama
19 | version: 38d579a708d2f87dd4e35342241048e361d1e66a
20 | testImports:
21 | - name: github.com/golang/protobuf
22 | version: 874264fbbb43f4d91e999fecb4b40143ed611400
23 | subpackages:
24 | - proto
25 | - proto/testdata
26 | - ptypes/any
27 | - name: github.com/onsi/ginkgo
28 | version: 059cec02d342bab423425a99b191186a03255e9e
29 | subpackages:
30 | - extensions/table
31 | - config
32 | - internal/codelocation
33 | - internal/failer
34 | - internal/remote
35 | - internal/suite
36 | - internal/testingtproxy
37 | - internal/writer
38 | - reporters
39 | - reporters/stenographer
40 | - types
41 | - ginkgo/convert
42 | - ginkgo/interrupthandler
43 | - ginkgo/nodot
44 | - ginkgo/testrunner
45 | - ginkgo/testsuite
46 | - ginkgo/watch
47 | - internal/leafnodes
48 | - name: github.com/onsi/gomega
49 | version: 0df7b7fdb38123c12a1f569f0affb2c2a7bd72cf
50 | subpackages:
51 | - internal/assertion
52 | - internal/asyncassertion
53 | - internal/testingtsupport
54 | - matchers
55 | - types
56 | - internal/oraclematcher
57 | - matchers/support/goraph/bipartitegraph
58 | - matchers/support/goraph/edge
59 | - matchers/support/goraph/node
60 | - matchers/support/goraph/util
61 | - name: gopkg.in/yaml.v2
62 | version: a83829b6f1293c91addabc89d0571c246397bbf4
63 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/api_versions_response.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type ApiVersionsResponseBlock struct {
4 | ApiKey int16
5 | MinVersion int16
6 | MaxVersion int16
7 | }
8 |
9 | func (b *ApiVersionsResponseBlock) encode(pe packetEncoder) error {
10 | pe.putInt16(b.ApiKey)
11 | pe.putInt16(b.MinVersion)
12 | pe.putInt16(b.MaxVersion)
13 | return nil
14 | }
15 |
16 | func (b *ApiVersionsResponseBlock) decode(pd packetDecoder) error {
17 | var err error
18 |
19 | if b.ApiKey, err = pd.getInt16(); err != nil {
20 | return err
21 | }
22 |
23 | if b.MinVersion, err = pd.getInt16(); err != nil {
24 | return err
25 | }
26 |
27 | if b.MaxVersion, err = pd.getInt16(); err != nil {
28 | return err
29 | }
30 |
31 | return nil
32 | }
33 |
34 | type ApiVersionsResponse struct {
35 | Err KError
36 | ApiVersions []*ApiVersionsResponseBlock
37 | }
38 |
39 | func (r *ApiVersionsResponse) encode(pe packetEncoder) error {
40 | pe.putInt16(int16(r.Err))
41 | if err := pe.putArrayLength(len(r.ApiVersions)); err != nil {
42 | return err
43 | }
44 | for _, apiVersion := range r.ApiVersions {
45 | if err := apiVersion.encode(pe); err != nil {
46 | return err
47 | }
48 | }
49 | return nil
50 | }
51 |
52 | func (r *ApiVersionsResponse) decode(pd packetDecoder, version int16) error {
53 | if kerr, err := pd.getInt16(); err != nil {
54 | return err
55 | } else {
56 | r.Err = KError(kerr)
57 | }
58 |
59 | numBlocks, err := pd.getArrayLength()
60 | if err != nil {
61 | return err
62 | }
63 |
64 | r.ApiVersions = make([]*ApiVersionsResponseBlock, numBlocks)
65 | for i := 0; i < numBlocks; i++ {
66 | block := new(ApiVersionsResponseBlock)
67 | if err := block.decode(pd); err != nil {
68 | return err
69 | }
70 | r.ApiVersions[i] = block
71 | }
72 |
73 | return nil
74 | }
75 |
76 | func (r *ApiVersionsResponse) key() int16 {
77 | return 18
78 | }
79 |
80 | func (r *ApiVersionsResponse) version() int16 {
81 | return 0
82 | }
83 |
84 | func (r *ApiVersionsResponse) requiredVersion() KafkaVersion {
85 | return V0_10_0_0
86 | }
87 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/api_versions_response.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type ApiVersionsResponseBlock struct {
4 | ApiKey int16
5 | MinVersion int16
6 | MaxVersion int16
7 | }
8 |
9 | func (b *ApiVersionsResponseBlock) encode(pe packetEncoder) error {
10 | pe.putInt16(b.ApiKey)
11 | pe.putInt16(b.MinVersion)
12 | pe.putInt16(b.MaxVersion)
13 | return nil
14 | }
15 |
16 | func (b *ApiVersionsResponseBlock) decode(pd packetDecoder) error {
17 | var err error
18 |
19 | if b.ApiKey, err = pd.getInt16(); err != nil {
20 | return err
21 | }
22 |
23 | if b.MinVersion, err = pd.getInt16(); err != nil {
24 | return err
25 | }
26 |
27 | if b.MaxVersion, err = pd.getInt16(); err != nil {
28 | return err
29 | }
30 |
31 | return nil
32 | }
33 |
34 | type ApiVersionsResponse struct {
35 | Err KError
36 | ApiVersions []*ApiVersionsResponseBlock
37 | }
38 |
39 | func (r *ApiVersionsResponse) encode(pe packetEncoder) error {
40 | pe.putInt16(int16(r.Err))
41 | if err := pe.putArrayLength(len(r.ApiVersions)); err != nil {
42 | return err
43 | }
44 | for _, apiVersion := range r.ApiVersions {
45 | if err := apiVersion.encode(pe); err != nil {
46 | return err
47 | }
48 | }
49 | return nil
50 | }
51 |
52 | func (r *ApiVersionsResponse) decode(pd packetDecoder, version int16) error {
53 | if kerr, err := pd.getInt16(); err != nil {
54 | return err
55 | } else {
56 | r.Err = KError(kerr)
57 | }
58 |
59 | numBlocks, err := pd.getArrayLength()
60 | if err != nil {
61 | return err
62 | }
63 |
64 | r.ApiVersions = make([]*ApiVersionsResponseBlock, numBlocks)
65 | for i := 0; i < numBlocks; i++ {
66 | block := new(ApiVersionsResponseBlock)
67 | if err := block.decode(pd); err != nil {
68 | return err
69 | }
70 | r.ApiVersions[i] = block
71 | }
72 |
73 | return nil
74 | }
75 |
76 | func (r *ApiVersionsResponse) key() int16 {
77 | return 18
78 | }
79 |
80 | func (r *ApiVersionsResponse) version() int16 {
81 | return 0
82 | }
83 |
84 | func (r *ApiVersionsResponse) requiredVersion() KafkaVersion {
85 | return V0_10_0_0
86 | }
87 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/README.md:
--------------------------------------------------------------------------------
1 | sarama
2 | ======
3 |
4 | [](https://godoc.org/github.com/Shopify/sarama)
5 | [](https://travis-ci.org/Shopify/sarama)
6 |
7 | Sarama is an MIT-licensed Go client library for [Apache Kafka](https://kafka.apache.org/) version 0.8 (and later).
8 |
9 | ### Getting started
10 |
11 | - API documentation and examples are available via [godoc](https://godoc.org/github.com/Shopify/sarama).
12 | - Mocks for testing are available in the [mocks](./mocks) subpackage.
13 | - The [examples](./examples) directory contains more elaborate example applications.
14 | - The [tools](./tools) directory contains command line tools that can be useful for testing, diagnostics, and instrumentation.
15 |
16 | ### Compatibility and API stability
17 |
18 | Sarama provides a "2 releases + 2 months" compatibility guarantee: we support
19 | the two latest stable releases of Kafka and Go, and we provide a two month
20 | grace period for older releases. This means we currently officially support
21 | Go 1.7 and 1.6, and Kafka 0.10.0 and 0.9.0, although older releases are
22 | still likely to work.
23 |
24 | Sarama follows semantic versioning and provides API stability via the gopkg.in service.
25 | You can import a version with a guaranteed stable API via http://gopkg.in/Shopify/sarama.v1.
26 | A changelog is available [here](CHANGELOG.md).
27 |
28 | ### Contributing
29 |
30 | * Get started by checking our [contribution guidelines](https://github.com/Shopify/sarama/blob/master/CONTRIBUTING.md).
31 | * Read the [Sarama wiki](https://github.com/Shopify/sarama/wiki) for more
32 | technical and design details.
33 | * The [Kafka Protocol Specification](https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol)
34 | contains a wealth of useful information.
35 | * For more general issues, there is [a google group](https://groups.google.com/forum/#!forum/kafka-clients) for Kafka client developers.
36 | * If you have any questions, just ask!
37 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/README.md:
--------------------------------------------------------------------------------
1 | sarama
2 | ======
3 |
4 | [](https://godoc.org/github.com/Shopify/sarama)
5 | [](https://travis-ci.org/Shopify/sarama)
6 |
7 | Sarama is an MIT-licensed Go client library for [Apache Kafka](https://kafka.apache.org/) version 0.8 (and later).
8 |
9 | ### Getting started
10 |
11 | - API documentation and examples are available via [godoc](https://godoc.org/github.com/Shopify/sarama).
12 | - Mocks for testing are available in the [mocks](./mocks) subpackage.
13 | - The [examples](./examples) directory contains more elaborate example applications.
14 | - The [tools](./tools) directory contains command line tools that can be useful for testing, diagnostics, and instrumentation.
15 |
16 | ### Compatibility and API stability
17 |
18 | Sarama provides a "2 releases + 2 months" compatibility guarantee: we support
19 | the two latest stable releases of Kafka and Go, and we provide a two month
20 | grace period for older releases. This means we currently officially support
21 | Go 1.6 and 1.5, and Kafka 0.10.0, 0.9.0 and 0.8.2, although older releases are
22 | still likely to work.
23 |
24 | Sarama follows semantic versioning and provides API stability via the gopkg.in service.
25 | You can import a version with a guaranteed stable API via http://gopkg.in/Shopify/sarama.v1.
26 | A changelog is available [here](CHANGELOG.md).
27 |
28 | ### Contributing
29 |
30 | * Get started by checking our [contribution guidelines](https://github.com/Shopify/sarama/blob/master/CONTRIBUTING.md).
31 | * Read the [Sarama wiki](https://github.com/Shopify/sarama/wiki) for more
32 | technical and design details.
33 | * The [Kafka Protocol Specification](https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol)
34 | contains a wealth of useful information.
35 | * For more general issues, there is [a google group](https://groups.google.com/forum/#!forum/kafka-clients) for Kafka client developers.
36 | * If you have any questions, just ask!
37 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/offset_fetch_request.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type OffsetFetchRequest struct {
4 | ConsumerGroup string
5 | Version int16
6 | partitions map[string][]int32
7 | }
8 |
9 | func (r *OffsetFetchRequest) encode(pe packetEncoder) (err error) {
10 | if r.Version < 0 || r.Version > 1 {
11 | return PacketEncodingError{"invalid or unsupported OffsetFetchRequest version field"}
12 | }
13 |
14 | if err = pe.putString(r.ConsumerGroup); err != nil {
15 | return err
16 | }
17 | if err = pe.putArrayLength(len(r.partitions)); err != nil {
18 | return err
19 | }
20 | for topic, partitions := range r.partitions {
21 | if err = pe.putString(topic); err != nil {
22 | return err
23 | }
24 | if err = pe.putInt32Array(partitions); err != nil {
25 | return err
26 | }
27 | }
28 | return nil
29 | }
30 |
31 | func (r *OffsetFetchRequest) decode(pd packetDecoder, version int16) (err error) {
32 | r.Version = version
33 | if r.ConsumerGroup, err = pd.getString(); err != nil {
34 | return err
35 | }
36 | partitionCount, err := pd.getArrayLength()
37 | if err != nil {
38 | return err
39 | }
40 | if partitionCount == 0 {
41 | return nil
42 | }
43 | r.partitions = make(map[string][]int32)
44 | for i := 0; i < partitionCount; i++ {
45 | topic, err := pd.getString()
46 | if err != nil {
47 | return err
48 | }
49 | partitions, err := pd.getInt32Array()
50 | if err != nil {
51 | return err
52 | }
53 | r.partitions[topic] = partitions
54 | }
55 | return nil
56 | }
57 |
58 | func (r *OffsetFetchRequest) key() int16 {
59 | return 9
60 | }
61 |
62 | func (r *OffsetFetchRequest) version() int16 {
63 | return r.Version
64 | }
65 |
66 | func (r *OffsetFetchRequest) requiredVersion() KafkaVersion {
67 | switch r.Version {
68 | case 1:
69 | return V0_8_2_0
70 | default:
71 | return minVersion
72 | }
73 | }
74 |
75 | func (r *OffsetFetchRequest) AddPartition(topic string, partitionID int32) {
76 | if r.partitions == nil {
77 | r.partitions = make(map[string][]int32)
78 | }
79 |
80 | r.partitions[topic] = append(r.partitions[topic], partitionID)
81 | }
82 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/offset_fetch_request.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type OffsetFetchRequest struct {
4 | ConsumerGroup string
5 | Version int16
6 | partitions map[string][]int32
7 | }
8 |
9 | func (r *OffsetFetchRequest) encode(pe packetEncoder) (err error) {
10 | if r.Version < 0 || r.Version > 1 {
11 | return PacketEncodingError{"invalid or unsupported OffsetFetchRequest version field"}
12 | }
13 |
14 | if err = pe.putString(r.ConsumerGroup); err != nil {
15 | return err
16 | }
17 | if err = pe.putArrayLength(len(r.partitions)); err != nil {
18 | return err
19 | }
20 | for topic, partitions := range r.partitions {
21 | if err = pe.putString(topic); err != nil {
22 | return err
23 | }
24 | if err = pe.putInt32Array(partitions); err != nil {
25 | return err
26 | }
27 | }
28 | return nil
29 | }
30 |
31 | func (r *OffsetFetchRequest) decode(pd packetDecoder, version int16) (err error) {
32 | r.Version = version
33 | if r.ConsumerGroup, err = pd.getString(); err != nil {
34 | return err
35 | }
36 | partitionCount, err := pd.getArrayLength()
37 | if err != nil {
38 | return err
39 | }
40 | if partitionCount == 0 {
41 | return nil
42 | }
43 | r.partitions = make(map[string][]int32)
44 | for i := 0; i < partitionCount; i++ {
45 | topic, err := pd.getString()
46 | if err != nil {
47 | return err
48 | }
49 | partitions, err := pd.getInt32Array()
50 | if err != nil {
51 | return err
52 | }
53 | r.partitions[topic] = partitions
54 | }
55 | return nil
56 | }
57 |
58 | func (r *OffsetFetchRequest) key() int16 {
59 | return 9
60 | }
61 |
62 | func (r *OffsetFetchRequest) version() int16 {
63 | return r.Version
64 | }
65 |
66 | func (r *OffsetFetchRequest) requiredVersion() KafkaVersion {
67 | switch r.Version {
68 | case 1:
69 | return V0_8_2_0
70 | default:
71 | return minVersion
72 | }
73 | }
74 |
75 | func (r *OffsetFetchRequest) AddPartition(topic string, partitionID int32) {
76 | if r.partitions == nil {
77 | r.partitions = make(map[string][]int32)
78 | }
79 |
80 | r.partitions[topic] = append(r.partitions[topic], partitionID)
81 | }
82 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/offset_commit_response.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type OffsetCommitResponse struct {
4 | Errors map[string]map[int32]KError
5 | }
6 |
7 | func (r *OffsetCommitResponse) AddError(topic string, partition int32, kerror KError) {
8 | if r.Errors == nil {
9 | r.Errors = make(map[string]map[int32]KError)
10 | }
11 | partitions := r.Errors[topic]
12 | if partitions == nil {
13 | partitions = make(map[int32]KError)
14 | r.Errors[topic] = partitions
15 | }
16 | partitions[partition] = kerror
17 | }
18 |
19 | func (r *OffsetCommitResponse) encode(pe packetEncoder) error {
20 | if err := pe.putArrayLength(len(r.Errors)); err != nil {
21 | return err
22 | }
23 | for topic, partitions := range r.Errors {
24 | if err := pe.putString(topic); err != nil {
25 | return err
26 | }
27 | if err := pe.putArrayLength(len(partitions)); err != nil {
28 | return err
29 | }
30 | for partition, kerror := range partitions {
31 | pe.putInt32(partition)
32 | pe.putInt16(int16(kerror))
33 | }
34 | }
35 | return nil
36 | }
37 |
38 | func (r *OffsetCommitResponse) decode(pd packetDecoder, version int16) (err error) {
39 | numTopics, err := pd.getArrayLength()
40 | if err != nil || numTopics == 0 {
41 | return err
42 | }
43 |
44 | r.Errors = make(map[string]map[int32]KError, numTopics)
45 | for i := 0; i < numTopics; i++ {
46 | name, err := pd.getString()
47 | if err != nil {
48 | return err
49 | }
50 |
51 | numErrors, err := pd.getArrayLength()
52 | if err != nil {
53 | return err
54 | }
55 |
56 | r.Errors[name] = make(map[int32]KError, numErrors)
57 |
58 | for j := 0; j < numErrors; j++ {
59 | id, err := pd.getInt32()
60 | if err != nil {
61 | return err
62 | }
63 |
64 | tmp, err := pd.getInt16()
65 | if err != nil {
66 | return err
67 | }
68 | r.Errors[name][id] = KError(tmp)
69 | }
70 | }
71 |
72 | return nil
73 | }
74 |
75 | func (r *OffsetCommitResponse) key() int16 {
76 | return 8
77 | }
78 |
79 | func (r *OffsetCommitResponse) version() int16 {
80 | return 0
81 | }
82 |
83 | func (r *OffsetCommitResponse) requiredVersion() KafkaVersion {
84 | return minVersion
85 | }
86 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/offset_commit_response.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type OffsetCommitResponse struct {
4 | Errors map[string]map[int32]KError
5 | }
6 |
7 | func (r *OffsetCommitResponse) AddError(topic string, partition int32, kerror KError) {
8 | if r.Errors == nil {
9 | r.Errors = make(map[string]map[int32]KError)
10 | }
11 | partitions := r.Errors[topic]
12 | if partitions == nil {
13 | partitions = make(map[int32]KError)
14 | r.Errors[topic] = partitions
15 | }
16 | partitions[partition] = kerror
17 | }
18 |
19 | func (r *OffsetCommitResponse) encode(pe packetEncoder) error {
20 | if err := pe.putArrayLength(len(r.Errors)); err != nil {
21 | return err
22 | }
23 | for topic, partitions := range r.Errors {
24 | if err := pe.putString(topic); err != nil {
25 | return err
26 | }
27 | if err := pe.putArrayLength(len(partitions)); err != nil {
28 | return err
29 | }
30 | for partition, kerror := range partitions {
31 | pe.putInt32(partition)
32 | pe.putInt16(int16(kerror))
33 | }
34 | }
35 | return nil
36 | }
37 |
38 | func (r *OffsetCommitResponse) decode(pd packetDecoder, version int16) (err error) {
39 | numTopics, err := pd.getArrayLength()
40 | if err != nil || numTopics == 0 {
41 | return err
42 | }
43 |
44 | r.Errors = make(map[string]map[int32]KError, numTopics)
45 | for i := 0; i < numTopics; i++ {
46 | name, err := pd.getString()
47 | if err != nil {
48 | return err
49 | }
50 |
51 | numErrors, err := pd.getArrayLength()
52 | if err != nil {
53 | return err
54 | }
55 |
56 | r.Errors[name] = make(map[int32]KError, numErrors)
57 |
58 | for j := 0; j < numErrors; j++ {
59 | id, err := pd.getInt32()
60 | if err != nil {
61 | return err
62 | }
63 |
64 | tmp, err := pd.getInt16()
65 | if err != nil {
66 | return err
67 | }
68 | r.Errors[name][id] = KError(tmp)
69 | }
70 | }
71 |
72 | return nil
73 | }
74 |
75 | func (r *OffsetCommitResponse) key() int16 {
76 | return 8
77 | }
78 |
79 | func (r *OffsetCommitResponse) version() int16 {
80 | return 0
81 | }
82 |
83 | func (r *OffsetCommitResponse) requiredVersion() KafkaVersion {
84 | return minVersion
85 | }
86 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/consumer_group_members.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type ConsumerGroupMemberMetadata struct {
4 | Version int16
5 | Topics []string
6 | UserData []byte
7 | }
8 |
9 | func (m *ConsumerGroupMemberMetadata) encode(pe packetEncoder) error {
10 | pe.putInt16(m.Version)
11 |
12 | if err := pe.putStringArray(m.Topics); err != nil {
13 | return err
14 | }
15 |
16 | if err := pe.putBytes(m.UserData); err != nil {
17 | return err
18 | }
19 |
20 | return nil
21 | }
22 |
23 | func (m *ConsumerGroupMemberMetadata) decode(pd packetDecoder) (err error) {
24 | if m.Version, err = pd.getInt16(); err != nil {
25 | return
26 | }
27 |
28 | if m.Topics, err = pd.getStringArray(); err != nil {
29 | return
30 | }
31 |
32 | if m.UserData, err = pd.getBytes(); err != nil {
33 | return
34 | }
35 |
36 | return nil
37 | }
38 |
39 | type ConsumerGroupMemberAssignment struct {
40 | Version int16
41 | Topics map[string][]int32
42 | UserData []byte
43 | }
44 |
45 | func (m *ConsumerGroupMemberAssignment) encode(pe packetEncoder) error {
46 | pe.putInt16(m.Version)
47 |
48 | if err := pe.putArrayLength(len(m.Topics)); err != nil {
49 | return err
50 | }
51 |
52 | for topic, partitions := range m.Topics {
53 | if err := pe.putString(topic); err != nil {
54 | return err
55 | }
56 | if err := pe.putInt32Array(partitions); err != nil {
57 | return err
58 | }
59 | }
60 |
61 | if err := pe.putBytes(m.UserData); err != nil {
62 | return err
63 | }
64 |
65 | return nil
66 | }
67 |
68 | func (m *ConsumerGroupMemberAssignment) decode(pd packetDecoder) (err error) {
69 | if m.Version, err = pd.getInt16(); err != nil {
70 | return
71 | }
72 |
73 | var topicLen int
74 | if topicLen, err = pd.getArrayLength(); err != nil {
75 | return
76 | }
77 |
78 | m.Topics = make(map[string][]int32, topicLen)
79 | for i := 0; i < topicLen; i++ {
80 | var topic string
81 | if topic, err = pd.getString(); err != nil {
82 | return
83 | }
84 | if m.Topics[topic], err = pd.getInt32Array(); err != nil {
85 | return
86 | }
87 | }
88 |
89 | if m.UserData, err = pd.getBytes(); err != nil {
90 | return
91 | }
92 |
93 | return nil
94 | }
95 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/consumer_group_members.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type ConsumerGroupMemberMetadata struct {
4 | Version int16
5 | Topics []string
6 | UserData []byte
7 | }
8 |
9 | func (m *ConsumerGroupMemberMetadata) encode(pe packetEncoder) error {
10 | pe.putInt16(m.Version)
11 |
12 | if err := pe.putStringArray(m.Topics); err != nil {
13 | return err
14 | }
15 |
16 | if err := pe.putBytes(m.UserData); err != nil {
17 | return err
18 | }
19 |
20 | return nil
21 | }
22 |
23 | func (m *ConsumerGroupMemberMetadata) decode(pd packetDecoder) (err error) {
24 | if m.Version, err = pd.getInt16(); err != nil {
25 | return
26 | }
27 |
28 | if m.Topics, err = pd.getStringArray(); err != nil {
29 | return
30 | }
31 |
32 | if m.UserData, err = pd.getBytes(); err != nil {
33 | return
34 | }
35 |
36 | return nil
37 | }
38 |
39 | type ConsumerGroupMemberAssignment struct {
40 | Version int16
41 | Topics map[string][]int32
42 | UserData []byte
43 | }
44 |
45 | func (m *ConsumerGroupMemberAssignment) encode(pe packetEncoder) error {
46 | pe.putInt16(m.Version)
47 |
48 | if err := pe.putArrayLength(len(m.Topics)); err != nil {
49 | return err
50 | }
51 |
52 | for topic, partitions := range m.Topics {
53 | if err := pe.putString(topic); err != nil {
54 | return err
55 | }
56 | if err := pe.putInt32Array(partitions); err != nil {
57 | return err
58 | }
59 | }
60 |
61 | if err := pe.putBytes(m.UserData); err != nil {
62 | return err
63 | }
64 |
65 | return nil
66 | }
67 |
68 | func (m *ConsumerGroupMemberAssignment) decode(pd packetDecoder) (err error) {
69 | if m.Version, err = pd.getInt16(); err != nil {
70 | return
71 | }
72 |
73 | var topicLen int
74 | if topicLen, err = pd.getArrayLength(); err != nil {
75 | return
76 | }
77 |
78 | m.Topics = make(map[string][]int32, topicLen)
79 | for i := 0; i < topicLen; i++ {
80 | var topic string
81 | if topic, err = pd.getString(); err != nil {
82 | return
83 | }
84 | if m.Topics[topic], err = pd.getInt32Array(); err != nil {
85 | return
86 | }
87 | }
88 |
89 | if m.UserData, err = pd.getBytes(); err != nil {
90 | return
91 | }
92 |
93 | return nil
94 | }
95 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/encoder_decoder.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | import "fmt"
4 |
5 | // Encoder is the interface that wraps the basic Encode method.
6 | // Anything implementing Encoder can be turned into bytes using Kafka's encoding rules.
7 | type encoder interface {
8 | encode(pe packetEncoder) error
9 | }
10 |
11 | // Encode takes an Encoder and turns it into bytes.
12 | func encode(e encoder) ([]byte, error) {
13 | if e == nil {
14 | return nil, nil
15 | }
16 |
17 | var prepEnc prepEncoder
18 | var realEnc realEncoder
19 |
20 | err := e.encode(&prepEnc)
21 | if err != nil {
22 | return nil, err
23 | }
24 |
25 | if prepEnc.length < 0 || prepEnc.length > int(MaxRequestSize) {
26 | return nil, PacketEncodingError{fmt.Sprintf("invalid request size (%d)", prepEnc.length)}
27 | }
28 |
29 | realEnc.raw = make([]byte, prepEnc.length)
30 | err = e.encode(&realEnc)
31 | if err != nil {
32 | return nil, err
33 | }
34 |
35 | return realEnc.raw, nil
36 | }
37 |
38 | // Decoder is the interface that wraps the basic Decode method.
39 | // Anything implementing Decoder can be extracted from bytes using Kafka's encoding rules.
40 | type decoder interface {
41 | decode(pd packetDecoder) error
42 | }
43 |
44 | type versionedDecoder interface {
45 | decode(pd packetDecoder, version int16) error
46 | }
47 |
48 | // Decode takes bytes and a Decoder and fills the fields of the decoder from the bytes,
49 | // interpreted using Kafka's encoding rules.
50 | func decode(buf []byte, in decoder) error {
51 | if buf == nil {
52 | return nil
53 | }
54 |
55 | helper := realDecoder{raw: buf}
56 | err := in.decode(&helper)
57 | if err != nil {
58 | return err
59 | }
60 |
61 | if helper.off != len(buf) {
62 | return PacketDecodingError{"invalid length"}
63 | }
64 |
65 | return nil
66 | }
67 |
68 | func versionedDecode(buf []byte, in versionedDecoder, version int16) error {
69 | if buf == nil {
70 | return nil
71 | }
72 |
73 | helper := realDecoder{raw: buf}
74 | err := in.decode(&helper, version)
75 | if err != nil {
76 | return err
77 | }
78 |
79 | if helper.off != len(buf) {
80 | return PacketDecodingError{"invalid length"}
81 | }
82 |
83 | return nil
84 | }
85 |
--------------------------------------------------------------------------------
/go/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "os"
6 | "os/signal"
7 |
8 | "github.com/Shopify/sarama"
9 | "github.com/spf13/cobra"
10 | "gopkg.in/bsm/sarama-cluster.v2"
11 | )
12 |
13 | var (
14 | BrokerAddrs string
15 | Topic string
16 | Username string
17 | Password string
18 | ConsumerGroup string
19 |
20 | Verbose bool
21 |
22 | Cli *cobra.Command
23 |
24 | Producer sarama.SyncProducer
25 | Consumer *cluster.Consumer
26 | )
27 |
28 | func init() {
29 | //sarama.Logger = log.New(os.Stderr, "[debug-sarama] ", log.LstdFlags)
30 |
31 | Cli = &cobra.Command{
32 | Use: "kafka-client",
33 | Short: "Go Kafka client to produce/consume using SASL/SSL",
34 | }
35 |
36 | Cli.PersistentFlags().StringVar(&BrokerAddrs, "brokers", "", "List of Kafka broker addresses separated by commas")
37 | Cli.PersistentFlags().StringVar(&Topic, "topic", "", "Topic, prefixed by your namespace (eg. --topic=myns.topic)")
38 | Cli.PersistentFlags().StringVar(&Username, "username", "", "SASL username, prefixed by your namespace (eg. --username=myns.user)")
39 | Cli.PersistentFlags().StringVar(&Password, "password", "", "SASL password")
40 | Cli.PersistentFlags().StringVar(&ConsumerGroup, "consumer-group", "", "Consumer group, prefixed by your SASL username (eg. --consumer-group=myns.user.g1)")
41 | Cli.PersistentFlags().BoolVar(&Verbose, "verbose", false, "Verbose mode")
42 |
43 | Cli.AddCommand(&cobra.Command{
44 | Use: "consume",
45 | Short: "Consume messages",
46 | Run: Consume,
47 | })
48 |
49 | Cli.AddCommand(&cobra.Command{
50 | Use: "produce",
51 | Short: "Produce messages",
52 | Run: Produce,
53 | })
54 | }
55 |
56 | func main() {
57 | SetupGracefulShutdown()
58 |
59 | err := Cli.Execute()
60 | HandleError(err)
61 | }
62 |
63 | func HandleError(err error) {
64 | if err != nil {
65 | fmt.Println("An error occurred: ", err.Error())
66 | os.Exit(1)
67 | }
68 | }
69 |
70 | func SetupGracefulShutdown() {
71 | c := make(chan os.Signal, 1)
72 | signal.Notify(c, os.Interrupt)
73 | go func() {
74 | <-c
75 | if Producer != nil {
76 | Producer.Close()
77 | }
78 | if Consumer != nil {
79 | Consumer.Close()
80 | }
81 | os.Exit(1)
82 | }()
83 | }
84 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/message_set.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type MessageBlock struct {
4 | Offset int64
5 | Msg *Message
6 | }
7 |
8 | // Messages convenience helper which returns either all the
9 | // messages that are wrapped in this block
10 | func (msb *MessageBlock) Messages() []*MessageBlock {
11 | if msb.Msg.Set != nil {
12 | return msb.Msg.Set.Messages
13 | }
14 | return []*MessageBlock{msb}
15 | }
16 |
17 | func (msb *MessageBlock) encode(pe packetEncoder) error {
18 | pe.putInt64(msb.Offset)
19 | pe.push(&lengthField{})
20 | err := msb.Msg.encode(pe)
21 | if err != nil {
22 | return err
23 | }
24 | return pe.pop()
25 | }
26 |
27 | func (msb *MessageBlock) decode(pd packetDecoder) (err error) {
28 | if msb.Offset, err = pd.getInt64(); err != nil {
29 | return err
30 | }
31 |
32 | if err = pd.push(&lengthField{}); err != nil {
33 | return err
34 | }
35 |
36 | msb.Msg = new(Message)
37 | if err = msb.Msg.decode(pd); err != nil {
38 | return err
39 | }
40 |
41 | if err = pd.pop(); err != nil {
42 | return err
43 | }
44 |
45 | return nil
46 | }
47 |
48 | type MessageSet struct {
49 | PartialTrailingMessage bool // whether the set on the wire contained an incomplete trailing MessageBlock
50 | Messages []*MessageBlock
51 | }
52 |
53 | func (ms *MessageSet) encode(pe packetEncoder) error {
54 | for i := range ms.Messages {
55 | err := ms.Messages[i].encode(pe)
56 | if err != nil {
57 | return err
58 | }
59 | }
60 | return nil
61 | }
62 |
63 | func (ms *MessageSet) decode(pd packetDecoder) (err error) {
64 | ms.Messages = nil
65 |
66 | for pd.remaining() > 0 {
67 | msb := new(MessageBlock)
68 | err = msb.decode(pd)
69 | switch err {
70 | case nil:
71 | ms.Messages = append(ms.Messages, msb)
72 | case ErrInsufficientData:
73 | // As an optimization the server is allowed to return a partial message at the
74 | // end of the message set. Clients should handle this case. So we just ignore such things.
75 | ms.PartialTrailingMessage = true
76 | return nil
77 | default:
78 | return err
79 | }
80 | }
81 |
82 | return nil
83 | }
84 |
85 | func (ms *MessageSet) addMessage(msg *Message) {
86 | block := new(MessageBlock)
87 | block.Msg = msg
88 | ms.Messages = append(ms.Messages, block)
89 | }
90 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/message_set.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type MessageBlock struct {
4 | Offset int64
5 | Msg *Message
6 | }
7 |
8 | // Messages convenience helper which returns either all the
9 | // messages that are wrapped in this block
10 | func (msb *MessageBlock) Messages() []*MessageBlock {
11 | if msb.Msg.Set != nil {
12 | return msb.Msg.Set.Messages
13 | }
14 | return []*MessageBlock{msb}
15 | }
16 |
17 | func (msb *MessageBlock) encode(pe packetEncoder) error {
18 | pe.putInt64(msb.Offset)
19 | pe.push(&lengthField{})
20 | err := msb.Msg.encode(pe)
21 | if err != nil {
22 | return err
23 | }
24 | return pe.pop()
25 | }
26 |
27 | func (msb *MessageBlock) decode(pd packetDecoder) (err error) {
28 | if msb.Offset, err = pd.getInt64(); err != nil {
29 | return err
30 | }
31 |
32 | if err = pd.push(&lengthField{}); err != nil {
33 | return err
34 | }
35 |
36 | msb.Msg = new(Message)
37 | if err = msb.Msg.decode(pd); err != nil {
38 | return err
39 | }
40 |
41 | if err = pd.pop(); err != nil {
42 | return err
43 | }
44 |
45 | return nil
46 | }
47 |
48 | type MessageSet struct {
49 | PartialTrailingMessage bool // whether the set on the wire contained an incomplete trailing MessageBlock
50 | Messages []*MessageBlock
51 | }
52 |
53 | func (ms *MessageSet) encode(pe packetEncoder) error {
54 | for i := range ms.Messages {
55 | err := ms.Messages[i].encode(pe)
56 | if err != nil {
57 | return err
58 | }
59 | }
60 | return nil
61 | }
62 |
63 | func (ms *MessageSet) decode(pd packetDecoder) (err error) {
64 | ms.Messages = nil
65 |
66 | for pd.remaining() > 0 {
67 | msb := new(MessageBlock)
68 | err = msb.decode(pd)
69 | switch err {
70 | case nil:
71 | ms.Messages = append(ms.Messages, msb)
72 | case ErrInsufficientData:
73 | // As an optimization the server is allowed to return a partial message at the
74 | // end of the message set. Clients should handle this case. So we just ignore such things.
75 | ms.PartialTrailingMessage = true
76 | return nil
77 | default:
78 | return err
79 | }
80 | }
81 |
82 | return nil
83 | }
84 |
85 | func (ms *MessageSet) addMessage(msg *Message) {
86 | block := new(MessageBlock)
87 | block.Msg = msg
88 | ms.Messages = append(ms.Messages, block)
89 | }
90 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/consumer_metadata_response.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | import (
4 | "net"
5 | "strconv"
6 | )
7 |
8 | type ConsumerMetadataResponse struct {
9 | Err KError
10 | Coordinator *Broker
11 | CoordinatorID int32 // deprecated: use Coordinator.ID()
12 | CoordinatorHost string // deprecated: use Coordinator.Addr()
13 | CoordinatorPort int32 // deprecated: use Coordinator.Addr()
14 | }
15 |
16 | func (r *ConsumerMetadataResponse) decode(pd packetDecoder, version int16) (err error) {
17 | tmp, err := pd.getInt16()
18 | if err != nil {
19 | return err
20 | }
21 | r.Err = KError(tmp)
22 |
23 | coordinator := new(Broker)
24 | if err := coordinator.decode(pd); err != nil {
25 | return err
26 | }
27 | if coordinator.addr == ":0" {
28 | return nil
29 | }
30 | r.Coordinator = coordinator
31 |
32 | // this can all go away in 2.0, but we have to fill in deprecated fields to maintain
33 | // backwards compatibility
34 | host, portstr, err := net.SplitHostPort(r.Coordinator.Addr())
35 | if err != nil {
36 | return err
37 | }
38 | port, err := strconv.ParseInt(portstr, 10, 32)
39 | if err != nil {
40 | return err
41 | }
42 | r.CoordinatorID = r.Coordinator.ID()
43 | r.CoordinatorHost = host
44 | r.CoordinatorPort = int32(port)
45 |
46 | return nil
47 | }
48 |
49 | func (r *ConsumerMetadataResponse) encode(pe packetEncoder) error {
50 | pe.putInt16(int16(r.Err))
51 | if r.Coordinator != nil {
52 | host, portstr, err := net.SplitHostPort(r.Coordinator.Addr())
53 | if err != nil {
54 | return err
55 | }
56 | port, err := strconv.ParseInt(portstr, 10, 32)
57 | if err != nil {
58 | return err
59 | }
60 | pe.putInt32(r.Coordinator.ID())
61 | if err := pe.putString(host); err != nil {
62 | return err
63 | }
64 | pe.putInt32(int32(port))
65 | return nil
66 | }
67 | pe.putInt32(r.CoordinatorID)
68 | if err := pe.putString(r.CoordinatorHost); err != nil {
69 | return err
70 | }
71 | pe.putInt32(r.CoordinatorPort)
72 | return nil
73 | }
74 |
75 | func (r *ConsumerMetadataResponse) key() int16 {
76 | return 10
77 | }
78 |
79 | func (r *ConsumerMetadataResponse) version() int16 {
80 | return 0
81 | }
82 |
83 | func (r *ConsumerMetadataResponse) requiredVersion() KafkaVersion {
84 | return V0_8_2_0
85 | }
86 |
--------------------------------------------------------------------------------
/go/vendor/github.com/rcrowley/go-metrics/syslog.go:
--------------------------------------------------------------------------------
1 | // +build !windows
2 |
3 | package metrics
4 |
5 | import (
6 | "fmt"
7 | "log/syslog"
8 | "time"
9 | )
10 |
11 | // Output each metric in the given registry to syslog periodically using
12 | // the given syslogger.
13 | func Syslog(r Registry, d time.Duration, w *syslog.Writer) {
14 | for _ = range time.Tick(d) {
15 | r.Each(func(name string, i interface{}) {
16 | switch metric := i.(type) {
17 | case Counter:
18 | w.Info(fmt.Sprintf("counter %s: count: %d", name, metric.Count()))
19 | case Gauge:
20 | w.Info(fmt.Sprintf("gauge %s: value: %d", name, metric.Value()))
21 | case GaugeFloat64:
22 | w.Info(fmt.Sprintf("gauge %s: value: %f", name, metric.Value()))
23 | case Healthcheck:
24 | metric.Check()
25 | w.Info(fmt.Sprintf("healthcheck %s: error: %v", name, metric.Error()))
26 | case Histogram:
27 | h := metric.Snapshot()
28 | ps := h.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
29 | w.Info(fmt.Sprintf(
30 | "histogram %s: count: %d min: %d max: %d mean: %.2f stddev: %.2f median: %.2f 75%%: %.2f 95%%: %.2f 99%%: %.2f 99.9%%: %.2f",
31 | name,
32 | h.Count(),
33 | h.Min(),
34 | h.Max(),
35 | h.Mean(),
36 | h.StdDev(),
37 | ps[0],
38 | ps[1],
39 | ps[2],
40 | ps[3],
41 | ps[4],
42 | ))
43 | case Meter:
44 | m := metric.Snapshot()
45 | w.Info(fmt.Sprintf(
46 | "meter %s: count: %d 1-min: %.2f 5-min: %.2f 15-min: %.2f mean: %.2f",
47 | name,
48 | m.Count(),
49 | m.Rate1(),
50 | m.Rate5(),
51 | m.Rate15(),
52 | m.RateMean(),
53 | ))
54 | case Timer:
55 | t := metric.Snapshot()
56 | ps := t.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
57 | w.Info(fmt.Sprintf(
58 | "timer %s: count: %d min: %d max: %d mean: %.2f stddev: %.2f median: %.2f 75%%: %.2f 95%%: %.2f 99%%: %.2f 99.9%%: %.2f 1-min: %.2f 5-min: %.2f 15-min: %.2f mean-rate: %.2f",
59 | name,
60 | t.Count(),
61 | t.Min(),
62 | t.Max(),
63 | t.Mean(),
64 | t.StdDev(),
65 | ps[0],
66 | ps[1],
67 | ps[2],
68 | ps[3],
69 | ps[4],
70 | t.Rate1(),
71 | t.Rate5(),
72 | t.Rate15(),
73 | t.RateMean(),
74 | ))
75 | }
76 | })
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/consumer_metadata_response.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | import (
4 | "net"
5 | "strconv"
6 | )
7 |
8 | type ConsumerMetadataResponse struct {
9 | Err KError
10 | Coordinator *Broker
11 | CoordinatorID int32 // deprecated: use Coordinator.ID()
12 | CoordinatorHost string // deprecated: use Coordinator.Addr()
13 | CoordinatorPort int32 // deprecated: use Coordinator.Addr()
14 | }
15 |
16 | func (r *ConsumerMetadataResponse) decode(pd packetDecoder, version int16) (err error) {
17 | tmp, err := pd.getInt16()
18 | if err != nil {
19 | return err
20 | }
21 | r.Err = KError(tmp)
22 |
23 | coordinator := new(Broker)
24 | if err := coordinator.decode(pd); err != nil {
25 | return err
26 | }
27 | if coordinator.addr == ":0" {
28 | return nil
29 | }
30 | r.Coordinator = coordinator
31 |
32 | // this can all go away in 2.0, but we have to fill in deprecated fields to maintain
33 | // backwards compatibility
34 | host, portstr, err := net.SplitHostPort(r.Coordinator.Addr())
35 | if err != nil {
36 | return err
37 | }
38 | port, err := strconv.ParseInt(portstr, 10, 32)
39 | if err != nil {
40 | return err
41 | }
42 | r.CoordinatorID = r.Coordinator.ID()
43 | r.CoordinatorHost = host
44 | r.CoordinatorPort = int32(port)
45 |
46 | return nil
47 | }
48 |
49 | func (r *ConsumerMetadataResponse) encode(pe packetEncoder) error {
50 | pe.putInt16(int16(r.Err))
51 | if r.Coordinator != nil {
52 | host, portstr, err := net.SplitHostPort(r.Coordinator.Addr())
53 | if err != nil {
54 | return err
55 | }
56 | port, err := strconv.ParseInt(portstr, 10, 32)
57 | if err != nil {
58 | return err
59 | }
60 | pe.putInt32(r.Coordinator.ID())
61 | if err := pe.putString(host); err != nil {
62 | return err
63 | }
64 | pe.putInt32(int32(port))
65 | return nil
66 | }
67 | pe.putInt32(r.CoordinatorID)
68 | if err := pe.putString(r.CoordinatorHost); err != nil {
69 | return err
70 | }
71 | pe.putInt32(r.CoordinatorPort)
72 | return nil
73 | }
74 |
75 | func (r *ConsumerMetadataResponse) key() int16 {
76 | return 10
77 | }
78 |
79 | func (r *ConsumerMetadataResponse) version() int16 {
80 | return 0
81 | }
82 |
83 | func (r *ConsumerMetadataResponse) requiredVersion() KafkaVersion {
84 | return V0_8_2_0
85 | }
86 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/encoder_decoder.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | import (
4 | "fmt"
5 |
6 | "github.com/rcrowley/go-metrics"
7 | )
8 |
9 | // Encoder is the interface that wraps the basic Encode method.
10 | // Anything implementing Encoder can be turned into bytes using Kafka's encoding rules.
11 | type encoder interface {
12 | encode(pe packetEncoder) error
13 | }
14 |
15 | // Encode takes an Encoder and turns it into bytes while potentially recording metrics.
16 | func encode(e encoder, metricRegistry metrics.Registry) ([]byte, error) {
17 | if e == nil {
18 | return nil, nil
19 | }
20 |
21 | var prepEnc prepEncoder
22 | var realEnc realEncoder
23 |
24 | err := e.encode(&prepEnc)
25 | if err != nil {
26 | return nil, err
27 | }
28 |
29 | if prepEnc.length < 0 || prepEnc.length > int(MaxRequestSize) {
30 | return nil, PacketEncodingError{fmt.Sprintf("invalid request size (%d)", prepEnc.length)}
31 | }
32 |
33 | realEnc.raw = make([]byte, prepEnc.length)
34 | realEnc.registry = metricRegistry
35 | err = e.encode(&realEnc)
36 | if err != nil {
37 | return nil, err
38 | }
39 |
40 | return realEnc.raw, nil
41 | }
42 |
43 | // Decoder is the interface that wraps the basic Decode method.
44 | // Anything implementing Decoder can be extracted from bytes using Kafka's encoding rules.
45 | type decoder interface {
46 | decode(pd packetDecoder) error
47 | }
48 |
49 | type versionedDecoder interface {
50 | decode(pd packetDecoder, version int16) error
51 | }
52 |
53 | // Decode takes bytes and a Decoder and fills the fields of the decoder from the bytes,
54 | // interpreted using Kafka's encoding rules.
55 | func decode(buf []byte, in decoder) error {
56 | if buf == nil {
57 | return nil
58 | }
59 |
60 | helper := realDecoder{raw: buf}
61 | err := in.decode(&helper)
62 | if err != nil {
63 | return err
64 | }
65 |
66 | if helper.off != len(buf) {
67 | return PacketDecodingError{"invalid length"}
68 | }
69 |
70 | return nil
71 | }
72 |
73 | func versionedDecode(buf []byte, in versionedDecoder, version int16) error {
74 | if buf == nil {
75 | return nil
76 | }
77 |
78 | helper := realDecoder{raw: buf}
79 | err := in.decode(&helper, version)
80 | if err != nil {
81 | return err
82 | }
83 |
84 | if helper.off != len(buf) {
85 | return PacketDecodingError{"invalid length"}
86 | }
87 |
88 | return nil
89 | }
90 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/metrics.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | import (
4 | "fmt"
5 | "strings"
6 |
7 | "github.com/rcrowley/go-metrics"
8 | )
9 |
10 | // Use exponentially decaying reservoir for sampling histograms with the same defaults as the Java library:
11 | // 1028 elements, which offers a 99.9% confidence level with a 5% margin of error assuming a normal distribution,
12 | // and an alpha factor of 0.015, which heavily biases the reservoir to the past 5 minutes of measurements.
13 | // See https://github.com/dropwizard/metrics/blob/v3.1.0/metrics-core/src/main/java/com/codahale/metrics/ExponentiallyDecayingReservoir.java#L38
14 | const (
15 | metricsReservoirSize = 1028
16 | metricsAlphaFactor = 0.015
17 | )
18 |
19 | func getOrRegisterHistogram(name string, r metrics.Registry) metrics.Histogram {
20 | return r.GetOrRegister(name, func() metrics.Histogram {
21 | return metrics.NewHistogram(metrics.NewExpDecaySample(metricsReservoirSize, metricsAlphaFactor))
22 | }).(metrics.Histogram)
23 | }
24 |
25 | func getMetricNameForBroker(name string, broker *Broker) string {
26 | // Use broker id like the Java client as it does not contain '.' or ':' characters that
27 | // can be interpreted as special character by monitoring tool (e.g. Graphite)
28 | return fmt.Sprintf(name+"-for-broker-%d", broker.ID())
29 | }
30 |
31 | func getOrRegisterBrokerMeter(name string, broker *Broker, r metrics.Registry) metrics.Meter {
32 | return metrics.GetOrRegisterMeter(getMetricNameForBroker(name, broker), r)
33 | }
34 |
35 | func getOrRegisterBrokerHistogram(name string, broker *Broker, r metrics.Registry) metrics.Histogram {
36 | return getOrRegisterHistogram(getMetricNameForBroker(name, broker), r)
37 | }
38 |
39 | func getMetricNameForTopic(name string, topic string) string {
40 | // Convert dot to _ since reporters like Graphite typically use dot to represent hierarchy
41 | // cf. KAFKA-1902 and KAFKA-2337
42 | return fmt.Sprintf(name+"-for-topic-%s", strings.Replace(topic, ".", "_", -1))
43 | }
44 |
45 | func getOrRegisterTopicMeter(name string, topic string, r metrics.Registry) metrics.Meter {
46 | return metrics.GetOrRegisterMeter(getMetricNameForTopic(name, topic), r)
47 | }
48 |
49 | func getOrRegisterTopicHistogram(name string, topic string, r metrics.Registry) metrics.Histogram {
50 | return getOrRegisterHistogram(getMetricNameForTopic(name, topic), r)
51 | }
52 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Sirupsen/logrus/alt_exit.go:
--------------------------------------------------------------------------------
1 | package logrus
2 |
3 | // The following code was sourced and modified from the
4 | // https://bitbucket.org/tebeka/atexit package governed by the following license:
5 | //
6 | // Copyright (c) 2012 Miki Tebeka .
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of
9 | // this software and associated documentation files (the "Software"), to deal in
10 | // the Software without restriction, including without limitation the rights to
11 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
12 | // the Software, and to permit persons to whom the Software is furnished to do so,
13 | // subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in all
16 | // copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
20 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
21 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 |
25 | import (
26 | "fmt"
27 | "os"
28 | )
29 |
30 | var handlers = []func(){}
31 |
32 | func runHandler(handler func()) {
33 | defer func() {
34 | if err := recover(); err != nil {
35 | fmt.Fprintln(os.Stderr, "Error: Logrus exit handler error:", err)
36 | }
37 | }()
38 |
39 | handler()
40 | }
41 |
42 | func runHandlers() {
43 | for _, handler := range handlers {
44 | runHandler(handler)
45 | }
46 | }
47 |
48 | // Exit runs all the Logrus atexit handlers and then terminates the program using os.Exit(code)
49 | func Exit(code int) {
50 | runHandlers()
51 | os.Exit(code)
52 | }
53 |
54 | // RegisterExitHandler adds a Logrus Exit handler, call logrus.Exit to invoke
55 | // all handlers. The handlers will also be invoked when any Fatal log entry is
56 | // made.
57 | //
58 | // This method is useful when a caller wishes to use logrus to log a fatal
59 | // message but also needs to gracefully shutdown. An example usecase could be
60 | // closing database connections, or sending a alert that the application is
61 | // closing.
62 | func RegisterExitHandler(handler func()) {
63 | handlers = append(handlers, handler)
64 | }
65 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/prep_encoder.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | import (
4 | "fmt"
5 | "math"
6 | )
7 |
8 | type prepEncoder struct {
9 | length int
10 | }
11 |
12 | // primitives
13 |
14 | func (pe *prepEncoder) putInt8(in int8) {
15 | pe.length++
16 | }
17 |
18 | func (pe *prepEncoder) putInt16(in int16) {
19 | pe.length += 2
20 | }
21 |
22 | func (pe *prepEncoder) putInt32(in int32) {
23 | pe.length += 4
24 | }
25 |
26 | func (pe *prepEncoder) putInt64(in int64) {
27 | pe.length += 8
28 | }
29 |
30 | func (pe *prepEncoder) putArrayLength(in int) error {
31 | if in > math.MaxInt32 {
32 | return PacketEncodingError{fmt.Sprintf("array too long (%d)", in)}
33 | }
34 | pe.length += 4
35 | return nil
36 | }
37 |
38 | // arrays
39 |
40 | func (pe *prepEncoder) putBytes(in []byte) error {
41 | pe.length += 4
42 | if in == nil {
43 | return nil
44 | }
45 | if len(in) > math.MaxInt32 {
46 | return PacketEncodingError{fmt.Sprintf("byteslice too long (%d)", len(in))}
47 | }
48 | pe.length += len(in)
49 | return nil
50 | }
51 |
52 | func (pe *prepEncoder) putRawBytes(in []byte) error {
53 | if len(in) > math.MaxInt32 {
54 | return PacketEncodingError{fmt.Sprintf("byteslice too long (%d)", len(in))}
55 | }
56 | pe.length += len(in)
57 | return nil
58 | }
59 |
60 | func (pe *prepEncoder) putString(in string) error {
61 | pe.length += 2
62 | if len(in) > math.MaxInt16 {
63 | return PacketEncodingError{fmt.Sprintf("string too long (%d)", len(in))}
64 | }
65 | pe.length += len(in)
66 | return nil
67 | }
68 |
69 | func (pe *prepEncoder) putStringArray(in []string) error {
70 | err := pe.putArrayLength(len(in))
71 | if err != nil {
72 | return err
73 | }
74 |
75 | for _, str := range in {
76 | if err := pe.putString(str); err != nil {
77 | return err
78 | }
79 | }
80 |
81 | return nil
82 | }
83 |
84 | func (pe *prepEncoder) putInt32Array(in []int32) error {
85 | err := pe.putArrayLength(len(in))
86 | if err != nil {
87 | return err
88 | }
89 | pe.length += 4 * len(in)
90 | return nil
91 | }
92 |
93 | func (pe *prepEncoder) putInt64Array(in []int64) error {
94 | err := pe.putArrayLength(len(in))
95 | if err != nil {
96 | return err
97 | }
98 | pe.length += 8 * len(in)
99 | return nil
100 | }
101 |
102 | // stackable
103 |
104 | func (pe *prepEncoder) push(in pushEncoder) {
105 | pe.length += in.reserveLength()
106 | }
107 |
108 | func (pe *prepEncoder) pop() error {
109 | return nil
110 | }
111 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/sync_group_request.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type SyncGroupRequest struct {
4 | GroupId string
5 | GenerationId int32
6 | MemberId string
7 | GroupAssignments map[string][]byte
8 | }
9 |
10 | func (r *SyncGroupRequest) encode(pe packetEncoder) error {
11 | if err := pe.putString(r.GroupId); err != nil {
12 | return err
13 | }
14 |
15 | pe.putInt32(r.GenerationId)
16 |
17 | if err := pe.putString(r.MemberId); err != nil {
18 | return err
19 | }
20 |
21 | if err := pe.putArrayLength(len(r.GroupAssignments)); err != nil {
22 | return err
23 | }
24 | for memberId, memberAssignment := range r.GroupAssignments {
25 | if err := pe.putString(memberId); err != nil {
26 | return err
27 | }
28 | if err := pe.putBytes(memberAssignment); err != nil {
29 | return err
30 | }
31 | }
32 |
33 | return nil
34 | }
35 |
36 | func (r *SyncGroupRequest) decode(pd packetDecoder, version int16) (err error) {
37 | if r.GroupId, err = pd.getString(); err != nil {
38 | return
39 | }
40 | if r.GenerationId, err = pd.getInt32(); err != nil {
41 | return
42 | }
43 | if r.MemberId, err = pd.getString(); err != nil {
44 | return
45 | }
46 |
47 | n, err := pd.getArrayLength()
48 | if err != nil {
49 | return err
50 | }
51 | if n == 0 {
52 | return nil
53 | }
54 |
55 | r.GroupAssignments = make(map[string][]byte)
56 | for i := 0; i < n; i++ {
57 | memberId, err := pd.getString()
58 | if err != nil {
59 | return err
60 | }
61 | memberAssignment, err := pd.getBytes()
62 | if err != nil {
63 | return err
64 | }
65 |
66 | r.GroupAssignments[memberId] = memberAssignment
67 | }
68 |
69 | return nil
70 | }
71 |
72 | func (r *SyncGroupRequest) key() int16 {
73 | return 14
74 | }
75 |
76 | func (r *SyncGroupRequest) version() int16 {
77 | return 0
78 | }
79 |
80 | func (r *SyncGroupRequest) requiredVersion() KafkaVersion {
81 | return V0_9_0_0
82 | }
83 |
84 | func (r *SyncGroupRequest) AddGroupAssignment(memberId string, memberAssignment []byte) {
85 | if r.GroupAssignments == nil {
86 | r.GroupAssignments = make(map[string][]byte)
87 | }
88 |
89 | r.GroupAssignments[memberId] = memberAssignment
90 | }
91 |
92 | func (r *SyncGroupRequest) AddGroupAssignmentMember(memberId string, memberAssignment *ConsumerGroupMemberAssignment) error {
93 | bin, err := encode(memberAssignment)
94 | if err != nil {
95 | return err
96 | }
97 |
98 | r.AddGroupAssignment(memberId, bin)
99 | return nil
100 | }
101 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/sync_group_request.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type SyncGroupRequest struct {
4 | GroupId string
5 | GenerationId int32
6 | MemberId string
7 | GroupAssignments map[string][]byte
8 | }
9 |
10 | func (r *SyncGroupRequest) encode(pe packetEncoder) error {
11 | if err := pe.putString(r.GroupId); err != nil {
12 | return err
13 | }
14 |
15 | pe.putInt32(r.GenerationId)
16 |
17 | if err := pe.putString(r.MemberId); err != nil {
18 | return err
19 | }
20 |
21 | if err := pe.putArrayLength(len(r.GroupAssignments)); err != nil {
22 | return err
23 | }
24 | for memberId, memberAssignment := range r.GroupAssignments {
25 | if err := pe.putString(memberId); err != nil {
26 | return err
27 | }
28 | if err := pe.putBytes(memberAssignment); err != nil {
29 | return err
30 | }
31 | }
32 |
33 | return nil
34 | }
35 |
36 | func (r *SyncGroupRequest) decode(pd packetDecoder, version int16) (err error) {
37 | if r.GroupId, err = pd.getString(); err != nil {
38 | return
39 | }
40 | if r.GenerationId, err = pd.getInt32(); err != nil {
41 | return
42 | }
43 | if r.MemberId, err = pd.getString(); err != nil {
44 | return
45 | }
46 |
47 | n, err := pd.getArrayLength()
48 | if err != nil {
49 | return err
50 | }
51 | if n == 0 {
52 | return nil
53 | }
54 |
55 | r.GroupAssignments = make(map[string][]byte)
56 | for i := 0; i < n; i++ {
57 | memberId, err := pd.getString()
58 | if err != nil {
59 | return err
60 | }
61 | memberAssignment, err := pd.getBytes()
62 | if err != nil {
63 | return err
64 | }
65 |
66 | r.GroupAssignments[memberId] = memberAssignment
67 | }
68 |
69 | return nil
70 | }
71 |
72 | func (r *SyncGroupRequest) key() int16 {
73 | return 14
74 | }
75 |
76 | func (r *SyncGroupRequest) version() int16 {
77 | return 0
78 | }
79 |
80 | func (r *SyncGroupRequest) requiredVersion() KafkaVersion {
81 | return V0_9_0_0
82 | }
83 |
84 | func (r *SyncGroupRequest) AddGroupAssignment(memberId string, memberAssignment []byte) {
85 | if r.GroupAssignments == nil {
86 | r.GroupAssignments = make(map[string][]byte)
87 | }
88 |
89 | r.GroupAssignments[memberId] = memberAssignment
90 | }
91 |
92 | func (r *SyncGroupRequest) AddGroupAssignmentMember(memberId string, memberAssignment *ConsumerGroupMemberAssignment) error {
93 | bin, err := encode(memberAssignment, nil)
94 | if err != nil {
95 | return err
96 | }
97 |
98 | r.AddGroupAssignment(memberId, bin)
99 | return nil
100 | }
101 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/join_group_request.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type JoinGroupRequest struct {
4 | GroupId string
5 | SessionTimeout int32
6 | MemberId string
7 | ProtocolType string
8 | GroupProtocols map[string][]byte
9 | }
10 |
11 | func (r *JoinGroupRequest) encode(pe packetEncoder) error {
12 | if err := pe.putString(r.GroupId); err != nil {
13 | return err
14 | }
15 | pe.putInt32(r.SessionTimeout)
16 | if err := pe.putString(r.MemberId); err != nil {
17 | return err
18 | }
19 | if err := pe.putString(r.ProtocolType); err != nil {
20 | return err
21 | }
22 |
23 | if err := pe.putArrayLength(len(r.GroupProtocols)); err != nil {
24 | return err
25 | }
26 | for name, metadata := range r.GroupProtocols {
27 | if err := pe.putString(name); err != nil {
28 | return err
29 | }
30 | if err := pe.putBytes(metadata); err != nil {
31 | return err
32 | }
33 | }
34 |
35 | return nil
36 | }
37 |
38 | func (r *JoinGroupRequest) decode(pd packetDecoder, version int16) (err error) {
39 | if r.GroupId, err = pd.getString(); err != nil {
40 | return
41 | }
42 |
43 | if r.SessionTimeout, err = pd.getInt32(); err != nil {
44 | return
45 | }
46 |
47 | if r.MemberId, err = pd.getString(); err != nil {
48 | return
49 | }
50 |
51 | if r.ProtocolType, err = pd.getString(); err != nil {
52 | return
53 | }
54 |
55 | n, err := pd.getArrayLength()
56 | if err != nil {
57 | return err
58 | }
59 | if n == 0 {
60 | return nil
61 | }
62 |
63 | r.GroupProtocols = make(map[string][]byte)
64 | for i := 0; i < n; i++ {
65 | name, err := pd.getString()
66 | if err != nil {
67 | return err
68 | }
69 | metadata, err := pd.getBytes()
70 | if err != nil {
71 | return err
72 | }
73 |
74 | r.GroupProtocols[name] = metadata
75 | }
76 |
77 | return nil
78 | }
79 |
80 | func (r *JoinGroupRequest) key() int16 {
81 | return 11
82 | }
83 |
84 | func (r *JoinGroupRequest) version() int16 {
85 | return 0
86 | }
87 |
88 | func (r *JoinGroupRequest) requiredVersion() KafkaVersion {
89 | return V0_9_0_0
90 | }
91 |
92 | func (r *JoinGroupRequest) AddGroupProtocol(name string, metadata []byte) {
93 | if r.GroupProtocols == nil {
94 | r.GroupProtocols = make(map[string][]byte)
95 | }
96 |
97 | r.GroupProtocols[name] = metadata
98 | }
99 |
100 | func (r *JoinGroupRequest) AddGroupProtocolMetadata(name string, metadata *ConsumerGroupMemberMetadata) error {
101 | bin, err := encode(metadata)
102 | if err != nil {
103 | return err
104 | }
105 |
106 | r.AddGroupProtocol(name, bin)
107 | return nil
108 | }
109 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/join_group_request.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type JoinGroupRequest struct {
4 | GroupId string
5 | SessionTimeout int32
6 | MemberId string
7 | ProtocolType string
8 | GroupProtocols map[string][]byte
9 | }
10 |
11 | func (r *JoinGroupRequest) encode(pe packetEncoder) error {
12 | if err := pe.putString(r.GroupId); err != nil {
13 | return err
14 | }
15 | pe.putInt32(r.SessionTimeout)
16 | if err := pe.putString(r.MemberId); err != nil {
17 | return err
18 | }
19 | if err := pe.putString(r.ProtocolType); err != nil {
20 | return err
21 | }
22 |
23 | if err := pe.putArrayLength(len(r.GroupProtocols)); err != nil {
24 | return err
25 | }
26 | for name, metadata := range r.GroupProtocols {
27 | if err := pe.putString(name); err != nil {
28 | return err
29 | }
30 | if err := pe.putBytes(metadata); err != nil {
31 | return err
32 | }
33 | }
34 |
35 | return nil
36 | }
37 |
38 | func (r *JoinGroupRequest) decode(pd packetDecoder, version int16) (err error) {
39 | if r.GroupId, err = pd.getString(); err != nil {
40 | return
41 | }
42 |
43 | if r.SessionTimeout, err = pd.getInt32(); err != nil {
44 | return
45 | }
46 |
47 | if r.MemberId, err = pd.getString(); err != nil {
48 | return
49 | }
50 |
51 | if r.ProtocolType, err = pd.getString(); err != nil {
52 | return
53 | }
54 |
55 | n, err := pd.getArrayLength()
56 | if err != nil {
57 | return err
58 | }
59 | if n == 0 {
60 | return nil
61 | }
62 |
63 | r.GroupProtocols = make(map[string][]byte)
64 | for i := 0; i < n; i++ {
65 | name, err := pd.getString()
66 | if err != nil {
67 | return err
68 | }
69 | metadata, err := pd.getBytes()
70 | if err != nil {
71 | return err
72 | }
73 |
74 | r.GroupProtocols[name] = metadata
75 | }
76 |
77 | return nil
78 | }
79 |
80 | func (r *JoinGroupRequest) key() int16 {
81 | return 11
82 | }
83 |
84 | func (r *JoinGroupRequest) version() int16 {
85 | return 0
86 | }
87 |
88 | func (r *JoinGroupRequest) requiredVersion() KafkaVersion {
89 | return V0_9_0_0
90 | }
91 |
92 | func (r *JoinGroupRequest) AddGroupProtocol(name string, metadata []byte) {
93 | if r.GroupProtocols == nil {
94 | r.GroupProtocols = make(map[string][]byte)
95 | }
96 |
97 | r.GroupProtocols[name] = metadata
98 | }
99 |
100 | func (r *JoinGroupRequest) AddGroupProtocolMetadata(name string, metadata *ConsumerGroupMemberMetadata) error {
101 | bin, err := encode(metadata, nil)
102 | if err != nil {
103 | return err
104 | }
105 |
106 | r.AddGroupProtocol(name, bin)
107 | return nil
108 | }
109 |
--------------------------------------------------------------------------------
/go/vendor/github.com/eapache/queue/queue.go:
--------------------------------------------------------------------------------
1 | /*
2 | Package queue provides a fast, ring-buffer queue based on the version suggested by Dariusz Górecki.
3 | Using this instead of other, simpler, queue implementations (slice+append or linked list) provides
4 | substantial memory and time benefits, and fewer GC pauses.
5 |
6 | The queue implemented here is as fast as it is for an additional reason: it is *not* thread-safe.
7 | */
8 | package queue
9 |
10 | const minQueueLen = 16
11 |
12 | // Queue represents a single instance of the queue data structure.
13 | type Queue struct {
14 | buf []interface{}
15 | head, tail, count int
16 | }
17 |
18 | // New constructs and returns a new Queue.
19 | func New() *Queue {
20 | return &Queue{
21 | buf: make([]interface{}, minQueueLen),
22 | }
23 | }
24 |
25 | // Length returns the number of elements currently stored in the queue.
26 | func (q *Queue) Length() int {
27 | return q.count
28 | }
29 |
30 | // resizes the queue to fit exactly twice its current contents
31 | // this can result in shrinking if the queue is less than half-full
32 | func (q *Queue) resize() {
33 | newBuf := make([]interface{}, q.count*2)
34 |
35 | if q.tail > q.head {
36 | copy(newBuf, q.buf[q.head:q.tail])
37 | } else {
38 | n := copy(newBuf, q.buf[q.head:])
39 | copy(newBuf[n:], q.buf[:q.tail])
40 | }
41 |
42 | q.head = 0
43 | q.tail = q.count
44 | q.buf = newBuf
45 | }
46 |
47 | // Add puts an element on the end of the queue.
48 | func (q *Queue) Add(elem interface{}) {
49 | if q.count == len(q.buf) {
50 | q.resize()
51 | }
52 |
53 | q.buf[q.tail] = elem
54 | q.tail = (q.tail + 1) % len(q.buf)
55 | q.count++
56 | }
57 |
58 | // Peek returns the element at the head of the queue. This call panics
59 | // if the queue is empty.
60 | func (q *Queue) Peek() interface{} {
61 | if q.count <= 0 {
62 | panic("queue: Peek() called on empty queue")
63 | }
64 | return q.buf[q.head]
65 | }
66 |
67 | // Get returns the element at index i in the queue. If the index is
68 | // invalid, the call will panic.
69 | func (q *Queue) Get(i int) interface{} {
70 | if i < 0 || i >= q.count {
71 | panic("queue: Get() called with index out of range")
72 | }
73 | return q.buf[(q.head+i)%len(q.buf)]
74 | }
75 |
76 | // Remove removes the element from the front of the queue. If you actually
77 | // want the element, call Peek first. This call panics if the queue is empty.
78 | func (q *Queue) Remove() {
79 | if q.count <= 0 {
80 | panic("queue: Remove() called on empty queue")
81 | }
82 | q.buf[q.head] = nil
83 | q.head = (q.head + 1) % len(q.buf)
84 | q.count--
85 | if len(q.buf) > minQueueLen && q.count*4 == len(q.buf) {
86 | q.resize()
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/real_encoder.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | import "encoding/binary"
4 |
5 | type realEncoder struct {
6 | raw []byte
7 | off int
8 | stack []pushEncoder
9 | }
10 |
11 | // primitives
12 |
13 | func (re *realEncoder) putInt8(in int8) {
14 | re.raw[re.off] = byte(in)
15 | re.off++
16 | }
17 |
18 | func (re *realEncoder) putInt16(in int16) {
19 | binary.BigEndian.PutUint16(re.raw[re.off:], uint16(in))
20 | re.off += 2
21 | }
22 |
23 | func (re *realEncoder) putInt32(in int32) {
24 | binary.BigEndian.PutUint32(re.raw[re.off:], uint32(in))
25 | re.off += 4
26 | }
27 |
28 | func (re *realEncoder) putInt64(in int64) {
29 | binary.BigEndian.PutUint64(re.raw[re.off:], uint64(in))
30 | re.off += 8
31 | }
32 |
33 | func (re *realEncoder) putArrayLength(in int) error {
34 | re.putInt32(int32(in))
35 | return nil
36 | }
37 |
38 | // collection
39 |
40 | func (re *realEncoder) putRawBytes(in []byte) error {
41 | copy(re.raw[re.off:], in)
42 | re.off += len(in)
43 | return nil
44 | }
45 |
46 | func (re *realEncoder) putBytes(in []byte) error {
47 | if in == nil {
48 | re.putInt32(-1)
49 | return nil
50 | }
51 | re.putInt32(int32(len(in)))
52 | copy(re.raw[re.off:], in)
53 | re.off += len(in)
54 | return nil
55 | }
56 |
57 | func (re *realEncoder) putString(in string) error {
58 | re.putInt16(int16(len(in)))
59 | copy(re.raw[re.off:], in)
60 | re.off += len(in)
61 | return nil
62 | }
63 |
64 | func (re *realEncoder) putStringArray(in []string) error {
65 | err := re.putArrayLength(len(in))
66 | if err != nil {
67 | return err
68 | }
69 |
70 | for _, val := range in {
71 | if err := re.putString(val); err != nil {
72 | return err
73 | }
74 | }
75 |
76 | return nil
77 | }
78 |
79 | func (re *realEncoder) putInt32Array(in []int32) error {
80 | err := re.putArrayLength(len(in))
81 | if err != nil {
82 | return err
83 | }
84 | for _, val := range in {
85 | re.putInt32(val)
86 | }
87 | return nil
88 | }
89 |
90 | func (re *realEncoder) putInt64Array(in []int64) error {
91 | err := re.putArrayLength(len(in))
92 | if err != nil {
93 | return err
94 | }
95 | for _, val := range in {
96 | re.putInt64(val)
97 | }
98 | return nil
99 | }
100 |
101 | // stacks
102 |
103 | func (re *realEncoder) push(in pushEncoder) {
104 | in.saveOffset(re.off)
105 | re.off += in.reserveLength()
106 | re.stack = append(re.stack, in)
107 | }
108 |
109 | func (re *realEncoder) pop() error {
110 | // this is go's ugly pop pattern (the inverse of append)
111 | in := re.stack[len(re.stack)-1]
112 | re.stack = re.stack[:len(re.stack)-1]
113 |
114 | return in.run(re.off, re.raw)
115 | }
116 |
--------------------------------------------------------------------------------
/go/vendor/github.com/rcrowley/go-metrics/json.go:
--------------------------------------------------------------------------------
1 | package metrics
2 |
3 | import (
4 | "encoding/json"
5 | "io"
6 | "time"
7 | )
8 |
9 | // MarshalJSON returns a byte slice containing a JSON representation of all
10 | // the metrics in the Registry.
11 | func (r *StandardRegistry) MarshalJSON() ([]byte, error) {
12 | data := make(map[string]map[string]interface{})
13 | r.Each(func(name string, i interface{}) {
14 | values := make(map[string]interface{})
15 | switch metric := i.(type) {
16 | case Counter:
17 | values["count"] = metric.Count()
18 | case Gauge:
19 | values["value"] = metric.Value()
20 | case GaugeFloat64:
21 | values["value"] = metric.Value()
22 | case Healthcheck:
23 | values["error"] = nil
24 | metric.Check()
25 | if err := metric.Error(); nil != err {
26 | values["error"] = metric.Error().Error()
27 | }
28 | case Histogram:
29 | h := metric.Snapshot()
30 | ps := h.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
31 | values["count"] = h.Count()
32 | values["min"] = h.Min()
33 | values["max"] = h.Max()
34 | values["mean"] = h.Mean()
35 | values["stddev"] = h.StdDev()
36 | values["median"] = ps[0]
37 | values["75%"] = ps[1]
38 | values["95%"] = ps[2]
39 | values["99%"] = ps[3]
40 | values["99.9%"] = ps[4]
41 | case Meter:
42 | m := metric.Snapshot()
43 | values["count"] = m.Count()
44 | values["1m.rate"] = m.Rate1()
45 | values["5m.rate"] = m.Rate5()
46 | values["15m.rate"] = m.Rate15()
47 | values["mean.rate"] = m.RateMean()
48 | case Timer:
49 | t := metric.Snapshot()
50 | ps := t.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
51 | values["count"] = t.Count()
52 | values["min"] = t.Min()
53 | values["max"] = t.Max()
54 | values["mean"] = t.Mean()
55 | values["stddev"] = t.StdDev()
56 | values["median"] = ps[0]
57 | values["75%"] = ps[1]
58 | values["95%"] = ps[2]
59 | values["99%"] = ps[3]
60 | values["99.9%"] = ps[4]
61 | values["1m.rate"] = t.Rate1()
62 | values["5m.rate"] = t.Rate5()
63 | values["15m.rate"] = t.Rate15()
64 | values["mean.rate"] = t.RateMean()
65 | }
66 | data[name] = values
67 | })
68 | return json.Marshal(data)
69 | }
70 |
71 | // WriteJSON writes metrics from the given registry periodically to the
72 | // specified io.Writer as JSON.
73 | func WriteJSON(r Registry, d time.Duration, w io.Writer) {
74 | for _ = range time.Tick(d) {
75 | WriteJSONOnce(r, w)
76 | }
77 | }
78 |
79 | // WriteJSONOnce writes metrics from the given registry to the specified
80 | // io.Writer as JSON.
81 | func WriteJSONOnce(r Registry, w io.Writer) {
82 | json.NewEncoder(w).Encode(r)
83 | }
84 |
85 | func (p *PrefixedRegistry) MarshalJSON() ([]byte, error) {
86 | return json.Marshal(p.underlying)
87 | }
88 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/join_group_response.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type JoinGroupResponse struct {
4 | Err KError
5 | GenerationId int32
6 | GroupProtocol string
7 | LeaderId string
8 | MemberId string
9 | Members map[string][]byte
10 | }
11 |
12 | func (r *JoinGroupResponse) GetMembers() (map[string]ConsumerGroupMemberMetadata, error) {
13 | members := make(map[string]ConsumerGroupMemberMetadata, len(r.Members))
14 | for id, bin := range r.Members {
15 | meta := new(ConsumerGroupMemberMetadata)
16 | if err := decode(bin, meta); err != nil {
17 | return nil, err
18 | }
19 | members[id] = *meta
20 | }
21 | return members, nil
22 | }
23 |
24 | func (r *JoinGroupResponse) encode(pe packetEncoder) error {
25 | pe.putInt16(int16(r.Err))
26 | pe.putInt32(r.GenerationId)
27 |
28 | if err := pe.putString(r.GroupProtocol); err != nil {
29 | return err
30 | }
31 | if err := pe.putString(r.LeaderId); err != nil {
32 | return err
33 | }
34 | if err := pe.putString(r.MemberId); err != nil {
35 | return err
36 | }
37 |
38 | if err := pe.putArrayLength(len(r.Members)); err != nil {
39 | return err
40 | }
41 |
42 | for memberId, memberMetadata := range r.Members {
43 | if err := pe.putString(memberId); err != nil {
44 | return err
45 | }
46 |
47 | if err := pe.putBytes(memberMetadata); err != nil {
48 | return err
49 | }
50 | }
51 |
52 | return nil
53 | }
54 |
55 | func (r *JoinGroupResponse) decode(pd packetDecoder, version int16) (err error) {
56 | if kerr, err := pd.getInt16(); err != nil {
57 | return err
58 | } else {
59 | r.Err = KError(kerr)
60 | }
61 |
62 | if r.GenerationId, err = pd.getInt32(); err != nil {
63 | return
64 | }
65 |
66 | if r.GroupProtocol, err = pd.getString(); err != nil {
67 | return
68 | }
69 |
70 | if r.LeaderId, err = pd.getString(); err != nil {
71 | return
72 | }
73 |
74 | if r.MemberId, err = pd.getString(); err != nil {
75 | return
76 | }
77 |
78 | n, err := pd.getArrayLength()
79 | if err != nil {
80 | return err
81 | }
82 | if n == 0 {
83 | return nil
84 | }
85 |
86 | r.Members = make(map[string][]byte)
87 | for i := 0; i < n; i++ {
88 | memberId, err := pd.getString()
89 | if err != nil {
90 | return err
91 | }
92 |
93 | memberMetadata, err := pd.getBytes()
94 | if err != nil {
95 | return err
96 | }
97 |
98 | r.Members[memberId] = memberMetadata
99 | }
100 |
101 | return nil
102 | }
103 |
104 | func (r *JoinGroupResponse) key() int16 {
105 | return 11
106 | }
107 |
108 | func (r *JoinGroupResponse) version() int16 {
109 | return 0
110 | }
111 |
112 | func (r *JoinGroupResponse) requiredVersion() KafkaVersion {
113 | return V0_9_0_0
114 | }
115 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/join_group_response.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type JoinGroupResponse struct {
4 | Err KError
5 | GenerationId int32
6 | GroupProtocol string
7 | LeaderId string
8 | MemberId string
9 | Members map[string][]byte
10 | }
11 |
12 | func (r *JoinGroupResponse) GetMembers() (map[string]ConsumerGroupMemberMetadata, error) {
13 | members := make(map[string]ConsumerGroupMemberMetadata, len(r.Members))
14 | for id, bin := range r.Members {
15 | meta := new(ConsumerGroupMemberMetadata)
16 | if err := decode(bin, meta); err != nil {
17 | return nil, err
18 | }
19 | members[id] = *meta
20 | }
21 | return members, nil
22 | }
23 |
24 | func (r *JoinGroupResponse) encode(pe packetEncoder) error {
25 | pe.putInt16(int16(r.Err))
26 | pe.putInt32(r.GenerationId)
27 |
28 | if err := pe.putString(r.GroupProtocol); err != nil {
29 | return err
30 | }
31 | if err := pe.putString(r.LeaderId); err != nil {
32 | return err
33 | }
34 | if err := pe.putString(r.MemberId); err != nil {
35 | return err
36 | }
37 |
38 | if err := pe.putArrayLength(len(r.Members)); err != nil {
39 | return err
40 | }
41 |
42 | for memberId, memberMetadata := range r.Members {
43 | if err := pe.putString(memberId); err != nil {
44 | return err
45 | }
46 |
47 | if err := pe.putBytes(memberMetadata); err != nil {
48 | return err
49 | }
50 | }
51 |
52 | return nil
53 | }
54 |
55 | func (r *JoinGroupResponse) decode(pd packetDecoder, version int16) (err error) {
56 | if kerr, err := pd.getInt16(); err != nil {
57 | return err
58 | } else {
59 | r.Err = KError(kerr)
60 | }
61 |
62 | if r.GenerationId, err = pd.getInt32(); err != nil {
63 | return
64 | }
65 |
66 | if r.GroupProtocol, err = pd.getString(); err != nil {
67 | return
68 | }
69 |
70 | if r.LeaderId, err = pd.getString(); err != nil {
71 | return
72 | }
73 |
74 | if r.MemberId, err = pd.getString(); err != nil {
75 | return
76 | }
77 |
78 | n, err := pd.getArrayLength()
79 | if err != nil {
80 | return err
81 | }
82 | if n == 0 {
83 | return nil
84 | }
85 |
86 | r.Members = make(map[string][]byte)
87 | for i := 0; i < n; i++ {
88 | memberId, err := pd.getString()
89 | if err != nil {
90 | return err
91 | }
92 |
93 | memberMetadata, err := pd.getBytes()
94 | if err != nil {
95 | return err
96 | }
97 |
98 | r.Members[memberId] = memberMetadata
99 | }
100 |
101 | return nil
102 | }
103 |
104 | func (r *JoinGroupResponse) key() int16 {
105 | return 11
106 | }
107 |
108 | func (r *JoinGroupResponse) version() int16 {
109 | return 0
110 | }
111 |
112 | func (r *JoinGroupResponse) requiredVersion() KafkaVersion {
113 | return V0_9_0_0
114 | }
115 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/prep_encoder.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | import (
4 | "fmt"
5 | "math"
6 |
7 | "github.com/rcrowley/go-metrics"
8 | )
9 |
10 | type prepEncoder struct {
11 | length int
12 | }
13 |
14 | // primitives
15 |
16 | func (pe *prepEncoder) putInt8(in int8) {
17 | pe.length++
18 | }
19 |
20 | func (pe *prepEncoder) putInt16(in int16) {
21 | pe.length += 2
22 | }
23 |
24 | func (pe *prepEncoder) putInt32(in int32) {
25 | pe.length += 4
26 | }
27 |
28 | func (pe *prepEncoder) putInt64(in int64) {
29 | pe.length += 8
30 | }
31 |
32 | func (pe *prepEncoder) putArrayLength(in int) error {
33 | if in > math.MaxInt32 {
34 | return PacketEncodingError{fmt.Sprintf("array too long (%d)", in)}
35 | }
36 | pe.length += 4
37 | return nil
38 | }
39 |
40 | // arrays
41 |
42 | func (pe *prepEncoder) putBytes(in []byte) error {
43 | pe.length += 4
44 | if in == nil {
45 | return nil
46 | }
47 | if len(in) > math.MaxInt32 {
48 | return PacketEncodingError{fmt.Sprintf("byteslice too long (%d)", len(in))}
49 | }
50 | pe.length += len(in)
51 | return nil
52 | }
53 |
54 | func (pe *prepEncoder) putRawBytes(in []byte) error {
55 | if len(in) > math.MaxInt32 {
56 | return PacketEncodingError{fmt.Sprintf("byteslice too long (%d)", len(in))}
57 | }
58 | pe.length += len(in)
59 | return nil
60 | }
61 |
62 | func (pe *prepEncoder) putString(in string) error {
63 | pe.length += 2
64 | if len(in) > math.MaxInt16 {
65 | return PacketEncodingError{fmt.Sprintf("string too long (%d)", len(in))}
66 | }
67 | pe.length += len(in)
68 | return nil
69 | }
70 |
71 | func (pe *prepEncoder) putStringArray(in []string) error {
72 | err := pe.putArrayLength(len(in))
73 | if err != nil {
74 | return err
75 | }
76 |
77 | for _, str := range in {
78 | if err := pe.putString(str); err != nil {
79 | return err
80 | }
81 | }
82 |
83 | return nil
84 | }
85 |
86 | func (pe *prepEncoder) putInt32Array(in []int32) error {
87 | err := pe.putArrayLength(len(in))
88 | if err != nil {
89 | return err
90 | }
91 | pe.length += 4 * len(in)
92 | return nil
93 | }
94 |
95 | func (pe *prepEncoder) putInt64Array(in []int64) error {
96 | err := pe.putArrayLength(len(in))
97 | if err != nil {
98 | return err
99 | }
100 | pe.length += 8 * len(in)
101 | return nil
102 | }
103 |
104 | func (pe *prepEncoder) offset() int {
105 | return pe.length
106 | }
107 |
108 | // stackable
109 |
110 | func (pe *prepEncoder) push(in pushEncoder) {
111 | pe.length += in.reserveLength()
112 | }
113 |
114 | func (pe *prepEncoder) pop() error {
115 | return nil
116 | }
117 |
118 | // we do not record metrics during the prep encoder pass
119 | func (pe *prepEncoder) metricRegistry() metrics.Registry {
120 | return nil
121 | }
122 |
--------------------------------------------------------------------------------
/go/vendor/github.com/rcrowley/go-metrics/debug.go:
--------------------------------------------------------------------------------
1 | package metrics
2 |
3 | import (
4 | "runtime/debug"
5 | "time"
6 | )
7 |
8 | var (
9 | debugMetrics struct {
10 | GCStats struct {
11 | LastGC Gauge
12 | NumGC Gauge
13 | Pause Histogram
14 | //PauseQuantiles Histogram
15 | PauseTotal Gauge
16 | }
17 | ReadGCStats Timer
18 | }
19 | gcStats debug.GCStats
20 | )
21 |
22 | // Capture new values for the Go garbage collector statistics exported in
23 | // debug.GCStats. This is designed to be called as a goroutine.
24 | func CaptureDebugGCStats(r Registry, d time.Duration) {
25 | for _ = range time.Tick(d) {
26 | CaptureDebugGCStatsOnce(r)
27 | }
28 | }
29 |
30 | // Capture new values for the Go garbage collector statistics exported in
31 | // debug.GCStats. This is designed to be called in a background goroutine.
32 | // Giving a registry which has not been given to RegisterDebugGCStats will
33 | // panic.
34 | //
35 | // Be careful (but much less so) with this because debug.ReadGCStats calls
36 | // the C function runtime·lock(runtime·mheap) which, while not a stop-the-world
37 | // operation, isn't something you want to be doing all the time.
38 | func CaptureDebugGCStatsOnce(r Registry) {
39 | lastGC := gcStats.LastGC
40 | t := time.Now()
41 | debug.ReadGCStats(&gcStats)
42 | debugMetrics.ReadGCStats.UpdateSince(t)
43 |
44 | debugMetrics.GCStats.LastGC.Update(int64(gcStats.LastGC.UnixNano()))
45 | debugMetrics.GCStats.NumGC.Update(int64(gcStats.NumGC))
46 | if lastGC != gcStats.LastGC && 0 < len(gcStats.Pause) {
47 | debugMetrics.GCStats.Pause.Update(int64(gcStats.Pause[0]))
48 | }
49 | //debugMetrics.GCStats.PauseQuantiles.Update(gcStats.PauseQuantiles)
50 | debugMetrics.GCStats.PauseTotal.Update(int64(gcStats.PauseTotal))
51 | }
52 |
53 | // Register metrics for the Go garbage collector statistics exported in
54 | // debug.GCStats. The metrics are named by their fully-qualified Go symbols,
55 | // i.e. debug.GCStats.PauseTotal.
56 | func RegisterDebugGCStats(r Registry) {
57 | debugMetrics.GCStats.LastGC = NewGauge()
58 | debugMetrics.GCStats.NumGC = NewGauge()
59 | debugMetrics.GCStats.Pause = NewHistogram(NewExpDecaySample(1028, 0.015))
60 | //debugMetrics.GCStats.PauseQuantiles = NewHistogram(NewExpDecaySample(1028, 0.015))
61 | debugMetrics.GCStats.PauseTotal = NewGauge()
62 | debugMetrics.ReadGCStats = NewTimer()
63 |
64 | r.Register("debug.GCStats.LastGC", debugMetrics.GCStats.LastGC)
65 | r.Register("debug.GCStats.NumGC", debugMetrics.GCStats.NumGC)
66 | r.Register("debug.GCStats.Pause", debugMetrics.GCStats.Pause)
67 | //r.Register("debug.GCStats.PauseQuantiles", debugMetrics.GCStats.PauseQuantiles)
68 | r.Register("debug.GCStats.PauseTotal", debugMetrics.GCStats.PauseTotal)
69 | r.Register("debug.ReadGCStats", debugMetrics.ReadGCStats)
70 | }
71 |
72 | // Allocate an initial slice for gcStats.Pause to avoid allocations during
73 | // normal operation.
74 | func init() {
75 | gcStats.Pause = make([]time.Duration, 11)
76 | }
77 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/request.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | import (
4 | "encoding/binary"
5 | "fmt"
6 | "io"
7 | )
8 |
9 | type protocolBody interface {
10 | encoder
11 | versionedDecoder
12 | key() int16
13 | version() int16
14 | requiredVersion() KafkaVersion
15 | }
16 |
17 | type request struct {
18 | correlationID int32
19 | clientID string
20 | body protocolBody
21 | }
22 |
23 | func (r *request) encode(pe packetEncoder) (err error) {
24 | pe.push(&lengthField{})
25 | pe.putInt16(r.body.key())
26 | pe.putInt16(r.body.version())
27 | pe.putInt32(r.correlationID)
28 | err = pe.putString(r.clientID)
29 | if err != nil {
30 | return err
31 | }
32 | err = r.body.encode(pe)
33 | if err != nil {
34 | return err
35 | }
36 | return pe.pop()
37 | }
38 |
39 | func (r *request) decode(pd packetDecoder) (err error) {
40 | var key int16
41 | if key, err = pd.getInt16(); err != nil {
42 | return err
43 | }
44 | var version int16
45 | if version, err = pd.getInt16(); err != nil {
46 | return err
47 | }
48 | if r.correlationID, err = pd.getInt32(); err != nil {
49 | return err
50 | }
51 | r.clientID, err = pd.getString()
52 |
53 | r.body = allocateBody(key, version)
54 | if r.body == nil {
55 | return PacketDecodingError{fmt.Sprintf("unknown request key (%d)", key)}
56 | }
57 | return r.body.decode(pd, version)
58 | }
59 |
60 | func decodeRequest(r io.Reader) (req *request, err error) {
61 | lengthBytes := make([]byte, 4)
62 | if _, err := io.ReadFull(r, lengthBytes); err != nil {
63 | return nil, err
64 | }
65 |
66 | length := int32(binary.BigEndian.Uint32(lengthBytes))
67 | if length <= 4 || length > MaxRequestSize {
68 | return nil, PacketDecodingError{fmt.Sprintf("message of length %d too large or too small", length)}
69 | }
70 |
71 | encodedReq := make([]byte, length)
72 | if _, err := io.ReadFull(r, encodedReq); err != nil {
73 | return nil, err
74 | }
75 |
76 | req = &request{}
77 | if err := decode(encodedReq, req); err != nil {
78 | return nil, err
79 | }
80 | return req, nil
81 | }
82 |
83 | func allocateBody(key, version int16) protocolBody {
84 | switch key {
85 | case 0:
86 | return &ProduceRequest{}
87 | case 1:
88 | return &FetchRequest{}
89 | case 2:
90 | return &OffsetRequest{}
91 | case 3:
92 | return &MetadataRequest{}
93 | case 8:
94 | return &OffsetCommitRequest{Version: version}
95 | case 9:
96 | return &OffsetFetchRequest{}
97 | case 10:
98 | return &ConsumerMetadataRequest{}
99 | case 11:
100 | return &JoinGroupRequest{}
101 | case 12:
102 | return &HeartbeatRequest{}
103 | case 13:
104 | return &LeaveGroupRequest{}
105 | case 14:
106 | return &SyncGroupRequest{}
107 | case 15:
108 | return &DescribeGroupsRequest{}
109 | case 16:
110 | return &ListGroupsRequest{}
111 | case 17:
112 | return &SaslHandshakeRequest{}
113 | case 18:
114 | return &ApiVersionsRequest{}
115 | }
116 | return nil
117 | }
118 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/real_encoder.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | import (
4 | "encoding/binary"
5 |
6 | "github.com/rcrowley/go-metrics"
7 | )
8 |
9 | type realEncoder struct {
10 | raw []byte
11 | off int
12 | stack []pushEncoder
13 | registry metrics.Registry
14 | }
15 |
16 | // primitives
17 |
18 | func (re *realEncoder) putInt8(in int8) {
19 | re.raw[re.off] = byte(in)
20 | re.off++
21 | }
22 |
23 | func (re *realEncoder) putInt16(in int16) {
24 | binary.BigEndian.PutUint16(re.raw[re.off:], uint16(in))
25 | re.off += 2
26 | }
27 |
28 | func (re *realEncoder) putInt32(in int32) {
29 | binary.BigEndian.PutUint32(re.raw[re.off:], uint32(in))
30 | re.off += 4
31 | }
32 |
33 | func (re *realEncoder) putInt64(in int64) {
34 | binary.BigEndian.PutUint64(re.raw[re.off:], uint64(in))
35 | re.off += 8
36 | }
37 |
38 | func (re *realEncoder) putArrayLength(in int) error {
39 | re.putInt32(int32(in))
40 | return nil
41 | }
42 |
43 | // collection
44 |
45 | func (re *realEncoder) putRawBytes(in []byte) error {
46 | copy(re.raw[re.off:], in)
47 | re.off += len(in)
48 | return nil
49 | }
50 |
51 | func (re *realEncoder) putBytes(in []byte) error {
52 | if in == nil {
53 | re.putInt32(-1)
54 | return nil
55 | }
56 | re.putInt32(int32(len(in)))
57 | copy(re.raw[re.off:], in)
58 | re.off += len(in)
59 | return nil
60 | }
61 |
62 | func (re *realEncoder) putString(in string) error {
63 | re.putInt16(int16(len(in)))
64 | copy(re.raw[re.off:], in)
65 | re.off += len(in)
66 | return nil
67 | }
68 |
69 | func (re *realEncoder) putStringArray(in []string) error {
70 | err := re.putArrayLength(len(in))
71 | if err != nil {
72 | return err
73 | }
74 |
75 | for _, val := range in {
76 | if err := re.putString(val); err != nil {
77 | return err
78 | }
79 | }
80 |
81 | return nil
82 | }
83 |
84 | func (re *realEncoder) putInt32Array(in []int32) error {
85 | err := re.putArrayLength(len(in))
86 | if err != nil {
87 | return err
88 | }
89 | for _, val := range in {
90 | re.putInt32(val)
91 | }
92 | return nil
93 | }
94 |
95 | func (re *realEncoder) putInt64Array(in []int64) error {
96 | err := re.putArrayLength(len(in))
97 | if err != nil {
98 | return err
99 | }
100 | for _, val := range in {
101 | re.putInt64(val)
102 | }
103 | return nil
104 | }
105 |
106 | func (re *realEncoder) offset() int {
107 | return re.off
108 | }
109 |
110 | // stacks
111 |
112 | func (re *realEncoder) push(in pushEncoder) {
113 | in.saveOffset(re.off)
114 | re.off += in.reserveLength()
115 | re.stack = append(re.stack, in)
116 | }
117 |
118 | func (re *realEncoder) pop() error {
119 | // this is go's ugly pop pattern (the inverse of append)
120 | in := re.stack[len(re.stack)-1]
121 | re.stack = re.stack[:len(re.stack)-1]
122 |
123 | return in.run(re.off, re.raw)
124 | }
125 |
126 | // we do record metrics during the real encoder pass
127 | func (re *realEncoder) metricRegistry() metrics.Registry {
128 | return re.registry
129 | }
130 |
--------------------------------------------------------------------------------
/go/vendor/gopkg.in/Shopify/sarama.v1/offset_request.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | type offsetRequestBlock struct {
4 | time int64
5 | maxOffsets int32
6 | }
7 |
8 | func (b *offsetRequestBlock) encode(pe packetEncoder) error {
9 | pe.putInt64(int64(b.time))
10 | pe.putInt32(b.maxOffsets)
11 | return nil
12 | }
13 |
14 | func (b *offsetRequestBlock) decode(pd packetDecoder) (err error) {
15 | if b.time, err = pd.getInt64(); err != nil {
16 | return err
17 | }
18 | if b.maxOffsets, err = pd.getInt32(); err != nil {
19 | return err
20 | }
21 | return nil
22 | }
23 |
24 | type OffsetRequest struct {
25 | blocks map[string]map[int32]*offsetRequestBlock
26 | }
27 |
28 | func (r *OffsetRequest) encode(pe packetEncoder) error {
29 | pe.putInt32(-1) // replica ID is always -1 for clients
30 | err := pe.putArrayLength(len(r.blocks))
31 | if err != nil {
32 | return err
33 | }
34 | for topic, partitions := range r.blocks {
35 | err = pe.putString(topic)
36 | if err != nil {
37 | return err
38 | }
39 | err = pe.putArrayLength(len(partitions))
40 | if err != nil {
41 | return err
42 | }
43 | for partition, block := range partitions {
44 | pe.putInt32(partition)
45 | if err = block.encode(pe); err != nil {
46 | return err
47 | }
48 | }
49 | }
50 | return nil
51 | }
52 |
53 | func (r *OffsetRequest) decode(pd packetDecoder, version int16) error {
54 | // Ignore replica ID
55 | if _, err := pd.getInt32(); err != nil {
56 | return err
57 | }
58 | blockCount, err := pd.getArrayLength()
59 | if err != nil {
60 | return err
61 | }
62 | if blockCount == 0 {
63 | return nil
64 | }
65 | r.blocks = make(map[string]map[int32]*offsetRequestBlock)
66 | for i := 0; i < blockCount; i++ {
67 | topic, err := pd.getString()
68 | if err != nil {
69 | return err
70 | }
71 | partitionCount, err := pd.getArrayLength()
72 | if err != nil {
73 | return err
74 | }
75 | r.blocks[topic] = make(map[int32]*offsetRequestBlock)
76 | for j := 0; j < partitionCount; j++ {
77 | partition, err := pd.getInt32()
78 | if err != nil {
79 | return err
80 | }
81 | block := &offsetRequestBlock{}
82 | if err := block.decode(pd); err != nil {
83 | return err
84 | }
85 | r.blocks[topic][partition] = block
86 | }
87 | }
88 | return nil
89 | }
90 |
91 | func (r *OffsetRequest) key() int16 {
92 | return 2
93 | }
94 |
95 | func (r *OffsetRequest) version() int16 {
96 | return 0
97 | }
98 |
99 | func (r *OffsetRequest) requiredVersion() KafkaVersion {
100 | return minVersion
101 | }
102 |
103 | func (r *OffsetRequest) AddBlock(topic string, partitionID int32, time int64, maxOffsets int32) {
104 | if r.blocks == nil {
105 | r.blocks = make(map[string]map[int32]*offsetRequestBlock)
106 | }
107 |
108 | if r.blocks[topic] == nil {
109 | r.blocks[topic] = make(map[int32]*offsetRequestBlock)
110 | }
111 |
112 | tmp := new(offsetRequestBlock)
113 | tmp.time = time
114 | tmp.maxOffsets = maxOffsets
115 |
116 | r.blocks[topic][partitionID] = tmp
117 | }
118 |
--------------------------------------------------------------------------------
/go/vendor/github.com/spf13/pflag/int.go:
--------------------------------------------------------------------------------
1 | package pflag
2 |
3 | import (
4 | "fmt"
5 | "strconv"
6 | )
7 |
8 | // -- int Value
9 | type intValue int
10 |
11 | func newIntValue(val int, p *int) *intValue {
12 | *p = val
13 | return (*intValue)(p)
14 | }
15 |
16 | func (i *intValue) Set(s string) error {
17 | v, err := strconv.ParseInt(s, 0, 64)
18 | *i = intValue(v)
19 | return err
20 | }
21 |
22 | func (i *intValue) Type() string {
23 | return "int"
24 | }
25 |
26 | func (i *intValue) String() string { return fmt.Sprintf("%v", *i) }
27 |
28 | func intConv(sval string) (interface{}, error) {
29 | return strconv.Atoi(sval)
30 | }
31 |
32 | // GetInt return the int value of a flag with the given name
33 | func (f *FlagSet) GetInt(name string) (int, error) {
34 | val, err := f.getFlagType(name, "int", intConv)
35 | if err != nil {
36 | return 0, err
37 | }
38 | return val.(int), nil
39 | }
40 |
41 | // IntVar defines an int flag with specified name, default value, and usage string.
42 | // The argument p points to an int variable in which to store the value of the flag.
43 | func (f *FlagSet) IntVar(p *int, name string, value int, usage string) {
44 | f.VarP(newIntValue(value, p), name, "", usage)
45 | }
46 |
47 | // IntVarP is like IntVar, but accepts a shorthand letter that can be used after a single dash.
48 | func (f *FlagSet) IntVarP(p *int, name, shorthand string, value int, usage string) {
49 | f.VarP(newIntValue(value, p), name, shorthand, usage)
50 | }
51 |
52 | // IntVar defines an int flag with specified name, default value, and usage string.
53 | // The argument p points to an int variable in which to store the value of the flag.
54 | func IntVar(p *int, name string, value int, usage string) {
55 | CommandLine.VarP(newIntValue(value, p), name, "", usage)
56 | }
57 |
58 | // IntVarP is like IntVar, but accepts a shorthand letter that can be used after a single dash.
59 | func IntVarP(p *int, name, shorthand string, value int, usage string) {
60 | CommandLine.VarP(newIntValue(value, p), name, shorthand, usage)
61 | }
62 |
63 | // Int defines an int flag with specified name, default value, and usage string.
64 | // The return value is the address of an int variable that stores the value of the flag.
65 | func (f *FlagSet) Int(name string, value int, usage string) *int {
66 | p := new(int)
67 | f.IntVarP(p, name, "", value, usage)
68 | return p
69 | }
70 |
71 | // IntP is like Int, but accepts a shorthand letter that can be used after a single dash.
72 | func (f *FlagSet) IntP(name, shorthand string, value int, usage string) *int {
73 | p := new(int)
74 | f.IntVarP(p, name, shorthand, value, usage)
75 | return p
76 | }
77 |
78 | // Int defines an int flag with specified name, default value, and usage string.
79 | // The return value is the address of an int variable that stores the value of the flag.
80 | func Int(name string, value int, usage string) *int {
81 | return CommandLine.IntP(name, "", value, usage)
82 | }
83 |
84 | // IntP is like Int, but accepts a shorthand letter that can be used after a single dash.
85 | func IntP(name, shorthand string, value int, usage string) *int {
86 | return CommandLine.IntP(name, shorthand, value, usage)
87 | }
88 |
--------------------------------------------------------------------------------
/go/vendor/github.com/Shopify/sarama/request.go:
--------------------------------------------------------------------------------
1 | package sarama
2 |
3 | import (
4 | "encoding/binary"
5 | "fmt"
6 | "io"
7 | )
8 |
9 | type protocolBody interface {
10 | encoder
11 | versionedDecoder
12 | key() int16
13 | version() int16
14 | requiredVersion() KafkaVersion
15 | }
16 |
17 | type request struct {
18 | correlationID int32
19 | clientID string
20 | body protocolBody
21 | }
22 |
23 | func (r *request) encode(pe packetEncoder) (err error) {
24 | pe.push(&lengthField{})
25 | pe.putInt16(r.body.key())
26 | pe.putInt16(r.body.version())
27 | pe.putInt32(r.correlationID)
28 | err = pe.putString(r.clientID)
29 | if err != nil {
30 | return err
31 | }
32 | err = r.body.encode(pe)
33 | if err != nil {
34 | return err
35 | }
36 | return pe.pop()
37 | }
38 |
39 | func (r *request) decode(pd packetDecoder) (err error) {
40 | var key int16
41 | if key, err = pd.getInt16(); err != nil {
42 | return err
43 | }
44 | var version int16
45 | if version, err = pd.getInt16(); err != nil {
46 | return err
47 | }
48 | if r.correlationID, err = pd.getInt32(); err != nil {
49 | return err
50 | }
51 | r.clientID, err = pd.getString()
52 |
53 | r.body = allocateBody(key, version)
54 | if r.body == nil {
55 | return PacketDecodingError{fmt.Sprintf("unknown request key (%d)", key)}
56 | }
57 | return r.body.decode(pd, version)
58 | }
59 |
60 | func decodeRequest(r io.Reader) (req *request, bytesRead int, err error) {
61 | lengthBytes := make([]byte, 4)
62 | if _, err := io.ReadFull(r, lengthBytes); err != nil {
63 | return nil, bytesRead, err
64 | }
65 | bytesRead += len(lengthBytes)
66 |
67 | length := int32(binary.BigEndian.Uint32(lengthBytes))
68 | if length <= 4 || length > MaxRequestSize {
69 | return nil, bytesRead, PacketDecodingError{fmt.Sprintf("message of length %d too large or too small", length)}
70 | }
71 |
72 | encodedReq := make([]byte, length)
73 | if _, err := io.ReadFull(r, encodedReq); err != nil {
74 | return nil, bytesRead, err
75 | }
76 | bytesRead += len(encodedReq)
77 |
78 | req = &request{}
79 | if err := decode(encodedReq, req); err != nil {
80 | return nil, bytesRead, err
81 | }
82 | return req, bytesRead, nil
83 | }
84 |
85 | func allocateBody(key, version int16) protocolBody {
86 | switch key {
87 | case 0:
88 | return &ProduceRequest{}
89 | case 1:
90 | return &FetchRequest{}
91 | case 2:
92 | return &OffsetRequest{Version: version}
93 | case 3:
94 | return &MetadataRequest{}
95 | case 8:
96 | return &OffsetCommitRequest{Version: version}
97 | case 9:
98 | return &OffsetFetchRequest{}
99 | case 10:
100 | return &ConsumerMetadataRequest{}
101 | case 11:
102 | return &JoinGroupRequest{}
103 | case 12:
104 | return &HeartbeatRequest{}
105 | case 13:
106 | return &LeaveGroupRequest{}
107 | case 14:
108 | return &SyncGroupRequest{}
109 | case 15:
110 | return &DescribeGroupsRequest{}
111 | case 16:
112 | return &ListGroupsRequest{}
113 | case 17:
114 | return &SaslHandshakeRequest{}
115 | case 18:
116 | return &ApiVersionsRequest{}
117 | }
118 | return nil
119 | }
120 |
--------------------------------------------------------------------------------
/go/vendor/github.com/rcrowley/go-metrics/counter.go:
--------------------------------------------------------------------------------
1 | package metrics
2 |
3 | import "sync/atomic"
4 |
5 | // Counters hold an int64 value that can be incremented and decremented.
6 | type Counter interface {
7 | Clear()
8 | Count() int64
9 | Dec(int64)
10 | Inc(int64)
11 | Snapshot() Counter
12 | }
13 |
14 | // GetOrRegisterCounter returns an existing Counter or constructs and registers
15 | // a new StandardCounter.
16 | func GetOrRegisterCounter(name string, r Registry) Counter {
17 | if nil == r {
18 | r = DefaultRegistry
19 | }
20 | return r.GetOrRegister(name, NewCounter).(Counter)
21 | }
22 |
23 | // NewCounter constructs a new StandardCounter.
24 | func NewCounter() Counter {
25 | if UseNilMetrics {
26 | return NilCounter{}
27 | }
28 | return &StandardCounter{0}
29 | }
30 |
31 | // NewRegisteredCounter constructs and registers a new StandardCounter.
32 | func NewRegisteredCounter(name string, r Registry) Counter {
33 | c := NewCounter()
34 | if nil == r {
35 | r = DefaultRegistry
36 | }
37 | r.Register(name, c)
38 | return c
39 | }
40 |
41 | // CounterSnapshot is a read-only copy of another Counter.
42 | type CounterSnapshot int64
43 |
44 | // Clear panics.
45 | func (CounterSnapshot) Clear() {
46 | panic("Clear called on a CounterSnapshot")
47 | }
48 |
49 | // Count returns the count at the time the snapshot was taken.
50 | func (c CounterSnapshot) Count() int64 { return int64(c) }
51 |
52 | // Dec panics.
53 | func (CounterSnapshot) Dec(int64) {
54 | panic("Dec called on a CounterSnapshot")
55 | }
56 |
57 | // Inc panics.
58 | func (CounterSnapshot) Inc(int64) {
59 | panic("Inc called on a CounterSnapshot")
60 | }
61 |
62 | // Snapshot returns the snapshot.
63 | func (c CounterSnapshot) Snapshot() Counter { return c }
64 |
65 | // NilCounter is a no-op Counter.
66 | type NilCounter struct{}
67 |
68 | // Clear is a no-op.
69 | func (NilCounter) Clear() {}
70 |
71 | // Count is a no-op.
72 | func (NilCounter) Count() int64 { return 0 }
73 |
74 | // Dec is a no-op.
75 | func (NilCounter) Dec(i int64) {}
76 |
77 | // Inc is a no-op.
78 | func (NilCounter) Inc(i int64) {}
79 |
80 | // Snapshot is a no-op.
81 | func (NilCounter) Snapshot() Counter { return NilCounter{} }
82 |
83 | // StandardCounter is the standard implementation of a Counter and uses the
84 | // sync/atomic package to manage a single int64 value.
85 | type StandardCounter struct {
86 | count int64
87 | }
88 |
89 | // Clear sets the counter to zero.
90 | func (c *StandardCounter) Clear() {
91 | atomic.StoreInt64(&c.count, 0)
92 | }
93 |
94 | // Count returns the current count.
95 | func (c *StandardCounter) Count() int64 {
96 | return atomic.LoadInt64(&c.count)
97 | }
98 |
99 | // Dec decrements the counter by the given amount.
100 | func (c *StandardCounter) Dec(i int64) {
101 | atomic.AddInt64(&c.count, -i)
102 | }
103 |
104 | // Inc increments the counter by the given amount.
105 | func (c *StandardCounter) Inc(i int64) {
106 | atomic.AddInt64(&c.count, i)
107 | }
108 |
109 | // Snapshot returns a read-only copy of the counter.
110 | func (c *StandardCounter) Snapshot() Counter {
111 | return CounterSnapshot(c.Count())
112 | }
113 |
--------------------------------------------------------------------------------
/go/vendor/github.com/spf13/pflag/count.go:
--------------------------------------------------------------------------------
1 | package pflag
2 |
3 | import (
4 | "fmt"
5 | "strconv"
6 | )
7 |
8 | // -- count Value
9 | type countValue int
10 |
11 | func newCountValue(val int, p *int) *countValue {
12 | *p = val
13 | return (*countValue)(p)
14 | }
15 |
16 | func (i *countValue) Set(s string) error {
17 | v, err := strconv.ParseInt(s, 0, 64)
18 | // -1 means that no specific value was passed, so increment
19 | if v == -1 {
20 | *i = countValue(*i + 1)
21 | } else {
22 | *i = countValue(v)
23 | }
24 | return err
25 | }
26 |
27 | func (i *countValue) Type() string {
28 | return "count"
29 | }
30 |
31 | func (i *countValue) String() string { return fmt.Sprintf("%v", *i) }
32 |
33 | func countConv(sval string) (interface{}, error) {
34 | i, err := strconv.Atoi(sval)
35 | if err != nil {
36 | return nil, err
37 | }
38 | return i, nil
39 | }
40 |
41 | // GetCount return the int value of a flag with the given name
42 | func (f *FlagSet) GetCount(name string) (int, error) {
43 | val, err := f.getFlagType(name, "count", countConv)
44 | if err != nil {
45 | return 0, err
46 | }
47 | return val.(int), nil
48 | }
49 |
50 | // CountVar defines a count flag with specified name, default value, and usage string.
51 | // The argument p points to an int variable in which to store the value of the flag.
52 | // A count flag will add 1 to its value evey time it is found on the command line
53 | func (f *FlagSet) CountVar(p *int, name string, usage string) {
54 | f.CountVarP(p, name, "", usage)
55 | }
56 |
57 | // CountVarP is like CountVar only take a shorthand for the flag name.
58 | func (f *FlagSet) CountVarP(p *int, name, shorthand string, usage string) {
59 | flag := f.VarPF(newCountValue(0, p), name, shorthand, usage)
60 | flag.NoOptDefVal = "-1"
61 | }
62 |
63 | // CountVar like CountVar only the flag is placed on the CommandLine instead of a given flag set
64 | func CountVar(p *int, name string, usage string) {
65 | CommandLine.CountVar(p, name, usage)
66 | }
67 |
68 | // CountVarP is like CountVar only take a shorthand for the flag name.
69 | func CountVarP(p *int, name, shorthand string, usage string) {
70 | CommandLine.CountVarP(p, name, shorthand, usage)
71 | }
72 |
73 | // Count defines a count flag with specified name, default value, and usage string.
74 | // The return value is the address of an int variable that stores the value of the flag.
75 | // A count flag will add 1 to its value evey time it is found on the command line
76 | func (f *FlagSet) Count(name string, usage string) *int {
77 | p := new(int)
78 | f.CountVarP(p, name, "", usage)
79 | return p
80 | }
81 |
82 | // CountP is like Count only takes a shorthand for the flag name.
83 | func (f *FlagSet) CountP(name, shorthand string, usage string) *int {
84 | p := new(int)
85 | f.CountVarP(p, name, shorthand, usage)
86 | return p
87 | }
88 |
89 | // Count like Count only the flag is placed on the CommandLine isntead of a given flag set
90 | func Count(name string, usage string) *int {
91 | return CommandLine.CountP(name, "", usage)
92 | }
93 |
94 | // CountP is like Count only takes a shorthand for the flag name.
95 | func CountP(name, shorthand string, usage string) *int {
96 | return CommandLine.CountP(name, shorthand, usage)
97 | }
98 |
--------------------------------------------------------------------------------