Skip to content

Commit 1e260ea

Browse files
committed
added ger_mysql_esm
1 parent d2952fa commit 1e260ea

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

cli.coffee

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ cli = ->
2020
.usage('[options]')
2121
.description('start a hapiger server')
2222
.option('-p, --port <port>', 'the port to start the server on', 3456)
23-
.option('-e, --es <esm>', 'select Event Store [memory, pg, rethinkdb]', 'memory')
23+
.option('-e, --es <esm>', 'select Event Store [memory, pg, rethinkdb, mysql]', 'memory')
2424
.option('-E, --esoptions <options>', 'JSON representation of Options for Event Store e.g. "{"url": "postgres://localhost/hapiger"}"
2525
\n\t memory -- {}
2626
\n\t pg -- {"url" : "postgres url"}
27-
\n\t rethinkdb -- "{"host": "rethinkdb host", "port": "rethink port", "db": "rethink database"}
27+
\n\t rethinkdb -- {"host": "rethinkdb host", "port": "rethink port", "db": "rethink database"}
28+
\n\t mysql -- {"connection": {"host": "mysql host", "port": "mysql port", "user": "mysql user", "password": "mysql password"}}
2829
', ((input) -> JSON.parse(input)), {})
2930
.option('-v, --verbose', "More Output", false)
3031
.option('-D --default_configuration', "Default Configuration to generate recommendations", {})

lib/hapi_server.coffee

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ ret_esm = require 'ger_rethinkdb_esm'
2323
RethinkDBESM = ret_esm.esm
2424
r = ret_esm.r
2525

26+
mysql_esm = require 'ger_mysql_esm'
27+
MysqlESM = mysql_esm.esm
28+
2629
class HapiGER
2730
constructor: (options = {}) ->
2831
@options = _.defaults(options, {
@@ -53,6 +56,15 @@ class HapiGER
5356
rethinkcon = new r(@options.esmoptions)
5457
@_esm = new RethinkDBESM({r: rethinkcon}, GER.NamespaceDoestNotExist)
5558
@_ger = new GER(@_esm, @options)
59+
when 'mysql'
60+
esm_options = _.defaults(@options.esmoptions, {client: 'mysql'})
61+
esm_options.connection = _.defaults(@options.esmoptions.connection, {
62+
timezone: 'utc',
63+
charset: 'utf8'
64+
})
65+
knex = new knex(esm_options)
66+
@_esm = new MysqlESM({knex: knex}, GER.NamespaceDoestNotExist)
67+
@_ger = new GER(@_esm, @options)
5668
else
5769
throw new Error("no such esm")
5870

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"commander": "2.6.0",
3535
"ger": "0.0.98",
3636
"ger_rethinkdb_esm": "0.0.05",
37+
"ger_mysql_esm": "0.0.2",
3738
"moment": "2.9.0"
3839
},
3940
"devDependencies": {

test/spec_helper.coffee

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,15 @@ global.server = new HapiGER()
2424
# "port": 28015,
2525
# "db":"hapiger"
2626
# }})
27-
27+
#
28+
#global.server = new HapiGER({esm:'mysql', esmoptions: {
29+
# connection: {
30+
# host: 'localhost',
31+
# port: 3306,
32+
# user: 'root',
33+
# password: ''
34+
# }
35+
#}})
2836

2937
global.client = null
3038

0 commit comments

Comments
 (0)