faastruby-rpc 0.2.5 → 0.2.6
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 +4 -0
- data/README.md +7 -6
- data/lib/faastruby-rpc.rb +2 -9
- data/lib/faastruby-rpc/caller.rb +15 -0
- data/lib/faastruby-rpc/function.rb +1 -1
- data/lib/faastruby-rpc/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 295c933a6bbc3937f2576f936df3f052c8fb11c3065b8c77b4f4ce5e9652ccf5
|
4
|
+
data.tar.gz: 6d0a18c426e98c39ec890053574066930089fb0cbd4603a72f12c39e093830b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b58a4026b6e45cb6a1f9df768df9e9809b0b97134af4a8a5e1ed7f4ea2c2a25048fe128560c2819b9e16c1dc9aa3c00f20c55338cee2295c166ffb792d86e881
|
7
|
+
data.tar.gz: ffc3a95906dcf78dc25bfc58220edafe9ce46e53f3172ce35d1e9bc28163b58e15cec0057b0d0167de38de04a5a38cc56a1185ac2c93c8ee342254fb6062d3d4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.2.6 - Mar 18 2019
|
4
|
+
- Multiple calls to the same function no longer overwrite each other.
|
5
|
+
- Use Oj mode :compat when converting keyword arguments to JSON.
|
6
|
+
|
3
7
|
## 0.2.5 - Mar 16 2019
|
4
8
|
- Add `inspect` method for when `p` is called. Ex: p Constant.call
|
5
9
|
- Added alias methods `value` - `Constant.call.value`
|
data/README.md
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
+

|
1
2
|
# faastruby-rpc
|
2
3
|
|
3
|
-
Wrapper to make it easy to call
|
4
|
+
Wrapper to make it easy to call faastRuby functions.
|
4
5
|
|
5
|
-
#### What is
|
6
|
-
|
6
|
+
#### What is faastRuby?
|
7
|
+
faastRuby is a serverless software development platform for Ruby and Crystal.
|
7
8
|
|
8
|
-
* [Tutorial](https://faastruby.io/
|
9
|
+
* [Tutorial](https://faastruby.io/docs/faastruby-local)
|
9
10
|
|
10
|
-
## Calling functions from within a function
|
11
|
+
## Calling functions from within a function asynchronously
|
11
12
|
|
12
13
|
To call another function you must first require it on the top of `handler.rb`, passing a string that will be converted to a constant. You then use the constant to call the function and get its response.
|
13
14
|
|
@@ -57,7 +58,7 @@ end
|
|
57
58
|
```
|
58
59
|
You can use positional or keyword arguments when calling external functions, as long as the external function's `handler` method is defined with matching arguments.
|
59
60
|
|
60
|
-
This gem is already required when you run your functions in
|
61
|
+
This gem is already required when you run your functions in faastRuby, or using `faastruby server`.
|
61
62
|
|
62
63
|
## Running code when the invoked function responds
|
63
64
|
If you pass a block when you call another function, the block will execute as soon as the response arrives. For example:
|
data/lib/faastruby-rpc.rb
CHANGED
@@ -3,6 +3,7 @@ require 'oj'
|
|
3
3
|
require 'yaml'
|
4
4
|
require 'openssl'
|
5
5
|
require 'faastruby-rpc/version'
|
6
|
+
require 'faastruby-rpc/caller'
|
6
7
|
require 'faastruby-rpc/function'
|
7
8
|
|
8
9
|
(Net::HTTP::SSL_IVNAMES << :@ssl_options).uniq!
|
@@ -12,17 +13,9 @@ Net::HTTP.class_eval do
|
|
12
13
|
attr_accessor :ssl_options
|
13
14
|
end
|
14
15
|
|
15
|
-
def invoke(function, raise_errors: true)
|
16
|
-
function(function, raise_errors: raise_errors)
|
17
|
-
end
|
18
|
-
|
19
|
-
def function(function, raise_errors: true)
|
20
|
-
FaaStRuby::RPC::Function.new(function, raise_errors: raise_errors)
|
21
|
-
end
|
22
|
-
|
23
16
|
def require_function(function, as:, raise_errors: true)
|
24
17
|
as[0] = as[0].capitalize
|
25
18
|
Object.send(:remove_const, as) if Object.const_defined?(as)
|
26
|
-
Object.const_set as, FaaStRuby::RPC::
|
19
|
+
Object.const_set as, FaaStRuby::RPC::Caller.new(function, raise_errors: raise_errors)
|
27
20
|
return false
|
28
21
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module FaaStRuby
|
2
|
+
module RPC
|
3
|
+
class Caller
|
4
|
+
def initialize(path, raise_errors: true)
|
5
|
+
@path = path
|
6
|
+
@raise_errors = raise_errors
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(*args)
|
10
|
+
function = FaaStRuby::RPC::Function.new(@path, raise_errors: @raise_errors)
|
11
|
+
function.call(*args)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -133,7 +133,7 @@ module FaaStRuby
|
|
133
133
|
private
|
134
134
|
|
135
135
|
def call_with(*args)
|
136
|
-
execute(req_body: Oj.dump(args), headers: {'Content-Type' => 'application/json', 'Faastruby-Rpc' => 'true'})
|
136
|
+
execute(req_body: Oj.dump(args, mode: :compat), headers: {'Content-Type' => 'application/json', 'Faastruby-Rpc' => 'true'})
|
137
137
|
end
|
138
138
|
|
139
139
|
def wait
|
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.6
|
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-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- bin/setup
|
101
101
|
- faastruby-rpc.gemspec
|
102
102
|
- lib/faastruby-rpc.rb
|
103
|
+
- lib/faastruby-rpc/caller.rb
|
103
104
|
- lib/faastruby-rpc/function.rb
|
104
105
|
- lib/faastruby-rpc/test_helper.rb
|
105
106
|
- lib/faastruby-rpc/version.rb
|