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

Add INNGEST_API_BASE_URL and INNGEST_EVENT_API_BASE_URL #378

Merged
merged 4 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/forty-impalas-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"inngest": patch
---

Add `INNGEST_API_BASE_URL` and `INNGEST_EVENT_API_BASE_URL`, used for internal testing
6 changes: 3 additions & 3 deletions packages/inngest/etc/inngest.api.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 15 additions & 6 deletions packages/inngest/src/components/Inngest.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { InngestApi } from "../api/api";
import {
defaultDevServerHost,
defaultInngestBaseUrl,
defaultInngestApiBaseUrl,
defaultInngestEventBaseUrl,
dummyEventKey,
envKeys,
Expand Down Expand Up @@ -102,7 +102,8 @@ export class Inngest<TOpts extends ClientOptions = ClientOptions> {
*/
private eventKey = "";

private readonly baseUrl: string | undefined;
private readonly apiBaseUrl: string | undefined;
private readonly eventBaseUrl: string | undefined;

private readonly inngestApi: InngestApi;

Expand Down Expand Up @@ -162,7 +163,15 @@ export class Inngest<TOpts extends ClientOptions = ClientOptions> {

this.id = id;

this.baseUrl = baseUrl || processEnv(envKeys.InngestBaseUrl);
this.apiBaseUrl =
baseUrl ||
processEnv(envKeys.InngestApiBaseUrl) ||
processEnv(envKeys.InngestBaseUrl);

this.eventBaseUrl =
baseUrl ||
processEnv(envKeys.InngestEventApiBaseUrl) ||
processEnv(envKeys.InngestBaseUrl);

this.setEventKey(eventKey || processEnv(envKeys.InngestEventKey) || "");

Expand All @@ -188,7 +197,7 @@ export class Inngest<TOpts extends ClientOptions = ClientOptions> {
this.fetch = getFetch(fetch);

this.inngestApi = new InngestApi({
baseUrl: this.baseUrl || defaultInngestBaseUrl,
baseUrl: this.apiBaseUrl || defaultInngestApiBaseUrl,
signingKey: processEnv(envKeys.InngestSigningKey) || "",
fetch: this.fetch,
});
Expand Down Expand Up @@ -294,7 +303,7 @@ export class Inngest<TOpts extends ClientOptions = ClientOptions> {

this.sendEventUrl = new URL(
`e/${this.eventKey}`,
this.baseUrl || defaultInngestEventBaseUrl
this.eventBaseUrl || defaultInngestEventBaseUrl
);
}

Expand Down Expand Up @@ -413,7 +422,7 @@ export class Inngest<TOpts extends ClientOptions = ClientOptions> {
* user has set this it means they have already chosen a URL to hit.
*/
if (!skipDevServer()) {
if (!this.baseUrl) {
if (!this.eventBaseUrl) {
const devAvailable = await devServerAvailable(
defaultDevServerHost,
this.fetch
Expand Down
14 changes: 4 additions & 10 deletions packages/inngest/src/components/InngestCommHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { z } from "zod";
import { ServerTiming } from "../helpers/ServerTiming";
import {
debugPrefix,
defaultInngestBaseUrl,
defaultInngestApiBaseUrl,
envKeys,
headerKeys,
logPrefix,
Expand Down Expand Up @@ -390,9 +390,10 @@ export class InngestCommHandler<
this.inngestRegisterUrl = new URL(
"/fn/register",
options.baseUrl ||
this.env[envKeys.InngestApiBaseUrl] ||
this.env[envKeys.InngestBaseUrl] ||
this.client["baseUrl"] ||
defaultInngestBaseUrl
this.client["apiBaseUrl"] ||
defaultInngestApiBaseUrl
);

this.signingKey = options.signingKey;
Expand Down Expand Up @@ -1097,13 +1098,6 @@ export class InngestCommHandler<
`Use of ${envKeys.InngestDevServerUrl} has been deprecated in v3; please use ${envKeys.InngestBaseUrl} instead. See https://www.inngest.com/docs/sdk/migration`
);
}

if (this.env[envKeys.InngestApiBaseUrl]) {
this.log(
"warn",
`Use of ${envKeys.InngestApiBaseUrl} has been deprecated in v3; please use ${envKeys.InngestBaseUrl} instead. See https://www.inngest.com/docs/sdk/migration`
);
}
}

protected validateSignature(sig: string | undefined, body: unknown) {
Expand Down
9 changes: 3 additions & 6 deletions packages/inngest/src/helpers/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,15 @@ export enum envKeys {
InngestDevServerUrl = "INNGEST_DEVSERVER_URL",
InngestEnvironment = "INNGEST_ENV",
InngestBaseUrl = "INNGEST_BASE_URL",
InngestEventApiBaseUrl = "INNGEST_EVENT_API_BASE_URL",
InngestApiBaseUrl = "INNGEST_API_BASE_URL",
InngestServeHost = "INNGEST_SERVE_HOST",
InngestServePath = "INNGEST_SERVE_PATH",
InngestLogLevel = "INNGEST_LOG_LEVEL",
InngestStreaming = "INNGEST_STREAMING",

BranchName = "BRANCH_NAME",

/**
* @deprecated Removed in v3. Use {@link InngestBaseUrl} instead.
*/
InngestApiBaseUrl = "INNGEST_API_BASE_URL",

/**
* The git branch of the commit the deployment was triggered by. Example:
* `improve-about-page`.
Expand Down Expand Up @@ -126,7 +123,7 @@ export enum headerKeys {
RetryAfter = "retry-after",
}

export const defaultInngestBaseUrl = "https://api.inngest.com/";
export const defaultInngestApiBaseUrl = "https://api.inngest.com/";
export const defaultInngestEventBaseUrl = "https://inn.gs/";
export const defaultDevServerHost = "http://127.0.0.1:8288/";

Expand Down
5 changes: 4 additions & 1 deletion packages/inngest/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,10 @@ export interface FunctionOptions<
*
* Specifying just a number means specifying only the concurrency limit.
*/
concurrency?: number | ConcurrencyOption | [ConcurrencyOption, ConcurrencyOption];
concurrency?:
| number
| ConcurrencyOption
| [ConcurrencyOption, ConcurrencyOption];

/**
* batchEvents specifies the batch configuration on when this function
Expand Down