Skip to content

Commit

Permalink
renamed
Browse files Browse the repository at this point in the history
  • Loading branch information
primalmotion committed Dec 6, 2018
1 parent 5da0e9c commit 2d20ef2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion context.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type WriteConsistency string
// Various values for Consistency
const (
WriteConsistencyDefault WriteConsistency = "default"
WriteConsistencyLow WriteConsistency = "low"
WriteConsistencyNone WriteConsistency = "none"
WriteConsistencyStrong WriteConsistency = "strong"
WriteConsistencyStrongest WriteConsistency = "strongest"
)
Expand Down
14 changes: 4 additions & 10 deletions manipmongo/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,21 +134,15 @@ func convertReadConsistency(c manipulate.ReadConsistency) mgo.Mode {
}
}

var (
defaultSafety = &mgo.Safe{}
strongSafety = &mgo.Safe{WMode: "majority"}
strongestSafety = &mgo.Safe{WMode: "majority", J: true}
)

func convertWriteConsistency(c manipulate.WriteConsistency) *mgo.Safe {
switch c {
case manipulate.WriteConsistencyLow:
case manipulate.WriteConsistencyNone:
return nil
case manipulate.WriteConsistencyStrong:
return strongSafety
return &mgo.Safe{WMode: "majority"}
case manipulate.WriteConsistencyStrongest:
return strongestSafety
return &mgo.Safe{WMode: "majority", J: true}
default:
return defaultSafety
return &mgo.Safe{}
}
}
4 changes: 2 additions & 2 deletions manipmongo/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ func Test_convertWriteConsistency(t *testing.T) {
want *mgo.Safe
}{
{
"low",
args{manipulate.WriteConsistencyLow},
"none",
args{manipulate.WriteConsistencyNone},
nil,
},
{
Expand Down

0 comments on commit 2d20ef2

Please sign in to comment.