$69 GRAYBYTE WORDPRESS FILE MANAGER $47

SERVER : in-mum-web1330.main-hosting.eu #1 SMP Mon Feb 10 22:45:17 UTC 2025
SERVER IP : 147.79.69.169 | ADMIN IP 216.73.216.215
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/go/pkg/mod/go.mongodb.org/mongo-driver@v1.11.3/event/

HOME
Current File : /opt/go/pkg/mod/go.mongodb.org/mongo-driver@v1.11.3/event//examples_test.go
// Copyright (C) MongoDB, Inc. 2017-present.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

package event_test

import (
	"context"
	"log"

	"go.mongodb.org/mongo-driver/bson"
	"go.mongodb.org/mongo-driver/event"
	"go.mongodb.org/mongo-driver/mongo"
	"go.mongodb.org/mongo-driver/mongo/options"
)

// Event examples

// CommandMonitor represents a monitor that is triggered for different events.
func ExampleCommandMonitor() {
	// If the application makes multiple concurrent requests, it would have to
	// use a concurrent map like sync.Map
	startedCommands := make(map[int64]bson.Raw)
	cmdMonitor := &event.CommandMonitor{
		Started: func(_ context.Context, evt *event.CommandStartedEvent) {
			startedCommands[evt.RequestID] = evt.Command
		},
		Succeeded: func(_ context.Context, evt *event.CommandSucceededEvent) {
			log.Printf("Command: %v Reply: %v\n",
				startedCommands[evt.RequestID],
				evt.Reply,
			)
		},
		Failed: func(_ context.Context, evt *event.CommandFailedEvent) {
			log.Printf("Command: %v Failure: %v\n",
				startedCommands[evt.RequestID],
				evt.Failure,
			)
		},
	}
	clientOpts := options.Client().ApplyURI("mongodb://localhost:27017").SetMonitor(cmdMonitor)
	client, err := mongo.Connect(context.Background(), clientOpts)
	if err != nil {
		log.Fatal(err)
	}
	defer func() {
		if err = client.Disconnect(context.TODO()); err != nil {
			log.Fatal(err)
		}
	}()
}

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
25 Jan 2024 4.43 PM
root / root
0555
doc.go
2.56 KB
25 Jan 2024 4.43 PM
root / root
0444
examples_test.go
1.537 KB
25 Jan 2024 4.43 PM
root / root
0444
monitoring.go
7.521 KB
25 Jan 2024 4.43 PM
root / root
0444

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF