twilight icon indicating copy to clipboard operation
twilight copied to clipboard

Make Gateway optionally depend on HTTP

Open A5rocks opened this issue 3 years ago • 3 comments

I believe twilight-gateway's dependency on twilight-http is unnecessary most of the time, and thus for bots that do not interact with the HTTP API this brings in unneeded dependencies to compile.

Here's the parts that I see as needing the dependency on twilight-http:

  1. ShardScheme::Auto.
  2. Getting Gateway URL.
  3. Session start info in twilight-gateway-queue.

The following would be necessary:

  1. Conditionally defining ShardScheme::Auto -- I'm not sure if this is a very nice thing to do for libraries that depend on twilight-gateway.
  2. Config already lets people specify the gateway url: simply conditionally compile the new methods that don't take in a custom config and perhaps conditionally change the type of the gateway url in the configuration.
  3. I don't believe session start info is necessary most of the time: most of the time, there's a lot of sessions left to start. If there isn't enough sessions, then passing the limit resets the session limit (AFAIK?) and so is probably the wanted behavior for small bots as those normally restart by closing all previous sessions and starting new ones (so without passing the limit and resetting it to 1000, the small bot would have to wait a day to get back online).

Nonetheless, the dependency should be left as a default feature; most bots are going to use HTTP anyways and so this dependency golfing is meaningless for them.

A5rocks avatar Feb 06 '22 04:02 A5rocks

Shard::new could conditionally require a ShardScheme & a gateway_url if a hypothetical http feature is disabled, but rustdoc is unable to highlight feature gated arguments, so it's unclear how this would be documented.

Another possibility would be to check for a user provided ShardScheme and gateway_url at runtime, erroring if not found and http isn't enabled (forcing the use of ShardBuilder when twilight-http isn't enabled)

vilgotf avatar Feb 18 '22 17:02 vilgotf

twilight-http is now an optional dep on twilight-gateway-queue, required for LargeBotQueue.

ShardScheme::Auto is being removed in #1600, but twilight-http is still required as a fallback for when the scheme is unspecified. twilight-http is still required for the gateway URL for the same reason.

vilgotf avatar Mar 22 '22 10:03 vilgotf

Gateway URL is now hard coded unless manually overwritten #1763

vilgotf avatar Jun 03 '22 05:06 vilgotf

Available on next, Twilight 0.14

vilgotf avatar Sep 27 '22 06:09 vilgotf