Sha256: 2c559398b39b247e7fb5ce8c9ab41969d8b699b6c5998c1bce93b2e6961543a9

Contents?: true

Size: 535 Bytes

Versions: 1

Compression:

Stored size: 535 Bytes

Contents

module Aggro
  # Public: Represents the local aggro server node.
  class LocalNode < Struct.new(:id)
    def client
      @client ||= create_loopback_client
    end

    def endpoint
      "tcp://127.0.0.1:#{Aggro.port}"
    end

    def publisher_endpoint
      "tcp://127.0.0.1:#{Aggro.publisher_port}"
    end

    def to_s
      id
    end

    private

    def create_loopback_client
      ->(msg) { Aggro.server.handle_message msg }.tap do |proc|
        proc.class_eval { alias_method :post, :call }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aggro-0.0.2 lib/aggro/local_node.rb