Skip to content

Commit b2656c6

Browse files
author
Zhen
committed
Add examples for driver documentation
1 parent 56941b8 commit b2656c6

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

test/v1/examples.test.js

+42
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,48 @@ describe('examples', () => {
112112
});
113113
});
114114

115+
it('config connection pool example', done => {
116+
// tag::config-connection-pool[]
117+
const driver = neo4j.driver(uri, neo4j.auth.basic(user, password),
118+
{
119+
maxConnectionLifetime: 30*60*60,
120+
maxConnectionPoolSize: 50,
121+
connectionAcquisitionTimeout: 2*60
122+
}
123+
);
124+
// end::config-connection-pool[]
125+
126+
driver.onCompleted = () => {
127+
done();
128+
};
129+
130+
const session = driver.session();
131+
session.run('RETURN 1').then(() => {
132+
session.close();
133+
driver.close();
134+
});
135+
});
136+
137+
it('config load balancing example', done => {
138+
// tag::config-load-balancing-strategy[]
139+
const driver = neo4j.driver(uri, neo4j.auth.basic(user, password),
140+
{
141+
loadBalancingStrategy: "least_connected"
142+
}
143+
);
144+
// end::config-load-balancing-strategy[]
145+
146+
driver.onCompleted = () => {
147+
done();
148+
};
149+
150+
const session = driver.session();
151+
session.run('RETURN 1').then(() => {
152+
session.close();
153+
driver.close();
154+
});
155+
});
156+
115157
it('config max retry time example', done => {
116158
// tag::config-max-retry-time[]
117159
const maxRetryTimeMs = 15 * 1000; // 15 seconds

0 commit comments

Comments
 (0)