perf: golang.org/x/perf/storage Index | Files | Directories

package storage

import "golang.org/x/perf/storage"

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

Index

Package Files

client.go

type Client Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

func (q *Query) Close() error

Close frees resources associated with the query.

func (*Query) Err Uses

func (q *Query) Err() error

Err returns the first error encountered during the query.

func (*Query) Next Uses

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 Uses

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

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

type Upload Uses

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 Uses

func (u *Upload) Abort() error

Abort attempts to cancel the in-progress upload.

func (*Upload) Commit Uses

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

Commit attempts to commit the upload.

func (*Upload) CreateFile Uses

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 Uses

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

UploadInfo represents an upload summary.

type UploadList Uses

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 Uses

func (ul *UploadList) Close() error

Close frees resources associated with the query.

func (*UploadList) Err Uses

func (ul *UploadList) Err() error

Err returns the error state of the query.

func (*UploadList) Info Uses

func (ul *UploadList) Info() UploadInfo

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

func (*UploadList) Next Uses

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 Uses

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

PathSynopsis
appPackage app implements the performance data storage server.
benchfmtPackage benchfmt provides readers and writers for the Go benchmark format.
dbPackage db provides the high-level database interface for the storage app.
db/dbtest
db/sqlite3Package sqlite3 provides the sqlite3 driver for x/perf/storage/db.
fsPackage fs provides a backend-agnostic filesystem layer for storing performance results.
fs/gcsPackage gcs implements the fs.FS interface using Google Cloud Storage.
fs/localPackage local implements the fs.FS interface using local files.
localperfdataLocalperfdata runs an HTTP server for benchmark storage.
queryPackage query provides tools for parsing a query.

Package storage imports 10 packages (graph) and is imported by 7 packages. Updated 2017-07-19. Refresh now. Tools for package owners.