protocodec

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 24, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BackendGetterV2 added in v1.0.1

func BackendGetterV2[C any, T pointerMessage[C]](f func(ctx context.Context, key string) (T, error)) galaxycache.BackendGetter

BackendGetterV2 is an adapter that implements galaxycache.BackendGetter (it wraps an unexported type because type-inference is much better on function-calls)

func GalaxyGet added in v1.0.1

func GalaxyGet[C any, T pointerMessage[C]](ctx context.Context, g *galaxycache.Galaxy, key string) (T, error)

GalaxyGet is a simple wrapper around a Galaxy.Get method-call that takes care of constructing the protocodec.CodecV2, etc. (making the interface more idiomatic for Go)

Types

type CodecV2

type CodecV2[C any, T pointerMessage[C]] struct {
	// contains filtered or unexported fields
}

CodecV2 wraps a google.golang.org/protobuf/proto.Message and implements Codec

func NewV2

func NewV2[C any, T pointerMessage[C]]() CodecV2[C, T]

NewV2 constructs a CodecV2 zero-value. It exists because type-parameter inference is nicer with function-calls than struct-literals

func (*CodecV2[C, T]) Get

func (c *CodecV2[C, T]) Get() T

Get implies returns the internal protobuf message value

func (*CodecV2[C, T]) MarshalBinary

func (c *CodecV2[C, T]) MarshalBinary() ([]byte, error)

MarshalBinary on a ProtoCodec returns the encoded proto message

func (*CodecV2[C, T]) Set

func (c *CodecV2[C, T]) Set(v T)

Set bypasses Marshaling and lets you set the internal protobuf value

func (*CodecV2[C, T]) UnmarshalBinary

func (c *CodecV2[C, T]) UnmarshalBinary(data []byte) error

UnmarshalBinary on a ProtoCodec unmarshals provided data into the proto message

type ProtoCodec

type ProtoCodec struct {
	Msg proto.Message
}

ProtoCodec wraps a proto.Message and implements Codec

func (*ProtoCodec) MarshalBinary

func (c *ProtoCodec) MarshalBinary() ([]byte, error)

MarshalBinary on a ProtoCodec returns the encoded proto message

func (*ProtoCodec) UnmarshalBinary

func (c *ProtoCodec) UnmarshalBinary(data []byte) error

UnmarshalBinary on a ProtoCodec unmarshals provided data into the proto message

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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