Coder Social home page Coder Social logo

andante20 / step Goto Github PK

View Code? Open in Web Editor NEW

This project forked from totherik/step

0.0 2.0 0.0 192 KB

An Amazon States Language implementation in JS. (The beginnings of building out FaaS-agnostic Step Functions.)

Shell 0.70% JavaScript 99.30%

step's Introduction

step

An Amazon State Language based state machine.

It is probably worth pointing out that this design probably isn't terribly practical in reality. There are many ways to solve this problem but the current structure was chosen for ease of development, to better understand the problem space, and to get a feel for the Amazon State Language spec itself. One could imagine many different approaches, including:

  • Separate the validation and execution steps: Validation and deployment of a specification versus the runtime invocation are distinctly different as it pertains to the overall lifecycle of the state machine. One approach could be to validate both structure and data integrity, then place the valid specification in a data store. At runtime the state machine could reference that specification by name, retrieve it, and run the machine to completion.
  • Generate the state machine implementation: Perhaps a more efficient solution would be to generate and deploy the complete implementation (a FaaS Function) based on the provided spec. The platform could either change the implementation of how it would fulfill remote Tasks based on the FaaS provider, or the implementation could be provided by the author. (I like this one, personally.)

See additional notes below.

Basic API

const json = {
    "StartAt": "Demo",
    "States": {
        "Demo": {
            "Type": "Pass",
            "Result": {
                "pass": {
                    "a": "b"
                }
            },
            "Next": "Done"
        },
        "Done": {
            "Type": "Succeed"
        }
    }
};

const input = {
    foo: {
        bar: true,
    },
};

const machine = Machine.create(json);
const result = await machine.run(input);
console.log(result);

Testing

$ npm test
Notes
  • The Node runtime version (in .npmrc) was explicitly chosen for OpenWhisk compatibility. The associated stability that comes with selecting one runtime is preferred for now (in the early stages of development) over flexbility across providers.

step's People

Contributors

totherik avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.