thread-inheritable_attributes 1.1.0 → 2.0.0.pre

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
  SHA1:
3
- metadata.gz: a3130d7814970966125c54e062264925dba75989
4
- data.tar.gz: 030e341b1d316194ca55ce125b67b74ec94b9f85
3
+ metadata.gz: 0dff9811be3da389b911143f7826ceac57d4cce8
4
+ data.tar.gz: ad8e9c2eb930352265d65092cfc1d41d9ac8ea0c
5
5
  SHA512:
6
- metadata.gz: c10e9d1ff9977fbd4c97fb06557be98aa3b348377391e9175a2f99517ad5a389a109127406876a00739a46996bc7141dba8a55508d46e1d13bb588cd7ffe6868
7
- data.tar.gz: ec351ce13c0974acd328993d799e27fbbe77843833104739d574ce1bf57cbdd78b26c2364bd69664cf7d2d1018288447a948de2a74431f3ae3d5b12e12c3f16c
6
+ metadata.gz: 299a3944ce9339a6772957fdab4e3809a59f5c4fcc994a78ebb3ded1946054e7114cc8d56616fd4bed50b3bfb87f2959f682317597d9a27e4c5fafb45738a68b
7
+ data.tar.gz: a688d786bf2afc9b500fbf238a24a8607e5892bf20d7e6f8efc049cd44361b12b10d7ecb986797eb706a4fd905217585cdd2141f66b5d71e3773fa019b61bcba
data/CHANGELOG.md CHANGED
@@ -1,4 +1,11 @@
1
- ## v1.1.0.beta1 - 2016-06-14
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 an optional dependency for when working within the context of a multi-threaded web server.
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,5 +1,5 @@
1
1
  class Thread
2
2
  module InheritableAttributes
3
- VERSION = "1.1.0"
3
+ VERSION = "2.0.0.pre"
4
4
  end
5
5
  end
@@ -1,14 +1,14 @@
1
1
  require "thread"
2
- require "thread/inheritable_attributes/request_store"
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
- RequestStore[:inheritable_attributes] = _inheritable_attributes
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
- RequestStore[:inheritable_attributes] ||= {}
31
+ store[:inheritable_attributes] ||= {}
32
+ end
33
+
34
+ def store
35
+ RequestStore.store
32
36
  end
33
37
  end
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "bundler", "~> 1.10"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
24
  spec.add_development_dependency "rspec", "~> 3.4"
25
+ spec.add_runtime_dependency "request_store", "~> 1.3"
25
26
  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.1.0
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-06-15 00:00:00.000000000 Z
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: '0'
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,13 +0,0 @@
1
- module CanBeLoaded
2
- def self.call(file)
3
- loaded = false
4
- begin
5
- require file
6
- loaded = true
7
- rescue LoadError => e
8
- raise e unless /^cannot load such file -- #{file}$/ =~ e.message
9
- false
10
- end
11
- loaded
12
- end
13
- end
@@ -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