How to use the resolve-es function in resolve-es

To help you get started, we’ve selected a few resolve-es examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github reimagined / resolve / benchmarks / mongo-es-speed / buildState.js View on Github external
import mongoDbDriver from 'resolve-es-mongo';
import createEs from 'resolve-es';

import { INFO_TOKEN, DONE_TOKEN, ERR_TOKEN } from './constants';
import config from './config';

const TYPES = config.GENERATED_EVENT_TYPES;

const store = createEs({
    driver: mongoDbDriver({
        url: config.MONGODB_CONNECTION_URL,
        collection: config.MONGODB_COLLECTION_NAME
    })
});

let eventCounter = 0;
let lastReportedEvents = 0;

function reporterHandler() {
    if (lastReportedEvents !== eventCounter) {
        const tickSize = eventCounter - lastReportedEvents;
        // eslint-disable-next-line no-console
        console.log(INFO_TOKEN, tickSize);
        lastReportedEvents = eventCounter;
    }
github reimagined / resolve / packages / resolve-scripts / src / server / event_store.js View on Github external
import createEventStore from 'resolve-es'

import config from '../configs/server.config.js'

const storage = config.storage.adapter(config.storage.params)

const busAdapter = config.bus.adapter
const bus = busAdapter(config.bus.params)

const eventStore = createEventStore({ storage, bus })

const subscribe = async (eventDescriptors, callback) => {
  if (Array.isArray(eventDescriptors.types) && eventDescriptors.ids === '*') {
    return await eventStore.subscribeByEventType(
      eventDescriptors.types,
      callback,
      {
        onlyBus: true
      }
    )
  } else if (
    Array.isArray(eventDescriptors.types) &&
    Array.isArray(eventDescriptors.ids)
  ) {
    return await eventStore.subscribeByAggregateId(
      eventDescriptors.ids,
github reimagined / resolve / packages / core / resolve-scripts / src / runtime / event_store.js View on Github external
import createEventStore from 'resolve-es'

import { storageAdapter, busAdapter } from './assemblies'

const createStorageAdapter = storageAdapter.module
const storageAdapterOptions = storageAdapter.options

const createBusAdapter = busAdapter.module
const busAdapterOptions = busAdapter.options

const storage = createStorageAdapter(storageAdapterOptions)

const bus = createBusAdapter(busAdapterOptions)

const eventStore = createEventStore({ storage, bus })

export default eventStore
github reimagined / resolve / packages / core / resolve-runtime / src / local_entry.js View on Github external
const initEventStore = async (
  { storageAdapter: createStorageAdapter, busAdapter: createBusAdapter },
  resolve
) => {
  Object.assign(resolve, {
    eventStore: createEventStore({
      storage: createStorageAdapter(),
      bus: createBusAdapter()
    })
  })
}
github reimagined / resolve / examples / todolist / index.js View on Github external
import todoCardAggregate from './aggregates/TodoCard';
import todoItemAggregate from './aggregates/TodoItem';
import cardsProjection from './projections/cards';
import cardDetailsProjection from './projections/cardDetails';

const setupMiddlewares = (app) => {
    app.use(bodyParser.json());
    app.use(bodyParser.urlencoded({ extended: true }));
    app.set('views', './views');
    app.set('view engine', 'pug');
};

const app = express();
app.use(express.static('static'));

const eventStore = createStore({
    driver: esDriver({ pathToFile: './event_store.json' })
});
const bus = createBus({ driver: busDriver() });

const execute = commandHandler({
    store: eventStore,
    bus,
    aggregates: [todoCardAggregate, todoItemAggregate]
});

const queries = query({
    store: eventStore,
    bus,
    projections: [cardsProjection, cardDetailsProjection]
});
github reimagined / resolve / packages / resolve-scripts / src / runtime / event_store.js View on Github external
import createEventStore from 'resolve-es'

import { storageAdapter, busAdapter } from './assemblies'

const createStorageAdapter = storageAdapter.module
const storageAdapterOptions = storageAdapter.options

const createBusAdapter = busAdapter.module
const busAdapterOptions = busAdapter.options

const storage = createStorageAdapter(storageAdapterOptions)

const bus = createBusAdapter(busAdapterOptions)

const eventStore = createEventStore({ storage, bus })

export default eventStore
github reimagined / resolve / packages / core / resolve-runtime / src / cloud_entry.js View on Github external
const initResolve = async (
  {
    snapshotAdapter: createSnapshotAdapter,
    storageAdapter: createStorageAdapter,
    readModelAdapters: readModelAdaptersCreators
  },
  resolve
) => {
  const storageAdapter = createStorageAdapter()
  const eventStore = createEventStore({ storage: storageAdapter })
  const { aggregates, readModels, viewModels } = resolve
  const snapshotAdapter = createSnapshotAdapter()

  const readModelAdapters = {}
  for (const { name, factory } of readModelAdaptersCreators) {
    readModelAdapters[name] = factory()
  }

  const executeCommand = createCommandExecutor({
    eventStore,
    aggregates,
    snapshotAdapter
  })

  const doUpdateRequest = async (pool, readModelName) => {
    const executor = pool.getExecutor(pool, readModelName)
github reimagined / resolve / examples / todo / server / command / index.js View on Github external
import createEventStore from 'resolve-es';
import storageAdapter from 'resolve-storage-lite';
import busAdapter from 'resolve-bus-zmq';
import commandHandler from 'resolve-command';

import { aggregates } from 'todo-common';

import config from '../config';

const todoCardAggregate = aggregates.TodoCard;
const todoItemAggregate = aggregates.TodoItem;

const storage = storageAdapter(config.esFile);
const bus = busAdapter(config.zmq);

const eventStore = createEventStore({ storage, bus });

const execute = commandHandler({
    eventStore,
    aggregates: [todoCardAggregate, todoItemAggregate]
});

process.on('message', (message) => {
    execute(message.payload)
        .then(() =>
            process.send({
                id: message.id,
                state: null
            })
        )
        .catch(err =>
            process.send({
github reimagined / resolve / examples / todo / server / index.js View on Github external
import http from 'http';
import socketIO from 'socket.io';
import uuid from 'uuid';
import createEventStore from 'resolve-es';
import busAdapter from 'resolve-bus-zmq';

import { readModel } from 'todo-common';
import makeIpc from './ipc';
import config from './config';

const eventStore = createEventStore({ bus: busAdapter(config.zmq) });

const PORT = 3001;

const server = http.createServer((req, res) => {
    res.writeHead(404);
    return res.end('Page not found');
});

const io = socketIO(server);

const eventNames = Object.keys(readModel.projection);

const requestReadModel = makeIpc('./query/index.js');
const requestCommand = makeIpc('./command/index.js');

io.on('connection', (socket) => {
github reimagined / resolve / examples / todo / server / query / index.js View on Github external
import createEventStore from 'resolve-es';
import storageAdapter from 'resolve-storage-lite';
import busAdapter from 'resolve-bus-zmq';
import query from 'resolve-query';
import { readModel } from 'todo-common';

import config from '../config';

const storage = storageAdapter(config.esFile);
const bus = busAdapter(config.zmq);
const eventStore = createEventStore({ storage, bus });

const queries = query({
    eventStore,
    readModel
});

process.on('message', (message) => {
    queries('query { View }')
        .then(state =>
            process.send({
                id: message.id,
                state
            })
        )
        .catch(err =>
            process.send({

resolve-es

The reSolve framework's event store.

MIT
Latest version published 4 years ago

Package Health Score

54 / 100
Full package analysis

Popular resolve-es functions