-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #304 from go-faster/chore/use-bytebufferpool
chore(prometheusremotewriter): use `bytebufferpool` to pool byte buffers
- Loading branch information
Showing
3 changed files
with
34 additions
and
50 deletions.
There are no files selected for viewing
33 changes: 0 additions & 33 deletions
33
internal/otelreceiver/prometheusremotewritereceiver/buffer.go
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
internal/otelreceiver/prometheusremotewritereceiver/pool.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package prometheusremotewritereceiver | ||
|
||
import ( | ||
"bytes" | ||
"sync" | ||
|
||
"github.com/go-faster/oteldb/internal/prompb" | ||
) | ||
|
||
var writeRequestPool sync.Pool | ||
|
||
func putWriteRequest(wr *prompb.WriteRequest) { | ||
wr.Reset() | ||
writeRequestPool.Put(wr) | ||
} | ||
|
||
func getWriteRequest() *prompb.WriteRequest { | ||
v := writeRequestPool.Get() | ||
if v == nil { | ||
return &prompb.WriteRequest{} | ||
} | ||
return v.(*prompb.WriteRequest) | ||
} | ||
|
||
type closerReader struct { | ||
data []byte | ||
bytes.Reader | ||
} | ||
|
||
func (c *closerReader) Close() error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters