fino 1.8.3 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92ab588981e1a3a7114f23e7c5fc19cd2821477bc8060170646d6366e1ccb300
4
- data.tar.gz: cea52b769341254d49f214ad44577203580ede4c35e9fbfd00454510d6f1a6b8
3
+ metadata.gz: 3acbc23a5c705d61f9d9a3f9f570e262fe96b940b523aa10a9edc0dbc3738545
4
+ data.tar.gz: 02bba82e7d24a7939f1e54e4e17610920a18d5efa6244cdd689bc74ef1fac15b
5
5
  SHA512:
6
- metadata.gz: ad589f2f78feca10e4d5fedbc0947806e1d9f6f333288b7bc8b1996624db5480e052d00d4dbdb9cd70b7e0cff64fbbabbcc2b7cd8e65eec2ca86a512bbf657fc
7
- data.tar.gz: c9a16f21aa25f339bf158dc7fd33b1513cc9e877f2c561c4ac7e7a0c261ac4e2e3e3a469da3bb9aa75bc0f50defda70aca80f7c750b62cda943d874cd8c9e8bb
6
+ metadata.gz: 3554875390236803ebc23b16ff603bcca22a6061c8c3579b99dd678c7b74c938196e26713214707372d5dc25a6d3348c4e872960fc844a9b59810e43554113e4
7
+ data.tar.gz: 16287e6c8bb34a13190352eecfe8ece1b3749afcee996bedd1a8d8e797a5e9aa45fb852677fe379faf48e44eed8edb0dc007dc1d2500eb2c110976f201d16cec
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # Fino
2
2
 
3
- ⚠️ Fino in active development phase at wasn't properly battle tested in production just yet. Give us a star and stay tuned for Production test results and new features
3
+ Fino is plug & play distributed settings engine for Ruby and Rails
4
4
 
5
- Fino is a dynamic settings engine for Ruby and Rails
5
+ - Blazing fast reads with multiple adapers (Redis, Active Record)
6
+ - Out of the box UI
7
+ - A/B test and override settings on the go
6
8
 
7
9
  ## Usage
8
10
 
@@ -139,6 +141,31 @@ Fino.value(:http_read_timeout, at: :my_micro_service, unit: :sec) #=> 0.2
139
141
  Fino.setting(:http_read_timeout, at: :my_micro_service).value(unit: :sec) #=> 0.2
