class MessageStore::Postgres::Get::Category

Constants

Error

Public Class Methods

build(category, batch_size: nil, correlation: nil, consumer_group_member: nil, consumer_group_size: nil, condition: nil, session: nil) click to toggle source
# File lib/message_store/postgres/get/category.rb, line 17
def self.build(category, batch_size: nil, correlation: nil, consumer_group_member: nil, consumer_group_size: nil, condition: nil, session: nil)
  instance = new(category, batch_size, correlation, consumer_group_member, consumer_group_size, condition)
  instance.configure(session: session)
  instance
end
call(category, position: nil, batch_size: nil, correlation: nil, consumer_group_member: nil, consumer_group_size: nil, condition: nil, session: nil) click to toggle source
# File lib/message_store/postgres/get/category.rb, line 12
def self.call(category, position: nil, batch_size: nil, correlation: nil, consumer_group_member: nil, consumer_group_size: nil, condition: nil, session: nil)
  instance = build(category, batch_size: batch_size, correlation: correlation, consumer_group_member: consumer_group_member, consumer_group_size: consumer_group_size, condition: condition, session: session)
  instance.(position)
end
configure(receiver, category, attr_name: nil, batch_size: nil, correlation: nil, consumer_group_member: nil, consumer_group_size: nil, condition: nil, session: nil) click to toggle source
# File lib/message_store/postgres/get/category.rb, line 23
def self.configure(receiver, category, attr_name: nil, batch_size: nil, correlation: nil, consumer_group_member: nil, consumer_group_size: nil, condition: nil, session: nil)
  attr_name ||= :get
  instance = build(category, batch_size: batch_size, correlation: correlation, consumer_group_member: consumer_group_member, consumer_group_size: consumer_group_size, condition: condition, session: session)
  receiver.public_send("#{attr_name}=", instance)
end

Public Instance Methods

assure() click to toggle source
# File lib/message_store/postgres/get/category.rb, line 67
def assure
  if not MessageStore::StreamName.category?(category)
    raise Error, "Must be a category (Stream Name: #{category})"
  end
end
last_position(batch) click to toggle source
# File lib/message_store/postgres/get/category.rb, line 49
def last_position(batch)
  batch.last.global_position
end
log_text(category, position) click to toggle source
# File lib/message_store/postgres/get/category.rb, line 63
def log_text(category, position)
  "Category: #{category}, Position: #{position.inspect}, Batch Size: #{batch_size.inspect}, Correlation: #{correlation.inspect}, Consumer Group Member: #{consumer_group_member.inspect}, Consumer Group Size: #{consumer_group_size.inspect}, Condition: #{condition.inspect})"
end
parameter_values(category, position) click to toggle source
# File lib/message_store/postgres/get/category.rb, line 37
def parameter_values(category, position)
  [
    category,
    position,
    batch_size,
    correlation,
    consumer_group_member,
    consumer_group_size,
    condition
  ]
end
parameters() click to toggle source
# File lib/message_store/postgres/get/category.rb, line 33
def parameters
  '$1::varchar, $2::bigint, $3::bigint, $4::varchar, $5::bigint, $6::bigint, $7::varchar'
end
specialize_error(error_message) click to toggle source
# File lib/message_store/postgres/get/category.rb, line 53
def specialize_error(error_message)
  error = Correlation.error(error_message)

  if error.nil?
    error = ConsumerGroup.error(error_message)
  end

  error
end
sql_command() click to toggle source
# File lib/message_store/postgres/get/category.rb, line 29
def sql_command
  "SELECT * FROM get_category_messages(#{parameters});"
end