MCPcopy
hub / github.com/NVIDIA/aistore / Example_msg

Function Example_msg

transport/msg_test.go:25–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23)
24
25func Example_msg() {
26 receive := func(msg transport.Msg, err error) error {
27 if !transport.ReservedOpcode(msg.Opcode) {
28 fmt.Printf("%s...\n", string(msg.Body[:16]))
29 }
30 return nil
31 }
32
33 ts := httptest.NewServer(msgmux)
34 defer ts.Close()
35
36 trname := "dummy-msg"
37 err := transport.HandleMsgStream(trname, receive)
38 if err != nil {
39 fmt.Println(err)
40 return
41 }
42 httpclient := transport.NewIntraDataClient()
43 url := ts.URL + transport.MsgURLPath(trname)
44 stream := transport.NewMsgStream(httpclient, url, cos.GenTie())
45
46 stream.Send(&transport.Msg{Body: []byte(lorem)})
47 stream.Send(&transport.Msg{Body: []byte(duis)})
48 stream.Send(&transport.Msg{Body: []byte(et)})
49 stream.Send(&transport.Msg{Body: []byte(temporibus)})
50
51 stream.Fin()
52
53 // Output:
54 // Lorem ipsum dolo...
55 // Duis aute irure ...
56 // Et harum quidem ...
57 // Temporibus autem...
58}
59
60func Test_MsgDryRun(t *testing.T) {
61 tutils.CheckSkip(t, tutils.SkipTestArgs{Long: true})

Callers

nothing calls this directly

Calls 9

SendMethod · 0.95
FinMethod · 0.95
ReservedOpcodeFunction · 0.92
HandleMsgStreamFunction · 0.92
NewIntraDataClientFunction · 0.92
MsgURLPathFunction · 0.92
NewMsgStreamFunction · 0.92
GenTieFunction · 0.92
CloseMethod · 0.65

Tested by

no test coverage detected