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

temporalio

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

temporalio

Temporal.io SDK meta-package

  • 0.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.5K
increased by17.42%
Maintainers
1
Weekly downloads
 
Created
Source

Temporal NodeJS SDK

CI NPM

Typescript + NodeJS SDK for Temporal.

!!! This is a work in progress, not ready for use yet !!!

For more information see the proposal.

Getting started

Install system dependencies

This project requires nodejs LTS version 12 (or later).

Furthermore, to install this module you will need a c++ compiler and the Rust toolchain installed. If you run into errors during installation it is likely your environment is not properly set up.

  • To set up a C++ compiler for node-gyp, follow the instuctions here
  • To set up the Rust toolchain, follow the instruction here
Create a new project
npm init @temporalio ./example
cd ./example
Build everything
npm run build
Run the Temporal server

Download, install, and run the Temporal server via docker-compose. It is easy to do and you can keep it running in the background while you build applications.

Test your workflow
  • Run the worker

    node lib/worker/index.js
    
  • Run the workflow

    node lib/worker/test.js
    

Hello World

Not working yet, activities not implemented

Activities and workflows

src/activities/greeter.ts

export async function greet(name: string): Promise<string> {
  return `Hello, ${name}!`;
}

src/interfaces/workflows.ts

import { Workflow } from '@temporalio/workflow';

export interface Example extends Workflow {
  main(name: string): Promise<string>;
}

src/workflows/example.ts

import { Example } from '@interfaces/workflows';
import { greet } from '@activities/greeter';

async function main(name: string): Promise<string> {
  return await greet(name);
}

export const workflow: Example = { main };
Worker and client

src/worker/index.ts

import { Worker } from '@temporalio/worker';

(async () => {
  // Automatically locate and register activities and workflows
  const worker = new Worker(__dirname);
  // Bind to the `tutorial` queue and start accepting tasks
  await worker.run('tutorial');
})();

src/worker/test.ts

import { Connection } from '@temporalio/client';
import { Example } from '@interfaces/workflows';

(async () => {
  const connection = new Connection();
  const example = connection.workflow<Example>('example', { taskQueue: 'tutorial' });
  const result = await example('Temporal');
  console.log(result); // Hello, Temporal
})();

Development

Environment set up
git submodule init
git submodule update
npm ci
Building
npm run clean
npm run build
Building with watch
npm run clean
npm run build  # Must be run once before build.watch
npm run build.watch
Testing
npm run test

-- OR --

npm run test.watch

Keywords

FAQs

Package last updated on 02 Mar 2021

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