Skip to content

Instantly share code, notes, and snippets.

@blomquisg
Created January 5, 2018 19:37
Show Gist options
  • Save blomquisg/3c4b541015c26afe2b95be1b27ab04f1 to your computer and use it in GitHub Desktop.
Save blomquisg/3c4b541015c26afe2b95be1b27ab04f1 to your computer and use it in GitHub Desktop.
Provider
--------
def destroy
managers.each { |m| m.destroy }
super
end
Manager
-------
def destroy
disable! if enabled?
kill_ems_workers
super
end
Worker
------
def kill
Process.kill(9, pid).wait!
destroy
end
@Fryguy
Copy link

Fryguy commented Jan 5, 2018

Provider
--------

def destroy(task_id = nil)
  managers.destroy_all
  super().tap do
    if task_id
      # update_status_and_log
    end
  end
end

Manager
-------

# Remove  the dependent destroys from the leaf classes

def destroy(task_id = nil)
  disable! if enabled?

  # destroy child managers if there are any

  # kill ems workers

  super().tap do
    if task_id
      # update_status_and_log
    end
  end
end

Worker
------

def kill
  Process.kill(9, pid)

  loop do
    break unless alive?
    sleep 0.01
  end

  destroy
end

@chessbyte
Copy link

Should the provider's destroy method have the following line at the top?

disable! if enabled?

@blomquisg
Copy link
Author

Providers don't have a disable concept today. And, we might be moving away from the provider concept as a whole. So, we probably aren't going to add it. Jason, me, Adam, and others need to have a good long discussion on the whole provider/manager concept. We just keep putting it on the back burner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment