Skip to content

Commit

Permalink
Merge pull request #6 from mstoykov/useSobek
Browse files Browse the repository at this point in the history
Change to using sobek instead of goja
  • Loading branch information
thotasrinath authored Jun 28, 2024
2 parents 72f688f + 9f1ea31 commit e58ac4d
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 83 deletions.
16 changes: 8 additions & 8 deletions couchbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package xk6_couchbase

import (
"fmt"
"github.com/couchbase/gocb/v2"
k6modules "go.k6.io/k6/js/modules"
"log"
"time"

"github.com/couchbase/gocb/v2"
k6modules "go.k6.io/k6/js/modules"
)

func init() {
Expand All @@ -19,7 +20,6 @@ type Client struct {
}

func (*CouchBase) NewClient(connectionString, username, password string) interface{} {

// For a secure cluster connection, use `couchbases://<your-cluster-ip>` instead.
cluster, err := gocb.Connect("couchbase://"+connectionString, gocb.ClusterOptions{
Authenticator: gocb.PasswordAuthenticator{
Expand All @@ -33,7 +33,6 @@ func (*CouchBase) NewClient(connectionString, username, password string) interfa
}

return &Client{client: cluster}

}

func (c *Client) Insert(bucketName, scope, collection, docId string, doc any) error {
Expand All @@ -59,7 +58,7 @@ func (c *Client) Remove(bucketName, scope, collection, docId string) error {
log.Fatal(err)
return err
}

col := bucket.Scope(scope).Collection(collection)

// Remove with Durability
Expand All @@ -78,7 +77,6 @@ func (c *Client) Remove(bucketName, scope, collection, docId string) error {
}

func (c *Client) InsertBatch(bucketName, scope, collection string, docs map[string]any) error {

batchItems := make([]gocb.BulkOp, len(docs))
index := 0
for k, v := range docs {
Expand Down Expand Up @@ -155,8 +153,10 @@ func (c *Client) FindByPreparedStmt(query string, params ...interface{}) (any, e
var result interface{}
queryResult, err := c.client.Query(
query,
&gocb.QueryOptions{Adhoc: true,
PositionalParameters: params},
&gocb.QueryOptions{
Adhoc: true,
PositionalParameters: params,
},
)
if err != nil {
log.Fatal(err)
Expand Down
45 changes: 32 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,49 @@ go 1.20

require (
github.com/couchbase/gocb/v2 v2.6.3
go.k6.io/k6 v0.43.0
go.k6.io/k6 v0.51.1-0.20240610082146-1f01a9bc2365
)

require (
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/couchbase/gocbcore/v10 v10.2.3 // indirect
github.com/dlclark/regexp2 v1.7.0 // indirect
github.com/dop251/goja v0.0.0-20230128084908-78b980256d04 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/go-sourcemap/sourcemap v2.1.4-0.20211119122758-180fcef48034+incompatible // indirect
github.com/dlclark/regexp2 v1.9.0 // indirect
github.com/dop251/goja v0.0.0-20240516125602-ccbae20bcec2 // indirect
github.com/evanw/esbuild v0.21.2 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-sourcemap/sourcemap v2.1.4+incompatible // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/google/pprof v0.0.0-20230728192033-2ba5b33183c6 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grafana/sobek v0.0.0-20240607083612-4f0cd64f4e78 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mstoykov/atlas v0.0.0-20220808085829-90340e9998bd // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/onsi/gomega v1.26.0 // indirect
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect
github.com/serenize/snaker v0.0.0-20201027110005-a7ad2135616e // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/afero v1.1.2 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/text v0.6.0 // indirect
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/sdk v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.opentelemetry.io/proto/otlp v1.1.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/guregu/null.v3 v3.3.0 // indirect
)
Loading

0 comments on commit e58ac4d

Please sign in to comment.