Skip to content

Commit

Permalink
Add version to priority docs. Update function options (#544)
Browse files Browse the repository at this point in the history
* Add priority to function options list

* Add version tag to priority docs
  • Loading branch information
djfarrelly authored Oct 23, 2023
1 parent 7030b31 commit 30fb1d2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 14 deletions.
13 changes: 11 additions & 2 deletions pages/docs/reference/functions/create.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ The `createFunction` method accepts a series of arguments to define your functio
</Properties>
</Property>

<Property name="priority" type="object">
Prioritize specific function runs ahead of others ([reference](/docs/reference/functions/run-priority))

<Properties nested={true} collapse={true}>
<Property name="run" type="string">
An expression which must return an integer between -600 and 600 (by default), with higher return values resulting in a higher priority. See [reference](/docs/reference/functions/run-priority) for more information.
</Property>
</Properties>
</Property>

<Property name="batchEvents" type="object">
Configure how the function should consume batches of events ([reference](/docs/guides/batching))
Expand Down Expand Up @@ -132,12 +141,12 @@ The `createFunction` method accepts a series of arguments to define your functio
<Properties>
<Property name="priority" type="object">
Options to configure how to prioritize functions

<Properties nested={true}>
<Property name="run" type="string">
An expression which must return an integer between -600 and 600 (by default), with higher
return values resulting in a higher priority. Examples:

* Return the priority within an event directly: `event.data.priority` (where
`event.data.priority` is an int within your account's range)
* Rate limit by a string field: `event.data.plan == 'enterprise' ? 180 : 0`
Expand Down
6 changes: 4 additions & 2 deletions pages/docs/reference/functions/run-priority.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Function run priority
# Function run priority <VersionBadge version="v3.2.1+" />

Defining a function's run priority allows you to **prioritize specific function runs above other runs within the same function**. For example:

Expand Down Expand Up @@ -48,6 +48,8 @@ export default inngest.createFunction(
);
```

---

## How `priority.run` works

**The queue**
Expand All @@ -71,7 +73,7 @@ time (as seconds). Returning `300` subtracts 300 seconds from the function run'
pushing the new run ahead of any other functions in the last 300 seconds (5 minutes).

If two function runs are scheduled at similar times, the functions with a higher priority run sooner
when at capacity.
when at capacity.

**Fairness**

Expand Down
15 changes: 10 additions & 5 deletions shared/Docs/Heading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ function Eyebrow({ tag, label }) {
);
}

function Anchor({ id, inView, children }) {
function Anchor({ id, inView, children, className = "" }) {
return (
<Link
href={`#${id}`}
className="group text-inherit no-underline hover:text-inherit"
className={`group text-inherit no-underline hover:text-inherit ${className}`}
>
{inView && (
<div className="absolute mt-1 ml-[calc(-1*var(--width))] hidden w-[var(--width)] opacity-0 transition [--width:calc(2.625rem+0.5px+50%-min(50%,calc(theme(maxWidth.lg)+theme(spacing.8))))] group-hover:opacity-100 group-focus:opacity-100 md:block lg:z-50 2xl:[--width:theme(spacing.10)]">
Expand Down Expand Up @@ -89,17 +89,22 @@ export function Heading({
}
});

const hasAnchor = anchor && id;
const flexClasses = `flex gap-4 items-center`;

return (
<>
<Eyebrow tag={tag} label={label} />
<Component
ref={ref}
id={anchor ? id : undefined}
className={tag || label ? "mt-2 scroll-mt-32" : "scroll-mt-24"}
className={`${flexClasses} ${
tag || label ? "mt-2 scroll-mt-32" : "scroll-mt-24"
}`}
{...props}
>
{anchor ? (
<Anchor id={id} inView={inView}>
{hasAnchor ? (
<Anchor id={id} inView={inView} className={flexClasses}>
{children}
</Anchor>
) : (
Expand Down
12 changes: 7 additions & 5 deletions shared/Docs/mdx.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import Link, { LinkProps } from "next/link";
import clsx from "clsx";


import { Heading } from "./Heading";
import React, { useState } from "react";
import { ChevronDown, ChevronUp } from "react-feather";

export {default as YouTube} from "react-youtube-embed"
export { default as YouTube } from "react-youtube-embed";

// export const a: React.FunctionComponent<LinkProps> = (props) => (
// <Link {...props} />
Expand All @@ -29,13 +28,16 @@ export {
GuideSection,
} from "./Code";

export const h2: React.FC<any> = function H2(props) {
export const h1: React.FC<any> = function (props) {
return <Heading level={1} {...props} />;
};
export const h2: React.FC<any> = function (props) {
return <Heading level={2} {...props} />;
};
export const h3: React.FC<any> = function H2(props) {
export const h3: React.FC<any> = function (props) {
return <Heading level={3} {...props} />;
};
export const h4: React.FC<any> = function H2(props) {
export const h4: React.FC<any> = function (props) {
return <Heading level={3} {...props} />;
};

Expand Down

1 comment on commit 30fb1d2

@vercel
Copy link

@vercel vercel bot commented on 30fb1d2 Oct 23, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

website – ./

inngest.vercel.app
website-inngest.vercel.app
www.inngest.com
website-git-main-inngest.vercel.app

Please sign in to comment.