SlideShare une entreprise Scribd logo
1  sur  16
Télécharger pour lire hors ligne
A simple workflow system



        David Peterson
      peterson@orbitec.com.au
What is a workflow?


A process that moves through a
sequence of steps (from start and
   finish) in order to perform
          some function
Examples


    Fulfilling an order
●




    Publishing documents / content
●




    Approving a request
●
A few things in common ...


    Typically multi-step
●



    Performed asynchronously
●



    May be long-running
●



    Steps may be conditional
●



    Each step may need to do an operation
●
The Idea


Many simple workflows
can be modelled as a
finite state machine


      (Not all)
acts_as_state_machine


    AASM to friends!
●



    Rails plugin by Scott Barron
●




    Provides:
●


        A simple FSM implementation
    ●


        A DSL for expressing FSM in Ruby code
    ●
http://elitists.textdriven.com/svn/plugins/
       acts_as_state_machine/trunk/
# Basic workflow example
class ActionWorkflow < ActiveRecord::Base

 acts_as_state_machine :initial => :created,
  :column => 'status'

 state :created
 state :approved
 state :rejected
 state :cancelled

 event :approve { transitions :to => :approved, :from
 => :created }

 event :cancel { transitions :to => :cancelled, :from
 =>[:created, :approved, :rejected] }
 ...
end
AASM provides some methods


    An action! method for each event
●



    A query? method for each state
●




Examples:
    workflow.approve!   # moves to approved state
    workflow.cancelled? # Returns boolean
Guards

    event :approve { transitions :to => :approved, :from
     => :created, :guard => Proc.new {|w| !w.expired?}}


    Allows conditions on transitions
●



    Transition is not available unless
●


    condition is met
    Some conditions may be expressed
●


    best in your code, not in guards
Callbacks
    state :approved, :after => :on_submit
    state :approved, :after => :Proc.new {|m| m.abc }



    Available hooks :enter, :after and :exit
●



    Callbacks provide a way to do some
●


    operation when a transition occurs
     def on_submit
       record_action
       ...
     end
Other useful stuff
# Fire your actions (cleanly)
  attr_accessor :action
  def action_workflow
    eval(quot;self.#{self.action}!quot;) unless self.action.nil?
  end


# Add an audit trail ...
  has_many :actions, :class_name => quot;WorkflowActionquot;
  def record_action
   self.actions << WorkflowAction.create(
    :comment => self.comment, :actioner_id =>
    self.acting_person, :state => self.state)
  end
A few caveats
    A minor change to AASM .rb required
●


        Avoids runtime error (on 1.2.3 anyway!)
    ●




    Also added a couple of things locally
●


        Lourens Naude's method (mis-named)
    ●


        A corrected next_events_for_current_state
    ●




    Ask me for the patch if you're keen
●
# Retrieves next states for current state

 def next_events_for_current_state
  events = []
  self.class.read_inheritable_attribute(
    :transition_table).each do |key, value|
      value.each do |transition|
       events << key if transition.from ==
          current_state()
        end
   end
 events
end
Remarks
AASM makes it very simple to implement
 a simple workflow model
        A full workflow system is more complex
    ●


        acts_as_coloured_petri_net :)
    ●




    Piston is your friend ... especially when
●


    making local modifications to plugins
Parting thought
Q: What are the three most important
 ideas in programming?

  1. Abstraction
  2. Abstraction
  3. Abstraction


(Hudak, 2000)

Contenu connexe

Tendances

Ct102 using ltmom to move to sap s4 hana
Ct102  using ltmom to move to sap s4 hanaCt102  using ltmom to move to sap s4 hana
Ct102 using ltmom to move to sap s4 hanaMichelle Crapo
 
SynapseIndia drupal presentation on drupal info
SynapseIndia drupal  presentation on drupal infoSynapseIndia drupal  presentation on drupal info
SynapseIndia drupal presentation on drupal infoSynapseindiappsdevelopment
 
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...Startupfest
 
Jonathon Wright - Intelligent Performance Cognitive Learning (AIOps)
Jonathon Wright - Intelligent Performance Cognitive Learning (AIOps)Jonathon Wright - Intelligent Performance Cognitive Learning (AIOps)
Jonathon Wright - Intelligent Performance Cognitive Learning (AIOps)Neotys_Partner
 
