Skip to main content

Sink - BlobSinkBuilder

Sink.BlobSinkBuilder

Create a SinkBuilder to build a data

Sink.

Methods on the SinkBuilder enable you to emit stream data to external systems. If the

Stream is a BlobType, specialised operations can be applied to perform an ftp put of the Stream.

Quality of data can be observed using assert and warn by providing expression based conditions and messages to the whole

Stream.

A corresponding

Template can be created using .toTemplate().

Remarks

See

Transform Data for a related learning module.

Type parameters

NameType
Outputextends BlobType
Inputsextends Record

Sink

error

error(config):

BlobSinkBuilder

Check the sink inputs for validity and identify any errors. When the if predicate returns true the sink will be terminated with an error message and sink output will not be produced.

Parameters

NameTypeDescription
configObjectthe error message and predicate
config.if(inputs: Inputs) => EastFunctionIf true an error will be created
config.messagestring | (inputs: Inputs) => EastFunctionThe message in the case that an error is created

Returns

BlobSinkBuilder

a new

BlobSinkBuilder

Example

 // get a predefined blob stream
const file = Stream("File", BlobType);
// get a predefined uri stream
const uri = Stream("uri", StringType)
// put the contents of the file at the uri
const sink = new SinkBuilder("Ftp")
.from(file)
.input({ name: "uri", stream: uri })
.error({
if: uri => Equal(uri, ''),
message: "Uri is empty"
})
.ftp({
uri: (inputs) => inputs.uri,
})
.toTemplate();

ftp

ftp(config):

FtpSinkBuilder

Build a sink to put a blob into an ftp file uri.

Type parameters

NameType
Uextends (inputs: Inputs) => EastFunction
Pextends (inputs: Inputs) => EastFunction

Parameters

NameTypeDescription
configObjectthe configuration of the ftp put
config.key?UAn EastFunction for the ftp private key
config.password?UAn EastFunction for the ftp password
config.port?PAn EastFunction for the ftp port
config.uriUAn EastFunction for the ftp uri
config.username?UAn EastFunction for the ftp username

Returns

FtpSinkBuilder

a new

BlobSinkBuilder

Example

 // get a predefined blob stream
const file = Stream("File", BlobType);
// get a predefined uri stream
const uri = Stream("uri", StringType)
// put the contents of the file at the uri
const sink = new SinkBuilder("Ftp")
.from(file)
.input({ name: "uri", stream: uri })
.warn({
predicate: uri => NotEqual(uri, ''),
message: "Uri is empty"
})
.ftp({
uri: (inputs) => inputs.uri,
})
.toTemplate();

input

input(config):

BlobSinkBuilder<Output, Inputs & { [K in string]: Variable }>

Add a stream as input to the BlobSinkBuilder, which can be used in expressions to configure how the

Sink will access the data (such as a URL or password), the output data, or any data assertions (preconditions and postconditions).

Type parameters

NameType
Nameextends string
Textends EastType

Parameters

NameTypeDescription
configObjectthe configuration for the input
config.nameName extends "input" | keyof Inputs ? never : Namethe name to give the input Variable
config.streamStreamthe input stream (the stream and associated preconditions)

Returns

BlobSinkBuilder<Output, Inputs & { [K in string]: Variable }>

a new

BlobSinkBuilder

Example

 // get a predefined blob stream
const file = Stream("File", BlobType);
// get a predefined uri stream
const uri = Stream("uri", StringType)
// put the contents of the file at the uri
const sink = new SinkBuilder("Ftp")
.from(file)
.input({ name: "uri", stream: uri })
.assert({
predicate: uri => NotEqual(uri, ''),
message: "Uri is empty"
})
.ftp({
uri: (inputs) => inputs.uri,
})
.toTemplate();

log

log(config):

BlobSinkBuilder

Produce log messages based on the sink inputs. When the if predicate returns true the sink will register a log message and proceed to proceed to output data.

Parameters

NameTypeDescription
configObjectthe log message and optional predicate
config.if?(inputs: Inputs) => EastFunctionIf true a log message will be produced (optional)
config.messagestring | (inputs: Inputs) => EastFunctionThe log message

Returns

BlobSinkBuilder

a new

BlobSinkBuilder

Example

 // get a predefined blob stream
const file = Stream("File", BlobType);
// get a predefined uri stream
const uri = Stream("uri", StringType)
// put the contents of the file at the uri
const sink = new SinkBuilder("Ftp")
.from(file)
.input({ name: "uri", stream: uri })
.warn({
if: uri => Equal(uri, ''),
message: "Uri is empty"
})
.ftp({
uri: (inputs) => inputs.uri,
})
.toTemplate();

s3

s3(config):

S3SinkBuilder

Build a sink to put a blob into an s3 path.

Type parameters

NameType
Uextends (inputs: Inputs) => EastFunction

Parameters

NameTypeDescription
configObjectthe configuration of the s3 blob
config.access_key_idUAn EastFunction with the AWS access key ID
config.bucketUAn EastFunction with a bucket name containing the object
config.keyUAn EastFunction with the key of the object to get.
config.regionUAn EastFunction with the aws region
config.secret_access_keyUAn EastFunction with the AWS secret access key

Returns

S3SinkBuilder

a new

BlobSinkBuilder

Example

 // get a predefined blob stream
const file = Stream("File", BlobType);
// get a predefined path stream
const key = Stream("key", StringType)
// put the contents of the file at the uri
const sink = new SinkBuilder("Ftp")
.from(file)
.input({ name: "key", stream: key })
.warn({
predicate: key => NotEqual(key, ''),
message: "Key is empty"
})
.s3({
region: (inputs) => Const("__REGION__"),
bucket: (inputs) => Const("__BUCKET__"),
key: (inputs) => inputs.key,
access_key_id: (inputs) => Const("__ACCESS_KEY_ID__"),
secret_access_key: (inputs) => Const("__SECRET_KEY__")
})
.toTemplate();

warn

warn(config):

BlobSinkBuilder

Check the sink inputs for validity and raise warnings as necessary. When the if predicate returns true the sink will register a warning with a message, but will proceed to proceed to output data.

Parameters

NameTypeDescription
configObjectthe warning message and predicate
config.if(inputs: Inputs) => EastFunctionIf true a warning will be produced
config.messagestring | (inputs: Inputs) => EastFunctionThe message in the case that a warning is created

Returns

BlobSinkBuilder

a new

BlobSinkBuilder

Example

 // get a predefined blob stream
const file = Stream("File", BlobType);
// get a predefined uri stream
const uri = Stream("uri", StringType)
// put the contents of the file at the uri
const sink = new SinkBuilder("Ftp")
.from(file)
.input({ name: "uri", stream: uri })
.warn({
if: uri => Equal(uri, ''),
message: "Uri is empty"
})
.ftp({
uri: (inputs) => inputs.uri,
})
.toTemplate();