21Bruce / resolved-bot

Resolved is a resy bot that assists in obtaining difficult or high-end reservations. Although it only works with resy, there is an opentable api in the tree.
BSD 3-Clause "New" or "Revised" License
41 stars 10 forks source link

[FEATURE]: Early Authentication + api.Time replacement #25

Closed 21Bruce closed 8 months ago

21Bruce commented 8 months ago

Is there an existing issue for this feature?

Description of the problem

We would like to implement a method for reducing the overhead of reservation-making http transcations by authenticating before the request date. This should reduce the RTT of the reservation operation by 1/4. Since this issue deals with manipulating dates, we find that a replacement of the api.Time abstraction with the go Time pkg.

Planned Solution

The first steps have already been implemented. These involved adding a method to the api interface that allows a consumer of the interface to extract a minimum auth time variable, which details the minimum amount of time a login token is viable for after a call to login. Then from here we analyzed the resy cookies and found that, accounting for a maximum time-zone diff of 24 hours, the resy auth token is viable for a minimum of 6 days. Now, we seek to utilize this abstraction + the specific value for resy to implement early authentication via the following pseudocode restructuring of the reserveAtTime operation function:

REQUESTDATE - MINAUTHDATE = AUTHDATE

if (AUTHDATE < NOW) { authenticate sleep till REQUESTDATE } else { sleep till AUTHDATE authenticate sleep till REQUESTDATE }

send request

Alternatives

Implementing a function that substracts api.times in a logical manner v.s. replacing api.time. Figured this function would be very complex

Solution Specifics

See planned solution

21Bruce commented 8 months ago

Closed with PR #26