- Download/Installation:
- on Ubuntu:
sudo service eventstore start
- Admin GUI: http://127.0.0.1:2113 (admin:changeit)
- When eventstore is installed on host instead of in the virtualbox, use port forwarding:
vagrant ssh -- -R 2113:localhost:2113
- Introduction: http://docs.geteventstore.com/introduction/
- Store events to a stream:
- streams are automatically created by posting data for the stream name
- general format:
[ { "eventId": "…", "eventType": "…", "data": {…}, "metadata": {…} } ]
(plus UUID if PUTing is used) - POSTing single events is assumed when content type is
application/json
orapplication/xml
- POSTing multiple events:
curl -i -d @testevents.txt "http://127.0.0.1:2113/streams/newstream" -H "Content-Type:application/vnd.eventstore.events+json"
- Single event POSTing allows to set
eventType
andeventId
via headersES-EventType
andES-EventId
:curl -i -d @singleevent.txt "http://127.0.0.1:2113/streams/shop" -H "Content-Type: application/json" -H "ES-EventType: HelloCreated" -H "ES-EventId: 8f5ff3e6-0e26-4510-96c4-7e61a270e6f6"
- Read streams:
- as Atom XML feed:
curl -i -H "Accept:application/atom+xml" "http://127.0.0.1:2113/streams/newstream"
- as Atom JSON feed:
curl -i -H "Accept: application/vnd.eventstore.atom+json" "http://127.0.0.1:2113/streams/newstream"
- single event payload as json:
curl -i -H "Accept: application/json" http://127.0.0.1:2113/streams/newstream/0
- as Atom XML feed:
- Setup ACL for a stream via the streams' metadata:
- Media types:
application/vnd.eventstore.events+json
andapplication/vnd.eventstore.events+xml
application/json
andapplication/xml
andtext/xml
- Projections
- used to query streams and create new persistent ones if needed
- when creating a projection one can specify whether to run it for history and stop or to run for the history and continue
- there are two standard projections built-in:
$by_category
for all events that have the same prefix (separator is-
)by_event_type
for all events that have the sametype
- e.g.:
fromCategory('foo')
gets all events from all streams starting with namefoo-
- general format:
fromStream("stream").when({ $init: f0, Event1: f1, Event2: f2, $any: f3 });
- use
$init
function to set initialstate
for your projection $any
will match all events to your function (useful when not caring for the actual event type as e.g. general metadata is interesting)- emit events to streams:
emit("stream", "eventtype", eventdata)
- emit w/o copy:
linkTo("stream", event)
doesn't actually write the event to the stream, but emits a pointer to the event to the stream (which doesn't make a difference when fetching the stream) - List existing projections:
curl -i 'http://localhost:2113/projections/any'
- Show state of specific projection:
curl -i 'http://localhost:2113/projection/$foo/state'
- Show query of specific projection:
curl -i 'http://localhost:2113/projection/$foo/query'
- Change query of projection:
curl -i -X PUT -d @proj.js 'http://localhost:2113/projection/$foo/query'
- create transient projection:
curl -i -d @projection-foo.js http://127.0.0.1:2113/projections/transient?enabled=yes -u admin:changeit -H "Content-Type: application/json"
– response contains projection name to querycurl -i http://127.0.0.1:2113/projection/uuid
- create projection:
curl -i -d @projection-foo.js 'http://127.0.0.1:2113/projections/continuous?name=$foo&enabled=yes&emit=yes&checkpoints=yes' -u admin:changeit -H "Content-Type: application/json"
(alternative tocontinuous
isonetime
)
- Subscriptions
- Live-only subscriptions
- Catch-up subscriptions
- Configuration read order
- Command Line Parameter (Most important)
- Environment Variable
- Configuration File
- Default (Least important)
Links/Sources:
- https://geteventstore.com/blog/
- http://docs.geteventstore.com/
- client: https://github.com/FriendsOfOuro/geteventstore-php-core
- above client w/ projection support: https://github.com/tetsuobe/php-eventstore-client
- client for event store TCP api: https://github.com/madkom/event-store-client
- a php7 client: https://github.com/rayrutjes/php-geteventstore-client
- https://groups.google.com/forum/#!forum/event-store
- http://www.ustream.tv/recorded/46673907
- http://blog.arkency.com/2015/03/your-solid-tool-for-event-sourcing-eventstore-examples/
- https://gist.github.com/graste/eebb6bf73b4226e47dcabfaa39f6a307
- Google protobuf v3+ brings php support as php package and extension for proto3 syntax https://github.com/google/protobuf/tree/master/php
Forks of https://github.com/FriendsOfOuro/geteventstore-php-core: