Class: ROM::Kafka::Relation

Inherits:
Relation
  • Object
show all
Defined in:
lib/rom/kafka/relation.rb

Overview

The Kafka-specific implementation of ROM::Relation

Examples:

ROM.use(:auto_registration)
ROM.setup(:kafka, "localhost:9092")

class Users < ROM::Relation[:kafka]
  topic "users"
end

rom = ROM.finalize.env
users = rom.relation(:users)
users.where(partition: 1).offset(0).limit(1).to_a
# => [
#      { value: "Andrew", topic: "users", partition: 1, offset: 0 }
#    ]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.topic(name) ⇒ undefined

Kafka-specific alias for the ROM `.dataset` helper method.

Parameters:

  • name (#to_sym)

Returns:

  • (undefined)


30
31
32
# File 'lib/rom/kafka/relation.rb', line 30

def self.topic(name)
  dataset(name)
end

Instance Method Details

#from(value) ⇒ ROM::Kafka::Relation

Returns new relation with updated `:partition` attribute

Parameters:

  • value (Integer)

Returns:



40
41
42
# File 'lib/rom/kafka/relation.rb', line 40

def from(value)
  using(partition: value)
end

#limit(value) ⇒ ROM::Kafka::Relation

Returns new relation with updated `:limit` attribute

Parameters:

  • value (Integer)

Returns:



60
61
62
# File 'lib/rom/kafka/relation.rb', line 60

def limit(value)
  using(limit: value)
end

#offset(value) ⇒ ROM::Kafka::Relation

Returns new relation with updated `:offset` attribute

Parameters:

  • value (Integer)

Returns:



50
51
52
# File 'lib/rom/kafka/relation.rb', line 50

def offset(value)
  using(offset: value)
end