nwitch_grpc_client 0.1.0
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 +7 -0
- data/bin/ruby_nwitch_grpc +56 -0
- data/lib/nwitch_grpc_client.rb +29 -0
- data/lib/nwitch_grpc_client/check.rb +27 -0
- data/lib/nwitch_grpc_client/configuration.rb +10 -0
- data/lib/nwitch_grpc_client/notification.rb +41 -0
- data/lib/nwitch_grpc_client/protobuf/check_pb.rb +24 -0
- data/lib/nwitch_grpc_client/protobuf/check_services_pb.rb +21 -0
- data/lib/nwitch_grpc_client/protobuf/push_pb.rb +21 -0
- data/lib/nwitch_grpc_client/protobuf/push_services_pb.rb +21 -0
- data/lib/nwitch_grpc_client/version.rb +3 -0
- metadata +125 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d3e552502af98b57153f96b50d9e1dde6ff73995dfdd073b198850324b6de7ec
|
4
|
+
data.tar.gz: 2d870003edc110bca09649bb6e032fabaf4a11b4b0383c508bf51eb841cc0c81
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 062efd73bc3b88dd821f4845f4efd7b24f8defbe442d146120a3032918f869f0a36dc6a970ae643d04e9d640ebdc891fb2f14d6039d3c9ddae98871b65f9c3f8
|
7
|
+
data.tar.gz: 69b1720263d9cacf350f28f21a9918ab9b123b326412c554c725b6f104abbb17e926664bf4008e47254a2a5e7d2bb2096dcc400d52f3dd2ac3c634ad3f4b0ccc
|
@@ -0,0 +1,56 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'nwitch_grpc_client'
|
4
|
+
|
5
|
+
def success!
|
6
|
+
puts 'sent'
|
7
|
+
end
|
8
|
+
|
9
|
+
def failure!
|
10
|
+
puts 'failed'
|
11
|
+
exit 1
|
12
|
+
end
|
13
|
+
|
14
|
+
# This is used in local testing only.
|
15
|
+
# This token is invalid for production.
|
16
|
+
def push
|
17
|
+
NWitchGRPCClient.configure do |config|
|
18
|
+
config.nwitch_token = 'ff8a0d3af823f27d2ce36ed8-b9ac52cdff'
|
19
|
+
config.grpc_host = 'localhost:50051'
|
20
|
+
end
|
21
|
+
|
22
|
+
if NWitchGRPCClient::Notification.push(ARGV[0], ARGV[1], ARGV[2])
|
23
|
+
success!
|
24
|
+
else
|
25
|
+
failure!
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def push_with_token
|
30
|
+
if NWitchGRPCClient::Notification.push_with_token(ARGV[0], ARGV[1], ARGV[2], ARGV[3])
|
31
|
+
success!
|
32
|
+
else
|
33
|
+
failure!
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def check
|
38
|
+
return false unless ARGV[0] == 'HealthCheck'
|
39
|
+
|
40
|
+
status = NWitchGRPCClient::Check.check
|
41
|
+
puts status
|
42
|
+
|
43
|
+
if status == 'SERVING'
|
44
|
+
exit 0
|
45
|
+
else
|
46
|
+
exit 1
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
check
|
51
|
+
|
52
|
+
unless ARGV[3]
|
53
|
+
push
|
54
|
+
else
|
55
|
+
push_with_token
|
56
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'google/protobuf'
|
2
|
+
require 'grpc'
|
3
|
+
|
4
|
+
require 'nwitch_grpc_client/configuration'
|
5
|
+
require 'nwitch_grpc_client/check'
|
6
|
+
require 'nwitch_grpc_client/notification'
|
7
|
+
require 'nwitch_grpc_client/version'
|
8
|
+
require 'nwitch_grpc_client/protobuf/check_pb'
|
9
|
+
require 'nwitch_grpc_client/protobuf/check_services_pb'
|
10
|
+
require 'nwitch_grpc_client/protobuf/push_pb'
|
11
|
+
require 'nwitch_grpc_client/protobuf/push_services_pb'
|
12
|
+
|
13
|
+
module NWitchGRPCClient
|
14
|
+
class << self
|
15
|
+
attr_writer :configuration
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.configuration
|
19
|
+
@configuration ||= Configuration.new
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.reset
|
23
|
+
@configuration = Configuration.new
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.configure
|
27
|
+
yield configuration
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module NWitchGRPCClient
|
2
|
+
class Check
|
3
|
+
def self.check
|
4
|
+
service = self.new
|
5
|
+
service.check
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
host = NWitchGRPCClient.configuration.grpc_host
|
10
|
+
|
11
|
+
@stub = NWitchGRPC::Protobuf::Health::Stub
|
12
|
+
.new(host, :this_channel_is_insecure)
|
13
|
+
end
|
14
|
+
|
15
|
+
def check
|
16
|
+
req = @stub.check(build_req)
|
17
|
+
|
18
|
+
req.status
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def build_req
|
24
|
+
NWitchGRPC::Protobuf::HealthCheckRequest.new(service: 'nwitch')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module NWitchGRPCClient
|
2
|
+
class Notification
|
3
|
+
def self.push(topic, title, msg)
|
4
|
+
token = NWitchGRPCClient.configuration.nwitch_token
|
5
|
+
service = self.new
|
6
|
+
|
7
|
+
service.push(topic, title, msg, token)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.push_with_token(topic, title, msg, token)
|
11
|
+
service = self.new
|
12
|
+
|
13
|
+
service.push(topic, title, msg, token)
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
host = NWitchGRPCClient.configuration.grpc_host
|
18
|
+
|
19
|
+
@stub = NWitchGRPC::Protobuf::Notification::Stub
|
20
|
+
.new(host, :this_channel_is_insecure)
|
21
|
+
end
|
22
|
+
|
23
|
+
def push(topic, title, msg, token)
|
24
|
+
req_params = build_req(topic, title, msg, token)
|
25
|
+
req = @stub.push(req_params)
|
26
|
+
|
27
|
+
req.success
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def build_req(topic, title, msg, token)
|
33
|
+
NWitchGRPC::Protobuf::PushRequest.new(
|
34
|
+
nwitch_token: token,
|
35
|
+
topic_name: topic,
|
36
|
+
title: title,
|
37
|
+
message: msg
|
38
|
+
)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: check.proto
|
3
|
+
|
4
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
5
|
+
add_message "NWitchGRPC.Protobuf.HealthCheckRequest" do
|
6
|
+
optional :service, :string, 1
|
7
|
+
end
|
8
|
+
add_message "NWitchGRPC.Protobuf.HealthCheckResponse" do
|
9
|
+
optional :status, :enum, 1, "NWitchGRPC.Protobuf.HealthCheckResponse.ServingStatus"
|
10
|
+
end
|
11
|
+
add_enum "NWitchGRPC.Protobuf.HealthCheckResponse.ServingStatus" do
|
12
|
+
value :UNKNOWN, 0
|
13
|
+
value :SERVING, 1
|
14
|
+
value :NOT_SERVING, 2
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
module NWitchGRPC
|
19
|
+
module Protobuf
|
20
|
+
HealthCheckRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("NWitchGRPC.Protobuf.HealthCheckRequest").msgclass
|
21
|
+
HealthCheckResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("NWitchGRPC.Protobuf.HealthCheckResponse").msgclass
|
22
|
+
HealthCheckResponse::ServingStatus = Google::Protobuf::DescriptorPool.generated_pool.lookup("NWitchGRPC.Protobuf.HealthCheckResponse.ServingStatus").enummodule
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# Source: check.proto for package 'NWitchGRPC.Protobuf'
|
3
|
+
|
4
|
+
module NWitchGRPC
|
5
|
+
module Protobuf
|
6
|
+
module Health
|
7
|
+
class Service
|
8
|
+
|
9
|
+
include GRPC::GenericService
|
10
|
+
|
11
|
+
self.marshal_class_method = :encode
|
12
|
+
self.unmarshal_class_method = :decode
|
13
|
+
self.service_name = 'NWitchGRPC.Protobuf.Health'
|
14
|
+
|
15
|
+
rpc :Check, HealthCheckRequest, HealthCheckResponse
|
16
|
+
end
|
17
|
+
|
18
|
+
Stub = Service.rpc_stub_class
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: push.proto
|
3
|
+
|
4
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
5
|
+
add_message "NWitchGRPC.Protobuf.PushRequest" do
|
6
|
+
optional :nwitch_token, :string, 1
|
7
|
+
optional :topic_name, :string, 2
|
8
|
+
optional :title, :string, 3
|
9
|
+
optional :message, :string, 4
|
10
|
+
end
|
11
|
+
add_message "NWitchGRPC.Protobuf.PushResponse" do
|
12
|
+
optional :success, :bool, 1
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module NWitchGRPC
|
17
|
+
module Protobuf
|
18
|
+
PushRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("NWitchGRPC.Protobuf.PushRequest").msgclass
|
19
|
+
PushResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("NWitchGRPC.Protobuf.PushResponse").msgclass
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# Source: push.proto for package 'NWitchGRPC.Protobuf'
|
3
|
+
|
4
|
+
module NWitchGRPC
|
5
|
+
module Protobuf
|
6
|
+
module Notification
|
7
|
+
class Service
|
8
|
+
|
9
|
+
include GRPC::GenericService
|
10
|
+
|
11
|
+
self.marshal_class_method = :encode
|
12
|
+
self.unmarshal_class_method = :decode
|
13
|
+
self.service_name = 'NWitchGRPC.Protobuf.Notification'
|
14
|
+
|
15
|
+
rpc :Push, PushRequest, PushResponse
|
16
|
+
end
|
17
|
+
|
18
|
+
Stub = Service.rpc_stub_class
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nwitch_grpc_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fernando Schuindt
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-03-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: google-protobuf
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.7'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.7'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: grpc
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.19'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.19'
|
83
|
+
description: Acts as a Ruby gem for the nwitch gRPC proxy.
|
84
|
+
email:
|
85
|
+
- fschuindt@722.network
|
86
|
+
executables:
|
87
|
+
- ruby_nwitch_grpc
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- bin/ruby_nwitch_grpc
|
92
|
+
- lib/nwitch_grpc_client.rb
|
93
|
+
- lib/nwitch_grpc_client/check.rb
|
94
|
+
- lib/nwitch_grpc_client/configuration.rb
|
95
|
+
- lib/nwitch_grpc_client/notification.rb
|
96
|
+
- lib/nwitch_grpc_client/protobuf/check_pb.rb
|
97
|
+
- lib/nwitch_grpc_client/protobuf/check_services_pb.rb
|
98
|
+
- lib/nwitch_grpc_client/protobuf/push_pb.rb
|
99
|
+
- lib/nwitch_grpc_client/protobuf/push_services_pb.rb
|
100
|
+
- lib/nwitch_grpc_client/version.rb
|
101
|
+
homepage: https://github.com/722-network/nwitch_grpc_ruby_client
|
102
|
+
licenses:
|
103
|
+
- MIT
|
104
|
+
metadata: {}
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
requirements: []
|
120
|
+
rubyforge_project:
|
121
|
+
rubygems_version: 2.7.6
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
124
|
+
summary: A Ruby gRPC client for nwitch.
|
125
|
+
test_files: []
|