faastruby-rpc 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +2 -2
- data/README.md +8 -8
- data/lib/faastruby-rpc/function.rb +8 -0
- 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: 9c1d5dd6a294cd35c77f2250739875dc08478fba0ff05d188a6e24d1dd42eda3
|
4
|
+
data.tar.gz: aa55ad837d15da082f29beac4d18287a40cdc8f0b833322fe9ab19a0d4c0a6d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8628de42548c2d3b3b4a71ae1f5f26360f248c88965fdc6ea8403f3cc7b89cae8c03db57071322d7783977bc4ed762aba00c6dc29e1a782ccb66ed4c3695198e
|
7
|
+
data.tar.gz: 1a198ce53073c97b2d386a0763a8def3c29f900fc59522fb77871c318f98560a3859aabdc1e927acd7e54c217444c64274b9b8d0d2b37fb5d8244f70729fb67b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.2.5 - Mar 16 2019
|
4
|
+
- Add `inspect` method for when `p` is called. Ex: p Constant.call
|
5
|
+
- Added alias methods `value` - `Constant.call.value`
|
6
|
+
- Remove references to workspace from README, as the workspace name is not part of the URI path anymore.
|
7
|
+
|
3
8
|
## 0.2.4 - Mar 14 2019
|
4
9
|
- Only capitalize first letter when creating constant to assign to fulction call
|
5
10
|
|
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.4)
|
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.10)
|
17
17
|
public_suffix (3.0.3)
|
18
18
|
rake (10.5.0)
|
19
19
|
rspec (3.8.0)
|
data/README.md
CHANGED
@@ -14,13 +14,13 @@ To call another function you must first require it on the top of `handler.rb`, p
|
|
14
14
|
To call the function, use the method `call`. Here is an example.
|
15
15
|
|
16
16
|
```ruby
|
17
|
-
require_function '
|
17
|
+
require_function 'hello-world', as: 'HelloWorld'
|
18
18
|
def handler(event)
|
19
19
|
hello = HelloWorld.call # Async call
|
20
20
|
hello.class #=> FaaStRuby::RPC::Function
|
21
21
|
hello.returned? #=> false # READ BELOW TO UNDERSTAND
|
22
|
-
hello #=>
|
23
|
-
hello.
|
22
|
+
puts hello #=> Hello, World! - Will block and wait until the response arrives
|
23
|
+
returned_value = hello.value #=> 'Hello, World!' - Block, wait for the response and assign to variable 'returned_value'
|
24
24
|
hello.returned? #=> true # READ BELOW TO UNDERSTAND
|
25
25
|
hello.code #=> 200 - The status code
|
26
26
|
hello.headers #=> {"content-type"=>"text/plain", "x-content-type-options"=>"nosniff", "connection"=>"close", "content-length"=>"5"} - The response headers
|
@@ -37,7 +37,7 @@ If at any point you need to know if the external function call already returned
|
|
37
37
|
|
38
38
|
## Passing arguments to the called function
|
39
39
|
|
40
|
-
Say you have the following function
|
40
|
+
Say you have the following function named `echo`:
|
41
41
|
|
42
42
|
```ruby
|
43
43
|
# Note the required keyword argument 'name:'
|
@@ -49,7 +49,7 @@ end
|
|
49
49
|
If you want to call this function in another function, you can simply pass the argument within `call`:
|
50
50
|
|
51
51
|
```ruby
|
52
|
-
require_function '
|
52
|
+
require_function 'echo', as: 'Echo'
|
53
53
|
def handler(event)
|
54
54
|
name = Echo.call(name: 'John Doe') # Async call
|
55
55
|
render text: "Hello, #{name}!" # calling 'name' will block until Echo returns
|
@@ -63,7 +63,7 @@ This gem is already required when you run your functions in FaaStRuby, or using
|
|
63
63
|
If you pass a block when you call another function, the block will execute as soon as the response arrives. For example:
|
64
64
|
|
65
65
|
```ruby
|
66
|
-
require_function '
|
66
|
+
require_function 'echo', as: 'Echo'
|
67
67
|
def handler(event)
|
68
68
|
name = Echo.call(name: 'john doe') do |response|
|
69
69
|
# response.body #=> "john doe"
|
@@ -90,11 +90,11 @@ require_function 'paulo/hello-world', as: 'HelloWorld', raise_errors: false
|
|
90
90
|
If you are testing a function that required another one, you likely will want to fake that call. To do that, use the following test helper:
|
91
91
|
|
92
92
|
```ruby
|
93
|
-
# This will make it fake the calls to '
|
93
|
+
# This will make it fake the calls to 'hello-world'
|
94
94
|
# and return the values you pass in the block.
|
95
95
|
require 'faastruby-rpc/test_helper'
|
96
96
|
|
97
|
-
FaaStRuby::RPC.stub_call('
|
97
|
+
FaaStRuby::RPC.stub_call('hello-world') do |response|
|
98
98
|
response.body = "hello, world!"
|
99
99
|
response.code = 200
|
100
100
|
response.headers = {'A-Header' => 'foobar'}
|
@@ -86,6 +86,10 @@ module FaaStRuby
|
|
86
86
|
!@response.nil?
|
87
87
|
end
|
88
88
|
|
89
|
+
def value
|
90
|
+
body
|
91
|
+
end
|
92
|
+
|
89
93
|
def method_missing(m, *args, &block)
|
90
94
|
rsp = response.body
|
91
95
|
rsp.send(m.to_sym, *args, &block)
|
@@ -100,6 +104,10 @@ module FaaStRuby
|
|
100
104
|
body.to_s || ""
|
101
105
|
end
|
102
106
|
|
107
|
+
def inspect
|
108
|
+
body.inspect || ""
|
109
|
+
end
|
110
|
+
|
103
111
|
# alias_method :read, :to_s
|
104
112
|
|
105
113
|
def body
|
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.5
|
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-03-
|
11
|
+
date: 2019-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|