Module: Labkit::RateLimit::Config::VendoredProto
- Defined in:
- lib/labkit/rate_limit/config/vendored_proto.rb
Overview
VendoredProto registers the vendored gitlab.ratelimit.config.v1 file in the global descriptor pool. The gitlab-ratelimit-config-v1 gem from gitlab-org/protos registers the same file name, unguarded, and a second registration raises. So the gem is loaded first whenever it is installed, and the vendored copy is then compared with it: the same schema means the gem's registration is used, a different one is a boot error, because two versions of one schema in one process would make the loader read fields the other copy does not know.
Constant Summary collapse
- Mismatch =
The gem registered a schema that differs from the vendored copy, or one this google-protobuf cannot compare.
Class.new(StandardError)
- PACKAGE =
"gitlab.ratelimit.config.v1"- PROBE =
"#{PACKAGE}.RateLimits".freeze
- GEM_FILE =
"gitlab/ratelimit/config/v1/config_pb"
Class Method Summary collapse
-
.register(pool, serialized) ⇒ Boolean
True when this call registered the file and the vendored file must define its constants; false when the gem's registration is in use and the vendored file must stop loading.
Class Method Details
.register(pool, serialized) ⇒ Boolean
Returns true when this call registered the file and the vendored file must define its constants; false when the gem's registration is in use and the vendored file must stop loading.
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/labkit/rate_limit/config/vendored_proto.rb', line 32 def register(pool, serialized) load_gem_first existing = pool.lookup(PROBE) if existing.nil? pool.add_serialized_file(serialized) return true end check_same_schema!(existing.file_descriptor, serialized) false end |