Class: Datadog::Core::Transport::Parcel
- Inherits:
-
Object
- Object
- Datadog::Core::Transport::Parcel
- Defined in:
- lib/datadog/core/transport/parcel.rb
Overview
Data transfer object for transporting already-encoded data.
A Parcel is a container that holds pre-encoded data along with metadata about its encoding. The key design principle is that encoding happens BEFORE the Parcel is created, not inside it.
The content_type and content_encoding fields are optional but recommended:
-
Set them when creating the Parcel for automatic header management
-
Leave them nil for IO transports or when headers are managed elsewhere
-
HTTP transports use these to set appropriate request headers
Direct Known Subclasses
Instance Attribute Summary collapse
-
#content_encoding ⇒ Object
readonly
Returns the value of attribute content_encoding.
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(data, content_type: nil, content_encoding: nil) ⇒ Parcel
constructor
Creates a new Parcel with pre-encoded data.
-
#length ⇒ Integer
Returns the length of the encoded data.
Constructor Details
#initialize(data, content_type: nil, content_encoding: nil) ⇒ Parcel
Creates a new Parcel with pre-encoded data.
47 48 49 50 51 |
# File 'lib/datadog/core/transport/parcel.rb', line 47 def initialize(data, content_type: nil, content_encoding: nil) @data = data @content_type = content_type @content_encoding = content_encoding end |
Instance Attribute Details
#content_encoding ⇒ Object (readonly)
Returns the value of attribute content_encoding.
70 71 72 |
# File 'lib/datadog/core/transport/parcel.rb', line 70 def content_encoding @content_encoding end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
66 67 68 |
# File 'lib/datadog/core/transport/parcel.rb', line 66 def content_type @content_type end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
55 56 57 |
# File 'lib/datadog/core/transport/parcel.rb', line 55 def data @data end |
Instance Method Details
#length ⇒ Integer
Returns the length of the encoded data.
60 61 62 |
# File 'lib/datadog/core/transport/parcel.rb', line 60 def length data.length end |