rockset

package module
v0.15.3 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2022 License: Apache-2.0 Imports: 18 Imported by: 15

README

Rockset Go Client

CircleCI Documentation License GitHub issues Release Coverage Status

Official Go client library for Rockset

Installation

Install the Rockset Go client from Github:

go get github.com/rockset/rockset-go-client

or install it from a source code checkout:

cd $GOPATH/src/github.com
mkdir rockset
cd rockset
git clone git@github.com:rockset/rockset-go-client.git
go install rockset-go-client/rockclient.go

Usage

You can see a few examples in the godoc of how to create a collection, how to put documents in a collection and how to use SQL to query your collections.

client, err := rockset.NewClient()
if err != nil {
    log.Fatal(err)
}

ctx := context.TODO()
q := `SELECT * FROM "_events" LIMIT 1`

res, _, err := client.Query(ctx, q)
if err != nil {
    log.Fatal(err)
}

fmt.Printf("%+v\n", res)

Testing

There are a number of testable examples which require an API key, i.e. set the ROCKSET_APIKEY environment variable.

To run tests:

go test ./...
Code Coverage
go test ./... -coverprofile cover.out
go tool cover -func=cover.out
go tool cover -html=cover.out -o coverage.html

Support

Feel free to log issues against this client through GitHub.

License

The Rockset Go Client is licensed under the Apache 2.0 License

Documentation

Overview

Package rockset provides a go client to interact with the Rockset database.

The client uses the Rockset REST API https://docs.rockset.com/rest-api/, and is an OpenAPI generated code by https://openapi-generator.tech/.

It provides convenience functions for all API calls to make the generated client easier to use, by wrapping the API calls in methods that require passing a context.Context and having all required arguments in the method signature, so that as many errors as possible are caught at compile time instead of at runtime. It uses functional options for any optional arguments. The convenience methods return the payload data from the models package, to reduce the indirection.

All methods also automatically retries any retryable error returned by the Rockset API, using exponential back-off. The retryable errors are defined in rockset.RetryableErrors.

If a zerolog logger is set in the context, the methods will log to it. E.g.

console := zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: time.RFC3339}
log := zerolog.New(console).Level(zerolog.TraceLevel).With().Timestamp().Logger()
ctx := log.WithContext(context.Background())

rc, err := rockset.NewClient()
if err != nil {
    log.Fatalf("failed to create RockClient: %v," err)
}

wsName := "commons"
ws, err := rc.GetWorkspace(ctx, wsName)
if err != nil {
    log.Fatalf("failed to get workspace %s: %v", wsName, err)
}

Example log output

2021-05-28T13:11:46-07:00 TRC api call curation d=467.371958ms
2021-05-28T13:11:46-07:00 DBG total duration d=467.538875ms
2021-05-28T13:11:46-07:00 DBG get workspace successful name=commons
Example (QueryRaw)

Raw usage of the openapi client

ctx := context.TODO()

rc, err := rockset.NewClient()
if err != nil {
	log.Fatal(err)
}

q := rc.QueriesApi.Query(ctx)
rq := openapi.NewQueryRequestWithDefaults()

rq.Sql = openapi.QueryRequestSql{Query: "SELECT * FROM commons._events where label = :label"}
rq.Sql.GenerateWarnings = openapi.PtrBool(true)
rq.Sql.DefaultRowLimit = openapi.PtrInt32(10)

rq.Sql.Parameters = []openapi.QueryParameter{
	{
		Name:  "label",
		Type:  "string",
		Value: "QUERY_SUCCESS",
	},
}

r, _, err := q.Body(*rq).Execute()
if err != nil {
	log.Fatal(err)
}

for _, c := range r.Collections {
	fmt.Printf("collection: %s\n", c)
}
Output:

collection: commons._events
Example (S3)

Example code to first create an S3 integration, then create a collection from the integration, and finally clean up.

ctx := context.TODO()

rc, err := rockset.NewClient(rockset.WithHTTPDebug())
if err != nil {
	log.Fatal(err)
}

// create integration
r, err := rc.CreateS3Integration(ctx, "exampleS3Integration",
	option.AWSRole("arn:aws:iam::469279130686:role/rockset-s3-integration"),
	option.WithS3IntegrationDescription("created by go example code"))
if err != nil {
	log.Fatalf("failed to create integration: %v", err)
}
fmt.Printf("integration created: %s\n", r.GetName())

// create an S3 collection
c, err := rc.CreateCollection(ctx, "example", "fromS3",
	option.WithCollectionDescription("created by go example code"),
	option.WithS3Source("exampleS3Integration", "rockset-go-tests",
		option.WithCSVFormat(
			[]string{"city", "country", "population", "visited"},
			[]option.ColumnType{
				option.ColumnTypeString, option.ColumnTypeString, option.ColumnTypeInteger, option.ColumnTypeBool,
			},
			option.WithEncoding("UTF-8"),
			option.WithEscapeChar("\\"),
			option.WithQuoteChar(`"`),
			option.WithSeparator(","),
		),
		option.WithS3Prefix("cities.csv"),
	),
	option.WithFieldMappingQuery("SELECT * FROM _input"),
)
if err != nil {
	log.Fatalf("failed to create collection: %v", err)
}
fmt.Printf("collection created: %s\n", c.GetName())

// wait until collection is ready
err = rc.WaitUntilCollectionReady(ctx, "example", "fromS3")
if err != nil {
	log.Fatalf("failed to wait for collection to be ready: %v", err)
}
fmt.Printf("collection ready: %s\n", c.GetName())

// wait until there are at least 3 new documents in the collection
err = rc.WaitUntilCollectionHasDocuments(ctx, "example", "fromS3", 3)
if err != nil {
	log.Fatalf("failed to wait for new documents: %v", err)
}

// get number of documents
collection, err := rc.GetCollection(ctx, "example", "fromS3")
if err != nil {
	log.Fatalf("failed to get collection: %v", err)
}
fmt.Printf("collection documents: %d\n", collection.Stats.GetDocCount())

// delete the collection
err = rc.DeleteCollection(ctx, "example", "fromS3")
if err != nil {
	log.Fatalf("failed to delete collection: %v", err)
}
fmt.Printf("collection deleted: %s\n", c.GetName())

// wait until the collection is gone
err = rc.WaitUntilCollectionGone(ctx, "example", "fromS3")
if err != nil {
	log.Fatalf("failed to wait for collection to be gone: %v", err)
}
fmt.Printf("collection gone: %s\n", c.GetName())

// delete integration
err = rc.DeleteIntegration(ctx, "exampleS3Integration")
if err != nil {
	log.Fatalf("failed to delete integration: %v", err)
}
fmt.Printf("integration deleted: %s\n", r.GetName())
Output:

integration created: exampleS3Integration
collection created: fromS3
collection ready: fromS3
collection documents: 3
collection deleted: fromS3
collection gone: fromS3
integration deleted: exampleS3Integration
Example (VCR)

Use govcr to record API calls as fixtures and then replay them. Note that this will record your API key so do not commit the saved "cassette" to a public repo. See https://github.com/seborama/govcr for information how to use govcr.

ctx := context.TODO()

cfg := govcr.VCRConfig{Logging: true, CassettePath: "vcr"}
rt := govcr.NewVCR("example", &cfg).Client

rc, err := rockset.NewClient(rockset.WithHTTPClient(rt))
if err != nil {
	log.Fatal(err)
}

// first request will make a HTTP request to the Rockset API
r, err := rc.GetOrganization(ctx)
if err != nil {
	log.Fatal(err)
}
fmt.Printf("org: %s\n", r.GetId())

// get a new client with recordings disabled
cfg.DisableRecording = true
rt = govcr.NewVCR("example", &cfg).Client
rc, err = rockset.NewClient(rockset.WithHTTPClient(rt))
if err != nil {
	log.Fatal(err)
}

// second request will replay the recorded information
r, err = rc.GetOrganization(ctx)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("org: %s\n", r.GetId())
Output:

org: rockset-circleci
org: rockset-circleci

Index

Examples

Constants

View Source
const (
	// APIKeyEnvironmentVariableName is the environment variable name for the API key
	APIKeyEnvironmentVariableName = "ROCKSET_APIKEY" //nolint
	// APIServerEnvironmentVariableName is the environment variable name for the API server
	APIServerEnvironmentVariableName = "ROCKSET_APISERVER"
	// DefaultUserAgent is the user agent string the Rockset go client will use for REST API calls.
	DefaultUserAgent = "rockset-go-client"
	// HeaderVersionName is the name of the HTTP header the go client sets which contains the client version used.
	HeaderVersionName = "x-rockset-version"
)
View Source
const (
	ReadOnlyRole = "read-only"
	MemberRole   = "member"
	AdminRole    = "admin"
)
View Source
const LatestTag = "latest"

LatestTag is the query lambda tag for the latest version.

View Source
const Version = "0.15.3"

Version is the Rockset client version

Variables

RetryableErrors are the errors which will cause the operation to be retried

Functions

func DefaultRetryableErrorCheck added in v0.15.3

func DefaultRetryableErrorCheck(err error) bool

DefaultRetryableErrorCheck returns true if err is an error that is retryable, i.e. implements RetryableError. This function is used to determine which errors to retry for the convenience methods on the RockClient.

Types

type Error added in v0.12.0

type Error struct {
	// ErrorModel is the ErrorModel of the underlying error
	*openapi.ErrorModel
	// Cause is the underlying cause of the error
	Cause error
}

Error is an error returned by the Rockset REST API.

func NewError added in v0.12.0

func NewError(err error) Error

NewError wraps err in an Error that provides better error messages than the openapi.GenericOpenAPIError

func (Error) Error added in v0.12.0

func (e Error) Error() string

Error returns a string representation of the error

func (Error) IsNotFoundError added in v0.12.0

func (e Error) IsNotFoundError() bool

IsNotFoundError returns true when the error is from an underlying 404 response from the Rockset REST API.

func (Error) RateLimited added in v0.12.0

func (e Error) RateLimited() bool

RateLimited checks if the error came from a http.StatusTooManyRequests, which is used for rate limiting.

func (Error) Retryable added in v0.12.0

func (e Error) Retryable() bool

Retryable returns true if the error is in RetryableErrors

func (Error) Unwrap added in v0.12.0

func (e Error) Unwrap() error

Unwrap returns the cause of the Error

type ExponentialRetry added in v0.12.0

type ExponentialRetry struct {
	// MaxBackoff is the max time the exponential backoff can wait
	MaxBackoff time.Duration
	// WaitInterval is the initial interval wait between consecutive calls
	WaitInterval time.Duration
	// JitterFraction is the fraction of wait interval to use as jitter [0,1.0]
	JitterFraction float64
	// RetryableErrorCheck is the function that determines if an error should be retried. If nil, it uses the RetryableError().
	RetryableErrorCheck func(error) bool
}

ExponentialRetry is used to perform API cal retries with exponential backoff

func (ExponentialRetry) Retry added in v0.12.0

func (r ExponentialRetry) Retry(ctx context.Context, retryFn RetryFunc) error

Retry retries retryFn until it returns false, or an error. Uses exponential backoff. If the retryFn returns an error, it is wrapped in an Error, which implements RetryableError so the RetryableErrorCheck can determine if it should retry the operation.

func (ExponentialRetry) RetryWithCheck added in v0.12.0

func (r ExponentialRetry) RetryWithCheck(ctx context.Context, checkFn RetryCheck) error

