Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Create a consumer interface users can extend #2

Open
agaro1121 opened this issue May 2, 2017 · 0 comments
Open

Create a consumer interface users can extend #2

agaro1121 opened this issue May 2, 2017 · 0 comments

Comments

@agaro1121
Copy link
Contributor

agaro1121 commented May 2, 2017

Maybe something like this:
So users are forced to process events and not have to worry about a receive method

import com.weightwatchers.core.eventing.consumer.ConsumerWorker.{EventProcessed, ProcessEvent}
import akka.actor._

abstract class AbstractConsumerActor extends Actor {

  def processEvent: Function[ProcessEvent, EventProcessed]

  def send: EventProcessed => Unit

  val processAndSend = processEvent.andThen(send).asInstanceOf[PartialFunction[Any,Unit]]


  override def receive: Receive = processAndSend
}

extending it would look like:

class TestConsumer extends AbstractConsumerActor {
  override def processEvent: Function[ProcessEvent, EventProcessed] = ???

  override def send: (EventProcessed) => Unit = ???
}
@agaro1121 agaro1121 changed the title Create an interface for consumers users can extend Create a consumer interface users can extend May 2, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant