How to use the @azure/event-hubs.DefaultDataTransformer function in @azure/event-hubs

To help you get started, we’ve selected a few @azure/event-hubs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / azure-sdk-for-js / sdk / eventhub / event-processor-host / src / hostContext.ts View on Github external
function _createBase(hostName: string, options: EventProcessorHostOptions): BaseHostContext {
    validateType("hostName", hostName, true, "string");

    const onEphErrorFunc: OnEphError = () => {
      // do nothing
    };
    const config = EventHubConnectionConfig.create(options.eventHubConnectionString!, options.eventHubPath);

    // set defaults
    if (!options.consumerGroup) options.consumerGroup = defaultConsumerGroup;
    if (!options.eventHubPath) options.eventHubPath = config.entityPath;
    if (!options.leaseRenewInterval) options.leaseRenewInterval = defaultLeaseRenewIntervalInSeconds;
    if (!options.leaseDuration) options.leaseDuration = defaultLeaseDurationInSeconds;
    if (!options.onEphError) options.onEphError = onEphErrorFunc;
    if (!options.dataTransformer) options.dataTransformer = new DefaultDataTransformer();
    if (!options.startupScanDelay) options.startupScanDelay = defaultStartupScanDelayInSeconds;
    if (!options.fastScanInterval) options.fastScanInterval = defaultFastScanIntervalInSeconds;
    if (!options.slowScanInterval) options.slowScanInterval = defaultSlowScanIntervalInSeconds;

    validateType("options", options, true, "object");
    validateType("options.eventHubPath", options.eventHubPath, true, "string");
    validateType("options.eventHubConnectionString", options.eventHubConnectionString, true, "string");
    validateType("options.storageConnectionString", options.storageConnectionString, false, "string");
    validateType("options.initialOffset", options.initialOffset, false, "object");
    validateType("options.consumerGroup", options.consumerGroup, false, "string");
    validateType("options.storageContainerName", options.storageContainerName, false, "string");
    validateType("options.storageBlobPrefix", options.storageBlobPrefix, false, "string");
    validateType("options.onEphError", options.onEphError, false, "function");
    validateType("options.leaseRenewInterval", options.leaseRenewInterval, false, "number");
    validateType("options.leaseDuration", options.leaseDuration, false, "number");
    _eitherStorageConnectionStringOrCheckpointLeaseManager(options);