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

Health service #15

Closed
wants to merge 8 commits into from
Closed

Health service #15

wants to merge 8 commits into from

Conversation

ojcarfr
Copy link
Contributor

@ojcarfr ojcarfr commented Nov 22, 2018

Resolves #1

@ojcarfr ojcarfr requested review from pandiello and removed request for pandiello November 30, 2018 13:28
Copy link

@pandiello pandiello left a comment

Choose a reason for hiding this comment

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

first review. Comments on files.

/// <exception cref="ArgumentException">If the specified value is an invalid value.</exception>
/// <returns>The result of the conversion.</returns>
public static explicit operator HealthStatus(byte value) =>
value <= Unhealthy.value ? new HealthStatus(value) : throw new ArgumentException(nameof(value));

Choose a reason for hiding this comment

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

Could we think about InvalidCastException? maybe is more verbose

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

/// <summary>
/// Represents the status of a health check result.
/// </summary>
public struct HealthStatus : IEquatable<HealthStatus>, IComparable<HealthStatus>

Choose a reason for hiding this comment

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

this functionality is really similar than Enum's one. is the size (enum allocate ints (32 bytes)) justification for maintain this code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, in .Net an enum is only a numeric value, not a closed set.

using System.Threading.Tasks;

/// <summary>
/// A health service that contains multiple <see cref="IHealthCheck"/>.

Choose a reason for hiding this comment

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

There isn't a real dependecy of this abstraction with IHealthCheck.
I'd like to create a more generic comment avoiding mention IHealthCheck

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

/// <exception cref="ArgumentException">If the specified value is an invalid value.</exception>
/// <returns>The result of the conversion.</returns>
public static explicit operator HealthStatus(int value) =>
value <= Unhealthy.value ? new HealthStatus((byte)value) : throw new ArgumentException(nameof(value));

Choose a reason for hiding this comment

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

could be confused when overflow because negative ints? is it a desirable feature?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

/// </summary>
public TimeSpan TotalDuration { get; }

private static HealthStatus GetLowerStatus(IEnumerable<HealthStatus> statuses)

Choose a reason for hiding this comment

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

could be confuse when the overflow of some shorts, int and longs (negative):
see comment: https://github.com/payvision-development/sakikku/pull/15/files#diff-e27231d79f2bbeae67b5011c1aee0cb3R65

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The comparisson is done for HealthStatus types which is a value by itself, so there is not possibility of overflows here.

new Dictionary<string, ReactiveHealthCheck>(StringComparer.OrdinalIgnoreCase);

/// <inheritdoc />
public IHealthCheckFactory Add(string name)

Choose a reason for hiding this comment

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

this way to include elements in a set could include incosistant checks (not calling for on check elements).
We should check on Build method for only the "good" ones or null exception could be thrown when Build method of ReactiveHealthCheck is called.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're absolutelly right

return this;
}

internal IObservable<HealthCheckEntry> Build(IScheduler scheduler)

Choose a reason for hiding this comment

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

I'm not sure but i think this check will only be executed ones per subscription not in a time base.
Maybe we could clarify this point

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually we're building a promise here, which is going to be decorated on the health check set build method. Doing in that way we're going to be able of configure the execution behavior afterwards.

@ojcarfr ojcarfr closed this Jun 7, 2019
@ojcarfr ojcarfr deleted the health_service branch June 7, 2019 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reactive Health Service
2 participants