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

feat: complete (mostly) the WebPushClient #379

Merged
merged 3 commits into from
May 22, 2023
Merged

Conversation

pjenvey
Copy link
Member

@pjenvey pjenvey commented May 17, 2023

@pjenvey pjenvey requested a review from jrconlin May 17, 2023 04:53
});
}
}
// NOTE: when the client's specified a uaid but get_user returns
Copy link
Member Author

Choose a reason for hiding this comment

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

Wanted to point this out as one difference between the other state machine. Previously we only set the defer_add_user (previously called deferred_registration) for when clients did not specify a uaid.

Now we're doing it for any case where we would have created a brand new user record -- including when a user specifies a uaid and its lookup failed or its record was invalid.

@pjenvey pjenvey force-pushed the feat/sm-storage-SYNC-3688 branch from 57eb0dc to 50e9d12 Compare May 17, 2023 22:54
@pjenvey
Copy link
Member Author

pjenvey commented May 17, 2023

Added an integration test run against this to ci

@@ -15,20 +15,37 @@ pub const HELLO: &str = r#"{"messageType": "hello", "use_webpush": true}"#;
pub const HELLO_AGAIN: &str = r#"{"messageType": "hello", "use_webpush": true,
"uaid": "deadbeef-0000-0000-deca-fbad00000000"}"#;

pub const CURRENT_MONTH: &str = "message_2023_5";
Copy link
Member

Choose a reason for hiding this comment

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

I'm tempted to suggest that we either use the current, production value here (message_2017_09 IIRC), or remove the table rotation code entirely since it's no longer useful and just adds complications.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed this test value to match prod, of course we can't hardcode the result of Db::message_month to such a value though (in case you're suggesting that which you probably aren't).

Copy link
Member Author

Choose a reason for hiding this comment

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

With the metrics we saw yesterday I'll definitely remove the table migration code in a separate PR (mostly to document it in isolation). I think it will end up having us match autoendpoint's validate_webpush_user even more closely.

jrconlin
jrconlin previously approved these changes May 18, 2023
Copy link
Member

@jrconlin jrconlin left a comment

Choose a reason for hiding this comment

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

minor notes, but nothing I'm going to block over.

Thanks!

self.app_state.db.fetch_messages(&self.uaid, 11).await?
} else {
Default::default()
};
Copy link
Member

Choose a reason for hiding this comment

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

This bit feels a bit confusing.

We check for topics first, returning them if there are any, otherwise we set the timestamp if we're supposed to include topics. Then we try fetching any pending messages.

It might be useful to add some comment blocks around the two parts, so it's a bit more obvious the division we're doing, and maybe change the first resp to something like topics_resp so it's a bit more obvious that there are two fetches going on?

Copy link
Member Author

Choose a reason for hiding this comment

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

I definitely meant to document the guts of check_storage more, I just added that as a TODO for now, but renamed the resp vars.

@@ -510,6 +511,35 @@ impl DbClient for DdbClientImpl {
})
}

async fn increment_storage(&self, uaid: &Uuid, timestamp: u64) -> DbResult<()> {
Copy link
Member

Choose a reason for hiding this comment

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

TODO: jr to add increment_storage and save_messages to #364

@jrconlin
Copy link
Member

FWIW: I pre-emptively merged this PR into #364. One thing that I spotted was that I don't know if we actually use the user timestamp field. (partly because of the way that BigTable keys work.) I'll dig into that a bit more next week.

@pjenvey
Copy link
Member Author

pjenvey commented May 19, 2023

Which timestamp? db::User doesn't have one

@jrconlin
Copy link
Member

Sorry, the one we write to the database in the User meta record for DynamoDB. It's the field updated in increment_storage.

@pjenvey pjenvey merged commit f711021 into master May 22, 2023
@pjenvey pjenvey deleted the feat/sm-storage-SYNC-3688 branch May 22, 2023 18:01
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