Skip to content

Commit

Permalink
JSCO-14: Use cluster deserializer when deserializer not specified in …
Browse files Browse the repository at this point in the history
…QueryOptions (#17)

Changes
=======
* Set a default deserializer in the cluster.
* Use the cluster's default deserializer if a deserializer is not
  specified in QueryOptions.
* Small change to CI
  • Loading branch information
thejcfactor authored Sep 18, 2024
1 parent 685834b commit b7a4f55
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
34 changes: 17 additions & 17 deletions .github/workflows/prebuilds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
echo "SHA=${{ inputs.sha }}"
echo "version=${{ inputs.version }}"
echo "cxx_change=${{ inputs.cxx_change }}"
echo "DEFAULT_PYTHON=${{ env.DEFAULT_NODE }}"
echo "DEFAULT_NODE=${{ env.DEFAULT_NODE }}"
validate-input:
Expand Down Expand Up @@ -206,22 +206,22 @@ jobs:
name: ncbcc-platform-packagejson
path: |
./platPkg.json
# - name: Create test requirements
# run: |
# mkdir ncbcc-lib
# cd ncbcc-lib
# cp ../tsconfig.json .
# cp ../typedoc.json .
# cp ../.npmignore .
# cp -r ../lib .
# ls -alh
# - name: Upload docs requirements
# uses: actions/upload-artifact@v4
# with:
# retention-days: 1
# name: ncbcc-lib
# path: |
# ./ncbcc-lib
- name: Copy over lib/ and other requirements for pack, docs, etc.
run: |
mkdir ncbcc-lib
cd ncbcc-lib
cp ../tsconfig.json .
cp ../typedoc.json .
cp ../.npmignore .
cp -r ../lib .
ls -alh
- name: Upload requirements for pack, docs, etc.
uses: actions/upload-artifact@v4
with:
retention-days: 1
name: ncbcc-lib
path: |
./ncbcc-lib
linux-prebuilds:
Expand Down
9 changes: 9 additions & 0 deletions lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export class Cluster {
private _securityOptions: SecurityOptions
private _conn: CppConnection
private _dnsConfig: DnsConfig | null
private _deserializer: Deserializer

/**
* @internal
Expand Down Expand Up @@ -250,6 +251,13 @@ export class Cluster {
return this._dispatchTimeout
}

/**
@internal
*/
get deserializer(): Deserializer {
return this._deserializer
}

/**
@internal
@deprecated Use the static sdk-level {@link createInstance} method instead.
Expand Down Expand Up @@ -285,6 +293,7 @@ export class Cluster {
this._bootstrapTimeout = options.timeoutOptions?.connectTimeout
this._connectTimeout = options.timeoutOptions?.socketConnectTimeout
this._resolveTimeout = options.timeoutOptions?.resolveTimeout
this._deserializer = options.deserializer || new JsonDeserializer()

this._credential = credential

Expand Down
3 changes: 1 addition & 2 deletions lib/queryexecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
} from './querytypes'
import { errorFromCpp, queryScanConsistencyToCpp } from './bindingutilities'
import { Cluster } from './cluster'
import { JsonDeserializer } from './deserializers'
import { CppColumnarQueryResult, CppColumnarError } from './binding'
import { OperationCanceledError } from './errors'

Expand Down Expand Up @@ -171,7 +170,7 @@ export class QueryExecutor {
*/
query(statement: string, options: QueryOptions): Promise<QueryResult> {
return new Promise((resolve, reject) => {
const deserializer = options.deserializer || new JsonDeserializer()
const deserializer = options.deserializer || this._cluster.deserializer
const timeout = options.timeout || this._cluster.queryTimeout

const { cppQueryErr, cppQueryResult } = this._cluster.conn.query(
Expand Down

0 comments on commit b7a4f55

Please sign in to comment.