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

[libbeat] [cleanup] make spool.{Spool, Settings} internal #16693

Merged
merged 6 commits into from
Mar 5, 2020

Conversation

faec
Copy link
Contributor

@faec faec commented Feb 28, 2020

What does this PR do?

Similar to #16667, spool.Spool is an implementation of the queue.Queue interface that is unreferenced outside its own package. This PR renames both the spool and its settings to internal types:

  • spool.Spool -> spool.diskSpool
  • spool.Settings -> spool.settings

so that the disk spool can only be referenced via its queue.Queue implementation in the beats registry.

This PR has no user-visible effects.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works

@faec faec requested a review from urso February 28, 2020 17:47
// NewSpool creates and initializes a new file based queue.
func NewSpool(logger logger, path string, settings Settings) (*Spool, error) {
// newDiskSpool creates and initializes a new file based queue.
func newDiskSpool(logger logger, path string, settings settings) (*diskSpool, error) {
Copy link

Choose a reason for hiding this comment

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

These have been public on purpose, so to allow us to reuse the Spool as is as a library. The 'Factory' approach to generate a queue.Queue would require us to go with an untyped config.
This might become interesting for the docker logging plugin in the future, maybe, maybe not :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, memqueue.NewQueue is exported for similar reasons (it is used in only one place to create an explicit queue with hard-coded settings). But I suspect the need to create a transactional on-disk queue is relatively rare -- at least, it wouldn't be a lightweight or casual choice -- so it's easy to revisit the exported API once such an application does arise.

My preference, since this feature is beta and other planned uses don't yet have solid requirements, is to start with things internal and make elements public as we're confident about the interface we want to support in the future. But if you feel strongly I can re-export Settings and wrap this helper in spool.NewQueue as in the memqueue case, which would at least restrict external dependencies to the queue interface instead of the specific implementing type.

@faec faec merged commit 76b6bdc into elastic:master Mar 5, 2020
@faec faec deleted the spool-internal branch March 6, 2020 19:11
@faec faec added the v7.7.0 label Mar 6, 2020
faec added a commit to faec/beats that referenced this pull request Mar 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants