@@ -22,7 +22,7 @@ import (
2222 "golang.org/x/sync/errgroup"
2323)
2424
25- const maxConcurrency = 5
25+ const MaxConcurrency = 5
2626
2727type Forwarder struct {
2828 cfg * config.Config
@@ -39,7 +39,7 @@ func NewForwarder(cfg *config.Config, client *http.Client, storage string) Forwa
3939}
4040
4141func (f Forwarder ) Start (ctx context.Context , in <- chan model.LogEntry ) error {
42- batches := make (chan []byte , maxConcurrency )
42+ batches := make (chan []byte , MaxConcurrency )
4343 batcher := batching .NewBatcher ()
4444
4545 producerErrCh := make (chan error , 1 )
@@ -49,7 +49,7 @@ func (f Forwarder) Start(ctx context.Context, in <-chan model.LogEntry) error {
4949 }()
5050
5151 var eg errgroup.Group
52- eg .SetLimit (maxConcurrency )
52+ eg .SetLimit (MaxConcurrency )
5353
5454 var errs []error
5555 var mu sync.Mutex
@@ -66,7 +66,10 @@ func (f Forwarder) Start(ctx context.Context, in <-chan model.LogEntry) error {
6666 }
6767
6868 eg .Go (func () error {
69- if err := f .send (ctx , body ); err != nil {
69+ if err := f .Send (ctx , body ); err != nil {
70+ if f .storage != nil {
71+ err = f .storage .Put (ctx , body , f .storageTag )
72+ }
7073 mu .Lock ()
7174 errs = append (errs , err )
7275 mu .Unlock ()
@@ -79,7 +82,7 @@ func (f Forwarder) Start(ctx context.Context, in <-chan model.LogEntry) error {
7982 return errors .Join (append (errs , <- producerErrCh )... )
8083}
8184
82- func (f Forwarder ) send (ctx context.Context , payload []byte ) error {
85+ func (f Forwarder ) Send (ctx context.Context , payload []byte ) error {
8386 ctx , cancel := context .WithTimeout (ctx , timeout )
8487 defer cancel ()
8588
0 commit comments