Sha256: d9f2fc541fac23c9d3d3eb8cc094995e57066ee4c734690d6fc776ff0bbc9075
Contents?: true
Size: 1.56 KB
Versions: 4
Compression:
Stored size: 1.56 KB
Contents
# frozen_string_literal: true module Bullion # Superclass for executing ACMEv2 Challenges class ChallengeClient ChallengeClientMetric = Prometheus::Client::Histogram.new( :challenge_execution_seconds, docstring: "Challenge execution histogram in seconds", labels: %i[acme_type status] ) MetricsRegistry.register(ChallengeClientMetric) attr_accessor :challenge def initialize(challenge) @challenge = challenge end # rubocop:disable Metrics/AbcSize # rubocop:disable Metrics/MethodLength def attempt(retries: 4) tries = 0 success = false challenge.update!(status: "processing") benchtime = Benchmark.realtime do until success || tries >= retries tries += 1 success = perform if success LOGGER.info "Validated #{type} #{identifier}" challenge.status = "valid" challenge.validated = Time.now else sleep rand(2..4) end end end unless success LOGGER.info "Failed to validate #{type} #{identifier}" challenge.status = "invalid" challenge.authorization.update!(status: "invalid") challenge.authorization.order.update!(status: "invalid") end challenge.save ChallengeClientMetric.observe( benchtime, labels: { acme_type: type, status: challenge.status } ) success end # rubocop:enable Metrics/AbcSize # rubocop:enable Metrics/MethodLength def identifier challenge.identifier end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
bullion-0.7.3 | lib/bullion/challenge_client.rb |
bullion-0.7.2 | lib/bullion/challenge_client.rb |
bullion-0.7.1 | lib/bullion/challenge_client.rb |
bullion-0.7.0 | lib/bullion/challenge_client.rb |