<kbd id="9plqc"><label id="9plqc"></label></kbd>

        <th id="9plqc"></th>
        1. <center id="9plqc"><video id="9plqc"></video></center>
          <sub id="9plqc"><form id="9plqc"><pre id="9plqc"></pre></form></sub>
          <nav id="9plqc"><form id="9plqc"><legend id="9plqc"></legend></form></nav>
          GitHub 您所在的位置:網(wǎng)站首頁 屬羊的能不能帶龍牌手鏈 GitHub

          GitHub

          #GitHub| 來源: 網(wǎng)絡(luò)整理| 查看: 265

          light-workflow-js

          Build Status

          A library to create, run and orchestrate AWS SWF workflow. Written in TypeScript and heavily relies on RxJS.

          Documentation - You can find a documentation here

          Getting Started $ git clone https://github.com/adamrecsko/light-workflow-js.git $ cd light-workflow-js $ yarn install Prerequisites

          You need node.js and yarn to be installed before a start.

          $ apt-get install nodejs $ npm install yarn -g

          For running a workflow on AWS you need aws credentials properly setup on your development environment and a registered AWS SWF domain.

          Running the tests $ yarn test Running linter

          Explain what these tests test and why

          $ yarn lint Example

          HelloWorld Application

          For examples please check the examples folder.

          Actor implementation import 'reflect-metadata'; import 'zone.js'; const HELLO_WORLD_ACTOR = Symbol('HELLO_WORLD_ACTOR'); export interface HelloWorld { formatText(text: string): Observable; printIt(text: string): Observable; } @injectable() export class HelloWorldImpl implements HelloWorld { private printer(text: string) { console.log(text); } @activity() @version('1') formatText(text: string): Observable { return of('Hello' + text); } @activity() @version('1') @description('print the text out') printIt(text: string): Observable { return of(text).do((text: string) => { this.printer(text); }); } } Workflow implementation export const HELLO_WORLD_WORKFLOW = Symbol('HELLO_WORLD_WORKFLOW'); export interface HelloWorldWorkflow { helloWorld(text: string): Promise; } @injectable() export class HelloWorldWorkflowImpl implements HelloWorldWorkflow { @actorClient @inject(HELLO_WORLD_ACTOR) private actor: HelloWorld; @workflow() async helloWorld(text: string) { const formattedText = await this.actor.formatText(text).toPromise(); const printedText = await this.actor.printIt(formattedText).toPromise(); return printedText; } }

          You can handle activity exceptions with try catch

          @workflow() async helloWorldWithErrorHandling() { try { await this.actor.throwException().toPromise(); } catch (e) { if (e instanceof FailedException) { return 'Error handled'; } throw e; } }

          Or you can use observables to create a flow

          @workflow() helloWorldHandleErrorWithObservables() { return this.actor.throwException().catch((err) => { if (err instanceof FailedException) { return Observable.of('Error handled, no problem!'); } return Observable.throw(err); }); }

          Or with lettable operators

          @workflow() helloWorldHandleErrorWithObservables() { const errorHandler = catchError(err => of('Error handled, no problem!')); return this.actor.throwException().let(errorHandler); }

          You can also reschedule an activity

          @workflow() async helloWorkflowWithRetry() { try { await this.actor.firstTryTimeOut(0).toPromise(); } catch (e) { if (e instanceof TimeoutException) { // Don't worry it is just a timeout return await this.actor.firstTryTimeOut(1).toPromise(); } throw Error('Unknown error'); } }

          For more examples please check the examples folder

          Application implementation @injectable() @configuration(new ApplicationConfiguration(new SWF({ region: 'us-east-1' }))) @services([ { impl: HelloWorldImpl, key: HELLO_WORLD_ACTOR, }, { impl: HelloWorldWorkflowImpl, key: HELLO_WORLD_WORKFLOW, }, ]) export class MyApp { public static domain = 'test-domain'; @inject(HELLO_WORLD_WORKFLOW) @workflowClient private workflow: HelloWorldWorkflow; @inject(WORKFLOWS) private workflows: Workflows; @inject(WORKFLOW_WORKER_FACTORY) private workerFactory: WorkflowWorkerFactory; @inject(ACTOR_WORKER_FACTORY) private actorWorkerFactory: ActorWorkerFactory; public async startHelloWorld(text: string): Promise { const start = this.workflows.createStarter(MyApp.domain, 'default'); const workflowResult = await start(this.workflow.helloWorld, text); return workflowResult.runId; } public createWorkflowWorker(): WorkflowWorker { return this.workerFactory.create(MyApp.domain, [{ key: HELLO_WORLD_WORKFLOW, impl: HelloWorldWorkflowImpl, }]); } public createActorWorker(): ActorWorker { return this.actorWorkerFactory.create(MyApp.domain, [{ key: HELLO_WORLD_ACTOR, impl: HelloWorldImpl, }]); } } How to start workers and workflow async function boot() { const app = createApplication(MyApp); const workflowWorker = app.createWorklfowWorker(); const actorWorker = app.createActorWorker(); await workflowWorker.register().toPromise(); await actorWorker.register().toPromise(); workflowWorker.startWorker(); actorWorker.startWorker(); await app.startHelloWorld('World'); } // boot // register workflow and activities boot().catch(err => console.error(err)); Built With RxJS TypeScript yarn Zone.js InversifyJS Authors Adam Recsko - Initial work License

          This project is licensed under the MIT License - see the LICENSE.md file for details

          Acknowledgments This library is under development and not production ready yet.


          【本文地址】

          公司簡介

          聯(lián)系我們

          今日新聞

          推薦新聞

          專題文章
            CopyRight 2018-2019 實驗室設(shè)備網(wǎng) 版權(quán)所有
            黄色免费网站在线看,韩国精品在线观看,韩国美女一区二区,99国产热 庆城县| 高平市| 城口县| 启东市| 宜兴市| 比如县| 东乡县| 布尔津县| 保靖县| 清苑县| 南康市| 自治县| 沈阳市| 宝丰县| 黑水县| 吉隆县| 隆林| 桐柏县| 平安县| 留坝县| 都江堰市| 庆元县| 兴隆县| 宜君县| 县级市| 乳山市| 嘉兴市| 成安县| 周至县| 兴城市| 利川市| 武安市| 贵定县| 张家港市| 南木林县| 双城市| 宜春市| 揭阳市| 那曲县| 苗栗市| 台中县| http://444 http://444 http://444 http://444 http://444 http://444