Documentation ¶
Overview ¶
Example ¶
package main import ( "context" "log" buntdbtrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/tidwall/buntdb" "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" ) func main() { db, err := buntdbtrace.Open(":memory:") if err != nil { log.Fatal(err) } // Create a root span, giving name, server and resource. _, ctx := tracer.StartSpanFromContext(context.Background(), "my-query", tracer.ServiceName("my-db"), tracer.ResourceName("initial-access"), ) // use WithContext to associate the span with the parent db.WithContext(ctx). Update(func(tx *buntdbtrace.Tx) error { _, _, err := tx.Set("key", "value", nil) return err }) db.View(func(tx *buntdbtrace.Tx) error { // you can also use WithContext on the transaction val, err := tx.WithContext(ctx).Get("key") log.Println(val) return err }) }
Output:
Index ¶
- type DB
- type Option
- type Tx
- func (tx *Tx) Ascend(index string, iterator func(key, value string) bool) error
- func (tx *Tx) AscendEqual(index, pivot string, iterator func(key, value string) bool) error
- func (tx *Tx) AscendGreaterOrEqual(index, pivot string, iterator func(key, value string) bool) error
- func (tx *Tx) AscendKeys(pattern string, iterator func(key, value string) bool) error
- func (tx *Tx) AscendLessThan(index, pivot string, iterator func(key, value string) bool) error
- func (tx *Tx) AscendRange(index, greaterOrEqual, lessThan string, iterator func(key, value string) bool) error
- func (tx *Tx) CreateIndex(name, pattern string, less ...func(a, b string) bool) error
- func (tx *Tx) CreateIndexOptions(name, pattern string, opts *buntdb.IndexOptions, ...) error
- func (tx *Tx) CreateSpatialIndex(name, pattern string, rect func(item string) (min, max []float64)) error
- func (tx *Tx) CreateSpatialIndexOptions(name, pattern string, opts *buntdb.IndexOptions, ...) error
- func (tx *Tx) Delete(key string) (val string, err error)
- func (tx *Tx) DeleteAll() error
- func (tx *Tx) Descend(index string, iterator func(key, value string) bool) error
- func (tx *Tx) DescendEqual(index, pivot string, iterator func(key, value string) bool) error
- func (tx *Tx) DescendGreaterThan(index, pivot string, iterator func(key, value string) bool) error
- func (tx *Tx) DescendKeys(pattern string, iterator func(key, value string) bool) error
- func (tx *Tx) DescendLessOrEqual(index, pivot string, iterator func(key, value string) bool) error
- func (tx *Tx) DescendRange(index, lessOrEqual, greaterThan string, iterator func(key, value string) bool) error
- func (tx *Tx) DropIndex(name string) error
- func (tx *Tx) Get(key string, ignoreExpired ...bool) (val string, err error)
- func (tx *Tx) Indexes() ([]string, error)
- func (tx *Tx) Intersects(index, bounds string, iterator func(key, value string) bool) error
- func (tx *Tx) Len() (int, error)
- func (tx *Tx) Nearby(index, bounds string, iterator func(key, value string, dist float64) bool) error
- func (tx *Tx) Set(key, value string, opts *buntdb.SetOptions) (previousValue string, replaced bool, err error)
- func (tx *Tx) TTL(key string) (time.Duration, error)
- func (tx *Tx) WithContext(ctx context.Context) *Tx
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
A DB wraps a buntdb.DB, automatically tracing any transactions.
type Option ¶
type Option func(cfg *config)
An Option customizes the config.
func WithContext ¶
WithContext sets the context for the transaction.
func WithServiceName ¶
WithServiceName sets the given service name for the transaction.
type Tx ¶
A Tx wraps a buntdb.Tx, automatically tracing any queries.
func (*Tx) AscendEqual ¶
AscendEqual calls the underlying Tx.AscendEqual and traces the query.
func (*Tx) AscendGreaterOrEqual ¶
func (tx *Tx) AscendGreaterOrEqual(index, pivot string, iterator func(key, value string) bool) error
AscendGreaterOrEqual calls the underlying Tx.AscendGreaterOrEqual and traces the query.
func (*Tx) AscendKeys ¶
AscendKeys calls the underlying Tx.AscendKeys and traces the query.
func (*Tx) AscendLessThan ¶
AscendLessThan calls the underlying Tx.AscendLessThan and traces the query.
func (*Tx) AscendRange ¶
func (tx *Tx) AscendRange(index, greaterOrEqual, lessThan string, iterator func(key, value string) bool) error
AscendRange calls the underlying Tx.AscendRange and traces the query.
func (*Tx) CreateIndex ¶
CreateIndex calls the underlying Tx.CreateIndex and traces the query.
func (*Tx) CreateIndexOptions ¶
func (tx *Tx) CreateIndexOptions(name, pattern string, opts *buntdb.IndexOptions, less ...func(a, b string) bool) error
CreateIndexOptions calls the underlying Tx.CreateIndexOptions and traces the query.
func (*Tx) CreateSpatialIndex ¶
func (tx *Tx) CreateSpatialIndex(name, pattern string, rect func(item string) (min, max []float64)) error
CreateSpatialIndex calls the underlying Tx.CreateSpatialIndex and traces the query.
func (*Tx) CreateSpatialIndexOptions ¶
func (tx *Tx) CreateSpatialIndexOptions(name, pattern string, opts *buntdb.IndexOptions, rect func(item string) (min, max []float64)) error
CreateSpatialIndexOptions calls the underlying Tx.CreateSpatialIndexOptions and traces the query.
func (*Tx) DescendEqual ¶
DescendEqual calls the underlying Tx.DescendEqual and traces the query.
func (*Tx) DescendGreaterThan ¶
DescendGreaterThan calls the underlying Tx.DescendGreaterThan and traces the query.
func (*Tx) DescendKeys ¶
DescendKeys calls the underlying Tx.DescendKeys and traces the query.
func (*Tx) DescendLessOrEqual ¶
DescendLessOrEqual calls the underlying Tx.DescendLessOrEqual and traces the query.
func (*Tx) DescendRange ¶
func (tx *Tx) DescendRange(index, lessOrEqual, greaterThan string, iterator func(key, value string) bool) error
DescendRange calls the underlying Tx.DescendRange and traces the query.
func (*Tx) Intersects ¶
Intersects calls the underlying Tx.Intersects and traces the query.
func (*Tx) Nearby ¶
func (tx *Tx) Nearby(index, bounds string, iterator func(key, value string, dist float64) bool) error
Nearby calls the underlying Tx.Nearby and traces the query.
func (*Tx) Set ¶
func (tx *Tx) Set(key, value string, opts *buntdb.SetOptions) (previousValue string, replaced bool, err error)
Set calls the underlying Tx.Set and traces the query.