Vendor cleanup

Signed-off-by: Madhu Rajanna <mrajanna@redhat.com>
This commit is contained in:
Madhu Rajanna
2019-01-16 18:11:54 +05:30
parent 661818bd79
commit 0f836c62fa
16816 changed files with 20 additions and 4611100 deletions

View File

@ -1,20 +0,0 @@
language: go
go_import_path: google.golang.org/appengine
install:
- ./travis_install.sh
script:
- ./travis_test.sh
matrix:
include:
- go: 1.8.x
env: GOAPP=true
- go: 1.9.x
env: GOAPP=true
- go: 1.10.x
env: GOAPP=false
- go: 1.11.x
env: GO111MODULE=on

View File

@ -1,90 +0,0 @@
# Contributing
1. Sign one of the contributor license agreements below.
1. Get the package:
`go get -d google.golang.org/appengine`
1. Change into the checked out source:
`cd $GOPATH/src/google.golang.org/appengine`
1. Fork the repo.
1. Set your fork as a remote:
`git remote add fork git@github.com:GITHUB_USERNAME/appengine.git`
1. Make changes, commit to your fork.
1. Send a pull request with your changes.
The first line of your commit message is conventionally a one-line summary of the change, prefixed by the primary affected package, and is used as the title of your pull request.
# Testing
## Running system tests
Download and install the [Go App Engine SDK](https://cloud.google.com/appengine/docs/go/download). Make sure the `go_appengine` dir is in your `PATH`.
Set the `APPENGINE_DEV_APPSERVER` environment variable to `/path/to/go_appengine/dev_appserver.py`.
Run tests with `goapp test`:
```
goapp test -v google.golang.org/appengine/...
```
## Contributor License Agreements
Before we can accept your pull requests you'll need to sign a Contributor
License Agreement (CLA):
- **If you are an individual writing original source code** and **you own the
intellectual property**, then you'll need to sign an [individual CLA][indvcla].
- **If you work for a company that wants to allow you to contribute your work**,
then you'll need to sign a [corporate CLA][corpcla].
You can sign these electronically (just scroll to the bottom). After that,
we'll be able to accept your pull requests.
## Contributor Code of Conduct
As contributors and maintainers of this project,
and in the interest of fostering an open and welcoming community,
we pledge to respect all people who contribute through reporting issues,
posting feature requests, updating documentation,
submitting pull requests or patches, and other activities.
We are committed to making participation in this project
a harassment-free experience for everyone,
regardless of level of experience, gender, gender identity and expression,
sexual orientation, disability, personal appearance,
body size, race, ethnicity, age, religion, or nationality.
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery
* Personal attacks
* Trolling or insulting/derogatory comments
* Public or private harassment
* Publishing other's private information,
such as physical or electronic
addresses, without explicit permission
* Other unethical or unprofessional conduct.
Project maintainers have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct.
By adopting this Code of Conduct,
project maintainers commit themselves to fairly and consistently
applying these principles to every aspect of managing this project.
Project maintainers who do not follow or enforce the Code of Conduct
may be permanently removed from the project team.
This code of conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community.
Instances of abusive, harassing, or otherwise unacceptable behavior
may be reported by opening an issue
or contacting one or more of the project maintainers.
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0,
available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
[indvcla]: https://developers.google.com/open-source/cla/individual
[corpcla]: https://developers.google.com/open-source/cla/corporate

View File

@ -1,73 +0,0 @@
# Go App Engine packages
[![Build Status](https://travis-ci.org/golang/appengine.svg)](https://travis-ci.org/golang/appengine)
This repository supports the Go runtime on *App Engine standard*.
It provides APIs for interacting with App Engine services.
Its canonical import path is `google.golang.org/appengine`.
See https://cloud.google.com/appengine/docs/go/
for more information.
File issue reports and feature requests on the [GitHub's issue
tracker](https://github.com/golang/appengine/issues).
## Upgrading an App Engine app to the flexible environment
This package does not work on *App Engine flexible*.
There are many differences between the App Engine standard environment and
the flexible environment.
See the [documentation on upgrading to the flexible environment](https://cloud.google.com/appengine/docs/flexible/go/upgrading).
## Directory structure
The top level directory of this repository is the `appengine` package. It
contains the
basic APIs (e.g. `appengine.NewContext`) that apply across APIs. Specific API
packages are in subdirectories (e.g. `datastore`).
There is an `internal` subdirectory that contains service protocol buffers,
plus packages required for connectivity to make API calls. App Engine apps
should not directly import any package under `internal`.
## Updating from legacy (`import "appengine"`) packages
If you're currently using the bare `appengine` packages
(that is, not these ones, imported via `google.golang.org/appengine`),
then you can use the `aefix` tool to help automate an upgrade to these packages.
Run `go get google.golang.org/appengine/cmd/aefix` to install it.
### 1. Update import paths
The import paths for App Engine packages are now fully qualified, based at `google.golang.org/appengine`.
You will need to update your code to use import paths starting with that; for instance,
code importing `appengine/datastore` will now need to import `google.golang.org/appengine/datastore`.
### 2. Update code using deprecated, removed or modified APIs
Most App Engine services are available with exactly the same API.
A few APIs were cleaned up, and there are some differences:
* `appengine.Context` has been replaced with the `Context` type from `golang.org/x/net/context`.
* Logging methods that were on `appengine.Context` are now functions in `google.golang.org/appengine/log`.
* `appengine.Timeout` has been removed. Use `context.WithTimeout` instead.
* `appengine.Datacenter` now takes a `context.Context` argument.
* `datastore.PropertyLoadSaver` has been simplified to use slices in place of channels.
* `delay.Call` now returns an error.
* `search.FieldLoadSaver` now handles document metadata.
* `urlfetch.Transport` no longer has a Deadline field; set a deadline on the
`context.Context` instead.
* `aetest` no longer declares its own Context type, and uses the standard one instead.
* `taskqueue.QueueStats` no longer takes a maxTasks argument. That argument has been
deprecated and unused for a long time.
* `appengine.BackendHostname` and `appengine.BackendInstance` were for the deprecated backends feature.
Use `appengine.ModuleHostname`and `appengine.ModuleName` instead.
* Most of `appengine/file` and parts of `appengine/blobstore` are deprecated.
Use [Google Cloud Storage](https://godoc.org/cloud.google.com/go/storage) if the
feature you require is not present in the new
[blobstore package](https://google.golang.org/appengine/blobstore).
* `appengine/socket` is not required on App Engine flexible environment / Managed VMs.
Use the standard `net` package instead.

View File

@ -1,42 +0,0 @@
/*
Package aetest provides an API for running dev_appserver for use in tests.
An example test file:
package foo_test
import (
"testing"
"google.golang.org/appengine/memcache"
"google.golang.org/appengine/aetest"
)
func TestFoo(t *testing.T) {
ctx, done, err := aetest.NewContext()
if err != nil {
t.Fatal(err)
}
defer done()
it := &memcache.Item{
Key: "some-key",
Value: []byte("some-value"),
}
err = memcache.Set(ctx, it)
if err != nil {
t.Fatalf("Set err: %v", err)
}
it, err = memcache.Get(ctx, "some-key")
if err != nil {
t.Fatalf("Get err: %v; want no error", err)
}
if g, w := string(it.Value), "some-value" ; g != w {
t.Errorf("retrieved Item.Value = %q, want %q", g, w)
}
}
The environment variable APPENGINE_DEV_APPSERVER specifies the location of the
dev_appserver.py executable to use. If unset, the system PATH is consulted.
*/
package aetest

View File

@ -1,61 +0,0 @@
package aetest
import (
"io"
"net/http"
"time"
"golang.org/x/net/context"
"google.golang.org/appengine"
)
// Instance represents a running instance of the development API Server.
type Instance interface {
// Close kills the child api_server.py process, releasing its resources.
io.Closer
// NewRequest returns an *http.Request associated with this instance.
NewRequest(method, urlStr string, body io.Reader) (*http.Request, error)
}
// Options is used to specify options when creating an Instance.
type Options struct {
// AppID specifies the App ID to use during tests.
// By default, "testapp".
AppID string
// StronglyConsistentDatastore is whether the local datastore should be
// strongly consistent. This will diverge from production behaviour.
StronglyConsistentDatastore bool
// SupportDatastoreEmulator is whether use Cloud Datastore Emulator or
// use old SQLite based Datastore backend or use default settings.
SupportDatastoreEmulator *bool
// SuppressDevAppServerLog is whether the dev_appserver running in tests
// should output logs.
SuppressDevAppServerLog bool
// StartupTimeout is a duration to wait for instance startup.
// By default, 15 seconds.
StartupTimeout time.Duration
}
// NewContext starts an instance of the development API server, and returns
// a context that will route all API calls to that server, as well as a
// closure that must be called when the Context is no longer required.
func NewContext() (context.Context, func(), error) {
inst, err := NewInstance(nil)
if err != nil {
return nil, nil, err
}
req, err := inst.NewRequest("GET", "/", nil)
if err != nil {
inst.Close()
return nil, nil, err
}
ctx := appengine.NewContext(req)
return ctx, func() {
inst.Close()
}, nil
}
// PrepareDevAppserver is a hook which, if set, will be called before the
// dev_appserver.py is started, each time it is started. If aetest.NewContext
// is invoked from the goapp test tool, this hook is unnecessary.
var PrepareDevAppserver func() error

View File

@ -1,21 +0,0 @@
// +build appengine
package aetest
import "appengine/aetest"
// NewInstance launches a running instance of api_server.py which can be used
// for multiple test Contexts that delegate all App Engine API calls to that
// instance.
// If opts is nil the default values are used.
func NewInstance(opts *Options) (Instance, error) {
aetest.PrepareDevAppserver = PrepareDevAppserver
var aeOpts *aetest.Options
if opts != nil {
aeOpts = &aetest.Options{
AppID: opts.AppID,
StronglyConsistentDatastore: opts.StronglyConsistentDatastore,
}
}
return aetest.NewInstance(aeOpts)
}

View File

@ -1,119 +0,0 @@
package aetest
import (
"os"
"testing"
"google.golang.org/appengine"
"google.golang.org/appengine/datastore"
"google.golang.org/appengine/internal"
"google.golang.org/appengine/memcache"
"google.golang.org/appengine/user"
)
func TestBasicAPICalls(t *testing.T) {
// Only run the test if APPENGINE_DEV_APPSERVER is explicitly set.
if os.Getenv("APPENGINE_DEV_APPSERVER") == "" {
t.Skip("APPENGINE_DEV_APPSERVER not set")
}
resetEnv := internal.SetTestEnv()
defer resetEnv()
inst, err := NewInstance(nil)
if err != nil {
t.Fatalf("NewInstance: %v", err)
}
defer inst.Close()
req, err := inst.NewRequest("GET", "http://example.com/page", nil)
if err != nil {
t.Fatalf("NewRequest: %v", err)
}
ctx := appengine.NewContext(req)
it := &memcache.Item{
Key: "some-key",
Value: []byte("some-value"),
}
err = memcache.Set(ctx, it)
if err != nil {
t.Fatalf("Set err: %v", err)
}
it, err = memcache.Get(ctx, "some-key")
if err != nil {
t.Fatalf("Get err: %v; want no error", err)
}
if g, w := string(it.Value), "some-value"; g != w {
t.Errorf("retrieved Item.Value = %q, want %q", g, w)
}
type Entity struct{ Value string }
e := &Entity{Value: "foo"}
k := datastore.NewIncompleteKey(ctx, "Entity", nil)
k, err = datastore.Put(ctx, k, e)
if err != nil {
t.Fatalf("datastore.Put: %v", err)
}
e = new(Entity)
if err := datastore.Get(ctx, k, e); err != nil {
t.Fatalf("datastore.Get: %v", err)
}
if g, w := e.Value, "foo"; g != w {
t.Errorf("retrieved Entity.Value = %q, want %q", g, w)
}
}
func TestContext(t *testing.T) {
// Only run the test if APPENGINE_DEV_APPSERVER is explicitly set.
if os.Getenv("APPENGINE_DEV_APPSERVER") == "" {
t.Skip("APPENGINE_DEV_APPSERVER not set")
}
// Check that the context methods work.
_, done, err := NewContext()
if err != nil {
t.Fatalf("NewContext: %v", err)
}
done()
}
func TestUsers(t *testing.T) {
// Only run the test if APPENGINE_DEV_APPSERVER is explicitly set.
if os.Getenv("APPENGINE_DEV_APPSERVER") == "" {
t.Skip("APPENGINE_DEV_APPSERVER not set")
}
inst, err := NewInstance(nil)
if err != nil {
t.Fatalf("NewInstance: %v", err)
}
defer inst.Close()
req, err := inst.NewRequest("GET", "http://example.com/page", nil)
if err != nil {
t.Fatalf("NewRequest: %v", err)
}
ctx := appengine.NewContext(req)
if user := user.Current(ctx); user != nil {
t.Errorf("user.Current initially %v, want nil", user)
}
u := &user.User{
Email: "gopher@example.com",
Admin: true,
}
Login(u, req)
if got := user.Current(ctx); got.Email != u.Email {
t.Errorf("user.Current: %v, want %v", got, u)
}
if admin := user.IsAdmin(ctx); !admin {
t.Errorf("user.IsAdmin: %t, want true", admin)
}
Logout(req)
if user := user.Current(ctx); user != nil {
t.Errorf("user.Current after logout %v, want nil", user)
}
}

View File

@ -1,287 +0,0 @@
// +build !appengine
package aetest
import (
"bufio"
"crypto/rand"
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"os"
"os/exec"
"path/filepath"
"regexp"
"time"
"golang.org/x/net/context"
"google.golang.org/appengine/internal"
)
// NewInstance launches a running instance of api_server.py which can be used
// for multiple test Contexts that delegate all App Engine API calls to that
// instance.
// If opts is nil the default values are used.
func NewInstance(opts *Options) (Instance, error) {
i := &instance{
opts: opts,
appID: "testapp",
startupTimeout: 15 * time.Second,
}
if opts != nil {
if opts.AppID != "" {
i.appID = opts.AppID
}
if opts.StartupTimeout > 0 {
i.startupTimeout = opts.StartupTimeout
}
}
if err := i.startChild(); err != nil {
return nil, err
}
return i, nil
}
func newSessionID() string {
var buf [16]byte
io.ReadFull(rand.Reader, buf[:])
return fmt.Sprintf("%x", buf[:])
}
// instance implements the Instance interface.
type instance struct {
opts *Options
child *exec.Cmd
apiURL *url.URL // base URL of API HTTP server
adminURL string // base URL of admin HTTP server
appDir string
appID string
startupTimeout time.Duration
relFuncs []func() // funcs to release any associated contexts
}
// NewRequest returns an *http.Request associated with this instance.
func (i *instance) NewRequest(method, urlStr string, body io.Reader) (*http.Request, error) {
req, err := http.NewRequest(method, urlStr, body)
if err != nil {
return nil, err
}
// Associate this request.
req, release := internal.RegisterTestRequest(req, i.apiURL, func(ctx context.Context) context.Context {
ctx = internal.WithAppIDOverride(ctx, "dev~"+i.appID)
return ctx
})
i.relFuncs = append(i.relFuncs, release)
return req, nil
}
// Close kills the child api_server.py process, releasing its resources.
func (i *instance) Close() (err error) {
for _, rel := range i.relFuncs {
rel()
}
i.relFuncs = nil
child := i.child
if child == nil {
return nil
}
defer func() {
i.child = nil
err1 := os.RemoveAll(i.appDir)
if err == nil {
err = err1
}
}()
if p := child.Process; p != nil {
errc := make(chan error, 1)
go func() {
errc <- child.Wait()
}()
// Call the quit handler on the admin server.
res, err := http.Get(i.adminURL + "/quit")
if err != nil {
p.Kill()
return fmt.Errorf("unable to call /quit handler: %v", err)
}
res.Body.Close()
select {
case <-time.After(15 * time.Second):
p.Kill()
return errors.New("timeout killing child process")
case err = <-errc:
// Do nothing.
}
}
return
}
func fileExists(path string) bool {
_, err := os.Stat(path)
return err == nil
}
func findPython() (path string, err error) {
for _, name := range []string{"python2.7", "python"} {
path, err = exec.LookPath(name)
if err == nil {
return
}
}
return
}
func findDevAppserver() (string, error) {
if p := os.Getenv("APPENGINE_DEV_APPSERVER"); p != "" {
if fileExists(p) {
return p, nil
}
return "", fmt.Errorf("invalid APPENGINE_DEV_APPSERVER environment variable; path %q doesn't exist", p)
}
return exec.LookPath("dev_appserver.py")
}
var apiServerAddrRE = regexp.MustCompile(`Starting API server at: (\S+)`)
var adminServerAddrRE = regexp.MustCompile(`Starting admin server at: (\S+)`)
func (i *instance) startChild() (err error) {
if PrepareDevAppserver != nil {
if err := PrepareDevAppserver(); err != nil {
return err
}
}
python, err := findPython()
if err != nil {
return fmt.Errorf("Could not find python interpreter: %v", err)
}
devAppserver, err := findDevAppserver()
if err != nil {
return fmt.Errorf("Could not find dev_appserver.py: %v", err)
}
i.appDir, err = ioutil.TempDir("", "appengine-aetest")
if err != nil {
return err
}
defer func() {
if err != nil {
os.RemoveAll(i.appDir)
}
}()
err = os.Mkdir(filepath.Join(i.appDir, "app"), 0755)
if err != nil {
return err
}
err = ioutil.WriteFile(filepath.Join(i.appDir, "app", "app.yaml"), []byte(i.appYAML()), 0644)
if err != nil {
return err
}
err = ioutil.WriteFile(filepath.Join(i.appDir, "app", "stubapp.go"), []byte(appSource), 0644)
if err != nil {
return err
}
appserverArgs := []string{
devAppserver,
"--port=0",
"--api_port=0",
"--admin_port=0",
"--automatic_restart=false",
"--skip_sdk_update_check=true",
"--clear_datastore=true",
"--clear_search_indexes=true",
"--datastore_path", filepath.Join(i.appDir, "datastore"),
}
if i.opts != nil && i.opts.StronglyConsistentDatastore {
appserverArgs = append(appserverArgs, "--datastore_consistency_policy=consistent")
}
if i.opts != nil && i.opts.SupportDatastoreEmulator != nil {
appserverArgs = append(appserverArgs, fmt.Sprintf("--support_datastore_emulator=%t", *i.opts.SupportDatastoreEmulator))
}
appserverArgs = append(appserverArgs, filepath.Join(i.appDir, "app"))
i.child = exec.Command(python,
appserverArgs...,
)
i.child.Stdout = os.Stdout
var stderr io.Reader
stderr, err = i.child.StderrPipe()
if err != nil {
return err
}
if !(i.opts != nil && i.opts.SuppressDevAppServerLog) {
stderr = io.TeeReader(stderr, os.Stderr)
}
if err = i.child.Start(); err != nil {
return err
}
// Read stderr until we have read the URLs of the API server and admin interface.
errc := make(chan error, 1)
go func() {
s := bufio.NewScanner(stderr)
for s.Scan() {
if match := apiServerAddrRE.FindStringSubmatch(s.Text()); match != nil {
u, err := url.Parse(match[1])
if err != nil {
errc <- fmt.Errorf("failed to parse API URL %q: %v", match[1], err)
return
}
i.apiURL = u
}
if match := adminServerAddrRE.FindStringSubmatch(s.Text()); match != nil {
i.adminURL = match[1]
}
if i.adminURL != "" && i.apiURL != nil {
break
}
}
errc <- s.Err()
}()
select {
case <-time.After(i.startupTimeout):
if p := i.child.Process; p != nil {
p.Kill()
}
return errors.New("timeout starting child process")
case err := <-errc:
if err != nil {
return fmt.Errorf("error reading child process stderr: %v", err)
}
}
if i.adminURL == "" {
return errors.New("unable to find admin server URL")
}
if i.apiURL == nil {
return errors.New("unable to find API server URL")
}
return nil
}
func (i *instance) appYAML() string {
return fmt.Sprintf(appYAMLTemplate, i.appID)
}
const appYAMLTemplate = `
application: %s
version: 1
runtime: go
api_version: go1
handlers:
- url: /.*
script: _go_app
`
const appSource = `
package main
import "google.golang.org/appengine"
func main() { appengine.Main() }
`

View File

@ -1,36 +0,0 @@
package aetest
import (
"hash/crc32"
"net/http"
"strconv"
"google.golang.org/appengine/user"
)
// Login causes the provided Request to act as though issued by the given user.
func Login(u *user.User, req *http.Request) {
req.Header.Set("X-AppEngine-User-Email", u.Email)
id := u.ID
if id == "" {
id = strconv.Itoa(int(crc32.Checksum([]byte(u.Email), crc32.IEEETable)))
}
req.Header.Set("X-AppEngine-User-Id", id)
req.Header.Set("X-AppEngine-User-Federated-Identity", u.Email)
req.Header.Set("X-AppEngine-User-Federated-Provider", u.FederatedProvider)
if u.Admin {
req.Header.Set("X-AppEngine-User-Is-Admin", "1")
} else {
req.Header.Set("X-AppEngine-User-Is-Admin", "0")
}
}
// Logout causes the provided Request to act as though issued by a logged-out
// user.
func Logout(req *http.Request) {
req.Header.Del("X-AppEngine-User-Email")
req.Header.Del("X-AppEngine-User-Id")
req.Header.Del("X-AppEngine-User-Is-Admin")
req.Header.Del("X-AppEngine-User-Federated-Identity")
req.Header.Del("X-AppEngine-User-Federated-Provider")
}

View File

@ -1,137 +0,0 @@
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// Package appengine provides basic functionality for Google App Engine.
//
// For more information on how to write Go apps for Google App Engine, see:
// https://cloud.google.com/appengine/docs/go/
package appengine // import "google.golang.org/appengine"
import (
"net/http"
"github.com/golang/protobuf/proto"
"golang.org/x/net/context"
"google.golang.org/appengine/internal"
)
// The gophers party all night; the rabbits provide the beats.
// Main is the principal entry point for an app running in App Engine.
//
// On App Engine Flexible it installs a trivial health checker if one isn't
// already registered, and starts listening on port 8080 (overridden by the
// $PORT environment variable).
//
// See https://cloud.google.com/appengine/docs/flexible/custom-runtimes#health_check_requests
// for details on how to do your own health checking.
//
// On App Engine Standard it ensures the server has started and is prepared to
// receive requests.
//
// Main never returns.
//
// Main is designed so that the app's main package looks like this:
//
// package main
//
// import (
// "google.golang.org/appengine"
//
// _ "myapp/package0"
// _ "myapp/package1"
// )
//
// func main() {
// appengine.Main()
// }
//
// The "myapp/packageX" packages are expected to register HTTP handlers
// in their init functions.
func Main() {
internal.Main()
}
// IsDevAppServer reports whether the App Engine app is running in the
// development App Server.
func IsDevAppServer() bool {
return internal.IsDevAppServer()
}
// IsStandard reports whether the App Engine app is running in the standard
// environment. This includes both the first generation runtimes (<= Go 1.9)
// and the second generation runtimes (>= Go 1.11).
func IsStandard() bool {
return internal.IsStandard()
}
// IsFlex reports whether the App Engine app is running in the flexible environment.
func IsFlex() bool {
return internal.IsFlex()
}
// IsAppEngine reports whether the App Engine app is running on App Engine, in either
// the standard or flexible environment.
func IsAppEngine() bool {
return internal.IsAppEngine()
}
// IsSecondGen reports whether the App Engine app is running on the second generation
// runtimes (>= Go 1.11).
func IsSecondGen() bool {
return internal.IsSecondGen()
}
// NewContext returns a context for an in-flight HTTP request.
// This function is cheap.
func NewContext(req *http.Request) context.Context {
return internal.ReqContext(req)
}
// WithContext returns a copy of the parent context
// and associates it with an in-flight HTTP request.
// This function is cheap.
func WithContext(parent context.Context, req *http.Request) context.Context {
return internal.WithContext(parent, req)
}
// TODO(dsymonds): Add a Call function here? Otherwise other packages can't access internal.Call.
// BlobKey is a key for a blobstore blob.
//
// Conceptually, this type belongs in the blobstore package, but it lives in
// the appengine package to avoid a circular dependency: blobstore depends on
// datastore, and datastore needs to refer to the BlobKey type.
type BlobKey string
// GeoPoint represents a location as latitude/longitude in degrees.
type GeoPoint struct {
Lat, Lng float64
}
// Valid returns whether a GeoPoint is within [-90, 90] latitude and [-180, 180] longitude.
func (g GeoPoint) Valid() bool {
return -90 <= g.Lat && g.Lat <= 90 && -180 <= g.Lng && g.Lng <= 180
}
// APICallFunc defines a function type for handling an API call.
// See WithCallOverride.
type APICallFunc func(ctx context.Context, service, method string, in, out proto.Message) error
// WithAPICallFunc returns a copy of the parent context
// that will cause API calls to invoke f instead of their normal operation.
//
// This is intended for advanced users only.
func WithAPICallFunc(ctx context.Context, f APICallFunc) context.Context {
return internal.WithCallOverride(ctx, internal.CallOverrideFunc(f))
}
// APICall performs an API call.
//
// This is not intended for general use; it is exported for use in conjunction
// with WithAPICallFunc.
func APICall(ctx context.Context, service, method string, in, out proto.Message) error {
return internal.Call(ctx, service, method, in, out)
}

View File

@ -1,49 +0,0 @@
// Copyright 2014 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package appengine
import (
"testing"
)
func TestValidGeoPoint(t *testing.T) {
testCases := []struct {
desc string
pt GeoPoint
want bool
}{
{
"valid",
GeoPoint{67.21, 13.37},
true,
},
{
"high lat",
GeoPoint{-90.01, 13.37},
false,
},
{
"low lat",
GeoPoint{90.01, 13.37},
false,
},
{
"high lng",
GeoPoint{67.21, 182},
false,
},
{
"low lng",
GeoPoint{67.21, -181},
false,
},
}
for _, tc := range testCases {
if got := tc.pt.Valid(); got != tc.want {
t.Errorf("%s: got %v, want %v", tc.desc, got, tc.want)
}
}
}

View File

@ -1,20 +0,0 @@
// Copyright 2015 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// +build !appengine
package appengine
import (
"golang.org/x/net/context"
"google.golang.org/appengine/internal"
)
// BackgroundContext returns a context not associated with a request.
// This should only be used when not servicing a request.
// This only works in App Engine "flexible environment".
func BackgroundContext() context.Context {
return internal.BackgroundContext()
}

View File

@ -1,306 +0,0 @@
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// Package blobstore provides a client for App Engine's persistent blob
// storage service.
package blobstore // import "google.golang.org/appengine/blobstore"
import (
"bufio"
"bytes"
"encoding/base64"
"fmt"
"io"
"io/ioutil"
"mime"
"mime/multipart"
"net/http"
"net/textproto"
"net/url"
"strconv"
"strings"
"time"
"github.com/golang/protobuf/proto"
"golang.org/x/net/context"
"golang.org/x/text/encoding/htmlindex"
"google.golang.org/appengine"
"google.golang.org/appengine/datastore"
"google.golang.org/appengine/internal"
basepb "google.golang.org/appengine/internal/base"
blobpb "google.golang.org/appengine/internal/blobstore"
)
const (
blobInfoKind = "__BlobInfo__"
blobFileIndexKind = "__BlobFileIndex__"
zeroKey = appengine.BlobKey("")
)
// BlobInfo is the blob metadata that is stored in the datastore.
// Filename may be empty.
type BlobInfo struct {
BlobKey appengine.BlobKey
ContentType string `datastore:"content_type"`
CreationTime time.Time `datastore:"creation"`
Filename string `datastore:"filename"`
Size int64 `datastore:"size"`
MD5 string `datastore:"md5_hash"`
// ObjectName is the Google Cloud Storage name for this blob.
ObjectName string `datastore:"gs_object_name"`
}
// isErrFieldMismatch returns whether err is a datastore.ErrFieldMismatch.
//
// The blobstore stores blob metadata in the datastore. When loading that
// metadata, it may contain fields that we don't care about. datastore.Get will
// return datastore.ErrFieldMismatch in that case, so we ignore that specific
// error.
func isErrFieldMismatch(err error) bool {
_, ok := err.(*datastore.ErrFieldMismatch)
return ok
}
// Stat returns the BlobInfo for a provided blobKey. If no blob was found for
// that key, Stat returns datastore.ErrNoSuchEntity.
func Stat(c context.Context, blobKey appengine.BlobKey) (*BlobInfo, error) {
c, _ = appengine.Namespace(c, "") // Blobstore is always in the empty string namespace
dskey := datastore.NewKey(c, blobInfoKind, string(blobKey), 0, nil)
bi := &BlobInfo{
BlobKey: blobKey,
}
if err := datastore.Get(c, dskey, bi); err != nil && !isErrFieldMismatch(err) {
return nil, err
}
return bi, nil
}
// Send sets the headers on response to instruct App Engine to send a blob as
// the response body. This is more efficient than reading and writing it out
// manually and isn't subject to normal response size limits.
func Send(response http.ResponseWriter, blobKey appengine.BlobKey) {
hdr := response.Header()
hdr.Set("X-AppEngine-BlobKey", string(blobKey))
if hdr.Get("Content-Type") == "" {
// This value is known to dev_appserver to mean automatic.
// In production this is remapped to the empty value which
// means automatic.
hdr.Set("Content-Type", "application/vnd.google.appengine.auto")
}
}
// UploadURL creates an upload URL for the form that the user will
// fill out, passing the application path to load when the POST of the
// form is completed. These URLs expire and should not be reused. The
// opts parameter may be nil.
func UploadURL(c context.Context, successPath string, opts *UploadURLOptions) (*url.URL, error) {
req := &blobpb.CreateUploadURLRequest{
SuccessPath: proto.String(successPath),
}
if opts != nil {
if n := opts.MaxUploadBytes; n != 0 {
req.MaxUploadSizeBytes = &n
}
if n := opts.MaxUploadBytesPerBlob; n != 0 {
req.MaxUploadSizePerBlobBytes = &n
}
if s := opts.StorageBucket; s != "" {
req.GsBucketName = &s
}
}
res := &blobpb.CreateUploadURLResponse{}
if err := internal.Call(c, "blobstore", "CreateUploadURL", req, res); err != nil {
return nil, err
}
return url.Parse(*res.Url)
}
// UploadURLOptions are the options to create an upload URL.
type UploadURLOptions struct {
MaxUploadBytes int64 // optional
MaxUploadBytesPerBlob int64 // optional
// StorageBucket specifies the Google Cloud Storage bucket in which
// to store the blob.
// This is required if you use Cloud Storage instead of Blobstore.
// Your application must have permission to write to the bucket.
// You may optionally specify a bucket name and path in the format
// "bucket_name/path", in which case the included path will be the
// prefix of the uploaded object's name.
StorageBucket string
}
// Delete deletes a blob.
func Delete(c context.Context, blobKey appengine.BlobKey) error {
return DeleteMulti(c, []appengine.BlobKey{blobKey})
}
// DeleteMulti deletes multiple blobs.
func DeleteMulti(c context.Context, blobKey []appengine.BlobKey) error {
s := make([]string, len(blobKey))
for i, b := range blobKey {
s[i] = string(b)
}
req := &blobpb.DeleteBlobRequest{
BlobKey: s,
}
res := &basepb.VoidProto{}
if err := internal.Call(c, "blobstore", "DeleteBlob", req, res); err != nil {
return err
}
return nil
}
func errorf(format string, args ...interface{}) error {
return fmt.Errorf("blobstore: "+format, args...)
}
// ParseUpload parses the synthetic POST request that your app gets from
// App Engine after a user's successful upload of blobs. Given the request,
// ParseUpload returns a map of the blobs received (keyed by HTML form
// element name) and other non-blob POST parameters.
func ParseUpload(req *http.Request) (blobs map[string][]*BlobInfo, other url.Values, err error) {
_, params, err := mime.ParseMediaType(req.Header.Get("Content-Type"))
if err != nil {
return nil, nil, err
}
boundary := params["boundary"]
if boundary == "" {
return nil, nil, errorf("did not find MIME multipart boundary")
}
blobs = make(map[string][]*BlobInfo)
other = make(url.Values)
mreader := multipart.NewReader(io.MultiReader(req.Body, strings.NewReader("\r\n\r\n")), boundary)
for {
part, perr := mreader.NextPart()
if perr == io.EOF {
break
}
if perr != nil {
return nil, nil, errorf("error reading next mime part with boundary %q (len=%d): %v",
boundary, len(boundary), perr)
}
bi := &BlobInfo{}
ctype, params, err := mime.ParseMediaType(part.Header.Get("Content-Disposition"))
if err != nil {
return nil, nil, err
}
bi.Filename = params["filename"]
formKey := params["name"]
ctype, params, err = mime.ParseMediaType(part.Header.Get("Content-Type"))
if err != nil {
return nil, nil, err
}
bi.BlobKey = appengine.BlobKey(params["blob-key"])
charset := params["charset"]
if ctype != "message/external-body" || bi.BlobKey == "" {
if formKey != "" {
slurp, serr := ioutil.ReadAll(part)
if serr != nil {
return nil, nil, errorf("error reading %q MIME part", formKey)
}
// Handle base64 content transfer encoding. multipart.Part transparently
// handles quoted-printable, and no special handling is required for
// 7bit, 8bit, or binary.
ctype, params, err = mime.ParseMediaType(part.Header.Get("Content-Transfer-Encoding"))
if err == nil && ctype == "base64" {
slurp, serr = ioutil.ReadAll(base64.NewDecoder(
base64.StdEncoding, bytes.NewReader(slurp)))
if serr != nil {
return nil, nil, errorf("error %s decoding %q MIME part", ctype, formKey)
}
}
// Handle charset
if charset != "" {
encoding, err := htmlindex.Get(charset)
if err != nil {
return nil, nil, errorf("error getting decoder for charset %q", charset)
}
slurp, err = encoding.NewDecoder().Bytes(slurp)
if err != nil {
return nil, nil, errorf("error decoding from charset %q", charset)
}
}
other[formKey] = append(other[formKey], string(slurp))
}
continue
}
// App Engine sends a MIME header as the body of each MIME part.
tp := textproto.NewReader(bufio.NewReader(part))
header, mimeerr := tp.ReadMIMEHeader()
if mimeerr != nil {
return nil, nil, mimeerr
}
bi.Size, err = strconv.ParseInt(header.Get("Content-Length"), 10, 64)
if err != nil {
return nil, nil, err
}
bi.ContentType = header.Get("Content-Type")
// Parse the time from the MIME header like:
// X-AppEngine-Upload-Creation: 2011-03-15 21:38:34.712136
createDate := header.Get("X-AppEngine-Upload-Creation")
if createDate == "" {
return nil, nil, errorf("expected to find an X-AppEngine-Upload-Creation header")
}
bi.CreationTime, err = time.Parse("2006-01-02 15:04:05.000000", createDate)
if err != nil {
return nil, nil, errorf("error parsing X-AppEngine-Upload-Creation: %s", err)
}
if hdr := header.Get("Content-MD5"); hdr != "" {
md5, err := base64.URLEncoding.DecodeString(hdr)
if err != nil {
return nil, nil, errorf("bad Content-MD5 %q: %v", hdr, err)
}
bi.MD5 = string(md5)
}
// If the GCS object name was provided, record it.
bi.ObjectName = header.Get("X-AppEngine-Cloud-Storage-Object")
blobs[formKey] = append(blobs[formKey], bi)
}
return
}
// Reader is a blob reader.
type Reader interface {
io.Reader
io.ReaderAt
io.Seeker
}
// NewReader returns a reader for a blob. It always succeeds; if the blob does
// not exist then an error will be reported upon first read.
func NewReader(c context.Context, blobKey appengine.BlobKey) Reader {
return openBlob(c, blobKey)
}
// BlobKeyForFile returns a BlobKey for a Google Storage file.
// 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,
}
res := &blobpb.CreateEncodedGoogleStorageKeyResponse{}
if err := internal.Call(c, "blobstore", "CreateEncodedGoogleStorageKey", req, res); err != nil {
return "", err
}
return appengine.BlobKey(*res.BlobKey), nil
}

View File

@ -1,289 +0,0 @@
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package blobstore
import (
"bytes"
"encoding/base64"
"fmt"
"io"
"mime/multipart"
"mime/quotedprintable"
"net/http"
"net/textproto"
"os"
"strconv"
"strings"
"testing"
"golang.org/x/text/encoding/htmlindex"
"google.golang.org/appengine"
"google.golang.org/appengine/internal/aetesting"
pb "google.golang.org/appengine/internal/blobstore"
)
const rbs = readBufferSize
const charsetUTF8 = "utf-8"
const charsetISO2022JP = "iso-2022-jp"
const nonASCIIStr = "Hello, 世界"
func min(x, y int) int {
if x < y {
return x
}
return y
}
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
if i := strings.Index(bk, "."); i != -1 {
// Strip everything past the ".".
bk = bk[:i]
}
switch bk {
case "a14p":
const s = "abcdefghijklmnop"
i0 := min(len(s), i0)
i1 := min(len(s), i1)
res.Data = []byte(s[i0:i1])
case "longBlob":
res.Data = make([]byte, i1-i0)
for i := range res.Data {
res.Data[i] = 'A' + uint8(i0/rbs)
i0++
}
}
return nil
}
// step is one step of a readerTest.
// It consists of a Reader method to call, the method arguments
// (lenp, offset, whence) and the expected results.
type step struct {
method string
lenp int
offset int64
whence int
want string
wantErr error
}
var readerTest = []struct {
blobKey string
step []step
}{
{"noSuchBlobKey", []step{
{"Read", 8, 0, 0, "", io.EOF},
}},
{"a14p.0", []step{
// Test basic reads.
{"Read", 1, 0, 0, "a", nil},
{"Read", 3, 0, 0, "bcd", nil},
{"Read", 1, 0, 0, "e", nil},
{"Read", 2, 0, 0, "fg", nil},
// Test Seek.
{"Seek", 0, 2, os.SEEK_SET, "2", nil},
{"Read", 5, 0, 0, "cdefg", nil},
{"Seek", 0, 2, os.SEEK_CUR, "9", nil},
{"Read", 1, 0, 0, "j", nil},
// Test reads up to and past EOF.
{"Read", 5, 0, 0, "klmno", nil},
{"Read", 5, 0, 0, "p", nil},
{"Read", 5, 0, 0, "", io.EOF},
// Test ReadAt.
{"ReadAt", 4, 0, 0, "abcd", nil},
{"ReadAt", 4, 3, 0, "defg", nil},
{"ReadAt", 4, 12, 0, "mnop", nil},
{"ReadAt", 4, 13, 0, "nop", io.EOF},
{"ReadAt", 4, 99, 0, "", io.EOF},
}},
{"a14p.1", []step{
// Test Seek before any reads.
{"Seek", 0, 2, os.SEEK_SET, "2", nil},
{"Read", 1, 0, 0, "c", nil},
// Test that ReadAt doesn't affect the Read offset.
{"ReadAt", 3, 9, 0, "jkl", nil},
{"Read", 3, 0, 0, "def", nil},
}},
{"a14p.2", []step{
// Test ReadAt before any reads or seeks.
{"ReadAt", 2, 14, 0, "op", nil},
}},
{"longBlob.0", []step{
// Test basic read.
{"Read", 1, 0, 0, "A", nil},
// Test that Read returns early when the buffer is exhausted.
{"Seek", 0, rbs - 2, os.SEEK_SET, strconv.Itoa(rbs - 2), nil},
{"Read", 5, 0, 0, "AA", nil},
{"Read", 3, 0, 0, "BBB", nil},
// Test that what we just read is still in the buffer.
{"Seek", 0, rbs - 2, os.SEEK_SET, strconv.Itoa(rbs - 2), nil},
{"Read", 5, 0, 0, "AABBB", nil},
// Test ReadAt.
{"ReadAt", 3, rbs - 4, 0, "AAA", nil},
{"ReadAt", 6, rbs - 4, 0, "AAAABB", nil},
{"ReadAt", 8, rbs - 4, 0, "AAAABBBB", nil},
{"ReadAt", 5, rbs - 4, 0, "AAAAB", nil},
{"ReadAt", 2, rbs - 4, 0, "AA", nil},
// Test seeking backwards from the Read offset.
{"Seek", 0, 2*rbs - 8, os.SEEK_SET, strconv.Itoa(2*rbs - 8), nil},
{"Read", 1, 0, 0, "B", nil},
{"Read", 1, 0, 0, "B", nil},
{"Read", 1, 0, 0, "B", nil},
{"Read", 1, 0, 0, "B", nil},
{"Read", 8, 0, 0, "BBBBCCCC", nil},
}},
{"longBlob.1", []step{
// Test ReadAt with a slice larger than the buffer size.
{"LargeReadAt", 2*rbs - 2, 0, 0, strconv.Itoa(2*rbs - 2), nil},
{"LargeReadAt", 2*rbs - 1, 0, 0, strconv.Itoa(2*rbs - 1), nil},
{"LargeReadAt", 2*rbs + 0, 0, 0, strconv.Itoa(2*rbs + 0), nil},
{"LargeReadAt", 2*rbs + 1, 0, 0, strconv.Itoa(2*rbs + 1), nil},
{"LargeReadAt", 2*rbs + 2, 0, 0, strconv.Itoa(2*rbs + 2), nil},
{"LargeReadAt", 2*rbs - 2, 1, 0, strconv.Itoa(2*rbs - 2), nil},
{"LargeReadAt", 2*rbs - 1, 1, 0, strconv.Itoa(2*rbs - 1), nil},
{"LargeReadAt", 2*rbs + 0, 1, 0, strconv.Itoa(2*rbs + 0), nil},
{"LargeReadAt", 2*rbs + 1, 1, 0, strconv.Itoa(2*rbs + 1), nil},
{"LargeReadAt", 2*rbs + 2, 1, 0, strconv.Itoa(2*rbs + 2), nil},
}},
}
func TestReader(t *testing.T) {
for _, rt := range readerTest {
c := aetesting.FakeSingleContext(t, "blobstore", "FetchData", fakeFetchData)
r := NewReader(c, appengine.BlobKey(rt.blobKey))
for i, step := range rt.step {
var (
got string
gotErr error
n int
offset int64
)
switch step.method {
case "LargeReadAt":
p := make([]byte, step.lenp)
n, gotErr = r.ReadAt(p, step.offset)
got = strconv.Itoa(n)
case "Read":
p := make([]byte, step.lenp)
n, gotErr = r.Read(p)
got = string(p[:n])
case "ReadAt":
p := make([]byte, step.lenp)
n, gotErr = r.ReadAt(p, step.offset)
got = string(p[:n])
case "Seek":
offset, gotErr = r.Seek(step.offset, step.whence)
got = strconv.FormatInt(offset, 10)
default:
t.Fatalf("unknown method: %s", step.method)
}
if gotErr != step.wantErr {
t.Fatalf("%s step %d: got error %v want %v", rt.blobKey, i, gotErr, step.wantErr)
}
if got != step.want {
t.Fatalf("%s step %d: got %q want %q", rt.blobKey, i, got, step.want)
}
}
}
}
// doPlainTextParseUploadTest tests ParseUpload's decoding of non-file form fields.
// It ensures that MIME multipart parts with Content-Type not equal to
// "message/external-body" (i.e. form fields that are not file uploads) are decoded
// correctly according to the value of their Content-Transfer-Encoding header field.
// If charset is not the empty string it will be set in the request's Content-Type
// header field, and if encoding is not the empty string then the Content-Transfer-Encoding
// header field will be set.
func doPlainTextParseUploadTest(t *testing.T, charset string, encoding string,
rawContent string, encodedContent string) {
bodyBuf := &bytes.Buffer{}
w := multipart.NewWriter(bodyBuf)
fieldName := "foo"
hdr := textproto.MIMEHeader{}
hdr.Set("Content-Disposition", fmt.Sprintf("form-data; name=%q", fieldName))
if charset != "" {
hdr.Set("Content-Type", fmt.Sprintf("text/plain; charset=%q", charset))
} else {
hdr.Set("Content-Type", "text/plain")
}
if encoding != "" {
hdr.Set("Content-Transfer-Encoding", encoding)
}
pw, err := w.CreatePart(hdr)
if err != nil {
t.Fatalf("error creating part: %v", err)
}
pw.Write([]byte(encodedContent))
if err := w.Close(); err != nil {
t.Fatalf("error closing multipart writer: %v\n", err)
}
req, err := http.NewRequest("POST", "/upload", bodyBuf)
if err != nil {
t.Fatalf("error creating request: %v", err)
}
req.Header.Set("Content-Type", w.FormDataContentType())
_, other, err := ParseUpload(req)
if err != nil {
t.Fatalf("error parsing upload: %v", err)
}
if other[fieldName][0] != rawContent {
t.Errorf("got %q expected %q", other[fieldName][0], rawContent)
}
}
func TestParseUploadUTF8Base64Encoding(t *testing.T) {
encoded := base64.StdEncoding.EncodeToString([]byte(nonASCIIStr))
doPlainTextParseUploadTest(t, charsetUTF8, "base64", nonASCIIStr, encoded)
}
func TestParseUploadUTF8Base64EncodingMultiline(t *testing.T) {
testStr := "words words words words words words words words words words words words"
encoded := "d29yZHMgd29yZHMgd29yZHMgd29yZHMgd29yZHMgd29yZHMgd29yZHMgd29yZHMgd29yZHMgd29y\r\nZHMgd29yZHMgd29yZHM="
doPlainTextParseUploadTest(t, charsetUTF8, "base64", testStr, encoded)
}
func TestParseUploadUTF8QuotedPrintableEncoding(t *testing.T) {
var encoded bytes.Buffer
writer := quotedprintable.NewWriter(&encoded)
writer.Write([]byte(nonASCIIStr))
writer.Close()
doPlainTextParseUploadTest(t, charsetUTF8, "quoted-printable", nonASCIIStr,
encoded.String())
}
func TestParseUploadISO2022JPBase64Encoding(t *testing.T) {
testStr := "こんにちは"
encoding, err := htmlindex.Get(charsetISO2022JP)
if err != nil {
t.Fatalf("error getting encoding: %v", err)
}
charsetEncoded, err := encoding.NewEncoder().String(testStr)
if err != nil {
t.Fatalf("error encoding string: %v", err)
}
base64Encoded := base64.StdEncoding.EncodeToString([]byte(charsetEncoded))
doPlainTextParseUploadTest(t, charsetISO2022JP, "base64", testStr, base64Encoded)
}
func TestParseUploadNoEncoding(t *testing.T) {
doPlainTextParseUploadTest(t, "", "", "Hello", "Hello")
}

View File

@ -1,160 +0,0 @@
// Copyright 2012 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package blobstore
import (
"errors"
"fmt"
"io"
"os"
"sync"
"github.com/golang/protobuf/proto"
"golang.org/x/net/context"
"google.golang.org/appengine"
"google.golang.org/appengine/internal"
blobpb "google.golang.org/appengine/internal/blobstore"
)
// openBlob returns a reader for a blob. It always succeeds; if the blob does
// not exist then an error will be reported upon first read.
func openBlob(c context.Context, blobKey appengine.BlobKey) Reader {
return &reader{
c: c,
blobKey: blobKey,
}
}
const readBufferSize = 256 * 1024
// reader is a blob reader. It implements the Reader interface.
type reader struct {
c context.Context
// Either blobKey or filename is set:
blobKey appengine.BlobKey
filename string
closeFunc func() // is nil if unavailable or already closed.
// buf is the read buffer. r is how much of buf has been read.
// off is the offset of buf[0] relative to the start of the blob.
// An invariant is 0 <= r && r <= len(buf).
// Reads that don't require an RPC call will increment r but not off.
// Seeks may modify r without discarding the buffer, but only if the
// invariant can be maintained.
mu sync.Mutex
buf []byte
r int
off int64
}
func (r *reader) Close() error {
if f := r.closeFunc; f != nil {
f()
}
r.closeFunc = nil
return nil
}
func (r *reader) Read(p []byte) (int, error) {
if len(p) == 0 {
return 0, nil
}
r.mu.Lock()
defer r.mu.Unlock()
if r.r == len(r.buf) {
if err := r.fetch(r.off + int64(r.r)); err != nil {
return 0, err
}
}
n := copy(p, r.buf[r.r:])
r.r += n
return n, nil
}
func (r *reader) ReadAt(p []byte, off int64) (int, error) {
if len(p) == 0 {
return 0, nil
}
r.mu.Lock()
defer r.mu.Unlock()
// Convert relative offsets to absolute offsets.
ab0 := r.off + int64(r.r)
ab1 := r.off + int64(len(r.buf))
ap0 := off
ap1 := off + int64(len(p))
// Check if we can satisfy the read entirely out of the existing buffer.
if r.off <= ap0 && ap1 <= ab1 {
// Convert off from an absolute offset to a relative offset.
rp0 := int(ap0 - r.off)
return copy(p, r.buf[rp0:]), nil
}
// Restore the original Read/Seek offset after ReadAt completes.
defer r.seek(ab0)
// Repeatedly fetch and copy until we have filled p.
n := 0
for len(p) > 0 {
if err := r.fetch(off + int64(n)); err != nil {
return n, err
}
r.r = copy(p, r.buf)
n += r.r
p = p[r.r:]
}
return n, nil
}
func (r *reader) Seek(offset int64, whence int) (ret int64, err error) {
r.mu.Lock()
defer r.mu.Unlock()
switch whence {
case os.SEEK_SET:
ret = offset
case os.SEEK_CUR:
ret = r.off + int64(r.r) + offset
case os.SEEK_END:
return 0, errors.New("seeking relative to the end of a blob isn't supported")
default:
return 0, fmt.Errorf("invalid Seek whence value: %d", whence)
}
if ret < 0 {
return 0, errors.New("negative Seek offset")
}
return r.seek(ret)
}
// fetch fetches readBufferSize bytes starting at the given offset. On success,
// 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.
}
res := &blobpb.FetchDataResponse{}
if err := internal.Call(r.c, "blobstore", "FetchData", req, res); err != nil {
return err
}
if len(res.Data) == 0 {
return io.EOF
}
r.buf, r.r, r.off = res.Data, 0, off
return nil
}
// seek seeks to the given offset with an effective whence equal to SEEK_SET.
// It discards the read buffer if the invariant cannot be maintained.
func (r *reader) seek(off int64) (int64, error) {
delta := off - r.off
if delta >= 0 && delta < int64(len(r.buf)) {
r.r = int(delta)
return off, nil
}
r.buf, r.r, r.off = nil, 0, off
return off, nil
}

View File

@ -1,52 +0,0 @@
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
/*
Package capability exposes information about outages and scheduled downtime
for specific API capabilities.
This package does not work in App Engine "flexible environment".
Example:
if !capability.Enabled(c, "datastore_v3", "write") {
// show user a different page
}
*/
package capability // import "google.golang.org/appengine/capability"
import (
"golang.org/x/net/context"
"google.golang.org/appengine/internal"
"google.golang.org/appengine/log"
pb "google.golang.org/appengine/internal/capability"
)
// Enabled returns whether an API's capabilities are enabled.
// The wildcard "*" capability matches every capability of an API.
// If the underlying RPC fails (if the package is unknown, for example),
// false is returned and information is written to the application log.
func Enabled(ctx context.Context, api, capability string) bool {
req := &pb.IsEnabledRequest{
Package: &api,
Capability: []string{capability},
}
res := &pb.IsEnabledResponse{}
if err := internal.Call(ctx, "capability_service", "IsEnabled", req, res); err != nil {
log.Warningf(ctx, "capability.Enabled: RPC failed: %v", err)
return false
}
switch *res.SummaryStatus {
case pb.IsEnabledResponse_ENABLED,
pb.IsEnabledResponse_SCHEDULED_FUTURE,
pb.IsEnabledResponse_SCHEDULED_NOW:
return true
case pb.IsEnabledResponse_UNKNOWN:
log.Errorf(ctx, "capability.Enabled: unknown API capability %s/%s", api, capability)
return false
default:
return false
}
}

View File

@ -1,87 +0,0 @@
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
/*
Package channel implements the server side of App Engine's Channel API.
Create creates a new channel associated with the given clientID,
which must be unique to the client that will use the returned token.
token, err := channel.Create(c, "player1")
if err != nil {
// handle error
}
// return token to the client in an HTTP response
Send sends a message to the client over the channel identified by clientID.
channel.Send(c, "player1", "Game over!")
Deprecated: The Channel API feature has been deprecated and is going to be removed. See the Channel API Turndown document for details and timetable.
https://cloud.google.com/appengine/docs/deprecations/channel
*/
package channel // import "google.golang.org/appengine/channel"
import (
"encoding/json"
"golang.org/x/net/context"
"google.golang.org/appengine"
"google.golang.org/appengine/internal"
basepb "google.golang.org/appengine/internal/base"
pb "google.golang.org/appengine/internal/channel"
)
// Create creates a channel and returns a token for use by the client.
// 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,
}
resp := &pb.CreateChannelResponse{}
err = internal.Call(c, service, "CreateChannel", req, resp)
token = resp.GetToken()
return token, remapError(err)
}
// 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,
}
resp := &basepb.VoidProto{}
return remapError(internal.Call(c, service, "SendChannelMessage", req, resp))
}
// SendJSON is a helper function that sends a JSON-encoded value
// on the channel associated with clientID.
func SendJSON(c context.Context, clientID string, value interface{}) error {
m, err := json.Marshal(value)
if err != nil {
return err
}
return Send(c, clientID, string(m))
}
// remapError fixes any APIError referencing "xmpp" into one referencing "channel".
func remapError(err error) error {
if e, ok := err.(*internal.APIError); ok {
if e.Service == "xmpp" {
e.Service = "channel"
}
}
return err
}
var service = "xmpp" // prod
func init() {
if appengine.IsDevAppServer() {
service = "channel" // dev
}
internal.RegisterErrorCodeMap("channel", pb.ChannelServiceError_ErrorCode_name)
}

View File

@ -1,21 +0,0 @@
// Copyright 2015 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package channel
import (
"testing"
"google.golang.org/appengine/internal"
)
func TestRemapError(t *testing.T) {
err := &internal.APIError{
Service: "xmpp",
}
err = remapError(err).(*internal.APIError)
if err.Service != "channel" {
t.Errorf("err.Service = %q, want %q", err.Service, "channel")
}
}

View File

@ -1,62 +0,0 @@
// Copyright 2013 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
/*
Package cloudsql exposes access to Google Cloud SQL databases.
This package does not work in App Engine "flexible environment".
This package is intended for MySQL drivers to make App Engine-specific
connections. Applications should use this package through database/sql:
Select a pure Go MySQL driver that supports this package, and use sql.Open
with protocol "cloudsql" and an address of the Cloud SQL instance.
A Go MySQL driver that has been tested to work well with Cloud SQL
is the go-sql-driver:
import "database/sql"
import _ "github.com/go-sql-driver/mysql"
db, err := sql.Open("mysql", "user@cloudsql(project-id:instance-name)/dbname")
Another driver that works well with Cloud SQL is the mymysql driver:
import "database/sql"
import _ "github.com/ziutek/mymysql/godrv"
db, err := sql.Open("mymysql", "cloudsql:instance-name*dbname/user/password")
Using either of these drivers, you can perform a standard SQL query.
This example assumes there is a table named 'users' with
columns 'first_name' and 'last_name':
rows, err := db.Query("SELECT first_name, last_name FROM users")
if err != nil {
log.Errorf(ctx, "db.Query: %v", err)
}
defer rows.Close()
for rows.Next() {
var firstName string
var lastName string
if err := rows.Scan(&firstName, &lastName); err != nil {
log.Errorf(ctx, "rows.Scan: %v", err)
continue
}
log.Infof(ctx, "First: %v - Last: %v", firstName, lastName)
}
if err := rows.Err(); err != nil {
log.Errorf(ctx, "Row error: %v", err)
}
*/
package cloudsql
import (
"net"
)
// Dial connects to the named Cloud SQL instance.
func Dial(instance string) (net.Conn, error) {
return connect(instance)
}

View File

@ -1,17 +0,0 @@
// Copyright 2013 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// +build appengine
package cloudsql
import (
"net"
"appengine/cloudsql"
)
func connect(instance string) (net.Conn, error) {
return cloudsql.Dial(instance)
}

View File

@ -1,16 +0,0 @@
// Copyright 2013 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// +build !appengine
package cloudsql
import (
"errors"
"net"
)
func connect(instance string) (net.Conn, error) {
return nil, errors.New(`cloudsql: not supported in App Engine "flexible environment"`)
}

View File

@ -1,342 +0,0 @@
// Copyright 2015 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// Program aebundler turns a Go app into a fully self-contained tar file.
// The app and its subdirectories (if any) are placed under "."
// and the dependencies from $GOPATH are placed under ./_gopath/src.
// A main func is synthesized if one does not exist.
//
// A sample Dockerfile to be used with this bundler could look like this:
// FROM gcr.io/google-appengine/go-compat
// ADD . /app
// RUN GOPATH=/app/_gopath go build -tags appenginevm -o /app/_ah/exe
package main
import (
"archive/tar"
"flag"
"fmt"
"go/ast"
"go/build"
"go/parser"
"go/token"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
)
var (
output = flag.String("o", "", "name of output tar file or '-' for stdout")
rootDir = flag.String("root", ".", "directory name of application root")
vm = flag.Bool("vm", true, `bundle an app for App Engine "flexible environment"`)
skipFiles = map[string]bool{
".git": true,
".gitconfig": true,
".hg": true,
".travis.yml": true,
}
)
const (
newMain = `package main
import "google.golang.org/appengine"
func main() {
appengine.Main()
}
`
)
func usage() {
fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
fmt.Fprintf(os.Stderr, "\t%s -o <file.tar|->\tBundle app to named tar file or stdout\n", os.Args[0])
fmt.Fprintf(os.Stderr, "\noptional arguments:\n")
flag.PrintDefaults()
}
func main() {
flag.Usage = usage
flag.Parse()
var tags []string
if *vm {
tags = append(tags, "appenginevm")
} else {
tags = append(tags, "appengine")
}
tarFile := *output
if tarFile == "" {
usage()
errorf("Required -o flag not specified.")
}
app, err := analyze(tags)
if err != nil {
errorf("Error analyzing app: %v", err)
}
if err := app.bundle(tarFile); err != nil {
errorf("Unable to bundle app: %v", err)
}
}
// errorf prints the error message and exits.
func errorf(format string, a ...interface{}) {
fmt.Fprintf(os.Stderr, "aebundler: "+format+"\n", a...)
os.Exit(1)
}
type app struct {
hasMain bool
appFiles []string
imports map[string]string
}
// analyze checks the app for building with the given build tags and returns hasMain,
// app files, and a map of full directory import names to original import names.
func analyze(tags []string) (*app, error) {
ctxt := buildContext(tags)
hasMain, appFiles, err := checkMain(ctxt)
if err != nil {
return nil, err
}
gopath := filepath.SplitList(ctxt.GOPATH)
im, err := imports(ctxt, *rootDir, gopath)
return &app{
hasMain: hasMain,
appFiles: appFiles,
imports: im,
}, err
}
// buildContext returns the context for building the source.
func buildContext(tags []string) *build.Context {
return &build.Context{
GOARCH: build.Default.GOARCH,
GOOS: build.Default.GOOS,
GOROOT: build.Default.GOROOT,
GOPATH: build.Default.GOPATH,
Compiler: build.Default.Compiler,
BuildTags: append(build.Default.BuildTags, tags...),
}
}
// bundle bundles the app into the named tarFile ("-"==stdout).
func (s *app) bundle(tarFile string) (err error) {
var out io.Writer
if tarFile == "-" {
out = os.Stdout
} else {
f, err := os.Create(tarFile)
if err != nil {
return err
}
defer func() {
if cerr := f.Close(); err == nil {
err = cerr
}
}()
out = f
}
tw := tar.NewWriter(out)
for srcDir, importName := range s.imports {
dstDir := "_gopath/src/" + importName
if err = copyTree(tw, dstDir, srcDir); err != nil {
return fmt.Errorf("unable to copy directory %v to %v: %v", srcDir, dstDir, err)
}
}
if err := copyTree(tw, ".", *rootDir); err != nil {
return fmt.Errorf("unable to copy root directory to /app: %v", err)
}
if !s.hasMain {
if err := synthesizeMain(tw, s.appFiles); err != nil {
return fmt.Errorf("unable to synthesize new main func: %v", err)
}
}
if err := tw.Close(); err != nil {
return fmt.Errorf("unable to close tar file %v: %v", tarFile, err)
}
return nil
}
// synthesizeMain generates a new main func and writes it to the tarball.
func synthesizeMain(tw *tar.Writer, appFiles []string) error {
appMap := make(map[string]bool)
for _, f := range appFiles {
appMap[f] = true
}
var f string
for i := 0; i < 100; i++ {
f = fmt.Sprintf("app_main%d.go", i)
if !appMap[filepath.Join(*rootDir, f)] {
break
}
}
if appMap[filepath.Join(*rootDir, f)] {
return fmt.Errorf("unable to find unique name for %v", f)
}
hdr := &tar.Header{
Name: f,
Mode: 0644,
Size: int64(len(newMain)),
}
if err := tw.WriteHeader(hdr); err != nil {
return fmt.Errorf("unable to write header for %v: %v", f, err)
}
if _, err := tw.Write([]byte(newMain)); err != nil {
return fmt.Errorf("unable to write %v to tar file: %v", f, err)
}
return nil
}
// imports returns a map of all import directories (recursively) used by the app.
// The return value maps full directory names to original import names.
func imports(ctxt *build.Context, srcDir string, gopath []string) (map[string]string, error) {
pkg, err := ctxt.ImportDir(srcDir, 0)
if err != nil {
return nil, fmt.Errorf("unable to analyze source: %v", err)
}
// Resolve all non-standard-library imports
result := make(map[string]string)
for _, v := range pkg.Imports {
if !strings.Contains(v, ".") {
continue
}
src, err := findInGopath(v, gopath)
if err != nil {
return nil, fmt.Errorf("unable to find import %v in gopath %v: %v", v, gopath, err)
}
result[src] = v
im, err := imports(ctxt, src, gopath)
if err != nil {
return nil, fmt.Errorf("unable to parse package %v: %v", src, err)
}
for k, v := range im {
result[k] = v
}
}
return result, nil
}
// findInGopath searches the gopath for the named import directory.
func findInGopath(dir string, gopath []string) (string, error) {
for _, v := range gopath {
dst := filepath.Join(v, "src", dir)
if _, err := os.Stat(dst); err == nil {
return dst, nil
}
}
return "", fmt.Errorf("unable to find package %v in gopath %v", dir, gopath)
}
// copyTree copies srcDir to tar file dstDir, ignoring skipFiles.
func copyTree(tw *tar.Writer, dstDir, srcDir string) error {
entries, err := ioutil.ReadDir(srcDir)
if err != nil {
return fmt.Errorf("unable to read dir %v: %v", srcDir, err)
}
for _, entry := range entries {
n := entry.Name()
if skipFiles[n] {
continue
}
s := filepath.Join(srcDir, n)
d := filepath.Join(dstDir, n)
if entry.IsDir() {
if err := copyTree(tw, d, s); err != nil {
return fmt.Errorf("unable to copy dir %v to %v: %v", s, d, err)
}
continue
}
if err := copyFile(tw, d, s); err != nil {
return fmt.Errorf("unable to copy dir %v to %v: %v", s, d, err)
}
}
return nil
}
// copyFile copies src to tar file dst.
func copyFile(tw *tar.Writer, dst, src string) error {
s, err := os.Open(src)
if err != nil {
return fmt.Errorf("unable to open %v: %v", src, err)
}
defer s.Close()
fi, err := s.Stat()
if err != nil {
return fmt.Errorf("unable to stat %v: %v", src, err)
}
hdr, err := tar.FileInfoHeader(fi, dst)
if err != nil {
return fmt.Errorf("unable to create tar header for %v: %v", dst, err)
}
hdr.Name = dst
if err := tw.WriteHeader(hdr); err != nil {
return fmt.Errorf("unable to write header for %v: %v", dst, err)
}
_, err = io.Copy(tw, s)
if err != nil {
return fmt.Errorf("unable to copy %v to %v: %v", src, dst, err)
}
return nil
}
// checkMain verifies that there is a single "main" function.
// It also returns a list of all Go source files in the app.
func checkMain(ctxt *build.Context) (bool, []string, error) {
pkg, err := ctxt.ImportDir(*rootDir, 0)
if err != nil {
return false, nil, fmt.Errorf("unable to analyze source: %v", err)
}
if !pkg.IsCommand() {
errorf("Your app's package needs to be changed from %q to \"main\".\n", pkg.Name)
}
// Search for a "func main"
var hasMain bool
var appFiles []string
for _, f := range pkg.GoFiles {
n := filepath.Join(*rootDir, f)
appFiles = append(appFiles, n)
if hasMain, err = readFile(n); err != nil {
return false, nil, fmt.Errorf("error parsing %q: %v", n, err)
}
}
return hasMain, appFiles, nil
}
// isMain returns whether the given function declaration is a main function.
// Such a function must be called "main", not have a receiver, and have no arguments or return types.
func isMain(f *ast.FuncDecl) bool {
ft := f.Type
return f.Name.Name == "main" && f.Recv == nil && ft.Params.NumFields() == 0 && ft.Results.NumFields() == 0
}
// readFile reads and parses the Go source code file and returns whether it has a main function.
func readFile(filename string) (hasMain bool, err error) {
var src []byte
src, err = ioutil.ReadFile(filename)
if err != nil {
return
}
fset := token.NewFileSet()
file, err := parser.ParseFile(fset, filename, src, 0)
for _, decl := range file.Decls {
funcDecl, ok := decl.(*ast.FuncDecl)
if !ok {
continue
}
if !isMain(funcDecl) {
continue
}
hasMain = true
break
}
return
}

View File

@ -1,72 +0,0 @@
// Copyright 2015 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// Program aedeploy assists with deploying App Engine "flexible environment" Go apps to production.
// A temporary directory is created; the app, its subdirectories, and all its
// dependencies from $GOPATH are copied into the directory; then the app
// is deployed to production with the provided command.
//
// The app must be in "package main".
//
// This command must be issued from within the root directory of the app
// (where the app.yaml file is located).
package main
import (
"flag"
"fmt"
"log"
"os"
"os/exec"
"strings"
)
func usage() {
fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
fmt.Fprintf(os.Stderr, "\t%s gcloud --verbosity debug app deploy --version myversion ./app.yaml\tDeploy app to production\n", os.Args[0])
}
var verbose bool
// vlogf logs to stderr if the "-v" flag is provided.
func vlogf(f string, v ...interface{}) {
if !verbose {
return
}
log.Printf("[aedeploy] "+f, v...)
}
func main() {
flag.BoolVar(&verbose, "v", false, "Verbose logging.")
flag.Usage = usage
flag.Parse()
if flag.NArg() < 1 {
usage()
os.Exit(1)
}
notice := func() {
fmt.Fprintln(os.Stderr, `NOTICE: aedeploy is deprecated. Just use "gcloud app deploy".`)
}
notice()
if err := deploy(); err != nil {
fmt.Fprintf(os.Stderr, os.Args[0]+": Error: %v\n", err)
notice()
fmt.Fprintln(os.Stderr, `You might need to update gcloud. Run "gcloud components update".`)
os.Exit(1)
}
notice() // Make sure they see it at the end.
}
// deploy calls the provided command to deploy the app from the temporary directory.
func deploy() error {
vlogf("Running command %v", flag.Args())
cmd := exec.Command(flag.Arg(0), flag.Args()[1:]...)
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
if err := cmd.Run(); err != nil {
return fmt.Errorf("unable to run %q: %v", strings.Join(flag.Args(), " "), err)
}
return nil
}

View File

@ -1,185 +0,0 @@
// Copyright 2016 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package main
import (
"go/ast"
"path"
"strconv"
"strings"
)
const (
ctxPackage = "golang.org/x/net/context"
newPackageBase = "google.golang.org/"
stutterPackage = false
)
func init() {
register(fix{
"ae",
"2016-04-15",
aeFn,
`Update old App Engine APIs to new App Engine APIs`,
})
}
// logMethod is the set of methods on appengine.Context used for logging.
var logMethod = map[string]bool{
"Debugf": true,
"Infof": true,
"Warningf": true,
"Errorf": true,
"Criticalf": true,
}
// mapPackage turns "appengine" into "google.golang.org/appengine", etc.
func mapPackage(s string) string {
if stutterPackage {
s += "/" + path.Base(s)
}
return newPackageBase + s
}
func aeFn(f *ast.File) bool {
// During the walk, we track the last thing seen that looks like
// an appengine.Context, and reset it once the walk leaves a func.
var lastContext *ast.Ident
fixed := false
// Update imports.
mainImp := "appengine"
for _, imp := range f.Imports {
pth, _ := strconv.Unquote(imp.Path.Value)
if pth == "appengine" || strings.HasPrefix(pth, "appengine/") {
newPth := mapPackage(pth)
imp.Path.Value = strconv.Quote(newPth)
fixed = true
if pth == "appengine" {
mainImp = newPth
}
}
}
// Update any API changes.
walk(f, func(n interface{}) {
if ft, ok := n.(*ast.FuncType); ok && ft.Params != nil {
// See if this func has an `appengine.Context arg`.
// If so, remember its identifier.
for _, param := range ft.Params.List {
if !isPkgDot(param.Type, "appengine", "Context") {
continue
}
if len(param.Names) == 1 {
lastContext = param.Names[0]
break
}
}
return
}
if as, ok := n.(*ast.AssignStmt); ok {
if len(as.Lhs) == 1 && len(as.Rhs) == 1 {
// If this node is an assignment from an appengine.NewContext invocation,
// remember the identifier on the LHS.
if isCall(as.Rhs[0], "appengine", "NewContext") {
if ident, ok := as.Lhs[0].(*ast.Ident); ok {
lastContext = ident
return
}
}
// x (=|:=) appengine.Timeout(y, z)
// should become
// x, _ (=|:=) context.WithTimeout(y, z)
if isCall(as.Rhs[0], "appengine", "Timeout") {
addImport(f, ctxPackage)
as.Lhs = append(as.Lhs, ast.NewIdent("_"))
// isCall already did the type checking.
sel := as.Rhs[0].(*ast.CallExpr).Fun.(*ast.SelectorExpr)
sel.X = ast.NewIdent("context")
sel.Sel = ast.NewIdent("WithTimeout")
fixed = true
return
}
}
return
}
// If this node is a FuncDecl, we've finished the function, so reset lastContext.
if _, ok := n.(*ast.FuncDecl); ok {
lastContext = nil
return
}
if call, ok := n.(*ast.CallExpr); ok {
if isPkgDot(call.Fun, "appengine", "Datacenter") && len(call.Args) == 0 {
insertContext(f, call, lastContext)
fixed = true
return
}
if isPkgDot(call.Fun, "taskqueue", "QueueStats") && len(call.Args) == 3 {
call.Args = call.Args[:2] // drop last arg
fixed = true
return
}
sel, ok := call.Fun.(*ast.SelectorExpr)
if !ok {
return
}
if lastContext != nil && refersTo(sel.X, lastContext) && logMethod[sel.Sel.Name] {
// c.Errorf(...)
// should become
// log.Errorf(c, ...)
addImport(f, mapPackage("appengine/log"))
sel.X = &ast.Ident{ // ast.NewIdent doesn't preserve the position.
NamePos: sel.X.Pos(),
Name: "log",
}
insertContext(f, call, lastContext)
fixed = true
return
}
}
})
// Change any `appengine.Context` to `context.Context`.
// Do this in a separate walk because the previous walk
// wants to identify "appengine.Context".
walk(f, func(n interface{}) {
expr, ok := n.(ast.Expr)
if ok && isPkgDot(expr, "appengine", "Context") {
addImport(f, ctxPackage)
// isPkgDot did the type checking.
n.(*ast.SelectorExpr).X.(*ast.Ident).Name = "context"
fixed = true
return
}
})
// The changes above might remove the need to import "appengine".
// Check if it's used, and drop it if it isn't.
if fixed && !usesImport(f, mainImp) {
deleteImport(f, mainImp)
}
return fixed
}
// ctx may be nil.
func insertContext(f *ast.File, call *ast.CallExpr, ctx *ast.Ident) {
if ctx == nil {
// context is unknown, so use a plain "ctx".
ctx = ast.NewIdent("ctx")
} else {
// Create a fresh *ast.Ident so we drop the position information.
ctx = ast.NewIdent(ctx.Name)
}
call.Args = append([]ast.Expr{ctx}, call.Args...)
}

View File

@ -1,144 +0,0 @@
// Copyright 2016 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package main
func init() {
addTestCases(aeTests, nil)
}
var aeTests = []testCase{
// Collection of fixes:
// - imports
// - appengine.Timeout -> context.WithTimeout
// - add ctx arg to appengine.Datacenter
// - logging API
{
Name: "ae.0",
In: `package foo
import (
"net/http"
"time"
"appengine"
"appengine/datastore"
)
func f(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
c = appengine.Timeout(c, 5*time.Second)
err := datastore.ErrNoSuchEntity
c.Errorf("Something interesting happened: %v", err)
_ = appengine.Datacenter()
}
`,
Out: `package foo
import (
"net/http"
"time"
"golang.org/x/net/context"
"google.golang.org/appengine"
"google.golang.org/appengine/datastore"
"google.golang.org/appengine/log"
)
func f(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
c, _ = context.WithTimeout(c, 5*time.Second)
err := datastore.ErrNoSuchEntity
log.Errorf(c, "Something interesting happened: %v", err)
_ = appengine.Datacenter(c)
}
`,
},
// Updating a function that takes an appengine.Context arg.
{
Name: "ae.1",
In: `package foo
import (
"appengine"
)
func LogSomething(c2 appengine.Context) {
c2.Warningf("Stand back! I'm going to try science!")
}
`,
Out: `package foo
import (
"golang.org/x/net/context"
"google.golang.org/appengine/log"
)
func LogSomething(c2 context.Context) {
log.Warningf(c2, "Stand back! I'm going to try science!")
}
`,
},
// Less widely used API changes:
// - drop maxTasks arg to taskqueue.QueueStats
{
Name: "ae.2",
In: `package foo
import (
"appengine"
"appengine/taskqueue"
)
func f(ctx appengine.Context) {
stats, err := taskqueue.QueueStats(ctx, []string{"one", "two"}, 0)
}
`,
Out: `package foo
import (
"golang.org/x/net/context"
"google.golang.org/appengine/taskqueue"
)
func f(ctx context.Context) {
stats, err := taskqueue.QueueStats(ctx, []string{"one", "two"})
}
`,
},
// Check that the main "appengine" import will not be dropped
// if an appengine.Context -> context.Context change happens
// but the appengine package is still referenced.
{
Name: "ae.3",
In: `package foo
import (
"appengine"
"io"
)
func f(ctx appengine.Context, w io.Writer) {
_ = appengine.IsDevAppServer()
}
`,
Out: `package foo
import (
"golang.org/x/net/context"
"google.golang.org/appengine"
"io"
)
func f(ctx context.Context, w io.Writer) {
_ = appengine.IsDevAppServer()
}
`,
},
}

View File

@ -1,848 +0,0 @@
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
"os"
"path"
"reflect"
"strconv"
"strings"
)
type fix struct {
name string
date string // date that fix was introduced, in YYYY-MM-DD format
f func(*ast.File) bool
desc string
}
// main runs sort.Sort(byName(fixes)) before printing list of fixes.
type byName []fix
func (f byName) Len() int { return len(f) }
func (f byName) Swap(i, j int) { f[i], f[j] = f[j], f[i] }
func (f byName) Less(i, j int) bool { return f[i].name < f[j].name }
// main runs sort.Sort(byDate(fixes)) before applying fixes.
type byDate []fix
func (f byDate) Len() int { return len(f) }
func (f byDate) Swap(i, j int) { f[i], f[j] = f[j], f[i] }
func (f byDate) Less(i, j int) bool { return f[i].date < f[j].date }
var fixes []fix
func register(f fix) {
fixes = append(fixes, f)
}
// walk traverses the AST x, calling visit(y) for each node y in the tree but
// also with a pointer to each ast.Expr, ast.Stmt, and *ast.BlockStmt,
// in a bottom-up traversal.
func walk(x interface{}, visit func(interface{})) {
walkBeforeAfter(x, nop, visit)
}
func nop(interface{}) {}
// walkBeforeAfter is like walk but calls before(x) before traversing
// x's children and after(x) afterward.
func walkBeforeAfter(x interface{}, before, after func(interface{})) {
before(x)
switch n := x.(type) {
default:
panic(fmt.Errorf("unexpected type %T in walkBeforeAfter", x))
case nil:
// pointers to interfaces
case *ast.Decl:
walkBeforeAfter(*n, before, after)
case *ast.Expr:
walkBeforeAfter(*n, before, after)
case *ast.Spec:
walkBeforeAfter(*n, before, after)
case *ast.Stmt:
walkBeforeAfter(*n, before, after)
// pointers to struct pointers
case **ast.BlockStmt:
walkBeforeAfter(*n, before, after)
case **ast.CallExpr:
walkBeforeAfter(*n, before, after)
case **ast.FieldList:
walkBeforeAfter(*n, before, after)
case **ast.FuncType:
walkBeforeAfter(*n, before, after)
case **ast.Ident:
walkBeforeAfter(*n, before, after)
case **ast.BasicLit:
walkBeforeAfter(*n, before, after)
// pointers to slices
case *[]ast.Decl:
walkBeforeAfter(*n, before, after)
case *[]ast.Expr:
walkBeforeAfter(*n, before, after)
case *[]*ast.File:
walkBeforeAfter(*n, before, after)
case *[]*ast.Ident:
walkBeforeAfter(*n, before, after)
case *[]ast.Spec:
walkBeforeAfter(*n, before, after)
case *[]ast.Stmt:
walkBeforeAfter(*n, before, after)
// These are ordered and grouped to match ../../pkg/go/ast/ast.go
case *ast.Field:
walkBeforeAfter(&n.Names, before, after)
walkBeforeAfter(&n.Type, before, after)
walkBeforeAfter(&n.Tag, before, after)
case *ast.FieldList:
for _, field := range n.List {
walkBeforeAfter(field, before, after)
}
case *ast.BadExpr:
case *ast.Ident:
case *ast.Ellipsis:
walkBeforeAfter(&n.Elt, before, after)
case *ast.BasicLit:
case *ast.FuncLit:
walkBeforeAfter(&n.Type, before, after)
walkBeforeAfter(&n.Body, before, after)
case *ast.CompositeLit:
walkBeforeAfter(&n.Type, before, after)
walkBeforeAfter(&n.Elts, before, after)
case *ast.ParenExpr:
walkBeforeAfter(&n.X, before, after)
case *ast.SelectorExpr:
walkBeforeAfter(&n.X, before, after)
case *ast.IndexExpr:
walkBeforeAfter(&n.X, before, after)
walkBeforeAfter(&n.Index, before, after)
case *ast.SliceExpr:
walkBeforeAfter(&n.X, before, after)
if n.Low != nil {
walkBeforeAfter(&n.Low, before, after)
}
if n.High != nil {
walkBeforeAfter(&n.High, before, after)
}
case *ast.TypeAssertExpr:
walkBeforeAfter(&n.X, before, after)
walkBeforeAfter(&n.Type, before, after)
case *ast.CallExpr:
walkBeforeAfter(&n.Fun, before, after)
walkBeforeAfter(&n.Args, before, after)
case *ast.StarExpr:
walkBeforeAfter(&n.X, before, after)
case *ast.UnaryExpr:
walkBeforeAfter(&n.X, before, after)
case *ast.BinaryExpr:
walkBeforeAfter(&n.X, before, after)
walkBeforeAfter(&n.Y, before, after)
case *ast.KeyValueExpr:
walkBeforeAfter(&n.Key, before, after)
walkBeforeAfter(&n.Value, before, after)
case *ast.ArrayType:
walkBeforeAfter(&n.Len, before, after)
walkBeforeAfter(&n.Elt, before, after)
case *ast.StructType:
walkBeforeAfter(&n.Fields, before, after)
case *ast.FuncType:
walkBeforeAfter(&n.Params, before, after)
if n.Results != nil {
walkBeforeAfter(&n.Results, before, after)
}
case *ast.InterfaceType:
walkBeforeAfter(&n.Methods, before, after)
case *ast.MapType:
walkBeforeAfter(&n.Key, before, after)
walkBeforeAfter(&n.Value, before, after)
case *ast.ChanType:
walkBeforeAfter(&n.Value, before, after)
case *ast.BadStmt:
case *ast.DeclStmt:
walkBeforeAfter(&n.Decl, before, after)
case *ast.EmptyStmt:
case *ast.LabeledStmt:
walkBeforeAfter(&n.Stmt, before, after)
case *ast.ExprStmt:
walkBeforeAfter(&n.X, before, after)
case *ast.SendStmt:
walkBeforeAfter(&n.Chan, before, after)
walkBeforeAfter(&n.Value, before, after)
case *ast.IncDecStmt:
walkBeforeAfter(&n.X, before, after)
case *ast.AssignStmt:
walkBeforeAfter(&n.Lhs, before, after)
walkBeforeAfter(&n.Rhs, before, after)
case *ast.GoStmt:
walkBeforeAfter(&n.Call, before, after)
case *ast.DeferStmt:
walkBeforeAfter(&n.Call, before, after)
case *ast.ReturnStmt:
walkBeforeAfter(&n.Results, before, after)
case *ast.BranchStmt:
case *ast.BlockStmt:
walkBeforeAfter(&n.List, before, after)
case *ast.IfStmt:
walkBeforeAfter(&n.Init, before, after)
walkBeforeAfter(&n.Cond, before, after)
walkBeforeAfter(&n.Body, before, after)
walkBeforeAfter(&n.Else, before, after)
case *ast.CaseClause:
walkBeforeAfter(&n.List, before, after)
walkBeforeAfter(&n.Body, before, after)
case *ast.SwitchStmt:
walkBeforeAfter(&n.Init, before, after)
walkBeforeAfter(&n.Tag, before, after)
walkBeforeAfter(&n.Body, before, after)
case *ast.TypeSwitchStmt:
walkBeforeAfter(&n.Init, before, after)
walkBeforeAfter(&n.Assign, before, after)
walkBeforeAfter(&n.Body, before, after)
case *ast.CommClause:
walkBeforeAfter(&n.Comm, before, after)
walkBeforeAfter(&n.Body, before, after)
case *ast.SelectStmt:
walkBeforeAfter(&n.Body, before, after)
case *ast.ForStmt:
walkBeforeAfter(&n.Init, before, after)
walkBeforeAfter(&n.Cond, before, after)
walkBeforeAfter(&n.Post, before, after)
walkBeforeAfter(&n.Body, before, after)
case *ast.RangeStmt:
walkBeforeAfter(&n.Key, before, after)
walkBeforeAfter(&n.Value, before, after)
walkBeforeAfter(&n.X, before, after)
walkBeforeAfter(&n.Body, before, after)
case *ast.ImportSpec:
case *ast.ValueSpec:
walkBeforeAfter(&n.Type, before, after)
walkBeforeAfter(&n.Values, before, after)
walkBeforeAfter(&n.Names, before, after)
case *ast.TypeSpec:
walkBeforeAfter(&n.Type, before, after)
case *ast.BadDecl:
case *ast.GenDecl:
walkBeforeAfter(&n.Specs, before, after)
case *ast.FuncDecl:
if n.Recv != nil {
walkBeforeAfter(&n.Recv, before, after)
}
walkBeforeAfter(&n.Type, before, after)
if n.Body != nil {
walkBeforeAfter(&n.Body, before, after)
}
case *ast.File:
walkBeforeAfter(&n.Decls, before, after)
case *ast.Package:
walkBeforeAfter(&n.Files, before, after)
case []*ast.File:
for i := range n {
walkBeforeAfter(&n[i], before, after)
}
case []ast.Decl:
for i := range n {
walkBeforeAfter(&n[i], before, after)
}
case []ast.Expr:
for i := range n {
walkBeforeAfter(&n[i], before, after)
}
case []*ast.Ident:
for i := range n {
walkBeforeAfter(&n[i], before, after)
}
case []ast.Stmt:
for i := range n {
walkBeforeAfter(&n[i], before, after)
}
case []ast.Spec:
for i := range n {
walkBeforeAfter(&n[i], before, after)
}
}
after(x)
}
// imports returns true if f imports path.
func imports(f *ast.File, path string) bool {
return importSpec(f, path) != nil
}
// importSpec returns the import spec if f imports path,
// or nil otherwise.
func importSpec(f *ast.File, path string) *ast.ImportSpec {
for _, s := range f.Imports {
if importPath(s) == path {
return s
}
}
return nil
}
// importPath returns the unquoted import path of s,
// or "" if the path is not properly quoted.
func importPath(s *ast.ImportSpec) string {
t, err := strconv.Unquote(s.Path.Value)
if err == nil {
return t
}
return ""
}
// declImports reports whether gen contains an import of path.
func declImports(gen *ast.GenDecl, path string) bool {
if gen.Tok != token.IMPORT {
return false
}
for _, spec := range gen.Specs {
impspec := spec.(*ast.ImportSpec)
if importPath(impspec) == path {
return true
}
}
return false
}
// isPkgDot returns true if t is the expression "pkg.name"
// where pkg is an imported identifier.
func isPkgDot(t ast.Expr, pkg, name string) bool {
sel, ok := t.(*ast.SelectorExpr)
return ok && isTopName(sel.X, pkg) && sel.Sel.String() == name
}
// isPtrPkgDot returns true if f is the expression "*pkg.name"
// where pkg is an imported identifier.
func isPtrPkgDot(t ast.Expr, pkg, name string) bool {
ptr, ok := t.(*ast.StarExpr)
return ok && isPkgDot(ptr.X, pkg, name)
}
// isTopName returns true if n is a top-level unresolved identifier with the given name.
func isTopName(n ast.Expr, name string) bool {
id, ok := n.(*ast.Ident)
return ok && id.Name == name && id.Obj == nil
}
// isName returns true if n is an identifier with the given name.
func isName(n ast.Expr, name string) bool {
id, ok := n.(*ast.Ident)
return ok && id.String() == name
}
// isCall returns true if t is a call to pkg.name.
func isCall(t ast.Expr, pkg, name string) bool {
call, ok := t.(*ast.CallExpr)
return ok && isPkgDot(call.Fun, pkg, name)
}
// If n is an *ast.Ident, isIdent returns it; otherwise isIdent returns nil.
func isIdent(n interface{}) *ast.Ident {
id, _ := n.(*ast.Ident)
return id
}
// refersTo returns true if n is a reference to the same object as x.
func refersTo(n ast.Node, x *ast.Ident) bool {
id, ok := n.(*ast.Ident)
// The test of id.Name == x.Name handles top-level unresolved
// identifiers, which all have Obj == nil.
return ok && id.Obj == x.Obj && id.Name == x.Name
}
// isBlank returns true if n is the blank identifier.
func isBlank(n ast.Expr) bool {
return isName(n, "_")
}
// isEmptyString returns true if n is an empty string literal.
func isEmptyString(n ast.Expr) bool {
lit, ok := n.(*ast.BasicLit)
return ok && lit.Kind == token.STRING && len(lit.Value) == 2
}
func warn(pos token.Pos, msg string, args ...interface{}) {
if pos.IsValid() {
msg = "%s: " + msg
arg1 := []interface{}{fset.Position(pos).String()}
args = append(arg1, args...)
}
fmt.Fprintf(os.Stderr, msg+"\n", args...)
}
// countUses returns the number of uses of the identifier x in scope.
func countUses(x *ast.Ident, scope []ast.Stmt) int {
count := 0
ff := func(n interface{}) {
if n, ok := n.(ast.Node); ok && refersTo(n, x) {
count++
}
}
for _, n := range scope {
walk(n, ff)
}
return count
}
// rewriteUses replaces all uses of the identifier x and !x in scope
// with f(x.Pos()) and fnot(x.Pos()).
func rewriteUses(x *ast.Ident, f, fnot func(token.Pos) ast.Expr, scope []ast.Stmt) {
var lastF ast.Expr
ff := func(n interface{}) {
ptr, ok := n.(*ast.Expr)
if !ok {
return
}
nn := *ptr
// The child node was just walked and possibly replaced.
// If it was replaced and this is a negation, replace with fnot(p).
not, ok := nn.(*ast.UnaryExpr)
if ok && not.Op == token.NOT && not.X == lastF {
*ptr = fnot(nn.Pos())
return
}
if refersTo(nn, x) {
lastF = f(nn.Pos())
*ptr = lastF
}
}
for _, n := range scope {
walk(n, ff)
}
}
// assignsTo returns true if any of the code in scope assigns to or takes the address of x.
func assignsTo(x *ast.Ident, scope []ast.Stmt) bool {
assigned := false
ff := func(n interface{}) {
if assigned {
return
}
switch n := n.(type) {
case *ast.UnaryExpr:
// use of &x
if n.Op == token.AND && refersTo(n.X, x) {
assigned = true
return
}
case *ast.AssignStmt:
for _, l := range n.Lhs {
if refersTo(l, x) {
assigned = true
return
}
}
}
}
for _, n := range scope {
if assigned {
break
}
walk(n, ff)
}
return assigned
}
// newPkgDot returns an ast.Expr referring to "pkg.name" at position pos.
func newPkgDot(pos token.Pos, pkg, name string) ast.Expr {
return &ast.SelectorExpr{
X: &ast.Ident{
NamePos: pos,
Name: pkg,
},
Sel: &ast.Ident{
NamePos: pos,
Name: name,
},
}
}
// renameTop renames all references to the top-level name old.
// It returns true if it makes any changes.
func renameTop(f *ast.File, old, new string) bool {
var fixed bool
// Rename any conflicting imports
// (assuming package name is last element of path).
for _, s := range f.Imports {
if s.Name != nil {
if s.Name.Name == old {
s.Name.Name = new
fixed = true
}
} else {
_, thisName := path.Split(importPath(s))
if thisName == old {
s.Name = ast.NewIdent(new)
fixed = true
}
}
}
// Rename any top-level declarations.
for _, d := range f.Decls {
switch d := d.(type) {
case *ast.FuncDecl:
if d.Recv == nil && d.Name.Name == old {
d.Name.Name = new
d.Name.Obj.Name = new
fixed = true
}
case *ast.GenDecl:
for _, s := range d.Specs {
switch s := s.(type) {
case *ast.TypeSpec:
if s.Name.Name == old {
s.Name.Name = new
s.Name.Obj.Name = new
fixed = true
}
case *ast.ValueSpec:
for _, n := range s.Names {
if n.Name == old {
n.Name = new
n.Obj.Name = new
fixed = true
}
}
}
}
}
}
// Rename top-level old to new, both unresolved names
// (probably defined in another file) and names that resolve
// to a declaration we renamed.
walk(f, func(n interface{}) {
id, ok := n.(*ast.Ident)
if ok && isTopName(id, old) {
id.Name = new
fixed = true
}
if ok && id.Obj != nil && id.Name == old && id.Obj.Name == new {
id.Name = id.Obj.Name
fixed = true
}
})
return fixed
}
// matchLen returns the length of the longest prefix shared by x and y.
func matchLen(x, y string) int {
i := 0
for i < len(x) && i < len(y) && x[i] == y[i] {
i++
}
return i
}
// addImport adds the import path to the file f, if absent.
func addImport(f *ast.File, ipath string) (added bool) {
if imports(f, ipath) {
return false
}
// Determine name of import.
// Assume added imports follow convention of using last element.
_, name := path.Split(ipath)
// Rename any conflicting top-level references from name to name_.
renameTop(f, name, name+"_")
newImport := &ast.ImportSpec{
Path: &ast.BasicLit{
Kind: token.STRING,
Value: strconv.Quote(ipath),
},
}
// Find an import decl to add to.
var (
bestMatch = -1
lastImport = -1
impDecl *ast.GenDecl
impIndex = -1
)
for i, decl := range f.Decls {
gen, ok := decl.(*ast.GenDecl)
if ok && gen.Tok == token.IMPORT {
lastImport = i
// Do not add to import "C", to avoid disrupting the
// association with its doc comment, breaking cgo.
if declImports(gen, "C") {
continue
}
// Compute longest shared prefix with imports in this block.
for j, spec := range gen.Specs {
impspec := spec.(*ast.ImportSpec)
n := matchLen(importPath(impspec), ipath)
if n > bestMatch {
bestMatch = n
impDecl = gen
impIndex = j
}
}
}
}
// If no import decl found, add one after the last import.
if impDecl == nil {
impDecl = &ast.GenDecl{
Tok: token.IMPORT,
}
f.Decls = append(f.Decls, nil)
copy(f.Decls[lastImport+2:], f.Decls[lastImport+1:])
f.Decls[lastImport+1] = impDecl
}
// Ensure the import decl has parentheses, if needed.
if len(impDecl.Specs) > 0 && !impDecl.Lparen.IsValid() {
impDecl.Lparen = impDecl.Pos()
}
insertAt := impIndex + 1
if insertAt == 0 {
insertAt = len(impDecl.Specs)
}
impDecl.Specs = append(impDecl.Specs, nil)
copy(impDecl.Specs[insertAt+1:], impDecl.Specs[insertAt:])
impDecl.Specs[insertAt] = newImport
if insertAt > 0 {
// Assign same position as the previous import,
// so that the sorter sees it as being in the same block.
prev := impDecl.Specs[insertAt-1]
newImport.Path.ValuePos = prev.Pos()
newImport.EndPos = prev.Pos()
}
f.Imports = append(f.Imports, newImport)
return true
}
// deleteImport deletes the import path from the file f, if present.
func deleteImport(f *ast.File, path string) (deleted bool) {
oldImport := importSpec(f, path)
// Find the import node that imports path, if any.
for i, decl := range f.Decls {
gen, ok := decl.(*ast.GenDecl)
if !ok || gen.Tok != token.IMPORT {
continue
}
for j, spec := range gen.Specs {
impspec := spec.(*ast.ImportSpec)
if oldImport != impspec {
continue
}
// We found an import spec that imports path.
// Delete it.
deleted = true
copy(gen.Specs[j:], gen.Specs[j+1:])
gen.Specs = gen.Specs[:len(gen.Specs)-1]
// If this was the last import spec in this decl,
// delete the decl, too.
if len(gen.Specs) == 0 {
copy(f.Decls[i:], f.Decls[i+1:])
f.Decls = f.Decls[:len(f.Decls)-1]
} else if len(gen.Specs) == 1 {
gen.Lparen = token.NoPos // drop parens
}
if j > 0 {
// We deleted an entry but now there will be
// a blank line-sized hole where the import was.
// Close the hole by making the previous
// import appear to "end" where this one did.
gen.Specs[j-1].(*ast.ImportSpec).EndPos = impspec.End()
}
break
}
}
// Delete it from f.Imports.
for i, imp := range f.Imports {
if imp == oldImport {
copy(f.Imports[i:], f.Imports[i+1:])
f.Imports = f.Imports[:len(f.Imports)-1]
break
}
}
return
}
// rewriteImport rewrites any import of path oldPath to path newPath.
func rewriteImport(f *ast.File, oldPath, newPath string) (rewrote bool) {
for _, imp := range f.Imports {
if importPath(imp) == oldPath {
rewrote = true
// record old End, because the default is to compute
// it using the length of imp.Path.Value.
imp.EndPos = imp.End()
imp.Path.Value = strconv.Quote(newPath)
}
}
return
}
func usesImport(f *ast.File, path string) (used bool) {
spec := importSpec(f, path)
if spec == nil {
return
}
name := spec.Name.String()
switch name {
case "<nil>":
// If the package name is not explicitly specified,
// make an educated guess. This is not guaranteed to be correct.
lastSlash := strings.LastIndex(path, "/")
if lastSlash == -1 {
name = path
} else {
name = path[lastSlash+1:]
}
case "_", ".":
// Not sure if this import is used - err on the side of caution.
return true
}
walk(f, func(n interface{}) {
sel, ok := n.(*ast.SelectorExpr)
if ok && isTopName(sel.X, name) {
used = true
}
})
return
}
func expr(s string) ast.Expr {
x, err := parser.ParseExpr(s)
if err != nil {
panic("parsing " + s + ": " + err.Error())
}
// Remove position information to avoid spurious newlines.
killPos(reflect.ValueOf(x))
return x
}
var posType = reflect.TypeOf(token.Pos(0))
func killPos(v reflect.Value) {
switch v.Kind() {
case reflect.Ptr, reflect.Interface:
if !v.IsNil() {
killPos(v.Elem())
}
case reflect.Slice:
n := v.Len()
for i := 0; i < n; i++ {
killPos(v.Index(i))
}
case reflect.Struct:
n := v.NumField()
for i := 0; i < n; i++ {
f := v.Field(i)
if f.Type() == posType {
f.SetInt(0)
continue
}
killPos(f)
}
}
}
// A Rename describes a single renaming.
type rename struct {
OldImport string // only apply rename if this import is present
NewImport string // add this import during rewrite
Old string // old name: p.T or *p.T
New string // new name: p.T or *p.T
}
func renameFix(tab []rename) func(*ast.File) bool {
return func(f *ast.File) bool {
return renameFixTab(f, tab)
}
}
func parseName(s string) (ptr bool, pkg, nam string) {
i := strings.Index(s, ".")
if i < 0 {
panic("parseName: invalid name " + s)
}
if strings.HasPrefix(s, "*") {
ptr = true
s = s[1:]
i--
}
pkg = s[:i]
nam = s[i+1:]
return
}
func renameFixTab(f *ast.File, tab []rename) bool {
fixed := false
added := map[string]bool{}
check := map[string]bool{}
for _, t := range tab {
if !imports(f, t.OldImport) {
continue
}
optr, opkg, onam := parseName(t.Old)
walk(f, func(n interface{}) {
np, ok := n.(*ast.Expr)
if !ok {
return
}
x := *np
if optr {
p, ok := x.(*ast.StarExpr)
if !ok {
return
}
x = p.X
}
if !isPkgDot(x, opkg, onam) {
return
}
if t.NewImport != "" && !added[t.NewImport] {
addImport(f, t.NewImport)
added[t.NewImport] = true
}
*np = expr(t.New)
check[t.OldImport] = true
fixed = true
})
}
for ipath := range check {
if !usesImport(f, ipath) {
deleteImport(f, ipath)
}
}
return fixed
}

View File

@ -1,258 +0,0 @@
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"bytes"
"flag"
"fmt"
"go/ast"
"go/format"
"go/parser"
"go/scanner"
"go/token"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"sort"
"strings"
)
var (
fset = token.NewFileSet()
exitCode = 0
)
var allowedRewrites = flag.String("r", "",
"restrict the rewrites to this comma-separated list")
var forceRewrites = flag.String("force", "",
"force these fixes to run even if the code looks updated")
var allowed, force map[string]bool
var doDiff = flag.Bool("diff", false, "display diffs instead of rewriting files")
// enable for debugging fix failures
const debug = false // display incorrectly reformatted source and exit
func usage() {
fmt.Fprintf(os.Stderr, "usage: aefix [-diff] [-r fixname,...] [-force fixname,...] [path ...]\n")
flag.PrintDefaults()
fmt.Fprintf(os.Stderr, "\nAvailable rewrites are:\n")
sort.Sort(byName(fixes))
for _, f := range fixes {
fmt.Fprintf(os.Stderr, "\n%s\n", f.name)
desc := strings.TrimSpace(f.desc)
desc = strings.Replace(desc, "\n", "\n\t", -1)
fmt.Fprintf(os.Stderr, "\t%s\n", desc)
}
os.Exit(2)
}
func main() {
flag.Usage = usage
flag.Parse()
sort.Sort(byDate(fixes))
if *allowedRewrites != "" {
allowed = make(map[string]bool)
for _, f := range strings.Split(*allowedRewrites, ",") {
allowed[f] = true
}
}
if *forceRewrites != "" {
force = make(map[string]bool)
for _, f := range strings.Split(*forceRewrites, ",") {
force[f] = true
}
}
if flag.NArg() == 0 {
if err := processFile("standard input", true); err != nil {
report(err)
}
os.Exit(exitCode)
}
for i := 0; i < flag.NArg(); i++ {
path := flag.Arg(i)
switch dir, err := os.Stat(path); {
case err != nil:
report(err)
case dir.IsDir():
walkDir(path)
default:
if err := processFile(path, false); err != nil {
report(err)
}
}
}
os.Exit(exitCode)
}
const parserMode = parser.ParseComments
func gofmtFile(f *ast.File) ([]byte, error) {
var buf bytes.Buffer
if err := format.Node(&buf, fset, f); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
func processFile(filename string, useStdin bool) error {
var f *os.File
var err error
var fixlog bytes.Buffer
if useStdin {
f = os.Stdin
} else {
f, err = os.Open(filename)
if err != nil {
return err
}
defer f.Close()
}
src, err := ioutil.ReadAll(f)
if err != nil {
return err
}
file, err := parser.ParseFile(fset, filename, src, parserMode)
if err != nil {
return err
}
// Apply all fixes to file.
newFile := file
fixed := false
for _, fix := range fixes {
if allowed != nil && !allowed[fix.name] {
continue
}
if fix.f(newFile) {
fixed = true
fmt.Fprintf(&fixlog, " %s", fix.name)
// AST changed.
// Print and parse, to update any missing scoping
// or position information for subsequent fixers.
newSrc, err := gofmtFile(newFile)
if err != nil {
return err
}
newFile, err = parser.ParseFile(fset, filename, newSrc, parserMode)
if err != nil {
if debug {
fmt.Printf("%s", newSrc)
report(err)
os.Exit(exitCode)
}
return err
}
}
}
if !fixed {
return nil
}
fmt.Fprintf(os.Stderr, "%s: fixed %s\n", filename, fixlog.String()[1:])
// Print AST. We did that after each fix, so this appears
// redundant, but it is necessary to generate gofmt-compatible
// source code in a few cases. The official gofmt style is the
// output of the printer run on a standard AST generated by the parser,
// but the source we generated inside the loop above is the
// output of the printer run on a mangled AST generated by a fixer.
newSrc, err := gofmtFile(newFile)
if err != nil {
return err
}
if *doDiff {
data, err := diff(src, newSrc)
if err != nil {
return fmt.Errorf("computing diff: %s", err)
}
fmt.Printf("diff %s fixed/%s\n", filename, filename)
os.Stdout.Write(data)
return nil
}
if useStdin {
os.Stdout.Write(newSrc)
return nil
}
return ioutil.WriteFile(f.Name(), newSrc, 0)
}
var gofmtBuf bytes.Buffer
func gofmt(n interface{}) string {
gofmtBuf.Reset()
if err := format.Node(&gofmtBuf, fset, n); err != nil {
return "<" + err.Error() + ">"
}
return gofmtBuf.String()
}
func report(err error) {
scanner.PrintError(os.Stderr, err)
exitCode = 2
}
func walkDir(path string) {
filepath.Walk(path, visitFile)
}
func visitFile(path string, f os.FileInfo, err error) error {
if err == nil && isGoFile(f) {
err = processFile(path, false)
}
if err != nil {
report(err)
}
return nil
}
func isGoFile(f os.FileInfo) bool {
// ignore non-Go files
name := f.Name()
return !f.IsDir() && !strings.HasPrefix(name, ".") && strings.HasSuffix(name, ".go")
}
func diff(b1, b2 []byte) (data []byte, err error) {
f1, err := ioutil.TempFile("", "go-fix")
if err != nil {
return nil, err
}
defer os.Remove(f1.Name())
defer f1.Close()
f2, err := ioutil.TempFile("", "go-fix")
if err != nil {
return nil, err
}
defer os.Remove(f2.Name())
defer f2.Close()
f1.Write(b1)
f2.Write(b2)
data, err = exec.Command("diff", "-u", f1.Name(), f2.Name()).CombinedOutput()
if len(data) > 0 {
// diff exits with a non-zero status when the files don't match.
// Ignore that failure as long as we get output.
err = nil
}
return
}

View File

@ -1,129 +0,0 @@
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"go/ast"
"go/parser"
"strings"
"testing"
)
type testCase struct {
Name string
Fn func(*ast.File) bool
In string
Out string
}
var testCases []testCase
func addTestCases(t []testCase, fn func(*ast.File) bool) {
// Fill in fn to avoid repetition in definitions.
if fn != nil {
for i := range t {
if t[i].Fn == nil {
t[i].Fn = fn
}
}
}
testCases = append(testCases, t...)
}
func fnop(*ast.File) bool { return false }
func parseFixPrint(t *testing.T, fn func(*ast.File) bool, desc, in string, mustBeGofmt bool) (out string, fixed, ok bool) {
file, err := parser.ParseFile(fset, desc, in, parserMode)
if err != nil {
t.Errorf("%s: parsing: %v", desc, err)
return
}
outb, err := gofmtFile(file)
if err != nil {
t.Errorf("%s: printing: %v", desc, err)
return
}
if s := string(outb); in != s && mustBeGofmt {
t.Errorf("%s: not gofmt-formatted.\n--- %s\n%s\n--- %s | gofmt\n%s",
desc, desc, in, desc, s)
tdiff(t, in, s)
return
}
if fn == nil {
for _, fix := range fixes {
if fix.f(file) {
fixed = true
}
}
} else {
fixed = fn(file)
}
outb, err = gofmtFile(file)
if err != nil {
t.Errorf("%s: printing: %v", desc, err)
return
}
return string(outb), fixed, true
}
func TestRewrite(t *testing.T) {
for _, tt := range testCases {
// Apply fix: should get tt.Out.
out, fixed, ok := parseFixPrint(t, tt.Fn, tt.Name, tt.In, true)
if !ok {
continue
}
// reformat to get printing right
out, _, ok = parseFixPrint(t, fnop, tt.Name, out, false)
if !ok {
continue
}
if out != tt.Out {
t.Errorf("%s: incorrect output.\n", tt.Name)
if !strings.HasPrefix(tt.Name, "testdata/") {
t.Errorf("--- have\n%s\n--- want\n%s", out, tt.Out)
}
tdiff(t, out, tt.Out)
continue
}
if changed := out != tt.In; changed != fixed {
t.Errorf("%s: changed=%v != fixed=%v", tt.Name, changed, fixed)
continue
}
// Should not change if run again.
out2, fixed2, ok := parseFixPrint(t, tt.Fn, tt.Name+" output", out, true)
if !ok {
continue
}
if fixed2 {
t.Errorf("%s: applied fixes during second round", tt.Name)
continue
}
if out2 != out {
t.Errorf("%s: changed output after second round of fixes.\n--- output after first round\n%s\n--- output after second round\n%s",
tt.Name, out, out2)
tdiff(t, out, out2)
}
}
}
func tdiff(t *testing.T, a, b string) {
data, err := diff([]byte(a), []byte(b))
if err != nil {
t.Error(err)
return
}
t.Error(string(data))
}

View File

@ -1,673 +0,0 @@
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"fmt"
"go/ast"
"go/token"
"os"
"reflect"
"strings"
)
// Partial type checker.
//
// The fact that it is partial is very important: the input is
// an AST and a description of some type information to
// assume about one or more packages, but not all the
// packages that the program imports. The checker is
// expected to do as much as it can with what it has been
// given. There is not enough information supplied to do
// a full type check, but the type checker is expected to
// apply information that can be derived from variable
// declarations, function and method returns, and type switches
// as far as it can, so that the caller can still tell the types
// of expression relevant to a particular fix.
//
// TODO(rsc,gri): Replace with go/typechecker.
// Doing that could be an interesting test case for go/typechecker:
// the constraints about working with partial information will
// likely exercise it in interesting ways. The ideal interface would
// be to pass typecheck a map from importpath to package API text
// (Go source code), but for now we use data structures (TypeConfig, Type).
//
// The strings mostly use gofmt form.
//
// A Field or FieldList has as its type a comma-separated list
// of the types of the fields. For example, the field list
// x, y, z int
// has type "int, int, int".
// The prefix "type " is the type of a type.
// For example, given
// var x int
// type T int
// x's type is "int" but T's type is "type int".
// mkType inserts the "type " prefix.
// getType removes it.
// isType tests for it.
func mkType(t string) string {
return "type " + t
}
func getType(t string) string {
if !isType(t) {
return ""
}
return t[len("type "):]
}
func isType(t string) bool {
return strings.HasPrefix(t, "type ")
}
// TypeConfig describes the universe of relevant types.
// For ease of creation, the types are all referred to by string
// name (e.g., "reflect.Value"). TypeByName is the only place
// where the strings are resolved.
type TypeConfig struct {
Type map[string]*Type
Var map[string]string
Func map[string]string
}
// typeof returns the type of the given name, which may be of
// the form "x" or "p.X".
func (cfg *TypeConfig) typeof(name string) string {
if cfg.Var != nil {
if t := cfg.Var[name]; t != "" {
return t
}
}
if cfg.Func != nil {
if t := cfg.Func[name]; t != "" {
return "func()" + t
}
}
return ""
}
// Type describes the Fields and Methods of a type.
// If the field or method cannot be found there, it is next
// looked for in the Embed list.
type Type struct {
Field map[string]string // map field name to type
Method map[string]string // map method name to comma-separated return types (should start with "func ")
Embed []string // list of types this type embeds (for extra methods)
Def string // definition of named type
}
// dot returns the type of "typ.name", making its decision
// using the type information in cfg.
func (typ *Type) dot(cfg *TypeConfig, name string) string {
if typ.Field != nil {
if t := typ.Field[name]; t != "" {
return t
}
}
if typ.Method != nil {
if t := typ.Method[name]; t != "" {
return t
}
}
for _, e := range typ.Embed {
etyp := cfg.Type[e]
if etyp != nil {
if t := etyp.dot(cfg, name); t != "" {
return t
}
}
}
return ""
}
// typecheck type checks the AST f assuming the information in cfg.
// It returns two maps with type information:
// typeof maps AST nodes to type information in gofmt string form.
// assign maps type strings to lists of expressions that were assigned
// to values of another type that were assigned to that type.
func typecheck(cfg *TypeConfig, f *ast.File) (typeof map[interface{}]string, assign map[string][]interface{}) {
typeof = make(map[interface{}]string)
assign = make(map[string][]interface{})
cfg1 := &TypeConfig{}
*cfg1 = *cfg // make copy so we can add locally
copied := false
// gather function declarations
for _, decl := range f.Decls {
fn, ok := decl.(*ast.FuncDecl)
if !ok {
continue
}
typecheck1(cfg, fn.Type, typeof, assign)
t := typeof[fn.Type]
if fn.Recv != nil {
// The receiver must be a type.
rcvr := typeof[fn.Recv]
if !isType(rcvr) {
if len(fn.Recv.List) != 1 {
continue
}
rcvr = mkType(gofmt(fn.Recv.List[0].Type))
typeof[fn.Recv.List[0].Type] = rcvr
}
rcvr = getType(rcvr)
if rcvr != "" && rcvr[0] == '*' {
rcvr = rcvr[1:]
}
typeof[rcvr+"."+fn.Name.Name] = t
} else {
if isType(t) {
t = getType(t)
} else {
t = gofmt(fn.Type)
}
typeof[fn.Name] = t
// Record typeof[fn.Name.Obj] for future references to fn.Name.
typeof[fn.Name.Obj] = t
}
}
// gather struct declarations
for _, decl := range f.Decls {
d, ok := decl.(*ast.GenDecl)
if ok {
for _, s := range d.Specs {
switch s := s.(type) {
case *ast.TypeSpec:
if cfg1.Type[s.Name.Name] != nil {
break
}
if !copied {
copied = true
// Copy map lazily: it's time.
cfg1.Type = make(map[string]*Type)
for k, v := range cfg.Type {
cfg1.Type[k] = v
}
}
t := &Type{Field: map[string]string{}}
cfg1.Type[s.Name.Name] = t
switch st := s.Type.(type) {
case *ast.StructType:
for _, f := range st.Fields.List {
for _, n := range f.Names {
t.Field[n.Name] = gofmt(f.Type)
}
}
case *ast.ArrayType, *ast.StarExpr, *ast.MapType:
t.Def = gofmt(st)
}
}
}
}
}
typecheck1(cfg1, f, typeof, assign)
return typeof, assign
}
func makeExprList(a []*ast.Ident) []ast.Expr {
var b []ast.Expr
for _, x := range a {
b = append(b, x)
}
return b
}
// Typecheck1 is the recursive form of typecheck.
// It is like typecheck but adds to the information in typeof
// instead of allocating a new map.
func typecheck1(cfg *TypeConfig, f interface{}, typeof map[interface{}]string, assign map[string][]interface{}) {
// set sets the type of n to typ.
// If isDecl is true, n is being declared.
set := func(n ast.Expr, typ string, isDecl bool) {
if typeof[n] != "" || typ == "" {
if typeof[n] != typ {
assign[typ] = append(assign[typ], n)
}
return
}
typeof[n] = typ
// If we obtained typ from the declaration of x
// propagate the type to all the uses.
// The !isDecl case is a cheat here, but it makes
// up in some cases for not paying attention to
// struct fields. The real type checker will be
// more accurate so we won't need the cheat.
if id, ok := n.(*ast.Ident); ok && id.Obj != nil && (isDecl || typeof[id.Obj] == "") {
typeof[id.Obj] = typ
}
}
// Type-check an assignment lhs = rhs.
// If isDecl is true, this is := so we can update
// the types of the objects that lhs refers to.
typecheckAssign := func(lhs, rhs []ast.Expr, isDecl bool) {
if len(lhs) > 1 && len(rhs) == 1 {
if _, ok := rhs[0].(*ast.CallExpr); ok {
t := split(typeof[rhs[0]])
// Lists should have same length but may not; pair what can be paired.
for i := 0; i < len(lhs) && i < len(t); i++ {
set(lhs[i], t[i], isDecl)
}
return
}
}
if len(lhs) == 1 && len(rhs) == 2 {
// x = y, ok
rhs = rhs[:1]
} else if len(lhs) == 2 && len(rhs) == 1 {
// x, ok = y
lhs = lhs[:1]
}
// Match as much as we can.
for i := 0; i < len(lhs) && i < len(rhs); i++ {
x, y := lhs[i], rhs[i]
if typeof[y] != "" {
set(x, typeof[y], isDecl)
} else {
set(y, typeof[x], false)
}
}
}
expand := func(s string) string {
typ := cfg.Type[s]
if typ != nil && typ.Def != "" {
return typ.Def
}
return s
}
// The main type check is a recursive algorithm implemented
// by walkBeforeAfter(n, before, after).
// Most of it is bottom-up, but in a few places we need
// to know the type of the function we are checking.
// The before function records that information on
// the curfn stack.
var curfn []*ast.FuncType
before := func(n interface{}) {
// push function type on stack
switch n := n.(type) {
case *ast.FuncDecl:
curfn = append(curfn, n.Type)
case *ast.FuncLit:
curfn = append(curfn, n.Type)
}
}
// After is the real type checker.
after := func(n interface{}) {
if n == nil {
return
}
if false && reflect.TypeOf(n).Kind() == reflect.Ptr { // debugging trace
defer func() {
if t := typeof[n]; t != "" {
pos := fset.Position(n.(ast.Node).Pos())
fmt.Fprintf(os.Stderr, "%s: typeof[%s] = %s\n", pos, gofmt(n), t)
}
}()
}
switch n := n.(type) {
case *ast.FuncDecl, *ast.FuncLit:
// pop function type off stack
curfn = curfn[:len(curfn)-1]
case *ast.FuncType:
typeof[n] = mkType(joinFunc(split(typeof[n.Params]), split(typeof[n.Results])))
case *ast.FieldList:
// Field list is concatenation of sub-lists.
t := ""
for _, field := range n.List {
if t != "" {
t += ", "
}
t += typeof[field]
}
typeof[n] = t
case *ast.Field:
// Field is one instance of the type per name.
all := ""
t := typeof[n.Type]
if !isType(t) {
// Create a type, because it is typically *T or *p.T
// and we might care about that type.
t = mkType(gofmt(n.Type))
typeof[n.Type] = t
}
t = getType(t)
if len(n.Names) == 0 {
all = t
} else {
for _, id := range n.Names {
if all != "" {
all += ", "
}
all += t
typeof[id.Obj] = t
typeof[id] = t
}
}
typeof[n] = all
case *ast.ValueSpec:
// var declaration. Use type if present.
if n.Type != nil {
t := typeof[n.Type]
if !isType(t) {
t = mkType(gofmt(n.Type))
typeof[n.Type] = t
}
t = getType(t)
for _, id := range n.Names {
set(id, t, true)
}
}
// Now treat same as assignment.
typecheckAssign(makeExprList(n.Names), n.Values, true)
case *ast.AssignStmt:
typecheckAssign(n.Lhs, n.Rhs, n.Tok == token.DEFINE)
case *ast.Ident:
// Identifier can take its type from underlying object.
if t := typeof[n.Obj]; t != "" {
typeof[n] = t
}
case *ast.SelectorExpr:
// Field or method.
name := n.Sel.Name
if t := typeof[n.X]; t != "" {
if strings.HasPrefix(t, "*") {
t = t[1:] // implicit *
}
if typ := cfg.Type[t]; typ != nil {
if t := typ.dot(cfg, name); t != "" {
typeof[n] = t
return
}
}
tt := typeof[t+"."+name]
if isType(tt) {
typeof[n] = getType(tt)
return
}
}
// Package selector.
if x, ok := n.X.(*ast.Ident); ok && x.Obj == nil {
str := x.Name + "." + name
if cfg.Type[str] != nil {
typeof[n] = mkType(str)
return
}
if t := cfg.typeof(x.Name + "." + name); t != "" {
typeof[n] = t
return
}
}
case *ast.CallExpr:
// make(T) has type T.
if isTopName(n.Fun, "make") && len(n.Args) >= 1 {
typeof[n] = gofmt(n.Args[0])
return
}
// new(T) has type *T
if isTopName(n.Fun, "new") && len(n.Args) == 1 {
typeof[n] = "*" + gofmt(n.Args[0])
return
}
// Otherwise, use type of function to determine arguments.
t := typeof[n.Fun]
in, out := splitFunc(t)
if in == nil && out == nil {
return
}
typeof[n] = join(out)
for i, arg := range n.Args {
if i >= len(in) {
break
}
if typeof[arg] == "" {
typeof[arg] = in[i]
}
}
case *ast.TypeAssertExpr:
// x.(type) has type of x.
if n.Type == nil {
typeof[n] = typeof[n.X]
return
}
// x.(T) has type T.
if t := typeof[n.Type]; isType(t) {
typeof[n] = getType(t)
} else {
typeof[n] = gofmt(n.Type)
}
case *ast.SliceExpr:
// x[i:j] has type of x.
typeof[n] = typeof[n.X]
case *ast.IndexExpr:
// x[i] has key type of x's type.
t := expand(typeof[n.X])
if strings.HasPrefix(t, "[") || strings.HasPrefix(t, "map[") {
// Lazy: assume there are no nested [] in the array
// length or map key type.
if i := strings.Index(t, "]"); i >= 0 {
typeof[n] = t[i+1:]
}
}
case *ast.StarExpr:
// *x for x of type *T has type T when x is an expr.
// We don't use the result when *x is a type, but
// compute it anyway.
t := expand(typeof[n.X])
if isType(t) {
typeof[n] = "type *" + getType(t)
} else if strings.HasPrefix(t, "*") {
typeof[n] = t[len("*"):]
}
case *ast.UnaryExpr:
// &x for x of type T has type *T.
t := typeof[n.X]
if t != "" && n.Op == token.AND {
typeof[n] = "*" + t
}
case *ast.CompositeLit:
// T{...} has type T.
typeof[n] = gofmt(n.Type)
case *ast.ParenExpr:
// (x) has type of x.
typeof[n] = typeof[n.X]
case *ast.RangeStmt:
t := expand(typeof[n.X])
if t == "" {
return
}
var key, value string
if t == "string" {
key, value = "int", "rune"
} else if strings.HasPrefix(t, "[") {
key = "int"
if i := strings.Index(t, "]"); i >= 0 {
value = t[i+1:]
}
} else if strings.HasPrefix(t, "map[") {
if i := strings.Index(t, "]"); i >= 0 {
key, value = t[4:i], t[i+1:]
}
}
changed := false
if n.Key != nil && key != "" {
changed = true
set(n.Key, key, n.Tok == token.DEFINE)
}
if n.Value != nil && value != "" {
changed = true
set(n.Value, value, n.Tok == token.DEFINE)
}
// Ugly failure of vision: already type-checked body.
// Do it again now that we have that type info.
if changed {
typecheck1(cfg, n.Body, typeof, assign)
}
case *ast.TypeSwitchStmt:
// Type of variable changes for each case in type switch,
// but go/parser generates just one variable.
// Repeat type check for each case with more precise
// type information.
as, ok := n.Assign.(*ast.AssignStmt)
if !ok {
return
}
varx, ok := as.Lhs[0].(*ast.Ident)
if !ok {
return
}
t := typeof[varx]
for _, cas := range n.Body.List {
cas := cas.(*ast.CaseClause)
if len(cas.List) == 1 {
// Variable has specific type only when there is
// exactly one type in the case list.
if tt := typeof[cas.List[0]]; isType(tt) {
tt = getType(tt)
typeof[varx] = tt
typeof[varx.Obj] = tt
typecheck1(cfg, cas.Body, typeof, assign)
}
}
}
// Restore t.
typeof[varx] = t
typeof[varx.Obj] = t
case *ast.ReturnStmt:
if len(curfn) == 0 {
// Probably can't happen.
return
}
f := curfn[len(curfn)-1]
res := n.Results
if f.Results != nil {
t := split(typeof[f.Results])
for i := 0; i < len(res) && i < len(t); i++ {
set(res[i], t[i], false)
}
}
}
}
walkBeforeAfter(f, before, after)
}
// Convert between function type strings and lists of types.
// Using strings makes this a little harder, but it makes
// a lot of the rest of the code easier. This will all go away
// when we can use go/typechecker directly.
// splitFunc splits "func(x,y,z) (a,b,c)" into ["x", "y", "z"] and ["a", "b", "c"].
func splitFunc(s string) (in, out []string) {
if !strings.HasPrefix(s, "func(") {
return nil, nil
}
i := len("func(") // index of beginning of 'in' arguments
nparen := 0
for j := i; j < len(s); j++ {
switch s[j] {
case '(':
nparen++
case ')':
nparen--
if nparen < 0 {
// found end of parameter list
out := strings.TrimSpace(s[j+1:])
if len(out) >= 2 && out[0] == '(' && out[len(out)-1] == ')' {
out = out[1 : len(out)-1]
}
return split(s[i:j]), split(out)
}
}
}
return nil, nil
}
// joinFunc is the inverse of splitFunc.
func joinFunc(in, out []string) string {
outs := ""
if len(out) == 1 {
outs = " " + out[0]
} else if len(out) > 1 {
outs = " (" + join(out) + ")"
}
return "func(" + join(in) + ")" + outs
}
// split splits "int, float" into ["int", "float"] and splits "" into [].
func split(s string) []string {
out := []string{}
i := 0 // current type being scanned is s[i:j].
nparen := 0
for j := 0; j < len(s); j++ {
switch s[j] {
case ' ':
if i == j {
i++
}
case '(':
nparen++
case ')':
nparen--
if nparen < 0 {
// probably can't happen
return nil
}
case ',':
if nparen == 0 {
if i < j {
out = append(out, s[i:j])
}
i = j + 1
}
}
}
if nparen != 0 {
// probably can't happen
return nil
}
if i < len(s) {
out = append(out, s[i:])
}
return out
}
// join is the inverse of split.
func join(x []string) string {
return strings.Join(x, ", ")
}

View File

@ -1,407 +0,0 @@
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package datastore
import (
"errors"
"fmt"
"reflect"
"github.com/golang/protobuf/proto"
"golang.org/x/net/context"
"google.golang.org/appengine"
"google.golang.org/appengine/internal"
pb "google.golang.org/appengine/internal/datastore"
)
var (
// ErrInvalidEntityType is returned when functions like Get or Next are
// passed a dst or src argument of invalid type.
ErrInvalidEntityType = errors.New("datastore: invalid entity type")
// ErrInvalidKey is returned when an invalid key is presented.
ErrInvalidKey = errors.New("datastore: invalid key")
// ErrNoSuchEntity is returned when no entity was found for a given key.
ErrNoSuchEntity = errors.New("datastore: no such entity")
)
// ErrFieldMismatch is returned when a field is to be loaded into a different
// type than the one it was stored from, or when a field is missing or
// unexported in the destination struct.
// StructType is the type of the struct pointed to by the destination argument
// passed to Get or to Iterator.Next.
type ErrFieldMismatch struct {
StructType reflect.Type
FieldName string
Reason string
}
func (e *ErrFieldMismatch) Error() string {
return fmt.Sprintf("datastore: cannot load field %q into a %q: %s",
e.FieldName, e.StructType, e.Reason)
}
// protoToKey converts a Reference proto to a *Key. If the key is invalid,
// protoToKey will return the invalid key along with ErrInvalidKey.
func protoToKey(r *pb.Reference) (k *Key, err error) {
appID := r.GetApp()
namespace := r.GetNameSpace()
for _, e := range r.Path.Element {
k = &Key{
kind: e.GetType(),
stringID: e.GetName(),
intID: e.GetId(),
parent: k,
appID: appID,
namespace: namespace,
}
if !k.valid() {
return k, ErrInvalidKey
}
}
return
}
// keyToProto converts a *Key to a Reference proto.
func keyToProto(defaultAppID string, k *Key) *pb.Reference {
appID := k.appID
if appID == "" {
appID = defaultAppID
}
n := 0
for i := k; i != nil; i = i.parent {
n++
}
e := make([]*pb.Path_Element, n)
for i := k; i != nil; i = i.parent {
n--
e[n] = &pb.Path_Element{
Type: &i.kind,
}
// At most one of {Name,Id} should be set.
// Neither will be set for incomplete keys.
if i.stringID != "" {
e[n].Name = &i.stringID
} else if i.intID != 0 {
e[n].Id = &i.intID
}
}
var namespace *string
if k.namespace != "" {
namespace = proto.String(k.namespace)
}
return &pb.Reference{
App: proto.String(appID),
NameSpace: namespace,
Path: &pb.Path{
Element: e,
},
}
}
// multiKeyToProto is a batch version of keyToProto.
func multiKeyToProto(appID string, key []*Key) []*pb.Reference {
ret := make([]*pb.Reference, len(key))
for i, k := range key {
ret[i] = keyToProto(appID, k)
}
return ret
}
// multiValid is a batch version of Key.valid. It returns an error, not a
// []bool.
func multiValid(key []*Key) error {
invalid := false
for _, k := range key {
if !k.valid() {
invalid = true
break
}
}
if !invalid {
return nil
}
err := make(appengine.MultiError, len(key))
for i, k := range key {
if !k.valid() {
err[i] = ErrInvalidKey
}
}
return err
}
// It's unfortunate that the two semantically equivalent concepts pb.Reference
// and pb.PropertyValue_ReferenceValue aren't the same type. For example, the
// two have different protobuf field numbers.
// 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) {
appID := r.GetApp()
namespace := r.GetNameSpace()
for _, e := range r.Pathelement {
k = &Key{
kind: e.GetType(),
stringID: e.GetName(),
intID: e.GetId(),
parent: k,
appID: appID,
namespace: namespace,
}
if !k.valid() {
return nil, ErrInvalidKey
}
}
return
}
// 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 {
ref := keyToProto(defaultAppID, k)
pe := make([]*pb.PropertyValue_ReferenceValue_PathElement, len(ref.Path.Element))
for i, e := range ref.Path.Element {
pe[i] = &pb.PropertyValue_ReferenceValue_PathElement{
Type: e.Type,
Id: e.Id,
Name: e.Name,
}
}
return &pb.PropertyValue_ReferenceValue{
App: ref.App,
NameSpace: ref.NameSpace,
Pathelement: pe,
}
}
type multiArgType int
const (
multiArgTypeInvalid multiArgType = iota
multiArgTypePropertyLoadSaver
multiArgTypeStruct
multiArgTypeStructPtr
multiArgTypeInterface
)
// checkMultiArg checks that v has type []S, []*S, []I, or []P, for some struct
// type S, for some interface type I, or some non-interface non-pointer type P
// such that P or *P implements PropertyLoadSaver.
//
// It returns what category the slice's elements are, and the reflect.Type
// that represents S, I or P.
//
// As a special case, PropertyList is an invalid type for v.
func checkMultiArg(v reflect.Value) (m multiArgType, elemType reflect.Type) {
if v.Kind() != reflect.Slice {
return multiArgTypeInvalid, nil
}
if v.Type() == typeOfPropertyList {
return multiArgTypeInvalid, nil
}
elemType = v.Type().Elem()
if reflect.PtrTo(elemType).Implements(typeOfPropertyLoadSaver) {
return multiArgTypePropertyLoadSaver, elemType
}
switch elemType.Kind() {
case reflect.Struct:
return multiArgTypeStruct, elemType
case reflect.Interface:
return multiArgTypeInterface, elemType
case reflect.Ptr:
elemType = elemType.Elem()
if elemType.Kind() == reflect.Struct {
return multiArgTypeStructPtr, elemType
}
}
return multiArgTypeInvalid, nil
}
// Get loads the entity stored for k into dst, which must be a struct pointer
// or implement PropertyLoadSaver. If there is no such entity for the key, Get
// returns ErrNoSuchEntity.
//
// The values of dst's unmatched struct fields are not modified, and matching
// slice-typed fields are not reset before appending to them. In particular, it
// is recommended to pass a pointer to a zero valued struct on each Get call.
//
// ErrFieldMismatch is returned when a field is to be loaded into a different
// type than the one it was stored from, or when a field is missing or
// unexported in the destination struct. ErrFieldMismatch is only returned if
// dst is a struct pointer.
func Get(c context.Context, key *Key, dst interface{}) error {
if dst == nil { // GetMulti catches nil interface; we need to catch nil ptr here
return ErrInvalidEntityType
}
err := GetMulti(c, []*Key{key}, []interface{}{dst})
if me, ok := err.(appengine.MultiError); ok {
return me[0]
}
return err
}
// GetMulti is a batch version of Get.
//
// dst must be a []S, []*S, []I or []P, for some struct type S, some interface
// type I, or some non-interface non-pointer type P such that P or *P
// implements PropertyLoadSaver. If an []I, each element must be a valid dst
// for Get: it must be a struct pointer or implement PropertyLoadSaver.
//
// As a special case, PropertyList is an invalid type for dst, even though a
// PropertyList is a slice of structs. It is treated as invalid to avoid being
// mistakenly passed when []PropertyList was intended.
func GetMulti(c context.Context, key []*Key, dst interface{}) error {
v := reflect.ValueOf(dst)
multiArgType, _ := checkMultiArg(v)
if multiArgType == multiArgTypeInvalid {
return errors.New("datastore: dst has invalid type")
}
if len(key) != v.Len() {
return errors.New("datastore: key and dst slices have different length")
}
if len(key) == 0 {
return nil
}
if err := multiValid(key); err != nil {
return err
}
req := &pb.GetRequest{
Key: multiKeyToProto(internal.FullyQualifiedAppID(c), key),
}
res := &pb.GetResponse{}
if err := internal.Call(c, "datastore_v3", "Get", req, res); err != nil {
return err
}
if len(key) != len(res.Entity) {
return errors.New("datastore: internal error: server returned the wrong number of entities")
}
multiErr, any := make(appengine.MultiError, len(key)), false
for i, e := range res.Entity {
if e.Entity == nil {
multiErr[i] = ErrNoSuchEntity
} else {
elem := v.Index(i)
if multiArgType == multiArgTypePropertyLoadSaver || multiArgType == multiArgTypeStruct {
elem = elem.Addr()
}
if multiArgType == multiArgTypeStructPtr && elem.IsNil() {
elem.Set(reflect.New(elem.Type().Elem()))
}
multiErr[i] = loadEntity(elem.Interface(), e.Entity)
}
if multiErr[i] != nil {
any = true
}
}
if any {
return multiErr
}
return nil
}
// Put saves the entity src into the datastore with key k. src must be a struct
// pointer or implement PropertyLoadSaver; if a struct pointer then any
// unexported fields of that struct will be skipped. If k is an incomplete key,
// the returned key will be a unique key generated by the datastore.
func Put(c context.Context, key *Key, src interface{}) (*Key, error) {
k, err := PutMulti(c, []*Key{key}, []interface{}{src})
if err != nil {
if me, ok := err.(appengine.MultiError); ok {
return nil, me[0]
}
return nil, err
}
return k[0], nil
}
// PutMulti is a batch version of Put.
//
// src must satisfy the same conditions as the dst argument to GetMulti.
func PutMulti(c context.Context, key []*Key, src interface{}) ([]*Key, error) {
v := reflect.ValueOf(src)
multiArgType, _ := checkMultiArg(v)
if multiArgType == multiArgTypeInvalid {
return nil, errors.New("datastore: src has invalid type")
}
if len(key) != v.Len() {
return nil, errors.New("datastore: key and src slices have different length")
}
if len(key) == 0 {
return nil, nil
}
appID := internal.FullyQualifiedAppID(c)
if err := multiValid(key); err != nil {
return nil, err
}
req := &pb.PutRequest{}
for i := range key {
elem := v.Index(i)
if multiArgType == multiArgTypePropertyLoadSaver || multiArgType == multiArgTypeStruct {
elem = elem.Addr()
}
sProto, err := saveEntity(appID, key[i], elem.Interface())
if err != nil {
return nil, err
}
req.Entity = append(req.Entity, sProto)
}
res := &pb.PutResponse{}
if err := internal.Call(c, "datastore_v3", "Put", req, res); err != nil {
return nil, err
}
if len(key) != len(res.Key) {
return nil, errors.New("datastore: internal error: server returned the wrong number of keys")
}
ret := make([]*Key, len(key))
for i := range ret {
var err error
ret[i], err = protoToKey(res.Key[i])
if err != nil || ret[i].Incomplete() {
return nil, errors.New("datastore: internal error: server returned an invalid key")
}
}
return ret, nil
}
// Delete deletes the entity for the given key.
func Delete(c context.Context, key *Key) error {
err := DeleteMulti(c, []*Key{key})
if me, ok := err.(appengine.MultiError); ok {
return me[0]
}
return err
}
// DeleteMulti is a batch version of Delete.
func DeleteMulti(c context.Context, key []*Key) error {
if len(key) == 0 {
return nil
}
if err := multiValid(key); err != nil {
return err
}
req := &pb.DeleteRequest{
Key: multiKeyToProto(internal.FullyQualifiedAppID(c), key),
}
res := &pb.DeleteResponse{}
return internal.Call(c, "datastore_v3", "Delete", req, res)
}
func namespaceMod(m proto.Message, namespace string) {
// pb.Query is the only type that has a name_space field.
// All other namespace support in datastore is in the keys.
switch m := m.(type) {
case *pb.Query:
if m.NameSpace == nil {
m.NameSpace = &namespace
}
}
}
func init() {
internal.NamespaceMods["datastore_v3"] = namespaceMod
internal.RegisterErrorCodeMap("datastore_v3", pb.Error_ErrorCode_name)
internal.RegisterTimeoutErrorCode("datastore_v3", int32(pb.Error_TIMEOUT))
}

File diff suppressed because it is too large Load Diff

View File

@ -1,361 +0,0 @@
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
/*
Package datastore provides a client for App Engine's datastore service.
Basic Operations
Entities are the unit of storage and are associated with a key. A key
consists of an optional parent key, a string application ID, a string kind
(also known as an entity type), and either a StringID or an IntID. A
StringID is also known as an entity name or key name.
It is valid to create a key with a zero StringID and a zero IntID; this is
called an incomplete key, and does not refer to any saved entity. Putting an
entity into the datastore under an incomplete key will cause a unique key
to be generated for that entity, with a non-zero IntID.
An entity's contents are a mapping from case-sensitive field names to values.
Valid value types are:
- signed integers (int, int8, int16, int32 and int64),
- bool,
- string,
- float32 and float64,
- []byte (up to 1 megabyte in length),
- any type whose underlying type is one of the above predeclared types,
- ByteString,
- *Key,
- time.Time (stored with microsecond precision),
- appengine.BlobKey,
- appengine.GeoPoint,
- structs whose fields are all valid value types,
- slices of any of the above.
Slices of structs are valid, as are structs that contain slices. However, if
one struct contains another, then at most one of those can be repeated. This
disqualifies recursively defined struct types: any struct T that (directly or
indirectly) contains a []T.
The Get and Put functions load and save an entity's contents. An entity's
contents are typically represented by a struct pointer.
Example code:
type Entity struct {
Value string
}
func handle(w http.ResponseWriter, r *http.Request) {
ctx := appengine.NewContext(r)
k := datastore.NewKey(ctx, "Entity", "stringID", 0, nil)
e := new(Entity)
if err := datastore.Get(ctx, k, e); err != nil {
http.Error(w, err.Error(), 500)
return
}
old := e.Value
e.Value = r.URL.Path
if _, err := datastore.Put(ctx, k, e); err != nil {
http.Error(w, err.Error(), 500)
return
}
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
fmt.Fprintf(w, "old=%q\nnew=%q\n", old, e.Value)
}
GetMulti, PutMulti and DeleteMulti are batch versions of the Get, Put and
Delete functions. They take a []*Key instead of a *Key, and may return an
appengine.MultiError when encountering partial failure.
Properties
An entity's contents can be represented by a variety of types. These are
typically struct pointers, but can also be any type that implements the
PropertyLoadSaver interface. If using a struct pointer, you do not have to
explicitly implement the PropertyLoadSaver interface; the datastore will
automatically convert via reflection. If a struct pointer does implement that
interface then those methods will be used in preference to the default
behavior for struct pointers. Struct pointers are more strongly typed and are
easier to use; PropertyLoadSavers are more flexible.
The actual types passed do not have to match between Get and Put calls or even
across different calls to datastore. It is valid to put a *PropertyList and
get that same entity as a *myStruct, or put a *myStruct0 and get a *myStruct1.
Conceptually, any entity is saved as a sequence of properties, and is loaded
into the destination value on a property-by-property basis. When loading into
a struct pointer, an entity that cannot be completely represented (such as a
missing field) will result in an ErrFieldMismatch error but it is up to the
caller whether this error is fatal, recoverable or ignorable.
By default, for struct pointers, all properties are potentially indexed, and
the property name is the same as the field name (and hence must start with an
upper case letter).
Fields may have a `datastore:"name,options"` tag. The tag name is the
property name, which must be one or more valid Go identifiers joined by ".",
but may start with a lower case letter. An empty tag name means to just use the
field name. A "-" tag name means that the datastore will ignore that field.
The only valid options are "omitempty" and "noindex".
If the options include "omitempty" and the value of the field is empty, then the field will be omitted on Save.
The empty values are false, 0, any nil interface value, and any array, slice, map, or string of length zero.
Struct field values will never be empty.
If options include "noindex" then the field will not be indexed. All fields are indexed
by default. Strings or byte slices longer than 1500 bytes cannot be indexed;
fields used to store long strings and byte slices must be tagged with "noindex"
or they will cause Put operations to fail.
To use multiple options together, separate them by a comma.
The order does not matter.
If the options is "" then the comma may be omitted.
Example code:
// A and B are renamed to a and b.
// A, C and J are not indexed.
// D's tag is equivalent to having no tag at all (E).
// I is ignored entirely by the datastore.
// J has tag information for both the datastore and json packages.
type TaggedStruct struct {
A int `datastore:"a,noindex"`
B int `datastore:"b"`
C int `datastore:",noindex"`
D int `datastore:""`
E int
I int `datastore:"-"`
J int `datastore:",noindex" json:"j"`
}
Structured Properties
If the struct pointed to contains other structs, then the nested or embedded
structs are flattened. For example, given these definitions:
type Inner1 struct {
W int32
X string
}
type Inner2 struct {
Y float64
}
type Inner3 struct {
Z bool
}
type Outer struct {
A int16
I []Inner1
J Inner2
Inner3
}
then an Outer's properties would be equivalent to those of:
type OuterEquivalent struct {
A int16
IDotW []int32 `datastore:"I.W"`
IDotX []string `datastore:"I.X"`
JDotY float64 `datastore:"J.Y"`
Z bool
}
If Outer's embedded Inner3 field was tagged as `datastore:"Foo"` then the
equivalent field would instead be: FooDotZ bool `datastore:"Foo.Z"`.
If an outer struct is tagged "noindex" then all of its implicit flattened
fields are effectively "noindex".
The PropertyLoadSaver Interface
An entity's contents can also be represented by any type that implements the
PropertyLoadSaver interface. This type may be a struct pointer, but it does
not have to be. The datastore package will call Load when getting the entity's
contents, and Save when putting the entity's contents.
Possible uses include deriving non-stored fields, verifying fields, or indexing
a field only if its value is positive.
Example code:
type CustomPropsExample struct {
I, J int
// Sum is not stored, but should always be equal to I + J.
Sum int `datastore:"-"`
}
func (x *CustomPropsExample) Load(ps []datastore.Property) error {
// Load I and J as usual.
if err := datastore.LoadStruct(x, ps); err != nil {
return err
}
// Derive the Sum field.
x.Sum = x.I + x.J
return nil
}
func (x *CustomPropsExample) Save() ([]datastore.Property, error) {
// Validate the Sum field.
if x.Sum != x.I + x.J {
return nil, errors.New("CustomPropsExample has inconsistent sum")
}
// Save I and J as usual. The code below is equivalent to calling
// "return datastore.SaveStruct(x)", but is done manually for
// demonstration purposes.
return []datastore.Property{
{
Name: "I",
Value: int64(x.I),
},
{
Name: "J",
Value: int64(x.J),
},
}, nil
}
The *PropertyList type implements PropertyLoadSaver, and can therefore hold an
arbitrary entity's contents.
Queries
Queries retrieve entities based on their properties or key's ancestry. Running
a query yields an iterator of results: either keys or (key, entity) pairs.
Queries are re-usable and it is safe to call Query.Run from concurrent
goroutines. Iterators are not safe for concurrent use.
Queries are immutable, and are either created by calling NewQuery, or derived
from an existing query by calling a method like Filter or Order that returns a
new query value. A query is typically constructed by calling NewQuery followed
by a chain of zero or more such methods. These methods are:
- Ancestor and Filter constrain the entities returned by running a query.
- Order affects the order in which they are returned.
- Project constrains the fields returned.
- Distinct de-duplicates projected entities.
- KeysOnly makes the iterator return only keys, not (key, entity) pairs.
- Start, End, Offset and Limit define which sub-sequence of matching entities
to return. Start and End take cursors, Offset and Limit take integers. Start
and Offset affect the first result, End and Limit affect the last result.
If both Start and Offset are set, then the offset is relative to Start.
If both End and Limit are set, then the earliest constraint wins. Limit is
relative to Start+Offset, not relative to End. As a special case, a
negative limit means unlimited.
Example code:
type Widget struct {
Description string
Price int
}
func handle(w http.ResponseWriter, r *http.Request) {
ctx := appengine.NewContext(r)
q := datastore.NewQuery("Widget").
Filter("Price <", 1000).
Order("-Price")
b := new(bytes.Buffer)
for t := q.Run(ctx); ; {
var x Widget
key, err := t.Next(&x)
if err == datastore.Done {
break
}
if err != nil {
serveError(ctx, w, err)
return
}
fmt.Fprintf(b, "Key=%v\nWidget=%#v\n\n", key, x)
}
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
io.Copy(w, b)
}
Transactions
RunInTransaction runs a function in a transaction.
Example code:
type Counter struct {
Count int
}
func inc(ctx context.Context, key *datastore.Key) (int, error) {
var x Counter
if err := datastore.Get(ctx, key, &x); err != nil && err != datastore.ErrNoSuchEntity {
return 0, err
}
x.Count++
if _, err := datastore.Put(ctx, key, &x); err != nil {
return 0, err
}
return x.Count, nil
}
func handle(w http.ResponseWriter, r *http.Request) {
ctx := appengine.NewContext(r)
var count int
err := datastore.RunInTransaction(ctx, func(ctx context.Context) error {
var err1 error
count, err1 = inc(ctx, datastore.NewKey(ctx, "Counter", "singleton", 0, nil))
return err1
}, nil)
if err != nil {
serveError(ctx, w, err)
return
}
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
fmt.Fprintf(w, "Count=%d", count)
}
Metadata
The datastore package provides access to some of App Engine's datastore
metadata. This metadata includes information about the entity groups,
namespaces, entity kinds, and properties in the datastore, as well as the
property representations for each property.
Example code:
func handle(w http.ResponseWriter, r *http.Request) {
// Print all the kinds in the datastore, with all the indexed
// properties (and their representations) for each.
ctx := appengine.NewContext(r)
kinds, err := datastore.Kinds(ctx)
if err != nil {
serveError(ctx, w, err)
return
}
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
for _, kind := range kinds {
fmt.Fprintf(w, "%s:\n", kind)
props, err := datastore.KindProperties(ctx, kind)
if err != nil {
fmt.Fprintln(w, "\t(unable to retrieve properties)")
continue
}
for p, rep := range props {
fmt.Fprintf(w, "\t-%s (%s)\n", p, strings.Join(rep, ", "))
}
}
}
*/
package datastore // import "google.golang.org/appengine/datastore"

View File

@ -1,396 +0,0 @@
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package datastore
import (
"bytes"
"encoding/base64"
"encoding/gob"
"errors"
"fmt"
"strconv"
"strings"
"github.com/golang/protobuf/proto"
"golang.org/x/net/context"
"google.golang.org/appengine/internal"
pb "google.golang.org/appengine/internal/datastore"
)
type KeyRangeCollisionError struct {
start int64
end int64
}
func (e *KeyRangeCollisionError) Error() string {
return fmt.Sprintf("datastore: Collision when attempting to allocate range [%d, %d]",
e.start, e.end)
}
type KeyRangeContentionError struct {
start int64
end int64
}
func (e *KeyRangeContentionError) Error() string {
return fmt.Sprintf("datastore: Contention when attempting to allocate range [%d, %d]",
e.start, e.end)
}
// Key represents the datastore key for a stored entity, and is immutable.
type Key struct {
kind string
stringID string
intID int64
parent *Key
appID string
namespace string
}
// Kind returns the key's kind (also known as entity type).
func (k *Key) Kind() string {
return k.kind
}
// StringID returns the key's string ID (also known as an entity name or key
// name), which may be "".
func (k *Key) StringID() string {
return k.stringID
}
// IntID returns the key's integer ID, which may be 0.
func (k *Key) IntID() int64 {
return k.intID
}
// Parent returns the key's parent key, which may be nil.
func (k *Key) Parent() *Key {
return k.parent
}
// AppID returns the key's application ID.
func (k *Key) AppID() string {
return k.appID
}
// Namespace returns the key's namespace.
func (k *Key) Namespace() string {
return k.namespace
}
// Incomplete returns whether the key does not refer to a stored entity.
// In particular, whether the key has a zero StringID and a zero IntID.
func (k *Key) Incomplete() bool {
return k.stringID == "" && k.intID == 0
}
// valid returns whether the key is valid.
func (k *Key) valid() bool {
if k == nil {
return false
}
for ; k != nil; k = k.parent {
if k.kind == "" || k.appID == "" {
return false
}
if k.stringID != "" && k.intID != 0 {
return false
}
if k.parent != nil {
if k.parent.Incomplete() {
return false
}
if k.parent.appID != k.appID || k.parent.namespace != k.namespace {
return false
}
}
}
return true
}
// Equal returns whether two keys are equal.
func (k *Key) Equal(o *Key) bool {
for k != nil && o != nil {
if k.kind != o.kind || k.stringID != o.stringID || k.intID != o.intID || k.appID != o.appID || k.namespace != o.namespace {
return false
}
k, o = k.parent, o.parent
}
return k == o
}
// root returns the furthest ancestor of a key, which may be itself.
func (k *Key) root() *Key {
for k.parent != nil {
k = k.parent
}
return k
}
// marshal marshals the key's string representation to the buffer.
func (k *Key) marshal(b *bytes.Buffer) {
if k.parent != nil {
k.parent.marshal(b)
}
b.WriteByte('/')
b.WriteString(k.kind)
b.WriteByte(',')
if k.stringID != "" {
b.WriteString(k.stringID)
} else {
b.WriteString(strconv.FormatInt(k.intID, 10))
}
}
// String returns a string representation of the key.
func (k *Key) String() string {
if k == nil {
return ""
}
b := bytes.NewBuffer(make([]byte, 0, 512))
k.marshal(b)
return b.String()
}
type gobKey struct {
Kind string
StringID string
IntID int64
Parent *gobKey
AppID string
Namespace string
}
func keyToGobKey(k *Key) *gobKey {
if k == nil {
return nil
}
return &gobKey{
Kind: k.kind,
StringID: k.stringID,
IntID: k.intID,
Parent: keyToGobKey(k.parent),
AppID: k.appID,
Namespace: k.namespace,
}
}
func gobKeyToKey(gk *gobKey) *Key {
if gk == nil {
return nil
}
return &Key{
kind: gk.Kind,
stringID: gk.StringID,
intID: gk.IntID,
parent: gobKeyToKey(gk.Parent),
appID: gk.AppID,
namespace: gk.Namespace,
}
}
func (k *Key) GobEncode() ([]byte, error) {
buf := new(bytes.Buffer)
if err := gob.NewEncoder(buf).Encode(keyToGobKey(k)); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
func (k *Key) GobDecode(buf []byte) error {
gk := new(gobKey)
if err := gob.NewDecoder(bytes.NewBuffer(buf)).Decode(gk); err != nil {
return err
}
*k = *gobKeyToKey(gk)
return nil
}
func (k *Key) MarshalJSON() ([]byte, error) {
return []byte(`"` + k.Encode() + `"`), nil
}
func (k *Key) UnmarshalJSON(buf []byte) error {
if len(buf) < 2 || buf[0] != '"' || buf[len(buf)-1] != '"' {
return errors.New("datastore: bad JSON key")
}
k2, err := DecodeKey(string(buf[1 : len(buf)-1]))
if err != nil {
return err
}
*k = *k2
return nil
}
// Encode returns an opaque representation of the key
// suitable for use in HTML and URLs.
// This is compatible with the Python and Java runtimes.
func (k *Key) Encode() string {
ref := keyToProto("", k)
b, err := proto.Marshal(ref)
if err != nil {
panic(err)
}
// Trailing padding is stripped.
return strings.TrimRight(base64.URLEncoding.EncodeToString(b), "=")
}
// DecodeKey decodes a key from the opaque representation returned by Encode.
func DecodeKey(encoded string) (*Key, error) {
// Re-add padding.
if m := len(encoded) % 4; m != 0 {
encoded += strings.Repeat("=", 4-m)
}
b, err := base64.URLEncoding.DecodeString(encoded)
if err != nil {
return nil, err
}
ref := new(pb.Reference)
if err := proto.Unmarshal(b, ref); err != nil {
return nil, err
}
return protoToKey(ref)
}
// NewIncompleteKey creates a new incomplete key.
// kind cannot be empty.
func NewIncompleteKey(c context.Context, kind string, parent *Key) *Key {
return NewKey(c, kind, "", 0, parent)
}
// NewKey creates a new key.
// kind cannot be empty.
// Either one or both of stringID and intID must be zero. If both are zero,
// the key returned is incomplete.
// parent must either be a complete key or nil.
func NewKey(c context.Context, kind, stringID string, intID int64, parent *Key) *Key {
// If there's a parent key, use its namespace.
// Otherwise, use any namespace attached to the context.
var namespace string
if parent != nil {
namespace = parent.namespace
} else {
namespace = internal.NamespaceFromContext(c)
}
return &Key{
kind: kind,
stringID: stringID,
intID: intID,
parent: parent,
appID: internal.FullyQualifiedAppID(c),
namespace: namespace,
}
}
// AllocateIDs returns a range of n integer IDs with the given kind and parent
// combination. kind cannot be empty; parent may be nil. The IDs in the range
// returned will not be used by the datastore's automatic ID sequence generator
// and may be used with NewKey without conflict.
//
// The range is inclusive at the low end and exclusive at the high end. In
// other words, valid intIDs x satisfy low <= x && x < high.
//
// If no error is returned, low + n == high.
func AllocateIDs(c context.Context, kind string, parent *Key, n int) (low, high int64, err error) {
if kind == "" {
return 0, 0, errors.New("datastore: AllocateIDs given an empty kind")
}
if n < 0 {
return 0, 0, fmt.Errorf("datastore: AllocateIDs given a negative count: %d", n)
}
if n == 0 {
return 0, 0, nil
}
req := &pb.AllocateIdsRequest{
ModelKey: keyToProto("", NewIncompleteKey(c, kind, parent)),
Size: proto.Int64(int64(n)),
}
res := &pb.AllocateIdsResponse{}
if err := internal.Call(c, "datastore_v3", "AllocateIds", req, res); err != nil {
return 0, 0, err
}
// The protobuf is inclusive at both ends. Idiomatic Go (e.g. slices, for loops)
// is inclusive at the low end and exclusive at the high end, so we add 1.
low = res.GetStart()
high = res.GetEnd() + 1
if low+int64(n) != high {
return 0, 0, fmt.Errorf("datastore: internal error: could not allocate %d IDs", n)
}
return low, high, nil
}
// AllocateIDRange allocates a range of IDs with specific endpoints.
// The range is inclusive at both the low and high end. Once these IDs have been
// allocated, you can manually assign them to newly created entities.
//
// The Datastore's automatic ID allocator never assigns a key that has already
// been allocated (either through automatic ID allocation or through an explicit
// AllocateIDs call). As a result, entities written to the given key range will
// never be overwritten. However, writing entities with manually assigned keys in
// this range may overwrite existing entities (or new entities written by a separate
// request), depending on the error returned.
//
// Use this only if you have an existing numeric ID range that you want to reserve
// (for example, bulk loading entities that already have IDs). If you don't care
// about which IDs you receive, use AllocateIDs instead.
//
// AllocateIDRange returns nil if the range is successfully allocated. If one or more
// entities with an ID in the given range already exist, it returns a KeyRangeCollisionError.
// If the Datastore has already cached IDs in this range (e.g. from a previous call to
// AllocateIDRange), it returns a KeyRangeContentionError. Errors of other types indicate
// problems with arguments or an error returned directly from the Datastore.
func AllocateIDRange(c context.Context, kind string, parent *Key, start, end int64) (err error) {
if kind == "" {
return errors.New("datastore: AllocateIDRange given an empty kind")
}
if start < 1 || end < 1 {
return errors.New("datastore: AllocateIDRange start and end must both be greater than 0")
}
if start > end {
return errors.New("datastore: AllocateIDRange start must be before end")
}
req := &pb.AllocateIdsRequest{
ModelKey: keyToProto("", NewIncompleteKey(c, kind, parent)),
Max: proto.Int64(end),
}
res := &pb.AllocateIdsResponse{}
if err := internal.Call(c, "datastore_v3", "AllocateIds", req, res); err != nil {
return err
}
// Check for collisions, i.e. existing entities with IDs in this range.
// We could do this before the allocation, but we'd still have to do it
// afterward as well to catch the race condition where an entity is inserted
// after that initial check but before the allocation. Skip the up-front check
// and just do it once.
q := NewQuery(kind).Filter("__key__ >=", NewKey(c, kind, "", start, parent)).
Filter("__key__ <=", NewKey(c, kind, "", end, parent)).KeysOnly().Limit(1)
keys, err := q.GetAll(c, nil)
if err != nil {
return err
}
if len(keys) != 0 {
return &KeyRangeCollisionError{start: start, end: end}
}
// Check for a race condition, i.e. cases where the datastore may have
// cached ID batches that contain IDs in this range.
if start < res.GetStart() {
return &KeyRangeContentionError{start: start, end: end}
}
return nil
}

View File

@ -1,204 +0,0 @@
// Copyright 2011 Google Inc. All Rights Reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package datastore
import (
"bytes"
"encoding/gob"
"encoding/json"
"testing"
"golang.org/x/net/context"
"google.golang.org/appengine/internal"
)
func TestKeyEncoding(t *testing.T) {
testCases := []struct {
desc string
key *Key
exp string
}{
{
desc: "A simple key with an int ID",
key: &Key{
kind: "Person",
intID: 1,
appID: "glibrary",
},
exp: "aghnbGlicmFyeXIMCxIGUGVyc29uGAEM",
},
{
desc: "A simple key with a string ID",
key: &Key{
kind: "Graph",
stringID: "graph:7-day-active",
appID: "glibrary",
},
exp: "aghnbGlicmFyeXIdCxIFR3JhcGgiEmdyYXBoOjctZGF5LWFjdGl2ZQw",
},
{
desc: "A key with a parent",
key: &Key{
kind: "WordIndex",
intID: 1033,
parent: &Key{
kind: "WordIndex",
intID: 1020032,
appID: "glibrary",
},
appID: "glibrary",
},
exp: "aghnbGlicmFyeXIhCxIJV29yZEluZGV4GIChPgwLEglXb3JkSW5kZXgYiQgM",
},
}
for _, tc := range testCases {
enc := tc.key.Encode()
if enc != tc.exp {
t.Errorf("%s: got %q, want %q", tc.desc, enc, tc.exp)
}
key, err := DecodeKey(tc.exp)
if err != nil {
t.Errorf("%s: failed decoding key: %v", tc.desc, err)
continue
}
if !key.Equal(tc.key) {
t.Errorf("%s: decoded key %v, want %v", tc.desc, key, tc.key)
}
}
}
func TestKeyGob(t *testing.T) {
k := &Key{
kind: "Gopher",
intID: 3,
parent: &Key{
kind: "Mom",
stringID: "narwhal",
appID: "gopher-con",
},
appID: "gopher-con",
}
buf := new(bytes.Buffer)
if err := gob.NewEncoder(buf).Encode(k); err != nil {
t.Fatalf("gob encode failed: %v", err)
}
k2 := new(Key)
if err := gob.NewDecoder(buf).Decode(k2); err != nil {
t.Fatalf("gob decode failed: %v", err)
}
if !k2.Equal(k) {
t.Errorf("gob round trip of %v produced %v", k, k2)
}
}
func TestNilKeyGob(t *testing.T) {
type S struct {
Key *Key
}
s1 := new(S)
buf := new(bytes.Buffer)
if err := gob.NewEncoder(buf).Encode(s1); err != nil {
t.Fatalf("gob encode failed: %v", err)
}
s2 := new(S)
if err := gob.NewDecoder(buf).Decode(s2); err != nil {
t.Fatalf("gob decode failed: %v", err)
}
if s2.Key != nil {
t.Errorf("gob round trip of nil key produced %v", s2.Key)
}
}
func TestKeyJSON(t *testing.T) {
k := &Key{
kind: "Gopher",
intID: 2,
parent: &Key{
kind: "Mom",
stringID: "narwhal",
appID: "gopher-con",
},
appID: "gopher-con",
}
exp := `"` + k.Encode() + `"`
buf, err := json.Marshal(k)
if err != nil {
t.Fatalf("json.Marshal failed: %v", err)
}
if s := string(buf); s != exp {
t.Errorf("JSON encoding of key %v: got %q, want %q", k, s, exp)
}
k2 := new(Key)
if err := json.Unmarshal(buf, k2); err != nil {
t.Fatalf("json.Unmarshal failed: %v", err)
}
if !k2.Equal(k) {
t.Errorf("JSON round trip of %v produced %v", k, k2)
}
}
func TestNilKeyJSON(t *testing.T) {
type S struct {
Key *Key
}
s1 := new(S)
buf, err := json.Marshal(s1)
if err != nil {
t.Fatalf("json.Marshal failed: %v", err)
}
s2 := new(S)
if err := json.Unmarshal(buf, s2); err != nil {
t.Fatalf("json.Unmarshal failed: %v", err)
}
if s2.Key != nil {
t.Errorf("JSON round trip of nil key produced %v", s2.Key)
}
}
func TestIncompleteKeyWithParent(t *testing.T) {
c := internal.WithAppIDOverride(context.Background(), "s~some-app")
// fadduh is a complete key.
fadduh := NewKey(c, "Person", "", 1, nil)
if fadduh.Incomplete() {
t.Fatalf("fadduh is incomplete")
}
// robert is an incomplete key with fadduh as a parent.
robert := NewIncompleteKey(c, "Person", fadduh)
if !robert.Incomplete() {
t.Fatalf("robert is complete")
}
// Both should be valid keys.
if !fadduh.valid() {
t.Errorf("fadduh is invalid: %v", fadduh)
}
if !robert.valid() {
t.Errorf("robert is invalid: %v", robert)
}
}
func TestNamespace(t *testing.T) {
key := &Key{
kind: "Person",
intID: 1,
appID: "s~some-app",
namespace: "mynamespace",
}
if g, w := key.Namespace(), "mynamespace"; g != w {
t.Errorf("key.Namespace() = %q, want %q", g, w)
}
}

View File

@ -1,429 +0,0 @@
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package datastore
import (
"fmt"
"reflect"
"strings"
"time"
"github.com/golang/protobuf/proto"
"google.golang.org/appengine"
pb "google.golang.org/appengine/internal/datastore"
)
var (
typeOfBlobKey = reflect.TypeOf(appengine.BlobKey(""))
typeOfByteSlice = reflect.TypeOf([]byte(nil))
typeOfByteString = reflect.TypeOf(ByteString(nil))
typeOfGeoPoint = reflect.TypeOf(appengine.GeoPoint{})
typeOfTime = reflect.TypeOf(time.Time{})
typeOfKeyPtr = reflect.TypeOf(&Key{})
typeOfEntityPtr = reflect.TypeOf(&Entity{})
)
// typeMismatchReason returns a string explaining why the property p could not
// be stored in an entity field of type v.Type().
func typeMismatchReason(pValue interface{}, v reflect.Value) string {
entityType := "empty"
switch pValue.(type) {
case int64:
entityType = "int"
case bool:
entityType = "bool"
case string:
entityType = "string"
case float64:
entityType = "float"
case *Key:
entityType = "*datastore.Key"
case time.Time:
entityType = "time.Time"
case appengine.BlobKey:
entityType = "appengine.BlobKey"
case appengine.GeoPoint:
entityType = "appengine.GeoPoint"
case ByteString:
entityType = "datastore.ByteString"
case []byte:
entityType = "[]byte"
}
return fmt.Sprintf("type mismatch: %s versus %v", entityType, v.Type())
}
type propertyLoader struct {
// m holds the number of times a substruct field like "Foo.Bar.Baz" has
// been seen so far. The map is constructed lazily.
m map[string]int
}
func (l *propertyLoader) load(codec *structCodec, structValue reflect.Value, p Property, requireSlice bool) string {
var v reflect.Value
var sliceIndex int
name := p.Name
// If name ends with a '.', the last field is anonymous.
// In this case, strings.Split will give us "" as the
// last element of our fields slice, which will match the ""
// field name in the substruct codec.
fields := strings.Split(name, ".")
for len(fields) > 0 {
var decoder fieldCodec
var ok bool
// Cut off the last field (delimited by ".") and find its parent
// in the codec.
// eg. for name "A.B.C.D", split off "A.B.C" and try to
// find a field in the codec with this name.
// Loop again with "A.B", etc.
for i := len(fields); i > 0; i-- {
parent := strings.Join(fields[:i], ".")
decoder, ok = codec.fields[parent]
if ok {
fields = fields[i:]
break
}
}
// If we never found a matching field in the codec, return
// error message.
if !ok {
return "no such struct field"
}
v = initField(structValue, decoder.path)
if !v.IsValid() {
return "no such struct field"
}
if !v.CanSet() {
return "cannot set struct field"
}
if decoder.structCodec != nil {
codec = decoder.structCodec
structValue = v
}
if v.Kind() == reflect.Slice && v.Type() != typeOfByteSlice {
if l.m == nil {
l.m = make(map[string]int)
}
sliceIndex = l.m[p.Name]
l.m[p.Name] = sliceIndex + 1
for v.Len() <= sliceIndex {
v.Set(reflect.Append(v, reflect.New(v.Type().Elem()).Elem()))
}
structValue = v.Index(sliceIndex)
requireSlice = false
}
}
var slice reflect.Value
if v.Kind() == reflect.Slice && v.Type().Elem().Kind() != reflect.Uint8 {
slice = v
v = reflect.New(v.Type().Elem()).Elem()
} else if requireSlice {
return "multiple-valued property requires a slice field type"
}
// Convert indexValues to a Go value with a meaning derived from the
// destination type.
pValue := p.Value
if iv, ok := pValue.(indexValue); ok {
meaning := pb.Property_NO_MEANING
switch v.Type() {
case typeOfBlobKey:
meaning = pb.Property_BLOBKEY
case typeOfByteSlice:
meaning = pb.Property_BLOB
case typeOfByteString:
meaning = pb.Property_BYTESTRING
case typeOfGeoPoint:
meaning = pb.Property_GEORSS_POINT
case typeOfTime:
meaning = pb.Property_GD_WHEN
case typeOfEntityPtr:
meaning = pb.Property_ENTITY_PROTO
}
var err error
pValue, err = propValue(iv.value, meaning)
if err != nil {
return err.Error()
}
}
if errReason := setVal(v, pValue); errReason != "" {
// Set the slice back to its zero value.
if slice.IsValid() {
slice.Set(reflect.Zero(slice.Type()))
}
return errReason
}
if slice.IsValid() {
slice.Index(sliceIndex).Set(v)
}
return ""
}
// setVal sets v to the value pValue.
func setVal(v reflect.Value, pValue interface{}) string {
switch v.Kind() {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
x, ok := pValue.(int64)
if !ok && pValue != nil {
return typeMismatchReason(pValue, v)
}
if v.OverflowInt(x) {
return fmt.Sprintf("value %v overflows struct field of type %v", x, v.Type())
}
v.SetInt(x)
case reflect.Bool:
x, ok := pValue.(bool)
if !ok && pValue != nil {
return typeMismatchReason(pValue, v)
}
v.SetBool(x)
case reflect.String:
switch x := pValue.(type) {
case appengine.BlobKey:
v.SetString(string(x))
case ByteString:
v.SetString(string(x))
case string:
v.SetString(x)
default:
if pValue != nil {
return typeMismatchReason(pValue, v)
}
}
case reflect.Float32, reflect.Float64:
x, ok := pValue.(float64)
if !ok && pValue != nil {
return typeMismatchReason(pValue, v)
}
if v.OverflowFloat(x) {
return fmt.Sprintf("value %v overflows struct field of type %v", x, v.Type())
}
v.SetFloat(x)
case reflect.Ptr:
x, ok := pValue.(*Key)
if !ok && pValue != nil {
return typeMismatchReason(pValue, v)
}
if _, ok := v.Interface().(*Key); !ok {
return typeMismatchReason(pValue, v)
}
v.Set(reflect.ValueOf(x))
case reflect.Struct:
switch v.Type() {
case typeOfTime:
x, ok := pValue.(time.Time)
if !ok && pValue != nil {
return typeMismatchReason(pValue, v)
}
v.Set(reflect.ValueOf(x))
case typeOfGeoPoint:
x, ok := pValue.(appengine.GeoPoint)
if !ok && pValue != nil {
return typeMismatchReason(pValue, v)
}
v.Set(reflect.ValueOf(x))
default:
ent, ok := pValue.(*Entity)
if !ok {
return typeMismatchReason(pValue, v)
}
// Recursively load nested struct
pls, err := newStructPLS(v.Addr().Interface())
if err != nil {
return err.Error()
}
// if ent has a Key value and our struct has a Key field,
// load the Entity's Key value into the Key field on the struct.
if ent.Key != nil && pls.codec.keyField != -1 {
pls.v.Field(pls.codec.keyField).Set(reflect.ValueOf(ent.Key))
}
err = pls.Load(ent.Properties)
if err != nil {
return err.Error()
}
}
case reflect.Slice:
x, ok := pValue.([]byte)
if !ok {
if y, yok := pValue.(ByteString); yok {
x, ok = []byte(y), true
}
}
if !ok && pValue != nil {
return typeMismatchReason(pValue, v)
}
if v.Type().Elem().Kind() != reflect.Uint8 {
return typeMismatchReason(pValue, v)
}
v.SetBytes(x)
default:
return typeMismatchReason(pValue, v)
}
return ""
}
// initField is similar to reflect's Value.FieldByIndex, in that it
// returns the nested struct field corresponding to index, but it
// initialises any nil pointers encountered when traversing the structure.
func initField(val reflect.Value, index []int) reflect.Value {
for _, i := range index[:len(index)-1] {
val = val.Field(i)
if val.Kind() == reflect.Ptr {
if val.IsNil() {
val.Set(reflect.New(val.Type().Elem()))
}
val = val.Elem()
}
}
return val.Field(index[len(index)-1])
}
// loadEntity loads an EntityProto into PropertyLoadSaver or struct pointer.
func loadEntity(dst interface{}, src *pb.EntityProto) (err error) {
ent, err := protoToEntity(src)
if err != nil {
return err
}
if e, ok := dst.(PropertyLoadSaver); ok {
return e.Load(ent.Properties)
}
return LoadStruct(dst, ent.Properties)
}
func (s structPLS) Load(props []Property) error {
var fieldName, reason string
var l propertyLoader
for _, p := range props {
if errStr := l.load(s.codec, s.v, p, p.Multiple); errStr != "" {
// We don't return early, as we try to load as many properties as possible.
// It is valid to load an entity into a struct that cannot fully represent it.
// That case returns an error, but the caller is free to ignore it.
fieldName, reason = p.Name, errStr
}
}
if reason != "" {
return &ErrFieldMismatch{
StructType: s.v.Type(),
FieldName: fieldName,
Reason: reason,
}
}
return nil
}
func protoToEntity(src *pb.EntityProto) (*Entity, error) {
props, rawProps := src.Property, src.RawProperty
outProps := make([]Property, 0, len(props)+len(rawProps))
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{}
if x.Meaning != nil && *x.Meaning == pb.Property_INDEX_VALUE {
value = indexValue{x.Value}
} else {
var err error
value, err = propValue(x.Value, x.GetMeaning())
if err != nil {
return nil, err
}
}
outProps = append(outProps, Property{
Name: x.GetName(),
Value: value,
NoIndex: noIndex,
Multiple: x.GetMultiple(),
})
}
var key *Key
if src.Key != nil {
// Ignore any error, since nested entity values
// are allowed to have an invalid key.
key, _ = protoToKey(src.Key)
}
return &Entity{key, outProps}, nil
}
// propValue returns a Go value that combines the raw PropertyValue with a
// meaning. For example, an Int64Value with GD_WHEN becomes a time.Time.
func propValue(v *pb.PropertyValue, m pb.Property_Meaning) (interface{}, error) {
switch {
case v.Int64Value != nil:
if m == pb.Property_GD_WHEN {
return fromUnixMicro(*v.Int64Value), nil
} else {
return *v.Int64Value, nil
}
case v.BooleanValue != nil:
return *v.BooleanValue, nil
case v.StringValue != nil:
if m == pb.Property_BLOB {
return []byte(*v.StringValue), nil
} else if m == pb.Property_BLOBKEY {
return appengine.BlobKey(*v.StringValue), nil
} else if m == pb.Property_BYTESTRING {
return ByteString(*v.StringValue), nil
} else if m == pb.Property_ENTITY_PROTO {
var ent pb.EntityProto
err := proto.Unmarshal([]byte(*v.StringValue), &ent)
if err != nil {
return nil, err
}
return protoToEntity(&ent)
} else {
return *v.StringValue, nil
}
case v.DoubleValue != nil:
return *v.DoubleValue, nil
case v.Referencevalue != nil:
key, err := referenceValueToKey(v.Referencevalue)
if err != nil {
return nil, err
}
return key, nil
case v.Pointvalue != nil:
// NOTE: Strangely, latitude maps to X, longitude to Y.
return appengine.GeoPoint{Lat: v.Pointvalue.GetX(), Lng: v.Pointvalue.GetY()}, nil
}
return nil, nil
}
// indexValue is a Property value that is created when entities are loaded from
// an index, such as from a projection query.
//
// Such Property values do not contain all of the metadata required to be
// faithfully represented as a Go value, and are instead represented as an
// opaque indexValue. Load the properties into a concrete struct type (e.g. by
// passing a struct pointer to Iterator.Next) to reconstruct actual Go values
// of type int, string, time.Time, etc.
type indexValue struct {
value *pb.PropertyValue
}

View File

@ -1,656 +0,0 @@
// Copyright 2016 Google Inc. All Rights Reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package datastore
import (
"reflect"
"testing"
proto "github.com/golang/protobuf/proto"
pb "google.golang.org/appengine/internal/datastore"
)
type Simple struct {
I int64
}
type SimpleWithTag struct {
I int64 `datastore:"II"`
}
type NestedSimpleWithTag struct {
A SimpleWithTag `datastore:"AA"`
}
type NestedSliceOfSimple struct {
A []Simple
}
type SimpleTwoFields struct {
S string
SS string
}
type NestedSimpleAnonymous struct {
Simple
X string
}
type NestedSimple struct {
A Simple
I int64
}
type NestedSimple1 struct {
A Simple
X string
}
type NestedSimple2X struct {
AA NestedSimple
A SimpleTwoFields
S string
}
type BDotB struct {
B string `datastore:"B.B"`
}
type ABDotB struct {
A BDotB
}
type MultiAnonymous struct {
Simple
SimpleTwoFields
X string
}
var (
// these values need to be addressable
testString2 = "two"
testString3 = "three"
testInt64 = int64(2)
fieldNameI = "I"
fieldNameX = "X"
fieldNameS = "S"
fieldNameSS = "SS"
fieldNameADotI = "A.I"
fieldNameAADotII = "AA.II"
fieldNameADotBDotB = "A.B.B"
)
func TestLoadEntityNestedLegacy(t *testing.T) {
testCases := []struct {
desc string
src *pb.EntityProto
want interface{}
}{
{
"nested",
&pb.EntityProto{
Key: keyToProto("some-app-id", testKey0),
Property: []*pb.Property{
&pb.Property{
Name: &fieldNameX,
Value: &pb.PropertyValue{
StringValue: &testString2,
},
},
&pb.Property{
Name: &fieldNameADotI,
Value: &pb.PropertyValue{
Int64Value: &testInt64,
},
},
},
},
&NestedSimple1{
A: Simple{I: testInt64},
X: testString2,
},
},
{
"nested with tag",
&pb.EntityProto{
Key: keyToProto("some-app-id", testKey0),
Property: []*pb.Property{
&pb.Property{
Name: &fieldNameAADotII,
Value: &pb.PropertyValue{
Int64Value: &testInt64,
},
},
},
},
&NestedSimpleWithTag{
A: SimpleWithTag{I: testInt64},
},
},
{
"nested with anonymous struct field",
&pb.EntityProto{
Key: keyToProto("some-app-id", testKey0),
Property: []*pb.Property{
&pb.Property{
Name: &fieldNameX,
Value: &pb.PropertyValue{
StringValue: &testString2,
},
},
&pb.Property{
Name: &fieldNameI,
Value: &pb.PropertyValue{
Int64Value: &testInt64,
},
},
},
},
&NestedSimpleAnonymous{
Simple: Simple{I: testInt64},
X: testString2,
},
},
{
"nested with dotted field tag",
&pb.EntityProto{
Key: keyToProto("some-app-id", testKey0),
Property: []*pb.Property{
&pb.Property{
Name: &fieldNameADotBDotB,
Value: &pb.PropertyValue{
StringValue: &testString2,
},
},
},
},
&ABDotB{
A: BDotB{
B: testString2,
},
},
},
{
"nested with dotted field tag",
&pb.EntityProto{
Key: keyToProto("some-app-id", testKey0),
Property: []*pb.Property{
&pb.Property{
Name: &fieldNameI,
Value: &pb.PropertyValue{
Int64Value: &testInt64,
},
},
&pb.Property{
Name: &fieldNameS,
Value: &pb.PropertyValue{
StringValue: &testString2,
},
},
&pb.Property{
Name: &fieldNameSS,
Value: &pb.PropertyValue{
StringValue: &testString3,
},
},
&pb.Property{
Name: &fieldNameX,
Value: &pb.PropertyValue{
StringValue: &testString3,
},
},
},
},
&MultiAnonymous{
Simple: Simple{I: testInt64},
SimpleTwoFields: SimpleTwoFields{S: "two", SS: "three"},
X: "three",
},
},
}
for _, tc := range testCases {
dst := reflect.New(reflect.TypeOf(tc.want).Elem()).Interface()
err := loadEntity(dst, tc.src)
if err != nil {
t.Errorf("loadEntity: %s: %v", tc.desc, err)
continue
}
if !reflect.DeepEqual(tc.want, dst) {
t.Errorf("%s: compare:\ngot: %#v\nwant: %#v", tc.desc, dst, tc.want)
}
}
}
type WithKey struct {
X string
I int64
K *Key `datastore:"__key__"`
}
type NestedWithKey struct {
N WithKey
Y string
}
var (
incompleteKey = newKey("", nil)
invalidKey = newKey("s", incompleteKey)
// these values need to be addressable
fieldNameA = "A"
fieldNameK = "K"
fieldNameN = "N"
fieldNameY = "Y"
fieldNameAA = "AA"
fieldNameII = "II"
fieldNameBDotB = "B.B"
entityProtoMeaning = pb.Property_ENTITY_PROTO
TRUE = true
FALSE = false
)
var (
simpleEntityProto, nestedSimpleEntityProto,
simpleTwoFieldsEntityProto, simpleWithTagEntityProto,
bDotBEntityProto, withKeyEntityProto string
)
func init() {
// simpleEntityProto corresponds to:
// Simple{I: testInt64}
simpleEntityProtob, err := proto.Marshal(&pb.EntityProto{
Key: keyToProto("", incompleteKey),
Property: []*pb.Property{
&pb.Property{
Name: &fieldNameI,
Value: &pb.PropertyValue{
Int64Value: &testInt64,
},
Multiple: &FALSE,
},
},
EntityGroup: &pb.Path{},
})
if err != nil {
panic(err)
}
simpleEntityProto = string(simpleEntityProtob)
// nestedSimpleEntityProto corresponds to:
// NestedSimple{
// A: Simple{I: testInt64},
// I: testInt64,
// }
nestedSimpleEntityProtob, err := proto.Marshal(&pb.EntityProto{
Key: keyToProto("", incompleteKey),
Property: []*pb.Property{
&pb.Property{
Name: &fieldNameA,
Meaning: &entityProtoMeaning,
Value: &pb.PropertyValue{
StringValue: &simpleEntityProto,
},
Multiple: &FALSE,
},
&pb.Property{
Name: &fieldNameI,
Meaning: &entityProtoMeaning,
Value: &pb.PropertyValue{
Int64Value: &testInt64,
},
Multiple: &FALSE,
},
},
EntityGroup: &pb.Path{},
})
if err != nil {
panic(err)
}
nestedSimpleEntityProto = string(nestedSimpleEntityProtob)
// simpleTwoFieldsEntityProto corresponds to:
// SimpleTwoFields{S: testString2, SS: testString3}
simpleTwoFieldsEntityProtob, err := proto.Marshal(&pb.EntityProto{
Key: keyToProto("", incompleteKey),
Property: []*pb.Property{
&pb.Property{
Name: &fieldNameS,
Value: &pb.PropertyValue{
StringValue: &testString2,
},
Multiple: &FALSE,
},
&pb.Property{
Name: &fieldNameSS,
Value: &pb.PropertyValue{
StringValue: &testString3,
},
Multiple: &FALSE,
},
},
EntityGroup: &pb.Path{},
})
if err != nil {
panic(err)
}
simpleTwoFieldsEntityProto = string(simpleTwoFieldsEntityProtob)
// simpleWithTagEntityProto corresponds to:
// SimpleWithTag{I: testInt64}
simpleWithTagEntityProtob, err := proto.Marshal(&pb.EntityProto{
Key: keyToProto("", incompleteKey),
Property: []*pb.Property{
&pb.Property{
Name: &fieldNameII,
Value: &pb.PropertyValue{
Int64Value: &testInt64,
},
Multiple: &FALSE,
},
},
EntityGroup: &pb.Path{},
})
if err != nil {
panic(err)
}
simpleWithTagEntityProto = string(simpleWithTagEntityProtob)
// bDotBEntityProto corresponds to:
// BDotB{
// B: testString2,
// }
bDotBEntityProtob, err := proto.Marshal(&pb.EntityProto{
Key: keyToProto("", incompleteKey),
Property: []*pb.Property{
&pb.Property{
Name: &fieldNameBDotB,
Value: &pb.PropertyValue{
StringValue: &testString2,
},
Multiple: &FALSE,
},
},
EntityGroup: &pb.Path{},
})
if err != nil {
panic(err)
}
bDotBEntityProto = string(bDotBEntityProtob)
// withKeyEntityProto corresponds to:
// WithKey{
// X: testString3,
// I: testInt64,
// K: testKey1a,
// }
withKeyEntityProtob, err := proto.Marshal(&pb.EntityProto{
Key: keyToProto("", testKey1a),
Property: []*pb.Property{
&pb.Property{
Name: &fieldNameX,
Value: &pb.PropertyValue{
StringValue: &testString3,
},
Multiple: &FALSE,
},
&pb.Property{
Name: &fieldNameI,
Value: &pb.PropertyValue{
Int64Value: &testInt64,
},
Multiple: &FALSE,
},
},
EntityGroup: &pb.Path{},
})
if err != nil {
panic(err)
}
withKeyEntityProto = string(withKeyEntityProtob)
}
func TestLoadEntityNested(t *testing.T) {
testCases := []struct {
desc string
src *pb.EntityProto
want interface{}
}{
{
"nested basic",
&pb.EntityProto{
Key: keyToProto("some-app-id", testKey0),
Property: []*pb.Property{
&pb.Property{
Name: &fieldNameA,
Meaning: &entityProtoMeaning,
Value: &pb.PropertyValue{
StringValue: &simpleEntityProto,
},
},
&pb.Property{
Name: &fieldNameI,
Value: &pb.PropertyValue{
Int64Value: &testInt64,
},
},
},
},
&NestedSimple{
A: Simple{I: 2},
I: 2,
},
},
{
"nested with struct tags",
&pb.EntityProto{
Key: keyToProto("some-app-id", testKey0),
Property: []*pb.Property{
&pb.Property{
Name: &fieldNameAA,
Meaning: &entityProtoMeaning,
Value: &pb.PropertyValue{
StringValue: &simpleWithTagEntityProto,
},
},
},
},
&NestedSimpleWithTag{
A: SimpleWithTag{I: testInt64},
},
},
{
"nested 2x",
&pb.EntityProto{
Key: keyToProto("some-app-id", testKey0),
Property: []*pb.Property{
&pb.Property{
Name: &fieldNameAA,
Meaning: &entityProtoMeaning,
Value: &pb.PropertyValue{
StringValue: &nestedSimpleEntityProto,
},
},
&pb.Property{
Name: &fieldNameA,
Meaning: &entityProtoMeaning,
Value: &pb.PropertyValue{
StringValue: &simpleTwoFieldsEntityProto,
},
},
&pb.Property{
Name: &fieldNameS,
Value: &pb.PropertyValue{
StringValue: &testString3,
},
},
},
},
&NestedSimple2X{
AA: NestedSimple{
A: Simple{I: testInt64},
I: testInt64,
},
A: SimpleTwoFields{S: testString2, SS: testString3},
S: testString3,
},
},
{
"nested anonymous",
&pb.EntityProto{
Key: keyToProto("some-app-id", testKey0),
Property: []*pb.Property{
&pb.Property{
Name: &fieldNameI,
Value: &pb.PropertyValue{
Int64Value: &testInt64,
},
},
&pb.Property{
Name: &fieldNameX,
Value: &pb.PropertyValue{
StringValue: &testString2,
},
},
},
},
&NestedSimpleAnonymous{
Simple: Simple{I: testInt64},
X: testString2,
},
},
{
"nested simple with slice",
&pb.EntityProto{
Key: keyToProto("some-app-id", testKey0),
Property: []*pb.Property{
&pb.Property{
Name: &fieldNameA,
Meaning: &entityProtoMeaning,
Multiple: &TRUE,
Value: &pb.PropertyValue{
StringValue: &simpleEntityProto,
},
},
&pb.Property{
Name: &fieldNameA,
Meaning: &entityProtoMeaning,
Multiple: &TRUE,
Value: &pb.PropertyValue{
StringValue: &simpleEntityProto,
},
},
},
},
&NestedSliceOfSimple{
A: []Simple{Simple{I: testInt64}, Simple{I: testInt64}},
},
},
{
"nested with multiple anonymous fields",
&pb.EntityProto{
Key: keyToProto("some-app-id", testKey0),
Property: []*pb.Property{
&pb.Property{
Name: &fieldNameI,
Value: &pb.PropertyValue{
Int64Value: &testInt64,
},
},
&pb.Property{
Name: &fieldNameS,
Value: &pb.PropertyValue{
StringValue: &testString2,
},
},
&pb.Property{
Name: &fieldNameSS,
Value: &pb.PropertyValue{
StringValue: &testString3,
},
},
&pb.Property{
Name: &fieldNameX,
Value: &pb.PropertyValue{
StringValue: &testString2,
},
},
},
},
&MultiAnonymous{
Simple: Simple{I: testInt64},
SimpleTwoFields: SimpleTwoFields{S: testString2, SS: testString3},
X: testString2,
},
},
{
"nested with dotted field tag",
&pb.EntityProto{
Key: keyToProto("some-app-id", testKey0),
Property: []*pb.Property{
&pb.Property{
Name: &fieldNameA,
Meaning: &entityProtoMeaning,
Value: &pb.PropertyValue{
StringValue: &bDotBEntityProto,
},
},
},
},
&ABDotB{
A: BDotB{
B: testString2,
},
},
},
{
"nested entity with key",
&pb.EntityProto{
Key: keyToProto("some-app-id", testKey0),
Property: []*pb.Property{
&pb.Property{
Name: &fieldNameY,
Value: &pb.PropertyValue{
StringValue: &testString2,
},
},
&pb.Property{
Name: &fieldNameN,
Meaning: &entityProtoMeaning,
Value: &pb.PropertyValue{
StringValue: &withKeyEntityProto,
},
},
},
},
&NestedWithKey{
Y: testString2,
N: WithKey{
X: testString3,
I: testInt64,
K: testKey1a,
},
},
},
}
for _, tc := range testCases {
dst := reflect.New(reflect.TypeOf(tc.want).Elem()).Interface()
err := loadEntity(dst, tc.src)
if err != nil {
t.Errorf("loadEntity: %s: %v", tc.desc, err)
continue
}
if !reflect.DeepEqual(tc.want, dst) {
t.Errorf("%s: compare:\ngot: %#v\nwant: %#v", tc.desc, dst, tc.want)
}
}
}

View File

@ -1,78 +0,0 @@
// Copyright 2016 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package datastore
import "golang.org/x/net/context"
// Datastore kinds for the metadata entities.
const (
namespaceKind = "__namespace__"
kindKind = "__kind__"
propertyKind = "__property__"
)
// Namespaces returns all the datastore namespaces.
func Namespaces(ctx context.Context) ([]string, error) {
// TODO(djd): Support range queries.
q := NewQuery(namespaceKind).KeysOnly()
keys, err := q.GetAll(ctx, nil)
if err != nil {
return nil, err
}
// The empty namespace key uses a numeric ID (==1), but luckily
// the string ID defaults to "" for numeric IDs anyway.
return keyNames(keys), nil
}
// Kinds returns the names of all the kinds in the current namespace.
func Kinds(ctx context.Context) ([]string, error) {
// TODO(djd): Support range queries.
q := NewQuery(kindKind).KeysOnly()
keys, err := q.GetAll(ctx, nil)
if err != nil {
return nil, err
}
return keyNames(keys), nil
}
// keyNames returns a slice of the provided keys' names (string IDs).
func keyNames(keys []*Key) []string {
n := make([]string, 0, len(keys))
for _, k := range keys {
n = append(n, k.StringID())
}
return n
}
// KindProperties returns all the indexed properties for the given kind.
// The properties are returned as a map of property names to a slice of the
// representation types. The representation types for the supported Go property
// types are:
// "INT64": signed integers and time.Time
// "DOUBLE": float32 and float64
// "BOOLEAN": bool
// "STRING": string, []byte and ByteString
// "POINT": appengine.GeoPoint
// "REFERENCE": *Key
// "USER": (not used in the Go runtime)
func KindProperties(ctx context.Context, kind string) (map[string][]string, error) {
// TODO(djd): Support range queries.
kindKey := NewKey(ctx, kindKind, kind, 0, nil)
q := NewQuery(propertyKind).Ancestor(kindKey)
propMap := map[string][]string{}
props := []struct {
Repr []string `datastore:"property_representation"`
}{}
keys, err := q.GetAll(ctx, &props)
if err != nil {
return nil, err
}
for i, p := range props {
propMap[keys[i].StringID()] = p.Repr
}
return propMap, nil
}

View File

@ -1,330 +0,0 @@
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package datastore
import (
"fmt"
"reflect"
"strings"
"sync"
"unicode"
)
// Entities with more than this many indexed properties will not be saved.
const maxIndexedProperties = 20000
// []byte fields more than 1 megabyte long will not be loaded or saved.
const maxBlobLen = 1 << 20
// Property is a name/value pair plus some metadata. A datastore entity's
// contents are loaded and saved as a sequence of Properties. An entity can
// have multiple Properties with the same name, provided that p.Multiple is
// true on all of that entity's Properties with that name.
type Property struct {
// Name is the property name.
Name string
// Value is the property value. The valid types are:
// - int64
// - bool
// - string
// - float64
// - ByteString
// - *Key
// - time.Time
// - appengine.BlobKey
// - appengine.GeoPoint
// - []byte (up to 1 megabyte in length)
// - *Entity (representing a nested struct)
// This set is smaller than the set of valid struct field types that the
// datastore can load and save. A Property Value cannot be a slice (apart
// from []byte); use multiple Properties instead. Also, a Value's type
// must be explicitly on the list above; it is not sufficient for the
// underlying type to be on that list. For example, a Value of "type
// myInt64 int64" is invalid. Smaller-width integers and floats are also
// invalid. Again, this is more restrictive than the set of valid struct
// field types.
//
// A Value will have an opaque type when loading entities from an index,
// such as via a projection query. Load entities into a struct instead
// of a PropertyLoadSaver when using a projection query.
//
// A Value may also be the nil interface value; this is equivalent to
// Python's None but not directly representable by a Go struct. Loading
// a nil-valued property into a struct will set that field to the zero
// value.
Value interface{}
// NoIndex is whether the datastore cannot index this property.
NoIndex bool
// Multiple is whether the entity can have multiple properties with
// the same name. Even if a particular instance only has one property with
// a certain name, Multiple should be true if a struct would best represent
// it as a field of type []T instead of type T.
Multiple bool
}
// An Entity is the value type for a nested struct.
// This type is only used for a Property's Value.
type Entity struct {
Key *Key
Properties []Property
}
// ByteString is a short byte slice (up to 1500 bytes) that can be indexed.
type ByteString []byte
// PropertyLoadSaver can be converted from and to a slice of Properties.
type PropertyLoadSaver interface {
Load([]Property) error
Save() ([]Property, error)
}
// PropertyList converts a []Property to implement PropertyLoadSaver.
type PropertyList []Property
var (
typeOfPropertyLoadSaver = reflect.TypeOf((*PropertyLoadSaver)(nil)).Elem()
typeOfPropertyList = reflect.TypeOf(PropertyList(nil))
)
// Load loads all of the provided properties into l.
// It does not first reset *l to an empty slice.
func (l *PropertyList) Load(p []Property) error {
*l = append(*l, p...)
return nil
}
// Save saves all of l's properties as a slice or Properties.
func (l *PropertyList) Save() ([]Property, error) {
return *l, nil
}
// validPropertyName returns whether name consists of one or more valid Go
// identifiers joined by ".".
func validPropertyName(name string) bool {
if name == "" {
return false
}
for _, s := range strings.Split(name, ".") {
if s == "" {
return false
}
first := true
for _, c := range s {
if first {
first = false
if c != '_' && !unicode.IsLetter(c) {
return false
}
} else {
if c != '_' && !unicode.IsLetter(c) && !unicode.IsDigit(c) {
return false
}
}
}
}
return true
}
// structCodec describes how to convert a struct to and from a sequence of
// properties.
type structCodec struct {
// fields gives the field codec for the structTag with the given name.
fields map[string]fieldCodec
// hasSlice is whether a struct or any of its nested or embedded structs
// has a slice-typed field (other than []byte).
hasSlice bool
// keyField is the index of a *Key field with structTag __key__.
// This field is not relevant for the top level struct, only for
// nested structs.
keyField int
// complete is whether the structCodec is complete. An incomplete
// structCodec may be encountered when walking a recursive struct.
complete bool
}
// fieldCodec is a struct field's index and, if that struct field's type is
// itself a struct, that substruct's structCodec.
type fieldCodec struct {
// path is the index path to the field
path []int
noIndex bool
// omitEmpty indicates that the field should be omitted on save
// if empty.
omitEmpty bool
// structCodec is the codec fot the struct field at index 'path',
// or nil if the field is not a struct.
structCodec *structCodec
}
// structCodecs collects the structCodecs that have already been calculated.
var (
structCodecsMutex sync.Mutex
structCodecs = make(map[reflect.Type]*structCodec)
)
// getStructCodec returns the structCodec for the given struct type.
func getStructCodec(t reflect.Type) (*structCodec, error) {
structCodecsMutex.Lock()
defer structCodecsMutex.Unlock()
return getStructCodecLocked(t)
}
// getStructCodecLocked implements getStructCodec. The structCodecsMutex must
// be held when calling this function.
func getStructCodecLocked(t reflect.Type) (ret *structCodec, retErr error) {
c, ok := structCodecs[t]
if ok {
return c, nil
}
c = &structCodec{
fields: make(map[string]fieldCodec),
// We initialize keyField to -1 so that the zero-value is not
// misinterpreted as index 0.
keyField: -1,
}
// Add c to the structCodecs map before we are sure it is good. If t is
// a recursive type, it needs to find the incomplete entry for itself in
// the map.
structCodecs[t] = c
defer func() {
if retErr != nil {
delete(structCodecs, t)
}
}()
for i := 0; i < t.NumField(); i++ {
f := t.Field(i)
// Skip unexported fields.
// Note that if f is an anonymous, unexported struct field,
// we will promote its fields.
if f.PkgPath != "" && !f.Anonymous {
continue
}
tags := strings.Split(f.Tag.Get("datastore"), ",")
name := tags[0]
opts := make(map[string]bool)
for _, t := range tags[1:] {
opts[t] = true
}
switch {
case name == "":
if !f.Anonymous {
name = f.Name
}
case name == "-":
continue
case name == "__key__":
if f.Type != typeOfKeyPtr {
return nil, fmt.Errorf("datastore: __key__ field on struct %v is not a *datastore.Key", t)
}
c.keyField = i
case !validPropertyName(name):
return nil, fmt.Errorf("datastore: struct tag has invalid property name: %q", name)
}
substructType, fIsSlice := reflect.Type(nil), false
switch f.Type.Kind() {
case reflect.Struct:
substructType = f.Type
case reflect.Slice:
if f.Type.Elem().Kind() == reflect.Struct {
substructType = f.Type.Elem()
}
fIsSlice = f.Type != typeOfByteSlice
c.hasSlice = c.hasSlice || fIsSlice
}
var sub *structCodec
if substructType != nil && substructType != typeOfTime && substructType != typeOfGeoPoint {
var err error
sub, err = getStructCodecLocked(substructType)
if err != nil {
return nil, err
}
if !sub.complete {
return nil, fmt.Errorf("datastore: recursive struct: field %q", f.Name)
}
if fIsSlice && sub.hasSlice {
return nil, fmt.Errorf(
"datastore: flattening nested structs leads to a slice of slices: field %q", f.Name)
}
c.hasSlice = c.hasSlice || sub.hasSlice
// If f is an anonymous struct field, we promote the substruct's fields up to this level
// in the linked list of struct codecs.
if f.Anonymous {
for subname, subfield := range sub.fields {
if name != "" {
subname = name + "." + subname
}
if _, ok := c.fields[subname]; ok {
return nil, fmt.Errorf("datastore: struct tag has repeated property name: %q", subname)
}
c.fields[subname] = fieldCodec{
path: append([]int{i}, subfield.path...),
noIndex: subfield.noIndex || opts["noindex"],
omitEmpty: subfield.omitEmpty,
structCodec: subfield.structCodec,
}
}
continue
}
}
if _, ok := c.fields[name]; ok {
return nil, fmt.Errorf("datastore: struct tag has repeated property name: %q", name)
}
c.fields[name] = fieldCodec{
path: []int{i},
noIndex: opts["noindex"],
omitEmpty: opts["omitempty"],
structCodec: sub,
}
}
c.complete = true
return c, nil
}
// structPLS adapts a struct to be a PropertyLoadSaver.
type structPLS struct {
v reflect.Value
codec *structCodec
}
// newStructPLS returns a structPLS, which implements the
// PropertyLoadSaver interface, for the struct pointer p.
func newStructPLS(p interface{}) (*structPLS, error) {
v := reflect.ValueOf(p)
if v.Kind() != reflect.Ptr || v.Elem().Kind() != reflect.Struct {
return nil, ErrInvalidEntityType
}
v = v.Elem()
codec, err := getStructCodec(v.Type())
if err != nil {
return nil, err
}
return &structPLS{v, codec}, nil
}
// LoadStruct loads the properties from p to dst.
// dst must be a struct pointer.
func LoadStruct(dst interface{}, p []Property) error {
x, err := newStructPLS(dst)
if err != nil {
return err
}
return x.Load(p)
}
// SaveStruct returns the properties from src as a slice of Properties.
// src must be a struct pointer.
func SaveStruct(src interface{}) ([]Property, error) {
x, err := newStructPLS(src)
if err != nil {
return nil, err
}
return x.Save()
}

View File

@ -1,672 +0,0 @@
// Copyright 2011 Google Inc. All Rights Reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package datastore
import (
"reflect"
"sort"
"testing"
"time"
"google.golang.org/appengine"
)
func TestValidPropertyName(t *testing.T) {
testCases := []struct {
name string
want bool
}{
// Invalid names.
{"", false},
{"'", false},
{".", false},
{"..", false},
{".foo", false},
{"0", false},
{"00", false},
{"X.X.4.X.X", false},
{"\n", false},
{"\x00", false},
{"abc\xffz", false},
{"foo.", false},
{"foo..", false},
{"foo..bar", false},
{"☃", false},
{`"`, false},
// Valid names.
{"AB", true},
{"Abc", true},
{"X.X.X.X.X", true},
{"_", true},
{"_0", true},
{"a", true},
{"a_B", true},
{"f00", true},
{"f0o", true},
{"fo0", true},
{"foo", true},
{"foo.bar", true},
{"foo.bar.baz", true},
{"世界", true},
}
for _, tc := range testCases {
got := validPropertyName(tc.name)
if got != tc.want {
t.Errorf("%q: got %v, want %v", tc.name, got, tc.want)
}
}
}
func TestStructCodec(t *testing.T) {
type oStruct struct {
O int
}
type pStruct struct {
P int
Q int
}
type rStruct struct {
R int
S pStruct
T oStruct
oStruct
}
type uStruct struct {
U int
v int
}
type vStruct struct {
V string `datastore:",noindex"`
}
oStructCodec := &structCodec{
fields: map[string]fieldCodec{
"O": {path: []int{0}},
},
complete: true,
}
pStructCodec := &structCodec{
fields: map[string]fieldCodec{
"P": {path: []int{0}},
"Q": {path: []int{1}},
},
complete: true,
}
rStructCodec := &structCodec{
fields: map[string]fieldCodec{
"R": {path: []int{0}},
"S": {path: []int{1}, structCodec: pStructCodec},
"T": {path: []int{2}, structCodec: oStructCodec},
"O": {path: []int{3, 0}},
},
complete: true,
}
uStructCodec := &structCodec{
fields: map[string]fieldCodec{
"U": {path: []int{0}},
},
complete: true,
}
vStructCodec := &structCodec{
fields: map[string]fieldCodec{
"V": {path: []int{0}, noIndex: true},
},
complete: true,
}
testCases := []struct {
desc string
structValue interface{}
want *structCodec
}{
{
"oStruct",
oStruct{},
oStructCodec,
},
{
"pStruct",
pStruct{},
pStructCodec,
},
{
"rStruct",
rStruct{},
rStructCodec,
},
{
"uStruct",
uStruct{},
uStructCodec,
},
{
"non-basic fields",
struct {
B appengine.BlobKey
K *Key
T time.Time
}{},
&structCodec{
fields: map[string]fieldCodec{
"B": {path: []int{0}},
"K": {path: []int{1}},
"T": {path: []int{2}},
},
complete: true,
},
},
{
"struct tags with ignored embed",
struct {
A int `datastore:"a,noindex"`
B int `datastore:"b"`
C int `datastore:",noindex"`
D int `datastore:""`
E int
I int `datastore:"-"`
J int `datastore:",noindex" json:"j"`
oStruct `datastore:"-"`
}{},
&structCodec{
fields: map[string]fieldCodec{
"a": {path: []int{0}, noIndex: true},
"b": {path: []int{1}},
"C": {path: []int{2}, noIndex: true},
"D": {path: []int{3}},
"E": {path: []int{4}},
"J": {path: []int{6}, noIndex: true},
},
complete: true,
},
},
{
"unexported fields",
struct {
A int
b int
C int `datastore:"x"`
d int `datastore:"Y"`
}{},
&structCodec{
fields: map[string]fieldCodec{
"A": {path: []int{0}},
"x": {path: []int{2}},
},
complete: true,
},
},
{
"nested and embedded structs",
struct {
A int
B int
CC oStruct
DDD rStruct
oStruct
}{},
&structCodec{
fields: map[string]fieldCodec{
"A": {path: []int{0}},
"B": {path: []int{1}},
"CC": {path: []int{2}, structCodec: oStructCodec},
"DDD": {path: []int{3}, structCodec: rStructCodec},
"O": {path: []int{4, 0}},
},
complete: true,
},
},
{
"struct tags with nested and embedded structs",
struct {
A int `datastore:"-"`
B int `datastore:"w"`
C oStruct `datastore:"xx"`
D rStruct `datastore:"y"`
oStruct `datastore:"z"`
}{},
&structCodec{
fields: map[string]fieldCodec{
"w": {path: []int{1}},
"xx": {path: []int{2}, structCodec: oStructCodec},
"y": {path: []int{3}, structCodec: rStructCodec},
"z.O": {path: []int{4, 0}},
},
complete: true,
},
},
{
"unexported nested and embedded structs",
struct {
a int
B int
c uStruct
D uStruct
uStruct
}{},
&structCodec{
fields: map[string]fieldCodec{
"B": {path: []int{1}},
"D": {path: []int{3}, structCodec: uStructCodec},
"U": {path: []int{4, 0}},
},
complete: true,
},
},
{
"noindex nested struct",
struct {
A oStruct `datastore:",noindex"`
}{},
&structCodec{
fields: map[string]fieldCodec{
"A": {path: []int{0}, structCodec: oStructCodec, noIndex: true},
},
complete: true,
},
},
{
"noindex slice",
struct {
A []string `datastore:",noindex"`
}{},
&structCodec{
fields: map[string]fieldCodec{
"A": {path: []int{0}, noIndex: true},
},
hasSlice: true,
complete: true,
},
},
{
"noindex embedded struct slice",
struct {
// vStruct has a single field, V, also with noindex.
A []vStruct `datastore:",noindex"`
}{},
&structCodec{
fields: map[string]fieldCodec{
"A": {path: []int{0}, structCodec: vStructCodec, noIndex: true},
},
hasSlice: true,
complete: true,
},
},
}
for _, tc := range testCases {
got, err := getStructCodec(reflect.TypeOf(tc.structValue))
if err != nil {
t.Errorf("%s: getStructCodec: %v", tc.desc, err)
continue
}
// can't reflect.DeepEqual b/c element order in fields map may differ
if !isEqualStructCodec(got, tc.want) {
t.Errorf("%s\ngot %+v\nwant %+v\n", tc.desc, got, tc.want)
}
}
}
func isEqualStructCodec(got, want *structCodec) bool {
if got.complete != want.complete {
return false
}
if got.hasSlice != want.hasSlice {
return false
}
if len(got.fields) != len(want.fields) {
return false
}
for name, wantF := range want.fields {
gotF := got.fields[name]
if !reflect.DeepEqual(wantF.path, gotF.path) {
return false
}
if wantF.noIndex != gotF.noIndex {
return false
}
if wantF.structCodec != nil {
if gotF.structCodec == nil {
return false
}
if !isEqualStructCodec(gotF.structCodec, wantF.structCodec) {
return false
}
}
}
return true
}
func TestRepeatedPropertyName(t *testing.T) {
good := []interface{}{
struct {
A int `datastore:"-"`
}{},
struct {
A int `datastore:"b"`
B int
}{},
struct {
A int
B int `datastore:"B"`
}{},
struct {
A int `datastore:"B"`
B int `datastore:"-"`
}{},
struct {
A int `datastore:"-"`
B int `datastore:"A"`
}{},
struct {
A int `datastore:"B"`
B int `datastore:"A"`
}{},
struct {
A int `datastore:"B"`
B int `datastore:"C"`
C int `datastore:"A"`
}{},
struct {
A int `datastore:"B"`
B int `datastore:"C"`
C int `datastore:"D"`
}{},
}
bad := []interface{}{
struct {
A int `datastore:"B"`
B int
}{},
struct {
A int
B int `datastore:"A"`
}{},
struct {
A int `datastore:"C"`
B int `datastore:"C"`
}{},
struct {
A int `datastore:"B"`
B int `datastore:"C"`
C int `datastore:"B"`
}{},
}
testGetStructCodec(t, good, bad)
}
func TestFlatteningNestedStructs(t *testing.T) {
type DeepGood struct {
A struct {
B []struct {
C struct {
D int
}
}
}
}
type DeepBad struct {
A struct {
B []struct {
C struct {
D []int
}
}
}
}
type ISay struct {
Tomato int
}
type YouSay struct {
Tomato int
}
type Tweedledee struct {
Dee int `datastore:"D"`
}
type Tweedledum struct {
Dum int `datastore:"D"`
}
good := []interface{}{
struct {
X []struct {
Y string
}
}{},
struct {
X []struct {
Y []byte
}
}{},
struct {
P []int
X struct {
Y []int
}
}{},
struct {
X struct {
Y []int
}
Q []int
}{},
struct {
P []int
X struct {
Y []int
}
Q []int
}{},
struct {
DeepGood
}{},
struct {
DG DeepGood
}{},
struct {
Foo struct {
Z int
} `datastore:"A"`
Bar struct {
Z int
} `datastore:"B"`
}{},
}
bad := []interface{}{
struct {
X []struct {
Y []string
}
}{},
struct {
X []struct {
Y []int
}
}{},
struct {
DeepBad
}{},
struct {
DB DeepBad
}{},
struct {
ISay
YouSay
}{},
struct {
Tweedledee
Tweedledum
}{},
struct {
Foo struct {
Z int
} `datastore:"A"`
Bar struct {
Z int
} `datastore:"A"`
}{},
}
testGetStructCodec(t, good, bad)
}
func testGetStructCodec(t *testing.T, good []interface{}, bad []interface{}) {
for _, x := range good {
if _, err := getStructCodec(reflect.TypeOf(x)); err != nil {
t.Errorf("type %T: got non-nil error (%s), want nil", x, err)
}
}
for _, x := range bad {
if _, err := getStructCodec(reflect.TypeOf(x)); err == nil {
t.Errorf("type %T: got nil error, want non-nil", x)
}
}
}
func TestNilKeyIsStored(t *testing.T) {
x := struct {
K *Key
I int
}{}
p := PropertyList{}
// Save x as properties.
p1, _ := SaveStruct(&x)
p.Load(p1)
// Set x's fields to non-zero.
x.K = &Key{}
x.I = 2
// Load x from properties.
p2, _ := p.Save()
LoadStruct(&x, p2)
// Check that x's fields were set to zero.
if x.K != nil {
t.Errorf("K field was not zero")
}
if x.I != 0 {
t.Errorf("I field was not zero")
}
}
func TestSaveStructOmitEmpty(t *testing.T) {
// Expected props names are sorted alphabetically
expectedPropNamesForSingles := []string{"EmptyValue", "NonEmptyValue", "OmitEmptyWithValue"}
expectedPropNamesForSlices := []string{"NonEmptyValue", "NonEmptyValue", "OmitEmptyWithValue", "OmitEmptyWithValue"}
testOmitted := func(expectedPropNames []string, src interface{}) {
// t.Helper() - this is available from Go version 1.9, but we also support Go versions 1.6, 1.7, 1.8
if props, err := SaveStruct(src); err != nil {
t.Fatal(err)
} else {
// Collect names for reporting if diffs from expected and for easier sorting
actualPropNames := make([]string, len(props))
for i := range props {
actualPropNames[i] = props[i].Name
}
// Sort actuals for comparing with already sorted expected names
sort.Sort(sort.StringSlice(actualPropNames))
if !reflect.DeepEqual(actualPropNames, expectedPropNames) {
t.Errorf("Expected this properties: %v, got: %v", expectedPropNames, actualPropNames)
}
}
}
testOmitted(expectedPropNamesForSingles, &struct {
EmptyValue int
NonEmptyValue int
OmitEmptyNoValue int `datastore:",omitempty"`
OmitEmptyWithValue int `datastore:",omitempty"`
}{
NonEmptyValue: 1,
OmitEmptyWithValue: 2,
})
testOmitted(expectedPropNamesForSlices, &struct {
EmptyValue []int
NonEmptyValue []int
OmitEmptyNoValue []int `datastore:",omitempty"`
OmitEmptyWithValue []int `datastore:",omitempty"`
}{
NonEmptyValue: []int{1, 2},
OmitEmptyWithValue: []int{3, 4},
})
testOmitted(expectedPropNamesForSingles, &struct {
EmptyValue bool
NonEmptyValue bool
OmitEmptyNoValue bool `datastore:",omitempty"`
OmitEmptyWithValue bool `datastore:",omitempty"`
}{
NonEmptyValue: true,
OmitEmptyWithValue: true,
})
testOmitted(expectedPropNamesForSlices, &struct {
EmptyValue []bool
NonEmptyValue []bool
OmitEmptyNoValue []bool `datastore:",omitempty"`
OmitEmptyWithValue []bool `datastore:",omitempty"`
}{
NonEmptyValue: []bool{true, true},
OmitEmptyWithValue: []bool{true, true},
})
testOmitted(expectedPropNamesForSingles, &struct {
EmptyValue string
NonEmptyValue string
OmitEmptyNoValue string `datastore:",omitempty"`
OmitEmptyWithValue string `datastore:",omitempty"`
}{
NonEmptyValue: "s",
OmitEmptyWithValue: "s",
})
testOmitted(expectedPropNamesForSlices, &struct {
EmptyValue []string
NonEmptyValue []string
OmitEmptyNoValue []string `datastore:",omitempty"`
OmitEmptyWithValue []string `datastore:",omitempty"`
}{
NonEmptyValue: []string{"s1", "s2"},
OmitEmptyWithValue: []string{"s3", "s4"},
})
testOmitted(expectedPropNamesForSingles, &struct {
EmptyValue float32
NonEmptyValue float32
OmitEmptyNoValue float32 `datastore:",omitempty"`
OmitEmptyWithValue float32 `datastore:",omitempty"`
}{
NonEmptyValue: 1.1,
OmitEmptyWithValue: 1.2,
})
testOmitted(expectedPropNamesForSlices, &struct {
EmptyValue []float32
NonEmptyValue []float32
OmitEmptyNoValue []float32 `datastore:",omitempty"`
OmitEmptyWithValue []float32 `datastore:",omitempty"`
}{
NonEmptyValue: []float32{1.1, 2.2},
OmitEmptyWithValue: []float32{3.3, 4.4},
})
testOmitted(expectedPropNamesForSingles, &struct {
EmptyValue time.Time
NonEmptyValue time.Time
OmitEmptyNoValue time.Time `datastore:",omitempty"`
OmitEmptyWithValue time.Time `datastore:",omitempty"`
}{
NonEmptyValue: now,
OmitEmptyWithValue: now,
})
testOmitted(expectedPropNamesForSlices, &struct {
EmptyValue []time.Time
NonEmptyValue []time.Time
OmitEmptyNoValue []time.Time `datastore:",omitempty"`
OmitEmptyWithValue []time.Time `datastore:",omitempty"`
}{
NonEmptyValue: []time.Time{now, now},
OmitEmptyWithValue: []time.Time{now, now},
})
}

View File

@ -1,757 +0,0 @@
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package datastore
import (
"encoding/base64"
"errors"
"fmt"
"math"
"reflect"
"strings"
"github.com/golang/protobuf/proto"
"golang.org/x/net/context"
"google.golang.org/appengine/internal"
pb "google.golang.org/appengine/internal/datastore"
)
type operator int
const (
lessThan operator = iota
lessEq
equal
greaterEq
greaterThan
)
var operatorToProto = map[operator]*pb.Query_Filter_Operator{
lessThan: pb.Query_Filter_LESS_THAN.Enum(),
lessEq: pb.Query_Filter_LESS_THAN_OR_EQUAL.Enum(),
equal: pb.Query_Filter_EQUAL.Enum(),
greaterEq: pb.Query_Filter_GREATER_THAN_OR_EQUAL.Enum(),
greaterThan: pb.Query_Filter_GREATER_THAN.Enum(),
}
// filter is a conditional filter on query results.
type filter struct {
FieldName string
Op operator
Value interface{}
}
type sortDirection int
const (
ascending sortDirection = iota
descending
)
var sortDirectionToProto = map[sortDirection]*pb.Query_Order_Direction{
ascending: pb.Query_Order_ASCENDING.Enum(),
descending: pb.Query_Order_DESCENDING.Enum(),
}
// order is a sort order on query results.
type order struct {
FieldName string
Direction sortDirection
}
// NewQuery creates a new Query for a specific entity kind.
//
// An empty kind means to return all entities, including entities created and
// managed by other App Engine features, and is called a kindless query.
// Kindless queries cannot include filters or sort orders on property values.
func NewQuery(kind string) *Query {
return &Query{
kind: kind,
limit: -1,
}
}
// Query represents a datastore query.
type Query struct {
kind string
ancestor *Key
filter []filter
order []order
projection []string
distinct bool
keysOnly bool
eventual bool
limit int32
offset int32
count int32
start *pb.CompiledCursor
end *pb.CompiledCursor
err error
}
func (q *Query) clone() *Query {
x := *q
// Copy the contents of the slice-typed fields to a new backing store.
if len(q.filter) > 0 {
x.filter = make([]filter, len(q.filter))
copy(x.filter, q.filter)
}
if len(q.order) > 0 {
x.order = make([]order, len(q.order))
copy(x.order, q.order)
}
return &x
}
// Ancestor returns a derivative query with an ancestor filter.
// The ancestor should not be nil.
func (q *Query) Ancestor(ancestor *Key) *Query {
q = q.clone()
if ancestor == nil {
q.err = errors.New("datastore: nil query ancestor")
return q
}
q.ancestor = ancestor
return q
}
// EventualConsistency returns a derivative query that returns eventually
// consistent results.
// It only has an effect on ancestor queries.
func (q *Query) EventualConsistency() *Query {
q = q.clone()
q.eventual = true
return q
}
// Filter returns a derivative query with a field-based filter.
// The filterStr argument must be a field name followed by optional space,
// followed by an operator, one of ">", "<", ">=", "<=", or "=".
// Fields are compared against the provided value using the operator.
// Multiple filters are AND'ed together.
func (q *Query) Filter(filterStr string, value interface{}) *Query {
q = q.clone()
filterStr = strings.TrimSpace(filterStr)
if len(filterStr) < 1 {
q.err = errors.New("datastore: invalid filter: " + filterStr)
return q
}
f := filter{
FieldName: strings.TrimRight(filterStr, " ><=!"),
Value: value,
}
switch op := strings.TrimSpace(filterStr[len(f.FieldName):]); op {
case "<=":
f.Op = lessEq
case ">=":
f.Op = greaterEq
case "<":
f.Op = lessThan
case ">":
f.Op = greaterThan
case "=":
f.Op = equal
default:
q.err = fmt.Errorf("datastore: invalid operator %q in filter %q", op, filterStr)
return q
}
q.filter = append(q.filter, f)
return q
}
// Order returns a derivative query with a field-based sort order. Orders are
// applied in the order they are added. The default order is ascending; to sort
// in descending order prefix the fieldName with a minus sign (-).
func (q *Query) Order(fieldName string) *Query {
q = q.clone()
fieldName = strings.TrimSpace(fieldName)
o := order{
Direction: ascending,
FieldName: fieldName,
}
if strings.HasPrefix(fieldName, "-") {
o.Direction = descending
o.FieldName = strings.TrimSpace(fieldName[1:])
} else if strings.HasPrefix(fieldName, "+") {
q.err = fmt.Errorf("datastore: invalid order: %q", fieldName)
return q
}
if len(o.FieldName) == 0 {
q.err = errors.New("datastore: empty order")
return q
}
q.order = append(q.order, o)
return q
}
// Project returns a derivative query that yields only the given fields. It
// cannot be used with KeysOnly.
func (q *Query) Project(fieldNames ...string) *Query {
q = q.clone()
q.projection = append([]string(nil), fieldNames...)
return q
}
// Distinct returns a derivative query that yields de-duplicated entities with
// respect to the set of projected fields. It is only used for projection
// queries.
func (q *Query) Distinct() *Query {
q = q.clone()
q.distinct = true
return q
}
// KeysOnly returns a derivative query that yields only keys, not keys and
// entities. It cannot be used with projection queries.
func (q *Query) KeysOnly() *Query {
q = q.clone()
q.keysOnly = true
return q
}
// Limit returns a derivative query that has a limit on the number of results
// returned. A negative value means unlimited.
func (q *Query) Limit(limit int) *Query {
q = q.clone()
if limit < math.MinInt32 || limit > math.MaxInt32 {
q.err = errors.New("datastore: query limit overflow")
return q
}
q.limit = int32(limit)
return q
}
// Offset returns a derivative query that has an offset of how many keys to
// skip over before returning results. A negative value is invalid.
func (q *Query) Offset(offset int) *Query {
q = q.clone()
if offset < 0 {
q.err = errors.New("datastore: negative query offset")
return q
}
if offset > math.MaxInt32 {
q.err = errors.New("datastore: query offset overflow")
return q
}
q.offset = int32(offset)
return q
}
// BatchSize returns a derivative query to fetch the supplied number of results
// at once. This value should be greater than zero, and equal to or less than
// the Limit.
func (q *Query) BatchSize(size int) *Query {
q = q.clone()
if size <= 0 || size > math.MaxInt32 {
q.err = errors.New("datastore: query batch size overflow")
return q
}
q.count = int32(size)
return q
}
// Start returns a derivative query with the given start point.
func (q *Query) Start(c Cursor) *Query {
q = q.clone()
if c.cc == nil {
q.err = errors.New("datastore: invalid cursor")
return q
}
q.start = c.cc
return q
}
// End returns a derivative query with the given end point.
func (q *Query) End(c Cursor) *Query {
q = q.clone()
if c.cc == nil {
q.err = errors.New("datastore: invalid cursor")
return q
}
q.end = c.cc
return q
}
// toProto converts the query to a protocol buffer.
func (q *Query) toProto(dst *pb.Query, appID string) error {
if len(q.projection) != 0 && q.keysOnly {
return errors.New("datastore: query cannot both project and be keys-only")
}
dst.Reset()
dst.App = proto.String(appID)
if q.kind != "" {
dst.Kind = proto.String(q.kind)
}
if q.ancestor != nil {
dst.Ancestor = keyToProto(appID, q.ancestor)
if q.eventual {
dst.Strong = proto.Bool(false)
}
}
if q.projection != nil {
dst.PropertyName = q.projection
if q.distinct {
dst.GroupByPropertyName = q.projection
}
}
if q.keysOnly {
dst.KeysOnly = proto.Bool(true)
dst.RequirePerfectPlan = proto.Bool(true)
}
for _, qf := range q.filter {
if qf.FieldName == "" {
return errors.New("datastore: empty query filter field name")
}
p, errStr := valueToProto(appID, qf.FieldName, reflect.ValueOf(qf.Value), false)
if errStr != "" {
return errors.New("datastore: bad query filter value type: " + errStr)
}
xf := &pb.Query_Filter{
Op: operatorToProto[qf.Op],
Property: []*pb.Property{p},
}
if xf.Op == nil {
return errors.New("datastore: unknown query filter operator")
}
dst.Filter = append(dst.Filter, xf)
}
for _, qo := range q.order {
if qo.FieldName == "" {
return errors.New("datastore: empty query order field name")
}
xo := &pb.Query_Order{
Property: proto.String(qo.FieldName),
Direction: sortDirectionToProto[qo.Direction],
}
if xo.Direction == nil {
return errors.New("datastore: unknown query order direction")
}
dst.Order = append(dst.Order, xo)
}
if q.limit >= 0 {
dst.Limit = proto.Int32(q.limit)
}
if q.offset != 0 {
dst.Offset = proto.Int32(q.offset)
}
if q.count != 0 {
dst.Count = proto.Int32(q.count)
}
dst.CompiledCursor = q.start
dst.EndCompiledCursor = q.end
dst.Compile = proto.Bool(true)
return nil
}
// Count returns the number of results for the query.
//
// The running time and number of API calls made by Count scale linearly with
// the sum of the query's offset and limit. Unless the result count is
// expected to be small, it is best to specify a limit; otherwise Count will
// continue until it finishes counting or the provided context expires.
func (q *Query) Count(c context.Context) (int, error) {
// Check that the query is well-formed.
if q.err != nil {
return 0, q.err
}
// Run a copy of the query, with keysOnly true (if we're not a projection,
// since the two are incompatible), and an adjusted offset. We also set the
// limit to zero, as we don't want any actual entity data, just the number
// of skipped results.
newQ := q.clone()
newQ.keysOnly = len(newQ.projection) == 0
newQ.limit = 0
if q.limit < 0 {
// If the original query was unlimited, set the new query's offset to maximum.
newQ.offset = math.MaxInt32
} else {
newQ.offset = q.offset + q.limit
if newQ.offset < 0 {
// Do the best we can, in the presence of overflow.
newQ.offset = math.MaxInt32
}
}
req := &pb.Query{}
if err := newQ.toProto(req, internal.FullyQualifiedAppID(c)); err != nil {
return 0, err
}
res := &pb.QueryResult{}
if err := internal.Call(c, "datastore_v3", "RunQuery", req, res); err != nil {
return 0, err
}
// n is the count we will return. For example, suppose that our original
// query had an offset of 4 and a limit of 2008: the count will be 2008,
// provided that there are at least 2012 matching entities. However, the
// RPCs will only skip 1000 results at a time. The RPC sequence is:
// call RunQuery with (offset, limit) = (2012, 0) // 2012 == newQ.offset
// response has (skippedResults, moreResults) = (1000, true)
// n += 1000 // n == 1000
// call Next with (offset, limit) = (1012, 0) // 1012 == newQ.offset - n
// response has (skippedResults, moreResults) = (1000, true)
// n += 1000 // n == 2000
// call Next with (offset, limit) = (12, 0) // 12 == newQ.offset - n
// response has (skippedResults, moreResults) = (12, false)
// n += 12 // n == 2012
// // exit the loop
// n -= 4 // n == 2008
var n int32
for {
// The QueryResult should have no actual entity data, just skipped results.
if len(res.Result) != 0 {
return 0, errors.New("datastore: internal error: Count request returned too much data")
}
n += res.GetSkippedResults()
if !res.GetMoreResults() {
break
}
if err := callNext(c, res, newQ.offset-n, q.count); err != nil {
return 0, err
}
}
n -= q.offset
if n < 0 {
// If the offset was greater than the number of matching entities,
// return 0 instead of negative.
n = 0
}
return int(n), nil
}
// callNext issues a datastore_v3/Next RPC to advance a cursor, such as that
// returned by a query with more results.
func callNext(c context.Context, res *pb.QueryResult, offset, count int32) error {
if res.Cursor == nil {
return errors.New("datastore: internal error: server did not return a cursor")
}
req := &pb.NextRequest{
Cursor: res.Cursor,
}
if count >= 0 {
req.Count = proto.Int32(count)
}
if offset != 0 {
req.Offset = proto.Int32(offset)
}
if res.CompiledCursor != nil {
req.Compile = proto.Bool(true)
}
res.Reset()
return internal.Call(c, "datastore_v3", "Next", req, res)
}
// GetAll runs the query in the given context and returns all keys that match
// that query, as well as appending the values to dst.
//
// dst must have type *[]S or *[]*S or *[]P, for some struct type S or some non-
// interface, non-pointer type P such that P or *P implements PropertyLoadSaver.
//
// As a special case, *PropertyList is an invalid type for dst, even though a
// PropertyList is a slice of structs. It is treated as invalid to avoid being
// mistakenly passed when *[]PropertyList was intended.
//
// The keys returned by GetAll will be in a 1-1 correspondence with the entities
// added to dst.
//
// If q is a ``keys-only'' query, GetAll ignores dst and only returns the keys.
//
// The running time and number of API calls made by GetAll scale linearly with
// the sum of the query's offset and limit. Unless the result count is
// expected to be small, it is best to specify a limit; otherwise GetAll will
// continue until it finishes collecting results or the provided context
// expires.
func (q *Query) GetAll(c context.Context, dst interface{}) ([]*Key, error) {
var (
dv reflect.Value
mat multiArgType
elemType reflect.Type
errFieldMismatch error
)
if !q.keysOnly {
dv = reflect.ValueOf(dst)
if dv.Kind() != reflect.Ptr || dv.IsNil() {
return nil, ErrInvalidEntityType
}
dv = dv.Elem()
mat, elemType = checkMultiArg(dv)
if mat == multiArgTypeInvalid || mat == multiArgTypeInterface {
return nil, ErrInvalidEntityType
}
}
var keys []*Key
for t := q.Run(c); ; {
k, e, err := t.next()
if err == Done {
break
}
if err != nil {
return keys, err
}
if !q.keysOnly {
ev := reflect.New(elemType)
if elemType.Kind() == reflect.Map {
// This is a special case. The zero values of a map type are
// not immediately useful; they have to be make'd.
//
// Funcs and channels are similar, in that a zero value is not useful,
// but even a freshly make'd channel isn't useful: there's no fixed
// channel buffer size that is always going to be large enough, and
// there's no goroutine to drain the other end. Theoretically, these
// types could be supported, for example by sniffing for a constructor
// method or requiring prior registration, but for now it's not a
// frequent enough concern to be worth it. Programmers can work around
// it by explicitly using Iterator.Next instead of the Query.GetAll
// convenience method.
x := reflect.MakeMap(elemType)
ev.Elem().Set(x)
}
if err = loadEntity(ev.Interface(), e); err != nil {
if _, ok := err.(*ErrFieldMismatch); ok {
// We continue loading entities even in the face of field mismatch errors.
// If we encounter any other error, that other error is returned. Otherwise,
// an ErrFieldMismatch is returned.
errFieldMismatch = err
} else {
return keys, err
}
}
if mat != multiArgTypeStructPtr {
ev = ev.Elem()
}
dv.Set(reflect.Append(dv, ev))
}
keys = append(keys, k)
}
return keys, errFieldMismatch
}
// Run runs the query in the given context.
func (q *Query) Run(c context.Context) *Iterator {
if q.err != nil {
return &Iterator{err: q.err}
}
t := &Iterator{
c: c,
limit: q.limit,
count: q.count,
q: q,
prevCC: q.start,
}
var req pb.Query
if err := q.toProto(&req, internal.FullyQualifiedAppID(c)); err != nil {
t.err = err
return t
}
if err := internal.Call(c, "datastore_v3", "RunQuery", &req, &t.res); err != nil {
t.err = err
return t
}
offset := q.offset - t.res.GetSkippedResults()
var count int32
if t.count > 0 && (t.limit < 0 || t.count < t.limit) {
count = t.count
} else {
count = t.limit
}
for offset > 0 && t.res.GetMoreResults() {
t.prevCC = t.res.CompiledCursor
if err := callNext(t.c, &t.res, offset, count); err != nil {
t.err = err
break
}
skip := t.res.GetSkippedResults()
if skip < 0 {
t.err = errors.New("datastore: internal error: negative number of skipped_results")
break
}
offset -= skip
}
if offset < 0 {
t.err = errors.New("datastore: internal error: query offset was overshot")
}
return t
}
// Iterator is the result of running a query.
type Iterator struct {
c context.Context
err error
// res is the result of the most recent RunQuery or Next API call.
res pb.QueryResult
// i is how many elements of res.Result we have iterated over.
i int
// limit is the limit on the number of results this iterator should return.
// A negative value means unlimited.
limit int32
// count is the number of results this iterator should fetch at once. This
// should be equal to or greater than zero.
count int32
// q is the original query which yielded this iterator.
q *Query
// prevCC is the compiled cursor that marks the end of the previous batch
// of results.
prevCC *pb.CompiledCursor
}
// Done is returned when a query iteration has completed.
var Done = errors.New("datastore: query has no more results")
// Next returns the key of the next result. When there are no more results,
// Done is returned as the error.
//
// If the query is not keys only and dst is non-nil, it also loads the entity
// stored for that key into the struct pointer or PropertyLoadSaver dst, with
// the same semantics and possible errors as for the Get function.
func (t *Iterator) Next(dst interface{}) (*Key, error) {
k, e, err := t.next()
if err != nil {
return nil, err
}
if dst != nil && !t.q.keysOnly {
err = loadEntity(dst, e)
}
return k, err
}
func (t *Iterator) next() (*Key, *pb.EntityProto, error) {
if t.err != nil {
return nil, nil, t.err
}
// Issue datastore_v3/Next RPCs as necessary.
for t.i == len(t.res.Result) {
if !t.res.GetMoreResults() {
t.err = Done
return nil, nil, t.err
}
t.prevCC = t.res.CompiledCursor
var count int32
if t.count > 0 && (t.limit < 0 || t.count < t.limit) {
count = t.count
} else {
count = t.limit
}
if err := callNext(t.c, &t.res, 0, count); err != nil {
t.err = err
return nil, nil, t.err
}
if t.res.GetSkippedResults() != 0 {
t.err = errors.New("datastore: internal error: iterator has skipped results")
return nil, nil, t.err
}
t.i = 0
if t.limit >= 0 {
t.limit -= int32(len(t.res.Result))
if t.limit < 0 {
t.err = errors.New("datastore: internal error: query returned more results than the limit")
return nil, nil, t.err
}
}
}
// Extract the key from the t.i'th element of t.res.Result.
e := t.res.Result[t.i]
t.i++
if e.Key == nil {
return nil, nil, errors.New("datastore: internal error: server did not return a key")
}
k, err := protoToKey(e.Key)
if err != nil || k.Incomplete() {
return nil, nil, errors.New("datastore: internal error: server returned an invalid key")
}
return k, e, nil
}
// Cursor returns a cursor for the iterator's current location.
func (t *Iterator) Cursor() (Cursor, error) {
if t.err != nil && t.err != Done {
return Cursor{}, t.err
}
// If we are at either end of the current batch of results,
// return the compiled cursor at that end.
skipped := t.res.GetSkippedResults()
if t.i == 0 && skipped == 0 {
if t.prevCC == nil {
// A nil pointer (of type *pb.CompiledCursor) means no constraint:
// passing it as the end cursor of a new query means unlimited results
// (glossing over the integer limit parameter for now).
// A non-nil pointer to an empty pb.CompiledCursor means the start:
// passing it as the end cursor of a new query means 0 results.
// If prevCC was nil, then the original query had no start cursor, but
// Iterator.Cursor should return "the start" instead of unlimited.
return Cursor{&zeroCC}, nil
}
return Cursor{t.prevCC}, nil
}
if t.i == len(t.res.Result) {
return Cursor{t.res.CompiledCursor}, nil
}
// Otherwise, re-run the query offset to this iterator's position, starting from
// the most recent compiled cursor. This is done on a best-effort basis, as it
// is racy; if a concurrent process has added or removed entities, then the
// cursor returned may be inconsistent.
q := t.q.clone()
q.start = t.prevCC
q.offset = skipped + int32(t.i)
q.limit = 0
q.keysOnly = len(q.projection) == 0
t1 := q.Run(t.c)
_, _, err := t1.next()
if err != Done {
if err == nil {
err = fmt.Errorf("datastore: internal error: zero-limit query did not have zero results")
}
return Cursor{}, err
}
return Cursor{t1.res.CompiledCursor}, nil
}
var zeroCC pb.CompiledCursor
// Cursor is an iterator's position. It can be converted to and from an opaque
// string. A cursor can be used from different HTTP requests, but only with a
// query with the same kind, ancestor, filter and order constraints.
type Cursor struct {
cc *pb.CompiledCursor
}
// String returns a base-64 string representation of a cursor.
func (c Cursor) String() string {
if c.cc == nil {
return ""
}
b, err := proto.Marshal(c.cc)
if err != nil {
// The only way to construct a Cursor with a non-nil cc field is to
// unmarshal from the byte representation. We panic if the unmarshal
// succeeds but the marshaling of the unchanged protobuf value fails.
panic(fmt.Sprintf("datastore: internal error: malformed cursor: %v", err))
}
return strings.TrimRight(base64.URLEncoding.EncodeToString(b), "=")
}
// Decode decodes a cursor from its base-64 string representation.
func DecodeCursor(s string) (Cursor, error) {
if s == "" {
return Cursor{&zeroCC}, nil
}
if n := len(s) % 4; n != 0 {
s += strings.Repeat("=", 4-n)
}
b, err := base64.URLEncoding.DecodeString(s)
if err != nil {
return Cursor{}, err
}
cc := &pb.CompiledCursor{}
if err := proto.Unmarshal(b, cc); err != nil {
return Cursor{}, err
}
return Cursor{cc}, nil
}

View File

@ -1,584 +0,0 @@
// Copyright 2011 Google Inc. All Rights Reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package datastore
import (
"errors"
"fmt"
"reflect"
"strings"
"testing"
"github.com/golang/protobuf/proto"
"google.golang.org/appengine/internal"
"google.golang.org/appengine/internal/aetesting"
pb "google.golang.org/appengine/internal/datastore"
)
var (
path1 = &pb.Path{
Element: []*pb.Path_Element{
{
Type: proto.String("Gopher"),
Id: proto.Int64(6),
},
},
}
path2 = &pb.Path{
Element: []*pb.Path_Element{
{
Type: proto.String("Gopher"),
Id: proto.Int64(6),
},
{
Type: proto.String("Gopher"),
Id: proto.Int64(8),
},
},
}
)
func fakeRunQuery(in *pb.Query, out *pb.QueryResult) error {
expectedIn := &pb.Query{
App: proto.String("dev~fake-app"),
Kind: proto.String("Gopher"),
Compile: proto.Bool(true),
}
if !proto.Equal(in, expectedIn) {
return fmt.Errorf("unsupported argument: got %v want %v", in, expectedIn)
}
*out = pb.QueryResult{
Result: []*pb.EntityProto{
{
Key: &pb.Reference{
App: proto.String("s~test-app"),
Path: path1,
},
EntityGroup: path1,
Property: []*pb.Property{
{
Meaning: pb.Property_TEXT.Enum(),
Name: proto.String("Name"),
Value: &pb.PropertyValue{
StringValue: proto.String("George"),
},
},
{
Name: proto.String("Height"),
Value: &pb.PropertyValue{
Int64Value: proto.Int64(32),
},
},
},
},
{
Key: &pb.Reference{
App: proto.String("s~test-app"),
Path: path2,
},
EntityGroup: path1, // ancestor is George
Property: []*pb.Property{
{
Meaning: pb.Property_TEXT.Enum(),
Name: proto.String("Name"),
Value: &pb.PropertyValue{
StringValue: proto.String("Rufus"),
},
},
// No height for Rufus.
},
},
},
MoreResults: proto.Bool(false),
}
return nil
}
type StructThatImplementsPLS struct{}
func (StructThatImplementsPLS) Load(p []Property) error { return nil }
func (StructThatImplementsPLS) Save() ([]Property, error) { return nil, nil }
var _ PropertyLoadSaver = StructThatImplementsPLS{}
type StructPtrThatImplementsPLS struct{}
func (*StructPtrThatImplementsPLS) Load(p []Property) error { return nil }
func (*StructPtrThatImplementsPLS) Save() ([]Property, error) { return nil, nil }
var _ PropertyLoadSaver = &StructPtrThatImplementsPLS{}
type PropertyMap map[string]Property
func (m PropertyMap) Load(props []Property) error {
for _, p := range props {
if p.Multiple {
return errors.New("PropertyMap does not support multiple properties")
}
m[p.Name] = p
}
return nil
}
func (m PropertyMap) Save() ([]Property, error) {
props := make([]Property, 0, len(m))
for _, p := range m {
if p.Multiple {
return nil, errors.New("PropertyMap does not support multiple properties")
}
props = append(props, p)
}
return props, nil
}
var _ PropertyLoadSaver = PropertyMap{}
type Gopher struct {
Name string
Height int
}
// typeOfEmptyInterface is the type of interface{}, but we can't use
// reflect.TypeOf((interface{})(nil)) directly because TypeOf takes an
// interface{}.
var typeOfEmptyInterface = reflect.TypeOf((*interface{})(nil)).Elem()
func TestCheckMultiArg(t *testing.T) {
testCases := []struct {
v interface{}
mat multiArgType
elemType reflect.Type
}{
// Invalid cases.
{nil, multiArgTypeInvalid, nil},
{Gopher{}, multiArgTypeInvalid, nil},
{&Gopher{}, multiArgTypeInvalid, nil},
{PropertyList{}, multiArgTypeInvalid, nil}, // This is a special case.
{PropertyMap{}, multiArgTypeInvalid, nil},
{[]*PropertyList(nil), multiArgTypeInvalid, nil},
{[]*PropertyMap(nil), multiArgTypeInvalid, nil},
{[]**Gopher(nil), multiArgTypeInvalid, nil},
{[]*interface{}(nil), multiArgTypeInvalid, nil},
// Valid cases.
{
[]PropertyList(nil),
multiArgTypePropertyLoadSaver,
reflect.TypeOf(PropertyList{}),
},
{
[]PropertyMap(nil),
multiArgTypePropertyLoadSaver,
reflect.TypeOf(PropertyMap{}),
},
{
[]StructThatImplementsPLS(nil),
multiArgTypePropertyLoadSaver,
reflect.TypeOf(StructThatImplementsPLS{}),
},
{
[]StructPtrThatImplementsPLS(nil),
multiArgTypePropertyLoadSaver,
reflect.TypeOf(StructPtrThatImplementsPLS{}),
},
{
[]Gopher(nil),
multiArgTypeStruct,
reflect.TypeOf(Gopher{}),
},
{
[]*Gopher(nil),
multiArgTypeStructPtr,
reflect.TypeOf(Gopher{}),
},
{
[]interface{}(nil),
multiArgTypeInterface,
typeOfEmptyInterface,
},
}
for _, tc := range testCases {
mat, elemType := checkMultiArg(reflect.ValueOf(tc.v))
if mat != tc.mat || elemType != tc.elemType {
t.Errorf("checkMultiArg(%T): got %v, %v want %v, %v",
tc.v, mat, elemType, tc.mat, tc.elemType)
}
}
}
func TestSimpleQuery(t *testing.T) {
struct1 := Gopher{Name: "George", Height: 32}
struct2 := Gopher{Name: "Rufus"}
pList1 := PropertyList{
{
Name: "Name",
Value: "George",
},
{
Name: "Height",
Value: int64(32),
},
}
pList2 := PropertyList{
{
Name: "Name",
Value: "Rufus",
},
}
pMap1 := PropertyMap{
"Name": Property{
Name: "Name",
Value: "George",
},
"Height": Property{
Name: "Height",
Value: int64(32),
},
}
pMap2 := PropertyMap{
"Name": Property{
Name: "Name",
Value: "Rufus",
},
}
testCases := []struct {
dst interface{}
want interface{}
}{
// The destination must have type *[]P, *[]S or *[]*S, for some non-interface
// type P such that *P implements PropertyLoadSaver, or for some struct type S.
{new([]Gopher), &[]Gopher{struct1, struct2}},
{new([]*Gopher), &[]*Gopher{&struct1, &struct2}},
{new([]PropertyList), &[]PropertyList{pList1, pList2}},
{new([]PropertyMap), &[]PropertyMap{pMap1, pMap2}},
// Any other destination type is invalid.
{0, nil},
{Gopher{}, nil},
{PropertyList{}, nil},
{PropertyMap{}, nil},
{[]int{}, nil},
{[]Gopher{}, nil},
{[]PropertyList{}, nil},
{new(int), nil},
{new(Gopher), nil},
{new(PropertyList), nil}, // This is a special case.
{new(PropertyMap), nil},
{new([]int), nil},
{new([]map[int]int), nil},
{new([]map[string]Property), nil},
{new([]map[string]interface{}), nil},
{new([]*int), nil},
{new([]*map[int]int), nil},
{new([]*map[string]Property), nil},
{new([]*map[string]interface{}), nil},
{new([]**Gopher), nil},
{new([]*PropertyList), nil},
{new([]*PropertyMap), nil},
}
for _, tc := range testCases {
nCall := 0
c := aetesting.FakeSingleContext(t, "datastore_v3", "RunQuery", func(in *pb.Query, out *pb.QueryResult) error {
nCall++
return fakeRunQuery(in, out)
})
c = internal.WithAppIDOverride(c, "dev~fake-app")
var (
expectedErr error
expectedNCall int
)
if tc.want == nil {
expectedErr = ErrInvalidEntityType
} else {
expectedNCall = 1
}
keys, err := NewQuery("Gopher").GetAll(c, tc.dst)
if err != expectedErr {
t.Errorf("dst type %T: got error [%v], want [%v]", tc.dst, err, expectedErr)
continue
}
if nCall != expectedNCall {
t.Errorf("dst type %T: Context.Call was called an incorrect number of times: got %d want %d", tc.dst, nCall, expectedNCall)
continue
}
if err != nil {
continue
}
key1 := NewKey(c, "Gopher", "", 6, nil)
expectedKeys := []*Key{
key1,
NewKey(c, "Gopher", "", 8, key1),
}
if l1, l2 := len(keys), len(expectedKeys); l1 != l2 {
t.Errorf("dst type %T: got %d keys, want %d keys", tc.dst, l1, l2)
continue
}
for i, key := range keys {
if key.AppID() != "s~test-app" {
t.Errorf(`dst type %T: Key #%d's AppID = %q, want "s~test-app"`, tc.dst, i, key.AppID())
continue
}
if !keysEqual(key, expectedKeys[i]) {
t.Errorf("dst type %T: got key #%d %v, want %v", tc.dst, i, key, expectedKeys[i])
continue
}
}
if !reflect.DeepEqual(tc.dst, tc.want) {
t.Errorf("dst type %T: Entities got %+v, want %+v", tc.dst, tc.dst, tc.want)
continue
}
}
}
// keysEqual is like (*Key).Equal, but ignores the App ID.
func keysEqual(a, b *Key) bool {
for a != nil && b != nil {
if a.Kind() != b.Kind() || a.StringID() != b.StringID() || a.IntID() != b.IntID() {
return false
}
a, b = a.Parent(), b.Parent()
}
return a == b
}
func TestQueriesAreImmutable(t *testing.T) {
// Test that deriving q2 from q1 does not modify q1.
q0 := NewQuery("foo")
q1 := NewQuery("foo")
q2 := q1.Offset(2)
if !reflect.DeepEqual(q0, q1) {
t.Errorf("q0 and q1 were not equal")
}
if reflect.DeepEqual(q1, q2) {
t.Errorf("q1 and q2 were equal")
}
// Test that deriving from q4 twice does not conflict, even though
// q4 has a long list of order clauses. This tests that the arrays
// backed by a query's slice of orders are not shared.
f := func() *Query {
q := NewQuery("bar")
// 47 is an ugly number that is unlikely to be near a re-allocation
// point in repeated append calls. For example, it's not near a power
// of 2 or a multiple of 10.
for i := 0; i < 47; i++ {
q = q.Order(fmt.Sprintf("x%d", i))
}
return q
}
q3 := f().Order("y")
q4 := f()
q5 := q4.Order("y")
q6 := q4.Order("z")
if !reflect.DeepEqual(q3, q5) {
t.Errorf("q3 and q5 were not equal")
}
if reflect.DeepEqual(q5, q6) {
t.Errorf("q5 and q6 were equal")
}
}
func TestFilterParser(t *testing.T) {
testCases := []struct {
filterStr string
wantOK bool
wantFieldName string
wantOp operator
}{
// Supported ops.
{"x<", true, "x", lessThan},
{"x <", true, "x", lessThan},
{"x <", true, "x", lessThan},
{" x < ", true, "x", lessThan},
{"x <=", true, "x", lessEq},
{"x =", true, "x", equal},
{"x >=", true, "x", greaterEq},
{"x >", true, "x", greaterThan},
{"in >", true, "in", greaterThan},
{"in>", true, "in", greaterThan},
// Valid but (currently) unsupported ops.
{"x!=", false, "", 0},
{"x !=", false, "", 0},
{" x != ", false, "", 0},
{"x IN", false, "", 0},
{"x in", false, "", 0},
// Invalid ops.
{"x EQ", false, "", 0},
{"x lt", false, "", 0},
{"x <>", false, "", 0},
{"x >>", false, "", 0},
{"x ==", false, "", 0},
{"x =<", false, "", 0},
{"x =>", false, "", 0},
{"x !", false, "", 0},
{"x ", false, "", 0},
{"x", false, "", 0},
}
for _, tc := range testCases {
q := NewQuery("foo").Filter(tc.filterStr, 42)
if ok := q.err == nil; ok != tc.wantOK {
t.Errorf("%q: ok=%t, want %t", tc.filterStr, ok, tc.wantOK)
continue
}
if !tc.wantOK {
continue
}
if len(q.filter) != 1 {
t.Errorf("%q: len=%d, want %d", tc.filterStr, len(q.filter), 1)
continue
}
got, want := q.filter[0], filter{tc.wantFieldName, tc.wantOp, 42}
if got != want {
t.Errorf("%q: got %v, want %v", tc.filterStr, got, want)
continue
}
}
}
func TestQueryToProto(t *testing.T) {
// The context is required to make Keys for the test cases.
var got *pb.Query
NoErr := errors.New("No error")
c := aetesting.FakeSingleContext(t, "datastore_v3", "RunQuery", func(in *pb.Query, out *pb.QueryResult) error {
got = in
return NoErr // return a non-nil error so Run doesn't keep going.
})
c = internal.WithAppIDOverride(c, "dev~fake-app")
testCases := []struct {
desc string
query *Query
want *pb.Query
err string
}{
{
desc: "empty",
query: NewQuery(""),
want: &pb.Query{},
},
{
desc: "standard query",
query: NewQuery("kind").Order("-I").Filter("I >", 17).Filter("U =", "Dave").Limit(7).Offset(42).BatchSize(5),
want: &pb.Query{
Kind: proto.String("kind"),
Filter: []*pb.Query_Filter{
{
Op: pb.Query_Filter_GREATER_THAN.Enum(),
Property: []*pb.Property{
{
Name: proto.String("I"),
Value: &pb.PropertyValue{Int64Value: proto.Int64(17)},
Multiple: proto.Bool(false),
},
},
},
{
Op: pb.Query_Filter_EQUAL.Enum(),
Property: []*pb.Property{
{
Name: proto.String("U"),
Value: &pb.PropertyValue{StringValue: proto.String("Dave")},
Multiple: proto.Bool(false),
},
},
},
},
Order: []*pb.Query_Order{
{
Property: proto.String("I"),
Direction: pb.Query_Order_DESCENDING.Enum(),
},
},
Limit: proto.Int32(7),
Offset: proto.Int32(42),
Count: proto.Int32(5),
},
},
{
desc: "ancestor",
query: NewQuery("").Ancestor(NewKey(c, "kind", "Mummy", 0, nil)),
want: &pb.Query{
Ancestor: &pb.Reference{
App: proto.String("dev~fake-app"),
Path: &pb.Path{
Element: []*pb.Path_Element{{Type: proto.String("kind"), Name: proto.String("Mummy")}},
},
},
},
},
{
desc: "projection",
query: NewQuery("").Project("A", "B"),
want: &pb.Query{
PropertyName: []string{"A", "B"},
},
},
{
desc: "projection with distinct",
query: NewQuery("").Project("A", "B").Distinct(),
want: &pb.Query{
PropertyName: []string{"A", "B"},
GroupByPropertyName: []string{"A", "B"},
},
},
{
desc: "keys only",
query: NewQuery("").KeysOnly(),
want: &pb.Query{
KeysOnly: proto.Bool(true),
RequirePerfectPlan: proto.Bool(true),
},
},
{
desc: "empty filter",
query: NewQuery("kind").Filter("=", 17),
err: "empty query filter field nam",
},
{
desc: "bad filter type",
query: NewQuery("kind").Filter("M =", map[string]bool{}),
err: "bad query filter value type",
},
{
desc: "bad filter operator",
query: NewQuery("kind").Filter("I <<=", 17),
err: `invalid operator "<<=" in filter "I <<="`,
},
{
desc: "empty order",
query: NewQuery("kind").Order(""),
err: "empty order",
},
{
desc: "bad order direction",
query: NewQuery("kind").Order("+I"),
err: `invalid order: "+I`,
},
}
for _, tt := range testCases {
got = nil
if _, err := tt.query.Run(c).Next(nil); err != NoErr {
if tt.err == "" || !strings.Contains(err.Error(), tt.err) {
t.Errorf("%s: error %v, want %q", tt.desc, err, tt.err)
}
continue
}
if tt.err != "" {
t.Errorf("%s: no error, want %q", tt.desc, tt.err)
continue
}
// Fields that are common to all protos.
tt.want.App = proto.String("dev~fake-app")
tt.want.Compile = proto.Bool(true)
if !proto.Equal(got, tt.want) {
t.Errorf("%s:\ngot %v\nwant %v", tt.desc, got, tt.want)
}
}
}

View File

@ -1,333 +0,0 @@
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package datastore
import (
"errors"
"fmt"
"math"
"reflect"
"time"
"github.com/golang/protobuf/proto"
"google.golang.org/appengine"
pb "google.golang.org/appengine/internal/datastore"
)
func toUnixMicro(t time.Time) int64 {
// We cannot use t.UnixNano() / 1e3 because we want to handle times more than
// 2^63 nanoseconds (which is about 292 years) away from 1970, and those cannot
// be represented in the numerator of a single int64 divide.
return t.Unix()*1e6 + int64(t.Nanosecond()/1e3)
}
func fromUnixMicro(t int64) time.Time {
return time.Unix(t/1e6, (t%1e6)*1e3).UTC()
}
var (
minTime = time.Unix(int64(math.MinInt64)/1e6, (int64(math.MinInt64)%1e6)*1e3)
maxTime = time.Unix(int64(math.MaxInt64)/1e6, (int64(math.MaxInt64)%1e6)*1e3)
)
// valueToProto converts a named value to a newly allocated Property.
// The returned error string is empty on success.
func valueToProto(defaultAppID, name string, v reflect.Value, multiple bool) (p *pb.Property, errStr string) {
var (
pv pb.PropertyValue
unsupported bool
)
switch v.Kind() {
case reflect.Invalid:
// No-op.
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
pv.Int64Value = proto.Int64(v.Int())
case reflect.Bool:
pv.BooleanValue = proto.Bool(v.Bool())
case reflect.String:
pv.StringValue = proto.String(v.String())
case reflect.Float32, reflect.Float64:
pv.DoubleValue = proto.Float64(v.Float())
case reflect.Ptr:
if k, ok := v.Interface().(*Key); ok {
if k != nil {
pv.Referencevalue = keyToReferenceValue(defaultAppID, k)
}
} else {
unsupported = true
}
case reflect.Struct:
switch t := v.Interface().(type) {
case time.Time:
if t.Before(minTime) || t.After(maxTime) {
return nil, "time value out of range"
}
pv.Int64Value = proto.Int64(toUnixMicro(t))
case appengine.GeoPoint:
if !t.Valid() {
return nil, "invalid GeoPoint value"
}
// NOTE: Strangely, latitude maps to X, longitude to Y.
pv.Pointvalue = &pb.PropertyValue_PointValue{X: &t.Lat, Y: &t.Lng}
default:
unsupported = true
}
case reflect.Slice:
if b, ok := v.Interface().([]byte); ok {
pv.StringValue = proto.String(string(b))
} else {
// nvToProto should already catch slice values.
// If we get here, we have a slice of slice values.
unsupported = true
}
default:
unsupported = true
}
if unsupported {
return nil, "unsupported datastore value type: " + v.Type().String()
}
p = &pb.Property{
Name: proto.String(name),
Value: &pv,
Multiple: proto.Bool(multiple),
}
if v.IsValid() {
switch v.Interface().(type) {
case []byte:
p.Meaning = pb.Property_BLOB.Enum()
case ByteString:
p.Meaning = pb.Property_BYTESTRING.Enum()
case appengine.BlobKey:
p.Meaning = pb.Property_BLOBKEY.Enum()
case time.Time:
p.Meaning = pb.Property_GD_WHEN.Enum()
case appengine.GeoPoint:
p.Meaning = pb.Property_GEORSS_POINT.Enum()
}
}
return p, ""
}
type saveOpts struct {
noIndex bool
multiple bool
omitEmpty bool
}
// saveEntity saves an EntityProto into a PropertyLoadSaver or struct pointer.
func saveEntity(defaultAppID string, key *Key, src interface{}) (*pb.EntityProto, error) {
var err error
var props []Property
if e, ok := src.(PropertyLoadSaver); ok {
props, err = e.Save()
} else {
props, err = SaveStruct(src)
}
if err != nil {
return nil, err
}
return propertiesToProto(defaultAppID, key, props)
}
func saveStructProperty(props *[]Property, name string, opts saveOpts, v reflect.Value) error {
if opts.omitEmpty && isEmptyValue(v) {
return nil
}
p := Property{
Name: name,
NoIndex: opts.noIndex,
Multiple: opts.multiple,
}
switch x := v.Interface().(type) {
case *Key:
p.Value = x
case time.Time:
p.Value = x
case appengine.BlobKey:
p.Value = x
case appengine.GeoPoint:
p.Value = x
case ByteString:
p.Value = x
default:
switch v.Kind() {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
p.Value = v.Int()
case reflect.Bool:
p.Value = v.Bool()
case reflect.String:
p.Value = v.String()
case reflect.Float32, reflect.Float64:
p.Value = v.Float()
case reflect.Slice:
if v.Type().Elem().Kind() == reflect.Uint8 {
p.NoIndex = true
p.Value = v.Bytes()
}
case reflect.Struct:
if !v.CanAddr() {
return fmt.Errorf("datastore: unsupported struct field: value is unaddressable")
}
sub, err := newStructPLS(v.Addr().Interface())
if err != nil {
return fmt.Errorf("datastore: unsupported struct field: %v", err)
}
return sub.save(props, name+".", opts)
}
}
if p.Value == nil {
return fmt.Errorf("datastore: unsupported struct field type: %v", v.Type())
}
*props = append(*props, p)
return nil
}
func (s structPLS) Save() ([]Property, error) {
var props []Property
if err := s.save(&props, "", saveOpts{}); err != nil {
return nil, err
}
return props, nil
}
func (s structPLS) save(props *[]Property, prefix string, opts saveOpts) error {
for name, f := range s.codec.fields {
name = prefix + name
v := s.v.FieldByIndex(f.path)
if !v.IsValid() || !v.CanSet() {
continue
}
var opts1 saveOpts
opts1.noIndex = opts.noIndex || f.noIndex
opts1.multiple = opts.multiple
opts1.omitEmpty = f.omitEmpty // don't propagate
// For slice fields that aren't []byte, save each element.
if v.Kind() == reflect.Slice && v.Type().Elem().Kind() != reflect.Uint8 {
opts1.multiple = true
for j := 0; j < v.Len(); j++ {
if err := saveStructProperty(props, name, opts1, v.Index(j)); err != nil {
return err
}
}
continue
}
// Otherwise, save the field itself.
if err := saveStructProperty(props, name, opts1, v); err != nil {
return err
}
}
return nil
}
func propertiesToProto(defaultAppID string, key *Key, props []Property) (*pb.EntityProto, error) {
e := &pb.EntityProto{
Key: keyToProto(defaultAppID, key),
}
if key.parent == nil {
e.EntityGroup = &pb.Path{}
} else {
e.EntityGroup = keyToProto(defaultAppID, key.root()).Path
}
prevMultiple := make(map[string]bool)
for _, p := range props {
if pm, ok := prevMultiple[p.Name]; ok {
if !pm || !p.Multiple {
return nil, fmt.Errorf("datastore: multiple Properties with Name %q, but Multiple is false", p.Name)
}
} else {
prevMultiple[p.Name] = p.Multiple
}
x := &pb.Property{
Name: proto.String(p.Name),
Value: new(pb.PropertyValue),
Multiple: proto.Bool(p.Multiple),
}
switch v := p.Value.(type) {
case int64:
x.Value.Int64Value = proto.Int64(v)
case bool:
x.Value.BooleanValue = proto.Bool(v)
case string:
x.Value.StringValue = proto.String(v)
if p.NoIndex {
x.Meaning = pb.Property_TEXT.Enum()
}
case float64:
x.Value.DoubleValue = proto.Float64(v)
case *Key:
if v != nil {
x.Value.Referencevalue = keyToReferenceValue(defaultAppID, v)
}
case time.Time:
if v.Before(minTime) || v.After(maxTime) {
return nil, fmt.Errorf("datastore: time value out of range")
}
x.Value.Int64Value = proto.Int64(toUnixMicro(v))
x.Meaning = pb.Property_GD_WHEN.Enum()
case appengine.BlobKey:
x.Value.StringValue = proto.String(string(v))
x.Meaning = pb.Property_BLOBKEY.Enum()
case appengine.GeoPoint:
if !v.Valid() {
return nil, fmt.Errorf("datastore: invalid GeoPoint value")
}
// NOTE: Strangely, latitude maps to X, longitude to Y.
x.Value.Pointvalue = &pb.PropertyValue_PointValue{X: &v.Lat, Y: &v.Lng}
x.Meaning = pb.Property_GEORSS_POINT.Enum()
case []byte:
x.Value.StringValue = proto.String(string(v))
x.Meaning = pb.Property_BLOB.Enum()
if !p.NoIndex {
return nil, fmt.Errorf("datastore: cannot index a []byte valued Property with Name %q", p.Name)
}
case ByteString:
x.Value.StringValue = proto.String(string(v))
x.Meaning = pb.Property_BYTESTRING.Enum()
default:
if p.Value != nil {
return nil, fmt.Errorf("datastore: invalid Value type for a Property with Name %q", p.Name)
}
}
if p.NoIndex {
e.RawProperty = append(e.RawProperty, x)
} else {
e.Property = append(e.Property, x)
if len(e.Property) > maxIndexedProperties {
return nil, errors.New("datastore: too many indexed properties")
}
}
}
return e, nil
}
// isEmptyValue is taken from the encoding/json package in the standard library.
func isEmptyValue(v reflect.Value) bool {
switch v.Kind() {
case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
// TODO(perfomance): Only reflect.String needed, other property types are not supported (copy/paste from json package)
return v.Len() == 0
case reflect.Bool:
return !v.Bool()
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return v.Int() == 0
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
// TODO(perfomance): Uint* are unsupported property types - should be removed (copy/paste from json package)
return v.Uint() == 0
case reflect.Float32, reflect.Float64:
return v.Float() == 0
case reflect.Interface, reflect.Ptr:
return v.IsNil()
case reflect.Struct:
switch x := v.Interface().(type) {
case time.Time:
return x.IsZero()
}
}
return false
}

View File

@ -1,65 +0,0 @@
// Copyright 2012 Google Inc. All Rights Reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package datastore
import (
"testing"
"time"
)
func TestUnixMicro(t *testing.T) {
// Test that all these time.Time values survive a round trip to unix micros.
testCases := []time.Time{
{},
time.Date(2, 1, 1, 0, 0, 0, 0, time.UTC),
time.Date(23, 1, 1, 0, 0, 0, 0, time.UTC),
time.Date(234, 1, 1, 0, 0, 0, 0, time.UTC),
time.Date(1000, 1, 1, 0, 0, 0, 0, time.UTC),
time.Date(1600, 1, 1, 0, 0, 0, 0, time.UTC),
time.Date(1700, 1, 1, 0, 0, 0, 0, time.UTC),
time.Date(1800, 1, 1, 0, 0, 0, 0, time.UTC),
time.Date(1900, 1, 1, 0, 0, 0, 0, time.UTC),
time.Unix(-1e6, -1000),
time.Unix(-1e6, 0),
time.Unix(-1e6, +1000),
time.Unix(-60, -1000),
time.Unix(-60, 0),
time.Unix(-60, +1000),
time.Unix(-1, -1000),
time.Unix(-1, 0),
time.Unix(-1, +1000),
time.Unix(0, -3000),
time.Unix(0, -2000),
time.Unix(0, -1000),
time.Unix(0, 0),
time.Unix(0, +1000),
time.Unix(0, +2000),
time.Unix(+60, -1000),
time.Unix(+60, 0),
time.Unix(+60, +1000),
time.Unix(+1e6, -1000),
time.Unix(+1e6, 0),
time.Unix(+1e6, +1000),
time.Date(1999, 12, 31, 23, 59, 59, 999000, time.UTC),
time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC),
time.Date(2006, 1, 2, 15, 4, 5, 678000, time.UTC),
time.Date(2009, 11, 10, 23, 0, 0, 0, time.UTC),
time.Date(3456, 1, 1, 0, 0, 0, 0, time.UTC),
}
for _, tc := range testCases {
got := fromUnixMicro(toUnixMicro(tc))
if !got.Equal(tc) {
t.Errorf("got %q, want %q", got, tc)
}
}
// Test that a time.Time that isn't an integral number of microseconds
// is not perfectly reconstructed after a round trip.
t0 := time.Unix(0, 123)
t1 := fromUnixMicro(toUnixMicro(t0))
if t1.Nanosecond()%1000 != 0 || t0.Nanosecond()%1000 == 0 {
t.Errorf("quantization to µs: got %q with %d ns, started with %d ns", t1, t1.Nanosecond(), t0.Nanosecond())
}
}

View File

@ -1,96 +0,0 @@
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package datastore
import (
"errors"
"golang.org/x/net/context"
"google.golang.org/appengine/internal"
pb "google.golang.org/appengine/internal/datastore"
)
func init() {
internal.RegisterTransactionSetter(func(x *pb.Query, t *pb.Transaction) {
x.Transaction = t
})
internal.RegisterTransactionSetter(func(x *pb.GetRequest, t *pb.Transaction) {
x.Transaction = t
})
internal.RegisterTransactionSetter(func(x *pb.PutRequest, t *pb.Transaction) {
x.Transaction = t
})
internal.RegisterTransactionSetter(func(x *pb.DeleteRequest, t *pb.Transaction) {
x.Transaction = t
})
}
// ErrConcurrentTransaction is returned when a transaction is rolled back due
// to a conflict with a concurrent transaction.
var ErrConcurrentTransaction = errors.New("datastore: concurrent transaction")
// RunInTransaction runs f in a transaction. It calls f with a transaction
// context tc that f should use for all App Engine operations.
//
// If f returns nil, RunInTransaction attempts to commit the transaction,
// returning nil if it succeeds. If the commit fails due to a conflicting
// transaction, RunInTransaction retries f, each time with a new transaction
// context. It gives up and returns ErrConcurrentTransaction after three
// failed attempts. The number of attempts can be configured by specifying
// TransactionOptions.Attempts.
//
// If f returns non-nil, then any datastore changes will not be applied and
// RunInTransaction returns that same error. The function f is not retried.
//
// Note that when f returns, the transaction is not yet committed. Calling code
// must be careful not to assume that any of f's changes have been committed
// until RunInTransaction returns nil.
//
// Since f may be called multiple times, f should usually be idempotent.
// datastore.Get is not idempotent when unmarshaling slice fields.
//
// Nested transactions are not supported; c may not be a transaction context.
func RunInTransaction(c context.Context, f func(tc context.Context) error, opts *TransactionOptions) error {
xg := false
if opts != nil {
xg = opts.XG
}
readOnly := false
if opts != nil {
readOnly = opts.ReadOnly
}
attempts := 3
if opts != nil && opts.Attempts > 0 {
attempts = opts.Attempts
}
var t *pb.Transaction
var err error
for i := 0; i < attempts; i++ {
if t, err = internal.RunTransactionOnce(c, f, xg, readOnly, t); err != internal.ErrConcurrentTransaction {
return err
}
}
return ErrConcurrentTransaction
}
// TransactionOptions are the options for running a transaction.
type TransactionOptions struct {
// XG is whether the transaction can cross multiple entity groups. In
// comparison, a single group transaction is one where all datastore keys
// used have the same root key. Note that cross group transactions do not
// have the same behavior as single group transactions. In particular, it
// is much more likely to see partially applied transactions in different
// entity groups, in global queries.
// It is valid to set XG to true even if the transaction is within a
// single entity group.
XG bool
// Attempts controls the number of retries to perform when commits fail
// due to a conflicting transaction. If omitted, it defaults to 3.
Attempts int
// ReadOnly controls whether the transaction is a read only transaction.
// Read only transactions are potentially more efficient.
ReadOnly bool
}

View File

@ -1,360 +0,0 @@
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
/*
Package delay provides a way to execute code outside the scope of a
user request by using the taskqueue API.
To declare a function that may be executed later, call Func
in a top-level assignment context, passing it an arbitrary string key
and a function whose first argument is of type context.Context.
The key is used to look up the function so it can be called later.
var laterFunc = delay.Func("key", myFunc)
It is also possible to use a function literal.
var laterFunc = delay.Func("key", func(c context.Context, x string) {
// ...
})
To call a function, invoke its Call method.
laterFunc.Call(c, "something")
A function may be called any number of times. If the function has any
return arguments, and the last one is of type error, the function may
return a non-nil error to signal that the function should be retried.
The arguments to functions may be of any type that is encodable by the gob
package. If an argument is of interface type, it is the client's responsibility
to register with the gob package whatever concrete type may be passed for that
argument; see http://golang.org/pkg/gob/#Register for details.
Any errors during initialization or execution of a function will be
logged to the application logs. Error logs that occur during initialization will
be associated with the request that invoked the Call method.
The state of a function invocation that has not yet successfully
executed is preserved by combining the file name in which it is declared
with the string key that was passed to the Func function. Updating an app
with pending function invocations should safe as long as the relevant
functions have the (filename, key) combination preserved. The filename is
parsed according to these rules:
* Paths in package main are shortened to just the file name (github.com/foo/foo.go -> foo.go)
* Paths are stripped to just package paths (/go/src/github.com/foo/bar.go -> github.com/foo/bar.go)
* Module versions are stripped (/go/pkg/mod/github.com/foo/bar@v0.0.0-20181026220418-f595d03440dc/baz.go -> github.com/foo/bar/baz.go)
There is some inherent risk of pending function invocations being lost during
an update that contains large changes. For example, switching from using GOPATH
to go.mod is a large change that may inadvertently cause file paths to change.
The delay package uses the Task Queue API to create tasks that call the
reserved application path "/_ah/queue/go/delay".
This path must not be marked as "login: required" in app.yaml;
it must be marked as "login: admin" or have no access restriction.
*/
package delay // import "google.golang.org/appengine/delay"
import (
"bytes"
stdctx "context"
"encoding/gob"
"errors"
"fmt"
"go/build"
stdlog "log"
"net/http"
"path/filepath"
"reflect"
"regexp"
"runtime"
"strings"
"golang.org/x/net/context"
"google.golang.org/appengine"
"google.golang.org/appengine/internal"
"google.golang.org/appengine/log"
"google.golang.org/appengine/taskqueue"
)
// Function represents a function that may have a delayed invocation.
type Function struct {
fv reflect.Value // Kind() == reflect.Func
key string
err error // any error during initialization
}
const (
// The HTTP path for invocations.
path = "/_ah/queue/go/delay"
// Use the default queue.
queue = ""
)
type contextKey int
var (
// registry of all delayed functions
funcs = make(map[string]*Function)
// precomputed types
errorType = reflect.TypeOf((*error)(nil)).Elem()
// errors
errFirstArg = errors.New("first argument must be context.Context")
errOutsideDelayFunc = errors.New("request headers are only available inside a delay.Func")
// context keys
headersContextKey contextKey = 0
stdContextType = reflect.TypeOf((*stdctx.Context)(nil)).Elem()
netContextType = reflect.TypeOf((*context.Context)(nil)).Elem()
)
func isContext(t reflect.Type) bool {
return t == stdContextType || t == netContextType
}
var modVersionPat = regexp.MustCompile("@v[^/]+")
// fileKey finds a stable representation of the caller's file path.
// For calls from package main: strip all leading path entries, leaving just the filename.
// For calls from anywhere else, strip $GOPATH/src, leaving just the package path and file path.
func fileKey(file string) (string, error) {
if !internal.IsSecondGen() || internal.MainPath == "" {
return file, nil
}
// If the caller is in the same Dir as mainPath, then strip everything but the file name.
if filepath.Dir(file) == internal.MainPath {
return filepath.Base(file), nil
}
// If the path contains "_gopath/src/", which is what the builder uses for
// apps which don't use go modules, strip everything up to and including src.
// Or, if the path starts with /tmp/staging, then we're importing a package
// from the app's module (and we must be using go modules), and we have a
// path like /tmp/staging1234/srv/... so strip everything up to and
// including the first /srv/.
// And be sure to look at the GOPATH, for local development.
s := string(filepath.Separator)
for _, s := range []string{filepath.Join("_gopath", "src") + s, s + "srv" + s, filepath.Join(build.Default.GOPATH, "src") + s} {
if idx := strings.Index(file, s); idx > 0 {
return file[idx+len(s):], nil
}
}
// Finally, if that all fails then we must be using go modules, and the file is a module,
// so the path looks like /go/pkg/mod/github.com/foo/bar@v0.0.0-20181026220418-f595d03440dc/baz.go
// So... remove everything up to and including mod, plus the @.... version string.
m := "/mod/"
if idx := strings.Index(file, m); idx > 0 {
file = file[idx+len(m):]
} else {
return file, fmt.Errorf("fileKey: unknown file path format for %q", file)
}
return modVersionPat.ReplaceAllString(file, ""), nil
}
// Func declares a new Function. The second argument must be a function with a
// first argument of type context.Context.
// This function must be called at program initialization time. That means it
// must be called in a global variable declaration or from an init function.
// This restriction is necessary because the instance that delays a function
// call may not be the one that executes it. Only the code executed at program
// initialization time is guaranteed to have been run by an instance before it
// receives a request.
func Func(key string, i interface{}) *Function {
f := &Function{fv: reflect.ValueOf(i)}
// Derive unique, somewhat stable key for this func.
_, file, _, _ := runtime.Caller(1)
fk, err := fileKey(file)
if err != nil {
// Not fatal, but log the error
stdlog.Printf("delay: %v", err)
}
f.key = fk + ":" + key
t := f.fv.Type()
if t.Kind() != reflect.Func {
f.err = errors.New("not a function")
return f
}
if t.NumIn() == 0 || !isContext(t.In(0)) {
f.err = errFirstArg
return f
}
// Register the function's arguments with the gob package.
// This is required because they are marshaled inside a []interface{}.
// gob.Register only expects to be called during initialization;
// that's fine because this function expects the same.
for i := 0; i < t.NumIn(); i++ {
// Only concrete types may be registered. If the argument has
// interface type, the client is resposible for registering the
// concrete types it will hold.
if t.In(i).Kind() == reflect.Interface {
continue
}
gob.Register(reflect.Zero(t.In(i)).Interface())
}
if old := funcs[f.key]; old != nil {
old.err = fmt.Errorf("multiple functions registered for %s in %s", key, file)
}
funcs[f.key] = f
return f
}
type invocation struct {
Key string
Args []interface{}
}
// Call invokes a delayed function.
// err := f.Call(c, ...)
// is equivalent to
// t, _ := f.Task(...)
// _, err := taskqueue.Add(c, t, "")
func (f *Function) Call(c context.Context, args ...interface{}) error {
t, err := f.Task(args...)
if err != nil {
return err
}
_, err = taskqueueAdder(c, t, queue)
return err
}
// Task creates a Task that will invoke the function.
// Its parameters may be tweaked before adding it to a queue.
// Users should not modify the Path or Payload fields of the returned Task.
func (f *Function) Task(args ...interface{}) (*taskqueue.Task, error) {
if f.err != nil {
return nil, fmt.Errorf("delay: func is invalid: %v", f.err)
}
nArgs := len(args) + 1 // +1 for the context.Context
ft := f.fv.Type()
minArgs := ft.NumIn()
if ft.IsVariadic() {
minArgs--
}
if nArgs < minArgs {
return nil, fmt.Errorf("delay: too few arguments to func: %d < %d", nArgs, minArgs)
}
if !ft.IsVariadic() && nArgs > minArgs {
return nil, fmt.Errorf("delay: too many arguments to func: %d > %d", nArgs, minArgs)
}
// Check arg types.
for i := 1; i < nArgs; i++ {
at := reflect.TypeOf(args[i-1])
var dt reflect.Type
if i < minArgs {
// not a variadic arg
dt = ft.In(i)
} else {
// a variadic arg
dt = ft.In(minArgs).Elem()
}
// nil arguments won't have a type, so they need special handling.
if at == nil {
// nil interface
switch dt.Kind() {
case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
continue // may be nil
}
return nil, fmt.Errorf("delay: argument %d has wrong type: %v is not nilable", i, dt)
}
switch at.Kind() {
case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
av := reflect.ValueOf(args[i-1])
if av.IsNil() {
// nil value in interface; not supported by gob, so we replace it
// with a nil interface value
args[i-1] = nil
}
}
if !at.AssignableTo(dt) {
return nil, fmt.Errorf("delay: argument %d has wrong type: %v is not assignable to %v", i, at, dt)
}
}
inv := invocation{
Key: f.key,
Args: args,
}
buf := new(bytes.Buffer)
if err := gob.NewEncoder(buf).Encode(inv); err != nil {
return nil, fmt.Errorf("delay: gob encoding failed: %v", err)
}
return &taskqueue.Task{
Path: path,
Payload: buf.Bytes(),
}, nil
}
// Request returns the special task-queue HTTP request headers for the current
// task queue handler. Returns an error if called from outside a delay.Func.
func RequestHeaders(c context.Context) (*taskqueue.RequestHeaders, error) {
if ret, ok := c.Value(headersContextKey).(*taskqueue.RequestHeaders); ok {
return ret, nil
}
return nil, errOutsideDelayFunc
}
var taskqueueAdder = taskqueue.Add // for testing
func init() {
http.HandleFunc(path, func(w http.ResponseWriter, req *http.Request) {
runFunc(appengine.NewContext(req), w, req)
})
}
func runFunc(c context.Context, w http.ResponseWriter, req *http.Request) {
defer req.Body.Close()
c = context.WithValue(c, headersContextKey, taskqueue.ParseRequestHeaders(req.Header))
var inv invocation
if err := gob.NewDecoder(req.Body).Decode(&inv); err != nil {
log.Errorf(c, "delay: failed decoding task payload: %v", err)
log.Warningf(c, "delay: dropping task")
return
}
f := funcs[inv.Key]
if f == nil {
log.Errorf(c, "delay: no func with key %q found", inv.Key)
log.Warningf(c, "delay: dropping task")
return
}
ft := f.fv.Type()
in := []reflect.Value{reflect.ValueOf(c)}
for _, arg := range inv.Args {
var v reflect.Value
if arg != nil {
v = reflect.ValueOf(arg)
} else {
// Task was passed a nil argument, so we must construct
// the zero value for the argument here.
n := len(in) // we're constructing the nth argument
var at reflect.Type
if !ft.IsVariadic() || n < ft.NumIn()-1 {
at = ft.In(n)
} else {
at = ft.In(ft.NumIn() - 1).Elem()
}
v = reflect.Zero(at)
}
in = append(in, v)
}
out := f.fv.Call(in)
if n := ft.NumOut(); n > 0 && ft.Out(n-1) == errorType {
if errv := out[n-1]; !errv.IsNil() {
log.Errorf(c, "delay: func failed (will retry): %v", errv.Interface())
w.WriteHeader(http.StatusInternalServerError)
return
}
}
}

View File

@ -1,541 +0,0 @@
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package delay
import (
"bytes"
stdctx "context"
"encoding/gob"
"errors"
"fmt"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"reflect"
"testing"
"github.com/golang/protobuf/proto"
"golang.org/x/net/context"
"google.golang.org/appengine/internal"
"google.golang.org/appengine/taskqueue"
)
type CustomType struct {
N int
}
type CustomInterface interface {
N() int
}
type CustomImpl int
func (c CustomImpl) N() int { return int(c) }
// CustomImpl needs to be registered with gob.
func init() {
gob.Register(CustomImpl(0))
}
var (
invalidFunc = Func("invalid", func() {})
regFuncRuns = 0
regFuncMsg = ""
regFunc = Func("reg", func(c context.Context, arg string) {
regFuncRuns++
regFuncMsg = arg
})
custFuncTally = 0
custFunc = Func("cust", func(c context.Context, ct *CustomType, ci CustomInterface) {
a, b := 2, 3
if ct != nil {
a = ct.N
}
if ci != nil {
b = ci.N()
}
custFuncTally += a + b
})
anotherCustFunc = Func("cust2", func(c context.Context, n int, ct *CustomType, ci CustomInterface) {
})
varFuncMsg = ""
varFunc = Func("variadic", func(c context.Context, format string, args ...int) {
// convert []int to []interface{} for fmt.Sprintf.
as := make([]interface{}, len(args))
for i, a := range args {
as[i] = a
}
varFuncMsg = fmt.Sprintf(format, as...)
})
errFuncRuns = 0
errFuncErr = errors.New("error!")
errFunc = Func("err", func(c context.Context) error {
errFuncRuns++
if errFuncRuns == 1 {
return nil
}
return errFuncErr
})
dupeWhich = 0
dupe1Func = Func("dupe", func(c context.Context) {
if dupeWhich == 0 {
dupeWhich = 1
}
})
dupe2Func = Func("dupe", func(c context.Context) {
if dupeWhich == 0 {
dupeWhich = 2
}
})
reqFuncRuns = 0
reqFuncHeaders *taskqueue.RequestHeaders
reqFuncErr error
reqFunc = Func("req", func(c context.Context) {
reqFuncRuns++
reqFuncHeaders, reqFuncErr = RequestHeaders(c)
})
stdCtxRuns = 0
stdCtxFunc = Func("stdctx", func(c stdctx.Context) {
stdCtxRuns++
})
)
type fakeContext struct {
ctx context.Context
logging [][]interface{}
}
func newFakeContext() *fakeContext {
f := new(fakeContext)
f.ctx = internal.WithCallOverride(context.Background(), f.call)
f.ctx = internal.WithLogOverride(f.ctx, f.logf)
return f
}
func (f *fakeContext) call(ctx context.Context, service, method string, in, out proto.Message) error {
panic("should never be called")
}
var logLevels = map[int64]string{1: "INFO", 3: "ERROR"}
func (f *fakeContext) logf(level int64, format string, args ...interface{}) {
f.logging = append(f.logging, append([]interface{}{logLevels[level], format}, args...))
}
func TestInvalidFunction(t *testing.T) {
c := newFakeContext()
if got, want := invalidFunc.Call(c.ctx), fmt.Errorf("delay: func is invalid: %s", errFirstArg); got.Error() != want.Error() {
t.Errorf("Incorrect error: got %q, want %q", got, want)
}
}
func TestVariadicFunctionArguments(t *testing.T) {
// Check the argument type validation for variadic functions.
c := newFakeContext()
calls := 0
taskqueueAdder = func(c context.Context, t *taskqueue.Task, _ string) (*taskqueue.Task, error) {
calls++
return t, nil
}
varFunc.Call(c.ctx, "hi")
varFunc.Call(c.ctx, "%d", 12)
varFunc.Call(c.ctx, "%d %d %d", 3, 1, 4)
if calls != 3 {
t.Errorf("Got %d calls to taskqueueAdder, want 3", calls)
}
if got, want := varFunc.Call(c.ctx, "%d %s", 12, "a string is bad"), errors.New("delay: argument 3 has wrong type: string is not assignable to int"); got.Error() != want.Error() {
t.Errorf("Incorrect error: got %q, want %q", got, want)
}
}
func TestBadArguments(t *testing.T) {
// Try running regFunc with different sets of inappropriate arguments.
c := newFakeContext()
tests := []struct {
args []interface{} // all except context
wantErr string
}{
{
args: nil,
wantErr: "delay: too few arguments to func: 1 < 2",
},
{
args: []interface{}{"lala", 53},
wantErr: "delay: too many arguments to func: 3 > 2",
},
{
args: []interface{}{53},
wantErr: "delay: argument 1 has wrong type: int is not assignable to string",
},
}
for i, tc := range tests {
got := regFunc.Call(c.ctx, tc.args...)
if got.Error() != tc.wantErr {
t.Errorf("Call %v: got %q, want %q", i, got, tc.wantErr)
}
}
}
func TestRunningFunction(t *testing.T) {
c := newFakeContext()
// Fake out the adding of a task.
var task *taskqueue.Task
taskqueueAdder = func(_ context.Context, tk *taskqueue.Task, queue string) (*taskqueue.Task, error) {
if queue != "" {
t.Errorf(`Got queue %q, expected ""`, queue)
}
task = tk
return tk, nil
}
regFuncRuns, regFuncMsg = 0, "" // reset state
const msg = "Why, hello!"
regFunc.Call(c.ctx, msg)
// Simulate the Task Queue service.
req, err := http.NewRequest("POST", path, bytes.NewBuffer(task.Payload))
if err != nil {
t.Fatalf("Failed making http.Request: %v", err)
}
rw := httptest.NewRecorder()
runFunc(c.ctx, rw, req)
if regFuncRuns != 1 {
t.Errorf("regFuncRuns: got %d, want 1", regFuncRuns)
}
if regFuncMsg != msg {
t.Errorf("regFuncMsg: got %q, want %q", regFuncMsg, msg)
}
}
func TestCustomType(t *testing.T) {
c := newFakeContext()
// Fake out the adding of a task.
var task *taskqueue.Task
taskqueueAdder = func(_ context.Context, tk *taskqueue.Task, queue string) (*taskqueue.Task, error) {
if queue != "" {
t.Errorf(`Got queue %q, expected ""`, queue)
}
task = tk
return tk, nil
}
custFuncTally = 0 // reset state
custFunc.Call(c.ctx, &CustomType{N: 11}, CustomImpl(13))
// Simulate the Task Queue service.
req, err := http.NewRequest("POST", path, bytes.NewBuffer(task.Payload))
if err != nil {
t.Fatalf("Failed making http.Request: %v", err)
}
rw := httptest.NewRecorder()
runFunc(c.ctx, rw, req)
if custFuncTally != 24 {
t.Errorf("custFuncTally = %d, want 24", custFuncTally)
}
// Try the same, but with nil values; one is a nil pointer (and thus a non-nil interface value),
// and the other is a nil interface value.
custFuncTally = 0 // reset state
custFunc.Call(c.ctx, (*CustomType)(nil), nil)
// Simulate the Task Queue service.
req, err = http.NewRequest("POST", path, bytes.NewBuffer(task.Payload))
if err != nil {
t.Fatalf("Failed making http.Request: %v", err)
}
rw = httptest.NewRecorder()
runFunc(c.ctx, rw, req)
if custFuncTally != 5 {
t.Errorf("custFuncTally = %d, want 5", custFuncTally)
}
}
func TestRunningVariadic(t *testing.T) {
c := newFakeContext()
// Fake out the adding of a task.
var task *taskqueue.Task
taskqueueAdder = func(_ context.Context, tk *taskqueue.Task, queue string) (*taskqueue.Task, error) {
if queue != "" {
t.Errorf(`Got queue %q, expected ""`, queue)
}
task = tk
return tk, nil
}
varFuncMsg = "" // reset state
varFunc.Call(c.ctx, "Amiga %d has %d KB RAM", 500, 512)
// Simulate the Task Queue service.
req, err := http.NewRequest("POST", path, bytes.NewBuffer(task.Payload))
if err != nil {
t.Fatalf("Failed making http.Request: %v", err)
}
rw := httptest.NewRecorder()
runFunc(c.ctx, rw, req)
const expected = "Amiga 500 has 512 KB RAM"
if varFuncMsg != expected {
t.Errorf("varFuncMsg = %q, want %q", varFuncMsg, expected)
}
}
func TestErrorFunction(t *testing.T) {
c := newFakeContext()
// Fake out the adding of a task.
var task *taskqueue.Task
taskqueueAdder = func(_ context.Context, tk *taskqueue.Task, queue string) (*taskqueue.Task, error) {
if queue != "" {
t.Errorf(`Got queue %q, expected ""`, queue)
}
task = tk
return tk, nil
}
errFunc.Call(c.ctx)
// Simulate the Task Queue service.
// The first call should succeed; the second call should fail.
{
req, err := http.NewRequest("POST", path, bytes.NewBuffer(task.Payload))
if err != nil {
t.Fatalf("Failed making http.Request: %v", err)
}
rw := httptest.NewRecorder()
runFunc(c.ctx, rw, req)
}
{
req, err := http.NewRequest("POST", path, bytes.NewBuffer(task.Payload))
if err != nil {
t.Fatalf("Failed making http.Request: %v", err)
}
rw := httptest.NewRecorder()
runFunc(c.ctx, rw, req)
if rw.Code != http.StatusInternalServerError {
t.Errorf("Got status code %d, want %d", rw.Code, http.StatusInternalServerError)
}
wantLogging := [][]interface{}{
{"ERROR", "delay: func failed (will retry): %v", errFuncErr},
}
if !reflect.DeepEqual(c.logging, wantLogging) {
t.Errorf("Incorrect logging: got %+v, want %+v", c.logging, wantLogging)
}
}
}
func TestDuplicateFunction(t *testing.T) {
c := newFakeContext()
// Fake out the adding of a task.
var task *taskqueue.Task
taskqueueAdder = func(_ context.Context, tk *taskqueue.Task, queue string) (*taskqueue.Task, error) {
if queue != "" {
t.Errorf(`Got queue %q, expected ""`, queue)
}
task = tk
return tk, nil
}
if err := dupe1Func.Call(c.ctx); err == nil {
t.Error("dupe1Func.Call did not return error")
}
if task != nil {
t.Error("dupe1Func.Call posted a task")
}
if err := dupe2Func.Call(c.ctx); err != nil {
t.Errorf("dupe2Func.Call error: %v", err)
}
if task == nil {
t.Fatalf("dupe2Func.Call did not post a task")
}
// Simulate the Task Queue service.
req, err := http.NewRequest("POST", path, bytes.NewBuffer(task.Payload))
if err != nil {
t.Fatalf("Failed making http.Request: %v", err)
}
rw := httptest.NewRecorder()
runFunc(c.ctx, rw, req)
if dupeWhich == 1 {
t.Error("dupe2Func.Call used old registered function")
} else if dupeWhich != 2 {
t.Errorf("dupeWhich = %d; want 2", dupeWhich)
}
}
func TestGetRequestHeadersFromContext(t *testing.T) {
c := newFakeContext()
// Outside a delay.Func should return an error.
headers, err := RequestHeaders(c.ctx)
if headers != nil {
t.Errorf("RequestHeaders outside Func, got %v, want nil", headers)
}
if err != errOutsideDelayFunc {
t.Errorf("RequestHeaders outside Func err, got %v, want %v", err, errOutsideDelayFunc)
}
// Fake out the adding of a task.
var task *taskqueue.Task
taskqueueAdder = func(_ context.Context, tk *taskqueue.Task, queue string) (*taskqueue.Task, error) {
if queue != "" {
t.Errorf(`Got queue %q, expected ""`, queue)
}
task = tk
return tk, nil
}
reqFunc.Call(c.ctx)
reqFuncRuns, reqFuncHeaders = 0, nil // reset state
// Simulate the Task Queue service.
req, err := http.NewRequest("POST", path, bytes.NewBuffer(task.Payload))
req.Header.Set("x-appengine-taskname", "foobar")
if err != nil {
t.Fatalf("Failed making http.Request: %v", err)
}
rw := httptest.NewRecorder()
runFunc(c.ctx, rw, req)
if reqFuncRuns != 1 {
t.Errorf("reqFuncRuns: got %d, want 1", reqFuncRuns)
}
if reqFuncHeaders.TaskName != "foobar" {
t.Errorf("reqFuncHeaders.TaskName: got %v, want 'foobar'", reqFuncHeaders.TaskName)
}
if reqFuncErr != nil {
t.Errorf("reqFuncErr: got %v, want nil", reqFuncErr)
}
}
func TestStandardContext(t *testing.T) {
// Fake out the adding of a task.
var task *taskqueue.Task
taskqueueAdder = func(_ context.Context, tk *taskqueue.Task, queue string) (*taskqueue.Task, error) {
if queue != "" {
t.Errorf(`Got queue %q, expected ""`, queue)
}
task = tk
return tk, nil
}
c := newFakeContext()
stdCtxRuns = 0 // reset state
if err := stdCtxFunc.Call(c.ctx); err != nil {
t.Fatal("Function.Call:", err)
}
// Simulate the Task Queue service.
req, err := http.NewRequest("POST", path, bytes.NewBuffer(task.Payload))
if err != nil {
t.Fatalf("Failed making http.Request: %v", err)
}
rw := httptest.NewRecorder()
runFunc(c.ctx, rw, req)
if stdCtxRuns != 1 {
t.Errorf("stdCtxRuns: got %d, want 1", stdCtxRuns)
}
}
func TestFileKey(t *testing.T) {
os.Setenv("GAE_ENV", "standard")
tests := []struct {
mainPath string
file string
want string
}{
// first-gen
{
"",
filepath.FromSlash("srv/foo.go"),
filepath.FromSlash("srv/foo.go"),
},
// gopath
{
filepath.FromSlash("/tmp/staging1234/srv/"),
filepath.FromSlash("/tmp/staging1234/srv/foo.go"),
"foo.go",
},
{
filepath.FromSlash("/tmp/staging1234/srv/_gopath/src/example.com/foo"),
filepath.FromSlash("/tmp/staging1234/srv/_gopath/src/example.com/foo/foo.go"),
"foo.go",
},
{
filepath.FromSlash("/tmp/staging2234/srv/_gopath/src/example.com/foo"),
filepath.FromSlash("/tmp/staging2234/srv/_gopath/src/example.com/foo/bar/bar.go"),
filepath.FromSlash("example.com/foo/bar/bar.go"),
},
{
filepath.FromSlash("/tmp/staging3234/srv/_gopath/src/example.com/foo"),
filepath.FromSlash("/tmp/staging3234/srv/_gopath/src/example.com/bar/main.go"),
filepath.FromSlash("example.com/bar/main.go"),
},
// go mod, same package
{
filepath.FromSlash("/tmp/staging3234/srv"),
filepath.FromSlash("/tmp/staging3234/srv/main.go"),
"main.go",
},
{
filepath.FromSlash("/tmp/staging3234/srv"),
filepath.FromSlash("/tmp/staging3234/srv/bar/main.go"),
filepath.FromSlash("bar/main.go"),
},
{
filepath.FromSlash("/tmp/staging3234/srv/cmd"),
filepath.FromSlash("/tmp/staging3234/srv/cmd/main.go"),
"main.go",
},
{
filepath.FromSlash("/tmp/staging3234/srv/cmd"),
filepath.FromSlash("/tmp/staging3234/srv/bar/main.go"),
filepath.FromSlash("bar/main.go"),
},
// go mod, other package
{
filepath.FromSlash("/tmp/staging3234/srv"),
filepath.FromSlash("/go/pkg/mod/github.com/foo/bar@v0.0.0-20181026220418-f595d03440dc/baz.go"),
filepath.FromSlash("github.com/foo/bar/baz.go"),
},
}
for i, tc := range tests {
internal.MainPath = tc.mainPath
got, err := fileKey(tc.file)
if err != nil {
t.Errorf("Unexpected error, call %v, file %q: %v", i, tc.file, err)
continue
}
if got != tc.want {
t.Errorf("Call %v, file %q: got %q, want %q", i, tc.file, got, tc.want)
}
}
}

View File

@ -1,14 +0,0 @@
# Demo application for App Engine "flexible environment".
runtime: go
vm: true
api_version: go1
handlers:
# Favicon. Without this, the browser hits this once per page view.
- url: /favicon.ico
static_files: favicon.ico
upload: favicon.ico
# Main app. All the real work is here.
- url: /.*
script: _go_app

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,109 +0,0 @@
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// This example only works on App Engine "flexible environment".
// +build !appengine
package main
import (
"html/template"
"net/http"
"time"
"golang.org/x/net/context"
"google.golang.org/appengine"
"google.golang.org/appengine/datastore"
"google.golang.org/appengine/log"
"google.golang.org/appengine/user"
)
var initTime time.Time
type Greeting struct {
Author string
Content string
Date time.Time
}
func main() {
http.HandleFunc("/", handleMainPage)
http.HandleFunc("/sign", handleSign)
appengine.Main()
}
// guestbookKey returns the key used for all guestbook entries.
func guestbookKey(ctx context.Context) *datastore.Key {
// The string "default_guestbook" here could be varied to have multiple guestbooks.
return datastore.NewKey(ctx, "Guestbook", "default_guestbook", 0, nil)
}
var tpl = template.Must(template.ParseGlob("templates/*.html"))
func handleMainPage(w http.ResponseWriter, r *http.Request) {
if r.Method != "GET" {
http.Error(w, "GET requests only", http.StatusMethodNotAllowed)
return
}
if r.URL.Path != "/" {
http.NotFound(w, r)
return
}
ctx := appengine.NewContext(r)
tic := time.Now()
q := datastore.NewQuery("Greeting").Ancestor(guestbookKey(ctx)).Order("-Date").Limit(10)
var gg []*Greeting
if _, err := q.GetAll(ctx, &gg); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
log.Errorf(ctx, "GetAll: %v", err)
return
}
log.Infof(ctx, "Datastore lookup took %s", time.Since(tic).String())
log.Infof(ctx, "Rendering %d greetings", len(gg))
var email, logout, login string
if u := user.Current(ctx); u != nil {
logout, _ = user.LogoutURL(ctx, "/")
email = u.Email
} else {
login, _ = user.LoginURL(ctx, "/")
}
data := struct {
Greetings []*Greeting
Login, Logout, Email string
}{
Greetings: gg,
Login: login,
Logout: logout,
Email: email,
}
w.Header().Set("Content-Type", "text/html; charset=utf-8")
if err := tpl.ExecuteTemplate(w, "guestbook.html", data); err != nil {
log.Errorf(ctx, "%v", err)
}
}
func handleSign(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
http.Error(w, "POST requests only", http.StatusMethodNotAllowed)
return
}
ctx := appengine.NewContext(r)
g := &Greeting{
Content: r.FormValue("content"),
Date: time.Now(),
}
if u := user.Current(ctx); u != nil {
g.Author = u.String()
}
key := datastore.NewIncompleteKey(ctx, "Greeting", guestbookKey(ctx))
if _, err := datastore.Put(ctx, key, g); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
// Redirect with 303 which causes the subsequent request to use GET.
http.Redirect(w, r, "/", http.StatusSeeOther)
}

View File

@ -1,7 +0,0 @@
indexes:
- kind: Greeting
ancestor: yes
properties:
- name: Date
direction: desc

View File

@ -1,26 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Guestbook Demo</title>
</head>
<body>
<p>
{{with .Email}}You are currently logged in as {{.}}.{{end}}
{{with .Login}}<a href="{{.}}">Sign in</a>{{end}}
{{with .Logout}}<a href="{{.}}">Sign out</a>{{end}}
</p>
{{range .Greetings }}
<p>
{{with .Author}}<b>{{.}}</b>{{else}}An anonymous person{{end}}
on <em>{{.Date.Format "3:04pm, Mon 2 Jan"}}</em>
wrote <blockquote>{{.Content}}</blockquote>
</p>
{{end}}
<form action="/sign" method="post">
<div><textarea name="content" rows="3" cols="60"></textarea></div>
<div><input type="submit" value="Sign Guestbook"></div>
</form>
</body>
</html>

View File

@ -1,10 +0,0 @@
runtime: go
api_version: go1
vm: true
handlers:
- url: /favicon.ico
static_files: favicon.ico
upload: favicon.ico
- url: /.*
script: _go_app

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,50 +0,0 @@
// Copyright 2014 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// This example only works on App Engine "flexible environment".
// +build !appengine
package main
import (
"html/template"
"net/http"
"time"
"google.golang.org/appengine"
"google.golang.org/appengine/log"
)
var initTime = time.Now()
func main() {
http.HandleFunc("/", handle)
appengine.Main()
}
func handle(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
http.NotFound(w, r)
return
}
ctx := appengine.NewContext(r)
log.Infof(ctx, "Serving the front page.")
tmpl.Execute(w, time.Since(initTime))
}
var tmpl = template.Must(template.New("front").Parse(`
<html><body>
<p>
Hello, World! 세상아 안녕!
</p>
<p>
This instance has been running for <em>{{.}}</em>.
</p>
</body></html>
`))

View File

@ -1,46 +0,0 @@
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// This file provides error functions for common API failure modes.
package appengine
import (
"fmt"
"google.golang.org/appengine/internal"
)
// IsOverQuota reports whether err represents an API call failure
// due to insufficient available quota.
func IsOverQuota(err error) bool {
callErr, ok := err.(*internal.CallError)
return ok && callErr.Code == 4
}
// MultiError is returned by batch operations when there are errors with
// particular elements. Errors will be in a one-to-one correspondence with
// the input elements; successful elements will have a nil entry.
type MultiError []error
func (m MultiError) Error() string {
s, n := "", 0
for _, e := range m {
if e != nil {
if n == 0 {
s = e.Error()
}
n++
}
}
switch n {
case 0:
return "(0 errors)"
case 1:
return s
case 2:
return s + " (and 1 other error)"
}
return fmt.Sprintf("%s (and %d other errors)", s, n-1)
}

View File

@ -1,28 +0,0 @@
// Copyright 2014 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// Package file provides helper functions for using Google Cloud Storage.
package file
import (
"fmt"
"golang.org/x/net/context"
"google.golang.org/appengine/internal"
aipb "google.golang.org/appengine/internal/app_identity"
)
// DefaultBucketName returns the name of this application's
// default Google Cloud Storage bucket.
func DefaultBucketName(c context.Context) (string, error) {
req := &aipb.GetDefaultGcsBucketNameRequest{}
res := &aipb.GetDefaultGcsBucketNameResponse{}
err := internal.Call(c, "app_identity_service", "GetDefaultGcsBucketName", req, res)
if err != nil {
return "", fmt.Errorf("file: no default bucket name returned in RPC response: %v", res)
}
return res.GetDefaultGcsBucketName(), nil
}

View File

@ -1,7 +0,0 @@
module google.golang.org/appengine
require (
github.com/golang/protobuf v1.2.0
golang.org/x/net v0.0.0-20180724234803-3673e40ba225
golang.org/x/text v0.3.0
)

View File

@ -1,6 +0,0 @@
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225 h1:kNX+jCowfMYzvlSvJu5pQWEmyWFrBXJ3PBy10xKMXK8=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

View File

@ -1,142 +0,0 @@
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package appengine
import (
"time"
"golang.org/x/net/context"
"google.golang.org/appengine/internal"
pb "google.golang.org/appengine/internal/app_identity"
modpb "google.golang.org/appengine/internal/modules"
)
// AppID returns the application ID for the current application.
// The string will be a plain application ID (e.g. "appid"), with a
// domain prefix for custom domain deployments (e.g. "example.com:appid").
func AppID(c context.Context) string { return internal.AppID(c) }
// DefaultVersionHostname returns the standard hostname of the default version
// of the current application (e.g. "my-app.appspot.com"). This is suitable for
// use in constructing URLs.
func DefaultVersionHostname(c context.Context) string {
return internal.DefaultVersionHostname(c)
}
// ModuleName returns the module name of the current instance.
func ModuleName(c context.Context) string {
return internal.ModuleName(c)
}
// ModuleHostname returns a hostname of a module instance.
// If module is the empty string, it refers to the module of the current instance.
// If version is empty, it refers to the version of the current instance if valid,
// or the default version of the module of the current instance.
// If instance is empty, ModuleHostname returns the load-balancing hostname.
func ModuleHostname(c context.Context, module, version, instance string) (string, error) {
req := &modpb.GetHostnameRequest{}
if module != "" {
req.Module = &module
}
if version != "" {
req.Version = &version
}
if instance != "" {
req.Instance = &instance
}
res := &modpb.GetHostnameResponse{}
if err := internal.Call(c, "modules", "GetHostname", req, res); err != nil {
return "", err
}
return *res.Hostname, nil
}
// VersionID returns the version ID for the current application.
// It will be of the form "X.Y", where X is specified in app.yaml,
// and Y is a number generated when each version of the app is uploaded.
// It does not include a module name.
func VersionID(c context.Context) string { return internal.VersionID(c) }
// InstanceID returns a mostly-unique identifier for this instance.
func InstanceID() string { return internal.InstanceID() }
// Datacenter returns an identifier for the datacenter that the instance is running in.
func Datacenter(c context.Context) string { return internal.Datacenter(c) }
// ServerSoftware returns the App Engine release version.
// In production, it looks like "Google App Engine/X.Y.Z".
// In the development appserver, it looks like "Development/X.Y".
func ServerSoftware() string { return internal.ServerSoftware() }
// RequestID returns a string that uniquely identifies the request.
func RequestID(c context.Context) string { return internal.RequestID(c) }
// AccessToken generates an OAuth2 access token for the specified scopes on
// behalf of service account of this application. This token will expire after
// the returned time.
func AccessToken(c context.Context, scopes ...string) (token string, expiry time.Time, err error) {
req := &pb.GetAccessTokenRequest{Scope: scopes}
res := &pb.GetAccessTokenResponse{}
err = internal.Call(c, "app_identity_service", "GetAccessToken", req, res)
if err != nil {
return "", time.Time{}, err
}
return res.GetAccessToken(), time.Unix(res.GetExpirationTime(), 0), nil
}
// Certificate represents a public certificate for the app.
type Certificate struct {
KeyName string
Data []byte // PEM-encoded X.509 certificate
}
// PublicCertificates retrieves the public certificates for the app.
// They can be used to verify a signature returned by SignBytes.
func PublicCertificates(c context.Context) ([]Certificate, error) {
req := &pb.GetPublicCertificateForAppRequest{}
res := &pb.GetPublicCertificateForAppResponse{}
if err := internal.Call(c, "app_identity_service", "GetPublicCertificatesForApp", req, res); err != nil {
return nil, err
}
var cs []Certificate
for _, pc := range res.PublicCertificateList {
cs = append(cs, Certificate{
KeyName: pc.GetKeyName(),
Data: []byte(pc.GetX509CertificatePem()),
})
}
return cs, nil
}
// ServiceAccount returns a string representing the service account name, in
// the form of an email address (typically app_id@appspot.gserviceaccount.com).
func ServiceAccount(c context.Context) (string, error) {
req := &pb.GetServiceAccountNameRequest{}
res := &pb.GetServiceAccountNameResponse{}
err := internal.Call(c, "app_identity_service", "GetServiceAccountName", req, res)
if err != nil {
return "", err
}
return res.GetServiceAccountName(), err
}
// SignBytes signs bytes using a private key unique to your application.
func SignBytes(c context.Context, bytes []byte) (keyName string, signature []byte, err error) {
req := &pb.SignForAppRequest{BytesToSign: bytes}
res := &pb.SignForAppResponse{}
if err := internal.Call(c, "app_identity_service", "SignForApp", req, res); err != nil {
return "", nil, err
}
return res.GetKeyName(), res.GetSignatureBytes(), nil
}
func init() {
internal.RegisterErrorCodeMap("app_identity_service", pb.AppIdentityServiceError_ErrorCode_name)
internal.RegisterErrorCodeMap("modules", modpb.ModulesServiceError_ErrorCode_name)
}

View File

@ -1,67 +0,0 @@
// Copyright 2012 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// Package image provides image services.
package image // import "google.golang.org/appengine/image"
import (
"fmt"
"net/url"
"golang.org/x/net/context"
"google.golang.org/appengine"
"google.golang.org/appengine/internal"
pb "google.golang.org/appengine/internal/image"
)
type ServingURLOptions struct {
Secure bool // whether the URL should use HTTPS
// Size must be between zero and 1600.
// If Size is non-zero, a resized version of the image is served,
// and Size is the served image's longest dimension. The aspect ratio is preserved.
// If Crop is true the image is cropped from the center instead of being resized.
Size int
Crop bool
}
// ServingURL returns a URL that will serve an image from Blobstore.
func ServingURL(c context.Context, key appengine.BlobKey, opts *ServingURLOptions) (*url.URL, error) {
req := &pb.ImagesGetUrlBaseRequest{
BlobKey: (*string)(&key),
}
if opts != nil && opts.Secure {
req.CreateSecureUrl = &opts.Secure
}
res := &pb.ImagesGetUrlBaseResponse{}
if err := internal.Call(c, "images", "GetUrlBase", req, res); err != nil {
return nil, err
}
// The URL may have suffixes added to dynamically resize or crop:
// - adding "=s32" will serve the image resized to 32 pixels, preserving the aspect ratio.
// - adding "=s32-c" is the same as "=s32" except it will be cropped.
u := *res.Url
if opts != nil && opts.Size > 0 {
u += fmt.Sprintf("=s%d", opts.Size)
if opts.Crop {
u += "-c"
}
}
return url.Parse(u)
}
// DeleteServingURL deletes the serving URL for an image.
func DeleteServingURL(c context.Context, key appengine.BlobKey) error {
req := &pb.ImagesDeleteUrlBaseRequest{
BlobKey: (*string)(&key),
}
res := &pb.ImagesDeleteUrlBaseResponse{}
return internal.Call(c, "images", "DeleteUrlBase", req, res)
}
func init() {
internal.RegisterErrorCodeMap("images", pb.ImagesServiceError_ErrorCode_name)
}

View File

@ -1,81 +0,0 @@
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// Package aetesting provides utilities for testing App Engine packages.
// This is not for testing user applications.
package aetesting
import (
"fmt"
"net/http"
"reflect"
"testing"
"github.com/golang/protobuf/proto"
"golang.org/x/net/context"
"google.golang.org/appengine/internal"
)
// FakeSingleContext returns a context whose Call invocations will be serviced
// by f, which should be a function that has two arguments of the input and output
// protocol buffer type, and one error return.
func FakeSingleContext(t *testing.T, service, method string, f interface{}) context.Context {
fv := reflect.ValueOf(f)
if fv.Kind() != reflect.Func {
t.Fatal("not a function")
}
ft := fv.Type()
if ft.NumIn() != 2 || ft.NumOut() != 1 {
t.Fatalf("f has %d in and %d out, want 2 in and 1 out", ft.NumIn(), ft.NumOut())
}
for i := 0; i < 2; i++ {
at := ft.In(i)
if !at.Implements(protoMessageType) {
t.Fatalf("arg %d does not implement proto.Message", i)
}
}
if ft.Out(0) != errorType {
t.Fatalf("f's return is %v, want error", ft.Out(0))
}
s := &single{
t: t,
service: service,
method: method,
f: fv,
}
return internal.WithCallOverride(internal.ContextForTesting(&http.Request{}), s.call)
}
var (
protoMessageType = reflect.TypeOf((*proto.Message)(nil)).Elem()
errorType = reflect.TypeOf((*error)(nil)).Elem()
)
type single struct {
t *testing.T
service, method string
f reflect.Value
}
func (s *single) call(ctx context.Context, service, method string, in, out proto.Message) error {
if service == "__go__" {
if method == "GetNamespace" {
return nil // always yield an empty namespace
}
return fmt.Errorf("Unknown API call /%s.%s", service, method)
}
if service != s.service || method != s.method {
s.t.Fatalf("Unexpected call to /%s.%s", service, method)
}
ins := []reflect.Value{
reflect.ValueOf(in),
reflect.ValueOf(out),
}
outs := s.f.Call(ins)
if outs[0].IsNil() {
return nil
}
return outs[0].Interface().(error)
}

View File

@ -1,9 +0,0 @@
// Copyright 2014 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// +build race
package internal
func init() { raceDetector = true }

View File

@ -1,500 +0,0 @@
// Copyright 2014 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// +build !appengine
package internal
import (
"bufio"
"bytes"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
"net/url"
"os"
"os/exec"
"strings"
"sync/atomic"
"testing"
"time"
"github.com/golang/protobuf/proto"
netcontext "golang.org/x/net/context"
basepb "google.golang.org/appengine/internal/base"
remotepb "google.golang.org/appengine/internal/remote_api"
)
const testTicketHeader = "X-Magic-Ticket-Header"
func init() {
ticketHeader = testTicketHeader
}
type fakeAPIHandler struct {
hang chan int // used for RunSlowly RPC
LogFlushes int32 // atomic
}
func (f *fakeAPIHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
writeResponse := func(res *remotepb.Response) {
hresBody, err := proto.Marshal(res)
if err != nil {
http.Error(w, fmt.Sprintf("Failed encoding API response: %v", err), 500)
return
}
w.Write(hresBody)
}
if r.URL.Path != "/rpc_http" {
http.NotFound(w, r)
return
}
hreqBody, err := ioutil.ReadAll(r.Body)
if err != nil {
http.Error(w, fmt.Sprintf("Bad body: %v", err), 500)
return
}
apiReq := &remotepb.Request{}
if err := proto.Unmarshal(hreqBody, apiReq); err != nil {
http.Error(w, fmt.Sprintf("Bad encoded API request: %v", err), 500)
return
}
if *apiReq.RequestId != "s3cr3t" && *apiReq.RequestId != DefaultTicket() {
writeResponse(&remotepb.Response{
RpcError: &remotepb.RpcError{
Code: proto.Int32(int32(remotepb.RpcError_SECURITY_VIOLATION)),
Detail: proto.String("bad security ticket"),
},
})
return
}
if got, want := r.Header.Get(dapperHeader), "trace-001"; got != want {
writeResponse(&remotepb.Response{
RpcError: &remotepb.RpcError{
Code: proto.Int32(int32(remotepb.RpcError_BAD_REQUEST)),
Detail: proto.String(fmt.Sprintf("trace info = %q, want %q", got, want)),
},
})
return
}
service, method := *apiReq.ServiceName, *apiReq.Method
var resOut proto.Message
if service == "actordb" && method == "LookupActor" {
req := &basepb.StringProto{}
res := &basepb.StringProto{}
if err := proto.Unmarshal(apiReq.Request, req); err != nil {
http.Error(w, fmt.Sprintf("Bad encoded request: %v", err), 500)
return
}
if *req.Value == "Doctor Who" {
res.Value = proto.String("David Tennant")
}
resOut = res
}
if service == "errors" {
switch method {
case "Non200":
http.Error(w, "I'm a little teapot.", 418)
return
case "ShortResponse":
w.Header().Set("Content-Length", "100")
w.Write([]byte("way too short"))
return
case "OverQuota":
writeResponse(&remotepb.Response{
RpcError: &remotepb.RpcError{
Code: proto.Int32(int32(remotepb.RpcError_OVER_QUOTA)),
Detail: proto.String("you are hogging the resources!"),
},
})
return
case "RunSlowly":
// TestAPICallRPCFailure creates f.hang, but does not strobe it
// until Call returns with remotepb.RpcError_CANCELLED.
// This is here to force a happens-before relationship between
// the httptest server handler and shutdown.
<-f.hang
resOut = &basepb.VoidProto{}
}
}
if service == "logservice" && method == "Flush" {
// Pretend log flushing is slow.
time.Sleep(50 * time.Millisecond)
atomic.AddInt32(&f.LogFlushes, 1)
resOut = &basepb.VoidProto{}
}
encOut, err := proto.Marshal(resOut)
if err != nil {
http.Error(w, fmt.Sprintf("Failed encoding response: %v", err), 500)
return
}
writeResponse(&remotepb.Response{
Response: encOut,
})
}
func setup() (f *fakeAPIHandler, c *context, cleanup func()) {
f = &fakeAPIHandler{}
srv := httptest.NewServer(f)
u, err := url.Parse(srv.URL + apiPath)
if err != nil {
panic(fmt.Sprintf("url.Parse(%q): %v", srv.URL+apiPath, err))
}
return f, &context{
req: &http.Request{
Header: http.Header{
ticketHeader: []string{"s3cr3t"},
dapperHeader: []string{"trace-001"},
},
},
apiURL: u,
}, srv.Close
}
func TestAPICall(t *testing.T) {
_, c, cleanup := setup()
defer cleanup()
req := &basepb.StringProto{
Value: proto.String("Doctor Who"),
}
res := &basepb.StringProto{}
err := Call(toContext(c), "actordb", "LookupActor", req, res)
if err != nil {
t.Fatalf("API call failed: %v", err)
}
if got, want := *res.Value, "David Tennant"; got != want {
t.Errorf("Response is %q, want %q", got, want)
}
}
func TestAPICallTicketUnavailable(t *testing.T) {
resetEnv := SetTestEnv()
defer resetEnv()
_, c, cleanup := setup()
defer cleanup()
c.req.Header.Set(ticketHeader, "")
req := &basepb.StringProto{
Value: proto.String("Doctor Who"),
}
res := &basepb.StringProto{}
err := Call(toContext(c), "actordb", "LookupActor", req, res)
if err != nil {
t.Fatalf("API call failed: %v", err)
}
if got, want := *res.Value, "David Tennant"; got != want {
t.Errorf("Response is %q, want %q", got, want)
}
}
func TestAPICallRPCFailure(t *testing.T) {
f, c, cleanup := setup()
defer cleanup()
testCases := []struct {
method string
code remotepb.RpcError_ErrorCode
}{
{"Non200", remotepb.RpcError_UNKNOWN},
{"ShortResponse", remotepb.RpcError_UNKNOWN},
{"OverQuota", remotepb.RpcError_OVER_QUOTA},
{"RunSlowly", remotepb.RpcError_CANCELLED},
}
f.hang = make(chan int) // only for RunSlowly
for _, tc := range testCases {
ctx, _ := netcontext.WithTimeout(toContext(c), 100*time.Millisecond)
err := Call(ctx, "errors", tc.method, &basepb.VoidProto{}, &basepb.VoidProto{})
ce, ok := err.(*CallError)
if !ok {
t.Errorf("%s: API call error is %T (%v), want *CallError", tc.method, err, err)
continue
}
if ce.Code != int32(tc.code) {
t.Errorf("%s: ce.Code = %d, want %d", tc.method, ce.Code, tc.code)
}
if tc.method == "RunSlowly" {
f.hang <- 1 // release the HTTP handler
}
}
}
func TestAPICallDialFailure(t *testing.T) {
// See what happens if the API host is unresponsive.
// This should time out quickly, not hang forever.
_, c, cleanup := setup()
defer cleanup()
// Reset the URL to the production address so that dialing fails.
c.apiURL = apiURL()
start := time.Now()
err := Call(toContext(c), "foo", "bar", &basepb.VoidProto{}, &basepb.VoidProto{})
const max = 1 * time.Second
if taken := time.Since(start); taken > max {
t.Errorf("Dial hang took too long: %v > %v", taken, max)
}
if err == nil {
t.Error("Call did not fail")
}
}
func TestDelayedLogFlushing(t *testing.T) {
f, c, cleanup := setup()
defer cleanup()
http.HandleFunc("/slow_log", func(w http.ResponseWriter, r *http.Request) {
logC := WithContext(netcontext.Background(), r)
fromContext(logC).apiURL = c.apiURL // Otherwise it will try to use the default URL.
Logf(logC, 1, "It's a lovely day.")
w.WriteHeader(200)
time.Sleep(1200 * time.Millisecond)
w.Write(make([]byte, 100<<10)) // write 100 KB to force HTTP flush
})
r := &http.Request{
Method: "GET",
URL: &url.URL{
Scheme: "http",
Path: "/slow_log",
},
Header: c.req.Header,
Body: ioutil.NopCloser(bytes.NewReader(nil)),
}
w := httptest.NewRecorder()
handled := make(chan struct{})
go func() {
defer close(handled)
handleHTTP(w, r)
}()
// Check that the log flush eventually comes in.
time.Sleep(1200 * time.Millisecond)
if f := atomic.LoadInt32(&f.LogFlushes); f != 1 {
t.Errorf("After 1.2s: f.LogFlushes = %d, want 1", f)
}
<-handled
const hdr = "X-AppEngine-Log-Flush-Count"
if got, want := w.HeaderMap.Get(hdr), "1"; got != want {
t.Errorf("%s header = %q, want %q", hdr, got, want)
}
if got, want := atomic.LoadInt32(&f.LogFlushes), int32(2); got != want {
t.Errorf("After HTTP response: f.LogFlushes = %d, want %d", got, want)
}
}
func TestLogFlushing(t *testing.T) {
f, c, cleanup := setup()
defer cleanup()
http.HandleFunc("/quick_log", func(w http.ResponseWriter, r *http.Request) {
logC := WithContext(netcontext.Background(), r)
fromContext(logC).apiURL = c.apiURL // Otherwise it will try to use the default URL.
Logf(logC, 1, "It's a lovely day.")
w.WriteHeader(200)
w.Write(make([]byte, 100<<10)) // write 100 KB to force HTTP flush
})
r := &http.Request{
Method: "GET",
URL: &url.URL{
Scheme: "http",
Path: "/quick_log",
},
Header: c.req.Header,
Body: ioutil.NopCloser(bytes.NewReader(nil)),
}
w := httptest.NewRecorder()
handleHTTP(w, r)
const hdr = "X-AppEngine-Log-Flush-Count"
if got, want := w.HeaderMap.Get(hdr), "1"; got != want {
t.Errorf("%s header = %q, want %q", hdr, got, want)
}
if got, want := atomic.LoadInt32(&f.LogFlushes), int32(1); got != want {
t.Errorf("After HTTP response: f.LogFlushes = %d, want %d", got, want)
}
}
func TestRemoteAddr(t *testing.T) {
var addr string
http.HandleFunc("/remote_addr", func(w http.ResponseWriter, r *http.Request) {
addr = r.RemoteAddr
})
testCases := []struct {
headers http.Header
addr string
}{
{http.Header{"X-Appengine-User-Ip": []string{"10.5.2.1"}}, "10.5.2.1:80"},
{http.Header{"X-Appengine-Remote-Addr": []string{"1.2.3.4"}}, "1.2.3.4:80"},
{http.Header{"X-Appengine-Remote-Addr": []string{"1.2.3.4:8080"}}, "1.2.3.4:8080"},
{
http.Header{"X-Appengine-Remote-Addr": []string{"2401:fa00:9:1:7646:a0ff:fe90:ca66"}},
"[2401:fa00:9:1:7646:a0ff:fe90:ca66]:80",
},
{
http.Header{"X-Appengine-Remote-Addr": []string{"[::1]:http"}},
"[::1]:http",
},
{http.Header{}, "127.0.0.1:80"},
}
for _, tc := range testCases {
r := &http.Request{
Method: "GET",
URL: &url.URL{Scheme: "http", Path: "/remote_addr"},
Header: tc.headers,
Body: ioutil.NopCloser(bytes.NewReader(nil)),
}
handleHTTP(httptest.NewRecorder(), r)
if addr != tc.addr {
t.Errorf("Header %v, got %q, want %q", tc.headers, addr, tc.addr)
}
}
}
func TestPanickingHandler(t *testing.T) {
http.HandleFunc("/panic", func(http.ResponseWriter, *http.Request) {
panic("whoops!")
})
r := &http.Request{
Method: "GET",
URL: &url.URL{Scheme: "http", Path: "/panic"},
Body: ioutil.NopCloser(bytes.NewReader(nil)),
}
rec := httptest.NewRecorder()
handleHTTP(rec, r)
if rec.Code != 500 {
t.Errorf("Panicking handler returned HTTP %d, want HTTP %d", rec.Code, 500)
}
}
var raceDetector = false
func TestAPICallAllocations(t *testing.T) {
if raceDetector {
t.Skip("not running under race detector")
}
// Run the test API server in a subprocess so we aren't counting its allocations.
u, cleanup := launchHelperProcess(t)
defer cleanup()
c := &context{
req: &http.Request{
Header: http.Header{
ticketHeader: []string{"s3cr3t"},
dapperHeader: []string{"trace-001"},
},
},
apiURL: u,
}
req := &basepb.StringProto{
Value: proto.String("Doctor Who"),
}
res := &basepb.StringProto{}
var apiErr error
avg := testing.AllocsPerRun(100, func() {
ctx, _ := netcontext.WithTimeout(toContext(c), 100*time.Millisecond)
if err := Call(ctx, "actordb", "LookupActor", req, res); err != nil && apiErr == nil {
apiErr = err // get the first error only
}
})
if apiErr != nil {
t.Errorf("API call failed: %v", apiErr)
}
// Lots of room for improvement...
const min, max float64 = 60, 85
if avg < min || max < avg {
t.Errorf("Allocations per API call = %g, want in [%g,%g]", avg, min, max)
}
}
func launchHelperProcess(t *testing.T) (apiURL *url.URL, cleanup func()) {
cmd := exec.Command(os.Args[0], "-test.run=TestHelperProcess")
cmd.Env = []string{"GO_WANT_HELPER_PROCESS=1"}
stdin, err := cmd.StdinPipe()
if err != nil {
t.Fatalf("StdinPipe: %v", err)
}
stdout, err := cmd.StdoutPipe()
if err != nil {
t.Fatalf("StdoutPipe: %v", err)
}
if err := cmd.Start(); err != nil {
t.Fatalf("Starting helper process: %v", err)
}
scan := bufio.NewScanner(stdout)
var u *url.URL
for scan.Scan() {
line := scan.Text()
if hp := strings.TrimPrefix(line, helperProcessMagic); hp != line {
var err error
u, err = url.Parse(hp)
if err != nil {
t.Fatalf("Failed to parse %q: %v", hp, err)
}
break
}
}
if err := scan.Err(); err != nil {
t.Fatalf("Scanning helper process stdout: %v", err)
}
if u == nil {
t.Fatal("Helper process never reported")
}
return u, func() {
stdin.Close()
if err := cmd.Wait(); err != nil {
t.Errorf("Helper process did not exit cleanly: %v", err)
}
}
}
const helperProcessMagic = "A lovely helper process is listening at "
// This isn't a real test. It's used as a helper process.
func TestHelperProcess(*testing.T) {
if os.Getenv("GO_WANT_HELPER_PROCESS") != "1" {
return
}
defer os.Exit(0)
f := &fakeAPIHandler{}
srv := httptest.NewServer(f)
defer srv.Close()
fmt.Println(helperProcessMagic + srv.URL + apiPath)
// Wait for stdin to be closed.
io.Copy(ioutil.Discard, os.Stdin)
}
func TestBackgroundContext(t *testing.T) {
resetEnv := SetTestEnv()
defer resetEnv()
ctx, key := fromContext(BackgroundContext()), "X-Magic-Ticket-Header"
if g, w := ctx.req.Header.Get(key), "my-app-id/default.20150612t184001.0"; g != w {
t.Errorf("%v = %q, want %q", key, g, w)
}
// Check that using the background context doesn't panic.
req := &basepb.StringProto{
Value: proto.String("Doctor Who"),
}
res := &basepb.StringProto{}
Call(BackgroundContext(), "actordb", "LookupActor", req, res) // expected to fail
}

View File

@ -1,34 +0,0 @@
// Copyright 2011 Google Inc. All Rights Reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package internal
import (
"testing"
)
func TestAppIDParsing(t *testing.T) {
testCases := []struct {
in string
partition, domain, displayID string
}{
{"simple-app-id", "", "", "simple-app-id"},
{"domain.com:domain-app-id", "", "domain.com", "domain-app-id"},
{"part~partition-app-id", "part", "", "partition-app-id"},
{"part~domain.com:display", "part", "domain.com", "display"},
}
for _, tc := range testCases {
part, dom, dis := parseFullAppID(tc.in)
if part != tc.partition {
t.Errorf("partition of %q: got %q, want %q", tc.in, part, tc.partition)
}
if dom != tc.domain {
t.Errorf("domain of %q: got %q, want %q", tc.in, dom, tc.domain)
}
if dis != tc.displayID {
t.Errorf("displayID of %q: got %q, want %q", tc.in, dis, tc.displayID)
}
}
}

View File

@ -1,611 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: google.golang.org/appengine/internal/app_identity/app_identity_service.proto
package app_identity
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type AppIdentityServiceError_ErrorCode int32
const (
AppIdentityServiceError_SUCCESS AppIdentityServiceError_ErrorCode = 0
AppIdentityServiceError_UNKNOWN_SCOPE AppIdentityServiceError_ErrorCode = 9
AppIdentityServiceError_BLOB_TOO_LARGE AppIdentityServiceError_ErrorCode = 1000
AppIdentityServiceError_DEADLINE_EXCEEDED AppIdentityServiceError_ErrorCode = 1001
AppIdentityServiceError_NOT_A_VALID_APP AppIdentityServiceError_ErrorCode = 1002
AppIdentityServiceError_UNKNOWN_ERROR AppIdentityServiceError_ErrorCode = 1003
AppIdentityServiceError_NOT_ALLOWED AppIdentityServiceError_ErrorCode = 1005
AppIdentityServiceError_NOT_IMPLEMENTED AppIdentityServiceError_ErrorCode = 1006
)
var AppIdentityServiceError_ErrorCode_name = map[int32]string{
0: "SUCCESS",
9: "UNKNOWN_SCOPE",
1000: "BLOB_TOO_LARGE",
1001: "DEADLINE_EXCEEDED",
1002: "NOT_A_VALID_APP",
1003: "UNKNOWN_ERROR",
1005: "NOT_ALLOWED",
1006: "NOT_IMPLEMENTED",
}
var AppIdentityServiceError_ErrorCode_value = map[string]int32{
"SUCCESS": 0,
"UNKNOWN_SCOPE": 9,
"BLOB_TOO_LARGE": 1000,
"DEADLINE_EXCEEDED": 1001,
"NOT_A_VALID_APP": 1002,
"UNKNOWN_ERROR": 1003,
"NOT_ALLOWED": 1005,
"NOT_IMPLEMENTED": 1006,
}
func (x AppIdentityServiceError_ErrorCode) Enum() *AppIdentityServiceError_ErrorCode {
p := new(AppIdentityServiceError_ErrorCode)
*p = x
return p
}
func (x AppIdentityServiceError_ErrorCode) String() string {
return proto.EnumName(AppIdentityServiceError_ErrorCode_name, int32(x))
}
func (x *AppIdentityServiceError_ErrorCode) UnmarshalJSON(data []byte) error {
value, err := proto.UnmarshalJSONEnum(AppIdentityServiceError_ErrorCode_value, data, "AppIdentityServiceError_ErrorCode")
if err != nil {
return err
}
*x = AppIdentityServiceError_ErrorCode(value)
return nil
}
func (AppIdentityServiceError_ErrorCode) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_app_identity_service_08a6e3f74b04cfa4, []int{0, 0}
}
type AppIdentityServiceError struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *AppIdentityServiceError) Reset() { *m = AppIdentityServiceError{} }
func (m *AppIdentityServiceError) String() string { return proto.CompactTextString(m) }
func (*AppIdentityServiceError) ProtoMessage() {}
func (*AppIdentityServiceError) Descriptor() ([]byte, []int) {
return fileDescriptor_app_identity_service_08a6e3f74b04cfa4, []int{0}
}
func (m *AppIdentityServiceError) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_AppIdentityServiceError.Unmarshal(m, b)
}
func (m *AppIdentityServiceError) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_AppIdentityServiceError.Marshal(b, m, deterministic)
}
func (dst *AppIdentityServiceError) XXX_Merge(src proto.Message) {
xxx_messageInfo_AppIdentityServiceError.Merge(dst, src)
}
func (m *AppIdentityServiceError) XXX_Size() int {
return xxx_messageInfo_AppIdentityServiceError.Size(m)
}
func (m *AppIdentityServiceError) XXX_DiscardUnknown() {
xxx_messageInfo_AppIdentityServiceError.DiscardUnknown(m)
}
var xxx_messageInfo_AppIdentityServiceError proto.InternalMessageInfo
type SignForAppRequest struct {
BytesToSign []byte `protobuf:"bytes,1,opt,name=bytes_to_sign,json=bytesToSign" json:"bytes_to_sign,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *SignForAppRequest) Reset() { *m = SignForAppRequest{} }
func (m *SignForAppRequest) String() string { return proto.CompactTextString(m) }
func (*SignForAppRequest) ProtoMessage() {}
func (*SignForAppRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_app_identity_service_08a6e3f74b04cfa4, []int{1}
}
func (m *SignForAppRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SignForAppRequest.Unmarshal(m, b)
}
func (m *SignForAppRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_SignForAppRequest.Marshal(b, m, deterministic)
}
func (dst *SignForAppRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_SignForAppRequest.Merge(dst, src)
}
func (m *SignForAppRequest) XXX_Size() int {
return xxx_messageInfo_SignForAppRequest.Size(m)
}
func (m *SignForAppRequest) XXX_DiscardUnknown() {
xxx_messageInfo_SignForAppRequest.DiscardUnknown(m)
}
var xxx_messageInfo_SignForAppRequest proto.InternalMessageInfo
func (m *SignForAppRequest) GetBytesToSign() []byte {
if m != nil {
return m.BytesToSign
}
return nil
}
type SignForAppResponse struct {
KeyName *string `protobuf:"bytes,1,opt,name=key_name,json=keyName" json:"key_name,omitempty"`
SignatureBytes []byte `protobuf:"bytes,2,opt,name=signature_bytes,json=signatureBytes" json:"signature_bytes,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *SignForAppResponse) Reset() { *m = SignForAppResponse{} }
func (m *SignForAppResponse) String() string { return proto.CompactTextString(m) }
func (*SignForAppResponse) ProtoMessage() {}
func (*SignForAppResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_app_identity_service_08a6e3f74b04cfa4, []int{2}
}
func (m *SignForAppResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SignForAppResponse.Unmarshal(m, b)
}
func (m *SignForAppResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_SignForAppResponse.Marshal(b, m, deterministic)
}
func (dst *SignForAppResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_SignForAppResponse.Merge(dst, src)
}
func (m *SignForAppResponse) XXX_Size() int {
return xxx_messageInfo_SignForAppResponse.Size(m)
}
func (m *SignForAppResponse) XXX_DiscardUnknown() {
xxx_messageInfo_SignForAppResponse.DiscardUnknown(m)
}
var xxx_messageInfo_SignForAppResponse proto.InternalMessageInfo
func (m *SignForAppResponse) GetKeyName() string {
if m != nil && m.KeyName != nil {
return *m.KeyName
}
return ""
}
func (m *SignForAppResponse) GetSignatureBytes() []byte {
if m != nil {
return m.SignatureBytes
}
return nil
}
type GetPublicCertificateForAppRequest struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetPublicCertificateForAppRequest) Reset() { *m = GetPublicCertificateForAppRequest{} }
func (m *GetPublicCertificateForAppRequest) String() string { return proto.CompactTextString(m) }
func (*GetPublicCertificateForAppRequest) ProtoMessage() {}
func (*GetPublicCertificateForAppRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_app_identity_service_08a6e3f74b04cfa4, []int{3}
}
func (m *GetPublicCertificateForAppRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetPublicCertificateForAppRequest.Unmarshal(m, b)
}
func (m *GetPublicCertificateForAppRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetPublicCertificateForAppRequest.Marshal(b, m, deterministic)
}
func (dst *GetPublicCertificateForAppRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetPublicCertificateForAppRequest.Merge(dst, src)
}
func (m *GetPublicCertificateForAppRequest) XXX_Size() int {
return xxx_messageInfo_GetPublicCertificateForAppRequest.Size(m)
}
func (m *GetPublicCertificateForAppRequest) XXX_DiscardUnknown() {
xxx_messageInfo_GetPublicCertificateForAppRequest.DiscardUnknown(m)
}
var xxx_messageInfo_GetPublicCertificateForAppRequest proto.InternalMessageInfo
type PublicCertificate struct {
KeyName *string `protobuf:"bytes,1,opt,name=key_name,json=keyName" json:"key_name,omitempty"`
X509CertificatePem *string `protobuf:"bytes,2,opt,name=x509_certificate_pem,json=x509CertificatePem" json:"x509_certificate_pem,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *PublicCertificate) Reset() { *m = PublicCertificate{} }
func (m *PublicCertificate) String() string { return proto.CompactTextString(m) }
func (*PublicCertificate) ProtoMessage() {}
func (*PublicCertificate) Descriptor() ([]byte, []int) {
return fileDescriptor_app_identity_service_08a6e3f74b04cfa4, []int{4}
}
func (m *PublicCertificate) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PublicCertificate.Unmarshal(m, b)
}
func (m *PublicCertificate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_PublicCertificate.Marshal(b, m, deterministic)
}
func (dst *PublicCertificate) XXX_Merge(src proto.Message) {
xxx_messageInfo_PublicCertificate.Merge(dst, src)
}
func (m *PublicCertificate) XXX_Size() int {
return xxx_messageInfo_PublicCertificate.Size(m)
}
func (m *PublicCertificate) XXX_DiscardUnknown() {
xxx_messageInfo_PublicCertificate.DiscardUnknown(m)
}
var xxx_messageInfo_PublicCertificate proto.InternalMessageInfo
func (m *PublicCertificate) GetKeyName() string {
if m != nil && m.KeyName != nil {
return *m.KeyName
}
return ""
}
func (m *PublicCertificate) GetX509CertificatePem() string {
if m != nil && m.X509CertificatePem != nil {
return *m.X509CertificatePem
}
return ""
}
type GetPublicCertificateForAppResponse struct {
PublicCertificateList []*PublicCertificate `protobuf:"bytes,1,rep,name=public_certificate_list,json=publicCertificateList" json:"public_certificate_list,omitempty"`
MaxClientCacheTimeInSecond *int64 `protobuf:"varint,2,opt,name=max_client_cache_time_in_second,json=maxClientCacheTimeInSecond" json:"max_client_cache_time_in_second,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetPublicCertificateForAppResponse) Reset() { *m = GetPublicCertificateForAppResponse{} }
func (m *GetPublicCertificateForAppResponse) String() string { return proto.CompactTextString(m) }
func (*GetPublicCertificateForAppResponse) ProtoMessage() {}
func (*GetPublicCertificateForAppResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_app_identity_service_08a6e3f74b04cfa4, []int{5}
}
func (m *GetPublicCertificateForAppResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetPublicCertificateForAppResponse.Unmarshal(m, b)
}
func (m *GetPublicCertificateForAppResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetPublicCertificateForAppResponse.Marshal(b, m, deterministic)
}
func (dst *GetPublicCertificateForAppResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetPublicCertificateForAppResponse.Merge(dst, src)
}
func (m *GetPublicCertificateForAppResponse) XXX_Size() int {
return xxx_messageInfo_GetPublicCertificateForAppResponse.Size(m)
}
func (m *GetPublicCertificateForAppResponse) XXX_DiscardUnknown() {
xxx_messageInfo_GetPublicCertificateForAppResponse.DiscardUnknown(m)
}
var xxx_messageInfo_GetPublicCertificateForAppResponse proto.InternalMessageInfo
func (m *GetPublicCertificateForAppResponse) GetPublicCertificateList() []*PublicCertificate {
if m != nil {
return m.PublicCertificateList
}
return nil
}
func (m *GetPublicCertificateForAppResponse) GetMaxClientCacheTimeInSecond() int64 {
if m != nil && m.MaxClientCacheTimeInSecond != nil {
return *m.MaxClientCacheTimeInSecond
}
return 0
}
type GetServiceAccountNameRequest struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetServiceAccountNameRequest) Reset() { *m = GetServiceAccountNameRequest{} }
func (m *GetServiceAccountNameRequest) String() string { return proto.CompactTextString(m) }
func (*GetServiceAccountNameRequest) ProtoMessage() {}
func (*GetServiceAccountNameRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_app_identity_service_08a6e3f74b04cfa4, []int{6}
}
func (m *GetServiceAccountNameRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetServiceAccountNameRequest.Unmarshal(m, b)
}
func (m *GetServiceAccountNameRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetServiceAccountNameRequest.Marshal(b, m, deterministic)
}
func (dst *GetServiceAccountNameRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetServiceAccountNameRequest.Merge(dst, src)
}
func (m *GetServiceAccountNameRequest) XXX_Size() int {
return xxx_messageInfo_GetServiceAccountNameRequest.Size(m)
}
func (m *GetServiceAccountNameRequest) XXX_DiscardUnknown() {
xxx_messageInfo_GetServiceAccountNameRequest.DiscardUnknown(m)
}
var xxx_messageInfo_GetServiceAccountNameRequest proto.InternalMessageInfo
type GetServiceAccountNameResponse struct {
ServiceAccountName *string `protobuf:"bytes,1,opt,name=service_account_name,json=serviceAccountName" json:"service_account_name,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetServiceAccountNameResponse) Reset() { *m = GetServiceAccountNameResponse{} }
func (m *GetServiceAccountNameResponse) String() string { return proto.CompactTextString(m) }
func (*GetServiceAccountNameResponse) ProtoMessage() {}
func (*GetServiceAccountNameResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_app_identity_service_08a6e3f74b04cfa4, []int{7}
}
func (m *GetServiceAccountNameResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetServiceAccountNameResponse.Unmarshal(m, b)
}
func (m *GetServiceAccountNameResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetServiceAccountNameResponse.Marshal(b, m, deterministic)
}
func (dst *GetServiceAccountNameResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetServiceAccountNameResponse.Merge(dst, src)
}
func (m *GetServiceAccountNameResponse) XXX_Size() int {
return xxx_messageInfo_GetServiceAccountNameResponse.Size(m)
}
func (m *GetServiceAccountNameResponse) XXX_DiscardUnknown() {
xxx_messageInfo_GetServiceAccountNameResponse.DiscardUnknown(m)
}
var xxx_messageInfo_GetServiceAccountNameResponse proto.InternalMessageInfo
func (m *GetServiceAccountNameResponse) GetServiceAccountName() string {
if m != nil && m.ServiceAccountName != nil {
return *m.ServiceAccountName
}
return ""
}
type GetAccessTokenRequest struct {
Scope []string `protobuf:"bytes,1,rep,name=scope" json:"scope,omitempty"`
ServiceAccountId *int64 `protobuf:"varint,2,opt,name=service_account_id,json=serviceAccountId" json:"service_account_id,omitempty"`
ServiceAccountName *string `protobuf:"bytes,3,opt,name=service_account_name,json=serviceAccountName" json:"service_account_name,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetAccessTokenRequest) Reset() { *m = GetAccessTokenRequest{} }
func (m *GetAccessTokenRequest) String() string { return proto.CompactTextString(m) }
func (*GetAccessTokenRequest) ProtoMessage() {}
func (*GetAccessTokenRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_app_identity_service_08a6e3f74b04cfa4, []int{8}
}
func (m *GetAccessTokenRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetAccessTokenRequest.Unmarshal(m, b)
}
func (m *GetAccessTokenRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetAccessTokenRequest.Marshal(b, m, deterministic)
}
func (dst *GetAccessTokenRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetAccessTokenRequest.Merge(dst, src)
}
func (m *GetAccessTokenRequest) XXX_Size() int {
return xxx_messageInfo_GetAccessTokenRequest.Size(m)
}
func (m *GetAccessTokenRequest) XXX_DiscardUnknown() {
xxx_messageInfo_GetAccessTokenRequest.DiscardUnknown(m)
}
var xxx_messageInfo_GetAccessTokenRequest proto.InternalMessageInfo
func (m *GetAccessTokenRequest) GetScope() []string {
if m != nil {
return m.Scope
}
return nil
}
func (m *GetAccessTokenRequest) GetServiceAccountId() int64 {
if m != nil && m.ServiceAccountId != nil {
return *m.ServiceAccountId
}
return 0
}
func (m *GetAccessTokenRequest) GetServiceAccountName() string {
if m != nil && m.ServiceAccountName != nil {
return *m.ServiceAccountName
}
return ""
}
type GetAccessTokenResponse struct {
AccessToken *string `protobuf:"bytes,1,opt,name=access_token,json=accessToken" json:"access_token,omitempty"`
ExpirationTime *int64 `protobuf:"varint,2,opt,name=expiration_time,json=expirationTime" json:"expiration_time,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetAccessTokenResponse) Reset() { *m = GetAccessTokenResponse{} }
func (m *GetAccessTokenResponse) String() string { return proto.CompactTextString(m) }
func (*GetAccessTokenResponse) ProtoMessage() {}
func (*GetAccessTokenResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_app_identity_service_08a6e3f74b04cfa4, []int{9}
}
func (m *GetAccessTokenResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetAccessTokenResponse.Unmarshal(m, b)
}
func (m *GetAccessTokenResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetAccessTokenResponse.Marshal(b, m, deterministic)
}
func (dst *GetAccessTokenResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetAccessTokenResponse.Merge(dst, src)
}
func (m *GetAccessTokenResponse) XXX_Size() int {
return xxx_messageInfo_GetAccessTokenResponse.Size(m)
}
func (m *GetAccessTokenResponse) XXX_DiscardUnknown() {
xxx_messageInfo_GetAccessTokenResponse.DiscardUnknown(m)
}
var xxx_messageInfo_GetAccessTokenResponse proto.InternalMessageInfo
func (m *GetAccessTokenResponse) GetAccessToken() string {
if m != nil && m.AccessToken != nil {
return *m.AccessToken
}
return ""
}
func (m *GetAccessTokenResponse) GetExpirationTime() int64 {
if m != nil && m.ExpirationTime != nil {
return *m.ExpirationTime
}
return 0
}
type GetDefaultGcsBucketNameRequest struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetDefaultGcsBucketNameRequest) Reset() { *m = GetDefaultGcsBucketNameRequest{} }
func (m *GetDefaultGcsBucketNameRequest) String() string { return proto.CompactTextString(m) }
func (*GetDefaultGcsBucketNameRequest) ProtoMessage() {}
func (*GetDefaultGcsBucketNameRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_app_identity_service_08a6e3f74b04cfa4, []int{10}
}
func (m *GetDefaultGcsBucketNameRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetDefaultGcsBucketNameRequest.Unmarshal(m, b)
}
func (m *GetDefaultGcsBucketNameRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetDefaultGcsBucketNameRequest.Marshal(b, m, deterministic)
}
func (dst *GetDefaultGcsBucketNameRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetDefaultGcsBucketNameRequest.Merge(dst, src)
}
func (m *GetDefaultGcsBucketNameRequest) XXX_Size() int {
return xxx_messageInfo_GetDefaultGcsBucketNameRequest.Size(m)
}
func (m *GetDefaultGcsBucketNameRequest) XXX_DiscardUnknown() {
xxx_messageInfo_GetDefaultGcsBucketNameRequest.DiscardUnknown(m)
}
var xxx_messageInfo_GetDefaultGcsBucketNameRequest proto.InternalMessageInfo
type GetDefaultGcsBucketNameResponse struct {
DefaultGcsBucketName *string `protobuf:"bytes,1,opt,name=default_gcs_bucket_name,json=defaultGcsBucketName" json:"default_gcs_bucket_name,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetDefaultGcsBucketNameResponse) Reset() { *m = GetDefaultGcsBucketNameResponse{} }
func (m *GetDefaultGcsBucketNameResponse) String() string { return proto.CompactTextString(m) }
func (*GetDefaultGcsBucketNameResponse) ProtoMessage() {}
func (*GetDefaultGcsBucketNameResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_app_identity_service_08a6e3f74b04cfa4, []int{11}
}
func (m *GetDefaultGcsBucketNameResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetDefaultGcsBucketNameResponse.Unmarshal(m, b)
}
func (m *GetDefaultGcsBucketNameResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetDefaultGcsBucketNameResponse.Marshal(b, m, deterministic)
}
func (dst *GetDefaultGcsBucketNameResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetDefaultGcsBucketNameResponse.Merge(dst, src)
}
func (m *GetDefaultGcsBucketNameResponse) XXX_Size() int {
return xxx_messageInfo_GetDefaultGcsBucketNameResponse.Size(m)
}
func (m *GetDefaultGcsBucketNameResponse) XXX_DiscardUnknown() {
xxx_messageInfo_GetDefaultGcsBucketNameResponse.DiscardUnknown(m)
}
var xxx_messageInfo_GetDefaultGcsBucketNameResponse proto.InternalMessageInfo
func (m *GetDefaultGcsBucketNameResponse) GetDefaultGcsBucketName() string {
if m != nil && m.DefaultGcsBucketName != nil {
return *m.DefaultGcsBucketName
}
return ""
}
func init() {
proto.RegisterType((*AppIdentityServiceError)(nil), "appengine.AppIdentityServiceError")
proto.RegisterType((*SignForAppRequest)(nil), "appengine.SignForAppRequest")
proto.RegisterType((*SignForAppResponse)(nil), "appengine.SignForAppResponse")
proto.RegisterType((*GetPublicCertificateForAppRequest)(nil), "appengine.GetPublicCertificateForAppRequest")
proto.RegisterType((*PublicCertificate)(nil), "appengine.PublicCertificate")
proto.RegisterType((*GetPublicCertificateForAppResponse)(nil), "appengine.GetPublicCertificateForAppResponse")
proto.RegisterType((*GetServiceAccountNameRequest)(nil), "appengine.GetServiceAccountNameRequest")
proto.RegisterType((*GetServiceAccountNameResponse)(nil), "appengine.GetServiceAccountNameResponse")
proto.RegisterType((*GetAccessTokenRequest)(nil), "appengine.GetAccessTokenRequest")
proto.RegisterType((*GetAccessTokenResponse)(nil), "appengine.GetAccessTokenResponse")
proto.RegisterType((*GetDefaultGcsBucketNameRequest)(nil), "appengine.GetDefaultGcsBucketNameRequest")
proto.RegisterType((*GetDefaultGcsBucketNameResponse)(nil), "appengine.GetDefaultGcsBucketNameResponse")
}
func init() {
proto.RegisterFile("google.golang.org/appengine/internal/app_identity/app_identity_service.proto", fileDescriptor_app_identity_service_08a6e3f74b04cfa4)
}
var fileDescriptor_app_identity_service_08a6e3f74b04cfa4 = []byte{
// 676 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x54, 0xdb, 0x6e, 0xda, 0x58,
0x14, 0x1d, 0x26, 0x1a, 0x31, 0x6c, 0x12, 0x62, 0xce, 0x90, 0xcb, 0x8c, 0x32, 0xb9, 0x78, 0x1e,
0x26, 0x0f, 0x15, 0x89, 0x2a, 0x45, 0x55, 0x1f, 0x8d, 0xed, 0x22, 0x54, 0x07, 0x53, 0x43, 0x9a,
0xa8, 0x2f, 0xa7, 0xce, 0x61, 0xc7, 0x3d, 0x02, 0x9f, 0xe3, 0xda, 0x87, 0x0a, 0x3e, 0xa2, 0x3f,
0xd2, 0x9f, 0xe8, 0x5b, 0xbf, 0xa5, 0x17, 0xb5, 0xdf, 0x50, 0xd9, 0x38, 0x5c, 0x92, 0x92, 0x37,
0xbc, 0xf6, 0x5a, 0xcb, 0x6b, 0x2f, 0x6d, 0x0c, 0x4e, 0x20, 0x65, 0x30, 0xc4, 0x7a, 0x20, 0x87,
0xbe, 0x08, 0xea, 0x32, 0x0e, 0x4e, 0xfc, 0x28, 0x42, 0x11, 0x70, 0x81, 0x27, 0x5c, 0x28, 0x8c,
0x85, 0x3f, 0x4c, 0x21, 0xca, 0xfb, 0x28, 0x14, 0x57, 0x93, 0xa5, 0x07, 0x9a, 0x60, 0xfc, 0x8e,
0x33, 0xac, 0x47, 0xb1, 0x54, 0x92, 0x94, 0x66, 0x5a, 0xfd, 0x53, 0x01, 0x76, 0x8c, 0x28, 0x6a,
0xe5, 0xc4, 0xee, 0x94, 0x67, 0xc7, 0xb1, 0x8c, 0xf5, 0x0f, 0x05, 0x28, 0x65, 0xbf, 0x4c, 0xd9,
0x47, 0x52, 0x86, 0x62, 0xf7, 0xc2, 0x34, 0xed, 0x6e, 0x57, 0xfb, 0x8d, 0x54, 0x61, 0xe3, 0xa2,
0xfd, 0xbc, 0xed, 0x5e, 0xb6, 0x69, 0xd7, 0x74, 0x3b, 0xb6, 0x56, 0x22, 0x7f, 0x41, 0xa5, 0xe1,
0xb8, 0x0d, 0xda, 0x73, 0x5d, 0xea, 0x18, 0x5e, 0xd3, 0xd6, 0x3e, 0x17, 0xc9, 0x36, 0x54, 0x2d,
0xdb, 0xb0, 0x9c, 0x56, 0xdb, 0xa6, 0xf6, 0x95, 0x69, 0xdb, 0x96, 0x6d, 0x69, 0x5f, 0x8a, 0xa4,
0x06, 0x9b, 0x6d, 0xb7, 0x47, 0x0d, 0xfa, 0xd2, 0x70, 0x5a, 0x16, 0x35, 0x3a, 0x1d, 0xed, 0x6b,
0x91, 0x90, 0xb9, 0xab, 0xed, 0x79, 0xae, 0xa7, 0x7d, 0x2b, 0x12, 0x0d, 0xca, 0x19, 0xd3, 0x71,
0xdc, 0x4b, 0xdb, 0xd2, 0xbe, 0xcf, 0xb4, 0xad, 0xf3, 0x8e, 0x63, 0x9f, 0xdb, 0xed, 0x9e, 0x6d,
0x69, 0x3f, 0x8a, 0xfa, 0x13, 0xa8, 0x76, 0x79, 0x20, 0x9e, 0xc9, 0xd8, 0x88, 0x22, 0x0f, 0xdf,
0x8e, 0x30, 0x51, 0x44, 0x87, 0x8d, 0xeb, 0x89, 0xc2, 0x84, 0x2a, 0x49, 0x13, 0x1e, 0x88, 0xdd,
0xc2, 0x61, 0xe1, 0x78, 0xdd, 0x2b, 0x67, 0x60, 0x4f, 0xa6, 0x02, 0xfd, 0x0a, 0xc8, 0xa2, 0x30,
0x89, 0xa4, 0x48, 0x90, 0xfc, 0x0d, 0x7f, 0x0e, 0x70, 0x42, 0x85, 0x1f, 0x62, 0x26, 0x2a, 0x79,
0xc5, 0x01, 0x4e, 0xda, 0x7e, 0x88, 0xe4, 0x7f, 0xd8, 0x4c, 0xbd, 0x7c, 0x35, 0x8a, 0x91, 0x66,
0x4e, 0xbb, 0xbf, 0x67, 0xb6, 0x95, 0x19, 0xdc, 0x48, 0x51, 0xfd, 0x3f, 0x38, 0x6a, 0xa2, 0xea,
0x8c, 0xae, 0x87, 0x9c, 0x99, 0x18, 0x2b, 0x7e, 0xc3, 0x99, 0xaf, 0x70, 0x29, 0xa2, 0xfe, 0x1a,
0xaa, 0xf7, 0x18, 0x0f, 0xbd, 0xfd, 0x14, 0x6a, 0xe3, 0xb3, 0xd3, 0xa7, 0x94, 0xcd, 0xe9, 0x34,
0xc2, 0x30, 0x8b, 0x50, 0xf2, 0x48, 0x3a, 0x5b, 0x70, 0xea, 0x60, 0xa8, 0x7f, 0x2c, 0x80, 0xfe,
0x50, 0x8e, 0x7c, 0xe3, 0x1e, 0xec, 0x44, 0x19, 0x65, 0xc9, 0x7a, 0xc8, 0x13, 0xb5, 0x5b, 0x38,
0x5c, 0x3b, 0x2e, 0x3f, 0xde, 0xab, 0xcf, 0xce, 0xa6, 0x7e, 0xcf, 0xcc, 0xdb, 0x8a, 0xee, 0x42,
0x0e, 0x4f, 0x14, 0x31, 0xe1, 0x20, 0xf4, 0xc7, 0x94, 0x0d, 0x39, 0x0a, 0x45, 0x99, 0xcf, 0xde,
0x20, 0x55, 0x3c, 0x44, 0xca, 0x05, 0x4d, 0x90, 0x49, 0xd1, 0xcf, 0x92, 0xaf, 0x79, 0xff, 0x84,
0xfe, 0xd8, 0xcc, 0x58, 0x66, 0x4a, 0xea, 0xf1, 0x10, 0x5b, 0xa2, 0x9b, 0x31, 0xf4, 0x7d, 0xd8,
0x6b, 0xa2, 0xca, 0x6f, 0xd3, 0x60, 0x4c, 0x8e, 0x84, 0x4a, 0xcb, 0xb8, 0xed, 0xf0, 0x05, 0xfc,
0xbb, 0x62, 0x9e, 0xef, 0x76, 0x0a, 0xb5, 0xfc, 0x1f, 0x40, 0xfd, 0xe9, 0x78, 0xb1, 0x5b, 0x92,
0xdc, 0x53, 0xea, 0xef, 0x0b, 0xb0, 0xd5, 0x44, 0x65, 0x30, 0x86, 0x49, 0xd2, 0x93, 0x03, 0x14,
0xb7, 0x37, 0x55, 0x83, 0x3f, 0x12, 0x26, 0x23, 0xcc, 0x5a, 0x29, 0x79, 0xd3, 0x07, 0xf2, 0x08,
0xc8, 0xdd, 0x37, 0xf0, 0xdb, 0xd5, 0xb4, 0x65, 0xff, 0x56, 0x7f, 0x65, 0x9e, 0xb5, 0x95, 0x79,
0xfa, 0xb0, 0x7d, 0x37, 0x4e, 0xbe, 0xdb, 0x11, 0xac, 0xfb, 0x19, 0x4c, 0x55, 0x8a, 0xe7, 0x3b,
0x95, 0xfd, 0x39, 0x35, 0xbd, 0x58, 0x1c, 0x47, 0x3c, 0xf6, 0x15, 0x97, 0x22, 0xab, 0x3f, 0x4f,
0x56, 0x99, 0xc3, 0x69, 0xe1, 0xfa, 0x21, 0xec, 0x37, 0x51, 0x59, 0x78, 0xe3, 0x8f, 0x86, 0xaa,
0xc9, 0x92, 0xc6, 0x88, 0x0d, 0x70, 0xa9, 0xea, 0x2b, 0x38, 0x58, 0xc9, 0xc8, 0x03, 0x9d, 0xc1,
0x4e, 0x7f, 0x3a, 0xa7, 0x01, 0x4b, 0xe8, 0x75, 0xc6, 0x58, 0xec, 0xbb, 0xd6, 0xff, 0x85, 0xbc,
0x51, 0x79, 0xb5, 0xbe, 0xf8, 0xc9, 0xfa, 0x19, 0x00, 0x00, 0xff, 0xff, 0x37, 0x4c, 0x56, 0x38,
0xf3, 0x04, 0x00, 0x00,
}

View File

@ -1,64 +0,0 @@
syntax = "proto2";
option go_package = "app_identity";
package appengine;
message AppIdentityServiceError {
enum ErrorCode {
SUCCESS = 0;
UNKNOWN_SCOPE = 9;
BLOB_TOO_LARGE = 1000;
DEADLINE_EXCEEDED = 1001;
NOT_A_VALID_APP = 1002;
UNKNOWN_ERROR = 1003;
NOT_ALLOWED = 1005;
NOT_IMPLEMENTED = 1006;
}
}
message SignForAppRequest {
optional bytes bytes_to_sign = 1;
}
message SignForAppResponse {
optional string key_name = 1;
optional bytes signature_bytes = 2;
}
message GetPublicCertificateForAppRequest {
}
message PublicCertificate {
optional string key_name = 1;
optional string x509_certificate_pem = 2;
}
message GetPublicCertificateForAppResponse {
repeated PublicCertificate public_certificate_list = 1;
optional int64 max_client_cache_time_in_second = 2;
}
message GetServiceAccountNameRequest {
}
message GetServiceAccountNameResponse {
optional string service_account_name = 1;
}
message GetAccessTokenRequest {
repeated string scope = 1;
optional int64 service_account_id = 2;
optional string service_account_name = 3;
}
message GetAccessTokenResponse {
optional string access_token = 1;
optional int64 expiration_time = 2;
}
message GetDefaultGcsBucketNameRequest {
}
message GetDefaultGcsBucketNameResponse {
optional string default_gcs_bucket_name = 1;
}

View File

@ -1,33 +0,0 @@
// Built-in base types for API calls. Primarily useful as return types.
syntax = "proto2";
option go_package = "base";
package appengine.base;
message StringProto {
required string value = 1;
}
message Integer32Proto {
required int32 value = 1;
}
message Integer64Proto {
required int64 value = 1;
}
message BoolProto {
required bool value = 1;
}
message DoubleProto {
required double value = 1;
}
message BytesProto {
required bytes value = 1 [ctype=CORD];
}
message VoidProto {
}

View File

@ -1,666 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: google.golang.org/appengine/internal/blobstore/blobstore_service.proto
package blobstore
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type BlobstoreServiceError_ErrorCode int32
const (
BlobstoreServiceError_OK BlobstoreServiceError_ErrorCode = 0
BlobstoreServiceError_INTERNAL_ERROR BlobstoreServiceError_ErrorCode = 1
BlobstoreServiceError_URL_TOO_LONG BlobstoreServiceError_ErrorCode = 2
BlobstoreServiceError_PERMISSION_DENIED BlobstoreServiceError_ErrorCode = 3
BlobstoreServiceError_BLOB_NOT_FOUND BlobstoreServiceError_ErrorCode = 4
BlobstoreServiceError_DATA_INDEX_OUT_OF_RANGE BlobstoreServiceError_ErrorCode = 5
BlobstoreServiceError_BLOB_FETCH_SIZE_TOO_LARGE BlobstoreServiceError_ErrorCode = 6
BlobstoreServiceError_ARGUMENT_OUT_OF_RANGE BlobstoreServiceError_ErrorCode = 8
BlobstoreServiceError_INVALID_BLOB_KEY BlobstoreServiceError_ErrorCode = 9
)
var BlobstoreServiceError_ErrorCode_name = map[int32]string{
0: "OK",
1: "INTERNAL_ERROR",
2: "URL_TOO_LONG",
3: "PERMISSION_DENIED",
4: "BLOB_NOT_FOUND",
5: "DATA_INDEX_OUT_OF_RANGE",
6: "BLOB_FETCH_SIZE_TOO_LARGE",
8: "ARGUMENT_OUT_OF_RANGE",
9: "INVALID_BLOB_KEY",
}
var BlobstoreServiceError_ErrorCode_value = map[string]int32{
"OK": 0,
"INTERNAL_ERROR": 1,
"URL_TOO_LONG": 2,
"PERMISSION_DENIED": 3,
"BLOB_NOT_FOUND": 4,
"DATA_INDEX_OUT_OF_RANGE": 5,
"BLOB_FETCH_SIZE_TOO_LARGE": 6,
"ARGUMENT_OUT_OF_RANGE": 8,
"INVALID_BLOB_KEY": 9,
}
func (x BlobstoreServiceError_ErrorCode) Enum() *BlobstoreServiceError_ErrorCode {
p := new(BlobstoreServiceError_ErrorCode)
*p = x
return p
}
func (x BlobstoreServiceError_ErrorCode) String() string {
return proto.EnumName(BlobstoreServiceError_ErrorCode_name, int32(x))
}
func (x *BlobstoreServiceError_ErrorCode) UnmarshalJSON(data []byte) error {
value, err := proto.UnmarshalJSONEnum(BlobstoreServiceError_ErrorCode_value, data, "BlobstoreServiceError_ErrorCode")
if err != nil {
return err
}
*x = BlobstoreServiceError_ErrorCode(value)
return nil
}
func (BlobstoreServiceError_ErrorCode) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_blobstore_service_3604fb6033ea2e2e, []int{0, 0}
}
type BlobstoreServiceError struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *BlobstoreServiceError) Reset() { *m = BlobstoreServiceError{} }
func (m *BlobstoreServiceError) String() string { return proto.CompactTextString(m) }
func (*BlobstoreServiceError) ProtoMessage() {}
func (*BlobstoreServiceError) Descriptor() ([]byte, []int) {
return fileDescriptor_blobstore_service_3604fb6033ea2e2e, []int{0}
}
func (m *BlobstoreServiceError) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_BlobstoreServiceError.Unmarshal(m, b)
}
func (m *BlobstoreServiceError) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_BlobstoreServiceError.Marshal(b, m, deterministic)
}
func (dst *BlobstoreServiceError) XXX_Merge(src proto.Message) {
xxx_messageInfo_BlobstoreServiceError.Merge(dst, src)
}
func (m *BlobstoreServiceError) XXX_Size() int {
return xxx_messageInfo_BlobstoreServiceError.Size(m)
}
func (m *BlobstoreServiceError) XXX_DiscardUnknown() {
xxx_messageInfo_BlobstoreServiceError.DiscardUnknown(m)
}
var xxx_messageInfo_BlobstoreServiceError proto.InternalMessageInfo
type CreateUploadURLRequest struct {
SuccessPath *string `protobuf:"bytes,1,req,name=success_path,json=successPath" json:"success_path,omitempty"`
MaxUploadSizeBytes *int64 `protobuf:"varint,2,opt,name=max_upload_size_bytes,json=maxUploadSizeBytes" json:"max_upload_size_bytes,omitempty"`
MaxUploadSizePerBlobBytes *int64 `protobuf:"varint,3,opt,name=max_upload_size_per_blob_bytes,json=maxUploadSizePerBlobBytes" json:"max_upload_size_per_blob_bytes,omitempty"`
GsBucketName *string `protobuf:"bytes,4,opt,name=gs_bucket_name,json=gsBucketName" json:"gs_bucket_name,omitempty"`
UrlExpiryTimeSeconds *int32 `protobuf:"varint,5,opt,name=url_expiry_time_seconds,json=urlExpiryTimeSeconds" json:"url_expiry_time_seconds,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CreateUploadURLRequest) Reset() { *m = CreateUploadURLRequest{} }
func (m *CreateUploadURLRequest) String() string { return proto.CompactTextString(m) }
func (*CreateUploadURLRequest) ProtoMessage() {}
func (*CreateUploadURLRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_blobstore_service_3604fb6033ea2e2e, []int{1}
}
func (m *CreateUploadURLRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CreateUploadURLRequest.Unmarshal(m, b)
}
func (m *CreateUploadURLRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CreateUploadURLRequest.Marshal(b, m, deterministic)
}
func (dst *CreateUploadURLRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_CreateUploadURLRequest.Merge(dst, src)
}
func (m *CreateUploadURLRequest) XXX_Size() int {
return xxx_messageInfo_CreateUploadURLRequest.Size(m)
}
func (m *CreateUploadURLRequest) XXX_DiscardUnknown() {
xxx_messageInfo_CreateUploadURLRequest.DiscardUnknown(m)
}
var xxx_messageInfo_CreateUploadURLRequest proto.InternalMessageInfo
func (m *CreateUploadURLRequest) GetSuccessPath() string {
if m != nil && m.SuccessPath != nil {
return *m.SuccessPath
}
return ""
}
func (m *CreateUploadURLRequest) GetMaxUploadSizeBytes() int64 {
if m != nil && m.MaxUploadSizeBytes != nil {
return *m.MaxUploadSizeBytes
}
return 0
}
func (m *CreateUploadURLRequest) GetMaxUploadSizePerBlobBytes() int64 {
if m != nil && m.MaxUploadSizePerBlobBytes != nil {
return *m.MaxUploadSizePerBlobBytes
}
return 0
}
func (m *CreateUploadURLRequest) GetGsBucketName() string {
if m != nil && m.GsBucketName != nil {
return *m.GsBucketName
}
return ""
}
func (m *CreateUploadURLRequest) GetUrlExpiryTimeSeconds() int32 {
if m != nil && m.UrlExpiryTimeSeconds != nil {
return *m.UrlExpiryTimeSeconds
}
return 0
}
type CreateUploadURLResponse struct {
Url *string `protobuf:"bytes,1,req,name=url" json:"url,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CreateUploadURLResponse) Reset() { *m = CreateUploadURLResponse{} }
func (m *CreateUploadURLResponse) String() string { return proto.CompactTextString(m) }
func (*CreateUploadURLResponse) ProtoMessage() {}
func (*CreateUploadURLResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_blobstore_service_3604fb6033ea2e2e, []int{2}
}
func (m *CreateUploadURLResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CreateUploadURLResponse.Unmarshal(m, b)
}
func (m *CreateUploadURLResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CreateUploadURLResponse.Marshal(b, m, deterministic)
}
func (dst *CreateUploadURLResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_CreateUploadURLResponse.Merge(dst, src)
}
func (m *CreateUploadURLResponse) XXX_Size() int {
return xxx_messageInfo_CreateUploadURLResponse.Size(m)
}
func (m *CreateUploadURLResponse) XXX_DiscardUnknown() {
xxx_messageInfo_CreateUploadURLResponse.DiscardUnknown(m)
}
var xxx_messageInfo_CreateUploadURLResponse proto.InternalMessageInfo
func (m *CreateUploadURLResponse) GetUrl() string {
if m != nil && m.Url != nil {
return *m.Url
}
return ""
}
type DeleteBlobRequest struct {
BlobKey []string `protobuf:"bytes,1,rep,name=blob_key,json=blobKey" json:"blob_key,omitempty"`
Token *string `protobuf:"bytes,2,opt,name=token" json:"token,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *DeleteBlobRequest) Reset() { *m = DeleteBlobRequest{} }
func (m *DeleteBlobRequest) String() string { return proto.CompactTextString(m) }
func (*DeleteBlobRequest) ProtoMessage() {}
func (*DeleteBlobRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_blobstore_service_3604fb6033ea2e2e, []int{3}
}
func (m *DeleteBlobRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DeleteBlobRequest.Unmarshal(m, b)
}
func (m *DeleteBlobRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_DeleteBlobRequest.Marshal(b, m, deterministic)
}
func (dst *DeleteBlobRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_DeleteBlobRequest.Merge(dst, src)
}
func (m *DeleteBlobRequest) XXX_Size() int {
return xxx_messageInfo_DeleteBlobRequest.Size(m)
}
func (m *DeleteBlobRequest) XXX_DiscardUnknown() {
xxx_messageInfo_DeleteBlobRequest.DiscardUnknown(m)
}
var xxx_messageInfo_DeleteBlobRequest proto.InternalMessageInfo
func (m *DeleteBlobRequest) GetBlobKey() []string {
if m != nil {
return m.BlobKey
}
return nil
}
func (m *DeleteBlobRequest) GetToken() string {
if m != nil && m.Token != nil {
return *m.Token
}
return ""
}
type FetchDataRequest struct {
BlobKey *string `protobuf:"bytes,1,req,name=blob_key,json=blobKey" json:"blob_key,omitempty"`
StartIndex *int64 `protobuf:"varint,2,req,name=start_index,json=startIndex" json:"start_index,omitempty"`
EndIndex *int64 `protobuf:"varint,3,req,name=end_index,json=endIndex" json:"end_index,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *FetchDataRequest) Reset() { *m = FetchDataRequest{} }
func (m *FetchDataRequest) String() string { return proto.CompactTextString(m) }
func (*FetchDataRequest) ProtoMessage() {}
func (*FetchDataRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_blobstore_service_3604fb6033ea2e2e, []int{4}
}
func (m *FetchDataRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_FetchDataRequest.Unmarshal(m, b)
}
func (m *FetchDataRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_FetchDataRequest.Marshal(b, m, deterministic)
}
func (dst *FetchDataRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_FetchDataRequest.Merge(dst, src)
}
func (m *FetchDataRequest) XXX_Size() int {
return xxx_messageInfo_FetchDataRequest.Size(m)
}
func (m *FetchDataRequest) XXX_DiscardUnknown() {
xxx_messageInfo_FetchDataRequest.DiscardUnknown(m)
}
var xxx_messageInfo_FetchDataRequest proto.InternalMessageInfo
func (m *FetchDataRequest) GetBlobKey() string {
if m != nil && m.BlobKey != nil {
return *m.BlobKey
}
return ""
}
func (m *FetchDataRequest) GetStartIndex() int64 {
if m != nil && m.StartIndex != nil {
return *m.StartIndex
}
return 0
}
func (m *FetchDataRequest) GetEndIndex() int64 {
if m != nil && m.EndIndex != nil {
return *m.EndIndex
}
return 0
}
type FetchDataResponse struct {
Data []byte `protobuf:"bytes,1000,req,name=data" json:"data,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *FetchDataResponse) Reset() { *m = FetchDataResponse{} }
func (m *FetchDataResponse) String() string { return proto.CompactTextString(m) }
func (*FetchDataResponse) ProtoMessage() {}
func (*FetchDataResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_blobstore_service_3604fb6033ea2e2e, []int{5}
}
func (m *FetchDataResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_FetchDataResponse.Unmarshal(m, b)
}
func (m *FetchDataResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_FetchDataResponse.Marshal(b, m, deterministic)
}
func (dst *FetchDataResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_FetchDataResponse.Merge(dst, src)
}
func (m *FetchDataResponse) XXX_Size() int {
return xxx_messageInfo_FetchDataResponse.Size(m)
}
func (m *FetchDataResponse) XXX_DiscardUnknown() {
xxx_messageInfo_FetchDataResponse.DiscardUnknown(m)
}
var xxx_messageInfo_FetchDataResponse proto.InternalMessageInfo
func (m *FetchDataResponse) GetData() []byte {
if m != nil {
return m.Data
}
return nil
}
type CloneBlobRequest struct {
BlobKey []byte `protobuf:"bytes,1,req,name=blob_key,json=blobKey" json:"blob_key,omitempty"`
MimeType []byte `protobuf:"bytes,2,req,name=mime_type,json=mimeType" json:"mime_type,omitempty"`
TargetAppId []byte `protobuf:"bytes,3,req,name=target_app_id,json=targetAppId" json:"target_app_id,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CloneBlobRequest) Reset() { *m = CloneBlobRequest{} }
func (m *CloneBlobRequest) String() string { return proto.CompactTextString(m) }
func (*CloneBlobRequest) ProtoMessage() {}
func (*CloneBlobRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_blobstore_service_3604fb6033ea2e2e, []int{6}
}
func (m *CloneBlobRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CloneBlobRequest.Unmarshal(m, b)
}
func (m *CloneBlobRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CloneBlobRequest.Marshal(b, m, deterministic)
}
func (dst *CloneBlobRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_CloneBlobRequest.Merge(dst, src)
}
func (m *CloneBlobRequest) XXX_Size() int {
return xxx_messageInfo_CloneBlobRequest.Size(m)
}
func (m *CloneBlobRequest) XXX_DiscardUnknown() {
xxx_messageInfo_CloneBlobRequest.DiscardUnknown(m)
}
var xxx_messageInfo_CloneBlobRequest proto.InternalMessageInfo
func (m *CloneBlobRequest) GetBlobKey() []byte {
if m != nil {
return m.BlobKey
}
return nil
}
func (m *CloneBlobRequest) GetMimeType() []byte {
if m != nil {
return m.MimeType
}
return nil
}
func (m *CloneBlobRequest) GetTargetAppId() []byte {
if m != nil {
return m.TargetAppId
}
return nil
}
type CloneBlobResponse struct {
BlobKey []byte `protobuf:"bytes,1,req,name=blob_key,json=blobKey" json:"blob_key,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CloneBlobResponse) Reset() { *m = CloneBlobResponse{} }
func (m *CloneBlobResponse) String() string { return proto.CompactTextString(m) }
func (*CloneBlobResponse) ProtoMessage() {}
func (*CloneBlobResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_blobstore_service_3604fb6033ea2e2e, []int{7}
}
func (m *CloneBlobResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CloneBlobResponse.Unmarshal(m, b)
}
func (m *CloneBlobResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CloneBlobResponse.Marshal(b, m, deterministic)
}
func (dst *CloneBlobResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_CloneBlobResponse.Merge(dst, src)
}
func (m *CloneBlobResponse) XXX_Size() int {
return xxx_messageInfo_CloneBlobResponse.Size(m)
}
func (m *CloneBlobResponse) XXX_DiscardUnknown() {
xxx_messageInfo_CloneBlobResponse.DiscardUnknown(m)
}
var xxx_messageInfo_CloneBlobResponse proto.InternalMessageInfo
func (m *CloneBlobResponse) GetBlobKey() []byte {
if m != nil {
return m.BlobKey
}
return nil
}
type DecodeBlobKeyRequest struct {
BlobKey []string `protobuf:"bytes,1,rep,name=blob_key,json=blobKey" json:"blob_key,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *DecodeBlobKeyRequest) Reset() { *m = DecodeBlobKeyRequest{} }
func (m *DecodeBlobKeyRequest) String() string { return proto.CompactTextString(m) }
func (*DecodeBlobKeyRequest) ProtoMessage() {}
func (*DecodeBlobKeyRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_blobstore_service_3604fb6033ea2e2e, []int{8}
}
func (m *DecodeBlobKeyRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DecodeBlobKeyRequest.Unmarshal(m, b)
}
func (m *DecodeBlobKeyRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_DecodeBlobKeyRequest.Marshal(b, m, deterministic)
}
func (dst *DecodeBlobKeyRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_DecodeBlobKeyRequest.Merge(dst, src)
}
func (m *DecodeBlobKeyRequest) XXX_Size() int {
return xxx_messageInfo_DecodeBlobKeyRequest.Size(m)
}
func (m *DecodeBlobKeyRequest) XXX_DiscardUnknown() {
xxx_messageInfo_DecodeBlobKeyRequest.DiscardUnknown(m)
}
var xxx_messageInfo_DecodeBlobKeyRequest proto.InternalMessageInfo
func (m *DecodeBlobKeyRequest) GetBlobKey() []string {
if m != nil {
return m.BlobKey
}
return nil
}
type DecodeBlobKeyResponse struct {
Decoded []string `protobuf:"bytes,1,rep,name=decoded" json:"decoded,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *DecodeBlobKeyResponse) Reset() { *m = DecodeBlobKeyResponse{} }
func (m *DecodeBlobKeyResponse) String() string { return proto.CompactTextString(m) }
func (*DecodeBlobKeyResponse) ProtoMessage() {}
func (*DecodeBlobKeyResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_blobstore_service_3604fb6033ea2e2e, []int{9}
}
func (m *DecodeBlobKeyResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DecodeBlobKeyResponse.Unmarshal(m, b)
}
func (m *DecodeBlobKeyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_DecodeBlobKeyResponse.Marshal(b, m, deterministic)
}
func (dst *DecodeBlobKeyResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_DecodeBlobKeyResponse.Merge(dst, src)
}
func (m *DecodeBlobKeyResponse) XXX_Size() int {
return xxx_messageInfo_DecodeBlobKeyResponse.Size(m)
}
func (m *DecodeBlobKeyResponse) XXX_DiscardUnknown() {
xxx_messageInfo_DecodeBlobKeyResponse.DiscardUnknown(m)
}
var xxx_messageInfo_DecodeBlobKeyResponse proto.InternalMessageInfo
func (m *DecodeBlobKeyResponse) GetDecoded() []string {
if m != nil {
return m.Decoded
}
return nil
}
type CreateEncodedGoogleStorageKeyRequest struct {
Filename *string `protobuf:"bytes,1,req,name=filename" json:"filename,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CreateEncodedGoogleStorageKeyRequest) Reset() { *m = CreateEncodedGoogleStorageKeyRequest{} }
func (m *CreateEncodedGoogleStorageKeyRequest) String() string { return proto.CompactTextString(m) }
func (*CreateEncodedGoogleStorageKeyRequest) ProtoMessage() {}
func (*CreateEncodedGoogleStorageKeyRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_blobstore_service_3604fb6033ea2e2e, []int{10}
}
func (m *CreateEncodedGoogleStorageKeyRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CreateEncodedGoogleStorageKeyRequest.Unmarshal(m, b)
}
func (m *CreateEncodedGoogleStorageKeyRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CreateEncodedGoogleStorageKeyRequest.Marshal(b, m, deterministic)
}
func (dst *CreateEncodedGoogleStorageKeyRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_CreateEncodedGoogleStorageKeyRequest.Merge(dst, src)
}
func (m *CreateEncodedGoogleStorageKeyRequest) XXX_Size() int {
return xxx_messageInfo_CreateEncodedGoogleStorageKeyRequest.Size(m)
}
func (m *CreateEncodedGoogleStorageKeyRequest) XXX_DiscardUnknown() {
xxx_messageInfo_CreateEncodedGoogleStorageKeyRequest.DiscardUnknown(m)
}
var xxx_messageInfo_CreateEncodedGoogleStorageKeyRequest proto.InternalMessageInfo
func (m *CreateEncodedGoogleStorageKeyRequest) GetFilename() string {
if m != nil && m.Filename != nil {
return *m.Filename
}
return ""
}
type CreateEncodedGoogleStorageKeyResponse struct {
BlobKey *string `protobuf:"bytes,1,req,name=blob_key,json=blobKey" json:"blob_key,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CreateEncodedGoogleStorageKeyResponse) Reset() { *m = CreateEncodedGoogleStorageKeyResponse{} }
func (m *CreateEncodedGoogleStorageKeyResponse) String() string { return proto.CompactTextString(m) }
func (*CreateEncodedGoogleStorageKeyResponse) ProtoMessage() {}
func (*CreateEncodedGoogleStorageKeyResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_blobstore_service_3604fb6033ea2e2e, []int{11}
}
func (m *CreateEncodedGoogleStorageKeyResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CreateEncodedGoogleStorageKeyResponse.Unmarshal(m, b)
}
func (m *CreateEncodedGoogleStorageKeyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CreateEncodedGoogleStorageKeyResponse.Marshal(b, m, deterministic)
}
func (dst *CreateEncodedGoogleStorageKeyResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_CreateEncodedGoogleStorageKeyResponse.Merge(dst, src)
}
func (m *CreateEncodedGoogleStorageKeyResponse) XXX_Size() int {
return xxx_messageInfo_CreateEncodedGoogleStorageKeyResponse.Size(m)
}
func (m *CreateEncodedGoogleStorageKeyResponse) XXX_DiscardUnknown() {
xxx_messageInfo_CreateEncodedGoogleStorageKeyResponse.DiscardUnknown(m)
}
var xxx_messageInfo_CreateEncodedGoogleStorageKeyResponse proto.InternalMessageInfo
func (m *CreateEncodedGoogleStorageKeyResponse) GetBlobKey() string {
if m != nil && m.BlobKey != nil {
return *m.BlobKey
}
return ""
}
func init() {
proto.RegisterType((*BlobstoreServiceError)(nil), "appengine.BlobstoreServiceError")
proto.RegisterType((*CreateUploadURLRequest)(nil), "appengine.CreateUploadURLRequest")
proto.RegisterType((*CreateUploadURLResponse)(nil), "appengine.CreateUploadURLResponse")
proto.RegisterType((*DeleteBlobRequest)(nil), "appengine.DeleteBlobRequest")
proto.RegisterType((*FetchDataRequest)(nil), "appengine.FetchDataRequest")
proto.RegisterType((*FetchDataResponse)(nil), "appengine.FetchDataResponse")
proto.RegisterType((*CloneBlobRequest)(nil), "appengine.CloneBlobRequest")
proto.RegisterType((*CloneBlobResponse)(nil), "appengine.CloneBlobResponse")
proto.RegisterType((*DecodeBlobKeyRequest)(nil), "appengine.DecodeBlobKeyRequest")
proto.RegisterType((*DecodeBlobKeyResponse)(nil), "appengine.DecodeBlobKeyResponse")
proto.RegisterType((*CreateEncodedGoogleStorageKeyRequest)(nil), "appengine.CreateEncodedGoogleStorageKeyRequest")
proto.RegisterType((*CreateEncodedGoogleStorageKeyResponse)(nil), "appengine.CreateEncodedGoogleStorageKeyResponse")
}
func init() {
proto.RegisterFile("google.golang.org/appengine/internal/blobstore/blobstore_service.proto", fileDescriptor_blobstore_service_3604fb6033ea2e2e)
}
var fileDescriptor_blobstore_service_3604fb6033ea2e2e = []byte{
// 737 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x54, 0xe1, 0x6e, 0xe3, 0x44,
0x10, 0xc6, 0x4e, 0x7b, 0x8d, 0xa7, 0xe1, 0xe4, 0xae, 0x1a, 0x9a, 0x52, 0x01, 0xc1, 0x3a, 0xa4,
0x48, 0xa0, 0x56, 0xfd, 0xc1, 0x03, 0xd8, 0xb5, 0x13, 0xac, 0xe6, 0xec, 0x6a, 0xe3, 0x20, 0xb8,
0x3f, 0xab, 0x6d, 0x3c, 0xb8, 0x56, 0x1d, 0xaf, 0x59, 0x6f, 0x50, 0x73, 0x0f, 0xc1, 0xbb, 0xf1,
0x16, 0x48, 0xbc, 0x04, 0xf2, 0xda, 0x6d, 0x73, 0x07, 0x77, 0xf7, 0x6f, 0xe7, 0xfb, 0xf6, 0x9b,
0xf9, 0x66, 0x66, 0xb5, 0x30, 0xcd, 0x84, 0xc8, 0x0a, 0x3c, 0xcf, 0x44, 0xc1, 0xcb, 0xec, 0x5c,
0xc8, 0xec, 0x82, 0x57, 0x15, 0x96, 0x59, 0x5e, 0xe2, 0x45, 0x5e, 0x2a, 0x94, 0x25, 0x2f, 0x2e,
0x6e, 0x0b, 0x71, 0x5b, 0x2b, 0x21, 0xf1, 0xf9, 0xc4, 0x6a, 0x94, 0x7f, 0xe4, 0x2b, 0x3c, 0xaf,
0xa4, 0x50, 0x82, 0x58, 0x4f, 0x2a, 0xe7, 0x1f, 0x03, 0x86, 0xde, 0xe3, 0xb5, 0x45, 0x7b, 0x2b,
0x90, 0x52, 0x48, 0xe7, 0x2f, 0x03, 0x2c, 0x7d, 0xba, 0x12, 0x29, 0x92, 0x17, 0x60, 0xc6, 0xd7,
0xf6, 0x67, 0x84, 0xc0, 0xcb, 0x30, 0x4a, 0x02, 0x1a, 0xb9, 0x73, 0x16, 0x50, 0x1a, 0x53, 0xdb,
0x20, 0x36, 0x0c, 0x96, 0x74, 0xce, 0x92, 0x38, 0x66, 0xf3, 0x38, 0x9a, 0xd9, 0x26, 0x19, 0xc2,
0xd1, 0x4d, 0x40, 0x5f, 0x87, 0x8b, 0x45, 0x18, 0x47, 0xcc, 0x0f, 0xa2, 0x30, 0xf0, 0xed, 0x5e,
0x23, 0xf6, 0xe6, 0xb1, 0xc7, 0xa2, 0x38, 0x61, 0xd3, 0x78, 0x19, 0xf9, 0xf6, 0x1e, 0x39, 0x83,
0x13, 0xdf, 0x4d, 0x5c, 0x16, 0x46, 0x7e, 0xf0, 0x0b, 0x8b, 0x97, 0x09, 0x8b, 0xa7, 0x8c, 0xba,
0xd1, 0x2c, 0xb0, 0xf7, 0xc9, 0x57, 0x70, 0xaa, 0x05, 0xd3, 0x20, 0xb9, 0xfa, 0x89, 0x2d, 0xc2,
0x37, 0x41, 0x5b, 0xc5, 0xa5, 0xb3, 0xc0, 0x7e, 0x41, 0x4e, 0x61, 0xe8, 0xd2, 0xd9, 0xf2, 0x75,
0x10, 0x25, 0xef, 0x2a, 0xfb, 0xe4, 0x18, 0xec, 0x30, 0xfa, 0xd9, 0x9d, 0x87, 0x3e, 0xd3, 0x19,
0xae, 0x83, 0x5f, 0x6d, 0xcb, 0xf9, 0xd3, 0x84, 0x2f, 0xae, 0x24, 0x72, 0x85, 0xcb, 0xaa, 0x10,
0x3c, 0x5d, 0xd2, 0x39, 0xc5, 0xdf, 0x37, 0x58, 0x2b, 0xf2, 0x2d, 0x0c, 0xea, 0xcd, 0x6a, 0x85,
0x75, 0xcd, 0x2a, 0xae, 0xee, 0x46, 0xc6, 0xd8, 0x9c, 0x58, 0xf4, 0xb0, 0xc3, 0x6e, 0xb8, 0xba,
0x23, 0x97, 0x30, 0x5c, 0xf3, 0x07, 0xb6, 0xd1, 0x52, 0x56, 0xe7, 0x6f, 0x91, 0xdd, 0x6e, 0x15,
0xd6, 0x23, 0x73, 0x6c, 0x4c, 0x7a, 0x94, 0xac, 0xf9, 0x43, 0x9b, 0x76, 0x91, 0xbf, 0x45, 0xaf,
0x61, 0x88, 0x0b, 0x5f, 0xbf, 0x2f, 0xa9, 0x50, 0xb2, 0x66, 0x31, 0x9d, 0xb6, 0xa7, 0xb5, 0xa7,
0xef, 0x68, 0x6f, 0x50, 0x36, 0x3b, 0x69, 0x53, 0xbc, 0x82, 0x97, 0x59, 0xcd, 0x6e, 0x37, 0xab,
0x7b, 0x54, 0xac, 0xe4, 0x6b, 0x1c, 0xed, 0x8d, 0x8d, 0x89, 0x45, 0x07, 0x59, 0xed, 0x69, 0x30,
0xe2, 0x6b, 0x24, 0x3f, 0xc2, 0xc9, 0x46, 0x16, 0x0c, 0x1f, 0xaa, 0x5c, 0x6e, 0x99, 0xca, 0xd7,
0xcd, 0xce, 0x57, 0xa2, 0x4c, 0xeb, 0xd1, 0xfe, 0xd8, 0x98, 0xec, 0xd3, 0xe3, 0x8d, 0x2c, 0x02,
0xcd, 0x26, 0xf9, 0x1a, 0x17, 0x2d, 0xe7, 0x7c, 0x0f, 0x27, 0xff, 0x99, 0x47, 0x5d, 0x89, 0xb2,
0x46, 0x62, 0x43, 0x6f, 0x23, 0x8b, 0x6e, 0x0e, 0xcd, 0xd1, 0xf1, 0xe1, 0xc8, 0xc7, 0x02, 0x15,
0x36, 0xe6, 0x1e, 0xe7, 0x76, 0x0a, 0x7d, 0xdd, 0xcd, 0x3d, 0x6e, 0x47, 0xc6, 0xb8, 0x37, 0xb1,
0xe8, 0x41, 0x13, 0x5f, 0xe3, 0x96, 0x1c, 0xc3, 0xbe, 0x12, 0xf7, 0x58, 0xea, 0xf9, 0x58, 0xb4,
0x0d, 0x9c, 0x7b, 0xb0, 0xa7, 0xa8, 0x56, 0x77, 0x3e, 0x57, 0xfc, 0xff, 0x93, 0x98, 0xbb, 0x49,
0xbe, 0x81, 0xc3, 0x5a, 0x71, 0xa9, 0x58, 0x5e, 0xa6, 0xf8, 0x30, 0x32, 0xc7, 0xe6, 0xa4, 0x47,
0x41, 0x43, 0x61, 0x83, 0x90, 0x33, 0xb0, 0xb0, 0x4c, 0x3b, 0xba, 0xa7, 0xe9, 0x3e, 0x96, 0xa9,
0x26, 0x9d, 0x1f, 0xe0, 0x68, 0xa7, 0x58, 0xd7, 0xd9, 0x09, 0xec, 0xa5, 0x5c, 0xf1, 0xd1, 0xdf,
0x07, 0x63, 0x73, 0x32, 0xf0, 0xcc, 0xbe, 0x41, 0x35, 0xe0, 0x94, 0x60, 0x5f, 0x15, 0xa2, 0xfc,
0x48, 0x7f, 0xe6, 0x64, 0xf0, 0x6c, 0xed, 0x0c, 0xac, 0x75, 0x33, 0x68, 0xb5, 0xad, 0x50, 0x1b,
0x1b, 0xd0, 0x7e, 0x03, 0x24, 0xdb, 0x0a, 0x89, 0x03, 0x9f, 0x2b, 0x2e, 0x33, 0x54, 0x8c, 0x57,
0x15, 0xcb, 0x53, 0x6d, 0x6d, 0x40, 0x0f, 0x5b, 0xd0, 0xad, 0xaa, 0x30, 0x75, 0xce, 0xe1, 0x68,
0xa7, 0x5e, 0xe7, 0xee, 0xc3, 0x05, 0x9d, 0x4b, 0x38, 0xf6, 0x71, 0x25, 0x52, 0x2d, 0xb8, 0xc6,
0xed, 0xa7, 0x77, 0xe0, 0x5c, 0xc2, 0xf0, 0x3d, 0x49, 0x57, 0x66, 0x04, 0x07, 0xa9, 0x26, 0xd2,
0x47, 0x49, 0x17, 0x3a, 0x1e, 0xbc, 0x6a, 0xdf, 0x44, 0x50, 0x6a, 0x60, 0xa6, 0x3f, 0x9d, 0x85,
0x12, 0x92, 0x67, 0xb8, 0x53, 0xf5, 0x4b, 0xe8, 0xff, 0x96, 0x17, 0xa8, 0x9f, 0x64, 0xbb, 0xb4,
0xa7, 0xd8, 0xf1, 0xe0, 0xbb, 0x4f, 0xe4, 0xf8, 0x40, 0xb7, 0xcf, 0xd6, 0xbd, 0xc3, 0x37, 0xd6,
0xd3, 0x07, 0xf6, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc1, 0xfb, 0x81, 0x94, 0xfb, 0x04, 0x00,
0x00,
}

View File

@ -1,71 +0,0 @@
syntax = "proto2";
option go_package = "blobstore";
package appengine;
message BlobstoreServiceError {
enum ErrorCode {
OK = 0;
INTERNAL_ERROR = 1;
URL_TOO_LONG = 2;
PERMISSION_DENIED = 3;
BLOB_NOT_FOUND = 4;
DATA_INDEX_OUT_OF_RANGE = 5;
BLOB_FETCH_SIZE_TOO_LARGE = 6;
ARGUMENT_OUT_OF_RANGE = 8;
INVALID_BLOB_KEY = 9;
}
}
message CreateUploadURLRequest {
required string success_path = 1;
optional int64 max_upload_size_bytes = 2;
optional int64 max_upload_size_per_blob_bytes = 3;
optional string gs_bucket_name = 4;
optional int32 url_expiry_time_seconds = 5;
}
message CreateUploadURLResponse {
required string url = 1;
}
message DeleteBlobRequest {
repeated string blob_key = 1;
optional string token = 2;
}
message FetchDataRequest {
required string blob_key = 1;
required int64 start_index = 2;
required int64 end_index = 3;
}
message FetchDataResponse {
required bytes data = 1000 [ctype = CORD];
}
message CloneBlobRequest {
required bytes blob_key = 1;
required bytes mime_type = 2;
required bytes target_app_id = 3;
}
message CloneBlobResponse {
required bytes blob_key = 1;
}
message DecodeBlobKeyRequest {
repeated string blob_key = 1;
}
message DecodeBlobKeyResponse {
repeated string decoded = 1;
}
message CreateEncodedGoogleStorageKeyRequest {
required string filename = 1;
}
message CreateEncodedGoogleStorageKeyResponse {
required string blob_key = 1;
}

View File

@ -1,203 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: google.golang.org/appengine/internal/capability/capability_service.proto
package capability
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type IsEnabledResponse_SummaryStatus int32
const (
IsEnabledResponse_DEFAULT IsEnabledResponse_SummaryStatus = 0
IsEnabledResponse_ENABLED IsEnabledResponse_SummaryStatus = 1
IsEnabledResponse_SCHEDULED_FUTURE IsEnabledResponse_SummaryStatus = 2
IsEnabledResponse_SCHEDULED_NOW IsEnabledResponse_SummaryStatus = 3
IsEnabledResponse_DISABLED IsEnabledResponse_SummaryStatus = 4
IsEnabledResponse_UNKNOWN IsEnabledResponse_SummaryStatus = 5
)
var IsEnabledResponse_SummaryStatus_name = map[int32]string{
0: "DEFAULT",
1: "ENABLED",
2: "SCHEDULED_FUTURE",
3: "SCHEDULED_NOW",
4: "DISABLED",
5: "UNKNOWN",
}
var IsEnabledResponse_SummaryStatus_value = map[string]int32{
"DEFAULT": 0,
"ENABLED": 1,
"SCHEDULED_FUTURE": 2,
"SCHEDULED_NOW": 3,
"DISABLED": 4,
"UNKNOWN": 5,
}
func (x IsEnabledResponse_SummaryStatus) Enum() *IsEnabledResponse_SummaryStatus {
p := new(IsEnabledResponse_SummaryStatus)
*p = x
return p
}
func (x IsEnabledResponse_SummaryStatus) String() string {
return proto.EnumName(IsEnabledResponse_SummaryStatus_name, int32(x))
}
func (x *IsEnabledResponse_SummaryStatus) UnmarshalJSON(data []byte) error {
value, err := proto.UnmarshalJSONEnum(IsEnabledResponse_SummaryStatus_value, data, "IsEnabledResponse_SummaryStatus")
if err != nil {
return err
}
*x = IsEnabledResponse_SummaryStatus(value)
return nil
}
func (IsEnabledResponse_SummaryStatus) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_capability_service_030277ff00db7e72, []int{1, 0}
}
type IsEnabledRequest struct {
Package *string `protobuf:"bytes,1,req,name=package" json:"package,omitempty"`
Capability []string `protobuf:"bytes,2,rep,name=capability" json:"capability,omitempty"`
Call []string `protobuf:"bytes,3,rep,name=call" json:"call,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *IsEnabledRequest) Reset() { *m = IsEnabledRequest{} }
func (m *IsEnabledRequest) String() string { return proto.CompactTextString(m) }
func (*IsEnabledRequest) ProtoMessage() {}
func (*IsEnabledRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_capability_service_030277ff00db7e72, []int{0}
}
func (m *IsEnabledRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_IsEnabledRequest.Unmarshal(m, b)
}
func (m *IsEnabledRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_IsEnabledRequest.Marshal(b, m, deterministic)
}
func (dst *IsEnabledRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_IsEnabledRequest.Merge(dst, src)
}
func (m *IsEnabledRequest) XXX_Size() int {
return xxx_messageInfo_IsEnabledRequest.Size(m)
}
func (m *IsEnabledRequest) XXX_DiscardUnknown() {
xxx_messageInfo_IsEnabledRequest.DiscardUnknown(m)
}
var xxx_messageInfo_IsEnabledRequest proto.InternalMessageInfo
func (m *IsEnabledRequest) GetPackage() string {
if m != nil && m.Package != nil {
return *m.Package
}
return ""
}
func (m *IsEnabledRequest) GetCapability() []string {
if m != nil {
return m.Capability
}
return nil
}
func (m *IsEnabledRequest) GetCall() []string {
if m != nil {
return m.Call
}
return nil
}
type IsEnabledResponse struct {
SummaryStatus *IsEnabledResponse_SummaryStatus `protobuf:"varint,1,opt,name=summary_status,json=summaryStatus,enum=appengine.IsEnabledResponse_SummaryStatus" json:"summary_status,omitempty"`
TimeUntilScheduled *int64 `protobuf:"varint,2,opt,name=time_until_scheduled,json=timeUntilScheduled" json:"time_until_scheduled,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *IsEnabledResponse) Reset() { *m = IsEnabledResponse{} }
func (m *IsEnabledResponse) String() string { return proto.CompactTextString(m) }
func (*IsEnabledResponse) ProtoMessage() {}
func (*IsEnabledResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_capability_service_030277ff00db7e72, []int{1}
}
func (m *IsEnabledResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_IsEnabledResponse.Unmarshal(m, b)
}
func (m *IsEnabledResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_IsEnabledResponse.Marshal(b, m, deterministic)
}
func (dst *IsEnabledResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_IsEnabledResponse.Merge(dst, src)
}
func (m *IsEnabledResponse) XXX_Size() int {
return xxx_messageInfo_IsEnabledResponse.Size(m)
}
func (m *IsEnabledResponse) XXX_DiscardUnknown() {
xxx_messageInfo_IsEnabledResponse.DiscardUnknown(m)
}
var xxx_messageInfo_IsEnabledResponse proto.InternalMessageInfo
func (m *IsEnabledResponse) GetSummaryStatus() IsEnabledResponse_SummaryStatus {
if m != nil && m.SummaryStatus != nil {
return *m.SummaryStatus
}
return IsEnabledResponse_DEFAULT
}
func (m *IsEnabledResponse) GetTimeUntilScheduled() int64 {
if m != nil && m.TimeUntilScheduled != nil {
return *m.TimeUntilScheduled
}
return 0
}
func init() {
proto.RegisterType((*IsEnabledRequest)(nil), "appengine.IsEnabledRequest")
proto.RegisterType((*IsEnabledResponse)(nil), "appengine.IsEnabledResponse")
}
func init() {
proto.RegisterFile("google.golang.org/appengine/internal/capability/capability_service.proto", fileDescriptor_capability_service_030277ff00db7e72)
}
var fileDescriptor_capability_service_030277ff00db7e72 = []byte{
// 359 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0xd1, 0x8a, 0x9b, 0x40,
0x14, 0x86, 0xa3, 0xa6, 0xa4, 0x9e, 0x26, 0xc1, 0x0c, 0xb9, 0x90, 0xb6, 0x14, 0xf1, 0x4a, 0x7a,
0x61, 0x4a, 0xde, 0x20, 0x89, 0x86, 0x84, 0x06, 0x43, 0x35, 0x12, 0x28, 0x14, 0x3b, 0x31, 0x83,
0x95, 0x8e, 0xa3, 0xeb, 0x8c, 0x0b, 0x79, 0x82, 0x7d, 0xed, 0x45, 0x43, 0x8c, 0xcb, 0x2e, 0x7b,
0x77, 0xce, 0xf9, 0xf9, 0xfe, 0x99, 0x73, 0x7e, 0xd8, 0x24, 0x79, 0x9e, 0x50, 0x62, 0x27, 0x39,
0xc5, 0x2c, 0xb1, 0xf3, 0x32, 0x99, 0xe1, 0xa2, 0x20, 0x2c, 0x49, 0x19, 0x99, 0xa5, 0x4c, 0x90,
0x92, 0x61, 0x3a, 0x8b, 0x71, 0x81, 0x4f, 0x29, 0x4d, 0xc5, 0xa5, 0x53, 0x46, 0x9c, 0x94, 0x8f,
0x69, 0x4c, 0xec, 0xa2, 0xcc, 0x45, 0x8e, 0xd4, 0x96, 0x33, 0xff, 0x82, 0xb6, 0xe5, 0x2e, 0xc3,
0x27, 0x4a, 0xce, 0x3e, 0x79, 0xa8, 0x08, 0x17, 0x48, 0x87, 0x41, 0x81, 0xe3, 0xff, 0x38, 0x21,
0xba, 0x64, 0xc8, 0x96, 0xea, 0xdf, 0x5a, 0xf4, 0x0d, 0xe0, 0x6e, 0xaa, 0xcb, 0x86, 0x62, 0xa9,
0x7e, 0x67, 0x82, 0x10, 0xf4, 0x63, 0x4c, 0xa9, 0xae, 0x34, 0x4a, 0x53, 0x9b, 0x4f, 0x32, 0x4c,
0x3a, 0x4f, 0xf0, 0x22, 0x67, 0x9c, 0xa0, 0x5f, 0x30, 0xe6, 0x55, 0x96, 0xe1, 0xf2, 0x12, 0x71,
0x81, 0x45, 0xc5, 0x75, 0xc9, 0x90, 0xac, 0xf1, 0xfc, 0xbb, 0xdd, 0xfe, 0xcd, 0x7e, 0x45, 0xd9,
0xc1, 0x15, 0x09, 0x1a, 0xc2, 0x1f, 0xf1, 0x6e, 0x8b, 0x7e, 0xc0, 0x54, 0xa4, 0x19, 0x89, 0x2a,
0x26, 0x52, 0x1a, 0xf1, 0xf8, 0x1f, 0x39, 0x57, 0x94, 0x9c, 0x75, 0xd9, 0x90, 0x2c, 0xc5, 0x47,
0xb5, 0x16, 0xd6, 0x52, 0x70, 0x53, 0xcc, 0x0c, 0x46, 0x2f, 0x1c, 0xd1, 0x27, 0x18, 0x38, 0xee,
0x7a, 0x11, 0xee, 0x0e, 0x5a, 0xaf, 0x6e, 0x5c, 0x6f, 0xb1, 0xdc, 0xb9, 0x8e, 0x26, 0xa1, 0x29,
0x68, 0xc1, 0x6a, 0xe3, 0x3a, 0xe1, 0xce, 0x75, 0xa2, 0x75, 0x78, 0x08, 0x7d, 0x57, 0x93, 0xd1,
0x04, 0x46, 0xf7, 0xa9, 0xb7, 0x3f, 0x6a, 0x0a, 0x1a, 0xc2, 0x47, 0x67, 0x1b, 0x5c, 0xb1, 0x7e,
0xed, 0x11, 0x7a, 0x3f, 0xbd, 0xfd, 0xd1, 0xd3, 0x3e, 0xcc, 0xff, 0xc0, 0x64, 0xd5, 0xde, 0x2a,
0xb8, 0x26, 0x82, 0x36, 0xa0, 0xb6, 0x7b, 0xa2, 0x2f, 0x6f, 0x6f, 0xdf, 0xc4, 0xf2, 0xf9, 0xeb,
0x7b, 0xa7, 0x31, 0x7b, 0xcb, 0xe1, 0xef, 0x4e, 0x14, 0xcf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xc0,
0x03, 0x26, 0x25, 0x2e, 0x02, 0x00, 0x00,
}

View File

@ -1,28 +0,0 @@
syntax = "proto2";
option go_package = "capability";
package appengine;
message IsEnabledRequest {
required string package = 1;
repeated string capability = 2;
repeated string call = 3;
}
message IsEnabledResponse {
enum SummaryStatus {
DEFAULT = 0;
ENABLED = 1;
SCHEDULED_FUTURE = 2;
SCHEDULED_NOW = 3;
DISABLED = 4;
UNKNOWN = 5;
}
optional SummaryStatus summary_status = 1;
optional int64 time_until_scheduled = 2;
}
service CapabilityService {
rpc IsEnabled(IsEnabledRequest) returns (IsEnabledResponse) {};
}

View File

@ -1,273 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: google.golang.org/appengine/internal/channel/channel_service.proto
package channel
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type ChannelServiceError_ErrorCode int32
const (
ChannelServiceError_OK ChannelServiceError_ErrorCode = 0
ChannelServiceError_INTERNAL_ERROR ChannelServiceError_ErrorCode = 1
ChannelServiceError_INVALID_CHANNEL_KEY ChannelServiceError_ErrorCode = 2
ChannelServiceError_BAD_MESSAGE ChannelServiceError_ErrorCode = 3
ChannelServiceError_INVALID_CHANNEL_TOKEN_DURATION ChannelServiceError_ErrorCode = 4
ChannelServiceError_APPID_ALIAS_REQUIRED ChannelServiceError_ErrorCode = 5
)
var ChannelServiceError_ErrorCode_name = map[int32]string{
0: "OK",
1: "INTERNAL_ERROR",
2: "INVALID_CHANNEL_KEY",
3: "BAD_MESSAGE",
4: "INVALID_CHANNEL_TOKEN_DURATION",
5: "APPID_ALIAS_REQUIRED",
}
var ChannelServiceError_ErrorCode_value = map[string]int32{
"OK": 0,
"INTERNAL_ERROR": 1,
"INVALID_CHANNEL_KEY": 2,
"BAD_MESSAGE": 3,
"INVALID_CHANNEL_TOKEN_DURATION": 4,
"APPID_ALIAS_REQUIRED": 5,
}
func (x ChannelServiceError_ErrorCode) Enum() *ChannelServiceError_ErrorCode {
p := new(ChannelServiceError_ErrorCode)
*p = x
return p
}
func (x ChannelServiceError_ErrorCode) String() string {
return proto.EnumName(ChannelServiceError_ErrorCode_name, int32(x))
}
func (x *ChannelServiceError_ErrorCode) UnmarshalJSON(data []byte) error {
value, err := proto.UnmarshalJSONEnum(ChannelServiceError_ErrorCode_value, data, "ChannelServiceError_ErrorCode")
if err != nil {
return err
}
*x = ChannelServiceError_ErrorCode(value)
return nil
}
func (ChannelServiceError_ErrorCode) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_channel_service_a8d15e05b34664a9, []int{0, 0}
}
type ChannelServiceError struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ChannelServiceError) Reset() { *m = ChannelServiceError{} }
func (m *ChannelServiceError) String() string { return proto.CompactTextString(m) }
func (*ChannelServiceError) ProtoMessage() {}
func (*ChannelServiceError) Descriptor() ([]byte, []int) {
return fileDescriptor_channel_service_a8d15e05b34664a9, []int{0}
}
func (m *ChannelServiceError) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ChannelServiceError.Unmarshal(m, b)
}
func (m *ChannelServiceError) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ChannelServiceError.Marshal(b, m, deterministic)
}
func (dst *ChannelServiceError) XXX_Merge(src proto.Message) {
xxx_messageInfo_ChannelServiceError.Merge(dst, src)
}
func (m *ChannelServiceError) XXX_Size() int {
return xxx_messageInfo_ChannelServiceError.Size(m)
}
func (m *ChannelServiceError) XXX_DiscardUnknown() {
xxx_messageInfo_ChannelServiceError.DiscardUnknown(m)
}
var xxx_messageInfo_ChannelServiceError proto.InternalMessageInfo
type CreateChannelRequest struct {
ApplicationKey *string `protobuf:"bytes,1,req,name=application_key,json=applicationKey" json:"application_key,omitempty"`
DurationMinutes *int32 `protobuf:"varint,2,opt,name=duration_minutes,json=durationMinutes" json:"duration_minutes,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CreateChannelRequest) Reset() { *m = CreateChannelRequest{} }
func (m *CreateChannelRequest) String() string { return proto.CompactTextString(m) }
func (*CreateChannelRequest) ProtoMessage() {}
func (*CreateChannelRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_channel_service_a8d15e05b34664a9, []int{1}
}
func (m *CreateChannelRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CreateChannelRequest.Unmarshal(m, b)
}
func (m *CreateChannelRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CreateChannelRequest.Marshal(b, m, deterministic)
}
func (dst *CreateChannelRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_CreateChannelRequest.Merge(dst, src)
}
func (m *CreateChannelRequest) XXX_Size() int {
return xxx_messageInfo_CreateChannelRequest.Size(m)
}
func (m *CreateChannelRequest) XXX_DiscardUnknown() {
xxx_messageInfo_CreateChannelRequest.DiscardUnknown(m)
}
var xxx_messageInfo_CreateChannelRequest proto.InternalMessageInfo
func (m *CreateChannelRequest) GetApplicationKey() string {
if m != nil && m.ApplicationKey != nil {
return *m.ApplicationKey
}
return ""
}
func (m *CreateChannelRequest) GetDurationMinutes() int32 {
if m != nil && m.DurationMinutes != nil {
return *m.DurationMinutes
}
return 0
}
type CreateChannelResponse struct {
Token *string `protobuf:"bytes,2,opt,name=token" json:"token,omitempty"`
DurationMinutes *int32 `protobuf:"varint,3,opt,name=duration_minutes,json=durationMinutes" json:"duration_minutes,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CreateChannelResponse) Reset() { *m = CreateChannelResponse{} }
func (m *CreateChannelResponse) String() string { return proto.CompactTextString(m) }
func (*CreateChannelResponse) ProtoMessage() {}
func (*CreateChannelResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_channel_service_a8d15e05b34664a9, []int{2}
}
func (m *CreateChannelResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CreateChannelResponse.Unmarshal(m, b)
}
func (m *CreateChannelResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CreateChannelResponse.Marshal(b, m, deterministic)
}
func (dst *CreateChannelResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_CreateChannelResponse.Merge(dst, src)
}
func (m *CreateChannelResponse) XXX_Size() int {
return xxx_messageInfo_CreateChannelResponse.Size(m)
}
func (m *CreateChannelResponse) XXX_DiscardUnknown() {
xxx_messageInfo_CreateChannelResponse.DiscardUnknown(m)
}
var xxx_messageInfo_CreateChannelResponse proto.InternalMessageInfo
func (m *CreateChannelResponse) GetToken() string {
if m != nil && m.Token != nil {
return *m.Token
}
return ""
}
func (m *CreateChannelResponse) GetDurationMinutes() int32 {
if m != nil && m.DurationMinutes != nil {
return *m.DurationMinutes
}
return 0
}
type SendMessageRequest struct {
ApplicationKey *string `protobuf:"bytes,1,req,name=application_key,json=applicationKey" json:"application_key,omitempty"`
Message *string `protobuf:"bytes,2,req,name=message" json:"message,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *SendMessageRequest) Reset() { *m = SendMessageRequest{} }
func (m *SendMessageRequest) String() string { return proto.CompactTextString(m) }
func (*SendMessageRequest) ProtoMessage() {}
func (*SendMessageRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_channel_service_a8d15e05b34664a9, []int{3}
}
func (m *SendMessageRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SendMessageRequest.Unmarshal(m, b)
}
func (m *SendMessageRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_SendMessageRequest.Marshal(b, m, deterministic)
}
func (dst *SendMessageRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_SendMessageRequest.Merge(dst, src)
}
func (m *SendMessageRequest) XXX_Size() int {
return xxx_messageInfo_SendMessageRequest.Size(m)
}
func (m *SendMessageRequest) XXX_DiscardUnknown() {
xxx_messageInfo_SendMessageRequest.DiscardUnknown(m)
}
var xxx_messageInfo_SendMessageRequest proto.InternalMessageInfo
func (m *SendMessageRequest) GetApplicationKey() string {
if m != nil && m.ApplicationKey != nil {
return *m.ApplicationKey
}
return ""
}
func (m *SendMessageRequest) GetMessage() string {
if m != nil && m.Message != nil {
return *m.Message
}
return ""
}
func init() {
proto.RegisterType((*ChannelServiceError)(nil), "appengine.ChannelServiceError")
proto.RegisterType((*CreateChannelRequest)(nil), "appengine.CreateChannelRequest")
proto.RegisterType((*CreateChannelResponse)(nil), "appengine.CreateChannelResponse")
proto.RegisterType((*SendMessageRequest)(nil), "appengine.SendMessageRequest")
}
func init() {
proto.RegisterFile("google.golang.org/appengine/internal/channel/channel_service.proto", fileDescriptor_channel_service_a8d15e05b34664a9)
}
var fileDescriptor_channel_service_a8d15e05b34664a9 = []byte{
// 355 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x91, 0xcd, 0xee, 0xd2, 0x40,
0x14, 0xc5, 0x6d, 0xff, 0x22, 0xe9, 0x35, 0x81, 0x66, 0xc0, 0xd8, 0x95, 0x21, 0xdd, 0x88, 0x1b,
0x78, 0x86, 0xa1, 0x9d, 0x68, 0xd3, 0xd2, 0xe2, 0x14, 0xfc, 0xda, 0x4c, 0x26, 0x70, 0x53, 0x2b,
0x65, 0xa6, 0x4e, 0x8b, 0x09, 0x4f, 0xe1, 0x63, 0xf8, 0x9a, 0x26, 0x14, 0x88, 0x21, 0x6c, 0x5c,
0xcd, 0x9c, 0x93, 0xdf, 0x39, 0x33, 0x37, 0x17, 0x16, 0x85, 0xd6, 0x45, 0x85, 0xb3, 0x42, 0x57,
0x52, 0x15, 0x33, 0x6d, 0x8a, 0xb9, 0xac, 0x6b, 0x54, 0x45, 0xa9, 0x70, 0x5e, 0xaa, 0x16, 0x8d,
0x92, 0xd5, 0x7c, 0xfb, 0x5d, 0x2a, 0x85, 0xb7, 0x53, 0x34, 0x68, 0x7e, 0x95, 0x5b, 0x9c, 0xd5,
0x46, 0xb7, 0x9a, 0x38, 0xb7, 0x84, 0xff, 0xc7, 0x82, 0x51, 0xd0, 0x41, 0x79, 0xc7, 0x30, 0x63,
0xb4, 0xf1, 0x7f, 0x5b, 0xe0, 0x9c, 0x6f, 0x81, 0xde, 0x21, 0x79, 0x01, 0x76, 0x16, 0xbb, 0xcf,
0x08, 0x81, 0x41, 0x94, 0xae, 0x19, 0x4f, 0x69, 0x22, 0x18, 0xe7, 0x19, 0x77, 0x2d, 0xf2, 0x1a,
0x46, 0x51, 0xfa, 0x89, 0x26, 0x51, 0x28, 0x82, 0x0f, 0x34, 0x4d, 0x59, 0x22, 0x62, 0xf6, 0xd5,
0xb5, 0xc9, 0x10, 0x5e, 0x2e, 0x68, 0x28, 0x96, 0x2c, 0xcf, 0xe9, 0x7b, 0xe6, 0x3e, 0x11, 0x1f,
0xde, 0xdc, 0x93, 0xeb, 0x2c, 0x66, 0xa9, 0x08, 0x37, 0x9c, 0xae, 0xa3, 0x2c, 0x75, 0x9f, 0x13,
0x0f, 0xc6, 0x74, 0xb5, 0x8a, 0x42, 0x41, 0x93, 0x88, 0xe6, 0x82, 0xb3, 0x8f, 0x9b, 0x88, 0xb3,
0xd0, 0xed, 0xf9, 0x3f, 0x60, 0x1c, 0x18, 0x94, 0x2d, 0x5e, 0xbe, 0xcb, 0xf1, 0xe7, 0x11, 0x9b,
0x96, 0xbc, 0x85, 0xa1, 0xac, 0xeb, 0xaa, 0xdc, 0xca, 0xb6, 0xd4, 0x4a, 0xec, 0xf1, 0xe4, 0x59,
0x13, 0x7b, 0xea, 0xf0, 0xc1, 0x3f, 0x76, 0x8c, 0x27, 0xf2, 0x0e, 0xdc, 0xdd, 0xd1, 0x74, 0xd4,
0xa1, 0x54, 0xc7, 0x16, 0x1b, 0xcf, 0x9e, 0x58, 0xd3, 0x1e, 0x1f, 0x5e, 0xfd, 0x65, 0x67, 0xfb,
0x5f, 0xe0, 0xd5, 0xdd, 0x5b, 0x4d, 0xad, 0x55, 0x83, 0x64, 0x0c, 0xbd, 0x56, 0xef, 0x51, 0x9d,
0x83, 0x0e, 0xef, 0xc4, 0xc3, 0xe6, 0xa7, 0xc7, 0xcd, 0x9f, 0x81, 0xe4, 0xa8, 0x76, 0x4b, 0x6c,
0x1a, 0x59, 0xe0, 0x7f, 0xcf, 0xe0, 0x41, 0xff, 0xd0, 0x45, 0x3d, 0xfb, 0x0c, 0x5c, 0xe5, 0xc2,
0xf9, 0xd6, 0xbf, 0x2c, 0xfb, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe9, 0x0a, 0x77, 0x06, 0x23,
0x02, 0x00, 0x00,
}

View File

@ -1,30 +0,0 @@
syntax = "proto2";
option go_package = "channel";
package appengine;
message ChannelServiceError {
enum ErrorCode {
OK = 0;
INTERNAL_ERROR = 1;
INVALID_CHANNEL_KEY = 2;
BAD_MESSAGE = 3;
INVALID_CHANNEL_TOKEN_DURATION = 4;
APPID_ALIAS_REQUIRED = 5;
}
}
message CreateChannelRequest {
required string application_key = 1;
optional int32 duration_minutes = 2;
}
message CreateChannelResponse {
optional string token = 2;
optional int32 duration_minutes = 3;
}
message SendMessageRequest {
required string application_key = 1;
required string message = 2;
}

View File

@ -1,551 +0,0 @@
syntax = "proto2";
option go_package = "datastore";
package appengine;
message Action{}
message PropertyValue {
optional int64 int64Value = 1;
optional bool booleanValue = 2;
optional string stringValue = 3;
optional double doubleValue = 4;
optional group PointValue = 5 {
required double x = 6;
required double y = 7;
}
optional group UserValue = 8 {
required string email = 9;
required string auth_domain = 10;
optional string nickname = 11;
optional string federated_identity = 21;
optional string federated_provider = 22;
}
optional group ReferenceValue = 12 {
required string app = 13;
optional string name_space = 20;
repeated group PathElement = 14 {
required string type = 15;
optional int64 id = 16;
optional string name = 17;
}
}
}
message Property {
enum Meaning {
NO_MEANING = 0;
BLOB = 14;
TEXT = 15;
BYTESTRING = 16;
ATOM_CATEGORY = 1;
ATOM_LINK = 2;
ATOM_TITLE = 3;
ATOM_CONTENT = 4;
ATOM_SUMMARY = 5;
ATOM_AUTHOR = 6;
GD_WHEN = 7;
GD_EMAIL = 8;
GEORSS_POINT = 9;
GD_IM = 10;
GD_PHONENUMBER = 11;
GD_POSTALADDRESS = 12;
GD_RATING = 13;
BLOBKEY = 17;
ENTITY_PROTO = 19;
INDEX_VALUE = 18;
};
optional Meaning meaning = 1 [default = NO_MEANING];
optional string meaning_uri = 2;
required string name = 3;
required PropertyValue value = 5;
required bool multiple = 4;
optional bool searchable = 6 [default=false];
enum FtsTokenizationOption {
HTML = 1;
ATOM = 2;
}
optional FtsTokenizationOption fts_tokenization_option = 8;
optional string locale = 9 [default = "en"];
}
message Path {
repeated group Element = 1 {
required string type = 2;
optional int64 id = 3;
optional string name = 4;
}
}
message Reference {
required string app = 13;
optional string name_space = 20;
required Path path = 14;
}
message User {
required string email = 1;
required string auth_domain = 2;
optional string nickname = 3;
optional string federated_identity = 6;
optional string federated_provider = 7;
}
message EntityProto {
required Reference key = 13;
required Path entity_group = 16;
optional User owner = 17;
enum Kind {
GD_CONTACT = 1;
GD_EVENT = 2;
GD_MESSAGE = 3;
}
optional Kind kind = 4;
optional string kind_uri = 5;
repeated Property property = 14;
repeated Property raw_property = 15;
optional int32 rank = 18;
}
message CompositeProperty {
required int64 index_id = 1;
repeated string value = 2;
}
message Index {
required string entity_type = 1;
required bool ancestor = 5;
repeated group Property = 2 {
required string name = 3;
enum Direction {
ASCENDING = 1;
DESCENDING = 2;
}
optional Direction direction = 4 [default = ASCENDING];
}
}
message CompositeIndex {
required string app_id = 1;
required int64 id = 2;
required Index definition = 3;
enum State {
WRITE_ONLY = 1;
READ_WRITE = 2;
DELETED = 3;
ERROR = 4;
}
required State state = 4;
optional bool only_use_if_required = 6 [default = false];
}
message IndexPostfix {
message IndexValue {
required string property_name = 1;
required PropertyValue value = 2;
}
repeated IndexValue index_value = 1;
optional Reference key = 2;
optional bool before = 3 [default=true];
}
message IndexPosition {
optional string key = 1;
optional bool before = 2 [default=true];
}
message Snapshot {
enum Status {
INACTIVE = 0;
ACTIVE = 1;
}
required int64 ts = 1;
}
message InternalHeader {
optional string qos = 1;
}
message Transaction {
optional InternalHeader header = 4;
required fixed64 handle = 1;
required string app = 2;
optional bool mark_changes = 3 [default = false];
}
message Query {
optional InternalHeader header = 39;
required string app = 1;
optional string name_space = 29;
optional string kind = 3;
optional Reference ancestor = 17;
repeated group Filter = 4 {
enum Operator {
LESS_THAN = 1;
LESS_THAN_OR_EQUAL = 2;
GREATER_THAN = 3;
GREATER_THAN_OR_EQUAL = 4;
EQUAL = 5;
IN = 6;
EXISTS = 7;
}
required Operator op = 6;
repeated Property property = 14;
}
optional string search_query = 8;
repeated group Order = 9 {
enum Direction {
ASCENDING = 1;
DESCENDING = 2;
}
required string property = 10;
optional Direction direction = 11 [default = ASCENDING];
}
enum Hint {
ORDER_FIRST = 1;
ANCESTOR_FIRST = 2;
FILTER_FIRST = 3;
}
optional Hint hint = 18;
optional int32 count = 23;
optional int32 offset = 12 [default = 0];
optional int32 limit = 16;
optional CompiledCursor compiled_cursor = 30;
optional CompiledCursor end_compiled_cursor = 31;
repeated CompositeIndex composite_index = 19;
optional bool require_perfect_plan = 20 [default = false];
optional bool keys_only = 21 [default = false];
optional Transaction transaction = 22;
optional bool compile = 25 [default = false];
optional int64 failover_ms = 26;
optional bool strong = 32;
repeated string property_name = 33;
repeated string group_by_property_name = 34;
optional bool distinct = 24;
optional int64 min_safe_time_seconds = 35;
repeated string safe_replica_name = 36;
optional bool persist_offset = 37 [default=false];
}
message CompiledQuery {
required group PrimaryScan = 1 {
optional string index_name = 2;
optional string start_key = 3;
optional bool start_inclusive = 4;
optional string end_key = 5;
optional bool end_inclusive = 6;
repeated string start_postfix_value = 22;
repeated string end_postfix_value = 23;
optional int64 end_unapplied_log_timestamp_us = 19;
}
repeated group MergeJoinScan = 7 {
required string index_name = 8;
repeated string prefix_value = 9;
optional bool value_prefix = 20 [default=false];
}
optional Index index_def = 21;
optional int32 offset = 10 [default = 0];
optional int32 limit = 11;
required bool keys_only = 12;
repeated string property_name = 24;
optional int32 distinct_infix_size = 25;
optional group EntityFilter = 13 {
optional bool distinct = 14 [default=false];
optional string kind = 17;
optional Reference ancestor = 18;
}
}
message CompiledCursor {
optional group Position = 2 {
optional string start_key = 27;
repeated group IndexValue = 29 {
optional string property = 30;
required PropertyValue value = 31;
}
optional Reference key = 32;
optional bool start_inclusive = 28 [default=true];
}
}
message Cursor {
required fixed64 cursor = 1;
optional string app = 2;
}
message Error {
enum ErrorCode {
BAD_REQUEST = 1;
CONCURRENT_TRANSACTION = 2;
INTERNAL_ERROR = 3;
NEED_INDEX = 4;
TIMEOUT = 5;
PERMISSION_DENIED = 6;
BIGTABLE_ERROR = 7;
COMMITTED_BUT_STILL_APPLYING = 8;
CAPABILITY_DISABLED = 9;
TRY_ALTERNATE_BACKEND = 10;
SAFE_TIME_TOO_OLD = 11;
}
}
message Cost {
optional int32 index_writes = 1;
optional int32 index_write_bytes = 2;
optional int32 entity_writes = 3;
optional int32 entity_write_bytes = 4;
optional group CommitCost = 5 {
optional int32 requested_entity_puts = 6;
optional int32 requested_entity_deletes = 7;
};
optional int32 approximate_storage_delta = 8;
optional int32 id_sequence_updates = 9;
}
message GetRequest {
optional InternalHeader header = 6;
repeated Reference key = 1;
optional Transaction transaction = 2;
optional int64 failover_ms = 3;
optional bool strong = 4;
optional bool allow_deferred = 5 [default=false];
}
message GetResponse {
repeated group Entity = 1 {
optional EntityProto entity = 2;
optional Reference key = 4;
optional int64 version = 3;
}
repeated Reference deferred = 5;
optional bool in_order = 6 [default=true];
}
message PutRequest {
optional InternalHeader header = 11;
repeated EntityProto entity = 1;
optional Transaction transaction = 2;
repeated CompositeIndex composite_index = 3;
optional bool trusted = 4 [default = false];
optional bool force = 7 [default = false];
optional bool mark_changes = 8 [default = false];
repeated Snapshot snapshot = 9;
enum AutoIdPolicy {
CURRENT = 0;
SEQUENTIAL = 1;
}
optional AutoIdPolicy auto_id_policy = 10 [default = CURRENT];
}
message PutResponse {
repeated Reference key = 1;
optional Cost cost = 2;
repeated int64 version = 3;
}
message TouchRequest {
optional InternalHeader header = 10;
repeated Reference key = 1;
repeated CompositeIndex composite_index = 2;
optional bool force = 3 [default = false];
repeated Snapshot snapshot = 9;
}
message TouchResponse {
optional Cost cost = 1;
}
message DeleteRequest {
optional InternalHeader header = 10;
repeated Reference key = 6;
optional Transaction transaction = 5;
optional bool trusted = 4 [default = false];
optional bool force = 7 [default = false];
optional bool mark_changes = 8 [default = false];
repeated Snapshot snapshot = 9;
}
message DeleteResponse {
optional Cost cost = 1;
repeated int64 version = 3;
}
message NextRequest {
optional InternalHeader header = 5;
required Cursor cursor = 1;
optional int32 count = 2;
optional int32 offset = 4 [default = 0];
optional bool compile = 3 [default = false];
}
message QueryResult {
optional Cursor cursor = 1;
repeated EntityProto result = 2;
optional int32 skipped_results = 7;
required bool more_results = 3;
optional bool keys_only = 4;
optional bool index_only = 9;
optional bool small_ops = 10;
optional CompiledQuery compiled_query = 5;
optional CompiledCursor compiled_cursor = 6;
repeated CompositeIndex index = 8;
repeated int64 version = 11;
}
message AllocateIdsRequest {
optional InternalHeader header = 4;
optional Reference model_key = 1;
optional int64 size = 2;
optional int64 max = 3;
repeated Reference reserve = 5;
}
message AllocateIdsResponse {
required int64 start = 1;
required int64 end = 2;
optional Cost cost = 3;
}
message CompositeIndices {
repeated CompositeIndex index = 1;
}
message AddActionsRequest {
optional InternalHeader header = 3;
required Transaction transaction = 1;
repeated Action action = 2;
}
message AddActionsResponse {
}
message BeginTransactionRequest {
optional InternalHeader header = 3;
required string app = 1;
optional bool allow_multiple_eg = 2 [default = false];
optional string database_id = 4;
enum TransactionMode {
UNKNOWN = 0;
READ_ONLY = 1;
READ_WRITE = 2;
}
optional TransactionMode mode = 5 [default = UNKNOWN];
optional Transaction previous_transaction = 7;
}
message CommitResponse {
optional Cost cost = 1;
repeated group Version = 3 {
required Reference root_entity_key = 4;
required int64 version = 5;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,162 +0,0 @@
syntax = "proto2";
option go_package = "image";
package appengine;
message ImagesServiceError {
enum ErrorCode {
UNSPECIFIED_ERROR = 1;
BAD_TRANSFORM_DATA = 2;
NOT_IMAGE = 3;
BAD_IMAGE_DATA = 4;
IMAGE_TOO_LARGE = 5;
INVALID_BLOB_KEY = 6;
ACCESS_DENIED = 7;
OBJECT_NOT_FOUND = 8;
}
}
message ImagesServiceTransform {
enum Type {
RESIZE = 1;
ROTATE = 2;
HORIZONTAL_FLIP = 3;
VERTICAL_FLIP = 4;
CROP = 5;
IM_FEELING_LUCKY = 6;
}
}
message Transform {
optional int32 width = 1;
optional int32 height = 2;
optional bool crop_to_fit = 11 [default = false];
optional float crop_offset_x = 12 [default = 0.5];
optional float crop_offset_y = 13 [default = 0.5];
optional int32 rotate = 3 [default = 0];
optional bool horizontal_flip = 4 [default = false];
optional bool vertical_flip = 5 [default = false];
optional float crop_left_x = 6 [default = 0.0];
optional float crop_top_y = 7 [default = 0.0];
optional float crop_right_x = 8 [default = 1.0];
optional float crop_bottom_y = 9 [default = 1.0];
optional bool autolevels = 10 [default = false];
optional bool allow_stretch = 14 [default = false];
}
message ImageData {
required bytes content = 1 [ctype=CORD];
optional string blob_key = 2;
optional int32 width = 3;
optional int32 height = 4;
}
message InputSettings {
enum ORIENTATION_CORRECTION_TYPE {
UNCHANGED_ORIENTATION = 0;
CORRECT_ORIENTATION = 1;
}
optional ORIENTATION_CORRECTION_TYPE correct_exif_orientation = 1
[default=UNCHANGED_ORIENTATION];
optional bool parse_metadata = 2 [default=false];
optional int32 transparent_substitution_rgb = 3;
}
message OutputSettings {
enum MIME_TYPE {
PNG = 0;
JPEG = 1;
WEBP = 2;
}
optional MIME_TYPE mime_type = 1 [default=PNG];
optional int32 quality = 2;
}
message ImagesTransformRequest {
required ImageData image = 1;
repeated Transform transform = 2;
required OutputSettings output = 3;
optional InputSettings input = 4;
}
message ImagesTransformResponse {
required ImageData image = 1;
optional string source_metadata = 2;
}
message CompositeImageOptions {
required int32 source_index = 1;
required int32 x_offset = 2;
required int32 y_offset = 3;
required float opacity = 4;
enum ANCHOR {
TOP_LEFT = 0;
TOP = 1;
TOP_RIGHT = 2;
LEFT = 3;
CENTER = 4;
RIGHT = 5;
BOTTOM_LEFT = 6;
BOTTOM = 7;
BOTTOM_RIGHT = 8;
}
required ANCHOR anchor = 5;
}
message ImagesCanvas {
required int32 width = 1;
required int32 height = 2;
required OutputSettings output = 3;
optional int32 color = 4 [default=-1];
}
message ImagesCompositeRequest {
repeated ImageData image = 1;
repeated CompositeImageOptions options = 2;
required ImagesCanvas canvas = 3;
}
message ImagesCompositeResponse {
required ImageData image = 1;
}
message ImagesHistogramRequest {
required ImageData image = 1;
}
message ImagesHistogram {
repeated int32 red = 1;
repeated int32 green = 2;
repeated int32 blue = 3;
}
message ImagesHistogramResponse {
required ImagesHistogram histogram = 1;
}
message ImagesGetUrlBaseRequest {
required string blob_key = 1;
optional bool create_secure_url = 2 [default = false];
}
message ImagesGetUrlBaseResponse {
required string url = 1;
}
message ImagesDeleteUrlBaseRequest {
required string blob_key = 1;
}
message ImagesDeleteUrlBaseResponse {
}

View File

@ -1,60 +0,0 @@
// Copyright 2014 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// +build !appengine
package internal
import (
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
"testing"
)
func TestInstallingHealthChecker(t *testing.T) {
try := func(desc string, mux *http.ServeMux, wantCode int, wantBody string) {
installHealthChecker(mux)
srv := httptest.NewServer(mux)
defer srv.Close()
resp, err := http.Get(srv.URL + "/_ah/health")
if err != nil {
t.Errorf("%s: http.Get: %v", desc, err)
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
t.Errorf("%s: reading body: %v", desc, err)
return
}
if resp.StatusCode != wantCode {
t.Errorf("%s: got HTTP %d, want %d", desc, resp.StatusCode, wantCode)
return
}
if wantBody != "" && string(body) != wantBody {
t.Errorf("%s: got HTTP body %q, want %q", desc, body, wantBody)
return
}
}
// If there's no handlers, or only a root handler, a health checker should be installed.
try("empty mux", http.NewServeMux(), 200, "ok")
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "root handler")
})
try("mux with root handler", mux, 200, "ok")
// If there's a custom health check handler, one should not be installed.
mux = http.NewServeMux()
mux.HandleFunc("/_ah/health", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(418)
io.WriteString(w, "I'm short and stout!")
})
try("mux with custom health checker", mux, 418, "I'm short and stout!")
}

View File

@ -1,150 +0,0 @@
syntax = "proto2";
option go_package = "log";
package appengine;
message LogServiceError {
enum ErrorCode {
OK = 0;
INVALID_REQUEST = 1;
STORAGE_ERROR = 2;
}
}
message UserAppLogLine {
required int64 timestamp_usec = 1;
required int64 level = 2;
required string message = 3;
}
message UserAppLogGroup {
repeated UserAppLogLine log_line = 2;
}
message FlushRequest {
optional bytes logs = 1;
}
message SetStatusRequest {
required string status = 1;
}
message LogOffset {
optional bytes request_id = 1;
}
message LogLine {
required int64 time = 1;
required int32 level = 2;
required string log_message = 3;
}
message RequestLog {
required string app_id = 1;
optional string module_id = 37 [default="default"];
required string version_id = 2;
required bytes request_id = 3;
optional LogOffset offset = 35;
required string ip = 4;
optional string nickname = 5;
required int64 start_time = 6;
required int64 end_time = 7;
required int64 latency = 8;
required int64 mcycles = 9;
required string method = 10;
required string resource = 11;
required string http_version = 12;
required int32 status = 13;
required int64 response_size = 14;
optional string referrer = 15;
optional string user_agent = 16;
required string url_map_entry = 17;
required string combined = 18;
optional int64 api_mcycles = 19;
optional string host = 20;
optional double cost = 21;
optional string task_queue_name = 22;
optional string task_name = 23;
optional bool was_loading_request = 24;
optional int64 pending_time = 25;
optional int32 replica_index = 26 [default = -1];
optional bool finished = 27 [default = true];
optional bytes clone_key = 28;
repeated LogLine line = 29;
optional bool lines_incomplete = 36;
optional bytes app_engine_release = 38;
optional int32 exit_reason = 30;
optional bool was_throttled_for_time = 31;
optional bool was_throttled_for_requests = 32;
optional int64 throttled_time = 33;
optional bytes server_name = 34;
}
message LogModuleVersion {
optional string module_id = 1 [default="default"];
optional string version_id = 2;
}
message LogReadRequest {
required string app_id = 1;
repeated string version_id = 2;
repeated LogModuleVersion module_version = 19;
optional int64 start_time = 3;
optional int64 end_time = 4;
optional LogOffset offset = 5;
repeated bytes request_id = 6;
optional int32 minimum_log_level = 7;
optional bool include_incomplete = 8;
optional int64 count = 9;
optional string combined_log_regex = 14;
optional string host_regex = 15;
optional int32 replica_index = 16;
optional bool include_app_logs = 10;
optional int32 app_logs_per_request = 17;
optional bool include_host = 11;
optional bool include_all = 12;
optional bool cache_iterator = 13;
optional int32 num_shards = 18;
}
message LogReadResponse {
repeated RequestLog log = 1;
optional LogOffset offset = 2;
optional int64 last_end_time = 3;
}
message LogUsageRecord {
optional string version_id = 1;
optional int32 start_time = 2;
optional int32 end_time = 3;
optional int64 count = 4;
optional int64 total_size = 5;
optional int32 records = 6;
}
message LogUsageRequest {
required string app_id = 1;
repeated string version_id = 2;
optional int32 start_time = 3;
optional int32 end_time = 4;
optional uint32 resolution_hours = 5 [default = 1];
optional bool combine_versions = 6;
optional int32 usage_version = 7;
optional bool versions_only = 8;
}
message LogUsageResponse {
repeated LogUsageRecord usage = 1;
optional LogUsageRecord summary = 2;
}

View File

@ -1,355 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: google.golang.org/appengine/internal/mail/mail_service.proto
package mail
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type MailServiceError_ErrorCode int32
const (
MailServiceError_OK MailServiceError_ErrorCode = 0
MailServiceError_INTERNAL_ERROR MailServiceError_ErrorCode = 1
MailServiceError_BAD_REQUEST MailServiceError_ErrorCode = 2
MailServiceError_UNAUTHORIZED_SENDER MailServiceError_ErrorCode = 3
MailServiceError_INVALID_ATTACHMENT_TYPE MailServiceError_ErrorCode = 4
MailServiceError_INVALID_HEADER_NAME MailServiceError_ErrorCode = 5
MailServiceError_INVALID_CONTENT_ID MailServiceError_ErrorCode = 6
)
var MailServiceError_ErrorCode_name = map[int32]string{
0: "OK",
1: "INTERNAL_ERROR",
2: "BAD_REQUEST",
3: "UNAUTHORIZED_SENDER",
4: "INVALID_ATTACHMENT_TYPE",
5: "INVALID_HEADER_NAME",
6: "INVALID_CONTENT_ID",
}
var MailServiceError_ErrorCode_value = map[string]int32{
"OK": 0,
"INTERNAL_ERROR": 1,
"BAD_REQUEST": 2,
"UNAUTHORIZED_SENDER": 3,
"INVALID_ATTACHMENT_TYPE": 4,
"INVALID_HEADER_NAME": 5,
"INVALID_CONTENT_ID": 6,
}
func (x MailServiceError_ErrorCode) Enum() *MailServiceError_ErrorCode {
p := new(MailServiceError_ErrorCode)
*p = x
return p
}
func (x MailServiceError_ErrorCode) String() string {
return proto.EnumName(MailServiceError_ErrorCode_name, int32(x))
}
func (x *MailServiceError_ErrorCode) UnmarshalJSON(data []byte) error {
value, err := proto.UnmarshalJSONEnum(MailServiceError_ErrorCode_value, data, "MailServiceError_ErrorCode")
if err != nil {
return err
}
*x = MailServiceError_ErrorCode(value)
return nil
}
func (MailServiceError_ErrorCode) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_mail_service_78722be3c4c01d17, []int{0, 0}
}
type MailServiceError struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *MailServiceError) Reset() { *m = MailServiceError{} }
func (m *MailServiceError) String() string { return proto.CompactTextString(m) }
func (*MailServiceError) ProtoMessage() {}
func (*MailServiceError) Descriptor() ([]byte, []int) {
return fileDescriptor_mail_service_78722be3c4c01d17, []int{0}
}
func (m *MailServiceError) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_MailServiceError.Unmarshal(m, b)
}
func (m *MailServiceError) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_MailServiceError.Marshal(b, m, deterministic)
}
func (dst *MailServiceError) XXX_Merge(src proto.Message) {
xxx_messageInfo_MailServiceError.Merge(dst, src)
}
func (m *MailServiceError) XXX_Size() int {
return xxx_messageInfo_MailServiceError.Size(m)
}
func (m *MailServiceError) XXX_DiscardUnknown() {
xxx_messageInfo_MailServiceError.DiscardUnknown(m)
}
var xxx_messageInfo_MailServiceError proto.InternalMessageInfo
type MailAttachment struct {
FileName *string `protobuf:"bytes,1,req,name=FileName" json:"FileName,omitempty"`
Data []byte `protobuf:"bytes,2,req,name=Data" json:"Data,omitempty"`
ContentID *string `protobuf:"bytes,3,opt,name=ContentID" json:"ContentID,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *MailAttachment) Reset() { *m = MailAttachment{} }
func (m *MailAttachment) String() string { return proto.CompactTextString(m) }
func (*MailAttachment) ProtoMessage() {}
func (*MailAttachment) Descriptor() ([]byte, []int) {
return fileDescriptor_mail_service_78722be3c4c01d17, []int{1}
}
func (m *MailAttachment) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_MailAttachment.Unmarshal(m, b)
}
func (m *MailAttachment) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_MailAttachment.Marshal(b, m, deterministic)
}
func (dst *MailAttachment) XXX_Merge(src proto.Message) {
xxx_messageInfo_MailAttachment.Merge(dst, src)
}
func (m *MailAttachment) XXX_Size() int {
return xxx_messageInfo_MailAttachment.Size(m)
}
func (m *MailAttachment) XXX_DiscardUnknown() {
xxx_messageInfo_MailAttachment.DiscardUnknown(m)
}
var xxx_messageInfo_MailAttachment proto.InternalMessageInfo
func (m *MailAttachment) GetFileName() string {
if m != nil && m.FileName != nil {
return *m.FileName
}
return ""
}
func (m *MailAttachment) GetData() []byte {
if m != nil {
return m.Data
}
return nil
}
func (m *MailAttachment) GetContentID() string {
if m != nil && m.ContentID != nil {
return *m.ContentID
}
return ""
}
type MailHeader struct {
Name *string `protobuf:"bytes,1,req,name=name" json:"name,omitempty"`
Value *string `protobuf:"bytes,2,req,name=value" json:"value,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *MailHeader) Reset() { *m = MailHeader{} }
func (m *MailHeader) String() string { return proto.CompactTextString(m) }
func (*MailHeader) ProtoMessage() {}
func (*MailHeader) Descriptor() ([]byte, []int) {
return fileDescriptor_mail_service_78722be3c4c01d17, []int{2}
}
func (m *MailHeader) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_MailHeader.Unmarshal(m, b)
}
func (m *MailHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_MailHeader.Marshal(b, m, deterministic)
}
func (dst *MailHeader) XXX_Merge(src proto.Message) {
xxx_messageInfo_MailHeader.Merge(dst, src)
}
func (m *MailHeader) XXX_Size() int {
return xxx_messageInfo_MailHeader.Size(m)
}
func (m *MailHeader) XXX_DiscardUnknown() {
xxx_messageInfo_MailHeader.DiscardUnknown(m)
}
var xxx_messageInfo_MailHeader proto.InternalMessageInfo
func (m *MailHeader) GetName() string {
if m != nil && m.Name != nil {
return *m.Name
}
return ""
}
func (m *MailHeader) GetValue() string {
if m != nil && m.Value != nil {
return *m.Value
}
return ""
}
type MailMessage struct {
Sender *string `protobuf:"bytes,1,req,name=Sender" json:"Sender,omitempty"`
ReplyTo *string `protobuf:"bytes,2,opt,name=ReplyTo" json:"ReplyTo,omitempty"`
To []string `protobuf:"bytes,3,rep,name=To" json:"To,omitempty"`
Cc []string `protobuf:"bytes,4,rep,name=Cc" json:"Cc,omitempty"`
Bcc []string `protobuf:"bytes,5,rep,name=Bcc" json:"Bcc,omitempty"`
Subject *string `protobuf:"bytes,6,req,name=Subject" json:"Subject,omitempty"`
TextBody *string `protobuf:"bytes,7,opt,name=TextBody" json:"TextBody,omitempty"`
HtmlBody *string `protobuf:"bytes,8,opt,name=HtmlBody" json:"HtmlBody,omitempty"`
Attachment []*MailAttachment `protobuf:"bytes,9,rep,name=Attachment" json:"Attachment,omitempty"`
Header []*MailHeader `protobuf:"bytes,10,rep,name=Header" json:"Header,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *MailMessage) Reset() { *m = MailMessage{} }
func (m *MailMessage) String() string { return proto.CompactTextString(m) }
func (*MailMessage) ProtoMessage() {}
func (*MailMessage) Descriptor() ([]byte, []int) {
return fileDescriptor_mail_service_78722be3c4c01d17, []int{3}
}
func (m *MailMessage) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_MailMessage.Unmarshal(m, b)
}
func (m *MailMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_MailMessage.Marshal(b, m, deterministic)
}
func (dst *MailMessage) XXX_Merge(src proto.Message) {
xxx_messageInfo_MailMessage.Merge(dst, src)
}
func (m *MailMessage) XXX_Size() int {
return xxx_messageInfo_MailMessage.Size(m)
}
func (m *MailMessage) XXX_DiscardUnknown() {
xxx_messageInfo_MailMessage.DiscardUnknown(m)
}
var xxx_messageInfo_MailMessage proto.InternalMessageInfo
func (m *MailMessage) GetSender() string {
if m != nil && m.Sender != nil {
return *m.Sender
}
return ""
}
func (m *MailMessage) GetReplyTo() string {
if m != nil && m.ReplyTo != nil {
return *m.ReplyTo
}
return ""
}
func (m *MailMessage) GetTo() []string {
if m != nil {
return m.To
}
return nil
}
func (m *MailMessage) GetCc() []string {
if m != nil {
return m.Cc
}
return nil
}
func (m *MailMessage) GetBcc() []string {
if m != nil {
return m.Bcc
}
return nil
}
func (m *MailMessage) GetSubject() string {
if m != nil && m.Subject != nil {
return *m.Subject
}
return ""
}
func (m *MailMessage) GetTextBody() string {
if m != nil && m.TextBody != nil {
return *m.TextBody
}
return ""
}
func (m *MailMessage) GetHtmlBody() string {
if m != nil && m.HtmlBody != nil {
return *m.HtmlBody
}
return ""
}
func (m *MailMessage) GetAttachment() []*MailAttachment {
if m != nil {
return m.Attachment
}
return nil
}
func (m *MailMessage) GetHeader() []*MailHeader {
if m != nil {
return m.Header
}
return nil
}
func init() {
proto.RegisterType((*MailServiceError)(nil), "appengine.MailServiceError")
proto.RegisterType((*MailAttachment)(nil), "appengine.MailAttachment")
proto.RegisterType((*MailHeader)(nil), "appengine.MailHeader")
proto.RegisterType((*MailMessage)(nil), "appengine.MailMessage")
}
func init() {
proto.RegisterFile("google.golang.org/appengine/internal/mail/mail_service.proto", fileDescriptor_mail_service_78722be3c4c01d17)
}
var fileDescriptor_mail_service_78722be3c4c01d17 = []byte{
// 480 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x92, 0xcf, 0x6e, 0xd3, 0x40,
0x10, 0xc6, 0x89, 0x9d, 0xb8, 0xf5, 0x04, 0x05, 0x6b, 0x81, 0x76, 0xf9, 0x73, 0x88, 0x72, 0xca,
0x85, 0x44, 0xe2, 0x80, 0x84, 0xc4, 0xc5, 0xb1, 0x17, 0xc5, 0xa2, 0x71, 0x60, 0xb3, 0x41, 0xa2,
0x07, 0xac, 0xc5, 0x19, 0x19, 0x23, 0xc7, 0x1b, 0x39, 0xdb, 0x8a, 0x3e, 0x0d, 0x4f, 0xc0, 0x8d,
0x07, 0x44, 0x6b, 0xc7, 0x09, 0xf4, 0x62, 0xcd, 0x6f, 0xbf, 0xf9, 0x66, 0xac, 0x4f, 0x03, 0xef,
0x32, 0xa5, 0xb2, 0x02, 0x27, 0x99, 0x2a, 0x64, 0x99, 0x4d, 0x54, 0x95, 0x4d, 0xe5, 0x6e, 0x87,
0x65, 0x96, 0x97, 0x38, 0xcd, 0x4b, 0x8d, 0x55, 0x29, 0x8b, 0xe9, 0x56, 0xe6, 0xcd, 0x27, 0xd9,
0x63, 0x75, 0x9b, 0xa7, 0x38, 0xd9, 0x55, 0x4a, 0x2b, 0xe2, 0x1e, 0x7b, 0x47, 0x7f, 0x3a, 0xe0,
0x2d, 0x64, 0x5e, 0xac, 0x9a, 0x06, 0x56, 0x55, 0xaa, 0x1a, 0xfd, 0xea, 0x80, 0x5b, 0x57, 0x81,
0xda, 0x20, 0x71, 0xc0, 0x5a, 0x7e, 0xf0, 0x1e, 0x10, 0x02, 0x83, 0x28, 0x16, 0x8c, 0xc7, 0xfe,
0x55, 0xc2, 0x38, 0x5f, 0x72, 0xaf, 0x43, 0x1e, 0x41, 0x7f, 0xe6, 0x87, 0x09, 0x67, 0x9f, 0xd6,
0x6c, 0x25, 0x3c, 0x8b, 0x5c, 0xc2, 0xe3, 0x75, 0xec, 0xaf, 0xc5, 0x7c, 0xc9, 0xa3, 0x6b, 0x16,
0x26, 0x2b, 0x16, 0x87, 0x8c, 0x7b, 0x36, 0x79, 0x01, 0x97, 0x51, 0xfc, 0xd9, 0xbf, 0x8a, 0xc2,
0xc4, 0x17, 0xc2, 0x0f, 0xe6, 0x0b, 0x16, 0x8b, 0x44, 0x7c, 0xf9, 0xc8, 0xbc, 0xae, 0x71, 0xb5,
0xe2, 0x9c, 0xf9, 0x21, 0xe3, 0x49, 0xec, 0x2f, 0x98, 0xd7, 0x23, 0x17, 0x40, 0x5a, 0x21, 0x58,
0xc6, 0xc2, 0x58, 0xa2, 0xd0, 0x73, 0x46, 0x5f, 0x61, 0x60, 0xfe, 0xda, 0xd7, 0x5a, 0xa6, 0xdf,
0xb7, 0x58, 0x6a, 0xf2, 0x1c, 0xce, 0xdf, 0xe7, 0x05, 0xc6, 0x72, 0x8b, 0xb4, 0x33, 0xb4, 0xc6,
0x2e, 0x3f, 0x32, 0x21, 0xd0, 0x0d, 0xa5, 0x96, 0xd4, 0x1a, 0x5a, 0xe3, 0x87, 0xbc, 0xae, 0xc9,
0x4b, 0x70, 0x03, 0x55, 0x6a, 0x2c, 0x75, 0x14, 0x52, 0x7b, 0xd8, 0x19, 0xbb, 0xfc, 0xf4, 0x30,
0x7a, 0x03, 0x60, 0xe6, 0xcf, 0x51, 0x6e, 0xb0, 0x32, 0xfe, 0xf2, 0x34, 0xb7, 0xae, 0xc9, 0x13,
0xe8, 0xdd, 0xca, 0xe2, 0x06, 0xeb, 0xa1, 0x2e, 0x6f, 0x60, 0xf4, 0xdb, 0x82, 0xbe, 0x31, 0x2e,
0x70, 0xbf, 0x97, 0x19, 0x92, 0x0b, 0x70, 0x56, 0x58, 0x6e, 0xb0, 0x3a, 0x78, 0x0f, 0x44, 0x28,
0x9c, 0x71, 0xdc, 0x15, 0x77, 0x42, 0x51, 0xab, 0xde, 0xdd, 0x22, 0x19, 0x80, 0x25, 0x14, 0xb5,
0x87, 0xf6, 0xd8, 0xe5, 0x56, 0xc3, 0x41, 0x4a, 0xbb, 0x0d, 0x07, 0x29, 0xf1, 0xc0, 0x9e, 0xa5,
0x29, 0xed, 0xd5, 0x0f, 0xa6, 0x34, 0xb3, 0x56, 0x37, 0xdf, 0x7e, 0x60, 0xaa, 0xa9, 0x53, 0x2f,
0x69, 0xd1, 0x64, 0x22, 0xf0, 0xa7, 0x9e, 0xa9, 0xcd, 0x1d, 0x3d, 0xab, 0xd7, 0x1c, 0xd9, 0x68,
0x73, 0xbd, 0x2d, 0x6a, 0xed, 0xbc, 0xd1, 0x5a, 0x26, 0x6f, 0x01, 0x4e, 0xc9, 0x52, 0x77, 0x68,
0x8f, 0xfb, 0xaf, 0x9f, 0x4d, 0x8e, 0x47, 0x33, 0xf9, 0x3f, 0x7a, 0xfe, 0x4f, 0x33, 0x79, 0x05,
0x4e, 0x13, 0x1a, 0x85, 0xda, 0xf6, 0xf4, 0x9e, 0xad, 0x11, 0xf9, 0xa1, 0x69, 0xe6, 0x5c, 0x77,
0xcd, 0x7d, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x4e, 0xd3, 0x01, 0x27, 0xd0, 0x02, 0x00, 0x00,
}

View File

@ -1,45 +0,0 @@
syntax = "proto2";
option go_package = "mail";
package appengine;
message MailServiceError {
enum ErrorCode {
OK = 0;
INTERNAL_ERROR = 1;
BAD_REQUEST = 2;
UNAUTHORIZED_SENDER = 3;
INVALID_ATTACHMENT_TYPE = 4;
INVALID_HEADER_NAME = 5;
INVALID_CONTENT_ID = 6;
}
}
message MailAttachment {
required string FileName = 1;
required bytes Data = 2;
optional string ContentID = 3;
}
message MailHeader {
required string name = 1;
required string value = 2;
}
message MailMessage {
required string Sender = 1;
optional string ReplyTo = 2;
repeated string To = 3;
repeated string Cc = 4;
repeated string Bcc = 5;
required string Subject = 6;
optional string TextBody = 7;
optional string HtmlBody = 8;
repeated MailAttachment Attachment = 9;
repeated MailHeader Header = 10;
}

View File

@ -1,18 +0,0 @@
// +build !appengine
package internal
import (
"go/build"
"path/filepath"
"testing"
)
func TestFindMainPath(t *testing.T) {
// Tests won't have package main, instead they have testing.tRunner
want := filepath.Join(build.Default.GOROOT, "src", "testing", "testing.go")
got := findMainPath()
if want != got {
t.Errorf("findMainPath: want %s, got %s", want, got)
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,165 +0,0 @@
syntax = "proto2";
option go_package = "memcache";
package appengine;
message MemcacheServiceError {
enum ErrorCode {
OK = 0;
UNSPECIFIED_ERROR = 1;
NAMESPACE_NOT_SET = 2;
PERMISSION_DENIED = 3;
INVALID_VALUE = 6;
}
}
message AppOverride {
required string app_id = 1;
optional int32 num_memcacheg_backends = 2 [deprecated=true];
optional bool ignore_shardlock = 3 [deprecated=true];
optional string memcache_pool_hint = 4 [deprecated=true];
optional bytes memcache_sharding_strategy = 5 [deprecated=true];
}
message MemcacheGetRequest {
repeated bytes key = 1;
optional string name_space = 2 [default = ""];
optional bool for_cas = 4;
optional AppOverride override = 5;
}
message MemcacheGetResponse {
repeated group Item = 1 {
required bytes key = 2;
required bytes value = 3;
optional fixed32 flags = 4;
optional fixed64 cas_id = 5;
optional int32 expires_in_seconds = 6;
}
}
message MemcacheSetRequest {
enum SetPolicy {
SET = 1;
ADD = 2;
REPLACE = 3;
CAS = 4;
}
repeated group Item = 1 {
required bytes key = 2;
required bytes value = 3;
optional fixed32 flags = 4;
optional SetPolicy set_policy = 5 [default = SET];
optional fixed32 expiration_time = 6 [default = 0];
optional fixed64 cas_id = 8;
optional bool for_cas = 9;
}
optional string name_space = 7 [default = ""];
optional AppOverride override = 10;
}
message MemcacheSetResponse {
enum SetStatusCode {
STORED = 1;
NOT_STORED = 2;
ERROR = 3;
EXISTS = 4;
}
repeated SetStatusCode set_status = 1;
}
message MemcacheDeleteRequest {
repeated group Item = 1 {
required bytes key = 2;
optional fixed32 delete_time = 3 [default = 0];
}
optional string name_space = 4 [default = ""];
optional AppOverride override = 5;
}
message MemcacheDeleteResponse {
enum DeleteStatusCode {
DELETED = 1;
NOT_FOUND = 2;
}
repeated DeleteStatusCode delete_status = 1;
}
message MemcacheIncrementRequest {
enum Direction {
INCREMENT = 1;
DECREMENT = 2;
}
required bytes key = 1;
optional string name_space = 4 [default = ""];
optional uint64 delta = 2 [default = 1];
optional Direction direction = 3 [default = INCREMENT];
optional uint64 initial_value = 5;
optional fixed32 initial_flags = 6;
optional AppOverride override = 7;
}
message MemcacheIncrementResponse {
enum IncrementStatusCode {
OK = 1;
NOT_CHANGED = 2;
ERROR = 3;
}
optional uint64 new_value = 1;
optional IncrementStatusCode increment_status = 2;
}
message MemcacheBatchIncrementRequest {
optional string name_space = 1 [default = ""];
repeated MemcacheIncrementRequest item = 2;
optional AppOverride override = 3;
}
message MemcacheBatchIncrementResponse {
repeated MemcacheIncrementResponse item = 1;
}
message MemcacheFlushRequest {
optional AppOverride override = 1;
}
message MemcacheFlushResponse {
}
message MemcacheStatsRequest {
optional AppOverride override = 1;
}
message MergedNamespaceStats {
required uint64 hits = 1;
required uint64 misses = 2;
required uint64 byte_hits = 3;
required uint64 items = 4;
required uint64 bytes = 5;
required fixed32 oldest_item_age = 6;
}
message MemcacheStatsResponse {
optional MergedNamespaceStats stats = 1;
}
message MemcacheGrabTailRequest {
required int32 item_count = 1;
optional string name_space = 2 [default = ""];
optional AppOverride override = 3;
}
message MemcacheGrabTailResponse {
repeated group Item = 1 {
required bytes value = 2;
optional fixed32 flags = 3;
}
}

View File

@ -1,786 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: google.golang.org/appengine/internal/modules/modules_service.proto
package modules
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type ModulesServiceError_ErrorCode int32
const (
ModulesServiceError_OK ModulesServiceError_ErrorCode = 0
ModulesServiceError_INVALID_MODULE ModulesServiceError_ErrorCode = 1
ModulesServiceError_INVALID_VERSION ModulesServiceError_ErrorCode = 2
ModulesServiceError_INVALID_INSTANCES ModulesServiceError_ErrorCode = 3
ModulesServiceError_TRANSIENT_ERROR ModulesServiceError_ErrorCode = 4
ModulesServiceError_UNEXPECTED_STATE ModulesServiceError_ErrorCode = 5
)
var ModulesServiceError_ErrorCode_name = map[int32]string{
0: "OK",
1: "INVALID_MODULE",
2: "INVALID_VERSION",
3: "INVALID_INSTANCES",
4: "TRANSIENT_ERROR",
5: "UNEXPECTED_STATE",
}
var ModulesServiceError_ErrorCode_value = map[string]int32{
"OK": 0,
"INVALID_MODULE": 1,
"INVALID_VERSION": 2,
"INVALID_INSTANCES": 3,
"TRANSIENT_ERROR": 4,
"UNEXPECTED_STATE": 5,
}
func (x ModulesServiceError_ErrorCode) Enum() *ModulesServiceError_ErrorCode {
p := new(ModulesServiceError_ErrorCode)
*p = x
return p
}
func (x ModulesServiceError_ErrorCode) String() string {
return proto.EnumName(ModulesServiceError_ErrorCode_name, int32(x))
}
func (x *ModulesServiceError_ErrorCode) UnmarshalJSON(data []byte) error {
value, err := proto.UnmarshalJSONEnum(ModulesServiceError_ErrorCode_value, data, "ModulesServiceError_ErrorCode")
if err != nil {
return err
}
*x = ModulesServiceError_ErrorCode(value)
return nil
}
func (ModulesServiceError_ErrorCode) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_modules_service_9cd3bffe4e91c59a, []int{0, 0}
}
type ModulesServiceError struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ModulesServiceError) Reset() { *m = ModulesServiceError{} }
func (m *ModulesServiceError) String() string { return proto.CompactTextString(m) }
func (*ModulesServiceError) ProtoMessage() {}
func (*ModulesServiceError) Descriptor() ([]byte, []int) {
return fileDescriptor_modules_service_9cd3bffe4e91c59a, []int{0}
}
func (m *ModulesServiceError) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ModulesServiceError.Unmarshal(m, b)
}
func (m *ModulesServiceError) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ModulesServiceError.Marshal(b, m, deterministic)
}
func (dst *ModulesServiceError) XXX_Merge(src proto.Message) {
xxx_messageInfo_ModulesServiceError.Merge(dst, src)
}
func (m *ModulesServiceError) XXX_Size() int {
return xxx_messageInfo_ModulesServiceError.Size(m)
}
func (m *ModulesServiceError) XXX_DiscardUnknown() {
xxx_messageInfo_ModulesServiceError.DiscardUnknown(m)
}
var xxx_messageInfo_ModulesServiceError proto.InternalMessageInfo
type GetModulesRequest struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetModulesRequest) Reset() { *m = GetModulesRequest{} }
func (m *GetModulesRequest) String() string { return proto.CompactTextString(m) }
func (*GetModulesRequest) ProtoMessage() {}
func (*GetModulesRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_modules_service_9cd3bffe4e91c59a, []int{1}
}
func (m *GetModulesRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetModulesRequest.Unmarshal(m, b)
}
func (m *GetModulesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetModulesRequest.Marshal(b, m, deterministic)
}
func (dst *GetModulesRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetModulesRequest.Merge(dst, src)
}
func (m *GetModulesRequest) XXX_Size() int {
return xxx_messageInfo_GetModulesRequest.Size(m)
}
func (m *GetModulesRequest) XXX_DiscardUnknown() {
xxx_messageInfo_GetModulesRequest.DiscardUnknown(m)
}
var xxx_messageInfo_GetModulesRequest proto.InternalMessageInfo
type GetModulesResponse struct {
Module []string `protobuf:"bytes,1,rep,name=module" json:"module,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetModulesResponse) Reset() { *m = GetModulesResponse{} }
func (m *GetModulesResponse) String() string { return proto.CompactTextString(m) }
func (*GetModulesResponse) ProtoMessage() {}
func (*GetModulesResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_modules_service_9cd3bffe4e91c59a, []int{2}
}
func (m *GetModulesResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetModulesResponse.Unmarshal(m, b)
}
func (m *GetModulesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetModulesResponse.Marshal(b, m, deterministic)
}
func (dst *GetModulesResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetModulesResponse.Merge(dst, src)
}
func (m *GetModulesResponse) XXX_Size() int {
return xxx_messageInfo_GetModulesResponse.Size(m)
}
func (m *GetModulesResponse) XXX_DiscardUnknown() {
xxx_messageInfo_GetModulesResponse.DiscardUnknown(m)
}
var xxx_messageInfo_GetModulesResponse proto.InternalMessageInfo
func (m *GetModulesResponse) GetModule() []string {
if m != nil {
return m.Module
}
return nil
}
type GetVersionsRequest struct {
Module *string `protobuf:"bytes,1,opt,name=module" json:"module,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetVersionsRequest) Reset() { *m = GetVersionsRequest{} }
func (m *GetVersionsRequest) String() string { return proto.CompactTextString(m) }
func (*GetVersionsRequest) ProtoMessage() {}
func (*GetVersionsRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_modules_service_9cd3bffe4e91c59a, []int{3}
}
func (m *GetVersionsRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetVersionsRequest.Unmarshal(m, b)
}
func (m *GetVersionsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetVersionsRequest.Marshal(b, m, deterministic)
}
func (dst *GetVersionsRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetVersionsRequest.Merge(dst, src)
}
func (m *GetVersionsRequest) XXX_Size() int {
return xxx_messageInfo_GetVersionsRequest.Size(m)
}
func (m *GetVersionsRequest) XXX_DiscardUnknown() {
xxx_messageInfo_GetVersionsRequest.DiscardUnknown(m)
}
var xxx_messageInfo_GetVersionsRequest proto.InternalMessageInfo
func (m *GetVersionsRequest) GetModule() string {
if m != nil && m.Module != nil {
return *m.Module
}
return ""
}
type GetVersionsResponse struct {
Version []string `protobuf:"bytes,1,rep,name=version" json:"version,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetVersionsResponse) Reset() { *m = GetVersionsResponse{} }
func (m *GetVersionsResponse) String() string { return proto.CompactTextString(m) }
func (*GetVersionsResponse) ProtoMessage() {}
func (*GetVersionsResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_modules_service_9cd3bffe4e91c59a, []int{4}
}
func (m *GetVersionsResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetVersionsResponse.Unmarshal(m, b)
}
func (m *GetVersionsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetVersionsResponse.Marshal(b, m, deterministic)
}
func (dst *GetVersionsResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetVersionsResponse.Merge(dst, src)
}
func (m *GetVersionsResponse) XXX_Size() int {
return xxx_messageInfo_GetVersionsResponse.Size(m)
}
func (m *GetVersionsResponse) XXX_DiscardUnknown() {
xxx_messageInfo_GetVersionsResponse.DiscardUnknown(m)
}
var xxx_messageInfo_GetVersionsResponse proto.InternalMessageInfo
func (m *GetVersionsResponse) GetVersion() []string {
if m != nil {
return m.Version
}
return nil
}
type GetDefaultVersionRequest struct {
Module *string `protobuf:"bytes,1,opt,name=module" json:"module,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetDefaultVersionRequest) Reset() { *m = GetDefaultVersionRequest{} }
func (m *GetDefaultVersionRequest) String() string { return proto.CompactTextString(m) }
func (*GetDefaultVersionRequest) ProtoMessage() {}
func (*GetDefaultVersionRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_modules_service_9cd3bffe4e91c59a, []int{5}
}
func (m *GetDefaultVersionRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetDefaultVersionRequest.Unmarshal(m, b)
}
func (m *GetDefaultVersionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetDefaultVersionRequest.Marshal(b, m, deterministic)
}
func (dst *GetDefaultVersionRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetDefaultVersionRequest.Merge(dst, src)
}
func (m *GetDefaultVersionRequest) XXX_Size() int {
return xxx_messageInfo_GetDefaultVersionRequest.Size(m)
}
func (m *GetDefaultVersionRequest) XXX_DiscardUnknown() {
xxx_messageInfo_GetDefaultVersionRequest.DiscardUnknown(m)
}
var xxx_messageInfo_GetDefaultVersionRequest proto.InternalMessageInfo
func (m *GetDefaultVersionRequest) GetModule() string {
if m != nil && m.Module != nil {
return *m.Module
}
return ""
}
type GetDefaultVersionResponse struct {
Version *string `protobuf:"bytes,1,req,name=version" json:"version,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetDefaultVersionResponse) Reset() { *m = GetDefaultVersionResponse{} }
func (m *GetDefaultVersionResponse) String() string { return proto.CompactTextString(m) }
func (*GetDefaultVersionResponse) ProtoMessage() {}
func (*GetDefaultVersionResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_modules_service_9cd3bffe4e91c59a, []int{6}
}
func (m *GetDefaultVersionResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetDefaultVersionResponse.Unmarshal(m, b)
}
func (m *GetDefaultVersionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetDefaultVersionResponse.Marshal(b, m, deterministic)
}
func (dst *GetDefaultVersionResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetDefaultVersionResponse.Merge(dst, src)
}
func (m *GetDefaultVersionResponse) XXX_Size() int {
return xxx_messageInfo_GetDefaultVersionResponse.Size(m)
}
func (m *GetDefaultVersionResponse) XXX_DiscardUnknown() {
xxx_messageInfo_GetDefaultVersionResponse.DiscardUnknown(m)
}
var xxx_messageInfo_GetDefaultVersionResponse proto.InternalMessageInfo
func (m *GetDefaultVersionResponse) GetVersion() string {
if m != nil && m.Version != nil {
return *m.Version
}
return ""
}
type GetNumInstancesRequest struct {
Module *string `protobuf:"bytes,1,opt,name=module" json:"module,omitempty"`
Version *string `protobuf:"bytes,2,opt,name=version" json:"version,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetNumInstancesRequest) Reset() { *m = GetNumInstancesRequest{} }
func (m *GetNumInstancesRequest) String() string { return proto.CompactTextString(m) }
func (*GetNumInstancesRequest) ProtoMessage() {}
func (*GetNumInstancesRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_modules_service_9cd3bffe4e91c59a, []int{7}
}
func (m *GetNumInstancesRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetNumInstancesRequest.Unmarshal(m, b)
}
func (m *GetNumInstancesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetNumInstancesRequest.Marshal(b, m, deterministic)
}
func (dst *GetNumInstancesRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetNumInstancesRequest.Merge(dst, src)
}
func (m *GetNumInstancesRequest) XXX_Size() int {
return xxx_messageInfo_GetNumInstancesRequest.Size(m)
}
func (m *GetNumInstancesRequest) XXX_DiscardUnknown() {
xxx_messageInfo_GetNumInstancesRequest.DiscardUnknown(m)
}
var xxx_messageInfo_GetNumInstancesRequest proto.InternalMessageInfo
func (m *GetNumInstancesRequest) GetModule() string {
if m != nil && m.Module != nil {
return *m.Module
}
return ""
}
func (m *GetNumInstancesRequest) GetVersion() string {
if m != nil && m.Version != nil {
return *m.Version
}
return ""
}
type GetNumInstancesResponse struct {
Instances *int64 `protobuf:"varint,1,req,name=instances" json:"instances,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetNumInstancesResponse) Reset() { *m = GetNumInstancesResponse{} }
func (m *GetNumInstancesResponse) String() string { return proto.CompactTextString(m) }
func (*GetNumInstancesResponse) ProtoMessage() {}
func (*GetNumInstancesResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_modules_service_9cd3bffe4e91c59a, []int{8}
}
func (m *GetNumInstancesResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetNumInstancesResponse.Unmarshal(m, b)
}
func (m *GetNumInstancesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetNumInstancesResponse.Marshal(b, m, deterministic)
}
func (dst *GetNumInstancesResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetNumInstancesResponse.Merge(dst, src)
}
func (m *GetNumInstancesResponse) XXX_Size() int {
return xxx_messageInfo_GetNumInstancesResponse.Size(m)
}
func (m *GetNumInstancesResponse) XXX_DiscardUnknown() {
xxx_messageInfo_GetNumInstancesResponse.DiscardUnknown(m)
}
var xxx_messageInfo_GetNumInstancesResponse proto.InternalMessageInfo
func (m *GetNumInstancesResponse) GetInstances() int64 {
if m != nil && m.Instances != nil {
return *m.Instances
}
return 0
}
type SetNumInstancesRequest struct {
Module *string `protobuf:"bytes,1,opt,name=module" json:"module,omitempty"`
Version *string `protobuf:"bytes,2,opt,name=version" json:"version,omitempty"`
Instances *int64 `protobuf:"varint,3,req,name=instances" json:"instances,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *SetNumInstancesRequest) Reset() { *m = SetNumInstancesRequest{} }
func (m *SetNumInstancesRequest) String() string { return proto.CompactTextString(m) }
func (*SetNumInstancesRequest) ProtoMessage() {}
func (*SetNumInstancesRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_modules_service_9cd3bffe4e91c59a, []int{9}
}
func (m *SetNumInstancesRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SetNumInstancesRequest.Unmarshal(m, b)
}
func (m *SetNumInstancesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_SetNumInstancesRequest.Marshal(b, m, deterministic)
}
func (dst *SetNumInstancesRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_SetNumInstancesRequest.Merge(dst, src)
}
func (m *SetNumInstancesRequest) XXX_Size() int {
return xxx_messageInfo_SetNumInstancesRequest.Size(m)
}
func (m *SetNumInstancesRequest) XXX_DiscardUnknown() {
xxx_messageInfo_SetNumInstancesRequest.DiscardUnknown(m)
}
var xxx_messageInfo_SetNumInstancesRequest proto.InternalMessageInfo
func (m *SetNumInstancesRequest) GetModule() string {
if m != nil && m.Module != nil {
return *m.Module
}
return ""
}
func (m *SetNumInstancesRequest) GetVersion() string {
if m != nil && m.Version != nil {
return *m.Version
}
return ""
}
func (m *SetNumInstancesRequest) GetInstances() int64 {
if m != nil && m.Instances != nil {
return *m.Instances
}
return 0
}
type SetNumInstancesResponse struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *SetNumInstancesResponse) Reset() { *m = SetNumInstancesResponse{} }
func (m *SetNumInstancesResponse) String() string { return proto.CompactTextString(m) }
func (*SetNumInstancesResponse) ProtoMessage() {}
func (*SetNumInstancesResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_modules_service_9cd3bffe4e91c59a, []int{10}
}
func (m *SetNumInstancesResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SetNumInstancesResponse.Unmarshal(m, b)
}
func (m *SetNumInstancesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_SetNumInstancesResponse.Marshal(b, m, deterministic)
}
func (dst *SetNumInstancesResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_SetNumInstancesResponse.Merge(dst, src)
}
func (m *SetNumInstancesResponse) XXX_Size() int {
return xxx_messageInfo_SetNumInstancesResponse.Size(m)
}
func (m *SetNumInstancesResponse) XXX_DiscardUnknown() {
xxx_messageInfo_SetNumInstancesResponse.DiscardUnknown(m)
}
var xxx_messageInfo_SetNumInstancesResponse proto.InternalMessageInfo
type StartModuleRequest struct {
Module *string `protobuf:"bytes,1,req,name=module" json:"module,omitempty"`
Version *string `protobuf:"bytes,2,req,name=version" json:"version,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *StartModuleRequest) Reset() { *m = StartModuleRequest{} }
func (m *StartModuleRequest) String() string { return proto.CompactTextString(m) }
func (*StartModuleRequest) ProtoMessage() {}
func (*StartModuleRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_modules_service_9cd3bffe4e91c59a, []int{11}
}
func (m *StartModuleRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_StartModuleRequest.Unmarshal(m, b)
}
func (m *StartModuleRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_StartModuleRequest.Marshal(b, m, deterministic)
}
func (dst *StartModuleRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_StartModuleRequest.Merge(dst, src)
}
func (m *StartModuleRequest) XXX_Size() int {
return xxx_messageInfo_StartModuleRequest.Size(m)
}
func (m *StartModuleRequest) XXX_DiscardUnknown() {
xxx_messageInfo_StartModuleRequest.DiscardUnknown(m)
}
var xxx_messageInfo_StartModuleRequest proto.InternalMessageInfo
func (m *StartModuleRequest) GetModule() string {
if m != nil && m.Module != nil {
return *m.Module
}
return ""
}
func (m *StartModuleRequest) GetVersion() string {
if m != nil && m.Version != nil {
return *m.Version
}
return ""
}
type StartModuleResponse struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *StartModuleResponse) Reset() { *m = StartModuleResponse{} }
func (m *StartModuleResponse) String() string { return proto.CompactTextString(m) }
func (*StartModuleResponse) ProtoMessage() {}
func (*StartModuleResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_modules_service_9cd3bffe4e91c59a, []int{12}
}
func (m *StartModuleResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_StartModuleResponse.Unmarshal(m, b)
}
func (m *StartModuleResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_StartModuleResponse.Marshal(b, m, deterministic)
}
func (dst *StartModuleResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_StartModuleResponse.Merge(dst, src)
}
func (m *StartModuleResponse) XXX_Size() int {
return xxx_messageInfo_StartModuleResponse.Size(m)
}
func (m *StartModuleResponse) XXX_DiscardUnknown() {
xxx_messageInfo_StartModuleResponse.DiscardUnknown(m)
}
var xxx_messageInfo_StartModuleResponse proto.InternalMessageInfo
type StopModuleRequest struct {
Module *string `protobuf:"bytes,1,opt,name=module" json:"module,omitempty"`
Version *string `protobuf:"bytes,2,opt,name=version" json:"version,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *StopModuleRequest) Reset() { *m = StopModuleRequest{} }
func (m *StopModuleRequest) String() string { return proto.CompactTextString(m) }
func (*StopModuleRequest) ProtoMessage() {}
func (*StopModuleRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_modules_service_9cd3bffe4e91c59a, []int{13}
}
func (m *StopModuleRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_StopModuleRequest.Unmarshal(m, b)
}
func (m *StopModuleRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_StopModuleRequest.Marshal(b, m, deterministic)
}
func (dst *StopModuleRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_StopModuleRequest.Merge(dst, src)
}
func (m *StopModuleRequest) XXX_Size() int {
return xxx_messageInfo_StopModuleRequest.Size(m)
}
func (m *StopModuleRequest) XXX_DiscardUnknown() {
xxx_messageInfo_StopModuleRequest.DiscardUnknown(m)
}
var xxx_messageInfo_StopModuleRequest proto.InternalMessageInfo
func (m *StopModuleRequest) GetModule() string {
if m != nil && m.Module != nil {
return *m.Module
}
return ""
}
func (m *StopModuleRequest) GetVersion() string {
if m != nil && m.Version != nil {
return *m.Version
}
return ""
}
type StopModuleResponse struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *StopModuleResponse) Reset() { *m = StopModuleResponse{} }
func (m *StopModuleResponse) String() string { return proto.CompactTextString(m) }
func (*StopModuleResponse) ProtoMessage() {}
func (*StopModuleResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_modules_service_9cd3bffe4e91c59a, []int{14}
}
func (m *StopModuleResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_StopModuleResponse.Unmarshal(m, b)
}
func (m *StopModuleResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_StopModuleResponse.Marshal(b, m, deterministic)
}
func (dst *StopModuleResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_StopModuleResponse.Merge(dst, src)
}
func (m *StopModuleResponse) XXX_Size() int {
return xxx_messageInfo_StopModuleResponse.Size(m)
}
func (m *StopModuleResponse) XXX_DiscardUnknown() {
xxx_messageInfo_StopModuleResponse.DiscardUnknown(m)
}
var xxx_messageInfo_StopModuleResponse proto.InternalMessageInfo
type GetHostnameRequest struct {
Module *string `protobuf:"bytes,1,opt,name=module" json:"module,omitempty"`
Version *string `protobuf:"bytes,2,opt,name=version" json:"version,omitempty"`
Instance *string `protobuf:"bytes,3,opt,name=instance" json:"instance,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetHostnameRequest) Reset() { *m = GetHostnameRequest{} }
func (m *GetHostnameRequest) String() string { return proto.CompactTextString(m) }
func (*GetHostnameRequest) ProtoMessage() {}
func (*GetHostnameRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_modules_service_9cd3bffe4e91c59a, []int{15}
}
func (m *GetHostnameRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetHostnameRequest.Unmarshal(m, b)
}
func (m *GetHostnameRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetHostnameRequest.Marshal(b, m, deterministic)
}
func (dst *GetHostnameRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetHostnameRequest.Merge(dst, src)
}
func (m *GetHostnameRequest) XXX_Size() int {
return xxx_messageInfo_GetHostnameRequest.Size(m)
}
func (m *GetHostnameRequest) XXX_DiscardUnknown() {
xxx_messageInfo_GetHostnameRequest.DiscardUnknown(m)
}
var xxx_messageInfo_GetHostnameRequest proto.InternalMessageInfo
func (m *GetHostnameRequest) GetModule() string {
if m != nil && m.Module != nil {
return *m.Module
}
return ""
}
func (m *GetHostnameRequest) GetVersion() string {
if m != nil && m.Version != nil {
return *m.Version
}
return ""
}
func (m *GetHostnameRequest) GetInstance() string {
if m != nil && m.Instance != nil {
return *m.Instance
}
return ""
}
type GetHostnameResponse struct {
Hostname *string `protobuf:"bytes,1,req,name=hostname" json:"hostname,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetHostnameResponse) Reset() { *m = GetHostnameResponse{} }
func (m *GetHostnameResponse) String() string { return proto.CompactTextString(m) }
func (*GetHostnameResponse) ProtoMessage() {}
func (*GetHostnameResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_modules_service_9cd3bffe4e91c59a, []int{16}
}
func (m *GetHostnameResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetHostnameResponse.Unmarshal(m, b)
}
func (m *GetHostnameResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetHostnameResponse.Marshal(b, m, deterministic)
}
func (dst *GetHostnameResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetHostnameResponse.Merge(dst, src)
}
func (m *GetHostnameResponse) XXX_Size() int {
return xxx_messageInfo_GetHostnameResponse.Size(m)
}
func (m *GetHostnameResponse) XXX_DiscardUnknown() {
xxx_messageInfo_GetHostnameResponse.DiscardUnknown(m)
}
var xxx_messageInfo_GetHostnameResponse proto.InternalMessageInfo
func (m *GetHostnameResponse) GetHostname() string {
if m != nil && m.Hostname != nil {
return *m.Hostname
}
return ""
}
func init() {
proto.RegisterType((*ModulesServiceError)(nil), "appengine.ModulesServiceError")
proto.RegisterType((*GetModulesRequest)(nil), "appengine.GetModulesRequest")
proto.RegisterType((*GetModulesResponse)(nil), "appengine.GetModulesResponse")
proto.RegisterType((*GetVersionsRequest)(nil), "appengine.GetVersionsRequest")
proto.RegisterType((*GetVersionsResponse)(nil), "appengine.GetVersionsResponse")
proto.RegisterType((*GetDefaultVersionRequest)(nil), "appengine.GetDefaultVersionRequest")
proto.RegisterType((*GetDefaultVersionResponse)(nil), "appengine.GetDefaultVersionResponse")
proto.RegisterType((*GetNumInstancesRequest)(nil), "appengine.GetNumInstancesRequest")
proto.RegisterType((*GetNumInstancesResponse)(nil), "appengine.GetNumInstancesResponse")
proto.RegisterType((*SetNumInstancesRequest)(nil), "appengine.SetNumInstancesRequest")
proto.RegisterType((*SetNumInstancesResponse)(nil), "appengine.SetNumInstancesResponse")
proto.RegisterType((*StartModuleRequest)(nil), "appengine.StartModuleRequest")
proto.RegisterType((*StartModuleResponse)(nil), "appengine.StartModuleResponse")
proto.RegisterType((*StopModuleRequest)(nil), "appengine.StopModuleRequest")
proto.RegisterType((*StopModuleResponse)(nil), "appengine.StopModuleResponse")
proto.RegisterType((*GetHostnameRequest)(nil), "appengine.GetHostnameRequest")
proto.RegisterType((*GetHostnameResponse)(nil), "appengine.GetHostnameResponse")
}
func init() {
proto.RegisterFile("google.golang.org/appengine/internal/modules/modules_service.proto", fileDescriptor_modules_service_9cd3bffe4e91c59a)
}
var fileDescriptor_modules_service_9cd3bffe4e91c59a = []byte{
// 457 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xc1, 0x6f, 0xd3, 0x30,
0x14, 0xc6, 0x69, 0x02, 0xdb, 0xf2, 0x0e, 0x90, 0x3a, 0x5b, 0xd7, 0x4d, 0x1c, 0x50, 0x4e, 0x1c,
0x50, 0x2b, 0x90, 0x10, 0xe7, 0xae, 0x35, 0x25, 0xb0, 0xa5, 0x28, 0xce, 0x2a, 0xc4, 0xa5, 0x0a,
0xdb, 0x23, 0x8b, 0x94, 0xda, 0xc1, 0x76, 0x77, 0xe4, 0xbf, 0xe0, 0xff, 0x45, 0x4b, 0xed, 0xb6,
0x81, 0x4e, 0x45, 0x68, 0xa7, 0xe4, 0x7d, 0xfe, 0xfc, 0x7b, 0x9f, 0x5f, 0xac, 0xc0, 0x59, 0x2e,
0x44, 0x5e, 0x62, 0x2f, 0x17, 0x65, 0xc6, 0xf3, 0x9e, 0x90, 0x79, 0x3f, 0xab, 0x2a, 0xe4, 0x79,
0xc1, 0xb1, 0x5f, 0x70, 0x8d, 0x92, 0x67, 0x65, 0x7f, 0x2e, 0xae, 0x17, 0x25, 0x2a, 0xfb, 0x9c,
0x29, 0x94, 0xb7, 0xc5, 0x15, 0xf6, 0x2a, 0x29, 0xb4, 0x20, 0xde, 0x6a, 0x47, 0xf8, 0xab, 0x05,
0xc1, 0xc5, 0xd2, 0xc4, 0x96, 0x1e, 0x2a, 0xa5, 0x90, 0xe1, 0x4f, 0xf0, 0xea, 0x97, 0xa1, 0xb8,
0x46, 0xb2, 0x07, 0xce, 0xe4, 0x93, 0xff, 0x88, 0x10, 0x78, 0x1a, 0xc5, 0xd3, 0xc1, 0x79, 0x34,
0x9a, 0x5d, 0x4c, 0x46, 0x97, 0xe7, 0xd4, 0x6f, 0x91, 0x00, 0x9e, 0x59, 0x6d, 0x4a, 0x13, 0x16,
0x4d, 0x62, 0xdf, 0x21, 0x47, 0xd0, 0xb6, 0x62, 0x14, 0xb3, 0x74, 0x10, 0x0f, 0x29, 0xf3, 0xdd,
0x3b, 0x6f, 0x9a, 0x0c, 0x62, 0x16, 0xd1, 0x38, 0x9d, 0xd1, 0x24, 0x99, 0x24, 0xfe, 0x63, 0x72,
0x08, 0xfe, 0x65, 0x4c, 0xbf, 0x7c, 0xa6, 0xc3, 0x94, 0x8e, 0x66, 0x2c, 0x1d, 0xa4, 0xd4, 0x7f,
0x12, 0x06, 0xd0, 0x1e, 0xa3, 0x36, 0xc9, 0x12, 0xfc, 0xb1, 0x40, 0xa5, 0xc3, 0x57, 0x40, 0x36,
0x45, 0x55, 0x09, 0xae, 0x90, 0x74, 0x60, 0x6f, 0x79, 0xcc, 0x6e, 0xeb, 0x85, 0xfb, 0xd2, 0x4b,
0x4c, 0x65, 0xdc, 0x53, 0x94, 0xaa, 0x10, 0xdc, 0x32, 0x1a, 0xee, 0xd6, 0x86, 0xbb, 0x0f, 0x41,
0xc3, 0x6d, 0xe0, 0x5d, 0xd8, 0xbf, 0x5d, 0x6a, 0x86, 0x6e, 0xcb, 0xf0, 0x0d, 0x74, 0xc7, 0xa8,
0x47, 0xf8, 0x3d, 0x5b, 0x94, 0x76, 0xdf, 0xae, 0x26, 0x6f, 0xe1, 0x64, 0xcb, 0x9e, 0x6d, 0xad,
0x9c, 0xcd, 0x56, 0x1f, 0xa1, 0x33, 0x46, 0x1d, 0x2f, 0xe6, 0x11, 0x57, 0x3a, 0xe3, 0x57, 0xb8,
0xeb, 0x34, 0x9b, 0x2c, 0xa7, 0x5e, 0x58, 0xb1, 0xde, 0xc1, 0xf1, 0x5f, 0x2c, 0x13, 0xe0, 0x39,
0x78, 0x85, 0x15, 0xeb, 0x08, 0x6e, 0xb2, 0x16, 0xc2, 0x1b, 0xe8, 0xb0, 0x07, 0x0a, 0xd1, 0xec,
0xe4, 0xfe, 0xd9, 0xe9, 0x04, 0x8e, 0xd9, 0xf6, 0x88, 0xe1, 0x7b, 0x20, 0x4c, 0x67, 0xd2, 0xdc,
0x81, 0x6d, 0x01, 0x9c, 0xfb, 0x02, 0x34, 0x26, 0x7a, 0x04, 0x41, 0x83, 0x63, 0xf0, 0x14, 0xda,
0x4c, 0x8b, 0xea, 0x7e, 0xfa, 0xbf, 0xcd, 0xf8, 0xf0, 0x2e, 0xe5, 0x1a, 0x63, 0xe0, 0xdf, 0xea,
0xfb, 0xf8, 0x41, 0x28, 0xcd, 0xb3, 0xf9, 0xff, 0xd3, 0xc9, 0x29, 0x1c, 0xd8, 0x59, 0x75, 0xdd,
0x7a, 0x69, 0x55, 0x87, 0xaf, 0xeb, 0x5b, 0xbc, 0xee, 0x61, 0xbe, 0xec, 0x29, 0x1c, 0xdc, 0x18,
0xcd, 0x8c, 0x68, 0x55, 0x9f, 0x79, 0x5f, 0xf7, 0xcd, 0x5f, 0xe2, 0x77, 0x00, 0x00, 0x00, 0xff,
0xff, 0x6e, 0xbc, 0xe0, 0x61, 0x5c, 0x04, 0x00, 0x00,
}

View File

@ -1,80 +0,0 @@
syntax = "proto2";
option go_package = "modules";
package appengine;
message ModulesServiceError {
enum ErrorCode {
OK = 0;
INVALID_MODULE = 1;
INVALID_VERSION = 2;
INVALID_INSTANCES = 3;
TRANSIENT_ERROR = 4;
UNEXPECTED_STATE = 5;
}
}
message GetModulesRequest {
}
message GetModulesResponse {
repeated string module = 1;
}
message GetVersionsRequest {
optional string module = 1;
}
message GetVersionsResponse {
repeated string version = 1;
}
message GetDefaultVersionRequest {
optional string module = 1;
}
message GetDefaultVersionResponse {
required string version = 1;
}
message GetNumInstancesRequest {
optional string module = 1;
optional string version = 2;
}
message GetNumInstancesResponse {
required int64 instances = 1;
}
message SetNumInstancesRequest {
optional string module = 1;
optional string version = 2;
required int64 instances = 3;
}
message SetNumInstancesResponse {}
message StartModuleRequest {
required string module = 1;
required string version = 2;
}
message StartModuleResponse {}
message StopModuleRequest {
optional string module = 1;
optional string version = 2;
}
message StopModuleResponse {}
message GetHostnameRequest {
optional string module = 1;
optional string version = 2;
optional string instance = 3;
}
message GetHostnameResponse {
required string hostname = 1;
}

View File

@ -1,58 +0,0 @@
// Copyright 2014 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// +build !appengine
package internal
import (
"sync"
"testing"
"time"
netcontext "golang.org/x/net/context"
basepb "google.golang.org/appengine/internal/base"
)
func TestDialLimit(t *testing.T) {
// Fill up semaphore with false acquisitions to permit only two TCP connections at a time.
// We don't replace limitSem because that results in a data race when net/http lazily closes connections.
nFake := cap(limitSem) - 2
for i := 0; i < nFake; i++ {
limitSem <- 1
}
defer func() {
for i := 0; i < nFake; i++ {
<-limitSem
}
}()
f, c, cleanup := setup() // setup is in api_test.go
defer cleanup()
f.hang = make(chan int)
// If we make two RunSlowly RPCs (which will wait for f.hang to be strobed),
// then the simple Non200 RPC should hang.
var wg sync.WaitGroup
wg.Add(2)
for i := 0; i < 2; i++ {
go func() {
defer wg.Done()
Call(toContext(c), "errors", "RunSlowly", &basepb.VoidProto{}, &basepb.VoidProto{})
}()
}
time.Sleep(50 * time.Millisecond) // let those two RPCs start
ctx, _ := netcontext.WithTimeout(toContext(c), 50*time.Millisecond)
err := Call(ctx, "errors", "Non200", &basepb.VoidProto{}, &basepb.VoidProto{})
if err != errTimeout {
t.Errorf("Non200 RPC returned with err %v, want errTimeout", err)
}
// Drain the two RunSlowly calls.
f.hang <- 1
f.hang <- 1
wg.Wait()
}

View File

@ -1,40 +0,0 @@
#!/bin/bash -e
#
# This script rebuilds the generated code for the protocol buffers.
# To run this you will need protoc and goprotobuf installed;
# see https://github.com/golang/protobuf for instructions.
PKG=google.golang.org/appengine
function die() {
echo 1>&2 $*
exit 1
}
# Sanity check that the right tools are accessible.
for tool in go protoc protoc-gen-go; do
q=$(which $tool) || die "didn't find $tool"
echo 1>&2 "$tool: $q"
done
echo -n 1>&2 "finding package dir... "
pkgdir=$(go list -f '{{.Dir}}' $PKG)
echo 1>&2 $pkgdir
base=$(echo $pkgdir | sed "s,/$PKG\$,,")
echo 1>&2 "base: $base"
cd $base
# Run protoc once per package.
for dir in $(find $PKG/internal -name '*.proto' | xargs dirname | sort | uniq); do
echo 1>&2 "* $dir"
protoc --go_out=. $dir/*.proto
done
for f in $(find $PKG/internal -name '*.pb.go'); do
# Remove proto.RegisterEnum calls.
# These cause duplicate registration panics when these packages
# are used on classic App Engine. proto.RegisterEnum only affects
# parsing the text format; we don't care about that.
# https://code.google.com/p/googleappengine/issues/detail?id=11670#c17
sed -i '/proto.RegisterEnum/d' $f
done

View File

@ -1,44 +0,0 @@
syntax = "proto2";
option go_package = "remote_api";
package remote_api;
message Request {
required string service_name = 2;
required string method = 3;
required bytes request = 4;
optional string request_id = 5;
}
message ApplicationError {
required int32 code = 1;
required string detail = 2;
}
message RpcError {
enum ErrorCode {
UNKNOWN = 0;
CALL_NOT_FOUND = 1;
PARSE_ERROR = 2;
SECURITY_VIOLATION = 3;
OVER_QUOTA = 4;
REQUEST_TOO_LARGE = 5;
CAPABILITY_DISABLED = 6;
FEATURE_DISABLED = 7;
BAD_REQUEST = 8;
RESPONSE_TOO_LARGE = 9;
CANCELLED = 10;
REPLAY_ERROR = 11;
DEADLINE_EXCEEDED = 12;
}
required int32 code = 1;
optional string detail = 2;
}
message Response {
optional bytes response = 1;
optional bytes exception = 2;
optional ApplicationError application_error = 3;
optional bytes java_exception = 4;
optional RpcError rpc_error = 5;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,394 +0,0 @@
syntax = "proto2";
option go_package = "search";
package search;
message Scope {
enum Type {
USER_BY_CANONICAL_ID = 1;
USER_BY_EMAIL = 2;
GROUP_BY_CANONICAL_ID = 3;
GROUP_BY_EMAIL = 4;
GROUP_BY_DOMAIN = 5;
ALL_USERS = 6;
ALL_AUTHENTICATED_USERS = 7;
}
optional Type type = 1;
optional string value = 2;
}
message Entry {
enum Permission {
READ = 1;
WRITE = 2;
FULL_CONTROL = 3;
}
optional Scope scope = 1;
optional Permission permission = 2;
optional string display_name = 3;
}
message AccessControlList {
optional string owner = 1;
repeated Entry entries = 2;
}
message FieldValue {
enum ContentType {
TEXT = 0;
HTML = 1;
ATOM = 2;
DATE = 3;
NUMBER = 4;
GEO = 5;
}
optional ContentType type = 1 [default = TEXT];
optional string language = 2 [default = "en"];
optional string string_value = 3;
optional group Geo = 4 {
required double lat = 5;
required double lng = 6;
}
}
message Field {
required string name = 1;
required FieldValue value = 2;
}
message FieldTypes {
required string name = 1;
repeated FieldValue.ContentType type = 2;
}
message IndexShardSettings {
repeated int32 prev_num_shards = 1;
required int32 num_shards = 2 [default=1];
repeated int32 prev_num_shards_search_false = 3;
optional string local_replica = 4 [default = ""];
}
message FacetValue {
enum ContentType {
ATOM = 2;
NUMBER = 4;
}
optional ContentType type = 1 [default = ATOM];
optional string string_value = 3;
}
message Facet {
required string name = 1;
required FacetValue value = 2;
}
message DocumentMetadata {
optional int64 version = 1;
optional int64 committed_st_version = 2;
}
message Document {
optional string id = 1;
optional string language = 2 [default = "en"];
repeated Field field = 3;
optional int32 order_id = 4;
optional OrderIdSource order_id_source = 6 [default = SUPPLIED];
enum OrderIdSource {
DEFAULTED = 0;
SUPPLIED = 1;
}
enum Storage {
DISK = 0;
}
optional Storage storage = 5 [default = DISK];
repeated Facet facet = 8;
}
message SearchServiceError {
enum ErrorCode {
OK = 0;
INVALID_REQUEST = 1;
TRANSIENT_ERROR = 2;
INTERNAL_ERROR = 3;
PERMISSION_DENIED = 4;
TIMEOUT = 5;
CONCURRENT_TRANSACTION = 6;
}
}
message RequestStatus {
required SearchServiceError.ErrorCode code = 1;
optional string error_detail = 2;
optional int32 canonical_code = 3;
}
message IndexSpec {
required string name = 1;
enum Consistency {
GLOBAL = 0;
PER_DOCUMENT = 1;
}
optional Consistency consistency = 2 [default = PER_DOCUMENT];
optional string namespace = 3;
optional int32 version = 4;
enum Source {
SEARCH = 0;
DATASTORE = 1;
CLOUD_STORAGE = 2;
}
optional Source source = 5 [default = SEARCH];
enum Mode {
PRIORITY = 0;
BACKGROUND = 1;
}
optional Mode mode = 6 [default = PRIORITY];
}
message IndexMetadata {
required IndexSpec index_spec = 1;
repeated FieldTypes field = 2;
message Storage {
optional int64 amount_used = 1;
optional int64 limit = 2;
}
optional Storage storage = 3;
}
message IndexDocumentParams {
repeated Document document = 1;
enum Freshness {
SYNCHRONOUSLY = 0;
WHEN_CONVENIENT = 1;
}
optional Freshness freshness = 2 [default = SYNCHRONOUSLY, deprecated=true];
required IndexSpec index_spec = 3;
}
message IndexDocumentRequest {
required IndexDocumentParams params = 1;
optional bytes app_id = 3;
}
message IndexDocumentResponse {
repeated RequestStatus status = 1;
repeated string doc_id = 2;
}
message DeleteDocumentParams {
repeated string doc_id = 1;
required IndexSpec index_spec = 2;
}
message DeleteDocumentRequest {
required DeleteDocumentParams params = 1;
optional bytes app_id = 3;
}
message DeleteDocumentResponse {
repeated RequestStatus status = 1;
}
message ListDocumentsParams {
required IndexSpec index_spec = 1;
optional string start_doc_id = 2;
optional bool include_start_doc = 3 [default = true];
optional int32 limit = 4 [default = 100];
optional bool keys_only = 5;
}
message ListDocumentsRequest {
required ListDocumentsParams params = 1;
optional bytes app_id = 2;
}
message ListDocumentsResponse {
required RequestStatus status = 1;
repeated Document document = 2;
}
message ListIndexesParams {
optional bool fetch_schema = 1;
optional int32 limit = 2 [default = 20];
optional string namespace = 3;
optional string start_index_name = 4;
optional bool include_start_index = 5 [default = true];
optional string index_name_prefix = 6;
optional int32 offset = 7;
optional IndexSpec.Source source = 8 [default = SEARCH];
}
message ListIndexesRequest {
required ListIndexesParams params = 1;
optional bytes app_id = 3;
}
message ListIndexesResponse {
required RequestStatus status = 1;
repeated IndexMetadata index_metadata = 2;
}
message DeleteSchemaParams {
optional IndexSpec.Source source = 1 [default = SEARCH];
repeated IndexSpec index_spec = 2;
}
message DeleteSchemaRequest {
required DeleteSchemaParams params = 1;
optional bytes app_id = 3;
}
message DeleteSchemaResponse {
repeated RequestStatus status = 1;
}
message SortSpec {
required string sort_expression = 1;
optional bool sort_descending = 2 [default = true];
optional string default_value_text = 4;
optional double default_value_numeric = 5;
}
message ScorerSpec {
enum Scorer {
RESCORING_MATCH_SCORER = 0;
MATCH_SCORER = 2;
}
optional Scorer scorer = 1 [default = MATCH_SCORER];
optional int32 limit = 2 [default = 1000];
optional string match_scorer_parameters = 9;
}
message FieldSpec {
repeated string name = 1;
repeated group Expression = 2 {
required string name = 3;
required string expression = 4;
}
}
message FacetRange {
optional string name = 1;
optional string start = 2;
optional string end = 3;
}
message FacetRequestParam {
optional int32 value_limit = 1;
repeated FacetRange range = 2;
repeated string value_constraint = 3;
}
message FacetAutoDetectParam {
optional int32 value_limit = 1 [default = 10];
}
message FacetRequest {
required string name = 1;
optional FacetRequestParam params = 2;
}
message FacetRefinement {
required string name = 1;
optional string value = 2;
message Range {
optional string start = 1;
optional string end = 2;
}
optional Range range = 3;
}
message SearchParams {
required IndexSpec index_spec = 1;
required string query = 2;
optional string cursor = 4;
optional int32 offset = 11;
enum CursorType {
NONE = 0;
SINGLE = 1;
PER_RESULT = 2;
}
optional CursorType cursor_type = 5 [default = NONE];
optional int32 limit = 6 [default = 20];
optional int32 matched_count_accuracy = 7;
repeated SortSpec sort_spec = 8;
optional ScorerSpec scorer_spec = 9;
optional FieldSpec field_spec = 10;
optional bool keys_only = 12;
enum ParsingMode {
STRICT = 0;
RELAXED = 1;
}
optional ParsingMode parsing_mode = 13 [default = STRICT];
optional int32 auto_discover_facet_count = 15 [default = 0];
repeated FacetRequest include_facet = 16;
repeated FacetRefinement facet_refinement = 17;
optional FacetAutoDetectParam facet_auto_detect_param = 18;
optional int32 facet_depth = 19 [default=1000];
}
message SearchRequest {
required SearchParams params = 1;
optional bytes app_id = 3;
}
message FacetResultValue {
required string name = 1;
required int32 count = 2;
required FacetRefinement refinement = 3;
}
message FacetResult {
required string name = 1;
repeated FacetResultValue value = 2;
}
message SearchResult {
required Document document = 1;
repeated Field expression = 4;
repeated double score = 2;
optional string cursor = 3;
}
message SearchResponse {
repeated SearchResult result = 1;
required int64 matched_count = 2;
required RequestStatus status = 3;
optional string cursor = 4;
repeated FacetResult facet_result = 5;
extensions 1000 to 9999;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,460 +0,0 @@
syntax = "proto2";
option go_package = "socket";
package appengine;
message RemoteSocketServiceError {
enum ErrorCode {
SYSTEM_ERROR = 1;
GAI_ERROR = 2;
FAILURE = 4;
PERMISSION_DENIED = 5;
INVALID_REQUEST = 6;
SOCKET_CLOSED = 7;
}
enum SystemError {
option allow_alias = true;
SYS_SUCCESS = 0;
SYS_EPERM = 1;
SYS_ENOENT = 2;
SYS_ESRCH = 3;
SYS_EINTR = 4;
SYS_EIO = 5;
SYS_ENXIO = 6;
SYS_E2BIG = 7;
SYS_ENOEXEC = 8;
SYS_EBADF = 9;
SYS_ECHILD = 10;
SYS_EAGAIN = 11;
SYS_EWOULDBLOCK = 11;
SYS_ENOMEM = 12;
SYS_EACCES = 13;
SYS_EFAULT = 14;
SYS_ENOTBLK = 15;
SYS_EBUSY = 16;
SYS_EEXIST = 17;
SYS_EXDEV = 18;
SYS_ENODEV = 19;
SYS_ENOTDIR = 20;
SYS_EISDIR = 21;
SYS_EINVAL = 22;
SYS_ENFILE = 23;
SYS_EMFILE = 24;
SYS_ENOTTY = 25;
SYS_ETXTBSY = 26;
SYS_EFBIG = 27;
SYS_ENOSPC = 28;
SYS_ESPIPE = 29;
SYS_EROFS = 30;
SYS_EMLINK = 31;
SYS_EPIPE = 32;
SYS_EDOM = 33;
SYS_ERANGE = 34;
SYS_EDEADLK = 35;
SYS_EDEADLOCK = 35;
SYS_ENAMETOOLONG = 36;
SYS_ENOLCK = 37;
SYS_ENOSYS = 38;
SYS_ENOTEMPTY = 39;
SYS_ELOOP = 40;
SYS_ENOMSG = 42;
SYS_EIDRM = 43;
SYS_ECHRNG = 44;
SYS_EL2NSYNC = 45;
SYS_EL3HLT = 46;
SYS_EL3RST = 47;
SYS_ELNRNG = 48;
SYS_EUNATCH = 49;
SYS_ENOCSI = 50;
SYS_EL2HLT = 51;
SYS_EBADE = 52;
SYS_EBADR = 53;
SYS_EXFULL = 54;
SYS_ENOANO = 55;
SYS_EBADRQC = 56;
SYS_EBADSLT = 57;
SYS_EBFONT = 59;
SYS_ENOSTR = 60;
SYS_ENODATA = 61;
SYS_ETIME = 62;
SYS_ENOSR = 63;
SYS_ENONET = 64;
SYS_ENOPKG = 65;
SYS_EREMOTE = 66;
SYS_ENOLINK = 67;
SYS_EADV = 68;
SYS_ESRMNT = 69;
SYS_ECOMM = 70;
SYS_EPROTO = 71;
SYS_EMULTIHOP = 72;
SYS_EDOTDOT = 73;
SYS_EBADMSG = 74;
SYS_EOVERFLOW = 75;
SYS_ENOTUNIQ = 76;
SYS_EBADFD = 77;
SYS_EREMCHG = 78;
SYS_ELIBACC = 79;
SYS_ELIBBAD = 80;
SYS_ELIBSCN = 81;
SYS_ELIBMAX = 82;
SYS_ELIBEXEC = 83;
SYS_EILSEQ = 84;
SYS_ERESTART = 85;
SYS_ESTRPIPE = 86;
SYS_EUSERS = 87;
SYS_ENOTSOCK = 88;
SYS_EDESTADDRREQ = 89;
SYS_EMSGSIZE = 90;
SYS_EPROTOTYPE = 91;
SYS_ENOPROTOOPT = 92;
SYS_EPROTONOSUPPORT = 93;
SYS_ESOCKTNOSUPPORT = 94;
SYS_EOPNOTSUPP = 95;
SYS_ENOTSUP = 95;
SYS_EPFNOSUPPORT = 96;
SYS_EAFNOSUPPORT = 97;
SYS_EADDRINUSE = 98;
SYS_EADDRNOTAVAIL = 99;
SYS_ENETDOWN = 100;
SYS_ENETUNREACH = 101;
SYS_ENETRESET = 102;
SYS_ECONNABORTED = 103;
SYS_ECONNRESET = 104;
SYS_ENOBUFS = 105;
SYS_EISCONN = 106;
SYS_ENOTCONN = 107;
SYS_ESHUTDOWN = 108;
SYS_ETOOMANYREFS = 109;
SYS_ETIMEDOUT = 110;
SYS_ECONNREFUSED = 111;
SYS_EHOSTDOWN = 112;
SYS_EHOSTUNREACH = 113;
SYS_EALREADY = 114;
SYS_EINPROGRESS = 115;
SYS_ESTALE = 116;
SYS_EUCLEAN = 117;
SYS_ENOTNAM = 118;
SYS_ENAVAIL = 119;
SYS_EISNAM = 120;
SYS_EREMOTEIO = 121;
SYS_EDQUOT = 122;
SYS_ENOMEDIUM = 123;
SYS_EMEDIUMTYPE = 124;
SYS_ECANCELED = 125;
SYS_ENOKEY = 126;
SYS_EKEYEXPIRED = 127;
SYS_EKEYREVOKED = 128;
SYS_EKEYREJECTED = 129;
SYS_EOWNERDEAD = 130;
SYS_ENOTRECOVERABLE = 131;
SYS_ERFKILL = 132;
}
optional int32 system_error = 1 [default=0];
optional string error_detail = 2;
}
message AddressPort {
required int32 port = 1;
optional bytes packed_address = 2;
optional string hostname_hint = 3;
}
message CreateSocketRequest {
enum SocketFamily {
IPv4 = 1;
IPv6 = 2;
}
enum SocketProtocol {
TCP = 1;
UDP = 2;
}
required SocketFamily family = 1;
required SocketProtocol protocol = 2;
repeated SocketOption socket_options = 3;
optional AddressPort proxy_external_ip = 4;
optional int32 listen_backlog = 5 [default=0];
optional AddressPort remote_ip = 6;
optional string app_id = 9;
optional int64 project_id = 10;
}
message CreateSocketReply {
optional string socket_descriptor = 1;
optional AddressPort server_address = 3;
optional AddressPort proxy_external_ip = 4;
extensions 1000 to max;
}
message BindRequest {
required string socket_descriptor = 1;
required AddressPort proxy_external_ip = 2;
}
message BindReply {
optional AddressPort proxy_external_ip = 1;
}
message GetSocketNameRequest {
required string socket_descriptor = 1;
}
message GetSocketNameReply {
optional AddressPort proxy_external_ip = 2;
}
message GetPeerNameRequest {
required string socket_descriptor = 1;
}
message GetPeerNameReply {
optional AddressPort peer_ip = 2;
}
message SocketOption {
enum SocketOptionLevel {
SOCKET_SOL_IP = 0;
SOCKET_SOL_SOCKET = 1;
SOCKET_SOL_TCP = 6;
SOCKET_SOL_UDP = 17;
}
enum SocketOptionName {
option allow_alias = true;
SOCKET_SO_DEBUG = 1;
SOCKET_SO_REUSEADDR = 2;
SOCKET_SO_TYPE = 3;
SOCKET_SO_ERROR = 4;
SOCKET_SO_DONTROUTE = 5;
SOCKET_SO_BROADCAST = 6;
SOCKET_SO_SNDBUF = 7;
SOCKET_SO_RCVBUF = 8;
SOCKET_SO_KEEPALIVE = 9;
SOCKET_SO_OOBINLINE = 10;
SOCKET_SO_LINGER = 13;
SOCKET_SO_RCVTIMEO = 20;
SOCKET_SO_SNDTIMEO = 21;
SOCKET_IP_TOS = 1;
SOCKET_IP_TTL = 2;
SOCKET_IP_HDRINCL = 3;
SOCKET_IP_OPTIONS = 4;
SOCKET_TCP_NODELAY = 1;
SOCKET_TCP_MAXSEG = 2;
SOCKET_TCP_CORK = 3;
SOCKET_TCP_KEEPIDLE = 4;
SOCKET_TCP_KEEPINTVL = 5;
SOCKET_TCP_KEEPCNT = 6;
SOCKET_TCP_SYNCNT = 7;
SOCKET_TCP_LINGER2 = 8;
SOCKET_TCP_DEFER_ACCEPT = 9;
SOCKET_TCP_WINDOW_CLAMP = 10;
SOCKET_TCP_INFO = 11;
SOCKET_TCP_QUICKACK = 12;
}
required SocketOptionLevel level = 1;
required SocketOptionName option = 2;
required bytes value = 3;
}
message SetSocketOptionsRequest {
required string socket_descriptor = 1;
repeated SocketOption options = 2;
}
message SetSocketOptionsReply {
}
message GetSocketOptionsRequest {
required string socket_descriptor = 1;
repeated SocketOption options = 2;
}
message GetSocketOptionsReply {
repeated SocketOption options = 2;
}
message ConnectRequest {
required string socket_descriptor = 1;
required AddressPort remote_ip = 2;
optional double timeout_seconds = 3 [default=-1];
}
message ConnectReply {
optional AddressPort proxy_external_ip = 1;
extensions 1000 to max;
}
message ListenRequest {
required string socket_descriptor = 1;
required int32 backlog = 2;
}
message ListenReply {
}
message AcceptRequest {
required string socket_descriptor = 1;
optional double timeout_seconds = 2 [default=-1];
}
message AcceptReply {
optional bytes new_socket_descriptor = 2;
optional AddressPort remote_address = 3;
}
message ShutDownRequest {
enum How {
SOCKET_SHUT_RD = 1;
SOCKET_SHUT_WR = 2;
SOCKET_SHUT_RDWR = 3;
}
required string socket_descriptor = 1;
required How how = 2;
required int64 send_offset = 3;
}
message ShutDownReply {
}
message CloseRequest {
required string socket_descriptor = 1;
optional int64 send_offset = 2 [default=-1];
}
message CloseReply {
}
message SendRequest {
required string socket_descriptor = 1;
required bytes data = 2 [ctype=CORD];
required int64 stream_offset = 3;
optional int32 flags = 4 [default=0];
optional AddressPort send_to = 5;
optional double timeout_seconds = 6 [default=-1];
}
message SendReply {
optional int32 data_sent = 1;
}
message ReceiveRequest {
enum Flags {
MSG_OOB = 1;
MSG_PEEK = 2;
}
required string socket_descriptor = 1;
required int32 data_size = 2;
optional int32 flags = 3 [default=0];
optional double timeout_seconds = 5 [default=-1];
}
message ReceiveReply {
optional int64 stream_offset = 2;
optional bytes data = 3 [ctype=CORD];
optional AddressPort received_from = 4;
optional int32 buffer_size = 5;
}
message PollEvent {
enum PollEventFlag {
SOCKET_POLLNONE = 0;
SOCKET_POLLIN = 1;
SOCKET_POLLPRI = 2;
SOCKET_POLLOUT = 4;
SOCKET_POLLERR = 8;
SOCKET_POLLHUP = 16;
SOCKET_POLLNVAL = 32;
SOCKET_POLLRDNORM = 64;
SOCKET_POLLRDBAND = 128;
SOCKET_POLLWRNORM = 256;
SOCKET_POLLWRBAND = 512;
SOCKET_POLLMSG = 1024;
SOCKET_POLLREMOVE = 4096;
SOCKET_POLLRDHUP = 8192;
};
required string socket_descriptor = 1;
required int32 requested_events = 2;
required int32 observed_events = 3;
}
message PollRequest {
repeated PollEvent events = 1;
optional double timeout_seconds = 2 [default=-1];
}
message PollReply {
repeated PollEvent events = 2;
}
message ResolveRequest {
required string name = 1;
repeated CreateSocketRequest.SocketFamily address_families = 2;
}
message ResolveReply {
enum ErrorCode {
SOCKET_EAI_ADDRFAMILY = 1;
SOCKET_EAI_AGAIN = 2;
SOCKET_EAI_BADFLAGS = 3;
SOCKET_EAI_FAIL = 4;
SOCKET_EAI_FAMILY = 5;
SOCKET_EAI_MEMORY = 6;
SOCKET_EAI_NODATA = 7;
SOCKET_EAI_NONAME = 8;
SOCKET_EAI_SERVICE = 9;
SOCKET_EAI_SOCKTYPE = 10;
SOCKET_EAI_SYSTEM = 11;
SOCKET_EAI_BADHINTS = 12;
SOCKET_EAI_PROTOCOL = 13;
SOCKET_EAI_OVERFLOW = 14;
SOCKET_EAI_MAX = 15;
};
repeated bytes packed_address = 2;
optional string canonical_name = 3;
repeated string aliases = 4;
}

View File

@ -1,362 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: google.golang.org/appengine/internal/system/system_service.proto
package system
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type SystemServiceError_ErrorCode int32
const (
SystemServiceError_OK SystemServiceError_ErrorCode = 0
SystemServiceError_INTERNAL_ERROR SystemServiceError_ErrorCode = 1
SystemServiceError_BACKEND_REQUIRED SystemServiceError_ErrorCode = 2
SystemServiceError_LIMIT_REACHED SystemServiceError_ErrorCode = 3
)
var SystemServiceError_ErrorCode_name = map[int32]string{
0: "OK",
1: "INTERNAL_ERROR",
2: "BACKEND_REQUIRED",
3: "LIMIT_REACHED",
}
var SystemServiceError_ErrorCode_value = map[string]int32{
"OK": 0,
"INTERNAL_ERROR": 1,
"BACKEND_REQUIRED": 2,
"LIMIT_REACHED": 3,
}
func (x SystemServiceError_ErrorCode) Enum() *SystemServiceError_ErrorCode {
p := new(SystemServiceError_ErrorCode)
*p = x
return p
}
func (x SystemServiceError_ErrorCode) String() string {
return proto.EnumName(SystemServiceError_ErrorCode_name, int32(x))
}
func (x *SystemServiceError_ErrorCode) UnmarshalJSON(data []byte) error {
value, err := proto.UnmarshalJSONEnum(SystemServiceError_ErrorCode_value, data, "SystemServiceError_ErrorCode")
if err != nil {
return err
}
*x = SystemServiceError_ErrorCode(value)
return nil
}
func (SystemServiceError_ErrorCode) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_system_service_ccf41ec210fc59eb, []int{0, 0}
}
type SystemServiceError struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *SystemServiceError) Reset() { *m = SystemServiceError{} }
func (m *SystemServiceError) String() string { return proto.CompactTextString(m) }
func (*SystemServiceError) ProtoMessage() {}
func (*SystemServiceError) Descriptor() ([]byte, []int) {
return fileDescriptor_system_service_ccf41ec210fc59eb, []int{0}
}
func (m *SystemServiceError) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SystemServiceError.Unmarshal(m, b)
}
func (m *SystemServiceError) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_SystemServiceError.Marshal(b, m, deterministic)
}
func (dst *SystemServiceError) XXX_Merge(src proto.Message) {
xxx_messageInfo_SystemServiceError.Merge(dst, src)
}
func (m *SystemServiceError) XXX_Size() int {
return xxx_messageInfo_SystemServiceError.Size(m)
}
func (m *SystemServiceError) XXX_DiscardUnknown() {
xxx_messageInfo_SystemServiceError.DiscardUnknown(m)
}
var xxx_messageInfo_SystemServiceError proto.InternalMessageInfo
type SystemStat struct {
// Instaneous value of this stat.
Current *float64 `protobuf:"fixed64,1,opt,name=current" json:"current,omitempty"`
// Average over time, if this stat has an instaneous value.
Average1M *float64 `protobuf:"fixed64,3,opt,name=average1m" json:"average1m,omitempty"`
Average10M *float64 `protobuf:"fixed64,4,opt,name=average10m" json:"average10m,omitempty"`
// Total value, if the stat accumulates over time.
Total *float64 `protobuf:"fixed64,2,opt,name=total" json:"total,omitempty"`
// Rate over time, if this stat accumulates.
Rate1M *float64 `protobuf:"fixed64,5,opt,name=rate1m" json:"rate1m,omitempty"`
Rate10M *float64 `protobuf:"fixed64,6,opt,name=rate10m" json:"rate10m,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *SystemStat) Reset() { *m = SystemStat{} }
func (m *SystemStat) String() string { return proto.CompactTextString(m) }
func (*SystemStat) ProtoMessage() {}
func (*SystemStat) Descriptor() ([]byte, []int) {
return fileDescriptor_system_service_ccf41ec210fc59eb, []int{1}
}
func (m *SystemStat) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SystemStat.Unmarshal(m, b)
}
func (m *SystemStat) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_SystemStat.Marshal(b, m, deterministic)
}
func (dst *SystemStat) XXX_Merge(src proto.Message) {
xxx_messageInfo_SystemStat.Merge(dst, src)
}
func (m *SystemStat) XXX_Size() int {
return xxx_messageInfo_SystemStat.Size(m)
}
func (m *SystemStat) XXX_DiscardUnknown() {
xxx_messageInfo_SystemStat.DiscardUnknown(m)
}
var xxx_messageInfo_SystemStat proto.InternalMessageInfo
func (m *SystemStat) GetCurrent() float64 {
if m != nil && m.Current != nil {
return *m.Current
}
return 0
}
func (m *SystemStat) GetAverage1M() float64 {
if m != nil && m.Average1M != nil {
return *m.Average1M
}
return 0
}
func (m *SystemStat) GetAverage10M() float64 {
if m != nil && m.Average10M != nil {
return *m.Average10M
}
return 0
}
func (m *SystemStat) GetTotal() float64 {
if m != nil && m.Total != nil {
return *m.Total
}
return 0
}
func (m *SystemStat) GetRate1M() float64 {
if m != nil && m.Rate1M != nil {
return *m.Rate1M
}
return 0
}
func (m *SystemStat) GetRate10M() float64 {
if m != nil && m.Rate10M != nil {
return *m.Rate10M
}
return 0
}
type GetSystemStatsRequest struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetSystemStatsRequest) Reset() { *m = GetSystemStatsRequest{} }
func (m *GetSystemStatsRequest) String() string { return proto.CompactTextString(m) }
func (*GetSystemStatsRequest) ProtoMessage() {}
func (*GetSystemStatsRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_system_service_ccf41ec210fc59eb, []int{2}
}
func (m *GetSystemStatsRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetSystemStatsRequest.Unmarshal(m, b)
}
func (m *GetSystemStatsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetSystemStatsRequest.Marshal(b, m, deterministic)
}
func (dst *GetSystemStatsRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetSystemStatsRequest.Merge(dst, src)
}
func (m *GetSystemStatsRequest) XXX_Size() int {
return xxx_messageInfo_GetSystemStatsRequest.Size(m)
}
func (m *GetSystemStatsRequest) XXX_DiscardUnknown() {
xxx_messageInfo_GetSystemStatsRequest.DiscardUnknown(m)
}
var xxx_messageInfo_GetSystemStatsRequest proto.InternalMessageInfo
type GetSystemStatsResponse struct {
// CPU used by this instance, in mcycles.
Cpu *SystemStat `protobuf:"bytes,1,opt,name=cpu" json:"cpu,omitempty"`
// Physical memory (RAM) used by this instance, in megabytes.
Memory *SystemStat `protobuf:"bytes,2,opt,name=memory" json:"memory,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetSystemStatsResponse) Reset() { *m = GetSystemStatsResponse{} }
func (m *GetSystemStatsResponse) String() string { return proto.CompactTextString(m) }
func (*GetSystemStatsResponse) ProtoMessage() {}
func (*GetSystemStatsResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_system_service_ccf41ec210fc59eb, []int{3}
}
func (m *GetSystemStatsResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetSystemStatsResponse.Unmarshal(m, b)
}
func (m *GetSystemStatsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetSystemStatsResponse.Marshal(b, m, deterministic)
}
func (dst *GetSystemStatsResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetSystemStatsResponse.Merge(dst, src)
}
func (m *GetSystemStatsResponse) XXX_Size() int {
return xxx_messageInfo_GetSystemStatsResponse.Size(m)
}
func (m *GetSystemStatsResponse) XXX_DiscardUnknown() {
xxx_messageInfo_GetSystemStatsResponse.DiscardUnknown(m)
}
var xxx_messageInfo_GetSystemStatsResponse proto.InternalMessageInfo
func (m *GetSystemStatsResponse) GetCpu() *SystemStat {
if m != nil {
return m.Cpu
}
return nil
}
func (m *GetSystemStatsResponse) GetMemory() *SystemStat {
if m != nil {
return m.Memory
}
return nil
}
type StartBackgroundRequestRequest struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *StartBackgroundRequestRequest) Reset() { *m = StartBackgroundRequestRequest{} }
func (m *StartBackgroundRequestRequest) String() string { return proto.CompactTextString(m) }
func (*StartBackgroundRequestRequest) ProtoMessage() {}
func (*StartBackgroundRequestRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_system_service_ccf41ec210fc59eb, []int{4}
}
func (m *StartBackgroundRequestRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_StartBackgroundRequestRequest.Unmarshal(m, b)
}
func (m *StartBackgroundRequestRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_StartBackgroundRequestRequest.Marshal(b, m, deterministic)
}
func (dst *StartBackgroundRequestRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_StartBackgroundRequestRequest.Merge(dst, src)
}
func (m *StartBackgroundRequestRequest) XXX_Size() int {
return xxx_messageInfo_StartBackgroundRequestRequest.Size(m)
}
func (m *StartBackgroundRequestRequest) XXX_DiscardUnknown() {
xxx_messageInfo_StartBackgroundRequestRequest.DiscardUnknown(m)
}
var xxx_messageInfo_StartBackgroundRequestRequest proto.InternalMessageInfo
type StartBackgroundRequestResponse struct {
// Every /_ah/background request will have an X-AppEngine-BackgroundRequest
// header, whose value will be equal to this parameter, the request_id.
RequestId *string `protobuf:"bytes,1,opt,name=request_id,json=requestId" json:"request_id,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *StartBackgroundRequestResponse) Reset() { *m = StartBackgroundRequestResponse{} }
func (m *StartBackgroundRequestResponse) String() string { return proto.CompactTextString(m) }
func (*StartBackgroundRequestResponse) ProtoMessage() {}
func (*StartBackgroundRequestResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_system_service_ccf41ec210fc59eb, []int{5}
}
func (m *StartBackgroundRequestResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_StartBackgroundRequestResponse.Unmarshal(m, b)
}
func (m *StartBackgroundRequestResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_StartBackgroundRequestResponse.Marshal(b, m, deterministic)
}
func (dst *StartBackgroundRequestResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_StartBackgroundRequestResponse.Merge(dst, src)
}
func (m *StartBackgroundRequestResponse) XXX_Size() int {
return xxx_messageInfo_StartBackgroundRequestResponse.Size(m)
}
func (m *StartBackgroundRequestResponse) XXX_DiscardUnknown() {
xxx_messageInfo_StartBackgroundRequestResponse.DiscardUnknown(m)
}
var xxx_messageInfo_StartBackgroundRequestResponse proto.InternalMessageInfo
func (m *StartBackgroundRequestResponse) GetRequestId() string {
if m != nil && m.RequestId != nil {
return *m.RequestId
}
return ""
}
func init() {
proto.RegisterType((*SystemServiceError)(nil), "appengine.SystemServiceError")
proto.RegisterType((*SystemStat)(nil), "appengine.SystemStat")
proto.RegisterType((*GetSystemStatsRequest)(nil), "appengine.GetSystemStatsRequest")
proto.RegisterType((*GetSystemStatsResponse)(nil), "appengine.GetSystemStatsResponse")
proto.RegisterType((*StartBackgroundRequestRequest)(nil), "appengine.StartBackgroundRequestRequest")
proto.RegisterType((*StartBackgroundRequestResponse)(nil), "appengine.StartBackgroundRequestResponse")
}
func init() {
proto.RegisterFile("google.golang.org/appengine/internal/system/system_service.proto", fileDescriptor_system_service_ccf41ec210fc59eb)
}
var fileDescriptor_system_service_ccf41ec210fc59eb = []byte{
// 377 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0x4f, 0x8f, 0x93, 0x40,
0x18, 0xc6, 0xa5, 0x75, 0x51, 0x5e, 0xa3, 0xc1, 0xc9, 0xee, 0xca, 0xc1, 0x5d, 0x0d, 0x17, 0xbd,
0x48, 0x57, 0xbf, 0x80, 0xf6, 0xcf, 0x44, 0x49, 0x6b, 0xab, 0xd3, 0x7a, 0xf1, 0x42, 0x26, 0xf0,
0x3a, 0x21, 0xc2, 0x0c, 0x0e, 0x43, 0x93, 0x7e, 0x27, 0x3f, 0xa4, 0xe9, 0x30, 0x6d, 0xcd, 0x26,
0x3d, 0x31, 0xcf, 0xf3, 0xfc, 0x02, 0x3f, 0x08, 0xf0, 0x49, 0x28, 0x25, 0x2a, 0x4c, 0x84, 0xaa,
0xb8, 0x14, 0x89, 0xd2, 0x62, 0xc4, 0x9b, 0x06, 0xa5, 0x28, 0x25, 0x8e, 0x4a, 0x69, 0x50, 0x4b,
0x5e, 0x8d, 0xda, 0x5d, 0x6b, 0xb0, 0x76, 0x97, 0xac, 0x45, 0xbd, 0x2d, 0x73, 0x4c, 0x1a, 0xad,
0x8c, 0x22, 0xc1, 0x91, 0x8f, 0x7f, 0x01, 0x59, 0x5b, 0x64, 0xdd, 0x13, 0x54, 0x6b, 0xa5, 0xe3,
0x6f, 0x10, 0xd8, 0xc3, 0x54, 0x15, 0x48, 0x7c, 0x18, 0xac, 0xe6, 0xe1, 0x03, 0x42, 0xe0, 0x59,
0xba, 0xdc, 0x50, 0xb6, 0x1c, 0x2f, 0x32, 0xca, 0xd8, 0x8a, 0x85, 0x1e, 0xb9, 0x84, 0x70, 0x32,
0x9e, 0xce, 0xe9, 0x72, 0x96, 0x31, 0xfa, 0xfd, 0x47, 0xca, 0xe8, 0x2c, 0x1c, 0x90, 0xe7, 0xf0,
0x74, 0x91, 0x7e, 0x4d, 0x37, 0x19, 0xa3, 0xe3, 0xe9, 0x17, 0x3a, 0x0b, 0x87, 0xf1, 0x5f, 0x0f,
0xc0, 0x3d, 0xc8, 0x70, 0x43, 0x22, 0x78, 0x94, 0x77, 0x5a, 0xa3, 0x34, 0x91, 0xf7, 0xda, 0x7b,
0xeb, 0xb1, 0x43, 0x24, 0x2f, 0x21, 0xe0, 0x5b, 0xd4, 0x5c, 0xe0, 0xfb, 0x3a, 0x1a, 0xda, 0xed,
0x54, 0x90, 0x5b, 0x80, 0x43, 0xb8, 0xab, 0xa3, 0x87, 0x76, 0xfe, 0xaf, 0x21, 0x97, 0x70, 0x61,
0x94, 0xe1, 0x55, 0x34, 0xb0, 0x53, 0x1f, 0xc8, 0x35, 0xf8, 0x9a, 0x9b, 0xfd, 0x0d, 0x2f, 0x6c,
0xed, 0xd2, 0xde, 0xc2, 0x9e, 0xee, 0xea, 0xc8, 0xef, 0x2d, 0x5c, 0x8c, 0x5f, 0xc0, 0xd5, 0x67,
0x34, 0x27, 0xe1, 0x96, 0xe1, 0x9f, 0x0e, 0x5b, 0x13, 0x37, 0x70, 0x7d, 0x7f, 0x68, 0x1b, 0x25,
0x5b, 0x24, 0x6f, 0x60, 0x98, 0x37, 0x9d, 0x7d, 0x9d, 0x27, 0x1f, 0xae, 0x92, 0xe3, 0x27, 0x4e,
0x4e, 0x30, 0xdb, 0x13, 0xe4, 0x1d, 0xf8, 0x35, 0xd6, 0x4a, 0xef, 0xac, 0xe4, 0x59, 0xd6, 0x41,
0xf1, 0x2b, 0xb8, 0x59, 0x1b, 0xae, 0xcd, 0x84, 0xe7, 0xbf, 0x85, 0x56, 0x9d, 0x2c, 0x9c, 0xcb,
0x41, 0xe9, 0x23, 0xdc, 0x9e, 0x03, 0x9c, 0xda, 0x0d, 0x80, 0xee, 0xab, 0xac, 0x2c, 0xac, 0x61,
0xc0, 0x02, 0xd7, 0xa4, 0xc5, 0xe4, 0xf1, 0x4f, 0xbf, 0xff, 0x4d, 0xfe, 0x05, 0x00, 0x00, 0xff,
0xff, 0x56, 0x5d, 0x5e, 0xc3, 0x5b, 0x02, 0x00, 0x00,
}

View File

@ -1,49 +0,0 @@
syntax = "proto2";
option go_package = "system";
package appengine;
message SystemServiceError {
enum ErrorCode {
OK = 0;
INTERNAL_ERROR = 1;
BACKEND_REQUIRED = 2;
LIMIT_REACHED = 3;
}
}
message SystemStat {
// Instaneous value of this stat.
optional double current = 1;
// Average over time, if this stat has an instaneous value.
optional double average1m = 3;
optional double average10m = 4;
// Total value, if the stat accumulates over time.
optional double total = 2;
// Rate over time, if this stat accumulates.
optional double rate1m = 5;
optional double rate10m = 6;
}
message GetSystemStatsRequest {
}
message GetSystemStatsResponse {
// CPU used by this instance, in mcycles.
optional SystemStat cpu = 1;
// Physical memory (RAM) used by this instance, in megabytes.
optional SystemStat memory = 2;
}
message StartBackgroundRequestRequest {
}
message StartBackgroundRequestResponse {
// Every /_ah/background request will have an X-AppEngine-BackgroundRequest
// header, whose value will be equal to this parameter, the request_id.
optional string request_id = 1;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,342 +0,0 @@
syntax = "proto2";
option go_package = "taskqueue";
import "google.golang.org/appengine/internal/datastore/datastore_v3.proto";
package appengine;
message TaskQueueServiceError {
enum ErrorCode {
OK = 0;
UNKNOWN_QUEUE = 1;
TRANSIENT_ERROR = 2;
INTERNAL_ERROR = 3;
TASK_TOO_LARGE = 4;
INVALID_TASK_NAME = 5;
INVALID_QUEUE_NAME = 6;
INVALID_URL = 7;
INVALID_QUEUE_RATE = 8;
PERMISSION_DENIED = 9;
TASK_ALREADY_EXISTS = 10;
TOMBSTONED_TASK = 11;
INVALID_ETA = 12;
INVALID_REQUEST = 13;
UNKNOWN_TASK = 14;
TOMBSTONED_QUEUE = 15;
DUPLICATE_TASK_NAME = 16;
SKIPPED = 17;
TOO_MANY_TASKS = 18;
INVALID_PAYLOAD = 19;
INVALID_RETRY_PARAMETERS = 20;
INVALID_QUEUE_MODE = 21;
ACL_LOOKUP_ERROR = 22;
TRANSACTIONAL_REQUEST_TOO_LARGE = 23;
INCORRECT_CREATOR_NAME = 24;
TASK_LEASE_EXPIRED = 25;
QUEUE_PAUSED = 26;
INVALID_TAG = 27;
// Reserved range for the Datastore error codes.
// Original Datastore error code is shifted by DATASTORE_ERROR offset.
DATASTORE_ERROR = 10000;
}
}
message TaskPayload {
extensions 10 to max;
option message_set_wire_format = true;
}
message TaskQueueRetryParameters {
optional int32 retry_limit = 1;
optional int64 age_limit_sec = 2;
optional double min_backoff_sec = 3 [default = 0.1];
optional double max_backoff_sec = 4 [default = 3600];
optional int32 max_doublings = 5 [default = 16];
}
message TaskQueueAcl {
repeated bytes user_email = 1;
repeated bytes writer_email = 2;
}
message TaskQueueHttpHeader {
required bytes key = 1;
required bytes value = 2;
}
message TaskQueueMode {
enum Mode {
PUSH = 0;
PULL = 1;
}
}
message TaskQueueAddRequest {
required bytes queue_name = 1;
required bytes task_name = 2;
required int64 eta_usec = 3;
enum RequestMethod {
GET = 1;
POST = 2;
HEAD = 3;
PUT = 4;
DELETE = 5;
}
optional RequestMethod method = 5 [default=POST];
optional bytes url = 4;
repeated group Header = 6 {
required bytes key = 7;
required bytes value = 8;
}
optional bytes body = 9 [ctype=CORD];
optional Transaction transaction = 10;
optional bytes app_id = 11;
optional group CronTimetable = 12 {
required bytes schedule = 13;
required bytes timezone = 14;
}
optional bytes description = 15;
optional TaskPayload payload = 16;
optional TaskQueueRetryParameters retry_parameters = 17;
optional TaskQueueMode.Mode mode = 18 [default=PUSH];
optional bytes tag = 19;
}
message TaskQueueAddResponse {
optional bytes chosen_task_name = 1;
}
message TaskQueueBulkAddRequest {
repeated TaskQueueAddRequest add_request = 1;
}
message TaskQueueBulkAddResponse {
repeated group TaskResult = 1 {
required TaskQueueServiceError.ErrorCode result = 2;
optional bytes chosen_task_name = 3;
}
}
message TaskQueueDeleteRequest {
required bytes queue_name = 1;
repeated bytes task_name = 2;
optional bytes app_id = 3;
}
message TaskQueueDeleteResponse {
repeated TaskQueueServiceError.ErrorCode result = 3;
}
message TaskQueueForceRunRequest {
optional bytes app_id = 1;
required bytes queue_name = 2;
required bytes task_name = 3;
}
message TaskQueueForceRunResponse {
required TaskQueueServiceError.ErrorCode result = 3;
}
message TaskQueueUpdateQueueRequest {
optional bytes app_id = 1;
required bytes queue_name = 2;
required double bucket_refill_per_second = 3;
required int32 bucket_capacity = 4;
optional string user_specified_rate = 5;
optional TaskQueueRetryParameters retry_parameters = 6;
optional int32 max_concurrent_requests = 7;
optional TaskQueueMode.Mode mode = 8 [default = PUSH];
optional TaskQueueAcl acl = 9;
repeated TaskQueueHttpHeader header_override = 10;
}
message TaskQueueUpdateQueueResponse {
}
message TaskQueueFetchQueuesRequest {
optional bytes app_id = 1;
required int32 max_rows = 2;
}
message TaskQueueFetchQueuesResponse {
repeated group Queue = 1 {
required bytes queue_name = 2;
required double bucket_refill_per_second = 3;
required double bucket_capacity = 4;
optional string user_specified_rate = 5;
required bool paused = 6 [default=false];
optional TaskQueueRetryParameters retry_parameters = 7;
optional int32 max_concurrent_requests = 8;
optional TaskQueueMode.Mode mode = 9 [default = PUSH];
optional TaskQueueAcl acl = 10;
repeated TaskQueueHttpHeader header_override = 11;
optional string creator_name = 12 [ctype=CORD, default="apphosting"];
}
}
message TaskQueueFetchQueueStatsRequest {
optional bytes app_id = 1;
repeated bytes queue_name = 2;
optional int32 max_num_tasks = 3 [default = 0];
}
message TaskQueueScannerQueueInfo {
required int64 executed_last_minute = 1;
required int64 executed_last_hour = 2;
required double sampling_duration_seconds = 3;
optional int32 requests_in_flight = 4;
optional double enforced_rate = 5;
}
message TaskQueueFetchQueueStatsResponse {
repeated group QueueStats = 1 {
required int32 num_tasks = 2;
required int64 oldest_eta_usec = 3;
optional TaskQueueScannerQueueInfo scanner_info = 4;
}
}
message TaskQueuePauseQueueRequest {
required bytes app_id = 1;
required bytes queue_name = 2;
required bool pause = 3;
}
message TaskQueuePauseQueueResponse {
}
message TaskQueuePurgeQueueRequest {
optional bytes app_id = 1;
required bytes queue_name = 2;
}
message TaskQueuePurgeQueueResponse {
}
message TaskQueueDeleteQueueRequest {
required bytes app_id = 1;
required bytes queue_name = 2;
}
message TaskQueueDeleteQueueResponse {
}
message TaskQueueDeleteGroupRequest {
required bytes app_id = 1;
}
message TaskQueueDeleteGroupResponse {
}
message TaskQueueQueryTasksRequest {
optional bytes app_id = 1;
required bytes queue_name = 2;
optional bytes start_task_name = 3;
optional int64 start_eta_usec = 4;
optional bytes start_tag = 6;
optional int32 max_rows = 5 [default = 1];
}
message TaskQueueQueryTasksResponse {
repeated group Task = 1 {
required bytes task_name = 2;
required int64 eta_usec = 3;
optional bytes url = 4;
enum RequestMethod {
GET = 1;
POST = 2;
HEAD = 3;
PUT = 4;
DELETE = 5;
}
optional RequestMethod method = 5;
optional int32 retry_count = 6 [default=0];
repeated group Header = 7 {
required bytes key = 8;
required bytes value = 9;
}
optional int32 body_size = 10;
optional bytes body = 11 [ctype=CORD];
required int64 creation_time_usec = 12;
optional group CronTimetable = 13 {
required bytes schedule = 14;
required bytes timezone = 15;
}
optional group RunLog = 16 {
required int64 dispatched_usec = 17;
required int64 lag_usec = 18;
required int64 elapsed_usec = 19;
optional int64 response_code = 20;
optional string retry_reason = 27;
}
optional bytes description = 21;
optional TaskPayload payload = 22;
optional TaskQueueRetryParameters retry_parameters = 23;
optional int64 first_try_usec = 24;
optional bytes tag = 25;
optional int32 execution_count = 26 [default=0];
}
}
message TaskQueueFetchTaskRequest {
optional bytes app_id = 1;
required bytes queue_name = 2;
required bytes task_name = 3;
}
message TaskQueueFetchTaskResponse {
required TaskQueueQueryTasksResponse task = 1;
}
message TaskQueueUpdateStorageLimitRequest {
required bytes app_id = 1;
required int64 limit = 2;
}
message TaskQueueUpdateStorageLimitResponse {
required int64 new_limit = 1;
}
message TaskQueueQueryAndOwnTasksRequest {
required bytes queue_name = 1;
required double lease_seconds = 2;
required int64 max_tasks = 3;
optional bool group_by_tag = 4 [default=false];
optional bytes tag = 5;
}
message TaskQueueQueryAndOwnTasksResponse {
repeated group Task = 1 {
required bytes task_name = 2;
required int64 eta_usec = 3;
optional int32 retry_count = 4 [default=0];
optional bytes body = 5 [ctype=CORD];
optional bytes tag = 6;
}
}
message TaskQueueModifyTaskLeaseRequest {
required bytes queue_name = 1;
required bytes task_name = 2;
required int64 eta_usec = 3;
required double lease_seconds = 4;
}
message TaskQueueModifyTaskLeaseResponse {
required int64 updated_eta_usec = 1;
}

View File

@ -1,64 +0,0 @@
syntax = "proto2";
option go_package = "urlfetch";
package appengine;
message URLFetchServiceError {
enum ErrorCode {
OK = 0;
INVALID_URL = 1;
FETCH_ERROR = 2;
UNSPECIFIED_ERROR = 3;
RESPONSE_TOO_LARGE = 4;
DEADLINE_EXCEEDED = 5;
SSL_CERTIFICATE_ERROR = 6;
DNS_ERROR = 7;
CLOSED = 8;
INTERNAL_TRANSIENT_ERROR = 9;
TOO_MANY_REDIRECTS = 10;
MALFORMED_REPLY = 11;
CONNECTION_ERROR = 12;
}
}
message URLFetchRequest {
enum RequestMethod {
GET = 1;
POST = 2;
HEAD = 3;
PUT = 4;
DELETE = 5;
PATCH = 6;
}
required RequestMethod Method = 1;
required string Url = 2;
repeated group Header = 3 {
required string Key = 4;
required string Value = 5;
}
optional bytes Payload = 6 [ctype=CORD];
optional bool FollowRedirects = 7 [default=true];
optional double Deadline = 8;
optional bool MustValidateServerCertificate = 9 [default=true];
}
message URLFetchResponse {
optional bytes Content = 1;
required int32 StatusCode = 2;
repeated group Header = 3 {
required string Key = 4;
required string Value = 5;
}
optional bool ContentWasTruncated = 6 [default=false];
optional int64 ExternalBytesSent = 7;
optional int64 ExternalBytesReceived = 8;
optional string FinalUrl = 9;
optional int64 ApiCpuMilliseconds = 10 [default=0];
optional int64 ApiBytesSent = 11 [default=0];
optional int64 ApiBytesReceived = 12 [default=0];
}

View File

@ -1,531 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: google.golang.org/appengine/internal/user/user_service.proto
package user
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type UserServiceError_ErrorCode int32
const (
UserServiceError_OK UserServiceError_ErrorCode = 0
UserServiceError_REDIRECT_URL_TOO_LONG UserServiceError_ErrorCode = 1
UserServiceError_NOT_ALLOWED UserServiceError_ErrorCode = 2
UserServiceError_OAUTH_INVALID_TOKEN UserServiceError_ErrorCode = 3
UserServiceError_OAUTH_INVALID_REQUEST UserServiceError_ErrorCode = 4
UserServiceError_OAUTH_ERROR UserServiceError_ErrorCode = 5
)
var UserServiceError_ErrorCode_name = map[int32]string{
0: "OK",
1: "REDIRECT_URL_TOO_LONG",
2: "NOT_ALLOWED",
3: "OAUTH_INVALID_TOKEN",
4: "OAUTH_INVALID_REQUEST",
5: "OAUTH_ERROR",
}
var UserServiceError_ErrorCode_value = map[string]int32{
"OK": 0,
"REDIRECT_URL_TOO_LONG": 1,
"NOT_ALLOWED": 2,
"OAUTH_INVALID_TOKEN": 3,
"OAUTH_INVALID_REQUEST": 4,
"OAUTH_ERROR": 5,
}
func (x UserServiceError_ErrorCode) Enum() *UserServiceError_ErrorCode {
p := new(UserServiceError_ErrorCode)
*p = x
return p
}
func (x UserServiceError_ErrorCode) String() string {
return proto.EnumName(UserServiceError_ErrorCode_name, int32(x))
}
func (x *UserServiceError_ErrorCode) UnmarshalJSON(data []byte) error {
value, err := proto.UnmarshalJSONEnum(UserServiceError_ErrorCode_value, data, "UserServiceError_ErrorCode")
if err != nil {
return err
}
*x = UserServiceError_ErrorCode(value)
return nil
}
func (UserServiceError_ErrorCode) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_user_service_faa685423dd20b0a, []int{0, 0}
}
type UserServiceError struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *UserServiceError) Reset() { *m = UserServiceError{} }
func (m *UserServiceError) String() string { return proto.CompactTextString(m) }
func (*UserServiceError) ProtoMessage() {}
func (*UserServiceError) Descriptor() ([]byte, []int) {
return fileDescriptor_user_service_faa685423dd20b0a, []int{0}
}
func (m *UserServiceError) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_UserServiceError.Unmarshal(m, b)
}
func (m *UserServiceError) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_UserServiceError.Marshal(b, m, deterministic)
}
func (dst *UserServiceError) XXX_Merge(src proto.Message) {
xxx_messageInfo_UserServiceError.Merge(dst, src)
}
func (m *UserServiceError) XXX_Size() int {
return xxx_messageInfo_UserServiceError.Size(m)
}
func (m *UserServiceError) XXX_DiscardUnknown() {
xxx_messageInfo_UserServiceError.DiscardUnknown(m)
}
var xxx_messageInfo_UserServiceError proto.InternalMessageInfo
type CreateLoginURLRequest struct {
DestinationUrl *string `protobuf:"bytes,1,req,name=destination_url,json=destinationUrl" json:"destination_url,omitempty"`
AuthDomain *string `protobuf:"bytes,2,opt,name=auth_domain,json=authDomain" json:"auth_domain,omitempty"`
FederatedIdentity *string `protobuf:"bytes,3,opt,name=federated_identity,json=federatedIdentity,def=" json:"federated_identity,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CreateLoginURLRequest) Reset() { *m = CreateLoginURLRequest{} }
func (m *CreateLoginURLRequest) String() string { return proto.CompactTextString(m) }
func (*CreateLoginURLRequest) ProtoMessage() {}
func (*CreateLoginURLRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_user_service_faa685423dd20b0a, []int{1}
}
func (m *CreateLoginURLRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CreateLoginURLRequest.Unmarshal(m, b)
}
func (m *CreateLoginURLRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CreateLoginURLRequest.Marshal(b, m, deterministic)
}
func (dst *CreateLoginURLRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_CreateLoginURLRequest.Merge(dst, src)
}
func (m *CreateLoginURLRequest) XXX_Size() int {
return xxx_messageInfo_CreateLoginURLRequest.Size(m)
}
func (m *CreateLoginURLRequest) XXX_DiscardUnknown() {
xxx_messageInfo_CreateLoginURLRequest.DiscardUnknown(m)
}
var xxx_messageInfo_CreateLoginURLRequest proto.InternalMessageInfo
func (m *CreateLoginURLRequest) GetDestinationUrl() string {
if m != nil && m.DestinationUrl != nil {
return *m.DestinationUrl
}
return ""
}
func (m *CreateLoginURLRequest) GetAuthDomain() string {
if m != nil && m.AuthDomain != nil {
return *m.AuthDomain
}
return ""
}
func (m *CreateLoginURLRequest) GetFederatedIdentity() string {
if m != nil && m.FederatedIdentity != nil {
return *m.FederatedIdentity
}
return ""
}
type CreateLoginURLResponse struct {
LoginUrl *string `protobuf:"bytes,1,req,name=login_url,json=loginUrl" json:"login_url,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CreateLoginURLResponse) Reset() { *m = CreateLoginURLResponse{} }
func (m *CreateLoginURLResponse) String() string { return proto.CompactTextString(m) }
func (*CreateLoginURLResponse) ProtoMessage() {}
func (*CreateLoginURLResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_user_service_faa685423dd20b0a, []int{2}
}
func (m *CreateLoginURLResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CreateLoginURLResponse.Unmarshal(m, b)
}
func (m *CreateLoginURLResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CreateLoginURLResponse.Marshal(b, m, deterministic)
}
func (dst *CreateLoginURLResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_CreateLoginURLResponse.Merge(dst, src)
}
func (m *CreateLoginURLResponse) XXX_Size() int {
return xxx_messageInfo_CreateLoginURLResponse.Size(m)
}
func (m *CreateLoginURLResponse) XXX_DiscardUnknown() {
xxx_messageInfo_CreateLoginURLResponse.DiscardUnknown(m)
}
var xxx_messageInfo_CreateLoginURLResponse proto.InternalMessageInfo
func (m *CreateLoginURLResponse) GetLoginUrl() string {
if m != nil && m.LoginUrl != nil {
return *m.LoginUrl
}
return ""
}
type CreateLogoutURLRequest struct {
DestinationUrl *string `protobuf:"bytes,1,req,name=destination_url,json=destinationUrl" json:"destination_url,omitempty"`
AuthDomain *string `protobuf:"bytes,2,opt,name=auth_domain,json=authDomain" json:"auth_domain,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CreateLogoutURLRequest) Reset() { *m = CreateLogoutURLRequest{} }
func (m *CreateLogoutURLRequest) String() string { return proto.CompactTextString(m) }
func (*CreateLogoutURLRequest) ProtoMessage() {}
func (*CreateLogoutURLRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_user_service_faa685423dd20b0a, []int{3}
}
func (m *CreateLogoutURLRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CreateLogoutURLRequest.Unmarshal(m, b)
}
func (m *CreateLogoutURLRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CreateLogoutURLRequest.Marshal(b, m, deterministic)
}
func (dst *CreateLogoutURLRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_CreateLogoutURLRequest.Merge(dst, src)
}
func (m *CreateLogoutURLRequest) XXX_Size() int {
return xxx_messageInfo_CreateLogoutURLRequest.Size(m)
}
func (m *CreateLogoutURLRequest) XXX_DiscardUnknown() {
xxx_messageInfo_CreateLogoutURLRequest.DiscardUnknown(m)
}
var xxx_messageInfo_CreateLogoutURLRequest proto.InternalMessageInfo
func (m *CreateLogoutURLRequest) GetDestinationUrl() string {
if m != nil && m.DestinationUrl != nil {
return *m.DestinationUrl
}
return ""
}
func (m *CreateLogoutURLRequest) GetAuthDomain() string {
if m != nil && m.AuthDomain != nil {
return *m.AuthDomain
}
return ""
}
type CreateLogoutURLResponse struct {
LogoutUrl *string `protobuf:"bytes,1,req,name=logout_url,json=logoutUrl" json:"logout_url,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CreateLogoutURLResponse) Reset() { *m = CreateLogoutURLResponse{} }
func (m *CreateLogoutURLResponse) String() string { return proto.CompactTextString(m) }
func (*CreateLogoutURLResponse) ProtoMessage() {}
func (*CreateLogoutURLResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_user_service_faa685423dd20b0a, []int{4}
}
func (m *CreateLogoutURLResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CreateLogoutURLResponse.Unmarshal(m, b)
}
func (m *CreateLogoutURLResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CreateLogoutURLResponse.Marshal(b, m, deterministic)
}
func (dst *CreateLogoutURLResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_CreateLogoutURLResponse.Merge(dst, src)
}
func (m *CreateLogoutURLResponse) XXX_Size() int {
return xxx_messageInfo_CreateLogoutURLResponse.Size(m)
}
func (m *CreateLogoutURLResponse) XXX_DiscardUnknown() {
xxx_messageInfo_CreateLogoutURLResponse.DiscardUnknown(m)
}
var xxx_messageInfo_CreateLogoutURLResponse proto.InternalMessageInfo
func (m *CreateLogoutURLResponse) GetLogoutUrl() string {
if m != nil && m.LogoutUrl != nil {
return *m.LogoutUrl
}
return ""
}
type GetOAuthUserRequest struct {
Scope *string `protobuf:"bytes,1,opt,name=scope" json:"scope,omitempty"`
Scopes []string `protobuf:"bytes,2,rep,name=scopes" json:"scopes,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetOAuthUserRequest) Reset() { *m = GetOAuthUserRequest{} }
func (m *GetOAuthUserRequest) String() string { return proto.CompactTextString(m) }
func (*GetOAuthUserRequest) ProtoMessage() {}
func (*GetOAuthUserRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_user_service_faa685423dd20b0a, []int{5}
}
func (m *GetOAuthUserRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetOAuthUserRequest.Unmarshal(m, b)
}
func (m *GetOAuthUserRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetOAuthUserRequest.Marshal(b, m, deterministic)
}
func (dst *GetOAuthUserRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetOAuthUserRequest.Merge(dst, src)
}
func (m *GetOAuthUserRequest) XXX_Size() int {
return xxx_messageInfo_GetOAuthUserRequest.Size(m)
}
func (m *GetOAuthUserRequest) XXX_DiscardUnknown() {
xxx_messageInfo_GetOAuthUserRequest.DiscardUnknown(m)
}
var xxx_messageInfo_GetOAuthUserRequest proto.InternalMessageInfo
func (m *GetOAuthUserRequest) GetScope() string {
if m != nil && m.Scope != nil {
return *m.Scope
}
return ""
}
func (m *GetOAuthUserRequest) GetScopes() []string {
if m != nil {
return m.Scopes
}
return nil
}
type GetOAuthUserResponse struct {
Email *string `protobuf:"bytes,1,req,name=email" json:"email,omitempty"`
UserId *string `protobuf:"bytes,2,req,name=user_id,json=userId" json:"user_id,omitempty"`
AuthDomain *string `protobuf:"bytes,3,req,name=auth_domain,json=authDomain" json:"auth_domain,omitempty"`
UserOrganization *string `protobuf:"bytes,4,opt,name=user_organization,json=userOrganization,def=" json:"user_organization,omitempty"`
IsAdmin *bool `protobuf:"varint,5,opt,name=is_admin,json=isAdmin,def=0" json:"is_admin,omitempty"`
ClientId *string `protobuf:"bytes,6,opt,name=client_id,json=clientId,def=" json:"client_id,omitempty"`
Scopes []string `protobuf:"bytes,7,rep,name=scopes" json:"scopes,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetOAuthUserResponse) Reset() { *m = GetOAuthUserResponse{} }
func (m *GetOAuthUserResponse) String() string { return proto.CompactTextString(m) }
func (*GetOAuthUserResponse) ProtoMessage() {}
func (*GetOAuthUserResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_user_service_faa685423dd20b0a, []int{6}
}
func (m *GetOAuthUserResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetOAuthUserResponse.Unmarshal(m, b)
}
func (m *GetOAuthUserResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetOAuthUserResponse.Marshal(b, m, deterministic)
}
func (dst *GetOAuthUserResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetOAuthUserResponse.Merge(dst, src)
}
func (m *GetOAuthUserResponse) XXX_Size() int {
return xxx_messageInfo_GetOAuthUserResponse.Size(m)
}
func (m *GetOAuthUserResponse) XXX_DiscardUnknown() {
xxx_messageInfo_GetOAuthUserResponse.DiscardUnknown(m)
}
var xxx_messageInfo_GetOAuthUserResponse proto.InternalMessageInfo
const Default_GetOAuthUserResponse_IsAdmin bool = false
func (m *GetOAuthUserResponse) GetEmail() string {
if m != nil && m.Email != nil {
return *m.Email
}
return ""
}
func (m *GetOAuthUserResponse) GetUserId() string {
if m != nil && m.UserId != nil {
return *m.UserId
}
return ""
}
func (m *GetOAuthUserResponse) GetAuthDomain() string {
if m != nil && m.AuthDomain != nil {
return *m.AuthDomain
}
return ""
}
func (m *GetOAuthUserResponse) GetUserOrganization() string {
if m != nil && m.UserOrganization != nil {
return *m.UserOrganization
}
return ""
}
func (m *GetOAuthUserResponse) GetIsAdmin() bool {
if m != nil && m.IsAdmin != nil {
return *m.IsAdmin
}
return Default_GetOAuthUserResponse_IsAdmin
}
func (m *GetOAuthUserResponse) GetClientId() string {
if m != nil && m.ClientId != nil {
return *m.ClientId
}
return ""
}
func (m *GetOAuthUserResponse) GetScopes() []string {
if m != nil {
return m.Scopes
}
return nil
}
type CheckOAuthSignatureRequest struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CheckOAuthSignatureRequest) Reset() { *m = CheckOAuthSignatureRequest{} }
func (m *CheckOAuthSignatureRequest) String() string { return proto.CompactTextString(m) }
func (*CheckOAuthSignatureRequest) ProtoMessage() {}
func (*CheckOAuthSignatureRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_user_service_faa685423dd20b0a, []int{7}
}
func (m *CheckOAuthSignatureRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CheckOAuthSignatureRequest.Unmarshal(m, b)
}
func (m *CheckOAuthSignatureRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CheckOAuthSignatureRequest.Marshal(b, m, deterministic)
}
func (dst *CheckOAuthSignatureRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_CheckOAuthSignatureRequest.Merge(dst, src)
}
func (m *CheckOAuthSignatureRequest) XXX_Size() int {
return xxx_messageInfo_CheckOAuthSignatureRequest.Size(m)
}
func (m *CheckOAuthSignatureRequest) XXX_DiscardUnknown() {
xxx_messageInfo_CheckOAuthSignatureRequest.DiscardUnknown(m)
}
var xxx_messageInfo_CheckOAuthSignatureRequest proto.InternalMessageInfo
type CheckOAuthSignatureResponse struct {
OauthConsumerKey *string `protobuf:"bytes,1,req,name=oauth_consumer_key,json=oauthConsumerKey" json:"oauth_consumer_key,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CheckOAuthSignatureResponse) Reset() { *m = CheckOAuthSignatureResponse{} }
func (m *CheckOAuthSignatureResponse) String() string { return proto.CompactTextString(m) }
func (*CheckOAuthSignatureResponse) ProtoMessage() {}
func (*CheckOAuthSignatureResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_user_service_faa685423dd20b0a, []int{8}
}
func (m *CheckOAuthSignatureResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CheckOAuthSignatureResponse.Unmarshal(m, b)
}
func (m *CheckOAuthSignatureResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CheckOAuthSignatureResponse.Marshal(b, m, deterministic)
}
func (dst *CheckOAuthSignatureResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_CheckOAuthSignatureResponse.Merge(dst, src)
}
func (m *CheckOAuthSignatureResponse) XXX_Size() int {
return xxx_messageInfo_CheckOAuthSignatureResponse.Size(m)
}
func (m *CheckOAuthSignatureResponse) XXX_DiscardUnknown() {
xxx_messageInfo_CheckOAuthSignatureResponse.DiscardUnknown(m)
}
var xxx_messageInfo_CheckOAuthSignatureResponse proto.InternalMessageInfo
func (m *CheckOAuthSignatureResponse) GetOauthConsumerKey() string {
if m != nil && m.OauthConsumerKey != nil {
return *m.OauthConsumerKey
}
return ""
}
func init() {
proto.RegisterType((*UserServiceError)(nil), "appengine.UserServiceError")
proto.RegisterType((*CreateLoginURLRequest)(nil), "appengine.CreateLoginURLRequest")
proto.RegisterType((*CreateLoginURLResponse)(nil), "appengine.CreateLoginURLResponse")
proto.RegisterType((*CreateLogoutURLRequest)(nil), "appengine.CreateLogoutURLRequest")
proto.RegisterType((*CreateLogoutURLResponse)(nil), "appengine.CreateLogoutURLResponse")
proto.RegisterType((*GetOAuthUserRequest)(nil), "appengine.GetOAuthUserRequest")
proto.RegisterType((*GetOAuthUserResponse)(nil), "appengine.GetOAuthUserResponse")
proto.RegisterType((*CheckOAuthSignatureRequest)(nil), "appengine.CheckOAuthSignatureRequest")
proto.RegisterType((*CheckOAuthSignatureResponse)(nil), "appengine.CheckOAuthSignatureResponse")
}
func init() {
proto.RegisterFile("google.golang.org/appengine/internal/user/user_service.proto", fileDescriptor_user_service_faa685423dd20b0a)
}
var fileDescriptor_user_service_faa685423dd20b0a = []byte{
// 573 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x52, 0x4d, 0x6f, 0xdb, 0x38,
0x10, 0x8d, 0xec, 0xd8, 0xb1, 0x26, 0xc0, 0x46, 0x61, 0xbe, 0xb4, 0x9b, 0x0d, 0xd6, 0xd0, 0x65,
0x7d, 0x68, 0xe3, 0x53, 0x81, 0x22, 0xe8, 0xc5, 0xb5, 0x85, 0xd4, 0xb0, 0x60, 0xa1, 0x8c, 0xd5,
0x02, 0xbd, 0x08, 0xac, 0x35, 0x51, 0x88, 0xc8, 0xa4, 0x4b, 0x52, 0x05, 0xd2, 0x73, 0x7f, 0x41,
0x6f, 0xfd, 0x93, 0xfd, 0x0d, 0x85, 0x68, 0x25, 0x50, 0xd2, 0x5e, 0x7b, 0x11, 0x34, 0xef, 0x0d,
0xdf, 0xbc, 0x37, 0x24, 0xbc, 0xca, 0xa5, 0xcc, 0x0b, 0x3c, 0xcf, 0x65, 0xc1, 0x44, 0x7e, 0x2e,
0x55, 0x3e, 0x64, 0xeb, 0x35, 0x8a, 0x9c, 0x0b, 0x1c, 0x72, 0x61, 0x50, 0x09, 0x56, 0x0c, 0x4b,
0x8d, 0xca, 0x7e, 0x52, 0x8d, 0xea, 0x33, 0x5f, 0xe2, 0xf9, 0x5a, 0x49, 0x23, 0x89, 0xfb, 0xd0,
0x1b, 0x7c, 0x77, 0xc0, 0x4b, 0x34, 0xaa, 0xab, 0x4d, 0x43, 0xa8, 0x94, 0x54, 0xc1, 0x57, 0x07,
0x5c, 0xfb, 0x37, 0x96, 0x19, 0x92, 0x2e, 0xb4, 0xe2, 0x99, 0xb7, 0x45, 0xfe, 0x86, 0x23, 0x1a,
0x4e, 0xa6, 0x34, 0x1c, 0x2f, 0xd2, 0x84, 0x46, 0xe9, 0x22, 0x8e, 0xd3, 0x28, 0x9e, 0x5f, 0x7a,
0x0e, 0xd9, 0x83, 0xdd, 0x79, 0xbc, 0x48, 0x47, 0x51, 0x14, 0xbf, 0x0f, 0x27, 0x5e, 0x8b, 0x9c,
0xc0, 0x41, 0x3c, 0x4a, 0x16, 0x6f, 0xd2, 0xe9, 0xfc, 0xdd, 0x28, 0x9a, 0x4e, 0xd2, 0x45, 0x3c,
0x0b, 0xe7, 0x5e, 0xbb, 0x12, 0x79, 0x4c, 0xd0, 0xf0, 0x6d, 0x12, 0x5e, 0x2d, 0xbc, 0xed, 0x4a,
0x64, 0x43, 0x85, 0x94, 0xc6, 0xd4, 0xeb, 0x04, 0xdf, 0x1c, 0x38, 0x1a, 0x2b, 0x64, 0x06, 0x23,
0x99, 0x73, 0x91, 0xd0, 0x88, 0xe2, 0xa7, 0x12, 0xb5, 0x21, 0xff, 0xc3, 0x5e, 0x86, 0xda, 0x70,
0xc1, 0x0c, 0x97, 0x22, 0x2d, 0x55, 0xe1, 0x3b, 0xfd, 0xd6, 0xc0, 0xa5, 0x7f, 0x35, 0xe0, 0x44,
0x15, 0xe4, 0x3f, 0xd8, 0x65, 0xa5, 0xb9, 0x49, 0x33, 0xb9, 0x62, 0x5c, 0xf8, 0xad, 0xbe, 0x33,
0x70, 0x29, 0x54, 0xd0, 0xc4, 0x22, 0x64, 0x08, 0xe4, 0x1a, 0x33, 0x54, 0xcc, 0x60, 0x96, 0xf2,
0x0c, 0x85, 0xe1, 0xe6, 0xce, 0x6f, 0x57, 0x7d, 0x17, 0x5b, 0x74, 0xff, 0x81, 0x9b, 0xd6, 0x54,
0xf0, 0x02, 0x8e, 0x9f, 0x7a, 0xd2, 0x6b, 0x29, 0x34, 0x92, 0x53, 0x70, 0x8b, 0x0a, 0x6b, 0xd8,
0xe9, 0x59, 0x20, 0x51, 0x45, 0xf0, 0xb1, 0x71, 0x4c, 0x96, 0xe6, 0x4f, 0x64, 0x09, 0x5e, 0xc2,
0xc9, 0x2f, 0x33, 0x6a, 0x6f, 0x67, 0x00, 0x85, 0x05, 0x1b, 0xfa, 0xee, 0x06, 0xa9, 0xdc, 0x8d,
0xe1, 0xe0, 0x12, 0x4d, 0x3c, 0x2a, 0xcd, 0x4d, 0xf5, 0x18, 0xee, 0xad, 0x1d, 0x42, 0x47, 0x2f,
0xe5, 0x1a, 0x7d, 0xc7, 0xce, 0xda, 0x14, 0xe4, 0x18, 0xba, 0xf6, 0x47, 0xfb, 0xad, 0x7e, 0x7b,
0xe0, 0xd2, 0xba, 0x0a, 0x7e, 0x38, 0x70, 0xf8, 0x58, 0xa5, 0x1e, 0x7e, 0x08, 0x1d, 0x5c, 0x31,
0x7e, 0x3f, 0x77, 0x53, 0x90, 0x13, 0xd8, 0xb1, 0x4f, 0x93, 0x67, 0x7e, 0xcb, 0xe2, 0xdd, 0xaa,
0x9c, 0x66, 0x4f, 0x73, 0xb6, 0x2d, 0xd9, 0xbc, 0xb3, 0xe7, 0xb0, 0x6f, 0x4f, 0x4a, 0x95, 0x33,
0xc1, 0xbf, 0xd8, 0x05, 0xf9, 0xdb, 0xf5, 0x95, 0x79, 0x15, 0x15, 0x37, 0x18, 0xd2, 0x87, 0x1e,
0xd7, 0x29, 0xcb, 0x56, 0x5c, 0xf8, 0x9d, 0xbe, 0x33, 0xe8, 0x5d, 0x74, 0xae, 0x59, 0xa1, 0x91,
0xee, 0x70, 0x3d, 0xaa, 0x50, 0x72, 0x06, 0xee, 0xb2, 0xe0, 0x28, 0x4c, 0x65, 0xa6, 0x5b, 0x0b,
0xf5, 0x36, 0xd0, 0x34, 0x6b, 0x04, 0xde, 0x79, 0x14, 0xf8, 0x5f, 0xf8, 0x67, 0x7c, 0x83, 0xcb,
0x5b, 0x9b, 0xf8, 0x8a, 0xe7, 0x82, 0x99, 0x52, 0x61, 0xbd, 0xbc, 0x60, 0x06, 0xa7, 0xbf, 0x65,
0xeb, 0xa5, 0x3c, 0x03, 0x22, 0x6d, 0xcc, 0xa5, 0x14, 0xba, 0x5c, 0xa1, 0x4a, 0x6f, 0xf1, 0xae,
0xde, 0x90, 0x67, 0x99, 0x71, 0x4d, 0xcc, 0xf0, 0xee, 0x75, 0xf7, 0xc3, 0x76, 0x95, 0xeb, 0x67,
0x00, 0x00, 0x00, 0xff, 0xff, 0x58, 0x04, 0x53, 0xcc, 0xf8, 0x03, 0x00, 0x00,
}

View File

@ -1,58 +0,0 @@
syntax = "proto2";
option go_package = "user";
package appengine;
message UserServiceError {
enum ErrorCode {
OK = 0;
REDIRECT_URL_TOO_LONG = 1;
NOT_ALLOWED = 2;
OAUTH_INVALID_TOKEN = 3;
OAUTH_INVALID_REQUEST = 4;
OAUTH_ERROR = 5;
}
}
message CreateLoginURLRequest {
required string destination_url = 1;
optional string auth_domain = 2;
optional string federated_identity = 3 [default = ""];
}
message CreateLoginURLResponse {
required string login_url = 1;
}
message CreateLogoutURLRequest {
required string destination_url = 1;
optional string auth_domain = 2;
}
message CreateLogoutURLResponse {
required string logout_url = 1;
}
message GetOAuthUserRequest {
optional string scope = 1;
repeated string scopes = 2;
}
message GetOAuthUserResponse {
required string email = 1;
required string user_id = 2;
required string auth_domain = 3;
optional string user_organization = 4 [default = ""];
optional bool is_admin = 5 [default = false];
optional string client_id = 6 [default = ""];
repeated string scopes = 7;
}
message CheckOAuthSignatureRequest {
}
message CheckOAuthSignatureResponse {
required string oauth_consumer_key = 1;
}

View File

@ -1,726 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: google.golang.org/appengine/internal/xmpp/xmpp_service.proto
package xmpp
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type XmppServiceError_ErrorCode int32
const (
XmppServiceError_UNSPECIFIED_ERROR XmppServiceError_ErrorCode = 1
XmppServiceError_INVALID_JID XmppServiceError_ErrorCode = 2
XmppServiceError_NO_BODY XmppServiceError_ErrorCode = 3
XmppServiceError_INVALID_XML XmppServiceError_ErrorCode = 4
XmppServiceError_INVALID_TYPE XmppServiceError_ErrorCode = 5
XmppServiceError_INVALID_SHOW XmppServiceError_ErrorCode = 6
XmppServiceError_EXCEEDED_MAX_SIZE XmppServiceError_ErrorCode = 7
XmppServiceError_APPID_ALIAS_REQUIRED XmppServiceError_ErrorCode = 8
XmppServiceError_NONDEFAULT_MODULE XmppServiceError_ErrorCode = 9
)
var XmppServiceError_ErrorCode_name = map[int32]string{
1: "UNSPECIFIED_ERROR",
2: "INVALID_JID",
3: "NO_BODY",
4: "INVALID_XML",
5: "INVALID_TYPE",
6: "INVALID_SHOW",
7: "EXCEEDED_MAX_SIZE",
8: "APPID_ALIAS_REQUIRED",
9: "NONDEFAULT_MODULE",
}
var XmppServiceError_ErrorCode_value = map[string]int32{
"UNSPECIFIED_ERROR": 1,
"INVALID_JID": 2,
"NO_BODY": 3,
"INVALID_XML": 4,
"INVALID_TYPE": 5,
"INVALID_SHOW": 6,
"EXCEEDED_MAX_SIZE": 7,
"APPID_ALIAS_REQUIRED": 8,
"NONDEFAULT_MODULE": 9,
}
func (x XmppServiceError_ErrorCode) Enum() *XmppServiceError_ErrorCode {
p := new(XmppServiceError_ErrorCode)
*p = x
return p
}
func (x XmppServiceError_ErrorCode) String() string {
return proto.EnumName(XmppServiceError_ErrorCode_name, int32(x))
}
func (x *XmppServiceError_ErrorCode) UnmarshalJSON(data []byte) error {
value, err := proto.UnmarshalJSONEnum(XmppServiceError_ErrorCode_value, data, "XmppServiceError_ErrorCode")
if err != nil {
return err
}
*x = XmppServiceError_ErrorCode(value)
return nil
}
func (XmppServiceError_ErrorCode) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_xmpp_service_628da92437bed65f, []int{0, 0}
}
type PresenceResponse_SHOW int32
const (
PresenceResponse_NORMAL PresenceResponse_SHOW = 0
PresenceResponse_AWAY PresenceResponse_SHOW = 1
PresenceResponse_DO_NOT_DISTURB PresenceResponse_SHOW = 2
PresenceResponse_CHAT PresenceResponse_SHOW = 3
PresenceResponse_EXTENDED_AWAY PresenceResponse_SHOW = 4
)
var PresenceResponse_SHOW_name = map[int32]string{
0: "NORMAL",
1: "AWAY",
2: "DO_NOT_DISTURB",
3: "CHAT",
4: "EXTENDED_AWAY",
}
var PresenceResponse_SHOW_value = map[string]int32{
"NORMAL": 0,
"AWAY": 1,
"DO_NOT_DISTURB": 2,
"CHAT": 3,
"EXTENDED_AWAY": 4,
}
func (x PresenceResponse_SHOW) Enum() *PresenceResponse_SHOW {
p := new(PresenceResponse_SHOW)
*p = x
return p
}
func (x PresenceResponse_SHOW) String() string {
return proto.EnumName(PresenceResponse_SHOW_name, int32(x))
}
func (x *PresenceResponse_SHOW) UnmarshalJSON(data []byte) error {
value, err := proto.UnmarshalJSONEnum(PresenceResponse_SHOW_value, data, "PresenceResponse_SHOW")
if err != nil {
return err
}
*x = PresenceResponse_SHOW(value)
return nil
}
func (PresenceResponse_SHOW) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_xmpp_service_628da92437bed65f, []int{2, 0}
}
type XmppMessageResponse_XmppMessageStatus int32
const (
XmppMessageResponse_NO_ERROR XmppMessageResponse_XmppMessageStatus = 0
XmppMessageResponse_INVALID_JID XmppMessageResponse_XmppMessageStatus = 1
XmppMessageResponse_OTHER_ERROR XmppMessageResponse_XmppMessageStatus = 2
)
var XmppMessageResponse_XmppMessageStatus_name = map[int32]string{
0: "NO_ERROR",
1: "INVALID_JID",
2: "OTHER_ERROR",
}
var XmppMessageResponse_XmppMessageStatus_value = map[string]int32{
"NO_ERROR": 0,
"INVALID_JID": 1,
"OTHER_ERROR": 2,
}
func (x XmppMessageResponse_XmppMessageStatus) Enum() *XmppMessageResponse_XmppMessageStatus {
p := new(XmppMessageResponse_XmppMessageStatus)
*p = x
return p
}
func (x XmppMessageResponse_XmppMessageStatus) String() string {
return proto.EnumName(XmppMessageResponse_XmppMessageStatus_name, int32(x))
}
func (x *XmppMessageResponse_XmppMessageStatus) UnmarshalJSON(data []byte) error {
value, err := proto.UnmarshalJSONEnum(XmppMessageResponse_XmppMessageStatus_value, data, "XmppMessageResponse_XmppMessageStatus")
if err != nil {
return err
}
*x = XmppMessageResponse_XmppMessageStatus(value)
return nil
}
func (XmppMessageResponse_XmppMessageStatus) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_xmpp_service_628da92437bed65f, []int{6, 0}
}
type XmppServiceError struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *XmppServiceError) Reset() { *m = XmppServiceError{} }
func (m *XmppServiceError) String() string { return proto.CompactTextString(m) }
func (*XmppServiceError) ProtoMessage() {}
func (*XmppServiceError) Descriptor() ([]byte, []int) {
return fileDescriptor_xmpp_service_628da92437bed65f, []int{0}
}
func (m *XmppServiceError) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_XmppServiceError.Unmarshal(m, b)
}
func (m *XmppServiceError) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_XmppServiceError.Marshal(b, m, deterministic)
}
func (dst *XmppServiceError) XXX_Merge(src proto.Message) {
xxx_messageInfo_XmppServiceError.Merge(dst, src)
}
func (m *XmppServiceError) XXX_Size() int {
return xxx_messageInfo_XmppServiceError.Size(m)
}
func (m *XmppServiceError) XXX_DiscardUnknown() {
xxx_messageInfo_XmppServiceError.DiscardUnknown(m)
}
var xxx_messageInfo_XmppServiceError proto.InternalMessageInfo
type PresenceRequest struct {
Jid *string `protobuf:"bytes,1,req,name=jid" json:"jid,omitempty"`
FromJid *string `protobuf:"bytes,2,opt,name=from_jid,json=fromJid" json:"from_jid,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *PresenceRequest) Reset() { *m = PresenceRequest{} }
func (m *PresenceRequest) String() string { return proto.CompactTextString(m) }
func (*PresenceRequest) ProtoMessage() {}
func (*PresenceRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_xmpp_service_628da92437bed65f, []int{1}
}
func (m *PresenceRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PresenceRequest.Unmarshal(m, b)
}
func (m *PresenceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_PresenceRequest.Marshal(b, m, deterministic)
}
func (dst *PresenceRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_PresenceRequest.Merge(dst, src)
}
func (m *PresenceRequest) XXX_Size() int {
return xxx_messageInfo_PresenceRequest.Size(m)
}
func (m *PresenceRequest) XXX_DiscardUnknown() {
xxx_messageInfo_PresenceRequest.DiscardUnknown(m)
}
var xxx_messageInfo_PresenceRequest proto.InternalMessageInfo
func (m *PresenceRequest) GetJid() string {
if m != nil && m.Jid != nil {
return *m.Jid
}
return ""
}
func (m *PresenceRequest) GetFromJid() string {
if m != nil && m.FromJid != nil {
return *m.FromJid
}
return ""
}
type PresenceResponse struct {
IsAvailable *bool `protobuf:"varint,1,req,name=is_available,json=isAvailable" json:"is_available,omitempty"`
Presence *PresenceResponse_SHOW `protobuf:"varint,2,opt,name=presence,enum=appengine.PresenceResponse_SHOW" json:"presence,omitempty"`
Valid *bool `protobuf:"varint,3,opt,name=valid" json:"valid,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *PresenceResponse) Reset() { *m = PresenceResponse{} }
func (m *PresenceResponse) String() string { return proto.CompactTextString(m) }
func (*PresenceResponse) ProtoMessage() {}
func (*PresenceResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_xmpp_service_628da92437bed65f, []int{2}
}
func (m *PresenceResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PresenceResponse.Unmarshal(m, b)
}
func (m *PresenceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_PresenceResponse.Marshal(b, m, deterministic)
}
func (dst *PresenceResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_PresenceResponse.Merge(dst, src)
}
func (m *PresenceResponse) XXX_Size() int {
return xxx_messageInfo_PresenceResponse.Size(m)
}
func (m *PresenceResponse) XXX_DiscardUnknown() {
xxx_messageInfo_PresenceResponse.DiscardUnknown(m)
}
var xxx_messageInfo_PresenceResponse proto.InternalMessageInfo
func (m *PresenceResponse) GetIsAvailable() bool {
if m != nil && m.IsAvailable != nil {
return *m.IsAvailable
}
return false
}
func (m *PresenceResponse) GetPresence() PresenceResponse_SHOW {
if m != nil && m.Presence != nil {
return *m.Presence
}
return PresenceResponse_NORMAL
}
func (m *PresenceResponse) GetValid() bool {
if m != nil && m.Valid != nil {
return *m.Valid
}
return false
}
type BulkPresenceRequest struct {
Jid []string `protobuf:"bytes,1,rep,name=jid" json:"jid,omitempty"`
FromJid *string `protobuf:"bytes,2,opt,name=from_jid,json=fromJid" json:"from_jid,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *BulkPresenceRequest) Reset() { *m = BulkPresenceRequest{} }
func (m *BulkPresenceRequest) String() string { return proto.CompactTextString(m) }
func (*BulkPresenceRequest) ProtoMessage() {}
func (*BulkPresenceRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_xmpp_service_628da92437bed65f, []int{3}
}
func (m *BulkPresenceRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_BulkPresenceRequest.Unmarshal(m, b)
}
func (m *BulkPresenceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_BulkPresenceRequest.Marshal(b, m, deterministic)
}
func (dst *BulkPresenceRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_BulkPresenceRequest.Merge(dst, src)
}
func (m *BulkPresenceRequest) XXX_Size() int {
return xxx_messageInfo_BulkPresenceRequest.Size(m)
}
func (m *BulkPresenceRequest) XXX_DiscardUnknown() {
xxx_messageInfo_BulkPresenceRequest.DiscardUnknown(m)
}
var xxx_messageInfo_BulkPresenceRequest proto.InternalMessageInfo
func (m *BulkPresenceRequest) GetJid() []string {
if m != nil {
return m.Jid
}
return nil
}
func (m *BulkPresenceRequest) GetFromJid() string {
if m != nil && m.FromJid != nil {
return *m.FromJid
}
return ""
}
type BulkPresenceResponse struct {
PresenceResponse []*PresenceResponse `protobuf:"bytes,1,rep,name=presence_response,json=presenceResponse" json:"presence_response,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *BulkPresenceResponse) Reset() { *m = BulkPresenceResponse{} }
func (m *BulkPresenceResponse) String() string { return proto.CompactTextString(m) }
func (*BulkPresenceResponse) ProtoMessage() {}
func (*BulkPresenceResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_xmpp_service_628da92437bed65f, []int{4}
}
func (m *BulkPresenceResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_BulkPresenceResponse.Unmarshal(m, b)
}
func (m *BulkPresenceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_BulkPresenceResponse.Marshal(b, m, deterministic)
}
func (dst *BulkPresenceResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_BulkPresenceResponse.Merge(dst, src)
}
func (m *BulkPresenceResponse) XXX_Size() int {
return xxx_messageInfo_BulkPresenceResponse.Size(m)
}
func (m *BulkPresenceResponse) XXX_DiscardUnknown() {
xxx_messageInfo_BulkPresenceResponse.DiscardUnknown(m)
}
var xxx_messageInfo_BulkPresenceResponse proto.InternalMessageInfo
func (m *BulkPresenceResponse) GetPresenceResponse() []*PresenceResponse {
if m != nil {
return m.PresenceResponse
}
return nil
}
type XmppMessageRequest struct {
Jid []string `protobuf:"bytes,1,rep,name=jid" json:"jid,omitempty"`
Body *string `protobuf:"bytes,2,req,name=body" json:"body,omitempty"`
RawXml *bool `protobuf:"varint,3,opt,name=raw_xml,json=rawXml,def=0" json:"raw_xml,omitempty"`
Type *string `protobuf:"bytes,4,opt,name=type,def=chat" json:"type,omitempty"`
FromJid *string `protobuf:"bytes,5,opt,name=from_jid,json=fromJid" json:"from_jid,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *XmppMessageRequest) Reset() { *m = XmppMessageRequest{} }
func (m *XmppMessageRequest) String() string { return proto.CompactTextString(m) }
func (*XmppMessageRequest) ProtoMessage() {}
func (*XmppMessageRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_xmpp_service_628da92437bed65f, []int{5}
}
func (m *XmppMessageRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_XmppMessageRequest.Unmarshal(m, b)
}
func (m *XmppMessageRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_XmppMessageRequest.Marshal(b, m, deterministic)
}
func (dst *XmppMessageRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_XmppMessageRequest.Merge(dst, src)
}
func (m *XmppMessageRequest) XXX_Size() int {
return xxx_messageInfo_XmppMessageRequest.Size(m)
}
func (m *XmppMessageRequest) XXX_DiscardUnknown() {
xxx_messageInfo_XmppMessageRequest.DiscardUnknown(m)
}
var xxx_messageInfo_XmppMessageRequest proto.InternalMessageInfo
const Default_XmppMessageRequest_RawXml bool = false
const Default_XmppMessageRequest_Type string = "chat"
func (m *XmppMessageRequest) GetJid() []string {
if m != nil {
return m.Jid
}
return nil
}
func (m *XmppMessageRequest) GetBody() string {
if m != nil && m.Body != nil {
return *m.Body
}
return ""
}
func (m *XmppMessageRequest) GetRawXml() bool {
if m != nil && m.RawXml != nil {
return *m.RawXml
}
return Default_XmppMessageRequest_RawXml
}
func (m *XmppMessageRequest) GetType() string {
if m != nil && m.Type != nil {
return *m.Type
}
return Default_XmppMessageRequest_Type
}
func (m *XmppMessageRequest) GetFromJid() string {
if m != nil && m.FromJid != nil {
return *m.FromJid
}
return ""
}
type XmppMessageResponse struct {
Status []XmppMessageResponse_XmppMessageStatus `protobuf:"varint,1,rep,name=status,enum=appengine.XmppMessageResponse_XmppMessageStatus" json:"status,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *XmppMessageResponse) Reset() { *m = XmppMessageResponse{} }
func (m *XmppMessageResponse) String() string { return proto.CompactTextString(m) }
func (*XmppMessageResponse) ProtoMessage() {}
func (*XmppMessageResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_xmpp_service_628da92437bed65f, []int{6}
}
func (m *XmppMessageResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_XmppMessageResponse.Unmarshal(m, b)
}
func (m *XmppMessageResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_XmppMessageResponse.Marshal(b, m, deterministic)
}
func (dst *XmppMessageResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_XmppMessageResponse.Merge(dst, src)
}
func (m *XmppMessageResponse) XXX_Size() int {
return xxx_messageInfo_XmppMessageResponse.Size(m)
}
func (m *XmppMessageResponse) XXX_DiscardUnknown() {
xxx_messageInfo_XmppMessageResponse.DiscardUnknown(m)
}
var xxx_messageInfo_XmppMessageResponse proto.InternalMessageInfo
func (m *XmppMessageResponse) GetStatus() []XmppMessageResponse_XmppMessageStatus {
if m != nil {
return m.Status
}
return nil
}
type XmppSendPresenceRequest struct {
Jid *string `protobuf:"bytes,1,req,name=jid" json:"jid,omitempty"`
Type *string `protobuf:"bytes,2,opt,name=type" json:"type,omitempty"`
Show *string `protobuf:"bytes,3,opt,name=show" json:"show,omitempty"`
Status *string `protobuf:"bytes,4,opt,name=status" json:"status,omitempty"`
FromJid *string `protobuf:"bytes,5,opt,name=from_jid,json=fromJid" json:"from_jid,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *XmppSendPresenceRequest) Reset() { *m = XmppSendPresenceRequest{} }
func (m *XmppSendPresenceRequest) String() string { return proto.CompactTextString(m) }
func (*XmppSendPresenceRequest) ProtoMessage() {}
func (*XmppSendPresenceRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_xmpp_service_628da92437bed65f, []int{7}
}
func (m *XmppSendPresenceRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_XmppSendPresenceRequest.Unmarshal(m, b)
}
func (m *XmppSendPresenceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_XmppSendPresenceRequest.Marshal(b, m, deterministic)
}
func (dst *XmppSendPresenceRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_XmppSendPresenceRequest.Merge(dst, src)
}
func (m *XmppSendPresenceRequest) XXX_Size() int {
return xxx_messageInfo_XmppSendPresenceRequest.Size(m)
}
func (m *XmppSendPresenceRequest) XXX_DiscardUnknown() {
xxx_messageInfo_XmppSendPresenceRequest.DiscardUnknown(m)
}
var xxx_messageInfo_XmppSendPresenceRequest proto.InternalMessageInfo
func (m *XmppSendPresenceRequest) GetJid() string {
if m != nil && m.Jid != nil {
return *m.Jid
}
return ""
}
func (m *XmppSendPresenceRequest) GetType() string {
if m != nil && m.Type != nil {
return *m.Type
}
return ""
}
func (m *XmppSendPresenceRequest) GetShow() string {
if m != nil && m.Show != nil {
return *m.Show
}
return ""
}
func (m *XmppSendPresenceRequest) GetStatus() string {
if m != nil && m.Status != nil {
return *m.Status
}
return ""
}
func (m *XmppSendPresenceRequest) GetFromJid() string {
if m != nil && m.FromJid != nil {
return *m.FromJid
}
return ""
}
type XmppSendPresenceResponse struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *XmppSendPresenceResponse) Reset() { *m = XmppSendPresenceResponse{} }
func (m *XmppSendPresenceResponse) String() string { return proto.CompactTextString(m) }
func (*XmppSendPresenceResponse) ProtoMessage() {}
func (*XmppSendPresenceResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_xmpp_service_628da92437bed65f, []int{8}
}
func (m *XmppSendPresenceResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_XmppSendPresenceResponse.Unmarshal(m, b)
}
func (m *XmppSendPresenceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_XmppSendPresenceResponse.Marshal(b, m, deterministic)
}
func (dst *XmppSendPresenceResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_XmppSendPresenceResponse.Merge(dst, src)
}
func (m *XmppSendPresenceResponse) XXX_Size() int {
return xxx_messageInfo_XmppSendPresenceResponse.Size(m)
}
func (m *XmppSendPresenceResponse) XXX_DiscardUnknown() {
xxx_messageInfo_XmppSendPresenceResponse.DiscardUnknown(m)
}
var xxx_messageInfo_XmppSendPresenceResponse proto.InternalMessageInfo
type XmppInviteRequest struct {
Jid *string `protobuf:"bytes,1,req,name=jid" json:"jid,omitempty"`
FromJid *string `protobuf:"bytes,2,opt,name=from_jid,json=fromJid" json:"from_jid,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *XmppInviteRequest) Reset() { *m = XmppInviteRequest{} }
func (m *XmppInviteRequest) String() string { return proto.CompactTextString(m) }
func (*XmppInviteRequest) ProtoMessage() {}
func (*XmppInviteRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_xmpp_service_628da92437bed65f, []int{9}
}
func (m *XmppInviteRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_XmppInviteRequest.Unmarshal(m, b)
}
func (m *XmppInviteRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_XmppInviteRequest.Marshal(b, m, deterministic)
}
func (dst *XmppInviteRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_XmppInviteRequest.Merge(dst, src)
}
func (m *XmppInviteRequest) XXX_Size() int {
return xxx_messageInfo_XmppInviteRequest.Size(m)
}
func (m *XmppInviteRequest) XXX_DiscardUnknown() {
xxx_messageInfo_XmppInviteRequest.DiscardUnknown(m)
}
var xxx_messageInfo_XmppInviteRequest proto.InternalMessageInfo
func (m *XmppInviteRequest) GetJid() string {
if m != nil && m.Jid != nil {
return *m.Jid
}
return ""
}
func (m *XmppInviteRequest) GetFromJid() string {
if m != nil && m.FromJid != nil {
return *m.FromJid
}
return ""
}
type XmppInviteResponse struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *XmppInviteResponse) Reset() { *m = XmppInviteResponse{} }
func (m *XmppInviteResponse) String() string { return proto.CompactTextString(m) }
func (*XmppInviteResponse) ProtoMessage() {}
func (*XmppInviteResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_xmpp_service_628da92437bed65f, []int{10}
}
func (m *XmppInviteResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_XmppInviteResponse.Unmarshal(m, b)
}
func (m *XmppInviteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_XmppInviteResponse.Marshal(b, m, deterministic)
}
func (dst *XmppInviteResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_XmppInviteResponse.Merge(dst, src)
}
func (m *XmppInviteResponse) XXX_Size() int {
return xxx_messageInfo_XmppInviteResponse.Size(m)
}
func (m *XmppInviteResponse) XXX_DiscardUnknown() {
xxx_messageInfo_XmppInviteResponse.DiscardUnknown(m)
}
var xxx_messageInfo_XmppInviteResponse proto.InternalMessageInfo
func init() {
proto.RegisterType((*XmppServiceError)(nil), "appengine.XmppServiceError")
proto.RegisterType((*PresenceRequest)(nil), "appengine.PresenceRequest")
proto.RegisterType((*PresenceResponse)(nil), "appengine.PresenceResponse")
proto.RegisterType((*BulkPresenceRequest)(nil), "appengine.BulkPresenceRequest")
proto.RegisterType((*BulkPresenceResponse)(nil), "appengine.BulkPresenceResponse")
proto.RegisterType((*XmppMessageRequest)(nil), "appengine.XmppMessageRequest")
proto.RegisterType((*XmppMessageResponse)(nil), "appengine.XmppMessageResponse")
proto.RegisterType((*XmppSendPresenceRequest)(nil), "appengine.XmppSendPresenceRequest")
proto.RegisterType((*XmppSendPresenceResponse)(nil), "appengine.XmppSendPresenceResponse")
proto.RegisterType((*XmppInviteRequest)(nil), "appengine.XmppInviteRequest")
proto.RegisterType((*XmppInviteResponse)(nil), "appengine.XmppInviteResponse")
}
func init() {
proto.RegisterFile("google.golang.org/appengine/internal/xmpp/xmpp_service.proto", fileDescriptor_xmpp_service_628da92437bed65f)
}
var fileDescriptor_xmpp_service_628da92437bed65f = []byte{
// 681 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xcd, 0x72, 0xda, 0x48,
0x10, 0xb6, 0x40, 0xfc, 0x35, 0x5e, 0x7b, 0x18, 0xb3, 0xbb, 0xec, 0xa6, 0x2a, 0x45, 0x74, 0xf2,
0x09, 0xa7, 0x7c, 0x74, 0xb9, 0x52, 0x11, 0x68, 0x5c, 0xc8, 0x05, 0x12, 0x19, 0x20, 0xc6, 0xbe,
0x4c, 0x64, 0x33, 0x96, 0x95, 0x08, 0x49, 0x91, 0x64, 0x6c, 0xbf, 0x40, 0xae, 0x79, 0x89, 0xbc,
0x46, 0x5e, 0x22, 0xa7, 0x3c, 0x4e, 0x4a, 0x23, 0x41, 0xc0, 0x4e, 0x9c, 0x54, 0x2e, 0x54, 0xcf,
0x37, 0xdd, 0x1f, 0xfd, 0x7d, 0x3d, 0x2d, 0x38, 0xb4, 0x7d, 0xdf, 0x76, 0x79, 0xcb, 0xf6, 0x5d,
0xcb, 0xb3, 0x5b, 0x7e, 0x68, 0xef, 0x59, 0x41, 0xc0, 0x3d, 0xdb, 0xf1, 0xf8, 0x9e, 0xe3, 0xc5,
0x3c, 0xf4, 0x2c, 0x77, 0xef, 0x76, 0x16, 0x04, 0xe2, 0x87, 0x45, 0x3c, 0x9c, 0x3b, 0x17, 0xbc,
0x15, 0x84, 0x7e, 0xec, 0xe3, 0xca, 0x32, 0x57, 0xf9, 0x22, 0x01, 0x9a, 0xcc, 0x82, 0x60, 0x98,
0x26, 0x90, 0x30, 0xf4, 0x43, 0xe5, 0xb3, 0x04, 0x15, 0x11, 0x75, 0xfc, 0x29, 0xc7, 0x7f, 0x43,
0x6d, 0x6c, 0x0c, 0x07, 0xa4, 0xa3, 0x1f, 0xe9, 0x44, 0x63, 0x84, 0x52, 0x93, 0x22, 0x09, 0x6f,
0x43, 0x55, 0x37, 0x5e, 0xab, 0x3d, 0x5d, 0x63, 0xc7, 0xba, 0x86, 0x72, 0xb8, 0x0a, 0x25, 0xc3,
0x64, 0x6d, 0x53, 0x3b, 0x45, 0xf9, 0xd5, 0xdb, 0x49, 0xbf, 0x87, 0x64, 0x8c, 0x60, 0x73, 0x01,
0x8c, 0x4e, 0x07, 0x04, 0x15, 0x56, 0x91, 0x61, 0xd7, 0x3c, 0x41, 0xc5, 0xe4, 0x9f, 0xc8, 0xa4,
0x43, 0x88, 0x46, 0x34, 0xd6, 0x57, 0x27, 0x6c, 0xa8, 0x9f, 0x11, 0x54, 0xc2, 0x0d, 0xa8, 0xab,
0x83, 0x81, 0xae, 0x31, 0xb5, 0xa7, 0xab, 0x43, 0x46, 0xc9, 0xab, 0xb1, 0x4e, 0x89, 0x86, 0xca,
0x49, 0x81, 0x61, 0x1a, 0x1a, 0x39, 0x52, 0xc7, 0xbd, 0x11, 0xeb, 0x9b, 0xda, 0xb8, 0x47, 0x50,
0x45, 0x79, 0x01, 0xdb, 0x83, 0x90, 0x47, 0xdc, 0xbb, 0xe0, 0x94, 0xbf, 0xbf, 0xe6, 0x51, 0x8c,
0x11, 0xe4, 0xdf, 0x3a, 0xd3, 0x86, 0xd4, 0xcc, 0xed, 0x56, 0x68, 0x12, 0xe2, 0xff, 0xa0, 0x7c,
0x19, 0xfa, 0x33, 0x96, 0xc0, 0xb9, 0xa6, 0xb4, 0x5b, 0xa1, 0xa5, 0xe4, 0x7c, 0xec, 0x4c, 0x95,
0xaf, 0x12, 0xa0, 0xef, 0x04, 0x51, 0xe0, 0x7b, 0x11, 0xc7, 0xcf, 0x60, 0xd3, 0x89, 0x98, 0x35,
0xb7, 0x1c, 0xd7, 0x3a, 0x77, 0xb9, 0xa0, 0x2a, 0xd3, 0xaa, 0x13, 0xa9, 0x0b, 0x08, 0x1f, 0x42,
0x39, 0xc8, 0xca, 0x04, 0xe5, 0xd6, 0x7e, 0xb3, 0xb5, 0xb4, 0xba, 0x75, 0x9f, 0xb1, 0x95, 0xa8,
0xa6, 0xcb, 0x0a, 0x5c, 0x87, 0xc2, 0xdc, 0x72, 0x9d, 0x69, 0x23, 0xdf, 0x94, 0x76, 0xcb, 0x34,
0x3d, 0x28, 0x7d, 0x90, 0x93, 0x3c, 0x0c, 0x50, 0x34, 0x4c, 0xda, 0x57, 0x7b, 0x68, 0x03, 0x97,
0x41, 0x56, 0x4f, 0xd4, 0x53, 0x24, 0x61, 0x0c, 0x5b, 0x9a, 0xc9, 0x0c, 0x73, 0xc4, 0x34, 0x7d,
0x38, 0x1a, 0xd3, 0x36, 0xca, 0x25, 0xb7, 0x9d, 0xae, 0x3a, 0x42, 0x79, 0x5c, 0x83, 0xbf, 0xc8,
0x64, 0x44, 0x8c, 0xc4, 0x4f, 0x51, 0x20, 0x2b, 0x6d, 0xd8, 0x69, 0x5f, 0xbb, 0xef, 0x7e, 0x6a,
0x4f, 0xfe, 0x37, 0xec, 0x79, 0x03, 0xf5, 0x75, 0x8e, 0xcc, 0xa1, 0x2e, 0xd4, 0x16, 0x62, 0x58,
0x98, 0x81, 0x82, 0xb2, 0xba, 0xff, 0xe4, 0x11, 0x1f, 0x28, 0x0a, 0xee, 0x21, 0xca, 0x47, 0x09,
0x70, 0xf2, 0x2a, 0xfb, 0x3c, 0x8a, 0x2c, 0xfb, 0x91, 0x2e, 0x31, 0xc8, 0xe7, 0xfe, 0xf4, 0xae,
0x91, 0x13, 0x73, 0x15, 0x31, 0x7e, 0x0a, 0xa5, 0xd0, 0xba, 0x61, 0xb7, 0x33, 0x37, 0x75, 0xf2,
0xa0, 0x70, 0x69, 0xb9, 0x11, 0xa7, 0xc5, 0xd0, 0xba, 0x99, 0xcc, 0x5c, 0xdc, 0x00, 0x39, 0xbe,
0x0b, 0x78, 0x43, 0x4e, 0x54, 0x1d, 0xc8, 0x17, 0x57, 0x56, 0x4c, 0x05, 0xb2, 0xa6, 0xb9, 0xb0,
0xae, 0xf9, 0x93, 0x04, 0x3b, 0x6b, 0x1d, 0x2d, 0x35, 0x17, 0xa3, 0xd8, 0x8a, 0xaf, 0x23, 0xd1,
0xd5, 0xd6, 0xfe, 0xf3, 0x15, 0xa1, 0x3f, 0xc8, 0x5f, 0xc5, 0x86, 0xa2, 0x8e, 0x66, 0xf5, 0x4a,
0x07, 0x6a, 0x0f, 0x2e, 0xf1, 0x26, 0x94, 0x0d, 0x33, 0x5b, 0xb9, 0x8d, 0xfb, 0x2b, 0x27, 0x76,
0xd0, 0x1c, 0x75, 0x09, 0xcd, 0x32, 0x72, 0xca, 0x07, 0x09, 0xfe, 0x4d, 0xd7, 0xd9, 0x9b, 0xfe,
0x7a, 0x05, 0x70, 0xe6, 0x44, 0x3a, 0xdf, 0xd4, 0x03, 0x0c, 0x72, 0x74, 0xe5, 0xdf, 0x08, 0xeb,
0x2a, 0x54, 0xc4, 0xf8, 0x9f, 0xa5, 0x48, 0xe1, 0xd9, 0xa2, 0xe5, 0xc7, 0xfc, 0xfa, 0x1f, 0x1a,
0x0f, 0xfb, 0xc8, 0xa6, 0xfb, 0x32, 0x55, 0xaa, 0x7b, 0x73, 0x27, 0xfe, 0xb3, 0x05, 0xad, 0xa7,
0xcf, 0x63, 0xc1, 0x90, 0xf2, 0xb6, 0x8b, 0x67, 0x72, 0xf2, 0xb1, 0xfb, 0x16, 0x00, 0x00, 0xff,
0xff, 0x4e, 0x58, 0x2e, 0xb1, 0x1d, 0x05, 0x00, 0x00,
}

Some files were not shown because too many files have changed in this diff Show More