-
Notifications
You must be signed in to change notification settings - Fork 42
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
Add stream APIs for PodNodes and PodResource #524
Conversation
jschwinger233
commented
Dec 23, 2021
•
edited
Loading
edited
- 新增了 PodNodesStream 和 PodResourceStream API
- toRPCNode 之前有 IO, node 去 fetch runtime Info, 把这部分放到 cluster 了, 让 rpc/transform 依然保持纯计算无 IO
533dbbc
to
7fad652
Compare
fa7142f
to
e525e3e
Compare
@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}) |
There was a problem hiding this comment.
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的两个方法呢?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没必要吧, cluster 的接口应该正交, 而且内部实现也是流式的, 多个 goroutine 并发去取
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个如果不需要存到ETCD里,要不要标上json:"-"
e525e3e
to
4d32584
Compare
那就这样吧先 |