RetryWithCheck will retry checkFn until it returns false or an error. If checkFn returns false, RetryWithCheck will return nil, otherwise it'll return the error.

type HA added in v0.14.1

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

func NewHA added in v0.14.1

func NewHA(client ...Querier) *HA

func (*HA) Query added in v0.14.1

func (ha *HA) Query(ctx context.Context, query string, options ...option.QueryOption) (openapi.QueryResponse, []error)

type PatchDocument added in v0.13.0

type PatchDocument struct {
	ID      string           `json:"_id"`
	Patches []PatchOperation `json:"patch"`
}

type PatchOperation added in v0.13.0

type PatchOperation struct {
	Op    string      `json:"op"`
	Path  string      `json:"path"`
	Value interface{} `json:"value"`
	From  *string     `json:"from"`
}

type Querier added in v0.14.1

type Querier interface {
	Query(context.Context, string, ...option.QueryOption) (openapi.QueryResponse, error)
}

type QueryState added in v0.15.0

type QueryState string
const (
	QueryQueued    QueryState = "QUEUED"
	QueryRunning   QueryState = "RUNNING"
	QueryError     QueryState = "ERROR"
	QueryCompleted QueryState = "COMPLETED"
	QueryCancelled QueryState = "CANCELLED"
)

type Retrier added in v0.12.0

type Retrier interface {
	// Retry will retry retryFn if it returns an error which is retryable
	Retry(ctx context.Context, retryFn RetryFunc) error
	// RetryWithCheck will retry checkFn until it returns false or an error
	RetryWithCheck(ctx context.Context, checkFunc RetryCheck) error
}

Retrier is the interface used by the RockClient convenience methods to retry an operation which returned a rockset.Error which is Retryable().

type RetryCheck added in v0.12.0

type RetryCheck func() (retry bool, err error)

RetryCheck is the function Retrier will call until the RetryFunc returns false or an error.

type RetryFunc added in v0.12.0

type RetryFunc func() (err error)

RetryFunc is the function Retrier will call as long as it returns an error which is retryable.

type RetryableError added in v0.12.0

type RetryableError interface {
	error
	Retryable() bool
}

RetryableError is an error which can be retried

type RockClient

type RockClient struct {
	*openapi.APIClient
	RockConfig
}

RockClient is the client struct for making APi calls to Rockset.

Example (Query)

Query convenience method

ctx := context.TODO()

rc, err := rockset.NewClient()
if err != nil {
	log.Fatal(err)
}

r, err := rc.Query(ctx, "SELECT * FROM commons._events where label = :label",
	option.WithWarnings(), option.WithRowLimit(10),
	option.WithParameter("label", "string", "QUERY_SUCCESS"))
if err != nil {
	log.Fatal(err)
}

for _, c := range r.Collections {
	fmt.Printf("collection: %s\n", c)
}
Output:

collection: commons._events
Example (QueryLambda)
ctx := context.TODO()

rc, err := rockset.NewClient()
if err != nil {
	log.Fatal(err)
}

r, err := rc.ExecuteQueryLambda(ctx, "commons", "eventType")
if err != nil {
	log.Fatal(err)
}

for _, c := range r.Collections {
	fmt.Printf("collection: %s\n", c)
}
Output:

collection: commons._events
Example (QueryLambdaByTag)
ctx := context.TODO()

rc, err := rockset.NewClient()
if err != nil {
	log.Fatal(err)
}

r, err := rc.ExecuteQueryLambda(ctx, "commons", "eventType", option.WithTag("test"))
if err != nil {
	log.Fatal(err)
}

for _, c := range r.Collections {
	fmt.Printf("collection: %s\n", c)
}
Output:

collection: commons._events
Example (QueryLambdaByVersion)
ctx := context.TODO()

rc, err := rockset.NewClient()
if err != nil {
	log.Fatal(err)
}

r, err := rc.ExecuteQueryLambda(ctx, "commons", "eventType",
	option.WithVersion("e4e67e8835063d03"))
if err != nil {
	log.Fatal(err)
}

for _, c := range r.Collections {
	fmt.Printf("collection: %s\n", c)
}
Output:

collection: commons._events
Example (ValidateQuery)
ctx := context.TODO()

rc, err := rockset.NewClient()
if err != nil {
	log.Fatal(err)
}

r, err := rc.Query(ctx, "SELECT * FROM commons._events where label = :label",
	option.WithParameter("label", "string", "QUERY_SUCCESS"))
if err != nil {
	log.Fatal(err)
}

for _, c := range r.Collections {
	fmt.Printf("collection: %s\n", c)
}
Output:

collection: commons._events

func NewClient added in v0.8.0

func NewClient(options ...RockOption) (*RockClient, error)

NewClient creates a new Rockset client.

Accessing the online database requires an API key and an API server to connect to, which can be provided by through the ROCKSET_APIKEY and ROCKSET_APISERVER environment variables,

c, err := rockset.NewClient()

or they can be explicitly set using the WithAPIKey() and WithAPIServer() options.

c, err := rockset.NewClient(rockset.WithAPIKey("..."), rockset.WithAPIServer("..."))

func (*RockClient) AddDocuments added in v0.12.0

func (rc *RockClient) AddDocuments(ctx context.Context, workspace, collection string,
	docs []interface{}) ([]openapi.DocumentStatus, error)

AddDocuments adds new documents to a collection

REST API documentation https://docs.rockset.com/rest-api/#adddocuments

func (*RockClient) CancelQuery added in v0.15.0

func (rc *RockClient) CancelQuery(ctx context.Context, queryID string) (openapi.QueryInfo, error)

CancelQuery cancels a queued or running query.

func (*RockClient) CreateAPIKey added in v0.12.0

