faastruby-rpc 0.2.6 → 0.2.7
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/CHANGELOG.md +3 -0
- data/Gemfile.lock +2 -2
- data/README.md +8 -7
- data/lib/faastruby-rpc/function.rb +4 -3
- data/lib/faastruby-rpc/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0c3418f7df2adeeb036da90edb276f35dfdbb219e590eb7b75ceb0e3495f7df
|
4
|
+
data.tar.gz: e17da63372be23f2c4b2aebce1fe3eb8c2cebae4a1443dd3d4c3e2915133dead
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 246c0d3311733f50d9fcd667c840ca6078308e3aa70c3820e211c74d05485a103291cbc3e24e41b710a24e461dc9ea9233d013cc94d85346c1a8526aa3c43052
|
7
|
+
data.tar.gz: a398d8633f992f561b1e8637f7b2d4b185b9b90f9994d5f82524b607b4c0f490b898fbfd6cc3af4c2f2319faacbf233b9b93619d86371963c1bc16683e96bf49
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
faastruby-rpc (0.2.
|
4
|
+
faastruby-rpc (0.2.7)
|
5
5
|
oj (~> 3.6)
|
6
6
|
|
7
7
|
GEM
|
@@ -13,7 +13,7 @@ GEM
|
|
13
13
|
safe_yaml (~> 1.0.0)
|
14
14
|
diff-lcs (1.3)
|
15
15
|
hashdiff (0.3.7)
|
16
|
-
oj (3.7.
|
16
|
+
oj (3.7.11)
|
17
17
|
public_suffix (3.0.3)
|
18
18
|
rake (10.5.0)
|
19
19
|
rspec (3.8.0)
|
data/README.md
CHANGED
@@ -41,13 +41,14 @@ If at any point you need to know if the external function call already returned
|
|
41
41
|
Say you have the following function named `echo`:
|
42
42
|
|
43
43
|
```ruby
|
44
|
-
|
45
|
-
def handler(event
|
46
|
-
|
44
|
+
require 'json'
|
45
|
+
def handler(event)
|
46
|
+
arguments = JSON.parse event.body
|
47
|
+
render text: arguments['name']
|
47
48
|
end
|
48
49
|
```
|
49
50
|
|
50
|
-
If you want to call this function
|
51
|
+
If you want to call this function from another function, you can simply pass the argument within `call`:
|
51
52
|
|
52
53
|
```ruby
|
53
54
|
require_function 'echo', as: 'Echo'
|
@@ -56,9 +57,9 @@ def handler(event)
|
|
56
57
|
render text: "Hello, #{name}!" # calling 'name' will block until Echo returns
|
57
58
|
end
|
58
59
|
```
|
59
|
-
You can use positional or keyword arguments when calling external functions,
|
60
|
+
You can use positional or keyword arguments when calling external functions, and have the called function's `handler` method parse the `event.body` as JSON.
|
60
61
|
|
61
|
-
This gem is already required when you run your functions in faastRuby, or using `faastruby
|
62
|
+
This gem is already required when you run your functions in faastRuby, or using `faastruby local`.
|
62
63
|
|
63
64
|
## Running code when the invoked function responds
|
64
65
|
If you pass a block when you call another function, the block will execute as soon as the response arrives. For example:
|
@@ -84,7 +85,7 @@ By default, an exception is raised if the invoked function HTTP status code is g
|
|
84
85
|
To disable this behaviour, pass `raise_errors: false` when requiring the function. For example:
|
85
86
|
|
86
87
|
```ruby
|
87
|
-
require_function '
|
88
|
+
require_function 'hello-world', as: 'HelloWorld', raise_errors: false
|
88
89
|
```
|
89
90
|
|
90
91
|
## Stubbing RPC calls in your function tests
|
@@ -15,8 +15,9 @@ module FaaStRuby
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
class Function
|
18
|
-
@@region = ENV['
|
19
|
-
@@endpoint_base_host = ENV['
|
18
|
+
@@region = ENV['FAASTRUBY_REGION']
|
19
|
+
@@endpoint_base_host = ENV['FAASTRUBY_WORKSPACE_BASE_HOST']
|
20
|
+
@@endpoint_base_protocol = ENV['FAASTRUBY_URL_PROTOCOL'] || 'https'
|
20
21
|
def self.workspace=(workspace)
|
21
22
|
@@workspace = workspace
|
22
23
|
end
|
@@ -42,7 +43,7 @@ module FaaStRuby
|
|
42
43
|
end
|
43
44
|
|
44
45
|
def get_endpoint(query_params)
|
45
|
-
return "
|
46
|
+
return "#{@@endpoint_base_protocol}://#{@@workspace}.#{@@region}.#{@@endpoint_base_host}/#{@path}#{query_params}" if @@endpoint_base_host && @@region && @@workspace
|
46
47
|
return "http://localhost:3000/#{@path}#{query_params}"
|
47
48
|
end
|
48
49
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faastruby-rpc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paulo Arruda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|