thread-inheritable_attributes 1.1.0 → 2.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/README.md +2 -1
- data/lib/thread/inheritable_attributes/version.rb +1 -1
- data/lib/thread/inheritable_attributes.rb +8 -4
- data/thread-inheritable_attributes.gemspec +1 -0
- metadata +19 -6
- data/lib/thread/inheritable_attributes/can_be_loaded.rb +0 -13
- data/lib/thread/inheritable_attributes/request_store.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0dff9811be3da389b911143f7826ceac57d4cce8
|
4
|
+
data.tar.gz: ad8e9c2eb930352265d65092cfc1d41d9ac8ea0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 299a3944ce9339a6772957fdab4e3809a59f5c4fcc994a78ebb3ded1946054e7114cc8d56616fd4bed50b3bfb87f2959f682317597d9a27e4c5fafb45738a68b
|
7
|
+
data.tar.gz: a688d786bf2afc9b500fbf238a24a8607e5892bf20d7e6f8efc049cd44361b12b10d7ecb986797eb706a4fd905217585cdd2141f66b5d71e3773fa019b61bcba
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,11 @@
|
|
1
|
-
##
|
1
|
+
## v2.0.0 - 2016-09-09
|
2
|
+
### Enhancement
|
3
|
+
* RequestStore is now a required dependency
|
4
|
+
|
5
|
+
### Fix
|
6
|
+
* State only flows in one direction into the child threads and not back.
|
7
|
+
|
8
|
+
## v1.1.0 - 2016-06-14
|
2
9
|
|
3
10
|
### Fix
|
4
11
|
Addresses the use of `Thread.current` and the potential issues when used in the context of multi-threaded web server and replaces it with `RequestStore` when the gem can be loaded.
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Thread Inheritable Attributes
|
2
2
|
|
3
3
|
Passes thread variables to child spawned threads. Main use case is enabling logging in child thread to keep context of a request.
|
4
|
+
State only flows in one direction into the child threads and not back.
|
4
5
|
|
5
6
|
## Installation
|
6
7
|
|
@@ -10,7 +11,7 @@ Add this line to your application's Gemfile:
|
|
10
11
|
gem "thread-inheritable_attributes"
|
11
12
|
```
|
12
13
|
|
13
|
-
[request_store](https://github.com/steveklabnik/request_store) is
|
14
|
+
[request_store](https://github.com/steveklabnik/request_store) is a dependency for when working within the context of a multi-threaded web server.
|
14
15
|
In that context Threads can be reused for different request causing state from a previous request to stick around to the next request.
|
15
16
|
Unless your are manually reinitializing or clearing the state in your own Rack Middleware (at the start of a request) it is recommended that you also include the request_store gem.
|
16
17
|
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require "thread"
|
2
|
-
require "
|
2
|
+
require "request_store"
|
3
3
|
|
4
4
|
class Thread
|
5
5
|
INHERITABLE_ATTRIBUTES_MUTEX = Mutex.new
|
6
6
|
alias_method :_initialize, :initialize
|
7
7
|
|
8
8
|
def initialize(*args, &block)
|
9
|
-
_inheritable_attributes = inheritable_attributes
|
9
|
+
_inheritable_attributes = inheritable_attributes.dup
|
10
10
|
_initialize(*args) do |*block_args|
|
11
|
-
|
11
|
+
store[:inheritable_attributes] = _inheritable_attributes
|
12
12
|
block.call(block_args)
|
13
13
|
end
|
14
14
|
end
|
@@ -28,6 +28,10 @@ class Thread
|
|
28
28
|
protected
|
29
29
|
|
30
30
|
def inheritable_attributes
|
31
|
-
|
31
|
+
store[:inheritable_attributes] ||= {}
|
32
|
+
end
|
33
|
+
|
34
|
+
def store
|
35
|
+
RequestStore.store
|
32
36
|
end
|
33
37
|
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:
|
4
|
+
version: 2.0.0.pre
|
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-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: request_store
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
55
69
|
description: Passes thread variables to child spawned threads. Main use case is enabling
|
56
70
|
logging in child thread to keep context of a request.
|
57
71
|
email:
|
@@ -72,8 +86,6 @@ files:
|
|
72
86
|
- bin/console
|
73
87
|
- bin/setup
|
74
88
|
- lib/thread/inheritable_attributes.rb
|
75
|
-
- lib/thread/inheritable_attributes/can_be_loaded.rb
|
76
|
-
- lib/thread/inheritable_attributes/request_store.rb
|
77
89
|
- lib/thread/inheritable_attributes/version.rb
|
78
90
|
- thread-inheritable_attributes.gemspec
|
79
91
|
homepage: https://github.com/zeisler/thread-inheritable_attributes
|
@@ -91,9 +103,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
103
|
version: '0'
|
92
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
105
|
requirements:
|
94
|
-
- - "
|
106
|
+
- - ">"
|
95
107
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
108
|
+
version: 1.3.1
|
97
109
|
requirements: []
|
98
110
|
rubyforge_project:
|
99
111
|
rubygems_version: 2.2.5
|
@@ -101,3 +113,4 @@ signing_key:
|
|
101
113
|
specification_version: 4
|
102
114
|
summary: Passes thread variables to child spawned threads.
|
103
115
|
test_files: []
|
116
|
+
has_rdoc:
|
@@ -1,14 +0,0 @@
|
|
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
|