Giter VIP home page Giter VIP logo

akka-fusion / akka-fusion Goto Github PK

View Code? Open in Web Editor NEW
29.0 29.0 5.0 3.39 MB

Akka Fusion可以轻松创建独立的,生产级的基于Akka的应用程序。我们集成了Akka生态系统里常用及流行的组件, 因此您可以快速搭建开始你的应用。大多数Akka Fusion应用程序只需要很少的配置。

Home Page: https://akka-fusion.github.io/akka-fusion/

License: Apache License 2.0

Shell 2.98% Scala 93.94% Java 2.28% Batchfile 0.71% HTML 0.09%
akka reactive scala

akka-fusion's Introduction

Akka Fusion

Build Status

Akka Fusion可以轻松创建独立的,生产级的基于Akka的应用程序。我们集成了Akka生态系统里常用及流行的组件, 因此您可以快速搭建开始你的应用。大多数Akka Fusion应用程序只需要很少的 配置

更多内容请阅读文档:https://akka-fusion.github.io/akka-fusion/

快速开始

object SampleApplication {

  def main(args: Array[String]): Unit = {
    val system = FusionUtils.createActorSystem(ConfigFactory.load())
    implicit val ec = system.executionContext
    val sampleService = new SampleService()
    val route = new SampleRoute(sampleService)
    FusionHttpServer(system).component.startAbstractRouteSync(route)
  }
}

// Route
class SampleRoute(sampleService: SampleService) extends AbstractRoute {
  override def route: Route = pathGet("hello") {
    parameters(('hello, 'year.as[Int].?(2019))).as(SampleReq) { req =>
      futureComplete(sampleService.hello(req))
    }
  }
}

// Request、Response Model
case class SampleReq(hello: String, year: Int)
case class SampleResp(hello: String, year: Int, language: String)

// Service
class SampleService()(implicit ec: ExecutionContext) {

  def hello(req: SampleReq): Future[SampleResp] = Future {
    SampleResp(req.hello, req.year, "scala")
  }
}

测试:

$ curl -i http://localhost:8000/hello?hello=Hello
HTTP/1.1 200 OK
Fusion-Server: fusion/0:0:0:0:0:0:0:0:8000
Server: akka-http/10.1.7
Date: Sat, 16 Feb 2019 11:24:37 GMT
Content-Type: application/json
Content-Length: 48

{"hello":"Hello","year":2019,"language":"scala"}

akka-fusion's People

Contributors

yangbajing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.