sc4ry 0.1.7 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86e9653534207c3b9809325a04d64da78f0636a1e62d800729cc15737ae0acf3
4
- data.tar.gz: 1c00863a8330914acf9aea73f6022d7afaef73be50b3341f01e21a7490244125
3
+ metadata.gz: 5a0a0b0ccc0176505d96bfe85b978f155a989db942cc031972d7c31f24db0d2a
4
+ data.tar.gz: 1e0a528951e291efb0f04b05eaa6ae0897a6a98fb3834b11e7a8e45597848da4
5
5
  SHA512:
6
- metadata.gz: 37c78c76dbb4a2a636ebbeb2bd70ac45949aa89983adda27810fb0bc3cf49078ef2e94e10b02f105ee6354109e2efeef9ed3f2b22678645fcf79e0cf097f0536
7
- data.tar.gz: e32fe7cb84723bfcbbb1a90634d55cd3922c42bedb3e98c93d80f817ee6236ca966196c067a410a44affd04ff00c21560cdf18c702ad8e3f727e37ff9b248fbe
6
+ metadata.gz: c0159b1b8254dbc358eb68b33cb96cafdd5007c065e549ce307fbeacfeaf22f4739181b996fb62ce27dba3b33947eccd6e1d497970c0c218d8ec199633d3f480
7
+ data.tar.gz: 58280b4b7fe4cc20c30738aabaf258e35efc349dc0df1d2211a058e3b9acd7d61f55df9b3a9cda01b5493c9cfd48bd96993835460c5da8e4205f8a85f74e9559
@@ -0,0 +1,27 @@
1
+ name: Ruby
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ container-job:
7
+ runs-on: ubuntu-latest
8
+ container: ruby:latest
9
+ services:
10
+ redis:
11
+ image: redis
12
+ pushgateway:
13
+ image: prom/pushgateway
14
+
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - name: Run the default task
18
+ run: |
19
+ gem install bundler -v 2.2.3
20
+ bundle install
21
+ bundle exec rake
22
+ env:
23
+ # The hostname used to communicate with the Redis service container
24
+ REDIS_HOST: redis
25
+ REDIS_PORT: 6379
26
+ PROM_PG_PORT: 9091
27
+ PROM_PG_HOST: pushgateway
data/.gitignore CHANGED
@@ -6,6 +6,6 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
-
9
+ /yardoc/
10
10
  # rspec failure tracking
11
11
  .rspec_status
data/.rubocop.yml ADDED
@@ -0,0 +1,47 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2022-07-26 15:23:44 UTC using RuboCop version 1.32.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ AllCops:
10
+ NewCops: enable
11
+ SuggestExtensions: false
12
+ Exclude:
13
+ - 'spec/sc4ry_spec.rb'
14
+ - 'samples/test.rb'
15
+
16
+
17
+ # definitive :
18
+ Style/ClassVars:
19
+ Enabled: false
20
+ Gemspec/RequireMFA:
21
+ Enabled: false
22
+ Security/YAMLLoad:
23
+ Enabled: false
24
+ Style/MutableConstant:
25
+ Enabled: false
26
+
27
+ # to study :
28
+
29
+ Metrics/ClassLength:
30
+ Enabled: false
31
+ Metrics/AbcSize:
32
+ Enabled: false
33
+ Metrics/CyclomaticComplexity:
34
+ Enabled: false
35
+ Metrics/MethodLength:
36
+ Enabled: false
37
+ Metrics/PerceivedComplexity:
38
+ Enabled: false
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
data/Gemfile CHANGED
@@ -1,9 +1,13 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in sc4ry.gemspec
4
6
  gemspec
5
7
 
6
- gem "rake", "~> 12.0"
7
- gem "rspec", "~> 3.0"
8
- gem "prometheus-client", "~> 3.0"
9
- gem "rest-client", "~> 2.1"
8
+ gem 'prometheus-client', '~> 3.0'
9
+ gem 'rake', '~> 12.0'
10
+ gem 'redis', '~> 4.6'
11
+ gem 'rest-client', '~> 2.1'
12
+ gem 'rspec', '~> 3.0'
13
+ gem 'version', '~> 1.1'
data/README.md CHANGED
@@ -2,7 +2,25 @@
2
2
 
