Reactive - 01 - 简介

翻译自:https://tech.io/playgrounds/929/reactive-programming-with-reactor-3/Intro

Introduction to Reactive Programming


Reactor 3 is a library built around the Reactive Streams
specification, bringing the paradigm of Reactive Programming
on the JVM.

Reactor 3是一个围绕反应流规范构建的库,在JVM上引入了反应式编程的范例。

In this course, you'll familiarize with the Reactor API.
So let's make a quick introduction to the more general concepts
in Reactive Streams and Reactive Programming.

在本课程中,您将熟悉Reactor API。让我们快速介绍一下反应流和反应编程中更一般的概念。

Why


Reactive Programming is a new paradigm in which you use declarative code
(in a manner that is similar to functional programming) in order to build
asynchronous processing pipelines. It is an event-based model where data
is pushed to the consumer, as it becomes available: we deal with asynchronous
sequences of events.

反应式编程是一种新的范式,在这种范式中,您使用声明性代码(以类似于函数式编程的方式)来构建异步处理管道。
它是一种基于事件的模型,当数据可用时,数据被推送到消费者手中:我们以异步事件序列来处理。

This is important in order to be more efficient with resources and increase
an application's capacity to serve large number of clients, without the
headache of writing low-level concurrent or and/or parallelized code.

为了更有效地利用资源,提高应用程序为大量客户机服务的能力,而不必编写低级并发或/或并行代码,这一点很重要。

By being built around the core pillars of being fully asynchronous and non-blocking,
Reactive Programming is an alternative to the more limited ways of doing asynchronous
code in the JDK: namely Callback based APIs and Future.

通过围绕完全异步和非阻塞的核心支柱构建,反应式编程是JDK中执行异步代码更有限方法的替代方法:
即基于Callback的API和Future。

It also facilitates composition, which in turn makes asynchronous code more
readable and maintainable.

它还促进了组合,从而使异步代码更具可读性和可维护性。

Reactive Streams


The Reactive Streams specification is an industry-driven effort to standardize
Reactive Programming libraries on the JVM, and more importantly specify how they
must behave so that they are interoperable. Implementors include Reactor 3 but also
RxJava from version 2 and above, Akka Streams, Vert.x and Ratpack.

反应流规范是一项行业驱动的工作,旨在标准化JVM上的反应式编程库,更重要的是指定它们的行为方式,
以使它们具有互操作性。实现者包括Reactor 3,也包括RxJava版本2及更高版本,Akka Streams,Vert.x和Ratpack。

It contains 4 very simple interfaces as well as a TCK, which shouldn't be overlooked
since it is the rules of the specification that bring the most value to it.

它包含4个非常简单的接口以及一个TCK,这不应该被忽视,因为规范的规则为它带来了最大的价值。

From a user perspective however, it is fairly low-level. Reactor 3 aims at offering an
higher level API that can be leverage in a large breadth of situations, building it on
top of Reactive Streams Publisher.

然而,从用户的角度来看,它是相当低级的。Reactor 3旨在提供一种更高级别的API,该API可以在广泛的情况下使用,
将其构建在反应流Publisher的基础上。

Interactions


In reactive stream sequences, the source Publisher produces data. But by default,
it does nothing until a Subscriber has registered (subscribed), at which point
it will push data to it.

在反应流序列中,源Publisher(发布者)生成数据。但默认情况下,在Subscriber(订阅者)注册(订阅)之前,
它什么也不做,订阅发生时它(Publisher)会将数据推送到它(Subscriber)。
01_PublisherSubscriber.png

Reactor adds the concept of operators, which are chained together to describe
what processing to apply at each stage to the data. Applying an operator returns a new
intermediate Publisher (in fact it can be thought of as both a Subscriber to the operator
upstream and a Publisher for downstream). The final form of the data ends up in the final
Subscriber that defines what to do from a user perspective.

Reactor增加了运算符(operators)的概念,将运算符链接在一起,以描述在每个阶段对数据应用什么处理。
应用运算符将返回一个新的中间发布者(实际上,它可以被视为运算符上游的订阅者和下游的发布者)。数据的最终形式在
最终订阅者中结束,该订阅者从用户角度定义了要做的事情。
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 218,546评论 6 507
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,224评论 3 395
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 164,911评论 0 354
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,737评论 1 294
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,753评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,598评论 1 305
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,338评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,249评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,696评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,888评论 3 336
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,013评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,731评论 5 346
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,348评论 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,929评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,048评论 1 270
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,203评论 3 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,960评论 2 355

推荐阅读更多精彩内容