Documentation ¶
Index ¶
- func ConvertJSONtoBSON(document string) interface{}
- func ObjectIDToString(oid primitive.ObjectID) string
- func ObjectIDsToString(oids []interface{}) []string
- type MongoDocument
- type MongoLoad
- func (m *MongoLoad) Init(ctx context.Context, opts *MongoLoadOptions) error
- func (m *MongoLoad) InsertDocument(document interface{}) (string, bool)
- func (m *MongoLoad) InsertDocuments(documents []interface{}) ([]string, bool)
- func (m *MongoLoad) InsertOneRoutine(docs chan interface{}, waitGroup *sync.WaitGroup)
- func (m *MongoLoad) ReadDocument(id string) bson.Raw
- func (m *MongoLoad) ReadOneRoutine(waitGroup *sync.WaitGroup)
- type MongoLoadOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertJSONtoBSON ¶
func ConvertJSONtoBSON(document string) interface{}
ConvertJSONtoBSON converts a JSON string to a BSON object
func ObjectIDToString ¶
ObjectIDToString converts a mongo ObjectID to a string representation of the hex value.
func ObjectIDsToString ¶
func ObjectIDsToString(oids []interface{}) []string
ObjectIDsToString converts an array of ObjectID primitives to their string representations.
Types ¶
type MongoDocument ¶
MongoDocument is the structure we stuff in a queue to read it later
type MongoLoad ¶
type MongoLoad struct {
// contains filtered or unexported fields
}
MongoLoad type for managing load tests to a mongo cluster
func (*MongoLoad) Init ¶
func (m *MongoLoad) Init(ctx context.Context, opts *MongoLoadOptions) error
Init Initialize a new connection to mongo and set the database If Init fails to initialize a database then all other mongo operations will fail.
func (*MongoLoad) InsertDocument ¶
InsertDocument attempts to insert a single document into a mongo collection.
The method returns an OperationResult and string with the object id of the inserted document. If the operation was unsuccessful the string will be an empty string.
document is expected to be a BSON object
func (*MongoLoad) InsertDocuments ¶
InsertDocuments attempts to insert a batch of documents as a single operation. This method uses the mongo InsertMany operation.
The document argument is expected to be a slice of BSON objects.
This method returns an OperationResult and slice of ObjectsIDs if the operation was successful. If the operation failed the slice will be nil. ObjectIDs are converted to hex and represented as strings if the _id is an ObjectID
func (*MongoLoad) InsertOneRoutine ¶
InsertOneRoutine writes documents in a loop until the duration has expired or a request to exit.
InsertOne expects a document channel
func (*MongoLoad) ReadDocument ¶
ReadDocument finds a document by _id and returns the result
func (*MongoLoad) ReadOneRoutine ¶
ReadOneRoutine reads documents based on queue items until test duration has expired.
type MongoLoadOptions ¶
type MongoLoadOptions struct { Version string ConnectionString string Database string Collection string SocketTimeout time.Duration ServerConnectTimeout time.Duration ConnectionTimeout time.Duration TestDuration time.Duration MaxPoolSize uint16 ReadPreference string EnableJournal bool WriteAcks int Queue *queue.Queue PrometheusRegistry *prometheus.Registry }
MongoLoadOptions type for containing load testing options