bed-con 2015 - From Virtual Machines to Containers
bed-con 2015 - From Virtual Machines to Containersbed-con 2015 - From Virtual Machines to Containers
bed-con 2015 - From Virtual Machines to Containerscamunda services GmbH
 
Case of the Unexplained Support Issue – Troubleshooting steps for diagnosing ...
Case of the Unexplained Support Issue – Troubleshooting steps for diagnosing ...Case of the Unexplained Support Issue – Troubleshooting steps for diagnosing ...
Case of the Unexplained Support Issue – Troubleshooting steps for diagnosing ...Charles Beyer
 
Object Oriented Programming I
Object Oriented Programming IObject Oriented Programming I
Object Oriented Programming Iraven_rainagi
 
Load testing with Visual Studio and Azure - Andrew Siemer
Load testing with Visual Studio and Azure - Andrew SiemerLoad testing with Visual Studio and Azure - Andrew Siemer
Load testing with Visual Studio and Azure - Andrew SiemerAndrew Siemer
 
Automated Performance Testing With J Meter And Maven
Automated  Performance  Testing With  J Meter And  MavenAutomated  Performance  Testing With  J Meter And  Maven
Automated Performance Testing With J Meter And MavenPerconaPerformance
 
Architecting for the cloud storage build test
Architecting for the cloud storage build testArchitecting for the cloud storage build test
Architecting for the cloud storage build testLen Bass
 
BlazeMeter- Effective Performance Reporting
BlazeMeter- Effective Performance ReportingBlazeMeter- Effective Performance Reporting
BlazeMeter- Effective Performance ReportingBlazeMeter
 
Gearman - Northeast PHP 2012
Gearman - Northeast PHP 2012Gearman - Northeast PHP 2012
Gearman - Northeast PHP 2012Mike Willbanks
 
SAP Workflow Po create workflow by pavan golesar
SAP Workflow Po create workflow by pavan golesarSAP Workflow Po create workflow by pavan golesar
SAP Workflow Po create workflow by pavan golesarPavan Golesar
 
Advanced Load Runner
Advanced Load RunnerAdvanced Load Runner
Advanced Load Runnertelab
 
Silk Performer Presentation v1
Silk Performer Presentation v1Silk Performer Presentation v1
Silk Performer Presentation v1Sun Technlogies
 
Synthetic web performance testing with Selenium
Synthetic web performance testing with SeleniumSynthetic web performance testing with Selenium
Synthetic web performance testing with SeleniumAndriy Samilyak
 
Building software by feature with immutable infrastructures on AWS
Building software by feature with immutable infrastructures on AWSBuilding software by feature with immutable infrastructures on AWS
Building software by feature with immutable infrastructures on AWSNicolas Mas
 
Kanban - Class of Service (To Manage Incidents in a DevOps Team)
Kanban - Class of Service (To Manage Incidents in a DevOps Team)Kanban - Class of Service (To Manage Incidents in a DevOps Team)
Kanban - Class of Service (To Manage Incidents in a DevOps Team)Anurag Shrivastava
 

Tendances (20)

Ct102 using ltmom to move to sap s4 hana
Ct102  using ltmom to move to sap s4 hanaCt102  using ltmom to move to sap s4 hana
Ct102 using ltmom to move to sap s4 hana
 
SynapseIndia drupal presentation on drupal info
SynapseIndia drupal  presentation on drupal infoSynapseIndia drupal  presentation on drupal info
SynapseIndia drupal presentation on drupal info
 
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...
 
Jonathon Wright - Intelligent Performance Cognitive Learning (AIOps)
Jonathon Wright - Intelligent Performance Cognitive Learning (AIOps)Jonathon Wright - Intelligent Performance Cognitive Learning (AIOps)
Jonathon Wright - Intelligent Performance Cognitive Learning (AIOps)
 
bed-con 2015 - From Virtual Machines to Containers
bed-con 2015 - From Virtual Machines to Containersbed-con 2015 - From Virtual Machines to Containers
bed-con 2015 - From Virtual Machines to Containers
 
Task flow
Task flowTask flow
Task flow
 
