planetscale 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/workflows/ci.yml +24 -0
- data/.github/workflows/gem-push.yml +38 -0
- data/.github/workflows/licensed.yml +43 -0
- data/.gitignore +10 -0
- data/.licensed.yml +9 -0
- data/.licenses/go/github.com/armon/circbuf.dep.yml +31 -0
- data/.licenses/go/github.com/gorilla/mux.dep.yml +41 -0
- data/.licenses/go/github.com/hashicorp/go-cleanhttp.dep.yml +375 -0
- data/.licenses/go/github.com/mitchellh/go-homedir.dep.yml +32 -0
- data/.licenses/go/github.com/pkg/errors.dep.yml +36 -0
- data/.licenses/go/github.com/planetscale/planetscale-go/planetscale.dep.yml +160 -0
- data/.licenses/go/github.com/planetscale/sql-proxy/proxy.dep.yml +180 -0
- data/.licenses/go/go.uber.org/atomic.dep.yml +31 -0
- data/.licenses/go/go.uber.org/multierr.dep.yml +30 -0
- data/.licenses/go/go.uber.org/zap.dep.yml +30 -0
- data/.licenses/go/go.uber.org/zap/buffer.dep.yml +30 -0
- data/.licenses/go/go.uber.org/zap/internal/bufferpool.dep.yml +30 -0
- data/.licenses/go/go.uber.org/zap/internal/color.dep.yml +30 -0
- data/.licenses/go/go.uber.org/zap/internal/exit.dep.yml +31 -0
- data/.licenses/go/go.uber.org/zap/zapcore.dep.yml +31 -0
- data/.licenses/go/golang.org/x/net/context/ctxhttp.dep.yml +63 -0
- data/.licenses/go/golang.org/x/oauth2.dep.yml +44 -0
- data/.licenses/go/golang.org/x/oauth2/internal.dep.yml +38 -0
- data/.ruby_version +1 -0
- data/Gemfile +8 -0
- data/LICENSE +201 -0
- data/README.md +88 -0
- data/Rakefile +10 -0
- data/bin/console +15 -0
- data/bin/setup +17 -0
- data/controller.go +255 -0
- data/go.mod +16 -0
- data/go.sum +428 -0
- data/lib/generators/planetscale/install_generator.rb +58 -0
- data/lib/planetscale.rb +137 -0
- data/lib/planetscale/version.rb +5 -0
- data/planetscale.gemspec +44 -0
- data/proxy.go +128 -0
- data/vendor/github.com/armon/circbuf/.gitignore +22 -0
- data/vendor/github.com/armon/circbuf/LICENSE +20 -0
- data/vendor/github.com/armon/circbuf/README.md +28 -0
- data/vendor/github.com/armon/circbuf/circbuf.go +92 -0
- data/vendor/github.com/armon/circbuf/go.mod +1 -0
- data/vendor/github.com/golang/protobuf/AUTHORS +3 -0
- data/vendor/github.com/golang/protobuf/CONTRIBUTORS +3 -0
- data/vendor/github.com/golang/protobuf/LICENSE +28 -0
- data/vendor/github.com/golang/protobuf/proto/buffer.go +324 -0
- data/vendor/github.com/golang/protobuf/proto/defaults.go +63 -0
- data/vendor/github.com/golang/protobuf/proto/deprecated.go +113 -0
- data/vendor/github.com/golang/protobuf/proto/discard.go +58 -0
- data/vendor/github.com/golang/protobuf/proto/extensions.go +356 -0
- data/vendor/github.com/golang/protobuf/proto/properties.go +306 -0
- data/vendor/github.com/golang/protobuf/proto/proto.go +167 -0
- data/vendor/github.com/golang/protobuf/proto/registry.go +317 -0
- data/vendor/github.com/golang/protobuf/proto/text_decode.go +801 -0
- data/vendor/github.com/golang/protobuf/proto/text_encode.go +560 -0
- data/vendor/github.com/golang/protobuf/proto/wire.go +78 -0
- data/vendor/github.com/golang/protobuf/proto/wrappers.go +34 -0
- data/vendor/github.com/gorilla/mux/AUTHORS +8 -0
- data/vendor/github.com/gorilla/mux/LICENSE +27 -0
- data/vendor/github.com/gorilla/mux/README.md +805 -0
- data/vendor/github.com/gorilla/mux/doc.go +306 -0
- data/vendor/github.com/gorilla/mux/go.mod +3 -0
- data/vendor/github.com/gorilla/mux/middleware.go +74 -0
- data/vendor/github.com/gorilla/mux/mux.go +606 -0
- data/vendor/github.com/gorilla/mux/regexp.go +388 -0
- data/vendor/github.com/gorilla/mux/route.go +736 -0
- data/vendor/github.com/gorilla/mux/test_helpers.go +19 -0
- data/vendor/github.com/hashicorp/go-cleanhttp/LICENSE +363 -0
- data/vendor/github.com/hashicorp/go-cleanhttp/README.md +30 -0
- data/vendor/github.com/hashicorp/go-cleanhttp/cleanhttp.go +58 -0
- data/vendor/github.com/hashicorp/go-cleanhttp/doc.go +20 -0
- data/vendor/github.com/hashicorp/go-cleanhttp/go.mod +3 -0
- data/vendor/github.com/hashicorp/go-cleanhttp/handlers.go +48 -0
- data/vendor/github.com/mitchellh/go-homedir/LICENSE +21 -0
- data/vendor/github.com/mitchellh/go-homedir/README.md +14 -0
- data/vendor/github.com/mitchellh/go-homedir/go.mod +1 -0
- data/vendor/github.com/mitchellh/go-homedir/homedir.go +167 -0
- data/vendor/github.com/pkg/errors/.gitignore +24 -0
- data/vendor/github.com/pkg/errors/.travis.yml +10 -0
- data/vendor/github.com/pkg/errors/LICENSE +23 -0
- data/vendor/github.com/pkg/errors/Makefile +44 -0
- data/vendor/github.com/pkg/errors/README.md +59 -0
- data/vendor/github.com/pkg/errors/appveyor.yml +32 -0
- data/vendor/github.com/pkg/errors/errors.go +288 -0
- data/vendor/github.com/pkg/errors/go113.go +38 -0
- data/vendor/github.com/pkg/errors/stack.go +177 -0
- data/vendor/github.com/planetscale/planetscale-go/planetscale/backups.go +139 -0
- data/vendor/github.com/planetscale/planetscale-go/planetscale/branches.go +258 -0
- data/vendor/github.com/planetscale/planetscale-go/planetscale/certs.go +142 -0
- data/vendor/github.com/planetscale/planetscale-go/planetscale/client.go +305 -0
- data/vendor/github.com/planetscale/planetscale-go/planetscale/databases.go +131 -0
- data/vendor/github.com/planetscale/planetscale-go/planetscale/deploy_requests.go +368 -0
- data/vendor/github.com/planetscale/planetscale-go/planetscale/organizations.go +78 -0
- data/vendor/github.com/planetscale/planetscale-go/planetscale/service_tokens.go +163 -0
- data/vendor/github.com/planetscale/sql-proxy/proxy/client.go +467 -0
- data/vendor/github.com/planetscale/sql-proxy/proxy/tls_cache.go +73 -0
- data/vendor/go.uber.org/atomic/.codecov.yml +19 -0
- data/vendor/go.uber.org/atomic/.gitignore +12 -0
- data/vendor/go.uber.org/atomic/.travis.yml +27 -0
- data/vendor/go.uber.org/atomic/CHANGELOG.md +76 -0
- data/vendor/go.uber.org/atomic/LICENSE.txt +19 -0
- data/vendor/go.uber.org/atomic/Makefile +78 -0
- data/vendor/go.uber.org/atomic/README.md +63 -0
- data/vendor/go.uber.org/atomic/bool.go +81 -0
- data/vendor/go.uber.org/atomic/bool_ext.go +53 -0
- data/vendor/go.uber.org/atomic/doc.go +23 -0
- data/vendor/go.uber.org/atomic/duration.go +82 -0
- data/vendor/go.uber.org/atomic/duration_ext.go +40 -0
- data/vendor/go.uber.org/atomic/error.go +51 -0
- data/vendor/go.uber.org/atomic/error_ext.go +39 -0
- data/vendor/go.uber.org/atomic/float64.go +76 -0
- data/vendor/go.uber.org/atomic/float64_ext.go +47 -0
- data/vendor/go.uber.org/atomic/gen.go +26 -0
- data/vendor/go.uber.org/atomic/go.mod +8 -0
- data/vendor/go.uber.org/atomic/go.sum +9 -0
- data/vendor/go.uber.org/atomic/int32.go +102 -0
- data/vendor/go.uber.org/atomic/int64.go +102 -0
- data/vendor/go.uber.org/atomic/nocmp.go +35 -0
- data/vendor/go.uber.org/atomic/string.go +54 -0
- data/vendor/go.uber.org/atomic/string_ext.go +43 -0
- data/vendor/go.uber.org/atomic/uint32.go +102 -0
- data/vendor/go.uber.org/atomic/uint64.go +102 -0
- data/vendor/go.uber.org/atomic/value.go +31 -0
- data/vendor/go.uber.org/multierr/.codecov.yml +15 -0
- data/vendor/go.uber.org/multierr/.gitignore +4 -0
- data/vendor/go.uber.org/multierr/.travis.yml +23 -0
- data/vendor/go.uber.org/multierr/CHANGELOG.md +60 -0
- data/vendor/go.uber.org/multierr/LICENSE.txt +19 -0
- data/vendor/go.uber.org/multierr/Makefile +42 -0
- data/vendor/go.uber.org/multierr/README.md +23 -0
- data/vendor/go.uber.org/multierr/error.go +449 -0
- data/vendor/go.uber.org/multierr/glide.yaml +8 -0
- data/vendor/go.uber.org/multierr/go.mod +8 -0
- data/vendor/go.uber.org/multierr/go.sum +11 -0
- data/vendor/go.uber.org/multierr/go113.go +52 -0
- data/vendor/go.uber.org/zap/.codecov.yml +17 -0
- data/vendor/go.uber.org/zap/.gitignore +32 -0
- data/vendor/go.uber.org/zap/.readme.tmpl +109 -0
- data/vendor/go.uber.org/zap/.travis.yml +23 -0
- data/vendor/go.uber.org/zap/CHANGELOG.md +432 -0
- data/vendor/go.uber.org/zap/CODE_OF_CONDUCT.md +75 -0
- data/vendor/go.uber.org/zap/CONTRIBUTING.md +81 -0
- data/vendor/go.uber.org/zap/FAQ.md +156 -0
- data/vendor/go.uber.org/zap/LICENSE.txt +19 -0
- data/vendor/go.uber.org/zap/Makefile +63 -0
- data/vendor/go.uber.org/zap/README.md +134 -0
- data/vendor/go.uber.org/zap/array.go +320 -0
- data/vendor/go.uber.org/zap/buffer/buffer.go +123 -0
- data/vendor/go.uber.org/zap/buffer/pool.go +49 -0
- data/vendor/go.uber.org/zap/checklicense.sh +17 -0
- data/vendor/go.uber.org/zap/config.go +264 -0
- data/vendor/go.uber.org/zap/doc.go +113 -0
- data/vendor/go.uber.org/zap/encoder.go +79 -0
- data/vendor/go.uber.org/zap/error.go +80 -0
- data/vendor/go.uber.org/zap/field.go +539 -0
- data/vendor/go.uber.org/zap/flag.go +39 -0
- data/vendor/go.uber.org/zap/glide.yaml +34 -0
- data/vendor/go.uber.org/zap/global.go +168 -0
- data/vendor/go.uber.org/zap/global_go112.go +26 -0
- data/vendor/go.uber.org/zap/global_prego112.go +26 -0
- data/vendor/go.uber.org/zap/go.mod +13 -0
- data/vendor/go.uber.org/zap/go.sum +56 -0
- data/vendor/go.uber.org/zap/http_handler.go +81 -0
- data/vendor/go.uber.org/zap/internal/bufferpool/bufferpool.go +31 -0
- data/vendor/go.uber.org/zap/internal/color/color.go +44 -0
- data/vendor/go.uber.org/zap/internal/exit/exit.go +64 -0
- data/vendor/go.uber.org/zap/level.go +132 -0
- data/vendor/go.uber.org/zap/logger.go +344 -0
- data/vendor/go.uber.org/zap/options.go +140 -0
- data/vendor/go.uber.org/zap/sink.go +161 -0
- data/vendor/go.uber.org/zap/stacktrace.go +85 -0
- data/vendor/go.uber.org/zap/sugar.go +304 -0
- data/vendor/go.uber.org/zap/time.go +27 -0
- data/vendor/go.uber.org/zap/writer.go +99 -0
- data/vendor/go.uber.org/zap/zapcore/console_encoder.go +161 -0
- data/vendor/go.uber.org/zap/zapcore/core.go +113 -0
- data/vendor/go.uber.org/zap/zapcore/doc.go +24 -0
- data/vendor/go.uber.org/zap/zapcore/encoder.go +443 -0
- data/vendor/go.uber.org/zap/zapcore/entry.go +264 -0
- data/vendor/go.uber.org/zap/zapcore/error.go +115 -0
- data/vendor/go.uber.org/zap/zapcore/field.go +227 -0
- data/vendor/go.uber.org/zap/zapcore/hook.go +68 -0
- data/vendor/go.uber.org/zap/zapcore/increase_level.go +66 -0
- data/vendor/go.uber.org/zap/zapcore/json_encoder.go +534 -0
- data/vendor/go.uber.org/zap/zapcore/level.go +175 -0
- data/vendor/go.uber.org/zap/zapcore/level_strings.go +46 -0
- data/vendor/go.uber.org/zap/zapcore/marshaler.go +61 -0
- data/vendor/go.uber.org/zap/zapcore/memory_encoder.go +179 -0
- data/vendor/go.uber.org/zap/zapcore/sampler.go +208 -0
- data/vendor/go.uber.org/zap/zapcore/tee.go +81 -0
- data/vendor/go.uber.org/zap/zapcore/write_syncer.go +123 -0
- data/vendor/golang.org/x/net/AUTHORS +3 -0
- data/vendor/golang.org/x/net/CONTRIBUTORS +3 -0
- data/vendor/golang.org/x/net/LICENSE +27 -0
- data/vendor/golang.org/x/net/PATENTS +22 -0
- data/vendor/golang.org/x/net/context/context.go +56 -0
- data/vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go +71 -0
- data/vendor/golang.org/x/net/context/go17.go +73 -0
- data/vendor/golang.org/x/net/context/go19.go +21 -0
- data/vendor/golang.org/x/net/context/pre_go17.go +301 -0
- data/vendor/golang.org/x/net/context/pre_go19.go +110 -0
- data/vendor/golang.org/x/oauth2/.travis.yml +13 -0
- data/vendor/golang.org/x/oauth2/AUTHORS +3 -0
- data/vendor/golang.org/x/oauth2/CONTRIBUTING.md +26 -0
- data/vendor/golang.org/x/oauth2/CONTRIBUTORS +3 -0
- data/vendor/golang.org/x/oauth2/LICENSE +27 -0
- data/vendor/golang.org/x/oauth2/README.md +36 -0
- data/vendor/golang.org/x/oauth2/go.mod +9 -0
- data/vendor/golang.org/x/oauth2/go.sum +361 -0
- data/vendor/golang.org/x/oauth2/internal/client_appengine.go +14 -0
- data/vendor/golang.org/x/oauth2/internal/doc.go +6 -0
- data/vendor/golang.org/x/oauth2/internal/oauth2.go +37 -0
- data/vendor/golang.org/x/oauth2/internal/token.go +294 -0
- data/vendor/golang.org/x/oauth2/internal/transport.go +33 -0
- data/vendor/golang.org/x/oauth2/oauth2.go +381 -0
- data/vendor/golang.org/x/oauth2/token.go +178 -0
- data/vendor/golang.org/x/oauth2/transport.go +89 -0
- data/vendor/google.golang.org/appengine/LICENSE +202 -0
- data/vendor/google.golang.org/appengine/internal/api.go +678 -0
- data/vendor/google.golang.org/appengine/internal/api_classic.go +169 -0
- data/vendor/google.golang.org/appengine/internal/api_common.go +123 -0
- data/vendor/google.golang.org/appengine/internal/app_id.go +28 -0
- data/vendor/google.golang.org/appengine/internal/base/api_base.pb.go +308 -0
- data/vendor/google.golang.org/appengine/internal/base/api_base.proto +33 -0
- data/vendor/google.golang.org/appengine/internal/datastore/datastore_v3.pb.go +4367 -0
- data/vendor/google.golang.org/appengine/internal/datastore/datastore_v3.proto +551 -0
- data/vendor/google.golang.org/appengine/internal/identity.go +55 -0
- data/vendor/google.golang.org/appengine/internal/identity_classic.go +61 -0
- data/vendor/google.golang.org/appengine/internal/identity_flex.go +11 -0
- data/vendor/google.golang.org/appengine/internal/identity_vm.go +134 -0
- data/vendor/google.golang.org/appengine/internal/internal.go +110 -0
- data/vendor/google.golang.org/appengine/internal/log/log_service.pb.go +1313 -0
- data/vendor/google.golang.org/appengine/internal/log/log_service.proto +150 -0
- data/vendor/google.golang.org/appengine/internal/main.go +16 -0
- data/vendor/google.golang.org/appengine/internal/main_common.go +7 -0
- data/vendor/google.golang.org/appengine/internal/main_vm.go +69 -0
- data/vendor/google.golang.org/appengine/internal/metadata.go +60 -0
- data/vendor/google.golang.org/appengine/internal/net.go +56 -0
- data/vendor/google.golang.org/appengine/internal/regen.sh +40 -0
- data/vendor/google.golang.org/appengine/internal/remote_api/remote_api.pb.go +361 -0
- data/vendor/google.golang.org/appengine/internal/remote_api/remote_api.proto +44 -0
- data/vendor/google.golang.org/appengine/internal/transaction.go +115 -0
- data/vendor/google.golang.org/appengine/internal/urlfetch/urlfetch_service.pb.go +527 -0
- data/vendor/google.golang.org/appengine/internal/urlfetch/urlfetch_service.proto +64 -0
- data/vendor/google.golang.org/appengine/urlfetch/urlfetch.go +210 -0
- data/vendor/google.golang.org/protobuf/AUTHORS +3 -0
- data/vendor/google.golang.org/protobuf/CONTRIBUTORS +3 -0
- data/vendor/google.golang.org/protobuf/LICENSE +27 -0
- data/vendor/google.golang.org/protobuf/PATENTS +22 -0
- data/vendor/google.golang.org/protobuf/encoding/prototext/decode.go +773 -0
- data/vendor/google.golang.org/protobuf/encoding/prototext/doc.go +7 -0
- data/vendor/google.golang.org/protobuf/encoding/prototext/encode.go +371 -0
- data/vendor/google.golang.org/protobuf/encoding/protowire/wire.go +538 -0
- data/vendor/google.golang.org/protobuf/internal/descfmt/stringer.go +318 -0
- data/vendor/google.golang.org/protobuf/internal/descopts/options.go +29 -0
- data/vendor/google.golang.org/protobuf/internal/detrand/rand.go +69 -0
- data/vendor/google.golang.org/protobuf/internal/encoding/defval/default.go +213 -0
- data/vendor/google.golang.org/protobuf/internal/encoding/messageset/messageset.go +241 -0
- data/vendor/google.golang.org/protobuf/internal/encoding/tag/tag.go +207 -0
- data/vendor/google.golang.org/protobuf/internal/encoding/text/decode.go +665 -0
- data/vendor/google.golang.org/protobuf/internal/encoding/text/decode_number.go +190 -0
- data/vendor/google.golang.org/protobuf/internal/encoding/text/decode_string.go +161 -0
- data/vendor/google.golang.org/protobuf/internal/encoding/text/decode_token.go +373 -0
- data/vendor/google.golang.org/protobuf/internal/encoding/text/doc.go +29 -0
- data/vendor/google.golang.org/protobuf/internal/encoding/text/encode.go +265 -0
- data/vendor/google.golang.org/protobuf/internal/errors/errors.go +89 -0
- data/vendor/google.golang.org/protobuf/internal/errors/is_go112.go +39 -0
- data/vendor/google.golang.org/protobuf/internal/errors/is_go113.go +12 -0
- data/vendor/google.golang.org/protobuf/internal/filedesc/build.go +158 -0
- data/vendor/google.golang.org/protobuf/internal/filedesc/desc.go +631 -0
- data/vendor/google.golang.org/protobuf/internal/filedesc/desc_init.go +471 -0
- data/vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go +704 -0
- data/vendor/google.golang.org/protobuf/internal/filedesc/desc_list.go +450 -0
- data/vendor/google.golang.org/protobuf/internal/filedesc/desc_list_gen.go +356 -0
- data/vendor/google.golang.org/protobuf/internal/filedesc/placeholder.go +107 -0
- data/vendor/google.golang.org/protobuf/internal/filetype/build.go +297 -0
- data/vendor/google.golang.org/protobuf/internal/flags/flags.go +24 -0
- data/vendor/google.golang.org/protobuf/internal/flags/proto_legacy_disable.go +9 -0
- data/vendor/google.golang.org/protobuf/internal/flags/proto_legacy_enable.go +9 -0
- data/vendor/google.golang.org/protobuf/internal/genid/any_gen.go +34 -0
- data/vendor/google.golang.org/protobuf/internal/genid/api_gen.go +106 -0
- data/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go +829 -0
- data/vendor/google.golang.org/protobuf/internal/genid/doc.go +11 -0
- data/vendor/google.golang.org/protobuf/internal/genid/duration_gen.go +34 -0
- data/vendor/google.golang.org/protobuf/internal/genid/empty_gen.go +19 -0
- data/vendor/google.golang.org/protobuf/internal/genid/field_mask_gen.go +31 -0
- data/vendor/google.golang.org/protobuf/internal/genid/goname.go +25 -0
- data/vendor/google.golang.org/protobuf/internal/genid/map_entry.go +16 -0
- data/vendor/google.golang.org/protobuf/internal/genid/source_context_gen.go +31 -0
- data/vendor/google.golang.org/protobuf/internal/genid/struct_gen.go +116 -0
- data/vendor/google.golang.org/protobuf/internal/genid/timestamp_gen.go +34 -0
- data/vendor/google.golang.org/protobuf/internal/genid/type_gen.go +184 -0
- data/vendor/google.golang.org/protobuf/internal/genid/wrappers.go +13 -0
- data/vendor/google.golang.org/protobuf/internal/genid/wrappers_gen.go +175 -0
- data/vendor/google.golang.org/protobuf/internal/impl/api_export.go +177 -0
- data/vendor/google.golang.org/protobuf/internal/impl/checkinit.go +141 -0
- data/vendor/google.golang.org/protobuf/internal/impl/codec_extension.go +223 -0
- data/vendor/google.golang.org/protobuf/internal/impl/codec_field.go +830 -0
- data/vendor/google.golang.org/protobuf/internal/impl/codec_gen.go +5637 -0
- data/vendor/google.golang.org/protobuf/internal/impl/codec_map.go +388 -0
- data/vendor/google.golang.org/protobuf/internal/impl/codec_map_go111.go +37 -0
- data/vendor/google.golang.org/protobuf/internal/impl/codec_map_go112.go +11 -0
- data/vendor/google.golang.org/protobuf/internal/impl/codec_message.go +217 -0
- data/vendor/google.golang.org/protobuf/internal/impl/codec_messageset.go +123 -0
- data/vendor/google.golang.org/protobuf/internal/impl/codec_reflect.go +209 -0
- data/vendor/google.golang.org/protobuf/internal/impl/codec_tables.go +557 -0
- data/vendor/google.golang.org/protobuf/internal/impl/codec_unsafe.go +17 -0
- data/vendor/google.golang.org/protobuf/internal/impl/convert.go +496 -0
- data/vendor/google.golang.org/protobuf/internal/impl/convert_list.go +141 -0
- data/vendor/google.golang.org/protobuf/internal/impl/convert_map.go +121 -0
- data/vendor/google.golang.org/protobuf/internal/impl/decode.go +276 -0
- data/vendor/google.golang.org/protobuf/internal/impl/encode.go +201 -0
- data/vendor/google.golang.org/protobuf/internal/impl/enum.go +21 -0
- data/vendor/google.golang.org/protobuf/internal/impl/extension.go +156 -0
- data/vendor/google.golang.org/protobuf/internal/impl/legacy_enum.go +219 -0
- data/vendor/google.golang.org/protobuf/internal/impl/legacy_export.go +92 -0
- data/vendor/google.golang.org/protobuf/internal/impl/legacy_extension.go +176 -0
- data/vendor/google.golang.org/protobuf/internal/impl/legacy_file.go +81 -0
- data/vendor/google.golang.org/protobuf/internal/impl/legacy_message.go +558 -0
- data/vendor/google.golang.org/protobuf/internal/impl/merge.go +176 -0
- data/vendor/google.golang.org/protobuf/internal/impl/merge_gen.go +209 -0
- data/vendor/google.golang.org/protobuf/internal/impl/message.go +276 -0
- data/vendor/google.golang.org/protobuf/internal/impl/message_reflect.go +465 -0
- data/vendor/google.golang.org/protobuf/internal/impl/message_reflect_field.go +543 -0
- data/vendor/google.golang.org/protobuf/internal/impl/message_reflect_gen.go +249 -0
- data/vendor/google.golang.org/protobuf/internal/impl/pointer_reflect.go +178 -0
- data/vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go +174 -0
- data/vendor/google.golang.org/protobuf/internal/impl/validate.go +576 -0
- data/vendor/google.golang.org/protobuf/internal/impl/weak.go +74 -0
- data/vendor/google.golang.org/protobuf/internal/order/order.go +89 -0
- data/vendor/google.golang.org/protobuf/internal/order/range.go +115 -0
- data/vendor/google.golang.org/protobuf/internal/pragma/pragma.go +29 -0
- data/vendor/google.golang.org/protobuf/internal/set/ints.go +58 -0
- data/vendor/google.golang.org/protobuf/internal/strs/strings.go +196 -0
- data/vendor/google.golang.org/protobuf/internal/strs/strings_pure.go +27 -0
- data/vendor/google.golang.org/protobuf/internal/strs/strings_unsafe.go +94 -0
- data/vendor/google.golang.org/protobuf/internal/version/version.go +79 -0
- data/vendor/google.golang.org/protobuf/proto/checkinit.go +71 -0
- data/vendor/google.golang.org/protobuf/proto/decode.go +278 -0
- data/vendor/google.golang.org/protobuf/proto/decode_gen.go +603 -0
- data/vendor/google.golang.org/protobuf/proto/doc.go +94 -0
- data/vendor/google.golang.org/protobuf/proto/encode.go +319 -0
- data/vendor/google.golang.org/protobuf/proto/encode_gen.go +97 -0
- data/vendor/google.golang.org/protobuf/proto/equal.go +167 -0
- data/vendor/google.golang.org/protobuf/proto/extension.go +92 -0
- data/vendor/google.golang.org/protobuf/proto/merge.go +139 -0
- data/vendor/google.golang.org/protobuf/proto/messageset.go +93 -0
- data/vendor/google.golang.org/protobuf/proto/proto.go +43 -0
- data/vendor/google.golang.org/protobuf/proto/proto_methods.go +19 -0
- data/vendor/google.golang.org/protobuf/proto/proto_reflect.go +19 -0
- data/vendor/google.golang.org/protobuf/proto/reset.go +43 -0
- data/vendor/google.golang.org/protobuf/proto/size.go +97 -0
- data/vendor/google.golang.org/protobuf/proto/size_gen.go +55 -0
- data/vendor/google.golang.org/protobuf/proto/wrappers.go +29 -0
- data/vendor/google.golang.org/protobuf/reflect/protodesc/desc.go +276 -0
- data/vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go +248 -0
- data/vendor/google.golang.org/protobuf/reflect/protodesc/desc_resolve.go +286 -0
- data/vendor/google.golang.org/protobuf/reflect/protodesc/desc_validate.go +374 -0
- data/vendor/google.golang.org/protobuf/reflect/protodesc/proto.go +252 -0
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/methods.go +77 -0
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/proto.go +504 -0
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/source.go +128 -0
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go +461 -0
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/type.go +665 -0
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/value.go +285 -0
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/value_pure.go +59 -0
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/value_union.go +411 -0
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/value_unsafe.go +98 -0
- data/vendor/google.golang.org/protobuf/reflect/protoregistry/registry.go +869 -0
- data/vendor/google.golang.org/protobuf/runtime/protoiface/legacy.go +15 -0
- data/vendor/google.golang.org/protobuf/runtime/protoiface/methods.go +167 -0
- data/vendor/google.golang.org/protobuf/runtime/protoimpl/impl.go +44 -0
- data/vendor/google.golang.org/protobuf/runtime/protoimpl/version.go +56 -0
- data/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go +4039 -0
- data/vendor/modules.txt +79 -0
- metadata +495 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
package circbuf
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
// Buffer implements a circular buffer. It is a fixed size,
|
|
8
|
+
// and new writes overwrite older data, such that for a buffer
|
|
9
|
+
// of size N, for any amount of writes, only the last N bytes
|
|
10
|
+
// are retained.
|
|
11
|
+
type Buffer struct {
|
|
12
|
+
data []byte
|
|
13
|
+
size int64
|
|
14
|
+
writeCursor int64
|
|
15
|
+
written int64
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// NewBuffer creates a new buffer of a given size. The size
|
|
19
|
+
// must be greater than 0.
|
|
20
|
+
func NewBuffer(size int64) (*Buffer, error) {
|
|
21
|
+
if size <= 0 {
|
|
22
|
+
return nil, fmt.Errorf("Size must be positive")
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
b := &Buffer{
|
|
26
|
+
size: size,
|
|
27
|
+
data: make([]byte, size),
|
|
28
|
+
}
|
|
29
|
+
return b, nil
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Write writes up to len(buf) bytes to the internal ring,
|
|
33
|
+
// overriding older data if necessary.
|
|
34
|
+
func (b *Buffer) Write(buf []byte) (int, error) {
|
|
35
|
+
// Account for total bytes written
|
|
36
|
+
n := len(buf)
|
|
37
|
+
b.written += int64(n)
|
|
38
|
+
|
|
39
|
+
// If the buffer is larger than ours, then we only care
|
|
40
|
+
// about the last size bytes anyways
|
|
41
|
+
if int64(n) > b.size {
|
|
42
|
+
buf = buf[int64(n)-b.size:]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Copy in place
|
|
46
|
+
remain := b.size - b.writeCursor
|
|
47
|
+
copy(b.data[b.writeCursor:], buf)
|
|
48
|
+
if int64(len(buf)) > remain {
|
|
49
|
+
copy(b.data, buf[remain:])
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Update location of the cursor
|
|
53
|
+
b.writeCursor = ((b.writeCursor + int64(len(buf))) % b.size)
|
|
54
|
+
return n, nil
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Size returns the size of the buffer
|
|
58
|
+
func (b *Buffer) Size() int64 {
|
|
59
|
+
return b.size
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// TotalWritten provides the total number of bytes written
|
|
63
|
+
func (b *Buffer) TotalWritten() int64 {
|
|
64
|
+
return b.written
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Bytes provides a slice of the bytes written. This
|
|
68
|
+
// slice should not be written to.
|
|
69
|
+
func (b *Buffer) Bytes() []byte {
|
|
70
|
+
switch {
|
|
71
|
+
case b.written >= b.size && b.writeCursor == 0:
|
|
72
|
+
return b.data
|
|
73
|
+
case b.written > b.size:
|
|
74
|
+
out := make([]byte, b.size)
|
|
75
|
+
copy(out, b.data[b.writeCursor:])
|
|
76
|
+
copy(out[b.size-b.writeCursor:], b.data[:b.writeCursor])
|
|
77
|
+
return out
|
|
78
|
+
default:
|
|
79
|
+
return b.data[:b.writeCursor]
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Reset resets the buffer so it has no content.
|
|
84
|
+
func (b *Buffer) Reset() {
|
|
85
|
+
b.writeCursor = 0
|
|
86
|
+
b.written = 0
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// String returns the contents of the buffer as a string
|
|
90
|
+
func (b *Buffer) String() string {
|
|
91
|
+
return string(b.Bytes())
|
|
92
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module github.com/armon/circbuf
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
Copyright 2010 The Go Authors. All rights reserved.
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
|
4
|
+
modification, are permitted provided that the following conditions are
|
|
5
|
+
met:
|
|
6
|
+
|
|
7
|
+
* Redistributions of source code must retain the above copyright
|
|
8
|
+
notice, this list of conditions and the following disclaimer.
|
|
9
|
+
* Redistributions in binary form must reproduce the above
|
|
10
|
+
copyright notice, this list of conditions and the following disclaimer
|
|
11
|
+
in the documentation and/or other materials provided with the
|
|
12
|
+
distribution.
|
|
13
|
+
* Neither the name of Google Inc. nor the names of its
|
|
14
|
+
contributors may be used to endorse or promote products derived from
|
|
15
|
+
this software without specific prior written permission.
|
|
16
|
+
|
|
17
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
18
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
19
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
20
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
21
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
22
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
23
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
24
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
25
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
26
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
27
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
+
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
// Copyright 2019 The Go Authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style
|
|
3
|
+
// license that can be found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
package proto
|
|
6
|
+
|
|
7
|
+
import (
|
|
8
|
+
"errors"
|
|
9
|
+
"fmt"
|
|
10
|
+
|
|
11
|
+
"google.golang.org/protobuf/encoding/prototext"
|
|
12
|
+
"google.golang.org/protobuf/encoding/protowire"
|
|
13
|
+
"google.golang.org/protobuf/runtime/protoimpl"
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
const (
|
|
17
|
+
WireVarint = 0
|
|
18
|
+
WireFixed32 = 5
|
|
19
|
+
WireFixed64 = 1
|
|
20
|
+
WireBytes = 2
|
|
21
|
+
WireStartGroup = 3
|
|
22
|
+
WireEndGroup = 4
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
// EncodeVarint returns the varint encoded bytes of v.
|
|
26
|
+
func EncodeVarint(v uint64) []byte {
|
|
27
|
+
return protowire.AppendVarint(nil, v)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// SizeVarint returns the length of the varint encoded bytes of v.
|
|
31
|
+
// This is equal to len(EncodeVarint(v)).
|
|
32
|
+
func SizeVarint(v uint64) int {
|
|
33
|
+
return protowire.SizeVarint(v)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// DecodeVarint parses a varint encoded integer from b,
|
|
37
|
+
// returning the integer value and the length of the varint.
|
|
38
|
+
// It returns (0, 0) if there is a parse error.
|
|
39
|
+
func DecodeVarint(b []byte) (uint64, int) {
|
|
40
|
+
v, n := protowire.ConsumeVarint(b)
|
|
41
|
+
if n < 0 {
|
|
42
|
+
return 0, 0
|
|
43
|
+
}
|
|
44
|
+
return v, n
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Buffer is a buffer for encoding and decoding the protobuf wire format.
|
|
48
|
+
// It may be reused between invocations to reduce memory usage.
|
|
49
|
+
type Buffer struct {
|
|
50
|
+
buf []byte
|
|
51
|
+
idx int
|
|
52
|
+
deterministic bool
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// NewBuffer allocates a new Buffer initialized with buf,
|
|
56
|
+
// where the contents of buf are considered the unread portion of the buffer.
|
|
57
|
+
func NewBuffer(buf []byte) *Buffer {
|
|
58
|
+
return &Buffer{buf: buf}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// SetDeterministic specifies whether to use deterministic serialization.
|
|
62
|
+
//
|
|
63
|
+
// Deterministic serialization guarantees that for a given binary, equal
|
|
64
|
+
// messages will always be serialized to the same bytes. This implies:
|
|
65
|
+
//
|
|
66
|
+
// - Repeated serialization of a message will return the same bytes.
|
|
67
|
+
// - Different processes of the same binary (which may be executing on
|
|
68
|
+
// different machines) will serialize equal messages to the same bytes.
|
|
69
|
+
//
|
|
70
|
+
// Note that the deterministic serialization is NOT canonical across
|
|
71
|
+
// languages. It is not guaranteed to remain stable over time. It is unstable
|
|
72
|
+
// across different builds with schema changes due to unknown fields.
|
|
73
|
+
// Users who need canonical serialization (e.g., persistent storage in a
|
|
74
|
+
// canonical form, fingerprinting, etc.) should define their own
|
|
75
|
+
// canonicalization specification and implement their own serializer rather
|
|
76
|
+
// than relying on this API.
|
|
77
|
+
//
|
|
78
|
+
// If deterministic serialization is requested, map entries will be sorted
|
|
79
|
+
// by keys in lexographical order. This is an implementation detail and
|
|
80
|
+
// subject to change.
|
|
81
|
+
func (b *Buffer) SetDeterministic(deterministic bool) {
|
|
82
|
+
b.deterministic = deterministic
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// SetBuf sets buf as the internal buffer,
|
|
86
|
+
// where the contents of buf are considered the unread portion of the buffer.
|
|
87
|
+
func (b *Buffer) SetBuf(buf []byte) {
|
|
88
|
+
b.buf = buf
|
|
89
|
+
b.idx = 0
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Reset clears the internal buffer of all written and unread data.
|
|
93
|
+
func (b *Buffer) Reset() {
|
|
94
|
+
b.buf = b.buf[:0]
|
|
95
|
+
b.idx = 0
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Bytes returns the internal buffer.
|
|
99
|
+
func (b *Buffer) Bytes() []byte {
|
|
100
|
+
return b.buf
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Unread returns the unread portion of the buffer.
|
|
104
|
+
func (b *Buffer) Unread() []byte {
|
|
105
|
+
return b.buf[b.idx:]
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Marshal appends the wire-format encoding of m to the buffer.
|
|
109
|
+
func (b *Buffer) Marshal(m Message) error {
|
|
110
|
+
var err error
|
|
111
|
+
b.buf, err = marshalAppend(b.buf, m, b.deterministic)
|
|
112
|
+
return err
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Unmarshal parses the wire-format message in the buffer and
|
|
116
|
+
// places the decoded results in m.
|
|
117
|
+
// It does not reset m before unmarshaling.
|
|
118
|
+
func (b *Buffer) Unmarshal(m Message) error {
|
|
119
|
+
err := UnmarshalMerge(b.Unread(), m)
|
|
120
|
+
b.idx = len(b.buf)
|
|
121
|
+
return err
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
type unknownFields struct{ XXX_unrecognized protoimpl.UnknownFields }
|
|
125
|
+
|
|
126
|
+
func (m *unknownFields) String() string { panic("not implemented") }
|
|
127
|
+
func (m *unknownFields) Reset() { panic("not implemented") }
|
|
128
|
+
func (m *unknownFields) ProtoMessage() { panic("not implemented") }
|
|
129
|
+
|
|
130
|
+
// DebugPrint dumps the encoded bytes of b with a header and footer including s
|
|
131
|
+
// to stdout. This is only intended for debugging.
|
|
132
|
+
func (*Buffer) DebugPrint(s string, b []byte) {
|
|
133
|
+
m := MessageReflect(new(unknownFields))
|
|
134
|
+
m.SetUnknown(b)
|
|
135
|
+
b, _ = prototext.MarshalOptions{AllowPartial: true, Indent: "\t"}.Marshal(m.Interface())
|
|
136
|
+
fmt.Printf("==== %s ====\n%s==== %s ====\n", s, b, s)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// EncodeVarint appends an unsigned varint encoding to the buffer.
|
|
140
|
+
func (b *Buffer) EncodeVarint(v uint64) error {
|
|
141
|
+
b.buf = protowire.AppendVarint(b.buf, v)
|
|
142
|
+
return nil
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// EncodeZigzag32 appends a 32-bit zig-zag varint encoding to the buffer.
|
|
146
|
+
func (b *Buffer) EncodeZigzag32(v uint64) error {
|
|
147
|
+
return b.EncodeVarint(uint64((uint32(v) << 1) ^ uint32((int32(v) >> 31))))
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// EncodeZigzag64 appends a 64-bit zig-zag varint encoding to the buffer.
|
|
151
|
+
func (b *Buffer) EncodeZigzag64(v uint64) error {
|
|
152
|
+
return b.EncodeVarint(uint64((uint64(v) << 1) ^ uint64((int64(v) >> 63))))
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// EncodeFixed32 appends a 32-bit little-endian integer to the buffer.
|
|
156
|
+
func (b *Buffer) EncodeFixed32(v uint64) error {
|
|
157
|
+
b.buf = protowire.AppendFixed32(b.buf, uint32(v))
|
|
158
|
+
return nil
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// EncodeFixed64 appends a 64-bit little-endian integer to the buffer.
|
|
162
|
+
func (b *Buffer) EncodeFixed64(v uint64) error {
|
|
163
|
+
b.buf = protowire.AppendFixed64(b.buf, uint64(v))
|
|
164
|
+
return nil
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// EncodeRawBytes appends a length-prefixed raw bytes to the buffer.
|
|
168
|
+
func (b *Buffer) EncodeRawBytes(v []byte) error {
|
|
169
|
+
b.buf = protowire.AppendBytes(b.buf, v)
|
|
170
|
+
return nil
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// EncodeStringBytes appends a length-prefixed raw bytes to the buffer.
|
|
174
|
+
// It does not validate whether v contains valid UTF-8.
|
|
175
|
+
func (b *Buffer) EncodeStringBytes(v string) error {
|
|
176
|
+
b.buf = protowire.AppendString(b.buf, v)
|
|
177
|
+
return nil
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// EncodeMessage appends a length-prefixed encoded message to the buffer.
|
|
181
|
+
func (b *Buffer) EncodeMessage(m Message) error {
|
|
182
|
+
var err error
|
|
183
|
+
b.buf = protowire.AppendVarint(b.buf, uint64(Size(m)))
|
|
184
|
+
b.buf, err = marshalAppend(b.buf, m, b.deterministic)
|
|
185
|
+
return err
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// DecodeVarint consumes an encoded unsigned varint from the buffer.
|
|
189
|
+
func (b *Buffer) DecodeVarint() (uint64, error) {
|
|
190
|
+
v, n := protowire.ConsumeVarint(b.buf[b.idx:])
|
|
191
|
+
if n < 0 {
|
|
192
|
+
return 0, protowire.ParseError(n)
|
|
193
|
+
}
|
|
194
|
+
b.idx += n
|
|
195
|
+
return uint64(v), nil
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// DecodeZigzag32 consumes an encoded 32-bit zig-zag varint from the buffer.
|
|
199
|
+
func (b *Buffer) DecodeZigzag32() (uint64, error) {
|
|
200
|
+
v, err := b.DecodeVarint()
|
|
201
|
+
if err != nil {
|
|
202
|
+
return 0, err
|
|
203
|
+
}
|
|
204
|
+
return uint64((uint32(v) >> 1) ^ uint32((int32(v&1)<<31)>>31)), nil
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// DecodeZigzag64 consumes an encoded 64-bit zig-zag varint from the buffer.
|
|
208
|
+
func (b *Buffer) DecodeZigzag64() (uint64, error) {
|
|
209
|
+
v, err := b.DecodeVarint()
|
|
210
|
+
if err != nil {
|
|
211
|
+
return 0, err
|
|
212
|
+
}
|
|
213
|
+
return uint64((uint64(v) >> 1) ^ uint64((int64(v&1)<<63)>>63)), nil
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// DecodeFixed32 consumes a 32-bit little-endian integer from the buffer.
|
|
217
|
+
func (b *Buffer) DecodeFixed32() (uint64, error) {
|
|
218
|
+
v, n := protowire.ConsumeFixed32(b.buf[b.idx:])
|
|
219
|
+
if n < 0 {
|
|
220
|
+
return 0, protowire.ParseError(n)
|
|
221
|
+
}
|
|
222
|
+
b.idx += n
|
|
223
|
+
return uint64(v), nil
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// DecodeFixed64 consumes a 64-bit little-endian integer from the buffer.
|
|
227
|
+
func (b *Buffer) DecodeFixed64() (uint64, error) {
|
|
228
|
+
v, n := protowire.ConsumeFixed64(b.buf[b.idx:])
|
|
229
|
+
if n < 0 {
|
|
230
|
+
return 0, protowire.ParseError(n)
|
|
231
|
+
}
|
|
232
|
+
b.idx += n
|
|
233
|
+
return uint64(v), nil
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// DecodeRawBytes consumes a length-prefixed raw bytes from the buffer.
|
|
237
|
+
// If alloc is specified, it returns a copy the raw bytes
|
|
238
|
+
// rather than a sub-slice of the buffer.
|
|
239
|
+
func (b *Buffer) DecodeRawBytes(alloc bool) ([]byte, error) {
|
|
240
|
+
v, n := protowire.ConsumeBytes(b.buf[b.idx:])
|
|
241
|
+
if n < 0 {
|
|
242
|
+
return nil, protowire.ParseError(n)
|
|
243
|
+
}
|
|
244
|
+
b.idx += n
|
|
245
|
+
if alloc {
|
|
246
|
+
v = append([]byte(nil), v...)
|
|
247
|
+
}
|
|
248
|
+
return v, nil
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// DecodeStringBytes consumes a length-prefixed raw bytes from the buffer.
|
|
252
|
+
// It does not validate whether the raw bytes contain valid UTF-8.
|
|
253
|
+
func (b *Buffer) DecodeStringBytes() (string, error) {
|
|
254
|
+
v, n := protowire.ConsumeString(b.buf[b.idx:])
|
|
255
|
+
if n < 0 {
|
|
256
|
+
return "", protowire.ParseError(n)
|
|
257
|
+
}
|
|
258
|
+
b.idx += n
|
|
259
|
+
return v, nil
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// DecodeMessage consumes a length-prefixed message from the buffer.
|
|
263
|
+
// It does not reset m before unmarshaling.
|
|
264
|
+
func (b *Buffer) DecodeMessage(m Message) error {
|
|
265
|
+
v, err := b.DecodeRawBytes(false)
|
|
266
|
+
if err != nil {
|
|
267
|
+
return err
|
|
268
|
+
}
|
|
269
|
+
return UnmarshalMerge(v, m)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// DecodeGroup consumes a message group from the buffer.
|
|
273
|
+
// It assumes that the start group marker has already been consumed and
|
|
274
|
+
// consumes all bytes until (and including the end group marker).
|
|
275
|
+
// It does not reset m before unmarshaling.
|
|
276
|
+
func (b *Buffer) DecodeGroup(m Message) error {
|
|
277
|
+
v, n, err := consumeGroup(b.buf[b.idx:])
|
|
278
|
+
if err != nil {
|
|
279
|
+
return err
|
|
280
|
+
}
|
|
281
|
+
b.idx += n
|
|
282
|
+
return UnmarshalMerge(v, m)
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// consumeGroup parses b until it finds an end group marker, returning
|
|
286
|
+
// the raw bytes of the message (excluding the end group marker) and the
|
|
287
|
+
// the total length of the message (including the end group marker).
|
|
288
|
+
func consumeGroup(b []byte) ([]byte, int, error) {
|
|
289
|
+
b0 := b
|
|
290
|
+
depth := 1 // assume this follows a start group marker
|
|
291
|
+
for {
|
|
292
|
+
_, wtyp, tagLen := protowire.ConsumeTag(b)
|
|
293
|
+
if tagLen < 0 {
|
|
294
|
+
return nil, 0, protowire.ParseError(tagLen)
|
|
295
|
+
}
|
|
296
|
+
b = b[tagLen:]
|
|
297
|
+
|
|
298
|
+
var valLen int
|
|
299
|
+
switch wtyp {
|
|
300
|
+
case protowire.VarintType:
|
|
301
|
+
_, valLen = protowire.ConsumeVarint(b)
|
|
302
|
+
case protowire.Fixed32Type:
|
|
303
|
+
_, valLen = protowire.ConsumeFixed32(b)
|
|
304
|
+
case protowire.Fixed64Type:
|
|
305
|
+
_, valLen = protowire.ConsumeFixed64(b)
|
|
306
|
+
case protowire.BytesType:
|
|
307
|
+
_, valLen = protowire.ConsumeBytes(b)
|
|
308
|
+
case protowire.StartGroupType:
|
|
309
|
+
depth++
|
|
310
|
+
case protowire.EndGroupType:
|
|
311
|
+
depth--
|
|
312
|
+
default:
|
|
313
|
+
return nil, 0, errors.New("proto: cannot parse reserved wire type")
|
|
314
|
+
}
|
|
315
|
+
if valLen < 0 {
|
|
316
|
+
return nil, 0, protowire.ParseError(valLen)
|
|
317
|
+
}
|
|
318
|
+
b = b[valLen:]
|
|
319
|
+
|
|
320
|
+
if depth == 0 {
|
|
321
|
+
return b0[:len(b0)-len(b)-tagLen], len(b0) - len(b), nil
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|