Module: DigitalFabric::Protocol

Defined in:
lib/tipi/digital_fabric/protocol.rb

Defined Under Namespace

Modules: Attribute

Constant Summary collapse

PING =
'ping'
SHUTDOWN =
'shutdown'
UNMOUNT =
'unmount'
HTTP_REQUEST =
'http_request'
HTTP_RESPONSE =
'http_response'
HTTP_UPGRADE =
'http_upgrade'
HTTP_GET_REQUEST_BODY =
'http_get_request_body'
HTTP_REQUEST_BODY =
'http_request_body'
CONN_DATA =
'conn_data'
CONN_CLOSE =
'conn_close'
WS_REQUEST =
'ws_request'
WS_RESPONSE =
'ws_response'
WS_DATA =
'ws_data'
WS_CLOSE =
'ws_close'
TRANSFER_COUNT =
'transfer_count'
STATS_REQUEST =
'stats_request'
STATS_RESPONSE =
'stats_response'
SEND_TIMEOUT =
15
RECV_TIMEOUT =
SEND_TIMEOUT + 5
DF_UPGRADE_RESPONSE =
<<~HTTP.gsub("\n", "\r\n")
  HTTP/1.1 101 Switching Protocols
  Upgrade: df
  Connection: Upgrade

HTTP

Class Method Summary collapse

Class Method Details

.connection_close(id) ⇒ Object



129
130
131
# File 'lib/tipi/digital_fabric/protocol.rb', line 129

def connection_close(id)
  [ CONN_CLOSE, id ]
end

.connection_data(id, data) ⇒ Object



125
126
127
# File 'lib/tipi/digital_fabric/protocol.rb', line 125

def connection_data(id, data)
  [ CONN_DATA, id, data ]
end

.df_upgrade_responseObject



101
102
103
# File 'lib/tipi/digital_fabric/protocol.rb', line 101

def df_upgrade_response
  DF_UPGRADE_RESPONSE
end

.http_get_request_body(id, limit = nil) ⇒ Object



117
118
119
# File 'lib/tipi/digital_fabric/protocol.rb', line 117

def http_get_request_body(id, limit = nil)
  [ HTTP_GET_REQUEST_BODY, id, limit ]
end

.http_request(id, headers, buffered_chunk, complete) ⇒ Object



105
106
107
# File 'lib/tipi/digital_fabric/protocol.rb', line 105

def http_request(id, headers, buffered_chunk, complete)
  [ HTTP_REQUEST, id, headers, buffered_chunk, complete ]
end

.http_request_body(id, body, complete) ⇒ Object



121
122
123
# File 'lib/tipi/digital_fabric/protocol.rb', line 121

def http_request_body(id, body, complete)
  [ HTTP_REQUEST_BODY, id, body, complete ]
end

.http_response(id, body, headers, complete, transfer_count_key = nil) ⇒ Object



109
110
111
# File 'lib/tipi/digital_fabric/protocol.rb', line 109

def http_response(id, body, headers, complete, transfer_count_key = nil)
  [ HTTP_RESPONSE, id, body, headers, complete, transfer_count_key ]
end

.http_upgrade(id, headers) ⇒ Object



113
114
115
# File 'lib/tipi/digital_fabric/protocol.rb', line 113

def http_upgrade(id, headers)
  [ HTTP_UPGRADE, id, headers ]
end

.pingObject



82
83
84
# File 'lib/tipi/digital_fabric/protocol.rb', line 82

def ping
  [ PING ]
end

.shutdownObject



86
87
88
# File 'lib/tipi/digital_fabric/protocol.rb', line 86

def shutdown
  [ SHUTDOWN ]
end

.stats_request(id) ⇒ Object



153
154
155
# File 'lib/tipi/digital_fabric/protocol.rb', line 153

def stats_request(id)
  [ STATS_REQUEST, id ]
end

.stats_response(id, stats) ⇒ Object



157
158
159
# File 'lib/tipi/digital_fabric/protocol.rb', line 157

def stats_response(id, stats)
  [ STATS_RESPONSE, id, stats ]
end

.transfer_count(key, rx, tx) ⇒ Object



149
150
151
# File 'lib/tipi/digital_fabric/protocol.rb', line 149

def transfer_count(key, rx, tx)
  [ TRANSFER_COUNT, key, rx, tx ]
end

.unmountObject



90
91
92
# File 'lib/tipi/digital_fabric/protocol.rb', line 90

def unmount
  [ UNMOUNT ]
end

.ws_close(id) ⇒ Object



145
146
147
# File 'lib/tipi/digital_fabric/protocol.rb', line 145

def ws_close(id)
  [ WS_CLOSE, id ]
end

.ws_data(id, data) ⇒ Object



141
142
143
# File 'lib/tipi/digital_fabric/protocol.rb', line 141

def ws_data(id, data)
  [ WS_DATA, id, data ]
end

.ws_request(id, headers) ⇒ Object



133
134
135
# File 'lib/tipi/digital_fabric/protocol.rb', line 133

def ws_request(id, headers)
  [ WS_REQUEST, id, headers ]
end

.ws_response(id, headers) ⇒ Object



137
138
139
# File 'lib/tipi/digital_fabric/protocol.rb', line 137

def ws_response(id, headers)
  [ WS_RESPONSE, id, headers ]
end