func (rc *RockClient) CreateAPIKey(ctx context.Context, keyName string,
	options ...option.APIKeyRoleOption) (openapi.ApiKey, error)

CreateAPIKey creates a new API key for the current user with the specified, with an optional role.

REST API documentation https://docs.rockset.com/rest-api/#createapikey

func (*RockClient) CreateAlias added in v0.12.0

func (rc *RockClient) CreateAlias(ctx context.Context, workspace, alias string, collections []string,
	options ...option.AliasOption) (openapi.Alias, error)

CreateAlias creates a new alias for a list of fully qualified collections, with an optional alias description using option.WithAliasDescription()

REST API documentation https://docs.rockset.com/rest-api/#createalias

func (*RockClient) CreateAzureBlobStorageIntegration added in v0.15.0

func (rc *RockClient) CreateAzureBlobStorageIntegration(ctx context.Context, name string,
	connection string) (openapi.Integration, error)

CreateAzureBlobStorageIntegration creates an integration for Azure's Blob Storage. requires a name for the integration and a connection string for the blob storage.

func (*RockClient) CreateCollection added in v0.12.0

func (rc *RockClient) CreateCollection(ctx context.Context, workspace, name string,
	options ...option.CollectionOption) (openapi.Collection, error)

CreateCollection is used to create a collection from one or more sources:

  • DynamoDB (see CreateDynamoDBIntegration())
  • GCS (see CreateGCSIntegration())
  • Kafka (see CreateKafkaIntegration())
  • Kinesis (see CreateKinesisIntegration())
  • MongoDB (see CreateMongoDBIntegration())
  • S3 (see CreateS3Integration())

It uses exponential backoff in case the API call is rate-limted.

To create a collection from multiple sources, use:

	 c, err := rc.CreateCollection(ctx, "commons", "example",
	   option.WithCollectionDescription("created by go example code"),
	   option.WithS3Source("s3-integration-name", "rockset-go-tests",
	     option.WithCSVFormat(
	       []string{"city", "country", "population", "visited"},
	       []option.ColumnType{
	         option.ColumnTypeString, option.ColumnTypeString, option.ColumnTypeInteger, option.ColumnTypeBool,
	       },
	       option.WithEncoding("UTF-8"),
	       option.WithEscapeChar("\\"),
	       option.WithQuoteChar(`"`),
	       option.WithSeparator(","),
	    ),
	    option.WithS3Prefix("cities.csv"),
	  ),
   option.WithKafkaSource("kafka-integration-name", "topic", option.KafkaStartingOffsetEarliest, option.WithJSONFormat(),
     option.WithKafkaSourceV3(),
   ),
   option.WithCollectionRetention(time.Hour),
	  option.WithFieldMappingQuery("SELECT * FROM _input"),
 )

func (*RockClient) CreateDynamoDBCollection added in v0.11.0

func (rc *RockClient) CreateDynamoDBCollection(ctx context.Context,
	workspace, name, description, integration, region, tableName string, maxRCU int64,
	format option.Format, options ...option.CollectionOption) (openapi.Collection, error)

func (*RockClient) CreateDynamoDBIntegration added in v0.11.0

func (rc *RockClient) CreateDynamoDBIntegration(ctx context.Context, name string, creds option.AWSCredentialsFn,
	s3BucketName string, options ...option.DynamoDBIntegrationOption) (openapi.Integration, error)

CreateDynamoDBIntegration creates a new AWS DynamoDB integration. It requires AWS credentials using either option.AWSKeys() or option.AWSRole(), and an S3 bucket which is used to export the DynamoDB tables.

func (*RockClient) CreateFileUploadCollection added in v0.11.0

func (rc *RockClient) CreateFileUploadCollection(ctx context.Context,
	workspace, name, description, fileName string, fileSize int64,
	fileUploadTime time.Time,
	format option.Format, options ...option.CollectionOption) (openapi.Collection, error)

func (*RockClient) CreateGCSCollection added in v0.11.0

func (rc *RockClient) CreateGCSCollection(ctx context.Context,
	workspace, name, description, integration, bucket, prefix string,
	format option.Format, options ...option.CollectionOption) (openapi.Collection, error)

func (*RockClient) CreateGCSIntegration added in v0.11.0

func (rc *RockClient) CreateGCSIntegration(ctx context.Context, name, serviceAccountKeyFileJSON string,
	options ...option.GCSIntegrationOption) (openapi.Integration, error)

func (*RockClient) CreateKafkaCollection added in v0.11.0

func (rc *RockClient) CreateKafkaCollection(ctx context.Context, workspace, name string,
	options ...option.CollectionOption) (openapi.Collection, error)

CreateKafkaCollection creates a single collection from a Kafka integration. Requires using option.WithKafkaSource() to configure the Kafka source options.

rc, err := rockset.NewClient()
if err != nil { ... }

c, err := rc.CreateKafkaCollection(ctx, "workspace", "collection",
    option.WithCollectionRetention(time.Hour),
    option.WithKafkaSource("integration-name", "topic", option.KafkaStartingOffsetEarliest,
        option.WithJSONFormat(),
    ))

if err != nil { ... }
if err = rc.WaitUntilCollectionReady(ctx, "workspace", "collection"); err != nil {
    ...
}

func (*RockClient) CreateKafkaIntegration added in v0.12.0

func (rc *RockClient) CreateKafkaIntegration(ctx context.Context, name string,
	options ...option.KafkaIntegrationOption) (openapi.Integration, error)

CreateKafkaIntegration create a new integration for a Kafka source. If no format is specified, it defaults to JSON.

func (*RockClient) CreateKinesisCollection added in v0.11.0

func (rc *RockClient) CreateKinesisCollection(ctx context.Context,
	workspace, name, description, integration, region, stream string,
	format option.Format, options ...option.CollectionOption) (openapi.Collection, error)

func (*RockClient) CreateKinesisIntegration added in v0.11.0

func (rc *RockClient) CreateKinesisIntegration(ctx context.Context, name string, creds option.AWSCredentialsFn,
	options ...option.KinesisIntegrationOption) (openapi.Integration, error)

func (*RockClient) CreateMongoDBCollection added in v0.11.0

func (rc *RockClient) CreateMongoDBCollection(ctx context.Context,
	workspace, name, description, integration, database, collection string,
	format option.Format, options ...option.CollectionOption) (openapi.Collection, error)

func (*RockClient) CreateMongoDBIntegration added in v0.12.0

func (rc *RockClient) CreateMongoDBIntegration(ctx context.Context, name, connectionURI string,
	options ...option.MongoDBIntegrationOption) (openapi.Integration, error)

func (*RockClient) CreateQueryLambda added in v0.12.4

func (rc *RockClient) CreateQueryLambda(ctx context.Context, workspace, name, sql string,
	options ...option.CreateQueryLambdaOption) (openapi.QueryLambdaVersion, error)

CreateQueryLambda creates a new query lambda.

https://docs.rockset.com/rest-api/#createquerylambda

func (*RockClient) CreateQueryLambdaTag added in v0.12.4

func (rc *RockClient) CreateQueryLambdaTag(ctx context.Context, workspace, name, version,
	tag string) (openapi.QueryLambdaTag, error)

CreateQueryLambdaTag creates a new tag for the query lambda version.

https://docs.rockset.com/rest-api/#createquerylambdatag

func (*RockClient) CreateRole added in v0.14.3

func (rc *RockClient) CreateRole(ctx context.Context, roleName string,
	options ...option.RoleOption) (openapi.Role, error)

CreateRole creates a new role

REST API documentation https://docs.rockset.com/rest-api/#createrole

func (*RockClient) CreateS3Collection added in v0.11.0

func (rc *RockClient) CreateS3Collection(ctx context.Context,
	workspace, name, description, integration, bucket, pattern string,
	format option.Format, options ...option.CollectionOption) (openapi.Collection, error)

CreateS3Collection creates an S3 collection from an existing S3 integration. Not specifying a format will default to JSON. Deprecated: use CreateCollection() with option.WithS3Source() instead.

func (*RockClient) CreateS3Integration added in v0.11.0

func (rc *RockClient) CreateS3Integration(ctx context.Context, name string, creds option.AWSCredentialsFn,
	options ...option.S3IntegrationOption) (openapi.Integration, error)

func (*RockClient) CreateUser added in v0.12.0

func (rc *RockClient) CreateUser(ctx context.Context, email string, roles []string) (openapi.User, error)

CreateUser creates a new user.

REST API documentation https://docs.rockset.com/rest-api/#createuser

func (*RockClient) CreateView added in v0.14.1

func (rc *RockClient) CreateView(ctx context.Context, workspace, view, query string,
	options ...option.ViewOption) (openapi.View, error)

CreateView creates a new view, with an optional description.

REST API documentation https://docs.rockset.com/rest-api/#createview

func (*RockClient) CreateWorkspace added in v0.9.1

func (rc *RockClient) CreateWorkspace(ctx context.Context, workspace string,
	options ...option.WorkspaceOption) (openapi.Workspace, error)

CreateWorkspace creates a new workspace, with an optional description.

REST API documentation https://docs.rockset.com/rest-api/#createworkspace

func (*RockClient) DeleteAPIKey added in v0.12.0

func (rc *RockClient) DeleteAPIKey(ctx context.Context, keyName string, options ...option.APIKeyOption) error

DeleteAPIKey deletes an API key. An admin can delete an api key for another user with option.ForUser().

REST API documentation https://docs.rockset.com/rest-api/#deleteapikey

func (*RockClient) DeleteAlias added in v0.12.0

func (rc *RockClient) DeleteAlias(ctx context.Context, workspace, alias string) error

DeleteAlias deletes an alias.

REST API documentation https://docs.rockset.com/rest-api/#deletealias

func (*RockClient) DeleteCollection added in v0.11.0

func (rc *RockClient) DeleteCollection(ctx context.Context, workspace, name string) error

DeleteCollection deletes collection.

func (*RockClient) DeleteDocuments added in v0.12.0

func (rc *RockClient) DeleteDocuments(ctx context.Context, workspace, collection string,
	docIDs []string) ([]openapi.DocumentStatus, error)

DeleteDocuments deletes documents from a collection

REST API documentation https://docs.rockset.com/rest-api/#deletedocuments

func (*RockClient) DeleteIntegration added in v0.11.0

func (rc *RockClient) DeleteIntegration(ctx context.Context, name string) error

func (*RockClient) DeleteQueryLambda added in v0.12.4

func (rc *RockClient) DeleteQueryLambda(ctx context.Context, workspace, name string) error

DeleteQueryLambda deletes a query lambda.

https://docs.rockset.com/rest-api/#deletequerylambda

func (*RockClient) DeleteQueryLambdaTag added in v0.12.4

func (rc *RockClient) DeleteQueryLambdaTag(ctx context.Context, workspace, name, tag string) error

DeleteQueryLambdaTag deletes a query lambda tag.

https://docs.rockset.com/rest-api/#deletequerylambdatag

func (*RockClient) DeleteQueryLambdaVersion added in v0.12.4

func (rc *RockClient) DeleteQueryLambdaVersion(ctx context.Context, workspace, name, version string) error

DeleteQueryLambdaVersion deletes a query lambda version.

https://docs.rockset.com/rest-api/#deletequerylambdaversion

func (*RockClient) DeleteRole added in v0.14.3

func (rc *RockClient) DeleteRole(ctx context.Context, roleName string) error

DeleteRole deletes a role.

