flux_capacitor 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/flux_capacitor.gemspec +3 -1
- data/lib/flux_capacitor/version.rb +1 -1
- metadata +6 -78
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f897fe1d5f357c010758842c3407fddbf9f7aa1
|
4
|
+
data.tar.gz: 4d5d8cf4934e2429eec97d3071dbd6bc99da91b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bd742e6e19b0d46e9ae0e8891a9c0ec59df0ea78629e51f488c09c736fe2f0160fa7fdb8f9ab93daaf9a1e85c83eba01ca5779f2a63dc2ba684eafe328f912c
|
7
|
+
data.tar.gz: b7fef45c25100bc5448d432bcb2bd1e9c05dfdd3dffde97716d249c37e3843bce06bcea35887945cd75b1acd638e4d45eef686004caf167d4e73f16c9398707b
|
data/flux_capacitor.gemspec
CHANGED
@@ -10,7 +10,9 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["raphaeleidus@gmail.com"]
|
11
11
|
|
12
12
|
spec.summary = %q{Utility for progressively rolling out a feature to existing content}
|
13
|
-
spec.description =
|
13
|
+
spec.description = %q{When you have some service that might not be able to handle a large transition of historical content, say a dynamic image service.
|
14
|
+
Instead of changing everything at once you can use the flux capacitor to progressively enable the new functionality based on content age.}
|
15
|
+
spec.extra_rdoc_files = ['README.md']
|
14
16
|
spec.homepage = "https://github.com/raphaeleidus/flux_capacitor"
|
15
17
|
|
16
18
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flux_capacitor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raphael Eidus
|
@@ -66,87 +66,15 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.0'
|
69
|
-
description:
|
70
|
-
|
71
|
-
|
72
|
-
# FluxCapacitor
|
73
|
-
|
74
|
-
Sometimes you want to change a feature or deploy a new feature but doing so all at once might take down some service. Enter Flux Capacitor. It allows you to gradually include more historical content in the new feature while allowing all future content to start out with the new feature already live.
|
75
|
-
|
76
|
-
## Installation
|
77
|
-
|
78
|
-
Add this line to your application's Gemfile:
|
79
|
-
|
80
|
-
```ruby
|
81
|
-
gem 'flux_capacitor'
|
82
|
-
```
|
83
|
-
|
84
|
-
And then execute:
|
85
|
-
|
86
|
-
$ bundle
|
87
|
-
|
88
|
-
Or install it yourself as:
|
89
|
-
|
90
|
-
$ gem install flux_capacitor
|
91
|
-
|
92
|
-
## Usage
|
93
|
-
|
94
|
-
```ruby
|
95
|
-
require 'flux_capacitor'
|
96
|
-
|
97
|
-
pivot = DateTime.parse('2017/08/14 00:00:00-000') # when do you want to start rolling out the feature
|
98
|
-
oldest = MyModel.first.created_at # If you are using active record finding your oldest item is pretty easy
|
99
|
-
# otherwise if you know the date of your first item, just use that
|
100
|
-
end_point = DateTime.parse('2017/09/14') # The point where the feature is fully rolled out/safe to remove the Flux Capacitor.
|
101
|
-
# This dictates how quickly the feature rolls out. If you are concerned about overloading a required service set this to farther in the future
|
102
|
-
|
103
|
-
FEATURE_1_CAPACITOR = Flux::Capacitor.new(pivot, end_point, oldest)
|
104
|
-
|
105
|
-
def controller_method
|
106
|
-
model = MyModel.find(params[:id])
|
107
|
-
if FEATURE_1_CAPACITOR.travel_to?(model.created_at)
|
108
|
-
use_new_feature
|
109
|
-
else
|
110
|
-
use_old_feature
|
111
|
-
end
|
112
|
-
end
|
113
|
-
```
|
114
|
-
|
115
|
-
If your feature doesn't map well to something where you have a date for each piece of content you can still use flux capacitor. It can also take strings and distribute them evenly over your rollout period using the murmur3 hashing algorithm.
|
116
|
-
```ruby
|
117
|
-
require 'flux_capacitor'
|
118
|
-
pivot = DateTime.parse('2017/08/14 00:00:00-000') # when do you want to start rolling out the feature
|
119
|
-
end_point = DateTime.parse('2017/09/14') # when do you want the rollout to finish
|
120
|
-
|
121
|
-
# NOTE: We don't need an oldest date when using strings
|
122
|
-
FEATURE_1_CAPACITOR = Flux::Capacitor.new(pivot, end_point)
|
123
|
-
|
124
|
-
def controller_method
|
125
|
-
model = MyModel.find(params[:id])
|
126
|
-
if FEATURE_1_CAPACITOR.travel_to?(model.uuid)
|
127
|
-
use_new_feature
|
128
|
-
else
|
129
|
-
use_old_feature
|
130
|
-
end
|
131
|
-
end
|
132
|
-
```
|
133
|
-
|
134
|
-
One note about using the string hashing method, new content could get the old feature for a while.
|
135
|
-
|
136
|
-
## Development
|
137
|
-
|
138
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
139
|
-
|
140
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
141
|
-
|
142
|
-
## Contributing
|
143
|
-
|
144
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/raphaeleidus/flux_capacitor.
|
69
|
+
description: |-
|
70
|
+
When you have some service that might not be able to handle a large transition of historical content, say a dynamic image service.
|
71
|
+
Instead of changing everything at once you can use the flux capacitor to progressively enable the new functionality based on content age.
|
145
72
|
email:
|
146
73
|
- raphaeleidus@gmail.com
|
147
74
|
executables: []
|
148
75
|
extensions: []
|
149
|
-
extra_rdoc_files:
|
76
|
+
extra_rdoc_files:
|
77
|
+
- README.md
|
150
78
|
files:
|
151
79
|
- ".gitignore"
|
152
80
|
- ".rspec"
|