# encoding: UTF-8 # frozen_string_literal: true # Requirements # ======================================================================= ### Stdlib ### require 'fileutils' ### Deps ### require 'plist' ### Project / Package ### require_relative './system' # Refinements # ======================================================================= require 'nrser/refinements/types' using NRSER::Types # Namespace # ============================================================================ module Locd class Agent # Definitions # ======================================================================= # An server {Locd::Agent} (HTTP only at the moment) that the proxy can # route requests to. # class Proxy < Agent # Mixins # ============================================================================ include System # Constants # ========================================================================== # Attribute / method names that {#to_h} uses. # # @return [Hamster::SortedSet] # TO_H_NAMES = Agent::TO_H_NAMES.union [:port, :url] # Class Methods # ========================================================================== # @return [String] # The non-namespace part of the proxy's label. # def self.label_name "proxy" end # @todo Document cmd_template method. # # @param [type] arg_name # @todo Add name param description. # # @return [return_type] # @todo Document return value. # def self.default_cmd_template "{bin} proxy run" end # .cmd_template def self.default_write_kwds cmd_template: self.default_cmd_template, **kwds super( keep_alive: true, run_at_load: true, port: Locd.config[:proxy, :port], cmd_template: cmd_template, **kwds, label: self.label ) end # Instance Methods # ============================================================================ # @!group Instance Methods: Attribute Readers # ---------------------------------------------------------------------------- # # Methods to read proxied and computed attributes. # # @return [Fixnum] # Port service runs on. def port config['port'] end # @return [String] # The URL the agent can be reached at through the proxy. def url "http://#{ label }:#{ Locd.get_port }" end # @!endgroup Instance Methods: Attribute Readers end # class Proxy # /Namespace # ============================================================================ end # class Agent end # module Locd