This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package akka.contrib.pattern | |
import akka.actor.{Cancellable, ActorLogging, ActorRef, Actor} | |
import java.util | |
import akka.serialization.SerializationExtension | |
import scala.concurrent.ExecutionContext | |
import scala.concurrent.duration._ | |
import scala.util.{Try, Failure, Success} | |
import scala.language.existentials | |
import java.util.UUID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Topic Entity | |
*/ | |
@Entity | |
@Table(uniqueConstraints = Array(new UniqueConstraint(columnNames=Array("application_id", "name")))) | |
@NamedQueries(Array( | |
new NamedQuery(name="Topic.findAllByApplication", query="from Topic where application=:application"), | |
new NamedQuery(name="Topic.findByApplicationAndName", query="from Topic where application=:application and name=:name") | |
)) | |
class Topic { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.Source | |
import java.io.{FileInputStream, InputStream} | |
import com.typesafe.config.{ConfigException, Config, ConfigFactory} | |
import com.foo.dbfs.{FileSystem, Factory} | |
import com.foo.util.Logging | |
import com.foo.util.Environment | |
/** | |
* CslConfig manages CSL Configuration. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import akka.util.{Duration, NonFatal} | |
import akka.actor.Scheduler | |
import akka.dispatch.{Promise, ExecutionContext, Future} | |
// Copied from Akka 2.1-M1 | |
trait FutureTimeoutSupport { | |
/** | |
* Returns a [[akka.dispatch.Future]] that will be completed with the success or failure of the provided value | |
* after the specified duration. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait ActorStack extends Actor { | |
/** Actor classes should implement this partialFunction for standard | |
* actor message handling | |
*/ | |
def wrappedReceive: Receive | |
/** Stackable traits should override and call super.receive(x) for | |
* stacking functionality | |
*/ | |
def receive: Receive = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package akka.contrib.pattern | |
import org.junit.runner.RunWith | |
import org.scalatest.junit.JUnitRunner | |
import org.scalatest.{FunSuite, BeforeAndAfterAll} | |
import akka.testkit.TestKit | |
import akka.actor._ | |
import java.util | |
import concurrent.duration._ | |
import akka.serialization.SerializationExtension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.concurrent.ExecutionContext | |
import java.lang.Thread.UncaughtExceptionHandler | |
import java.util.concurrent.atomic.AtomicInteger | |
import java.util.concurrent.{ThreadPoolExecutor, LinkedBlockingQueue, ThreadFactory, TimeUnit} | |
import java.util.concurrent.{Executors, RejectedExecutionHandler, RejectedExecutionException} | |
object ScalingThreadPoolExecutor { | |
val defaultSecondsBeforeEviction = 60 | |
def apply(minThreads: Int, maxThreads: Int, threadFactory: ThreadFactory): ScalingThreadPoolExecutor = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com> | |
*/ | |
package akka.contrib.pattern | |
import akka.actor._ | |
import akka.remote.RemoteScope | |
import scala.concurrent.duration._ | |
import scala.util.Try |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait FutureCancelSupport { | |
def cancellableFuture[T](fun: Future[T] => T)(implicit ex: ExecutionContext): (Future[T], () => Boolean) = { | |
val p = Promise[T]() | |
val f = p.future | |
val funFuture = Future(fun(f)) | |
funFuture.onComplete(p tryComplete(_)) // Akka 2.0 | |
// p tryCompleteWith funFuture // Scala 2.10 | |
(f, () => p.tryComplete(Left(new CancellationException))) // Akka 2.0 |
NewerOlder