Class: Hook0::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/hook0/client.rb

Overview

Every bound a client applies to one send.

Constant Summary collapse

DEFAULT_MAX_PAYLOAD_BYTES =

Largest event payload the client agrees to send, in bytes.

Hook0's API refuses request bodies above 2 MiB, so a payload above 1 MiB is already at risk of being refused once the JSON envelope around it — metadata, labels, identifiers — is counted. The client rules such an event out rather than spending a round trip, and every retry after it, on a request that cannot be accepted.

1024 * 1024

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(retry_policy: RetryPolicy.new, request_timeout: Transport::DEFAULT_REQUEST_TIMEOUT, max_payload_bytes: DEFAULT_MAX_PAYLOAD_BYTES, max_response_bytes: Transport::DEFAULT_MAX_RESPONSE_BYTES, max_response_headers: Transport::DEFAULT_MAX_RESPONSE_HEADERS, max_header_bytes: Transport::DEFAULT_MAX_HEADER_BYTES, max_head_bytes: Transport::DEFAULT_MAX_HEAD_BYTES) ⇒ Options

Returns a new instance of Options.

Parameters:

  • retry_policy (RetryPolicy) (defaults to: RetryPolicy.new)
  • request_timeout (Float) (defaults to: Transport::DEFAULT_REQUEST_TIMEOUT)
  • max_payload_bytes (Integer) (defaults to: DEFAULT_MAX_PAYLOAD_BYTES)
  • max_response_bytes (Integer) (defaults to: Transport::DEFAULT_MAX_RESPONSE_BYTES)
  • max_response_headers (Integer) (defaults to: Transport::DEFAULT_MAX_RESPONSE_HEADERS)
  • max_header_bytes (Integer) (defaults to: Transport::DEFAULT_MAX_HEADER_BYTES)
  • max_head_bytes (Integer) (defaults to: Transport::DEFAULT_MAX_HEAD_BYTES)


222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/hook0/client.rb', line 222

def initialize(
  retry_policy: RetryPolicy.new,
  request_timeout: Transport::DEFAULT_REQUEST_TIMEOUT,
  max_payload_bytes: DEFAULT_MAX_PAYLOAD_BYTES,
  max_response_bytes: Transport::DEFAULT_MAX_RESPONSE_BYTES,
  max_response_headers: Transport::DEFAULT_MAX_RESPONSE_HEADERS,
  max_header_bytes: Transport::DEFAULT_MAX_HEADER_BYTES,
  max_head_bytes: Transport::DEFAULT_MAX_HEAD_BYTES
)
  @retry_policy = retry_policy
  @request_timeout = request_timeout
  @max_payload_bytes = max_payload_bytes
  @max_response_bytes = max_response_bytes
  @max_response_headers = max_response_headers
  @max_header_bytes = max_header_bytes
  @max_head_bytes = max_head_bytes
  freeze
end

Instance Attribute Details

#max_head_bytesInteger (readonly)

Returns the largest whole head, every line counted together.

Returns:

  • (Integer)

    the largest whole head, every line counted together



213
214
215
# File 'lib/hook0/client.rb', line 213

def max_head_bytes
  @max_head_bytes
end

#max_header_bytesInteger (readonly)

Returns the longest one header line may be.

Returns:

  • (Integer)

    the longest one header line may be



210
211
212
# File 'lib/hook0/client.rb', line 210

def max_header_bytes
  @max_header_bytes
end

#max_payload_bytesInteger (readonly)

Returns the largest payload sent, refused before a socket is opened.

Returns:

  • (Integer)

    the largest payload sent, refused before a socket is opened



201
202
203
# File 'lib/hook0/client.rb', line 201

def max_payload_bytes
  @max_payload_bytes
end

#max_response_bytesInteger (readonly)

Returns the largest answer read off a socket.

Returns:

  • (Integer)

    the largest answer read off a socket



204
205
206
# File 'lib/hook0/client.rb', line 204

def max_response_bytes
  @max_response_bytes
end

#max_response_headersInteger (readonly)

Returns how many header lines an answer may carry.

Returns:

  • (Integer)

    how many header lines an answer may carry



207
208
209
# File 'lib/hook0/client.rb', line 207

def max_response_headers
  @max_response_headers
end

#request_timeoutFloat (readonly)

Returns how long one attempt is given, in seconds.

Returns:

  • (Float)

    how long one attempt is given, in seconds



198
199
200
# File 'lib/hook0/client.rb', line 198

def request_timeout
  @request_timeout
end

#retry_policyRetryPolicy (readonly)

Returns how the attempts of one send are spaced out.

Returns:

  • (RetryPolicy)

    how the attempts of one send are spaced out



195
196
197
# File 'lib/hook0/client.rb', line 195

def retry_policy
  @retry_policy
end