Ejemplo n.º 1
0
func ExampleOpLog_Append() {
	ol, err := oplog.New("mongodb://localhost/oplog", 1048576)
	if err != nil {
		log.Fatal(err)
	}
	op := oplog.NewOperation("insert", time.Now(), "123", "user", nil)
	ol.Append(op)
}
Ejemplo n.º 2
0
func ExampleOpLog_Ingest() {
	ol, err := oplog.New("mongodb://localhost/oplog", 1048576)
	if err != nil {
		log.Fatal(err)
	}
	ops := make(chan *oplog.Operation)
	done := make(chan bool, 1)
	go ol.Ingest(ops, nil)
	// Insert a large number of operations
	for i := 0; i < 1000; i++ {
		ops <- oplog.NewOperation("insert", time.Now(), strconv.FormatInt(int64(i), 10), "user", nil)
	}
	done <- true
}