本文整理汇总了Golang中k8s/io/kubernetes/pkg/watch/json.Object函数的典型用法代码示例。如果您正苦于以下问题:Golang Object函数的具体用法?Golang Object怎么用?Golang Object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Object函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: HandleWS
// HandleWS implements a websocket handler.
func (w *WatchServer) HandleWS(ws *websocket.Conn) {
defer ws.Close()
done := make(chan struct{})
go func() {
var unused interface{}
// Expect this to block until the connection is closed. Client should not
// send anything.
websocket.JSON.Receive(ws, &unused)
close(done)
}()
for {
select {
case <-done:
w.watching.Stop()
return
case event, ok := <-w.watching.ResultChan():
if !ok {
// End of results.
return
}
w.fixup(event.Object)
obj, err := watchjson.Object(w.codec, &event)
if err != nil {
// Client disconnect.
w.watching.Stop()
return
}
if err := websocket.JSON.Send(ws, obj); err != nil {
// Client disconnect.
w.watching.Stop()
return
}
}
}
}
示例2: eventString
// eventString marshals the event into a string
func eventString(e *watch.Event) string {
obj, _ := watchjson.Object(v1beta3.Codec, e)
s, _ := json.Marshal(obj)
return string(s)
}
示例3: eventString
// eventString marshals the event into a string
func eventString(e *watch.Event) string {
obj, _ := watchjson.Object(kapi.Codecs.LegacyCodec(v1.SchemeGroupVersion), e)
s, _ := json.Marshal(obj)
return string(s)
}