// protoToKey converts a Reference proto to a *Key. func protoToKey(r *pb.Reference) (k *Key, err error) { appID := proto.GetString(r.App) namespace := proto.GetString(r.NameSpace) for _, e := range r.Path.Element { k = &Key{ kind: proto.GetString(e.Type), stringID: proto.GetString(e.Name), intID: proto.GetInt64(e.Id), parent: k, appID: appID, namespace: namespace, } if !k.valid() { return nil, ErrInvalidKey } } return }
func protoToProperties(dst chan<- Property, errc chan<- error, src *pb.EntityProto) { defer close(dst) props, rawProps := src.Property, src.RawProperty for { var ( x *pb.Property noIndex bool ) if len(props) > 0 { x, props = props[0], props[1:] } else if len(rawProps) > 0 { x, rawProps = rawProps[0], rawProps[1:] noIndex = true } else { break } var value interface{} switch { case x.Value.Int64Value != nil: if x.Meaning != nil && *x.Meaning == pb.Property_GD_WHEN { value = time.Unix(0, *x.Value.Int64Value*1e3) } else { value = *x.Value.Int64Value } case x.Value.BooleanValue != nil: value = *x.Value.BooleanValue case x.Value.StringValue != nil: if x.Meaning != nil && *x.Meaning == pb.Property_BLOB { value = []byte(*x.Value.StringValue) } else if x.Meaning != nil && *x.Meaning == pb.Property_BLOBKEY { value = appengine.BlobKey(*x.Value.StringValue) } else { value = *x.Value.StringValue } case x.Value.DoubleValue != nil: value = *x.Value.DoubleValue case x.Value.Referencevalue != nil: key, err := referenceValueToKey(x.Value.Referencevalue) if err != nil { errc <- err return } value = key } dst <- Property{ Name: proto.GetString(x.Name), Value: value, NoIndex: noIndex, Multiple: proto.GetBool(x.Multiple), } } errc <- nil }
func (t *txn) stat() { if !t.c.raccess { t.respondOsError(syscall.EACCES) return } go func() { g, err := t.getter() if err != nil { t.respondOsError(err) return } len, rev := g.Stat(proto.GetString(t.req.Path)) t.resp.Len = &len t.resp.Rev = &rev t.respond() }() }