Class: Splash::Transfers::TxRecords
- Inherits:
-
Object
- Object
- Splash::Transfers::TxRecords
- Defined in:
- lib/splash/transfers.rb
Constant Summary
Constants included from Constants
Constants::AUTHOR, Constants::BACKENDS_STRUCT, Constants::CONFIG_FILE, Constants::COPYRIGHT, Constants::DAEMON_LOGMON_SCHEDULING, Constants::DAEMON_METRICS_SCHEDULING, Constants::DAEMON_PID_FILE, Constants::DAEMON_PROCESS_NAME, Constants::DAEMON_PROCMON_SCHEDULING, Constants::DAEMON_STDERR_TRACE, Constants::DAEMON_STDOUT_TRACE, Constants::DEFAULT_RETENTION, Constants::EMAIL, Constants::EXECUTION_TEMPLATE, Constants::EXECUTION_TEMPLATE_TOKENS_LIST, Constants::LICENSE, Constants::LOGGERS_STRUCT, Constants::PID_PATH, Constants::PROMETHEUS_ALERTMANAGER_URL, Constants::PROMETHEUS_PUSHGATEWAY_URL, Constants::PROMETHEUS_URL, Constants::TRACE_PATH, Constants::TRANSPORTS_STRUCT, Constants::VERSION, Constants::WEBADMIN_IP, Constants::WEBADMIN_PID_FILE, Constants::WEBADMIN_PID_PATH, Constants::WEBADMIN_PORT, Constants::WEBADMIN_PROCESS_NAME, Constants::WEBADMIN_PROXY, Constants::WEBADMIN_STDERR_TRACE, Constants::WEBADMIN_STDOUT_TRACE
Instance Method Summary collapse
- #add_record(record) ⇒ Object
- #check_prepared ⇒ Object
- #get_all_records(options = {}) ⇒ Object
-
#initialize(name) ⇒ TxRecords
constructor
A new instance of TxRecords.
- #purge(retention) ⇒ Object
Methods included from Backends
Methods included from Config
Methods included from ConfigUtilities
#addservice, #checkconfig, #flush_backend, #setupsplash
Methods included from Helpers
#check_unicode_term, #daemonize, #format_by_extensions, #format_response, #get_processes, #group_root, #install_file, #is_root?, #make_folder, #make_link, #run_as_root, #search_file_in_gem, #user_root, #verify_file, #verify_folder, #verify_link, #verify_service
Constructor Details
#initialize(name) ⇒ TxRecords
Returns a new instance of TxRecords.
54 55 56 57 |
# File 'lib/splash/transfers.rb', line 54 def initialize(name) @name = name @backend = get_backend :transfers_trace end |
Instance Method Details
#add_record(record) ⇒ Object
76 77 78 79 80 |
# File 'lib/splash/transfers.rb', line 76 def add_record(record) data = get_all_records data.push({ DateTime.now.to_s => record }) @backend.put key: @name, value: data.to_yaml end |
#check_prepared ⇒ Object
86 87 88 89 90 91 92 93 94 |
# File 'lib/splash/transfers.rb', line 86 def check_prepared return :never_run_prepare unless @backend.exist?({key: @name}) return :never_prepare unless YAML::load(@backend.get({key: @name})).select {|item| record =item.keys.first value=item[record] value[:status] == :prepared }.count > 0 return :prepared end |
#get_all_records(options = {}) ⇒ Object
82 83 84 |
# File 'lib/splash/transfers.rb', line 82 def get_all_records(={}) return (@backend.exist?({key: @name}))? YAML::load(@backend.get({key: @name})) : [] end |
#purge(retention) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/splash/transfers.rb', line 59 def purge(retention) retention = {} if retention.nil? if retention.include? :hours then adjusted_datetime = DateTime.now - retention[:hours].to_f / 24 elsif retention.include? :hours then adjusted_datetime = DateTime.now - retention[:days].to_i else adjusted_datetime = DateTime.now - DEFAULT_RETENTION end data = get_all_records data.delete_if { |item| DateTime.parse(item.keys.first) <= (adjusted_datetime)} @backend.put key: @name, value: data.to_yaml end |