Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrap first gem version #1

Merged
merged 16 commits into from
Jun 29, 2017
Merged

Bootstrap first gem version #1

merged 16 commits into from
Jun 29, 2017

Conversation

ivoanjo
Copy link
Contributor

@ivoanjo ivoanjo commented Jun 29, 2017

See individual commits AND the beautiful README I wrote for details :)

Ivo Anjo added 9 commits June 29, 2017 10:56
Used `bundler gem warm-blanket` to generate template and slightly
tweaked it to our standards.
This class takes a list of endpoints and makes a request to one of them
(in order) every time it is called.
This class waits for a given port to be open on the target machine.
end
end

WarmBlanket.instance_eval do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this be included in the above module definition?

module WarmBlanket
  extend Dry::Configurable

  setting ...

  def self.trigger_warmup(...)
  end
end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes indeed. I got confused by the documentation and thought that maybe it did not work as expected on modules, but re-testing the assumption it turns out that is not the case.

Fixed in 65fe3d2

Ivo Anjo added 3 commits June 29, 2017 14:05
Due to a misunderstanding of dry-configuration documentation I believed
that we could not use their module and configuration on a `module`
rather than a `class`; but after a review suggestion it turns out that
it works, so we can simplify the configuration.
The two fixed methods are instance methods, not class methods, and thus
they should be prefixed with `#` and not with `.`.
Otherwise, we would fail when picking up the port from an environment
variable.

tries = 0

while true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would a default timeout make sense here? Asking because due to the current state of affairs, we really don't want this to still be running when the new dynos start receiving production traffic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to approximate it with a attempts counter, but I can switch to a time-based scheme, that indeed would give us better guarantees of how much time is spent here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reported as #2

end
end

def wait_for_port_to_open

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of renaming this to port_is_open?? Or port_is_finally_open? :P
Asking because this is being used in the if block above, and it's a bit weird to read if wait_for_port_to_open. Aka, nitpicking 💅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I see your point, but I wanted to highlight that this is a non-trivial operation that may take time.

What do you think if I instead changed #orchestrate to be

def orchestrate
  success = wait_for_port_to_open
   
  spawn_warmup_threads if success
end

Thus eliminating the confusing if?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 5c6cc10


logger.debug "Requesting #{endpoint.fetch(:get)}"

response = connection.get do |request|

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flexibility over the verb is desirable (e.g.: Permissions API requires a POST).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to get away with just get on the first version, will do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although we'll have to be careful with any side effects caused by such a post.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feature added in 132830b

@trenpixster
Copy link

LGTM! Merge away! 👍

@ivoanjo
Copy link
Contributor Author

ivoanjo commented Jun 29, 2017

Thanks! Merging ahead, and I'll create an issue to track the time-based waiting for port work separately.

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

Successfully merging this pull request may close these issues.

3 participants