Skip to content

Low-level api for interacting with the EventStore database

Notifications You must be signed in to change notification settings

chrismcleod/rx-eventstore-streams

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rx-eventstore-streams

The rx-eventstore-streams library exposes a low-level api for interacting with the EventStore database.

Basic Usage

Connecting sending, and receiving operations

import { v4 } from 'uuid';

import { connect } from '../connection';
import wtfuuid from '../wtfuuid';

setImmediate(async () => {

  const connection = await connect({
    host: '123.45.67.89',
    port: 1113,
    credentials: {
      username: process.env.ES_USERNAME!,
      password: process.env.ES_PASSWORD!,
    },
  });

  setInterval(() => {

    const command = {
      code: 130,
      data: {
        eventStreamId: `dev_test_shareable-resource-${v4()}`,
        expectedVersion: -2,
        requireMaster: false,
        events: [ {
          data: Buffer.from(JSON.stringify({ it: 'doesnt matter' })),
          dataContentType: 1,
          eventId: wtfuuid.write(v4()),
          eventType: 'TestEvent',
          metadataContentType: 0,
        }]
      }
    }

    connection.send(command);

    connection.$
      .filter(event => event.code === 199)
      .subscribe((event) => {
        connection.send({
          code: 204,
          correlationId: event.correlationId,
          data: {
            processedEventIds: [ event.data.event.link.eventId ],
            subscriptionId: '$ce-dev_test_shareable::dev_test_shareable',
          },
        });
      });
  });
});

About

Low-level api for interacting with the EventStore database

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published