GitLab wurde aktualisiert. Dank regelmäßiger Updates bleibt das THM GitLab sicher und Sie profitieren von den neuesten Funktionen. Vielen Dank für Ihre Geduld.

Commit c1e067e7 authored by Tom Käsler's avatar Tom Käsler
Browse files

only utilize one execution context!

parent d9c431b1
package de.thm.arsnova
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import scala.concurrent.ExecutionContext
object Context {
implicit val system = ActorSystem()
implicit val executor: ExecutionContext = system.dispatcher
implicit val materializer: ActorMaterializer = ActorMaterializer()
}
......@@ -4,16 +4,13 @@ import akka.actor.ActorSystem
import akka.event.{Logging, LoggingAdapter}
import akka.http.scaladsl.Http
import akka.http.scaladsl.server.Directives._
import akka.stream.ActorMaterializer
import de.thm.arsnova.utils.{MigrationConfig, Config}
import scala.concurrent.ExecutionContext
object WebServer extends App with Config with MigrationConfig with Routes {
private implicit val system = ActorSystem()
protected implicit val executor: ExecutionContext = system.dispatcher
import de.thm.arsnova.Context._
protected val log: LoggingAdapter = Logging(system, getClass)
protected implicit val materializer: ActorMaterializer = ActorMaterializer()
if (args.contains("migrate")) {
migrate
......
......@@ -4,7 +4,6 @@ import de.thm.arsnova.services.{ChoiceAnswerService, FreetextAnswerService}
import de.thm.arsnova.models._
import de.thm.arsnova.hateoas.{ApiRoutes, ResourceAdapter, Link}
import scala.concurrent.ExecutionContext.Implicits.global
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import akka.http.scaladsl.server.Directives._
import spray.json._
......@@ -13,6 +12,8 @@ import spray.json._
The API Interface regarding answers to choice questions (e.g. MC, SC).
*/
trait ChoiceAnswerApi {
import de.thm.arsnova.Context.executor
// protocol for serializing data
import de.thm.arsnova.mappings.ChoiceAnswerJsonProtocol._
......
......@@ -4,7 +4,6 @@ import de.thm.arsnova.services.CommentService
import de.thm.arsnova.models._
import de.thm.arsnova.hateoas.{ApiRoutes, ResourceAdapter, Link}
import scala.concurrent.ExecutionContext.Implicits.global
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import akka.http.scaladsl.server.Directives._
import spray.json._
......@@ -14,6 +13,8 @@ import spray.json._
The API Interface regarding comments (formerly known as "interposed question"), made by participants.
*/
trait CommentApi {
import de.thm.arsnova.Context.executor
// protocol for serializing data
import de.thm.arsnova.mappings.CommentJsonProtocol._
......
......@@ -4,7 +4,6 @@ import de.thm.arsnova.services.FeaturesService
import de.thm.arsnova.models._
import de.thm.arsnova.hateoas.{ApiRoutes, ResourceAdapter, Link}
import scala.concurrent.ExecutionContext.Implicits.global
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import akka.http.scaladsl.server.Directives._
import spray.json._
......@@ -14,6 +13,8 @@ import spray.json._
The API Interface regarding session features.
*/
trait FeaturesApi {
import de.thm.arsnova.Context.executor
// protocol for serializing data
import de.thm.arsnova.mappings.FeatureJsonProtocol._
......
......@@ -4,7 +4,6 @@ import de.thm.arsnova.services.FreetextAnswerService
import de.thm.arsnova.models._
import de.thm.arsnova.hateoas.{ApiRoutes, ResourceAdapter, Link}
import scala.concurrent.ExecutionContext.Implicits.global
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import akka.http.scaladsl.server.Directives._
import spray.json._
......@@ -14,6 +13,8 @@ import spray.json._
The API Interface regarding answers for the question type "freetext".
*/
trait FreetextAnswerApi {
import de.thm.arsnova.Context.executor
// protocol for serializing data
import de.thm.arsnova.mappings.FreetextAnswerJsonProtocol._
......
......@@ -4,7 +4,6 @@ import de.thm.arsnova.services.GlobalMotdService
import de.thm.arsnova.models._
import de.thm.arsnova.hateoas.{ApiRoutes, ResourceAdapter, Link}
import scala.concurrent.ExecutionContext.Implicits.global
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import akka.http.scaladsl.server.Directives._
import spray.json._
......@@ -14,6 +13,8 @@ The API Interface regarding global messages.
Only an admin should post these motd
*/
trait GlobalMotdApi {
import de.thm.arsnova.Context.executor
// protocol for serializing data
import de.thm.arsnova.mappings.GlobalMotdJsonProtocol._
......
......@@ -4,7 +4,6 @@ import de.thm.arsnova.services.QuestionService
import de.thm.arsnova.models._
import de.thm.arsnova.hateoas.{ApiRoutes, ResourceAdapter, Link}
import scala.concurrent.ExecutionContext.Implicits.global
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import akka.http.scaladsl.server.Directives._
import spray.json._
......@@ -14,6 +13,8 @@ import spray.json._
The API Interface regarding questions.
*/
trait QuestionApi {
import de.thm.arsnova.Context.executor
// protocol for serializing data
import de.thm.arsnova.mappings.QuestionJsonProtocol._
......
......@@ -4,7 +4,6 @@ import de.thm.arsnova.services.SessionService
import de.thm.arsnova.models._
import de.thm.arsnova.hateoas.{ApiRoutes, ResourceAdapter, Link}
import scala.concurrent.ExecutionContext.Implicits.global
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import akka.http.scaladsl.server.Directives._
import spray.json._
......@@ -14,6 +13,8 @@ import spray.json._
The API Interface regarding sessions, the core component for arsnova.voting.
*/
trait SessionApi {
import de.thm.arsnova.Context.executor
// protocol for serializing data
import de.thm.arsnova.mappings.SessionJsonProtocol._
......
......@@ -4,7 +4,6 @@ import de.thm.arsnova.services.SessionMotdService
import de.thm.arsnova.models._
import de.thm.arsnova.hateoas.{ApiRoutes, ResourceAdapter, Link}
import scala.concurrent.ExecutionContext.Implicits.global
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import akka.http.scaladsl.server.Directives._
import spray.json._
......@@ -13,6 +12,8 @@ import spray.json._
The API Interface regarding session messages.
*/
trait SessionMotdApi {
import de.thm.arsnova.Context.executor
// protocol for serializing data
import de.thm.arsnova.mappings.SessionMotdJsonProtocol._
......
......@@ -3,12 +3,13 @@ package de.thm.arsnova.api
import de.thm.arsnova.services.UserService
import de.thm.arsnova.models._
import scala.concurrent.ExecutionContext.Implicits.global
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import akka.http.scaladsl.server.Directives._
import spray.json._
trait UserApi {
import de.thm.arsnova.Context.executor
import de.thm.arsnova.mappings.UserJsonProtocol._
val userApi = pathPrefix("") {
......
......@@ -2,11 +2,12 @@ package de.thm.arsnova.services
import de.thm.arsnova.models._
import slick.driver.MySQLDriver.api._
import scala.concurrent.{ExecutionContext, Future}
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.util.{Failure, Success}
object FeaturesService extends BaseService {
import de.thm.arsnova.Context.executor
def getById(featuresId: FeaturesId): Future[Features] = {
featuresTable.filter(_.id === featuresId).result.head
}
......
......@@ -3,10 +3,11 @@ package de.thm.arsnova.services
import de.thm.arsnova.models._
import slick.driver.MySQLDriver.api._
import scala.concurrent.{ExecutionContext, Future}
import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.{Failure, Success}
object QuestionService extends BaseService {
import de.thm.arsnova.Context.executor
def findQuestionsBySessionIdAndVariant(sessionId: SessionId, variant: String): Future[Seq[Question]] = {
db.run(questionsTable.filter(q => q.sessionId === sessionId && q.variant === variant).result).map(qSeq =>
Future.traverse(qSeq) { q: Question => q.format match {
......
......@@ -3,9 +3,10 @@ package de.thm.arsnova.services
import de.thm.arsnova.models.{UserId, Session, SessionId, Features}
import slick.driver.MySQLDriver.api._
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
object SessionService extends BaseService{
object SessionService extends BaseService {
import de.thm.arsnova.Context.executor
def findUserSessions(userId: UserId): Future[Seq[Session]] = {
val resultTupleQry = for {
sessions <- sessionsTable.filter(_.userId === userId)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment