Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@temporalio/workflow

Package Overview
Dependencies
Maintainers
4
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@temporalio/workflow

Temporal.io SDK Workflow sub-package

  • 0.23.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
189K
decreased by-24.11%
Maintainers
4
Weekly downloads
 
Created

What is @temporalio/workflow?

@temporalio/workflow is a package for building and managing workflows using Temporal, a microservices orchestration platform. It allows developers to write workflows in a straightforward and maintainable way, handling complex state management, retries, and timeouts.

What are @temporalio/workflow's main functionalities?

Defining a Workflow

This feature allows you to define a workflow using the `defineWorkflow` function. The workflow logic is written as an async function, making it easy to manage asynchronous operations.

const { defineWorkflow } = require('@temporalio/workflow');

const myWorkflow = defineWorkflow(async function() {
  // Workflow logic here
  console.log('Workflow started');
  await someActivity();
  console.log('Workflow completed');
});

Executing Activities

Activities are the building blocks of workflows. This feature allows you to define activities that can be executed within a workflow. Activities can perform tasks such as calling external services or processing data.

const { defineActivity } = require('@temporalio/workflow');

const someActivity = defineActivity(async function() {
  // Activity logic here
  return 'Activity result';
});

Handling Workflow State

Temporal workflows can maintain state across different steps. This feature allows you to set and get state within a workflow, making it easier to manage complex workflows with multiple steps.

const { defineWorkflow, setState, getState } = require('@temporalio/workflow');

const myWorkflow = defineWorkflow(async function() {
  setState('step', 1);
  console.log('Step 1');
  await someActivity();
  setState('step', 2);
  console.log('Step 2');
  await anotherActivity();
  console.log('Workflow completed');
});

Retrying Failed Activities

Temporal provides built-in support for retrying failed activities. This feature allows you to specify retry policies for activities, ensuring that transient failures are automatically retried.

const { defineActivity } = require('@temporalio/workflow');

const someActivity = defineActivity(async function() {
  // Activity logic here
  throw new Error('Activity failed');
}, { retry: { maximumAttempts: 3 } });

Other packages similar to @temporalio/workflow

Keywords

FAQs

Package last updated on 12 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc