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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c1d5dd6a294cd35c77f2250739875dc08478fba0ff05d188a6e24d1dd42eda3
4
- data.tar.gz: aa55ad837d15da082f29beac4d18287a40cdc8f0b833322fe9ab19a0d4c0a6d6
3
+ metadata.gz: 295c933a6bbc3937f2576f936df3f052c8fb11c3065b8c77b4f4ce5e9652ccf5
4
+ data.tar.gz: 6d0a18c426e98c39ec890053574066930089fb0cbd4603a72f12c39e093830b5
5
5
  SHA512:
6
- metadata.gz: 8628de42548c2d3b3b4a71ae1f5f26360f248c88965fdc6ea8403f3cc7b89cae8c03db57071322d7783977bc4ed762aba00c6dc29e1a782ccb66ed4c3695198e
7
- data.tar.gz: 1a198ce53073c97b2d386a0763a8def3c29f900fc59522fb77871c318f98560a3859aabdc1e927acd7e54c217444c64274b9b8d0d2b37fb5d8244f70729fb67b
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
+ ![faastRuby](https://faastruby.io/wp-content/uploads/2019/03/logo-positive.png)
1
2
  # faastruby-rpc
2
3
 
3
- Wrapper to make it easy to call FaaStRuby functions.
4
+ Wrapper to make it easy to call faastRuby functions.
4
5
 
5
- #### What is FaaStRuby?
6
- FaaStRuby is a serverless platform built for Ruby developers.
6
+ #### What is faastRuby?
7
+ faastRuby is a serverless software development platform for Ruby and Crystal.
7
8
 
8
- * [Tutorial](https://faastruby.io/getting-started)
9
+ * [Tutorial](https://faastruby.io/docs/faastruby-local)
9
10
 
10
- ## Calling functions from within a function (RPC calls)
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 FaaStRuby, or using `faastruby server`.
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::Function.new(function, raise_errors: raise_errors)
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
@@ -1,5 +1,5 @@
1
1
  module FaaStRuby
2
2
  module RPC
3
- VERSION = '0.2.5'
3
+ VERSION = '0.2.6'
4
4
  end
5
5
  end
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.5
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-16 00:00:00.000000000 Z
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