1.1.3 • Published 6 months ago

@azure-utils/durable-functions v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Azure Durable Functions

This package provides a set of tools for working with Azure Durable Functions in TypeScript. It includes functions for interacting with Durable Functions through HTTP API.

Orchestrations API

Example

import { durableOrchestrations } from "@azure-utils/durable-functions";

try {
  const response = await durableOrchestrations.start(
    {
      functionName: "myOrchestratorName",
      input: { key: "value" },
    },
    {
      baseUrl: "http://localhost:7071",
      systemKey: "",
    }
  );

  const id = response.result.id;
  console.log(`Orchestration started with ID: ${id}`);
} catch (error) {
  console.error(error);
}

Entities API

Example

import { durableEntities } from "@azure-utils/durable-functions";

type State = { foo: string; bar: number };

try {
  const state = await durableEntities.getState<State>(
    {
      entityName: "myOrchestratorName",
      entityKey: "value",
    },
    {
      baseUrl: "http://localhost:7071",
      systemKey: "",
    }
  );

  console.log(`State: ${state}`);
} catch (error) {
  console.error(error);
}

DurableEntity class

This class is used to define a Durable Entity with a specific state and methods. It provides a way to manage the state of the entity and define actions that can be performed on it.

This must be used in the Azure Functions app.

import { DurableEntity } from "@azure-utils/durable-functions/entity";

type MyEntityState = { foo: string; bar: number };
const defaultState: MyEntityState = { foo: "bar", bar: 0 };

export const myEntity = new DurableEntity("my-entity", defaultState, {
  updateFoo: (input: { foo: string }) => ({ foo: input.foo }),
  updateBar: (input: { bar: number }) => ({ bar: input.bar }),
});
1.1.3

6 months ago

1.1.2

6 months ago

1.1.1

6 months ago

1.1.0

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago

0.0.4

6 months ago

0.0.3

6 months ago

0.0.2

6 months ago