MCPcopy
hub / github.com/grpc/grpc-go / retrieveSnapshot

Function retrieveSnapshot

profiling/cmd/remote.go:44–71  ·  view source on GitHub ↗
(ctx context.Context, c ppb.ProfilingClient, f string)

Source from the content-addressed store, hash-verified

42}
43
44func retrieveSnapshot(ctx context.Context, c ppb.ProfilingClient, f string) error {
45 logger.Infof("getting stream stats")
46 resp, err := c.GetStreamStats(ctx, &ppb.GetStreamStatsRequest{})
47 if err != nil {
48 logger.Errorf("error calling GetStreamStats: %v\n", err)
49 return err
50 }
51 s := &snapshot{StreamStats: resp.StreamStats}
52
53 logger.Infof("creating snapshot file %s", f)
54 file, err := os.Create(f)
55 if err != nil {
56 logger.Errorf("cannot create %s: %v", f, err)
57 return err
58 }
59 defer file.Close()
60
61 logger.Infof("encoding data and writing to snapshot file %s", f)
62 encoder := gob.NewEncoder(file)
63 err = encoder.Encode(s)
64 if err != nil {
65 logger.Infof("error encoding: %v", err)
66 return err
67 }
68
69 logger.Infof("successfully wrote profiling snapshot to %s", f)
70 return nil
71}
72
73func remoteCommand() error {
74 ctx := context.Background()

Callers 1

remoteCommandFunction · 0.85

Calls 5

InfofMethod · 0.65
GetStreamStatsMethod · 0.65
ErrorfMethod · 0.65
CloseMethod · 0.65
EncodeMethod · 0.45

Tested by

no test coverage detected