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

Make ValueHandler public so it is easier to create custom status item parsers #98

Closed

Conversation

natewalck
Copy link
Contributor

This allows external code to easily parse a given statusitem path

@jessepeterson
Copy link
Owner

Can you tell me how you're planning to use this?

valueHandler is used for the internal parsing of status items to populate the internal StatusReport by way of parseStatusReportValue (for handing off to the storage layers).

You should just be able to implement a custom jsonpath.Handler and attach it to the mux with a path for anything custom.

@natewalck
Copy link
Contributor Author

Can you tell me how you're planning to use this?

valueHandler is used for the internal parsing of status items to populate the internal StatusReport by way of parseStatusReportValue (for handing off to the storage layers).

You should just be able to implement a custom jsonpath.Handler and attach it to the mux with a path for anything custom.

I was looking at this as inspiration: https://github.com/jessepeterson/kmfddm/blob/main/ddm/status.go#L204-L209

It appears that parseStatusReportValue handles figuring out the values of the items in the rawbytes, so I was hoping to avoid having to write my own parsing for that.

Is parseStatusReportValue specific to one particular status item payload? Will we need a parser for each one?

@jessepeterson
Copy link
Owner

I was looking at this as inspiration: https://github.com/jessepeterson/kmfddm/blob/main/ddm/status.go#L204-L209

It appears that parseStatusReportValue handles figuring out the values of the items in the rawbytes, so I was hoping to avoid having to write my own parsing for that.

Almost. The raw bytes are already turned into a *fastjson.Value when it gets to the handler. It's up to the handler to handle that however it wants.

Is parseStatusReportValue specific to one particular status item payload? Will we need a parser for each one?

parseStatusReportValue parses things under .StatusItems.management (i.e. all the "informational" data returned from a status report—excepting declarations which use a different handler under a different, lower/embedded path).

To parse anything other than the four built-in paths yes, you have to write your own handler/parser.

@natewalck natewalck closed this Aug 15, 2024
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.

2 participants