1 |
|
2 |
|
3 |
|
4 | import { EmitterContract } from '@ioc:Adonis/Core/Event';
|
5 | import { LoggerContract } from '@ioc:Adonis/Core/Logger';
|
6 | import { HealthReportEntry } from '@ioc:Adonis/Core/HealthCheck';
|
7 | import { ReportNode, ConnectionNode, ConnectionConfig, ConnectionManagerContract } from '@ioc:Adonis/Lucid/Database';
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | export declare class ConnectionManager implements ConnectionManagerContract {
|
14 | private logger;
|
15 | private emitter;
|
16 | |
17 |
|
18 |
|
19 | connections: ConnectionManagerContract['connections'];
|
20 | |
21 |
|
22 |
|
23 |
|
24 | private orphanConnections;
|
25 | constructor(logger: LoggerContract, emitter: EmitterContract);
|
26 | /**
|
27 | * Handles disconnection of a connection
|
28 | */
|
29 | private handleDisconnect;
|
30 | /**
|
31 | * Handles event when a new connection is added
|
32 | */
|
33 | private handleConnect;
|
34 | /**
|
35 | * Monitors a given connection by listening for lifecycle events
|
36 | */
|
37 | private monitorConnection;
|
38 | /**
|
39 | * Add a named connection with it's configuration. Make sure to call `connect`
|
40 | * before using the connection to make database queries.
|
41 | */
|
42 | add(connectionName: string, config: ConnectionConfig): void;
|
43 | /**
|
44 | * Connect to the database using config for a given named connection
|
45 | */
|
46 | connect(connectionName: string): void;
|
47 | /**
|
48 | * Patching the config
|
49 | */
|
50 | patch(connectionName: string, config: ConnectionConfig): void;
|
51 | /**
|
52 | * Returns the connection node for a given named connection
|
53 | */
|
54 | get(connectionName: string): ConnectionNode | undefined;
|
55 | /**
|
56 | * Returns a boolean telling if we have connection details for
|
57 | * a given named connection. This method doesn't tell if
|
58 | * connection is connected or not.
|
59 | */
|
60 | has(connectionName: string): boolean;
|
61 | /**
|
62 | * Returns a boolean telling if connection has been established
|
63 | * with the database or not
|
64 | */
|
65 | isConnected(connectionName: string): boolean;
|
66 | /**
|
67 | * Closes a given connection and can optionally release it from the
|
68 | * tracking list
|
69 | */
|
70 | close(connectionName: string, release?: boolean): Promise<void>;
|
71 | /**
|
72 | * Close all tracked connections
|
73 | */
|
74 | closeAll(release?: boolean): Promise<void>;
|
75 | /**
|
76 | * Release a connection. This will disconnect the connection
|
77 | * and will delete it from internal list
|
78 | */
|
79 | release(connectionName: string): Promise<void>;
|
80 | /**
|
81 | * Returns the report for all the connections marked for healthChecks.
|
82 | */
|
83 | report(): Promise<HealthReportEntry & {
|
84 | meta: ReportNode[];
|
85 | }>;
|
86 | }
|