Set global broker and cache values

This commit is contained in:
Chris Roberts 2022-06-13 17:03:34 -07:00
parent 70d725f8a0
commit 8fcabc2c1d

View File

@ -16,6 +16,8 @@ require 'grpc'
require 'grpc/health/checker'
require 'grpc/health/v1/health_services_pb'
require Vagrant.source_root.join("plugins/commands/serve/util/direct_conversions.rb").to_s
module VagrantPlugins
module CommandServe
# Simple constant aliases to reduce namespace typing
@ -30,6 +32,12 @@ module VagrantPlugins
autoload :Type, Vagrant.source_root.join("plugins/commands/serve/type").to_s
autoload :Util, Vagrant.source_root.join("plugins/commands/serve/util").to_s
class << self
attr_accessor :broker
attr_reader :cache
end
@cache = Util::Cacher.new
class Command < Vagrant.plugin("2", :command)
DEFAULT_BIND = "localhost"
@ -93,11 +101,13 @@ module VagrantPlugins
health_checker = Grpc::Health::Checker.new
broker = Broker.new(bind: bind_addr, ports: ports)
CommandServe.broker = broker
logger.debug("vagrant grpc broker started for grpc service addr=#{bind_addr} ports=#{ports.inspect}")
[Broker::Streamer,
Service::CommandService,
Service::CommunicatorService,
Service::ConfigService,
Service::GuestService,
Service::HostService,
Service::InternalService,