Skip to content

hangscer8/monitorSystem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

writen in scala(my favourite language)

some helpful util

import play.api.mvc._

class ActionContext[A](val request: Request[A], private[this] val p: Promise[Result]) {
  def complete(result: Result): Future[Result] = {
    p.complete(Try(result))
    p.future
  }
}

object ActionContext {
  def imperativelyComplete[A](bp: BodyParser[A])(inner: ActionContext[A] => Unit): Action[A] = {
    Action.async(bp) { request =>
      val p = Promise[Result]
      inner(new ActionContext(request, p))
      p.future
    }
  }

  def imperativelyComplete(inner: ActionContext[AnyContent] => Unit): Action[AnyContent] = {
    Action.async { request =>
      val p = Promise[Result]
      inner(new ActionContext(request, p))
      p.future
    }
  }
}
@Singleton
class AlarmEventController @Inject()(cc: ControllerComponents) extends AbstractController(cc) with Circe with AlarmServiceTrait with UtilTrait {
  def index() = ActionContext.imperativelyComplete { ctx =>
    val agentList = db.run(alarmEvents.sortBy(_.created.desc).take(15).result).exe
    ctx.complete(Ok(views.html.alarm.alarmEvent("查看告警信息", agentList)))
  }
}

About

基于 scala akka 毕业作品

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages