Documentation
¶
Overview ¶
Package xk6_couchbase implements a k6 extension (k6/x/couchbase) for running load tests against Couchbase clusters.
Index ¶
- type Client
- func (c *Client) Close() error
- func (c *Client) Exists(bucketName string, scope string, collection string, docID string) error
- func (c *Client) Find(query string) (any, error)
- func (c *Client) FindByPreparedStmt(query string, params ...interface{}) (any, error)
- func (c *Client) FindMany(bucketName string, scope string, collection string, keys []string) (map[string]interface{}, error)
- func (c *Client) FindOne(bucketName string, scope string, collection string, docID string) (any, error)
- func (c *Client) Insert(bucketName string, scope string, collection string, docID string, doc any) error
- func (c *Client) InsertBatch(bucketName string, scope string, collection string, docs map[string]any) error
- func (c *Client) Remove(bucketName string, scope string, collection string, docID string) error
- func (c *Client) Upsert(bucketName string, scope string, collection string, docID string, doc any) error
- type CouchBase
- func (c *CouchBase) NewClient(connectionString string, username string, password string) interface{}
- func (c *CouchBase) NewClientPerVU(dbConfig DBConfig, bucketsToWarm []string, bucketReadinessDuration string, ...) (*Client, error)
- func (c *CouchBase) NewClientWithOptions(dbConfig DBConfig, opts options) (*Client, error)
- func (c *CouchBase) NewClientWithSharedConnection(dbConfig DBConfig, bucketsToWarm []string, bucketReadinessDuration string, ...) (*Client, error)
- type DBConfig
- type ModuleInstance
- type RootModule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a connected Couchbase client exposed to JS test scripts. It is returned by the NewClient* constructors and caches per-bucket connections.
func (*Client) FindByPreparedStmt ¶
FindByPreparedStmt executes a N1QL query with positional parameters and returns the last row read.
func (*Client) FindMany ¶ added in v0.0.10
func (c *Client) FindMany(bucketName string, scope string, collection string, keys []string) (map[string]interface{}, error)
FindMany fetches multiple documents by key in a single bulk operation, returning a map of document ID to document. Keys that do not exist (or fail to decode) are omitted from the result.
func (*Client) FindOne ¶
func (c *Client) FindOne(bucketName string, scope string, collection string, docID string) (any, error)
FindOne fetches a single document by ID.
func (*Client) Insert ¶
func (c *Client) Insert(bucketName string, scope string, collection string, docID string, doc any) error
Insert adds a new document, failing if the document ID already exists.
func (*Client) InsertBatch ¶
func (c *Client) InsertBatch(bucketName string, scope string, collection string, docs map[string]any) error
InsertBatch inserts multiple documents (keyed by document ID) in a single bulk operation.
type CouchBase ¶
type CouchBase struct {
// contains filtered or unexported fields
}
CouchBase is the JS-facing API object. Shared state lives on root.
func (*CouchBase) NewClient ¶
func (c *CouchBase) NewClient(connectionString string, username string, password string) interface{}
NewClient returns a client using the default options (shared connection). On success it returns the *Client; on failure it returns an error value to the JS runtime.
func (*CouchBase) NewClientPerVU ¶ added in v0.0.9
func (c *CouchBase) NewClientPerVU(dbConfig DBConfig, bucketsToWarm []string, bucketReadinessDuration string, connectionBufferSizeBytes int) (*Client, error)
NewClientPerVU returns a client that opens a dedicated cluster connection for each VU. Useful for exercising the maximum number of connections a cluster can handle.
func (*CouchBase) NewClientWithOptions ¶ added in v0.0.9
NewClientWithOptions returns a client configured with the given options, optionally pre-warming the requested buckets.
func (*CouchBase) NewClientWithSharedConnection ¶ added in v0.0.9
func (c *CouchBase) NewClientWithSharedConnection(dbConfig DBConfig, bucketsToWarm []string, bucketReadinessDuration string, connectionBufferSizeBytes int) (*Client, error)
NewClientWithSharedConnection returns a client backed by a single cluster connection shared across all VUs, maximizing QPS without exhausting client resources.
type DBConfig ¶ added in v0.0.9
type DBConfig struct {
Hostname string `json:"connection_string,omitempty"`
Username string `json:"-"`
Password string `json:"-"`
}
DBConfig holds the connection details for a Couchbase cluster.
type ModuleInstance ¶ added in v0.0.10
type ModuleInstance struct {
// contains filtered or unexported fields
}
ModuleInstance is created once per VU by k6. Each instance points back to the single RootModule so VUs can share the singleton connection when requested.
func (*ModuleInstance) Exports ¶ added in v0.0.10
func (mi *ModuleInstance) Exports() k6modules.Exports
Exports exposes the CouchBase API object to the JS runtime as the default export, preserving the `import xk6_couchbase from 'k6/x/couchbase'` usage.
type RootModule ¶ added in v0.0.10
type RootModule struct {
// contains filtered or unexported fields
}
RootModule is created once per k6 run. It holds state that is shared across all VUs, namely the lazily-initialized singleton client used in shared connection mode.
func New ¶ added in v0.0.10
func New() *RootModule
New builds the root module. It is registered once in init.
func (*RootModule) NewModuleInstance ¶ added in v0.0.10
func (r *RootModule) NewModuleInstance(vu k6modules.VU) k6modules.Instance
NewModuleInstance is called by k6 for every VU, handing it the shared root.