forked from go-mgo/mgo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
119 additions
and
114 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
// mgo - MongoDB driver for Go | ||
// | ||
// | ||
// Copyright (c) 2010-2012 - Gustavo Niemeyer <[email protected]> | ||
// | ||
// | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are met: | ||
// | ||
// modification, are permitted provided that the following conditions are met: | ||
// | ||
// 1. Redistributions of source code must retain the above copyright notice, this | ||
// list of conditions and the following disclaimer. | ||
// list of conditions and the following disclaimer. | ||
// 2. Redistributions in binary form must reproduce the above copyright notice, | ||
// this list of conditions and the following disclaimer in the documentation | ||
// and/or other materials provided with the distribution. | ||
// | ||
// and/or other materials provided with the distribution. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
|
@@ -91,13 +91,13 @@ func (socket *mongoSocket) resetNonce() { | |
op.limit = -1 | ||
op.replyFunc = func(err error, reply *replyOp, docNum int, docData []byte) { | ||
if err != nil { | ||
socket.kill(errors.New("getNonce: " + err.Error()), true) | ||
socket.kill(errors.New("getNonce: "+err.Error()), true) | ||
return | ||
} | ||
result := &getNonceResult{} | ||
err = bson.Unmarshal(docData, &result) | ||
if err != nil { | ||
socket.kill(errors.New("Failed to unmarshal nonce: " + err.Error()), true) | ||
socket.kill(errors.New("Failed to unmarshal nonce: "+err.Error()), true) | ||
return | ||
} | ||
debugf("Socket %p to %s: nonce unmarshalled: %#v", socket, socket.addr, result) | ||
|
@@ -125,7 +125,7 @@ func (socket *mongoSocket) resetNonce() { | |
} | ||
err := socket.Query(op) | ||
if err != nil { | ||
socket.kill(errors.New("resetNonce: " + err.Error()), true) | ||
socket.kill(errors.New("resetNonce: "+err.Error()), true) | ||
} | ||
} | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
// mgo - MongoDB driver for Go | ||
// | ||
// | ||
// Copyright (c) 2010-2012 - Gustavo Niemeyer <[email protected]> | ||
// | ||
// | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are met: | ||
// | ||
// modification, are permitted provided that the following conditions are met: | ||
// | ||
// 1. Redistributions of source code must retain the above copyright notice, this | ||
// list of conditions and the following disclaimer. | ||
// list of conditions and the following disclaimer. | ||
// 2. Redistributions in binary form must reproduce the above copyright notice, | ||
// this list of conditions and the following disclaimer in the documentation | ||
// and/or other materials provided with the distribution. | ||
// | ||
// and/or other materials provided with the distribution. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
|
@@ -27,8 +27,8 @@ | |
package mgo_test | ||
|
||
import ( | ||
. "launchpad.net/gocheck" | ||
"labix.org/v2/mgo" | ||
. "launchpad.net/gocheck" | ||
"sync" | ||
) | ||
|
||
|
@@ -146,17 +146,17 @@ func (s *S) TestAuthUpsertUser(c *C) { | |
ruser := &mgo.User{ | ||
Username: "myruser", | ||
Password: "mypass", | ||
Roles: []mgo.Role{mgo.RoleRead}, | ||
Roles: []mgo.Role{mgo.RoleRead}, | ||
} | ||
rwuser := &mgo.User{ | ||
Username: "myrwuser", | ||
Password: "mypass", | ||
Roles: []mgo.Role{mgo.RoleReadWrite}, | ||
Roles: []mgo.Role{mgo.RoleReadWrite}, | ||
} | ||
rwuserother := &mgo.User{ | ||
Username: "myrwuser", | ||
Username: "myrwuser", | ||
UserSource: "mydb", | ||
Roles: []mgo.Role{mgo.RoleRead}, | ||
Roles: []mgo.Role{mgo.RoleRead}, | ||
} | ||
|
||
err = mydb.UpsertUser(ruser) | ||
|
@@ -209,8 +209,8 @@ func (s *S) TestAuthUpserUserOtherDBRoles(c *C) { | |
c.Assert(err, IsNil) | ||
|
||
ruser := &mgo.User{ | ||
Username: "myruser", | ||
Password: "mypass", | ||
Username: "myruser", | ||
Password: "mypass", | ||
OtherDBRoles: map[string][]mgo.Role{"mydb": []mgo.Role{mgo.RoleRead}}, | ||
} | ||
|
||
|
@@ -243,9 +243,9 @@ func (s *S) TestAuthUpserUserUnsetFields(c *C) { | |
|
||
// Insert a user with most fields set. | ||
user := &mgo.User{ | ||
Username: "myruser", | ||
Password: "mypass", | ||
Roles: []mgo.Role{mgo.RoleRead}, | ||
Username: "myruser", | ||
Password: "mypass", | ||
Roles: []mgo.Role{mgo.RoleRead}, | ||
OtherDBRoles: map[string][]mgo.Role{"mydb": []mgo.Role{mgo.RoleRead}}, | ||
} | ||
err = admindb.UpsertUser(user) | ||
|
@@ -254,7 +254,7 @@ func (s *S) TestAuthUpserUserUnsetFields(c *C) { | |
|
||
// Now update the user with few things set. | ||
user = &mgo.User{ | ||
Username: "myruser", | ||
Username: "myruser", | ||
UserSource: "mydb", | ||
} | ||
err = admindb.UpsertUser(user) | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
// mgo - MongoDB driver for Go | ||
// | ||
// | ||
// Copyright (c) 2010-2012 - Gustavo Niemeyer <[email protected]> | ||
// | ||
// | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are met: | ||
// | ||
// modification, are permitted provided that the following conditions are met: | ||
// | ||
// 1. Redistributions of source code must retain the above copyright notice, this | ||
// list of conditions and the following disclaimer. | ||
// list of conditions and the following disclaimer. | ||
// 2. Redistributions in binary form must reproduce the above copyright notice, | ||
// this list of conditions and the following disclaimer in the documentation | ||
// and/or other materials provided with the distribution. | ||
// | ||
// and/or other materials provided with the distribution. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
|
@@ -29,9 +29,9 @@ package mgo_test | |
import ( | ||
"fmt" | ||
"io" | ||
. "launchpad.net/gocheck" | ||
"labix.org/v2/mgo" | ||
"labix.org/v2/mgo/bson" | ||
. "launchpad.net/gocheck" | ||
"net" | ||
"strings" | ||
"time" | ||
|
@@ -766,7 +766,7 @@ func (s *S) TestTopologySyncWithSlaveSeed(c *C) { | |
c.Assert(result.Ok, Equals, true) | ||
|
||
// One connection to each during discovery. Master | ||
// socket recycled for insert. | ||
// socket recycled for insert. | ||
stats := mgo.GetStats() | ||
c.Assert(stats.MasterConns, Equals, 1) | ||
c.Assert(stats.SlaveConns, Equals, 2) | ||
|
@@ -1002,7 +1002,10 @@ func (s *S) TestRemovalOfClusterMember(c *C) { | |
c.Fatalf("Test started with bad cluster state: %v", master.LiveServers()) | ||
} | ||
|
||
result := &struct{ IsMaster bool; Me string }{} | ||
result := &struct { | ||
IsMaster bool | ||
Me string | ||
}{} | ||
slave := master.Copy() | ||
slave.SetMode(mgo.Monotonic, true) // Monotonic can hold a non-master socket persistently. | ||
err = slave.Run("isMaster", result) | ||
|
@@ -1149,7 +1152,7 @@ func (s *S) TestCustomDial(c *C) { | |
} | ||
info := mgo.DialInfo{ | ||
Addrs: []string{"localhost:40012"}, | ||
Dial: dial, | ||
Dial: dial, | ||
} | ||
|
||
// Use hostname here rather than IP, to make things trickier. | ||
|
@@ -1288,4 +1291,3 @@ func (s *S) TestNearestSecondary(c *C) { | |
c.Assert(hostPort(result.Host), Equals, hostPort(rs1b)) | ||
} | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
// mgo - MongoDB driver for Go | ||
// | ||
// | ||
// Copyright (c) 2010-2012 - Gustavo Niemeyer <[email protected]> | ||
// | ||
// | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are met: | ||
// | ||
// modification, are permitted provided that the following conditions are met: | ||
// | ||
// 1. Redistributions of source code must retain the above copyright notice, this | ||
// list of conditions and the following disclaimer. | ||
// list of conditions and the following disclaimer. | ||
// 2. Redistributions in binary form must reproduce the above copyright notice, | ||
// this list of conditions and the following disclaimer in the documentation | ||
// and/or other materials provided with the distribution. | ||
// | ||
// and/or other materials provided with the distribution. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
|
@@ -72,10 +72,10 @@ type GridFile struct { | |
} | ||
|
||
type gfsFile struct { | ||
Id interface{} "_id" | ||
ChunkSize int "chunkSize" | ||
UploadDate time.Time "uploadDate" | ||
Length int64 ",minsize" | ||
Id interface{} "_id" | ||
ChunkSize int "chunkSize" | ||
UploadDate time.Time "uploadDate" | ||
Length int64 ",minsize" | ||
MD5 string | ||
Filename string ",omitempty" | ||
ContentType string "contentType,omitempty" | ||
|
@@ -165,7 +165,7 @@ func (gfs *GridFS) Create(name string) (file *GridFile, err error) { | |
// completed successfully. | ||
// | ||
// The following example will print the first 8192 bytes from the file: | ||
// | ||
// | ||
// func check(err os.Error) { | ||
// if err != nil { | ||
// panic(err.String()) | ||
|
@@ -214,7 +214,7 @@ func (gfs *GridFS) OpenId(id interface{}) (file *GridFile, err error) { | |
// completed successfully. | ||
// | ||
// The following example will print the first 8192 bytes from the file: | ||
// | ||
// | ||
// file, err := db.GridFS("fs").Open("myfile.txt") | ||
// check(err) | ||
// b := make([]byte, 8192) | ||
|
@@ -307,7 +307,7 @@ func (gfs *GridFS) OpenNext(iter *Iter, file **GridFile) bool { | |
// | ||
// files := db.C("fs" + ".files") | ||
// iter := files.Find(nil).Iter() | ||
// | ||
// | ||
func (gfs *GridFS) Find(query interface{}) *Query { | ||
return gfs.Files.Find(query) | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
// mgo - MongoDB driver for Go | ||
// | ||
// | ||
// Copyright (c) 2010-2012 - Gustavo Niemeyer <[email protected]> | ||
// | ||
// | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are met: | ||
// | ||
// modification, are permitted provided that the following conditions are met: | ||
// | ||
// 1. Redistributions of source code must retain the above copyright notice, this | ||
// list of conditions and the following disclaimer. | ||
// list of conditions and the following disclaimer. | ||
// 2. Redistributions in binary form must reproduce the above copyright notice, | ||
// this list of conditions and the following disclaimer in the documentation | ||
// and/or other materials provided with the distribution. | ||
// | ||
// and/or other materials provided with the distribution. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
|
@@ -28,9 +28,9 @@ package mgo_test | |
|
||
import ( | ||
"io" | ||
. "launchpad.net/gocheck" | ||
"labix.org/v2/mgo" | ||
"labix.org/v2/mgo/bson" | ||
. "launchpad.net/gocheck" | ||
"os" | ||
"time" | ||
) | ||
|
@@ -161,7 +161,7 @@ func (s *S) TestGridFSFileDetails(c *C) { | |
ud := file.UploadDate() | ||
now := time.Now() | ||
c.Assert(ud.Before(now), Equals, true) | ||
c.Assert(ud.After(now.Add(-3 * time.Second)), Equals, true) | ||
c.Assert(ud.After(now.Add(-3*time.Second)), Equals, true) | ||
|
||
result := M{} | ||
err = db.C("fs.files").Find(nil).One(result) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
// mgo - MongoDB driver for Go | ||
// | ||
// | ||
// Copyright (c) 2010-2012 - Gustavo Niemeyer <[email protected]> | ||
// | ||
// | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are met: | ||
// | ||
// modification, are permitted provided that the following conditions are met: | ||
// | ||
// 1. Redistributions of source code must retain the above copyright notice, this | ||
// list of conditions and the following disclaimer. | ||
// list of conditions and the following disclaimer. | ||
// 2. Redistributions in binary form must reproduce the above copyright notice, | ||
// this list of conditions and the following disclaimer in the documentation | ||
// and/or other materials provided with the distribution. | ||
// | ||
// and/or other materials provided with the distribution. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
// mgo - MongoDB driver for Go | ||
// | ||
// | ||
// Copyright (c) 2010-2012 - Gustavo Niemeyer <[email protected]> | ||
// | ||
// | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are met: | ||
// | ||
// modification, are permitted provided that the following conditions are met: | ||
// | ||
// 1. Redistributions of source code must retain the above copyright notice, this | ||
// list of conditions and the following disclaimer. | ||
// list of conditions and the following disclaimer. | ||
// 2. Redistributions in binary form must reproduce the above copyright notice, | ||
// this list of conditions and the following disclaimer in the documentation | ||
// and/or other materials provided with the distribution. | ||
// | ||
// and/or other materials provided with the distribution. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
|
Oops, something went wrong.