Skip to content

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

Merged
merged 3 commits into from
Sep 24, 2020

Conversation

bsardo
Copy link
Collaborator

@bsardo bsardo commented Sep 8, 2020

…lta query periodically

)

type PostgresEventProducerConfig struct {
Db *sql.DB
Copy link
Contributor

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?
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'll have to spend some time to understand the details of saves.

Copy link
Collaborator

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.

Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

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

What's #338? Consider including the details from #338 in this comment instead of a github issue reference?


switch dataType {
case "request":
if len(data) == 0 || bytes.Equal(data, []byte("null")) {
Copy link
Contributor

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?
Copy link
Contributor

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?

Copy link
Collaborator Author

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.

hhhjort
hhhjort previously approved these changes Sep 23, 2020
Copy link
Collaborator

@hhhjort hhhjort left a 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?
Copy link
Contributor

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.

@bsardo bsardo requested a review from hhhjort September 24, 2020 17:24
@hhhjort hhhjort merged commit e496c8b into prebid:master Sep 24, 2020
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.

3 participants