grpc_toolbox 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/auditor_pb.rb +31 -0
- data/lib/auditor_services_pb.rb +23 -0
- data/lib/grpc_toolbox/client.rb +52 -0
- data/lib/grpc_toolbox/configuration.rb +7 -0
- data/lib/grpc_toolbox.rb +20 -0
- metadata +159 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: da2f6797db91e94219dec03cec4c4307c5024214a01960be0792bbbed7ae5fba
|
4
|
+
data.tar.gz: b7f81cb665732370b3a6970f9dad032a7b9da91e671dbd1b0f4fd83a350306c5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 842da7b4be6a6d0fa2a1f3d3959b10f60e0f62ac04781f482e297f78db417b83dab1a601a3459d660f1802993178d0bc7ff84a6ac4743be77cb23bcd77595958
|
7
|
+
data.tar.gz: 8cfa6e2259ef1779df889c3cd6c5a0d7aa41f672123ce272ec4571b553c2b753fa2b9068917d8d297520362d3c4e141965b5052e69926c7495c701fffcffc21e
|
data/lib/auditor_pb.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: auditor.proto
|
3
|
+
|
4
|
+
require 'google/protobuf'
|
5
|
+
|
6
|
+
require 'google/protobuf/timestamp_pb'
|
7
|
+
|
8
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
9
|
+
add_file("auditor.proto", :syntax => :proto3) do
|
10
|
+
add_message "auditor.SendAuditRequest" do
|
11
|
+
optional :origin_ip, :string, 1
|
12
|
+
optional :username, :string, 2
|
13
|
+
optional :origin_type, :string, 3
|
14
|
+
optional :operation_timestamp, :message, 4, "google.protobuf.Timestamp"
|
15
|
+
optional :system, :string, 5
|
16
|
+
optional :module, :string, 6
|
17
|
+
optional :operation_type, :string, 7
|
18
|
+
optional :diff_data, :bytes, 8
|
19
|
+
optional :full_data, :bytes, 9
|
20
|
+
end
|
21
|
+
add_message "auditor.SendAuditReply" do
|
22
|
+
optional :accepted, :bool, 1
|
23
|
+
optional :message, :string, 2
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
module Auditor
|
29
|
+
SendAuditRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("auditor.SendAuditRequest").msgclass
|
30
|
+
SendAuditReply = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("auditor.SendAuditReply").msgclass
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# Source: auditor.proto for package 'auditor'
|
3
|
+
|
4
|
+
require 'grpc'
|
5
|
+
require 'auditor_pb'
|
6
|
+
|
7
|
+
module Auditor
|
8
|
+
module Auditor
|
9
|
+
# The audit service definition
|
10
|
+
class Service
|
11
|
+
|
12
|
+
include ::GRPC::GenericService
|
13
|
+
|
14
|
+
self.marshal_class_method = :encode
|
15
|
+
self.unmarshal_class_method = :decode
|
16
|
+
self.service_name = 'auditor.Auditor'
|
17
|
+
|
18
|
+
rpc :SendAudit, ::Auditor::SendAuditRequest, ::Auditor::SendAuditReply
|
19
|
+
end
|
20
|
+
|
21
|
+
Stub = Service.rpc_stub_class
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'grpc'
|
4
|
+
require 'concurrent-ruby'
|
5
|
+
|
6
|
+
require 'auditor_services_pb'
|
7
|
+
|
8
|
+
module GRPCToolbox
|
9
|
+
class Client
|
10
|
+
include Concurrent::Async
|
11
|
+
|
12
|
+
def config
|
13
|
+
@config ||= GRPCToolbox.configuration
|
14
|
+
end
|
15
|
+
|
16
|
+
def send_audit_request(params)
|
17
|
+
stub = Auditor::Auditor::Stub.new(config.server,channel_credentials)
|
18
|
+
|
19
|
+
begin
|
20
|
+
message = stub.send_audit(
|
21
|
+
Auditor::SendAuditRequest.new(audit_request_params(params))
|
22
|
+
).message
|
23
|
+
rescue GRPC::BadStatus => e
|
24
|
+
abort "ERROR: #{e.message}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def channel_credentials
|
31
|
+
@channel_credentials ||= GRPC::Core::ChannelCredentials.new(
|
32
|
+
File.read(config.certificate_path)
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
def audit_request_params(params)
|
37
|
+
# TODO: pensar numa forma de indicar ao cliente como mandar os parametros corretos
|
38
|
+
# TODO: adicionar uma clausula que quebra caso algum dado importante nao seja mandado
|
39
|
+
{
|
40
|
+
origin_ip: params[:origin_ip],
|
41
|
+
username: params[:username],
|
42
|
+
origin_type: params[:origin_type],
|
43
|
+
operation_timestamp: Time.now.getutc,
|
44
|
+
system: params[:system],
|
45
|
+
module: params[:module],
|
46
|
+
operation_type: params[:operation_type],
|
47
|
+
diff_data: params[:diff_data],
|
48
|
+
full_data: params[:full_data]
|
49
|
+
}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/grpc_toolbox.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'grpc_toolbox/client'
|
4
|
+
require 'grpc_toolbox/configuration'
|
5
|
+
|
6
|
+
module GRPCToolbox
|
7
|
+
class << self
|
8
|
+
def reset
|
9
|
+
@configuration = Configuration.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def configuration
|
13
|
+
@configuration ||= Configuration.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def configure
|
17
|
+
yield(configuration)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: grpc_toolbox
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ricardo de Lucas
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-03-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 13.0.6
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 13.0.6
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: grpc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.52.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.52.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: concurrent-ruby
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.2.2
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.2.2
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: grpc-tools
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: dotenv
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry-byebug
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: shoulda-matchers
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.1'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.1'
|
125
|
+
description: A simple grpc gem for now
|
126
|
+
email: rlnascimento@guide.com.br
|
127
|
+
executables: []
|
128
|
+
extensions: []
|
129
|
+
extra_rdoc_files: []
|
130
|
+
files:
|
131
|
+
- lib/auditor_pb.rb
|
132
|
+
- lib/auditor_services_pb.rb
|
133
|
+
- lib/grpc_toolbox.rb
|
134
|
+
- lib/grpc_toolbox/client.rb
|
135
|
+
- lib/grpc_toolbox/configuration.rb
|
136
|
+
homepage: https://rubygems.org/gems/hola
|
137
|
+
licenses:
|
138
|
+
- MIT
|
139
|
+
metadata: {}
|
140
|
+
post_install_message:
|
141
|
+
rdoc_options: []
|
142
|
+
require_paths:
|
143
|
+
- lib
|
144
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
requirements: []
|
155
|
+
rubygems_version: 3.4.6
|
156
|
+
signing_key:
|
157
|
+
specification_version: 4
|
158
|
+
summary: GRPC Toolbox
|
159
|
+
test_files: []
|