Skip to content

Conversation

@atlas-comstock
Copy link
Contributor

No description provided.

@CMGS CMGS changed the title realloc: Send Error to watcher instead of boolean success. [WIP] realloc: Send Error to watcher instead of boolean success. Nov 14, 2019
@jschwinger233
Copy link
Member

有一个奇异的想法, 因为 errCh 是一个请求上下文的东西, 那么可不可以把 errCh 统一在 rpc 层塞入 context.Value 呢...

这是受 flask 的模式影响了, 在 flask 里的两大上下文 request / application 用很多的应用场合.

查了一下文档, 似乎也是鼓励把 Context.Value 用在请求上下文的场合:

Use context Values only for request-scoped data that transits processes and APIs, not for passing optional parameters to functions.

https://golang.org/pkg/context/#WithValue

@CMGS
Copy link
Contributor

CMGS commented Nov 26, 2019 via email

@jschwinger233
Copy link
Member

比方说 rpc 层里把 ctx 包一下再传给 calcium:

errCh = make(chan error);
ctx = context.WithValue(ctx, "errCh", errCh);

calcium 要取 errCh 的时候直接 errCh, ok = ctx.Value("errCh").(chan error) 就可以了吧;

同理 store 等下层都可以取出, 只要 ctx 是一路传递下去的.

@jschwinger233
Copy link
Member

为啥没下文啦 这个功能还挺有用的 @yonghaowu

@atlas-comstock
Copy link
Contributor Author

@jschwinger23 代码还要再改改,那时忙着搞CacheCloud了,我这几天改改

@CMGS
Copy link
Contributor

CMGS commented Mar 11, 2020

@jschwinger23 代码还要再改改,那时忙着搞CacheCloud了,我这几天改改

那时到现在都过了一年了。。。

@jschwinger233
Copy link
Member

那时到现在都过了一年零8天了。。。

@atlas-comstock atlas-comstock force-pushed the master branch 2 times, most recently from 90c661a to 463834f Compare March 20, 2020 03:55
@CMGS CMGS changed the title [WIP] realloc: Send Error to watcher instead of boolean success. realloc: Send Error to watcher instead of boolean success. Mar 23, 2020
@CMGS CMGS requested a review from jschwinger233 March 23, 2020 08:54
Copy link
Member

@jschwinger233 jschwinger233 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改下 calVolCPUMemNodeContainersInfo 就好了

@atlas-comstock
Copy link
Contributor Author

@jschwinger23 好!等我 整体再看看,对抽出来的函数的命名感觉不太准确

@atlas-comstock atlas-comstock changed the title realloc: Send Error to watcher instead of boolean success. realloc: Send Error to channel instead of boolean success. Mar 24, 2020
@CMGS CMGS merged commit 9de65e9 into projecteru2:master Mar 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants