Class: Splash::Commands::CmdRecords
- Inherits:
-
Object
- Object
- Splash::Commands::CmdRecords
- Includes:
- Backends, Splash::Constants
- Defined in:
- lib/splash/commands.rb
Constant Summary
Constants included from Splash::Constants
Splash::Constants::AUTHOR, Splash::Constants::BACKENDS_STRUCT, Splash::Constants::CONFIG_FILE, Splash::Constants::COPYRIGHT, Splash::Constants::DAEMON_LOGMON_SCHEDULING, Splash::Constants::DAEMON_METRICS_SCHEDULING, Splash::Constants::DAEMON_PID_FILE, Splash::Constants::DAEMON_PROCESS_NAME, Splash::Constants::DAEMON_PROCMON_SCHEDULING, Splash::Constants::DAEMON_STDERR_TRACE, Splash::Constants::DAEMON_STDOUT_TRACE, Splash::Constants::DEFAULT_RETENTION, Splash::Constants::EMAIL, Splash::Constants::EXECUTION_TEMPLATE, Splash::Constants::EXECUTION_TEMPLATE_TOKENS_LIST, Splash::Constants::LICENSE, Splash::Constants::LOGGERS_STRUCT, Splash::Constants::PID_PATH, Splash::Constants::PROMETHEUS_ALERTMANAGER_URL, Splash::Constants::PROMETHEUS_PUSHGATEWAY_URL, Splash::Constants::PROMETHEUS_URL, Splash::Constants::TRACE_PATH, Splash::Constants::TRANSPORTS_STRUCT, Splash::Constants::VERSION, Splash::Constants::WEBADMIN_IP, Splash::Constants::WEBADMIN_PID_FILE, Splash::Constants::WEBADMIN_PID_PATH, Splash::Constants::WEBADMIN_PORT, Splash::Constants::WEBADMIN_PROCESS_NAME, Splash::Constants::WEBADMIN_PROXY, Splash::Constants::WEBADMIN_STDERR_TRACE, Splash::Constants::WEBADMIN_STDOUT_TRACE
Instance Method Summary collapse
- #add_record(record) ⇒ Object
- #get_all_records(options = {}) ⇒ Object
-
#initialize(name) ⇒ CmdRecords
constructor
A new instance of CmdRecords.
- #purge(retention) ⇒ Object
Methods included from Backends
Methods included from Splash::Config
Methods included from Splash::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) ⇒ CmdRecords
Returns a new instance of CmdRecords.
46 47 48 49 |
# File 'lib/splash/commands.rb', line 46 def initialize(name) @name = name @backend = get_backend :execution_trace end |
Instance Method Details
#add_record(record) ⇒ Object
68 69 70 71 72 |
# File 'lib/splash/commands.rb', line 68 def add_record(record) data = get_all_records data.push({ DateTime.now.to_s => record }) @backend.put key: @name, value: data.to_yaml end |
#get_all_records(options = {}) ⇒ Object
74 75 76 |
# File 'lib/splash/commands.rb', line 74 def get_all_records(={}) return (@backend.exist?({key: @name}))? YAML::load(@backend.get({key: @name})) : [] end |
#purge(retention) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/splash/commands.rb', line 51 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 |