reselect

Dubbo(五):集群容错的实现

巧了我就是萌 提交于 2020-05-03 18:56:30
  前两篇中,我们看到了dubbo在负载均衡和服务路由方面的实现,它为集群功能提供了必要的功能。   今天我们再来看另一个集群组件的实现:集群容错。 1. dubbo 集群容错简介   为了避免单点故障,现在的应用通常至少会部署在两台服务器上。对于一些负载比较高的服务,会部署更多的服务器。对于服务消费者来说,同一环境下出现了多个服务提供者。这时会出现一个问题,服务消费者需要决定选择哪个服务提供者进行调用。另外服务调用失败时的处理措施也是需要考虑的,是重试呢,还是抛出异常,亦或是只打印异常等。为了处理这些问题,Dubbo 定义了集群接口 Cluster 以及 Cluster Invoker。集群 Cluster 用途是将多个服务提供者合并为一个 Cluster Invoker,并将这个 Invoker 暴露给服务消费者。这样一来,服务消费者只需通过这个 Invoker 进行远程调用即可,至于具体调用哪个服务提供者,以及调用失败后如何处理等问题,现在都交给集群模块去处理。集群模块是服务提供者和服务消费者的中间层,为服务消费者屏蔽了服务提供者的情况,这样服务消费者就可以专心处理远程调用相关事宜。   dubbo的集群容错功能由多个组件共同完成:包括 Cluster、Cluster Invoker、Directory、Router 和 LoadBalance 等。它们之间的依赖关系如下:

redux reselect is returning a function

偶尔善良 提交于 2020-04-18 12:52:30
问题 For some strange weird reason my reselect selector is returning this function : ƒ () { if (!areArgumentsShallowlyEqual(equalityCheck, lastArgs, arguments)) { // apply arguments instead of spreading for performance. lastResult = func.apply(null, arguments); } I do not understand why it is doing this. It is supposed to return some JSON which I can use to map in my mapToProps . My redux mapping is simple enough and looks like this : const mapStateToProps = (state) => { return { initialValues:

redux reselect is returning a function

淺唱寂寞╮ 提交于 2020-04-18 12:51:32
问题 For some strange weird reason my reselect selector is returning this function : ƒ () { if (!areArgumentsShallowlyEqual(equalityCheck, lastArgs, arguments)) { // apply arguments instead of spreading for performance. lastResult = func.apply(null, arguments); } I do not understand why it is doing this. It is supposed to return some JSON which I can use to map in my mapToProps . My redux mapping is simple enough and looks like this : const mapStateToProps = (state) => { return { initialValues:

Get last 2 elements of an array in a selector (Redux)

大城市里の小女人 提交于 2020-02-08 09:27:25
问题 An array starts as [] and then keeps growing with numbers being added to it. I'm trying to create a selector to extract the last 2 elements of the array. I've got the following: const getHistory = (state) => state.score.history; export const lastTwo = createSelector( [getHistory], history => (history.length > 1 ? history.slice(-1, -3) : 0) ); It shows the initial 0 but then it does not output any value. Please advise. If, just for testing purposes, I do: export const lastTwo = createSelector(

Immutable, why does my nested object using fromJS are not immutable when I use reselect

我们两清 提交于 2020-01-17 03:19:08
问题 I have a bug with immutablejs and reselect. I have the following redux store in my reactjs application : /* * The reducer takes care of our data * Using actions, we can change our application state * To add a new action, add it to the switch statement in the homeReducer function * * Example: * case YOUR_ACTION_CONSTANT: * return assign({}, state, { * stateVariable: action.var * }); */ import { fromJS } from 'immutable'; import { CHANGE_FORM, SENDING_REQUEST, REQUEST_SUCCESS, CLEAR_SUCCESS,

How is state passed to selectors in a react-redux app?

自古美人都是妖i 提交于 2020-01-12 03:34:57
问题 I came across an example, where the mapStateToProps function is using memoization. I was just wondering how the "state" parameter is passed onto memoized selectors. After looking at the docs for reselect as well as redux, it seems that the mapStateToProps can return a function which accepts state as its argument, and the connect decorator might be the one passing the state to it but am not sure. Can someone please shed some light? views/tracklist/index.js const mapStateToProps =

How is state passed to selectors in a react-redux app?

馋奶兔 提交于 2020-01-12 03:34:09
问题 I came across an example, where the mapStateToProps function is using memoization. I was just wondering how the "state" parameter is passed onto memoized selectors. After looking at the docs for reselect as well as redux, it seems that the mapStateToProps can return a function which accepts state as its argument, and the connect decorator might be the one passing the state to it but am not sure. Can someone please shed some light? views/tracklist/index.js const mapStateToProps =

Reselect - does it ever make sense to create a memorized selector which is just used to get part of the state?

别说谁变了你拦得住时间么 提交于 2020-01-03 08:31:34
问题 I have a normal selector which is just used to get part of the state: export const getAllPosts = state => { return state.posts; }; If I use the reselect to wrap the selector: import { createSelector } from 'reselect'; export const allPosts = createSelector( getAllPosts, (posts) => posts ); Does it make any sense such as improving performance ? In my opinion, the wrapper is unnecessary. 回答1: No, it does not make sense to create a memoized selector just to get part of the state tree. The reason

substate.get() is not a function using React Boilerplate

核能气质少年 提交于 2019-12-23 20:15:36
问题 I have a component called Login, and these selectors: const selectLogin = () => (state) => state.get('login'); const selectUser = () => createSelector( selectLogin(), (loginState) => loginState.get('user') ); Here's what state looks like for the "login" component: login: { user: { id: 206 } } In another component, I want to select the "user" object. At the top of my file, I have import { createStructuredSelector } from 'reselect'; import { selectLogin, selectUser } from 'containers/Login

Reselect - selector that invokes another selector?

牧云@^-^@ 提交于 2019-12-21 03:53:29
问题 I have a selector: const someSelector = createSelector( getUserIdsSelector, (ids) => ids.map((id) => yetAnotherSelector(store, id), ); // ^^^^^ (yetAnotherSelector expects 2 args) That yetAnotherSelector is another selector, that takes user id - id and returns some data. However , since it's createSelector , I don't have access to store in it (I don't want it as a function because the memoization wouldn't work then). Is there a way to access store somehow inside createSelector ? Or is there