Class: Bas::SharedStorage::Postgres
- Inherits:
-
Base
- Object
- Base
- Bas::SharedStorage::Postgres
show all
- Defined in:
- lib/bas/shared_storage/postgres.rb
Overview
The SharedStorage::Postgres class serves as a shared storage implementation to read and write on a shared storage defined as a postgres database
Constant Summary
collapse
- TABLE_PARAMS =
"data, tag, archived, stage, status, error_message, version"
Instance Attribute Summary
Attributes inherited from Base
#read_options, #read_response, #write_options, #write_response
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#read ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/bas/shared_storage/postgres.rb', line 19
def read
params = { connection: read_options[:connection], query: read_query }
first_result = Utils::Postgres::Request.execute(params).first || {}
@read_response = Bas::SharedStorage::Types::Read.new(first_result[:id], first_result[:data],
first_result[:inserted_at])
end
|
#set_in_process ⇒ Object
33
34
35
36
37
|
# File 'lib/bas/shared_storage/postgres.rb', line 33
def set_in_process
return if read_options[:avoid_process].eql?(true) || read_response.id.nil?
update_stage(read_response.id, "in process")
end
|
#set_processed ⇒ Object
39
40
41
42
43
|
# File 'lib/bas/shared_storage/postgres.rb', line 39
def set_processed
return if read_options[:avoid_process].eql?(true) || read_response.id.nil?
update_stage(read_response.id, "processed") unless @read_response.nil?
end
|
#write(data) ⇒ Object
28
29
30
31
|
# File 'lib/bas/shared_storage/postgres.rb', line 28
def write(data)
params = { connection: write_options[:connection], query: write_query(data) }
@write_response = Utils::Postgres::Request.execute(params)
end
|