Skip to content

feat: change to enable token pool#125

Open
ota-meshi wants to merge 2 commits into
unjs:mainfrom
ota-meshi:token-pool
Open

feat: change to enable token pool#125
ota-meshi wants to merge 2 commits into
unjs:mainfrom
ota-meshi:token-pool

Conversation

@ota-meshi

@ota-meshi ota-meshi commented May 24, 2025

Copy link
Copy Markdown

related to #5

This PR will improve the server to make the token pool available.

About the implementation:

Currently the implementation makes the second token available through the GH_TOKEN2 environment variable, but that can be changed. Please let me know your preferred way of defining it.
-> The way tokens are defined has been changed so that GH_TOKENS is specified as an array in JSON.

The priority for using tokens is the token with the most remaining rate limit window. However, since the number of remaining rate limits is not known until each token is used to make a request, they are used in order regardless of the rate limit window.

Additional comments:

We are still discussing how to collect the token pool in #5, so I don't think this PR change alone will enable the token pool, but I would be happy if I could contribute the first step.

Comment thread nitro.config.ts Outdated
export default defineNitroConfig({
runtimeConfig: {
GH_TOKEN: process.env.GH_TOKEN,
GH_TOKEN2: process.env.GH_TOKEN2,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We need to support an array (not just 2 hardcoded) also we need to read it from a json source (in code or later remote URL)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I wasn't sure what the best way to define an array for an environment variable was.
Would it be better to define an array in JSON for an environment variable like GH_TOKENS?
Also, if we define GH_TOKENS, can I remove GH_TOKEN?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

later remote URL

This looks really cool, but I'm not sure how to implement it 😅

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