Case of the Unexplained Support Issue – Troubleshooting steps for diagnosing ...
Case of the Unexplained Support Issue – Troubleshooting steps for diagnosing ...Case of the Unexplained Support Issue – Troubleshooting steps for diagnosing ...
Case of the Unexplained Support Issue – Troubleshooting steps for diagnosing ...
 
Object Oriented Programming I
Object Oriented Programming IObject Oriented Programming I
Object Oriented Programming I
 
Load testing with Visual Studio and Azure - Andrew Siemer
Load testing with Visual Studio and Azure - Andrew SiemerLoad testing with Visual Studio and Azure - Andrew Siemer
Load testing with Visual Studio and Azure - Andrew Siemer
 
Automated Performance Testing With J Meter And Maven
Automated  Performance  Testing With  J Meter And  MavenAutomated  Performance  Testing With  J Meter And  Maven
Automated Performance Testing With J Meter And Maven
 
Architecting for the cloud storage build test
Architecting for the cloud storage build testArchitecting for the cloud storage build test
Architecting for the cloud storage build test
 
BlazeMeter- Effective Performance Reporting
BlazeMeter- Effective Performance ReportingBlazeMeter- Effective Performance Reporting
BlazeMeter- Effective Performance Reporting
 
Gearman - Northeast PHP 2012
Gearman - Northeast PHP 2012Gearman - Northeast PHP 2012
Gearman - Northeast PHP 2012
 
SAP Workflow Po create workflow by pavan golesar
SAP Workflow Po create workflow by pavan golesarSAP Workflow Po create workflow by pavan golesar
SAP Workflow Po create workflow by pavan golesar
 
Load Runner
Load RunnerLoad Runner
Load Runner
 
Advanced Load Runner
Advanced Load RunnerAdvanced Load Runner
Advanced Load Runner
 
Silk Performer Presentation v1
Silk Performer Presentation v1Silk Performer Presentation v1
Silk Performer Presentation v1
 
Synthetic web performance testing with Selenium
Synthetic web performance testing with SeleniumSynthetic web performance testing with Selenium
Synthetic web performance testing with Selenium
 
Building software by feature with immutable infrastructures on AWS
Building software by feature with immutable infrastructures on AWSBuilding software by feature with immutable infrastructures on AWS
Building software by feature with immutable infrastructures on AWS
 
Kanban - Class of Service (To Manage Incidents in a DevOps Team)
Kanban - Class of Service (To Manage Incidents in a DevOps Team)Kanban - Class of Service (To Manage Incidents in a DevOps Team)
Kanban - Class of Service (To Manage Incidents in a DevOps Team)
 

En vedette

Corporate Workflow Process - Complaints and Legal Matters (illustration)
Corporate Workflow Process - Complaints and Legal Matters (illustration)Corporate Workflow Process - Complaints and Legal Matters (illustration)
Corporate Workflow Process - Complaints and Legal Matters (illustration)Elizabeth Baker, JD, CRCMP
 
Scalable web-based workflow platform
Scalable web-based workflow platformScalable web-based workflow platform
Scalable web-based workflow platformAshutosh Bijoor
 
workflow in temporal state machine v1
workflow in temporal state machine v1workflow in temporal state machine v1
workflow in temporal state machine v1Gordon Morrison
 
Events Workflow diagram
Events Workflow diagramEvents Workflow diagram
Events Workflow diagramColin Thomson
 
JBoss BPM Suite 6 Tech labs
JBoss BPM Suite 6 Tech labsJBoss BPM Suite 6 Tech labs
JBoss BPM Suite 6 Tech labsAndrea Leoncini
 
Message Oriented Middleware (MOM)
Message Oriented Middleware (MOM)Message Oriented Middleware (MOM)
Message Oriented Middleware (MOM)drewenut
 
Sending and receiving messages in mq queues
Sending and receiving messages in mq queuesSending and receiving messages in mq queues
Sending and receiving messages in mq queuesRavi Babu
 
The Workflow Reference Model
The Workflow Reference ModelThe Workflow Reference Model
The Workflow Reference ModelAldo Quelopana
 
Djangocon 09 Presentation - Pluggable Applications
Djangocon 09 Presentation - Pluggable ApplicationsDjangocon 09 Presentation - Pluggable Applications
Djangocon 09 Presentation - Pluggable ApplicationsNowell Strite
 
Architecture of message oriented middleware
Architecture of message oriented middlewareArchitecture of message oriented middleware
Architecture of message oriented middlewareLikan Patra
 
