protosink

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package protosink provides a cache.Sink using Protobuf encoding

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewProtoSink added in v0.1.0

func NewProtoSink[T any, M ProtoMessage[T]]() cache.TSink[T]

NewProtoSink creates a ProtoSink for a particular proto.Message type

Types

type ProtoMessage added in v0.1.0

type ProtoMessage[T any] interface {
	proto.Message
	*T
}

ProtoMessage is a generic constraint for a type which pointer implements proto.Message

type ProtoSink

type ProtoSink[T any, M ProtoMessage[T]] struct {
	cache.ByteSink
	// contains filtered or unexported fields
}

ProtoSink is a Sink using Proto for encoding

func (*ProtoSink[T, M]) Reset

func (sink *ProtoSink[T, M]) Reset()

Reset clears everything but the type pointer assigned during creation

func (*ProtoSink[T, M]) SetBytes

func (sink *ProtoSink[T, M]) SetBytes(b []byte, e time.Time) error

SetBytes sets the object of the ProtoSink and its expiration time from a Protobuf encoded byte array

func (*ProtoSink[T, M]) SetValue

func (sink *ProtoSink[T, M]) SetValue(v *T, e time.Time) error

SetValue sets the object of the ProtoSink and its expiration time

func (*ProtoSink[T, M]) Value

func (sink *ProtoSink[T, M]) Value() (*T, bool)

Value returns the stored object

Jump to

Keyboard shortcuts

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