fix(recorder): propagate context, handle short writes, add nil guards, idempotent Close, and doc comments
- httpRecorder: use http.NewRequestWithContext instead of http.NewRequest - tcpRecorder: loop Write to avoid short-write data loss - fileRecorder: guard against nil out in Record and Close - plugin/grpc, plugin/http: handle json.Marshal errors instead of ignoring - fileRecorder, redis*Recorder: idempotent Close via sync.Once - All exported symbols: add doc comments
This commit is contained in:
@@ -55,7 +55,10 @@ func (p *grpcPlugin) Record(ctx context.Context, b []byte, opts ...recorder.Reco
|
||||
opt(&options)
|
||||
}
|
||||
|
||||
md, _ := json.Marshal(options.Metadata)
|
||||
md, err := json.Marshal(options.Metadata)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
reply, err := p.client.Record(ctx,
|
||||
&proto.RecordRequest{
|
||||
|
||||
@@ -56,7 +56,10 @@ func (p *httpPlugin) Record(ctx context.Context, b []byte, opts ...recorder.Reco
|
||||
opt(&options)
|
||||
}
|
||||
|
||||
md, _ := json.Marshal(options.Metadata)
|
||||
md, err := json.Marshal(options.Metadata)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rb := httpPluginRequest{
|
||||
Data: b,
|
||||
|
||||
Reference in New Issue
Block a user