Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
faec merged 6 commits into
elastic:masterfrom
faec:spool-internal
Mar 5, 2020
Merged

[libbeat] [cleanup] make spool.{Spool, Settings} internal#16693
faec merged 6 commits into
elastic:masterfrom
faec:spool-internal

Conversation

@faec
Copy link
Copy Markdown

@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
Copy Markdown

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
Copy Markdown
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 pushed 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.

2 participants