cloudreactor_api_client 0.1.1 → 0.1.2
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/README.md +7 -1
- data/cloudreactor_api_client.md +4 -4
- data/lib/cloudreactor_api_client/version.rb +1 -1
- data/lib/cloudreactor_wrapper_io/status_updater.rb +41 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28a47db9dc24badcd8700fedf6faa51ff5634673b69483a454d565e29af3d654
|
4
|
+
data.tar.gz: 4a956e4d3cf6d1a0575d29512e3f4b6d844e89af67c4816d4ccab5037580e20e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b584519bebceaeebc76670aca674c540ab981f4571b70cc5fb9a215f5f3c058c13aa7ee695b215eae04d5ae4c7a9a2b20b18bceba974a70e12c80f9aeb2db30b
|
7
|
+
data.tar.gz: c943df9a612804544a2b446f924ad04ef5073ef68f485218b1c828d351727d69308a1e1d4bca2a96dafe2842fab31b1f65925a2a9ad149459baf3f2bc5b66f41
|
data/README.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# cloudreactor-ruby-client-wrapperio
|
2
2
|
|
3
|
+

|
3
4
|

|
4
5
|

|
6
|
+

|
5
7
|
|
6
8
|
## Overview
|
7
9
|
|
@@ -64,13 +66,17 @@ picked up correctly.
|
|
64
66
|
### Example usage
|
65
67
|
|
66
68
|
```ruby
|
69
|
+
# This is necessary even in Rails, due to the module name not matching the
|
70
|
+
# package name.
|
71
|
+
require 'cloudreactor_wrapper_io'
|
72
|
+
|
67
73
|
# Use the environment variables
|
68
74
|
# PROC_WRAPPER_ENABLE_STATUS_UPDATE_LISTENER
|
69
75
|
# PROC_WRAPPER_STATUS_UPDATE_SOCKET_PORT
|
70
76
|
# PROC_WRAPPER_STATUS_UPDATE_SOCKET_BIND_PORT
|
71
77
|
# to determine configuration. These environment variables are typically passed
|
72
78
|
# to the proc_wrapper module which then passes them on to your process.
|
73
|
-
status_updater =
|
79
|
+
status_updater = CloudReactorWrapperIO::StatusUpdater.new()
|
74
80
|
|
75
81
|
begin
|
76
82
|
status_updater.send_update(
|
data/cloudreactor_api_client.md
CHANGED
@@ -7,7 +7,7 @@ CloudReactor API Documentation
|
|
7
7
|
This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
8
8
|
|
9
9
|
- API version: 0.2.0
|
10
|
-
- Package version: 0.1.
|
10
|
+
- Package version: 0.1.2
|
11
11
|
- Build package: org.openapitools.codegen.languages.RubyClientCodegen
|
12
12
|
For more information, please visit [https://cloudreactor.io/](https://cloudreactor.io/)
|
13
13
|
|
@@ -24,16 +24,16 @@ gem build cloudreactor_api_client.gemspec
|
|
24
24
|
Then either install the gem locally:
|
25
25
|
|
26
26
|
```shell
|
27
|
-
gem install ./cloudreactor_api_client-0.1.
|
27
|
+
gem install ./cloudreactor_api_client-0.1.2.gem
|
28
28
|
```
|
29
29
|
|
30
|
-
(for development, run `gem install --dev ./cloudreactor_api_client-0.1.
|
30
|
+
(for development, run `gem install --dev ./cloudreactor_api_client-0.1.2.gem` to install the development dependencies)
|
31
31
|
|
32
32
|
or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/).
|
33
33
|
|
34
34
|
Finally add this to the Gemfile:
|
35
35
|
|
36
|
-
gem 'cloudreactor_api_client', '~> 0.1.
|
36
|
+
gem 'cloudreactor_api_client', '~> 0.1.2'
|
37
37
|
|
38
38
|
### Install from Git
|
39
39
|
|
@@ -2,13 +2,39 @@ require 'json'
|
|
2
2
|
require 'logger'
|
3
3
|
require 'socket'
|
4
4
|
|
5
|
+
# @note You must require the cloudreactor_wrapper_io module to use this service,
|
6
|
+
# even in Rails!
|
7
|
+
# @example
|
8
|
+
# require 'cloudreactor_wrapper_io'
|
9
|
+
# status_updater = CloudReactorWrapperIO::StatusUpdater.new()
|
10
|
+
# begin
|
11
|
+
# status_updater.send_update(
|
12
|
+
# success_count: 1,
|
13
|
+
# error_count: 2,
|
14
|
+
# last_status_message: 'running'
|
15
|
+
# )
|
16
|
+
# ensure
|
17
|
+
# status_updater.close()
|
18
|
+
# end
|
5
19
|
module CloudReactorWrapperIO
|
20
|
+
# A service used to update the CloudReactor service of the status of
|
21
|
+
# a currently running process. The service sends UDP messages to a
|
22
|
+
# process wrapper, which then forwards the updates to CloudReactor.
|
23
|
+
# @author Jeff Tsay (jeff@cloudreactor.io)
|
6
24
|
class StatusUpdater
|
7
25
|
DEFAULT_STATUS_UPDATE_PORT = 2373
|
8
26
|
|
9
27
|
attr_reader :enabled
|
10
28
|
attr_reader :port
|
11
29
|
|
30
|
+
# Create a new instance.
|
31
|
+
# @param enabled [Boolean, nil] true to enable updates. If nil, will use the
|
32
|
+
# PROC_WRAPPER_ENABLE_STATUS_UPDATE_LISTENER environment variable.
|
33
|
+
# @param port [Integer, nil] the port number to use. If nil, will use the
|
34
|
+
# PROC_WRAPPER_STATUS_UPDATE_SOCKET_PORT environment variable, or 2373
|
35
|
+
# if the environment variable is not available.
|
36
|
+
# @param logger [Logger, nil] the logger to use. If nil, will use
|
37
|
+
# Rails.logger if available, otherwise will create a new Logger.
|
12
38
|
def initialize(enabled: nil, port: nil, logger: nil)
|
13
39
|
@logger = logger
|
14
40
|
|
@@ -60,6 +86,20 @@ module CloudReactorWrapperIO
|
|
60
86
|
end
|
61
87
|
end
|
62
88
|
|
89
|
+
|
90
|
+
# Sends an update message to the process wrapper. The process wrapper should
|
91
|
+
# merge updates together until it is time to send a heartbeat to the
|
92
|
+
# server, so it should be safe to call this method rapidly.
|
93
|
+
# Messages are not guaranteed to be sent successfully, but in practice
|
94
|
+
# they almost always are.
|
95
|
+
#
|
96
|
+
# @param success_count [Integer, nil] The number of successful items so far
|
97
|
+
# @param error_count [Integer, nil] The number of failed items so far
|
98
|
+
# @param skipped_count [Integer, nil] The number of skipped items so far
|
99
|
+
# @param expected_count [Integer, nil] The number of expected items
|
100
|
+
# @param last_status_message [String, nil] A status message
|
101
|
+
# @param [Hash, nil] extra_props Additional properties to send
|
102
|
+
# @return [Boolean] True if the update was sent, false othewise
|
63
103
|
def send_update(success_count: nil, error_count: nil, skipped_count: nil,
|
64
104
|
expected_count: nil, last_status_message: nil, extra_props: nil)
|
65
105
|
unless @enabled
|
@@ -108,6 +148,7 @@ module CloudReactorWrapperIO
|
|
108
148
|
end
|
109
149
|
end
|
110
150
|
|
151
|
+
# Close any resources associated with this instance.
|
111
152
|
def close
|
112
153
|
if @socket
|
113
154
|
@socket.shutdown
|