mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-20 22:10:30 +00:00
Add StoreReport methods to stores
Not sure if we'll use them.
This commit is contained in:
@@ -2,6 +2,7 @@ package multitenant
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"fmt"
|
||||
"net"
|
||||
"sort"
|
||||
@@ -202,6 +203,13 @@ func (c *MemcacheClient) FetchReports(keys []string) (map[string]report.Report,
|
||||
return reports, missing, nil
|
||||
}
|
||||
|
||||
// StoreReport serializes and stores a report.
|
||||
func (c *MemcacheClient) StoreReport(key string, report *report.Report) error {
|
||||
var buf bytes.Buffer
|
||||
report.WriteBinary(&buf, gzip.BestCompression)
|
||||
return c.StoreBytes(key, buf.Bytes())
|
||||
}
|
||||
|
||||
// StoreBytes stores a report, expecting the report to be serialized already.
|
||||
func (c *MemcacheClient) StoreBytes(key string, content []byte) error {
|
||||
return instrument.TimeRequestHistogramStatus("Put", memcacheRequestDuration, memcacheStatusCode, func() error {
|
||||
|
||||
@@ -2,6 +2,7 @@ package multitenant
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
@@ -84,6 +85,13 @@ func (store *S3Store) fetchReport(key string) (*report.Report, error) {
|
||||
return report.MakeFromBinary(resp.Body)
|
||||
}
|
||||
|
||||
// StoreReport serializes and stores a report.
|
||||
func (store *S3Store) StoreReport(key string, report *report.Report) error {
|
||||
var buf bytes.Buffer
|
||||
report.WriteBinary(&buf, gzip.BestCompression)
|
||||
return store.StoreBytes(key, buf.Bytes())
|
||||
}
|
||||
|
||||
// StoreBytes stores a report in S3, expecting the report to be serialized
|
||||
// already.
|
||||
func (store *S3Store) StoreBytes(key string, content []byte) error {
|
||||
|
||||
Reference in New Issue
Block a user