Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ install:

# Google App Engine dependencies
- cd ..
- wget https://storage.googleapis.com/appengine-sdks/featured/go_appengine_sdk_linux_amd64-1.9.23.zip
- unzip -q go_appengine_sdk_linux_amd64-1.9.23.zip
- wget https://storage.googleapis.com/appengine-sdks/featured/go_appengine_sdk_linux_amd64-1.9.40.zip
- unzip -q go_appengine_sdk_linux_amd64-1.9.40.zip
- export PATH=$PATH:$PWD/go_appengine/
- $PWD/go_appengine/goapp get github.com/stretchr/testify/require github.com/pborman/uuid golang.org/x/net/context # FIXME
- cd cayley

script:
Expand Down
4 changes: 4 additions & 0 deletions appengine/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/appengine
/docs
/static
/templates
59 changes: 59 additions & 0 deletions appengine/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# About appengine

This directory contains a appengine deployable cayley graph instance.

# Running/testing traditional appengine locally

Install the latest appengine sdk, and ensure that your local version of go
matches the same version obtained from `goapp`.

Note: if you use a more recent version of Go locally, `goapp` get might
accidentally copy the wrong files from the local `$GOPATH`.

```sh
$ cd $GOPATH/src/github.com/cayleygraph/cayley/appengine

# check go version
$ go version

# check goapp version
$ goapp version

# install dependencies
$ goapp get

# ensure that goapp can build
$ goapp build

# test locally
$ goapp serve
```

# Running/testing flexible appengine locally

The latest appengine flexible environment can be tested instead of the
traditional environment by doing the following:

```sh
# calls ./sync-assets.sh
$ go generate

$ goapp serve app.flexible.yaml
```

# Deploying to traditional appengine environment
```sh
$ goapp deploy -version 1 -application <MY_PROJECT_ID>
```

# Deploying to flexible appengine environment
```sh
# install aedeploy if not installed
$ go get -u google.golang.org/appengine/cmd/aedeploy

# calls ./sync-assets.sh
$ go generate

# deploy
$ aedeploy gcloud app deploy app.flexible.yaml
```
2 changes: 2 additions & 0 deletions appengine/app.flexible.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
runtime: go
vm: true
4 changes: 1 addition & 3 deletions appengine/app.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
application: cayley-test
version: 1
runtime: go
api_version: go1.6.3
api_version: go1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to unpin it from 1.6.3?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


handlers:
- url: /.*
Expand Down
2 changes: 1 addition & 1 deletion appengine/appengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// +build appengine
// +build appengine appenginevm

package main

Expand Down
10 changes: 10 additions & 0 deletions appengine/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// +build appenginevm
package main

//go:generate ./sync-assets.sh

import "google.golang.org/appengine"

func main() {
appengine.Main()
}
5 changes: 5 additions & 0 deletions appengine/sync-assets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

SRC="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

rsync -avP --delete $GOPATH/src/github.com/cayleygraph/cayley/{static,docs,templates} $SRC/
38 changes: 28 additions & 10 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions graph/gaedatastore/iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// +build appengine

package gaedatastore

import (
"fmt"

"github.com/cayleygraph/cayley/graph"
"github.com/cayleygraph/cayley/graph/iterator"
"github.com/cayleygraph/cayley/quad"

"appengine/datastore"
"github.com/cayleygraph/cayley/clog"
"google.golang.org/appengine/datastore"
)

type Iterator struct {
Expand Down
17 changes: 8 additions & 9 deletions graph/gaedatastore/quadstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// +build appengine

package gaedatastore

import (
Expand All @@ -24,8 +22,9 @@ import (

"github.com/cayleygraph/cayley/clog"

"appengine"
"appengine/datastore"
"golang.org/x/net/context"
"google.golang.org/appengine"
"google.golang.org/appengine/datastore"

"github.com/cayleygraph/cayley/graph"
"github.com/cayleygraph/cayley/graph/iterator"
Expand All @@ -44,7 +43,7 @@ var (
)

type QuadStore struct {
context appengine.Context
context context.Context
}

type MetadataEntry struct {
Expand Down Expand Up @@ -156,7 +155,7 @@ func (qs *QuadStore) checkValid(k *datastore.Key) (bool, error) {
return true, nil
}

func getContext(opts graph.Options) (appengine.Context, error) {
func getContext(opts graph.Options) (context.Context, error) {
req := opts["HTTPRequest"].(*http.Request)
if req == nil {
err := errors.New("HTTP Request needed")
Expand Down Expand Up @@ -270,7 +269,7 @@ func (qs *QuadStore) updateNodes(in []graph.Delta) (int64, error) {
for i := 0; i < len(nodeDeltas); i += 5 {
j := int(math.Min(float64(len(nodeDeltas)-i), 5))
foundNodes := make([]NodeEntry, j)
err := datastore.RunInTransaction(qs.context, func(c appengine.Context) error {
err := datastore.RunInTransaction(qs.context, func(c context.Context) error {
err := datastore.GetMulti(c, keys[i:i+j], foundNodes)
// Sift through for errors
if me, ok := err.(appengine.MultiError); ok {
Expand Down Expand Up @@ -308,7 +307,7 @@ func (qs *QuadStore) updateQuads(in []graph.Delta) (int64, error) {
for i := 0; i < len(in); i += 5 {
// Find the closest batch of 5
j := int(math.Min(float64(len(in)-i), 5))
err := datastore.RunInTransaction(qs.context, func(c appengine.Context) error {
err := datastore.RunInTransaction(qs.context, func(c context.Context) error {
foundQuads := make([]QuadEntry, j)
// We don't process errors from GetMulti as they don't mean anything,
// we've handled existing quad conflicts above and we overwrite everything again anyways
Expand Down Expand Up @@ -343,7 +342,7 @@ func (qs *QuadStore) updateQuads(in []graph.Delta) (int64, error) {
func (qs *QuadStore) updateMetadata(quadsAdded int64, nodesAdded int64) error {
key := qs.createKeyForMetadata()
foundMetadata := new(MetadataEntry)
err := datastore.RunInTransaction(qs.context, func(c appengine.Context) error {
err := datastore.RunInTransaction(qs.context, func(c context.Context) error {
err := datastore.Get(c, key, foundMetadata)
if err != nil && err != datastore.ErrNoSuchEntity {
clog.Errorf("Error: %v", err)
Expand Down
3 changes: 1 addition & 2 deletions graph/gaedatastore/quadstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// +build appengine

package gaedatastore

Expand All @@ -24,7 +23,7 @@ import (
"github.com/cayleygraph/cayley/writer"
"github.com/stretchr/testify/require"

"appengine/aetest"
"google.golang.org/appengine/aetest"
)

// This is a simple test graph.
Expand Down