Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize PromiseHandler #26

Closed
7 tasks done
PetrosPapapa opened this issue Nov 22, 2018 · 0 comments
Closed
7 tasks done

Generalize PromiseHandler #26

PetrosPapapa opened this issue Nov 22, 2018 · 0 comments
Assignees
Labels
feature New feature or request

Comments

@PetrosPapapa
Copy link
Member

PetrosPapapa commented Nov 22, 2018

PromiseHandler currently only returns the result of the overall workflow.

The CounterHandler introduced in 0488604 is a good example of how promises can be used to return different things.

It would be nice to generalize the PromiseHandler so that it is simpler to implement handlers that need to return stuff.

So you can implement the CounterHandler like this:

class CounterHandler[T](override val name:String) extends PromiseHandler[T,Int] {   
  private var counter:Int = 0
  def count = counter
  
  override def apply(e:PiEvent[T]) = counter += 1
  override def onSuccess(result:Any) = promise.success(counter)
  override def onFailure(result:Any) = promise.success(counter)
}

The current version of the PromiseHandler that returns the result of the workflow can be named ResultHandler or something like that instead, as a simple instance of the PromiseHandler.

  • New PromiseHandler
  • ResultHandler
  • CounterHandler
  • New PromiseHandleFactory
  • ResultHandleFactory
  • New CounterHandlerFactory
  • Resolve things that break in ProcessExecutor.scala and anywhere else
@PetrosPapapa PetrosPapapa added the feature New feature or request label Nov 22, 2018
@PetrosPapapa PetrosPapapa self-assigned this Nov 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant