Learn R Programming

RStorm (version 1.0)

Bolt: Function to create a Bolt object to add to a stream

Description

Function to create a Bolt object. A Bolt object consists of a function which receives as its first argument the Tuple emitted by the element the Bolt listens to.

Usage

Bolt(FUNC, listen = 0, boltID = 0)

Arguments

FUNC

a [R] function with a first argument which receive a Tuple and using the ,... specification to receive arguments auxiliary to the functioning of the stream.

listen

a number indicating which element in the topology to listen too. $0$ indicates the Spout itself, while other integers refer to the Tuples emitted by other Bolts along the Stream. Default is $0$. Printing the Topology allows one to see the position number of each Bolt.

boltID

(optional) the ID of this bolt. A given name -- mostly a number -- to pass the name of the bolt to the bolt itself which can be used to create (e.g.) a hashMap that is distinct for the current bolt.

Value

An object of type Bolt which is a list containing the following elements:

name

the name of the function that was passed when initializing the Bolt

func

the function itself

listen

the identifier of the element in the stream from which the Bolt receives its Tuples

id

the id of the current Bolt

Warning

Functions used as bolt in a stream should always use the dots argument (...) to facilitate the internal working of RStorm.

Additional Info

The is.Bolt function checks whether an object is of Type Bolt and is used internally.

See Also

See Also: Topology, AddBolt, RStorm

Examples

Run this code
# NOT RUN {
# Create a Bolt:
bolt1 <- function(x, ...){print(x)}
Bolt(bolt1, listen=0, boltID=12)

# }

Run the code above in your browser using DataLab