prometheus-splash 0.5.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +44 -0
  3. data/README.md +58 -60
  4. data/bin/splash +3 -0
  5. data/config/splash.yml +77 -7
  6. data/lib/splash/backends.rb +6 -0
  7. data/lib/splash/backends/file.rb +40 -0
  8. data/lib/splash/backends/redis.rb +47 -4
  9. data/lib/splash/cli.rb +18 -5
  10. data/lib/splash/cli/commands.rb +26 -18
  11. data/lib/splash/cli/config.rb +16 -2
  12. data/lib/splash/cli/daemon.rb +10 -3
  13. data/lib/splash/cli/documentation.rb +5 -2
  14. data/lib/splash/cli/logs.rb +25 -16
  15. data/lib/splash/cli/process.rb +103 -0
  16. data/lib/splash/cli/sequences.rb +114 -0
  17. data/lib/splash/cli/webadmin.rb +46 -0
  18. data/lib/splash/commands.rb +146 -122
  19. data/lib/splash/config.rb +166 -14
  20. data/lib/splash/config/flush.rb +30 -0
  21. data/lib/splash/config/sanitycheck.rb +7 -2
  22. data/lib/splash/config/service.rb +8 -1
  23. data/lib/splash/config/setup.rb +8 -3
  24. data/lib/splash/constants.rb +37 -8
  25. data/lib/splash/daemon.rb +6 -0
  26. data/lib/splash/{controller.rb → daemon/controller.rb} +34 -14
  27. data/lib/splash/daemon/metrics.rb +103 -0
  28. data/lib/splash/daemon/orchestrator.rb +182 -0
  29. data/lib/splash/daemon/orchestrator/grammar.rb +76 -0
  30. data/lib/splash/daemon/orchestrator/hooks.rb +28 -0
  31. data/lib/splash/dependencies.rb +16 -2
  32. data/lib/splash/exiter.rb +14 -0
  33. data/lib/splash/helpers.rb +84 -48
  34. data/lib/splash/loggers.rb +40 -13
  35. data/lib/splash/loggers/cli.rb +18 -3
  36. data/lib/splash/loggers/daemon.rb +14 -3
  37. data/lib/splash/loggers/dual.rb +35 -2
  38. data/lib/splash/loggers/web.rb +51 -0
  39. data/lib/splash/logs.rb +67 -54
  40. data/lib/splash/processes.rb +83 -0
  41. data/lib/splash/sequences.rb +105 -0
  42. data/lib/splash/templates.rb +10 -0
  43. data/lib/splash/transports.rb +9 -0
  44. data/lib/splash/transports/rabbitmq.rb +33 -4
  45. data/lib/splash/webadmin.rb +122 -0
  46. data/lib/splash/webadmin/api/routes/commands.rb +28 -0
  47. data/lib/splash/webadmin/api/routes/config.rb +10 -0
  48. data/lib/splash/webadmin/api/routes/init.rb +2 -0
  49. data/lib/splash/webadmin/api/routes/logs.rb +59 -0
  50. data/lib/splash/webadmin/api/routes/process.rb +60 -0
  51. data/lib/splash/webadmin/api/routes/sequences.rb +28 -0
  52. data/lib/splash/webadmin/main.rb +26 -0
  53. data/lib/splash/webadmin/portal/controllers/commands.rb +7 -0
  54. data/lib/splash/webadmin/portal/controllers/documentation.rb +6 -0
  55. data/lib/splash/webadmin/portal/controllers/home.rb +12 -0
  56. data/lib/splash/webadmin/portal/controllers/logs.rb +14 -0
  57. data/lib/splash/webadmin/portal/controllers/notfound.rb +5 -0
  58. data/lib/splash/webadmin/portal/controllers/processes.rb +14 -0
  59. data/lib/splash/webadmin/portal/controllers/proxy.rb +28 -0
  60. data/lib/splash/webadmin/portal/controllers/restclient.rb +19 -0
  61. data/lib/splash/webadmin/portal/controllers/sequences.rb +7 -0
  62. data/lib/splash/webadmin/portal/init.rb +11 -0
  63. data/lib/splash/webadmin/portal/public/css/ultragreen.css +8544 -0
  64. data/lib/splash/webadmin/portal/public/fonts/FontAwesome.otf +0 -0
  65. data/lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.ttf +0 -0
  66. data/lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.woff +0 -0
  67. data/lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.woff2 +0 -0
  68. data/lib/splash/webadmin/portal/public/images/logo_splash.png +0 -0
  69. data/lib/splash/webadmin/portal/public/images/logo_splash_reduce.png +0 -0
  70. data/lib/splash/webadmin/portal/public/images/logo_splash_tiny.png +0 -0
  71. data/lib/splash/webadmin/portal/views/commands.slim +49 -0
  72. data/lib/splash/webadmin/portal/views/documentation.slim +3 -0
  73. data/lib/splash/webadmin/portal/views/home.slim +78 -0
  74. data/lib/splash/webadmin/portal/views/layout.slim +43 -0
  75. data/lib/splash/webadmin/portal/views/logs.slim +32 -0
  76. data/lib/splash/webadmin/portal/views/nav.slim +17 -0
  77. data/lib/splash/webadmin/portal/views/not_found.slim +3 -0
  78. data/lib/splash/webadmin/portal/views/processes.slim +29 -0
  79. data/lib/splash/webadmin/portal/views/proxy.slim +13 -0
  80. data/lib/splash/webadmin/portal/views/restclient.slim +41 -0
  81. data/lib/splash/webadmin/portal/views/restclient_result.slim +29 -0
  82. data/lib/splash/webadmin/portal/views/sequences.slim +50 -0
  83. data/prometheus-splash.gemspec +7 -1
  84. data/spec/helpers_spec.rb +119 -0
  85. data/templates/ansible-splash/roles/splash/handlers/main.yml +4 -0
  86. data/templates/ansible-splash/roles/splash/tasks/main.yml +24 -1
  87. data/templates/ansible-splash/roles/splash/templates/logrotate.splash.j2 +11 -0
  88. data/templates/ansible-splash/roles/splash/templates/splash.yml.j2 +1 -1
  89. metadata +145 -10
  90. data/lib/splash/orchestrator.rb +0 -100
  91. data/lib/splash/orchestrator/grammar.rb +0 -54
  92. data/lib/splash/orchestrator/hooks.rb +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d510e4761e365c1ee36881fb1a3a4a99a7dbe7965958841497cdcaaadfb0c1b3
4
- data.tar.gz: 4f01f486135696ef0142d42362379e59868b1265ce367b3e3aac9853fcc48336
3
+ metadata.gz: 4e97bc4cce28c28f041ef5699bf6d3236001e84517bdefe8449cc572952997d2
4
+ data.tar.gz: c8e67cdc8089ff1db9e19ea4b86b84b52a64515d167b11df4f70e0e85e42f9f8
5
5
  SHA512:
6
- metadata.gz: 8b5c84b54b2098f9b027408ab8419fb19964feb1056607d090802acc793c2ccd6a9b98c1c8c2ca91334ccc8a36de88c1bf6cd674b6f5ef9df33a40debbfe84f5
7
- data.tar.gz: 1d93b819d8a9592495271a24bdc3e69e63a15489f5885faa729a8e42428a68dada73748ea8440c1338625a36c89d84a260e3bc9cdafa8fb869747864edc001f4
6
+ metadata.gz: 6642f9127b2f422e839d0b19c10c4625eb8b86bb1feeb7cd8ff2ba00369905fc1bb8a3f078a896cf3cf5e661273fc355c6194dde625673e9a17dc4bba14c3bc9
7
+ data.tar.gz: 10d052291ebe57a916f4079c23934fda5dac4e44d3ec45856982ba2b827c2764a57dd3990bd4819847278d7f6a5b22996f7e24dd5a4bcfc3936091b71d599645
@@ -81,3 +81,47 @@
81
81
  * quiet mode + no-colors and no-emoji #5
82
82
  * correlation id in log for daemon #15
83
83
  * systemd Splashd service installation #32
84
+
85
+
86
+ ## V 0.5.1 2020/04/17
87
+
88
+ ### CHANGES
89
+
90
+ * short Alias for commands without --no-[xxxx] #38
91
+ * REFACTO : namespaces
92
+ * Splash::Commands
93
+ * Splash::Log
94
+ * Splash::Daemon
95
+ * Splash::Daemon::Orchestrator
96
+
97
+
98
+ ### FEATURES
99
+
100
+ * flush backend arg in config #41
101
+ * adding global --debug flag
102
+ * adding splash Daemon metrics #25
103
+
104
+ ### DOC
105
+
106
+ * default value of mon scheduling 20s => 1m in ansible splash.yml
107
+
108
+
109
+ ### FIX
110
+
111
+ * Ansible Splash role handler error
112
+ * Ansible Splash role logrotate copytruncate for splash logs
113
+ * Prometheus Registry mismatch=> cumulative metrics on each groups #42
114
+ * logger Dual level conservation #43
115
+
116
+ ## V 0.5.2 2020/04/18
117
+
118
+ ### FIX
119
+
120
+ * dual logger daemon shutdown foreground error
121
+
122
+ ## V 0.5.3 2020/04/18
123
+
124
+ ### FEATURE
125
+
126
+ * processes monitoring #23
127
+
data/README.md CHANGED
@@ -9,7 +9,7 @@ SPLASH is **Supervision with Prometheus of Logs and Asynchronous tasks orchestra
9
9
  * Web : http://www.ultragreen.net
10
10
  * Github : https://github.com/Ultragreen/prometheus-splash
11
11
  * Rubygems : https://rubygems.org/gems/prometheus-splash
12
- * DOC yardoc : https://www.rubydoc.info/gems/prometheus-splash/0.3.0
12
+ * DOC yardoc : https://www.rubydoc.info/gems/prometheus-splash/0.6.0
13
13
 
14
14
  Prometheus Logs and Batchs supervision over PushGateway
15
15
 
@@ -65,10 +65,12 @@ As root or with rvmsudo, if you use RVM.
65
65
  # splash config setup
66
66
  Splash -> setup :
67
67
  * Installing Configuration file : /etc/splash.yml : [OK]
68
- * Installing template file : /etc/splash_execution_report.tpl : [OK]
69
- * Creating/Checking pid file path : /var/lib/splash : [OK]
70
- * Creating/Checking trace file path : /var/lib/splash : [OK]
71
- Splash config successfully done.
68
+ 👍 Splash Initialisation
69
+ 👍 Installing template file : /etc/splash_execution_report.tpl
70
+ 👍 Creating/Checking pid file path : /var/run/splash
71
+ 👍 Creating/Checking trace file path : /var/run/spla
72
+
73
+ *NOTE : you can just type 'splash' withou any arguments, for the first setup because, Splash come with an automatic recovery mode, when configuration file is missing, run at the very beginnning of his the execution*
72
74
 
73
75
  *WARNING : if you have already configured Splash, running this command without --preserve flag, RESET the Splash Configuration.*
74
76
 
@@ -121,7 +123,7 @@ For file/folders if problems is detected, it could be such as :
121
123
  run :
122
124
 
123
125
  $ splash config version
124
- Splash version : 0.0.3, Author : Romain GEORGES <gems@ultragreen.net>
126
+ Splash version : 0.6.0, Author : Romain GEORGES <gems@ultragreen.net>
125
127
  Ultragreen (c) 2020 BSD-2-Clause
126
128
 
127
129
 
@@ -652,74 +654,70 @@ TODO
652
654
 
653
655
  defined in the lib/splash/constants.rb
654
656
 
655
- ```ruby
656
657
 
657
- # the only one non-overridable by the configuration
658
- CONFIG_FILE = "/etc/splash.yml"
658
+
659
+ # the only one non-overridable by the configuration
660
+ CONFIG_FILE = "/etc/splash.yml"
659
661
 
660
662
 
661
- TRACE_PATH="/var/run/splash"
663
+ TRACE_PATH="/var/run/splash"
662
664
 
663
- DAEMON_LOGMON_SCHEDULING={ :every => '20s'}
664
- DAEMON_PROCESS_NAME="Splash : daemon."
665
- DAEMON_PID_PATH="/var/run"
666
- DAEMON_PID_FILE="splash.pid"
667
- DAEMON_STDOUT_TRACE="stdout.txt"
668
- DAEMON_STDERR_TRACE="stderr.txt"
665
+ DAEMON_LOGMON_SCHEDULING={ :every => '20s'}
666
+ DAEMON_PROCESS_NAME="Splash : daemon."
667
+ DAEMON_PID_PATH="/var/run"
668
+ DAEMON_PID_FILE="splash.pid"
669
+ DAEMON_STDOUT_TRACE="stdout.txt"
670
+ DAEMON_STDERR_TRACE="stderr.txt"
669
671
 
670
- AUTHOR="Romain GEORGES"
671
- EMAIL = "gems@ultragreen.net"
672
- COPYRIGHT="Ultragreen (c) 2020"
673
- LICENSE="BSD-2-Clause"
672
+ AUTHOR="Romain GEORGES"
673
+ EMAIL = "gems@ultragreen.net"
674
+ COPYRIGHT="Ultragreen (c) 2020"
675
+ LICENSE="BSD-2-Clause"
674
676
 
675
- PROMETHEUS_PUSHGATEWAY_HOST = "localhost"
676
- PROMETHEUS_PUSHGATEWAY_PORT = "9091"
677
+ PROMETHEUS_PUSHGATEWAY_HOST = "localhost"
678
+ PROMETHEUS_PUSHGATEWAY_PORT = "9091"
677
679
 
678
- EXECUTION_TEMPLATE="/etc/splash_execution_report.tpl"
679
- EXECUTION_TEMPLATE_TOKENS_LIST = [:end_date,:start_date,:cmd_name,:cmd_line,:stdout,:stderr,:desc,:status,:exec_time]
680
+ EXECUTION_TEMPLATE="/etc/splash_execution_report.tpl"
681
+ EXECUTION_TEMPLATE_TOKENS_LIST = [:end_date,:start_date,:cmd_name,:cmd_line,:stdout,:stderr,:desc,:status,:exec_time]
680
682
 
681
- BACKENDS_STRUCT = { :list => [:file,:redis],
683
+ BACKENDS_STRUCT = { :list => [:file,:redis],
682
684
  :stores => { :execution_trace => { :type => :file, :path => "/var/run/splash" }}}
683
- TRANSPORTS_STRUCT = { :list => [:rabbitmq],
685
+ TRANSPORTS_STRUCT = { :list => [:rabbitmq],
684
686
  :active => :rabbitmq,
685
687
  :rabbitmq => { :url => 'amqp://localhost/'} }
686
688
 
687
- ```
688
-
689
689
 
690
690
  #### Splash CLI return code significations
691
- ```ruby
692
- EXIT_MAP= {
693
-
694
- # context execution
695
- :not_root => {:message => "This operation need to be run as root (use sudo or rvmsudo)", :code => 10},
696
- :options_incompatibility => {:message => "Options incompatibility", :code => 40},
697
- :service_dependence_missing => {:message => "Splash Service dependence missing", :code => 60},
698
-
699
- # config
700
- :specific_config_required => {:message => "Specific configuration required", :code => 30},
701
- :splash_setup_error => {:message => "Splash Setup terminated unsuccessfully", :code => 25},
702
- :splash_setup_success => {:message => "Splash Setup terminated successfully", :code => 0},
703
- :splash_sanitycheck_error => {:message => "Splash Sanitycheck terminated unsuccessfully", :code => 20},
704
- :splash_sanitycheck_success => {:message => "Splash Sanitycheck terminated successfully", :code => 0},
705
- :configuration_error => {:message => "Splash Configuration Error", :code => 50},
706
-
707
-
708
- # global
709
- :quiet_exit => {:code => 0},
710
-
711
- # events
712
- :interrupt => {:message => "Splash user operation interrupted", :code => 33},
713
-
714
- # request
715
- :not_found => {:message => "Object not found", :code => 44},
716
- :already_exist => {:message => "Object already exist", :code => 48},
717
-
718
- # daemon
719
- :status_ok => {:message => "Status OK", :code => 0},
720
- :status_ko => {:message => "Status KO", :code => 31}
721
- ```
722
- }
691
+
692
+
693
+ # context execution
694
+ :not_root => {:message => "This operation need to be run as root (use sudo or rvmsudo)", :code => 10},
695
+ :options_incompatibility => {:message => "Options incompatibility", :code => 40},
696
+ :service_dependence_missing => {:message => "Splash Service dependence missing", :code => 60},
697
+
698
+ # config
699
+ :specific_config_required => {:message => "Specific configuration required", :code => 30},
700
+ :splash_setup_error => {:message => "Splash Setup terminated unsuccessfully", :code => 25},
701
+ :splash_setup_success => {:message => "Splash Setup terminated successfully", :code => 0},
702
+ :splash_sanitycheck_error => {:message => "Splash Sanitycheck terminated unsuccessfully", :code => 20},
703
+ :splash_sanitycheck_success => {:message => "Splash Sanitycheck terminated successfully", :code => 0},
704
+ :configuration_error => {:message => "Splash Configuration Error", :code => 50},
705
+
706
+
707
+ # global
708
+ :quiet_exit => {:code => 0},
709
+
710
+ # events
711
+ :interrupt => {:message => "Splash user operation interrupted", :code => 33},
712
+
713
+ # request
714
+ :not_found => {:message => "Object not found", :code => 44},
715
+ :already_exist => {:message => "Object already exist", :code => 48},
716
+
717
+ # daemon
718
+ :status_ok => {:message => "Status OK", :code => 0},
719
+ :status_ko => {:message => "Status KO", :code => 31}
720
+
723
721
 