Cognitive IBM Watson Services for Bluemix Developers
Cognitive IBM Watson Services for Bluemix DevelopersCognitive IBM Watson Services for Bluemix Developers
Cognitive IBM Watson Services for Bluemix DevelopersNiklas Heidloff
 
Responsive Design Workflow: Mobilism 2012
Responsive Design Workflow: Mobilism 2012Responsive Design Workflow: Mobilism 2012
Responsive Design Workflow: Mobilism 2012Stephen Hay
 
Developing a PLN and open co-learning opportunities #UoRsocialmedia
Developing a PLN and open co-learning opportunities #UoRsocialmediaDeveloping a PLN and open co-learning opportunities #UoRsocialmedia
Developing a PLN and open co-learning opportunities #UoRsocialmediaSue Beckingham
 

En vedette (20)

Corporate Workflow Process - Complaints and Legal Matters (illustration)
Corporate Workflow Process - Complaints and Legal Matters (illustration)Corporate Workflow Process - Complaints and Legal Matters (illustration)
Corporate Workflow Process - Complaints and Legal Matters (illustration)
 
Neuro4j Workflow Overview
Neuro4j Workflow OverviewNeuro4j Workflow Overview
Neuro4j Workflow Overview
 
Scalable web-based workflow platform
Scalable web-based workflow platformScalable web-based workflow platform
Scalable web-based workflow platform
 
workflow in temporal state machine v1
workflow in temporal state machine v1workflow in temporal state machine v1
workflow in temporal state machine v1
 
Workflow Foundation 4
Workflow Foundation 4Workflow Foundation 4
Workflow Foundation 4
 
Message oriented middleware
Message oriented middlewareMessage oriented middleware
Message oriented middleware
 
Windows Workflow Foundation
Windows Workflow FoundationWindows Workflow Foundation
Windows Workflow Foundation
 
Events Workflow diagram
Events Workflow diagramEvents Workflow diagram
Events Workflow diagram
 
JBoss BPM Suite 6 Tech labs
JBoss BPM Suite 6 Tech labsJBoss BPM Suite 6 Tech labs
JBoss BPM Suite 6 Tech labs
 
Message Oriented Middleware (MOM)
Message Oriented Middleware (MOM)Message Oriented Middleware (MOM)
Message Oriented Middleware (MOM)
 
Sending and receiving messages in mq queues
Sending and receiving messages in mq queuesSending and receiving messages in mq queues
Sending and receiving messages in mq queues
 
Workflow for XPages
Workflow for XPagesWorkflow for XPages
Workflow for XPages
 
The Workflow Reference Model
The Workflow Reference ModelThe Workflow Reference Model
The Workflow Reference Model
 
Djangocon 09 Presentation - Pluggable Applications
Djangocon 09 Presentation - Pluggable ApplicationsDjangocon 09 Presentation - Pluggable Applications
Djangocon 09 Presentation - Pluggable Applications
 
Architecture of message oriented middleware
Architecture of message oriented middlewareArchitecture of message oriented middleware
Architecture of message oriented middleware
 
Cognitive IBM Watson Services for Bluemix Developers
Cognitive IBM Watson Services for Bluemix DevelopersCognitive IBM Watson Services for Bluemix Developers
Cognitive IBM Watson Services for Bluemix Developers
 
Responsive Design Workflow: Mobilism 2012
Responsive Design Workflow: Mobilism 2012Responsive Design Workflow: Mobilism 2012
Responsive Design Workflow: Mobilism 2012
 
Career vs Health
Career vs HealthCareer vs Health
Career vs Health
 
Circuits 2011 in English
Circuits 2011 in EnglishCircuits 2011 in English
Circuits 2011 in English
 
Developing a PLN and open co-learning opportunities #UoRsocialmedia
Developing a PLN and open co-learning opportunities #UoRsocialmediaDeveloping a PLN and open co-learning opportunities #UoRsocialmedia
Developing a PLN and open co-learning opportunities #UoRsocialmedia
 

Similaire à A simple workflow system using state machines

540slidesofnodejsbackendhopeitworkforu.pdf
540slidesofnodejsbackendhopeitworkforu.pdf540slidesofnodejsbackendhopeitworkforu.pdf
540slidesofnodejsbackendhopeitworkforu.pdfhamzadamani7
 
Linux Cluster Job Management Systems (SGE)
Linux Cluster Job Management Systems (SGE)Linux Cluster Job Management Systems (SGE)
Linux Cluster Job Management Systems (SGE)anandvaidya
 
Getting Reactive with Cycle.js and xstream
Getting Reactive with Cycle.js and xstreamGetting Reactive with Cycle.js and xstream
Getting Reactive with Cycle.js and xstreamSteve Lee
 
Automating EVA Workflows with AWS Step Functions
Automating EVA Workflows with AWS Step FunctionsAutomating EVA Workflows with AWS Step Functions
Automating EVA Workflows with AWS Step FunctionsChris Shenton
 
Velocity 2018 preetha appan final
Velocity 2018   preetha appan finalVelocity 2018   preetha appan final
Velocity 2018 preetha appan finalpreethaappan
 
Intro to tsql unit 14
Intro to tsql   unit 14Intro to tsql   unit 14
Intro to tsql unit 14Syed Asrarali
 
File Processing - Batch Process Execution
File Processing - Batch Process ExecutionFile Processing - Batch Process Execution
File Processing - Batch Process ExecutionAbimael Desales López
 
File Processing - Process Execution Solution
File Processing - Process Execution SolutionFile Processing - Process Execution Solution
File Processing - Process Execution SolutionAbimael Desales López
 
Complex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxComplex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxbobmcwhirter
 
Angular Optimization Web Performance Meetup
Angular Optimization Web Performance MeetupAngular Optimization Web Performance Meetup
Angular Optimization Web Performance MeetupDavid Barreto
 
Gearmanpresentation 110308165409-phpapp01
Gearmanpresentation 110308165409-phpapp01Gearmanpresentation 110308165409-phpapp01
Gearmanpresentation 110308165409-phpapp01longtuan
 
Angular performance slides
Angular performance slidesAngular performance slides
Angular performance slidesDavid Barreto
 
Node js
Node jsNode js
Node jshazzaz
 
Container Orchestration from Theory to Practice
Container Orchestration from Theory to PracticeContainer Orchestration from Theory to Practice
Container Orchestration from Theory to PracticeDocker, Inc.
 
IBM ConnectED 2015 - MAS103 XPages Performance and Scalability
IBM ConnectED 2015 - MAS103 XPages Performance and ScalabilityIBM ConnectED 2015 - MAS103 XPages Performance and Scalability
IBM ConnectED 2015 - MAS103 XPages Performance and ScalabilityPaul Withers
 
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...Alan Pinstein
 

Similaire à A simple workflow system using state machines (20)

Os Whitaker
Os WhitakerOs Whitaker
Os Whitaker
 
540slidesofnodejsbackendhopeitworkforu.pdf
540slidesofnodejsbackendhopeitworkforu.pdf540slidesofnodejsbackendhopeitworkforu.pdf
540slidesofnodejsbackendhopeitworkforu.pdf
 
Linux Cluster Job Management Systems (SGE)
Linux Cluster Job Management Systems (SGE)Linux Cluster Job Management Systems (SGE)
Linux Cluster Job Management Systems (SGE)
 
Getting Reactive with Cycle.js and xstream
Getting Reactive with Cycle.js and xstreamGetting Reactive with Cycle.js and xstream
Getting Reactive with Cycle.js and xstream
 
Automating EVA Workflows with AWS Step Functions
Automating EVA Workflows with AWS Step FunctionsAutomating EVA Workflows with AWS Step Functions
Automating EVA Workflows with AWS Step Functions
 
Velocity 2018 preetha appan final
Velocity 2018   preetha appan finalVelocity 2018   preetha appan final
Velocity 2018 preetha appan final
 
Intro to tsql
Intro to tsqlIntro to tsql
Intro to tsql
 
Intro to tsql unit 14
Intro to tsql   unit 14Intro to tsql   unit 14
Intro to tsql unit 14
 
File Processing - Batch Process Execution
File Processing - Batch Process ExecutionFile Processing - Batch Process Execution
File Processing - Batch Process Execution
 
File Processing - Process Execution Solution
File Processing - Process Execution SolutionFile Processing - Process Execution Solution
File Processing - Process Execution Solution
 
