-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathend_sessions.ts
More file actions
42 lines (36 loc) · 1.12 KB
/
end_sessions.ts
File metadata and controls
42 lines (36 loc) · 1.12 KB
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
import {
type ClientSession,
type Connection,
type ServerCommandOptions,
type ServerSessionId,
type TimeoutContext
} from '..';
import { type Document } from '../bson';
import { MongoDBResponse } from '../cmap/wire_protocol/responses';
import { ReadPreference } from '../read_preference';
import { MongoDBNamespace } from '../utils';
import { AbstractOperation } from './operation';
export class EndSessionsOperation extends AbstractOperation<void> {
override ns = MongoDBNamespace.fromString('admin.$cmd');
override SERVER_COMMAND_RESPONSE_TYPE = MongoDBResponse;
private sessions: Array<ServerSessionId>;
constructor(sessions: Array<ServerSessionId>) {
super();
this.sessions = sessions;
}
override buildCommand(_connection: Connection, _session?: ClientSession): Document {
return {
endSessions: this.sessions
};
}
override buildOptions(timeoutContext: TimeoutContext): ServerCommandOptions {
return {
timeoutContext,
readPreference: ReadPreference.primaryPreferred,
noResponse: true
};
}
override get commandName(): string {
return 'endSessions';
}
}