Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stream APIs for PodNodes and PodResource #524

Merged
merged 6 commits into from
Dec 29, 2021

Conversation

jschwinger233
Copy link
Member

@jschwinger233 jschwinger233 commented Dec 23, 2021

  1. 新增了 PodNodesStream 和 PodResourceStream API
  2. toRPCNode 之前有 IO, node 去 fetch runtime Info, 把这部分放到 cluster 了, 让 rpc/transform 依然保持纯计算无 IO

@jschwinger233 jschwinger233 changed the title [WIP] add stream APIs for PodNodes related operations Add stream APIs for PodNodes and PodResource Dec 28, 2021
@jschwinger233
Copy link
Member Author

@DuodenumL 求 review

@@ -17,11 +17,15 @@ import (
func (c *Calcium) ListNetworks(ctx context.Context, podname string, driver string) ([]*enginetypes.Network, error) {
logger := log.WithField("Calcium", "ListNetworks").WithField("podname", podname).WithField("driver", driver)
networks := []*enginetypes.Network{}
nodes, err := c.ListPodNodes(ctx, podname, nil, false)
ch, err := c.ListPodNodes(ctx, &types.ListNodesOptions{Podname: podname})
Copy link
Contributor

Choose a reason for hiding this comment

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

是不是应该分别提供返回chan *types.Node和[]*types.Node的两个方法呢?

Copy link
Member Author

Choose a reason for hiding this comment

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

没必要吧, cluster 的接口应该正交, 而且内部实现也是流式的, 多个 goroutine 并发去取

Copy link
Member Author

Choose a reason for hiding this comment

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

等泛型可用了加一个 ChanToSlice 的泛型函数就好了

types/node.go Outdated
@@ -56,6 +55,7 @@ func (n NodeMeta) DeepCopy() (nn NodeMeta, err error) {
// Node store node info
type Node struct {
NodeMeta
NodeInfo string
Copy link
Contributor

Choose a reason for hiding this comment

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

这个如果不需要存到ETCD里,要不要标上json:"-"

@jschwinger233
Copy link
Member Author

那就这样吧先

@jschwinger233 jschwinger233 merged commit 117368c into projecteru2:master Dec 29, 2021
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.

2 participants