-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from asandeep/app-engine-support
Adds Google App Engine Support for neoism.
- Loading branch information
Showing
9 changed files
with
168 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) 2012-2013 Jason McVetta. This is Free Software, released under | ||
// the terms of the GPL v3. See http://www.gnu.org/copyleft/gpl.html for details. | ||
// Resist intellectual serfdom - the ownership of ideas is akin to slavery. | ||
|
||
// +build appengine | ||
|
||
package neoism | ||
|
||
import ( | ||
"log" | ||
"testing" | ||
|
||
"appengine/aetest" | ||
) | ||
|
||
func connectBench(b *testing.B) *Database { | ||
gaeContext, err := aetest.NewContext(nil) | ||
if err != nil { | ||
b.Fatal(err) | ||
} | ||
defer gaeContext.Close() | ||
|
||
log.SetFlags(log.Ltime | log.Lshortfile) | ||
db, err := Connect("http://localhost:7474/db/data", gaeContext) | ||
|
||
if err != nil { | ||
b.Fatal(err) | ||
} | ||
return db | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) 2012-2013 Jason McVetta. This is Free Software, released under | ||
// the terms of the GPL v3. See http://www.gnu.org/copyleft/gpl.html for details. | ||
// Resist intellectual serfdom - the ownership of ideas is akin to slavery. | ||
|
||
// +build !appengine | ||
|
||
package neoism | ||
|
||
import ( | ||
"log" | ||
"testing" | ||
) | ||
|
||
func connectBench(b *testing.B) *Database { | ||
log.SetFlags(log.Ltime | log.Lshortfile) | ||
db, err := Connect("http://localhost:7474/db/data") | ||
if err != nil { | ||
b.Fatal(err) | ||
} | ||
return db | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) 2012-2013 Jason McVetta. This is Free Software, released under | ||
// the terms of the GPL v3. See http://www.gnu.org/copyleft/gpl.html for details. | ||
// Resist intellectual serfdom - the ownership of ideas is akin to slavery. | ||
|
||
// +build !appengine | ||
|
||
package neoism | ||
|
||
import ( | ||
"net/http" | ||
"net/url" | ||
|
||
"github.com/jmcvetta/napping" | ||
) | ||
|
||
// Connect setups parameters for the Neo4j server | ||
// and calls ConnectWithRetry() | ||
func Connect(uri string) (*Database, error) { | ||
h := http.Header{} | ||
h.Add("User-Agent", "neoism") | ||
db := &Database{ | ||
Session: &napping.Session{ | ||
Header: &h, | ||
}, | ||
} | ||
parsedUrl, err := url.Parse(uri) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if parsedUrl.User != nil { | ||
db.Session.Userinfo = parsedUrl.User | ||
} | ||
return connectWithRetry(db, parsedUrl, 0) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (c) 2012-2013 Jason McVetta. This is Free Software, released under | ||
// the terms of the GPL v3. See http://www.gnu.org/copyleft/gpl.html for details. | ||
// Resist intellectual serfdom - the ownership of ideas is akin to slavery. | ||
|
||
// +build appengine | ||
|
||
package neoism | ||
|
||
import ( | ||
"net/http" | ||
"net/url" | ||
|
||
"appengine" | ||
"appengine/urlfetch" | ||
|
||
"github.com/jmcvetta/napping" | ||
) | ||
|
||
// Modified version of Connect that support Google App Engine. | ||
// Connect setups parameters for the Neo4j server | ||
// and calls ConnectWithRetry() | ||
func Connect(uri string, gaeContext appengine.Context) (*Database, error) { | ||
h := http.Header{} | ||
h.Add("User-Agent", "neoism") | ||
db := &Database{ | ||
Session: &napping.Session{ | ||
Header: &h, | ||
Client: urlfetch.Client(gaeContext), | ||
}, | ||
} | ||
parsedUrl, err := url.Parse(uri) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if parsedUrl.User != nil { | ||
db.Session.Userinfo = parsedUrl.User | ||
} | ||
return connectWithRetry(db, parsedUrl, 0) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (c) 2012-2013 Jason McVetta. This is Free Software, released under | ||
// the terms of the GPL v3. See http://www.gnu.org/copyleft/gpl.html for details. | ||
// Resist intellectual serfdom - the ownership of ideas is akin to slavery. | ||
|
||
// +build appengine | ||
|
||
package neoism | ||
|
||
import "appengine/aetest" | ||
|
||
func dbConnect(url string) (*Database, error) { | ||
gaeContext, err := aetest.NewContext(nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return Connect(url, gaeContext) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright (c) 2012-2013 Jason McVetta. This is Free Software, released under | ||
// the terms of the GPL v3. See http://www.gnu.org/copyleft/gpl.html for details. | ||
// Resist intellectual serfdom - the ownership of ideas is akin to slavery. | ||
|
||
// +build !appengine | ||
|
||
package neoism | ||
|
||
func dbConnect(url string) (*Database, error) { | ||
return Connect(url) | ||
} |