tiny_tds_wrapper 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 203dc87b1fd6f2b2da628d48d074405a570ef9eb94fa2094480013faebea3342
4
+ data.tar.gz: 9d8a4c0c3553845608953b1a299184bbcbf4af5695c5c7313b9aa951d605d7fb
5
+ SHA512:
6
+ metadata.gz: dbdd4955bea5faebbea70a5ca308bbe89d74d7800677362d32bf5b6826ba7e487bbf44c631661fcab99a000a3e16b0e90efce9fda73c33151d5535984a47a2c4
7
+ data.tar.gz: bba450bf30226ca5d220a3e44c48a53534984cca4ab5a15b7e411ced4cf183748afae737b08da6ddfb58289bfb44158ca4c67f6683f7500461942bea72b00778
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.3.4
7
+ before_install: gem install bundler -v 2.0.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in tiny_tds_wrapper.gemspec
4
+ gemspec
@@ -0,0 +1,36 @@
1
+ # TinyTdsWrapper
2
+
3
+ This wrapper manages connection health. It will reconnnect automatically when TinyTds throws an error. It can be used with connection pooling gems.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'tiny_tds_wrapper'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install tiny_tds_wrapper
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ def prepare_connection_pool!
25
+ @@pool ||= ConnectionPool.new(size: 100, timeout: 5) { TinyTdsWrapper::Client.new(config) }
26
+ end
27
+ ```
28
+ ## Development
29
+
30
+ 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.
31
+
32
+ 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).
33
+
34
+ ## Contributing
35
+
36
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/tiny_tds_wrapper.
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tiny_tds_wrapper"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ require "tiny_tds_wrapper/version"
2
+ require "tiny_tds_wrapper/client"
3
+
4
+ module TinyTdsWrapper
5
+ class Error < StandardError; end
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,36 @@
1
+ require 'tiny_tds'
2
+
3
+ module TinyTdsWrapper
4
+ class Client
5
+ def initialize(config)
6
+ @config = config
7
+ @client = nil
8
+ end
9
+
10
+ private
11
+
12
+ def method_missing(method_name, *args, &block)
13
+ connect!
14
+ begin
15
+ @client.send(method_name, *args, &block)
16
+ rescue TinyTds::Error => e
17
+ disconnect!
18
+ raise e
19
+ end
20
+ end
21
+
22
+ def connect!
23
+ disconnect! if active?
24
+ @client ||= TinyTds::Client.new(@config)
25
+ end
26
+
27
+ def disconnect!
28
+ @client.close if @client
29
+ @client = nil
30
+ end
31
+
32
+ def active?
33
+ !!(@client && @client.active?)
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,3 @@
1
+ module TinyTdsWrapper
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,35 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "tiny_tds_wrapper/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "tiny_tds_wrapper"
7
+ spec.version = TinyTdsWrapper::VERSION
8
+ spec.authors = ["Adam Hallett"]
9
+ spec.email = ["adam.t.hallett@gmail.com"]
10
+
11
+ spec.summary = %q{A self-healing wrapper to be used with connection pooling}
12
+ spec.homepage = "https://github.com/atomical/tiny_tds_wrapper"
13
+
14
+ spec.metadata["allowed_push_host"] = "https://rubygems.org/"
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = spec.homepage
18
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_dependency "tiny_tds"
30
+
31
+ spec.add_development_dependency "bundler", "~> 2.0"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_development_dependency "rspec", "~> 3.0"
34
+ spec.add_development_dependency "simplecov"
35
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tiny_tds_wrapper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Adam Hallett
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-12-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tiny_tds
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ - adam.t.hallett@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - README.md
95
+ - Rakefile
96
+ - bin/console
97
+ - bin/setup
98
+ - lib/tiny_tds_wrapper.rb
99
+ - lib/tiny_tds_wrapper/client.rb
100
+ - lib/tiny_tds_wrapper/version.rb
101
+ - tiny_tds_wrapper.gemspec
102
+ homepage: https://github.com/atomical/tiny_tds_wrapper
103
+ licenses: []
104
+ metadata:
105
+ allowed_push_host: https://rubygems.org/
106
+ homepage_uri: https://github.com/atomical/tiny_tds_wrapper
107
+ source_code_uri: https://github.com/atomical/tiny_tds_wrapper
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.7.10
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: A self-healing wrapper to be used with connection pooling
128
+ test_files: []