eventstore-stream-subscriber
Subscribe to an Eventstore stream with the possibility to add separate event handlers for specific event types.
Subscribe to realtime events only
var subscriber = ; // register eventhandlers for eventtypes of a streamsubscriber; // configure the subscribersubscriber; // connect and start consuming eventssubscriber;
Catch up from beginning of stream and continue to consume realtime events
subscriber;
Read the entire stream from start to end
// register a global handler (will receive all) subscriber; subscriber; const streamName = "Order-123"; await subscriber ; });
Configuration
The default configuration:
var configuration = resolveLinkTos : true logHeartbeats : false userName : "admin" password : "changeit" eventstoreHost : "127.0.0.1" eventstorePort : 1113
Override these settings in createConnection:
subscriber;
Or using .env (make sure to pass these vars to your application)
# eventstore.production.env EVENTSTORE_STREAM_SUB_HOST=eventstoreprod.somewhere.comEVENTSTORE_STREAM_SUB_PORT=3113
Since .env overrides the configuration object, both of these will have the same effect when .env variables are present:
//With local configsubscriber; /* Resolves to tcp://eventstoreprod.somewhere.com:3113*/ //without local configsubscriber; /* Resolves to tcp://eventstoreprod.somewhere.com:3113*/
Logging
The following loglevels can be set in the environment variable EVENTSTORE_STREAM_SUB_LOGLEVEL:
info warning error fatal