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

Make state comparison more generic #4190

Merged
merged 2 commits into from May 23, 2017

Conversation

Projects
None yet
3 participants
@ruflin
Copy link
Collaborator

commented May 3, 2017

For the state comparison FileStateOS was accessed directly. By having new prospector types there might be different state objects. This is a first step to remove the dependency on FileStateOS and do state comparison string based.


// IsEqual compares the state to an other state supporing stringer based on the unique string
func (s *State) IsEqual(c fmt.Stringer) bool {
return s.String() == c.String()

This comment has been minimized.

Copy link
@tsg

tsg May 3, 2017

Collaborator

Somehow relying on String() functions seems dangerous to me. Perhaps you could have the same logic, but based on a string id that is only computed once and stored in the state?

This comment has been minimized.

Copy link
@ruflin

ruflin May 4, 2017

Author Collaborator

I initially had a ID() function for comparison. I switched it to String() because the Stringer interface already exist. But perhaps have a local interface with ID() string is a better choice? +1 on storing it locally and not generating it every time, as it should not change over time.

@ruflin ruflin added the in progress label May 4, 2017

@ruflin ruflin referenced this pull request May 10, 2017

Closed

Filebeat refactoring / restructuring #4277

7 of 14 tasks complete

@ruflin ruflin force-pushed the ruflin:state-comparison branch from 12da5cc to 7bdef3d May 15, 2017

@ruflin

This comment has been minimized.

Copy link
Collaborator Author

commented May 15, 2017

New version pushed

Make state comparison more generic
For the state comparison FileStateOS was accessed directly. By having new prospector types there might be different state objects. This is a first step to remove the dependency on FileStateOS and do state comparison string based.

@ruflin ruflin force-pushed the ruflin:state-comparison branch from 7bdef3d to 4862d71 May 17, 2017

@@ -10,6 +10,7 @@ import (

// State is used to communicate the reading state of a file
type State struct {
Id string `json:"-"` // local unique id to make comparison more efficient

This comment has been minimized.

Copy link
@elasticmachine

elasticmachine May 17, 2017

Collaborator

[golint] reported by reviewdog 🐶
struct field Id should be ID

This comment has been minimized.

Copy link
@ruflin

ruflin May 17, 2017

Author Collaborator

this can't be ID as it otherwise conflicts with the ID() method.

@@ -33,6 +34,20 @@ func NewState(fileInfo os.FileInfo, path string, t string) State {
}
}

// String returns a unique id for the state as a string

This comment has been minimized.

Copy link
@elasticmachine

elasticmachine May 17, 2017

Collaborator

[golint] reported by reviewdog 🐶
comment on exported method State.ID should be of the form "ID ..."

Make state comparison more generic
For the state comparison FileStateOS was accessed directly. By having new prospector types there might be different state objects. This is a first step to remove the dependency on FileStateOS and do state comparison string based.

@ruflin ruflin force-pushed the ruflin:state-comparison branch from 4862d71 to 0b1a5c0 May 17, 2017

@ruflin ruflin removed the in progress label May 17, 2017

@tsg tsg merged commit 747e5bf into elastic:master May 23, 2017

6 checks passed

CLA Commit author has signed the CLA
Details
codecov/patch 100% of diff hit (target 63.38%)
Details
codecov/project 63.39% (+0.01%) compared to a09c903
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
default Build finished.
Details

ramon-garcia added a commit to ramon-garcia/beats that referenced this pull request Dec 5, 2017

Make state comparison more generic (elastic#4190)
* Make state comparison more generic

For the state comparison FileStateOS was accessed directly. By having new prospector types there might be different state objects. This is a first step to remove the dependency on FileStateOS and do state comparison string based.

* Make state comparison more generic

For the state comparison FileStateOS was accessed directly. By having new prospector types there might be different state objects. This is a first step to remove the dependency on FileStateOS and do state comparison string based.

athom added a commit to athom/beats that referenced this pull request Jan 25, 2018

Make state comparison more generic (elastic#4190)
* Make state comparison more generic

For the state comparison FileStateOS was accessed directly. By having new prospector types there might be different state objects. This is a first step to remove the dependency on FileStateOS and do state comparison string based.

* Make state comparison more generic

For the state comparison FileStateOS was accessed directly. By having new prospector types there might be different state objects. This is a first step to remove the dependency on FileStateOS and do state comparison string based.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.