record

package
v0.2.0-beta2 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2021 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.

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:"-"`
	Properties   PropertyMap
	OwnerID      string
	Tags         []string
	OpaqueString string `datastore:",noindex"`

	// 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

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) 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