here-leslie-lau / mongo-plus Goto Github PK
View Code? Open in Web Editor NEWSecondary encapsulation based on mongo go driver
License: MIT License
Secondary encapsulation based on mongo go driver
License: MIT License
类似qmgo的CommandMonitor,比如我想在qmgo里设置一个监听每次MongoDB成功和失败操作请求的监视器来打印日志,便于维护和定位问题,在qmgo里代码类似这样:
// 创建cmdMonitor,用于打印日志
startedCommands := sync.Map{}
cmdMonitor := &event.CommandMonitor{
Started: func(_ context.Context, evt *event.CommandStartedEvent) {
startedCommands.Store(evt.RequestID, evt.Command)
},
Succeeded: func(_ context.Context, evt *event.CommandSucceededEvent) {
var commands bson.Raw
v, ok := startedCommands.Load(evt.RequestID)
if ok {
commands = v.(bson.Raw)
}
defer mLog.Sync()
mLog.Infof("\n[MongoDB] [%.3fms] [%v] %v \n", float64(evt.DurationNanos)/1e6, commands, evt.Reply)
},
Failed: func(_ context.Context, evt *event.CommandFailedEvent) {
var commands bson.Raw
v, ok := startedCommands.Load(evt.RequestID)
if ok {
commands = v.(bson.Raw)
}
defer mLog.Sync()
mLog.Fatalf("\n[MongoDB] [%.3fms] [%v] \n %v \n", float64(evt.DurationNanos)/1e6, commands, evt.Failure)
},
}
ops.SetMonitor(cmdMonitor)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.