REST API documentation https://docs.rockset.com/rest-api/#deleterole

func (*RockClient) DeleteUser added in v0.12.0

func (rc *RockClient) DeleteUser(ctx context.Context, email string) error

DeleteUser deletes a user.

REST API documentation https://docs.rockset.com/rest-api/#deleteuser

func (*RockClient) DeleteView added in v0.14.1

func (rc *RockClient) DeleteView(ctx context.Context, workspace, view string) error

DeleteView marks the view for deletion, which will take place in the background. Use the WaitUntilViewGone() call to block until the view has been deleted.

REST API documentation https://docs.rockset.com/rest-api/#deleteview

func (*RockClient) DeleteWorkspace added in v0.9.1

func (rc *RockClient) DeleteWorkspace(ctx context.Context, name string) error

DeleteWorkspace deletes a workspace.

REST API documentation https://docs.rockset.com/rest-api/#deleteworkspace

func (*RockClient) ExecuteQueryLambda added in v0.11.0

func (rc *RockClient) ExecuteQueryLambda(ctx context.Context, workspace, name string,
	options ...option.QueryLambdaOption) (openapi.QueryResponse, error)

ExecuteQueryLambda executes a query lambda with optional query options.

func (*RockClient) GetAPIKey added in v0.12.0

func (rc *RockClient) GetAPIKey(ctx context.Context, name string,
	options ...option.APIKeyOption) (openapi.ApiKey, error)

GetAPIKey gets the named API key. An admin can get an api key for another user with option.ForUser().

REST API documentation https://docs.rockset.com/rest-api/#getapikey

func (*RockClient) GetAlias added in v0.12.0

func (rc *RockClient) GetAlias(ctx context.Context, workspace, alias string) (openapi.Alias, error)

GetAlias gets an alias

REST API documentation https://docs.rockset.com/rest-api/#getalias

func (*RockClient) GetCollection added in v0.11.0

func (rc *RockClient) GetCollection(ctx context.Context, workspace, name string) (openapi.Collection, error)

GetCollection gets information about a collection.

func (*RockClient) GetCurrentUser added in v0.12.0

func (rc *RockClient) GetCurrentUser(ctx context.Context) (openapi.User, error)

GetCurrentUser gets the current user.

REST API documentation https://docs.rockset.com/rest-api/#getcurrentuser

func (*RockClient) GetIntegration added in v0.12.3

func (rc *RockClient) GetIntegration(ctx context.Context, name string) (openapi.Integration, error)

func (*RockClient) GetOrganization added in v0.12.0

func (rc *RockClient) GetOrganization(ctx context.Context) (openapi.Organization, error)

GetOrganization gets the current organization.

func (*RockClient) GetQueryInfo added in v0.15.0

func (rc *RockClient) GetQueryInfo(ctx context.Context, queryID string) (openapi.QueryInfo, error)

GetQueryInfo retrieves information about a query.

func (*RockClient) GetQueryLambdaVersion added in v0.12.3

func (rc *RockClient) GetQueryLambdaVersion(ctx context.Context,
	workspace, name, version string) (openapi.QueryLambdaVersion, error)

GetQueryLambdaVersion get the query lambda information for a specific version.

func (*RockClient) GetQueryLambdaVersionByTag added in v0.12.3

func (rc *RockClient) GetQueryLambdaVersionByTag(ctx context.Context,
	workspace, name, tag string) (openapi.QueryLambdaTag, error)

GetQueryLambdaVersionByTag gets the query lambda version for a tag.

func (*RockClient) GetQueryResults added in v0.15.0

func (rc *RockClient) GetQueryResults(ctx context.Context, queryID string) (openapi.QueryPaginationResponse, error)

GetQueryResults retrieves the results of a completed async query.

func (*RockClient) GetRole added in v0.14.4

func (rc *RockClient) GetRole(ctx context.Context, roleName string) (openapi.Role, error)

GetRole retrieve a role.

REST API documentation https://docs.rockset.com/rest-api/#getrole

func (*RockClient) GetUser added in v0.15.0

func (rc *RockClient) GetUser(ctx context.Context, email string) (openapi.User, error)

GetUser gets a user.

REST API documentation https://docs.rockset.com/rest-api/#getuser

func (*RockClient) GetView added in v0.14.1

func (rc *RockClient) GetView(ctx context.Context, workspace, name string) (openapi.View, error)

GetView gets details about a view.

REST API documentation https://docs.rockset.com/rest-api/#getview

func (*RockClient) GetVirtualInstance added in v0.12.0

func (rc *RockClient) GetVirtualInstance(ctx context.Context, vID string) (openapi.VirtualInstance, error)

GetVirtualInstance gets a virtual instance by the virtual instance uuid.

REST API documentation https://docs.rockset.com/rest-api/#getvirtualinstance

func (*RockClient) GetWorkspace added in v0.9.1

func (rc *RockClient) GetWorkspace(ctx context.Context, workspace string) (openapi.Workspace, error)

GetWorkspace gets a workspace.

REST API documentation https://docs.rockset.com/rest-api/#getworkspace

func (*RockClient) ListAPIKeys added in v0.12.0

func (rc *RockClient) ListAPIKeys(ctx context.Context, options ...option.APIKeyOption) ([]openapi.ApiKey, error)

ListAPIKeys list API keys. An admin can list api keys for another user with option.ForUser().

REST API documentation https://docs.rockset.com/rest-api/#listapikey

func (*RockClient) ListActiveQueries added in v0.15.0

func (rc *RockClient) ListActiveQueries(ctx context.Context) ([]openapi.QueryInfo, error)

ListActiveQueries lists all active queries, i.e. queued or running.

func (*RockClient) ListAliases added in v0.12.0

func (rc *RockClient) ListAliases(ctx context.Context, options ...option.ListAliasesOption) ([]openapi.Alias, error)

