本文整理匯總了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)
}