storage

package
v0.0.0-...-f3e401e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2024 License: BSD-3-Clause Imports: 9 Imported by: 55

Documentation

Overview

Package storage contains a client for the performance data storage server.

Deprecated: Moved to golang.org/x/build/perfdata.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// BaseURL is the base URL of the storage server.
	BaseURL string
	// HTTPClient is the HTTP client for sending requests. If nil, http.DefaultClient will be used.
	HTTPClient *http.Client
}

A Client issues queries to a performance data storage server. It is safe to use from multiple goroutines simultaneously.

func (*Client) ListUploads

func (c *Client) ListUploads(ctx context.Context, q string, extraLabels []string, limit int) *UploadList

ListUploads searches for uploads containing results matching the given query string. The query may be empty, in which case all uploads will be returned. extraLabels specifies other labels to be retrieved. If limit is 0, no limit will be provided to the server. The uploads are returned starting with the most recent upload.

func (*Client) NewUpload

func (c *Client) NewUpload(ctx context.Context) *Upload

NewUpload starts a new upload to the storage server. The upload must have Abort or Commit called on it. If the server requires authentication for uploads, c.HTTPClient should be set to the result of oauth2.NewClient.

func (*Client) Query

func (c *Client) Query(ctx context.Context, q string) *Query

Query searches for results matching the given query string.

The query string is first parsed into quoted words (as in the shell) and then each word must be formatted as one of the following: key:value - exact match on label "key" = "value" key>value - value greater than (useful for dates) key<value - value less than (also useful for dates)

type Query

type Query struct {
	// contains filtered or unexported fields
}

A Query allows iteration over the results of a search query. Use Next to advance through the results, making sure to call Close when done:

q := client.Query("key:value")
defer q.Close()
for q.Next() {
  res := q.Result()
  ...
}
if err = q.Err(); err != nil {
  // handle error encountered during query
}

func (*Query) Close

func (q *Query) Close() error

Close frees resources associated with the query.

func (*Query) Err

func (q *Query) Err() error

Err returns the first error encountered during the query.

func (*Query) Next

func (q *Query) Next() bool

Next prepares the next result for reading with the Result method. It returns false when there are no more results, either by reaching the end of the input or an error.

func (*Query) Result

func (q *Query) Result() *benchfmt.Result

Result returns the most recent result generated by a call to Next.

type Upload

type Upload struct {
	// contains filtered or unexported fields
}

An Upload is an in-progress upload. Use CreateFile to upload one or more files, then call Commit or Abort.

u := client.NewUpload()
w, err := u.CreateFile()
if err != nil {
  u.Abort()
  return err
}
fmt.Fprintf(w, "BenchmarkResult 1 1 ns/op\n")
if err := u.Commit(); err != nil {
  return err
}

func (*Upload) Abort

func (u *Upload) Abort() error

Abort attempts to cancel the in-progress upload.

func (*Upload) Commit

func (u *Upload) Commit() (*UploadStatus, error)

Commit attempts to commit the upload.

func (*Upload) CreateFile

func (u *Upload) CreateFile(name string) (io.Writer, error)

CreateFile creates a new upload with the given name. The Writer may be used until CreateFile is called again. name may be the empty string if the file does not have a name.

type UploadInfo

type UploadInfo struct {
	Count       int
	UploadID    string
	LabelValues benchfmt.Labels `json:",omitempty"`
}

UploadInfo represents an upload summary.

type UploadList

type UploadList struct {
	// contains filtered or unexported fields
}

UploadList is the result of ListUploads. Use Next to advance through the rows, making sure to call Close when done:

q := db.ListUploads("key:value")
defer q.Close()
for q.Next() {
  id, count := q.Row()
  labels := q.LabelValues()
  ...
}
err = q.Err() // get any error encountered during iteration
...

func (*UploadList) Close

func (ul *UploadList) Close() error

Close frees resources associated with the query.

func (*UploadList) Err

func (ul *UploadList) Err() error

Err returns the error state of the query.

func (*UploadList) Info

func (ul *UploadList) Info() UploadInfo

Info returns the most recent UploadInfo generated by a call to Next.

func (*UploadList) Next

func (ul *UploadList) Next() bool

Next prepares the next result for reading with the Result method. It returns false when there are no more results, either by reaching the end of the input or an error.

type UploadStatus

type UploadStatus struct {
	// UploadID is the upload ID assigned to the upload.
	UploadID string `json:"uploadid"`
	// FileIDs is the list of file IDs assigned to the files in the upload.
	FileIDs []string `json:"fileids"`
	// ViewURL is a server-supplied URL to view the results.
	ViewURL string `json:"viewurl"`
}

UploadStatus contains information about a successful upload.

Directories

Path Synopsis
Package app implements the performance data storage server.
Package app implements the performance data storage server.
This binary contains an App Engine app for perfdata.golang.org
This binary contains an App Engine app for perfdata.golang.org
Package benchfmt provides readers and writers for the Go benchmark format.
Package benchfmt provides readers and writers for the Go benchmark format.
db
Package db provides the high-level database interface for the storage app.
Package db provides the high-level database interface for the storage app.
sqlite3
Package sqlite3 provides the sqlite3 driver for x/perf/storage/db.
Package sqlite3 provides the sqlite3 driver for x/perf/storage/db.
fs
Package fs provides a backend-agnostic filesystem layer for storing performance results.
Package fs provides a backend-agnostic filesystem layer for storing performance results.
gcs
Package gcs implements the fs.FS interface using Google Cloud Storage.
Package gcs implements the fs.FS interface using Google Cloud Storage.
local
Package local implements the fs.FS interface using local files.
Package local implements the fs.FS interface using local files.
Localperfdata runs an HTTP server for benchmark storage.
Localperfdata runs an HTTP server for benchmark storage.
Package query provides tools for parsing a query.
Package query provides tools for parsing a query.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL