diff --git a/.circleci/config.yml b/.circleci/config.yml index 65922ad..50dd7d3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,6 +12,8 @@ jobs: steps: - checkout - run: go get github.com/jstemmer/go-junit-report + - run: make install-linters + # - run: make lint - run: | mkdir -p ${TEST_RESULTS} trap "go-junit-report <${TEST_RESULTS}/go-test.out > ${TEST_RESULTS}/go-test-report.xml" EXIT diff --git a/.gitignore b/.gitignore index 746134e..cd6a5ec 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,10 @@ out/ .idea/**/sqlDataSources.xml .idea/**/dynamic.xml .idea/**/uiDesigner.xml + +# pinned tool versions +bin + +# data directories +influxdb_data +chronograf_data diff --git a/.gitmodules b/.gitmodules index 7ebeb9d..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "influx-sandbox"] - path = sandbox - url = https://github.com/influxdata/sandbox diff --git a/Gopkg.lock b/Gopkg.lock index 3e488dc..2e58d0a 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -3,42 +3,38 @@ [[projects]] branch = "master" + digest = "1:b9ed0475a5f2702704fba2d1f50dcaae426f090b05b4509ec86ddf7b0965cd5c" name = "dmitri.shuralyov.com/text/kebabcase" packages = ["."] + pruneopts = "NUT" revision = "40e40b42552a9cb37d6e98f4ad31f63ae53ea43a" -[[projects]] - name = "github.com/apache/thrift" - packages = ["lib/go/thrift"] - revision = "b2a4d4ae21c789b689dd162deb819665567f481c" - version = "0.10.0" - [[projects]] branch = "master" + digest = "1:8ecb89af7dfe3ac401bdb0c9390b134ef96a97e85f732d2b0604fb7b3977839f" name = "github.com/codahale/hdrhistogram" packages = ["."] + pruneopts = "NUT" revision = "3a0bb77429bd3a61596f5e8a3172445844342120" [[projects]] + digest = "1:ffe9824d294da03b391f44e1ae8281281b4afc1bdaa9588c9097785e3af10cec" name = "github.com/davecgh/go-spew" packages = ["spew"] - revision = "346938d642f2ec3594ed81d874461961cd0faa76" - version = "v1.1.0" + pruneopts = "NUT" + revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73" + version = "v1.1.1" [[projects]] + digest = "1:1b91ae0dc69a41d4c2ed23ea5cffb721ea63f5037ca4b81e6d6771fbb8f45129" name = "github.com/fsnotify/fsnotify" packages = ["."] - revision = "629574ca2a5df945712d3079857300b5e4da0236" - version = "v1.4.2" - -[[projects]] - branch = "master" - name = "github.com/gocarina/gocsv" - packages = ["."] - revision = "a7422e75c1caf4c04c1b413ad1cd857d3eebb85c" + pruneopts = "NUT" + revision = "c2828203cd70a50dcccfb2761f8b1f8ceef9a8e9" + version = "v1.4.7" [[projects]] - branch = "master" + digest = "1:5ae5b54d7cd695bafa92bf426b7c3d046f907260ec0fcb4fe5c368d937597c00" name = "github.com/golang/protobuf" packages = [ "proto", @@ -46,230 +42,306 @@ "ptypes", "ptypes/any", "ptypes/duration", - "ptypes/timestamp" + "ptypes/timestamp", ] - revision = "1e59b77b52bf8e4b449a57e6f79f21226d571845" + pruneopts = "NUT" + revision = "aa810b61a9c79d51363740d207bb46cf8e620ed5" + version = "v1.2.0" [[projects]] + digest = "1:c01767916c59f084bb7c41a7d5877c0f3099b1595cfa066e84ec6ad6b084dd89" name = "github.com/gorilla/context" packages = ["."] - revision = "1ea25387ff6f684839d82767c1733ff4d4d15d0a" - version = "v1.1" + pruneopts = "NUT" + revision = "08b5f424b9271eedf6f9f0ce86cb9396ed337a42" + version = "v1.1.1" [[projects]] + digest = "1:bf5cf1d53d703332e9bd8984c69784645b73a938317bf5ace9aadf20ac49379a" name = "github.com/gorilla/mux" packages = ["."] - revision = "53c1911da2b537f792e7cafcb446b05ffe33b996" - version = "v1.6.1" + pruneopts = "NUT" + revision = "e3702bed27f0d39777b0b37b664b6280e8ef8fbf" + version = "v1.6.2" [[projects]] - branch = "master" + digest = "1:11c6c696067d3127ecf332b10f89394d386d9083f82baf71f40f2da31841a009" name = "github.com/hashicorp/hcl" packages = [ ".", "hcl/ast", "hcl/parser", + "hcl/printer", "hcl/scanner", "hcl/strconv", "hcl/token", "json/parser", "json/scanner", - "json/token" + "json/token", ] - revision = "23c074d0eceb2b8a5bfdbb271ab780cde70f05a8" + pruneopts = "NUT" + revision = "8cb6e5b959231cc1119e43259c4a608f9c51a241" + version = "v1.0.0" [[projects]] + digest = "1:406338ad39ab2e37b7f4452906442a3dbf0eb3379dd1f06aafb5c07e769a5fbb" name = "github.com/inconshreveable/mousetrap" packages = ["."] + pruneopts = "NUT" revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" version = "v1.0" [[projects]] + digest = "1:18f8bac7ae238f1d06b347d40fea2a37d029e11ddeac57163182a08c780955f2" name = "github.com/influxdata/influxdb" packages = [ "client/v2", "models", - "pkg/escape" + "pkg/escape", ] - revision = "60d27e6995558f38a39e90b35a92cbac080310a3" - version = "v1.4.3" + pruneopts = "NUT" + revision = "389de31c961831de0a9f4172173337d4a6193909" + version = "v1.6.3" [[projects]] branch = "master" + digest = "1:fa28c806ef9bf20a50e560414cadb0d51652a7dca348ef2f1252cba5f7096621" name = "github.com/jackbeasley/structs" packages = ["."] + pruneopts = "NUT" revision = "fbc39dc5fbad5a8e59cd0061d2776f26623706ce" source = "github.com/jackbeasley/structs" [[projects]] + digest = "1:d244f8666a838fe6ad70ec8fe77f50ebc29fdc3331a2729ba5886bef8435d10d" name = "github.com/magiconair/properties" packages = ["."] - revision = "d419a98cdbed11a922bf76f257b7c4be79b50e73" - version = "v1.7.4" + pruneopts = "NUT" + revision = "c2353362d570a7bfa228149c62842019201cfb71" + version = "v1.8.0" [[projects]] - branch = "master" + digest = "1:a127ff6552f64ae4ff4ccc051201edba258f545221f40b4bdf1c2a7db8c0906b" name = "github.com/microcosm-cc/bluemonday" packages = ["."] - revision = "542fd4642604d0d0c26112396ce5b1a9d01eee0b" + pruneopts = "NUT" + revision = "82c7118e8ccf7403d4860175d97bb635e8e28239" + version = "v1.0.1" [[projects]] - branch = "master" + digest = "1:a4df73029d2c42fabcb6b41e327d2f87e685284ec03edf76921c267d9cfc9c23" name = "github.com/mitchellh/go-homedir" packages = ["."] - revision = "b8bc1bf767474819792c23f32d8286a45736f1c6" + pruneopts = "NUT" + revision = "ae18d6b8b3205b561c79e8e5f69bff09736185f4" + version = "v1.0.0" [[projects]] - branch = "master" + digest = "1:5fe20cfe4ef484c237cec9f947b2a6fa90bad4b8610fd014f0e4211e13d82d5d" name = "github.com/mitchellh/mapstructure" packages = ["."] - revision = "06020f85339e21b2478f756a78e295255ffa4d6a" + pruneopts = "NUT" + revision = "fa473d140ef3c6adf42d6b391fe76707f1f243c8" + version = "v1.0.0" [[projects]] + digest = "1:7da29c22bcc5c2ffb308324377dc00b5084650348c2799e573ed226d8cc9faf0" name = "github.com/opentracing/opentracing-go" packages = [ ".", "ext", - "log" + "log", ] + pruneopts = "NUT" revision = "1949ddbfd147afd4d964a9f00b24eb291e0e7c38" version = "v1.0.2" [[projects]] + digest = "1:51ea800cff51752ff68e12e04106f5887b4daec6f9356721238c28019f0b42db" name = "github.com/pelletier/go-toml" packages = ["."] - revision = "16398bac157da96aa88f98a2df640c7f32af1da2" - version = "v1.0.1" + pruneopts = "NUT" + revision = "c01d1270ff3e442a8a57cddc1c92dc1138598194" + version = "v1.2.0" + +[[projects]] + digest = "1:5cf3f025cbee5951a4ee961de067c8a89fc95a5adabead774f82822efabab121" + name = "github.com/pkg/errors" + packages = ["."] + pruneopts = "NUT" + revision = "645ef00459ed84a119197bfb8d8205042c6df63d" + version = "v0.8.0" [[projects]] + digest = "1:0028cb19b2e4c3112225cd871870f2d9cf49b9b4276531f03438a88e94be86fe" name = "github.com/pmezard/go-difflib" packages = ["difflib"] + pruneopts = "NUT" revision = "792786c7400a136282c1664665ae0a8db921c6c2" version = "v1.0.0" [[projects]] + branch = "master" + digest = "1:d9afa09f6a45f68ec50047f8187c9d273b1fbf507858a104064bb6d9eb2e2795" name = "github.com/russross/blackfriday" packages = ["."] - revision = "cadec560ec52d93835bf2f15bd794700d3a2473b" - version = "v2.0.0" + pruneopts = "NUT" + revision = "05f3235734ad95d0016f6a23902f06461fcf567a" [[projects]] - branch = "master" + digest = "1:d917313f309bda80d27274d53985bc65651f81a5b66b820749ac7f8ef061fd04" name = "github.com/sergi/go-diff" packages = ["diffmatchpatch"] + pruneopts = "NUT" revision = "1744e2970ca51c86172c8190fadad617561ed6e7" + version = "v1.0.0" [[projects]] branch = "master" + digest = "1:332245fb3f2e3d7261a14b849af99d2db4becf6ffef86dcf60c2946879831ad6" name = "github.com/shurcooL/github_flavored_markdown" packages = ["."] - revision = "28433ea3fc83827d77424782fefdcd94703366cc" + pruneopts = "NUT" + revision = "8913699a52e3aa02aa96387098e0004bb84aacf0" [[projects]] branch = "master" + digest = "1:c46a4157f74a181fab75707f9af94d77f8fcb1285d8eccd9451788586f42fe3e" name = "github.com/shurcooL/go" packages = [ "parserutil", "printerutil", "reflectfind", - "reflectsource" + "reflectsource", ] - revision = "364c5ae8518b51f5fda954762864d6f4d5c30c89" + pruneopts = "NUT" + revision = "9e1955d9fb6e1ee2345ba1f5e71669263e719e27" [[projects]] branch = "master" + digest = "1:a878e54a77606c6e347e5eca41f87903629464f477602565bc2bd9add6277fbb" name = "github.com/shurcooL/go-goon" packages = ["."] + pruneopts = "NUT" revision = "37c2f522c041b74919a9e5e3a6c5c47eb34730a5" [[projects]] branch = "master" + digest = "1:23a0fdf4f939b35ca0f40530d39671b2fdd503e978a9783b89b059c7e9ff4889" name = "github.com/shurcooL/graphql" packages = ["ident"] - revision = "8d3d310716dedf6f4945d11299e54a55bbdc6ff1" + pruneopts = "NUT" + revision = "365899397c9ad12805631fe4c9b2a64be9d74818" [[projects]] branch = "master" + digest = "1:37d9586adce8284ccfada415cdd7976f666f7600a1d43ed923c1bfbb98226719" name = "github.com/shurcooL/highlight_diff" packages = ["."] + pruneopts = "NUT" revision = "09bb4053de1b1d872a9f25dc21378fa71dca4e4e" [[projects]] branch = "master" + digest = "1:d94b6fe6e7f1768a4b5ffcd855ba28f0c558ad7ec530b0e4dca66482bcd46f7d" name = "github.com/shurcooL/highlight_go" packages = ["."] + pruneopts = "NUT" revision = "78fb10f4a5f89e812a5e26ab723b954a51226086" [[projects]] branch = "master" - name = "github.com/shurcooL/octiconssvg" + digest = "1:9e295e2f3a38a737a1316f4fb2c8d8c39744e58a81ada3cc83426e0b2bf0de26" + name = "github.com/shurcooL/octicon" packages = ["."] - revision = "91d14858bf8188ba5143d67a3a677ea559000b0a" + pruneopts = "NUT" + revision = "c42b0e3b24d96976ecac81ef691662777b39ef64" [[projects]] branch = "master" + digest = "1:debf1a119378d059b68925f1796851b6855bfc2f55419a50d634ecce3eabd8e8" name = "github.com/shurcooL/sanitized_anchor_name" packages = ["."] + pruneopts = "NUT" revision = "86672fcb3f950f35f2e675df2240550f2a50762f" [[projects]] branch = "master" + digest = "1:8b7ebf4dccd5fdad5e59de1f00045a35ff7a3e7f0ef9fd8e59ba0f0c389dfd1a" name = "github.com/sourcegraph/annotate" packages = ["."] + pruneopts = "NUT" revision = "f4cad6c6324d3f584e1743d8b3e0e017a5f3a636" [[projects]] branch = "master" + digest = "1:71cbd1bebcbe8b215d26b85b5e3977ca4a022962d99866a24a987a866bf3e7ed" name = "github.com/sourcegraph/syntaxhighlight" packages = ["."] + pruneopts = "NUT" revision = "bd320f5d308e1a3c4314c678d8227a0d72574ae7" [[projects]] + digest = "1:330e9062b308ac597e28485699c02223bd052437a6eed32a173c9227dcb9d95a" name = "github.com/spf13/afero" packages = [ ".", - "mem" + "mem", ] - revision = "ec3a3111d1e1bdff38a61e09d5a5f5e974905611" - version = "v1.0.1" + pruneopts = "NUT" + revision = "d40851caa0d747393da1ffb28f7f9d8b4eeffebd" + version = "v1.1.2" [[projects]] + digest = "1:3fa7947ca83b98ae553590d993886e845a4bff19b7b007e869c6e0dd3b9da9cd" name = "github.com/spf13/cast" packages = ["."] - revision = "acbeb36b902d72a7a4c18e8f3241075e7ab763e4" - version = "v1.1.0" + pruneopts = "NUT" + revision = "8965335b8c7107321228e3e3702cab9832751bac" + version = "v1.2.0" [[projects]] + digest = "1:343d44e06621142ab09ae0c76c1799104cdfddd3ffb445d78b1adf8dc3ffaf3d" name = "github.com/spf13/cobra" packages = ["."] - revision = "7b2c5ac9fc04fc5efafb60700713d4fa609b777b" - version = "v0.0.1" + pruneopts = "NUT" + revision = "ef82de70bb3f60c65fb8eebacbb2d122ef517385" + version = "v0.0.3" [[projects]] - branch = "master" + digest = "1:f29f83301ed096daed24a90f4af591b7560cb14b9cc3e1827abbf04db7269ab5" name = "github.com/spf13/jwalterweatherman" packages = ["."] - revision = "12bd96e66386c1960ab0f74ced1362f66f552f7b" + pruneopts = "NUT" + revision = "4a4406e478ca629068e7768fc33f3f044173c0a6" + version = "v1.0.0" [[projects]] + digest = "1:e3707aeaccd2adc89eba6c062fec72116fe1fc1ba71097da85b4d8ae1668a675" name = "github.com/spf13/pflag" packages = ["."] - revision = "e57e3eeb33f795204c1ca35f56c44f83227c6e66" - version = "v1.0.0" + pruneopts = "NUT" + revision = "9a97c102cda95a86cec2345a6f09f55a939babf5" + version = "v1.0.2" [[projects]] + digest = "1:e37ec5ec59746bb63bda84331b5ff892e1a301648c1736364e78ec5df468ad72" name = "github.com/spf13/viper" packages = ["."] - revision = "25b30aa063fc18e48662b86996252eabdcf2f0c7" - version = "v1.0.0" + pruneopts = "NUT" + revision = "8fb642006536c8d3760c99d4fa2389f5e2205631" + version = "v1.2.0" [[projects]] + digest = "1:bacb8b590716ab7c33f2277240972c9582d389593ee8d66fc10074e0508b8126" name = "github.com/stretchr/testify" packages = ["assert"] - revision = "69483b4bd14f5845b5a1e55bca19e954e827f1d0" - version = "v1.1.4" + pruneopts = "NUT" + revision = "f35b8ab0b5a2cef36673838d662e249dd9c94686" + version = "v1.2.2" [[projects]] + digest = "1:3d48c38e0eca8c66df62379c5ae7a83fb5cd839b94f241354c07ba077da7bc45" name = "github.com/uber/jaeger-client-go" packages = [ ".", @@ -277,48 +349,58 @@ "internal/baggage", "internal/baggage/remote", "internal/spanlog", + "internal/throttler", + "internal/throttler/remote", "log", "rpcmetrics", + "thrift", "thrift-gen/agent", "thrift-gen/baggage", "thrift-gen/jaeger", "thrift-gen/sampling", "thrift-gen/zipkincore", - "utils" + "utils", ] - revision = "3ac96c6e679cb60a74589b0d0aa7c70a906183f7" - version = "v2.11.2" + pruneopts = "NUT" + revision = "b043381d944715b469fd6b37addfd30145ca1758" + version = "v2.14.0" [[projects]] + digest = "1:0f09db8429e19d57c8346ad76fbbc679341fa86073d3b8fb5ac919f0357d8f4c" name = "github.com/uber/jaeger-lib" packages = ["metrics"] - revision = "7f95f4f7e80028096410abddaae2556e4c61b59f" - version = "v1.3.1" + pruneopts = "NUT" + revision = "ed3a127ec5fef7ae9ea95b01b542c47fbd999ce5" + version = "v1.5.0" [[projects]] branch = "master" + digest = "1:78d42b4865d3429cbc8daa29434c806c761ae4c553233e31a3848fbbd6a2ad0a" name = "golang.org/x/net" packages = [ "context", "html", "html/atom", + "http/httpguts", "http2", "http2/hpack", "idna", "internal/timeseries", - "lex/httplex", - "trace" + "trace", ] - revision = "d866cfc389cec985d6fda2859936a575a55a3ab6" + pruneopts = "NUT" + revision = "26e67e76b6c3f6ce91f7c52def5af501b4e0f3a2" [[projects]] branch = "master" + digest = "1:e87594335f7fc5df850c2673c46896af42963d497be3e2a358d43e5b1163e852" name = "golang.org/x/sys" packages = ["unix"] - revision = "2493af8e3bc76234993370d82120c7e15ed4c95b" + pruneopts = "NUT" + revision = "ee1b12c67af419cf5a9be3bdbeea7fc1c5f32f11" [[projects]] - branch = "master" + digest = "1:e7071ed636b5422cc51c0e3a6cebc229d6c9fffc528814b519a980641422d619" name = "golang.org/x/text" packages = [ "collate", @@ -334,23 +416,30 @@ "unicode/bidi", "unicode/cldr", "unicode/norm", - "unicode/rangetable" + "unicode/rangetable", ] - revision = "e19ae1496984b1c655b8044a65c0300a3c878dd3" + pruneopts = "NUT" + revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0" + version = "v0.3.0" [[projects]] branch = "master" + digest = "1:c9e7a4b4d47c0ed205d257648b0e5b0440880cb728506e318f8ac7cd36270bc4" name = "golang.org/x/time" packages = ["rate"] - revision = "6dc17368e09b0e8634d71cac8168d853e869a0c7" + pruneopts = "NUT" + revision = "fbb02b2291d28baffd63558aa44b4b56f178d650" [[projects]] branch = "master" + digest = "1:56b0bca90b7e5d1facf5fbdacba23e4e0ce069d25381b8e2f70ef1e7ebfb9c1a" name = "google.golang.org/genproto" packages = ["googleapis/rpc/status"] - revision = "2b5a72b8730b0b16380010cfe5286c42108d88e7" + pruneopts = "NUT" + revision = "c3f76f3b92d1ffa4c58a9ff842a58b8877655e0f" [[projects]] + digest = "1:88e363aac7a4308ba0aa1fa3c77abee900bbc7d0131417f0a7adde0a01371fa3" name = "google.golang.org/grpc" packages = [ ".", @@ -362,9 +451,13 @@ "credentials", "encoding", "encoding/proto", - "grpclb/grpc_lb_v1/messages", "grpclog", "internal", + "internal/backoff", + "internal/channelz", + "internal/envconfig", + "internal/grpcrand", + "internal/transport", "keepalive", "metadata", "naming", @@ -377,20 +470,44 @@ "stats", "status", "tap", - "transport" ] - revision = "8e4536a86ab602859c20df5ebfd0bd4228d08655" - version = "v1.10.0" + pruneopts = "NUT" + revision = "8dea3dc473e90c8179e519d91302d0597c0ca1d1" + version = "v1.15.0" [[projects]] - branch = "v2" + digest = "1:7c95b35057a0ff2e19f707173cc1a947fa43a6eb5c4d300d196ece0334046082" name = "gopkg.in/yaml.v2" packages = ["."] - revision = "1244d3ce02e3e1c16820ada0bae506b6c479f106" + pruneopts = "NUT" + revision = "5420a8b6744d3b0345ab293f6fcba19c978f1183" + version = "v2.2.1" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "f7681b2cc0cb05335a4248b9ac2666601b6b815c6d3185a333dc5a73744c2212" + input-imports = [ + "github.com/golang/protobuf/proto", + "github.com/gorilla/mux", + "github.com/influxdata/influxdb/client/v2", + "github.com/jackbeasley/structs", + "github.com/mitchellh/go-homedir", + "github.com/opentracing/opentracing-go", + "github.com/opentracing/opentracing-go/ext", + "github.com/opentracing/opentracing-go/log", + "github.com/russross/blackfriday", + "github.com/shurcooL/github_flavored_markdown", + "github.com/spf13/cobra", + "github.com/spf13/viper", + "github.com/stretchr/testify/assert", + "github.com/uber/jaeger-client-go", + "github.com/uber/jaeger-client-go/config", + "github.com/uber/jaeger-client-go/log", + "github.com/uber/jaeger-lib/metrics", + "golang.org/x/net/context", + "golang.org/x/time/rate", + "google.golang.org/grpc", + "google.golang.org/grpc/reflection", + ] solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index a6b10d3..8b47226 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -1,25 +1,5 @@ - -# Gopkg.toml example -# -# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md -# for detailed Gopkg.toml documentation. -# -# required = ["github.com/user/thing/cmd/thing"] -# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] -# -# [[constraint]] -# name = "github.com/user/project" -# version = "1.0.0" -# -# [[constraint]] -# name = "github.com/user/project2" -# branch = "dev" -# source = "github.com/myfork/project2" -# -# [[override]] -# name = "github.com/x/y" -# version = "2.4.0" ignored = ["github.com/sscp/telemetry/sandbox"] +required = ["github.com/russross/blackfriday"] [prune] non-go = true @@ -31,3 +11,6 @@ ignored = ["github.com/sscp/telemetry/sandbox"] branch = "master" source = "github.com/jackbeasley/structs" +[[constraint]] + branch = "master" + name = "github.com/russross/blackfriday" diff --git a/Makefile b/Makefile index b78d0a1..b07d7c7 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,22 @@ BINARY_NAME=telemetry # Installs tools to generate code/work with the repo .PHONY: install-tools -install-tools: +install-tools: install-code-gen install-linters + +.PHONY: install-code-gen +install-code-gen: go get -u github.com/golang/protobuf/{proto,protoc-gen-go} go get -u github.com/favadi/protoc-go-inject-tag go get -u google.golang.org/grpc +.PHONY: install-linters +install-linters: + curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b ./bin v1.10.2 + +.PHONY: lint +lint: + ./bin/golangci-lint run ./... + .PHONY: generate generate: go generate ./... diff --git a/blog/blog_test.go b/blog/blog_test.go index 930786a..03795e6 100644 --- a/blog/blog_test.go +++ b/blog/blog_test.go @@ -6,6 +6,8 @@ import ( "io/ioutil" "reflect" "testing" + + "github.com/stretchr/testify/assert" ) type BlogTest struct { @@ -25,7 +27,8 @@ func TestBlog(t *testing.T) { writer := NewWriter(buf) for _, s := range blogTest.Packets { - writer.Write(s) + _, err := writer.Write(s) + assert.NoError(t, err) } bufRead := bytes.NewReader(buf.Bytes()) @@ -51,7 +54,8 @@ func TestBlog(t *testing.T) { } // Reset reader - bufRead.Seek(0, io.SeekStart) + _, err := bufRead.Seek(0, io.SeekStart) + assert.NoError(t, err) for i := 0; i < len(blogTest.Packets)+1; i++ { packet, err := rdr.NextPacket() @@ -78,7 +82,8 @@ func TestBlogReadZero(t *testing.T) { writer := NewWriter(buf) for _, s := range BlogTests[0].Packets { - writer.Write(s) + _, err := writer.Write(s) + assert.NoError(t, err) } bufRead := bytes.NewReader(buf.Bytes()) diff --git a/cars/cars.go b/cars/cars.go new file mode 100644 index 0000000..4f21d30 --- /dev/null +++ b/cars/cars.go @@ -0,0 +1,35 @@ +package cars + +import ( + "context" + + "github.com/sscp/telemetry/cars/sundae" + + "github.com/sscp/telemetry/events" +) + +//go:generate enumer -type=Car -json -text -output=gen_cars.go + +// Car refers to a car-specific deserialization routine. +type Car int + +const ( + // Sundae is sscp's 2017 WSC car + Sundae Car = iota +) + +func stubCarSupport(ctx context.Context, event events.RawEvent) (events.DataEvent, error) { + return events.DataEvent{ + EventMeta: event.EventMeta, + Data: make(map[string]interface{}, 0), + }, nil +} + +func GetCarDeserializer(car Car) func(ctx context.Context, rawEvent events.RawEvent) (events.DataEvent, error) { + switch car { + case Sundae: + return sundae.Deserialize + default: + return stubCarSupport + } +} diff --git a/cars/gen_cars.go b/cars/gen_cars.go new file mode 100644 index 0000000..306f41e --- /dev/null +++ b/cars/gen_cars.go @@ -0,0 +1,78 @@ +// Code generated by "enumer -type=Car -json -text -output=gen_cars.go"; DO NOT EDIT. + +package cars + +import ( + "encoding/json" + "fmt" +) + +const _CarName = "Sundae" + +var _CarIndex = [...]uint8{0, 6} + +func (i Car) String() string { + if i < 0 || i >= Car(len(_CarIndex)-1) { + return fmt.Sprintf("Car(%d)", i) + } + return _CarName[_CarIndex[i]:_CarIndex[i+1]] +} + +var _CarValues = []Car{0} + +var _CarNameToValueMap = map[string]Car{ + _CarName[0:6]: 0, +} + +// CarString retrieves an enum value from the enum constants string name. +// Throws an error if the param is not part of the enum. +func CarString(s string) (Car, error) { + if val, ok := _CarNameToValueMap[s]; ok { + return val, nil + } + return 0, fmt.Errorf("%s does not belong to Car values", s) +} + +// CarValues returns all values of the enum +func CarValues() []Car { + return _CarValues +} + +// IsACar returns "true" if the value is listed in the enum definition. "false" otherwise +func (i Car) IsACar() bool { + for _, v := range _CarValues { + if i == v { + return true + } + } + return false +} + +// MarshalJSON implements the json.Marshaler interface for Car +func (i Car) MarshalJSON() ([]byte, error) { + return json.Marshal(i.String()) +} + +// UnmarshalJSON implements the json.Unmarshaler interface for Car +func (i *Car) UnmarshalJSON(data []byte) error { + var s string + if err := json.Unmarshal(data, &s); err != nil { + return fmt.Errorf("Car should be a string, got %s", data) + } + + var err error + *i, err = CarString(s) + return err +} + +// MarshalText implements the encoding.TextMarshaler interface for Car +func (i Car) MarshalText() ([]byte, error) { + return []byte(i.String()), nil +} + +// UnmarshalText implements the encoding.TextUnmarshaler interface for Car +func (i *Car) UnmarshalText(text []byte) error { + var err error + *i, err = CarString(string(text)) + return err +} diff --git a/collector/sundae/deserialize.go b/cars/sundae/deserialize.go similarity index 52% rename from collector/sundae/deserialize.go rename to cars/sundae/deserialize.go index 9e777fe..65dc926 100644 --- a/collector/sundae/deserialize.go +++ b/cars/sundae/deserialize.go @@ -5,15 +5,19 @@ import ( "fmt" "math" - "github.com/sscp/telemetry/collector/contextkeys" - collectorproto "github.com/sscp/telemetry/collector/internalproto" - "github.com/sscp/telemetry/log" - "github.com/golang/protobuf/proto" //"github.com/opentracing/opentracing-go" + + // Fork of https://github.com/fatih/structs/ that adds an "indirect" + // option to dereference pointers to get values, not pointers in map + "github.com/jackbeasley/structs" + + "github.com/sscp/telemetry/events" + "github.com/sscp/telemetry/log" ) //go:generate protoc -I=. --go_out=. ./sundae.proto +//go:generate protoc-go-inject-tag -input=./sundae.pb.go const tryToHandlePadding = false @@ -181,194 +185,20 @@ func deserializeProto(ctx context.Context, packet []byte, handlePadding bool) (* } // Deserialize unpacks a sundae protobuf, verifies that the fields are valid, then derives any values as needed -func Deserialize(ctx context.Context, packet []byte) (*collectorproto.DataMessage, error) { +func Deserialize(ctx context.Context, rawEvent events.RawEvent) (events.DataEvent, error) { - dMsg, err := deserializeProto(ctx, packet, tryToHandlePadding) + dMsg, err := deserializeProto(ctx, rawEvent.Data, tryToHandlePadding) if err != nil { log.Error(ctx, err, "Could not deserialize protobuf") - return nil, err + return events.DataEvent{}, err } // Verify the the proto and clean up data VerifyFloatValues(ctx, dMsg) - // Unpack the receivedTime from the context and add it to the protobuf - t, ok := contextkeys.RecievedTimeFromContext(ctx) - var timeCollected *int64 - if ok { - receivedTimeNanos := t.UnixNano() - timeCollected = &receivedTimeNanos - } else { - timeCollected = nil - } + dataFields := structs.Map(dMsg) - // Transfer to internal collector proto, derriving values as needed - // Currently quite boring as no values are derrived - collectorDm := collectorproto.DataMessage{ - RegenEnabled: dMsg.RegenEnabled, - RegenCommand: dMsg.RegenCommand, - BatteryPower: dMsg.BatteryPower, - ArrayPower: dMsg.ArrayPower, - ReverseOn: dMsg.ReverseOn, - LowVoltPower: dMsg.LowVoltPower, - HazardLightsOn: dMsg.HazardLightsOn, - BatteryVoltage: dMsg.BatteryVoltage, - Ltc6804Badpec: dMsg.Ltc6804Badpec, - BmsState: dMsg.BmsState, - ChargeEnabled: dMsg.ChargeEnabled, - DischargeEnabled: dMsg.DischargeEnabled, - HighsideContactorOn: dMsg.HighsideContactorOn, - LowsideContactorOn: dMsg.LowsideContactorOn, - PrechargeOn: dMsg.PrechargeOn, - LowVoltBusOn: dMsg.LowVoltBusOn, - BatteryTemp_1: dMsg.BatteryTemp_1, - BatteryTemp_2: dMsg.BatteryTemp_2, - BatteryTemp_3: dMsg.BatteryTemp_3, - BatteryTemp_4: dMsg.BatteryTemp_4, - BatteryTemp_5: dMsg.BatteryTemp_5, - BatteryTemp_6: dMsg.BatteryTemp_6, - BmsPrechargeBatteryAdc: dMsg.BmsPrechargeBatteryAdc, - BmsPrechargeCarAdc: dMsg.BmsPrechargeCarAdc, - LowVoltOutputCurrent: dMsg.LowVoltOutputCurrent, - BatteryCurrent: dMsg.BatteryCurrent, - RightMotorControllerPower: dMsg.RightMotorControllerPower, - AmpHours: dMsg.AmpHours, - HeadLightsOn: dMsg.HeadLightsOn, - BrakeLightsOn: dMsg.BrakeLightsOn, - RightBlinkerOn: dMsg.RightBlinkerOn, - LeftBlinkerOn: dMsg.LeftBlinkerOn, - BrakePressed: dMsg.BrakePressed, - ThrottlePressed: dMsg.ThrottlePressed, - DriveMode: dMsg.DriveMode, - MotorControllerEnabled: dMsg.MotorControllerEnabled, - MotorControllerSpeed: dMsg.MotorControllerSpeed, - MotorControllerRpm: dMsg.MotorControllerRpm, - AvgOdometer: dMsg.AvgOdometer, - LeftMotorTemp: dMsg.LeftMotorTemp, - RightMotorTemp: dMsg.RightMotorTemp, - LeftMotorControllerTemp: dMsg.LeftMotorControllerTemp, - RightMotorControllerTemp: dMsg.RightMotorControllerTemp, - LeftMotorControllerAlive: dMsg.LeftMotorControllerAlive, - RightMotorControllerAlive: dMsg.RightMotorControllerAlive, - LeftMotorControllerCurrent: dMsg.LeftMotorControllerCurrent, - RightMotorControllerCurrent: dMsg.RightMotorControllerCurrent, - MotorControllerCurrentDiff: dMsg.MotorControllerCurrentDiff, - LeftMotorControllerError: dMsg.LeftMotorControllerError, - RightMotorControllerError: dMsg.RightMotorControllerError, - LeftMotorControllerLimit: dMsg.LeftMotorControllerLimit, - RightMotorControllerLimit: dMsg.RightMotorControllerLimit, - LeftMotorControllerRxErrorCount: dMsg.LeftMotorControllerRxErrorCount, - RightMotorControllerRxErrorCount: dMsg.RightMotorControllerRxErrorCount, - LeftMotorControllerTxErrorCount: dMsg.LeftMotorControllerTxErrorCount, - RightMotorControllerTxErrorCount: dMsg.RightMotorControllerTxErrorCount, - LeftMotorControllerBusVoltage: dMsg.LeftMotorControllerBusVoltage, - RightMotorControllerBusVoltage: dMsg.RightMotorControllerBusVoltage, - LeftMotorController_15VVoltage: dMsg.LeftMotorController_15VVoltage, - RightMotorController_15VVoltage: dMsg.RightMotorController_15VVoltage, - LeftMotorController_3V3Voltage: dMsg.LeftMotorController_3V3Voltage, - RightMotorController_3V3Voltage: dMsg.RightMotorController_3V3Voltage, - LeftMotorController_1V9Voltage: dMsg.LeftMotorController_1V9Voltage, - RightMotorController_1V9Voltage: dMsg.RightMotorController_1V9Voltage, - LeftMotorControllerDspTemp: dMsg.LeftMotorControllerDspTemp, - RightMotorControllerDspTemp: dMsg.RightMotorControllerDspTemp, - LeftMotorControllerPhaseCurrent: dMsg.LeftMotorControllerPhaseCurrent, - RightMotorControllerPhaseCurrent: dMsg.RightMotorControllerPhaseCurrent, - LeftMotorRpmCommand: dMsg.LeftMotorRpmCommand, - RightMotorRpmCommand: dMsg.RightMotorRpmCommand, - LeftMotorCurrentCommand: dMsg.LeftMotorCurrentCommand, - RightMotorCurrentCommand: dMsg.RightMotorCurrentCommand, - GpsTime: dMsg.GpsTime, - GpsLatitude: dMsg.GpsLatitude, - GpsLongitude: dMsg.GpsLongitude, - GpsSpeed: dMsg.GpsSpeed, - GpsAltitude: dMsg.GpsAltitude, - GpsBearing: dMsg.GpsBearing, - LedState: dMsg.LedState, - MpptArrayPower: dMsg.MpptArrayPower, - Mppt_A0VoltIn: dMsg.Mppt_A0VoltIn, - Mppt_A0VoltOut: dMsg.Mppt_A0VoltOut, - Mppt_A0Current: dMsg.Mppt_A0Current, - Mppt_A0Temp: dMsg.Mppt_A0Temp, - Mppt_A1VoltIn: dMsg.Mppt_A1VoltIn, - Mppt_A1VoltOut: dMsg.Mppt_A1VoltOut, - Mppt_A1Current: dMsg.Mppt_A1Current, - Mppt_A1Temp: dMsg.Mppt_A1Temp, - Mppt_B0VoltIn: dMsg.Mppt_B0VoltIn, - Mppt_B0VoltOut: dMsg.Mppt_B0VoltOut, - Mppt_B0Current: dMsg.Mppt_B0Current, - Mppt_B0Temp: dMsg.Mppt_B0Temp, - Mppt_B1VoltIn: dMsg.Mppt_B1VoltIn, - Mppt_B1VoltOut: dMsg.Mppt_B1VoltOut, - Mppt_B1Current: dMsg.Mppt_B1Current, - Mppt_B1Temp: dMsg.Mppt_B1Temp, - Mppt_C0VoltIn: dMsg.Mppt_C0VoltIn, - Mppt_C0VoltOut: dMsg.Mppt_C0VoltOut, - Mppt_C0Current: dMsg.Mppt_C0Current, - Mppt_C0Temp: dMsg.Mppt_C0Temp, - Mppt_C1VoltIn: dMsg.Mppt_C1VoltIn, - Mppt_C1VoltOut: dMsg.Mppt_C1VoltOut, - Mppt_C1Current: dMsg.Mppt_C1Current, - Mppt_C1Temp: dMsg.Mppt_C1Temp, - Mppt_D0VoltIn: dMsg.Mppt_D0VoltIn, - Mppt_D0VoltOut: dMsg.Mppt_D0VoltOut, - Mppt_D0Current: dMsg.Mppt_D0Current, - Mppt_D0Temp: dMsg.Mppt_D0Temp, - Mppt_D1VoltIn: dMsg.Mppt_D1VoltIn, - Mppt_D1VoltOut: dMsg.Mppt_D1VoltOut, - Mppt_D1Current: dMsg.Mppt_D1Current, - Mppt_D1Temp: dMsg.Mppt_D1Temp, - CellVolt_1: dMsg.CellVolt_1, - CellVolt_2: dMsg.CellVolt_2, - CellVolt_3: dMsg.CellVolt_3, - CellVolt_4: dMsg.CellVolt_4, - CellVolt_5: dMsg.CellVolt_5, - CellVolt_6: dMsg.CellVolt_6, - CellVolt_7: dMsg.CellVolt_7, - CellVolt_8: dMsg.CellVolt_8, - CellVolt_9: dMsg.CellVolt_9, - CellVolt_10: dMsg.CellVolt_10, - CellVolt_11: dMsg.CellVolt_11, - CellVolt_12: dMsg.CellVolt_12, - CellVolt_13: dMsg.CellVolt_13, - CellVolt_14: dMsg.CellVolt_14, - CellVolt_15: dMsg.CellVolt_15, - CellVolt_16: dMsg.CellVolt_16, - CellVolt_17: dMsg.CellVolt_17, - CellVolt_18: dMsg.CellVolt_18, - CellVolt_19: dMsg.CellVolt_19, - CellVolt_20: dMsg.CellVolt_20, - CellVolt_21: dMsg.CellVolt_21, - CellVolt_22: dMsg.CellVolt_22, - CellVolt_23: dMsg.CellVolt_23, - CellVolt_24: dMsg.CellVolt_24, - CellVolt_25: dMsg.CellVolt_25, - CellVolt_26: dMsg.CellVolt_26, - CellVolt_27: dMsg.CellVolt_27, - CellVolt_28: dMsg.CellVolt_28, - CellVolt_29: dMsg.CellVolt_29, - CellVolt_30: dMsg.CellVolt_30, - CellVolt_31: dMsg.CellVolt_31, - CellVoltMin: dMsg.CellVoltMin, - CellVoltMax: dMsg.CellVoltMax, - CellVoltAvg: dMsg.CellVoltAvg, - CellVoltDiff: dMsg.CellVoltDiff, - PowerSaveOn: dMsg.PowerSaveOn, - RearviewOn: dMsg.RearviewOn, - MicEnabled: dMsg.MicEnabled, - ImuTemp: dMsg.ImuTemp, - ImuMagnetX: dMsg.ImuMagnetX, - ImuMagnetY: dMsg.ImuMagnetY, - ImuMagnetZ: dMsg.ImuMagnetZ, - ImuGyroX: dMsg.ImuGyroX, - ImuGyroY: dMsg.ImuGyroY, - ImuGyroZ: dMsg.ImuGyroZ, - ImuAccelX: dMsg.ImuAccelX, - ImuAccelY: dMsg.ImuAccelY, - ImuAccelZ: dMsg.ImuAccelZ, - BmsLeftMotorControllerCurrent: dMsg.BmsLeftMotorControllerCurrent, - BmsRightMotorControllerCurrent: dMsg.BmsRightMotorControllerCurrent, - BmsMotorControllerCurrentSum: dMsg.BmsMotorControllerCurrentSum, - PacketsPerSec: dMsg.PacketsPerSec, - TimeCollected: timeCollected, - } - return &collectorDm, nil + return events.DataEvent{ + EventMeta: rawEvent.EventMeta, + Data: dataFields, + }, nil } diff --git a/collector/sundae/deserialize_test.go b/cars/sundae/deserialize_test.go similarity index 92% rename from collector/sundae/deserialize_test.go rename to cars/sundae/deserialize_test.go index 0b175d2..185aee1 100644 --- a/collector/sundae/deserialize_test.go +++ b/cars/sundae/deserialize_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/sscp/telemetry/blog" + "github.com/sscp/telemetry/events" ) func runTestOnDataFile(t *testing.T, filename string) { @@ -29,7 +30,7 @@ func runTestOnDataFile(t *testing.T, filename string) { t.Errorf("Error reading blog file: %v", err) } ctx := context.Background() - _, err = Deserialize(ctx, packet) + _, err = Deserialize(ctx, events.NewRawEventNow(packet)) if err != nil { t.Errorf("Could not deserialize packet: %v", err) } diff --git a/collector/internalproto/data_message.pb.go b/cars/sundae/sundae.pb.go similarity index 57% rename from collector/internalproto/data_message.pb.go rename to cars/sundae/sundae.pb.go index 52ab494..7149487 100644 --- a/collector/internalproto/data_message.pb.go +++ b/cars/sundae/sundae.pb.go @@ -1,16 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. -// source: data_message.proto +// source: sundae.proto -/* -Package data_message is a generated protocol buffer package. - -It is generated from these files: - data_message.proto - -It has these top-level messages: - DataMessage -*/ -package data_message +package sundae import proto "github.com/golang/protobuf/proto" import fmt "fmt" @@ -27,1696 +18,1707 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package -type DataMessage struct { +type SundaeDataMessage struct { // @inject_tag: structs:"regen_enabled,indirect" csv:"regen_enabled" - RegenEnabled *uint32 `protobuf:"varint,1,opt,name=regen_enabled,json=regenEnabled" json:"regen_enabled,omitempty" structs:"regen_enabled,indirect" csv:"regen_enabled" structs:"regen_enabled,indirect" csv:"regen_enabled"` + RegenEnabled *uint32 `protobuf:"varint,1,opt,name=regen_enabled,json=regenEnabled" json:"regen_enabled,omitempty" structs:"regen_enabled,indirect" csv:"regen_enabled"` // @inject_tag: structs:"regen_command,indirect" csv:"regen_command" - RegenCommand *uint32 `protobuf:"varint,2,opt,name=regen_command,json=regenCommand" json:"regen_command,omitempty" structs:"regen_command,indirect" csv:"regen_command" structs:"regen_command,indirect" csv:"regen_command"` + RegenCommand *uint32 `protobuf:"varint,2,opt,name=regen_command,json=regenCommand" json:"regen_command,omitempty" structs:"regen_command,indirect" csv:"regen_command"` // @inject_tag: structs:"battery_power,indirect" csv:"battery_power" - BatteryPower *uint32 `protobuf:"varint,3,opt,name=battery_power,json=batteryPower" json:"battery_power,omitempty" structs:"battery_power,indirect" csv:"battery_power" structs:"battery_power,indirect" csv:"battery_power"` + BatteryPower *uint32 `protobuf:"varint,3,opt,name=battery_power,json=batteryPower" json:"battery_power,omitempty" structs:"battery_power,indirect" csv:"battery_power"` // @inject_tag: structs:"array_power,indirect" csv:"array_power" - ArrayPower *float32 `protobuf:"fixed32,4,opt,name=array_power,json=arrayPower" json:"array_power,omitempty" structs:"array_power,indirect" csv:"array_power" structs:"array_power,indirect" csv:"array_power"` + ArrayPower *float32 `protobuf:"fixed32,4,opt,name=array_power,json=arrayPower" json:"array_power,omitempty" structs:"array_power,indirect" csv:"array_power"` // @inject_tag: structs:"reverse_on,indirect" csv:"reverse_on" - ReverseOn *uint32 `protobuf:"varint,5,opt,name=reverse_on,json=reverseOn" json:"reverse_on,omitempty" structs:"reverse_on,indirect" csv:"reverse_on" structs:"reverse_on,indirect" csv:"reverse_on"` + ReverseOn *uint32 `protobuf:"varint,5,opt,name=reverse_on,json=reverseOn" json:"reverse_on,omitempty" structs:"reverse_on,indirect" csv:"reverse_on"` // @inject_tag: structs:"low_volt_power,indirect" csv:"low_volt_power" - LowVoltPower *float32 `protobuf:"fixed32,6,opt,name=low_volt_power,json=lowVoltPower" json:"low_volt_power,omitempty" structs:"low_volt_power,indirect" csv:"low_volt_power" structs:"low_volt_power,indirect" csv:"low_volt_power"` + LowVoltPower *float32 `protobuf:"fixed32,6,opt,name=low_volt_power,json=lowVoltPower" json:"low_volt_power,omitempty" structs:"low_volt_power,indirect" csv:"low_volt_power"` // @inject_tag: structs:"cell_read_error,indirect" csv:"cell_read_error" - CellReadError *int32 `protobuf:"varint,7,opt,name=cell_read_error,json=cellReadError" json:"cell_read_error,omitempty" structs:"cell_read_error,indirect" csv:"cell_read_error" structs:"cell_read_error,indirect" csv:"cell_read_error"` + CellReadError *int32 `protobuf:"varint,7,opt,name=cell_read_error,json=cellReadError" json:"cell_read_error,omitempty" structs:"cell_read_error,indirect" csv:"cell_read_error"` // @inject_tag: structs:"cell_bleed,indirect" csv:"cell_bleed" - CellBleed *uint32 `protobuf:"varint,8,opt,name=cell_bleed,json=cellBleed" json:"cell_bleed,omitempty" structs:"cell_bleed,indirect" csv:"cell_bleed" structs:"cell_bleed,indirect" csv:"cell_bleed"` + CellBleed *uint32 `protobuf:"varint,8,opt,name=cell_bleed,json=cellBleed" json:"cell_bleed,omitempty" structs:"cell_bleed,indirect" csv:"cell_bleed"` // @inject_tag: structs:"cruise_speed,indirect" csv:"cruise_speed" - CruiseSpeed *float32 `protobuf:"fixed32,9,opt,name=cruise_speed,json=cruiseSpeed" json:"cruise_speed,omitempty" structs:"cruise_speed,indirect" csv:"cruise_speed" structs:"cruise_speed,indirect" csv:"cruise_speed"` + CruiseSpeed *float32 `protobuf:"fixed32,9,opt,name=cruise_speed,json=cruiseSpeed" json:"cruise_speed,omitempty" structs:"cruise_speed,indirect" csv:"cruise_speed"` // @inject_tag: structs:"hazard_lights_on,indirect" csv:"hazard_lights_on" - HazardLightsOn *int32 `protobuf:"varint,10,opt,name=hazard_lights_on,json=hazardLightsOn" json:"hazard_lights_on,omitempty" structs:"hazard_lights_on,indirect" csv:"hazard_lights_on" structs:"hazard_lights_on,indirect" csv:"hazard_lights_on"` + HazardLightsOn *int32 `protobuf:"varint,10,opt,name=hazard_lights_on,json=hazardLightsOn" json:"hazard_lights_on,omitempty" structs:"hazard_lights_on,indirect" csv:"hazard_lights_on"` // @inject_tag: structs:"battery_voltage,indirect" csv:"battery_voltage" - BatteryVoltage *float32 `protobuf:"fixed32,11,opt,name=battery_voltage,json=batteryVoltage" json:"battery_voltage,omitempty" structs:"battery_voltage,indirect" csv:"battery_voltage" structs:"battery_voltage,indirect" csv:"battery_voltage"` + BatteryVoltage *float32 `protobuf:"fixed32,11,opt,name=battery_voltage,json=batteryVoltage" json:"battery_voltage,omitempty" structs:"battery_voltage,indirect" csv:"battery_voltage"` // @inject_tag: structs:"ltc6804_badpec,indirect" csv:"ltc6804_badpec" - Ltc6804Badpec *uint32 `protobuf:"varint,12,opt,name=ltc6804_badpec,json=ltc6804Badpec" json:"ltc6804_badpec,omitempty" structs:"ltc6804_badpec,indirect" csv:"ltc6804_badpec" structs:"ltc6804_badpec,indirect" csv:"ltc6804_badpec"` + Ltc6804Badpec *uint32 `protobuf:"varint,12,opt,name=ltc6804_badpec,json=ltc6804Badpec" json:"ltc6804_badpec,omitempty" structs:"ltc6804_badpec,indirect" csv:"ltc6804_badpec"` // @inject_tag: structs:"bms_state,indirect" csv:"bms_state" - BmsState *uint32 `protobuf:"varint,13,opt,name=bms_state,json=bmsState" json:"bms_state,omitempty" structs:"bms_state,indirect" csv:"bms_state" structs:"bms_state,indirect" csv:"bms_state"` + BmsState *uint32 `protobuf:"varint,13,opt,name=bms_state,json=bmsState" json:"bms_state,omitempty" structs:"bms_state,indirect" csv:"bms_state"` // @inject_tag: structs:"charge_enabled,indirect" csv:"charge_enabled" - ChargeEnabled *int32 `protobuf:"varint,14,opt,name=charge_enabled,json=chargeEnabled" json:"charge_enabled,omitempty" structs:"charge_enabled,indirect" csv:"charge_enabled" structs:"charge_enabled,indirect" csv:"charge_enabled"` + ChargeEnabled *int32 `protobuf:"varint,14,opt,name=charge_enabled,json=chargeEnabled" json:"charge_enabled,omitempty" structs:"charge_enabled,indirect" csv:"charge_enabled"` // @inject_tag: structs:"discharge_enabled,indirect" csv:"discharge_enabled" - DischargeEnabled *int32 `protobuf:"varint,15,opt,name=discharge_enabled,json=dischargeEnabled" json:"discharge_enabled,omitempty" structs:"discharge_enabled,indirect" csv:"discharge_enabled" structs:"discharge_enabled,indirect" csv:"discharge_enabled"` + DischargeEnabled *int32 `protobuf:"varint,15,opt,name=discharge_enabled,json=dischargeEnabled" json:"discharge_enabled,omitempty" structs:"discharge_enabled,indirect" csv:"discharge_enabled"` // @inject_tag: structs:"highside_contactor_on,indirect" csv:"highside_contactor_on" - HighsideContactorOn *int32 `protobuf:"varint,16,opt,name=highside_contactor_on,json=highsideContactorOn" json:"highside_contactor_on,omitempty" structs:"highside_contactor_on,indirect" csv:"highside_contactor_on" structs:"highside_contactor_on,indirect" csv:"highside_contactor_on"` + HighsideContactorOn *int32 `protobuf:"varint,16,opt,name=highside_contactor_on,json=highsideContactorOn" json:"highside_contactor_on,omitempty" structs:"highside_contactor_on,indirect" csv:"highside_contactor_on"` // @inject_tag: structs:"lowside_contactor_on,indirect" csv:"lowside_contactor_on" - LowsideContactorOn *int32 `protobuf:"varint,17,opt,name=lowside_contactor_on,json=lowsideContactorOn" json:"lowside_contactor_on,omitempty" structs:"lowside_contactor_on,indirect" csv:"lowside_contactor_on" structs:"lowside_contactor_on,indirect" csv:"lowside_contactor_on"` + LowsideContactorOn *int32 `protobuf:"varint,17,opt,name=lowside_contactor_on,json=lowsideContactorOn" json:"lowside_contactor_on,omitempty" structs:"lowside_contactor_on,indirect" csv:"lowside_contactor_on"` // @inject_tag: structs:"precharge_on,indirect" csv:"precharge_on" - PrechargeOn *int32 `protobuf:"varint,18,opt,name=precharge_on,json=prechargeOn" json:"precharge_on,omitempty" structs:"precharge_on,indirect" csv:"precharge_on" structs:"precharge_on,indirect" csv:"precharge_on"` + PrechargeOn *int32 `protobuf:"varint,18,opt,name=precharge_on,json=prechargeOn" json:"precharge_on,omitempty" structs:"precharge_on,indirect" csv:"precharge_on"` // @inject_tag: structs:"low_volt_bus_on,indirect" csv:"low_volt_bus_on" - LowVoltBusOn *int32 `protobuf:"varint,19,opt,name=low_volt_bus_on,json=lowVoltBusOn" json:"low_volt_bus_on,omitempty" structs:"low_volt_bus_on,indirect" csv:"low_volt_bus_on" structs:"low_volt_bus_on,indirect" csv:"low_volt_bus_on"` + LowVoltBusOn *int32 `protobuf:"varint,19,opt,name=low_volt_bus_on,json=lowVoltBusOn" json:"low_volt_bus_on,omitempty" structs:"low_volt_bus_on,indirect" csv:"low_volt_bus_on"` // @inject_tag: structs:"battery_temp_1,indirect" csv:"battery_temp_1" - BatteryTemp_1 *float32 `protobuf:"fixed32,20,opt,name=battery_temp_1,json=batteryTemp1" json:"battery_temp_1,omitempty" structs:"battery_temp_1,indirect" csv:"battery_temp_1" structs:"battery_temp_1,indirect" csv:"battery_temp_1"` + BatteryTemp_1 *float32 `protobuf:"fixed32,20,opt,name=battery_temp_1,json=batteryTemp1" json:"battery_temp_1,omitempty" structs:"battery_temp_1,indirect" csv:"battery_temp_1"` // @inject_tag: structs:"battery_temp_2,indirect" csv:"battery_temp_2" - BatteryTemp_2 *float32 `protobuf:"fixed32,21,opt,name=battery_temp_2,json=batteryTemp2" json:"battery_temp_2,omitempty" structs:"battery_temp_2,indirect" csv:"battery_temp_2" structs:"battery_temp_2,indirect" csv:"battery_temp_2"` + BatteryTemp_2 *float32 `protobuf:"fixed32,21,opt,name=battery_temp_2,json=batteryTemp2" json:"battery_temp_2,omitempty" structs:"battery_temp_2,indirect" csv:"battery_temp_2"` // @inject_tag: structs:"battery_temp_3,indirect" csv:"battery_temp_3" - BatteryTemp_3 *float32 `protobuf:"fixed32,22,opt,name=battery_temp_3,json=batteryTemp3" json:"battery_temp_3,omitempty" structs:"battery_temp_3,indirect" csv:"battery_temp_3" structs:"battery_temp_3,indirect" csv:"battery_temp_3"` + BatteryTemp_3 *float32 `protobuf:"fixed32,22,opt,name=battery_temp_3,json=batteryTemp3" json:"battery_temp_3,omitempty" structs:"battery_temp_3,indirect" csv:"battery_temp_3"` // @inject_tag: structs:"battery_temp_4,indirect" csv:"battery_temp_4" - BatteryTemp_4 *float32 `protobuf:"fixed32,23,opt,name=battery_temp_4,json=batteryTemp4" json:"battery_temp_4,omitempty" structs:"battery_temp_4,indirect" csv:"battery_temp_4" structs:"battery_temp_4,indirect" csv:"battery_temp_4"` + BatteryTemp_4 *float32 `protobuf:"fixed32,23,opt,name=battery_temp_4,json=batteryTemp4" json:"battery_temp_4,omitempty" structs:"battery_temp_4,indirect" csv:"battery_temp_4"` // @inject_tag: structs:"battery_temp_5,indirect" csv:"battery_temp_5" - BatteryTemp_5 *float32 `protobuf:"fixed32,24,opt,name=battery_temp_5,json=batteryTemp5" json:"battery_temp_5,omitempty" structs:"battery_temp_5,indirect" csv:"battery_temp_5" structs:"battery_temp_5,indirect" csv:"battery_temp_5"` + BatteryTemp_5 *float32 `protobuf:"fixed32,24,opt,name=battery_temp_5,json=batteryTemp5" json:"battery_temp_5,omitempty" structs:"battery_temp_5,indirect" csv:"battery_temp_5"` // @inject_tag: structs:"battery_temp_6,indirect" csv:"battery_temp_6" - BatteryTemp_6 *float32 `protobuf:"fixed32,25,opt,name=battery_temp_6,json=batteryTemp6" json:"battery_temp_6,omitempty" structs:"battery_temp_6,indirect" csv:"battery_temp_6" structs:"battery_temp_6,indirect" csv:"battery_temp_6"` + BatteryTemp_6 *float32 `protobuf:"fixed32,25,opt,name=battery_temp_6,json=batteryTemp6" json:"battery_temp_6,omitempty" structs:"battery_temp_6,indirect" csv:"battery_temp_6"` // @inject_tag: structs:"bms_precharge_battery_adc,indirect" csv:"bms_precharge_battery_adc" - BmsPrechargeBatteryAdc *float32 `protobuf:"fixed32,26,opt,name=bms_precharge_battery_adc,json=bmsPrechargeBatteryAdc" json:"bms_precharge_battery_adc,omitempty" structs:"bms_precharge_battery_adc,indirect" csv:"bms_precharge_battery_adc" structs:"bms_precharge_battery_adc,indirect" csv:"bms_precharge_battery_adc"` + BmsPrechargeBatteryAdc *float32 `protobuf:"fixed32,26,opt,name=bms_precharge_battery_adc,json=bmsPrechargeBatteryAdc" json:"bms_precharge_battery_adc,omitempty" structs:"bms_precharge_battery_adc,indirect" csv:"bms_precharge_battery_adc"` // @inject_tag: structs:"bms_precharge_car_adc,indirect" csv:"bms_precharge_car_adc" - BmsPrechargeCarAdc *float32 `protobuf:"fixed32,27,opt,name=bms_precharge_car_adc,json=bmsPrechargeCarAdc" json:"bms_precharge_car_adc,omitempty" structs:"bms_precharge_car_adc,indirect" csv:"bms_precharge_car_adc" structs:"bms_precharge_car_adc,indirect" csv:"bms_precharge_car_adc"` + BmsPrechargeCarAdc *float32 `protobuf:"fixed32,27,opt,name=bms_precharge_car_adc,json=bmsPrechargeCarAdc" json:"bms_precharge_car_adc,omitempty" structs:"bms_precharge_car_adc,indirect" csv:"bms_precharge_car_adc"` // @inject_tag: structs:"low_volt_output_current,indirect" csv:"low_volt_output_current" - LowVoltOutputCurrent *float32 `protobuf:"fixed32,29,opt,name=low_volt_output_current,json=lowVoltOutputCurrent" json:"low_volt_output_current,omitempty" structs:"low_volt_output_current,indirect" csv:"low_volt_output_current" structs:"low_volt_output_current,indirect" csv:"low_volt_output_current"` + LowVoltOutputCurrent *float32 `protobuf:"fixed32,29,opt,name=low_volt_output_current,json=lowVoltOutputCurrent" json:"low_volt_output_current,omitempty" structs:"low_volt_output_current,indirect" csv:"low_volt_output_current"` // @inject_tag: structs:"array_current,indirect" csv:"array_current" - ArrayCurrent *float32 `protobuf:"fixed32,30,opt,name=array_current,json=arrayCurrent" json:"array_current,omitempty" structs:"array_current,indirect" csv:"array_current" structs:"array_current,indirect" csv:"array_current"` + ArrayCurrent *float32 `protobuf:"fixed32,30,opt,name=array_current,json=arrayCurrent" json:"array_current,omitempty" structs:"array_current,indirect" csv:"array_current"` // @inject_tag: structs:"battery_current,indirect" csv:"battery_current" - BatteryCurrent *float32 `protobuf:"fixed32,31,opt,name=battery_current,json=batteryCurrent" json:"battery_current,omitempty" structs:"battery_current,indirect" csv:"battery_current" structs:"battery_current,indirect" csv:"battery_current"` + BatteryCurrent *float32 `protobuf:"fixed32,31,opt,name=battery_current,json=batteryCurrent" json:"battery_current,omitempty" structs:"battery_current,indirect" csv:"battery_current"` // @inject_tag: structs:"left_motor_controller_power,indirect" csv:"left_motor_controller_power" - LeftMotorControllerPower *float32 `protobuf:"fixed32,32,opt,name=left_motor_controller_power,json=leftMotorControllerPower" json:"left_motor_controller_power,omitempty" structs:"left_motor_controller_power,indirect" csv:"left_motor_controller_power" structs:"left_motor_controller_power,indirect" csv:"left_motor_controller_power"` + LeftMotorControllerPower *float32 `protobuf:"fixed32,32,opt,name=left_motor_controller_power,json=leftMotorControllerPower" json:"left_motor_controller_power,omitempty" structs:"left_motor_controller_power,indirect" csv:"left_motor_controller_power"` // @inject_tag: structs:"right_motor_controller_power,indirect" csv:"right_motor_controller_power" - RightMotorControllerPower *float32 `protobuf:"fixed32,33,opt,name=right_motor_controller_power,json=rightMotorControllerPower" json:"right_motor_controller_power,omitempty" structs:"right_motor_controller_power,indirect" csv:"right_motor_controller_power" structs:"right_motor_controller_power,indirect" csv:"right_motor_controller_power"` + RightMotorControllerPower *float32 `protobuf:"fixed32,33,opt,name=right_motor_controller_power,json=rightMotorControllerPower" json:"right_motor_controller_power,omitempty" structs:"right_motor_controller_power,indirect" csv:"right_motor_controller_power"` // @inject_tag: structs:"amp_hours,indirect" csv:"amp_hours" - AmpHours *float32 `protobuf:"fixed32,34,opt,name=amp_hours,json=ampHours" json:"amp_hours,omitempty" structs:"amp_hours,indirect" csv:"amp_hours" structs:"amp_hours,indirect" csv:"amp_hours"` + AmpHours *float32 `protobuf:"fixed32,34,opt,name=amp_hours,json=ampHours" json:"amp_hours,omitempty" structs:"amp_hours,indirect" csv:"amp_hours"` // @inject_tag: structs:"head_lights_on,indirect" csv:"head_lights_on" - HeadLightsOn *int32 `protobuf:"varint,35,opt,name=head_lights_on,json=headLightsOn" json:"head_lights_on,omitempty" structs:"head_lights_on,indirect" csv:"head_lights_on" structs:"head_lights_on,indirect" csv:"head_lights_on"` + HeadLightsOn *int32 `protobuf:"varint,35,opt,name=head_lights_on,json=headLightsOn" json:"head_lights_on,omitempty" structs:"head_lights_on,indirect" csv:"head_lights_on"` // @inject_tag: structs:"brake_lights_on,indirect" csv:"brake_lights_on" - BrakeLightsOn *int32 `protobuf:"varint,36,opt,name=brake_lights_on,json=brakeLightsOn" json:"brake_lights_on,omitempty" structs:"brake_lights_on,indirect" csv:"brake_lights_on" structs:"brake_lights_on,indirect" csv:"brake_lights_on"` + BrakeLightsOn *int32 `protobuf:"varint,36,opt,name=brake_lights_on,json=brakeLightsOn" json:"brake_lights_on,omitempty" structs:"brake_lights_on,indirect" csv:"brake_lights_on"` // @inject_tag: structs:"right_blinker_on,indirect" csv:"right_blinker_on" - RightBlinkerOn *int32 `protobuf:"varint,37,opt,name=right_blinker_on,json=rightBlinkerOn" json:"right_blinker_on,omitempty" structs:"right_blinker_on,indirect" csv:"right_blinker_on" structs:"right_blinker_on,indirect" csv:"right_blinker_on"` + RightBlinkerOn *int32 `protobuf:"varint,37,opt,name=right_blinker_on,json=rightBlinkerOn" json:"right_blinker_on,omitempty" structs:"right_blinker_on,indirect" csv:"right_blinker_on"` // @inject_tag: structs:"left_blinker_on,indirect" csv:"left_blinker_on" - LeftBlinkerOn *int32 `protobuf:"varint,38,opt,name=left_blinker_on,json=leftBlinkerOn" json:"left_blinker_on,omitempty" structs:"left_blinker_on,indirect" csv:"left_blinker_on" structs:"left_blinker_on,indirect" csv:"left_blinker_on"` + LeftBlinkerOn *int32 `protobuf:"varint,38,opt,name=left_blinker_on,json=leftBlinkerOn" json:"left_blinker_on,omitempty" structs:"left_blinker_on,indirect" csv:"left_blinker_on"` // @inject_tag: structs:"brake_pressed,indirect" csv:"brake_pressed" - BrakePressed *int32 `protobuf:"varint,39,opt,name=brake_pressed,json=brakePressed" json:"brake_pressed,omitempty" structs:"brake_pressed,indirect" csv:"brake_pressed" structs:"brake_pressed,indirect" csv:"brake_pressed"` + BrakePressed *int32 `protobuf:"varint,39,opt,name=brake_pressed,json=brakePressed" json:"brake_pressed,omitempty" structs:"brake_pressed,indirect" csv:"brake_pressed"` // @inject_tag: structs:"throttle_pressed,indirect" csv:"throttle_pressed" - ThrottlePressed *int32 `protobuf:"varint,40,opt,name=throttle_pressed,json=throttlePressed" json:"throttle_pressed,omitempty" structs:"throttle_pressed,indirect" csv:"throttle_pressed" structs:"throttle_pressed,indirect" csv:"throttle_pressed"` + ThrottlePressed *int32 `protobuf:"varint,40,opt,name=throttle_pressed,json=throttlePressed" json:"throttle_pressed,omitempty" structs:"throttle_pressed,indirect" csv:"throttle_pressed"` // @inject_tag: structs:"drive_mode,indirect" csv:"drive_mode" - DriveMode *uint32 `protobuf:"varint,41,opt,name=drive_mode,json=driveMode" json:"drive_mode,omitempty" structs:"drive_mode,indirect" csv:"drive_mode" structs:"drive_mode,indirect" csv:"drive_mode"` + DriveMode *uint32 `protobuf:"varint,41,opt,name=drive_mode,json=driveMode" json:"drive_mode,omitempty" structs:"drive_mode,indirect" csv:"drive_mode"` // @inject_tag: structs:"motor_controller_enabled,indirect" csv:"motor_controller_enabled" - MotorControllerEnabled *int32 `protobuf:"varint,42,opt,name=motor_controller_enabled,json=motorControllerEnabled" json:"motor_controller_enabled,omitempty" structs:"motor_controller_enabled,indirect" csv:"motor_controller_enabled" structs:"motor_controller_enabled,indirect" csv:"motor_controller_enabled"` + MotorControllerEnabled *int32 `protobuf:"varint,42,opt,name=motor_controller_enabled,json=motorControllerEnabled" json:"motor_controller_enabled,omitempty" structs:"motor_controller_enabled,indirect" csv:"motor_controller_enabled"` // @inject_tag: structs:"motor_controller_speed,indirect" csv:"motor_controller_speed" - MotorControllerSpeed *float32 `protobuf:"fixed32,43,opt,name=motor_controller_speed,json=motorControllerSpeed" json:"motor_controller_speed,omitempty" structs:"motor_controller_speed,indirect" csv:"motor_controller_speed" structs:"motor_controller_speed,indirect" csv:"motor_controller_speed"` + MotorControllerSpeed *float32 `protobuf:"fixed32,43,opt,name=motor_controller_speed,json=motorControllerSpeed" json:"motor_controller_speed,omitempty" structs:"motor_controller_speed,indirect" csv:"motor_controller_speed"` // @inject_tag: structs:"motor_controller_rpm,indirect" csv:"motor_controller_rpm" - MotorControllerRpm *float32 `protobuf:"fixed32,44,opt,name=motor_controller_rpm,json=motorControllerRpm" json:"motor_controller_rpm,omitempty" structs:"motor_controller_rpm,indirect" csv:"motor_controller_rpm" structs:"motor_controller_rpm,indirect" csv:"motor_controller_rpm"` + MotorControllerRpm *float32 `protobuf:"fixed32,44,opt,name=motor_controller_rpm,json=motorControllerRpm" json:"motor_controller_rpm,omitempty" structs:"motor_controller_rpm,indirect" csv:"motor_controller_rpm"` // @inject_tag: structs:"avg_odometer,indirect" csv:"avg_odometer" - AvgOdometer *float32 `protobuf:"fixed32,45,opt,name=avg_odometer,json=avgOdometer" json:"avg_odometer,omitempty" structs:"avg_odometer,indirect" csv:"avg_odometer" structs:"avg_odometer,indirect" csv:"avg_odometer"` + AvgOdometer *float32 `protobuf:"fixed32,45,opt,name=avg_odometer,json=avgOdometer" json:"avg_odometer,omitempty" structs:"avg_odometer,indirect" csv:"avg_odometer"` // @inject_tag: structs:"left_motor_temp,indirect" csv:"left_motor_temp" - LeftMotorTemp *float32 `protobuf:"fixed32,46,opt,name=left_motor_temp,json=leftMotorTemp" json:"left_motor_temp,omitempty" structs:"left_motor_temp,indirect" csv:"left_motor_temp" structs:"left_motor_temp,indirect" csv:"left_motor_temp"` + LeftMotorTemp *float32 `protobuf:"fixed32,46,opt,name=left_motor_temp,json=leftMotorTemp" json:"left_motor_temp,omitempty" structs:"left_motor_temp,indirect" csv:"left_motor_temp"` // @inject_tag: structs:"right_motor_temp,indirect" csv:"right_motor_temp" - RightMotorTemp *float32 `protobuf:"fixed32,47,opt,name=right_motor_temp,json=rightMotorTemp" json:"right_motor_temp,omitempty" structs:"right_motor_temp,indirect" csv:"right_motor_temp" structs:"right_motor_temp,indirect" csv:"right_motor_temp"` + RightMotorTemp *float32 `protobuf:"fixed32,47,opt,name=right_motor_temp,json=rightMotorTemp" json:"right_motor_temp,omitempty" structs:"right_motor_temp,indirect" csv:"right_motor_temp"` // @inject_tag: structs:"left_motor_controller_temp,indirect" csv:"left_motor_controller_temp" - LeftMotorControllerTemp *float32 `protobuf:"fixed32,48,opt,name=left_motor_controller_temp,json=leftMotorControllerTemp" json:"left_motor_controller_temp,omitempty" structs:"left_motor_controller_temp,indirect" csv:"left_motor_controller_temp" structs:"left_motor_controller_temp,indirect" csv:"left_motor_controller_temp"` + LeftMotorControllerTemp *float32 `protobuf:"fixed32,48,opt,name=left_motor_controller_temp,json=leftMotorControllerTemp" json:"left_motor_controller_temp,omitempty" structs:"left_motor_controller_temp,indirect" csv:"left_motor_controller_temp"` // @inject_tag: structs:"right_motor_controller_temp,indirect" csv:"right_motor_controller_temp" - RightMotorControllerTemp *float32 `protobuf:"fixed32,49,opt,name=right_motor_controller_temp,json=rightMotorControllerTemp" json:"right_motor_controller_temp,omitempty" structs:"right_motor_controller_temp,indirect" csv:"right_motor_controller_temp" structs:"right_motor_controller_temp,indirect" csv:"right_motor_controller_temp"` + RightMotorControllerTemp *float32 `protobuf:"fixed32,49,opt,name=right_motor_controller_temp,json=rightMotorControllerTemp" json:"right_motor_controller_temp,omitempty" structs:"right_motor_controller_temp,indirect" csv:"right_motor_controller_temp"` // @inject_tag: structs:"left_motor_controller_alive,indirect" csv:"left_motor_controller_alive" - LeftMotorControllerAlive *float32 `protobuf:"fixed32,50,opt,name=left_motor_controller_alive,json=leftMotorControllerAlive" json:"left_motor_controller_alive,omitempty" structs:"left_motor_controller_alive,indirect" csv:"left_motor_controller_alive" structs:"left_motor_controller_alive,indirect" csv:"left_motor_controller_alive"` + LeftMotorControllerAlive *float32 `protobuf:"fixed32,50,opt,name=left_motor_controller_alive,json=leftMotorControllerAlive" json:"left_motor_controller_alive,omitempty" structs:"left_motor_controller_alive,indirect" csv:"left_motor_controller_alive"` // @inject_tag: structs:"right_motor_controller_alive,indirect" csv:"right_motor_controller_alive" - RightMotorControllerAlive *float32 `protobuf:"fixed32,51,opt,name=right_motor_controller_alive,json=rightMotorControllerAlive" json:"right_motor_controller_alive,omitempty" structs:"right_motor_controller_alive,indirect" csv:"right_motor_controller_alive" structs:"right_motor_controller_alive,indirect" csv:"right_motor_controller_alive"` + RightMotorControllerAlive *float32 `protobuf:"fixed32,51,opt,name=right_motor_controller_alive,json=rightMotorControllerAlive" json:"right_motor_controller_alive,omitempty" structs:"right_motor_controller_alive,indirect" csv:"right_motor_controller_alive"` // @inject_tag: structs:"left_motor_controller_current,indirect" csv:"left_motor_controller_current" - LeftMotorControllerCurrent *float32 `protobuf:"fixed32,52,opt,name=left_motor_controller_current,json=leftMotorControllerCurrent" json:"left_motor_controller_current,omitempty" structs:"left_motor_controller_current,indirect" csv:"left_motor_controller_current" structs:"left_motor_controller_current,indirect" csv:"left_motor_controller_current"` + LeftMotorControllerCurrent *float32 `protobuf:"fixed32,52,opt,name=left_motor_controller_current,json=leftMotorControllerCurrent" json:"left_motor_controller_current,omitempty" structs:"left_motor_controller_current,indirect" csv:"left_motor_controller_current"` // @inject_tag: structs:"right_motor_controller_current,indirect" csv:"right_motor_controller_current" - RightMotorControllerCurrent *float32 `protobuf:"fixed32,53,opt,name=right_motor_controller_current,json=rightMotorControllerCurrent" json:"right_motor_controller_current,omitempty" structs:"right_motor_controller_current,indirect" csv:"right_motor_controller_current" structs:"right_motor_controller_current,indirect" csv:"right_motor_controller_current"` + RightMotorControllerCurrent *float32 `protobuf:"fixed32,53,opt,name=right_motor_controller_current,json=rightMotorControllerCurrent" json:"right_motor_controller_current,omitempty" structs:"right_motor_controller_current,indirect" csv:"right_motor_controller_current"` // @inject_tag: structs:"motor_controller_current_diff,indirect" csv:"motor_controller_current_diff" - MotorControllerCurrentDiff *float32 `protobuf:"fixed32,54,opt,name=motor_controller_current_diff,json=motorControllerCurrentDiff" json:"motor_controller_current_diff,omitempty" structs:"motor_controller_current_diff,indirect" csv:"motor_controller_current_diff" structs:"motor_controller_current_diff,indirect" csv:"motor_controller_current_diff"` + MotorControllerCurrentDiff *float32 `protobuf:"fixed32,54,opt,name=motor_controller_current_diff,json=motorControllerCurrentDiff" json:"motor_controller_current_diff,omitempty" structs:"motor_controller_current_diff,indirect" csv:"motor_controller_current_diff"` // @inject_tag: structs:"left_motor_controller_error,indirect" csv:"left_motor_controller_error" - LeftMotorControllerError *uint32 `protobuf:"varint,55,opt,name=left_motor_controller_error,json=leftMotorControllerError" json:"left_motor_controller_error,omitempty" structs:"left_motor_controller_error,indirect" csv:"left_motor_controller_error" structs:"left_motor_controller_error,indirect" csv:"left_motor_controller_error"` + LeftMotorControllerError *uint32 `protobuf:"varint,55,opt,name=left_motor_controller_error,json=leftMotorControllerError" json:"left_motor_controller_error,omitempty" structs:"left_motor_controller_error,indirect" csv:"left_motor_controller_error"` // @inject_tag: structs:"right_motor_controller_error,indirect" csv:"right_motor_controller_error" - RightMotorControllerError *uint32 `protobuf:"varint,56,opt,name=right_motor_controller_error,json=rightMotorControllerError" json:"right_motor_controller_error,omitempty" structs:"right_motor_controller_error,indirect" csv:"right_motor_controller_error" structs:"right_motor_controller_error,indirect" csv:"right_motor_controller_error"` + RightMotorControllerError *uint32 `protobuf:"varint,56,opt,name=right_motor_controller_error,json=rightMotorControllerError" json:"right_motor_controller_error,omitempty" structs:"right_motor_controller_error,indirect" csv:"right_motor_controller_error"` // @inject_tag: structs:"left_motor_controller_limit,indirect" csv:"left_motor_controller_limit" - LeftMotorControllerLimit *uint32 `protobuf:"varint,57,opt,name=left_motor_controller_limit,json=leftMotorControllerLimit" json:"left_motor_controller_limit,omitempty" structs:"left_motor_controller_limit,indirect" csv:"left_motor_controller_limit" structs:"left_motor_controller_limit,indirect" csv:"left_motor_controller_limit"` + LeftMotorControllerLimit *uint32 `protobuf:"varint,57,opt,name=left_motor_controller_limit,json=leftMotorControllerLimit" json:"left_motor_controller_limit,omitempty" structs:"left_motor_controller_limit,indirect" csv:"left_motor_controller_limit"` // @inject_tag: structs:"right_motor_controller_limit,indirect" csv:"right_motor_controller_limit" - RightMotorControllerLimit *uint32 `protobuf:"varint,58,opt,name=right_motor_controller_limit,json=rightMotorControllerLimit" json:"right_motor_controller_limit,omitempty" structs:"right_motor_controller_limit,indirect" csv:"right_motor_controller_limit" structs:"right_motor_controller_limit,indirect" csv:"right_motor_controller_limit"` + RightMotorControllerLimit *uint32 `protobuf:"varint,58,opt,name=right_motor_controller_limit,json=rightMotorControllerLimit" json:"right_motor_controller_limit,omitempty" structs:"right_motor_controller_limit,indirect" csv:"right_motor_controller_limit"` // @inject_tag: structs:"left_motor_controller_rx_error_count,indirect" csv:"left_motor_controller_rx_error_count" - LeftMotorControllerRxErrorCount *uint32 `protobuf:"varint,59,opt,name=left_motor_controller_rx_error_count,json=leftMotorControllerRxErrorCount" json:"left_motor_controller_rx_error_count,omitempty" structs:"left_motor_controller_rx_error_count,indirect" csv:"left_motor_controller_rx_error_count" structs:"left_motor_controller_rx_error_count,indirect" csv:"left_motor_controller_rx_error_count"` + LeftMotorControllerRxErrorCount *uint32 `protobuf:"varint,59,opt,name=left_motor_controller_rx_error_count,json=leftMotorControllerRxErrorCount" json:"left_motor_controller_rx_error_count,omitempty" structs:"left_motor_controller_rx_error_count,indirect" csv:"left_motor_controller_rx_error_count"` // @inject_tag: structs:"right_motor_controller_rx_error_count,indirect" csv:"right_motor_controller_rx_error_count" - RightMotorControllerRxErrorCount *uint32 `protobuf:"varint,60,opt,name=right_motor_controller_rx_error_count,json=rightMotorControllerRxErrorCount" json:"right_motor_controller_rx_error_count,omitempty" structs:"right_motor_controller_rx_error_count,indirect" csv:"right_motor_controller_rx_error_count" structs:"right_motor_controller_rx_error_count,indirect" csv:"right_motor_controller_rx_error_count"` + RightMotorControllerRxErrorCount *uint32 `protobuf:"varint,60,opt,name=right_motor_controller_rx_error_count,json=rightMotorControllerRxErrorCount" json:"right_motor_controller_rx_error_count,omitempty" structs:"right_motor_controller_rx_error_count,indirect" csv:"right_motor_controller_rx_error_count"` // @inject_tag: structs:"left_motor_controller_tx_error_count,indirect" csv:"left_motor_controller_tx_error_count" - LeftMotorControllerTxErrorCount *uint32 `protobuf:"varint,61,opt,name=left_motor_controller_tx_error_count,json=leftMotorControllerTxErrorCount" json:"left_motor_controller_tx_error_count,omitempty" structs:"left_motor_controller_tx_error_count,indirect" csv:"left_motor_controller_tx_error_count" structs:"left_motor_controller_tx_error_count,indirect" csv:"left_motor_controller_tx_error_count"` + LeftMotorControllerTxErrorCount *uint32 `protobuf:"varint,61,opt,name=left_motor_controller_tx_error_count,json=leftMotorControllerTxErrorCount" json:"left_motor_controller_tx_error_count,omitempty" structs:"left_motor_controller_tx_error_count,indirect" csv:"left_motor_controller_tx_error_count"` // @inject_tag: structs:"right_motor_controller_tx_error_count,indirect" csv:"right_motor_controller_tx_error_count" - RightMotorControllerTxErrorCount *uint32 `protobuf:"varint,62,opt,name=right_motor_controller_tx_error_count,json=rightMotorControllerTxErrorCount" json:"right_motor_controller_tx_error_count,omitempty" structs:"right_motor_controller_tx_error_count,indirect" csv:"right_motor_controller_tx_error_count" structs:"right_motor_controller_tx_error_count,indirect" csv:"right_motor_controller_tx_error_count"` + RightMotorControllerTxErrorCount *uint32 `protobuf:"varint,62,opt,name=right_motor_controller_tx_error_count,json=rightMotorControllerTxErrorCount" json:"right_motor_controller_tx_error_count,omitempty" structs:"right_motor_controller_tx_error_count,indirect" csv:"right_motor_controller_tx_error_count"` // @inject_tag: structs:"left_motor_controller_bus_voltage,indirect" csv:"left_motor_controller_bus_voltage" - LeftMotorControllerBusVoltage *float32 `protobuf:"fixed32,63,opt,name=left_motor_controller_bus_voltage,json=leftMotorControllerBusVoltage" json:"left_motor_controller_bus_voltage,omitempty" structs:"left_motor_controller_bus_voltage,indirect" csv:"left_motor_controller_bus_voltage" structs:"left_motor_controller_bus_voltage,indirect" csv:"left_motor_controller_bus_voltage"` + LeftMotorControllerBusVoltage *float32 `protobuf:"fixed32,63,opt,name=left_motor_controller_bus_voltage,json=leftMotorControllerBusVoltage" json:"left_motor_controller_bus_voltage,omitempty" structs:"left_motor_controller_bus_voltage,indirect" csv:"left_motor_controller_bus_voltage"` // @inject_tag: structs:"right_motor_controller_bus_voltage,indirect" csv:"right_motor_controller_bus_voltage" - RightMotorControllerBusVoltage *float32 `protobuf:"fixed32,64,opt,name=right_motor_controller_bus_voltage,json=rightMotorControllerBusVoltage" json:"right_motor_controller_bus_voltage,omitempty" structs:"right_motor_controller_bus_voltage,indirect" csv:"right_motor_controller_bus_voltage" structs:"right_motor_controller_bus_voltage,indirect" csv:"right_motor_controller_bus_voltage"` + RightMotorControllerBusVoltage *float32 `protobuf:"fixed32,64,opt,name=right_motor_controller_bus_voltage,json=rightMotorControllerBusVoltage" json:"right_motor_controller_bus_voltage,omitempty" structs:"right_motor_controller_bus_voltage,indirect" csv:"right_motor_controller_bus_voltage"` // @inject_tag: structs:"left_motor_controller_15v_voltage,indirect" csv:"left_motor_controller_15v_voltage" - LeftMotorController_15VVoltage *float32 `protobuf:"fixed32,65,opt,name=left_motor_controller_15v_voltage,json=leftMotorController15vVoltage" json:"left_motor_controller_15v_voltage,omitempty" structs:"left_motor_controller_15v_voltage,indirect" csv:"left_motor_controller_15v_voltage" structs:"left_motor_controller_15v_voltage,indirect" csv:"left_motor_controller_15v_voltage"` + LeftMotorController_15VVoltage *float32 `protobuf:"fixed32,65,opt,name=left_motor_controller_15v_voltage,json=leftMotorController15vVoltage" json:"left_motor_controller_15v_voltage,omitempty" structs:"left_motor_controller_15v_voltage,indirect" csv:"left_motor_controller_15v_voltage"` // @inject_tag: structs:"right_motor_controller_15v_voltage,indirect" csv:"right_motor_controller_15v_voltage" - RightMotorController_15VVoltage *float32 `protobuf:"fixed32,66,opt,name=right_motor_controller_15v_voltage,json=rightMotorController15vVoltage" json:"right_motor_controller_15v_voltage,omitempty" structs:"right_motor_controller_15v_voltage,indirect" csv:"right_motor_controller_15v_voltage" structs:"right_motor_controller_15v_voltage,indirect" csv:"right_motor_controller_15v_voltage"` + RightMotorController_15VVoltage *float32 `protobuf:"fixed32,66,opt,name=right_motor_controller_15v_voltage,json=rightMotorController15vVoltage" json:"right_motor_controller_15v_voltage,omitempty" structs:"right_motor_controller_15v_voltage,indirect" csv:"right_motor_controller_15v_voltage"` // @inject_tag: structs:"left_motor_controller_3v3_voltage,indirect" csv:"left_motor_controller_3v3_voltage" - LeftMotorController_3V3Voltage *float32 `protobuf:"fixed32,67,opt,name=left_motor_controller_3v3_voltage,json=leftMotorController3v3Voltage" json:"left_motor_controller_3v3_voltage,omitempty" structs:"left_motor_controller_3v3_voltage,indirect" csv:"left_motor_controller_3v3_voltage" structs:"left_motor_controller_3v3_voltage,indirect" csv:"left_motor_controller_3v3_voltage"` + LeftMotorController_3V3Voltage *float32 `protobuf:"fixed32,67,opt,name=left_motor_controller_3v3_voltage,json=leftMotorController3v3Voltage" json:"left_motor_controller_3v3_voltage,omitempty" structs:"left_motor_controller_3v3_voltage,indirect" csv:"left_motor_controller_3v3_voltage"` // @inject_tag: structs:"right_motor_controller_3v3_voltage,indirect" csv:"right_motor_controller_3v3_voltage" - RightMotorController_3V3Voltage *float32 `protobuf:"fixed32,68,opt,name=right_motor_controller_3v3_voltage,json=rightMotorController3v3Voltage" json:"right_motor_controller_3v3_voltage,omitempty" structs:"right_motor_controller_3v3_voltage,indirect" csv:"right_motor_controller_3v3_voltage" structs:"right_motor_controller_3v3_voltage,indirect" csv:"right_motor_controller_3v3_voltage"` + RightMotorController_3V3Voltage *float32 `protobuf:"fixed32,68,opt,name=right_motor_controller_3v3_voltage,json=rightMotorController3v3Voltage" json:"right_motor_controller_3v3_voltage,omitempty" structs:"right_motor_controller_3v3_voltage,indirect" csv:"right_motor_controller_3v3_voltage"` // @inject_tag: structs:"left_motor_controller_1v9_voltage,indirect" csv:"left_motor_controller_1v9_voltage" - LeftMotorController_1V9Voltage *float32 `protobuf:"fixed32,69,opt,name=left_motor_controller_1v9_voltage,json=leftMotorController1v9Voltage" json:"left_motor_controller_1v9_voltage,omitempty" structs:"left_motor_controller_1v9_voltage,indirect" csv:"left_motor_controller_1v9_voltage" structs:"left_motor_controller_1v9_voltage,indirect" csv:"left_motor_controller_1v9_voltage"` + LeftMotorController_1V9Voltage *float32 `protobuf:"fixed32,69,opt,name=left_motor_controller_1v9_voltage,json=leftMotorController1v9Voltage" json:"left_motor_controller_1v9_voltage,omitempty" structs:"left_motor_controller_1v9_voltage,indirect" csv:"left_motor_controller_1v9_voltage"` // @inject_tag: structs:"right_motor_controller_1v9_voltage,indirect" csv:"right_motor_controller_1v9_voltage" - RightMotorController_1V9Voltage *float32 `protobuf:"fixed32,70,opt,name=right_motor_controller_1v9_voltage,json=rightMotorController1v9Voltage" json:"right_motor_controller_1v9_voltage,omitempty" structs:"right_motor_controller_1v9_voltage,indirect" csv:"right_motor_controller_1v9_voltage" structs:"right_motor_controller_1v9_voltage,indirect" csv:"right_motor_controller_1v9_voltage"` + RightMotorController_1V9Voltage *float32 `protobuf:"fixed32,70,opt,name=right_motor_controller_1v9_voltage,json=rightMotorController1v9Voltage" json:"right_motor_controller_1v9_voltage,omitempty" structs:"right_motor_controller_1v9_voltage,indirect" csv:"right_motor_controller_1v9_voltage"` // @inject_tag: structs:"left_motor_controller_dsp_temp,indirect" csv:"left_motor_controller_dsp_temp" - LeftMotorControllerDspTemp *float32 `protobuf:"fixed32,71,opt,name=left_motor_controller_dsp_temp,json=leftMotorControllerDspTemp" json:"left_motor_controller_dsp_temp,omitempty" structs:"left_motor_controller_dsp_temp,indirect" csv:"left_motor_controller_dsp_temp" structs:"left_motor_controller_dsp_temp,indirect" csv:"left_motor_controller_dsp_temp"` + LeftMotorControllerDspTemp *float32 `protobuf:"fixed32,71,opt,name=left_motor_controller_dsp_temp,json=leftMotorControllerDspTemp" json:"left_motor_controller_dsp_temp,omitempty" structs:"left_motor_controller_dsp_temp,indirect" csv:"left_motor_controller_dsp_temp"` // @inject_tag: structs:"right_motor_controller_dsp_temp,indirect" csv:"right_motor_controller_dsp_temp" - RightMotorControllerDspTemp *float32 `protobuf:"fixed32,72,opt,name=right_motor_controller_dsp_temp,json=rightMotorControllerDspTemp" json:"right_motor_controller_dsp_temp,omitempty" structs:"right_motor_controller_dsp_temp,indirect" csv:"right_motor_controller_dsp_temp" structs:"right_motor_controller_dsp_temp,indirect" csv:"right_motor_controller_dsp_temp"` + RightMotorControllerDspTemp *float32 `protobuf:"fixed32,72,opt,name=right_motor_controller_dsp_temp,json=rightMotorControllerDspTemp" json:"right_motor_controller_dsp_temp,omitempty" structs:"right_motor_controller_dsp_temp,indirect" csv:"right_motor_controller_dsp_temp"` // @inject_tag: structs:"left_motor_controller_phase_current,indirect" csv:"left_motor_controller_phase_current" - LeftMotorControllerPhaseCurrent *float32 `protobuf:"fixed32,73,opt,name=left_motor_controller_phase_current,json=leftMotorControllerPhaseCurrent" json:"left_motor_controller_phase_current,omitempty" structs:"left_motor_controller_phase_current,indirect" csv:"left_motor_controller_phase_current" structs:"left_motor_controller_phase_current,indirect" csv:"left_motor_controller_phase_current"` + LeftMotorControllerPhaseCurrent *float32 `protobuf:"fixed32,73,opt,name=left_motor_controller_phase_current,json=leftMotorControllerPhaseCurrent" json:"left_motor_controller_phase_current,omitempty" structs:"left_motor_controller_phase_current,indirect" csv:"left_motor_controller_phase_current"` // @inject_tag: structs:"right_motor_controller_phase_current,indirect" csv:"right_motor_controller_phase_current" - RightMotorControllerPhaseCurrent *float32 `protobuf:"fixed32,74,opt,name=right_motor_controller_phase_current,json=rightMotorControllerPhaseCurrent" json:"right_motor_controller_phase_current,omitempty" structs:"right_motor_controller_phase_current,indirect" csv:"right_motor_controller_phase_current" structs:"right_motor_controller_phase_current,indirect" csv:"right_motor_controller_phase_current"` + RightMotorControllerPhaseCurrent *float32 `protobuf:"fixed32,74,opt,name=right_motor_controller_phase_current,json=rightMotorControllerPhaseCurrent" json:"right_motor_controller_phase_current,omitempty" structs:"right_motor_controller_phase_current,indirect" csv:"right_motor_controller_phase_current"` // @inject_tag: structs:"left_motor_rpm_command,indirect" csv:"left_motor_rpm_command" - LeftMotorRpmCommand *float32 `protobuf:"fixed32,75,opt,name=left_motor_rpm_command,json=leftMotorRpmCommand" json:"left_motor_rpm_command,omitempty" structs:"left_motor_rpm_command,indirect" csv:"left_motor_rpm_command" structs:"left_motor_rpm_command,indirect" csv:"left_motor_rpm_command"` + LeftMotorRpmCommand *float32 `protobuf:"fixed32,75,opt,name=left_motor_rpm_command,json=leftMotorRpmCommand" json:"left_motor_rpm_command,omitempty" structs:"left_motor_rpm_command,indirect" csv:"left_motor_rpm_command"` // @inject_tag: structs:"right_motor_rpm_command,indirect" csv:"right_motor_rpm_command" - RightMotorRpmCommand *float32 `protobuf:"fixed32,76,opt,name=right_motor_rpm_command,json=rightMotorRpmCommand" json:"right_motor_rpm_command,omitempty" structs:"right_motor_rpm_command,indirect" csv:"right_motor_rpm_command" structs:"right_motor_rpm_command,indirect" csv:"right_motor_rpm_command"` + RightMotorRpmCommand *float32 `protobuf:"fixed32,76,opt,name=right_motor_rpm_command,json=rightMotorRpmCommand" json:"right_motor_rpm_command,omitempty" structs:"right_motor_rpm_command,indirect" csv:"right_motor_rpm_command"` // @inject_tag: structs:"left_motor_current_command,indirect" csv:"left_motor_current_command" - LeftMotorCurrentCommand *float32 `protobuf:"fixed32,77,opt,name=left_motor_current_command,json=leftMotorCurrentCommand" json:"left_motor_current_command,omitempty" structs:"left_motor_current_command,indirect" csv:"left_motor_current_command" structs:"left_motor_current_command,indirect" csv:"left_motor_current_command"` + LeftMotorCurrentCommand *float32 `protobuf:"fixed32,77,opt,name=left_motor_current_command,json=leftMotorCurrentCommand" json:"left_motor_current_command,omitempty" structs:"left_motor_current_command,indirect" csv:"left_motor_current_command"` // @inject_tag: structs:"right_motor_current_command,indirect" csv:"right_motor_current_command" - RightMotorCurrentCommand *float32 `protobuf:"fixed32,78,opt,name=right_motor_current_command,json=rightMotorCurrentCommand" json:"right_motor_current_command,omitempty" structs:"right_motor_current_command,indirect" csv:"right_motor_current_command" structs:"right_motor_current_command,indirect" csv:"right_motor_current_command"` + RightMotorCurrentCommand *float32 `protobuf:"fixed32,78,opt,name=right_motor_current_command,json=rightMotorCurrentCommand" json:"right_motor_current_command,omitempty" structs:"right_motor_current_command,indirect" csv:"right_motor_current_command"` // @inject_tag: structs:"gps_time,indirect" csv:"gps_time" - GpsTime *int64 `protobuf:"varint,80,opt,name=gps_time,json=gpsTime" json:"gps_time,omitempty" structs:"gps_time,indirect" csv:"gps_time" structs:"gps_time,indirect" csv:"gps_time"` + GpsTime *int64 `protobuf:"varint,80,opt,name=gps_time,json=gpsTime" json:"gps_time,omitempty" structs:"gps_time,indirect" csv:"gps_time"` // @inject_tag: structs:"gps_latitude,indirect" csv:"gps_latitude" - GpsLatitude *float32 `protobuf:"fixed32,81,opt,name=gps_latitude,json=gpsLatitude" json:"gps_latitude,omitempty" structs:"gps_latitude,indirect" csv:"gps_latitude" structs:"gps_latitude,indirect" csv:"gps_latitude"` + GpsLatitude *float32 `protobuf:"fixed32,81,opt,name=gps_latitude,json=gpsLatitude" json:"gps_latitude,omitempty" structs:"gps_latitude,indirect" csv:"gps_latitude"` // @inject_tag: structs:"gps_longitude,indirect" csv:"gps_longitude" - GpsLongitude *float32 `protobuf:"fixed32,82,opt,name=gps_longitude,json=gpsLongitude" json:"gps_longitude,omitempty" structs:"gps_longitude,indirect" csv:"gps_longitude" structs:"gps_longitude,indirect" csv:"gps_longitude"` + GpsLongitude *float32 `protobuf:"fixed32,82,opt,name=gps_longitude,json=gpsLongitude" json:"gps_longitude,omitempty" structs:"gps_longitude,indirect" csv:"gps_longitude"` // @inject_tag: structs:"gps_speed,indirect" csv:"gps_speed" - GpsSpeed *float32 `protobuf:"fixed32,83,opt,name=gps_speed,json=gpsSpeed" json:"gps_speed,omitempty" structs:"gps_speed,indirect" csv:"gps_speed" structs:"gps_speed,indirect" csv:"gps_speed"` + GpsSpeed *float32 `protobuf:"fixed32,83,opt,name=gps_speed,json=gpsSpeed" json:"gps_speed,omitempty" structs:"gps_speed,indirect" csv:"gps_speed"` // @inject_tag: structs:"gps_altitude,indirect" csv:"gps_altitude" - GpsAltitude *float32 `protobuf:"fixed32,84,opt,name=gps_altitude,json=gpsAltitude" json:"gps_altitude,omitempty" structs:"gps_altitude,indirect" csv:"gps_altitude" structs:"gps_altitude,indirect" csv:"gps_altitude"` + GpsAltitude *float32 `protobuf:"fixed32,84,opt,name=gps_altitude,json=gpsAltitude" json:"gps_altitude,omitempty" structs:"gps_altitude,indirect" csv:"gps_altitude"` // @inject_tag: structs:"gps_bearing,indirect" csv:"gps_bearing" - GpsBearing *float32 `protobuf:"fixed32,85,opt,name=gps_bearing,json=gpsBearing" json:"gps_bearing,omitempty" structs:"gps_bearing,indirect" csv:"gps_bearing" structs:"gps_bearing,indirect" csv:"gps_bearing"` + GpsBearing *float32 `protobuf:"fixed32,85,opt,name=gps_bearing,json=gpsBearing" json:"gps_bearing,omitempty" structs:"gps_bearing,indirect" csv:"gps_bearing"` // @inject_tag: structs:"led_state,indirect" csv:"led_state" - LedState *int32 `protobuf:"varint,86,opt,name=led_state,json=ledState" json:"led_state,omitempty" structs:"led_state,indirect" csv:"led_state" structs:"led_state,indirect" csv:"led_state"` + LedState *int32 `protobuf:"varint,86,opt,name=led_state,json=ledState" json:"led_state,omitempty" structs:"led_state,indirect" csv:"led_state"` // @inject_tag: structs:"mppt_array_power,indirect" csv:"mppt_array_power" - MpptArrayPower *float32 `protobuf:"fixed32,87,opt,name=mppt_array_power,json=mpptArrayPower" json:"mppt_array_power,omitempty" structs:"mppt_array_power,indirect" csv:"mppt_array_power" structs:"mppt_array_power,indirect" csv:"mppt_array_power"` + MpptArrayPower *float32 `protobuf:"fixed32,87,opt,name=mppt_array_power,json=mpptArrayPower" json:"mppt_array_power,omitempty" structs:"mppt_array_power,indirect" csv:"mppt_array_power"` // @inject_tag: structs:"mppt_A0_volt_in,indirect" csv:"mppt_A0_volt_in" - Mppt_A0VoltIn *float32 `protobuf:"fixed32,88,opt,name=mppt_A0_volt_in,json=mpptA0VoltIn" json:"mppt_A0_volt_in,omitempty" structs:"mppt_A0_volt_in,indirect" csv:"mppt_A0_volt_in" structs:"mppt_A0_volt_in,indirect" csv:"mppt_A0_volt_in"` + Mppt_A0VoltIn *float32 `protobuf:"fixed32,88,opt,name=mppt_A0_volt_in,json=mpptA0VoltIn" json:"mppt_A0_volt_in,omitempty" structs:"mppt_A0_volt_in,indirect" csv:"mppt_A0_volt_in"` // @inject_tag: structs:"mppt_A0_volt_out,indirect" csv:"mppt_A0_volt_out" - Mppt_A0VoltOut *float32 `protobuf:"fixed32,89,opt,name=mppt_A0_volt_out,json=mpptA0VoltOut" json:"mppt_A0_volt_out,omitempty" structs:"mppt_A0_volt_out,indirect" csv:"mppt_A0_volt_out" structs:"mppt_A0_volt_out,indirect" csv:"mppt_A0_volt_out"` + Mppt_A0VoltOut *float32 `protobuf:"fixed32,89,opt,name=mppt_A0_volt_out,json=mpptA0VoltOut" json:"mppt_A0_volt_out,omitempty" structs:"mppt_A0_volt_out,indirect" csv:"mppt_A0_volt_out"` // @inject_tag: structs:"mppt_A0_current,indirect" csv:"mppt_A0_current" - Mppt_A0Current *float32 `protobuf:"fixed32,90,opt,name=mppt_A0_current,json=mpptA0Current" json:"mppt_A0_current,omitempty" structs:"mppt_A0_current,indirect" csv:"mppt_A0_current" structs:"mppt_A0_current,indirect" csv:"mppt_A0_current"` + Mppt_A0Current *float32 `protobuf:"fixed32,90,opt,name=mppt_A0_current,json=mpptA0Current" json:"mppt_A0_current,omitempty" structs:"mppt_A0_current,indirect" csv:"mppt_A0_current"` // @inject_tag: structs:"mppt_A0_temp,indirect" csv:"mppt_A0_temp" - Mppt_A0Temp *float32 `protobuf:"fixed32,91,opt,name=mppt_A0_temp,json=mpptA0Temp" json:"mppt_A0_temp,omitempty" structs:"mppt_A0_temp,indirect" csv:"mppt_A0_temp" structs:"mppt_A0_temp,indirect" csv:"mppt_A0_temp"` + Mppt_A0Temp *float32 `protobuf:"fixed32,91,opt,name=mppt_A0_temp,json=mpptA0Temp" json:"mppt_A0_temp,omitempty" structs:"mppt_A0_temp,indirect" csv:"mppt_A0_temp"` // @inject_tag: structs:"mppt_A1_volt_in,indirect" csv:"mppt_A1_volt_in" - Mppt_A1VoltIn *float32 `protobuf:"fixed32,92,opt,name=mppt_A1_volt_in,json=mpptA1VoltIn" json:"mppt_A1_volt_in,omitempty" structs:"mppt_A1_volt_in,indirect" csv:"mppt_A1_volt_in" structs:"mppt_A1_volt_in,indirect" csv:"mppt_A1_volt_in"` + Mppt_A1VoltIn *float32 `protobuf:"fixed32,92,opt,name=mppt_A1_volt_in,json=mpptA1VoltIn" json:"mppt_A1_volt_in,omitempty" structs:"mppt_A1_volt_in,indirect" csv:"mppt_A1_volt_in"` // @inject_tag: structs:"mppt_A1_volt_out,indirect" csv:"mppt_A1_volt_out" - Mppt_A1VoltOut *float32 `protobuf:"fixed32,93,opt,name=mppt_A1_volt_out,json=mpptA1VoltOut" json:"mppt_A1_volt_out,omitempty" structs:"mppt_A1_volt_out,indirect" csv:"mppt_A1_volt_out" structs:"mppt_A1_volt_out,indirect" csv:"mppt_A1_volt_out"` + Mppt_A1VoltOut *float32 `protobuf:"fixed32,93,opt,name=mppt_A1_volt_out,json=mpptA1VoltOut" json:"mppt_A1_volt_out,omitempty" structs:"mppt_A1_volt_out,indirect" csv:"mppt_A1_volt_out"` // @inject_tag: structs:"mppt_A1_current,indirect" csv:"mppt_A1_current" - Mppt_A1Current *float32 `protobuf:"fixed32,94,opt,name=mppt_A1_current,json=mpptA1Current" json:"mppt_A1_current,omitempty" structs:"mppt_A1_current,indirect" csv:"mppt_A1_current" structs:"mppt_A1_current,indirect" csv:"mppt_A1_current"` + Mppt_A1Current *float32 `protobuf:"fixed32,94,opt,name=mppt_A1_current,json=mpptA1Current" json:"mppt_A1_current,omitempty" structs:"mppt_A1_current,indirect" csv:"mppt_A1_current"` // @inject_tag: structs:"mppt_A1_temp,indirect" csv:"mppt_A1_temp" - Mppt_A1Temp *float32 `protobuf:"fixed32,95,opt,name=mppt_A1_temp,json=mpptA1Temp" json:"mppt_A1_temp,omitempty" structs:"mppt_A1_temp,indirect" csv:"mppt_A1_temp" structs:"mppt_A1_temp,indirect" csv:"mppt_A1_temp"` + Mppt_A1Temp *float32 `protobuf:"fixed32,95,opt,name=mppt_A1_temp,json=mpptA1Temp" json:"mppt_A1_temp,omitempty" structs:"mppt_A1_temp,indirect" csv:"mppt_A1_temp"` // @inject_tag: structs:"mppt_B0_volt_in,indirect" csv:"mppt_B0_volt_in" - Mppt_B0VoltIn *float32 `protobuf:"fixed32,96,opt,name=mppt_B0_volt_in,json=mpptB0VoltIn" json:"mppt_B0_volt_in,omitempty" structs:"mppt_B0_volt_in,indirect" csv:"mppt_B0_volt_in" structs:"mppt_B0_volt_in,indirect" csv:"mppt_B0_volt_in"` + Mppt_B0VoltIn *float32 `protobuf:"fixed32,96,opt,name=mppt_B0_volt_in,json=mpptB0VoltIn" json:"mppt_B0_volt_in,omitempty" structs:"mppt_B0_volt_in,indirect" csv:"mppt_B0_volt_in"` // @inject_tag: structs:"mppt_B0_volt_out,indirect" csv:"mppt_B0_volt_out" - Mppt_B0VoltOut *float32 `protobuf:"fixed32,97,opt,name=mppt_B0_volt_out,json=mpptB0VoltOut" json:"mppt_B0_volt_out,omitempty" structs:"mppt_B0_volt_out,indirect" csv:"mppt_B0_volt_out" structs:"mppt_B0_volt_out,indirect" csv:"mppt_B0_volt_out"` + Mppt_B0VoltOut *float32 `protobuf:"fixed32,97,opt,name=mppt_B0_volt_out,json=mpptB0VoltOut" json:"mppt_B0_volt_out,omitempty" structs:"mppt_B0_volt_out,indirect" csv:"mppt_B0_volt_out"` // @inject_tag: structs:"mppt_B0_current,indirect" csv:"mppt_B0_current" - Mppt_B0Current *float32 `protobuf:"fixed32,98,opt,name=mppt_B0_current,json=mpptB0Current" json:"mppt_B0_current,omitempty" structs:"mppt_B0_current,indirect" csv:"mppt_B0_current" structs:"mppt_B0_current,indirect" csv:"mppt_B0_current"` + Mppt_B0Current *float32 `protobuf:"fixed32,98,opt,name=mppt_B0_current,json=mpptB0Current" json:"mppt_B0_current,omitempty" structs:"mppt_B0_current,indirect" csv:"mppt_B0_current"` // @inject_tag: structs:"mppt_B0_temp,indirect" csv:"mppt_B0_temp" - Mppt_B0Temp *float32 `protobuf:"fixed32,99,opt,name=mppt_B0_temp,json=mpptB0Temp" json:"mppt_B0_temp,omitempty" structs:"mppt_B0_temp,indirect" csv:"mppt_B0_temp" structs:"mppt_B0_temp,indirect" csv:"mppt_B0_temp"` + Mppt_B0Temp *float32 `protobuf:"fixed32,99,opt,name=mppt_B0_temp,json=mpptB0Temp" json:"mppt_B0_temp,omitempty" structs:"mppt_B0_temp,indirect" csv:"mppt_B0_temp"` // @inject_tag: structs:"mppt_B1_volt_in,indirect" csv:"mppt_B1_volt_in" - Mppt_B1VoltIn *float32 `protobuf:"fixed32,100,opt,name=mppt_B1_volt_in,json=mpptB1VoltIn" json:"mppt_B1_volt_in,omitempty" structs:"mppt_B1_volt_in,indirect" csv:"mppt_B1_volt_in" structs:"mppt_B1_volt_in,indirect" csv:"mppt_B1_volt_in"` + Mppt_B1VoltIn *float32 `protobuf:"fixed32,100,opt,name=mppt_B1_volt_in,json=mpptB1VoltIn" json:"mppt_B1_volt_in,omitempty" structs:"mppt_B1_volt_in,indirect" csv:"mppt_B1_volt_in"` // @inject_tag: structs:"mppt_B1_volt_out,indirect" csv:"mppt_B1_volt_out" - Mppt_B1VoltOut *float32 `protobuf:"fixed32,101,opt,name=mppt_B1_volt_out,json=mpptB1VoltOut" json:"mppt_B1_volt_out,omitempty" structs:"mppt_B1_volt_out,indirect" csv:"mppt_B1_volt_out" structs:"mppt_B1_volt_out,indirect" csv:"mppt_B1_volt_out"` + Mppt_B1VoltOut *float32 `protobuf:"fixed32,101,opt,name=mppt_B1_volt_out,json=mpptB1VoltOut" json:"mppt_B1_volt_out,omitempty" structs:"mppt_B1_volt_out,indirect" csv:"mppt_B1_volt_out"` // @inject_tag: structs:"mppt_B1_current,indirect" csv:"mppt_B1_current" - Mppt_B1Current *float32 `protobuf:"fixed32,102,opt,name=mppt_B1_current,json=mpptB1Current" json:"mppt_B1_current,omitempty" structs:"mppt_B1_current,indirect" csv:"mppt_B1_current" structs:"mppt_B1_current,indirect" csv:"mppt_B1_current"` + Mppt_B1Current *float32 `protobuf:"fixed32,102,opt,name=mppt_B1_current,json=mpptB1Current" json:"mppt_B1_current,omitempty" structs:"mppt_B1_current,indirect" csv:"mppt_B1_current"` // @inject_tag: structs:"mppt_B1_temp,indirect" csv:"mppt_B1_temp" - Mppt_B1Temp *float32 `protobuf:"fixed32,103,opt,name=mppt_B1_temp,json=mpptB1Temp" json:"mppt_B1_temp,omitempty" structs:"mppt_B1_temp,indirect" csv:"mppt_B1_temp" structs:"mppt_B1_temp,indirect" csv:"mppt_B1_temp"` + Mppt_B1Temp *float32 `protobuf:"fixed32,103,opt,name=mppt_B1_temp,json=mpptB1Temp" json:"mppt_B1_temp,omitempty" structs:"mppt_B1_temp,indirect" csv:"mppt_B1_temp"` // @inject_tag: structs:"mppt_C0_volt_in,indirect" csv:"mppt_C0_volt_in" - Mppt_C0VoltIn *float32 `protobuf:"fixed32,104,opt,name=mppt_C0_volt_in,json=mpptC0VoltIn" json:"mppt_C0_volt_in,omitempty" structs:"mppt_C0_volt_in,indirect" csv:"mppt_C0_volt_in" structs:"mppt_C0_volt_in,indirect" csv:"mppt_C0_volt_in"` + Mppt_C0VoltIn *float32 `protobuf:"fixed32,104,opt,name=mppt_C0_volt_in,json=mpptC0VoltIn" json:"mppt_C0_volt_in,omitempty" structs:"mppt_C0_volt_in,indirect" csv:"mppt_C0_volt_in"` // @inject_tag: structs:"mppt_C0_volt_out,indirect" csv:"mppt_C0_volt_out" - Mppt_C0VoltOut *float32 `protobuf:"fixed32,105,opt,name=mppt_C0_volt_out,json=mpptC0VoltOut" json:"mppt_C0_volt_out,omitempty" structs:"mppt_C0_volt_out,indirect" csv:"mppt_C0_volt_out" structs:"mppt_C0_volt_out,indirect" csv:"mppt_C0_volt_out"` + Mppt_C0VoltOut *float32 `protobuf:"fixed32,105,opt,name=mppt_C0_volt_out,json=mpptC0VoltOut" json:"mppt_C0_volt_out,omitempty" structs:"mppt_C0_volt_out,indirect" csv:"mppt_C0_volt_out"` // @inject_tag: structs:"mppt_C0_current,indirect" csv:"mppt_C0_current" - Mppt_C0Current *float32 `protobuf:"fixed32,106,opt,name=mppt_C0_current,json=mpptC0Current" json:"mppt_C0_current,omitempty" structs:"mppt_C0_current,indirect" csv:"mppt_C0_current" structs:"mppt_C0_current,indirect" csv:"mppt_C0_current"` + Mppt_C0Current *float32 `protobuf:"fixed32,106,opt,name=mppt_C0_current,json=mpptC0Current" json:"mppt_C0_current,omitempty" structs:"mppt_C0_current,indirect" csv:"mppt_C0_current"` // @inject_tag: structs:"mppt_C0_temp,indirect" csv:"mppt_C0_temp" - Mppt_C0Temp *float32 `protobuf:"fixed32,107,opt,name=mppt_C0_temp,json=mpptC0Temp" json:"mppt_C0_temp,omitempty" structs:"mppt_C0_temp,indirect" csv:"mppt_C0_temp" structs:"mppt_C0_temp,indirect" csv:"mppt_C0_temp"` + Mppt_C0Temp *float32 `protobuf:"fixed32,107,opt,name=mppt_C0_temp,json=mpptC0Temp" json:"mppt_C0_temp,omitempty" structs:"mppt_C0_temp,indirect" csv:"mppt_C0_temp"` // @inject_tag: structs:"mppt_C1_volt_in,indirect" csv:"mppt_C1_volt_in" - Mppt_C1VoltIn *float32 `protobuf:"fixed32,108,opt,name=mppt_C1_volt_in,json=mpptC1VoltIn" json:"mppt_C1_volt_in,omitempty" structs:"mppt_C1_volt_in,indirect" csv:"mppt_C1_volt_in" structs:"mppt_C1_volt_in,indirect" csv:"mppt_C1_volt_in"` + Mppt_C1VoltIn *float32 `protobuf:"fixed32,108,opt,name=mppt_C1_volt_in,json=mpptC1VoltIn" json:"mppt_C1_volt_in,omitempty" structs:"mppt_C1_volt_in,indirect" csv:"mppt_C1_volt_in"` // @inject_tag: structs:"mppt_C1_volt_out,indirect" csv:"mppt_C1_volt_out" - Mppt_C1VoltOut *float32 `protobuf:"fixed32,109,opt,name=mppt_C1_volt_out,json=mpptC1VoltOut" json:"mppt_C1_volt_out,omitempty" structs:"mppt_C1_volt_out,indirect" csv:"mppt_C1_volt_out" structs:"mppt_C1_volt_out,indirect" csv:"mppt_C1_volt_out"` + Mppt_C1VoltOut *float32 `protobuf:"fixed32,109,opt,name=mppt_C1_volt_out,json=mpptC1VoltOut" json:"mppt_C1_volt_out,omitempty" structs:"mppt_C1_volt_out,indirect" csv:"mppt_C1_volt_out"` // @inject_tag: structs:"mppt_C1_current,indirect" csv:"mppt_C1_current" - Mppt_C1Current *float32 `protobuf:"fixed32,110,opt,name=mppt_C1_current,json=mpptC1Current" json:"mppt_C1_current,omitempty" structs:"mppt_C1_current,indirect" csv:"mppt_C1_current" structs:"mppt_C1_current,indirect" csv:"mppt_C1_current"` + Mppt_C1Current *float32 `protobuf:"fixed32,110,opt,name=mppt_C1_current,json=mpptC1Current" json:"mppt_C1_current,omitempty" structs:"mppt_C1_current,indirect" csv:"mppt_C1_current"` // @inject_tag: structs:"mppt_C1_temp,indirect" csv:"mppt_C1_temp" - Mppt_C1Temp *float32 `protobuf:"fixed32,111,opt,name=mppt_C1_temp,json=mpptC1Temp" json:"mppt_C1_temp,omitempty" structs:"mppt_C1_temp,indirect" csv:"mppt_C1_temp" structs:"mppt_C1_temp,indirect" csv:"mppt_C1_temp"` + Mppt_C1Temp *float32 `protobuf:"fixed32,111,opt,name=mppt_C1_temp,json=mpptC1Temp" json:"mppt_C1_temp,omitempty" structs:"mppt_C1_temp,indirect" csv:"mppt_C1_temp"` // @inject_tag: structs:"mppt_D0_volt_in,indirect" csv:"mppt_D0_volt_in" - Mppt_D0VoltIn *float32 `protobuf:"fixed32,112,opt,name=mppt_D0_volt_in,json=mpptD0VoltIn" json:"mppt_D0_volt_in,omitempty" structs:"mppt_D0_volt_in,indirect" csv:"mppt_D0_volt_in" structs:"mppt_D0_volt_in,indirect" csv:"mppt_D0_volt_in"` + Mppt_D0VoltIn *float32 `protobuf:"fixed32,112,opt,name=mppt_D0_volt_in,json=mpptD0VoltIn" json:"mppt_D0_volt_in,omitempty" structs:"mppt_D0_volt_in,indirect" csv:"mppt_D0_volt_in"` // @inject_tag: structs:"mppt_D0_volt_out,indirect" csv:"mppt_D0_volt_out" - Mppt_D0VoltOut *float32 `protobuf:"fixed32,113,opt,name=mppt_D0_volt_out,json=mpptD0VoltOut" json:"mppt_D0_volt_out,omitempty" structs:"mppt_D0_volt_out,indirect" csv:"mppt_D0_volt_out" structs:"mppt_D0_volt_out,indirect" csv:"mppt_D0_volt_out"` + Mppt_D0VoltOut *float32 `protobuf:"fixed32,113,opt,name=mppt_D0_volt_out,json=mpptD0VoltOut" json:"mppt_D0_volt_out,omitempty" structs:"mppt_D0_volt_out,indirect" csv:"mppt_D0_volt_out"` // @inject_tag: structs:"mppt_D0_current,indirect" csv:"mppt_D0_current" - Mppt_D0Current *float32 `protobuf:"fixed32,114,opt,name=mppt_D0_current,json=mpptD0Current" json:"mppt_D0_current,omitempty" structs:"mppt_D0_current,indirect" csv:"mppt_D0_current" structs:"mppt_D0_current,indirect" csv:"mppt_D0_current"` + Mppt_D0Current *float32 `protobuf:"fixed32,114,opt,name=mppt_D0_current,json=mpptD0Current" json:"mppt_D0_current,omitempty" structs:"mppt_D0_current,indirect" csv:"mppt_D0_current"` // @inject_tag: structs:"mppt_D0_temp,indirect" csv:"mppt_D0_temp" - Mppt_D0Temp *float32 `protobuf:"fixed32,115,opt,name=mppt_D0_temp,json=mpptD0Temp" json:"mppt_D0_temp,omitempty" structs:"mppt_D0_temp,indirect" csv:"mppt_D0_temp" structs:"mppt_D0_temp,indirect" csv:"mppt_D0_temp"` + Mppt_D0Temp *float32 `protobuf:"fixed32,115,opt,name=mppt_D0_temp,json=mpptD0Temp" json:"mppt_D0_temp,omitempty" structs:"mppt_D0_temp,indirect" csv:"mppt_D0_temp"` // @inject_tag: structs:"mppt_D1_volt_in,indirect" csv:"mppt_D1_volt_in" - Mppt_D1VoltIn *float32 `protobuf:"fixed32,116,opt,name=mppt_D1_volt_in,json=mpptD1VoltIn" json:"mppt_D1_volt_in,omitempty" structs:"mppt_D1_volt_in,indirect" csv:"mppt_D1_volt_in" structs:"mppt_D1_volt_in,indirect" csv:"mppt_D1_volt_in"` + Mppt_D1VoltIn *float32 `protobuf:"fixed32,116,opt,name=mppt_D1_volt_in,json=mpptD1VoltIn" json:"mppt_D1_volt_in,omitempty" structs:"mppt_D1_volt_in,indirect" csv:"mppt_D1_volt_in"` // @inject_tag: structs:"mppt_D1_volt_out,indirect" csv:"mppt_D1_volt_out" - Mppt_D1VoltOut *float32 `protobuf:"fixed32,117,opt,name=mppt_D1_volt_out,json=mpptD1VoltOut" json:"mppt_D1_volt_out,omitempty" structs:"mppt_D1_volt_out,indirect" csv:"mppt_D1_volt_out" structs:"mppt_D1_volt_out,indirect" csv:"mppt_D1_volt_out"` + Mppt_D1VoltOut *float32 `protobuf:"fixed32,117,opt,name=mppt_D1_volt_out,json=mpptD1VoltOut" json:"mppt_D1_volt_out,omitempty" structs:"mppt_D1_volt_out,indirect" csv:"mppt_D1_volt_out"` // @inject_tag: structs:"mppt_D1_current,indirect" csv:"mppt_D1_current" - Mppt_D1Current *float32 `protobuf:"fixed32,118,opt,name=mppt_D1_current,json=mpptD1Current" json:"mppt_D1_current,omitempty" structs:"mppt_D1_current,indirect" csv:"mppt_D1_current" structs:"mppt_D1_current,indirect" csv:"mppt_D1_current"` + Mppt_D1Current *float32 `protobuf:"fixed32,118,opt,name=mppt_D1_current,json=mpptD1Current" json:"mppt_D1_current,omitempty" structs:"mppt_D1_current,indirect" csv:"mppt_D1_current"` // @inject_tag: structs:"mppt_D1_temp,indirect" csv:"mppt_D1_temp" - Mppt_D1Temp *float32 `protobuf:"fixed32,119,opt,name=mppt_D1_temp,json=mpptD1Temp" json:"mppt_D1_temp,omitempty" structs:"mppt_D1_temp,indirect" csv:"mppt_D1_temp" structs:"mppt_D1_temp,indirect" csv:"mppt_D1_temp"` + Mppt_D1Temp *float32 `protobuf:"fixed32,119,opt,name=mppt_D1_temp,json=mpptD1Temp" json:"mppt_D1_temp,omitempty" structs:"mppt_D1_temp,indirect" csv:"mppt_D1_temp"` // @inject_tag: structs:"cell_volt_1,indirect" csv:"cell_volt_1" - CellVolt_1 *float32 `protobuf:"fixed32,120,opt,name=cell_volt_1,json=cellVolt1" json:"cell_volt_1,omitempty" structs:"cell_volt_1,indirect" csv:"cell_volt_1" structs:"cell_volt_1,indirect" csv:"cell_volt_1"` + CellVolt_1 *float32 `protobuf:"fixed32,120,opt,name=cell_volt_1,json=cellVolt1" json:"cell_volt_1,omitempty" structs:"cell_volt_1,indirect" csv:"cell_volt_1"` // @inject_tag: structs:"cell_volt_2,indirect" csv:"cell_volt_2" - CellVolt_2 *float32 `protobuf:"fixed32,121,opt,name=cell_volt_2,json=cellVolt2" json:"cell_volt_2,omitempty" structs:"cell_volt_2,indirect" csv:"cell_volt_2" structs:"cell_volt_2,indirect" csv:"cell_volt_2"` + CellVolt_2 *float32 `protobuf:"fixed32,121,opt,name=cell_volt_2,json=cellVolt2" json:"cell_volt_2,omitempty" structs:"cell_volt_2,indirect" csv:"cell_volt_2"` // @inject_tag: structs:"cell_volt_3,indirect" csv:"cell_volt_3" - CellVolt_3 *float32 `protobuf:"fixed32,122,opt,name=cell_volt_3,json=cellVolt3" json:"cell_volt_3,omitempty" structs:"cell_volt_3,indirect" csv:"cell_volt_3" structs:"cell_volt_3,indirect" csv:"cell_volt_3"` + CellVolt_3 *float32 `protobuf:"fixed32,122,opt,name=cell_volt_3,json=cellVolt3" json:"cell_volt_3,omitempty" structs:"cell_volt_3,indirect" csv:"cell_volt_3"` // @inject_tag: structs:"cell_volt_4,indirect" csv:"cell_volt_4" - CellVolt_4 *float32 `protobuf:"fixed32,123,opt,name=cell_volt_4,json=cellVolt4" json:"cell_volt_4,omitempty" structs:"cell_volt_4,indirect" csv:"cell_volt_4" structs:"cell_volt_4,indirect" csv:"cell_volt_4"` + CellVolt_4 *float32 `protobuf:"fixed32,123,opt,name=cell_volt_4,json=cellVolt4" json:"cell_volt_4,omitempty" structs:"cell_volt_4,indirect" csv:"cell_volt_4"` // @inject_tag: structs:"cell_volt_5,indirect" csv:"cell_volt_5" - CellVolt_5 *float32 `protobuf:"fixed32,124,opt,name=cell_volt_5,json=cellVolt5" json:"cell_volt_5,omitempty" structs:"cell_volt_5,indirect" csv:"cell_volt_5" structs:"cell_volt_5,indirect" csv:"cell_volt_5"` + CellVolt_5 *float32 `protobuf:"fixed32,124,opt,name=cell_volt_5,json=cellVolt5" json:"cell_volt_5,omitempty" structs:"cell_volt_5,indirect" csv:"cell_volt_5"` // @inject_tag: structs:"cell_volt_6,indirect" csv:"cell_volt_6" - CellVolt_6 *float32 `protobuf:"fixed32,125,opt,name=cell_volt_6,json=cellVolt6" json:"cell_volt_6,omitempty" structs:"cell_volt_6,indirect" csv:"cell_volt_6" structs:"cell_volt_6,indirect" csv:"cell_volt_6"` + CellVolt_6 *float32 `protobuf:"fixed32,125,opt,name=cell_volt_6,json=cellVolt6" json:"cell_volt_6,omitempty" structs:"cell_volt_6,indirect" csv:"cell_volt_6"` // @inject_tag: structs:"cell_volt_7,indirect" csv:"cell_volt_7" - CellVolt_7 *float32 `protobuf:"fixed32,126,opt,name=cell_volt_7,json=cellVolt7" json:"cell_volt_7,omitempty" structs:"cell_volt_7,indirect" csv:"cell_volt_7" structs:"cell_volt_7,indirect" csv:"cell_volt_7"` + CellVolt_7 *float32 `protobuf:"fixed32,126,opt,name=cell_volt_7,json=cellVolt7" json:"cell_volt_7,omitempty" structs:"cell_volt_7,indirect" csv:"cell_volt_7"` // @inject_tag: structs:"cell_volt_8,indirect" csv:"cell_volt_8" - CellVolt_8 *float32 `protobuf:"fixed32,127,opt,name=cell_volt_8,json=cellVolt8" json:"cell_volt_8,omitempty" structs:"cell_volt_8,indirect" csv:"cell_volt_8" structs:"cell_volt_8,indirect" csv:"cell_volt_8"` + CellVolt_8 *float32 `protobuf:"fixed32,127,opt,name=cell_volt_8,json=cellVolt8" json:"cell_volt_8,omitempty" structs:"cell_volt_8,indirect" csv:"cell_volt_8"` // @inject_tag: structs:"cell_volt_9,indirect" csv:"cell_volt_9" - CellVolt_9 *float32 `protobuf:"fixed32,128,opt,name=cell_volt_9,json=cellVolt9" json:"cell_volt_9,omitempty" structs:"cell_volt_9,indirect" csv:"cell_volt_9" structs:"cell_volt_9,indirect" csv:"cell_volt_9"` + CellVolt_9 *float32 `protobuf:"fixed32,128,opt,name=cell_volt_9,json=cellVolt9" json:"cell_volt_9,omitempty" structs:"cell_volt_9,indirect" csv:"cell_volt_9"` // @inject_tag: structs:"cell_volt_10,indirect" csv:"cell_volt_10" - CellVolt_10 *float32 `protobuf:"fixed32,129,opt,name=cell_volt_10,json=cellVolt10" json:"cell_volt_10,omitempty" structs:"cell_volt_10,indirect" csv:"cell_volt_10" structs:"cell_volt_10,indirect" csv:"cell_volt_10"` + CellVolt_10 *float32 `protobuf:"fixed32,129,opt,name=cell_volt_10,json=cellVolt10" json:"cell_volt_10,omitempty" structs:"cell_volt_10,indirect" csv:"cell_volt_10"` // @inject_tag: structs:"cell_volt_11,indirect" csv:"cell_volt_11" - CellVolt_11 *float32 `protobuf:"fixed32,130,opt,name=cell_volt_11,json=cellVolt11" json:"cell_volt_11,omitempty" structs:"cell_volt_11,indirect" csv:"cell_volt_11" structs:"cell_volt_11,indirect" csv:"cell_volt_11"` + CellVolt_11 *float32 `protobuf:"fixed32,130,opt,name=cell_volt_11,json=cellVolt11" json:"cell_volt_11,omitempty" structs:"cell_volt_11,indirect" csv:"cell_volt_11"` // @inject_tag: structs:"cell_volt_12,indirect" csv:"cell_volt_12" - CellVolt_12 *float32 `protobuf:"fixed32,131,opt,name=cell_volt_12,json=cellVolt12" json:"cell_volt_12,omitempty" structs:"cell_volt_12,indirect" csv:"cell_volt_12" structs:"cell_volt_12,indirect" csv:"cell_volt_12"` + CellVolt_12 *float32 `protobuf:"fixed32,131,opt,name=cell_volt_12,json=cellVolt12" json:"cell_volt_12,omitempty" structs:"cell_volt_12,indirect" csv:"cell_volt_12"` // @inject_tag: structs:"cell_volt_13,indirect" csv:"cell_volt_13" - CellVolt_13 *float32 `protobuf:"fixed32,132,opt,name=cell_volt_13,json=cellVolt13" json:"cell_volt_13,omitempty" structs:"cell_volt_13,indirect" csv:"cell_volt_13" structs:"cell_volt_13,indirect" csv:"cell_volt_13"` + CellVolt_13 *float32 `protobuf:"fixed32,132,opt,name=cell_volt_13,json=cellVolt13" json:"cell_volt_13,omitempty" structs:"cell_volt_13,indirect" csv:"cell_volt_13"` // @inject_tag: structs:"cell_volt_14,indirect" csv:"cell_volt_14" - CellVolt_14 *float32 `protobuf:"fixed32,133,opt,name=cell_volt_14,json=cellVolt14" json:"cell_volt_14,omitempty" structs:"cell_volt_14,indirect" csv:"cell_volt_14" structs:"cell_volt_14,indirect" csv:"cell_volt_14"` + CellVolt_14 *float32 `protobuf:"fixed32,133,opt,name=cell_volt_14,json=cellVolt14" json:"cell_volt_14,omitempty" structs:"cell_volt_14,indirect" csv:"cell_volt_14"` // @inject_tag: structs:"cell_volt_15,indirect" csv:"cell_volt_15" - CellVolt_15 *float32 `protobuf:"fixed32,134,opt,name=cell_volt_15,json=cellVolt15" json:"cell_volt_15,omitempty" structs:"cell_volt_15,indirect" csv:"cell_volt_15" structs:"cell_volt_15,indirect" csv:"cell_volt_15"` + CellVolt_15 *float32 `protobuf:"fixed32,134,opt,name=cell_volt_15,json=cellVolt15" json:"cell_volt_15,omitempty" structs:"cell_volt_15,indirect" csv:"cell_volt_15"` // @inject_tag: structs:"cell_volt_16,indirect" csv:"cell_volt_16" - CellVolt_16 *float32 `protobuf:"fixed32,135,opt,name=cell_volt_16,json=cellVolt16" json:"cell_volt_16,omitempty" structs:"cell_volt_16,indirect" csv:"cell_volt_16" structs:"cell_volt_16,indirect" csv:"cell_volt_16"` + CellVolt_16 *float32 `protobuf:"fixed32,135,opt,name=cell_volt_16,json=cellVolt16" json:"cell_volt_16,omitempty" structs:"cell_volt_16,indirect" csv:"cell_volt_16"` // @inject_tag: structs:"cell_volt_17,indirect" csv:"cell_volt_17" - CellVolt_17 *float32 `protobuf:"fixed32,136,opt,name=cell_volt_17,json=cellVolt17" json:"cell_volt_17,omitempty" structs:"cell_volt_17,indirect" csv:"cell_volt_17" structs:"cell_volt_17,indirect" csv:"cell_volt_17"` + CellVolt_17 *float32 `protobuf:"fixed32,136,opt,name=cell_volt_17,json=cellVolt17" json:"cell_volt_17,omitempty" structs:"cell_volt_17,indirect" csv:"cell_volt_17"` // @inject_tag: structs:"cell_volt_18,indirect" csv:"cell_volt_18" - CellVolt_18 *float32 `protobuf:"fixed32,137,opt,name=cell_volt_18,json=cellVolt18" json:"cell_volt_18,omitempty" structs:"cell_volt_18,indirect" csv:"cell_volt_18" structs:"cell_volt_18,indirect" csv:"cell_volt_18"` + CellVolt_18 *float32 `protobuf:"fixed32,137,opt,name=cell_volt_18,json=cellVolt18" json:"cell_volt_18,omitempty" structs:"cell_volt_18,indirect" csv:"cell_volt_18"` // @inject_tag: structs:"cell_volt_19,indirect" csv:"cell_volt_19" - CellVolt_19 *float32 `protobuf:"fixed32,138,opt,name=cell_volt_19,json=cellVolt19" json:"cell_volt_19,omitempty" structs:"cell_volt_19,indirect" csv:"cell_volt_19" structs:"cell_volt_19,indirect" csv:"cell_volt_19"` + CellVolt_19 *float32 `protobuf:"fixed32,138,opt,name=cell_volt_19,json=cellVolt19" json:"cell_volt_19,omitempty" structs:"cell_volt_19,indirect" csv:"cell_volt_19"` // @inject_tag: structs:"cell_volt_20,indirect" csv:"cell_volt_20" - CellVolt_20 *float32 `protobuf:"fixed32,139,opt,name=cell_volt_20,json=cellVolt20" json:"cell_volt_20,omitempty" structs:"cell_volt_20,indirect" csv:"cell_volt_20" structs:"cell_volt_20,indirect" csv:"cell_volt_20"` + CellVolt_20 *float32 `protobuf:"fixed32,139,opt,name=cell_volt_20,json=cellVolt20" json:"cell_volt_20,omitempty" structs:"cell_volt_20,indirect" csv:"cell_volt_20"` // @inject_tag: structs:"cell_volt_21,indirect" csv:"cell_volt_21" - CellVolt_21 *float32 `protobuf:"fixed32,140,opt,name=cell_volt_21,json=cellVolt21" json:"cell_volt_21,omitempty" structs:"cell_volt_21,indirect" csv:"cell_volt_21" structs:"cell_volt_21,indirect" csv:"cell_volt_21"` + CellVolt_21 *float32 `protobuf:"fixed32,140,opt,name=cell_volt_21,json=cellVolt21" json:"cell_volt_21,omitempty" structs:"cell_volt_21,indirect" csv:"cell_volt_21"` // @inject_tag: structs:"cell_volt_22,indirect" csv:"cell_volt_22" - CellVolt_22 *float32 `protobuf:"fixed32,141,opt,name=cell_volt_22,json=cellVolt22" json:"cell_volt_22,omitempty" structs:"cell_volt_22,indirect" csv:"cell_volt_22" structs:"cell_volt_22,indirect" csv:"cell_volt_22"` + CellVolt_22 *float32 `protobuf:"fixed32,141,opt,name=cell_volt_22,json=cellVolt22" json:"cell_volt_22,omitempty" structs:"cell_volt_22,indirect" csv:"cell_volt_22"` // @inject_tag: structs:"cell_volt_23,indirect" csv:"cell_volt_23" - CellVolt_23 *float32 `protobuf:"fixed32,142,opt,name=cell_volt_23,json=cellVolt23" json:"cell_volt_23,omitempty" structs:"cell_volt_23,indirect" csv:"cell_volt_23" structs:"cell_volt_23,indirect" csv:"cell_volt_23"` + CellVolt_23 *float32 `protobuf:"fixed32,142,opt,name=cell_volt_23,json=cellVolt23" json:"cell_volt_23,omitempty" structs:"cell_volt_23,indirect" csv:"cell_volt_23"` // @inject_tag: structs:"cell_volt_24,indirect" csv:"cell_volt_24" - CellVolt_24 *float32 `protobuf:"fixed32,143,opt,name=cell_volt_24,json=cellVolt24" json:"cell_volt_24,omitempty" structs:"cell_volt_24,indirect" csv:"cell_volt_24" structs:"cell_volt_24,indirect" csv:"cell_volt_24"` + CellVolt_24 *float32 `protobuf:"fixed32,143,opt,name=cell_volt_24,json=cellVolt24" json:"cell_volt_24,omitempty" structs:"cell_volt_24,indirect" csv:"cell_volt_24"` // @inject_tag: structs:"cell_volt_25,indirect" csv:"cell_volt_25" - CellVolt_25 *float32 `protobuf:"fixed32,144,opt,name=cell_volt_25,json=cellVolt25" json:"cell_volt_25,omitempty" structs:"cell_volt_25,indirect" csv:"cell_volt_25" structs:"cell_volt_25,indirect" csv:"cell_volt_25"` + CellVolt_25 *float32 `protobuf:"fixed32,144,opt,name=cell_volt_25,json=cellVolt25" json:"cell_volt_25,omitempty" structs:"cell_volt_25,indirect" csv:"cell_volt_25"` // @inject_tag: structs:"cell_volt_26,indirect" csv:"cell_volt_26" - CellVolt_26 *float32 `protobuf:"fixed32,145,opt,name=cell_volt_26,json=cellVolt26" json:"cell_volt_26,omitempty" structs:"cell_volt_26,indirect" csv:"cell_volt_26" structs:"cell_volt_26,indirect" csv:"cell_volt_26"` + CellVolt_26 *float32 `protobuf:"fixed32,145,opt,name=cell_volt_26,json=cellVolt26" json:"cell_volt_26,omitempty" structs:"cell_volt_26,indirect" csv:"cell_volt_26"` // @inject_tag: structs:"cell_volt_27,indirect" csv:"cell_volt_27" - CellVolt_27 *float32 `protobuf:"fixed32,146,opt,name=cell_volt_27,json=cellVolt27" json:"cell_volt_27,omitempty" structs:"cell_volt_27,indirect" csv:"cell_volt_27" structs:"cell_volt_27,indirect" csv:"cell_volt_27"` + CellVolt_27 *float32 `protobuf:"fixed32,146,opt,name=cell_volt_27,json=cellVolt27" json:"cell_volt_27,omitempty" structs:"cell_volt_27,indirect" csv:"cell_volt_27"` // @inject_tag: structs:"cell_volt_28,indirect" csv:"cell_volt_28" - CellVolt_28 *float32 `protobuf:"fixed32,147,opt,name=cell_volt_28,json=cellVolt28" json:"cell_volt_28,omitempty" structs:"cell_volt_28,indirect" csv:"cell_volt_28" structs:"cell_volt_28,indirect" csv:"cell_volt_28"` + CellVolt_28 *float32 `protobuf:"fixed32,147,opt,name=cell_volt_28,json=cellVolt28" json:"cell_volt_28,omitempty" structs:"cell_volt_28,indirect" csv:"cell_volt_28"` // @inject_tag: structs:"cell_volt_29,indirect" csv:"cell_volt_29" - CellVolt_29 *float32 `protobuf:"fixed32,148,opt,name=cell_volt_29,json=cellVolt29" json:"cell_volt_29,omitempty" structs:"cell_volt_29,indirect" csv:"cell_volt_29" structs:"cell_volt_29,indirect" csv:"cell_volt_29"` + CellVolt_29 *float32 `protobuf:"fixed32,148,opt,name=cell_volt_29,json=cellVolt29" json:"cell_volt_29,omitempty" structs:"cell_volt_29,indirect" csv:"cell_volt_29"` // @inject_tag: structs:"cell_volt_30,indirect" csv:"cell_volt_30" - CellVolt_30 *float32 `protobuf:"fixed32,149,opt,name=cell_volt_30,json=cellVolt30" json:"cell_volt_30,omitempty" structs:"cell_volt_30,indirect" csv:"cell_volt_30" structs:"cell_volt_30,indirect" csv:"cell_volt_30"` + CellVolt_30 *float32 `protobuf:"fixed32,149,opt,name=cell_volt_30,json=cellVolt30" json:"cell_volt_30,omitempty" structs:"cell_volt_30,indirect" csv:"cell_volt_30"` // @inject_tag: structs:"cell_volt_31,indirect" csv:"cell_volt_31" - CellVolt_31 *float32 `protobuf:"fixed32,150,opt,name=cell_volt_31,json=cellVolt31" json:"cell_volt_31,omitempty" structs:"cell_volt_31,indirect" csv:"cell_volt_31" structs:"cell_volt_31,indirect" csv:"cell_volt_31"` + CellVolt_31 *float32 `protobuf:"fixed32,150,opt,name=cell_volt_31,json=cellVolt31" json:"cell_volt_31,omitempty" structs:"cell_volt_31,indirect" csv:"cell_volt_31"` // @inject_tag: structs:"cell_volt_min,indirect" csv:"cell_volt_min" - CellVoltMin *float32 `protobuf:"fixed32,151,opt,name=cell_volt_min,json=cellVoltMin" json:"cell_volt_min,omitempty" structs:"cell_volt_min,indirect" csv:"cell_volt_min" structs:"cell_volt_min,indirect" csv:"cell_volt_min"` + CellVoltMin *float32 `protobuf:"fixed32,151,opt,name=cell_volt_min,json=cellVoltMin" json:"cell_volt_min,omitempty" structs:"cell_volt_min,indirect" csv:"cell_volt_min"` // @inject_tag: structs:"cell_volt_max,indirect" csv:"cell_volt_max" - CellVoltMax *float32 `protobuf:"fixed32,152,opt,name=cell_volt_max,json=cellVoltMax" json:"cell_volt_max,omitempty" structs:"cell_volt_max,indirect" csv:"cell_volt_max" structs:"cell_volt_max,indirect" csv:"cell_volt_max"` + CellVoltMax *float32 `protobuf:"fixed32,152,opt,name=cell_volt_max,json=cellVoltMax" json:"cell_volt_max,omitempty" structs:"cell_volt_max,indirect" csv:"cell_volt_max"` // @inject_tag: structs:"cell_volt_avg,indirect" csv:"cell_volt_avg" - CellVoltAvg *float32 `protobuf:"fixed32,153,opt,name=cell_volt_avg,json=cellVoltAvg" json:"cell_volt_avg,omitempty" structs:"cell_volt_avg,indirect" csv:"cell_volt_avg" structs:"cell_volt_avg,indirect" csv:"cell_volt_avg"` + CellVoltAvg *float32 `protobuf:"fixed32,153,opt,name=cell_volt_avg,json=cellVoltAvg" json:"cell_volt_avg,omitempty" structs:"cell_volt_avg,indirect" csv:"cell_volt_avg"` // @inject_tag: structs:"cell_volt_diff,indirect" csv:"cell_volt_diff" - CellVoltDiff *float32 `protobuf:"fixed32,154,opt,name=cell_volt_diff,json=cellVoltDiff" json:"cell_volt_diff,omitempty" structs:"cell_volt_diff,indirect" csv:"cell_volt_diff" structs:"cell_volt_diff,indirect" csv:"cell_volt_diff"` + CellVoltDiff *float32 `protobuf:"fixed32,154,opt,name=cell_volt_diff,json=cellVoltDiff" json:"cell_volt_diff,omitempty" structs:"cell_volt_diff,indirect" csv:"cell_volt_diff"` // @inject_tag: structs:"power_save_on,indirect" csv:"power_save_on" - PowerSaveOn *int32 `protobuf:"varint,155,opt,name=power_save_on,json=powerSaveOn" json:"power_save_on,omitempty" structs:"power_save_on,indirect" csv:"power_save_on" structs:"power_save_on,indirect" csv:"power_save_on"` + PowerSaveOn *int32 `protobuf:"varint,155,opt,name=power_save_on,json=powerSaveOn" json:"power_save_on,omitempty" structs:"power_save_on,indirect" csv:"power_save_on"` // @inject_tag: structs:"rearview_on,indirect" csv:"rearview_on" - RearviewOn *int32 `protobuf:"varint,156,opt,name=rearview_on,json=rearviewOn" json:"rearview_on,omitempty" structs:"rearview_on,indirect" csv:"rearview_on" structs:"rearview_on,indirect" csv:"rearview_on"` + RearviewOn *int32 `protobuf:"varint,156,opt,name=rearview_on,json=rearviewOn" json:"rearview_on,omitempty" structs:"rearview_on,indirect" csv:"rearview_on"` // @inject_tag: structs:"mic_enabled,indirect" csv:"mic_enabled" - MicEnabled *int32 `protobuf:"varint,157,opt,name=mic_enabled,json=micEnabled" json:"mic_enabled,omitempty" structs:"mic_enabled,indirect" csv:"mic_enabled" structs:"mic_enabled,indirect" csv:"mic_enabled"` + MicEnabled *int32 `protobuf:"varint,157,opt,name=mic_enabled,json=micEnabled" json:"mic_enabled,omitempty" structs:"mic_enabled,indirect" csv:"mic_enabled"` // @inject_tag: structs:"imu_temp,indirect" csv:"imu_temp" - ImuTemp *int32 `protobuf:"varint,158,opt,name=imu_temp,json=imuTemp" json:"imu_temp,omitempty" structs:"imu_temp,indirect" csv:"imu_temp" structs:"imu_temp,indirect" csv:"imu_temp"` + ImuTemp *int32 `protobuf:"varint,158,opt,name=imu_temp,json=imuTemp" json:"imu_temp,omitempty" structs:"imu_temp,indirect" csv:"imu_temp"` // @inject_tag: structs:"imu_magnet_x,indirect" csv:"imu_magnet_x" - ImuMagnetX *int32 `protobuf:"varint,159,opt,name=imu_magnet_x,json=imuMagnetX" json:"imu_magnet_x,omitempty" structs:"imu_magnet_x,indirect" csv:"imu_magnet_x" structs:"imu_magnet_x,indirect" csv:"imu_magnet_x"` + ImuMagnetX *int32 `protobuf:"varint,159,opt,name=imu_magnet_x,json=imuMagnetX" json:"imu_magnet_x,omitempty" structs:"imu_magnet_x,indirect" csv:"imu_magnet_x"` // @inject_tag: structs:"imu_magnet_y,indirect" csv:"imu_magnet_y" - ImuMagnetY *int32 `protobuf:"varint,160,opt,name=imu_magnet_y,json=imuMagnetY" json:"imu_magnet_y,omitempty" structs:"imu_magnet_y,indirect" csv:"imu_magnet_y" structs:"imu_magnet_y,indirect" csv:"imu_magnet_y"` + ImuMagnetY *int32 `protobuf:"varint,160,opt,name=imu_magnet_y,json=imuMagnetY" json:"imu_magnet_y,omitempty" structs:"imu_magnet_y,indirect" csv:"imu_magnet_y"` // @inject_tag: structs:"imu_magnet_z,indirect" csv:"imu_magnet_z" - ImuMagnetZ *int32 `protobuf:"varint,161,opt,name=imu_magnet_z,json=imuMagnetZ" json:"imu_magnet_z,omitempty" structs:"imu_magnet_z,indirect" csv:"imu_magnet_z" structs:"imu_magnet_z,indirect" csv:"imu_magnet_z"` + ImuMagnetZ *int32 `protobuf:"varint,161,opt,name=imu_magnet_z,json=imuMagnetZ" json:"imu_magnet_z,omitempty" structs:"imu_magnet_z,indirect" csv:"imu_magnet_z"` // @inject_tag: structs:"imu_gyro_x,indirect" csv:"imu_gyro_x" - ImuGyroX *int32 `protobuf:"varint,162,opt,name=imu_gyro_x,json=imuGyroX" json:"imu_gyro_x,omitempty" structs:"imu_gyro_x,indirect" csv:"imu_gyro_x" structs:"imu_gyro_x,indirect" csv:"imu_gyro_x"` + ImuGyroX *int32 `protobuf:"varint,162,opt,name=imu_gyro_x,json=imuGyroX" json:"imu_gyro_x,omitempty" structs:"imu_gyro_x,indirect" csv:"imu_gyro_x"` // @inject_tag: structs:"imu_gyro_y,indirect" csv:"imu_gyro_y" - ImuGyroY *int32 `protobuf:"varint,163,opt,name=imu_gyro_y,json=imuGyroY" json:"imu_gyro_y,omitempty" structs:"imu_gyro_y,indirect" csv:"imu_gyro_y" structs:"imu_gyro_y,indirect" csv:"imu_gyro_y"` + ImuGyroY *int32 `protobuf:"varint,163,opt,name=imu_gyro_y,json=imuGyroY" json:"imu_gyro_y,omitempty" structs:"imu_gyro_y,indirect" csv:"imu_gyro_y"` // @inject_tag: structs:"imu_gyro_z,indirect" csv:"imu_gyro_z" - ImuGyroZ *int32 `protobuf:"varint,164,opt,name=imu_gyro_z,json=imuGyroZ" json:"imu_gyro_z,omitempty" structs:"imu_gyro_z,indirect" csv:"imu_gyro_z" structs:"imu_gyro_z,indirect" csv:"imu_gyro_z"` + ImuGyroZ *int32 `protobuf:"varint,164,opt,name=imu_gyro_z,json=imuGyroZ" json:"imu_gyro_z,omitempty" structs:"imu_gyro_z,indirect" csv:"imu_gyro_z"` // @inject_tag: structs:"imu_accel_x,indirect" csv:"imu_accel_x" - ImuAccelX *int32 `protobuf:"varint,165,opt,name=imu_accel_x,json=imuAccelX" json:"imu_accel_x,omitempty" structs:"imu_accel_x,indirect" csv:"imu_accel_x" structs:"imu_accel_x,indirect" csv:"imu_accel_x"` + ImuAccelX *int32 `protobuf:"varint,165,opt,name=imu_accel_x,json=imuAccelX" json:"imu_accel_x,omitempty" structs:"imu_accel_x,indirect" csv:"imu_accel_x"` // @inject_tag: structs:"imu_accel_y,indirect" csv:"imu_accel_y" - ImuAccelY *int32 `protobuf:"varint,166,opt,name=imu_accel_y,json=imuAccelY" json:"imu_accel_y,omitempty" structs:"imu_accel_y,indirect" csv:"imu_accel_y" structs:"imu_accel_y,indirect" csv:"imu_accel_y"` + ImuAccelY *int32 `protobuf:"varint,166,opt,name=imu_accel_y,json=imuAccelY" json:"imu_accel_y,omitempty" structs:"imu_accel_y,indirect" csv:"imu_accel_y"` // @inject_tag: structs:"imu_accel_z,indirect" csv:"imu_accel_z" - ImuAccelZ *int32 `protobuf:"varint,167,opt,name=imu_accel_z,json=imuAccelZ" json:"imu_accel_z,omitempty" structs:"imu_accel_z,indirect" csv:"imu_accel_z" structs:"imu_accel_z,indirect" csv:"imu_accel_z"` + ImuAccelZ *int32 `protobuf:"varint,167,opt,name=imu_accel_z,json=imuAccelZ" json:"imu_accel_z,omitempty" structs:"imu_accel_z,indirect" csv:"imu_accel_z"` // @inject_tag: structs:"bms_left_motor_controller_current,indirect" csv:"bms_left_motor_controller_current" - BmsLeftMotorControllerCurrent *float32 `protobuf:"fixed32,168,opt,name=bms_left_motor_controller_current,json=bmsLeftMotorControllerCurrent" json:"bms_left_motor_controller_current,omitempty" structs:"bms_left_motor_controller_current,indirect" csv:"bms_left_motor_controller_current" structs:"bms_left_motor_controller_current,indirect" csv:"bms_left_motor_controller_current"` + BmsLeftMotorControllerCurrent *float32 `protobuf:"fixed32,168,opt,name=bms_left_motor_controller_current,json=bmsLeftMotorControllerCurrent" json:"bms_left_motor_controller_current,omitempty" structs:"bms_left_motor_controller_current,indirect" csv:"bms_left_motor_controller_current"` // @inject_tag: structs:"bms_right_motor_controller_current,indirect" csv:"bms_right_motor_controller_current" - BmsRightMotorControllerCurrent *float32 `protobuf:"fixed32,169,opt,name=bms_right_motor_controller_current,json=bmsRightMotorControllerCurrent" json:"bms_right_motor_controller_current,omitempty" structs:"bms_right_motor_controller_current,indirect" csv:"bms_right_motor_controller_current" structs:"bms_right_motor_controller_current,indirect" csv:"bms_right_motor_controller_current"` + BmsRightMotorControllerCurrent *float32 `protobuf:"fixed32,169,opt,name=bms_right_motor_controller_current,json=bmsRightMotorControllerCurrent" json:"bms_right_motor_controller_current,omitempty" structs:"bms_right_motor_controller_current,indirect" csv:"bms_right_motor_controller_current"` // @inject_tag: structs:"bms_motor_controller_current_sum,indirect" csv:"bms_motor_controller_current_sum" - BmsMotorControllerCurrentSum *float32 `protobuf:"fixed32,170,opt,name=bms_motor_controller_current_sum,json=bmsMotorControllerCurrentSum" json:"bms_motor_controller_current_sum,omitempty" structs:"bms_motor_controller_current_sum,indirect" csv:"bms_motor_controller_current_sum" structs:"bms_motor_controller_current_sum,indirect" csv:"bms_motor_controller_current_sum"` + BmsMotorControllerCurrentSum *float32 `protobuf:"fixed32,170,opt,name=bms_motor_controller_current_sum,json=bmsMotorControllerCurrentSum" json:"bms_motor_controller_current_sum,omitempty" structs:"bms_motor_controller_current_sum,indirect" csv:"bms_motor_controller_current_sum"` // @inject_tag: structs:"packets_per_sec,indirect" csv:"packets_per_sec" - PacketsPerSec *float32 `protobuf:"fixed32,171,opt,name=packets_per_sec,json=packetsPerSec" json:"packets_per_sec,omitempty" structs:"packets_per_sec,indirect" csv:"packets_per_sec" structs:"packets_per_sec,indirect" csv:"packets_per_sec"` - // @inject_tag: structs:"-" csv:"time_collected" // Not in struct, b/c not data - TimeCollected *int64 `protobuf:"varint,172,opt,name=time_collected,json=timeCollected" json:"time_collected,omitempty" structs:"-" csv:"time_collected" // Not in struct, b/c not data structs:"-" csv:"time_collected" // Not in struct, b/c not data` - XXX_unrecognized []byte `json:"-" structs:"-" csv:"-"` + PacketsPerSec *float32 `protobuf:"fixed32,171,opt,name=packets_per_sec,json=packetsPerSec" json:"packets_per_sec,omitempty" structs:"packets_per_sec,indirect" csv:"packets_per_sec"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *DataMessage) Reset() { *m = DataMessage{} } -func (m *DataMessage) String() string { return proto.CompactTextString(m) } -func (*DataMessage) ProtoMessage() {} -func (*DataMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } +func (m *SundaeDataMessage) Reset() { *m = SundaeDataMessage{} } +func (m *SundaeDataMessage) String() string { return proto.CompactTextString(m) } +func (*SundaeDataMessage) ProtoMessage() {} +func (*SundaeDataMessage) Descriptor() ([]byte, []int) { + return fileDescriptor_sundae_f201ade6f1f0d470, []int{0} +} +func (m *SundaeDataMessage) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SundaeDataMessage.Unmarshal(m, b) +} +func (m *SundaeDataMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SundaeDataMessage.Marshal(b, m, deterministic) +} +func (dst *SundaeDataMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_SundaeDataMessage.Merge(dst, src) +} +func (m *SundaeDataMessage) XXX_Size() int { + return xxx_messageInfo_SundaeDataMessage.Size(m) +} +func (m *SundaeDataMessage) XXX_DiscardUnknown() { + xxx_messageInfo_SundaeDataMessage.DiscardUnknown(m) +} + +var xxx_messageInfo_SundaeDataMessage proto.InternalMessageInfo -func (m *DataMessage) GetRegenEnabled() uint32 { +func (m *SundaeDataMessage) GetRegenEnabled() uint32 { if m != nil && m.RegenEnabled != nil { return *m.RegenEnabled } return 0 } -func (m *DataMessage) GetRegenCommand() uint32 { +func (m *SundaeDataMessage) GetRegenCommand() uint32 { if m != nil && m.RegenCommand != nil { return *m.RegenCommand } return 0 } -func (m *DataMessage) GetBatteryPower() uint32 { +func (m *SundaeDataMessage) GetBatteryPower() uint32 { if m != nil && m.BatteryPower != nil { return *m.BatteryPower } return 0 } -func (m *DataMessage) GetArrayPower() float32 { +func (m *SundaeDataMessage) GetArrayPower() float32 { if m != nil && m.ArrayPower != nil { return *m.ArrayPower } return 0 } -func (m *DataMessage) GetReverseOn() uint32 { +func (m *SundaeDataMessage) GetReverseOn() uint32 { if m != nil && m.ReverseOn != nil { return *m.ReverseOn } return 0 } -func (m *DataMessage) GetLowVoltPower() float32 { +func (m *SundaeDataMessage) GetLowVoltPower() float32 { if m != nil && m.LowVoltPower != nil { return *m.LowVoltPower } return 0 } -func (m *DataMessage) GetCellReadError() int32 { +func (m *SundaeDataMessage) GetCellReadError() int32 { if m != nil && m.CellReadError != nil { return *m.CellReadError } return 0 } -func (m *DataMessage) GetCellBleed() uint32 { +func (m *SundaeDataMessage) GetCellBleed() uint32 { if m != nil && m.CellBleed != nil { return *m.CellBleed } return 0 } -func (m *DataMessage) GetCruiseSpeed() float32 { +func (m *SundaeDataMessage) GetCruiseSpeed() float32 { if m != nil && m.CruiseSpeed != nil { return *m.CruiseSpeed } return 0 } -func (m *DataMessage) GetHazardLightsOn() int32 { +func (m *SundaeDataMessage) GetHazardLightsOn() int32 { if m != nil && m.HazardLightsOn != nil { return *m.HazardLightsOn } return 0 } -func (m *DataMessage) GetBatteryVoltage() float32 { +func (m *SundaeDataMessage) GetBatteryVoltage() float32 { if m != nil && m.BatteryVoltage != nil { return *m.BatteryVoltage } return 0 } -func (m *DataMessage) GetLtc6804Badpec() uint32 { +func (m *SundaeDataMessage) GetLtc6804Badpec() uint32 { if m != nil && m.Ltc6804Badpec != nil { return *m.Ltc6804Badpec } return 0 } -func (m *DataMessage) GetBmsState() uint32 { +func (m *SundaeDataMessage) GetBmsState() uint32 { if m != nil && m.BmsState != nil { return *m.BmsState } return 0 } -func (m *DataMessage) GetChargeEnabled() int32 { +func (m *SundaeDataMessage) GetChargeEnabled() int32 { if m != nil && m.ChargeEnabled != nil { return *m.ChargeEnabled } return 0 } -func (m *DataMessage) GetDischargeEnabled() int32 { +func (m *SundaeDataMessage) GetDischargeEnabled() int32 { if m != nil && m.DischargeEnabled != nil { return *m.DischargeEnabled } return 0 } -func (m *DataMessage) GetHighsideContactorOn() int32 { +func (m *SundaeDataMessage) GetHighsideContactorOn() int32 { if m != nil && m.HighsideContactorOn != nil { return *m.HighsideContactorOn } return 0 } -func (m *DataMessage) GetLowsideContactorOn() int32 { +func (m *SundaeDataMessage) GetLowsideContactorOn() int32 { if m != nil && m.LowsideContactorOn != nil { return *m.LowsideContactorOn } return 0 } -func (m *DataMessage) GetPrechargeOn() int32 { +func (m *SundaeDataMessage) GetPrechargeOn() int32 { if m != nil && m.PrechargeOn != nil { return *m.PrechargeOn } return 0 } -func (m *DataMessage) GetLowVoltBusOn() int32 { +func (m *SundaeDataMessage) GetLowVoltBusOn() int32 { if m != nil && m.LowVoltBusOn != nil { return *m.LowVoltBusOn } return 0 } -func (m *DataMessage) GetBatteryTemp_1() float32 { +func (m *SundaeDataMessage) GetBatteryTemp_1() float32 { if m != nil && m.BatteryTemp_1 != nil { return *m.BatteryTemp_1 } return 0 } -func (m *DataMessage) GetBatteryTemp_2() float32 { +func (m *SundaeDataMessage) GetBatteryTemp_2() float32 { if m != nil && m.BatteryTemp_2 != nil { return *m.BatteryTemp_2 } return 0 } -func (m *DataMessage) GetBatteryTemp_3() float32 { +func (m *SundaeDataMessage) GetBatteryTemp_3() float32 { if m != nil && m.BatteryTemp_3 != nil { return *m.BatteryTemp_3 } return 0 } -func (m *DataMessage) GetBatteryTemp_4() float32 { +func (m *SundaeDataMessage) GetBatteryTemp_4() float32 { if m != nil && m.BatteryTemp_4 != nil { return *m.BatteryTemp_4 } return 0 } -func (m *DataMessage) GetBatteryTemp_5() float32 { +func (m *SundaeDataMessage) GetBatteryTemp_5() float32 { if m != nil && m.BatteryTemp_5 != nil { return *m.BatteryTemp_5 } return 0 } -func (m *DataMessage) GetBatteryTemp_6() float32 { +func (m *SundaeDataMessage) GetBatteryTemp_6() float32 { if m != nil && m.BatteryTemp_6 != nil { return *m.BatteryTemp_6 } return 0 } -func (m *DataMessage) GetBmsPrechargeBatteryAdc() float32 { +func (m *SundaeDataMessage) GetBmsPrechargeBatteryAdc() float32 { if m != nil && m.BmsPrechargeBatteryAdc != nil { return *m.BmsPrechargeBatteryAdc } return 0 } -func (m *DataMessage) GetBmsPrechargeCarAdc() float32 { +func (m *SundaeDataMessage) GetBmsPrechargeCarAdc() float32 { if m != nil && m.BmsPrechargeCarAdc != nil { return *m.BmsPrechargeCarAdc } return 0 } -func (m *DataMessage) GetLowVoltOutputCurrent() float32 { +func (m *SundaeDataMessage) GetLowVoltOutputCurrent() float32 { if m != nil && m.LowVoltOutputCurrent != nil { return *m.LowVoltOutputCurrent } return 0 } -func (m *DataMessage) GetArrayCurrent() float32 { +func (m *SundaeDataMessage) GetArrayCurrent() float32 { if m != nil && m.ArrayCurrent != nil { return *m.ArrayCurrent } return 0 } -func (m *DataMessage) GetBatteryCurrent() float32 { +func (m *SundaeDataMessage) GetBatteryCurrent() float32 { if m != nil && m.BatteryCurrent != nil { return *m.BatteryCurrent } return 0 } -func (m *DataMessage) GetLeftMotorControllerPower() float32 { +func (m *SundaeDataMessage) GetLeftMotorControllerPower() float32 { if m != nil && m.LeftMotorControllerPower != nil { return *m.LeftMotorControllerPower } return 0 } -func (m *DataMessage) GetRightMotorControllerPower() float32 { +func (m *SundaeDataMessage) GetRightMotorControllerPower() float32 { if m != nil && m.RightMotorControllerPower != nil { return *m.RightMotorControllerPower } return 0 } -func (m *DataMessage) GetAmpHours() float32 { +func (m *SundaeDataMessage) GetAmpHours() float32 { if m != nil && m.AmpHours != nil { return *m.AmpHours } return 0 } -func (m *DataMessage) GetHeadLightsOn() int32 { +func (m *SundaeDataMessage) GetHeadLightsOn() int32 { if m != nil && m.HeadLightsOn != nil { return *m.HeadLightsOn } return 0 } -func (m *DataMessage) GetBrakeLightsOn() int32 { +func (m *SundaeDataMessage) GetBrakeLightsOn() int32 { if m != nil && m.BrakeLightsOn != nil { return *m.BrakeLightsOn } return 0 } -func (m *DataMessage) GetRightBlinkerOn() int32 { +func (m *SundaeDataMessage) GetRightBlinkerOn() int32 { if m != nil && m.RightBlinkerOn != nil { return *m.RightBlinkerOn } return 0 } -func (m *DataMessage) GetLeftBlinkerOn() int32 { +func (m *SundaeDataMessage) GetLeftBlinkerOn() int32 { if m != nil && m.LeftBlinkerOn != nil { return *m.LeftBlinkerOn } return 0 } -func (m *DataMessage) GetBrakePressed() int32 { +func (m *SundaeDataMessage) GetBrakePressed() int32 { if m != nil && m.BrakePressed != nil { return *m.BrakePressed } return 0 } -func (m *DataMessage) GetThrottlePressed() int32 { +func (m *SundaeDataMessage) GetThrottlePressed() int32 { if m != nil && m.ThrottlePressed != nil { return *m.ThrottlePressed } return 0 } -func (m *DataMessage) GetDriveMode() uint32 { +func (m *SundaeDataMessage) GetDriveMode() uint32 { if m != nil && m.DriveMode != nil { return *m.DriveMode } return 0 } -func (m *DataMessage) GetMotorControllerEnabled() int32 { +func (m *SundaeDataMessage) GetMotorControllerEnabled() int32 { if m != nil && m.MotorControllerEnabled != nil { return *m.MotorControllerEnabled } return 0 } -func (m *DataMessage) GetMotorControllerSpeed() float32 { +func (m *SundaeDataMessage) GetMotorControllerSpeed() float32 { if m != nil && m.MotorControllerSpeed != nil { return *m.MotorControllerSpeed } return 0 } -func (m *DataMessage) GetMotorControllerRpm() float32 { +func (m *SundaeDataMessage) GetMotorControllerRpm() float32 { if m != nil && m.MotorControllerRpm != nil { return *m.MotorControllerRpm } return 0 } -func (m *DataMessage) GetAvgOdometer() float32 { +func (m *SundaeDataMessage) GetAvgOdometer() float32 { if m != nil && m.AvgOdometer != nil { return *m.AvgOdometer } return 0 } -func (m *DataMessage) GetLeftMotorTemp() float32 { +func (m *SundaeDataMessage) GetLeftMotorTemp() float32 { if m != nil && m.LeftMotorTemp != nil { return *m.LeftMotorTemp } return 0 } -func (m *DataMessage) GetRightMotorTemp() float32 { +func (m *SundaeDataMessage) GetRightMotorTemp() float32 { if m != nil && m.RightMotorTemp != nil { return *m.RightMotorTemp } return 0 } -func (m *DataMessage) GetLeftMotorControllerTemp() float32 { +func (m *SundaeDataMessage) GetLeftMotorControllerTemp() float32 { if m != nil && m.LeftMotorControllerTemp != nil { return *m.LeftMotorControllerTemp } return 0 } -func (m *DataMessage) GetRightMotorControllerTemp() float32 { +func (m *SundaeDataMessage) GetRightMotorControllerTemp() float32 { if m != nil && m.RightMotorControllerTemp != nil { return *m.RightMotorControllerTemp } return 0 } -func (m *DataMessage) GetLeftMotorControllerAlive() float32 { +func (m *SundaeDataMessage) GetLeftMotorControllerAlive() float32 { if m != nil && m.LeftMotorControllerAlive != nil { return *m.LeftMotorControllerAlive } return 0 } -func (m *DataMessage) GetRightMotorControllerAlive() float32 { +func (m *SundaeDataMessage) GetRightMotorControllerAlive() float32 { if m != nil && m.RightMotorControllerAlive != nil { return *m.RightMotorControllerAlive } return 0 } -func (m *DataMessage) GetLeftMotorControllerCurrent() float32 { +func (m *SundaeDataMessage) GetLeftMotorControllerCurrent() float32 { if m != nil && m.LeftMotorControllerCurrent != nil { return *m.LeftMotorControllerCurrent } return 0 } -func (m *DataMessage) GetRightMotorControllerCurrent() float32 { +func (m *SundaeDataMessage) GetRightMotorControllerCurrent() float32 { if m != nil && m.RightMotorControllerCurrent != nil { return *m.RightMotorControllerCurrent } return 0 } -func (m *DataMessage) GetMotorControllerCurrentDiff() float32 { +func (m *SundaeDataMessage) GetMotorControllerCurrentDiff() float32 { if m != nil && m.MotorControllerCurrentDiff != nil { return *m.MotorControllerCurrentDiff } return 0 } -func (m *DataMessage) GetLeftMotorControllerError() uint32 { +func (m *SundaeDataMessage) GetLeftMotorControllerError() uint32 { if m != nil && m.LeftMotorControllerError != nil { return *m.LeftMotorControllerError } return 0 } -func (m *DataMessage) GetRightMotorControllerError() uint32 { +func (m *SundaeDataMessage) GetRightMotorControllerError() uint32 { if m != nil && m.RightMotorControllerError != nil { return *m.RightMotorControllerError } return 0 } -func (m *DataMessage) GetLeftMotorControllerLimit() uint32 { +func (m *SundaeDataMessage) GetLeftMotorControllerLimit() uint32 { if m != nil && m.LeftMotorControllerLimit != nil { return *m.LeftMotorControllerLimit } return 0 } -func (m *DataMessage) GetRightMotorControllerLimit() uint32 { +func (m *SundaeDataMessage) GetRightMotorControllerLimit() uint32 { if m != nil && m.RightMotorControllerLimit != nil { return *m.RightMotorControllerLimit } return 0 } -func (m *DataMessage) GetLeftMotorControllerRxErrorCount() uint32 { +func (m *SundaeDataMessage) GetLeftMotorControllerRxErrorCount() uint32 { if m != nil && m.LeftMotorControllerRxErrorCount != nil { return *m.LeftMotorControllerRxErrorCount } return 0 } -func (m *DataMessage) GetRightMotorControllerRxErrorCount() uint32 { +func (m *SundaeDataMessage) GetRightMotorControllerRxErrorCount() uint32 { if m != nil && m.RightMotorControllerRxErrorCount != nil { return *m.RightMotorControllerRxErrorCount } return 0 } -func (m *DataMessage) GetLeftMotorControllerTxErrorCount() uint32 { +func (m *SundaeDataMessage) GetLeftMotorControllerTxErrorCount() uint32 { if m != nil && m.LeftMotorControllerTxErrorCount != nil { return *m.LeftMotorControllerTxErrorCount } return 0 } -func (m *DataMessage) GetRightMotorControllerTxErrorCount() uint32 { +func (m *SundaeDataMessage) GetRightMotorControllerTxErrorCount() uint32 { if m != nil && m.RightMotorControllerTxErrorCount != nil { return *m.RightMotorControllerTxErrorCount } return 0 } -func (m *DataMessage) GetLeftMotorControllerBusVoltage() float32 { +func (m *SundaeDataMessage) GetLeftMotorControllerBusVoltage() float32 { if m != nil && m.LeftMotorControllerBusVoltage != nil { return *m.LeftMotorControllerBusVoltage } return 0 } -func (m *DataMessage) GetRightMotorControllerBusVoltage() float32 { +func (m *SundaeDataMessage) GetRightMotorControllerBusVoltage() float32 { if m != nil && m.RightMotorControllerBusVoltage != nil { return *m.RightMotorControllerBusVoltage } return 0 } -func (m *DataMessage) GetLeftMotorController_15VVoltage() float32 { +func (m *SundaeDataMessage) GetLeftMotorController_15VVoltage() float32 { if m != nil && m.LeftMotorController_15VVoltage != nil { return *m.LeftMotorController_15VVoltage } return 0 } -func (m *DataMessage) GetRightMotorController_15VVoltage() float32 { +func (m *SundaeDataMessage) GetRightMotorController_15VVoltage() float32 { if m != nil && m.RightMotorController_15VVoltage != nil { return *m.RightMotorController_15VVoltage } return 0 } -func (m *DataMessage) GetLeftMotorController_3V3Voltage() float32 { +func (m *SundaeDataMessage) GetLeftMotorController_3V3Voltage() float32 { if m != nil && m.LeftMotorController_3V3Voltage != nil { return *m.LeftMotorController_3V3Voltage } return 0 } -func (m *DataMessage) GetRightMotorController_3V3Voltage() float32 { +func (m *SundaeDataMessage) GetRightMotorController_3V3Voltage() float32 { if m != nil && m.RightMotorController_3V3Voltage != nil { return *m.RightMotorController_3V3Voltage } return 0 } -func (m *DataMessage) GetLeftMotorController_1V9Voltage() float32 { +func (m *SundaeDataMessage) GetLeftMotorController_1V9Voltage() float32 { if m != nil && m.LeftMotorController_1V9Voltage != nil { return *m.LeftMotorController_1V9Voltage } return 0 } -func (m *DataMessage) GetRightMotorController_1V9Voltage() float32 { +func (m *SundaeDataMessage) GetRightMotorController_1V9Voltage() float32 { if m != nil && m.RightMotorController_1V9Voltage != nil { return *m.RightMotorController_1V9Voltage } return 0 } -func (m *DataMessage) GetLeftMotorControllerDspTemp() float32 { +func (m *SundaeDataMessage) GetLeftMotorControllerDspTemp() float32 { if m != nil && m.LeftMotorControllerDspTemp != nil { return *m.LeftMotorControllerDspTemp } return 0 } -func (m *DataMessage) GetRightMotorControllerDspTemp() float32 { +func (m *SundaeDataMessage) GetRightMotorControllerDspTemp() float32 { if m != nil && m.RightMotorControllerDspTemp != nil { return *m.RightMotorControllerDspTemp } return 0 } -func (m *DataMessage) GetLeftMotorControllerPhaseCurrent() float32 { +func (m *SundaeDataMessage) GetLeftMotorControllerPhaseCurrent() float32 { if m != nil && m.LeftMotorControllerPhaseCurrent != nil { return *m.LeftMotorControllerPhaseCurrent } return 0 } -func (m *DataMessage) GetRightMotorControllerPhaseCurrent() float32 { +func (m *SundaeDataMessage) GetRightMotorControllerPhaseCurrent() float32 { if m != nil && m.RightMotorControllerPhaseCurrent != nil { return *m.RightMotorControllerPhaseCurrent } return 0 } -func (m *DataMessage) GetLeftMotorRpmCommand() float32 { +func (m *SundaeDataMessage) GetLeftMotorRpmCommand() float32 { if m != nil && m.LeftMotorRpmCommand != nil { return *m.LeftMotorRpmCommand } return 0 } -func (m *DataMessage) GetRightMotorRpmCommand() float32 { +func (m *SundaeDataMessage) GetRightMotorRpmCommand() float32 { if m != nil && m.RightMotorRpmCommand != nil { return *m.RightMotorRpmCommand } return 0 } -func (m *DataMessage) GetLeftMotorCurrentCommand() float32 { +func (m *SundaeDataMessage) GetLeftMotorCurrentCommand() float32 { if m != nil && m.LeftMotorCurrentCommand != nil { return *m.LeftMotorCurrentCommand } return 0 } -func (m *DataMessage) GetRightMotorCurrentCommand() float32 { +func (m *SundaeDataMessage) GetRightMotorCurrentCommand() float32 { if m != nil && m.RightMotorCurrentCommand != nil { return *m.RightMotorCurrentCommand } return 0 } -func (m *DataMessage) GetGpsTime() int64 { +func (m *SundaeDataMessage) GetGpsTime() int64 { if m != nil && m.GpsTime != nil { return *m.GpsTime } return 0 } -func (m *DataMessage) GetGpsLatitude() float32 { +func (m *SundaeDataMessage) GetGpsLatitude() float32 { if m != nil && m.GpsLatitude != nil { return *m.GpsLatitude } return 0 } -func (m *DataMessage) GetGpsLongitude() float32 { +func (m *SundaeDataMessage) GetGpsLongitude() float32 { if m != nil && m.GpsLongitude != nil { return *m.GpsLongitude } return 0 } -func (m *DataMessage) GetGpsSpeed() float32 { +func (m *SundaeDataMessage) GetGpsSpeed() float32 { if m != nil && m.GpsSpeed != nil { return *m.GpsSpeed } return 0 } -func (m *DataMessage) GetGpsAltitude() float32 { +func (m *SundaeDataMessage) GetGpsAltitude() float32 { if m != nil && m.GpsAltitude != nil { return *m.GpsAltitude } return 0 } -func (m *DataMessage) GetGpsBearing() float32 { +func (m *SundaeDataMessage) GetGpsBearing() float32 { if m != nil && m.GpsBearing != nil { return *m.GpsBearing } return 0 } -func (m *DataMessage) GetLedState() int32 { +func (m *SundaeDataMessage) GetLedState() int32 { if m != nil && m.LedState != nil { return *m.LedState } return 0 } -func (m *DataMessage) GetMpptArrayPower() float32 { +func (m *SundaeDataMessage) GetMpptArrayPower() float32 { if m != nil && m.MpptArrayPower != nil { return *m.MpptArrayPower } return 0 } -func (m *DataMessage) GetMppt_A0VoltIn() float32 { +func (m *SundaeDataMessage) GetMppt_A0VoltIn() float32 { if m != nil && m.Mppt_A0VoltIn != nil { return *m.Mppt_A0VoltIn } return 0 } -func (m *DataMessage) GetMppt_A0VoltOut() float32 { +func (m *SundaeDataMessage) GetMppt_A0VoltOut() float32 { if m != nil && m.Mppt_A0VoltOut != nil { return *m.Mppt_A0VoltOut } return 0 } -func (m *DataMessage) GetMppt_A0Current() float32 { +func (m *SundaeDataMessage) GetMppt_A0Current() float32 { if m != nil && m.Mppt_A0Current != nil { return *m.Mppt_A0Current } return 0 } -func (m *DataMessage) GetMppt_A0Temp() float32 { +func (m *SundaeDataMessage) GetMppt_A0Temp() float32 { if m != nil && m.Mppt_A0Temp != nil { return *m.Mppt_A0Temp } return 0 } -func (m *DataMessage) GetMppt_A1VoltIn() float32 { +func (m *SundaeDataMessage) GetMppt_A1VoltIn() float32 { if m != nil && m.Mppt_A1VoltIn != nil { return *m.Mppt_A1VoltIn } return 0 } -func (m *DataMessage) GetMppt_A1VoltOut() float32 { +func (m *SundaeDataMessage) GetMppt_A1VoltOut() float32 { if m != nil && m.Mppt_A1VoltOut != nil { return *m.Mppt_A1VoltOut } return 0 } -func (m *DataMessage) GetMppt_A1Current() float32 { +func (m *SundaeDataMessage) GetMppt_A1Current() float32 { if m != nil && m.Mppt_A1Current != nil { return *m.Mppt_A1Current } return 0 } -func (m *DataMessage) GetMppt_A1Temp() float32 { +func (m *SundaeDataMessage) GetMppt_A1Temp() float32 { if m != nil && m.Mppt_A1Temp != nil { return *m.Mppt_A1Temp } return 0 } -func (m *DataMessage) GetMppt_B0VoltIn() float32 { +func (m *SundaeDataMessage) GetMppt_B0VoltIn() float32 { if m != nil && m.Mppt_B0VoltIn != nil { return *m.Mppt_B0VoltIn } return 0 } -func (m *DataMessage) GetMppt_B0VoltOut() float32 { +func (m *SundaeDataMessage) GetMppt_B0VoltOut() float32 { if m != nil && m.Mppt_B0VoltOut != nil { return *m.Mppt_B0VoltOut } return 0 } -func (m *DataMessage) GetMppt_B0Current() float32 { +func (m *SundaeDataMessage) GetMppt_B0Current() float32 { if m != nil && m.Mppt_B0Current != nil { return *m.Mppt_B0Current } return 0 } -func (m *DataMessage) GetMppt_B0Temp() float32 { +func (m *SundaeDataMessage) GetMppt_B0Temp() float32 { if m != nil && m.Mppt_B0Temp != nil { return *m.Mppt_B0Temp } return 0 } -func (m *DataMessage) GetMppt_B1VoltIn() float32 { +func (m *SundaeDataMessage) GetMppt_B1VoltIn() float32 { if m != nil && m.Mppt_B1VoltIn != nil { return *m.Mppt_B1VoltIn } return 0 } -func (m *DataMessage) GetMppt_B1VoltOut() float32 { +func (m *SundaeDataMessage) GetMppt_B1VoltOut() float32 { if m != nil && m.Mppt_B1VoltOut != nil { return *m.Mppt_B1VoltOut } return 0 } -func (m *DataMessage) GetMppt_B1Current() float32 { +func (m *SundaeDataMessage) GetMppt_B1Current() float32 { if m != nil && m.Mppt_B1Current != nil { return *m.Mppt_B1Current } return 0 } -func (m *DataMessage) GetMppt_B1Temp() float32 { +func (m *SundaeDataMessage) GetMppt_B1Temp() float32 { if m != nil && m.Mppt_B1Temp != nil { return *m.Mppt_B1Temp } return 0 } -func (m *DataMessage) GetMppt_C0VoltIn() float32 { +func (m *SundaeDataMessage) GetMppt_C0VoltIn() float32 { if m != nil && m.Mppt_C0VoltIn != nil { return *m.Mppt_C0VoltIn } return 0 } -func (m *DataMessage) GetMppt_C0VoltOut() float32 { +func (m *SundaeDataMessage) GetMppt_C0VoltOut() float32 { if m != nil && m.Mppt_C0VoltOut != nil { return *m.Mppt_C0VoltOut } return 0 } -func (m *DataMessage) GetMppt_C0Current() float32 { +func (m *SundaeDataMessage) GetMppt_C0Current() float32 { if m != nil && m.Mppt_C0Current != nil { return *m.Mppt_C0Current } return 0 } -func (m *DataMessage) GetMppt_C0Temp() float32 { +func (m *SundaeDataMessage) GetMppt_C0Temp() float32 { if m != nil && m.Mppt_C0Temp != nil { return *m.Mppt_C0Temp } return 0 } -func (m *DataMessage) GetMppt_C1VoltIn() float32 { +func (m *SundaeDataMessage) GetMppt_C1VoltIn() float32 { if m != nil && m.Mppt_C1VoltIn != nil { return *m.Mppt_C1VoltIn } return 0 } -func (m *DataMessage) GetMppt_C1VoltOut() float32 { +func (m *SundaeDataMessage) GetMppt_C1VoltOut() float32 { if m != nil && m.Mppt_C1VoltOut != nil { return *m.Mppt_C1VoltOut } return 0 } -func (m *DataMessage) GetMppt_C1Current() float32 { +func (m *SundaeDataMessage) GetMppt_C1Current() float32 { if m != nil && m.Mppt_C1Current != nil { return *m.Mppt_C1Current } return 0 } -func (m *DataMessage) GetMppt_C1Temp() float32 { +func (m *SundaeDataMessage) GetMppt_C1Temp() float32 { if m != nil && m.Mppt_C1Temp != nil { return *m.Mppt_C1Temp } return 0 } -func (m *DataMessage) GetMppt_D0VoltIn() float32 { +func (m *SundaeDataMessage) GetMppt_D0VoltIn() float32 { if m != nil && m.Mppt_D0VoltIn != nil { return *m.Mppt_D0VoltIn } return 0 } -func (m *DataMessage) GetMppt_D0VoltOut() float32 { +func (m *SundaeDataMessage) GetMppt_D0VoltOut() float32 { if m != nil && m.Mppt_D0VoltOut != nil { return *m.Mppt_D0VoltOut } return 0 } -func (m *DataMessage) GetMppt_D0Current() float32 { +func (m *SundaeDataMessage) GetMppt_D0Current() float32 { if m != nil && m.Mppt_D0Current != nil { return *m.Mppt_D0Current } return 0 } -func (m *DataMessage) GetMppt_D0Temp() float32 { +func (m *SundaeDataMessage) GetMppt_D0Temp() float32 { if m != nil && m.Mppt_D0Temp != nil { return *m.Mppt_D0Temp } return 0 } -func (m *DataMessage) GetMppt_D1VoltIn() float32 { +func (m *SundaeDataMessage) GetMppt_D1VoltIn() float32 { if m != nil && m.Mppt_D1VoltIn != nil { return *m.Mppt_D1VoltIn } return 0 } -func (m *DataMessage) GetMppt_D1VoltOut() float32 { +func (m *SundaeDataMessage) GetMppt_D1VoltOut() float32 { if m != nil && m.Mppt_D1VoltOut != nil { return *m.Mppt_D1VoltOut } return 0 } -func (m *DataMessage) GetMppt_D1Current() float32 { +func (m *SundaeDataMessage) GetMppt_D1Current() float32 { if m != nil && m.Mppt_D1Current != nil { return *m.Mppt_D1Current } return 0 } -func (m *DataMessage) GetMppt_D1Temp() float32 { +func (m *SundaeDataMessage) GetMppt_D1Temp() float32 { if m != nil && m.Mppt_D1Temp != nil { return *m.Mppt_D1Temp } return 0 } -func (m *DataMessage) GetCellVolt_1() float32 { +func (m *SundaeDataMessage) GetCellVolt_1() float32 { if m != nil && m.CellVolt_1 != nil { return *m.CellVolt_1 } return 0 } -func (m *DataMessage) GetCellVolt_2() float32 { +func (m *SundaeDataMessage) GetCellVolt_2() float32 { if m != nil && m.CellVolt_2 != nil { return *m.CellVolt_2 } return 0 } -func (m *DataMessage) GetCellVolt_3() float32 { +func (m *SundaeDataMessage) GetCellVolt_3() float32 { if m != nil && m.CellVolt_3 != nil { return *m.CellVolt_3 } return 0 } -func (m *DataMessage) GetCellVolt_4() float32 { +func (m *SundaeDataMessage) GetCellVolt_4() float32 { if m != nil && m.CellVolt_4 != nil { return *m.CellVolt_4 } return 0 } -func (m *DataMessage) GetCellVolt_5() float32 { +func (m *SundaeDataMessage) GetCellVolt_5() float32 { if m != nil && m.CellVolt_5 != nil { return *m.CellVolt_5 } return 0 } -func (m *DataMessage) GetCellVolt_6() float32 { +func (m *SundaeDataMessage) GetCellVolt_6() float32 { if m != nil && m.CellVolt_6 != nil { return *m.CellVolt_6 } return 0 } -func (m *DataMessage) GetCellVolt_7() float32 { +func (m *SundaeDataMessage) GetCellVolt_7() float32 { if m != nil && m.CellVolt_7 != nil { return *m.CellVolt_7 } return 0 } -func (m *DataMessage) GetCellVolt_8() float32 { +func (m *SundaeDataMessage) GetCellVolt_8() float32 { if m != nil && m.CellVolt_8 != nil { return *m.CellVolt_8 } return 0 } -func (m *DataMessage) GetCellVolt_9() float32 { +func (m *SundaeDataMessage) GetCellVolt_9() float32 { if m != nil && m.CellVolt_9 != nil { return *m.CellVolt_9 } return 0 } -func (m *DataMessage) GetCellVolt_10() float32 { +func (m *SundaeDataMessage) GetCellVolt_10() float32 { if m != nil && m.CellVolt_10 != nil { return *m.CellVolt_10 } return 0 } -func (m *DataMessage) GetCellVolt_11() float32 { +func (m *SundaeDataMessage) GetCellVolt_11() float32 { if m != nil && m.CellVolt_11 != nil { return *m.CellVolt_11 } return 0 } -func (m *DataMessage) GetCellVolt_12() float32 { +func (m *SundaeDataMessage) GetCellVolt_12() float32 { if m != nil && m.CellVolt_12 != nil { return *m.CellVolt_12 } return 0 } -func (m *DataMessage) GetCellVolt_13() float32 { +func (m *SundaeDataMessage) GetCellVolt_13() float32 { if m != nil && m.CellVolt_13 != nil { return *m.CellVolt_13 } return 0 } -func (m *DataMessage) GetCellVolt_14() float32 { +func (m *SundaeDataMessage) GetCellVolt_14() float32 { if m != nil && m.CellVolt_14 != nil { return *m.CellVolt_14 } return 0 } -func (m *DataMessage) GetCellVolt_15() float32 { +func (m *SundaeDataMessage) GetCellVolt_15() float32 { if m != nil && m.CellVolt_15 != nil { return *m.CellVolt_15 } return 0 } -func (m *DataMessage) GetCellVolt_16() float32 { +func (m *SundaeDataMessage) GetCellVolt_16() float32 { if m != nil && m.CellVolt_16 != nil { return *m.CellVolt_16 } return 0 } -func (m *DataMessage) GetCellVolt_17() float32 { +func (m *SundaeDataMessage) GetCellVolt_17() float32 { if m != nil && m.CellVolt_17 != nil { return *m.CellVolt_17 } return 0 } -func (m *DataMessage) GetCellVolt_18() float32 { +func (m *SundaeDataMessage) GetCellVolt_18() float32 { if m != nil && m.CellVolt_18 != nil { return *m.CellVolt_18 } return 0 } -func (m *DataMessage) GetCellVolt_19() float32 { +func (m *SundaeDataMessage) GetCellVolt_19() float32 { if m != nil && m.CellVolt_19 != nil { return *m.CellVolt_19 } return 0 } -func (m *DataMessage) GetCellVolt_20() float32 { +func (m *SundaeDataMessage) GetCellVolt_20() float32 { if m != nil && m.CellVolt_20 != nil { return *m.CellVolt_20 } return 0 } -func (m *DataMessage) GetCellVolt_21() float32 { +func (m *SundaeDataMessage) GetCellVolt_21() float32 { if m != nil && m.CellVolt_21 != nil { return *m.CellVolt_21 } return 0 } -func (m *DataMessage) GetCellVolt_22() float32 { +func (m *SundaeDataMessage) GetCellVolt_22() float32 { if m != nil && m.CellVolt_22 != nil { return *m.CellVolt_22 } return 0 } -func (m *DataMessage) GetCellVolt_23() float32 { +func (m *SundaeDataMessage) GetCellVolt_23() float32 { if m != nil && m.CellVolt_23 != nil { return *m.CellVolt_23 } return 0 } -func (m *DataMessage) GetCellVolt_24() float32 { +func (m *SundaeDataMessage) GetCellVolt_24() float32 { if m != nil && m.CellVolt_24 != nil { return *m.CellVolt_24 } return 0 } -func (m *DataMessage) GetCellVolt_25() float32 { +func (m *SundaeDataMessage) GetCellVolt_25() float32 { if m != nil && m.CellVolt_25 != nil { return *m.CellVolt_25 } return 0 } -func (m *DataMessage) GetCellVolt_26() float32 { +func (m *SundaeDataMessage) GetCellVolt_26() float32 { if m != nil && m.CellVolt_26 != nil { return *m.CellVolt_26 } return 0 } -func (m *DataMessage) GetCellVolt_27() float32 { +func (m *SundaeDataMessage) GetCellVolt_27() float32 { if m != nil && m.CellVolt_27 != nil { return *m.CellVolt_27 } return 0 } -func (m *DataMessage) GetCellVolt_28() float32 { +func (m *SundaeDataMessage) GetCellVolt_28() float32 { if m != nil && m.CellVolt_28 != nil { return *m.CellVolt_28 } return 0 } -func (m *DataMessage) GetCellVolt_29() float32 { +func (m *SundaeDataMessage) GetCellVolt_29() float32 { if m != nil && m.CellVolt_29 != nil { return *m.CellVolt_29 } return 0 } -func (m *DataMessage) GetCellVolt_30() float32 { +func (m *SundaeDataMessage) GetCellVolt_30() float32 { if m != nil && m.CellVolt_30 != nil { return *m.CellVolt_30 } return 0 } -func (m *DataMessage) GetCellVolt_31() float32 { +func (m *SundaeDataMessage) GetCellVolt_31() float32 { if m != nil && m.CellVolt_31 != nil { return *m.CellVolt_31 } return 0 } -func (m *DataMessage) GetCellVoltMin() float32 { +func (m *SundaeDataMessage) GetCellVoltMin() float32 { if m != nil && m.CellVoltMin != nil { return *m.CellVoltMin } return 0 } -func (m *DataMessage) GetCellVoltMax() float32 { +func (m *SundaeDataMessage) GetCellVoltMax() float32 { if m != nil && m.CellVoltMax != nil { return *m.CellVoltMax } return 0 } -func (m *DataMessage) GetCellVoltAvg() float32 { +func (m *SundaeDataMessage) GetCellVoltAvg() float32 { if m != nil && m.CellVoltAvg != nil { return *m.CellVoltAvg } return 0 } -func (m *DataMessage) GetCellVoltDiff() float32 { +func (m *SundaeDataMessage) GetCellVoltDiff() float32 { if m != nil && m.CellVoltDiff != nil { return *m.CellVoltDiff } return 0 } -func (m *DataMessage) GetPowerSaveOn() int32 { +func (m *SundaeDataMessage) GetPowerSaveOn() int32 { if m != nil && m.PowerSaveOn != nil { return *m.PowerSaveOn } return 0 } -func (m *DataMessage) GetRearviewOn() int32 { +func (m *SundaeDataMessage) GetRearviewOn() int32 { if m != nil && m.RearviewOn != nil { return *m.RearviewOn } return 0 } -func (m *DataMessage) GetMicEnabled() int32 { +func (m *SundaeDataMessage) GetMicEnabled() int32 { if m != nil && m.MicEnabled != nil { return *m.MicEnabled } return 0 } -func (m *DataMessage) GetImuTemp() int32 { +func (m *SundaeDataMessage) GetImuTemp() int32 { if m != nil && m.ImuTemp != nil { return *m.ImuTemp } return 0 } -func (m *DataMessage) GetImuMagnetX() int32 { +func (m *SundaeDataMessage) GetImuMagnetX() int32 { if m != nil && m.ImuMagnetX != nil { return *m.ImuMagnetX } return 0 } -func (m *DataMessage) GetImuMagnetY() int32 { +func (m *SundaeDataMessage) GetImuMagnetY() int32 { if m != nil && m.ImuMagnetY != nil { return *m.ImuMagnetY } return 0 } -func (m *DataMessage) GetImuMagnetZ() int32 { +func (m *SundaeDataMessage) GetImuMagnetZ() int32 { if m != nil && m.ImuMagnetZ != nil { return *m.ImuMagnetZ } return 0 } -func (m *DataMessage) GetImuGyroX() int32 { +func (m *SundaeDataMessage) GetImuGyroX() int32 { if m != nil && m.ImuGyroX != nil { return *m.ImuGyroX } return 0 } -func (m *DataMessage) GetImuGyroY() int32 { +func (m *SundaeDataMessage) GetImuGyroY() int32 { if m != nil && m.ImuGyroY != nil { return *m.ImuGyroY } return 0 } -func (m *DataMessage) GetImuGyroZ() int32 { +func (m *SundaeDataMessage) GetImuGyroZ() int32 { if m != nil && m.ImuGyroZ != nil { return *m.ImuGyroZ } return 0 } -func (m *DataMessage) GetImuAccelX() int32 { +func (m *SundaeDataMessage) GetImuAccelX() int32 { if m != nil && m.ImuAccelX != nil { return *m.ImuAccelX } return 0 } -func (m *DataMessage) GetImuAccelY() int32 { +func (m *SundaeDataMessage) GetImuAccelY() int32 { if m != nil && m.ImuAccelY != nil { return *m.ImuAccelY } return 0 } -func (m *DataMessage) GetImuAccelZ() int32 { +func (m *SundaeDataMessage) GetImuAccelZ() int32 { if m != nil && m.ImuAccelZ != nil { return *m.ImuAccelZ } return 0 } -func (m *DataMessage) GetBmsLeftMotorControllerCurrent() float32 { +func (m *SundaeDataMessage) GetBmsLeftMotorControllerCurrent() float32 { if m != nil && m.BmsLeftMotorControllerCurrent != nil { return *m.BmsLeftMotorControllerCurrent } return 0 } -func (m *DataMessage) GetBmsRightMotorControllerCurrent() float32 { +func (m *SundaeDataMessage) GetBmsRightMotorControllerCurrent() float32 { if m != nil && m.BmsRightMotorControllerCurrent != nil { return *m.BmsRightMotorControllerCurrent } return 0 } -func (m *DataMessage) GetBmsMotorControllerCurrentSum() float32 { +func (m *SundaeDataMessage) GetBmsMotorControllerCurrentSum() float32 { if m != nil && m.BmsMotorControllerCurrentSum != nil { return *m.BmsMotorControllerCurrentSum } return 0 } -func (m *DataMessage) GetPacketsPerSec() float32 { +func (m *SundaeDataMessage) GetPacketsPerSec() float32 { if m != nil && m.PacketsPerSec != nil { return *m.PacketsPerSec } return 0 } -func (m *DataMessage) GetTimeCollected() int64 { - if m != nil && m.TimeCollected != nil { - return *m.TimeCollected - } - return 0 -} - func init() { - proto.RegisterType((*DataMessage)(nil), "DataMessage") -} - -func init() { proto.RegisterFile("data_message.proto", fileDescriptor0) } - -var fileDescriptor0 = []byte{ - // 2320 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x99, 0x77, 0x7f, 0xdc, 0xb6, - 0x19, 0xc7, 0x3f, 0x4a, 0x9a, 0x46, 0x86, 0x66, 0xe8, 0xf5, 0xd8, 0x8a, 0x64, 0xc9, 0x53, 0x69, - 0xda, 0x54, 0xe4, 0xe9, 0x34, 0x92, 0xba, 0xa9, 0xee, 0xce, 0xb5, 0x9d, 0x48, 0x91, 0x2a, 0xb9, - 0xae, 0xed, 0x0e, 0x16, 0x47, 0x42, 0x14, 0x6b, 0xae, 0x82, 0xbc, 0x93, 0xe4, 0xee, 0xbd, 0xf7, - 0xde, 0x7b, 0xf7, 0x65, 0xf5, 0x85, 0xf4, 0x03, 0x80, 0x03, 0x04, 0x49, 0x39, 0x7f, 0xea, 0x79, - 0xbe, 0xcf, 0x83, 0x1f, 0x7f, 0x07, 0x80, 0x20, 0x84, 0x34, 0x1b, 0x27, 0xd8, 0xf4, 0x49, 0x1c, - 0x63, 0x87, 0xbc, 0x12, 0xd1, 0x30, 0x09, 0x2f, 0xff, 0xef, 0x55, 0x34, 0xd6, 0xc3, 0x09, 0xde, - 0x12, 0x51, 0xed, 0x0a, 0x9a, 0xa0, 0xc4, 0x21, 0x81, 0x49, 0x02, 0xdc, 0xf7, 0x88, 0x0d, 0x23, - 0xf3, 0x23, 0x8b, 0x13, 0xbb, 0xe3, 0x3c, 0x78, 0x4b, 0xc4, 0x0a, 0xc8, 0x0a, 0x7d, 0x1f, 0x07, - 0x36, 0x3c, 0x23, 0x41, 0x5d, 0x11, 0x63, 0x50, 0x1f, 0x27, 0x09, 0xa1, 0xc7, 0x66, 0x14, 0x1e, - 0x12, 0x0a, 0xcf, 0x0a, 0x28, 0x0d, 0xee, 0xb0, 0x98, 0x76, 0x09, 0x8d, 0x61, 0x4a, 0x71, 0x86, - 0xbc, 0x63, 0x7e, 0x64, 0xf1, 0x99, 0x5d, 0xc4, 0x43, 0x02, 0x98, 0x45, 0x88, 0x92, 0x21, 0xa1, - 0x31, 0x31, 0xc3, 0x00, 0x9e, 0xe3, 0x2d, 0x4e, 0xa5, 0x91, 0xed, 0x40, 0xbb, 0x8a, 0x26, 0xbd, - 0xf0, 0xd0, 0x1c, 0x86, 0x5e, 0x92, 0xb6, 0x78, 0x27, 0x6f, 0x31, 0xee, 0x85, 0x87, 0xf7, 0x43, - 0x2f, 0x11, 0x4d, 0xae, 0xa3, 0x29, 0x8b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dd, 0x46, 0xf3, 0xac, - 0x59, 0xe3, 0x45, 0x5e, 0x3c, 0xf0, 0xe1, 0xdf, 0xa2, 0xd5, 0x8b, 0x7d, 0x3f, 0xae, 0xef, 0xb2, - 0x37, 0xf0, 0xb5, 0x1b, 0x68, 0x2a, 0xc2, 0xd6, 0x63, 0x92, 0xc4, 0x66, 0xc4, 0x26, 0x25, 0xb1, - 0xe0, 0x3f, 0xa2, 0x6e, 0x22, 0x8d, 0xef, 0x10, 0xba, 0x47, 0x2c, 0xed, 0x3a, 0x9a, 0x64, 0xdf, - 0x51, 0xa6, 0xc5, 0x3a, 0x58, 0x09, 0xb1, 0xe1, 0xbf, 0x23, 0xfc, 0x93, 0x6a, 0x82, 0x85, 0xbb, - 0x59, 0xf4, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x59, 0xd9, 0x8e, 0x04, 0x7b, 0x1d, 0x00, 0x00, + proto.RegisterType((*SundaeDataMessage)(nil), "SundaeDataMessage") +} + +func init() { proto.RegisterFile("sundae.proto", fileDescriptor_sundae_f201ade6f1f0d470) } + +var fileDescriptor_sundae_f201ade6f1f0d470 = []byte{ + // 2299 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x99, 0x79, 0x5f, 0xdc, 0xc6, + 0x19, 0xc7, 0x3f, 0x24, 0x4d, 0x8d, 0x07, 0x30, 0x58, 0xbe, 0x1e, 0x9b, 0x80, 0xc1, 0x27, 0x69, + 0xda, 0x94, 0xd5, 0xb2, 0x1c, 0x49, 0xdd, 0x94, 0xdd, 0x75, 0x6d, 0x27, 0x10, 0x28, 0xb8, 0xae, + 0xed, 0x1e, 0xea, 0xac, 0x34, 0x08, 0xd5, 0xba, 0x3a, 0x92, 0x16, 0x70, 0xef, 0xfb, 0xbe, 0xef, + 0xfb, 0xbe, 0xdf, 0x45, 0x5f, 0x59, 0x3e, 0x33, 0xa3, 0x63, 0x34, 0x92, 0x70, 0xfe, 0xe4, 0x79, + 0xbe, 0xcf, 0x33, 0x3f, 0xfd, 0x76, 0x66, 0x34, 0x1a, 0xd0, 0x78, 0x94, 0xf8, 0x16, 0x26, 0xaf, + 0x84, 0x34, 0x88, 0x83, 0x2b, 0xff, 0x7f, 0x15, 0x9d, 0xde, 0xe5, 0x81, 0x3e, 0x8e, 0xf1, 0x26, + 0x89, 0x22, 0x6c, 0x13, 0xed, 0x2a, 0x9a, 0xa0, 0xc4, 0x26, 0xbe, 0x41, 0x7c, 0x3c, 0x70, 0x89, + 0x05, 0x23, 0x73, 0x23, 0x0b, 0x13, 0x3b, 0xe3, 0x3c, 0x78, 0x5b, 0xc4, 0x0a, 0xc8, 0x0c, 0x3c, + 0x0f, 0xfb, 0x16, 0x3c, 0x27, 0x41, 0x3d, 0x11, 0x63, 0xd0, 0x00, 0xc7, 0x31, 0xa1, 0x47, 0x46, + 0x18, 0x1c, 0x10, 0x0a, 0xcf, 0x0b, 0x28, 0x0d, 0x6e, 0xb3, 0x98, 0x76, 0x19, 0x8d, 0x61, 0x4a, + 0x71, 0x86, 0xbc, 0x6b, 0x6e, 0x64, 0xe1, 0xb9, 0x1d, 0xc4, 0x43, 0x02, 0x98, 0x41, 0x88, 0x92, + 0x21, 0xa1, 0x11, 0x31, 0x02, 0x1f, 0x5e, 0xe0, 0x2d, 0x4e, 0xa6, 0x91, 0x2d, 0x5f, 0xbb, 0x86, + 0x4e, 0xb9, 0xc1, 0x81, 0x31, 0x0c, 0xdc, 0x38, 0x6d, 0xf1, 0x6e, 0xde, 0x62, 0xdc, 0x0d, 0x0e, + 0x1e, 0x04, 0x6e, 0x2c, 0x9a, 0xdc, 0x40, 0x93, 0x26, 0x71, 0x5d, 0x83, 0x12, 0x6c, 0x19, 0x84, + 0xd2, 0x80, 0xc2, 0x89, 0xb9, 0x91, 0x85, 0x17, 0x76, 0x26, 0x58, 0x78, 0x87, 0x60, 0xeb, 0x36, + 0x0b, 0xb2, 0xc1,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 0x5e, 0xa2, 0xa5, 0x39, 0xb9, 0x62, + 0x1e, 0x8d, 0x87, 0x94, 0xa4, 0x92, 0x02, 0x1f, 0x34, 0x4e, 0x8e, 0xe5, 0xb1, 0x2d, 0x5f, 0xbb, + 0x8e, 0x26, 0xf3, 0x39, 0x30, 0x48, 0xb8, 0xe5, 0x67, 0x38, 0x95, 0x4d, 0x82, 0x6e, 0x12, 0x89, + 0xa9, 0x92, 0x19, 0x1e, 0x13, 0x2f, 0x34, 0x5a, 0x70, 0x56, 0x4c, 0x95, 0x34, 0x7a, 0x9f, 0x78, + 0x61, 0xab, 0x42, 0xe9, 0x70, 0xae, 0x42, 0xe9, 0x15, 0xaa, 0x0d, 0xe7, 0x2b, 0x54, 0xbb, 0x42, + 0x2d, 0xc1, 0x85, 0x0a, 0xb5, 0x54, 0xa1, 0x3a, 0x00, 0x15, 0xaa, 0x53, 0xa1, 0x96, 0xe1, 0x62, + 0x85, 0x5a, 0xd6, 0xd6, 0xd0, 0x45, 0x36, 0x09, 0x0a, 0xc7, 0xb2, 0x1a, 0x6c, 0x99, 0x70, 0x89, + 0x17, 0x9c, 0x1f, 0x78, 0xd1, 0x76, 0x96, 0xef, 0x8a, 0xf4, 0xba, 0x65, 0x6a, 0x2d, 0x74, 0xae, + 0x5c, 0x6a, 0x62, 0xca, 0xcb, 0xa6, 0x79, 0x99, 0x26, 0x97, 0xf5, 0x30, 0x65, 0x25, 0x1d, 0x74, + 0x21, 0x37, 0x3e, 0x48, 0xe2, 0x30, 0x89, 0x0d, 0x33, 0xa1, 0x94, 0xf8, 0x31, 0xcc, 0xf0, 0xa2, + 0xb3, 0xe9, 0x0f, 0xb0, 0xc5, 0x93, 0x3d, 0x91, 0x63, 0x1b, 0x83, 0x58, 0xf3, 0x19, 0x3c, 0x2b, + 0x9e, 0x84, 0x07, 0x33, 0x48, 0x5a, 0x1e, 0x19, 0x76, 0xb9, 0xb4, 0x3c, 0x32, 0xf0, 0x16, 0x9a, + 0x76, 0xc9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, 0xe2, 0x69, 0x37, 0xd1, 0x64, 0x88, 0xcd, 0x27, 0x24, 0x8e, 0x8c, 0x90, 0x4d, + 0x4a, 0x62, 0xc2, 0xff, 0x44, 0xdd, 0x44, 0x1a, 0xdf, 0x26, 0x74, 0x97, 0x98, 0x6f, 0x07, 0x00, + 0x00, 0xff, 0xff, 0xbc, 0x95, 0x87, 0x64, 0x53, 0x1d, 0x00, 0x00, } diff --git a/collector/internalproto/data_message.proto b/cars/sundae/sundae.proto similarity index 99% rename from collector/internalproto/data_message.proto rename to cars/sundae/sundae.proto index b53c8b9..19d6218 100644 --- a/collector/internalproto/data_message.proto +++ b/cars/sundae/sundae.proto @@ -1,5 +1,5 @@ syntax = "proto2"; -message DataMessage { //1512 bytes constraint +message SundaeDataMessage { // 1512 bytes constraint // @inject_tag: structs:"regen_enabled,indirect" csv:"regen_enabled" optional uint32 regen_enabled = 1; @@ -508,7 +508,4 @@ message DataMessage { //1512 bytes constraint // @inject_tag: structs:"packets_per_sec,indirect" csv:"packets_per_sec" optional float packets_per_sec = 171; - - // @inject_tag: structs:"-" csv:"time_collected" // Not in struct, b/c not data - optional int64 time_collected = 172; } diff --git a/collector/sources/zero_source.go b/cars/sundae/test_packets.go similarity index 88% rename from collector/sources/zero_source.go rename to cars/sundae/test_packets.go index d51b112..121ebbe 100644 --- a/collector/sources/zero_source.go +++ b/cars/sundae/test_packets.go @@ -1,83 +1,15 @@ -package sources +package sundae import ( - "context" - "fmt" "math/rand" - "time" - - "github.com/sscp/telemetry/collector/contextkeys" - internalproto "github.com/sscp/telemetry/collector/internalproto" "github.com/golang/protobuf/proto" - "golang.org/x/time/rate" ) -// ZeroPacketSource is a PacketSource that returns only zeroed out DataMessages -// at a given rate -type ZeroPacketSource struct { - outChan chan *ContextPacket - doneChan chan bool - limiter *rate.Limiter -} - -// Packets is the stream of zeroed binary packets -// It is simply a reference to outChan -func (zps *ZeroPacketSource) Packets() <-chan *ContextPacket { - return zps.outChan -} - -// Listen begins sending zeroed packets to the Packets channel. -// It launches a gorountine that sen -func (zps *ZeroPacketSource) Listen() { - go func() { - for { - select { - case <-zps.doneChan: - return - default: - err := zps.limiter.Wait(context.TODO()) - if err == nil { - zPacket, _ := CreateZeroPacket() - recievedTime := time.Now() - // Create context with time of receiving packet - ctx := contextkeys.ContextWithRecievedTime(context.Background(), recievedTime) - - zps.outChan <- &ContextPacket{ - Ctx: ctx, - Packet: zPacket, - } - } else { - fmt.Println("too fast") - } - } - } - }() -} - -// Close sends a close signal on doneChan and closes both doneChan and outChan. -// NOTE: this currently does not reset the ZeroPacketSource to listen again -func (zps *ZeroPacketSource) Close() { - zps.doneChan <- true - close(zps.doneChan) - close(zps.outChan) -} - -// NewZeroPacketSource constructs a new ZeroPacketSource that emits zeroed out -// packets at packetsPerSecond -func NewZeroPacketSource(packetsPerSecond int) PacketSource { - return &ZeroPacketSource{ - outChan: make(chan *ContextPacket), - doneChan: make(chan bool), - // Only allow one packet out at a time - limiter: rate.NewLimiter(rate.Limit(packetsPerSecond), 1), - } -} - // CreateZeroPacket returns a zeroed protocol buffer marshaled to binary func CreateZeroPacket() ([]byte, error) { zdm := CreateZeroDataMessage() - return proto.Marshal(zdm) + return proto.Marshal(&zdm) } func zeroUInt32() *uint32 { @@ -85,11 +17,6 @@ func zeroUInt32() *uint32 { return &z } -func zeroUInt64() *uint64 { - z := uint64(0) - return &z -} - func zeroInt32() *int32 { z := int32(0) return &z @@ -110,11 +37,6 @@ func randUInt32() *uint32 { return &z } -func randUInt64() *uint64 { - z := uint64(rand.Intn(100)) - return &z -} - func randInt32() *int32 { z := int32(rand.Intn(100)) return &z @@ -132,8 +54,8 @@ func randFloat32() *float32 { // CreateZeroDataMessage fills a DataMessage with pointers to zero values of // each value -func CreateZeroDataMessage() *internalproto.DataMessage { - zdm := internalproto.DataMessage{ +func CreateZeroDataMessage() SundaeDataMessage { + zdm := SundaeDataMessage{ RegenEnabled: zeroUInt32(), RegenCommand: zeroUInt32(), BatteryPower: zeroUInt32(), @@ -299,13 +221,13 @@ func CreateZeroDataMessage() *internalproto.DataMessage { BmsMotorControllerCurrentSum: zeroFloat32(), PacketsPerSec: zeroFloat32(), } - return &zdm + return zdm } // CreateRandomDataMessage fills a DataMessage with pointers to random values // for each entry in the DataMessage -func CreateRandomDataMessage() *internalproto.DataMessage { - zdm := internalproto.DataMessage{ +func CreateRandomDataMessage() SundaeDataMessage { + zdm := SundaeDataMessage{ RegenEnabled: randUInt32(), RegenCommand: randUInt32(), BatteryPower: randUInt32(), @@ -471,5 +393,5 @@ func CreateRandomDataMessage() *internalproto.DataMessage { BmsMotorControllerCurrentSum: randFloat32(), PacketsPerSec: randFloat32(), } - return &zdm + return zdm } diff --git a/collector/sundae/unpadded_test_data.blog b/cars/sundae/unpadded_test_data.blog similarity index 100% rename from collector/sundae/unpadded_test_data.blog rename to cars/sundae/unpadded_test_data.blog diff --git a/cars/sundae/verify_test.go b/cars/sundae/verify_test.go new file mode 100644 index 0000000..085196a --- /dev/null +++ b/cars/sundae/verify_test.go @@ -0,0 +1,45 @@ +package sundae + +import ( + "context" + "math" + "testing" +) + +type verifyFloat32Test struct { + inVal *float32 + outVal *float32 +} + +func (test verifyFloat32Test) runTest(t *testing.T) { +} + +var positiveinf = float32(math.Inf(1)) +var negativeinf = float32(math.Inf(-1)) +var nan = float32(math.NaN()) +var zero = float32(0.0) +var posnum = float32(10) +var negnum = float32(-10) + +func TestVerifyFloat32(t *testing.T) { + cases := []struct { + inVal *float32 + outVal *float32 + }{ + verifyFloat32Test{inVal: &posnum, outVal: &posnum}, + verifyFloat32Test{inVal: &negnum, outVal: &negnum}, + verifyFloat32Test{inVal: &zero, outVal: &zero}, + + verifyFloat32Test{inVal: &positiveinf, outVal: nil}, + verifyFloat32Test{inVal: &negativeinf, outVal: nil}, + verifyFloat32Test{inVal: &nan, outVal: nil}, + } + for _, tt := range cases { + ctx := context.Background() + output := verifyFloat32(ctx, tt.inVal, "testValue") + if tt.outVal != output { + t.Errorf("error: verifyFloat32(%v) != %v (should be %v)", + tt.inVal, output, tt.outVal) + } + } +} diff --git a/cmd/call.go b/cmd/call.go index 940e8f9..f067e63 100644 --- a/cmd/call.go +++ b/cmd/call.go @@ -15,15 +15,19 @@ import ( func readConfAndConnect(rootConfig *viper.Viper) *collector.CollectorClient { cfg := collector.CollectorClientConfig{} - rootConfig.UnmarshalKey("client", &cfg) + err := rootConfig.UnmarshalKey("client", &cfg) + if err != nil { + log.Fatalf("invalid config: %v", err) + return nil + } addr := net.JoinHostPort(cfg.Hostname, strconv.FormatInt(int64(cfg.Port), 10)) fmt.Printf("Connecting to collector at: %v\n", addr) client, err := collector.NewCollectorClient(cfg) if err != nil { log.Fatalf("Could not connect to collector: %v", err) + return nil } return client - } func printCollectorStatus(status *pb.CollectorStatus) { @@ -85,7 +89,10 @@ func createCallStart(rootConfig *viper.Viper) func(cmd *cobra.Command, args []st return func(cmd *cobra.Command, args []string) { runName := args[0] config := collector.CollectorClientConfig{} - rootConfig.UnmarshalKey("client", &config) + err := rootConfig.UnmarshalKey("client", &config) + if err != nil { + log.Fatalf("invalid config: %v", err) + } client := readConfAndConnect(rootConfig) defer client.Close() @@ -103,7 +110,10 @@ func createCallStart(rootConfig *viper.Viper) func(cmd *cobra.Command, args []st func createCallStop(rootConfig *viper.Viper) func(cmd *cobra.Command, args []string) { return func(cmd *cobra.Command, args []string) { config := collector.CollectorClientConfig{} - rootConfig.UnmarshalKey("client", &config) + err := rootConfig.UnmarshalKey("client", &config) + if err != nil { + log.Fatalf("invalid config: %v", err) + } client := readConfAndConnect(rootConfig) defer client.Close() @@ -120,7 +130,10 @@ func createCallStop(rootConfig *viper.Viper) func(cmd *cobra.Command, args []str func createCallStatus(rootConfig *viper.Viper) func(cmd *cobra.Command, args []string) { return func(cmd *cobra.Command, args []string) { config := collector.CollectorClientConfig{} - rootConfig.UnmarshalKey("client", &config) + err := rootConfig.UnmarshalKey("client", &config) + if err != nil { + log.Fatalf("invalid config: %v", err) + } client := readConfAndConnect(rootConfig) defer client.Close() diff --git a/cmd/collect.go b/cmd/collect.go index 892d4a4..2971c94 100644 --- a/cmd/collect.go +++ b/cmd/collect.go @@ -8,6 +8,7 @@ import ( "github.com/sscp/telemetry/collector" "context" + "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -33,6 +34,9 @@ func createRunCollectorFunc(rootConfig *viper.Viper) func(cmd *cobra.Command, ar return func(cmd *cobra.Command, args []string) error { config := collector.CollectorConfig{} err := rootConfig.UnmarshalKey("collector", &config) + if err != nil { + return err + } col, err := collector.NewUDPCollector(config) if err != nil { @@ -43,7 +47,10 @@ func createRunCollectorFunc(rootConfig *viper.Viper) func(cmd *cobra.Command, ar col.RecordRun(context.TODO(), args[0]) buf := bufio.NewReader(os.Stdin) fmt.Print("Press any key to end") - buf.ReadBytes('\n') + _, err = buf.ReadBytes('\n') + if err != nil { + return err + } return nil } diff --git a/cmd/server.go b/cmd/server.go index 285f7a8..7c016f7 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -2,6 +2,7 @@ package cmd import ( "fmt" + "log" "github.com/sscp/telemetry/collector" @@ -28,7 +29,10 @@ func registerServerCmd(rootCmd *cobra.Command, rootConfig *viper.Viper) { func createRunServerFunc(rootConfig *viper.Viper) func(cmd *cobra.Command, args []string) { return func(cmd *cobra.Command, args []string) { config := collector.CollectorServiceConfig{} - rootConfig.UnmarshalKey("server", &config) + err := rootConfig.UnmarshalKey("server", &config) + if err != nil { + log.Fatalf("invalid config: %v", err) + } fmt.Printf("Starting server on port %v, collector listening on port %v\n", config.Port, config.Collector.Port) collector.RunCollectionService(config) diff --git a/cmd/udpsend.go b/cmd/udpsend.go index 86f38bf..5483ec7 100644 --- a/cmd/udpsend.go +++ b/cmd/udpsend.go @@ -5,7 +5,7 @@ import ( "fmt" "os" - "github.com/sscp/telemetry/collector/sources" + "github.com/sscp/telemetry/sources" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -30,14 +30,18 @@ func registerUDPSendCmd(rootCmd *cobra.Command, rootConfig *viper.Viper) { func createUDPSendFunc(rootConfig *viper.Viper) func(cmd *cobra.Command, args []string) { return func(cmd *cobra.Command, args []string) { - zps := sources.NewZeroPacketSource(20) - go sources.SendPacketsAsUDP(zps.Packets(), 33333) + zps := sources.NewZeroRawEventSource(20) + go sources.SendEventsAsUDP(zps.RawEvents(), 33333) zps.Listen() fmt.Printf("Now sending packets on port %v\n", 33333) buf := bufio.NewReader(os.Stdin) fmt.Print("Press any key to end") - buf.ReadBytes('\n') - zps.Close() + _, err := buf.ReadBytes('\n') + if err != nil { + zps.Close() + } else { + zps.Close() + } } diff --git a/collector/collector.go b/collector/collector.go index 763c12d..e853e32 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -2,10 +2,10 @@ // car data stream. There are three primary concepts in addition to the core // collector defined below: // -// PacketSource (defined in source.go) which collects packets from UDP or -// some other source and passes them to the core collector. Implementations of a -// UDPPacketSource and a BlogPacketSource can be found in udp_source.go and -// blog_source.go respectively. +// RawEventSource (defined in sources/source.go) which collects packets from +// UDP or some other source and passes them to the core collector. +// Implementations of a UDPRawEventSource and a BlogRawEventSource can be found in +// udp_source.go and blog_source.go respectively. // // DataHandler (defined in handlers.go) is a sink for deserialized data in // the form of DataMessage. The implementation of a CSVWriter can be found in @@ -25,17 +25,14 @@ import ( "sync" "time" - "github.com/sscp/telemetry/collector/handlers" - internalproto "github.com/sscp/telemetry/collector/internalproto" - "github.com/sscp/telemetry/collector/sources" - sundaeproto "github.com/sscp/telemetry/collector/sundae" - "github.com/sscp/telemetry/log" - "github.com/opentracing/opentracing-go" -) -//go:generate protoc --go_out=internalproto ./internalproto/data_message.proto -//go:generate protoc-go-inject-tag -input=./internalproto/data_message.pb.go + "github.com/sscp/telemetry/cars" + "github.com/sscp/telemetry/events" + "github.com/sscp/telemetry/handlers" + "github.com/sscp/telemetry/log" + "github.com/sscp/telemetry/sources" +) const defaultBufferSize = 10 @@ -46,11 +43,11 @@ const defaultBufferSize = 10 // DataHandler. A goroutine running processPackets handles the delivery of // packets and deserialized data to all of the handlers. type Collector struct { - packetSource sources.PacketSource + packetSource sources.RawEventSource binaryHandlers []handlers.BinaryHandler - binaryChans []chan sources.ContextPacket + binaryChans []chan *events.ContextRawEvent dataHandlers []handlers.DataHandler - dataChans []chan ContextDataMessage + dataChans []chan *events.ContextDataEvent waitGroup *sync.WaitGroup status CollectorStatus } @@ -58,7 +55,7 @@ type Collector struct { // CollectorConfig holds config values needed to create a collector type CollectorConfig struct { Port int - CSV *handlers.CSVConfig + //CSV *handlers.CSVConfig Blog *handlers.BlogConfig Influx *handlers.InfluxConfig @@ -75,17 +72,10 @@ type CollectorStatus struct { PacketsProcessed int64 } -// ContextDataMessage is an internal type for passing packet-scoped context -// though a channel along with the DataMessage pointer -type ContextDataMessage struct { - ctx context.Context - data *internalproto.DataMessage -} - // NewUDPCollector creates a new Collector that listens on the UDP port // specified and writes .csv and .blog files func NewUDPCollector(cfg CollectorConfig) (*Collector, error) { - ps, err := sources.NewUDPPacketSource(cfg.Port) + ps, err := sources.NewUDPRawEventSource(cfg.Port) if err != nil { return nil, err } @@ -93,13 +83,13 @@ func NewUDPCollector(cfg CollectorConfig) (*Collector, error) { var binaryHandlers []handlers.BinaryHandler var dataHandlers []handlers.DataHandler - if cfg.CSV != nil { - csvHandler, err := handlers.NewCSVWriter(*cfg.CSV) - if err != nil { - return nil, err - } - dataHandlers = append(dataHandlers, csvHandler) - } + //if cfg.CSV != nil { + // csvHandler, err := handlers.NewCSVWriter(*cfg.CSV) + // if err != nil { + // return nil, err + // } + // dataHandlers = append(dataHandlers, csvHandler) + //} if cfg.Blog != nil { blogHandler, err := handlers.NewBlogWriter(*cfg.Blog) @@ -122,7 +112,7 @@ func NewUDPCollector(cfg CollectorConfig) (*Collector, error) { // NewCollector creates a new instance of Collector that reads packets from the // given PacketSource, and outputs data to the given BinaryHandlers and // Datahandlers. Channels are setup for each handler with the given bufferSize. -func NewCollector(ps sources.PacketSource, bh []handlers.BinaryHandler, dh []handlers.DataHandler) *Collector { +func NewCollector(ps sources.RawEventSource, bh []handlers.BinaryHandler, dh []handlers.DataHandler) *Collector { col := &Collector{ packetSource: ps, binaryHandlers: bh, @@ -134,7 +124,7 @@ func NewCollector(ps sources.PacketSource, bh []handlers.BinaryHandler, dh []han } // RecordRun starts listening for and processing packets from the -// PacketSource +// RawEventSource func (col *Collector) RecordRun(ctx context.Context, runName string) { span, ctx := opentracing.StartSpanFromContext(ctx, "collector/RecordRun") defer span.Finish() @@ -148,7 +138,7 @@ func (col *Collector) RecordRun(ctx context.Context, runName string) { col.status.RunName = runName col.status.Collecting = true - col.packetSource.Listen() + go col.packetSource.Listen() } // GetStatus returns the status struct for the collector @@ -163,6 +153,7 @@ func (col *Collector) Close(ctx context.Context) { defer span.Finish() col.packetSource.Close() + currentTime := time.Now() // Get time after we stop recording, not processing col.waitGroup.Wait() col.stopHandlers(ctx, currentTime) @@ -177,13 +168,13 @@ func (col *Collector) Close(ctx context.Context) { // BinaryHandler in binaryHandlers and an array of channels for each // DataHandler in dataHandlers. func (col *Collector) createChannels(bufferSize int) { - col.binaryChans = make([]chan sources.ContextPacket, len(col.binaryHandlers)) + col.binaryChans = make([]chan *events.ContextRawEvent, len(col.binaryHandlers)) for i := 0; i < len(col.binaryChans); i++ { - col.binaryChans[i] = make(chan sources.ContextPacket, bufferSize) + col.binaryChans[i] = make(chan *events.ContextRawEvent, bufferSize) } - col.dataChans = make([]chan ContextDataMessage, len(col.dataHandlers)) + col.dataChans = make([]chan *events.ContextDataEvent, len(col.dataHandlers)) for i := 0; i < len(col.dataChans); i++ { - col.dataChans[i] = make(chan ContextDataMessage, bufferSize) + col.dataChans[i] = make(chan *events.ContextDataEvent, bufferSize) } } @@ -215,35 +206,35 @@ func (col *Collector) stopHandlers(ctx context.Context, endTime time.Time) { // dataChans. To be called after the channels are created by createChannels. func (col *Collector) startHandlers(ctx context.Context, runName string, startTime time.Time) { for i, handler := range col.binaryHandlers { - wrapBinaryHandler(handler.HandlePacket, col.binaryChans[i], col.waitGroup) + wrapBinaryHandler(handler.HandleRawEvent, col.binaryChans[i], col.waitGroup) handler.HandleStartRun(ctx, runName, startTime) } for i, handler := range col.dataHandlers { - wrapDataHandler(handler.HandleData, col.dataChans[i], col.waitGroup) + wrapDataHandler(handler.HandleDataEvent, col.dataChans[i], col.waitGroup) handler.HandleStartRun(ctx, runName, startTime) } } // processPacket sends a single packet to all binaryChans in binary form and to // all dataChans in deserialized form -func (col *Collector) processPacket(ctx context.Context, packet []byte) { +func (col *Collector) processPacket(ctx context.Context, rawEvent events.RawEvent) { span, ctx := opentracing.StartSpanFromContext(ctx, "collector/processPacket") defer span.Finish() // Forward the binary packets first for i := range col.binaryChans { if len(col.binaryChans[i]) != cap(col.binaryChans[i]) { - col.binaryChans[i] <- sources.ContextPacket{ - Ctx: ctx, - Packet: packet, + col.binaryChans[i] <- &events.ContextRawEvent{ + Context: ctx, + RawEvent: rawEvent, } } else { col.binaryHandlers[i].HandleDroppedPacket(ctx) } } - // Deserialize ProtoBuf - dMsg, err := sundaeproto.Deserialize(ctx, packet) + // Deserialize rawEvent + dataEvent, err := cars.GetCarDeserializer(cars.Sundae)(ctx, rawEvent) if err != nil { log.Error(ctx, err, "Could not deserialize protobuf") return @@ -252,9 +243,9 @@ func (col *Collector) processPacket(ctx context.Context, packet []byte) { // Pass off deserialized data to channels for i := 0; i < len(col.dataChans); i++ { if len(col.dataChans[i]) != cap(col.dataChans[i]) { - col.dataChans[i] <- ContextDataMessage{ - ctx: ctx, - data: dMsg, + col.dataChans[i] <- &events.ContextDataEvent{ + Context: ctx, + DataEvent: dataEvent, } } else { col.dataHandlers[i].HandleDroppedData(ctx) @@ -265,8 +256,8 @@ func (col *Collector) processPacket(ctx context.Context, packet []byte) { // Listens to the incomming packets on the DataSource's channel and processes // them func (col *Collector) processPackets() { - for ctxPacket := range col.packetSource.Packets() { - col.processPacket(ctxPacket.Ctx, ctxPacket.Packet) + for ctxRawEvent := range col.packetSource.RawEvents() { + col.processPacket(ctxRawEvent.Context, ctxRawEvent.RawEvent) col.status.PacketsProcessed++ } col.closeChannels() @@ -276,12 +267,12 @@ func (col *Collector) processPackets() { // calls the BinaryHandler on each packet and context. One is added to the // given WaitGroup and when the goroutine exits, one is subtracted from the // WaitGroup. -func wrapBinaryHandler(binaryFunc func(context.Context, []byte), packetChan <-chan sources.ContextPacket, wg *sync.WaitGroup) { +func wrapBinaryHandler(binaryFunc func(context.Context, events.RawEvent), packetChan <-chan *events.ContextRawEvent, wg *sync.WaitGroup) { wg.Add(1) go func() { defer wg.Done() for packet := range packetChan { - binaryFunc(packet.Ctx, packet.Packet) + binaryFunc(packet.Context, packet.RawEvent) } }() } @@ -290,12 +281,12 @@ func wrapBinaryHandler(binaryFunc func(context.Context, []byte), packetChan <-ch // calls the DataHandler on each packet and context. One is added to the // given WaitGroup and when the goroutine exits, one is subtracted from the // WaitGroup. -func wrapDataHandler(dataFunc func(context.Context, *internalproto.DataMessage), dataMsgChan <-chan ContextDataMessage, wg *sync.WaitGroup) { +func wrapDataHandler(dataFunc func(context.Context, events.DataEvent), dataEventChan <-chan *events.ContextDataEvent, wg *sync.WaitGroup) { wg.Add(1) go func() { defer wg.Done() - for dataMsg := range dataMsgChan { - dataFunc(dataMsg.ctx, dataMsg.data) + for dataEvent := range dataEventChan { + dataFunc(dataEvent.Context, dataEvent.DataEvent) } }() } diff --git a/collector/collector_service.go b/collector/collector_service.go index fee6440..c1d42b1 100644 --- a/collector/collector_service.go +++ b/collector/collector_service.go @@ -20,8 +20,6 @@ import ( //go:generate protoc -I serviceproto collector_service.proto --go_out=plugins=grpc:serviceproto -const nilPort = 0 - // CollectorService is a server for telemetry that allows for controlling the // collector over GRPC type CollectorService struct { @@ -99,7 +97,7 @@ func (cs *CollectorService) StopCollecting(ctx context.Context, req *pb.StopRequ // GetCollectorStatus simply returns the status of the Collector func (cs *CollectorService) GetCollectorStatus(ctx context.Context, req *pb.StatusRequest) (*pb.CollectorStatus, error) { - span, ctx := opentracing.StartSpanFromContext(ctx, "collectorService/GetCollectorStatus") + span, _ := opentracing.StartSpanFromContext(ctx, "collectorService/GetCollectorStatus") defer span.Finish() return cs.getStatus(), nil @@ -158,6 +156,9 @@ func RunCollectionService(cfg CollectorServiceConfig) { } - grpcServer.Serve(lis) + err = grpcServer.Serve(lis) + if err != nil { + log.Fatalf("failed to start collector service: %v", err) + } } diff --git a/collector/collector_test.go b/collector/collector_test.go index 0a2381b..75a0264 100644 --- a/collector/collector_test.go +++ b/collector/collector_test.go @@ -1,16 +1,13 @@ package collector import ( - "github.com/golang/protobuf/proto" - - "github.com/sscp/telemetry/collector/handlers" - internalproto "github.com/sscp/telemetry/collector/internalproto" - "github.com/sscp/telemetry/collector/sources" - "context" - //"github.com/opentracing/opentracing-go" "testing" "time" + + "github.com/sscp/telemetry/events" + "github.com/sscp/telemetry/handlers" + "github.com/sscp/telemetry/sources" ) type CollectorTest struct { @@ -52,15 +49,7 @@ func (tbh *testBinaryHandler) HandleEndRun(ctx context.Context, endTime time.Tim } } -func (tbh *testBinaryHandler) HandlePacket(ctx context.Context, packet []byte) { - dm := internalproto.DataMessage{} - err := proto.Unmarshal(packet, &dm) - if err != nil { - tbh.t.Errorf("Expected no deserialiation error, instead got %v", err) - } - if dm.GetMotorControllerSpeed() != float32(0.0) { - tbh.t.Errorf("Expected struct to be zeroed but got for motor speed %v instead", dm.GetMotorControllerSpeed()) - } +func (tbh *testBinaryHandler) HandleRawEvent(ctx context.Context, rawEvent events.RawEvent) { time.Sleep(tbh.delay) tbh.DeliveryCount++ } @@ -98,7 +87,7 @@ func (tdh *testDataHandler) HandleEndRun(ctx context.Context, endTime time.Time) } } -func (tbh *testDataHandler) HandleData(ctx context.Context, data *internalproto.DataMessage) { +func (tbh *testDataHandler) HandleDataEvent(ctx context.Context, dataEvent events.DataEvent) { time.Sleep(tbh.delay) tbh.DeliveryCount++ } @@ -107,113 +96,118 @@ func (tbh *testDataHandler) HandleDroppedData(ctx context.Context) { tbh.DroppedPackets++ } -func runCollectorTest(t *testing.T, test CollectorTest) { - bh := newTestBinaryHandler(t, test.BinaryHandlerDelay) - dh := newTestDataHandler(t, test.DataHandlerDelay) - zps := sources.NewZeroPacketSource(test.PacketsPerSecond) - telem := NewCollector(zps, []handlers.BinaryHandler{handlers.BinaryHandler(bh)}, []handlers.DataHandler{handlers.DataHandler(dh)}) - ctx := context.TODO() - telem.RecordRun(ctx, "test") - time.Sleep(test.TestTime) - telem.Close(ctx) - expectedPackets := int64(float64(test.PacketsPerSecond) * test.TestTime.Seconds()) - if telem.GetStatus().PacketsProcessed < expectedPackets { - t.Errorf("Expected to process %v packets, but collector only processed %v packets", expectedPackets, telem.GetStatus().PacketsProcessed) +func TestCollector(t *testing.T) { + + specs := []CollectorTest{ + CollectorTest{ + PacketsPerSecond: 100, + BufferSize: 1, + TestTime: 500 * time.Millisecond, + BinaryHandlerDelay: 5 * time.Millisecond, + DataHandlerDelay: 5 * time.Millisecond, + BinaryReceiveAll: true, + DataReceiveAll: true, + }, + CollectorTest{ + PacketsPerSecond: 100, + BufferSize: 1, + TestTime: 500 * time.Millisecond, + BinaryHandlerDelay: 100 * time.Millisecond, + DataHandlerDelay: 5 * time.Millisecond, + BinaryReceiveAll: false, + DataReceiveAll: true, + }, + CollectorTest{ + PacketsPerSecond: 100, + BufferSize: 1, + TestTime: 500 * time.Millisecond, + BinaryHandlerDelay: 5 * time.Millisecond, + DataHandlerDelay: 100 * time.Millisecond, + BinaryReceiveAll: true, + DataReceiveAll: false, + }, + + CollectorTest{ + PacketsPerSecond: 100, + BufferSize: 10, + TestTime: 500 * time.Millisecond, + BinaryHandlerDelay: 5 * time.Millisecond, + DataHandlerDelay: 5 * time.Millisecond, + BinaryReceiveAll: true, + DataReceiveAll: true, + }, + CollectorTest{ + PacketsPerSecond: 250, + BufferSize: 10, + TestTime: 500 * time.Millisecond, + BinaryHandlerDelay: 1 * time.Millisecond, + DataHandlerDelay: 1 * time.Millisecond, + BinaryReceiveAll: true, + DataReceiveAll: true, + }, + CollectorTest{ + PacketsPerSecond: 250, + BufferSize: 10, + TestTime: 500 * time.Millisecond, + BinaryHandlerDelay: 0 * time.Millisecond, + DataHandlerDelay: 0 * time.Millisecond, + BinaryReceiveAll: true, + DataReceiveAll: true, + }, + CollectorTest{ + PacketsPerSecond: 250, + BufferSize: 10, + TestTime: 500 * time.Millisecond, + BinaryHandlerDelay: 10 * time.Millisecond, + DataHandlerDelay: 10 * time.Millisecond, + BinaryReceiveAll: false, + DataReceiveAll: false, + }, } - if test.BinaryReceiveAll { - if bh.DeliveryCount < telem.GetStatus().PacketsProcessed { - t.Errorf("Expected all packets to be delivered to binary handler, but %v packets were processed and %v delivered", telem.GetStatus().PacketsProcessed, bh.DeliveryCount) - } - } else { - if bh.DeliveryCount == telem.GetStatus().PacketsProcessed { - t.Errorf("Expected binary handler to fall behind, but %v packets were processed and %v delivered", telem.GetStatus().PacketsProcessed, bh.DeliveryCount) - } + for _, test := range specs { + bh := newTestBinaryHandler(t, test.BinaryHandlerDelay) + dh := newTestDataHandler(t, test.DataHandlerDelay) + zps := sources.NewZeroRawEventSource(test.PacketsPerSecond) + telem := NewCollector(zps, []handlers.BinaryHandler{handlers.BinaryHandler(bh)}, []handlers.DataHandler{handlers.DataHandler(dh)}) + ctx := context.TODO() - } + telem.RecordRun(ctx, "test") + + time.Sleep(test.TestTime) + + telem.Close(ctx) + + expectedPackets := int64(float64(test.PacketsPerSecond) * test.TestTime.Seconds()) + + if telem.GetStatus().PacketsProcessed < expectedPackets { + t.Errorf("Expected to process %v packets, but collector only processed %v packets", expectedPackets, telem.GetStatus().PacketsProcessed) + } else { - if test.DataReceiveAll { - if dh.DeliveryCount < telem.GetStatus().PacketsProcessed { - t.Errorf("Expected all packets to be delivered to data handler, but %v packets were processed and %v delivered", telem.GetStatus().PacketsProcessed, dh.DeliveryCount) } - } else { - if dh.DeliveryCount == telem.GetStatus().PacketsProcessed { - t.Errorf("Expected data handler to fall behind, but %v packets were processed and %v delivered", telem.GetStatus().PacketsProcessed, dh.DeliveryCount) + if test.BinaryReceiveAll { + if bh.DeliveryCount < telem.GetStatus().PacketsProcessed { + t.Errorf("Expected all packets to be delivered to binary handler, but %v packets were processed and %v delivered", telem.GetStatus().PacketsProcessed, bh.DeliveryCount) + } + } else { + if bh.DeliveryCount == telem.GetStatus().PacketsProcessed { + t.Errorf("Expected binary handler to fall behind, but %v packets were processed and %v delivered", telem.GetStatus().PacketsProcessed, bh.DeliveryCount) + + } } - } -} + if test.DataReceiveAll { + if dh.DeliveryCount < telem.GetStatus().PacketsProcessed { + t.Errorf("Expected all packets to be delivered to data handler, but %v packets were processed and %v delivered", telem.GetStatus().PacketsProcessed, dh.DeliveryCount) + } + } else { + if dh.DeliveryCount == telem.GetStatus().PacketsProcessed { + t.Errorf("Expected data handler to fall behind, but %v packets were processed and %v delivered", telem.GetStatus().PacketsProcessed, dh.DeliveryCount) -var collectorTests []CollectorTest = []CollectorTest{ - CollectorTest{ - PacketsPerSecond: 100, - BufferSize: 1, - TestTime: 500 * time.Millisecond, - BinaryHandlerDelay: 5 * time.Millisecond, - DataHandlerDelay: 5 * time.Millisecond, - BinaryReceiveAll: true, - DataReceiveAll: true, - }, - CollectorTest{ - PacketsPerSecond: 100, - BufferSize: 1, - TestTime: 500 * time.Millisecond, - BinaryHandlerDelay: 100 * time.Millisecond, - DataHandlerDelay: 5 * time.Millisecond, - BinaryReceiveAll: false, - DataReceiveAll: true, - }, - CollectorTest{ - PacketsPerSecond: 100, - BufferSize: 1, - TestTime: 500 * time.Millisecond, - BinaryHandlerDelay: 5 * time.Millisecond, - DataHandlerDelay: 100 * time.Millisecond, - BinaryReceiveAll: true, - DataReceiveAll: false, - }, - - CollectorTest{ - PacketsPerSecond: 100, - BufferSize: 10, - TestTime: 500 * time.Millisecond, - BinaryHandlerDelay: 5 * time.Millisecond, - DataHandlerDelay: 5 * time.Millisecond, - BinaryReceiveAll: true, - DataReceiveAll: true, - }, - CollectorTest{ - PacketsPerSecond: 250, - BufferSize: 10, - TestTime: 500 * time.Millisecond, - BinaryHandlerDelay: 1 * time.Millisecond, - DataHandlerDelay: 1 * time.Millisecond, - BinaryReceiveAll: true, - DataReceiveAll: true, - }, - CollectorTest{ - PacketsPerSecond: 250, - BufferSize: 10, - TestTime: 500 * time.Millisecond, - BinaryHandlerDelay: 0 * time.Millisecond, - DataHandlerDelay: 0 * time.Millisecond, - BinaryReceiveAll: true, - DataReceiveAll: true, - }, - CollectorTest{ - PacketsPerSecond: 250, - BufferSize: 10, - TestTime: 500 * time.Millisecond, - BinaryHandlerDelay: 10 * time.Millisecond, - DataHandlerDelay: 10 * time.Millisecond, - BinaryReceiveAll: false, - DataReceiveAll: false, - }, -} + } + + } -func TestCollector(t *testing.T) { - for _, test := range collectorTests { - runCollectorTest(t, test) } } diff --git a/collector/handlers/data_buffer_test.go b/collector/handlers/data_buffer_test.go deleted file mode 100644 index d81e048..0000000 --- a/collector/handlers/data_buffer_test.go +++ /dev/null @@ -1,80 +0,0 @@ -package handlers - -import ( - "context" - "reflect" - "testing" - "time" - - internalproto "github.com/sscp/telemetry/collector/internalproto" - "github.com/sscp/telemetry/collector/sources" -) - -func TestDataMessageBuffer(t *testing.T) { - runDataMessageTest(t, 20, 10) - runDataMessageTest(t, 20, 1) - runDataMessageTest(t, 20, 2) - runDataMessageTest(t, 20, 5) -} - -func runDataMessageTest(t *testing.T, numItems int, bufferSize int) { - - in := createTestDataMessages(numItems) - var out []*internalproto.DataMessage - - dmb := NewDataMessageBuffer(func(ctx context.Context, data []*internalproto.DataMessage) { - for _, dm := range data { - out = append(out, dm) - } - }, bufferSize) - - for _, dm := range in { - dmb.AddData(context.TODO(), dm) - } - dmb.Flush(context.TODO()) - - if len(in) != len(out) { - t.Errorf("Not all data made it though. In: %v Out: %v", len(in), len(out)) - } - inIndices := getIndexList(in) - outIndices := getIndexList(out) - if !reflect.DeepEqual(inIndices, outIndices) { - t.Errorf("Buffer corrupted data. In: %v Out: %v", inIndices, outIndices) - } - - inTimes := getTimeList(in) - outTimes := getTimeList(out) - if !reflect.DeepEqual(inTimes, outTimes) { - t.Errorf("Buffer corrupted data. In: %v Out: %v", inTimes, outTimes) - } - -} - -func createTestDataMessages(numItems int) []*internalproto.DataMessage { - var arr []*internalproto.DataMessage - for i := 0; i < numItems; i++ { - zdm := sources.CreateZeroDataMessage() - time := time.Now().UnixNano() - zdm.TimeCollected = &time - index := uint32(i) - zdm.RegenEnabled = &index - arr = append(arr, zdm) - } - return arr -} - -func getTimeList(dms []*internalproto.DataMessage) []int64 { - times := make([]int64, len(dms)) - for i, dm := range dms { - times[i] = dm.GetTimeCollected() - } - return times -} - -func getIndexList(dms []*internalproto.DataMessage) []uint32 { - indies := make([]uint32, len(dms)) - for i, dm := range dms { - indies[i] = dm.GetRegenEnabled() - } - return indies -} diff --git a/collector/internalproto/internalproto/data_message.pb.go b/collector/internalproto/internalproto/data_message.pb.go deleted file mode 100644 index 1b5c509..0000000 --- a/collector/internalproto/internalproto/data_message.pb.go +++ /dev/null @@ -1,1723 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: internalproto/data_message.proto - -/* -Package data_message is a generated protocol buffer package. - -It is generated from these files: - internalproto/data_message.proto - -It has these top-level messages: - DataMessage -*/ -package data_message - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -type DataMessage struct { - // @inject_tag: structs:"regen_enabled,indirect" csv:"regen_enabled" - RegenEnabled *uint32 `protobuf:"varint,1,opt,name=regen_enabled,json=regenEnabled" json:"regen_enabled,omitempty"` - // @inject_tag: structs:"regen_command,indirect" csv:"regen_command" - RegenCommand *uint32 `protobuf:"varint,2,opt,name=regen_command,json=regenCommand" json:"regen_command,omitempty"` - // @inject_tag: structs:"battery_power,indirect" csv:"battery_power" - BatteryPower *uint32 `protobuf:"varint,3,opt,name=battery_power,json=batteryPower" json:"battery_power,omitempty"` - // @inject_tag: structs:"array_power,indirect" csv:"array_power" - ArrayPower *float32 `protobuf:"fixed32,4,opt,name=array_power,json=arrayPower" json:"array_power,omitempty"` - // @inject_tag: structs:"reverse_on,indirect" csv:"reverse_on" - ReverseOn *uint32 `protobuf:"varint,5,opt,name=reverse_on,json=reverseOn" json:"reverse_on,omitempty"` - // @inject_tag: structs:"low_volt_power,indirect" csv:"low_volt_power" - LowVoltPower *float32 `protobuf:"fixed32,6,opt,name=low_volt_power,json=lowVoltPower" json:"low_volt_power,omitempty"` - // @inject_tag: structs:"cell_read_error,indirect" csv:"cell_read_error" - CellReadError *int32 `protobuf:"varint,7,opt,name=cell_read_error,json=cellReadError" json:"cell_read_error,omitempty"` - // @inject_tag: structs:"cell_bleed,indirect" csv:"cell_bleed" - CellBleed *uint32 `protobuf:"varint,8,opt,name=cell_bleed,json=cellBleed" json:"cell_bleed,omitempty"` - // @inject_tag: structs:"cruise_speed,indirect" csv:"cruise_speed" - CruiseSpeed *float32 `protobuf:"fixed32,9,opt,name=cruise_speed,json=cruiseSpeed" json:"cruise_speed,omitempty"` - // @inject_tag: structs:"hazard_lights_on,indirect" csv:"hazard_lights_on" - HazardLightsOn *int32 `protobuf:"varint,10,opt,name=hazard_lights_on,json=hazardLightsOn" json:"hazard_lights_on,omitempty"` - // @inject_tag: structs:"battery_voltage,indirect" csv:"battery_voltage" - BatteryVoltage *float32 `protobuf:"fixed32,11,opt,name=battery_voltage,json=batteryVoltage" json:"battery_voltage,omitempty"` - // @inject_tag: structs:"ltc6804_badpec,indirect" csv:"ltc6804_badpec" - Ltc6804Badpec *uint32 `protobuf:"varint,12,opt,name=ltc6804_badpec,json=ltc6804Badpec" json:"ltc6804_badpec,omitempty"` - // @inject_tag: structs:"bms_state,indirect" csv:"bms_state" - BmsState *uint32 `protobuf:"varint,13,opt,name=bms_state,json=bmsState" json:"bms_state,omitempty"` - // @inject_tag: structs:"charge_enabled,indirect" csv:"charge_enabled" - ChargeEnabled *int32 `protobuf:"varint,14,opt,name=charge_enabled,json=chargeEnabled" json:"charge_enabled,omitempty"` - // @inject_tag: structs:"discharge_enabled,indirect" csv:"discharge_enabled" - DischargeEnabled *int32 `protobuf:"varint,15,opt,name=discharge_enabled,json=dischargeEnabled" json:"discharge_enabled,omitempty"` - // @inject_tag: structs:"highside_contactor_on,indirect" csv:"highside_contactor_on" - HighsideContactorOn *int32 `protobuf:"varint,16,opt,name=highside_contactor_on,json=highsideContactorOn" json:"highside_contactor_on,omitempty"` - // @inject_tag: structs:"lowside_contactor_on,indirect" csv:"lowside_contactor_on" - LowsideContactorOn *int32 `protobuf:"varint,17,opt,name=lowside_contactor_on,json=lowsideContactorOn" json:"lowside_contactor_on,omitempty"` - // @inject_tag: structs:"precharge_on,indirect" csv:"precharge_on" - PrechargeOn *int32 `protobuf:"varint,18,opt,name=precharge_on,json=prechargeOn" json:"precharge_on,omitempty"` - // @inject_tag: structs:"low_volt_bus_on,indirect" csv:"low_volt_bus_on" - LowVoltBusOn *int32 `protobuf:"varint,19,opt,name=low_volt_bus_on,json=lowVoltBusOn" json:"low_volt_bus_on,omitempty"` - // @inject_tag: structs:"battery_temp_1,indirect" csv:"battery_temp_1" - BatteryTemp_1 *float32 `protobuf:"fixed32,20,opt,name=battery_temp_1,json=batteryTemp1" json:"battery_temp_1,omitempty"` - // @inject_tag: structs:"battery_temp_2,indirect" csv:"battery_temp_2" - BatteryTemp_2 *float32 `protobuf:"fixed32,21,opt,name=battery_temp_2,json=batteryTemp2" json:"battery_temp_2,omitempty"` - // @inject_tag: structs:"battery_temp_3,indirect" csv:"battery_temp_3" - BatteryTemp_3 *float32 `protobuf:"fixed32,22,opt,name=battery_temp_3,json=batteryTemp3" json:"battery_temp_3,omitempty"` - // @inject_tag: structs:"battery_temp_4,indirect" csv:"battery_temp_4" - BatteryTemp_4 *float32 `protobuf:"fixed32,23,opt,name=battery_temp_4,json=batteryTemp4" json:"battery_temp_4,omitempty"` - // @inject_tag: structs:"battery_temp_5,indirect" csv:"battery_temp_5" - BatteryTemp_5 *float32 `protobuf:"fixed32,24,opt,name=battery_temp_5,json=batteryTemp5" json:"battery_temp_5,omitempty"` - // @inject_tag: structs:"battery_temp_6,indirect" csv:"battery_temp_6" - BatteryTemp_6 *float32 `protobuf:"fixed32,25,opt,name=battery_temp_6,json=batteryTemp6" json:"battery_temp_6,omitempty"` - // @inject_tag: structs:"bms_precharge_battery_adc,indirect" csv:"bms_precharge_battery_adc" - BmsPrechargeBatteryAdc *float32 `protobuf:"fixed32,26,opt,name=bms_precharge_battery_adc,json=bmsPrechargeBatteryAdc" json:"bms_precharge_battery_adc,omitempty"` - // @inject_tag: structs:"bms_precharge_car_adc,indirect" csv:"bms_precharge_car_adc" - BmsPrechargeCarAdc *float32 `protobuf:"fixed32,27,opt,name=bms_precharge_car_adc,json=bmsPrechargeCarAdc" json:"bms_precharge_car_adc,omitempty"` - // @inject_tag: structs:"low_volt_output_current,indirect" csv:"low_volt_output_current" - LowVoltOutputCurrent *float32 `protobuf:"fixed32,29,opt,name=low_volt_output_current,json=lowVoltOutputCurrent" json:"low_volt_output_current,omitempty"` - // @inject_tag: structs:"array_current,indirect" csv:"array_current" - ArrayCurrent *float32 `protobuf:"fixed32,30,opt,name=array_current,json=arrayCurrent" json:"array_current,omitempty"` - // @inject_tag: structs:"battery_current,indirect" csv:"battery_current" - BatteryCurrent *float32 `protobuf:"fixed32,31,opt,name=battery_current,json=batteryCurrent" json:"battery_current,omitempty"` - // @inject_tag: structs:"left_motor_controller_power,indirect" csv:"left_motor_controller_power" - LeftMotorControllerPower *float32 `protobuf:"fixed32,32,opt,name=left_motor_controller_power,json=leftMotorControllerPower" json:"left_motor_controller_power,omitempty"` - // @inject_tag: structs:"right_motor_controller_power,indirect" csv:"right_motor_controller_power" - RightMotorControllerPower *float32 `protobuf:"fixed32,33,opt,name=right_motor_controller_power,json=rightMotorControllerPower" json:"right_motor_controller_power,omitempty"` - // @inject_tag: structs:"amp_hours,indirect" csv:"amp_hours" - AmpHours *float32 `protobuf:"fixed32,34,opt,name=amp_hours,json=ampHours" json:"amp_hours,omitempty"` - // @inject_tag: structs:"head_lights_on,indirect" csv:"head_lights_on" - HeadLightsOn *int32 `protobuf:"varint,35,opt,name=head_lights_on,json=headLightsOn" json:"head_lights_on,omitempty"` - // @inject_tag: structs:"brake_lights_on,indirect" csv:"brake_lights_on" - BrakeLightsOn *int32 `protobuf:"varint,36,opt,name=brake_lights_on,json=brakeLightsOn" json:"brake_lights_on,omitempty"` - // @inject_tag: structs:"right_blinker_on,indirect" csv:"right_blinker_on" - RightBlinkerOn *int32 `protobuf:"varint,37,opt,name=right_blinker_on,json=rightBlinkerOn" json:"right_blinker_on,omitempty"` - // @inject_tag: structs:"left_blinker_on,indirect" csv:"left_blinker_on" - LeftBlinkerOn *int32 `protobuf:"varint,38,opt,name=left_blinker_on,json=leftBlinkerOn" json:"left_blinker_on,omitempty"` - // @inject_tag: structs:"brake_pressed,indirect" csv:"brake_pressed" - BrakePressed *int32 `protobuf:"varint,39,opt,name=brake_pressed,json=brakePressed" json:"brake_pressed,omitempty"` - // @inject_tag: structs:"throttle_pressed,indirect" csv:"throttle_pressed" - ThrottlePressed *int32 `protobuf:"varint,40,opt,name=throttle_pressed,json=throttlePressed" json:"throttle_pressed,omitempty"` - // @inject_tag: structs:"drive_mode,indirect" csv:"drive_mode" - DriveMode *uint32 `protobuf:"varint,41,opt,name=drive_mode,json=driveMode" json:"drive_mode,omitempty"` - // @inject_tag: structs:"motor_controller_enabled,indirect" csv:"motor_controller_enabled" - MotorControllerEnabled *int32 `protobuf:"varint,42,opt,name=motor_controller_enabled,json=motorControllerEnabled" json:"motor_controller_enabled,omitempty"` - // @inject_tag: structs:"motor_controller_speed,indirect" csv:"motor_controller_speed" - MotorControllerSpeed *float32 `protobuf:"fixed32,43,opt,name=motor_controller_speed,json=motorControllerSpeed" json:"motor_controller_speed,omitempty"` - // @inject_tag: structs:"motor_controller_rpm,indirect" csv:"motor_controller_rpm" - MotorControllerRpm *float32 `protobuf:"fixed32,44,opt,name=motor_controller_rpm,json=motorControllerRpm" json:"motor_controller_rpm,omitempty"` - // @inject_tag: structs:"avg_odometer,indirect" csv:"avg_odometer" - AvgOdometer *float32 `protobuf:"fixed32,45,opt,name=avg_odometer,json=avgOdometer" json:"avg_odometer,omitempty"` - // @inject_tag: structs:"left_motor_temp,indirect" csv:"left_motor_temp" - LeftMotorTemp *float32 `protobuf:"fixed32,46,opt,name=left_motor_temp,json=leftMotorTemp" json:"left_motor_temp,omitempty"` - // @inject_tag: structs:"right_motor_temp,indirect" csv:"right_motor_temp" - RightMotorTemp *float32 `protobuf:"fixed32,47,opt,name=right_motor_temp,json=rightMotorTemp" json:"right_motor_temp,omitempty"` - // @inject_tag: structs:"left_motor_controller_temp,indirect" csv:"left_motor_controller_temp" - LeftMotorControllerTemp *float32 `protobuf:"fixed32,48,opt,name=left_motor_controller_temp,json=leftMotorControllerTemp" json:"left_motor_controller_temp,omitempty"` - // @inject_tag: structs:"right_motor_controller_temp,indirect" csv:"right_motor_controller_temp" - RightMotorControllerTemp *float32 `protobuf:"fixed32,49,opt,name=right_motor_controller_temp,json=rightMotorControllerTemp" json:"right_motor_controller_temp,omitempty"` - // @inject_tag: structs:"left_motor_controller_alive,indirect" csv:"left_motor_controller_alive" - LeftMotorControllerAlive *float32 `protobuf:"fixed32,50,opt,name=left_motor_controller_alive,json=leftMotorControllerAlive" json:"left_motor_controller_alive,omitempty"` - // @inject_tag: structs:"right_motor_controller_alive,indirect" csv:"right_motor_controller_alive" - RightMotorControllerAlive *float32 `protobuf:"fixed32,51,opt,name=right_motor_controller_alive,json=rightMotorControllerAlive" json:"right_motor_controller_alive,omitempty"` - // @inject_tag: structs:"left_motor_controller_current,indirect" csv:"left_motor_controller_current" - LeftMotorControllerCurrent *float32 `protobuf:"fixed32,52,opt,name=left_motor_controller_current,json=leftMotorControllerCurrent" json:"left_motor_controller_current,omitempty"` - // @inject_tag: structs:"right_motor_controller_current,indirect" csv:"right_motor_controller_current" - RightMotorControllerCurrent *float32 `protobuf:"fixed32,53,opt,name=right_motor_controller_current,json=rightMotorControllerCurrent" json:"right_motor_controller_current,omitempty"` - // @inject_tag: structs:"motor_controller_current_diff,indirect" csv:"motor_controller_current_diff" - MotorControllerCurrentDiff *float32 `protobuf:"fixed32,54,opt,name=motor_controller_current_diff,json=motorControllerCurrentDiff" json:"motor_controller_current_diff,omitempty"` - // @inject_tag: structs:"left_motor_controller_error,indirect" csv:"left_motor_controller_error" - LeftMotorControllerError *uint32 `protobuf:"varint,55,opt,name=left_motor_controller_error,json=leftMotorControllerError" json:"left_motor_controller_error,omitempty"` - // @inject_tag: structs:"right_motor_controller_error,indirect" csv:"right_motor_controller_error" - RightMotorControllerError *uint32 `protobuf:"varint,56,opt,name=right_motor_controller_error,json=rightMotorControllerError" json:"right_motor_controller_error,omitempty"` - // @inject_tag: structs:"left_motor_controller_limit,indirect" csv:"left_motor_controller_limit" - LeftMotorControllerLimit *uint32 `protobuf:"varint,57,opt,name=left_motor_controller_limit,json=leftMotorControllerLimit" json:"left_motor_controller_limit,omitempty"` - // @inject_tag: structs:"right_motor_controller_limit,indirect" csv:"right_motor_controller_limit" - RightMotorControllerLimit *uint32 `protobuf:"varint,58,opt,name=right_motor_controller_limit,json=rightMotorControllerLimit" json:"right_motor_controller_limit,omitempty"` - // @inject_tag: structs:"left_motor_controller_rx_error_count,indirect" csv:"left_motor_controller_rx_error_count" - LeftMotorControllerRxErrorCount *uint32 `protobuf:"varint,59,opt,name=left_motor_controller_rx_error_count,json=leftMotorControllerRxErrorCount" json:"left_motor_controller_rx_error_count,omitempty"` - // @inject_tag: structs:"right_motor_controller_rx_error_count,indirect" csv:"right_motor_controller_rx_error_count" - RightMotorControllerRxErrorCount *uint32 `protobuf:"varint,60,opt,name=right_motor_controller_rx_error_count,json=rightMotorControllerRxErrorCount" json:"right_motor_controller_rx_error_count,omitempty"` - // @inject_tag: structs:"left_motor_controller_tx_error_count,indirect" csv:"left_motor_controller_tx_error_count" - LeftMotorControllerTxErrorCount *uint32 `protobuf:"varint,61,opt,name=left_motor_controller_tx_error_count,json=leftMotorControllerTxErrorCount" json:"left_motor_controller_tx_error_count,omitempty"` - // @inject_tag: structs:"right_motor_controller_tx_error_count,indirect" csv:"right_motor_controller_tx_error_count" - RightMotorControllerTxErrorCount *uint32 `protobuf:"varint,62,opt,name=right_motor_controller_tx_error_count,json=rightMotorControllerTxErrorCount" json:"right_motor_controller_tx_error_count,omitempty"` - // @inject_tag: structs:"left_motor_controller_bus_voltage,indirect" csv:"left_motor_controller_bus_voltage" - LeftMotorControllerBusVoltage *float32 `protobuf:"fixed32,63,opt,name=left_motor_controller_bus_voltage,json=leftMotorControllerBusVoltage" json:"left_motor_controller_bus_voltage,omitempty"` - // @inject_tag: structs:"right_motor_controller_bus_voltage,indirect" csv:"right_motor_controller_bus_voltage" - RightMotorControllerBusVoltage *float32 `protobuf:"fixed32,64,opt,name=right_motor_controller_bus_voltage,json=rightMotorControllerBusVoltage" json:"right_motor_controller_bus_voltage,omitempty"` - // @inject_tag: structs:"left_motor_controller_15v_voltage,indirect" csv:"left_motor_controller_15v_voltage" - LeftMotorController_15VVoltage *float32 `protobuf:"fixed32,65,opt,name=left_motor_controller_15v_voltage,json=leftMotorController15vVoltage" json:"left_motor_controller_15v_voltage,omitempty"` - // @inject_tag: structs:"right_motor_controller_15v_voltage,indirect" csv:"right_motor_controller_15v_voltage" - RightMotorController_15VVoltage *float32 `protobuf:"fixed32,66,opt,name=right_motor_controller_15v_voltage,json=rightMotorController15vVoltage" json:"right_motor_controller_15v_voltage,omitempty"` - // @inject_tag: structs:"left_motor_controller_3v3_voltage,indirect" csv:"left_motor_controller_3v3_voltage" - LeftMotorController_3V3Voltage *float32 `protobuf:"fixed32,67,opt,name=left_motor_controller_3v3_voltage,json=leftMotorController3v3Voltage" json:"left_motor_controller_3v3_voltage,omitempty"` - // @inject_tag: structs:"right_motor_controller_3v3_voltage,indirect" csv:"right_motor_controller_3v3_voltage" - RightMotorController_3V3Voltage *float32 `protobuf:"fixed32,68,opt,name=right_motor_controller_3v3_voltage,json=rightMotorController3v3Voltage" json:"right_motor_controller_3v3_voltage,omitempty"` - // @inject_tag: structs:"left_motor_controller_1v9_voltage,indirect" csv:"left_motor_controller_1v9_voltage" - LeftMotorController_1V9Voltage *float32 `protobuf:"fixed32,69,opt,name=left_motor_controller_1v9_voltage,json=leftMotorController1v9Voltage" json:"left_motor_controller_1v9_voltage,omitempty"` - // @inject_tag: structs:"right_motor_controller_1v9_voltage,indirect" csv:"right_motor_controller_1v9_voltage" - RightMotorController_1V9Voltage *float32 `protobuf:"fixed32,70,opt,name=right_motor_controller_1v9_voltage,json=rightMotorController1v9Voltage" json:"right_motor_controller_1v9_voltage,omitempty"` - // @inject_tag: structs:"left_motor_controller_dsp_temp,indirect" csv:"left_motor_controller_dsp_temp" - LeftMotorControllerDspTemp *float32 `protobuf:"fixed32,71,opt,name=left_motor_controller_dsp_temp,json=leftMotorControllerDspTemp" json:"left_motor_controller_dsp_temp,omitempty"` - // @inject_tag: structs:"right_motor_controller_dsp_temp,indirect" csv:"right_motor_controller_dsp_temp" - RightMotorControllerDspTemp *float32 `protobuf:"fixed32,72,opt,name=right_motor_controller_dsp_temp,json=rightMotorControllerDspTemp" json:"right_motor_controller_dsp_temp,omitempty"` - // @inject_tag: structs:"left_motor_controller_phase_current,indirect" csv:"left_motor_controller_phase_current" - LeftMotorControllerPhaseCurrent *float32 `protobuf:"fixed32,73,opt,name=left_motor_controller_phase_current,json=leftMotorControllerPhaseCurrent" json:"left_motor_controller_phase_current,omitempty"` - // @inject_tag: structs:"right_motor_controller_phase_current,indirect" csv:"right_motor_controller_phase_current" - RightMotorControllerPhaseCurrent *float32 `protobuf:"fixed32,74,opt,name=right_motor_controller_phase_current,json=rightMotorControllerPhaseCurrent" json:"right_motor_controller_phase_current,omitempty"` - // @inject_tag: structs:"left_motor_rpm_command,indirect" csv:"left_motor_rpm_command" - LeftMotorRpmCommand *float32 `protobuf:"fixed32,75,opt,name=left_motor_rpm_command,json=leftMotorRpmCommand" json:"left_motor_rpm_command,omitempty"` - // @inject_tag: structs:"right_motor_rpm_command,indirect" csv:"right_motor_rpm_command" - RightMotorRpmCommand *float32 `protobuf:"fixed32,76,opt,name=right_motor_rpm_command,json=rightMotorRpmCommand" json:"right_motor_rpm_command,omitempty"` - // @inject_tag: structs:"left_motor_current_command,indirect" csv:"left_motor_current_command" - LeftMotorCurrentCommand *float32 `protobuf:"fixed32,77,opt,name=left_motor_current_command,json=leftMotorCurrentCommand" json:"left_motor_current_command,omitempty"` - // @inject_tag: structs:"right_motor_current_command,indirect" csv:"right_motor_current_command" - RightMotorCurrentCommand *float32 `protobuf:"fixed32,78,opt,name=right_motor_current_command,json=rightMotorCurrentCommand" json:"right_motor_current_command,omitempty"` - // @inject_tag: structs:"gps_time,indirect" csv:"gps_time" - GpsTime *int64 `protobuf:"varint,80,opt,name=gps_time,json=gpsTime" json:"gps_time,omitempty"` - // @inject_tag: structs:"gps_latitude,indirect" csv:"gps_latitude" - GpsLatitude *float32 `protobuf:"fixed32,81,opt,name=gps_latitude,json=gpsLatitude" json:"gps_latitude,omitempty"` - // @inject_tag: structs:"gps_longitude,indirect" csv:"gps_longitude" - GpsLongitude *float32 `protobuf:"fixed32,82,opt,name=gps_longitude,json=gpsLongitude" json:"gps_longitude,omitempty"` - // @inject_tag: structs:"gps_speed,indirect" csv:"gps_speed" - GpsSpeed *float32 `protobuf:"fixed32,83,opt,name=gps_speed,json=gpsSpeed" json:"gps_speed,omitempty"` - // @inject_tag: structs:"gps_altitude,indirect" csv:"gps_altitude" - GpsAltitude *float32 `protobuf:"fixed32,84,opt,name=gps_altitude,json=gpsAltitude" json:"gps_altitude,omitempty"` - // @inject_tag: structs:"gps_bearing,indirect" csv:"gps_bearing" - GpsBearing *float32 `protobuf:"fixed32,85,opt,name=gps_bearing,json=gpsBearing" json:"gps_bearing,omitempty"` - // @inject_tag: structs:"led_state,indirect" csv:"led_state" - LedState *int32 `protobuf:"varint,86,opt,name=led_state,json=ledState" json:"led_state,omitempty"` - // @inject_tag: structs:"mppt_array_power,indirect" csv:"mppt_array_power" - MpptArrayPower *float32 `protobuf:"fixed32,87,opt,name=mppt_array_power,json=mpptArrayPower" json:"mppt_array_power,omitempty"` - // @inject_tag: structs:"mppt_A0_volt_in,indirect" csv:"mppt_A0_volt_in" - Mppt_A0VoltIn *float32 `protobuf:"fixed32,88,opt,name=mppt_A0_volt_in,json=mpptA0VoltIn" json:"mppt_A0_volt_in,omitempty"` - // @inject_tag: structs:"mppt_A0_volt_out,indirect" csv:"mppt_A0_volt_out" - Mppt_A0VoltOut *float32 `protobuf:"fixed32,89,opt,name=mppt_A0_volt_out,json=mpptA0VoltOut" json:"mppt_A0_volt_out,omitempty"` - // @inject_tag: structs:"mppt_A0_current,indirect" csv:"mppt_A0_current" - Mppt_A0Current *float32 `protobuf:"fixed32,90,opt,name=mppt_A0_current,json=mpptA0Current" json:"mppt_A0_current,omitempty"` - // @inject_tag: structs:"mppt_A0_temp,indirect" csv:"mppt_A0_temp" - Mppt_A0Temp *float32 `protobuf:"fixed32,91,opt,name=mppt_A0_temp,json=mpptA0Temp" json:"mppt_A0_temp,omitempty"` - // @inject_tag: structs:"mppt_A1_volt_in,indirect" csv:"mppt_A1_volt_in" - Mppt_A1VoltIn *float32 `protobuf:"fixed32,92,opt,name=mppt_A1_volt_in,json=mpptA1VoltIn" json:"mppt_A1_volt_in,omitempty"` - // @inject_tag: structs:"mppt_A1_volt_out,indirect" csv:"mppt_A1_volt_out" - Mppt_A1VoltOut *float32 `protobuf:"fixed32,93,opt,name=mppt_A1_volt_out,json=mpptA1VoltOut" json:"mppt_A1_volt_out,omitempty"` - // @inject_tag: structs:"mppt_A1_current,indirect" csv:"mppt_A1_current" - Mppt_A1Current *float32 `protobuf:"fixed32,94,opt,name=mppt_A1_current,json=mpptA1Current" json:"mppt_A1_current,omitempty"` - // @inject_tag: structs:"mppt_A1_temp,indirect" csv:"mppt_A1_temp" - Mppt_A1Temp *float32 `protobuf:"fixed32,95,opt,name=mppt_A1_temp,json=mpptA1Temp" json:"mppt_A1_temp,omitempty"` - // @inject_tag: structs:"mppt_B0_volt_in,indirect" csv:"mppt_B0_volt_in" - Mppt_B0VoltIn *float32 `protobuf:"fixed32,96,opt,name=mppt_B0_volt_in,json=mpptB0VoltIn" json:"mppt_B0_volt_in,omitempty"` - // @inject_tag: structs:"mppt_B0_volt_out,indirect" csv:"mppt_B0_volt_out" - Mppt_B0VoltOut *float32 `protobuf:"fixed32,97,opt,name=mppt_B0_volt_out,json=mpptB0VoltOut" json:"mppt_B0_volt_out,omitempty"` - // @inject_tag: structs:"mppt_B0_current,indirect" csv:"mppt_B0_current" - Mppt_B0Current *float32 `protobuf:"fixed32,98,opt,name=mppt_B0_current,json=mpptB0Current" json:"mppt_B0_current,omitempty"` - // @inject_tag: structs:"mppt_B0_temp,indirect" csv:"mppt_B0_temp" - Mppt_B0Temp *float32 `protobuf:"fixed32,99,opt,name=mppt_B0_temp,json=mpptB0Temp" json:"mppt_B0_temp,omitempty"` - // @inject_tag: structs:"mppt_B1_volt_in,indirect" csv:"mppt_B1_volt_in" - Mppt_B1VoltIn *float32 `protobuf:"fixed32,100,opt,name=mppt_B1_volt_in,json=mpptB1VoltIn" json:"mppt_B1_volt_in,omitempty"` - // @inject_tag: structs:"mppt_B1_volt_out,indirect" csv:"mppt_B1_volt_out" - Mppt_B1VoltOut *float32 `protobuf:"fixed32,101,opt,name=mppt_B1_volt_out,json=mpptB1VoltOut" json:"mppt_B1_volt_out,omitempty"` - // @inject_tag: structs:"mppt_B1_current,indirect" csv:"mppt_B1_current" - Mppt_B1Current *float32 `protobuf:"fixed32,102,opt,name=mppt_B1_current,json=mpptB1Current" json:"mppt_B1_current,omitempty"` - // @inject_tag: structs:"mppt_B1_temp,indirect" csv:"mppt_B1_temp" - Mppt_B1Temp *float32 `protobuf:"fixed32,103,opt,name=mppt_B1_temp,json=mpptB1Temp" json:"mppt_B1_temp,omitempty"` - // @inject_tag: structs:"mppt_C0_volt_in,indirect" csv:"mppt_C0_volt_in" - Mppt_C0VoltIn *float32 `protobuf:"fixed32,104,opt,name=mppt_C0_volt_in,json=mpptC0VoltIn" json:"mppt_C0_volt_in,omitempty"` - // @inject_tag: structs:"mppt_C0_volt_out,indirect" csv:"mppt_C0_volt_out" - Mppt_C0VoltOut *float32 `protobuf:"fixed32,105,opt,name=mppt_C0_volt_out,json=mpptC0VoltOut" json:"mppt_C0_volt_out,omitempty"` - // @inject_tag: structs:"mppt_C0_current,indirect" csv:"mppt_C0_current" - Mppt_C0Current *float32 `protobuf:"fixed32,106,opt,name=mppt_C0_current,json=mpptC0Current" json:"mppt_C0_current,omitempty"` - // @inject_tag: structs:"mppt_C0_temp,indirect" csv:"mppt_C0_temp" - Mppt_C0Temp *float32 `protobuf:"fixed32,107,opt,name=mppt_C0_temp,json=mpptC0Temp" json:"mppt_C0_temp,omitempty"` - // @inject_tag: structs:"mppt_C1_volt_in,indirect" csv:"mppt_C1_volt_in" - Mppt_C1VoltIn *float32 `protobuf:"fixed32,108,opt,name=mppt_C1_volt_in,json=mpptC1VoltIn" json:"mppt_C1_volt_in,omitempty"` - // @inject_tag: structs:"mppt_C1_volt_out,indirect" csv:"mppt_C1_volt_out" - Mppt_C1VoltOut *float32 `protobuf:"fixed32,109,opt,name=mppt_C1_volt_out,json=mpptC1VoltOut" json:"mppt_C1_volt_out,omitempty"` - // @inject_tag: structs:"mppt_C1_current,indirect" csv:"mppt_C1_current" - Mppt_C1Current *float32 `protobuf:"fixed32,110,opt,name=mppt_C1_current,json=mpptC1Current" json:"mppt_C1_current,omitempty"` - // @inject_tag: structs:"mppt_C1_temp,indirect" csv:"mppt_C1_temp" - Mppt_C1Temp *float32 `protobuf:"fixed32,111,opt,name=mppt_C1_temp,json=mpptC1Temp" json:"mppt_C1_temp,omitempty"` - // @inject_tag: structs:"mppt_D0_volt_in,indirect" csv:"mppt_D0_volt_in" - Mppt_D0VoltIn *float32 `protobuf:"fixed32,112,opt,name=mppt_D0_volt_in,json=mpptD0VoltIn" json:"mppt_D0_volt_in,omitempty"` - // @inject_tag: structs:"mppt_D0_volt_out,indirect" csv:"mppt_D0_volt_out" - Mppt_D0VoltOut *float32 `protobuf:"fixed32,113,opt,name=mppt_D0_volt_out,json=mpptD0VoltOut" json:"mppt_D0_volt_out,omitempty"` - // @inject_tag: structs:"mppt_D0_current,indirect" csv:"mppt_D0_current" - Mppt_D0Current *float32 `protobuf:"fixed32,114,opt,name=mppt_D0_current,json=mpptD0Current" json:"mppt_D0_current,omitempty"` - // @inject_tag: structs:"mppt_D0_temp,indirect" csv:"mppt_D0_temp" - Mppt_D0Temp *float32 `protobuf:"fixed32,115,opt,name=mppt_D0_temp,json=mpptD0Temp" json:"mppt_D0_temp,omitempty"` - // @inject_tag: structs:"mppt_D1_volt_in,indirect" csv:"mppt_D1_volt_in" - Mppt_D1VoltIn *float32 `protobuf:"fixed32,116,opt,name=mppt_D1_volt_in,json=mpptD1VoltIn" json:"mppt_D1_volt_in,omitempty"` - // @inject_tag: structs:"mppt_D1_volt_out,indirect" csv:"mppt_D1_volt_out" - Mppt_D1VoltOut *float32 `protobuf:"fixed32,117,opt,name=mppt_D1_volt_out,json=mpptD1VoltOut" json:"mppt_D1_volt_out,omitempty"` - // @inject_tag: structs:"mppt_D1_current,indirect" csv:"mppt_D1_current" - Mppt_D1Current *float32 `protobuf:"fixed32,118,opt,name=mppt_D1_current,json=mpptD1Current" json:"mppt_D1_current,omitempty"` - // @inject_tag: structs:"mppt_D1_temp,indirect" csv:"mppt_D1_temp" - Mppt_D1Temp *float32 `protobuf:"fixed32,119,opt,name=mppt_D1_temp,json=mpptD1Temp" json:"mppt_D1_temp,omitempty"` - // @inject_tag: structs:"cell_volt_1,indirect" csv:"cell_volt_1" - CellVolt_1 *float32 `protobuf:"fixed32,120,opt,name=cell_volt_1,json=cellVolt1" json:"cell_volt_1,omitempty"` - // @inject_tag: structs:"cell_volt_2,indirect" csv:"cell_volt_2" - CellVolt_2 *float32 `protobuf:"fixed32,121,opt,name=cell_volt_2,json=cellVolt2" json:"cell_volt_2,omitempty"` - // @inject_tag: structs:"cell_volt_3,indirect" csv:"cell_volt_3" - CellVolt_3 *float32 `protobuf:"fixed32,122,opt,name=cell_volt_3,json=cellVolt3" json:"cell_volt_3,omitempty"` - // @inject_tag: structs:"cell_volt_4,indirect" csv:"cell_volt_4" - CellVolt_4 *float32 `protobuf:"fixed32,123,opt,name=cell_volt_4,json=cellVolt4" json:"cell_volt_4,omitempty"` - // @inject_tag: structs:"cell_volt_5,indirect" csv:"cell_volt_5" - CellVolt_5 *float32 `protobuf:"fixed32,124,opt,name=cell_volt_5,json=cellVolt5" json:"cell_volt_5,omitempty"` - // @inject_tag: structs:"cell_volt_6,indirect" csv:"cell_volt_6" - CellVolt_6 *float32 `protobuf:"fixed32,125,opt,name=cell_volt_6,json=cellVolt6" json:"cell_volt_6,omitempty"` - // @inject_tag: structs:"cell_volt_7,indirect" csv:"cell_volt_7" - CellVolt_7 *float32 `protobuf:"fixed32,126,opt,name=cell_volt_7,json=cellVolt7" json:"cell_volt_7,omitempty"` - // @inject_tag: structs:"cell_volt_8,indirect" csv:"cell_volt_8" - CellVolt_8 *float32 `protobuf:"fixed32,127,opt,name=cell_volt_8,json=cellVolt8" json:"cell_volt_8,omitempty"` - // @inject_tag: structs:"cell_volt_9,indirect" csv:"cell_volt_9" - CellVolt_9 *float32 `protobuf:"fixed32,128,opt,name=cell_volt_9,json=cellVolt9" json:"cell_volt_9,omitempty"` - // @inject_tag: structs:"cell_volt_10,indirect" csv:"cell_volt_10" - CellVolt_10 *float32 `protobuf:"fixed32,129,opt,name=cell_volt_10,json=cellVolt10" json:"cell_volt_10,omitempty"` - // @inject_tag: structs:"cell_volt_11,indirect" csv:"cell_volt_11" - CellVolt_11 *float32 `protobuf:"fixed32,130,opt,name=cell_volt_11,json=cellVolt11" json:"cell_volt_11,omitempty"` - // @inject_tag: structs:"cell_volt_12,indirect" csv:"cell_volt_12" - CellVolt_12 *float32 `protobuf:"fixed32,131,opt,name=cell_volt_12,json=cellVolt12" json:"cell_volt_12,omitempty"` - // @inject_tag: structs:"cell_volt_13,indirect" csv:"cell_volt_13" - CellVolt_13 *float32 `protobuf:"fixed32,132,opt,name=cell_volt_13,json=cellVolt13" json:"cell_volt_13,omitempty"` - // @inject_tag: structs:"cell_volt_14,indirect" csv:"cell_volt_14" - CellVolt_14 *float32 `protobuf:"fixed32,133,opt,name=cell_volt_14,json=cellVolt14" json:"cell_volt_14,omitempty"` - // @inject_tag: structs:"cell_volt_15,indirect" csv:"cell_volt_15" - CellVolt_15 *float32 `protobuf:"fixed32,134,opt,name=cell_volt_15,json=cellVolt15" json:"cell_volt_15,omitempty"` - // @inject_tag: structs:"cell_volt_16,indirect" csv:"cell_volt_16" - CellVolt_16 *float32 `protobuf:"fixed32,135,opt,name=cell_volt_16,json=cellVolt16" json:"cell_volt_16,omitempty"` - // @inject_tag: structs:"cell_volt_17,indirect" csv:"cell_volt_17" - CellVolt_17 *float32 `protobuf:"fixed32,136,opt,name=cell_volt_17,json=cellVolt17" json:"cell_volt_17,omitempty"` - // @inject_tag: structs:"cell_volt_18,indirect" csv:"cell_volt_18" - CellVolt_18 *float32 `protobuf:"fixed32,137,opt,name=cell_volt_18,json=cellVolt18" json:"cell_volt_18,omitempty"` - // @inject_tag: structs:"cell_volt_19,indirect" csv:"cell_volt_19" - CellVolt_19 *float32 `protobuf:"fixed32,138,opt,name=cell_volt_19,json=cellVolt19" json:"cell_volt_19,omitempty"` - // @inject_tag: structs:"cell_volt_20,indirect" csv:"cell_volt_20" - CellVolt_20 *float32 `protobuf:"fixed32,139,opt,name=cell_volt_20,json=cellVolt20" json:"cell_volt_20,omitempty"` - // @inject_tag: structs:"cell_volt_21,indirect" csv:"cell_volt_21" - CellVolt_21 *float32 `protobuf:"fixed32,140,opt,name=cell_volt_21,json=cellVolt21" json:"cell_volt_21,omitempty"` - // @inject_tag: structs:"cell_volt_22,indirect" csv:"cell_volt_22" - CellVolt_22 *float32 `protobuf:"fixed32,141,opt,name=cell_volt_22,json=cellVolt22" json:"cell_volt_22,omitempty"` - // @inject_tag: structs:"cell_volt_23,indirect" csv:"cell_volt_23" - CellVolt_23 *float32 `protobuf:"fixed32,142,opt,name=cell_volt_23,json=cellVolt23" json:"cell_volt_23,omitempty"` - // @inject_tag: structs:"cell_volt_24,indirect" csv:"cell_volt_24" - CellVolt_24 *float32 `protobuf:"fixed32,143,opt,name=cell_volt_24,json=cellVolt24" json:"cell_volt_24,omitempty"` - // @inject_tag: structs:"cell_volt_25,indirect" csv:"cell_volt_25" - CellVolt_25 *float32 `protobuf:"fixed32,144,opt,name=cell_volt_25,json=cellVolt25" json:"cell_volt_25,omitempty"` - // @inject_tag: structs:"cell_volt_26,indirect" csv:"cell_volt_26" - CellVolt_26 *float32 `protobuf:"fixed32,145,opt,name=cell_volt_26,json=cellVolt26" json:"cell_volt_26,omitempty"` - // @inject_tag: structs:"cell_volt_27,indirect" csv:"cell_volt_27" - CellVolt_27 *float32 `protobuf:"fixed32,146,opt,name=cell_volt_27,json=cellVolt27" json:"cell_volt_27,omitempty"` - // @inject_tag: structs:"cell_volt_28,indirect" csv:"cell_volt_28" - CellVolt_28 *float32 `protobuf:"fixed32,147,opt,name=cell_volt_28,json=cellVolt28" json:"cell_volt_28,omitempty"` - // @inject_tag: structs:"cell_volt_29,indirect" csv:"cell_volt_29" - CellVolt_29 *float32 `protobuf:"fixed32,148,opt,name=cell_volt_29,json=cellVolt29" json:"cell_volt_29,omitempty"` - // @inject_tag: structs:"cell_volt_30,indirect" csv:"cell_volt_30" - CellVolt_30 *float32 `protobuf:"fixed32,149,opt,name=cell_volt_30,json=cellVolt30" json:"cell_volt_30,omitempty"` - // @inject_tag: structs:"cell_volt_31,indirect" csv:"cell_volt_31" - CellVolt_31 *float32 `protobuf:"fixed32,150,opt,name=cell_volt_31,json=cellVolt31" json:"cell_volt_31,omitempty"` - // @inject_tag: structs:"cell_volt_min,indirect" csv:"cell_volt_min" - CellVoltMin *float32 `protobuf:"fixed32,151,opt,name=cell_volt_min,json=cellVoltMin" json:"cell_volt_min,omitempty"` - // @inject_tag: structs:"cell_volt_max,indirect" csv:"cell_volt_max" - CellVoltMax *float32 `protobuf:"fixed32,152,opt,name=cell_volt_max,json=cellVoltMax" json:"cell_volt_max,omitempty"` - // @inject_tag: structs:"cell_volt_avg,indirect" csv:"cell_volt_avg" - CellVoltAvg *float32 `protobuf:"fixed32,153,opt,name=cell_volt_avg,json=cellVoltAvg" json:"cell_volt_avg,omitempty"` - // @inject_tag: structs:"cell_volt_diff,indirect" csv:"cell_volt_diff" - CellVoltDiff *float32 `protobuf:"fixed32,154,opt,name=cell_volt_diff,json=cellVoltDiff" json:"cell_volt_diff,omitempty"` - // @inject_tag: structs:"power_save_on,indirect" csv:"power_save_on" - PowerSaveOn *int32 `protobuf:"varint,155,opt,name=power_save_on,json=powerSaveOn" json:"power_save_on,omitempty"` - // @inject_tag: structs:"rearview_on,indirect" csv:"rearview_on" - RearviewOn *int32 `protobuf:"varint,156,opt,name=rearview_on,json=rearviewOn" json:"rearview_on,omitempty"` - // @inject_tag: structs:"mic_enabled,indirect" csv:"mic_enabled" - MicEnabled *int32 `protobuf:"varint,157,opt,name=mic_enabled,json=micEnabled" json:"mic_enabled,omitempty"` - // @inject_tag: structs:"imu_temp,indirect" csv:"imu_temp" - ImuTemp *int32 `protobuf:"varint,158,opt,name=imu_temp,json=imuTemp" json:"imu_temp,omitempty"` - // @inject_tag: structs:"imu_magnet_x,indirect" csv:"imu_magnet_x" - ImuMagnetX *int32 `protobuf:"varint,159,opt,name=imu_magnet_x,json=imuMagnetX" json:"imu_magnet_x,omitempty"` - // @inject_tag: structs:"imu_magnet_y,indirect" csv:"imu_magnet_y" - ImuMagnetY *int32 `protobuf:"varint,160,opt,name=imu_magnet_y,json=imuMagnetY" json:"imu_magnet_y,omitempty"` - // @inject_tag: structs:"imu_magnet_z,indirect" csv:"imu_magnet_z" - ImuMagnetZ *int32 `protobuf:"varint,161,opt,name=imu_magnet_z,json=imuMagnetZ" json:"imu_magnet_z,omitempty"` - // @inject_tag: structs:"imu_gyro_x,indirect" csv:"imu_gyro_x" - ImuGyroX *int32 `protobuf:"varint,162,opt,name=imu_gyro_x,json=imuGyroX" json:"imu_gyro_x,omitempty"` - // @inject_tag: structs:"imu_gyro_y,indirect" csv:"imu_gyro_y" - ImuGyroY *int32 `protobuf:"varint,163,opt,name=imu_gyro_y,json=imuGyroY" json:"imu_gyro_y,omitempty"` - // @inject_tag: structs:"imu_gyro_z,indirect" csv:"imu_gyro_z" - ImuGyroZ *int32 `protobuf:"varint,164,opt,name=imu_gyro_z,json=imuGyroZ" json:"imu_gyro_z,omitempty"` - // @inject_tag: structs:"imu_accel_x,indirect" csv:"imu_accel_x" - ImuAccelX *int32 `protobuf:"varint,165,opt,name=imu_accel_x,json=imuAccelX" json:"imu_accel_x,omitempty"` - // @inject_tag: structs:"imu_accel_y,indirect" csv:"imu_accel_y" - ImuAccelY *int32 `protobuf:"varint,166,opt,name=imu_accel_y,json=imuAccelY" json:"imu_accel_y,omitempty"` - // @inject_tag: structs:"imu_accel_z,indirect" csv:"imu_accel_z" - ImuAccelZ *int32 `protobuf:"varint,167,opt,name=imu_accel_z,json=imuAccelZ" json:"imu_accel_z,omitempty"` - // @inject_tag: structs:"bms_left_motor_controller_current,indirect" csv:"bms_left_motor_controller_current" - BmsLeftMotorControllerCurrent *float32 `protobuf:"fixed32,168,opt,name=bms_left_motor_controller_current,json=bmsLeftMotorControllerCurrent" json:"bms_left_motor_controller_current,omitempty"` - // @inject_tag: structs:"bms_right_motor_controller_current,indirect" csv:"bms_right_motor_controller_current" - BmsRightMotorControllerCurrent *float32 `protobuf:"fixed32,169,opt,name=bms_right_motor_controller_current,json=bmsRightMotorControllerCurrent" json:"bms_right_motor_controller_current,omitempty"` - // @inject_tag: structs:"bms_motor_controller_current_sum,indirect" csv:"bms_motor_controller_current_sum" - BmsMotorControllerCurrentSum *float32 `protobuf:"fixed32,170,opt,name=bms_motor_controller_current_sum,json=bmsMotorControllerCurrentSum" json:"bms_motor_controller_current_sum,omitempty"` - // @inject_tag: structs:"packets_per_sec,indirect" csv:"packets_per_sec" - PacketsPerSec *float32 `protobuf:"fixed32,171,opt,name=packets_per_sec,json=packetsPerSec" json:"packets_per_sec,omitempty"` - // @inject_tag: structs:"-" csv:"time_collected" // Not in struct, b/c not data - TimeCollected *int64 `protobuf:"varint,172,opt,name=time_collected,json=timeCollected" json:"time_collected,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *DataMessage) Reset() { *m = DataMessage{} } -func (m *DataMessage) String() string { return proto.CompactTextString(m) } -func (*DataMessage) ProtoMessage() {} -func (*DataMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } - -func (m *DataMessage) GetRegenEnabled() uint32 { - if m != nil && m.RegenEnabled != nil { - return *m.RegenEnabled - } - return 0 -} - -func (m *DataMessage) GetRegenCommand() uint32 { - if m != nil && m.RegenCommand != nil { - return *m.RegenCommand - } - return 0 -} - -func (m *DataMessage) GetBatteryPower() uint32 { - if m != nil && m.BatteryPower != nil { - return *m.BatteryPower - } - return 0 -} - -func (m *DataMessage) GetArrayPower() float32 { - if m != nil && m.ArrayPower != nil { - return *m.ArrayPower - } - return 0 -} - -func (m *DataMessage) GetReverseOn() uint32 { - if m != nil && m.ReverseOn != nil { - return *m.ReverseOn - } - return 0 -} - -func (m *DataMessage) GetLowVoltPower() float32 { - if m != nil && m.LowVoltPower != nil { - return *m.LowVoltPower - } - return 0 -} - -func (m *DataMessage) GetCellReadError() int32 { - if m != nil && m.CellReadError != nil { - return *m.CellReadError - } - return 0 -} - -func (m *DataMessage) GetCellBleed() uint32 { - if m != nil && m.CellBleed != nil { - return *m.CellBleed - } - return 0 -} - -func (m *DataMessage) GetCruiseSpeed() float32 { - if m != nil && m.CruiseSpeed != nil { - return *m.CruiseSpeed - } - return 0 -} - -func (m *DataMessage) GetHazardLightsOn() int32 { - if m != nil && m.HazardLightsOn != nil { - return *m.HazardLightsOn - } - return 0 -} - -func (m *DataMessage) GetBatteryVoltage() float32 { - if m != nil && m.BatteryVoltage != nil { - return *m.BatteryVoltage - } - return 0 -} - -func (m *DataMessage) GetLtc6804Badpec() uint32 { - if m != nil && m.Ltc6804Badpec != nil { - return *m.Ltc6804Badpec - } - return 0 -} - -func (m *DataMessage) GetBmsState() uint32 { - if m != nil && m.BmsState != nil { - return *m.BmsState - } - return 0 -} - -func (m *DataMessage) GetChargeEnabled() int32 { - if m != nil && m.ChargeEnabled != nil { - return *m.ChargeEnabled - } - return 0 -} - -func (m *DataMessage) GetDischargeEnabled() int32 { - if m != nil && m.DischargeEnabled != nil { - return *m.DischargeEnabled - } - return 0 -} - -func (m *DataMessage) GetHighsideContactorOn() int32 { - if m != nil && m.HighsideContactorOn != nil { - return *m.HighsideContactorOn - } - return 0 -} - -func (m *DataMessage) GetLowsideContactorOn() int32 { - if m != nil && m.LowsideContactorOn != nil { - return *m.LowsideContactorOn - } - return 0 -} - -func (m *DataMessage) GetPrechargeOn() int32 { - if m != nil && m.PrechargeOn != nil { - return *m.PrechargeOn - } - return 0 -} - -func (m *DataMessage) GetLowVoltBusOn() int32 { - if m != nil && m.LowVoltBusOn != nil { - return *m.LowVoltBusOn - } - return 0 -} - -func (m *DataMessage) GetBatteryTemp_1() float32 { - if m != nil && m.BatteryTemp_1 != nil { - return *m.BatteryTemp_1 - } - return 0 -} - -func (m *DataMessage) GetBatteryTemp_2() float32 { - if m != nil && m.BatteryTemp_2 != nil { - return *m.BatteryTemp_2 - } - return 0 -} - -func (m *DataMessage) GetBatteryTemp_3() float32 { - if m != nil && m.BatteryTemp_3 != nil { - return *m.BatteryTemp_3 - } - return 0 -} - -func (m *DataMessage) GetBatteryTemp_4() float32 { - if m != nil && m.BatteryTemp_4 != nil { - return *m.BatteryTemp_4 - } - return 0 -} - -func (m *DataMessage) GetBatteryTemp_5() float32 { - if m != nil && m.BatteryTemp_5 != nil { - return *m.BatteryTemp_5 - } - return 0 -} - -func (m *DataMessage) GetBatteryTemp_6() float32 { - if m != nil && m.BatteryTemp_6 != nil { - return *m.BatteryTemp_6 - } - return 0 -} - -func (m *DataMessage) GetBmsPrechargeBatteryAdc() float32 { - if m != nil && m.BmsPrechargeBatteryAdc != nil { - return *m.BmsPrechargeBatteryAdc - } - return 0 -} - -func (m *DataMessage) GetBmsPrechargeCarAdc() float32 { - if m != nil && m.BmsPrechargeCarAdc != nil { - return *m.BmsPrechargeCarAdc - } - return 0 -} - -func (m *DataMessage) GetLowVoltOutputCurrent() float32 { - if m != nil && m.LowVoltOutputCurrent != nil { - return *m.LowVoltOutputCurrent - } - return 0 -} - -func (m *DataMessage) GetArrayCurrent() float32 { - if m != nil && m.ArrayCurrent != nil { - return *m.ArrayCurrent - } - return 0 -} - -func (m *DataMessage) GetBatteryCurrent() float32 { - if m != nil && m.BatteryCurrent != nil { - return *m.BatteryCurrent - } - return 0 -} - -func (m *DataMessage) GetLeftMotorControllerPower() float32 { - if m != nil && m.LeftMotorControllerPower != nil { - return *m.LeftMotorControllerPower - } - return 0 -} - -func (m *DataMessage) GetRightMotorControllerPower() float32 { - if m != nil && m.RightMotorControllerPower != nil { - return *m.RightMotorControllerPower - } - return 0 -} - -func (m *DataMessage) GetAmpHours() float32 { - if m != nil && m.AmpHours != nil { - return *m.AmpHours - } - return 0 -} - -func (m *DataMessage) GetHeadLightsOn() int32 { - if m != nil && m.HeadLightsOn != nil { - return *m.HeadLightsOn - } - return 0 -} - -func (m *DataMessage) GetBrakeLightsOn() int32 { - if m != nil && m.BrakeLightsOn != nil { - return *m.BrakeLightsOn - } - return 0 -} - -func (m *DataMessage) GetRightBlinkerOn() int32 { - if m != nil && m.RightBlinkerOn != nil { - return *m.RightBlinkerOn - } - return 0 -} - -func (m *DataMessage) GetLeftBlinkerOn() int32 { - if m != nil && m.LeftBlinkerOn != nil { - return *m.LeftBlinkerOn - } - return 0 -} - -func (m *DataMessage) GetBrakePressed() int32 { - if m != nil && m.BrakePressed != nil { - return *m.BrakePressed - } - return 0 -} - -func (m *DataMessage) GetThrottlePressed() int32 { - if m != nil && m.ThrottlePressed != nil { - return *m.ThrottlePressed - } - return 0 -} - -func (m *DataMessage) GetDriveMode() uint32 { - if m != nil && m.DriveMode != nil { - return *m.DriveMode - } - return 0 -} - -func (m *DataMessage) GetMotorControllerEnabled() int32 { - if m != nil && m.MotorControllerEnabled != nil { - return *m.MotorControllerEnabled - } - return 0 -} - -func (m *DataMessage) GetMotorControllerSpeed() float32 { - if m != nil && m.MotorControllerSpeed != nil { - return *m.MotorControllerSpeed - } - return 0 -} - -func (m *DataMessage) GetMotorControllerRpm() float32 { - if m != nil && m.MotorControllerRpm != nil { - return *m.MotorControllerRpm - } - return 0 -} - -func (m *DataMessage) GetAvgOdometer() float32 { - if m != nil && m.AvgOdometer != nil { - return *m.AvgOdometer - } - return 0 -} - -func (m *DataMessage) GetLeftMotorTemp() float32 { - if m != nil && m.LeftMotorTemp != nil { - return *m.LeftMotorTemp - } - return 0 -} - -func (m *DataMessage) GetRightMotorTemp() float32 { - if m != nil && m.RightMotorTemp != nil { - return *m.RightMotorTemp - } - return 0 -} - -func (m *DataMessage) GetLeftMotorControllerTemp() float32 { - if m != nil && m.LeftMotorControllerTemp != nil { - return *m.LeftMotorControllerTemp - } - return 0 -} - -func (m *DataMessage) GetRightMotorControllerTemp() float32 { - if m != nil && m.RightMotorControllerTemp != nil { - return *m.RightMotorControllerTemp - } - return 0 -} - -func (m *DataMessage) GetLeftMotorControllerAlive() float32 { - if m != nil && m.LeftMotorControllerAlive != nil { - return *m.LeftMotorControllerAlive - } - return 0 -} - -func (m *DataMessage) GetRightMotorControllerAlive() float32 { - if m != nil && m.RightMotorControllerAlive != nil { - return *m.RightMotorControllerAlive - } - return 0 -} - -func (m *DataMessage) GetLeftMotorControllerCurrent() float32 { - if m != nil && m.LeftMotorControllerCurrent != nil { - return *m.LeftMotorControllerCurrent - } - return 0 -} - -func (m *DataMessage) GetRightMotorControllerCurrent() float32 { - if m != nil && m.RightMotorControllerCurrent != nil { - return *m.RightMotorControllerCurrent - } - return 0 -} - -func (m *DataMessage) GetMotorControllerCurrentDiff() float32 { - if m != nil && m.MotorControllerCurrentDiff != nil { - return *m.MotorControllerCurrentDiff - } - return 0 -} - -func (m *DataMessage) GetLeftMotorControllerError() uint32 { - if m != nil && m.LeftMotorControllerError != nil { - return *m.LeftMotorControllerError - } - return 0 -} - -func (m *DataMessage) GetRightMotorControllerError() uint32 { - if m != nil && m.RightMotorControllerError != nil { - return *m.RightMotorControllerError - } - return 0 -} - -func (m *DataMessage) GetLeftMotorControllerLimit() uint32 { - if m != nil && m.LeftMotorControllerLimit != nil { - return *m.LeftMotorControllerLimit - } - return 0 -} - -func (m *DataMessage) GetRightMotorControllerLimit() uint32 { - if m != nil && m.RightMotorControllerLimit != nil { - return *m.RightMotorControllerLimit - } - return 0 -} - -func (m *DataMessage) GetLeftMotorControllerRxErrorCount() uint32 { - if m != nil && m.LeftMotorControllerRxErrorCount != nil { - return *m.LeftMotorControllerRxErrorCount - } - return 0 -} - -func (m *DataMessage) GetRightMotorControllerRxErrorCount() uint32 { - if m != nil && m.RightMotorControllerRxErrorCount != nil { - return *m.RightMotorControllerRxErrorCount - } - return 0 -} - -func (m *DataMessage) GetLeftMotorControllerTxErrorCount() uint32 { - if m != nil && m.LeftMotorControllerTxErrorCount != nil { - return *m.LeftMotorControllerTxErrorCount - } - return 0 -} - -func (m *DataMessage) GetRightMotorControllerTxErrorCount() uint32 { - if m != nil && m.RightMotorControllerTxErrorCount != nil { - return *m.RightMotorControllerTxErrorCount - } - return 0 -} - -func (m *DataMessage) GetLeftMotorControllerBusVoltage() float32 { - if m != nil && m.LeftMotorControllerBusVoltage != nil { - return *m.LeftMotorControllerBusVoltage - } - return 0 -} - -func (m *DataMessage) GetRightMotorControllerBusVoltage() float32 { - if m != nil && m.RightMotorControllerBusVoltage != nil { - return *m.RightMotorControllerBusVoltage - } - return 0 -} - -func (m *DataMessage) GetLeftMotorController_15VVoltage() float32 { - if m != nil && m.LeftMotorController_15VVoltage != nil { - return *m.LeftMotorController_15VVoltage - } - return 0 -} - -func (m *DataMessage) GetRightMotorController_15VVoltage() float32 { - if m != nil && m.RightMotorController_15VVoltage != nil { - return *m.RightMotorController_15VVoltage - } - return 0 -} - -func (m *DataMessage) GetLeftMotorController_3V3Voltage() float32 { - if m != nil && m.LeftMotorController_3V3Voltage != nil { - return *m.LeftMotorController_3V3Voltage - } - return 0 -} - -func (m *DataMessage) GetRightMotorController_3V3Voltage() float32 { - if m != nil && m.RightMotorController_3V3Voltage != nil { - return *m.RightMotorController_3V3Voltage - } - return 0 -} - -func (m *DataMessage) GetLeftMotorController_1V9Voltage() float32 { - if m != nil && m.LeftMotorController_1V9Voltage != nil { - return *m.LeftMotorController_1V9Voltage - } - return 0 -} - -func (m *DataMessage) GetRightMotorController_1V9Voltage() float32 { - if m != nil && m.RightMotorController_1V9Voltage != nil { - return *m.RightMotorController_1V9Voltage - } - return 0 -} - -func (m *DataMessage) GetLeftMotorControllerDspTemp() float32 { - if m != nil && m.LeftMotorControllerDspTemp != nil { - return *m.LeftMotorControllerDspTemp - } - return 0 -} - -func (m *DataMessage) GetRightMotorControllerDspTemp() float32 { - if m != nil && m.RightMotorControllerDspTemp != nil { - return *m.RightMotorControllerDspTemp - } - return 0 -} - -func (m *DataMessage) GetLeftMotorControllerPhaseCurrent() float32 { - if m != nil && m.LeftMotorControllerPhaseCurrent != nil { - return *m.LeftMotorControllerPhaseCurrent - } - return 0 -} - -func (m *DataMessage) GetRightMotorControllerPhaseCurrent() float32 { - if m != nil && m.RightMotorControllerPhaseCurrent != nil { - return *m.RightMotorControllerPhaseCurrent - } - return 0 -} - -func (m *DataMessage) GetLeftMotorRpmCommand() float32 { - if m != nil && m.LeftMotorRpmCommand != nil { - return *m.LeftMotorRpmCommand - } - return 0 -} - -func (m *DataMessage) GetRightMotorRpmCommand() float32 { - if m != nil && m.RightMotorRpmCommand != nil { - return *m.RightMotorRpmCommand - } - return 0 -} - -func (m *DataMessage) GetLeftMotorCurrentCommand() float32 { - if m != nil && m.LeftMotorCurrentCommand != nil { - return *m.LeftMotorCurrentCommand - } - return 0 -} - -func (m *DataMessage) GetRightMotorCurrentCommand() float32 { - if m != nil && m.RightMotorCurrentCommand != nil { - return *m.RightMotorCurrentCommand - } - return 0 -} - -func (m *DataMessage) GetGpsTime() int64 { - if m != nil && m.GpsTime != nil { - return *m.GpsTime - } - return 0 -} - -func (m *DataMessage) GetGpsLatitude() float32 { - if m != nil && m.GpsLatitude != nil { - return *m.GpsLatitude - } - return 0 -} - -func (m *DataMessage) GetGpsLongitude() float32 { - if m != nil && m.GpsLongitude != nil { - return *m.GpsLongitude - } - return 0 -} - -func (m *DataMessage) GetGpsSpeed() float32 { - if m != nil && m.GpsSpeed != nil { - return *m.GpsSpeed - } - return 0 -} - -func (m *DataMessage) GetGpsAltitude() float32 { - if m != nil && m.GpsAltitude != nil { - return *m.GpsAltitude - } - return 0 -} - -func (m *DataMessage) GetGpsBearing() float32 { - if m != nil && m.GpsBearing != nil { - return *m.GpsBearing - } - return 0 -} - -func (m *DataMessage) GetLedState() int32 { - if m != nil && m.LedState != nil { - return *m.LedState - } - return 0 -} - -func (m *DataMessage) GetMpptArrayPower() float32 { - if m != nil && m.MpptArrayPower != nil { - return *m.MpptArrayPower - } - return 0 -} - -func (m *DataMessage) GetMppt_A0VoltIn() float32 { - if m != nil && m.Mppt_A0VoltIn != nil { - return *m.Mppt_A0VoltIn - } - return 0 -} - -func (m *DataMessage) GetMppt_A0VoltOut() float32 { - if m != nil && m.Mppt_A0VoltOut != nil { - return *m.Mppt_A0VoltOut - } - return 0 -} - -func (m *DataMessage) GetMppt_A0Current() float32 { - if m != nil && m.Mppt_A0Current != nil { - return *m.Mppt_A0Current - } - return 0 -} - -func (m *DataMessage) GetMppt_A0Temp() float32 { - if m != nil && m.Mppt_A0Temp != nil { - return *m.Mppt_A0Temp - } - return 0 -} - -func (m *DataMessage) GetMppt_A1VoltIn() float32 { - if m != nil && m.Mppt_A1VoltIn != nil { - return *m.Mppt_A1VoltIn - } - return 0 -} - -func (m *DataMessage) GetMppt_A1VoltOut() float32 { - if m != nil && m.Mppt_A1VoltOut != nil { - return *m.Mppt_A1VoltOut - } - return 0 -} - -func (m *DataMessage) GetMppt_A1Current() float32 { - if m != nil && m.Mppt_A1Current != nil { - return *m.Mppt_A1Current - } - return 0 -} - -func (m *DataMessage) GetMppt_A1Temp() float32 { - if m != nil && m.Mppt_A1Temp != nil { - return *m.Mppt_A1Temp - } - return 0 -} - -func (m *DataMessage) GetMppt_B0VoltIn() float32 { - if m != nil && m.Mppt_B0VoltIn != nil { - return *m.Mppt_B0VoltIn - } - return 0 -} - -func (m *DataMessage) GetMppt_B0VoltOut() float32 { - if m != nil && m.Mppt_B0VoltOut != nil { - return *m.Mppt_B0VoltOut - } - return 0 -} - -func (m *DataMessage) GetMppt_B0Current() float32 { - if m != nil && m.Mppt_B0Current != nil { - return *m.Mppt_B0Current - } - return 0 -} - -func (m *DataMessage) GetMppt_B0Temp() float32 { - if m != nil && m.Mppt_B0Temp != nil { - return *m.Mppt_B0Temp - } - return 0 -} - -func (m *DataMessage) GetMppt_B1VoltIn() float32 { - if m != nil && m.Mppt_B1VoltIn != nil { - return *m.Mppt_B1VoltIn - } - return 0 -} - -func (m *DataMessage) GetMppt_B1VoltOut() float32 { - if m != nil && m.Mppt_B1VoltOut != nil { - return *m.Mppt_B1VoltOut - } - return 0 -} - -func (m *DataMessage) GetMppt_B1Current() float32 { - if m != nil && m.Mppt_B1Current != nil { - return *m.Mppt_B1Current - } - return 0 -} - -func (m *DataMessage) GetMppt_B1Temp() float32 { - if m != nil && m.Mppt_B1Temp != nil { - return *m.Mppt_B1Temp - } - return 0 -} - -func (m *DataMessage) GetMppt_C0VoltIn() float32 { - if m != nil && m.Mppt_C0VoltIn != nil { - return *m.Mppt_C0VoltIn - } - return 0 -} - -func (m *DataMessage) GetMppt_C0VoltOut() float32 { - if m != nil && m.Mppt_C0VoltOut != nil { - return *m.Mppt_C0VoltOut - } - return 0 -} - -func (m *DataMessage) GetMppt_C0Current() float32 { - if m != nil && m.Mppt_C0Current != nil { - return *m.Mppt_C0Current - } - return 0 -} - -func (m *DataMessage) GetMppt_C0Temp() float32 { - if m != nil && m.Mppt_C0Temp != nil { - return *m.Mppt_C0Temp - } - return 0 -} - -func (m *DataMessage) GetMppt_C1VoltIn() float32 { - if m != nil && m.Mppt_C1VoltIn != nil { - return *m.Mppt_C1VoltIn - } - return 0 -} - -func (m *DataMessage) GetMppt_C1VoltOut() float32 { - if m != nil && m.Mppt_C1VoltOut != nil { - return *m.Mppt_C1VoltOut - } - return 0 -} - -func (m *DataMessage) GetMppt_C1Current() float32 { - if m != nil && m.Mppt_C1Current != nil { - return *m.Mppt_C1Current - } - return 0 -} - -func (m *DataMessage) GetMppt_C1Temp() float32 { - if m != nil && m.Mppt_C1Temp != nil { - return *m.Mppt_C1Temp - } - return 0 -} - -func (m *DataMessage) GetMppt_D0VoltIn() float32 { - if m != nil && m.Mppt_D0VoltIn != nil { - return *m.Mppt_D0VoltIn - } - return 0 -} - -func (m *DataMessage) GetMppt_D0VoltOut() float32 { - if m != nil && m.Mppt_D0VoltOut != nil { - return *m.Mppt_D0VoltOut - } - return 0 -} - -func (m *DataMessage) GetMppt_D0Current() float32 { - if m != nil && m.Mppt_D0Current != nil { - return *m.Mppt_D0Current - } - return 0 -} - -func (m *DataMessage) GetMppt_D0Temp() float32 { - if m != nil && m.Mppt_D0Temp != nil { - return *m.Mppt_D0Temp - } - return 0 -} - -func (m *DataMessage) GetMppt_D1VoltIn() float32 { - if m != nil && m.Mppt_D1VoltIn != nil { - return *m.Mppt_D1VoltIn - } - return 0 -} - -func (m *DataMessage) GetMppt_D1VoltOut() float32 { - if m != nil && m.Mppt_D1VoltOut != nil { - return *m.Mppt_D1VoltOut - } - return 0 -} - -func (m *DataMessage) GetMppt_D1Current() float32 { - if m != nil && m.Mppt_D1Current != nil { - return *m.Mppt_D1Current - } - return 0 -} - -func (m *DataMessage) GetMppt_D1Temp() float32 { - if m != nil && m.Mppt_D1Temp != nil { - return *m.Mppt_D1Temp - } - return 0 -} - -func (m *DataMessage) GetCellVolt_1() float32 { - if m != nil && m.CellVolt_1 != nil { - return *m.CellVolt_1 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_2() float32 { - if m != nil && m.CellVolt_2 != nil { - return *m.CellVolt_2 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_3() float32 { - if m != nil && m.CellVolt_3 != nil { - return *m.CellVolt_3 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_4() float32 { - if m != nil && m.CellVolt_4 != nil { - return *m.CellVolt_4 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_5() float32 { - if m != nil && m.CellVolt_5 != nil { - return *m.CellVolt_5 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_6() float32 { - if m != nil && m.CellVolt_6 != nil { - return *m.CellVolt_6 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_7() float32 { - if m != nil && m.CellVolt_7 != nil { - return *m.CellVolt_7 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_8() float32 { - if m != nil && m.CellVolt_8 != nil { - return *m.CellVolt_8 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_9() float32 { - if m != nil && m.CellVolt_9 != nil { - return *m.CellVolt_9 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_10() float32 { - if m != nil && m.CellVolt_10 != nil { - return *m.CellVolt_10 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_11() float32 { - if m != nil && m.CellVolt_11 != nil { - return *m.CellVolt_11 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_12() float32 { - if m != nil && m.CellVolt_12 != nil { - return *m.CellVolt_12 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_13() float32 { - if m != nil && m.CellVolt_13 != nil { - return *m.CellVolt_13 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_14() float32 { - if m != nil && m.CellVolt_14 != nil { - return *m.CellVolt_14 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_15() float32 { - if m != nil && m.CellVolt_15 != nil { - return *m.CellVolt_15 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_16() float32 { - if m != nil && m.CellVolt_16 != nil { - return *m.CellVolt_16 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_17() float32 { - if m != nil && m.CellVolt_17 != nil { - return *m.CellVolt_17 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_18() float32 { - if m != nil && m.CellVolt_18 != nil { - return *m.CellVolt_18 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_19() float32 { - if m != nil && m.CellVolt_19 != nil { - return *m.CellVolt_19 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_20() float32 { - if m != nil && m.CellVolt_20 != nil { - return *m.CellVolt_20 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_21() float32 { - if m != nil && m.CellVolt_21 != nil { - return *m.CellVolt_21 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_22() float32 { - if m != nil && m.CellVolt_22 != nil { - return *m.CellVolt_22 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_23() float32 { - if m != nil && m.CellVolt_23 != nil { - return *m.CellVolt_23 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_24() float32 { - if m != nil && m.CellVolt_24 != nil { - return *m.CellVolt_24 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_25() float32 { - if m != nil && m.CellVolt_25 != nil { - return *m.CellVolt_25 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_26() float32 { - if m != nil && m.CellVolt_26 != nil { - return *m.CellVolt_26 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_27() float32 { - if m != nil && m.CellVolt_27 != nil { - return *m.CellVolt_27 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_28() float32 { - if m != nil && m.CellVolt_28 != nil { - return *m.CellVolt_28 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_29() float32 { - if m != nil && m.CellVolt_29 != nil { - return *m.CellVolt_29 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_30() float32 { - if m != nil && m.CellVolt_30 != nil { - return *m.CellVolt_30 - } - return 0 -} - -func (m *DataMessage) GetCellVolt_31() float32 { - if m != nil && m.CellVolt_31 != nil { - return *m.CellVolt_31 - } - return 0 -} - -func (m *DataMessage) GetCellVoltMin() float32 { - if m != nil && m.CellVoltMin != nil { - return *m.CellVoltMin - } - return 0 -} - -func (m *DataMessage) GetCellVoltMax() float32 { - if m != nil && m.CellVoltMax != nil { - return *m.CellVoltMax - } - return 0 -} - -func (m *DataMessage) GetCellVoltAvg() float32 { - if m != nil && m.CellVoltAvg != nil { - return *m.CellVoltAvg - } - return 0 -} - -func (m *DataMessage) GetCellVoltDiff() float32 { - if m != nil && m.CellVoltDiff != nil { - return *m.CellVoltDiff - } - return 0 -} - -func (m *DataMessage) GetPowerSaveOn() int32 { - if m != nil && m.PowerSaveOn != nil { - return *m.PowerSaveOn - } - return 0 -} - -func (m *DataMessage) GetRearviewOn() int32 { - if m != nil && m.RearviewOn != nil { - return *m.RearviewOn - } - return 0 -} - -func (m *DataMessage) GetMicEnabled() int32 { - if m != nil && m.MicEnabled != nil { - return *m.MicEnabled - } - return 0 -} - -func (m *DataMessage) GetImuTemp() int32 { - if m != nil && m.ImuTemp != nil { - return *m.ImuTemp - } - return 0 -} - -func (m *DataMessage) GetImuMagnetX() int32 { - if m != nil && m.ImuMagnetX != nil { - return *m.ImuMagnetX - } - return 0 -} - -func (m *DataMessage) GetImuMagnetY() int32 { - if m != nil && m.ImuMagnetY != nil { - return *m.ImuMagnetY - } - return 0 -} - -func (m *DataMessage) GetImuMagnetZ() int32 { - if m != nil && m.ImuMagnetZ != nil { - return *m.ImuMagnetZ - } - return 0 -} - -func (m *DataMessage) GetImuGyroX() int32 { - if m != nil && m.ImuGyroX != nil { - return *m.ImuGyroX - } - return 0 -} - -func (m *DataMessage) GetImuGyroY() int32 { - if m != nil && m.ImuGyroY != nil { - return *m.ImuGyroY - } - return 0 -} - -func (m *DataMessage) GetImuGyroZ() int32 { - if m != nil && m.ImuGyroZ != nil { - return *m.ImuGyroZ - } - return 0 -} - -func (m *DataMessage) GetImuAccelX() int32 { - if m != nil && m.ImuAccelX != nil { - return *m.ImuAccelX - } - return 0 -} - -func (m *DataMessage) GetImuAccelY() int32 { - if m != nil && m.ImuAccelY != nil { - return *m.ImuAccelY - } - return 0 -} - -func (m *DataMessage) GetImuAccelZ() int32 { - if m != nil && m.ImuAccelZ != nil { - return *m.ImuAccelZ - } - return 0 -} - -func (m *DataMessage) GetBmsLeftMotorControllerCurrent() float32 { - if m != nil && m.BmsLeftMotorControllerCurrent != nil { - return *m.BmsLeftMotorControllerCurrent - } - return 0 -} - -func (m *DataMessage) GetBmsRightMotorControllerCurrent() float32 { - if m != nil && m.BmsRightMotorControllerCurrent != nil { - return *m.BmsRightMotorControllerCurrent - } - return 0 -} - -func (m *DataMessage) GetBmsMotorControllerCurrentSum() float32 { - if m != nil && m.BmsMotorControllerCurrentSum != nil { - return *m.BmsMotorControllerCurrentSum - } - return 0 -} - -func (m *DataMessage) GetPacketsPerSec() float32 { - if m != nil && m.PacketsPerSec != nil { - return *m.PacketsPerSec - } - return 0 -} - -func (m *DataMessage) GetTimeCollected() int64 { - if m != nil && m.TimeCollected != nil { - return *m.TimeCollected - } - return 0 -} - -func init() { - proto.RegisterType((*DataMessage)(nil), "DataMessage") -} - -func init() { proto.RegisterFile("internalproto/data_message.proto", fileDescriptor0) } - -var fileDescriptor0 = []byte{ - // 2328 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x99, 0x77, 0x7f, 0xdc, 0xb6, - 0x19, 0xc7, 0x3f, 0x4a, 0x9a, 0x5a, 0x86, 0x66, 0xe8, 0xf5, 0xd8, 0x8a, 0x64, 0xc9, 0x53, 0x69, - 0xda, 0x44, 0xe4, 0xe9, 0x34, 0x92, 0xba, 0xa9, 0xee, 0xce, 0xb5, 0x9d, 0x48, 0x91, 0x2a, 0xb9, - 0xae, 0xed, 0x0e, 0x16, 0x47, 0x42, 0x14, 0x6b, 0xae, 0x82, 0xbc, 0x93, 0xe4, 0xee, 0xbd, 0xf7, - 0xde, 0x7b, 0xf7, 0x65, 0xf5, 0x85, 0xe4, 0x03, 0x80, 0x03, 0x04, 0x49, 0x3b, 0x7f, 0xea, 0x79, - 0xbe, 0xcf, 0x83, 0x1f, 0x7f, 0x07, 0x80, 0x20, 0x84, 0xe6, 0xdd, 0x20, 0x21, 0x34, 0xc0, 0x5e, - 0x44, 0xc3, 0x24, 0x7c, 0xc5, 0xc6, 0x09, 0x36, 0x7d, 0x12, 0xc7, 0xd8, 0x21, 0x2f, 0xf3, 0xd0, - 0xa5, 0xff, 0xbf, 0x8a, 0xc6, 0x7a, 0x38, 0xc1, 0x5b, 0x22, 0xaa, 0x5d, 0x46, 0x13, 0x94, 0x38, - 0x24, 0x30, 0x49, 0x80, 0xfb, 0x1e, 0xb1, 0x61, 0x64, 0x7e, 0x64, 0x71, 0x62, 0x77, 0x9c, 0x07, - 0x6f, 0x8a, 0x58, 0x01, 0x59, 0xa1, 0xef, 0xe3, 0xc0, 0x86, 0x67, 0x24, 0xa8, 0x2b, 0x62, 0x0c, - 0xea, 0xe3, 0x24, 0x21, 0xf4, 0xd8, 0x8c, 0xc2, 0x43, 0x42, 0xe1, 0x59, 0x01, 0xa5, 0xc1, 0x1d, - 0x16, 0xd3, 0x2e, 0xa2, 0x31, 0x4c, 0x29, 0xce, 0x90, 0x77, 0xcd, 0x8f, 0x2c, 0x3e, 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, 0x16, 0xba, 0x5f, 0x06, - 0x8e, 0xe1, 0x1f, 0x0a, 0xf0, 0xa0, 0x0c, 0x3c, 0x86, 0x7f, 0x2a, 0xc0, 0x43, 0xed, 0x0e, 0x5a, - 0xe8, 0xfb, 0xb1, 0xf9, 0xe4, 0x8b, 0xbb, 0x7f, 0x89, 0xdf, 0x79, 0xb6, 0xef, 0xc7, 0x9b, 0xcd, - 0x97, 0x77, 0x6f, 0xa2, 0x4b, 0xac, 0xd5, 0x53, 0x2e, 0xf0, 0xfe, 0x2d, 0x7a, 0xcd, 0xf5, 0xfd, - 0x78, 0xf7, 0x09, 0x97, 0x78, 0xb7, 0xd0, 0x3c, 0x6b, 0xd6, 0x78, 0x91, 0x17, 0x0f, 0x7c, 0xf8, - 0x8f, 0x68, 0xf5, 0x42, 0xdf, 0x8f, 0xeb, 0xbb, 0xec, 0x0d, 0x7c, 0xed, 0x3a, 0x9a, 0x8a, 0xb0, - 0xf5, 0x88, 0x24, 0xb1, 0x19, 0xb1, 0x49, 0x49, 0x2c, 0xf8, 0xaf, 0xa8, 0x9b, 0x48, 0xe3, 0x3b, - 0x84, 0xee, 0x11, 0x4b, 0xbb, 0x86, 0x26, 0xd9, 0x77, 0x94, 0x69, 0xb1, 0x0e, 0x56, 0x42, 0x6c, - 0xf8, 0xdf, 0x08, 0xff, 0xa4, 0x9a, 0x60, 0xe1, 0x6e, 0x16, 0x7d, 0x3b, 0x00, 0x00, 0xff, 0xff, - 0x4e, 0xf6, 0x37, 0x32, 0x89, 0x1d, 0x00, 0x00, -} diff --git a/collector/serviceproto/collector_service.pb.go b/collector/serviceproto/collector_service.pb.go index a94683d..3506752 100644 --- a/collector/serviceproto/collector_service.pb.go +++ b/collector/serviceproto/collector_service.pb.go @@ -1,18 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: collector_service.proto -/* -Package collector_service is a generated protocol buffer package. - -It is generated from these files: - collector_service.proto - -It has these top-level messages: - StartRequest - StopRequest - StatusRequest - CollectorStatus -*/ package collector_service import proto "github.com/golang/protobuf/proto" @@ -36,13 +24,35 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package type StartRequest struct { - RunName string `protobuf:"bytes,1,opt,name=run_name,json=runName" json:"run_name,omitempty"` + RunName string `protobuf:"bytes,1,opt,name=run_name,json=runName,proto3" json:"run_name,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *StartRequest) Reset() { *m = StartRequest{} } -func (m *StartRequest) String() string { return proto.CompactTextString(m) } -func (*StartRequest) ProtoMessage() {} -func (*StartRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } +func (m *StartRequest) Reset() { *m = StartRequest{} } +func (m *StartRequest) String() string { return proto.CompactTextString(m) } +func (*StartRequest) ProtoMessage() {} +func (*StartRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_collector_service_b183020b3f37a696, []int{0} +} +func (m *StartRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_StartRequest.Unmarshal(m, b) +} +func (m *StartRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_StartRequest.Marshal(b, m, deterministic) +} +func (dst *StartRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_StartRequest.Merge(dst, src) +} +func (m *StartRequest) XXX_Size() int { + return xxx_messageInfo_StartRequest.Size(m) +} +func (m *StartRequest) XXX_DiscardUnknown() { + xxx_messageInfo_StartRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_StartRequest proto.InternalMessageInfo func (m *StartRequest) GetRunName() string { if m != nil { @@ -52,32 +62,98 @@ func (m *StartRequest) GetRunName() string { } type StopRequest struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *StopRequest) Reset() { *m = StopRequest{} } +func (m *StopRequest) String() string { return proto.CompactTextString(m) } +func (*StopRequest) ProtoMessage() {} +func (*StopRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_collector_service_b183020b3f37a696, []int{1} +} +func (m *StopRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_StopRequest.Unmarshal(m, b) +} +func (m *StopRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_StopRequest.Marshal(b, m, deterministic) +} +func (dst *StopRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_StopRequest.Merge(dst, src) +} +func (m *StopRequest) XXX_Size() int { + return xxx_messageInfo_StopRequest.Size(m) +} +func (m *StopRequest) XXX_DiscardUnknown() { + xxx_messageInfo_StopRequest.DiscardUnknown(m) } -func (m *StopRequest) Reset() { *m = StopRequest{} } -func (m *StopRequest) String() string { return proto.CompactTextString(m) } -func (*StopRequest) ProtoMessage() {} -func (*StopRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } +var xxx_messageInfo_StopRequest proto.InternalMessageInfo type StatusRequest struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *StatusRequest) Reset() { *m = StatusRequest{} } +func (m *StatusRequest) String() string { return proto.CompactTextString(m) } +func (*StatusRequest) ProtoMessage() {} +func (*StatusRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_collector_service_b183020b3f37a696, []int{2} +} +func (m *StatusRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_StatusRequest.Unmarshal(m, b) +} +func (m *StatusRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_StatusRequest.Marshal(b, m, deterministic) +} +func (dst *StatusRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_StatusRequest.Merge(dst, src) +} +func (m *StatusRequest) XXX_Size() int { + return xxx_messageInfo_StatusRequest.Size(m) +} +func (m *StatusRequest) XXX_DiscardUnknown() { + xxx_messageInfo_StatusRequest.DiscardUnknown(m) } -func (m *StatusRequest) Reset() { *m = StatusRequest{} } -func (m *StatusRequest) String() string { return proto.CompactTextString(m) } -func (*StatusRequest) ProtoMessage() {} -func (*StatusRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } +var xxx_messageInfo_StatusRequest proto.InternalMessageInfo type CollectorStatus struct { - Collecting bool `protobuf:"varint,1,opt,name=collecting" json:"collecting,omitempty"` - RunName string `protobuf:"bytes,2,opt,name=run_name,json=runName" json:"run_name,omitempty"` - Port int32 `protobuf:"varint,3,opt,name=port" json:"port,omitempty"` - PacketsRecorded int64 `protobuf:"varint,4,opt,name=packets_recorded,json=packetsRecorded" json:"packets_recorded,omitempty"` + Collecting bool `protobuf:"varint,1,opt,name=collecting,proto3" json:"collecting,omitempty"` + RunName string `protobuf:"bytes,2,opt,name=run_name,json=runName,proto3" json:"run_name,omitempty"` + Port int32 `protobuf:"varint,3,opt,name=port,proto3" json:"port,omitempty"` + PacketsRecorded int64 `protobuf:"varint,4,opt,name=packets_recorded,json=packetsRecorded,proto3" json:"packets_recorded,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *CollectorStatus) Reset() { *m = CollectorStatus{} } +func (m *CollectorStatus) String() string { return proto.CompactTextString(m) } +func (*CollectorStatus) ProtoMessage() {} +func (*CollectorStatus) Descriptor() ([]byte, []int) { + return fileDescriptor_collector_service_b183020b3f37a696, []int{3} +} +func (m *CollectorStatus) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_CollectorStatus.Unmarshal(m, b) +} +func (m *CollectorStatus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_CollectorStatus.Marshal(b, m, deterministic) +} +func (dst *CollectorStatus) XXX_Merge(src proto.Message) { + xxx_messageInfo_CollectorStatus.Merge(dst, src) +} +func (m *CollectorStatus) XXX_Size() int { + return xxx_messageInfo_CollectorStatus.Size(m) +} +func (m *CollectorStatus) XXX_DiscardUnknown() { + xxx_messageInfo_CollectorStatus.DiscardUnknown(m) } -func (m *CollectorStatus) Reset() { *m = CollectorStatus{} } -func (m *CollectorStatus) String() string { return proto.CompactTextString(m) } -func (*CollectorStatus) ProtoMessage() {} -func (*CollectorStatus) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } +var xxx_messageInfo_CollectorStatus proto.InternalMessageInfo func (m *CollectorStatus) GetCollecting() bool { if m != nil { @@ -122,8 +198,9 @@ var _ grpc.ClientConn // is compatible with the grpc package it is being compiled against. const _ = grpc.SupportPackageIsVersion4 -// Client API for CollectorService service - +// CollectorServiceClient is the client API for CollectorService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type CollectorServiceClient interface { StartCollecting(ctx context.Context, in *StartRequest, opts ...grpc.CallOption) (*CollectorStatus, error) StopCollecting(ctx context.Context, in *StopRequest, opts ...grpc.CallOption) (*CollectorStatus, error) @@ -140,7 +217,7 @@ func NewCollectorServiceClient(cc *grpc.ClientConn) CollectorServiceClient { func (c *collectorServiceClient) StartCollecting(ctx context.Context, in *StartRequest, opts ...grpc.CallOption) (*CollectorStatus, error) { out := new(CollectorStatus) - err := grpc.Invoke(ctx, "/CollectorService/StartCollecting", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/CollectorService/StartCollecting", in, out, opts...) if err != nil { return nil, err } @@ -149,7 +226,7 @@ func (c *collectorServiceClient) StartCollecting(ctx context.Context, in *StartR func (c *collectorServiceClient) StopCollecting(ctx context.Context, in *StopRequest, opts ...grpc.CallOption) (*CollectorStatus, error) { out := new(CollectorStatus) - err := grpc.Invoke(ctx, "/CollectorService/StopCollecting", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/CollectorService/StopCollecting", in, out, opts...) if err != nil { return nil, err } @@ -158,15 +235,14 @@ func (c *collectorServiceClient) StopCollecting(ctx context.Context, in *StopReq func (c *collectorServiceClient) GetCollectorStatus(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*CollectorStatus, error) { out := new(CollectorStatus) - err := grpc.Invoke(ctx, "/CollectorService/GetCollectorStatus", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/CollectorService/GetCollectorStatus", in, out, opts...) if err != nil { return nil, err } return out, nil } -// Server API for CollectorService service - +// CollectorServiceServer is the server API for CollectorService service. type CollectorServiceServer interface { StartCollecting(context.Context, *StartRequest) (*CollectorStatus, error) StopCollecting(context.Context, *StopRequest) (*CollectorStatus, error) @@ -252,9 +328,11 @@ var _CollectorService_serviceDesc = grpc.ServiceDesc{ Metadata: "collector_service.proto", } -func init() { proto.RegisterFile("collector_service.proto", fileDescriptor0) } +func init() { + proto.RegisterFile("collector_service.proto", fileDescriptor_collector_service_b183020b3f37a696) +} -var fileDescriptor0 = []byte{ +var fileDescriptor_collector_service_b183020b3f37a696 = []byte{ // 255 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xb1, 0x4e, 0xc3, 0x30, 0x10, 0x86, 0x31, 0x2d, 0x50, 0x8e, 0xa6, 0x89, 0x6e, 0x21, 0x30, 0xa0, 0x28, 0x53, 0xba, 0x78, diff --git a/collector/sources/blog_source.go b/collector/sources/blog_source.go deleted file mode 100644 index 491e57d..0000000 --- a/collector/sources/blog_source.go +++ /dev/null @@ -1,71 +0,0 @@ -package sources - -import ( - "context" - "io" - "log" - "time" - - "github.com/sscp/telemetry/blog" - "github.com/sscp/telemetry/collector/contextkeys" -) - -// BlogPacketSource is a PacketSource that reads from an io.Reader -// The delay between packets can be set to some constant -type BlogPacketSource struct { - reader io.Reader - doneChan chan bool - outChan chan *ContextPacket -} - -// NewBlogPacketSource instantiates a BlogPacketSource -// It reads packets to the specified output channel and waits the given -// duration between reading packets -func NewBlogPacketSource(r io.Reader, d time.Duration) PacketSource { - return &BlogPacketSource{ - reader: r, - doneChan: make(chan bool), - outChan: make(chan *ContextPacket), - } -} - -// Listen reads packets from the file sequentially until the file is empty, then calls Close -func (bps *BlogPacketSource) Listen() { - rdr := blog.NewReader(bps.reader) - go func() { - for { - readPacket, err := rdr.NextPacket() - if err != nil { - if err == io.EOF { - bps.Close() - bps.doneChan <- true - break - } else { - log.Fatal(err) - } - } - recievedTime := time.Now() - // Create context with time of receiving packet - ctx := contextkeys.ContextWithRecievedTime(context.Background(), recievedTime) - - bps.outChan <- &ContextPacket{ - Ctx: ctx, - Packet: readPacket, - } - } - }() -} - -// Packets returns the channel into which all the read packets are placed -func (bps *BlogPacketSource) Packets() <-chan *ContextPacket { - return bps.outChan -} - -// Close closes the Packets channel -// -// This is called when the end of the stream is reached to wait until the -// goroutine exits and there are no more packets -func (bps *BlogPacketSource) Close() { - // Wait on the done channel - <-bps.doneChan -} diff --git a/collector/sources/blog_source_test.go b/collector/sources/blog_source_test.go deleted file mode 100644 index b2674a2..0000000 --- a/collector/sources/blog_source_test.go +++ /dev/null @@ -1,42 +0,0 @@ -package sources - -import ( - "bytes" - "github.com/sscp/telemetry/blog" - "reflect" - "testing" - "time" -) - -type BlogReaderSourceTest struct { - Packets [][]byte - Delay time.Duration -} - -var BlogTests = []BlogReaderSourceTest{ - BlogReaderSourceTest{ - Packets: [][]byte{[]byte("hello"), []byte("i am a packet"), []byte("im another packet")}, - }, -} - -func testBlogReaderSource(t *testing.T) { - for _, blogTest := range BlogTests { - buf := new(bytes.Buffer) - - writer := blog.NewWriter(buf) - for _, s := range blogTest.Packets { - writer.Write(s) - } - - bufRead := bytes.NewReader(buf.Bytes()) - bps := NewBlogPacketSource(bufRead, blogTest.Delay) - - var i int = 0 - for packet := range bps.Packets() { - if !reflect.DeepEqual(blogTest.Packets[i], packet) { - t.Errorf("Output packet, %v, does not match input packet %s", packet, blogTest.Packets[i]) - } - i++ - } - } -} diff --git a/collector/sources/source.go b/collector/sources/source.go deleted file mode 100644 index f20323f..0000000 --- a/collector/sources/source.go +++ /dev/null @@ -1,30 +0,0 @@ -package sources - -import ( - "context" -) - -// ContextPacket holds context from -type ContextPacket struct { - Ctx context.Context - Packet []byte -} - -// PacketSource abstracts over a source of data packets, can be a file or -// listening for UDP packets -// -// Packets is a channel where raw packets are returned -// Close closes the channel, but the channel may close by itself if it reaches -// the end of the file, or there is a natural end to the stream -type PacketSource interface { - // Packets returns a reference to the output channel of packets - // produced by the DataSource - Packets() <-chan *ContextPacket - - // Listen begins collecting packets and putting them on the output - // channel. - Listen() - - // Close stops putting packets on the output channel - Close() -} diff --git a/collector/sources/udp_source_test.go b/collector/sources/udp_source_test.go deleted file mode 100644 index e323dac..0000000 --- a/collector/sources/udp_source_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package sources - -import ( - "context" - "math/rand" - "reflect" - "testing" -) - -func TestUDPSendRecv(t *testing.T) { - src, err := NewUDPPacketSource(3000) - if err != nil { - t.Errorf("Error creating packet source: %v", err) - } - - packetChan := make(chan *ContextPacket) - // Send all the packets in the channel - go SendPacketsAsUDP(packetChan, 3000) - - // Listen for those same packets - src.Listen() - defer src.Close() - - for i := 1; i < 512; i++ { - // Make a random packet - packet := make([]byte, i) - rand.Read(packet) - - // Packet sent to the send channel - packetChan <- &ContextPacket{Packet: packet, Ctx: context.Background()} - - // Listen for the packet on the recv channel - outPacket := <-src.Packets() - - // Check that everything made it - if !reflect.DeepEqual(packet, outPacket.Packet) { - t.Errorf("Output packet, %v, does not match input packet %v", outPacket.Packet, packet) - } - } -} diff --git a/collector/sources/zero_source_test.go b/collector/sources/zero_source_test.go deleted file mode 100644 index 5099381..0000000 --- a/collector/sources/zero_source_test.go +++ /dev/null @@ -1,26 +0,0 @@ -package sources - -import ( - "github.com/golang/protobuf/proto" - internalproto "github.com/sscp/telemetry/collector/internalproto" - - "github.com/stretchr/testify/assert" - "testing" -) - -func TestZeroPacketSource(t *testing.T) { - zps := NewZeroPacketSource(1000) - - zps.Listen() - - for i := 0; i < 10; i++ { - ctxPacket := <-zps.Packets() - dm := internalproto.DataMessage{} - err := proto.Unmarshal(ctxPacket.Packet, &dm) - assert.Nil(t, err) - assert.Equal( - t, dm.GetMotorControllerSpeed(), float32(0.0), - "Motor controller speed should be zero", - ) - } -} diff --git a/collector/sundae/sundae.pb.go b/collector/sundae/sundae.pb.go deleted file mode 100644 index 1044d37..0000000 --- a/collector/sundae/sundae.pb.go +++ /dev/null @@ -1,1544 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: sundae.proto - -/* -Package sundae is a generated protocol buffer package. - -It is generated from these files: - sundae.proto - -It has these top-level messages: - SundaeDataMessage -*/ -package sundae - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -type SundaeDataMessage struct { - RegenEnabled *uint32 `protobuf:"varint,1,opt,name=regen_enabled,json=regenEnabled" json:"regen_enabled,omitempty"` - RegenCommand *uint32 `protobuf:"varint,2,opt,name=regen_command,json=regenCommand" json:"regen_command,omitempty"` - BatteryPower *uint32 `protobuf:"varint,3,opt,name=battery_power,json=batteryPower" json:"battery_power,omitempty"` - ArrayPower *float32 `protobuf:"fixed32,4,opt,name=array_power,json=arrayPower" json:"array_power,omitempty"` - ReverseOn *uint32 `protobuf:"varint,5,opt,name=reverse_on,json=reverseOn" json:"reverse_on,omitempty"` - LowVoltPower *float32 `protobuf:"fixed32,6,opt,name=low_volt_power,json=lowVoltPower" json:"low_volt_power,omitempty"` - CellReadError *int32 `protobuf:"varint,7,opt,name=cell_read_error,json=cellReadError" json:"cell_read_error,omitempty"` - CellBleed *uint32 `protobuf:"varint,8,opt,name=cell_bleed,json=cellBleed" json:"cell_bleed,omitempty"` - CruiseSpeed *float32 `protobuf:"fixed32,9,opt,name=cruise_speed,json=cruiseSpeed" json:"cruise_speed,omitempty"` - HazardLightsOn *int32 `protobuf:"varint,10,opt,name=hazard_lights_on,json=hazardLightsOn" json:"hazard_lights_on,omitempty"` - BatteryVoltage *float32 `protobuf:"fixed32,11,opt,name=battery_voltage,json=batteryVoltage" json:"battery_voltage,omitempty"` - Ltc6804Badpec *uint32 `protobuf:"varint,12,opt,name=ltc6804_badpec,json=ltc6804Badpec" json:"ltc6804_badpec,omitempty"` - BmsState *uint32 `protobuf:"varint,13,opt,name=bms_state,json=bmsState" json:"bms_state,omitempty"` - ChargeEnabled *int32 `protobuf:"varint,14,opt,name=charge_enabled,json=chargeEnabled" json:"charge_enabled,omitempty"` - DischargeEnabled *int32 `protobuf:"varint,15,opt,name=discharge_enabled,json=dischargeEnabled" json:"discharge_enabled,omitempty"` - HighsideContactorOn *int32 `protobuf:"varint,16,opt,name=highside_contactor_on,json=highsideContactorOn" json:"highside_contactor_on,omitempty"` - LowsideContactorOn *int32 `protobuf:"varint,17,opt,name=lowside_contactor_on,json=lowsideContactorOn" json:"lowside_contactor_on,omitempty"` - PrechargeOn *int32 `protobuf:"varint,18,opt,name=precharge_on,json=prechargeOn" json:"precharge_on,omitempty"` - LowVoltBusOn *int32 `protobuf:"varint,19,opt,name=low_volt_bus_on,json=lowVoltBusOn" json:"low_volt_bus_on,omitempty"` - BatteryTemp_1 *float32 `protobuf:"fixed32,20,opt,name=battery_temp_1,json=batteryTemp1" json:"battery_temp_1,omitempty"` - BatteryTemp_2 *float32 `protobuf:"fixed32,21,opt,name=battery_temp_2,json=batteryTemp2" json:"battery_temp_2,omitempty"` - BatteryTemp_3 *float32 `protobuf:"fixed32,22,opt,name=battery_temp_3,json=batteryTemp3" json:"battery_temp_3,omitempty"` - BatteryTemp_4 *float32 `protobuf:"fixed32,23,opt,name=battery_temp_4,json=batteryTemp4" json:"battery_temp_4,omitempty"` - BatteryTemp_5 *float32 `protobuf:"fixed32,24,opt,name=battery_temp_5,json=batteryTemp5" json:"battery_temp_5,omitempty"` - BatteryTemp_6 *float32 `protobuf:"fixed32,25,opt,name=battery_temp_6,json=batteryTemp6" json:"battery_temp_6,omitempty"` - BmsPrechargeBatteryAdc *float32 `protobuf:"fixed32,26,opt,name=bms_precharge_battery_adc,json=bmsPrechargeBatteryAdc" json:"bms_precharge_battery_adc,omitempty"` - BmsPrechargeCarAdc *float32 `protobuf:"fixed32,27,opt,name=bms_precharge_car_adc,json=bmsPrechargeCarAdc" json:"bms_precharge_car_adc,omitempty"` - // gap - LowVoltOutputCurrent *float32 `protobuf:"fixed32,29,opt,name=low_volt_output_current,json=lowVoltOutputCurrent" json:"low_volt_output_current,omitempty"` - ArrayCurrent *float32 `protobuf:"fixed32,30,opt,name=array_current,json=arrayCurrent" json:"array_current,omitempty"` - BatteryCurrent *float32 `protobuf:"fixed32,31,opt,name=battery_current,json=batteryCurrent" json:"battery_current,omitempty"` - LeftMotorControllerPower *float32 `protobuf:"fixed32,32,opt,name=left_motor_controller_power,json=leftMotorControllerPower" json:"left_motor_controller_power,omitempty"` - RightMotorControllerPower *float32 `protobuf:"fixed32,33,opt,name=right_motor_controller_power,json=rightMotorControllerPower" json:"right_motor_controller_power,omitempty"` - AmpHours *float32 `protobuf:"fixed32,34,opt,name=amp_hours,json=ampHours" json:"amp_hours,omitempty"` - HeadLightsOn *int32 `protobuf:"varint,35,opt,name=head_lights_on,json=headLightsOn" json:"head_lights_on,omitempty"` - BrakeLightsOn *int32 `protobuf:"varint,36,opt,name=brake_lights_on,json=brakeLightsOn" json:"brake_lights_on,omitempty"` - RightBlinkerOn *int32 `protobuf:"varint,37,opt,name=right_blinker_on,json=rightBlinkerOn" json:"right_blinker_on,omitempty"` - LeftBlinkerOn *int32 `protobuf:"varint,38,opt,name=left_blinker_on,json=leftBlinkerOn" json:"left_blinker_on,omitempty"` - BrakePressed *int32 `protobuf:"varint,39,opt,name=brake_pressed,json=brakePressed" json:"brake_pressed,omitempty"` - ThrottlePressed *int32 `protobuf:"varint,40,opt,name=throttle_pressed,json=throttlePressed" json:"throttle_pressed,omitempty"` - DriveMode *uint32 `protobuf:"varint,41,opt,name=drive_mode,json=driveMode" json:"drive_mode,omitempty"` - MotorControllerEnabled *int32 `protobuf:"varint,42,opt,name=motor_controller_enabled,json=motorControllerEnabled" json:"motor_controller_enabled,omitempty"` - MotorControllerSpeed *float32 `protobuf:"fixed32,43,opt,name=motor_controller_speed,json=motorControllerSpeed" json:"motor_controller_speed,omitempty"` - MotorControllerRpm *float32 `protobuf:"fixed32,44,opt,name=motor_controller_rpm,json=motorControllerRpm" json:"motor_controller_rpm,omitempty"` - AvgOdometer *float32 `protobuf:"fixed32,45,opt,name=avg_odometer,json=avgOdometer" json:"avg_odometer,omitempty"` - LeftMotorTemp *float32 `protobuf:"fixed32,46,opt,name=left_motor_temp,json=leftMotorTemp" json:"left_motor_temp,omitempty"` - RightMotorTemp *float32 `protobuf:"fixed32,47,opt,name=right_motor_temp,json=rightMotorTemp" json:"right_motor_temp,omitempty"` - LeftMotorControllerTemp *float32 `protobuf:"fixed32,48,opt,name=left_motor_controller_temp,json=leftMotorControllerTemp" json:"left_motor_controller_temp,omitempty"` - RightMotorControllerTemp *float32 `protobuf:"fixed32,49,opt,name=right_motor_controller_temp,json=rightMotorControllerTemp" json:"right_motor_controller_temp,omitempty"` - LeftMotorControllerAlive *float32 `protobuf:"fixed32,50,opt,name=left_motor_controller_alive,json=leftMotorControllerAlive" json:"left_motor_controller_alive,omitempty"` - RightMotorControllerAlive *float32 `protobuf:"fixed32,51,opt,name=right_motor_controller_alive,json=rightMotorControllerAlive" json:"right_motor_controller_alive,omitempty"` - LeftMotorControllerCurrent *float32 `protobuf:"fixed32,52,opt,name=left_motor_controller_current,json=leftMotorControllerCurrent" json:"left_motor_controller_current,omitempty"` - RightMotorControllerCurrent *float32 `protobuf:"fixed32,53,opt,name=right_motor_controller_current,json=rightMotorControllerCurrent" json:"right_motor_controller_current,omitempty"` - MotorControllerCurrentDiff *float32 `protobuf:"fixed32,54,opt,name=motor_controller_current_diff,json=motorControllerCurrentDiff" json:"motor_controller_current_diff,omitempty"` - LeftMotorControllerError *uint32 `protobuf:"varint,55,opt,name=left_motor_controller_error,json=leftMotorControllerError" json:"left_motor_controller_error,omitempty"` - RightMotorControllerError *uint32 `protobuf:"varint,56,opt,name=right_motor_controller_error,json=rightMotorControllerError" json:"right_motor_controller_error,omitempty"` - LeftMotorControllerLimit *uint32 `protobuf:"varint,57,opt,name=left_motor_controller_limit,json=leftMotorControllerLimit" json:"left_motor_controller_limit,omitempty"` - RightMotorControllerLimit *uint32 `protobuf:"varint,58,opt,name=right_motor_controller_limit,json=rightMotorControllerLimit" json:"right_motor_controller_limit,omitempty"` - LeftMotorControllerRxErrorCount *uint32 `protobuf:"varint,59,opt,name=left_motor_controller_rx_error_count,json=leftMotorControllerRxErrorCount" json:"left_motor_controller_rx_error_count,omitempty"` - RightMotorControllerRxErrorCount *uint32 `protobuf:"varint,60,opt,name=right_motor_controller_rx_error_count,json=rightMotorControllerRxErrorCount" json:"right_motor_controller_rx_error_count,omitempty"` - LeftMotorControllerTxErrorCount *uint32 `protobuf:"varint,61,opt,name=left_motor_controller_tx_error_count,json=leftMotorControllerTxErrorCount" json:"left_motor_controller_tx_error_count,omitempty"` - RightMotorControllerTxErrorCount *uint32 `protobuf:"varint,62,opt,name=right_motor_controller_tx_error_count,json=rightMotorControllerTxErrorCount" json:"right_motor_controller_tx_error_count,omitempty"` - LeftMotorControllerBusVoltage *float32 `protobuf:"fixed32,63,opt,name=left_motor_controller_bus_voltage,json=leftMotorControllerBusVoltage" json:"left_motor_controller_bus_voltage,omitempty"` - RightMotorControllerBusVoltage *float32 `protobuf:"fixed32,64,opt,name=right_motor_controller_bus_voltage,json=rightMotorControllerBusVoltage" json:"right_motor_controller_bus_voltage,omitempty"` - LeftMotorController_15VVoltage *float32 `protobuf:"fixed32,65,opt,name=left_motor_controller_15v_voltage,json=leftMotorController15vVoltage" json:"left_motor_controller_15v_voltage,omitempty"` - RightMotorController_15VVoltage *float32 `protobuf:"fixed32,66,opt,name=right_motor_controller_15v_voltage,json=rightMotorController15vVoltage" json:"right_motor_controller_15v_voltage,omitempty"` - LeftMotorController_3V3Voltage *float32 `protobuf:"fixed32,67,opt,name=left_motor_controller_3v3_voltage,json=leftMotorController3v3Voltage" json:"left_motor_controller_3v3_voltage,omitempty"` - RightMotorController_3V3Voltage *float32 `protobuf:"fixed32,68,opt,name=right_motor_controller_3v3_voltage,json=rightMotorController3v3Voltage" json:"right_motor_controller_3v3_voltage,omitempty"` - LeftMotorController_1V9Voltage *float32 `protobuf:"fixed32,69,opt,name=left_motor_controller_1v9_voltage,json=leftMotorController1v9Voltage" json:"left_motor_controller_1v9_voltage,omitempty"` - RightMotorController_1V9Voltage *float32 `protobuf:"fixed32,70,opt,name=right_motor_controller_1v9_voltage,json=rightMotorController1v9Voltage" json:"right_motor_controller_1v9_voltage,omitempty"` - LeftMotorControllerDspTemp *float32 `protobuf:"fixed32,71,opt,name=left_motor_controller_dsp_temp,json=leftMotorControllerDspTemp" json:"left_motor_controller_dsp_temp,omitempty"` - RightMotorControllerDspTemp *float32 `protobuf:"fixed32,72,opt,name=right_motor_controller_dsp_temp,json=rightMotorControllerDspTemp" json:"right_motor_controller_dsp_temp,omitempty"` - LeftMotorControllerPhaseCurrent *float32 `protobuf:"fixed32,73,opt,name=left_motor_controller_phase_current,json=leftMotorControllerPhaseCurrent" json:"left_motor_controller_phase_current,omitempty"` - RightMotorControllerPhaseCurrent *float32 `protobuf:"fixed32,74,opt,name=right_motor_controller_phase_current,json=rightMotorControllerPhaseCurrent" json:"right_motor_controller_phase_current,omitempty"` - LeftMotorRpmCommand *float32 `protobuf:"fixed32,75,opt,name=left_motor_rpm_command,json=leftMotorRpmCommand" json:"left_motor_rpm_command,omitempty"` - RightMotorRpmCommand *float32 `protobuf:"fixed32,76,opt,name=right_motor_rpm_command,json=rightMotorRpmCommand" json:"right_motor_rpm_command,omitempty"` - LeftMotorCurrentCommand *float32 `protobuf:"fixed32,77,opt,name=left_motor_current_command,json=leftMotorCurrentCommand" json:"left_motor_current_command,omitempty"` - RightMotorCurrentCommand *float32 `protobuf:"fixed32,78,opt,name=right_motor_current_command,json=rightMotorCurrentCommand" json:"right_motor_current_command,omitempty"` - GpsTime *int64 `protobuf:"varint,80,opt,name=gps_time,json=gpsTime" json:"gps_time,omitempty"` - GpsLatitude *float32 `protobuf:"fixed32,81,opt,name=gps_latitude,json=gpsLatitude" json:"gps_latitude,omitempty"` - GpsLongitude *float32 `protobuf:"fixed32,82,opt,name=gps_longitude,json=gpsLongitude" json:"gps_longitude,omitempty"` - GpsSpeed *float32 `protobuf:"fixed32,83,opt,name=gps_speed,json=gpsSpeed" json:"gps_speed,omitempty"` - GpsAltitude *float32 `protobuf:"fixed32,84,opt,name=gps_altitude,json=gpsAltitude" json:"gps_altitude,omitempty"` - GpsBearing *float32 `protobuf:"fixed32,85,opt,name=gps_bearing,json=gpsBearing" json:"gps_bearing,omitempty"` - LedState *int32 `protobuf:"varint,86,opt,name=led_state,json=ledState" json:"led_state,omitempty"` - MpptArrayPower *float32 `protobuf:"fixed32,87,opt,name=mppt_array_power,json=mpptArrayPower" json:"mppt_array_power,omitempty"` - Mppt_A0VoltIn *float32 `protobuf:"fixed32,88,opt,name=mppt_A0_volt_in,json=mpptA0VoltIn" json:"mppt_A0_volt_in,omitempty"` - Mppt_A0VoltOut *float32 `protobuf:"fixed32,89,opt,name=mppt_A0_volt_out,json=mpptA0VoltOut" json:"mppt_A0_volt_out,omitempty"` - Mppt_A0Current *float32 `protobuf:"fixed32,90,opt,name=mppt_A0_current,json=mpptA0Current" json:"mppt_A0_current,omitempty"` - Mppt_A0Temp *float32 `protobuf:"fixed32,91,opt,name=mppt_A0_temp,json=mpptA0Temp" json:"mppt_A0_temp,omitempty"` - Mppt_A1VoltIn *float32 `protobuf:"fixed32,92,opt,name=mppt_A1_volt_in,json=mpptA1VoltIn" json:"mppt_A1_volt_in,omitempty"` - Mppt_A1VoltOut *float32 `protobuf:"fixed32,93,opt,name=mppt_A1_volt_out,json=mpptA1VoltOut" json:"mppt_A1_volt_out,omitempty"` - Mppt_A1Current *float32 `protobuf:"fixed32,94,opt,name=mppt_A1_current,json=mpptA1Current" json:"mppt_A1_current,omitempty"` - Mppt_A1Temp *float32 `protobuf:"fixed32,95,opt,name=mppt_A1_temp,json=mpptA1Temp" json:"mppt_A1_temp,omitempty"` - Mppt_B0VoltIn *float32 `protobuf:"fixed32,96,opt,name=mppt_B0_volt_in,json=mpptB0VoltIn" json:"mppt_B0_volt_in,omitempty"` - Mppt_B0VoltOut *float32 `protobuf:"fixed32,97,opt,name=mppt_B0_volt_out,json=mpptB0VoltOut" json:"mppt_B0_volt_out,omitempty"` - Mppt_B0Current *float32 `protobuf:"fixed32,98,opt,name=mppt_B0_current,json=mpptB0Current" json:"mppt_B0_current,omitempty"` - Mppt_B0Temp *float32 `protobuf:"fixed32,99,opt,name=mppt_B0_temp,json=mpptB0Temp" json:"mppt_B0_temp,omitempty"` - Mppt_B1VoltIn *float32 `protobuf:"fixed32,100,opt,name=mppt_B1_volt_in,json=mpptB1VoltIn" json:"mppt_B1_volt_in,omitempty"` - Mppt_B1VoltOut *float32 `protobuf:"fixed32,101,opt,name=mppt_B1_volt_out,json=mpptB1VoltOut" json:"mppt_B1_volt_out,omitempty"` - Mppt_B1Current *float32 `protobuf:"fixed32,102,opt,name=mppt_B1_current,json=mpptB1Current" json:"mppt_B1_current,omitempty"` - Mppt_B1Temp *float32 `protobuf:"fixed32,103,opt,name=mppt_B1_temp,json=mpptB1Temp" json:"mppt_B1_temp,omitempty"` - Mppt_C0VoltIn *float32 `protobuf:"fixed32,104,opt,name=mppt_C0_volt_in,json=mpptC0VoltIn" json:"mppt_C0_volt_in,omitempty"` - Mppt_C0VoltOut *float32 `protobuf:"fixed32,105,opt,name=mppt_C0_volt_out,json=mpptC0VoltOut" json:"mppt_C0_volt_out,omitempty"` - Mppt_C0Current *float32 `protobuf:"fixed32,106,opt,name=mppt_C0_current,json=mpptC0Current" json:"mppt_C0_current,omitempty"` - Mppt_C0Temp *float32 `protobuf:"fixed32,107,opt,name=mppt_C0_temp,json=mpptC0Temp" json:"mppt_C0_temp,omitempty"` - Mppt_C1VoltIn *float32 `protobuf:"fixed32,108,opt,name=mppt_C1_volt_in,json=mpptC1VoltIn" json:"mppt_C1_volt_in,omitempty"` - Mppt_C1VoltOut *float32 `protobuf:"fixed32,109,opt,name=mppt_C1_volt_out,json=mpptC1VoltOut" json:"mppt_C1_volt_out,omitempty"` - Mppt_C1Current *float32 `protobuf:"fixed32,110,opt,name=mppt_C1_current,json=mpptC1Current" json:"mppt_C1_current,omitempty"` - Mppt_C1Temp *float32 `protobuf:"fixed32,111,opt,name=mppt_C1_temp,json=mpptC1Temp" json:"mppt_C1_temp,omitempty"` - Mppt_D0VoltIn *float32 `protobuf:"fixed32,112,opt,name=mppt_D0_volt_in,json=mpptD0VoltIn" json:"mppt_D0_volt_in,omitempty"` - Mppt_D0VoltOut *float32 `protobuf:"fixed32,113,opt,name=mppt_D0_volt_out,json=mpptD0VoltOut" json:"mppt_D0_volt_out,omitempty"` - Mppt_D0Current *float32 `protobuf:"fixed32,114,opt,name=mppt_D0_current,json=mpptD0Current" json:"mppt_D0_current,omitempty"` - Mppt_D0Temp *float32 `protobuf:"fixed32,115,opt,name=mppt_D0_temp,json=mpptD0Temp" json:"mppt_D0_temp,omitempty"` - Mppt_D1VoltIn *float32 `protobuf:"fixed32,116,opt,name=mppt_D1_volt_in,json=mpptD1VoltIn" json:"mppt_D1_volt_in,omitempty"` - Mppt_D1VoltOut *float32 `protobuf:"fixed32,117,opt,name=mppt_D1_volt_out,json=mpptD1VoltOut" json:"mppt_D1_volt_out,omitempty"` - Mppt_D1Current *float32 `protobuf:"fixed32,118,opt,name=mppt_D1_current,json=mpptD1Current" json:"mppt_D1_current,omitempty"` - Mppt_D1Temp *float32 `protobuf:"fixed32,119,opt,name=mppt_D1_temp,json=mpptD1Temp" json:"mppt_D1_temp,omitempty"` - CellVolt_1 *float32 `protobuf:"fixed32,120,opt,name=cell_volt_1,json=cellVolt1" json:"cell_volt_1,omitempty"` - CellVolt_2 *float32 `protobuf:"fixed32,121,opt,name=cell_volt_2,json=cellVolt2" json:"cell_volt_2,omitempty"` - CellVolt_3 *float32 `protobuf:"fixed32,122,opt,name=cell_volt_3,json=cellVolt3" json:"cell_volt_3,omitempty"` - CellVolt_4 *float32 `protobuf:"fixed32,123,opt,name=cell_volt_4,json=cellVolt4" json:"cell_volt_4,omitempty"` - CellVolt_5 *float32 `protobuf:"fixed32,124,opt,name=cell_volt_5,json=cellVolt5" json:"cell_volt_5,omitempty"` - CellVolt_6 *float32 `protobuf:"fixed32,125,opt,name=cell_volt_6,json=cellVolt6" json:"cell_volt_6,omitempty"` - CellVolt_7 *float32 `protobuf:"fixed32,126,opt,name=cell_volt_7,json=cellVolt7" json:"cell_volt_7,omitempty"` - CellVolt_8 *float32 `protobuf:"fixed32,127,opt,name=cell_volt_8,json=cellVolt8" json:"cell_volt_8,omitempty"` - CellVolt_9 *float32 `protobuf:"fixed32,128,opt,name=cell_volt_9,json=cellVolt9" json:"cell_volt_9,omitempty"` - CellVolt_10 *float32 `protobuf:"fixed32,129,opt,name=cell_volt_10,json=cellVolt10" json:"cell_volt_10,omitempty"` - CellVolt_11 *float32 `protobuf:"fixed32,130,opt,name=cell_volt_11,json=cellVolt11" json:"cell_volt_11,omitempty"` - CellVolt_12 *float32 `protobuf:"fixed32,131,opt,name=cell_volt_12,json=cellVolt12" json:"cell_volt_12,omitempty"` - CellVolt_13 *float32 `protobuf:"fixed32,132,opt,name=cell_volt_13,json=cellVolt13" json:"cell_volt_13,omitempty"` - CellVolt_14 *float32 `protobuf:"fixed32,133,opt,name=cell_volt_14,json=cellVolt14" json:"cell_volt_14,omitempty"` - CellVolt_15 *float32 `protobuf:"fixed32,134,opt,name=cell_volt_15,json=cellVolt15" json:"cell_volt_15,omitempty"` - CellVolt_16 *float32 `protobuf:"fixed32,135,opt,name=cell_volt_16,json=cellVolt16" json:"cell_volt_16,omitempty"` - CellVolt_17 *float32 `protobuf:"fixed32,136,opt,name=cell_volt_17,json=cellVolt17" json:"cell_volt_17,omitempty"` - CellVolt_18 *float32 `protobuf:"fixed32,137,opt,name=cell_volt_18,json=cellVolt18" json:"cell_volt_18,omitempty"` - CellVolt_19 *float32 `protobuf:"fixed32,138,opt,name=cell_volt_19,json=cellVolt19" json:"cell_volt_19,omitempty"` - CellVolt_20 *float32 `protobuf:"fixed32,139,opt,name=cell_volt_20,json=cellVolt20" json:"cell_volt_20,omitempty"` - CellVolt_21 *float32 `protobuf:"fixed32,140,opt,name=cell_volt_21,json=cellVolt21" json:"cell_volt_21,omitempty"` - CellVolt_22 *float32 `protobuf:"fixed32,141,opt,name=cell_volt_22,json=cellVolt22" json:"cell_volt_22,omitempty"` - CellVolt_23 *float32 `protobuf:"fixed32,142,opt,name=cell_volt_23,json=cellVolt23" json:"cell_volt_23,omitempty"` - CellVolt_24 *float32 `protobuf:"fixed32,143,opt,name=cell_volt_24,json=cellVolt24" json:"cell_volt_24,omitempty"` - CellVolt_25 *float32 `protobuf:"fixed32,144,opt,name=cell_volt_25,json=cellVolt25" json:"cell_volt_25,omitempty"` - CellVolt_26 *float32 `protobuf:"fixed32,145,opt,name=cell_volt_26,json=cellVolt26" json:"cell_volt_26,omitempty"` - CellVolt_27 *float32 `protobuf:"fixed32,146,opt,name=cell_volt_27,json=cellVolt27" json:"cell_volt_27,omitempty"` - CellVolt_28 *float32 `protobuf:"fixed32,147,opt,name=cell_volt_28,json=cellVolt28" json:"cell_volt_28,omitempty"` - CellVolt_29 *float32 `protobuf:"fixed32,148,opt,name=cell_volt_29,json=cellVolt29" json:"cell_volt_29,omitempty"` - CellVolt_30 *float32 `protobuf:"fixed32,149,opt,name=cell_volt_30,json=cellVolt30" json:"cell_volt_30,omitempty"` - CellVolt_31 *float32 `protobuf:"fixed32,150,opt,name=cell_volt_31,json=cellVolt31" json:"cell_volt_31,omitempty"` - CellVoltMin *float32 `protobuf:"fixed32,151,opt,name=cell_volt_min,json=cellVoltMin" json:"cell_volt_min,omitempty"` - CellVoltMax *float32 `protobuf:"fixed32,152,opt,name=cell_volt_max,json=cellVoltMax" json:"cell_volt_max,omitempty"` - CellVoltAvg *float32 `protobuf:"fixed32,153,opt,name=cell_volt_avg,json=cellVoltAvg" json:"cell_volt_avg,omitempty"` - CellVoltDiff *float32 `protobuf:"fixed32,154,opt,name=cell_volt_diff,json=cellVoltDiff" json:"cell_volt_diff,omitempty"` - PowerSaveOn *int32 `protobuf:"varint,155,opt,name=power_save_on,json=powerSaveOn" json:"power_save_on,omitempty"` - RearviewOn *int32 `protobuf:"varint,156,opt,name=rearview_on,json=rearviewOn" json:"rearview_on,omitempty"` - MicEnabled *int32 `protobuf:"varint,157,opt,name=mic_enabled,json=micEnabled" json:"mic_enabled,omitempty"` - ImuTemp *int32 `protobuf:"varint,158,opt,name=imu_temp,json=imuTemp" json:"imu_temp,omitempty"` - ImuMagnetX *int32 `protobuf:"varint,159,opt,name=imu_magnet_x,json=imuMagnetX" json:"imu_magnet_x,omitempty"` - ImuMagnetY *int32 `protobuf:"varint,160,opt,name=imu_magnet_y,json=imuMagnetY" json:"imu_magnet_y,omitempty"` - ImuMagnetZ *int32 `protobuf:"varint,161,opt,name=imu_magnet_z,json=imuMagnetZ" json:"imu_magnet_z,omitempty"` - ImuGyroX *int32 `protobuf:"varint,162,opt,name=imu_gyro_x,json=imuGyroX" json:"imu_gyro_x,omitempty"` - ImuGyroY *int32 `protobuf:"varint,163,opt,name=imu_gyro_y,json=imuGyroY" json:"imu_gyro_y,omitempty"` - ImuGyroZ *int32 `protobuf:"varint,164,opt,name=imu_gyro_z,json=imuGyroZ" json:"imu_gyro_z,omitempty"` - ImuAccelX *int32 `protobuf:"varint,165,opt,name=imu_accel_x,json=imuAccelX" json:"imu_accel_x,omitempty"` - ImuAccelY *int32 `protobuf:"varint,166,opt,name=imu_accel_y,json=imuAccelY" json:"imu_accel_y,omitempty"` - ImuAccelZ *int32 `protobuf:"varint,167,opt,name=imu_accel_z,json=imuAccelZ" json:"imu_accel_z,omitempty"` - BmsLeftMotorControllerCurrent *float32 `protobuf:"fixed32,168,opt,name=bms_left_motor_controller_current,json=bmsLeftMotorControllerCurrent" json:"bms_left_motor_controller_current,omitempty"` - BmsRightMotorControllerCurrent *float32 `protobuf:"fixed32,169,opt,name=bms_right_motor_controller_current,json=bmsRightMotorControllerCurrent" json:"bms_right_motor_controller_current,omitempty"` - BmsMotorControllerCurrentSum *float32 `protobuf:"fixed32,170,opt,name=bms_motor_controller_current_sum,json=bmsMotorControllerCurrentSum" json:"bms_motor_controller_current_sum,omitempty"` - PacketsPerSec *float32 `protobuf:"fixed32,171,opt,name=packets_per_sec,json=packetsPerSec" json:"packets_per_sec,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *SundaeDataMessage) Reset() { *m = SundaeDataMessage{} } -func (m *SundaeDataMessage) String() string { return proto.CompactTextString(m) } -func (*SundaeDataMessage) ProtoMessage() {} -func (*SundaeDataMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } - -func (m *SundaeDataMessage) GetRegenEnabled() uint32 { - if m != nil && m.RegenEnabled != nil { - return *m.RegenEnabled - } - return 0 -} - -func (m *SundaeDataMessage) GetRegenCommand() uint32 { - if m != nil && m.RegenCommand != nil { - return *m.RegenCommand - } - return 0 -} - -func (m *SundaeDataMessage) GetBatteryPower() uint32 { - if m != nil && m.BatteryPower != nil { - return *m.BatteryPower - } - return 0 -} - -func (m *SundaeDataMessage) GetArrayPower() float32 { - if m != nil && m.ArrayPower != nil { - return *m.ArrayPower - } - return 0 -} - -func (m *SundaeDataMessage) GetReverseOn() uint32 { - if m != nil && m.ReverseOn != nil { - return *m.ReverseOn - } - return 0 -} - -func (m *SundaeDataMessage) GetLowVoltPower() float32 { - if m != nil && m.LowVoltPower != nil { - return *m.LowVoltPower - } - return 0 -} - -func (m *SundaeDataMessage) GetCellReadError() int32 { - if m != nil && m.CellReadError != nil { - return *m.CellReadError - } - return 0 -} - -func (m *SundaeDataMessage) GetCellBleed() uint32 { - if m != nil && m.CellBleed != nil { - return *m.CellBleed - } - return 0 -} - -func (m *SundaeDataMessage) GetCruiseSpeed() float32 { - if m != nil && m.CruiseSpeed != nil { - return *m.CruiseSpeed - } - return 0 -} - -func (m *SundaeDataMessage) GetHazardLightsOn() int32 { - if m != nil && m.HazardLightsOn != nil { - return *m.HazardLightsOn - } - return 0 -} - -func (m *SundaeDataMessage) GetBatteryVoltage() float32 { - if m != nil && m.BatteryVoltage != nil { - return *m.BatteryVoltage - } - return 0 -} - -func (m *SundaeDataMessage) GetLtc6804Badpec() uint32 { - if m != nil && m.Ltc6804Badpec != nil { - return *m.Ltc6804Badpec - } - return 0 -} - -func (m *SundaeDataMessage) GetBmsState() uint32 { - if m != nil && m.BmsState != nil { - return *m.BmsState - } - return 0 -} - -func (m *SundaeDataMessage) GetChargeEnabled() int32 { - if m != nil && m.ChargeEnabled != nil { - return *m.ChargeEnabled - } - return 0 -} - -func (m *SundaeDataMessage) GetDischargeEnabled() int32 { - if m != nil && m.DischargeEnabled != nil { - return *m.DischargeEnabled - } - return 0 -} - -func (m *SundaeDataMessage) GetHighsideContactorOn() int32 { - if m != nil && m.HighsideContactorOn != nil { - return *m.HighsideContactorOn - } - return 0 -} - -func (m *SundaeDataMessage) GetLowsideContactorOn() int32 { - if m != nil && m.LowsideContactorOn != nil { - return *m.LowsideContactorOn - } - return 0 -} - -func (m *SundaeDataMessage) GetPrechargeOn() int32 { - if m != nil && m.PrechargeOn != nil { - return *m.PrechargeOn - } - return 0 -} - -func (m *SundaeDataMessage) GetLowVoltBusOn() int32 { - if m != nil && m.LowVoltBusOn != nil { - return *m.LowVoltBusOn - } - return 0 -} - -func (m *SundaeDataMessage) GetBatteryTemp_1() float32 { - if m != nil && m.BatteryTemp_1 != nil { - return *m.BatteryTemp_1 - } - return 0 -} - -func (m *SundaeDataMessage) GetBatteryTemp_2() float32 { - if m != nil && m.BatteryTemp_2 != nil { - return *m.BatteryTemp_2 - } - return 0 -} - -func (m *SundaeDataMessage) GetBatteryTemp_3() float32 { - if m != nil && m.BatteryTemp_3 != nil { - return *m.BatteryTemp_3 - } - return 0 -} - -func (m *SundaeDataMessage) GetBatteryTemp_4() float32 { - if m != nil && m.BatteryTemp_4 != nil { - return *m.BatteryTemp_4 - } - return 0 -} - -func (m *SundaeDataMessage) GetBatteryTemp_5() float32 { - if m != nil && m.BatteryTemp_5 != nil { - return *m.BatteryTemp_5 - } - return 0 -} - -func (m *SundaeDataMessage) GetBatteryTemp_6() float32 { - if m != nil && m.BatteryTemp_6 != nil { - return *m.BatteryTemp_6 - } - return 0 -} - -func (m *SundaeDataMessage) GetBmsPrechargeBatteryAdc() float32 { - if m != nil && m.BmsPrechargeBatteryAdc != nil { - return *m.BmsPrechargeBatteryAdc - } - return 0 -} - -func (m *SundaeDataMessage) GetBmsPrechargeCarAdc() float32 { - if m != nil && m.BmsPrechargeCarAdc != nil { - return *m.BmsPrechargeCarAdc - } - return 0 -} - -func (m *SundaeDataMessage) GetLowVoltOutputCurrent() float32 { - if m != nil && m.LowVoltOutputCurrent != nil { - return *m.LowVoltOutputCurrent - } - return 0 -} - -func (m *SundaeDataMessage) GetArrayCurrent() float32 { - if m != nil && m.ArrayCurrent != nil { - return *m.ArrayCurrent - } - return 0 -} - -func (m *SundaeDataMessage) GetBatteryCurrent() float32 { - if m != nil && m.BatteryCurrent != nil { - return *m.BatteryCurrent - } - return 0 -} - -func (m *SundaeDataMessage) GetLeftMotorControllerPower() float32 { - if m != nil && m.LeftMotorControllerPower != nil { - return *m.LeftMotorControllerPower - } - return 0 -} - -func (m *SundaeDataMessage) GetRightMotorControllerPower() float32 { - if m != nil && m.RightMotorControllerPower != nil { - return *m.RightMotorControllerPower - } - return 0 -} - -func (m *SundaeDataMessage) GetAmpHours() float32 { - if m != nil && m.AmpHours != nil { - return *m.AmpHours - } - return 0 -} - -func (m *SundaeDataMessage) GetHeadLightsOn() int32 { - if m != nil && m.HeadLightsOn != nil { - return *m.HeadLightsOn - } - return 0 -} - -func (m *SundaeDataMessage) GetBrakeLightsOn() int32 { - if m != nil && m.BrakeLightsOn != nil { - return *m.BrakeLightsOn - } - return 0 -} - -func (m *SundaeDataMessage) GetRightBlinkerOn() int32 { - if m != nil && m.RightBlinkerOn != nil { - return *m.RightBlinkerOn - } - return 0 -} - -func (m *SundaeDataMessage) GetLeftBlinkerOn() int32 { - if m != nil && m.LeftBlinkerOn != nil { - return *m.LeftBlinkerOn - } - return 0 -} - -func (m *SundaeDataMessage) GetBrakePressed() int32 { - if m != nil && m.BrakePressed != nil { - return *m.BrakePressed - } - return 0 -} - -func (m *SundaeDataMessage) GetThrottlePressed() int32 { - if m != nil && m.ThrottlePressed != nil { - return *m.ThrottlePressed - } - return 0 -} - -func (m *SundaeDataMessage) GetDriveMode() uint32 { - if m != nil && m.DriveMode != nil { - return *m.DriveMode - } - return 0 -} - -func (m *SundaeDataMessage) GetMotorControllerEnabled() int32 { - if m != nil && m.MotorControllerEnabled != nil { - return *m.MotorControllerEnabled - } - return 0 -} - -func (m *SundaeDataMessage) GetMotorControllerSpeed() float32 { - if m != nil && m.MotorControllerSpeed != nil { - return *m.MotorControllerSpeed - } - return 0 -} - -func (m *SundaeDataMessage) GetMotorControllerRpm() float32 { - if m != nil && m.MotorControllerRpm != nil { - return *m.MotorControllerRpm - } - return 0 -} - -func (m *SundaeDataMessage) GetAvgOdometer() float32 { - if m != nil && m.AvgOdometer != nil { - return *m.AvgOdometer - } - return 0 -} - -func (m *SundaeDataMessage) GetLeftMotorTemp() float32 { - if m != nil && m.LeftMotorTemp != nil { - return *m.LeftMotorTemp - } - return 0 -} - -func (m *SundaeDataMessage) GetRightMotorTemp() float32 { - if m != nil && m.RightMotorTemp != nil { - return *m.RightMotorTemp - } - return 0 -} - -func (m *SundaeDataMessage) GetLeftMotorControllerTemp() float32 { - if m != nil && m.LeftMotorControllerTemp != nil { - return *m.LeftMotorControllerTemp - } - return 0 -} - -func (m *SundaeDataMessage) GetRightMotorControllerTemp() float32 { - if m != nil && m.RightMotorControllerTemp != nil { - return *m.RightMotorControllerTemp - } - return 0 -} - -func (m *SundaeDataMessage) GetLeftMotorControllerAlive() float32 { - if m != nil && m.LeftMotorControllerAlive != nil { - return *m.LeftMotorControllerAlive - } - return 0 -} - -func (m *SundaeDataMessage) GetRightMotorControllerAlive() float32 { - if m != nil && m.RightMotorControllerAlive != nil { - return *m.RightMotorControllerAlive - } - return 0 -} - -func (m *SundaeDataMessage) GetLeftMotorControllerCurrent() float32 { - if m != nil && m.LeftMotorControllerCurrent != nil { - return *m.LeftMotorControllerCurrent - } - return 0 -} - -func (m *SundaeDataMessage) GetRightMotorControllerCurrent() float32 { - if m != nil && m.RightMotorControllerCurrent != nil { - return *m.RightMotorControllerCurrent - } - return 0 -} - -func (m *SundaeDataMessage) GetMotorControllerCurrentDiff() float32 { - if m != nil && m.MotorControllerCurrentDiff != nil { - return *m.MotorControllerCurrentDiff - } - return 0 -} - -func (m *SundaeDataMessage) GetLeftMotorControllerError() uint32 { - if m != nil && m.LeftMotorControllerError != nil { - return *m.LeftMotorControllerError - } - return 0 -} - -func (m *SundaeDataMessage) GetRightMotorControllerError() uint32 { - if m != nil && m.RightMotorControllerError != nil { - return *m.RightMotorControllerError - } - return 0 -} - -func (m *SundaeDataMessage) GetLeftMotorControllerLimit() uint32 { - if m != nil && m.LeftMotorControllerLimit != nil { - return *m.LeftMotorControllerLimit - } - return 0 -} - -func (m *SundaeDataMessage) GetRightMotorControllerLimit() uint32 { - if m != nil && m.RightMotorControllerLimit != nil { - return *m.RightMotorControllerLimit - } - return 0 -} - -func (m *SundaeDataMessage) GetLeftMotorControllerRxErrorCount() uint32 { - if m != nil && m.LeftMotorControllerRxErrorCount != nil { - return *m.LeftMotorControllerRxErrorCount - } - return 0 -} - -func (m *SundaeDataMessage) GetRightMotorControllerRxErrorCount() uint32 { - if m != nil && m.RightMotorControllerRxErrorCount != nil { - return *m.RightMotorControllerRxErrorCount - } - return 0 -} - -func (m *SundaeDataMessage) GetLeftMotorControllerTxErrorCount() uint32 { - if m != nil && m.LeftMotorControllerTxErrorCount != nil { - return *m.LeftMotorControllerTxErrorCount - } - return 0 -} - -func (m *SundaeDataMessage) GetRightMotorControllerTxErrorCount() uint32 { - if m != nil && m.RightMotorControllerTxErrorCount != nil { - return *m.RightMotorControllerTxErrorCount - } - return 0 -} - -func (m *SundaeDataMessage) GetLeftMotorControllerBusVoltage() float32 { - if m != nil && m.LeftMotorControllerBusVoltage != nil { - return *m.LeftMotorControllerBusVoltage - } - return 0 -} - -func (m *SundaeDataMessage) GetRightMotorControllerBusVoltage() float32 { - if m != nil && m.RightMotorControllerBusVoltage != nil { - return *m.RightMotorControllerBusVoltage - } - return 0 -} - -func (m *SundaeDataMessage) GetLeftMotorController_15VVoltage() float32 { - if m != nil && m.LeftMotorController_15VVoltage != nil { - return *m.LeftMotorController_15VVoltage - } - return 0 -} - -func (m *SundaeDataMessage) GetRightMotorController_15VVoltage() float32 { - if m != nil && m.RightMotorController_15VVoltage != nil { - return *m.RightMotorController_15VVoltage - } - return 0 -} - -func (m *SundaeDataMessage) GetLeftMotorController_3V3Voltage() float32 { - if m != nil && m.LeftMotorController_3V3Voltage != nil { - return *m.LeftMotorController_3V3Voltage - } - return 0 -} - -func (m *SundaeDataMessage) GetRightMotorController_3V3Voltage() float32 { - if m != nil && m.RightMotorController_3V3Voltage != nil { - return *m.RightMotorController_3V3Voltage - } - return 0 -} - -func (m *SundaeDataMessage) GetLeftMotorController_1V9Voltage() float32 { - if m != nil && m.LeftMotorController_1V9Voltage != nil { - return *m.LeftMotorController_1V9Voltage - } - return 0 -} - -func (m *SundaeDataMessage) GetRightMotorController_1V9Voltage() float32 { - if m != nil && m.RightMotorController_1V9Voltage != nil { - return *m.RightMotorController_1V9Voltage - } - return 0 -} - -func (m *SundaeDataMessage) GetLeftMotorControllerDspTemp() float32 { - if m != nil && m.LeftMotorControllerDspTemp != nil { - return *m.LeftMotorControllerDspTemp - } - return 0 -} - -func (m *SundaeDataMessage) GetRightMotorControllerDspTemp() float32 { - if m != nil && m.RightMotorControllerDspTemp != nil { - return *m.RightMotorControllerDspTemp - } - return 0 -} - -func (m *SundaeDataMessage) GetLeftMotorControllerPhaseCurrent() float32 { - if m != nil && m.LeftMotorControllerPhaseCurrent != nil { - return *m.LeftMotorControllerPhaseCurrent - } - return 0 -} - -func (m *SundaeDataMessage) GetRightMotorControllerPhaseCurrent() float32 { - if m != nil && m.RightMotorControllerPhaseCurrent != nil { - return *m.RightMotorControllerPhaseCurrent - } - return 0 -} - -func (m *SundaeDataMessage) GetLeftMotorRpmCommand() float32 { - if m != nil && m.LeftMotorRpmCommand != nil { - return *m.LeftMotorRpmCommand - } - return 0 -} - -func (m *SundaeDataMessage) GetRightMotorRpmCommand() float32 { - if m != nil && m.RightMotorRpmCommand != nil { - return *m.RightMotorRpmCommand - } - return 0 -} - -func (m *SundaeDataMessage) GetLeftMotorCurrentCommand() float32 { - if m != nil && m.LeftMotorCurrentCommand != nil { - return *m.LeftMotorCurrentCommand - } - return 0 -} - -func (m *SundaeDataMessage) GetRightMotorCurrentCommand() float32 { - if m != nil && m.RightMotorCurrentCommand != nil { - return *m.RightMotorCurrentCommand - } - return 0 -} - -func (m *SundaeDataMessage) GetGpsTime() int64 { - if m != nil && m.GpsTime != nil { - return *m.GpsTime - } - return 0 -} - -func (m *SundaeDataMessage) GetGpsLatitude() float32 { - if m != nil && m.GpsLatitude != nil { - return *m.GpsLatitude - } - return 0 -} - -func (m *SundaeDataMessage) GetGpsLongitude() float32 { - if m != nil && m.GpsLongitude != nil { - return *m.GpsLongitude - } - return 0 -} - -func (m *SundaeDataMessage) GetGpsSpeed() float32 { - if m != nil && m.GpsSpeed != nil { - return *m.GpsSpeed - } - return 0 -} - -func (m *SundaeDataMessage) GetGpsAltitude() float32 { - if m != nil && m.GpsAltitude != nil { - return *m.GpsAltitude - } - return 0 -} - -func (m *SundaeDataMessage) GetGpsBearing() float32 { - if m != nil && m.GpsBearing != nil { - return *m.GpsBearing - } - return 0 -} - -func (m *SundaeDataMessage) GetLedState() int32 { - if m != nil && m.LedState != nil { - return *m.LedState - } - return 0 -} - -func (m *SundaeDataMessage) GetMpptArrayPower() float32 { - if m != nil && m.MpptArrayPower != nil { - return *m.MpptArrayPower - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_A0VoltIn() float32 { - if m != nil && m.Mppt_A0VoltIn != nil { - return *m.Mppt_A0VoltIn - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_A0VoltOut() float32 { - if m != nil && m.Mppt_A0VoltOut != nil { - return *m.Mppt_A0VoltOut - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_A0Current() float32 { - if m != nil && m.Mppt_A0Current != nil { - return *m.Mppt_A0Current - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_A0Temp() float32 { - if m != nil && m.Mppt_A0Temp != nil { - return *m.Mppt_A0Temp - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_A1VoltIn() float32 { - if m != nil && m.Mppt_A1VoltIn != nil { - return *m.Mppt_A1VoltIn - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_A1VoltOut() float32 { - if m != nil && m.Mppt_A1VoltOut != nil { - return *m.Mppt_A1VoltOut - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_A1Current() float32 { - if m != nil && m.Mppt_A1Current != nil { - return *m.Mppt_A1Current - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_A1Temp() float32 { - if m != nil && m.Mppt_A1Temp != nil { - return *m.Mppt_A1Temp - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_B0VoltIn() float32 { - if m != nil && m.Mppt_B0VoltIn != nil { - return *m.Mppt_B0VoltIn - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_B0VoltOut() float32 { - if m != nil && m.Mppt_B0VoltOut != nil { - return *m.Mppt_B0VoltOut - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_B0Current() float32 { - if m != nil && m.Mppt_B0Current != nil { - return *m.Mppt_B0Current - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_B0Temp() float32 { - if m != nil && m.Mppt_B0Temp != nil { - return *m.Mppt_B0Temp - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_B1VoltIn() float32 { - if m != nil && m.Mppt_B1VoltIn != nil { - return *m.Mppt_B1VoltIn - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_B1VoltOut() float32 { - if m != nil && m.Mppt_B1VoltOut != nil { - return *m.Mppt_B1VoltOut - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_B1Current() float32 { - if m != nil && m.Mppt_B1Current != nil { - return *m.Mppt_B1Current - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_B1Temp() float32 { - if m != nil && m.Mppt_B1Temp != nil { - return *m.Mppt_B1Temp - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_C0VoltIn() float32 { - if m != nil && m.Mppt_C0VoltIn != nil { - return *m.Mppt_C0VoltIn - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_C0VoltOut() float32 { - if m != nil && m.Mppt_C0VoltOut != nil { - return *m.Mppt_C0VoltOut - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_C0Current() float32 { - if m != nil && m.Mppt_C0Current != nil { - return *m.Mppt_C0Current - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_C0Temp() float32 { - if m != nil && m.Mppt_C0Temp != nil { - return *m.Mppt_C0Temp - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_C1VoltIn() float32 { - if m != nil && m.Mppt_C1VoltIn != nil { - return *m.Mppt_C1VoltIn - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_C1VoltOut() float32 { - if m != nil && m.Mppt_C1VoltOut != nil { - return *m.Mppt_C1VoltOut - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_C1Current() float32 { - if m != nil && m.Mppt_C1Current != nil { - return *m.Mppt_C1Current - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_C1Temp() float32 { - if m != nil && m.Mppt_C1Temp != nil { - return *m.Mppt_C1Temp - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_D0VoltIn() float32 { - if m != nil && m.Mppt_D0VoltIn != nil { - return *m.Mppt_D0VoltIn - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_D0VoltOut() float32 { - if m != nil && m.Mppt_D0VoltOut != nil { - return *m.Mppt_D0VoltOut - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_D0Current() float32 { - if m != nil && m.Mppt_D0Current != nil { - return *m.Mppt_D0Current - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_D0Temp() float32 { - if m != nil && m.Mppt_D0Temp != nil { - return *m.Mppt_D0Temp - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_D1VoltIn() float32 { - if m != nil && m.Mppt_D1VoltIn != nil { - return *m.Mppt_D1VoltIn - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_D1VoltOut() float32 { - if m != nil && m.Mppt_D1VoltOut != nil { - return *m.Mppt_D1VoltOut - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_D1Current() float32 { - if m != nil && m.Mppt_D1Current != nil { - return *m.Mppt_D1Current - } - return 0 -} - -func (m *SundaeDataMessage) GetMppt_D1Temp() float32 { - if m != nil && m.Mppt_D1Temp != nil { - return *m.Mppt_D1Temp - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_1() float32 { - if m != nil && m.CellVolt_1 != nil { - return *m.CellVolt_1 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_2() float32 { - if m != nil && m.CellVolt_2 != nil { - return *m.CellVolt_2 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_3() float32 { - if m != nil && m.CellVolt_3 != nil { - return *m.CellVolt_3 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_4() float32 { - if m != nil && m.CellVolt_4 != nil { - return *m.CellVolt_4 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_5() float32 { - if m != nil && m.CellVolt_5 != nil { - return *m.CellVolt_5 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_6() float32 { - if m != nil && m.CellVolt_6 != nil { - return *m.CellVolt_6 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_7() float32 { - if m != nil && m.CellVolt_7 != nil { - return *m.CellVolt_7 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_8() float32 { - if m != nil && m.CellVolt_8 != nil { - return *m.CellVolt_8 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_9() float32 { - if m != nil && m.CellVolt_9 != nil { - return *m.CellVolt_9 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_10() float32 { - if m != nil && m.CellVolt_10 != nil { - return *m.CellVolt_10 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_11() float32 { - if m != nil && m.CellVolt_11 != nil { - return *m.CellVolt_11 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_12() float32 { - if m != nil && m.CellVolt_12 != nil { - return *m.CellVolt_12 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_13() float32 { - if m != nil && m.CellVolt_13 != nil { - return *m.CellVolt_13 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_14() float32 { - if m != nil && m.CellVolt_14 != nil { - return *m.CellVolt_14 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_15() float32 { - if m != nil && m.CellVolt_15 != nil { - return *m.CellVolt_15 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_16() float32 { - if m != nil && m.CellVolt_16 != nil { - return *m.CellVolt_16 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_17() float32 { - if m != nil && m.CellVolt_17 != nil { - return *m.CellVolt_17 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_18() float32 { - if m != nil && m.CellVolt_18 != nil { - return *m.CellVolt_18 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_19() float32 { - if m != nil && m.CellVolt_19 != nil { - return *m.CellVolt_19 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_20() float32 { - if m != nil && m.CellVolt_20 != nil { - return *m.CellVolt_20 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_21() float32 { - if m != nil && m.CellVolt_21 != nil { - return *m.CellVolt_21 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_22() float32 { - if m != nil && m.CellVolt_22 != nil { - return *m.CellVolt_22 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_23() float32 { - if m != nil && m.CellVolt_23 != nil { - return *m.CellVolt_23 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_24() float32 { - if m != nil && m.CellVolt_24 != nil { - return *m.CellVolt_24 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_25() float32 { - if m != nil && m.CellVolt_25 != nil { - return *m.CellVolt_25 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_26() float32 { - if m != nil && m.CellVolt_26 != nil { - return *m.CellVolt_26 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_27() float32 { - if m != nil && m.CellVolt_27 != nil { - return *m.CellVolt_27 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_28() float32 { - if m != nil && m.CellVolt_28 != nil { - return *m.CellVolt_28 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_29() float32 { - if m != nil && m.CellVolt_29 != nil { - return *m.CellVolt_29 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_30() float32 { - if m != nil && m.CellVolt_30 != nil { - return *m.CellVolt_30 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVolt_31() float32 { - if m != nil && m.CellVolt_31 != nil { - return *m.CellVolt_31 - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVoltMin() float32 { - if m != nil && m.CellVoltMin != nil { - return *m.CellVoltMin - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVoltMax() float32 { - if m != nil && m.CellVoltMax != nil { - return *m.CellVoltMax - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVoltAvg() float32 { - if m != nil && m.CellVoltAvg != nil { - return *m.CellVoltAvg - } - return 0 -} - -func (m *SundaeDataMessage) GetCellVoltDiff() float32 { - if m != nil && m.CellVoltDiff != nil { - return *m.CellVoltDiff - } - return 0 -} - -func (m *SundaeDataMessage) GetPowerSaveOn() int32 { - if m != nil && m.PowerSaveOn != nil { - return *m.PowerSaveOn - } - return 0 -} - -func (m *SundaeDataMessage) GetRearviewOn() int32 { - if m != nil && m.RearviewOn != nil { - return *m.RearviewOn - } - return 0 -} - -func (m *SundaeDataMessage) GetMicEnabled() int32 { - if m != nil && m.MicEnabled != nil { - return *m.MicEnabled - } - return 0 -} - -func (m *SundaeDataMessage) GetImuTemp() int32 { - if m != nil && m.ImuTemp != nil { - return *m.ImuTemp - } - return 0 -} - -func (m *SundaeDataMessage) GetImuMagnetX() int32 { - if m != nil && m.ImuMagnetX != nil { - return *m.ImuMagnetX - } - return 0 -} - -func (m *SundaeDataMessage) GetImuMagnetY() int32 { - if m != nil && m.ImuMagnetY != nil { - return *m.ImuMagnetY - } - return 0 -} - -func (m *SundaeDataMessage) GetImuMagnetZ() int32 { - if m != nil && m.ImuMagnetZ != nil { - return *m.ImuMagnetZ - } - return 0 -} - -func (m *SundaeDataMessage) GetImuGyroX() int32 { - if m != nil && m.ImuGyroX != nil { - return *m.ImuGyroX - } - return 0 -} - -func (m *SundaeDataMessage) GetImuGyroY() int32 { - if m != nil && m.ImuGyroY != nil { - return *m.ImuGyroY - } - return 0 -} - -func (m *SundaeDataMessage) GetImuGyroZ() int32 { - if m != nil && m.ImuGyroZ != nil { - return *m.ImuGyroZ - } - return 0 -} - -func (m *SundaeDataMessage) GetImuAccelX() int32 { - if m != nil && m.ImuAccelX != nil { - return *m.ImuAccelX - } - return 0 -} - -func (m *SundaeDataMessage) GetImuAccelY() int32 { - if m != nil && m.ImuAccelY != nil { - return *m.ImuAccelY - } - return 0 -} - -func (m *SundaeDataMessage) GetImuAccelZ() int32 { - if m != nil && m.ImuAccelZ != nil { - return *m.ImuAccelZ - } - return 0 -} - -func (m *SundaeDataMessage) GetBmsLeftMotorControllerCurrent() float32 { - if m != nil && m.BmsLeftMotorControllerCurrent != nil { - return *m.BmsLeftMotorControllerCurrent - } - return 0 -} - -func (m *SundaeDataMessage) GetBmsRightMotorControllerCurrent() float32 { - if m != nil && m.BmsRightMotorControllerCurrent != nil { - return *m.BmsRightMotorControllerCurrent - } - return 0 -} - -func (m *SundaeDataMessage) GetBmsMotorControllerCurrentSum() float32 { - if m != nil && m.BmsMotorControllerCurrentSum != nil { - return *m.BmsMotorControllerCurrentSum - } - return 0 -} - -func (m *SundaeDataMessage) GetPacketsPerSec() float32 { - if m != nil && m.PacketsPerSec != nil { - return *m.PacketsPerSec - } - return 0 -} - -func init() { - proto.RegisterType((*SundaeDataMessage)(nil), "SundaeDataMessage") -} - -func init() { proto.RegisterFile("sundae.proto", fileDescriptor0) } - -var fileDescriptor0 = []byte{ - // 2299 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x99, 0x79, 0x5f, 0xdc, 0xc6, - 0x19, 0xc7, 0x3f, 0x24, 0x4d, 0x8d, 0x07, 0x30, 0x58, 0xbe, 0x1e, 0x9b, 0x80, 0xc1, 0x27, 0x69, - 0xda, 0x94, 0xd5, 0xb2, 0x1c, 0x49, 0xdd, 0x94, 0xdd, 0x75, 0x6d, 0x27, 0x10, 0x28, 0xb8, 0xae, - 0xed, 0x1e, 0xea, 0xac, 0x34, 0x08, 0xd5, 0xba, 0x3a, 0x92, 0x16, 0x70, 0xef, 0xfb, 0xbe, 0xef, - 0xfb, 0xbe, 0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0x6d, 0x11, 0x9d, 0x75, 0x83, 0x83, 0x6a, 0xc9, 0x69, 0x5e, 0xa2, 0xa5, 0x39, 0xb9, 0x62, - 0x1e, 0x8d, 0x87, 0x94, 0xa4, 0x92, 0x02, 0x1f, 0x34, 0x4e, 0x8e, 0xe5, 0xb1, 0x2d, 0x5f, 0xbb, - 0x8e, 0x26, 0xf3, 0x39, 0x30, 0x48, 0xb8, 0xe5, 0x67, 0x38, 0x95, 0x4d, 0x82, 0x6e, 0x12, 0x89, - 0xa9, 0x92, 0x19, 0x1e, 0x13, 0x2f, 0x34, 0x5a, 0x70, 0x56, 0x4c, 0x95, 0x34, 0x7a, 0x9f, 0x78, - 0x61, 0xab, 0x42, 0xe9, 0x70, 0xae, 0x42, 0xe9, 0x15, 0xaa, 0x0d, 0xe7, 0x2b, 0x54, 0xbb, 0x42, - 0x2d, 0xc1, 0x85, 0x0a, 0xb5, 0x54, 0xa1, 0x3a, 0x00, 0x15, 0xaa, 0x53, 0xa1, 0x96, 0xe1, 0x62, - 0x85, 0x5a, 0xd6, 0xd6, 0xd0, 0x45, 0x36, 0x09, 0x0a, 0xc7, 0xb2, 0x1a, 0x6c, 0x99, 0x70, 0x89, - 0x17, 0x9c, 0x1f, 0x78, 0xd1, 0x76, 0x96, 0xef, 0x8a, 0xf4, 0xba, 0x65, 0x6a, 0x2d, 0x74, 0xae, - 0x5c, 0x6a, 0x62, 0xca, 0xcb, 0xa6, 0x79, 0x99, 0x26, 0x97, 0xf5, 0x30, 0x65, 0x25, 0x1d, 0x74, - 0x21, 0x37, 0x3e, 0x48, 0xe2, 0x30, 0x89, 0x0d, 0x33, 0xa1, 0x94, 0xf8, 0x31, 0xcc, 0xf0, 0xa2, - 0xb3, 0xe9, 0x0f, 0xb0, 0xc5, 0x93, 0x3d, 0x91, 0x63, 0x1b, 0x83, 0x58, 0xf3, 0x19, 0x3c, 0x2b, - 0x9e, 0x84, 0x07, 0x33, 0x48, 0x5a, 0x1e, 0x19, 0x76, 0x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, 0x56, 0x2f, 0x0e, 0xbc, 0xa8, - 0xbe, 0xcb, 0x6e, 0xe2, 0x69, 0x37, 0xd1, 0x64, 0x88, 0xcd, 0x27, 0x24, 0x8e, 0x8c, 0x90, 0x4d, - 0x4a, 0x62, 0xc2, 0xff, 0x44, 0xdd, 0x44, 0x1a, 0xdf, 0x26, 0x74, 0x97, 0x98, 0x6f, 0x07, 0x00, - 0x00, 0xff, 0xff, 0xbc, 0x95, 0x87, 0x64, 0x53, 0x1d, 0x00, 0x00, -} diff --git a/collector/sundae/sundae.proto b/collector/sundae/sundae.proto deleted file mode 100644 index fd2baed..0000000 --- a/collector/sundae/sundae.proto +++ /dev/null @@ -1,173 +0,0 @@ -syntax="proto2"; -message SundaeDataMessage { //1512 bytes constraint - optional uint32 regen_enabled = 1; - optional uint32 regen_command = 2; - optional uint32 battery_power = 3; - optional float array_power = 4; - optional uint32 reverse_on = 5; - optional float low_volt_power = 6; - optional int32 cell_read_error = 7; - optional uint32 cell_bleed = 8; - optional float cruise_speed = 9; - optional int32 hazard_lights_on = 10; - optional float battery_voltage = 11; - optional uint32 ltc6804_badpec = 12; - optional uint32 bms_state = 13; - optional int32 charge_enabled = 14; - optional int32 discharge_enabled = 15; - optional int32 highside_contactor_on = 16; - optional int32 lowside_contactor_on = 17; - optional int32 precharge_on = 18; - optional int32 low_volt_bus_on = 19; - optional float battery_temp_1 = 20; - optional float battery_temp_2 = 21; - optional float battery_temp_3 = 22; - optional float battery_temp_4 = 23; - optional float battery_temp_5 = 24; - optional float battery_temp_6 = 25; - optional float bms_precharge_battery_adc = 26; - optional float bms_precharge_car_adc = 27; - //gap - optional float low_volt_output_current = 29; - optional float array_current = 30; - optional float battery_current = 31; - optional float left_motor_controller_power = 32; - optional float right_motor_controller_power = 33; - optional float amp_hours = 34; - optional int32 head_lights_on = 35; - optional int32 brake_lights_on = 36; - optional int32 right_blinker_on = 37; - optional int32 left_blinker_on = 38; - optional int32 brake_pressed = 39; - optional int32 throttle_pressed = 40; - optional uint32 drive_mode = 41; - optional int32 motor_controller_enabled = 42; - optional float motor_controller_speed = 43; - optional float motor_controller_rpm = 44; - optional float avg_odometer = 45; //??? - optional float left_motor_temp = 46; - optional float right_motor_temp = 47; - optional float left_motor_controller_temp = 48; - optional float right_motor_controller_temp = 49; - optional float left_motor_controller_alive = 50; - optional float right_motor_controller_alive = 51; - optional float left_motor_controller_current = 52; - optional float right_motor_controller_current = 53; - optional float motor_controller_current_diff = 54; - optional uint32 left_motor_controller_error = 55; - optional uint32 right_motor_controller_error = 56; - optional uint32 left_motor_controller_limit = 57; - optional uint32 right_motor_controller_limit = 58; - optional uint32 left_motor_controller_rx_error_count = 59; - optional uint32 right_motor_controller_rx_error_count = 60; - optional uint32 left_motor_controller_tx_error_count = 61; - optional uint32 right_motor_controller_tx_error_count = 62; - optional float left_motor_controller_bus_voltage = 63; - optional float right_motor_controller_bus_voltage = 64; - optional float left_motor_controller_15v_voltage = 65; - optional float right_motor_controller_15v_voltage = 66; - optional float left_motor_controller_3v3_voltage = 67; - optional float right_motor_controller_3v3_voltage = 68; - optional float left_motor_controller_1v9_voltage = 69; - optional float right_motor_controller_1v9_voltage = 70; - optional float left_motor_controller_dsp_temp = 71; - optional float right_motor_controller_dsp_temp = 72; - optional float left_motor_controller_phase_current = 73; - optional float right_motor_controller_phase_current = 74; - optional float left_motor_rpm_command = 75; - optional float right_motor_rpm_command = 76; - optional float left_motor_current_command = 77; - optional float right_motor_current_command = 78; - optional int64 gps_time = 80; - optional float gps_latitude = 81; - optional float gps_longitude = 82; - optional float gps_speed = 83; - optional float gps_altitude = 84; - optional float gps_bearing = 85; - optional int32 led_state = 86; - optional float mppt_array_power = 87; - optional float mppt_A0_volt_in = 88; - optional float mppt_A0_volt_out = 89; - optional float mppt_A0_current = 90; - optional float mppt_A0_temp = 91; - optional float mppt_A1_volt_in = 92; - optional float mppt_A1_volt_out = 93; - optional float mppt_A1_current = 94; - optional float mppt_A1_temp = 95; - optional float mppt_B0_volt_in = 96; - optional float mppt_B0_volt_out = 97; - optional float mppt_B0_current = 98; - optional float mppt_B0_temp = 99; - optional float mppt_B1_volt_in = 100; - optional float mppt_B1_volt_out = 101; - optional float mppt_B1_current = 102; - optional float mppt_B1_temp = 103; - optional float mppt_C0_volt_in = 104; - optional float mppt_C0_volt_out = 105; - optional float mppt_C0_current = 106; - optional float mppt_C0_temp = 107; - optional float mppt_C1_volt_in = 108; - optional float mppt_C1_volt_out = 109; - optional float mppt_C1_current = 110; - optional float mppt_C1_temp = 111; - optional float mppt_D0_volt_in = 112; - optional float mppt_D0_volt_out = 113; - optional float mppt_D0_current = 114; - optional float mppt_D0_temp = 115; - optional float mppt_D1_volt_in = 116; - optional float mppt_D1_volt_out = 117; - optional float mppt_D1_current = 118; - optional float mppt_D1_temp = 119; - optional float cell_volt_1 = 120; - optional float cell_volt_2 = 121; - optional float cell_volt_3 = 122; - optional float cell_volt_4 = 123; - optional float cell_volt_5 = 124; - optional float cell_volt_6 = 125; - optional float cell_volt_7 = 126; - optional float cell_volt_8 = 127; - optional float cell_volt_9 = 128; - optional float cell_volt_10 = 129; - optional float cell_volt_11 = 130; - optional float cell_volt_12 = 131; - optional float cell_volt_13 = 132; - optional float cell_volt_14 = 133; - optional float cell_volt_15 = 134; - optional float cell_volt_16 = 135; - optional float cell_volt_17 = 136; - optional float cell_volt_18 = 137; - optional float cell_volt_19 = 138; - optional float cell_volt_20 = 139; - optional float cell_volt_21 = 140; - optional float cell_volt_22 = 141; - optional float cell_volt_23 = 142; - optional float cell_volt_24 = 143; - optional float cell_volt_25 = 144; - optional float cell_volt_26 = 145; - optional float cell_volt_27 = 146; - optional float cell_volt_28 = 147; - optional float cell_volt_29 = 148; - optional float cell_volt_30 = 149; - optional float cell_volt_31 = 150; - optional float cell_volt_min = 151; - optional float cell_volt_max = 152; - optional float cell_volt_avg = 153; //not in use - optional float cell_volt_diff = 154; - optional int32 power_save_on = 155; - optional int32 rearview_on = 156; - optional int32 mic_enabled = 157; - optional int32 imu_temp = 158; - optional int32 imu_magnet_x = 159; - optional int32 imu_magnet_y = 160; - optional int32 imu_magnet_z = 161; - optional int32 imu_gyro_x = 162; - optional int32 imu_gyro_y = 163; - optional int32 imu_gyro_z = 164; - optional int32 imu_accel_x = 165; - optional int32 imu_accel_y = 166; - optional int32 imu_accel_z = 167; - optional float bms_left_motor_controller_current = 168; - optional float bms_right_motor_controller_current = 169; - optional float bms_motor_controller_current_sum = 170; - optional float packets_per_sec = 171; -} diff --git a/collector/sundae/verify_test.go b/collector/sundae/verify_test.go deleted file mode 100644 index 184c4c3..0000000 --- a/collector/sundae/verify_test.go +++ /dev/null @@ -1,44 +0,0 @@ -package sundae - -import ( - "context" - "math" - "testing" -) - -type verifyFloat32Test struct { - inVal *float32 - outVal *float32 -} - -func (test verifyFloat32Test) runTest(t *testing.T) { - ctx := context.Background() - output := verifyFloat32(ctx, test.inVal, "testValue") - if test.outVal != output { - t.Errorf("error: verifyFloat32(%v) != %v (should be %v)", - test.inVal, output, test.outVal) - } -} - -var positiveinf = float32(math.Inf(1)) -var negativeinf = float32(math.Inf(-1)) -var nan = float32(math.NaN()) -var zero = float32(0.0) -var posnum = float32(10) -var negnum = float32(-10) - -var float32Tests = []verifyFloat32Test{ - verifyFloat32Test{inVal: &posnum, outVal: &posnum}, - verifyFloat32Test{inVal: &negnum, outVal: &negnum}, - verifyFloat32Test{inVal: &zero, outVal: &zero}, - - verifyFloat32Test{inVal: &positiveinf, outVal: nil}, - verifyFloat32Test{inVal: &negativeinf, outVal: nil}, - verifyFloat32Test{inVal: &nan, outVal: nil}, -} - -func TestVerifyFloat32(t *testing.T) { - for _, test := range float32Tests { - test.runTest(t) - } -} diff --git a/docker-compose.yml b/docker-compose.yml index 7079f30..31895d2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,31 +26,13 @@ services: image: quay.io/influxdb/chronograf:1.4.1.3 volumes: # Mount for chronograf database - - ./sandbox/chronograf/data/:/var/lib/chronograf/ + - ./chronograf_data/:/var/lib/chronograf/ links: # Chronograf requires network access to InfluxDB and Kapacitor - influxdb - - kapacitor ports: # The WebUI for Chronograf is served on port 8888 - "8888:8888" - depends_on: - - kapacitor - - influxdb - - telegraf - telegraf: - # Full tag list: https://hub.docker.com/r/library/telegraf/tags/ - image: telegraf:1.5.2 - environment: - HOSTNAME: "telegraf-getting-started" - # Telegraf requires network access to InfluxDB - links: - - influxdb - volumes: - # Mount for telegraf configuration - - ./sandbox/telegraf/:/etc/telegraf/ - # Mount for Docker API access - - /var/run/docker.sock:/var/run/docker.sock depends_on: - influxdb influxdb: @@ -58,31 +40,12 @@ services: image: influxdb:1.4.3 volumes: # Mount for influxdb data directory - - ./sandbox/influxdb/data:/var/lib/influxdb + - ./influxdb_data:/var/lib/influxdb # Mount for influxdb configuration - - ./sandbox/influxdb/config/:/etc/influxdb/ + - ./influxdb_config/:/etc/influxdb/ ports: # The API for InfluxDB is served on port 8086 - "8086:8086" - kapacitor: - # Full tag list: https://hub.docker.com/r/library/kapacitor/tags/ - image: kapacitor:1.4.0 - volumes: - # Mount for kapacitor data directory - - ./sandbox/kapacitor/data/:/var/lib/kapacitor - # Mount for kapacitor configuration - - ./sandbox/kapacitor/config/:/etc/kapacitor/ - # Kapacitor requires network access to Influxdb - links: - - influxdb - ports: - # The API for Kapacitor is served on port 9092 - - "9092:9092" - documentation: - build: - context: ./sandbox/documentation - ports: - - "3010:3000" # ========================== jaegertracing ========================== # Docs here: http://jaeger.readthedocs.io/en/latest/getting_started/ jaeger: diff --git a/events/event.go b/events/event.go new file mode 100644 index 0000000..449a020 --- /dev/null +++ b/events/event.go @@ -0,0 +1,45 @@ +package events + +import ( + "context" + "time" +) + +type EventMeta struct { + CollectedTimeNanos int64 +} + +func (e EventMeta) GetCollectedTime() time.Time { + return time.Unix(0, e.CollectedTimeNanos) +} + +type DataEvent struct { + EventMeta + Data map[string]interface{} +} + +// ContextDataEvent adds context to a RawEvent to hold request-scopped info +type ContextDataEvent struct { + context.Context + DataEvent +} + +// ContextRawEvent adds context to a RawEvent to hold request-scopped info +type ContextRawEvent struct { + context.Context + RawEvent +} + +type RawEvent struct { + EventMeta + Data []byte +} + +func NewRawEventNow(packet []byte) RawEvent { + return RawEvent{ + EventMeta: EventMeta{ + CollectedTimeNanos: time.Now().UnixNano(), + }, + Data: packet, + } +} diff --git a/collector/handlers/blog_handler.go b/handlers/blog_handler.go similarity index 81% rename from collector/handlers/blog_handler.go rename to handlers/blog_handler.go index a6c6f86..0e60204 100644 --- a/collector/handlers/blog_handler.go +++ b/handlers/blog_handler.go @@ -9,6 +9,7 @@ import ( "time" "github.com/sscp/telemetry/blog" + "github.com/sscp/telemetry/events" "github.com/sscp/telemetry/log" "github.com/opentracing/opentracing-go" @@ -64,27 +65,29 @@ func (bw *BlogWriter) createFile(ctx context.Context, runName string, startTime } } -// HandlePacket is called when collector passes off a packet to BlogWriter and +// HandleRawEvent is called when collector passes off a packet to BlogWriter and // simply writes the packet the blogWriter -func (bw *BlogWriter) HandlePacket(ctx context.Context, packet []byte) { - span, ctx := opentracing.StartSpanFromContext(ctx, "BlogWriter/HandleData") +func (bw *BlogWriter) HandleRawEvent(ctx context.Context, rawEvent events.RawEvent) { + span, _ := opentracing.StartSpanFromContext(ctx, "BlogWriter/HandleData") defer span.Finish() - bw.blogWriter.Write(packet) + _, err := bw.blogWriter.Write(rawEvent.Data) + if err != nil { + log.Error(ctx, err, "could not write to blog") + } } // HandleDroppedPacket is called when BlogWriter falls behind and cannot // process an incomming packet, it currently does nothing func (bw *BlogWriter) HandleDroppedPacket(ctx context.Context) { - span, ctx := opentracing.StartSpanFromContext(ctx, "BlogWriter/HandleDroppedPacket") + span, _ := opentracing.StartSpanFromContext(ctx, "BlogWriter/HandleDroppedPacket") defer span.Finish() - } // HandleEndRun flushes the buffers and closes the file and is called when the // collector stops recording packets and BlogWriter has cleared its input // channel of packets. func (bw *BlogWriter) HandleEndRun(ctx context.Context, endTime time.Time) { - span, ctx := opentracing.StartSpanFromContext(ctx, "BlogWriter/HandleEndRun") + span, _ := opentracing.StartSpanFromContext(ctx, "BlogWriter/HandleEndRun") defer span.Finish() bw.buffer.Flush() bw.file.Close() diff --git a/collector/handlers/blog_handler_test.go b/handlers/blog_handler_test.go similarity index 53% rename from collector/handlers/blog_handler_test.go rename to handlers/blog_handler_test.go index 26c381c..a18ce52 100644 --- a/collector/handlers/blog_handler_test.go +++ b/handlers/blog_handler_test.go @@ -2,13 +2,14 @@ package handlers import ( "context" + "crypto/rand" "os" "testing" "time" - "github.com/sscp/telemetry/collector/sources" + "github.com/stretchr/testify/assert" - "github.com/golang/protobuf/proto" + "github.com/sscp/telemetry/events" ) func BenchmarkBlogWriter(b *testing.B) { @@ -21,13 +22,19 @@ func BenchmarkBlogWriter(b *testing.B) { ctx := context.TODO() bw.HandleStartRun(ctx, runName, runStart) defer bw.HandleEndRun(ctx, time.Now()) - defer os.Remove(GetCSVFileName(runName, runStart)) - zdm := sources.CreateZeroDataMessage() - packet, _ := proto.Marshal(zdm) + defer os.Remove(GetBlogFileName(runName, runStart)) + + testPackets := make([][]byte, b.N) + for i := 0; i < b.N; i++ { + // Make a random packet + testPackets[i] = make([]byte, 1500) + _, err := rand.Read(testPackets[i]) + assert.NoError(b, err) + } b.ResetTimer() // run b.N times for n := 0; n < b.N; n++ { - bw.HandlePacket(ctx, packet) + bw.HandleRawEvent(ctx, events.NewRawEventNow(testPackets[n])) } b.StopTimer() } diff --git a/collector/handlers/csv_handler.go b/handlers/csv_handler.go.old similarity index 78% rename from collector/handlers/csv_handler.go rename to handlers/csv_handler.go.old index 8aa56ae..9d26fa4 100644 --- a/collector/handlers/csv_handler.go +++ b/handlers/csv_handler.go.old @@ -3,15 +3,14 @@ package handlers import ( "bufio" "context" + "encoding/csv" "fmt" "os" "path/filepath" "time" - internalproto "github.com/sscp/telemetry/collector/internalproto" "github.com/sscp/telemetry/log" - "github.com/gocarina/gocsv" "github.com/opentracing/opentracing-go" ) @@ -30,8 +29,9 @@ type CSVWriter struct { folderPath string file *os.File buffer *bufio.Writer - csvWrite *gocsv.SafeCSVWriter - dmBuffer *DataMessageBuffer + csvWrite *csv.Writer + dmBuffer *DataEventBuffer + keyToIndex map[string]interface{} } // dataBufferSize is the default size of the queues that lead to each handler @@ -71,29 +71,36 @@ func (cw *CSVWriter) createFile(ctx context.Context, runName string, startTime t // simply append rows of data without headers. func (cw *CSVWriter) setupWriter() { cw.buffer = bufio.NewWriter(cw.file) - cw.csvWrite = gocsv.DefaultCSVWriter(cw.buffer) - cw.dmBuffer = NewDataMessageBuffer(cw.writeData, 10) - // Write only the headers because all future data will be written - // without headers - empData := []*internalproto.DataMessage{} - gocsv.MarshalCSV(&empData, cw.csvWrite) + cw.csvWrite = csv.NewWriter(cw.buffer) + cw.dmBuffer = NewDataEventBuffer(cw.writeData, 10) } // flushDataBuffer writes all the data in the DataMessage buffer to the // buffered writer -func (cw *CSVWriter) writeData(ctx context.Context, data []*internalproto.DataMessage) { - // Write all data up until the current index. We can't write all the - // data because there might be already written *DataMessages beyond the - // current index - gocsv.MarshalCSVWithoutHeaders(data, cw.csvWrite) +func (cw *CSVWriter) writeData(ctx context.Context, data []map[string]interface{}) { + if len(data) > 0 && (cw.keys == nil || len(cw.keys) == 0) { + cw.keyToIndex = make(map[string]int, len(data[0])) + } + for _, dataMap := range data { + csvLine := make([]string, len(dataMap)) + for key, value := range dataMap { + index, ok := cw.keyToIndex[key] + if !ok { + cw.keyToIndex[key] = len(cw.keyToIndex) + } + csvLine[index] = value.String() + } + cw.csvWrite.Marshall(csvLine) + } } // HandleData is called on every new DataMessage from the collector and adds // the new DataMessage to the buffer of DataMessages and flushes the buffer if // it is full -func (cw *CSVWriter) HandleData(ctx context.Context, data *internalproto.DataMessage) { +func (cw *CSVWriter) HandleData(ctx context.Context, data map[string]interface{}) { span, ctx := opentracing.StartSpanFromContext(ctx, "CSVWriter/HandleData") defer span.Finish() + cw.dmBuffer.AddData(ctx, data) } @@ -111,5 +118,12 @@ func (cw *CSVWriter) HandleDroppedData(ctx context.Context) { func (cw *CSVWriter) HandleEndRun(ctx context.Context, endTime time.Time) { cw.dmBuffer.Flush(ctx) cw.buffer.Flush() + + csvLine := make([]string, len(cw.keyToIndex)) + for key, index := range keyToIndex { + csvLine[index] = key + } + cw.csvWrite.Marshall(csvLine) + cw.file.Close() } diff --git a/collector/handlers/csv_handler_test.go b/handlers/csv_handler_test.go.old similarity index 94% rename from collector/handlers/csv_handler_test.go rename to handlers/csv_handler_test.go.old index 631c8a3..be6f023 100644 --- a/collector/handlers/csv_handler_test.go +++ b/handlers/csv_handler_test.go.old @@ -8,8 +8,7 @@ import ( "testing" "time" - internalproto "github.com/sscp/telemetry/collector/internalproto" - "github.com/sscp/telemetry/collector/sources" + "github.com/sscp/telemetry/sources" "github.com/gocarina/gocsv" "github.com/sergi/go-diff/diffmatchpatch" diff --git a/collector/handlers/data_buffer.go b/handlers/data_buffer.go similarity index 52% rename from collector/handlers/data_buffer.go rename to handlers/data_buffer.go index 6b00d81..93395ae 100644 --- a/collector/handlers/data_buffer.go +++ b/handlers/data_buffer.go @@ -3,25 +3,25 @@ package handlers import ( "context" - internalproto "github.com/sscp/telemetry/collector/internalproto" + "github.com/sscp/telemetry/events" ) -// DataMessageBuffer holds DataMessages before emptying the buffer by calling a +// DataMapBuffer holds DataMessages before emptying the buffer by calling a // callback function to write everything out of the buffer. The buffer is // flushed whenever AddData is called and the buffer becomes full or whenever // Flush is called. Ensure to call flush to close out the buffer at the end of // use. -type DataMessageBuffer struct { - dataBuf []*internalproto.DataMessage +type DataEventBuffer struct { + dataBuf []events.DataEvent lastIndex int - writeData func(context.Context, []*internalproto.DataMessage) + writeData func(context.Context, []events.DataEvent) } -// NewDataMessageBuffer constructs a new DataMessageBuffer with the given +// NewDataMapBuffer constructs a new DataMapBuffer with the given // callback function and of the given size. -func NewDataMessageBuffer(callback func(context.Context, []*internalproto.DataMessage), size int) *DataMessageBuffer { - return &DataMessageBuffer{ - dataBuf: make([]*internalproto.DataMessage, 10), +func NewDataEventBuffer(callback func(context.Context, []events.DataEvent), size int) *DataEventBuffer { + return &DataEventBuffer{ + dataBuf: make([]events.DataEvent, 10), lastIndex: -1, writeData: callback, } @@ -29,7 +29,7 @@ func NewDataMessageBuffer(callback func(context.Context, []*internalproto.DataMe // AddData adds a single DataMessage to the buffer and if after that message is // added, the buffer is full, it calls Flush to empty the buffer. -func (dmb *DataMessageBuffer) AddData(ctx context.Context, dm *internalproto.DataMessage) { +func (dmb *DataEventBuffer) AddData(ctx context.Context, dm events.DataEvent) { dmb.dataBuf[dmb.lastIndex+1] = dm dmb.lastIndex++ if dmb.lastIndex >= len(dmb.dataBuf)-1 { @@ -40,11 +40,11 @@ func (dmb *DataMessageBuffer) AddData(ctx context.Context, dm *internalproto.Dat // Flush empties the buffer by calling the callback function and passing it all // the data in the buffer, then reseting the buffer index. -func (dmb *DataMessageBuffer) Flush(ctx context.Context) { - if dmb.lastIndex != -1 { +func (deb *DataEventBuffer) Flush(ctx context.Context) { + if deb.lastIndex != -1 { // Slice is exclusive so +1 to lastIndex - dmb.writeData(ctx, dmb.dataBuf[0:dmb.lastIndex+1]) + deb.writeData(ctx, deb.dataBuf[0:deb.lastIndex+1]) } - dmb.lastIndex = -1 + deb.lastIndex = -1 } diff --git a/handlers/data_buffer_test.go b/handlers/data_buffer_test.go new file mode 100644 index 0000000..ddbe536 --- /dev/null +++ b/handlers/data_buffer_test.go @@ -0,0 +1,57 @@ +package handlers + +import ( + "context" + "testing" + "time" + + "github.com/stretchr/testify/assert" + + "github.com/sscp/telemetry/events" +) + +func TestDataEventBuffer(t *testing.T) { + runDataEventBufferTest(t, 20, 10) + runDataEventBufferTest(t, 20, 1) + runDataEventBufferTest(t, 20, 2) + runDataEventBufferTest(t, 20, 5) +} + +func runDataEventBufferTest(t *testing.T, numItems int, bufferSize int) { + + in := createTestDataEvents(numItems) + var out []events.DataEvent + + dmb := NewDataEventBuffer(func(ctx context.Context, data []events.DataEvent) { + for _, dm := range data { + out = append(out, dm) + } + }, bufferSize) + + for _, dm := range in { + dmb.AddData(context.TODO(), dm) + } + dmb.Flush(context.TODO()) + + assert.Equal(t, in, out, "Buffer should output the exact same data input") +} + +func createTestDataEvents(numItems int) []events.DataEvent { + testEvents := make([]events.DataEvent, numItems) + for i := 0; i < numItems; i++ { + testEvents[i] = createTestDataEvent() + } + return testEvents +} + +func createTestDataEvent() events.DataEvent { + return events.DataEvent{ + EventMeta: events.EventMeta{ + CollectedTimeNanos: time.Now().UnixNano(), + }, + Data: map[string]interface{}{ + "test_uint32_data_point": uint32(32), + }, + } + +} diff --git a/collector/handlers/handlers.go b/handlers/handlers.go similarity index 93% rename from collector/handlers/handlers.go rename to handlers/handlers.go index 8f36d89..0a17d68 100644 --- a/collector/handlers/handlers.go +++ b/handlers/handlers.go @@ -3,10 +3,13 @@ package handlers import ( "context" "fmt" - internalproto "github.com/sscp/telemetry/collector/internalproto" "time" + + "github.com/sscp/telemetry/events" ) +// TODO: update doc + // DataHandler is a sink for DataMessages from the collector. // // A DataHandler can be plugged into the collector and will recieve all the @@ -22,11 +25,11 @@ type DataHandler interface { // file and setting up buffers. HandleStartRun(context.Context, string, time.Time) - // HandleData is called by collector on every incomming packet. This + // HandleDataEvent is called by collector on every incomming packet. This // method is performance critical, so if it is slow, the DataHandler // will not recieve every packet from collector. This method should be // benchmarked to verify that it is fast enough to recieve all data. - HandleData(context.Context, *internalproto.DataMessage) + HandleDataEvent(context.Context, events.DataEvent) // HandleDroppedData is called by collector whenever the DataHandler // falls behind and misses a packet. This is a performance critical @@ -57,7 +60,7 @@ type BinaryHandler interface { // method is performance critical, so if it is slow, the BinaryHandler // will not recieve every packet from collector. This method should be // benchmarked to verify that it is fast enough to recieve all data. - HandlePacket(context.Context, []byte) + HandleRawEvent(context.Context, events.RawEvent) // HandleDroppedPacket is called by collector whenever the // BinaryHandler falls behind and misses a packet. This is a diff --git a/collector/handlers/influx_handler.go b/handlers/influx_handler.go similarity index 79% rename from collector/handlers/influx_handler.go rename to handlers/influx_handler.go index 418923f..4828214 100644 --- a/collector/handlers/influx_handler.go +++ b/handlers/influx_handler.go @@ -6,15 +6,11 @@ import ( "math" "time" - internalproto "github.com/sscp/telemetry/collector/internalproto" - "github.com/sscp/telemetry/log" - influx "github.com/influxdata/influxdb/client/v2" "github.com/opentracing/opentracing-go" - // Fork of https://github.com/fatih/structs/ that adds an "indirect" - // option to dereference pointers to get values, not pointers in map - "github.com/jackbeasley/structs" + "github.com/sscp/telemetry/events" + "github.com/sscp/telemetry/log" ) const databaseName = "sundae" @@ -48,7 +44,7 @@ type InfluxWriter struct { config InfluxConfig runName string client influx.Client - dmBuffer *DataMessageBuffer + deBuffer *DataEventBuffer } // NewInfluxWriter returns an instantiated InfluxWriter as a DataHandler interface @@ -86,7 +82,7 @@ func (cw *InfluxWriter) HandleStartRun(ctx context.Context, runName string, star return } - cw.dmBuffer = NewDataMessageBuffer(cw.writeData, 10) + cw.deBuffer = NewDataEventBuffer(cw.writeData, 10) cw.runName = runName } @@ -99,7 +95,7 @@ func (cw *InfluxWriter) setupWriter() error { // writeData writes all the data in the DataMessage buffer to influx as a // point batch -func (cw *InfluxWriter) writeData(ctx context.Context, data []*internalproto.DataMessage) { +func (cw *InfluxWriter) writeData(ctx context.Context, data []events.DataEvent) { // Create a new point batch bp, err := influx.NewBatchPoints(influx.BatchPointsConfig{ Database: databaseName, @@ -109,18 +105,16 @@ func (cw *InfluxWriter) writeData(ctx context.Context, data []*internalproto.Dat log.Error(ctx, err, "Error creating batch points") return } - for _, dm := range data { - // Convert struct to map[string]interface{} - dataFields := structs.Map(dm) - for key, value := range dataFields { + for _, dataEvent := range data { + for key, value := range dataEvent.Data { if val, ok := value.(float32); ok { if math.IsNaN(float64(val)) { - delete(dataFields, key) + delete(dataEvent.Data, key) } } if val, ok := value.(float64); ok { if math.IsNaN(val) { - delete(dataFields, key) + delete(dataEvent.Data, key) } } @@ -128,7 +122,7 @@ func (cw *InfluxWriter) writeData(ctx context.Context, data []*internalproto.Dat // Create a point and add to batch tags := map[string]string{"run_name": cw.runName} // TimeCollected is always set when deserialized by collector - pt, err := influx.NewPoint("car_state", tags, dataFields, time.Unix(0, dm.GetTimeCollected())) + pt, err := influx.NewPoint("car_state", tags, dataEvent.Data, dataEvent.GetCollectedTime()) if err != nil { log.Error(ctx, err, "Error creating influx point") return @@ -142,19 +136,19 @@ func (cw *InfluxWriter) writeData(ctx context.Context, data []*internalproto.Dat } } -// HandleData is called on every new DataMessage from the collector and adds +// HandleDataEvent is called on every new DataMessage from the collector and adds // the new DataMessage to the buffer of DataMessages and flushes the buffer if // it is full -func (cw *InfluxWriter) HandleData(ctx context.Context, data *internalproto.DataMessage) { - span, ctx := opentracing.StartSpanFromContext(ctx, "InfluxWriter/HandleData") +func (cw *InfluxWriter) HandleDataEvent(ctx context.Context, dataEvent events.DataEvent) { + span, ctx := opentracing.StartSpanFromContext(ctx, "InfluxWriter/HandleDataEvent") defer span.Finish() - cw.dmBuffer.AddData(ctx, data) + cw.deBuffer.AddData(ctx, dataEvent) } // HandleDroppedData is called whenever InfluxWriter falls behind and currently // does nothing other than report a span to tracing func (cw *InfluxWriter) HandleDroppedData(ctx context.Context) { - span, ctx := opentracing.StartSpanFromContext(ctx, "InfluxWriter/HandleDroppedPacket") + span, _ := opentracing.StartSpanFromContext(ctx, "InfluxWriter/HandleDroppedPacket") defer span.Finish() } @@ -166,7 +160,7 @@ func (cw *InfluxWriter) HandleEndRun(ctx context.Context, endTime time.Time) { span, ctx := opentracing.StartSpanFromContext(ctx, "InfluxWriter/HandleEndRun") defer span.Finish() - cw.dmBuffer.Flush(ctx) + cw.deBuffer.Flush(ctx) cw.client.Close() cw.runName = "" } diff --git a/collector/handlers/influx_handler_test.go b/handlers/influx_handler_test.go similarity index 75% rename from collector/handlers/influx_handler_test.go rename to handlers/influx_handler_test.go index 888df02..a27e263 100644 --- a/collector/handlers/influx_handler_test.go +++ b/handlers/influx_handler_test.go @@ -4,8 +4,6 @@ import ( "context" "testing" "time" - - "github.com/sscp/telemetry/collector/sources" ) func BenchmarkInfluxWriter(b *testing.B) { @@ -23,12 +21,12 @@ func BenchmarkInfluxWriter(b *testing.B) { iw.HandleStartRun(ctx, runName, runStart) defer iw.HandleEndRun(ctx, time.Now()) b.ResetTimer() + + testEvents := createTestDataEvents(b.N) + // run b.N times for n := 0; n < b.N; n++ { - zdm := sources.CreateRandomDataMessage() - time := time.Now().UnixNano() - zdm.TimeCollected = &time - iw.HandleData(ctx, zdm) + iw.HandleDataEvent(ctx, testEvents[n]) } b.StopTimer() } diff --git a/influxdb_config/influxdb.conf b/influxdb_config/influxdb.conf new file mode 100644 index 0000000..1ea714e --- /dev/null +++ b/influxdb_config/influxdb.conf @@ -0,0 +1,135 @@ +reporting-disabled = false +bind-address = ":8088" + +[meta] + dir = "/var/lib/influxdb/meta" + retention-autocreate = true + logging-enabled = true + +[data] + dir = "/var/lib/influxdb/data" + wal-dir = "/var/lib/influxdb/wal" + query-log-enabled = true + cache-max-memory-size = 1073741824 + cache-snapshot-memory-size = 26214400 + cache-snapshot-write-cold-duration = "10m0s" + compact-full-write-cold-duration = "4h0m0s" + max-series-per-database = 1000000 + max-values-per-tag = 100000 + index-version = "tsi1" + trace-logging-enabled = false + +[ifql] + enabled = true + log-enabled = true + bind-address = ":8082" + +[coordinator] + write-timeout = "10s" + max-concurrent-queries = 0 + query-timeout = "0s" + log-queries-after = "0s" + max-select-point = 0 + max-select-series = 0 + max-select-buckets = 0 + +[retention] + enabled = true + check-interval = "30m0s" + +[shard-precreation] + enabled = true + check-interval = "10m0s" + advance-period = "30m0s" + +[admin] + enabled = false + bind-address = ":8083" + https-enabled = false + https-certificate = "/etc/ssl/influxdb.pem" + +[monitor] + store-enabled = true + store-database = "_internal" + store-interval = "10s" + +[subscriber] + enabled = true + http-timeout = "30s" + insecure-skip-verify = false + ca-certs = "" + write-concurrency = 40 + write-buffer-size = 1000 + +[http] + enabled = true + bind-address = ":8086" + auth-enabled = false + log-enabled = true + write-tracing = false + pprof-enabled = true + https-enabled = false + https-certificate = "/etc/ssl/influxdb.pem" + https-private-key = "" + max-row-limit = 0 + max-connection-limit = 0 + shared-secret = "" + realm = "InfluxDB" + unix-socket-enabled = false + bind-socket = "/var/run/influxdb.sock" + +[[graphite]] + enabled = false + bind-address = ":2003" + database = "graphite" + retention-policy = "" + protocol = "tcp" + batch-size = 5000 + batch-pending = 10 + batch-timeout = "1s" + consistency-level = "one" + separator = "." + udp-read-buffer = 0 + +[[collectd]] + enabled = false + bind-address = ":25826" + database = "collectd" + retention-policy = "" + batch-size = 5000 + batch-pending = 10 + batch-timeout = "10s" + read-buffer = 0 + typesdb = "/usr/share/collectd/types.db" + security-level = "none" + auth-file = "/etc/collectd/auth_file" + +[[opentsdb]] + enabled = false + bind-address = ":4242" + database = "opentsdb" + retention-policy = "" + consistency-level = "one" + tls-enabled = false + certificate = "/etc/ssl/influxdb.pem" + batch-size = 1000 + batch-pending = 5 + batch-timeout = "1s" + log-point-errors = true + +[[udp]] + enabled = true + bind-address = ":8089" + database = "udp" + retention-policy = "" + batch-size = 5000 + batch-pending = 10 + read-buffer = 0 + batch-timeout = "1s" + precision = "" + +[continuous_queries] + log-enabled = true + enabled = true + run-interval = "1s" + diff --git a/sandbox b/sandbox deleted file mode 160000 index 494b6f5..0000000 --- a/sandbox +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 494b6f53fefa93bb7cd7d5aab362dea1db49d6b5 diff --git a/sources/blog_source.go b/sources/blog_source.go new file mode 100644 index 0000000..dcc134d --- /dev/null +++ b/sources/blog_source.go @@ -0,0 +1,68 @@ +package sources + +import ( + "context" + "io" + "log" + "time" + + "github.com/sscp/telemetry/blog" + "github.com/sscp/telemetry/events" +) + +// BlogRawEventSource is a RawEventSource that reads from an io.Reader +// The delay between packets can be set to some constant +type BlogRawEventSource struct { + reader io.Reader + doneChan chan bool + outChan chan *events.ContextRawEvent +} + +// NewBlogRawEventSource instantiates a BlogRawEventSource +// It reads packets to the specified output channel and waits the given +// duration between reading packets +func NewBlogRawEventSource(r io.Reader, d time.Duration) RawEventSource { + return &BlogRawEventSource{ + reader: r, + doneChan: make(chan bool), + outChan: make(chan *events.ContextRawEvent), + } +} + +// Listen reads packets from the file sequentially until the file is empty, then calls Close +func (bps *BlogRawEventSource) Listen() { + rdr := blog.NewReader(bps.reader) + for { + readPacket, err := rdr.NextPacket() + if err != nil { + if err == io.EOF { + bps.Close() + bps.doneChan <- true + break + } else { + log.Fatal(err) + } + } + // TODO: NewRawDataEvent sets CollectedTimeNanos to + // current time, maybe try to pull from blog? + bps.outChan <- &events.ContextRawEvent{ + Context: context.Background(), + RawEvent: events.NewRawEventNow(readPacket), + } + } +} + +// RawEvents returns the channel into which all the read packets are placed +func (bps *BlogRawEventSource) RawEvents() <-chan *events.ContextRawEvent { + return bps.outChan +} + +// Close closes the RawEvents channel +// +// This is called when the end of the stream is reached to wait until the +// goroutine exits and there are no more packets +func (bps *BlogRawEventSource) Close() error { + // Wait on the done channel + <-bps.doneChan + return nil +} diff --git a/sources/blog_source_test.go b/sources/blog_source_test.go new file mode 100644 index 0000000..2a2f129 --- /dev/null +++ b/sources/blog_source_test.go @@ -0,0 +1,42 @@ +package sources + +import ( + "bytes" + "testing" + "time" + + "github.com/stretchr/testify/assert" + + "github.com/sscp/telemetry/blog" +) + +func TestBlogReaderSource(t *testing.T) { + specs := []struct { + Packets [][]byte + Delay time.Duration + }{ + { + Packets: [][]byte{[]byte("hello"), []byte("i am a packet"), []byte("im another packet")}, + }, + } + + for _, tt := range specs { + buf := new(bytes.Buffer) + + writer := blog.NewWriter(buf) + for _, s := range tt.Packets { + _, err := writer.Write(s) + assert.NoError(t, err) + } + + bufRead := bytes.NewReader(buf.Bytes()) + bps := NewBlogRawEventSource(bufRead, tt.Delay) + go bps.Listen() + + var i int = 0 + for packet := range bps.RawEvents() { + assert.Equal(t, tt.Packets[i], packet) + i++ + } + } +} diff --git a/sources/source.go b/sources/source.go new file mode 100644 index 0000000..754134b --- /dev/null +++ b/sources/source.go @@ -0,0 +1,18 @@ +package sources + +import "github.com/sscp/telemetry/events" + +// RawEventSource abstracts over a source of data packets, can be a file or +// listening for UDP packets +type RawEventSource interface { + // RawEvents returns a reference to the output channel of rawEvents + // produced by the DataSource + RawEvents() <-chan *events.ContextRawEvent + + // Listen begins collecting packets and putting them on the output + // channel. + Listen() + + // Close stops putting packets on the output channel + Close() error +} diff --git a/collector/sources/udp_source.go b/sources/udp_source.go similarity index 55% rename from collector/sources/udp_source.go rename to sources/udp_source.go index 6afc45a..e82a17b 100644 --- a/collector/sources/udp_source.go +++ b/sources/udp_source.go @@ -6,25 +6,25 @@ import ( "net" "time" - "github.com/sscp/telemetry/collector/contextkeys" + "github.com/sscp/telemetry/events" ) // UDPListenTimeout is the time to wait for the next packet const udpListenTimeout = 100 * time.Millisecond -// UDPPacketSource is a PacketSource that reads from a UDP socket -type UDPPacketSource struct { +// UDPRawEventSource is a RawEventSource that reads from a UDP socket +type UDPRawEventSource struct { port int - outChan chan *ContextPacket + outChan chan *events.ContextRawEvent doneChan chan bool conn *net.UDPConn packetBuffer []byte } -// NewUDPPacketSource constructs a UDPPacketSource that listens on the given +// NewUDPRawEventSource constructs a UDPRawEventSource that listens on the given // port for packets -func NewUDPPacketSource(port int) (PacketSource, error) { - ups := &UDPPacketSource{ +func NewUDPRawEventSource(port int) (RawEventSource, error) { + ups := &UDPRawEventSource{ port: port, packetBuffer: make([]byte, 2000), // Max packet size is ~1000 } @@ -38,7 +38,7 @@ func NewUDPPacketSource(port int) (PacketSource, error) { // setupForListen creates the UDP connection, begins listening, and creates the // outChan and doneChan to send out received packets and notifies the goroutine // to stop listening when done -func (ups *UDPPacketSource) setupForListen() error { +func (ups *UDPRawEventSource) setupForListen() error { // Listen to the zero port for IPv4 to catch any packet to that port // This will catch broadcast packets from the car var err error @@ -49,36 +49,33 @@ func (ups *UDPPacketSource) setupForListen() error { if err != nil { return err } - ups.outChan = make(chan *ContextPacket) + ups.outChan = make(chan *events.ContextRawEvent) ups.doneChan = make(chan bool) return nil } -// Packets is the stream of packets received from UDP +// RawEvents is the stream of packets received from UDP // It is simply a reference to outChan -func (ups *UDPPacketSource) Packets() <-chan *ContextPacket { +func (ups *UDPRawEventSource) RawEvents() <-chan *events.ContextRawEvent { return ups.outChan } // Listen spins up a goroutine that listens for packets until it receives a // signal on the doneChan, in which case it closes the connection and returns -func (ups *UDPPacketSource) Listen() { - - go func() { - for { - select { - case <-ups.doneChan: - // Close Conn and shutdown goroutine - ups.conn.Close() - return - default: - ups.readAndForwardPacket() - } +func (ups *UDPRawEventSource) Listen() { + for { + select { + case <-ups.doneChan: + // Close Conn and shutdown goroutine + ups.conn.Close() + return + default: + ups.readAndForwardRawEvent() } - }() + } } -func (ups *UDPPacketSource) readAndForwardPacket() { +func (ups *UDPRawEventSource) readAndForwardRawEvent() { packet, err := ups.readPacket() if netError, ok := err.(net.Error); ok { // If timeout error, keep looping @@ -87,12 +84,9 @@ func (ups *UDPPacketSource) readAndForwardPacket() { log.Fatal(err) } } else { - recievedTime := time.Now() - // Create context with time of receiving packet - ctx := contextkeys.ContextWithRecievedTime(context.Background(), recievedTime) - ups.outChan <- &ContextPacket{ - Ctx: ctx, - Packet: packet, + ups.outChan <- &events.ContextRawEvent{ + Context: context.Background(), + RawEvent: events.NewRawEventNow(packet), } } @@ -100,8 +94,11 @@ func (ups *UDPPacketSource) readAndForwardPacket() { // readPacket reads a single packet into the packetBuffer, then copies the exact // packet into a new byte array and returns it. -func (ups *UDPPacketSource) readPacket() ([]byte, error) { - ups.conn.SetDeadline(time.Now().Add(udpListenTimeout)) +func (ups *UDPRawEventSource) readPacket() ([]byte, error) { + err := ups.conn.SetDeadline(time.Now().Add(udpListenTimeout)) + if err != nil { + return nil, err + } numBytes, _, err := ups.conn.ReadFromUDP(ups.packetBuffer) if err != nil { return nil, err @@ -114,18 +111,24 @@ func (ups *UDPPacketSource) readPacket() ([]byte, error) { } // Close sends a done signal on doneChan, closes both doneChan, outChan, then -// resets the UDPPacketSource so that it is ready to be reused -func (ups *UDPPacketSource) Close() { +// resets the UDPRawEventSource so that it is ready to be reused +func (ups *UDPRawEventSource) Close() error { ups.doneChan <- true close(ups.doneChan) close(ups.outChan) + if err := ups.conn.Close(); err != nil { + return err + } // Reset - ups.setupForListen() + if err := ups.setupForListen(); err != nil { + return err + } + return nil } -// SendPacketsAsUDP sends all the packets from the dataSource to the broadcast -// ip on the given port. Packets are spaced by the given delay duration. -func SendPacketsAsUDP(packetChan <-chan *ContextPacket, port int) { +// SendEventsAsUDP sends all the events from the dataSource to the broadcast +// ip on the given port. +func SendEventsAsUDP(eventChan <-chan *events.ContextRawEvent, port int) { conn, err := net.DialUDP("udp4", nil, &net.UDPAddr{ IP: net.IPv4bcast, Port: port, @@ -135,7 +138,10 @@ func SendPacketsAsUDP(packetChan <-chan *ContextPacket, port int) { } defer conn.Close() - for packet := range packetChan { - conn.Write(packet.Packet) + for event := range eventChan { + _, err := conn.Write(event.Data) + if err != nil { + log.Printf("could not write packet: %v", err) + } } } diff --git a/sources/udp_source_test.go b/sources/udp_source_test.go new file mode 100644 index 0000000..ca1d82b --- /dev/null +++ b/sources/udp_source_test.go @@ -0,0 +1,56 @@ +package sources + +import ( + "context" + "fmt" + "math/rand" + "testing" + + "github.com/stretchr/testify/assert" + "golang.org/x/time/rate" + + "github.com/sscp/telemetry/events" +) + +func TestUDPSendRecv(t *testing.T) { + src, err := NewUDPRawEventSource(3000) + if err != nil { + t.Errorf("Error creating packet source: %v", err) + } + + eventChan := make(chan *events.ContextRawEvent) + // Send all the packets in the channel + go SendEventsAsUDP(eventChan, 3000) + + // Listen for those same packets + go src.Listen() + defer src.Close() + packets := make([][]byte, 100) + + for i := 0; i < len(packets); i++ { + // Make a random packet + packets[i] = make([]byte, i) + rand.Read(packets[i]) + } + limiter := rate.NewLimiter(rate.Limit(100), 1) + for _, packet := range packets { + err := limiter.Wait(context.TODO()) + if err != nil { + fmt.Println("f") + } + // Packet sent to the send channel + eventChan <- &events.ContextRawEvent{ + Context: context.Background(), + RawEvent: events.NewRawEventNow(packet), + } + } + close(eventChan) + + for i := 0; i < len(packets); i++ { + // Listen for the packet on the recv channel + rawEvent := <-src.RawEvents() + + // Check that everything made it + assert.Equal(t, packets[i], rawEvent.Data) + } +} diff --git a/sources/zero_source.go b/sources/zero_source.go new file mode 100644 index 0000000..2aa98b7 --- /dev/null +++ b/sources/zero_source.go @@ -0,0 +1,68 @@ +package sources + +import ( + "context" + "fmt" + + "github.com/sscp/telemetry/cars/sundae" + "github.com/sscp/telemetry/events" + + "golang.org/x/time/rate" +) + +// ZeroRawEventSource is a RawEventSource that returns only zeroed out DataMessages +// at a given rate +type ZeroRawEventSource struct { + outChan chan *events.ContextRawEvent + doneChan chan bool + limiter *rate.Limiter +} + +// RawEvents is the stream of zeroed binary packets +// It is simply a reference to outChan +func (zps *ZeroRawEventSource) RawEvents() <-chan *events.ContextRawEvent { + return zps.outChan +} + +// Listen begins sending zeroed packets to the RawEvents channel. +// It launches a gorountine that sen +func (zps *ZeroRawEventSource) Listen() { + for { + err := zps.limiter.Wait(context.TODO()) + if err != nil { + fmt.Println("too fast") + continue + } + zPacket, _ := sundae.CreateZeroPacket() + + select { + case <-zps.doneChan: + return + default: + zps.outChan <- &events.ContextRawEvent{ + Context: context.Background(), + RawEvent: events.NewRawEventNow(zPacket), + } + } + } +} + +// Close sends a close signal on doneChan and closes both doneChan and outChan. +// NOTE: this currently does not reset the ZeroRawEventSource to listen again +func (zps *ZeroRawEventSource) Close() error { + zps.doneChan <- true + close(zps.outChan) + close(zps.doneChan) + return nil +} + +// NewZeroRawEventSource constructs a new ZeroRawEventSource that emits zeroed out +// packets at packetsPerSecond +func NewZeroRawEventSource(packetsPerSecond int) RawEventSource { + return &ZeroRawEventSource{ + outChan: make(chan *events.ContextRawEvent), + doneChan: make(chan bool, 1), + // Only allow one packet out at a time + limiter: rate.NewLimiter(rate.Limit(packetsPerSecond), 1), + } +} diff --git a/sources/zero_source_test.go b/sources/zero_source_test.go new file mode 100644 index 0000000..a7db18c --- /dev/null +++ b/sources/zero_source_test.go @@ -0,0 +1,25 @@ +package sources + +import ( + "testing" + + "github.com/sscp/telemetry/cars/sundae" + + "github.com/stretchr/testify/assert" +) + +func TestZeroRawEventSource(t *testing.T) { + zps := NewZeroRawEventSource(1000) + defer zps.Close() + go zps.Listen() + + for i := 0; i < 10; i++ { + rawEvent := <-zps.RawEvents() + dataEvent, err := sundae.Deserialize(rawEvent.Context, rawEvent.RawEvent) + assert.Nil(t, err) + assert.Equal( + t, dataEvent.Data["motor_controller_speed"], float32(0.0), + "Motor controller speed should be zero", + ) + } +} diff --git a/vendor/github.com/apache/thrift/LICENSE b/vendor/github.com/apache/thrift/LICENSE deleted file mode 100644 index 3b6d7d7..0000000 --- a/vendor/github.com/apache/thrift/LICENSE +++ /dev/null @@ -1,239 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - --------------------------------------------------- -SOFTWARE DISTRIBUTED WITH THRIFT: - -The Apache Thrift software includes a number of subcomponents with -separate copyright notices and license terms. Your use of the source -code for the these subcomponents is subject to the terms and -conditions of the following licenses. - --------------------------------------------------- -Portions of the following files are licensed under the MIT License: - - lib/erl/src/Makefile.am - -Please see doc/otp-base-license.txt for the full terms of this license. - --------------------------------------------------- -For the aclocal/ax_boost_base.m4 and contrib/fb303/aclocal/ax_boost_base.m4 components: - -# Copyright (c) 2007 Thomas Porschberg -# -# Copying and distribution of this file, with or without -# modification, are permitted in any medium without royalty provided -# the copyright notice and this notice are preserved. - --------------------------------------------------- -For the lib/nodejs/lib/thrift/json_parse.js: - -/* - json_parse.js - 2015-05-02 - Public Domain. - NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. - -*/ -(By Douglas Crockford ) --------------------------------------------------- diff --git a/vendor/github.com/apache/thrift/NOTICE b/vendor/github.com/apache/thrift/NOTICE deleted file mode 100644 index c23995a..0000000 --- a/vendor/github.com/apache/thrift/NOTICE +++ /dev/null @@ -1,5 +0,0 @@ -Apache Thrift -Copyright 2006-2010 The Apache Software Foundation. - -This product includes software developed at -The Apache Software Foundation (http://www.apache.org/). \ No newline at end of file diff --git a/vendor/github.com/apache/thrift/contrib/fb303/LICENSE b/vendor/github.com/apache/thrift/contrib/fb303/LICENSE deleted file mode 100644 index 4eacb64..0000000 --- a/vendor/github.com/apache/thrift/contrib/fb303/LICENSE +++ /dev/null @@ -1,16 +0,0 @@ -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. diff --git a/vendor/github.com/apache/thrift/debian/copyright b/vendor/github.com/apache/thrift/debian/copyright deleted file mode 100644 index 850643c..0000000 --- a/vendor/github.com/apache/thrift/debian/copyright +++ /dev/null @@ -1,129 +0,0 @@ -This package was debianized by Thrift Developer's . - - -This package and the Debian packaging is licensed under the Apache License, -see `/usr/share/common-licenses/Apache-2.0'. - -The following information was copied from Apache Thrift LICENSE file. - --------------------------------------------------- -SOFTWARE DISTRIBUTED WITH THRIFT: - -The Apache Thrift software includes a number of subcomponents with -separate copyright notices and license terms. Your use of the source -code for the these subcomponents is subject to the terms and -conditions of the following licenses. - --------------------------------------------------- -Portions of the following files are licensed under the MIT License: - - lib/erl/src/Makefile.am - -Please see doc/otp-base-license.txt for the full terms of this license. - - --------------------------------------------------- -The following files contain some portions of code contributed under -the Thrift Software License (see doc/old-thrift-license.txt), and relicensed -under the Apache 2.0 License: - - compiler/cpp/Makefile.am - compiler/cpp/src/generate/t_cocoa_generator.cc - compiler/cpp/src/generate/t_cpp_generator.cc - compiler/cpp/src/generate/t_csharp_generator.cc - compiler/cpp/src/generate/t_erl_generator.cc - compiler/cpp/src/generate/t_hs_generator.cc - compiler/cpp/src/generate/t_java_generator.cc - compiler/cpp/src/generate/t_ocaml_generator.cc - compiler/cpp/src/generate/t_perl_generator.cc - compiler/cpp/src/generate/t_php_generator.cc - compiler/cpp/src/generate/t_py_generator.cc - compiler/cpp/src/generate/t_rb_generator.cc - compiler/cpp/src/generate/t_st_generator.cc - compiler/cpp/src/generate/t_xsd_generator.cc - compiler/cpp/src/main.cc - compiler/cpp/src/parse/t_field.h - compiler/cpp/src/parse/t_program.h - compiler/cpp/src/platform.h - compiler/cpp/src/thriftl.ll - compiler/cpp/src/thrifty.yy - lib/csharp/src/Protocol/TBinaryProtocol.cs - lib/csharp/src/Protocol/TField.cs - lib/csharp/src/Protocol/TList.cs - lib/csharp/src/Protocol/TMap.cs - lib/csharp/src/Protocol/TMessage.cs - lib/csharp/src/Protocol/TMessageType.cs - lib/csharp/src/Protocol/TProtocol.cs - lib/csharp/src/Protocol/TProtocolException.cs - lib/csharp/src/Protocol/TProtocolFactory.cs - lib/csharp/src/Protocol/TProtocolUtil.cs - lib/csharp/src/Protocol/TSet.cs - lib/csharp/src/Protocol/TStruct.cs - lib/csharp/src/Protocol/TType.cs - lib/csharp/src/Server/TServer.cs - lib/csharp/src/Server/TSimpleServer.cs - lib/csharp/src/Server/TThreadPoolServer.cs - lib/csharp/src/TApplicationException.cs - lib/csharp/src/Thrift.csproj - lib/csharp/src/Thrift.sln - lib/csharp/src/TProcessor.cs - lib/csharp/src/Transport/TServerSocket.cs - lib/csharp/src/Transport/TServerTransport.cs - lib/csharp/src/Transport/TSocket.cs - lib/csharp/src/Transport/TStreamTransport.cs - lib/csharp/src/Transport/TTransport.cs - lib/csharp/src/Transport/TTransportException.cs - lib/csharp/src/Transport/TTransportFactory.cs - lib/csharp/ThriftMSBuildTask/Properties/AssemblyInfo.cs - lib/csharp/ThriftMSBuildTask/ThriftBuild.cs - lib/csharp/ThriftMSBuildTask/ThriftMSBuildTask.csproj - lib/rb/lib/thrift.rb - lib/st/README - lib/st/thrift.st - test/OptionalRequiredTest.cpp - test/OptionalRequiredTest.thrift - test/ThriftTest.thrift - --------------------------------------------------- -For the aclocal/ax_boost_base.m4 and contrib/fb303/aclocal/ax_boost_base.m4 components: - -# Copyright (c) 2007 Thomas Porschberg -# -# Copying and distribution of this file, with or without -# modification, are permitted in any medium without royalty provided -# the copyright notice and this notice are preserved. - --------------------------------------------------- -For the compiler/cpp/src/md5.[ch] components: - -/* - Copyright (C) 1999, 2000, 2002 Aladdin Enterprises. All rights reserved. - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - L. Peter Deutsch - ghost@aladdin.com - - */ - ---------------------------------------------------- -For the lib/rb/setup.rb: Copyright (c) 2000-2005 Minero Aoki, -lib/ocaml/OCamlMakefile and lib/ocaml/README-OCamlMakefile components: - Copyright (C) 1999 - 2007 Markus Mottl - -Licensed under the terms of the GNU Lesser General Public License 2.1 -(see doc/lgpl-2.1.txt for the full terms of this license) diff --git a/vendor/github.com/apache/thrift/lib/dart/LICENSE_HEADER b/vendor/github.com/apache/thrift/lib/dart/LICENSE_HEADER deleted file mode 100644 index 4eacb64..0000000 --- a/vendor/github.com/apache/thrift/lib/dart/LICENSE_HEADER +++ /dev/null @@ -1,16 +0,0 @@ -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/buffered_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/buffered_transport.go deleted file mode 100644 index f73a98b..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/buffered_transport.go +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package thrift - -import ( - "bufio" -) - -type TBufferedTransportFactory struct { - size int -} - -type TBufferedTransport struct { - bufio.ReadWriter - tp TTransport -} - -func (p *TBufferedTransportFactory) GetTransport(trans TTransport) TTransport { - return NewTBufferedTransport(trans, p.size) -} - -func NewTBufferedTransportFactory(bufferSize int) *TBufferedTransportFactory { - return &TBufferedTransportFactory{size: bufferSize} -} - -func NewTBufferedTransport(trans TTransport, bufferSize int) *TBufferedTransport { - return &TBufferedTransport{ - ReadWriter: bufio.ReadWriter{ - Reader: bufio.NewReaderSize(trans, bufferSize), - Writer: bufio.NewWriterSize(trans, bufferSize), - }, - tp: trans, - } -} - -func (p *TBufferedTransport) IsOpen() bool { - return p.tp.IsOpen() -} - -func (p *TBufferedTransport) Open() (err error) { - return p.tp.Open() -} - -func (p *TBufferedTransport) Close() (err error) { - return p.tp.Close() -} - -func (p *TBufferedTransport) Read(b []byte) (int, error) { - n, err := p.ReadWriter.Read(b) - if err != nil { - p.ReadWriter.Reader.Reset(p.tp) - } - return n, err -} - -func (p *TBufferedTransport) Write(b []byte) (int, error) { - n, err := p.ReadWriter.Write(b) - if err != nil { - p.ReadWriter.Writer.Reset(p.tp) - } - return n, err -} - -func (p *TBufferedTransport) Flush() error { - if err := p.ReadWriter.Flush(); err != nil { - p.ReadWriter.Writer.Reset(p.tp) - return err - } - return p.tp.Flush() -} - -func (p *TBufferedTransport) RemainingBytes() (num_bytes uint64) { - return p.tp.RemainingBytes() -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/debug_protocol.go b/vendor/github.com/apache/thrift/lib/go/thrift/debug_protocol.go deleted file mode 100644 index d37252c..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/debug_protocol.go +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package thrift - -import ( - "log" -) - -type TDebugProtocol struct { - Delegate TProtocol - LogPrefix string -} - -type TDebugProtocolFactory struct { - Underlying TProtocolFactory - LogPrefix string -} - -func NewTDebugProtocolFactory(underlying TProtocolFactory, logPrefix string) *TDebugProtocolFactory { - return &TDebugProtocolFactory{ - Underlying: underlying, - LogPrefix: logPrefix, - } -} - -func (t *TDebugProtocolFactory) GetProtocol(trans TTransport) TProtocol { - return &TDebugProtocol{ - Delegate: t.Underlying.GetProtocol(trans), - LogPrefix: t.LogPrefix, - } -} - -func (tdp *TDebugProtocol) WriteMessageBegin(name string, typeId TMessageType, seqid int32) error { - err := tdp.Delegate.WriteMessageBegin(name, typeId, seqid) - log.Printf("%sWriteMessageBegin(name=%#v, typeId=%#v, seqid=%#v) => %#v", tdp.LogPrefix, name, typeId, seqid, err) - return err -} -func (tdp *TDebugProtocol) WriteMessageEnd() error { - err := tdp.Delegate.WriteMessageEnd() - log.Printf("%sWriteMessageEnd() => %#v", tdp.LogPrefix, err) - return err -} -func (tdp *TDebugProtocol) WriteStructBegin(name string) error { - err := tdp.Delegate.WriteStructBegin(name) - log.Printf("%sWriteStructBegin(name=%#v) => %#v", tdp.LogPrefix, name, err) - return err -} -func (tdp *TDebugProtocol) WriteStructEnd() error { - err := tdp.Delegate.WriteStructEnd() - log.Printf("%sWriteStructEnd() => %#v", tdp.LogPrefix, err) - return err -} -func (tdp *TDebugProtocol) WriteFieldBegin(name string, typeId TType, id int16) error { - err := tdp.Delegate.WriteFieldBegin(name, typeId, id) - log.Printf("%sWriteFieldBegin(name=%#v, typeId=%#v, id%#v) => %#v", tdp.LogPrefix, name, typeId, id, err) - return err -} -func (tdp *TDebugProtocol) WriteFieldEnd() error { - err := tdp.Delegate.WriteFieldEnd() - log.Printf("%sWriteFieldEnd() => %#v", tdp.LogPrefix, err) - return err -} -func (tdp *TDebugProtocol) WriteFieldStop() error { - err := tdp.Delegate.WriteFieldStop() - log.Printf("%sWriteFieldStop() => %#v", tdp.LogPrefix, err) - return err -} -func (tdp *TDebugProtocol) WriteMapBegin(keyType TType, valueType TType, size int) error { - err := tdp.Delegate.WriteMapBegin(keyType, valueType, size) - log.Printf("%sWriteMapBegin(keyType=%#v, valueType=%#v, size=%#v) => %#v", tdp.LogPrefix, keyType, valueType, size, err) - return err -} -func (tdp *TDebugProtocol) WriteMapEnd() error { - err := tdp.Delegate.WriteMapEnd() - log.Printf("%sWriteMapEnd() => %#v", tdp.LogPrefix, err) - return err -} -func (tdp *TDebugProtocol) WriteListBegin(elemType TType, size int) error { - err := tdp.Delegate.WriteListBegin(elemType, size) - log.Printf("%sWriteListBegin(elemType=%#v, size=%#v) => %#v", tdp.LogPrefix, elemType, size, err) - return err -} -func (tdp *TDebugProtocol) WriteListEnd() error { - err := tdp.Delegate.WriteListEnd() - log.Printf("%sWriteListEnd() => %#v", tdp.LogPrefix, err) - return err -} -func (tdp *TDebugProtocol) WriteSetBegin(elemType TType, size int) error { - err := tdp.Delegate.WriteSetBegin(elemType, size) - log.Printf("%sWriteSetBegin(elemType=%#v, size=%#v) => %#v", tdp.LogPrefix, elemType, size, err) - return err -} -func (tdp *TDebugProtocol) WriteSetEnd() error { - err := tdp.Delegate.WriteSetEnd() - log.Printf("%sWriteSetEnd() => %#v", tdp.LogPrefix, err) - return err -} -func (tdp *TDebugProtocol) WriteBool(value bool) error { - err := tdp.Delegate.WriteBool(value) - log.Printf("%sWriteBool(value=%#v) => %#v", tdp.LogPrefix, value, err) - return err -} -func (tdp *TDebugProtocol) WriteByte(value int8) error { - err := tdp.Delegate.WriteByte(value) - log.Printf("%sWriteByte(value=%#v) => %#v", tdp.LogPrefix, value, err) - return err -} -func (tdp *TDebugProtocol) WriteI16(value int16) error { - err := tdp.Delegate.WriteI16(value) - log.Printf("%sWriteI16(value=%#v) => %#v", tdp.LogPrefix, value, err) - return err -} -func (tdp *TDebugProtocol) WriteI32(value int32) error { - err := tdp.Delegate.WriteI32(value) - log.Printf("%sWriteI32(value=%#v) => %#v", tdp.LogPrefix, value, err) - return err -} -func (tdp *TDebugProtocol) WriteI64(value int64) error { - err := tdp.Delegate.WriteI64(value) - log.Printf("%sWriteI64(value=%#v) => %#v", tdp.LogPrefix, value, err) - return err -} -func (tdp *TDebugProtocol) WriteDouble(value float64) error { - err := tdp.Delegate.WriteDouble(value) - log.Printf("%sWriteDouble(value=%#v) => %#v", tdp.LogPrefix, value, err) - return err -} -func (tdp *TDebugProtocol) WriteString(value string) error { - err := tdp.Delegate.WriteString(value) - log.Printf("%sWriteString(value=%#v) => %#v", tdp.LogPrefix, value, err) - return err -} -func (tdp *TDebugProtocol) WriteBinary(value []byte) error { - err := tdp.Delegate.WriteBinary(value) - log.Printf("%sWriteBinary(value=%#v) => %#v", tdp.LogPrefix, value, err) - return err -} - -func (tdp *TDebugProtocol) ReadMessageBegin() (name string, typeId TMessageType, seqid int32, err error) { - name, typeId, seqid, err = tdp.Delegate.ReadMessageBegin() - log.Printf("%sReadMessageBegin() (name=%#v, typeId=%#v, seqid=%#v, err=%#v)", tdp.LogPrefix, name, typeId, seqid, err) - return -} -func (tdp *TDebugProtocol) ReadMessageEnd() (err error) { - err = tdp.Delegate.ReadMessageEnd() - log.Printf("%sReadMessageEnd() err=%#v", tdp.LogPrefix, err) - return -} -func (tdp *TDebugProtocol) ReadStructBegin() (name string, err error) { - name, err = tdp.Delegate.ReadStructBegin() - log.Printf("%sReadStructBegin() (name%#v, err=%#v)", tdp.LogPrefix, name, err) - return -} -func (tdp *TDebugProtocol) ReadStructEnd() (err error) { - err = tdp.Delegate.ReadStructEnd() - log.Printf("%sReadStructEnd() err=%#v", tdp.LogPrefix, err) - return -} -func (tdp *TDebugProtocol) ReadFieldBegin() (name string, typeId TType, id int16, err error) { - name, typeId, id, err = tdp.Delegate.ReadFieldBegin() - log.Printf("%sReadFieldBegin() (name=%#v, typeId=%#v, id=%#v, err=%#v)", tdp.LogPrefix, name, typeId, id, err) - return -} -func (tdp *TDebugProtocol) ReadFieldEnd() (err error) { - err = tdp.Delegate.ReadFieldEnd() - log.Printf("%sReadFieldEnd() err=%#v", tdp.LogPrefix, err) - return -} -func (tdp *TDebugProtocol) ReadMapBegin() (keyType TType, valueType TType, size int, err error) { - keyType, valueType, size, err = tdp.Delegate.ReadMapBegin() - log.Printf("%sReadMapBegin() (keyType=%#v, valueType=%#v, size=%#v, err=%#v)", tdp.LogPrefix, keyType, valueType, size, err) - return -} -func (tdp *TDebugProtocol) ReadMapEnd() (err error) { - err = tdp.Delegate.ReadMapEnd() - log.Printf("%sReadMapEnd() err=%#v", tdp.LogPrefix, err) - return -} -func (tdp *TDebugProtocol) ReadListBegin() (elemType TType, size int, err error) { - elemType, size, err = tdp.Delegate.ReadListBegin() - log.Printf("%sReadListBegin() (elemType=%#v, size=%#v, err=%#v)", tdp.LogPrefix, elemType, size, err) - return -} -func (tdp *TDebugProtocol) ReadListEnd() (err error) { - err = tdp.Delegate.ReadListEnd() - log.Printf("%sReadListEnd() err=%#v", tdp.LogPrefix, err) - return -} -func (tdp *TDebugProtocol) ReadSetBegin() (elemType TType, size int, err error) { - elemType, size, err = tdp.Delegate.ReadSetBegin() - log.Printf("%sReadSetBegin() (elemType=%#v, size=%#v, err=%#v)", tdp.LogPrefix, elemType, size, err) - return -} -func (tdp *TDebugProtocol) ReadSetEnd() (err error) { - err = tdp.Delegate.ReadSetEnd() - log.Printf("%sReadSetEnd() err=%#v", tdp.LogPrefix, err) - return -} -func (tdp *TDebugProtocol) ReadBool() (value bool, err error) { - value, err = tdp.Delegate.ReadBool() - log.Printf("%sReadBool() (value=%#v, err=%#v)", tdp.LogPrefix, value, err) - return -} -func (tdp *TDebugProtocol) ReadByte() (value int8, err error) { - value, err = tdp.Delegate.ReadByte() - log.Printf("%sReadByte() (value=%#v, err=%#v)", tdp.LogPrefix, value, err) - return -} -func (tdp *TDebugProtocol) ReadI16() (value int16, err error) { - value, err = tdp.Delegate.ReadI16() - log.Printf("%sReadI16() (value=%#v, err=%#v)", tdp.LogPrefix, value, err) - return -} -func (tdp *TDebugProtocol) ReadI32() (value int32, err error) { - value, err = tdp.Delegate.ReadI32() - log.Printf("%sReadI32() (value=%#v, err=%#v)", tdp.LogPrefix, value, err) - return -} -func (tdp *TDebugProtocol) ReadI64() (value int64, err error) { - value, err = tdp.Delegate.ReadI64() - log.Printf("%sReadI64() (value=%#v, err=%#v)", tdp.LogPrefix, value, err) - return -} -func (tdp *TDebugProtocol) ReadDouble() (value float64, err error) { - value, err = tdp.Delegate.ReadDouble() - log.Printf("%sReadDouble() (value=%#v, err=%#v)", tdp.LogPrefix, value, err) - return -} -func (tdp *TDebugProtocol) ReadString() (value string, err error) { - value, err = tdp.Delegate.ReadString() - log.Printf("%sReadString() (value=%#v, err=%#v)", tdp.LogPrefix, value, err) - return -} -func (tdp *TDebugProtocol) ReadBinary() (value []byte, err error) { - value, err = tdp.Delegate.ReadBinary() - log.Printf("%sReadBinary() (value=%#v, err=%#v)", tdp.LogPrefix, value, err) - return -} -func (tdp *TDebugProtocol) Skip(fieldType TType) (err error) { - err = tdp.Delegate.Skip(fieldType) - log.Printf("%sSkip(fieldType=%#v) (err=%#v)", tdp.LogPrefix, fieldType, err) - return -} -func (tdp *TDebugProtocol) Flush() (err error) { - err = tdp.Delegate.Flush() - log.Printf("%sFlush() (err=%#v)", tdp.LogPrefix, err) - return -} - -func (tdp *TDebugProtocol) Transport() TTransport { - return tdp.Delegate.Transport() -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/deserializer.go b/vendor/github.com/apache/thrift/lib/go/thrift/deserializer.go deleted file mode 100644 index 91a0983..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/deserializer.go +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package thrift - -type TDeserializer struct { - Transport TTransport - Protocol TProtocol -} - -func NewTDeserializer() *TDeserializer { - var transport TTransport - transport = NewTMemoryBufferLen(1024) - - protocol := NewTBinaryProtocolFactoryDefault().GetProtocol(transport) - - return &TDeserializer{ - transport, - protocol} -} - -func (t *TDeserializer) ReadString(msg TStruct, s string) (err error) { - err = nil - if _, err = t.Transport.Write([]byte(s)); err != nil { - return - } - if err = msg.Read(t.Protocol); err != nil { - return - } - return -} - -func (t *TDeserializer) Read(msg TStruct, b []byte) (err error) { - err = nil - if _, err = t.Transport.Write(b); err != nil { - return - } - if err = msg.Read(t.Protocol); err != nil { - return - } - return -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/field.go b/vendor/github.com/apache/thrift/lib/go/thrift/field.go deleted file mode 100644 index 9d66525..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/field.go +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package thrift - -// Helper class that encapsulates field metadata. -type field struct { - name string - typeId TType - id int -} - -func newField(n string, t TType, i int) *field { - return &field{name: n, typeId: t, id: i} -} - -func (p *field) Name() string { - if p == nil { - return "" - } - return p.name -} - -func (p *field) TypeId() TType { - if p == nil { - return TType(VOID) - } - return p.typeId -} - -func (p *field) Id() int { - if p == nil { - return -1 - } - return p.id -} - -func (p *field) String() string { - if p == nil { - return "" - } - return "" -} - -var ANONYMOUS_FIELD *field - -type fieldSlice []field - -func (p fieldSlice) Len() int { - return len(p) -} - -func (p fieldSlice) Less(i, j int) bool { - return p[i].Id() < p[j].Id() -} - -func (p fieldSlice) Swap(i, j int) { - p[i], p[j] = p[j], p[i] -} - -func init() { - ANONYMOUS_FIELD = newField("", STOP, 0) -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/framed_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/framed_transport.go deleted file mode 100644 index d0bae21..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/framed_transport.go +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package thrift - -import ( - "bufio" - "bytes" - "encoding/binary" - "fmt" - "io" -) - -const DEFAULT_MAX_LENGTH = 16384000 - -type TFramedTransport struct { - transport TTransport - buf bytes.Buffer - reader *bufio.Reader - frameSize uint32 //Current remaining size of the frame. if ==0 read next frame header - buffer [4]byte - maxLength uint32 -} - -type tFramedTransportFactory struct { - factory TTransportFactory - maxLength uint32 -} - -func NewTFramedTransportFactory(factory TTransportFactory) TTransportFactory { - return &tFramedTransportFactory{factory: factory, maxLength: DEFAULT_MAX_LENGTH} -} - -func NewTFramedTransportFactoryMaxLength(factory TTransportFactory, maxLength uint32) TTransportFactory { - return &tFramedTransportFactory{factory: factory, maxLength: maxLength} -} - -func (p *tFramedTransportFactory) GetTransport(base TTransport) TTransport { - return NewTFramedTransportMaxLength(p.factory.GetTransport(base), p.maxLength) -} - -func NewTFramedTransport(transport TTransport) *TFramedTransport { - return &TFramedTransport{transport: transport, reader: bufio.NewReader(transport), maxLength: DEFAULT_MAX_LENGTH} -} - -func NewTFramedTransportMaxLength(transport TTransport, maxLength uint32) *TFramedTransport { - return &TFramedTransport{transport: transport, reader: bufio.NewReader(transport), maxLength: maxLength} -} - -func (p *TFramedTransport) Open() error { - return p.transport.Open() -} - -func (p *TFramedTransport) IsOpen() bool { - return p.transport.IsOpen() -} - -func (p *TFramedTransport) Close() error { - return p.transport.Close() -} - -func (p *TFramedTransport) Read(buf []byte) (l int, err error) { - if p.frameSize == 0 { - p.frameSize, err = p.readFrameHeader() - if err != nil { - return - } - } - if p.frameSize < uint32(len(buf)) { - frameSize := p.frameSize - tmp := make([]byte, p.frameSize) - l, err = p.Read(tmp) - copy(buf, tmp) - if err == nil { - err = NewTTransportExceptionFromError(fmt.Errorf("Not enough frame size %d to read %d bytes", frameSize, len(buf))) - return - } - } - got, err := p.reader.Read(buf) - p.frameSize = p.frameSize - uint32(got) - //sanity check - if p.frameSize < 0 { - return 0, NewTTransportException(UNKNOWN_TRANSPORT_EXCEPTION, "Negative frame size") - } - return got, NewTTransportExceptionFromError(err) -} - -func (p *TFramedTransport) ReadByte() (c byte, err error) { - if p.frameSize == 0 { - p.frameSize, err = p.readFrameHeader() - if err != nil { - return - } - } - if p.frameSize < 1 { - return 0, NewTTransportExceptionFromError(fmt.Errorf("Not enough frame size %d to read %d bytes", p.frameSize, 1)) - } - c, err = p.reader.ReadByte() - if err == nil { - p.frameSize-- - } - return -} - -func (p *TFramedTransport) Write(buf []byte) (int, error) { - n, err := p.buf.Write(buf) - return n, NewTTransportExceptionFromError(err) -} - -func (p *TFramedTransport) WriteByte(c byte) error { - return p.buf.WriteByte(c) -} - -func (p *TFramedTransport) WriteString(s string) (n int, err error) { - return p.buf.WriteString(s) -} - -func (p *TFramedTransport) Flush() error { - size := p.buf.Len() - buf := p.buffer[:4] - binary.BigEndian.PutUint32(buf, uint32(size)) - _, err := p.transport.Write(buf) - if err != nil { - return NewTTransportExceptionFromError(err) - } - if size > 0 { - if n, err := p.buf.WriteTo(p.transport); err != nil { - print("Error while flushing write buffer of size ", size, " to transport, only wrote ", n, " bytes: ", err.Error(), "\n") - return NewTTransportExceptionFromError(err) - } - } - err = p.transport.Flush() - return NewTTransportExceptionFromError(err) -} - -func (p *TFramedTransport) readFrameHeader() (uint32, error) { - buf := p.buffer[:4] - if _, err := io.ReadFull(p.reader, buf); err != nil { - return 0, err - } - size := binary.BigEndian.Uint32(buf) - if size < 0 || size > p.maxLength { - return 0, NewTTransportException(UNKNOWN_TRANSPORT_EXCEPTION, fmt.Sprintf("Incorrect frame size (%d)", size)) - } - return size, nil -} - -func (p *TFramedTransport) RemainingBytes() (num_bytes uint64) { - return uint64(p.frameSize) -} - diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/http_client.go b/vendor/github.com/apache/thrift/lib/go/thrift/http_client.go deleted file mode 100644 index 88eb2c1..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/http_client.go +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package thrift - -import ( - "bytes" - "io" - "io/ioutil" - "net/http" - "net/url" - "strconv" -) - -// Default to using the shared http client. Library users are -// free to change this global client or specify one through -// THttpClientOptions. -var DefaultHttpClient *http.Client = http.DefaultClient - -type THttpClient struct { - client *http.Client - response *http.Response - url *url.URL - requestBuffer *bytes.Buffer - header http.Header - nsecConnectTimeout int64 - nsecReadTimeout int64 -} - -type THttpClientTransportFactory struct { - options THttpClientOptions - url string - isPost bool -} - -func (p *THttpClientTransportFactory) GetTransport(trans TTransport) TTransport { - if trans != nil { - t, ok := trans.(*THttpClient) - if ok && t.url != nil { - if t.requestBuffer != nil { - t2, _ := NewTHttpPostClientWithOptions(t.url.String(), p.options) - return t2 - } - t2, _ := NewTHttpClientWithOptions(t.url.String(), p.options) - return t2 - } - } - if p.isPost { - s, _ := NewTHttpPostClientWithOptions(p.url, p.options) - return s - } - s, _ := NewTHttpClientWithOptions(p.url, p.options) - return s -} - -type THttpClientOptions struct { - // If nil, DefaultHttpClient is used - Client *http.Client -} - -func NewTHttpClientTransportFactory(url string) *THttpClientTransportFactory { - return NewTHttpClientTransportFactoryWithOptions(url, THttpClientOptions{}) -} - -func NewTHttpClientTransportFactoryWithOptions(url string, options THttpClientOptions) *THttpClientTransportFactory { - return &THttpClientTransportFactory{url: url, isPost: false, options: options} -} - -func NewTHttpPostClientTransportFactory(url string) *THttpClientTransportFactory { - return NewTHttpPostClientTransportFactoryWithOptions(url, THttpClientOptions{}) -} - -func NewTHttpPostClientTransportFactoryWithOptions(url string, options THttpClientOptions) *THttpClientTransportFactory { - return &THttpClientTransportFactory{url: url, isPost: true, options: options} -} - -func NewTHttpClientWithOptions(urlstr string, options THttpClientOptions) (TTransport, error) { - parsedURL, err := url.Parse(urlstr) - if err != nil { - return nil, err - } - response, err := http.Get(urlstr) - if err != nil { - return nil, err - } - client := options.Client - if client == nil { - client = DefaultHttpClient - } - httpHeader := map[string][]string{"Content-Type": []string{"application/x-thrift"}} - return &THttpClient{client: client, response: response, url: parsedURL, header: httpHeader}, nil -} - -func NewTHttpClient(urlstr string) (TTransport, error) { - return NewTHttpClientWithOptions(urlstr, THttpClientOptions{}) -} - -func NewTHttpPostClientWithOptions(urlstr string, options THttpClientOptions) (TTransport, error) { - parsedURL, err := url.Parse(urlstr) - if err != nil { - return nil, err - } - buf := make([]byte, 0, 1024) - client := options.Client - if client == nil { - client = DefaultHttpClient - } - httpHeader := map[string][]string{"Content-Type": []string{"application/x-thrift"}} - return &THttpClient{client: client, url: parsedURL, requestBuffer: bytes.NewBuffer(buf), header: httpHeader}, nil -} - -func NewTHttpPostClient(urlstr string) (TTransport, error) { - return NewTHttpPostClientWithOptions(urlstr, THttpClientOptions{}) -} - -// Set the HTTP Header for this specific Thrift Transport -// It is important that you first assert the TTransport as a THttpClient type -// like so: -// -// httpTrans := trans.(THttpClient) -// httpTrans.SetHeader("User-Agent","Thrift Client 1.0") -func (p *THttpClient) SetHeader(key string, value string) { - p.header.Add(key, value) -} - -// Get the HTTP Header represented by the supplied Header Key for this specific Thrift Transport -// It is important that you first assert the TTransport as a THttpClient type -// like so: -// -// httpTrans := trans.(THttpClient) -// hdrValue := httpTrans.GetHeader("User-Agent") -func (p *THttpClient) GetHeader(key string) string { - return p.header.Get(key) -} - -// Deletes the HTTP Header given a Header Key for this specific Thrift Transport -// It is important that you first assert the TTransport as a THttpClient type -// like so: -// -// httpTrans := trans.(THttpClient) -// httpTrans.DelHeader("User-Agent") -func (p *THttpClient) DelHeader(key string) { - p.header.Del(key) -} - -func (p *THttpClient) Open() error { - // do nothing - return nil -} - -func (p *THttpClient) IsOpen() bool { - return p.response != nil || p.requestBuffer != nil -} - -func (p *THttpClient) closeResponse() error { - var err error - if p.response != nil && p.response.Body != nil { - // The docs specify that if keepalive is enabled and the response body is not - // read to completion the connection will never be returned to the pool and - // reused. Errors are being ignored here because if the connection is invalid - // and this fails for some reason, the Close() method will do any remaining - // cleanup. - io.Copy(ioutil.Discard, p.response.Body) - - err = p.response.Body.Close() - } - - p.response = nil - return err -} - -func (p *THttpClient) Close() error { - if p.requestBuffer != nil { - p.requestBuffer.Reset() - p.requestBuffer = nil - } - return p.closeResponse() -} - -func (p *THttpClient) Read(buf []byte) (int, error) { - if p.response == nil { - return 0, NewTTransportException(NOT_OPEN, "Response buffer is empty, no request.") - } - n, err := p.response.Body.Read(buf) - if n > 0 && (err == nil || err == io.EOF) { - return n, nil - } - return n, NewTTransportExceptionFromError(err) -} - -func (p *THttpClient) ReadByte() (c byte, err error) { - return readByte(p.response.Body) -} - -func (p *THttpClient) Write(buf []byte) (int, error) { - n, err := p.requestBuffer.Write(buf) - return n, err -} - -func (p *THttpClient) WriteByte(c byte) error { - return p.requestBuffer.WriteByte(c) -} - -func (p *THttpClient) WriteString(s string) (n int, err error) { - return p.requestBuffer.WriteString(s) -} - -func (p *THttpClient) Flush() error { - // Close any previous response body to avoid leaking connections. - p.closeResponse() - - req, err := http.NewRequest("POST", p.url.String(), p.requestBuffer) - if err != nil { - return NewTTransportExceptionFromError(err) - } - req.Header = p.header - response, err := p.client.Do(req) - if err != nil { - return NewTTransportExceptionFromError(err) - } - if response.StatusCode != http.StatusOK { - // Close the response to avoid leaking file descriptors. closeResponse does - // more than just call Close(), so temporarily assign it and reuse the logic. - p.response = response - p.closeResponse() - - // TODO(pomack) log bad response - return NewTTransportException(UNKNOWN_TRANSPORT_EXCEPTION, "HTTP Response code: "+strconv.Itoa(response.StatusCode)) - } - p.response = response - return nil -} - -func (p *THttpClient) RemainingBytes() (num_bytes uint64) { - len := p.response.ContentLength - if len >= 0 { - return uint64(len) - } - - const maxSize = ^uint64(0) - return maxSize // the thruth is, we just don't know unless framed is used -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/http_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/http_transport.go deleted file mode 100644 index f6d7458..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/http_transport.go +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package thrift - -import "net/http" - -// NewThriftHandlerFunc is a function that create a ready to use Apache Thrift Handler function -func NewThriftHandlerFunc(processor TProcessor, - inPfactory, outPfactory TProtocolFactory) func(w http.ResponseWriter, r *http.Request) { - - return func(w http.ResponseWriter, r *http.Request) { - w.Header().Add("Content-Type", "application/x-thrift") - - transport := NewStreamTransport(r.Body, w) - processor.Process(inPfactory.GetProtocol(transport), outPfactory.GetProtocol(transport)) - } -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/iostream_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/iostream_transport.go deleted file mode 100644 index 794872f..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/iostream_transport.go +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package thrift - -import ( - "bufio" - "io" -) - -// StreamTransport is a Transport made of an io.Reader and/or an io.Writer -type StreamTransport struct { - io.Reader - io.Writer - isReadWriter bool - closed bool -} - -type StreamTransportFactory struct { - Reader io.Reader - Writer io.Writer - isReadWriter bool -} - -func (p *StreamTransportFactory) GetTransport(trans TTransport) TTransport { - if trans != nil { - t, ok := trans.(*StreamTransport) - if ok { - if t.isReadWriter { - return NewStreamTransportRW(t.Reader.(io.ReadWriter)) - } - if t.Reader != nil && t.Writer != nil { - return NewStreamTransport(t.Reader, t.Writer) - } - if t.Reader != nil && t.Writer == nil { - return NewStreamTransportR(t.Reader) - } - if t.Reader == nil && t.Writer != nil { - return NewStreamTransportW(t.Writer) - } - return &StreamTransport{} - } - } - if p.isReadWriter { - return NewStreamTransportRW(p.Reader.(io.ReadWriter)) - } - if p.Reader != nil && p.Writer != nil { - return NewStreamTransport(p.Reader, p.Writer) - } - if p.Reader != nil && p.Writer == nil { - return NewStreamTransportR(p.Reader) - } - if p.Reader == nil && p.Writer != nil { - return NewStreamTransportW(p.Writer) - } - return &StreamTransport{} -} - -func NewStreamTransportFactory(reader io.Reader, writer io.Writer, isReadWriter bool) *StreamTransportFactory { - return &StreamTransportFactory{Reader: reader, Writer: writer, isReadWriter: isReadWriter} -} - -func NewStreamTransport(r io.Reader, w io.Writer) *StreamTransport { - return &StreamTransport{Reader: bufio.NewReader(r), Writer: bufio.NewWriter(w)} -} - -func NewStreamTransportR(r io.Reader) *StreamTransport { - return &StreamTransport{Reader: bufio.NewReader(r)} -} - -func NewStreamTransportW(w io.Writer) *StreamTransport { - return &StreamTransport{Writer: bufio.NewWriter(w)} -} - -func NewStreamTransportRW(rw io.ReadWriter) *StreamTransport { - bufrw := bufio.NewReadWriter(bufio.NewReader(rw), bufio.NewWriter(rw)) - return &StreamTransport{Reader: bufrw, Writer: bufrw, isReadWriter: true} -} - -func (p *StreamTransport) IsOpen() bool { - return !p.closed -} - -// implicitly opened on creation, can't be reopened once closed -func (p *StreamTransport) Open() error { - if !p.closed { - return NewTTransportException(ALREADY_OPEN, "StreamTransport already open.") - } else { - return NewTTransportException(NOT_OPEN, "cannot reopen StreamTransport.") - } -} - -// Closes both the input and output streams. -func (p *StreamTransport) Close() error { - if p.closed { - return NewTTransportException(NOT_OPEN, "StreamTransport already closed.") - } - p.closed = true - closedReader := false - if p.Reader != nil { - c, ok := p.Reader.(io.Closer) - if ok { - e := c.Close() - closedReader = true - if e != nil { - return e - } - } - p.Reader = nil - } - if p.Writer != nil && (!closedReader || !p.isReadWriter) { - c, ok := p.Writer.(io.Closer) - if ok { - e := c.Close() - if e != nil { - return e - } - } - p.Writer = nil - } - return nil -} - -// Flushes the underlying output stream if not null. -func (p *StreamTransport) Flush() error { - if p.Writer == nil { - return NewTTransportException(NOT_OPEN, "Cannot flush null outputStream") - } - f, ok := p.Writer.(Flusher) - if ok { - err := f.Flush() - if err != nil { - return NewTTransportExceptionFromError(err) - } - } - return nil -} - -func (p *StreamTransport) Read(c []byte) (n int, err error) { - n, err = p.Reader.Read(c) - if err != nil { - err = NewTTransportExceptionFromError(err) - } - return -} - -func (p *StreamTransport) ReadByte() (c byte, err error) { - f, ok := p.Reader.(io.ByteReader) - if ok { - c, err = f.ReadByte() - } else { - c, err = readByte(p.Reader) - } - if err != nil { - err = NewTTransportExceptionFromError(err) - } - return -} - -func (p *StreamTransport) Write(c []byte) (n int, err error) { - n, err = p.Writer.Write(c) - if err != nil { - err = NewTTransportExceptionFromError(err) - } - return -} - -func (p *StreamTransport) WriteByte(c byte) (err error) { - f, ok := p.Writer.(io.ByteWriter) - if ok { - err = f.WriteByte(c) - } else { - err = writeByte(p.Writer, c) - } - if err != nil { - err = NewTTransportExceptionFromError(err) - } - return -} - -func (p *StreamTransport) WriteString(s string) (n int, err error) { - f, ok := p.Writer.(stringWriter) - if ok { - n, err = f.WriteString(s) - } else { - n, err = p.Writer.Write([]byte(s)) - } - if err != nil { - err = NewTTransportExceptionFromError(err) - } - return -} - -func (p *StreamTransport) RemainingBytes() (num_bytes uint64) { - const maxSize = ^uint64(0) - return maxSize // the thruth is, we just don't know unless framed is used -} - diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/json_protocol.go b/vendor/github.com/apache/thrift/lib/go/thrift/json_protocol.go deleted file mode 100644 index 442fa91..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/json_protocol.go +++ /dev/null @@ -1,583 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package thrift - -import ( - "encoding/base64" - "fmt" -) - -const ( - THRIFT_JSON_PROTOCOL_VERSION = 1 -) - -// for references to _ParseContext see tsimplejson_protocol.go - -// JSON protocol implementation for thrift. -// -// This protocol produces/consumes a simple output format -// suitable for parsing by scripting languages. It should not be -// confused with the full-featured TJSONProtocol. -// -type TJSONProtocol struct { - *TSimpleJSONProtocol -} - -// Constructor -func NewTJSONProtocol(t TTransport) *TJSONProtocol { - v := &TJSONProtocol{TSimpleJSONProtocol: NewTSimpleJSONProtocol(t)} - v.parseContextStack = append(v.parseContextStack, int(_CONTEXT_IN_TOPLEVEL)) - v.dumpContext = append(v.dumpContext, int(_CONTEXT_IN_TOPLEVEL)) - return v -} - -// Factory -type TJSONProtocolFactory struct{} - -func (p *TJSONProtocolFactory) GetProtocol(trans TTransport) TProtocol { - return NewTJSONProtocol(trans) -} - -func NewTJSONProtocolFactory() *TJSONProtocolFactory { - return &TJSONProtocolFactory{} -} - -func (p *TJSONProtocol) WriteMessageBegin(name string, typeId TMessageType, seqId int32) error { - p.resetContextStack() // THRIFT-3735 - if e := p.OutputListBegin(); e != nil { - return e - } - if e := p.WriteI32(THRIFT_JSON_PROTOCOL_VERSION); e != nil { - return e - } - if e := p.WriteString(name); e != nil { - return e - } - if e := p.WriteByte(int8(typeId)); e != nil { - return e - } - if e := p.WriteI32(seqId); e != nil { - return e - } - return nil -} - -func (p *TJSONProtocol) WriteMessageEnd() error { - return p.OutputListEnd() -} - -func (p *TJSONProtocol) WriteStructBegin(name string) error { - if e := p.OutputObjectBegin(); e != nil { - return e - } - return nil -} - -func (p *TJSONProtocol) WriteStructEnd() error { - return p.OutputObjectEnd() -} - -func (p *TJSONProtocol) WriteFieldBegin(name string, typeId TType, id int16) error { - if e := p.WriteI16(id); e != nil { - return e - } - if e := p.OutputObjectBegin(); e != nil { - return e - } - s, e1 := p.TypeIdToString(typeId) - if e1 != nil { - return e1 - } - if e := p.WriteString(s); e != nil { - return e - } - return nil -} - -func (p *TJSONProtocol) WriteFieldEnd() error { - return p.OutputObjectEnd() -} - -func (p *TJSONProtocol) WriteFieldStop() error { return nil } - -func (p *TJSONProtocol) WriteMapBegin(keyType TType, valueType TType, size int) error { - if e := p.OutputListBegin(); e != nil { - return e - } - s, e1 := p.TypeIdToString(keyType) - if e1 != nil { - return e1 - } - if e := p.WriteString(s); e != nil { - return e - } - s, e1 = p.TypeIdToString(valueType) - if e1 != nil { - return e1 - } - if e := p.WriteString(s); e != nil { - return e - } - if e := p.WriteI64(int64(size)); e != nil { - return e - } - return p.OutputObjectBegin() -} - -func (p *TJSONProtocol) WriteMapEnd() error { - if e := p.OutputObjectEnd(); e != nil { - return e - } - return p.OutputListEnd() -} - -func (p *TJSONProtocol) WriteListBegin(elemType TType, size int) error { - return p.OutputElemListBegin(elemType, size) -} - -func (p *TJSONProtocol) WriteListEnd() error { - return p.OutputListEnd() -} - -func (p *TJSONProtocol) WriteSetBegin(elemType TType, size int) error { - return p.OutputElemListBegin(elemType, size) -} - -func (p *TJSONProtocol) WriteSetEnd() error { - return p.OutputListEnd() -} - -func (p *TJSONProtocol) WriteBool(b bool) error { - if b { - return p.WriteI32(1) - } - return p.WriteI32(0) -} - -func (p *TJSONProtocol) WriteByte(b int8) error { - return p.WriteI32(int32(b)) -} - -func (p *TJSONProtocol) WriteI16(v int16) error { - return p.WriteI32(int32(v)) -} - -func (p *TJSONProtocol) WriteI32(v int32) error { - return p.OutputI64(int64(v)) -} - -func (p *TJSONProtocol) WriteI64(v int64) error { - return p.OutputI64(int64(v)) -} - -func (p *TJSONProtocol) WriteDouble(v float64) error { - return p.OutputF64(v) -} - -func (p *TJSONProtocol) WriteString(v string) error { - return p.OutputString(v) -} - -func (p *TJSONProtocol) WriteBinary(v []byte) error { - // JSON library only takes in a string, - // not an arbitrary byte array, to ensure bytes are transmitted - // efficiently we must convert this into a valid JSON string - // therefore we use base64 encoding to avoid excessive escaping/quoting - if e := p.OutputPreValue(); e != nil { - return e - } - if _, e := p.write(JSON_QUOTE_BYTES); e != nil { - return NewTProtocolException(e) - } - writer := base64.NewEncoder(base64.StdEncoding, p.writer) - if _, e := writer.Write(v); e != nil { - p.writer.Reset(p.trans) // THRIFT-3735 - return NewTProtocolException(e) - } - if e := writer.Close(); e != nil { - return NewTProtocolException(e) - } - if _, e := p.write(JSON_QUOTE_BYTES); e != nil { - return NewTProtocolException(e) - } - return p.OutputPostValue() -} - -// Reading methods. -func (p *TJSONProtocol) ReadMessageBegin() (name string, typeId TMessageType, seqId int32, err error) { - p.resetContextStack() // THRIFT-3735 - if isNull, err := p.ParseListBegin(); isNull || err != nil { - return name, typeId, seqId, err - } - version, err := p.ReadI32() - if err != nil { - return name, typeId, seqId, err - } - if version != THRIFT_JSON_PROTOCOL_VERSION { - e := fmt.Errorf("Unknown Protocol version %d, expected version %d", version, THRIFT_JSON_PROTOCOL_VERSION) - return name, typeId, seqId, NewTProtocolExceptionWithType(INVALID_DATA, e) - - } - if name, err = p.ReadString(); err != nil { - return name, typeId, seqId, err - } - bTypeId, err := p.ReadByte() - typeId = TMessageType(bTypeId) - if err != nil { - return name, typeId, seqId, err - } - if seqId, err = p.ReadI32(); err != nil { - return name, typeId, seqId, err - } - return name, typeId, seqId, nil -} - -func (p *TJSONProtocol) ReadMessageEnd() error { - err := p.ParseListEnd() - return err -} - -func (p *TJSONProtocol) ReadStructBegin() (name string, err error) { - _, err = p.ParseObjectStart() - return "", err -} - -func (p *TJSONProtocol) ReadStructEnd() error { - return p.ParseObjectEnd() -} - -func (p *TJSONProtocol) ReadFieldBegin() (string, TType, int16, error) { - b, _ := p.reader.Peek(1) - if len(b) < 1 || b[0] == JSON_RBRACE[0] || b[0] == JSON_RBRACKET[0] { - return "", STOP, -1, nil - } - fieldId, err := p.ReadI16() - if err != nil { - return "", STOP, fieldId, err - } - if _, err = p.ParseObjectStart(); err != nil { - return "", STOP, fieldId, err - } - sType, err := p.ReadString() - if err != nil { - return "", STOP, fieldId, err - } - fType, err := p.StringToTypeId(sType) - return "", fType, fieldId, err -} - -func (p *TJSONProtocol) ReadFieldEnd() error { - return p.ParseObjectEnd() -} - -func (p *TJSONProtocol) ReadMapBegin() (keyType TType, valueType TType, size int, e error) { - if isNull, e := p.ParseListBegin(); isNull || e != nil { - return VOID, VOID, 0, e - } - - // read keyType - sKeyType, e := p.ReadString() - if e != nil { - return keyType, valueType, size, e - } - keyType, e = p.StringToTypeId(sKeyType) - if e != nil { - return keyType, valueType, size, e - } - - // read valueType - sValueType, e := p.ReadString() - if e != nil { - return keyType, valueType, size, e - } - valueType, e = p.StringToTypeId(sValueType) - if e != nil { - return keyType, valueType, size, e - } - - // read size - iSize, e := p.ReadI64() - if e != nil { - return keyType, valueType, size, e - } - size = int(iSize) - - _, e = p.ParseObjectStart() - return keyType, valueType, size, e -} - -func (p *TJSONProtocol) ReadMapEnd() error { - e := p.ParseObjectEnd() - if e != nil { - return e - } - return p.ParseListEnd() -} - -func (p *TJSONProtocol) ReadListBegin() (elemType TType, size int, e error) { - return p.ParseElemListBegin() -} - -func (p *TJSONProtocol) ReadListEnd() error { - return p.ParseListEnd() -} - -func (p *TJSONProtocol) ReadSetBegin() (elemType TType, size int, e error) { - return p.ParseElemListBegin() -} - -func (p *TJSONProtocol) ReadSetEnd() error { - return p.ParseListEnd() -} - -func (p *TJSONProtocol) ReadBool() (bool, error) { - value, err := p.ReadI32() - return (value != 0), err -} - -func (p *TJSONProtocol) ReadByte() (int8, error) { - v, err := p.ReadI64() - return int8(v), err -} - -func (p *TJSONProtocol) ReadI16() (int16, error) { - v, err := p.ReadI64() - return int16(v), err -} - -func (p *TJSONProtocol) ReadI32() (int32, error) { - v, err := p.ReadI64() - return int32(v), err -} - -func (p *TJSONProtocol) ReadI64() (int64, error) { - v, _, err := p.ParseI64() - return v, err -} - -func (p *TJSONProtocol) ReadDouble() (float64, error) { - v, _, err := p.ParseF64() - return v, err -} - -func (p *TJSONProtocol) ReadString() (string, error) { - var v string - if err := p.ParsePreValue(); err != nil { - return v, err - } - f, _ := p.reader.Peek(1) - if len(f) > 0 && f[0] == JSON_QUOTE { - p.reader.ReadByte() - value, err := p.ParseStringBody() - v = value - if err != nil { - return v, err - } - } else if len(f) > 0 && f[0] == JSON_NULL[0] { - b := make([]byte, len(JSON_NULL)) - _, err := p.reader.Read(b) - if err != nil { - return v, NewTProtocolException(err) - } - if string(b) != string(JSON_NULL) { - e := fmt.Errorf("Expected a JSON string, found unquoted data started with %s", string(b)) - return v, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - } else { - e := fmt.Errorf("Expected a JSON string, found unquoted data started with %s", string(f)) - return v, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - return v, p.ParsePostValue() -} - -func (p *TJSONProtocol) ReadBinary() ([]byte, error) { - var v []byte - if err := p.ParsePreValue(); err != nil { - return nil, err - } - f, _ := p.reader.Peek(1) - if len(f) > 0 && f[0] == JSON_QUOTE { - p.reader.ReadByte() - value, err := p.ParseBase64EncodedBody() - v = value - if err != nil { - return v, err - } - } else if len(f) > 0 && f[0] == JSON_NULL[0] { - b := make([]byte, len(JSON_NULL)) - _, err := p.reader.Read(b) - if err != nil { - return v, NewTProtocolException(err) - } - if string(b) != string(JSON_NULL) { - e := fmt.Errorf("Expected a JSON string, found unquoted data started with %s", string(b)) - return v, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - } else { - e := fmt.Errorf("Expected a JSON string, found unquoted data started with %s", string(f)) - return v, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - - return v, p.ParsePostValue() -} - -func (p *TJSONProtocol) Flush() (err error) { - err = p.writer.Flush() - if err == nil { - err = p.trans.Flush() - } - return NewTProtocolException(err) -} - -func (p *TJSONProtocol) Skip(fieldType TType) (err error) { - return SkipDefaultDepth(p, fieldType) -} - -func (p *TJSONProtocol) Transport() TTransport { - return p.trans -} - -func (p *TJSONProtocol) OutputElemListBegin(elemType TType, size int) error { - if e := p.OutputListBegin(); e != nil { - return e - } - s, e1 := p.TypeIdToString(elemType) - if e1 != nil { - return e1 - } - if e := p.WriteString(s); e != nil { - return e - } - if e := p.WriteI64(int64(size)); e != nil { - return e - } - return nil -} - -func (p *TJSONProtocol) ParseElemListBegin() (elemType TType, size int, e error) { - if isNull, e := p.ParseListBegin(); isNull || e != nil { - return VOID, 0, e - } - sElemType, err := p.ReadString() - if err != nil { - return VOID, size, err - } - elemType, err = p.StringToTypeId(sElemType) - if err != nil { - return elemType, size, err - } - nSize, err2 := p.ReadI64() - size = int(nSize) - return elemType, size, err2 -} - -func (p *TJSONProtocol) readElemListBegin() (elemType TType, size int, e error) { - if isNull, e := p.ParseListBegin(); isNull || e != nil { - return VOID, 0, e - } - sElemType, err := p.ReadString() - if err != nil { - return VOID, size, err - } - elemType, err = p.StringToTypeId(sElemType) - if err != nil { - return elemType, size, err - } - nSize, err2 := p.ReadI64() - size = int(nSize) - return elemType, size, err2 -} - -func (p *TJSONProtocol) writeElemListBegin(elemType TType, size int) error { - if e := p.OutputListBegin(); e != nil { - return e - } - s, e1 := p.TypeIdToString(elemType) - if e1 != nil { - return e1 - } - if e := p.OutputString(s); e != nil { - return e - } - if e := p.OutputI64(int64(size)); e != nil { - return e - } - return nil -} - -func (p *TJSONProtocol) TypeIdToString(fieldType TType) (string, error) { - switch byte(fieldType) { - case BOOL: - return "tf", nil - case BYTE: - return "i8", nil - case I16: - return "i16", nil - case I32: - return "i32", nil - case I64: - return "i64", nil - case DOUBLE: - return "dbl", nil - case STRING: - return "str", nil - case STRUCT: - return "rec", nil - case MAP: - return "map", nil - case SET: - return "set", nil - case LIST: - return "lst", nil - } - - e := fmt.Errorf("Unknown fieldType: %d", int(fieldType)) - return "", NewTProtocolExceptionWithType(INVALID_DATA, e) -} - -func (p *TJSONProtocol) StringToTypeId(fieldType string) (TType, error) { - switch fieldType { - case "tf": - return TType(BOOL), nil - case "i8": - return TType(BYTE), nil - case "i16": - return TType(I16), nil - case "i32": - return TType(I32), nil - case "i64": - return TType(I64), nil - case "dbl": - return TType(DOUBLE), nil - case "str": - return TType(STRING), nil - case "rec": - return TType(STRUCT), nil - case "map": - return TType(MAP), nil - case "set": - return TType(SET), nil - case "lst": - return TType(LIST), nil - } - - e := fmt.Errorf("Unknown type identifier: %s", fieldType) - return TType(STOP), NewTProtocolExceptionWithType(INVALID_DATA, e) -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/multiplexed_protocol.go b/vendor/github.com/apache/thrift/lib/go/thrift/multiplexed_protocol.go deleted file mode 100644 index 3157e0d..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/multiplexed_protocol.go +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package thrift - -import ( - "fmt" - "strings" -) - -/* -TMultiplexedProtocol is a protocol-independent concrete decorator -that allows a Thrift client to communicate with a multiplexing Thrift server, -by prepending the service name to the function name during function calls. - -NOTE: THIS IS NOT USED BY SERVERS. On the server, use TMultiplexedProcessor to handle request -from a multiplexing client. - -This example uses a single socket transport to invoke two services: - -socket := thrift.NewTSocketFromAddrTimeout(addr, TIMEOUT) -transport := thrift.NewTFramedTransport(socket) -protocol := thrift.NewTBinaryProtocolTransport(transport) - -mp := thrift.NewTMultiplexedProtocol(protocol, "Calculator") -service := Calculator.NewCalculatorClient(mp) - -mp2 := thrift.NewTMultiplexedProtocol(protocol, "WeatherReport") -service2 := WeatherReport.NewWeatherReportClient(mp2) - -err := transport.Open() -if err != nil { - t.Fatal("Unable to open client socket", err) -} - -fmt.Println(service.Add(2,2)) -fmt.Println(service2.GetTemperature()) -*/ - -type TMultiplexedProtocol struct { - TProtocol - serviceName string -} - -const MULTIPLEXED_SEPARATOR = ":" - -func NewTMultiplexedProtocol(protocol TProtocol, serviceName string) *TMultiplexedProtocol { - return &TMultiplexedProtocol{ - TProtocol: protocol, - serviceName: serviceName, - } -} - -func (t *TMultiplexedProtocol) WriteMessageBegin(name string, typeId TMessageType, seqid int32) error { - if typeId == CALL || typeId == ONEWAY { - return t.TProtocol.WriteMessageBegin(t.serviceName+MULTIPLEXED_SEPARATOR+name, typeId, seqid) - } else { - return t.TProtocol.WriteMessageBegin(name, typeId, seqid) - } -} - -/* -TMultiplexedProcessor is a TProcessor allowing -a single TServer to provide multiple services. - -To do so, you instantiate the processor and then register additional -processors with it, as shown in the following example: - -var processor = thrift.NewTMultiplexedProcessor() - -firstProcessor := -processor.RegisterProcessor("FirstService", firstProcessor) - -processor.registerProcessor( - "Calculator", - Calculator.NewCalculatorProcessor(&CalculatorHandler{}), -) - -processor.registerProcessor( - "WeatherReport", - WeatherReport.NewWeatherReportProcessor(&WeatherReportHandler{}), -) - -serverTransport, err := thrift.NewTServerSocketTimeout(addr, TIMEOUT) -if err != nil { - t.Fatal("Unable to create server socket", err) -} -server := thrift.NewTSimpleServer2(processor, serverTransport) -server.Serve(); -*/ - -type TMultiplexedProcessor struct { - serviceProcessorMap map[string]TProcessor - DefaultProcessor TProcessor -} - -func NewTMultiplexedProcessor() *TMultiplexedProcessor { - return &TMultiplexedProcessor{ - serviceProcessorMap: make(map[string]TProcessor), - } -} - -func (t *TMultiplexedProcessor) RegisterDefault(processor TProcessor) { - t.DefaultProcessor = processor -} - -func (t *TMultiplexedProcessor) RegisterProcessor(name string, processor TProcessor) { - if t.serviceProcessorMap == nil { - t.serviceProcessorMap = make(map[string]TProcessor) - } - t.serviceProcessorMap[name] = processor -} - -func (t *TMultiplexedProcessor) Process(in, out TProtocol) (bool, TException) { - name, typeId, seqid, err := in.ReadMessageBegin() - if err != nil { - return false, err - } - if typeId != CALL && typeId != ONEWAY { - return false, fmt.Errorf("Unexpected message type %v", typeId) - } - //extract the service name - v := strings.SplitN(name, MULTIPLEXED_SEPARATOR, 2) - if len(v) != 2 { - if t.DefaultProcessor != nil { - smb := NewStoredMessageProtocol(in, name, typeId, seqid) - return t.DefaultProcessor.Process(smb, out) - } - return false, fmt.Errorf("Service name not found in message name: %s. Did you forget to use a TMultiplexProtocol in your client?", name) - } - actualProcessor, ok := t.serviceProcessorMap[v[0]] - if !ok { - return false, fmt.Errorf("Service name not found: %s. Did you forget to call registerProcessor()?", v[0]) - } - smb := NewStoredMessageProtocol(in, v[1], typeId, seqid) - return actualProcessor.Process(smb, out) -} - -//Protocol that use stored message for ReadMessageBegin -type storedMessageProtocol struct { - TProtocol - name string - typeId TMessageType - seqid int32 -} - -func NewStoredMessageProtocol(protocol TProtocol, name string, typeId TMessageType, seqid int32) *storedMessageProtocol { - return &storedMessageProtocol{protocol, name, typeId, seqid} -} - -func (s *storedMessageProtocol) ReadMessageBegin() (name string, typeId TMessageType, seqid int32, err error) { - return s.name, s.typeId, s.seqid, nil -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/pointerize.go b/vendor/github.com/apache/thrift/lib/go/thrift/pointerize.go deleted file mode 100644 index 8d6b2c2..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/pointerize.go +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package thrift - -/////////////////////////////////////////////////////////////////////////////// -// This file is home to helpers that convert from various base types to -// respective pointer types. This is necessary because Go does not permit -// references to constants, nor can a pointer type to base type be allocated -// and initialized in a single expression. -// -// E.g., this is not allowed: -// -// var ip *int = &5 -// -// But this *is* allowed: -// -// func IntPtr(i int) *int { return &i } -// var ip *int = IntPtr(5) -// -// Since pointers to base types are commonplace as [optional] fields in -// exported thrift structs, we factor such helpers here. -/////////////////////////////////////////////////////////////////////////////// - -func Float32Ptr(v float32) *float32 { return &v } -func Float64Ptr(v float64) *float64 { return &v } -func IntPtr(v int) *int { return &v } -func Int32Ptr(v int32) *int32 { return &v } -func Int64Ptr(v int64) *int64 { return &v } -func StringPtr(v string) *string { return &v } -func Uint32Ptr(v uint32) *uint32 { return &v } -func Uint64Ptr(v uint64) *uint64 { return &v } -func BoolPtr(v bool) *bool { return &v } -func ByteSlicePtr(v []byte) *[]byte { return &v } diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/processor_factory.go b/vendor/github.com/apache/thrift/lib/go/thrift/processor_factory.go deleted file mode 100644 index 9d645df..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/processor_factory.go +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package thrift - -// The default processor factory just returns a singleton -// instance. -type TProcessorFactory interface { - GetProcessor(trans TTransport) TProcessor -} - -type tProcessorFactory struct { - processor TProcessor -} - -func NewTProcessorFactory(p TProcessor) TProcessorFactory { - return &tProcessorFactory{processor: p} -} - -func (p *tProcessorFactory) GetProcessor(trans TTransport) TProcessor { - return p.processor -} - -/** - * The default processor factory just returns a singleton - * instance. - */ -type TProcessorFunctionFactory interface { - GetProcessorFunction(trans TTransport) TProcessorFunction -} - -type tProcessorFunctionFactory struct { - processor TProcessorFunction -} - -func NewTProcessorFunctionFactory(p TProcessorFunction) TProcessorFunctionFactory { - return &tProcessorFunctionFactory{processor: p} -} - -func (p *tProcessorFunctionFactory) GetProcessorFunction(trans TTransport) TProcessorFunction { - return p.processor -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/server.go b/vendor/github.com/apache/thrift/lib/go/thrift/server.go deleted file mode 100644 index f813fa3..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/server.go +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package thrift - -type TServer interface { - ProcessorFactory() TProcessorFactory - ServerTransport() TServerTransport - InputTransportFactory() TTransportFactory - OutputTransportFactory() TTransportFactory - InputProtocolFactory() TProtocolFactory - OutputProtocolFactory() TProtocolFactory - - // Starts the server - Serve() error - // Stops the server. This is optional on a per-implementation basis. Not - // all servers are required to be cleanly stoppable. - Stop() error -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/server_socket.go b/vendor/github.com/apache/thrift/lib/go/thrift/server_socket.go deleted file mode 100644 index d6e9495..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/server_socket.go +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package thrift - -import ( - "net" - "sync" - "time" -) - -type TServerSocket struct { - listener net.Listener - addr net.Addr - clientTimeout time.Duration - - // Protects the interrupted value to make it thread safe. - mu sync.RWMutex - interrupted bool -} - -func NewTServerSocket(listenAddr string) (*TServerSocket, error) { - return NewTServerSocketTimeout(listenAddr, 0) -} - -func NewTServerSocketTimeout(listenAddr string, clientTimeout time.Duration) (*TServerSocket, error) { - addr, err := net.ResolveTCPAddr("tcp", listenAddr) - if err != nil { - return nil, err - } - return &TServerSocket{addr: addr, clientTimeout: clientTimeout}, nil -} - -func (p *TServerSocket) Listen() error { - if p.IsListening() { - return nil - } - l, err := net.Listen(p.addr.Network(), p.addr.String()) - if err != nil { - return err - } - p.listener = l - return nil -} - -func (p *TServerSocket) Accept() (TTransport, error) { - p.mu.RLock() - interrupted := p.interrupted - p.mu.RUnlock() - - if interrupted { - return nil, errTransportInterrupted - } - if p.listener == nil { - return nil, NewTTransportException(NOT_OPEN, "No underlying server socket") - } - conn, err := p.listener.Accept() - if err != nil { - return nil, NewTTransportExceptionFromError(err) - } - return NewTSocketFromConnTimeout(conn, p.clientTimeout), nil -} - -// Checks whether the socket is listening. -func (p *TServerSocket) IsListening() bool { - return p.listener != nil -} - -// Connects the socket, creating a new socket object if necessary. -func (p *TServerSocket) Open() error { - if p.IsListening() { - return NewTTransportException(ALREADY_OPEN, "Server socket already open") - } - if l, err := net.Listen(p.addr.Network(), p.addr.String()); err != nil { - return err - } else { - p.listener = l - } - return nil -} - -func (p *TServerSocket) Addr() net.Addr { - if p.listener != nil { - return p.listener.Addr() - } - return p.addr -} - -func (p *TServerSocket) Close() error { - defer func() { - p.listener = nil - }() - if p.IsListening() { - return p.listener.Close() - } - return nil -} - -func (p *TServerSocket) Interrupt() error { - p.mu.Lock() - p.interrupted = true - p.Close() - p.mu.Unlock() - - return nil -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/server_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/server_transport.go deleted file mode 100644 index 51c40b6..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/server_transport.go +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package thrift - -// Server transport. Object which provides client transports. -type TServerTransport interface { - Listen() error - Accept() (TTransport, error) - Close() error - - // Optional method implementation. This signals to the server transport - // that it should break out of any accept() or listen() that it is currently - // blocked on. This method, if implemented, MUST be thread safe, as it may - // be called from a different thread context than the other TServerTransport - // methods. - Interrupt() error -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/simple_server.go b/vendor/github.com/apache/thrift/lib/go/thrift/simple_server.go deleted file mode 100644 index 4097c4a..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/simple_server.go +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package thrift - -import ( - "log" - "runtime/debug" - "sync" -) - -// Simple, non-concurrent server for testing. -type TSimpleServer struct { - quit chan struct{} - - processorFactory TProcessorFactory - serverTransport TServerTransport - inputTransportFactory TTransportFactory - outputTransportFactory TTransportFactory - inputProtocolFactory TProtocolFactory - outputProtocolFactory TProtocolFactory -} - -func NewTSimpleServer2(processor TProcessor, serverTransport TServerTransport) *TSimpleServer { - return NewTSimpleServerFactory2(NewTProcessorFactory(processor), serverTransport) -} - -func NewTSimpleServer4(processor TProcessor, serverTransport TServerTransport, transportFactory TTransportFactory, protocolFactory TProtocolFactory) *TSimpleServer { - return NewTSimpleServerFactory4(NewTProcessorFactory(processor), - serverTransport, - transportFactory, - protocolFactory, - ) -} - -func NewTSimpleServer6(processor TProcessor, serverTransport TServerTransport, inputTransportFactory TTransportFactory, outputTransportFactory TTransportFactory, inputProtocolFactory TProtocolFactory, outputProtocolFactory TProtocolFactory) *TSimpleServer { - return NewTSimpleServerFactory6(NewTProcessorFactory(processor), - serverTransport, - inputTransportFactory, - outputTransportFactory, - inputProtocolFactory, - outputProtocolFactory, - ) -} - -func NewTSimpleServerFactory2(processorFactory TProcessorFactory, serverTransport TServerTransport) *TSimpleServer { - return NewTSimpleServerFactory6(processorFactory, - serverTransport, - NewTTransportFactory(), - NewTTransportFactory(), - NewTBinaryProtocolFactoryDefault(), - NewTBinaryProtocolFactoryDefault(), - ) -} - -func NewTSimpleServerFactory4(processorFactory TProcessorFactory, serverTransport TServerTransport, transportFactory TTransportFactory, protocolFactory TProtocolFactory) *TSimpleServer { - return NewTSimpleServerFactory6(processorFactory, - serverTransport, - transportFactory, - transportFactory, - protocolFactory, - protocolFactory, - ) -} - -func NewTSimpleServerFactory6(processorFactory TProcessorFactory, serverTransport TServerTransport, inputTransportFactory TTransportFactory, outputTransportFactory TTransportFactory, inputProtocolFactory TProtocolFactory, outputProtocolFactory TProtocolFactory) *TSimpleServer { - return &TSimpleServer{ - processorFactory: processorFactory, - serverTransport: serverTransport, - inputTransportFactory: inputTransportFactory, - outputTransportFactory: outputTransportFactory, - inputProtocolFactory: inputProtocolFactory, - outputProtocolFactory: outputProtocolFactory, - quit: make(chan struct{}, 1), - } -} - -func (p *TSimpleServer) ProcessorFactory() TProcessorFactory { - return p.processorFactory -} - -func (p *TSimpleServer) ServerTransport() TServerTransport { - return p.serverTransport -} - -func (p *TSimpleServer) InputTransportFactory() TTransportFactory { - return p.inputTransportFactory -} - -func (p *TSimpleServer) OutputTransportFactory() TTransportFactory { - return p.outputTransportFactory -} - -func (p *TSimpleServer) InputProtocolFactory() TProtocolFactory { - return p.inputProtocolFactory -} - -func (p *TSimpleServer) OutputProtocolFactory() TProtocolFactory { - return p.outputProtocolFactory -} - -func (p *TSimpleServer) Listen() error { - return p.serverTransport.Listen() -} - -func (p *TSimpleServer) AcceptLoop() error { - for { - client, err := p.serverTransport.Accept() - if err != nil { - select { - case <-p.quit: - return nil - default: - } - return err - } - if client != nil { - go func() { - if err := p.processRequests(client); err != nil { - log.Println("error processing request:", err) - } - }() - } - } -} - -func (p *TSimpleServer) Serve() error { - err := p.Listen() - if err != nil { - return err - } - p.AcceptLoop() - return nil -} - -var once sync.Once - -func (p *TSimpleServer) Stop() error { - q := func() { - p.quit <- struct{}{} - p.serverTransport.Interrupt() - } - once.Do(q) - return nil -} - -func (p *TSimpleServer) processRequests(client TTransport) error { - processor := p.processorFactory.GetProcessor(client) - inputTransport := p.inputTransportFactory.GetTransport(client) - outputTransport := p.outputTransportFactory.GetTransport(client) - inputProtocol := p.inputProtocolFactory.GetProtocol(inputTransport) - outputProtocol := p.outputProtocolFactory.GetProtocol(outputTransport) - defer func() { - if e := recover(); e != nil { - log.Printf("panic in processor: %s: %s", e, debug.Stack()) - } - }() - if inputTransport != nil { - defer inputTransport.Close() - } - if outputTransport != nil { - defer outputTransport.Close() - } - for { - ok, err := processor.Process(inputProtocol, outputProtocol) - if err, ok := err.(TTransportException); ok && err.TypeId() == END_OF_FILE { - return nil - } else if err != nil { - log.Printf("error processing request: %s", err) - return err - } - if err, ok := err.(TApplicationException); ok && err.TypeId() == UNKNOWN_METHOD { - continue - } - if !ok { - break - } - } - return nil -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/socket.go b/vendor/github.com/apache/thrift/lib/go/thrift/socket.go deleted file mode 100644 index 82e28b4..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/socket.go +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package thrift - -import ( - "net" - "time" -) - -type TSocket struct { - conn net.Conn - addr net.Addr - timeout time.Duration -} - -// NewTSocket creates a net.Conn-backed TTransport, given a host and port -// -// Example: -// trans, err := thrift.NewTSocket("localhost:9090") -func NewTSocket(hostPort string) (*TSocket, error) { - return NewTSocketTimeout(hostPort, 0) -} - -// NewTSocketTimeout creates a net.Conn-backed TTransport, given a host and port -// it also accepts a timeout as a time.Duration -func NewTSocketTimeout(hostPort string, timeout time.Duration) (*TSocket, error) { - //conn, err := net.DialTimeout(network, address, timeout) - addr, err := net.ResolveTCPAddr("tcp", hostPort) - if err != nil { - return nil, err - } - return NewTSocketFromAddrTimeout(addr, timeout), nil -} - -// Creates a TSocket from a net.Addr -func NewTSocketFromAddrTimeout(addr net.Addr, timeout time.Duration) *TSocket { - return &TSocket{addr: addr, timeout: timeout} -} - -// Creates a TSocket from an existing net.Conn -func NewTSocketFromConnTimeout(conn net.Conn, timeout time.Duration) *TSocket { - return &TSocket{conn: conn, addr: conn.RemoteAddr(), timeout: timeout} -} - -// Sets the socket timeout -func (p *TSocket) SetTimeout(timeout time.Duration) error { - p.timeout = timeout - return nil -} - -func (p *TSocket) pushDeadline(read, write bool) { - var t time.Time - if p.timeout > 0 { - t = time.Now().Add(time.Duration(p.timeout)) - } - if read && write { - p.conn.SetDeadline(t) - } else if read { - p.conn.SetReadDeadline(t) - } else if write { - p.conn.SetWriteDeadline(t) - } -} - -// Connects the socket, creating a new socket object if necessary. -func (p *TSocket) Open() error { - if p.IsOpen() { - return NewTTransportException(ALREADY_OPEN, "Socket already connected.") - } - if p.addr == nil { - return NewTTransportException(NOT_OPEN, "Cannot open nil address.") - } - if len(p.addr.Network()) == 0 { - return NewTTransportException(NOT_OPEN, "Cannot open bad network name.") - } - if len(p.addr.String()) == 0 { - return NewTTransportException(NOT_OPEN, "Cannot open bad address.") - } - var err error - if p.conn, err = net.DialTimeout(p.addr.Network(), p.addr.String(), p.timeout); err != nil { - return NewTTransportException(NOT_OPEN, err.Error()) - } - return nil -} - -// Retrieve the underlying net.Conn -func (p *TSocket) Conn() net.Conn { - return p.conn -} - -// Returns true if the connection is open -func (p *TSocket) IsOpen() bool { - if p.conn == nil { - return false - } - return true -} - -// Closes the socket. -func (p *TSocket) Close() error { - // Close the socket - if p.conn != nil { - err := p.conn.Close() - if err != nil { - return err - } - p.conn = nil - } - return nil -} - -//Returns the remote address of the socket. -func (p *TSocket) Addr() net.Addr { - return p.addr -} - -func (p *TSocket) Read(buf []byte) (int, error) { - if !p.IsOpen() { - return 0, NewTTransportException(NOT_OPEN, "Connection not open") - } - p.pushDeadline(true, false) - n, err := p.conn.Read(buf) - return n, NewTTransportExceptionFromError(err) -} - -func (p *TSocket) Write(buf []byte) (int, error) { - if !p.IsOpen() { - return 0, NewTTransportException(NOT_OPEN, "Connection not open") - } - p.pushDeadline(false, true) - return p.conn.Write(buf) -} - -func (p *TSocket) Flush() error { - return nil -} - -func (p *TSocket) Interrupt() error { - if !p.IsOpen() { - return nil - } - return p.conn.Close() -} - -func (p *TSocket) RemainingBytes() (num_bytes uint64) { - const maxSize = ^uint64(0) - return maxSize // the thruth is, we just don't know unless framed is used -} - diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/ssl_server_socket.go b/vendor/github.com/apache/thrift/lib/go/thrift/ssl_server_socket.go deleted file mode 100644 index 58f859b..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/ssl_server_socket.go +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package thrift - -import ( - "net" - "time" - "crypto/tls" -) - -type TSSLServerSocket struct { - listener net.Listener - addr net.Addr - clientTimeout time.Duration - interrupted bool - cfg *tls.Config -} - -func NewTSSLServerSocket(listenAddr string, cfg *tls.Config) (*TSSLServerSocket, error) { - return NewTSSLServerSocketTimeout(listenAddr, cfg, 0) -} - -func NewTSSLServerSocketTimeout(listenAddr string, cfg *tls.Config, clientTimeout time.Duration) (*TSSLServerSocket, error) { - addr, err := net.ResolveTCPAddr("tcp", listenAddr) - if err != nil { - return nil, err - } - return &TSSLServerSocket{addr: addr, clientTimeout: clientTimeout, cfg: cfg}, nil -} - -func (p *TSSLServerSocket) Listen() error { - if p.IsListening() { - return nil - } - l, err := tls.Listen(p.addr.Network(), p.addr.String(), p.cfg) - if err != nil { - return err - } - p.listener = l - return nil -} - -func (p *TSSLServerSocket) Accept() (TTransport, error) { - if p.interrupted { - return nil, errTransportInterrupted - } - if p.listener == nil { - return nil, NewTTransportException(NOT_OPEN, "No underlying server socket") - } - conn, err := p.listener.Accept() - if err != nil { - return nil, NewTTransportExceptionFromError(err) - } - return NewTSSLSocketFromConnTimeout(conn, p.cfg, p.clientTimeout), nil -} - -// Checks whether the socket is listening. -func (p *TSSLServerSocket) IsListening() bool { - return p.listener != nil -} - -// Connects the socket, creating a new socket object if necessary. -func (p *TSSLServerSocket) Open() error { - if p.IsListening() { - return NewTTransportException(ALREADY_OPEN, "Server socket already open") - } - if l, err := tls.Listen(p.addr.Network(), p.addr.String(), p.cfg); err != nil { - return err - } else { - p.listener = l - } - return nil -} - -func (p *TSSLServerSocket) Addr() net.Addr { - return p.addr -} - -func (p *TSSLServerSocket) Close() error { - defer func() { - p.listener = nil - }() - if p.IsListening() { - return p.listener.Close() - } - return nil -} - -func (p *TSSLServerSocket) Interrupt() error { - p.interrupted = true - return nil -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/ssl_socket.go b/vendor/github.com/apache/thrift/lib/go/thrift/ssl_socket.go deleted file mode 100644 index 04d3850..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/ssl_socket.go +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package thrift - -import ( - "crypto/tls" - "net" - "time" -) - -type TSSLSocket struct { - conn net.Conn - // hostPort contains host:port (e.g. "asdf.com:12345"). The field is - // only valid if addr is nil. - hostPort string - // addr is nil when hostPort is not "", and is only used when the - // TSSLSocket is constructed from a net.Addr. - addr net.Addr - timeout time.Duration - cfg *tls.Config -} - -// NewTSSLSocket creates a net.Conn-backed TTransport, given a host and port and tls Configuration -// -// Example: -// trans, err := thrift.NewTSSLSocket("localhost:9090", nil) -func NewTSSLSocket(hostPort string, cfg *tls.Config) (*TSSLSocket, error) { - return NewTSSLSocketTimeout(hostPort, cfg, 0) -} - -// NewTSSLSocketTimeout creates a net.Conn-backed TTransport, given a host and port -// it also accepts a tls Configuration and a timeout as a time.Duration -func NewTSSLSocketTimeout(hostPort string, cfg *tls.Config, timeout time.Duration) (*TSSLSocket, error) { - return &TSSLSocket{hostPort: hostPort, timeout: timeout, cfg: cfg}, nil -} - -// Creates a TSSLSocket from a net.Addr -func NewTSSLSocketFromAddrTimeout(addr net.Addr, cfg *tls.Config, timeout time.Duration) *TSSLSocket { - return &TSSLSocket{addr: addr, timeout: timeout, cfg: cfg} -} - -// Creates a TSSLSocket from an existing net.Conn -func NewTSSLSocketFromConnTimeout(conn net.Conn, cfg *tls.Config, timeout time.Duration) *TSSLSocket { - return &TSSLSocket{conn: conn, addr: conn.RemoteAddr(), timeout: timeout, cfg: cfg} -} - -// Sets the socket timeout -func (p *TSSLSocket) SetTimeout(timeout time.Duration) error { - p.timeout = timeout - return nil -} - -func (p *TSSLSocket) pushDeadline(read, write bool) { - var t time.Time - if p.timeout > 0 { - t = time.Now().Add(time.Duration(p.timeout)) - } - if read && write { - p.conn.SetDeadline(t) - } else if read { - p.conn.SetReadDeadline(t) - } else if write { - p.conn.SetWriteDeadline(t) - } -} - -// Connects the socket, creating a new socket object if necessary. -func (p *TSSLSocket) Open() error { - var err error - // If we have a hostname, we need to pass the hostname to tls.Dial for - // certificate hostname checks. - if p.hostPort != "" { - if p.conn, err = tls.Dial("tcp", p.hostPort, p.cfg); err != nil { - return NewTTransportException(NOT_OPEN, err.Error()) - } - } else { - if p.IsOpen() { - return NewTTransportException(ALREADY_OPEN, "Socket already connected.") - } - if p.addr == nil { - return NewTTransportException(NOT_OPEN, "Cannot open nil address.") - } - if len(p.addr.Network()) == 0 { - return NewTTransportException(NOT_OPEN, "Cannot open bad network name.") - } - if len(p.addr.String()) == 0 { - return NewTTransportException(NOT_OPEN, "Cannot open bad address.") - } - if p.conn, err = tls.Dial(p.addr.Network(), p.addr.String(), p.cfg); err != nil { - return NewTTransportException(NOT_OPEN, err.Error()) - } - } - return nil -} - -// Retrieve the underlying net.Conn -func (p *TSSLSocket) Conn() net.Conn { - return p.conn -} - -// Returns true if the connection is open -func (p *TSSLSocket) IsOpen() bool { - if p.conn == nil { - return false - } - return true -} - -// Closes the socket. -func (p *TSSLSocket) Close() error { - // Close the socket - if p.conn != nil { - err := p.conn.Close() - if err != nil { - return err - } - p.conn = nil - } - return nil -} - -func (p *TSSLSocket) Read(buf []byte) (int, error) { - if !p.IsOpen() { - return 0, NewTTransportException(NOT_OPEN, "Connection not open") - } - p.pushDeadline(true, false) - n, err := p.conn.Read(buf) - return n, NewTTransportExceptionFromError(err) -} - -func (p *TSSLSocket) Write(buf []byte) (int, error) { - if !p.IsOpen() { - return 0, NewTTransportException(NOT_OPEN, "Connection not open") - } - p.pushDeadline(false, true) - return p.conn.Write(buf) -} - -func (p *TSSLSocket) Flush() error { - return nil -} - -func (p *TSSLSocket) Interrupt() error { - if !p.IsOpen() { - return nil - } - return p.conn.Close() -} - -func (p *TSSLSocket) RemainingBytes() (num_bytes uint64) { - const maxSize = ^uint64(0) - return maxSize // the thruth is, we just don't know unless framed is used -} - diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/zlib_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/zlib_transport.go deleted file mode 100644 index e47455f..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/zlib_transport.go +++ /dev/null @@ -1,117 +0,0 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The ASF licenses this file -* to you under the Apache License, Version 2.0 (the -* "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. - */ - -package thrift - -import ( - "compress/zlib" - "io" - "log" -) - -// TZlibTransportFactory is a factory for TZlibTransport instances -type TZlibTransportFactory struct { - level int -} - -// TZlibTransport is a TTransport implementation that makes use of zlib compression. -type TZlibTransport struct { - reader io.ReadCloser - transport TTransport - writer *zlib.Writer -} - -// GetTransport constructs a new instance of NewTZlibTransport -func (p *TZlibTransportFactory) GetTransport(trans TTransport) TTransport { - t, _ := NewTZlibTransport(trans, p.level) - return t -} - -// NewTZlibTransportFactory constructs a new instance of NewTZlibTransportFactory -func NewTZlibTransportFactory(level int) *TZlibTransportFactory { - return &TZlibTransportFactory{level: level} -} - -// NewTZlibTransport constructs a new instance of TZlibTransport -func NewTZlibTransport(trans TTransport, level int) (*TZlibTransport, error) { - w, err := zlib.NewWriterLevel(trans, level) - if err != nil { - log.Println(err) - return nil, err - } - - return &TZlibTransport{ - writer: w, - transport: trans, - }, nil -} - -// Close closes the reader and writer (flushing any unwritten data) and closes -// the underlying transport. -func (z *TZlibTransport) Close() error { - if z.reader != nil { - if err := z.reader.Close(); err != nil { - return err - } - } - if err := z.writer.Close(); err != nil { - return err - } - return z.transport.Close() -} - -// Flush flushes the writer and its underlying transport. -func (z *TZlibTransport) Flush() error { - if err := z.writer.Flush(); err != nil { - return err - } - return z.transport.Flush() -} - -// IsOpen returns true if the transport is open -func (z *TZlibTransport) IsOpen() bool { - return z.transport.IsOpen() -} - -// Open opens the transport for communication -func (z *TZlibTransport) Open() error { - return z.transport.Open() -} - -func (z *TZlibTransport) Read(p []byte) (int, error) { - if z.reader == nil { - r, err := zlib.NewReader(z.transport) - if err != nil { - return 0, NewTTransportExceptionFromError(err) - } - z.reader = r - } - - return z.reader.Read(p) -} - -// RemainingBytes returns the size in bytes of the data that is still to be -// read. -func (z *TZlibTransport) RemainingBytes() uint64 { - return z.transport.RemainingBytes() -} - -func (z *TZlibTransport) Write(p []byte) (int, error) { - return z.writer.Write(p) -} diff --git a/vendor/github.com/apache/thrift/lib/hs/LICENSE b/vendor/github.com/apache/thrift/lib/hs/LICENSE deleted file mode 100644 index d645695..0000000 --- a/vendor/github.com/apache/thrift/lib/hs/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/apache/thrift/tutorial/erl/client.sh b/vendor/github.com/apache/thrift/tutorial/erl/client.sh deleted file mode 120000 index a417e0d..0000000 --- a/vendor/github.com/apache/thrift/tutorial/erl/client.sh +++ /dev/null @@ -1 +0,0 @@ -server.sh \ No newline at end of file diff --git a/vendor/github.com/davecgh/go-spew/LICENSE b/vendor/github.com/davecgh/go-spew/LICENSE index c836416..bc52e96 100644 --- a/vendor/github.com/davecgh/go-spew/LICENSE +++ b/vendor/github.com/davecgh/go-spew/LICENSE @@ -2,7 +2,7 @@ ISC License Copyright (c) 2012-2016 Dave Collins -Permission to use, copy, modify, and distribute this software for any +Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. diff --git a/vendor/github.com/davecgh/go-spew/spew/bypass.go b/vendor/github.com/davecgh/go-spew/spew/bypass.go index 8a4a658..7929947 100644 --- a/vendor/github.com/davecgh/go-spew/spew/bypass.go +++ b/vendor/github.com/davecgh/go-spew/spew/bypass.go @@ -16,7 +16,9 @@ // when the code is not running on Google App Engine, compiled by GopherJS, and // "-tags safe" is not added to the go build command line. The "disableunsafe" // tag is deprecated and thus should not be used. -// +build !js,!appengine,!safe,!disableunsafe +// Go versions prior to 1.4 are disabled because they use a different layout +// for interfaces which make the implementation of unsafeReflectValue more complex. +// +build !js,!appengine,!safe,!disableunsafe,go1.4 package spew @@ -34,80 +36,49 @@ const ( ptrSize = unsafe.Sizeof((*byte)(nil)) ) +type flag uintptr + var ( - // offsetPtr, offsetScalar, and offsetFlag are the offsets for the - // internal reflect.Value fields. These values are valid before golang - // commit ecccf07e7f9d which changed the format. The are also valid - // after commit 82f48826c6c7 which changed the format again to mirror - // the original format. Code in the init function updates these offsets - // as necessary. - offsetPtr = uintptr(ptrSize) - offsetScalar = uintptr(0) - offsetFlag = uintptr(ptrSize * 2) - - // flagKindWidth and flagKindShift indicate various bits that the - // reflect package uses internally to track kind information. - // - // flagRO indicates whether or not the value field of a reflect.Value is - // read-only. - // - // flagIndir indicates whether the value field of a reflect.Value is - // the actual data or a pointer to the data. - // - // These values are valid before golang commit 90a7c3c86944 which - // changed their positions. Code in the init function updates these - // flags as necessary. - flagKindWidth = uintptr(5) - flagKindShift = uintptr(flagKindWidth - 1) - flagRO = uintptr(1 << 0) - flagIndir = uintptr(1 << 1) + // flagRO indicates whether the value field of a reflect.Value + // is read-only. + flagRO flag + + // flagAddr indicates whether the address of the reflect.Value's + // value may be taken. + flagAddr flag ) -func init() { - // Older versions of reflect.Value stored small integers directly in the - // ptr field (which is named val in the older versions). Versions - // between commits ecccf07e7f9d and 82f48826c6c7 added a new field named - // scalar for this purpose which unfortunately came before the flag - // field, so the offset of the flag field is different for those - // versions. - // - // This code constructs a new reflect.Value from a known small integer - // and checks if the size of the reflect.Value struct indicates it has - // the scalar field. When it does, the offsets are updated accordingly. - vv := reflect.ValueOf(0xf00) - if unsafe.Sizeof(vv) == (ptrSize * 4) { - offsetScalar = ptrSize * 2 - offsetFlag = ptrSize * 3 - } +// flagKindMask holds the bits that make up the kind +// part of the flags field. In all the supported versions, +// it is in the lower 5 bits. +const flagKindMask = flag(0x1f) - // Commit 90a7c3c86944 changed the flag positions such that the low - // order bits are the kind. This code extracts the kind from the flags - // field and ensures it's the correct type. When it's not, the flag - // order has been changed to the newer format, so the flags are updated - // accordingly. - upf := unsafe.Pointer(uintptr(unsafe.Pointer(&vv)) + offsetFlag) - upfv := *(*uintptr)(upf) - flagKindMask := uintptr((1<>flagKindShift != uintptr(reflect.Int) { - flagKindShift = 0 - flagRO = 1 << 5 - flagIndir = 1 << 6 - - // Commit adf9b30e5594 modified the flags to separate the - // flagRO flag into two bits which specifies whether or not the - // field is embedded. This causes flagIndir to move over a bit - // and means that flagRO is the combination of either of the - // original flagRO bit and the new bit. - // - // This code detects the change by extracting what used to be - // the indirect bit to ensure it's set. When it's not, the flag - // order has been changed to the newer format, so the flags are - // updated accordingly. - if upfv&flagIndir == 0 { - flagRO = 3 << 5 - flagIndir = 1 << 7 - } +// Different versions of Go have used different +// bit layouts for the flags type. This table +// records the known combinations. +var okFlags = []struct { + ro, addr flag +}{{ + // From Go 1.4 to 1.5 + ro: 1 << 5, + addr: 1 << 7, +}, { + // Up to Go tip. + ro: 1<<5 | 1<<6, + addr: 1 << 8, +}} + +var flagValOffset = func() uintptr { + field, ok := reflect.TypeOf(reflect.Value{}).FieldByName("flag") + if !ok { + panic("reflect.Value has no flag field") } + return field.Offset +}() + +// flagField returns a pointer to the flag field of a reflect.Value. +func flagField(v *reflect.Value) *flag { + return (*flag)(unsafe.Pointer(uintptr(unsafe.Pointer(v)) + flagValOffset)) } // unsafeReflectValue converts the passed reflect.Value into a one that bypasses @@ -119,34 +90,56 @@ func init() { // This allows us to check for implementations of the Stringer and error // interfaces to be used for pretty printing ordinarily unaddressable and // inaccessible values such as unexported struct fields. -func unsafeReflectValue(v reflect.Value) (rv reflect.Value) { - indirects := 1 - vt := v.Type() - upv := unsafe.Pointer(uintptr(unsafe.Pointer(&v)) + offsetPtr) - rvf := *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&v)) + offsetFlag)) - if rvf&flagIndir != 0 { - vt = reflect.PtrTo(v.Type()) - indirects++ - } else if offsetScalar != 0 { - // The value is in the scalar field when it's not one of the - // reference types. - switch vt.Kind() { - case reflect.Uintptr: - case reflect.Chan: - case reflect.Func: - case reflect.Map: - case reflect.Ptr: - case reflect.UnsafePointer: - default: - upv = unsafe.Pointer(uintptr(unsafe.Pointer(&v)) + - offsetScalar) - } +func unsafeReflectValue(v reflect.Value) reflect.Value { + if !v.IsValid() || (v.CanInterface() && v.CanAddr()) { + return v } + flagFieldPtr := flagField(&v) + *flagFieldPtr &^= flagRO + *flagFieldPtr |= flagAddr + return v +} - pv := reflect.NewAt(vt, upv) - rv = pv - for i := 0; i < indirects; i++ { - rv = rv.Elem() +// Sanity checks against future reflect package changes +// to the type or semantics of the Value.flag field. +func init() { + field, ok := reflect.TypeOf(reflect.Value{}).FieldByName("flag") + if !ok { + panic("reflect.Value has no flag field") + } + if field.Type.Kind() != reflect.TypeOf(flag(0)).Kind() { + panic("reflect.Value flag field has changed kind") + } + type t0 int + var t struct { + A t0 + // t0 will have flagEmbedRO set. + t0 + // a will have flagStickyRO set + a t0 + } + vA := reflect.ValueOf(t).FieldByName("A") + va := reflect.ValueOf(t).FieldByName("a") + vt0 := reflect.ValueOf(t).FieldByName("t0") + + // Infer flagRO from the difference between the flags + // for the (otherwise identical) fields in t. + flagPublic := *flagField(&vA) + flagWithRO := *flagField(&va) | *flagField(&vt0) + flagRO = flagPublic ^ flagWithRO + + // Infer flagAddr from the difference between a value + // taken from a pointer and not. + vPtrA := reflect.ValueOf(&t).Elem().FieldByName("A") + flagNoPtr := *flagField(&vA) + flagPtr := *flagField(&vPtrA) + flagAddr = flagNoPtr ^ flagPtr + + // Check that the inferred flags tally with one of the known versions. + for _, f := range okFlags { + if flagRO == f.ro && flagAddr == f.addr { + return + } } - return rv + panic("reflect.Value read-only flag has changed semantics") } diff --git a/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go b/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go index 1fe3cf3..205c28d 100644 --- a/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go +++ b/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go @@ -16,7 +16,7 @@ // when the code is running on Google App Engine, compiled by GopherJS, or // "-tags safe" is added to the go build command line. The "disableunsafe" // tag is deprecated and thus should not be used. -// +build js appengine safe disableunsafe +// +build js appengine safe disableunsafe !go1.4 package spew diff --git a/vendor/github.com/davecgh/go-spew/spew/common.go b/vendor/github.com/davecgh/go-spew/spew/common.go index 7c519ff..1be8ce9 100644 --- a/vendor/github.com/davecgh/go-spew/spew/common.go +++ b/vendor/github.com/davecgh/go-spew/spew/common.go @@ -180,7 +180,7 @@ func printComplex(w io.Writer, c complex128, floatPrecision int) { w.Write(closeParenBytes) } -// printHexPtr outputs a uintptr formatted as hexidecimal with a leading '0x' +// printHexPtr outputs a uintptr formatted as hexadecimal with a leading '0x' // prefix to Writer w. func printHexPtr(w io.Writer, p uintptr) { // Null pointer. diff --git a/vendor/github.com/davecgh/go-spew/spew/dump.go b/vendor/github.com/davecgh/go-spew/spew/dump.go index df1d582..f78d89f 100644 --- a/vendor/github.com/davecgh/go-spew/spew/dump.go +++ b/vendor/github.com/davecgh/go-spew/spew/dump.go @@ -35,16 +35,16 @@ var ( // cCharRE is a regular expression that matches a cgo char. // It is used to detect character arrays to hexdump them. - cCharRE = regexp.MustCompile("^.*\\._Ctype_char$") + cCharRE = regexp.MustCompile(`^.*\._Ctype_char$`) // cUnsignedCharRE is a regular expression that matches a cgo unsigned // char. It is used to detect unsigned character arrays to hexdump // them. - cUnsignedCharRE = regexp.MustCompile("^.*\\._Ctype_unsignedchar$") + cUnsignedCharRE = regexp.MustCompile(`^.*\._Ctype_unsignedchar$`) // cUint8tCharRE is a regular expression that matches a cgo uint8_t. // It is used to detect uint8_t arrays to hexdump them. - cUint8tCharRE = regexp.MustCompile("^.*\\._Ctype_uint8_t$") + cUint8tCharRE = regexp.MustCompile(`^.*\._Ctype_uint8_t$`) ) // dumpState contains information about the state of a dump operation. @@ -143,10 +143,10 @@ func (d *dumpState) dumpPtr(v reflect.Value) { // Display dereferenced value. d.w.Write(openParenBytes) switch { - case nilFound == true: + case nilFound: d.w.Write(nilAngleBytes) - case cycleFound == true: + case cycleFound: d.w.Write(circularBytes) default: diff --git a/vendor/github.com/davecgh/go-spew/spew/format.go b/vendor/github.com/davecgh/go-spew/spew/format.go index c49875b..b04edb7 100644 --- a/vendor/github.com/davecgh/go-spew/spew/format.go +++ b/vendor/github.com/davecgh/go-spew/spew/format.go @@ -182,10 +182,10 @@ func (f *formatState) formatPtr(v reflect.Value) { // Display dereferenced value. switch { - case nilFound == true: + case nilFound: f.fs.Write(nilAngleBytes) - case cycleFound == true: + case cycleFound: f.fs.Write(circularShortBytes) default: diff --git a/vendor/github.com/fsnotify/fsnotify/AUTHORS b/vendor/github.com/fsnotify/fsnotify/AUTHORS index 0a5bf8f..5ab5d41 100644 --- a/vendor/github.com/fsnotify/fsnotify/AUTHORS +++ b/vendor/github.com/fsnotify/fsnotify/AUTHORS @@ -8,8 +8,10 @@ # Please keep the list sorted. +Aaron L Adrien Bustany Amit Krishnan +Anmol Sethi Bjørn Erik Pedersen Bruno Bigras Caleb Spare @@ -26,6 +28,7 @@ Kelvin Fo Ken-ichirou MATSUZAWA Matt Layher Nathan Youngman +Nickolai Zeldovich Patrick Paul Hammond Pawel Knap @@ -33,12 +36,15 @@ Pieter Droogendijk Pursuit92 Riku Voipio Rob Figueiredo +Rodrigo Chiossi Slawek Ligus Soge Zhang Tiffany Jernigan Tilak Sharma +Tom Payne Travis Cline Tudor Golubenco +Vahe Khachikyan Yukang bronze1man debrando diff --git a/vendor/github.com/fsnotify/fsnotify/fsnotify.go b/vendor/github.com/fsnotify/fsnotify/fsnotify.go index e7f55fe..190bf0d 100644 --- a/vendor/github.com/fsnotify/fsnotify/fsnotify.go +++ b/vendor/github.com/fsnotify/fsnotify/fsnotify.go @@ -9,6 +9,7 @@ package fsnotify import ( "bytes" + "errors" "fmt" ) @@ -60,3 +61,6 @@ func (op Op) String() string { func (e Event) String() string { return fmt.Sprintf("%q: %s", e.Name, e.Op.String()) } + +// Common errors that can be reported by a watcher +var ErrEventOverflow = errors.New("fsnotify queue overflow") diff --git a/vendor/github.com/fsnotify/fsnotify/inotify.go b/vendor/github.com/fsnotify/fsnotify/inotify.go index f3b74c5..d9fd1b8 100644 --- a/vendor/github.com/fsnotify/fsnotify/inotify.go +++ b/vendor/github.com/fsnotify/fsnotify/inotify.go @@ -24,7 +24,6 @@ type Watcher struct { Events chan Event Errors chan error mu sync.Mutex // Map access - cv *sync.Cond // sync removing on rm_watch with IN_IGNORE fd int poller *fdPoller watches map[string]*watch // Map of inotify watches (key: path) @@ -56,7 +55,6 @@ func NewWatcher() (*Watcher, error) { done: make(chan struct{}), doneResp: make(chan struct{}), } - w.cv = sync.NewCond(&w.mu) go w.readEvents() return w, nil @@ -103,21 +101,23 @@ func (w *Watcher) Add(name string) error { var flags uint32 = agnosticEvents w.mu.Lock() - watchEntry, found := w.watches[name] - w.mu.Unlock() - if found { - watchEntry.flags |= flags - flags |= unix.IN_MASK_ADD + defer w.mu.Unlock() + watchEntry := w.watches[name] + if watchEntry != nil { + flags |= watchEntry.flags | unix.IN_MASK_ADD } wd, errno := unix.InotifyAddWatch(w.fd, name, flags) if wd == -1 { return errno } - w.mu.Lock() - w.watches[name] = &watch{wd: uint32(wd), flags: flags} - w.paths[wd] = name - w.mu.Unlock() + if watchEntry == nil { + w.watches[name] = &watch{wd: uint32(wd), flags: flags} + w.paths[wd] = name + } else { + watchEntry.wd = uint32(wd) + watchEntry.flags = flags + } return nil } @@ -135,6 +135,13 @@ func (w *Watcher) Remove(name string) error { if !ok { return fmt.Errorf("can't remove non-existent inotify watch for: %s", name) } + + // We successfully removed the watch if InotifyRmWatch doesn't return an + // error, we need to clean up our internal state to ensure it matches + // inotify's kernel state. + delete(w.paths, int(watch.wd)) + delete(w.watches, name) + // inotify_rm_watch will return EINVAL if the file has been deleted; // the inotify will already have been removed. // watches and pathes are deleted in ignoreLinux() implicitly and asynchronously @@ -152,13 +159,6 @@ func (w *Watcher) Remove(name string) error { return errno } - // wait until ignoreLinux() deleting maps - exists := true - for exists { - w.cv.Wait() - _, exists = w.watches[name] - } - return nil } @@ -245,13 +245,31 @@ func (w *Watcher) readEvents() { mask := uint32(raw.Mask) nameLen := uint32(raw.Len) + + if mask&unix.IN_Q_OVERFLOW != 0 { + select { + case w.Errors <- ErrEventOverflow: + case <-w.done: + return + } + } + // If the event happened to the watched directory or the watched file, the kernel // doesn't append the filename to the event, but we would like to always fill the // the "Name" field with a valid filename. We retrieve the path of the watch from // the "paths" map. w.mu.Lock() - name := w.paths[int(raw.Wd)] + name, ok := w.paths[int(raw.Wd)] + // IN_DELETE_SELF occurs when the file/directory being watched is removed. + // This is a sign to clean up the maps, otherwise we are no longer in sync + // with the inotify kernel state which has already deleted the watch + // automatically. + if ok && mask&unix.IN_DELETE_SELF == unix.IN_DELETE_SELF { + delete(w.paths, int(raw.Wd)) + delete(w.watches, name) + } w.mu.Unlock() + if nameLen > 0 { // Point "bytes" at the first byte of the filename bytes := (*[unix.PathMax]byte)(unsafe.Pointer(&buf[offset+unix.SizeofInotifyEvent])) @@ -262,7 +280,7 @@ func (w *Watcher) readEvents() { event := newEvent(name, mask) // Send the events that are not ignored on the events channel - if !event.ignoreLinux(w, raw.Wd, mask) { + if !event.ignoreLinux(mask) { select { case w.Events <- event: case <-w.done: @@ -279,15 +297,9 @@ func (w *Watcher) readEvents() { // Certain types of events can be "ignored" and not sent over the Events // channel. Such as events marked ignore by the kernel, or MODIFY events // against files that do not exist. -func (e *Event) ignoreLinux(w *Watcher, wd int32, mask uint32) bool { +func (e *Event) ignoreLinux(mask uint32) bool { // Ignore anything the inotify API says to ignore if mask&unix.IN_IGNORED == unix.IN_IGNORED { - w.mu.Lock() - defer w.mu.Unlock() - name := w.paths[int(wd)] - delete(w.paths, int(wd)) - delete(w.watches, name) - w.cv.Broadcast() return true } diff --git a/vendor/github.com/fsnotify/fsnotify/kqueue.go b/vendor/github.com/fsnotify/fsnotify/kqueue.go index c2b4acb..86e76a3 100644 --- a/vendor/github.com/fsnotify/fsnotify/kqueue.go +++ b/vendor/github.com/fsnotify/fsnotify/kqueue.go @@ -22,7 +22,7 @@ import ( type Watcher struct { Events chan Event Errors chan error - done chan bool // Channel for sending a "quit message" to the reader goroutine + done chan struct{} // Channel for sending a "quit message" to the reader goroutine kq int // File descriptor (as returned by the kqueue() syscall). @@ -56,7 +56,7 @@ func NewWatcher() (*Watcher, error) { externalWatches: make(map[string]bool), Events: make(chan Event), Errors: make(chan error), - done: make(chan bool), + done: make(chan struct{}), } go w.readEvents() @@ -71,10 +71,8 @@ func (w *Watcher) Close() error { return nil } w.isClosed = true - w.mu.Unlock() // copy paths to remove while locked - w.mu.Lock() var pathsToRemove = make([]string, 0, len(w.watches)) for name := range w.watches { pathsToRemove = append(pathsToRemove, name) @@ -82,15 +80,12 @@ func (w *Watcher) Close() error { w.mu.Unlock() // unlock before calling Remove, which also locks - var err error for _, name := range pathsToRemove { - if e := w.Remove(name); e != nil && err == nil { - err = e - } + w.Remove(name) } - // Send "quit" message to the reader goroutine: - w.done <- true + // send a "quit" message to the reader goroutine + close(w.done) return nil } @@ -266,17 +261,12 @@ func (w *Watcher) addWatch(name string, flags uint32) (string, error) { func (w *Watcher) readEvents() { eventBuffer := make([]unix.Kevent_t, 10) +loop: for { // See if there is a message on the "done" channel select { case <-w.done: - err := unix.Close(w.kq) - if err != nil { - w.Errors <- err - } - close(w.Events) - close(w.Errors) - return + break loop default: } @@ -284,7 +274,11 @@ func (w *Watcher) readEvents() { kevents, err := read(w.kq, eventBuffer, &keventWaitTime) // EINTR is okay, the syscall was interrupted before timeout expired. if err != nil && err != unix.EINTR { - w.Errors <- err + select { + case w.Errors <- err: + case <-w.done: + break loop + } continue } @@ -319,8 +313,12 @@ func (w *Watcher) readEvents() { if path.isDir && event.Op&Write == Write && !(event.Op&Remove == Remove) { w.sendDirectoryChangeEvents(event.Name) } else { - // Send the event on the Events channel - w.Events <- event + // Send the event on the Events channel. + select { + case w.Events <- event: + case <-w.done: + break loop + } } if event.Op&Remove == Remove { @@ -352,6 +350,18 @@ func (w *Watcher) readEvents() { kevents = kevents[1:] } } + + // cleanup + err := unix.Close(w.kq) + if err != nil { + // only way the previous loop breaks is if w.done was closed so we need to async send to w.Errors. + select { + case w.Errors <- err: + default: + } + } + close(w.Events) + close(w.Errors) } // newEvent returns an platform-independent Event based on kqueue Fflags. @@ -407,7 +417,11 @@ func (w *Watcher) sendDirectoryChangeEvents(dirPath string) { // Get all files files, err := ioutil.ReadDir(dirPath) if err != nil { - w.Errors <- err + select { + case w.Errors <- err: + case <-w.done: + return + } } // Search for new files @@ -428,7 +442,11 @@ func (w *Watcher) sendFileCreatedEventIfNew(filePath string, fileInfo os.FileInf w.mu.Unlock() if !doesExist { // Send create event - w.Events <- newCreateEvent(filePath) + select { + case w.Events <- newCreateEvent(filePath): + case <-w.done: + return + } } // like watchDirectoryFiles (but without doing another ReadDir) diff --git a/vendor/github.com/gocarina/gocsv/LICENSE b/vendor/github.com/gocarina/gocsv/LICENSE deleted file mode 100644 index 052a371..0000000 --- a/vendor/github.com/gocarina/gocsv/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 Jonathan Picques - -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: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -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. \ No newline at end of file diff --git a/vendor/github.com/gocarina/gocsv/csv.go b/vendor/github.com/gocarina/gocsv/csv.go deleted file mode 100644 index 2e336ea..0000000 --- a/vendor/github.com/gocarina/gocsv/csv.go +++ /dev/null @@ -1,319 +0,0 @@ -// Copyright 2014 Jonathan Picques. All rights reserved. -// Use of this source code is governed by a MIT license -// The license can be found in the LICENSE file. - -// The GoCSV package aims to provide easy CSV serialization and deserialization to the golang programming language - -package gocsv - -import ( - "bytes" - "encoding/csv" - "fmt" - "io" - "os" - "reflect" - "strings" -) - -// FailIfUnmatchedStructTags indicates whether it is considered an error when there is an unmatched -// struct tag. -var FailIfUnmatchedStructTags = false - -// FailIfDoubleHeaderNames indicates whether it is considered an error when a header name is repeated -// in the csv header. -var FailIfDoubleHeaderNames = false - -// ShouldAlignDuplicateHeadersWithStructFieldOrder indicates whether we should align duplicate CSV -// headers per their alignment in the struct definition. -var ShouldAlignDuplicateHeadersWithStructFieldOrder = false - -// TagSeparator defines seperator string for multiple csv tags in struct fields -var TagSeparator = "," - -// -------------------------------------------------------------------------- -// CSVWriter used to format CSV - -var selfCSVWriter = DefaultCSVWriter - -// DefaultCSVWriter is the default SafeCSVWriter used to format CSV (cf. csv.NewWriter) -func DefaultCSVWriter(out io.Writer) *SafeCSVWriter { - writer := NewSafeCSVWriter(csv.NewWriter(out)) - - // As only one rune can be defined as a CSV separator, we are going to trim - // the custom tag separator and use the first rune. - if runes := []rune(strings.TrimSpace(TagSeparator)); len(runes) > 0 { - writer.Comma = runes[0] - } - - return writer -} - -// SetCSVWriter sets the SafeCSVWriter used to format CSV. -func SetCSVWriter(csvWriter func(io.Writer) *SafeCSVWriter) { - selfCSVWriter = csvWriter -} - -func getCSVWriter(out io.Writer) *SafeCSVWriter { - return selfCSVWriter(out) -} - -// -------------------------------------------------------------------------- -// CSVReader used to parse CSV - -var selfCSVReader = DefaultCSVReader - -// DefaultCSVReader is the default CSV reader used to parse CSV (cf. csv.NewReader) -func DefaultCSVReader(in io.Reader) CSVReader { - return csv.NewReader(in) -} - -// LazyCSVReader returns a lazy CSV reader, with LazyQuotes and TrimLeadingSpace. -func LazyCSVReader(in io.Reader) CSVReader { - csvReader := csv.NewReader(in) - csvReader.LazyQuotes = true - csvReader.TrimLeadingSpace = true - return csvReader -} - -// SetCSVReader sets the CSV reader used to parse CSV. -func SetCSVReader(csvReader func(io.Reader) CSVReader) { - selfCSVReader = csvReader -} - -func getCSVReader(in io.Reader) CSVReader { - return selfCSVReader(in) -} - -// -------------------------------------------------------------------------- -// Marshal functions - -// MarshalFile saves the interface as CSV in the file. -func MarshalFile(in interface{}, file *os.File) (err error) { - return Marshal(in, file) -} - -// MarshalString returns the CSV string from the interface. -func MarshalString(in interface{}) (out string, err error) { - bufferString := bytes.NewBufferString(out) - if err := Marshal(in, bufferString); err != nil { - return "", err - } - return bufferString.String(), nil -} - -// MarshalBytes returns the CSV bytes from the interface. -func MarshalBytes(in interface{}) (out []byte, err error) { - bufferString := bytes.NewBuffer(out) - if err := Marshal(in, bufferString); err != nil { - return nil, err - } - return bufferString.Bytes(), nil -} - -// Marshal returns the CSV in writer from the interface. -func Marshal(in interface{}, out io.Writer) (err error) { - writer := getCSVWriter(out) - return writeTo(writer, in, false) -} - -// Marshal returns the CSV in writer from the interface. -func MarshalWithoutHeaders(in interface{}, out io.Writer) (err error) { - writer := getCSVWriter(out) - return writeTo(writer, in, true) -} - -// MarshalChan returns the CSV read from the channel. -func MarshalChan(c <-chan interface{}, out *SafeCSVWriter) error { - return writeFromChan(out, c) -} - -// MarshalCSV returns the CSV in writer from the interface. -func MarshalCSV(in interface{}, out *SafeCSVWriter) (err error) { - return writeTo(out, in, false) -} - -// MarshalCSVWithoutHeaders returns the CSV in writer from the interface. -func MarshalCSVWithoutHeaders(in interface{}, out *SafeCSVWriter) (err error) { - return writeTo(out, in, true) -} - -// -------------------------------------------------------------------------- -// Unmarshal functions - -// UnmarshalFile parses the CSV from the file in the interface. -func UnmarshalFile(in *os.File, out interface{}) error { - return Unmarshal(in, out) -} - -// UnmarshalString parses the CSV from the string in the interface. -func UnmarshalString(in string, out interface{}) error { - return Unmarshal(strings.NewReader(in), out) -} - -// UnmarshalBytes parses the CSV from the bytes in the interface. -func UnmarshalBytes(in []byte, out interface{}) error { - return Unmarshal(bytes.NewReader(in), out) -} - -// Unmarshal parses the CSV from the reader in the interface. -func Unmarshal(in io.Reader, out interface{}) error { - return readTo(newDecoder(in), out) -} - -// UnmarshalDecoder parses the CSV from the decoder in the interface -func UnmarshalDecoder(in Decoder, out interface{}) error { - return readTo(in, out) -} - -// UnmarshalCSV parses the CSV from the reader in the interface. -func UnmarshalCSV(in CSVReader, out interface{}) error { - return readTo(csvDecoder{in}, out) -} - -// UnmarshalToChan parses the CSV from the reader and send each value in the chan c. -// The channel must have a concrete type. -func UnmarshalToChan(in io.Reader, c interface{}) error { - if c == nil { - return fmt.Errorf("goscv: channel is %v", c) - } - return readEach(newDecoder(in), c) -} - -// UnmarshalDecoderToChan parses the CSV from the decoder and send each value in the chan c. -// The channel must have a concrete type. -func UnmarshalDecoderToChan(in SimpleDecoder, c interface{}) error { - if c == nil { - return fmt.Errorf("goscv: channel is %v", c) - } - return readEach(in, c) -} - -// UnmarshalStringToChan parses the CSV from the string and send each value in the chan c. -// The channel must have a concrete type. -func UnmarshalStringToChan(in string, c interface{}) error { - return UnmarshalToChan(strings.NewReader(in), c) -} - -// UnmarshalBytesToChan parses the CSV from the bytes and send each value in the chan c. -// The channel must have a concrete type. -func UnmarshalBytesToChan(in []byte, c interface{}) error { - return UnmarshalToChan(bytes.NewReader(in), c) -} - -// UnmarshalToCallback parses the CSV from the reader and send each value to the given func f. -// The func must look like func(Struct). -func UnmarshalToCallback(in io.Reader, f interface{}) error { - valueFunc := reflect.ValueOf(f) - t := reflect.TypeOf(f) - if t.NumIn() != 1 { - return fmt.Errorf("the given function must have exactly one parameter") - } - cerr := make(chan error) - c := reflect.MakeChan(reflect.ChanOf(reflect.BothDir, t.In(0)), 0) - go func() { - cerr <- UnmarshalToChan(in, c.Interface()) - }() - for { - select { - case err := <-cerr: - return err - default: - } - v, notClosed := c.Recv() - if !notClosed || v.Interface() == nil { - break - } - valueFunc.Call([]reflect.Value{v}) - } - return nil -} - -// UnmarshalDecoderToCallback parses the CSV from the decoder and send each value to the given func f. -// The func must look like func(Struct). -func UnmarshalDecoderToCallback(in SimpleDecoder, f interface{}) error { - valueFunc := reflect.ValueOf(f) - t := reflect.TypeOf(f) - if t.NumIn() != 1 { - return fmt.Errorf("the given function must have exactly one parameter") - } - cerr := make(chan error) - c := reflect.MakeChan(reflect.ChanOf(reflect.BothDir, t.In(0)), 0) - go func() { - cerr <- UnmarshalDecoderToChan(in, c.Interface()) - }() - for { - select { - case err := <-cerr: - return err - default: - } - v, notClosed := c.Recv() - if !notClosed || v.Interface() == nil { - break - } - valueFunc.Call([]reflect.Value{v}) - } - return nil -} - -// UnmarshalBytesToCallback parses the CSV from the bytes and send each value to the given func f. -// The func must look like func(Struct). -func UnmarshalBytesToCallback(in []byte, f interface{}) error { - return UnmarshalToCallback(bytes.NewReader(in), f) -} - -// UnmarshalStringToCallback parses the CSV from the string and send each value to the given func f. -// The func must look like func(Struct). -func UnmarshalStringToCallback(in string, c interface{}) (err error) { - return UnmarshalToCallback(strings.NewReader(in), c) -} - -// CSVToMap creates a simple map from a CSV of 2 columns. -func CSVToMap(in io.Reader) (map[string]string, error) { - decoder := newDecoder(in) - header, err := decoder.getCSVRow() - if err != nil { - return nil, err - } - if len(header) != 2 { - return nil, fmt.Errorf("maps can only be created for csv of two columns") - } - m := make(map[string]string) - for { - line, err := decoder.getCSVRow() - if err == io.EOF { - break - } else if err != nil { - return nil, err - } - m[line[0]] = line[1] - } - return m, nil -} - -// CSVToMaps takes a reader and returns an array of dictionaries, using the header row as the keys -func CSVToMaps(reader io.Reader) ([]map[string]string, error) { - r := csv.NewReader(reader) - rows := []map[string]string{} - var header []string - for { - record, err := r.Read() - if err == io.EOF { - break - } - if err != nil { - return nil, err - } - if header == nil { - header = record - } else { - dict := map[string]string{} - for i := range header { - dict[header[i]] = record[i] - } - rows = append(rows, dict) - } - } - return rows, nil -} diff --git a/vendor/github.com/gocarina/gocsv/decode.go b/vendor/github.com/gocarina/gocsv/decode.go deleted file mode 100644 index 51dc1d7..0000000 --- a/vendor/github.com/gocarina/gocsv/decode.go +++ /dev/null @@ -1,296 +0,0 @@ -package gocsv - -import ( - "encoding/csv" - "errors" - "fmt" - "io" - "reflect" -) - -// Decoder . -type Decoder interface { - getCSVRows() ([][]string, error) -} - -// SimpleDecoder . -type SimpleDecoder interface { - getCSVRow() ([]string, error) -} - -type decoder struct { - in io.Reader - csvDecoder *csvDecoder -} - -func newDecoder(in io.Reader) *decoder { - return &decoder{in: in} -} - -func (decode *decoder) getCSVRows() ([][]string, error) { - return getCSVReader(decode.in).ReadAll() -} - -func (decode *decoder) getCSVRow() ([]string, error) { - if decode.csvDecoder == nil { - decode.csvDecoder = &csvDecoder{getCSVReader(decode.in)} - } - return decode.csvDecoder.Read() -} - -type CSVReader interface { - Read() ([]string, error) - ReadAll() ([][]string, error) -} - -type csvDecoder struct { - CSVReader -} - -func (c csvDecoder) getCSVRows() ([][]string, error) { - return c.ReadAll() -} - -func (c csvDecoder) getCSVRow() ([]string, error) { - return c.Read() -} - -func maybeMissingStructFields(structInfo []fieldInfo, headers []string) error { - if len(structInfo) == 0 { - return nil - } - - headerMap := make(map[string]struct{}, len(headers)) - for idx := range headers { - headerMap[headers[idx]] = struct{}{} - } - - for _, info := range structInfo { - found := false - for _, key := range info.keys { - if _, ok := headerMap[key]; ok { - found = true - break - } - } - if !found { - return fmt.Errorf("found unmatched struct field with tags %v", info.keys) - } - } - return nil -} - -// Check that no header name is repeated twice -func maybeDoubleHeaderNames(headers []string) error { - headerMap := make(map[string]bool, len(headers)) - for _, v := range headers { - if _, ok := headerMap[v]; ok { - return fmt.Errorf("Repeated header name: %v", v) - } - headerMap[v] = true - } - return nil -} - -func readTo(decoder Decoder, out interface{}) error { - outValue, outType := getConcreteReflectValueAndType(out) // Get the concrete type (not pointer) (Slice or Array) - if err := ensureOutType(outType); err != nil { - return err - } - outInnerWasPointer, outInnerType := getConcreteContainerInnerType(outType) // Get the concrete inner type (not pointer) (Container<"?">) - if err := ensureOutInnerType(outInnerType); err != nil { - return err - } - csvRows, err := decoder.getCSVRows() // Get the CSV csvRows - if err != nil { - return err - } - if len(csvRows) == 0 { - return errors.New("empty csv file given") - } - if err := ensureOutCapacity(&outValue, len(csvRows)); err != nil { // Ensure the container is big enough to hold the CSV content - return err - } - outInnerStructInfo := getStructInfo(outInnerType) // Get the inner struct info to get CSV annotations - if len(outInnerStructInfo.Fields) == 0 { - return errors.New("no csv struct tags found") - } - - headers := csvRows[0] - body := csvRows[1:] - - csvHeadersLabels := make(map[int]*fieldInfo, len(outInnerStructInfo.Fields)) // Used to store the correspondance header <-> position in CSV - - headerCount := map[string]int{} - for i, csvColumnHeader := range headers { - curHeaderCount := headerCount[csvColumnHeader] - if fieldInfo := getCSVFieldPosition(csvColumnHeader, outInnerStructInfo, curHeaderCount); fieldInfo != nil { - csvHeadersLabels[i] = fieldInfo - if ShouldAlignDuplicateHeadersWithStructFieldOrder { - curHeaderCount++ - headerCount[csvColumnHeader] = curHeaderCount - } - } - } - - if FailIfUnmatchedStructTags { - if err := maybeMissingStructFields(outInnerStructInfo.Fields, headers); err != nil { - return err - } - } - if FailIfDoubleHeaderNames { - if err := maybeDoubleHeaderNames(headers); err != nil { - return err - } - } - - for i, csvRow := range body { - outInner := createNewOutInner(outInnerWasPointer, outInnerType) - for j, csvColumnContent := range csvRow { - if fieldInfo, ok := csvHeadersLabels[j]; ok { // Position found accordingly to header name - if err := setInnerField(&outInner, outInnerWasPointer, fieldInfo.IndexChain, csvColumnContent, fieldInfo.omitEmpty); err != nil { // Set field of struct - return &csv.ParseError{ - Line: i + 2, //add 2 to account for the header & 0-indexing of arrays - Column: j + 1, - Err: err, - } - } - } - } - outValue.Index(i).Set(outInner) - } - return nil -} - -func readEach(decoder SimpleDecoder, c interface{}) error { - headers, err := decoder.getCSVRow() - if err != nil { - return err - } - outValue, outType := getConcreteReflectValueAndType(c) // Get the concrete type (not pointer) (Slice or Array) - if err := ensureOutType(outType); err != nil { - return err - } - defer outValue.Close() - outInnerWasPointer, outInnerType := getConcreteContainerInnerType(outType) // Get the concrete inner type (not pointer) (Container<"?">) - if err := ensureOutInnerType(outInnerType); err != nil { - return err - } - outInnerStructInfo := getStructInfo(outInnerType) // Get the inner struct info to get CSV annotations - if len(outInnerStructInfo.Fields) == 0 { - return errors.New("no csv struct tags found") - } - csvHeadersLabels := make(map[int]*fieldInfo, len(outInnerStructInfo.Fields)) // Used to store the correspondance header <-> position in CSV - headerCount := map[string]int{} - for i, csvColumnHeader := range headers { - curHeaderCount := headerCount[csvColumnHeader] - if fieldInfo := getCSVFieldPosition(csvColumnHeader, outInnerStructInfo, curHeaderCount); fieldInfo != nil { - csvHeadersLabels[i] = fieldInfo - if ShouldAlignDuplicateHeadersWithStructFieldOrder { - curHeaderCount++ - headerCount[csvColumnHeader] = curHeaderCount - } - } - } - if err := maybeMissingStructFields(outInnerStructInfo.Fields, headers); err != nil { - if FailIfUnmatchedStructTags { - return err - } - } - if FailIfDoubleHeaderNames { - if err := maybeDoubleHeaderNames(headers); err != nil { - return err - } - } - i := 0 - for { - line, err := decoder.getCSVRow() - if err == io.EOF { - break - } else if err != nil { - return err - } - outInner := createNewOutInner(outInnerWasPointer, outInnerType) - for j, csvColumnContent := range line { - if fieldInfo, ok := csvHeadersLabels[j]; ok { // Position found accordingly to header name - if err := setInnerField(&outInner, outInnerWasPointer, fieldInfo.IndexChain, csvColumnContent, fieldInfo.omitEmpty); err != nil { // Set field of struct - return &csv.ParseError{ - Line: i + 2, //add 2 to account for the header & 0-indexing of arrays - Column: j + 1, - Err: err, - } - } - } - } - outValue.Send(outInner) - i++ - } - return nil -} - -// Check if the outType is an array or a slice -func ensureOutType(outType reflect.Type) error { - switch outType.Kind() { - case reflect.Slice: - fallthrough - case reflect.Chan: - fallthrough - case reflect.Array: - return nil - } - return fmt.Errorf("cannot use " + outType.String() + ", only slice or array supported") -} - -// Check if the outInnerType is of type struct -func ensureOutInnerType(outInnerType reflect.Type) error { - switch outInnerType.Kind() { - case reflect.Struct: - return nil - } - return fmt.Errorf("cannot use " + outInnerType.String() + ", only struct supported") -} - -func ensureOutCapacity(out *reflect.Value, csvLen int) error { - switch out.Kind() { - case reflect.Array: - if out.Len() < csvLen-1 { // Array is not big enough to hold the CSV content (arrays are not addressable) - return fmt.Errorf("array capacity problem: cannot store %d %s in %s", csvLen-1, out.Type().Elem().String(), out.Type().String()) - } - case reflect.Slice: - if !out.CanAddr() && out.Len() < csvLen-1 { // Slice is not big enough tho hold the CSV content and is not addressable - return fmt.Errorf("slice capacity problem and is not addressable (did you forget &?)") - } else if out.CanAddr() && out.Len() < csvLen-1 { - out.Set(reflect.MakeSlice(out.Type(), csvLen-1, csvLen-1)) // Slice is not big enough, so grows it - } - } - return nil -} - -func getCSVFieldPosition(key string, structInfo *structInfo, curHeaderCount int) *fieldInfo { - matchedFieldCount := 0 - for _, field := range structInfo.Fields { - if field.matchesKey(key) { - if matchedFieldCount >= curHeaderCount { - return &field - } else { - matchedFieldCount++ - } - } - } - return nil -} - -func createNewOutInner(outInnerWasPointer bool, outInnerType reflect.Type) reflect.Value { - if outInnerWasPointer { - return reflect.New(outInnerType) - } - return reflect.New(outInnerType).Elem() -} - -func setInnerField(outInner *reflect.Value, outInnerWasPointer bool, index []int, value string, omitEmpty bool) error { - oi := *outInner - if outInnerWasPointer { - oi = outInner.Elem() - } - return setField(oi.FieldByIndex(index), value, omitEmpty) -} diff --git a/vendor/github.com/gocarina/gocsv/encode.go b/vendor/github.com/gocarina/gocsv/encode.go deleted file mode 100644 index 7a41f9f..0000000 --- a/vendor/github.com/gocarina/gocsv/encode.go +++ /dev/null @@ -1,139 +0,0 @@ -package gocsv - -import ( - "fmt" - "io" - "reflect" -) - -type encoder struct { - out io.Writer -} - -func newEncoder(out io.Writer) *encoder { - return &encoder{out} -} - -func writeFromChan(writer *SafeCSVWriter, c <-chan interface{}) error { - // Get the first value. It wil determine the header structure. - firstValue, ok := <-c - if !ok { - return fmt.Errorf("channel is closed") - } - inValue, inType := getConcreteReflectValueAndType(firstValue) // Get the concrete type - if err := ensureStructOrPtr(inType); err != nil { - return err - } - inInnerWasPointer := inType.Kind() == reflect.Ptr - inInnerStructInfo := getStructInfo(inType) // Get the inner struct info to get CSV annotations - csvHeadersLabels := make([]string, len(inInnerStructInfo.Fields)) - for i, fieldInfo := range inInnerStructInfo.Fields { // Used to write the header (first line) in CSV - csvHeadersLabels[i] = fieldInfo.getFirstKey() - } - if err := writer.Write(csvHeadersLabels); err != nil { - return err - } - write := func(val reflect.Value) error { - for j, fieldInfo := range inInnerStructInfo.Fields { - csvHeadersLabels[j] = "" - inInnerFieldValue, err := getInnerField(val, inInnerWasPointer, fieldInfo.IndexChain) // Get the correct field header <-> position - if err != nil { - return err - } - csvHeadersLabels[j] = inInnerFieldValue - } - if err := writer.Write(csvHeadersLabels); err != nil { - return err - } - return nil - } - if err := write(inValue); err != nil { - return err - } - for v := range c { - val, _ := getConcreteReflectValueAndType(v) // Get the concrete type (not pointer) (Slice or Array) - if err := ensureStructOrPtr(inType); err != nil { - return err - } - if err := write(val); err != nil { - return err - } - } - writer.Flush() - return writer.Error() -} - -func writeTo(writer *SafeCSVWriter, in interface{}, omitHeaders bool) error { - inValue, inType := getConcreteReflectValueAndType(in) // Get the concrete type (not pointer) (Slice or Array) - if err := ensureInType(inType); err != nil { - return err - } - inInnerWasPointer, inInnerType := getConcreteContainerInnerType(inType) // Get the concrete inner type (not pointer) (Container<"?">) - if err := ensureInInnerType(inInnerType); err != nil { - return err - } - inInnerStructInfo := getStructInfo(inInnerType) // Get the inner struct info to get CSV annotations - csvHeadersLabels := make([]string, len(inInnerStructInfo.Fields)) - for i, fieldInfo := range inInnerStructInfo.Fields { // Used to write the header (first line) in CSV - csvHeadersLabels[i] = fieldInfo.getFirstKey() - } - if !omitHeaders { - if err := writer.Write(csvHeadersLabels); err != nil { - return err - } - } - inLen := inValue.Len() - for i := 0; i < inLen; i++ { // Iterate over container rows - for j, fieldInfo := range inInnerStructInfo.Fields { - csvHeadersLabels[j] = "" - inInnerFieldValue, err := getInnerField(inValue.Index(i), inInnerWasPointer, fieldInfo.IndexChain) // Get the correct field header <-> position - if err != nil { - return err - } - csvHeadersLabels[j] = inInnerFieldValue - } - if err := writer.Write(csvHeadersLabels); err != nil { - return err - } - } - writer.Flush() - return writer.Error() -} - -func ensureStructOrPtr(t reflect.Type) error { - switch t.Kind() { - case reflect.Struct: - fallthrough - case reflect.Ptr: - return nil - } - return fmt.Errorf("cannot use " + t.String() + ", only slice or array supported") -} - -// Check if the inType is an array or a slice -func ensureInType(outType reflect.Type) error { - switch outType.Kind() { - case reflect.Slice: - fallthrough - case reflect.Array: - return nil - } - return fmt.Errorf("cannot use " + outType.String() + ", only slice or array supported") -} - -// Check if the inInnerType is of type struct -func ensureInInnerType(outInnerType reflect.Type) error { - switch outInnerType.Kind() { - case reflect.Struct: - return nil - } - return fmt.Errorf("cannot use " + outInnerType.String() + ", only struct supported") -} - -func getInnerField(outInner reflect.Value, outInnerWasPointer bool, index []int) (string, error) { - oi := outInner - if outInnerWasPointer { - oi = outInner.Elem() - } - return getFieldAsString(oi.FieldByIndex(index)) -} diff --git a/vendor/github.com/gocarina/gocsv/reflect.go b/vendor/github.com/gocarina/gocsv/reflect.go deleted file mode 100644 index 9217e30..0000000 --- a/vendor/github.com/gocarina/gocsv/reflect.go +++ /dev/null @@ -1,107 +0,0 @@ -package gocsv - -import ( - "reflect" - "strings" - "sync" -) - -// -------------------------------------------------------------------------- -// Reflection helpers - -type structInfo struct { - Fields []fieldInfo -} - -// fieldInfo is a struct field that should be mapped to a CSV column, or vice-versa -// Each IndexChain element before the last is the index of an the embedded struct field -// that defines Key as a tag -type fieldInfo struct { - keys []string - omitEmpty bool - IndexChain []int -} - -func (f fieldInfo) getFirstKey() string { - return f.keys[0] -} - -func (f fieldInfo) matchesKey(key string) bool { - for _, k := range f.keys { - if key == k || strings.TrimSpace(key) == k { - return true - } - } - return false -} - -var structMap = make(map[reflect.Type]*structInfo) -var structMapMutex sync.RWMutex - -func getStructInfo(rType reflect.Type) *structInfo { - structMapMutex.RLock() - stInfo, ok := structMap[rType] - structMapMutex.RUnlock() - if ok { - return stInfo - } - fieldsList := getFieldInfos(rType, []int{}) - stInfo = &structInfo{fieldsList} - return stInfo -} - -func getFieldInfos(rType reflect.Type, parentIndexChain []int) []fieldInfo { - fieldsCount := rType.NumField() - fieldsList := make([]fieldInfo, 0, fieldsCount) - for i := 0; i < fieldsCount; i++ { - field := rType.Field(i) - if field.PkgPath != "" { - continue - } - indexChain := append(parentIndexChain, i) - // if the field is an embedded struct, create a fieldInfo for each of its fields - if field.Anonymous && field.Type.Kind() == reflect.Struct { - fieldsList = append(fieldsList, getFieldInfos(field.Type, indexChain)...) - continue - } - fieldInfo := fieldInfo{IndexChain: indexChain} - fieldTag := field.Tag.Get("csv") - fieldTags := strings.Split(fieldTag, TagSeparator) - filteredTags := []string{} - for _, fieldTagEntry := range fieldTags { - if fieldTagEntry != "omitempty" { - filteredTags = append(filteredTags, fieldTagEntry) - } else { - fieldInfo.omitEmpty = true - } - } - - if len(filteredTags) == 1 && filteredTags[0] == "-" { - continue - } else if len(filteredTags) > 0 && filteredTags[0] != "" { - fieldInfo.keys = filteredTags - } else { - fieldInfo.keys = []string{field.Name} - } - fieldsList = append(fieldsList, fieldInfo) - } - return fieldsList -} - -func getConcreteContainerInnerType(in reflect.Type) (inInnerWasPointer bool, inInnerType reflect.Type) { - inInnerType = in.Elem() - inInnerWasPointer = false - if inInnerType.Kind() == reflect.Ptr { - inInnerWasPointer = true - inInnerType = inInnerType.Elem() - } - return inInnerWasPointer, inInnerType -} - -func getConcreteReflectValueAndType(in interface{}) (reflect.Value, reflect.Type) { - value := reflect.ValueOf(in) - if value.Kind() == reflect.Ptr { - value = value.Elem() - } - return value, value.Type() -} diff --git a/vendor/github.com/gocarina/gocsv/safe_csv.go b/vendor/github.com/gocarina/gocsv/safe_csv.go deleted file mode 100644 index 4b2882f..0000000 --- a/vendor/github.com/gocarina/gocsv/safe_csv.go +++ /dev/null @@ -1,32 +0,0 @@ -package gocsv - -//Wraps around SafeCSVWriter and makes it thread safe. -import ( - "encoding/csv" - "sync" -) - -type SafeCSVWriter struct { - *csv.Writer - m sync.Mutex -} - -func NewSafeCSVWriter(original *csv.Writer) *SafeCSVWriter { - return &SafeCSVWriter{ - Writer: original, - } -} - -//Override write -func (w *SafeCSVWriter) Write(row []string) error { - w.m.Lock() - defer w.m.Unlock() - return w.Writer.Write(row) -} - -//Override flush -func (w *SafeCSVWriter) Flush() { - w.m.Lock() - w.Writer.Flush() - w.m.Unlock() -} diff --git a/vendor/github.com/gocarina/gocsv/types.go b/vendor/github.com/gocarina/gocsv/types.go deleted file mode 100644 index 50d88ce..0000000 --- a/vendor/github.com/gocarina/gocsv/types.go +++ /dev/null @@ -1,456 +0,0 @@ -package gocsv - -import ( - "encoding" - "fmt" - "reflect" - "strconv" - "strings" -) - -// -------------------------------------------------------------------------- -// Conversion interfaces - -// TypeMarshaller is implemented by any value that has a MarshalCSV method -// This converter is used to convert the value to it string representation -type TypeMarshaller interface { - MarshalCSV() (string, error) -} - -// Stringer is implemented by any value that has a String method -// This converter is used to convert the value to it string representation -// This converter will be used if your value does not implement TypeMarshaller -type Stringer interface { - String() string -} - -// TypeUnmarshaller is implemented by any value that has an UnmarshalCSV method -// This converter is used to convert a string to your value representation of that string -type TypeUnmarshaller interface { - UnmarshalCSV(string) error -} - -// NoUnmarshalFuncError is the custom error type to be raised in case there is no unmarshal function defined on type -type NoUnmarshalFuncError struct { - msg string -} - -func (e NoUnmarshalFuncError) Error() string { - return e.msg -} - -// NoMarshalFuncError is the custom error type to be raised in case there is no marshal function defined on type -type NoMarshalFuncError struct { - msg string -} - -func (e NoMarshalFuncError) Error() string { - return e.msg -} - -var ( - stringerType = reflect.TypeOf((*Stringer)(nil)).Elem() - marshallerType = reflect.TypeOf((*TypeMarshaller)(nil)).Elem() - unMarshallerType = reflect.TypeOf((*TypeUnmarshaller)(nil)).Elem() - textMarshalerType = reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem() - textUnMarshalerType = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem() -) - -// -------------------------------------------------------------------------- -// Conversion helpers - -func toString(in interface{}) (string, error) { - inValue := reflect.ValueOf(in) - - switch inValue.Kind() { - case reflect.String: - return inValue.String(), nil - case reflect.Bool: - b := inValue.Bool() - if b { - return "true", nil - } - return "false", nil - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return fmt.Sprintf("%v", inValue.Int()), nil - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - return fmt.Sprintf("%v", inValue.Uint()), nil - case reflect.Float32: - return strconv.FormatFloat(inValue.Float(), byte('f'), -1, 32), nil - case reflect.Float64: - return strconv.FormatFloat(inValue.Float(), byte('f'), -1, 64), nil - } - return "", fmt.Errorf("No known conversion from " + inValue.Type().String() + " to string") -} - -func toBool(in interface{}) (bool, error) { - inValue := reflect.ValueOf(in) - - switch inValue.Kind() { - case reflect.String: - s := inValue.String() - switch s { - case "yes": - return true, nil - case "no", "": - return false, nil - default: - return strconv.ParseBool(s) - } - case reflect.Bool: - return inValue.Bool(), nil - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - i := inValue.Int() - if i != 0 { - return true, nil - } - return false, nil - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - i := inValue.Uint() - if i != 0 { - return true, nil - } - return false, nil - case reflect.Float32, reflect.Float64: - f := inValue.Float() - if f != 0 { - return true, nil - } - return false, nil - } - return false, fmt.Errorf("No known conversion from " + inValue.Type().String() + " to bool") -} - -func toInt(in interface{}) (int64, error) { - inValue := reflect.ValueOf(in) - - switch inValue.Kind() { - case reflect.String: - s := strings.TrimSpace(inValue.String()) - if s == "" { - return 0, nil - } - return strconv.ParseInt(s, 0, 64) - case reflect.Bool: - if inValue.Bool() { - return 1, nil - } - return 0, nil - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return inValue.Int(), nil - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - return int64(inValue.Uint()), nil - case reflect.Float32, reflect.Float64: - return int64(inValue.Float()), nil - } - return 0, fmt.Errorf("No known conversion from " + inValue.Type().String() + " to int") -} - -func toUint(in interface{}) (uint64, error) { - inValue := reflect.ValueOf(in) - - switch inValue.Kind() { - case reflect.String: - s := strings.TrimSpace(inValue.String()) - if s == "" { - return 0, nil - } - - // support the float input - if strings.Contains(s, ".") { - f, err := strconv.ParseFloat(s, 64) - if err != nil { - return 0, err - } - return uint64(f), nil - } - return strconv.ParseUint(s, 0, 64) - case reflect.Bool: - if inValue.Bool() { - return 1, nil - } - return 0, nil - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return uint64(inValue.Int()), nil - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - return inValue.Uint(), nil - case reflect.Float32, reflect.Float64: - return uint64(inValue.Float()), nil - } - return 0, fmt.Errorf("No known conversion from " + inValue.Type().String() + " to uint") -} - -func toFloat(in interface{}) (float64, error) { - inValue := reflect.ValueOf(in) - - switch inValue.Kind() { - case reflect.String: - s := strings.TrimSpace(inValue.String()) - if s == "" { - return 0, nil - } - return strconv.ParseFloat(s, 64) - case reflect.Bool: - if inValue.Bool() { - return 1, nil - } - return 0, nil - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return float64(inValue.Int()), nil - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - return float64(inValue.Uint()), nil - case reflect.Float32, reflect.Float64: - return inValue.Float(), nil - } - return 0, fmt.Errorf("No known conversion from " + inValue.Type().String() + " to float") -} - -func setField(field reflect.Value, value string, omitEmpty bool) error { - if field.Kind() == reflect.Ptr { - if omitEmpty && value == "" { - return nil - } - if field.IsNil() { - field.Set(reflect.New(field.Type().Elem())) - } - field = field.Elem() - } - - switch field.Interface().(type) { - case string: - s, err := toString(value) - if err != nil { - return err - } - field.SetString(s) - case bool: - b, err := toBool(value) - if err != nil { - return err - } - field.SetBool(b) - case int, int8, int16, int32, int64: - i, err := toInt(value) - if err != nil { - return err - } - field.SetInt(i) - case uint, uint8, uint16, uint32, uint64: - ui, err := toUint(value) - if err != nil { - return err - } - field.SetUint(ui) - case float32, float64: - f, err := toFloat(value) - if err != nil { - return err - } - field.SetFloat(f) - default: - // Not a native type, check for unmarshal method - if err := unmarshall(field, value); err != nil { - if _, ok := err.(NoUnmarshalFuncError); !ok { - return err - } - // Could not unmarshal, check for kind, e.g. renamed type from basic type - switch field.Kind() { - case reflect.String: - s, err := toString(value) - if err != nil { - return err - } - field.SetString(s) - case reflect.Bool: - b, err := toBool(value) - if err != nil { - return err - } - field.SetBool(b) - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - i, err := toInt(value) - if err != nil { - return err - } - field.SetInt(i) - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - ui, err := toUint(value) - if err != nil { - return err - } - field.SetUint(ui) - case reflect.Float32, reflect.Float64: - f, err := toFloat(value) - if err != nil { - return err - } - field.SetFloat(f) - default: - return err - } - } else { - return nil - } - } - return nil -} - -func getFieldAsString(field reflect.Value) (str string, err error) { - switch field.Kind() { - case reflect.Interface: - case reflect.Ptr: - if field.IsNil() { - return "", nil - } - return getFieldAsString(field.Elem()) - default: - // Check if field is go native type - switch field.Interface().(type) { - case string: - return field.String(), nil - case bool: - str, err = toString(field.Bool()) - if err != nil { - return str, err - } - case int, int8, int16, int32, int64: - str, err = toString(field.Int()) - if err != nil { - return str, err - } - case uint, uint8, uint16, uint32, uint64: - str, err = toString(field.Uint()) - if err != nil { - return str, err - } - case float32: - str, err = toString(float32(field.Float())) - if err != nil { - return str, err - } - case float64: - str, err = toString(field.Float()) - if err != nil { - return str, err - } - default: - // Not a native type, check for marshal method - str, err = marshall(field) - if err != nil { - if _, ok := err.(NoMarshalFuncError); !ok { - return str, err - } - // If not marshal method, is field compatible with/renamed from native type - switch field.Kind() { - case reflect.String: - return field.String(), nil - case reflect.Bool: - str, err = toString(field.Bool()) - if err != nil { - return str, err - } - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - str, err = toString(field.Int()) - if err != nil { - return str, err - } - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - str, err = toString(field.Uint()) - if err != nil { - return str, err - } - case reflect.Float32: - str, err = toString(float32(field.Float())) - if err != nil { - return str, err - } - case reflect.Float64: - str, err = toString(field.Float()) - if err != nil { - return str, err - } - } - } else { - return str, nil - } - } - } - return str, nil -} - -// -------------------------------------------------------------------------- -// Un/serializations helpers - -func unmarshall(field reflect.Value, value string) error { - dupField := field - unMarshallIt := func(finalField reflect.Value) error { - if finalField.CanInterface() { - fieldIface := finalField.Interface() - - fieldTypeUnmarshaller, ok := fieldIface.(TypeUnmarshaller) - if ok { - return fieldTypeUnmarshaller.UnmarshalCSV(value) - } - - // Otherwise try to use TextUnmarshaler - fieldTextUnmarshaler, ok := fieldIface.(encoding.TextUnmarshaler) - if ok { - return fieldTextUnmarshaler.UnmarshalText([]byte(value)) - } - } - - return NoUnmarshalFuncError{"No known conversion from string to " + field.Type().String() + ", " + field.Type().String() + " does not implement TypeUnmarshaller"} - } - for dupField.Kind() == reflect.Interface || dupField.Kind() == reflect.Ptr { - if dupField.IsNil() { - dupField = reflect.New(field.Type().Elem()) - field.Set(dupField) - return unMarshallIt(dupField) - } - dupField = dupField.Elem() - } - if dupField.CanAddr() { - return unMarshallIt(dupField.Addr()) - } - return NoUnmarshalFuncError{"No known conversion from string to " + field.Type().String() + ", " + field.Type().String() + " does not implement TypeUnmarshaller"} -} - -func marshall(field reflect.Value) (value string, err error) { - dupField := field - marshallIt := func(finalField reflect.Value) (string, error) { - if finalField.CanInterface() { - fieldIface := finalField.Interface() - - // Use TypeMarshaller when possible - fieldTypeMarhaller, ok := fieldIface.(TypeMarshaller) - if ok { - return fieldTypeMarhaller.MarshalCSV() - } - - // Otherwise try to use TextMarshaller - fieldTextMarshaler, ok := fieldIface.(encoding.TextMarshaler) - if ok { - text, err := fieldTextMarshaler.MarshalText() - return string(text), err - } - - // Otherwise try to use Stringer - fieldStringer, ok := fieldIface.(Stringer) - if ok { - return fieldStringer.String(), nil - } - } - - return value, NoMarshalFuncError{"No known conversion from " + field.Type().String() + " to string, " + field.Type().String() + " does not implement TypeMarshaller nor Stringer"} - } - for dupField.Kind() == reflect.Interface || dupField.Kind() == reflect.Ptr { - if dupField.IsNil() { - return value, nil - } - dupField = dupField.Elem() - } - if dupField.CanAddr() { - return marshallIt(dupField.Addr()) - } - return value, NoMarshalFuncError{"No known conversion from " + field.Type().String() + " to string, " + field.Type().String() + " does not implement TypeMarshaller nor Stringer"} -} diff --git a/vendor/github.com/golang/protobuf/LICENSE b/vendor/github.com/golang/protobuf/LICENSE index 1b1b192..0f64693 100644 --- a/vendor/github.com/golang/protobuf/LICENSE +++ b/vendor/github.com/golang/protobuf/LICENSE @@ -1,7 +1,4 @@ -Go support for Protocol Buffers - Google's data interchange format - Copyright 2010 The Go Authors. All rights reserved. -https://github.com/golang/protobuf Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are diff --git a/vendor/github.com/golang/protobuf/proto/clone.go b/vendor/github.com/golang/protobuf/proto/clone.go index e392575..3cd3249 100644 --- a/vendor/github.com/golang/protobuf/proto/clone.go +++ b/vendor/github.com/golang/protobuf/proto/clone.go @@ -35,22 +35,39 @@ package proto import ( + "fmt" "log" "reflect" "strings" ) // Clone returns a deep copy of a protocol buffer. -func Clone(pb Message) Message { - in := reflect.ValueOf(pb) +func Clone(src Message) Message { + in := reflect.ValueOf(src) if in.IsNil() { - return pb + return src } - out := reflect.New(in.Type().Elem()) - // out is empty so a merge is a deep copy. - mergeStruct(out.Elem(), in.Elem()) - return out.Interface().(Message) + dst := out.Interface().(Message) + Merge(dst, src) + return dst +} + +// Merger is the interface representing objects that can merge messages of the same type. +type Merger interface { + // Merge merges src into this message. + // Required and optional fields that are set in src will be set to that value in dst. + // Elements of repeated fields will be appended. + // + // Merge may panic if called with a different argument type than the receiver. + Merge(src Message) +} + +// generatedMerger is the custom merge method that generated protos will have. +// We must add this method since a generate Merge method will conflict with +// many existing protos that have a Merge data field already defined. +type generatedMerger interface { + XXX_Merge(src Message) } // Merge merges src into dst. @@ -58,17 +75,24 @@ func Clone(pb Message) Message { // Elements of repeated fields will be appended. // Merge panics if src and dst are not the same type, or if dst is nil. func Merge(dst, src Message) { + if m, ok := dst.(Merger); ok { + m.Merge(src) + return + } + in := reflect.ValueOf(src) out := reflect.ValueOf(dst) if out.IsNil() { panic("proto: nil destination") } if in.Type() != out.Type() { - // Explicit test prior to mergeStruct so that mistyped nils will fail - panic("proto: type mismatch") + panic(fmt.Sprintf("proto.Merge(%T, %T) type mismatch", dst, src)) } if in.IsNil() { - // Merging nil into non-nil is a quiet no-op + return // Merge from nil src is a noop + } + if m, ok := dst.(generatedMerger); ok { + m.XXX_Merge(src) return } mergeStruct(out.Elem(), in.Elem()) @@ -84,7 +108,7 @@ func mergeStruct(out, in reflect.Value) { mergeAny(out.Field(i), in.Field(i), false, sprop.Prop[i]) } - if emIn, ok := extendable(in.Addr().Interface()); ok { + if emIn, err := extendable(in.Addr().Interface()); err == nil { emOut, _ := extendable(out.Addr().Interface()) mIn, muIn := emIn.extensionsRead() if mIn != nil { diff --git a/vendor/github.com/golang/protobuf/proto/decode.go b/vendor/github.com/golang/protobuf/proto/decode.go index aa20729..d9aa3c4 100644 --- a/vendor/github.com/golang/protobuf/proto/decode.go +++ b/vendor/github.com/golang/protobuf/proto/decode.go @@ -39,8 +39,6 @@ import ( "errors" "fmt" "io" - "os" - "reflect" ) // errOverflow is returned when an integer is too large to be represented. @@ -50,10 +48,6 @@ var errOverflow = errors.New("proto: integer overflow") // wire type is encountered. It does not get returned to user code. var ErrInternalBadWireType = errors.New("proto: internal error: bad wiretype for oneof") -// The fundamental decoders that interpret bytes on the wire. -// Those that take integer types all return uint64 and are -// therefore of type valueDecoder. - // DecodeVarint reads a varint-encoded integer from the slice. // It returns the integer and the number of bytes consumed, or // zero if there is not enough. @@ -267,9 +261,6 @@ func (p *Buffer) DecodeZigzag32() (x uint64, err error) { return } -// These are not ValueDecoders: they produce an array of bytes or a string. -// bytes, embedded messages - // DecodeRawBytes reads a count-delimited byte buffer from the Buffer. // This is the format used for the bytes protocol buffer // type and for embedded messages. @@ -311,81 +302,29 @@ func (p *Buffer) DecodeStringBytes() (s string, err error) { return string(buf), nil } -// Skip the next item in the buffer. Its wire type is decoded and presented as an argument. -// If the protocol buffer has extensions, and the field matches, add it as an extension. -// Otherwise, if the XXX_unrecognized field exists, append the skipped data there. -func (o *Buffer) skipAndSave(t reflect.Type, tag, wire int, base structPointer, unrecField field) error { - oi := o.index - - err := o.skip(t, tag, wire) - if err != nil { - return err - } - - if !unrecField.IsValid() { - return nil - } - - ptr := structPointer_Bytes(base, unrecField) - - // Add the skipped field to struct field - obuf := o.buf - - o.buf = *ptr - o.EncodeVarint(uint64(tag<<3 | wire)) - *ptr = append(o.buf, obuf[oi:o.index]...) - - o.buf = obuf - - return nil -} - -// Skip the next item in the buffer. Its wire type is decoded and presented as an argument. -func (o *Buffer) skip(t reflect.Type, tag, wire int) error { - - var u uint64 - var err error - - switch wire { - case WireVarint: - _, err = o.DecodeVarint() - case WireFixed64: - _, err = o.DecodeFixed64() - case WireBytes: - _, err = o.DecodeRawBytes(false) - case WireFixed32: - _, err = o.DecodeFixed32() - case WireStartGroup: - for { - u, err = o.DecodeVarint() - if err != nil { - break - } - fwire := int(u & 0x7) - if fwire == WireEndGroup { - break - } - ftag := int(u >> 3) - err = o.skip(t, ftag, fwire) - if err != nil { - break - } - } - default: - err = fmt.Errorf("proto: can't skip unknown wire type %d for %s", wire, t) - } - return err -} - // Unmarshaler is the interface representing objects that can -// unmarshal themselves. The method should reset the receiver before -// decoding starts. The argument points to data that may be +// unmarshal themselves. The argument points to data that may be // overwritten, so implementations should not keep references to the // buffer. +// Unmarshal implementations should not clear the receiver. +// Any unmarshaled data should be merged into the receiver. +// Callers of Unmarshal that do not want to retain existing data +// should Reset the receiver before calling Unmarshal. type Unmarshaler interface { Unmarshal([]byte) error } +// newUnmarshaler is the interface representing objects that can +// unmarshal themselves. The semantics are identical to Unmarshaler. +// +// This exists to support protoc-gen-go generated messages. +// The proto package will stop type-asserting to this interface in the future. +// +// DO NOT DEPEND ON THIS. +type newUnmarshaler interface { + XXX_Unmarshal([]byte) error +} + // Unmarshal parses the protocol buffer representation in buf and places the // decoded result in pb. If the struct underlying pb does not match // the data in buf, the results can be unpredictable. @@ -395,7 +334,13 @@ type Unmarshaler interface { // to preserve and append to existing data. func Unmarshal(buf []byte, pb Message) error { pb.Reset() - return UnmarshalMerge(buf, pb) + if u, ok := pb.(newUnmarshaler); ok { + return u.XXX_Unmarshal(buf) + } + if u, ok := pb.(Unmarshaler); ok { + return u.Unmarshal(buf) + } + return NewBuffer(buf).Unmarshal(pb) } // UnmarshalMerge parses the protocol buffer representation in buf and @@ -405,8 +350,16 @@ func Unmarshal(buf []byte, pb Message) error { // UnmarshalMerge merges into existing data in pb. // Most code should use Unmarshal instead. func UnmarshalMerge(buf []byte, pb Message) error { - // If the object can unmarshal itself, let it. + if u, ok := pb.(newUnmarshaler); ok { + return u.XXX_Unmarshal(buf) + } if u, ok := pb.(Unmarshaler); ok { + // NOTE: The history of proto have unfortunately been inconsistent + // whether Unmarshaler should or should not implicitly clear itself. + // Some implementations do, most do not. + // Thus, calling this here may or may not do what people want. + // + // See https://github.com/golang/protobuf/issues/424 return u.Unmarshal(buf) } return NewBuffer(buf).Unmarshal(pb) @@ -422,12 +375,17 @@ func (p *Buffer) DecodeMessage(pb Message) error { } // DecodeGroup reads a tag-delimited group from the Buffer. +// StartGroup tag is already consumed. This function consumes +// EndGroup tag. func (p *Buffer) DecodeGroup(pb Message) error { - typ, base, err := getbase(pb) - if err != nil { - return err + b := p.buf[p.index:] + x, y := findEndGroup(b) + if x < 0 { + return io.ErrUnexpectedEOF } - return p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), true, base) + err := Unmarshal(b[:x], pb) + p.index += y + return err } // Unmarshal parses the protocol buffer representation in the @@ -438,533 +396,33 @@ func (p *Buffer) DecodeGroup(pb Message) error { // Unlike proto.Unmarshal, this does not reset pb before starting to unmarshal. func (p *Buffer) Unmarshal(pb Message) error { // If the object can unmarshal itself, let it. - if u, ok := pb.(Unmarshaler); ok { - err := u.Unmarshal(p.buf[p.index:]) + if u, ok := pb.(newUnmarshaler); ok { + err := u.XXX_Unmarshal(p.buf[p.index:]) p.index = len(p.buf) return err } - - typ, base, err := getbase(pb) - if err != nil { - return err - } - - err = p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), false, base) - - if collectStats { - stats.Decode++ - } - - return err -} - -// unmarshalType does the work of unmarshaling a structure. -func (o *Buffer) unmarshalType(st reflect.Type, prop *StructProperties, is_group bool, base structPointer) error { - var state errorState - required, reqFields := prop.reqCount, uint64(0) - - var err error - for err == nil && o.index < len(o.buf) { - oi := o.index - var u uint64 - u, err = o.DecodeVarint() - if err != nil { - break - } - wire := int(u & 0x7) - if wire == WireEndGroup { - if is_group { - if required > 0 { - // Not enough information to determine the exact field. - // (See below.) - return &RequiredNotSetError{"{Unknown}"} - } - return nil // input is satisfied - } - return fmt.Errorf("proto: %s: wiretype end group for non-group", st) - } - tag := int(u >> 3) - if tag <= 0 { - return fmt.Errorf("proto: %s: illegal tag %d (wire type %d)", st, tag, wire) - } - fieldnum, ok := prop.decoderTags.get(tag) - if !ok { - // Maybe it's an extension? - if prop.extendable { - if e, _ := extendable(structPointer_Interface(base, st)); isExtensionField(e, int32(tag)) { - if err = o.skip(st, tag, wire); err == nil { - extmap := e.extensionsWrite() - ext := extmap[int32(tag)] // may be missing - ext.enc = append(ext.enc, o.buf[oi:o.index]...) - extmap[int32(tag)] = ext - } - continue - } - } - // Maybe it's a oneof? - if prop.oneofUnmarshaler != nil { - m := structPointer_Interface(base, st).(Message) - // First return value indicates whether tag is a oneof field. - ok, err = prop.oneofUnmarshaler(m, tag, wire, o) - if err == ErrInternalBadWireType { - // Map the error to something more descriptive. - // Do the formatting here to save generated code space. - err = fmt.Errorf("bad wiretype for oneof field in %T", m) - } - if ok { - continue - } - } - err = o.skipAndSave(st, tag, wire, base, prop.unrecField) - continue - } - p := prop.Prop[fieldnum] - - if p.dec == nil { - fmt.Fprintf(os.Stderr, "proto: no protobuf decoder for %s.%s\n", st, st.Field(fieldnum).Name) - continue - } - dec := p.dec - if wire != WireStartGroup && wire != p.WireType { - if wire == WireBytes && p.packedDec != nil { - // a packable field - dec = p.packedDec - } else { - err = fmt.Errorf("proto: bad wiretype for field %s.%s: got wiretype %d, want %d", st, st.Field(fieldnum).Name, wire, p.WireType) - continue - } - } - decErr := dec(o, p, base) - if decErr != nil && !state.shouldContinue(decErr, p) { - err = decErr - } - if err == nil && p.Required { - // Successfully decoded a required field. - if tag <= 64 { - // use bitmap for fields 1-64 to catch field reuse. - var mask uint64 = 1 << uint64(tag-1) - if reqFields&mask == 0 { - // new required field - reqFields |= mask - required-- - } - } else { - // This is imprecise. It can be fooled by a required field - // with a tag > 64 that is encoded twice; that's very rare. - // A fully correct implementation would require allocating - // a data structure, which we would like to avoid. - required-- - } - } - } - if err == nil { - if is_group { - return io.ErrUnexpectedEOF - } - if state.err != nil { - return state.err - } - if required > 0 { - // Not enough information to determine the exact field. If we use extra - // CPU, we could determine the field only if the missing required field - // has a tag <= 64 and we check reqFields. - return &RequiredNotSetError{"{Unknown}"} - } - } - return err -} - -// Individual type decoders -// For each, -// u is the decoded value, -// v is a pointer to the field (pointer) in the struct - -// Sizes of the pools to allocate inside the Buffer. -// The goal is modest amortization and allocation -// on at least 16-byte boundaries. -const ( - boolPoolSize = 16 - uint32PoolSize = 8 - uint64PoolSize = 4 -) - -// Decode a bool. -func (o *Buffer) dec_bool(p *Properties, base structPointer) error { - u, err := p.valDec(o) - if err != nil { - return err - } - if len(o.bools) == 0 { - o.bools = make([]bool, boolPoolSize) - } - o.bools[0] = u != 0 - *structPointer_Bool(base, p.field) = &o.bools[0] - o.bools = o.bools[1:] - return nil -} - -func (o *Buffer) dec_proto3_bool(p *Properties, base structPointer) error { - u, err := p.valDec(o) - if err != nil { - return err - } - *structPointer_BoolVal(base, p.field) = u != 0 - return nil -} - -// Decode an int32. -func (o *Buffer) dec_int32(p *Properties, base structPointer) error { - u, err := p.valDec(o) - if err != nil { - return err - } - word32_Set(structPointer_Word32(base, p.field), o, uint32(u)) - return nil -} - -func (o *Buffer) dec_proto3_int32(p *Properties, base structPointer) error { - u, err := p.valDec(o) - if err != nil { - return err - } - word32Val_Set(structPointer_Word32Val(base, p.field), uint32(u)) - return nil -} - -// Decode an int64. -func (o *Buffer) dec_int64(p *Properties, base structPointer) error { - u, err := p.valDec(o) - if err != nil { - return err - } - word64_Set(structPointer_Word64(base, p.field), o, u) - return nil -} - -func (o *Buffer) dec_proto3_int64(p *Properties, base structPointer) error { - u, err := p.valDec(o) - if err != nil { - return err - } - word64Val_Set(structPointer_Word64Val(base, p.field), o, u) - return nil -} - -// Decode a string. -func (o *Buffer) dec_string(p *Properties, base structPointer) error { - s, err := o.DecodeStringBytes() - if err != nil { - return err - } - *structPointer_String(base, p.field) = &s - return nil -} - -func (o *Buffer) dec_proto3_string(p *Properties, base structPointer) error { - s, err := o.DecodeStringBytes() - if err != nil { - return err - } - *structPointer_StringVal(base, p.field) = s - return nil -} - -// Decode a slice of bytes ([]byte). -func (o *Buffer) dec_slice_byte(p *Properties, base structPointer) error { - b, err := o.DecodeRawBytes(true) - if err != nil { - return err - } - *structPointer_Bytes(base, p.field) = b - return nil -} - -// Decode a slice of bools ([]bool). -func (o *Buffer) dec_slice_bool(p *Properties, base structPointer) error { - u, err := p.valDec(o) - if err != nil { - return err - } - v := structPointer_BoolSlice(base, p.field) - *v = append(*v, u != 0) - return nil -} - -// Decode a slice of bools ([]bool) in packed format. -func (o *Buffer) dec_slice_packed_bool(p *Properties, base structPointer) error { - v := structPointer_BoolSlice(base, p.field) - - nn, err := o.DecodeVarint() - if err != nil { - return err - } - nb := int(nn) // number of bytes of encoded bools - fin := o.index + nb - if fin < o.index { - return errOverflow - } - - y := *v - for o.index < fin { - u, err := p.valDec(o) - if err != nil { - return err - } - y = append(y, u != 0) - } - - *v = y - return nil -} - -// Decode a slice of int32s ([]int32). -func (o *Buffer) dec_slice_int32(p *Properties, base structPointer) error { - u, err := p.valDec(o) - if err != nil { - return err - } - structPointer_Word32Slice(base, p.field).Append(uint32(u)) - return nil -} - -// Decode a slice of int32s ([]int32) in packed format. -func (o *Buffer) dec_slice_packed_int32(p *Properties, base structPointer) error { - v := structPointer_Word32Slice(base, p.field) - - nn, err := o.DecodeVarint() - if err != nil { - return err - } - nb := int(nn) // number of bytes of encoded int32s - - fin := o.index + nb - if fin < o.index { - return errOverflow - } - for o.index < fin { - u, err := p.valDec(o) - if err != nil { - return err - } - v.Append(uint32(u)) - } - return nil -} - -// Decode a slice of int64s ([]int64). -func (o *Buffer) dec_slice_int64(p *Properties, base structPointer) error { - u, err := p.valDec(o) - if err != nil { - return err - } - - structPointer_Word64Slice(base, p.field).Append(u) - return nil -} - -// Decode a slice of int64s ([]int64) in packed format. -func (o *Buffer) dec_slice_packed_int64(p *Properties, base structPointer) error { - v := structPointer_Word64Slice(base, p.field) - - nn, err := o.DecodeVarint() - if err != nil { - return err - } - nb := int(nn) // number of bytes of encoded int64s - - fin := o.index + nb - if fin < o.index { - return errOverflow - } - for o.index < fin { - u, err := p.valDec(o) - if err != nil { - return err - } - v.Append(u) - } - return nil -} - -// Decode a slice of strings ([]string). -func (o *Buffer) dec_slice_string(p *Properties, base structPointer) error { - s, err := o.DecodeStringBytes() - if err != nil { - return err - } - v := structPointer_StringSlice(base, p.field) - *v = append(*v, s) - return nil -} - -// Decode a slice of slice of bytes ([][]byte). -func (o *Buffer) dec_slice_slice_byte(p *Properties, base structPointer) error { - b, err := o.DecodeRawBytes(true) - if err != nil { - return err - } - v := structPointer_BytesSlice(base, p.field) - *v = append(*v, b) - return nil -} - -// Decode a map field. -func (o *Buffer) dec_new_map(p *Properties, base structPointer) error { - raw, err := o.DecodeRawBytes(false) - if err != nil { - return err - } - oi := o.index // index at the end of this map entry - o.index -= len(raw) // move buffer back to start of map entry - - mptr := structPointer_NewAt(base, p.field, p.mtype) // *map[K]V - if mptr.Elem().IsNil() { - mptr.Elem().Set(reflect.MakeMap(mptr.Type().Elem())) - } - v := mptr.Elem() // map[K]V - - // Prepare addressable doubly-indirect placeholders for the key and value types. - // See enc_new_map for why. - keyptr := reflect.New(reflect.PtrTo(p.mtype.Key())).Elem() // addressable *K - keybase := toStructPointer(keyptr.Addr()) // **K - - var valbase structPointer - var valptr reflect.Value - switch p.mtype.Elem().Kind() { - case reflect.Slice: - // []byte - var dummy []byte - valptr = reflect.ValueOf(&dummy) // *[]byte - valbase = toStructPointer(valptr) // *[]byte - case reflect.Ptr: - // message; valptr is **Msg; need to allocate the intermediate pointer - valptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V - valptr.Set(reflect.New(valptr.Type().Elem())) - valbase = toStructPointer(valptr) - default: - // everything else - valptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V - valbase = toStructPointer(valptr.Addr()) // **V - } - - // Decode. - // This parses a restricted wire format, namely the encoding of a message - // with two fields. See enc_new_map for the format. - for o.index < oi { - // tagcode for key and value properties are always a single byte - // because they have tags 1 and 2. - tagcode := o.buf[o.index] - o.index++ - switch tagcode { - case p.mkeyprop.tagcode[0]: - if err := p.mkeyprop.dec(o, p.mkeyprop, keybase); err != nil { - return err - } - case p.mvalprop.tagcode[0]: - if err := p.mvalprop.dec(o, p.mvalprop, valbase); err != nil { - return err - } - default: - // TODO: Should we silently skip this instead? - return fmt.Errorf("proto: bad map data tag %d", raw[0]) - } - } - keyelem, valelem := keyptr.Elem(), valptr.Elem() - if !keyelem.IsValid() { - keyelem = reflect.Zero(p.mtype.Key()) - } - if !valelem.IsValid() { - valelem = reflect.Zero(p.mtype.Elem()) - } - - v.SetMapIndex(keyelem, valelem) - return nil -} - -// Decode a group. -func (o *Buffer) dec_struct_group(p *Properties, base structPointer) error { - bas := structPointer_GetStructPointer(base, p.field) - if structPointer_IsNil(bas) { - // allocate new nested message - bas = toStructPointer(reflect.New(p.stype)) - structPointer_SetStructPointer(base, p.field, bas) - } - return o.unmarshalType(p.stype, p.sprop, true, bas) -} - -// Decode an embedded message. -func (o *Buffer) dec_struct_message(p *Properties, base structPointer) (err error) { - raw, e := o.DecodeRawBytes(false) - if e != nil { - return e - } - - bas := structPointer_GetStructPointer(base, p.field) - if structPointer_IsNil(bas) { - // allocate new nested message - bas = toStructPointer(reflect.New(p.stype)) - structPointer_SetStructPointer(base, p.field, bas) - } - - // If the object can unmarshal itself, let it. - if p.isUnmarshaler { - iv := structPointer_Interface(bas, p.stype) - return iv.(Unmarshaler).Unmarshal(raw) - } - - obuf := o.buf - oi := o.index - o.buf = raw - o.index = 0 - - err = o.unmarshalType(p.stype, p.sprop, false, bas) - o.buf = obuf - o.index = oi - - return err -} - -// Decode a slice of embedded messages. -func (o *Buffer) dec_slice_struct_message(p *Properties, base structPointer) error { - return o.dec_slice_struct(p, false, base) -} - -// Decode a slice of embedded groups. -func (o *Buffer) dec_slice_struct_group(p *Properties, base structPointer) error { - return o.dec_slice_struct(p, true, base) -} - -// Decode a slice of structs ([]*struct). -func (o *Buffer) dec_slice_struct(p *Properties, is_group bool, base structPointer) error { - v := reflect.New(p.stype) - bas := toStructPointer(v) - structPointer_StructPointerSlice(base, p.field).Append(bas) - - if is_group { - err := o.unmarshalType(p.stype, p.sprop, is_group, bas) - return err - } - - raw, err := o.DecodeRawBytes(false) - if err != nil { + if u, ok := pb.(Unmarshaler); ok { + // NOTE: The history of proto have unfortunately been inconsistent + // whether Unmarshaler should or should not implicitly clear itself. + // Some implementations do, most do not. + // Thus, calling this here may or may not do what people want. + // + // See https://github.com/golang/protobuf/issues/424 + err := u.Unmarshal(p.buf[p.index:]) + p.index = len(p.buf) return err } - // If the object can unmarshal itself, let it. - if p.isUnmarshaler { - iv := v.Interface() - return iv.(Unmarshaler).Unmarshal(raw) - } - - obuf := o.buf - oi := o.index - o.buf = raw - o.index = 0 - - err = o.unmarshalType(p.stype, p.sprop, is_group, bas) - - o.buf = obuf - o.index = oi - + // Slow workaround for messages that aren't Unmarshalers. + // This includes some hand-coded .pb.go files and + // bootstrap protos. + // TODO: fix all of those and then add Unmarshal to + // the Message interface. Then: + // The cast above and code below can be deleted. + // The old unmarshaler can be deleted. + // Clients can call Unmarshal directly (can already do that, actually). + var info InternalMessageInfo + err := info.Unmarshal(pb, p.buf[p.index:]) + p.index = len(p.buf) return err } diff --git a/vendor/github.com/golang/protobuf/proto/discard.go b/vendor/github.com/golang/protobuf/proto/discard.go new file mode 100644 index 0000000..dea2617 --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/discard.go @@ -0,0 +1,350 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2017 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +import ( + "fmt" + "reflect" + "strings" + "sync" + "sync/atomic" +) + +type generatedDiscarder interface { + XXX_DiscardUnknown() +} + +// DiscardUnknown recursively discards all unknown fields from this message +// and all embedded messages. +// +// When unmarshaling a message with unrecognized fields, the tags and values +// of such fields are preserved in the Message. This allows a later call to +// marshal to be able to produce a message that continues to have those +// unrecognized fields. To avoid this, DiscardUnknown is used to +// explicitly clear the unknown fields after unmarshaling. +// +// For proto2 messages, the unknown fields of message extensions are only +// discarded from messages that have been accessed via GetExtension. +func DiscardUnknown(m Message) { + if m, ok := m.(generatedDiscarder); ok { + m.XXX_DiscardUnknown() + return + } + // TODO: Dynamically populate a InternalMessageInfo for legacy messages, + // but the master branch has no implementation for InternalMessageInfo, + // so it would be more work to replicate that approach. + discardLegacy(m) +} + +// DiscardUnknown recursively discards all unknown fields. +func (a *InternalMessageInfo) DiscardUnknown(m Message) { + di := atomicLoadDiscardInfo(&a.discard) + if di == nil { + di = getDiscardInfo(reflect.TypeOf(m).Elem()) + atomicStoreDiscardInfo(&a.discard, di) + } + di.discard(toPointer(&m)) +} + +type discardInfo struct { + typ reflect.Type + + initialized int32 // 0: only typ is valid, 1: everything is valid + lock sync.Mutex + + fields []discardFieldInfo + unrecognized field +} + +type discardFieldInfo struct { + field field // Offset of field, guaranteed to be valid + discard func(src pointer) +} + +var ( + discardInfoMap = map[reflect.Type]*discardInfo{} + discardInfoLock sync.Mutex +) + +func getDiscardInfo(t reflect.Type) *discardInfo { + discardInfoLock.Lock() + defer discardInfoLock.Unlock() + di := discardInfoMap[t] + if di == nil { + di = &discardInfo{typ: t} + discardInfoMap[t] = di + } + return di +} + +func (di *discardInfo) discard(src pointer) { + if src.isNil() { + return // Nothing to do. + } + + if atomic.LoadInt32(&di.initialized) == 0 { + di.computeDiscardInfo() + } + + for _, fi := range di.fields { + sfp := src.offset(fi.field) + fi.discard(sfp) + } + + // For proto2 messages, only discard unknown fields in message extensions + // that have been accessed via GetExtension. + if em, err := extendable(src.asPointerTo(di.typ).Interface()); err == nil { + // Ignore lock since DiscardUnknown is not concurrency safe. + emm, _ := em.extensionsRead() + for _, mx := range emm { + if m, ok := mx.value.(Message); ok { + DiscardUnknown(m) + } + } + } + + if di.unrecognized.IsValid() { + *src.offset(di.unrecognized).toBytes() = nil + } +} + +func (di *discardInfo) computeDiscardInfo() { + di.lock.Lock() + defer di.lock.Unlock() + if di.initialized != 0 { + return + } + t := di.typ + n := t.NumField() + + for i := 0; i < n; i++ { + f := t.Field(i) + if strings.HasPrefix(f.Name, "XXX_") { + continue + } + + dfi := discardFieldInfo{field: toField(&f)} + tf := f.Type + + // Unwrap tf to get its most basic type. + var isPointer, isSlice bool + if tf.Kind() == reflect.Slice && tf.Elem().Kind() != reflect.Uint8 { + isSlice = true + tf = tf.Elem() + } + if tf.Kind() == reflect.Ptr { + isPointer = true + tf = tf.Elem() + } + if isPointer && isSlice && tf.Kind() != reflect.Struct { + panic(fmt.Sprintf("%v.%s cannot be a slice of pointers to primitive types", t, f.Name)) + } + + switch tf.Kind() { + case reflect.Struct: + switch { + case !isPointer: + panic(fmt.Sprintf("%v.%s cannot be a direct struct value", t, f.Name)) + case isSlice: // E.g., []*pb.T + di := getDiscardInfo(tf) + dfi.discard = func(src pointer) { + sps := src.getPointerSlice() + for _, sp := range sps { + if !sp.isNil() { + di.discard(sp) + } + } + } + default: // E.g., *pb.T + di := getDiscardInfo(tf) + dfi.discard = func(src pointer) { + sp := src.getPointer() + if !sp.isNil() { + di.discard(sp) + } + } + } + case reflect.Map: + switch { + case isPointer || isSlice: + panic(fmt.Sprintf("%v.%s cannot be a pointer to a map or a slice of map values", t, f.Name)) + default: // E.g., map[K]V + if tf.Elem().Kind() == reflect.Ptr { // Proto struct (e.g., *T) + dfi.discard = func(src pointer) { + sm := src.asPointerTo(tf).Elem() + if sm.Len() == 0 { + return + } + for _, key := range sm.MapKeys() { + val := sm.MapIndex(key) + DiscardUnknown(val.Interface().(Message)) + } + } + } else { + dfi.discard = func(pointer) {} // Noop + } + } + case reflect.Interface: + // Must be oneof field. + switch { + case isPointer || isSlice: + panic(fmt.Sprintf("%v.%s cannot be a pointer to a interface or a slice of interface values", t, f.Name)) + default: // E.g., interface{} + // TODO: Make this faster? + dfi.discard = func(src pointer) { + su := src.asPointerTo(tf).Elem() + if !su.IsNil() { + sv := su.Elem().Elem().Field(0) + if sv.Kind() == reflect.Ptr && sv.IsNil() { + return + } + switch sv.Type().Kind() { + case reflect.Ptr: // Proto struct (e.g., *T) + DiscardUnknown(sv.Interface().(Message)) + } + } + } + } + default: + continue + } + di.fields = append(di.fields, dfi) + } + + di.unrecognized = invalidField + if f, ok := t.FieldByName("XXX_unrecognized"); ok { + if f.Type != reflect.TypeOf([]byte{}) { + panic("expected XXX_unrecognized to be of type []byte") + } + di.unrecognized = toField(&f) + } + + atomic.StoreInt32(&di.initialized, 1) +} + +func discardLegacy(m Message) { + v := reflect.ValueOf(m) + if v.Kind() != reflect.Ptr || v.IsNil() { + return + } + v = v.Elem() + if v.Kind() != reflect.Struct { + return + } + t := v.Type() + + for i := 0; i < v.NumField(); i++ { + f := t.Field(i) + if strings.HasPrefix(f.Name, "XXX_") { + continue + } + vf := v.Field(i) + tf := f.Type + + // Unwrap tf to get its most basic type. + var isPointer, isSlice bool + if tf.Kind() == reflect.Slice && tf.Elem().Kind() != reflect.Uint8 { + isSlice = true + tf = tf.Elem() + } + if tf.Kind() == reflect.Ptr { + isPointer = true + tf = tf.Elem() + } + if isPointer && isSlice && tf.Kind() != reflect.Struct { + panic(fmt.Sprintf("%T.%s cannot be a slice of pointers to primitive types", m, f.Name)) + } + + switch tf.Kind() { + case reflect.Struct: + switch { + case !isPointer: + panic(fmt.Sprintf("%T.%s cannot be a direct struct value", m, f.Name)) + case isSlice: // E.g., []*pb.T + for j := 0; j < vf.Len(); j++ { + discardLegacy(vf.Index(j).Interface().(Message)) + } + default: // E.g., *pb.T + discardLegacy(vf.Interface().(Message)) + } + case reflect.Map: + switch { + case isPointer || isSlice: + panic(fmt.Sprintf("%T.%s cannot be a pointer to a map or a slice of map values", m, f.Name)) + default: // E.g., map[K]V + tv := vf.Type().Elem() + if tv.Kind() == reflect.Ptr && tv.Implements(protoMessageType) { // Proto struct (e.g., *T) + for _, key := range vf.MapKeys() { + val := vf.MapIndex(key) + discardLegacy(val.Interface().(Message)) + } + } + } + case reflect.Interface: + // Must be oneof field. + switch { + case isPointer || isSlice: + panic(fmt.Sprintf("%T.%s cannot be a pointer to a interface or a slice of interface values", m, f.Name)) + default: // E.g., test_proto.isCommunique_Union interface + if !vf.IsNil() && f.Tag.Get("protobuf_oneof") != "" { + vf = vf.Elem() // E.g., *test_proto.Communique_Msg + if !vf.IsNil() { + vf = vf.Elem() // E.g., test_proto.Communique_Msg + vf = vf.Field(0) // E.g., Proto struct (e.g., *T) or primitive value + if vf.Kind() == reflect.Ptr { + discardLegacy(vf.Interface().(Message)) + } + } + } + } + } + } + + if vf := v.FieldByName("XXX_unrecognized"); vf.IsValid() { + if vf.Type() != reflect.TypeOf([]byte{}) { + panic("expected XXX_unrecognized to be of type []byte") + } + vf.Set(reflect.ValueOf([]byte(nil))) + } + + // For proto2 messages, only discard unknown fields in message extensions + // that have been accessed via GetExtension. + if em, err := extendable(m); err == nil { + // Ignore lock since discardLegacy is not concurrency safe. + emm, _ := em.extensionsRead() + for _, mx := range emm { + if m, ok := mx.value.(Message); ok { + discardLegacy(m) + } + } + } +} diff --git a/vendor/github.com/golang/protobuf/proto/encode.go b/vendor/github.com/golang/protobuf/proto/encode.go index 8b84d1b..3abfed2 100644 --- a/vendor/github.com/golang/protobuf/proto/encode.go +++ b/vendor/github.com/golang/protobuf/proto/encode.go @@ -37,28 +37,9 @@ package proto import ( "errors" - "fmt" "reflect" - "sort" ) -// RequiredNotSetError is the error returned if Marshal is called with -// a protocol buffer struct whose required fields have not -// all been initialized. It is also the error returned if Unmarshal is -// called with an encoded protocol buffer that does not include all the -// required fields. -// -// When printed, RequiredNotSetError reports the first unset required field in a -// message. If the field cannot be precisely determined, it is reported as -// "{Unknown}". -type RequiredNotSetError struct { - field string -} - -func (e *RequiredNotSetError) Error() string { - return fmt.Sprintf("proto: required field %q not set", e.field) -} - var ( // errRepeatedHasNil is the error returned if Marshal is called with // a struct with a repeated field containing a nil element. @@ -82,10 +63,6 @@ var ( const maxVarintBytes = 10 // maximum length of a varint -// maxMarshalSize is the largest allowed size of an encoded protobuf, -// since C++ and Java use signed int32s for the size. -const maxMarshalSize = 1<<31 - 1 - // EncodeVarint returns the varint encoding of x. // This is the format for the // int32, int64, uint32, uint64, bool, and enum @@ -119,18 +96,27 @@ func (p *Buffer) EncodeVarint(x uint64) error { // SizeVarint returns the varint encoding size of an integer. func SizeVarint(x uint64) int { - return sizeVarint(x) -} - -func sizeVarint(x uint64) (n int) { - for { - n++ - x >>= 7 - if x == 0 { - break - } - } - return n + switch { + case x < 1<<7: + return 1 + case x < 1<<14: + return 2 + case x < 1<<21: + return 3 + case x < 1<<28: + return 4 + case x < 1<<35: + return 5 + case x < 1<<42: + return 6 + case x < 1<<49: + return 7 + case x < 1<<56: + return 8 + case x < 1<<63: + return 9 + } + return 10 } // EncodeFixed64 writes a 64-bit integer to the Buffer. @@ -149,10 +135,6 @@ func (p *Buffer) EncodeFixed64(x uint64) error { return nil } -func sizeFixed64(x uint64) int { - return 8 -} - // EncodeFixed32 writes a 32-bit integer to the Buffer. // This is the format for the // fixed32, sfixed32, and float protocol buffer types. @@ -165,20 +147,12 @@ func (p *Buffer) EncodeFixed32(x uint64) error { return nil } -func sizeFixed32(x uint64) int { - return 4 -} - // EncodeZigzag64 writes a zigzag-encoded 64-bit integer // to the Buffer. // This is the format used for the sint64 protocol buffer type. func (p *Buffer) EncodeZigzag64(x uint64) error { // use signed number to get arithmetic right shift. - return p.EncodeVarint((x << 1) ^ uint64((int64(x) >> 63))) -} - -func sizeZigzag64(x uint64) int { - return sizeVarint((x << 1) ^ uint64((int64(x) >> 63))) + return p.EncodeVarint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } // EncodeZigzag32 writes a zigzag-encoded 32-bit integer @@ -189,10 +163,6 @@ func (p *Buffer) EncodeZigzag32(x uint64) error { return p.EncodeVarint(uint64((uint32(x) << 1) ^ uint32((int32(x) >> 31)))) } -func sizeZigzag32(x uint64) int { - return sizeVarint(uint64((uint32(x) << 1) ^ uint32((int32(x) >> 31)))) -} - // EncodeRawBytes writes a count-delimited byte buffer to the Buffer. // This is the format used for the bytes protocol buffer // type and for embedded messages. @@ -202,11 +172,6 @@ func (p *Buffer) EncodeRawBytes(b []byte) error { return nil } -func sizeRawBytes(b []byte) int { - return sizeVarint(uint64(len(b))) + - len(b) -} - // EncodeStringBytes writes an encoded string to the Buffer. // This is the format used for the proto2 string type. func (p *Buffer) EncodeStringBytes(s string) error { @@ -215,319 +180,17 @@ func (p *Buffer) EncodeStringBytes(s string) error { return nil } -func sizeStringBytes(s string) int { - return sizeVarint(uint64(len(s))) + - len(s) -} - // Marshaler is the interface representing objects that can marshal themselves. type Marshaler interface { Marshal() ([]byte, error) } -// Marshal takes the protocol buffer -// and encodes it into the wire format, returning the data. -func Marshal(pb Message) ([]byte, error) { - // Can the object marshal itself? - if m, ok := pb.(Marshaler); ok { - return m.Marshal() - } - p := NewBuffer(nil) - err := p.Marshal(pb) - if p.buf == nil && err == nil { - // Return a non-nil slice on success. - return []byte{}, nil - } - return p.buf, err -} - // EncodeMessage writes the protocol buffer to the Buffer, // prefixed by a varint-encoded length. func (p *Buffer) EncodeMessage(pb Message) error { - t, base, err := getbase(pb) - if structPointer_IsNil(base) { - return ErrNil - } - if err == nil { - var state errorState - err = p.enc_len_struct(GetProperties(t.Elem()), base, &state) - } - return err -} - -// Marshal takes the protocol buffer -// and encodes it into the wire format, writing the result to the -// Buffer. -func (p *Buffer) Marshal(pb Message) error { - // Can the object marshal itself? - if m, ok := pb.(Marshaler); ok { - data, err := m.Marshal() - p.buf = append(p.buf, data...) - return err - } - - t, base, err := getbase(pb) - if structPointer_IsNil(base) { - return ErrNil - } - if err == nil { - err = p.enc_struct(GetProperties(t.Elem()), base) - } - - if collectStats { - (stats).Encode++ // Parens are to work around a goimports bug. - } - - if len(p.buf) > maxMarshalSize { - return ErrTooLarge - } - return err -} - -// Size returns the encoded size of a protocol buffer. -func Size(pb Message) (n int) { - // Can the object marshal itself? If so, Size is slow. - // TODO: add Size to Marshaler, or add a Sizer interface. - if m, ok := pb.(Marshaler); ok { - b, _ := m.Marshal() - return len(b) - } - - t, base, err := getbase(pb) - if structPointer_IsNil(base) { - return 0 - } - if err == nil { - n = size_struct(GetProperties(t.Elem()), base) - } - - if collectStats { - (stats).Size++ // Parens are to work around a goimports bug. - } - - return -} - -// Individual type encoders. - -// Encode a bool. -func (o *Buffer) enc_bool(p *Properties, base structPointer) error { - v := *structPointer_Bool(base, p.field) - if v == nil { - return ErrNil - } - x := 0 - if *v { - x = 1 - } - o.buf = append(o.buf, p.tagcode...) - p.valEnc(o, uint64(x)) - return nil -} - -func (o *Buffer) enc_proto3_bool(p *Properties, base structPointer) error { - v := *structPointer_BoolVal(base, p.field) - if !v { - return ErrNil - } - o.buf = append(o.buf, p.tagcode...) - p.valEnc(o, 1) - return nil -} - -func size_bool(p *Properties, base structPointer) int { - v := *structPointer_Bool(base, p.field) - if v == nil { - return 0 - } - return len(p.tagcode) + 1 // each bool takes exactly one byte -} - -func size_proto3_bool(p *Properties, base structPointer) int { - v := *structPointer_BoolVal(base, p.field) - if !v && !p.oneof { - return 0 - } - return len(p.tagcode) + 1 // each bool takes exactly one byte -} - -// Encode an int32. -func (o *Buffer) enc_int32(p *Properties, base structPointer) error { - v := structPointer_Word32(base, p.field) - if word32_IsNil(v) { - return ErrNil - } - x := int32(word32_Get(v)) // permit sign extension to use full 64-bit range - o.buf = append(o.buf, p.tagcode...) - p.valEnc(o, uint64(x)) - return nil -} - -func (o *Buffer) enc_proto3_int32(p *Properties, base structPointer) error { - v := structPointer_Word32Val(base, p.field) - x := int32(word32Val_Get(v)) // permit sign extension to use full 64-bit range - if x == 0 { - return ErrNil - } - o.buf = append(o.buf, p.tagcode...) - p.valEnc(o, uint64(x)) - return nil -} - -func size_int32(p *Properties, base structPointer) (n int) { - v := structPointer_Word32(base, p.field) - if word32_IsNil(v) { - return 0 - } - x := int32(word32_Get(v)) // permit sign extension to use full 64-bit range - n += len(p.tagcode) - n += p.valSize(uint64(x)) - return -} - -func size_proto3_int32(p *Properties, base structPointer) (n int) { - v := structPointer_Word32Val(base, p.field) - x := int32(word32Val_Get(v)) // permit sign extension to use full 64-bit range - if x == 0 && !p.oneof { - return 0 - } - n += len(p.tagcode) - n += p.valSize(uint64(x)) - return -} - -// Encode a uint32. -// Exactly the same as int32, except for no sign extension. -func (o *Buffer) enc_uint32(p *Properties, base structPointer) error { - v := structPointer_Word32(base, p.field) - if word32_IsNil(v) { - return ErrNil - } - x := word32_Get(v) - o.buf = append(o.buf, p.tagcode...) - p.valEnc(o, uint64(x)) - return nil -} - -func (o *Buffer) enc_proto3_uint32(p *Properties, base structPointer) error { - v := structPointer_Word32Val(base, p.field) - x := word32Val_Get(v) - if x == 0 { - return ErrNil - } - o.buf = append(o.buf, p.tagcode...) - p.valEnc(o, uint64(x)) - return nil -} - -func size_uint32(p *Properties, base structPointer) (n int) { - v := structPointer_Word32(base, p.field) - if word32_IsNil(v) { - return 0 - } - x := word32_Get(v) - n += len(p.tagcode) - n += p.valSize(uint64(x)) - return -} - -func size_proto3_uint32(p *Properties, base structPointer) (n int) { - v := structPointer_Word32Val(base, p.field) - x := word32Val_Get(v) - if x == 0 && !p.oneof { - return 0 - } - n += len(p.tagcode) - n += p.valSize(uint64(x)) - return -} - -// Encode an int64. -func (o *Buffer) enc_int64(p *Properties, base structPointer) error { - v := structPointer_Word64(base, p.field) - if word64_IsNil(v) { - return ErrNil - } - x := word64_Get(v) - o.buf = append(o.buf, p.tagcode...) - p.valEnc(o, x) - return nil -} - -func (o *Buffer) enc_proto3_int64(p *Properties, base structPointer) error { - v := structPointer_Word64Val(base, p.field) - x := word64Val_Get(v) - if x == 0 { - return ErrNil - } - o.buf = append(o.buf, p.tagcode...) - p.valEnc(o, x) - return nil -} - -func size_int64(p *Properties, base structPointer) (n int) { - v := structPointer_Word64(base, p.field) - if word64_IsNil(v) { - return 0 - } - x := word64_Get(v) - n += len(p.tagcode) - n += p.valSize(x) - return -} - -func size_proto3_int64(p *Properties, base structPointer) (n int) { - v := structPointer_Word64Val(base, p.field) - x := word64Val_Get(v) - if x == 0 && !p.oneof { - return 0 - } - n += len(p.tagcode) - n += p.valSize(x) - return -} - -// Encode a string. -func (o *Buffer) enc_string(p *Properties, base structPointer) error { - v := *structPointer_String(base, p.field) - if v == nil { - return ErrNil - } - x := *v - o.buf = append(o.buf, p.tagcode...) - o.EncodeStringBytes(x) - return nil -} - -func (o *Buffer) enc_proto3_string(p *Properties, base structPointer) error { - v := *structPointer_StringVal(base, p.field) - if v == "" { - return ErrNil - } - o.buf = append(o.buf, p.tagcode...) - o.EncodeStringBytes(v) - return nil -} - -func size_string(p *Properties, base structPointer) (n int) { - v := *structPointer_String(base, p.field) - if v == nil { - return 0 - } - x := *v - n += len(p.tagcode) - n += sizeStringBytes(x) - return -} - -func size_proto3_string(p *Properties, base structPointer) (n int) { - v := *structPointer_StringVal(base, p.field) - if v == "" && !p.oneof { - return 0 - } - n += len(p.tagcode) - n += sizeStringBytes(v) - return + siz := Size(pb) + p.EncodeVarint(uint64(siz)) + return p.Marshal(pb) } // All protocol buffer fields are nillable, but be careful. @@ -538,825 +201,3 @@ func isNil(v reflect.Value) bool { } return false } - -// Encode a message struct. -func (o *Buffer) enc_struct_message(p *Properties, base structPointer) error { - var state errorState - structp := structPointer_GetStructPointer(base, p.field) - if structPointer_IsNil(structp) { - return ErrNil - } - - // Can the object marshal itself? - if p.isMarshaler { - m := structPointer_Interface(structp, p.stype).(Marshaler) - data, err := m.Marshal() - if err != nil && !state.shouldContinue(err, nil) { - return err - } - o.buf = append(o.buf, p.tagcode...) - o.EncodeRawBytes(data) - return state.err - } - - o.buf = append(o.buf, p.tagcode...) - return o.enc_len_struct(p.sprop, structp, &state) -} - -func size_struct_message(p *Properties, base structPointer) int { - structp := structPointer_GetStructPointer(base, p.field) - if structPointer_IsNil(structp) { - return 0 - } - - // Can the object marshal itself? - if p.isMarshaler { - m := structPointer_Interface(structp, p.stype).(Marshaler) - data, _ := m.Marshal() - n0 := len(p.tagcode) - n1 := sizeRawBytes(data) - return n0 + n1 - } - - n0 := len(p.tagcode) - n1 := size_struct(p.sprop, structp) - n2 := sizeVarint(uint64(n1)) // size of encoded length - return n0 + n1 + n2 -} - -// Encode a group struct. -func (o *Buffer) enc_struct_group(p *Properties, base structPointer) error { - var state errorState - b := structPointer_GetStructPointer(base, p.field) - if structPointer_IsNil(b) { - return ErrNil - } - - o.EncodeVarint(uint64((p.Tag << 3) | WireStartGroup)) - err := o.enc_struct(p.sprop, b) - if err != nil && !state.shouldContinue(err, nil) { - return err - } - o.EncodeVarint(uint64((p.Tag << 3) | WireEndGroup)) - return state.err -} - -func size_struct_group(p *Properties, base structPointer) (n int) { - b := structPointer_GetStructPointer(base, p.field) - if structPointer_IsNil(b) { - return 0 - } - - n += sizeVarint(uint64((p.Tag << 3) | WireStartGroup)) - n += size_struct(p.sprop, b) - n += sizeVarint(uint64((p.Tag << 3) | WireEndGroup)) - return -} - -// Encode a slice of bools ([]bool). -func (o *Buffer) enc_slice_bool(p *Properties, base structPointer) error { - s := *structPointer_BoolSlice(base, p.field) - l := len(s) - if l == 0 { - return ErrNil - } - for _, x := range s { - o.buf = append(o.buf, p.tagcode...) - v := uint64(0) - if x { - v = 1 - } - p.valEnc(o, v) - } - return nil -} - -func size_slice_bool(p *Properties, base structPointer) int { - s := *structPointer_BoolSlice(base, p.field) - l := len(s) - if l == 0 { - return 0 - } - return l * (len(p.tagcode) + 1) // each bool takes exactly one byte -} - -// Encode a slice of bools ([]bool) in packed format. -func (o *Buffer) enc_slice_packed_bool(p *Properties, base structPointer) error { - s := *structPointer_BoolSlice(base, p.field) - l := len(s) - if l == 0 { - return ErrNil - } - o.buf = append(o.buf, p.tagcode...) - o.EncodeVarint(uint64(l)) // each bool takes exactly one byte - for _, x := range s { - v := uint64(0) - if x { - v = 1 - } - p.valEnc(o, v) - } - return nil -} - -func size_slice_packed_bool(p *Properties, base structPointer) (n int) { - s := *structPointer_BoolSlice(base, p.field) - l := len(s) - if l == 0 { - return 0 - } - n += len(p.tagcode) - n += sizeVarint(uint64(l)) - n += l // each bool takes exactly one byte - return -} - -// Encode a slice of bytes ([]byte). -func (o *Buffer) enc_slice_byte(p *Properties, base structPointer) error { - s := *structPointer_Bytes(base, p.field) - if s == nil { - return ErrNil - } - o.buf = append(o.buf, p.tagcode...) - o.EncodeRawBytes(s) - return nil -} - -func (o *Buffer) enc_proto3_slice_byte(p *Properties, base structPointer) error { - s := *structPointer_Bytes(base, p.field) - if len(s) == 0 { - return ErrNil - } - o.buf = append(o.buf, p.tagcode...) - o.EncodeRawBytes(s) - return nil -} - -func size_slice_byte(p *Properties, base structPointer) (n int) { - s := *structPointer_Bytes(base, p.field) - if s == nil && !p.oneof { - return 0 - } - n += len(p.tagcode) - n += sizeRawBytes(s) - return -} - -func size_proto3_slice_byte(p *Properties, base structPointer) (n int) { - s := *structPointer_Bytes(base, p.field) - if len(s) == 0 && !p.oneof { - return 0 - } - n += len(p.tagcode) - n += sizeRawBytes(s) - return -} - -// Encode a slice of int32s ([]int32). -func (o *Buffer) enc_slice_int32(p *Properties, base structPointer) error { - s := structPointer_Word32Slice(base, p.field) - l := s.Len() - if l == 0 { - return ErrNil - } - for i := 0; i < l; i++ { - o.buf = append(o.buf, p.tagcode...) - x := int32(s.Index(i)) // permit sign extension to use full 64-bit range - p.valEnc(o, uint64(x)) - } - return nil -} - -func size_slice_int32(p *Properties, base structPointer) (n int) { - s := structPointer_Word32Slice(base, p.field) - l := s.Len() - if l == 0 { - return 0 - } - for i := 0; i < l; i++ { - n += len(p.tagcode) - x := int32(s.Index(i)) // permit sign extension to use full 64-bit range - n += p.valSize(uint64(x)) - } - return -} - -// Encode a slice of int32s ([]int32) in packed format. -func (o *Buffer) enc_slice_packed_int32(p *Properties, base structPointer) error { - s := structPointer_Word32Slice(base, p.field) - l := s.Len() - if l == 0 { - return ErrNil - } - // TODO: Reuse a Buffer. - buf := NewBuffer(nil) - for i := 0; i < l; i++ { - x := int32(s.Index(i)) // permit sign extension to use full 64-bit range - p.valEnc(buf, uint64(x)) - } - - o.buf = append(o.buf, p.tagcode...) - o.EncodeVarint(uint64(len(buf.buf))) - o.buf = append(o.buf, buf.buf...) - return nil -} - -func size_slice_packed_int32(p *Properties, base structPointer) (n int) { - s := structPointer_Word32Slice(base, p.field) - l := s.Len() - if l == 0 { - return 0 - } - var bufSize int - for i := 0; i < l; i++ { - x := int32(s.Index(i)) // permit sign extension to use full 64-bit range - bufSize += p.valSize(uint64(x)) - } - - n += len(p.tagcode) - n += sizeVarint(uint64(bufSize)) - n += bufSize - return -} - -// Encode a slice of uint32s ([]uint32). -// Exactly the same as int32, except for no sign extension. -func (o *Buffer) enc_slice_uint32(p *Properties, base structPointer) error { - s := structPointer_Word32Slice(base, p.field) - l := s.Len() - if l == 0 { - return ErrNil - } - for i := 0; i < l; i++ { - o.buf = append(o.buf, p.tagcode...) - x := s.Index(i) - p.valEnc(o, uint64(x)) - } - return nil -} - -func size_slice_uint32(p *Properties, base structPointer) (n int) { - s := structPointer_Word32Slice(base, p.field) - l := s.Len() - if l == 0 { - return 0 - } - for i := 0; i < l; i++ { - n += len(p.tagcode) - x := s.Index(i) - n += p.valSize(uint64(x)) - } - return -} - -// Encode a slice of uint32s ([]uint32) in packed format. -// Exactly the same as int32, except for no sign extension. -func (o *Buffer) enc_slice_packed_uint32(p *Properties, base structPointer) error { - s := structPointer_Word32Slice(base, p.field) - l := s.Len() - if l == 0 { - return ErrNil - } - // TODO: Reuse a Buffer. - buf := NewBuffer(nil) - for i := 0; i < l; i++ { - p.valEnc(buf, uint64(s.Index(i))) - } - - o.buf = append(o.buf, p.tagcode...) - o.EncodeVarint(uint64(len(buf.buf))) - o.buf = append(o.buf, buf.buf...) - return nil -} - -func size_slice_packed_uint32(p *Properties, base structPointer) (n int) { - s := structPointer_Word32Slice(base, p.field) - l := s.Len() - if l == 0 { - return 0 - } - var bufSize int - for i := 0; i < l; i++ { - bufSize += p.valSize(uint64(s.Index(i))) - } - - n += len(p.tagcode) - n += sizeVarint(uint64(bufSize)) - n += bufSize - return -} - -// Encode a slice of int64s ([]int64). -func (o *Buffer) enc_slice_int64(p *Properties, base structPointer) error { - s := structPointer_Word64Slice(base, p.field) - l := s.Len() - if l == 0 { - return ErrNil - } - for i := 0; i < l; i++ { - o.buf = append(o.buf, p.tagcode...) - p.valEnc(o, s.Index(i)) - } - return nil -} - -func size_slice_int64(p *Properties, base structPointer) (n int) { - s := structPointer_Word64Slice(base, p.field) - l := s.Len() - if l == 0 { - return 0 - } - for i := 0; i < l; i++ { - n += len(p.tagcode) - n += p.valSize(s.Index(i)) - } - return -} - -// Encode a slice of int64s ([]int64) in packed format. -func (o *Buffer) enc_slice_packed_int64(p *Properties, base structPointer) error { - s := structPointer_Word64Slice(base, p.field) - l := s.Len() - if l == 0 { - return ErrNil - } - // TODO: Reuse a Buffer. - buf := NewBuffer(nil) - for i := 0; i < l; i++ { - p.valEnc(buf, s.Index(i)) - } - - o.buf = append(o.buf, p.tagcode...) - o.EncodeVarint(uint64(len(buf.buf))) - o.buf = append(o.buf, buf.buf...) - return nil -} - -func size_slice_packed_int64(p *Properties, base structPointer) (n int) { - s := structPointer_Word64Slice(base, p.field) - l := s.Len() - if l == 0 { - return 0 - } - var bufSize int - for i := 0; i < l; i++ { - bufSize += p.valSize(s.Index(i)) - } - - n += len(p.tagcode) - n += sizeVarint(uint64(bufSize)) - n += bufSize - return -} - -// Encode a slice of slice of bytes ([][]byte). -func (o *Buffer) enc_slice_slice_byte(p *Properties, base structPointer) error { - ss := *structPointer_BytesSlice(base, p.field) - l := len(ss) - if l == 0 { - return ErrNil - } - for i := 0; i < l; i++ { - o.buf = append(o.buf, p.tagcode...) - o.EncodeRawBytes(ss[i]) - } - return nil -} - -func size_slice_slice_byte(p *Properties, base structPointer) (n int) { - ss := *structPointer_BytesSlice(base, p.field) - l := len(ss) - if l == 0 { - return 0 - } - n += l * len(p.tagcode) - for i := 0; i < l; i++ { - n += sizeRawBytes(ss[i]) - } - return -} - -// Encode a slice of strings ([]string). -func (o *Buffer) enc_slice_string(p *Properties, base structPointer) error { - ss := *structPointer_StringSlice(base, p.field) - l := len(ss) - for i := 0; i < l; i++ { - o.buf = append(o.buf, p.tagcode...) - o.EncodeStringBytes(ss[i]) - } - return nil -} - -func size_slice_string(p *Properties, base structPointer) (n int) { - ss := *structPointer_StringSlice(base, p.field) - l := len(ss) - n += l * len(p.tagcode) - for i := 0; i < l; i++ { - n += sizeStringBytes(ss[i]) - } - return -} - -// Encode a slice of message structs ([]*struct). -func (o *Buffer) enc_slice_struct_message(p *Properties, base structPointer) error { - var state errorState - s := structPointer_StructPointerSlice(base, p.field) - l := s.Len() - - for i := 0; i < l; i++ { - structp := s.Index(i) - if structPointer_IsNil(structp) { - return errRepeatedHasNil - } - - // Can the object marshal itself? - if p.isMarshaler { - m := structPointer_Interface(structp, p.stype).(Marshaler) - data, err := m.Marshal() - if err != nil && !state.shouldContinue(err, nil) { - return err - } - o.buf = append(o.buf, p.tagcode...) - o.EncodeRawBytes(data) - continue - } - - o.buf = append(o.buf, p.tagcode...) - err := o.enc_len_struct(p.sprop, structp, &state) - if err != nil && !state.shouldContinue(err, nil) { - if err == ErrNil { - return errRepeatedHasNil - } - return err - } - } - return state.err -} - -func size_slice_struct_message(p *Properties, base structPointer) (n int) { - s := structPointer_StructPointerSlice(base, p.field) - l := s.Len() - n += l * len(p.tagcode) - for i := 0; i < l; i++ { - structp := s.Index(i) - if structPointer_IsNil(structp) { - return // return the size up to this point - } - - // Can the object marshal itself? - if p.isMarshaler { - m := structPointer_Interface(structp, p.stype).(Marshaler) - data, _ := m.Marshal() - n += sizeRawBytes(data) - continue - } - - n0 := size_struct(p.sprop, structp) - n1 := sizeVarint(uint64(n0)) // size of encoded length - n += n0 + n1 - } - return -} - -// Encode a slice of group structs ([]*struct). -func (o *Buffer) enc_slice_struct_group(p *Properties, base structPointer) error { - var state errorState - s := structPointer_StructPointerSlice(base, p.field) - l := s.Len() - - for i := 0; i < l; i++ { - b := s.Index(i) - if structPointer_IsNil(b) { - return errRepeatedHasNil - } - - o.EncodeVarint(uint64((p.Tag << 3) | WireStartGroup)) - - err := o.enc_struct(p.sprop, b) - - if err != nil && !state.shouldContinue(err, nil) { - if err == ErrNil { - return errRepeatedHasNil - } - return err - } - - o.EncodeVarint(uint64((p.Tag << 3) | WireEndGroup)) - } - return state.err -} - -func size_slice_struct_group(p *Properties, base structPointer) (n int) { - s := structPointer_StructPointerSlice(base, p.field) - l := s.Len() - - n += l * sizeVarint(uint64((p.Tag<<3)|WireStartGroup)) - n += l * sizeVarint(uint64((p.Tag<<3)|WireEndGroup)) - for i := 0; i < l; i++ { - b := s.Index(i) - if structPointer_IsNil(b) { - return // return size up to this point - } - - n += size_struct(p.sprop, b) - } - return -} - -// Encode an extension map. -func (o *Buffer) enc_map(p *Properties, base structPointer) error { - exts := structPointer_ExtMap(base, p.field) - if err := encodeExtensionsMap(*exts); err != nil { - return err - } - - return o.enc_map_body(*exts) -} - -func (o *Buffer) enc_exts(p *Properties, base structPointer) error { - exts := structPointer_Extensions(base, p.field) - - v, mu := exts.extensionsRead() - if v == nil { - return nil - } - - mu.Lock() - defer mu.Unlock() - if err := encodeExtensionsMap(v); err != nil { - return err - } - - return o.enc_map_body(v) -} - -func (o *Buffer) enc_map_body(v map[int32]Extension) error { - // Fast-path for common cases: zero or one extensions. - if len(v) <= 1 { - for _, e := range v { - o.buf = append(o.buf, e.enc...) - } - return nil - } - - // Sort keys to provide a deterministic encoding. - keys := make([]int, 0, len(v)) - for k := range v { - keys = append(keys, int(k)) - } - sort.Ints(keys) - - for _, k := range keys { - o.buf = append(o.buf, v[int32(k)].enc...) - } - return nil -} - -func size_map(p *Properties, base structPointer) int { - v := structPointer_ExtMap(base, p.field) - return extensionsMapSize(*v) -} - -func size_exts(p *Properties, base structPointer) int { - v := structPointer_Extensions(base, p.field) - return extensionsSize(v) -} - -// Encode a map field. -func (o *Buffer) enc_new_map(p *Properties, base structPointer) error { - var state errorState // XXX: or do we need to plumb this through? - - /* - A map defined as - map map_field = N; - is encoded in the same way as - message MapFieldEntry { - key_type key = 1; - value_type value = 2; - } - repeated MapFieldEntry map_field = N; - */ - - v := structPointer_NewAt(base, p.field, p.mtype).Elem() // map[K]V - if v.Len() == 0 { - return nil - } - - keycopy, valcopy, keybase, valbase := mapEncodeScratch(p.mtype) - - enc := func() error { - if err := p.mkeyprop.enc(o, p.mkeyprop, keybase); err != nil { - return err - } - if err := p.mvalprop.enc(o, p.mvalprop, valbase); err != nil && err != ErrNil { - return err - } - return nil - } - - // Don't sort map keys. It is not required by the spec, and C++ doesn't do it. - for _, key := range v.MapKeys() { - val := v.MapIndex(key) - - keycopy.Set(key) - valcopy.Set(val) - - o.buf = append(o.buf, p.tagcode...) - if err := o.enc_len_thing(enc, &state); err != nil { - return err - } - } - return nil -} - -func size_new_map(p *Properties, base structPointer) int { - v := structPointer_NewAt(base, p.field, p.mtype).Elem() // map[K]V - - keycopy, valcopy, keybase, valbase := mapEncodeScratch(p.mtype) - - n := 0 - for _, key := range v.MapKeys() { - val := v.MapIndex(key) - keycopy.Set(key) - valcopy.Set(val) - - // Tag codes for key and val are the responsibility of the sub-sizer. - keysize := p.mkeyprop.size(p.mkeyprop, keybase) - valsize := p.mvalprop.size(p.mvalprop, valbase) - entry := keysize + valsize - // Add on tag code and length of map entry itself. - n += len(p.tagcode) + sizeVarint(uint64(entry)) + entry - } - return n -} - -// mapEncodeScratch returns a new reflect.Value matching the map's value type, -// and a structPointer suitable for passing to an encoder or sizer. -func mapEncodeScratch(mapType reflect.Type) (keycopy, valcopy reflect.Value, keybase, valbase structPointer) { - // Prepare addressable doubly-indirect placeholders for the key and value types. - // This is needed because the element-type encoders expect **T, but the map iteration produces T. - - keycopy = reflect.New(mapType.Key()).Elem() // addressable K - keyptr := reflect.New(reflect.PtrTo(keycopy.Type())).Elem() // addressable *K - keyptr.Set(keycopy.Addr()) // - keybase = toStructPointer(keyptr.Addr()) // **K - - // Value types are more varied and require special handling. - switch mapType.Elem().Kind() { - case reflect.Slice: - // []byte - var dummy []byte - valcopy = reflect.ValueOf(&dummy).Elem() // addressable []byte - valbase = toStructPointer(valcopy.Addr()) - case reflect.Ptr: - // message; the generated field type is map[K]*Msg (so V is *Msg), - // so we only need one level of indirection. - valcopy = reflect.New(mapType.Elem()).Elem() // addressable V - valbase = toStructPointer(valcopy.Addr()) - default: - // everything else - valcopy = reflect.New(mapType.Elem()).Elem() // addressable V - valptr := reflect.New(reflect.PtrTo(valcopy.Type())).Elem() // addressable *V - valptr.Set(valcopy.Addr()) // - valbase = toStructPointer(valptr.Addr()) // **V - } - return -} - -// Encode a struct. -func (o *Buffer) enc_struct(prop *StructProperties, base structPointer) error { - var state errorState - // Encode fields in tag order so that decoders may use optimizations - // that depend on the ordering. - // https://developers.google.com/protocol-buffers/docs/encoding#order - for _, i := range prop.order { - p := prop.Prop[i] - if p.enc != nil { - err := p.enc(o, p, base) - if err != nil { - if err == ErrNil { - if p.Required && state.err == nil { - state.err = &RequiredNotSetError{p.Name} - } - } else if err == errRepeatedHasNil { - // Give more context to nil values in repeated fields. - return errors.New("repeated field " + p.OrigName + " has nil element") - } else if !state.shouldContinue(err, p) { - return err - } - } - if len(o.buf) > maxMarshalSize { - return ErrTooLarge - } - } - } - - // Do oneof fields. - if prop.oneofMarshaler != nil { - m := structPointer_Interface(base, prop.stype).(Message) - if err := prop.oneofMarshaler(m, o); err == ErrNil { - return errOneofHasNil - } else if err != nil { - return err - } - } - - // Add unrecognized fields at the end. - if prop.unrecField.IsValid() { - v := *structPointer_Bytes(base, prop.unrecField) - if len(o.buf)+len(v) > maxMarshalSize { - return ErrTooLarge - } - if len(v) > 0 { - o.buf = append(o.buf, v...) - } - } - - return state.err -} - -func size_struct(prop *StructProperties, base structPointer) (n int) { - for _, i := range prop.order { - p := prop.Prop[i] - if p.size != nil { - n += p.size(p, base) - } - } - - // Add unrecognized fields at the end. - if prop.unrecField.IsValid() { - v := *structPointer_Bytes(base, prop.unrecField) - n += len(v) - } - - // Factor in any oneof fields. - if prop.oneofSizer != nil { - m := structPointer_Interface(base, prop.stype).(Message) - n += prop.oneofSizer(m) - } - - return -} - -var zeroes [20]byte // longer than any conceivable sizeVarint - -// Encode a struct, preceded by its encoded length (as a varint). -func (o *Buffer) enc_len_struct(prop *StructProperties, base structPointer, state *errorState) error { - return o.enc_len_thing(func() error { return o.enc_struct(prop, base) }, state) -} - -// Encode something, preceded by its encoded length (as a varint). -func (o *Buffer) enc_len_thing(enc func() error, state *errorState) error { - iLen := len(o.buf) - o.buf = append(o.buf, 0, 0, 0, 0) // reserve four bytes for length - iMsg := len(o.buf) - err := enc() - if err != nil && !state.shouldContinue(err, nil) { - return err - } - lMsg := len(o.buf) - iMsg - lLen := sizeVarint(uint64(lMsg)) - switch x := lLen - (iMsg - iLen); { - case x > 0: // actual length is x bytes larger than the space we reserved - // Move msg x bytes right. - o.buf = append(o.buf, zeroes[:x]...) - copy(o.buf[iMsg+x:], o.buf[iMsg:iMsg+lMsg]) - case x < 0: // actual length is x bytes smaller than the space we reserved - // Move msg x bytes left. - copy(o.buf[iMsg+x:], o.buf[iMsg:iMsg+lMsg]) - o.buf = o.buf[:len(o.buf)+x] // x is negative - } - // Encode the length in the reserved space. - o.buf = o.buf[:iLen] - o.EncodeVarint(uint64(lMsg)) - o.buf = o.buf[:len(o.buf)+lMsg] - return state.err -} - -// errorState maintains the first error that occurs and updates that error -// with additional context. -type errorState struct { - err error -} - -// shouldContinue reports whether encoding should continue upon encountering the -// given error. If the error is RequiredNotSetError, shouldContinue returns true -// and, if this is the first appearance of that error, remembers it for future -// reporting. -// -// If prop is not nil, it may update any error with additional context about the -// field with the error. -func (s *errorState) shouldContinue(err error, prop *Properties) bool { - // Ignore unset required fields. - reqNotSet, ok := err.(*RequiredNotSetError) - if !ok { - return false - } - if s.err == nil { - if prop != nil { - err = &RequiredNotSetError{prop.Name + "." + reqNotSet.field} - } - s.err = err - } - return true -} diff --git a/vendor/github.com/golang/protobuf/proto/equal.go b/vendor/github.com/golang/protobuf/proto/equal.go index 2ed1cf5..d4db5a1 100644 --- a/vendor/github.com/golang/protobuf/proto/equal.go +++ b/vendor/github.com/golang/protobuf/proto/equal.go @@ -109,15 +109,6 @@ func equalStruct(v1, v2 reflect.Value) bool { // set/unset mismatch return false } - b1, ok := f1.Interface().(raw) - if ok { - b2 := f2.Interface().(raw) - // RawMessage - if !bytes.Equal(b1.Bytes(), b2.Bytes()) { - return false - } - continue - } f1, f2 = f1.Elem(), f2.Elem() } if !equalAny(f1, f2, sprop.Prop[i]) { @@ -146,11 +137,7 @@ func equalStruct(v1, v2 reflect.Value) bool { u1 := uf.Bytes() u2 := v2.FieldByName("XXX_unrecognized").Bytes() - if !bytes.Equal(u1, u2) { - return false - } - - return true + return bytes.Equal(u1, u2) } // v1 and v2 are known to have the same type. @@ -261,6 +248,15 @@ func equalExtMap(base reflect.Type, em1, em2 map[int32]Extension) bool { m1, m2 := e1.value, e2.value + if m1 == nil && m2 == nil { + // Both have only encoded form. + if bytes.Equal(e1.enc, e2.enc) { + continue + } + // The bytes are different, but the extensions might still be + // equal. We need to decode them to compare. + } + if m1 != nil && m2 != nil { // Both are unencoded. if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) { @@ -276,8 +272,12 @@ func equalExtMap(base reflect.Type, em1, em2 map[int32]Extension) bool { desc = m[extNum] } if desc == nil { + // If both have only encoded form and the bytes are the same, + // it is handled above. We get here when the bytes are different. + // We don't know how to decode it, so just compare them as byte + // slices. log.Printf("proto: don't know how to compare extension %d of %v", extNum, base) - continue + return false } var err error if m1 == nil { diff --git a/vendor/github.com/golang/protobuf/proto/extensions.go b/vendor/github.com/golang/protobuf/proto/extensions.go index eaad218..816a3b9 100644 --- a/vendor/github.com/golang/protobuf/proto/extensions.go +++ b/vendor/github.com/golang/protobuf/proto/extensions.go @@ -38,6 +38,7 @@ package proto import ( "errors" "fmt" + "io" "reflect" "strconv" "sync" @@ -91,14 +92,29 @@ func (n notLocker) Unlock() {} // extendable returns the extendableProto interface for the given generated proto message. // If the proto message has the old extension format, it returns a wrapper that implements // the extendableProto interface. -func extendable(p interface{}) (extendableProto, bool) { - if ep, ok := p.(extendableProto); ok { - return ep, ok - } - if ep, ok := p.(extendableProtoV1); ok { - return extensionAdapter{ep}, ok +func extendable(p interface{}) (extendableProto, error) { + switch p := p.(type) { + case extendableProto: + if isNilPtr(p) { + return nil, fmt.Errorf("proto: nil %T is not extendable", p) + } + return p, nil + case extendableProtoV1: + if isNilPtr(p) { + return nil, fmt.Errorf("proto: nil %T is not extendable", p) + } + return extensionAdapter{p}, nil } - return nil, false + // Don't allocate a specific error containing %T: + // this is the hot path for Clone and MarshalText. + return nil, errNotExtendable +} + +var errNotExtendable = errors.New("proto: not an extendable proto.Message") + +func isNilPtr(x interface{}) bool { + v := reflect.ValueOf(x) + return v.Kind() == reflect.Ptr && v.IsNil() } // XXX_InternalExtensions is an internal representation of proto extensions. @@ -143,9 +159,6 @@ func (e *XXX_InternalExtensions) extensionsRead() (map[int32]Extension, sync.Loc return e.p.extensionMap, &e.p.mu } -var extendableProtoType = reflect.TypeOf((*extendableProto)(nil)).Elem() -var extendableProtoV1Type = reflect.TypeOf((*extendableProtoV1)(nil)).Elem() - // ExtensionDesc represents an extension specification. // Used in generated code from the protocol compiler. type ExtensionDesc struct { @@ -179,8 +192,8 @@ type Extension struct { // SetRawExtension is for testing only. func SetRawExtension(base Message, id int32, b []byte) { - epb, ok := extendable(base) - if !ok { + epb, err := extendable(base) + if err != nil { return } extmap := epb.extensionsWrite() @@ -205,7 +218,7 @@ func checkExtensionTypes(pb extendableProto, extension *ExtensionDesc) error { pbi = ea.extendableProtoV1 } if a, b := reflect.TypeOf(pbi), reflect.TypeOf(extension.ExtendedType); a != b { - return errors.New("proto: bad extended type; " + b.String() + " does not extend " + a.String()) + return fmt.Errorf("proto: bad extended type; %v does not extend %v", b, a) } // Check the range. if !isExtensionField(pb, extension.Field) { @@ -250,85 +263,11 @@ func extensionProperties(ed *ExtensionDesc) *Properties { return prop } -// encode encodes any unmarshaled (unencoded) extensions in e. -func encodeExtensions(e *XXX_InternalExtensions) error { - m, mu := e.extensionsRead() - if m == nil { - return nil // fast path - } - mu.Lock() - defer mu.Unlock() - return encodeExtensionsMap(m) -} - -// encode encodes any unmarshaled (unencoded) extensions in e. -func encodeExtensionsMap(m map[int32]Extension) error { - for k, e := range m { - if e.value == nil || e.desc == nil { - // Extension is only in its encoded form. - continue - } - - // We don't skip extensions that have an encoded form set, - // because the extension value may have been mutated after - // the last time this function was called. - - et := reflect.TypeOf(e.desc.ExtensionType) - props := extensionProperties(e.desc) - - p := NewBuffer(nil) - // If e.value has type T, the encoder expects a *struct{ X T }. - // Pass a *T with a zero field and hope it all works out. - x := reflect.New(et) - x.Elem().Set(reflect.ValueOf(e.value)) - if err := props.enc(p, props, toStructPointer(x)); err != nil { - return err - } - e.enc = p.buf - m[k] = e - } - return nil -} - -func extensionsSize(e *XXX_InternalExtensions) (n int) { - m, mu := e.extensionsRead() - if m == nil { - return 0 - } - mu.Lock() - defer mu.Unlock() - return extensionsMapSize(m) -} - -func extensionsMapSize(m map[int32]Extension) (n int) { - for _, e := range m { - if e.value == nil || e.desc == nil { - // Extension is only in its encoded form. - n += len(e.enc) - continue - } - - // We don't skip extensions that have an encoded form set, - // because the extension value may have been mutated after - // the last time this function was called. - - et := reflect.TypeOf(e.desc.ExtensionType) - props := extensionProperties(e.desc) - - // If e.value has type T, the encoder expects a *struct{ X T }. - // Pass a *T with a zero field and hope it all works out. - x := reflect.New(et) - x.Elem().Set(reflect.ValueOf(e.value)) - n += props.size(props, toStructPointer(x)) - } - return -} - // HasExtension returns whether the given extension is present in pb. func HasExtension(pb Message, extension *ExtensionDesc) bool { // TODO: Check types, field numbers, etc.? - epb, ok := extendable(pb) - if !ok { + epb, err := extendable(pb) + if err != nil { return false } extmap, mu := epb.extensionsRead() @@ -336,15 +275,15 @@ func HasExtension(pb Message, extension *ExtensionDesc) bool { return false } mu.Lock() - _, ok = extmap[extension.Field] + _, ok := extmap[extension.Field] mu.Unlock() return ok } // ClearExtension removes the given extension from pb. func ClearExtension(pb Message, extension *ExtensionDesc) { - epb, ok := extendable(pb) - if !ok { + epb, err := extendable(pb) + if err != nil { return } // TODO: Check types, field numbers, etc.? @@ -352,16 +291,26 @@ func ClearExtension(pb Message, extension *ExtensionDesc) { delete(extmap, extension.Field) } -// GetExtension parses and returns the given extension of pb. -// If the extension is not present and has no default value it returns ErrMissingExtension. +// GetExtension retrieves a proto2 extended field from pb. +// +// If the descriptor is type complete (i.e., ExtensionDesc.ExtensionType is non-nil), +// then GetExtension parses the encoded field and returns a Go value of the specified type. +// If the field is not present, then the default value is returned (if one is specified), +// otherwise ErrMissingExtension is reported. +// +// If the descriptor is not type complete (i.e., ExtensionDesc.ExtensionType is nil), +// then GetExtension returns the raw encoded bytes of the field extension. func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) { - epb, ok := extendable(pb) - if !ok { - return nil, errors.New("proto: not an extendable proto") + epb, err := extendable(pb) + if err != nil { + return nil, err } - if err := checkExtensionTypes(epb, extension); err != nil { - return nil, err + if extension.ExtendedType != nil { + // can only check type if this is a complete descriptor + if err := checkExtensionTypes(epb, extension); err != nil { + return nil, err + } } emap, mu := epb.extensionsRead() @@ -388,6 +337,11 @@ func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) { return e.value, nil } + if extension.ExtensionType == nil { + // incomplete descriptor + return e.enc, nil + } + v, err := decodeExtension(e.enc, extension) if err != nil { return nil, err @@ -405,6 +359,11 @@ func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) { // defaultExtensionValue returns the default value for extension. // If no default for an extension is defined ErrMissingExtension is returned. func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) { + if extension.ExtensionType == nil { + // incomplete descriptor, so no default + return nil, ErrMissingExtension + } + t := reflect.TypeOf(extension.ExtensionType) props := extensionProperties(extension) @@ -439,31 +398,28 @@ func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) { // decodeExtension decodes an extension encoded in b. func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) { - o := NewBuffer(b) - t := reflect.TypeOf(extension.ExtensionType) - - props := extensionProperties(extension) + unmarshal := typeUnmarshaler(t, extension.Tag) // t is a pointer to a struct, pointer to basic type or a slice. - // Allocate a "field" to store the pointer/slice itself; the - // pointer/slice will be stored here. We pass - // the address of this field to props.dec. - // This passes a zero field and a *t and lets props.dec - // interpret it as a *struct{ x t }. + // Allocate space to store the pointer/slice. value := reflect.New(t).Elem() + var err error for { - // Discard wire type and field number varint. It isn't needed. - if _, err := o.DecodeVarint(); err != nil { - return nil, err + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF } + b = b[n:] + wire := int(x) & 7 - if err := props.dec(o, props, toStructPointer(value.Addr())); err != nil { + b, err = unmarshal(b, valToPointer(value.Addr()), wire) + if err != nil { return nil, err } - if o.index >= len(o.buf) { + if len(b) == 0 { break } } @@ -473,9 +429,9 @@ func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) { // GetExtensions returns a slice of the extensions present in pb that are also listed in es. // The returned slice has the same length as es; missing extensions will appear as nil elements. func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, err error) { - epb, ok := extendable(pb) - if !ok { - return nil, errors.New("proto: not an extendable proto") + epb, err := extendable(pb) + if err != nil { + return nil, err } extensions = make([]interface{}, len(es)) for i, e := range es { @@ -494,9 +450,9 @@ func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, e // For non-registered extensions, ExtensionDescs returns an incomplete descriptor containing // just the Field field, which defines the extension's field number. func ExtensionDescs(pb Message) ([]*ExtensionDesc, error) { - epb, ok := extendable(pb) - if !ok { - return nil, fmt.Errorf("proto: %T is not an extendable proto.Message", pb) + epb, err := extendable(pb) + if err != nil { + return nil, err } registeredExtensions := RegisteredExtensions(pb) @@ -523,9 +479,9 @@ func ExtensionDescs(pb Message) ([]*ExtensionDesc, error) { // SetExtension sets the specified extension of pb to the specified value. func SetExtension(pb Message, extension *ExtensionDesc, value interface{}) error { - epb, ok := extendable(pb) - if !ok { - return errors.New("proto: not an extendable proto") + epb, err := extendable(pb) + if err != nil { + return err } if err := checkExtensionTypes(epb, extension); err != nil { return err @@ -550,8 +506,8 @@ func SetExtension(pb Message, extension *ExtensionDesc, value interface{}) error // ClearAllExtensions clears all extensions from pb. func ClearAllExtensions(pb Message) { - epb, ok := extendable(pb) - if !ok { + epb, err := extendable(pb) + if err != nil { return } m := epb.extensionsWrite() diff --git a/vendor/github.com/golang/protobuf/proto/lib.go b/vendor/github.com/golang/protobuf/proto/lib.go index 1c22550..75565cc 100644 --- a/vendor/github.com/golang/protobuf/proto/lib.go +++ b/vendor/github.com/golang/protobuf/proto/lib.go @@ -273,6 +273,67 @@ import ( "sync" ) +// RequiredNotSetError is an error type returned by either Marshal or Unmarshal. +// Marshal reports this when a required field is not initialized. +// Unmarshal reports this when a required field is missing from the wire data. +type RequiredNotSetError struct{ field string } + +func (e *RequiredNotSetError) Error() string { + if e.field == "" { + return fmt.Sprintf("proto: required field not set") + } + return fmt.Sprintf("proto: required field %q not set", e.field) +} +func (e *RequiredNotSetError) RequiredNotSet() bool { + return true +} + +type invalidUTF8Error struct{ field string } + +func (e *invalidUTF8Error) Error() string { + if e.field == "" { + return "proto: invalid UTF-8 detected" + } + return fmt.Sprintf("proto: field %q contains invalid UTF-8", e.field) +} +func (e *invalidUTF8Error) InvalidUTF8() bool { + return true +} + +// errInvalidUTF8 is a sentinel error to identify fields with invalid UTF-8. +// This error should not be exposed to the external API as such errors should +// be recreated with the field information. +var errInvalidUTF8 = &invalidUTF8Error{} + +// isNonFatal reports whether the error is either a RequiredNotSet error +// or a InvalidUTF8 error. +func isNonFatal(err error) bool { + if re, ok := err.(interface{ RequiredNotSet() bool }); ok && re.RequiredNotSet() { + return true + } + if re, ok := err.(interface{ InvalidUTF8() bool }); ok && re.InvalidUTF8() { + return true + } + return false +} + +type nonFatal struct{ E error } + +// Merge merges err into nf and reports whether it was successful. +// Otherwise it returns false for any fatal non-nil errors. +func (nf *nonFatal) Merge(err error) (ok bool) { + if err == nil { + return true // not an error + } + if !isNonFatal(err) { + return false // fatal error + } + if nf.E == nil { + nf.E = err // store first instance of non-fatal error + } + return true +} + // Message is implemented by generated protocol buffer messages. type Message interface { Reset() @@ -309,16 +370,7 @@ type Buffer struct { buf []byte // encode/decode byte stream index int // read point - // pools of basic types to amortize allocation. - bools []bool - uint32s []uint32 - uint64s []uint64 - - // extra pools, only used with pointer_reflect.go - int32s []int32 - int64s []int64 - float32s []float32 - float64s []float64 + deterministic bool } // NewBuffer allocates a new Buffer and initializes its internal data to @@ -343,6 +395,30 @@ func (p *Buffer) SetBuf(s []byte) { // Bytes returns the contents of the Buffer. func (p *Buffer) Bytes() []byte { return p.buf } +// SetDeterministic sets whether to use deterministic serialization. +// +// Deterministic serialization guarantees that for a given binary, equal +// messages will always be serialized to the same bytes. This implies: +// +// - Repeated serialization of a message will return the same bytes. +// - Different processes of the same binary (which may be executing on +// different machines) will serialize equal messages to the same bytes. +// +// Note that the deterministic serialization is NOT canonical across +// languages. It is not guaranteed to remain stable over time. It is unstable +// across different builds with schema changes due to unknown fields. +// Users who need canonical serialization (e.g., persistent storage in a +// canonical form, fingerprinting, etc.) should define their own +// canonicalization specification and implement their own serializer rather +// than relying on this API. +// +// If deterministic serialization is requested, map entries will be sorted +// by keys in lexographical order. This is an implementation detail and +// subject to change. +func (p *Buffer) SetDeterministic(deterministic bool) { + p.deterministic = deterministic +} + /* * Helper routines for simplifying the creation of optional fields of basic type. */ @@ -831,22 +907,12 @@ func fieldDefault(ft reflect.Type, prop *Properties) (sf *scalarField, nestedMes return sf, false, nil } +// mapKeys returns a sort.Interface to be used for sorting the map keys. // Map fields may have key types of non-float scalars, strings and enums. -// The easiest way to sort them in some deterministic order is to use fmt. -// If this turns out to be inefficient we can always consider other options, -// such as doing a Schwartzian transform. - func mapKeys(vs []reflect.Value) sort.Interface { - s := mapKeySorter{ - vs: vs, - // default Less function: textual comparison - less: func(a, b reflect.Value) bool { - return fmt.Sprint(a.Interface()) < fmt.Sprint(b.Interface()) - }, - } + s := mapKeySorter{vs: vs} - // Type specialization per https://developers.google.com/protocol-buffers/docs/proto#maps; - // numeric keys are sorted numerically. + // Type specialization per https://developers.google.com/protocol-buffers/docs/proto#maps. if len(vs) == 0 { return s } @@ -855,6 +921,12 @@ func mapKeys(vs []reflect.Value) sort.Interface { s.less = func(a, b reflect.Value) bool { return a.Int() < b.Int() } case reflect.Uint32, reflect.Uint64: s.less = func(a, b reflect.Value) bool { return a.Uint() < b.Uint() } + case reflect.Bool: + s.less = func(a, b reflect.Value) bool { return !a.Bool() && b.Bool() } // false < true + case reflect.String: + s.less = func(a, b reflect.Value) bool { return a.String() < b.String() } + default: + panic(fmt.Sprintf("unsupported map key type: %v", vs[0].Kind())) } return s @@ -895,3 +967,13 @@ const ProtoPackageIsVersion2 = true // ProtoPackageIsVersion1 is referenced from generated protocol buffer files // to assert that that code is compatible with this version of the proto package. const ProtoPackageIsVersion1 = true + +// InternalMessageInfo is a type used internally by generated .pb.go files. +// This type is not intended to be used by non-generated code. +// This type is not subject to any compatibility guarantee. +type InternalMessageInfo struct { + marshal *marshalInfo + unmarshal *unmarshalInfo + merge *mergeInfo + discard *discardInfo +} diff --git a/vendor/github.com/golang/protobuf/proto/message_set.go b/vendor/github.com/golang/protobuf/proto/message_set.go index fd982de..3b6ca41 100644 --- a/vendor/github.com/golang/protobuf/proto/message_set.go +++ b/vendor/github.com/golang/protobuf/proto/message_set.go @@ -42,6 +42,7 @@ import ( "fmt" "reflect" "sort" + "sync" ) // errNoMessageTypeID occurs when a protocol buffer does not have a message type ID. @@ -94,10 +95,7 @@ func (ms *messageSet) find(pb Message) *_MessageSet_Item { } func (ms *messageSet) Has(pb Message) bool { - if ms.find(pb) != nil { - return true - } - return false + return ms.find(pb) != nil } func (ms *messageSet) Unmarshal(pb Message) error { @@ -150,46 +148,42 @@ func skipVarint(buf []byte) []byte { // MarshalMessageSet encodes the extension map represented by m in the message set wire format. // It is called by generated Marshal methods on protocol buffer messages with the message_set_wire_format option. func MarshalMessageSet(exts interface{}) ([]byte, error) { - var m map[int32]Extension + return marshalMessageSet(exts, false) +} + +// marshaMessageSet implements above function, with the opt to turn on / off deterministic during Marshal. +func marshalMessageSet(exts interface{}, deterministic bool) ([]byte, error) { switch exts := exts.(type) { case *XXX_InternalExtensions: - if err := encodeExtensions(exts); err != nil { - return nil, err - } - m, _ = exts.extensionsRead() + var u marshalInfo + siz := u.sizeMessageSet(exts) + b := make([]byte, 0, siz) + return u.appendMessageSet(b, exts, deterministic) + case map[int32]Extension: - if err := encodeExtensionsMap(exts); err != nil { - return nil, err + // This is an old-style extension map. + // Wrap it in a new-style XXX_InternalExtensions. + ie := XXX_InternalExtensions{ + p: &struct { + mu sync.Mutex + extensionMap map[int32]Extension + }{ + extensionMap: exts, + }, } - m = exts + + var u marshalInfo + siz := u.sizeMessageSet(&ie) + b := make([]byte, 0, siz) + return u.appendMessageSet(b, &ie, deterministic) + default: return nil, errors.New("proto: not an extension map") } - - // Sort extension IDs to provide a deterministic encoding. - // See also enc_map in encode.go. - ids := make([]int, 0, len(m)) - for id := range m { - ids = append(ids, int(id)) - } - sort.Ints(ids) - - ms := &messageSet{Item: make([]*_MessageSet_Item, 0, len(m))} - for _, id := range ids { - e := m[int32(id)] - // Remove the wire type and field number varint, as well as the length varint. - msg := skipVarint(skipVarint(e.enc)) - - ms.Item = append(ms.Item, &_MessageSet_Item{ - TypeId: Int32(int32(id)), - Message: msg, - }) - } - return Marshal(ms) } // UnmarshalMessageSet decodes the extension map encoded in buf in the message set wire format. -// It is called by generated Unmarshal methods on protocol buffer messages with the message_set_wire_format option. +// It is called by Unmarshal methods on protocol buffer messages with the message_set_wire_format option. func UnmarshalMessageSet(buf []byte, exts interface{}) error { var m map[int32]Extension switch exts := exts.(type) { @@ -235,7 +229,15 @@ func MarshalMessageSetJSON(exts interface{}) ([]byte, error) { var m map[int32]Extension switch exts := exts.(type) { case *XXX_InternalExtensions: - m, _ = exts.extensionsRead() + var mu sync.Locker + m, mu = exts.extensionsRead() + if m != nil { + // Keep the extensions map locked until we're done marshaling to prevent + // races between marshaling and unmarshaling the lazily-{en,de}coded + // values. + mu.Lock() + defer mu.Unlock() + } case map[int32]Extension: m = exts default: @@ -253,15 +255,16 @@ func MarshalMessageSetJSON(exts interface{}) ([]byte, error) { for i, id := range ids { ext := m[id] - if i > 0 { - b.WriteByte(',') - } - msd, ok := messageSetMap[id] if !ok { // Unknown type; we can't render it, so skip it. continue } + + if i > 0 && b.Len() > 1 { + b.WriteByte(',') + } + fmt.Fprintf(&b, `"[%s]":`, msd.name) x := ext.value diff --git a/vendor/github.com/golang/protobuf/proto/pointer_reflect.go b/vendor/github.com/golang/protobuf/proto/pointer_reflect.go index fb512e2..b6cad90 100644 --- a/vendor/github.com/golang/protobuf/proto/pointer_reflect.go +++ b/vendor/github.com/golang/protobuf/proto/pointer_reflect.go @@ -29,7 +29,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +build appengine js +// +build purego appengine js // This file contains an implementation of proto field accesses using package reflect. // It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can @@ -38,32 +38,13 @@ package proto import ( - "math" "reflect" + "sync" ) -// A structPointer is a pointer to a struct. -type structPointer struct { - v reflect.Value -} - -// toStructPointer returns a structPointer equivalent to the given reflect value. -// The reflect value must itself be a pointer to a struct. -func toStructPointer(v reflect.Value) structPointer { - return structPointer{v} -} - -// IsNil reports whether p is nil. -func structPointer_IsNil(p structPointer) bool { - return p.v.IsNil() -} +const unsafeAllowed = false -// Interface returns the struct pointer as an interface value. -func structPointer_Interface(p structPointer, _ reflect.Type) interface{} { - return p.v.Interface() -} - -// A field identifies a field in a struct, accessible from a structPointer. +// A field identifies a field in a struct, accessible from a pointer. // In this implementation, a field is identified by the sequence of field indices // passed to reflect's FieldByIndex. type field []int @@ -76,409 +57,301 @@ func toField(f *reflect.StructField) field { // invalidField is an invalid field identifier. var invalidField = field(nil) +// zeroField is a noop when calling pointer.offset. +var zeroField = field([]int{}) + // IsValid reports whether the field identifier is valid. func (f field) IsValid() bool { return f != nil } -// field returns the given field in the struct as a reflect value. -func structPointer_field(p structPointer, f field) reflect.Value { - // Special case: an extension map entry with a value of type T - // passes a *T to the struct-handling code with a zero field, - // expecting that it will be treated as equivalent to *struct{ X T }, - // which has the same memory layout. We have to handle that case - // specially, because reflect will panic if we call FieldByIndex on a - // non-struct. - if f == nil { - return p.v.Elem() - } - - return p.v.Elem().FieldByIndex(f) +// The pointer type is for the table-driven decoder. +// The implementation here uses a reflect.Value of pointer type to +// create a generic pointer. In pointer_unsafe.go we use unsafe +// instead of reflect to implement the same (but faster) interface. +type pointer struct { + v reflect.Value } -// ifield returns the given field in the struct as an interface value. -func structPointer_ifield(p structPointer, f field) interface{} { - return structPointer_field(p, f).Addr().Interface() +// toPointer converts an interface of pointer type to a pointer +// that points to the same target. +func toPointer(i *Message) pointer { + return pointer{v: reflect.ValueOf(*i)} } -// Bytes returns the address of a []byte field in the struct. -func structPointer_Bytes(p structPointer, f field) *[]byte { - return structPointer_ifield(p, f).(*[]byte) +// toAddrPointer converts an interface to a pointer that points to +// the interface data. +func toAddrPointer(i *interface{}, isptr bool) pointer { + v := reflect.ValueOf(*i) + u := reflect.New(v.Type()) + u.Elem().Set(v) + return pointer{v: u} } -// BytesSlice returns the address of a [][]byte field in the struct. -func structPointer_BytesSlice(p structPointer, f field) *[][]byte { - return structPointer_ifield(p, f).(*[][]byte) +// valToPointer converts v to a pointer. v must be of pointer type. +func valToPointer(v reflect.Value) pointer { + return pointer{v: v} } -// Bool returns the address of a *bool field in the struct. -func structPointer_Bool(p structPointer, f field) **bool { - return structPointer_ifield(p, f).(**bool) +// offset converts from a pointer to a structure to a pointer to +// one of its fields. +func (p pointer) offset(f field) pointer { + return pointer{v: p.v.Elem().FieldByIndex(f).Addr()} } -// BoolVal returns the address of a bool field in the struct. -func structPointer_BoolVal(p structPointer, f field) *bool { - return structPointer_ifield(p, f).(*bool) +func (p pointer) isNil() bool { + return p.v.IsNil() } -// BoolSlice returns the address of a []bool field in the struct. -func structPointer_BoolSlice(p structPointer, f field) *[]bool { - return structPointer_ifield(p, f).(*[]bool) +// grow updates the slice s in place to make it one element longer. +// s must be addressable. +// Returns the (addressable) new element. +func grow(s reflect.Value) reflect.Value { + n, m := s.Len(), s.Cap() + if n < m { + s.SetLen(n + 1) + } else { + s.Set(reflect.Append(s, reflect.Zero(s.Type().Elem()))) + } + return s.Index(n) } -// String returns the address of a *string field in the struct. -func structPointer_String(p structPointer, f field) **string { - return structPointer_ifield(p, f).(**string) +func (p pointer) toInt64() *int64 { + return p.v.Interface().(*int64) } - -// StringVal returns the address of a string field in the struct. -func structPointer_StringVal(p structPointer, f field) *string { - return structPointer_ifield(p, f).(*string) +func (p pointer) toInt64Ptr() **int64 { + return p.v.Interface().(**int64) } - -// StringSlice returns the address of a []string field in the struct. -func structPointer_StringSlice(p structPointer, f field) *[]string { - return structPointer_ifield(p, f).(*[]string) +func (p pointer) toInt64Slice() *[]int64 { + return p.v.Interface().(*[]int64) } -// Extensions returns the address of an extension map field in the struct. -func structPointer_Extensions(p structPointer, f field) *XXX_InternalExtensions { - return structPointer_ifield(p, f).(*XXX_InternalExtensions) -} +var int32ptr = reflect.TypeOf((*int32)(nil)) -// ExtMap returns the address of an extension map field in the struct. -func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension { - return structPointer_ifield(p, f).(*map[int32]Extension) +func (p pointer) toInt32() *int32 { + return p.v.Convert(int32ptr).Interface().(*int32) } -// NewAt returns the reflect.Value for a pointer to a field in the struct. -func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value { - return structPointer_field(p, f).Addr() +// The toInt32Ptr/Slice methods don't work because of enums. +// Instead, we must use set/get methods for the int32ptr/slice case. +/* + func (p pointer) toInt32Ptr() **int32 { + return p.v.Interface().(**int32) } - -// SetStructPointer writes a *struct field in the struct. -func structPointer_SetStructPointer(p structPointer, f field, q structPointer) { - structPointer_field(p, f).Set(q.v) + func (p pointer) toInt32Slice() *[]int32 { + return p.v.Interface().(*[]int32) } - -// GetStructPointer reads a *struct field in the struct. -func structPointer_GetStructPointer(p structPointer, f field) structPointer { - return structPointer{structPointer_field(p, f)} +*/ +func (p pointer) getInt32Ptr() *int32 { + if p.v.Type().Elem().Elem() == reflect.TypeOf(int32(0)) { + // raw int32 type + return p.v.Elem().Interface().(*int32) + } + // an enum + return p.v.Elem().Convert(int32PtrType).Interface().(*int32) +} +func (p pointer) setInt32Ptr(v int32) { + // Allocate value in a *int32. Possibly convert that to a *enum. + // Then assign it to a **int32 or **enum. + // Note: we can convert *int32 to *enum, but we can't convert + // **int32 to **enum! + p.v.Elem().Set(reflect.ValueOf(&v).Convert(p.v.Type().Elem())) +} + +// getInt32Slice copies []int32 from p as a new slice. +// This behavior differs from the implementation in pointer_unsafe.go. +func (p pointer) getInt32Slice() []int32 { + if p.v.Type().Elem().Elem() == reflect.TypeOf(int32(0)) { + // raw int32 type + return p.v.Elem().Interface().([]int32) + } + // an enum + // Allocate a []int32, then assign []enum's values into it. + // Note: we can't convert []enum to []int32. + slice := p.v.Elem() + s := make([]int32, slice.Len()) + for i := 0; i < slice.Len(); i++ { + s[i] = int32(slice.Index(i).Int()) + } + return s } -// StructPointerSlice the address of a []*struct field in the struct. -func structPointer_StructPointerSlice(p structPointer, f field) structPointerSlice { - return structPointerSlice{structPointer_field(p, f)} +// setInt32Slice copies []int32 into p as a new slice. +// This behavior differs from the implementation in pointer_unsafe.go. +func (p pointer) setInt32Slice(v []int32) { + if p.v.Type().Elem().Elem() == reflect.TypeOf(int32(0)) { + // raw int32 type + p.v.Elem().Set(reflect.ValueOf(v)) + return + } + // an enum + // Allocate a []enum, then assign []int32's values into it. + // Note: we can't convert []enum to []int32. + slice := reflect.MakeSlice(p.v.Type().Elem(), len(v), cap(v)) + for i, x := range v { + slice.Index(i).SetInt(int64(x)) + } + p.v.Elem().Set(slice) } - -// A structPointerSlice represents the address of a slice of pointers to structs -// (themselves messages or groups). That is, v.Type() is *[]*struct{...}. -type structPointerSlice struct { - v reflect.Value +func (p pointer) appendInt32Slice(v int32) { + grow(p.v.Elem()).SetInt(int64(v)) } -func (p structPointerSlice) Len() int { return p.v.Len() } -func (p structPointerSlice) Index(i int) structPointer { return structPointer{p.v.Index(i)} } -func (p structPointerSlice) Append(q structPointer) { - p.v.Set(reflect.Append(p.v, q.v)) +func (p pointer) toUint64() *uint64 { + return p.v.Interface().(*uint64) } - -var ( - int32Type = reflect.TypeOf(int32(0)) - uint32Type = reflect.TypeOf(uint32(0)) - float32Type = reflect.TypeOf(float32(0)) - int64Type = reflect.TypeOf(int64(0)) - uint64Type = reflect.TypeOf(uint64(0)) - float64Type = reflect.TypeOf(float64(0)) -) - -// A word32 represents a field of type *int32, *uint32, *float32, or *enum. -// That is, v.Type() is *int32, *uint32, *float32, or *enum and v is assignable. -type word32 struct { - v reflect.Value +func (p pointer) toUint64Ptr() **uint64 { + return p.v.Interface().(**uint64) } - -// IsNil reports whether p is nil. -func word32_IsNil(p word32) bool { - return p.v.IsNil() +func (p pointer) toUint64Slice() *[]uint64 { + return p.v.Interface().(*[]uint64) } - -// Set sets p to point at a newly allocated word with bits set to x. -func word32_Set(p word32, o *Buffer, x uint32) { - t := p.v.Type().Elem() - switch t { - case int32Type: - if len(o.int32s) == 0 { - o.int32s = make([]int32, uint32PoolSize) - } - o.int32s[0] = int32(x) - p.v.Set(reflect.ValueOf(&o.int32s[0])) - o.int32s = o.int32s[1:] - return - case uint32Type: - if len(o.uint32s) == 0 { - o.uint32s = make([]uint32, uint32PoolSize) - } - o.uint32s[0] = x - p.v.Set(reflect.ValueOf(&o.uint32s[0])) - o.uint32s = o.uint32s[1:] - return - case float32Type: - if len(o.float32s) == 0 { - o.float32s = make([]float32, uint32PoolSize) - } - o.float32s[0] = math.Float32frombits(x) - p.v.Set(reflect.ValueOf(&o.float32s[0])) - o.float32s = o.float32s[1:] - return - } - - // must be enum - p.v.Set(reflect.New(t)) - p.v.Elem().SetInt(int64(int32(x))) +func (p pointer) toUint32() *uint32 { + return p.v.Interface().(*uint32) } - -// Get gets the bits pointed at by p, as a uint32. -func word32_Get(p word32) uint32 { - elem := p.v.Elem() - switch elem.Kind() { - case reflect.Int32: - return uint32(elem.Int()) - case reflect.Uint32: - return uint32(elem.Uint()) - case reflect.Float32: - return math.Float32bits(float32(elem.Float())) - } - panic("unreachable") +func (p pointer) toUint32Ptr() **uint32 { + return p.v.Interface().(**uint32) } - -// Word32 returns a reference to a *int32, *uint32, *float32, or *enum field in the struct. -func structPointer_Word32(p structPointer, f field) word32 { - return word32{structPointer_field(p, f)} +func (p pointer) toUint32Slice() *[]uint32 { + return p.v.Interface().(*[]uint32) } - -// A word32Val represents a field of type int32, uint32, float32, or enum. -// That is, v.Type() is int32, uint32, float32, or enum and v is assignable. -type word32Val struct { - v reflect.Value +func (p pointer) toBool() *bool { + return p.v.Interface().(*bool) } - -// Set sets *p to x. -func word32Val_Set(p word32Val, x uint32) { - switch p.v.Type() { - case int32Type: - p.v.SetInt(int64(x)) - return - case uint32Type: - p.v.SetUint(uint64(x)) - return - case float32Type: - p.v.SetFloat(float64(math.Float32frombits(x))) - return - } - - // must be enum - p.v.SetInt(int64(int32(x))) +func (p pointer) toBoolPtr() **bool { + return p.v.Interface().(**bool) } - -// Get gets the bits pointed at by p, as a uint32. -func word32Val_Get(p word32Val) uint32 { - elem := p.v - switch elem.Kind() { - case reflect.Int32: - return uint32(elem.Int()) - case reflect.Uint32: - return uint32(elem.Uint()) - case reflect.Float32: - return math.Float32bits(float32(elem.Float())) - } - panic("unreachable") +func (p pointer) toBoolSlice() *[]bool { + return p.v.Interface().(*[]bool) } - -// Word32Val returns a reference to a int32, uint32, float32, or enum field in the struct. -func structPointer_Word32Val(p structPointer, f field) word32Val { - return word32Val{structPointer_field(p, f)} +func (p pointer) toFloat64() *float64 { + return p.v.Interface().(*float64) } - -// A word32Slice is a slice of 32-bit values. -// That is, v.Type() is []int32, []uint32, []float32, or []enum. -type word32Slice struct { - v reflect.Value +func (p pointer) toFloat64Ptr() **float64 { + return p.v.Interface().(**float64) } - -func (p word32Slice) Append(x uint32) { - n, m := p.v.Len(), p.v.Cap() - if n < m { - p.v.SetLen(n + 1) - } else { - t := p.v.Type().Elem() - p.v.Set(reflect.Append(p.v, reflect.Zero(t))) - } - elem := p.v.Index(n) - switch elem.Kind() { - case reflect.Int32: - elem.SetInt(int64(int32(x))) - case reflect.Uint32: - elem.SetUint(uint64(x)) - case reflect.Float32: - elem.SetFloat(float64(math.Float32frombits(x))) - } +func (p pointer) toFloat64Slice() *[]float64 { + return p.v.Interface().(*[]float64) } - -func (p word32Slice) Len() int { - return p.v.Len() +func (p pointer) toFloat32() *float32 { + return p.v.Interface().(*float32) } - -func (p word32Slice) Index(i int) uint32 { - elem := p.v.Index(i) - switch elem.Kind() { - case reflect.Int32: - return uint32(elem.Int()) - case reflect.Uint32: - return uint32(elem.Uint()) - case reflect.Float32: - return math.Float32bits(float32(elem.Float())) - } - panic("unreachable") +func (p pointer) toFloat32Ptr() **float32 { + return p.v.Interface().(**float32) } - -// Word32Slice returns a reference to a []int32, []uint32, []float32, or []enum field in the struct. -func structPointer_Word32Slice(p structPointer, f field) word32Slice { - return word32Slice{structPointer_field(p, f)} +func (p pointer) toFloat32Slice() *[]float32 { + return p.v.Interface().(*[]float32) } - -// word64 is like word32 but for 64-bit values. -type word64 struct { - v reflect.Value +func (p pointer) toString() *string { + return p.v.Interface().(*string) } - -func word64_Set(p word64, o *Buffer, x uint64) { - t := p.v.Type().Elem() - switch t { - case int64Type: - if len(o.int64s) == 0 { - o.int64s = make([]int64, uint64PoolSize) - } - o.int64s[0] = int64(x) - p.v.Set(reflect.ValueOf(&o.int64s[0])) - o.int64s = o.int64s[1:] - return - case uint64Type: - if len(o.uint64s) == 0 { - o.uint64s = make([]uint64, uint64PoolSize) - } - o.uint64s[0] = x - p.v.Set(reflect.ValueOf(&o.uint64s[0])) - o.uint64s = o.uint64s[1:] - return - case float64Type: - if len(o.float64s) == 0 { - o.float64s = make([]float64, uint64PoolSize) - } - o.float64s[0] = math.Float64frombits(x) - p.v.Set(reflect.ValueOf(&o.float64s[0])) - o.float64s = o.float64s[1:] - return - } - panic("unreachable") +func (p pointer) toStringPtr() **string { + return p.v.Interface().(**string) } - -func word64_IsNil(p word64) bool { - return p.v.IsNil() +func (p pointer) toStringSlice() *[]string { + return p.v.Interface().(*[]string) } - -func word64_Get(p word64) uint64 { - elem := p.v.Elem() - switch elem.Kind() { - case reflect.Int64: - return uint64(elem.Int()) - case reflect.Uint64: - return elem.Uint() - case reflect.Float64: - return math.Float64bits(elem.Float()) - } - panic("unreachable") +func (p pointer) toBytes() *[]byte { + return p.v.Interface().(*[]byte) } - -func structPointer_Word64(p structPointer, f field) word64 { - return word64{structPointer_field(p, f)} +func (p pointer) toBytesSlice() *[][]byte { + return p.v.Interface().(*[][]byte) +} +func (p pointer) toExtensions() *XXX_InternalExtensions { + return p.v.Interface().(*XXX_InternalExtensions) +} +func (p pointer) toOldExtensions() *map[int32]Extension { + return p.v.Interface().(*map[int32]Extension) +} +func (p pointer) getPointer() pointer { + return pointer{v: p.v.Elem()} +} +func (p pointer) setPointer(q pointer) { + p.v.Elem().Set(q.v) +} +func (p pointer) appendPointer(q pointer) { + grow(p.v.Elem()).Set(q.v) } -// word64Val is like word32Val but for 64-bit values. -type word64Val struct { - v reflect.Value +// getPointerSlice copies []*T from p as a new []pointer. +// This behavior differs from the implementation in pointer_unsafe.go. +func (p pointer) getPointerSlice() []pointer { + if p.v.IsNil() { + return nil + } + n := p.v.Elem().Len() + s := make([]pointer, n) + for i := 0; i < n; i++ { + s[i] = pointer{v: p.v.Elem().Index(i)} + } + return s } -func word64Val_Set(p word64Val, o *Buffer, x uint64) { - switch p.v.Type() { - case int64Type: - p.v.SetInt(int64(x)) - return - case uint64Type: - p.v.SetUint(x) - return - case float64Type: - p.v.SetFloat(math.Float64frombits(x)) +// setPointerSlice copies []pointer into p as a new []*T. +// This behavior differs from the implementation in pointer_unsafe.go. +func (p pointer) setPointerSlice(v []pointer) { + if v == nil { + p.v.Elem().Set(reflect.New(p.v.Elem().Type()).Elem()) return } - panic("unreachable") + s := reflect.MakeSlice(p.v.Elem().Type(), 0, len(v)) + for _, p := range v { + s = reflect.Append(s, p.v) + } + p.v.Elem().Set(s) } -func word64Val_Get(p word64Val) uint64 { - elem := p.v - switch elem.Kind() { - case reflect.Int64: - return uint64(elem.Int()) - case reflect.Uint64: - return elem.Uint() - case reflect.Float64: - return math.Float64bits(elem.Float()) +// getInterfacePointer returns a pointer that points to the +// interface data of the interface pointed by p. +func (p pointer) getInterfacePointer() pointer { + if p.v.Elem().IsNil() { + return pointer{v: p.v.Elem()} } - panic("unreachable") + return pointer{v: p.v.Elem().Elem().Elem().Field(0).Addr()} // *interface -> interface -> *struct -> struct } -func structPointer_Word64Val(p structPointer, f field) word64Val { - return word64Val{structPointer_field(p, f)} +func (p pointer) asPointerTo(t reflect.Type) reflect.Value { + // TODO: check that p.v.Type().Elem() == t? + return p.v } -type word64Slice struct { - v reflect.Value +func atomicLoadUnmarshalInfo(p **unmarshalInfo) *unmarshalInfo { + atomicLock.Lock() + defer atomicLock.Unlock() + return *p } - -func (p word64Slice) Append(x uint64) { - n, m := p.v.Len(), p.v.Cap() - if n < m { - p.v.SetLen(n + 1) - } else { - t := p.v.Type().Elem() - p.v.Set(reflect.Append(p.v, reflect.Zero(t))) - } - elem := p.v.Index(n) - switch elem.Kind() { - case reflect.Int64: - elem.SetInt(int64(int64(x))) - case reflect.Uint64: - elem.SetUint(uint64(x)) - case reflect.Float64: - elem.SetFloat(float64(math.Float64frombits(x))) - } +func atomicStoreUnmarshalInfo(p **unmarshalInfo, v *unmarshalInfo) { + atomicLock.Lock() + defer atomicLock.Unlock() + *p = v } - -func (p word64Slice) Len() int { - return p.v.Len() +func atomicLoadMarshalInfo(p **marshalInfo) *marshalInfo { + atomicLock.Lock() + defer atomicLock.Unlock() + return *p } - -func (p word64Slice) Index(i int) uint64 { - elem := p.v.Index(i) - switch elem.Kind() { - case reflect.Int64: - return uint64(elem.Int()) - case reflect.Uint64: - return uint64(elem.Uint()) - case reflect.Float64: - return math.Float64bits(float64(elem.Float())) - } - panic("unreachable") +func atomicStoreMarshalInfo(p **marshalInfo, v *marshalInfo) { + atomicLock.Lock() + defer atomicLock.Unlock() + *p = v } - -func structPointer_Word64Slice(p structPointer, f field) word64Slice { - return word64Slice{structPointer_field(p, f)} +func atomicLoadMergeInfo(p **mergeInfo) *mergeInfo { + atomicLock.Lock() + defer atomicLock.Unlock() + return *p +} +func atomicStoreMergeInfo(p **mergeInfo, v *mergeInfo) { + atomicLock.Lock() + defer atomicLock.Unlock() + *p = v } +func atomicLoadDiscardInfo(p **discardInfo) *discardInfo { + atomicLock.Lock() + defer atomicLock.Unlock() + return *p +} +func atomicStoreDiscardInfo(p **discardInfo, v *discardInfo) { + atomicLock.Lock() + defer atomicLock.Unlock() + *p = v +} + +var atomicLock sync.Mutex diff --git a/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go b/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go index 6b5567d..d55a335 100644 --- a/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go +++ b/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go @@ -29,7 +29,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +build !appengine,!js +// +build !purego,!appengine,!js // This file contains the implementation of the proto field accesses using package unsafe. @@ -37,38 +37,13 @@ package proto import ( "reflect" + "sync/atomic" "unsafe" ) -// NOTE: These type_Foo functions would more idiomatically be methods, -// but Go does not allow methods on pointer types, and we must preserve -// some pointer type for the garbage collector. We use these -// funcs with clunky names as our poor approximation to methods. -// -// An alternative would be -// type structPointer struct { p unsafe.Pointer } -// but that does not registerize as well. - -// A structPointer is a pointer to a struct. -type structPointer unsafe.Pointer - -// toStructPointer returns a structPointer equivalent to the given reflect value. -func toStructPointer(v reflect.Value) structPointer { - return structPointer(unsafe.Pointer(v.Pointer())) -} - -// IsNil reports whether p is nil. -func structPointer_IsNil(p structPointer) bool { - return p == nil -} - -// Interface returns the struct pointer, assumed to have element type t, -// as an interface value. -func structPointer_Interface(p structPointer, t reflect.Type) interface{} { - return reflect.NewAt(t, unsafe.Pointer(p)).Interface() -} +const unsafeAllowed = true -// A field identifies a field in a struct, accessible from a structPointer. +// A field identifies a field in a struct, accessible from a pointer. // In this implementation, a field is identified by its byte offset from the start of the struct. type field uintptr @@ -80,191 +55,254 @@ func toField(f *reflect.StructField) field { // invalidField is an invalid field identifier. const invalidField = ^field(0) +// zeroField is a noop when calling pointer.offset. +const zeroField = field(0) + // IsValid reports whether the field identifier is valid. func (f field) IsValid() bool { - return f != ^field(0) + return f != invalidField } -// Bytes returns the address of a []byte field in the struct. -func structPointer_Bytes(p structPointer, f field) *[]byte { - return (*[]byte)(unsafe.Pointer(uintptr(p) + uintptr(f))) +// The pointer type below is for the new table-driven encoder/decoder. +// The implementation here uses unsafe.Pointer to create a generic pointer. +// In pointer_reflect.go we use reflect instead of unsafe to implement +// the same (but slower) interface. +type pointer struct { + p unsafe.Pointer } -// BytesSlice returns the address of a [][]byte field in the struct. -func structPointer_BytesSlice(p structPointer, f field) *[][]byte { - return (*[][]byte)(unsafe.Pointer(uintptr(p) + uintptr(f))) -} +// size of pointer +var ptrSize = unsafe.Sizeof(uintptr(0)) -// Bool returns the address of a *bool field in the struct. -func structPointer_Bool(p structPointer, f field) **bool { - return (**bool)(unsafe.Pointer(uintptr(p) + uintptr(f))) +// toPointer converts an interface of pointer type to a pointer +// that points to the same target. +func toPointer(i *Message) pointer { + // Super-tricky - read pointer out of data word of interface value. + // Saves ~25ns over the equivalent: + // return valToPointer(reflect.ValueOf(*i)) + return pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]} } -// BoolVal returns the address of a bool field in the struct. -func structPointer_BoolVal(p structPointer, f field) *bool { - return (*bool)(unsafe.Pointer(uintptr(p) + uintptr(f))) +// toAddrPointer converts an interface to a pointer that points to +// the interface data. +func toAddrPointer(i *interface{}, isptr bool) pointer { + // Super-tricky - read or get the address of data word of interface value. + if isptr { + // The interface is of pointer type, thus it is a direct interface. + // The data word is the pointer data itself. We take its address. + return pointer{p: unsafe.Pointer(uintptr(unsafe.Pointer(i)) + ptrSize)} + } + // The interface is not of pointer type. The data word is the pointer + // to the data. + return pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]} } -// BoolSlice returns the address of a []bool field in the struct. -func structPointer_BoolSlice(p structPointer, f field) *[]bool { - return (*[]bool)(unsafe.Pointer(uintptr(p) + uintptr(f))) +// valToPointer converts v to a pointer. v must be of pointer type. +func valToPointer(v reflect.Value) pointer { + return pointer{p: unsafe.Pointer(v.Pointer())} } -// String returns the address of a *string field in the struct. -func structPointer_String(p structPointer, f field) **string { - return (**string)(unsafe.Pointer(uintptr(p) + uintptr(f))) +// offset converts from a pointer to a structure to a pointer to +// one of its fields. +func (p pointer) offset(f field) pointer { + // For safety, we should panic if !f.IsValid, however calling panic causes + // this to no longer be inlineable, which is a serious performance cost. + /* + if !f.IsValid() { + panic("invalid field") + } + */ + return pointer{p: unsafe.Pointer(uintptr(p.p) + uintptr(f))} } -// StringVal returns the address of a string field in the struct. -func structPointer_StringVal(p structPointer, f field) *string { - return (*string)(unsafe.Pointer(uintptr(p) + uintptr(f))) +func (p pointer) isNil() bool { + return p.p == nil } -// StringSlice returns the address of a []string field in the struct. -func structPointer_StringSlice(p structPointer, f field) *[]string { - return (*[]string)(unsafe.Pointer(uintptr(p) + uintptr(f))) +func (p pointer) toInt64() *int64 { + return (*int64)(p.p) } - -// ExtMap returns the address of an extension map field in the struct. -func structPointer_Extensions(p structPointer, f field) *XXX_InternalExtensions { - return (*XXX_InternalExtensions)(unsafe.Pointer(uintptr(p) + uintptr(f))) +func (p pointer) toInt64Ptr() **int64 { + return (**int64)(p.p) } - -func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension { - return (*map[int32]Extension)(unsafe.Pointer(uintptr(p) + uintptr(f))) +func (p pointer) toInt64Slice() *[]int64 { + return (*[]int64)(p.p) } - -// NewAt returns the reflect.Value for a pointer to a field in the struct. -func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value { - return reflect.NewAt(typ, unsafe.Pointer(uintptr(p)+uintptr(f))) +func (p pointer) toInt32() *int32 { + return (*int32)(p.p) } -// SetStructPointer writes a *struct field in the struct. -func structPointer_SetStructPointer(p structPointer, f field, q structPointer) { - *(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f))) = q +// See pointer_reflect.go for why toInt32Ptr/Slice doesn't exist. +/* + func (p pointer) toInt32Ptr() **int32 { + return (**int32)(p.p) + } + func (p pointer) toInt32Slice() *[]int32 { + return (*[]int32)(p.p) + } +*/ +func (p pointer) getInt32Ptr() *int32 { + return *(**int32)(p.p) } - -// GetStructPointer reads a *struct field in the struct. -func structPointer_GetStructPointer(p structPointer, f field) structPointer { - return *(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f))) +func (p pointer) setInt32Ptr(v int32) { + *(**int32)(p.p) = &v } -// StructPointerSlice the address of a []*struct field in the struct. -func structPointer_StructPointerSlice(p structPointer, f field) *structPointerSlice { - return (*structPointerSlice)(unsafe.Pointer(uintptr(p) + uintptr(f))) +// getInt32Slice loads a []int32 from p. +// The value returned is aliased with the original slice. +// This behavior differs from the implementation in pointer_reflect.go. +func (p pointer) getInt32Slice() []int32 { + return *(*[]int32)(p.p) } -// A structPointerSlice represents a slice of pointers to structs (themselves submessages or groups). -type structPointerSlice []structPointer - -func (v *structPointerSlice) Len() int { return len(*v) } -func (v *structPointerSlice) Index(i int) structPointer { return (*v)[i] } -func (v *structPointerSlice) Append(p structPointer) { *v = append(*v, p) } - -// A word32 is the address of a "pointer to 32-bit value" field. -type word32 **uint32 - -// IsNil reports whether *v is nil. -func word32_IsNil(p word32) bool { - return *p == nil +// setInt32Slice stores a []int32 to p. +// The value set is aliased with the input slice. +// This behavior differs from the implementation in pointer_reflect.go. +func (p pointer) setInt32Slice(v []int32) { + *(*[]int32)(p.p) = v } -// Set sets *v to point at a newly allocated word set to x. -func word32_Set(p word32, o *Buffer, x uint32) { - if len(o.uint32s) == 0 { - o.uint32s = make([]uint32, uint32PoolSize) - } - o.uint32s[0] = x - *p = &o.uint32s[0] - o.uint32s = o.uint32s[1:] +// TODO: Can we get rid of appendInt32Slice and use setInt32Slice instead? +func (p pointer) appendInt32Slice(v int32) { + s := (*[]int32)(p.p) + *s = append(*s, v) } -// Get gets the value pointed at by *v. -func word32_Get(p word32) uint32 { - return **p +func (p pointer) toUint64() *uint64 { + return (*uint64)(p.p) } - -// Word32 returns the address of a *int32, *uint32, *float32, or *enum field in the struct. -func structPointer_Word32(p structPointer, f field) word32 { - return word32((**uint32)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +func (p pointer) toUint64Ptr() **uint64 { + return (**uint64)(p.p) } - -// A word32Val is the address of a 32-bit value field. -type word32Val *uint32 - -// Set sets *p to x. -func word32Val_Set(p word32Val, x uint32) { - *p = x +func (p pointer) toUint64Slice() *[]uint64 { + return (*[]uint64)(p.p) } - -// Get gets the value pointed at by p. -func word32Val_Get(p word32Val) uint32 { - return *p +func (p pointer) toUint32() *uint32 { + return (*uint32)(p.p) } - -// Word32Val returns the address of a *int32, *uint32, *float32, or *enum field in the struct. -func structPointer_Word32Val(p structPointer, f field) word32Val { - return word32Val((*uint32)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +func (p pointer) toUint32Ptr() **uint32 { + return (**uint32)(p.p) } - -// A word32Slice is a slice of 32-bit values. -type word32Slice []uint32 - -func (v *word32Slice) Append(x uint32) { *v = append(*v, x) } -func (v *word32Slice) Len() int { return len(*v) } -func (v *word32Slice) Index(i int) uint32 { return (*v)[i] } - -// Word32Slice returns the address of a []int32, []uint32, []float32, or []enum field in the struct. -func structPointer_Word32Slice(p structPointer, f field) *word32Slice { - return (*word32Slice)(unsafe.Pointer(uintptr(p) + uintptr(f))) +func (p pointer) toUint32Slice() *[]uint32 { + return (*[]uint32)(p.p) } - -// word64 is like word32 but for 64-bit values. -type word64 **uint64 - -func word64_Set(p word64, o *Buffer, x uint64) { - if len(o.uint64s) == 0 { - o.uint64s = make([]uint64, uint64PoolSize) - } - o.uint64s[0] = x - *p = &o.uint64s[0] - o.uint64s = o.uint64s[1:] +func (p pointer) toBool() *bool { + return (*bool)(p.p) } - -func word64_IsNil(p word64) bool { - return *p == nil +func (p pointer) toBoolPtr() **bool { + return (**bool)(p.p) } - -func word64_Get(p word64) uint64 { - return **p +func (p pointer) toBoolSlice() *[]bool { + return (*[]bool)(p.p) +} +func (p pointer) toFloat64() *float64 { + return (*float64)(p.p) +} +func (p pointer) toFloat64Ptr() **float64 { + return (**float64)(p.p) +} +func (p pointer) toFloat64Slice() *[]float64 { + return (*[]float64)(p.p) +} +func (p pointer) toFloat32() *float32 { + return (*float32)(p.p) +} +func (p pointer) toFloat32Ptr() **float32 { + return (**float32)(p.p) +} +func (p pointer) toFloat32Slice() *[]float32 { + return (*[]float32)(p.p) +} +func (p pointer) toString() *string { + return (*string)(p.p) +} +func (p pointer) toStringPtr() **string { + return (**string)(p.p) +} +func (p pointer) toStringSlice() *[]string { + return (*[]string)(p.p) +} +func (p pointer) toBytes() *[]byte { + return (*[]byte)(p.p) +} +func (p pointer) toBytesSlice() *[][]byte { + return (*[][]byte)(p.p) +} +func (p pointer) toExtensions() *XXX_InternalExtensions { + return (*XXX_InternalExtensions)(p.p) +} +func (p pointer) toOldExtensions() *map[int32]Extension { + return (*map[int32]Extension)(p.p) } -func structPointer_Word64(p structPointer, f field) word64 { - return word64((**uint64)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +// getPointerSlice loads []*T from p as a []pointer. +// The value returned is aliased with the original slice. +// This behavior differs from the implementation in pointer_reflect.go. +func (p pointer) getPointerSlice() []pointer { + // Super-tricky - p should point to a []*T where T is a + // message type. We load it as []pointer. + return *(*[]pointer)(p.p) } -// word64Val is like word32Val but for 64-bit values. -type word64Val *uint64 +// setPointerSlice stores []pointer into p as a []*T. +// The value set is aliased with the input slice. +// This behavior differs from the implementation in pointer_reflect.go. +func (p pointer) setPointerSlice(v []pointer) { + // Super-tricky - p should point to a []*T where T is a + // message type. We store it as []pointer. + *(*[]pointer)(p.p) = v +} -func word64Val_Set(p word64Val, o *Buffer, x uint64) { - *p = x +// getPointer loads the pointer at p and returns it. +func (p pointer) getPointer() pointer { + return pointer{p: *(*unsafe.Pointer)(p.p)} } -func word64Val_Get(p word64Val) uint64 { - return *p +// setPointer stores the pointer q at p. +func (p pointer) setPointer(q pointer) { + *(*unsafe.Pointer)(p.p) = q.p } -func structPointer_Word64Val(p structPointer, f field) word64Val { - return word64Val((*uint64)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +// append q to the slice pointed to by p. +func (p pointer) appendPointer(q pointer) { + s := (*[]unsafe.Pointer)(p.p) + *s = append(*s, q.p) } -// word64Slice is like word32Slice but for 64-bit values. -type word64Slice []uint64 +// getInterfacePointer returns a pointer that points to the +// interface data of the interface pointed by p. +func (p pointer) getInterfacePointer() pointer { + // Super-tricky - read pointer out of data word of interface value. + return pointer{p: (*(*[2]unsafe.Pointer)(p.p))[1]} +} -func (v *word64Slice) Append(x uint64) { *v = append(*v, x) } -func (v *word64Slice) Len() int { return len(*v) } -func (v *word64Slice) Index(i int) uint64 { return (*v)[i] } +// asPointerTo returns a reflect.Value that is a pointer to an +// object of type t stored at p. +func (p pointer) asPointerTo(t reflect.Type) reflect.Value { + return reflect.NewAt(t, p.p) +} -func structPointer_Word64Slice(p structPointer, f field) *word64Slice { - return (*word64Slice)(unsafe.Pointer(uintptr(p) + uintptr(f))) +func atomicLoadUnmarshalInfo(p **unmarshalInfo) *unmarshalInfo { + return (*unmarshalInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p)))) +} +func atomicStoreUnmarshalInfo(p **unmarshalInfo, v *unmarshalInfo) { + atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v)) +} +func atomicLoadMarshalInfo(p **marshalInfo) *marshalInfo { + return (*marshalInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p)))) +} +func atomicStoreMarshalInfo(p **marshalInfo, v *marshalInfo) { + atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v)) +} +func atomicLoadMergeInfo(p **mergeInfo) *mergeInfo { + return (*mergeInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p)))) +} +func atomicStoreMergeInfo(p **mergeInfo, v *mergeInfo) { + atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v)) +} +func atomicLoadDiscardInfo(p **discardInfo) *discardInfo { + return (*discardInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p)))) +} +func atomicStoreDiscardInfo(p **discardInfo, v *discardInfo) { + atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v)) } diff --git a/vendor/github.com/golang/protobuf/proto/properties.go b/vendor/github.com/golang/protobuf/proto/properties.go index ec2289c..50b99b8 100644 --- a/vendor/github.com/golang/protobuf/proto/properties.go +++ b/vendor/github.com/golang/protobuf/proto/properties.go @@ -58,42 +58,6 @@ const ( WireFixed32 = 5 ) -const startSize = 10 // initial slice/string sizes - -// Encoders are defined in encode.go -// An encoder outputs the full representation of a field, including its -// tag and encoder type. -type encoder func(p *Buffer, prop *Properties, base structPointer) error - -// A valueEncoder encodes a single integer in a particular encoding. -type valueEncoder func(o *Buffer, x uint64) error - -// Sizers are defined in encode.go -// A sizer returns the encoded size of a field, including its tag and encoder -// type. -type sizer func(prop *Properties, base structPointer) int - -// A valueSizer returns the encoded size of a single integer in a particular -// encoding. -type valueSizer func(x uint64) int - -// Decoders are defined in decode.go -// A decoder creates a value from its wire representation. -// Unrecognized subelements are saved in unrec. -type decoder func(p *Buffer, prop *Properties, base structPointer) error - -// A valueDecoder decodes a single integer in a particular encoding. -type valueDecoder func(o *Buffer) (x uint64, err error) - -// A oneofMarshaler does the marshaling for all oneof fields in a message. -type oneofMarshaler func(Message, *Buffer) error - -// A oneofUnmarshaler does the unmarshaling for a oneof field in a message. -type oneofUnmarshaler func(Message, int, int, *Buffer) (bool, error) - -// A oneofSizer does the sizing for all oneof fields in a message. -type oneofSizer func(Message) int - // tagMap is an optimization over map[int]int for typical protocol buffer // use-cases. Encoded protocol buffers are often in tag order with small tag // numbers. @@ -140,13 +104,6 @@ type StructProperties struct { decoderTags tagMap // map from proto tag to struct field number decoderOrigNames map[string]int // map from original name to struct field number order []int // list of struct field numbers in tag order - unrecField field // field id of the XXX_unrecognized []byte field - extendable bool // is this an extendable proto - - oneofMarshaler oneofMarshaler - oneofUnmarshaler oneofUnmarshaler - oneofSizer oneofSizer - stype reflect.Type // OneofTypes contains information about the oneof fields in this message. // It is keyed by the original name of a field. @@ -182,41 +139,24 @@ type Properties struct { Repeated bool Packed bool // relevant for repeated primitives only Enum string // set for enum types only - proto3 bool // whether this is known to be a proto3 field; set for []byte only + proto3 bool // whether this is known to be a proto3 field oneof bool // whether this is a oneof field Default string // default value HasDefault bool // whether an explicit default was provided - def_uint64 uint64 - - enc encoder - valEnc valueEncoder // set for bool and numeric types only - field field - tagcode []byte // encoding of EncodeVarint((Tag<<3)|WireType) - tagbuf [8]byte - stype reflect.Type // set for struct types only - sprop *StructProperties // set for struct types only - isMarshaler bool - isUnmarshaler bool - - mtype reflect.Type // set for map types only - mkeyprop *Properties // set for map types only - mvalprop *Properties // set for map types only - - size sizer - valSize valueSizer // set for bool and numeric types only - - dec decoder - valDec valueDecoder // set for bool and numeric types only - - // If this is a packable field, this will be the decoder for the packed version of the field. - packedDec decoder + + stype reflect.Type // set for struct types only + sprop *StructProperties // set for struct types only + + mtype reflect.Type // set for map types only + MapKeyProp *Properties // set for map types only + MapValProp *Properties // set for map types only } // String formats the properties in the protobuf struct field tag style. func (p *Properties) String() string { s := p.Wire - s = "," + s += "," s += strconv.Itoa(p.Tag) if p.Required { s += ",req" @@ -262,29 +202,14 @@ func (p *Properties) Parse(s string) { switch p.Wire { case "varint": p.WireType = WireVarint - p.valEnc = (*Buffer).EncodeVarint - p.valDec = (*Buffer).DecodeVarint - p.valSize = sizeVarint case "fixed32": p.WireType = WireFixed32 - p.valEnc = (*Buffer).EncodeFixed32 - p.valDec = (*Buffer).DecodeFixed32 - p.valSize = sizeFixed32 case "fixed64": p.WireType = WireFixed64 - p.valEnc = (*Buffer).EncodeFixed64 - p.valDec = (*Buffer).DecodeFixed64 - p.valSize = sizeFixed64 case "zigzag32": p.WireType = WireVarint - p.valEnc = (*Buffer).EncodeZigzag32 - p.valDec = (*Buffer).DecodeZigzag32 - p.valSize = sizeZigzag32 case "zigzag64": p.WireType = WireVarint - p.valEnc = (*Buffer).EncodeZigzag64 - p.valDec = (*Buffer).DecodeZigzag64 - p.valSize = sizeZigzag64 case "bytes", "group": p.WireType = WireBytes // no numeric converter for non-numeric types @@ -299,6 +224,7 @@ func (p *Properties) Parse(s string) { return } +outer: for i := 2; i < len(fields); i++ { f := fields[i] switch { @@ -326,256 +252,41 @@ func (p *Properties) Parse(s string) { if i+1 < len(fields) { // Commas aren't escaped, and def is always last. p.Default += "," + strings.Join(fields[i+1:], ",") - break + break outer } } } } -func logNoSliceEnc(t1, t2 reflect.Type) { - fmt.Fprintf(os.Stderr, "proto: no slice oenc for %T = []%T\n", t1, t2) -} - var protoMessageType = reflect.TypeOf((*Message)(nil)).Elem() -// Initialize the fields for encoding and decoding. -func (p *Properties) setEncAndDec(typ reflect.Type, f *reflect.StructField, lockGetProp bool) { - p.enc = nil - p.dec = nil - p.size = nil - +// setFieldProps initializes the field properties for submessages and maps. +func (p *Properties) setFieldProps(typ reflect.Type, f *reflect.StructField, lockGetProp bool) { switch t1 := typ; t1.Kind() { - default: - fmt.Fprintf(os.Stderr, "proto: no coders for %v\n", t1) - - // proto3 scalar types - - case reflect.Bool: - p.enc = (*Buffer).enc_proto3_bool - p.dec = (*Buffer).dec_proto3_bool - p.size = size_proto3_bool - case reflect.Int32: - p.enc = (*Buffer).enc_proto3_int32 - p.dec = (*Buffer).dec_proto3_int32 - p.size = size_proto3_int32 - case reflect.Uint32: - p.enc = (*Buffer).enc_proto3_uint32 - p.dec = (*Buffer).dec_proto3_int32 // can reuse - p.size = size_proto3_uint32 - case reflect.Int64, reflect.Uint64: - p.enc = (*Buffer).enc_proto3_int64 - p.dec = (*Buffer).dec_proto3_int64 - p.size = size_proto3_int64 - case reflect.Float32: - p.enc = (*Buffer).enc_proto3_uint32 // can just treat them as bits - p.dec = (*Buffer).dec_proto3_int32 - p.size = size_proto3_uint32 - case reflect.Float64: - p.enc = (*Buffer).enc_proto3_int64 // can just treat them as bits - p.dec = (*Buffer).dec_proto3_int64 - p.size = size_proto3_int64 - case reflect.String: - p.enc = (*Buffer).enc_proto3_string - p.dec = (*Buffer).dec_proto3_string - p.size = size_proto3_string - case reflect.Ptr: - switch t2 := t1.Elem(); t2.Kind() { - default: - fmt.Fprintf(os.Stderr, "proto: no encoder function for %v -> %v\n", t1, t2) - break - case reflect.Bool: - p.enc = (*Buffer).enc_bool - p.dec = (*Buffer).dec_bool - p.size = size_bool - case reflect.Int32: - p.enc = (*Buffer).enc_int32 - p.dec = (*Buffer).dec_int32 - p.size = size_int32 - case reflect.Uint32: - p.enc = (*Buffer).enc_uint32 - p.dec = (*Buffer).dec_int32 // can reuse - p.size = size_uint32 - case reflect.Int64, reflect.Uint64: - p.enc = (*Buffer).enc_int64 - p.dec = (*Buffer).dec_int64 - p.size = size_int64 - case reflect.Float32: - p.enc = (*Buffer).enc_uint32 // can just treat them as bits - p.dec = (*Buffer).dec_int32 - p.size = size_uint32 - case reflect.Float64: - p.enc = (*Buffer).enc_int64 // can just treat them as bits - p.dec = (*Buffer).dec_int64 - p.size = size_int64 - case reflect.String: - p.enc = (*Buffer).enc_string - p.dec = (*Buffer).dec_string - p.size = size_string - case reflect.Struct: + if t1.Elem().Kind() == reflect.Struct { p.stype = t1.Elem() - p.isMarshaler = isMarshaler(t1) - p.isUnmarshaler = isUnmarshaler(t1) - if p.Wire == "bytes" { - p.enc = (*Buffer).enc_struct_message - p.dec = (*Buffer).dec_struct_message - p.size = size_struct_message - } else { - p.enc = (*Buffer).enc_struct_group - p.dec = (*Buffer).dec_struct_group - p.size = size_struct_group - } } case reflect.Slice: - switch t2 := t1.Elem(); t2.Kind() { - default: - logNoSliceEnc(t1, t2) - break - case reflect.Bool: - if p.Packed { - p.enc = (*Buffer).enc_slice_packed_bool - p.size = size_slice_packed_bool - } else { - p.enc = (*Buffer).enc_slice_bool - p.size = size_slice_bool - } - p.dec = (*Buffer).dec_slice_bool - p.packedDec = (*Buffer).dec_slice_packed_bool - case reflect.Int32: - if p.Packed { - p.enc = (*Buffer).enc_slice_packed_int32 - p.size = size_slice_packed_int32 - } else { - p.enc = (*Buffer).enc_slice_int32 - p.size = size_slice_int32 - } - p.dec = (*Buffer).dec_slice_int32 - p.packedDec = (*Buffer).dec_slice_packed_int32 - case reflect.Uint32: - if p.Packed { - p.enc = (*Buffer).enc_slice_packed_uint32 - p.size = size_slice_packed_uint32 - } else { - p.enc = (*Buffer).enc_slice_uint32 - p.size = size_slice_uint32 - } - p.dec = (*Buffer).dec_slice_int32 - p.packedDec = (*Buffer).dec_slice_packed_int32 - case reflect.Int64, reflect.Uint64: - if p.Packed { - p.enc = (*Buffer).enc_slice_packed_int64 - p.size = size_slice_packed_int64 - } else { - p.enc = (*Buffer).enc_slice_int64 - p.size = size_slice_int64 - } - p.dec = (*Buffer).dec_slice_int64 - p.packedDec = (*Buffer).dec_slice_packed_int64 - case reflect.Uint8: - p.dec = (*Buffer).dec_slice_byte - if p.proto3 { - p.enc = (*Buffer).enc_proto3_slice_byte - p.size = size_proto3_slice_byte - } else { - p.enc = (*Buffer).enc_slice_byte - p.size = size_slice_byte - } - case reflect.Float32, reflect.Float64: - switch t2.Bits() { - case 32: - // can just treat them as bits - if p.Packed { - p.enc = (*Buffer).enc_slice_packed_uint32 - p.size = size_slice_packed_uint32 - } else { - p.enc = (*Buffer).enc_slice_uint32 - p.size = size_slice_uint32 - } - p.dec = (*Buffer).dec_slice_int32 - p.packedDec = (*Buffer).dec_slice_packed_int32 - case 64: - // can just treat them as bits - if p.Packed { - p.enc = (*Buffer).enc_slice_packed_int64 - p.size = size_slice_packed_int64 - } else { - p.enc = (*Buffer).enc_slice_int64 - p.size = size_slice_int64 - } - p.dec = (*Buffer).dec_slice_int64 - p.packedDec = (*Buffer).dec_slice_packed_int64 - default: - logNoSliceEnc(t1, t2) - break - } - case reflect.String: - p.enc = (*Buffer).enc_slice_string - p.dec = (*Buffer).dec_slice_string - p.size = size_slice_string - case reflect.Ptr: - switch t3 := t2.Elem(); t3.Kind() { - default: - fmt.Fprintf(os.Stderr, "proto: no ptr oenc for %T -> %T -> %T\n", t1, t2, t3) - break - case reflect.Struct: - p.stype = t2.Elem() - p.isMarshaler = isMarshaler(t2) - p.isUnmarshaler = isUnmarshaler(t2) - if p.Wire == "bytes" { - p.enc = (*Buffer).enc_slice_struct_message - p.dec = (*Buffer).dec_slice_struct_message - p.size = size_slice_struct_message - } else { - p.enc = (*Buffer).enc_slice_struct_group - p.dec = (*Buffer).dec_slice_struct_group - p.size = size_slice_struct_group - } - } - case reflect.Slice: - switch t2.Elem().Kind() { - default: - fmt.Fprintf(os.Stderr, "proto: no slice elem oenc for %T -> %T -> %T\n", t1, t2, t2.Elem()) - break - case reflect.Uint8: - p.enc = (*Buffer).enc_slice_slice_byte - p.dec = (*Buffer).dec_slice_slice_byte - p.size = size_slice_slice_byte - } + if t2 := t1.Elem(); t2.Kind() == reflect.Ptr && t2.Elem().Kind() == reflect.Struct { + p.stype = t2.Elem() } case reflect.Map: - p.enc = (*Buffer).enc_new_map - p.dec = (*Buffer).dec_new_map - p.size = size_new_map - p.mtype = t1 - p.mkeyprop = &Properties{} - p.mkeyprop.init(reflect.PtrTo(p.mtype.Key()), "Key", f.Tag.Get("protobuf_key"), nil, lockGetProp) - p.mvalprop = &Properties{} + p.MapKeyProp = &Properties{} + p.MapKeyProp.init(reflect.PtrTo(p.mtype.Key()), "Key", f.Tag.Get("protobuf_key"), nil, lockGetProp) + p.MapValProp = &Properties{} vtype := p.mtype.Elem() if vtype.Kind() != reflect.Ptr && vtype.Kind() != reflect.Slice { // The value type is not a message (*T) or bytes ([]byte), // so we need encoders for the pointer to this type. vtype = reflect.PtrTo(vtype) } - p.mvalprop.init(vtype, "Value", f.Tag.Get("protobuf_val"), nil, lockGetProp) + p.MapValProp.init(vtype, "Value", f.Tag.Get("protobuf_val"), nil, lockGetProp) } - // precalculate tag code - wire := p.WireType - if p.Packed { - wire = WireBytes - } - x := uint32(p.Tag)<<3 | uint32(wire) - i := 0 - for i = 0; x > 127; i++ { - p.tagbuf[i] = 0x80 | uint8(x&0x7F) - x >>= 7 - } - p.tagbuf[i] = uint8(x) - p.tagcode = p.tagbuf[0 : i+1] - if p.stype != nil { if lockGetProp { p.sprop = GetProperties(p.stype) @@ -586,32 +297,9 @@ func (p *Properties) setEncAndDec(typ reflect.Type, f *reflect.StructField, lock } var ( - marshalerType = reflect.TypeOf((*Marshaler)(nil)).Elem() - unmarshalerType = reflect.TypeOf((*Unmarshaler)(nil)).Elem() + marshalerType = reflect.TypeOf((*Marshaler)(nil)).Elem() ) -// isMarshaler reports whether type t implements Marshaler. -func isMarshaler(t reflect.Type) bool { - // We're checking for (likely) pointer-receiver methods - // so if t is not a pointer, something is very wrong. - // The calls above only invoke isMarshaler on pointer types. - if t.Kind() != reflect.Ptr { - panic("proto: misuse of isMarshaler") - } - return t.Implements(marshalerType) -} - -// isUnmarshaler reports whether type t implements Unmarshaler. -func isUnmarshaler(t reflect.Type) bool { - // We're checking for (likely) pointer-receiver methods - // so if t is not a pointer, something is very wrong. - // The calls above only invoke isUnmarshaler on pointer types. - if t.Kind() != reflect.Ptr { - panic("proto: misuse of isUnmarshaler") - } - return t.Implements(unmarshalerType) -} - // Init populates the properties from a protocol buffer struct tag. func (p *Properties) Init(typ reflect.Type, name, tag string, f *reflect.StructField) { p.init(typ, name, tag, f, true) @@ -621,14 +309,11 @@ func (p *Properties) init(typ reflect.Type, name, tag string, f *reflect.StructF // "bytes,49,opt,def=hello!" p.Name = name p.OrigName = name - if f != nil { - p.field = toField(f) - } if tag == "" { return } p.Parse(tag) - p.setEncAndDec(typ, f, lockGetProp) + p.setFieldProps(typ, f, lockGetProp) } var ( @@ -678,9 +363,6 @@ func getPropertiesLocked(t reflect.Type) *StructProperties { propertiesMap[t] = prop // build properties - prop.extendable = reflect.PtrTo(t).Implements(extendableProtoType) || - reflect.PtrTo(t).Implements(extendableProtoV1Type) - prop.unrecField = invalidField prop.Prop = make([]*Properties, t.NumField()) prop.order = make([]int, t.NumField()) @@ -690,17 +372,6 @@ func getPropertiesLocked(t reflect.Type) *StructProperties { name := f.Name p.init(f.Type, name, f.Tag.Get("protobuf"), &f, false) - if f.Name == "XXX_InternalExtensions" { // special case - p.enc = (*Buffer).enc_exts - p.dec = nil // not needed - p.size = size_exts - } else if f.Name == "XXX_extensions" { // special case - p.enc = (*Buffer).enc_map - p.dec = nil // not needed - p.size = size_map - } else if f.Name == "XXX_unrecognized" { // special case - prop.unrecField = toField(&f) - } oneof := f.Tag.Get("protobuf_oneof") // special case if oneof != "" { // Oneof fields don't use the traditional protobuf tag. @@ -715,9 +386,6 @@ func getPropertiesLocked(t reflect.Type) *StructProperties { } print("\n") } - if p.enc == nil && !strings.HasPrefix(f.Name, "XXX_") && oneof == "" { - fmt.Fprintln(os.Stderr, "proto: no encoder for", f.Name, f.Type.String(), "[GetProperties]") - } } // Re-order prop.order. @@ -728,8 +396,7 @@ func getPropertiesLocked(t reflect.Type) *StructProperties { } if om, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); ok { var oots []interface{} - prop.oneofMarshaler, prop.oneofUnmarshaler, prop.oneofSizer, oots = om.XXX_OneofFuncs() - prop.stype = t + _, _, _, oots = om.XXX_OneofFuncs() // Interpret oneof metadata. prop.OneofTypes = make(map[string]*OneofProperties) @@ -779,30 +446,6 @@ func getPropertiesLocked(t reflect.Type) *StructProperties { return prop } -// Return the Properties object for the x[0]'th field of the structure. -func propByIndex(t reflect.Type, x []int) *Properties { - if len(x) != 1 { - fmt.Fprintf(os.Stderr, "proto: field index dimension %d (not 1) for type %s\n", len(x), t) - return nil - } - prop := GetProperties(t) - return prop.Prop[x[0]] -} - -// Get the address and type of a pointer to a struct from an interface. -func getbase(pb Message) (t reflect.Type, b structPointer, err error) { - if pb == nil { - err = ErrNil - return - } - // get the reflect type of the pointer to the struct. - t = reflect.TypeOf(pb) - // get the address of the struct. - value := reflect.ValueOf(pb) - b = toStructPointer(value) - return -} - // A global registry of enum types. // The generated code will register the generated maps by calling RegisterEnum. @@ -826,20 +469,42 @@ func EnumValueMap(enumType string) map[string]int32 { // A registry of all linked message types. // The string is a fully-qualified proto name ("pkg.Message"). var ( - protoTypes = make(map[string]reflect.Type) - revProtoTypes = make(map[reflect.Type]string) + protoTypedNils = make(map[string]Message) // a map from proto names to typed nil pointers + protoMapTypes = make(map[string]reflect.Type) // a map from proto names to map types + revProtoTypes = make(map[reflect.Type]string) ) // RegisterType is called from generated code and maps from the fully qualified // proto name to the type (pointer to struct) of the protocol buffer. func RegisterType(x Message, name string) { - if _, ok := protoTypes[name]; ok { + if _, ok := protoTypedNils[name]; ok { // TODO: Some day, make this a panic. log.Printf("proto: duplicate proto type registered: %s", name) return } t := reflect.TypeOf(x) - protoTypes[name] = t + if v := reflect.ValueOf(x); v.Kind() == reflect.Ptr && v.Pointer() == 0 { + // Generated code always calls RegisterType with nil x. + // This check is just for extra safety. + protoTypedNils[name] = x + } else { + protoTypedNils[name] = reflect.Zero(t).Interface().(Message) + } + revProtoTypes[t] = name +} + +// RegisterMapType is called from generated code and maps from the fully qualified +// proto name to the native map type of the proto map definition. +func RegisterMapType(x interface{}, name string) { + if reflect.TypeOf(x).Kind() != reflect.Map { + panic(fmt.Sprintf("RegisterMapType(%T, %q); want map", x, name)) + } + if _, ok := protoMapTypes[name]; ok { + log.Printf("proto: duplicate proto type registered: %s", name) + return + } + t := reflect.TypeOf(x) + protoMapTypes[name] = t revProtoTypes[t] = name } @@ -855,7 +520,14 @@ func MessageName(x Message) string { } // MessageType returns the message type (pointer to struct) for a named message. -func MessageType(name string) reflect.Type { return protoTypes[name] } +// The type is not guaranteed to implement proto.Message if the name refers to a +// map entry. +func MessageType(name string) reflect.Type { + if t, ok := protoTypedNils[name]; ok { + return reflect.TypeOf(t) + } + return protoMapTypes[name] +} // A registry of all linked proto files. var ( diff --git a/vendor/github.com/golang/protobuf/proto/table_marshal.go b/vendor/github.com/golang/protobuf/proto/table_marshal.go new file mode 100644 index 0000000..b167944 --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/table_marshal.go @@ -0,0 +1,2767 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2016 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +import ( + "errors" + "fmt" + "math" + "reflect" + "sort" + "strconv" + "strings" + "sync" + "sync/atomic" + "unicode/utf8" +) + +// a sizer takes a pointer to a field and the size of its tag, computes the size of +// the encoded data. +type sizer func(pointer, int) int + +// a marshaler takes a byte slice, a pointer to a field, and its tag (in wire format), +// marshals the field to the end of the slice, returns the slice and error (if any). +type marshaler func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) + +// marshalInfo is the information used for marshaling a message. +type marshalInfo struct { + typ reflect.Type + fields []*marshalFieldInfo + unrecognized field // offset of XXX_unrecognized + extensions field // offset of XXX_InternalExtensions + v1extensions field // offset of XXX_extensions + sizecache field // offset of XXX_sizecache + initialized int32 // 0 -- only typ is set, 1 -- fully initialized + messageset bool // uses message set wire format + hasmarshaler bool // has custom marshaler + sync.RWMutex // protect extElems map, also for initialization + extElems map[int32]*marshalElemInfo // info of extension elements +} + +// marshalFieldInfo is the information used for marshaling a field of a message. +type marshalFieldInfo struct { + field field + wiretag uint64 // tag in wire format + tagsize int // size of tag in wire format + sizer sizer + marshaler marshaler + isPointer bool + required bool // field is required + name string // name of the field, for error reporting + oneofElems map[reflect.Type]*marshalElemInfo // info of oneof elements +} + +// marshalElemInfo is the information used for marshaling an extension or oneof element. +type marshalElemInfo struct { + wiretag uint64 // tag in wire format + tagsize int // size of tag in wire format + sizer sizer + marshaler marshaler + isptr bool // elem is pointer typed, thus interface of this type is a direct interface (extension only) +} + +var ( + marshalInfoMap = map[reflect.Type]*marshalInfo{} + marshalInfoLock sync.Mutex +) + +// getMarshalInfo returns the information to marshal a given type of message. +// The info it returns may not necessarily initialized. +// t is the type of the message (NOT the pointer to it). +func getMarshalInfo(t reflect.Type) *marshalInfo { + marshalInfoLock.Lock() + u, ok := marshalInfoMap[t] + if !ok { + u = &marshalInfo{typ: t} + marshalInfoMap[t] = u + } + marshalInfoLock.Unlock() + return u +} + +// Size is the entry point from generated code, +// and should be ONLY called by generated code. +// It computes the size of encoded data of msg. +// a is a pointer to a place to store cached marshal info. +func (a *InternalMessageInfo) Size(msg Message) int { + u := getMessageMarshalInfo(msg, a) + ptr := toPointer(&msg) + if ptr.isNil() { + // We get here if msg is a typed nil ((*SomeMessage)(nil)), + // so it satisfies the interface, and msg == nil wouldn't + // catch it. We don't want crash in this case. + return 0 + } + return u.size(ptr) +} + +// Marshal is the entry point from generated code, +// and should be ONLY called by generated code. +// It marshals msg to the end of b. +// a is a pointer to a place to store cached marshal info. +func (a *InternalMessageInfo) Marshal(b []byte, msg Message, deterministic bool) ([]byte, error) { + u := getMessageMarshalInfo(msg, a) + ptr := toPointer(&msg) + if ptr.isNil() { + // We get here if msg is a typed nil ((*SomeMessage)(nil)), + // so it satisfies the interface, and msg == nil wouldn't + // catch it. We don't want crash in this case. + return b, ErrNil + } + return u.marshal(b, ptr, deterministic) +} + +func getMessageMarshalInfo(msg interface{}, a *InternalMessageInfo) *marshalInfo { + // u := a.marshal, but atomically. + // We use an atomic here to ensure memory consistency. + u := atomicLoadMarshalInfo(&a.marshal) + if u == nil { + // Get marshal information from type of message. + t := reflect.ValueOf(msg).Type() + if t.Kind() != reflect.Ptr { + panic(fmt.Sprintf("cannot handle non-pointer message type %v", t)) + } + u = getMarshalInfo(t.Elem()) + // Store it in the cache for later users. + // a.marshal = u, but atomically. + atomicStoreMarshalInfo(&a.marshal, u) + } + return u +} + +// size is the main function to compute the size of the encoded data of a message. +// ptr is the pointer to the message. +func (u *marshalInfo) size(ptr pointer) int { + if atomic.LoadInt32(&u.initialized) == 0 { + u.computeMarshalInfo() + } + + // If the message can marshal itself, let it do it, for compatibility. + // NOTE: This is not efficient. + if u.hasmarshaler { + m := ptr.asPointerTo(u.typ).Interface().(Marshaler) + b, _ := m.Marshal() + return len(b) + } + + n := 0 + for _, f := range u.fields { + if f.isPointer && ptr.offset(f.field).getPointer().isNil() { + // nil pointer always marshals to nothing + continue + } + n += f.sizer(ptr.offset(f.field), f.tagsize) + } + if u.extensions.IsValid() { + e := ptr.offset(u.extensions).toExtensions() + if u.messageset { + n += u.sizeMessageSet(e) + } else { + n += u.sizeExtensions(e) + } + } + if u.v1extensions.IsValid() { + m := *ptr.offset(u.v1extensions).toOldExtensions() + n += u.sizeV1Extensions(m) + } + if u.unrecognized.IsValid() { + s := *ptr.offset(u.unrecognized).toBytes() + n += len(s) + } + // cache the result for use in marshal + if u.sizecache.IsValid() { + atomic.StoreInt32(ptr.offset(u.sizecache).toInt32(), int32(n)) + } + return n +} + +// cachedsize gets the size from cache. If there is no cache (i.e. message is not generated), +// fall back to compute the size. +func (u *marshalInfo) cachedsize(ptr pointer) int { + if u.sizecache.IsValid() { + return int(atomic.LoadInt32(ptr.offset(u.sizecache).toInt32())) + } + return u.size(ptr) +} + +// marshal is the main function to marshal a message. It takes a byte slice and appends +// the encoded data to the end of the slice, returns the slice and error (if any). +// ptr is the pointer to the message. +// If deterministic is true, map is marshaled in deterministic order. +func (u *marshalInfo) marshal(b []byte, ptr pointer, deterministic bool) ([]byte, error) { + if atomic.LoadInt32(&u.initialized) == 0 { + u.computeMarshalInfo() + } + + // If the message can marshal itself, let it do it, for compatibility. + // NOTE: This is not efficient. + if u.hasmarshaler { + m := ptr.asPointerTo(u.typ).Interface().(Marshaler) + b1, err := m.Marshal() + b = append(b, b1...) + return b, err + } + + var err, errLater error + // The old marshaler encodes extensions at beginning. + if u.extensions.IsValid() { + e := ptr.offset(u.extensions).toExtensions() + if u.messageset { + b, err = u.appendMessageSet(b, e, deterministic) + } else { + b, err = u.appendExtensions(b, e, deterministic) + } + if err != nil { + return b, err + } + } + if u.v1extensions.IsValid() { + m := *ptr.offset(u.v1extensions).toOldExtensions() + b, err = u.appendV1Extensions(b, m, deterministic) + if err != nil { + return b, err + } + } + for _, f := range u.fields { + if f.required { + if ptr.offset(f.field).getPointer().isNil() { + // Required field is not set. + // We record the error but keep going, to give a complete marshaling. + if errLater == nil { + errLater = &RequiredNotSetError{f.name} + } + continue + } + } + if f.isPointer && ptr.offset(f.field).getPointer().isNil() { + // nil pointer always marshals to nothing + continue + } + b, err = f.marshaler(b, ptr.offset(f.field), f.wiretag, deterministic) + if err != nil { + if err1, ok := err.(*RequiredNotSetError); ok { + // Required field in submessage is not set. + // We record the error but keep going, to give a complete marshaling. + if errLater == nil { + errLater = &RequiredNotSetError{f.name + "." + err1.field} + } + continue + } + if err == errRepeatedHasNil { + err = errors.New("proto: repeated field " + f.name + " has nil element") + } + if err == errInvalidUTF8 { + if errLater == nil { + fullName := revProtoTypes[reflect.PtrTo(u.typ)] + "." + f.name + errLater = &invalidUTF8Error{fullName} + } + continue + } + return b, err + } + } + if u.unrecognized.IsValid() { + s := *ptr.offset(u.unrecognized).toBytes() + b = append(b, s...) + } + return b, errLater +} + +// computeMarshalInfo initializes the marshal info. +func (u *marshalInfo) computeMarshalInfo() { + u.Lock() + defer u.Unlock() + if u.initialized != 0 { // non-atomic read is ok as it is protected by the lock + return + } + + t := u.typ + u.unrecognized = invalidField + u.extensions = invalidField + u.v1extensions = invalidField + u.sizecache = invalidField + + // If the message can marshal itself, let it do it, for compatibility. + // NOTE: This is not efficient. + if reflect.PtrTo(t).Implements(marshalerType) { + u.hasmarshaler = true + atomic.StoreInt32(&u.initialized, 1) + return + } + + // get oneof implementers + var oneofImplementers []interface{} + if m, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); ok { + _, _, _, oneofImplementers = m.XXX_OneofFuncs() + } + + n := t.NumField() + + // deal with XXX fields first + for i := 0; i < t.NumField(); i++ { + f := t.Field(i) + if !strings.HasPrefix(f.Name, "XXX_") { + continue + } + switch f.Name { + case "XXX_sizecache": + u.sizecache = toField(&f) + case "XXX_unrecognized": + u.unrecognized = toField(&f) + case "XXX_InternalExtensions": + u.extensions = toField(&f) + u.messageset = f.Tag.Get("protobuf_messageset") == "1" + case "XXX_extensions": + u.v1extensions = toField(&f) + case "XXX_NoUnkeyedLiteral": + // nothing to do + default: + panic("unknown XXX field: " + f.Name) + } + n-- + } + + // normal fields + fields := make([]marshalFieldInfo, n) // batch allocation + u.fields = make([]*marshalFieldInfo, 0, n) + for i, j := 0, 0; i < t.NumField(); i++ { + f := t.Field(i) + + if strings.HasPrefix(f.Name, "XXX_") { + continue + } + field := &fields[j] + j++ + field.name = f.Name + u.fields = append(u.fields, field) + if f.Tag.Get("protobuf_oneof") != "" { + field.computeOneofFieldInfo(&f, oneofImplementers) + continue + } + if f.Tag.Get("protobuf") == "" { + // field has no tag (not in generated message), ignore it + u.fields = u.fields[:len(u.fields)-1] + j-- + continue + } + field.computeMarshalFieldInfo(&f) + } + + // fields are marshaled in tag order on the wire. + sort.Sort(byTag(u.fields)) + + atomic.StoreInt32(&u.initialized, 1) +} + +// helper for sorting fields by tag +type byTag []*marshalFieldInfo + +func (a byTag) Len() int { return len(a) } +func (a byTag) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +func (a byTag) Less(i, j int) bool { return a[i].wiretag < a[j].wiretag } + +// getExtElemInfo returns the information to marshal an extension element. +// The info it returns is initialized. +func (u *marshalInfo) getExtElemInfo(desc *ExtensionDesc) *marshalElemInfo { + // get from cache first + u.RLock() + e, ok := u.extElems[desc.Field] + u.RUnlock() + if ok { + return e + } + + t := reflect.TypeOf(desc.ExtensionType) // pointer or slice to basic type or struct + tags := strings.Split(desc.Tag, ",") + tag, err := strconv.Atoi(tags[1]) + if err != nil { + panic("tag is not an integer") + } + wt := wiretype(tags[0]) + sizer, marshaler := typeMarshaler(t, tags, false, false) + e = &marshalElemInfo{ + wiretag: uint64(tag)<<3 | wt, + tagsize: SizeVarint(uint64(tag) << 3), + sizer: sizer, + marshaler: marshaler, + isptr: t.Kind() == reflect.Ptr, + } + + // update cache + u.Lock() + if u.extElems == nil { + u.extElems = make(map[int32]*marshalElemInfo) + } + u.extElems[desc.Field] = e + u.Unlock() + return e +} + +// computeMarshalFieldInfo fills up the information to marshal a field. +func (fi *marshalFieldInfo) computeMarshalFieldInfo(f *reflect.StructField) { + // parse protobuf tag of the field. + // tag has format of "bytes,49,opt,name=foo,def=hello!" + tags := strings.Split(f.Tag.Get("protobuf"), ",") + if tags[0] == "" { + return + } + tag, err := strconv.Atoi(tags[1]) + if err != nil { + panic("tag is not an integer") + } + wt := wiretype(tags[0]) + if tags[2] == "req" { + fi.required = true + } + fi.setTag(f, tag, wt) + fi.setMarshaler(f, tags) +} + +func (fi *marshalFieldInfo) computeOneofFieldInfo(f *reflect.StructField, oneofImplementers []interface{}) { + fi.field = toField(f) + fi.wiretag = 1<<31 - 1 // Use a large tag number, make oneofs sorted at the end. This tag will not appear on the wire. + fi.isPointer = true + fi.sizer, fi.marshaler = makeOneOfMarshaler(fi, f) + fi.oneofElems = make(map[reflect.Type]*marshalElemInfo) + + ityp := f.Type // interface type + for _, o := range oneofImplementers { + t := reflect.TypeOf(o) + if !t.Implements(ityp) { + continue + } + sf := t.Elem().Field(0) // oneof implementer is a struct with a single field + tags := strings.Split(sf.Tag.Get("protobuf"), ",") + tag, err := strconv.Atoi(tags[1]) + if err != nil { + panic("tag is not an integer") + } + wt := wiretype(tags[0]) + sizer, marshaler := typeMarshaler(sf.Type, tags, false, true) // oneof should not omit any zero value + fi.oneofElems[t.Elem()] = &marshalElemInfo{ + wiretag: uint64(tag)<<3 | wt, + tagsize: SizeVarint(uint64(tag) << 3), + sizer: sizer, + marshaler: marshaler, + } + } +} + +type oneofMessage interface { + XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{}) +} + +// wiretype returns the wire encoding of the type. +func wiretype(encoding string) uint64 { + switch encoding { + case "fixed32": + return WireFixed32 + case "fixed64": + return WireFixed64 + case "varint", "zigzag32", "zigzag64": + return WireVarint + case "bytes": + return WireBytes + case "group": + return WireStartGroup + } + panic("unknown wire type " + encoding) +} + +// setTag fills up the tag (in wire format) and its size in the info of a field. +func (fi *marshalFieldInfo) setTag(f *reflect.StructField, tag int, wt uint64) { + fi.field = toField(f) + fi.wiretag = uint64(tag)<<3 | wt + fi.tagsize = SizeVarint(uint64(tag) << 3) +} + +// setMarshaler fills up the sizer and marshaler in the info of a field. +func (fi *marshalFieldInfo) setMarshaler(f *reflect.StructField, tags []string) { + switch f.Type.Kind() { + case reflect.Map: + // map field + fi.isPointer = true + fi.sizer, fi.marshaler = makeMapMarshaler(f) + return + case reflect.Ptr, reflect.Slice: + fi.isPointer = true + } + fi.sizer, fi.marshaler = typeMarshaler(f.Type, tags, true, false) +} + +// typeMarshaler returns the sizer and marshaler of a given field. +// t is the type of the field. +// tags is the generated "protobuf" tag of the field. +// If nozero is true, zero value is not marshaled to the wire. +// If oneof is true, it is a oneof field. +func typeMarshaler(t reflect.Type, tags []string, nozero, oneof bool) (sizer, marshaler) { + encoding := tags[0] + + pointer := false + slice := false + if t.Kind() == reflect.Slice && t.Elem().Kind() != reflect.Uint8 { + slice = true + t = t.Elem() + } + if t.Kind() == reflect.Ptr { + pointer = true + t = t.Elem() + } + + packed := false + proto3 := false + validateUTF8 := true + for i := 2; i < len(tags); i++ { + if tags[i] == "packed" { + packed = true + } + if tags[i] == "proto3" { + proto3 = true + } + } + validateUTF8 = validateUTF8 && proto3 + + switch t.Kind() { + case reflect.Bool: + if pointer { + return sizeBoolPtr, appendBoolPtr + } + if slice { + if packed { + return sizeBoolPackedSlice, appendBoolPackedSlice + } + return sizeBoolSlice, appendBoolSlice + } + if nozero { + return sizeBoolValueNoZero, appendBoolValueNoZero + } + return sizeBoolValue, appendBoolValue + case reflect.Uint32: + switch encoding { + case "fixed32": + if pointer { + return sizeFixed32Ptr, appendFixed32Ptr + } + if slice { + if packed { + return sizeFixed32PackedSlice, appendFixed32PackedSlice + } + return sizeFixed32Slice, appendFixed32Slice + } + if nozero { + return sizeFixed32ValueNoZero, appendFixed32ValueNoZero + } + return sizeFixed32Value, appendFixed32Value + case "varint": + if pointer { + return sizeVarint32Ptr, appendVarint32Ptr + } + if slice { + if packed { + return sizeVarint32PackedSlice, appendVarint32PackedSlice + } + return sizeVarint32Slice, appendVarint32Slice + } + if nozero { + return sizeVarint32ValueNoZero, appendVarint32ValueNoZero + } + return sizeVarint32Value, appendVarint32Value + } + case reflect.Int32: + switch encoding { + case "fixed32": + if pointer { + return sizeFixedS32Ptr, appendFixedS32Ptr + } + if slice { + if packed { + return sizeFixedS32PackedSlice, appendFixedS32PackedSlice + } + return sizeFixedS32Slice, appendFixedS32Slice + } + if nozero { + return sizeFixedS32ValueNoZero, appendFixedS32ValueNoZero + } + return sizeFixedS32Value, appendFixedS32Value + case "varint": + if pointer { + return sizeVarintS32Ptr, appendVarintS32Ptr + } + if slice { + if packed { + return sizeVarintS32PackedSlice, appendVarintS32PackedSlice + } + return sizeVarintS32Slice, appendVarintS32Slice + } + if nozero { + return sizeVarintS32ValueNoZero, appendVarintS32ValueNoZero + } + return sizeVarintS32Value, appendVarintS32Value + case "zigzag32": + if pointer { + return sizeZigzag32Ptr, appendZigzag32Ptr + } + if slice { + if packed { + return sizeZigzag32PackedSlice, appendZigzag32PackedSlice + } + return sizeZigzag32Slice, appendZigzag32Slice + } + if nozero { + return sizeZigzag32ValueNoZero, appendZigzag32ValueNoZero + } + return sizeZigzag32Value, appendZigzag32Value + } + case reflect.Uint64: + switch encoding { + case "fixed64": + if pointer { + return sizeFixed64Ptr, appendFixed64Ptr + } + if slice { + if packed { + return sizeFixed64PackedSlice, appendFixed64PackedSlice + } + return sizeFixed64Slice, appendFixed64Slice + } + if nozero { + return sizeFixed64ValueNoZero, appendFixed64ValueNoZero + } + return sizeFixed64Value, appendFixed64Value + case "varint": + if pointer { + return sizeVarint64Ptr, appendVarint64Ptr + } + if slice { + if packed { + return sizeVarint64PackedSlice, appendVarint64PackedSlice + } + return sizeVarint64Slice, appendVarint64Slice + } + if nozero { + return sizeVarint64ValueNoZero, appendVarint64ValueNoZero + } + return sizeVarint64Value, appendVarint64Value + } + case reflect.Int64: + switch encoding { + case "fixed64": + if pointer { + return sizeFixedS64Ptr, appendFixedS64Ptr + } + if slice { + if packed { + return sizeFixedS64PackedSlice, appendFixedS64PackedSlice + } + return sizeFixedS64Slice, appendFixedS64Slice + } + if nozero { + return sizeFixedS64ValueNoZero, appendFixedS64ValueNoZero + } + return sizeFixedS64Value, appendFixedS64Value + case "varint": + if pointer { + return sizeVarintS64Ptr, appendVarintS64Ptr + } + if slice { + if packed { + return sizeVarintS64PackedSlice, appendVarintS64PackedSlice + } + return sizeVarintS64Slice, appendVarintS64Slice + } + if nozero { + return sizeVarintS64ValueNoZero, appendVarintS64ValueNoZero + } + return sizeVarintS64Value, appendVarintS64Value + case "zigzag64": + if pointer { + return sizeZigzag64Ptr, appendZigzag64Ptr + } + if slice { + if packed { + return sizeZigzag64PackedSlice, appendZigzag64PackedSlice + } + return sizeZigzag64Slice, appendZigzag64Slice + } + if nozero { + return sizeZigzag64ValueNoZero, appendZigzag64ValueNoZero + } + return sizeZigzag64Value, appendZigzag64Value + } + case reflect.Float32: + if pointer { + return sizeFloat32Ptr, appendFloat32Ptr + } + if slice { + if packed { + return sizeFloat32PackedSlice, appendFloat32PackedSlice + } + return sizeFloat32Slice, appendFloat32Slice + } + if nozero { + return sizeFloat32ValueNoZero, appendFloat32ValueNoZero + } + return sizeFloat32Value, appendFloat32Value + case reflect.Float64: + if pointer { + return sizeFloat64Ptr, appendFloat64Ptr + } + if slice { + if packed { + return sizeFloat64PackedSlice, appendFloat64PackedSlice + } + return sizeFloat64Slice, appendFloat64Slice + } + if nozero { + return sizeFloat64ValueNoZero, appendFloat64ValueNoZero + } + return sizeFloat64Value, appendFloat64Value + case reflect.String: + if validateUTF8 { + if pointer { + return sizeStringPtr, appendUTF8StringPtr + } + if slice { + return sizeStringSlice, appendUTF8StringSlice + } + if nozero { + return sizeStringValueNoZero, appendUTF8StringValueNoZero + } + return sizeStringValue, appendUTF8StringValue + } + if pointer { + return sizeStringPtr, appendStringPtr + } + if slice { + return sizeStringSlice, appendStringSlice + } + if nozero { + return sizeStringValueNoZero, appendStringValueNoZero + } + return sizeStringValue, appendStringValue + case reflect.Slice: + if slice { + return sizeBytesSlice, appendBytesSlice + } + if oneof { + // Oneof bytes field may also have "proto3" tag. + // We want to marshal it as a oneof field. Do this + // check before the proto3 check. + return sizeBytesOneof, appendBytesOneof + } + if proto3 { + return sizeBytes3, appendBytes3 + } + return sizeBytes, appendBytes + case reflect.Struct: + switch encoding { + case "group": + if slice { + return makeGroupSliceMarshaler(getMarshalInfo(t)) + } + return makeGroupMarshaler(getMarshalInfo(t)) + case "bytes": + if slice { + return makeMessageSliceMarshaler(getMarshalInfo(t)) + } + return makeMessageMarshaler(getMarshalInfo(t)) + } + } + panic(fmt.Sprintf("unknown or mismatched type: type: %v, wire type: %v", t, encoding)) +} + +// Below are functions to size/marshal a specific type of a field. +// They are stored in the field's info, and called by function pointers. +// They have type sizer or marshaler. + +func sizeFixed32Value(_ pointer, tagsize int) int { + return 4 + tagsize +} +func sizeFixed32ValueNoZero(ptr pointer, tagsize int) int { + v := *ptr.toUint32() + if v == 0 { + return 0 + } + return 4 + tagsize +} +func sizeFixed32Ptr(ptr pointer, tagsize int) int { + p := *ptr.toUint32Ptr() + if p == nil { + return 0 + } + return 4 + tagsize +} +func sizeFixed32Slice(ptr pointer, tagsize int) int { + s := *ptr.toUint32Slice() + return (4 + tagsize) * len(s) +} +func sizeFixed32PackedSlice(ptr pointer, tagsize int) int { + s := *ptr.toUint32Slice() + if len(s) == 0 { + return 0 + } + return 4*len(s) + SizeVarint(uint64(4*len(s))) + tagsize +} +func sizeFixedS32Value(_ pointer, tagsize int) int { + return 4 + tagsize +} +func sizeFixedS32ValueNoZero(ptr pointer, tagsize int) int { + v := *ptr.toInt32() + if v == 0 { + return 0 + } + return 4 + tagsize +} +func sizeFixedS32Ptr(ptr pointer, tagsize int) int { + p := ptr.getInt32Ptr() + if p == nil { + return 0 + } + return 4 + tagsize +} +func sizeFixedS32Slice(ptr pointer, tagsize int) int { + s := ptr.getInt32Slice() + return (4 + tagsize) * len(s) +} +func sizeFixedS32PackedSlice(ptr pointer, tagsize int) int { + s := ptr.getInt32Slice() + if len(s) == 0 { + return 0 + } + return 4*len(s) + SizeVarint(uint64(4*len(s))) + tagsize +} +func sizeFloat32Value(_ pointer, tagsize int) int { + return 4 + tagsize +} +func sizeFloat32ValueNoZero(ptr pointer, tagsize int) int { + v := math.Float32bits(*ptr.toFloat32()) + if v == 0 { + return 0 + } + return 4 + tagsize +} +func sizeFloat32Ptr(ptr pointer, tagsize int) int { + p := *ptr.toFloat32Ptr() + if p == nil { + return 0 + } + return 4 + tagsize +} +func sizeFloat32Slice(ptr pointer, tagsize int) int { + s := *ptr.toFloat32Slice() + return (4 + tagsize) * len(s) +} +func sizeFloat32PackedSlice(ptr pointer, tagsize int) int { + s := *ptr.toFloat32Slice() + if len(s) == 0 { + return 0 + } + return 4*len(s) + SizeVarint(uint64(4*len(s))) + tagsize +} +func sizeFixed64Value(_ pointer, tagsize int) int { + return 8 + tagsize +} +func sizeFixed64ValueNoZero(ptr pointer, tagsize int) int { + v := *ptr.toUint64() + if v == 0 { + return 0 + } + return 8 + tagsize +} +func sizeFixed64Ptr(ptr pointer, tagsize int) int { + p := *ptr.toUint64Ptr() + if p == nil { + return 0 + } + return 8 + tagsize +} +func sizeFixed64Slice(ptr pointer, tagsize int) int { + s := *ptr.toUint64Slice() + return (8 + tagsize) * len(s) +} +func sizeFixed64PackedSlice(ptr pointer, tagsize int) int { + s := *ptr.toUint64Slice() + if len(s) == 0 { + return 0 + } + return 8*len(s) + SizeVarint(uint64(8*len(s))) + tagsize +} +func sizeFixedS64Value(_ pointer, tagsize int) int { + return 8 + tagsize +} +func sizeFixedS64ValueNoZero(ptr pointer, tagsize int) int { + v := *ptr.toInt64() + if v == 0 { + return 0 + } + return 8 + tagsize +} +func sizeFixedS64Ptr(ptr pointer, tagsize int) int { + p := *ptr.toInt64Ptr() + if p == nil { + return 0 + } + return 8 + tagsize +} +func sizeFixedS64Slice(ptr pointer, tagsize int) int { + s := *ptr.toInt64Slice() + return (8 + tagsize) * len(s) +} +func sizeFixedS64PackedSlice(ptr pointer, tagsize int) int { + s := *ptr.toInt64Slice() + if len(s) == 0 { + return 0 + } + return 8*len(s) + SizeVarint(uint64(8*len(s))) + tagsize +} +func sizeFloat64Value(_ pointer, tagsize int) int { + return 8 + tagsize +} +func sizeFloat64ValueNoZero(ptr pointer, tagsize int) int { + v := math.Float64bits(*ptr.toFloat64()) + if v == 0 { + return 0 + } + return 8 + tagsize +} +func sizeFloat64Ptr(ptr pointer, tagsize int) int { + p := *ptr.toFloat64Ptr() + if p == nil { + return 0 + } + return 8 + tagsize +} +func sizeFloat64Slice(ptr pointer, tagsize int) int { + s := *ptr.toFloat64Slice() + return (8 + tagsize) * len(s) +} +func sizeFloat64PackedSlice(ptr pointer, tagsize int) int { + s := *ptr.toFloat64Slice() + if len(s) == 0 { + return 0 + } + return 8*len(s) + SizeVarint(uint64(8*len(s))) + tagsize +} +func sizeVarint32Value(ptr pointer, tagsize int) int { + v := *ptr.toUint32() + return SizeVarint(uint64(v)) + tagsize +} +func sizeVarint32ValueNoZero(ptr pointer, tagsize int) int { + v := *ptr.toUint32() + if v == 0 { + return 0 + } + return SizeVarint(uint64(v)) + tagsize +} +func sizeVarint32Ptr(ptr pointer, tagsize int) int { + p := *ptr.toUint32Ptr() + if p == nil { + return 0 + } + return SizeVarint(uint64(*p)) + tagsize +} +func sizeVarint32Slice(ptr pointer, tagsize int) int { + s := *ptr.toUint32Slice() + n := 0 + for _, v := range s { + n += SizeVarint(uint64(v)) + tagsize + } + return n +} +func sizeVarint32PackedSlice(ptr pointer, tagsize int) int { + s := *ptr.toUint32Slice() + if len(s) == 0 { + return 0 + } + n := 0 + for _, v := range s { + n += SizeVarint(uint64(v)) + } + return n + SizeVarint(uint64(n)) + tagsize +} +func sizeVarintS32Value(ptr pointer, tagsize int) int { + v := *ptr.toInt32() + return SizeVarint(uint64(v)) + tagsize +} +func sizeVarintS32ValueNoZero(ptr pointer, tagsize int) int { + v := *ptr.toInt32() + if v == 0 { + return 0 + } + return SizeVarint(uint64(v)) + tagsize +} +func sizeVarintS32Ptr(ptr pointer, tagsize int) int { + p := ptr.getInt32Ptr() + if p == nil { + return 0 + } + return SizeVarint(uint64(*p)) + tagsize +} +func sizeVarintS32Slice(ptr pointer, tagsize int) int { + s := ptr.getInt32Slice() + n := 0 + for _, v := range s { + n += SizeVarint(uint64(v)) + tagsize + } + return n +} +func sizeVarintS32PackedSlice(ptr pointer, tagsize int) int { + s := ptr.getInt32Slice() + if len(s) == 0 { + return 0 + } + n := 0 + for _, v := range s { + n += SizeVarint(uint64(v)) + } + return n + SizeVarint(uint64(n)) + tagsize +} +func sizeVarint64Value(ptr pointer, tagsize int) int { + v := *ptr.toUint64() + return SizeVarint(v) + tagsize +} +func sizeVarint64ValueNoZero(ptr pointer, tagsize int) int { + v := *ptr.toUint64() + if v == 0 { + return 0 + } + return SizeVarint(v) + tagsize +} +func sizeVarint64Ptr(ptr pointer, tagsize int) int { + p := *ptr.toUint64Ptr() + if p == nil { + return 0 + } + return SizeVarint(*p) + tagsize +} +func sizeVarint64Slice(ptr pointer, tagsize int) int { + s := *ptr.toUint64Slice() + n := 0 + for _, v := range s { + n += SizeVarint(v) + tagsize + } + return n +} +func sizeVarint64PackedSlice(ptr pointer, tagsize int) int { + s := *ptr.toUint64Slice() + if len(s) == 0 { + return 0 + } + n := 0 + for _, v := range s { + n += SizeVarint(v) + } + return n + SizeVarint(uint64(n)) + tagsize +} +func sizeVarintS64Value(ptr pointer, tagsize int) int { + v := *ptr.toInt64() + return SizeVarint(uint64(v)) + tagsize +} +func sizeVarintS64ValueNoZero(ptr pointer, tagsize int) int { + v := *ptr.toInt64() + if v == 0 { + return 0 + } + return SizeVarint(uint64(v)) + tagsize +} +func sizeVarintS64Ptr(ptr pointer, tagsize int) int { + p := *ptr.toInt64Ptr() + if p == nil { + return 0 + } + return SizeVarint(uint64(*p)) + tagsize +} +func sizeVarintS64Slice(ptr pointer, tagsize int) int { + s := *ptr.toInt64Slice() + n := 0 + for _, v := range s { + n += SizeVarint(uint64(v)) + tagsize + } + return n +} +func sizeVarintS64PackedSlice(ptr pointer, tagsize int) int { + s := *ptr.toInt64Slice() + if len(s) == 0 { + return 0 + } + n := 0 + for _, v := range s { + n += SizeVarint(uint64(v)) + } + return n + SizeVarint(uint64(n)) + tagsize +} +func sizeZigzag32Value(ptr pointer, tagsize int) int { + v := *ptr.toInt32() + return SizeVarint(uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + tagsize +} +func sizeZigzag32ValueNoZero(ptr pointer, tagsize int) int { + v := *ptr.toInt32() + if v == 0 { + return 0 + } + return SizeVarint(uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + tagsize +} +func sizeZigzag32Ptr(ptr pointer, tagsize int) int { + p := ptr.getInt32Ptr() + if p == nil { + return 0 + } + v := *p + return SizeVarint(uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + tagsize +} +func sizeZigzag32Slice(ptr pointer, tagsize int) int { + s := ptr.getInt32Slice() + n := 0 + for _, v := range s { + n += SizeVarint(uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + tagsize + } + return n +} +func sizeZigzag32PackedSlice(ptr pointer, tagsize int) int { + s := ptr.getInt32Slice() + if len(s) == 0 { + return 0 + } + n := 0 + for _, v := range s { + n += SizeVarint(uint64((uint32(v) << 1) ^ uint32((int32(v) >> 31)))) + } + return n + SizeVarint(uint64(n)) + tagsize +} +func sizeZigzag64Value(ptr pointer, tagsize int) int { + v := *ptr.toInt64() + return SizeVarint(uint64(v<<1)^uint64((int64(v)>>63))) + tagsize +} +func sizeZigzag64ValueNoZero(ptr pointer, tagsize int) int { + v := *ptr.toInt64() + if v == 0 { + return 0 + } + return SizeVarint(uint64(v<<1)^uint64((int64(v)>>63))) + tagsize +} +func sizeZigzag64Ptr(ptr pointer, tagsize int) int { + p := *ptr.toInt64Ptr() + if p == nil { + return 0 + } + v := *p + return SizeVarint(uint64(v<<1)^uint64((int64(v)>>63))) + tagsize +} +func sizeZigzag64Slice(ptr pointer, tagsize int) int { + s := *ptr.toInt64Slice() + n := 0 + for _, v := range s { + n += SizeVarint(uint64(v<<1)^uint64((int64(v)>>63))) + tagsize + } + return n +} +func sizeZigzag64PackedSlice(ptr pointer, tagsize int) int { + s := *ptr.toInt64Slice() + if len(s) == 0 { + return 0 + } + n := 0 + for _, v := range s { + n += SizeVarint(uint64(v<<1) ^ uint64((int64(v) >> 63))) + } + return n + SizeVarint(uint64(n)) + tagsize +} +func sizeBoolValue(_ pointer, tagsize int) int { + return 1 + tagsize +} +func sizeBoolValueNoZero(ptr pointer, tagsize int) int { + v := *ptr.toBool() + if !v { + return 0 + } + return 1 + tagsize +} +func sizeBoolPtr(ptr pointer, tagsize int) int { + p := *ptr.toBoolPtr() + if p == nil { + return 0 + } + return 1 + tagsize +} +func sizeBoolSlice(ptr pointer, tagsize int) int { + s := *ptr.toBoolSlice() + return (1 + tagsize) * len(s) +} +func sizeBoolPackedSlice(ptr pointer, tagsize int) int { + s := *ptr.toBoolSlice() + if len(s) == 0 { + return 0 + } + return len(s) + SizeVarint(uint64(len(s))) + tagsize +} +func sizeStringValue(ptr pointer, tagsize int) int { + v := *ptr.toString() + return len(v) + SizeVarint(uint64(len(v))) + tagsize +} +func sizeStringValueNoZero(ptr pointer, tagsize int) int { + v := *ptr.toString() + if v == "" { + return 0 + } + return len(v) + SizeVarint(uint64(len(v))) + tagsize +} +func sizeStringPtr(ptr pointer, tagsize int) int { + p := *ptr.toStringPtr() + if p == nil { + return 0 + } + v := *p + return len(v) + SizeVarint(uint64(len(v))) + tagsize +} +func sizeStringSlice(ptr pointer, tagsize int) int { + s := *ptr.toStringSlice() + n := 0 + for _, v := range s { + n += len(v) + SizeVarint(uint64(len(v))) + tagsize + } + return n +} +func sizeBytes(ptr pointer, tagsize int) int { + v := *ptr.toBytes() + if v == nil { + return 0 + } + return len(v) + SizeVarint(uint64(len(v))) + tagsize +} +func sizeBytes3(ptr pointer, tagsize int) int { + v := *ptr.toBytes() + if len(v) == 0 { + return 0 + } + return len(v) + SizeVarint(uint64(len(v))) + tagsize +} +func sizeBytesOneof(ptr pointer, tagsize int) int { + v := *ptr.toBytes() + return len(v) + SizeVarint(uint64(len(v))) + tagsize +} +func sizeBytesSlice(ptr pointer, tagsize int) int { + s := *ptr.toBytesSlice() + n := 0 + for _, v := range s { + n += len(v) + SizeVarint(uint64(len(v))) + tagsize + } + return n +} + +// appendFixed32 appends an encoded fixed32 to b. +func appendFixed32(b []byte, v uint32) []byte { + b = append(b, + byte(v), + byte(v>>8), + byte(v>>16), + byte(v>>24)) + return b +} + +// appendFixed64 appends an encoded fixed64 to b. +func appendFixed64(b []byte, v uint64) []byte { + b = append(b, + byte(v), + byte(v>>8), + byte(v>>16), + byte(v>>24), + byte(v>>32), + byte(v>>40), + byte(v>>48), + byte(v>>56)) + return b +} + +// appendVarint appends an encoded varint to b. +func appendVarint(b []byte, v uint64) []byte { + // TODO: make 1-byte (maybe 2-byte) case inline-able, once we + // have non-leaf inliner. + switch { + case v < 1<<7: + b = append(b, byte(v)) + case v < 1<<14: + b = append(b, + byte(v&0x7f|0x80), + byte(v>>7)) + case v < 1<<21: + b = append(b, + byte(v&0x7f|0x80), + byte((v>>7)&0x7f|0x80), + byte(v>>14)) + case v < 1<<28: + b = append(b, + byte(v&0x7f|0x80), + byte((v>>7)&0x7f|0x80), + byte((v>>14)&0x7f|0x80), + byte(v>>21)) + case v < 1<<35: + b = append(b, + byte(v&0x7f|0x80), + byte((v>>7)&0x7f|0x80), + byte((v>>14)&0x7f|0x80), + byte((v>>21)&0x7f|0x80), + byte(v>>28)) + case v < 1<<42: + b = append(b, + byte(v&0x7f|0x80), + byte((v>>7)&0x7f|0x80), + byte((v>>14)&0x7f|0x80), + byte((v>>21)&0x7f|0x80), + byte((v>>28)&0x7f|0x80), + byte(v>>35)) + case v < 1<<49: + b = append(b, + byte(v&0x7f|0x80), + byte((v>>7)&0x7f|0x80), + byte((v>>14)&0x7f|0x80), + byte((v>>21)&0x7f|0x80), + byte((v>>28)&0x7f|0x80), + byte((v>>35)&0x7f|0x80), + byte(v>>42)) + case v < 1<<56: + b = append(b, + byte(v&0x7f|0x80), + byte((v>>7)&0x7f|0x80), + byte((v>>14)&0x7f|0x80), + byte((v>>21)&0x7f|0x80), + byte((v>>28)&0x7f|0x80), + byte((v>>35)&0x7f|0x80), + byte((v>>42)&0x7f|0x80), + byte(v>>49)) + case v < 1<<63: + b = append(b, + byte(v&0x7f|0x80), + byte((v>>7)&0x7f|0x80), + byte((v>>14)&0x7f|0x80), + byte((v>>21)&0x7f|0x80), + byte((v>>28)&0x7f|0x80), + byte((v>>35)&0x7f|0x80), + byte((v>>42)&0x7f|0x80), + byte((v>>49)&0x7f|0x80), + byte(v>>56)) + default: + b = append(b, + byte(v&0x7f|0x80), + byte((v>>7)&0x7f|0x80), + byte((v>>14)&0x7f|0x80), + byte((v>>21)&0x7f|0x80), + byte((v>>28)&0x7f|0x80), + byte((v>>35)&0x7f|0x80), + byte((v>>42)&0x7f|0x80), + byte((v>>49)&0x7f|0x80), + byte((v>>56)&0x7f|0x80), + 1) + } + return b +} + +func appendFixed32Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toUint32() + b = appendVarint(b, wiretag) + b = appendFixed32(b, v) + return b, nil +} +func appendFixed32ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toUint32() + if v == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendFixed32(b, v) + return b, nil +} +func appendFixed32Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := *ptr.toUint32Ptr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendFixed32(b, *p) + return b, nil +} +func appendFixed32Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toUint32Slice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendFixed32(b, v) + } + return b, nil +} +func appendFixed32PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toUint32Slice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + b = appendVarint(b, uint64(4*len(s))) + for _, v := range s { + b = appendFixed32(b, v) + } + return b, nil +} +func appendFixedS32Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toInt32() + b = appendVarint(b, wiretag) + b = appendFixed32(b, uint32(v)) + return b, nil +} +func appendFixedS32ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toInt32() + if v == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendFixed32(b, uint32(v)) + return b, nil +} +func appendFixedS32Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := ptr.getInt32Ptr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendFixed32(b, uint32(*p)) + return b, nil +} +func appendFixedS32Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := ptr.getInt32Slice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendFixed32(b, uint32(v)) + } + return b, nil +} +func appendFixedS32PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := ptr.getInt32Slice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + b = appendVarint(b, uint64(4*len(s))) + for _, v := range s { + b = appendFixed32(b, uint32(v)) + } + return b, nil +} +func appendFloat32Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := math.Float32bits(*ptr.toFloat32()) + b = appendVarint(b, wiretag) + b = appendFixed32(b, v) + return b, nil +} +func appendFloat32ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := math.Float32bits(*ptr.toFloat32()) + if v == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendFixed32(b, v) + return b, nil +} +func appendFloat32Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := *ptr.toFloat32Ptr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendFixed32(b, math.Float32bits(*p)) + return b, nil +} +func appendFloat32Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toFloat32Slice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendFixed32(b, math.Float32bits(v)) + } + return b, nil +} +func appendFloat32PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toFloat32Slice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + b = appendVarint(b, uint64(4*len(s))) + for _, v := range s { + b = appendFixed32(b, math.Float32bits(v)) + } + return b, nil +} +func appendFixed64Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toUint64() + b = appendVarint(b, wiretag) + b = appendFixed64(b, v) + return b, nil +} +func appendFixed64ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toUint64() + if v == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendFixed64(b, v) + return b, nil +} +func appendFixed64Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := *ptr.toUint64Ptr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendFixed64(b, *p) + return b, nil +} +func appendFixed64Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toUint64Slice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendFixed64(b, v) + } + return b, nil +} +func appendFixed64PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toUint64Slice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + b = appendVarint(b, uint64(8*len(s))) + for _, v := range s { + b = appendFixed64(b, v) + } + return b, nil +} +func appendFixedS64Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toInt64() + b = appendVarint(b, wiretag) + b = appendFixed64(b, uint64(v)) + return b, nil +} +func appendFixedS64ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toInt64() + if v == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendFixed64(b, uint64(v)) + return b, nil +} +func appendFixedS64Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := *ptr.toInt64Ptr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendFixed64(b, uint64(*p)) + return b, nil +} +func appendFixedS64Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toInt64Slice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendFixed64(b, uint64(v)) + } + return b, nil +} +func appendFixedS64PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toInt64Slice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + b = appendVarint(b, uint64(8*len(s))) + for _, v := range s { + b = appendFixed64(b, uint64(v)) + } + return b, nil +} +func appendFloat64Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := math.Float64bits(*ptr.toFloat64()) + b = appendVarint(b, wiretag) + b = appendFixed64(b, v) + return b, nil +} +func appendFloat64ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := math.Float64bits(*ptr.toFloat64()) + if v == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendFixed64(b, v) + return b, nil +} +func appendFloat64Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := *ptr.toFloat64Ptr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendFixed64(b, math.Float64bits(*p)) + return b, nil +} +func appendFloat64Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toFloat64Slice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendFixed64(b, math.Float64bits(v)) + } + return b, nil +} +func appendFloat64PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toFloat64Slice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + b = appendVarint(b, uint64(8*len(s))) + for _, v := range s { + b = appendFixed64(b, math.Float64bits(v)) + } + return b, nil +} +func appendVarint32Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toUint32() + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(v)) + return b, nil +} +func appendVarint32ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toUint32() + if v == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(v)) + return b, nil +} +func appendVarint32Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := *ptr.toUint32Ptr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(*p)) + return b, nil +} +func appendVarint32Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toUint32Slice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(v)) + } + return b, nil +} +func appendVarint32PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toUint32Slice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + // compute size + n := 0 + for _, v := range s { + n += SizeVarint(uint64(v)) + } + b = appendVarint(b, uint64(n)) + for _, v := range s { + b = appendVarint(b, uint64(v)) + } + return b, nil +} +func appendVarintS32Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toInt32() + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(v)) + return b, nil +} +func appendVarintS32ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toInt32() + if v == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(v)) + return b, nil +} +func appendVarintS32Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := ptr.getInt32Ptr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(*p)) + return b, nil +} +func appendVarintS32Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := ptr.getInt32Slice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(v)) + } + return b, nil +} +func appendVarintS32PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := ptr.getInt32Slice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + // compute size + n := 0 + for _, v := range s { + n += SizeVarint(uint64(v)) + } + b = appendVarint(b, uint64(n)) + for _, v := range s { + b = appendVarint(b, uint64(v)) + } + return b, nil +} +func appendVarint64Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toUint64() + b = appendVarint(b, wiretag) + b = appendVarint(b, v) + return b, nil +} +func appendVarint64ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toUint64() + if v == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendVarint(b, v) + return b, nil +} +func appendVarint64Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := *ptr.toUint64Ptr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendVarint(b, *p) + return b, nil +} +func appendVarint64Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toUint64Slice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendVarint(b, v) + } + return b, nil +} +func appendVarint64PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toUint64Slice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + // compute size + n := 0 + for _, v := range s { + n += SizeVarint(v) + } + b = appendVarint(b, uint64(n)) + for _, v := range s { + b = appendVarint(b, v) + } + return b, nil +} +func appendVarintS64Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toInt64() + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(v)) + return b, nil +} +func appendVarintS64ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toInt64() + if v == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(v)) + return b, nil +} +func appendVarintS64Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := *ptr.toInt64Ptr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(*p)) + return b, nil +} +func appendVarintS64Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toInt64Slice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(v)) + } + return b, nil +} +func appendVarintS64PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toInt64Slice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + // compute size + n := 0 + for _, v := range s { + n += SizeVarint(uint64(v)) + } + b = appendVarint(b, uint64(n)) + for _, v := range s { + b = appendVarint(b, uint64(v)) + } + return b, nil +} +func appendZigzag32Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toInt32() + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + return b, nil +} +func appendZigzag32ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toInt32() + if v == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + return b, nil +} +func appendZigzag32Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := ptr.getInt32Ptr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + v := *p + b = appendVarint(b, uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + return b, nil +} +func appendZigzag32Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := ptr.getInt32Slice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + } + return b, nil +} +func appendZigzag32PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := ptr.getInt32Slice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + // compute size + n := 0 + for _, v := range s { + n += SizeVarint(uint64((uint32(v) << 1) ^ uint32((int32(v) >> 31)))) + } + b = appendVarint(b, uint64(n)) + for _, v := range s { + b = appendVarint(b, uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + } + return b, nil +} +func appendZigzag64Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toInt64() + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(v<<1)^uint64((int64(v)>>63))) + return b, nil +} +func appendZigzag64ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toInt64() + if v == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(v<<1)^uint64((int64(v)>>63))) + return b, nil +} +func appendZigzag64Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := *ptr.toInt64Ptr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + v := *p + b = appendVarint(b, uint64(v<<1)^uint64((int64(v)>>63))) + return b, nil +} +func appendZigzag64Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toInt64Slice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(v<<1)^uint64((int64(v)>>63))) + } + return b, nil +} +func appendZigzag64PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toInt64Slice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + // compute size + n := 0 + for _, v := range s { + n += SizeVarint(uint64(v<<1) ^ uint64((int64(v) >> 63))) + } + b = appendVarint(b, uint64(n)) + for _, v := range s { + b = appendVarint(b, uint64(v<<1)^uint64((int64(v)>>63))) + } + return b, nil +} +func appendBoolValue(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toBool() + b = appendVarint(b, wiretag) + if v { + b = append(b, 1) + } else { + b = append(b, 0) + } + return b, nil +} +func appendBoolValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toBool() + if !v { + return b, nil + } + b = appendVarint(b, wiretag) + b = append(b, 1) + return b, nil +} + +func appendBoolPtr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := *ptr.toBoolPtr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + if *p { + b = append(b, 1) + } else { + b = append(b, 0) + } + return b, nil +} +func appendBoolSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toBoolSlice() + for _, v := range s { + b = appendVarint(b, wiretag) + if v { + b = append(b, 1) + } else { + b = append(b, 0) + } + } + return b, nil +} +func appendBoolPackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toBoolSlice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + b = appendVarint(b, uint64(len(s))) + for _, v := range s { + if v { + b = append(b, 1) + } else { + b = append(b, 0) + } + } + return b, nil +} +func appendStringValue(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toString() + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(v))) + b = append(b, v...) + return b, nil +} +func appendStringValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toString() + if v == "" { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(v))) + b = append(b, v...) + return b, nil +} +func appendStringPtr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := *ptr.toStringPtr() + if p == nil { + return b, nil + } + v := *p + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(v))) + b = append(b, v...) + return b, nil +} +func appendStringSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toStringSlice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(v))) + b = append(b, v...) + } + return b, nil +} +func appendUTF8StringValue(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + var invalidUTF8 bool + v := *ptr.toString() + if !utf8.ValidString(v) { + invalidUTF8 = true + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(v))) + b = append(b, v...) + if invalidUTF8 { + return b, errInvalidUTF8 + } + return b, nil +} +func appendUTF8StringValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + var invalidUTF8 bool + v := *ptr.toString() + if v == "" { + return b, nil + } + if !utf8.ValidString(v) { + invalidUTF8 = true + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(v))) + b = append(b, v...) + if invalidUTF8 { + return b, errInvalidUTF8 + } + return b, nil +} +func appendUTF8StringPtr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + var invalidUTF8 bool + p := *ptr.toStringPtr() + if p == nil { + return b, nil + } + v := *p + if !utf8.ValidString(v) { + invalidUTF8 = true + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(v))) + b = append(b, v...) + if invalidUTF8 { + return b, errInvalidUTF8 + } + return b, nil +} +func appendUTF8StringSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + var invalidUTF8 bool + s := *ptr.toStringSlice() + for _, v := range s { + if !utf8.ValidString(v) { + invalidUTF8 = true + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(v))) + b = append(b, v...) + } + if invalidUTF8 { + return b, errInvalidUTF8 + } + return b, nil +} +func appendBytes(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toBytes() + if v == nil { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(v))) + b = append(b, v...) + return b, nil +} +func appendBytes3(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toBytes() + if len(v) == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(v))) + b = append(b, v...) + return b, nil +} +func appendBytesOneof(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toBytes() + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(v))) + b = append(b, v...) + return b, nil +} +func appendBytesSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toBytesSlice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(v))) + b = append(b, v...) + } + return b, nil +} + +// makeGroupMarshaler returns the sizer and marshaler for a group. +// u is the marshal info of the underlying message. +func makeGroupMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + p := ptr.getPointer() + if p.isNil() { + return 0 + } + return u.size(p) + 2*tagsize + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + p := ptr.getPointer() + if p.isNil() { + return b, nil + } + var err error + b = appendVarint(b, wiretag) // start group + b, err = u.marshal(b, p, deterministic) + b = appendVarint(b, wiretag+(WireEndGroup-WireStartGroup)) // end group + return b, err + } +} + +// makeGroupSliceMarshaler returns the sizer and marshaler for a group slice. +// u is the marshal info of the underlying message. +func makeGroupSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getPointerSlice() + n := 0 + for _, v := range s { + if v.isNil() { + continue + } + n += u.size(v) + 2*tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getPointerSlice() + var err error + var nerr nonFatal + for _, v := range s { + if v.isNil() { + return b, errRepeatedHasNil + } + b = appendVarint(b, wiretag) // start group + b, err = u.marshal(b, v, deterministic) + b = appendVarint(b, wiretag+(WireEndGroup-WireStartGroup)) // end group + if !nerr.Merge(err) { + if err == ErrNil { + err = errRepeatedHasNil + } + return b, err + } + } + return b, nerr.E + } +} + +// makeMessageMarshaler returns the sizer and marshaler for a message field. +// u is the marshal info of the message. +func makeMessageMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + p := ptr.getPointer() + if p.isNil() { + return 0 + } + siz := u.size(p) + return siz + SizeVarint(uint64(siz)) + tagsize + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + p := ptr.getPointer() + if p.isNil() { + return b, nil + } + b = appendVarint(b, wiretag) + siz := u.cachedsize(p) + b = appendVarint(b, uint64(siz)) + return u.marshal(b, p, deterministic) + } +} + +// makeMessageSliceMarshaler returns the sizer and marshaler for a message slice. +// u is the marshal info of the message. +func makeMessageSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getPointerSlice() + n := 0 + for _, v := range s { + if v.isNil() { + continue + } + siz := u.size(v) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getPointerSlice() + var err error + var nerr nonFatal + for _, v := range s { + if v.isNil() { + return b, errRepeatedHasNil + } + b = appendVarint(b, wiretag) + siz := u.cachedsize(v) + b = appendVarint(b, uint64(siz)) + b, err = u.marshal(b, v, deterministic) + + if !nerr.Merge(err) { + if err == ErrNil { + err = errRepeatedHasNil + } + return b, err + } + } + return b, nerr.E + } +} + +// makeMapMarshaler returns the sizer and marshaler for a map field. +// f is the pointer to the reflect data structure of the field. +func makeMapMarshaler(f *reflect.StructField) (sizer, marshaler) { + // figure out key and value type + t := f.Type + keyType := t.Key() + valType := t.Elem() + keyTags := strings.Split(f.Tag.Get("protobuf_key"), ",") + valTags := strings.Split(f.Tag.Get("protobuf_val"), ",") + keySizer, keyMarshaler := typeMarshaler(keyType, keyTags, false, false) // don't omit zero value in map + valSizer, valMarshaler := typeMarshaler(valType, valTags, false, false) // don't omit zero value in map + keyWireTag := 1<<3 | wiretype(keyTags[0]) + valWireTag := 2<<3 | wiretype(valTags[0]) + + // We create an interface to get the addresses of the map key and value. + // If value is pointer-typed, the interface is a direct interface, the + // idata itself is the value. Otherwise, the idata is the pointer to the + // value. + // Key cannot be pointer-typed. + valIsPtr := valType.Kind() == reflect.Ptr + + // If value is a message with nested maps, calling + // valSizer in marshal may be quadratic. We should use + // cached version in marshal (but not in size). + // If value is not message type, we don't have size cache, + // but it cannot be nested either. Just use valSizer. + valCachedSizer := valSizer + if valIsPtr && valType.Elem().Kind() == reflect.Struct { + u := getMarshalInfo(valType.Elem()) + valCachedSizer = func(ptr pointer, tagsize int) int { + // Same as message sizer, but use cache. + p := ptr.getPointer() + if p.isNil() { + return 0 + } + siz := u.cachedsize(p) + return siz + SizeVarint(uint64(siz)) + tagsize + } + } + return func(ptr pointer, tagsize int) int { + m := ptr.asPointerTo(t).Elem() // the map + n := 0 + for _, k := range m.MapKeys() { + ki := k.Interface() + vi := m.MapIndex(k).Interface() + kaddr := toAddrPointer(&ki, false) // pointer to key + vaddr := toAddrPointer(&vi, valIsPtr) // pointer to value + siz := keySizer(kaddr, 1) + valSizer(vaddr, 1) // tag of key = 1 (size=1), tag of val = 2 (size=1) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, tag uint64, deterministic bool) ([]byte, error) { + m := ptr.asPointerTo(t).Elem() // the map + var err error + keys := m.MapKeys() + if len(keys) > 1 && deterministic { + sort.Sort(mapKeys(keys)) + } + + var nerr nonFatal + for _, k := range keys { + ki := k.Interface() + vi := m.MapIndex(k).Interface() + kaddr := toAddrPointer(&ki, false) // pointer to key + vaddr := toAddrPointer(&vi, valIsPtr) // pointer to value + b = appendVarint(b, tag) + siz := keySizer(kaddr, 1) + valCachedSizer(vaddr, 1) // tag of key = 1 (size=1), tag of val = 2 (size=1) + b = appendVarint(b, uint64(siz)) + b, err = keyMarshaler(b, kaddr, keyWireTag, deterministic) + if !nerr.Merge(err) { + return b, err + } + b, err = valMarshaler(b, vaddr, valWireTag, deterministic) + if err != ErrNil && !nerr.Merge(err) { // allow nil value in map + return b, err + } + } + return b, nerr.E + } +} + +// makeOneOfMarshaler returns the sizer and marshaler for a oneof field. +// fi is the marshal info of the field. +// f is the pointer to the reflect data structure of the field. +func makeOneOfMarshaler(fi *marshalFieldInfo, f *reflect.StructField) (sizer, marshaler) { + // Oneof field is an interface. We need to get the actual data type on the fly. + t := f.Type + return func(ptr pointer, _ int) int { + p := ptr.getInterfacePointer() + if p.isNil() { + return 0 + } + v := ptr.asPointerTo(t).Elem().Elem().Elem() // *interface -> interface -> *struct -> struct + telem := v.Type() + e := fi.oneofElems[telem] + return e.sizer(p, e.tagsize) + }, + func(b []byte, ptr pointer, _ uint64, deterministic bool) ([]byte, error) { + p := ptr.getInterfacePointer() + if p.isNil() { + return b, nil + } + v := ptr.asPointerTo(t).Elem().Elem().Elem() // *interface -> interface -> *struct -> struct + telem := v.Type() + if telem.Field(0).Type.Kind() == reflect.Ptr && p.getPointer().isNil() { + return b, errOneofHasNil + } + e := fi.oneofElems[telem] + return e.marshaler(b, p, e.wiretag, deterministic) + } +} + +// sizeExtensions computes the size of encoded data for a XXX_InternalExtensions field. +func (u *marshalInfo) sizeExtensions(ext *XXX_InternalExtensions) int { + m, mu := ext.extensionsRead() + if m == nil { + return 0 + } + mu.Lock() + + n := 0 + for _, e := range m { + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + n += len(e.enc) + continue + } + + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + ei := u.getExtElemInfo(e.desc) + v := e.value + p := toAddrPointer(&v, ei.isptr) + n += ei.sizer(p, ei.tagsize) + } + mu.Unlock() + return n +} + +// appendExtensions marshals a XXX_InternalExtensions field to the end of byte slice b. +func (u *marshalInfo) appendExtensions(b []byte, ext *XXX_InternalExtensions, deterministic bool) ([]byte, error) { + m, mu := ext.extensionsRead() + if m == nil { + return b, nil + } + mu.Lock() + defer mu.Unlock() + + var err error + var nerr nonFatal + + // Fast-path for common cases: zero or one extensions. + // Don't bother sorting the keys. + if len(m) <= 1 { + for _, e := range m { + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + b = append(b, e.enc...) + continue + } + + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + + ei := u.getExtElemInfo(e.desc) + v := e.value + p := toAddrPointer(&v, ei.isptr) + b, err = ei.marshaler(b, p, ei.wiretag, deterministic) + if !nerr.Merge(err) { + return b, err + } + } + return b, nerr.E + } + + // Sort the keys to provide a deterministic encoding. + // Not sure this is required, but the old code does it. + keys := make([]int, 0, len(m)) + for k := range m { + keys = append(keys, int(k)) + } + sort.Ints(keys) + + for _, k := range keys { + e := m[int32(k)] + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + b = append(b, e.enc...) + continue + } + + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + + ei := u.getExtElemInfo(e.desc) + v := e.value + p := toAddrPointer(&v, ei.isptr) + b, err = ei.marshaler(b, p, ei.wiretag, deterministic) + if !nerr.Merge(err) { + return b, err + } + } + return b, nerr.E +} + +// message set format is: +// message MessageSet { +// repeated group Item = 1 { +// required int32 type_id = 2; +// required string message = 3; +// }; +// } + +// sizeMessageSet computes the size of encoded data for a XXX_InternalExtensions field +// in message set format (above). +func (u *marshalInfo) sizeMessageSet(ext *XXX_InternalExtensions) int { + m, mu := ext.extensionsRead() + if m == nil { + return 0 + } + mu.Lock() + + n := 0 + for id, e := range m { + n += 2 // start group, end group. tag = 1 (size=1) + n += SizeVarint(uint64(id)) + 1 // type_id, tag = 2 (size=1) + + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + msgWithLen := skipVarint(e.enc) // skip old tag, but leave the length varint + siz := len(msgWithLen) + n += siz + 1 // message, tag = 3 (size=1) + continue + } + + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + + ei := u.getExtElemInfo(e.desc) + v := e.value + p := toAddrPointer(&v, ei.isptr) + n += ei.sizer(p, 1) // message, tag = 3 (size=1) + } + mu.Unlock() + return n +} + +// appendMessageSet marshals a XXX_InternalExtensions field in message set format (above) +// to the end of byte slice b. +func (u *marshalInfo) appendMessageSet(b []byte, ext *XXX_InternalExtensions, deterministic bool) ([]byte, error) { + m, mu := ext.extensionsRead() + if m == nil { + return b, nil + } + mu.Lock() + defer mu.Unlock() + + var err error + var nerr nonFatal + + // Fast-path for common cases: zero or one extensions. + // Don't bother sorting the keys. + if len(m) <= 1 { + for id, e := range m { + b = append(b, 1<<3|WireStartGroup) + b = append(b, 2<<3|WireVarint) + b = appendVarint(b, uint64(id)) + + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + msgWithLen := skipVarint(e.enc) // skip old tag, but leave the length varint + b = append(b, 3<<3|WireBytes) + b = append(b, msgWithLen...) + b = append(b, 1<<3|WireEndGroup) + continue + } + + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + + ei := u.getExtElemInfo(e.desc) + v := e.value + p := toAddrPointer(&v, ei.isptr) + b, err = ei.marshaler(b, p, 3<<3|WireBytes, deterministic) + if !nerr.Merge(err) { + return b, err + } + b = append(b, 1<<3|WireEndGroup) + } + return b, nerr.E + } + + // Sort the keys to provide a deterministic encoding. + keys := make([]int, 0, len(m)) + for k := range m { + keys = append(keys, int(k)) + } + sort.Ints(keys) + + for _, id := range keys { + e := m[int32(id)] + b = append(b, 1<<3|WireStartGroup) + b = append(b, 2<<3|WireVarint) + b = appendVarint(b, uint64(id)) + + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + msgWithLen := skipVarint(e.enc) // skip old tag, but leave the length varint + b = append(b, 3<<3|WireBytes) + b = append(b, msgWithLen...) + b = append(b, 1<<3|WireEndGroup) + continue + } + + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + + ei := u.getExtElemInfo(e.desc) + v := e.value + p := toAddrPointer(&v, ei.isptr) + b, err = ei.marshaler(b, p, 3<<3|WireBytes, deterministic) + b = append(b, 1<<3|WireEndGroup) + if !nerr.Merge(err) { + return b, err + } + } + return b, nerr.E +} + +// sizeV1Extensions computes the size of encoded data for a V1-API extension field. +func (u *marshalInfo) sizeV1Extensions(m map[int32]Extension) int { + if m == nil { + return 0 + } + + n := 0 + for _, e := range m { + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + n += len(e.enc) + continue + } + + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + + ei := u.getExtElemInfo(e.desc) + v := e.value + p := toAddrPointer(&v, ei.isptr) + n += ei.sizer(p, ei.tagsize) + } + return n +} + +// appendV1Extensions marshals a V1-API extension field to the end of byte slice b. +func (u *marshalInfo) appendV1Extensions(b []byte, m map[int32]Extension, deterministic bool) ([]byte, error) { + if m == nil { + return b, nil + } + + // Sort the keys to provide a deterministic encoding. + keys := make([]int, 0, len(m)) + for k := range m { + keys = append(keys, int(k)) + } + sort.Ints(keys) + + var err error + var nerr nonFatal + for _, k := range keys { + e := m[int32(k)] + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + b = append(b, e.enc...) + continue + } + + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + + ei := u.getExtElemInfo(e.desc) + v := e.value + p := toAddrPointer(&v, ei.isptr) + b, err = ei.marshaler(b, p, ei.wiretag, deterministic) + if !nerr.Merge(err) { + return b, err + } + } + return b, nerr.E +} + +// newMarshaler is the interface representing objects that can marshal themselves. +// +// This exists to support protoc-gen-go generated messages. +// The proto package will stop type-asserting to this interface in the future. +// +// DO NOT DEPEND ON THIS. +type newMarshaler interface { + XXX_Size() int + XXX_Marshal(b []byte, deterministic bool) ([]byte, error) +} + +// Size returns the encoded size of a protocol buffer message. +// This is the main entry point. +func Size(pb Message) int { + if m, ok := pb.(newMarshaler); ok { + return m.XXX_Size() + } + if m, ok := pb.(Marshaler); ok { + // If the message can marshal itself, let it do it, for compatibility. + // NOTE: This is not efficient. + b, _ := m.Marshal() + return len(b) + } + // in case somehow we didn't generate the wrapper + if pb == nil { + return 0 + } + var info InternalMessageInfo + return info.Size(pb) +} + +// Marshal takes a protocol buffer message +// and encodes it into the wire format, returning the data. +// This is the main entry point. +func Marshal(pb Message) ([]byte, error) { + if m, ok := pb.(newMarshaler); ok { + siz := m.XXX_Size() + b := make([]byte, 0, siz) + return m.XXX_Marshal(b, false) + } + if m, ok := pb.(Marshaler); ok { + // If the message can marshal itself, let it do it, for compatibility. + // NOTE: This is not efficient. + return m.Marshal() + } + // in case somehow we didn't generate the wrapper + if pb == nil { + return nil, ErrNil + } + var info InternalMessageInfo + siz := info.Size(pb) + b := make([]byte, 0, siz) + return info.Marshal(b, pb, false) +} + +// Marshal takes a protocol buffer message +// and encodes it into the wire format, writing the result to the +// Buffer. +// This is an alternative entry point. It is not necessary to use +// a Buffer for most applications. +func (p *Buffer) Marshal(pb Message) error { + var err error + if m, ok := pb.(newMarshaler); ok { + siz := m.XXX_Size() + p.grow(siz) // make sure buf has enough capacity + p.buf, err = m.XXX_Marshal(p.buf, p.deterministic) + return err + } + if m, ok := pb.(Marshaler); ok { + // If the message can marshal itself, let it do it, for compatibility. + // NOTE: This is not efficient. + b, err := m.Marshal() + p.buf = append(p.buf, b...) + return err + } + // in case somehow we didn't generate the wrapper + if pb == nil { + return ErrNil + } + var info InternalMessageInfo + siz := info.Size(pb) + p.grow(siz) // make sure buf has enough capacity + p.buf, err = info.Marshal(p.buf, pb, p.deterministic) + return err +} + +// grow grows the buffer's capacity, if necessary, to guarantee space for +// another n bytes. After grow(n), at least n bytes can be written to the +// buffer without another allocation. +func (p *Buffer) grow(n int) { + need := len(p.buf) + n + if need <= cap(p.buf) { + return + } + newCap := len(p.buf) * 2 + if newCap < need { + newCap = need + } + p.buf = append(make([]byte, 0, newCap), p.buf...) +} diff --git a/vendor/github.com/golang/protobuf/proto/table_merge.go b/vendor/github.com/golang/protobuf/proto/table_merge.go new file mode 100644 index 0000000..5525def --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/table_merge.go @@ -0,0 +1,654 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2016 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +import ( + "fmt" + "reflect" + "strings" + "sync" + "sync/atomic" +) + +// Merge merges the src message into dst. +// This assumes that dst and src of the same type and are non-nil. +func (a *InternalMessageInfo) Merge(dst, src Message) { + mi := atomicLoadMergeInfo(&a.merge) + if mi == nil { + mi = getMergeInfo(reflect.TypeOf(dst).Elem()) + atomicStoreMergeInfo(&a.merge, mi) + } + mi.merge(toPointer(&dst), toPointer(&src)) +} + +type mergeInfo struct { + typ reflect.Type + + initialized int32 // 0: only typ is valid, 1: everything is valid + lock sync.Mutex + + fields []mergeFieldInfo + unrecognized field // Offset of XXX_unrecognized +} + +type mergeFieldInfo struct { + field field // Offset of field, guaranteed to be valid + + // isPointer reports whether the value in the field is a pointer. + // This is true for the following situations: + // * Pointer to struct + // * Pointer to basic type (proto2 only) + // * Slice (first value in slice header is a pointer) + // * String (first value in string header is a pointer) + isPointer bool + + // basicWidth reports the width of the field assuming that it is directly + // embedded in the struct (as is the case for basic types in proto3). + // The possible values are: + // 0: invalid + // 1: bool + // 4: int32, uint32, float32 + // 8: int64, uint64, float64 + basicWidth int + + // Where dst and src are pointers to the types being merged. + merge func(dst, src pointer) +} + +var ( + mergeInfoMap = map[reflect.Type]*mergeInfo{} + mergeInfoLock sync.Mutex +) + +func getMergeInfo(t reflect.Type) *mergeInfo { + mergeInfoLock.Lock() + defer mergeInfoLock.Unlock() + mi := mergeInfoMap[t] + if mi == nil { + mi = &mergeInfo{typ: t} + mergeInfoMap[t] = mi + } + return mi +} + +// merge merges src into dst assuming they are both of type *mi.typ. +func (mi *mergeInfo) merge(dst, src pointer) { + if dst.isNil() { + panic("proto: nil destination") + } + if src.isNil() { + return // Nothing to do. + } + + if atomic.LoadInt32(&mi.initialized) == 0 { + mi.computeMergeInfo() + } + + for _, fi := range mi.fields { + sfp := src.offset(fi.field) + + // As an optimization, we can avoid the merge function call cost + // if we know for sure that the source will have no effect + // by checking if it is the zero value. + if unsafeAllowed { + if fi.isPointer && sfp.getPointer().isNil() { // Could be slice or string + continue + } + if fi.basicWidth > 0 { + switch { + case fi.basicWidth == 1 && !*sfp.toBool(): + continue + case fi.basicWidth == 4 && *sfp.toUint32() == 0: + continue + case fi.basicWidth == 8 && *sfp.toUint64() == 0: + continue + } + } + } + + dfp := dst.offset(fi.field) + fi.merge(dfp, sfp) + } + + // TODO: Make this faster? + out := dst.asPointerTo(mi.typ).Elem() + in := src.asPointerTo(mi.typ).Elem() + if emIn, err := extendable(in.Addr().Interface()); err == nil { + emOut, _ := extendable(out.Addr().Interface()) + mIn, muIn := emIn.extensionsRead() + if mIn != nil { + mOut := emOut.extensionsWrite() + muIn.Lock() + mergeExtension(mOut, mIn) + muIn.Unlock() + } + } + + if mi.unrecognized.IsValid() { + if b := *src.offset(mi.unrecognized).toBytes(); len(b) > 0 { + *dst.offset(mi.unrecognized).toBytes() = append([]byte(nil), b...) + } + } +} + +func (mi *mergeInfo) computeMergeInfo() { + mi.lock.Lock() + defer mi.lock.Unlock() + if mi.initialized != 0 { + return + } + t := mi.typ + n := t.NumField() + + props := GetProperties(t) + for i := 0; i < n; i++ { + f := t.Field(i) + if strings.HasPrefix(f.Name, "XXX_") { + continue + } + + mfi := mergeFieldInfo{field: toField(&f)} + tf := f.Type + + // As an optimization, we can avoid the merge function call cost + // if we know for sure that the source will have no effect + // by checking if it is the zero value. + if unsafeAllowed { + switch tf.Kind() { + case reflect.Ptr, reflect.Slice, reflect.String: + // As a special case, we assume slices and strings are pointers + // since we know that the first field in the SliceSlice or + // StringHeader is a data pointer. + mfi.isPointer = true + case reflect.Bool: + mfi.basicWidth = 1 + case reflect.Int32, reflect.Uint32, reflect.Float32: + mfi.basicWidth = 4 + case reflect.Int64, reflect.Uint64, reflect.Float64: + mfi.basicWidth = 8 + } + } + + // Unwrap tf to get at its most basic type. + var isPointer, isSlice bool + if tf.Kind() == reflect.Slice && tf.Elem().Kind() != reflect.Uint8 { + isSlice = true + tf = tf.Elem() + } + if tf.Kind() == reflect.Ptr { + isPointer = true + tf = tf.Elem() + } + if isPointer && isSlice && tf.Kind() != reflect.Struct { + panic("both pointer and slice for basic type in " + tf.Name()) + } + + switch tf.Kind() { + case reflect.Int32: + switch { + case isSlice: // E.g., []int32 + mfi.merge = func(dst, src pointer) { + // NOTE: toInt32Slice is not defined (see pointer_reflect.go). + /* + sfsp := src.toInt32Slice() + if *sfsp != nil { + dfsp := dst.toInt32Slice() + *dfsp = append(*dfsp, *sfsp...) + if *dfsp == nil { + *dfsp = []int64{} + } + } + */ + sfs := src.getInt32Slice() + if sfs != nil { + dfs := dst.getInt32Slice() + dfs = append(dfs, sfs...) + if dfs == nil { + dfs = []int32{} + } + dst.setInt32Slice(dfs) + } + } + case isPointer: // E.g., *int32 + mfi.merge = func(dst, src pointer) { + // NOTE: toInt32Ptr is not defined (see pointer_reflect.go). + /* + sfpp := src.toInt32Ptr() + if *sfpp != nil { + dfpp := dst.toInt32Ptr() + if *dfpp == nil { + *dfpp = Int32(**sfpp) + } else { + **dfpp = **sfpp + } + } + */ + sfp := src.getInt32Ptr() + if sfp != nil { + dfp := dst.getInt32Ptr() + if dfp == nil { + dst.setInt32Ptr(*sfp) + } else { + *dfp = *sfp + } + } + } + default: // E.g., int32 + mfi.merge = func(dst, src pointer) { + if v := *src.toInt32(); v != 0 { + *dst.toInt32() = v + } + } + } + case reflect.Int64: + switch { + case isSlice: // E.g., []int64 + mfi.merge = func(dst, src pointer) { + sfsp := src.toInt64Slice() + if *sfsp != nil { + dfsp := dst.toInt64Slice() + *dfsp = append(*dfsp, *sfsp...) + if *dfsp == nil { + *dfsp = []int64{} + } + } + } + case isPointer: // E.g., *int64 + mfi.merge = func(dst, src pointer) { + sfpp := src.toInt64Ptr() + if *sfpp != nil { + dfpp := dst.toInt64Ptr() + if *dfpp == nil { + *dfpp = Int64(**sfpp) + } else { + **dfpp = **sfpp + } + } + } + default: // E.g., int64 + mfi.merge = func(dst, src pointer) { + if v := *src.toInt64(); v != 0 { + *dst.toInt64() = v + } + } + } + case reflect.Uint32: + switch { + case isSlice: // E.g., []uint32 + mfi.merge = func(dst, src pointer) { + sfsp := src.toUint32Slice() + if *sfsp != nil { + dfsp := dst.toUint32Slice() + *dfsp = append(*dfsp, *sfsp...) + if *dfsp == nil { + *dfsp = []uint32{} + } + } + } + case isPointer: // E.g., *uint32 + mfi.merge = func(dst, src pointer) { + sfpp := src.toUint32Ptr() + if *sfpp != nil { + dfpp := dst.toUint32Ptr() + if *dfpp == nil { + *dfpp = Uint32(**sfpp) + } else { + **dfpp = **sfpp + } + } + } + default: // E.g., uint32 + mfi.merge = func(dst, src pointer) { + if v := *src.toUint32(); v != 0 { + *dst.toUint32() = v + } + } + } + case reflect.Uint64: + switch { + case isSlice: // E.g., []uint64 + mfi.merge = func(dst, src pointer) { + sfsp := src.toUint64Slice() + if *sfsp != nil { + dfsp := dst.toUint64Slice() + *dfsp = append(*dfsp, *sfsp...) + if *dfsp == nil { + *dfsp = []uint64{} + } + } + } + case isPointer: // E.g., *uint64 + mfi.merge = func(dst, src pointer) { + sfpp := src.toUint64Ptr() + if *sfpp != nil { + dfpp := dst.toUint64Ptr() + if *dfpp == nil { + *dfpp = Uint64(**sfpp) + } else { + **dfpp = **sfpp + } + } + } + default: // E.g., uint64 + mfi.merge = func(dst, src pointer) { + if v := *src.toUint64(); v != 0 { + *dst.toUint64() = v + } + } + } + case reflect.Float32: + switch { + case isSlice: // E.g., []float32 + mfi.merge = func(dst, src pointer) { + sfsp := src.toFloat32Slice() + if *sfsp != nil { + dfsp := dst.toFloat32Slice() + *dfsp = append(*dfsp, *sfsp...) + if *dfsp == nil { + *dfsp = []float32{} + } + } + } + case isPointer: // E.g., *float32 + mfi.merge = func(dst, src pointer) { + sfpp := src.toFloat32Ptr() + if *sfpp != nil { + dfpp := dst.toFloat32Ptr() + if *dfpp == nil { + *dfpp = Float32(**sfpp) + } else { + **dfpp = **sfpp + } + } + } + default: // E.g., float32 + mfi.merge = func(dst, src pointer) { + if v := *src.toFloat32(); v != 0 { + *dst.toFloat32() = v + } + } + } + case reflect.Float64: + switch { + case isSlice: // E.g., []float64 + mfi.merge = func(dst, src pointer) { + sfsp := src.toFloat64Slice() + if *sfsp != nil { + dfsp := dst.toFloat64Slice() + *dfsp = append(*dfsp, *sfsp...) + if *dfsp == nil { + *dfsp = []float64{} + } + } + } + case isPointer: // E.g., *float64 + mfi.merge = func(dst, src pointer) { + sfpp := src.toFloat64Ptr() + if *sfpp != nil { + dfpp := dst.toFloat64Ptr() + if *dfpp == nil { + *dfpp = Float64(**sfpp) + } else { + **dfpp = **sfpp + } + } + } + default: // E.g., float64 + mfi.merge = func(dst, src pointer) { + if v := *src.toFloat64(); v != 0 { + *dst.toFloat64() = v + } + } + } + case reflect.Bool: + switch { + case isSlice: // E.g., []bool + mfi.merge = func(dst, src pointer) { + sfsp := src.toBoolSlice() + if *sfsp != nil { + dfsp := dst.toBoolSlice() + *dfsp = append(*dfsp, *sfsp...) + if *dfsp == nil { + *dfsp = []bool{} + } + } + } + case isPointer: // E.g., *bool + mfi.merge = func(dst, src pointer) { + sfpp := src.toBoolPtr() + if *sfpp != nil { + dfpp := dst.toBoolPtr() + if *dfpp == nil { + *dfpp = Bool(**sfpp) + } else { + **dfpp = **sfpp + } + } + } + default: // E.g., bool + mfi.merge = func(dst, src pointer) { + if v := *src.toBool(); v { + *dst.toBool() = v + } + } + } + case reflect.String: + switch { + case isSlice: // E.g., []string + mfi.merge = func(dst, src pointer) { + sfsp := src.toStringSlice() + if *sfsp != nil { + dfsp := dst.toStringSlice() + *dfsp = append(*dfsp, *sfsp...) + if *dfsp == nil { + *dfsp = []string{} + } + } + } + case isPointer: // E.g., *string + mfi.merge = func(dst, src pointer) { + sfpp := src.toStringPtr() + if *sfpp != nil { + dfpp := dst.toStringPtr() + if *dfpp == nil { + *dfpp = String(**sfpp) + } else { + **dfpp = **sfpp + } + } + } + default: // E.g., string + mfi.merge = func(dst, src pointer) { + if v := *src.toString(); v != "" { + *dst.toString() = v + } + } + } + case reflect.Slice: + isProto3 := props.Prop[i].proto3 + switch { + case isPointer: + panic("bad pointer in byte slice case in " + tf.Name()) + case tf.Elem().Kind() != reflect.Uint8: + panic("bad element kind in byte slice case in " + tf.Name()) + case isSlice: // E.g., [][]byte + mfi.merge = func(dst, src pointer) { + sbsp := src.toBytesSlice() + if *sbsp != nil { + dbsp := dst.toBytesSlice() + for _, sb := range *sbsp { + if sb == nil { + *dbsp = append(*dbsp, nil) + } else { + *dbsp = append(*dbsp, append([]byte{}, sb...)) + } + } + if *dbsp == nil { + *dbsp = [][]byte{} + } + } + } + default: // E.g., []byte + mfi.merge = func(dst, src pointer) { + sbp := src.toBytes() + if *sbp != nil { + dbp := dst.toBytes() + if !isProto3 || len(*sbp) > 0 { + *dbp = append([]byte{}, *sbp...) + } + } + } + } + case reflect.Struct: + switch { + case !isPointer: + panic(fmt.Sprintf("message field %s without pointer", tf)) + case isSlice: // E.g., []*pb.T + mi := getMergeInfo(tf) + mfi.merge = func(dst, src pointer) { + sps := src.getPointerSlice() + if sps != nil { + dps := dst.getPointerSlice() + for _, sp := range sps { + var dp pointer + if !sp.isNil() { + dp = valToPointer(reflect.New(tf)) + mi.merge(dp, sp) + } + dps = append(dps, dp) + } + if dps == nil { + dps = []pointer{} + } + dst.setPointerSlice(dps) + } + } + default: // E.g., *pb.T + mi := getMergeInfo(tf) + mfi.merge = func(dst, src pointer) { + sp := src.getPointer() + if !sp.isNil() { + dp := dst.getPointer() + if dp.isNil() { + dp = valToPointer(reflect.New(tf)) + dst.setPointer(dp) + } + mi.merge(dp, sp) + } + } + } + case reflect.Map: + switch { + case isPointer || isSlice: + panic("bad pointer or slice in map case in " + tf.Name()) + default: // E.g., map[K]V + mfi.merge = func(dst, src pointer) { + sm := src.asPointerTo(tf).Elem() + if sm.Len() == 0 { + return + } + dm := dst.asPointerTo(tf).Elem() + if dm.IsNil() { + dm.Set(reflect.MakeMap(tf)) + } + + switch tf.Elem().Kind() { + case reflect.Ptr: // Proto struct (e.g., *T) + for _, key := range sm.MapKeys() { + val := sm.MapIndex(key) + val = reflect.ValueOf(Clone(val.Interface().(Message))) + dm.SetMapIndex(key, val) + } + case reflect.Slice: // E.g. Bytes type (e.g., []byte) + for _, key := range sm.MapKeys() { + val := sm.MapIndex(key) + val = reflect.ValueOf(append([]byte{}, val.Bytes()...)) + dm.SetMapIndex(key, val) + } + default: // Basic type (e.g., string) + for _, key := range sm.MapKeys() { + val := sm.MapIndex(key) + dm.SetMapIndex(key, val) + } + } + } + } + case reflect.Interface: + // Must be oneof field. + switch { + case isPointer || isSlice: + panic("bad pointer or slice in interface case in " + tf.Name()) + default: // E.g., interface{} + // TODO: Make this faster? + mfi.merge = func(dst, src pointer) { + su := src.asPointerTo(tf).Elem() + if !su.IsNil() { + du := dst.asPointerTo(tf).Elem() + typ := su.Elem().Type() + if du.IsNil() || du.Elem().Type() != typ { + du.Set(reflect.New(typ.Elem())) // Initialize interface if empty + } + sv := su.Elem().Elem().Field(0) + if sv.Kind() == reflect.Ptr && sv.IsNil() { + return + } + dv := du.Elem().Elem().Field(0) + if dv.Kind() == reflect.Ptr && dv.IsNil() { + dv.Set(reflect.New(sv.Type().Elem())) // Initialize proto message if empty + } + switch sv.Type().Kind() { + case reflect.Ptr: // Proto struct (e.g., *T) + Merge(dv.Interface().(Message), sv.Interface().(Message)) + case reflect.Slice: // E.g. Bytes type (e.g., []byte) + dv.Set(reflect.ValueOf(append([]byte{}, sv.Bytes()...))) + default: // Basic type (e.g., string) + dv.Set(sv) + } + } + } + } + default: + panic(fmt.Sprintf("merger not found for type:%s", tf)) + } + mi.fields = append(mi.fields, mfi) + } + + mi.unrecognized = invalidField + if f, ok := t.FieldByName("XXX_unrecognized"); ok { + if f.Type != reflect.TypeOf([]byte{}) { + panic("expected XXX_unrecognized to be of type []byte") + } + mi.unrecognized = toField(&f) + } + + atomic.StoreInt32(&mi.initialized, 1) +} diff --git a/vendor/github.com/golang/protobuf/proto/table_unmarshal.go b/vendor/github.com/golang/protobuf/proto/table_unmarshal.go new file mode 100644 index 0000000..ebf1caa --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/table_unmarshal.go @@ -0,0 +1,2051 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2016 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +import ( + "errors" + "fmt" + "io" + "math" + "reflect" + "strconv" + "strings" + "sync" + "sync/atomic" + "unicode/utf8" +) + +// Unmarshal is the entry point from the generated .pb.go files. +// This function is not intended to be used by non-generated code. +// This function is not subject to any compatibility guarantee. +// msg contains a pointer to a protocol buffer struct. +// b is the data to be unmarshaled into the protocol buffer. +// a is a pointer to a place to store cached unmarshal information. +func (a *InternalMessageInfo) Unmarshal(msg Message, b []byte) error { + // Load the unmarshal information for this message type. + // The atomic load ensures memory consistency. + u := atomicLoadUnmarshalInfo(&a.unmarshal) + if u == nil { + // Slow path: find unmarshal info for msg, update a with it. + u = getUnmarshalInfo(reflect.TypeOf(msg).Elem()) + atomicStoreUnmarshalInfo(&a.unmarshal, u) + } + // Then do the unmarshaling. + err := u.unmarshal(toPointer(&msg), b) + return err +} + +type unmarshalInfo struct { + typ reflect.Type // type of the protobuf struct + + // 0 = only typ field is initialized + // 1 = completely initialized + initialized int32 + lock sync.Mutex // prevents double initialization + dense []unmarshalFieldInfo // fields indexed by tag # + sparse map[uint64]unmarshalFieldInfo // fields indexed by tag # + reqFields []string // names of required fields + reqMask uint64 // 1< 0 { + // Read tag and wire type. + // Special case 1 and 2 byte varints. + var x uint64 + if b[0] < 128 { + x = uint64(b[0]) + b = b[1:] + } else if len(b) >= 2 && b[1] < 128 { + x = uint64(b[0]&0x7f) + uint64(b[1])<<7 + b = b[2:] + } else { + var n int + x, n = decodeVarint(b) + if n == 0 { + return io.ErrUnexpectedEOF + } + b = b[n:] + } + tag := x >> 3 + wire := int(x) & 7 + + // Dispatch on the tag to one of the unmarshal* functions below. + var f unmarshalFieldInfo + if tag < uint64(len(u.dense)) { + f = u.dense[tag] + } else { + f = u.sparse[tag] + } + if fn := f.unmarshal; fn != nil { + var err error + b, err = fn(b, m.offset(f.field), wire) + if err == nil { + reqMask |= f.reqMask + continue + } + if r, ok := err.(*RequiredNotSetError); ok { + // Remember this error, but keep parsing. We need to produce + // a full parse even if a required field is missing. + if errLater == nil { + errLater = r + } + reqMask |= f.reqMask + continue + } + if err != errInternalBadWireType { + if err == errInvalidUTF8 { + if errLater == nil { + fullName := revProtoTypes[reflect.PtrTo(u.typ)] + "." + f.name + errLater = &invalidUTF8Error{fullName} + } + continue + } + return err + } + // Fragments with bad wire type are treated as unknown fields. + } + + // Unknown tag. + if !u.unrecognized.IsValid() { + // Don't keep unrecognized data; just skip it. + var err error + b, err = skipField(b, wire) + if err != nil { + return err + } + continue + } + // Keep unrecognized data around. + // maybe in extensions, maybe in the unrecognized field. + z := m.offset(u.unrecognized).toBytes() + var emap map[int32]Extension + var e Extension + for _, r := range u.extensionRanges { + if uint64(r.Start) <= tag && tag <= uint64(r.End) { + if u.extensions.IsValid() { + mp := m.offset(u.extensions).toExtensions() + emap = mp.extensionsWrite() + e = emap[int32(tag)] + z = &e.enc + break + } + if u.oldExtensions.IsValid() { + p := m.offset(u.oldExtensions).toOldExtensions() + emap = *p + if emap == nil { + emap = map[int32]Extension{} + *p = emap + } + e = emap[int32(tag)] + z = &e.enc + break + } + panic("no extensions field available") + } + } + + // Use wire type to skip data. + var err error + b0 := b + b, err = skipField(b, wire) + if err != nil { + return err + } + *z = encodeVarint(*z, tag<<3|uint64(wire)) + *z = append(*z, b0[:len(b0)-len(b)]...) + + if emap != nil { + emap[int32(tag)] = e + } + } + if reqMask != u.reqMask && errLater == nil { + // A required field of this message is missing. + for _, n := range u.reqFields { + if reqMask&1 == 0 { + errLater = &RequiredNotSetError{n} + } + reqMask >>= 1 + } + } + return errLater +} + +// computeUnmarshalInfo fills in u with information for use +// in unmarshaling protocol buffers of type u.typ. +func (u *unmarshalInfo) computeUnmarshalInfo() { + u.lock.Lock() + defer u.lock.Unlock() + if u.initialized != 0 { + return + } + t := u.typ + n := t.NumField() + + // Set up the "not found" value for the unrecognized byte buffer. + // This is the default for proto3. + u.unrecognized = invalidField + u.extensions = invalidField + u.oldExtensions = invalidField + + // List of the generated type and offset for each oneof field. + type oneofField struct { + ityp reflect.Type // interface type of oneof field + field field // offset in containing message + } + var oneofFields []oneofField + + for i := 0; i < n; i++ { + f := t.Field(i) + if f.Name == "XXX_unrecognized" { + // The byte slice used to hold unrecognized input is special. + if f.Type != reflect.TypeOf(([]byte)(nil)) { + panic("bad type for XXX_unrecognized field: " + f.Type.Name()) + } + u.unrecognized = toField(&f) + continue + } + if f.Name == "XXX_InternalExtensions" { + // Ditto here. + if f.Type != reflect.TypeOf(XXX_InternalExtensions{}) { + panic("bad type for XXX_InternalExtensions field: " + f.Type.Name()) + } + u.extensions = toField(&f) + if f.Tag.Get("protobuf_messageset") == "1" { + u.isMessageSet = true + } + continue + } + if f.Name == "XXX_extensions" { + // An older form of the extensions field. + if f.Type != reflect.TypeOf((map[int32]Extension)(nil)) { + panic("bad type for XXX_extensions field: " + f.Type.Name()) + } + u.oldExtensions = toField(&f) + continue + } + if f.Name == "XXX_NoUnkeyedLiteral" || f.Name == "XXX_sizecache" { + continue + } + + oneof := f.Tag.Get("protobuf_oneof") + if oneof != "" { + oneofFields = append(oneofFields, oneofField{f.Type, toField(&f)}) + // The rest of oneof processing happens below. + continue + } + + tags := f.Tag.Get("protobuf") + tagArray := strings.Split(tags, ",") + if len(tagArray) < 2 { + panic("protobuf tag not enough fields in " + t.Name() + "." + f.Name + ": " + tags) + } + tag, err := strconv.Atoi(tagArray[1]) + if err != nil { + panic("protobuf tag field not an integer: " + tagArray[1]) + } + + name := "" + for _, tag := range tagArray[3:] { + if strings.HasPrefix(tag, "name=") { + name = tag[5:] + } + } + + // Extract unmarshaling function from the field (its type and tags). + unmarshal := fieldUnmarshaler(&f) + + // Required field? + var reqMask uint64 + if tagArray[2] == "req" { + bit := len(u.reqFields) + u.reqFields = append(u.reqFields, name) + reqMask = uint64(1) << uint(bit) + // TODO: if we have more than 64 required fields, we end up + // not verifying that all required fields are present. + // Fix this, perhaps using a count of required fields? + } + + // Store the info in the correct slot in the message. + u.setTag(tag, toField(&f), unmarshal, reqMask, name) + } + + // Find any types associated with oneof fields. + // TODO: XXX_OneofFuncs returns more info than we need. Get rid of some of it? + fn := reflect.Zero(reflect.PtrTo(t)).MethodByName("XXX_OneofFuncs") + if fn.IsValid() { + res := fn.Call(nil)[3] // last return value from XXX_OneofFuncs: []interface{} + for i := res.Len() - 1; i >= 0; i-- { + v := res.Index(i) // interface{} + tptr := reflect.ValueOf(v.Interface()).Type() // *Msg_X + typ := tptr.Elem() // Msg_X + + f := typ.Field(0) // oneof implementers have one field + baseUnmarshal := fieldUnmarshaler(&f) + tags := strings.Split(f.Tag.Get("protobuf"), ",") + fieldNum, err := strconv.Atoi(tags[1]) + if err != nil { + panic("protobuf tag field not an integer: " + tags[1]) + } + var name string + for _, tag := range tags { + if strings.HasPrefix(tag, "name=") { + name = strings.TrimPrefix(tag, "name=") + break + } + } + + // Find the oneof field that this struct implements. + // Might take O(n^2) to process all of the oneofs, but who cares. + for _, of := range oneofFields { + if tptr.Implements(of.ityp) { + // We have found the corresponding interface for this struct. + // That lets us know where this struct should be stored + // when we encounter it during unmarshaling. + unmarshal := makeUnmarshalOneof(typ, of.ityp, baseUnmarshal) + u.setTag(fieldNum, of.field, unmarshal, 0, name) + } + } + } + } + + // Get extension ranges, if any. + fn = reflect.Zero(reflect.PtrTo(t)).MethodByName("ExtensionRangeArray") + if fn.IsValid() { + if !u.extensions.IsValid() && !u.oldExtensions.IsValid() { + panic("a message with extensions, but no extensions field in " + t.Name()) + } + u.extensionRanges = fn.Call(nil)[0].Interface().([]ExtensionRange) + } + + // Explicitly disallow tag 0. This will ensure we flag an error + // when decoding a buffer of all zeros. Without this code, we + // would decode and skip an all-zero buffer of even length. + // [0 0] is [tag=0/wiretype=varint varint-encoded-0]. + u.setTag(0, zeroField, func(b []byte, f pointer, w int) ([]byte, error) { + return nil, fmt.Errorf("proto: %s: illegal tag 0 (wire type %d)", t, w) + }, 0, "") + + // Set mask for required field check. + u.reqMask = uint64(1)<= 0 && (tag < 16 || tag < 2*n) { // TODO: what are the right numbers here? + for len(u.dense) <= tag { + u.dense = append(u.dense, unmarshalFieldInfo{}) + } + u.dense[tag] = i + return + } + if u.sparse == nil { + u.sparse = map[uint64]unmarshalFieldInfo{} + } + u.sparse[uint64(tag)] = i +} + +// fieldUnmarshaler returns an unmarshaler for the given field. +func fieldUnmarshaler(f *reflect.StructField) unmarshaler { + if f.Type.Kind() == reflect.Map { + return makeUnmarshalMap(f) + } + return typeUnmarshaler(f.Type, f.Tag.Get("protobuf")) +} + +// typeUnmarshaler returns an unmarshaler for the given field type / field tag pair. +func typeUnmarshaler(t reflect.Type, tags string) unmarshaler { + tagArray := strings.Split(tags, ",") + encoding := tagArray[0] + name := "unknown" + proto3 := false + validateUTF8 := true + for _, tag := range tagArray[3:] { + if strings.HasPrefix(tag, "name=") { + name = tag[5:] + } + if tag == "proto3" { + proto3 = true + } + } + validateUTF8 = validateUTF8 && proto3 + + // Figure out packaging (pointer, slice, or both) + slice := false + pointer := false + if t.Kind() == reflect.Slice && t.Elem().Kind() != reflect.Uint8 { + slice = true + t = t.Elem() + } + if t.Kind() == reflect.Ptr { + pointer = true + t = t.Elem() + } + + // We'll never have both pointer and slice for basic types. + if pointer && slice && t.Kind() != reflect.Struct { + panic("both pointer and slice for basic type in " + t.Name()) + } + + switch t.Kind() { + case reflect.Bool: + if pointer { + return unmarshalBoolPtr + } + if slice { + return unmarshalBoolSlice + } + return unmarshalBoolValue + case reflect.Int32: + switch encoding { + case "fixed32": + if pointer { + return unmarshalFixedS32Ptr + } + if slice { + return unmarshalFixedS32Slice + } + return unmarshalFixedS32Value + case "varint": + // this could be int32 or enum + if pointer { + return unmarshalInt32Ptr + } + if slice { + return unmarshalInt32Slice + } + return unmarshalInt32Value + case "zigzag32": + if pointer { + return unmarshalSint32Ptr + } + if slice { + return unmarshalSint32Slice + } + return unmarshalSint32Value + } + case reflect.Int64: + switch encoding { + case "fixed64": + if pointer { + return unmarshalFixedS64Ptr + } + if slice { + return unmarshalFixedS64Slice + } + return unmarshalFixedS64Value + case "varint": + if pointer { + return unmarshalInt64Ptr + } + if slice { + return unmarshalInt64Slice + } + return unmarshalInt64Value + case "zigzag64": + if pointer { + return unmarshalSint64Ptr + } + if slice { + return unmarshalSint64Slice + } + return unmarshalSint64Value + } + case reflect.Uint32: + switch encoding { + case "fixed32": + if pointer { + return unmarshalFixed32Ptr + } + if slice { + return unmarshalFixed32Slice + } + return unmarshalFixed32Value + case "varint": + if pointer { + return unmarshalUint32Ptr + } + if slice { + return unmarshalUint32Slice + } + return unmarshalUint32Value + } + case reflect.Uint64: + switch encoding { + case "fixed64": + if pointer { + return unmarshalFixed64Ptr + } + if slice { + return unmarshalFixed64Slice + } + return unmarshalFixed64Value + case "varint": + if pointer { + return unmarshalUint64Ptr + } + if slice { + return unmarshalUint64Slice + } + return unmarshalUint64Value + } + case reflect.Float32: + if pointer { + return unmarshalFloat32Ptr + } + if slice { + return unmarshalFloat32Slice + } + return unmarshalFloat32Value + case reflect.Float64: + if pointer { + return unmarshalFloat64Ptr + } + if slice { + return unmarshalFloat64Slice + } + return unmarshalFloat64Value + case reflect.Map: + panic("map type in typeUnmarshaler in " + t.Name()) + case reflect.Slice: + if pointer { + panic("bad pointer in slice case in " + t.Name()) + } + if slice { + return unmarshalBytesSlice + } + return unmarshalBytesValue + case reflect.String: + if validateUTF8 { + if pointer { + return unmarshalUTF8StringPtr + } + if slice { + return unmarshalUTF8StringSlice + } + return unmarshalUTF8StringValue + } + if pointer { + return unmarshalStringPtr + } + if slice { + return unmarshalStringSlice + } + return unmarshalStringValue + case reflect.Struct: + // message or group field + if !pointer { + panic(fmt.Sprintf("message/group field %s:%s without pointer", t, encoding)) + } + switch encoding { + case "bytes": + if slice { + return makeUnmarshalMessageSlicePtr(getUnmarshalInfo(t), name) + } + return makeUnmarshalMessagePtr(getUnmarshalInfo(t), name) + case "group": + if slice { + return makeUnmarshalGroupSlicePtr(getUnmarshalInfo(t), name) + } + return makeUnmarshalGroupPtr(getUnmarshalInfo(t), name) + } + } + panic(fmt.Sprintf("unmarshaler not found type:%s encoding:%s", t, encoding)) +} + +// Below are all the unmarshalers for individual fields of various types. + +func unmarshalInt64Value(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int64(x) + *f.toInt64() = v + return b, nil +} + +func unmarshalInt64Ptr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int64(x) + *f.toInt64Ptr() = &v + return b, nil +} + +func unmarshalInt64Slice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + x, n = decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int64(x) + s := f.toInt64Slice() + *s = append(*s, v) + } + return res, nil + } + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int64(x) + s := f.toInt64Slice() + *s = append(*s, v) + return b, nil +} + +func unmarshalSint64Value(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int64(x>>1) ^ int64(x)<<63>>63 + *f.toInt64() = v + return b, nil +} + +func unmarshalSint64Ptr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int64(x>>1) ^ int64(x)<<63>>63 + *f.toInt64Ptr() = &v + return b, nil +} + +func unmarshalSint64Slice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + x, n = decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int64(x>>1) ^ int64(x)<<63>>63 + s := f.toInt64Slice() + *s = append(*s, v) + } + return res, nil + } + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int64(x>>1) ^ int64(x)<<63>>63 + s := f.toInt64Slice() + *s = append(*s, v) + return b, nil +} + +func unmarshalUint64Value(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := uint64(x) + *f.toUint64() = v + return b, nil +} + +func unmarshalUint64Ptr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := uint64(x) + *f.toUint64Ptr() = &v + return b, nil +} + +func unmarshalUint64Slice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + x, n = decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := uint64(x) + s := f.toUint64Slice() + *s = append(*s, v) + } + return res, nil + } + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := uint64(x) + s := f.toUint64Slice() + *s = append(*s, v) + return b, nil +} + +func unmarshalInt32Value(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int32(x) + *f.toInt32() = v + return b, nil +} + +func unmarshalInt32Ptr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int32(x) + f.setInt32Ptr(v) + return b, nil +} + +func unmarshalInt32Slice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + x, n = decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int32(x) + f.appendInt32Slice(v) + } + return res, nil + } + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int32(x) + f.appendInt32Slice(v) + return b, nil +} + +func unmarshalSint32Value(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int32(x>>1) ^ int32(x)<<31>>31 + *f.toInt32() = v + return b, nil +} + +func unmarshalSint32Ptr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int32(x>>1) ^ int32(x)<<31>>31 + f.setInt32Ptr(v) + return b, nil +} + +func unmarshalSint32Slice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + x, n = decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int32(x>>1) ^ int32(x)<<31>>31 + f.appendInt32Slice(v) + } + return res, nil + } + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int32(x>>1) ^ int32(x)<<31>>31 + f.appendInt32Slice(v) + return b, nil +} + +func unmarshalUint32Value(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := uint32(x) + *f.toUint32() = v + return b, nil +} + +func unmarshalUint32Ptr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := uint32(x) + *f.toUint32Ptr() = &v + return b, nil +} + +func unmarshalUint32Slice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + x, n = decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := uint32(x) + s := f.toUint32Slice() + *s = append(*s, v) + } + return res, nil + } + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := uint32(x) + s := f.toUint32Slice() + *s = append(*s, v) + return b, nil +} + +func unmarshalFixed64Value(b []byte, f pointer, w int) ([]byte, error) { + if w != WireFixed64 { + return b, errInternalBadWireType + } + if len(b) < 8 { + return nil, io.ErrUnexpectedEOF + } + v := uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56 + *f.toUint64() = v + return b[8:], nil +} + +func unmarshalFixed64Ptr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireFixed64 { + return b, errInternalBadWireType + } + if len(b) < 8 { + return nil, io.ErrUnexpectedEOF + } + v := uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56 + *f.toUint64Ptr() = &v + return b[8:], nil +} + +func unmarshalFixed64Slice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + if len(b) < 8 { + return nil, io.ErrUnexpectedEOF + } + v := uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56 + s := f.toUint64Slice() + *s = append(*s, v) + b = b[8:] + } + return res, nil + } + if w != WireFixed64 { + return b, errInternalBadWireType + } + if len(b) < 8 { + return nil, io.ErrUnexpectedEOF + } + v := uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56 + s := f.toUint64Slice() + *s = append(*s, v) + return b[8:], nil +} + +func unmarshalFixedS64Value(b []byte, f pointer, w int) ([]byte, error) { + if w != WireFixed64 { + return b, errInternalBadWireType + } + if len(b) < 8 { + return nil, io.ErrUnexpectedEOF + } + v := int64(b[0]) | int64(b[1])<<8 | int64(b[2])<<16 | int64(b[3])<<24 | int64(b[4])<<32 | int64(b[5])<<40 | int64(b[6])<<48 | int64(b[7])<<56 + *f.toInt64() = v + return b[8:], nil +} + +func unmarshalFixedS64Ptr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireFixed64 { + return b, errInternalBadWireType + } + if len(b) < 8 { + return nil, io.ErrUnexpectedEOF + } + v := int64(b[0]) | int64(b[1])<<8 | int64(b[2])<<16 | int64(b[3])<<24 | int64(b[4])<<32 | int64(b[5])<<40 | int64(b[6])<<48 | int64(b[7])<<56 + *f.toInt64Ptr() = &v + return b[8:], nil +} + +func unmarshalFixedS64Slice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + if len(b) < 8 { + return nil, io.ErrUnexpectedEOF + } + v := int64(b[0]) | int64(b[1])<<8 | int64(b[2])<<16 | int64(b[3])<<24 | int64(b[4])<<32 | int64(b[5])<<40 | int64(b[6])<<48 | int64(b[7])<<56 + s := f.toInt64Slice() + *s = append(*s, v) + b = b[8:] + } + return res, nil + } + if w != WireFixed64 { + return b, errInternalBadWireType + } + if len(b) < 8 { + return nil, io.ErrUnexpectedEOF + } + v := int64(b[0]) | int64(b[1])<<8 | int64(b[2])<<16 | int64(b[3])<<24 | int64(b[4])<<32 | int64(b[5])<<40 | int64(b[6])<<48 | int64(b[7])<<56 + s := f.toInt64Slice() + *s = append(*s, v) + return b[8:], nil +} + +func unmarshalFixed32Value(b []byte, f pointer, w int) ([]byte, error) { + if w != WireFixed32 { + return b, errInternalBadWireType + } + if len(b) < 4 { + return nil, io.ErrUnexpectedEOF + } + v := uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 + *f.toUint32() = v + return b[4:], nil +} + +func unmarshalFixed32Ptr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireFixed32 { + return b, errInternalBadWireType + } + if len(b) < 4 { + return nil, io.ErrUnexpectedEOF + } + v := uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 + *f.toUint32Ptr() = &v + return b[4:], nil +} + +func unmarshalFixed32Slice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + if len(b) < 4 { + return nil, io.ErrUnexpectedEOF + } + v := uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 + s := f.toUint32Slice() + *s = append(*s, v) + b = b[4:] + } + return res, nil + } + if w != WireFixed32 { + return b, errInternalBadWireType + } + if len(b) < 4 { + return nil, io.ErrUnexpectedEOF + } + v := uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 + s := f.toUint32Slice() + *s = append(*s, v) + return b[4:], nil +} + +func unmarshalFixedS32Value(b []byte, f pointer, w int) ([]byte, error) { + if w != WireFixed32 { + return b, errInternalBadWireType + } + if len(b) < 4 { + return nil, io.ErrUnexpectedEOF + } + v := int32(b[0]) | int32(b[1])<<8 | int32(b[2])<<16 | int32(b[3])<<24 + *f.toInt32() = v + return b[4:], nil +} + +func unmarshalFixedS32Ptr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireFixed32 { + return b, errInternalBadWireType + } + if len(b) < 4 { + return nil, io.ErrUnexpectedEOF + } + v := int32(b[0]) | int32(b[1])<<8 | int32(b[2])<<16 | int32(b[3])<<24 + f.setInt32Ptr(v) + return b[4:], nil +} + +func unmarshalFixedS32Slice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + if len(b) < 4 { + return nil, io.ErrUnexpectedEOF + } + v := int32(b[0]) | int32(b[1])<<8 | int32(b[2])<<16 | int32(b[3])<<24 + f.appendInt32Slice(v) + b = b[4:] + } + return res, nil + } + if w != WireFixed32 { + return b, errInternalBadWireType + } + if len(b) < 4 { + return nil, io.ErrUnexpectedEOF + } + v := int32(b[0]) | int32(b[1])<<8 | int32(b[2])<<16 | int32(b[3])<<24 + f.appendInt32Slice(v) + return b[4:], nil +} + +func unmarshalBoolValue(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + // Note: any length varint is allowed, even though any sane + // encoder will use one byte. + // See https://github.com/golang/protobuf/issues/76 + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + // TODO: check if x>1? Tests seem to indicate no. + v := x != 0 + *f.toBool() = v + return b[n:], nil +} + +func unmarshalBoolPtr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + v := x != 0 + *f.toBoolPtr() = &v + return b[n:], nil +} + +func unmarshalBoolSlice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + x, n = decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + v := x != 0 + s := f.toBoolSlice() + *s = append(*s, v) + b = b[n:] + } + return res, nil + } + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + v := x != 0 + s := f.toBoolSlice() + *s = append(*s, v) + return b[n:], nil +} + +func unmarshalFloat64Value(b []byte, f pointer, w int) ([]byte, error) { + if w != WireFixed64 { + return b, errInternalBadWireType + } + if len(b) < 8 { + return nil, io.ErrUnexpectedEOF + } + v := math.Float64frombits(uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56) + *f.toFloat64() = v + return b[8:], nil +} + +func unmarshalFloat64Ptr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireFixed64 { + return b, errInternalBadWireType + } + if len(b) < 8 { + return nil, io.ErrUnexpectedEOF + } + v := math.Float64frombits(uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56) + *f.toFloat64Ptr() = &v + return b[8:], nil +} + +func unmarshalFloat64Slice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + if len(b) < 8 { + return nil, io.ErrUnexpectedEOF + } + v := math.Float64frombits(uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56) + s := f.toFloat64Slice() + *s = append(*s, v) + b = b[8:] + } + return res, nil + } + if w != WireFixed64 { + return b, errInternalBadWireType + } + if len(b) < 8 { + return nil, io.ErrUnexpectedEOF + } + v := math.Float64frombits(uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56) + s := f.toFloat64Slice() + *s = append(*s, v) + return b[8:], nil +} + +func unmarshalFloat32Value(b []byte, f pointer, w int) ([]byte, error) { + if w != WireFixed32 { + return b, errInternalBadWireType + } + if len(b) < 4 { + return nil, io.ErrUnexpectedEOF + } + v := math.Float32frombits(uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24) + *f.toFloat32() = v + return b[4:], nil +} + +func unmarshalFloat32Ptr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireFixed32 { + return b, errInternalBadWireType + } + if len(b) < 4 { + return nil, io.ErrUnexpectedEOF + } + v := math.Float32frombits(uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24) + *f.toFloat32Ptr() = &v + return b[4:], nil +} + +func unmarshalFloat32Slice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + if len(b) < 4 { + return nil, io.ErrUnexpectedEOF + } + v := math.Float32frombits(uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24) + s := f.toFloat32Slice() + *s = append(*s, v) + b = b[4:] + } + return res, nil + } + if w != WireFixed32 { + return b, errInternalBadWireType + } + if len(b) < 4 { + return nil, io.ErrUnexpectedEOF + } + v := math.Float32frombits(uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24) + s := f.toFloat32Slice() + *s = append(*s, v) + return b[4:], nil +} + +func unmarshalStringValue(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + v := string(b[:x]) + *f.toString() = v + return b[x:], nil +} + +func unmarshalStringPtr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + v := string(b[:x]) + *f.toStringPtr() = &v + return b[x:], nil +} + +func unmarshalStringSlice(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + v := string(b[:x]) + s := f.toStringSlice() + *s = append(*s, v) + return b[x:], nil +} + +func unmarshalUTF8StringValue(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + v := string(b[:x]) + *f.toString() = v + if !utf8.ValidString(v) { + return b[x:], errInvalidUTF8 + } + return b[x:], nil +} + +func unmarshalUTF8StringPtr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + v := string(b[:x]) + *f.toStringPtr() = &v + if !utf8.ValidString(v) { + return b[x:], errInvalidUTF8 + } + return b[x:], nil +} + +func unmarshalUTF8StringSlice(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + v := string(b[:x]) + s := f.toStringSlice() + *s = append(*s, v) + if !utf8.ValidString(v) { + return b[x:], errInvalidUTF8 + } + return b[x:], nil +} + +var emptyBuf [0]byte + +func unmarshalBytesValue(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + // The use of append here is a trick which avoids the zeroing + // that would be required if we used a make/copy pair. + // We append to emptyBuf instead of nil because we want + // a non-nil result even when the length is 0. + v := append(emptyBuf[:], b[:x]...) + *f.toBytes() = v + return b[x:], nil +} + +func unmarshalBytesSlice(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + v := append(emptyBuf[:], b[:x]...) + s := f.toBytesSlice() + *s = append(*s, v) + return b[x:], nil +} + +func makeUnmarshalMessagePtr(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + // First read the message field to see if something is there. + // The semantics of multiple submessages are weird. Instead of + // the last one winning (as it is for all other fields), multiple + // submessages are merged. + v := f.getPointer() + if v.isNil() { + v = valToPointer(reflect.New(sub.typ)) + f.setPointer(v) + } + err := sub.unmarshal(v, b[:x]) + if err != nil { + if r, ok := err.(*RequiredNotSetError); ok { + r.field = name + "." + r.field + } else { + return nil, err + } + } + return b[x:], err + } +} + +func makeUnmarshalMessageSlicePtr(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + v := valToPointer(reflect.New(sub.typ)) + err := sub.unmarshal(v, b[:x]) + if err != nil { + if r, ok := err.(*RequiredNotSetError); ok { + r.field = name + "." + r.field + } else { + return nil, err + } + } + f.appendPointer(v) + return b[x:], err + } +} + +func makeUnmarshalGroupPtr(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireStartGroup { + return b, errInternalBadWireType + } + x, y := findEndGroup(b) + if x < 0 { + return nil, io.ErrUnexpectedEOF + } + v := f.getPointer() + if v.isNil() { + v = valToPointer(reflect.New(sub.typ)) + f.setPointer(v) + } + err := sub.unmarshal(v, b[:x]) + if err != nil { + if r, ok := err.(*RequiredNotSetError); ok { + r.field = name + "." + r.field + } else { + return nil, err + } + } + return b[y:], err + } +} + +func makeUnmarshalGroupSlicePtr(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireStartGroup { + return b, errInternalBadWireType + } + x, y := findEndGroup(b) + if x < 0 { + return nil, io.ErrUnexpectedEOF + } + v := valToPointer(reflect.New(sub.typ)) + err := sub.unmarshal(v, b[:x]) + if err != nil { + if r, ok := err.(*RequiredNotSetError); ok { + r.field = name + "." + r.field + } else { + return nil, err + } + } + f.appendPointer(v) + return b[y:], err + } +} + +func makeUnmarshalMap(f *reflect.StructField) unmarshaler { + t := f.Type + kt := t.Key() + vt := t.Elem() + unmarshalKey := typeUnmarshaler(kt, f.Tag.Get("protobuf_key")) + unmarshalVal := typeUnmarshaler(vt, f.Tag.Get("protobuf_val")) + return func(b []byte, f pointer, w int) ([]byte, error) { + // The map entry is a submessage. Figure out how big it is. + if w != WireBytes { + return nil, fmt.Errorf("proto: bad wiretype for map field: got %d want %d", w, WireBytes) + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + r := b[x:] // unused data to return + b = b[:x] // data for map entry + + // Note: we could use #keys * #values ~= 200 functions + // to do map decoding without reflection. Probably not worth it. + // Maps will be somewhat slow. Oh well. + + // Read key and value from data. + var nerr nonFatal + k := reflect.New(kt) + v := reflect.New(vt) + for len(b) > 0 { + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + wire := int(x) & 7 + b = b[n:] + + var err error + switch x >> 3 { + case 1: + b, err = unmarshalKey(b, valToPointer(k), wire) + case 2: + b, err = unmarshalVal(b, valToPointer(v), wire) + default: + err = errInternalBadWireType // skip unknown tag + } + + if nerr.Merge(err) { + continue + } + if err != errInternalBadWireType { + return nil, err + } + + // Skip past unknown fields. + b, err = skipField(b, wire) + if err != nil { + return nil, err + } + } + + // Get map, allocate if needed. + m := f.asPointerTo(t).Elem() // an addressable map[K]T + if m.IsNil() { + m.Set(reflect.MakeMap(t)) + } + + // Insert into map. + m.SetMapIndex(k.Elem(), v.Elem()) + + return r, nerr.E + } +} + +// makeUnmarshalOneof makes an unmarshaler for oneof fields. +// for: +// message Msg { +// oneof F { +// int64 X = 1; +// float64 Y = 2; +// } +// } +// typ is the type of the concrete entry for a oneof case (e.g. Msg_X). +// ityp is the interface type of the oneof field (e.g. isMsg_F). +// unmarshal is the unmarshaler for the base type of the oneof case (e.g. int64). +// Note that this function will be called once for each case in the oneof. +func makeUnmarshalOneof(typ, ityp reflect.Type, unmarshal unmarshaler) unmarshaler { + sf := typ.Field(0) + field0 := toField(&sf) + return func(b []byte, f pointer, w int) ([]byte, error) { + // Allocate holder for value. + v := reflect.New(typ) + + // Unmarshal data into holder. + // We unmarshal into the first field of the holder object. + var err error + var nerr nonFatal + b, err = unmarshal(b, valToPointer(v).offset(field0), w) + if !nerr.Merge(err) { + return nil, err + } + + // Write pointer to holder into target field. + f.asPointerTo(ityp).Elem().Set(v) + + return b, nerr.E + } +} + +// Error used by decode internally. +var errInternalBadWireType = errors.New("proto: internal error: bad wiretype") + +// skipField skips past a field of type wire and returns the remaining bytes. +func skipField(b []byte, wire int) ([]byte, error) { + switch wire { + case WireVarint: + _, k := decodeVarint(b) + if k == 0 { + return b, io.ErrUnexpectedEOF + } + b = b[k:] + case WireFixed32: + if len(b) < 4 { + return b, io.ErrUnexpectedEOF + } + b = b[4:] + case WireFixed64: + if len(b) < 8 { + return b, io.ErrUnexpectedEOF + } + b = b[8:] + case WireBytes: + m, k := decodeVarint(b) + if k == 0 || uint64(len(b)-k) < m { + return b, io.ErrUnexpectedEOF + } + b = b[uint64(k)+m:] + case WireStartGroup: + _, i := findEndGroup(b) + if i == -1 { + return b, io.ErrUnexpectedEOF + } + b = b[i:] + default: + return b, fmt.Errorf("proto: can't skip unknown wire type %d", wire) + } + return b, nil +} + +// findEndGroup finds the index of the next EndGroup tag. +// Groups may be nested, so the "next" EndGroup tag is the first +// unpaired EndGroup. +// findEndGroup returns the indexes of the start and end of the EndGroup tag. +// Returns (-1,-1) if it can't find one. +func findEndGroup(b []byte) (int, int) { + depth := 1 + i := 0 + for { + x, n := decodeVarint(b[i:]) + if n == 0 { + return -1, -1 + } + j := i + i += n + switch x & 7 { + case WireVarint: + _, k := decodeVarint(b[i:]) + if k == 0 { + return -1, -1 + } + i += k + case WireFixed32: + if len(b)-4 < i { + return -1, -1 + } + i += 4 + case WireFixed64: + if len(b)-8 < i { + return -1, -1 + } + i += 8 + case WireBytes: + m, k := decodeVarint(b[i:]) + if k == 0 { + return -1, -1 + } + i += k + if uint64(len(b)-i) < m { + return -1, -1 + } + i += int(m) + case WireStartGroup: + depth++ + case WireEndGroup: + depth-- + if depth == 0 { + return j, i + } + default: + return -1, -1 + } + } +} + +// encodeVarint appends a varint-encoded integer to b and returns the result. +func encodeVarint(b []byte, x uint64) []byte { + for x >= 1<<7 { + b = append(b, byte(x&0x7f|0x80)) + x >>= 7 + } + return append(b, byte(x)) +} + +// decodeVarint reads a varint-encoded integer from b. +// Returns the decoded integer and the number of bytes read. +// If there is an error, it returns 0,0. +func decodeVarint(b []byte) (uint64, int) { + var x, y uint64 + if len(b) <= 0 { + goto bad + } + x = uint64(b[0]) + if x < 0x80 { + return x, 1 + } + x -= 0x80 + + if len(b) <= 1 { + goto bad + } + y = uint64(b[1]) + x += y << 7 + if y < 0x80 { + return x, 2 + } + x -= 0x80 << 7 + + if len(b) <= 2 { + goto bad + } + y = uint64(b[2]) + x += y << 14 + if y < 0x80 { + return x, 3 + } + x -= 0x80 << 14 + + if len(b) <= 3 { + goto bad + } + y = uint64(b[3]) + x += y << 21 + if y < 0x80 { + return x, 4 + } + x -= 0x80 << 21 + + if len(b) <= 4 { + goto bad + } + y = uint64(b[4]) + x += y << 28 + if y < 0x80 { + return x, 5 + } + x -= 0x80 << 28 + + if len(b) <= 5 { + goto bad + } + y = uint64(b[5]) + x += y << 35 + if y < 0x80 { + return x, 6 + } + x -= 0x80 << 35 + + if len(b) <= 6 { + goto bad + } + y = uint64(b[6]) + x += y << 42 + if y < 0x80 { + return x, 7 + } + x -= 0x80 << 42 + + if len(b) <= 7 { + goto bad + } + y = uint64(b[7]) + x += y << 49 + if y < 0x80 { + return x, 8 + } + x -= 0x80 << 49 + + if len(b) <= 8 { + goto bad + } + y = uint64(b[8]) + x += y << 56 + if y < 0x80 { + return x, 9 + } + x -= 0x80 << 56 + + if len(b) <= 9 { + goto bad + } + y = uint64(b[9]) + x += y << 63 + if y < 2 { + return x, 10 + } + +bad: + return 0, 0 +} diff --git a/vendor/github.com/golang/protobuf/proto/text.go b/vendor/github.com/golang/protobuf/proto/text.go index 965876b..1aaee72 100644 --- a/vendor/github.com/golang/protobuf/proto/text.go +++ b/vendor/github.com/golang/protobuf/proto/text.go @@ -50,7 +50,6 @@ import ( var ( newline = []byte("\n") spaces = []byte(" ") - gtNewline = []byte(">\n") endBraceNewline = []byte("}\n") backslashN = []byte{'\\', 'n'} backslashR = []byte{'\\', 'r'} @@ -170,11 +169,6 @@ func writeName(w *textWriter, props *Properties) error { return nil } -// raw is the interface satisfied by RawMessage. -type raw interface { - Bytes() []byte -} - func requiresQuotes(u string) bool { // When type URL contains any characters except [0-9A-Za-z./\-]*, it must be quoted. for _, ch := range u { @@ -269,6 +263,10 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error { props := sprops.Prop[i] name := st.Field(i).Name + if name == "XXX_NoUnkeyedLiteral" { + continue + } + if strings.HasPrefix(name, "XXX_") { // There are two XXX_ fields: // XXX_unrecognized []byte @@ -355,7 +353,7 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error { return err } } - if err := tm.writeAny(w, key, props.mkeyprop); err != nil { + if err := tm.writeAny(w, key, props.MapKeyProp); err != nil { return err } if err := w.WriteByte('\n'); err != nil { @@ -372,7 +370,7 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error { return err } } - if err := tm.writeAny(w, val, props.mvalprop); err != nil { + if err := tm.writeAny(w, val, props.MapValProp); err != nil { return err } if err := w.WriteByte('\n'); err != nil { @@ -436,12 +434,6 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error { return err } } - if b, ok := fv.Interface().(raw); ok { - if err := writeRaw(w, b.Bytes()); err != nil { - return err - } - continue - } // Enums have a String method, so writeAny will work fine. if err := tm.writeAny(w, fv, props); err != nil { @@ -455,7 +447,7 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error { // Extensions (the XXX_extensions field). pv := sv.Addr() - if _, ok := extendable(pv.Interface()); ok { + if _, err := extendable(pv.Interface()); err == nil { if err := tm.writeExtensions(w, pv); err != nil { return err } @@ -464,27 +456,6 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error { return nil } -// writeRaw writes an uninterpreted raw message. -func writeRaw(w *textWriter, b []byte) error { - if err := w.WriteByte('<'); err != nil { - return err - } - if !w.compact { - if err := w.WriteByte('\n'); err != nil { - return err - } - } - w.indent() - if err := writeUnknownStruct(w, b); err != nil { - return err - } - w.unindent() - if err := w.WriteByte('>'); err != nil { - return err - } - return nil -} - // writeAny writes an arbitrary field. func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Properties) error { v = reflect.Indirect(v) @@ -535,6 +506,19 @@ func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Propert } } w.indent() + if v.CanAddr() { + // Calling v.Interface on a struct causes the reflect package to + // copy the entire struct. This is racy with the new Marshaler + // since we atomically update the XXX_sizecache. + // + // Thus, we retrieve a pointer to the struct if possible to avoid + // a race since v.Interface on the pointer doesn't copy the struct. + // + // If v is not addressable, then we are not worried about a race + // since it implies that the binary Marshaler cannot possibly be + // mutating this value. + v = v.Addr() + } if etm, ok := v.Interface().(encoding.TextMarshaler); ok { text, err := etm.MarshalText() if err != nil { @@ -543,8 +527,13 @@ func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Propert if _, err = w.Write(text); err != nil { return err } - } else if err := tm.writeStruct(w, v); err != nil { - return err + } else { + if v.Kind() == reflect.Ptr { + v = v.Elem() + } + if err := tm.writeStruct(w, v); err != nil { + return err + } } w.unindent() if err := w.WriteByte(ket); err != nil { diff --git a/vendor/github.com/golang/protobuf/proto/text_parser.go b/vendor/github.com/golang/protobuf/proto/text_parser.go index 5e14513..bb55a3a 100644 --- a/vendor/github.com/golang/protobuf/proto/text_parser.go +++ b/vendor/github.com/golang/protobuf/proto/text_parser.go @@ -206,7 +206,6 @@ func (p *textParser) advance() { var ( errBadUTF8 = errors.New("proto: bad UTF-8") - errBadHex = errors.New("proto: bad hexadecimal") ) func unquoteC(s string, quote rune) (string, error) { @@ -277,60 +276,47 @@ func unescape(s string) (ch string, tail string, err error) { return "?", s, nil // trigraph workaround case '\'', '"', '\\': return string(r), s, nil - case '0', '1', '2', '3', '4', '5', '6', '7', 'x', 'X': + case '0', '1', '2', '3', '4', '5', '6', '7': if len(s) < 2 { return "", "", fmt.Errorf(`\%c requires 2 following digits`, r) } - base := 8 - ss := s[:2] + ss := string(r) + s[:2] s = s[2:] - if r == 'x' || r == 'X' { - base = 16 - } else { - ss = string(r) + ss - } - i, err := strconv.ParseUint(ss, base, 8) + i, err := strconv.ParseUint(ss, 8, 8) if err != nil { - return "", "", err + return "", "", fmt.Errorf(`\%s contains non-octal digits`, ss) } return string([]byte{byte(i)}), s, nil - case 'u', 'U': - n := 4 - if r == 'U' { + case 'x', 'X', 'u', 'U': + var n int + switch r { + case 'x', 'X': + n = 2 + case 'u': + n = 4 + case 'U': n = 8 } if len(s) < n { - return "", "", fmt.Errorf(`\%c requires %d digits`, r, n) - } - - bs := make([]byte, n/2) - for i := 0; i < n; i += 2 { - a, ok1 := unhex(s[i]) - b, ok2 := unhex(s[i+1]) - if !ok1 || !ok2 { - return "", "", errBadHex - } - bs[i/2] = a<<4 | b + return "", "", fmt.Errorf(`\%c requires %d following digits`, r, n) } + ss := s[:n] s = s[n:] - return string(bs), s, nil + i, err := strconv.ParseUint(ss, 16, 64) + if err != nil { + return "", "", fmt.Errorf(`\%c%s contains non-hexadecimal digits`, r, ss) + } + if r == 'x' || r == 'X' { + return string([]byte{byte(i)}), s, nil + } + if i > utf8.MaxRune { + return "", "", fmt.Errorf(`\%c%s is not a valid Unicode code point`, r, ss) + } + return string(i), s, nil } return "", "", fmt.Errorf(`unknown escape \%c`, r) } -// Adapted from src/pkg/strconv/quote.go. -func unhex(b byte) (v byte, ok bool) { - switch { - case '0' <= b && b <= '9': - return b - '0', true - case 'a' <= b && b <= 'f': - return b - 'a' + 10, true - case 'A' <= b && b <= 'F': - return b - 'A' + 10, true - } - return 0, false -} - // Back off the parser by one token. Can only be done between calls to next(). // It makes the next advance() a no-op. func (p *textParser) back() { p.backed = true } @@ -644,17 +630,17 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) error { if err := p.consumeToken(":"); err != nil { return err } - if err := p.readAny(key, props.mkeyprop); err != nil { + if err := p.readAny(key, props.MapKeyProp); err != nil { return err } if err := p.consumeOptionalSeparator(); err != nil { return err } case "value": - if err := p.checkForColon(props.mvalprop, dst.Type().Elem()); err != nil { + if err := p.checkForColon(props.MapValProp, dst.Type().Elem()); err != nil { return err } - if err := p.readAny(val, props.mvalprop); err != nil { + if err := p.readAny(val, props.MapValProp); err != nil { return err } if err := p.consumeOptionalSeparator(); err != nil { @@ -728,6 +714,9 @@ func (p *textParser) consumeExtName() (string, error) { if tok.err != nil { return "", p.errorf("unrecognized type_url or extension name: %s", tok.err) } + if p.done && tok.value != "]" { + return "", p.errorf("unclosed type_url or extension name") + } } return strings.Join(parts, ""), nil } @@ -865,7 +854,7 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) error { return p.readStruct(fv, terminator) case reflect.Uint32: if x, err := strconv.ParseUint(tok.value, 0, 32); err == nil { - fv.SetUint(x) + fv.SetUint(uint64(x)) return nil } case reflect.Uint64: @@ -883,13 +872,9 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) error { // UnmarshalText returns *RequiredNotSetError. func UnmarshalText(s string, pb Message) error { if um, ok := pb.(encoding.TextUnmarshaler); ok { - err := um.UnmarshalText([]byte(s)) - return err + return um.UnmarshalText([]byte(s)) } pb.Reset() v := reflect.ValueOf(pb) - if pe := newTextParser(s).readStruct(v.Elem(), ""); pe != nil { - return pe - } - return nil + return newTextParser(s).readStruct(v.Elem(), "") } diff --git a/vendor/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.pb.go b/vendor/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.pb.go index c6a91bc..e855b1f 100644 --- a/vendor/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.pb.go +++ b/vendor/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.pb.go @@ -1,36 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: google/protobuf/descriptor.proto -/* -Package descriptor is a generated protocol buffer package. - -It is generated from these files: - google/protobuf/descriptor.proto - -It has these top-level messages: - FileDescriptorSet - FileDescriptorProto - DescriptorProto - ExtensionRangeOptions - FieldDescriptorProto - OneofDescriptorProto - EnumDescriptorProto - EnumValueDescriptorProto - ServiceDescriptorProto - MethodDescriptorProto - FileOptions - MessageOptions - FieldOptions - OneofOptions - EnumOptions - EnumValueOptions - ServiceOptions - MethodOptions - UninterpretedOption - SourceCodeInfo - GeneratedCodeInfo -*/ -package descriptor +package descriptor // import "github.com/golang/protobuf/protoc-gen-go/descriptor" import proto "github.com/golang/protobuf/proto" import fmt "fmt" @@ -138,7 +109,9 @@ func (x *FieldDescriptorProto_Type) UnmarshalJSON(data []byte) error { *x = FieldDescriptorProto_Type(value) return nil } -func (FieldDescriptorProto_Type) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{4, 0} } +func (FieldDescriptorProto_Type) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{4, 0} +} type FieldDescriptorProto_Label int32 @@ -177,7 +150,7 @@ func (x *FieldDescriptorProto_Label) UnmarshalJSON(data []byte) error { return nil } func (FieldDescriptorProto_Label) EnumDescriptor() ([]byte, []int) { - return fileDescriptor0, []int{4, 1} + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{4, 1} } // Generated classes can be optimized for speed or code size. @@ -217,7 +190,9 @@ func (x *FileOptions_OptimizeMode) UnmarshalJSON(data []byte) error { *x = FileOptions_OptimizeMode(value) return nil } -func (FileOptions_OptimizeMode) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{10, 0} } +func (FileOptions_OptimizeMode) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{10, 0} +} type FieldOptions_CType int32 @@ -255,7 +230,9 @@ func (x *FieldOptions_CType) UnmarshalJSON(data []byte) error { *x = FieldOptions_CType(value) return nil } -func (FieldOptions_CType) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{12, 0} } +func (FieldOptions_CType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{12, 0} +} type FieldOptions_JSType int32 @@ -295,7 +272,9 @@ func (x *FieldOptions_JSType) UnmarshalJSON(data []byte) error { *x = FieldOptions_JSType(value) return nil } -func (FieldOptions_JSType) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{12, 1} } +func (FieldOptions_JSType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{12, 1} +} // Is this method side-effect-free (or safe in HTTP parlance), or idempotent, // or neither? HTTP based RPC implementation may choose GET verb for safe @@ -336,20 +315,41 @@ func (x *MethodOptions_IdempotencyLevel) UnmarshalJSON(data []byte) error { return nil } func (MethodOptions_IdempotencyLevel) EnumDescriptor() ([]byte, []int) { - return fileDescriptor0, []int{17, 0} + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{17, 0} } // The protocol compiler can output a FileDescriptorSet containing the .proto // files it parses. type FileDescriptorSet struct { - File []*FileDescriptorProto `protobuf:"bytes,1,rep,name=file" json:"file,omitempty"` - XXX_unrecognized []byte `json:"-"` + File []*FileDescriptorProto `protobuf:"bytes,1,rep,name=file" json:"file,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *FileDescriptorSet) Reset() { *m = FileDescriptorSet{} } +func (m *FileDescriptorSet) String() string { return proto.CompactTextString(m) } +func (*FileDescriptorSet) ProtoMessage() {} +func (*FileDescriptorSet) Descriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{0} +} +func (m *FileDescriptorSet) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_FileDescriptorSet.Unmarshal(m, b) +} +func (m *FileDescriptorSet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_FileDescriptorSet.Marshal(b, m, deterministic) +} +func (dst *FileDescriptorSet) XXX_Merge(src proto.Message) { + xxx_messageInfo_FileDescriptorSet.Merge(dst, src) +} +func (m *FileDescriptorSet) XXX_Size() int { + return xxx_messageInfo_FileDescriptorSet.Size(m) +} +func (m *FileDescriptorSet) XXX_DiscardUnknown() { + xxx_messageInfo_FileDescriptorSet.DiscardUnknown(m) } -func (m *FileDescriptorSet) Reset() { *m = FileDescriptorSet{} } -func (m *FileDescriptorSet) String() string { return proto.CompactTextString(m) } -func (*FileDescriptorSet) ProtoMessage() {} -func (*FileDescriptorSet) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } +var xxx_messageInfo_FileDescriptorSet proto.InternalMessageInfo func (m *FileDescriptorSet) GetFile() []*FileDescriptorProto { if m != nil { @@ -382,14 +382,35 @@ type FileDescriptorProto struct { SourceCodeInfo *SourceCodeInfo `protobuf:"bytes,9,opt,name=source_code_info,json=sourceCodeInfo" json:"source_code_info,omitempty"` // The syntax of the proto file. // The supported values are "proto2" and "proto3". - Syntax *string `protobuf:"bytes,12,opt,name=syntax" json:"syntax,omitempty"` - XXX_unrecognized []byte `json:"-"` + Syntax *string `protobuf:"bytes,12,opt,name=syntax" json:"syntax,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *FileDescriptorProto) Reset() { *m = FileDescriptorProto{} } +func (m *FileDescriptorProto) String() string { return proto.CompactTextString(m) } +func (*FileDescriptorProto) ProtoMessage() {} +func (*FileDescriptorProto) Descriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{1} +} +func (m *FileDescriptorProto) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_FileDescriptorProto.Unmarshal(m, b) +} +func (m *FileDescriptorProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_FileDescriptorProto.Marshal(b, m, deterministic) +} +func (dst *FileDescriptorProto) XXX_Merge(src proto.Message) { + xxx_messageInfo_FileDescriptorProto.Merge(dst, src) +} +func (m *FileDescriptorProto) XXX_Size() int { + return xxx_messageInfo_FileDescriptorProto.Size(m) +} +func (m *FileDescriptorProto) XXX_DiscardUnknown() { + xxx_messageInfo_FileDescriptorProto.DiscardUnknown(m) } -func (m *FileDescriptorProto) Reset() { *m = FileDescriptorProto{} } -func (m *FileDescriptorProto) String() string { return proto.CompactTextString(m) } -func (*FileDescriptorProto) ProtoMessage() {} -func (*FileDescriptorProto) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } +var xxx_messageInfo_FileDescriptorProto proto.InternalMessageInfo func (m *FileDescriptorProto) GetName() string { if m != nil && m.Name != nil { @@ -488,14 +509,35 @@ type DescriptorProto struct { ReservedRange []*DescriptorProto_ReservedRange `protobuf:"bytes,9,rep,name=reserved_range,json=reservedRange" json:"reserved_range,omitempty"` // Reserved field names, which may not be used by fields in the same message. // A given name may only be reserved once. - ReservedName []string `protobuf:"bytes,10,rep,name=reserved_name,json=reservedName" json:"reserved_name,omitempty"` - XXX_unrecognized []byte `json:"-"` + ReservedName []string `protobuf:"bytes,10,rep,name=reserved_name,json=reservedName" json:"reserved_name,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *DescriptorProto) Reset() { *m = DescriptorProto{} } +func (m *DescriptorProto) String() string { return proto.CompactTextString(m) } +func (*DescriptorProto) ProtoMessage() {} +func (*DescriptorProto) Descriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{2} +} +func (m *DescriptorProto) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_DescriptorProto.Unmarshal(m, b) +} +func (m *DescriptorProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_DescriptorProto.Marshal(b, m, deterministic) +} +func (dst *DescriptorProto) XXX_Merge(src proto.Message) { + xxx_messageInfo_DescriptorProto.Merge(dst, src) +} +func (m *DescriptorProto) XXX_Size() int { + return xxx_messageInfo_DescriptorProto.Size(m) +} +func (m *DescriptorProto) XXX_DiscardUnknown() { + xxx_messageInfo_DescriptorProto.DiscardUnknown(m) } -func (m *DescriptorProto) Reset() { *m = DescriptorProto{} } -func (m *DescriptorProto) String() string { return proto.CompactTextString(m) } -func (*DescriptorProto) ProtoMessage() {} -func (*DescriptorProto) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } +var xxx_messageInfo_DescriptorProto proto.InternalMessageInfo func (m *DescriptorProto) GetName() string { if m != nil && m.Name != nil { @@ -568,19 +610,38 @@ func (m *DescriptorProto) GetReservedName() []string { } type DescriptorProto_ExtensionRange struct { - Start *int32 `protobuf:"varint,1,opt,name=start" json:"start,omitempty"` - End *int32 `protobuf:"varint,2,opt,name=end" json:"end,omitempty"` - Options *ExtensionRangeOptions `protobuf:"bytes,3,opt,name=options" json:"options,omitempty"` - XXX_unrecognized []byte `json:"-"` + Start *int32 `protobuf:"varint,1,opt,name=start" json:"start,omitempty"` + End *int32 `protobuf:"varint,2,opt,name=end" json:"end,omitempty"` + Options *ExtensionRangeOptions `protobuf:"bytes,3,opt,name=options" json:"options,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *DescriptorProto_ExtensionRange) Reset() { *m = DescriptorProto_ExtensionRange{} } func (m *DescriptorProto_ExtensionRange) String() string { return proto.CompactTextString(m) } func (*DescriptorProto_ExtensionRange) ProtoMessage() {} func (*DescriptorProto_ExtensionRange) Descriptor() ([]byte, []int) { - return fileDescriptor0, []int{2, 0} + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{2, 0} +} +func (m *DescriptorProto_ExtensionRange) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_DescriptorProto_ExtensionRange.Unmarshal(m, b) +} +func (m *DescriptorProto_ExtensionRange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_DescriptorProto_ExtensionRange.Marshal(b, m, deterministic) +} +func (dst *DescriptorProto_ExtensionRange) XXX_Merge(src proto.Message) { + xxx_messageInfo_DescriptorProto_ExtensionRange.Merge(dst, src) +} +func (m *DescriptorProto_ExtensionRange) XXX_Size() int { + return xxx_messageInfo_DescriptorProto_ExtensionRange.Size(m) +} +func (m *DescriptorProto_ExtensionRange) XXX_DiscardUnknown() { + xxx_messageInfo_DescriptorProto_ExtensionRange.DiscardUnknown(m) } +var xxx_messageInfo_DescriptorProto_ExtensionRange proto.InternalMessageInfo + func (m *DescriptorProto_ExtensionRange) GetStart() int32 { if m != nil && m.Start != nil { return *m.Start @@ -606,17 +667,36 @@ func (m *DescriptorProto_ExtensionRange) GetOptions() *ExtensionRangeOptions { // fields or extension ranges in the same message. Reserved ranges may // not overlap. type DescriptorProto_ReservedRange struct { - Start *int32 `protobuf:"varint,1,opt,name=start" json:"start,omitempty"` - End *int32 `protobuf:"varint,2,opt,name=end" json:"end,omitempty"` - XXX_unrecognized []byte `json:"-"` + Start *int32 `protobuf:"varint,1,opt,name=start" json:"start,omitempty"` + End *int32 `protobuf:"varint,2,opt,name=end" json:"end,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *DescriptorProto_ReservedRange) Reset() { *m = DescriptorProto_ReservedRange{} } func (m *DescriptorProto_ReservedRange) String() string { return proto.CompactTextString(m) } func (*DescriptorProto_ReservedRange) ProtoMessage() {} func (*DescriptorProto_ReservedRange) Descriptor() ([]byte, []int) { - return fileDescriptor0, []int{2, 1} + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{2, 1} +} +func (m *DescriptorProto_ReservedRange) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_DescriptorProto_ReservedRange.Unmarshal(m, b) +} +func (m *DescriptorProto_ReservedRange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_DescriptorProto_ReservedRange.Marshal(b, m, deterministic) +} +func (dst *DescriptorProto_ReservedRange) XXX_Merge(src proto.Message) { + xxx_messageInfo_DescriptorProto_ReservedRange.Merge(dst, src) +} +func (m *DescriptorProto_ReservedRange) XXX_Size() int { + return xxx_messageInfo_DescriptorProto_ReservedRange.Size(m) } +func (m *DescriptorProto_ReservedRange) XXX_DiscardUnknown() { + xxx_messageInfo_DescriptorProto_ReservedRange.DiscardUnknown(m) +} + +var xxx_messageInfo_DescriptorProto_ReservedRange proto.InternalMessageInfo func (m *DescriptorProto_ReservedRange) GetStart() int32 { if m != nil && m.Start != nil { @@ -635,22 +715,43 @@ func (m *DescriptorProto_ReservedRange) GetEnd() int32 { type ExtensionRangeOptions struct { // The parser stores options it doesn't recognize here. See above. UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` proto.XXX_InternalExtensions `json:"-"` XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *ExtensionRangeOptions) Reset() { *m = ExtensionRangeOptions{} } -func (m *ExtensionRangeOptions) String() string { return proto.CompactTextString(m) } -func (*ExtensionRangeOptions) ProtoMessage() {} -func (*ExtensionRangeOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } +func (m *ExtensionRangeOptions) Reset() { *m = ExtensionRangeOptions{} } +func (m *ExtensionRangeOptions) String() string { return proto.CompactTextString(m) } +func (*ExtensionRangeOptions) ProtoMessage() {} +func (*ExtensionRangeOptions) Descriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{3} +} var extRange_ExtensionRangeOptions = []proto.ExtensionRange{ - {1000, 536870911}, + {Start: 1000, End: 536870911}, } func (*ExtensionRangeOptions) ExtensionRangeArray() []proto.ExtensionRange { return extRange_ExtensionRangeOptions } +func (m *ExtensionRangeOptions) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ExtensionRangeOptions.Unmarshal(m, b) +} +func (m *ExtensionRangeOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ExtensionRangeOptions.Marshal(b, m, deterministic) +} +func (dst *ExtensionRangeOptions) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExtensionRangeOptions.Merge(dst, src) +} +func (m *ExtensionRangeOptions) XXX_Size() int { + return xxx_messageInfo_ExtensionRangeOptions.Size(m) +} +func (m *ExtensionRangeOptions) XXX_DiscardUnknown() { + xxx_messageInfo_ExtensionRangeOptions.DiscardUnknown(m) +} + +var xxx_messageInfo_ExtensionRangeOptions proto.InternalMessageInfo func (m *ExtensionRangeOptions) GetUninterpretedOption() []*UninterpretedOption { if m != nil { @@ -689,15 +790,36 @@ type FieldDescriptorProto struct { // user has set a "json_name" option on this field, that option's value // will be used. Otherwise, it's deduced from the field's name by converting // it to camelCase. - JsonName *string `protobuf:"bytes,10,opt,name=json_name,json=jsonName" json:"json_name,omitempty"` - Options *FieldOptions `protobuf:"bytes,8,opt,name=options" json:"options,omitempty"` - XXX_unrecognized []byte `json:"-"` + JsonName *string `protobuf:"bytes,10,opt,name=json_name,json=jsonName" json:"json_name,omitempty"` + Options *FieldOptions `protobuf:"bytes,8,opt,name=options" json:"options,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *FieldDescriptorProto) Reset() { *m = FieldDescriptorProto{} } -func (m *FieldDescriptorProto) String() string { return proto.CompactTextString(m) } -func (*FieldDescriptorProto) ProtoMessage() {} -func (*FieldDescriptorProto) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } +func (m *FieldDescriptorProto) Reset() { *m = FieldDescriptorProto{} } +func (m *FieldDescriptorProto) String() string { return proto.CompactTextString(m) } +func (*FieldDescriptorProto) ProtoMessage() {} +func (*FieldDescriptorProto) Descriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{4} +} +func (m *FieldDescriptorProto) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_FieldDescriptorProto.Unmarshal(m, b) +} +func (m *FieldDescriptorProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_FieldDescriptorProto.Marshal(b, m, deterministic) +} +func (dst *FieldDescriptorProto) XXX_Merge(src proto.Message) { + xxx_messageInfo_FieldDescriptorProto.Merge(dst, src) +} +func (m *FieldDescriptorProto) XXX_Size() int { + return xxx_messageInfo_FieldDescriptorProto.Size(m) +} +func (m *FieldDescriptorProto) XXX_DiscardUnknown() { + xxx_messageInfo_FieldDescriptorProto.DiscardUnknown(m) +} + +var xxx_messageInfo_FieldDescriptorProto proto.InternalMessageInfo func (m *FieldDescriptorProto) GetName() string { if m != nil && m.Name != nil { @@ -771,15 +893,36 @@ func (m *FieldDescriptorProto) GetOptions() *FieldOptions { // Describes a oneof. type OneofDescriptorProto struct { - Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` - Options *OneofOptions `protobuf:"bytes,2,opt,name=options" json:"options,omitempty"` - XXX_unrecognized []byte `json:"-"` + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Options *OneofOptions `protobuf:"bytes,2,opt,name=options" json:"options,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *OneofDescriptorProto) Reset() { *m = OneofDescriptorProto{} } +func (m *OneofDescriptorProto) String() string { return proto.CompactTextString(m) } +func (*OneofDescriptorProto) ProtoMessage() {} +func (*OneofDescriptorProto) Descriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{5} +} +func (m *OneofDescriptorProto) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_OneofDescriptorProto.Unmarshal(m, b) +} +func (m *OneofDescriptorProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_OneofDescriptorProto.Marshal(b, m, deterministic) +} +func (dst *OneofDescriptorProto) XXX_Merge(src proto.Message) { + xxx_messageInfo_OneofDescriptorProto.Merge(dst, src) +} +func (m *OneofDescriptorProto) XXX_Size() int { + return xxx_messageInfo_OneofDescriptorProto.Size(m) +} +func (m *OneofDescriptorProto) XXX_DiscardUnknown() { + xxx_messageInfo_OneofDescriptorProto.DiscardUnknown(m) } -func (m *OneofDescriptorProto) Reset() { *m = OneofDescriptorProto{} } -func (m *OneofDescriptorProto) String() string { return proto.CompactTextString(m) } -func (*OneofDescriptorProto) ProtoMessage() {} -func (*OneofDescriptorProto) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} } +var xxx_messageInfo_OneofDescriptorProto proto.InternalMessageInfo func (m *OneofDescriptorProto) GetName() string { if m != nil && m.Name != nil { @@ -797,16 +940,44 @@ func (m *OneofDescriptorProto) GetOptions() *OneofOptions { // Describes an enum type. type EnumDescriptorProto struct { - Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` - Value []*EnumValueDescriptorProto `protobuf:"bytes,2,rep,name=value" json:"value,omitempty"` - Options *EnumOptions `protobuf:"bytes,3,opt,name=options" json:"options,omitempty"` - XXX_unrecognized []byte `json:"-"` + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Value []*EnumValueDescriptorProto `protobuf:"bytes,2,rep,name=value" json:"value,omitempty"` + Options *EnumOptions `protobuf:"bytes,3,opt,name=options" json:"options,omitempty"` + // Range of reserved numeric values. Reserved numeric values may not be used + // by enum values in the same enum declaration. Reserved ranges may not + // overlap. + ReservedRange []*EnumDescriptorProto_EnumReservedRange `protobuf:"bytes,4,rep,name=reserved_range,json=reservedRange" json:"reserved_range,omitempty"` + // Reserved enum value names, which may not be reused. A given name may only + // be reserved once. + ReservedName []string `protobuf:"bytes,5,rep,name=reserved_name,json=reservedName" json:"reserved_name,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *EnumDescriptorProto) Reset() { *m = EnumDescriptorProto{} } +func (m *EnumDescriptorProto) String() string { return proto.CompactTextString(m) } +func (*EnumDescriptorProto) ProtoMessage() {} +func (*EnumDescriptorProto) Descriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{6} +} +func (m *EnumDescriptorProto) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_EnumDescriptorProto.Unmarshal(m, b) +} +func (m *EnumDescriptorProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_EnumDescriptorProto.Marshal(b, m, deterministic) +} +func (dst *EnumDescriptorProto) XXX_Merge(src proto.Message) { + xxx_messageInfo_EnumDescriptorProto.Merge(dst, src) +} +func (m *EnumDescriptorProto) XXX_Size() int { + return xxx_messageInfo_EnumDescriptorProto.Size(m) +} +func (m *EnumDescriptorProto) XXX_DiscardUnknown() { + xxx_messageInfo_EnumDescriptorProto.DiscardUnknown(m) } -func (m *EnumDescriptorProto) Reset() { *m = EnumDescriptorProto{} } -func (m *EnumDescriptorProto) String() string { return proto.CompactTextString(m) } -func (*EnumDescriptorProto) ProtoMessage() {} -func (*EnumDescriptorProto) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} } +var xxx_messageInfo_EnumDescriptorProto proto.InternalMessageInfo func (m *EnumDescriptorProto) GetName() string { if m != nil && m.Name != nil { @@ -829,18 +1000,105 @@ func (m *EnumDescriptorProto) GetOptions() *EnumOptions { return nil } +func (m *EnumDescriptorProto) GetReservedRange() []*EnumDescriptorProto_EnumReservedRange { + if m != nil { + return m.ReservedRange + } + return nil +} + +func (m *EnumDescriptorProto) GetReservedName() []string { + if m != nil { + return m.ReservedName + } + return nil +} + +// Range of reserved numeric values. Reserved values may not be used by +// entries in the same enum. Reserved ranges may not overlap. +// +// Note that this is distinct from DescriptorProto.ReservedRange in that it +// is inclusive such that it can appropriately represent the entire int32 +// domain. +type EnumDescriptorProto_EnumReservedRange struct { + Start *int32 `protobuf:"varint,1,opt,name=start" json:"start,omitempty"` + End *int32 `protobuf:"varint,2,opt,name=end" json:"end,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *EnumDescriptorProto_EnumReservedRange) Reset() { *m = EnumDescriptorProto_EnumReservedRange{} } +func (m *EnumDescriptorProto_EnumReservedRange) String() string { return proto.CompactTextString(m) } +func (*EnumDescriptorProto_EnumReservedRange) ProtoMessage() {} +func (*EnumDescriptorProto_EnumReservedRange) Descriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{6, 0} +} +func (m *EnumDescriptorProto_EnumReservedRange) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_EnumDescriptorProto_EnumReservedRange.Unmarshal(m, b) +} +func (m *EnumDescriptorProto_EnumReservedRange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_EnumDescriptorProto_EnumReservedRange.Marshal(b, m, deterministic) +} +func (dst *EnumDescriptorProto_EnumReservedRange) XXX_Merge(src proto.Message) { + xxx_messageInfo_EnumDescriptorProto_EnumReservedRange.Merge(dst, src) +} +func (m *EnumDescriptorProto_EnumReservedRange) XXX_Size() int { + return xxx_messageInfo_EnumDescriptorProto_EnumReservedRange.Size(m) +} +func (m *EnumDescriptorProto_EnumReservedRange) XXX_DiscardUnknown() { + xxx_messageInfo_EnumDescriptorProto_EnumReservedRange.DiscardUnknown(m) +} + +var xxx_messageInfo_EnumDescriptorProto_EnumReservedRange proto.InternalMessageInfo + +func (m *EnumDescriptorProto_EnumReservedRange) GetStart() int32 { + if m != nil && m.Start != nil { + return *m.Start + } + return 0 +} + +func (m *EnumDescriptorProto_EnumReservedRange) GetEnd() int32 { + if m != nil && m.End != nil { + return *m.End + } + return 0 +} + // Describes a value within an enum. type EnumValueDescriptorProto struct { - Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` - Number *int32 `protobuf:"varint,2,opt,name=number" json:"number,omitempty"` - Options *EnumValueOptions `protobuf:"bytes,3,opt,name=options" json:"options,omitempty"` - XXX_unrecognized []byte `json:"-"` + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Number *int32 `protobuf:"varint,2,opt,name=number" json:"number,omitempty"` + Options *EnumValueOptions `protobuf:"bytes,3,opt,name=options" json:"options,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *EnumValueDescriptorProto) Reset() { *m = EnumValueDescriptorProto{} } -func (m *EnumValueDescriptorProto) String() string { return proto.CompactTextString(m) } -func (*EnumValueDescriptorProto) ProtoMessage() {} -func (*EnumValueDescriptorProto) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} } +func (m *EnumValueDescriptorProto) Reset() { *m = EnumValueDescriptorProto{} } +func (m *EnumValueDescriptorProto) String() string { return proto.CompactTextString(m) } +func (*EnumValueDescriptorProto) ProtoMessage() {} +func (*EnumValueDescriptorProto) Descriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{7} +} +func (m *EnumValueDescriptorProto) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_EnumValueDescriptorProto.Unmarshal(m, b) +} +func (m *EnumValueDescriptorProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_EnumValueDescriptorProto.Marshal(b, m, deterministic) +} +func (dst *EnumValueDescriptorProto) XXX_Merge(src proto.Message) { + xxx_messageInfo_EnumValueDescriptorProto.Merge(dst, src) +} +func (m *EnumValueDescriptorProto) XXX_Size() int { + return xxx_messageInfo_EnumValueDescriptorProto.Size(m) +} +func (m *EnumValueDescriptorProto) XXX_DiscardUnknown() { + xxx_messageInfo_EnumValueDescriptorProto.DiscardUnknown(m) +} + +var xxx_messageInfo_EnumValueDescriptorProto proto.InternalMessageInfo func (m *EnumValueDescriptorProto) GetName() string { if m != nil && m.Name != nil { @@ -865,16 +1123,37 @@ func (m *EnumValueDescriptorProto) GetOptions() *EnumValueOptions { // Describes a service. type ServiceDescriptorProto struct { - Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` - Method []*MethodDescriptorProto `protobuf:"bytes,2,rep,name=method" json:"method,omitempty"` - Options *ServiceOptions `protobuf:"bytes,3,opt,name=options" json:"options,omitempty"` - XXX_unrecognized []byte `json:"-"` + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Method []*MethodDescriptorProto `protobuf:"bytes,2,rep,name=method" json:"method,omitempty"` + Options *ServiceOptions `protobuf:"bytes,3,opt,name=options" json:"options,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *ServiceDescriptorProto) Reset() { *m = ServiceDescriptorProto{} } -func (m *ServiceDescriptorProto) String() string { return proto.CompactTextString(m) } -func (*ServiceDescriptorProto) ProtoMessage() {} -func (*ServiceDescriptorProto) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} } +func (m *ServiceDescriptorProto) Reset() { *m = ServiceDescriptorProto{} } +func (m *ServiceDescriptorProto) String() string { return proto.CompactTextString(m) } +func (*ServiceDescriptorProto) ProtoMessage() {} +func (*ServiceDescriptorProto) Descriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{8} +} +func (m *ServiceDescriptorProto) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ServiceDescriptorProto.Unmarshal(m, b) +} +func (m *ServiceDescriptorProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ServiceDescriptorProto.Marshal(b, m, deterministic) +} +func (dst *ServiceDescriptorProto) XXX_Merge(src proto.Message) { + xxx_messageInfo_ServiceDescriptorProto.Merge(dst, src) +} +func (m *ServiceDescriptorProto) XXX_Size() int { + return xxx_messageInfo_ServiceDescriptorProto.Size(m) +} +func (m *ServiceDescriptorProto) XXX_DiscardUnknown() { + xxx_messageInfo_ServiceDescriptorProto.DiscardUnknown(m) +} + +var xxx_messageInfo_ServiceDescriptorProto proto.InternalMessageInfo func (m *ServiceDescriptorProto) GetName() string { if m != nil && m.Name != nil { @@ -908,14 +1187,35 @@ type MethodDescriptorProto struct { // Identifies if client streams multiple client messages ClientStreaming *bool `protobuf:"varint,5,opt,name=client_streaming,json=clientStreaming,def=0" json:"client_streaming,omitempty"` // Identifies if server streams multiple server messages - ServerStreaming *bool `protobuf:"varint,6,opt,name=server_streaming,json=serverStreaming,def=0" json:"server_streaming,omitempty"` - XXX_unrecognized []byte `json:"-"` + ServerStreaming *bool `protobuf:"varint,6,opt,name=server_streaming,json=serverStreaming,def=0" json:"server_streaming,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *MethodDescriptorProto) Reset() { *m = MethodDescriptorProto{} } +func (m *MethodDescriptorProto) String() string { return proto.CompactTextString(m) } +func (*MethodDescriptorProto) ProtoMessage() {} +func (*MethodDescriptorProto) Descriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{9} +} +func (m *MethodDescriptorProto) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_MethodDescriptorProto.Unmarshal(m, b) +} +func (m *MethodDescriptorProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_MethodDescriptorProto.Marshal(b, m, deterministic) +} +func (dst *MethodDescriptorProto) XXX_Merge(src proto.Message) { + xxx_messageInfo_MethodDescriptorProto.Merge(dst, src) +} +func (m *MethodDescriptorProto) XXX_Size() int { + return xxx_messageInfo_MethodDescriptorProto.Size(m) +} +func (m *MethodDescriptorProto) XXX_DiscardUnknown() { + xxx_messageInfo_MethodDescriptorProto.DiscardUnknown(m) } -func (m *MethodDescriptorProto) Reset() { *m = MethodDescriptorProto{} } -func (m *MethodDescriptorProto) String() string { return proto.CompactTextString(m) } -func (*MethodDescriptorProto) ProtoMessage() {} -func (*MethodDescriptorProto) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} } +var xxx_messageInfo_MethodDescriptorProto proto.InternalMessageInfo const Default_MethodDescriptorProto_ClientStreaming bool = false const Default_MethodDescriptorProto_ServerStreaming bool = false @@ -982,7 +1282,7 @@ type FileOptions struct { // top-level extensions defined in the file. JavaMultipleFiles *bool `protobuf:"varint,10,opt,name=java_multiple_files,json=javaMultipleFiles,def=0" json:"java_multiple_files,omitempty"` // This option does nothing. - JavaGenerateEqualsAndHash *bool `protobuf:"varint,20,opt,name=java_generate_equals_and_hash,json=javaGenerateEqualsAndHash" json:"java_generate_equals_and_hash,omitempty"` + JavaGenerateEqualsAndHash *bool `protobuf:"varint,20,opt,name=java_generate_equals_and_hash,json=javaGenerateEqualsAndHash" json:"java_generate_equals_and_hash,omitempty"` // Deprecated: Do not use. // If set true, then the Java2 code generator will generate code that // throws an exception whenever an attempt is made to assign a non-UTF-8 // byte sequence to a string field. @@ -1036,24 +1336,46 @@ type FileOptions struct { // is empty. When this option is empty, the package name will be used for // determining the namespace. PhpNamespace *string `protobuf:"bytes,41,opt,name=php_namespace,json=phpNamespace" json:"php_namespace,omitempty"` - // The parser stores options it doesn't recognize here. See above. + // The parser stores options it doesn't recognize here. + // See the documentation for the "Options" section above. UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` proto.XXX_InternalExtensions `json:"-"` XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *FileOptions) Reset() { *m = FileOptions{} } -func (m *FileOptions) String() string { return proto.CompactTextString(m) } -func (*FileOptions) ProtoMessage() {} -func (*FileOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} } +func (m *FileOptions) Reset() { *m = FileOptions{} } +func (m *FileOptions) String() string { return proto.CompactTextString(m) } +func (*FileOptions) ProtoMessage() {} +func (*FileOptions) Descriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{10} +} var extRange_FileOptions = []proto.ExtensionRange{ - {1000, 536870911}, + {Start: 1000, End: 536870911}, } func (*FileOptions) ExtensionRangeArray() []proto.ExtensionRange { return extRange_FileOptions } +func (m *FileOptions) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_FileOptions.Unmarshal(m, b) +} +func (m *FileOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_FileOptions.Marshal(b, m, deterministic) +} +func (dst *FileOptions) XXX_Merge(src proto.Message) { + xxx_messageInfo_FileOptions.Merge(dst, src) +} +func (m *FileOptions) XXX_Size() int { + return xxx_messageInfo_FileOptions.Size(m) +} +func (m *FileOptions) XXX_DiscardUnknown() { + xxx_messageInfo_FileOptions.DiscardUnknown(m) +} + +var xxx_messageInfo_FileOptions proto.InternalMessageInfo const Default_FileOptions_JavaMultipleFiles bool = false const Default_FileOptions_JavaStringCheckUtf8 bool = false @@ -1086,6 +1408,7 @@ func (m *FileOptions) GetJavaMultipleFiles() bool { return Default_FileOptions_JavaMultipleFiles } +// Deprecated: Do not use. func (m *FileOptions) GetJavaGenerateEqualsAndHash() bool { if m != nil && m.JavaGenerateEqualsAndHash != nil { return *m.JavaGenerateEqualsAndHash @@ -1251,22 +1574,43 @@ type MessageOptions struct { MapEntry *bool `protobuf:"varint,7,opt,name=map_entry,json=mapEntry" json:"map_entry,omitempty"` // The parser stores options it doesn't recognize here. See above. UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` proto.XXX_InternalExtensions `json:"-"` XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *MessageOptions) Reset() { *m = MessageOptions{} } -func (m *MessageOptions) String() string { return proto.CompactTextString(m) } -func (*MessageOptions) ProtoMessage() {} -func (*MessageOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} } +func (m *MessageOptions) Reset() { *m = MessageOptions{} } +func (m *MessageOptions) String() string { return proto.CompactTextString(m) } +func (*MessageOptions) ProtoMessage() {} +func (*MessageOptions) Descriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{11} +} var extRange_MessageOptions = []proto.ExtensionRange{ - {1000, 536870911}, + {Start: 1000, End: 536870911}, } func (*MessageOptions) ExtensionRangeArray() []proto.ExtensionRange { return extRange_MessageOptions } +func (m *MessageOptions) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_MessageOptions.Unmarshal(m, b) +} +func (m *MessageOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_MessageOptions.Marshal(b, m, deterministic) +} +func (dst *MessageOptions) XXX_Merge(src proto.Message) { + xxx_messageInfo_MessageOptions.Merge(dst, src) +} +func (m *MessageOptions) XXX_Size() int { + return xxx_messageInfo_MessageOptions.Size(m) +} +func (m *MessageOptions) XXX_DiscardUnknown() { + xxx_messageInfo_MessageOptions.DiscardUnknown(m) +} + +var xxx_messageInfo_MessageOptions proto.InternalMessageInfo const Default_MessageOptions_MessageSetWireFormat bool = false const Default_MessageOptions_NoStandardDescriptorAccessor bool = false @@ -1369,22 +1713,43 @@ type FieldOptions struct { Weak *bool `protobuf:"varint,10,opt,name=weak,def=0" json:"weak,omitempty"` // The parser stores options it doesn't recognize here. See above. UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` proto.XXX_InternalExtensions `json:"-"` XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *FieldOptions) Reset() { *m = FieldOptions{} } -func (m *FieldOptions) String() string { return proto.CompactTextString(m) } -func (*FieldOptions) ProtoMessage() {} -func (*FieldOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{12} } +func (m *FieldOptions) Reset() { *m = FieldOptions{} } +func (m *FieldOptions) String() string { return proto.CompactTextString(m) } +func (*FieldOptions) ProtoMessage() {} +func (*FieldOptions) Descriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{12} +} var extRange_FieldOptions = []proto.ExtensionRange{ - {1000, 536870911}, + {Start: 1000, End: 536870911}, } func (*FieldOptions) ExtensionRangeArray() []proto.ExtensionRange { return extRange_FieldOptions } +func (m *FieldOptions) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_FieldOptions.Unmarshal(m, b) +} +func (m *FieldOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_FieldOptions.Marshal(b, m, deterministic) +} +func (dst *FieldOptions) XXX_Merge(src proto.Message) { + xxx_messageInfo_FieldOptions.Merge(dst, src) +} +func (m *FieldOptions) XXX_Size() int { + return xxx_messageInfo_FieldOptions.Size(m) +} +func (m *FieldOptions) XXX_DiscardUnknown() { + xxx_messageInfo_FieldOptions.DiscardUnknown(m) +} + +var xxx_messageInfo_FieldOptions proto.InternalMessageInfo const Default_FieldOptions_Ctype FieldOptions_CType = FieldOptions_STRING const Default_FieldOptions_Jstype FieldOptions_JSType = FieldOptions_JS_NORMAL @@ -1444,22 +1809,43 @@ func (m *FieldOptions) GetUninterpretedOption() []*UninterpretedOption { type OneofOptions struct { // The parser stores options it doesn't recognize here. See above. UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` proto.XXX_InternalExtensions `json:"-"` XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *OneofOptions) Reset() { *m = OneofOptions{} } -func (m *OneofOptions) String() string { return proto.CompactTextString(m) } -func (*OneofOptions) ProtoMessage() {} -func (*OneofOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{13} } +func (m *OneofOptions) Reset() { *m = OneofOptions{} } +func (m *OneofOptions) String() string { return proto.CompactTextString(m) } +func (*OneofOptions) ProtoMessage() {} +func (*OneofOptions) Descriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{13} +} var extRange_OneofOptions = []proto.ExtensionRange{ - {1000, 536870911}, + {Start: 1000, End: 536870911}, } func (*OneofOptions) ExtensionRangeArray() []proto.ExtensionRange { return extRange_OneofOptions } +func (m *OneofOptions) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_OneofOptions.Unmarshal(m, b) +} +func (m *OneofOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_OneofOptions.Marshal(b, m, deterministic) +} +func (dst *OneofOptions) XXX_Merge(src proto.Message) { + xxx_messageInfo_OneofOptions.Merge(dst, src) +} +func (m *OneofOptions) XXX_Size() int { + return xxx_messageInfo_OneofOptions.Size(m) +} +func (m *OneofOptions) XXX_DiscardUnknown() { + xxx_messageInfo_OneofOptions.DiscardUnknown(m) +} + +var xxx_messageInfo_OneofOptions proto.InternalMessageInfo func (m *OneofOptions) GetUninterpretedOption() []*UninterpretedOption { if m != nil { @@ -1479,22 +1865,43 @@ type EnumOptions struct { Deprecated *bool `protobuf:"varint,3,opt,name=deprecated,def=0" json:"deprecated,omitempty"` // The parser stores options it doesn't recognize here. See above. UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` proto.XXX_InternalExtensions `json:"-"` XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *EnumOptions) Reset() { *m = EnumOptions{} } -func (m *EnumOptions) String() string { return proto.CompactTextString(m) } -func (*EnumOptions) ProtoMessage() {} -func (*EnumOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{14} } +func (m *EnumOptions) Reset() { *m = EnumOptions{} } +func (m *EnumOptions) String() string { return proto.CompactTextString(m) } +func (*EnumOptions) ProtoMessage() {} +func (*EnumOptions) Descriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{14} +} var extRange_EnumOptions = []proto.ExtensionRange{ - {1000, 536870911}, + {Start: 1000, End: 536870911}, } func (*EnumOptions) ExtensionRangeArray() []proto.ExtensionRange { return extRange_EnumOptions } +func (m *EnumOptions) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_EnumOptions.Unmarshal(m, b) +} +func (m *EnumOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_EnumOptions.Marshal(b, m, deterministic) +} +func (dst *EnumOptions) XXX_Merge(src proto.Message) { + xxx_messageInfo_EnumOptions.Merge(dst, src) +} +func (m *EnumOptions) XXX_Size() int { + return xxx_messageInfo_EnumOptions.Size(m) +} +func (m *EnumOptions) XXX_DiscardUnknown() { + xxx_messageInfo_EnumOptions.DiscardUnknown(m) +} + +var xxx_messageInfo_EnumOptions proto.InternalMessageInfo const Default_EnumOptions_Deprecated bool = false @@ -1527,22 +1934,43 @@ type EnumValueOptions struct { Deprecated *bool `protobuf:"varint,1,opt,name=deprecated,def=0" json:"deprecated,omitempty"` // The parser stores options it doesn't recognize here. See above. UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` proto.XXX_InternalExtensions `json:"-"` XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *EnumValueOptions) Reset() { *m = EnumValueOptions{} } -func (m *EnumValueOptions) String() string { return proto.CompactTextString(m) } -func (*EnumValueOptions) ProtoMessage() {} -func (*EnumValueOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{15} } +func (m *EnumValueOptions) Reset() { *m = EnumValueOptions{} } +func (m *EnumValueOptions) String() string { return proto.CompactTextString(m) } +func (*EnumValueOptions) ProtoMessage() {} +func (*EnumValueOptions) Descriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{15} +} var extRange_EnumValueOptions = []proto.ExtensionRange{ - {1000, 536870911}, + {Start: 1000, End: 536870911}, } func (*EnumValueOptions) ExtensionRangeArray() []proto.ExtensionRange { return extRange_EnumValueOptions } +func (m *EnumValueOptions) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_EnumValueOptions.Unmarshal(m, b) +} +func (m *EnumValueOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_EnumValueOptions.Marshal(b, m, deterministic) +} +func (dst *EnumValueOptions) XXX_Merge(src proto.Message) { + xxx_messageInfo_EnumValueOptions.Merge(dst, src) +} +func (m *EnumValueOptions) XXX_Size() int { + return xxx_messageInfo_EnumValueOptions.Size(m) +} +func (m *EnumValueOptions) XXX_DiscardUnknown() { + xxx_messageInfo_EnumValueOptions.DiscardUnknown(m) +} + +var xxx_messageInfo_EnumValueOptions proto.InternalMessageInfo const Default_EnumValueOptions_Deprecated bool = false @@ -1568,22 +1996,43 @@ type ServiceOptions struct { Deprecated *bool `protobuf:"varint,33,opt,name=deprecated,def=0" json:"deprecated,omitempty"` // The parser stores options it doesn't recognize here. See above. UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` proto.XXX_InternalExtensions `json:"-"` XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *ServiceOptions) Reset() { *m = ServiceOptions{} } -func (m *ServiceOptions) String() string { return proto.CompactTextString(m) } -func (*ServiceOptions) ProtoMessage() {} -func (*ServiceOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{16} } +func (m *ServiceOptions) Reset() { *m = ServiceOptions{} } +func (m *ServiceOptions) String() string { return proto.CompactTextString(m) } +func (*ServiceOptions) ProtoMessage() {} +func (*ServiceOptions) Descriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{16} +} var extRange_ServiceOptions = []proto.ExtensionRange{ - {1000, 536870911}, + {Start: 1000, End: 536870911}, } func (*ServiceOptions) ExtensionRangeArray() []proto.ExtensionRange { return extRange_ServiceOptions } +func (m *ServiceOptions) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ServiceOptions.Unmarshal(m, b) +} +func (m *ServiceOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ServiceOptions.Marshal(b, m, deterministic) +} +func (dst *ServiceOptions) XXX_Merge(src proto.Message) { + xxx_messageInfo_ServiceOptions.Merge(dst, src) +} +func (m *ServiceOptions) XXX_Size() int { + return xxx_messageInfo_ServiceOptions.Size(m) +} +func (m *ServiceOptions) XXX_DiscardUnknown() { + xxx_messageInfo_ServiceOptions.DiscardUnknown(m) +} + +var xxx_messageInfo_ServiceOptions proto.InternalMessageInfo const Default_ServiceOptions_Deprecated bool = false @@ -1610,22 +2059,43 @@ type MethodOptions struct { IdempotencyLevel *MethodOptions_IdempotencyLevel `protobuf:"varint,34,opt,name=idempotency_level,json=idempotencyLevel,enum=google.protobuf.MethodOptions_IdempotencyLevel,def=0" json:"idempotency_level,omitempty"` // The parser stores options it doesn't recognize here. See above. UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` proto.XXX_InternalExtensions `json:"-"` XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *MethodOptions) Reset() { *m = MethodOptions{} } -func (m *MethodOptions) String() string { return proto.CompactTextString(m) } -func (*MethodOptions) ProtoMessage() {} -func (*MethodOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{17} } +func (m *MethodOptions) Reset() { *m = MethodOptions{} } +func (m *MethodOptions) String() string { return proto.CompactTextString(m) } +func (*MethodOptions) ProtoMessage() {} +func (*MethodOptions) Descriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{17} +} var extRange_MethodOptions = []proto.ExtensionRange{ - {1000, 536870911}, + {Start: 1000, End: 536870911}, } func (*MethodOptions) ExtensionRangeArray() []proto.ExtensionRange { return extRange_MethodOptions } +func (m *MethodOptions) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_MethodOptions.Unmarshal(m, b) +} +func (m *MethodOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_MethodOptions.Marshal(b, m, deterministic) +} +func (dst *MethodOptions) XXX_Merge(src proto.Message) { + xxx_messageInfo_MethodOptions.Merge(dst, src) +} +func (m *MethodOptions) XXX_Size() int { + return xxx_messageInfo_MethodOptions.Size(m) +} +func (m *MethodOptions) XXX_DiscardUnknown() { + xxx_messageInfo_MethodOptions.DiscardUnknown(m) +} + +var xxx_messageInfo_MethodOptions proto.InternalMessageInfo const Default_MethodOptions_Deprecated bool = false const Default_MethodOptions_IdempotencyLevel MethodOptions_IdempotencyLevel = MethodOptions_IDEMPOTENCY_UNKNOWN @@ -1661,19 +2131,40 @@ type UninterpretedOption struct { Name []*UninterpretedOption_NamePart `protobuf:"bytes,2,rep,name=name" json:"name,omitempty"` // The value of the uninterpreted option, in whatever type the tokenizer // identified it as during parsing. Exactly one of these should be set. - IdentifierValue *string `protobuf:"bytes,3,opt,name=identifier_value,json=identifierValue" json:"identifier_value,omitempty"` - PositiveIntValue *uint64 `protobuf:"varint,4,opt,name=positive_int_value,json=positiveIntValue" json:"positive_int_value,omitempty"` - NegativeIntValue *int64 `protobuf:"varint,5,opt,name=negative_int_value,json=negativeIntValue" json:"negative_int_value,omitempty"` - DoubleValue *float64 `protobuf:"fixed64,6,opt,name=double_value,json=doubleValue" json:"double_value,omitempty"` - StringValue []byte `protobuf:"bytes,7,opt,name=string_value,json=stringValue" json:"string_value,omitempty"` - AggregateValue *string `protobuf:"bytes,8,opt,name=aggregate_value,json=aggregateValue" json:"aggregate_value,omitempty"` - XXX_unrecognized []byte `json:"-"` + IdentifierValue *string `protobuf:"bytes,3,opt,name=identifier_value,json=identifierValue" json:"identifier_value,omitempty"` + PositiveIntValue *uint64 `protobuf:"varint,4,opt,name=positive_int_value,json=positiveIntValue" json:"positive_int_value,omitempty"` + NegativeIntValue *int64 `protobuf:"varint,5,opt,name=negative_int_value,json=negativeIntValue" json:"negative_int_value,omitempty"` + DoubleValue *float64 `protobuf:"fixed64,6,opt,name=double_value,json=doubleValue" json:"double_value,omitempty"` + StringValue []byte `protobuf:"bytes,7,opt,name=string_value,json=stringValue" json:"string_value,omitempty"` + AggregateValue *string `protobuf:"bytes,8,opt,name=aggregate_value,json=aggregateValue" json:"aggregate_value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *UninterpretedOption) Reset() { *m = UninterpretedOption{} } -func (m *UninterpretedOption) String() string { return proto.CompactTextString(m) } -func (*UninterpretedOption) ProtoMessage() {} -func (*UninterpretedOption) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{18} } +func (m *UninterpretedOption) Reset() { *m = UninterpretedOption{} } +func (m *UninterpretedOption) String() string { return proto.CompactTextString(m) } +func (*UninterpretedOption) ProtoMessage() {} +func (*UninterpretedOption) Descriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{18} +} +func (m *UninterpretedOption) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_UninterpretedOption.Unmarshal(m, b) +} +func (m *UninterpretedOption) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_UninterpretedOption.Marshal(b, m, deterministic) +} +func (dst *UninterpretedOption) XXX_Merge(src proto.Message) { + xxx_messageInfo_UninterpretedOption.Merge(dst, src) +} +func (m *UninterpretedOption) XXX_Size() int { + return xxx_messageInfo_UninterpretedOption.Size(m) +} +func (m *UninterpretedOption) XXX_DiscardUnknown() { + xxx_messageInfo_UninterpretedOption.DiscardUnknown(m) +} + +var xxx_messageInfo_UninterpretedOption proto.InternalMessageInfo func (m *UninterpretedOption) GetName() []*UninterpretedOption_NamePart { if m != nil { @@ -1730,18 +2221,37 @@ func (m *UninterpretedOption) GetAggregateValue() string { // E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents // "foo.(bar.baz).qux". type UninterpretedOption_NamePart struct { - NamePart *string `protobuf:"bytes,1,req,name=name_part,json=namePart" json:"name_part,omitempty"` - IsExtension *bool `protobuf:"varint,2,req,name=is_extension,json=isExtension" json:"is_extension,omitempty"` - XXX_unrecognized []byte `json:"-"` + NamePart *string `protobuf:"bytes,1,req,name=name_part,json=namePart" json:"name_part,omitempty"` + IsExtension *bool `protobuf:"varint,2,req,name=is_extension,json=isExtension" json:"is_extension,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *UninterpretedOption_NamePart) Reset() { *m = UninterpretedOption_NamePart{} } func (m *UninterpretedOption_NamePart) String() string { return proto.CompactTextString(m) } func (*UninterpretedOption_NamePart) ProtoMessage() {} func (*UninterpretedOption_NamePart) Descriptor() ([]byte, []int) { - return fileDescriptor0, []int{18, 0} + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{18, 0} +} +func (m *UninterpretedOption_NamePart) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_UninterpretedOption_NamePart.Unmarshal(m, b) +} +func (m *UninterpretedOption_NamePart) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_UninterpretedOption_NamePart.Marshal(b, m, deterministic) +} +func (dst *UninterpretedOption_NamePart) XXX_Merge(src proto.Message) { + xxx_messageInfo_UninterpretedOption_NamePart.Merge(dst, src) +} +func (m *UninterpretedOption_NamePart) XXX_Size() int { + return xxx_messageInfo_UninterpretedOption_NamePart.Size(m) +} +func (m *UninterpretedOption_NamePart) XXX_DiscardUnknown() { + xxx_messageInfo_UninterpretedOption_NamePart.DiscardUnknown(m) } +var xxx_messageInfo_UninterpretedOption_NamePart proto.InternalMessageInfo + func (m *UninterpretedOption_NamePart) GetNamePart() string { if m != nil && m.NamePart != nil { return *m.NamePart @@ -1802,14 +2312,35 @@ type SourceCodeInfo struct { // - Code which tries to interpret locations should probably be designed to // ignore those that it doesn't understand, as more types of locations could // be recorded in the future. - Location []*SourceCodeInfo_Location `protobuf:"bytes,1,rep,name=location" json:"location,omitempty"` - XXX_unrecognized []byte `json:"-"` + Location []*SourceCodeInfo_Location `protobuf:"bytes,1,rep,name=location" json:"location,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SourceCodeInfo) Reset() { *m = SourceCodeInfo{} } +func (m *SourceCodeInfo) String() string { return proto.CompactTextString(m) } +func (*SourceCodeInfo) ProtoMessage() {} +func (*SourceCodeInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{19} +} +func (m *SourceCodeInfo) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SourceCodeInfo.Unmarshal(m, b) +} +func (m *SourceCodeInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SourceCodeInfo.Marshal(b, m, deterministic) +} +func (dst *SourceCodeInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_SourceCodeInfo.Merge(dst, src) +} +func (m *SourceCodeInfo) XXX_Size() int { + return xxx_messageInfo_SourceCodeInfo.Size(m) +} +func (m *SourceCodeInfo) XXX_DiscardUnknown() { + xxx_messageInfo_SourceCodeInfo.DiscardUnknown(m) } -func (m *SourceCodeInfo) Reset() { *m = SourceCodeInfo{} } -func (m *SourceCodeInfo) String() string { return proto.CompactTextString(m) } -func (*SourceCodeInfo) ProtoMessage() {} -func (*SourceCodeInfo) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{19} } +var xxx_messageInfo_SourceCodeInfo proto.InternalMessageInfo func (m *SourceCodeInfo) GetLocation() []*SourceCodeInfo_Location { if m != nil { @@ -1899,13 +2430,34 @@ type SourceCodeInfo_Location struct { LeadingComments *string `protobuf:"bytes,3,opt,name=leading_comments,json=leadingComments" json:"leading_comments,omitempty"` TrailingComments *string `protobuf:"bytes,4,opt,name=trailing_comments,json=trailingComments" json:"trailing_comments,omitempty"` LeadingDetachedComments []string `protobuf:"bytes,6,rep,name=leading_detached_comments,json=leadingDetachedComments" json:"leading_detached_comments,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SourceCodeInfo_Location) Reset() { *m = SourceCodeInfo_Location{} } +func (m *SourceCodeInfo_Location) String() string { return proto.CompactTextString(m) } +func (*SourceCodeInfo_Location) ProtoMessage() {} +func (*SourceCodeInfo_Location) Descriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{19, 0} +} +func (m *SourceCodeInfo_Location) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SourceCodeInfo_Location.Unmarshal(m, b) +} +func (m *SourceCodeInfo_Location) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SourceCodeInfo_Location.Marshal(b, m, deterministic) +} +func (dst *SourceCodeInfo_Location) XXX_Merge(src proto.Message) { + xxx_messageInfo_SourceCodeInfo_Location.Merge(dst, src) +} +func (m *SourceCodeInfo_Location) XXX_Size() int { + return xxx_messageInfo_SourceCodeInfo_Location.Size(m) +} +func (m *SourceCodeInfo_Location) XXX_DiscardUnknown() { + xxx_messageInfo_SourceCodeInfo_Location.DiscardUnknown(m) } -func (m *SourceCodeInfo_Location) Reset() { *m = SourceCodeInfo_Location{} } -func (m *SourceCodeInfo_Location) String() string { return proto.CompactTextString(m) } -func (*SourceCodeInfo_Location) ProtoMessage() {} -func (*SourceCodeInfo_Location) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{19, 0} } +var xxx_messageInfo_SourceCodeInfo_Location proto.InternalMessageInfo func (m *SourceCodeInfo_Location) GetPath() []int32 { if m != nil { @@ -1948,14 +2500,35 @@ func (m *SourceCodeInfo_Location) GetLeadingDetachedComments() []string { type GeneratedCodeInfo struct { // An Annotation connects some span of text in generated code to an element // of its generating .proto file. - Annotation []*GeneratedCodeInfo_Annotation `protobuf:"bytes,1,rep,name=annotation" json:"annotation,omitempty"` - XXX_unrecognized []byte `json:"-"` + Annotation []*GeneratedCodeInfo_Annotation `protobuf:"bytes,1,rep,name=annotation" json:"annotation,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *GeneratedCodeInfo) Reset() { *m = GeneratedCodeInfo{} } -func (m *GeneratedCodeInfo) String() string { return proto.CompactTextString(m) } -func (*GeneratedCodeInfo) ProtoMessage() {} -func (*GeneratedCodeInfo) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{20} } +func (m *GeneratedCodeInfo) Reset() { *m = GeneratedCodeInfo{} } +func (m *GeneratedCodeInfo) String() string { return proto.CompactTextString(m) } +func (*GeneratedCodeInfo) ProtoMessage() {} +func (*GeneratedCodeInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{20} +} +func (m *GeneratedCodeInfo) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GeneratedCodeInfo.Unmarshal(m, b) +} +func (m *GeneratedCodeInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GeneratedCodeInfo.Marshal(b, m, deterministic) +} +func (dst *GeneratedCodeInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_GeneratedCodeInfo.Merge(dst, src) +} +func (m *GeneratedCodeInfo) XXX_Size() int { + return xxx_messageInfo_GeneratedCodeInfo.Size(m) +} +func (m *GeneratedCodeInfo) XXX_DiscardUnknown() { + xxx_messageInfo_GeneratedCodeInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_GeneratedCodeInfo proto.InternalMessageInfo func (m *GeneratedCodeInfo) GetAnnotation() []*GeneratedCodeInfo_Annotation { if m != nil { @@ -1976,17 +2549,36 @@ type GeneratedCodeInfo_Annotation struct { // Identifies the ending offset in bytes in the generated code that // relates to the identified offset. The end offset should be one past // the last relevant byte (so the length of the text = end - begin). - End *int32 `protobuf:"varint,4,opt,name=end" json:"end,omitempty"` - XXX_unrecognized []byte `json:"-"` + End *int32 `protobuf:"varint,4,opt,name=end" json:"end,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *GeneratedCodeInfo_Annotation) Reset() { *m = GeneratedCodeInfo_Annotation{} } func (m *GeneratedCodeInfo_Annotation) String() string { return proto.CompactTextString(m) } func (*GeneratedCodeInfo_Annotation) ProtoMessage() {} func (*GeneratedCodeInfo_Annotation) Descriptor() ([]byte, []int) { - return fileDescriptor0, []int{20, 0} + return fileDescriptor_descriptor_4df4cb5f42392df6, []int{20, 0} +} +func (m *GeneratedCodeInfo_Annotation) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GeneratedCodeInfo_Annotation.Unmarshal(m, b) +} +func (m *GeneratedCodeInfo_Annotation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GeneratedCodeInfo_Annotation.Marshal(b, m, deterministic) +} +func (dst *GeneratedCodeInfo_Annotation) XXX_Merge(src proto.Message) { + xxx_messageInfo_GeneratedCodeInfo_Annotation.Merge(dst, src) +} +func (m *GeneratedCodeInfo_Annotation) XXX_Size() int { + return xxx_messageInfo_GeneratedCodeInfo_Annotation.Size(m) +} +func (m *GeneratedCodeInfo_Annotation) XXX_DiscardUnknown() { + xxx_messageInfo_GeneratedCodeInfo_Annotation.DiscardUnknown(m) } +var xxx_messageInfo_GeneratedCodeInfo_Annotation proto.InternalMessageInfo + func (m *GeneratedCodeInfo_Annotation) GetPath() []int32 { if m != nil { return m.Path @@ -2025,6 +2617,7 @@ func init() { proto.RegisterType((*FieldDescriptorProto)(nil), "google.protobuf.FieldDescriptorProto") proto.RegisterType((*OneofDescriptorProto)(nil), "google.protobuf.OneofDescriptorProto") proto.RegisterType((*EnumDescriptorProto)(nil), "google.protobuf.EnumDescriptorProto") + proto.RegisterType((*EnumDescriptorProto_EnumReservedRange)(nil), "google.protobuf.EnumDescriptorProto.EnumReservedRange") proto.RegisterType((*EnumValueDescriptorProto)(nil), "google.protobuf.EnumValueDescriptorProto") proto.RegisterType((*ServiceDescriptorProto)(nil), "google.protobuf.ServiceDescriptorProto") proto.RegisterType((*MethodDescriptorProto)(nil), "google.protobuf.MethodDescriptorProto") @@ -2050,166 +2643,170 @@ func init() { proto.RegisterEnum("google.protobuf.MethodOptions_IdempotencyLevel", MethodOptions_IdempotencyLevel_name, MethodOptions_IdempotencyLevel_value) } -func init() { proto.RegisterFile("google/protobuf/descriptor.proto", fileDescriptor0) } +func init() { + proto.RegisterFile("google/protobuf/descriptor.proto", fileDescriptor_descriptor_4df4cb5f42392df6) +} -var fileDescriptor0 = []byte{ - // 2519 bytes of a gzipped FileDescriptorProto +var fileDescriptor_descriptor_4df4cb5f42392df6 = []byte{ + // 2555 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x59, 0xdd, 0x6e, 0x1b, 0xc7, - 0x15, 0x0e, 0x7f, 0x45, 0x1e, 0x52, 0xd4, 0x68, 0xa4, 0xd8, 0x6b, 0xe5, 0xc7, 0x32, 0xf3, 0x63, - 0xd9, 0x69, 0xa8, 0x40, 0xb1, 0x1d, 0x47, 0x29, 0xd2, 0x52, 0xe4, 0x5a, 0xa1, 0x4a, 0x91, 0xec, - 0x92, 0x6a, 0x7e, 0x6e, 0x16, 0xa3, 0xdd, 0x21, 0xb9, 0xf6, 0x72, 0x77, 0xb3, 0xbb, 0xb4, 0xad, - 0xa0, 0x17, 0x06, 0x7a, 0x55, 0xa0, 0x0f, 0x50, 0x14, 0x45, 0x2f, 0x72, 0x13, 0xa0, 0x0f, 0x50, - 0x20, 0x77, 0x7d, 0x82, 0x02, 0x79, 0x83, 0xa2, 0x28, 0xd0, 0x3e, 0x46, 0x31, 0x33, 0xbb, 0xcb, - 0x5d, 0xfe, 0xc4, 0x6a, 0x80, 0x38, 0x57, 0xe4, 0x7c, 0xe7, 0x3b, 0x67, 0xce, 0x9c, 0x39, 0x33, - 0x73, 0x66, 0x16, 0x76, 0x47, 0xb6, 0x3d, 0x32, 0xe9, 0xbe, 0xe3, 0xda, 0xbe, 0x7d, 0x3e, 0x1d, - 0xee, 0xeb, 0xd4, 0xd3, 0x5c, 0xc3, 0xf1, 0x6d, 0xb7, 0xc6, 0x31, 0xbc, 0x21, 0x18, 0xb5, 0x90, - 0x51, 0x3d, 0x85, 0xcd, 0x07, 0x86, 0x49, 0x9b, 0x11, 0xb1, 0x4f, 0x7d, 0x7c, 0x1f, 0xb2, 0x43, - 0xc3, 0xa4, 0x52, 0x6a, 0x37, 0xb3, 0x57, 0x3a, 0x78, 0xb3, 0x36, 0xa7, 0x54, 0x4b, 0x6a, 0xf4, - 0x18, 0xac, 0x70, 0x8d, 0xea, 0xbf, 0xb3, 0xb0, 0xb5, 0x44, 0x8a, 0x31, 0x64, 0x2d, 0x32, 0x61, - 0x16, 0x53, 0x7b, 0x45, 0x85, 0xff, 0xc7, 0x12, 0xac, 0x39, 0x44, 0x7b, 0x44, 0x46, 0x54, 0x4a, - 0x73, 0x38, 0x6c, 0xe2, 0xd7, 0x01, 0x74, 0xea, 0x50, 0x4b, 0xa7, 0x96, 0x76, 0x21, 0x65, 0x76, - 0x33, 0x7b, 0x45, 0x25, 0x86, 0xe0, 0x77, 0x60, 0xd3, 0x99, 0x9e, 0x9b, 0x86, 0xa6, 0xc6, 0x68, - 0xb0, 0x9b, 0xd9, 0xcb, 0x29, 0x48, 0x08, 0x9a, 0x33, 0xf2, 0x4d, 0xd8, 0x78, 0x42, 0xc9, 0xa3, - 0x38, 0xb5, 0xc4, 0xa9, 0x15, 0x06, 0xc7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x93, 0x0c, 0x62, 0xfe, 0x07, - 0x06, 0xb1, 0x0e, 0x25, 0x8b, 0x7a, 0x3e, 0xd5, 0x45, 0x46, 0x64, 0x2e, 0x99, 0x53, 0x20, 0x94, - 0x16, 0x53, 0x2a, 0xfb, 0x83, 0x52, 0xea, 0x33, 0xd8, 0x88, 0x5c, 0x52, 0x5d, 0x62, 0x8d, 0xc2, - 0xdc, 0xdc, 0x7f, 0x9e, 0x27, 0x35, 0x39, 0xd4, 0x53, 0x98, 0x9a, 0x52, 0xa1, 0x89, 0x36, 0x6e, - 0x02, 0xd8, 0x16, 0xb5, 0x87, 0xaa, 0x4e, 0x35, 0x53, 0x2a, 0xac, 0x88, 0x52, 0x97, 0x51, 0x16, - 0xa2, 0x64, 0x0b, 0x54, 0x33, 0xf1, 0x87, 0xb3, 0x54, 0x5b, 0x5b, 0x91, 0x29, 0xa7, 0x62, 0x91, - 0x2d, 0x64, 0xdb, 0x19, 0x54, 0x5c, 0xca, 0xf2, 0x9e, 0xea, 0xc1, 0xc8, 0x8a, 0xdc, 0x89, 0xda, - 0x73, 0x47, 0xa6, 0x04, 0x6a, 0x62, 0x60, 0xeb, 0x6e, 0xbc, 0x89, 0xdf, 0x80, 0x08, 0x50, 0x79, - 0x5a, 0x01, 0xdf, 0x85, 0xca, 0x21, 0xd8, 0x21, 0x13, 0xba, 0xf3, 0x15, 0x54, 0x92, 0xe1, 0xc1, - 0xdb, 0x90, 0xf3, 0x7c, 0xe2, 0xfa, 0x3c, 0x0b, 0x73, 0x8a, 0x68, 0x60, 0x04, 0x19, 0x6a, 0xe9, - 0x7c, 0x97, 0xcb, 0x29, 0xec, 0x2f, 0xfe, 0xe5, 0x6c, 0xc0, 0x19, 0x3e, 0xe0, 0xb7, 0x17, 0x67, - 0x34, 0x61, 0x79, 0x7e, 0xdc, 0x3b, 0x1f, 0xc0, 0x7a, 0x62, 0x00, 0x97, 0xed, 0xba, 0xfa, 0x5b, - 0x78, 0x79, 0xa9, 0x69, 0x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69, 0x30, 0xca, 0x99, 0x3f, 0xbc, - 0x8f, 0xfb, 0x50, 0x66, 0x93, 0x31, 0x31, 0xbe, 0xa2, 0xea, 0xd0, 0x76, 0xf9, 0xc9, 0x52, 0x59, - 0xb2, 0xb2, 0x63, 0x11, 0xac, 0x75, 0x03, 0x85, 0x53, 0x5b, 0xa7, 0x87, 0xb9, 0x7e, 0x4f, 0x96, - 0x9b, 0x4a, 0x29, 0xb4, 0xf2, 0xc0, 0x76, 0x59, 0x42, 0x8d, 0xec, 0x28, 0xc0, 0x25, 0x91, 0x50, - 0x23, 0x3b, 0x0c, 0xef, 0x5d, 0xd8, 0xd2, 0x34, 0x31, 0x66, 0x43, 0x53, 0x83, 0x2b, 0x8a, 0x27, - 0xa1, 0x44, 0xb0, 0x34, 0xed, 0x58, 0x10, 0x82, 0x1c, 0xf7, 0xf0, 0x87, 0xf0, 0xf2, 0x2c, 0x58, - 0x71, 0xc5, 0xcd, 0x85, 0x51, 0xce, 0xab, 0xde, 0x85, 0x2d, 0xe7, 0x62, 0x51, 0x11, 0x27, 0x7a, - 0x74, 0x2e, 0xe6, 0xd5, 0x3e, 0x80, 0x6d, 0x67, 0xec, 0x2c, 0xea, 0xdd, 0x8e, 0xeb, 0x61, 0x67, - 0xec, 0xcc, 0x2b, 0xbe, 0xc5, 0xef, 0xab, 0x2e, 0xd5, 0x88, 0x4f, 0x75, 0xe9, 0x6a, 0x9c, 0x1e, - 0x13, 0xe0, 0x7d, 0x40, 0x9a, 0xa6, 0x52, 0x8b, 0x9c, 0x9b, 0x54, 0x25, 0x2e, 0xb5, 0x88, 0x27, - 0x5d, 0x8f, 0x93, 0x2b, 0x9a, 0x26, 0x73, 0x69, 0x9d, 0x0b, 0xf1, 0x6d, 0xd8, 0xb4, 0xcf, 0x1f, - 0x6a, 0x22, 0x25, 0x55, 0xc7, 0xa5, 0x43, 0xe3, 0xa9, 0xf4, 0x26, 0x8f, 0xef, 0x06, 0x13, 0xf0, - 0x84, 0xec, 0x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x06, 0x77, 0x6f, 0xa3, 0x6c, 0x2c, 0x70, 0x22, 0x80, 0x5c, + 0x92, 0xf0, 0xfe, 0x2d, 0x94, 0xc7, 0x08, 0x2a, 0x42, 0x41, 0xfb, 0x53, 0xa5, 0x75, 0xf7, 0x36, + 0x2a, 0xa4, 0x91, 0xf7, 0x6f, 0xa1, 0x15, 0xbc, 0x0a, 0x25, 0x8e, 0xec, 0x77, 0xbb, 0x47, 0xa8, + 0x18, 0xeb, 0xec, 0x0f, 0xd4, 0x76, 0xe7, 0x00, 0x95, 0x62, 0x9d, 0x07, 0x6a, 0xf7, 0xa4, 0x87, + 0x20, 0xd6, 0x70, 0xac, 0xf4, 0xfb, 0x8d, 0x03, 0x05, 0x95, 0x63, 0xc6, 0xfe, 0x67, 0x03, 0xa5, + 0x8f, 0x2a, 0x29, 0xb3, 0xde, 0xbf, 0x85, 0x56, 0xe3, 0x21, 0x94, 0xce, 0xc9, 0x31, 0xaa, 0xe2, + 0x75, 0x58, 0x15, 0x43, 0x44, 0x46, 0xac, 0xcd, 0x41, 0x77, 0x6f, 0x23, 0x34, 0x33, 0x44, 0x68, + 0x59, 0x4f, 0x01, 0x77, 0x6f, 0x23, 0x5c, 0x6b, 0x42, 0x9e, 0x47, 0x17, 0xc6, 0x50, 0x3d, 0x6a, + 0xec, 0x2b, 0x47, 0x5a, 0xb7, 0x37, 0x68, 0x77, 0x3b, 0x8d, 0x23, 0x24, 0xcd, 0x30, 0x55, 0xf9, + 0xf9, 0x49, 0x5b, 0x55, 0x5a, 0x28, 0x93, 0xc4, 0x7a, 0x4a, 0x63, 0xa0, 0xb4, 0x50, 0xb6, 0xa6, + 0xc3, 0xe6, 0xb2, 0x3c, 0xb9, 0x74, 0x67, 0x24, 0x96, 0x38, 0x73, 0xce, 0x12, 0x73, 0x5d, 0x0b, + 0x4b, 0xfc, 0xcf, 0x0c, 0x6c, 0x2c, 0x39, 0x2b, 0x96, 0x0e, 0xf2, 0x13, 0xc8, 0x8b, 0x10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x77, 0x26, 0xbb, 0x23, 0xc7, + 0x22, 0xf6, 0x68, 0xf6, 0x99, 0x93, 0xff, 0xd1, 0xdf, 0x1d, 0x51, 0xfb, 0xdd, 0x91, 0x93, 0xf8, + 0xe8, 0x79, 0x7f, 0xf6, 0xf7, 0xbf, 0x92, 0xf4, 0xa7, 0x4c, 0xf6, 0xa0, 0xb7, 0xff, 0xe7, 0xcc, + 0xd6, 0x81, 0x18, 0xae, 0x17, 0xb9, 0x47, 0xa5, 0x43, 0x8b, 0xea, 0x6c, 0xca, 0xff, 0x0b, 0x00, + 0x00, 0xff, 0xff, 0x1a, 0x28, 0x25, 0x79, 0x42, 0x1d, 0x00, 0x00, } diff --git a/vendor/github.com/golang/protobuf/ptypes/any.go b/vendor/github.com/golang/protobuf/ptypes/any.go index b2af97f..70276e8 100644 --- a/vendor/github.com/golang/protobuf/ptypes/any.go +++ b/vendor/github.com/golang/protobuf/ptypes/any.go @@ -130,10 +130,12 @@ func UnmarshalAny(any *any.Any, pb proto.Message) error { // Is returns true if any value contains a given message type. func Is(any *any.Any, pb proto.Message) bool { - aname, err := AnyMessageName(any) - if err != nil { + // The following is equivalent to AnyMessageName(any) == proto.MessageName(pb), + // but it avoids scanning TypeUrl for the slash. + if any == nil { return false } - - return aname == proto.MessageName(pb) + name := proto.MessageName(pb) + prefix := len(any.TypeUrl) - len(name) + return prefix >= 1 && any.TypeUrl[prefix-1] == '/' && any.TypeUrl[prefix:] == name } diff --git a/vendor/github.com/golang/protobuf/ptypes/any/any.pb.go b/vendor/github.com/golang/protobuf/ptypes/any/any.pb.go index f346017..e3c56d3 100644 --- a/vendor/github.com/golang/protobuf/ptypes/any/any.pb.go +++ b/vendor/github.com/golang/protobuf/ptypes/any/any.pb.go @@ -1,16 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: google/protobuf/any.proto -/* -Package any is a generated protocol buffer package. - -It is generated from these files: - google/protobuf/any.proto - -It has these top-level messages: - Any -*/ -package any +package any // import "github.com/golang/protobuf/ptypes/any" import proto "github.com/golang/protobuf/proto" import fmt "fmt" @@ -130,16 +121,38 @@ type Any struct { // Schemes other than `http`, `https` (or the empty scheme) might be // used with implementation specific semantics. // - TypeUrl string `protobuf:"bytes,1,opt,name=type_url,json=typeUrl" json:"type_url,omitempty"` + TypeUrl string `protobuf:"bytes,1,opt,name=type_url,json=typeUrl,proto3" json:"type_url,omitempty"` // Must be a valid serialized protocol buffer of the above specified type. - Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Any) Reset() { *m = Any{} } +func (m *Any) String() string { return proto.CompactTextString(m) } +func (*Any) ProtoMessage() {} +func (*Any) Descriptor() ([]byte, []int) { + return fileDescriptor_any_744b9ca530f228db, []int{0} +} +func (*Any) XXX_WellKnownType() string { return "Any" } +func (m *Any) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Any.Unmarshal(m, b) +} +func (m *Any) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Any.Marshal(b, m, deterministic) +} +func (dst *Any) XXX_Merge(src proto.Message) { + xxx_messageInfo_Any.Merge(dst, src) +} +func (m *Any) XXX_Size() int { + return xxx_messageInfo_Any.Size(m) +} +func (m *Any) XXX_DiscardUnknown() { + xxx_messageInfo_Any.DiscardUnknown(m) } -func (m *Any) Reset() { *m = Any{} } -func (m *Any) String() string { return proto.CompactTextString(m) } -func (*Any) ProtoMessage() {} -func (*Any) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } -func (*Any) XXX_WellKnownType() string { return "Any" } +var xxx_messageInfo_Any proto.InternalMessageInfo func (m *Any) GetTypeUrl() string { if m != nil { @@ -159,9 +172,9 @@ func init() { proto.RegisterType((*Any)(nil), "google.protobuf.Any") } -func init() { proto.RegisterFile("google/protobuf/any.proto", fileDescriptor0) } +func init() { proto.RegisterFile("google/protobuf/any.proto", fileDescriptor_any_744b9ca530f228db) } -var fileDescriptor0 = []byte{ +var fileDescriptor_any_744b9ca530f228db = []byte{ // 185 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4c, 0xcf, 0xcf, 0x4f, 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x4f, 0xcc, 0xab, 0xd4, diff --git a/vendor/github.com/golang/protobuf/ptypes/duration/duration.pb.go b/vendor/github.com/golang/protobuf/ptypes/duration/duration.pb.go index b2410a0..a7beb2c 100644 --- a/vendor/github.com/golang/protobuf/ptypes/duration/duration.pb.go +++ b/vendor/github.com/golang/protobuf/ptypes/duration/duration.pb.go @@ -1,16 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: google/protobuf/duration.proto -/* -Package duration is a generated protocol buffer package. - -It is generated from these files: - google/protobuf/duration.proto - -It has these top-level messages: - Duration -*/ -package duration +package duration // import "github.com/golang/protobuf/ptypes/duration" import proto "github.com/golang/protobuf/proto" import fmt "fmt" @@ -91,21 +82,43 @@ type Duration struct { // Signed seconds of the span of time. Must be from -315,576,000,000 // to +315,576,000,000 inclusive. Note: these bounds are computed from: // 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years - Seconds int64 `protobuf:"varint,1,opt,name=seconds" json:"seconds,omitempty"` + Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"` // Signed fractions of a second at nanosecond resolution of the span // of time. Durations less than one second are represented with a 0 // `seconds` field and a positive or negative `nanos` field. For durations // of one second or more, a non-zero value for the `nanos` field must be // of the same sign as the `seconds` field. Must be from -999,999,999 // to +999,999,999 inclusive. - Nanos int32 `protobuf:"varint,2,opt,name=nanos" json:"nanos,omitempty"` + Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *Duration) Reset() { *m = Duration{} } -func (m *Duration) String() string { return proto.CompactTextString(m) } -func (*Duration) ProtoMessage() {} -func (*Duration) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } -func (*Duration) XXX_WellKnownType() string { return "Duration" } +func (m *Duration) Reset() { *m = Duration{} } +func (m *Duration) String() string { return proto.CompactTextString(m) } +func (*Duration) ProtoMessage() {} +func (*Duration) Descriptor() ([]byte, []int) { + return fileDescriptor_duration_e7d612259e3f0613, []int{0} +} +func (*Duration) XXX_WellKnownType() string { return "Duration" } +func (m *Duration) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Duration.Unmarshal(m, b) +} +func (m *Duration) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Duration.Marshal(b, m, deterministic) +} +func (dst *Duration) XXX_Merge(src proto.Message) { + xxx_messageInfo_Duration.Merge(dst, src) +} +func (m *Duration) XXX_Size() int { + return xxx_messageInfo_Duration.Size(m) +} +func (m *Duration) XXX_DiscardUnknown() { + xxx_messageInfo_Duration.DiscardUnknown(m) +} + +var xxx_messageInfo_Duration proto.InternalMessageInfo func (m *Duration) GetSeconds() int64 { if m != nil { @@ -125,9 +138,11 @@ func init() { proto.RegisterType((*Duration)(nil), "google.protobuf.Duration") } -func init() { proto.RegisterFile("google/protobuf/duration.proto", fileDescriptor0) } +func init() { + proto.RegisterFile("google/protobuf/duration.proto", fileDescriptor_duration_e7d612259e3f0613) +} -var fileDescriptor0 = []byte{ +var fileDescriptor_duration_e7d612259e3f0613 = []byte{ // 190 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xcf, 0xcf, 0x4f, 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x4f, 0x29, 0x2d, 0x4a, diff --git a/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go b/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go index e23e4a2..8e76ae9 100644 --- a/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go +++ b/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go @@ -1,16 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: google/protobuf/timestamp.proto -/* -Package timestamp is a generated protocol buffer package. - -It is generated from these files: - google/protobuf/timestamp.proto - -It has these top-level messages: - Timestamp -*/ -package timestamp +package timestamp // import "github.com/golang/protobuf/ptypes/timestamp" import proto "github.com/golang/protobuf/proto" import fmt "fmt" @@ -101,7 +92,7 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package // to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) // with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one // can use the Joda Time's [`ISODateTimeFormat.dateTime()`]( -// http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()) +// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--) // to obtain a formatter capable of generating timestamps in this format. // // @@ -109,19 +100,41 @@ type Timestamp struct { // Represents seconds of UTC time since Unix epoch // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to // 9999-12-31T23:59:59Z inclusive. - Seconds int64 `protobuf:"varint,1,opt,name=seconds" json:"seconds,omitempty"` + Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"` // Non-negative fractions of a second at nanosecond resolution. Negative // second values with fractions must still have non-negative nanos values // that count forward in time. Must be from 0 to 999,999,999 // inclusive. - Nanos int32 `protobuf:"varint,2,opt,name=nanos" json:"nanos,omitempty"` + Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *Timestamp) Reset() { *m = Timestamp{} } -func (m *Timestamp) String() string { return proto.CompactTextString(m) } -func (*Timestamp) ProtoMessage() {} -func (*Timestamp) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } -func (*Timestamp) XXX_WellKnownType() string { return "Timestamp" } +func (m *Timestamp) Reset() { *m = Timestamp{} } +func (m *Timestamp) String() string { return proto.CompactTextString(m) } +func (*Timestamp) ProtoMessage() {} +func (*Timestamp) Descriptor() ([]byte, []int) { + return fileDescriptor_timestamp_b826e8e5fba671a8, []int{0} +} +func (*Timestamp) XXX_WellKnownType() string { return "Timestamp" } +func (m *Timestamp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Timestamp.Unmarshal(m, b) +} +func (m *Timestamp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Timestamp.Marshal(b, m, deterministic) +} +func (dst *Timestamp) XXX_Merge(src proto.Message) { + xxx_messageInfo_Timestamp.Merge(dst, src) +} +func (m *Timestamp) XXX_Size() int { + return xxx_messageInfo_Timestamp.Size(m) +} +func (m *Timestamp) XXX_DiscardUnknown() { + xxx_messageInfo_Timestamp.DiscardUnknown(m) +} + +var xxx_messageInfo_Timestamp proto.InternalMessageInfo func (m *Timestamp) GetSeconds() int64 { if m != nil { @@ -141,9 +154,11 @@ func init() { proto.RegisterType((*Timestamp)(nil), "google.protobuf.Timestamp") } -func init() { proto.RegisterFile("google/protobuf/timestamp.proto", fileDescriptor0) } +func init() { + proto.RegisterFile("google/protobuf/timestamp.proto", fileDescriptor_timestamp_b826e8e5fba671a8) +} -var fileDescriptor0 = []byte{ +var fileDescriptor_timestamp_b826e8e5fba671a8 = []byte{ // 191 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xcf, 0xcf, 0x4f, 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x2f, 0xc9, 0xcc, 0x4d, diff --git a/vendor/github.com/gorilla/context/doc.go b/vendor/github.com/gorilla/context/doc.go index 73c7400..448d1bf 100644 --- a/vendor/github.com/gorilla/context/doc.go +++ b/vendor/github.com/gorilla/context/doc.go @@ -5,6 +5,12 @@ /* Package context stores values shared during a request lifetime. +Note: gorilla/context, having been born well before `context.Context` existed, +does not play well > with the shallow copying of the request that +[`http.Request.WithContext`](https://golang.org/pkg/net/http/#Request.WithContext) +(added to net/http Go 1.7 onwards) performs. You should either use *just* +gorilla/context, or moving forward, the new `http.Request.Context()`. + For example, a router can set variables extracted from the URL and later application handlers can access those values, or it can be used to store sessions values to be saved at the end of a request. There are several diff --git a/vendor/github.com/gorilla/mux/doc.go b/vendor/github.com/gorilla/mux/doc.go index 013f088..38957de 100644 --- a/vendor/github.com/gorilla/mux/doc.go +++ b/vendor/github.com/gorilla/mux/doc.go @@ -239,8 +239,7 @@ as well: "category", "technology", "id", "42") -Since **vX.Y.Z**, mux supports the addition of middlewares to a [Router](https://godoc.org/github.com/gorilla/mux#Router), which are executed if a -match is found (including subrouters). Middlewares are defined using the de facto standard type: +Mux supports the addition of middlewares to a Router, which are executed in the order they are added if a match is found, including its subrouters. Middlewares are (typically) small pieces of code which take one request, do something with it, and pass it down to another middleware or the final handler. Some common use cases for middleware are request logging, header manipulation, or ResponseWriter hijacking. type MiddlewareFunc func(http.Handler) http.Handler @@ -261,7 +260,7 @@ Middlewares can be added to a router using `Router.Use()`: r := mux.NewRouter() r.HandleFunc("/", handler) - r.AddMiddleware(simpleMw) + r.Use(simpleMw) A more complex authentication middleware, which maps session token to users, could be written as: @@ -288,7 +287,7 @@ A more complex authentication middleware, which maps session token to users, cou log.Printf("Authenticated user %s\n", user) next.ServeHTTP(w, r) } else { - http.Error(w, "Forbidden", 403) + http.Error(w, "Forbidden", http.StatusForbidden) } }) } diff --git a/vendor/github.com/gorilla/mux/middleware.go b/vendor/github.com/gorilla/mux/middleware.go index 8f89867..ceb812c 100644 --- a/vendor/github.com/gorilla/mux/middleware.go +++ b/vendor/github.com/gorilla/mux/middleware.go @@ -1,6 +1,9 @@ package mux -import "net/http" +import ( + "net/http" + "strings" +) // MiddlewareFunc is a function which receives an http.Handler and returns another http.Handler. // Typically, the returned handler is a closure which does something with the http.ResponseWriter and http.Request passed @@ -12,17 +15,58 @@ type middleware interface { Middleware(handler http.Handler) http.Handler } -// MiddlewareFunc also implements the middleware interface. +// Middleware allows MiddlewareFunc to implement the middleware interface. func (mw MiddlewareFunc) Middleware(handler http.Handler) http.Handler { return mw(handler) } // Use appends a MiddlewareFunc to the chain. Middleware can be used to intercept or otherwise modify requests and/or responses, and are executed in the order that they are applied to the Router. -func (r *Router) Use(mwf MiddlewareFunc) { - r.middlewares = append(r.middlewares, mwf) +func (r *Router) Use(mwf ...MiddlewareFunc) { + for _, fn := range mwf { + r.middlewares = append(r.middlewares, fn) + } } // useInterface appends a middleware to the chain. Middleware can be used to intercept or otherwise modify requests and/or responses, and are executed in the order that they are applied to the Router. func (r *Router) useInterface(mw middleware) { r.middlewares = append(r.middlewares, mw) } + +// CORSMethodMiddleware sets the Access-Control-Allow-Methods response header +// on a request, by matching routes based only on paths. It also handles +// OPTIONS requests, by settings Access-Control-Allow-Methods, and then +// returning without calling the next http handler. +func CORSMethodMiddleware(r *Router) MiddlewareFunc { + return func(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + var allMethods []string + + err := r.Walk(func(route *Route, _ *Router, _ []*Route) error { + for _, m := range route.matchers { + if _, ok := m.(*routeRegexp); ok { + if m.Match(req, &RouteMatch{}) { + methods, err := route.GetMethods() + if err != nil { + return err + } + + allMethods = append(allMethods, methods...) + } + break + } + } + return nil + }) + + if err == nil { + w.Header().Set("Access-Control-Allow-Methods", strings.Join(append(allMethods, "OPTIONS"), ",")) + + if req.Method == "OPTIONS" { + return + } + } + + next.ServeHTTP(w, req) + }) + } +} diff --git a/vendor/github.com/gorilla/mux/mux.go b/vendor/github.com/gorilla/mux/mux.go index efabd24..4bbafa5 100644 --- a/vendor/github.com/gorilla/mux/mux.go +++ b/vendor/github.com/gorilla/mux/mux.go @@ -13,8 +13,11 @@ import ( ) var ( + // ErrMethodMismatch is returned when the method in the request does not match + // the method defined against the route. ErrMethodMismatch = errors.New("method is not allowed") - ErrNotFound = errors.New("no matching route was found") + // ErrNotFound is returned when no route match is found. + ErrNotFound = errors.New("no matching route was found") ) // NewRouter returns a new router instance. @@ -95,9 +98,9 @@ func (r *Router) Match(req *http.Request, match *RouteMatch) bool { if r.MethodNotAllowedHandler != nil { match.Handler = r.MethodNotAllowedHandler return true - } else { - return false } + + return false } // Closest match for a router (includes sub-routers) diff --git a/vendor/github.com/gorilla/mux/route.go b/vendor/github.com/gorilla/mux/route.go index 4ce098d..a591d73 100644 --- a/vendor/github.com/gorilla/mux/route.go +++ b/vendor/github.com/gorilla/mux/route.go @@ -43,6 +43,8 @@ type Route struct { buildVarsFunc BuildVarsFunc } +// SkipClean reports whether path cleaning is enabled for this route via +// Router.SkipClean. func (r *Route) SkipClean() bool { return r.skipClean } @@ -622,7 +624,7 @@ func (r *Route) GetPathRegexp() (string, error) { // route queries. // This is useful for building simple REST API documentation and for instrumentation // against third-party services. -// An empty list will be returned if the route does not have queries. +// An error will be returned if the route does not have queries. func (r *Route) GetQueriesRegexp() ([]string, error) { if r.err != nil { return nil, r.err @@ -641,7 +643,7 @@ func (r *Route) GetQueriesRegexp() ([]string, error) { // query matching. // This is useful for building simple REST API documentation and for instrumentation // against third-party services. -// An empty list will be returned if the route does not define queries. +// An error will be returned if the route does not define queries. func (r *Route) GetQueriesTemplates() ([]string, error) { if r.err != nil { return nil, r.err @@ -659,7 +661,7 @@ func (r *Route) GetQueriesTemplates() ([]string, error) { // GetMethods returns the methods the route matches against // This is useful for building simple REST API documentation and for instrumentation // against third-party services. -// An empty list will be returned if route does not have methods. +// An error will be returned if route does not have methods. func (r *Route) GetMethods() ([]string, error) { if r.err != nil { return nil, r.err @@ -669,7 +671,7 @@ func (r *Route) GetMethods() ([]string, error) { return []string(methods), nil } } - return nil, nil + return nil, errors.New("mux: route doesn't have methods") } // GetHostTemplate returns the template used to build the diff --git a/vendor/github.com/gorilla/mux/test_helpers.go b/vendor/github.com/gorilla/mux/test_helpers.go index 8b2c4a4..32ecffd 100644 --- a/vendor/github.com/gorilla/mux/test_helpers.go +++ b/vendor/github.com/gorilla/mux/test_helpers.go @@ -7,7 +7,8 @@ package mux import "net/http" // SetURLVars sets the URL variables for the given request, to be accessed via -// mux.Vars for testing route behaviour. +// mux.Vars for testing route behaviour. Arguments are not modified, a shallow +// copy is returned. // // This API should only be used for testing purposes; it provides a way to // inject variables into the request context. Alternatively, URL variables diff --git a/vendor/github.com/hashicorp/hcl/hcl/parser/parser.go b/vendor/github.com/hashicorp/hcl/hcl/parser/parser.go index 098e1bc..64c83bc 100644 --- a/vendor/github.com/hashicorp/hcl/hcl/parser/parser.go +++ b/vendor/github.com/hashicorp/hcl/hcl/parser/parser.go @@ -205,6 +205,12 @@ func (p *Parser) objectItem() (*ast.ObjectItem, error) { } } + // key=#comment + // val + if p.lineComment != nil { + o.LineComment, p.lineComment = p.lineComment, nil + } + // do a look-ahead for line comment p.scan() if len(keys) > 0 && o.Val.Pos().Line == keys[0].Pos().Line && p.lineComment != nil { diff --git a/vendor/github.com/hashicorp/hcl/hcl/printer/nodes.go b/vendor/github.com/hashicorp/hcl/hcl/printer/nodes.go new file mode 100644 index 0000000..7c038d1 --- /dev/null +++ b/vendor/github.com/hashicorp/hcl/hcl/printer/nodes.go @@ -0,0 +1,789 @@ +package printer + +import ( + "bytes" + "fmt" + "sort" + + "github.com/hashicorp/hcl/hcl/ast" + "github.com/hashicorp/hcl/hcl/token" +) + +const ( + blank = byte(' ') + newline = byte('\n') + tab = byte('\t') + infinity = 1 << 30 // offset or line +) + +var ( + unindent = []byte("\uE123") // in the private use space +) + +type printer struct { + cfg Config + prev token.Pos + + comments []*ast.CommentGroup // may be nil, contains all comments + standaloneComments []*ast.CommentGroup // contains all standalone comments (not assigned to any node) + + enableTrace bool + indentTrace int +} + +type ByPosition []*ast.CommentGroup + +func (b ByPosition) Len() int { return len(b) } +func (b ByPosition) Swap(i, j int) { b[i], b[j] = b[j], b[i] } +func (b ByPosition) Less(i, j int) bool { return b[i].Pos().Before(b[j].Pos()) } + +// collectComments comments all standalone comments which are not lead or line +// comment +func (p *printer) collectComments(node ast.Node) { + // first collect all comments. This is already stored in + // ast.File.(comments) + ast.Walk(node, func(nn ast.Node) (ast.Node, bool) { + switch t := nn.(type) { + case *ast.File: + p.comments = t.Comments + return nn, false + } + return nn, true + }) + + standaloneComments := make(map[token.Pos]*ast.CommentGroup, 0) + for _, c := range p.comments { + standaloneComments[c.Pos()] = c + } + + // next remove all lead and line comments from the overall comment map. + // This will give us comments which are standalone, comments which are not + // assigned to any kind of node. + ast.Walk(node, func(nn ast.Node) (ast.Node, bool) { + switch t := nn.(type) { + case *ast.LiteralType: + if t.LeadComment != nil { + for _, comment := range t.LeadComment.List { + if _, ok := standaloneComments[comment.Pos()]; ok { + delete(standaloneComments, comment.Pos()) + } + } + } + + if t.LineComment != nil { + for _, comment := range t.LineComment.List { + if _, ok := standaloneComments[comment.Pos()]; ok { + delete(standaloneComments, comment.Pos()) + } + } + } + case *ast.ObjectItem: + if t.LeadComment != nil { + for _, comment := range t.LeadComment.List { + if _, ok := standaloneComments[comment.Pos()]; ok { + delete(standaloneComments, comment.Pos()) + } + } + } + + if t.LineComment != nil { + for _, comment := range t.LineComment.List { + if _, ok := standaloneComments[comment.Pos()]; ok { + delete(standaloneComments, comment.Pos()) + } + } + } + } + + return nn, true + }) + + for _, c := range standaloneComments { + p.standaloneComments = append(p.standaloneComments, c) + } + + sort.Sort(ByPosition(p.standaloneComments)) +} + +// output prints creates b printable HCL output and returns it. +func (p *printer) output(n interface{}) []byte { + var buf bytes.Buffer + + switch t := n.(type) { + case *ast.File: + // File doesn't trace so we add the tracing here + defer un(trace(p, "File")) + return p.output(t.Node) + case *ast.ObjectList: + defer un(trace(p, "ObjectList")) + + var index int + for { + // Determine the location of the next actual non-comment + // item. If we're at the end, the next item is at "infinity" + var nextItem token.Pos + if index != len(t.Items) { + nextItem = t.Items[index].Pos() + } else { + nextItem = token.Pos{Offset: infinity, Line: infinity} + } + + // Go through the standalone comments in the file and print out + // the comments that we should be for this object item. + for _, c := range p.standaloneComments { + // Go through all the comments in the group. The group + // should be printed together, not separated by double newlines. + printed := false + newlinePrinted := false + for _, comment := range c.List { + // We only care about comments after the previous item + // we've printed so that comments are printed in the + // correct locations (between two objects for example). + // And before the next item. + if comment.Pos().After(p.prev) && comment.Pos().Before(nextItem) { + // if we hit the end add newlines so we can print the comment + // we don't do this if prev is invalid which means the + // beginning of the file since the first comment should + // be at the first line. + if !newlinePrinted && p.prev.IsValid() && index == len(t.Items) { + buf.Write([]byte{newline, newline}) + newlinePrinted = true + } + + // Write the actual comment. + buf.WriteString(comment.Text) + buf.WriteByte(newline) + + // Set printed to true to note that we printed something + printed = true + } + } + + // If we're not at the last item, write a new line so + // that there is a newline separating this comment from + // the next object. + if printed && index != len(t.Items) { + buf.WriteByte(newline) + } + } + + if index == len(t.Items) { + break + } + + buf.Write(p.output(t.Items[index])) + if index != len(t.Items)-1 { + // Always write a newline to separate us from the next item + buf.WriteByte(newline) + + // Need to determine if we're going to separate the next item + // with a blank line. The logic here is simple, though there + // are a few conditions: + // + // 1. The next object is more than one line away anyways, + // so we need an empty line. + // + // 2. The next object is not a "single line" object, so + // we need an empty line. + // + // 3. This current object is not a single line object, + // so we need an empty line. + current := t.Items[index] + next := t.Items[index+1] + if next.Pos().Line != t.Items[index].Pos().Line+1 || + !p.isSingleLineObject(next) || + !p.isSingleLineObject(current) { + buf.WriteByte(newline) + } + } + index++ + } + case *ast.ObjectKey: + buf.WriteString(t.Token.Text) + case *ast.ObjectItem: + p.prev = t.Pos() + buf.Write(p.objectItem(t)) + case *ast.LiteralType: + buf.Write(p.literalType(t)) + case *ast.ListType: + buf.Write(p.list(t)) + case *ast.ObjectType: + buf.Write(p.objectType(t)) + default: + fmt.Printf(" unknown type: %T\n", n) + } + + return buf.Bytes() +} + +func (p *printer) literalType(lit *ast.LiteralType) []byte { + result := []byte(lit.Token.Text) + switch lit.Token.Type { + case token.HEREDOC: + // Clear the trailing newline from heredocs + if result[len(result)-1] == '\n' { + result = result[:len(result)-1] + } + + // Poison lines 2+ so that we don't indent them + result = p.heredocIndent(result) + case token.STRING: + // If this is a multiline string, poison lines 2+ so we don't + // indent them. + if bytes.IndexRune(result, '\n') >= 0 { + result = p.heredocIndent(result) + } + } + + return result +} + +// objectItem returns the printable HCL form of an object item. An object type +// starts with one/multiple keys and has a value. The value might be of any +// type. +func (p *printer) objectItem(o *ast.ObjectItem) []byte { + defer un(trace(p, fmt.Sprintf("ObjectItem: %s", o.Keys[0].Token.Text))) + var buf bytes.Buffer + + if o.LeadComment != nil { + for _, comment := range o.LeadComment.List { + buf.WriteString(comment.Text) + buf.WriteByte(newline) + } + } + + // If key and val are on different lines, treat line comments like lead comments. + if o.LineComment != nil && o.Val.Pos().Line != o.Keys[0].Pos().Line { + for _, comment := range o.LineComment.List { + buf.WriteString(comment.Text) + buf.WriteByte(newline) + } + } + + for i, k := range o.Keys { + buf.WriteString(k.Token.Text) + buf.WriteByte(blank) + + // reach end of key + if o.Assign.IsValid() && i == len(o.Keys)-1 && len(o.Keys) == 1 { + buf.WriteString("=") + buf.WriteByte(blank) + } + } + + buf.Write(p.output(o.Val)) + + if o.LineComment != nil && o.Val.Pos().Line == o.Keys[0].Pos().Line { + buf.WriteByte(blank) + for _, comment := range o.LineComment.List { + buf.WriteString(comment.Text) + } + } + + return buf.Bytes() +} + +// objectType returns the printable HCL form of an object type. An object type +// begins with a brace and ends with a brace. +func (p *printer) objectType(o *ast.ObjectType) []byte { + defer un(trace(p, "ObjectType")) + var buf bytes.Buffer + buf.WriteString("{") + + var index int + var nextItem token.Pos + var commented, newlinePrinted bool + for { + // Determine the location of the next actual non-comment + // item. If we're at the end, the next item is the closing brace + if index != len(o.List.Items) { + nextItem = o.List.Items[index].Pos() + } else { + nextItem = o.Rbrace + } + + // Go through the standalone comments in the file and print out + // the comments that we should be for this object item. + for _, c := range p.standaloneComments { + printed := false + var lastCommentPos token.Pos + for _, comment := range c.List { + // We only care about comments after the previous item + // we've printed so that comments are printed in the + // correct locations (between two objects for example). + // And before the next item. + if comment.Pos().After(p.prev) && comment.Pos().Before(nextItem) { + // If there are standalone comments and the initial newline has not + // been printed yet, do it now. + if !newlinePrinted { + newlinePrinted = true + buf.WriteByte(newline) + } + + // add newline if it's between other printed nodes + if index > 0 { + commented = true + buf.WriteByte(newline) + } + + // Store this position + lastCommentPos = comment.Pos() + + // output the comment itself + buf.Write(p.indent(p.heredocIndent([]byte(comment.Text)))) + + // Set printed to true to note that we printed something + printed = true + + /* + if index != len(o.List.Items) { + buf.WriteByte(newline) // do not print on the end + } + */ + } + } + + // Stuff to do if we had comments + if printed { + // Always write a newline + buf.WriteByte(newline) + + // If there is another item in the object and our comment + // didn't hug it directly, then make sure there is a blank + // line separating them. + if nextItem != o.Rbrace && nextItem.Line != lastCommentPos.Line+1 { + buf.WriteByte(newline) + } + } + } + + if index == len(o.List.Items) { + p.prev = o.Rbrace + break + } + + // At this point we are sure that it's not a totally empty block: print + // the initial newline if it hasn't been printed yet by the previous + // block about standalone comments. + if !newlinePrinted { + buf.WriteByte(newline) + newlinePrinted = true + } + + // check if we have adjacent one liner items. If yes we'll going to align + // the comments. + var aligned []*ast.ObjectItem + for _, item := range o.List.Items[index:] { + // we don't group one line lists + if len(o.List.Items) == 1 { + break + } + + // one means a oneliner with out any lead comment + // two means a oneliner with lead comment + // anything else might be something else + cur := lines(string(p.objectItem(item))) + if cur > 2 { + break + } + + curPos := item.Pos() + + nextPos := token.Pos{} + if index != len(o.List.Items)-1 { + nextPos = o.List.Items[index+1].Pos() + } + + prevPos := token.Pos{} + if index != 0 { + prevPos = o.List.Items[index-1].Pos() + } + + // fmt.Println("DEBUG ----------------") + // fmt.Printf("prev = %+v prevPos: %s\n", prev, prevPos) + // fmt.Printf("cur = %+v curPos: %s\n", cur, curPos) + // fmt.Printf("next = %+v nextPos: %s\n", next, nextPos) + + if curPos.Line+1 == nextPos.Line { + aligned = append(aligned, item) + index++ + continue + } + + if curPos.Line-1 == prevPos.Line { + aligned = append(aligned, item) + index++ + + // finish if we have a new line or comment next. This happens + // if the next item is not adjacent + if curPos.Line+1 != nextPos.Line { + break + } + continue + } + + break + } + + // put newlines if the items are between other non aligned items. + // newlines are also added if there is a standalone comment already, so + // check it too + if !commented && index != len(aligned) { + buf.WriteByte(newline) + } + + if len(aligned) >= 1 { + p.prev = aligned[len(aligned)-1].Pos() + + items := p.alignedItems(aligned) + buf.Write(p.indent(items)) + } else { + p.prev = o.List.Items[index].Pos() + + buf.Write(p.indent(p.objectItem(o.List.Items[index]))) + index++ + } + + buf.WriteByte(newline) + } + + buf.WriteString("}") + return buf.Bytes() +} + +func (p *printer) alignedItems(items []*ast.ObjectItem) []byte { + var buf bytes.Buffer + + // find the longest key and value length, needed for alignment + var longestKeyLen int // longest key length + var longestValLen int // longest value length + for _, item := range items { + key := len(item.Keys[0].Token.Text) + val := len(p.output(item.Val)) + + if key > longestKeyLen { + longestKeyLen = key + } + + if val > longestValLen { + longestValLen = val + } + } + + for i, item := range items { + if item.LeadComment != nil { + for _, comment := range item.LeadComment.List { + buf.WriteString(comment.Text) + buf.WriteByte(newline) + } + } + + for i, k := range item.Keys { + keyLen := len(k.Token.Text) + buf.WriteString(k.Token.Text) + for i := 0; i < longestKeyLen-keyLen+1; i++ { + buf.WriteByte(blank) + } + + // reach end of key + if i == len(item.Keys)-1 && len(item.Keys) == 1 { + buf.WriteString("=") + buf.WriteByte(blank) + } + } + + val := p.output(item.Val) + valLen := len(val) + buf.Write(val) + + if item.Val.Pos().Line == item.Keys[0].Pos().Line && item.LineComment != nil { + for i := 0; i < longestValLen-valLen+1; i++ { + buf.WriteByte(blank) + } + + for _, comment := range item.LineComment.List { + buf.WriteString(comment.Text) + } + } + + // do not print for the last item + if i != len(items)-1 { + buf.WriteByte(newline) + } + } + + return buf.Bytes() +} + +// list returns the printable HCL form of an list type. +func (p *printer) list(l *ast.ListType) []byte { + if p.isSingleLineList(l) { + return p.singleLineList(l) + } + + var buf bytes.Buffer + buf.WriteString("[") + buf.WriteByte(newline) + + var longestLine int + for _, item := range l.List { + // for now we assume that the list only contains literal types + if lit, ok := item.(*ast.LiteralType); ok { + lineLen := len(lit.Token.Text) + if lineLen > longestLine { + longestLine = lineLen + } + } + } + + haveEmptyLine := false + for i, item := range l.List { + // If we have a lead comment, then we want to write that first + leadComment := false + if lit, ok := item.(*ast.LiteralType); ok && lit.LeadComment != nil { + leadComment = true + + // Ensure an empty line before every element with a + // lead comment (except the first item in a list). + if !haveEmptyLine && i != 0 { + buf.WriteByte(newline) + } + + for _, comment := range lit.LeadComment.List { + buf.Write(p.indent([]byte(comment.Text))) + buf.WriteByte(newline) + } + } + + // also indent each line + val := p.output(item) + curLen := len(val) + buf.Write(p.indent(val)) + + // if this item is a heredoc, then we output the comma on + // the next line. This is the only case this happens. + comma := []byte{','} + if lit, ok := item.(*ast.LiteralType); ok && lit.Token.Type == token.HEREDOC { + buf.WriteByte(newline) + comma = p.indent(comma) + } + + buf.Write(comma) + + if lit, ok := item.(*ast.LiteralType); ok && lit.LineComment != nil { + // if the next item doesn't have any comments, do not align + buf.WriteByte(blank) // align one space + for i := 0; i < longestLine-curLen; i++ { + buf.WriteByte(blank) + } + + for _, comment := range lit.LineComment.List { + buf.WriteString(comment.Text) + } + } + + buf.WriteByte(newline) + + // Ensure an empty line after every element with a + // lead comment (except the first item in a list). + haveEmptyLine = leadComment && i != len(l.List)-1 + if haveEmptyLine { + buf.WriteByte(newline) + } + } + + buf.WriteString("]") + return buf.Bytes() +} + +// isSingleLineList returns true if: +// * they were previously formatted entirely on one line +// * they consist entirely of literals +// * there are either no heredoc strings or the list has exactly one element +// * there are no line comments +func (printer) isSingleLineList(l *ast.ListType) bool { + for _, item := range l.List { + if item.Pos().Line != l.Lbrack.Line { + return false + } + + lit, ok := item.(*ast.LiteralType) + if !ok { + return false + } + + if lit.Token.Type == token.HEREDOC && len(l.List) != 1 { + return false + } + + if lit.LineComment != nil { + return false + } + } + + return true +} + +// singleLineList prints a simple single line list. +// For a definition of "simple", see isSingleLineList above. +func (p *printer) singleLineList(l *ast.ListType) []byte { + buf := &bytes.Buffer{} + + buf.WriteString("[") + for i, item := range l.List { + if i != 0 { + buf.WriteString(", ") + } + + // Output the item itself + buf.Write(p.output(item)) + + // The heredoc marker needs to be at the end of line. + if lit, ok := item.(*ast.LiteralType); ok && lit.Token.Type == token.HEREDOC { + buf.WriteByte(newline) + } + } + + buf.WriteString("]") + return buf.Bytes() +} + +// indent indents the lines of the given buffer for each non-empty line +func (p *printer) indent(buf []byte) []byte { + var prefix []byte + if p.cfg.SpacesWidth != 0 { + for i := 0; i < p.cfg.SpacesWidth; i++ { + prefix = append(prefix, blank) + } + } else { + prefix = []byte{tab} + } + + var res []byte + bol := true + for _, c := range buf { + if bol && c != '\n' { + res = append(res, prefix...) + } + + res = append(res, c) + bol = c == '\n' + } + return res +} + +// unindent removes all the indentation from the tombstoned lines +func (p *printer) unindent(buf []byte) []byte { + var res []byte + for i := 0; i < len(buf); i++ { + skip := len(buf)-i <= len(unindent) + if !skip { + skip = !bytes.Equal(unindent, buf[i:i+len(unindent)]) + } + if skip { + res = append(res, buf[i]) + continue + } + + // We have a marker. we have to backtrace here and clean out + // any whitespace ahead of our tombstone up to a \n + for j := len(res) - 1; j >= 0; j-- { + if res[j] == '\n' { + break + } + + res = res[:j] + } + + // Skip the entire unindent marker + i += len(unindent) - 1 + } + + return res +} + +// heredocIndent marks all the 2nd and further lines as unindentable +func (p *printer) heredocIndent(buf []byte) []byte { + var res []byte + bol := false + for _, c := range buf { + if bol && c != '\n' { + res = append(res, unindent...) + } + res = append(res, c) + bol = c == '\n' + } + return res +} + +// isSingleLineObject tells whether the given object item is a single +// line object such as "obj {}". +// +// A single line object: +// +// * has no lead comments (hence multi-line) +// * has no assignment +// * has no values in the stanza (within {}) +// +func (p *printer) isSingleLineObject(val *ast.ObjectItem) bool { + // If there is a lead comment, can't be one line + if val.LeadComment != nil { + return false + } + + // If there is assignment, we always break by line + if val.Assign.IsValid() { + return false + } + + // If it isn't an object type, then its not a single line object + ot, ok := val.Val.(*ast.ObjectType) + if !ok { + return false + } + + // If the object has no items, it is single line! + return len(ot.List.Items) == 0 +} + +func lines(txt string) int { + endline := 1 + for i := 0; i < len(txt); i++ { + if txt[i] == '\n' { + endline++ + } + } + return endline +} + +// ---------------------------------------------------------------------------- +// Tracing support + +func (p *printer) printTrace(a ...interface{}) { + if !p.enableTrace { + return + } + + const dots = ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . " + const n = len(dots) + i := 2 * p.indentTrace + for i > n { + fmt.Print(dots) + i -= n + } + // i <= n + fmt.Print(dots[0:i]) + fmt.Println(a...) +} + +func trace(p *printer, msg string) *printer { + p.printTrace(msg, "(") + p.indentTrace++ + return p +} + +// Usage pattern: defer un(trace(p, "...")) +func un(p *printer) { + p.indentTrace-- + p.printTrace(")") +} diff --git a/vendor/github.com/hashicorp/hcl/hcl/printer/printer.go b/vendor/github.com/hashicorp/hcl/hcl/printer/printer.go new file mode 100644 index 0000000..6617ab8 --- /dev/null +++ b/vendor/github.com/hashicorp/hcl/hcl/printer/printer.go @@ -0,0 +1,66 @@ +// Package printer implements printing of AST nodes to HCL format. +package printer + +import ( + "bytes" + "io" + "text/tabwriter" + + "github.com/hashicorp/hcl/hcl/ast" + "github.com/hashicorp/hcl/hcl/parser" +) + +var DefaultConfig = Config{ + SpacesWidth: 2, +} + +// A Config node controls the output of Fprint. +type Config struct { + SpacesWidth int // if set, it will use spaces instead of tabs for alignment +} + +func (c *Config) Fprint(output io.Writer, node ast.Node) error { + p := &printer{ + cfg: *c, + comments: make([]*ast.CommentGroup, 0), + standaloneComments: make([]*ast.CommentGroup, 0), + // enableTrace: true, + } + + p.collectComments(node) + + if _, err := output.Write(p.unindent(p.output(node))); err != nil { + return err + } + + // flush tabwriter, if any + var err error + if tw, _ := output.(*tabwriter.Writer); tw != nil { + err = tw.Flush() + } + + return err +} + +// Fprint "pretty-prints" an HCL node to output +// It calls Config.Fprint with default settings. +func Fprint(output io.Writer, node ast.Node) error { + return DefaultConfig.Fprint(output, node) +} + +// Format formats src HCL and returns the result. +func Format(src []byte) ([]byte, error) { + node, err := parser.Parse(src) + if err != nil { + return nil, err + } + + var buf bytes.Buffer + if err := DefaultConfig.Fprint(&buf, node); err != nil { + return nil, err + } + + // Add trailing newline to result + buf.WriteString("\n") + return buf.Bytes(), nil +} diff --git a/vendor/github.com/hashicorp/hcl/hcl/scanner/scanner.go b/vendor/github.com/hashicorp/hcl/hcl/scanner/scanner.go index 6601ef7..624a18f 100644 --- a/vendor/github.com/hashicorp/hcl/hcl/scanner/scanner.go +++ b/vendor/github.com/hashicorp/hcl/hcl/scanner/scanner.go @@ -74,14 +74,6 @@ func (s *Scanner) next() rune { return eof } - if ch == utf8.RuneError && size == 1 { - s.srcPos.Column++ - s.srcPos.Offset += size - s.lastCharLen = size - s.err("illegal UTF-8 encoding") - return ch - } - // remember last position s.prevPos = s.srcPos @@ -89,18 +81,27 @@ func (s *Scanner) next() rune { s.lastCharLen = size s.srcPos.Offset += size + if ch == utf8.RuneError && size == 1 { + s.err("illegal UTF-8 encoding") + return ch + } + if ch == '\n' { s.srcPos.Line++ s.lastLineLen = s.srcPos.Column s.srcPos.Column = 0 } - // If we see a null character with data left, then that is an error - if ch == '\x00' && s.buf.Len() > 0 { + if ch == '\x00' { s.err("unexpected null character (0x00)") return eof } + if ch == '\uE123' { + s.err("unicode code point U+E123 reserved for internal use") + return utf8.RuneError + } + // debug // fmt.Printf("ch: %q, offset:column: %d:%d\n", ch, s.srcPos.Offset, s.srcPos.Column) return ch @@ -432,16 +433,16 @@ func (s *Scanner) scanHeredoc() { // Read the identifier identBytes := s.src[offs : s.srcPos.Offset-s.lastCharLen] - if len(identBytes) == 0 { + if len(identBytes) == 0 || (len(identBytes) == 1 && identBytes[0] == '-') { s.err("zero-length heredoc anchor") return } var identRegexp *regexp.Regexp if identBytes[0] == '-' { - identRegexp = regexp.MustCompile(fmt.Sprintf(`[[:space:]]*%s\z`, identBytes[1:])) + identRegexp = regexp.MustCompile(fmt.Sprintf(`^[[:space:]]*%s\r*\z`, identBytes[1:])) } else { - identRegexp = regexp.MustCompile(fmt.Sprintf(`[[:space:]]*%s\z`, identBytes)) + identRegexp = regexp.MustCompile(fmt.Sprintf(`^[[:space:]]*%s\r*\z`, identBytes)) } // Read the actual string value @@ -551,7 +552,7 @@ func (s *Scanner) scanDigits(ch rune, base, n int) rune { s.err("illegal char escape") } - if n != start { + if n != start && ch != eof { // we scanned all digits, put the last non digit char back, // only if we read anything at all s.unread() diff --git a/vendor/github.com/influxdata/influxdb/LICENSE_OF_DEPENDENCIES.md b/vendor/github.com/influxdata/influxdb/LICENSE_OF_DEPENDENCIES.md index 8311b75..b5b0df8 100644 --- a/vendor/github.com/influxdata/influxdb/LICENSE_OF_DEPENDENCIES.md +++ b/vendor/github.com/influxdata/influxdb/LICENSE_OF_DEPENDENCIES.md @@ -1,7 +1,9 @@ -# List +- # List - bootstrap 3.3.5 [MIT LICENSE](https://github.com/twbs/bootstrap/blob/master/LICENSE) - collectd.org [ISC LICENSE](https://github.com/collectd/go-collectd/blob/master/LICENSE) - github.com/BurntSushi/toml [MIT LICENSE](https://github.com/BurntSushi/toml/blob/master/COPYING) +- github.com/RoaringBitmap/roaring [APACHE LICENSE](https://github.com/RoaringBitmap/roaring/blob/master/LICENSE) +- github.com/beorn7/perks [MIT LICENSE](https://github.com/beorn7/perks/blob/master/LICENSE) - github.com/bmizerany/pat [MIT LICENSE](https://github.com/bmizerany/pat#license) - github.com/boltdb/bolt [MIT LICENSE](https://github.com/boltdb/bolt/blob/master/LICENSE) - github.com/cespare/xxhash [MIT LICENSE](https://github.com/cespare/xxhash/blob/master/LICENSE.txt) @@ -10,20 +12,52 @@ - github.com/dgrijalva/jwt-go [MIT LICENSE](https://github.com/dgrijalva/jwt-go/blob/master/LICENSE) - github.com/dgryski/go-bits [MIT LICENSE](https://github.com/dgryski/go-bits/blob/master/LICENSE) - github.com/dgryski/go-bitstream [MIT LICENSE](https://github.com/dgryski/go-bitstream/blob/master/LICENSE) +- github.com/glycerine/go-unsnap-stream [MIT LICENSE](https://github.com/glycerine/go-unsnap-stream/blob/master/LICENSE) - github.com/gogo/protobuf/proto [BSD LICENSE](https://github.com/gogo/protobuf/blob/master/LICENSE) +- github.com/golang/protobuf [BSD LICENSE](https://github.com/golang/protobuf/blob/master/LICENSE) - github.com/golang/snappy [BSD LICENSE](https://github.com/golang/snappy/blob/master/LICENSE) - github.com/google/go-cmp [BSD LICENSE](https://github.com/google/go-cmp/blob/master/LICENSE) +- github.com/influxdata/influxql [MIT LICENSE](https://github.com/influxdata/influxql/blob/master/LICENSE) - github.com/influxdata/usage-client [MIT LICENSE](https://github.com/influxdata/usage-client/blob/master/LICENSE.txt) +- github.com/influxdata/yamux [MOZILLA PUBLIC LICENSE](https://github.com/influxdata/yamux/blob/master/LICENSE) +- github.com/influxdata/yarpc [MIT LICENSE](https://github.com/influxdata/yarpc/blob/master/LICENSE) +- github.com/jsternberg/zap-logfmt [MIT LICENSE](https://github.com/jsternberg/zap-logfmt/blob/master/LICENSE) - github.com/jwilder/encoding [MIT LICENSE](https://github.com/jwilder/encoding/blob/master/LICENSE) -- github.com/philhofer/fwd [MIT LICENSE](https://github.com/philhofer/fwd/blob/master/LICENSE.md) +- github.com/klauspost/pgzip [MIT LICENSE](https://github.com/klauspost/pgzip/blob/master/LICENSE) +- github.com/mattn/go-isatty [MIT LICENSE](https://github.com/mattn/go-isatty/blob/master/LICENSE) +- github.com/matttproud/golang_protobuf_extensions [APACHE LICENSE](https://github.com/matttproud/golang_protobuf_extensions/blob/master/LICENSE) +- github.com/opentracing/opentracing-go [MIT LICENSE](https://github.com/opentracing/opentracing-go/blob/master/LICENSE) - github.com/paulbellamy/ratecounter [MIT LICENSE](https://github.com/paulbellamy/ratecounter/blob/master/LICENSE) - github.com/peterh/liner [MIT LICENSE](https://github.com/peterh/liner/blob/master/COPYING) -- github.com/tinylib/msgp [MIT LICENSE](https://github.com/tinylib/msgp/blob/master/LICENSE) +- github.com/philhofer/fwd [MIT LICENSE](https://github.com/philhofer/fwd/blob/master/LICENSE.md) +- github.com/prometheus/client_golang [MIT LICENSE](https://github.com/prometheus/client_golang/blob/master/LICENSE) +- github.com/prometheus/client_model [MIT LICENSE](https://github.com/prometheus/client_model/blob/master/LICENSE) +- github.com/prometheus/common [APACHE LICENSE](https://github.com/prometheus/common/blob/master/LICENSE) +- github.com/prometheus/procfs [APACHE LICENSE](https://github.com/prometheus/procfs/blob/master/LICENSE) - github.com/rakyll/statik [APACHE LICENSE](https://github.com/rakyll/statik/blob/master/LICENSE) - github.com/retailnext/hllpp [BSD LICENSE](https://github.com/retailnext/hllpp/blob/master/LICENSE) -- github.com/uber-go/atomic [MIT LICENSE](https://github.com/uber-go/atomic/blob/master/LICENSE.txt) -- github.com/uber-go/zap [MIT LICENSE](https://github.com/uber-go/zap/blob/master/LICENSE.txt) +- github.com/tinylib/msgp [MIT LICENSE](https://github.com/tinylib/msgp/blob/master/LICENSE) +- go.uber.org/atomic [MIT LICENSE](https://github.com/uber-go/atomic/blob/master/LICENSE.txt) +- go.uber.org/multierr [MIT LICENSE](https://github.com/uber-go/multierr/blob/master/LICENSE.txt) +- go.uber.org/zap [MIT LICENSE](https://github.com/uber-go/zap/blob/master/LICENSE.txt) - golang.org/x/crypto [BSD LICENSE](https://github.com/golang/crypto/blob/master/LICENSE) +- golang.org/x/net [BSD LICENSE](https://github.com/golang/net/blob/master/LICENSE) +- golang.org/x/sys [BSD LICENSE](https://github.com/golang/sys/blob/master/LICENSE) - golang.org/x/text [BSD LICENSE](https://github.com/golang/text/blob/master/LICENSE) +- golang.org/x/time [BSD LICENSE](https://github.com/golang/time/blob/master/LICENSE) - jquery 2.1.4 [MIT LICENSE](https://github.com/jquery/jquery/blob/master/LICENSE.txt) - github.com/xlab/treeprint [MIT LICENSE](https://github.com/xlab/treeprint/blob/master/LICENSE) + + + + + + + + + + + + + + diff --git a/vendor/github.com/influxdata/influxdb/client/v2/client.go b/vendor/github.com/influxdata/influxdb/client/v2/client.go index 2870cf8..6a5c238 100644 --- a/vendor/github.com/influxdata/influxdb/client/v2/client.go +++ b/vendor/github.com/influxdata/influxdb/client/v2/client.go @@ -12,6 +12,7 @@ import ( "mime" "net/http" "net/url" + "path" "strconv" "strings" "time" @@ -44,6 +45,9 @@ type HTTPConfig struct { // TLSConfig allows the user to set their own TLS config for the HTTP // Client. If set, this option overrides InsecureSkipVerify. TLSConfig *tls.Config + + // Proxy configures the Proxy function on the HTTP client. + Proxy func(req *http.Request) (*url.URL, error) } // BatchPointsConfig is the config data needed to create an instance of the BatchPoints struct. @@ -98,6 +102,7 @@ func NewHTTPClient(conf HTTPConfig) (Client, error) { TLSClientConfig: &tls.Config{ InsecureSkipVerify: conf.InsecureSkipVerify, }, + Proxy: conf.Proxy, } if conf.TLSConfig != nil { tr.TLSClientConfig = conf.TLSConfig @@ -119,8 +124,9 @@ func NewHTTPClient(conf HTTPConfig) (Client, error) { // Ping returns how long the request took, the version of the server it connected to, and an error if one occurred. func (c *client) Ping(timeout time.Duration) (time.Duration, string, error) { now := time.Now() + u := c.url - u.Path = "ping" + u.Path = path.Join(u.Path, "ping") req, err := http.NewRequest("GET", u.String(), nil) if err != nil { @@ -169,7 +175,7 @@ func (c *client) Close() error { // once the client is instantiated. type client struct { // N.B - if url.UserInfo is accessed in future modifications to the - // methods on client, you will need to syncronise access to url. + // methods on client, you will need to synchronize access to url. url url.URL username string password string @@ -319,8 +325,8 @@ func (p *Point) String() string { // PrecisionString returns a line-protocol string of the Point, // with the timestamp formatted for the given precision. -func (p *Point) PrecisionString(precison string) string { - return p.pt.PrecisionString(precison) +func (p *Point) PrecisionString(precision string) string { + return p.pt.PrecisionString(precision) } // Name returns the measurement name of the point. @@ -357,6 +363,9 @@ func (c *client) Write(bp BatchPoints) error { var b bytes.Buffer for _, p := range bp.Points() { + if p == nil { + continue + } if _, err := b.WriteString(p.pt.PrecisionString(bp.Precision())); err != nil { return err } @@ -367,7 +376,8 @@ func (c *client) Write(bp BatchPoints) error { } u := c.url - u.Path = "write" + u.Path = path.Join(u.Path, "write") + req, err := http.NewRequest("POST", u.String(), &b) if err != nil { return err @@ -406,12 +416,13 @@ func (c *client) Write(bp BatchPoints) error { // Query defines a query to send to the server. type Query struct { - Command string - Database string - Precision string - Chunked bool - ChunkSize int - Parameters map[string]interface{} + Command string + Database string + RetentionPolicy string + Precision string + Chunked bool + ChunkSize int + Parameters map[string]interface{} } // NewQuery returns a query object. @@ -425,6 +436,19 @@ func NewQuery(command, database, precision string) Query { } } +// NewQueryWithRP returns a query object. +// The database, retention policy, and precision arguments can be empty strings if they are not needed +// for the query. Setting the retention policy only works on InfluxDB versions 1.6 or greater. +func NewQueryWithRP(command, database, retentionPolicy, precision string) Query { + return Query{ + Command: command, + Database: database, + RetentionPolicy: retentionPolicy, + Precision: precision, + Parameters: make(map[string]interface{}), + } +} + // NewQueryWithParameters returns a query object. // The database and precision arguments can be empty strings if they are not needed for the query. // parameters is a map of the parameter names used in the command to their values. @@ -473,7 +497,7 @@ type Result struct { // Query sends a command to the server and returns the Response. func (c *client) Query(q Query) (*Response, error) { u := c.url - u.Path = "query" + u.Path = path.Join(u.Path, "query") jsonParameters, err := json.Marshal(q.Parameters) @@ -496,6 +520,9 @@ func (c *client) Query(q Query) (*Response, error) { params := req.URL.Query() params.Set("q", q.Command) params.Set("db", q.Database) + if q.RetentionPolicy != "" { + params.Set("rp", q.RetentionPolicy) + } params.Set("params", string(jsonParameters)) if q.Chunked { params.Set("chunked", "true") @@ -534,7 +561,7 @@ func (c *client) Query(q Query) (*Response, error) { // like downstream serving a large file body, err := ioutil.ReadAll(io.LimitReader(resp.Body, 1024)) if err != nil || len(body) == 0 { - return nil, fmt.Errorf("expected json response, got %q, with status: %v", cType, resp.StatusCode) + return nil, fmt.Errorf("expected json response, got empty body, with status: %v", resp.StatusCode) } return nil, fmt.Errorf("expected json response, got %q, with status: %v and response body: %q", cType, resp.StatusCode, body) diff --git a/vendor/github.com/influxdata/influxdb/models/points.go b/vendor/github.com/influxdata/influxdb/models/points.go index 86594da..f8571af 100644 --- a/vendor/github.com/influxdata/influxdb/models/points.go +++ b/vendor/github.com/influxdata/influxdb/models/points.go @@ -12,20 +12,27 @@ import ( "strconv" "strings" "time" + "unicode" + "unicode/utf8" "github.com/influxdata/influxdb/pkg/escape" ) +type escapeSet struct { + k [1]byte + esc [2]byte +} + var ( - measurementEscapeCodes = map[byte][]byte{ - ',': []byte(`\,`), - ' ': []byte(`\ `), + measurementEscapeCodes = [...]escapeSet{ + {k: [1]byte{','}, esc: [2]byte{'\\', ','}}, + {k: [1]byte{' '}, esc: [2]byte{'\\', ' '}}, } - tagEscapeCodes = map[byte][]byte{ - ',': []byte(`\,`), - ' ': []byte(`\ `), - '=': []byte(`\=`), + tagEscapeCodes = [...]escapeSet{ + {k: [1]byte{','}, esc: [2]byte{'\\', ','}}, + {k: [1]byte{' '}, esc: [2]byte{'\\', ' '}}, + {k: [1]byte{'='}, esc: [2]byte{'\\', '='}}, } // ErrPointMustHaveAField is returned when operating on a point that does not have any fields. @@ -64,6 +71,9 @@ type Point interface { // Tags returns the tag set for the point. Tags() Tags + // ForEachTag iterates over each tag invoking fn. If fn return false, iteration stops. + ForEachTag(fn func(k, v []byte) bool) + // AddTag adds or replaces a tag value for a point. AddTag(key, value string) @@ -263,31 +273,46 @@ func ParsePointsString(buf string) ([]Point, error) { // NOTE: to minimize heap allocations, the returned Tags will refer to subslices of buf. // This can have the unintended effect preventing buf from being garbage collected. func ParseKey(buf []byte) (string, Tags) { + name, tags := ParseKeyBytes(buf) + return string(name), tags +} + +func ParseKeyBytes(buf []byte) ([]byte, Tags) { + return ParseKeyBytesWithTags(buf, nil) +} + +func ParseKeyBytesWithTags(buf []byte, tags Tags) ([]byte, Tags) { // Ignore the error because scanMeasurement returns "missing fields" which we ignore // when just parsing a key state, i, _ := scanMeasurement(buf, 0) - var tags Tags + var name []byte if state == tagKeyState { - tags = parseTags(buf) + tags = parseTags(buf, tags) // scanMeasurement returns the location of the comma if there are tags, strip that off - return string(buf[:i-1]), tags + name = buf[:i-1] + } else { + name = buf[:i] } - return string(buf[:i]), tags + return unescapeMeasurement(name), tags } -func ParseTags(buf []byte) (Tags, error) { - return parseTags(buf), nil +func ParseTags(buf []byte) Tags { + return parseTags(buf, nil) } -func ParseName(buf []byte) ([]byte, error) { +func ParseName(buf []byte) []byte { // Ignore the error because scanMeasurement returns "missing fields" which we ignore // when just parsing a key state, i, _ := scanMeasurement(buf, 0) + var name []byte if state == tagKeyState { - return buf[:i-1], nil + name = buf[:i-1] + } else { + name = buf[:i] } - return buf[:i], nil + + return unescapeMeasurement(name) } // ParsePointsWithPrecision is similar to ParsePoints, but allows the @@ -1194,23 +1219,33 @@ func scanFieldValue(buf []byte, i int) (int, []byte) { } func EscapeMeasurement(in []byte) []byte { - for b, esc := range measurementEscapeCodes { - in = bytes.Replace(in, []byte{b}, esc, -1) + for _, c := range measurementEscapeCodes { + if bytes.IndexByte(in, c.k[0]) != -1 { + in = bytes.Replace(in, c.k[:], c.esc[:], -1) + } } return in } func unescapeMeasurement(in []byte) []byte { - for b, esc := range measurementEscapeCodes { - in = bytes.Replace(in, esc, []byte{b}, -1) + if bytes.IndexByte(in, '\\') == -1 { + return in + } + + for i := range measurementEscapeCodes { + c := &measurementEscapeCodes[i] + if bytes.IndexByte(in, c.k[0]) != -1 { + in = bytes.Replace(in, c.esc[:], c.k[:], -1) + } } return in } func escapeTag(in []byte) []byte { - for b, esc := range tagEscapeCodes { - if bytes.IndexByte(in, b) != -1 { - in = bytes.Replace(in, []byte{b}, esc, -1) + for i := range tagEscapeCodes { + c := &tagEscapeCodes[i] + if bytes.IndexByte(in, c.k[0]) != -1 { + in = bytes.Replace(in, c.k[:], c.esc[:], -1) } } return in @@ -1221,9 +1256,10 @@ func unescapeTag(in []byte) []byte { return in } - for b, esc := range tagEscapeCodes { - if bytes.IndexByte(in, b) != -1 { - in = bytes.Replace(in, esc, []byte{b}, -1) + for i := range tagEscapeCodes { + c := &tagEscapeCodes[i] + if bytes.IndexByte(in, c.k[0]) != -1 { + in = bytes.Replace(in, c.esc[:], c.k[:], -1) } } return in @@ -1275,7 +1311,8 @@ func unescapeStringField(in string) string { } // NewPoint returns a new point with the given measurement name, tags, fields and timestamp. If -// an unsupported field value (NaN) or out of range time is passed, this function returns an error. +// an unsupported field value (NaN, or +/-Inf) or out of range time is passed, this function +// returns an error. func NewPoint(name string, tags Tags, fields Fields, t time.Time) (Point, error) { key, err := pointKey(name, tags, fields, t) if err != nil { @@ -1306,11 +1343,17 @@ func pointKey(measurement string, tags Tags, fields Fields, t time.Time) ([]byte switch value := value.(type) { case float64: // Ensure the caller validates and handles invalid field values + if math.IsInf(value, 0) { + return nil, fmt.Errorf("+/-Inf is an unsupported value for field %s", key) + } if math.IsNaN(value) { return nil, fmt.Errorf("NaN is an unsupported value for field %s", key) } case float32: // Ensure the caller validates and handles invalid field values + if math.IsInf(float64(value), 0) { + return nil, fmt.Errorf("+/-Inf is an unsupported value for field %s", key) + } if math.IsNaN(float64(value)) { return nil, fmt.Errorf("NaN is an unsupported value for field %s", key) } @@ -1436,10 +1479,14 @@ func (p *point) Tags() Tags { if p.cachedTags != nil { return p.cachedTags } - p.cachedTags = parseTags(p.key) + p.cachedTags = parseTags(p.key, nil) return p.cachedTags } +func (p *point) ForEachTag(fn func(k, v []byte) bool) { + walkTags(p.key, fn) +} + func (p *point) HasTag(tag []byte) bool { if len(p.key) == 0 { return false @@ -1518,24 +1565,49 @@ func walkFields(buf []byte, fn func(key, value []byte) bool) { } } -func parseTags(buf []byte) Tags { +// parseTags parses buf into the provided destination tags, returning destination +// Tags, which may have a different length and capacity. +func parseTags(buf []byte, dst Tags) Tags { if len(buf) == 0 { return nil } - tags := make(Tags, 0, bytes.Count(buf, []byte(","))) + n := bytes.Count(buf, []byte(",")) + if cap(dst) < n { + dst = make(Tags, n) + } else { + dst = dst[:n] + } + + // Ensure existing behaviour when point has no tags and nil slice passed in. + if dst == nil { + dst = Tags{} + } + + // Series keys can contain escaped commas, therefore the number of commas + // in a series key only gives an estimation of the upper bound on the number + // of tags. + var i int walkTags(buf, func(key, value []byte) bool { - tags = append(tags, NewTag(key, value)) + dst[i].Key, dst[i].Value = key, value + i++ return true }) - return tags + return dst[:i] } // MakeKey creates a key for a set of tags. func MakeKey(name []byte, tags Tags) []byte { + return AppendMakeKey(nil, name, tags) +} + +// AppendMakeKey appends the key derived from name and tags to dst and returns the extended buffer. +func AppendMakeKey(dst []byte, name []byte, tags Tags) []byte { // unescape the name and then re-escape it to avoid double escaping. // The key should always be stored in escaped form. - return append(EscapeMeasurement(unescapeMeasurement(name)), tags.HashKey()...) + dst = append(dst, EscapeMeasurement(unescapeMeasurement(name))...) + dst = tags.AppendHashKey(dst) + return dst } // SetTags replaces the tags for the point. @@ -1684,10 +1756,7 @@ func (p *point) UnmarshalBinary(b []byte) error { p.fields, b = b[:n], b[n:] // Read timestamp. - if err := p.time.UnmarshalBinary(b); err != nil { - return err - } - return nil + return p.time.UnmarshalBinary(b) } // PrecisionString returns a string representation of the point. If there @@ -1906,8 +1975,8 @@ func (a Tags) String() string { // for data structures or delimiters for example. func (a Tags) Size() int { var total int - for _, t := range a { - total += t.Size() + for i := range a { + total += a[i].Size() } return total } @@ -2040,42 +2109,78 @@ func (a Tags) Merge(other map[string]string) Tags { // HashKey hashes all of a tag's keys. func (a Tags) HashKey() []byte { + return a.AppendHashKey(nil) +} + +func (a Tags) needsEscape() bool { + for i := range a { + t := &a[i] + for j := range tagEscapeCodes { + c := &tagEscapeCodes[j] + if bytes.IndexByte(t.Key, c.k[0]) != -1 || bytes.IndexByte(t.Value, c.k[0]) != -1 { + return true + } + } + } + return false +} + +// AppendHashKey appends the result of hashing all of a tag's keys and values to dst and returns the extended buffer. +func (a Tags) AppendHashKey(dst []byte) []byte { // Empty maps marshal to empty bytes. if len(a) == 0 { - return nil + return dst } // Type invariant: Tags are sorted - escaped := make(Tags, 0, len(a)) sz := 0 - for _, t := range a { - ek := escapeTag(t.Key) - ev := escapeTag(t.Value) + var escaped Tags + if a.needsEscape() { + var tmp [20]Tag + if len(a) < len(tmp) { + escaped = tmp[:len(a)] + } else { + escaped = make(Tags, len(a)) + } - if len(ev) > 0 { - escaped = append(escaped, Tag{Key: ek, Value: ev}) - sz += len(ek) + len(ev) + for i := range a { + t := &a[i] + nt := &escaped[i] + nt.Key = escapeTag(t.Key) + nt.Value = escapeTag(t.Value) + sz += len(nt.Key) + len(nt.Value) } + } else { + sz = a.Size() + escaped = a } sz += len(escaped) + (len(escaped) * 2) // separators // Generate marshaled bytes. - b := make([]byte, sz) - buf := b + if cap(dst)-len(dst) < sz { + nd := make([]byte, len(dst), len(dst)+sz) + copy(nd, dst) + dst = nd + } + buf := dst[len(dst) : len(dst)+sz] idx := 0 - for _, k := range escaped { + for i := range escaped { + k := &escaped[i] + if len(k.Value) == 0 { + continue + } buf[idx] = ',' idx++ - copy(buf[idx:idx+len(k.Key)], k.Key) + copy(buf[idx:], k.Key) idx += len(k.Key) buf[idx] = '=' idx++ - copy(buf[idx:idx+len(k.Value)], k.Value) + copy(buf[idx:], k.Value) idx += len(k.Value) } - return b[:idx] + return dst[:len(dst)+idx] } // CopyTags returns a shallow copy of tags. @@ -2322,8 +2427,29 @@ func appendField(b []byte, k string, v interface{}) []byte { return b } -type byteSlices [][]byte +// ValidKeyToken returns true if the token used for measurement, tag key, or tag +// value is a valid unicode string and only contains printable, non-replacement characters. +func ValidKeyToken(s string) bool { + if !utf8.ValidString(s) { + return false + } + for _, r := range s { + if !unicode.IsPrint(r) || r == unicode.ReplacementChar { + return false + } + } + return true +} -func (a byteSlices) Len() int { return len(a) } -func (a byteSlices) Less(i, j int) bool { return bytes.Compare(a[i], a[j]) == -1 } -func (a byteSlices) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +// ValidKeyTokens returns true if the measurement name and all tags are valid. +func ValidKeyTokens(name string, tags Tags) bool { + if !ValidKeyToken(name) { + return false + } + for _, tag := range tags { + if !ValidKeyToken(string(tag.Key)) || !ValidKeyToken(string(tag.Value)) { + return false + } + } + return true +} diff --git a/vendor/github.com/influxdata/influxdb/pkg/escape/bytes.go b/vendor/github.com/influxdata/influxdb/pkg/escape/bytes.go index ac7ed5a..f3b31f4 100644 --- a/vendor/github.com/influxdata/influxdb/pkg/escape/bytes.go +++ b/vendor/github.com/influxdata/influxdb/pkg/escape/bytes.go @@ -78,7 +78,11 @@ func Unescape(in []byte) []byte { i := 0 inLen := len(in) - var out []byte + + // The output size will be no more than inLen. Preallocating the + // capacity of the output is faster and uses less memory than + // letting append() do its own (over)allocation. + out := make([]byte, 0, inLen) for { if i >= inLen { diff --git a/vendor/github.com/magiconair/properties/LICENSE b/vendor/github.com/magiconair/properties/LICENSE index 7eab43b..b387087 100644 --- a/vendor/github.com/magiconair/properties/LICENSE +++ b/vendor/github.com/magiconair/properties/LICENSE @@ -1,6 +1,6 @@ goproperties - properties file decoder for Go -Copyright (c) 2013-2014 - Frank Schroeder +Copyright (c) 2013-2018 - Frank Schroeder All rights reserved. diff --git a/vendor/github.com/magiconair/properties/decode.go b/vendor/github.com/magiconair/properties/decode.go index 0a961bb..3ebf804 100644 --- a/vendor/github.com/magiconair/properties/decode.go +++ b/vendor/github.com/magiconair/properties/decode.go @@ -1,4 +1,4 @@ -// Copyright 2017 Frank Schroeder. All rights reserved. +// Copyright 2018 Frank Schroeder. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/magiconair/properties/doc.go b/vendor/github.com/magiconair/properties/doc.go index 36c8368..f8822da 100644 --- a/vendor/github.com/magiconair/properties/doc.go +++ b/vendor/github.com/magiconair/properties/doc.go @@ -1,4 +1,4 @@ -// Copyright 2017 Frank Schroeder. All rights reserved. +// Copyright 2018 Frank Schroeder. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. @@ -73,7 +73,7 @@ // # refers to the users' home dir // home = ${HOME} // -// # local key takes precendence over env var: u = foo +// # local key takes precedence over env var: u = foo // USER = foo // u = ${USER} // @@ -102,7 +102,7 @@ // v = p.GetString("key", "def") // v = p.GetDuration("key", 999) // -// As an alterantive properties may be applied with the standard +// As an alternative properties may be applied with the standard // library's flag implementation at any time. // // # Standard configuration diff --git a/vendor/github.com/magiconair/properties/integrate.go b/vendor/github.com/magiconair/properties/integrate.go index 0d775e0..74d38dc 100644 --- a/vendor/github.com/magiconair/properties/integrate.go +++ b/vendor/github.com/magiconair/properties/integrate.go @@ -1,4 +1,4 @@ -// Copyright 2017 Frank Schroeder. All rights reserved. +// Copyright 2018 Frank Schroeder. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/magiconair/properties/lex.go b/vendor/github.com/magiconair/properties/lex.go index c63fcc6..367166d 100644 --- a/vendor/github.com/magiconair/properties/lex.go +++ b/vendor/github.com/magiconair/properties/lex.go @@ -1,4 +1,4 @@ -// Copyright 2017 Frank Schroeder. All rights reserved. +// Copyright 2018 Frank Schroeder. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // diff --git a/vendor/github.com/magiconair/properties/load.go b/vendor/github.com/magiconair/properties/load.go index 278cc2e..c8e1b58 100644 --- a/vendor/github.com/magiconair/properties/load.go +++ b/vendor/github.com/magiconair/properties/load.go @@ -1,4 +1,4 @@ -// Copyright 2017 Frank Schroeder. All rights reserved. +// Copyright 2018 Frank Schroeder. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. @@ -16,21 +16,157 @@ import ( type Encoding uint const ( + // utf8Default is a private placeholder for the zero value of Encoding to + // ensure that it has the correct meaning. UTF8 is the default encoding but + // was assigned a non-zero value which cannot be changed without breaking + // existing code. Clients should continue to use the public constants. + utf8Default Encoding = iota + // UTF8 interprets the input data as UTF-8. - UTF8 Encoding = 1 << iota + UTF8 // ISO_8859_1 interprets the input data as ISO-8859-1. ISO_8859_1 ) +type Loader struct { + // Encoding determines how the data from files and byte buffers + // is interpreted. For URLs the Content-Type header is used + // to determine the encoding of the data. + Encoding Encoding + + // DisableExpansion configures the property expansion of the + // returned property object. When set to true, the property values + // will not be expanded and the Property object will not be checked + // for invalid expansion expressions. + DisableExpansion bool + + // IgnoreMissing configures whether missing files or URLs which return + // 404 are reported as errors. When set to true, missing files and 404 + // status codes are not reported as errors. + IgnoreMissing bool +} + +// Load reads a buffer into a Properties struct. +func (l *Loader) LoadBytes(buf []byte) (*Properties, error) { + return l.loadBytes(buf, l.Encoding) +} + +// LoadAll reads the content of multiple URLs or files in the given order into +// a Properties struct. If IgnoreMissing is true then a 404 status code or +// missing file will not be reported as error. Encoding sets the encoding for +// files. For the URLs see LoadURL for the Content-Type header and the +// encoding. +func (l *Loader) LoadAll(names []string) (*Properties, error) { + all := NewProperties() + for _, name := range names { + n, err := expandName(name) + if err != nil { + return nil, err + } + + var p *Properties + switch { + case strings.HasPrefix(n, "http://"): + p, err = l.LoadURL(n) + case strings.HasPrefix(n, "https://"): + p, err = l.LoadURL(n) + default: + p, err = l.LoadFile(n) + } + if err != nil { + return nil, err + } + all.Merge(p) + } + + all.DisableExpansion = l.DisableExpansion + if all.DisableExpansion { + return all, nil + } + return all, all.check() +} + +// LoadFile reads a file into a Properties struct. +// If IgnoreMissing is true then a missing file will not be +// reported as error. +func (l *Loader) LoadFile(filename string) (*Properties, error) { + data, err := ioutil.ReadFile(filename) + if err != nil { + if l.IgnoreMissing && os.IsNotExist(err) { + LogPrintf("properties: %s not found. skipping", filename) + return NewProperties(), nil + } + return nil, err + } + return l.loadBytes(data, l.Encoding) +} + +// LoadURL reads the content of the URL into a Properties struct. +// +// The encoding is determined via the Content-Type header which +// should be set to 'text/plain'. If the 'charset' parameter is +// missing, 'iso-8859-1' or 'latin1' the encoding is set to +// ISO-8859-1. If the 'charset' parameter is set to 'utf-8' the +// encoding is set to UTF-8. A missing content type header is +// interpreted as 'text/plain; charset=utf-8'. +func (l *Loader) LoadURL(url string) (*Properties, error) { + resp, err := http.Get(url) + if err != nil { + return nil, fmt.Errorf("properties: error fetching %q. %s", url, err) + } + + if resp.StatusCode == 404 && l.IgnoreMissing { + LogPrintf("properties: %s returned %d. skipping", url, resp.StatusCode) + return NewProperties(), nil + } + + if resp.StatusCode != 200 { + return nil, fmt.Errorf("properties: %s returned %d", url, resp.StatusCode) + } + + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, fmt.Errorf("properties: %s error reading response. %s", url, err) + } + defer resp.Body.Close() + + ct := resp.Header.Get("Content-Type") + var enc Encoding + switch strings.ToLower(ct) { + case "text/plain", "text/plain; charset=iso-8859-1", "text/plain; charset=latin1": + enc = ISO_8859_1 + case "", "text/plain; charset=utf-8": + enc = UTF8 + default: + return nil, fmt.Errorf("properties: invalid content type %s", ct) + } + + return l.loadBytes(body, enc) +} + +func (l *Loader) loadBytes(buf []byte, enc Encoding) (*Properties, error) { + p, err := parse(convert(buf, enc)) + if err != nil { + return nil, err + } + p.DisableExpansion = l.DisableExpansion + if p.DisableExpansion { + return p, nil + } + return p, p.check() +} + // Load reads a buffer into a Properties struct. func Load(buf []byte, enc Encoding) (*Properties, error) { - return loadBuf(buf, enc) + l := &Loader{Encoding: enc} + return l.LoadBytes(buf) } // LoadString reads an UTF8 string into a properties struct. func LoadString(s string) (*Properties, error) { - return loadBuf([]byte(s), UTF8) + l := &Loader{Encoding: UTF8} + return l.LoadBytes([]byte(s)) } // LoadMap creates a new Properties struct from a string map. @@ -44,34 +180,32 @@ func LoadMap(m map[string]string) *Properties { // LoadFile reads a file into a Properties struct. func LoadFile(filename string, enc Encoding) (*Properties, error) { - return loadAll([]string{filename}, enc, false) + l := &Loader{Encoding: enc} + return l.LoadAll([]string{filename}) } // LoadFiles reads multiple files in the given order into // a Properties struct. If 'ignoreMissing' is true then // non-existent files will not be reported as error. func LoadFiles(filenames []string, enc Encoding, ignoreMissing bool) (*Properties, error) { - return loadAll(filenames, enc, ignoreMissing) + l := &Loader{Encoding: enc, IgnoreMissing: ignoreMissing} + return l.LoadAll(filenames) } // LoadURL reads the content of the URL into a Properties struct. -// -// The encoding is determined via the Content-Type header which -// should be set to 'text/plain'. If the 'charset' parameter is -// missing, 'iso-8859-1' or 'latin1' the encoding is set to -// ISO-8859-1. If the 'charset' parameter is set to 'utf-8' the -// encoding is set to UTF-8. A missing content type header is -// interpreted as 'text/plain; charset=utf-8'. +// See Loader#LoadURL for details. func LoadURL(url string) (*Properties, error) { - return loadAll([]string{url}, UTF8, false) + l := &Loader{Encoding: UTF8} + return l.LoadAll([]string{url}) } // LoadURLs reads the content of multiple URLs in the given order into a -// Properties struct. If 'ignoreMissing' is true then a 404 status code will -// not be reported as error. See LoadURL for the Content-Type header +// Properties struct. If IgnoreMissing is true then a 404 status code will +// not be reported as error. See Loader#LoadURL for the Content-Type header // and the encoding. func LoadURLs(urls []string, ignoreMissing bool) (*Properties, error) { - return loadAll(urls, UTF8, ignoreMissing) + l := &Loader{Encoding: UTF8, IgnoreMissing: ignoreMissing} + return l.LoadAll(urls) } // LoadAll reads the content of multiple URLs or files in the given order into a @@ -79,7 +213,8 @@ func LoadURLs(urls []string, ignoreMissing bool) (*Properties, error) { // not be reported as error. Encoding sets the encoding for files. For the URLs please see // LoadURL for the Content-Type header and the encoding. func LoadAll(names []string, enc Encoding, ignoreMissing bool) (*Properties, error) { - return loadAll(names, enc, ignoreMissing) + l := &Loader{Encoding: enc, IgnoreMissing: ignoreMissing} + return l.LoadAll(names) } // MustLoadString reads an UTF8 string into a Properties struct and @@ -122,90 +257,6 @@ func MustLoadAll(names []string, enc Encoding, ignoreMissing bool) *Properties { return must(LoadAll(names, enc, ignoreMissing)) } -func loadBuf(buf []byte, enc Encoding) (*Properties, error) { - p, err := parse(convert(buf, enc)) - if err != nil { - return nil, err - } - return p, p.check() -} - -func loadAll(names []string, enc Encoding, ignoreMissing bool) (*Properties, error) { - result := NewProperties() - for _, name := range names { - n, err := expandName(name) - if err != nil { - return nil, err - } - var p *Properties - if strings.HasPrefix(n, "http://") || strings.HasPrefix(n, "https://") { - p, err = loadURL(n, ignoreMissing) - } else { - p, err = loadFile(n, enc, ignoreMissing) - } - if err != nil { - return nil, err - } - result.Merge(p) - - } - return result, result.check() -} - -func loadFile(filename string, enc Encoding, ignoreMissing bool) (*Properties, error) { - data, err := ioutil.ReadFile(filename) - if err != nil { - if ignoreMissing && os.IsNotExist(err) { - LogPrintf("properties: %s not found. skipping", filename) - return NewProperties(), nil - } - return nil, err - } - p, err := parse(convert(data, enc)) - if err != nil { - return nil, err - } - return p, nil -} - -func loadURL(url string, ignoreMissing bool) (*Properties, error) { - resp, err := http.Get(url) - if err != nil { - return nil, fmt.Errorf("properties: error fetching %q. %s", url, err) - } - if resp.StatusCode == 404 && ignoreMissing { - LogPrintf("properties: %s returned %d. skipping", url, resp.StatusCode) - return NewProperties(), nil - } - if resp.StatusCode != 200 { - return nil, fmt.Errorf("properties: %s returned %d", url, resp.StatusCode) - } - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return nil, fmt.Errorf("properties: %s error reading response. %s", url, err) - } - if err = resp.Body.Close(); err != nil { - return nil, fmt.Errorf("properties: %s error reading response. %s", url, err) - } - - ct := resp.Header.Get("Content-Type") - var enc Encoding - switch strings.ToLower(ct) { - case "text/plain", "text/plain; charset=iso-8859-1", "text/plain; charset=latin1": - enc = ISO_8859_1 - case "", "text/plain; charset=utf-8": - enc = UTF8 - default: - return nil, fmt.Errorf("properties: invalid content type %s", ct) - } - - p, err := parse(convert(body, enc)) - if err != nil { - return nil, err - } - return p, nil -} - func must(p *Properties, err error) *Properties { if err != nil { ErrorHandler(err) @@ -218,7 +269,7 @@ func must(p *Properties, err error) *Properties { // with an empty string. Malformed expressions like "${ENV_VAR" will // be reported as error. func expandName(name string) (string, error) { - return expand(name, make(map[string]bool), "${", "}", make(map[string]string)) + return expand(name, []string{}, "${", "}", make(map[string]string)) } // Interprets a byte buffer either as an ISO-8859-1 or UTF-8 encoded string. @@ -226,7 +277,7 @@ func expandName(name string) (string, error) { // first 256 unicode code points cover ISO-8859-1. func convert(buf []byte, enc Encoding) string { switch enc { - case UTF8: + case utf8Default, UTF8: return string(buf) case ISO_8859_1: runes := make([]rune, len(buf)) diff --git a/vendor/github.com/magiconair/properties/parser.go b/vendor/github.com/magiconair/properties/parser.go index 90f555c..cdc4a80 100644 --- a/vendor/github.com/magiconair/properties/parser.go +++ b/vendor/github.com/magiconair/properties/parser.go @@ -1,4 +1,4 @@ -// Copyright 2017 Frank Schroeder. All rights reserved. +// Copyright 2018 Frank Schroeder. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/magiconair/properties/properties.go b/vendor/github.com/magiconair/properties/properties.go index 85bb186..cb3d1a3 100644 --- a/vendor/github.com/magiconair/properties/properties.go +++ b/vendor/github.com/magiconair/properties/properties.go @@ -1,4 +1,4 @@ -// Copyright 2017 Frank Schroeder. All rights reserved. +// Copyright 2018 Frank Schroeder. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. @@ -19,6 +19,8 @@ import ( "unicode/utf8" ) +const maxExpansionDepth = 64 + // ErrorHandlerFunc defines the type of function which handles failures // of the MustXXX() functions. An error handler function must exit // the application after handling the error. @@ -81,6 +83,17 @@ func NewProperties() *Properties { } } +// Load reads a buffer into the given Properties struct. +func (p *Properties) Load(buf []byte, enc Encoding) error { + l := &Loader{Encoding: enc, DisableExpansion: p.DisableExpansion} + newProperties, err := l.LoadBytes(buf) + if err != nil { + return err + } + p.Merge(newProperties) + return nil +} + // Get returns the expanded value for the given key if exists. // Otherwise, ok is false. func (p *Properties) Get(key string) (value string, ok bool) { @@ -92,7 +105,7 @@ func (p *Properties) Get(key string) (value string, ok bool) { return "", false } - expanded, err := p.expand(v) + expanded, err := p.expand(key, v) // we guarantee that the expanded value is free of // circular references and malformed expressions @@ -525,7 +538,7 @@ func (p *Properties) Set(key, value string) (prev string, ok bool, err error) { p.m[key] = value // now check for a circular reference - _, err = p.expand(value) + _, err = p.expand(key, value) if err != nil { // revert to the previous state @@ -696,56 +709,65 @@ outer: // check expands all values and returns an error if a circular reference or // a malformed expression was found. func (p *Properties) check() error { - for _, value := range p.m { - if _, err := p.expand(value); err != nil { + for key, value := range p.m { + if _, err := p.expand(key, value); err != nil { return err } } return nil } -func (p *Properties) expand(input string) (string, error) { +func (p *Properties) expand(key, input string) (string, error) { // no pre/postfix -> nothing to expand if p.Prefix == "" && p.Postfix == "" { return input, nil } - return expand(input, make(map[string]bool), p.Prefix, p.Postfix, p.m) + return expand(input, []string{key}, p.Prefix, p.Postfix, p.m) } // expand recursively expands expressions of '(prefix)key(postfix)' to their corresponding values. // The function keeps track of the keys that were already expanded and stops if it // detects a circular reference or a malformed expression of the form '(prefix)key'. -func expand(s string, keys map[string]bool, prefix, postfix string, values map[string]string) (string, error) { - start := strings.Index(s, prefix) - if start == -1 { - return s, nil - } - - keyStart := start + len(prefix) - keyLen := strings.Index(s[keyStart:], postfix) - if keyLen == -1 { - return "", fmt.Errorf("malformed expression") +func expand(s string, keys []string, prefix, postfix string, values map[string]string) (string, error) { + if len(keys) > maxExpansionDepth { + return "", fmt.Errorf("expansion too deep") } - end := keyStart + keyLen + len(postfix) - 1 - key := s[keyStart : keyStart+keyLen] + for { + start := strings.Index(s, prefix) + if start == -1 { + return s, nil + } - // fmt.Printf("s:%q pp:%q start:%d end:%d keyStart:%d keyLen:%d key:%q\n", s, prefix + "..." + postfix, start, end, keyStart, keyLen, key) + keyStart := start + len(prefix) + keyLen := strings.Index(s[keyStart:], postfix) + if keyLen == -1 { + return "", fmt.Errorf("malformed expression") + } - if _, ok := keys[key]; ok { - return "", fmt.Errorf("circular reference") - } + end := keyStart + keyLen + len(postfix) - 1 + key := s[keyStart : keyStart+keyLen] - val, ok := values[key] - if !ok { - val = os.Getenv(key) - } + // fmt.Printf("s:%q pp:%q start:%d end:%d keyStart:%d keyLen:%d key:%q\n", s, prefix + "..." + postfix, start, end, keyStart, keyLen, key) - // remember that we've seen the key - keys[key] = true + for _, k := range keys { + if key == k { + return "", fmt.Errorf("circular reference") + } + } - return expand(s[:start]+val+s[end+1:], keys, prefix, postfix, values) + val, ok := values[key] + if !ok { + val = os.Getenv(key) + } + new_val, err := expand(val, append(keys, key), prefix, postfix, values) + if err != nil { + return "", err + } + s = s[:start] + new_val + s[end+1:] + } + return s, nil } // encode encodes a UTF-8 string to ISO-8859-1 and escapes some characters. diff --git a/vendor/github.com/magiconair/properties/rangecheck.go b/vendor/github.com/magiconair/properties/rangecheck.go index 2e907d5..b013a2e 100644 --- a/vendor/github.com/magiconair/properties/rangecheck.go +++ b/vendor/github.com/magiconair/properties/rangecheck.go @@ -1,4 +1,4 @@ -// Copyright 2017 Frank Schroeder. All rights reserved. +// Copyright 2018 Frank Schroeder. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/microcosm-cc/bluemonday/doc.go b/vendor/github.com/microcosm-cc/bluemonday/doc.go index 2cb0a36..71dab60 100644 --- a/vendor/github.com/microcosm-cc/bluemonday/doc.go +++ b/vendor/github.com/microcosm-cc/bluemonday/doc.go @@ -84,7 +84,7 @@ bluemonday is heavily inspired by both the OWASP Java HTML Sanitizer We ship two default policies, one is bluemonday.StrictPolicy() and can be thought of as equivalent to stripping all HTML elements and their attributes as -it has nothing on it's whitelist. +it has nothing on its whitelist. The other is bluemonday.UGCPolicy() and allows a broad selection of HTML elements and attributes that are safe for user generated content. Note that diff --git a/vendor/github.com/microcosm-cc/bluemonday/policy.go b/vendor/github.com/microcosm-cc/bluemonday/policy.go index 49ce508..f61d98f 100644 --- a/vendor/github.com/microcosm-cc/bluemonday/policy.go +++ b/vendor/github.com/microcosm-cc/bluemonday/policy.go @@ -70,6 +70,9 @@ type Policy struct { // When true, u, _ := url.Parse("url"); !u.IsAbs() is permitted allowRelativeURLs bool + // When true, allow data attributes. + allowDataAttributes bool + // map[htmlElementName]map[htmlAttributeName]attrPolicy elsAndAttrs map[string]map[string]attrPolicy @@ -158,6 +161,21 @@ func (p *Policy) AllowAttrs(attrNames ...string) *attrPolicyBuilder { return &abp } +// AllowDataAttributes whitelists all data attributes. We can't specify the name +// of each attribute exactly as they are customized. +// +// NOTE: These values are not sanitized and applications that evaluate or process +// them without checking and verification of the input may be at risk if this option +// is enabled. This is a 'caveat emptor' option and the person enabling this option +// needs to fully understand the potential impact with regards to whatever application +// will be consuming the sanitized HTML afterwards, i.e. if you know you put a link in a +// data attribute and use that to automatically load some new window then you're giving +// the author of a HTML fragment the means to open a malicious destination automatically. +// Use with care! +func (p *Policy) AllowDataAttributes() { + p.allowDataAttributes = true +} + // AllowNoAttrs says that attributes on element are optional. // // The attribute policy is only added to the core policy when OnElements(...) @@ -384,7 +402,7 @@ func (p *Policy) AddSpaceWhenStrippingTag(allow bool) *Policy { } // SkipElementsContent adds the HTML elements whose tags is needed to be removed -// with it's content. +// with its content. func (p *Policy) SkipElementsContent(names ...string) *Policy { p.init() @@ -422,6 +440,7 @@ func (p *Policy) addDefaultElementsWithoutAttrs() { p.setOfElementsAllowedWithoutAttrs["abbr"] = struct{}{} p.setOfElementsAllowedWithoutAttrs["acronym"] = struct{}{} + p.setOfElementsAllowedWithoutAttrs["address"] = struct{}{} p.setOfElementsAllowedWithoutAttrs["article"] = struct{}{} p.setOfElementsAllowedWithoutAttrs["aside"] = struct{}{} p.setOfElementsAllowedWithoutAttrs["audio"] = struct{}{} diff --git a/vendor/github.com/microcosm-cc/bluemonday/sanitize.go b/vendor/github.com/microcosm-cc/bluemonday/sanitize.go index 4de0a7b..65ed89b 100644 --- a/vendor/github.com/microcosm-cc/bluemonday/sanitize.go +++ b/vendor/github.com/microcosm-cc/bluemonday/sanitize.go @@ -33,11 +33,18 @@ import ( "bytes" "io" "net/url" + "regexp" "strings" "golang.org/x/net/html" ) +var ( + dataAttribute = regexp.MustCompile("^data-.+") + dataAttributeXMLPrefix = regexp.MustCompile("^xml.+") + dataAttributeInvalidChars = regexp.MustCompile("[A-Z;]+") +) + // Sanitize takes a string that contains a HTML fragment or document and applies // the given policy whitelist. // @@ -259,6 +266,13 @@ func (p *Policy) sanitizeAttrs( // whitelisted explicitly or globally. cleanAttrs := []html.Attribute{} for _, htmlAttr := range attrs { + if p.allowDataAttributes { + // If we see a data attribute, let it through. + if isDataAttribute(htmlAttr.Key) { + cleanAttrs = append(cleanAttrs, htmlAttr) + continue + } + } // Is there an element specific attribute policy that applies? if ap, ok := aps[htmlAttr.Key]; ok { if ap.regexp != nil { @@ -274,6 +288,7 @@ func (p *Policy) sanitizeAttrs( // Is there a global attribute policy that applies? if ap, ok := p.globalAttrs[htmlAttr.Key]; ok { + if ap.regexp != nil { if ap.regexp.MatchString(htmlAttr.Val) { cleanAttrs = append(cleanAttrs, htmlAttr) @@ -545,3 +560,22 @@ func linkable(elementName string) bool { return false } } + +func isDataAttribute(val string) bool { + if !dataAttribute.MatchString(val) { + return false + } + rest := strings.Split(val, "data-") + if len(rest) == 1 { + return false + } + // data-xml* is invalid. + if dataAttributeXMLPrefix.MatchString(rest[1]) { + return false + } + // no uppercase or semi-colons allowed. + if dataAttributeInvalidChars.MatchString(rest[1]) { + return false + } + return true +} diff --git a/vendor/github.com/mitchellh/go-homedir/homedir.go b/vendor/github.com/mitchellh/go-homedir/homedir.go index 47e1f9e..fb87bef 100644 --- a/vendor/github.com/mitchellh/go-homedir/homedir.go +++ b/vendor/github.com/mitchellh/go-homedir/homedir.go @@ -77,33 +77,51 @@ func Expand(path string) (string, error) { } func dirUnix() (string, error) { + homeEnv := "HOME" + if runtime.GOOS == "plan9" { + // On plan9, env vars are lowercase. + homeEnv = "home" + } + // First prefer the HOME environmental variable - if home := os.Getenv("HOME"); home != "" { + if home := os.Getenv(homeEnv); home != "" { return home, nil } - // If that fails, try getent var stdout bytes.Buffer - cmd := exec.Command("getent", "passwd", strconv.Itoa(os.Getuid())) - cmd.Stdout = &stdout - if err := cmd.Run(); err != nil { - // If the error is ErrNotFound, we ignore it. Otherwise, return it. - if err != exec.ErrNotFound { - return "", err + + // If that fails, try OS specific commands + if runtime.GOOS == "darwin" { + cmd := exec.Command("sh", "-c", `dscl -q . -read /Users/"$(whoami)" NFSHomeDirectory | sed 's/^[^ ]*: //'`) + cmd.Stdout = &stdout + if err := cmd.Run(); err == nil { + result := strings.TrimSpace(stdout.String()) + if result != "" { + return result, nil + } } } else { - if passwd := strings.TrimSpace(stdout.String()); passwd != "" { - // username:password:uid:gid:gecos:home:shell - passwdParts := strings.SplitN(passwd, ":", 7) - if len(passwdParts) > 5 { - return passwdParts[5], nil + cmd := exec.Command("getent", "passwd", strconv.Itoa(os.Getuid())) + cmd.Stdout = &stdout + if err := cmd.Run(); err != nil { + // If the error is ErrNotFound, we ignore it. Otherwise, return it. + if err != exec.ErrNotFound { + return "", err + } + } else { + if passwd := strings.TrimSpace(stdout.String()); passwd != "" { + // username:password:uid:gid:gecos:home:shell + passwdParts := strings.SplitN(passwd, ":", 7) + if len(passwdParts) > 5 { + return passwdParts[5], nil + } } } } // If all else fails, try the shell stdout.Reset() - cmd = exec.Command("sh", "-c", "cd && pwd") + cmd := exec.Command("sh", "-c", "cd && pwd") cmd.Stdout = &stdout if err := cmd.Run(); err != nil { return "", err @@ -123,14 +141,16 @@ func dirWindows() (string, error) { return home, nil } + // Prefer standard environment variable USERPROFILE + if home := os.Getenv("USERPROFILE"); home != "" { + return home, nil + } + drive := os.Getenv("HOMEDRIVE") path := os.Getenv("HOMEPATH") home := drive + path if drive == "" || path == "" { - home = os.Getenv("USERPROFILE") - } - if home == "" { - return "", errors.New("HOMEDRIVE, HOMEPATH, and USERPROFILE are blank") + return "", errors.New("HOMEDRIVE, HOMEPATH, or USERPROFILE are blank") } return home, nil diff --git a/vendor/github.com/mitchellh/mapstructure/decode_hooks.go b/vendor/github.com/mitchellh/mapstructure/decode_hooks.go index afcfd5e..2a72757 100644 --- a/vendor/github.com/mitchellh/mapstructure/decode_hooks.go +++ b/vendor/github.com/mitchellh/mapstructure/decode_hooks.go @@ -115,6 +115,25 @@ func StringToTimeDurationHookFunc() DecodeHookFunc { } } +// StringToTimeHookFunc returns a DecodeHookFunc that converts +// strings to time.Time. +func StringToTimeHookFunc(layout string) DecodeHookFunc { + return func( + f reflect.Type, + t reflect.Type, + data interface{}) (interface{}, error) { + if f.Kind() != reflect.String { + return data, nil + } + if t != reflect.TypeOf(time.Time{}) { + return data, nil + } + + // Convert it by parsing + return time.Parse(layout, data.(string)) + } +} + // WeaklyTypedHook is a DecodeHookFunc which adds support for weak typing to // the decoder. // diff --git a/vendor/github.com/mitchellh/mapstructure/mapstructure.go b/vendor/github.com/mitchellh/mapstructure/mapstructure.go index 30a9957..d3222b8 100644 --- a/vendor/github.com/mitchellh/mapstructure/mapstructure.go +++ b/vendor/github.com/mitchellh/mapstructure/mapstructure.go @@ -114,12 +114,12 @@ type Metadata struct { Unused []string } -// Decode takes a map and uses reflection to convert it into the -// given Go native structure. val must be a pointer to a struct. -func Decode(m interface{}, rawVal interface{}) error { +// Decode takes an input structure and uses reflection to translate it to +// the output structure. output must be a pointer to a map or struct. +func Decode(input interface{}, output interface{}) error { config := &DecoderConfig{ Metadata: nil, - Result: rawVal, + Result: output, } decoder, err := NewDecoder(config) @@ -127,7 +127,7 @@ func Decode(m interface{}, rawVal interface{}) error { return err } - return decoder.Decode(m) + return decoder.Decode(input) } // WeakDecode is the same as Decode but is shorthand to enable @@ -147,6 +147,40 @@ func WeakDecode(input, output interface{}) error { return decoder.Decode(input) } +// DecodeMetadata is the same as Decode, but is shorthand to +// enable metadata collection. See DecoderConfig for more info. +func DecodeMetadata(input interface{}, output interface{}, metadata *Metadata) error { + config := &DecoderConfig{ + Metadata: metadata, + Result: output, + } + + decoder, err := NewDecoder(config) + if err != nil { + return err + } + + return decoder.Decode(input) +} + +// WeakDecodeMetadata is the same as Decode, but is shorthand to +// enable both WeaklyTypedInput and metadata collection. See +// DecoderConfig for more info. +func WeakDecodeMetadata(input interface{}, output interface{}, metadata *Metadata) error { + config := &DecoderConfig{ + Metadata: metadata, + Result: output, + WeaklyTypedInput: true, + } + + decoder, err := NewDecoder(config) + if err != nil { + return err + } + + return decoder.Decode(input) +} + // NewDecoder returns a new decoder for the given configuration. Once // a decoder has been returned, the same configuration must not be used // again. @@ -184,68 +218,81 @@ func NewDecoder(config *DecoderConfig) (*Decoder, error) { // Decode decodes the given raw interface to the target pointer specified // by the configuration. -func (d *Decoder) Decode(raw interface{}) error { - return d.decode("", raw, reflect.ValueOf(d.config.Result).Elem()) +func (d *Decoder) Decode(input interface{}) error { + return d.decode("", input, reflect.ValueOf(d.config.Result).Elem()) } // Decodes an unknown data type into a specific reflection value. -func (d *Decoder) decode(name string, data interface{}, val reflect.Value) error { - if data == nil { - // If the data is nil, then we don't set anything. +func (d *Decoder) decode(name string, input interface{}, outVal reflect.Value) error { + if input == nil { + // If the data is nil, then we don't set anything, unless ZeroFields is set + // to true. + if d.config.ZeroFields { + outVal.Set(reflect.Zero(outVal.Type())) + + if d.config.Metadata != nil && name != "" { + d.config.Metadata.Keys = append(d.config.Metadata.Keys, name) + } + } return nil } - dataVal := reflect.ValueOf(data) - if !dataVal.IsValid() { - // If the data value is invalid, then we just set the value + inputVal := reflect.ValueOf(input) + if !inputVal.IsValid() { + // If the input value is invalid, then we just set the value // to be the zero value. - val.Set(reflect.Zero(val.Type())) + outVal.Set(reflect.Zero(outVal.Type())) + if d.config.Metadata != nil && name != "" { + d.config.Metadata.Keys = append(d.config.Metadata.Keys, name) + } return nil } if d.config.DecodeHook != nil { - // We have a DecodeHook, so let's pre-process the data. + // We have a DecodeHook, so let's pre-process the input. var err error - data, err = DecodeHookExec( + input, err = DecodeHookExec( d.config.DecodeHook, - dataVal.Type(), val.Type(), data) + inputVal.Type(), outVal.Type(), input) if err != nil { return fmt.Errorf("error decoding '%s': %s", name, err) } } var err error - dataKind := getKind(val) - switch dataKind { + inputKind := getKind(outVal) + switch inputKind { case reflect.Bool: - err = d.decodeBool(name, data, val) + err = d.decodeBool(name, input, outVal) case reflect.Interface: - err = d.decodeBasic(name, data, val) + err = d.decodeBasic(name, input, outVal) case reflect.String: - err = d.decodeString(name, data, val) + err = d.decodeString(name, input, outVal) case reflect.Int: - err = d.decodeInt(name, data, val) + err = d.decodeInt(name, input, outVal) case reflect.Uint: - err = d.decodeUint(name, data, val) + err = d.decodeUint(name, input, outVal) case reflect.Float32: - err = d.decodeFloat(name, data, val) + err = d.decodeFloat(name, input, outVal) case reflect.Struct: - err = d.decodeStruct(name, data, val) + err = d.decodeStruct(name, input, outVal) case reflect.Map: - err = d.decodeMap(name, data, val) + err = d.decodeMap(name, input, outVal) case reflect.Ptr: - err = d.decodePtr(name, data, val) + err = d.decodePtr(name, input, outVal) case reflect.Slice: - err = d.decodeSlice(name, data, val) + err = d.decodeSlice(name, input, outVal) + case reflect.Array: + err = d.decodeArray(name, input, outVal) case reflect.Func: - err = d.decodeFunc(name, data, val) + err = d.decodeFunc(name, input, outVal) default: // If we reached this point then we weren't able to decode it - return fmt.Errorf("%s: unsupported type: %s", name, dataKind) + return fmt.Errorf("%s: unsupported type: %s", name, inputKind) } // If we reached here, then we successfully decoded SOMETHING, so - // mark the key as used if we're tracking metadata. + // mark the key as used if we're tracking metainput. if d.config.Metadata != nil && name != "" { d.config.Metadata.Keys = append(d.config.Metadata.Keys, name) } @@ -256,6 +303,9 @@ func (d *Decoder) decode(name string, data interface{}, val reflect.Value) error // This decodes a basic type (bool, int, string, etc.) and sets the // value to "data" of that type. func (d *Decoder) decodeBasic(name string, data interface{}, val reflect.Value) error { + if val.IsValid() && val.Elem().IsValid() { + return d.decode(name, data, val.Elem()) + } dataVal := reflect.ValueOf(data) if !dataVal.IsValid() { dataVal = reflect.Zero(val.Type()) @@ -292,12 +342,22 @@ func (d *Decoder) decodeString(name string, data interface{}, val reflect.Value) val.SetString(strconv.FormatUint(dataVal.Uint(), 10)) case dataKind == reflect.Float32 && d.config.WeaklyTypedInput: val.SetString(strconv.FormatFloat(dataVal.Float(), 'f', -1, 64)) - case dataKind == reflect.Slice && d.config.WeaklyTypedInput: + case dataKind == reflect.Slice && d.config.WeaklyTypedInput, + dataKind == reflect.Array && d.config.WeaklyTypedInput: dataType := dataVal.Type() elemKind := dataType.Elem().Kind() - switch { - case elemKind == reflect.Uint8: - val.SetString(string(dataVal.Interface().([]uint8))) + switch elemKind { + case reflect.Uint8: + var uints []uint8 + if dataKind == reflect.Array { + uints = make([]uint8, dataVal.Len(), dataVal.Len()) + for i := range uints { + uints[i] = dataVal.Index(i).Interface().(uint8) + } + } else { + uints = dataVal.Interface().([]uint8) + } + val.SetString(string(uints)) default: converted = false } @@ -487,34 +547,50 @@ func (d *Decoder) decodeMap(name string, data interface{}, val reflect.Value) er valMap = reflect.MakeMap(mapType) } - // Check input type + // Check input type and based on the input type jump to the proper func dataVal := reflect.Indirect(reflect.ValueOf(data)) - if dataVal.Kind() != reflect.Map { - // In weak mode, we accept a slice of maps as an input... - if d.config.WeaklyTypedInput { - switch dataVal.Kind() { - case reflect.Array, reflect.Slice: - // Special case for BC reasons (covered by tests) - if dataVal.Len() == 0 { - val.Set(valMap) - return nil - } + switch dataVal.Kind() { + case reflect.Map: + return d.decodeMapFromMap(name, dataVal, val, valMap) - for i := 0; i < dataVal.Len(); i++ { - err := d.decode( - fmt.Sprintf("%s[%d]", name, i), - dataVal.Index(i).Interface(), val) - if err != nil { - return err - } - } + case reflect.Struct: + return d.decodeMapFromStruct(name, dataVal, val, valMap) - return nil - } + case reflect.Array, reflect.Slice: + if d.config.WeaklyTypedInput { + return d.decodeMapFromSlice(name, dataVal, val, valMap) } + fallthrough + + default: return fmt.Errorf("'%s' expected a map, got '%s'", name, dataVal.Kind()) } +} + +func (d *Decoder) decodeMapFromSlice(name string, dataVal reflect.Value, val reflect.Value, valMap reflect.Value) error { + // Special case for BC reasons (covered by tests) + if dataVal.Len() == 0 { + val.Set(valMap) + return nil + } + + for i := 0; i < dataVal.Len(); i++ { + err := d.decode( + fmt.Sprintf("%s[%d]", name, i), + dataVal.Index(i).Interface(), val) + if err != nil { + return err + } + } + + return nil +} + +func (d *Decoder) decodeMapFromMap(name string, dataVal reflect.Value, val reflect.Value, valMap reflect.Value) error { + valType := val.Type() + valKeyType := valType.Key() + valElemType := valType.Elem() // Accumulate errors errors := make([]string, 0) @@ -551,22 +627,106 @@ func (d *Decoder) decodeMap(name string, data interface{}, val reflect.Value) er return nil } +func (d *Decoder) decodeMapFromStruct(name string, dataVal reflect.Value, val reflect.Value, valMap reflect.Value) error { + typ := dataVal.Type() + for i := 0; i < typ.NumField(); i++ { + // Get the StructField first since this is a cheap operation. If the + // field is unexported, then ignore it. + f := typ.Field(i) + if f.PkgPath != "" { + continue + } + + // Next get the actual value of this field and verify it is assignable + // to the map value. + v := dataVal.Field(i) + if !v.Type().AssignableTo(valMap.Type().Elem()) { + return fmt.Errorf("cannot assign type '%s' to map value field of type '%s'", v.Type(), valMap.Type().Elem()) + } + + tagValue := f.Tag.Get(d.config.TagName) + tagParts := strings.Split(tagValue, ",") + + // Determine the name of the key in the map + keyName := f.Name + if tagParts[0] != "" { + if tagParts[0] == "-" { + continue + } + keyName = tagParts[0] + } + + // If "squash" is specified in the tag, we squash the field down. + squash := false + for _, tag := range tagParts[1:] { + if tag == "squash" { + squash = true + break + } + } + if squash && v.Kind() != reflect.Struct { + return fmt.Errorf("cannot squash non-struct type '%s'", v.Type()) + } + + switch v.Kind() { + // this is an embedded struct, so handle it differently + case reflect.Struct: + x := reflect.New(v.Type()) + x.Elem().Set(v) + + vType := valMap.Type() + vKeyType := vType.Key() + vElemType := vType.Elem() + mType := reflect.MapOf(vKeyType, vElemType) + vMap := reflect.MakeMap(mType) + + err := d.decode(keyName, x.Interface(), vMap) + if err != nil { + return err + } + + if squash { + for _, k := range vMap.MapKeys() { + valMap.SetMapIndex(k, vMap.MapIndex(k)) + } + } else { + valMap.SetMapIndex(reflect.ValueOf(keyName), vMap) + } + + default: + valMap.SetMapIndex(reflect.ValueOf(keyName), v) + } + } + + if val.CanAddr() { + val.Set(valMap) + } + + return nil +} + func (d *Decoder) decodePtr(name string, data interface{}, val reflect.Value) error { // Create an element of the concrete (non pointer) type and decode // into that. Then set the value of the pointer to this type. valType := val.Type() valElemType := valType.Elem() - realVal := val - if realVal.IsNil() || d.config.ZeroFields { - realVal = reflect.New(valElemType) - } + if val.CanSet() { + realVal := val + if realVal.IsNil() || d.config.ZeroFields { + realVal = reflect.New(valElemType) + } - if err := d.decode(name, data, reflect.Indirect(realVal)); err != nil { - return err - } + if err := d.decode(name, data, reflect.Indirect(realVal)); err != nil { + return err + } - val.Set(realVal) + val.Set(realVal) + } else { + if err := d.decode(name, data, reflect.Indirect(val)); err != nil { + return err + } + } return nil } @@ -602,7 +762,11 @@ func (d *Decoder) decodeSlice(name string, data interface{}, val reflect.Value) val.Set(reflect.MakeSlice(sliceType, 0, 0)) return nil } + // Create slice of maps of other sizes + return d.decodeSlice(name, []interface{}{data}, val) + case dataValKind == reflect.String && valElemType.Kind() == reflect.Uint8: + return d.decodeSlice(name, []byte(dataVal.String()), val) // All other types we try to convert to the slice type // and "lift" it into it. i.e. a string becomes a string slice. default: @@ -610,7 +774,6 @@ func (d *Decoder) decodeSlice(name string, data interface{}, val reflect.Value) return d.decodeSlice(name, []interface{}{data}, val) } } - return fmt.Errorf( "'%s': source data must be an array or slice, got %s", name, dataValKind) @@ -647,6 +810,73 @@ func (d *Decoder) decodeSlice(name string, data interface{}, val reflect.Value) return nil } +func (d *Decoder) decodeArray(name string, data interface{}, val reflect.Value) error { + dataVal := reflect.Indirect(reflect.ValueOf(data)) + dataValKind := dataVal.Kind() + valType := val.Type() + valElemType := valType.Elem() + arrayType := reflect.ArrayOf(valType.Len(), valElemType) + + valArray := val + + if valArray.Interface() == reflect.Zero(valArray.Type()).Interface() || d.config.ZeroFields { + // Check input type + if dataValKind != reflect.Array && dataValKind != reflect.Slice { + if d.config.WeaklyTypedInput { + switch { + // Empty maps turn into empty arrays + case dataValKind == reflect.Map: + if dataVal.Len() == 0 { + val.Set(reflect.Zero(arrayType)) + return nil + } + + // All other types we try to convert to the array type + // and "lift" it into it. i.e. a string becomes a string array. + default: + // Just re-try this function with data as a slice. + return d.decodeArray(name, []interface{}{data}, val) + } + } + + return fmt.Errorf( + "'%s': source data must be an array or slice, got %s", name, dataValKind) + + } + if dataVal.Len() > arrayType.Len() { + return fmt.Errorf( + "'%s': expected source data to have length less or equal to %d, got %d", name, arrayType.Len(), dataVal.Len()) + + } + + // Make a new array to hold our result, same size as the original data. + valArray = reflect.New(arrayType).Elem() + } + + // Accumulate any errors + errors := make([]string, 0) + + for i := 0; i < dataVal.Len(); i++ { + currentData := dataVal.Index(i).Interface() + currentField := valArray.Index(i) + + fieldName := fmt.Sprintf("%s[%d]", name, i) + if err := d.decode(fieldName, currentData, currentField); err != nil { + errors = appendErrors(errors, err) + } + } + + // Finally, set the value to the array we built up + val.Set(valArray) + + // If there were errors, we return those + if len(errors) > 0 { + return &Error{errors} + } + + return nil +} + func (d *Decoder) decodeStruct(name string, data interface{}, val reflect.Value) error { dataVal := reflect.Indirect(reflect.ValueOf(data)) @@ -716,7 +946,7 @@ func (d *Decoder) decodeStruct(name string, data interface{}, val reflect.Value) errors = appendErrors(errors, fmt.Errorf("%s: unsupported type for squash: %s", fieldType.Name, fieldKind)) } else { - structs = append(structs, val.FieldByName(fieldType.Name)) + structs = append(structs, structVal.FieldByName(fieldType.Name)) } continue } diff --git a/vendor/github.com/pelletier/go-toml/doc.go b/vendor/github.com/pelletier/go-toml/doc.go index 3c89619..d5fd98c 100644 --- a/vendor/github.com/pelletier/go-toml/doc.go +++ b/vendor/github.com/pelletier/go-toml/doc.go @@ -17,7 +17,7 @@ // JSONPath-like queries // // The package github.com/pelletier/go-toml/query implements a system -// similar to JSONPath to quickly retrive elements of a TOML document using a +// similar to JSONPath to quickly retrieve elements of a TOML document using a // single expression. See the package documentation for more information. // package toml diff --git a/vendor/github.com/pelletier/go-toml/fuzz.go b/vendor/github.com/pelletier/go-toml/fuzz.go new file mode 100644 index 0000000..14570c8 --- /dev/null +++ b/vendor/github.com/pelletier/go-toml/fuzz.go @@ -0,0 +1,31 @@ +// +build gofuzz + +package toml + +func Fuzz(data []byte) int { + tree, err := LoadBytes(data) + if err != nil { + if tree != nil { + panic("tree must be nil if there is an error") + } + return 0 + } + + str, err := tree.ToTomlString() + if err != nil { + if str != "" { + panic(`str must be "" if there is an error`) + } + panic(err) + } + + tree, err = Load(str) + if err != nil { + if tree != nil { + panic("tree must be nil if there is an error") + } + return 0 + } + + return 1 +} diff --git a/vendor/github.com/pelletier/go-toml/keysparsing.go b/vendor/github.com/pelletier/go-toml/keysparsing.go index d62ca5f..284db64 100644 --- a/vendor/github.com/pelletier/go-toml/keysparsing.go +++ b/vendor/github.com/pelletier/go-toml/keysparsing.go @@ -9,12 +9,14 @@ import ( "unicode" ) +// Convert the bare key group string to an array. +// The input supports double quotation to allow "." inside the key name, +// but escape sequences are not supported. Lexers must unescape them beforehand. func parseKey(key string) ([]string, error) { groups := []string{} var buffer bytes.Buffer inQuotes := false wasInQuotes := false - escapeNext := false ignoreSpace := true expectDot := false @@ -25,15 +27,7 @@ func parseKey(key string) ([]string, error) { } ignoreSpace = false } - if escapeNext { - buffer.WriteRune(char) - escapeNext = false - continue - } switch char { - case '\\': - escapeNext = true - continue case '"': if inQuotes { groups = append(groups, buffer.String()) @@ -77,9 +71,6 @@ func parseKey(key string) ([]string, error) { if inQuotes { return nil, errors.New("mismatched quotes") } - if escapeNext { - return nil, errors.New("unfinished escape sequence") - } if buffer.Len() > 0 { groups = append(groups, buffer.String()) } diff --git a/vendor/github.com/pelletier/go-toml/lexer.go b/vendor/github.com/pelletier/go-toml/lexer.go index 1b6647d..d11de42 100644 --- a/vendor/github.com/pelletier/go-toml/lexer.go +++ b/vendor/github.com/pelletier/go-toml/lexer.go @@ -204,6 +204,14 @@ func (l *tomlLexer) lexRvalue() tomlLexStateFn { return l.lexFalse } + if l.follow("inf") { + return l.lexInf + } + + if l.follow("nan") { + return l.lexNan + } + if isSpace(next) { l.skip() continue @@ -265,6 +273,18 @@ func (l *tomlLexer) lexFalse() tomlLexStateFn { return l.lexRvalue } +func (l *tomlLexer) lexInf() tomlLexStateFn { + l.fastForward(3) + l.emit(tokenInf) + return l.lexRvalue +} + +func (l *tomlLexer) lexNan() tomlLexStateFn { + l.fastForward(3) + l.emit(tokenNan) + return l.lexRvalue +} + func (l *tomlLexer) lexEqual() tomlLexStateFn { l.next() l.emit(tokenEqual) @@ -277,6 +297,8 @@ func (l *tomlLexer) lexComma() tomlLexStateFn { return l.lexRvalue } +// Parse the key and emits its value without escape sequences. +// bare keys, basic string keys and literal string keys are supported. func (l *tomlLexer) lexKey() tomlLexStateFn { growingString := "" @@ -287,7 +309,16 @@ func (l *tomlLexer) lexKey() tomlLexStateFn { if err != nil { return l.errorf(err.Error()) } - growingString += `"` + str + `"` + growingString += str + l.next() + continue + } else if r == '\'' { + l.next() + str, err := l.lexLiteralStringAsString(`'`, false) + if err != nil { + return l.errorf(err.Error()) + } + growingString += str l.next() continue } else if r == '\n' { @@ -527,6 +558,7 @@ func (l *tomlLexer) lexTableKey() tomlLexStateFn { return l.lexInsideTableKey } +// Parse the key till "]]", but only bare keys are supported func (l *tomlLexer) lexInsideTableArrayKey() tomlLexStateFn { for r := l.peek(); r != eof; r = l.peek() { switch r { @@ -550,6 +582,7 @@ func (l *tomlLexer) lexInsideTableArrayKey() tomlLexStateFn { return l.errorf("unclosed table array key") } +// Parse the key till "]" but only bare keys are supported func (l *tomlLexer) lexInsideTableKey() tomlLexStateFn { for r := l.peek(); r != eof; r = l.peek() { switch r { @@ -575,11 +608,77 @@ func (l *tomlLexer) lexRightBracket() tomlLexStateFn { return l.lexRvalue } +type validRuneFn func(r rune) bool + +func isValidHexRune(r rune) bool { + return r >= 'a' && r <= 'f' || + r >= 'A' && r <= 'F' || + r >= '0' && r <= '9' || + r == '_' +} + +func isValidOctalRune(r rune) bool { + return r >= '0' && r <= '7' || r == '_' +} + +func isValidBinaryRune(r rune) bool { + return r == '0' || r == '1' || r == '_' +} + func (l *tomlLexer) lexNumber() tomlLexStateFn { r := l.peek() + + if r == '0' { + follow := l.peekString(2) + if len(follow) == 2 { + var isValidRune validRuneFn + switch follow[1] { + case 'x': + isValidRune = isValidHexRune + case 'o': + isValidRune = isValidOctalRune + case 'b': + isValidRune = isValidBinaryRune + default: + if follow[1] >= 'a' && follow[1] <= 'z' || follow[1] >= 'A' && follow[1] <= 'Z' { + return l.errorf("unknown number base: %s. possible options are x (hex) o (octal) b (binary)", string(follow[1])) + } + } + + if isValidRune != nil { + l.next() + l.next() + digitSeen := false + for { + next := l.peek() + if !isValidRune(next) { + break + } + digitSeen = true + l.next() + } + + if !digitSeen { + return l.errorf("number needs at least one digit") + } + + l.emit(tokenInteger) + + return l.lexRvalue + } + } + } + if r == '+' || r == '-' { l.next() + if l.follow("inf") { + return l.lexInf + } + if l.follow("nan") { + return l.lexNan + } } + pointSeen := false expSeen := false digitSeen := false diff --git a/vendor/github.com/pelletier/go-toml/marshal.go b/vendor/github.com/pelletier/go-toml/marshal.go index 1a3176f..671da55 100644 --- a/vendor/github.com/pelletier/go-toml/marshal.go +++ b/vendor/github.com/pelletier/go-toml/marshal.go @@ -4,17 +4,33 @@ import ( "bytes" "errors" "fmt" + "io" "reflect" + "strconv" "strings" "time" ) +const tagKeyMultiline = "multiline" + type tomlOpts struct { name string + comment string + commented bool + multiline bool include bool omitempty bool } +type encOpts struct { + quoteMapKeys bool + arraysOneElementPerLine bool +} + +var encOptsDefaults = encOpts{ + quoteMapKeys: false, +} + var timeType = reflect.TypeOf(time.Time{}) var marshalerType = reflect.TypeOf(new(Marshaler)).Elem() @@ -94,8 +110,15 @@ encoder, except that there is no concept of a Marshaler interface or MarshalTOML function for sub-structs, and currently only definite types can be marshaled (i.e. no `interface{}`). +The following struct annotations are supported: + + toml:"Field" Overrides the field's name to output. + omitempty When set, empty values and groups are not emitted. + comment:"comment" Emits a # comment on the same line. This supports new lines. + commented:"true" Emits the value as commented. + Note that pointers are automatically assigned the "omitempty" option, as TOML -explicity does not handle null values (saying instead the label should be +explicitly does not handle null values (saying instead the label should be dropped). Tree structural types and corresponding marshal types: @@ -115,6 +138,66 @@ Tree primitive types and corresponding marshal types: time.Time time.Time{}, pointers to same */ func Marshal(v interface{}) ([]byte, error) { + return NewEncoder(nil).marshal(v) +} + +// Encoder writes TOML values to an output stream. +type Encoder struct { + w io.Writer + encOpts +} + +// NewEncoder returns a new encoder that writes to w. +func NewEncoder(w io.Writer) *Encoder { + return &Encoder{ + w: w, + encOpts: encOptsDefaults, + } +} + +// Encode writes the TOML encoding of v to the stream. +// +// See the documentation for Marshal for details. +func (e *Encoder) Encode(v interface{}) error { + b, err := e.marshal(v) + if err != nil { + return err + } + if _, err := e.w.Write(b); err != nil { + return err + } + return nil +} + +// QuoteMapKeys sets up the encoder to encode +// maps with string type keys with quoted TOML keys. +// +// This relieves the character limitations on map keys. +func (e *Encoder) QuoteMapKeys(v bool) *Encoder { + e.quoteMapKeys = v + return e +} + +// ArraysWithOneElementPerLine sets up the encoder to encode arrays +// with more than one element on multiple lines instead of one. +// +// For example: +// +// A = [1,2,3] +// +// Becomes +// +// A = [ +// 1, +// 2, +// 3, +// ] +func (e *Encoder) ArraysWithOneElementPerLine(v bool) *Encoder { + e.arraysOneElementPerLine = v + return e +} + +func (e *Encoder) marshal(v interface{}) ([]byte, error) { mtype := reflect.TypeOf(v) if mtype.Kind() != reflect.Struct { return []byte{}, errors.New("Only a struct can be marshaled to TOML") @@ -123,18 +206,21 @@ func Marshal(v interface{}) ([]byte, error) { if isCustomMarshaler(mtype) { return callCustomMarshaler(sval) } - t, err := valueToTree(mtype, sval) + t, err := e.valueToTree(mtype, sval) if err != nil { return []byte{}, err } - s, err := t.ToTomlString() - return []byte(s), err + + var buf bytes.Buffer + _, err = t.writeTo(&buf, "", "", 0, e.arraysOneElementPerLine) + + return buf.Bytes(), err } // Convert given marshal struct or map value to toml tree -func valueToTree(mtype reflect.Type, mval reflect.Value) (*Tree, error) { +func (e *Encoder) valueToTree(mtype reflect.Type, mval reflect.Value) (*Tree, error) { if mtype.Kind() == reflect.Ptr { - return valueToTree(mtype.Elem(), mval.Elem()) + return e.valueToTree(mtype.Elem(), mval.Elem()) } tval := newTree() switch mtype.Kind() { @@ -143,31 +229,44 @@ func valueToTree(mtype reflect.Type, mval reflect.Value) (*Tree, error) { mtypef, mvalf := mtype.Field(i), mval.Field(i) opts := tomlOptions(mtypef) if opts.include && (!opts.omitempty || !isZero(mvalf)) { - val, err := valueToToml(mtypef.Type, mvalf) + val, err := e.valueToToml(mtypef.Type, mvalf) if err != nil { return nil, err } - tval.Set(opts.name, val) + + tval.SetWithOptions(opts.name, SetOptions{ + Comment: opts.comment, + Commented: opts.commented, + Multiline: opts.multiline, + }, val) } } case reflect.Map: for _, key := range mval.MapKeys() { mvalf := mval.MapIndex(key) - val, err := valueToToml(mtype.Elem(), mvalf) + val, err := e.valueToToml(mtype.Elem(), mvalf) if err != nil { return nil, err } - tval.Set(key.String(), val) + if e.quoteMapKeys { + keyStr, err := tomlValueStringRepresentation(key.String(), "", e.arraysOneElementPerLine) + if err != nil { + return nil, err + } + tval.SetPath([]string{keyStr}, val) + } else { + tval.Set(key.String(), val) + } } } return tval, nil } // Convert given marshal slice to slice of Toml trees -func valueToTreeSlice(mtype reflect.Type, mval reflect.Value) ([]*Tree, error) { +func (e *Encoder) valueToTreeSlice(mtype reflect.Type, mval reflect.Value) ([]*Tree, error) { tval := make([]*Tree, mval.Len(), mval.Len()) for i := 0; i < mval.Len(); i++ { - val, err := valueToTree(mtype.Elem(), mval.Index(i)) + val, err := e.valueToTree(mtype.Elem(), mval.Index(i)) if err != nil { return nil, err } @@ -177,10 +276,10 @@ func valueToTreeSlice(mtype reflect.Type, mval reflect.Value) ([]*Tree, error) { } // Convert given marshal slice to slice of toml values -func valueToOtherSlice(mtype reflect.Type, mval reflect.Value) (interface{}, error) { +func (e *Encoder) valueToOtherSlice(mtype reflect.Type, mval reflect.Value) (interface{}, error) { tval := make([]interface{}, mval.Len(), mval.Len()) for i := 0; i < mval.Len(); i++ { - val, err := valueToToml(mtype.Elem(), mval.Index(i)) + val, err := e.valueToToml(mtype.Elem(), mval.Index(i)) if err != nil { return nil, err } @@ -190,19 +289,19 @@ func valueToOtherSlice(mtype reflect.Type, mval reflect.Value) (interface{}, err } // Convert given marshal value to toml value -func valueToToml(mtype reflect.Type, mval reflect.Value) (interface{}, error) { +func (e *Encoder) valueToToml(mtype reflect.Type, mval reflect.Value) (interface{}, error) { if mtype.Kind() == reflect.Ptr { - return valueToToml(mtype.Elem(), mval.Elem()) + return e.valueToToml(mtype.Elem(), mval.Elem()) } switch { case isCustomMarshaler(mtype): return callCustomMarshaler(mval) case isTree(mtype): - return valueToTree(mtype, mval) + return e.valueToTree(mtype, mval) case isTreeSlice(mtype): - return valueToTreeSlice(mtype, mval) + return e.valueToTreeSlice(mtype, mval) case isOtherSlice(mtype): - return valueToOtherSlice(mtype, mval) + return e.valueToOtherSlice(mtype, mval) default: switch mtype.Kind() { case reflect.Bool: @@ -227,17 +326,16 @@ func valueToToml(mtype reflect.Type, mval reflect.Value) (interface{}, error) { // Neither Unmarshaler interfaces nor UnmarshalTOML functions are supported for // sub-structs, and only definite types can be unmarshaled. func (t *Tree) Unmarshal(v interface{}) error { - mtype := reflect.TypeOf(v) - if mtype.Kind() != reflect.Ptr || mtype.Elem().Kind() != reflect.Struct { - return errors.New("Only a pointer to struct can be unmarshaled from TOML") - } + d := Decoder{tval: t} + return d.unmarshal(v) +} - sval, err := valueFromTree(mtype.Elem(), t) - if err != nil { - return err - } - reflect.ValueOf(v).Elem().Set(sval) - return nil +// Marshal returns the TOML encoding of Tree. +// See Marshal() documentation for types mapping table. +func (t *Tree) Marshal() ([]byte, error) { + var buf bytes.Buffer + err := NewEncoder(&buf).Encode(t) + return buf.Bytes(), err } // Unmarshal parses the TOML-encoded data and stores the result in the value @@ -246,6 +344,10 @@ func (t *Tree) Unmarshal(v interface{}) error { // sub-structs, and currently only definite types can be unmarshaled to (i.e. no // `interface{}`). // +// The following struct annotations are supported: +// +// toml:"Field" Overrides the field's name to map to. +// // See Marshal() documentation for types mapping table. func Unmarshal(data []byte, v interface{}) error { t, err := LoadReader(bytes.NewReader(data)) @@ -255,10 +357,52 @@ func Unmarshal(data []byte, v interface{}) error { return t.Unmarshal(v) } +// Decoder reads and decodes TOML values from an input stream. +type Decoder struct { + r io.Reader + tval *Tree + encOpts +} + +// NewDecoder returns a new decoder that reads from r. +func NewDecoder(r io.Reader) *Decoder { + return &Decoder{ + r: r, + encOpts: encOptsDefaults, + } +} + +// Decode reads a TOML-encoded value from it's input +// and unmarshals it in the value pointed at by v. +// +// See the documentation for Marshal for details. +func (d *Decoder) Decode(v interface{}) error { + var err error + d.tval, err = LoadReader(d.r) + if err != nil { + return err + } + return d.unmarshal(v) +} + +func (d *Decoder) unmarshal(v interface{}) error { + mtype := reflect.TypeOf(v) + if mtype.Kind() != reflect.Ptr || mtype.Elem().Kind() != reflect.Struct { + return errors.New("Only a pointer to struct can be unmarshaled from TOML") + } + + sval, err := d.valueFromTree(mtype.Elem(), d.tval) + if err != nil { + return err + } + reflect.ValueOf(v).Elem().Set(sval) + return nil +} + // Convert toml tree to marshal struct or map, using marshal type -func valueFromTree(mtype reflect.Type, tval *Tree) (reflect.Value, error) { +func (d *Decoder) valueFromTree(mtype reflect.Type, tval *Tree) (reflect.Value, error) { if mtype.Kind() == reflect.Ptr { - return unwrapPointer(mtype, tval) + return d.unwrapPointer(mtype, tval) } var mval reflect.Value switch mtype.Kind() { @@ -276,7 +420,7 @@ func valueFromTree(mtype reflect.Type, tval *Tree) (reflect.Value, error) { continue } val := tval.Get(key) - mvalf, err := valueFromToml(mtypef.Type, val) + mvalf, err := d.valueFromToml(mtypef.Type, val) if err != nil { return mval, formatError(err, tval.GetPosition(key)) } @@ -288,8 +432,9 @@ func valueFromTree(mtype reflect.Type, tval *Tree) (reflect.Value, error) { case reflect.Map: mval = reflect.MakeMap(mtype) for _, key := range tval.Keys() { - val := tval.Get(key) - mvalf, err := valueFromToml(mtype.Elem(), val) + // TODO: path splits key + val := tval.GetPath([]string{key}) + mvalf, err := d.valueFromToml(mtype.Elem(), val) if err != nil { return mval, formatError(err, tval.GetPosition(key)) } @@ -300,10 +445,10 @@ func valueFromTree(mtype reflect.Type, tval *Tree) (reflect.Value, error) { } // Convert toml value to marshal struct/map slice, using marshal type -func valueFromTreeSlice(mtype reflect.Type, tval []*Tree) (reflect.Value, error) { +func (d *Decoder) valueFromTreeSlice(mtype reflect.Type, tval []*Tree) (reflect.Value, error) { mval := reflect.MakeSlice(mtype, len(tval), len(tval)) for i := 0; i < len(tval); i++ { - val, err := valueFromTree(mtype.Elem(), tval[i]) + val, err := d.valueFromTree(mtype.Elem(), tval[i]) if err != nil { return mval, err } @@ -313,10 +458,10 @@ func valueFromTreeSlice(mtype reflect.Type, tval []*Tree) (reflect.Value, error) } // Convert toml value to marshal primitive slice, using marshal type -func valueFromOtherSlice(mtype reflect.Type, tval []interface{}) (reflect.Value, error) { +func (d *Decoder) valueFromOtherSlice(mtype reflect.Type, tval []interface{}) (reflect.Value, error) { mval := reflect.MakeSlice(mtype, len(tval), len(tval)) for i := 0; i < len(tval); i++ { - val, err := valueFromToml(mtype.Elem(), tval[i]) + val, err := d.valueFromToml(mtype.Elem(), tval[i]) if err != nil { return mval, err } @@ -326,117 +471,86 @@ func valueFromOtherSlice(mtype reflect.Type, tval []interface{}) (reflect.Value, } // Convert toml value to marshal value, using marshal type -func valueFromToml(mtype reflect.Type, tval interface{}) (reflect.Value, error) { +func (d *Decoder) valueFromToml(mtype reflect.Type, tval interface{}) (reflect.Value, error) { if mtype.Kind() == reflect.Ptr { - return unwrapPointer(mtype, tval) + return d.unwrapPointer(mtype, tval) } - switch { - case isTree(mtype): - return valueFromTree(mtype, tval.(*Tree)) - case isTreeSlice(mtype): - return valueFromTreeSlice(mtype, tval.([]*Tree)) - case isOtherSlice(mtype): - return valueFromOtherSlice(mtype, tval.([]interface{})) + + switch tval.(type) { + case *Tree: + if isTree(mtype) { + return d.valueFromTree(mtype, tval.(*Tree)) + } + return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to a tree", tval, tval) + case []*Tree: + if isTreeSlice(mtype) { + return d.valueFromTreeSlice(mtype, tval.([]*Tree)) + } + return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to trees", tval, tval) + case []interface{}: + if isOtherSlice(mtype) { + return d.valueFromOtherSlice(mtype, tval.([]interface{})) + } + return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to a slice", tval, tval) default: switch mtype.Kind() { - case reflect.Bool: - val, ok := tval.(bool) - if !ok { - return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to bool", tval, tval) - } - return reflect.ValueOf(val), nil - case reflect.Int: - val, ok := tval.(int64) - if !ok { - return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to int", tval, tval) - } - return reflect.ValueOf(int(val)), nil - case reflect.Int8: - val, ok := tval.(int64) - if !ok { - return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to int", tval, tval) - } - return reflect.ValueOf(int8(val)), nil - case reflect.Int16: - val, ok := tval.(int64) - if !ok { - return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to int", tval, tval) - } - return reflect.ValueOf(int16(val)), nil - case reflect.Int32: - val, ok := tval.(int64) - if !ok { - return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to int", tval, tval) - } - return reflect.ValueOf(int32(val)), nil - case reflect.Int64: - val, ok := tval.(int64) - if !ok { - return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to int", tval, tval) + case reflect.Bool, reflect.Struct: + val := reflect.ValueOf(tval) + // if this passes for when mtype is reflect.Struct, tval is a time.Time + if !val.Type().ConvertibleTo(mtype) { + return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v", tval, tval, mtype.String()) } - return reflect.ValueOf(val), nil - case reflect.Uint: - val, ok := tval.(int64) - if !ok { - return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to uint", tval, tval) - } - return reflect.ValueOf(uint(val)), nil - case reflect.Uint8: - val, ok := tval.(int64) - if !ok { - return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to uint", tval, tval) + + return val.Convert(mtype), nil + case reflect.String: + val := reflect.ValueOf(tval) + // stupidly, int64 is convertible to string. So special case this. + if !val.Type().ConvertibleTo(mtype) || val.Kind() == reflect.Int64 { + return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v", tval, tval, mtype.String()) } - return reflect.ValueOf(uint8(val)), nil - case reflect.Uint16: - val, ok := tval.(int64) - if !ok { - return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to uint", tval, tval) + + return val.Convert(mtype), nil + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + val := reflect.ValueOf(tval) + if !val.Type().ConvertibleTo(mtype) { + return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v", tval, tval, mtype.String()) } - return reflect.ValueOf(uint16(val)), nil - case reflect.Uint32: - val, ok := tval.(int64) - if !ok { - return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to uint", tval, tval) + if reflect.Indirect(reflect.New(mtype)).OverflowInt(val.Int()) { + return reflect.ValueOf(nil), fmt.Errorf("%v(%T) would overflow %v", tval, tval, mtype.String()) } - return reflect.ValueOf(uint32(val)), nil - case reflect.Uint64: - val, ok := tval.(int64) - if !ok { - return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to uint", tval, tval) + + return val.Convert(mtype), nil + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + val := reflect.ValueOf(tval) + if !val.Type().ConvertibleTo(mtype) { + return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v", tval, tval, mtype.String()) } - return reflect.ValueOf(uint64(val)), nil - case reflect.Float32: - val, ok := tval.(float64) - if !ok { - return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to float", tval, tval) + if val.Int() < 0 { + return reflect.ValueOf(nil), fmt.Errorf("%v(%T) is negative so does not fit in %v", tval, tval, mtype.String()) } - return reflect.ValueOf(float32(val)), nil - case reflect.Float64: - val, ok := tval.(float64) - if !ok { - return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to float", tval, tval) + if reflect.Indirect(reflect.New(mtype)).OverflowUint(uint64(val.Int())) { + return reflect.ValueOf(nil), fmt.Errorf("%v(%T) would overflow %v", tval, tval, mtype.String()) } - return reflect.ValueOf(val), nil - case reflect.String: - val, ok := tval.(string) - if !ok { - return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to string", tval, tval) + + return val.Convert(mtype), nil + case reflect.Float32, reflect.Float64: + val := reflect.ValueOf(tval) + if !val.Type().ConvertibleTo(mtype) { + return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v", tval, tval, mtype.String()) } - return reflect.ValueOf(val), nil - case reflect.Struct: - val, ok := tval.(time.Time) - if !ok { - return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to time", tval, tval) + if reflect.Indirect(reflect.New(mtype)).OverflowFloat(val.Float()) { + return reflect.ValueOf(nil), fmt.Errorf("%v(%T) would overflow %v", tval, tval, mtype.String()) } - return reflect.ValueOf(val), nil + + return val.Convert(mtype), nil default: - return reflect.ValueOf(nil), fmt.Errorf("Unmarshal can't handle %v(%v)", mtype, mtype.Kind()) + return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v(%v)", tval, tval, mtype, mtype.Kind()) } } } -func unwrapPointer(mtype reflect.Type, tval interface{}) (reflect.Value, error) { - val, err := valueFromToml(mtype.Elem(), tval) +func (d *Decoder) unwrapPointer(mtype reflect.Type, tval interface{}) (reflect.Value, error) { + val, err := d.valueFromToml(mtype.Elem(), tval) if err != nil { return reflect.ValueOf(nil), err } @@ -448,7 +562,13 @@ func unwrapPointer(mtype reflect.Type, tval interface{}) (reflect.Value, error) func tomlOptions(vf reflect.StructField) tomlOpts { tag := vf.Tag.Get("toml") parse := strings.Split(tag, ",") - result := tomlOpts{vf.Name, true, false} + var comment string + if c := vf.Tag.Get("comment"); c != "" { + comment = c + } + commented, _ := strconv.ParseBool(vf.Tag.Get("commented")) + multiline, _ := strconv.ParseBool(vf.Tag.Get(tagKeyMultiline)) + result := tomlOpts{name: vf.Name, comment: comment, commented: commented, multiline: multiline, include: true, omitempty: false} if parse[0] != "" { if parse[0] == "-" && len(parse) == 1 { result.include = false diff --git a/vendor/github.com/pelletier/go-toml/parser.go b/vendor/github.com/pelletier/go-toml/parser.go index 8ee49cb..2d27599 100644 --- a/vendor/github.com/pelletier/go-toml/parser.go +++ b/vendor/github.com/pelletier/go-toml/parser.go @@ -5,6 +5,7 @@ package toml import ( "errors" "fmt" + "math" "reflect" "regexp" "strconv" @@ -185,10 +186,7 @@ func (p *tomlParser) parseAssign() tomlParserStateFn { } // assign value to the found table - keyVals, err := parseKey(key.val) - if err != nil { - p.raiseError(key, "%s", err) - } + keyVals := []string{key.val} if len(keyVals) != 1 { p.raiseError(key, "Invalid key") } @@ -205,20 +203,32 @@ func (p *tomlParser) parseAssign() tomlParserStateFn { case *Tree, []*Tree: toInsert = value default: - toInsert = &tomlValue{value, key.Position} + toInsert = &tomlValue{value: value, position: key.Position} } targetNode.values[keyVal] = toInsert return p.parseStart } var numberUnderscoreInvalidRegexp *regexp.Regexp +var hexNumberUnderscoreInvalidRegexp *regexp.Regexp -func cleanupNumberToken(value string) (string, error) { +func numberContainsInvalidUnderscore(value string) error { if numberUnderscoreInvalidRegexp.MatchString(value) { - return "", errors.New("invalid use of _ in number") + return errors.New("invalid use of _ in number") + } + return nil +} + +func hexNumberContainsInvalidUnderscore(value string) error { + if hexNumberUnderscoreInvalidRegexp.MatchString(value) { + return errors.New("invalid use of _ in hex number") } + return nil +} + +func cleanupNumberToken(value string) string { cleanedVal := strings.Replace(value, "_", "", -1) - return cleanedVal, nil + return cleanedVal } func (p *tomlParser) parseRvalue() interface{} { @@ -234,21 +244,57 @@ func (p *tomlParser) parseRvalue() interface{} { return true case tokenFalse: return false + case tokenInf: + if tok.val[0] == '-' { + return math.Inf(-1) + } + return math.Inf(1) + case tokenNan: + return math.NaN() case tokenInteger: - cleanedVal, err := cleanupNumberToken(tok.val) - if err != nil { - p.raiseError(tok, "%s", err) + cleanedVal := cleanupNumberToken(tok.val) + var err error + var val int64 + if len(cleanedVal) >= 3 && cleanedVal[0] == '0' { + switch cleanedVal[1] { + case 'x': + err = hexNumberContainsInvalidUnderscore(tok.val) + if err != nil { + p.raiseError(tok, "%s", err) + } + val, err = strconv.ParseInt(cleanedVal[2:], 16, 64) + case 'o': + err = numberContainsInvalidUnderscore(tok.val) + if err != nil { + p.raiseError(tok, "%s", err) + } + val, err = strconv.ParseInt(cleanedVal[2:], 8, 64) + case 'b': + err = numberContainsInvalidUnderscore(tok.val) + if err != nil { + p.raiseError(tok, "%s", err) + } + val, err = strconv.ParseInt(cleanedVal[2:], 2, 64) + default: + panic("invalid base") // the lexer should catch this first + } + } else { + err = numberContainsInvalidUnderscore(tok.val) + if err != nil { + p.raiseError(tok, "%s", err) + } + val, err = strconv.ParseInt(cleanedVal, 10, 64) } - val, err := strconv.ParseInt(cleanedVal, 10, 64) if err != nil { p.raiseError(tok, "%s", err) } return val case tokenFloat: - cleanedVal, err := cleanupNumberToken(tok.val) + err := numberContainsInvalidUnderscore(tok.val) if err != nil { p.raiseError(tok, "%s", err) } + cleanedVal := cleanupNumberToken(tok.val) val, err := strconv.ParseFloat(cleanedVal, 64) if err != nil { p.raiseError(tok, "%s", err) @@ -309,7 +355,7 @@ Loop: } p.getToken() default: - p.raiseError(follow, "unexpected token type in inline table: %s", follow.typ.String()) + p.raiseError(follow, "unexpected token type in inline table: %s", follow.String()) } previous = follow } @@ -379,5 +425,6 @@ func parseToml(flow []token) *Tree { } func init() { - numberUnderscoreInvalidRegexp = regexp.MustCompile(`([^\d]_|_[^\d]|_$|^_)`) + numberUnderscoreInvalidRegexp = regexp.MustCompile(`([^\d]_|_[^\d])|_$|^_`) + hexNumberUnderscoreInvalidRegexp = regexp.MustCompile(`(^0x_)|([^\da-f]_|_[^\da-f])|_$|^_`) } diff --git a/vendor/github.com/pelletier/go-toml/token.go b/vendor/github.com/pelletier/go-toml/token.go index 5581fe0..1a90813 100644 --- a/vendor/github.com/pelletier/go-toml/token.go +++ b/vendor/github.com/pelletier/go-toml/token.go @@ -23,6 +23,8 @@ const ( tokenTrue tokenFalse tokenFloat + tokenInf + tokenNan tokenEqual tokenLeftBracket tokenRightBracket @@ -55,6 +57,8 @@ var tokenTypeNames = []string{ "True", "False", "Float", + "Inf", + "NaN", "=", "[", "]", diff --git a/vendor/github.com/pelletier/go-toml/toml.go b/vendor/github.com/pelletier/go-toml/toml.go index 64f19ed..98c185a 100644 --- a/vendor/github.com/pelletier/go-toml/toml.go +++ b/vendor/github.com/pelletier/go-toml/toml.go @@ -11,14 +11,19 @@ import ( ) type tomlValue struct { - value interface{} // string, int64, uint64, float64, bool, time.Time, [] of any of this list - position Position + value interface{} // string, int64, uint64, float64, bool, time.Time, [] of any of this list + comment string + commented bool + multiline bool + position Position } // Tree is the result of the parsing of a TOML file. type Tree struct { - values map[string]interface{} // string -> *tomlValue, *Tree, []*Tree - position Position + values map[string]interface{} // string -> *tomlValue, *Tree, []*Tree + comment string + commented bool + position Position } func newTree() *Tree { @@ -67,18 +72,15 @@ func (t *Tree) Keys() []string { } // Get the value at key in the Tree. -// Key is a dot-separated path (e.g. a.b.c). +// Key is a dot-separated path (e.g. a.b.c) without single/double quoted strings. +// If you need to retrieve non-bare keys, use GetPath. // Returns nil if the path does not exist in the tree. // If keys is of length zero, the current tree is returned. func (t *Tree) Get(key string) interface{} { if key == "" { return t } - comps, err := parseKey(key) - if err != nil { - return nil - } - return t.GetPath(comps) + return t.GetPath(strings.Split(key, ".")) } // GetPath returns the element in the tree indicated by 'keys'. @@ -174,17 +176,86 @@ func (t *Tree) GetDefault(key string, def interface{}) interface{} { return val } +// SetOptions arguments are supplied to the SetWithOptions and SetPathWithOptions functions to modify marshalling behaviour. +// The default values within the struct are valid default options. +type SetOptions struct { + Comment string + Commented bool + Multiline bool +} + +// SetWithOptions is the same as Set, but allows you to provide formatting +// instructions to the key, that will be used by Marshal(). +func (t *Tree) SetWithOptions(key string, opts SetOptions, value interface{}) { + t.SetPathWithOptions(strings.Split(key, "."), opts, value) +} + +// SetPathWithOptions is the same as SetPath, but allows you to provide +// formatting instructions to the key, that will be reused by Marshal(). +func (t *Tree) SetPathWithOptions(keys []string, opts SetOptions, value interface{}) { + subtree := t + for _, intermediateKey := range keys[:len(keys)-1] { + nextTree, exists := subtree.values[intermediateKey] + if !exists { + nextTree = newTree() + subtree.values[intermediateKey] = nextTree // add new element here + } + switch node := nextTree.(type) { + case *Tree: + subtree = node + case []*Tree: + // go to most recent element + if len(node) == 0 { + // create element if it does not exist + subtree.values[intermediateKey] = append(node, newTree()) + } + subtree = node[len(node)-1] + } + } + + var toInsert interface{} + + switch value.(type) { + case *Tree: + tt := value.(*Tree) + tt.comment = opts.Comment + toInsert = value + case []*Tree: + toInsert = value + case *tomlValue: + tt := value.(*tomlValue) + tt.comment = opts.Comment + toInsert = tt + default: + toInsert = &tomlValue{value: value, comment: opts.Comment, commented: opts.Commented, multiline: opts.Multiline} + } + + subtree.values[keys[len(keys)-1]] = toInsert +} + // Set an element in the tree. // Key is a dot-separated path (e.g. a.b.c). // Creates all necessary intermediate trees, if needed. func (t *Tree) Set(key string, value interface{}) { - t.SetPath(strings.Split(key, "."), value) + t.SetWithComment(key, "", false, value) +} + +// SetWithComment is the same as Set, but allows you to provide comment +// information to the key, that will be reused by Marshal(). +func (t *Tree) SetWithComment(key string, comment string, commented bool, value interface{}) { + t.SetPathWithComment(strings.Split(key, "."), comment, commented, value) } // SetPath sets an element in the tree. // Keys is an array of path elements (e.g. {"a","b","c"}). // Creates all necessary intermediate trees, if needed. func (t *Tree) SetPath(keys []string, value interface{}) { + t.SetPathWithComment(keys, "", false, value) +} + +// SetPathWithComment is the same as SetPath, but allows you to provide comment +// information to the key, that will be reused by Marshal(). +func (t *Tree) SetPathWithComment(keys []string, comment string, commented bool, value interface{}) { subtree := t for _, intermediateKey := range keys[:len(keys)-1] { nextTree, exists := subtree.values[intermediateKey] @@ -209,13 +280,17 @@ func (t *Tree) SetPath(keys []string, value interface{}) { switch value.(type) { case *Tree: + tt := value.(*Tree) + tt.comment = comment toInsert = value case []*Tree: toInsert = value case *tomlValue: - toInsert = value + tt := value.(*tomlValue) + tt.comment = comment + toInsert = tt default: - toInsert = &tomlValue{value: value} + toInsert = &tomlValue{value: value, comment: comment, commented: commented} } subtree.values[keys[len(keys)-1]] = toInsert diff --git a/vendor/github.com/pelletier/go-toml/tomltree_create.go b/vendor/github.com/pelletier/go-toml/tomltree_create.go index 19d1c0d..79610e9 100644 --- a/vendor/github.com/pelletier/go-toml/tomltree_create.go +++ b/vendor/github.com/pelletier/go-toml/tomltree_create.go @@ -104,7 +104,7 @@ func sliceToTree(object interface{}) (interface{}, error) { } arrayValue = reflect.Append(arrayValue, reflect.ValueOf(simpleValue)) } - return &tomlValue{arrayValue.Interface(), Position{}}, nil + return &tomlValue{value: arrayValue.Interface(), position: Position{}}, nil } func toTree(object interface{}) (interface{}, error) { @@ -127,7 +127,7 @@ func toTree(object interface{}) (interface{}, error) { } values[key.String()] = newValue } - return &Tree{values, Position{}}, nil + return &Tree{values: values, position: Position{}}, nil } if value.Kind() == reflect.Array || value.Kind() == reflect.Slice { @@ -138,5 +138,5 @@ func toTree(object interface{}) (interface{}, error) { if err != nil { return nil, err } - return &tomlValue{simpleValue, Position{}}, nil + return &tomlValue{value: simpleValue, position: Position{}}, nil } diff --git a/vendor/github.com/pelletier/go-toml/tomltree_write.go b/vendor/github.com/pelletier/go-toml/tomltree_write.go index ca763ed..e4049e2 100644 --- a/vendor/github.com/pelletier/go-toml/tomltree_write.go +++ b/vendor/github.com/pelletier/go-toml/tomltree_write.go @@ -12,7 +12,41 @@ import ( "time" ) -// encodes a string to a TOML-compliant string value +// Encodes a string to a TOML-compliant multi-line string value +// This function is a clone of the existing encodeTomlString function, except that whitespace characters +// are preserved. Quotation marks and backslashes are also not escaped. +func encodeMultilineTomlString(value string) string { + var b bytes.Buffer + + for _, rr := range value { + switch rr { + case '\b': + b.WriteString(`\b`) + case '\t': + b.WriteString("\t") + case '\n': + b.WriteString("\n") + case '\f': + b.WriteString(`\f`) + case '\r': + b.WriteString("\r") + case '"': + b.WriteString(`"`) + case '\\': + b.WriteString(`\`) + default: + intRr := uint16(rr) + if intRr < 0x001F { + b.WriteString(fmt.Sprintf("\\u%0.4X", intRr)) + } else { + b.WriteRune(rr) + } + } + } + return b.String() +} + +// Encodes a string to a TOML-compliant string value func encodeTomlString(value string) string { var b bytes.Buffer @@ -44,7 +78,16 @@ func encodeTomlString(value string) string { return b.String() } -func tomlValueStringRepresentation(v interface{}) (string, error) { +func tomlValueStringRepresentation(v interface{}, indent string, arraysOneElementPerLine bool) (string, error) { + // this interface check is added to dereference the change made in the writeTo function. + // That change was made to allow this function to see formatting options. + tv, ok := v.(*tomlValue) + if ok { + v = tv.value + } else { + tv = &tomlValue{} + } + switch value := v.(type) { case uint64: return strconv.FormatUint(value, 10), nil @@ -54,14 +97,17 @@ func tomlValueStringRepresentation(v interface{}) (string, error) { // Ensure a round float does contain a decimal point. Otherwise feeding // the output back to the parser would convert to an integer. if math.Trunc(value) == value { - return strconv.FormatFloat(value, 'f', 1, 32), nil + return strings.ToLower(strconv.FormatFloat(value, 'f', 1, 32)), nil } - return strconv.FormatFloat(value, 'f', -1, 32), nil + return strings.ToLower(strconv.FormatFloat(value, 'f', -1, 32)), nil case string: + if tv.multiline { + return "\"\"\"\n" + encodeMultilineTomlString(value) + "\"\"\"", nil + } return "\"" + encodeTomlString(value) + "\"", nil case []byte: b, _ := v.([]byte) - return tomlValueStringRepresentation(string(b)) + return tomlValueStringRepresentation(string(b), indent, arraysOneElementPerLine) case bool: if value { return "true", nil @@ -76,21 +122,38 @@ func tomlValueStringRepresentation(v interface{}) (string, error) { rv := reflect.ValueOf(v) if rv.Kind() == reflect.Slice { - values := []string{} + var values []string for i := 0; i < rv.Len(); i++ { item := rv.Index(i).Interface() - itemRepr, err := tomlValueStringRepresentation(item) + itemRepr, err := tomlValueStringRepresentation(item, indent, arraysOneElementPerLine) if err != nil { return "", err } values = append(values, itemRepr) } + if arraysOneElementPerLine && len(values) > 1 { + stringBuffer := bytes.Buffer{} + valueIndent := indent + ` ` // TODO: move that to a shared encoder state + + stringBuffer.WriteString("[\n") + + for _, value := range values { + stringBuffer.WriteString(valueIndent) + stringBuffer.WriteString(value) + stringBuffer.WriteString(`,`) + stringBuffer.WriteString("\n") + } + + stringBuffer.WriteString(indent + "]") + + return stringBuffer.String(), nil + } return "[" + strings.Join(values, ",") + "]", nil } return "", fmt.Errorf("unsupported value type %T: %v", v, v) } -func (t *Tree) writeTo(w io.Writer, indent, keyspace string, bytesCount int64) (int64, error) { +func (t *Tree) writeTo(w io.Writer, indent, keyspace string, bytesCount int64, arraysOneElementPerLine bool) (int64, error) { simpleValuesKeys := make([]string, 0) complexValuesKeys := make([]string, 0) @@ -113,12 +176,29 @@ func (t *Tree) writeTo(w io.Writer, indent, keyspace string, bytesCount int64) ( return bytesCount, fmt.Errorf("invalid value type at %s: %T", k, t.values[k]) } - repr, err := tomlValueStringRepresentation(v.value) + repr, err := tomlValueStringRepresentation(v, indent, arraysOneElementPerLine) if err != nil { return bytesCount, err } - writtenBytesCount, err := writeStrings(w, indent, k, " = ", repr, "\n") + if v.comment != "" { + comment := strings.Replace(v.comment, "\n", "\n"+indent+"#", -1) + start := "# " + if strings.HasPrefix(comment, "#") { + start = "" + } + writtenBytesCountComment, errc := writeStrings(w, "\n", indent, start, comment, "\n") + bytesCount += int64(writtenBytesCountComment) + if errc != nil { + return bytesCount, errc + } + } + + var commented string + if v.commented { + commented = "# " + } + writtenBytesCount, err := writeStrings(w, indent, commented, k, " = ", repr, "\n") bytesCount += int64(writtenBytesCount) if err != nil { return bytesCount, err @@ -132,28 +212,48 @@ func (t *Tree) writeTo(w io.Writer, indent, keyspace string, bytesCount int64) ( if keyspace != "" { combinedKey = keyspace + "." + combinedKey } + var commented string + if t.commented { + commented = "# " + } switch node := v.(type) { // node has to be of those two types given how keys are sorted above case *Tree: - writtenBytesCount, err := writeStrings(w, "\n", indent, "[", combinedKey, "]\n") + tv, ok := t.values[k].(*Tree) + if !ok { + return bytesCount, fmt.Errorf("invalid value type at %s: %T", k, t.values[k]) + } + if tv.comment != "" { + comment := strings.Replace(tv.comment, "\n", "\n"+indent+"#", -1) + start := "# " + if strings.HasPrefix(comment, "#") { + start = "" + } + writtenBytesCountComment, errc := writeStrings(w, "\n", indent, start, comment) + bytesCount += int64(writtenBytesCountComment) + if errc != nil { + return bytesCount, errc + } + } + writtenBytesCount, err := writeStrings(w, "\n", indent, commented, "[", combinedKey, "]\n") bytesCount += int64(writtenBytesCount) if err != nil { return bytesCount, err } - bytesCount, err = node.writeTo(w, indent+" ", combinedKey, bytesCount) + bytesCount, err = node.writeTo(w, indent+" ", combinedKey, bytesCount, arraysOneElementPerLine) if err != nil { return bytesCount, err } case []*Tree: for _, subTree := range node { - writtenBytesCount, err := writeStrings(w, "\n", indent, "[[", combinedKey, "]]\n") + writtenBytesCount, err := writeStrings(w, "\n", indent, commented, "[[", combinedKey, "]]\n") bytesCount += int64(writtenBytesCount) if err != nil { return bytesCount, err } - bytesCount, err = subTree.writeTo(w, indent+" ", combinedKey, bytesCount) + bytesCount, err = subTree.writeTo(w, indent+" ", combinedKey, bytesCount, arraysOneElementPerLine) if err != nil { return bytesCount, err } @@ -179,7 +279,7 @@ func writeStrings(w io.Writer, s ...string) (int, error) { // WriteTo encode the Tree as Toml and writes it to the writer w. // Returns the number of bytes written in case of success, or an error if anything happened. func (t *Tree) WriteTo(w io.Writer) (int64, error) { - return t.writeTo(w, "", "", 0) + return t.writeTo(w, "", "", 0, false) } // ToTomlString generates a human-readable representation of the current tree. diff --git a/vendor/github.com/pkg/errors/LICENSE b/vendor/github.com/pkg/errors/LICENSE new file mode 100644 index 0000000..835ba3e --- /dev/null +++ b/vendor/github.com/pkg/errors/LICENSE @@ -0,0 +1,23 @@ +Copyright (c) 2015, Dave Cheney +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/pkg/errors/errors.go b/vendor/github.com/pkg/errors/errors.go new file mode 100644 index 0000000..842ee80 --- /dev/null +++ b/vendor/github.com/pkg/errors/errors.go @@ -0,0 +1,269 @@ +// Package errors provides simple error handling primitives. +// +// The traditional error handling idiom in Go is roughly akin to +// +// if err != nil { +// return err +// } +// +// which applied recursively up the call stack results in error reports +// without context or debugging information. The errors package allows +// programmers to add context to the failure path in their code in a way +// that does not destroy the original value of the error. +// +// Adding context to an error +// +// The errors.Wrap function returns a new error that adds context to the +// original error by recording a stack trace at the point Wrap is called, +// and the supplied message. For example +// +// _, err := ioutil.ReadAll(r) +// if err != nil { +// return errors.Wrap(err, "read failed") +// } +// +// If additional control is required the errors.WithStack and errors.WithMessage +// functions destructure errors.Wrap into its component operations of annotating +// an error with a stack trace and an a message, respectively. +// +// Retrieving the cause of an error +// +// Using errors.Wrap constructs a stack of errors, adding context to the +// preceding error. Depending on the nature of the error it may be necessary +// to reverse the operation of errors.Wrap to retrieve the original error +// for inspection. Any error value which implements this interface +// +// type causer interface { +// Cause() error +// } +// +// can be inspected by errors.Cause. errors.Cause will recursively retrieve +// the topmost error which does not implement causer, which is assumed to be +// the original cause. For example: +// +// switch err := errors.Cause(err).(type) { +// case *MyError: +// // handle specifically +// default: +// // unknown error +// } +// +// causer interface is not exported by this package, but is considered a part +// of stable public API. +// +// Formatted printing of errors +// +// All error values returned from this package implement fmt.Formatter and can +// be formatted by the fmt package. The following verbs are supported +// +// %s print the error. If the error has a Cause it will be +// printed recursively +// %v see %s +// %+v extended format. Each Frame of the error's StackTrace will +// be printed in detail. +// +// Retrieving the stack trace of an error or wrapper +// +// New, Errorf, Wrap, and Wrapf record a stack trace at the point they are +// invoked. This information can be retrieved with the following interface. +// +// type stackTracer interface { +// StackTrace() errors.StackTrace +// } +// +// Where errors.StackTrace is defined as +// +// type StackTrace []Frame +// +// The Frame type represents a call site in the stack trace. Frame supports +// the fmt.Formatter interface that can be used for printing information about +// the stack trace of this error. For example: +// +// if err, ok := err.(stackTracer); ok { +// for _, f := range err.StackTrace() { +// fmt.Printf("%+s:%d", f) +// } +// } +// +// stackTracer interface is not exported by this package, but is considered a part +// of stable public API. +// +// See the documentation for Frame.Format for more details. +package errors + +import ( + "fmt" + "io" +) + +// New returns an error with the supplied message. +// New also records the stack trace at the point it was called. +func New(message string) error { + return &fundamental{ + msg: message, + stack: callers(), + } +} + +// Errorf formats according to a format specifier and returns the string +// as a value that satisfies error. +// Errorf also records the stack trace at the point it was called. +func Errorf(format string, args ...interface{}) error { + return &fundamental{ + msg: fmt.Sprintf(format, args...), + stack: callers(), + } +} + +// fundamental is an error that has a message and a stack, but no caller. +type fundamental struct { + msg string + *stack +} + +func (f *fundamental) Error() string { return f.msg } + +func (f *fundamental) Format(s fmt.State, verb rune) { + switch verb { + case 'v': + if s.Flag('+') { + io.WriteString(s, f.msg) + f.stack.Format(s, verb) + return + } + fallthrough + case 's': + io.WriteString(s, f.msg) + case 'q': + fmt.Fprintf(s, "%q", f.msg) + } +} + +// WithStack annotates err with a stack trace at the point WithStack was called. +// If err is nil, WithStack returns nil. +func WithStack(err error) error { + if err == nil { + return nil + } + return &withStack{ + err, + callers(), + } +} + +type withStack struct { + error + *stack +} + +func (w *withStack) Cause() error { return w.error } + +func (w *withStack) Format(s fmt.State, verb rune) { + switch verb { + case 'v': + if s.Flag('+') { + fmt.Fprintf(s, "%+v", w.Cause()) + w.stack.Format(s, verb) + return + } + fallthrough + case 's': + io.WriteString(s, w.Error()) + case 'q': + fmt.Fprintf(s, "%q", w.Error()) + } +} + +// Wrap returns an error annotating err with a stack trace +// at the point Wrap is called, and the supplied message. +// If err is nil, Wrap returns nil. +func Wrap(err error, message string) error { + if err == nil { + return nil + } + err = &withMessage{ + cause: err, + msg: message, + } + return &withStack{ + err, + callers(), + } +} + +// Wrapf returns an error annotating err with a stack trace +// at the point Wrapf is call, and the format specifier. +// If err is nil, Wrapf returns nil. +func Wrapf(err error, format string, args ...interface{}) error { + if err == nil { + return nil + } + err = &withMessage{ + cause: err, + msg: fmt.Sprintf(format, args...), + } + return &withStack{ + err, + callers(), + } +} + +// WithMessage annotates err with a new message. +// If err is nil, WithMessage returns nil. +func WithMessage(err error, message string) error { + if err == nil { + return nil + } + return &withMessage{ + cause: err, + msg: message, + } +} + +type withMessage struct { + cause error + msg string +} + +func (w *withMessage) Error() string { return w.msg + ": " + w.cause.Error() } +func (w *withMessage) Cause() error { return w.cause } + +func (w *withMessage) Format(s fmt.State, verb rune) { + switch verb { + case 'v': + if s.Flag('+') { + fmt.Fprintf(s, "%+v\n", w.Cause()) + io.WriteString(s, w.msg) + return + } + fallthrough + case 's', 'q': + io.WriteString(s, w.Error()) + } +} + +// Cause returns the underlying cause of the error, if possible. +// An error value has a cause if it implements the following +// interface: +// +// type causer interface { +// Cause() error +// } +// +// If the error does not implement Cause, the original error will +// be returned. If the error is nil, nil will be returned without further +// investigation. +func Cause(err error) error { + type causer interface { + Cause() error + } + + for err != nil { + cause, ok := err.(causer) + if !ok { + break + } + err = cause.Cause() + } + return err +} diff --git a/vendor/github.com/pkg/errors/stack.go b/vendor/github.com/pkg/errors/stack.go new file mode 100644 index 0000000..6b1f289 --- /dev/null +++ b/vendor/github.com/pkg/errors/stack.go @@ -0,0 +1,178 @@ +package errors + +import ( + "fmt" + "io" + "path" + "runtime" + "strings" +) + +// Frame represents a program counter inside a stack frame. +type Frame uintptr + +// pc returns the program counter for this frame; +// multiple frames may have the same PC value. +func (f Frame) pc() uintptr { return uintptr(f) - 1 } + +// file returns the full path to the file that contains the +// function for this Frame's pc. +func (f Frame) file() string { + fn := runtime.FuncForPC(f.pc()) + if fn == nil { + return "unknown" + } + file, _ := fn.FileLine(f.pc()) + return file +} + +// line returns the line number of source code of the +// function for this Frame's pc. +func (f Frame) line() int { + fn := runtime.FuncForPC(f.pc()) + if fn == nil { + return 0 + } + _, line := fn.FileLine(f.pc()) + return line +} + +// Format formats the frame according to the fmt.Formatter interface. +// +// %s source file +// %d source line +// %n function name +// %v equivalent to %s:%d +// +// Format accepts flags that alter the printing of some verbs, as follows: +// +// %+s path of source file relative to the compile time GOPATH +// %+v equivalent to %+s:%d +func (f Frame) Format(s fmt.State, verb rune) { + switch verb { + case 's': + switch { + case s.Flag('+'): + pc := f.pc() + fn := runtime.FuncForPC(pc) + if fn == nil { + io.WriteString(s, "unknown") + } else { + file, _ := fn.FileLine(pc) + fmt.Fprintf(s, "%s\n\t%s", fn.Name(), file) + } + default: + io.WriteString(s, path.Base(f.file())) + } + case 'd': + fmt.Fprintf(s, "%d", f.line()) + case 'n': + name := runtime.FuncForPC(f.pc()).Name() + io.WriteString(s, funcname(name)) + case 'v': + f.Format(s, 's') + io.WriteString(s, ":") + f.Format(s, 'd') + } +} + +// StackTrace is stack of Frames from innermost (newest) to outermost (oldest). +type StackTrace []Frame + +func (st StackTrace) Format(s fmt.State, verb rune) { + switch verb { + case 'v': + switch { + case s.Flag('+'): + for _, f := range st { + fmt.Fprintf(s, "\n%+v", f) + } + case s.Flag('#'): + fmt.Fprintf(s, "%#v", []Frame(st)) + default: + fmt.Fprintf(s, "%v", []Frame(st)) + } + case 's': + fmt.Fprintf(s, "%s", []Frame(st)) + } +} + +// stack represents a stack of program counters. +type stack []uintptr + +func (s *stack) Format(st fmt.State, verb rune) { + switch verb { + case 'v': + switch { + case st.Flag('+'): + for _, pc := range *s { + f := Frame(pc) + fmt.Fprintf(st, "\n%+v", f) + } + } + } +} + +func (s *stack) StackTrace() StackTrace { + f := make([]Frame, len(*s)) + for i := 0; i < len(f); i++ { + f[i] = Frame((*s)[i]) + } + return f +} + +func callers() *stack { + const depth = 32 + var pcs [depth]uintptr + n := runtime.Callers(3, pcs[:]) + var st stack = pcs[0:n] + return &st +} + +// funcname removes the path prefix component of a function's name reported by func.Name(). +func funcname(name string) string { + i := strings.LastIndex(name, "/") + name = name[i+1:] + i = strings.Index(name, ".") + return name[i+1:] +} + +func trimGOPATH(name, file string) string { + // Here we want to get the source file path relative to the compile time + // GOPATH. As of Go 1.6.x there is no direct way to know the compiled + // GOPATH at runtime, but we can infer the number of path segments in the + // GOPATH. We note that fn.Name() returns the function name qualified by + // the import path, which does not include the GOPATH. Thus we can trim + // segments from the beginning of the file path until the number of path + // separators remaining is one more than the number of path separators in + // the function name. For example, given: + // + // GOPATH /home/user + // file /home/user/src/pkg/sub/file.go + // fn.Name() pkg/sub.Type.Method + // + // We want to produce: + // + // pkg/sub/file.go + // + // From this we can easily see that fn.Name() has one less path separator + // than our desired output. We count separators from the end of the file + // path until it finds two more than in the function name and then move + // one character forward to preserve the initial path segment without a + // leading separator. + const sep = "/" + goal := strings.Count(name, sep) + 2 + i := len(file) + for n := 0; n < goal; n++ { + i = strings.LastIndex(file[:i], sep) + if i == -1 { + // not enough separators found, set i so that the slice expression + // below leaves file unmodified + i = -len(sep) + break + } + } + // get back to 0 or trim the leading separator + file = file[i+len(sep):] + return file +} diff --git a/vendor/github.com/russross/blackfriday/block.go b/vendor/github.com/russross/blackfriday/block.go index d7da33f..45c21a6 100644 --- a/vendor/github.com/russross/blackfriday/block.go +++ b/vendor/github.com/russross/blackfriday/block.go @@ -15,26 +15,18 @@ package blackfriday import ( "bytes" - "html" - "regexp" - - "github.com/shurcooL/sanitized_anchor_name" -) - -const ( - charEntity = "&(?:#x[a-f0-9]{1,8}|#[0-9]{1,8}|[a-z][a-z0-9]{1,31});" - escapable = "[!\"#$%&'()*+,./:;<=>?@[\\\\\\]^_`{|}~-]" -) - -var ( - reBackslashOrAmp = regexp.MustCompile("[\\&]") - reEntityOrEscapedChar = regexp.MustCompile("(?i)\\\\" + escapable + "|" + charEntity) + "strings" + "unicode" ) // Parse block-level data. // Note: this function and many that it calls assume that // the input buffer ends with a newline. -func (p *Markdown) block(data []byte) { +func (p *parser) block(out *bytes.Buffer, data []byte) { + if len(data) == 0 || data[len(data)-1] != '\n' { + panic("block input is missing terminating newline") + } + // this is called recursively: enforce a maximum depth if p.nesting >= p.maxNesting { return @@ -43,14 +35,14 @@ func (p *Markdown) block(data []byte) { // parse out one block-level construct at a time for len(data) > 0 { - // prefixed heading: + // prefixed header: // - // # Heading 1 - // ## Heading 2 + // # Header 1 + // ## Header 2 // ... - // ###### Heading 6 - if p.isPrefixHeading(data) { - data = data[p.prefixHeading(data):] + // ###### Header 6 + if p.isPrefixHeader(data) { + data = data[p.prefixHeader(out, data):] continue } @@ -60,7 +52,7 @@ func (p *Markdown) block(data []byte) { // ... // if data[0] == '<' { - if i := p.html(data, true); i > 0 { + if i := p.html(out, data, true); i > 0 { data = data[i:] continue } @@ -71,9 +63,9 @@ func (p *Markdown) block(data []byte) { // % stuff // % more stuff // % even more stuff - if p.extensions&Titleblock != 0 { + if p.flags&EXTENSION_TITLEBLOCK != 0 { if data[0] == '%' { - if i := p.titleBlock(data, true); i > 0 { + if i := p.titleBlock(out, data, true); i > 0 { data = data[i:] continue } @@ -95,13 +87,13 @@ func (p *Markdown) block(data []byte) { // return b // } if p.codePrefix(data) > 0 { - data = data[p.code(data):] + data = data[p.code(out, data):] continue } // fenced code block: // - // ``` go + // ``` go info string here // func fact(n int) int { // if n <= 1 { // return n @@ -109,8 +101,8 @@ func (p *Markdown) block(data []byte) { // return n * fact(n-1) // } // ``` - if p.extensions&FencedCode != 0 { - if i := p.fencedCodeBlock(data, true); i > 0 { + if p.flags&EXTENSION_FENCED_CODE != 0 { + if i := p.fencedCodeBlock(out, data, true); i > 0 { data = data[i:] continue } @@ -124,9 +116,9 @@ func (p *Markdown) block(data []byte) { // or // ______ if p.isHRule(data) { - p.addBlock(HorizontalRule, nil) + p.r.HRule(out) var i int - for i = 0; i < len(data) && data[i] != '\n'; i++ { + for i = 0; data[i] != '\n'; i++ { } data = data[i:] continue @@ -137,7 +129,7 @@ func (p *Markdown) block(data []byte) { // > A big quote I found somewhere // > on the web if p.quotePrefix(data) > 0 { - data = data[p.quote(data):] + data = data[p.quote(out, data):] continue } @@ -147,8 +139,8 @@ func (p *Markdown) block(data []byte) { // ------|-----|--------- // Bob | 31 | 555-1234 // Alice | 27 | 555-4321 - if p.extensions&Tables != 0 { - if i := p.table(data); i > 0 { + if p.flags&EXTENSION_TABLES != 0 { + if i := p.table(out, data); i > 0 { data = data[i:] continue } @@ -161,7 +153,7 @@ func (p *Markdown) block(data []byte) { // // also works with + or - if p.uliPrefix(data) > 0 { - data = data[p.list(data, 0):] + data = data[p.list(out, data, 0):] continue } @@ -170,7 +162,7 @@ func (p *Markdown) block(data []byte) { // 1. Item 1 // 2. Item 2 if p.oliPrefix(data) > 0 { - data = data[p.list(data, ListTypeOrdered):] + data = data[p.list(out, data, LIST_TYPE_ORDERED):] continue } @@ -182,62 +174,55 @@ func (p *Markdown) block(data []byte) { // // Term 2 // : Definition c - if p.extensions&DefinitionLists != 0 { + if p.flags&EXTENSION_DEFINITION_LISTS != 0 { if p.dliPrefix(data) > 0 { - data = data[p.list(data, ListTypeDefinition):] + data = data[p.list(out, data, LIST_TYPE_DEFINITION):] continue } } // anything else must look like a normal paragraph - // note: this finds underlined headings, too - data = data[p.paragraph(data):] + // note: this finds underlined headers, too + data = data[p.paragraph(out, data):] } p.nesting-- } -func (p *Markdown) addBlock(typ NodeType, content []byte) *Node { - p.closeUnmatchedBlocks() - container := p.addChild(typ, 0) - container.content = content - return container -} - -func (p *Markdown) isPrefixHeading(data []byte) bool { +func (p *parser) isPrefixHeader(data []byte) bool { if data[0] != '#' { return false } - if p.extensions&SpaceHeadings != 0 { + if p.flags&EXTENSION_SPACE_HEADERS != 0 { level := 0 - for level < 6 && level < len(data) && data[level] == '#' { + for level < 6 && data[level] == '#' { level++ } - if level == len(data) || data[level] != ' ' { + if data[level] != ' ' { return false } } return true } -func (p *Markdown) prefixHeading(data []byte) int { +func (p *parser) prefixHeader(out *bytes.Buffer, data []byte) int { level := 0 - for level < 6 && level < len(data) && data[level] == '#' { + for level < 6 && data[level] == '#' { level++ } i := skipChar(data, level, ' ') end := skipUntilChar(data, i, '\n') skip := end id := "" - if p.extensions&HeadingIDs != 0 { + if p.flags&EXTENSION_HEADER_IDS != 0 { j, k := 0, 0 - // find start/end of heading id + // find start/end of header id for j = i; j < end-1 && (data[j] != '{' || data[j+1] != '#'); j++ { } for k = j + 1; k < end && data[k] != '}'; k++ { } - // extract heading id iff found + // extract header id iff found if j < end && k < end { id = string(data[j+2 : k]) end = j @@ -257,41 +242,45 @@ func (p *Markdown) prefixHeading(data []byte) int { end-- } if end > i { - if id == "" && p.extensions&AutoHeadingIDs != 0 { - id = sanitized_anchor_name.Create(string(data[i:end])) + if id == "" && p.flags&EXTENSION_AUTO_HEADER_IDS != 0 { + id = SanitizedAnchorName(string(data[i:end])) } - block := p.addBlock(Heading, data[i:end]) - block.HeadingID = id - block.Level = level + work := func() bool { + p.inline(out, data[i:end]) + return true + } + p.r.Header(out, work, level, id) } return skip } -func (p *Markdown) isUnderlinedHeading(data []byte) int { - // test of level 1 heading +func (p *parser) isUnderlinedHeader(data []byte) int { + // test of level 1 header if data[0] == '=' { i := skipChar(data, 1, '=') i = skipChar(data, i, ' ') - if i < len(data) && data[i] == '\n' { + if data[i] == '\n' { return 1 + } else { + return 0 } - return 0 } - // test of level 2 heading + // test of level 2 header if data[0] == '-' { i := skipChar(data, 1, '-') i = skipChar(data, i, ' ') - if i < len(data) && data[i] == '\n' { + if data[i] == '\n' { return 2 + } else { + return 0 } - return 0 } return 0 } -func (p *Markdown) titleBlock(data []byte, doRender bool) int { +func (p *parser) titleBlock(out *bytes.Buffer, data []byte, doRender bool) int { if data[0] != '%' { return 0 } @@ -305,17 +294,12 @@ func (p *Markdown) titleBlock(data []byte, doRender bool) int { } data = bytes.Join(splitData[0:i], []byte("\n")) - consumed := len(data) - data = bytes.TrimPrefix(data, []byte("% ")) - data = bytes.Replace(data, []byte("\n% "), []byte("\n"), -1) - block := p.addBlock(Heading, data) - block.Level = 1 - block.IsTitleblock = true - - return consumed + p.r.TitleBlock(out, data) + + return len(data) } -func (p *Markdown) html(data []byte, doRender bool) int { +func (p *parser) html(out *bytes.Buffer, data []byte, doRender bool) int { var i, j int // identify the opening tag @@ -327,12 +311,17 @@ func (p *Markdown) html(data []byte, doRender bool) int { // handle special cases if !tagfound { // check for an HTML comment - if size := p.htmlComment(data, doRender); size > 0 { + if size := p.htmlComment(out, data, doRender); size > 0 { return size } // check for an
tag - if size := p.htmlHr(data, doRender); size > 0 { + if size := p.htmlHr(out, data, doRender); size > 0 { + return size + } + + // check for HTML CDATA + if size := p.htmlCDATA(out, data, doRender); size > 0 { return size } @@ -407,42 +396,60 @@ func (p *Markdown) html(data []byte, doRender bool) int { for end > 0 && data[end-1] == '\n' { end-- } - finalizeHTMLBlock(p.addBlock(HTMLBlock, data[:end])) + p.r.BlockHtml(out, data[:end]) } return i } -func finalizeHTMLBlock(block *Node) { - block.Literal = block.content - block.content = nil -} - -// HTML comment, lax form -func (p *Markdown) htmlComment(data []byte, doRender bool) int { - i := p.inlineHTMLComment(data) - // needs to end with a blank line - if j := p.isEmpty(data[i:]); j > 0 { - size := i + j +func (p *parser) renderHTMLBlock(out *bytes.Buffer, data []byte, start int, doRender bool) int { + // html block needs to end with a blank line + if i := p.isEmpty(data[start:]); i > 0 { + size := start + i if doRender { // trim trailing newlines end := size for end > 0 && data[end-1] == '\n' { end-- } - block := p.addBlock(HTMLBlock, data[:end]) - finalizeHTMLBlock(block) + p.r.BlockHtml(out, data[:end]) } return size } return 0 } -// HR, which is the only self-closing block tag considered -func (p *Markdown) htmlHr(data []byte, doRender bool) int { - if len(data) < 4 { +// HTML comment, lax form +func (p *parser) htmlComment(out *bytes.Buffer, data []byte, doRender bool) int { + i := p.inlineHTMLComment(out, data) + return p.renderHTMLBlock(out, data, i, doRender) +} + +// HTML CDATA section +func (p *parser) htmlCDATA(out *bytes.Buffer, data []byte, doRender bool) int { + const cdataTag = "') { + i++ + } + i++ + // no end-of-comment marker + if i >= len(data) { + return 0 + } + return p.renderHTMLBlock(out, data, i, doRender) +} + +// HR, which is the only self-closing block tag considered +func (p *parser) htmlHr(out *bytes.Buffer, data []byte, doRender bool) int { if data[0] != '<' || (data[1] != 'h' && data[1] != 'H') || (data[2] != 'r' && data[2] != 'R') { return 0 } @@ -450,31 +457,22 @@ func (p *Markdown) htmlHr(data []byte, doRender bool) int { // not an
tag after all; at least not a valid one return 0 } + i := 3 - for i < len(data) && data[i] != '>' && data[i] != '\n' { + for data[i] != '>' && data[i] != '\n' { i++ } - if i < len(data) && data[i] == '>' { - i++ - if j := p.isEmpty(data[i:]); j > 0 { - size := i + j - if doRender { - // trim newlines - end := size - for end > 0 && data[end-1] == '\n' { - end-- - } - finalizeHTMLBlock(p.addBlock(HTMLBlock, data[:end])) - } - return size - } + + if data[i] == '>' { + return p.renderHTMLBlock(out, data, i+1, doRender) } + return 0 } -func (p *Markdown) htmlFindTag(data []byte) (string, bool) { +func (p *parser) htmlFindTag(data []byte) (string, bool) { i := 0 - for i < len(data) && isalnum(data[i]) { + for isalnum(data[i]) { i++ } key := string(data[:i]) @@ -484,11 +482,9 @@ func (p *Markdown) htmlFindTag(data []byte) (string, bool) { return "", false } -func (p *Markdown) htmlFindEnd(tag string, data []byte) int { +func (p *parser) htmlFindEnd(tag string, data []byte) int { // assume data[0] == '<' && data[1] == '/' already tested - if tag == "hr" { - return 2 - } + // check if tag is a match closetag := []byte("") if !bytes.HasPrefix(data, closetag) { @@ -508,7 +504,7 @@ func (p *Markdown) htmlFindEnd(tag string, data []byte) int { return i } - if p.extensions&LaxHTMLBlocks != 0 { + if p.flags&EXTENSION_LAX_HTML_BLOCKS != 0 { return i } if skip = p.isEmpty(data[i:]); skip == 0 { @@ -519,7 +515,7 @@ func (p *Markdown) htmlFindEnd(tag string, data []byte) int { return i + skip } -func (*Markdown) isEmpty(data []byte) int { +func (*parser) isEmpty(data []byte) int { // it is okay to call isEmpty on an empty buffer if len(data) == 0 { return 0 @@ -531,13 +527,10 @@ func (*Markdown) isEmpty(data []byte) int { return 0 } } - if i < len(data) && data[i] == '\n' { - i++ - } - return i + return i + 1 } -func (*Markdown) isHRule(data []byte) bool { +func (*parser) isHRule(data []byte) bool { i := 0 // skip up to three spaces @@ -553,7 +546,7 @@ func (*Markdown) isHRule(data []byte) bool { // the whole line must be the char or whitespace n := 0 - for i < len(data) && data[i] != '\n' { + for data[i] != '\n' { switch { case data[i] == c: n++ @@ -569,7 +562,8 @@ func (*Markdown) isHRule(data []byte) bool { // isFenceLine checks if there's a fence line (e.g., ``` or ``` go) at the beginning of data, // and returns the end index if so, or 0 otherwise. It also returns the marker found. // If syntax is not nil, it gets set to the syntax specified in the fence line. -func isFenceLine(data []byte, syntax *string, oldmarker string) (end int, marker string) { +// A final newline is mandatory to recognize the fence line, unless newlineOptional is true. +func isFenceLine(data []byte, info *string, oldmarker string, newlineOptional bool) (end int, marker string) { i, size := 0, 0 // skip up to three spaces @@ -605,26 +599,26 @@ func isFenceLine(data []byte, syntax *string, oldmarker string) (end int, marker } // TODO(shurcooL): It's probably a good idea to simplify the 2 code paths here - // into one, always get the syntax, and discard it if the caller doesn't care. - if syntax != nil { - syn := 0 + // into one, always get the info string, and discard it if the caller doesn't care. + if info != nil { + infoLength := 0 i = skipChar(data, i, ' ') if i >= len(data) { - if i == len(data) { + if newlineOptional && i == len(data) { return i, marker } return 0, "" } - syntaxStart := i + infoStart := i if data[i] == '{' { i++ - syntaxStart++ + infoStart++ for i < len(data) && data[i] != '}' && data[i] != '\n' { - syn++ + infoLength++ i++ } @@ -634,55 +628,55 @@ func isFenceLine(data []byte, syntax *string, oldmarker string) (end int, marker // strip all whitespace at the beginning and the end // of the {} block - for syn > 0 && isspace(data[syntaxStart]) { - syntaxStart++ - syn-- + for infoLength > 0 && isspace(data[infoStart]) { + infoStart++ + infoLength-- } - for syn > 0 && isspace(data[syntaxStart+syn-1]) { - syn-- + for infoLength > 0 && isspace(data[infoStart+infoLength-1]) { + infoLength-- } i++ } else { - for i < len(data) && !isspace(data[i]) { - syn++ + for i < len(data) && !isverticalspace(data[i]) { + infoLength++ i++ } } - *syntax = string(data[syntaxStart : syntaxStart+syn]) + *info = strings.TrimSpace(string(data[infoStart : infoStart+infoLength])) } i = skipChar(data, i, ' ') if i >= len(data) || data[i] != '\n' { - if i == len(data) { + if newlineOptional && i == len(data) { return i, marker } return 0, "" } + return i + 1, marker // Take newline into account. } // fencedCodeBlock returns the end index if data contains a fenced code block at the beginning, // or 0 otherwise. It writes to out if doRender is true, otherwise it has no side effects. // If doRender is true, a final newline is mandatory to recognize the fenced code block. -func (p *Markdown) fencedCodeBlock(data []byte, doRender bool) int { - var syntax string - beg, marker := isFenceLine(data, &syntax, "") +func (p *parser) fencedCodeBlock(out *bytes.Buffer, data []byte, doRender bool) int { + var infoString string + beg, marker := isFenceLine(data, &infoString, "", false) if beg == 0 || beg >= len(data) { return 0 } var work bytes.Buffer - work.Write([]byte(syntax)) - work.WriteByte('\n') for { // safe to assume beg < len(data) // check for the end of the code block - fenceEnd, _ := isFenceLine(data[beg:], nil, marker) + newlineOptional := !doRender + fenceEnd, _ := isFenceLine(data[beg:], nil, marker, newlineOptional) if fenceEnd != 0 { beg += fenceEnd break @@ -704,55 +698,24 @@ func (p *Markdown) fencedCodeBlock(data []byte, doRender bool) int { } if doRender { - block := p.addBlock(CodeBlock, work.Bytes()) // TODO: get rid of temp buffer - block.IsFenced = true - finalizeCodeBlock(block) + p.r.BlockCode(out, work.Bytes(), infoString) } return beg } -func unescapeChar(str []byte) []byte { - if str[0] == '\\' { - return []byte{str[1]} - } - return []byte(html.UnescapeString(string(str))) -} - -func unescapeString(str []byte) []byte { - if reBackslashOrAmp.Match(str) { - return reEntityOrEscapedChar.ReplaceAllFunc(str, unescapeChar) - } - return str -} - -func finalizeCodeBlock(block *Node) { - if block.IsFenced { - newlinePos := bytes.IndexByte(block.content, '\n') - firstLine := block.content[:newlinePos] - rest := block.content[newlinePos+1:] - block.Info = unescapeString(bytes.Trim(firstLine, "\n")) - block.Literal = rest - } else { - block.Literal = block.content - } - block.content = nil -} - -func (p *Markdown) table(data []byte) int { - table := p.addBlock(Table, nil) - i, columns := p.tableHeader(data) +func (p *parser) table(out *bytes.Buffer, data []byte) int { + var header bytes.Buffer + i, columns := p.tableHeader(&header, data) if i == 0 { - p.tip = table.Parent - table.Unlink() return 0 } - p.addBlock(TableBody, nil) + var body bytes.Buffer for i < len(data) { pipes, rowStart := 0, i - for ; i < len(data) && data[i] != '\n'; i++ { + for ; data[i] != '\n'; i++ { if data[i] == '|' { pipes++ } @@ -764,12 +727,12 @@ func (p *Markdown) table(data []byte) int { } // include the newline in data sent to tableRow - if i < len(data) && data[i] == '\n' { - i++ - } - p.tableRow(data[rowStart:i], columns, false) + i++ + p.tableRow(&body, data[rowStart:i], columns, false) } + p.r.Table(out, header.Bytes(), body.Bytes(), columns) + return i } @@ -782,10 +745,10 @@ func isBackslashEscaped(data []byte, i int) bool { return backslashes&1 == 1 } -func (p *Markdown) tableHeader(data []byte) (size int, columns []CellAlignFlags) { +func (p *parser) tableHeader(out *bytes.Buffer, data []byte) (size int, columns []int) { i := 0 colCount := 1 - for i = 0; i < len(data) && data[i] != '\n'; i++ { + for i = 0; data[i] != '\n'; i++ { if data[i] == '|' && !isBackslashEscaped(data, i) { colCount++ } @@ -797,11 +760,7 @@ func (p *Markdown) tableHeader(data []byte) (size int, columns []CellAlignFlags) } // include the newline in the data sent to tableRow - j := i - if j < len(data) && data[j] == '\n' { - j++ - } - header := data[:j] + header := data[:i+1] // column count ignores pipes at beginning or end of line if data[0] == '|' { @@ -811,7 +770,7 @@ func (p *Markdown) tableHeader(data []byte) (size int, columns []CellAlignFlags) colCount-- } - columns = make([]CellAlignFlags, colCount) + columns = make([]int, colCount) // move on to the header underline i++ @@ -827,29 +786,27 @@ func (p *Markdown) tableHeader(data []byte) (size int, columns []CellAlignFlags) // each column header is of form: / *:?-+:? *|/ with # dashes + # colons >= 3 // and trailing | optional on last column col := 0 - for i < len(data) && data[i] != '\n' { + for data[i] != '\n' { dashes := 0 if data[i] == ':' { i++ - columns[col] |= TableAlignmentLeft + columns[col] |= TABLE_ALIGNMENT_LEFT dashes++ } - for i < len(data) && data[i] == '-' { + for data[i] == '-' { i++ dashes++ } - if i < len(data) && data[i] == ':' { + if data[i] == ':' { i++ - columns[col] |= TableAlignmentRight + columns[col] |= TABLE_ALIGNMENT_RIGHT dashes++ } - for i < len(data) && data[i] == ' ' { + for data[i] == ' ' { i++ } - if i == len(data) { - return - } + // end of column test is messy switch { case dashes < 3: @@ -860,12 +817,12 @@ func (p *Markdown) tableHeader(data []byte) (size int, columns []CellAlignFlags) // marker found, now skip past trailing whitespace col++ i++ - for i < len(data) && data[i] == ' ' { + for data[i] == ' ' { i++ } // trailing junk found after last column - if col >= colCount && i < len(data) && data[i] != '\n' { + if col >= colCount && data[i] != '\n' { return } @@ -886,31 +843,27 @@ func (p *Markdown) tableHeader(data []byte) (size int, columns []CellAlignFlags) return } - p.addBlock(TableHead, nil) - p.tableRow(header, columns, true) - size = i - if size < len(data) && data[size] == '\n' { - size++ - } + p.tableRow(out, header, columns, true) + size = i + 1 return } -func (p *Markdown) tableRow(data []byte, columns []CellAlignFlags, header bool) { - p.addBlock(TableRow, nil) +func (p *parser) tableRow(out *bytes.Buffer, data []byte, columns []int, header bool) { i, col := 0, 0 + var rowWork bytes.Buffer if data[i] == '|' && !isBackslashEscaped(data, i) { i++ } for col = 0; col < len(columns) && i < len(data); col++ { - for i < len(data) && data[i] == ' ' { + for data[i] == ' ' { i++ } cellStart := i - for i < len(data) && (data[i] != '|' || isBackslashEscaped(data, i)) && data[i] != '\n' { + for (data[i] != '|' || isBackslashEscaped(data, i)) && data[i] != '\n' { i++ } @@ -919,33 +872,42 @@ func (p *Markdown) tableRow(data []byte, columns []CellAlignFlags, header bool) // skip the end-of-cell marker, possibly taking us past end of buffer i++ - for cellEnd > cellStart && cellEnd-1 < len(data) && data[cellEnd-1] == ' ' { + for cellEnd > cellStart && data[cellEnd-1] == ' ' { cellEnd-- } - cell := p.addBlock(TableCell, data[cellStart:cellEnd]) - cell.IsHeader = header - cell.Align = columns[col] + var cellWork bytes.Buffer + p.inline(&cellWork, data[cellStart:cellEnd]) + + if header { + p.r.TableHeaderCell(&rowWork, cellWork.Bytes(), columns[col]) + } else { + p.r.TableCell(&rowWork, cellWork.Bytes(), columns[col]) + } } // pad it out with empty columns to get the right number for ; col < len(columns); col++ { - cell := p.addBlock(TableCell, nil) - cell.IsHeader = header - cell.Align = columns[col] + if header { + p.r.TableHeaderCell(&rowWork, nil, columns[col]) + } else { + p.r.TableCell(&rowWork, nil, columns[col]) + } } // silently ignore rows with too many cells + + p.r.TableRow(out, rowWork.Bytes()) } // returns blockquote prefix length -func (p *Markdown) quotePrefix(data []byte) int { +func (p *parser) quotePrefix(data []byte) int { i := 0 - for i < 3 && i < len(data) && data[i] == ' ' { + for i < 3 && data[i] == ' ' { i++ } - if i < len(data) && data[i] == '>' { - if i+1 < len(data) && data[i+1] == ' ' { + if data[i] == '>' { + if data[i+1] == ' ' { return i + 2 } return i + 1 @@ -955,7 +917,7 @@ func (p *Markdown) quotePrefix(data []byte) int { // blockquote ends with at least one blank line // followed by something without a blockquote prefix -func (p *Markdown) terminateBlockquote(data []byte, beg, end int) bool { +func (p *parser) terminateBlockquote(data []byte, beg, end int) bool { if p.isEmpty(data[beg:]) <= 0 { return false } @@ -966,8 +928,7 @@ func (p *Markdown) terminateBlockquote(data []byte, beg, end int) bool { } // parse a blockquote fragment -func (p *Markdown) quote(data []byte) int { - block := p.addBlock(BlockQuote, nil) +func (p *parser) quote(out *bytes.Buffer, data []byte) int { var raw bytes.Buffer beg, end := 0, 0 for beg < len(data) { @@ -975,9 +936,9 @@ func (p *Markdown) quote(data []byte) int { // Step over whole lines, collecting them. While doing that, check for // fenced code and if one's found, incorporate it altogether, // irregardless of any contents inside it - for end < len(data) && data[end] != '\n' { - if p.extensions&FencedCode != 0 { - if i := p.fencedCodeBlock(data[end:], false); i > 0 { + for data[end] != '\n' { + if p.flags&EXTENSION_FENCED_CODE != 0 { + if i := p.fencedCodeBlock(out, data[end:], false); i > 0 { // -1 to compensate for the extra end++ after the loop: end += i - 1 break @@ -985,47 +946,44 @@ func (p *Markdown) quote(data []byte) int { } end++ } - if end < len(data) && data[end] == '\n' { - end++ - } + end++ + if pre := p.quotePrefix(data[beg:]); pre > 0 { // skip the prefix beg += pre } else if p.terminateBlockquote(data, beg, end) { break } + // this line is part of the blockquote raw.Write(data[beg:end]) beg = end } - p.block(raw.Bytes()) - p.finalize(block) + + var cooked bytes.Buffer + p.block(&cooked, raw.Bytes()) + p.r.BlockQuote(out, cooked.Bytes()) return end } // returns prefix length for block code -func (p *Markdown) codePrefix(data []byte) int { - if len(data) >= 1 && data[0] == '\t' { - return 1 - } - if len(data) >= 4 && data[0] == ' ' && data[1] == ' ' && data[2] == ' ' && data[3] == ' ' { +func (p *parser) codePrefix(data []byte) int { + if data[0] == ' ' && data[1] == ' ' && data[2] == ' ' && data[3] == ' ' { return 4 } return 0 } -func (p *Markdown) code(data []byte) int { +func (p *parser) code(out *bytes.Buffer, data []byte) int { var work bytes.Buffer i := 0 for i < len(data) { beg := i - for i < len(data) && data[i] != '\n' { - i++ - } - if i < len(data) && data[i] == '\n' { + for data[i] != '\n' { i++ } + i++ blankline := p.isEmpty(data[beg:i]) > 0 if pre := p.codePrefix(data[beg:i]); pre > 0 { @@ -1036,7 +994,7 @@ func (p *Markdown) code(data []byte) int { break } - // verbatim copy to the working buffer + // verbatim copy to the working buffeu if blankline { work.WriteByte('\n') } else { @@ -1056,183 +1014,122 @@ func (p *Markdown) code(data []byte) int { work.WriteByte('\n') - block := p.addBlock(CodeBlock, work.Bytes()) // TODO: get rid of temp buffer - block.IsFenced = false - finalizeCodeBlock(block) + p.r.BlockCode(out, work.Bytes(), "") return i } // returns unordered list item prefix -func (p *Markdown) uliPrefix(data []byte) int { +func (p *parser) uliPrefix(data []byte) int { i := 0 + // start with up to 3 spaces - for i < len(data) && i < 3 && data[i] == ' ' { + for i < 3 && data[i] == ' ' { i++ } - if i >= len(data)-1 { - return 0 - } - // need one of {'*', '+', '-'} followed by a space or a tab + + // need a *, +, or - followed by a space if (data[i] != '*' && data[i] != '+' && data[i] != '-') || - (data[i+1] != ' ' && data[i+1] != '\t') { + data[i+1] != ' ' { return 0 } return i + 2 } // returns ordered list item prefix -func (p *Markdown) oliPrefix(data []byte) int { +func (p *parser) oliPrefix(data []byte) int { i := 0 // start with up to 3 spaces - for i < 3 && i < len(data) && data[i] == ' ' { + for i < 3 && data[i] == ' ' { i++ } // count the digits start := i - for i < len(data) && data[i] >= '0' && data[i] <= '9' { + for data[i] >= '0' && data[i] <= '9' { i++ } - if start == i || i >= len(data)-1 { - return 0 - } - // we need >= 1 digits followed by a dot and a space or a tab - if data[i] != '.' || !(data[i+1] == ' ' || data[i+1] == '\t') { + // we need >= 1 digits followed by a dot and a space + if start == i || data[i] != '.' || data[i+1] != ' ' { return 0 } return i + 2 } // returns definition list item prefix -func (p *Markdown) dliPrefix(data []byte) int { - if len(data) < 2 { - return 0 - } +func (p *parser) dliPrefix(data []byte) int { i := 0 - // need a ':' followed by a space or a tab - if data[i] != ':' || !(data[i+1] == ' ' || data[i+1] == '\t') { + + // need a : followed by a spaces + if data[i] != ':' || data[i+1] != ' ' { return 0 } - for i < len(data) && data[i] == ' ' { + for data[i] == ' ' { i++ } return i + 2 } // parse ordered or unordered list block -func (p *Markdown) list(data []byte, flags ListType) int { +func (p *parser) list(out *bytes.Buffer, data []byte, flags int) int { i := 0 - flags |= ListItemBeginningOfList - block := p.addBlock(List, nil) - block.ListFlags = flags - block.Tight = true - - for i < len(data) { - skip := p.listItem(data[i:], &flags) - if flags&ListItemContainsBlock != 0 { - block.ListData.Tight = false - } - i += skip - if skip == 0 || flags&ListItemEndOfList != 0 { - break - } - flags &= ^ListItemBeginningOfList - } - - above := block.Parent - finalizeList(block) - p.tip = above - return i -} - -// Returns true if block ends with a blank line, descending if needed -// into lists and sublists. -func endsWithBlankLine(block *Node) bool { - // TODO: figure this out. Always false now. - for block != nil { - //if block.lastLineBlank { - //return true - //} - t := block.Type - if t == List || t == Item { - block = block.LastChild - } else { - break - } - } - return false -} + flags |= LIST_ITEM_BEGINNING_OF_LIST + work := func() bool { + for i < len(data) { + skip := p.listItem(out, data[i:], &flags) + i += skip -func finalizeList(block *Node) { - block.open = false - item := block.FirstChild - for item != nil { - // check for non-final list item ending with blank line: - if endsWithBlankLine(item) && item.Next != nil { - block.ListData.Tight = false - break - } - // recurse into children of list item, to see if there are spaces - // between any of them: - subItem := item.FirstChild - for subItem != nil { - if endsWithBlankLine(subItem) && (item.Next != nil || subItem.Next != nil) { - block.ListData.Tight = false + if skip == 0 || flags&LIST_ITEM_END_OF_LIST != 0 { break } - subItem = subItem.Next + flags &= ^LIST_ITEM_BEGINNING_OF_LIST } - item = item.Next + return true } + + p.r.List(out, work, flags) + return i } // Parse a single list item. // Assumes initial prefix is already removed if this is a sublist. -func (p *Markdown) listItem(data []byte, flags *ListType) int { +func (p *parser) listItem(out *bytes.Buffer, data []byte, flags *int) int { // keep track of the indentation of the first line itemIndent := 0 - if data[0] == '\t' { - itemIndent += 4 - } else { - for itemIndent < 3 && data[itemIndent] == ' ' { - itemIndent++ - } + for itemIndent < 3 && data[itemIndent] == ' ' { + itemIndent++ } - var bulletChar byte = '*' i := p.uliPrefix(data) if i == 0 { i = p.oliPrefix(data) - } else { - bulletChar = data[i-2] } if i == 0 { i = p.dliPrefix(data) // reset definition term flag if i > 0 { - *flags &= ^ListTypeTerm + *flags &= ^LIST_TYPE_TERM } } if i == 0 { - // if in definition list, set term flag and continue - if *flags&ListTypeDefinition != 0 { - *flags |= ListTypeTerm + // if in defnition list, set term flag and continue + if *flags&LIST_TYPE_DEFINITION != 0 { + *flags |= LIST_TYPE_TERM } else { return 0 } } // skip leading whitespace on first line - for i < len(data) && data[i] == ' ' { + for data[i] == ' ' { i++ } // find the end of the line line := i - for i > 0 && i < len(data) && data[i-1] != '\n' { + for i > 0 && data[i-1] != '\n' { i++ } @@ -1246,13 +1143,14 @@ func (p *Markdown) listItem(data []byte, flags *ListType) int { // process the following lines containsBlankLine := false sublist := 0 + codeBlockMarker := "" gatherlines: for line < len(data) { i++ // find the end of this line - for i < len(data) && data[i-1] != '\n' { + for data[i-1] != '\n' { i++ } @@ -1260,24 +1158,40 @@ gatherlines: // and move on to the next line if p.isEmpty(data[line:i]) > 0 { containsBlankLine = true + raw.Write(data[line:i]) line = i continue } // calculate the indentation indent := 0 - indentIndex := 0 - if data[line] == '\t' { - indentIndex++ - indent += 4 - } else { - for indent < 4 && line+indent < i && data[line+indent] == ' ' { - indent++ - indentIndex++ - } + for indent < 4 && line+indent < i && data[line+indent] == ' ' { + indent++ } - chunk := data[line+indentIndex : i] + chunk := data[line+indent : i] + + if p.flags&EXTENSION_FENCED_CODE != 0 { + // determine if in or out of codeblock + // if in codeblock, ignore normal list processing + _, marker := isFenceLine(chunk, nil, codeBlockMarker, false) + if marker != "" { + if codeBlockMarker == "" { + // start of codeblock + codeBlockMarker = marker + } else { + // end of codeblock. + *flags |= LIST_ITEM_CONTAINS_BLOCK + codeBlockMarker = "" + } + } + // we are in a codeblock, write line, and continue + if codeBlockMarker != "" || marker != "" { + raw.Write(data[line+indent : i]) + line = i + continue gatherlines + } + } // evaluate how this line fits in switch { @@ -1287,7 +1201,15 @@ gatherlines: p.dliPrefix(chunk) > 0: if containsBlankLine { - *flags |= ListItemContainsBlock + // end the list if the type changed after a blank line + if indent <= itemIndent && + ((*flags&LIST_TYPE_ORDERED != 0 && p.uliPrefix(chunk) > 0) || + (*flags&LIST_TYPE_ORDERED == 0 && p.oliPrefix(chunk) > 0)) { + + *flags |= LIST_ITEM_END_OF_LIST + break gatherlines + } + *flags |= LIST_ITEM_CONTAINS_BLOCK } // to be a nested list, it must be indented more @@ -1301,89 +1223,93 @@ gatherlines: sublist = raw.Len() } - // is this a nested prefix heading? - case p.isPrefixHeading(chunk): - // if the heading is not indented, it is not nested in the list + // is this a nested prefix header? + case p.isPrefixHeader(chunk): + // if the header is not indented, it is not nested in the list // and thus ends the list if containsBlankLine && indent < 4 { - *flags |= ListItemEndOfList + *flags |= LIST_ITEM_END_OF_LIST break gatherlines } - *flags |= ListItemContainsBlock + *flags |= LIST_ITEM_CONTAINS_BLOCK // anything following an empty line is only part // of this item if it is indented 4 spaces // (regardless of the indentation of the beginning of the item) case containsBlankLine && indent < 4: - if *flags&ListTypeDefinition != 0 && i < len(data)-1 { + if *flags&LIST_TYPE_DEFINITION != 0 && i < len(data)-1 { // is the next item still a part of this list? next := i - for next < len(data) && data[next] != '\n' { + for data[next] != '\n' { next++ } for next < len(data)-1 && data[next] == '\n' { next++ } if i < len(data)-1 && data[i] != ':' && data[next] != ':' { - *flags |= ListItemEndOfList + *flags |= LIST_ITEM_END_OF_LIST } } else { - *flags |= ListItemEndOfList + *flags |= LIST_ITEM_END_OF_LIST } break gatherlines // a blank line means this should be parsed as a block case containsBlankLine: - raw.WriteByte('\n') - *flags |= ListItemContainsBlock + *flags |= LIST_ITEM_CONTAINS_BLOCK } - // if this line was preceded by one or more blanks, - // re-introduce the blank into the buffer - if containsBlankLine { - containsBlankLine = false - raw.WriteByte('\n') - } + containsBlankLine = false // add the line into the working buffer without prefix - raw.Write(data[line+indentIndex : i]) + raw.Write(data[line+indent : i]) line = i } - rawBytes := raw.Bytes() + // If reached end of data, the Renderer.ListItem call we're going to make below + // is definitely the last in the list. + if line >= len(data) { + *flags |= LIST_ITEM_END_OF_LIST + } - block := p.addBlock(Item, nil) - block.ListFlags = *flags - block.Tight = false - block.BulletChar = bulletChar - block.Delimiter = '.' // Only '.' is possible in Markdown, but ')' will also be possible in CommonMark + rawBytes := raw.Bytes() // render the contents of the list item - if *flags&ListItemContainsBlock != 0 && *flags&ListTypeTerm == 0 { + var cooked bytes.Buffer + if *flags&LIST_ITEM_CONTAINS_BLOCK != 0 && *flags&LIST_TYPE_TERM == 0 { // intermediate render of block item, except for definition term if sublist > 0 { - p.block(rawBytes[:sublist]) - p.block(rawBytes[sublist:]) + p.block(&cooked, rawBytes[:sublist]) + p.block(&cooked, rawBytes[sublist:]) } else { - p.block(rawBytes) + p.block(&cooked, rawBytes) } } else { // intermediate render of inline item if sublist > 0 { - child := p.addChild(Paragraph, 0) - child.content = rawBytes[:sublist] - p.block(rawBytes[sublist:]) + p.inline(&cooked, rawBytes[:sublist]) + p.block(&cooked, rawBytes[sublist:]) } else { - child := p.addChild(Paragraph, 0) - child.content = rawBytes + p.inline(&cooked, rawBytes) } } + + // render the actual list item + cookedBytes := cooked.Bytes() + parsedEnd := len(cookedBytes) + + // strip trailing newlines + for parsedEnd > 0 && cookedBytes[parsedEnd-1] == '\n' { + parsedEnd-- + } + p.r.ListItem(out, cookedBytes[:parsedEnd], *flags) + return line } // render a single paragraph that has already been parsed out -func (p *Markdown) renderParagraph(data []byte) { +func (p *parser) renderParagraph(out *bytes.Buffer, data []byte) { if len(data) == 0 { return } @@ -1394,29 +1320,27 @@ func (p *Markdown) renderParagraph(data []byte) { beg++ } - end := len(data) // trim trailing newline - if data[len(data)-1] == '\n' { - end-- - } + end := len(data) - 1 // trim trailing spaces for end > beg && data[end-1] == ' ' { end-- } - p.addBlock(Paragraph, data[beg:end]) + work := func() bool { + p.inline(out, data[beg:end]) + return true + } + p.r.Paragraph(out, work) } -func (p *Markdown) paragraph(data []byte) int { +func (p *parser) paragraph(out *bytes.Buffer, data []byte) int { // prev: index of 1st char of previous line // line: index of 1st char of current line // i: index of cursor/end of current line var prev, line, i int - tabSize := TabSizeDefault - if p.extensions&TabSizeEight != 0 { - tabSize = TabSizeDouble - } + // keep going until we find something to mark the end of the paragraph for i < len(data) { // mark the beginning of the current line @@ -1424,32 +1348,24 @@ func (p *Markdown) paragraph(data []byte) int { current := data[i:] line = i - // did we find a reference or a footnote? If so, end a paragraph - // preceding it and report that we have consumed up to the end of that - // reference: - if refEnd := isReference(p, current, tabSize); refEnd > 0 { - p.renderParagraph(data[:i]) - return i + refEnd - } - // did we find a blank line marking the end of the paragraph? if n := p.isEmpty(current); n > 0 { // did this blank line followed by a definition list item? - if p.extensions&DefinitionLists != 0 { + if p.flags&EXTENSION_DEFINITION_LISTS != 0 { if i < len(data)-1 && data[i+1] == ':' { - return p.list(data[prev:], ListTypeDefinition) + return p.list(out, data[prev:], LIST_TYPE_DEFINITION) } } - p.renderParagraph(data[:i]) + p.renderParagraph(out, data[:i]) return i + n } - // an underline under some text marks a heading, so our paragraph ended on prev line + // an underline under some text marks a header, so our paragraph ended on prev line if i > 0 { - if level := p.isUnderlinedHeading(current); level > 0 { + if level := p.isUnderlinedHeader(current); level > 0 { // render the paragraph - p.renderParagraph(data[:prev]) + p.renderParagraph(out, data[:prev]) // ignore leading and trailing whitespace eol := i - 1 @@ -1460,17 +1376,24 @@ func (p *Markdown) paragraph(data []byte) int { eol-- } + // render the header + // this ugly double closure avoids forcing variables onto the heap + work := func(o *bytes.Buffer, pp *parser, d []byte) func() bool { + return func() bool { + pp.inline(o, d) + return true + } + }(out, p, data[prev:eol]) + id := "" - if p.extensions&AutoHeadingIDs != 0 { - id = sanitized_anchor_name.Create(string(data[prev:eol])) + if p.flags&EXTENSION_AUTO_HEADER_IDS != 0 { + id = SanitizedAnchorName(string(data[prev:eol])) } - block := p.addBlock(Heading, data[prev:eol]) - block.Level = level - block.HeadingID = id + p.r.Header(out, work, level, id) // find the end of the underline - for i < len(data) && data[i] != '\n' { + for data[i] != '\n' { i++ } return i @@ -1478,72 +1401,74 @@ func (p *Markdown) paragraph(data []byte) int { } // if the next line starts a block of HTML, then the paragraph ends here - if p.extensions&LaxHTMLBlocks != 0 { - if data[i] == '<' && p.html(current, false) > 0 { + if p.flags&EXTENSION_LAX_HTML_BLOCKS != 0 { + if data[i] == '<' && p.html(out, current, false) > 0 { // rewind to before the HTML block - p.renderParagraph(data[:i]) + p.renderParagraph(out, data[:i]) return i } } - // if there's a prefixed heading or a horizontal rule after this, paragraph is over - if p.isPrefixHeading(current) || p.isHRule(current) { - p.renderParagraph(data[:i]) + // if there's a prefixed header or a horizontal rule after this, paragraph is over + if p.isPrefixHeader(current) || p.isHRule(current) { + p.renderParagraph(out, data[:i]) return i } // if there's a fenced code block, paragraph is over - if p.extensions&FencedCode != 0 { - if p.fencedCodeBlock(current, false) > 0 { - p.renderParagraph(data[:i]) + if p.flags&EXTENSION_FENCED_CODE != 0 { + if p.fencedCodeBlock(out, current, false) > 0 { + p.renderParagraph(out, data[:i]) return i } } // if there's a definition list item, prev line is a definition term - if p.extensions&DefinitionLists != 0 { + if p.flags&EXTENSION_DEFINITION_LISTS != 0 { if p.dliPrefix(current) != 0 { - ret := p.list(data[prev:], ListTypeDefinition) - return ret + return p.list(out, data[prev:], LIST_TYPE_DEFINITION) } } // if there's a list after this, paragraph is over - if p.extensions&NoEmptyLineBeforeBlock != 0 { + if p.flags&EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK != 0 { if p.uliPrefix(current) != 0 || p.oliPrefix(current) != 0 || p.quotePrefix(current) != 0 || p.codePrefix(current) != 0 { - p.renderParagraph(data[:i]) + p.renderParagraph(out, data[:i]) return i } } // otherwise, scan to the beginning of the next line - nl := bytes.IndexByte(data[i:], '\n') - if nl >= 0 { - i += nl + 1 - } else { - i += len(data[i:]) + for data[i] != '\n' { + i++ } - } - - p.renderParagraph(data[:i]) - return i -} - -func skipChar(data []byte, start int, char byte) int { - i := start - for i < len(data) && data[i] == char { i++ } + + p.renderParagraph(out, data[:i]) return i } -func skipUntilChar(text []byte, start int, char byte) int { - i := start - for i < len(text) && text[i] != char { - i++ +// SanitizedAnchorName returns a sanitized anchor name for the given text. +// +// It implements the algorithm specified in the package comment. +func SanitizedAnchorName(text string) string { + var anchorName []rune + futureDash := false + for _, r := range text { + switch { + case unicode.IsLetter(r) || unicode.IsNumber(r): + if futureDash && len(anchorName) > 0 { + anchorName = append(anchorName, '-') + } + futureDash = false + anchorName = append(anchorName, unicode.ToLower(r)) + default: + futureDash = true + } } - return i + return string(anchorName) } diff --git a/vendor/github.com/russross/blackfriday/doc.go b/vendor/github.com/russross/blackfriday/doc.go index 5b3fa98..9656c42 100644 --- a/vendor/github.com/russross/blackfriday/doc.go +++ b/vendor/github.com/russross/blackfriday/doc.go @@ -1,18 +1,32 @@ -// Package blackfriday is a markdown processor. +// Package blackfriday is a Markdown processor. // -// It translates plain text with simple formatting rules into an AST, which can -// then be further processed to HTML (provided by Blackfriday itself) or other -// formats (provided by the community). +// It translates plain text with simple formatting rules into HTML or LaTeX. // -// The simplest way to invoke Blackfriday is to call the Run function. It will -// take a text input and produce a text output in HTML (or other format). +// Sanitized Anchor Names // -// A slightly more sophisticated way to use Blackfriday is to create a Markdown -// processor and to call Parse, which returns a syntax tree for the input -// document. You can leverage Blackfriday's parsing for content extraction from -// markdown documents. You can assign a custom renderer and set various options -// to the Markdown processor. +// Blackfriday includes an algorithm for creating sanitized anchor names +// corresponding to a given input text. This algorithm is used to create +// anchors for headings when EXTENSION_AUTO_HEADER_IDS is enabled. The +// algorithm is specified below, so that other packages can create +// compatible anchor names and links to those anchors. // -// If you're interested in calling Blackfriday from command line, see -// https://github.com/russross/blackfriday-tool. +// The algorithm iterates over the input text, interpreted as UTF-8, +// one Unicode code point (rune) at a time. All runes that are letters (category L) +// or numbers (category N) are considered valid characters. They are mapped to +// lower case, and included in the output. All other runes are considered +// invalid characters. Invalid characters that preceed the first valid character, +// as well as invalid character that follow the last valid character +// are dropped completely. All other sequences of invalid characters +// between two valid characters are replaced with a single dash character '-'. +// +// SanitizedAnchorName exposes this functionality, and can be used to +// create compatible links to the anchor names generated by blackfriday. +// This algorithm is also implemented in a small standalone package at +// github.com/shurcooL/sanitized_anchor_name. It can be useful for clients +// that want a small package and don't need full functionality of blackfriday. package blackfriday + +// NOTE: Keep Sanitized Anchor Name algorithm in sync with package +// github.com/shurcooL/sanitized_anchor_name. +// Otherwise, users of sanitized_anchor_name will get anchor names +// that are incompatible with those generated by blackfriday. diff --git a/vendor/github.com/russross/blackfriday/esc.go b/vendor/github.com/russross/blackfriday/esc.go deleted file mode 100644 index 6385f27..0000000 --- a/vendor/github.com/russross/blackfriday/esc.go +++ /dev/null @@ -1,34 +0,0 @@ -package blackfriday - -import ( - "html" - "io" -) - -var htmlEscaper = [256][]byte{ - '&': []byte("&"), - '<': []byte("<"), - '>': []byte(">"), - '"': []byte("""), -} - -func escapeHTML(w io.Writer, s []byte) { - var start, end int - for end < len(s) { - escSeq := htmlEscaper[s[end]] - if escSeq != nil { - w.Write(s[start:end]) - w.Write(escSeq) - start = end + 1 - } - end++ - } - if start < len(s) && end <= len(s) { - w.Write(s[start:end]) - } -} - -func escLink(w io.Writer, text []byte) { - unesc := html.UnescapeString(string(text)) - escapeHTML(w, []byte(unesc)) -} diff --git a/vendor/github.com/russross/blackfriday/html.go b/vendor/github.com/russross/blackfriday/html.go index 25fb185..e0a6c69 100644 --- a/vendor/github.com/russross/blackfriday/html.go +++ b/vendor/github.com/russross/blackfriday/html.go @@ -18,62 +18,46 @@ package blackfriday import ( "bytes" "fmt" - "io" "regexp" + "strconv" "strings" ) -// HTMLFlags control optional behavior of HTML renderer. -type HTMLFlags int - -// HTML renderer configuration options. +// Html renderer configuration options. const ( - HTMLFlagsNone HTMLFlags = 0 - SkipHTML HTMLFlags = 1 << iota // Skip preformatted HTML blocks - SkipImages // Skip embedded images - SkipLinks // Skip all links - Safelink // Only link to trusted protocols - NofollowLinks // Only link with rel="nofollow" - NoreferrerLinks // Only link with rel="noreferrer" - HrefTargetBlank // Add a blank target - CompletePage // Generate a complete HTML page - UseXHTML // Generate XHTML output instead of HTML - FootnoteReturnLinks // Generate a link at the end of a footnote to return to the source - Smartypants // Enable smart punctuation substitutions - SmartypantsFractions // Enable smart fractions (with Smartypants) - SmartypantsDashes // Enable smart dashes (with Smartypants) - SmartypantsLatexDashes // Enable LaTeX-style dashes (with Smartypants) - SmartypantsAngledQuotes // Enable angled double quotes (with Smartypants) for double quotes rendering - SmartypantsQuotesNBSP // Enable « French guillemets » (with Smartypants) - TOC // Generate a table of contents + HTML_SKIP_HTML = 1 << iota // skip preformatted HTML blocks + HTML_SKIP_STYLE // skip embedded