Skip to content

Latest commit

 

History

History
188 lines (139 loc) · 7.23 KB

usage.md

File metadata and controls

188 lines (139 loc) · 7.23 KB

Classes

Client

Functions

AvroValidationError()

A AvroValidationError is thrown when avsc fails to encode/decode data.

Typedefs

ClientConstructorOptions : Object
AwsClientOptions : Object
WriteOptions : Object
WriteResponse : Object

Client

Kind: global class

new Client(options)

Param Type Description
options ClientConstructorOptions A hash of options

client.write(streamName, data, options) ⇒ Promise.<WriteReponse>

Write data to named stream.

Kind: instance method of Client
Returns: Promise.<WriteReponse> - A promise that resolves a WriteReponse obj

Note, the data arg can be an object or array of objects.

Param Type Description
streamName string Name of stream to write to.
data Object | Array Object (or array of objects) to write.
options WriteOptions

client.kinesisClient() ⇒ Promise.<AWS.Kinesis>

Kind: instance method of Client
Returns: Promise.<AWS.Kinesis> - A Promise that resolves an instance of AWS.Kinesis

client.dataApiClient() ⇒ Promise.<NyplClient>

Kind: instance method of Client
Returns: Promise.<NyplClient> - A Promise that resolves an instance of the NYPL Data API Client ( https://www.npmjs.com/package/@nypl/nypl-data-api-client )

client.encodeData(schemaName, data) ⇒ Promise

Returns Promise that resolves the given data encoded against the named schema

Kind: instance method of Client

Param Type
schemaName String
data Object | String

client.decodeData(schemaName, data) ⇒ Promise

Returns a Promise that resolves the given data decoded against the given schema.

Kind: instance method of Client

Param Type
schemaName String
data Object | String

client.decodeAvroBufferString(bufferString, avroObject, encodeType) ⇒

Returns a decoded Avro Object from a given encoded Buffer

Kind: instance method of Client
Returns: Returns a deserialized buffer

Param Type Default Description
bufferString String
avroObject Object
encodeType String base64 default encode type base64.

client.getAvroType() ⇒ Promise.<avsc.Type>

Returns an avro type instance by schema name

Kind: instance method of Client
Returns: Promise.<avsc.Type> - A Promise that resolves an avsc.Type instance

client._defaultSchema()

Given a stream name (e.g. MyEventStream-qa) returns the conventional schema name (MyEventStream)

Kind: instance method of Client

AvroValidationError()

A AvroValidationError is thrown when avsc fails to encode/decode data.

Kind: global function

ClientConstructorOptions : Object

Kind: global typedef
Properties

Name Type Description
nyplDataApiClientBase string Base URL for API (e.g. 'https://[FQDN]/api/v0.1/'). If missing, client will check process.env.NYPL_API_BASE_URL
writeBatchSize number How many records to write to a stream at once. Default 500. http://docs.aws.amazon.com/streams/latest/dev/service-sizes-and-limits.html
recordsPerSecond number How many records to write to a stream in a single 1s period. Default 500. AWS max is 1000/s. See: http://docs.aws.amazon.com/streams/latest/dev/service-sizes-and-limits.html
waitBetweenDescribeCallsInSeconds number How many seconds to pause between describe calls (i.e. when waiting for active stream). Default 4
maxDescribeCallRetries number Maximum describe calls to make before giving up (i.e. when waiting for active stream). Default 10.
logLevel string Set log level (i.e. info, error, warn, debug). Default env.LOG_LEVEL or 'error'
awsClientOptions AwsClientOptions AWS client options

AwsClientOptions : Object

Kind: global typedef
Properties

Name Type Description
region string AWS region to use. Default us-east-1
profile string Named profile to use for from local credentials file.

WriteOptions : Object

Kind: global typedef
Properties

Name Type Description
avroEncode boolean Whether or not to Name of avro schema to use to encode.
avroSchemaName string Name of avro schema to use to encode. Defaults to streamName (with -qa/-production suffix removed).

WriteResponse : Object

Kind: global typedef
Properties

Name Type Description
Records Array Array of records written
FailedRecordCount number Number of records that failed
unmergedResponses Array Raw AWS responses (for debugging mult. batch jobs)