Add module for connection helper

This commit is contained in:
Chris Roberts 2021-08-13 13:38:41 -07:00 committed by Paul Hinze
parent a180e8441c
commit 363a1f30c1
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0

View File

@ -1,6 +1,21 @@
module VagrantPlugins
module CommandServe
module Util
# Extracts connection information from a proto
# and establishes a new connection
module Connector
def connect(proto:, broker:)
if(proto.target.to_s.empty?)
conn = broker.dial(proto.stream_id)
else
conn = proto.target.to_s.start_with?('/') ?
"unix:#{proto.target}" :
proto.target.to_s
end
conn.to_s
end
end
# Requires a broker to be set when initializing an
# instance and adds an accessor to the broker
module HasBroker