summaryrefslogtreecommitdiff
path: root/bin/rpc
diff options
context:
space:
mode:
Diffstat (limited to 'bin/rpc')
-rwxr-xr-xbin/rpc34
1 files changed, 34 insertions, 0 deletions
diff --git a/bin/rpc b/bin/rpc
new file mode 100755
index 00000000..14490182
--- /dev/null
+++ b/bin/rpc
@@ -0,0 +1,34 @@
+#!/usr/bin/env ruby
+
+require "bundler/inline"
+
+gemfile do
+ source "https://rubygems.org"
+
+ gem "grpc", "~> 1.0"
+ gem "grpc-tools", "~> 1.0"
+ gem "logger", "~> 1.0"
+end
+
+lib_path = Pathname.new(__FILE__).parent.parent.join('lib').realpath.to_s
+$LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)
+
+require 'ability_services_pb'
+
+class AbilityHandler < ::Ability::Service
+ def allowed(request, _call)
+ puts [request, _call].inspect
+ # TODO:: entrypoint to declarative policies
+ AllowReply.new(result: true)
+ end
+end
+
+host = ENV.fetch("HOST", "localhost")
+port = ENV.fetch("PORT", "50051")
+bind_addr = "#{host}:#{port}"
+server = GRPC::RpcServer.new
+server.add_http2_port(bind_addr, :this_port_is_insecure)
+GRPC.logger = Logger.new($stderr, level: :debug)
+GRPC.logger.info("... running insecurely on #{bind_addr}")
+server.handle(AbilityHandler.new)
+server.run_till_terminated_or_interrupted([1, 'int', 'SIGQUIT'])