@@ -37,19 +37,10 @@ type msgReceipt struct {
37
37
Sockets SocketGroup
38
38
}
39
39
40
- // OutputMsg holds the data for a pyout message.
41
- type OutputMsg struct {
42
- Execcount int `json:"execution_count"`
43
- Data map [string ]string `json:"data"`
44
- Metadata map [string ]interface {} `json:"metadata"`
45
- }
46
-
47
- // ErrMsg encodes the traceback of errors output to the notebook.
48
- type ErrMsg struct {
49
- EName string `json:"ename"`
50
- EValue string `json:"evalue"`
51
- Traceback []string `json:"traceback"`
52
- }
40
+ // bundledMIMEData holds data that can be presented in multiple formats. The keys are MIME types
41
+ // and the values are the data formatted with respect to it's MIME type. All bundles should contain
42
+ // at least a "text/plain" representation with a string value.
43
+ type bundledMIMEData map [string ]interface {}
53
44
54
45
// InvalidSignatureError is returned when the signature on a received message does not
55
46
// validate.
@@ -214,32 +205,20 @@ func (receipt *msgReceipt) Reply(msgType string, content interface{}) error {
214
205
return receipt .SendResponse (receipt .Sockets .ShellSocket , msg )
215
206
}
216
207
217
- // MIMEDataBundle holds data that can be presented in multiple formats. The keys are MIME types
218
- // and the values are the data formatted with respect to it's MIME type. All bundle should contain
219
- // at least a "text/plain" representation with a string value.
220
- type MIMEDataBundle map [string ]interface {}
221
-
222
- // NewTextMIMEDataBundle creates a MIMEDataBundle that only contains a text representation described
223
- // the the parameter 'value'.
224
- func NewTextMIMEDataBundle (value string ) MIMEDataBundle {
225
- return MIMEDataBundle {
208
+ // newTextMIMEDataBundle creates a bundledMIMEData that only contains a text representation described
209
+ // by the value parameter.
210
+ func newTextBundledMIMEData (value string ) bundledMIMEData {
211
+ return bundledMIMEData {
226
212
"text/plain" : value ,
227
213
}
228
214
}
229
215
230
- type KernelStatus string
231
-
232
- const (
233
- KernelStarting KernelStatus = "starting"
234
- KernelBusy = "busy"
235
- KernelIdle = "idle"
236
- )
237
-
238
- // PublishKernelStatus publishes a status message notifying front-ends of the state the kernel is in.
239
- func (receipt * msgReceipt ) PublishKernelStatus (status KernelStatus ) error {
216
+ // PublishKernelStatus publishes a status message notifying front-ends of the state the kernel is in. Supports
217
+ // states "starting", "busy", and "idle".
218
+ func (receipt * msgReceipt ) PublishKernelStatus (status string ) error {
240
219
return receipt .Publish ("status" ,
241
220
struct {
242
- ExecutionState KernelStatus `json:"execution_state"`
221
+ ExecutionState string `json:"execution_state"`
243
222
}{
244
223
ExecutionState : status ,
245
224
},
@@ -264,13 +243,13 @@ func (receipt *msgReceipt) PublishExecutionInput(execCount int, code string) err
264
243
func (receipt * msgReceipt ) PublishExecutionResult (execCount int , output string ) error {
265
244
return receipt .Publish ("execute_result" ,
266
245
struct {
267
- ExecCount int `json:"execution_count"`
268
- Data MIMEDataBundle `json:"data"`
269
- Metadata MIMEDataBundle `json:"metadata"`
246
+ ExecCount int `json:"execution_count"`
247
+ Data bundledMIMEData `json:"data"`
248
+ Metadata bundledMIMEData `json:"metadata"`
270
249
}{
271
250
ExecCount : execCount ,
272
- Data : NewTextMIMEDataBundle (output ),
273
- Metadata : make (MIMEDataBundle ),
251
+ Data : newTextBundledMIMEData (output ),
252
+ Metadata : make (bundledMIMEData ),
274
253
},
275
254
)
276
255
}
@@ -289,24 +268,3 @@ func (receipt *msgReceipt) PublishExecutionError(err string, trace []string) err
289
268
},
290
269
)
291
270
}
292
-
293
- type Stream string
294
-
295
- const (
296
- StreamStdout Stream = "stdout"
297
- StreamStderr = "stderr"
298
- )
299
-
300
- // PublishWriteStream prints the data string to a stream on the front-end. This is
301
- // either `StreamStdout` or `StreamStderr`.
302
- func (receipt * msgReceipt ) PublishWriteStream (stream Stream , data string ) error {
303
- return receipt .Publish ("stream" ,
304
- struct {
305
- Stream Stream `json:"name"`
306
- Data string `json:"text"`
307
- }{
308
- Stream : stream ,
309
- Data : data ,
310
- },
311
- )
312
- }
0 commit comments