本文整理汇总了Golang中github.com/docker/containerd/api/grpc/types.APIClient类的典型用法代码示例。如果您正苦于以下问题:Golang APIClient类的具体用法?Golang APIClient怎么用?Golang APIClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了APIClient类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: containerEvents
func containerEvents(c types.APIClient, container string) <-chan *types.Event {
evChan := make(chan *types.Event)
ts := time.Now()
go func() {
for {
tsp, err := ptypes.TimestampProto(ts)
if err != nil {
close(evChan)
return
}
events, err := c.Events(netcontext.Background(), &types.EventsRequest{Timestamp: tsp})
if err != nil {
fmt.Printf("c.Events error: %v", err)
// TODO try to find a way to kill the process ?
close(evChan)
return
}
for {
e, err := events.Recv()
if err != nil {
time.Sleep(1 * time.Second)
break
}
ts, err = ptypes.Timestamp(e.Timestamp)
if e.Id == container {
evChan <- e
}
}
}
}()
return evChan
}
开发者ID:hyperhq,项目名称:runv,代码行数:32,代码来源:main.go
示例2: waitForExit
func waitForExit(c types.APIClient, events types.API_EventsClient, id, pid string, closer func()) {
timestamp := time.Now()
for {
e, err := events.Recv()
if err != nil {
if grpc.ErrorDesc(err) == transport.ErrConnClosing.Desc {
closer()
os.Exit(128 + int(syscall.SIGHUP))
}
time.Sleep(1 * time.Second)
tsp, err := ptypes.TimestampProto(timestamp)
if err != nil {
closer()
fmt.Fprintf(os.Stderr, "%s", err.Error())
os.Exit(1)
}
events, _ = c.Events(netcontext.Background(), &types.EventsRequest{Timestamp: tsp})
continue
}
timestamp, err = ptypes.Timestamp(e.Timestamp)
if e.Id == id && e.Type == "exit" && e.Pid == pid {
closer()
os.Exit(int(e.Status))
}
}
}
开发者ID:estesp,项目名称:containerd,代码行数:26,代码来源:container.go
示例3: worker
func worker(client types.APIClient) {
defer group.Done()
for id := range jobs {
if _, err := client.CreateContainer(netcontext.Background(), &types.CreateContainerRequest{
Id: id,
BundlePath: bundle,
}); err != nil {
logrus.Error(err)
}
}
}
开发者ID:mynameismevin,项目名称:containerd,代码行数:11,代码来源:benchmark.go
示例4: resize
func resize(id, pid string, c types.APIClient) error {
ws, err := term.GetWinsize(os.Stdin.Fd())
if err != nil {
return err
}
if _, err := c.UpdateProcess(netcontext.Background(), &types.UpdateProcessRequest{
Id: id,
Pid: "init",
Width: uint32(ws.Width),
Height: uint32(ws.Height),
}); err != nil {
return err
}
return nil
}
开发者ID:carriercomm,项目名称:containerd,代码行数:15,代码来源:container.go
示例5: waitForExit
func waitForExit(c types.APIClient, events types.API_EventsClient, id, pid string, closer func()) {
timestamp := uint64(time.Now().Unix())
for {
e, err := events.Recv()
if err != nil {
time.Sleep(1 * time.Second)
events, _ = c.Events(netcontext.Background(), &types.EventsRequest{Timestamp: timestamp})
continue
}
timestamp = e.Timestamp
if e.Id == id && e.Type == "exit" && e.Pid == pid {
closer()
os.Exit(int(e.Status))
}
}
}
开发者ID:carriercomm,项目名称:containerd,代码行数:16,代码来源:container.go
示例6: resizeTty
func resizeTty(c types.APIClient, container, process string) {
ws, err := term.GetWinsize(os.Stdin.Fd())
if err != nil {
fmt.Printf("Error getting size: %s", err.Error())
return
}
if _, err = c.UpdateProcess(netcontext.Background(), &types.UpdateProcessRequest{
Id: container,
Pid: process,
Width: uint32(ws.Width),
Height: uint32(ws.Height),
}); err != nil {
fmt.Printf("set winsize failed, %v\n", err)
}
}
开发者ID:hyperhq,项目名称:runv,代码行数:16,代码来源:tty.go
注:本文中的github.com/docker/containerd/api/grpc/types.APIClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论