Giter Site home page Giter Site logo

mongo-plus's Introduction

Hi there 👋

  • 🔭 I'm open sourcing something I'm passionate about
  • 📖 I'm learning english now💪
  • I'm a gopher now😄
  • I'm a vimer🐛

Personal Blog links

Blog


Individual statistics

all-smile's GitHub stats

Homepage page View Statistics:   Homepage page View Statistics

Top Langs

mongo-plus's People

Contributors

dependabot[bot] avatar here-leslie-lau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

i-lucifer

mongo-plus's Issues

请问有类似Monitor的针对不同事件触发的监视器吗?

类似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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.