Class: EventStore::HTTPClient::Projection::GetState
- Inherits:
-
Object
- Object
- EventStore::HTTPClient::Projection::GetState
- Defined in:
- lib/event_store_http_client/projection/get_state.rb
Instance Attribute Summary collapse
-
#partition ⇒ Object
Returns the value of attribute partition.
-
#projection ⇒ Object
Returns the value of attribute projection.
Class Method Summary collapse
Instance Method Summary collapse
- #! ⇒ Object
-
#initialize(projection, partition) ⇒ GetState
constructor
A new instance of GetState.
- #make_request ⇒ Object
Constructor Details
#initialize(projection, partition) ⇒ GetState
Returns a new instance of GetState.
29 30 31 32 |
# File 'lib/event_store_http_client/projection/get_state.rb', line 29 def initialize(projection, partition) @projection = projection @partition = partition end |
Instance Attribute Details
#partition ⇒ Object
Returns the value of attribute partition.
7 8 9 |
# File 'lib/event_store_http_client/projection/get_state.rb', line 7 def partition @partition end |
#projection ⇒ Object
Returns the value of attribute projection.
6 7 8 |
# File 'lib/event_store_http_client/projection/get_state.rb', line 6 def projection @projection end |
Class Method Details
.!(params) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/event_store_http_client/projection/get_state.rb', line 12 def self.!(params) instance = build(params) instance.! do |result| yield result end end |
.build(params) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/event_store_http_client/projection/get_state.rb', line 19 def self.build(params) projection = params[:projection] partition = params[:partition] new(projection, partition).tap do |instance| Logger.configure instance EventStore::HTTPClient::Client::Builder.configure instance end end |
Instance Method Details
#! ⇒ Object
34 35 36 37 38 |
# File 'lib/event_store_http_client/projection/get_state.rb', line 34 def ! make_request do |result| yield result end end |
#make_request ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/event_store_http_client/projection/get_state.rb', line 40 def make_request logger.debug "Making request to /projection/#{projection}/state?partition=#{partition}" request = client.get("/projection/#{projection}/state?partition=#{partition}") do |resp| logger.debug "Response #{resp.status_code}" resp.body_handler do |body| status = resp.status_code == 200 ? :success : :error yield({ status: status, status_code: resp.status_code, body: body}) end end # If I put this 'Accept' header in, it returns a 406. Else, it works # request.put_header('Accept', 'application/vnd.eventstore.atom+json') request.put_header('Content-Type', 'application/json') request.exception_handler { |e| logger.error "Projection failed to query state, trying again" Vertx.set_timer(rand(1000)) do make_request end } request.end end |