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,285 @@
|
|
|
1
|
+
// Copyright 2018 The Go Authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style
|
|
3
|
+
// license that can be found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
package protoreflect
|
|
6
|
+
|
|
7
|
+
import "google.golang.org/protobuf/encoding/protowire"
|
|
8
|
+
|
|
9
|
+
// Enum is a reflection interface for a concrete enum value,
|
|
10
|
+
// which provides type information and a getter for the enum number.
|
|
11
|
+
// Enum does not provide a mutable API since enums are commonly backed by
|
|
12
|
+
// Go constants, which are not addressable.
|
|
13
|
+
type Enum interface {
|
|
14
|
+
// Descriptor returns enum descriptor, which contains only the protobuf
|
|
15
|
+
// type information for the enum.
|
|
16
|
+
Descriptor() EnumDescriptor
|
|
17
|
+
|
|
18
|
+
// Type returns the enum type, which encapsulates both Go and protobuf
|
|
19
|
+
// type information. If the Go type information is not needed,
|
|
20
|
+
// it is recommended that the enum descriptor be used instead.
|
|
21
|
+
Type() EnumType
|
|
22
|
+
|
|
23
|
+
// Number returns the enum value as an integer.
|
|
24
|
+
Number() EnumNumber
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Message is a reflective interface for a concrete message value,
|
|
28
|
+
// encapsulating both type and value information for the message.
|
|
29
|
+
//
|
|
30
|
+
// Accessor/mutators for individual fields are keyed by FieldDescriptor.
|
|
31
|
+
// For non-extension fields, the descriptor must exactly match the
|
|
32
|
+
// field known by the parent message.
|
|
33
|
+
// For extension fields, the descriptor must implement ExtensionTypeDescriptor,
|
|
34
|
+
// extend the parent message (i.e., have the same message FullName), and
|
|
35
|
+
// be within the parent's extension range.
|
|
36
|
+
//
|
|
37
|
+
// Each field Value can be a scalar or a composite type (Message, List, or Map).
|
|
38
|
+
// See Value for the Go types associated with a FieldDescriptor.
|
|
39
|
+
// Providing a Value that is invalid or of an incorrect type panics.
|
|
40
|
+
type Message interface {
|
|
41
|
+
// Descriptor returns message descriptor, which contains only the protobuf
|
|
42
|
+
// type information for the message.
|
|
43
|
+
Descriptor() MessageDescriptor
|
|
44
|
+
|
|
45
|
+
// Type returns the message type, which encapsulates both Go and protobuf
|
|
46
|
+
// type information. If the Go type information is not needed,
|
|
47
|
+
// it is recommended that the message descriptor be used instead.
|
|
48
|
+
Type() MessageType
|
|
49
|
+
|
|
50
|
+
// New returns a newly allocated and mutable empty message.
|
|
51
|
+
New() Message
|
|
52
|
+
|
|
53
|
+
// Interface unwraps the message reflection interface and
|
|
54
|
+
// returns the underlying ProtoMessage interface.
|
|
55
|
+
Interface() ProtoMessage
|
|
56
|
+
|
|
57
|
+
// Range iterates over every populated field in an undefined order,
|
|
58
|
+
// calling f for each field descriptor and value encountered.
|
|
59
|
+
// Range returns immediately if f returns false.
|
|
60
|
+
// While iterating, mutating operations may only be performed
|
|
61
|
+
// on the current field descriptor.
|
|
62
|
+
Range(f func(FieldDescriptor, Value) bool)
|
|
63
|
+
|
|
64
|
+
// Has reports whether a field is populated.
|
|
65
|
+
//
|
|
66
|
+
// Some fields have the property of nullability where it is possible to
|
|
67
|
+
// distinguish between the default value of a field and whether the field
|
|
68
|
+
// was explicitly populated with the default value. Singular message fields,
|
|
69
|
+
// member fields of a oneof, and proto2 scalar fields are nullable. Such
|
|
70
|
+
// fields are populated only if explicitly set.
|
|
71
|
+
//
|
|
72
|
+
// In other cases (aside from the nullable cases above),
|
|
73
|
+
// a proto3 scalar field is populated if it contains a non-zero value, and
|
|
74
|
+
// a repeated field is populated if it is non-empty.
|
|
75
|
+
Has(FieldDescriptor) bool
|
|
76
|
+
|
|
77
|
+
// Clear clears the field such that a subsequent Has call reports false.
|
|
78
|
+
//
|
|
79
|
+
// Clearing an extension field clears both the extension type and value
|
|
80
|
+
// associated with the given field number.
|
|
81
|
+
//
|
|
82
|
+
// Clear is a mutating operation and unsafe for concurrent use.
|
|
83
|
+
Clear(FieldDescriptor)
|
|
84
|
+
|
|
85
|
+
// Get retrieves the value for a field.
|
|
86
|
+
//
|
|
87
|
+
// For unpopulated scalars, it returns the default value, where
|
|
88
|
+
// the default value of a bytes scalar is guaranteed to be a copy.
|
|
89
|
+
// For unpopulated composite types, it returns an empty, read-only view
|
|
90
|
+
// of the value; to obtain a mutable reference, use Mutable.
|
|
91
|
+
Get(FieldDescriptor) Value
|
|
92
|
+
|
|
93
|
+
// Set stores the value for a field.
|
|
94
|
+
//
|
|
95
|
+
// For a field belonging to a oneof, it implicitly clears any other field
|
|
96
|
+
// that may be currently set within the same oneof.
|
|
97
|
+
// For extension fields, it implicitly stores the provided ExtensionType.
|
|
98
|
+
// When setting a composite type, it is unspecified whether the stored value
|
|
99
|
+
// aliases the source's memory in any way. If the composite value is an
|
|
100
|
+
// empty, read-only value, then it panics.
|
|
101
|
+
//
|
|
102
|
+
// Set is a mutating operation and unsafe for concurrent use.
|
|
103
|
+
Set(FieldDescriptor, Value)
|
|
104
|
+
|
|
105
|
+
// Mutable returns a mutable reference to a composite type.
|
|
106
|
+
//
|
|
107
|
+
// If the field is unpopulated, it may allocate a composite value.
|
|
108
|
+
// For a field belonging to a oneof, it implicitly clears any other field
|
|
109
|
+
// that may be currently set within the same oneof.
|
|
110
|
+
// For extension fields, it implicitly stores the provided ExtensionType
|
|
111
|
+
// if not already stored.
|
|
112
|
+
// It panics if the field does not contain a composite type.
|
|
113
|
+
//
|
|
114
|
+
// Mutable is a mutating operation and unsafe for concurrent use.
|
|
115
|
+
Mutable(FieldDescriptor) Value
|
|
116
|
+
|
|
117
|
+
// NewField returns a new value that is assignable to the field
|
|
118
|
+
// for the given descriptor. For scalars, this returns the default value.
|
|
119
|
+
// For lists, maps, and messages, this returns a new, empty, mutable value.
|
|
120
|
+
NewField(FieldDescriptor) Value
|
|
121
|
+
|
|
122
|
+
// WhichOneof reports which field within the oneof is populated,
|
|
123
|
+
// returning nil if none are populated.
|
|
124
|
+
// It panics if the oneof descriptor does not belong to this message.
|
|
125
|
+
WhichOneof(OneofDescriptor) FieldDescriptor
|
|
126
|
+
|
|
127
|
+
// GetUnknown retrieves the entire list of unknown fields.
|
|
128
|
+
// The caller may only mutate the contents of the RawFields
|
|
129
|
+
// if the mutated bytes are stored back into the message with SetUnknown.
|
|
130
|
+
GetUnknown() RawFields
|
|
131
|
+
|
|
132
|
+
// SetUnknown stores an entire list of unknown fields.
|
|
133
|
+
// The raw fields must be syntactically valid according to the wire format.
|
|
134
|
+
// An implementation may panic if this is not the case.
|
|
135
|
+
// Once stored, the caller must not mutate the content of the RawFields.
|
|
136
|
+
// An empty RawFields may be passed to clear the fields.
|
|
137
|
+
//
|
|
138
|
+
// SetUnknown is a mutating operation and unsafe for concurrent use.
|
|
139
|
+
SetUnknown(RawFields)
|
|
140
|
+
|
|
141
|
+
// IsValid reports whether the message is valid.
|
|
142
|
+
//
|
|
143
|
+
// An invalid message is an empty, read-only value.
|
|
144
|
+
//
|
|
145
|
+
// An invalid message often corresponds to a nil pointer of the concrete
|
|
146
|
+
// message type, but the details are implementation dependent.
|
|
147
|
+
// Validity is not part of the protobuf data model, and may not
|
|
148
|
+
// be preserved in marshaling or other operations.
|
|
149
|
+
IsValid() bool
|
|
150
|
+
|
|
151
|
+
// ProtoMethods returns optional fast-path implementions of various operations.
|
|
152
|
+
// This method may return nil.
|
|
153
|
+
//
|
|
154
|
+
// The returned methods type is identical to
|
|
155
|
+
// "google.golang.org/protobuf/runtime/protoiface".Methods.
|
|
156
|
+
// Consult the protoiface package documentation for details.
|
|
157
|
+
ProtoMethods() *methods
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// RawFields is the raw bytes for an ordered sequence of fields.
|
|
161
|
+
// Each field contains both the tag (representing field number and wire type),
|
|
162
|
+
// and also the wire data itself.
|
|
163
|
+
type RawFields []byte
|
|
164
|
+
|
|
165
|
+
// IsValid reports whether b is syntactically correct wire format.
|
|
166
|
+
func (b RawFields) IsValid() bool {
|
|
167
|
+
for len(b) > 0 {
|
|
168
|
+
_, _, n := protowire.ConsumeField(b)
|
|
169
|
+
if n < 0 {
|
|
170
|
+
return false
|
|
171
|
+
}
|
|
172
|
+
b = b[n:]
|
|
173
|
+
}
|
|
174
|
+
return true
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// List is a zero-indexed, ordered list.
|
|
178
|
+
// The element Value type is determined by FieldDescriptor.Kind.
|
|
179
|
+
// Providing a Value that is invalid or of an incorrect type panics.
|
|
180
|
+
type List interface {
|
|
181
|
+
// Len reports the number of entries in the List.
|
|
182
|
+
// Get, Set, and Truncate panic with out of bound indexes.
|
|
183
|
+
Len() int
|
|
184
|
+
|
|
185
|
+
// Get retrieves the value at the given index.
|
|
186
|
+
// It never returns an invalid value.
|
|
187
|
+
Get(int) Value
|
|
188
|
+
|
|
189
|
+
// Set stores a value for the given index.
|
|
190
|
+
// When setting a composite type, it is unspecified whether the set
|
|
191
|
+
// value aliases the source's memory in any way.
|
|
192
|
+
//
|
|
193
|
+
// Set is a mutating operation and unsafe for concurrent use.
|
|
194
|
+
Set(int, Value)
|
|
195
|
+
|
|
196
|
+
// Append appends the provided value to the end of the list.
|
|
197
|
+
// When appending a composite type, it is unspecified whether the appended
|
|
198
|
+
// value aliases the source's memory in any way.
|
|
199
|
+
//
|
|
200
|
+
// Append is a mutating operation and unsafe for concurrent use.
|
|
201
|
+
Append(Value)
|
|
202
|
+
|
|
203
|
+
// AppendMutable appends a new, empty, mutable message value to the end
|
|
204
|
+
// of the list and returns it.
|
|
205
|
+
// It panics if the list does not contain a message type.
|
|
206
|
+
AppendMutable() Value
|
|
207
|
+
|
|
208
|
+
// Truncate truncates the list to a smaller length.
|
|
209
|
+
//
|
|
210
|
+
// Truncate is a mutating operation and unsafe for concurrent use.
|
|
211
|
+
Truncate(int)
|
|
212
|
+
|
|
213
|
+
// NewElement returns a new value for a list element.
|
|
214
|
+
// For enums, this returns the first enum value.
|
|
215
|
+
// For other scalars, this returns the zero value.
|
|
216
|
+
// For messages, this returns a new, empty, mutable value.
|
|
217
|
+
NewElement() Value
|
|
218
|
+
|
|
219
|
+
// IsValid reports whether the list is valid.
|
|
220
|
+
//
|
|
221
|
+
// An invalid list is an empty, read-only value.
|
|
222
|
+
//
|
|
223
|
+
// Validity is not part of the protobuf data model, and may not
|
|
224
|
+
// be preserved in marshaling or other operations.
|
|
225
|
+
IsValid() bool
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Map is an unordered, associative map.
|
|
229
|
+
// The entry MapKey type is determined by FieldDescriptor.MapKey.Kind.
|
|
230
|
+
// The entry Value type is determined by FieldDescriptor.MapValue.Kind.
|
|
231
|
+
// Providing a MapKey or Value that is invalid or of an incorrect type panics.
|
|
232
|
+
type Map interface {
|
|
233
|
+
// Len reports the number of elements in the map.
|
|
234
|
+
Len() int
|
|
235
|
+
|
|
236
|
+
// Range iterates over every map entry in an undefined order,
|
|
237
|
+
// calling f for each key and value encountered.
|
|
238
|
+
// Range calls f Len times unless f returns false, which stops iteration.
|
|
239
|
+
// While iterating, mutating operations may only be performed
|
|
240
|
+
// on the current map key.
|
|
241
|
+
Range(f func(MapKey, Value) bool)
|
|
242
|
+
|
|
243
|
+
// Has reports whether an entry with the given key is in the map.
|
|
244
|
+
Has(MapKey) bool
|
|
245
|
+
|
|
246
|
+
// Clear clears the entry associated with they given key.
|
|
247
|
+
// The operation does nothing if there is no entry associated with the key.
|
|
248
|
+
//
|
|
249
|
+
// Clear is a mutating operation and unsafe for concurrent use.
|
|
250
|
+
Clear(MapKey)
|
|
251
|
+
|
|
252
|
+
// Get retrieves the value for an entry with the given key.
|
|
253
|
+
// It returns an invalid value for non-existent entries.
|
|
254
|
+
Get(MapKey) Value
|
|
255
|
+
|
|
256
|
+
// Set stores the value for an entry with the given key.
|
|
257
|
+
// It panics when given a key or value that is invalid or the wrong type.
|
|
258
|
+
// When setting a composite type, it is unspecified whether the set
|
|
259
|
+
// value aliases the source's memory in any way.
|
|
260
|
+
//
|
|
261
|
+
// Set is a mutating operation and unsafe for concurrent use.
|
|
262
|
+
Set(MapKey, Value)
|
|
263
|
+
|
|
264
|
+
// Mutable retrieves a mutable reference to the entry for the given key.
|
|
265
|
+
// If no entry exists for the key, it creates a new, empty, mutable value
|
|
266
|
+
// and stores it as the entry for the key.
|
|
267
|
+
// It panics if the map value is not a message.
|
|
268
|
+
Mutable(MapKey) Value
|
|
269
|
+
|
|
270
|
+
// NewValue returns a new value assignable as a map value.
|
|
271
|
+
// For enums, this returns the first enum value.
|
|
272
|
+
// For other scalars, this returns the zero value.
|
|
273
|
+
// For messages, this returns a new, empty, mutable value.
|
|
274
|
+
NewValue() Value
|
|
275
|
+
|
|
276
|
+
// IsValid reports whether the map is valid.
|
|
277
|
+
//
|
|
278
|
+
// An invalid map is an empty, read-only value.
|
|
279
|
+
//
|
|
280
|
+
// An invalid message often corresponds to a nil Go map value,
|
|
281
|
+
// but the details are implementation dependent.
|
|
282
|
+
// Validity is not part of the protobuf data model, and may not
|
|
283
|
+
// be preserved in marshaling or other operations.
|
|
284
|
+
IsValid() bool
|
|
285
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Copyright 2018 The Go Authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style
|
|
3
|
+
// license that can be found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
// +build purego appengine
|
|
6
|
+
|
|
7
|
+
package protoreflect
|
|
8
|
+
|
|
9
|
+
import "google.golang.org/protobuf/internal/pragma"
|
|
10
|
+
|
|
11
|
+
type valueType int
|
|
12
|
+
|
|
13
|
+
const (
|
|
14
|
+
nilType valueType = iota
|
|
15
|
+
boolType
|
|
16
|
+
int32Type
|
|
17
|
+
int64Type
|
|
18
|
+
uint32Type
|
|
19
|
+
uint64Type
|
|
20
|
+
float32Type
|
|
21
|
+
float64Type
|
|
22
|
+
stringType
|
|
23
|
+
bytesType
|
|
24
|
+
enumType
|
|
25
|
+
ifaceType
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
// value is a union where only one type can be represented at a time.
|
|
29
|
+
// This uses a distinct field for each type. This is type safe in Go, but
|
|
30
|
+
// occupies more memory than necessary (72B).
|
|
31
|
+
type value struct {
|
|
32
|
+
pragma.DoNotCompare // 0B
|
|
33
|
+
|
|
34
|
+
typ valueType // 8B
|
|
35
|
+
num uint64 // 8B
|
|
36
|
+
str string // 16B
|
|
37
|
+
bin []byte // 24B
|
|
38
|
+
iface interface{} // 16B
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
func valueOfString(v string) Value {
|
|
42
|
+
return Value{typ: stringType, str: v}
|
|
43
|
+
}
|
|
44
|
+
func valueOfBytes(v []byte) Value {
|
|
45
|
+
return Value{typ: bytesType, bin: v}
|
|
46
|
+
}
|
|
47
|
+
func valueOfIface(v interface{}) Value {
|
|
48
|
+
return Value{typ: ifaceType, iface: v}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
func (v Value) getString() string {
|
|
52
|
+
return v.str
|
|
53
|
+
}
|
|
54
|
+
func (v Value) getBytes() []byte {
|
|
55
|
+
return v.bin
|
|
56
|
+
}
|
|
57
|
+
func (v Value) getIface() interface{} {
|
|
58
|
+
return v.iface
|
|
59
|
+
}
|
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
// Copyright 2018 The Go Authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style
|
|
3
|
+
// license that can be found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
package protoreflect
|
|
6
|
+
|
|
7
|
+
import (
|
|
8
|
+
"fmt"
|
|
9
|
+
"math"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
// Value is a union where only one Go type may be set at a time.
|
|
13
|
+
// The Value is used to represent all possible values a field may take.
|
|
14
|
+
// The following shows which Go type is used to represent each proto Kind:
|
|
15
|
+
//
|
|
16
|
+
// ╔════════════╤═════════════════════════════════════╗
|
|
17
|
+
// ║ Go type │ Protobuf kind ║
|
|
18
|
+
// ╠════════════╪═════════════════════════════════════╣
|
|
19
|
+
// ║ bool │ BoolKind ║
|
|
20
|
+
// ║ int32 │ Int32Kind, Sint32Kind, Sfixed32Kind ║
|
|
21
|
+
// ║ int64 │ Int64Kind, Sint64Kind, Sfixed64Kind ║
|
|
22
|
+
// ║ uint32 │ Uint32Kind, Fixed32Kind ║
|
|
23
|
+
// ║ uint64 │ Uint64Kind, Fixed64Kind ║
|
|
24
|
+
// ║ float32 │ FloatKind ║
|
|
25
|
+
// ║ float64 │ DoubleKind ║
|
|
26
|
+
// ║ string │ StringKind ║
|
|
27
|
+
// ║ []byte │ BytesKind ║
|
|
28
|
+
// ║ EnumNumber │ EnumKind ║
|
|
29
|
+
// ║ Message │ MessageKind, GroupKind ║
|
|
30
|
+
// ╚════════════╧═════════════════════════════════════╝
|
|
31
|
+
//
|
|
32
|
+
// Multiple protobuf Kinds may be represented by a single Go type if the type
|
|
33
|
+
// can losslessly represent the information for the proto kind. For example,
|
|
34
|
+
// Int64Kind, Sint64Kind, and Sfixed64Kind are all represented by int64,
|
|
35
|
+
// but use different integer encoding methods.
|
|
36
|
+
//
|
|
37
|
+
// The List or Map types are used if the field cardinality is repeated.
|
|
38
|
+
// A field is a List if FieldDescriptor.IsList reports true.
|
|
39
|
+
// A field is a Map if FieldDescriptor.IsMap reports true.
|
|
40
|
+
//
|
|
41
|
+
// Converting to/from a Value and a concrete Go value panics on type mismatch.
|
|
42
|
+
// For example, ValueOf("hello").Int() panics because this attempts to
|
|
43
|
+
// retrieve an int64 from a string.
|
|
44
|
+
type Value value
|
|
45
|
+
|
|
46
|
+
// The protoreflect API uses a custom Value union type instead of interface{}
|
|
47
|
+
// to keep the future open for performance optimizations. Using an interface{}
|
|
48
|
+
// always incurs an allocation for primitives (e.g., int64) since it needs to
|
|
49
|
+
// be boxed on the heap (as interfaces can only contain pointers natively).
|
|
50
|
+
// Instead, we represent the Value union as a flat struct that internally keeps
|
|
51
|
+
// track of which type is set. Using unsafe, the Value union can be reduced
|
|
52
|
+
// down to 24B, which is identical in size to a slice.
|
|
53
|
+
//
|
|
54
|
+
// The latest compiler (Go1.11) currently suffers from some limitations:
|
|
55
|
+
// • With inlining, the compiler should be able to statically prove that
|
|
56
|
+
// only one of these switch cases are taken and inline one specific case.
|
|
57
|
+
// See https://golang.org/issue/22310.
|
|
58
|
+
|
|
59
|
+
// ValueOf returns a Value initialized with the concrete value stored in v.
|
|
60
|
+
// This panics if the type does not match one of the allowed types in the
|
|
61
|
+
// Value union.
|
|
62
|
+
func ValueOf(v interface{}) Value {
|
|
63
|
+
switch v := v.(type) {
|
|
64
|
+
case nil:
|
|
65
|
+
return Value{}
|
|
66
|
+
case bool:
|
|
67
|
+
return ValueOfBool(v)
|
|
68
|
+
case int32:
|
|
69
|
+
return ValueOfInt32(v)
|
|
70
|
+
case int64:
|
|
71
|
+
return ValueOfInt64(v)
|
|
72
|
+
case uint32:
|
|
73
|
+
return ValueOfUint32(v)
|
|
74
|
+
case uint64:
|
|
75
|
+
return ValueOfUint64(v)
|
|
76
|
+
case float32:
|
|
77
|
+
return ValueOfFloat32(v)
|
|
78
|
+
case float64:
|
|
79
|
+
return ValueOfFloat64(v)
|
|
80
|
+
case string:
|
|
81
|
+
return ValueOfString(v)
|
|
82
|
+
case []byte:
|
|
83
|
+
return ValueOfBytes(v)
|
|
84
|
+
case EnumNumber:
|
|
85
|
+
return ValueOfEnum(v)
|
|
86
|
+
case Message, List, Map:
|
|
87
|
+
return valueOfIface(v)
|
|
88
|
+
case ProtoMessage:
|
|
89
|
+
panic(fmt.Sprintf("invalid proto.Message(%T) type, expected a protoreflect.Message type", v))
|
|
90
|
+
default:
|
|
91
|
+
panic(fmt.Sprintf("invalid type: %T", v))
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// ValueOfBool returns a new boolean value.
|
|
96
|
+
func ValueOfBool(v bool) Value {
|
|
97
|
+
if v {
|
|
98
|
+
return Value{typ: boolType, num: 1}
|
|
99
|
+
} else {
|
|
100
|
+
return Value{typ: boolType, num: 0}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// ValueOfInt32 returns a new int32 value.
|
|
105
|
+
func ValueOfInt32(v int32) Value {
|
|
106
|
+
return Value{typ: int32Type, num: uint64(v)}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// ValueOfInt64 returns a new int64 value.
|
|
110
|
+
func ValueOfInt64(v int64) Value {
|
|
111
|
+
return Value{typ: int64Type, num: uint64(v)}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// ValueOfUint32 returns a new uint32 value.
|
|
115
|
+
func ValueOfUint32(v uint32) Value {
|
|
116
|
+
return Value{typ: uint32Type, num: uint64(v)}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// ValueOfUint64 returns a new uint64 value.
|
|
120
|
+
func ValueOfUint64(v uint64) Value {
|
|
121
|
+
return Value{typ: uint64Type, num: v}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// ValueOfFloat32 returns a new float32 value.
|
|
125
|
+
func ValueOfFloat32(v float32) Value {
|
|
126
|
+
return Value{typ: float32Type, num: uint64(math.Float64bits(float64(v)))}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// ValueOfFloat64 returns a new float64 value.
|
|
130
|
+
func ValueOfFloat64(v float64) Value {
|
|
131
|
+
return Value{typ: float64Type, num: uint64(math.Float64bits(float64(v)))}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// ValueOfString returns a new string value.
|
|
135
|
+
func ValueOfString(v string) Value {
|
|
136
|
+
return valueOfString(v)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// ValueOfBytes returns a new bytes value.
|
|
140
|
+
func ValueOfBytes(v []byte) Value {
|
|
141
|
+
return valueOfBytes(v[:len(v):len(v)])
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// ValueOfEnum returns a new enum value.
|
|
145
|
+
func ValueOfEnum(v EnumNumber) Value {
|
|
146
|
+
return Value{typ: enumType, num: uint64(v)}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// ValueOfMessage returns a new Message value.
|
|
150
|
+
func ValueOfMessage(v Message) Value {
|
|
151
|
+
return valueOfIface(v)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// ValueOfList returns a new List value.
|
|
155
|
+
func ValueOfList(v List) Value {
|
|
156
|
+
return valueOfIface(v)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// ValueOfMap returns a new Map value.
|
|
160
|
+
func ValueOfMap(v Map) Value {
|
|
161
|
+
return valueOfIface(v)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// IsValid reports whether v is populated with a value.
|
|
165
|
+
func (v Value) IsValid() bool {
|
|
166
|
+
return v.typ != nilType
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Interface returns v as an interface{}.
|
|
170
|
+
//
|
|
171
|
+
// Invariant: v == ValueOf(v).Interface()
|
|
172
|
+
func (v Value) Interface() interface{} {
|
|
173
|
+
switch v.typ {
|
|
174
|
+
case nilType:
|
|
175
|
+
return nil
|
|
176
|
+
case boolType:
|
|
177
|
+
return v.Bool()
|
|
178
|
+
case int32Type:
|
|
179
|
+
return int32(v.Int())
|
|
180
|
+
case int64Type:
|
|
181
|
+
return int64(v.Int())
|
|
182
|
+
case uint32Type:
|
|
183
|
+
return uint32(v.Uint())
|
|
184
|
+
case uint64Type:
|
|
185
|
+
return uint64(v.Uint())
|
|
186
|
+
case float32Type:
|
|
187
|
+
return float32(v.Float())
|
|
188
|
+
case float64Type:
|
|
189
|
+
return float64(v.Float())
|
|
190
|
+
case stringType:
|
|
191
|
+
return v.String()
|
|
192
|
+
case bytesType:
|
|
193
|
+
return v.Bytes()
|
|
194
|
+
case enumType:
|
|
195
|
+
return v.Enum()
|
|
196
|
+
default:
|
|
197
|
+
return v.getIface()
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
func (v Value) typeName() string {
|
|
202
|
+
switch v.typ {
|
|
203
|
+
case nilType:
|
|
204
|
+
return "nil"
|
|
205
|
+
case boolType:
|
|
206
|
+
return "bool"
|
|
207
|
+
case int32Type:
|
|
208
|
+
return "int32"
|
|
209
|
+
case int64Type:
|
|
210
|
+
return "int64"
|
|
211
|
+
case uint32Type:
|
|
212
|
+
return "uint32"
|
|
213
|
+
case uint64Type:
|
|
214
|
+
return "uint64"
|
|
215
|
+
case float32Type:
|
|
216
|
+
return "float32"
|
|
217
|
+
case float64Type:
|
|
218
|
+
return "float64"
|
|
219
|
+
case stringType:
|
|
220
|
+
return "string"
|
|
221
|
+
case bytesType:
|
|
222
|
+
return "bytes"
|
|
223
|
+
case enumType:
|
|
224
|
+
return "enum"
|
|
225
|
+
default:
|
|
226
|
+
switch v := v.getIface().(type) {
|
|
227
|
+
case Message:
|
|
228
|
+
return "message"
|
|
229
|
+
case List:
|
|
230
|
+
return "list"
|
|
231
|
+
case Map:
|
|
232
|
+
return "map"
|
|
233
|
+
default:
|
|
234
|
+
return fmt.Sprintf("<unknown: %T>", v)
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
func (v Value) panicMessage(what string) string {
|
|
240
|
+
return fmt.Sprintf("type mismatch: cannot convert %v to %s", v.typeName(), what)
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Bool returns v as a bool and panics if the type is not a bool.
|
|
244
|
+
func (v Value) Bool() bool {
|
|
245
|
+
switch v.typ {
|
|
246
|
+
case boolType:
|
|
247
|
+
return v.num > 0
|
|
248
|
+
default:
|
|
249
|
+
panic(v.panicMessage("bool"))
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// Int returns v as a int64 and panics if the type is not a int32 or int64.
|
|
254
|
+
func (v Value) Int() int64 {
|
|
255
|
+
switch v.typ {
|
|
256
|
+
case int32Type, int64Type:
|
|
257
|
+
return int64(v.num)
|
|
258
|
+
default:
|
|
259
|
+
panic(v.panicMessage("int"))
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// Uint returns v as a uint64 and panics if the type is not a uint32 or uint64.
|
|
264
|
+
func (v Value) Uint() uint64 {
|
|
265
|
+
switch v.typ {
|
|
266
|
+
case uint32Type, uint64Type:
|
|
267
|
+
return uint64(v.num)
|
|
268
|
+
default:
|
|
269
|
+
panic(v.panicMessage("uint"))
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Float returns v as a float64 and panics if the type is not a float32 or float64.
|
|
274
|
+
func (v Value) Float() float64 {
|
|
275
|
+
switch v.typ {
|
|
276
|
+
case float32Type, float64Type:
|
|
277
|
+
return math.Float64frombits(uint64(v.num))
|
|
278
|
+
default:
|
|
279
|
+
panic(v.panicMessage("float"))
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// String returns v as a string. Since this method implements fmt.Stringer,
|
|
284
|
+
// this returns the formatted string value for any non-string type.
|
|
285
|
+
func (v Value) String() string {
|
|
286
|
+
switch v.typ {
|
|
287
|
+
case stringType:
|
|
288
|
+
return v.getString()
|
|
289
|
+
default:
|
|
290
|
+
return fmt.Sprint(v.Interface())
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// Bytes returns v as a []byte and panics if the type is not a []byte.
|
|
295
|
+
func (v Value) Bytes() []byte {
|
|
296
|
+
switch v.typ {
|
|
297
|
+
case bytesType:
|
|
298
|
+
return v.getBytes()
|
|
299
|
+
default:
|
|
300
|
+
panic(v.panicMessage("bytes"))
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// Enum returns v as a EnumNumber and panics if the type is not a EnumNumber.
|
|
305
|
+
func (v Value) Enum() EnumNumber {
|
|
306
|
+
switch v.typ {
|
|
307
|
+
case enumType:
|
|
308
|
+
return EnumNumber(v.num)
|
|
309
|
+
default:
|
|
310
|
+
panic(v.panicMessage("enum"))
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// Message returns v as a Message and panics if the type is not a Message.
|
|
315
|
+
func (v Value) Message() Message {
|
|
316
|
+
switch vi := v.getIface().(type) {
|
|
317
|
+
case Message:
|
|
318
|
+
return vi
|
|
319
|
+
default:
|
|
320
|
+
panic(v.panicMessage("message"))
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// List returns v as a List and panics if the type is not a List.
|
|
325
|
+
func (v Value) List() List {
|
|
326
|
+
switch vi := v.getIface().(type) {
|
|
327
|
+
case List:
|
|
328
|
+
return vi
|
|
329
|
+
default:
|
|
330
|
+
panic(v.panicMessage("list"))
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Map returns v as a Map and panics if the type is not a Map.
|
|
335
|
+
func (v Value) Map() Map {
|
|
336
|
+
switch vi := v.getIface().(type) {
|
|
337
|
+
case Map:
|
|
338
|
+
return vi
|
|
339
|
+
default:
|
|
340
|
+
panic(v.panicMessage("map"))
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// MapKey returns v as a MapKey and panics for invalid MapKey types.
|
|
345
|
+
func (v Value) MapKey() MapKey {
|
|
346
|
+
switch v.typ {
|
|
347
|
+
case boolType, int32Type, int64Type, uint32Type, uint64Type, stringType:
|
|
348
|
+
return MapKey(v)
|
|
349
|
+
default:
|
|
350
|
+
panic(v.panicMessage("map key"))
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// MapKey is used to index maps, where the Go type of the MapKey must match
|
|
355
|
+
// the specified key Kind (see MessageDescriptor.IsMapEntry).
|
|
356
|
+
// The following shows what Go type is used to represent each proto Kind:
|
|
357
|
+
//
|
|
358
|
+
// ╔═════════╤═════════════════════════════════════╗
|
|
359
|
+
// ║ Go type │ Protobuf kind ║
|
|
360
|
+
// ╠═════════╪═════════════════════════════════════╣
|
|
361
|
+
// ║ bool │ BoolKind ║
|
|
362
|
+
// ║ int32 │ Int32Kind, Sint32Kind, Sfixed32Kind ║
|
|
363
|
+
// ║ int64 │ Int64Kind, Sint64Kind, Sfixed64Kind ║
|
|
364
|
+
// ║ uint32 │ Uint32Kind, Fixed32Kind ║
|
|
365
|
+
// ║ uint64 │ Uint64Kind, Fixed64Kind ║
|
|
366
|
+
// ║ string │ StringKind ║
|
|
367
|
+
// ╚═════════╧═════════════════════════════════════╝
|
|
368
|
+
//
|
|
369
|
+
// A MapKey is constructed and accessed through a Value:
|
|
370
|
+
// k := ValueOf("hash").MapKey() // convert string to MapKey
|
|
371
|
+
// s := k.String() // convert MapKey to string
|
|
372
|
+
//
|
|
373
|
+
// The MapKey is a strict subset of valid types used in Value;
|
|
374
|
+
// converting a Value to a MapKey with an invalid type panics.
|
|
375
|
+
type MapKey value
|
|
376
|
+
|
|
377
|
+
// IsValid reports whether k is populated with a value.
|
|
378
|
+
func (k MapKey) IsValid() bool {
|
|
379
|
+
return Value(k).IsValid()
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// Interface returns k as an interface{}.
|
|
383
|
+
func (k MapKey) Interface() interface{} {
|
|
384
|
+
return Value(k).Interface()
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// Bool returns k as a bool and panics if the type is not a bool.
|
|
388
|
+
func (k MapKey) Bool() bool {
|
|
389
|
+
return Value(k).Bool()
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// Int returns k as a int64 and panics if the type is not a int32 or int64.
|
|
393
|
+
func (k MapKey) Int() int64 {
|
|
394
|
+
return Value(k).Int()
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// Uint returns k as a uint64 and panics if the type is not a uint32 or uint64.
|
|
398
|
+
func (k MapKey) Uint() uint64 {
|
|
399
|
+
return Value(k).Uint()
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// String returns k as a string. Since this method implements fmt.Stringer,
|
|
403
|
+
// this returns the formatted string value for any non-string type.
|
|
404
|
+
func (k MapKey) String() string {
|
|
405
|
+
return Value(k).String()
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// Value returns k as a Value.
|
|
409
|
+
func (k MapKey) Value() Value {
|
|
410
|
+
return Value(k)
|
|
411
|
+
}
|