protobuf

package
v0.27.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 12 Imported by: 113

Documentation

Overview

Package protobuf provides a Kubernetes serializer for the protobuf format.

Index

Constants

This section is empty.

Variables

View Source
var LengthDelimitedFramer = lengthDelimitedFramer{}

LengthDelimitedFramer is exported variable of type lengthDelimitedFramer

Functions

func IsNotMarshalable

func IsNotMarshalable(err error) bool

IsNotMarshalable checks the type of error, returns a boolean true if error is not nil and not marshalable false otherwise

Types

type RawSerializer

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

RawSerializer encodes and decodes objects without adding a runtime.Unknown wrapper (objects are encoded without identifying type).

func NewRawSerializer

func NewRawSerializer(creater runtime.ObjectCreater, typer runtime.ObjectTyper) *RawSerializer

NewRawSerializer creates a Protobuf serializer that handles encoding versioned objects into the proper wire form. If typer is not nil, the object has the group, version, and kind fields set. This serializer does not provide type information for the encoded object, and thus is not self describing (callers must know what type is being described in order to decode).

This encoding scheme is experimental, and is subject to change at any time.

func (*RawSerializer) Decode

func (s *RawSerializer) Decode(originalData []byte, gvk *schema.GroupVersionKind, into runtime.Object) (runtime.Object, *schema.GroupVersionKind, error)

Decode attempts to convert the provided data into a protobuf message, extract the stored schema kind, apply the provided default gvk, and then load that data into an object matching the desired schema kind or the provided into. If into is *runtime.Unknown, the raw data will be extracted and no decoding will be performed. If into is not registered with the typer, then the object will be straight decoded using normal protobuf unmarshalling (the MarshalTo interface). If into is provided and the original data is not fully qualified with kind/version/group, the type of the into will be used to alter the returned gvk. On success or most errors, the method will return the calculated schema kind.

func (*RawSerializer) Encode

func (s *RawSerializer) Encode(obj runtime.Object, w io.Writer) error

Encode serializes the provided object to the given writer. Overrides is ignored.

func (*RawSerializer) EncodeWithAllocator added in v0.24.0

func (s *RawSerializer) EncodeWithAllocator(obj runtime.Object, w io.Writer, memAlloc runtime.MemoryAllocator) error

EncodeWithAllocator writes an object to the provided writer. In addition, it allows for providing a memory allocator for efficient memory usage during object serialization.

func (*RawSerializer) Identifier added in v0.17.0

func (s *RawSerializer) Identifier() runtime.Identifier

Identifier implements runtime.Encoder interface.

type Serializer

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

Serializer handles encoding versioned objects into the proper wire form

func NewSerializer

func NewSerializer(creater runtime.ObjectCreater, typer runtime.ObjectTyper) *Serializer

NewSerializer creates a Protobuf serializer that handles encoding versioned objects into the proper wire form. If a typer is passed, the encoded object will have group, version, and kind fields set. If typer is nil, the objects will be written as-is (any type info passed with the object will be used).

func (*Serializer) Decode

func (s *Serializer) Decode(originalData []byte, gvk *schema.GroupVersionKind, into runtime.Object) (runtime.Object, *schema.GroupVersionKind, error)

Decode attempts to convert the provided data into a protobuf message, extract the stored schema kind, apply the provided default gvk, and then load that data into an object matching the desired schema kind or the provided into. If into is *runtime.Unknown, the raw data will be extracted and no decoding will be performed. If into is not registered with the typer, then the object will be straight decoded using normal protobuf unmarshalling (the MarshalTo interface). If into is provided and the original data is not fully qualified with kind/version/group, the type of the into will be used to alter the returned gvk. On success or most errors, the method will return the calculated schema kind.

func (*Serializer) Encode

func (s *Serializer) Encode(obj runtime.Object, w io.Writer) error

Encode serializes the provided object to the given writer.

func (*Serializer) EncodeWithAllocator added in v0.24.0

func (s *Serializer) EncodeWithAllocator(obj runtime.Object, w io.Writer, memAlloc runtime.MemoryAllocator) error

EncodeWithAllocator writes an object to the provided writer. In addition, it allows for providing a memory allocator for efficient memory usage during object serialization.

func (*Serializer) Identifier added in v0.17.0

func (s *Serializer) Identifier() runtime.Identifier

Identifier implements runtime.Encoder interface.

func (*Serializer) RecognizesData

func (s *Serializer) RecognizesData(data []byte) (bool, bool, error)

RecognizesData implements the RecognizingDecoder interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL