Sha256: 2ef2ebeafd633f88f235579e06f3ec13183d237142641200837c1b8374976f05

Contents?: true

Size: 601 Bytes

Versions: 1

Compression:

Stored size: 601 Bytes

Contents

module MicroServiceClient
	class MicroServiceServerInstallJob < ActiveJob::Base
		queue_as :default

		def perform(*args)
			params = args.extract_options!

			begin
				MicroService::Server.new(params).save
			# Failed to notify the microservice we successfully installed ourselves
			rescue MicroService::Server::InstallError => $e
				# Increment attempt number
				params["attempt"] ||= 1
				params["attempt"] = params["attempt"] + 1

				# Try again in one minute
				MicroServiceServerInstallJob.set(wait: 1.minute).perform_later(params) unless params["attempt"].to_i > 3
			end
		end
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
micro_service_client-0.0.3 app/jobs/micro_service_client/micro_service_server_install_job.rb