-
Notifications
You must be signed in to change notification settings - Fork 805
Refactor postgres event producer so it will run either the full or de… #1485
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
Conversation
…lta query periodically
) | ||
|
||
type PostgresEventProducerConfig struct { | ||
Db *sql.DB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: Should be DB
per Go naming conventions.
|
||
if err != nil { | ||
glog.Warningf("Failed to fetch all Stored %s data from the DB: %v", e.cfg.RequestType, err) | ||
// e.saves <- events.Save{} //TODO: do we need to do this? |
There was a problem hiding this comment.
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'll have to spend some time to understand the details of saves
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I can see, we shouldn't need to do this ... it should be a noop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After careful analysis of the code :), I agree. Please remove the related commented out lines.
var data []byte | ||
var dataType string | ||
|
||
// Beware #338... we really don't want to save corrupt data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
switch dataType { | ||
case "request": | ||
if len(data) == 0 || bytes.Equal(data, []byte("null")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving []byte("null")
to a package constant.
} | ||
} | ||
|
||
//TODO: do we really need to check that this isn't a fetch all here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add more context about the question in this comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this comment with no changes to the code. I think that we should keep the check in here to ensure that cache invalidations only occur during a fetch delta. When we fetch all, the cache should be empty so there's no reason to perform any cache invalidations, even if the data returned is empty or null
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good.
|
||
if err != nil { | ||
glog.Warningf("Failed to fetch all Stored %s data from the DB: %v", e.cfg.RequestType, err) | ||
// e.saves <- events.Save{} //TODO: do we need to do this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After careful analysis of the code :), I agree. Please remove the related commented out lines.
…lta query periodically