In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to understand the Reactive system". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to understand the Reactive system".
The system of Reactive is a system that can respond to customer requests in a timely manner through the realization of resilience.
As Reactive Manifesto said:
Systems built as Reactive Systems are more flexible, loosely-coupled and scalable.
When it comes to loose coupling, one of the most basic patterns is the "observer mode". Further from the observer model, the publish-subscribe model can be derived. Compared with the former, the publish-subscribe model has an additional role of "event channel". Through this channel, subscribers do not have to know about the publisher-the two are decoupled.
Responsive stream = observer + iterator
From the definition of Iterator, Iterator is a "pull" model, which is pulled by calling next () when we need data, and hasNext () is to query whether there is still data available. If there is anything abnormal in the upstream data, it can only be sensed or even not detected by the exception thrown by next (). Public interface Iterator {E next (); boolean hasNext ();}
Take the RxObserver of RxJava as an example to feel the improvement in its interface semantics:
Public interface RxObserver {
Void onNext (T next)
Void onComplete ()
Void onError ()
}
The method name that begins with a prefix in the form of on gives me a distinct sense of "notification". The upstream component tells us that there is new data, it is over, and something has gone wrong! A "push" smell.
Is it perfect to evolve to this stage? No, no.
If the RxObserver communicates with the upstream components across the network, then we can imagine that the mode in which each onNext processes one data at a time over the network is not efficient. And RxObserver can't express its needs upstream (for example, how much data do you need? No longer need data, etc.), this can easily extend to the question of how to coordinate with the upstream when the processing speed of RxObserver as a consumer does not match that of the upstream.
The Reactive Stream specification standardizes the above requirements, as follows. Subscription can be used for upstream Publisher requests to express whether and how much data is still needed. If you request (1) each time, the whole pattern is equivalent to a "pull" model; request (Integer.MAX_VALUE) is the equivalent of a "push" model.
Public interface Publisher {
Public void subscribe (Subscriber
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.