forkhandle 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OTFhNWJkZjkxYTI2ODhlNzZmMjZjYjM3NGVmMDNhNmE2NmU0ODBhNQ==
5
+ data.tar.gz: !binary |-
6
+ ZWMxZTVhYTZmZDI1Y2Y1NWEzZjhjZjZkNTAwNDJiNzg4NTdiNDU2Yg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ Y2QwNzdiZTE0N2VlZGUwNTllODNjNjlkNWZiMTFjNWQzMDUwYjkxNzA4ZDMx
10
+ NjA4MTg5ZDE1NzAxNjdmZWYwY2I4YTYxZTNmYjk0NzA5ZTUzMjlhMzk4NzEw
11
+ ZjhhMDFkYTY3NjFkNDc4N2JmNTkwMGY2Mjc1NGE0MmQ4NWQ3YmM=
12
+ data.tar.gz: !binary |-
13
+ Mjk5Y2U5Zjg3YWZlMzkzZDQyNzdlYmY5MTMyYTgwYzllODQxMTljMjJjMGU0
14
+ NjBiZTEzN2YyZjg3YzY4MzM1ZjNkZDQ2ZmE1ZmJlOWVlZjI2N2FiYzkwY2Qw
15
+ OWNkOGE1OTZhZjMxMDQ5MDkyYTMwMjJiZGZiNjRjOTY4MTJlNTU=
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ NAME
2
+ ----
3
+ forkhandle
4
+
5
+ SYNOPSIS
6
+ --------
7
+
8
+ connection = ForkHandle.get(:db_connection){ Db.connect(config) }
9
+
10
+
11
+ DESCRIPTION
12
+ -----------
13
+
14
+ managing connection across forks and threads is tricky. most libraries use
15
+ and icky idiom that requires each and every client to configure it's own
16
+ forking logic, something like
17
+
18
+ MyLameLib.after_fork do
19
+
20
+ # close handles you should close
21
+
22
+ end
23
+
24
+ many libs also do not provide you with per-thread connection, making MT a
25
+ manual process.
26
+
27
+ a teeny bit of code can solve both. the concept is simple:
28
+
29
+ maintain a table of connections scoped by process id and thread id. any
30
+ miss will trigger auto-scrubbing the table, but only connections from
31
+ another process (we've been forked) will be closed. this gives
32
+
33
+ * per thread connections
34
+
35
+ * per process connections
36
+
37
+ * auto-matic cleanup after a fork
38
+
data/Rakefile CHANGED
@@ -32,7 +32,7 @@ def run_tests!(which = nil)
32
32
 
33
33
  test_rbs.each_with_index do |test_rb, index|
34
34
  testno = index + 1
35
- command = "#{ This.ruby } -I ./lib -I ./test/lib #{ test_rb }"
35
+ command = "#{ This.ruby } -w -I ./lib -I ./test/lib #{ test_rb }"
36
36
 
37
37
  puts
38
38
  say(div, :color => :cyan, :bold => true)
@@ -93,6 +93,7 @@ task :gemspec do
93
93
  test_files = "test/#{ lib }.rb" if File.file?("test/#{ lib }.rb")
94
94
  summary = object.respond_to?(:summary) ? object.summary : "summary: #{ lib } kicks the ass"
95
95
  description = object.respond_to?(:description) ? object.description : "description: #{ lib } kicks the ass"
96
+ license = object.respond_to?(:license) ? object.license : "same as ruby's"
96
97
 
97
98
  if This.extensions.nil?
98
99
  This.extensions = []
@@ -118,6 +119,7 @@ task :gemspec do
118
119
  spec.platform = Gem::Platform::RUBY
119
120
  spec.summary = #{ lib.inspect }
120
121
  spec.description = #{ description.inspect }
122
+ spec.license = #{ license.inspect }
121
123
 
122
124
  spec.files =\n#{ files.sort.pretty_inspect }
123
125
  spec.executables = #{ executables.inspect }
@@ -178,8 +180,8 @@ task :readme do
178
180
  end
179
181
 
180
182
  template =
181
- if test(?e, 'readme.erb')
182
- Template{ IO.read('readme.erb') }
183
+ if test(?e, 'README.erb')
184
+ Template{ IO.read('README.erb') }
183
185
  else
184
186
  Template {
185
187
  <<-__
data/forkhandle.gemspec CHANGED
@@ -3,13 +3,14 @@
3
3
 
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "forkhandle"
6
- spec.version = "0.0.1"
6
+ spec.version = "0.0.2"
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.summary = "forkhandle"
9
- spec.description = "description: forkhandle kicks the ass"
9
+ spec.description = "a teeny library / design pattern for managing connections in a process and thread safe fashion"
10
+ spec.license = "same as ruby's"
10
11
 
11
12
  spec.files =
12
- ["Rakefile", "forkhandle.gemspec", "lib", "lib/forkhandle.rb"]
13
+ ["README.md", "Rakefile", "forkhandle.gemspec", "lib", "lib/forkhandle.rb"]
13
14
 
14
15
  spec.executables = []
15
16
 
data/lib/forkhandle.rb CHANGED
@@ -1,29 +1,10 @@
1
- # managing connection across forks and threads is tricky. most libraries use
2
- # and icky idiom that requires each and every client to configure it's own
3
- # forking logic, something like
4
- #
5
- # MyLameLib.after_for do
6
- # # close handles you should close
7
- # end
8
- #
9
- # many libs also do not provide you with per-thread connection, making MT a
10
- # manual process.
11
- #
12
- # a teeny bit of code can solve both. the concept is simple:
13
- #
14
- # maintain a table of connections scoped by process id and thread id. any
15
- # miss will trigger auto-scrubbing the table, but only connections from
16
- # another process (we've been forked) will be closed. this gives
17
- #
18
- # * per thread connections
19
- #
20
- # * per process connections
21
- #
22
- # * auto-matic cleanup after a fork
23
- #
24
1
  module ForkHandle
25
2
  def version
26
- '0.0.1'
3
+ '0.0.2'
4
+ end
5
+
6
+ def description
7
+ "a teeny library / design pattern for managing connections in a process and thread safe fashion"
27
8
  end
28
9
 
29
10
  @handles = Hash.new
@@ -84,13 +65,3 @@ module ForkHandle
84
65
  end
85
66
 
86
67
  Forkhandle = ForkHandle
87
-
88
-
89
- __END__
90
-
91
- ForkHandle.get(:default){ build_default_connection }
92
-
93
- ForkHandle.set(:default, build_default_connection)
94
-
95
-
96
-
metadata CHANGED
@@ -1,47 +1,48 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forkhandle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ara T. Howard
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-06-19 00:00:00.000000000 Z
11
+ date: 2014-02-13 00:00:00.000000000 Z
13
12
  dependencies: []
14
- description: ! 'description: forkhandle kicks the ass'
13
+ description: a teeny library / design pattern for managing connections in a process
14
+ and thread safe fashion
15
15
  email: ara.t.howard@gmail.com
16
16
  executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - README.md
20
21
  - Rakefile
21
22
  - forkhandle.gemspec
22
23
  - lib/forkhandle.rb
23
24
  homepage: https://github.com/ahoward/forkhandle
24
- licenses: []
25
+ licenses:
26
+ - same as ruby's
27
+ metadata: {}
25
28
  post_install_message:
26
29
  rdoc_options: []
27
30
  require_paths:
28
31
  - lib
29
32
  required_ruby_version: !ruby/object:Gem::Requirement
30
- none: false
31
33
  requirements:
32
34
  - - ! '>='
33
35
  - !ruby/object:Gem::Version
34
36
  version: '0'
35
37
  required_rubygems_version: !ruby/object:Gem::Requirement
36
- none: false
37
38
  requirements:
38
39
  - - ! '>='
39
40
  - !ruby/object:Gem::Version
40
41
  version: '0'
41
42
  requirements: []
42
43
  rubyforge_project: codeforpeople
43
- rubygems_version: 1.8.23
44
+ rubygems_version: 2.0.3
44
45
  signing_key:
45
- specification_version: 3
46
+ specification_version: 4
46
47
  summary: forkhandle
47
48
  test_files: []