ocean-rails 4.0.2 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ocean/api.rb +2 -4
- data/lib/ocean/version.rb +1 -1
- metadata +1 -2
- data/lib/ocean/continuation_experiments.rb +0 -139
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 695bf42c433ee293191b3c856bdea9659fa6026b
|
4
|
+
data.tar.gz: 2472561dd035df00ca8ee24d923d6576ba3bc79f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c32548ba8c61a9b8348f8f710e97864ac26a58f2dd18dce8f2ceb2d872472630d2d30f3780e756e14d4336ab3fffcdcf818c56784d7e420e4293f69082a52c6a
|
7
|
+
data.tar.gz: 722dc5edec98fcf8a921fcc5f3b9372804eaedb4e33f6206b0090c48d4bf8a2e82f1add6e81bacc98dd9f768bb1c7861a1584aec8d3f42f9117f5de359acc74c
|
data/lib/ocean/api.rb
CHANGED
@@ -11,7 +11,6 @@ class Api
|
|
11
11
|
# etc.
|
12
12
|
#
|
13
13
|
def self.internalize_uri(uri, chef_env=CHEF_ENV)
|
14
|
-
return uri if chef_env == 'prod'
|
15
14
|
uri.sub(OCEAN_API_URL, INTERNAL_OCEAN_API_URL)
|
16
15
|
end
|
17
16
|
|
@@ -188,6 +187,8 @@ class Api
|
|
188
187
|
request = nil # For clarity
|
189
188
|
response = nil
|
190
189
|
|
190
|
+
url = url.first == "/" ? "#{INTERNAL_OCEAN_API_URL}#{url}" : Api.internalize_uri(url)
|
191
|
+
|
191
192
|
# This is a Proc when run queues the request and schedules retries
|
192
193
|
enqueue_request = lambda do
|
193
194
|
# First construct a request. It will not be sent yet.
|
@@ -422,9 +423,6 @@ class Api
|
|
422
423
|
#
|
423
424
|
def self.permitted?(token, args={})
|
424
425
|
raise unless token
|
425
|
-
#response = Api.get(:auth, "/authentications/#{token}", args)
|
426
|
-
|
427
|
-
#response
|
428
426
|
Api.request "#{INTERNAL_OCEAN_API_URL}/v1/authentications/#{token}", :get,
|
429
427
|
args: args
|
430
428
|
end
|
data/lib/ocean/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ocean-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Bengtson
|
@@ -252,7 +252,6 @@ files:
|
|
252
252
|
- lib/ocean/api.rb
|
253
253
|
- lib/ocean/api_remote_resource.rb
|
254
254
|
- lib/ocean/api_resource.rb
|
255
|
-
- lib/ocean/continuation_experiments.rb
|
256
255
|
- lib/ocean/engine.rb
|
257
256
|
- lib/ocean/flooding.rb
|
258
257
|
- lib/ocean/ocean_application_controller.rb
|
@@ -1,139 +0,0 @@
|
|
1
|
-
require 'continuation'
|
2
|
-
|
3
|
-
# Api.simultaneously takes a block. It executes the block straight away.
|
4
|
-
#
|
5
|
-
# When executing inside an Api.simultaneously block, Api.request only enqueues its request,
|
6
|
-
# but doesn't run it. They register on_complete handlers that will be run asynchronously
|
7
|
-
# when Api.simultaneously fires hydra to run after the block.
|
8
|
-
#
|
9
|
-
# When Api.request runs outside Api.simultaneously, it simply returns an Api::Response.
|
10
|
-
# When running inside Api.simultaneously, however, Api.request creates a continuation
|
11
|
-
# and registers it with Api.simultaneously. After the block has run, Api.simultaneously
|
12
|
-
# invokes each continuation in turn with another continuation to allow the next
|
13
|
-
# continuation to be called. When there are no more continuations to process,
|
14
|
-
# Api.simultaneously returns normally. In this way, all continuations are executed serially
|
15
|
-
# to process the Api.request results, no matter who called them or from where.
|
16
|
-
|
17
|
-
class Quux
|
18
|
-
|
19
|
-
require 'continuation'
|
20
|
-
|
21
|
-
|
22
|
-
def self.simultaneously?
|
23
|
-
!!@continuations
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.accumulating?
|
27
|
-
@accumulating
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
def self.simultaneously
|
32
|
-
raise "Api.simultaneously may not be nested" if simultaneously?
|
33
|
-
@continuations = []
|
34
|
-
# Execute the block
|
35
|
-
begin
|
36
|
-
puts "--------------------------- ACCUMULATING ------------------------"
|
37
|
-
@accumulating = true
|
38
|
-
yield @continuations
|
39
|
-
ensure
|
40
|
-
@accumulating = false
|
41
|
-
end
|
42
|
-
|
43
|
-
# The continuations array should now have entries. Create a continuation
|
44
|
-
# to return to this point.
|
45
|
-
begin
|
46
|
-
puts '', "--------------------------- EXECUTING ------------------------"
|
47
|
-
cc, results, result = callcc { |cc, results, result| [cc, [], :init] }
|
48
|
-
# '-BACK AT TOP LEVEL-----', [cc, results, result].inspect
|
49
|
-
raise "must be a continuation" unless cc.is_a? Continuation
|
50
|
-
results << result if result && result != :init
|
51
|
-
# Call the first accumulated continuation (if any) with it. When they call
|
52
|
-
# here, the next continuation will be called (if any). This is a loop,
|
53
|
-
# continuation style.
|
54
|
-
if @continuations.size > 0
|
55
|
-
@continuations.shift.call(cc, results)
|
56
|
-
end
|
57
|
-
ensure
|
58
|
-
# No longer nested
|
59
|
-
@continuations = nil
|
60
|
-
end
|
61
|
-
results
|
62
|
-
end
|
63
|
-
|
64
|
-
|
65
|
-
def self.doubler (arg, k: nil)
|
66
|
-
raise "K is not a continuation: #{k.inspect}" if k && !k.is_a?(Continuation)
|
67
|
-
cc, acc = callcc { |cc, acc| [cc, acc] }
|
68
|
-
puts '', '-CONTINUATION CALL TO DOUBLER-----', [cc, acc].inspect
|
69
|
-
return cc if accumulating?
|
70
|
-
|
71
|
-
# Execution phase
|
72
|
-
|
73
|
-
# Calculate a result
|
74
|
-
result = arg * 2 # Calculate the result
|
75
|
-
|
76
|
-
# Transfer back
|
77
|
-
k.call(k, result) if k # Go elsewhere if k is there (e.g. to a nested caller)
|
78
|
-
cc.call(cc, acc, result) # Return to caller
|
79
|
-
end
|
80
|
-
|
81
|
-
|
82
|
-
def self.nested(arg, k: nil)
|
83
|
-
raise "K is not a continuation: #{k.inspect}" if k && !k.is_a?(Continuation)
|
84
|
-
cc, acc = callcc { |cc, acc| [cc, acc] }
|
85
|
-
puts '', '-CONTINUATION CALL TO NESTED-----', [cc, acc].inspect
|
86
|
-
return cc if accumulating?
|
87
|
-
|
88
|
-
# Execution phase
|
89
|
-
# Set up the overriding continuation for the callee
|
90
|
-
callee_k, result = callcc { |callee_k, result| [callee_k, result] }
|
91
|
-
# The callee returns to the following statement
|
92
|
-
result = doubler(arg, k: callee_k) unless result # Can't be nil or false (fix later)
|
93
|
-
|
94
|
-
# Calculate a result
|
95
|
-
result = "#{result} processed"
|
96
|
-
|
97
|
-
# Transfer back
|
98
|
-
k.call(k, result) if k # Go elsewhere if k is there (e.g. to a nested caller)
|
99
|
-
cc.call(cc, acc, result) # Return to caller
|
100
|
-
end
|
101
|
-
|
102
|
-
|
103
|
-
def self.deeply_nested(arg, k: nil)
|
104
|
-
raise "K is not a continuation: #{k.inspect}" if k && !k.is_a?(Continuation)
|
105
|
-
cc, acc = callcc { |cc, acc| [cc, acc] }
|
106
|
-
puts '', '-CONTINUATION CALL TO DEEPLY_NESTED-----', [cc, acc].inspect
|
107
|
-
return cc if accumulating?
|
108
|
-
|
109
|
-
# Execution phase
|
110
|
-
# Set up the overriding continuation for the callee
|
111
|
-
callee_k, result = callcc { |callee_k, result| [callee_k, result] }
|
112
|
-
# The callee returns to the following statement
|
113
|
-
result = nested(arg, k: callee_k) unless result # Can't be nil or false (fix later)
|
114
|
-
|
115
|
-
# Calculate a result
|
116
|
-
result = "#{result} more deeply"
|
117
|
-
|
118
|
-
# Transfer back
|
119
|
-
k.call(k, result) if k # Go elsewhere if k is there (e.g. to a nested caller)
|
120
|
-
cc.call(cc, acc, result) # Return to caller
|
121
|
-
end
|
122
|
-
|
123
|
-
end
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
# This accumulates stuff
|
128
|
-
res = Quux.simultaneously do |r|
|
129
|
-
r << Quux.doubler(24)
|
130
|
-
r << Quux.nested("hej")
|
131
|
-
r << Quux.doubler(100)
|
132
|
-
r << Quux.deeply_nested("woo")
|
133
|
-
r << Quux.doubler(1)
|
134
|
-
end
|
135
|
-
|
136
|
-
puts
|
137
|
-
puts res.inspect
|
138
|
-
puts
|
139
|
-
|