activebridge 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.standard.yml +3 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -36
- data/Rakefile +6 -0
- data/e2e/execute.rb +19 -0
- data/e2e/throttle.rb +11 -0
- data/lib/active_bridge/execute.rb +33 -0
- data/lib/active_bridge/throttle.rb +10 -0
- data/lib/active_bridge/version.rb +1 -1
- data/lib/active_bridge.rb +3 -4
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16e6404432ed07b76f64563aa8d02f63c43657a24e5b76516968663f747ad3d8
|
4
|
+
data.tar.gz: 3e9b2bf0d8fd47f809510a04bc66057906a7e0bc07da3e2fc9b58913ff1566d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce30d371d0c85f494766990d47504cb17d09bf74a26507c14d5acc0786563d4819422f799842be0a809fc8ec8326440b3ea11b4ba0e80523683ce43fc2c072b5
|
7
|
+
data.tar.gz: 754d69618667f96d0d69c5992972057b39f68c7516aba0e3ccc242446b2f04db25e9605ff4773523330b4a6de4028cdc47193fcb5f3183b06f7c38ad143a6cee
|
data/.standard.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,39 +1,6 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/activebridge`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
1
|
+
# ActiveBridge
|
10
2
|
|
11
3
|
```ruby
|
12
|
-
|
4
|
+
require 'activebridge'
|
5
|
+
include ActiveBridge
|
13
6
|
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle install
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install activebridge
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/activebridge.
|
36
|
-
|
37
|
-
## License
|
38
|
-
|
39
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
data/e2e/execute.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative "../lib/active_bridge"
|
2
|
+
|
3
|
+
status, took, value = execute do
|
4
|
+
sleep 0.2
|
5
|
+
[1, 2, 3]
|
6
|
+
end
|
7
|
+
|
8
|
+
puts "status: #{status.inspect}"
|
9
|
+
puts "took: #{took}"
|
10
|
+
puts "value: #{value.inspect}"
|
11
|
+
|
12
|
+
status, took, value = execute timeout: 0.1 do
|
13
|
+
sleep 0.2
|
14
|
+
[1, 2, 3]
|
15
|
+
end
|
16
|
+
|
17
|
+
puts "status: #{status.inspect}"
|
18
|
+
puts "took: #{took}"
|
19
|
+
puts "value: #{value.inspect}"
|
data/e2e/throttle.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveBridge
|
4
|
+
def execute(opts = {}, &block)
|
5
|
+
queue = Queue.new
|
6
|
+
timeout_thr = if opts[:timeout]
|
7
|
+
Thread.new do
|
8
|
+
queue.push [:timeout, sleep(opts[:timeout])]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
started_at = Time.now
|
12
|
+
main_thr = Thread.new do
|
13
|
+
queue.push [:ok, block.call]
|
14
|
+
end
|
15
|
+
|
16
|
+
op, value = queue.pop
|
17
|
+
took = Time.now - started_at
|
18
|
+
|
19
|
+
timeout_thr&.kill
|
20
|
+
main_thr.kill
|
21
|
+
main_thr.kill
|
22
|
+
main_thr.kill
|
23
|
+
|
24
|
+
case op
|
25
|
+
when :timeout
|
26
|
+
[:timeout, took, nil]
|
27
|
+
when :ok
|
28
|
+
[:ok, took, value]
|
29
|
+
else
|
30
|
+
raise "well, this is interesting"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/active_bridge.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "active_bridge/version"
|
4
|
+
require_relative "active_bridge/throttle"
|
5
|
+
require_relative "active_bridge/execute"
|
4
6
|
|
5
|
-
|
6
|
-
class Error < StandardError; end
|
7
|
-
# Your code goes here...
|
8
|
-
end
|
7
|
+
include ActiveBridge
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activebridge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matti Paksula
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: activebridge
|
14
14
|
email:
|
@@ -27,7 +27,11 @@ files:
|
|
27
27
|
- README.md
|
28
28
|
- Rakefile
|
29
29
|
- activebridge.gemspec
|
30
|
+
- e2e/execute.rb
|
31
|
+
- e2e/throttle.rb
|
30
32
|
- lib/active_bridge.rb
|
33
|
+
- lib/active_bridge/execute.rb
|
34
|
+
- lib/active_bridge/throttle.rb
|
31
35
|
- lib/active_bridge/version.rb
|
32
36
|
- sig/activebridge.rbs
|
33
37
|
homepage: https://github.com/matti/activebridge
|