Connect sign-up to Sendico Facts intake (#46)
This commit is contained in:
1 parent
30f0455122
commit
a584c8189a
40 files changed
+1616
-35
No files matched your search
@@ -0,0 +1,25 @@
|
||||
package source
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.mongodb.org/mongo-driver/v2/mongo"
|
||||
"go.mongodb.org/mongo-driver/v2/mongo/options"
|
||||
"go.mongodb.org/mongo-driver/v2/mongo/readconcern"
|
||||
"go.mongodb.org/mongo-driver/v2/mongo/readpref"
|
||||
"go.mongodb.org/mongo-driver/v2/mongo/writeconcern"
|
||||
)
|
||||
|
||||
type majority struct{ Source }
|
||||
|
||||
// Majority retains the source's lease and transaction lifecycle while requiring
|
||||
// durable writes and primary majority reads for externally visible handoffs.
|
||||
func Majority(database Source) Source { return &majority{Source: database} }
|
||||
|
||||
func (s *majority) Acquire(ctx context.Context) (*mongo.Database, context.Context, func(), error) {
|
||||
database, scoped, release, err := s.Source.Acquire(ctx)
|
||||
if err != nil {
|
||||
return nil, scoped, release, err
|
||||
}
|
||||
return database.Client().Database(database.Name(), options.Database().SetWriteConcern(writeconcern.Majority()).SetReadConcern(readconcern.Majority()).SetReadPreference(readpref.Primary())), scoped, release, nil
|
||||
}
|
||||
Reference in new issue
Block a user