3
3
  Sc4ry provide the Circuit Breaker Design Pattern for your applications
4
4
 
5
- ![Sc4ry logo](assets/images/logo_sc4ry.png) _Simple CircuitBreacker 4 RubY_
5
+ [![Ruby](https://github.com/Ultragreen/Sc4ry/workflows/Ruby/badge.svg)](https://github.com/Ultragreen/sc4ry/actions?query=workflow%3ARuby+branch%3Amaster)
6
+ ![GitHub](https://img.shields.io/github/license/Ultragreen/sc4ry)
7
+
8
+ [![Documentation](https://img.shields.io/badge/docs-rubydoc.info-brightgreen)](https://rubydoc.info/gems/sc4ry)
9
+ ![GitHub issues](https://img.shields.io/github/issues/Ultragreen/sc4ry)
10
+ ![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/Ultragreen/sc4ry)
11
+ ![GitHub top language](https://img.shields.io/github/languages/top/Ultragreen/sc4ry)
12
+ ![GitHub milestones](https://img.shields.io/github/milestones/open/Ultragreen/sc4ry)
13
+
14
+ ![Gem](https://img.shields.io/gem/dt/sc4ry)
15
+ [![Gem Version](https://badge.fury.io/rb/sc4ry.svg)](https://badge.fury.io/rb/sc4ry)
16
+ ![Twitter Follow](https://img.shields.io/twitter/follow/Ultragreen?style=social)
17
+ ![GitHub Org's stars](https://img.shields.io/github/stars/Ultragreen?style=social)
18
+ ![GitHub watchers](https://img.shields.io/github/watchers/Ultragreen/sc4ry?style=social)
19
+
20
+ <noscript><a href="https://liberapay.com/ruydiaz/donate"><img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg"></a></noscript>
21
+
22
+ ![Sc4ry logo](assets/images/logo_sc4ry.png)
23
+ _Simple CircuitBreacker 4 RubY_
6
24
 
7
25
  ## Installation
8
26
 
@@ -22,58 +40,285 @@ Or install it yourself as:
22
40
 
23
41
  ## Usage
24
42
 
25
- ### sample with Restclient
43
+ ### Circuits States Worflow
44
+
45
+ ![Sc4ry workflow](assets/images/sc4ry_workflow.png)
46
+ ### Quickstart : sample with Restclient
47
+
48
+ A quick circuit test :
49
+ create a test script lile test.rb :
26
50
 
27
51
  ```ruby
28
52
 
29
- require 'rubygems'
30
- require 'sc4ry'
53
+ require 'rubygems'
54
+ require 'sc4ry'
31
55
 
56
+ include Sc4ry
32
57
 
33
- # defining a circuit, config must be empty or override from default
34
- Sc4ry::Circuits.register({:circuit =>:test, :config => {:notifiers => [:prometheus, :mattermost], :exceptions => [Errno::ECONNREFUSED], :timeout => true, :timeout_value => 3, :check_delay => 5 }})
58
+ Circuits.register circuit: :mycircuit, config: {:notifiers => [:prometheus,:mattermost],
59
+ :exceptions => [Errno::ECONNREFUSED, URI::InvalidURIError]}
35
60
 
36
- # display the list of known circuit
37
- pp Sc4ry::Circuits.list
61
+ Circuits.run do # circuit: :mycircuit is optional, run work with the first circuit registered
62
+ puts RestClient.get('http://your_service/endpoint')
63
+ end
38
64
 
39
- # display default config, must be override with a nested hash by calling default_config= method
40
- pp Sc4ry::Circuits.default_config
65
+
41
66
 
67
+ ```
42
68
 
43
- # Config an alternate logger
44
- Sc4ry::Logger.register name: :perso, instance: ::Logger.new('/tmp/logfile.log')
45
- Sc4ry::Logger::current = :perso
69
+ ### the Sc4ry Config default values :
46
70
 
71
+ Default values, circuit is half open before one of the max count is reached :
47
72
 
48
- # default values, circuit is half open before one of the max count is reached
73
+ * _:max_failure_count_
74
+ <br>*description* : maximum failure before opening circuit
75
+ <br>*default value* : 5
76
+ <br>
49
77
 
50
- # {:max_failure_count=>5, => maximum failure before opening circuit
51
- # :timeout_value=>20, => timeout value, if :timeout => true
52
- # :timeout=>false, => (de)activate internal timeout
53
- # :max_timeout_count=>5, => maximum timeout try before opening circuit
54
- # :max_time=>10, => maximum time for a circuit run
55
- # :max_overtime_count=>3, => maximum count of overtime before opening circuit
56
- # :check_delay=>30, => delay after opening, before trying again to closed circuit or after an other check
57
- # :notifiers=>[], => active notifier, must be :symbol in [:prometheus, :mattermost]
58
- # :forward_unknown_exceptions => true, => (de)activate forwarding of unknown exceptions, just log in DEBUG if false
59
- # :raise_on_opening => false, => (de)activate raise specific Sc4ry exceptions ( CircuitBreaked ) if circuit opening
60
- # :exceptions=>[StandardError, RuntimeError]} => list of selected Exceptions considered for failure, others are SKIPPED.
78
+ * _:timeout_value_
79
+ <br>*description* : timeout value, if :timeout => true
80
+ <br>*default value* : 20
81
+ <br>
61
82
 
62
- # display configuration for a specific circuit
63
- pp Sc4ry::Circuits.get circuit: :test
83
+ * _:timeout_
84
+ <br>*description* : (de)activate internal timeout
85
+ <br>*default value* : false
86
+ <br>
64
87
 
65
- # sample Mattermost notification
66
- #Sc4ry::Notifiers::config({:name => :mattermost, :config => {:url => 'https://mattermost.mycorp.com', :token => "<TOKEN>"}})
88
+ * _:max_timeout_count_
89
+ <br>*description* : maximum timeout try before opening circuit
90
+ <br>*default value** : 5
91
+ <br>
67
92
 
68
- # sample loop
69
- 100.times do
70
- sleep 1
71
- Sc4ry::Circuits.run circuit: :test do
72
- # for the test choose or build an endpoint you must shutdown
73
- puts RestClient.get('http://<URL_OF_A_ENDPOINT>')
74
- end
75
- end
93
+ * _:max_time_
94
+ <br>*description* : maximum time for a circuit run
95
+ <br>*default value* : 10
96
+ <br>
97
+
98
+ * _:max_overtime_count_
99
+ <br>*description* : maximum count of overtime before opening circuit
100
+ <br>*default value* : 3
101
+ <br>
102
+
103
+ * _:check_delay_
104
+ <br>*description* : delay after opening, before trying again to closed circuit or after an other check
105
+ <br>*default value* : 30
106
+ <br>
107
+
108
+ * _:notifiers_
109
+ <br>*description* : active notifier, must be :symbol in [:prometheus, :mattermost]
110
+ <br>*default value* : []
111
+ <br>
112
+
113
+ * _:forward_unknown_exceptions_
114
+ <br>*description* : (de)activate forwarding of unknown exceptions, just log in DEBUG if false
115
+ <br>*default value* : true
116
+ <br>
117
+
118
+ * _:raise_on_opening_
119
+ <br>*description* : (de)activate raise specific Sc4ry exceptions ( CircuitBreaked ) if circuit opening
120
+ <br>*default value* : false
121
+ <br>
122
+
123
+ * _:exceptions_
124
+ <br>*description* : [StandardError, RuntimeError]
125
+ <br>*default value* : list of selected Exceptions considered for failure, others are SKIPPED.
126
+
127
+ ### Global overview for all features
128
+
129
+ This script could be usefull to test all feature on your installation
130
+
131
+ You need:
132
+ * Redis
133
+ * Prometheus pushgateway
134
+ * an endpoint if you want to check real endpoint
135
+ * a Mattermost/Slack incoming webhook (optional)
136
+
137
+ You could gate all this pre-requistes simply if you jave docker up on your machine
76
138
 
139
+ ```
140
+ $ docker pull redis:latest
141
+ $ docker run --rm -d -p 6379:6379/tcp redis:latest
142
+ $ docker pull prom/pushgateway:latest
143
+ $ docker run --rm -d -p 9091:9091 prom/pushgateway:latest
144
+ $ git clone https://github.com/Ultragreen/MockWS.git
145
+ $ cd MockWS
146
+ $ rackup
147
+ ```
148
+
149
+ create the test script like :
150
+
151
+ ```ruby
152
+
153
+ require 'rubygems'
154
+ require 'sc4ry'
155
+
156
+
157
+ include Sc4ry
158
+
159
+ # display of default Sc4ry config
160
+ puts '1.1/ CONFIG : Initial default config'
161
+ Circuits.default_config.each do |item,value|
162
+ puts " * #{item} : #{value}"
163
+ end
164
+ puts ''
165
+
166
+ # testing the two ways to configure Sc4ry default config
167
+ puts "1.2/ CONFIG : modifying default config activate timout and set max_time to 12"
168
+ Circuits.merge_default_config diff: {timeout: true }
169
+ Circuits.configure do |spec|
170
+ spec.max_time = 12
171
+ end
172
+ puts ''
173
+
174
+ # display default config, must be override with a nested hash by calling default_config= method
175
+ puts '1.3/ CONFIG : Default config updated:'
176
+ Circuits.default_config.each do |item,value|
177
+ puts " * #{item} : #{value}"
178
+ end
179
+ puts ''
180
+
181
+ # display current data Store
182
+ print "2.1/ STORE : Current datastore backend : "
183
+ puts Circuits.store.current
184
+ puts ''
185
+
186
+
187
+ # display available backend
188
+ puts "2.2/ STORE : List of existing backends : "
189
+ Circuits.store.list_backend.each do |backend|
190
+ puts " - #{backend}"
191
+ end
192
+ puts ''
193
+
194
+
195
+ # display Redis backend config in store before change
196
+ puts '2.3/ STORE : display default config of redis backend'
197
+ Circuits.store.get_config(backend: :redis).each do |item,value|
198
+ puts " * #{item} : #{value}"
199
+ end
200
+ puts ''
201
+
202
+ # reconfigure a backend
203
+ puts "2.4/ STORE : reconfigure Redis backend"
204
+ Circuits.store.config_backend name: :redis, config: {:host => 'localhost', :port => 6379, :db => 10 }
205
+ puts
206
+
207
+ # display after
208
+ puts '2.5/ STORE : display altered config of redis backend'
209
+ Circuits.store.get_config(backend: :redis).each do |item,value|
210
+ puts " * #{item} : #{value}"
211
+ end
212
+ puts ''
213
+
214
+
215
+ # change backend
216
+
217
+ puts '2.6/ STORE : change to redis backend (NEED a Redis installed) '
218
+ puts " $ docker pull redis:latest"
219
+ puts " $ docker run --rm -d -p 6379:6379/tcp redis:latest"
220
+ Circuits.store.change_backend name: :redis
221
+ puts ''
222
+
223
+ puts '2.7/ STORE : flush redis backend, just for test, and for idempotency (NEED a Redis installed) '
224
+ Circuits.store.flush
225
+ puts ''
226
+
227
+ # defining a circuit, config must be empty or override from default
228
+ puts "3.1/ CIRCUIT : registering a circuit by merge :"
229
+ Circuits.register circuit: :test, config: {:notifiers => [:prometheus,:mattermost], :exceptions => [Errno::ECONNREFUSED, URI::InvalidURIError] }
230
+ puts ""
231
+
232
+ puts "3.2/ CIRCUIT : registering a circuit by block :"
233
+ Circuits.register circuit: :test2 do |spec|
234
+ spec.exceptions = [Errno::ECONNREFUSED]
235
+ end
236
+ puts ''
237
+
238
+ puts "3.3/ CIRCUIT : registering a circuit by default :"
239
+ Circuits.register circuit: :test3
240
+ puts ''
241
+
242
+ puts "3.4/ CIRCUITS : Circuits list"
243
+ Circuits::list.each do |circuit|
244
+ puts " * #{circuit}"
245
+ end
246
+ puts ""
247
+
248
+ puts "3.5/ CIRCUIT : display a circuit config :test3 :"
249
+ Circuits.get(circuit: :test3).each do |item,value|
250
+ puts " * #{item} : #{value}"
251
+ end
252
+ puts ""
253
+
254
+ puts "3.6/ CIRCUIT : update config of :test3 => :raise_on_opening == true :"
255
+ Circuits.update_config circuit: :test3, config: {raise_on_opening: true}
256
+ puts ''
257
+
258
+ puts "3.7/ CIRCUIT : display a circuit config :test3 after change :"
259
+ Circuits.get(circuit: :test3).each do |item,value|
260
+ puts " * #{item} : #{value}"
261
+ end
262
+ puts ""
263
+
264
+
265
+ puts "3.8/ unregister a circuit : :test2 :"
266
+ Circuits.unregister circuit: :test2
267
+ puts ''
268
+
269
+ puts "3.9/ CIRCUITS : Circuits list after unregister"
270
+ Circuits::list.each do |circuit|
271
+ puts " * #{circuit}"
272
+ end
273
+ puts ""
274
+
275
+ # Config an alternate logger
276
+
277
+ puts "4.1/ LOGGER : register a logger on file "
278
+ Circuits.loggers.register name: :perso, instance: ::Logger.new('/tmp/logfile.log')
279
+ puts ''
280
+
281
+ puts "4.2/ LOGGER : get the list of available loggers"
282
+ Circuits.loggers.list_available.each do |logger|
283
+ puts " * #{logger}"
284
+ end
285
+ puts ''
286
+
287
+ puts "4.3/ LOGGER : change logger to :perso"
288
+ Circuits.loggers.current = :perso
289
+ puts ""
290
+
291
+
292
+
293
+
294
+
295
+ # sample Mattermost notification
296
+ puts "5/ set notifier mattermost on dummy url, change with your slack or mattermost server"
297
+ Sc4ry::Notifiers::config name: :mattermost, config: {:url => 'https://mattermost.mycorp.com', :token => "<TOKEN>"}
298
+ puts ""
299
+
300
+
301
+ # sample loop
302
+ puts "6/ running circuits test, please wait ... (see /tmp/logfile.log for result)"
303
+ puts " check endoint status for different result, you cloud use http://github.com/Ultragreen/MockWS for testing endpoint, on an other tty"
304
+ puts " $ git clone https://github.com/Ultragreen/MockWS.git"
305
+ puts " $ cd MockWS"
306
+ puts " $ rackup"
307
+ begin
308
+ 10.times do
309
+ sleep 1
310
+ Circuits.run circuit: :test do
311
+ # for the test choose or build an endpoint you must shutdown
312
+ puts RestClient.get('http://localhost:9292/test2/data')
313
+ end
314
+ end
315
+ rescue Interrupt
316
+ puts 'Interrputed'
317
+ ensure
318
+ Circuits.store.flush
319
+ end
320
+
321
+ puts "end"
77
322
  ```
78
323
 
79
324
  ## Development
@@ -84,8 +329,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
84
329
 
85
330
  ## Contributing
86
331
 
87
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sc4ry. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/sc4ry/blob/master/CODE_OF_CONDUCT.md).
88
-
332
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Ultragreen/sc4ry.
89
333
 
90
334
  ## License
91
335
 
data/Rakefile CHANGED
@@ -1,6 +1,44 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
3
2
 
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+ require 'yard'
6
+ require 'yard/rake/yardoc_task'
7
+ require 'code_statistics'
8
+ require 'version'
9
+ require 'rake/version_task'
10
+ require 'rubocop//rake_task'
11
+
12
+ Rake::VersionTask.new
13
+ RuboCop::RakeTask.new
4
14
  RSpec::Core::RakeTask.new(:spec)
5
15
 
6
- task :default => :spec
16
+ task default: :spec
17
+
18
+ YARD::Rake::YardocTask.new do |t|
19
+ t.files = ['lib/**/*.rb', '-', 'doc/**/*', 'spec/**/*_spec.rb']
20
+ t.options += ['-o', 'yardoc']
21
+ end
22
+ YARD::Config.load_plugin('yard-rspec')
23
+
24
+ namespace :yardoc do
25
+ task :clobber do
26
+ begin
27
+ rm_r 'yardoc'
28
+ rescue StandardError
29
+ nil
30
+ end
31
+ begin
32
+ rm_r '.yardoc'
33
+ rescue StandardError
34
+ nil
35
+ end
36
+ begin
37
+ rm_r 'pkg'
38
+ rescue StandardError
39
+ nil
40
+ end
41
+ end
42
+ end
43
+
44
+ task clobber: 'yardoc:clobber'
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.1
Binary file
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "sc4ry"
4
+ require 'bundler/setup'
5
+ require 'sc4ry'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "sc4ry"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
@@ -1 +1,3 @@
1
- Dir[File.dirname(__FILE__) + '/*.rb'].sort.each { |file| require file unless File.basename(file) == 'init.rb' }
1
+ # frozen_string_literal: true
2
+
3
+ Dir["#{File.dirname(__FILE__)}/*.rb"].sort.each { |file| require file unless File.basename(file) == 'init.rb' }
@@ -1,35 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Sc4ry module
4
+ # @note namespace
1
5
  module Sc4ry
6
+ # Sc4ry:Backends module
7
+ # @note namespace
2
8
  module Backends
3
-
9
+ # class of the memory backend
4
10
  class Memory
5
- def initialize(config=nil?)
6
- @data = Hash::new
11
+ # Constructor
12
+ # @param [Hash] config Config map
13
+ # @return [Sc4ry::Backends::Memory] a in Memory backend
14
+ def initialize(_config = nil?)
15
+ @data = {}
7
16
  end
8
17
 
18
+ # return the list of find records in backend for a specific pattern
19
+ # @return [Array] list of record (for all hostname if hostname is specified)
9
20
  def list
10
- return @data.keys
21
+ @data.keys
11
22
  end
12
23
 
13
- def get(options)
14
- return @data[options[:key]]
24
+ # return value of queried record
25
+ # @param key [Symbol] the name of the record
26
+ # @return [String] content value of record
27
+ def get(key:)
28
+ @data[key]
15
29
  end
16
30
 
17
- def put(options)
18
- @data[options[:key]] = options[:value]
19
- end
31
+ # defined and store value for specified key
32
+ # @param key [Symbol] :key the name of the record
33
+ # @param value [Symbol] :value the content value of the record
34
+ # @return [String] content value of record
35
+ def put(key:, value:)
36
+ @data[key] = value
37
+ end
20
38
 
21
- def del(options)
22
- @data.delete options[:key]
23
- end
39
+ # delete a specific record
40
+ # @param params [Symbol] the name of the record
41
+ # @return [Boolean] status of the operation
42
+ def del(key:)
43
+ @data.delete key
44
+ end
24
45
 
46
+ # flush all records in backend
47
+ # @return [Boolean] status of the operation
25
48
  def flush
26
49
  @data.clear
27
50
  end
28
51
 
29
- def exist?(options)
30
- return @data.include? options[:key]
52
+ # verifiy a specific record existence
53
+ # @param key [Symbol] the name of the record
54
+ # @return [Boolean] presence of the record
55
+ def exist?(key:)
56
+ @data.include? key
31
57
  end
32
-
33
58
  end
34
59
  end
35
- end
60
+ end