Module: ElasticGraph::SchemaDefinition::Indexing::EventEnvelope Private

Defined in:
lib/elastic_graph/schema_definition/indexing/event_envelope.rb

Overview

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

Contains logic related to “event envelope”–the layer of metadata that wraps all indexing events.

Class Method Summary collapse

Class Method Details

.json_schema(indexed_type_names, json_schema_version) ⇒ Hash<String, Object>

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.

Returns the JSON schema for the ElasticGraph event envelope for the given ‘indexed_type_names`.

Parameters:

  • indexed_type_names (Array<String>)

    names of the indexed types

  • json_schema_version (Integer)

    the version of the JSON schema

Returns:

  • (Hash<String, Object>)

    the JSON schema for the ElasticGraph event envelope for the given ‘indexed_type_names`.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/elastic_graph/schema_definition/indexing/event_envelope.rb', line 21

def self.json_schema(indexed_type_names, json_schema_version)
  {
    "type" => "object",
    "properties" => {
      "op" => {
        "type" => "string",
        "enum" => %w[upsert]
      },
      "type" => {
        "type" => "string",
        # Sorting doesn't really matter here, but it's nice for the output in the schema artifact to be consistent.
        "enum" => indexed_type_names.sort
      },
      "id" => {
        "type" => "string",
        "maxLength" => DEFAULT_MAX_KEYWORD_LENGTH
      },
      "version" => {
        "type" => "integer",
        "minimum" => 0,
        "maximum" => (2**63) - 1
      },
      "record" => {
        "type" => "object"
      },
      "latency_timestamps" => {
        "type" => "object",
        "additionalProperties" => false,
        "patternProperties" => {
          "^\\w+_at$" => {"type" => "string", "format" => "date-time"}
        }
      },
      JSON_SCHEMA_VERSION_KEY => {
        "const" => json_schema_version
      },
      "message_id" => {
        "type" => "string",
        "description" => "The optional ID of the message containing this event from whatever messaging system is being used between the publisher and the ElasticGraph indexer."
      }
    },
    "additionalProperties" => false,
    "required" => ["op", "type", "id", "version", JSON_SCHEMA_VERSION_KEY],
    "if" => {
      "properties" => {
        "op" => {"const" => "upsert"}
      }
    },
    "then" => {"required" => ["record"]}
  }
end