├── .circleci ├── config.yml └── debian-install-protobuf ├── CONTRIBUTING.md ├── Dockerfile ├── LICENSE ├── README.md ├── build ├── check_generated_code ├── clients ├── .DS_Store ├── Makefile ├── README.md ├── install-protobuf ├── node │ ├── README.md │ ├── example.js │ ├── package-lock.json │ └── package.json ├── python │ ├── .coveragerc │ ├── Makefile │ ├── example.py │ ├── github │ │ └── com │ │ │ └── golang │ │ │ └── protobuf │ │ │ └── ptypes │ │ │ └── struct │ │ │ └── struct_pb2.py │ ├── pqstream_pb2.py │ ├── pqstream_pb2_grpc.py │ ├── requirements.dev.txt │ └── requirements.txt └── ruby │ ├── .gitignore │ ├── .rubocop.yml │ ├── .ruby-version │ ├── Gemfile │ ├── Gemfile.lock │ ├── Makefile │ ├── basic_test.rb │ ├── lib │ ├── pqstream.rb │ ├── pqstream │ │ └── version.rb │ ├── pqstream_pb.rb │ └── pqstream_services_pb.rb │ ├── pqstream.gemspec │ ├── protoc-fixup │ └── spec │ ├── pqstream_spec.rb │ └── spec_helper.rb ├── cmd ├── pqs │ └── main.go └── pqsd │ └── main.go ├── codecov.yml ├── contrib └── cmd │ └── pqsamq │ └── main.go ├── ctxutil └── background_signals.go ├── gen.go ├── install-go ├── lint ├── patch.go ├── patch_test.go ├── pqs └── pqstream.pb.go ├── pqstream.proto ├── queries.go ├── redactions.go ├── redactions_test.go ├── server.go ├── server_test.go ├── test └── vendor ├── github.com └── golang │ └── protobuf │ ├── AUTHORS │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── Make.protobuf │ ├── Makefile │ ├── README.md │ ├── descriptor │ └── descriptor.go │ ├── jsonpb │ ├── jsonpb.go │ └── jsonpb_test_proto │ │ ├── Makefile │ │ ├── more_test_objects.pb.go │ │ ├── more_test_objects.proto │ │ ├── test_objects.pb.go │ │ └── test_objects.proto │ ├── proto │ ├── Makefile │ ├── clone.go │ ├── decode.go │ ├── encode.go │ ├── equal.go │ ├── extensions.go │ ├── lib.go │ ├── message_set.go │ ├── pointer_reflect.go │ ├── pointer_unsafe.go │ ├── properties.go │ ├── proto3_proto │ │ ├── proto3.pb.go │ │ └── proto3.proto │ ├── text.go │ └── text_parser.go │ ├── protoc-gen-go │ ├── Makefile │ ├── descriptor │ │ ├── Makefile │ │ ├── descriptor.pb.go │ │ └── descriptor.proto │ ├── doc.go │ ├── generator │ │ ├── Makefile │ │ └── generator.go │ ├── grpc │ │ └── grpc.go │ ├── link_grpc.go │ ├── main.go │ └── plugin │ │ ├── Makefile │ │ ├── plugin.pb.go │ │ ├── plugin.pb.golden │ │ └── plugin.proto │ └── ptypes │ ├── any.go │ ├── any │ ├── any.pb.go │ └── any.proto │ ├── doc.go │ ├── duration.go │ ├── duration │ ├── duration.pb.go │ └── duration.proto │ ├── empty │ ├── empty.pb.go │ └── empty.proto │ ├── regen.sh │ ├── struct │ ├── struct.pb.go │ └── struct.proto │ ├── timestamp.go │ ├── timestamp │ ├── timestamp.pb.go │ └── timestamp.proto │ └── wrappers │ ├── wrappers.pb.go │ └── wrappers.proto └── vendor.json /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | build-and-test: 4 | docker: 5 | - image: circleci/golang:1.9 6 | - image: circleci/postgres 7 | environment: 8 | POSTGRES_USER: root 9 | POSTGRES_DB: circle_test 10 | working_directory: /go/src/github.com/tmc/pqstream 11 | 12 | environment: 13 | TEST_RESULTS: /tmp/test-results 14 | 15 | steps: 16 | - checkout 17 | - run: mkdir -p $TEST_RESULTS 18 | 19 | - run: go get github.com/jstemmer/go-junit-report 20 | 21 | - run: 22 | name: Waiting for Postgres to be ready 23 | command: | 24 | for i in `seq 1 10`; 25 | do 26 | nc -z localhost 5432 && echo Success && exit 0 27 | echo -n . 28 | sleep 1 29 | done 30 | echo Failed waiting for Postgres && exit 1 31 | 32 | - run: ./check_generated_code 33 | 34 | - run: ./build 35 | 36 | - run: 37 | name: Run unit tests 38 | environment: 39 | PQSTREAM_TEST_DB_URL: "postgres://root@localhost:5432/circle_test?sslmode=disable" 40 | PQSTREAM_TEST_DB_TMPL_URL: "postgres://root@localhost:5432/%s?sslmode=disable" 41 | command: | 42 | trap "go-junit-report <${TEST_RESULTS}/go-test.out > ${TEST_RESULTS}/go-test-report.xml" EXIT 43 | ./test | tee ${TEST_RESULTS}/go-test.out 44 | 45 | - store_artifacts: 46 | path: /tmp/test-results 47 | destination: raw-test-output 48 | 49 | - store_test_results: 50 | path: /tmp/test-results 51 | lint: 52 | docker: 53 | - image: circleci/golang:1.9 54 | working_directory: /go/src/github.com/tmc/pqstream 55 | 56 | steps: 57 | - checkout 58 | 59 | - run: ./check_generated_code 60 | 61 | - run: ./build 62 | 63 | - run: ./lint 64 | clients-python: 65 | docker: 66 | - image: circleci/python:3 67 | - image: circleci/postgres 68 | environment: 69 | POSTGRES_USER: root 70 | POSTGRES_DB: circle_test 71 | working_directory: /home/circleci/go/src/github.com/tmc/pqstream 72 | steps: 73 | - checkout 74 | 75 | - run: echo 'export PATH=$HOME/go/bin:$PATH' >> $BASH_ENV 76 | - run: echo 'export PATH=$HOME/goroot/bin:$PATH' >> $BASH_ENV 77 | - run: echo 'export PATH=$HOME/protobuf/bin:$PATH' >> $BASH_ENV 78 | 79 | - run: cd clients; make deps 80 | 81 | - run: ./install-go 82 | 83 | - run: ./check_generated_code 84 | 85 | - run: ./build 86 | 87 | - run: cd clients/python; sudo make deps 88 | 89 | - run: 90 | name: Waiting for Postgres to be ready 91 | command: | 92 | for i in `seq 1 10`; 93 | do 94 | nc -z localhost 5432 && echo Success && exit 0 95 | echo -n . 96 | sleep 1 97 | done 98 | echo Failed waiting for Postgres && exit 1 99 | 100 | - run: 101 | name: Run tests 102 | environment: 103 | PQSTREAM_TEST_DB_URL: "postgres://root@localhost:5432/circle_test?sslmode=disable" 104 | PQSTREAM_TEST_DB_TMPL_URL: "postgres://root@localhost:5432/%s?sslmode=disable" 105 | command: cd clients/python; make generate lint test 106 | 107 | - store_artifacts: 108 | path: /tmp/test-results 109 | destination: raw-test-output 110 | 111 | - store_test_results: 112 | path: /tmp/test-results 113 | 114 | clients-ruby: 115 | docker: 116 | - image: circleci/ruby:2.4 117 | steps: 118 | - checkout 119 | 120 | - run: cd clients; make deps 121 | 122 | - run: cd clients/ruby; make deps generate gem lint 123 | 124 | - run: cd clients/ruby; make test 125 | 126 | docker-image: 127 | docker: 128 | - image: gcr.io/cloud-builders/docker 129 | working_directory: /go/src/github.com/tmc/pqstream 130 | steps: 131 | - checkout 132 | - setup_remote_docker: 133 | resuable: true 134 | - run: 135 | name: Build Image 136 | command: | 137 | docker build . 138 | workflows: 139 | version: 2 140 | ci: 141 | jobs: 142 | - build-and-test 143 | - lint 144 | - docker-image 145 | - clients-python 146 | - clients-ruby 147 | -------------------------------------------------------------------------------- /.circleci/debian-install-protobuf: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | VERSION=${1:-3.4.0} 4 | which unzip || sudo apt-get install -y unzip 5 | curl -OL https://github.com/google/protobuf/releases/download/v${VERSION}/protoc-${VERSION}-linux-x86_64.zip 6 | unzip protoc-${VERSION}-linux-x86_64.zip -d protoc3 7 | sudo mv protoc3/bin/* /usr/local/bin/ 8 | sudo mv protoc3/include/* /usr/local/include/ 9 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing to pqstream 2 | ======================== 3 | 4 | Welcome and thank you for taking time to contributing to the project. 5 | 6 | ## Menu 7 | 8 | - [General](#general) 9 | - [Making a pull request](#making-a-pull-request) 10 | - [Reporting a bug](#report-a-bug) 11 | - [Request a change/feature](#change-requests) 12 | - [Setup your development environment](#setup) 13 | 14 | ### General 15 | 16 | - Check that your development setup is correct. (see [setup](#setup)) 17 | 18 | - Make sure your issue have not been attended to already by searching through the project [Issues](https://github.com/tmc/pqstream/issues) page. 19 | 20 | - Please follow Go best practices when making changes: 21 | - [Effective Go](https://golang.org/doc/effective_go.html) 22 | - [Code Review Comments](https://golang.org/wiki/CodeReviewComments) 23 | 24 | - When comments are made about your changes, always assume positive intent. 25 | 26 | ### Making a pull request 27 | 28 | Contributing to a Go project is slightly different because of import paths, please follow these steps to make it easier: 29 | 30 | 1. [Fork the repo](https://github.com/tmc/pqstream). This makes a copy of the code you can write to on your Github account. You will now have a repo called `pqstream` under your account i.e `https://github.com//pqstream` 31 | 32 | 2. If you haven't already done this, please `go get` the repo `go get github.com/tmc/pqstream`. This will download the repo into your local `$GOPATH`. The repo will be under `$GOPATH/src/github.com/tmc/pqstream` 33 | 34 | 3. Change directory to the downloaded repo (`cd $GOPATH/src/github.com/tmc/pqstream`) and tell git that it can push to your fork by adding a remote: `git remote add fork https://github.com//pqstream.git` 35 | 36 | 4. Make your changes in the repo on your computer, preferably by branching 37 | 38 | 5. Push your changes to your fork: `git push fork` 39 | 40 | 6. Create a pull request to merge your changes into the `pqstream` **master** branch 41 | 42 | 43 | *These guidelines are based on [GitHub and Go: forking, pull requests, and go-getting](http://blog.campoy.cat/2014/03/github-and-go-forking-pull-requests-and.html)* 44 | 45 | ### Report a bug 46 | 47 | Bugs can be reported by creating a new issue on the project [Issues](https://github.com/tmc/pqstream/issues) page. 48 | 49 | ### Change requests 50 | 51 | Change requests can be logged by creating a new issue on the project [Issues](https://github.com/tmc/pqstream/issues) page. *Tip: Search through the issues first to see if someone else have to not maybe requested something similar.* 52 | 53 | ### Setup 54 | 55 | To be able to contribute to this project you will need make sure that you have the following dependencies are installed on your development machine: 56 | 57 | - Go environment (minimum version 1.7): 58 | - [Install Go](https://golang.org/doc/install) 59 | - To setup your Go workspace, please read [How to write Go code](https://golang.org/doc/code.html) 60 | 61 | - Protocol Buffers 62 | - The project uses protocol buffers. The `protoc` compiler can be downloaded from [here](https://github.com/google/protobuf/releases) 63 | 64 | - The rest of the Go packages that are needed can be downloaded by running the `build` script in the root folder of the repo. 65 | 66 | 67 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:alpine as builder 2 | 3 | RUN apk add --no-cache git 4 | 5 | ENV BUILD_PATH /build/main 6 | 7 | COPY . /go/src/github.com/tmc/pqstream 8 | 9 | RUN go get -v github.com/tmc/pqstream/cmd/pqs \ 10 | && go get -v github.com/tmc/pqstream/cmd/pqsd 11 | 12 | RUN mkdir -p ${BUILD_PATH} 13 | ENV GOBIN ${BUILD_PATH} 14 | 15 | RUN go install github.com/tmc/pqstream/cmd/pqs \ 16 | && go install github.com/tmc/pqstream/cmd/pqsd 17 | 18 | FROM alpine 19 | 20 | RUN adduser -S -D -H -h /app appuser && \ 21 | mkdir /app && \ 22 | chown appuser:nogroup /app 23 | 24 | USER appuser 25 | 26 | WORKDIR /app 27 | 28 | COPY --from=builder --chown=appuser:nogroup /build/main /app/ 29 | 30 | EXPOSE 7000 31 | 32 | CMD ["./pqsd"] 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2017 Travis Cline 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pqstream 2 | 3 | pqstream is a program that streams changes out of a postgres database with the intent of populating other systems and enabling stream processing of data sets. 4 | 5 | [![ci status](https://circleci.com/gh/tmc/pqstream.svg?style=shield)](https://circleci.com/gh/tmc/workflows/pqstream/tree/master) 6 | [![go report card](https://goreportcard.com/badge/github.com/tmc/pqstream)](https://goreportcard.com/report/github.com/tmc/pqstream) 7 | [![coverage](https://codecov.io/gh/tmc/pqstream/branch/master/graph/badge.svg)](https://codecov.io/gh/tmc/pqstream) 8 | 9 | ## installation 10 | 11 | ```sh 12 | $ go get -u github.com/tmc/pqstream/cmd/{pqs,pqsd} 13 | ``` 14 | 15 | ## basic usage 16 | 17 | create an example database: 18 | 19 | ```sh 20 | $ createdb dbname 21 | # echo "create table notes (id serial, created_at timestamp, note text)" | psql dbname 22 | ``` 23 | 24 | connect the agent: 25 | 26 | ```sh 27 | $ pqsd -connect postgresql://user:pass@host/dbname 28 | ``` 29 | 30 | connect the cli: 31 | ```sh 32 | $ pqs 33 | ``` 34 | 35 | at this point you will see streams of database operations rendered to stdout: 36 | 37 | 38 | (in a psql shell): 39 | 40 | ```sql 41 | dbname=# insert into notes values (default, default, 'here is a sample note'); 42 | INSERT 0 1 43 | dbname=# insert into notes values (default, default, 'here is a sample note'); 44 | INSERT 0 1 45 | dbname=# update notes set note = 'here is an updated note' where id=1; 46 | UPDATE 1 47 | dbname=# delete from notes where id = 1; 48 | DELETE 1 49 | dbname=# 50 | ``` 51 | 52 | our client should now show our operations: 53 | ```sh 54 | $ pqs 55 | {"schema":"public","table":"notes","op":"INSERT","id":"1","payload":{"created_at":null,"id":1,"note":"here is a sample note"}} 56 | {"schema":"public","table":"notes","op":"INSERT","id":"2","payload":{"created_at":null,"id":2,"note":"here is a sample note"}} 57 | {"schema":"public","table":"notes","op":"UPDATE","id":"1","payload":{"created_at":null,"id":1,"note":"here is an updated note"},"changes":{"note":"here is a sample note"}} 58 | {"schema":"public","table":"notes","op":"DELETE","id":"1","payload":{"created_at":null,"id":1,"note":"here is an updated note"}} 59 | ``` 60 | 61 | 62 | ## field redaction 63 | 64 | If there's a need to prevent sensitive fields (i.e. PII) from being exported the `redactions` flag can be used with `pqsd`: 65 | 66 | 67 | ```sh 68 | $ pqsd -connect postgresql://user:pass@host/dbname -redactions='{"public":{"users":["first_name","last_name","email"]}}' 69 | ``` 70 | 71 | The `redactions` is encoded in [JSON](http://json.org/) and conforms to the following layout: 72 | ``` json 73 | '{"schema":{"table":["field1","field2"]}}'` 74 | ``` 75 | -------------------------------------------------------------------------------- /build: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | go get -t -v ./... 4 | go generate 5 | go install -v ./... 6 | -------------------------------------------------------------------------------- /check_generated_code: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | set -x 4 | which protoc || sudo apt-get install -y protobuf-compiler 5 | which protoc-gen-go || go get -v -u github.com/golang/protobuf/protoc-gen-go 6 | 7 | protoc --version 8 | go generate 9 | 10 | # if this exits non-zero then our generated code is out of date 11 | git diff --exit-code pqs 12 | -------------------------------------------------------------------------------- /clients/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tmc/pqstream/c9027a0afa15cb7c5412d82eabf12a1dc3f96bd2/clients/.DS_Store -------------------------------------------------------------------------------- /clients/Makefile: -------------------------------------------------------------------------------- 1 | all: python ruby 2 | 3 | .PHONY: deps 4 | deps: 5 | ./install-protobuf 6 | sudo ldconfig 7 | 8 | .PHONY: python 9 | python: 10 | $(MAKE) -C python 11 | 12 | .PHONY: ruby 13 | ruby: 14 | $(MAKE) -C ruby 15 | -------------------------------------------------------------------------------- /clients/README.md: -------------------------------------------------------------------------------- 1 | # Node Client 2 | 3 | Node client loads the .proto file in order to populate all the rpc calls that are available to it. 4 | 5 | Simply run `pqsd -connect postgresql://localhost/db` in a seperate terminal, and then run `node example.js` in this. -------------------------------------------------------------------------------- /clients/install-protobuf: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | set -x 4 | which protoc && exit 0 5 | version=${PROTOBUF_VERSION:-3.4.0} 6 | mkdir ~/protobuf || echo 7 | cd ~/protobuf 8 | curl -LO "https://github.com/google/protobuf/releases/download/v${version}/protoc-${version}-linux-x86_64.zip" 9 | unzip protoc*zip -d ~/protobuf 10 | -------------------------------------------------------------------------------- /clients/node/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tmc/pqstream/c9027a0afa15cb7c5412d82eabf12a1dc3f96bd2/clients/node/README.md -------------------------------------------------------------------------------- /clients/node/example.js: -------------------------------------------------------------------------------- 1 | var grpc = require('grpc'); 2 | var path = require('path') 3 | var protoDescriptor = grpc.load(path.resolve(__dirname ,'..', '..', 'pqstream.proto')); 4 | var pqs = protoDescriptor.pqs 5 | var ListenRequest = pqs.ListenRequest; 6 | var PQStream = pqs.PQStream; 7 | 8 | function main() { 9 | var client = new PQStream('0.0.0.0:7000', grpc.credentials.createInsecure()); 10 | var request = new ListenRequest() 11 | request.table_regexp = ".*" 12 | 13 | var call = client.listen(request) 14 | call.on('data', function( data) { 15 | console.log("data received", data) 16 | }) 17 | 18 | call.on('end', function() { 19 | // The server has finished sending 20 | }); 21 | call.on('status', function(status) { 22 | // process status 23 | }); 24 | call.on("error", function(err) { 25 | console.log(err) 26 | }) 27 | } 28 | 29 | main(); -------------------------------------------------------------------------------- /clients/node/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "event.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "grpc": "^1.6.6" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /clients/python/.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | branch = True 3 | -------------------------------------------------------------------------------- /clients/python/Makefile: -------------------------------------------------------------------------------- 1 | all: lint 2 | 3 | test: 4 | TEST_PYTHON_INTEGRATION_EXEC="cd clients/python; coverage run example.py" go test -v github.com/tmc/pqstream -run TestServer_Listen/python_integration 5 | bash -c 'bash <(curl -s https://codecov.io/bash) -F python' 6 | 7 | generate: 8 | python -m grpc_tools.protoc -I ../.. -I ../../vendor -I ../../../../.. --python_out=. --grpc_python_out=. ../../pqstream.proto 9 | git diff --exit-code 10 | 11 | deps: 12 | pip install -r requirements.txt 13 | pip install -r requirements.dev.txt 14 | 15 | lint: 16 | pylint example.py 17 | -------------------------------------------------------------------------------- /clients/python/example.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """PQstream Python example client 4 | 5 | This client connects to a running PQstream instance running at 6 | localhost on port 7000 and processes, when called from the command 7 | line, serveral messages and then exits. The payload of the messages 8 | will be printed to stdout. 9 | """ 10 | 11 | import os 12 | 13 | import grpc 14 | import pqstream_pb2_grpc 15 | import pqstream_pb2 16 | 17 | def run(messages): 18 | """process a set number of messages""" 19 | port = os.environ.get("PORT", 7000) 20 | channel = grpc.insecure_channel('localhost:{}'.format(port)) 21 | stub = pqstream_pb2_grpc.PQStreamStub(channel) 22 | 23 | request = pqstream_pb2.ListenRequest() 24 | request.table_regexp = ".*" 25 | 26 | i = 0 27 | for event in stub.Listen(request): 28 | print("OP: {0}".format(event.op)) 29 | print("Table: {0}.{1}".format(event.schema, event.table)) 30 | print(event.payload) 31 | i = i + 1 32 | if i >= messages: 33 | return 34 | 35 | if __name__ == "__main__": 36 | print("Now receiving messages.") 37 | run(10) 38 | -------------------------------------------------------------------------------- /clients/python/pqstream_pb2_grpc.py: -------------------------------------------------------------------------------- 1 | # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! 2 | import grpc 3 | 4 | import pqstream_pb2 as pqstream__pb2 5 | 6 | 7 | class PQStreamStub(object): 8 | # missing associated documentation comment in .proto file 9 | pass 10 | 11 | def __init__(self, channel): 12 | """Constructor. 13 | 14 | Args: 15 | channel: A grpc.Channel. 16 | """ 17 | self.Listen = channel.unary_stream( 18 | '/pqs.PQStream/Listen', 19 | request_serializer=pqstream__pb2.ListenRequest.SerializeToString, 20 | response_deserializer=pqstream__pb2.Event.FromString, 21 | ) 22 | 23 | 24 | class PQStreamServicer(object): 25 | # missing associated documentation comment in .proto file 26 | pass 27 | 28 | def Listen(self, request, context): 29 | """Listen responds with a stream of database operations. 30 | """ 31 | context.set_code(grpc.StatusCode.UNIMPLEMENTED) 32 | context.set_details('Method not implemented!') 33 | raise NotImplementedError('Method not implemented!') 34 | 35 | 36 | def add_PQStreamServicer_to_server(servicer, server): 37 | rpc_method_handlers = { 38 | 'Listen': grpc.unary_stream_rpc_method_handler( 39 | servicer.Listen, 40 | request_deserializer=pqstream__pb2.ListenRequest.FromString, 41 | response_serializer=pqstream__pb2.Event.SerializeToString, 42 | ), 43 | } 44 | generic_handler = grpc.method_handlers_generic_handler( 45 | 'pqs.PQStream', rpc_method_handlers) 46 | server.add_generic_rpc_handlers((generic_handler,)) 47 | -------------------------------------------------------------------------------- /clients/python/requirements.dev.txt: -------------------------------------------------------------------------------- 1 | coverage 2 | grpcio-tools 3 | pylint 4 | -------------------------------------------------------------------------------- /clients/python/requirements.txt: -------------------------------------------------------------------------------- 1 | grpcio 2 | -------------------------------------------------------------------------------- /clients/ruby/.gitignore: -------------------------------------------------------------------------------- 1 | pqstream*.gem 2 | -------------------------------------------------------------------------------- /clients/ruby/.rubocop.yml: -------------------------------------------------------------------------------- 1 | AllCops: 2 | Exclude: 3 | - 'lib/pqstream_pb.rb' 4 | - 'lib/pqstream_services_pb.rb' 5 | -------------------------------------------------------------------------------- /clients/ruby/.ruby-version: -------------------------------------------------------------------------------- 1 | 2.4.1 2 | -------------------------------------------------------------------------------- /clients/ruby/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source 'https://rubygems.org' 4 | 5 | # Specify your gem's dependencies in pqstream.gemspec 6 | gemspec 7 | -------------------------------------------------------------------------------- /clients/ruby/Gemfile.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: . 3 | specs: 4 | pqstream (0.0.1) 5 | grpc (~> 1) 6 | 7 | GEM 8 | remote: https://rubygems.org/ 9 | specs: 10 | addressable (2.5.2) 11 | public_suffix (>= 2.0.2, < 4.0) 12 | ast (2.3.0) 13 | diff-lcs (1.3) 14 | docile (1.1.5) 15 | faraday (0.13.1) 16 | multipart-post (>= 1.2, < 3) 17 | google-protobuf (3.4.1.1) 18 | googleapis-common-protos-types (1.0.0) 19 | google-protobuf (~> 3.0) 20 | googleauth (0.5.3) 21 | faraday (~> 0.12) 22 | jwt (~> 1.4) 23 | logging (~> 2.0) 24 | memoist (~> 0.12) 25 | multi_json (~> 1.11) 26 | os (~> 0.9) 27 | signet (~> 0.7) 28 | grpc (1.6.6) 29 | google-protobuf (~> 3.1) 30 | googleapis-common-protos-types (~> 1.0.0) 31 | googleauth (~> 0.5.1) 32 | grpc-tools (1.6.6) 33 | json (2.1.0) 34 | jwt (1.5.6) 35 | little-plugger (1.1.4) 36 | logging (2.2.2) 37 | little-plugger (~> 1.1) 38 | multi_json (~> 1.10) 39 | memoist (0.16.0) 40 | multi_json (1.12.2) 41 | multipart-post (2.0.0) 42 | os (0.9.6) 43 | parallel (1.12.1) 44 | parser (2.4.0.2) 45 | ast (~> 2.3) 46 | powerpack (0.1.1) 47 | public_suffix (3.0.0) 48 | rainbow (3.0.0) 49 | rspec (3.7.0) 50 | rspec-core (~> 3.7.0) 51 | rspec-expectations (~> 3.7.0) 52 | rspec-mocks (~> 3.7.0) 53 | rspec-core (3.7.0) 54 | rspec-support (~> 3.7.0) 55 | rspec-expectations (3.7.0) 56 | diff-lcs (>= 1.2.0, < 2.0) 57 | rspec-support (~> 3.7.0) 58 | rspec-mocks (3.7.0) 59 | diff-lcs (>= 1.2.0, < 2.0) 60 | rspec-support (~> 3.7.0) 61 | rspec-support (3.7.0) 62 | rubocop (0.52.1) 63 | parallel (~> 1.10) 64 | parser (>= 2.4.0.2, < 3.0) 65 | powerpack (~> 0.1) 66 | rainbow (>= 2.2.2, < 4.0) 67 | ruby-progressbar (~> 1.7) 68 | unicode-display_width (~> 1.0, >= 1.0.1) 69 | ruby-progressbar (1.9.0) 70 | signet (0.7.3) 71 | addressable (~> 2.3) 72 | faraday (~> 0.9) 73 | jwt (~> 1.5) 74 | multi_json (~> 1.10) 75 | simplecov (0.15.1) 76 | docile (~> 1.1.0) 77 | json (>= 1.8, < 3) 78 | simplecov-html (~> 0.10.0) 79 | simplecov-html (0.10.2) 80 | unicode-display_width (1.3.0) 81 | 82 | PLATFORMS 83 | ruby 84 | 85 | DEPENDENCIES 86 | grpc-tools (~> 1) 87 | pqstream! 88 | rspec 89 | rubocop 90 | simplecov 91 | 92 | BUNDLED WITH 93 | 1.14.6 94 | -------------------------------------------------------------------------------- /clients/ruby/Makefile: -------------------------------------------------------------------------------- 1 | all: lint 2 | 3 | test: 4 | CODECOV_FLAG=ruby bundle exec rspec -fd 5 | 6 | generate: 7 | grpc_tools_ruby_protoc -I ../.. -I ../../vendor -I ../../../../.. --ruby_out=lib --grpc_out=lib ../../pqstream.proto 8 | ./protoc-fixup 9 | 10 | deps: 11 | bundle install 12 | 13 | gem: 14 | gem build pqstream.gemspec 15 | 16 | lint: 17 | rubocop 18 | -------------------------------------------------------------------------------- /clients/ruby/basic_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'pqstream' 4 | 5 | c = Pqs::PQStream::Client.new('localhost:7000') 6 | c.listen.each { |x| puts x.to_json } 7 | -------------------------------------------------------------------------------- /clients/ruby/lib/pqstream.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'pqstream/version' 4 | require 'pqstream_services_pb' 5 | 6 | module Pqs 7 | module PQStream 8 | # Client allows subscribing to pqstream streams. 9 | class Client 10 | def initialize(addr) 11 | @stub = Pqs::PQStream::Stub.new(addr, :this_channel_is_insecure) 12 | end 13 | 14 | def listen(opts = { table_regexp: '.*' }) 15 | @stub.listen(Pqs::ListenRequest.new(opts)) 16 | end 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /clients/ruby/lib/pqstream/version.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Pqstream 4 | VERSION = '0.1.0' 5 | end 6 | -------------------------------------------------------------------------------- /clients/ruby/lib/pqstream_pb.rb: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # source: pqstream.proto 3 | 4 | require 'google/protobuf' 5 | 6 | require 'google/protobuf/well_known_types' 7 | Google::Protobuf::DescriptorPool.generated_pool.build do 8 | add_message "pqs.ListenRequest" do 9 | optional :table_regexp, :string, 1 10 | end 11 | add_message "pqs.RawEvent" do 12 | optional :schema, :string, 1 13 | optional :table, :string, 2 14 | optional :op, :enum, 3, "pqs.Operation" 15 | optional :id, :string, 4 16 | optional :payload, :message, 5, "google.protobuf.Struct" 17 | optional :previous, :message, 6, "google.protobuf.Struct" 18 | end 19 | add_message "pqs.Event" do 20 | optional :schema, :string, 1 21 | optional :table, :string, 2 22 | optional :op, :enum, 3, "pqs.Operation" 23 | optional :id, :string, 4 24 | optional :payload, :message, 5, "google.protobuf.Struct" 25 | optional :changes, :message, 6, "google.protobuf.Struct" 26 | end 27 | add_enum "pqs.Operation" do 28 | value :UNKNOWN, 0 29 | value :INSERT, 1 30 | value :UPDATE, 2 31 | value :DELETE, 3 32 | value :TRUNCATE, 4 33 | end 34 | end 35 | 36 | module Pqs 37 | ListenRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("pqs.ListenRequest").msgclass 38 | RawEvent = Google::Protobuf::DescriptorPool.generated_pool.lookup("pqs.RawEvent").msgclass 39 | Event = Google::Protobuf::DescriptorPool.generated_pool.lookup("pqs.Event").msgclass 40 | Operation = Google::Protobuf::DescriptorPool.generated_pool.lookup("pqs.Operation").enummodule 41 | end 42 | -------------------------------------------------------------------------------- /clients/ruby/lib/pqstream_services_pb.rb: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # Source: pqstream.proto for package 'pqs' 3 | 4 | require 'grpc' 5 | require 'pqstream_pb' 6 | 7 | module Pqs 8 | module PQStream 9 | class Service 10 | 11 | include GRPC::GenericService 12 | 13 | self.marshal_class_method = :encode 14 | self.unmarshal_class_method = :decode 15 | self.service_name = 'pqs.PQStream' 16 | 17 | # Listen responds with a stream of database operations. 18 | rpc :Listen, ListenRequest, stream(Event) 19 | end 20 | 21 | Stub = Service.rpc_stub_class 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /clients/ruby/pqstream.gemspec: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | Gem::Specification.new do |s| 4 | s.name = 'pqstream' 5 | s.version = '0.0.1' 6 | # s.date = '' 7 | s.summary = '' 8 | s.description = '' 9 | s.authors = [''] 10 | s.email = '' 11 | s.files = [ 12 | 'lib/pqstream.rb', 13 | 'lib/pqstream/version.rb', 14 | 'lib/pqstream_pb.rb', 15 | 'lib/pqstream_services_pb.rb' 16 | ] 17 | s.homepage = 'http://github.com/tmc/pqstream' 18 | s.license = 'ISC' 19 | 20 | s.add_runtime_dependency 'grpc', '~> 1' 21 | s.add_development_dependency 'codecov' 22 | s.add_development_dependency 'grpc-tools', '~> 1' 23 | s.add_development_dependency 'rspec' 24 | s.add_development_dependency 'rubocop' 25 | s.add_development_dependency 'simplecov' 26 | end 27 | -------------------------------------------------------------------------------- /clients/ruby/protoc-fixup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sed=$(which gsed || which sed) 3 | ${sed} -i 's/github.com\/golang\/protobuf\/ptypes\/struct\/struct_pb/google\/protobuf\/well_known_types/' lib/pqstream_pb.rb 4 | -------------------------------------------------------------------------------- /clients/ruby/spec/pqstream_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | RSpec.describe Pqstream do 6 | it 'has a version number' do 7 | expect(Pqstream::VERSION).not_to be nil 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /clients/ruby/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'simplecov' 4 | SimpleCov.start 5 | 6 | require 'codecov' 7 | SimpleCov.formatter = SimpleCov::Formatter::Codecov 8 | 9 | require 'bundler/setup' 10 | require 'pqstream' 11 | 12 | RSpec.configure do |config| 13 | # Enable flags like --only-failures and --next-failure 14 | config.example_status_persistence_file_path = '.rspec_status' 15 | 16 | config.expect_with :rspec do |c| 17 | c.syntax = :expect 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /cmd/pqs/main.go: -------------------------------------------------------------------------------- 1 | // pqs is the client for psqd which allows subscription to change events in a postgres database cluster. 2 | package main 3 | 4 | import ( 5 | "context" 6 | "flag" 7 | "fmt" 8 | "log" 9 | "net/http" 10 | "os" 11 | 12 | _ "net/http/pprof" 13 | 14 | "github.com/google/gops/agent" 15 | _ "golang.org/x/net/trace" 16 | "google.golang.org/grpc" 17 | 18 | "github.com/golang/protobuf/jsonpb" 19 | _ "github.com/kardianos/minwinsvc" // import minwinsvc for windows service support 20 | "github.com/pkg/errors" 21 | "github.com/tmc/pqstream/ctxutil" 22 | "github.com/tmc/pqstream/pqs" 23 | ) 24 | 25 | var ( 26 | pqsdAddr = flag.String("connect", ":7000", "pqsd address") 27 | tableRegexp = flag.String("tables", ".*", "regexp of tables to match") 28 | debugAddr = flag.String("debugaddr", ":7001", "listen debug addr") 29 | ) 30 | 31 | func main() { 32 | flag.Parse() 33 | if err := run(ctxutil.BackgroundWithSignals()); err != nil { 34 | fmt.Fprintln(os.Stderr, err) 35 | os.Exit(1) 36 | } 37 | } 38 | 39 | func run(ctx context.Context) error { 40 | // starts the gops diagnostics agent 41 | if err := agent.Listen(agent.Options{ 42 | ShutdownCleanup: true, 43 | }); err != nil { 44 | return err 45 | } 46 | 47 | conn, err := grpc.DialContext(ctx, *pqsdAddr, grpc.WithInsecure()) 48 | if err != nil { 49 | return errors.Wrap(err, "dial") 50 | } 51 | defer conn.Close() 52 | 53 | c, err := pqs.NewPQStreamClient(conn).Listen(ctx, &pqs.ListenRequest{ 54 | TableRegexp: *tableRegexp, 55 | }) 56 | if err != nil { 57 | return err 58 | } 59 | go func() { 60 | <-ctx.Done() 61 | log.Println("context done.") 62 | }() 63 | go http.ListenAndServe(*debugAddr, nil) 64 | 65 | // TODO(tmc): add format flag to control output (probably offer text/template) 66 | m := &jsonpb.Marshaler{} 67 | for { 68 | ev, err := c.Recv() 69 | if err != nil { 70 | return err 71 | } 72 | if err := m.Marshal(os.Stdout, ev); err != nil { 73 | return err 74 | } 75 | fmt.Println() 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /cmd/pqsd/main.go: -------------------------------------------------------------------------------- 1 | // pqsd is an agent that connects to a postgresql cluster and manages stream emission. 2 | package main 3 | 4 | import ( 5 | "context" 6 | "flag" 7 | "fmt" 8 | "log" 9 | "net" 10 | "os" 11 | "regexp" 12 | "strings" 13 | "time" 14 | 15 | _ "net/http/pprof" 16 | 17 | _ "golang.org/x/net/trace" 18 | "google.golang.org/grpc" 19 | 20 | "github.com/google/gops/agent" 21 | "github.com/pkg/errors" 22 | "github.com/sirupsen/logrus" 23 | "github.com/tmc/pqstream" 24 | "github.com/tmc/pqstream/ctxutil" 25 | "github.com/tmc/pqstream/pqs" 26 | 27 | _ "github.com/kardianos/minwinsvc" // import minwinsvc for windows service support 28 | ) 29 | 30 | var ( 31 | verbose = flag.Bool("v", false, "be verbose") 32 | postgresCluster = flag.String("connect", "", "postgresql cluster address") 33 | tableRegexp = flag.String("tables", ".*", "regexp of tables to manage") 34 | remove = flag.Bool("remove", false, "if true, remove triggers and exit") 35 | grpcAddr = flag.String("addr", ":7000", "listen addr") 36 | debugAddr = flag.String("debugaddr", ":7001", "listen debug addr") 37 | redactions = flag.String("redactions", "", "details of fields to redact in JSON format i.e '{\"public\":{\"users\":[\"password\",\"ssn\"]}}'") 38 | ) 39 | 40 | const ( 41 | gracefulStopMaxWait = 10 * time.Second 42 | ) 43 | 44 | func main() { 45 | flag.Parse() 46 | if err := run(ctxutil.BackgroundWithSignals()); err != nil { 47 | fmt.Fprintln(os.Stderr, err) 48 | os.Exit(1) 49 | } 50 | } 51 | 52 | func run(ctx context.Context) error { 53 | // starts the gops diagnostics agent 54 | if err := agent.Listen(agent.Options{ 55 | ShutdownCleanup: true, 56 | }); err != nil { 57 | return err 58 | } 59 | 60 | lis, err := net.Listen("tcp", *grpcAddr) 61 | if err != nil { 62 | return err 63 | } 64 | 65 | tableRe, err := regexp.Compile(*tableRegexp) 66 | if err != nil { 67 | return err 68 | } 69 | 70 | opts := []pqstream.ServerOption{ 71 | pqstream.WithTableRegexp(tableRe), 72 | } 73 | 74 | if (len(*redactions)) > 0 { 75 | rfields, err := pqstream.DecodeRedactions(*redactions) 76 | if err != nil { 77 | return errors.Wrap(err, "decoding redactions") 78 | } 79 | 80 | if len(rfields) > 0 { 81 | opts = append(opts, pqstream.WithFieldRedactions(rfields)) 82 | } 83 | } 84 | if *verbose { 85 | l := logrus.New() 86 | l.Level = logrus.DebugLevel 87 | opts = append(opts, pqstream.WithLogger(l)) 88 | } 89 | 90 | server, err := pqstream.NewServer(*postgresCluster, opts...) 91 | if err != nil { 92 | return err 93 | } 94 | 95 | err = errors.Wrap(server.RemoveTriggers(), "RemoveTriggers") 96 | if err != nil || *remove { 97 | return err 98 | } 99 | 100 | if err = server.InstallTriggers(); err != nil { 101 | return errors.Wrap(err, "InstallTriggers") 102 | } 103 | 104 | go func() { 105 | if err = server.HandleEvents(ctx); err != nil { 106 | // TODO(tmc): try to be more graceful 107 | log.Fatalln(err) 108 | } 109 | }() 110 | 111 | s := grpc.NewServer() 112 | pqs.RegisterPQStreamServer(s, server) 113 | go func() { 114 | <-ctx.Done() 115 | s.GracefulStop() 116 | <-time.After(gracefulStopMaxWait) 117 | s.Stop() 118 | }() 119 | if *verbose { 120 | log.Println("listening on", *grpcAddr, "and", *debugAddr) 121 | } 122 | err = s.Serve(lis) 123 | if strings.Contains(err.Error(), "use of closed network connection") { 124 | // return nil for expected error from the accept loop 125 | return nil 126 | } 127 | return err 128 | } 129 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | 2 | fixes: 3 | - "lib/::clients/ruby/lib/" 4 | -------------------------------------------------------------------------------- /contrib/cmd/pqsamq/main.go: -------------------------------------------------------------------------------- 1 | // pqs is the client for psqd which allows subscription to change events in a postgres database cluster. 2 | package main 3 | 4 | import ( 5 | "context" 6 | "flag" 7 | "fmt" 8 | "log" 9 | "net/http" 10 | "os" 11 | "strings" 12 | 13 | _ "net/http/pprof" 14 | 15 | "github.com/go-stomp/stomp" 16 | "github.com/google/gops/agent" 17 | _ "golang.org/x/net/trace" 18 | "google.golang.org/grpc" 19 | 20 | "github.com/golang/protobuf/jsonpb" 21 | _ "github.com/kardianos/minwinsvc" // import minwinsvc for windows service support 22 | "github.com/pkg/errors" 23 | "github.com/tmc/pqstream/ctxutil" 24 | "github.com/tmc/pqstream/pqs" 25 | ) 26 | 27 | var ( 28 | pqsdAddr = flag.String("connect", ":7000", "pqsd address") 29 | tableRegexp = flag.String("tables", ".*", "regexp of tables to match") 30 | debugAddr = flag.String("debugaddr", ":7001", "listen debug addr") 31 | activeMqAddr = flag.String("amqaddr", "localhost:61613", "ActiveMq server to send messages to") 32 | actvieMqQueue = flag.String("amqqueue", "/queue/test", "ActiveMq queue to send messages to") 33 | ) 34 | 35 | func main() { 36 | flag.Parse() 37 | if err := run(ctxutil.BackgroundWithSignals()); err != nil { 38 | fmt.Fprintln(os.Stderr, err) 39 | os.Exit(1) 40 | } 41 | } 42 | 43 | func run(ctx context.Context) error { 44 | // starts the gops diagnostics agent 45 | if err := agent.Listen(agent.Options{ 46 | ShutdownCleanup: true, 47 | }); err != nil { 48 | return err 49 | } 50 | 51 | conn, err := grpc.DialContext(ctx, *pqsdAddr, grpc.WithInsecure()) 52 | if err != nil { 53 | return errors.Wrap(err, "dial") 54 | } 55 | defer conn.Close() 56 | 57 | c, err := pqs.NewPQStreamClient(conn).Listen(ctx, &pqs.ListenRequest{ 58 | TableRegexp: *tableRegexp, 59 | }) 60 | if err != nil { 61 | return err 62 | } 63 | go func() { 64 | <-ctx.Done() 65 | log.Println("context done.") 66 | }() 67 | go http.ListenAndServe(*debugAddr, nil) 68 | 69 | amqConn, err := stomp.Dial("tcp", *activeMqAddr) 70 | if err != nil { 71 | return errors.Wrap(err, "dialing amqp address failed") 72 | } 73 | defer amqConn.Disconnect() 74 | 75 | m := &jsonpb.Marshaler{} 76 | for { 77 | ev, err := c.Recv() 78 | if err != nil { 79 | return err 80 | } 81 | if strings.Compare(*activeMqAddr, "") != 0 && strings.Compare(*actvieMqQueue, "") != 0 { 82 | message, err := m.MarshalToString(ev) 83 | if err != nil { 84 | return err 85 | } 86 | if err := amqConn.Send(*actvieMqQueue, "text/plain", []byte(message)); err != nil { 87 | return err 88 | } 89 | } 90 | if err := m.Marshal(os.Stdout, ev); err != nil { 91 | return err 92 | } 93 | fmt.Println() 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /ctxutil/background_signals.go: -------------------------------------------------------------------------------- 1 | package ctxutil 2 | 3 | import ( 4 | "context" 5 | "os" 6 | "os/signal" 7 | ) 8 | 9 | // BackgroundWithSignals returns a Context that will be 10 | // canceled with the process receives a SIGINT signal. 11 | // This function starts a goroutine and listens for signals. 12 | func BackgroundWithSignals() context.Context { 13 | ctx, cancelFn := context.WithCancel(context.Background()) 14 | go func() { 15 | c := make(chan os.Signal, 1) 16 | signal.Notify(c, os.Interrupt) 17 | <-c 18 | signal.Reset(os.Interrupt) 19 | cancelFn() 20 | }() 21 | return ctx 22 | } 23 | -------------------------------------------------------------------------------- /gen.go: -------------------------------------------------------------------------------- 1 | //go:generate protoc -I . -I ../../.. pqstream.proto --go_out=plugins=grpc:pqs 2 | 3 | package pqstream 4 | -------------------------------------------------------------------------------- /install-go: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | wget https://redirector.gvt1.com/edgedl/go/go1.9.2.linux-amd64.tar.gz 4 | tar xf go*tar.gz 5 | mv go "$HOME/goroot" 6 | -------------------------------------------------------------------------------- /lint: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | command -v gometalinter > /dev/null || go get github.com/alecthomas/gometalinter 4 | command -v revgrep > /dev/null || go get github.com/bradleyfalzon/revgrep/cmd/revgrep 5 | 6 | set +o pipefail 7 | command -v errcheck > /dev/null || gometalinter -i 8 | gometalinter -t --vendored-linters --cyclo-over=15 --deadline=2m --disable-all \ 9 | --enable=errcheck \ 10 | --enable=vet \ 11 | --enable=vetshadow \ 12 | --enable=gotype \ 13 | --enable=deadcode \ 14 | --enable=gocyclo \ 15 | --enable=golint \ 16 | --enable=varcheck \ 17 | --enable=structcheck \ 18 | --enable=aligncheck \ 19 | --enable=megacheck \ 20 | --enable=dupl \ 21 | --enable=ineffassign \ 22 | --enable=interfacer \ 23 | --enable=unconvert \ 24 | --enable=goconst \ 25 | --enable=gas \ 26 | --enable=misspell \ 27 | "$@" 2>&1 | tee lint.out 28 | set -o pipefail 29 | 30 | # only error on newly introduced lint issues 31 | cat lint.out| revgrep master 32 | -------------------------------------------------------------------------------- /patch.go: -------------------------------------------------------------------------------- 1 | package pqstream 2 | 3 | import ( 4 | "bytes" 5 | 6 | jsonpatch "github.com/evanphx/json-patch" 7 | "github.com/golang/protobuf/jsonpb" 8 | ptypes_struct "github.com/golang/protobuf/ptypes/struct" 9 | ) 10 | 11 | func generatePatch(a, b *ptypes_struct.Struct) (*ptypes_struct.Struct, error) { 12 | abytes := &bytes.Buffer{} 13 | bbytes := &bytes.Buffer{} 14 | m := &jsonpb.Marshaler{} 15 | 16 | if a != nil { 17 | if err := m.Marshal(abytes, a); err != nil { 18 | return nil, err 19 | } 20 | } 21 | if b != nil { 22 | if err := m.Marshal(bbytes, b); err != nil { 23 | return nil, err 24 | } 25 | } 26 | if abytes.Len() == 0 { 27 | abytes.Write([]byte("{}")) 28 | } 29 | if bbytes.Len() == 0 { 30 | bbytes.Write([]byte("{}")) 31 | } 32 | p, err := jsonpatch.CreateMergePatch(abytes.Bytes(), bbytes.Bytes()) 33 | if err != nil { 34 | return nil, err 35 | } 36 | r := &ptypes_struct.Struct{} 37 | rbytes := bytes.NewReader(p) 38 | err = (&jsonpb.Unmarshaler{}).Unmarshal(rbytes, r) 39 | return r, err 40 | } 41 | -------------------------------------------------------------------------------- /patch_test.go: -------------------------------------------------------------------------------- 1 | package pqstream 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/golang/protobuf/jsonpb" 7 | ptypes_struct "github.com/golang/protobuf/ptypes/struct" 8 | "github.com/google/go-cmp/cmp" 9 | ) 10 | 11 | func Test_generatePatch(t *testing.T) { 12 | type args struct { 13 | a *ptypes_struct.Struct 14 | b *ptypes_struct.Struct 15 | } 16 | tests := []struct { 17 | name string 18 | args args 19 | wantJSON string 20 | wantErr bool 21 | }{ 22 | {"nils", args{nil, nil}, "{}", false}, 23 | {"empties", args{&ptypes_struct.Struct{}, &ptypes_struct.Struct{}}, "{}", false}, 24 | {"basic", args{&ptypes_struct.Struct{}, &ptypes_struct.Struct{ 25 | Fields: map[string]*ptypes_struct.Value{ 26 | "foo": { 27 | Kind: &ptypes_struct.Value_StringValue{ 28 | StringValue: "bar", 29 | }, 30 | }, 31 | }, 32 | }}, `{"foo":"bar"}`, false}, 33 | } 34 | for _, tt := range tests { 35 | t.Run(tt.name, func(t *testing.T) { 36 | got, err := generatePatch(tt.args.a, tt.args.b) 37 | if (err != nil) != tt.wantErr { 38 | t.Errorf("generatePatch() error = %v, wantErr %v", err, tt.wantErr) 39 | return 40 | } 41 | gotJSON, err := (&jsonpb.Marshaler{}).MarshalToString(got) 42 | if err != nil { 43 | t.Error(err) 44 | } 45 | if !cmp.Equal(gotJSON, tt.wantJSON) { 46 | t.Errorf("generatePatch() = %v, want %v\n%s", gotJSON, tt.wantJSON, cmp.Diff(gotJSON, tt.wantJSON)) 47 | } 48 | }) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /pqstream.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package pqs; 3 | 4 | import "github.com/golang/protobuf/ptypes/struct/struct.proto"; 5 | 6 | service PQStream { 7 | // Listen responds with a stream of database operations. 8 | rpc Listen (ListenRequest) returns (stream Event) {} 9 | } 10 | 11 | // A request to listen to database event streams. 12 | message ListenRequest { 13 | // if provided, this string will be used to match table names to track. 14 | string table_regexp = 1; 15 | } 16 | 17 | // An operation in the database. 18 | enum Operation { 19 | UNKNOWN = 0; 20 | INSERT = 1; 21 | UPDATE = 2; 22 | DELETE = 3; 23 | TRUNCATE = 4; 24 | } 25 | 26 | // RawEvent is an internal type. 27 | message RawEvent { 28 | string schema = 1; 29 | string table = 2; 30 | Operation op = 3; 31 | string id = 4; 32 | google.protobuf.Struct payload = 5; 33 | google.protobuf.Struct previous = 6; 34 | } 35 | 36 | // A database event. 37 | message Event { 38 | string schema = 1; 39 | string table = 2; 40 | Operation op = 3; 41 | // if the id column exists, this will populate it 42 | string id = 4; 43 | // payload is a json encoded representation of the changed object. 44 | google.protobuf.Struct payload = 5; 45 | // changes is, in the event of op==UPDATE an RFC7386 JSON merge patch. 46 | google.protobuf.Struct changes = 6; 47 | } 48 | 49 | -------------------------------------------------------------------------------- /queries.go: -------------------------------------------------------------------------------- 1 | package pqstream 2 | 3 | var ( 4 | sqlQueryTables = ` 5 | SELECT table_name 6 | FROM information_schema.tables 7 | WHERE table_schema='public' 8 | AND table_type='BASE TABLE' 9 | ` 10 | sqlTriggerFunction = ` 11 | CREATE OR REPLACE FUNCTION pqstream_notify() RETURNS TRIGGER AS $$ 12 | DECLARE 13 | payload json; 14 | previous json; 15 | notification json; 16 | BEGIN 17 | IF (TG_OP = 'DELETE') THEN 18 | payload = row_to_json(OLD); 19 | ELSE 20 | payload = row_to_json(NEW); 21 | END IF; 22 | IF (TG_OP = 'UPDATE') THEN 23 | previous = row_to_json(OLD); 24 | END IF; 25 | 26 | notification = json_build_object( 27 | 'schema', TG_TABLE_SCHEMA, 28 | 'table', TG_TABLE_NAME, 29 | 'op', TG_OP, 30 | 'id', json_extract_path(payload, 'id')::text, 31 | 'payload', payload, 32 | 'previous', previous); 33 | IF (length(notification::text) >= 8000) THEN 34 | notification = json_build_object( 35 | 'schema', TG_TABLE_SCHEMA, 36 | 'table', TG_TABLE_NAME, 37 | 'op', TG_OP, 38 | 'id', json_extract_path(payload, 'id')::text, 39 | 'payload', payload); 40 | END IF; 41 | IF (length(notification::text) >= 8000) THEN 42 | notification = json_build_object( 43 | 'schema', TG_TABLE_SCHEMA, 44 | 'table', TG_TABLE_NAME, 45 | 'op', TG_OP, 46 | 'id', json_extract_path(payload, 'id')::text); 47 | END IF; 48 | 49 | PERFORM pg_notify('pqstream_notify', notification::text); 50 | RETURN NULL; 51 | END; 52 | $$ LANGUAGE plpgsql; 53 | ` 54 | sqlRemoveTrigger = ` 55 | DROP TRIGGER IF EXISTS pqstream_notify ON %s 56 | ` 57 | sqlInstallTrigger = ` 58 | CREATE TRIGGER pqstream_notify 59 | AFTER INSERT OR UPDATE OR DELETE ON %s 60 | FOR EACH ROW EXECUTE PROCEDURE pqstream_notify(); 61 | ` 62 | sqlFetchRowByID = ` 63 | SELECT row_to_json(r)::text from (select * from %s where id = $1::%s) r; 64 | ` 65 | ) 66 | -------------------------------------------------------------------------------- /redactions.go: -------------------------------------------------------------------------------- 1 | package pqstream 2 | 3 | import ( 4 | "encoding/json" 5 | "strings" 6 | 7 | "github.com/tmc/pqstream/pqs" 8 | ) 9 | 10 | // FieldRedactions describes how redaction fields are specified. 11 | // Top level map key is the schema, inner map key is the table and slice is the fields to redact. 12 | type FieldRedactions map[string]map[string][]string 13 | 14 | // DecodeRedactions returns a FieldRedactions map decoded from redactions specified in json format. 15 | func DecodeRedactions(r string) (FieldRedactions, error) { 16 | rfields := make(FieldRedactions) 17 | if err := json.NewDecoder(strings.NewReader(r)).Decode(&rfields); err != nil { 18 | return nil, err 19 | } 20 | 21 | return rfields, nil 22 | } 23 | 24 | // WithFieldRedactions controls which fields are redacted from the feed. 25 | func WithFieldRedactions(r FieldRedactions) ServerOption { 26 | return func(s *Server) { 27 | s.redactions = r 28 | } 29 | } 30 | 31 | // redactFields search through redactionMap if there's any redacted fields 32 | // specified that match the fields of the current event. 33 | func (s *Server) redactFields(e *pqs.RawEvent) { 34 | if tables, ok := s.redactions[e.GetSchema()]; ok { 35 | if fields, ok := tables[e.GetTable()]; ok { 36 | for _, rf := range fields { 37 | if e.Payload != nil { 38 | if _, ok := e.Payload.Fields[rf]; ok { 39 | //remove field from payload 40 | delete(e.Payload.Fields, rf) 41 | } 42 | } 43 | if e.Previous != nil { 44 | if _, ok := e.Previous.Fields[rf]; ok { 45 | //remove field from previous payload 46 | delete(e.Previous.Fields, rf) 47 | } 48 | } 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /redactions_test.go: -------------------------------------------------------------------------------- 1 | package pqstream 2 | 3 | import ( 4 | "testing" 5 | 6 | google_protobuf "github.com/golang/protobuf/ptypes/struct" 7 | "github.com/google/go-cmp/cmp" 8 | "github.com/tmc/pqstream/pqs" 9 | ) 10 | 11 | func TestServer_redactFields(t *testing.T) { 12 | 13 | rfields := FieldRedactions{ 14 | "public": {"users": []string{ 15 | "password", 16 | "email", 17 | }, 18 | }, 19 | } 20 | 21 | s, err := NewServer(testConnectionString, WithFieldRedactions(rfields)) 22 | if err != nil { 23 | t.Fatal(err) 24 | } 25 | 26 | event := &pqs.RawEvent{ 27 | Schema: "public", 28 | Table: "users", 29 | Payload: &google_protobuf.Struct{ 30 | Fields: map[string]*google_protobuf.Value{ 31 | "first_name": { 32 | Kind: &google_protobuf.Value_StringValue{StringValue: "first_name"}, 33 | }, 34 | "last_name": { 35 | Kind: &google_protobuf.Value_StringValue{StringValue: "last_name"}, 36 | }, 37 | "password": { 38 | Kind: &google_protobuf.Value_StringValue{StringValue: "_insecure_"}, 39 | }, 40 | "email": { 41 | Kind: &google_protobuf.Value_StringValue{StringValue: "someone@corp.com"}, 42 | }, 43 | }, 44 | }, 45 | } 46 | 47 | type args struct { 48 | redactions FieldRedactions 49 | incoming *pqs.RawEvent 50 | expected *pqs.RawEvent 51 | } 52 | tests := []struct { 53 | name string 54 | args args 55 | }{ 56 | {"nil", args{redactions: rfields, incoming: nil}}, 57 | {"nil_payload", args{redactions: rfields, incoming: &pqs.RawEvent{}}}, 58 | {"nil_payload_matching", args{redactions: rfields, incoming: &pqs.RawEvent{ 59 | Schema: "public", 60 | Table: "users", 61 | }}}, 62 | {"nil_payload_nonnil_previous", args{redactions: rfields, incoming: &pqs.RawEvent{ 63 | Schema: "public", 64 | Table: "users", 65 | Previous: &google_protobuf.Struct{ 66 | Fields: map[string]*google_protobuf.Value{ 67 | "password": { 68 | Kind: &google_protobuf.Value_StringValue{StringValue: "password"}, 69 | }, 70 | }, 71 | }, 72 | }}}, 73 | { 74 | name: "found", 75 | args: args{ 76 | redactions: rfields, 77 | incoming: event, 78 | expected: &pqs.RawEvent{ 79 | Schema: "public", 80 | Table: "users", 81 | Payload: &google_protobuf.Struct{ 82 | Fields: map[string]*google_protobuf.Value{ 83 | "first_name": { 84 | Kind: &google_protobuf.Value_StringValue{StringValue: "first_name"}, 85 | }, 86 | "last_name": { 87 | Kind: &google_protobuf.Value_StringValue{StringValue: "last_name"}, 88 | }, 89 | }, 90 | }, 91 | }, 92 | }, 93 | }, 94 | { 95 | name: "not_found", 96 | args: args{ 97 | redactions: rfields, 98 | incoming: event, 99 | expected: event, 100 | }, 101 | }, 102 | } 103 | 104 | for _, tt := range tests { 105 | t.Run(tt.name, func(t *testing.T) { 106 | s.redactions = tt.args.redactions 107 | s.redactFields(tt.args.incoming) 108 | 109 | if got := tt.args.incoming; tt.args.expected != nil && !cmp.Equal(got, tt.args.expected) { 110 | t.Errorf("s.redactFields()= %v, want %v", got, tt.args.expected) 111 | } 112 | }) 113 | } 114 | } 115 | 116 | func TestDecodeRedactions(t *testing.T) { 117 | type args struct { 118 | r string 119 | } 120 | tests := []struct { 121 | name string 122 | args args 123 | want FieldRedactions 124 | wantErr bool 125 | }{ 126 | { 127 | name: "basic", 128 | args: args{r: `{"public":{"users":["first_name","last_name","email"]}}`}, 129 | want: FieldRedactions{ 130 | "public": {"users": []string{ 131 | "first_name", 132 | "last_name", 133 | "email", 134 | }, 135 | }, 136 | }, 137 | wantErr: false, 138 | }, 139 | } 140 | for _, tt := range tests { 141 | t.Run(tt.name, func(t *testing.T) { 142 | got, err := DecodeRedactions(tt.args.r) 143 | if (err != nil) != tt.wantErr { 144 | t.Errorf("DecodeRedactions() error = %v, wantErr %v", err, tt.wantErr) 145 | return 146 | } 147 | if !cmp.Equal(got, tt.want) { 148 | t.Errorf("DecodeRedactions() = %v, want %v", got, tt.want) 149 | } 150 | }) 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /server.go: -------------------------------------------------------------------------------- 1 | package pqstream 2 | 3 | import ( 4 | "context" 5 | "database/sql" 6 | "fmt" 7 | "regexp" 8 | "time" 9 | 10 | "github.com/golang/protobuf/jsonpb" 11 | "github.com/sirupsen/logrus" 12 | 13 | "github.com/lib/pq" 14 | "github.com/pkg/errors" 15 | "github.com/tmc/pqstream/pqs" 16 | 17 | ptypes_struct "github.com/golang/protobuf/ptypes/struct" 18 | ) 19 | 20 | const ( 21 | minReconnectInterval = time.Second 22 | maxReconnectInterval = 10 * time.Second 23 | defaultPingInterval = 9 * time.Second 24 | channel = "pqstream_notify" 25 | 26 | fallbackIDColumnType = "integer" // TODO(tmc) parameterize 27 | ) 28 | 29 | // subscription 30 | type subscription struct { 31 | // while fn returns true the subscription will stay active 32 | fn func(*pqs.Event) bool 33 | } 34 | 35 | // Server implements PQStreamServer and manages both client connections and database event monitoring. 36 | type Server struct { 37 | logger logrus.FieldLogger 38 | l *pq.Listener 39 | db *sql.DB 40 | ctx context.Context 41 | 42 | tableRe *regexp.Regexp 43 | 44 | listenerPingInterval time.Duration 45 | subscribe chan *subscription 46 | redactions FieldRedactions 47 | } 48 | 49 | // statically assert that Server satisfies pqs.PQStreamServer 50 | var _ pqs.PQStreamServer = (*Server)(nil) 51 | 52 | // ServerOption allows customization of a new server. 53 | type ServerOption func(*Server) 54 | 55 | // WithTableRegexp controls which tables are managed. 56 | func WithTableRegexp(re *regexp.Regexp) ServerOption { 57 | return func(s *Server) { 58 | s.tableRe = re 59 | } 60 | } 61 | 62 | // WithLogger allows attaching a custom logger. 63 | func WithLogger(l logrus.FieldLogger) ServerOption { 64 | return func(s *Server) { 65 | s.logger = l 66 | } 67 | } 68 | 69 | // WithContext allows supplying a custom context. 70 | func WithContext(ctx context.Context) ServerOption { 71 | return func(s *Server) { 72 | s.ctx = ctx 73 | } 74 | } 75 | 76 | // NewServer prepares a new pqstream server. 77 | func NewServer(connectionString string, opts ...ServerOption) (*Server, error) { 78 | s := &Server{ 79 | subscribe: make(chan *subscription), 80 | redactions: make(FieldRedactions), 81 | 82 | ctx: context.Background(), 83 | listenerPingInterval: defaultPingInterval, 84 | } 85 | for _, o := range opts { 86 | o(s) 87 | } 88 | if s.logger == nil { 89 | s.logger = logrus.StandardLogger() 90 | } 91 | db, err := sql.Open("postgres", connectionString) 92 | if err != nil { 93 | return nil, err 94 | } 95 | if err := db.Ping(); err != nil { 96 | return nil, errors.Wrap(err, "ping") 97 | } 98 | s.l = pq.NewListener(connectionString, minReconnectInterval, maxReconnectInterval, func(ev pq.ListenerEventType, err error) { 99 | s.logger.WithField("listener-event", ev).Debugln("got listener event") 100 | if err != nil { 101 | s.logger.WithField("listener-event", ev).WithError(err).Errorln("got listener event error") 102 | } 103 | }) 104 | if err := s.l.Listen(channel); err != nil { 105 | return nil, errors.Wrap(err, "listen") 106 | } 107 | if err := s.l.Listen(channel + "-ctl"); err != nil { 108 | return nil, errors.Wrap(err, "listen") 109 | } 110 | s.db = db 111 | return s, nil 112 | } 113 | 114 | // Close stops the pqstream server. 115 | func (s *Server) Close() error { 116 | errL := s.l.Close() 117 | errDB := s.db.Close() 118 | if errL != nil { 119 | return errors.Wrap(errL, "listener") 120 | } 121 | if errDB != nil { 122 | return errors.Wrap(errDB, "DB") 123 | } 124 | return nil 125 | } 126 | 127 | // InstallTriggers sets up triggers to start observing changes for the set of tables in the database. 128 | func (s *Server) InstallTriggers() error { 129 | _, err := s.db.Exec(sqlTriggerFunction) 130 | if err != nil { 131 | return err 132 | } 133 | // TODO(tmc): watch for new tables 134 | tableNames, err := s.tableNames() 135 | if err != nil { 136 | return err 137 | } 138 | for _, t := range tableNames { 139 | if err := s.installTrigger(t); err != nil { 140 | return errors.Wrap(err, fmt.Sprintf("installTrigger table %s", t)) 141 | } 142 | } 143 | if len(tableNames) == 0 { 144 | return errors.New("no tables found") 145 | } 146 | return nil 147 | } 148 | 149 | func (s *Server) tableNames() ([]string, error) { 150 | rows, err := s.db.Query(sqlQueryTables) 151 | if err != nil { 152 | return nil, err 153 | } 154 | var tableNames []string 155 | for rows.Next() { 156 | var t string 157 | if err := rows.Scan(&t); err != nil { 158 | return nil, errors.Wrap(err, fmt.Sprintln("tableNames scan, after", len(tableNames))) 159 | } 160 | if s.tableRe != nil && !s.tableRe.MatchString(t) { 161 | continue 162 | } 163 | tableNames = append(tableNames, t) 164 | } 165 | return tableNames, nil 166 | } 167 | 168 | func (s *Server) installTrigger(table string) error { 169 | q := fmt.Sprintf(sqlInstallTrigger, table) 170 | _, err := s.db.Exec(q) 171 | return err 172 | } 173 | 174 | // RemoveTriggers removes triggers from the database. 175 | func (s *Server) RemoveTriggers() error { 176 | tableNames, err := s.tableNames() 177 | if err != nil { 178 | return err 179 | } 180 | for _, t := range tableNames { 181 | if err := s.removeTrigger(t); err != nil { 182 | return errors.Wrap(err, fmt.Sprintf("removeTrigger table:%s", t)) 183 | } 184 | } 185 | return nil 186 | } 187 | 188 | func (s *Server) removeTrigger(table string) error { 189 | q := fmt.Sprintf(sqlRemoveTrigger, table) 190 | _, err := s.db.Exec(q) 191 | return err 192 | } 193 | 194 | // fallbackLookup will be invoked if we have apparently exceeded the 8000 byte notify limit. 195 | func (s *Server) fallbackLookup(e *pqs.Event) error { 196 | rows, err := s.db.Query(fmt.Sprintf(sqlFetchRowByID, e.Table, fallbackIDColumnType), e.Id) 197 | if err != nil { 198 | return errors.Wrap(err, "fallback query") 199 | } 200 | defer rows.Close() 201 | if rows.Next() { 202 | payload := "" 203 | if err := rows.Scan(&payload); err != nil { 204 | return errors.Wrap(err, "fallback scan") 205 | } 206 | e.Payload = &ptypes_struct.Struct{} 207 | if err := jsonpb.UnmarshalString(payload, e.Payload); err != nil { 208 | return errors.Wrap(err, "fallback unmarshal") 209 | } 210 | } 211 | return nil 212 | } 213 | 214 | func (s *Server) handleEvent(subscribers map[*subscription]bool, ev *pq.Notification) error { 215 | if ev == nil { 216 | return errors.New("got nil event") 217 | } 218 | 219 | re := &pqs.RawEvent{} 220 | if err := jsonpb.UnmarshalString(ev.Extra, re); err != nil { 221 | return errors.Wrap(err, "jsonpb unmarshal") 222 | } 223 | 224 | // perform field redactions 225 | s.redactFields(re) 226 | 227 | e := &pqs.Event{ 228 | Schema: re.Schema, 229 | Table: re.Table, 230 | Op: re.Op, 231 | Id: re.Id, 232 | Payload: re.Payload, 233 | } 234 | 235 | if re.Op == pqs.Operation_UPDATE { 236 | if patch, err := generatePatch(re.Payload, re.Previous); err != nil { 237 | s.logger.WithField("event", e).WithError(err).Infoln("issue generating json patch") 238 | } else { 239 | e.Changes = patch 240 | } 241 | } 242 | 243 | if e.Payload == nil && e.Id != "" { 244 | if err := s.fallbackLookup(e); err != nil { 245 | s.logger.WithField("event", e).WithError(err).Errorln("fallback lookup failed") 246 | } 247 | 248 | } 249 | for s := range subscribers { 250 | if !s.fn(e) { 251 | delete(subscribers, s) 252 | } 253 | } 254 | return nil 255 | } 256 | 257 | // HandleEvents processes events from the database and copies them to relevant clients. 258 | func (s *Server) HandleEvents(ctx context.Context) error { 259 | subscribers := map[*subscription]bool{} 260 | events := s.l.NotificationChannel() 261 | for { 262 | select { 263 | case <-ctx.Done(): 264 | return nil 265 | case sub := <-s.subscribe: 266 | s.logger.Debugln("got subscriber") 267 | subscribers[sub] = true 268 | case ev := <-events: 269 | // TODO(tmc): separate case handling into method 270 | s.logger.WithField("event", ev).Debugln("got event") 271 | if err := s.handleEvent(subscribers, ev); err != nil { 272 | return err 273 | } 274 | case <-time.After(s.listenerPingInterval): 275 | s.logger.WithField("interval", s.listenerPingInterval).Debugln("pinging") 276 | if err := s.l.Ping(); err != nil { 277 | return errors.Wrap(err, "Ping") 278 | } 279 | } 280 | } 281 | } 282 | 283 | // Listen handles a request to listen for database events and streams them to clients. 284 | func (s *Server) Listen(r *pqs.ListenRequest, srv pqs.PQStream_ListenServer) error { 285 | ctx := srv.Context() 286 | s.logger.WithField("listen-request", r).Infoln("got listen request") 287 | tableRe, err := regexp.Compile(r.TableRegexp) 288 | if err != nil { 289 | return err 290 | } 291 | events := make(chan *pqs.Event) // TODO(tmc): will likely buffer after benchmarking 292 | s.subscribe <- &subscription{fn: func(e *pqs.Event) bool { 293 | if !tableRe.MatchString(e.Table) { 294 | return true 295 | } 296 | select { 297 | case <-ctx.Done(): 298 | return false 299 | case events <- e: 300 | return true 301 | } 302 | }} 303 | for { 304 | select { 305 | case <-s.ctx.Done(): 306 | return nil 307 | case <-ctx.Done(): 308 | return nil 309 | case e := <-events: 310 | if err := srv.Send(e); err != nil { 311 | return err 312 | } 313 | } 314 | } 315 | } 316 | -------------------------------------------------------------------------------- /test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | go test -v -race -coverprofile=coverage.txt -covermode=atomic 4 | if [ -n "${CODECOV_TOKEN:-}" ]; then 5 | bash <(curl -s https://codecov.io/bash) -F go 6 | fi 7 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/LICENSE: -------------------------------------------------------------------------------- 1 | Go support for Protocol Buffers - Google's data interchange format 2 | 3 | Copyright 2010 The Go Authors. All rights reserved. 4 | https://github.com/golang/protobuf 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are 8 | met: 9 | 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above 13 | copyright notice, this list of conditions and the following disclaimer 14 | in the documentation and/or other materials provided with the 15 | distribution. 16 | * Neither the name of Google Inc. nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/Make.protobuf: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | # Includable Makefile to add a rule for generating .pb.go files from .proto files 33 | # (Google protocol buffer descriptions). 34 | # Typical use if myproto.proto is a file in package mypackage in this directory: 35 | # 36 | # include $(GOROOT)/src/pkg/github.com/golang/protobuf/Make.protobuf 37 | 38 | %.pb.go: %.proto 39 | protoc --go_out=. $< 40 | 41 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | 33 | all: install 34 | 35 | install: 36 | go install ./proto ./jsonpb ./ptypes 37 | go install ./protoc-gen-go 38 | 39 | test: 40 | go test ./proto ./jsonpb ./ptypes 41 | make -C protoc-gen-go/testdata test 42 | 43 | clean: 44 | go clean ./... 45 | 46 | nuke: 47 | go clean -i ./... 48 | 49 | regenerate: 50 | make -C protoc-gen-go/descriptor regenerate 51 | make -C protoc-gen-go/plugin regenerate 52 | make -C protoc-gen-go/testdata regenerate 53 | make -C proto/testdata regenerate 54 | make -C jsonpb/jsonpb_test_proto regenerate 55 | make -C _conformance regenerate 56 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/descriptor/descriptor.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2016 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | // Package descriptor provides functions for obtaining protocol buffer 33 | // descriptors for generated Go types. 34 | // 35 | // These functions cannot go in package proto because they depend on the 36 | // generated protobuf descriptor messages, which themselves depend on proto. 37 | package descriptor 38 | 39 | import ( 40 | "bytes" 41 | "compress/gzip" 42 | "fmt" 43 | "io/ioutil" 44 | 45 | "github.com/golang/protobuf/proto" 46 | protobuf "github.com/golang/protobuf/protoc-gen-go/descriptor" 47 | ) 48 | 49 | // extractFile extracts a FileDescriptorProto from a gzip'd buffer. 50 | func extractFile(gz []byte) (*protobuf.FileDescriptorProto, error) { 51 | r, err := gzip.NewReader(bytes.NewReader(gz)) 52 | if err != nil { 53 | return nil, fmt.Errorf("failed to open gzip reader: %v", err) 54 | } 55 | defer r.Close() 56 | 57 | b, err := ioutil.ReadAll(r) 58 | if err != nil { 59 | return nil, fmt.Errorf("failed to uncompress descriptor: %v", err) 60 | } 61 | 62 | fd := new(protobuf.FileDescriptorProto) 63 | if err := proto.Unmarshal(b, fd); err != nil { 64 | return nil, fmt.Errorf("malformed FileDescriptorProto: %v", err) 65 | } 66 | 67 | return fd, nil 68 | } 69 | 70 | // Message is a proto.Message with a method to return its descriptor. 71 | // 72 | // Message types generated by the protocol compiler always satisfy 73 | // the Message interface. 74 | type Message interface { 75 | proto.Message 76 | Descriptor() ([]byte, []int) 77 | } 78 | 79 | // ForMessage returns a FileDescriptorProto and a DescriptorProto from within it 80 | // describing the given message. 81 | func ForMessage(msg Message) (fd *protobuf.FileDescriptorProto, md *protobuf.DescriptorProto) { 82 | gz, path := msg.Descriptor() 83 | fd, err := extractFile(gz) 84 | if err != nil { 85 | panic(fmt.Sprintf("invalid FileDescriptorProto for %T: %v", msg, err)) 86 | } 87 | 88 | md = fd.MessageType[path[0]] 89 | for _, i := range path[1:] { 90 | md = md.NestedType[i] 91 | } 92 | return fd, md 93 | } 94 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2015 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | regenerate: 33 | protoc --go_out=Mgoogle/protobuf/any.proto=github.com/golang/protobuf/ptypes/any,Mgoogle/protobuf/duration.proto=github.com/golang/protobuf/ptypes/duration,Mgoogle/protobuf/struct.proto=github.com/golang/protobuf/ptypes/struct,Mgoogle/protobuf/timestamp.proto=github.com/golang/protobuf/ptypes/timestamp,Mgoogle/protobuf/wrappers.proto=github.com/golang/protobuf/ptypes/wrappers:. *.proto 34 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.proto: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2015 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | syntax = "proto3"; 33 | 34 | package jsonpb; 35 | 36 | message Simple3 { 37 | double dub = 1; 38 | } 39 | 40 | message SimpleSlice3 { 41 | repeated string slices = 1; 42 | } 43 | 44 | message SimpleMap3 { 45 | map stringy = 1; 46 | } 47 | 48 | message SimpleNull3 { 49 | Simple3 simple = 1; 50 | } 51 | 52 | enum Numeral { 53 | UNKNOWN = 0; 54 | ARABIC = 1; 55 | ROMAN = 2; 56 | } 57 | 58 | message Mappy { 59 | map nummy = 1; 60 | map strry = 2; 61 | map objjy = 3; 62 | map buggy = 4; 63 | map booly = 5; 64 | map enumy = 6; 65 | map s32booly = 7; 66 | map s64booly = 8; 67 | map u32booly = 9; 68 | map u64booly = 10; 69 | } 70 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/test_objects.proto: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2015 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | syntax = "proto2"; 33 | 34 | import "google/protobuf/any.proto"; 35 | import "google/protobuf/duration.proto"; 36 | import "google/protobuf/struct.proto"; 37 | import "google/protobuf/timestamp.proto"; 38 | import "google/protobuf/wrappers.proto"; 39 | 40 | package jsonpb; 41 | 42 | // Test message for holding primitive types. 43 | message Simple { 44 | optional bool o_bool = 1; 45 | optional int32 o_int32 = 2; 46 | optional int64 o_int64 = 3; 47 | optional uint32 o_uint32 = 4; 48 | optional uint64 o_uint64 = 5; 49 | optional sint32 o_sint32 = 6; 50 | optional sint64 o_sint64 = 7; 51 | optional float o_float = 8; 52 | optional double o_double = 9; 53 | optional string o_string = 10; 54 | optional bytes o_bytes = 11; 55 | } 56 | 57 | // Test message for holding special non-finites primitives. 58 | message NonFinites { 59 | optional float f_nan = 1; 60 | optional float f_pinf = 2; 61 | optional float f_ninf = 3; 62 | optional double d_nan = 4; 63 | optional double d_pinf = 5; 64 | optional double d_ninf = 6; 65 | } 66 | 67 | // Test message for holding repeated primitives. 68 | message Repeats { 69 | repeated bool r_bool = 1; 70 | repeated int32 r_int32 = 2; 71 | repeated int64 r_int64 = 3; 72 | repeated uint32 r_uint32 = 4; 73 | repeated uint64 r_uint64 = 5; 74 | repeated sint32 r_sint32 = 6; 75 | repeated sint64 r_sint64 = 7; 76 | repeated float r_float = 8; 77 | repeated double r_double = 9; 78 | repeated string r_string = 10; 79 | repeated bytes r_bytes = 11; 80 | } 81 | 82 | // Test message for holding enums and nested messages. 83 | message Widget { 84 | enum Color { 85 | RED = 0; 86 | GREEN = 1; 87 | BLUE = 2; 88 | }; 89 | optional Color color = 1; 90 | repeated Color r_color = 2; 91 | 92 | optional Simple simple = 10; 93 | repeated Simple r_simple = 11; 94 | 95 | optional Repeats repeats = 20; 96 | repeated Repeats r_repeats = 21; 97 | } 98 | 99 | message Maps { 100 | map m_int64_str = 1; 101 | map m_bool_simple = 2; 102 | } 103 | 104 | message MsgWithOneof { 105 | oneof union { 106 | string title = 1; 107 | int64 salary = 2; 108 | string Country = 3; 109 | string home_address = 4; 110 | } 111 | } 112 | 113 | message Real { 114 | optional double value = 1; 115 | extensions 100 to max; 116 | } 117 | 118 | extend Real { 119 | optional string name = 124; 120 | } 121 | 122 | message Complex { 123 | extend Real { 124 | optional Complex real_extension = 123; 125 | } 126 | optional double imaginary = 1; 127 | extensions 100 to max; 128 | } 129 | 130 | message KnownTypes { 131 | optional google.protobuf.Any an = 14; 132 | optional google.protobuf.Duration dur = 1; 133 | optional google.protobuf.Struct st = 12; 134 | optional google.protobuf.Timestamp ts = 2; 135 | optional google.protobuf.ListValue lv = 15; 136 | optional google.protobuf.Value val = 16; 137 | 138 | optional google.protobuf.DoubleValue dbl = 3; 139 | optional google.protobuf.FloatValue flt = 4; 140 | optional google.protobuf.Int64Value i64 = 5; 141 | optional google.protobuf.UInt64Value u64 = 6; 142 | optional google.protobuf.Int32Value i32 = 7; 143 | optional google.protobuf.UInt32Value u32 = 8; 144 | optional google.protobuf.BoolValue bool = 9; 145 | optional google.protobuf.StringValue str = 10; 146 | optional google.protobuf.BytesValue bytes = 11; 147 | } 148 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | install: 33 | go install 34 | 35 | test: install generate-test-pbs 36 | go test 37 | 38 | 39 | generate-test-pbs: 40 | make install 41 | make -C testdata 42 | protoc --go_out=Mtestdata/test.proto=github.com/golang/protobuf/proto/testdata,Mgoogle/protobuf/any.proto=github.com/golang/protobuf/ptypes/any:. proto3_proto/proto3.proto 43 | make 44 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/clone.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2011 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | // Protocol buffer deep copy and merge. 33 | // TODO: RawMessage. 34 | 35 | package proto 36 | 37 | import ( 38 | "log" 39 | "reflect" 40 | "strings" 41 | ) 42 | 43 | // Clone returns a deep copy of a protocol buffer. 44 | func Clone(pb Message) Message { 45 | in := reflect.ValueOf(pb) 46 | if in.IsNil() { 47 | return pb 48 | } 49 | 50 | out := reflect.New(in.Type().Elem()) 51 | // out is empty so a merge is a deep copy. 52 | mergeStruct(out.Elem(), in.Elem()) 53 | return out.Interface().(Message) 54 | } 55 | 56 | // Merge merges src into dst. 57 | // Required and optional fields that are set in src will be set to that value in dst. 58 | // Elements of repeated fields will be appended. 59 | // Merge panics if src and dst are not the same type, or if dst is nil. 60 | func Merge(dst, src Message) { 61 | in := reflect.ValueOf(src) 62 | out := reflect.ValueOf(dst) 63 | if out.IsNil() { 64 | panic("proto: nil destination") 65 | } 66 | if in.Type() != out.Type() { 67 | // Explicit test prior to mergeStruct so that mistyped nils will fail 68 | panic("proto: type mismatch") 69 | } 70 | if in.IsNil() { 71 | // Merging nil into non-nil is a quiet no-op 72 | return 73 | } 74 | mergeStruct(out.Elem(), in.Elem()) 75 | } 76 | 77 | func mergeStruct(out, in reflect.Value) { 78 | sprop := GetProperties(in.Type()) 79 | for i := 0; i < in.NumField(); i++ { 80 | f := in.Type().Field(i) 81 | if strings.HasPrefix(f.Name, "XXX_") { 82 | continue 83 | } 84 | mergeAny(out.Field(i), in.Field(i), false, sprop.Prop[i]) 85 | } 86 | 87 | if emIn, ok := extendable(in.Addr().Interface()); ok { 88 | emOut, _ := extendable(out.Addr().Interface()) 89 | mIn, muIn := emIn.extensionsRead() 90 | if mIn != nil { 91 | mOut := emOut.extensionsWrite() 92 | muIn.Lock() 93 | mergeExtension(mOut, mIn) 94 | muIn.Unlock() 95 | } 96 | } 97 | 98 | uf := in.FieldByName("XXX_unrecognized") 99 | if !uf.IsValid() { 100 | return 101 | } 102 | uin := uf.Bytes() 103 | if len(uin) > 0 { 104 | out.FieldByName("XXX_unrecognized").SetBytes(append([]byte(nil), uin...)) 105 | } 106 | } 107 | 108 | // mergeAny performs a merge between two values of the same type. 109 | // viaPtr indicates whether the values were indirected through a pointer (implying proto2). 110 | // prop is set if this is a struct field (it may be nil). 111 | func mergeAny(out, in reflect.Value, viaPtr bool, prop *Properties) { 112 | if in.Type() == protoMessageType { 113 | if !in.IsNil() { 114 | if out.IsNil() { 115 | out.Set(reflect.ValueOf(Clone(in.Interface().(Message)))) 116 | } else { 117 | Merge(out.Interface().(Message), in.Interface().(Message)) 118 | } 119 | } 120 | return 121 | } 122 | switch in.Kind() { 123 | case reflect.Bool, reflect.Float32, reflect.Float64, reflect.Int32, reflect.Int64, 124 | reflect.String, reflect.Uint32, reflect.Uint64: 125 | if !viaPtr && isProto3Zero(in) { 126 | return 127 | } 128 | out.Set(in) 129 | case reflect.Interface: 130 | // Probably a oneof field; copy non-nil values. 131 | if in.IsNil() { 132 | return 133 | } 134 | // Allocate destination if it is not set, or set to a different type. 135 | // Otherwise we will merge as normal. 136 | if out.IsNil() || out.Elem().Type() != in.Elem().Type() { 137 | out.Set(reflect.New(in.Elem().Elem().Type())) // interface -> *T -> T -> new(T) 138 | } 139 | mergeAny(out.Elem(), in.Elem(), false, nil) 140 | case reflect.Map: 141 | if in.Len() == 0 { 142 | return 143 | } 144 | if out.IsNil() { 145 | out.Set(reflect.MakeMap(in.Type())) 146 | } 147 | // For maps with value types of *T or []byte we need to deep copy each value. 148 | elemKind := in.Type().Elem().Kind() 149 | for _, key := range in.MapKeys() { 150 | var val reflect.Value 151 | switch elemKind { 152 | case reflect.Ptr: 153 | val = reflect.New(in.Type().Elem().Elem()) 154 | mergeAny(val, in.MapIndex(key), false, nil) 155 | case reflect.Slice: 156 | val = in.MapIndex(key) 157 | val = reflect.ValueOf(append([]byte{}, val.Bytes()...)) 158 | default: 159 | val = in.MapIndex(key) 160 | } 161 | out.SetMapIndex(key, val) 162 | } 163 | case reflect.Ptr: 164 | if in.IsNil() { 165 | return 166 | } 167 | if out.IsNil() { 168 | out.Set(reflect.New(in.Elem().Type())) 169 | } 170 | mergeAny(out.Elem(), in.Elem(), true, nil) 171 | case reflect.Slice: 172 | if in.IsNil() { 173 | return 174 | } 175 | if in.Type().Elem().Kind() == reflect.Uint8 { 176 | // []byte is a scalar bytes field, not a repeated field. 177 | 178 | // Edge case: if this is in a proto3 message, a zero length 179 | // bytes field is considered the zero value, and should not 180 | // be merged. 181 | if prop != nil && prop.proto3 && in.Len() == 0 { 182 | return 183 | } 184 | 185 | // Make a deep copy. 186 | // Append to []byte{} instead of []byte(nil) so that we never end up 187 | // with a nil result. 188 | out.SetBytes(append([]byte{}, in.Bytes()...)) 189 | return 190 | } 191 | n := in.Len() 192 | if out.IsNil() { 193 | out.Set(reflect.MakeSlice(in.Type(), 0, n)) 194 | } 195 | switch in.Type().Elem().Kind() { 196 | case reflect.Bool, reflect.Float32, reflect.Float64, reflect.Int32, reflect.Int64, 197 | reflect.String, reflect.Uint32, reflect.Uint64: 198 | out.Set(reflect.AppendSlice(out, in)) 199 | default: 200 | for i := 0; i < n; i++ { 201 | x := reflect.Indirect(reflect.New(in.Type().Elem())) 202 | mergeAny(x, in.Index(i), false, nil) 203 | out.Set(reflect.Append(out, x)) 204 | } 205 | } 206 | case reflect.Struct: 207 | mergeStruct(out, in) 208 | default: 209 | // unknown type, so not a protocol buffer 210 | log.Printf("proto: don't know how to copy %v", in) 211 | } 212 | } 213 | 214 | func mergeExtension(out, in map[int32]Extension) { 215 | for extNum, eIn := range in { 216 | eOut := Extension{desc: eIn.desc} 217 | if eIn.value != nil { 218 | v := reflect.New(reflect.TypeOf(eIn.value)).Elem() 219 | mergeAny(v, reflect.ValueOf(eIn.value), false, nil) 220 | eOut.value = v.Interface() 221 | } 222 | if eIn.enc != nil { 223 | eOut.enc = make([]byte, len(eIn.enc)) 224 | copy(eOut.enc, eIn.enc) 225 | } 226 | 227 | out[extNum] = eOut 228 | } 229 | } 230 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/equal.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2011 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | // Protocol buffer comparison. 33 | 34 | package proto 35 | 36 | import ( 37 | "bytes" 38 | "log" 39 | "reflect" 40 | "strings" 41 | ) 42 | 43 | /* 44 | Equal returns true iff protocol buffers a and b are equal. 45 | The arguments must both be pointers to protocol buffer structs. 46 | 47 | Equality is defined in this way: 48 | - Two messages are equal iff they are the same type, 49 | corresponding fields are equal, unknown field sets 50 | are equal, and extensions sets are equal. 51 | - Two set scalar fields are equal iff their values are equal. 52 | If the fields are of a floating-point type, remember that 53 | NaN != x for all x, including NaN. If the message is defined 54 | in a proto3 .proto file, fields are not "set"; specifically, 55 | zero length proto3 "bytes" fields are equal (nil == {}). 56 | - Two repeated fields are equal iff their lengths are the same, 57 | and their corresponding elements are equal. Note a "bytes" field, 58 | although represented by []byte, is not a repeated field and the 59 | rule for the scalar fields described above applies. 60 | - Two unset fields are equal. 61 | - Two unknown field sets are equal if their current 62 | encoded state is equal. 63 | - Two extension sets are equal iff they have corresponding 64 | elements that are pairwise equal. 65 | - Two map fields are equal iff their lengths are the same, 66 | and they contain the same set of elements. Zero-length map 67 | fields are equal. 68 | - Every other combination of things are not equal. 69 | 70 | The return value is undefined if a and b are not protocol buffers. 71 | */ 72 | func Equal(a, b Message) bool { 73 | if a == nil || b == nil { 74 | return a == b 75 | } 76 | v1, v2 := reflect.ValueOf(a), reflect.ValueOf(b) 77 | if v1.Type() != v2.Type() { 78 | return false 79 | } 80 | if v1.Kind() == reflect.Ptr { 81 | if v1.IsNil() { 82 | return v2.IsNil() 83 | } 84 | if v2.IsNil() { 85 | return false 86 | } 87 | v1, v2 = v1.Elem(), v2.Elem() 88 | } 89 | if v1.Kind() != reflect.Struct { 90 | return false 91 | } 92 | return equalStruct(v1, v2) 93 | } 94 | 95 | // v1 and v2 are known to have the same type. 96 | func equalStruct(v1, v2 reflect.Value) bool { 97 | sprop := GetProperties(v1.Type()) 98 | for i := 0; i < v1.NumField(); i++ { 99 | f := v1.Type().Field(i) 100 | if strings.HasPrefix(f.Name, "XXX_") { 101 | continue 102 | } 103 | f1, f2 := v1.Field(i), v2.Field(i) 104 | if f.Type.Kind() == reflect.Ptr { 105 | if n1, n2 := f1.IsNil(), f2.IsNil(); n1 && n2 { 106 | // both unset 107 | continue 108 | } else if n1 != n2 { 109 | // set/unset mismatch 110 | return false 111 | } 112 | b1, ok := f1.Interface().(raw) 113 | if ok { 114 | b2 := f2.Interface().(raw) 115 | // RawMessage 116 | if !bytes.Equal(b1.Bytes(), b2.Bytes()) { 117 | return false 118 | } 119 | continue 120 | } 121 | f1, f2 = f1.Elem(), f2.Elem() 122 | } 123 | if !equalAny(f1, f2, sprop.Prop[i]) { 124 | return false 125 | } 126 | } 127 | 128 | if em1 := v1.FieldByName("XXX_InternalExtensions"); em1.IsValid() { 129 | em2 := v2.FieldByName("XXX_InternalExtensions") 130 | if !equalExtensions(v1.Type(), em1.Interface().(XXX_InternalExtensions), em2.Interface().(XXX_InternalExtensions)) { 131 | return false 132 | } 133 | } 134 | 135 | if em1 := v1.FieldByName("XXX_extensions"); em1.IsValid() { 136 | em2 := v2.FieldByName("XXX_extensions") 137 | if !equalExtMap(v1.Type(), em1.Interface().(map[int32]Extension), em2.Interface().(map[int32]Extension)) { 138 | return false 139 | } 140 | } 141 | 142 | uf := v1.FieldByName("XXX_unrecognized") 143 | if !uf.IsValid() { 144 | return true 145 | } 146 | 147 | u1 := uf.Bytes() 148 | u2 := v2.FieldByName("XXX_unrecognized").Bytes() 149 | if !bytes.Equal(u1, u2) { 150 | return false 151 | } 152 | 153 | return true 154 | } 155 | 156 | // v1 and v2 are known to have the same type. 157 | // prop may be nil. 158 | func equalAny(v1, v2 reflect.Value, prop *Properties) bool { 159 | if v1.Type() == protoMessageType { 160 | m1, _ := v1.Interface().(Message) 161 | m2, _ := v2.Interface().(Message) 162 | return Equal(m1, m2) 163 | } 164 | switch v1.Kind() { 165 | case reflect.Bool: 166 | return v1.Bool() == v2.Bool() 167 | case reflect.Float32, reflect.Float64: 168 | return v1.Float() == v2.Float() 169 | case reflect.Int32, reflect.Int64: 170 | return v1.Int() == v2.Int() 171 | case reflect.Interface: 172 | // Probably a oneof field; compare the inner values. 173 | n1, n2 := v1.IsNil(), v2.IsNil() 174 | if n1 || n2 { 175 | return n1 == n2 176 | } 177 | e1, e2 := v1.Elem(), v2.Elem() 178 | if e1.Type() != e2.Type() { 179 | return false 180 | } 181 | return equalAny(e1, e2, nil) 182 | case reflect.Map: 183 | if v1.Len() != v2.Len() { 184 | return false 185 | } 186 | for _, key := range v1.MapKeys() { 187 | val2 := v2.MapIndex(key) 188 | if !val2.IsValid() { 189 | // This key was not found in the second map. 190 | return false 191 | } 192 | if !equalAny(v1.MapIndex(key), val2, nil) { 193 | return false 194 | } 195 | } 196 | return true 197 | case reflect.Ptr: 198 | // Maps may have nil values in them, so check for nil. 199 | if v1.IsNil() && v2.IsNil() { 200 | return true 201 | } 202 | if v1.IsNil() != v2.IsNil() { 203 | return false 204 | } 205 | return equalAny(v1.Elem(), v2.Elem(), prop) 206 | case reflect.Slice: 207 | if v1.Type().Elem().Kind() == reflect.Uint8 { 208 | // short circuit: []byte 209 | 210 | // Edge case: if this is in a proto3 message, a zero length 211 | // bytes field is considered the zero value. 212 | if prop != nil && prop.proto3 && v1.Len() == 0 && v2.Len() == 0 { 213 | return true 214 | } 215 | if v1.IsNil() != v2.IsNil() { 216 | return false 217 | } 218 | return bytes.Equal(v1.Interface().([]byte), v2.Interface().([]byte)) 219 | } 220 | 221 | if v1.Len() != v2.Len() { 222 | return false 223 | } 224 | for i := 0; i < v1.Len(); i++ { 225 | if !equalAny(v1.Index(i), v2.Index(i), prop) { 226 | return false 227 | } 228 | } 229 | return true 230 | case reflect.String: 231 | return v1.Interface().(string) == v2.Interface().(string) 232 | case reflect.Struct: 233 | return equalStruct(v1, v2) 234 | case reflect.Uint32, reflect.Uint64: 235 | return v1.Uint() == v2.Uint() 236 | } 237 | 238 | // unknown type, so not a protocol buffer 239 | log.Printf("proto: don't know how to compare %v", v1) 240 | return false 241 | } 242 | 243 | // base is the struct type that the extensions are based on. 244 | // x1 and x2 are InternalExtensions. 245 | func equalExtensions(base reflect.Type, x1, x2 XXX_InternalExtensions) bool { 246 | em1, _ := x1.extensionsRead() 247 | em2, _ := x2.extensionsRead() 248 | return equalExtMap(base, em1, em2) 249 | } 250 | 251 | func equalExtMap(base reflect.Type, em1, em2 map[int32]Extension) bool { 252 | if len(em1) != len(em2) { 253 | return false 254 | } 255 | 256 | for extNum, e1 := range em1 { 257 | e2, ok := em2[extNum] 258 | if !ok { 259 | return false 260 | } 261 | 262 | m1, m2 := e1.value, e2.value 263 | 264 | if m1 != nil && m2 != nil { 265 | // Both are unencoded. 266 | if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) { 267 | return false 268 | } 269 | continue 270 | } 271 | 272 | // At least one is encoded. To do a semantically correct comparison 273 | // we need to unmarshal them first. 274 | var desc *ExtensionDesc 275 | if m := extensionMaps[base]; m != nil { 276 | desc = m[extNum] 277 | } 278 | if desc == nil { 279 | log.Printf("proto: don't know how to compare extension %d of %v", extNum, base) 280 | continue 281 | } 282 | var err error 283 | if m1 == nil { 284 | m1, err = decodeExtension(e1.enc, desc) 285 | } 286 | if m2 == nil && err == nil { 287 | m2, err = decodeExtension(e2.enc, desc) 288 | } 289 | if err != nil { 290 | // The encoded form is invalid. 291 | log.Printf("proto: badly encoded extension %d of %v: %v", extNum, base, err) 292 | return false 293 | } 294 | if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) { 295 | return false 296 | } 297 | } 298 | 299 | return true 300 | } 301 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/message_set.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2010 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | package proto 33 | 34 | /* 35 | * Support for message sets. 36 | */ 37 | 38 | import ( 39 | "bytes" 40 | "encoding/json" 41 | "errors" 42 | "fmt" 43 | "reflect" 44 | "sort" 45 | ) 46 | 47 | // errNoMessageTypeID occurs when a protocol buffer does not have a message type ID. 48 | // A message type ID is required for storing a protocol buffer in a message set. 49 | var errNoMessageTypeID = errors.New("proto does not have a message type ID") 50 | 51 | // The first two types (_MessageSet_Item and messageSet) 52 | // model what the protocol compiler produces for the following protocol message: 53 | // message MessageSet { 54 | // repeated group Item = 1 { 55 | // required int32 type_id = 2; 56 | // required string message = 3; 57 | // }; 58 | // } 59 | // That is the MessageSet wire format. We can't use a proto to generate these 60 | // because that would introduce a circular dependency between it and this package. 61 | 62 | type _MessageSet_Item struct { 63 | TypeId *int32 `protobuf:"varint,2,req,name=type_id"` 64 | Message []byte `protobuf:"bytes,3,req,name=message"` 65 | } 66 | 67 | type messageSet struct { 68 | Item []*_MessageSet_Item `protobuf:"group,1,rep"` 69 | XXX_unrecognized []byte 70 | // TODO: caching? 71 | } 72 | 73 | // Make sure messageSet is a Message. 74 | var _ Message = (*messageSet)(nil) 75 | 76 | // messageTypeIder is an interface satisfied by a protocol buffer type 77 | // that may be stored in a MessageSet. 78 | type messageTypeIder interface { 79 | MessageTypeId() int32 80 | } 81 | 82 | func (ms *messageSet) find(pb Message) *_MessageSet_Item { 83 | mti, ok := pb.(messageTypeIder) 84 | if !ok { 85 | return nil 86 | } 87 | id := mti.MessageTypeId() 88 | for _, item := range ms.Item { 89 | if *item.TypeId == id { 90 | return item 91 | } 92 | } 93 | return nil 94 | } 95 | 96 | func (ms *messageSet) Has(pb Message) bool { 97 | if ms.find(pb) != nil { 98 | return true 99 | } 100 | return false 101 | } 102 | 103 | func (ms *messageSet) Unmarshal(pb Message) error { 104 | if item := ms.find(pb); item != nil { 105 | return Unmarshal(item.Message, pb) 106 | } 107 | if _, ok := pb.(messageTypeIder); !ok { 108 | return errNoMessageTypeID 109 | } 110 | return nil // TODO: return error instead? 111 | } 112 | 113 | func (ms *messageSet) Marshal(pb Message) error { 114 | msg, err := Marshal(pb) 115 | if err != nil { 116 | return err 117 | } 118 | if item := ms.find(pb); item != nil { 119 | // reuse existing item 120 | item.Message = msg 121 | return nil 122 | } 123 | 124 | mti, ok := pb.(messageTypeIder) 125 | if !ok { 126 | return errNoMessageTypeID 127 | } 128 | 129 | mtid := mti.MessageTypeId() 130 | ms.Item = append(ms.Item, &_MessageSet_Item{ 131 | TypeId: &mtid, 132 | Message: msg, 133 | }) 134 | return nil 135 | } 136 | 137 | func (ms *messageSet) Reset() { *ms = messageSet{} } 138 | func (ms *messageSet) String() string { return CompactTextString(ms) } 139 | func (*messageSet) ProtoMessage() {} 140 | 141 | // Support for the message_set_wire_format message option. 142 | 143 | func skipVarint(buf []byte) []byte { 144 | i := 0 145 | for ; buf[i]&0x80 != 0; i++ { 146 | } 147 | return buf[i+1:] 148 | } 149 | 150 | // MarshalMessageSet encodes the extension map represented by m in the message set wire format. 151 | // It is called by generated Marshal methods on protocol buffer messages with the message_set_wire_format option. 152 | func MarshalMessageSet(exts interface{}) ([]byte, error) { 153 | var m map[int32]Extension 154 | switch exts := exts.(type) { 155 | case *XXX_InternalExtensions: 156 | if err := encodeExtensions(exts); err != nil { 157 | return nil, err 158 | } 159 | m, _ = exts.extensionsRead() 160 | case map[int32]Extension: 161 | if err := encodeExtensionsMap(exts); err != nil { 162 | return nil, err 163 | } 164 | m = exts 165 | default: 166 | return nil, errors.New("proto: not an extension map") 167 | } 168 | 169 | // Sort extension IDs to provide a deterministic encoding. 170 | // See also enc_map in encode.go. 171 | ids := make([]int, 0, len(m)) 172 | for id := range m { 173 | ids = append(ids, int(id)) 174 | } 175 | sort.Ints(ids) 176 | 177 | ms := &messageSet{Item: make([]*_MessageSet_Item, 0, len(m))} 178 | for _, id := range ids { 179 | e := m[int32(id)] 180 | // Remove the wire type and field number varint, as well as the length varint. 181 | msg := skipVarint(skipVarint(e.enc)) 182 | 183 | ms.Item = append(ms.Item, &_MessageSet_Item{ 184 | TypeId: Int32(int32(id)), 185 | Message: msg, 186 | }) 187 | } 188 | return Marshal(ms) 189 | } 190 | 191 | // UnmarshalMessageSet decodes the extension map encoded in buf in the message set wire format. 192 | // It is called by generated Unmarshal methods on protocol buffer messages with the message_set_wire_format option. 193 | func UnmarshalMessageSet(buf []byte, exts interface{}) error { 194 | var m map[int32]Extension 195 | switch exts := exts.(type) { 196 | case *XXX_InternalExtensions: 197 | m = exts.extensionsWrite() 198 | case map[int32]Extension: 199 | m = exts 200 | default: 201 | return errors.New("proto: not an extension map") 202 | } 203 | 204 | ms := new(messageSet) 205 | if err := Unmarshal(buf, ms); err != nil { 206 | return err 207 | } 208 | for _, item := range ms.Item { 209 | id := *item.TypeId 210 | msg := item.Message 211 | 212 | // Restore wire type and field number varint, plus length varint. 213 | // Be careful to preserve duplicate items. 214 | b := EncodeVarint(uint64(id)<<3 | WireBytes) 215 | if ext, ok := m[id]; ok { 216 | // Existing data; rip off the tag and length varint 217 | // so we join the new data correctly. 218 | // We can assume that ext.enc is set because we are unmarshaling. 219 | o := ext.enc[len(b):] // skip wire type and field number 220 | _, n := DecodeVarint(o) // calculate length of length varint 221 | o = o[n:] // skip length varint 222 | msg = append(o, msg...) // join old data and new data 223 | } 224 | b = append(b, EncodeVarint(uint64(len(msg)))...) 225 | b = append(b, msg...) 226 | 227 | m[id] = Extension{enc: b} 228 | } 229 | return nil 230 | } 231 | 232 | // MarshalMessageSetJSON encodes the extension map represented by m in JSON format. 233 | // It is called by generated MarshalJSON methods on protocol buffer messages with the message_set_wire_format option. 234 | func MarshalMessageSetJSON(exts interface{}) ([]byte, error) { 235 | var m map[int32]Extension 236 | switch exts := exts.(type) { 237 | case *XXX_InternalExtensions: 238 | m, _ = exts.extensionsRead() 239 | case map[int32]Extension: 240 | m = exts 241 | default: 242 | return nil, errors.New("proto: not an extension map") 243 | } 244 | var b bytes.Buffer 245 | b.WriteByte('{') 246 | 247 | // Process the map in key order for deterministic output. 248 | ids := make([]int32, 0, len(m)) 249 | for id := range m { 250 | ids = append(ids, id) 251 | } 252 | sort.Sort(int32Slice(ids)) // int32Slice defined in text.go 253 | 254 | for i, id := range ids { 255 | ext := m[id] 256 | if i > 0 { 257 | b.WriteByte(',') 258 | } 259 | 260 | msd, ok := messageSetMap[id] 261 | if !ok { 262 | // Unknown type; we can't render it, so skip it. 263 | continue 264 | } 265 | fmt.Fprintf(&b, `"[%s]":`, msd.name) 266 | 267 | x := ext.value 268 | if x == nil { 269 | x = reflect.New(msd.t.Elem()).Interface() 270 | if err := Unmarshal(ext.enc, x.(Message)); err != nil { 271 | return nil, err 272 | } 273 | } 274 | d, err := json.Marshal(x) 275 | if err != nil { 276 | return nil, err 277 | } 278 | b.Write(d) 279 | } 280 | b.WriteByte('}') 281 | return b.Bytes(), nil 282 | } 283 | 284 | // UnmarshalMessageSetJSON decodes the extension map encoded in buf in JSON format. 285 | // It is called by generated UnmarshalJSON methods on protocol buffer messages with the message_set_wire_format option. 286 | func UnmarshalMessageSetJSON(buf []byte, exts interface{}) error { 287 | // Common-case fast path. 288 | if len(buf) == 0 || bytes.Equal(buf, []byte("{}")) { 289 | return nil 290 | } 291 | 292 | // This is fairly tricky, and it's not clear that it is needed. 293 | return errors.New("TODO: UnmarshalMessageSetJSON not yet implemented") 294 | } 295 | 296 | // A global registry of types that can be used in a MessageSet. 297 | 298 | var messageSetMap = make(map[int32]messageSetDesc) 299 | 300 | type messageSetDesc struct { 301 | t reflect.Type // pointer to struct 302 | name string 303 | } 304 | 305 | // RegisterMessageSetType is called from the generated code. 306 | func RegisterMessageSetType(m Message, fieldNum int32, name string) { 307 | messageSetMap[fieldNum] = messageSetDesc{ 308 | t: reflect.TypeOf(m), 309 | name: name, 310 | } 311 | } 312 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/proto3_proto/proto3.proto: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | syntax = "proto3"; 33 | 34 | import "google/protobuf/any.proto"; 35 | import "testdata/test.proto"; 36 | 37 | package proto3_proto; 38 | 39 | message Message { 40 | enum Humour { 41 | UNKNOWN = 0; 42 | PUNS = 1; 43 | SLAPSTICK = 2; 44 | BILL_BAILEY = 3; 45 | } 46 | 47 | string name = 1; 48 | Humour hilarity = 2; 49 | uint32 height_in_cm = 3; 50 | bytes data = 4; 51 | int64 result_count = 7; 52 | bool true_scotsman = 8; 53 | float score = 9; 54 | 55 | repeated uint64 key = 5; 56 | repeated int32 short_key = 19; 57 | Nested nested = 6; 58 | repeated Humour r_funny = 16; 59 | 60 | map terrain = 10; 61 | testdata.SubDefaults proto2_field = 11; 62 | map proto2_value = 13; 63 | 64 | google.protobuf.Any anything = 14; 65 | repeated google.protobuf.Any many_things = 15; 66 | 67 | Message submessage = 17; 68 | repeated Message children = 18; 69 | } 70 | 71 | message Nested { 72 | string bunny = 1; 73 | bool cute = 2; 74 | } 75 | 76 | message MessageWithMap { 77 | map byte_mapping = 1; 78 | } 79 | 80 | 81 | message IntMap { 82 | map rtt = 1; 83 | } 84 | 85 | message IntMaps { 86 | repeated IntMap maps = 1; 87 | } 88 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | test: 33 | cd testdata && make test 34 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/descriptor/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | # Not stored here, but descriptor.proto is in https://github.com/google/protobuf/ 33 | # at src/google/protobuf/descriptor.proto 34 | regenerate: 35 | @echo WARNING! THIS RULE IS PROBABLY NOT RIGHT FOR YOUR INSTALLATION 36 | cp $(HOME)/src/protobuf/include/google/protobuf/descriptor.proto . 37 | protoc --go_out=../../../../.. -I$(HOME)/src/protobuf/include $(HOME)/src/protobuf/include/google/protobuf/descriptor.proto 38 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/doc.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2010 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | /* 33 | A plugin for the Google protocol buffer compiler to generate Go code. 34 | Run it by building this program and putting it in your path with the name 35 | protoc-gen-go 36 | That word 'go' at the end becomes part of the option string set for the 37 | protocol compiler, so once the protocol compiler (protoc) is installed 38 | you can run 39 | protoc --go_out=output_directory input_directory/file.proto 40 | to generate Go bindings for the protocol defined by file.proto. 41 | With that input, the output will be written to 42 | output_directory/file.pb.go 43 | 44 | The generated code is documented in the package comment for 45 | the library. 46 | 47 | See the README and documentation for protocol buffers to learn more: 48 | https://developers.google.com/protocol-buffers/ 49 | 50 | */ 51 | package documentation 52 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/generator/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | include $(GOROOT)/src/Make.inc 33 | 34 | TARG=github.com/golang/protobuf/compiler/generator 35 | GOFILES=\ 36 | generator.go\ 37 | 38 | DEPS=../descriptor ../plugin ../../proto 39 | 40 | include $(GOROOT)/src/Make.pkg 41 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/link_grpc.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2015 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | package main 33 | 34 | import _ "github.com/golang/protobuf/protoc-gen-go/grpc" 35 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/main.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2010 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | // protoc-gen-go is a plugin for the Google protocol buffer compiler to generate 33 | // Go code. Run it by building this program and putting it in your path with 34 | // the name 35 | // protoc-gen-go 36 | // That word 'go' at the end becomes part of the option string set for the 37 | // protocol compiler, so once the protocol compiler (protoc) is installed 38 | // you can run 39 | // protoc --go_out=output_directory input_directory/file.proto 40 | // to generate Go bindings for the protocol defined by file.proto. 41 | // With that input, the output will be written to 42 | // output_directory/file.pb.go 43 | // 44 | // The generated code is documented in the package comment for 45 | // the library. 46 | // 47 | // See the README and documentation for protocol buffers to learn more: 48 | // https://developers.google.com/protocol-buffers/ 49 | package main 50 | 51 | import ( 52 | "io/ioutil" 53 | "os" 54 | 55 | "github.com/golang/protobuf/proto" 56 | "github.com/golang/protobuf/protoc-gen-go/generator" 57 | ) 58 | 59 | func main() { 60 | // Begin by allocating a generator. The request and response structures are stored there 61 | // so we can do error handling easily - the response structure contains the field to 62 | // report failure. 63 | g := generator.New() 64 | 65 | data, err := ioutil.ReadAll(os.Stdin) 66 | if err != nil { 67 | g.Error(err, "reading input") 68 | } 69 | 70 | if err := proto.Unmarshal(data, g.Request); err != nil { 71 | g.Error(err, "parsing input proto") 72 | } 73 | 74 | if len(g.Request.FileToGenerate) == 0 { 75 | g.Fail("no files to generate") 76 | } 77 | 78 | g.CommandLineParameters(g.Request.GetParameter()) 79 | 80 | // Create a wrapped version of the Descriptors and EnumDescriptors that 81 | // point to the file that defines them. 82 | g.WrapTypes() 83 | 84 | g.SetPackageNames() 85 | g.BuildTypeNameMap() 86 | 87 | g.GenerateAllFiles() 88 | 89 | // Send back the results. 90 | data, err = proto.Marshal(g.Response) 91 | if err != nil { 92 | g.Error(err, "failed to marshal output proto") 93 | } 94 | _, err = os.Stdout.Write(data) 95 | if err != nil { 96 | g.Error(err, "failed to write output proto") 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/plugin/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | # Not stored here, but plugin.proto is in https://github.com/google/protobuf/ 33 | # at src/google/protobuf/compiler/plugin.proto 34 | # Also we need to fix an import. 35 | regenerate: 36 | @echo WARNING! THIS RULE IS PROBABLY NOT RIGHT FOR YOUR INSTALLATION 37 | cp $(HOME)/src/protobuf/include/google/protobuf/compiler/plugin.proto . 38 | protoc --go_out=Mgoogle/protobuf/descriptor.proto=github.com/golang/protobuf/protoc-gen-go/descriptor:../../../../.. \ 39 | -I$(HOME)/src/protobuf/include $(HOME)/src/protobuf/include/google/protobuf/compiler/plugin.proto 40 | 41 | restore: 42 | cp plugin.pb.golden plugin.pb.go 43 | 44 | preserve: 45 | cp plugin.pb.go plugin.pb.golden 46 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/plugin/plugin.pb.golden: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: google/protobuf/compiler/plugin.proto 3 | // DO NOT EDIT! 4 | 5 | package google_protobuf_compiler 6 | 7 | import proto "github.com/golang/protobuf/proto" 8 | import "math" 9 | import google_protobuf "github.com/golang/protobuf/protoc-gen-go/descriptor" 10 | 11 | // Reference proto and math imports to suppress error if they are not otherwise used. 12 | var _ = proto.GetString 13 | var _ = math.Inf 14 | 15 | type CodeGeneratorRequest struct { 16 | FileToGenerate []string `protobuf:"bytes,1,rep,name=file_to_generate" json:"file_to_generate,omitempty"` 17 | Parameter *string `protobuf:"bytes,2,opt,name=parameter" json:"parameter,omitempty"` 18 | ProtoFile []*google_protobuf.FileDescriptorProto `protobuf:"bytes,15,rep,name=proto_file" json:"proto_file,omitempty"` 19 | XXX_unrecognized []byte `json:"-"` 20 | } 21 | 22 | func (this *CodeGeneratorRequest) Reset() { *this = CodeGeneratorRequest{} } 23 | func (this *CodeGeneratorRequest) String() string { return proto.CompactTextString(this) } 24 | func (*CodeGeneratorRequest) ProtoMessage() {} 25 | 26 | func (this *CodeGeneratorRequest) GetParameter() string { 27 | if this != nil && this.Parameter != nil { 28 | return *this.Parameter 29 | } 30 | return "" 31 | } 32 | 33 | type CodeGeneratorResponse struct { 34 | Error *string `protobuf:"bytes,1,opt,name=error" json:"error,omitempty"` 35 | File []*CodeGeneratorResponse_File `protobuf:"bytes,15,rep,name=file" json:"file,omitempty"` 36 | XXX_unrecognized []byte `json:"-"` 37 | } 38 | 39 | func (this *CodeGeneratorResponse) Reset() { *this = CodeGeneratorResponse{} } 40 | func (this *CodeGeneratorResponse) String() string { return proto.CompactTextString(this) } 41 | func (*CodeGeneratorResponse) ProtoMessage() {} 42 | 43 | func (this *CodeGeneratorResponse) GetError() string { 44 | if this != nil && this.Error != nil { 45 | return *this.Error 46 | } 47 | return "" 48 | } 49 | 50 | type CodeGeneratorResponse_File struct { 51 | Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` 52 | InsertionPoint *string `protobuf:"bytes,2,opt,name=insertion_point" json:"insertion_point,omitempty"` 53 | Content *string `protobuf:"bytes,15,opt,name=content" json:"content,omitempty"` 54 | XXX_unrecognized []byte `json:"-"` 55 | } 56 | 57 | func (this *CodeGeneratorResponse_File) Reset() { *this = CodeGeneratorResponse_File{} } 58 | func (this *CodeGeneratorResponse_File) String() string { return proto.CompactTextString(this) } 59 | func (*CodeGeneratorResponse_File) ProtoMessage() {} 60 | 61 | func (this *CodeGeneratorResponse_File) GetName() string { 62 | if this != nil && this.Name != nil { 63 | return *this.Name 64 | } 65 | return "" 66 | } 67 | 68 | func (this *CodeGeneratorResponse_File) GetInsertionPoint() string { 69 | if this != nil && this.InsertionPoint != nil { 70 | return *this.InsertionPoint 71 | } 72 | return "" 73 | } 74 | 75 | func (this *CodeGeneratorResponse_File) GetContent() string { 76 | if this != nil && this.Content != nil { 77 | return *this.Content 78 | } 79 | return "" 80 | } 81 | 82 | func init() { 83 | } 84 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/plugin/plugin.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: kenton@google.com (Kenton Varda) 32 | // 33 | // WARNING: The plugin interface is currently EXPERIMENTAL and is subject to 34 | // change. 35 | // 36 | // protoc (aka the Protocol Compiler) can be extended via plugins. A plugin is 37 | // just a program that reads a CodeGeneratorRequest from stdin and writes a 38 | // CodeGeneratorResponse to stdout. 39 | // 40 | // Plugins written using C++ can use google/protobuf/compiler/plugin.h instead 41 | // of dealing with the raw protocol defined here. 42 | // 43 | // A plugin executable needs only to be placed somewhere in the path. The 44 | // plugin should be named "protoc-gen-$NAME", and will then be used when the 45 | // flag "--${NAME}_out" is passed to protoc. 46 | 47 | syntax = "proto2"; 48 | package google.protobuf.compiler; 49 | option java_package = "com.google.protobuf.compiler"; 50 | option java_outer_classname = "PluginProtos"; 51 | 52 | option go_package = "github.com/golang/protobuf/protoc-gen-go/plugin;plugin_go"; 53 | 54 | import "google/protobuf/descriptor.proto"; 55 | 56 | // The version number of protocol compiler. 57 | message Version { 58 | optional int32 major = 1; 59 | optional int32 minor = 2; 60 | optional int32 patch = 3; 61 | // A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should 62 | // be empty for mainline stable releases. 63 | optional string suffix = 4; 64 | } 65 | 66 | // An encoded CodeGeneratorRequest is written to the plugin's stdin. 67 | message CodeGeneratorRequest { 68 | // The .proto files that were explicitly listed on the command-line. The 69 | // code generator should generate code only for these files. Each file's 70 | // descriptor will be included in proto_file, below. 71 | repeated string file_to_generate = 1; 72 | 73 | // The generator parameter passed on the command-line. 74 | optional string parameter = 2; 75 | 76 | // FileDescriptorProtos for all files in files_to_generate and everything 77 | // they import. The files will appear in topological order, so each file 78 | // appears before any file that imports it. 79 | // 80 | // protoc guarantees that all proto_files will be written after 81 | // the fields above, even though this is not technically guaranteed by the 82 | // protobuf wire format. This theoretically could allow a plugin to stream 83 | // in the FileDescriptorProtos and handle them one by one rather than read 84 | // the entire set into memory at once. However, as of this writing, this 85 | // is not similarly optimized on protoc's end -- it will store all fields in 86 | // memory at once before sending them to the plugin. 87 | // 88 | // Type names of fields and extensions in the FileDescriptorProto are always 89 | // fully qualified. 90 | repeated FileDescriptorProto proto_file = 15; 91 | 92 | // The version number of protocol compiler. 93 | optional Version compiler_version = 3; 94 | 95 | } 96 | 97 | // The plugin writes an encoded CodeGeneratorResponse to stdout. 98 | message CodeGeneratorResponse { 99 | // Error message. If non-empty, code generation failed. The plugin process 100 | // should exit with status code zero even if it reports an error in this way. 101 | // 102 | // This should be used to indicate errors in .proto files which prevent the 103 | // code generator from generating correct code. Errors which indicate a 104 | // problem in protoc itself -- such as the input CodeGeneratorRequest being 105 | // unparseable -- should be reported by writing a message to stderr and 106 | // exiting with a non-zero status code. 107 | optional string error = 1; 108 | 109 | // Represents a single generated file. 110 | message File { 111 | // The file name, relative to the output directory. The name must not 112 | // contain "." or ".." components and must be relative, not be absolute (so, 113 | // the file cannot lie outside the output directory). "/" must be used as 114 | // the path separator, not "\". 115 | // 116 | // If the name is omitted, the content will be appended to the previous 117 | // file. This allows the generator to break large files into small chunks, 118 | // and allows the generated text to be streamed back to protoc so that large 119 | // files need not reside completely in memory at one time. Note that as of 120 | // this writing protoc does not optimize for this -- it will read the entire 121 | // CodeGeneratorResponse before writing files to disk. 122 | optional string name = 1; 123 | 124 | // If non-empty, indicates that the named file should already exist, and the 125 | // content here is to be inserted into that file at a defined insertion 126 | // point. This feature allows a code generator to extend the output 127 | // produced by another code generator. The original generator may provide 128 | // insertion points by placing special annotations in the file that look 129 | // like: 130 | // @@protoc_insertion_point(NAME) 131 | // The annotation can have arbitrary text before and after it on the line, 132 | // which allows it to be placed in a comment. NAME should be replaced with 133 | // an identifier naming the point -- this is what other generators will use 134 | // as the insertion_point. Code inserted at this point will be placed 135 | // immediately above the line containing the insertion point (thus multiple 136 | // insertions to the same point will come out in the order they were added). 137 | // The double-@ is intended to make it unlikely that the generated code 138 | // could contain things that look like insertion points by accident. 139 | // 140 | // For example, the C++ code generator places the following line in the 141 | // .pb.h files that it generates: 142 | // // @@protoc_insertion_point(namespace_scope) 143 | // This line appears within the scope of the file's package namespace, but 144 | // outside of any particular class. Another plugin can then specify the 145 | // insertion_point "namespace_scope" to generate additional classes or 146 | // other declarations that should be placed in this scope. 147 | // 148 | // Note that if the line containing the insertion point begins with 149 | // whitespace, the same whitespace will be added to every line of the 150 | // inserted text. This is useful for languages like Python, where 151 | // indentation matters. In these languages, the insertion point comment 152 | // should be indented the same amount as any inserted code will need to be 153 | // in order to work correctly in that context. 154 | // 155 | // The code generator that generates the initial file and the one which 156 | // inserts into it must both run as part of a single invocation of protoc. 157 | // Code generators are executed in the order in which they appear on the 158 | // command line. 159 | // 160 | // If |insertion_point| is present, |name| must also be present. 161 | optional string insertion_point = 2; 162 | 163 | // The file contents. 164 | optional string content = 15; 165 | } 166 | repeated File file = 15; 167 | } 168 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/any.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2016 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | package ptypes 33 | 34 | // This file implements functions to marshal proto.Message to/from 35 | // google.protobuf.Any message. 36 | 37 | import ( 38 | "fmt" 39 | "reflect" 40 | "strings" 41 | 42 | "github.com/golang/protobuf/proto" 43 | "github.com/golang/protobuf/ptypes/any" 44 | ) 45 | 46 | const googleApis = "type.googleapis.com/" 47 | 48 | // AnyMessageName returns the name of the message contained in a google.protobuf.Any message. 49 | // 50 | // Note that regular type assertions should be done using the Is 51 | // function. AnyMessageName is provided for less common use cases like filtering a 52 | // sequence of Any messages based on a set of allowed message type names. 53 | func AnyMessageName(any *any.Any) (string, error) { 54 | if any == nil { 55 | return "", fmt.Errorf("message is nil") 56 | } 57 | slash := strings.LastIndex(any.TypeUrl, "/") 58 | if slash < 0 { 59 | return "", fmt.Errorf("message type url %q is invalid", any.TypeUrl) 60 | } 61 | return any.TypeUrl[slash+1:], nil 62 | } 63 | 64 | // MarshalAny takes the protocol buffer and encodes it into google.protobuf.Any. 65 | func MarshalAny(pb proto.Message) (*any.Any, error) { 66 | value, err := proto.Marshal(pb) 67 | if err != nil { 68 | return nil, err 69 | } 70 | return &any.Any{TypeUrl: googleApis + proto.MessageName(pb), Value: value}, nil 71 | } 72 | 73 | // DynamicAny is a value that can be passed to UnmarshalAny to automatically 74 | // allocate a proto.Message for the type specified in a google.protobuf.Any 75 | // message. The allocated message is stored in the embedded proto.Message. 76 | // 77 | // Example: 78 | // 79 | // var x ptypes.DynamicAny 80 | // if err := ptypes.UnmarshalAny(a, &x); err != nil { ... } 81 | // fmt.Printf("unmarshaled message: %v", x.Message) 82 | type DynamicAny struct { 83 | proto.Message 84 | } 85 | 86 | // Empty returns a new proto.Message of the type specified in a 87 | // google.protobuf.Any message. It returns an error if corresponding message 88 | // type isn't linked in. 89 | func Empty(any *any.Any) (proto.Message, error) { 90 | aname, err := AnyMessageName(any) 91 | if err != nil { 92 | return nil, err 93 | } 94 | 95 | t := proto.MessageType(aname) 96 | if t == nil { 97 | return nil, fmt.Errorf("any: message type %q isn't linked in", aname) 98 | } 99 | return reflect.New(t.Elem()).Interface().(proto.Message), nil 100 | } 101 | 102 | // UnmarshalAny parses the protocol buffer representation in a google.protobuf.Any 103 | // message and places the decoded result in pb. It returns an error if type of 104 | // contents of Any message does not match type of pb message. 105 | // 106 | // pb can be a proto.Message, or a *DynamicAny. 107 | func UnmarshalAny(any *any.Any, pb proto.Message) error { 108 | if d, ok := pb.(*DynamicAny); ok { 109 | if d.Message == nil { 110 | var err error 111 | d.Message, err = Empty(any) 112 | if err != nil { 113 | return err 114 | } 115 | } 116 | return UnmarshalAny(any, d.Message) 117 | } 118 | 119 | aname, err := AnyMessageName(any) 120 | if err != nil { 121 | return err 122 | } 123 | 124 | mname := proto.MessageName(pb) 125 | if aname != mname { 126 | return fmt.Errorf("mismatched message type: got %q want %q", aname, mname) 127 | } 128 | return proto.Unmarshal(any.Value, pb) 129 | } 130 | 131 | // Is returns true if any value contains a given message type. 132 | func Is(any *any.Any, pb proto.Message) bool { 133 | aname, err := AnyMessageName(any) 134 | if err != nil { 135 | return false 136 | } 137 | 138 | return aname == proto.MessageName(pb) 139 | } 140 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/any/any.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // source: google/protobuf/any.proto 3 | 4 | /* 5 | Package any is a generated protocol buffer package. 6 | 7 | It is generated from these files: 8 | google/protobuf/any.proto 9 | 10 | It has these top-level messages: 11 | Any 12 | */ 13 | package any 14 | 15 | import proto "github.com/golang/protobuf/proto" 16 | import fmt "fmt" 17 | import math "math" 18 | 19 | // Reference imports to suppress errors if they are not otherwise used. 20 | var _ = proto.Marshal 21 | var _ = fmt.Errorf 22 | var _ = math.Inf 23 | 24 | // This is a compile-time assertion to ensure that this generated file 25 | // is compatible with the proto package it is being compiled against. 26 | // A compilation error at this line likely means your copy of the 27 | // proto package needs to be updated. 28 | const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package 29 | 30 | // `Any` contains an arbitrary serialized protocol buffer message along with a 31 | // URL that describes the type of the serialized message. 32 | // 33 | // Protobuf library provides support to pack/unpack Any values in the form 34 | // of utility functions or additional generated methods of the Any type. 35 | // 36 | // Example 1: Pack and unpack a message in C++. 37 | // 38 | // Foo foo = ...; 39 | // Any any; 40 | // any.PackFrom(foo); 41 | // ... 42 | // if (any.UnpackTo(&foo)) { 43 | // ... 44 | // } 45 | // 46 | // Example 2: Pack and unpack a message in Java. 47 | // 48 | // Foo foo = ...; 49 | // Any any = Any.pack(foo); 50 | // ... 51 | // if (any.is(Foo.class)) { 52 | // foo = any.unpack(Foo.class); 53 | // } 54 | // 55 | // Example 3: Pack and unpack a message in Python. 56 | // 57 | // foo = Foo(...) 58 | // any = Any() 59 | // any.Pack(foo) 60 | // ... 61 | // if any.Is(Foo.DESCRIPTOR): 62 | // any.Unpack(foo) 63 | // ... 64 | // 65 | // Example 4: Pack and unpack a message in Go 66 | // 67 | // foo := &pb.Foo{...} 68 | // any, err := ptypes.MarshalAny(foo) 69 | // ... 70 | // foo := &pb.Foo{} 71 | // if err := ptypes.UnmarshalAny(any, foo); err != nil { 72 | // ... 73 | // } 74 | // 75 | // The pack methods provided by protobuf library will by default use 76 | // 'type.googleapis.com/full.type.name' as the type URL and the unpack 77 | // methods only use the fully qualified type name after the last '/' 78 | // in the type URL, for example "foo.bar.com/x/y.z" will yield type 79 | // name "y.z". 80 | // 81 | // 82 | // JSON 83 | // ==== 84 | // The JSON representation of an `Any` value uses the regular 85 | // representation of the deserialized, embedded message, with an 86 | // additional field `@type` which contains the type URL. Example: 87 | // 88 | // package google.profile; 89 | // message Person { 90 | // string first_name = 1; 91 | // string last_name = 2; 92 | // } 93 | // 94 | // { 95 | // "@type": "type.googleapis.com/google.profile.Person", 96 | // "firstName": , 97 | // "lastName": 98 | // } 99 | // 100 | // If the embedded message type is well-known and has a custom JSON 101 | // representation, that representation will be embedded adding a field 102 | // `value` which holds the custom JSON in addition to the `@type` 103 | // field. Example (for message [google.protobuf.Duration][]): 104 | // 105 | // { 106 | // "@type": "type.googleapis.com/google.protobuf.Duration", 107 | // "value": "1.212s" 108 | // } 109 | // 110 | type Any struct { 111 | // A URL/resource name whose content describes the type of the 112 | // serialized protocol buffer message. 113 | // 114 | // For URLs which use the scheme `http`, `https`, or no scheme, the 115 | // following restrictions and interpretations apply: 116 | // 117 | // * If no scheme is provided, `https` is assumed. 118 | // * The last segment of the URL's path must represent the fully 119 | // qualified name of the type (as in `path/google.protobuf.Duration`). 120 | // The name should be in a canonical form (e.g., leading "." is 121 | // not accepted). 122 | // * An HTTP GET on the URL must yield a [google.protobuf.Type][] 123 | // value in binary format, or produce an error. 124 | // * Applications are allowed to cache lookup results based on the 125 | // URL, or have them precompiled into a binary to avoid any 126 | // lookup. Therefore, binary compatibility needs to be preserved 127 | // on changes to types. (Use versioned type names to manage 128 | // breaking changes.) 129 | // 130 | // Schemes other than `http`, `https` (or the empty scheme) might be 131 | // used with implementation specific semantics. 132 | // 133 | TypeUrl string `protobuf:"bytes,1,opt,name=type_url,json=typeUrl" json:"type_url,omitempty"` 134 | // Must be a valid serialized protocol buffer of the above specified type. 135 | Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` 136 | } 137 | 138 | func (m *Any) Reset() { *m = Any{} } 139 | func (m *Any) String() string { return proto.CompactTextString(m) } 140 | func (*Any) ProtoMessage() {} 141 | func (*Any) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } 142 | func (*Any) XXX_WellKnownType() string { return "Any" } 143 | 144 | func (m *Any) GetTypeUrl() string { 145 | if m != nil { 146 | return m.TypeUrl 147 | } 148 | return "" 149 | } 150 | 151 | func (m *Any) GetValue() []byte { 152 | if m != nil { 153 | return m.Value 154 | } 155 | return nil 156 | } 157 | 158 | func init() { 159 | proto.RegisterType((*Any)(nil), "google.protobuf.Any") 160 | } 161 | 162 | func init() { proto.RegisterFile("google/protobuf/any.proto", fileDescriptor0) } 163 | 164 | var fileDescriptor0 = []byte{ 165 | // 185 bytes of a gzipped FileDescriptorProto 166 | 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4c, 0xcf, 0xcf, 0x4f, 167 | 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x4f, 0xcc, 0xab, 0xd4, 168 | 0x03, 0x73, 0x84, 0xf8, 0x21, 0x52, 0x7a, 0x30, 0x29, 0x25, 0x33, 0x2e, 0x66, 0xc7, 0xbc, 0x4a, 169 | 0x21, 0x49, 0x2e, 0x8e, 0x92, 0xca, 0x82, 0xd4, 0xf8, 0xd2, 0xa2, 0x1c, 0x09, 0x46, 0x05, 0x46, 170 | 0x0d, 0xce, 0x20, 0x76, 0x10, 0x3f, 0xb4, 0x28, 0x47, 0x48, 0x84, 0x8b, 0xb5, 0x2c, 0x31, 0xa7, 171 | 0x34, 0x55, 0x82, 0x49, 0x81, 0x51, 0x83, 0x27, 0x08, 0xc2, 0x71, 0xca, 0xe7, 0x12, 0x4e, 0xce, 172 | 0xcf, 0xd5, 0x43, 0x33, 0xce, 0x89, 0xc3, 0x31, 0xaf, 0x32, 0x00, 0xc4, 0x09, 0x60, 0x8c, 0x52, 173 | 0x4d, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcf, 0xcf, 0x49, 0xcc, 174 | 0x4b, 0x47, 0xb8, 0xa8, 0x00, 0x64, 0x7a, 0x31, 0xc8, 0x61, 0x8b, 0x98, 0x98, 0xdd, 0x03, 0x9c, 175 | 0x56, 0x31, 0xc9, 0xb9, 0x43, 0x8c, 0x0a, 0x80, 0x2a, 0xd1, 0x0b, 0x4f, 0xcd, 0xc9, 0xf1, 0xce, 176 | 0xcb, 0x2f, 0xcf, 0x0b, 0x01, 0x29, 0x4d, 0x62, 0x03, 0xeb, 0x35, 0x06, 0x04, 0x00, 0x00, 0xff, 177 | 0xff, 0x13, 0xf8, 0xe8, 0x42, 0xdd, 0x00, 0x00, 0x00, 178 | } 179 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/any/any.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option go_package = "github.com/golang/protobuf/ptypes/any"; 37 | option java_package = "com.google.protobuf"; 38 | option java_outer_classname = "AnyProto"; 39 | option java_multiple_files = true; 40 | option objc_class_prefix = "GPB"; 41 | 42 | // `Any` contains an arbitrary serialized protocol buffer message along with a 43 | // URL that describes the type of the serialized message. 44 | // 45 | // Protobuf library provides support to pack/unpack Any values in the form 46 | // of utility functions or additional generated methods of the Any type. 47 | // 48 | // Example 1: Pack and unpack a message in C++. 49 | // 50 | // Foo foo = ...; 51 | // Any any; 52 | // any.PackFrom(foo); 53 | // ... 54 | // if (any.UnpackTo(&foo)) { 55 | // ... 56 | // } 57 | // 58 | // Example 2: Pack and unpack a message in Java. 59 | // 60 | // Foo foo = ...; 61 | // Any any = Any.pack(foo); 62 | // ... 63 | // if (any.is(Foo.class)) { 64 | // foo = any.unpack(Foo.class); 65 | // } 66 | // 67 | // Example 3: Pack and unpack a message in Python. 68 | // 69 | // foo = Foo(...) 70 | // any = Any() 71 | // any.Pack(foo) 72 | // ... 73 | // if any.Is(Foo.DESCRIPTOR): 74 | // any.Unpack(foo) 75 | // ... 76 | // 77 | // Example 4: Pack and unpack a message in Go 78 | // 79 | // foo := &pb.Foo{...} 80 | // any, err := ptypes.MarshalAny(foo) 81 | // ... 82 | // foo := &pb.Foo{} 83 | // if err := ptypes.UnmarshalAny(any, foo); err != nil { 84 | // ... 85 | // } 86 | // 87 | // The pack methods provided by protobuf library will by default use 88 | // 'type.googleapis.com/full.type.name' as the type URL and the unpack 89 | // methods only use the fully qualified type name after the last '/' 90 | // in the type URL, for example "foo.bar.com/x/y.z" will yield type 91 | // name "y.z". 92 | // 93 | // 94 | // JSON 95 | // ==== 96 | // The JSON representation of an `Any` value uses the regular 97 | // representation of the deserialized, embedded message, with an 98 | // additional field `@type` which contains the type URL. Example: 99 | // 100 | // package google.profile; 101 | // message Person { 102 | // string first_name = 1; 103 | // string last_name = 2; 104 | // } 105 | // 106 | // { 107 | // "@type": "type.googleapis.com/google.profile.Person", 108 | // "firstName": , 109 | // "lastName": 110 | // } 111 | // 112 | // If the embedded message type is well-known and has a custom JSON 113 | // representation, that representation will be embedded adding a field 114 | // `value` which holds the custom JSON in addition to the `@type` 115 | // field. Example (for message [google.protobuf.Duration][]): 116 | // 117 | // { 118 | // "@type": "type.googleapis.com/google.protobuf.Duration", 119 | // "value": "1.212s" 120 | // } 121 | // 122 | message Any { 123 | // A URL/resource name whose content describes the type of the 124 | // serialized protocol buffer message. 125 | // 126 | // For URLs which use the scheme `http`, `https`, or no scheme, the 127 | // following restrictions and interpretations apply: 128 | // 129 | // * If no scheme is provided, `https` is assumed. 130 | // * The last segment of the URL's path must represent the fully 131 | // qualified name of the type (as in `path/google.protobuf.Duration`). 132 | // The name should be in a canonical form (e.g., leading "." is 133 | // not accepted). 134 | // * An HTTP GET on the URL must yield a [google.protobuf.Type][] 135 | // value in binary format, or produce an error. 136 | // * Applications are allowed to cache lookup results based on the 137 | // URL, or have them precompiled into a binary to avoid any 138 | // lookup. Therefore, binary compatibility needs to be preserved 139 | // on changes to types. (Use versioned type names to manage 140 | // breaking changes.) 141 | // 142 | // Schemes other than `http`, `https` (or the empty scheme) might be 143 | // used with implementation specific semantics. 144 | // 145 | string type_url = 1; 146 | 147 | // Must be a valid serialized protocol buffer of the above specified type. 148 | bytes value = 2; 149 | } 150 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/doc.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2016 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | /* 33 | Package ptypes contains code for interacting with well-known types. 34 | */ 35 | package ptypes 36 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/duration.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2016 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | package ptypes 33 | 34 | // This file implements conversions between google.protobuf.Duration 35 | // and time.Duration. 36 | 37 | import ( 38 | "errors" 39 | "fmt" 40 | "time" 41 | 42 | durpb "github.com/golang/protobuf/ptypes/duration" 43 | ) 44 | 45 | const ( 46 | // Range of a durpb.Duration in seconds, as specified in 47 | // google/protobuf/duration.proto. This is about 10,000 years in seconds. 48 | maxSeconds = int64(10000 * 365.25 * 24 * 60 * 60) 49 | minSeconds = -maxSeconds 50 | ) 51 | 52 | // validateDuration determines whether the durpb.Duration is valid according to the 53 | // definition in google/protobuf/duration.proto. A valid durpb.Duration 54 | // may still be too large to fit into a time.Duration (the range of durpb.Duration 55 | // is about 10,000 years, and the range of time.Duration is about 290). 56 | func validateDuration(d *durpb.Duration) error { 57 | if d == nil { 58 | return errors.New("duration: nil Duration") 59 | } 60 | if d.Seconds < minSeconds || d.Seconds > maxSeconds { 61 | return fmt.Errorf("duration: %v: seconds out of range", d) 62 | } 63 | if d.Nanos <= -1e9 || d.Nanos >= 1e9 { 64 | return fmt.Errorf("duration: %v: nanos out of range", d) 65 | } 66 | // Seconds and Nanos must have the same sign, unless d.Nanos is zero. 67 | if (d.Seconds < 0 && d.Nanos > 0) || (d.Seconds > 0 && d.Nanos < 0) { 68 | return fmt.Errorf("duration: %v: seconds and nanos have different signs", d) 69 | } 70 | return nil 71 | } 72 | 73 | // Duration converts a durpb.Duration to a time.Duration. Duration 74 | // returns an error if the durpb.Duration is invalid or is too large to be 75 | // represented in a time.Duration. 76 | func Duration(p *durpb.Duration) (time.Duration, error) { 77 | if err := validateDuration(p); err != nil { 78 | return 0, err 79 | } 80 | d := time.Duration(p.Seconds) * time.Second 81 | if int64(d/time.Second) != p.Seconds { 82 | return 0, fmt.Errorf("duration: %v is out of range for time.Duration", p) 83 | } 84 | if p.Nanos != 0 { 85 | d += time.Duration(p.Nanos) 86 | if (d < 0) != (p.Nanos < 0) { 87 | return 0, fmt.Errorf("duration: %v is out of range for time.Duration", p) 88 | } 89 | } 90 | return d, nil 91 | } 92 | 93 | // DurationProto converts a time.Duration to a durpb.Duration. 94 | func DurationProto(d time.Duration) *durpb.Duration { 95 | nanos := d.Nanoseconds() 96 | secs := nanos / 1e9 97 | nanos -= secs * 1e9 98 | return &durpb.Duration{ 99 | Seconds: secs, 100 | Nanos: int32(nanos), 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/duration/duration.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // source: google/protobuf/duration.proto 3 | 4 | /* 5 | Package duration is a generated protocol buffer package. 6 | 7 | It is generated from these files: 8 | google/protobuf/duration.proto 9 | 10 | It has these top-level messages: 11 | Duration 12 | */ 13 | package duration 14 | 15 | import proto "github.com/golang/protobuf/proto" 16 | import fmt "fmt" 17 | import math "math" 18 | 19 | // Reference imports to suppress errors if they are not otherwise used. 20 | var _ = proto.Marshal 21 | var _ = fmt.Errorf 22 | var _ = math.Inf 23 | 24 | // This is a compile-time assertion to ensure that this generated file 25 | // is compatible with the proto package it is being compiled against. 26 | // A compilation error at this line likely means your copy of the 27 | // proto package needs to be updated. 28 | const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package 29 | 30 | // A Duration represents a signed, fixed-length span of time represented 31 | // as a count of seconds and fractions of seconds at nanosecond 32 | // resolution. It is independent of any calendar and concepts like "day" 33 | // or "month". It is related to Timestamp in that the difference between 34 | // two Timestamp values is a Duration and it can be added or subtracted 35 | // from a Timestamp. Range is approximately +-10,000 years. 36 | // 37 | // # Examples 38 | // 39 | // Example 1: Compute Duration from two Timestamps in pseudo code. 40 | // 41 | // Timestamp start = ...; 42 | // Timestamp end = ...; 43 | // Duration duration = ...; 44 | // 45 | // duration.seconds = end.seconds - start.seconds; 46 | // duration.nanos = end.nanos - start.nanos; 47 | // 48 | // if (duration.seconds < 0 && duration.nanos > 0) { 49 | // duration.seconds += 1; 50 | // duration.nanos -= 1000000000; 51 | // } else if (durations.seconds > 0 && duration.nanos < 0) { 52 | // duration.seconds -= 1; 53 | // duration.nanos += 1000000000; 54 | // } 55 | // 56 | // Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. 57 | // 58 | // Timestamp start = ...; 59 | // Duration duration = ...; 60 | // Timestamp end = ...; 61 | // 62 | // end.seconds = start.seconds + duration.seconds; 63 | // end.nanos = start.nanos + duration.nanos; 64 | // 65 | // if (end.nanos < 0) { 66 | // end.seconds -= 1; 67 | // end.nanos += 1000000000; 68 | // } else if (end.nanos >= 1000000000) { 69 | // end.seconds += 1; 70 | // end.nanos -= 1000000000; 71 | // } 72 | // 73 | // Example 3: Compute Duration from datetime.timedelta in Python. 74 | // 75 | // td = datetime.timedelta(days=3, minutes=10) 76 | // duration = Duration() 77 | // duration.FromTimedelta(td) 78 | // 79 | // # JSON Mapping 80 | // 81 | // In JSON format, the Duration type is encoded as a string rather than an 82 | // object, where the string ends in the suffix "s" (indicating seconds) and 83 | // is preceded by the number of seconds, with nanoseconds expressed as 84 | // fractional seconds. For example, 3 seconds with 0 nanoseconds should be 85 | // encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should 86 | // be expressed in JSON format as "3.000000001s", and 3 seconds and 1 87 | // microsecond should be expressed in JSON format as "3.000001s". 88 | // 89 | // 90 | type Duration struct { 91 | // Signed seconds of the span of time. Must be from -315,576,000,000 92 | // to +315,576,000,000 inclusive. Note: these bounds are computed from: 93 | // 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years 94 | Seconds int64 `protobuf:"varint,1,opt,name=seconds" json:"seconds,omitempty"` 95 | // Signed fractions of a second at nanosecond resolution of the span 96 | // of time. Durations less than one second are represented with a 0 97 | // `seconds` field and a positive or negative `nanos` field. For durations 98 | // of one second or more, a non-zero value for the `nanos` field must be 99 | // of the same sign as the `seconds` field. Must be from -999,999,999 100 | // to +999,999,999 inclusive. 101 | Nanos int32 `protobuf:"varint,2,opt,name=nanos" json:"nanos,omitempty"` 102 | } 103 | 104 | func (m *Duration) Reset() { *m = Duration{} } 105 | func (m *Duration) String() string { return proto.CompactTextString(m) } 106 | func (*Duration) ProtoMessage() {} 107 | func (*Duration) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } 108 | func (*Duration) XXX_WellKnownType() string { return "Duration" } 109 | 110 | func (m *Duration) GetSeconds() int64 { 111 | if m != nil { 112 | return m.Seconds 113 | } 114 | return 0 115 | } 116 | 117 | func (m *Duration) GetNanos() int32 { 118 | if m != nil { 119 | return m.Nanos 120 | } 121 | return 0 122 | } 123 | 124 | func init() { 125 | proto.RegisterType((*Duration)(nil), "google.protobuf.Duration") 126 | } 127 | 128 | func init() { proto.RegisterFile("google/protobuf/duration.proto", fileDescriptor0) } 129 | 130 | var fileDescriptor0 = []byte{ 131 | // 190 bytes of a gzipped FileDescriptorProto 132 | 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xcf, 0xcf, 0x4f, 133 | 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x4f, 0x29, 0x2d, 0x4a, 134 | 0x2c, 0xc9, 0xcc, 0xcf, 0xd3, 0x03, 0x8b, 0x08, 0xf1, 0x43, 0xe4, 0xf5, 0x60, 0xf2, 0x4a, 0x56, 135 | 0x5c, 0x1c, 0x2e, 0x50, 0x25, 0x42, 0x12, 0x5c, 0xec, 0xc5, 0xa9, 0xc9, 0xf9, 0x79, 0x29, 0xc5, 136 | 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xcc, 0x41, 0x30, 0xae, 0x90, 0x08, 0x17, 0x6b, 0x5e, 0x62, 0x5e, 137 | 0x7e, 0xb1, 0x04, 0x93, 0x02, 0xa3, 0x06, 0x6b, 0x10, 0x84, 0xe3, 0x54, 0xc3, 0x25, 0x9c, 0x9c, 138 | 0x9f, 0xab, 0x87, 0x66, 0xa4, 0x13, 0x2f, 0xcc, 0xc0, 0x00, 0x90, 0x48, 0x00, 0x63, 0x94, 0x56, 139 | 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x7a, 0x7e, 0x4e, 0x62, 0x5e, 140 | 0x3a, 0xc2, 0x7d, 0x05, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x70, 0x67, 0xfe, 0x60, 0x64, 0x5c, 0xc4, 141 | 0xc4, 0xec, 0x1e, 0xe0, 0xb4, 0x8a, 0x49, 0xce, 0x1d, 0x62, 0x6e, 0x00, 0x54, 0xa9, 0x5e, 0x78, 142 | 0x6a, 0x4e, 0x8e, 0x77, 0x5e, 0x7e, 0x79, 0x5e, 0x08, 0x48, 0x4b, 0x12, 0x1b, 0xd8, 0x0c, 0x63, 143 | 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xdc, 0x84, 0x30, 0xff, 0xf3, 0x00, 0x00, 0x00, 144 | } 145 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/duration/duration.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option cc_enable_arenas = true; 37 | option go_package = "github.com/golang/protobuf/ptypes/duration"; 38 | option java_package = "com.google.protobuf"; 39 | option java_outer_classname = "DurationProto"; 40 | option java_multiple_files = true; 41 | option objc_class_prefix = "GPB"; 42 | 43 | // A Duration represents a signed, fixed-length span of time represented 44 | // as a count of seconds and fractions of seconds at nanosecond 45 | // resolution. It is independent of any calendar and concepts like "day" 46 | // or "month". It is related to Timestamp in that the difference between 47 | // two Timestamp values is a Duration and it can be added or subtracted 48 | // from a Timestamp. Range is approximately +-10,000 years. 49 | // 50 | // # Examples 51 | // 52 | // Example 1: Compute Duration from two Timestamps in pseudo code. 53 | // 54 | // Timestamp start = ...; 55 | // Timestamp end = ...; 56 | // Duration duration = ...; 57 | // 58 | // duration.seconds = end.seconds - start.seconds; 59 | // duration.nanos = end.nanos - start.nanos; 60 | // 61 | // if (duration.seconds < 0 && duration.nanos > 0) { 62 | // duration.seconds += 1; 63 | // duration.nanos -= 1000000000; 64 | // } else if (durations.seconds > 0 && duration.nanos < 0) { 65 | // duration.seconds -= 1; 66 | // duration.nanos += 1000000000; 67 | // } 68 | // 69 | // Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. 70 | // 71 | // Timestamp start = ...; 72 | // Duration duration = ...; 73 | // Timestamp end = ...; 74 | // 75 | // end.seconds = start.seconds + duration.seconds; 76 | // end.nanos = start.nanos + duration.nanos; 77 | // 78 | // if (end.nanos < 0) { 79 | // end.seconds -= 1; 80 | // end.nanos += 1000000000; 81 | // } else if (end.nanos >= 1000000000) { 82 | // end.seconds += 1; 83 | // end.nanos -= 1000000000; 84 | // } 85 | // 86 | // Example 3: Compute Duration from datetime.timedelta in Python. 87 | // 88 | // td = datetime.timedelta(days=3, minutes=10) 89 | // duration = Duration() 90 | // duration.FromTimedelta(td) 91 | // 92 | // # JSON Mapping 93 | // 94 | // In JSON format, the Duration type is encoded as a string rather than an 95 | // object, where the string ends in the suffix "s" (indicating seconds) and 96 | // is preceded by the number of seconds, with nanoseconds expressed as 97 | // fractional seconds. For example, 3 seconds with 0 nanoseconds should be 98 | // encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should 99 | // be expressed in JSON format as "3.000000001s", and 3 seconds and 1 100 | // microsecond should be expressed in JSON format as "3.000001s". 101 | // 102 | // 103 | message Duration { 104 | 105 | // Signed seconds of the span of time. Must be from -315,576,000,000 106 | // to +315,576,000,000 inclusive. Note: these bounds are computed from: 107 | // 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years 108 | int64 seconds = 1; 109 | 110 | // Signed fractions of a second at nanosecond resolution of the span 111 | // of time. Durations less than one second are represented with a 0 112 | // `seconds` field and a positive or negative `nanos` field. For durations 113 | // of one second or more, a non-zero value for the `nanos` field must be 114 | // of the same sign as the `seconds` field. Must be from -999,999,999 115 | // to +999,999,999 inclusive. 116 | int32 nanos = 2; 117 | } 118 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/empty/empty.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // source: google/protobuf/empty.proto 3 | 4 | /* 5 | Package empty is a generated protocol buffer package. 6 | 7 | It is generated from these files: 8 | google/protobuf/empty.proto 9 | 10 | It has these top-level messages: 11 | Empty 12 | */ 13 | package empty 14 | 15 | import proto "github.com/golang/protobuf/proto" 16 | import fmt "fmt" 17 | import math "math" 18 | 19 | // Reference imports to suppress errors if they are not otherwise used. 20 | var _ = proto.Marshal 21 | var _ = fmt.Errorf 22 | var _ = math.Inf 23 | 24 | // This is a compile-time assertion to ensure that this generated file 25 | // is compatible with the proto package it is being compiled against. 26 | // A compilation error at this line likely means your copy of the 27 | // proto package needs to be updated. 28 | const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package 29 | 30 | // A generic empty message that you can re-use to avoid defining duplicated 31 | // empty messages in your APIs. A typical example is to use it as the request 32 | // or the response type of an API method. For instance: 33 | // 34 | // service Foo { 35 | // rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); 36 | // } 37 | // 38 | // The JSON representation for `Empty` is empty JSON object `{}`. 39 | type Empty struct { 40 | } 41 | 42 | func (m *Empty) Reset() { *m = Empty{} } 43 | func (m *Empty) String() string { return proto.CompactTextString(m) } 44 | func (*Empty) ProtoMessage() {} 45 | func (*Empty) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } 46 | func (*Empty) XXX_WellKnownType() string { return "Empty" } 47 | 48 | func init() { 49 | proto.RegisterType((*Empty)(nil), "google.protobuf.Empty") 50 | } 51 | 52 | func init() { proto.RegisterFile("google/protobuf/empty.proto", fileDescriptor0) } 53 | 54 | var fileDescriptor0 = []byte{ 55 | // 148 bytes of a gzipped FileDescriptorProto 56 | 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4e, 0xcf, 0xcf, 0x4f, 57 | 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x4f, 0xcd, 0x2d, 0x28, 58 | 0xa9, 0xd4, 0x03, 0x73, 0x85, 0xf8, 0x21, 0x92, 0x7a, 0x30, 0x49, 0x25, 0x76, 0x2e, 0x56, 0x57, 59 | 0x90, 0xbc, 0x53, 0x19, 0x97, 0x70, 0x72, 0x7e, 0xae, 0x1e, 0x9a, 0xbc, 0x13, 0x17, 0x58, 0x36, 60 | 0x00, 0xc4, 0x0d, 0x60, 0x8c, 0x52, 0x4f, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 61 | 0xd5, 0x4f, 0xcf, 0xcf, 0x49, 0xcc, 0x4b, 0x47, 0x58, 0x53, 0x50, 0x52, 0x59, 0x90, 0x5a, 0x0c, 62 | 0xb1, 0xed, 0x07, 0x23, 0xe3, 0x22, 0x26, 0x66, 0xf7, 0x00, 0xa7, 0x55, 0x4c, 0x72, 0xee, 0x10, 63 | 0x13, 0x03, 0xa0, 0xea, 0xf4, 0xc2, 0x53, 0x73, 0x72, 0xbc, 0xf3, 0xf2, 0xcb, 0xf3, 0x42, 0x40, 64 | 0xea, 0x93, 0xd8, 0xc0, 0x06, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x64, 0xd4, 0xb3, 0xa6, 65 | 0xb7, 0x00, 0x00, 0x00, 66 | } 67 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/empty/empty.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option go_package = "github.com/golang/protobuf/ptypes/empty"; 37 | option java_package = "com.google.protobuf"; 38 | option java_outer_classname = "EmptyProto"; 39 | option java_multiple_files = true; 40 | option objc_class_prefix = "GPB"; 41 | option cc_enable_arenas = true; 42 | 43 | // A generic empty message that you can re-use to avoid defining duplicated 44 | // empty messages in your APIs. A typical example is to use it as the request 45 | // or the response type of an API method. For instance: 46 | // 47 | // service Foo { 48 | // rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); 49 | // } 50 | // 51 | // The JSON representation for `Empty` is empty JSON object `{}`. 52 | message Empty {} 53 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/regen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # 3 | # This script fetches and rebuilds the "well-known types" protocol buffers. 4 | # To run this you will need protoc and goprotobuf installed; 5 | # see https://github.com/golang/protobuf for instructions. 6 | # You also need Go and Git installed. 7 | 8 | PKG=github.com/golang/protobuf/ptypes 9 | UPSTREAM=https://github.com/google/protobuf 10 | UPSTREAM_SUBDIR=src/google/protobuf 11 | PROTO_FILES=(any duration empty struct timestamp wrappers) 12 | 13 | function die() { 14 | echo 1>&2 $* 15 | exit 1 16 | } 17 | 18 | # Sanity check that the right tools are accessible. 19 | for tool in go git protoc protoc-gen-go; do 20 | q=$(which $tool) || die "didn't find $tool" 21 | echo 1>&2 "$tool: $q" 22 | done 23 | 24 | tmpdir=$(mktemp -d -t regen-wkt.XXXXXX) 25 | trap 'rm -rf $tmpdir' EXIT 26 | 27 | echo -n 1>&2 "finding package dir... " 28 | pkgdir=$(go list -f '{{.Dir}}' $PKG) 29 | echo 1>&2 $pkgdir 30 | base=$(echo $pkgdir | sed "s,/$PKG\$,,") 31 | echo 1>&2 "base: $base" 32 | cd "$base" 33 | 34 | echo 1>&2 "fetching latest protos... " 35 | git clone -q $UPSTREAM $tmpdir 36 | 37 | for file in ${PROTO_FILES[@]}; do 38 | echo 1>&2 "* $file" 39 | protoc --go_out=. -I$tmpdir/src $tmpdir/src/google/protobuf/$file.proto || die 40 | cp $tmpdir/src/google/protobuf/$file.proto $PKG/$file 41 | done 42 | 43 | echo 1>&2 "All OK" 44 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/struct/struct.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option cc_enable_arenas = true; 37 | option go_package = "github.com/golang/protobuf/ptypes/struct;structpb"; 38 | option java_package = "com.google.protobuf"; 39 | option java_outer_classname = "StructProto"; 40 | option java_multiple_files = true; 41 | option objc_class_prefix = "GPB"; 42 | 43 | 44 | // `Struct` represents a structured data value, consisting of fields 45 | // which map to dynamically typed values. In some languages, `Struct` 46 | // might be supported by a native representation. For example, in 47 | // scripting languages like JS a struct is represented as an 48 | // object. The details of that representation are described together 49 | // with the proto support for the language. 50 | // 51 | // The JSON representation for `Struct` is JSON object. 52 | message Struct { 53 | // Unordered map of dynamically typed values. 54 | map fields = 1; 55 | } 56 | 57 | // `Value` represents a dynamically typed value which can be either 58 | // null, a number, a string, a boolean, a recursive struct value, or a 59 | // list of values. A producer of value is expected to set one of that 60 | // variants, absence of any variant indicates an error. 61 | // 62 | // The JSON representation for `Value` is JSON value. 63 | message Value { 64 | // The kind of value. 65 | oneof kind { 66 | // Represents a null value. 67 | NullValue null_value = 1; 68 | // Represents a double value. 69 | double number_value = 2; 70 | // Represents a string value. 71 | string string_value = 3; 72 | // Represents a boolean value. 73 | bool bool_value = 4; 74 | // Represents a structured value. 75 | Struct struct_value = 5; 76 | // Represents a repeated `Value`. 77 | ListValue list_value = 6; 78 | } 79 | } 80 | 81 | // `NullValue` is a singleton enumeration to represent the null value for the 82 | // `Value` type union. 83 | // 84 | // The JSON representation for `NullValue` is JSON `null`. 85 | enum NullValue { 86 | // Null value. 87 | NULL_VALUE = 0; 88 | } 89 | 90 | // `ListValue` is a wrapper around a repeated field of values. 91 | // 92 | // The JSON representation for `ListValue` is JSON array. 93 | message ListValue { 94 | // Repeated field of dynamically typed values. 95 | repeated Value values = 1; 96 | } 97 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/timestamp.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2016 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | package ptypes 33 | 34 | // This file implements operations on google.protobuf.Timestamp. 35 | 36 | import ( 37 | "errors" 38 | "fmt" 39 | "time" 40 | 41 | tspb "github.com/golang/protobuf/ptypes/timestamp" 42 | ) 43 | 44 | const ( 45 | // Seconds field of the earliest valid Timestamp. 46 | // This is time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC).Unix(). 47 | minValidSeconds = -62135596800 48 | // Seconds field just after the latest valid Timestamp. 49 | // This is time.Date(10000, 1, 1, 0, 0, 0, 0, time.UTC).Unix(). 50 | maxValidSeconds = 253402300800 51 | ) 52 | 53 | // validateTimestamp determines whether a Timestamp is valid. 54 | // A valid timestamp represents a time in the range 55 | // [0001-01-01, 10000-01-01) and has a Nanos field 56 | // in the range [0, 1e9). 57 | // 58 | // If the Timestamp is valid, validateTimestamp returns nil. 59 | // Otherwise, it returns an error that describes 60 | // the problem. 61 | // 62 | // Every valid Timestamp can be represented by a time.Time, but the converse is not true. 63 | func validateTimestamp(ts *tspb.Timestamp) error { 64 | if ts == nil { 65 | return errors.New("timestamp: nil Timestamp") 66 | } 67 | if ts.Seconds < minValidSeconds { 68 | return fmt.Errorf("timestamp: %v before 0001-01-01", ts) 69 | } 70 | if ts.Seconds >= maxValidSeconds { 71 | return fmt.Errorf("timestamp: %v after 10000-01-01", ts) 72 | } 73 | if ts.Nanos < 0 || ts.Nanos >= 1e9 { 74 | return fmt.Errorf("timestamp: %v: nanos not in range [0, 1e9)", ts) 75 | } 76 | return nil 77 | } 78 | 79 | // Timestamp converts a google.protobuf.Timestamp proto to a time.Time. 80 | // It returns an error if the argument is invalid. 81 | // 82 | // Unlike most Go functions, if Timestamp returns an error, the first return value 83 | // is not the zero time.Time. Instead, it is the value obtained from the 84 | // time.Unix function when passed the contents of the Timestamp, in the UTC 85 | // locale. This may or may not be a meaningful time; many invalid Timestamps 86 | // do map to valid time.Times. 87 | // 88 | // A nil Timestamp returns an error. The first return value in that case is 89 | // undefined. 90 | func Timestamp(ts *tspb.Timestamp) (time.Time, error) { 91 | // Don't return the zero value on error, because corresponds to a valid 92 | // timestamp. Instead return whatever time.Unix gives us. 93 | var t time.Time 94 | if ts == nil { 95 | t = time.Unix(0, 0).UTC() // treat nil like the empty Timestamp 96 | } else { 97 | t = time.Unix(ts.Seconds, int64(ts.Nanos)).UTC() 98 | } 99 | return t, validateTimestamp(ts) 100 | } 101 | 102 | // TimestampNow returns a google.protobuf.Timestamp for the current time. 103 | func TimestampNow() *tspb.Timestamp { 104 | ts, err := TimestampProto(time.Now()) 105 | if err != nil { 106 | panic("ptypes: time.Now() out of Timestamp range") 107 | } 108 | return ts 109 | } 110 | 111 | // TimestampProto converts the time.Time to a google.protobuf.Timestamp proto. 112 | // It returns an error if the resulting Timestamp is invalid. 113 | func TimestampProto(t time.Time) (*tspb.Timestamp, error) { 114 | seconds := t.Unix() 115 | nanos := int32(t.Sub(time.Unix(seconds, 0))) 116 | ts := &tspb.Timestamp{ 117 | Seconds: seconds, 118 | Nanos: nanos, 119 | } 120 | if err := validateTimestamp(ts); err != nil { 121 | return nil, err 122 | } 123 | return ts, nil 124 | } 125 | 126 | // TimestampString returns the RFC 3339 string for valid Timestamps. For invalid 127 | // Timestamps, it returns an error message in parentheses. 128 | func TimestampString(ts *tspb.Timestamp) string { 129 | t, err := Timestamp(ts) 130 | if err != nil { 131 | return fmt.Sprintf("(%v)", err) 132 | } 133 | return t.Format(time.RFC3339Nano) 134 | } 135 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // source: google/protobuf/timestamp.proto 3 | 4 | /* 5 | Package timestamp is a generated protocol buffer package. 6 | 7 | It is generated from these files: 8 | google/protobuf/timestamp.proto 9 | 10 | It has these top-level messages: 11 | Timestamp 12 | */ 13 | package timestamp 14 | 15 | import proto "github.com/golang/protobuf/proto" 16 | import fmt "fmt" 17 | import math "math" 18 | 19 | // Reference imports to suppress errors if they are not otherwise used. 20 | var _ = proto.Marshal 21 | var _ = fmt.Errorf 22 | var _ = math.Inf 23 | 24 | // This is a compile-time assertion to ensure that this generated file 25 | // is compatible with the proto package it is being compiled against. 26 | // A compilation error at this line likely means your copy of the 27 | // proto package needs to be updated. 28 | const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package 29 | 30 | // A Timestamp represents a point in time independent of any time zone 31 | // or calendar, represented as seconds and fractions of seconds at 32 | // nanosecond resolution in UTC Epoch time. It is encoded using the 33 | // Proleptic Gregorian Calendar which extends the Gregorian calendar 34 | // backwards to year one. It is encoded assuming all minutes are 60 35 | // seconds long, i.e. leap seconds are "smeared" so that no leap second 36 | // table is needed for interpretation. Range is from 37 | // 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. 38 | // By restricting to that range, we ensure that we can convert to 39 | // and from RFC 3339 date strings. 40 | // See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt). 41 | // 42 | // # Examples 43 | // 44 | // Example 1: Compute Timestamp from POSIX `time()`. 45 | // 46 | // Timestamp timestamp; 47 | // timestamp.set_seconds(time(NULL)); 48 | // timestamp.set_nanos(0); 49 | // 50 | // Example 2: Compute Timestamp from POSIX `gettimeofday()`. 51 | // 52 | // struct timeval tv; 53 | // gettimeofday(&tv, NULL); 54 | // 55 | // Timestamp timestamp; 56 | // timestamp.set_seconds(tv.tv_sec); 57 | // timestamp.set_nanos(tv.tv_usec * 1000); 58 | // 59 | // Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. 60 | // 61 | // FILETIME ft; 62 | // GetSystemTimeAsFileTime(&ft); 63 | // UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; 64 | // 65 | // // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z 66 | // // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. 67 | // Timestamp timestamp; 68 | // timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); 69 | // timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); 70 | // 71 | // Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. 72 | // 73 | // long millis = System.currentTimeMillis(); 74 | // 75 | // Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) 76 | // .setNanos((int) ((millis % 1000) * 1000000)).build(); 77 | // 78 | // 79 | // Example 5: Compute Timestamp from current time in Python. 80 | // 81 | // timestamp = Timestamp() 82 | // timestamp.GetCurrentTime() 83 | // 84 | // # JSON Mapping 85 | // 86 | // In JSON format, the Timestamp type is encoded as a string in the 87 | // [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the 88 | // format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" 89 | // where {year} is always expressed using four digits while {month}, {day}, 90 | // {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional 91 | // seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), 92 | // are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone 93 | // is required, though only UTC (as indicated by "Z") is presently supported. 94 | // 95 | // For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past 96 | // 01:30 UTC on January 15, 2017. 97 | // 98 | // In JavaScript, one can convert a Date object to this format using the 99 | // standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString] 100 | // method. In Python, a standard `datetime.datetime` object can be converted 101 | // to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) 102 | // with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one 103 | // can use the Joda Time's [`ISODateTimeFormat.dateTime()`]( 104 | // http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()) 105 | // to obtain a formatter capable of generating timestamps in this format. 106 | // 107 | // 108 | type Timestamp struct { 109 | // Represents seconds of UTC time since Unix epoch 110 | // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to 111 | // 9999-12-31T23:59:59Z inclusive. 112 | Seconds int64 `protobuf:"varint,1,opt,name=seconds" json:"seconds,omitempty"` 113 | // Non-negative fractions of a second at nanosecond resolution. Negative 114 | // second values with fractions must still have non-negative nanos values 115 | // that count forward in time. Must be from 0 to 999,999,999 116 | // inclusive. 117 | Nanos int32 `protobuf:"varint,2,opt,name=nanos" json:"nanos,omitempty"` 118 | } 119 | 120 | func (m *Timestamp) Reset() { *m = Timestamp{} } 121 | func (m *Timestamp) String() string { return proto.CompactTextString(m) } 122 | func (*Timestamp) ProtoMessage() {} 123 | func (*Timestamp) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } 124 | func (*Timestamp) XXX_WellKnownType() string { return "Timestamp" } 125 | 126 | func (m *Timestamp) GetSeconds() int64 { 127 | if m != nil { 128 | return m.Seconds 129 | } 130 | return 0 131 | } 132 | 133 | func (m *Timestamp) GetNanos() int32 { 134 | if m != nil { 135 | return m.Nanos 136 | } 137 | return 0 138 | } 139 | 140 | func init() { 141 | proto.RegisterType((*Timestamp)(nil), "google.protobuf.Timestamp") 142 | } 143 | 144 | func init() { proto.RegisterFile("google/protobuf/timestamp.proto", fileDescriptor0) } 145 | 146 | var fileDescriptor0 = []byte{ 147 | // 191 bytes of a gzipped FileDescriptorProto 148 | 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xcf, 0xcf, 0x4f, 149 | 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x2f, 0xc9, 0xcc, 0x4d, 150 | 0x2d, 0x2e, 0x49, 0xcc, 0x2d, 0xd0, 0x03, 0x0b, 0x09, 0xf1, 0x43, 0x14, 0xe8, 0xc1, 0x14, 0x28, 151 | 0x59, 0x73, 0x71, 0x86, 0xc0, 0xd4, 0x08, 0x49, 0x70, 0xb1, 0x17, 0xa7, 0x26, 0xe7, 0xe7, 0xa5, 152 | 0x14, 0x4b, 0x30, 0x2a, 0x30, 0x6a, 0x30, 0x07, 0xc1, 0xb8, 0x42, 0x22, 0x5c, 0xac, 0x79, 0x89, 153 | 0x79, 0xf9, 0xc5, 0x12, 0x4c, 0x0a, 0x8c, 0x1a, 0xac, 0x41, 0x10, 0x8e, 0x53, 0x1d, 0x97, 0x70, 154 | 0x72, 0x7e, 0xae, 0x1e, 0x9a, 0x99, 0x4e, 0x7c, 0x70, 0x13, 0x03, 0x40, 0x42, 0x01, 0x8c, 0x51, 155 | 0xda, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xe9, 0xf9, 0x39, 0x89, 156 | 0x79, 0xe9, 0x08, 0x27, 0x16, 0x94, 0x54, 0x16, 0xa4, 0x16, 0x23, 0x5c, 0xfa, 0x83, 0x91, 0x71, 157 | 0x11, 0x13, 0xb3, 0x7b, 0x80, 0xd3, 0x2a, 0x26, 0x39, 0x77, 0x88, 0xc9, 0x01, 0x50, 0xb5, 0x7a, 158 | 0xe1, 0xa9, 0x39, 0x39, 0xde, 0x79, 0xf9, 0xe5, 0x79, 0x21, 0x20, 0x3d, 0x49, 0x6c, 0x60, 0x43, 159 | 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xbc, 0x77, 0x4a, 0x07, 0xf7, 0x00, 0x00, 0x00, 160 | } 161 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option cc_enable_arenas = true; 37 | option go_package = "github.com/golang/protobuf/ptypes/timestamp"; 38 | option java_package = "com.google.protobuf"; 39 | option java_outer_classname = "TimestampProto"; 40 | option java_multiple_files = true; 41 | option objc_class_prefix = "GPB"; 42 | 43 | // A Timestamp represents a point in time independent of any time zone 44 | // or calendar, represented as seconds and fractions of seconds at 45 | // nanosecond resolution in UTC Epoch time. It is encoded using the 46 | // Proleptic Gregorian Calendar which extends the Gregorian calendar 47 | // backwards to year one. It is encoded assuming all minutes are 60 48 | // seconds long, i.e. leap seconds are "smeared" so that no leap second 49 | // table is needed for interpretation. Range is from 50 | // 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. 51 | // By restricting to that range, we ensure that we can convert to 52 | // and from RFC 3339 date strings. 53 | // See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt). 54 | // 55 | // # Examples 56 | // 57 | // Example 1: Compute Timestamp from POSIX `time()`. 58 | // 59 | // Timestamp timestamp; 60 | // timestamp.set_seconds(time(NULL)); 61 | // timestamp.set_nanos(0); 62 | // 63 | // Example 2: Compute Timestamp from POSIX `gettimeofday()`. 64 | // 65 | // struct timeval tv; 66 | // gettimeofday(&tv, NULL); 67 | // 68 | // Timestamp timestamp; 69 | // timestamp.set_seconds(tv.tv_sec); 70 | // timestamp.set_nanos(tv.tv_usec * 1000); 71 | // 72 | // Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. 73 | // 74 | // FILETIME ft; 75 | // GetSystemTimeAsFileTime(&ft); 76 | // UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; 77 | // 78 | // // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z 79 | // // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. 80 | // Timestamp timestamp; 81 | // timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); 82 | // timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); 83 | // 84 | // Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. 85 | // 86 | // long millis = System.currentTimeMillis(); 87 | // 88 | // Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) 89 | // .setNanos((int) ((millis % 1000) * 1000000)).build(); 90 | // 91 | // 92 | // Example 5: Compute Timestamp from current time in Python. 93 | // 94 | // timestamp = Timestamp() 95 | // timestamp.GetCurrentTime() 96 | // 97 | // # JSON Mapping 98 | // 99 | // In JSON format, the Timestamp type is encoded as a string in the 100 | // [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the 101 | // format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" 102 | // where {year} is always expressed using four digits while {month}, {day}, 103 | // {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional 104 | // seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), 105 | // are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone 106 | // is required, though only UTC (as indicated by "Z") is presently supported. 107 | // 108 | // For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past 109 | // 01:30 UTC on January 15, 2017. 110 | // 111 | // In JavaScript, one can convert a Date object to this format using the 112 | // standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString] 113 | // method. In Python, a standard `datetime.datetime` object can be converted 114 | // to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) 115 | // with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one 116 | // can use the Joda Time's [`ISODateTimeFormat.dateTime()`]( 117 | // http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()) 118 | // to obtain a formatter capable of generating timestamps in this format. 119 | // 120 | // 121 | message Timestamp { 122 | 123 | // Represents seconds of UTC time since Unix epoch 124 | // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to 125 | // 9999-12-31T23:59:59Z inclusive. 126 | int64 seconds = 1; 127 | 128 | // Non-negative fractions of a second at nanosecond resolution. Negative 129 | // second values with fractions must still have non-negative nanos values 130 | // that count forward in time. Must be from 0 to 999,999,999 131 | // inclusive. 132 | int32 nanos = 2; 133 | } 134 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/wrappers/wrappers.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Wrappers for primitive (non-message) types. These types are useful 32 | // for embedding primitives in the `google.protobuf.Any` type and for places 33 | // where we need to distinguish between the absence of a primitive 34 | // typed field and its default value. 35 | 36 | syntax = "proto3"; 37 | 38 | package google.protobuf; 39 | 40 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 41 | option cc_enable_arenas = true; 42 | option go_package = "github.com/golang/protobuf/ptypes/wrappers"; 43 | option java_package = "com.google.protobuf"; 44 | option java_outer_classname = "WrappersProto"; 45 | option java_multiple_files = true; 46 | option objc_class_prefix = "GPB"; 47 | 48 | // Wrapper message for `double`. 49 | // 50 | // The JSON representation for `DoubleValue` is JSON number. 51 | message DoubleValue { 52 | // The double value. 53 | double value = 1; 54 | } 55 | 56 | // Wrapper message for `float`. 57 | // 58 | // The JSON representation for `FloatValue` is JSON number. 59 | message FloatValue { 60 | // The float value. 61 | float value = 1; 62 | } 63 | 64 | // Wrapper message for `int64`. 65 | // 66 | // The JSON representation for `Int64Value` is JSON string. 67 | message Int64Value { 68 | // The int64 value. 69 | int64 value = 1; 70 | } 71 | 72 | // Wrapper message for `uint64`. 73 | // 74 | // The JSON representation for `UInt64Value` is JSON string. 75 | message UInt64Value { 76 | // The uint64 value. 77 | uint64 value = 1; 78 | } 79 | 80 | // Wrapper message for `int32`. 81 | // 82 | // The JSON representation for `Int32Value` is JSON number. 83 | message Int32Value { 84 | // The int32 value. 85 | int32 value = 1; 86 | } 87 | 88 | // Wrapper message for `uint32`. 89 | // 90 | // The JSON representation for `UInt32Value` is JSON number. 91 | message UInt32Value { 92 | // The uint32 value. 93 | uint32 value = 1; 94 | } 95 | 96 | // Wrapper message for `bool`. 97 | // 98 | // The JSON representation for `BoolValue` is JSON `true` and `false`. 99 | message BoolValue { 100 | // The bool value. 101 | bool value = 1; 102 | } 103 | 104 | // Wrapper message for `string`. 105 | // 106 | // The JSON representation for `StringValue` is JSON string. 107 | message StringValue { 108 | // The string value. 109 | string value = 1; 110 | } 111 | 112 | // Wrapper message for `bytes`. 113 | // 114 | // The JSON representation for `BytesValue` is JSON string. 115 | message BytesValue { 116 | // The bytes value. 117 | bytes value = 1; 118 | } 119 | -------------------------------------------------------------------------------- /vendor/vendor.json: -------------------------------------------------------------------------------- 1 | { 2 | "comment": "", 3 | "ignore": "test", 4 | "package": [ 5 | { 6 | "checksumSHA1": "mIlVmok2pb5Xiw5i4V/QUdNmbfY=", 7 | "path": "github.com/golang/protobuf", 8 | "revision": "1e59b77b52bf8e4b449a57e6f79f21226d571845", 9 | "revisionTime": "2017-11-13T18:07:20Z", 10 | "tree": true 11 | } 12 | ], 13 | "rootPath": "github.com/tmc/pqstream" 14 | } 15 | --------------------------------------------------------------------------------