shameless 0.1.0 → 0.2.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: f6279a53b06a5c2ceeb839ecc50eca06951c12f0
4
- data.tar.gz: d8dd4210688a3f72e1ea7574ceeb9f2cb690796d
3
+ metadata.gz: 3243fd35d7a9377bdaccb46cfcbacd03be44c8c7
4
+ data.tar.gz: 9d18df882c3964ca57a387199f191dbfdcbbfd61
5
5
  SHA512:
6
- metadata.gz: 3f69323c0db8d7fbf99018da32f743c6155f98766bd021d92edd9d1932d30294a0c145ca1be5514f2d6a9883ebde836f0e58d5f9fb3aca8fa278447d0e971621
7
- data.tar.gz: d0843089e84f7cc1125166338d1fa38bd8dca4cd5cc3b4fede32cdf79b11854bc86a287e811c9111416b8f9c8111b74cfcfae70c284a6659ae4756b82525901a
6
+ metadata.gz: 7b56807b2507d10c86dbdf502b2031fab3beb79024f385e130bca212a15eb6dca6cd2dc0d7a49e2451f947a9875fb8c3b3e423ef894e7429707991469ffdd524
7
+ data.tar.gz: 9c94897619fd4978e639ff806dcc88625844f13683adc660b28213a67fa64aade9701f23430312ed9b795afa255542beeae0727ce472a7d4f5f3acec0d791231
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ ### 0.2.0 (2016-11-14)
2
+
3
+ * Add `Store#padded_shard` to get the formatted shard number for a shardable value
4
+
5
+ ### 0.1.0 (2016-10-14)
6
+
7
+ * Initial release
data/README.md CHANGED
@@ -53,7 +53,7 @@ Once you've got the Store configured, you can declare models.
53
53
 
54
54
  ### Declaring models
55
55
 
56
- Models specify the kinds of entities you want to persist in your store. Models are simple Ruby classes (even anonymous) that you attach to a `Store` using `Store#attach_to(model)`, e.g.:
56
+ Models specify the kinds of entities you want to persist in your store. Models are simple Ruby classes (even anonymous) that you attach to a `Store` using `Store#attach(model)`, e.g.:
57
57
 
58
58
  ```ruby
59
59
  # app/models/rate.rb
@@ -117,7 +117,7 @@ end
117
117
 
118
118
  Model content is stored in blobs called "cells". You can think of cells as separate model columns that can store rich data structures and can change independently over time. The default cell is called "base" (that's what all model-level accessors delegate to), but you can declare additional cells using `Model.cell`:
119
119
 
120
- ```
120
+ ```ruby
121
121
  class Rate
122
122
  RateStore.attach(self)
123
123
 
@@ -150,7 +150,7 @@ rate.meta.save
150
150
  rates = Rate.where(hotel_id: 1, room_type: '1 bed', check_in_date: Date.today)
151
151
 
152
152
  # Querying by a named index
153
- rates = Rate.secondary.where(hotel_id: 1, gateway: 'pegasus', discount_type: 'geo')
153
+ rates = Rate.secondary_index.where(hotel_id: 1, gateway: 'pegasus', discount_type: 'geo')
154
154
  rates.first[:net_price] # => 130.0
155
155
  ```
156
156
 
@@ -39,6 +39,11 @@ module Shameless
39
39
  end
40
40
  end
41
41
 
42
+ def padded_shard(shardable_value)
43
+ shard = find_shard(shardable_value)
44
+ format_shard(shard)
45
+ end
46
+
42
47
  private
43
48
 
44
49
  def partitions
@@ -50,12 +55,20 @@ module Shameless
50
55
  end
51
56
 
52
57
  def table_name_with_shard(table_name, shard)
53
- padded_shard = shard.to_s.rjust(6, '0')
58
+ padded_shard = format_shard(shard)
54
59
  "#{table_name}_#{padded_shard}"
55
60
  end
56
61
 
62
+ def format_shard(shard)
63
+ shard.to_s.rjust(6, '0')
64
+ end
65
+
66
+ def find_shard(shardable_value)
67
+ shardable_value % @configuration.shards_count
68
+ end
69
+
57
70
  def find_table(table_name, shardable_value)
58
- shard = shardable_value % @configuration.shards_count
71
+ shard = find_shard(shardable_value)
59
72
  partition = find_partition_for_shard(shard)
60
73
  table_name = table_name_with_shard(table_name, shard)
61
74
  partition.from(table_name)
@@ -1,3 +1,3 @@
1
1
  module Shameless
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/shameless.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["Olek Janiszewski"]
9
9
  spec.email = ["olek@hoteltonight.com"]
10
10
 
11
- spec.summary = %q{Scalable distributed append-only data store built}
11
+ spec.summary = %q{Scalable distributed append-only data store}
12
12
  spec.homepage = "https://github.com/hoteltonight/shameless"
13
13
  spec.license = "MIT"
14
14
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shameless
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olek Janiszewski
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-14 00:00:00.000000000 Z
11
+ date: 2016-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -104,6 +104,7 @@ files:
104
104
  - ".gitignore"
105
105
  - ".rspec"
106
106
  - ".travis.yml"
107
+ - CHANGELOG.md
107
108
  - Gemfile
108
109
  - LICENSE.txt
109
110
  - README.md
@@ -142,5 +143,5 @@ rubyforge_project:
142
143
  rubygems_version: 2.5.1
143
144
  signing_key:
144
145
  specification_version: 4
145
- summary: Scalable distributed append-only data store built
146
+ summary: Scalable distributed append-only data store
146
147
  test_files: []