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

Refactor logs tail command with channel and visitors #661

Merged

Conversation

vcheung-stripe
Copy link
Collaborator

Reviewers

r? @pepin-stripe
cc @stripe/developer-products

Summary

This decouples user IO and the receiving of logs.

  • The Tailer is concerned with sending data on a channel. The data is either a log, an error, a warning, or a connection state.
  • The cobra command, as a client of the Tailer, receives these different data types and processes them using a visitor object.

This pattern enables Tailer to be used by any class that wants to do something with logs, for example a gRPC service that wants to stream logs, errors, and connection state to a gRPC client. All the class has to do is read from the channel and provide its own visitor object.

This pattern might also work well for #574. This is quite boilerplate heavy, so I am open to other solutions as well.

Copy link
Contributor

@pepin-stripe pepin-stripe left a comment

Choose a reason for hiding this comment

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

didn't know about the visitor pattern, neat :)

@vcheung-stripe vcheung-stripe merged commit 75e8179 into stripe:master May 10, 2021
@vcheung-stripe vcheung-stripe deleted the vcheung/refactor-logs-tail branch May 10, 2021 17:17
az777777 pushed a commit to az777777/stripe-cli that referenced this pull request Jun 22, 2021
* Refactor logs tail command

* cleanup

* renaming

* Renaming
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.

None yet

2 participants