Sha256: fdbca29384e491c4a4631b8eb44c75c9c0703cfc3322f9586148e628970b6edf

Contents?: true

Size: 601 Bytes

Versions: 2

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

2 entries across 2 versions & 1 rubygems

Version Path
micro_service_client-0.0.2 app/jobs/micro_service_client/microservice_server_install_job.rb
micro_service_client-0.0.1 app/jobs/micro_service_client/microservice_server_install_job.rb