Hello,


I was trying to deploy an API using PubSub with AppEngine but I got a "not 
an App Engine context" error, it's related to the following code:


package main 

import (
"golang.org/x/net/context"
"log"

"cloud.google.com/go/pubsub"
)

var (
ctx context.Context
pubsubClient *pubsub.Client
)  

func InitPubSub () {
ctx = context.Background()

psClient, err := pubsub.NewClient(ctx, "myproject-645411")
if err != nil {
log.Println("(init pub sub) error while creating new pubsub client:", err)

} else {
pubsubClient = psClient

}
}


So I was looking at the BackgroundContext func from the appengine package 
but it says that it only works with AppEngine flexible environment 
(standard environment seems more appropriate to my app): 
https://godoc.org/google.golang.org/appengine#BackgroundContext


Do you know if there's another function I can use? Or should I create and 
close a client for each request?


Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/81c3ddbd-ccde-48c8-a317-92445f7f3ad2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • [google-appengine]... william

Reply via email to