event_store 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +34 -20
- data/lib/event_store/version.rb +1 -1
- data/lib/event_store.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -1,34 +1,50 @@
|
|
1
1
|
# EventStore
|
2
2
|
|
3
|
-
Ruby implementation of an
|
3
|
+
A Very Fast Ruby implementation of an EventStore (A+ES).
|
4
|
+
For more detail on what an EventStore is checkout what Gregg Young has to stay about it:
|
5
|
+
http://codebetter.com/gregyoung/2010/02/20/why-use-event-sourcing/
|
4
6
|
|
5
7
|
# Usage
|
6
8
|
|
7
|
-
Currently, `EventStore` supports `postgres`
|
9
|
+
Currently, `EventStore` supports `postgres` and `vertica` adapters.
|
8
10
|
|
9
|
-
### Connecting
|
11
|
+
### Connecting in Development or Test
|
10
12
|
```ruby
|
11
|
-
EventStore.
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
EventStore.postgres(:development)
|
14
|
+
EventStore.postgres #test
|
15
|
+
|
16
|
+
EventStore.vertica(:development)
|
17
|
+
EventStore.vertica #test
|
18
|
+
|
19
|
+
#Production
|
20
|
+
EventStore.connect_db(redis_config, database_config) #The redis and database configs are the standard hashes expected by the databases -- we just pass them directly in
|
19
21
|
```
|
20
|
-
The arguments to `EventStore#connect` are the same as those to `Sequel#connect`
|
21
22
|
|
22
23
|
### Notes on Connecting
|
23
24
|
|
25
|
+
- `EventStore` expects a database called `history_store` to exist.
|
26
|
+
- `postgres` will try to connect in dev and test mode as 'nexia:Password1@localhost'
|
24
27
|
- `postgres` will assume a port of `5432` if one is not supplied.
|
25
28
|
|
29
|
+
- `vertica` expects to find an environment variable (VERTICA_HOST) to be set and will use this as the host in dev and test mode
|
30
|
+
- `vertica` will assume its default port if one is not supplied.
|
31
|
+
- `vertica` will try to connect in dev and test mode as 'dbadmin:password@[vertica_host]'
|
32
|
+
- To find the ip address of vertica on your local box (running in a vm):
|
33
|
+
1. open Settings -> Network and select Wi-Fi
|
34
|
+
2. open a terminal in the VM
|
35
|
+
3. do /sbin/ifconfig (ifconfig is not in $PATH)
|
36
|
+
4. the inet address for en0 is what you want
|
37
|
+
Hint: if it just hangs, you have have the wrong IP
|
38
|
+
|
26
39
|
### Creating a client
|
27
40
|
|
28
41
|
```ruby
|
29
42
|
client = EventStore::Client.new(aggregate_id)
|
30
43
|
|
31
|
-
# Get
|
44
|
+
# Get a list of events representing a snapshot of the aggregate's current state (fast)
|
45
|
+
client.snapshot
|
46
|
+
|
47
|
+
# Get an aggregate's entire event stream (can be very large)
|
32
48
|
client.event_stream
|
33
49
|
|
34
50
|
# Get an aggregate's event stream starting from a version
|
@@ -42,12 +58,10 @@ client.peek
|
|
42
58
|
|
43
59
|
# Append events to an aggregate's event stream
|
44
60
|
client.append(events, expected_version)
|
45
|
-
```
|
46
|
-
|
47
|
-
### Migrating your database
|
48
61
|
|
49
|
-
|
50
|
-
|
62
|
+
# Get the current version of an aggregate
|
63
|
+
client.version
|
51
64
|
|
52
|
-
|
53
|
-
|
65
|
+
# Drop all the events associated with an aggregate, including its snapshot
|
66
|
+
client.destroy!
|
67
|
+
```
|
data/lib/event_store/version.rb
CHANGED
data/lib/event_store.rb
CHANGED
@@ -95,7 +95,7 @@ module EventStore
|
|
95
95
|
#3. do /sbin/ifconfig (ifconfig is not in $PATH)
|
96
96
|
#4. the inet address for en0 is what you want
|
97
97
|
#Hint: if it just hangs, you have have the wrong IP
|
98
|
-
db_config['host'] = vertica_host
|
98
|
+
db_config['host'] = ENV['VERTICA_HOST'] || vertica_host
|
99
99
|
@migrations_dir = 'db/migrations'
|
100
100
|
else
|
101
101
|
@migrations_dir = 'db/pg_migrations'
|