Giter Club home page Giter Club logo

fission-workflow-sample's Introduction

Fission Workflow Sample: Carpool

Fission workflow sample mimics a carpool application. It tries to match a car owner who offers seats in his car and riders who are looking for one or more seats in a shared carpool. In current version for sake of simplicity there is no concept of of source & destination i.e. a single route is assumed.

Everything is a Fission function in this application and connecting the functions is done using the Fission workflow project

Architecture

There are four custom functions and two Fission workflow's built in functions used to achieve an end to end carpool application.

Workflow

Please check the workflow definition in Carpool workflow spec while going over the description of each function below.

  1. CarPool producer

Carpool producer produces a random car owner's with car plate and number of seats they can offer on ride.

  1. Foreach

Foreach is a built in function in Fission workflow. Instead of writing a custom function for simple things like iterating over a list or checking a condition, you can use built in functions. In this case, we are getting a list of CarPool objects from CarPool producer and feeding one item at a time to CarPool validator.

  1. CarPool validator

CarPool validator right now simply drops off the carpools which exceed a certain number of seats.

  1. Compose

Although not clearly visible - a foreach is wrapped by a compose. Compose collects output of foreach and makes a list from individual outputs.

  1. CarPool allocator

Carpool allocator generates a set of rider requests and matches them with carpool requests. Currently the matching algorithm is rather rudimentry. This function also exposes a REST endpoint which reports matched rides, unmatched cars and unmatched riders.

  1. Carpool dashboard

CarPool dashboard consumes the output of CarPool allocator and displays a simple dashboard

Dashboards

Dashboard 1/2

Dashboard 2/2

Try it out

If you have Fission and Fission Workflows installed, you can use specs to apply all functions and visit the dashboard URL at $FISSION_ROUTER/carpoolweb/index.html

$ fission spec apply
uploading archive archive://carpool-validator-1-0-0-jar-with-dependencies-jar
uploading archive archive://carpool-allocator-1-0-0-jar-with-dependencies-jar
uploading archive archive://carpool-producer-1-0-0-jar-with-dependencies-jar
5 functions created: carpool, cpallocator, cpproducer, cpvalidator, carpool-web
1 HTTPTrigger created: 408fd31e-5149-4c0c-acb0-9445d4a05f37
2 environments created: java, python
5 packages created: carpool-workflow-wf-yaml-hiri, carpool-allocator-1-0-0-jar-with-dependencies-jar-owhb, carpool-producer-1-0-0-jar-with-dependencies-jar-owhb, carpool-validator-1-0-0-jar-with-dependencies-jar-owhb, cp-web-pkg

Future work

Although a working examplem, this can be enhanced further to make a real world carpool application

  • Split the car riders generation into a different function.
  • Make the matching algorithm more robust
  • Use a document store to store requests from carpool creators and riders and then clean up based on a reasonable timeout like 30 minutes if no match found.

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.