Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

converting to the new appengine packages #1

Merged
merged 1 commit into from
Feb 4, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 5 additions & 6 deletions amqp.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ import (
"time"

"github.com/streadway/amqp"

"appengine"
"appengine/socket"
"golang.org/x/net/context"
"google.golang.org/appengine/socket"
)

const (
defaultHeartbeat = 10 * time.Second
defaultConnectionTimeout = 30 * time.Second
)

func appEngineDial(c appengine.Context) func(network, addr string) (net.Conn, error) {
func appEngineDial(c context.Context) func(network, addr string) (net.Conn, error) {
return func(network, addr string) (net.Conn, error) {
conn, err := socket.DialTimeout(c, network, addr, defaultConnectionTimeout)
if err != nil {
Expand All @@ -30,7 +29,7 @@ func appEngineDial(c appengine.Context) func(network, addr string) (net.Conn, er
}
}

func Dialer(c appengine.Context) func(url string) (*amqp.Connection, error) {
func Dialer(c context.Context) func(url string) (*amqp.Connection, error) {
return func(url string) (*amqp.Connection, error) {
return amqp.DialConfig(url, amqp.Config{
Heartbeat: defaultHeartbeat,
Expand All @@ -39,6 +38,6 @@ func Dialer(c appengine.Context) func(url string) (*amqp.Connection, error) {
}
}

func Dial(c appengine.Context, url string) (*amqp.Connection, error) {
func Dial(c context.Context, url string) (*amqp.Connection, error) {
return Dialer(c)(url)
}