Created
May 31, 2022 04:34
-
-
Save frame-lang/5a0d41006c06c4e489bc4c7832da02c8 to your computer and use it in GitHub Desktop.
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
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