kubernetes: github.com/erimatnor/kubernetes/pkg/watch/json Index | Files

package json

import "github.com/erimatnor/kubernetes/pkg/watch/json"

Package json implements a simple encoder and decoder for streams of watch events over io.Writer/Readers

Index

Package Files

decoder.go doc.go encoder.go types.go

func Object Uses

func Object(codec runtime.Codec, event *watch.Event) (interface{}, error)

Object converts a watch.Event into an appropriately serializable JSON object

type Decoder Uses

type Decoder struct {
    // contains filtered or unexported fields
}

Decoder implements the watch.Decoder interface for io.ReadClosers that have contents which consist of a series of watchEvent objects encoded via JSON. It will decode any object registered in the supplied codec.

func NewDecoder Uses

func NewDecoder(r io.ReadCloser, codec runtime.Codec) *Decoder

NewDecoder creates an Decoder for the given writer and codec.

func (*Decoder) Close Uses

func (d *Decoder) Close()

Close closes the underlying r.

func (*Decoder) Decode Uses

func (d *Decoder) Decode() (watch.EventType, runtime.Object, error)

Decode blocks until it can return the next object in the writer. Returns an error if the writer is closed or an object can't be decoded.

type Encoder Uses

type Encoder struct {
    // contains filtered or unexported fields
}

Encoder implements the json.Encoder interface for io.Writers that should serialize WatchEvent objects into JSON. It will encode any object registered in the supplied codec and return an error otherwies.

func NewEncoder Uses

func NewEncoder(w io.Writer, codec runtime.Codec) *Encoder

NewEncoder creates an Encoder for the given writer and codec

func (*Encoder) Encode Uses

func (e *Encoder) Encode(event *watch.Event) error

Encode writes an event to the writer. Returns an error if the writer is closed or an object can't be encoded.

type WatchEvent Uses

type WatchEvent struct {
    // The type of the watch event; added, modified, deleted, or error.
    Type watch.EventType `json:"type,omitempty" description:"the type of watch event; may be ADDED, MODIFIED, DELETED, or ERROR"`

    // For added or modified objects, this is the new object; for deleted objects,
    // it's the state of the object immediately prior to its deletion.
    // For errors, it's an api.Status.
    Object runtime.RawExtension `json:"object,omitempty" description:"the object being watched; will match the type of the resource endpoint or be a Status object if the type is ERROR"`
}

WatchEvent objects are streamed from the api server in response to a watch request. These are not API objects and may not be changed in a backward-incompatible way. TODO: move to a public, versioned object now that RawExtension conversions are possible in the schema.

Package json imports 6 packages (graph). Updated 2017-05-11. Refresh now. Tools for package owners.