In this documentation, we will focus on the common API. This module includes the core of BatchJS. This API allows you to create your own custom jobs and steps using the common interface.
extends ObjectReadable
Class that enable to implement classes to read data in batches of a specified size in different types of data storage.
Name | Description | Type |
---|---|---|
options | The options for the AbstractBatchEntityReaderStream. | AbstractBatchEntityReaderStreamOptions |
options.batchSize | The maximum number of elements in a batch. | number |
Reads a batch of data from the data storage and pushes it to the consumer stream. If the size parameter is not specified, it reads the number of entities specified in the batchSize option. If the size parameter is specified, it reads the minimum of the size and the batchSize option. If no data is available, it pushes null to the consumer stream to signal that the end of the stream has been reached. If an error occurs while reading data, it emits an error event to the stream.
Name | Description | Type |
---|---|---|
size | The size parameter for controlling the read operation. | number |
Type | Description |
---|---|
Promise.<void> | A promise that resolves when the data has been read and pushed to the consumer stream. |
private
Flushes the buffer by pushing its content to the consumer stream. If the consumer stream is not ready to receive data, it waits for the drain event and flushes the buffer again when it is emitted. This function is recursive and will keep flushing the buffer until it is empty.
Type | Description |
---|---|
Promise.<void> | A promise that resolves when the buffer is flushed. |
extends ObjectWritable
Class that enable to implement classes to write data in batches of a specified size in different types of data storage.
Name | Description | Type |
---|---|---|
options | The options for the AbstractBatchEntityWriterStream. | AbstractBatchEntityWriterStreamOptions |
options.batchSize | The maximum number of elements in a batch. | number |
A method to write data to the stream, push the chunk to the buffer, and execute the callback.
Name | Description | Type |
---|---|---|
chunk | The data chunk to write to the stream. | T |
encoding | The encoding of the data. | BufferEncoding |
callback | The callback function to be executed after writing the data. | WriteCallback |
Type | Description |
---|---|
Promise.<void> | This function does not return anything. |
Finalizes the stream by pushing remaining data batches, handling errors, and executing the final callback.
Name | Description | Type |
---|---|---|
callback | The callback function to be executed after finalizing the stream. | WriteCallback |
Type | Description |
---|---|
Promise.<void> | This function does not return anything. |
private
Creates a batch of data from the buffer and flushes it to the storage.
Type | Description |
---|---|
Promise.<void> |