Giter Club home page Giter Club logo

Comments (5)

joshbedo avatar joshbedo commented on August 27, 2024

nevermind got it working by looking at the hapiger implementation

from ger.

joshbedo avatar joshbedo commented on August 27, 2024

@grahamjenson Actually i can't figure out how to initialize the namespace. I have this so far

'use strict';

var env = process.env.NODE_ENV;
import config from '../local.json';
import g from 'ger';
import ret_esm from 'ger_rethinkdb_esm';

var RethinkDBESM = ret_esm.esm; // rethinkdb event storage manager
var r = ret_esm.r; // rethinkdb ORM

var conn = r({
  host: '192.168.99.100',
  port: 28015,
  db: 'matching'
});

var esm = new RethinkDBESM({r: conn})
var ger = new g.GER(esm);


/**
* Track actions like `bob`, `likes`, `jill` and
**/
export function trackEvent(params, done) {
  ger.events([params.event])
    .then((event) => {
      done(null, params.event);
    })
    .catch((error) => {
      done('Failed to save event: ', params.event);
    });
}
/**
* Get recommendations for user and filter
* out user blacklisted ids.
**/
export function getRecommendations(params, done) {

}

from ger.

joshbedo avatar joshbedo commented on August 27, 2024

Got this working by doing something like this

'use strict';

import g from 'ger';
import ret_esm from 'ger_rethinkdb_esm';

var RethinkDBESM = ret_esm.esm; // rethinkdb event storage manager
var r = ret_esm.r; // rethinkdb ORM

class MatchingService {
  constructor(config) {
    let conn = r(config.connection)
    let esm = new RethinkDBESM({r: conn})

    let ger = new g.GER(esm, {
      logging_options: {
        reporters: [{
          reporter: require('good-console'),
          events: { log: '*', response: '*' }
        }]
      }
    });

    // Create namespace if it doesnt exist (db tables)
    ger.initialize_namespace(config.namespace)
      .then((namespace) => {
        console.info(`initialized ${config.namespace}:`, namespace)
      })

    this._ger = ger;
  }

  /**
  * Track actions like `bob`, `likes`, `jill` and
  **/
  trackEvent(params, done) {
    this._ger.events([params.event])
      .then((event) => {
        done(null, params.event);
      })
      .catch((error) => {
        done('Failed to save event: ', params.event);
      });
  }

  /**
  * Get recommendations for user and filter
  * out user blacklisted ids.
  **/
  getRecommendations(params, done) {

  }
}

export default MatchingService

from ger.

grahamjenson avatar grahamjenson commented on August 27, 2024

Hey, this was awesome. Cheers for contributing :)

Yeah namespaces are just buckets where events live, so one needs to be created before events go into it. I used to check before each event if the namespace exists and if it didnt create it. But this was a massive performance hit for something that would just be a one-off event.

from ger.

joshbedo avatar joshbedo commented on August 27, 2024

Yeah i was confused originally because when i called initialize_namespace tables weren't being created and i didn't have any errors. I think this was due to my docker containers connecting together since i have a container for rethinkdb and another for our matching service.

Also was a little confused on the ESM setup and Rethinkdbdash but it makes sense now. Thanks for putting together the ESM!

from ger.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.