Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( WithReplicaSet = func(n string) ServerOption { return func(s *Server) { s.replSet = n } } WithPort = func(p int) ServerOption { return func(s *Server) { s.port = p } } WithDatabaseDir = func(d string) ServerOption { return func(s *Server) { s.dbDir = d } } )
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents a running MongoDB server.
func Start ¶
Start runs a MongoDB server of the given version using a random free port and returns the Server.
func StartWithOptions ¶
StartWithOptions runs a MongoDB server of the given version, with 0 or more options as defined: WithReplicaSet, WithPort, WithDatabaseDir
If an empty string is provided in WithReplicaSet, the server is started as a standalone server If a port value of 0 is provided in WithPort, the server is started on a random port If an empty string is provided in WithDatabaseDir, the server is started with a random temporary directory
func StartWithReplicaSet ¶
StartWithReplicaSet runs a MongoDB server (of the given version) as a replica set (with the given name). If a name is not given, a default name of "rs0" is used. The server uses a random free port and returns the Server
func (*Server) ReplicaSet ¶
ReplicaSet returns the Replica Set name being used by the server (cluster of 1)
type ServerOption ¶
type ServerOption func(*Server)
ServerOption defines the template function for defining options that may be used to configure the server The options available are given by the exported variables: WithPort, WithReplicaSet, WithDatabaseDir