dsio

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Export

func Export(it *datastore.Iterator, w io.Writer) (err error)

Export exports the given DataStore entity iterator into the given stream.

func Import

func Import(r io.Reader, ds *datastore.Client) (err error)

Import imports DataStore entities from the export file.

func ImportFile added in v0.2.1

func ImportFile(r io.Reader, outCh chan Entity, errCh chan error) (err error)

ImportFile reads an export file, writing DataStore entities to outCh. Closes outCh to signal EOF. Waits until errCh is closed. Returns the first encountered error.

func ImportFileReflect added in v0.6.0

func ImportFileReflect(filename string, modelMap []ModelMapping) error

ImportFileReflect imports a given .ds file using the provided type and import function.

func ImportStreamReflect added in v0.6.0

func ImportStreamReflect(r io.Reader, modelMap []ModelMapping) (err error)

ImportStreamReflect imports a given .ds stream using the provided type and import function mapping

func Marshal

func Marshal(inCh <-chan Entity, outCh chan<- []byte, errCh chan<- error)

Marshal marshals a stream of DataStore entities into a stream of byte arrays.

func MarshalKey

func MarshalKey(key *datastore.Key) string

func OpenForReading added in v1.1.0

func OpenForReading(filename string) (io.ReadCloser, error)

OpenForReading opens a file for reading, seamlessly un-gzipping if needed.

func OpenForWriting added in v1.1.0

func OpenForWriting(filename string) (io.WriteCloser, error)

OpenForWriting opens a file for writing, seamlessly gzipping if needed.

func Unmarshal

func Unmarshal(inCh <-chan []byte, outCh chan<- Entity, errCh chan<- error)

Unmarshal processes export file lines, writing DataStore entities to outCh and any error to errCh. Closes outCh and errCh before returning.

func UnmarshalKey

func UnmarshalKey(s string) (key *datastore.Key)

Types

type Entity

type Entity struct {
	Key        *datastore.Key
	Properties datastore.PropertyList
}

Entity wraps a DataStore entity including its key and all properties as key-value pairs.

type ImportFuncType added in v0.6.0

type ImportFuncType func(kind string, rows []interface{}) error

ImportFuncType is the type of the import callback.

type ModelMapping added in v0.7.0

type ModelMapping struct {
	// DataStore entity kind (type name).
	Kind string
	// TypePtr must be a pointer to a struct of the desired type.
	TypePtr interface{}
	// ImportFunc will be called with a slice of pointers to objects of the given type.
	ImportFunc ImportFuncType
	// BatchSize defines the desired number of elements for a single ImportFunc call.
	BatchSize int
}

ModelMapping wraps a single data model type.

type Reflector added in v0.6.0

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

Reflector implements a caching reflection helper.

func NewReflector added in v0.6.0

func NewReflector(typePtr interface{}) *Reflector

NewReflector returns a new instance of Reflector. Typical use-case flow: r.Reset(), r.Set(), r.Set() ..., r.MakeCopy()

func (*Reflector) MakeCopy added in v0.6.0

func (r *Reflector) MakeCopy() interface{}

MakeCopy returns a pointer to a copy of the reflected object.

func (*Reflector) Reset added in v0.6.0

func (r *Reflector) Reset()

Reset default-initializes the reflected object.

func (*Reflector) Set added in v0.6.0

func (r *Reflector) Set(field string, value interface{})

Set sets a property in the reflected object.

Jump to

Keyboard shortcuts

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