hookshot 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/lib/hookshot.rb +24 -21
  3. data/lib/hookshot/version.rb +1 -1
  4. metadata +8 -10
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 50a6ddf79d002197181d01e453820959a59c24fd
4
+ data.tar.gz: 2af7e0bb07e0d6810cb2e1e8722f44b97ea891c0
5
+ SHA512:
6
+ metadata.gz: 6af6ecbb0d55181f235d3b9a9c7f79124e3c29e575bb0856dee3d038b1d8c5375119014906f0d5640d89dfddde2bf6d6024ae4de2fcd0e9274d9ec89ef8a7edc
7
+ data.tar.gz: bd380b8d21b96d091698e5fdc35e86193a8b334cd268fcee7e86e5f71d43b3ebc124683ea6b5a1549cdfeffb91854316e5667e7b75299fd89b14ad2104ad499b
@@ -5,11 +5,11 @@ require "hookshot/version"
5
5
 
6
6
  class Hookshot
7
7
 
8
- NEW_JOBS_LIST = "hookshot:jobs"
9
- DELAYED_SET = "hookshot:delayed"
10
- FAILURES_LIST = "hookshot:failures"
11
- MANUAL_BLACKLIST = "hookshot:throttle:blacklist"
12
- MANUAL_WHITELIST = "hookshot:throttle:whitelist"
8
+ PREFIX = "hookshot"
9
+ NEW_JOBS_LIST = "#{PREFIX}:jobs"
10
+ DELAYED_SET = "#{PREFIX}:delayed"
11
+ FAILURES_LIST = "#{PREFIX}:failures"
12
+ MANUAL_BLACKLIST = "#{PREFIX}:throttle:blacklist"
13
13
 
14
14
  FINAL_FAILURE = -1
15
15
 
@@ -18,18 +18,16 @@ class Hookshot
18
18
  @redis = redis
19
19
  end
20
20
 
21
- def enqueue_in(duration, url, headers, subscription, payload)
22
- enqueue_time = (Time.now + duration).to_i
23
- enqueue(url, headers, subscription, payload, activate_at: enqueue_time)
24
- end
25
-
26
- def enqueue(url, headers, subscription, payload, options = {})
27
- activate_at = options.delete(:activate_at)
28
- raise ArgumentError, "invalid option" if options.any?
29
-
21
+ def enqueue(url:, headers:, context:, payload:, activate_at: nil)
30
22
  uuid = SecureRandom.uuid
31
23
  redis.pipelined do
32
- redis.hmset(job_key(uuid), "url", url, "headers", serialize_headers(headers), "subscription", subscription, "payload", payload)
24
+ redis.hmset(
25
+ job_key(uuid),
26
+ "url", url,
27
+ "headers", serialize_headers(headers),
28
+ "context", context,
29
+ "payload", payload,
30
+ "failures", 0)
33
31
  if activate_at
34
32
  redis.zadd(DELAYED_SET, activate_at, uuid)
35
33
  else
@@ -37,7 +35,17 @@ class Hookshot
37
35
  end
38
36
  end
39
37
 
40
- true
38
+ uuid
39
+ end
40
+
41
+ def enqueue_in(duration, url:, headers:, context:, payload:)
42
+ enqueue_time = (Time.now + duration).to_i
43
+ enqueue(
44
+ url: url,
45
+ headers: headers,
46
+ context: context,
47
+ payload: payload,
48
+ activate_at: enqueue_time)
41
49
  end
42
50
 
43
51
  def get_next_failure
@@ -56,13 +64,8 @@ class Hookshot
56
64
  redis.zadd(MANUAL_BLACKLIST, Time.now.to_i+duration, domain)
57
65
  end
58
66
 
59
- def force_whitelist(domain, duration)
60
- redis.zadd(MANUAL_WHITELIST, Time.now.to_i+duration, domain)
61
- end
62
-
63
67
  def remove_override(domain)
64
68
  redis.zrem(MANUAL_BLACKLIST, domain)
65
- redis.zrem(MANUAL_WHITELIST, domain)
66
69
  end
67
70
 
68
71
  def queue_stats
@@ -1,3 +1,3 @@
1
1
  class Hookshot
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hookshot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Burke Libbey
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-27 00:00:00.000000000 Z
11
+ date: 2014-09-11 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Hookshot client library for ruby
15
14
  email:
@@ -18,7 +17,7 @@ executables: []
18
17
  extensions: []
19
18
  extra_rdoc_files: []
20
19
  files:
21
- - .gitignore
20
+ - ".gitignore"
22
21
  - Gemfile
23
22
  - LICENSE.txt
24
23
  - README.md
@@ -28,26 +27,25 @@ files:
28
27
  - lib/hookshot/version.rb
29
28
  homepage: ''
30
29
  licenses: []
30
+ metadata: {}
31
31
  post_install_message:
32
32
  rdoc_options: []
33
33
  require_paths:
34
34
  - lib
35
35
  required_ruby_version: !ruby/object:Gem::Requirement
36
- none: false
37
36
  requirements:
38
- - - ! '>='
37
+ - - ">="
39
38
  - !ruby/object:Gem::Version
40
39
  version: '0'
41
40
  required_rubygems_version: !ruby/object:Gem::Requirement
42
- none: false
43
41
  requirements:
44
- - - ! '>='
42
+ - - ">="
45
43
  - !ruby/object:Gem::Version
46
44
  version: '0'
47
45
  requirements: []
48
46
  rubyforge_project:
49
- rubygems_version: 1.8.23
47
+ rubygems_version: 2.2.2
50
48
  signing_key:
51
- specification_version: 3
49
+ specification_version: 4
52
50
  summary: Hookshot client library for ruby.
53
51
  test_files: []