17
17
* limitations under the License.
18
18
*/
19
19
20
- import { newError } from './error'
21
-
22
20
/**
23
21
* Interface which defines the raw connection with the database
24
22
* @private
25
23
*/
26
- interface Connection {
24
+ class Connection {
27
25
id : string
28
26
databaseId : string
29
27
server : any
@@ -41,89 +39,61 @@ interface Connection {
41
39
/**
42
40
* @returns {boolean } whether this connection is in a working condition
43
41
*/
44
- isOpen ( ) : boolean
42
+ isOpen ( ) : boolean {
43
+ return false
44
+ }
45
45
46
46
/**
47
47
* @todo be removed and internalize the methods
48
48
* @returns {any } the underlying bolt protocol assigned to this connection
49
49
*/
50
- protocol ( ) : any
50
+ protocol ( ) : any {
51
+ throw Error ( 'Not implemented' )
52
+ }
51
53
52
54
/**
53
55
* Connect to the target address, negotiate Bolt protocol and send initialization message.
54
56
* @param {string } userAgent the user agent for this driver.
55
57
* @param {Object } authToken the object containing auth information.
56
58
* @return {Promise<Connection> } promise resolved with the current connection if connection is successful. Rejected promise otherwise.
57
59
*/
58
- connect ( userAgent : string , authToken : any ) : Promise < Connection >
60
+ connect ( userAgent : string , authToken : any ) : Promise < Connection > {
61
+ throw Error ( 'Not implemented' )
62
+ }
59
63
60
64
/**
61
65
* Write a message to the network channel.
62
66
* @param {RequestMessage } message the message to write.
63
67
* @param {ResultStreamObserver } observer the response observer.
64
68
* @param {boolean } flush `true` if flush should happen after the message is written to the buffer.
65
69
*/
66
- write ( message : any , observer : any , flush : boolean ) : void
70
+ write ( message : any , observer : any , flush : boolean ) : void {
71
+ throw Error ( 'Not implemented' )
72
+ }
73
+
67
74
/**
68
75
* Send a RESET-message to the database. Message is immediately flushed to the network.
69
76
* @return {Promise<void> } promise resolved when SUCCESS-message response arrives, or failed when other response messages arrives.
70
77
*/
71
- resetAndFlush ( ) : Promise < void >
78
+ resetAndFlush ( ) : Promise < void > {
79
+ throw Error ( 'Not implemented' )
80
+ }
72
81
73
82
/**
74
83
* Call close on the channel.
75
84
* @returns {Promise<void> } - A promise that will be resolved when the connection is closed.
76
85
*
77
86
*/
78
- close ( ) : Promise < void >
79
- }
80
-
81
- /**
82
- * @private
83
- */
84
- interface ConnectionHolder {
85
- mode ( ) : string | undefined
86
- database ( ) : string | undefined
87
- initializeConnection ( ) : boolean
88
- getConnection ( ) : Promise < Connection >
89
- releaseConnection ( ) : Promise < Connection | void >
90
- close ( ) : Promise < Connection | void >
91
- }
92
-
93
- class EmptyConnectionHolder implements ConnectionHolder {
94
- mode ( ) : undefined {
95
- return undefined
87
+ close ( ) : Promise < void > {
88
+ throw Error ( 'Not implemented' )
96
89
}
97
90
98
- database ( ) : undefined {
99
- return undefined
100
- }
101
-
102
- initializeConnection ( ) {
103
- // nothing to initialize
104
- return true
105
- }
106
-
107
- getConnection ( ) : Promise < Connection > {
108
- return Promise . reject (
109
- newError ( 'This connection holder does not serve connections' )
110
- )
111
- }
112
-
113
- releaseConnection ( ) : Promise < void > {
114
- return Promise . resolve ( )
115
- }
116
-
117
- close ( ) : Promise < void > {
91
+ /**
92
+ * Called to release the connection
93
+ */
94
+ _release ( ) : Promise < void > {
118
95
return Promise . resolve ( )
119
96
}
120
97
}
121
98
122
- /**
123
- * Connection holder that does not manage any connections.
124
- * @type {ConnectionHolder }
125
- */
126
- const EMPTY_CONNECTION_HOLDER = new EmptyConnectionHolder ( )
127
-
128
99
export default Connection
129
- export { ConnectionHolder , EMPTY_CONNECTION_HOLDER }
0 commit comments