grpclb 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ruby/lib/grpclb.rb +31 -0
- data/ruby/lib/grpclb_backend_v1/backend_pb.rb +21 -0
- data/ruby/lib/grpclb_backend_v1/backend_services_pb.rb +26 -0
- data/ruby/lib/grpclb_balancer_v1/balancer_pb.rb +27 -0
- data/ruby/lib/grpclb_balancer_v1/balancer_services_pb.rb +26 -0
- metadata +89 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7b85ba65cf8d185b28e8b75ff30dc889201ed2ab
|
4
|
+
data.tar.gz: 7d338e7ae2e0856698dfe9f07c9745fa2abb6beb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e77a00a74ccc9bfc06c7958559a77808dcad2c6798dfc4b6754a4d3d051dec8034681402136be4d38dea0a47a6d36ae575b3d78322b5a9b3d200a83c81258aee
|
7
|
+
data.tar.gz: 185c097ed9def4b65b05a332f39607a14e45b73c1ac8351d9efdc7d2e4335e3853e18a1e1553211877d89cc9a992a699a11d7e91211e3634629934713f8a10c2
|
data/ruby/lib/grpclb.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'grpclb_backend_v1/backend_pb'
|
2
|
+
require 'grpclb_backend_v1/backend_services_pb'
|
3
|
+
require 'grpclb_balancer_v1/balancer_pb'
|
4
|
+
require 'grpclb_balancer_v1/balancer_services_pb'
|
5
|
+
|
6
|
+
class Grpclb::Client < ::SimpleDelegator
|
7
|
+
attr_reader :target
|
8
|
+
|
9
|
+
# @param [String] lb_addr the load balancer address
|
10
|
+
# @param [String] target the target service name, as registered in the backend
|
11
|
+
# @param [Class] service_stub the service stub class
|
12
|
+
def initialize(lb_addr, target, service_stub, lb_creds: :this_channel_is_insecure, service_creds: :this_channel_is_insecure)
|
13
|
+
@lb_stub = Grpclb::Balancer::V1::LoadBalancer::Stub.new(lb_addr, lb_creds)
|
14
|
+
@target = target
|
15
|
+
@service_stub = service_stub
|
16
|
+
@service_creds = service_creds
|
17
|
+
|
18
|
+
reconnect!
|
19
|
+
end
|
20
|
+
|
21
|
+
def reconnect!
|
22
|
+
req = Grpclb::Balancer::V1::ServersRequest.new(target: target)
|
23
|
+
servers = @lb_stub.servers(req).servers
|
24
|
+
raise "No servers available for target '#{target}'" if servers.empty?
|
25
|
+
|
26
|
+
primary = servers.first.address
|
27
|
+
client = @service_stub.new(primary, @service_creds)
|
28
|
+
__setobj__(client)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: grpclb_backend_v1/backend.proto
|
3
|
+
|
4
|
+
require 'google/protobuf'
|
5
|
+
|
6
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
7
|
+
add_message "grpclb.backend.v1.LoadRequest" do
|
8
|
+
end
|
9
|
+
add_message "grpclb.backend.v1.LoadResponse" do
|
10
|
+
optional :score, :int64, 1
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module Grpclb
|
15
|
+
module Backend
|
16
|
+
module V1
|
17
|
+
LoadRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpclb.backend.v1.LoadRequest").msgclass
|
18
|
+
LoadResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpclb.backend.v1.LoadResponse").msgclass
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# Source: grpclb_backend_v1/backend.proto for package 'grpclb.backend.v1'
|
3
|
+
|
4
|
+
require 'grpc'
|
5
|
+
require 'grpclb_backend_v1/backend_pb'
|
6
|
+
|
7
|
+
module Grpclb
|
8
|
+
module Backend
|
9
|
+
module V1
|
10
|
+
module LoadReport
|
11
|
+
class Service
|
12
|
+
|
13
|
+
include GRPC::GenericService
|
14
|
+
|
15
|
+
self.marshal_class_method = :encode
|
16
|
+
self.unmarshal_class_method = :decode
|
17
|
+
self.service_name = 'grpclb.backend.v1.LoadReport'
|
18
|
+
|
19
|
+
rpc :Load, LoadRequest, LoadResponse
|
20
|
+
end
|
21
|
+
|
22
|
+
Stub = Service.rpc_stub_class
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: grpclb_balancer_v1/balancer.proto
|
3
|
+
|
4
|
+
require 'google/protobuf'
|
5
|
+
|
6
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
7
|
+
add_message "grpclb.balancer.v1.Server" do
|
8
|
+
optional :address, :string, 1
|
9
|
+
optional :score, :int64, 2
|
10
|
+
end
|
11
|
+
add_message "grpclb.balancer.v1.ServersRequest" do
|
12
|
+
optional :target, :string, 1
|
13
|
+
end
|
14
|
+
add_message "grpclb.balancer.v1.ServersResponse" do
|
15
|
+
repeated :servers, :message, 1, "grpclb.balancer.v1.Server"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
module Grpclb
|
20
|
+
module Balancer
|
21
|
+
module V1
|
22
|
+
Server = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpclb.balancer.v1.Server").msgclass
|
23
|
+
ServersRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpclb.balancer.v1.ServersRequest").msgclass
|
24
|
+
ServersResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpclb.balancer.v1.ServersResponse").msgclass
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# Source: grpclb_balancer_v1/balancer.proto for package 'grpclb.balancer.v1'
|
3
|
+
|
4
|
+
require 'grpc'
|
5
|
+
require 'grpclb_balancer_v1/balancer_pb'
|
6
|
+
|
7
|
+
module Grpclb
|
8
|
+
module Balancer
|
9
|
+
module V1
|
10
|
+
module LoadBalancer
|
11
|
+
class Service
|
12
|
+
|
13
|
+
include GRPC::GenericService
|
14
|
+
|
15
|
+
self.marshal_class_method = :encode
|
16
|
+
self.unmarshal_class_method = :decode
|
17
|
+
self.service_name = 'grpclb.balancer.v1.LoadBalancer'
|
18
|
+
|
19
|
+
rpc :Servers, ServersRequest, ServersResponse
|
20
|
+
end
|
21
|
+
|
22
|
+
Stub = Service.rpc_stub_class
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: grpclb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Black Square Media
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-10-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: grpc
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: grpc-tools
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- ruby/lib/grpclb.rb
|
62
|
+
- ruby/lib/grpclb_backend_v1/backend_pb.rb
|
63
|
+
- ruby/lib/grpclb_backend_v1/backend_services_pb.rb
|
64
|
+
- ruby/lib/grpclb_balancer_v1/balancer_pb.rb
|
65
|
+
- ruby/lib/grpclb_balancer_v1/balancer_services_pb.rb
|
66
|
+
homepage:
|
67
|
+
licenses: []
|
68
|
+
metadata: {}
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- ruby/lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 2.6.11
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: grpclb ruby protocol
|
89
|
+
test_files: []
|