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

Allow nested parsers on MessageProducer level (v4) #2087

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

AmmarAbouZor
Copy link
Member

This PR isn't for to be merged. It's a suggestion in the scope of work on #2073, #2078 and #2084
It provides the basic implementation for #2071 on parser level.

  • The struct ParseRestResolver implemented to provide methods to parse a given chunks of bytes with a hint about how to parse those bytes.
  • LogMessage doesn't implement Display anymore. Instead, it has the method try_resolve(&self, resolver: Option<&mut ParseRestResolver>) -> Result<impl Display, ...> to try to parse the message using the provided resolver if possible and returning an error to express the case when parsing fails.
  • The trait ParseLogMsgError is defined with methods to parse the messages lossy (replace none-parsed bytes with their byte representation), besides the severity of the error and an error message to be used to collect the errors for proper error handling of parse log messages (as mentions in Consider Errors while parsing messages payload  #2071)
  • LogMessage has and associated error type which implement ParseLogMsgError, giving a chance for parser which never fails to provide Infallible Error type, to tell the compiler that this types will never error for compile time optimizations. Parser that can fail can use the struct GeneralParseLogError which implements the trait ParseLogMsgError.

* Resolver will be passed to resolve method instead of parser returning
  a template.
* Parsing log message is returning an error which is defined by each
  type implementing LogMessage trait.
* Types with no errors sets the error to infallible for compiler
  optimizations.
* This approach enables saving parsing errors.
* Nested errors are ignored for now
* Sessions needs to keep track on errors but indexer CLI doesn't need
  that for now.
* Each part should responsible of how errors for parsing log messages
  should be handled.
* Added reminder for handling resolver in indexer CLI.
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.

1 participant