ListAliases lists all aliases for the organization, or for a workspace when using the option.WithAliasWorkspace() option.

REST API documentation https://docs.rockset.com/rest-api/#listalias

func (*RockClient) ListCollections added in v0.12.3

func (rc *RockClient) ListCollections(ctx context.Context,
	options ...option.ListCollectionOption) ([]openapi.Collection, error)

ListCollections lists all collections, or in a specific workspace is option.WithWorkspace() is used.

func (*RockClient) ListIntegrations added in v0.12.3

func (rc *RockClient) ListIntegrations(ctx context.Context) ([]openapi.Integration, error)

func (*RockClient) ListQueryLambdaTags added in v0.12.3

func (rc *RockClient) ListQueryLambdaTags(ctx context.Context, workspace,
	queryLambda string) ([]openapi.QueryLambdaTag, error)

ListQueryLambdaTags lists all tags for a query lambda.

func (*RockClient) ListQueryLambdaVersions added in v0.12.3

func (rc *RockClient) ListQueryLambdaVersions(ctx context.Context,
	workspace, name string) ([]openapi.QueryLambdaVersion, error)

ListQueryLambdaVersions lists all versions for a query lambda.

func (*RockClient) ListQueryLambdas added in v0.12.3

func (rc *RockClient) ListQueryLambdas(ctx context.Context,
	options ...option.ListQueryLambdaOption) ([]openapi.QueryLambda, error)

ListQueryLambdas lists all query lambdas, unless the option.WithQueryLambdaWorkspace is used.

https://docs.rockset.com/rest-api/#listallquerylambdas

func (*RockClient) ListRoles added in v0.14.3

func (rc *RockClient) ListRoles(ctx context.Context) ([]openapi.Role, error)

ListRoles list all roles.

REST API documentation https://docs.rockset.com/rest-api/#listroles

func (*RockClient) ListUsers added in v0.12.0

func (rc *RockClient) ListUsers(ctx context.Context) ([]openapi.User, error)

ListUsers lists all users.

REST API documentation https://docs.rockset.com/rest-api/#listusers

func (*RockClient) ListViews added in v0.14.1

func (rc *RockClient) ListViews(ctx context.Context, options ...option.ListViewOption) ([]openapi.View, error)

ListViews list views. Use option.WithViewWorkspace() to limit the request to just one workspace.

REST API documentation https://docs.rockset.com/rest-api/#listviews

func (*RockClient) ListVirtualInstances added in v0.12.0

func (rc *RockClient) ListVirtualInstances(ctx context.Context) ([]openapi.VirtualInstance, error)

ListVirtualInstances lists all virtual instances.

REST API documentation https://docs.rockset.com/rest-api/#listvirtualinstances

func (*RockClient) ListWorkspaces added in v0.9.1

func (rc *RockClient) ListWorkspaces(ctx context.Context) ([]openapi.Workspace, error)

ListWorkspaces list all workspaces.

REST API documentation https://docs.rockset.com/rest-api/#listworkspaces

func (*RockClient) PatchDocuments added in v0.12.0

func (rc *RockClient) PatchDocuments(ctx context.Context, workspace, collection string,
	patches []PatchDocument) ([]openapi.DocumentStatus, error)

PatchDocuments patches (updates) existing documents in a collection. This convenience method does not use the generated client, as it takes values as map[string]interface{} which doesn't work when you want to patch e.g. a top-level boolean value.

REST API documentation https://docs.rockset.com/rest-api/#patchdocuments

func (*RockClient) Ping added in v0.13.0

func (rc *RockClient) Ping(ctx context.Context) error

Ping connects to the Rockset API server and can be used to verify connectivity. It does not require authentication, so to test that use the GetOrganization() method instead.

func (*RockClient) Query

func (rc *RockClient) Query(ctx context.Context, sql string,
	options ...option.QueryOption) (openapi.QueryResponse, error)

Query executes a sql query with optional option.QueryOption

func (*RockClient) UpdateAPIKey added in v0.15.0

func (rc *RockClient) UpdateAPIKey(ctx context.Context, keyName string,
	options ...option.APIKeyOption) (openapi.ApiKey, error)

UpdateAPIKey updates the state of an API key. An admin can update an api key for another user with option.ForUser().

REST API documentation https://rockset.com/docs/rest-api/#updateapikey

func (*RockClient) UpdateAlias added in v0.12.0

func (rc *RockClient) UpdateAlias(ctx context.Context, workspace, alias string, collections []string,
	options ...option.AliasOption) error

UpdateAlias updates an alias

REST API documentation https://docs.rockset.com/rest-api/#updatealias

func (*RockClient) UpdateQueryLambda added in v0.12.4

func (rc *RockClient) UpdateQueryLambda(ctx context.Context, workspace, name, sql string,
	options ...option.CreateQueryLambdaOption) (openapi.QueryLambdaVersion, error)

UpdateQueryLambda updates an existing query lambda.

https://docs.rockset.com/rest-api/#updatequerylambda

func (*RockClient) UpdateRole added in v0.14.3

func (rc *RockClient) UpdateRole(ctx context.Context, roleName string,
	options ...option.RoleOption) (openapi.Role, error)

UpdateRole updates a role.

REST API documentation https://docs.rockset.com/rest-api/#updaterole

func (*RockClient) UpdateUser added in v0.15.1

func (rc *RockClient) UpdateUser(ctx context.Context, email string, roles []string,
	options ...option.UserOption) (openapi.User, error)

UpdateUser updates as existing user. Note that the user first and last name aren't visible for privacy reasons, until the user has accepted the invite, i.e. is in the ACTIVE state.

REST API documentation https://docs.rockset.com/rest-api/#updateuser

func (*RockClient) UpdateView added in v0.14.1

