本文整理汇总了Golang中github.com/coreos/rkt/api/v1alpha.PublicAPIClient类的典型用法代码示例。如果您正苦于以下问题:Golang PublicAPIClient类的具体用法?Golang PublicAPIClient怎么用?Golang PublicAPIClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PublicAPIClient类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: getLogsWithFollow
func getLogsWithFollow(c v1alpha.PublicAPIClient, p *v1alpha.Pod) {
if len(p.Apps) == 0 {
fmt.Printf("Pod %q has no apps\n", p.Id)
return
}
logsResp, err := c.GetLogs(context.Background(), &v1alpha.GetLogsRequest{
PodId: p.Id,
Follow: true,
AppName: p.Apps[0].Name,
})
if err != nil {
fmt.Println(err)
os.Exit(1)
}
for {
logsRecvResp, err := logsResp.Recv()
if err == io.EOF {
return
}
if err != nil {
fmt.Println(err)
return
}
for _, l := range logsRecvResp.Lines {
fmt.Println(l)
}
}
}
开发者ID:CodeJuan,项目名称:kubernetes,代码行数:32,代码来源:client_example.go
示例2: getLogsWithoutFollow
func getLogsWithoutFollow(c v1alpha.PublicAPIClient, p *v1alpha.Pod) {
if len(p.Apps) == 0 {
fmt.Printf("Pod %q has no apps\n", p.Id)
return
}
logsResp, err := c.GetLogs(context.Background(), &v1alpha.GetLogsRequest{
PodId: p.Id,
Follow: false,
AppName: p.Apps[0].Name,
SinceTime: time.Now().Add(-time.Second * 5).Unix(),
Lines: 10,
})
if err != nil {
fmt.Println(err)
os.Exit(1)
}
logsRecvResp, err := logsResp.Recv()
if err == io.EOF {
return
}
if err != nil {
fmt.Println(err)
return
}
for _, l := range logsRecvResp.Lines {
fmt.Println(l)
}
}
开发者ID:CodeJuan,项目名称:kubernetes,代码行数:34,代码来源:client_example.go
示例3: benchListPods
func benchListPods(b *testing.B, c v1alpha.PublicAPIClient, detail bool) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, err := c.ListPods(context.Background(), &v1alpha.ListPodsRequest{Detail: detail})
if err != nil {
b.Error(err)
}
}
b.StopTimer()
}
开发者ID:sinfomicien,项目名称:rkt,代码行数:10,代码来源:rkt_api_service_bench_test.go
示例4: benchInspectPod
func benchInspectPod(b *testing.B, c v1alpha.PublicAPIClient) {
resp, err := c.ListPods(context.Background(), &v1alpha.ListPodsRequest{})
if err != nil {
b.Fatalf("Unexpected error: %v", err)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, err := c.InspectPod(context.Background(), &v1alpha.InspectPodRequest{Id: resp.Pods[0].Id})
if err != nil {
b.Error(err)
}
}
b.StopTimer()
}
开发者ID:sinfomicien,项目名称:rkt,代码行数:15,代码来源:rkt_api_service_bench_test.go
示例5: newRktContainerHandler
func newRktContainerHandler(name string, rktClient rktapi.PublicAPIClient, rktPath string, cgroupSubsystems *libcontainer.CgroupSubsystems, machineInfoFactory info.MachineInfoFactory, fsInfo fs.FsInfo, rootFs string, ignoreMetrics container.MetricSet) (container.ContainerHandler, error) {
aliases := make([]string, 1)
isPod := false
apiPod := &rktapi.Pod{}
parsed, err := parseName(name)
if err != nil {
return nil, fmt.Errorf("this should be impossible!, new handler failing, but factory allowed, name = %s", name)
}
//rktnetes uses containerID: rkt://fff40827-b994-4e3a-8f88-6427c2c8a5ac:nginx
if parsed.Container == "" {
isPod = true
aliases = append(aliases, "rkt://"+parsed.Pod)
} else {
aliases = append(aliases, "rkt://"+parsed.Pod+":"+parsed.Container)
}
pid := os.Getpid()
labels := make(map[string]string)
resp, err := rktClient.InspectPod(context.Background(), &rktapi.InspectPodRequest{
Id: parsed.Pod,
})
if err != nil {
return nil, err
} else {
var annotations []*rktapi.KeyValue
if parsed.Container == "" {
pid = int(resp.Pod.Pid)
apiPod = resp.Pod
annotations = resp.Pod.Annotations
} else {
var ok bool
if annotations, ok = findAnnotations(resp.Pod.Apps, parsed.Container); !ok {
glog.Warningf("couldn't find application in Pod matching %v", parsed.Container)
}
}
labels = createLabels(annotations)
}
cgroupPaths := common.MakeCgroupPaths(cgroupSubsystems.MountPoints, name)
// Generate the equivalent cgroup manager for this container.
cgroupManager := &cgroupfs.Manager{
Cgroups: &configs.Cgroup{
Name: name,
},
Paths: cgroupPaths,
}
hasNetwork := false
if isPod {
hasNetwork = true
}
rootfsStorageDir := getRootFs(rktPath, parsed)
handler := &rktContainerHandler{
name: name,
rktClient: rktClient,
cgroupSubsystems: cgroupSubsystems,
machineInfoFactory: machineInfoFactory,
cgroupPaths: cgroupPaths,
cgroupManager: cgroupManager,
fsInfo: fsInfo,
hasNetwork: hasNetwork,
rootFs: rootFs,
isPod: isPod,
aliases: aliases,
pid: pid,
labels: labels,
rootfsStorageDir: rootfsStorageDir,
ignoreMetrics: ignoreMetrics,
apiPod: apiPod,
}
if !ignoreMetrics.Has(container.DiskUsageMetrics) {
handler.fsHandler = common.NewFsHandler(time.Minute, rootfsStorageDir, "", fsInfo)
}
return handler, nil
}
开发者ID:Clarifai,项目名称:kubernetes,代码行数:83,代码来源:handler.go
注:本文中的github.com/coreos/rkt/api/v1alpha.PublicAPIClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论