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

[RFC]: Add a ResultData object as Result data #59

Closed
bram123 opened this issue Nov 11, 2022 · 1 comment
Closed

[RFC]: Add a ResultData object as Result data #59

bram123 opened this issue Nov 11, 2022 · 1 comment

Comments

@bram123
Copy link
Contributor

bram123 commented Nov 11, 2022

RFC

Q A
Proposed Version(s) 1.x.x
BC Break? Yes/No/Maybe

Goal

Provide a structured class to use when providing extra details about a executed check.

Background

I'm looking into using this package to generate an API health endpoint, for that we'd need more data besides the fact that a check was successful. In previous PRs I already added some data to some checks, but got a review point to see if we can make this more structured/typed.

The idea is to add a ResultData object so Checks can provide extra data in a set format.

Considerations

Big question is, are the current Check's data returns covered by BC?
DiskUsage::check()->getData is now always an int, even though it's typed to mixed|null.

If we were to have a class available, these checks couldn't just switch over. Otherwise users of this package, who currently assume it's an int, will suddenly get something else.

Proposal(s)

Add a new ResultData object into Laminas\Diagnostics\Result, or Laminas\Diagnostics\Result\Data.
Preferably not simply key + value, but:

  • key (uptime / responseTime / connections / utilization)
  • value
  • valueType (second, milisecond, percentage)

Quick proposal:

$data = new ResultData();
$data->addDetail(uptime, 500, seconds);

return new Success("Connected successfully", $data);

Appendix

I got this as review point in a previous PR: #57 (comment).
The PR was merged already (thanks for that), but I didn't want to 'forget about it'.

@bram123 bram123 added the RFC label Nov 11, 2022
@Ocramius
Copy link
Member

Big question is, are the current Check's data returns covered by BC?

I would say no until the types are actually refined.

In fact, I would say that Success<T> should be defined, where we declare T on each of the various Check implementations.

I don't think that a ResultData structure is needed there, if the type is well defined: then it would be covered by BC.

@bram123 bram123 closed this as not planned Won't fix, can't repro, duplicate, stale Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants