Protocol

sunng87 edited this page Jan 4, 2012 · 3 revisions
Clone this wiki locally

Slacker Protocol

This document is for Slacker version 0.4.0, protocol version: 4.

Request Packet

Request packet is sent from client to server when client issues a function call.

  • int8 (protocol version)
  • int8 (packet type, constant 0)
  • int8 (content type, 0 for carbonite, 1 for json)
  • uint16 (function name length)
  • string (function name, UTF8)
  • uint32 (content length)
  • encoded arguments (content, carbonite bytes or json string)

Response Packet

Response packet is sent from server to client after function called (or function not found.)

  • int8 (protocol version)
  • int8 (packet type, constant 1)
  • int8 (content type, same as request packet)
  • int8 (result code)
    • 0 success
    • 11 function not found
    • 12 exception caught when execute function
  • uint32 (content length)
  • encoded return data (content, carbonite or json)

Ping Packet

Ping packet is sent by client to keep connection alive.

  • int8 (protocol version)
  • int8 (packet type, constant 2)

Pong Packet

Pong packet is returned from server as response of Ping packet.

  • int8 (protocol version)
  • int8 (packet type, constant 3)

Error Packet

Error packet is sent from server to client when a protocol error found.

  • int8 (protocol version)
  • int8 (packet type, constant 4)
  • int8 (error code)
    • 20 protocol version mismatch
    • 21 invalid packet type

Inspect Request Packet

An inspect request is sent from clients to server for metadata of functions hosted.

  • int8 (protocol version)
  • int8 (packet type, constant 7)
  • int8 (command code)
    • 0 get all functions
    • 1 get metadata of a particular function
  • uint16 (content length)
  • arguments serialized in clj

Inspect Ack Packet

An inspect response returned from server

  • int8 (protocol version)
  • int8 (packet type, constant 8)
  • uint16 (content length)
  • result data serialized in clj