Class: MessageStore::Postgres::Get::Category
- Inherits:
-
Object
- Object
- MessageStore::Postgres::Get::Category
show all
- Includes:
- MessageStore::Postgres::Get
- Defined in:
- lib/message_store/postgres/get/category.rb,
lib/message_store/postgres/get/category/correlation.rb,
lib/message_store/postgres/get/category/consumer_group.rb
Defined Under Namespace
Modules: ConsumerGroup, Correlation, Defaults
Constant Summary
collapse
- Error =
Class.new(RuntimeError)
Class Method Summary
collapse
-
.build(category, batch_size: nil, correlation: nil, consumer_group_member: nil, consumer_group_size: nil, condition: nil, session: nil) ⇒ Object
-
.call(category, position: nil, batch_size: nil, correlation: nil, consumer_group_member: nil, consumer_group_size: nil, condition: nil, session: nil) ⇒ Object
-
.configure(receiver, category, attr_name: nil, batch_size: nil, correlation: nil, consumer_group_member: nil, consumer_group_size: nil, condition: nil, session: nil) ⇒ Object
Instance Method Summary
collapse
#configure, #convert, error_message, #get_result, included, message_data, #raise_error, specialization
Class Method Details
.build(category, batch_size: nil, correlation: nil, consumer_group_member: nil, consumer_group_size: nil, condition: nil, session: nil) ⇒ Object
17
18
19
20
21
|
# 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) ⇒ Object
12
13
14
15
|
# 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
|
23
24
25
26
27
|
# 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
|
Instance Method Details
#assure ⇒ Object
67
68
69
70
71
|
# 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) ⇒ Object
49
50
51
|
# File 'lib/message_store/postgres/get/category.rb', line 49
def last_position(batch)
batch.last.global_position
end
|
#log_text(category, position) ⇒ Object
63
64
65
|
# 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) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
|
# 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 ⇒ Object
33
34
35
|
# 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) ⇒ Object
53
54
55
56
57
58
59
60
61
|
# 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 ⇒ Object
29
30
31
|
# File 'lib/message_store/postgres/get/category.rb', line 29
def sql_command
"SELECT * FROM get_category_messages(#{parameters});"
end
|