Skip to content

Commit

Permalink
added ger_mysql_esm
Browse files Browse the repository at this point in the history
  • Loading branch information
nikashitsa committed Dec 30, 2016
1 parent d2952fa commit 1e260ea
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
5 changes: 3 additions & 2 deletions cli.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ cli = ->
.usage('[options]')
.description('start a hapiger server')
.option('-p, --port <port>', 'the port to start the server on', 3456)
.option('-e, --es <esm>', 'select Event Store [memory, pg, rethinkdb]', 'memory')
.option('-e, --es <esm>', 'select Event Store [memory, pg, rethinkdb, mysql]', 'memory')
.option('-E, --esoptions <options>', 'JSON representation of Options for Event Store e.g. "{"url": "postgres://localhost/hapiger"}"
\n\t memory -- {}
\n\t pg -- {"url" : "postgres url"}
\n\t rethinkdb -- "{"host": "rethinkdb host", "port": "rethink port", "db": "rethink database"}
\n\t rethinkdb -- {"host": "rethinkdb host", "port": "rethink port", "db": "rethink database"}
\n\t mysql -- {"connection": {"host": "mysql host", "port": "mysql port", "user": "mysql user", "password": "mysql password"}}
', ((input) -> JSON.parse(input)), {})
.option('-v, --verbose', "More Output", false)
.option('-D --default_configuration', "Default Configuration to generate recommendations", {})
Expand Down
12 changes: 12 additions & 0 deletions lib/hapi_server.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ ret_esm = require 'ger_rethinkdb_esm'
RethinkDBESM = ret_esm.esm
r = ret_esm.r

mysql_esm = require 'ger_mysql_esm'
MysqlESM = mysql_esm.esm

class HapiGER
constructor: (options = {}) ->
@options = _.defaults(options, {
Expand Down Expand Up @@ -53,6 +56,15 @@ class HapiGER
rethinkcon = new r(@options.esmoptions)
@_esm = new RethinkDBESM({r: rethinkcon}, GER.NamespaceDoestNotExist)
@_ger = new GER(@_esm, @options)
when 'mysql'
esm_options = _.defaults(@options.esmoptions, {client: 'mysql'})
esm_options.connection = _.defaults(@options.esmoptions.connection, {
timezone: 'utc',
charset: 'utf8'
})
knex = new knex(esm_options)
@_esm = new MysqlESM({knex: knex}, GER.NamespaceDoestNotExist)
@_ger = new GER(@_esm, @options)
else
throw new Error("no such esm")

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"commander": "2.6.0",
"ger": "0.0.98",
"ger_rethinkdb_esm": "0.0.05",
"ger_mysql_esm": "0.0.2",
"moment": "2.9.0"
},
"devDependencies": {
Expand Down
10 changes: 9 additions & 1 deletion test/spec_helper.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ global.server = new HapiGER()
# "port": 28015,
# "db":"hapiger"
# }})

#
#global.server = new HapiGER({esm:'mysql', esmoptions: {
# connection: {
# host: 'localhost',
# port: 3306,
# user: 'root',
# password: ''
# }
#}})

global.client = null

Expand Down

0 comments on commit 1e260ea

Please sign in to comment.