File size: 3,174 Bytes
9756872
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WaitingForSuitableServerEvent = exports.ServerSelectionSucceededEvent = exports.ServerSelectionFailedEvent = exports.ServerSelectionStartedEvent = exports.ServerSelectionEvent = void 0;
const utils_1 = require(".././utils");
const constants_1 = require("../constants");
/**
 * The base export class for all logs published from server selection
 * @internal
 * @category Log Type
 */
class ServerSelectionEvent {
    /** @internal */
    constructor(selector, topologyDescription, operation) {
        this.selector = selector;
        this.operation = operation;
        this.topologyDescription = topologyDescription;
    }
}
exports.ServerSelectionEvent = ServerSelectionEvent;
/**
 * An event published when server selection starts
 * @internal
 * @category Event
 */
class ServerSelectionStartedEvent extends ServerSelectionEvent {
    /** @internal */
    constructor(selector, topologyDescription, operation) {
        super(selector, topologyDescription, operation);
        /** @internal */
        this.name = constants_1.SERVER_SELECTION_STARTED;
        this.message = 'Server selection started';
    }
}
exports.ServerSelectionStartedEvent = ServerSelectionStartedEvent;
/**
 * An event published when a server selection fails
 * @internal
 * @category Event
 */
class ServerSelectionFailedEvent extends ServerSelectionEvent {
    /** @internal */
    constructor(selector, topologyDescription, error, operation) {
        super(selector, topologyDescription, operation);
        /** @internal */
        this.name = constants_1.SERVER_SELECTION_FAILED;
        this.message = 'Server selection failed';
        this.failure = error;
    }
}
exports.ServerSelectionFailedEvent = ServerSelectionFailedEvent;
/**
 * An event published when server selection succeeds
 * @internal
 * @category Event
 */
class ServerSelectionSucceededEvent extends ServerSelectionEvent {
    /** @internal */
    constructor(selector, topologyDescription, address, operation) {
        super(selector, topologyDescription, operation);
        /** @internal */
        this.name = constants_1.SERVER_SELECTION_SUCCEEDED;
        this.message = 'Server selection succeeded';
        const { host, port } = utils_1.HostAddress.fromString(address).toHostPort();
        this.serverHost = host;
        this.serverPort = port;
    }
}
exports.ServerSelectionSucceededEvent = ServerSelectionSucceededEvent;
/**
 * An event published when server selection is waiting for a suitable server to become available
 * @internal
 * @category Event
 */
class WaitingForSuitableServerEvent extends ServerSelectionEvent {
    /** @internal */
    constructor(selector, topologyDescription, remainingTimeMS, operation) {
        super(selector, topologyDescription, operation);
        /** @internal */
        this.name = constants_1.WAITING_FOR_SUITABLE_SERVER;
        this.message = 'Waiting for suitable server to become available';
        this.remainingTimeMS = remainingTimeMS;
    }
}
exports.WaitingForSuitableServerEvent = WaitingForSuitableServerEvent;
//# sourceMappingURL=server_selection_events.js.map