微软的分布式应用框架 Dapr Helloworld


Dapr HelloWorld

dapr/dapr

GitHub

Dapr is a portable, serverless, event-driven runtime that makes it easy for developers to build resilient, stateless and stateful microservices that run on the cloud and edge and embraces the diversity of languages and developer frameworks.

Dapr codifies the best practices for building microservice applications into open, independent, building blocks that enable you to build portable applications with the language and framework of your choice. Each building block is independent and you can use one, some, or all of them in your application.

比上面的介绍多了 stateless or stateful 的标签。学《计算理论》的时候接触过一些状态机。

”状态是万恶之源“

注意提到了多语言和多开发者框架,我认为这是他选择的通过通信共享信息,即 HTTPGRPC 支持多语言等特性。微软想通过这个设定一个构建微服务应用的规则。从根本上确立你开发的每一个应用的独立性。

下面进行一个 QuickStart

Docker(微服务已经离不开容器化了)

  • Install Dapr
  • Node.js version 8 or greater(这个 Helloworld 是 node 应用)
  • Rest Client Plugin
    然后打开目录下的 sample.http , 可以看到 send request 的选项
    sample.http

    POST http://localhost:3500/v1.0/invoke/mynode/method/neworder
    {
      "data": {
        "orderId": "42"
      } 
    }
    

    sample.http

    GET http://localhost:3500/v1.0/invoke/mynode/method/order
    

    https://github.com/dapr/dapr

  • https://github.com/dapr/docs/blob/master/getting-started/environment-setup.md#environment-setup
  • https://github.com/dapr/docs/tree/master/howto
  • https://github.com/dapr/samples
  • https://github.com/dapr/samples/tree/master/1.hello-world