warden-protocol 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. data/.gitignore +17 -0
  2. data/.rspec +1 -0
  3. data/CHANGELOG.md +14 -0
  4. data/Gemfile +6 -0
  5. data/README.md +13 -0
  6. data/Rakefile +40 -0
  7. data/lib/warden/protocol.rb +4 -0
  8. data/lib/warden/protocol/base.rb +168 -0
  9. data/lib/warden/protocol/buffer.rb +69 -0
  10. data/lib/warden/protocol/build.sh +13 -0
  11. data/lib/warden/protocol/message.rb +50 -0
  12. data/lib/warden/protocol/pb.rb +497 -0
  13. data/lib/warden/protocol/pb/copy_in.proto +35 -0
  14. data/lib/warden/protocol/pb/copy_out.proto +39 -0
  15. data/lib/warden/protocol/pb/create.proto +65 -0
  16. data/lib/warden/protocol/pb/destroy.proto +33 -0
  17. data/lib/warden/protocol/pb/echo.proto +26 -0
  18. data/lib/warden/protocol/pb/error.proto +19 -0
  19. data/lib/warden/protocol/pb/info.proto +95 -0
  20. data/lib/warden/protocol/pb/limit_bandwidth.proto +30 -0
  21. data/lib/warden/protocol/pb/limit_disk.proto +70 -0
  22. data/lib/warden/protocol/pb/limit_memory.proto +34 -0
  23. data/lib/warden/protocol/pb/link.proto +40 -0
  24. data/lib/warden/protocol/pb/list.proto +25 -0
  25. data/lib/warden/protocol/pb/message.proto +36 -0
  26. data/lib/warden/protocol/pb/net_in.proto +39 -0
  27. data/lib/warden/protocol/pb/net_out.proto +35 -0
  28. data/lib/warden/protocol/pb/ping.proto +24 -0
  29. data/lib/warden/protocol/pb/resource_limits.proto +30 -0
  30. data/lib/warden/protocol/pb/run.proto +29 -0
  31. data/lib/warden/protocol/pb/spawn.proto +37 -0
  32. data/lib/warden/protocol/pb/stop.proto +40 -0
  33. data/lib/warden/protocol/pb/stream.proto +41 -0
  34. data/lib/warden/protocol/version.rb +7 -0
  35. data/spec/base_spec.rb +150 -0
  36. data/spec/buffer_spec.rb +65 -0
  37. data/spec/copy_in_spec.rb +51 -0
  38. data/spec/copy_out_spec.rb +56 -0
  39. data/spec/create_spec.rb +70 -0
  40. data/spec/destroy_spec.rb +36 -0
  41. data/spec/echo_spec.rb +42 -0
  42. data/spec/error_spec.rb +33 -0
  43. data/spec/info_spec.rb +122 -0
  44. data/spec/limit_bandwidth_spec.rb +57 -0
  45. data/spec/limit_disk_spec.rb +103 -0
  46. data/spec/limit_memory_spec.rb +47 -0
  47. data/spec/link_spec.rb +67 -0
  48. data/spec/list_spec.rb +41 -0
  49. data/spec/net_in_spec.rb +57 -0
  50. data/spec/net_out_spec.rb +47 -0
  51. data/spec/ping_spec.rb +32 -0
  52. data/spec/resource_limits_spec.rb +84 -0
  53. data/spec/run_spec.rb +79 -0
  54. data/spec/spawn_spec.rb +55 -0
  55. data/spec/spec_helper.rb +11 -0
  56. data/spec/stop_spec.rb +46 -0
  57. data/spec/stream_spec.rb +65 -0
  58. data/spec/support/examples/wrappable_reply.rb +26 -0
  59. data/spec/support/examples/wrappable_request.rb +26 -0
  60. data/spec/support/helper.rb +122 -0
  61. data/spec/support/matchers.rb +22 -0
  62. data/warden-protocol.gemspec +21 -0
  63. metadata +166 -0
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --fail-fast --backtrace --color
data/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ ## 0.0.3
2
+
3
+ * Ignore string encoding when a request or response is encoded
4
+
5
+ ## 0.0.2
6
+
7
+ ### `StopRequest`
8
+
9
+ * Added `background` flag
10
+ * Added `kill` flag
11
+
12
+ ## 0.0.1
13
+
14
+ * Initial version.
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in warden-protocol.gemspec
4
+ gemspec
5
+
6
+ gem 'rake'
data/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # warden-protocol
2
+
3
+ > This README describes the **protocol** library. Please refer to the top
4
+ > level [README][tlr] for an overview of all components.
5
+
6
+ [tlr]: /README.md
7
+
8
+ ## License
9
+
10
+ The project is licensed under the Apache 2.0 license (see the
11
+ [`LICENSE`][license] file in the root directory of the repository).
12
+
13
+ [license]: /LICENSE
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ # coding: UTF-8
2
+
3
+ require "rspec/core/rake_task"
4
+ require "rspec/core/version"
5
+
6
+ task :default => :spec
7
+
8
+ desc "Run all examples"
9
+ RSpec::Core::RakeTask.new(:spec) do |t|
10
+ # See .rspec
11
+ end
12
+
13
+ desc "Build pb.rb"
14
+ task :build do
15
+ sh("lib/warden/protocol/build.sh")
16
+ end
17
+
18
+ task :ensure_coding do
19
+ patterns = [
20
+ /Rakefile$/,
21
+ /\.rb$/,
22
+ ]
23
+
24
+ files = `git ls-files`.split.select do |file|
25
+ patterns.any? { |e| e.match(file) }
26
+ end
27
+
28
+ header = "# coding: UTF-8\n\n"
29
+
30
+ files.each do |file|
31
+ content = File.read(file)
32
+
33
+ unless content.start_with?(header)
34
+ File.open(file, "w") do |f|
35
+ f.write(header)
36
+ f.write(content)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,4 @@
1
+ # coding: UTF-8
2
+
3
+ require "warden/protocol/version"
4
+ require "warden/protocol/message"
@@ -0,0 +1,168 @@
1
+ # coding: UTF-8
2
+
3
+ require "beefcake"
4
+
5
+ module Beefcake
6
+ class Buffer
7
+ # Patch beefcake to be encoding-agnostic
8
+ def append_string(s)
9
+ if s.respond_to?(:force_encoding)
10
+ s = s.dup.force_encoding("binary")
11
+ end
12
+
13
+ append_uint64(s.length)
14
+ self << s
15
+ end
16
+ end
17
+ end
18
+
19
+ module Warden
20
+ module Protocol
21
+ TypeConverter = {
22
+ :bool => lambda do |arg|
23
+ return true if arg.downcase == "true"
24
+ return false if arg.downcase == "false"
25
+ raise ArgumentError, "Expected 'true' or 'false', but received: '#{arg}'."
26
+ end,
27
+
28
+ :int32 => lambda { |arg| Integer(arg) },
29
+ :uint32 => lambda { |arg| Integer(arg) },
30
+ :sint32 => lambda { |arg| Integer(arg) },
31
+ :int64 => lambda { |arg| Integer(arg) },
32
+ :uint64 => lambda { |arg| Integer(arg) },
33
+ :fixed32 => lambda { |arg| Float(arg) },
34
+ :sfixed32 => lambda { |arg| Float(arg) },
35
+ :float => lambda { |arg| Float(arg) },
36
+ :fixed64 => lambda { |arg| Float(arg) },
37
+ :sfixed64 => lambda { |arg| Float(arg) },
38
+ :double => lambda { |arg| Float(arg) },
39
+ :string => lambda { |arg| String(arg) },
40
+ }
41
+
42
+ # Used to wrap around Beefcake errors.
43
+ class ProtocolError < StandardError
44
+ attr_reader :cause
45
+
46
+ def initialize(cause)
47
+ @cause = cause
48
+ end
49
+
50
+ def message
51
+ return @cause.message
52
+ end
53
+ end
54
+
55
+ def self.protocol_type_to_str(protocol_type)
56
+ if protocol_type.class == Module
57
+ return "#{protocol_type.constants.join(", ")}"
58
+ elsif protocol_type.is_a?(Symbol)
59
+ return "#{protocol_type.to_s}"
60
+ end
61
+
62
+ return nil
63
+ end
64
+
65
+ def self.to_ruby_type(str, protocol_type)
66
+ converter = Warden::Protocol::TypeConverter[protocol_type]
67
+ return converter.call(str) if converter
68
+
69
+ # Enums are defined as Ruby Modules in Beefcake
70
+ error_msg = nil
71
+ if protocol_type.class == Module
72
+ return protocol_type.const_get(str) if protocol_type.const_defined?(str)
73
+ raise TypeError, "The constant: '#{str}' is not defined in the module: '#{protocol_type}'."
74
+ end
75
+
76
+ raise TypeError, "Non-existent protocol type passed: '#{protocol_type}'."
77
+ end
78
+
79
+ module BaseMessage
80
+ def self.included(base)
81
+ base.send(:include, Beefcake::Message)
82
+
83
+ if base.name =~ /(Request|Response)$/
84
+ base.extend(ClassMethods)
85
+
86
+ case $1
87
+ when "Request"
88
+ base.send(:include, BaseRequest)
89
+ when "Response"
90
+ base.send(:include, BaseResponse)
91
+ end
92
+ end
93
+ end
94
+
95
+ def safe
96
+ yield
97
+ rescue Beefcake::Message::WrongTypeError,
98
+ Beefcake::Message::InvalidValueError,
99
+ Beefcake::Message::RequiredFieldNotSetError => e
100
+ raise ProtocolError, e
101
+ end
102
+
103
+ def reload
104
+ safe do
105
+ self.class.decode(encode)
106
+ end
107
+ end
108
+
109
+ def wrap
110
+ safe do
111
+ Message.new(:type => self.class.type, :payload => encode)
112
+ end
113
+ end
114
+
115
+ def to_hash
116
+ fields.values.inject({}) do |h, fld|
117
+ if v = self[fld.name]
118
+ v = v.to_hash if v.respond_to?(:to_hash)
119
+ h[fld.name] = v
120
+ end
121
+ h
122
+ end
123
+ end
124
+
125
+ module ClassMethods
126
+ def type
127
+ Message::Type.const_get(type_name)
128
+ end
129
+
130
+ def type_camelized
131
+ type_name
132
+ end
133
+
134
+ def type_underscored
135
+ type_name.gsub(/(.)([A-Z])/, "\\1_\\2").downcase
136
+ end
137
+
138
+ def type_name
139
+ type_name = name.gsub(/(Request|Response)$/, "")
140
+ type_name = type_name.split("::").last
141
+ type_name
142
+ end
143
+ end
144
+ end
145
+
146
+ module BaseRequest
147
+ def create_response(attributes = {})
148
+ klass_name = self.class.name.gsub(/Request$/, "Response")
149
+ klass_name = klass_name.split("::").last
150
+ klass = Protocol.const_get(klass_name)
151
+ klass.new(attributes)
152
+ end
153
+ end
154
+
155
+ module BaseResponse
156
+ def ok?
157
+ !error?
158
+ end
159
+
160
+ def error?
161
+ self.class.type == Message::Type::Error
162
+ end
163
+ end
164
+ end
165
+ end
166
+
167
+ require "warden/protocol/pb"
168
+ require "warden/protocol/message"
@@ -0,0 +1,69 @@
1
+ # coding: UTF-8
2
+
3
+ require "warden/protocol/base"
4
+
5
+ module Warden
6
+ module Protocol
7
+ class Buffer
8
+ CRLF = "\r\n"
9
+
10
+ def self.request_to_wire(request)
11
+ unless request.kind_of?(BaseRequest)
12
+ raise ArgumentError, "Expected #kind_of? ::%s" % BaseRequest.name
13
+ end
14
+ payload_to_wire request.wrap.encode.to_s
15
+ end
16
+
17
+ def self.response_to_wire(response)
18
+ unless response.kind_of?(BaseResponse)
19
+ raise ArgumentError, "Expected #kind_of? ::%s" % BaseResponse.name
20
+ end
21
+ payload_to_wire response.wrap.encode.to_s
22
+ end
23
+
24
+ def initialize
25
+ @buffer = ""
26
+ end
27
+
28
+ def <<(data)
29
+ @buffer += data
30
+ end
31
+
32
+ def each_request(&blk)
33
+ each do |payload|
34
+ yield(Warden::Protocol::Message.decode(payload).request)
35
+ end
36
+ end
37
+
38
+ def each_response(&blk)
39
+ each do |payload|
40
+ yield(Warden::Protocol::Message.decode(payload).response)
41
+ end
42
+ end
43
+
44
+ protected
45
+
46
+ def self.payload_to_wire(payload)
47
+ payload.to_s.length.to_s + CRLF + payload.to_s + CRLF
48
+ end
49
+
50
+ def each
51
+ loop do
52
+ crlf = @buffer.index(CRLF)
53
+ break unless crlf
54
+
55
+ length = Integer(@buffer[0...crlf])
56
+ protocol_length = crlf + 2 + length + 2
57
+ break unless @buffer.length >= protocol_length
58
+
59
+ payload = @buffer[crlf + 2, length]
60
+
61
+ # Trim buffer
62
+ @buffer = @buffer[protocol_length..-1]
63
+
64
+ yield(payload)
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,13 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ cd $(dirname $0)/pb
6
+
7
+ export BEEFCAKE_NAMESPACE=Warden::Protocol
8
+
9
+ out=bundle
10
+ (echo "package protocol;" && (find . -name '*.proto' | sort | xargs cat | sed /^package/d)) > $out
11
+ protoc --beefcake_out=. $out
12
+ sed -e "s/Beefcake::Message/Warden::Protocol::BaseMessage/" $out.pb.rb > ../pb.rb
13
+ rm -f $out*
@@ -0,0 +1,50 @@
1
+ # coding: UTF-8
2
+
3
+ require "warden/protocol/base"
4
+
5
+ module Warden
6
+ module Protocol
7
+ class Message
8
+ module Type
9
+ def self.generate_klass_map(suffix)
10
+ map = Hash[self.constants.map do |name|
11
+ klass_name = "#{name}#{suffix}"
12
+ if Protocol.const_defined?(klass_name)
13
+ [const_get(name), Protocol.const_get(klass_name)]
14
+ end
15
+ end]
16
+
17
+ if map.respond_to?(:default_proc=)
18
+ map.default_proc = lambda do |h, k|
19
+ raise "Unknown request type: #{k}"
20
+ end
21
+ end
22
+
23
+ map
24
+ end
25
+
26
+ def self.to_request_klass(type)
27
+ @request_klass_map ||= generate_klass_map("Request")
28
+ @request_klass_map[type]
29
+ end
30
+
31
+ def self.to_response_klass(type)
32
+ @response_klass_map ||= generate_klass_map("Response")
33
+ @response_klass_map[type]
34
+ end
35
+ end
36
+
37
+ def request
38
+ safe do
39
+ Type.to_request_klass(type).decode(payload)
40
+ end
41
+ end
42
+
43
+ def response
44
+ safe do
45
+ Type.to_response_klass(type).decode(payload)
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,497 @@
1
+ ## Generated from bundle for protocol
2
+ require "beefcake"
3
+
4
+ module Warden
5
+ module Protocol
6
+
7
+ class CopyInRequest
8
+ include Warden::Protocol::BaseMessage
9
+
10
+
11
+ required :handle, :string, 1
12
+ required :src_path, :string, 2
13
+ required :dst_path, :string, 3
14
+
15
+ end
16
+
17
+ class CopyInResponse
18
+ include Warden::Protocol::BaseMessage
19
+
20
+
21
+
22
+ end
23
+
24
+ class CopyOutRequest
25
+ include Warden::Protocol::BaseMessage
26
+
27
+
28
+ required :handle, :string, 1
29
+ required :src_path, :string, 2
30
+ required :dst_path, :string, 3
31
+ optional :owner, :string, 4
32
+
33
+ end
34
+
35
+ class CopyOutResponse
36
+ include Warden::Protocol::BaseMessage
37
+
38
+
39
+
40
+ end
41
+
42
+ class CreateRequest
43
+ include Warden::Protocol::BaseMessage
44
+
45
+
46
+ class BindMount
47
+ include Warden::Protocol::BaseMessage
48
+
49
+ module Mode
50
+ RO = 0
51
+ RW = 1
52
+ end
53
+
54
+ required :src_path, :string, 1
55
+ required :dst_path, :string, 2
56
+ required :mode, CreateRequest::BindMount::Mode, 3
57
+
58
+ end
59
+
60
+ repeated :bind_mounts, CreateRequest::BindMount, 1
61
+ optional :grace_time, :uint32, 2
62
+ optional :handle, :string, 3
63
+ optional :network, :string, 4
64
+ optional :rootfs, :string, 5
65
+
66
+ end
67
+
68
+ class CreateResponse
69
+ include Warden::Protocol::BaseMessage
70
+
71
+
72
+ required :handle, :string, 1
73
+
74
+ end
75
+
76
+ class DestroyRequest
77
+ include Warden::Protocol::BaseMessage
78
+
79
+
80
+ required :handle, :string, 1
81
+
82
+ end
83
+
84
+ class DestroyResponse
85
+ include Warden::Protocol::BaseMessage
86
+
87
+
88
+
89
+ end
90
+
91
+ class EchoRequest
92
+ include Warden::Protocol::BaseMessage
93
+
94
+
95
+ required :message, :string, 1
96
+
97
+ end
98
+
99
+ class EchoResponse
100
+ include Warden::Protocol::BaseMessage
101
+
102
+
103
+ required :message, :string, 1
104
+
105
+ end
106
+
107
+ class ErrorResponse
108
+ include Warden::Protocol::BaseMessage
109
+
110
+
111
+ optional :message, :string, 2
112
+ optional :data, :string, 4
113
+ repeated :backtrace, :string, 3
114
+
115
+ end
116
+
117
+ class InfoRequest
118
+ include Warden::Protocol::BaseMessage
119
+
120
+
121
+ required :handle, :string, 1
122
+
123
+ end
124
+
125
+ class InfoResponse
126
+ include Warden::Protocol::BaseMessage
127
+
128
+
129
+ class MemoryStat
130
+ include Warden::Protocol::BaseMessage
131
+
132
+
133
+ optional :cache, :uint64, 1
134
+ optional :rss, :uint64, 2
135
+ optional :mapped_file, :uint64, 3
136
+ optional :pgpgin, :uint64, 4
137
+ optional :pgpgout, :uint64, 5
138
+ optional :swap, :uint64, 6
139
+ optional :pgfault, :uint64, 7
140
+ optional :pgmajfault, :uint64, 8
141
+ optional :inactive_anon, :uint64, 9
142
+ optional :active_anon, :uint64, 10
143
+ optional :inactive_file, :uint64, 11
144
+ optional :active_file, :uint64, 12
145
+ optional :unevictable, :uint64, 13
146
+ optional :hierarchical_memory_limit, :uint64, 14
147
+ optional :hierarchical_memsw_limit, :uint64, 15
148
+ optional :total_cache, :uint64, 16
149
+ optional :total_rss, :uint64, 17
150
+ optional :total_mapped_file, :uint64, 18
151
+ optional :total_pgpgin, :uint64, 19
152
+ optional :total_pgpgout, :uint64, 20
153
+ optional :total_swap, :uint64, 21
154
+ optional :total_pgfault, :uint64, 22
155
+ optional :total_pgmajfault, :uint64, 23
156
+ optional :total_inactive_anon, :uint64, 24
157
+ optional :total_active_anon, :uint64, 25
158
+ optional :total_inactive_file, :uint64, 26
159
+ optional :total_active_file, :uint64, 27
160
+ optional :total_unevictable, :uint64, 28
161
+
162
+ end
163
+
164
+ class CpuStat
165
+ include Warden::Protocol::BaseMessage
166
+
167
+
168
+ optional :usage, :uint64, 1
169
+ optional :user, :uint64, 2
170
+ optional :system, :uint64, 3
171
+
172
+ end
173
+
174
+ class DiskStat
175
+ include Warden::Protocol::BaseMessage
176
+
177
+
178
+ optional :bytes_used, :uint64, 1
179
+ optional :inodes_used, :uint64, 2
180
+
181
+ end
182
+
183
+ class BandwidthStat
184
+ include Warden::Protocol::BaseMessage
185
+
186
+
187
+ optional :in_rate, :uint64, 1
188
+ optional :in_burst, :uint64, 2
189
+ optional :out_rate, :uint64, 3
190
+ optional :out_burst, :uint64, 4
191
+
192
+ end
193
+
194
+ optional :state, :string, 10
195
+ repeated :events, :string, 20
196
+ optional :host_ip, :string, 30
197
+ optional :container_ip, :string, 31
198
+ optional :container_path, :string, 32
199
+ optional :memory_stat, InfoResponse::MemoryStat, 40
200
+ optional :cpu_stat, InfoResponse::CpuStat, 41
201
+ optional :disk_stat, InfoResponse::DiskStat, 42
202
+ optional :bandwidth_stat, InfoResponse::BandwidthStat, 43
203
+ repeated :job_ids, :uint64, 44
204
+
205
+ end
206
+
207
+ class LimitBandwidthRequest
208
+ include Warden::Protocol::BaseMessage
209
+
210
+
211
+ required :handle, :string, 1
212
+ required :rate, :uint64, 2
213
+ required :burst, :uint64, 3
214
+
215
+ end
216
+
217
+ class LimitBandwidthResponse
218
+ include Warden::Protocol::BaseMessage
219
+
220
+
221
+ required :rate, :uint64, 1
222
+ required :burst, :uint64, 2
223
+
224
+ end
225
+
226
+ class LimitDiskRequest
227
+ include Warden::Protocol::BaseMessage
228
+
229
+
230
+ required :handle, :string, 1
231
+ optional :block_limit, :uint64, 10
232
+ optional :block, :uint64, 11
233
+ optional :block_soft, :uint64, 12
234
+ optional :block_hard, :uint64, 13
235
+ optional :inode_limit, :uint64, 20
236
+ optional :inode, :uint64, 21
237
+ optional :inode_soft, :uint64, 22
238
+ optional :inode_hard, :uint64, 23
239
+ optional :byte_limit, :uint64, 30
240
+ optional :byte, :uint64, 31
241
+ optional :byte_soft, :uint64, 32
242
+ optional :byte_hard, :uint64, 33
243
+
244
+ end
245
+
246
+ class LimitDiskResponse
247
+ include Warden::Protocol::BaseMessage
248
+
249
+
250
+ optional :block_limit, :uint64, 10
251
+ optional :block, :uint64, 11
252
+ optional :block_soft, :uint64, 12
253
+ optional :block_hard, :uint64, 13
254
+ optional :inode_limit, :uint64, 20
255
+ optional :inode, :uint64, 21
256
+ optional :inode_soft, :uint64, 22
257
+ optional :inode_hard, :uint64, 23
258
+ optional :byte_limit, :uint64, 30
259
+ optional :byte, :uint64, 31
260
+ optional :byte_soft, :uint64, 32
261
+ optional :byte_hard, :uint64, 33
262
+
263
+ end
264
+
265
+ class LimitMemoryRequest
266
+ include Warden::Protocol::BaseMessage
267
+
268
+
269
+ required :handle, :string, 1
270
+ optional :limit_in_bytes, :uint64, 2
271
+
272
+ end
273
+
274
+ class LimitMemoryResponse
275
+ include Warden::Protocol::BaseMessage
276
+
277
+
278
+ optional :limit_in_bytes, :uint64, 1
279
+
280
+ end
281
+
282
+ class LinkRequest
283
+ include Warden::Protocol::BaseMessage
284
+
285
+
286
+ required :handle, :string, 1
287
+ required :job_id, :uint32, 2
288
+
289
+ end
290
+
291
+ class LinkResponse
292
+ include Warden::Protocol::BaseMessage
293
+
294
+
295
+ optional :exit_status, :uint32, 1
296
+ optional :stdout, :string, 2
297
+ optional :stderr, :string, 3
298
+ optional :info, InfoResponse, 4
299
+
300
+ end
301
+
302
+ class ListRequest
303
+ include Warden::Protocol::BaseMessage
304
+
305
+
306
+
307
+ end
308
+
309
+ class ListResponse
310
+ include Warden::Protocol::BaseMessage
311
+
312
+
313
+ repeated :handles, :string, 1
314
+
315
+ end
316
+
317
+ class Message
318
+ include Warden::Protocol::BaseMessage
319
+
320
+ module Type
321
+ Error = 1
322
+ Create = 11
323
+ Stop = 12
324
+ Destroy = 13
325
+ Info = 14
326
+ Spawn = 21
327
+ Link = 22
328
+ Run = 23
329
+ Stream = 24
330
+ NetIn = 31
331
+ NetOut = 32
332
+ CopyIn = 41
333
+ CopyOut = 42
334
+ LimitMemory = 51
335
+ LimitDisk = 52
336
+ LimitBandwidth = 53
337
+ Ping = 91
338
+ List = 92
339
+ Echo = 93
340
+ end
341
+
342
+ required :type, Message::Type, 1
343
+ required :payload, :bytes, 2
344
+
345
+ end
346
+
347
+ class NetInRequest
348
+ include Warden::Protocol::BaseMessage
349
+
350
+
351
+ required :handle, :string, 1
352
+ optional :host_port, :uint32, 3
353
+ optional :container_port, :uint32, 2
354
+
355
+ end
356
+
357
+ class NetInResponse
358
+ include Warden::Protocol::BaseMessage
359
+
360
+
361
+ required :host_port, :uint32, 1
362
+ required :container_port, :uint32, 2
363
+
364
+ end
365
+
366
+ class NetOutRequest
367
+ include Warden::Protocol::BaseMessage
368
+
369
+
370
+ required :handle, :string, 1
371
+ optional :network, :string, 2
372
+ optional :port, :uint32, 3
373
+
374
+ end
375
+
376
+ class NetOutResponse
377
+ include Warden::Protocol::BaseMessage
378
+
379
+
380
+
381
+ end
382
+
383
+ class PingRequest
384
+ include Warden::Protocol::BaseMessage
385
+
386
+
387
+
388
+ end
389
+
390
+ class PingResponse
391
+ include Warden::Protocol::BaseMessage
392
+
393
+
394
+
395
+ end
396
+
397
+ class ResourceLimits
398
+ include Warden::Protocol::BaseMessage
399
+
400
+
401
+ optional :as, :uint64, 1
402
+ optional :core, :uint64, 2
403
+ optional :cpu, :uint64, 3
404
+ optional :data, :uint64, 4
405
+ optional :fsize, :uint64, 5
406
+ optional :locks, :uint64, 6
407
+ optional :memlock, :uint64, 7
408
+ optional :msgqueue, :uint64, 8
409
+ optional :nice, :uint64, 9
410
+ optional :nofile, :uint64, 10
411
+ optional :nproc, :uint64, 11
412
+ optional :rss, :uint64, 12
413
+ optional :rtprio, :uint64, 13
414
+ optional :sigpending, :uint64, 14
415
+ optional :stack, :uint64, 15
416
+
417
+ end
418
+
419
+ class RunRequest
420
+ include Warden::Protocol::BaseMessage
421
+
422
+
423
+ required :handle, :string, 1
424
+ required :script, :string, 2
425
+ optional :privileged, :bool, 3, :default => false
426
+ optional :rlimits, ResourceLimits, 4
427
+
428
+ end
429
+
430
+ class RunResponse
431
+ include Warden::Protocol::BaseMessage
432
+
433
+
434
+ optional :exit_status, :uint32, 1
435
+ optional :stdout, :string, 2
436
+ optional :stderr, :string, 3
437
+ optional :info, InfoResponse, 4
438
+
439
+ end
440
+
441
+ class SpawnRequest
442
+ include Warden::Protocol::BaseMessage
443
+
444
+
445
+ required :handle, :string, 1
446
+ required :script, :string, 2
447
+ optional :privileged, :bool, 3, :default => false
448
+ optional :rlimits, ResourceLimits, 4
449
+
450
+ end
451
+
452
+ class SpawnResponse
453
+ include Warden::Protocol::BaseMessage
454
+
455
+
456
+ required :job_id, :uint32, 1
457
+
458
+ end
459
+
460
+ class StopRequest
461
+ include Warden::Protocol::BaseMessage
462
+
463
+
464
+ required :handle, :string, 1
465
+ optional :background, :bool, 10, :default => false
466
+ optional :kill, :bool, 20, :default => false
467
+
468
+ end
469
+
470
+ class StopResponse
471
+ include Warden::Protocol::BaseMessage
472
+
473
+
474
+
475
+ end
476
+
477
+ class StreamRequest
478
+ include Warden::Protocol::BaseMessage
479
+
480
+
481
+ required :handle, :string, 1
482
+ required :job_id, :uint32, 2
483
+
484
+ end
485
+
486
+ class StreamResponse
487
+ include Warden::Protocol::BaseMessage
488
+
489
+
490
+ optional :name, :string, 1
491
+ optional :data, :string, 2
492
+ optional :exit_status, :uint32, 3
493
+ optional :info, InfoResponse, 4
494
+
495
+ end
496
+ end
497
+ end