Skip to content
This repository was archived by the owner on Mar 11, 2024. It is now read-only.

Status checking#7

Open
laz2 wants to merge 3 commits intomatiaskorhonen:masterfrom
laz2:status-checking
Open

Status checking#7
laz2 wants to merge 3 commits intomatiaskorhonen:masterfrom
laz2:status-checking

Conversation

@laz2
Copy link

@laz2 laz2 commented Apr 6, 2014

Monit service has fields status and status_hint. If error occurs then monit sets bit in status field and resets same bit in status_hint.
I add constants and method for errors checking in status field.

Choose a reason for hiding this comment

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

Seems like passing in code is done purely for testing purposes; it'd be better to not do so and instead find some other way to set the status, probably by mocking a Service object.

Also I don't quite understand why exact was added; what's wrong with always being exact, or always being fuzzy?

Copy link
Author

Choose a reason for hiding this comment

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

Passing code to method allows error checking, because monit stores codes in status and error flags in status_hint.

Choose a reason for hiding this comment

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

I'm confused, then; how does code allow error checking? Shouldn't has_errors? already have all the information it needs between the Service object and the constants you've added?

Copy link
Author

Choose a reason for hiding this comment

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

Monit has many errors flags. Argument code allows testing of special error codes. If you call has_errors? without arguments then it just determine presence of errors.

Choose a reason for hiding this comment

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

Ah I get it now, thanks for explaining.

I guess I prefer the ActiveRecord way of doing things. .valid? doesn't let you assert against specific errors but rather only generally if there was an error. To check against specific errors, you have to check .errors

I suppose it's just personal preference, though.

@anujbiyani
Copy link

👍 for a has_errors? method. Added some of my own thoughts above, though I'm not a collaborator.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants