Skip to content

Instantly share code, notes, and snippets.

@frame-lang
Created May 31, 2022 04:34
Show Gist options
  • Save frame-lang/5a0d41006c06c4e489bc4c7832da02c8 to your computer and use it in GitHub Desktop.
Save frame-lang/5a0d41006c06c4e489bc4c7832da02c8 to your computer and use it in GitHub Desktop.
func init() {
// For testing
cloudFunctionID = strconv.FormatInt(time.Now().UTC().UnixNano(), 10)
log.Println("A new cloud function is being inilialized: ", cloudFunctionID)
// err is pre-declared to avoid shadowing client.
var err error
// client is initialized with context.Background() because it should
// persist between function invocations.
client, err = pubsub.NewClient(ctx, os.Getenv("PROJECTID"))
if err != nil {
log.Fatalf("pubsub.NewClient: %v", err)
}
topic = client.Topic(os.Getenv("TOPICID"))
// Initialize Redis
var redisError error
redisPool, redisError = initializeRedis()
if redisError != nil {
log.Printf("initializeRedis: %v", err)
return
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment