Skip to content

Instantly share code, notes, and snippets.

@rusenask
Created August 28, 2019 19:59
Show Gist options
  • Save rusenask/f77cab7d936636bf9424d9fd1d8c3bfd to your computer and use it in GitHub Desktop.
Save rusenask/f77cab7d936636bf9424d9fd1d8c3bfd to your computer and use it in GitHub Desktop.
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