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]: Change AppCtx to handle multiple API objects #11

Closed 21Bruce closed 9 months ago

21Bruce commented 1 year ago

Is there an existing issue for this feature?

Description of the problem

Now that there are two APIs, the AppCtx object should be improved to allow for multiple API objects and multiplex properly between them. This will affect developers and end-users, as well as any current applications.

Planned Solution

My solution will introduce the ability to register multiple APIs to the AppCtx object, and restructure the semantics of API calls to force them to specify which API to perform scheduling ops on.

Alternatives

I've considered moving the multiplexing to the runnable layer, so like each runnable makes a separate app context for each api, but then that defeats the point of the common api interface almost, plus I wouldn't want to redo multiplexing logic across runnables

Solution Specifics

I'll update this with more specifics in a few days

21Bruce commented 1 year ago

Working on this next

21Bruce commented 1 year ago

Implemented a basic API multiplexing scheme at the AppCtx level, need to push this changed downstream to ResolvedCLi

21Bruce commented 1 year ago

Note:

To address API swaps(which requires parsing of different login flags), I've implemented a new cli Flag API called an 'arbitrator'. Basically, an arbitrator is a function that takes in a list of the flag's arguments and outputs a list of flags. When a flag is parsed, if it has an arbitrator, the arbitrator will get run with the flag's arguments as input and the output flag list will be appended to the parser's working flag list. This way, we can implement an -a|--api flag, which will dynamically change the parser depending on its input argument. Will probably update ResolvedCLI with this new feature tonight or tomorrow night