Sha256: 2238e79591ae7ccf834fdb495ca530e928ae958583af658751be01f6e5e50242

Contents?: true

Size: 628 Bytes

Versions: 2

Compression:

Stored size: 628 Bytes

Contents

module Aggro
  # Public: Represents an aggro server node.
  class Node < Struct.new(:id, :endpoint)
    def client
      @client ||= Aggro::Client.new(endpoint)
    end

    def publisher_endpoint
      @publisher_endpoint ||= discover_publisher_endpoint
    end

    def to_s
      id
    end

    private

    def discover_publisher_endpoint
      message = Message::PublisherEndpointInquiry.new(Aggro.local_node.id)
      response = client.post(message)

      if response.is_a? Message::Endpoint
        response.endpoint
      else
        fail "Could not discover publisher endpoint for #{id}"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aggro-0.0.3 lib/aggro/node.rb
aggro-0.0.2 lib/aggro/node.rb