Complex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxComplex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBox
 
Angular Optimization Web Performance Meetup
Angular Optimization Web Performance MeetupAngular Optimization Web Performance Meetup
Angular Optimization Web Performance Meetup
 
Capistrano
CapistranoCapistrano
Capistrano
 
Gearmanpresentation 110308165409-phpapp01
Gearmanpresentation 110308165409-phpapp01Gearmanpresentation 110308165409-phpapp01
Gearmanpresentation 110308165409-phpapp01
 
ReactJS
ReactJSReactJS
ReactJS
 
Angular performance slides
Angular performance slidesAngular performance slides
Angular performance slides
 
Node js
Node jsNode js
Node js
 
Container Orchestration from Theory to Practice
Container Orchestration from Theory to PracticeContainer Orchestration from Theory to Practice
Container Orchestration from Theory to Practice
 
IBM ConnectED 2015 - MAS103 XPages Performance and Scalability
IBM ConnectED 2015 - MAS103 XPages Performance and ScalabilityIBM ConnectED 2015 - MAS103 XPages Performance and Scalability
IBM ConnectED 2015 - MAS103 XPages Performance and Scalability
 
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...
 

Dernier

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Dernier (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

A simple workflow system using state machines

  • 1. A simple workflow system David Peterson peterson@orbitec.com.au
  • 2. What is a workflow? A process that moves through a sequence of steps (from start and finish) in order to perform some function
  • 3. Examples Fulfilling an order ● Publishing documents / content ● Approving a request ●
  • 4. A few things in common ... Typically multi-step ● Performed asynchronously ● May be long-running ● Steps may be conditional ● Each step may need to do an operation ●
  • 5. The Idea Many simple workflows can be modelled as a finite state machine (Not all)
  • 6. acts_as_state_machine AASM to friends! ● Rails plugin by Scott Barron ● Provides: ● A simple FSM implementation ● A DSL for expressing FSM in Ruby code ●
  • 7. http://elitists.textdriven.com/svn/plugins/ acts_as_state_machine/trunk/
  • 8. # Basic workflow example class ActionWorkflow < ActiveRecord::Base acts_as_state_machine :initial => :created, :column => 'status' state :created state :approved state :rejected state :cancelled event :approve { transitions :to => :approved, :from => :created } event :cancel { transitions :to => :cancelled, :from =>[:created, :approved, :rejected] } ... end
  • 9. AASM provides some methods An action! method for each event ● A query? method for each state ● Examples: workflow.approve! # moves to approved state workflow.cancelled? # Returns boolean
  • 10. Guards event :approve { transitions :to => :approved, :from => :created, :guard => Proc.new {|w| !w.expired?}} Allows conditions on transitions ● Transition is not available unless ● condition is met Some conditions may be expressed ● best in your code, not in guards
  • 11. Callbacks state :approved, :after => :on_submit state :approved, :after => :Proc.new {|m| m.abc } Available hooks :enter, :after and :exit ● Callbacks provide a way to do some ● operation when a transition occurs def on_submit record_action ... end
  • 12. Other useful stuff # Fire your actions (cleanly) attr_accessor :action def action_workflow eval(quot;self.#{self.action}!quot;) unless self.action.nil? end # Add an audit trail ... has_many :actions, :class_name => quot;WorkflowActionquot; def record_action self.actions << WorkflowAction.create( :comment => self.comment, :actioner_id => self.acting_person, :state => self.state) end
  • 13. A few caveats A minor change to AASM .rb required ● Avoids runtime error (on 1.2.3 anyway!) ● Also added a couple of things locally ● Lourens Naude's method (mis-named) ● A corrected next_events_for_current_state ● Ask me for the patch if you're keen ●
  • 14. # Retrieves next states for current state def next_events_for_current_state events = [] self.class.read_inheritable_attribute( :transition_table).each do |key, value| value.each do |transition| events << key if transition.from == current_state() end end events end
  • 15. Remarks AASM makes it very simple to implement a simple workflow model A full workflow system is more complex ● acts_as_coloured_petri_net :) ● Piston is your friend ... especially when ● making local modifications to plugins
  • 16. Parting thought Q: What are the three most important ideas in programming? 1. Abstraction 2. Abstraction 3. Abstraction (Hudak, 2000)