-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Meta data #22
Open
hallgren
wants to merge
7
commits into
arkency:master
Choose a base branch
from
hallgren:meta_data
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Meta data #22
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f01f3f6
append_to_stream can handle meta data
5c6371c
moved meta_data position in initialize of Event and added spec
c276a03
dont json parse empty string (data/meta_data) and return nil if event…
5653ed7
replaced meta_data with metadata
3363c55
put metadata in separate spec
79022ca
return {} instead of nil on data / metadata
ae02734
reset to data instead of eventType on nil check and let PR #21 fix this
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,18 +13,19 @@ def call(entries) | |
private | ||
|
||
def create_event(entry) | ||
return nil unless entry['data'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
return nil unless entry['eventType'] | ||
|
||
id = entry['eventNumber'] | ||
event_id = entry['eventId'] | ||
type = entry['eventType'] | ||
source_event_uri = entry['id'] | ||
data = JSON.parse(entry['data']) | ||
data = !entry['data'].nil? && !entry['data'].empty? ? JSON.parse(entry['data']) : nil | ||
stream_name = entry['streamId'] | ||
position = entry['positionEventNumber'] | ||
created_time = entry['updated'] ? Time.parse(entry['updated']) : nil | ||
meta_data = !entry['meta_data'].nil? && !entry['meta_data'].empty? ? JSON.parse(entry['meta_data']) : nil | ||
|
||
Event.new(type, data, source_event_uri, event_id, id, position, stream_name, created_time) | ||
Event.new(type, data, meta_data, source_event_uri, event_id, id, position, stream_name, created_time) | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,10 +10,10 @@ module Api | |
describe '#append_to_stream' do | ||
|
||
it "should handle one event" do | ||
event = Event.new('event_type', { data: 1 }) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are adding new thing here - so why changing existing tests instead of just adding a new one ? |
||
expect(client).to receive(:make_request).with(:post, '/streams/streamname', [{eventId: event.event_id, eventType: event.type, data: event.data}], {'accept' => 'application/vnd.eventstore.events+json', 'content-type' => 'application/vnd.eventstore.events+json'}) | ||
event = Event.new('event_type', { data: 1 }, { meta_data: 2}) | ||
expect(client).to receive(:make_request).with(:post, '/streams/streamname', [{eventId: event.event_id, eventType: event.type, data: event.data, metadata: { meta_data: 2}}], {'accept' => 'application/vnd.eventstore.events+json', 'content-type' => 'application/vnd.eventstore.events+json'}) | ||
client.append_to_stream(stream_name, event) | ||
expect(client).to receive(:make_request).with(:post, '/streams/streamname', [{eventId: event.event_id, eventType: event.type, data: event.data}], {'ES-ExpectedVersion' => '1', 'accept' => 'application/vnd.eventstore.events+json', 'content-type' => 'application/vnd.eventstore.events+json'}) | ||
expect(client).to receive(:make_request).with(:post, '/streams/streamname', [{eventId: event.event_id, eventType: event.type, data: event.data, metadata: { meta_data: 2}}], {'ES-ExpectedVersion' => '1', 'accept' => 'application/vnd.eventstore.events+json', 'content-type' => 'application/vnd.eventstore.events+json'}) | ||
client.append_to_stream(stream_name, event, 1) | ||
end | ||
|
||
|
@@ -22,7 +22,7 @@ module Api | |
event2 = Event.new('event-type2', {data: 2}) | ||
events = [event1, event2] | ||
|
||
expect(client).to receive(:make_request).with(:post, '/streams/streamname', [{eventId: event1.event_id, eventType: event1.type, data: event1.data},{eventId: event2.event_id, eventType: event2.type, data: event2.data}], {'ES-ExpectedVersion' => '1', 'accept' => 'application/vnd.eventstore.events+json', 'content-type' => 'application/vnd.eventstore.events+json'}) | ||
expect(client).to receive(:make_request).with(:post, '/streams/streamname', [{eventId: event1.event_id, eventType: event1.type, data: event1.data, metadata: nil},{eventId: event2.event_id, eventType: event2.type, data: event2.data, metadata: nil}], {'ES-ExpectedVersion' => '1', 'accept' => 'application/vnd.eventstore.events+json', 'content-type' => 'application/vnd.eventstore.events+json'}) | ||
client.append_to_stream(stream_name, events, 1) | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why
meta_data
? I would prefermetadata
as this is just a single word