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

Factor out common Graphite code #1932

Merged
merged 4 commits into from
Mar 12, 2015
Merged

Factor out common Graphite code #1932

merged 4 commits into from
Mar 12, 2015

Conversation

otoolep
Copy link
Contributor

@otoolep otoolep commented Mar 12, 2015

No description provided.

Comments imply it should be this name in any event.
@otoolep otoolep force-pushed the ol_refactor branch 2 times, most recently from 5bcbd58 to f41530d Compare March 12, 2015 19:18
@otoolep
Copy link
Contributor Author

otoolep commented Mar 12, 2015

After reviewing some recent changes by @corylanou it seem to me we've now got too much boilerplate when bringing up a Graphite server. This change factors it out into the Graphite package.

@corylanou -- let me know what you think.

@@ -12,7 +12,7 @@ import (

// TCPServer processes Graphite data received over TCP connections.
type TCPServer struct {
server Server
server SeriesWriter
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I like how these names now line up. I understand that we introduced another Server interface above. Might be better as GraphiteServer and then Server or something along that line. I can see this be confusing for the next developer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I think I follow you. Let me take another pass at this. However, calling something GraphiteServer within the graphite package does not follow Go style.

By doing this the SeriesWriter interface stays focused and just has
methods for writing data. Its name then remains coherent.
@otoolep
Copy link
Contributor Author

otoolep commented Mar 12, 2015

@corylanou -- take a look now. I think the key to this refactor is to keep SeriesWriter focused on just exposing an interface for writing points. SeriesWriter shouldn't need to know how to create databases, check existence etc -- have the existing server object do that as part of the Graphite set up.

I also added a CreateDatabaseIfNotExists function, since we seem to have this pattern in our code already.

@@ -752,6 +752,14 @@ func (s *Server) CreateDatabase(name string) error {
return err
}

// CreateDatabaseIfNotExists creates a new database if, and only if, it does not exist already.
func (s *Server) CreateDatabaseIfNotExists(name string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could use some tests around this new method.

@corylanou
Copy link
Contributor

One nit, update changelog, and 🚢

@otoolep
Copy link
Contributor Author

otoolep commented Mar 12, 2015

Merging now. Thanks @corylanou

otoolep added a commit that referenced this pull request Mar 12, 2015
Factor out common Graphite code
@otoolep otoolep merged commit aecb9b5 into master Mar 12, 2015
@otoolep otoolep deleted the ol_refactor branch March 12, 2015 21:24
mark-rushakoff pushed a commit that referenced this pull request Jan 11, 2019
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.

2 participants