Skip to content

Commit

Permalink
Merge pull request #38 from Streamware/develop
Browse files Browse the repository at this point in the history
merge dev to master
  • Loading branch information
Hasan Haghniya authored Jun 21, 2024
2 parents c6aa4cc + 4b23ee2 commit 5cfa380
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/pulsar-client.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,39 @@ function getAuthentication():
}
}

function safeParseInt(value: string | undefined, fallback: number): number {
const parsed = parseInt(value || '', 10);
return isNaN(parsed) ? fallback : parsed;
}

export default (): { pulsar: ClientConfig } => ({
pulsar: {
serviceUrl: process.env.PULSAR_SERVICE_URL || 'pulsar://localhost:6650',
authentication: getAuthentication(),
operationTimeoutSeconds:
parseInt(process.env.PULSAR_OPERATION_TIMEOUT_SECONDS, 10) || 30,
ioThreads: parseInt(process.env.PULSAR_IO_THREADS, 10) || 1,
messageListenerThreads:
parseInt(process.env.PULSAR_MESSAGE_LISTENER_THREADS, 10) || 1,
concurrentLookupRequest:
parseInt(process.env.PULSAR_CONCURRENT_LOOKUP_REQUEST, 10) || undefined,
operationTimeoutSeconds: safeParseInt(
process.env.PULSAR_OPERATION_TIMEOUT_SECONDS,
30,
),
ioThreads: safeParseInt(process.env.PULSAR_IO_THREADS, 1),
messageListenerThreads: safeParseInt(
process.env.PULSAR_MESSAGE_LISTENER_THREADS,
1,
),
concurrentLookupRequest: safeParseInt(
process.env.PULSAR_CONCURRENT_LOOKUP_REQUEST,
undefined,
),
useTls: process.env.PULSAR_USE_TLS === 'true' || undefined,
tlsTrustCertsFilePath:
process.env.PULSAR_TLS_TRUST_CERTS_FILE_PATH || undefined,
tlsValidateHostname:
process.env.PULSAR_TLS_VALIDATE_HOSTNAME === 'true' || undefined,
tlsAllowInsecureConnection:
process.env.PULSAR_TLS_ALLOW_INSECURE_CONNECTION === 'true' || undefined,
statsIntervalInSeconds:
parseInt(process.env.PULSAR_STATS_INTERVAL_IN_SECONDS, 10) || undefined,
statsIntervalInSeconds: safeParseInt(
process.env.PULSAR_STATS_INTERVAL_IN_SECONDS,
undefined,
),
listenerName: process.env.PULSAR_LISTENER_NAME || undefined,
},
});

0 comments on commit 5cfa380

Please sign in to comment.