forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring of filestream input backend (elastic#22448) (elastic#22866)
## What does this PR do? This PR refactors parts of the filestream input. A new interface is added named `resourceLocker` to let the `HarvesterGroup` lock resources from the store with fewer hops. Another new interface is added for cleaning up the internal states before a `loginp.Prospector` is started. These cleaner functions can clean entries of removed files and update IDs if the `file_identity` configuration is changed. The bookkeeping of readers is now threadsafe. From now on `source.Name()` returns only a suffix of the state ID. The prefix `{input_type}::{user_id}` is added by a new interface `sourceIder` (I am open for better names.). ```golang // SourceIder generates an ID for a Source. type sourceIder interface { ID(Source) string } ``` A special store is added as well which accepts `Source` interface as parameters and gets the full ID from a `sourceIder` instance. Only the interface `StateMetadataUpdater` is now accepted by `prospector.Run`. ```golang // StateMetadataUpdater updates and removes the state information for a given Source. type StateMetadataUpdater interface { // FindCursorMeta retrieves and unpacks the cursor metadata of a Source. FindCursorMeta(s Source, v interface{}) error // UpdateMetadata updates the source metadata of a registry entry for a given Source. UpdateMetadata(s Source, v interface{}) error // Remove marks a state for deletion with a given Source. Remove(s Source) error } ``` Important difference between `sourceStore` and `store` is that the first one only deals with `Source` parameters. When you use `store`, you need to specify the full ID of an entry in the format of `{input_type::user_id::source_id}`. ## Why is it important? Cleaner architecture, responsibilities are separated even more. Prospector can stop/start readers out of band. (cherry picked from commit f8f1be7)
- Loading branch information
Showing
15 changed files
with
727 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.