### Basic H3 Server Setup Source: https://www.inngest.com/docs-markdown/getting-started/h3-quick-start Create a basic H3 server file to get started. ```typescript import { createApp, createRouter, eventHandler, toNodeListener } from "h3"; import { createServer } from "node:http"; const app = createApp(); const router = createRouter(); app.use(router); createServer(toNodeListener(app)).listen(3000, () => { console.log("Server running on http://localhost:3000"); }); ``` -------------------------------- ### Install Checkpointing Package (Go) Source: https://www.inngest.com/docs-markdown/setup/checkpointing Install the Inngest Go SDK checkpointing package using `go get`. ```shell go get github.com/inngest/inngestgo/pkg/checkpoint ``` -------------------------------- ### Install Inngest SDK for Go Source: https://www.inngest.com/llms-full.txt Install the Inngest SDK for Go projects using the go get command. ```shell go get github.com/inngest/inngestgo ``` -------------------------------- ### Install and Run Inngest Dev Server Source: https://www.inngest.com/docs/getting-started/python-quick-start Installs the Inngest CLI and starts the Dev Server for local development and testing of Inngest functions. ```bash # Install the CLI - follow the steps to complete install: curl -sSfL https://cli.inngest.com/install.sh | sh # Run the dev server inngest dev -u http://localhost:8000/api/inngest ``` -------------------------------- ### Install Workflow Kit Source: https://www.inngest.com/docs/reference/workflow-kit Install the Workflow Kit and Inngest using npm or yarn. Ensure you have an Inngest setup and are ready to serve Inngest functions. ```bash npm install @inngest/workflow-kit inngest ``` -------------------------------- ### Express Server Setup and Event Sending Source: https://www.inngest.com/docs-markdown/getting-started/express-quick-start This snippet shows how to set up an Express server, integrate Inngest, and define a GET endpoint that sends a 'test/hello.world' event to Inngest. ```typescript import express from "express"; import { serve } from "inngest/express"; import { inngest, functions } from "./src/inngest" const app = express(); app.use(express.json()); app.use("/api/inngest", serve({ client: inngest, functions })); // Create a new route app.get("/api/hello", async function (req, res, next) { await inngest.send({ name: "test/hello.world", data: { email: "testUser@example.com", }, }).catch(err => next(err)); res.json({ message: 'Event sent!' }); }); app.listen(3000, () => { console.log('Server running on http://localhost:3000'); }); ``` -------------------------------- ### Installation Source: https://www.inngest.com/docs-markdown/cli You can install the Inngest CLI using npm, Homebrew, or a curl script. ```APIDOC ## Installation ### Using npm ```bash npx inngest-cli@latest ``` ### Using Homebrew ```bash brew install inngest/tap/inngest ``` ### Using curl script ```bash curl -sfL https://cli.inngest.com/install.sh | sh ``` ``` -------------------------------- ### Install Inngest CLI with curl Source: https://www.inngest.com/docs-markdown/cli Installs the Inngest CLI by downloading and executing an installation script. ```bash curl -sfL https://cli.inngest.com/install.sh | sh ``` -------------------------------- ### Setup Source: https://www.inngest.com/llms-full.txt To make `step.metadata()` available, add `metadataMiddleware()` to your Inngest client configuration. ```APIDOC ## Setup Add `metadataMiddleware()` to your Inngest client: ```ts new Inngest({ id: "my-app", middleware: [metadataMiddleware()] }); ``` This makes `step.metadata()` available inside function handlers and `inngest.metadata` available on the client instance. ``` -------------------------------- ### Inngest Start Command Help Source: https://www.inngest.com/docs/self-hosting View all available command-line options for starting the Inngest server. This includes configuration, networking, and persistence settings. ```bash $ inngest start --help ``` -------------------------------- ### Define a simple Inngest function Source: https://www.inngest.com/blog/queues-are-no-longer-the-right-abstraction Define a simple Inngest function that logs a message. This is a basic example to get started with Inngest. ```typescript import { event, Inngest } from "@inngest/next"; const inngest = new Inngest({ id: "my-app", }); export const hello = new Inngest.Function( { name: "Hello World", trigger: { event: "app/hello_world", }, }, async ({ event }) => { console.log(`Received event: ${event.name} with data:`, event.data); return { body: `Hello ${event.data.name}!`, }; } ); ``` -------------------------------- ### Example: Get a function run Source: https://www.inngest.com/docs-markdown/cli Example of how to get a specific function run using its ID. ```APIDOC ## Example: Get a function run ```bash npx inngest-cli@latest api get-function-run 01KTCTWT8XDEGWDMVX3Q9M69ND ``` ``` -------------------------------- ### Inngest Start Command Options Source: https://www.inngest.com/docs/self-hosting This output details the various options available when starting the Inngest server via the CLI. It covers essential parameters like event keys, signing keys, host, port, and SDK URLs, as well as advanced and persistence-related configurations. ```bash NAME: inngest start - [Beta] Run Inngest as a single-node service. USAGE: inngest start [options] DESCRIPTION: Example: inngest start OPTIONS: --config string Path to an Inngest configuration file --event-key string [ --event-key string ] Event key(s) that will be used by apps to send events to the server. --help, -h show help --host string Inngest server hostname --port string, -p string Inngest server port (default: "8288") --sdk-url string, -u string [ --sdk-url string, -u string ] App serve URLs to sync (ex. http://localhost:3000/api/inngest) --signing-key string Signing key used to sign and validate data between the server and apps. Must be hex string with even number of chars Advanced --connect-gateway-port int Port to expose connect gateway endpoint (default: 8289) --no-ui Disable the web UI and GraphQL API endpoint (default: false) --poll-interval int Interval in seconds between polling for updates to apps (default: 0) --queue-workers int Number of executor workers to execute steps from the queue (default: 100) --retry-interval int Retry interval in seconds for linear backoff when retrying functions - must be 1 or above (default: 0) --tick int The interval (in milliseconds) at which the executor polls the queue (default: 150) Persistence --postgres-conn-max-idle-time int Sets the maximum amount of time, in minutes, a PostgreSQL connection may be idle. (default: 5) --postgres-conn-max-lifetime int Sets the maximum amount of time, in minutes, a PostgreSQL connection may be reused. (default: 30) --postgres-max-idle-conns int Sets the maximum number of idle database connections in the PostgreSQL connection pool. (default: 10) --postgres-max-open-conns int Sets the maximum number of open database connections allowed in the PostgreSQL connection pool. (default: 100) --postgres-uri string PostgreSQL database URI for configuration and history persistence. Defaults to SQLite database. --redis-uri string Redis server URI for external queue and run state. Defaults to self-contained, in-memory Redis server with periodic snapshot backups. --sqlite-dir string Directory for where to write SQLite database. GLOBAL OPTIONS: --json Output logs as JSON. Set to true if stdout is not a TTY. (default: false) --verbose Enable verbose logging. (default: false) --log-level string, -l string Set the log level. One of: trace, debug, info, warn, error. (default: "info") ``` -------------------------------- ### Simple Go Function Example Source: https://www.inngest.com/docs-markdown/guides/working-with-loops Demonstrates the equivalent of the JavaScript example in Go, highlighting the use of `step.Run` for managing execution. ```go import ( "fmt" "github.com/inngest/inngestgo" "github.com/inngest/inngestgo/step" ) inngestgo.CreateFunction( client, inngestgo.FunctionOpts{ID: "simple-function"}, inngestgo.EventTrigger("test/simple.function", nil), func(ctx context.Context, input inngestgo.Input[map[string]any]) (any, error) { fmt.Println("hello") _, err := step.Run(ctx, "a", func(ctx context.Context) (any, error) { fmt.Println("a") return nil, nil }) if err != nil { return nil, err } _, err = step.Run(ctx, "b", func(ctx context.Context) (any, error) { fmt.Println("b") return nil, nil }) if err != nil { return nil, err } _, err = step.Run(ctx, "c", func(ctx context.Context) (any, error) { fmt.Println("c") return nil, nil }) if err != nil { return nil, err } return nil, nil }, ) ``` -------------------------------- ### Create Virtual Environment and Install Dependencies Source: https://www.inngest.com/docs/getting-started/python-quick-start Sets up a Python virtual environment and installs necessary packages for FastAPI and Inngest. ```bash python -m venv .venv && source .venv/bin/activate pip install fastapi inngest uvicorn ``` -------------------------------- ### Example: Get runs triggered by an event Source: https://www.inngest.com/docs-markdown/cli Example of how to list runs triggered by a specific event ID, including output and limiting results. ```APIDOC ## Example: Get runs triggered by an event ```bash npx inngest-cli@latest api get-event-runs 01KTCTWSZJEKAFEDA4F9GYHFQW --include-output --limit 5 ``` ``` -------------------------------- ### Configuration File Example (JSON) Source: https://www.inngest.com/docs/self-hosting Example of an Inngest configuration file in JSON format. Use this file to specify application Inngest serve endpoints using the 'urls' key. ```json { "urls": [ "http://localhost:3000/api/inngest" ] } ``` -------------------------------- ### Handle User Signup Event in Go Source: https://www.inngest.com/docs-markdown/guides/fan-out-jobs Sets up an HTTP route to receive user signup data and send a "app/user.signup" event to Inngest. ```go package main import ( "encoding/json" "log" "net/http" "github.com/inngest/inngestgo" ) func main() { // Initialize the Inngest SDK client client, err := inngestgo.NewClient(inngestgo.ClientOpts{ AppID: "core", }) if err != nil { panic(err) } // Initialize your HTTP server mux := http.NewServeMux() // Handle signup route mux.HandleFunc("/signup", func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodPost { http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) return } // Parse request body - in a real app you'd validate the input var user struct { Email string `json:"email"` } if err := json.NewDecoder(r.Body).Decode(&user); err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return } // Send event to Inngest _, err := client.Send(r.Context(), inngestgo.Event{ Name: "app/user.signup", Data: map[string]interface{}{ "user": map[string]interface{}{ "email": user.Email, }, }, }) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) }) // Start the server log.Fatal(http.ListenAndServe(":8080", mux)) } ``` -------------------------------- ### Configure Function Start Timeout (TypeScript) Source: https://www.inngest.com/docs-markdown/features/inngest-functions/cancellation/cancel-on-timeouts Set a `start` timeout to cancel functions that remain queued for too long before their first step begins. This example cancels if the run takes over 10 seconds to start. ```typescript const scheduleReminder = inngest.createFunction( { id: "schedule-reminder", timeouts: { // If the run takes longer than 10s to start, cancel the run. start: "10s", }, triggers: { event: "tasks/reminder.created", }, }, async ({ event, step }) => { await step.run('send-reminder-push', async () => { await pushNotificationService.push(event.data.reminder) }) } // ... ); ``` -------------------------------- ### Initialize Inngest Client with serve() Configuration Source: https://www.inngest.com/docs/sdk/reference/serve Demonstrates how to initialize the Inngest client with various configuration options for the `serve()` function. This includes setting a signing key, base URL, enabling streaming, and specifying allowed origins. ```typescript import { serve } from "inngest"; export const inngest = serve({ id: "my-app", // Signing key is required for Inngest to verify incoming requests signingKey: process.env.INNGEST_SIGNING_KEY, // Base URL is required for Inngest to send requests to your functions baseUrl: "https://my-app.inngest.com", // Enable streaming for faster responses streaming: true, // Allowed origins for incoming requests allowedOrigins: [ "https://my-app.inngest.com", "https://my-app.inngest.com/api", ], }); ``` -------------------------------- ### Basic FastAPI App Setup Source: https://www.inngest.com/docs/getting-started/python-quick-start Initializes a basic FastAPI application instance. ```python from fastapi import FastAPI app = FastAPI() ``` -------------------------------- ### Configure Function Start Timeout (Go) Source: https://www.inngest.com/docs-markdown/features/inngest-functions/cancellation/cancel-on-timeouts Set a `Start` timeout in Go to cancel functions that remain queued for too long before their first step begins. This example cancels if the run takes over 10 seconds to start. ```go import ( "context" "time" "github.com/inngest/inngestgo" "github.com/inngest/inngestgo/step" ) func loadInngestFnWithStartTimeout(client inngestgo.Client) (inngestgo.ServableFunction, error) { return inngestgo.CreateFunction( client, inngestgo.FunctionOpts{ Name: "A function", Timeouts: &inngestgo.ConfigTimeouts{ // If the run takes longer than 10s to start, cancel the run. Start: inngestgo.Ptr(10 * time.Second), }, }, inngestgo.EventTrigger("tasks/reminder.created", nil), func(ctx context.Context, input inngestgo.Input[map[string]any]) (any, error) { return step.Run(ctx, "send-reminder", func(ctx context.Context) (bool, error) { // ... return false, nil }) }, ) } ``` -------------------------------- ### Configuration File Example (YAML) Source: https://www.inngest.com/docs/self-hosting Example of an Inngest configuration file in YAML format. Use this file to specify application Inngest serve endpoints using the 'urls' key. ```yaml urls: - http://localhost:3000/api/inngest ``` -------------------------------- ### Inngest Dev Server Output Source: https://www.inngest.com/llms-full.txt Example output when starting the Inngest dev server. It shows the server starting, subscribing to events, and becoming available at http://127.0.0.1:8288. ```js $ inngest dev -u http://localhost:3000/api/inngest 12:33PM INF executor > service starting 12:33PM INF runner > starting event stream backend=redis 12:33PM INF executor > subscribing to function queue 12:33PM INF runner > service starting 12:33PM INF runner > subscribing to events topic=events 12:33PM INF no shard finder; skipping shard claiming 12:33PM INF devserver > service starting 12:33PM INF devserver > autodiscovering locally hosted SDKs 12:33PM INF api > starting server addr=0.0.0.0:8288 Inngest dev server online at 0.0.0.0:8288, visible at the following URLs: - http://127.0.0.1:8288 (http://localhost:8288) Scanning for available serve handlers. To disable scanning run `inngest dev` with flags: --no-discovery -u ``` -------------------------------- ### Start Inngest Server with Keys Source: https://www.inngest.com/docs/self-hosting Start the Inngest server using your generated event and signing keys. These keys are essential for secure communication. ```bash inngest start --event-key --signing-key ``` -------------------------------- ### Serve Inngest Functions with Tanstack Start Source: https://www.inngest.com/docs-markdown/learn/serving-inngest-functions Add this code to `./src/routes/api/inngest.ts` to serve Inngest functions with Tanstack Start. It configures the handler for GET, POST, and PUT requests. ```typescript import { createFileRoute } from "@tanstack/react-router"; import { serve } from "inngest/edge"; import { inngest, functions } from "../../inngest"; const handler = serve({ client: inngest, functions }); export const Route = createFileRoute("/api/inngest")({ server: { handlers: { GET: async ({ request }) => handler(request), POST: async ({ request }) => handler(request), PUT: async ({ request }) => handler(request), }, }, }); ``` -------------------------------- ### Hono Framework Example Source: https://www.inngest.com/docs/learn/serving-inngest-functions Integrate Inngest functions with the Hono framework, commonly used for Cloudflare Workers. This example defines routes for GET, PUT, and POST requests to the /api/inngest path. ```typescript import { Hono } from "hono"; import { serve } from "inngest/hono"; import { functions, inngest } from "./inngest"; const app = new Hono(); app.on( ["GET", "PUT", "POST"], "/api/inngest", serve({ client: inngest, functions, }) ); export default app; ``` -------------------------------- ### Inngest Start Help Command Source: https://www.inngest.com/docs-markdown/self-hosting Displays all available options and their descriptions for the 'inngest start' command. This is useful for understanding the full range of configuration possibilities. ```plaintext inngest start --help ``` -------------------------------- ### Configure Pytest for Inngest Dev Server Source: https://www.inngest.com/docs-markdown/reference/python/guides/testing Configure Pytest to start and stop a real Inngest Dev Server for integration tests. This requires `npm` to be installed. Ensure `v0.4.15+` is installed. ```python import pytest from inngest.experimental import dev_server def pytest_configure(config: pytest.Config) -> None: dev_server.server.start() def pytest_unconfigure(config: pytest.Config) -> None: dev_server.server.stop() ``` -------------------------------- ### Inngest Start Command Options Source: https://www.inngest.com/docs-markdown/self-hosting Lists the available command-line options for starting the Inngest server, including configuration paths, keys, host, port, SDK URLs, and advanced settings. ```plaintext $ inngest start --help NAME: inngest start - [Beta] Run Inngest as a single-node service. USAGE: inngest start [options] DESCRIPTION: Example: inngest start OPTIONS: --config string Path to an Inngest configuration file --event-key string Event key(s) that will be used by apps to send events to the server. --help, -h show help --host string Inngest server hostname --port string, -p string Inngest server port (default: "8288") --sdk-url string, -u string App serve URLs to sync (ex. http://localhost:3000/api/inngest) --signing-key string Signing key used to sign and validate data between the server and apps. Must be hex string with even number of chars Advanced --connect-gateway-port int Port to expose connect gateway endpoint (default: 8289) --no-ui Disable the web UI and GraphQL API endpoint (default: false) --poll-interval int Interval in seconds between polling for updates to apps (default: 0) --queue-workers int Number of executor workers to execute steps from the queue (default: 100) --retry-interval int Retry interval in seconds for linear backoff when retrying functions - must be 1 or above (default: 0) --tick int The interval (in milliseconds) at which the executor polls the queue (default: 150) Persistence --postgres-conn-max-idle-time int Sets the maximum amount of time, in minutes, a PostgreSQL connection may be idle. (default: 5) --postgres-conn-max-lifetime int Sets the maximum amount of time, in minutes, a PostgreSQL connection may be reused. (default: 30) --postgres-max-idle-conns int Sets the maximum number of idle database connections in the PostgreSQL connection pool. (default: 10) --postgres-max-open-conns int Sets the maximum number of open database connections allowed in the PostgreSQL connection pool. (default: 100) --postgres-uri string PostgreSQL database URI for configuration and history persistence. Defaults to SQLite database. --redis-uri string Redis server URI for external queue and run state. Defaults to self-contained, in-memory Redis server with periodic snapshot backups. --sqlite-dir string Directory for where to write SQLite database. GLOBAL OPTIONS: --json Output logs as JSON. Set to true if stdout is not a TTY. (default: false) --verbose Enable verbose logging. (default: false) --log-level string, -l string Set the log level. One of: trace, debug, info, warn, error. (default: "info") ``` -------------------------------- ### TanStack Start Server Function to Mint Token Source: https://www.inngest.com/docs-markdown/reference/typescript/v4/realtime/subscribing This example shows how to create a TanStack Start server function that mints a realtime subscription token. It validates the `runId` and uses `getClientSubscriptionToken` to generate the token. ```typescript import { createServerFn } from "@tanstack/start"; import { getClientSubscriptionToken } from "inngest/react"; import { inngest } from "./inngest/client"; import { pipelineChannel } from "./inngest/channels"; export const getRealtimeToken = createServerFn({ method: "GET", }) .validator((runId: string) => runId) .handler(async ({ data: runId }) => { return getClientSubscriptionToken(inngest, { channel: pipelineChannel({ runId }), topics: ["status", "tokens"], }); }); ``` -------------------------------- ### Serve Inngest Functions in TanStack Start Source: https://www.inngest.com/docs-markdown/getting-started/tanstack-start-quick-start Integrate your Inngest functions into a TanStack Start application by importing and adding them to the `serve` handler in your API route. This example uses `inngest/edge` for edge runtime compatibility. ```typescript import { createServerFileRoute } from "@tanstack/react-start/server"; import { serve } from "inngest/edge"; import { inngest } from "../../inngest/client"; import { helloWorld } from "../../inngest/functions"; const handler = serve({ client: inngest, functions: [ helloWorld, // <-- This is where you'll always add all your functions ], }); export const Route = createFileRoute("/api/inngest")({ server: { handlers: { GET: async ({ request }) => handler(request), POST: async ({ request }) => handler(request), PUT: async ({ request }) => handler(request), }, }, }); ``` -------------------------------- ### Start Inngest Server with Environment Variables Source: https://www.inngest.com/docs-markdown/self-hosting Starts the Inngest server using event and signing keys provided as environment variables. This is an alternative to passing keys directly via command-line arguments. ```plaintext INNGEST_EVENT_KEY= INGEST_SIGNING_KEY= inngest start ``` -------------------------------- ### TanStack Start API Handler for Inngest Source: https://www.inngest.com/docs-markdown/getting-started/tanstack-start-quick-start Set up a file-based API route handler in TanStack Start to serve Inngest functions. This configures GET, POST, and PUT requests to be handled by the Inngest server. ```typescript import { createServerFileRoute } from "@tanstack/react-start/server"; import { serve } from "inngest/edge"; import { inngest } from "../../inngest/client"; const handler = serve({ client: inngest, functions: [ /* your functions will be passed here later! */ ], }); export const Route = createFileRoute("/api/inngest")({ server: { handlers: { GET: async ({ request }) => handler(request), POST: async ({ request }) => handler(request), PUT: async ({ request }) => handler(request), }, }, }); ``` -------------------------------- ### Start Inngest Server with CLI Flags Source: https://www.inngest.com/docs-markdown/self-hosting Start the Inngest server using the CLI, providing event and signing keys as command-line arguments. This method uses default configurations like SQLite for persistence. ```plaintext inngest start --event-key abcd --signing-key 1234 ``` -------------------------------- ### Configure Start Timeout for Inngest Functions Source: https://www.inngest.com/docs/features/inngest-functions/cancellation/cancel-on-timeouts Set a `timeouts.start` duration to cancel queued runs if they don't begin execution within the specified time. This example cancels runs if they take longer than 10 seconds to start. ```typescript const scheduleReminder = inngest.createFunction( { id: "schedule-reminder", timeouts: { // If the run takes longer than 10s to start, cancel the run. start: "10s", }, triggers: { event: "tasks/reminder.created" }, }, async ({ event, step }) => { await step.run('send-reminder-push', async () => { await pushNotificationService.push(event.data.reminder) }) } // ... ); ``` -------------------------------- ### Basic Durable Endpoint Setup Source: https://www.inngest.com/docs/reference/typescript/durable-endpoints Demonstrates the basic setup for creating a durable HTTP endpoint using `inngest.endpoint()` and the `endpointAdapter`. ```APIDOC ## Basic Durable Endpoint Setup ### Description This example shows how to initialize the Inngest client with the `endpointAdapter` and define a durable endpoint handler. ### Code ```typescript import { Inngest, step } from "inngest"; import { endpointAdapter } from "inngest/edge"; const inngest = new Inngest({ id: "my-app", endpointAdapter, }); export const handler = inngest.endpoint(async (req: Request): Promise => { const data = await step.run("fetch-data", async () => { return await fetchExternalAPI(); }); return Response.json({ data }); }); async function fetchExternalAPI() { // Placeholder for actual API call return { message: "Data fetched successfully" }; } ``` ``` -------------------------------- ### Inngest Dev Server Output Source: https://www.inngest.com/docs-markdown/getting-started/h3-quick-start Example output when starting the Inngest dev server, indicating it's online and scanning for handlers. ```js $ inngest dev -u http://localhost:3000/api/inngest 12:33PM INF executor > service starting 12:33PM INF runner > starting event stream backend=redis 12:33PM INF executor > subscribing to function queue 12:33PM INF runner > service starting 12:33PM INF runner > subscribing to events topic=events 12:33PM INF no shard finder; skipping shard claiming 12:33PM INF devserver > service starting 12:33PM INF devserver > autodiscovering locally hosted SDKs 12:33PM INF api > starting server addr=0.0.0.0:8288 Inngest dev server online at 0.0.0.0:8288, visible at the following URLs: - http://127.0.0.1:8288 (http://localhost:8288) Scanning for available serve handlers. To disable scanning run `inngest dev` with flags: --no-discovery -u ``` -------------------------------- ### Inngest Dev Server Output Source: https://www.inngest.com/docs-markdown/getting-started/astro-quick-start Example output when starting the Inngest Dev Server. It shows service status and discovery information. ```js $ inngest dev -u http://localhost:4321/api/inngest 12:33PM INF executor > service starting 12:33PM INF runner > starting event stream backend=redis 12:33PM INF executor > subscribing to function queue 12:33PM INF runner > service starting 12:33PM INF runner > subscribing to events topic=events 12:33PM INF no shard finder; skipping shard claiming 12:33PM INF devserver > service starting 12:33PM INF devserver > autodiscovering locally hosted SDKs 12:33PM INF api > starting server addr=0.0.0.0:8288 Inngest dev server online at 0.0.0.0:8288, visible at the following URLs: - http://127.0.0.1:8288 (http://localhost:8288) Scanning for available serve handlers. To disable scanning run `inngest dev` with flags: --no-discovery -u ``` -------------------------------- ### Start Inngest Server with Keys Source: https://www.inngest.com/docs-markdown/self-hosting Starts the Inngest server using generated event and signing keys. These keys can be provided directly as command-line arguments. ```plaintext inngest start --event-key --signing-key ``` -------------------------------- ### Define Inngest Function with HTTP Methods Source: https://www.inngest.com/blog/ai-agents-inngest-durable-steps Example of an Inngest function definition that specifies allowed HTTP methods (GET, POST, PUT). ```typescript export const GET, POST, PUT = serve( { client, } ); ``` -------------------------------- ### Connect Inngest with Go App Source: https://www.inngest.com/llms-full.txt Set up the Inngest Go client, define a function to handle events, and use `inngestgo.Connect` to establish a connection. This example includes error handling and graceful shutdown. ```go type UserCreatedEvent struct { Name string Data struct { UserID string `json:"user_id"` } } func main() { ctx := context.Background() client, err := inngestgo.NewClient(inngestgo.ClientOpts{ AppID: "my-app", Logger: logger.StdlibLogger(ctx), AppVersion: nil, // Optional, defaults to the git commit SHA }) if err != nil { panic(err) } _, err = inngestgo.CreateFunction( client, inngestgo.FunctionOpts{ID: "handle-signup", Name: "Handle signup"}, inngestgo.EventTrigger("user.created", nil), func(ctx context.Context, input inngestgo.Input[UserCreatedEvent]) (any, error) { fmt.Println("Function called") return map[string]any{"success": true}, nil }, ) if err != nil { panic(err) } fmt.Println("Worker: connecting") conn, err := inngestgo.Connect(ctx, inngestgo.ConnectOpts{ InstanceID: inngestgo.Ptr("example-worker"), Apps: []inngestgo.Client{client}, }) if err != nil { fmt.Printf("ERROR: %#v\n", err) os.Exit(1) } defer func(conn connect.WorkerConnection) { <-ctx.Done() err := conn.Close() if err != nil { fmt.Printf("could not close connection: %s\n", err) } }(conn) } ``` -------------------------------- ### Deploy Inngest Functions with Connect Source: https://www.inngest.com/docs/guides/development-with-docker Example of how to deploy Inngest functions using the Connect feature. This involves setting up the Inngest CLI and pointing it to your functions. ```bash inngest-cli@latest deploy --all --project "my-app" ``` -------------------------------- ### step.run() with Async Function Source: https://www.inngest.com/docs/reference/typescript/v4/functions/step-run This example shows how step.run() can execute an asynchronous function. The `await` keyword is used to get the resolved value from the async operation. ```typescript import { workflow } from "inngest"; export const myWorkflow = workflow( { id: "my-workflow", on: { "custom.event": "*"; } }, async ({ step }) => { const data = await step.run("fetch-data", async () => { const response = await fetch("https://api.example.com/data"); return response.json(); }); return data; } ); ``` -------------------------------- ### Invoke a Function with Inngest MCP Source: https://www.inngest.com/docs/ai-dev-tools/mcp Use `invoke_function` to directly execute a function and get its result, which is useful for testing. This example invokes the 'process-payment' function. ```javascript > "Invoke the 'process-payment' function with amount 100 and currency USD" ``` -------------------------------- ### Initialize Inngest Client with Serve Options Source: https://www.inngest.com/docs/reference/serve Demonstrates how to initialize the Inngest client with serve options, including setting the signing key, event key, and serving functions. This is a common setup for Inngest applications. ```typescript import type { ServeMux } from "@inngest/core"; import { Inngest } from "@inngest/core"; // Create a new Inngest client instance const inngest = new Inngest({ id: "my-app", // Serve functions from the current file serve: { // Use a signing key to verify incoming requests signingKey: process.env.INNGEST_SIGNING_KEY, // Use an event key to send events eventKey: process.env.INNGEST_EVENT_KEY, // Serve functions from the current file functions: [ // ... your functions here ], }, }); // Example function (replace with your actual functions) const helloWorld = inngest.createFunction({ id: "hello-world", name: "Hello World", trigger: { event: "test.hello", }, async call({ event }) { return { message: `Hello ${event.data.name}!` }; }, }); // Export the function to be served export const handler = inngest.createHandler(); ``` -------------------------------- ### Usage Examples for step.run() Source: https://www.inngest.com/docs-markdown/reference/typescript/v3/functions/step-run Demonstrates various ways to use step.run() within your Inngest functions, including with async/await, Promise.all, and handling return values. ```APIDOC ## How to call `step.run()` As `step.run()` returns a Promise, you will need to handle it like any other Promise in JavaScript. ### Using `await` ```ts // Steps can have async handlers const result = await step.run("get-api-data", async () => { // Steps should return data used in other steps return fetch("...").json(); }); // Steps can have synchronous handlers const data = await step.run("transform", () => { return transformData(result); }); // Returning data is optional await step.run("insert-data", async () => { db.insert(data); }); ``` ### Using `.then()` ```ts step.run("create-user", () => { /* ... */ }) .then((user) => { // do something else }); ``` ### Running steps in parallel with `Promise.all` ```ts Promise.all([ step.run("create-subscription", () => { /* ... */ }), step.run("add-to-crm", () => { /* ... */ }), step.run("send-welcome-email", () => { /* ... */ }), ]); ``` ``` -------------------------------- ### Configure Inngest Dev Server with Docker Compose Source: https://www.inngest.com/docs/guides/development-with-docker Example Docker Compose configuration to run the Inngest Dev Server. This setup includes the server and a Redis instance. ```yaml version: "3.8" services: inngest-dev-server: image: "public.ecr.aws/inngest/inngest:latest" ports: - "8080:8080" environment: - INNGEST_DEV_SERVER_LICENSE_KEY - INNGEST_DATABASE_URL=redis://redis:6379 depends_on: - redis redis: image: "redis:alpine" ports: - "6379:6379" ``` -------------------------------- ### Integrate Inngest Dev Server with Docker Compose Source: https://www.inngest.com/docs/dev-server Add the Inngest Dev Server to your Docker Compose setup. This example configures both your application service and the Inngest service. ```yaml services: app: build: ./app environment: - INNGEST_DEV=1 - INNGEST_BASE_URL=http://inngest:8288 ports: - '3000:3000' inngest: image: inngest/inngest command: 'inngest dev -u http://app:3000/api/inngest' ports: - '8288:8288' - '8289:8289' # Used for connect() ``` -------------------------------- ### Sleep until a Date object Source: https://www.inngest.com/docs/reference/functions/step-sleep-until Pause function execution until a specific date by providing a JavaScript `Date` object to `step.sleepUntil()`. This example shows how to use `dayjs` to get the end of the week. ```typescript // Sleep until the end of the this week const date = dayjs().endOf("week").toDate(); await step.sleepUntil("wait-for-end-of-the-week", date); ``` -------------------------------- ### Creating a New Inngest Client (Go v0.8) Source: https://www.inngest.com/llms-full.txt Demonstrates how to create a new Inngest client using `NewClient` in Go v0.8. `AppID` is a required field and must be provided. ```go client, err := inngestgo.NewClient(inngestgo.ClientOpts{AppID: "my-app"}) ``` -------------------------------- ### Celery tasks.py example Source: https://www.inngest.com/blog/queues-are-no-longer-the-right-abstraction This Python code defines Celery tasks for video processing, including transcription, summarization, and database writing. Ensure Celery and necessary utilities are installed. ```python # tasks.py from celery import shared_task from utils import transcribe_video, summarize_transcript, write_to_db ```