diff options
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/rpc | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -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']) |
