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

Define more precisely Collector lifecyle #635

Open
douglas-raillard-arm opened this issue Jul 17, 2023 · 0 comments
Open

Define more precisely Collector lifecyle #635

douglas-raillard-arm opened this issue Jul 17, 2023 · 0 comments

Comments

@douglas-raillard-arm
Copy link
Contributor

The Collector documentation only states the constraint that reset() must be called at least once before the first start() call.
There is a number of important points that are not addressed and might be useful to formalize, even if they differ from one collector to another:

  • reentrancy: Whether multiple instances of the collector can be nested successfully. This is not granted and many collectors cannot because of fundamental reasons, but some can (like dmesg if you don't force emptying the buffer).
  • Whether collection can be interrupted and resumed and what will be the result, i.e. the sequence reset() -> start() -> stop() -> start() -> stop(). It might mean the output is the logical combination of what happened during the first start()/stop() pair and the 2nd one, or it could mean the result of the first start()/stop() is discarded (i.e. implicit reset() on start()).
    I think most collectors would simply discard the data during the first start()/stop() pair by virtue of assigning the results to a single attribute in stop() (vs storing it in e.g. a list of results to be combined later). Collectors storing the data straight in their output file would also likely behave this way.
  • What happens on invalid sequences, such as reset() -> stop() -> stop(): that's the easiest to fix, as we could enforce a state machine with metaprogramming in CollectorBase and raise a consistent exception. We simply need to apply a decorator that checks valid transitions on start(), stop() and reset() using CollectorBase.__init_subclass__. This would avoid having to make a breaking change (e.g. have subclasses define _reset() and let a generic CollectorBase.reset() handle the check)
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

No branches or pull requests

1 participant