Skip to Content
Dapr学习手册
book

Dapr学习手册

by Haishi Bai, Yaron Schneider
November 2021
Beginner to intermediate
239 pages
4h 15m
Chinese
China Electric Power Press Ltd.
Content preview from Dapr学习手册
简介
41
0.5.1
独立模式下的绑定
绑定的主要好处之一是关注点分离。当你使用绑定时,你将应用设计为从命
名(
named
)事件源中接收事件。但是,你没有提供有关事件源的任何详细信
息。然后,你(或者操作你应用的人)可以在未来选择将你的应用重新绑定
到完全不同的事件源上去,而不会影响你的代码。
实际上,你甚至可以在应
用运行时对其进行重新绑定。
Dapr
附带了一些预先构建的绑定。
在独立模式下,每个绑定由
components
目录中的元数据文件描述。
在以下练习中,我们将首先充当开发人员,并使
JavaScript
编写一个简单的
HTML
页面,该页面将事件发送给名为
target
的目标。
然后,我们将充当应用运维人员,并将
target
配置为
Azure Event
Hub
0.5.1.1
开发人员:编写一个简单的
HTML
页面
在这一部分中,我们将编写一个带有按钮的
HTML
页面。单击该按钮后,应
用通过向
Dapr
边车发送包含一个地址为
target
的消息的
POST
请求,从而
将消息发送到名为
target
的绑定:
1.
创建一个名为
html-app
的新目录。
2.
在该目录下创建一个
index.html
的文件,其中包含以下内容。该代码创
建一个按钮,当该按钮被按下后,将使用
jQuery
http://localhost:3500/
v1.0/bindings/target
上的
POST
请求发送给
Dapr
边车:
<!DOCTYPE html>
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

流畅的Python(第2版)

流畅的Python(第2版)

Luciano Ramalho
数据科学原理

数据科学原理

Posts & Telecom Press, Sinan Ozdemir
Python预测分析实战

Python预测分析实战

Posts & Telecom Press, Alvaro Fuentes
机器学习开发者指南

机器学习开发者指南

Posts & Telecom Press, Rodolfo Bonnin

Publisher Resources

ISBN: 9787519859367