Class: KafkaRest::Schema

Inherits:
Object
  • Object
show all
Defined in:
lib/kafka_rest/schema.rb

Constant Summary collapse

AVRO_CONTENT =
'application/vnd.kafka.avro.v1+json'.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(serialized) ⇒ Schema

Returns a new instance of Schema.



12
13
14
15
16
17
# File 'lib/kafka_rest/schema.rb', line 12

def initialize(serialized)
  @id = nil
  @serialized = serialized
  @mutex = Mutex.new
  @content_type = AVRO_CONTENT
end

Instance Attribute Details

#content_typeObject (readonly)

Returns the value of attribute content_type.



6
7
8
# File 'lib/kafka_rest/schema.rb', line 6

def content_type
  @content_type
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/kafka_rest/schema.rb', line 5

def id
  @id
end

#serializedObject (readonly)

Returns the value of attribute serialized.



6
7
8
# File 'lib/kafka_rest/schema.rb', line 6

def serialized
  @serialized
end

Class Method Details

.parse(file) ⇒ Object



8
9
10
# File 'lib/kafka_rest/schema.rb', line 8

def self.parse(file)
  new(SchemaParser.call(file))
end

Instance Method Details

#update_id(id) ⇒ Object



19
20
21
# File 'lib/kafka_rest/schema.rb', line 19

def update_id(id)
  @mutex.synchronize { @id = id }
end