func (rc *RockClient) UpdateView(ctx context.Context, workspace, view, query string,
	options ...option.ViewOption) (openapi.View, error)

UpdateView updates an existing view, with an optional description.

REST API documentation https://docs.rockset.com/rest-api/#updateview

func (*RockClient) UpdateVirtualInstance added in v0.12.0

func (rc *RockClient) UpdateVirtualInstance(ctx context.Context, vID string,
	options ...option.VirtualInstanceOption) (openapi.VirtualInstance, error)

UpdateVirtualInstance updates the properties of a virtual instance.

REST API documentation https://docs.rockset.com/rest-api/#setvirtualinstance

func (*RockClient) ValidateQuery added in v0.11.0

func (rc *RockClient) ValidateQuery(ctx context.Context, sql string,
	options ...option.QueryOption) (openapi.ValidateQueryResponse, error)

ValidateQuery validates a sql query with optional option.QueryOption

func (*RockClient) WaitUntilAliasAvailable added in v0.12.0

func (rc *RockClient) WaitUntilAliasAvailable(ctx context.Context, workspace, alias string) error

WaitUntilAliasAvailable waits until the alias is available.

func (*RockClient) WaitUntilAliasGone added in v0.15.3

func (rc *RockClient) WaitUntilAliasGone(ctx context.Context, workspace, alias string) error

WaitUntilAliasGone waits until the alias is gone.

func (*RockClient) WaitUntilCollectionGone added in v0.12.0

func (rc *RockClient) WaitUntilCollectionGone(ctx context.Context, workspace, name string) error

WaitUntilCollectionGone waits until a collection marked for deletion is gone, i.e. GetCollection() returns "not found".

func (*RockClient) WaitUntilCollectionHasDocuments added in v0.15.1

func (rc *RockClient) WaitUntilCollectionHasDocuments(ctx context.Context, workspace, name string, count int64) error

WaitUntilCollectionHasDocuments waits until the collection has at least count documents

func (*RockClient) WaitUntilCollectionHasNewDocuments added in v0.15.1

func (rc *RockClient) WaitUntilCollectionHasNewDocuments(ctx context.Context, workspace, name string, count int64) error

WaitUntilCollectionHasNewDocuments waits until the collection has at least count new documents (measured from when the method is called).

func (*RockClient) WaitUntilCollectionReady added in v0.12.0

func (rc *RockClient) WaitUntilCollectionReady(ctx context.Context, workspace, name string) error

WaitUntilCollectionReady waits until the collection is ready.

func (*RockClient) WaitUntilKafkaIntegrationActive added in v0.15.0

func (rc *RockClient) WaitUntilKafkaIntegrationActive(ctx context.Context, integration string) error

WaitUntilKafkaIntegrationActive waits until all topics in a Kafka integration are in ACTIVE state.

func (*RockClient) WaitUntilQueryCompleted added in v0.15.1

func (rc *RockClient) WaitUntilQueryCompleted(ctx context.Context, queryID string) error

WaitUntilQueryCompleted waits until queryID has either completed, errored, or been cancelled.

func (*RockClient) WaitUntilViewGone added in v0.14.1

func (rc *RockClient) WaitUntilViewGone(ctx context.Context, workspace, name string) error

WaitUntilViewGone waits until a view marked for deletion is gone, i.e. GetView() returns "not found".

func (*RockClient) WaitUntilWorkspaceAvailable added in v0.15.0

func (rc *RockClient) WaitUntilWorkspaceAvailable(ctx context.Context, workspace string) error

WaitUntilWorkspaceAvailable waits until the workspace is available.

type RockConfig added in v0.12.0

type RockConfig struct {
	// Retrier is the retry function used to retry API calls.
	Retrier
	// APIKey is the API key to use for authentication
	APIKey string
	// APIServer is the API server to connect to
	APIServer string
	// contains filtered or unexported fields
}

RockConfig contains the configurable options for the RockClient.

type RockOption added in v0.8.0

type RockOption func(rc *RockConfig)

RockOption is the type for RockClient options.

func WithAPIKey added in v0.8.0

func WithAPIKey(apiKey string) RockOption

WithAPIKey sets the API key to use

func WithAPIServer added in v0.8.0

func WithAPIServer(server string) RockOption

WithAPIServer sets the API server to connect to, and override the ROCKSET_APISERVER.

func WithHTTPClient added in v0.8.0

func WithHTTPClient(c *http.Client) RockOption

WithHTTPClient sets the HTTP client. Without this option RockClient uses the http.DefaultClient.

func WithHTTPDebug added in v0.12.0

func WithHTTPDebug() RockOption

WithHTTPDebug adds a http.RoundTripper that logs the request and response.

func WithRetry added in v0.12.0

func WithRetry(r Retrier) RockOption

WithRetry sets the Retrier the RockClient uses to retry requests which return a Error that can be retried. The errors which can be retried are configurable using the ExponentialRetry field RetryableErrorCheck.

er := rockset.ExponentialRetry{
	RetryableErrorCheck: func(err error) bool {
		return error.Is(err, io.ErrUnexpectedEOF)
	}
}
rc, err := rockset.NewClient(rockset.WithRetry(er))
//handle error
err = rc.Retry(ctx, func() error{
	// call that will be retried if it returns io.ErrUnexpectedEOF
})

This would retry all io.ErrUnexpectedEOF errors

func WithUserAgent added in v0.15.1

func WithUserAgent(name string) RockOption

WithUserAgent sets the user agent string. Used by the Rockset terraform provider. If not set, it defaults to DefaultUserAgent.

Directories

Path Synopsis
Package option contains optional arguments for rockset.RockClient convenience methods.
Package option contains optional arguments for rockset.RockClient convenience methods.

Jump to

Keyboard shortcuts

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