Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove references to deprecated protobuf module #346

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion appengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"context"
"net/http"

"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"

"google.golang.org/appengine/internal"
)
Expand Down
10 changes: 4 additions & 6 deletions blobstore/blobstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ import (
"strings"
"time"

"github.com/golang/protobuf/proto"
"golang.org/x/text/encoding/htmlindex"

"google.golang.org/appengine"
"google.golang.org/appengine/datastore"
"google.golang.org/appengine/internal"
Expand Down Expand Up @@ -100,7 +98,7 @@ func Send(response http.ResponseWriter, blobKey appengine.BlobKey) {
// opts parameter may be nil.
func UploadURL(c context.Context, successPath string, opts *UploadURLOptions) (*url.URL, error) {
req := &blobpb.CreateUploadURLRequest{
SuccessPath: proto.String(successPath),
SuccessPath: successPath,
}
if opts != nil {
if n := opts.MaxUploadBytes; n != 0 {
Expand All @@ -117,7 +115,7 @@ func UploadURL(c context.Context, successPath string, opts *UploadURLOptions) (*
if err := internal.Call(c, "blobstore", "CreateUploadURL", req, res); err != nil {
return nil, err
}
return url.Parse(*res.Url)
return url.Parse(res.Url)
}

// UploadURLOptions are the options to create an upload URL.
Expand Down Expand Up @@ -296,11 +294,11 @@ func NewReader(c context.Context, blobKey appengine.BlobKey) Reader {
// The filename should be of the form "/gs/bucket_name/object_name".
func BlobKeyForFile(c context.Context, filename string) (appengine.BlobKey, error) {
req := &blobpb.CreateEncodedGoogleStorageKeyRequest{
Filename: &filename,
Filename: filename,
}
res := &blobpb.CreateEncodedGoogleStorageKeyResponse{}
if err := internal.Call(c, "blobstore", "CreateEncodedGoogleStorageKey", req, res); err != nil {
return "", err
}
return appengine.BlobKey(*res.BlobKey), nil
return appengine.BlobKey(res.BlobKey), nil
}
6 changes: 3 additions & 3 deletions blobstore/blobstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ func min(x, y int) int {
}

func fakeFetchData(req *pb.FetchDataRequest, res *pb.FetchDataResponse) error {
i0 := int(*req.StartIndex)
i1 := int(*req.EndIndex + 1) // Blobstore's end-indices are inclusive; Go's are exclusive.
bk := *req.BlobKey
i0 := int(req.StartIndex)
i1 := int(req.EndIndex + 1) // Blobstore's end-indices are inclusive; Go's are exclusive.
bk := req.BlobKey
if i := strings.Index(bk, "."); i != -1 {
// Strip everything past the ".".
bk = bk[:i]
Expand Down
8 changes: 3 additions & 5 deletions blobstore/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (
"os"
"sync"

"github.com/golang/protobuf/proto"

"google.golang.org/appengine"
"google.golang.org/appengine/internal"

Expand Down Expand Up @@ -132,9 +130,9 @@ func (r *reader) Seek(offset int64, whence int) (ret int64, err error) {
// the data is saved as r.buf.
func (r *reader) fetch(off int64) error {
req := &blobpb.FetchDataRequest{
BlobKey: proto.String(string(r.blobKey)),
StartIndex: proto.Int64(off),
EndIndex: proto.Int64(off + readBufferSize - 1), // EndIndex is inclusive.
BlobKey: string(r.blobKey),
StartIndex: off,
EndIndex: off + readBufferSize - 1, // EndIndex is inclusive.
}
res := &blobpb.FetchDataResponse{}
if err := internal.Call(r.c, "blobstore", "FetchData", req, res); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion capability/capability.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func Enabled(ctx context.Context, api, capability string) bool {
}

req := &pb.IsEnabledRequest{
Package: &api,
Package: api,
Capability: []string{capability},
}
res := &pb.IsEnabledResponse{}
Expand Down
6 changes: 3 additions & 3 deletions channel/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
// The clientID is an application-provided string used to identify the client.
func Create(c context.Context, clientID string) (token string, err error) {
req := &pb.CreateChannelRequest{
ApplicationKey: &clientID,
ApplicationKey: clientID,
}
resp := &pb.CreateChannelResponse{}
err = internal.Call(c, service, "CreateChannel", req, resp)
Expand All @@ -49,8 +49,8 @@ func Create(c context.Context, clientID string) (token string, err error) {
// Send sends a message on the channel associated with clientID.
func Send(c context.Context, clientID, message string) error {
req := &pb.SendMessageRequest{
ApplicationKey: &clientID,
Message: &message,
ApplicationKey: clientID,
Message: message,
}
resp := &basepb.VoidProto{}
return remapError(internal.Call(c, service, "SendChannelMessage", req, resp))
Expand Down
27 changes: 15 additions & 12 deletions datastore/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"fmt"
"reflect"

"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"

"google.golang.org/appengine"
"google.golang.org/appengine/internal"
Expand Down Expand Up @@ -48,6 +48,9 @@ func (e *ErrFieldMismatch) Error() string {
func protoToKey(r *pb.Reference) (k *Key, err error) {
appID := r.GetApp()
namespace := r.GetNameSpace()
if r.Path == nil {
return nil, fmt.Errorf("path is empty: %w", ErrInvalidKey)
}
for _, e := range r.Path.Element {
k = &Key{
kind: e.GetType(),
Expand All @@ -74,11 +77,11 @@ func keyToProto(defaultAppID string, k *Key) *pb.Reference {
for i := k; i != nil; i = i.parent {
n++
}
e := make([]*pb.Path_Element, n)
e := make([]*pb.Path_ElementType, n)
for i := k; i != nil; i = i.parent {
n--
e[n] = &pb.Path_Element{
Type: &i.kind,
e[n] = &pb.Path_ElementType{
Type: i.kind,
}
// At most one of {Name,Id} should be set.
// Neither will be set for incomplete keys.
Expand All @@ -93,7 +96,7 @@ func keyToProto(defaultAppID string, k *Key) *pb.Reference {
namespace = proto.String(k.namespace)
}
return &pb.Reference{
App: proto.String(appID),
App: appID,
NameSpace: namespace,
Path: &pb.Path{
Element: e,
Expand Down Expand Up @@ -138,10 +141,10 @@ func multiValid(key []*Key) error {

// referenceValueToKey is the same as protoToKey except the input is a
// PropertyValue_ReferenceValue instead of a Reference.
func referenceValueToKey(r *pb.PropertyValue_ReferenceValue) (k *Key, err error) {
func referenceValueToKey(r *pb.PropertyValue_ReferenceValueType) (k *Key, err error) {
appID := r.GetApp()
namespace := r.GetNameSpace()
for _, e := range r.Pathelement {
for _, e := range r.PathElement {
k = &Key{
kind: e.GetType(),
stringID: e.GetName(),
Expand All @@ -159,20 +162,20 @@ func referenceValueToKey(r *pb.PropertyValue_ReferenceValue) (k *Key, err error)

// keyToReferenceValue is the same as keyToProto except the output is a
// PropertyValue_ReferenceValue instead of a Reference.
func keyToReferenceValue(defaultAppID string, k *Key) *pb.PropertyValue_ReferenceValue {
func keyToReferenceValue(defaultAppID string, k *Key) *pb.PropertyValue_ReferenceValueType {
ref := keyToProto(defaultAppID, k)
pe := make([]*pb.PropertyValue_ReferenceValue_PathElement, len(ref.Path.Element))
pe := make([]*pb.PropertyValue_ReferenceValueType_PathElementType, len(ref.Path.Element))
for i, e := range ref.Path.Element {
pe[i] = &pb.PropertyValue_ReferenceValue_PathElement{
pe[i] = &pb.PropertyValue_ReferenceValueType_PathElementType{
Type: e.Type,
Id: e.Id,
Name: e.Name,
}
}
return &pb.PropertyValue_ReferenceValue{
return &pb.PropertyValue_ReferenceValueType{
App: ref.App,
NameSpace: ref.NameSpace,
Pathelement: pe,
PathElement: pe,
}
}

Expand Down
2 changes: 1 addition & 1 deletion datastore/internal/cloudkey/cloudkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"errors"
"strings"

"github.com/golang/protobuf/proto"
cloudpb "google.golang.org/appengine/datastore/internal/cloudpb"
"google.golang.org/protobuf/proto"
)

/////////////////////////////////////////////////////////////////////
Expand Down
Loading