Skip to content

v3 asynchronous endpoint flow

Chris Selzo edited this page Jun 28, 2018 · 7 revisions

Using AppApplyManifest as an example:

Controller flow

(Follow along in app_manifests_controller.rb)

  1. hit endpoint /apply_manifest
  2. construct message from request values
  3. validations on message
  4. fetch models required —> the resource, app, and others (space, org)
  5. raise errors if the resource is not found or if user is not authorized
  6. initialize the action we want
  7. initialize the job we want with the action, message, and any other necessary parameters
  8. record an audit event
  9. enqueue the job
    • this enqueues it in the Delayed::Job table, possibly with a timeout, run by the worker process on the scheduler VM —> in contrast to jobs run inline/immediately, which would be run on the worker processes on the API VM
  10. build the url using the job guid and return that to the user

Action flow

(Follow along in app_apply_manifest.rb)

  1. load the model needed from the db - App, in this case
  2. apply side effects - apply all process updates and scales
  3. update the model - AppUpdate.update
    • go into a transaction
    • update the resource
    • save
    • record event as necessary
  4. apply any changes to associated models, eg.
    • patch environment variables
    • create service bindings if there are services on the message
  5. return the modified model
Clone this wiki locally