dogtag 1.2.1 → 1.2.2

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: 30994b71b3d3f4fe46d6bad9f37697714d50a404
4
- data.tar.gz: 1839f477f5d8dff1fe188ee9326e24302989c82a
3
+ metadata.gz: 6b6c81c67e8ff11a656633eebeb2677e2b7bfd77
4
+ data.tar.gz: 73a06d852bac9ac5cbda1755422e0820c341d210
5
5
  SHA512:
6
- metadata.gz: 6ba8b3146e0706823746fbe630376e35450615dcbe789db138aedf0dfd668f62abbcc3557ae57e28780191ce796fe90809519633c3c4c45897d229fc3be0f480
7
- data.tar.gz: 501efc644f6547948545706bf2796a79a19470bc536e2ac396e6804c15ba1cfaebe6592d347b14b9221adc85c693366715c1e012d586609e2b23ffb7bbd87e9a
6
+ metadata.gz: 3e30da8fd34c6891f341b871d2bc791c79959c4072307e7eebe4d85f1b568d8a837856fe16bb4a12728f840ace00b840895d26d399435a6dd03570369ae7ff67
7
+ data.tar.gz: 52f52d6a11de81bf2b3e3ebbc8f1eaf0928cf877e09547c6fad61ee89dd8c0f8ebc4d40e21a344a28061fdbb5c76b1899c6bbb9b3adff1158529aed1fe135971
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
- Dogtag
2
- ======
1
+ Dogtag [![Code Climate](https://codeclimate.com/repos/5942bc55a2d69c025b00037d/badges/9f08a12606fdc4e23360/gpa.svg)](https://codeclimate.com/repos/5942bc55a2d69c025b00037d/feed) [![Build Status](https://travis-ci.com/zillyinc/dogtag.svg?token=zLzTcsQJDEyJnTYpWzNq&branch=master)](https://travis-ci.com/zillyinc/dogtag)
2
+ ============
3
3
 
4
4
  A Redis-powered Ruby client for generating unique IDs with Redis for use in distributed systems. Based heavily off of [Icicle](https://github.com/intenthq/icicle/) and [Twitter Snowflake](https://github.com/intenthq/icicle/)
5
5
 
@@ -16,7 +16,7 @@ Simply add `gem 'dogtag'` to your `Gemfile` and run `bundle`
16
16
  Configuration
17
17
  -------------
18
18
 
19
- To configure the connection to your Redis server simply set a `DOGTAG_REDIS_URL` or `REDIS_URL` environment variable. Dogtag will first look for the `DOGTAG_REDIS_URL`, then `REDIS_URL`. If neither are found it will default to `redis://localhost:6379`.
19
+ To configure the connection to your Redis server simply set a `DOGTAG_REDIS_URL` or `REDIS_URL` environment variable. Dogtag will first look for the `DOGTAG_REDIS_URL`, then `REDIS_URL`. If neither are found it will default to `redis://127.0.01:6379`.
20
20
 
21
21
  To set the range of logical shard IDs this server should manage, run the command below replacing the number range with a range of numbers, of which none can be shared with another Redis server. If a logical shard ID is shared a separate Redis instance, you may get ID collisions.
22
22
 
@@ -40,6 +40,18 @@ count = 100
40
40
  Dogtag.generate_ids data_type, count
41
41
  ```
42
42
 
43
+ ```ruby
44
+ id_number = Dogtag.generate_id 42
45
+ id = Dogtag::Id.new(id_number)
46
+ id.data_type #=> 42
47
+ id.sequence #=> 1
48
+ id.logical_shard_id #=> 12
49
+ id.custom_timestamp # time since custom epoch
50
+ id.timestamp.to_i #=> 28146773761 # Unix timestamp
51
+ id.timestamp.to_time # Ruby Time object
52
+ id.timestamp.epoch #=> 1483228800000
53
+ ```
54
+
43
55
  *Note: The available data type ID numbers are current 0 - 255.*
44
56
 
45
57
  Gotchas
@@ -1,7 +1,7 @@
1
1
  module Dogtag
2
2
  module Mixins
3
3
  module Redis
4
- DEFAULT_REDIS_URL = 'redis://localhost:6379'.freeze
4
+ DEFAULT_REDIS_URL = 'redis://127.0.0.1:6379'.freeze
5
5
 
6
6
  def redis
7
7
  # TODO: Redis config for multiple servers
@@ -46,7 +46,7 @@ module Dogtag
46
46
  @@lua_script_sha = nil
47
47
 
48
48
  # Exponentially sleep more and more on each try
49
- sleep (@tries * @tries).to_f / 900
49
+ sleep((@tries * @tries).to_f / 900)
50
50
  retry
51
51
  else
52
52
  raise err
@@ -1,3 +1,3 @@
1
1
  module Dogtag
2
- VERSION = '1.2.1'.freeze
2
+ VERSION = '1.2.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dogtag
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Crownoble
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-29 00:00:00.000000000 Z
11
+ date: 2018-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: '3.3'
22
+ version: '5'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">"
28
+ - !ruby/object:Gem::Version
29
+ version: '3.2'
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: '3.3'
32
+ version: '5'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: rspec
29
35
  requirement: !ruby/object:Gem::Requirement