add options for components
This commit is contained in:
@ -37,7 +37,7 @@ func FileRecorder(filename string, opts ...FileRecorderOption) recorder.Recorder
|
||||
}
|
||||
}
|
||||
|
||||
func (r *fileRecorder) Record(ctx context.Context, b []byte) error {
|
||||
func (r *fileRecorder) Record(ctx context.Context, b []byte, opts ...recorder.RecordOption) error {
|
||||
f, err := os.OpenFile(r.filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -42,7 +42,7 @@ func HTTPRecorder(url string, opts ...HTTPRecorderOption) recorder.Recorder {
|
||||
}
|
||||
}
|
||||
|
||||
func (r *httpRecorder) Record(ctx context.Context, b []byte) error {
|
||||
func (r *httpRecorder) Record(ctx context.Context, b []byte, opts ...recorder.RecordOption) error {
|
||||
req, err := http.NewRequest(http.MethodPost, r.url, bytes.NewReader(b))
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -48,7 +48,7 @@ func NewGRPCPlugin(name string, addr string, opts ...plugin.Option) recorder.Rec
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *grpcPlugin) Record(ctx context.Context, b []byte) error {
|
||||
func (p *grpcPlugin) Record(ctx context.Context, b []byte, opts ...recorder.RecordOption) error {
|
||||
if p.client == nil {
|
||||
return nil
|
||||
}
|
||||
@ -98,13 +98,13 @@ func NewHTTPPlugin(name string, url string, opts ...plugin.Option) recorder.Reco
|
||||
client: plugin.NewHTTPClient(&options),
|
||||
header: options.Header,
|
||||
log: logger.Default().WithFields(map[string]any{
|
||||
"kind": "recorder",
|
||||
"kind": "recorder",
|
||||
"recorder": name,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
func (p *httpPlugin) Record(ctx context.Context, b []byte) error {
|
||||
func (p *httpPlugin) Record(ctx context.Context, b []byte, opts ...recorder.RecordOption) error {
|
||||
if len(b) == 0 || p.client == nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ func RedisSetRecorder(addr string, opts ...RedisRecorderOption) recorder.Recorde
|
||||
}
|
||||
}
|
||||
|
||||
func (r *redisSetRecorder) Record(ctx context.Context, b []byte) error {
|
||||
func (r *redisSetRecorder) Record(ctx context.Context, b []byte, opts ...recorder.RecordOption) error {
|
||||
if r.key == "" {
|
||||
return nil
|
||||
}
|
||||
@ -88,7 +88,7 @@ func RedisListRecorder(addr string, opts ...RedisRecorderOption) recorder.Record
|
||||
}
|
||||
}
|
||||
|
||||
func (r *redisListRecorder) Record(ctx context.Context, b []byte) error {
|
||||
func (r *redisListRecorder) Record(ctx context.Context, b []byte, opts ...recorder.RecordOption) error {
|
||||
if r.key == "" {
|
||||
return nil
|
||||
}
|
||||
@ -122,7 +122,7 @@ func RedisSortedSetRecorder(addr string, opts ...RedisRecorderOption) recorder.R
|
||||
}
|
||||
}
|
||||
|
||||
func (r *redisSortedSetRecorder) Record(ctx context.Context, b []byte) error {
|
||||
func (r *redisSortedSetRecorder) Record(ctx context.Context, b []byte, opts ...recorder.RecordOption) error {
|
||||
if r.key == "" {
|
||||
return nil
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ func TCPRecorder(addr string, opts ...TCPRecorderOption) recorder.Recorder {
|
||||
}
|
||||
}
|
||||
|
||||
func (r *tcpRecorder) Record(ctx context.Context, b []byte) error {
|
||||
func (r *tcpRecorder) Record(ctx context.Context, b []byte, opts ...recorder.RecordOption) error {
|
||||
c, err := r.dialer.DialContext(ctx, "tcp", r.addr)
|
||||
if err != nil {
|
||||
return err
|
||||
|
Reference in New Issue
Block a user