flux_capacitor 0.1.1 → 0.1.2
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 +1 -2
- data/lib/flux_capacitor/version.rb +1 -1
- metadata +77 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4107cf109861cb1776c98c445095f3570ed0e10
|
4
|
+
data.tar.gz: e2ec734dcb62f0d1f06a3de91b914cee9e53ef31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02ef0c049f13c79cb14cff6c2fcd699b4720f6cf6561b54de17e678daee5e4cdc9ffebb7ed05742d3176ce283d85ed4bee0e4094553dacd385db951d400afbcd
|
7
|
+
data.tar.gz: 457b0cc03af39e3a4dd1ddc38a01a0a6dbd3ffbd0d5d760d5bf6484162e7b5c881ccc5ac4a6847b9760019a00d4c96a2941ca0c01f7169a67c3888b19bd79665
|
data/flux_capacitor.gemspec
CHANGED
@@ -10,8 +10,7 @@ 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 =
|
14
|
-
Instead of changing everything at once you can use the flux capacitor to progressively enable the new functionality based on content age.}
|
13
|
+
spec.description = File.read('README.md')
|
15
14
|
spec.homepage = "https://github.com/raphaeleidus/flux_capacitor"
|
16
15
|
|
17
16
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raphael Eidus
|
@@ -66,9 +66,82 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.0'
|
69
|
-
description:
|
70
|
-
|
71
|
-
|
69
|
+
description: |
|
70
|
+
[![Gem Version](https://badge.fury.io/rb/flux_capacitor.svg)](https://badge.fury.io/rb/flux_capacitor)
|
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.
|
72
145
|
email:
|
73
146
|
- raphaeleidus@gmail.com
|
74
147
|
executables: []
|