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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc683a7bd63c353942d0f7e72891d49eb93c8c78eeef82a184e2cec19337de2d
4
- data.tar.gz: 684eff3feb5aee6712c7c08663a2713b47622911347eb8a5794b62f3d50f23ac
3
+ metadata.gz: 28a47db9dc24badcd8700fedf6faa51ff5634673b69483a454d565e29af3d654
4
+ data.tar.gz: 4a956e4d3cf6d1a0575d29512e3f4b6d844e89af67c4816d4ccab5037580e20e
5
5
  SHA512:
6
- metadata.gz: d928e48d84c6c8d8cde6c4ebe4da1cedc88eff27cb610f1ea6e11ece1858a4916524bbf255ebea98294ed7a90fcba46a9d1e3693d93ac1b6478d256087f750c2
7
- data.tar.gz: 4074301b99e6ff24dfac28b9a6a1fc2cd7246ee9f64e6d79029ba1b137a87cb6d78596503d82f5acdd4f87e5aef34972af17fe79ffce8321c07ea17e5f22ebdd
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
+ ![Gem](https://img.shields.io/gem/v/cloudreactor_api_client)
3
4
  ![Ruby CI](https://github.com/CloudReactor/cloudreactor-ruby-client-wrapperio/workflows/Ruby%20CI/badge.svg?branch=master)
4
5
  ![GitHub](https://img.shields.io/github/license/CloudReactor/cloudreactor-ruby-client-wrapperio)
6
+ ![Snyk Vulnerabilities for GitHub Repo](https://img.shields.io/snyk/vulnerabilities/github/CloudReactor/cloudreactor-ruby-client-wrapperio)
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 = new CloudReactorWrapperIO::StatusUpdater()
79
+ status_updater = CloudReactorWrapperIO::StatusUpdater.new()
74
80
 
75
81
  begin
76
82
  status_updater.send_update(
@@ -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.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.1.gem
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.1.gem` to install the development dependencies)
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.1'
36
+ gem 'cloudreactor_api_client', '~> 0.1.2'
37
37
 
38
38
  ### Install from Git
39
39
 
@@ -11,5 +11,5 @@ OpenAPI Generator version: 5.4.0
11
11
  =end
12
12
 
13
13
  module CloudReactorAPIClient
14
- VERSION = '0.1.1'
14
+ VERSION = '0.1.2'
15
15
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudreactor_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Tsay