724
722
  ### In the Futur ?
725
723
 
data/bin/splash CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # coding: utf-8
3
3
 
4
+ # major include
4
5
  require 'splash/dependencies'
5
6
  require 'splash/cli'
6
7
 
@@ -13,6 +14,7 @@ include Splash::Exiter
13
14
  include Splash::Loggers
14
15
  include Splash::Config
15
16
 
17
+ # auto setup
16
18
  unless verify_file(name: CONFIG_FILE, mode: "644", owner: user_root, group: group_root).empty? then
17
19
  puts 'Splash need reconfiguration : Auto setup launch'
18
20
 
@@ -26,4 +28,5 @@ unless verify_file(name: CONFIG_FILE, mode: "644", owner: user_root, group: grou
26
28
  end
27
29
  end
28
30
 
31
+ # running Thor
29
32
  CLI.start(ARGV)
@@ -34,6 +34,10 @@
34
34
  :daemon:
35
35
  :logmon_scheduling:
36
36
  :every: 20s
37
+ :metrics_scheduling:
38
+ :every: 15s
39
+ :procmon_scheduling:
40
+ :every: 20s
37
41
  :process_name: "Splash : daemon."
38
42
  :paths:
39
43
  :pid_path: /var/run/splash
@@ -43,12 +47,20 @@
43
47
  :stderr_trace: stderr.txt
44
48
  :pid_file: splash.pid
45
49
  :prometheus:
46
- :pushgateway:
47
- :host: "localhost"
48
- :port: 9091
50
+ :pushgateway: 'http://localhost:9091/'
51
+ :url: 'http://localhost:9090/'
52
+ :webadmin:
53
+ :port: 9234
54
+ :ip: 127.0.0.1
55
+ :proxy: false
56
+ :process_name: "Splash : WebAdmin."
57
+ :files:
58
+ :stdout_trace: stdout_webadmin.txt
59
+ :stderr_trace: stderr_webadmin.txt
60
+ :pid_file: splash_webadmin.pid
49
61
 
50
62
 
51
- ### configuration of commands and scheduling
63
+ ### Sample configuration of commands and scheduling
52
64
  :commands:
53
65
  :id_root:
54
66
  :desc: run id command on root
@@ -100,9 +112,67 @@
100
112
  :on_success: :echo3
101
113
 
102
114
 
103
- ### configuration of monitored logs
115
+ ### Sample configuration of monitored logs
104
116
  :logs:
105
- - :log: /tmp/test
117
+ - :label: :log_app_1
118
+ :log: /tmp/test
106
119
  :pattern: ERROR
107
- - :log: /tmp/test2
120
+ - :label: :log_app_2
121
+ :log: /tmp/test2
108
122
  :pattern: ERROR
123
+
124
+ ### configuration of monitored processes
125
+ :processes:
126
+ - :process: cron
127
+ :patterns:
128
+ - cron
129
+
130
+
131
+ ###
132
+ ## Sample configuration of executions sequences
133
+ :sequences:
134
+ :sample_remote_sequence:
135
+ :definition:
136
+ - :step: execute echo2 on omicron
137
+ :command: :echo2
138
+ :on_host: omicron
139
+ - :step: run locally echo3
140
+ :command: :echo3
141
+ :trace: false
142
+ :sample_local_sequence:
143
+ :definition:
144
+ - :step: run locally pwd without callback
145
+ :command: :pwd
146
+ :callback: false
147
+ - :step: run locally echo3 without Prometheus notifications
148
+ :command: :echo3
149
+ :notify: false
150
+ :sample_local_failed_sequence:
151
+ :options:
152
+ :continue: false
153
+ :definition:
154
+ - :step: run false_test locally without callback
155
+ :command: :false_test
156
+ :callback: false
157
+ - :step: considere this as inefective
158
+ :command: :echo3
159
+ :sample_local_full_sequence:
160
+ :options:
161
+ :continue: true
162
+ :definition:
163
+ - :step: run false_test locally without callback
164
+ :command: :false_test
165
+ :callback: false
166
+ :trace: false
167
+ - :step: considere this as inefective
168
+ :command: :pwd
169
+ :sample_scheduled_sequence:
170
+ :schedule:
171
+ :every: 1m
172
+ :options:
173
+ :continue: true
174
+ :definition:
175
+ - :step: exec echo3
176
+ :command: :echo3
177
+
178
+ ###
@@ -1,11 +1,17 @@
1
1
  # coding: utf-8
2
2
  Dir[File.dirname(__FILE__) + '/backends/*.rb'].each {|file| require file }
3
3
 
4
+ # base Splash Module
4
5
  module Splash
6
+
7
+ # generic backends module
5
8
  module Backends
6
9
  include Splash::Config
7
10
  include Splash::Constants
8
11
 
12
+ # factory for backend
13
+ # @param [Symbol] store the name of the store actually in [:execution_trace]
14
+ # @return [Splash::Backends::<Type>|Hash] with type in [:redis,:file] or Exiter case :configuration_error
9
15
  def get_backend(store)
10
16
  backend = get_config[:backends][:stores][store][:type].to_s
11
17
  aclass = "Splash::Backends::#{backend.capitalize}"
@@ -1,46 +1,86 @@
1
1
  # coding: utf-8
2
+
3
+ # base Splash Module
2
4
  module Splash
5
+ # generic backends module
3
6
  module Backends
7
+
8
+ # File backend definition
4
9
  class File
5
10
  include Splash::Config
6
11
  include Splash::Exiter
7
12
  include Splash::Helpers
8
13
  include Splash::Loggers
9
14
 
15
+ # Constructor
16
+ # @param [Symbol] store name in [:execution_trace] actually (see config and constants )
17
+ # @return [Splash::Backends::File] a File backend
10
18
  def initialize(store)
11
19
  @config = get_config[:backends][:stores][store]
12
20
  @path = @config[:path]
13
21
  ensure_backend
14
22
  end
15
23
 
24
+ # return the list of find records in backend for a specific pattern
25
+ # @param [String] pattern shell regexp
26
+ # @return [Array] list of record
16
27
  def list(pattern='*')
17
28
  pattern = suffix_trace(pattern)
18
29
  return Dir.glob("#{@path}/#{pattern}").map{|item| ::File.basename(item,".trace") }
19
30
  end
20
31
 
32
+
33
+ # return value of queried record
34
+ # @param [Hash] options
35
+ # @option options [Symbol] :key the name of the record
36
+ # @return [String] content value of record
21
37
  def get(options)
22
38
  return ::File.readlines("#{@path}/#{suffix_trace(options[:key])}").join
23
39
  end
24
40
 
41
+ # defined and store value for specified key
42
+ # @param [Hash] options
43
+ # @option options [Symbol] :key the name of the record
44
+ # @option options [Symbol] :value the content value of the record
45
+ # @return [String] content value of record
25
46
  def put(options)
26
47
  ::File.open("#{@path}/#{suffix_trace(options[:key])}", 'w') { |file|
27
48
  file.write options[:value]
28
49
  }
29
50
  end
30
51
 
52
+ # delete a specific record
53
+ # @param [Hash] options
54
+ # @option options [Symbol] :key the name of the record
55
+ # @return [Boolean] status of the operation
31
56
  def del(options)
32
57
  ::File.unlink("#{@path}/#{suffix_trace(options[:key])}") if File.exist?("#{@path}/#{suffix_trace(options[:key])}")
33
58
  end
34
59
 
60
+ # verifiy a specific record existance
61
+ # @param [Hash] options
62
+ # @option options [Symbol] :key the name of the record
63
+ # @return [Boolean] presence of the record
35
64
  def exist?(options)
36
65
  return ::File.exist?("#{@path}/#{suffix_trace(options[:key])}")
37
66
  end
38
67
 
68
+ # flush all records in backend
69
+ def flush
70
+ Dir.glob("#{@path}/*.trace").each { |file| ::File.delete(file)}
71
+ end
72
+
39
73
  private
74
+
75
+ # File backend specific method for suffixing record name with .trace for filename
76
+ # @param [String] astring
77
+ # @return [String] suffixed string
40
78
  def suffix_trace(astring)
41
79
  return "#{astring}.trace"
42
80
  end
43
81
 
82
+ # File backend specific method to test backend, correcting if requiered, spool path checking
83
+ # @return [True|Hash] Exiter case :configuration_error if failing to correct backend
44
84
  def ensure_backend
45
85
  unless verify_folder(name: @config[:path], mode: "644", owner: get_config.user_root, group: get_config.group_root).empty? then
46
86
  get_logger.warn "File Backend folder : #{@config[:path]} is missing"