Skip to content

Commit

Permalink
break enqueueing into its own controller method
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Butz committed Sep 17, 2020
1 parent 8f3a852 commit a0e116c
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions app/controllers/v3/service_route_bindings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,8 @@ def create

case service_instance
when ManagedServiceInstance
bind_job = VCAP::CloudController::V3::CreateRouteBindingJob.new(
precursor.guid,
user_audit_info: user_audit_info,
parameters: message.parameters,
)
pollable_job = Jobs::Enqueuer.new(bind_job, queue: Jobs::Queues.generic).enqueue_pollable
head :accepted, 'Location' => url_builder.build_url(path: "/v3/jobs/#{pollable_job.guid}")
pollable_job_guid = enqueue_bind_job(precursor.guid, message.parameters)
head :accepted, 'Location' => url_builder.build_url(path: "/v3/jobs/#{pollable_job_guid}")
when UserProvidedServiceInstance
action.bind(precursor)
render status: :created, json: Presenters::V3::ServiceRouteBindingPresenter.new(precursor)
Expand Down Expand Up @@ -89,6 +84,16 @@ def valid_message(message_type:)
end
end

def enqueue_bind_job(binding_guid, parameters)
bind_job = VCAP::CloudController::V3::CreateRouteBindingJob.new(
binding_guid,
user_audit_info: user_audit_info,
parameters: parameters,
)
pollable_job = Jobs::Enqueuer.new(bind_job, queue: Jobs::Queues.generic).enqueue_pollable
pollable_job.guid
end

def fetch_route_bindings(message)
fetcher = RouteBindingListFetcher.new
if permission_queryer.can_read_globally?
Expand Down

0 comments on commit a0e116c

Please sign in to comment.