Created
August 28, 2019 19:59
-
-
Save rusenask/f77cab7d936636bf9424d9fd1d8c3bfd 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 NewFirestoreBinManager(opts *FirestoreBinManagerOpts) (*FirestoreBinManager, error) { | |
ctx := context.Background() | |
var options []option.ClientOption | |
if opts.CredsFile != "" { | |
options = append(options, option.WithCredentialsFile(opts.CredsFile)) | |
} | |
// credentials file option is optional, by default it will use GOOGLE_APPLICATION_CREDENTIALS | |
// environment variable, this is a default method to connect to Google services | |
client, err := firestore.NewClient(ctx, opts.ProjectID, options...) | |
if err != nil { | |
return nil, err | |
} | |
return &FirestoreBinManager{ | |
binsCollection: opts.BinsCollection, // our bins collection name | |
reqsCollection: opts.ReqsCollection, // our requests collection name | |
client: client, | |
pubsub: opts.Pubsub, | |
logger: opts.Logger, | |
}, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment