sequel-schema-sharding 0.9.1 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea4a2b527ce17f8307ddd24be978f68bcd39b6bc
4
- data.tar.gz: d4bb27788548838a33fd44f0c22b805911c275b0
3
+ metadata.gz: e8b1bb945b2bfeb51b502e79ae7199b9a15ac979
4
+ data.tar.gz: c644252bbcd60dc5c054208f366ef04706317d6d
5
5
  SHA512:
6
- metadata.gz: 25c8ec3fe83a20bc5e5a4709f92f6a2627efbd2ae18d8e7ed806a6fa02cc73e9b7ab4f429d906f972264c8d6fd82796997c23e67a87d876c24ba812484ecb9d0
7
- data.tar.gz: 408b96aae129a274e553e7abab512da3c19cb8a9de1f43c93736e1bf91bdebeacfda95aeb06aa89b5a4ee3019bcb114295cedaf59a7633f28d8be2bce78450d3
6
+ metadata.gz: fb2a36a6a4bbad5a40edfb9922ff132c0019f633f0f6ee03c9eabef4def14c13c3bbc0df82141939efb708b4ae845ed7e4ca04b2f49eab840514185143daf61f
7
+ data.tar.gz: 7d3dc3295513f7fc896b3686b48e467e1a06ba7026c0c6efea08c70f1b38efe31b8c49dae86cdc24d2e40d8ca3e776bfce45102afba393889b10148202e5e6db
data/Gemfile CHANGED
@@ -8,4 +8,7 @@ group :test do
8
8
  gem 'mocha', require: false
9
9
  gem 'pry-nav'
10
10
  gem 'guard-rspec'
11
+
12
+ # for testing purposes until pull request is accepted
13
+ gem 'ruby-usdt', github: 'sax/ruby-usdt', ref: 'probe-introspection', submodules: true
11
14
  end
@@ -1,6 +1,7 @@
1
1
  require 'logger'
2
2
  require 'sequel'
3
3
  require 'sequel/schema-sharding/version'
4
+ require 'sequel/schema-sharding/dtrace_provider'
4
5
  require 'sequel/schema-sharding/configuration'
5
6
  require 'sequel/schema-sharding/connection_manager'
6
7
  require 'sequel/schema-sharding/database_manager'
@@ -0,0 +1,25 @@
1
+ require 'usdt'
2
+
3
+ module Sequel
4
+ module SchemaSharding
5
+ class DTraceProvider
6
+ attr_reader :provider
7
+
8
+ def initialize
9
+ @provider = USDT::Provider.create(:ruby, :sequel_schema_sharding)
10
+ end
11
+
12
+ def read_only_shard_for
13
+ @read_only_probe ||= provider.probe(:model, :read_only_shard_for, :string)
14
+ end
15
+
16
+ def self.provider
17
+ @provider ||= new.tap do |p|
18
+ p.read_only_shard_for
19
+ p.provider.enable
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+
@@ -57,6 +57,7 @@ module Sequel
57
57
  end
58
58
 
59
59
  def read_only_shard_for(id)
60
+ Sequel::SchemaSharding::DTraceProvider.provider.read_only_shard_for.fire(id.to_s) if Sequel::SchemaSharding::DTraceProvider.provider.read_only_shard_for.enabled?
60
61
  shard_for(id).server(:read_only)
61
62
  end
62
63
 
@@ -1,5 +1,5 @@
1
1
  module Sequel
2
2
  module SchemaSharding
3
- VERSION = "0.9.1"
3
+ VERSION = "0.10.0"
4
4
  end
5
5
  end
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency 'sequel'
22
22
  spec.add_dependency 'pg'
23
23
  spec.add_dependency 'sequel-replica-failover'
24
+ spec.add_dependency 'ruby-usdt'
24
25
 
25
26
  spec.add_development_dependency 'bundler', '~> 1.3'
26
27
  spec.add_development_dependency 'rake'
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sequel::SchemaSharding::DTraceProvider do
4
+ describe 'initialize' do
5
+ it 'creates a new provider' do
6
+ USDT::Provider.expects(:create).with(:ruby, :sequel_schema_sharding)
7
+ Sequel::SchemaSharding::DTraceProvider.new
8
+ end
9
+ end
10
+
11
+ describe 'probes' do
12
+ let(:provider) { Sequel::SchemaSharding::DTraceProvider.new }
13
+
14
+ describe '#read_only_shard_for' do
15
+ it 'is a probe' do
16
+ expect(provider.read_only_shard_for).to be_a USDT::Probe
17
+ end
18
+
19
+ it 'has :model for its function' do
20
+ expect(provider.read_only_shard_for.function).to eq(:model)
21
+ end
22
+
23
+ it 'has :read_only_shard_for for its name' do
24
+ expect(provider.read_only_shard_for.name).to eq(:read_only_shard_for)
25
+ end
26
+
27
+ it 'takes a string argument' do
28
+ expect(provider.read_only_shard_for.arguments).to eq([:string])
29
+ end
30
+ end
31
+ end
32
+
33
+ describe '::provider' do
34
+ it 'returns a DTraceProvider' do
35
+ provider = Sequel::SchemaSharding::DTraceProvider.provider
36
+ expect(provider).to be_a(Sequel::SchemaSharding::DTraceProvider)
37
+ end
38
+ end
39
+ end
40
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel-schema-sharding
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Henry
@@ -54,6 +54,20 @@ dependencies:
54
54
  - - '>='
55
55
  - !ruby/object:Gem::Version
56
56
  version: '0'
57
+ - !ruby/object:Gem::Dependency
58
+ name: ruby-usdt
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ type: :runtime
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
57
71
  - !ruby/object:Gem::Dependency
58
72
  name: bundler
59
73
  requirement: !ruby/object:Gem::Requirement
@@ -109,6 +123,7 @@ files:
109
123
  - lib/sequel/schema-sharding/connection_manager.rb
110
124
  - lib/sequel/schema-sharding/database_manager.rb
111
125
  - lib/sequel/schema-sharding/database_manager/schema_iterator.rb
126
+ - lib/sequel/schema-sharding/dtrace_provider.rb
112
127
  - lib/sequel/schema-sharding/extensions/migrations_ext.rb
113
128
  - lib/sequel/schema-sharding/extensions/sequel_ext.rb
114
129
  - lib/sequel/schema-sharding/finder.rb
@@ -127,6 +142,7 @@ files:
127
142
  - spec/schema-sharding/connection_manager_spec.rb
128
143
  - spec/schema-sharding/database_manager/schema_iterator_spec.rb
129
144
  - spec/schema-sharding/database_manager_spec.rb
145
+ - spec/schema-sharding/dtrace_provider_spec.rb
130
146
  - spec/schema-sharding/finder_spec.rb
131
147
  - spec/schema-sharding/model_spec.rb
132
148
  - spec/schema-sharding/ring_spec.rb
@@ -165,6 +181,7 @@ test_files:
165
181
  - spec/schema-sharding/connection_manager_spec.rb
166
182
  - spec/schema-sharding/database_manager/schema_iterator_spec.rb
167
183
  - spec/schema-sharding/database_manager_spec.rb
184
+ - spec/schema-sharding/dtrace_provider_spec.rb
168
185
  - spec/schema-sharding/finder_spec.rb
169
186
  - spec/schema-sharding/model_spec.rb
170
187
  - spec/schema-sharding/ring_spec.rb