140
142
  ```
141
143
 
144
+ ### Callbacks
145
+
146
+ Fino provides callbacks configuration that will be called once some particular action is triggered:
147
+
148
+ - `after_write` - yields `setting_definition`, `value`, `overrides` and `variants`, is triggered when setting is updated
149
+
150
+ ```ruby
151
+ Fino.configure do
152
+ # ...
153
+
154
+ after_write do |setting_definition, value, overrides, variants|
155
+ next unless setting_definition.tags.include?(:monitor)
156
+
157
+ Monitor.track_changes("Set #{setting_definition.key} to #{value}")
158
+ end
159
+
160
+ settings do
161
+ setting :maintenance_mode, :boolean, default: false
162
+
163
+ setting :http_read_timeout, :integer, unit: :ms, default: 200, tags: %i[monitor]
164
+ setting :http_open_timeout, :integer, unit: :ms, default: 500, tags: %i[monitor]
165
+ end
166
+ end
167
+ ```
168
+
142
169
  ## Rails integration
143
170
 
144
171
  Fino easily integrates with Rails. Just add the gem to your Gemfile:
data/lib/fino/cache.rb CHANGED
@@ -13,11 +13,11 @@ module Fino::Cache
13
13
  raise NotImplementedError
14
14
  end
15
15
 
16
- def fetch(key, &block)
16
+ def fetch(key, &)
17
17
  raise NotImplementedError
18
18
  end
19
19
 
20
- def fetch_multi(*keys, &block)
20
+ def fetch_multi(*keys, &)
21
21
  raise NotImplementedError
22
22
  end
23
23
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Fino::Configuration
4
- attr_reader :registry, :pipeline_builder_block
4
+ attr_reader :registry, :pipeline_builder_block, :after_write_block
5
5
 
6
6
  def initialize(registry)
7
7
  @registry = registry
@@ -37,7 +37,11 @@ class Fino::Configuration
37
37
  @pipeline_builder_block = block
38
38
  end
39
39
 
40
- def settings(&block)
41
- Fino::Registry::DSL.new(registry).instance_eval(&block)
40
+ def after_write(&block)
41
+ @after_write_block = block
42
+ end
43
+
44
+ def settings(&)
45
+ Fino::Registry::DSL.new(registry).instance_eval(&)
42
46
  end
43
47
  end
@@ -35,6 +35,10 @@ class Fino::Definition::Setting
35
35
  defined?(@description) ? @description : @description = options[:description]
36
36
  end
37
37
 
38
+ def tags
39
+ defined?(@tags) ? @tags : @tags = options[:tags] || []
40
+ end
41
+
38
42
  def path
39
43
  @path ||= [setting_name, section_definition&.name].compact
40
44
  end
data/lib/fino/library.rb CHANGED
@@ -124,7 +124,7 @@ class Fino::Library
124
124
  end
125
125
 
126
126
  def storage
127
- Fino::Pipe::Storage.new(adapter)
127
+ Fino::Pipe::Storage.new(adapter, configuration)
128
128
  end
129
129
 
130
130
  def adapter
data/lib/fino/metadata.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "./version"
3
+ require_relative "version"
4
4
 
5
5
  module Fino
6
6
  module_function
@@ -3,8 +3,9 @@
3
3
  class Fino::Pipe::Storage
4
4
  include Fino::Pipe
5
5
 
6
- def initialize(adapter)
6
+ def initialize(adapter, configuration)
7
7
  @adapter = adapter
8
+ @configuration = configuration
8
9
  end
9
10
 
10
11
  def read(setting_definition)
@@ -18,12 +19,14 @@ class Fino::Pipe::Storage
18
19
  end
19
20
 
20
21
  def write(setting_definition, value, overrides, variants)
21
- adapter.write(setting_definition, value, overrides, variants)
22
+ adapter.write(setting_definition, value, overrides, variants).tap do
23
+ configuration.after_write_block&.call(setting_definition, value, overrides, variants)
24
+ end
22
25
  end
23
26
 
24
27
  private
25
28
 
26
- attr_reader :adapter
29
+ attr_reader :adapter, :configuration
27
30
 
28
31
  def to_setting(setting_definition, raw_adapter_data)
29
32
  raw_value = adapter.fetch_value_from(raw_adapter_data)
data/lib/fino/registry.rb CHANGED
@@ -37,7 +37,7 @@ class Fino::Registry
37
37
  )
38
38
  end
39
39
 
40
- def section(section_name, options = {}, &block)
40
+ def section(section_name, options = {}, &)
41
41
  section_definition = Fino::Definition::Section.new(
42
42
  name: section_name,
43
43
  **options
@@ -45,7 +45,7 @@ class Fino::Registry
45
45
 
46
46
  @registry.register_section(section_definition)
47
47
 
48
- SectionDSL.new(section_definition, @registry).instance_eval(&block)
48
+ SectionDSL.new(section_definition, @registry).instance_eval(&)
49
49
  end
50
50
  end
51
51
 
data/lib/fino/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fino
4
- VERSION = "1.8.3"
5
- REQUIRED_RUBY_VERSION = ">= 3.0.0"
4
+ VERSION = "1.9.0"
5
+ REQUIRED_RUBY_VERSION = ">= 3.2.0"
6
6
  end
data/lib/fino.rb CHANGED
@@ -5,8 +5,8 @@ require "zeitwerk"
5
5
 
6
6
  module Fino
7
7
  module Stateful
8
- def configure(&block)
9
- configuration.instance_eval(&block)
8
+ def configure(&)
9
+ configuration.instance_eval(&)
10
10
  end
11
11
 
12
12
  def reset!
@@ -15,9 +15,9 @@ module Fino
15
15
  @configuration = nil
16
16
  end
17
17
 
18
- def reconfigure(&block)
18
+ def reconfigure(&)
19
19
  reset!
20
- configure(&block)
20
+ configure(&)
21
21
  end
22
22
 
23
23
  def library
@@ -68,7 +68,7 @@ module Fino
68
68
  Logger.new($stdout).tap do |l|
69
69
  l.progname = name
70
70
  l.level = ENV.fetch("FINO_LOG_LEVEL", "info")
71
- l.formatter = proc do |severity, datetime, progname, msg|
71
+ l.formatter = proc do |severity, _datetime, progname, msg|
72
72
  "[#{progname}] #{severity}: #{msg}\n"
73
73
  end
74
74
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fino
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.3
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Egor Iskrenkov
@@ -83,7 +83,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
83
83
  requirements:
84
84
  - - ">="
85
85
  - !ruby/object:Gem::Version
86
- version: 3.0.0
86
+ version: 3.2.0
87
87
  required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  requirements:
89
89
  - - ">="
@@ -92,5 +92,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  requirements: []
93
93
  rubygems_version: 3.6.9
94
94
  specification_version: 4
95
- summary: Elegant & performant settings engine for Ruby and Rails
95
+ summary: Plug & play distributed settings engine for Ruby and Rails
96
96
  test_files: []