Async

info.fingo.spata.CSVParser.Async
final class Async[F[_]]

CSVParser helper with asynchronous parsing method.

Type parameters

F

the effect type, with type class providing support for concurrency (typically cats.effect.IO) and logging (provided internally by spata)

Value parameters

parser

the regular parser

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def process(stream: Stream[F, Char], maxConcurrent: Int)(cb: Callback): F[Unit]

Processes each CSV record with provided callback functions to execute some side effects. Stops processing input as soon as the callback function returns false, stream is exhausted or exception thrown.

Processes each CSV record with provided callback functions to execute some side effects. Stops processing input as soon as the callback function returns false, stream is exhausted or exception thrown.

This function processes the callbacks asynchronously while retaining order of handled data. The callbacks are run concurrently according to maxConcurrent parameter.

Processing success or failure may be checked by examining by callback to method triggering effect evaluation (e.g. cats.effect.IO.unsafeRunAsync) or handling error (e.g. with cats.effect.IO.handleErrorWith).

Value parameters

cb

the callback function to operate on each CSV record and produce some side effect; it should return true to continue with next record or false to stop processing the source

maxConcurrent

maximum number of concurrently evaluated effects

stream

the source stream containing CSV content

Attributes

Returns

unit effect, used as a handle to trigger evaluation