record

package
v0.3.0-beta0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheKey

func CacheKey(storeKey, key string) string

CacheKey returns a cache key string to manage cached entries. concatenates store and record keys separated by a slash.

func ExtractValue

func ExtractValue(p *pb.Property) interface{}

ExtractValue returns the value that is held by the property.

func NewBooleanPropertyProto

func NewBooleanPropertyProto(v bool) *pb.Property

NewBooleanPropertyProto returns a new pb.Property with boolean value v.

func NewIntegerPropertyProto

func NewIntegerPropertyProto(v int64) *pb.Property

NewIntegerPropertyProto returns a new pb.Property with integer value v.

func NewStringPropertyProto

func NewStringPropertyProto(v string) *pb.Property

NewStringPropertyProto returns a new pb.Property with string value v.

Types

type PropertyMap

type PropertyMap map[string]*PropertyValue

PropertyMap represents user-defined custom properties.

func NewPropertyMapFromProto

func NewPropertyMapFromProto(proto map[string]*pb.Property) PropertyMap

NewPropertyMapFromProto creates a new Property instance from a proto. Passing nil returns an empty map.

func (*PropertyMap) Load

func (m *PropertyMap) Load(ps []datastore.Property) error

Load implements the Datastore PropertyLoadSaver interface and converts individual properties to PropertyMap.

func (*PropertyMap) Save

func (m *PropertyMap) Save() ([]datastore.Property, error)

Save implements the Datastore PropertyLoadSaver interface and converts PropertyMap to a slice of datastore Properties.

func (*PropertyMap) ToProto

func (m *PropertyMap) ToProto() map[string]*pb.Property

ToProto converts the struct to a proto.

type PropertyValue

type PropertyValue struct {
	Type         pb.Property_Type
	IntegerValue int64
	StringValue  string
	BooleanValue bool
}

PropertyValue is an internal representation of the user-defined property. See the Open Saves API definition for details.

func NewPropertyValueFromProto

func NewPropertyValueFromProto(proto *pb.Property) *PropertyValue

NewPropertyValueFromProto creates a new Property instance from a proto. Passing nil returns a zero-initialized Property.

func (*PropertyValue) ToProto

func (p *PropertyValue) ToProto() *pb.Property

ToProto converts the struct to a proto.

type Record

type Record struct {
	Key          string `datastore:"-"`
	Blob         []byte `datastore:",noindex"`
	BlobSize     int64
	ExternalBlob uuid.UUID `datastore:"-"`
	Chunked      bool
	ChunkCount   int64
	Properties   PropertyMap
	OwnerID      string
	Tags         []string
	OpaqueString string `datastore:",noindex"`

	// Checksums have checksums for inline blobs.
	// Note that a BlobRef object doesn't exist for inline blobs.
	checksums.Checksums `datastore:",flatten"`

	// Timestamps keeps track of creation and modification times and stores a randomly
	// generated UUID to maintain consistency.
	Timestamps timestamps.Timestamps

	// StoreKey is used to generate a cache key and needs to be set
	// before calling the CacheKey function.
	// It is automatically set when read from Datastore.
	StoreKey string `datastore:"-"`
}

Record represents a Open Saves record in the metadata database. See the Open Saves API definition for details.

func FromProto

func FromProto(storeKey string, p *pb.Record) (*Record, error)

FromProto creates a new Record instance from a proto. Passing nil returns a zero-initialized proto.

func (*Record) CacheKey

func (r *Record) CacheKey() string

CacheKey returns a cache key string to manage cached entries. concatenates store and record keys separated by a slash.

func (*Record) DecodeBytes

func (r *Record) DecodeBytes(by []byte) error

DecodeBytes deserializes the byte slice given by by.

func (*Record) EncodeBytes

func (r *Record) EncodeBytes() ([]byte, error)

EncodeBytes returns a serialized byte slice of the object.

func (*Record) GetInlineBlobMetadata

func (r *Record) GetInlineBlobMetadata() *pb.BlobMetadata

GetInlineBlobMetadata returns a BlobMetadata proto for the inline blob.

func (*Record) GetStoreKey

func (r *Record) GetStoreKey() string

GetStoreKey() returns the parent StoreKey.

func (*Record) Load

func (r *Record) Load(ps []datastore.Property) error

Load implements the Datastore PropertyLoadSaver interface and converts Datastore properties to corresponding struct fields.

func (*Record) LoadKey

func (r *Record) LoadKey(k *datastore.Key) error

LoadKey implements the KeyLoader interface and sets the value to the Key and StoreKey fields.

func (*Record) Save

func (r *Record) Save() ([]datastore.Property, error)

Save implements the Datastore PropertyLoadSaver interface and converts struct fields to Datastore properties.

func (*Record) ToProto

func (r *Record) ToProto() *pb.Record

ToProto converts the struct to a proto.

Jump to

Keyboard shortcuts

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