thread-inheritable_attributes 1.0.0 → 1.1.0.beta1
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 +4 -4
- data/CHANGELOG.md +12 -2
- data/README.md +9 -1
- data/lib/thread/inheritable_attributes.rb +4 -4
- data/lib/thread/inheritable_attributes/can_be_loaded.rb +13 -0
- data/lib/thread/inheritable_attributes/request_store.rb +14 -0
- data/lib/thread/inheritable_attributes/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83c5bf46acdb7eece51054d9dbb2d2c8ba5a7cd3
|
4
|
+
data.tar.gz: e1a1e6199bd7630e7ef75d2c35d005e8e0049366
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfbd56fa3ae6f6ee3033cf2805a2a53f4d998bc208513e8d800da99a4de267e991dea72c70977e152e047f569b87963be85c00efaee180eaa2c4f271f563a239
|
7
|
+
data.tar.gz: dbabee7900d20b1386106ecb4c62c351acae02dd60043a0d67ea042d21a2b302ae08df5c10d32e425c2a1c4d7eed6827759c42b1ad7f212778221a6d2457d9b6
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,19 @@
|
|
1
|
-
##
|
1
|
+
## v1.1.0.beta1 - 2016-06-14
|
2
|
+
|
3
|
+
### Fix
|
4
|
+
Add request_store gem as an optional dependency for when working within the context of a multi-threaded web server.
|
5
|
+
Addresses the use of `Thread.current` and replaces it with `RequestStore` when the gem can be required.
|
6
|
+
|
7
|
+
> if you use Thread.current, and you use [a multi-threaded web server] ..., watch out! Values can stick around longer than you'd expect, and this can cause bugs."
|
8
|
+
|
9
|
+
> -- <cite>[request_store docs](https://github.com/steveklabnik/request_store#the-problem)</cite>
|
10
|
+
|
11
|
+
## v1.0.0 - 2016-05-25
|
2
12
|
|
3
13
|
No changes from v0.2.0, but it is being promoted to production ready.
|
4
14
|
It's been used on multiple production environments for 3 months without issues.
|
5
15
|
|
6
|
-
##
|
16
|
+
## v0.2.0 - 2016-03-14
|
7
17
|
|
8
18
|
### Fix
|
9
19
|
- Addressing issue of args not being passed to thread block when creating a Thread and passing args to the initializer.
|
data/README.md
CHANGED
@@ -10,6 +10,14 @@ Add this line to your application's Gemfile:
|
|
10
10
|
gem "thread-inheritable_attributes"
|
11
11
|
```
|
12
12
|
|
13
|
+
[request_store](https://github.com/steveklabnik/request_store) is an optional dependency for when working within the context of a multi-threaded web server.
|
14
|
+
|
15
|
+
If using Rails no config is required, except including the gem. When using other Rack based frameworks see [docs](https://github.com/steveklabnik/request_store#no-rails-no-problem) for including middleware.
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem "request_store"
|
19
|
+
```
|
20
|
+
|
13
21
|
And then execute:
|
14
22
|
|
15
23
|
$ bundle
|
@@ -41,7 +49,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
41
49
|
|
42
50
|
## Contributing
|
43
51
|
|
44
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
52
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/zeisler/thread_variable_cascade. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
45
53
|
|
46
54
|
|
47
55
|
## License
|
@@ -1,13 +1,14 @@
|
|
1
1
|
require "thread"
|
2
|
+
require "thread/inheritable_attributes/request_store"
|
2
3
|
|
3
4
|
class Thread
|
4
5
|
INHERITABLE_ATTRIBUTES_MUTEX = Mutex.new
|
5
6
|
alias_method :_initialize, :initialize
|
6
7
|
|
7
8
|
def initialize(*args, &block)
|
8
|
-
|
9
|
+
_inheritable_attributes = inheritable_attributes
|
9
10
|
_initialize(*args) do |*block_args|
|
10
|
-
|
11
|
+
RequestStore[:inheritable_attributes] = _inheritable_attributes
|
11
12
|
block.call(block_args)
|
12
13
|
end
|
13
14
|
end
|
@@ -27,7 +28,6 @@ class Thread
|
|
27
28
|
protected
|
28
29
|
|
29
30
|
def inheritable_attributes
|
30
|
-
|
31
|
+
RequestStore[:inheritable_attributes] ||= {}
|
31
32
|
end
|
32
|
-
|
33
33
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "thread/inheritable_attributes/can_be_loaded"
|
2
|
+
|
3
|
+
class Thread
|
4
|
+
if CanBeLoaded.call("request_store") && defined? ::RequestStore
|
5
|
+
request_store_version = Gem::Version.new(::RequestStore::VERSION)
|
6
|
+
if request_store_version >= Gem::Version.new("1.0") && request_store_version < Gem::Version.new("2.0")
|
7
|
+
RequestStore = ::RequestStore
|
8
|
+
else
|
9
|
+
raise "RequestStore version: #{::RequestStore::Version} unsupported"
|
10
|
+
end
|
11
|
+
else
|
12
|
+
RequestStore = Thread.current
|
13
|
+
end
|
14
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thread-inheritable_attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.1.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dustin Zeisler
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,6 +72,8 @@ files:
|
|
72
72
|
- bin/console
|
73
73
|
- bin/setup
|
74
74
|
- lib/thread/inheritable_attributes.rb
|
75
|
+
- lib/thread/inheritable_attributes/can_be_loaded.rb
|
76
|
+
- lib/thread/inheritable_attributes/request_store.rb
|
75
77
|
- lib/thread/inheritable_attributes/version.rb
|
76
78
|
- thread-inheritable_attributes.gemspec
|
77
79
|
homepage: https://github.com/zeisler/thread-inheritable_attributes
|
@@ -89,9 +91,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
91
|
version: '0'
|
90
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
93
|
requirements:
|
92
|
-
- - "
|
94
|
+
- - ">"
|
93
95
|
- !ruby/object:Gem::Version
|
94
|
-
version:
|
96
|
+
version: 1.3.1
|
95
97
|
requirements: []
|
96
98
|
rubyforge_project:
|
97
99
|
rubygems_version: 2.2.5
|