Module: ElasticGraph::ProtoIngestion::SchemaDefinition::APIExtension

Defined in:
elasticgraph-proto_ingestion/lib/elastic_graph/proto_ingestion/schema_definition/api_extension.rb

Overview

Module designed to be extended onto an SchemaDefinition::API instance to enable protobuf schema artifact generation.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(api) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Wires up the protobuf extensions when this module is extended onto an API instance.

Parameters:



29
30
31
32
# File 'elasticgraph-proto_ingestion/lib/elastic_graph/proto_ingestion/schema_definition/api_extension.rb', line 29

def self.extended(api)
  api.state.extend(StateExtension)
  api.factory.extend(FactoryExtension)
end

Instance Method Details

#proto_schema_artifacts(package_name:, syntax: Schema::DEFAULT_SYNTAX, header_lines: []) ⇒ void

This method returns an undefined value.

Configures protobuf artifact generation behavior.

Examples:

Set the proto package name

ElasticGraph.define_schema do |schema|
  schema.proto_schema_artifacts package_name: "myapp.events.v1"
end

Emit proto2 with file-level options

ElasticGraph.define_schema do |schema|
  schema.proto_schema_artifacts(
    package_name: "myapp.events.v1",
    syntax: :proto2,
    header_lines: [%(option java_package = "com.myapp.events";)]
  )
end

Parameters:

  • package_name (String)

    proto package name to emit

  • syntax (Symbol, String) (defaults to: Schema::DEFAULT_SYNTAX)

    :proto3 (default) or :proto2

  • header_lines (Array<String>) (defaults to: [])

    file-level lines rendered verbatim after the package declaration



54
55
56
57
58
59
60
# File 'elasticgraph-proto_ingestion/lib/elastic_graph/proto_ingestion/schema_definition/api_extension.rb', line 54

def proto_schema_artifacts(package_name:, syntax: Schema::DEFAULT_SYNTAX, header_lines: [])
  ingestion_state = proto_ingestion_state
  ingestion_state.package_name = Identifier.validate_package_name(package_name)
  ingestion_state.syntax = Schema.validate_syntax(syntax)
  ingestion_state.header_lines = Schema.validate_header_lines(header_lines)
  nil
end