Class: JRPC::Transport::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/jrpc/transport/base.rb

Direct Known Subclasses

Tcp, Test

Defined Under Namespace

Classes: ConnectionError, Error, MalformedFrame, Timeout

Instance Method Summary collapse

Constructor Details

#initialize(server, **options) ⇒ Base

Returns a new instance of Base.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/jrpc/transport/base.rb', line 14

def initialize(server, **options)
  @server = server
  # connect_timeout: total wall-clock budget for the whole connect (across retries).
  # connect_attempt_timeout: cap on a single connect attempt; nil means a single
  # attempt is bounded only by whatever is left of connect_timeout.
  @connect_timeout = options.fetch(:connect_timeout, 60)
  @connect_attempt_timeout = options.fetch(:connect_attempt_timeout, nil)
  @connect_retry_count = options.fetch(:connect_retry_count, 0)
  @connect_retry_interval = options.fetch(:connect_retry_interval, 0.5)
  @write_timeout = options.fetch(:write_timeout, nil)
  # Optional RFC2385 TCP MD5 Signature key. nil disables it. When set, the
  # transport installs it on the socket before connect (Linux-only). See Tcp.
  @tcp_md5_pass = options.fetch(:tcp_md5_pass, nil)
end

Instance Method Details

#closeObject

Raises:

  • (NotImplementedError)


49
50
51
# File 'lib/jrpc/transport/base.rb', line 49

def close
  raise NotImplementedError
end

#closed?Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


53
54
55
# File 'lib/jrpc/transport/base.rb', line 53

def closed?
  raise NotImplementedError
end

#connectObject

Abstract interface. Subclasses must implement every method below; the bodies only exist to fail loudly if one is forgotten, so they carry no logic worth covering and are excluded from coverage via :nocov:. :nocov:

Raises:

  • (NotImplementedError)


33
34
35
# File 'lib/jrpc/transport/base.rb', line 33

def connect
  raise NotImplementedError
end

#read_frame(timeout:) ⇒ Object

Raises:

  • (NotImplementedError)


41
42
43
# File 'lib/jrpc/transport/base.rb', line 41

def read_frame(timeout:)
  raise NotImplementedError
end

#socketObject

Raises:

  • (NotImplementedError)


57
58
59
# File 'lib/jrpc/transport/base.rb', line 57

def socket
  raise NotImplementedError
end

#try_read_frameObject

Raises:

  • (NotImplementedError)


45
46
47
# File 'lib/jrpc/transport/base.rb', line 45

def try_read_frame
  raise NotImplementedError
end

#write_frame(bytes, timeout:) ⇒ Object

Raises:

  • (NotImplementedError)


37
38
39
# File 'lib/jrpc/transport/base.rb', line 37

def write_frame(bytes, timeout:)
  raise NotImplementedError
end