Skip to content

Commit b978fe3

Browse files
committed
Do a pass through tagging doc
1 parent 86c6707 commit b978fe3

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

doc/api.md

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,7 +1842,7 @@ String sessionCallback | function sessionCallback(Connection connection, String
18421842
```
18431843

18441844
When `sessionCallback` is a Node.js function, it will be invoked for
1845-
each `pool.getConnection()` call that will return a brand new
1845+
each `pool.getConnection()` call that will return a newly created
18461846
connection in the pool. It will also be called if
18471847
`pool.getConnection()` requests a connection from the pool with a
18481848
given [`tag`](#getconnectiondbattrstag), and that tag value does not
@@ -1852,7 +1852,7 @@ other `getConnection()` calls. The tag requested by
18521852
the actual tag is available in [`connection.tag`](#propconntag).
18531853

18541854
The session callback is called before `getConnection()` returns so it
1855-
can be used to do logging, or efficiently set session state such as
1855+
can be used to do logging or efficiently set session state such as
18561856
with ALTER SESSION statements. Make sure any session state is set and
18571857
`connection.tag` is updated in the `sessionCallback` function prior to
18581858
it calling its own `callback` function otherwise the session will not
@@ -2338,6 +2338,14 @@ When node-oracledb is using Oracle Client libraries 12.2 or later, the
23382338
tag must be a [multi-property tag][125] with name=value pairs like
23392339
"k1=v1;k2=v2".
23402340

2341+
An empty string represents not having a tag set.
2342+
2343+
See [Connection Tagging and Session State](#connpooltagging).
2344+
2345+
This property was added in node-oracledb 3.1.
2346+
2347+
##### Getting the tag
2348+
23412349
After a `pool.getConnection()` requests a [tagged
23422350
connection](#getconnectiondbattrstag):
23432351

@@ -2346,21 +2354,22 @@ connection](#getconnectiondbattrstag):
23462354
connection.
23472355

23482356
- When a Node.js `sessionCallback` function is used, then
2349-
`connection.tag` will be set to the value of the connection's actual
2350-
tag prior to invoking the callback. The callback can then set the
2351-
connection state and alter `connection.tag` as desired.
2357+
`connection.tag` will be set to the value of the connection's actual
2358+
tag prior to invoking the callback. The callback can then set
2359+
connection state and alter `connection.tag` as desired.
23522360

23532361
- When a PL/SQL `sessionCallback` is used, then `connection.tag`
2354-
contains the value of the tag that was requested by
2355-
`pool.getConnection()`. The PL/SQL callback is expected to set the
2356-
state to match.
2362+
contains the value of the tag that was requested by
2363+
`pool.getConnection()`. The PL/SQL callback is expected to set the
2364+
state to match.
23572365

2358-
An empty string represents no tag. To clear a connection's tag, set
2359-
`connection.tag = ""` prior to closing the connection.
2366+
##### Setting the tag
23602367

2361-
See [Connection Tagging and Session State](#connpooltagging).
2368+
A tag can be set anytime prior to closing the connection. If a
2369+
Node.js `sessionCallback` function is being used, the best practice
2370+
recommendation is to set the tag in the callback function.
23622371

2363-
This property was added in node-oracledb 3.1.
2372+
To clear a connection's tag, set `connection.tag = ""`.
23642373

23652374
### <a name="connectionmethods"></a> 4.2 Connection Methods
23662375

@@ -6525,7 +6534,7 @@ database. The `requestedTag` parameter is ignored because it is only
65256534
valid when tagging is being used:
65266535
65276536
```javascript
6528-
function mySetState(connection, requestedTag, cb) {
6537+
function initSession(connection, requestedTag, cb) {
65296538
connection.execute(
65306539
`alter session set nls_date_format = 'YYYY-MM-DD' nls_language = AMERICAN`,
65316540
cb);
@@ -6536,7 +6545,7 @@ try {
65366545
user: 'hr',
65376546
password: 'welcome',
65386547
connectString: 'localhost/XEPDB1',
6539-
sessionCallback: mySetState
6548+
sessionCallback: initSession
65406549
});
65416550
. . .
65426551
}
@@ -6598,7 +6607,7 @@ properties that may be set:
65986607
```javascript
65996608
const sessionTag = "location=USA";
66006609

6601-
function mySetState(connection, requestedTag, cb) {
6610+
function initSession(connection, requestedTag, cb) {
66026611
let seen = connection.tag ? connection.tag.split(";").includes(requestedTag) : false;
66036612
if (seen) {
66046613
cb()
@@ -6619,7 +6628,7 @@ try {
66196628
user: 'hr',
66206629
password: 'welcome',
66216630
connectString: 'localhost/XEPDB1',
6622-
sessionCallback: mySetState
6631+
sessionCallback: initSession
66236632
});
66246633

66256634
// Request a connection with a given tag from the pool cache, but accept any tag being returned.

0 commit comments

Comments
 (0)