Coder Social home page Coder Social logo

akka-fusion / fusion-discoveryx Goto Github PK

View Code? Open in Web Editor NEW
15.0 3.0 7.0 2.25 MB

基于Akka实现的服务注册与发现平台

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

License: Apache License 2.0

Scala 28.99% JavaScript 67.37% Shell 0.43% HTML 1.38% CSS 0.98% Dockerfile 0.06% Java 0.66% PLSQL 0.14%
akka scala config-management discovery-service grpc akka-cluster akka-grpc typed-actor akka-typed

fusion-discoveryx'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"}

fusion-discoveryx's People

Contributors

gongtiexin avatar yangbajing avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

fusion-discoveryx's Issues

还打算继续维护吗?要升级到Akka Typed吗?

看了你写的文章,国内用akka的人少,lightbend公司的这一套技术栈非常厉害,但是门槛有点高,我用akka写了个迁移elasticsearch数据的小工具,性能非常高,代码设计起来也很舒服,打算进一步扩大试用范围

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.