Class: PDU

PDU

Represents the Kinetic Protocol Data Structure.

Constructor

new PDU(input)

Parameters:
Name Type Description
input Buffer An optional input buffer to parse the Kinetic message from
Source:

Methods

_parse(data) → {number}

Creates the Kinetic Protocol Data Structure from a buffer.
Parameters:
Name Type Description
data Buffer The data received by the socket.
Source:
Throws:
- err.badVersion is set the version is incompatible, - err.badLength is set if the buffer size is incoherent, - err.decodingError is the protobuf is not decodable, - err.hmacFail is set if the HMAC does not match.
Type
Error
Returns:
- an error code
Type
number

checkHmacIntegrity(hmac) → {Boolean}

Test the HMAC integrity between the actual instance and the given HMAC
Parameters:
Name Type Description
hmac Buffer the non instance hmac to compare
Source:
Returns:
- whether HMAC matches or not
Type
Boolean

checkTagIntegrity(tag) → {Boolean}

Test the Tag integrity between the actual instance and the given tag
Parameters:
Name Type Description
tag Buffer the non instance tag to compare
Source:
Returns:
- whether tag matches or not
Type
Boolean

computeHMAC() → {Kinetic}

Sets the HMAC for the Kinetic Protocol Data Unit integrity.
Source:
Returns:
- to allow for a functional style.
Type
Kinetic

getChunkSize() → {number}

Gets the actual chunk size.
Source:
Returns:
- Chunk size.
Type
number

getClusterVersion() → {number}

Gets the actual clusterVersion.
Source:
Returns:
- The clusterVersion, or 0 if missing.
Type
number

getCommand() → {Object}

Gets the protobuf command.
Source:
Returns:
- the object-typed command
Type
Object

getCommandSize() → {number}

Gets the protobuf command size.
Source:
Returns:
- the size in bytes
Type
number

getConnectionId() → {Number}

Gets the pdu connection ID
Source:
Returns:
- the connection ID.
Type
Number

getDbVersion() → {Buffer}

Gets the version of the data unit in the database.
Source:
Returns:
- Version of the data unit in the database, or `undefined` if missing.
Type
Buffer

getErrorMessage() → {Buffer}

Gets the detailed error message.
Source:
Returns:
- Detailed error message.
Type
Buffer

getForce() → {boolean}

Gets the force value of the data unit.
Source:
Returns:
- Whether force is true or false. If missing, false is assumed.
Type
boolean

getHMAC() → {Buffer}

Gets the actual HMAC.
Source:
Returns:
- HMAC.
Type
Buffer

getKey() → {Buffer}

Gets the actual key.
Source:
Returns:
- The key value, or `undefined` if missing.
Type
Buffer

getLogObject() → {Object}

Gets the logs object.
Source:
Returns:
- Logs, or `undefined` if missing.
Type
Object

getMessageType() → {number}

Gets the actual request messageType.
Source:
Returns:
- The code number of the request.
Type
number

getNewClusterVersion() → {number}

Gets the updated clusterVersion.
Source:
Returns:
- The updated clusterVersion, or undefined if missing.
Type
number

getNewVersion() → {Buffer}

Gets the new version of the data unit.
Source:
Returns:
- New version of the data unit, or `undefined` if missing.
Type
Buffer

getProtobuf() → {Buffer}

Get the actual Kinetic protobuf, encoded as a buffer ready to be sent over the network.
Source:
Returns:
- the encoded protobuf message
Type
Buffer

getProtobufSize() → {number}

Gets the actual protobuf message size.
Source:
Returns:
- Size of the kinetic protobuf message.
Type
number

getSequence() → {number}

Gets sequence (monotonically increasing number for each request in a TCP connection) or ackSequence in case of a response message.
Source:
Returns:
- The sequence number.
Type
number

getSlice(obj) → {Buffer}

Slice the buffer with the offset and the limit.
Parameters:
Name Type Description
obj Object an object buffer with offset and limit.
Source:
Returns:
- sliced buffer from the buffer structure with the offset and the limit.
Type
Buffer

getStatusCode() → {number}

Gets the status code for response messages.
Source:
Returns:
- The status code.
Type
number

getTag() → {Buffer}

Gets the tag
Source:
Returns:
- the tag.
Type
Buffer

setChunkSize(size) → {Kinetic}

Sets the size of the chunk following the protobuf message in the PDU.
Parameters:
Name Type Description
size number Size of the chunk.
Source:
Returns:
- To allow for a functional style.
Type
Kinetic

setCommand(command) → {Kinetic}

Sets the protobuf command for the Kinetic Protocol Data Unit.
Parameters:
Name Type Description
command Object the well formated kinetic protobuf structure.
Source:
Returns:
- this
Type
Kinetic