libvirt_async 0.2.1 → 0.4.0
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 +4 -4
- data/.github/workflows/tests.yml +24 -0
- data/Gemfile +2 -0
- data/Rakefile +2 -0
- data/bin/console +0 -0
- data/bin/setup +0 -0
- data/lib/libvirt_async/error.rb +2 -0
- data/lib/libvirt_async/handle.rb +5 -3
- data/lib/libvirt_async/implementations.rb +15 -7
- data/lib/libvirt_async/log_formatter.rb +2 -0
- data/lib/libvirt_async/stream_read.rb +5 -2
- data/lib/libvirt_async/timer.rb +5 -3
- data/lib/libvirt_async/util.rb +2 -0
- data/lib/libvirt_async/version.rb +3 -1
- data/lib/libvirt_async/with_dbg.rb +2 -0
- data/lib/libvirt_async.rb +4 -2
- data/libvirt_async.gemspec +1 -1
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a09af72032f53f8c42c5b94d07545ea1d83162f27b43cc37bf7b76299c09bce3
|
4
|
+
data.tar.gz: 36871662bf7af1a333a0e5209ee280b992bb65c4eca5d57dd9f540b046137f9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 826e01d8be353bc9dbb9e920ebc4c879970218c6c8808d1db77d3fbd2145ef1a77b894ac5ffb0232381ff45f45a0d667ccd84b9d885c8198c014bc78a0c99123
|
7
|
+
data.tar.gz: 3d85a9f6c6eb9bc7b8c9eec53c9880c79892cc74bf2798473469397c750a9e0d6e589eb42c63901c3984b5f109567df7ce7d5d78ec9830bbd7c8111e5b1db29f
|
@@ -0,0 +1,24 @@
|
|
1
|
+
name: Tests
|
2
|
+
on:
|
3
|
+
pull_request:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
test:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
strategy:
|
12
|
+
matrix:
|
13
|
+
ruby: [ '2.6', '2.7', '3.0' ]
|
14
|
+
name: Tests with Ruby ${{ matrix.ruby }}
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v2
|
17
|
+
- uses: actions/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: ${{ matrix.ruby }}
|
20
|
+
- name: Run tests
|
21
|
+
run: |
|
22
|
+
gem install bundler
|
23
|
+
bundle install
|
24
|
+
bundle exec rake
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/bin/console
CHANGED
File without changes
|
data/bin/setup
CHANGED
File without changes
|
data/lib/libvirt_async/error.rb
CHANGED
data/lib/libvirt_async/handle.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module LibvirtAsync
|
2
4
|
class Handle
|
3
5
|
# Represents an event handle (usually a file descriptor). When an event
|
4
6
|
# happens to the handle, we dispatch the event to libvirt via
|
5
|
-
# Libvirt::
|
7
|
+
# Libvirt::Event.invoke_handle_callback (feeding it the handle_id we returned
|
6
8
|
# from add_handle, the file descriptor, the new events, and the opaque
|
7
9
|
# data that libvirt gave us earlier).
|
8
10
|
|
@@ -117,11 +119,11 @@ module LibvirtAsync
|
|
117
119
|
|
118
120
|
task = Util.create_task do
|
119
121
|
dbg { "#{self.class}#dispatch async starts handle_id=#{handle_id} events=#{events}, fd=#{fd}" }
|
120
|
-
Libvirt::
|
122
|
+
Libvirt::Event.invoke_handle_callback(handle_id, fd, events, opaque)
|
121
123
|
dbg { "#{self.class}#dispatch async ends handle_id=#{handle_id} received_events=#{events}, fd=#{fd}" }
|
122
124
|
end
|
123
125
|
dbg { "#{self.class}#dispatch invokes fiber=0x#{task.fiber.object_id.to_s(16)} handle_id=#{handle_id}, events=#{events}, fd=#{fd}" }
|
124
|
-
task.
|
126
|
+
task.reactor << task.fiber
|
125
127
|
|
126
128
|
dbg { "#{self.class}#dispatch ends handle_id=#{handle_id}, events=#{events}, fd=#{fd}" }
|
127
129
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'async'
|
2
4
|
require 'libvirt_async/with_dbg'
|
3
5
|
require 'libvirt_async/util'
|
@@ -62,16 +64,22 @@ module LibvirtAsync
|
|
62
64
|
def register_implementations
|
63
65
|
dbg { "#{self.class}#register_implementations" }
|
64
66
|
|
65
|
-
Libvirt::
|
66
|
-
method(:add_handle).to_proc,
|
67
|
-
method(:update_handle).to_proc,
|
68
|
-
method(:remove_handle).to_proc,
|
69
|
-
method(:add_timer).to_proc,
|
70
|
-
method(:update_timer).to_proc,
|
71
|
-
method(:remove_timer).to_proc
|
67
|
+
Libvirt::Event.register(
|
68
|
+
add_handle: method(:add_handle).to_proc,
|
69
|
+
update_handle: method(:update_handle).to_proc,
|
70
|
+
remove_handle: method(:remove_handle).to_proc,
|
71
|
+
add_timer: method(:add_timer).to_proc,
|
72
|
+
update_timer: method(:update_timer).to_proc,
|
73
|
+
remove_timer: method(:remove_timer).to_proc,
|
74
|
+
schedule: method(:schedule).to_proc
|
72
75
|
)
|
73
76
|
end
|
74
77
|
|
78
|
+
def schedule(&block)
|
79
|
+
t = Async::Task.new(Async::Task.current.reactor, nil, &block)
|
80
|
+
t.reactor << t.fiber
|
81
|
+
end
|
82
|
+
|
75
83
|
def add_handle(fd, events, opaque)
|
76
84
|
# add a handle to be tracked by this object. The application is
|
77
85
|
# expected to maintain a list of internal handle IDs (integers); this
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module LibvirtAsync
|
2
4
|
class StreamRead
|
3
5
|
# StreamRead allows to work with stream in non-block read mode.
|
@@ -44,10 +46,11 @@ module LibvirtAsync
|
|
44
46
|
raise ArgumentError, 'block must be given' if @callback.nil?
|
45
47
|
|
46
48
|
dbg { "#{to_s}#call event_add_callback calling" }
|
49
|
+
proc = -> (_stream, events, _opaque) { stream_callback(events) }
|
47
50
|
@cb_opaque = stream.event_add_callback(
|
48
51
|
Libvirt::Stream::EVENT_READABLE,
|
49
|
-
|
50
|
-
|
52
|
+
self,
|
53
|
+
&proc
|
51
54
|
)
|
52
55
|
dbg { "#{to_s}#call event_add_callback called" }
|
53
56
|
|
data/lib/libvirt_async/timer.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module LibvirtAsync
|
2
4
|
class Timer
|
3
5
|
# Represents a When a timer expires, we dispatch the event to
|
4
|
-
# libvirt via Libvirt::
|
6
|
+
# libvirt via Libvirt::Event.invoke_timeout_callback (feeding it the timer_id
|
5
7
|
# we returned from add_timer and the opaque data that libvirt gave us
|
6
8
|
# earlier).
|
7
9
|
|
@@ -114,12 +116,12 @@ module LibvirtAsync
|
|
114
116
|
|
115
117
|
task = Util.create_task do
|
116
118
|
dbg { "#{self.class}#dispatch async starts timer_id=#{timer_id}, interval=#{interval}" }
|
117
|
-
Libvirt::
|
119
|
+
Libvirt::Event.invoke_timeout_callback(timer_id, opaque)
|
118
120
|
dbg { "#{self.class}#dispatch async async ends timer_id=#{timer_id}, interval=#{interval}" }
|
119
121
|
end
|
120
122
|
|
121
123
|
dbg { "#{self.class}#dispatch invokes fiber=0x#{task.fiber.object_id.to_s(16)} timer_id=#{timer_id}, interval=#{interval}" }
|
122
|
-
task.
|
124
|
+
task.reactor << task.fiber
|
123
125
|
|
124
126
|
dbg { "#{self.class}#dispatch ends timer_id=#{timer_id}, interval=#{interval}" }
|
125
127
|
end
|
data/lib/libvirt_async/util.rb
CHANGED
data/lib/libvirt_async.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'logger'
|
2
4
|
require 'libvirt_async/version'
|
3
5
|
require 'libvirt_async/error'
|
@@ -44,8 +46,8 @@ module LibvirtAsync
|
|
44
46
|
|
45
47
|
module_function :build_logger
|
46
48
|
|
47
|
-
def use_logger!(io = STDOUT, options
|
48
|
-
self.logger = build_logger(io, options)
|
49
|
+
def use_logger!(io = STDOUT, **options)
|
50
|
+
self.logger = build_logger(io, **options)
|
49
51
|
end
|
50
52
|
|
51
53
|
module_function :use_logger!
|
data/libvirt_async.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
26
|
spec.require_paths = ['lib']
|
27
27
|
|
28
|
-
spec.add_dependency '
|
28
|
+
spec.add_dependency 'libvirt_ffi'
|
29
29
|
spec.add_dependency 'async', '~> 1.24'
|
30
30
|
spec.add_dependency 'activesupport'
|
31
31
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libvirt_async
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Talakevich
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: libvirt_ffi
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: async
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,6 +60,7 @@ executables: []
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
+
- ".github/workflows/tests.yml"
|
63
64
|
- ".gitignore"
|
64
65
|
- ".travis.yml"
|
65
66
|
- CHANGELOG.md
|
@@ -103,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
104
|
- !ruby/object:Gem::Version
|
104
105
|
version: '0'
|
105
106
|
requirements: []
|
106
|
-
rubygems_version: 3.
|
107
|
+
rubygems_version: 3.2.32
|
107
108
|
signing_key:
|
108
109
|
specification_version: 4
|
109
110
|
summary: Libvirt event async implementation.
|