Documentation
¶
Index ¶
- Constants
- Variables
- func Infer[InputT any, OutputT any](ctx context.Context, id string, in InferOpts[InputT]) (out OutputT, err error)
- func Invoke[T any](ctx context.Context, id string, opts InvokeOpts) (T, error)
- func IsWithinStep(ctx context.Context) bool
- func Run[T any](ctx context.Context, id string, f func(ctx context.Context) (T, error)) (T, error)
- func Send[DATA any](ctx context.Context, id string, event event.GenericEvent[DATA]) (string, error)
- func SendMany[DATA any](ctx context.Context, id string, events []event.GenericEvent[DATA]) ([]string, error)
- func SetTargetStepID(ctx context.Context, id string) context.Context
- func Sleep(ctx context.Context, id string, duration time.Duration)
- func SleepUntil(ctx context.Context, id string, until time.Time)
- func WaitForEvent[T any](ctx context.Context, stepID string, opts WaitForEventOpts) (T, error)
- type ControlHijack
- type InferFormat
- type InferOpts
- type InferRequestOpts
- type InvokeOpts
- type RunOpts
- type SleepOpts
- type WaitForEventOpts
Constants ¶
const (
ParallelKey = ctxKey("parallelKey")
)
Variables ¶
var ( // ErrEventNotReceived is returned when a WaitForEvent call times out. It indicates that a // matching event was not received before the timeout. ErrEventNotReceived = fmt.Errorf("event not received") )
var ( // ErrNotInFunction is called when a step tool is executed outside of an Inngest // function call context. // // If this is thrown, you're likely executing an Inngest function manually instead // of it being invoked by the scheduler. ErrNotInFunction = &errNotInFunction{} )
Functions ¶
func Infer ¶ added in v0.8.0
func Infer[InputT any, OutputT any]( ctx context.Context, id string, in InferOpts[InputT], ) (out OutputT, err error)
StepRun runs any code reliably, with retries, returning the resulting data. If this fails the function stops.
func Invoke ¶ added in v0.5.3
Invoke another Inngest function using its ID. Returns the value returned from that function.
If the invoked function can't be found or otherwise errors, the step will fail and the function will stop with a `NoRetryError`.
func IsWithinStep ¶ added in v0.8.0
func Run ¶
func Run[T any]( ctx context.Context, id string, f func(ctx context.Context) (T, error), ) (T, error)
StepRun runs any code reliably, with retries, returning the resulting data. If this fails the function stops.
func Send ¶ added in v0.9.0
func Send[DATA any]( ctx context.Context, id string, event event.GenericEvent[DATA], ) (string, error)
Send sends an event to Inngest.
func SendMany ¶ added in v0.9.0
func SendMany[DATA any]( ctx context.Context, id string, events []event.GenericEvent[DATA], ) ([]string, error)
SendMany sends a batch of events to Inngest.
func SetTargetStepID ¶ added in v0.7.4
func SleepUntil ¶ added in v0.11.1
SleepUntil sleeps until a given time. This halts function execution entirely, and Inngest will resume the function after the given time from this step.
func WaitForEvent ¶
WaitForEvent pauses function execution until a specific event is received or the wait times out. You must pass in an event name within WaitForEventOpts.Event, and may pass an optional expression to filter events based off of data.
For example:
step.waitForEvent(ctx, "wait-for-open", opts.WaitForEventOpts{ Event: "email/mail.opened", If: inngestgo.StrPtr(fmt.Sprintf("async.data.id == %s", strconv.Quote("my-id"))), Timeout: 24 * time.Hour, })
Types ¶
type ControlHijack ¶
type ControlHijack struct{}
type InferFormat ¶ added in v0.8.0
type InferFormat string
const ( // FormatOpenAIChat represents the default OpenAI chat completion request. InferFormatOpenAIChat InferFormat = "openai-chat" InferFormatAnthropic InferFormat = "anthropic" InferFormatGemini InferFormat = "gemini" InferFormatBedrock InferFormat = "bedrock" )
type InferOpts ¶ added in v0.8.0
type InferOpts[RequestT any] struct { // Opts represents the Inngest-specific step and request opts Opts InferRequestOpts // Body is the raw request type, eg. the Anthropic or OpenAI request. Body RequestT }
type InferRequestOpts ¶ added in v0.8.0
type InferRequestOpts struct { // URL is the provider URL which is used when making the request. URL string `json:"url"` // Headers represent additional headers to send in the request. Headers map[string]string `json:"headers,omitempty"` // AuthKey is your API key. This will be added to the inference request depending // on the API format chosen in Format. // // This is NEVER logged or kept. AuthKey string `json:"auth_key"` // Format represents the format for the API request and response. Infer allows // the use of common formats, and we create the request and infer metadata based // off of the API format. Note that many providers support an open OpenAI-like // format. Format InferFormat `json:"format"` }
func InferOpenAIOpts ¶ added in v0.8.0
func InferOpenAIOpts(key *string, baseURL *string) InferRequestOpts
InferOpenAIOpts is a helper function for generating OpenAI opts.
type InvokeOpts ¶ added in v0.5.3
type InvokeOpts struct { // ID is the ID of the function to invoke, including the client ID prefix. FunctionId string // Data is the data to pass to the invoked function. Data map[string]any // User is the user data to pass to the invoked function. User any // Timeout is an optional duration specifying when the invoked function will be // considered timed out Timeout time.Duration }
type WaitForEventOpts ¶
type WaitForEventOpts struct { // Name represents the optional step name. Name string // Event is the event name to wait for. Event string // Timeout is how long to wait. We must always timebound event lsiteners. Timeout time.Duration // If allows you to write arbitrary expressions to match against. If *string `json:"if"` }