Class: EndPointBlank::Commands::EndpointUpdate
- Inherits:
-
Object
- Object
- EndPointBlank::Commands::EndpointUpdate
- Defined in:
- lib/end_point_blank/commands/endpoint_update.rb
Overview
Collects and sends application endpoint information to a remote registry service. Scans all Rails routes and extracts details including path, HTTP verb, API version, and deprecation status from controller versioning concerns. Sends this data along with application metadata (name, hostname, environment) to the configured endpoint_update_url for centralized endpoint tracking and documentation.
Class Method Summary collapse
Instance Method Summary collapse
- #application_info ⇒ Object
- #auth ⇒ Object
- #configuration ⇒ Object
-
#initialize ⇒ EndpointUpdate
constructor
A new instance of EndpointUpdate.
- #update ⇒ Object
- #write(data) ⇒ Object
Constructor Details
#initialize ⇒ EndpointUpdate
Returns a new instance of EndpointUpdate.
14 15 |
# File 'lib/end_point_blank/commands/endpoint_update.rb', line 14 def initialize end |
Class Method Details
.update ⇒ Object
50 51 52 |
# File 'lib/end_point_blank/commands/endpoint_update.rb', line 50 def self.update new.update end |
Instance Method Details
#application_info ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/end_point_blank/commands/endpoint_update.rb', line 58 def application_info { application: application_name, hostname: hostname, lib_version: EndPointBlank::VERSION, environment: environment, endpoints: , app_version: , } end |
#auth ⇒ Object
21 22 23 |
# File 'lib/end_point_blank/commands/endpoint_update.rb', line 21 def auth Authorization.header end |
#configuration ⇒ Object
17 18 19 |
# File 'lib/end_point_blank/commands/endpoint_update.rb', line 17 def configuration EndPointBlank::Configuration.instance end |
#update ⇒ Object
54 55 56 |
# File 'lib/end_point_blank/commands/endpoint_update.rb', line 54 def update write(application_info) end |
#write(data) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/end_point_blank/commands/endpoint_update.rb', line 25 def write(data) EndPointBlank.logger.info "[EndPointBlank] Sending application update: " \ "application=#{data[:application]} environment=#{data[:environment]} " \ "app_version=#{data[:app_version]}" response = Excon.post(configuration.endpoint_update_url, headers: {'Authorization' => auth, 'Content-Type' => 'application/json'}, body: data.to_json, **EndPointBlank::Commands::Http::TIMEOUT_OPTIONS ) if response.status > 299 EndPointBlank.logger.error "Failed to update endpoint: #{response.status} - #{response.body}" else EndPointBlank.logger.info "Endpoint updated successfully: #{response.status}" end rescue Excon::Error => e # Was `rescue Excon::Error::Socket, Excon::Error::Connection` - # Excon::Error::Connection does not exist in this excon version, so # that clause raised NameError instead of catching anything, and a # timeout (Excon::Error::Timeout) would have crashed the caller. # Rescuing Excon::Error catches every transport failure, including # timeouts, without letting this fire-and-forget call ever raise. EndPointBlank.logger.warn "EndPointBlank: could not reach intake to update endpoints (#{e.})" end |