hopper 0.0.1.pre.alpha.1 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 33d562bd6dd3fb4fbf879d90de308e9a065545ff
4
- data.tar.gz: b9a8719f539441ef1a9d2807a1075f0ae1131844
3
+ metadata.gz: 27d2b14dd2167a64a19313222427ca9f1096074b
4
+ data.tar.gz: bbd8f806df0f11709081abb213ced5d4c1f7d3ae
5
5
  SHA512:
6
- metadata.gz: 4d050bda365e3af3e77f0592b169e9e713e4fa5c7ce550b3c8e09fb8cb82461f67783ae47c689f78c6aba1d5c5389ebec6aae29c8cce4328268fc9c956052658
7
- data.tar.gz: f1be57515a48a11bc67947c8bad4225d5fc4f44db0162d51e72ac567969265e43c46f824e4563622cafd872734098c76bd10e723665bf0d4de2a05b13d58e565
6
+ metadata.gz: a06a597fc6c1bd5eda7ce1dd7382604994c4493f5abdabfd008db9aa5501a1ba0fc2a2f256d761818888bc746a360c6685e9e23a3f69350c9962cfe755715aff
7
+ data.tar.gz: 1823412b728c4380f2fa366d4bbdf7813b9c569bfdeed9037feb8898eccbffcc8579238d21274cc7614d85d8a45458f247bd442cc8c774a8a3ab13eaa74758ae
@@ -0,0 +1,33 @@
1
+ Contributing to Hopper
2
+ ======================
3
+
4
+ First of all, thanks for your interest in contributing to Hopper!
5
+
6
+ Below are a list of guidelines to help keep this project sane in the face of open source entropy.
7
+
8
+ How To Submit A Patch
9
+ ---------------------
10
+
11
+ Any patch you feel would make this a better project is welcome, including but not limited to: bug fixes, new features, refactoring, and better documentation.
12
+
13
+ Make a fork of this project, and hack to your heart's content. Once you have something you think would be great to include into master, feel free to open a pull request. Please keep in mind the following guidelines, which will make it more likely for your pull request to be accepted:
14
+
15
+ 1. Please have test cases, both in the unit suite and the integration suite, that fail when your code is not present.
16
+ 1. Please open a topic branch in your fork, and create your pull request against that.
17
+ * Use a separate topic for each feature and/or bug fix you want to submit.
18
+ 1. Be logically consistent in your commits. Make them as small as possible, so they can tell a story the maintainer can understand.
19
+ 1. Keeping a consistent style in the codebase is important for maintainability. When possible, please stick to the guidelines within [this guide](https://github.com/bbatsov/ruby-style-guide).
20
+ 1. Pay attention to things like code climate and test coverage. A drop in these metrics will not necessarily preclude a patch from being accepted, but we'd much prefer to keep these numbers high.
21
+
22
+ Please keep in mind your contributions will be licensed the same as the rest of Hopper, under the MIT license.
23
+
24
+ It may take the developer a day or two to get to your pull request. If your request has not been responded to in a few days, though, feel free to ping the developer team, preferably through a comment on the pull.
25
+
26
+ How To Report An Issue
27
+ ----------------------
28
+
29
+ Issue reports are welcome, even if not accompanied by a pull request. Keep in mind that submitting a pull request will mean your issue likely gets resolved sooner, because less work will be left to do.
30
+
31
+ The most important thing an issue can do is get a developer as close as possible to seeing what you are seeing, in the case of a bug report. In the case of a feature request, you want to get them to the point where they don't see what you want to see, so they can make a decision about whether and how to include the proposed feature.
32
+
33
+ More about good bug reports [here](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html).
data/README.md CHANGED
@@ -1,3 +1,71 @@
1
+ [![Build Status](https://travis-ci.org/azanar/hopper.svg)](https://travis-ci.org/azanar/hopper)
2
+ [![Dependency Status](http://img.shields.io/gemnasium/azanar/hopper.svg)](https://gemnasium.com/azanar/hopper)
3
+ [![Coverage Status](http://img.shields.io/coveralls/azanar/hopper.svg)](https://coveralls.io/r/azanar/hopper)
4
+ [![Code Climate](http://img.shields.io/codeclimate/github/azanar/hopper.svg)](https://codeclimate.com/github/azanar/hopper)
5
+ [![Gem Version](http://img.shields.io/gem/v/hopper.svg)](https://rubygems.org/gems/hopper)
6
+ [![License](http://img.shields.io/:license-mit-blue.svg)](http://azanar.mit-license.org)
7
+ [![Badges](http://img.shields.io/:badges-7/7-ff6799.svg)](https://github.com/badges/badgerbadgerbadger)
8
+
9
+
1
10
  Hopper
2
11
  ======
3
12
  A framework for task execution written around bunny.
13
+
14
+ Usable on its own, or as part of [Hopper](https://github.com/azanar/hopper).
15
+
16
+ Examples
17
+ --------
18
+ A Publisher:
19
+
20
+ ```ruby
21
+ channel = Hopper::Channel.new
22
+
23
+ queue = Hopper::Queue.new("hopper-stresstest")
24
+
25
+ publisher = queue.publisher(channel)
26
+
27
+ publisher.publish(m)
28
+ ```
29
+
30
+ A Listener:
31
+ ```ruby
32
+ channel = Hopper::Channel.new
33
+
34
+ queue = Hopper::Queue.new("hopper-stresstest")
35
+
36
+ listener = queue.listener(channel)
37
+
38
+ listener.listen do |m|
39
+
40
+ unless valid(m)
41
+ m.reject
42
+ next
43
+ end
44
+
45
+ # do some stuff
46
+
47
+ m.acknowledge
48
+ end
49
+ ```
50
+
51
+ TODO
52
+ ----
53
+
54
+ - Add support for pluggable serialization mechanisms (MsgPack, JSON, etc.)
55
+
56
+ API Documentation
57
+ -----------------
58
+
59
+ See [RubyDoc](http://rubydoc.info/github/azanar/hopper/index)
60
+
61
+ Contributors
62
+ ------------
63
+
64
+ See [Contributing](CONTRIBUTING.md) for details.
65
+
66
+ License
67
+ -------
68
+
69
+ ©2015 Ed Carrel. Released under the MIT License.
70
+
71
+ See [License](LICENSE) for details.
@@ -1,3 +1,3 @@
1
1
  module Hopper
2
- VERSION = "0.0.1-alpha.1"
2
+ VERSION = "0.0.1"
3
3
  end
@@ -2,7 +2,7 @@ require File.expand_path('../test_helper', __FILE__)
2
2
 
3
3
  require 'bunny'
4
4
 
5
- require 'timeout'
5
+ require 'thread'
6
6
 
7
7
  require 'hopper'
8
8
 
@@ -15,7 +15,7 @@ module Hopper
15
15
  channel = Hopper::Channel.new
16
16
 
17
17
  queue = Hopper::Queue.new("hopper-stresstest")
18
-
18
+
19
19
  publisher = queue.publisher(channel)
20
20
  listener = queue.listener(channel)
21
21
 
@@ -26,36 +26,55 @@ module Hopper
26
26
  channel = Hopper::Channel.new
27
27
 
28
28
  queue = channel.queue("hopper-stresstest")
29
-
29
+
30
30
  publisher = queue.publisher
31
31
  listener = queue.listener
32
-
32
+
33
33
  run_queue(publisher, listener)
34
34
 
35
35
  end
36
36
 
37
+ QUEUE_LENGTH = 100
38
+
37
39
  def run_queue(publisher, listener)
38
- messages = 10.times.map do |x|
39
- Message.new("message#{x}")
40
+ message_strings = QUEUE_LENGTH.times.map do |x|
41
+ "message#{x}"
42
+ end
43
+
44
+ messages = message_strings.map do |s|
45
+ Message.new(s)
40
46
  end
41
-
47
+
42
48
  messages.each do |m|
43
49
  publisher.publish(m)
44
50
  end
45
51
 
46
52
  received = []
47
53
 
48
- Timeout::timeout(1) do
54
+ validate_mutex = Mutex.new
55
+ validate_latch = ConditionVariable.new
56
+
57
+ Thread.new do
49
58
  listener.listen do |m|
50
59
  received << m
51
60
  m.acknowledge
52
- if received.length == 10
61
+ if received.length == QUEUE_LENGTH
62
+ validate_latch.signal
53
63
  m.terminate
54
64
  end
55
65
  end
56
66
  end
57
67
 
58
- assert_equal 10, received.length
68
+ validate_mutex.synchronize {
69
+ validate_latch.wait(validate_mutex)
70
+ }
71
+
72
+ assert_equal QUEUE_LENGTH, received.length
73
+ received_strings = received.map {|r|
74
+ r.message.payload
75
+ }
76
+ assert_equal Set.new(message_strings), Set.new(received_strings)
59
77
  end
78
+
60
79
  end
61
80
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hopper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.pre.alpha.1
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ed Carrel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-21 00:00:00.000000000 Z
11
+ date: 2015-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -131,6 +131,7 @@ extra_rdoc_files: []
131
131
  files:
132
132
  - ".gitignore"
133
133
  - ".travis.yml"
134
+ - CONTRIBUTING.md
134
135
  - Gemfile
135
136
  - LICENSE
136
137
  - README.md
@@ -175,12 +176,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
175
176
  version: '0'
176
177
  required_rubygems_version: !ruby/object:Gem::Requirement
177
178
  requirements:
178
- - - ">"
179
+ - - ">="
179
180
  - !ruby/object:Gem::Version
180
- version: 1.3.1
181
+ version: '0'
181
182
  requirements: []
182
183
  rubyforge_project:
183
- rubygems_version: 2.2.2
184
+ rubygems_version: 2.4.5
184
185
  signing_key:
185
186
  specification_version: 4
186
187
  summary: A framework for task execution written around bunny