<commit_before>/*
* Many of you want to scale the server with docker images or some other way.
* You should be able to use the following code to get full events stream
* and pipe it with some service like rabbitMQ or zeroMQ.
* You shouldn't worry about events mirroring between different processes,
* EVENT_PROVIDER is smart enough to filter broadcasted events.
*/

/*
  to build this sample run

    npm run examples:build

  to run

    npm run examples:run:eventprovider

  if this fails, ensure you have to latest version of spark-protocol, run

    npm update spark-protocol

*/

/* eslint-disable */

import type { Event } from '../types';
import { Container } from 'constitute';
import defaultBindings from '../defaultBindings';
import settings from '../settings.js';
import logger from '../lib/logger';

const container = new Container();
defaultBindings(container, settings);

const deviceServer = container.constitute('DeviceServer');
deviceServer.start();

const evProvider = container.constitute('EVENT_PROVIDER');
evProvider.onNewEvent((event: Event) => {
  logger.info('Event',event);
});<commit_msg>patched sample to working code<commit_after>/*
* Many of you want to scale the server with docker images or some other way.
* You should be able to use the following code to get full events stream
* and pipe it with some service like rabbitMQ or zeroMQ.
* You shouldn't worry about events mirroring between different processes,
* EVENT_PROVIDER is smart enough to filter broadcasted events.
*/

/*
  to build this sample run

    npm run examples:build

  to run

    npm run examples:run:eventprovider

  if this fails, ensure you have to latest version of spark-protocol, run

    npm update spark-protocol

*/

/* eslint-disable */

import type { Event } from '../types';
import { Container } from 'constitute';
import defaultBindings from '../defaultBindings';
import settings from '../settings.js';
import logger from '../lib/logger';

const container = new Container();
defaultBindings(container, settings);

const deviceServer = container.constitute('DeviceServer');
deviceServer.start();

/*
const evProvider = container.constitute('EVENT_PROVIDER');
evProvider.onNewEvent((event: Event) => {
  logger.info('Event onNewEvent',event);
});
*/



deviceServer._eventPublisher.subscribe('*', (ev: any) => {
  logger.info({ data: ev.data, event: ev.name, name: ev.deviceID, event: ev }, 'Incomming Event');
});
{'fraction_non_alphanumeric': 0.10671611042439226, 'fraction_numerical': 0.0, 'mean_word_length': 4.4075723830734965, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6507011', 'n_tokens_mistral': 675, 'n_tokens_neox': 644, 'n_words': 265}