id
int32 0
167k
| repo
stringlengths 5
54
| path
stringlengths 4
155
| func_name
stringlengths 1
118
| original_string
stringlengths 52
85.5k
| language
stringclasses 1
value | code
stringlengths 52
85.5k
| code_tokens
listlengths 21
1.41k
| docstring
stringlengths 6
2.61k
| docstring_tokens
listlengths 3
215
| sha
stringlengths 40
40
| url
stringlengths 85
252
|
---|---|---|---|---|---|---|---|---|---|---|---|
9,500 | rubyist/circuitbreaker | circuitbreaker.go | ThresholdTripFunc | func ThresholdTripFunc(threshold int64) TripFunc {
return func(cb *Breaker) bool {
return cb.Failures() == threshold
}
} | go | func ThresholdTripFunc(threshold int64) TripFunc {
return func(cb *Breaker) bool {
return cb.Failures() == threshold
}
} | [
"func",
"ThresholdTripFunc",
"(",
"threshold",
"int64",
")",
"TripFunc",
"{",
"return",
"func",
"(",
"cb",
"*",
"Breaker",
")",
"bool",
"{",
"return",
"cb",
".",
"Failures",
"(",
")",
"==",
"threshold",
"\n",
"}",
"\n",
"}"
]
| // ThresholdTripFunc returns a TripFunc with that trips whenever
// the failure count meets the threshold. | [
"ThresholdTripFunc",
"returns",
"a",
"TripFunc",
"with",
"that",
"trips",
"whenever",
"the",
"failure",
"count",
"meets",
"the",
"threshold",
"."
]
| 2074adba5ddc7d5f7559448a9c3066573521c5bf | https://github.com/rubyist/circuitbreaker/blob/2074adba5ddc7d5f7559448a9c3066573521c5bf/circuitbreaker.go#L420-L424 |
9,501 | rubyist/circuitbreaker | circuitbreaker.go | ConsecutiveTripFunc | func ConsecutiveTripFunc(threshold int64) TripFunc {
return func(cb *Breaker) bool {
return cb.ConsecFailures() == threshold
}
} | go | func ConsecutiveTripFunc(threshold int64) TripFunc {
return func(cb *Breaker) bool {
return cb.ConsecFailures() == threshold
}
} | [
"func",
"ConsecutiveTripFunc",
"(",
"threshold",
"int64",
")",
"TripFunc",
"{",
"return",
"func",
"(",
"cb",
"*",
"Breaker",
")",
"bool",
"{",
"return",
"cb",
".",
"ConsecFailures",
"(",
")",
"==",
"threshold",
"\n",
"}",
"\n",
"}"
]
| // ConsecutiveTripFunc returns a TripFunc that trips whenever
// the consecutive failure count meets the threshold. | [
"ConsecutiveTripFunc",
"returns",
"a",
"TripFunc",
"that",
"trips",
"whenever",
"the",
"consecutive",
"failure",
"count",
"meets",
"the",
"threshold",
"."
]
| 2074adba5ddc7d5f7559448a9c3066573521c5bf | https://github.com/rubyist/circuitbreaker/blob/2074adba5ddc7d5f7559448a9c3066573521c5bf/circuitbreaker.go#L428-L432 |
9,502 | rubyist/circuitbreaker | panel.go | NewPanel | func NewPanel() *Panel {
return &Panel{
Circuits: make(map[string]*Breaker),
Statter: &noopStatter{},
StatsPrefixf: defaultStatsPrefixf,
lastTripTimes: make(map[string]time.Time)}
} | go | func NewPanel() *Panel {
return &Panel{
Circuits: make(map[string]*Breaker),
Statter: &noopStatter{},
StatsPrefixf: defaultStatsPrefixf,
lastTripTimes: make(map[string]time.Time)}
} | [
"func",
"NewPanel",
"(",
")",
"*",
"Panel",
"{",
"return",
"&",
"Panel",
"{",
"Circuits",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"Breaker",
")",
",",
"Statter",
":",
"&",
"noopStatter",
"{",
"}",
",",
"StatsPrefixf",
":",
"defaultStatsPrefixf",
",",
"lastTripTimes",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"time",
".",
"Time",
")",
"}",
"\n",
"}"
]
| // NewPanel creates a new Panel | [
"NewPanel",
"creates",
"a",
"new",
"Panel"
]
| 2074adba5ddc7d5f7559448a9c3066573521c5bf | https://github.com/rubyist/circuitbreaker/blob/2074adba5ddc7d5f7559448a9c3066573521c5bf/panel.go#L38-L44 |
9,503 | rubyist/circuitbreaker | panel.go | Add | func (p *Panel) Add(name string, cb *Breaker) {
p.panelLock.Lock()
p.Circuits[name] = cb
p.panelLock.Unlock()
events := cb.Subscribe()
go func() {
for event := range events {
for _, receiver := range p.eventReceivers {
receiver <- PanelEvent{name, event}
}
switch event {
case BreakerTripped:
p.breakerTripped(name)
case BreakerReset:
p.breakerReset(name)
case BreakerFail:
p.breakerFail(name)
case BreakerReady:
p.breakerReady(name)
}
}
}()
} | go | func (p *Panel) Add(name string, cb *Breaker) {
p.panelLock.Lock()
p.Circuits[name] = cb
p.panelLock.Unlock()
events := cb.Subscribe()
go func() {
for event := range events {
for _, receiver := range p.eventReceivers {
receiver <- PanelEvent{name, event}
}
switch event {
case BreakerTripped:
p.breakerTripped(name)
case BreakerReset:
p.breakerReset(name)
case BreakerFail:
p.breakerFail(name)
case BreakerReady:
p.breakerReady(name)
}
}
}()
} | [
"func",
"(",
"p",
"*",
"Panel",
")",
"Add",
"(",
"name",
"string",
",",
"cb",
"*",
"Breaker",
")",
"{",
"p",
".",
"panelLock",
".",
"Lock",
"(",
")",
"\n",
"p",
".",
"Circuits",
"[",
"name",
"]",
"=",
"cb",
"\n",
"p",
".",
"panelLock",
".",
"Unlock",
"(",
")",
"\n\n",
"events",
":=",
"cb",
".",
"Subscribe",
"(",
")",
"\n\n",
"go",
"func",
"(",
")",
"{",
"for",
"event",
":=",
"range",
"events",
"{",
"for",
"_",
",",
"receiver",
":=",
"range",
"p",
".",
"eventReceivers",
"{",
"receiver",
"<-",
"PanelEvent",
"{",
"name",
",",
"event",
"}",
"\n",
"}",
"\n",
"switch",
"event",
"{",
"case",
"BreakerTripped",
":",
"p",
".",
"breakerTripped",
"(",
"name",
")",
"\n",
"case",
"BreakerReset",
":",
"p",
".",
"breakerReset",
"(",
"name",
")",
"\n",
"case",
"BreakerFail",
":",
"p",
".",
"breakerFail",
"(",
"name",
")",
"\n",
"case",
"BreakerReady",
":",
"p",
".",
"breakerReady",
"(",
"name",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n",
"}"
]
| // Add sets the name as a reference to the given circuit breaker. | [
"Add",
"sets",
"the",
"name",
"as",
"a",
"reference",
"to",
"the",
"given",
"circuit",
"breaker",
"."
]
| 2074adba5ddc7d5f7559448a9c3066573521c5bf | https://github.com/rubyist/circuitbreaker/blob/2074adba5ddc7d5f7559448a9c3066573521c5bf/panel.go#L47-L71 |
9,504 | rubyist/circuitbreaker | panel.go | Get | func (p *Panel) Get(name string) (*Breaker, bool) {
p.panelLock.RLock()
cb, ok := p.Circuits[name]
p.panelLock.RUnlock()
if ok {
return cb, ok
}
return NewBreaker(), ok
} | go | func (p *Panel) Get(name string) (*Breaker, bool) {
p.panelLock.RLock()
cb, ok := p.Circuits[name]
p.panelLock.RUnlock()
if ok {
return cb, ok
}
return NewBreaker(), ok
} | [
"func",
"(",
"p",
"*",
"Panel",
")",
"Get",
"(",
"name",
"string",
")",
"(",
"*",
"Breaker",
",",
"bool",
")",
"{",
"p",
".",
"panelLock",
".",
"RLock",
"(",
")",
"\n",
"cb",
",",
"ok",
":=",
"p",
".",
"Circuits",
"[",
"name",
"]",
"\n",
"p",
".",
"panelLock",
".",
"RUnlock",
"(",
")",
"\n\n",
"if",
"ok",
"{",
"return",
"cb",
",",
"ok",
"\n",
"}",
"\n\n",
"return",
"NewBreaker",
"(",
")",
",",
"ok",
"\n",
"}"
]
| // Get retrieves a circuit breaker by name. If no circuit breaker exists, it
// returns the NoOp one and sets ok to false. | [
"Get",
"retrieves",
"a",
"circuit",
"breaker",
"by",
"name",
".",
"If",
"no",
"circuit",
"breaker",
"exists",
"it",
"returns",
"the",
"NoOp",
"one",
"and",
"sets",
"ok",
"to",
"false",
"."
]
| 2074adba5ddc7d5f7559448a9c3066573521c5bf | https://github.com/rubyist/circuitbreaker/blob/2074adba5ddc7d5f7559448a9c3066573521c5bf/panel.go#L75-L85 |
9,505 | rubyist/circuitbreaker | panel.go | Subscribe | func (p *Panel) Subscribe() <-chan PanelEvent {
eventReader := make(chan PanelEvent)
output := make(chan PanelEvent, 100)
go func() {
for v := range eventReader {
select {
case output <- v:
default:
<-output
output <- v
}
}
}()
p.eventReceivers = append(p.eventReceivers, eventReader)
return output
} | go | func (p *Panel) Subscribe() <-chan PanelEvent {
eventReader := make(chan PanelEvent)
output := make(chan PanelEvent, 100)
go func() {
for v := range eventReader {
select {
case output <- v:
default:
<-output
output <- v
}
}
}()
p.eventReceivers = append(p.eventReceivers, eventReader)
return output
} | [
"func",
"(",
"p",
"*",
"Panel",
")",
"Subscribe",
"(",
")",
"<-",
"chan",
"PanelEvent",
"{",
"eventReader",
":=",
"make",
"(",
"chan",
"PanelEvent",
")",
"\n",
"output",
":=",
"make",
"(",
"chan",
"PanelEvent",
",",
"100",
")",
"\n\n",
"go",
"func",
"(",
")",
"{",
"for",
"v",
":=",
"range",
"eventReader",
"{",
"select",
"{",
"case",
"output",
"<-",
"v",
":",
"default",
":",
"<-",
"output",
"\n",
"output",
"<-",
"v",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n",
"p",
".",
"eventReceivers",
"=",
"append",
"(",
"p",
".",
"eventReceivers",
",",
"eventReader",
")",
"\n",
"return",
"output",
"\n",
"}"
]
| // Subscribe returns a channel of PanelEvents. Whenever a breaker changes state,
// the PanelEvent will be sent over the channel. See BreakerEvent for the types of events. | [
"Subscribe",
"returns",
"a",
"channel",
"of",
"PanelEvents",
".",
"Whenever",
"a",
"breaker",
"changes",
"state",
"the",
"PanelEvent",
"will",
"be",
"sent",
"over",
"the",
"channel",
".",
"See",
"BreakerEvent",
"for",
"the",
"types",
"of",
"events",
"."
]
| 2074adba5ddc7d5f7559448a9c3066573521c5bf | https://github.com/rubyist/circuitbreaker/blob/2074adba5ddc7d5f7559448a9c3066573521c5bf/panel.go#L89-L105 |
9,506 | rubyist/circuitbreaker | client.go | NewHTTPClient | func NewHTTPClient(timeout time.Duration, threshold int64, client *http.Client) *HTTPClient {
breaker := NewThresholdBreaker(threshold)
return NewHTTPClientWithBreaker(breaker, timeout, client)
} | go | func NewHTTPClient(timeout time.Duration, threshold int64, client *http.Client) *HTTPClient {
breaker := NewThresholdBreaker(threshold)
return NewHTTPClientWithBreaker(breaker, timeout, client)
} | [
"func",
"NewHTTPClient",
"(",
"timeout",
"time",
".",
"Duration",
",",
"threshold",
"int64",
",",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"HTTPClient",
"{",
"breaker",
":=",
"NewThresholdBreaker",
"(",
"threshold",
")",
"\n",
"return",
"NewHTTPClientWithBreaker",
"(",
"breaker",
",",
"timeout",
",",
"client",
")",
"\n",
"}"
]
| // NewHTTPClient provides a circuit breaker wrapper around http.Client.
// It wraps all of the regular http.Client functions. Specifying 0 for timeout will
// give a breaker that does not check for time outs. | [
"NewHTTPClient",
"provides",
"a",
"circuit",
"breaker",
"wrapper",
"around",
"http",
".",
"Client",
".",
"It",
"wraps",
"all",
"of",
"the",
"regular",
"http",
".",
"Client",
"functions",
".",
"Specifying",
"0",
"for",
"timeout",
"will",
"give",
"a",
"breaker",
"that",
"does",
"not",
"check",
"for",
"time",
"outs",
"."
]
| 2074adba5ddc7d5f7559448a9c3066573521c5bf | https://github.com/rubyist/circuitbreaker/blob/2074adba5ddc7d5f7559448a9c3066573521c5bf/client.go#L29-L32 |
9,507 | rubyist/circuitbreaker | client.go | NewHostBasedHTTPClient | func NewHostBasedHTTPClient(timeout time.Duration, threshold int64, client *http.Client) *HTTPClient {
brclient := NewHTTPClient(timeout, threshold, client)
brclient.BreakerLookup = func(c *HTTPClient, val interface{}) *Breaker {
rawURL := val.(string)
parsedURL, err := url.Parse(rawURL)
if err != nil {
breaker, _ := c.Panel.Get(defaultBreakerName)
return breaker
}
host := parsedURL.Host
cb, ok := c.Panel.Get(host)
if !ok {
cb = NewThresholdBreaker(threshold)
c.Panel.Add(host, cb)
}
return cb
}
return brclient
} | go | func NewHostBasedHTTPClient(timeout time.Duration, threshold int64, client *http.Client) *HTTPClient {
brclient := NewHTTPClient(timeout, threshold, client)
brclient.BreakerLookup = func(c *HTTPClient, val interface{}) *Breaker {
rawURL := val.(string)
parsedURL, err := url.Parse(rawURL)
if err != nil {
breaker, _ := c.Panel.Get(defaultBreakerName)
return breaker
}
host := parsedURL.Host
cb, ok := c.Panel.Get(host)
if !ok {
cb = NewThresholdBreaker(threshold)
c.Panel.Add(host, cb)
}
return cb
}
return brclient
} | [
"func",
"NewHostBasedHTTPClient",
"(",
"timeout",
"time",
".",
"Duration",
",",
"threshold",
"int64",
",",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"HTTPClient",
"{",
"brclient",
":=",
"NewHTTPClient",
"(",
"timeout",
",",
"threshold",
",",
"client",
")",
"\n\n",
"brclient",
".",
"BreakerLookup",
"=",
"func",
"(",
"c",
"*",
"HTTPClient",
",",
"val",
"interface",
"{",
"}",
")",
"*",
"Breaker",
"{",
"rawURL",
":=",
"val",
".",
"(",
"string",
")",
"\n",
"parsedURL",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"rawURL",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"breaker",
",",
"_",
":=",
"c",
".",
"Panel",
".",
"Get",
"(",
"defaultBreakerName",
")",
"\n",
"return",
"breaker",
"\n",
"}",
"\n",
"host",
":=",
"parsedURL",
".",
"Host",
"\n\n",
"cb",
",",
"ok",
":=",
"c",
".",
"Panel",
".",
"Get",
"(",
"host",
")",
"\n",
"if",
"!",
"ok",
"{",
"cb",
"=",
"NewThresholdBreaker",
"(",
"threshold",
")",
"\n",
"c",
".",
"Panel",
".",
"Add",
"(",
"host",
",",
"cb",
")",
"\n",
"}",
"\n\n",
"return",
"cb",
"\n",
"}",
"\n\n",
"return",
"brclient",
"\n",
"}"
]
| // NewHostBasedHTTPClient provides a circuit breaker wrapper around http.Client. This
// client will use one circuit breaker per host parsed from the request URL. This allows
// you to use a single HTTPClient for multiple hosts with one host's breaker not affecting
// the other hosts. | [
"NewHostBasedHTTPClient",
"provides",
"a",
"circuit",
"breaker",
"wrapper",
"around",
"http",
".",
"Client",
".",
"This",
"client",
"will",
"use",
"one",
"circuit",
"breaker",
"per",
"host",
"parsed",
"from",
"the",
"request",
"URL",
".",
"This",
"allows",
"you",
"to",
"use",
"a",
"single",
"HTTPClient",
"for",
"multiple",
"hosts",
"with",
"one",
"host",
"s",
"breaker",
"not",
"affecting",
"the",
"other",
"hosts",
"."
]
| 2074adba5ddc7d5f7559448a9c3066573521c5bf | https://github.com/rubyist/circuitbreaker/blob/2074adba5ddc7d5f7559448a9c3066573521c5bf/client.go#L38-L60 |
9,508 | rubyist/circuitbreaker | client.go | NewHTTPClientWithBreaker | func NewHTTPClientWithBreaker(breaker *Breaker, timeout time.Duration, client *http.Client) *HTTPClient {
if client == nil {
client = &http.Client{}
}
panel := NewPanel()
panel.Add(defaultBreakerName, breaker)
brclient := &HTTPClient{Client: client, Panel: panel, timeout: timeout}
brclient.BreakerLookup = func(c *HTTPClient, val interface{}) *Breaker {
cb, _ := c.Panel.Get(defaultBreakerName)
return cb
}
events := breaker.Subscribe()
go func() {
event := <-events
switch event {
case BreakerTripped:
brclient.runBreakerTripped()
case BreakerReset:
brclient.runBreakerReset()
}
}()
return brclient
} | go | func NewHTTPClientWithBreaker(breaker *Breaker, timeout time.Duration, client *http.Client) *HTTPClient {
if client == nil {
client = &http.Client{}
}
panel := NewPanel()
panel.Add(defaultBreakerName, breaker)
brclient := &HTTPClient{Client: client, Panel: panel, timeout: timeout}
brclient.BreakerLookup = func(c *HTTPClient, val interface{}) *Breaker {
cb, _ := c.Panel.Get(defaultBreakerName)
return cb
}
events := breaker.Subscribe()
go func() {
event := <-events
switch event {
case BreakerTripped:
brclient.runBreakerTripped()
case BreakerReset:
brclient.runBreakerReset()
}
}()
return brclient
} | [
"func",
"NewHTTPClientWithBreaker",
"(",
"breaker",
"*",
"Breaker",
",",
"timeout",
"time",
".",
"Duration",
",",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"HTTPClient",
"{",
"if",
"client",
"==",
"nil",
"{",
"client",
"=",
"&",
"http",
".",
"Client",
"{",
"}",
"\n",
"}",
"\n\n",
"panel",
":=",
"NewPanel",
"(",
")",
"\n",
"panel",
".",
"Add",
"(",
"defaultBreakerName",
",",
"breaker",
")",
"\n\n",
"brclient",
":=",
"&",
"HTTPClient",
"{",
"Client",
":",
"client",
",",
"Panel",
":",
"panel",
",",
"timeout",
":",
"timeout",
"}",
"\n",
"brclient",
".",
"BreakerLookup",
"=",
"func",
"(",
"c",
"*",
"HTTPClient",
",",
"val",
"interface",
"{",
"}",
")",
"*",
"Breaker",
"{",
"cb",
",",
"_",
":=",
"c",
".",
"Panel",
".",
"Get",
"(",
"defaultBreakerName",
")",
"\n",
"return",
"cb",
"\n",
"}",
"\n\n",
"events",
":=",
"breaker",
".",
"Subscribe",
"(",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"event",
":=",
"<-",
"events",
"\n",
"switch",
"event",
"{",
"case",
"BreakerTripped",
":",
"brclient",
".",
"runBreakerTripped",
"(",
")",
"\n",
"case",
"BreakerReset",
":",
"brclient",
".",
"runBreakerReset",
"(",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"return",
"brclient",
"\n",
"}"
]
| // NewHTTPClientWithBreaker provides a circuit breaker wrapper around http.Client.
// It wraps all of the regular http.Client functions using the provided Breaker. | [
"NewHTTPClientWithBreaker",
"provides",
"a",
"circuit",
"breaker",
"wrapper",
"around",
"http",
".",
"Client",
".",
"It",
"wraps",
"all",
"of",
"the",
"regular",
"http",
".",
"Client",
"functions",
"using",
"the",
"provided",
"Breaker",
"."
]
| 2074adba5ddc7d5f7559448a9c3066573521c5bf | https://github.com/rubyist/circuitbreaker/blob/2074adba5ddc7d5f7559448a9c3066573521c5bf/client.go#L64-L90 |
9,509 | rubyist/circuitbreaker | window.go | Fail | func (w *window) Fail() {
w.bucketLock.Lock()
b := w.getLatestBucket()
b.Fail()
w.bucketLock.Unlock()
} | go | func (w *window) Fail() {
w.bucketLock.Lock()
b := w.getLatestBucket()
b.Fail()
w.bucketLock.Unlock()
} | [
"func",
"(",
"w",
"*",
"window",
")",
"Fail",
"(",
")",
"{",
"w",
".",
"bucketLock",
".",
"Lock",
"(",
")",
"\n",
"b",
":=",
"w",
".",
"getLatestBucket",
"(",
")",
"\n",
"b",
".",
"Fail",
"(",
")",
"\n",
"w",
".",
"bucketLock",
".",
"Unlock",
"(",
")",
"\n",
"}"
]
| // Fail records a failure in the current bucket. | [
"Fail",
"records",
"a",
"failure",
"in",
"the",
"current",
"bucket",
"."
]
| 2074adba5ddc7d5f7559448a9c3066573521c5bf | https://github.com/rubyist/circuitbreaker/blob/2074adba5ddc7d5f7559448a9c3066573521c5bf/window.go#L76-L81 |
9,510 | rubyist/circuitbreaker | window.go | Success | func (w *window) Success() {
w.bucketLock.Lock()
b := w.getLatestBucket()
b.Success()
w.bucketLock.Unlock()
} | go | func (w *window) Success() {
w.bucketLock.Lock()
b := w.getLatestBucket()
b.Success()
w.bucketLock.Unlock()
} | [
"func",
"(",
"w",
"*",
"window",
")",
"Success",
"(",
")",
"{",
"w",
".",
"bucketLock",
".",
"Lock",
"(",
")",
"\n",
"b",
":=",
"w",
".",
"getLatestBucket",
"(",
")",
"\n",
"b",
".",
"Success",
"(",
")",
"\n",
"w",
".",
"bucketLock",
".",
"Unlock",
"(",
")",
"\n",
"}"
]
| // Success records a success in the current bucket. | [
"Success",
"records",
"a",
"success",
"in",
"the",
"current",
"bucket",
"."
]
| 2074adba5ddc7d5f7559448a9c3066573521c5bf | https://github.com/rubyist/circuitbreaker/blob/2074adba5ddc7d5f7559448a9c3066573521c5bf/window.go#L84-L89 |
9,511 | rubyist/circuitbreaker | window.go | Failures | func (w *window) Failures() int64 {
w.bucketLock.RLock()
var failures int64
w.buckets.Do(func(x interface{}) {
b := x.(*bucket)
failures += b.failure
})
w.bucketLock.RUnlock()
return failures
} | go | func (w *window) Failures() int64 {
w.bucketLock.RLock()
var failures int64
w.buckets.Do(func(x interface{}) {
b := x.(*bucket)
failures += b.failure
})
w.bucketLock.RUnlock()
return failures
} | [
"func",
"(",
"w",
"*",
"window",
")",
"Failures",
"(",
")",
"int64",
"{",
"w",
".",
"bucketLock",
".",
"RLock",
"(",
")",
"\n\n",
"var",
"failures",
"int64",
"\n",
"w",
".",
"buckets",
".",
"Do",
"(",
"func",
"(",
"x",
"interface",
"{",
"}",
")",
"{",
"b",
":=",
"x",
".",
"(",
"*",
"bucket",
")",
"\n",
"failures",
"+=",
"b",
".",
"failure",
"\n",
"}",
")",
"\n\n",
"w",
".",
"bucketLock",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"failures",
"\n",
"}"
]
| // Failures returns the total number of failures recorded in all buckets. | [
"Failures",
"returns",
"the",
"total",
"number",
"of",
"failures",
"recorded",
"in",
"all",
"buckets",
"."
]
| 2074adba5ddc7d5f7559448a9c3066573521c5bf | https://github.com/rubyist/circuitbreaker/blob/2074adba5ddc7d5f7559448a9c3066573521c5bf/window.go#L92-L103 |
9,512 | rubyist/circuitbreaker | window.go | Successes | func (w *window) Successes() int64 {
w.bucketLock.RLock()
var successes int64
w.buckets.Do(func(x interface{}) {
b := x.(*bucket)
successes += b.success
})
w.bucketLock.RUnlock()
return successes
} | go | func (w *window) Successes() int64 {
w.bucketLock.RLock()
var successes int64
w.buckets.Do(func(x interface{}) {
b := x.(*bucket)
successes += b.success
})
w.bucketLock.RUnlock()
return successes
} | [
"func",
"(",
"w",
"*",
"window",
")",
"Successes",
"(",
")",
"int64",
"{",
"w",
".",
"bucketLock",
".",
"RLock",
"(",
")",
"\n\n",
"var",
"successes",
"int64",
"\n",
"w",
".",
"buckets",
".",
"Do",
"(",
"func",
"(",
"x",
"interface",
"{",
"}",
")",
"{",
"b",
":=",
"x",
".",
"(",
"*",
"bucket",
")",
"\n",
"successes",
"+=",
"b",
".",
"success",
"\n",
"}",
")",
"\n",
"w",
".",
"bucketLock",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"successes",
"\n",
"}"
]
| // Successes returns the total number of successes recorded in all buckets. | [
"Successes",
"returns",
"the",
"total",
"number",
"of",
"successes",
"recorded",
"in",
"all",
"buckets",
"."
]
| 2074adba5ddc7d5f7559448a9c3066573521c5bf | https://github.com/rubyist/circuitbreaker/blob/2074adba5ddc7d5f7559448a9c3066573521c5bf/window.go#L106-L116 |
9,513 | rubyist/circuitbreaker | window.go | Reset | func (w *window) Reset() {
w.bucketLock.Lock()
w.buckets.Do(func(x interface{}) {
x.(*bucket).Reset()
})
w.bucketLock.Unlock()
} | go | func (w *window) Reset() {
w.bucketLock.Lock()
w.buckets.Do(func(x interface{}) {
x.(*bucket).Reset()
})
w.bucketLock.Unlock()
} | [
"func",
"(",
"w",
"*",
"window",
")",
"Reset",
"(",
")",
"{",
"w",
".",
"bucketLock",
".",
"Lock",
"(",
")",
"\n\n",
"w",
".",
"buckets",
".",
"Do",
"(",
"func",
"(",
"x",
"interface",
"{",
"}",
")",
"{",
"x",
".",
"(",
"*",
"bucket",
")",
".",
"Reset",
"(",
")",
"\n",
"}",
")",
"\n",
"w",
".",
"bucketLock",
".",
"Unlock",
"(",
")",
"\n",
"}"
]
| // Reset resets the count of all buckets. | [
"Reset",
"resets",
"the",
"count",
"of",
"all",
"buckets",
"."
]
| 2074adba5ddc7d5f7559448a9c3066573521c5bf | https://github.com/rubyist/circuitbreaker/blob/2074adba5ddc7d5f7559448a9c3066573521c5bf/window.go#L140-L147 |
9,514 | couchbase/gocb | token.go | NewMutationState | func NewMutationState(tokens ...MutationToken) *MutationState {
mt := &MutationState{}
mt.Add(tokens...)
return mt
} | go | func NewMutationState(tokens ...MutationToken) *MutationState {
mt := &MutationState{}
mt.Add(tokens...)
return mt
} | [
"func",
"NewMutationState",
"(",
"tokens",
"...",
"MutationToken",
")",
"*",
"MutationState",
"{",
"mt",
":=",
"&",
"MutationState",
"{",
"}",
"\n",
"mt",
".",
"Add",
"(",
"tokens",
"...",
")",
"\n",
"return",
"mt",
"\n",
"}"
]
| // NewMutationState creates a new MutationState for tracking mutation state. | [
"NewMutationState",
"creates",
"a",
"new",
"MutationState",
"for",
"tracking",
"mutation",
"state",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/token.go#L40-L44 |
9,515 | couchbase/gocb | token.go | Add | func (mt *MutationState) Add(tokens ...MutationToken) {
for _, v := range tokens {
mt.addSingle(v)
}
} | go | func (mt *MutationState) Add(tokens ...MutationToken) {
for _, v := range tokens {
mt.addSingle(v)
}
} | [
"func",
"(",
"mt",
"*",
"MutationState",
")",
"Add",
"(",
"tokens",
"...",
"MutationToken",
")",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"tokens",
"{",
"mt",
".",
"addSingle",
"(",
"v",
")",
"\n",
"}",
"\n",
"}"
]
| // Add includes an operation's mutation information in this mutation state. | [
"Add",
"includes",
"an",
"operation",
"s",
"mutation",
"information",
"in",
"this",
"mutation",
"state",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/token.go#L74-L78 |
9,516 | couchbase/gocb | token.go | UnmarshalJSON | func (mt *MutationState) UnmarshalJSON(data []byte) error {
return json.Unmarshal(data, &mt.data)
} | go | func (mt *MutationState) UnmarshalJSON(data []byte) error {
return json.Unmarshal(data, &mt.data)
} | [
"func",
"(",
"mt",
"*",
"MutationState",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"return",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"mt",
".",
"data",
")",
"\n",
"}"
]
| // UnmarshalJSON unmarshal's a mutation state from JSON. | [
"UnmarshalJSON",
"unmarshal",
"s",
"a",
"mutation",
"state",
"from",
"JSON",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/token.go#L86-L88 |
9,517 | couchbase/gocb | analyticsquery_deferred.go | One | func (r *AnalyticsDeferredResultHandle) One(valuePtr interface{}) error {
if !r.Next(valuePtr) {
err := r.Close()
if err != nil {
return err
}
// return ErrNoResults
}
// Ignore any errors occurring after we already have our result
err := r.Close()
if err != nil {
// Return no error as we got the one result already.
return nil
}
return nil
} | go | func (r *AnalyticsDeferredResultHandle) One(valuePtr interface{}) error {
if !r.Next(valuePtr) {
err := r.Close()
if err != nil {
return err
}
// return ErrNoResults
}
// Ignore any errors occurring after we already have our result
err := r.Close()
if err != nil {
// Return no error as we got the one result already.
return nil
}
return nil
} | [
"func",
"(",
"r",
"*",
"AnalyticsDeferredResultHandle",
")",
"One",
"(",
"valuePtr",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"!",
"r",
".",
"Next",
"(",
"valuePtr",
")",
"{",
"err",
":=",
"r",
".",
"Close",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"// return ErrNoResults",
"}",
"\n\n",
"// Ignore any errors occurring after we already have our result",
"err",
":=",
"r",
".",
"Close",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// Return no error as we got the one result already.",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // One assigns the first value from the results into the value pointer. | [
"One",
"assigns",
"the",
"first",
"value",
"from",
"the",
"results",
"into",
"the",
"value",
"pointer",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/analyticsquery_deferred.go#L130-L147 |
9,518 | couchbase/gocb | searchquery_sorting.go | NewSearchSortField | func NewSearchSortField(field string) *SearchSortField {
q := &SearchSortField{newFtsSortBase()}
q.options["by"] = "field"
q.options["field"] = field
return q
} | go | func NewSearchSortField(field string) *SearchSortField {
q := &SearchSortField{newFtsSortBase()}
q.options["by"] = "field"
q.options["field"] = field
return q
} | [
"func",
"NewSearchSortField",
"(",
"field",
"string",
")",
"*",
"SearchSortField",
"{",
"q",
":=",
"&",
"SearchSortField",
"{",
"newFtsSortBase",
"(",
")",
"}",
"\n",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"\"",
"\"",
"\n",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"field",
"\n",
"return",
"q",
"\n",
"}"
]
| // NewSearchSortField creates a new SearchSortField. | [
"NewSearchSortField",
"creates",
"a",
"new",
"SearchSortField",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery_sorting.go#L68-L73 |
9,519 | couchbase/gocb | searchquery_sorting.go | Type | func (q *SearchSortField) Type(value string) *SearchSortField {
q.options["type"] = value
return q
} | go | func (q *SearchSortField) Type(value string) *SearchSortField {
q.options["type"] = value
return q
} | [
"func",
"(",
"q",
"*",
"SearchSortField",
")",
"Type",
"(",
"value",
"string",
")",
"*",
"SearchSortField",
"{",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"value",
"\n",
"return",
"q",
"\n",
"}"
]
| // Type allows you to specify the FTS field sort type. | [
"Type",
"allows",
"you",
"to",
"specify",
"the",
"FTS",
"field",
"sort",
"type",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery_sorting.go#L76-L79 |
9,520 | couchbase/gocb | searchquery_sorting.go | Mode | func (q *SearchSortField) Mode(mode string) *SearchSortField {
q.options["mode"] = mode
return q
} | go | func (q *SearchSortField) Mode(mode string) *SearchSortField {
q.options["mode"] = mode
return q
} | [
"func",
"(",
"q",
"*",
"SearchSortField",
")",
"Mode",
"(",
"mode",
"string",
")",
"*",
"SearchSortField",
"{",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"mode",
"\n",
"return",
"q",
"\n",
"}"
]
| // Mode allows you to specify the FTS field sort mode. | [
"Mode",
"allows",
"you",
"to",
"specify",
"the",
"FTS",
"field",
"sort",
"mode",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery_sorting.go#L82-L85 |
9,521 | couchbase/gocb | searchquery_sorting.go | Missing | func (q *SearchSortField) Missing(missing string) *SearchSortField {
q.options["missing"] = missing
return q
} | go | func (q *SearchSortField) Missing(missing string) *SearchSortField {
q.options["missing"] = missing
return q
} | [
"func",
"(",
"q",
"*",
"SearchSortField",
")",
"Missing",
"(",
"missing",
"string",
")",
"*",
"SearchSortField",
"{",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"missing",
"\n",
"return",
"q",
"\n",
"}"
]
| // Missing allows you to specify the FTS field sort missing behaviour. | [
"Missing",
"allows",
"you",
"to",
"specify",
"the",
"FTS",
"field",
"sort",
"missing",
"behaviour",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery_sorting.go#L88-L91 |
9,522 | couchbase/gocb | searchquery_sorting.go | NewSearchSortGeoDistance | func NewSearchSortGeoDistance(field string, lat, lon float64) *SearchSortGeoDistance {
q := &SearchSortGeoDistance{newFtsSortBase()}
q.options["by"] = "geo_distance"
q.options["field"] = field
q.options["location"] = []float64{lon, lat}
return q
} | go | func NewSearchSortGeoDistance(field string, lat, lon float64) *SearchSortGeoDistance {
q := &SearchSortGeoDistance{newFtsSortBase()}
q.options["by"] = "geo_distance"
q.options["field"] = field
q.options["location"] = []float64{lon, lat}
return q
} | [
"func",
"NewSearchSortGeoDistance",
"(",
"field",
"string",
",",
"lat",
",",
"lon",
"float64",
")",
"*",
"SearchSortGeoDistance",
"{",
"q",
":=",
"&",
"SearchSortGeoDistance",
"{",
"newFtsSortBase",
"(",
")",
"}",
"\n",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"\"",
"\"",
"\n",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"field",
"\n",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"[",
"]",
"float64",
"{",
"lon",
",",
"lat",
"}",
"\n",
"return",
"q",
"\n",
"}"
]
| // NewSearchSortGeoDistance creates a new SearchSortGeoDistance. | [
"NewSearchSortGeoDistance",
"creates",
"a",
"new",
"SearchSortGeoDistance",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery_sorting.go#L105-L111 |
9,523 | couchbase/gocb | searchquery_sorting.go | Unit | func (q *SearchSortGeoDistance) Unit(unit string) *SearchSortGeoDistance {
q.options["unit"] = unit
return q
} | go | func (q *SearchSortGeoDistance) Unit(unit string) *SearchSortGeoDistance {
q.options["unit"] = unit
return q
} | [
"func",
"(",
"q",
"*",
"SearchSortGeoDistance",
")",
"Unit",
"(",
"unit",
"string",
")",
"*",
"SearchSortGeoDistance",
"{",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"unit",
"\n",
"return",
"q",
"\n",
"}"
]
| // Unit specifies the unit used for sorting | [
"Unit",
"specifies",
"the",
"unit",
"used",
"for",
"sorting"
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery_sorting.go#L114-L117 |
9,524 | couchbase/gocb | cluster.go | Close | func (c *Cluster) Close(opts *ClusterCloseOptions) error {
var overallErr error
c.clusterLock.Lock()
for key, conn := range c.connections {
err := conn.close()
if err != nil && gocbcore.ErrorCause(err) != gocbcore.ErrShutdown {
logWarnf("Failed to close a client in cluster close: %s", err)
overallErr = err
}
delete(c.connections, key)
}
c.clusterLock.Unlock()
return overallErr
} | go | func (c *Cluster) Close(opts *ClusterCloseOptions) error {
var overallErr error
c.clusterLock.Lock()
for key, conn := range c.connections {
err := conn.close()
if err != nil && gocbcore.ErrorCause(err) != gocbcore.ErrShutdown {
logWarnf("Failed to close a client in cluster close: %s", err)
overallErr = err
}
delete(c.connections, key)
}
c.clusterLock.Unlock()
return overallErr
} | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"Close",
"(",
"opts",
"*",
"ClusterCloseOptions",
")",
"error",
"{",
"var",
"overallErr",
"error",
"\n\n",
"c",
".",
"clusterLock",
".",
"Lock",
"(",
")",
"\n",
"for",
"key",
",",
"conn",
":=",
"range",
"c",
".",
"connections",
"{",
"err",
":=",
"conn",
".",
"close",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"&&",
"gocbcore",
".",
"ErrorCause",
"(",
"err",
")",
"!=",
"gocbcore",
".",
"ErrShutdown",
"{",
"logWarnf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"overallErr",
"=",
"err",
"\n",
"}",
"\n\n",
"delete",
"(",
"c",
".",
"connections",
",",
"key",
")",
"\n",
"}",
"\n",
"c",
".",
"clusterLock",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"overallErr",
"\n",
"}"
]
| // Close shuts down all buckets in this cluster and invalidates any references this cluster has. | [
"Close",
"shuts",
"down",
"all",
"buckets",
"in",
"this",
"cluster",
"and",
"invalidates",
"any",
"references",
"this",
"cluster",
"has",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/cluster.go#L234-L250 |
9,525 | couchbase/gocb | searchquery.go | NewMatchPhraseQuery | func NewMatchPhraseQuery(phrase string) *MatchPhraseQuery {
q := &MatchPhraseQuery{newFtsQueryBase()}
q.options["match_phrase"] = phrase
return q
} | go | func NewMatchPhraseQuery(phrase string) *MatchPhraseQuery {
q := &MatchPhraseQuery{newFtsQueryBase()}
q.options["match_phrase"] = phrase
return q
} | [
"func",
"NewMatchPhraseQuery",
"(",
"phrase",
"string",
")",
"*",
"MatchPhraseQuery",
"{",
"q",
":=",
"&",
"MatchPhraseQuery",
"{",
"newFtsQueryBase",
"(",
")",
"}",
"\n",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"phrase",
"\n",
"return",
"q",
"\n",
"}"
]
| // NewMatchPhraseQuery creates a new MatchPhraseQuery | [
"NewMatchPhraseQuery",
"creates",
"a",
"new",
"MatchPhraseQuery"
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery.go#L72-L76 |
9,526 | couchbase/gocb | searchquery.go | NewRegexpQuery | func NewRegexpQuery(regexp string) *RegexpQuery {
q := &RegexpQuery{newFtsQueryBase()}
q.options["regexp"] = regexp
return q
} | go | func NewRegexpQuery(regexp string) *RegexpQuery {
q := &RegexpQuery{newFtsQueryBase()}
q.options["regexp"] = regexp
return q
} | [
"func",
"NewRegexpQuery",
"(",
"regexp",
"string",
")",
"*",
"RegexpQuery",
"{",
"q",
":=",
"&",
"RegexpQuery",
"{",
"newFtsQueryBase",
"(",
")",
"}",
"\n",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"regexp",
"\n",
"return",
"q",
"\n",
"}"
]
| // NewRegexpQuery creates a new RegexpQuery. | [
"NewRegexpQuery",
"creates",
"a",
"new",
"RegexpQuery",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery.go#L102-L106 |
9,527 | couchbase/gocb | searchquery.go | NewQueryStringQuery | func NewQueryStringQuery(query string) *QueryStringQuery {
q := &QueryStringQuery{newFtsQueryBase()}
q.options["query"] = query
return q
} | go | func NewQueryStringQuery(query string) *QueryStringQuery {
q := &QueryStringQuery{newFtsQueryBase()}
q.options["query"] = query
return q
} | [
"func",
"NewQueryStringQuery",
"(",
"query",
"string",
")",
"*",
"QueryStringQuery",
"{",
"q",
":=",
"&",
"QueryStringQuery",
"{",
"newFtsQueryBase",
"(",
")",
"}",
"\n",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"query",
"\n",
"return",
"q",
"\n",
"}"
]
| // NewQueryStringQuery creates a new StringQuery. | [
"NewQueryStringQuery",
"creates",
"a",
"new",
"StringQuery",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery.go#L126-L130 |
9,528 | couchbase/gocb | searchquery.go | Start | func (q *DateRangeQuery) Start(start string, inclusive bool) *DateRangeQuery {
q.options["start"] = start
q.options["inclusive_start"] = inclusive
return q
} | go | func (q *DateRangeQuery) Start(start string, inclusive bool) *DateRangeQuery {
q.options["start"] = start
q.options["inclusive_start"] = inclusive
return q
} | [
"func",
"(",
"q",
"*",
"DateRangeQuery",
")",
"Start",
"(",
"start",
"string",
",",
"inclusive",
"bool",
")",
"*",
"DateRangeQuery",
"{",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"start",
"\n",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"inclusive",
"\n",
"return",
"q",
"\n",
"}"
]
| // Start specifies the start value and inclusiveness for this range query. | [
"Start",
"specifies",
"the",
"start",
"value",
"and",
"inclusiveness",
"for",
"this",
"range",
"query",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery.go#L187-L191 |
9,529 | couchbase/gocb | searchquery.go | End | func (q *DateRangeQuery) End(end string, inclusive bool) *DateRangeQuery {
q.options["end"] = end
q.options["inclusive_end"] = inclusive
return q
} | go | func (q *DateRangeQuery) End(end string, inclusive bool) *DateRangeQuery {
q.options["end"] = end
q.options["inclusive_end"] = inclusive
return q
} | [
"func",
"(",
"q",
"*",
"DateRangeQuery",
")",
"End",
"(",
"end",
"string",
",",
"inclusive",
"bool",
")",
"*",
"DateRangeQuery",
"{",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"end",
"\n",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"inclusive",
"\n",
"return",
"q",
"\n",
"}"
]
| // End specifies the end value and inclusiveness for this range query. | [
"End",
"specifies",
"the",
"end",
"value",
"and",
"inclusiveness",
"for",
"this",
"range",
"query",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery.go#L194-L198 |
9,530 | couchbase/gocb | searchquery.go | DateTimeParser | func (q *DateRangeQuery) DateTimeParser(parser string) *DateRangeQuery {
q.options["datetime_parser"] = parser
return q
} | go | func (q *DateRangeQuery) DateTimeParser(parser string) *DateRangeQuery {
q.options["datetime_parser"] = parser
return q
} | [
"func",
"(",
"q",
"*",
"DateRangeQuery",
")",
"DateTimeParser",
"(",
"parser",
"string",
")",
"*",
"DateRangeQuery",
"{",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"parser",
"\n",
"return",
"q",
"\n",
"}"
]
| // DateTimeParser specifies which date time string parser to use. | [
"DateTimeParser",
"specifies",
"which",
"date",
"time",
"string",
"parser",
"to",
"use",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery.go#L201-L204 |
9,531 | couchbase/gocb | searchquery.go | NewConjunctionQuery | func NewConjunctionQuery(queries ...FtsQuery) *ConjunctionQuery {
q := &ConjunctionQuery{newFtsQueryBase()}
q.options["conjuncts"] = []FtsQuery{}
return q.And(queries...)
} | go | func NewConjunctionQuery(queries ...FtsQuery) *ConjunctionQuery {
q := &ConjunctionQuery{newFtsQueryBase()}
q.options["conjuncts"] = []FtsQuery{}
return q.And(queries...)
} | [
"func",
"NewConjunctionQuery",
"(",
"queries",
"...",
"FtsQuery",
")",
"*",
"ConjunctionQuery",
"{",
"q",
":=",
"&",
"ConjunctionQuery",
"{",
"newFtsQueryBase",
"(",
")",
"}",
"\n",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"[",
"]",
"FtsQuery",
"{",
"}",
"\n",
"return",
"q",
".",
"And",
"(",
"queries",
"...",
")",
"\n",
"}"
]
| // NewConjunctionQuery creates a new ConjunctionQuery. | [
"NewConjunctionQuery",
"creates",
"a",
"new",
"ConjunctionQuery",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery.go#L224-L228 |
9,532 | couchbase/gocb | searchquery.go | And | func (q *ConjunctionQuery) And(queries ...FtsQuery) *ConjunctionQuery {
q.options["conjuncts"] = append(q.options["conjuncts"].([]FtsQuery), queries...)
return q
} | go | func (q *ConjunctionQuery) And(queries ...FtsQuery) *ConjunctionQuery {
q.options["conjuncts"] = append(q.options["conjuncts"].([]FtsQuery), queries...)
return q
} | [
"func",
"(",
"q",
"*",
"ConjunctionQuery",
")",
"And",
"(",
"queries",
"...",
"FtsQuery",
")",
"*",
"ConjunctionQuery",
"{",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"append",
"(",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
".",
"(",
"[",
"]",
"FtsQuery",
")",
",",
"queries",
"...",
")",
"\n",
"return",
"q",
"\n",
"}"
]
| // And adds new predicate queries to this conjunction query. | [
"And",
"adds",
"new",
"predicate",
"queries",
"to",
"this",
"conjunction",
"query",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery.go#L231-L234 |
9,533 | couchbase/gocb | searchquery.go | NewDisjunctionQuery | func NewDisjunctionQuery(queries ...FtsQuery) *DisjunctionQuery {
q := &DisjunctionQuery{newFtsQueryBase()}
q.options["disjuncts"] = []FtsQuery{}
return q.Or(queries...)
} | go | func NewDisjunctionQuery(queries ...FtsQuery) *DisjunctionQuery {
q := &DisjunctionQuery{newFtsQueryBase()}
q.options["disjuncts"] = []FtsQuery{}
return q.Or(queries...)
} | [
"func",
"NewDisjunctionQuery",
"(",
"queries",
"...",
"FtsQuery",
")",
"*",
"DisjunctionQuery",
"{",
"q",
":=",
"&",
"DisjunctionQuery",
"{",
"newFtsQueryBase",
"(",
")",
"}",
"\n",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"[",
"]",
"FtsQuery",
"{",
"}",
"\n",
"return",
"q",
".",
"Or",
"(",
"queries",
"...",
")",
"\n",
"}"
]
| // NewDisjunctionQuery creates a new DisjunctionQuery. | [
"NewDisjunctionQuery",
"creates",
"a",
"new",
"DisjunctionQuery",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery.go#L248-L252 |
9,534 | couchbase/gocb | searchquery.go | Or | func (q *DisjunctionQuery) Or(queries ...FtsQuery) *DisjunctionQuery {
q.options["disjuncts"] = append(q.options["disjuncts"].([]FtsQuery), queries...)
return q
} | go | func (q *DisjunctionQuery) Or(queries ...FtsQuery) *DisjunctionQuery {
q.options["disjuncts"] = append(q.options["disjuncts"].([]FtsQuery), queries...)
return q
} | [
"func",
"(",
"q",
"*",
"DisjunctionQuery",
")",
"Or",
"(",
"queries",
"...",
"FtsQuery",
")",
"*",
"DisjunctionQuery",
"{",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"append",
"(",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
".",
"(",
"[",
"]",
"FtsQuery",
")",
",",
"queries",
"...",
")",
"\n",
"return",
"q",
"\n",
"}"
]
| // Or adds new predicate queries to this disjunction query. | [
"Or",
"adds",
"new",
"predicate",
"queries",
"to",
"this",
"disjunction",
"query",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery.go#L255-L258 |
9,535 | couchbase/gocb | searchquery.go | Must | func (q *BooleanQuery) Must(query FtsQuery) *BooleanQuery {
switch val := query.(type) {
case ConjunctionQuery:
q.data.Must = &val
case *ConjunctionQuery:
q.data.Must = val
default:
q.data.Must = NewConjunctionQuery(val)
}
return q
} | go | func (q *BooleanQuery) Must(query FtsQuery) *BooleanQuery {
switch val := query.(type) {
case ConjunctionQuery:
q.data.Must = &val
case *ConjunctionQuery:
q.data.Must = val
default:
q.data.Must = NewConjunctionQuery(val)
}
return q
} | [
"func",
"(",
"q",
"*",
"BooleanQuery",
")",
"Must",
"(",
"query",
"FtsQuery",
")",
"*",
"BooleanQuery",
"{",
"switch",
"val",
":=",
"query",
".",
"(",
"type",
")",
"{",
"case",
"ConjunctionQuery",
":",
"q",
".",
"data",
".",
"Must",
"=",
"&",
"val",
"\n",
"case",
"*",
"ConjunctionQuery",
":",
"q",
".",
"data",
".",
"Must",
"=",
"val",
"\n",
"default",
":",
"q",
".",
"data",
".",
"Must",
"=",
"NewConjunctionQuery",
"(",
"val",
")",
"\n",
"}",
"\n",
"return",
"q",
"\n",
"}"
]
| // Must specifies a query which must match. | [
"Must",
"specifies",
"a",
"query",
"which",
"must",
"match",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery.go#L286-L296 |
9,536 | couchbase/gocb | searchquery.go | MustNot | func (q *BooleanQuery) MustNot(query FtsQuery) *BooleanQuery {
switch val := query.(type) {
case DisjunctionQuery:
q.data.MustNot = &val
case *DisjunctionQuery:
q.data.MustNot = val
default:
q.data.MustNot = NewDisjunctionQuery(val)
}
return q
} | go | func (q *BooleanQuery) MustNot(query FtsQuery) *BooleanQuery {
switch val := query.(type) {
case DisjunctionQuery:
q.data.MustNot = &val
case *DisjunctionQuery:
q.data.MustNot = val
default:
q.data.MustNot = NewDisjunctionQuery(val)
}
return q
} | [
"func",
"(",
"q",
"*",
"BooleanQuery",
")",
"MustNot",
"(",
"query",
"FtsQuery",
")",
"*",
"BooleanQuery",
"{",
"switch",
"val",
":=",
"query",
".",
"(",
"type",
")",
"{",
"case",
"DisjunctionQuery",
":",
"q",
".",
"data",
".",
"MustNot",
"=",
"&",
"val",
"\n",
"case",
"*",
"DisjunctionQuery",
":",
"q",
".",
"data",
".",
"MustNot",
"=",
"val",
"\n",
"default",
":",
"q",
".",
"data",
".",
"MustNot",
"=",
"NewDisjunctionQuery",
"(",
"val",
")",
"\n",
"}",
"\n",
"return",
"q",
"\n",
"}"
]
| // MustNot specifies a query which must not match. | [
"MustNot",
"specifies",
"a",
"query",
"which",
"must",
"not",
"match",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery.go#L312-L322 |
9,537 | couchbase/gocb | searchquery.go | ShouldMin | func (q *BooleanQuery) ShouldMin(min int) *BooleanQuery {
q.shouldMin = min
return q
} | go | func (q *BooleanQuery) ShouldMin(min int) *BooleanQuery {
q.shouldMin = min
return q
} | [
"func",
"(",
"q",
"*",
"BooleanQuery",
")",
"ShouldMin",
"(",
"min",
"int",
")",
"*",
"BooleanQuery",
"{",
"q",
".",
"shouldMin",
"=",
"min",
"\n",
"return",
"q",
"\n",
"}"
]
| // ShouldMin specifies the minimum value before the should query will boost. | [
"ShouldMin",
"specifies",
"the",
"minimum",
"value",
"before",
"the",
"should",
"query",
"will",
"boost",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery.go#L325-L328 |
9,538 | couchbase/gocb | searchquery.go | MarshalJSON | func (q *BooleanQuery) MarshalJSON() ([]byte, error) {
if q.data.Should != nil {
q.data.Should.options["min"] = q.shouldMin
}
bytes, err := json.Marshal(q.data)
if q.data.Should != nil {
delete(q.data.Should.options, "min")
}
return bytes, err
} | go | func (q *BooleanQuery) MarshalJSON() ([]byte, error) {
if q.data.Should != nil {
q.data.Should.options["min"] = q.shouldMin
}
bytes, err := json.Marshal(q.data)
if q.data.Should != nil {
delete(q.data.Should.options, "min")
}
return bytes, err
} | [
"func",
"(",
"q",
"*",
"BooleanQuery",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"q",
".",
"data",
".",
"Should",
"!=",
"nil",
"{",
"q",
".",
"data",
".",
"Should",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"q",
".",
"shouldMin",
"\n",
"}",
"\n",
"bytes",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"q",
".",
"data",
")",
"\n",
"if",
"q",
".",
"data",
".",
"Should",
"!=",
"nil",
"{",
"delete",
"(",
"q",
".",
"data",
".",
"Should",
".",
"options",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"bytes",
",",
"err",
"\n",
"}"
]
| // MarshalJSON marshal's this query to JSON for the FTS REST API. | [
"MarshalJSON",
"marshal",
"s",
"this",
"query",
"to",
"JSON",
"for",
"the",
"FTS",
"REST",
"API",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery.go#L337-L346 |
9,539 | couchbase/gocb | searchquery.go | NewWildcardQuery | func NewWildcardQuery(wildcard string) *WildcardQuery {
q := &WildcardQuery{newFtsQueryBase()}
q.options["wildcard"] = wildcard
return q
} | go | func NewWildcardQuery(wildcard string) *WildcardQuery {
q := &WildcardQuery{newFtsQueryBase()}
q.options["wildcard"] = wildcard
return q
} | [
"func",
"NewWildcardQuery",
"(",
"wildcard",
"string",
")",
"*",
"WildcardQuery",
"{",
"q",
":=",
"&",
"WildcardQuery",
"{",
"newFtsQueryBase",
"(",
")",
"}",
"\n",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"wildcard",
"\n",
"return",
"q",
"\n",
"}"
]
| // NewWildcardQuery creates a new WildcardQuery. | [
"NewWildcardQuery",
"creates",
"a",
"new",
"WildcardQuery",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery.go#L354-L358 |
9,540 | couchbase/gocb | searchquery.go | NewDocIdQuery | func NewDocIdQuery(ids ...string) *DocIdQuery {
q := &DocIdQuery{newFtsQueryBase()}
q.options["ids"] = []string{}
return q.AddDocIds(ids...)
} | go | func NewDocIdQuery(ids ...string) *DocIdQuery {
q := &DocIdQuery{newFtsQueryBase()}
q.options["ids"] = []string{}
return q.AddDocIds(ids...)
} | [
"func",
"NewDocIdQuery",
"(",
"ids",
"...",
"string",
")",
"*",
"DocIdQuery",
"{",
"q",
":=",
"&",
"DocIdQuery",
"{",
"newFtsQueryBase",
"(",
")",
"}",
"\n",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"[",
"]",
"string",
"{",
"}",
"\n",
"return",
"q",
".",
"AddDocIds",
"(",
"ids",
"...",
")",
"\n",
"}"
]
| // NewDocIdQuery creates a new DocIdQuery. | [
"NewDocIdQuery",
"creates",
"a",
"new",
"DocIdQuery",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery.go#L378-L382 |
9,541 | couchbase/gocb | searchquery.go | AddDocIds | func (q *DocIdQuery) AddDocIds(ids ...string) *DocIdQuery {
q.options["ids"] = append(q.options["ids"].([]string), ids...)
return q
} | go | func (q *DocIdQuery) AddDocIds(ids ...string) *DocIdQuery {
q.options["ids"] = append(q.options["ids"].([]string), ids...)
return q
} | [
"func",
"(",
"q",
"*",
"DocIdQuery",
")",
"AddDocIds",
"(",
"ids",
"...",
"string",
")",
"*",
"DocIdQuery",
"{",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"append",
"(",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
".",
"(",
"[",
"]",
"string",
")",
",",
"ids",
"...",
")",
"\n",
"return",
"q",
"\n",
"}"
]
| // AddDocIds adds addition document ids to this query. | [
"AddDocIds",
"adds",
"addition",
"document",
"ids",
"to",
"this",
"query",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery.go#L385-L388 |
9,542 | couchbase/gocb | searchquery.go | NewBooleanFieldQuery | func NewBooleanFieldQuery(val bool) *BooleanFieldQuery {
q := &BooleanFieldQuery{newFtsQueryBase()}
q.options["bool"] = val
return q
} | go | func NewBooleanFieldQuery(val bool) *BooleanFieldQuery {
q := &BooleanFieldQuery{newFtsQueryBase()}
q.options["bool"] = val
return q
} | [
"func",
"NewBooleanFieldQuery",
"(",
"val",
"bool",
")",
"*",
"BooleanFieldQuery",
"{",
"q",
":=",
"&",
"BooleanFieldQuery",
"{",
"newFtsQueryBase",
"(",
")",
"}",
"\n",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"val",
"\n",
"return",
"q",
"\n",
"}"
]
| // NewBooleanFieldQuery creates a new BooleanFieldQuery. | [
"NewBooleanFieldQuery",
"creates",
"a",
"new",
"BooleanFieldQuery",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery.go#L408-L412 |
9,543 | couchbase/gocb | searchquery.go | NewTermQuery | func NewTermQuery(term string) *TermQuery {
q := &TermQuery{newFtsQueryBase()}
q.options["term"] = term
return q
} | go | func NewTermQuery(term string) *TermQuery {
q := &TermQuery{newFtsQueryBase()}
q.options["term"] = term
return q
} | [
"func",
"NewTermQuery",
"(",
"term",
"string",
")",
"*",
"TermQuery",
"{",
"q",
":=",
"&",
"TermQuery",
"{",
"newFtsQueryBase",
"(",
")",
"}",
"\n",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"term",
"\n",
"return",
"q",
"\n",
"}"
]
| // NewTermQuery creates a new TermQuery. | [
"NewTermQuery",
"creates",
"a",
"new",
"TermQuery",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery.go#L432-L436 |
9,544 | couchbase/gocb | searchquery.go | NewPhraseQuery | func NewPhraseQuery(terms ...string) *PhraseQuery {
q := &PhraseQuery{newFtsQueryBase()}
q.options["terms"] = terms
return q
} | go | func NewPhraseQuery(terms ...string) *PhraseQuery {
q := &PhraseQuery{newFtsQueryBase()}
q.options["terms"] = terms
return q
} | [
"func",
"NewPhraseQuery",
"(",
"terms",
"...",
"string",
")",
"*",
"PhraseQuery",
"{",
"q",
":=",
"&",
"PhraseQuery",
"{",
"newFtsQueryBase",
"(",
")",
"}",
"\n",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"terms",
"\n",
"return",
"q",
"\n",
"}"
]
| // NewPhraseQuery creates a new PhraseQuery. | [
"NewPhraseQuery",
"creates",
"a",
"new",
"PhraseQuery",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery.go#L468-L472 |
9,545 | couchbase/gocb | searchquery.go | NewPrefixQuery | func NewPrefixQuery(prefix string) *PrefixQuery {
q := &PrefixQuery{newFtsQueryBase()}
q.options["prefix"] = prefix
return q
} | go | func NewPrefixQuery(prefix string) *PrefixQuery {
q := &PrefixQuery{newFtsQueryBase()}
q.options["prefix"] = prefix
return q
} | [
"func",
"NewPrefixQuery",
"(",
"prefix",
"string",
")",
"*",
"PrefixQuery",
"{",
"q",
":=",
"&",
"PrefixQuery",
"{",
"newFtsQueryBase",
"(",
")",
"}",
"\n",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"prefix",
"\n",
"return",
"q",
"\n",
"}"
]
| // NewPrefixQuery creates a new PrefixQuery. | [
"NewPrefixQuery",
"creates",
"a",
"new",
"PrefixQuery",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery.go#L492-L496 |
9,546 | couchbase/gocb | searchquery.go | NewTermRangeQuery | func NewTermRangeQuery(term string) *TermRangeQuery {
q := &TermRangeQuery{newFtsQueryBase()}
q.options["term"] = term
return q
} | go | func NewTermRangeQuery(term string) *TermRangeQuery {
q := &TermRangeQuery{newFtsQueryBase()}
q.options["term"] = term
return q
} | [
"func",
"NewTermRangeQuery",
"(",
"term",
"string",
")",
"*",
"TermRangeQuery",
"{",
"q",
":=",
"&",
"TermRangeQuery",
"{",
"newFtsQueryBase",
"(",
")",
"}",
"\n",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"term",
"\n",
"return",
"q",
"\n",
"}"
]
| // NewTermRangeQuery creates a new TermRangeQuery. | [
"NewTermRangeQuery",
"creates",
"a",
"new",
"TermRangeQuery",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery.go#L540-L544 |
9,547 | couchbase/gocb | searchquery.go | NewGeoDistanceQuery | func NewGeoDistanceQuery(lat, lon float64, distance string) *GeoDistanceQuery {
q := &GeoDistanceQuery{newFtsQueryBase()}
q.options["location"] = []float64{lon, lat}
q.options["distance"] = distance
return q
} | go | func NewGeoDistanceQuery(lat, lon float64, distance string) *GeoDistanceQuery {
q := &GeoDistanceQuery{newFtsQueryBase()}
q.options["location"] = []float64{lon, lat}
q.options["distance"] = distance
return q
} | [
"func",
"NewGeoDistanceQuery",
"(",
"lat",
",",
"lon",
"float64",
",",
"distance",
"string",
")",
"*",
"GeoDistanceQuery",
"{",
"q",
":=",
"&",
"GeoDistanceQuery",
"{",
"newFtsQueryBase",
"(",
")",
"}",
"\n",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"[",
"]",
"float64",
"{",
"lon",
",",
"lat",
"}",
"\n",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"distance",
"\n",
"return",
"q",
"\n",
"}"
]
| // NewGeoDistanceQuery creates a new GeoDistanceQuery. | [
"NewGeoDistanceQuery",
"creates",
"a",
"new",
"GeoDistanceQuery",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery.go#L578-L583 |
9,548 | couchbase/gocb | searchquery.go | NewGeoBoundingBoxQuery | func NewGeoBoundingBoxQuery(tlLat, tlLon, brLat, brLon float64) *GeoBoundingBoxQuery {
q := &GeoBoundingBoxQuery{newFtsQueryBase()}
q.options["top_left"] = []float64{tlLon, tlLat}
q.options["bottom_right"] = []float64{brLon, brLat}
return q
} | go | func NewGeoBoundingBoxQuery(tlLat, tlLon, brLat, brLon float64) *GeoBoundingBoxQuery {
q := &GeoBoundingBoxQuery{newFtsQueryBase()}
q.options["top_left"] = []float64{tlLon, tlLat}
q.options["bottom_right"] = []float64{brLon, brLat}
return q
} | [
"func",
"NewGeoBoundingBoxQuery",
"(",
"tlLat",
",",
"tlLon",
",",
"brLat",
",",
"brLon",
"float64",
")",
"*",
"GeoBoundingBoxQuery",
"{",
"q",
":=",
"&",
"GeoBoundingBoxQuery",
"{",
"newFtsQueryBase",
"(",
")",
"}",
"\n",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"[",
"]",
"float64",
"{",
"tlLon",
",",
"tlLat",
"}",
"\n",
"q",
".",
"options",
"[",
"\"",
"\"",
"]",
"=",
"[",
"]",
"float64",
"{",
"brLon",
",",
"brLat",
"}",
"\n",
"return",
"q",
"\n",
"}"
]
| // NewGeoBoundingBoxQuery creates a new GeoBoundingBoxQuery. | [
"NewGeoBoundingBoxQuery",
"creates",
"a",
"new",
"GeoBoundingBoxQuery",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery.go#L603-L608 |
9,549 | couchbase/gocb | results.go | Content | func (d *GetResult) Content(valuePtr interface{}) error {
return DefaultDecode(d.contents, d.flags, valuePtr)
} | go | func (d *GetResult) Content(valuePtr interface{}) error {
return DefaultDecode(d.contents, d.flags, valuePtr)
} | [
"func",
"(",
"d",
"*",
"GetResult",
")",
"Content",
"(",
"valuePtr",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"DefaultDecode",
"(",
"d",
".",
"contents",
",",
"d",
".",
"flags",
",",
"valuePtr",
")",
"\n",
"}"
]
| // Content assigns the value of the result into the valuePtr using default decoding. | [
"Content",
"assigns",
"the",
"value",
"of",
"the",
"result",
"into",
"the",
"valuePtr",
"using",
"default",
"decoding",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/results.go#L42-L44 |
9,550 | couchbase/gocb | results.go | Decode | func (d *GetResult) Decode(valuePtr interface{}, decode Decode) error {
if decode == nil {
decode = DefaultDecode
}
return decode(d.contents, d.flags, valuePtr)
} | go | func (d *GetResult) Decode(valuePtr interface{}, decode Decode) error {
if decode == nil {
decode = DefaultDecode
}
return decode(d.contents, d.flags, valuePtr)
} | [
"func",
"(",
"d",
"*",
"GetResult",
")",
"Decode",
"(",
"valuePtr",
"interface",
"{",
"}",
",",
"decode",
"Decode",
")",
"error",
"{",
"if",
"decode",
"==",
"nil",
"{",
"decode",
"=",
"DefaultDecode",
"\n",
"}",
"\n",
"return",
"decode",
"(",
"d",
".",
"contents",
",",
"d",
".",
"flags",
",",
"valuePtr",
")",
"\n",
"}"
]
| // Decode assigns the value of the result into the valuePtr using the decode function
// specified. | [
"Decode",
"assigns",
"the",
"value",
"of",
"the",
"result",
"into",
"the",
"valuePtr",
"using",
"the",
"decode",
"function",
"specified",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/results.go#L48-L53 |
9,551 | couchbase/gocb | results.go | set | func (d *GetResult) set(paths []subdocPath, content interface{}, value interface{}) interface{} {
path := paths[0]
if len(paths) == 1 {
if path.isArray {
arr := make([]interface{}, 0)
arr = append(arr, value)
content.(map[string]interface{})[path.path] = arr
} else {
if _, ok := content.([]interface{}); ok {
elem := make(map[string]interface{})
elem[path.path] = value
content = append(content.([]interface{}), elem)
} else {
content.(map[string]interface{})[path.path] = value
}
}
return content
}
if path.isArray {
// TODO: in the future consider an array of arrays
if cMap, ok := content.(map[string]interface{}); ok {
cMap[path.path] = make([]interface{}, 0)
cMap[path.path] = d.set(paths[1:], cMap[path.path], value)
return content
}
} else {
if arr, ok := content.([]interface{}); ok {
m := make(map[string]interface{})
m[path.path] = make(map[string]interface{})
content = append(arr, m)
d.set(paths[1:], m[path.path], value)
return content
}
cMap, ok := content.(map[string]interface{})
if !ok {
// this isn't possible but the linter won't play nice without it
}
cMap[path.path] = make(map[string]interface{})
return d.set(paths[1:], cMap[path.path], value)
}
return content
} | go | func (d *GetResult) set(paths []subdocPath, content interface{}, value interface{}) interface{} {
path := paths[0]
if len(paths) == 1 {
if path.isArray {
arr := make([]interface{}, 0)
arr = append(arr, value)
content.(map[string]interface{})[path.path] = arr
} else {
if _, ok := content.([]interface{}); ok {
elem := make(map[string]interface{})
elem[path.path] = value
content = append(content.([]interface{}), elem)
} else {
content.(map[string]interface{})[path.path] = value
}
}
return content
}
if path.isArray {
// TODO: in the future consider an array of arrays
if cMap, ok := content.(map[string]interface{}); ok {
cMap[path.path] = make([]interface{}, 0)
cMap[path.path] = d.set(paths[1:], cMap[path.path], value)
return content
}
} else {
if arr, ok := content.([]interface{}); ok {
m := make(map[string]interface{})
m[path.path] = make(map[string]interface{})
content = append(arr, m)
d.set(paths[1:], m[path.path], value)
return content
}
cMap, ok := content.(map[string]interface{})
if !ok {
// this isn't possible but the linter won't play nice without it
}
cMap[path.path] = make(map[string]interface{})
return d.set(paths[1:], cMap[path.path], value)
}
return content
} | [
"func",
"(",
"d",
"*",
"GetResult",
")",
"set",
"(",
"paths",
"[",
"]",
"subdocPath",
",",
"content",
"interface",
"{",
"}",
",",
"value",
"interface",
"{",
"}",
")",
"interface",
"{",
"}",
"{",
"path",
":=",
"paths",
"[",
"0",
"]",
"\n",
"if",
"len",
"(",
"paths",
")",
"==",
"1",
"{",
"if",
"path",
".",
"isArray",
"{",
"arr",
":=",
"make",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"0",
")",
"\n",
"arr",
"=",
"append",
"(",
"arr",
",",
"value",
")",
"\n",
"content",
".",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"[",
"path",
".",
"path",
"]",
"=",
"arr",
"\n",
"}",
"else",
"{",
"if",
"_",
",",
"ok",
":=",
"content",
".",
"(",
"[",
"]",
"interface",
"{",
"}",
")",
";",
"ok",
"{",
"elem",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"elem",
"[",
"path",
".",
"path",
"]",
"=",
"value",
"\n",
"content",
"=",
"append",
"(",
"content",
".",
"(",
"[",
"]",
"interface",
"{",
"}",
")",
",",
"elem",
")",
"\n",
"}",
"else",
"{",
"content",
".",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"[",
"path",
".",
"path",
"]",
"=",
"value",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"content",
"\n",
"}",
"\n\n",
"if",
"path",
".",
"isArray",
"{",
"// TODO: in the future consider an array of arrays",
"if",
"cMap",
",",
"ok",
":=",
"content",
".",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
";",
"ok",
"{",
"cMap",
"[",
"path",
".",
"path",
"]",
"=",
"make",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"0",
")",
"\n",
"cMap",
"[",
"path",
".",
"path",
"]",
"=",
"d",
".",
"set",
"(",
"paths",
"[",
"1",
":",
"]",
",",
"cMap",
"[",
"path",
".",
"path",
"]",
",",
"value",
")",
"\n",
"return",
"content",
"\n",
"}",
"\n",
"}",
"else",
"{",
"if",
"arr",
",",
"ok",
":=",
"content",
".",
"(",
"[",
"]",
"interface",
"{",
"}",
")",
";",
"ok",
"{",
"m",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"m",
"[",
"path",
".",
"path",
"]",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"content",
"=",
"append",
"(",
"arr",
",",
"m",
")",
"\n",
"d",
".",
"set",
"(",
"paths",
"[",
"1",
":",
"]",
",",
"m",
"[",
"path",
".",
"path",
"]",
",",
"value",
")",
"\n",
"return",
"content",
"\n",
"}",
"\n",
"cMap",
",",
"ok",
":=",
"content",
".",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"if",
"!",
"ok",
"{",
"// this isn't possible but the linter won't play nice without it",
"}",
"\n",
"cMap",
"[",
"path",
".",
"path",
"]",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"return",
"d",
".",
"set",
"(",
"paths",
"[",
"1",
":",
"]",
",",
"cMap",
"[",
"path",
".",
"path",
"]",
",",
"value",
")",
"\n",
"}",
"\n\n",
"return",
"content",
"\n",
"}"
]
| // thing,false , animals,true , anotherthing,false .thing | [
"thing",
"false",
"animals",
"true",
"anotherthing",
"false",
".",
"thing"
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/results.go#L155-L198 |
9,552 | couchbase/gocb | results.go | DecodeAt | func (lir *LookupInResult) DecodeAt(idx int, valuePtr interface{}, decode Decode) error {
if idx > len(lir.contents) {
return errors.New("the supplied index was invalid")
}
if decode == nil {
decode = JSONDecode
}
return lir.contents[idx].as(valuePtr, decode)
} | go | func (lir *LookupInResult) DecodeAt(idx int, valuePtr interface{}, decode Decode) error {
if idx > len(lir.contents) {
return errors.New("the supplied index was invalid")
}
if decode == nil {
decode = JSONDecode
}
return lir.contents[idx].as(valuePtr, decode)
} | [
"func",
"(",
"lir",
"*",
"LookupInResult",
")",
"DecodeAt",
"(",
"idx",
"int",
",",
"valuePtr",
"interface",
"{",
"}",
",",
"decode",
"Decode",
")",
"error",
"{",
"if",
"idx",
">",
"len",
"(",
"lir",
".",
"contents",
")",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"decode",
"==",
"nil",
"{",
"decode",
"=",
"JSONDecode",
"\n",
"}",
"\n",
"return",
"lir",
".",
"contents",
"[",
"idx",
"]",
".",
"as",
"(",
"valuePtr",
",",
"decode",
")",
"\n",
"}"
]
| // DecodeAt retrieves the value of the operation by its index. The index is the position of
// the operation as it was added to the builder. In order to decode the value it will use the
// support Decode function, by default it will use JSONDecode | [
"DecodeAt",
"retrieves",
"the",
"value",
"of",
"the",
"operation",
"by",
"its",
"index",
".",
"The",
"index",
"is",
"the",
"position",
"of",
"the",
"operation",
"as",
"it",
"was",
"added",
"to",
"the",
"builder",
".",
"In",
"order",
"to",
"decode",
"the",
"value",
"it",
"will",
"use",
"the",
"support",
"Decode",
"function",
"by",
"default",
"it",
"will",
"use",
"JSONDecode"
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/results.go#L246-L254 |
9,553 | couchbase/gocb | results.go | Exists | func (lir *LookupInResult) Exists(idx int) bool {
return lir.contents[idx].exists()
} | go | func (lir *LookupInResult) Exists(idx int) bool {
return lir.contents[idx].exists()
} | [
"func",
"(",
"lir",
"*",
"LookupInResult",
")",
"Exists",
"(",
"idx",
"int",
")",
"bool",
"{",
"return",
"lir",
".",
"contents",
"[",
"idx",
"]",
".",
"exists",
"(",
")",
"\n",
"}"
]
| // Exists verifies that the item at idx exists. | [
"Exists",
"verifies",
"that",
"the",
"item",
"at",
"idx",
"exists",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/results.go#L257-L259 |
9,554 | couchbase/gocb | results.go | Exists | func (d *ExistsResult) Exists() bool {
return d.keyState != gocbcore.KeyStateNotFound && d.keyState != gocbcore.KeyStateDeleted
} | go | func (d *ExistsResult) Exists() bool {
return d.keyState != gocbcore.KeyStateNotFound && d.keyState != gocbcore.KeyStateDeleted
} | [
"func",
"(",
"d",
"*",
"ExistsResult",
")",
"Exists",
"(",
")",
"bool",
"{",
"return",
"d",
".",
"keyState",
"!=",
"gocbcore",
".",
"KeyStateNotFound",
"&&",
"d",
".",
"keyState",
"!=",
"gocbcore",
".",
"KeyStateDeleted",
"\n",
"}"
]
| // Exists returns whether or not the document exists. | [
"Exists",
"returns",
"whether",
"or",
"not",
"the",
"document",
"exists",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/results.go#L268-L270 |
9,555 | couchbase/gocb | cluster_searchquery.go | Facets | func (r SearchResults) Facets() (map[string]SearchResultFacet, error) {
if !r.streamResult.Closed() {
return nil, errors.New("result must be closed before accessing meta-data")
}
return r.facets, nil
} | go | func (r SearchResults) Facets() (map[string]SearchResultFacet, error) {
if !r.streamResult.Closed() {
return nil, errors.New("result must be closed before accessing meta-data")
}
return r.facets, nil
} | [
"func",
"(",
"r",
"SearchResults",
")",
"Facets",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"SearchResultFacet",
",",
"error",
")",
"{",
"if",
"!",
"r",
".",
"streamResult",
".",
"Closed",
"(",
")",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"r",
".",
"facets",
",",
"nil",
"\n",
"}"
]
| // Facets contains the information relative to the facets requested in the search query. | [
"Facets",
"contains",
"the",
"information",
"relative",
"to",
"the",
"facets",
"requested",
"in",
"the",
"search",
"query",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/cluster_searchquery.go#L221-L227 |
9,556 | couchbase/gocb | cluster_searchquery.go | Took | func (r SearchResultsMetadata) Took() time.Duration {
return time.Duration(r.took) / time.Nanosecond
} | go | func (r SearchResultsMetadata) Took() time.Duration {
return time.Duration(r.took) / time.Nanosecond
} | [
"func",
"(",
"r",
"SearchResultsMetadata",
")",
"Took",
"(",
")",
"time",
".",
"Duration",
"{",
"return",
"time",
".",
"Duration",
"(",
"r",
".",
"took",
")",
"/",
"time",
".",
"Nanosecond",
"\n",
"}"
]
| // Took returns the time taken to execute the search. | [
"Took",
"returns",
"the",
"time",
"taken",
"to",
"execute",
"the",
"search",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/cluster_searchquery.go#L230-L232 |
9,557 | couchbase/gocb | cluster_searchquery.go | SearchQuery | func (c *Cluster) SearchQuery(q SearchQuery, opts *SearchQueryOptions) (*SearchResults, error) {
if opts == nil {
opts = &SearchQueryOptions{}
}
ctx := opts.Context
if ctx == nil {
ctx = context.Background()
}
var span opentracing.Span
if opts.ParentSpanContext == nil {
span = opentracing.GlobalTracer().StartSpan("ExecuteSearchQuery",
opentracing.Tag{Key: "couchbase.service", Value: "fts"})
} else {
span = opentracing.GlobalTracer().StartSpan("ExecuteSearchQuery",
opentracing.Tag{Key: "couchbase.service", Value: "fts"}, opentracing.ChildOf(opts.ParentSpanContext))
}
defer span.Finish()
provider, err := c.getHTTPProvider()
if err != nil {
return nil, err
}
return c.searchQuery(ctx, span.Context(), q, opts, provider)
} | go | func (c *Cluster) SearchQuery(q SearchQuery, opts *SearchQueryOptions) (*SearchResults, error) {
if opts == nil {
opts = &SearchQueryOptions{}
}
ctx := opts.Context
if ctx == nil {
ctx = context.Background()
}
var span opentracing.Span
if opts.ParentSpanContext == nil {
span = opentracing.GlobalTracer().StartSpan("ExecuteSearchQuery",
opentracing.Tag{Key: "couchbase.service", Value: "fts"})
} else {
span = opentracing.GlobalTracer().StartSpan("ExecuteSearchQuery",
opentracing.Tag{Key: "couchbase.service", Value: "fts"}, opentracing.ChildOf(opts.ParentSpanContext))
}
defer span.Finish()
provider, err := c.getHTTPProvider()
if err != nil {
return nil, err
}
return c.searchQuery(ctx, span.Context(), q, opts, provider)
} | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"SearchQuery",
"(",
"q",
"SearchQuery",
",",
"opts",
"*",
"SearchQueryOptions",
")",
"(",
"*",
"SearchResults",
",",
"error",
")",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"&",
"SearchQueryOptions",
"{",
"}",
"\n",
"}",
"\n",
"ctx",
":=",
"opts",
".",
"Context",
"\n",
"if",
"ctx",
"==",
"nil",
"{",
"ctx",
"=",
"context",
".",
"Background",
"(",
")",
"\n",
"}",
"\n\n",
"var",
"span",
"opentracing",
".",
"Span",
"\n",
"if",
"opts",
".",
"ParentSpanContext",
"==",
"nil",
"{",
"span",
"=",
"opentracing",
".",
"GlobalTracer",
"(",
")",
".",
"StartSpan",
"(",
"\"",
"\"",
",",
"opentracing",
".",
"Tag",
"{",
"Key",
":",
"\"",
"\"",
",",
"Value",
":",
"\"",
"\"",
"}",
")",
"\n",
"}",
"else",
"{",
"span",
"=",
"opentracing",
".",
"GlobalTracer",
"(",
")",
".",
"StartSpan",
"(",
"\"",
"\"",
",",
"opentracing",
".",
"Tag",
"{",
"Key",
":",
"\"",
"\"",
",",
"Value",
":",
"\"",
"\"",
"}",
",",
"opentracing",
".",
"ChildOf",
"(",
"opts",
".",
"ParentSpanContext",
")",
")",
"\n",
"}",
"\n",
"defer",
"span",
".",
"Finish",
"(",
")",
"\n\n",
"provider",
",",
"err",
":=",
"c",
".",
"getHTTPProvider",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"c",
".",
"searchQuery",
"(",
"ctx",
",",
"span",
".",
"Context",
"(",
")",
",",
"q",
",",
"opts",
",",
"provider",
")",
"\n",
"}"
]
| // SearchQuery performs a n1ql query and returns a list of rows or an error. | [
"SearchQuery",
"performs",
"a",
"n1ql",
"query",
"and",
"returns",
"a",
"list",
"of",
"rows",
"or",
"an",
"error",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/cluster_searchquery.go#L339-L364 |
9,558 | couchbase/gocb | collection_crud.go | Upsert | func (c *Collection) Upsert(key string, val interface{}, opts *UpsertOptions) (mutOut *MutationResult, errOut error) {
if opts == nil {
opts = &UpsertOptions{}
}
span := c.startKvOpTrace(opts.ParentSpanContext, "Upsert")
defer span.Finish()
ctx, cancel := c.context(opts.Context, opts.Timeout)
if cancel != nil {
defer cancel()
}
res, err := c.upsert(ctx, span.Context(), key, val, *opts)
if err != nil {
return nil, err
}
if opts.PersistTo == 0 && opts.ReplicateTo == 0 {
return res, nil
}
return res, c.durability(durabilitySettings{
ctx: opts.Context,
tracectx: span.Context(),
key: key,
cas: res.Cas(),
mt: res.MutationToken(),
replicaTo: opts.ReplicateTo,
persistTo: opts.PersistTo,
forDelete: false,
scopeName: c.scopeName(),
collectionName: c.name(),
})
} | go | func (c *Collection) Upsert(key string, val interface{}, opts *UpsertOptions) (mutOut *MutationResult, errOut error) {
if opts == nil {
opts = &UpsertOptions{}
}
span := c.startKvOpTrace(opts.ParentSpanContext, "Upsert")
defer span.Finish()
ctx, cancel := c.context(opts.Context, opts.Timeout)
if cancel != nil {
defer cancel()
}
res, err := c.upsert(ctx, span.Context(), key, val, *opts)
if err != nil {
return nil, err
}
if opts.PersistTo == 0 && opts.ReplicateTo == 0 {
return res, nil
}
return res, c.durability(durabilitySettings{
ctx: opts.Context,
tracectx: span.Context(),
key: key,
cas: res.Cas(),
mt: res.MutationToken(),
replicaTo: opts.ReplicateTo,
persistTo: opts.PersistTo,
forDelete: false,
scopeName: c.scopeName(),
collectionName: c.name(),
})
} | [
"func",
"(",
"c",
"*",
"Collection",
")",
"Upsert",
"(",
"key",
"string",
",",
"val",
"interface",
"{",
"}",
",",
"opts",
"*",
"UpsertOptions",
")",
"(",
"mutOut",
"*",
"MutationResult",
",",
"errOut",
"error",
")",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"&",
"UpsertOptions",
"{",
"}",
"\n",
"}",
"\n\n",
"span",
":=",
"c",
".",
"startKvOpTrace",
"(",
"opts",
".",
"ParentSpanContext",
",",
"\"",
"\"",
")",
"\n",
"defer",
"span",
".",
"Finish",
"(",
")",
"\n\n",
"ctx",
",",
"cancel",
":=",
"c",
".",
"context",
"(",
"opts",
".",
"Context",
",",
"opts",
".",
"Timeout",
")",
"\n",
"if",
"cancel",
"!=",
"nil",
"{",
"defer",
"cancel",
"(",
")",
"\n",
"}",
"\n\n",
"res",
",",
"err",
":=",
"c",
".",
"upsert",
"(",
"ctx",
",",
"span",
".",
"Context",
"(",
")",
",",
"key",
",",
"val",
",",
"*",
"opts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"opts",
".",
"PersistTo",
"==",
"0",
"&&",
"opts",
".",
"ReplicateTo",
"==",
"0",
"{",
"return",
"res",
",",
"nil",
"\n",
"}",
"\n",
"return",
"res",
",",
"c",
".",
"durability",
"(",
"durabilitySettings",
"{",
"ctx",
":",
"opts",
".",
"Context",
",",
"tracectx",
":",
"span",
".",
"Context",
"(",
")",
",",
"key",
":",
"key",
",",
"cas",
":",
"res",
".",
"Cas",
"(",
")",
",",
"mt",
":",
"res",
".",
"MutationToken",
"(",
")",
",",
"replicaTo",
":",
"opts",
".",
"ReplicateTo",
",",
"persistTo",
":",
"opts",
".",
"PersistTo",
",",
"forDelete",
":",
"false",
",",
"scopeName",
":",
"c",
".",
"scopeName",
"(",
")",
",",
"collectionName",
":",
"c",
".",
"name",
"(",
")",
",",
"}",
")",
"\n",
"}"
]
| // Upsert creates a new document in the Collection if it does not exist, if it does exist then it updates it. | [
"Upsert",
"creates",
"a",
"new",
"document",
"in",
"the",
"Collection",
"if",
"it",
"does",
"not",
"exist",
"if",
"it",
"does",
"exist",
"then",
"it",
"updates",
"it",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/collection_crud.go#L210-L243 |
9,559 | couchbase/gocb | collection_crud.go | get | func (c *Collection) get(ctx context.Context, traceCtx opentracing.SpanContext, key string, opts *GetOptions) (docOut *GetResult, errOut error) {
span := c.startKvOpTrace(traceCtx, "get")
defer span.Finish()
agent, err := c.getKvProvider()
if err != nil {
return nil, err
}
ctrl := c.newOpManager(ctx)
err = ctrl.wait(agent.GetEx(gocbcore.GetOptions{
Key: []byte(key),
TraceContext: traceCtx,
CollectionName: c.name(),
ScopeName: c.scopeName(),
}, func(res *gocbcore.GetResult, err error) {
if err != nil {
errOut = maybeEnhanceErr(err, key)
ctrl.resolve()
return
}
if res != nil {
doc := &GetResult{
Result: Result{
cas: Cas(res.Cas),
},
contents: res.Value,
flags: res.Flags,
}
docOut = doc
}
ctrl.resolve()
}))
if err != nil {
errOut = err
}
return
} | go | func (c *Collection) get(ctx context.Context, traceCtx opentracing.SpanContext, key string, opts *GetOptions) (docOut *GetResult, errOut error) {
span := c.startKvOpTrace(traceCtx, "get")
defer span.Finish()
agent, err := c.getKvProvider()
if err != nil {
return nil, err
}
ctrl := c.newOpManager(ctx)
err = ctrl.wait(agent.GetEx(gocbcore.GetOptions{
Key: []byte(key),
TraceContext: traceCtx,
CollectionName: c.name(),
ScopeName: c.scopeName(),
}, func(res *gocbcore.GetResult, err error) {
if err != nil {
errOut = maybeEnhanceErr(err, key)
ctrl.resolve()
return
}
if res != nil {
doc := &GetResult{
Result: Result{
cas: Cas(res.Cas),
},
contents: res.Value,
flags: res.Flags,
}
docOut = doc
}
ctrl.resolve()
}))
if err != nil {
errOut = err
}
return
} | [
"func",
"(",
"c",
"*",
"Collection",
")",
"get",
"(",
"ctx",
"context",
".",
"Context",
",",
"traceCtx",
"opentracing",
".",
"SpanContext",
",",
"key",
"string",
",",
"opts",
"*",
"GetOptions",
")",
"(",
"docOut",
"*",
"GetResult",
",",
"errOut",
"error",
")",
"{",
"span",
":=",
"c",
".",
"startKvOpTrace",
"(",
"traceCtx",
",",
"\"",
"\"",
")",
"\n",
"defer",
"span",
".",
"Finish",
"(",
")",
"\n\n",
"agent",
",",
"err",
":=",
"c",
".",
"getKvProvider",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"ctrl",
":=",
"c",
".",
"newOpManager",
"(",
"ctx",
")",
"\n",
"err",
"=",
"ctrl",
".",
"wait",
"(",
"agent",
".",
"GetEx",
"(",
"gocbcore",
".",
"GetOptions",
"{",
"Key",
":",
"[",
"]",
"byte",
"(",
"key",
")",
",",
"TraceContext",
":",
"traceCtx",
",",
"CollectionName",
":",
"c",
".",
"name",
"(",
")",
",",
"ScopeName",
":",
"c",
".",
"scopeName",
"(",
")",
",",
"}",
",",
"func",
"(",
"res",
"*",
"gocbcore",
".",
"GetResult",
",",
"err",
"error",
")",
"{",
"if",
"err",
"!=",
"nil",
"{",
"errOut",
"=",
"maybeEnhanceErr",
"(",
"err",
",",
"key",
")",
"\n",
"ctrl",
".",
"resolve",
"(",
")",
"\n",
"return",
"\n",
"}",
"\n",
"if",
"res",
"!=",
"nil",
"{",
"doc",
":=",
"&",
"GetResult",
"{",
"Result",
":",
"Result",
"{",
"cas",
":",
"Cas",
"(",
"res",
".",
"Cas",
")",
",",
"}",
",",
"contents",
":",
"res",
".",
"Value",
",",
"flags",
":",
"res",
".",
"Flags",
",",
"}",
"\n\n",
"docOut",
"=",
"doc",
"\n",
"}",
"\n\n",
"ctrl",
".",
"resolve",
"(",
")",
"\n",
"}",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"errOut",
"=",
"err",
"\n",
"}",
"\n\n",
"return",
"\n",
"}"
]
| // get performs a full document fetch against the collection | [
"get",
"performs",
"a",
"full",
"document",
"fetch",
"against",
"the",
"collection"
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/collection_crud.go#L478-L518 |
9,560 | couchbase/gocb | collection_crud.go | Exists | func (c *Collection) Exists(key string, opts *ExistsOptions) (docOut *ExistsResult, errOut error) {
if opts == nil {
opts = &ExistsOptions{}
}
span := c.startKvOpTrace(opts.ParentSpanContext, "Exists")
defer span.Finish()
ctx, cancel := c.context(opts.Context, opts.Timeout)
if cancel != nil {
defer cancel()
}
res, err := c.exists(ctx, span.Context(), key, *opts)
if err != nil {
return nil, err
}
return res, nil
} | go | func (c *Collection) Exists(key string, opts *ExistsOptions) (docOut *ExistsResult, errOut error) {
if opts == nil {
opts = &ExistsOptions{}
}
span := c.startKvOpTrace(opts.ParentSpanContext, "Exists")
defer span.Finish()
ctx, cancel := c.context(opts.Context, opts.Timeout)
if cancel != nil {
defer cancel()
}
res, err := c.exists(ctx, span.Context(), key, *opts)
if err != nil {
return nil, err
}
return res, nil
} | [
"func",
"(",
"c",
"*",
"Collection",
")",
"Exists",
"(",
"key",
"string",
",",
"opts",
"*",
"ExistsOptions",
")",
"(",
"docOut",
"*",
"ExistsResult",
",",
"errOut",
"error",
")",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"&",
"ExistsOptions",
"{",
"}",
"\n",
"}",
"\n\n",
"span",
":=",
"c",
".",
"startKvOpTrace",
"(",
"opts",
".",
"ParentSpanContext",
",",
"\"",
"\"",
")",
"\n",
"defer",
"span",
".",
"Finish",
"(",
")",
"\n\n",
"ctx",
",",
"cancel",
":=",
"c",
".",
"context",
"(",
"opts",
".",
"Context",
",",
"opts",
".",
"Timeout",
")",
"\n",
"if",
"cancel",
"!=",
"nil",
"{",
"defer",
"cancel",
"(",
")",
"\n",
"}",
"\n\n",
"res",
",",
"err",
":=",
"c",
".",
"exists",
"(",
"ctx",
",",
"span",
".",
"Context",
"(",
")",
",",
"key",
",",
"*",
"opts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"res",
",",
"nil",
"\n",
"}"
]
| // Exists checks if a document exists for the given key. | [
"Exists",
"checks",
"if",
"a",
"document",
"exists",
"for",
"the",
"given",
"key",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/collection_crud.go#L528-L547 |
9,561 | couchbase/gocb | collection_crud.go | GetFromReplica | func (c *Collection) GetFromReplica(key string, replicaIdx int, opts *GetFromReplicaOptions) (docOut *GetResult, errOut error) {
if opts == nil {
opts = &GetFromReplicaOptions{}
}
span := c.startKvOpTrace(opts.ParentSpanContext, "GetFromReplica")
defer span.Finish()
ctx, cancel := c.context(opts.Context, opts.Timeout)
if cancel != nil {
defer cancel()
}
res, err := c.getFromReplica(ctx, span.Context(), key, replicaIdx, *opts)
if err != nil {
return nil, err
}
return res, nil
} | go | func (c *Collection) GetFromReplica(key string, replicaIdx int, opts *GetFromReplicaOptions) (docOut *GetResult, errOut error) {
if opts == nil {
opts = &GetFromReplicaOptions{}
}
span := c.startKvOpTrace(opts.ParentSpanContext, "GetFromReplica")
defer span.Finish()
ctx, cancel := c.context(opts.Context, opts.Timeout)
if cancel != nil {
defer cancel()
}
res, err := c.getFromReplica(ctx, span.Context(), key, replicaIdx, *opts)
if err != nil {
return nil, err
}
return res, nil
} | [
"func",
"(",
"c",
"*",
"Collection",
")",
"GetFromReplica",
"(",
"key",
"string",
",",
"replicaIdx",
"int",
",",
"opts",
"*",
"GetFromReplicaOptions",
")",
"(",
"docOut",
"*",
"GetResult",
",",
"errOut",
"error",
")",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"&",
"GetFromReplicaOptions",
"{",
"}",
"\n",
"}",
"\n\n",
"span",
":=",
"c",
".",
"startKvOpTrace",
"(",
"opts",
".",
"ParentSpanContext",
",",
"\"",
"\"",
")",
"\n",
"defer",
"span",
".",
"Finish",
"(",
")",
"\n\n",
"ctx",
",",
"cancel",
":=",
"c",
".",
"context",
"(",
"opts",
".",
"Context",
",",
"opts",
".",
"Timeout",
")",
"\n",
"if",
"cancel",
"!=",
"nil",
"{",
"defer",
"cancel",
"(",
")",
"\n",
"}",
"\n\n",
"res",
",",
"err",
":=",
"c",
".",
"getFromReplica",
"(",
"ctx",
",",
"span",
".",
"Context",
"(",
")",
",",
"key",
",",
"replicaIdx",
",",
"*",
"opts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"res",
",",
"nil",
"\n",
"}"
]
| // GetFromReplica returns the value of a particular document from a replica server.. | [
"GetFromReplica",
"returns",
"the",
"value",
"of",
"a",
"particular",
"document",
"from",
"a",
"replica",
"server",
".."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/collection_crud.go#L596-L615 |
9,562 | couchbase/gocb | collection_crud.go | GetAndTouch | func (c *Collection) GetAndTouch(key string, expiration uint32, opts *GetAndTouchOptions) (docOut *GetResult, errOut error) {
if opts == nil {
opts = &GetAndTouchOptions{}
}
span := c.startKvOpTrace(opts.ParentSpanContext, "GetAndTouch")
defer span.Finish()
ctx, cancel := c.context(opts.Context, opts.Timeout)
if cancel != nil {
defer cancel()
}
res, err := c.getAndTouch(ctx, span.Context(), key, expiration, *opts)
if err != nil {
return nil, err
}
return res, nil
} | go | func (c *Collection) GetAndTouch(key string, expiration uint32, opts *GetAndTouchOptions) (docOut *GetResult, errOut error) {
if opts == nil {
opts = &GetAndTouchOptions{}
}
span := c.startKvOpTrace(opts.ParentSpanContext, "GetAndTouch")
defer span.Finish()
ctx, cancel := c.context(opts.Context, opts.Timeout)
if cancel != nil {
defer cancel()
}
res, err := c.getAndTouch(ctx, span.Context(), key, expiration, *opts)
if err != nil {
return nil, err
}
return res, nil
} | [
"func",
"(",
"c",
"*",
"Collection",
")",
"GetAndTouch",
"(",
"key",
"string",
",",
"expiration",
"uint32",
",",
"opts",
"*",
"GetAndTouchOptions",
")",
"(",
"docOut",
"*",
"GetResult",
",",
"errOut",
"error",
")",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"&",
"GetAndTouchOptions",
"{",
"}",
"\n",
"}",
"\n\n",
"span",
":=",
"c",
".",
"startKvOpTrace",
"(",
"opts",
".",
"ParentSpanContext",
",",
"\"",
"\"",
")",
"\n",
"defer",
"span",
".",
"Finish",
"(",
")",
"\n\n",
"ctx",
",",
"cancel",
":=",
"c",
".",
"context",
"(",
"opts",
".",
"Context",
",",
"opts",
".",
"Timeout",
")",
"\n",
"if",
"cancel",
"!=",
"nil",
"{",
"defer",
"cancel",
"(",
")",
"\n",
"}",
"\n\n",
"res",
",",
"err",
":=",
"c",
".",
"getAndTouch",
"(",
"ctx",
",",
"span",
".",
"Context",
"(",
")",
",",
"key",
",",
"expiration",
",",
"*",
"opts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"res",
",",
"nil",
"\n",
"}"
]
| // GetAndTouch retrieves a document and simultaneously updates its expiry time. | [
"GetAndTouch",
"retrieves",
"a",
"document",
"and",
"simultaneously",
"updates",
"its",
"expiry",
"time",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/collection_crud.go#L751-L770 |
9,563 | couchbase/gocb | collection_crud.go | GetAndLock | func (c *Collection) GetAndLock(key string, expiration uint32, opts *GetAndLockOptions) (docOut *GetResult, errOut error) {
if opts == nil {
opts = &GetAndLockOptions{}
}
span := c.startKvOpTrace(opts.ParentSpanContext, "GetAndLock")
defer span.Finish()
ctx, cancel := c.context(opts.Context, opts.Timeout)
if cancel != nil {
defer cancel()
}
res, err := c.getAndLock(ctx, span.Context(), key, expiration, *opts)
if err != nil {
return nil, err
}
return res, nil
} | go | func (c *Collection) GetAndLock(key string, expiration uint32, opts *GetAndLockOptions) (docOut *GetResult, errOut error) {
if opts == nil {
opts = &GetAndLockOptions{}
}
span := c.startKvOpTrace(opts.ParentSpanContext, "GetAndLock")
defer span.Finish()
ctx, cancel := c.context(opts.Context, opts.Timeout)
if cancel != nil {
defer cancel()
}
res, err := c.getAndLock(ctx, span.Context(), key, expiration, *opts)
if err != nil {
return nil, err
}
return res, nil
} | [
"func",
"(",
"c",
"*",
"Collection",
")",
"GetAndLock",
"(",
"key",
"string",
",",
"expiration",
"uint32",
",",
"opts",
"*",
"GetAndLockOptions",
")",
"(",
"docOut",
"*",
"GetResult",
",",
"errOut",
"error",
")",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"&",
"GetAndLockOptions",
"{",
"}",
"\n",
"}",
"\n\n",
"span",
":=",
"c",
".",
"startKvOpTrace",
"(",
"opts",
".",
"ParentSpanContext",
",",
"\"",
"\"",
")",
"\n",
"defer",
"span",
".",
"Finish",
"(",
")",
"\n\n",
"ctx",
",",
"cancel",
":=",
"c",
".",
"context",
"(",
"opts",
".",
"Context",
",",
"opts",
".",
"Timeout",
")",
"\n",
"if",
"cancel",
"!=",
"nil",
"{",
"defer",
"cancel",
"(",
")",
"\n",
"}",
"\n\n",
"res",
",",
"err",
":=",
"c",
".",
"getAndLock",
"(",
"ctx",
",",
"span",
".",
"Context",
"(",
")",
",",
"key",
",",
"expiration",
",",
"*",
"opts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"res",
",",
"nil",
"\n",
"}"
]
| // GetAndLock locks a document for a period of time, providing exclusive RW access to it. | [
"GetAndLock",
"locks",
"a",
"document",
"for",
"a",
"period",
"of",
"time",
"providing",
"exclusive",
"RW",
"access",
"to",
"it",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/collection_crud.go#L820-L839 |
9,564 | couchbase/gocb | collection_crud.go | Unlock | func (c *Collection) Unlock(key string, opts *UnlockOptions) (mutOut *MutationResult, errOut error) {
if opts == nil {
opts = &UnlockOptions{}
}
span := c.startKvOpTrace(opts.ParentSpanContext, "Unlock")
defer span.Finish()
ctx, cancel := c.context(opts.Context, opts.Timeout)
if cancel != nil {
defer cancel()
}
res, err := c.unlock(ctx, span.Context(), key, *opts)
if err != nil {
return nil, err
}
return res, nil
} | go | func (c *Collection) Unlock(key string, opts *UnlockOptions) (mutOut *MutationResult, errOut error) {
if opts == nil {
opts = &UnlockOptions{}
}
span := c.startKvOpTrace(opts.ParentSpanContext, "Unlock")
defer span.Finish()
ctx, cancel := c.context(opts.Context, opts.Timeout)
if cancel != nil {
defer cancel()
}
res, err := c.unlock(ctx, span.Context(), key, *opts)
if err != nil {
return nil, err
}
return res, nil
} | [
"func",
"(",
"c",
"*",
"Collection",
")",
"Unlock",
"(",
"key",
"string",
",",
"opts",
"*",
"UnlockOptions",
")",
"(",
"mutOut",
"*",
"MutationResult",
",",
"errOut",
"error",
")",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"&",
"UnlockOptions",
"{",
"}",
"\n",
"}",
"\n\n",
"span",
":=",
"c",
".",
"startKvOpTrace",
"(",
"opts",
".",
"ParentSpanContext",
",",
"\"",
"\"",
")",
"\n",
"defer",
"span",
".",
"Finish",
"(",
")",
"\n\n",
"ctx",
",",
"cancel",
":=",
"c",
".",
"context",
"(",
"opts",
".",
"Context",
",",
"opts",
".",
"Timeout",
")",
"\n",
"if",
"cancel",
"!=",
"nil",
"{",
"defer",
"cancel",
"(",
")",
"\n",
"}",
"\n\n",
"res",
",",
"err",
":=",
"c",
".",
"unlock",
"(",
"ctx",
",",
"span",
".",
"Context",
"(",
")",
",",
"key",
",",
"*",
"opts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"res",
",",
"nil",
"\n",
"}"
]
| // Unlock unlocks a document which was locked with GetAndLock. | [
"Unlock",
"unlocks",
"a",
"document",
"which",
"was",
"locked",
"with",
"GetAndLock",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/collection_crud.go#L889-L908 |
9,565 | couchbase/gocb | collection_crud.go | Touch | func (c *Collection) Touch(key string, expiration uint32, opts *TouchOptions) (mutOut *MutationResult, errOut error) {
if opts == nil {
opts = &TouchOptions{}
}
span := c.startKvOpTrace(opts.ParentSpanContext, "Touch")
defer span.Finish()
ctx, cancel := c.context(opts.Context, opts.Timeout)
if cancel != nil {
defer cancel()
}
res, err := c.touch(ctx, span.Context(), key, expiration, *opts)
if err != nil {
return nil, err
}
return res, nil
} | go | func (c *Collection) Touch(key string, expiration uint32, opts *TouchOptions) (mutOut *MutationResult, errOut error) {
if opts == nil {
opts = &TouchOptions{}
}
span := c.startKvOpTrace(opts.ParentSpanContext, "Touch")
defer span.Finish()
ctx, cancel := c.context(opts.Context, opts.Timeout)
if cancel != nil {
defer cancel()
}
res, err := c.touch(ctx, span.Context(), key, expiration, *opts)
if err != nil {
return nil, err
}
return res, nil
} | [
"func",
"(",
"c",
"*",
"Collection",
")",
"Touch",
"(",
"key",
"string",
",",
"expiration",
"uint32",
",",
"opts",
"*",
"TouchOptions",
")",
"(",
"mutOut",
"*",
"MutationResult",
",",
"errOut",
"error",
")",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"&",
"TouchOptions",
"{",
"}",
"\n",
"}",
"\n\n",
"span",
":=",
"c",
".",
"startKvOpTrace",
"(",
"opts",
".",
"ParentSpanContext",
",",
"\"",
"\"",
")",
"\n",
"defer",
"span",
".",
"Finish",
"(",
")",
"\n\n",
"ctx",
",",
"cancel",
":=",
"c",
".",
"context",
"(",
"opts",
".",
"Context",
",",
"opts",
".",
"Timeout",
")",
"\n",
"if",
"cancel",
"!=",
"nil",
"{",
"defer",
"cancel",
"(",
")",
"\n",
"}",
"\n\n",
"res",
",",
"err",
":=",
"c",
".",
"touch",
"(",
"ctx",
",",
"span",
".",
"Context",
"(",
")",
",",
"key",
",",
"expiration",
",",
"*",
"opts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"res",
",",
"nil",
"\n",
"}"
]
| // Touch touches a document, specifying a new expiry time for it. | [
"Touch",
"touches",
"a",
"document",
"specifying",
"a",
"new",
"expiry",
"time",
"for",
"it",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/collection_crud.go#L956-L975 |
9,566 | couchbase/gocb | collection_subdoc.go | GetFull | func (spec LookupInSpec) GetFull(opts *LookupInSpecGetFullOptions) LookupInOp {
op := gocbcore.SubDocOp{
Op: gocbcore.SubDocOpGetDoc,
Flags: gocbcore.SubdocFlag(SubdocFlagNone),
}
return LookupInOp{op: op}
} | go | func (spec LookupInSpec) GetFull(opts *LookupInSpecGetFullOptions) LookupInOp {
op := gocbcore.SubDocOp{
Op: gocbcore.SubDocOpGetDoc,
Flags: gocbcore.SubdocFlag(SubdocFlagNone),
}
return LookupInOp{op: op}
} | [
"func",
"(",
"spec",
"LookupInSpec",
")",
"GetFull",
"(",
"opts",
"*",
"LookupInSpecGetFullOptions",
")",
"LookupInOp",
"{",
"op",
":=",
"gocbcore",
".",
"SubDocOp",
"{",
"Op",
":",
"gocbcore",
".",
"SubDocOpGetDoc",
",",
"Flags",
":",
"gocbcore",
".",
"SubdocFlag",
"(",
"SubdocFlagNone",
")",
",",
"}",
"\n\n",
"return",
"LookupInOp",
"{",
"op",
":",
"op",
"}",
"\n",
"}"
]
| // GetFull indicates that a full document should be retrieved. This command allows you
// to do things like combine with Get to fetch a document with certain Xattrs | [
"GetFull",
"indicates",
"that",
"a",
"full",
"document",
"should",
"be",
"retrieved",
".",
"This",
"command",
"allows",
"you",
"to",
"do",
"things",
"like",
"combine",
"with",
"Get",
"to",
"fetch",
"a",
"document",
"with",
"certain",
"Xattrs"
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/collection_subdoc.go#L51-L58 |
9,567 | couchbase/gocb | collection_subdoc.go | Count | func (spec LookupInSpec) Count(path string, opts *LookupInSpecCountOptions) LookupInOp {
if opts == nil {
opts = &LookupInSpecCountOptions{}
}
var flags gocbcore.SubdocFlag
if opts.IsXattr {
flags |= gocbcore.SubdocFlag(SubdocFlagXattr)
}
op := gocbcore.SubDocOp{
Op: gocbcore.SubDocOpGetCount,
Path: path,
Flags: gocbcore.SubdocFlag(flags),
}
return LookupInOp{op: op}
} | go | func (spec LookupInSpec) Count(path string, opts *LookupInSpecCountOptions) LookupInOp {
if opts == nil {
opts = &LookupInSpecCountOptions{}
}
var flags gocbcore.SubdocFlag
if opts.IsXattr {
flags |= gocbcore.SubdocFlag(SubdocFlagXattr)
}
op := gocbcore.SubDocOp{
Op: gocbcore.SubDocOpGetCount,
Path: path,
Flags: gocbcore.SubdocFlag(flags),
}
return LookupInOp{op: op}
} | [
"func",
"(",
"spec",
"LookupInSpec",
")",
"Count",
"(",
"path",
"string",
",",
"opts",
"*",
"LookupInSpecCountOptions",
")",
"LookupInOp",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"&",
"LookupInSpecCountOptions",
"{",
"}",
"\n",
"}",
"\n\n",
"var",
"flags",
"gocbcore",
".",
"SubdocFlag",
"\n",
"if",
"opts",
".",
"IsXattr",
"{",
"flags",
"|=",
"gocbcore",
".",
"SubdocFlag",
"(",
"SubdocFlagXattr",
")",
"\n",
"}",
"\n\n",
"op",
":=",
"gocbcore",
".",
"SubDocOp",
"{",
"Op",
":",
"gocbcore",
".",
"SubDocOpGetCount",
",",
"Path",
":",
"path",
",",
"Flags",
":",
"gocbcore",
".",
"SubdocFlag",
"(",
"flags",
")",
",",
"}",
"\n\n",
"return",
"LookupInOp",
"{",
"op",
":",
"op",
"}",
"\n",
"}"
]
| // Count allows you to retrieve the number of items in an array or keys within an
// dictionary within an element of a document. | [
"Count",
"allows",
"you",
"to",
"retrieve",
"the",
"number",
"of",
"items",
"in",
"an",
"array",
"or",
"keys",
"within",
"an",
"dictionary",
"within",
"an",
"element",
"of",
"a",
"document",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/collection_subdoc.go#L110-L127 |
9,568 | couchbase/gocb | collection_subdoc.go | LookupIn | func (c *Collection) LookupIn(key string, ops []LookupInOp, opts *LookupInOptions) (docOut *LookupInResult, errOut error) {
if opts == nil {
opts = &LookupInOptions{}
}
// Only update ctx if necessary, this means that the original ctx.Done() signal will be triggered as expected
ctx, cancel := c.context(opts.Context, opts.Timeout)
if cancel != nil {
defer cancel()
}
span := c.startKvOpTrace(opts.ParentSpanContext, "LookupIn")
defer span.Finish()
res, err := c.lookupIn(ctx, span.Context(), key, ops, *opts)
if err != nil {
return nil, err
}
return res, nil
} | go | func (c *Collection) LookupIn(key string, ops []LookupInOp, opts *LookupInOptions) (docOut *LookupInResult, errOut error) {
if opts == nil {
opts = &LookupInOptions{}
}
// Only update ctx if necessary, this means that the original ctx.Done() signal will be triggered as expected
ctx, cancel := c.context(opts.Context, opts.Timeout)
if cancel != nil {
defer cancel()
}
span := c.startKvOpTrace(opts.ParentSpanContext, "LookupIn")
defer span.Finish()
res, err := c.lookupIn(ctx, span.Context(), key, ops, *opts)
if err != nil {
return nil, err
}
return res, nil
} | [
"func",
"(",
"c",
"*",
"Collection",
")",
"LookupIn",
"(",
"key",
"string",
",",
"ops",
"[",
"]",
"LookupInOp",
",",
"opts",
"*",
"LookupInOptions",
")",
"(",
"docOut",
"*",
"LookupInResult",
",",
"errOut",
"error",
")",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"&",
"LookupInOptions",
"{",
"}",
"\n",
"}",
"\n\n",
"// Only update ctx if necessary, this means that the original ctx.Done() signal will be triggered as expected",
"ctx",
",",
"cancel",
":=",
"c",
".",
"context",
"(",
"opts",
".",
"Context",
",",
"opts",
".",
"Timeout",
")",
"\n",
"if",
"cancel",
"!=",
"nil",
"{",
"defer",
"cancel",
"(",
")",
"\n",
"}",
"\n\n",
"span",
":=",
"c",
".",
"startKvOpTrace",
"(",
"opts",
".",
"ParentSpanContext",
",",
"\"",
"\"",
")",
"\n",
"defer",
"span",
".",
"Finish",
"(",
")",
"\n\n",
"res",
",",
"err",
":=",
"c",
".",
"lookupIn",
"(",
"ctx",
",",
"span",
".",
"Context",
"(",
")",
",",
"key",
",",
"ops",
",",
"*",
"opts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"res",
",",
"nil",
"\n",
"}"
]
| // LookupIn performs a set of subdocument lookup operations on the document identified by key. | [
"LookupIn",
"performs",
"a",
"set",
"of",
"subdocument",
"lookup",
"operations",
"on",
"the",
"document",
"identified",
"by",
"key",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/collection_subdoc.go#L130-L150 |
9,569 | couchbase/gocb | collection_subdoc.go | UpsertFull | func (spec MutateInSpec) UpsertFull(val interface{}, opts *MutateInSpecUpsertFullOptions) MutateInOp {
if opts == nil {
opts = &MutateInSpecUpsertFullOptions{}
}
encoder := opts.Encoder
if opts.Encoder == nil {
encoder = JSONEncode
}
marshaled, _, err := encoder(val)
if err != nil {
return MutateInOp{err: err}
}
op := gocbcore.SubDocOp{
Op: gocbcore.SubDocOpSetDoc,
Flags: gocbcore.SubdocFlag(SubdocFlagNone),
Value: marshaled,
}
return MutateInOp{op: op}
} | go | func (spec MutateInSpec) UpsertFull(val interface{}, opts *MutateInSpecUpsertFullOptions) MutateInOp {
if opts == nil {
opts = &MutateInSpecUpsertFullOptions{}
}
encoder := opts.Encoder
if opts.Encoder == nil {
encoder = JSONEncode
}
marshaled, _, err := encoder(val)
if err != nil {
return MutateInOp{err: err}
}
op := gocbcore.SubDocOp{
Op: gocbcore.SubDocOpSetDoc,
Flags: gocbcore.SubdocFlag(SubdocFlagNone),
Value: marshaled,
}
return MutateInOp{op: op}
} | [
"func",
"(",
"spec",
"MutateInSpec",
")",
"UpsertFull",
"(",
"val",
"interface",
"{",
"}",
",",
"opts",
"*",
"MutateInSpecUpsertFullOptions",
")",
"MutateInOp",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"&",
"MutateInSpecUpsertFullOptions",
"{",
"}",
"\n",
"}",
"\n\n",
"encoder",
":=",
"opts",
".",
"Encoder",
"\n",
"if",
"opts",
".",
"Encoder",
"==",
"nil",
"{",
"encoder",
"=",
"JSONEncode",
"\n",
"}",
"\n\n",
"marshaled",
",",
"_",
",",
"err",
":=",
"encoder",
"(",
"val",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"MutateInOp",
"{",
"err",
":",
"err",
"}",
"\n",
"}",
"\n\n",
"op",
":=",
"gocbcore",
".",
"SubDocOp",
"{",
"Op",
":",
"gocbcore",
".",
"SubDocOpSetDoc",
",",
"Flags",
":",
"gocbcore",
".",
"SubdocFlag",
"(",
"SubdocFlagNone",
")",
",",
"Value",
":",
"marshaled",
",",
"}",
"\n\n",
"return",
"MutateInOp",
"{",
"op",
":",
"op",
"}",
"\n",
"}"
]
| // UpsertFull creates a new document if it does not exist, if it does exist then it
// updates it. This command allows you to do things like updating xattrs whilst upserting
// a document. | [
"UpsertFull",
"creates",
"a",
"new",
"document",
"if",
"it",
"does",
"not",
"exist",
"if",
"it",
"does",
"exist",
"then",
"it",
"updates",
"it",
".",
"This",
"command",
"allows",
"you",
"to",
"do",
"things",
"like",
"updating",
"xattrs",
"whilst",
"upserting",
"a",
"document",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/collection_subdoc.go#L374-L396 |
9,570 | couchbase/gocb | collection_subdoc.go | Replace | func (spec MutateInSpec) Replace(path string, val interface{}, opts *MutateInSpecReplaceOptions) MutateInOp {
if opts == nil {
opts = &MutateInSpecReplaceOptions{}
}
var flags SubdocFlag
if opts.IsXattr {
flags |= SubdocFlagXattr
}
encoder := opts.Encoder
if opts.Encoder == nil {
encoder = JSONEncode
}
marshaled, _, err := encoder(val)
if err != nil {
return MutateInOp{err: err}
}
op := gocbcore.SubDocOp{
Op: gocbcore.SubDocOpReplace,
Path: path,
Flags: gocbcore.SubdocFlag(flags),
Value: marshaled,
}
return MutateInOp{op: op}
} | go | func (spec MutateInSpec) Replace(path string, val interface{}, opts *MutateInSpecReplaceOptions) MutateInOp {
if opts == nil {
opts = &MutateInSpecReplaceOptions{}
}
var flags SubdocFlag
if opts.IsXattr {
flags |= SubdocFlagXattr
}
encoder := opts.Encoder
if opts.Encoder == nil {
encoder = JSONEncode
}
marshaled, _, err := encoder(val)
if err != nil {
return MutateInOp{err: err}
}
op := gocbcore.SubDocOp{
Op: gocbcore.SubDocOpReplace,
Path: path,
Flags: gocbcore.SubdocFlag(flags),
Value: marshaled,
}
return MutateInOp{op: op}
} | [
"func",
"(",
"spec",
"MutateInSpec",
")",
"Replace",
"(",
"path",
"string",
",",
"val",
"interface",
"{",
"}",
",",
"opts",
"*",
"MutateInSpecReplaceOptions",
")",
"MutateInOp",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"&",
"MutateInSpecReplaceOptions",
"{",
"}",
"\n",
"}",
"\n",
"var",
"flags",
"SubdocFlag",
"\n",
"if",
"opts",
".",
"IsXattr",
"{",
"flags",
"|=",
"SubdocFlagXattr",
"\n",
"}",
"\n\n",
"encoder",
":=",
"opts",
".",
"Encoder",
"\n",
"if",
"opts",
".",
"Encoder",
"==",
"nil",
"{",
"encoder",
"=",
"JSONEncode",
"\n",
"}",
"\n\n",
"marshaled",
",",
"_",
",",
"err",
":=",
"encoder",
"(",
"val",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"MutateInOp",
"{",
"err",
":",
"err",
"}",
"\n",
"}",
"\n\n",
"op",
":=",
"gocbcore",
".",
"SubDocOp",
"{",
"Op",
":",
"gocbcore",
".",
"SubDocOpReplace",
",",
"Path",
":",
"path",
",",
"Flags",
":",
"gocbcore",
".",
"SubdocFlag",
"(",
"flags",
")",
",",
"Value",
":",
"marshaled",
",",
"}",
"\n\n",
"return",
"MutateInOp",
"{",
"op",
":",
"op",
"}",
"\n",
"}"
]
| // Replace replaces the value of the field at path. | [
"Replace",
"replaces",
"the",
"value",
"of",
"the",
"field",
"at",
"path",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/collection_subdoc.go#L405-L432 |
9,571 | couchbase/gocb | collection_subdoc.go | Remove | func (spec MutateInSpec) Remove(path string, opts *MutateInSpecRemoveOptions) MutateInOp {
if opts == nil {
opts = &MutateInSpecRemoveOptions{}
}
var flags SubdocFlag
if opts.IsXattr {
flags |= SubdocFlagXattr
}
op := gocbcore.SubDocOp{
Op: gocbcore.SubDocOpDelete,
Path: path,
Flags: gocbcore.SubdocFlag(flags),
}
return MutateInOp{op: op}
} | go | func (spec MutateInSpec) Remove(path string, opts *MutateInSpecRemoveOptions) MutateInOp {
if opts == nil {
opts = &MutateInSpecRemoveOptions{}
}
var flags SubdocFlag
if opts.IsXattr {
flags |= SubdocFlagXattr
}
op := gocbcore.SubDocOp{
Op: gocbcore.SubDocOpDelete,
Path: path,
Flags: gocbcore.SubdocFlag(flags),
}
return MutateInOp{op: op}
} | [
"func",
"(",
"spec",
"MutateInSpec",
")",
"Remove",
"(",
"path",
"string",
",",
"opts",
"*",
"MutateInSpecRemoveOptions",
")",
"MutateInOp",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"&",
"MutateInSpecRemoveOptions",
"{",
"}",
"\n",
"}",
"\n",
"var",
"flags",
"SubdocFlag",
"\n",
"if",
"opts",
".",
"IsXattr",
"{",
"flags",
"|=",
"SubdocFlagXattr",
"\n",
"}",
"\n\n",
"op",
":=",
"gocbcore",
".",
"SubDocOp",
"{",
"Op",
":",
"gocbcore",
".",
"SubDocOpDelete",
",",
"Path",
":",
"path",
",",
"Flags",
":",
"gocbcore",
".",
"SubdocFlag",
"(",
"flags",
")",
",",
"}",
"\n\n",
"return",
"MutateInOp",
"{",
"op",
":",
"op",
"}",
"\n",
"}"
]
| // Remove removes the field at path. | [
"Remove",
"removes",
"the",
"field",
"at",
"path",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/collection_subdoc.go#L440-L456 |
9,572 | couchbase/gocb | collection_subdoc.go | RemoveFull | func (spec MutateInSpec) RemoveFull() (*MutateInOp, error) {
op := gocbcore.SubDocOp{
Op: gocbcore.SubDocOpDeleteDoc,
Flags: gocbcore.SubdocFlag(SubdocFlagNone),
}
return &MutateInOp{op: op}, nil
} | go | func (spec MutateInSpec) RemoveFull() (*MutateInOp, error) {
op := gocbcore.SubDocOp{
Op: gocbcore.SubDocOpDeleteDoc,
Flags: gocbcore.SubdocFlag(SubdocFlagNone),
}
return &MutateInOp{op: op}, nil
} | [
"func",
"(",
"spec",
"MutateInSpec",
")",
"RemoveFull",
"(",
")",
"(",
"*",
"MutateInOp",
",",
"error",
")",
"{",
"op",
":=",
"gocbcore",
".",
"SubDocOp",
"{",
"Op",
":",
"gocbcore",
".",
"SubDocOpDeleteDoc",
",",
"Flags",
":",
"gocbcore",
".",
"SubdocFlag",
"(",
"SubdocFlagNone",
")",
",",
"}",
"\n\n",
"return",
"&",
"MutateInOp",
"{",
"op",
":",
"op",
"}",
",",
"nil",
"\n",
"}"
]
| // RemoveFull removes the full document, including metadata. | [
"RemoveFull",
"removes",
"the",
"full",
"document",
"including",
"metadata",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/collection_subdoc.go#L459-L466 |
9,573 | couchbase/gocb | collection_subdoc.go | ArrayAddUnique | func (spec MutateInSpec) ArrayAddUnique(path string, val interface{}, opts *MutateInSpecArrayAddUniqueOptions) MutateInOp {
if opts == nil {
opts = &MutateInSpecArrayAddUniqueOptions{}
}
var flags SubdocFlag
_, ok := val.(MutationMacro)
if ok {
flags |= SubdocFlagUseMacros
opts.IsXattr = true
}
if opts.CreatePath {
flags |= SubdocFlagCreatePath
}
if opts.IsXattr {
flags |= SubdocFlagXattr
}
encoder := opts.Encoder
if opts.Encoder == nil {
encoder = JSONEncode
}
marshaled, _, err := encoder(val)
if err != nil {
return MutateInOp{err: err}
}
op := gocbcore.SubDocOp{
Op: gocbcore.SubDocOpArrayAddUnique,
Path: path,
Flags: gocbcore.SubdocFlag(flags),
Value: marshaled,
}
return MutateInOp{op: op}
} | go | func (spec MutateInSpec) ArrayAddUnique(path string, val interface{}, opts *MutateInSpecArrayAddUniqueOptions) MutateInOp {
if opts == nil {
opts = &MutateInSpecArrayAddUniqueOptions{}
}
var flags SubdocFlag
_, ok := val.(MutationMacro)
if ok {
flags |= SubdocFlagUseMacros
opts.IsXattr = true
}
if opts.CreatePath {
flags |= SubdocFlagCreatePath
}
if opts.IsXattr {
flags |= SubdocFlagXattr
}
encoder := opts.Encoder
if opts.Encoder == nil {
encoder = JSONEncode
}
marshaled, _, err := encoder(val)
if err != nil {
return MutateInOp{err: err}
}
op := gocbcore.SubDocOp{
Op: gocbcore.SubDocOpArrayAddUnique,
Path: path,
Flags: gocbcore.SubdocFlag(flags),
Value: marshaled,
}
return MutateInOp{op: op}
} | [
"func",
"(",
"spec",
"MutateInSpec",
")",
"ArrayAddUnique",
"(",
"path",
"string",
",",
"val",
"interface",
"{",
"}",
",",
"opts",
"*",
"MutateInSpecArrayAddUniqueOptions",
")",
"MutateInOp",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"&",
"MutateInSpecArrayAddUniqueOptions",
"{",
"}",
"\n",
"}",
"\n",
"var",
"flags",
"SubdocFlag",
"\n",
"_",
",",
"ok",
":=",
"val",
".",
"(",
"MutationMacro",
")",
"\n",
"if",
"ok",
"{",
"flags",
"|=",
"SubdocFlagUseMacros",
"\n",
"opts",
".",
"IsXattr",
"=",
"true",
"\n",
"}",
"\n\n",
"if",
"opts",
".",
"CreatePath",
"{",
"flags",
"|=",
"SubdocFlagCreatePath",
"\n",
"}",
"\n",
"if",
"opts",
".",
"IsXattr",
"{",
"flags",
"|=",
"SubdocFlagXattr",
"\n",
"}",
"\n\n",
"encoder",
":=",
"opts",
".",
"Encoder",
"\n",
"if",
"opts",
".",
"Encoder",
"==",
"nil",
"{",
"encoder",
"=",
"JSONEncode",
"\n",
"}",
"\n\n",
"marshaled",
",",
"_",
",",
"err",
":=",
"encoder",
"(",
"val",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"MutateInOp",
"{",
"err",
":",
"err",
"}",
"\n",
"}",
"\n\n",
"op",
":=",
"gocbcore",
".",
"SubDocOp",
"{",
"Op",
":",
"gocbcore",
".",
"SubDocOpArrayAddUnique",
",",
"Path",
":",
"path",
",",
"Flags",
":",
"gocbcore",
".",
"SubdocFlag",
"(",
"flags",
")",
",",
"Value",
":",
"marshaled",
",",
"}",
"\n\n",
"return",
"MutateInOp",
"{",
"op",
":",
"op",
"}",
"\n",
"}"
]
| // ArrayAddUnique adds an dictionary add unique operation to this mutation operation set. | [
"ArrayAddUnique",
"adds",
"an",
"dictionary",
"add",
"unique",
"operation",
"to",
"this",
"mutation",
"operation",
"set",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/collection_subdoc.go#L666-L702 |
9,574 | couchbase/gocb | collection_subdoc.go | Decrement | func (spec MutateInSpec) Decrement(path string, delta int64, opts *MutateInSpecCounterOptions) MutateInOp {
if opts == nil {
opts = &MutateInSpecCounterOptions{}
}
var flags SubdocFlag
if opts.CreatePath {
flags |= SubdocFlagCreatePath
}
if opts.IsXattr {
flags |= SubdocFlagXattr
}
encoder := opts.Encoder
if opts.Encoder == nil {
encoder = JSONEncode
}
marshaled, _, err := encoder(-delta)
if err != nil {
return MutateInOp{err: err}
}
op := gocbcore.SubDocOp{
Op: gocbcore.SubDocOpCounter,
Path: path,
Flags: gocbcore.SubdocFlag(flags),
Value: marshaled,
}
return MutateInOp{op: op}
} | go | func (spec MutateInSpec) Decrement(path string, delta int64, opts *MutateInSpecCounterOptions) MutateInOp {
if opts == nil {
opts = &MutateInSpecCounterOptions{}
}
var flags SubdocFlag
if opts.CreatePath {
flags |= SubdocFlagCreatePath
}
if opts.IsXattr {
flags |= SubdocFlagXattr
}
encoder := opts.Encoder
if opts.Encoder == nil {
encoder = JSONEncode
}
marshaled, _, err := encoder(-delta)
if err != nil {
return MutateInOp{err: err}
}
op := gocbcore.SubDocOp{
Op: gocbcore.SubDocOpCounter,
Path: path,
Flags: gocbcore.SubdocFlag(flags),
Value: marshaled,
}
return MutateInOp{op: op}
} | [
"func",
"(",
"spec",
"MutateInSpec",
")",
"Decrement",
"(",
"path",
"string",
",",
"delta",
"int64",
",",
"opts",
"*",
"MutateInSpecCounterOptions",
")",
"MutateInOp",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"&",
"MutateInSpecCounterOptions",
"{",
"}",
"\n",
"}",
"\n",
"var",
"flags",
"SubdocFlag",
"\n",
"if",
"opts",
".",
"CreatePath",
"{",
"flags",
"|=",
"SubdocFlagCreatePath",
"\n",
"}",
"\n",
"if",
"opts",
".",
"IsXattr",
"{",
"flags",
"|=",
"SubdocFlagXattr",
"\n",
"}",
"\n\n",
"encoder",
":=",
"opts",
".",
"Encoder",
"\n",
"if",
"opts",
".",
"Encoder",
"==",
"nil",
"{",
"encoder",
"=",
"JSONEncode",
"\n",
"}",
"\n\n",
"marshaled",
",",
"_",
",",
"err",
":=",
"encoder",
"(",
"-",
"delta",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"MutateInOp",
"{",
"err",
":",
"err",
"}",
"\n",
"}",
"\n",
"op",
":=",
"gocbcore",
".",
"SubDocOp",
"{",
"Op",
":",
"gocbcore",
".",
"SubDocOpCounter",
",",
"Path",
":",
"path",
",",
"Flags",
":",
"gocbcore",
".",
"SubdocFlag",
"(",
"flags",
")",
",",
"Value",
":",
"marshaled",
",",
"}",
"\n\n",
"return",
"MutateInOp",
"{",
"op",
":",
"op",
"}",
"\n",
"}"
]
| // Decrement adds a decrement operation to this mutation operation set. | [
"Decrement",
"adds",
"a",
"decrement",
"operation",
"to",
"this",
"mutation",
"operation",
"set",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/collection_subdoc.go#L744-L773 |
9,575 | couchbase/gocb | collection_subdoc.go | MutateIn | func (c *Collection) MutateIn(key string, ops []MutateInOp, opts *MutateInOptions) (mutOut *MutateInResult, errOut error) {
if opts == nil {
opts = &MutateInOptions{}
}
span := c.startKvOpTrace(opts.ParentSpanContext, "MutateIn")
defer span.Finish()
// Only update ctx if necessary, this means that the original ctx.Done() signal will be triggered as expected
ctx, cancel := c.context(opts.Context, opts.Timeout)
if cancel != nil {
defer cancel()
}
res, err := c.mutate(ctx, span.Context(), key, ops, *opts)
if err != nil {
return nil, err
}
if opts.PersistTo == 0 && opts.ReplicateTo == 0 {
return res, nil
}
return res, c.durability(durabilitySettings{
ctx: opts.Context,
tracectx: span.Context(),
key: key,
cas: res.Cas(),
mt: res.MutationToken(),
replicaTo: opts.ReplicateTo,
persistTo: opts.PersistTo,
forDelete: false,
scopeName: c.scopeName(),
collectionName: c.name(),
})
} | go | func (c *Collection) MutateIn(key string, ops []MutateInOp, opts *MutateInOptions) (mutOut *MutateInResult, errOut error) {
if opts == nil {
opts = &MutateInOptions{}
}
span := c.startKvOpTrace(opts.ParentSpanContext, "MutateIn")
defer span.Finish()
// Only update ctx if necessary, this means that the original ctx.Done() signal will be triggered as expected
ctx, cancel := c.context(opts.Context, opts.Timeout)
if cancel != nil {
defer cancel()
}
res, err := c.mutate(ctx, span.Context(), key, ops, *opts)
if err != nil {
return nil, err
}
if opts.PersistTo == 0 && opts.ReplicateTo == 0 {
return res, nil
}
return res, c.durability(durabilitySettings{
ctx: opts.Context,
tracectx: span.Context(),
key: key,
cas: res.Cas(),
mt: res.MutationToken(),
replicaTo: opts.ReplicateTo,
persistTo: opts.PersistTo,
forDelete: false,
scopeName: c.scopeName(),
collectionName: c.name(),
})
} | [
"func",
"(",
"c",
"*",
"Collection",
")",
"MutateIn",
"(",
"key",
"string",
",",
"ops",
"[",
"]",
"MutateInOp",
",",
"opts",
"*",
"MutateInOptions",
")",
"(",
"mutOut",
"*",
"MutateInResult",
",",
"errOut",
"error",
")",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"&",
"MutateInOptions",
"{",
"}",
"\n",
"}",
"\n\n",
"span",
":=",
"c",
".",
"startKvOpTrace",
"(",
"opts",
".",
"ParentSpanContext",
",",
"\"",
"\"",
")",
"\n",
"defer",
"span",
".",
"Finish",
"(",
")",
"\n\n",
"// Only update ctx if necessary, this means that the original ctx.Done() signal will be triggered as expected",
"ctx",
",",
"cancel",
":=",
"c",
".",
"context",
"(",
"opts",
".",
"Context",
",",
"opts",
".",
"Timeout",
")",
"\n",
"if",
"cancel",
"!=",
"nil",
"{",
"defer",
"cancel",
"(",
")",
"\n",
"}",
"\n\n",
"res",
",",
"err",
":=",
"c",
".",
"mutate",
"(",
"ctx",
",",
"span",
".",
"Context",
"(",
")",
",",
"key",
",",
"ops",
",",
"*",
"opts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"opts",
".",
"PersistTo",
"==",
"0",
"&&",
"opts",
".",
"ReplicateTo",
"==",
"0",
"{",
"return",
"res",
",",
"nil",
"\n",
"}",
"\n",
"return",
"res",
",",
"c",
".",
"durability",
"(",
"durabilitySettings",
"{",
"ctx",
":",
"opts",
".",
"Context",
",",
"tracectx",
":",
"span",
".",
"Context",
"(",
")",
",",
"key",
":",
"key",
",",
"cas",
":",
"res",
".",
"Cas",
"(",
")",
",",
"mt",
":",
"res",
".",
"MutationToken",
"(",
")",
",",
"replicaTo",
":",
"opts",
".",
"ReplicateTo",
",",
"persistTo",
":",
"opts",
".",
"PersistTo",
",",
"forDelete",
":",
"false",
",",
"scopeName",
":",
"c",
".",
"scopeName",
"(",
")",
",",
"collectionName",
":",
"c",
".",
"name",
"(",
")",
",",
"}",
")",
"\n",
"}"
]
| // MutateIn performs a set of subdocument mutations on the document specified by key. | [
"MutateIn",
"performs",
"a",
"set",
"of",
"subdocument",
"mutations",
"on",
"the",
"document",
"specified",
"by",
"key",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/collection_subdoc.go#L776-L810 |
9,576 | couchbase/gocb | collection_binary_crud.go | Append | func (c *CollectionBinary) Append(key string, val []byte, opts *AppendOptions) (mutOut *MutationResult, errOut error) {
if opts == nil {
opts = &AppendOptions{}
}
span := c.startKvOpTrace(opts.ParentSpanContext, "BinaryAppend")
defer span.Finish()
// Only update ctx if necessary, this means that the original ctx.Done() signal will be triggered as expected
ctx, cancel := c.context(opts.Context, opts.Timeout)
if cancel != nil {
defer cancel()
}
res, err := c.append(ctx, span.Context(), key, val, *opts)
if err != nil {
return nil, err
}
return res, nil
} | go | func (c *CollectionBinary) Append(key string, val []byte, opts *AppendOptions) (mutOut *MutationResult, errOut error) {
if opts == nil {
opts = &AppendOptions{}
}
span := c.startKvOpTrace(opts.ParentSpanContext, "BinaryAppend")
defer span.Finish()
// Only update ctx if necessary, this means that the original ctx.Done() signal will be triggered as expected
ctx, cancel := c.context(opts.Context, opts.Timeout)
if cancel != nil {
defer cancel()
}
res, err := c.append(ctx, span.Context(), key, val, *opts)
if err != nil {
return nil, err
}
return res, nil
} | [
"func",
"(",
"c",
"*",
"CollectionBinary",
")",
"Append",
"(",
"key",
"string",
",",
"val",
"[",
"]",
"byte",
",",
"opts",
"*",
"AppendOptions",
")",
"(",
"mutOut",
"*",
"MutationResult",
",",
"errOut",
"error",
")",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"&",
"AppendOptions",
"{",
"}",
"\n",
"}",
"\n\n",
"span",
":=",
"c",
".",
"startKvOpTrace",
"(",
"opts",
".",
"ParentSpanContext",
",",
"\"",
"\"",
")",
"\n",
"defer",
"span",
".",
"Finish",
"(",
")",
"\n\n",
"// Only update ctx if necessary, this means that the original ctx.Done() signal will be triggered as expected",
"ctx",
",",
"cancel",
":=",
"c",
".",
"context",
"(",
"opts",
".",
"Context",
",",
"opts",
".",
"Timeout",
")",
"\n",
"if",
"cancel",
"!=",
"nil",
"{",
"defer",
"cancel",
"(",
")",
"\n",
"}",
"\n\n",
"res",
",",
"err",
":=",
"c",
".",
"append",
"(",
"ctx",
",",
"span",
".",
"Context",
"(",
")",
",",
"key",
",",
"val",
",",
"*",
"opts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"res",
",",
"nil",
"\n",
"}"
]
| // Append appends a byte value to a document. | [
"Append",
"appends",
"a",
"byte",
"value",
"to",
"a",
"document",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/collection_binary_crud.go#L24-L44 |
9,577 | couchbase/gocb | collection_binary_crud.go | Prepend | func (c *CollectionBinary) Prepend(key string, val []byte, opts *PrependOptions) (mutOut *MutationResult, errOut error) {
if opts == nil {
opts = &PrependOptions{}
}
span := c.startKvOpTrace(opts.ParentSpanContext, "BinaryPrepend")
defer span.Finish()
// Only update ctx if necessary, this means that the original ctx.Done() signal will be triggered as expected
ctx, cancel := c.context(opts.Context, opts.Timeout)
if cancel != nil {
defer cancel()
}
res, err := c.prepend(ctx, span.Context(), key, val, *opts)
if err != nil {
return nil, err
}
return res, nil
} | go | func (c *CollectionBinary) Prepend(key string, val []byte, opts *PrependOptions) (mutOut *MutationResult, errOut error) {
if opts == nil {
opts = &PrependOptions{}
}
span := c.startKvOpTrace(opts.ParentSpanContext, "BinaryPrepend")
defer span.Finish()
// Only update ctx if necessary, this means that the original ctx.Done() signal will be triggered as expected
ctx, cancel := c.context(opts.Context, opts.Timeout)
if cancel != nil {
defer cancel()
}
res, err := c.prepend(ctx, span.Context(), key, val, *opts)
if err != nil {
return nil, err
}
return res, nil
} | [
"func",
"(",
"c",
"*",
"CollectionBinary",
")",
"Prepend",
"(",
"key",
"string",
",",
"val",
"[",
"]",
"byte",
",",
"opts",
"*",
"PrependOptions",
")",
"(",
"mutOut",
"*",
"MutationResult",
",",
"errOut",
"error",
")",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"&",
"PrependOptions",
"{",
"}",
"\n",
"}",
"\n\n",
"span",
":=",
"c",
".",
"startKvOpTrace",
"(",
"opts",
".",
"ParentSpanContext",
",",
"\"",
"\"",
")",
"\n",
"defer",
"span",
".",
"Finish",
"(",
")",
"\n\n",
"// Only update ctx if necessary, this means that the original ctx.Done() signal will be triggered as expected",
"ctx",
",",
"cancel",
":=",
"c",
".",
"context",
"(",
"opts",
".",
"Context",
",",
"opts",
".",
"Timeout",
")",
"\n",
"if",
"cancel",
"!=",
"nil",
"{",
"defer",
"cancel",
"(",
")",
"\n",
"}",
"\n\n",
"res",
",",
"err",
":=",
"c",
".",
"prepend",
"(",
"ctx",
",",
"span",
".",
"Context",
"(",
")",
",",
"key",
",",
"val",
",",
"*",
"opts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"res",
",",
"nil",
"\n",
"}"
]
| // Prepend prepends a byte value to a document. | [
"Prepend",
"prepends",
"a",
"byte",
"value",
"to",
"a",
"document",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/collection_binary_crud.go#L92-L112 |
9,578 | couchbase/gocb | collection_binary_crud.go | Decrement | func (c *CollectionBinary) Decrement(key string, opts *CounterOptions) (countOut *CounterResult, errOut error) {
if opts == nil {
opts = &CounterOptions{}
}
span := c.startKvOpTrace(opts.ParentSpanContext, "Decrement")
defer span.Finish()
// Only update ctx if necessary, this means that the original ctx.Done() signal will be triggered as expected
ctx, cancel := c.context(opts.Context, opts.Timeout)
if cancel != nil {
defer cancel()
}
res, err := c.decrement(ctx, span.Context(), key, *opts)
if err != nil {
return nil, err
}
return res, nil
} | go | func (c *CollectionBinary) Decrement(key string, opts *CounterOptions) (countOut *CounterResult, errOut error) {
if opts == nil {
opts = &CounterOptions{}
}
span := c.startKvOpTrace(opts.ParentSpanContext, "Decrement")
defer span.Finish()
// Only update ctx if necessary, this means that the original ctx.Done() signal will be triggered as expected
ctx, cancel := c.context(opts.Context, opts.Timeout)
if cancel != nil {
defer cancel()
}
res, err := c.decrement(ctx, span.Context(), key, *opts)
if err != nil {
return nil, err
}
return res, nil
} | [
"func",
"(",
"c",
"*",
"CollectionBinary",
")",
"Decrement",
"(",
"key",
"string",
",",
"opts",
"*",
"CounterOptions",
")",
"(",
"countOut",
"*",
"CounterResult",
",",
"errOut",
"error",
")",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"&",
"CounterOptions",
"{",
"}",
"\n",
"}",
"\n\n",
"span",
":=",
"c",
".",
"startKvOpTrace",
"(",
"opts",
".",
"ParentSpanContext",
",",
"\"",
"\"",
")",
"\n",
"defer",
"span",
".",
"Finish",
"(",
")",
"\n\n",
"// Only update ctx if necessary, this means that the original ctx.Done() signal will be triggered as expected",
"ctx",
",",
"cancel",
":=",
"c",
".",
"context",
"(",
"opts",
".",
"Context",
",",
"opts",
".",
"Timeout",
")",
"\n",
"if",
"cancel",
"!=",
"nil",
"{",
"defer",
"cancel",
"(",
")",
"\n",
"}",
"\n\n",
"res",
",",
"err",
":=",
"c",
".",
"decrement",
"(",
"ctx",
",",
"span",
".",
"Context",
"(",
")",
",",
"key",
",",
"*",
"opts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"res",
",",
"nil",
"\n",
"}"
]
| // Decrement performs an atomic subtraction for an integer document. Passing a
// non-negative `initial` value will cause the document to be created if it did not
// already exist. | [
"Decrement",
"performs",
"an",
"atomic",
"subtraction",
"for",
"an",
"integer",
"document",
".",
"Passing",
"a",
"non",
"-",
"negative",
"initial",
"value",
"will",
"cause",
"the",
"document",
"to",
"be",
"created",
"if",
"it",
"did",
"not",
"already",
"exist",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/collection_binary_crud.go#L245-L265 |
9,579 | couchbase/gocb | bucket_viewquery.go | ViewQuery | func (b *Bucket) ViewQuery(designDoc string, viewName string, opts *ViewOptions) (*ViewResults, error) {
if opts == nil {
opts = &ViewOptions{}
}
ctx := opts.Context
if ctx == nil {
ctx = context.Background()
}
var span opentracing.Span
if opts.ParentSpanContext == nil {
span = opentracing.GlobalTracer().StartSpan("ExecuteViewQuery",
opentracing.Tag{Key: "couchbase.service", Value: "views"})
} else {
span = opentracing.GlobalTracer().StartSpan("ExecuteViewQuery",
opentracing.Tag{Key: "couchbase.service", Value: "views"}, opentracing.ChildOf(opts.ParentSpanContext))
}
defer span.Finish()
cli := b.sb.getCachedClient()
provider, err := cli.getHTTPProvider()
if err != nil {
return nil, err
}
designDoc = b.maybePrefixDevDocument(opts.Development, designDoc)
urlValues, err := opts.toURLValues()
if err != nil {
return nil, errors.Wrap(err, "could not parse query options")
}
return b.executeViewQuery(ctx, span.Context(), "_view", designDoc, viewName, *urlValues, provider)
} | go | func (b *Bucket) ViewQuery(designDoc string, viewName string, opts *ViewOptions) (*ViewResults, error) {
if opts == nil {
opts = &ViewOptions{}
}
ctx := opts.Context
if ctx == nil {
ctx = context.Background()
}
var span opentracing.Span
if opts.ParentSpanContext == nil {
span = opentracing.GlobalTracer().StartSpan("ExecuteViewQuery",
opentracing.Tag{Key: "couchbase.service", Value: "views"})
} else {
span = opentracing.GlobalTracer().StartSpan("ExecuteViewQuery",
opentracing.Tag{Key: "couchbase.service", Value: "views"}, opentracing.ChildOf(opts.ParentSpanContext))
}
defer span.Finish()
cli := b.sb.getCachedClient()
provider, err := cli.getHTTPProvider()
if err != nil {
return nil, err
}
designDoc = b.maybePrefixDevDocument(opts.Development, designDoc)
urlValues, err := opts.toURLValues()
if err != nil {
return nil, errors.Wrap(err, "could not parse query options")
}
return b.executeViewQuery(ctx, span.Context(), "_view", designDoc, viewName, *urlValues, provider)
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"ViewQuery",
"(",
"designDoc",
"string",
",",
"viewName",
"string",
",",
"opts",
"*",
"ViewOptions",
")",
"(",
"*",
"ViewResults",
",",
"error",
")",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"&",
"ViewOptions",
"{",
"}",
"\n",
"}",
"\n",
"ctx",
":=",
"opts",
".",
"Context",
"\n",
"if",
"ctx",
"==",
"nil",
"{",
"ctx",
"=",
"context",
".",
"Background",
"(",
")",
"\n",
"}",
"\n\n",
"var",
"span",
"opentracing",
".",
"Span",
"\n",
"if",
"opts",
".",
"ParentSpanContext",
"==",
"nil",
"{",
"span",
"=",
"opentracing",
".",
"GlobalTracer",
"(",
")",
".",
"StartSpan",
"(",
"\"",
"\"",
",",
"opentracing",
".",
"Tag",
"{",
"Key",
":",
"\"",
"\"",
",",
"Value",
":",
"\"",
"\"",
"}",
")",
"\n",
"}",
"else",
"{",
"span",
"=",
"opentracing",
".",
"GlobalTracer",
"(",
")",
".",
"StartSpan",
"(",
"\"",
"\"",
",",
"opentracing",
".",
"Tag",
"{",
"Key",
":",
"\"",
"\"",
",",
"Value",
":",
"\"",
"\"",
"}",
",",
"opentracing",
".",
"ChildOf",
"(",
"opts",
".",
"ParentSpanContext",
")",
")",
"\n",
"}",
"\n",
"defer",
"span",
".",
"Finish",
"(",
")",
"\n\n",
"cli",
":=",
"b",
".",
"sb",
".",
"getCachedClient",
"(",
")",
"\n",
"provider",
",",
"err",
":=",
"cli",
".",
"getHTTPProvider",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"designDoc",
"=",
"b",
".",
"maybePrefixDevDocument",
"(",
"opts",
".",
"Development",
",",
"designDoc",
")",
"\n\n",
"urlValues",
",",
"err",
":=",
"opts",
".",
"toURLValues",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"b",
".",
"executeViewQuery",
"(",
"ctx",
",",
"span",
".",
"Context",
"(",
")",
",",
"\"",
"\"",
",",
"designDoc",
",",
"viewName",
",",
"*",
"urlValues",
",",
"provider",
")",
"\n",
"}"
]
| // ViewQuery performs a view query and returns a list of rows or an error. | [
"ViewQuery",
"performs",
"a",
"view",
"query",
"and",
"returns",
"a",
"list",
"of",
"rows",
"or",
"an",
"error",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/bucket_viewquery.go#L205-L238 |
9,580 | couchbase/gocb | bucket.go | DefaultCollection | func (b *Bucket) DefaultCollection(opts *CollectionOptions) *Collection {
return b.defaultScope().DefaultCollection(opts)
} | go | func (b *Bucket) DefaultCollection(opts *CollectionOptions) *Collection {
return b.defaultScope().DefaultCollection(opts)
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"DefaultCollection",
"(",
"opts",
"*",
"CollectionOptions",
")",
"*",
"Collection",
"{",
"return",
"b",
".",
"defaultScope",
"(",
")",
".",
"DefaultCollection",
"(",
"opts",
")",
"\n",
"}"
]
| // DefaultCollection returns an instance of the default collection. | [
"DefaultCollection",
"returns",
"an",
"instance",
"of",
"the",
"default",
"collection",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/bucket.go#L65-L67 |
9,581 | couchbase/gocb | searchquery_facet.go | NewTermFacet | func NewTermFacet(field string, size int) *TermFacet {
mq := &TermFacet{}
mq.data.Field = field
mq.data.Size = size
return mq
} | go | func NewTermFacet(field string, size int) *TermFacet {
mq := &TermFacet{}
mq.data.Field = field
mq.data.Size = size
return mq
} | [
"func",
"NewTermFacet",
"(",
"field",
"string",
",",
"size",
"int",
")",
"*",
"TermFacet",
"{",
"mq",
":=",
"&",
"TermFacet",
"{",
"}",
"\n",
"mq",
".",
"data",
".",
"Field",
"=",
"field",
"\n",
"mq",
".",
"data",
".",
"Size",
"=",
"size",
"\n",
"return",
"mq",
"\n",
"}"
]
| // NewTermFacet creates a new TermFacet | [
"NewTermFacet",
"creates",
"a",
"new",
"TermFacet"
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery_facet.go#L27-L32 |
9,582 | couchbase/gocb | searchquery_facet.go | AddRange | func (f *NumericFacet) AddRange(name string, start, end float64) *NumericFacet {
f.data.NumericRanges = append(f.data.NumericRanges, numericFacetRange{
Name: name,
Start: start,
End: end,
})
return f
} | go | func (f *NumericFacet) AddRange(name string, start, end float64) *NumericFacet {
f.data.NumericRanges = append(f.data.NumericRanges, numericFacetRange{
Name: name,
Start: start,
End: end,
})
return f
} | [
"func",
"(",
"f",
"*",
"NumericFacet",
")",
"AddRange",
"(",
"name",
"string",
",",
"start",
",",
"end",
"float64",
")",
"*",
"NumericFacet",
"{",
"f",
".",
"data",
".",
"NumericRanges",
"=",
"append",
"(",
"f",
".",
"data",
".",
"NumericRanges",
",",
"numericFacetRange",
"{",
"Name",
":",
"name",
",",
"Start",
":",
"start",
",",
"End",
":",
"end",
",",
"}",
")",
"\n",
"return",
"f",
"\n",
"}"
]
| // AddRange adds a new range to this numeric range facet. | [
"AddRange",
"adds",
"a",
"new",
"range",
"to",
"this",
"numeric",
"range",
"facet",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery_facet.go#L56-L63 |
9,583 | couchbase/gocb | searchquery_facet.go | NewNumericFacet | func NewNumericFacet(field string, size int) *NumericFacet {
mq := &NumericFacet{}
mq.data.Field = field
mq.data.Size = size
return mq
} | go | func NewNumericFacet(field string, size int) *NumericFacet {
mq := &NumericFacet{}
mq.data.Field = field
mq.data.Size = size
return mq
} | [
"func",
"NewNumericFacet",
"(",
"field",
"string",
",",
"size",
"int",
")",
"*",
"NumericFacet",
"{",
"mq",
":=",
"&",
"NumericFacet",
"{",
"}",
"\n",
"mq",
".",
"data",
".",
"Field",
"=",
"field",
"\n",
"mq",
".",
"data",
".",
"Size",
"=",
"size",
"\n",
"return",
"mq",
"\n",
"}"
]
| // NewNumericFacet creates a new numeric range facet. | [
"NewNumericFacet",
"creates",
"a",
"new",
"numeric",
"range",
"facet",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery_facet.go#L66-L71 |
9,584 | couchbase/gocb | searchquery_facet.go | AddRange | func (f *DateFacet) AddRange(name string, start, end string) *DateFacet {
f.data.DateRanges = append(f.data.DateRanges, dateFacetRange{
Name: name,
Start: start,
End: end,
})
return f
} | go | func (f *DateFacet) AddRange(name string, start, end string) *DateFacet {
f.data.DateRanges = append(f.data.DateRanges, dateFacetRange{
Name: name,
Start: start,
End: end,
})
return f
} | [
"func",
"(",
"f",
"*",
"DateFacet",
")",
"AddRange",
"(",
"name",
"string",
",",
"start",
",",
"end",
"string",
")",
"*",
"DateFacet",
"{",
"f",
".",
"data",
".",
"DateRanges",
"=",
"append",
"(",
"f",
".",
"data",
".",
"DateRanges",
",",
"dateFacetRange",
"{",
"Name",
":",
"name",
",",
"Start",
":",
"start",
",",
"End",
":",
"end",
",",
"}",
")",
"\n",
"return",
"f",
"\n",
"}"
]
| // AddRange adds a new range to this date range facet. | [
"AddRange",
"adds",
"a",
"new",
"range",
"to",
"this",
"date",
"range",
"facet",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery_facet.go#L95-L102 |
9,585 | couchbase/gocb | searchquery_facet.go | NewDateFacet | func NewDateFacet(field string, size int) *DateFacet {
mq := &DateFacet{}
mq.data.Field = field
mq.data.Size = size
return mq
} | go | func NewDateFacet(field string, size int) *DateFacet {
mq := &DateFacet{}
mq.data.Field = field
mq.data.Size = size
return mq
} | [
"func",
"NewDateFacet",
"(",
"field",
"string",
",",
"size",
"int",
")",
"*",
"DateFacet",
"{",
"mq",
":=",
"&",
"DateFacet",
"{",
"}",
"\n",
"mq",
".",
"data",
".",
"Field",
"=",
"field",
"\n",
"mq",
".",
"data",
".",
"Size",
"=",
"size",
"\n",
"return",
"mq",
"\n",
"}"
]
| // NewDateFacet creates a new date range facet. | [
"NewDateFacet",
"creates",
"a",
"new",
"date",
"range",
"facet",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/searchquery_facet.go#L105-L110 |
9,586 | couchbase/gocb | collection.go | startKvOpTrace | func (c *Collection) startKvOpTrace(parentSpanCtx opentracing.SpanContext, operationName string) opentracing.Span {
var span opentracing.Span
if parentSpanCtx == nil {
span = opentracing.GlobalTracer().StartSpan(operationName,
opentracing.Tag{Key: "couchbase.collection", Value: c.sb.CollectionName},
opentracing.Tag{Key: "couchbase.service", Value: "kv"})
} else {
span = opentracing.GlobalTracer().StartSpan(operationName,
opentracing.Tag{Key: "couchbase.collection", Value: c.sb.CollectionName},
opentracing.Tag{Key: "couchbase.service", Value: "kv"}, opentracing.ChildOf(parentSpanCtx))
}
return span
} | go | func (c *Collection) startKvOpTrace(parentSpanCtx opentracing.SpanContext, operationName string) opentracing.Span {
var span opentracing.Span
if parentSpanCtx == nil {
span = opentracing.GlobalTracer().StartSpan(operationName,
opentracing.Tag{Key: "couchbase.collection", Value: c.sb.CollectionName},
opentracing.Tag{Key: "couchbase.service", Value: "kv"})
} else {
span = opentracing.GlobalTracer().StartSpan(operationName,
opentracing.Tag{Key: "couchbase.collection", Value: c.sb.CollectionName},
opentracing.Tag{Key: "couchbase.service", Value: "kv"}, opentracing.ChildOf(parentSpanCtx))
}
return span
} | [
"func",
"(",
"c",
"*",
"Collection",
")",
"startKvOpTrace",
"(",
"parentSpanCtx",
"opentracing",
".",
"SpanContext",
",",
"operationName",
"string",
")",
"opentracing",
".",
"Span",
"{",
"var",
"span",
"opentracing",
".",
"Span",
"\n",
"if",
"parentSpanCtx",
"==",
"nil",
"{",
"span",
"=",
"opentracing",
".",
"GlobalTracer",
"(",
")",
".",
"StartSpan",
"(",
"operationName",
",",
"opentracing",
".",
"Tag",
"{",
"Key",
":",
"\"",
"\"",
",",
"Value",
":",
"c",
".",
"sb",
".",
"CollectionName",
"}",
",",
"opentracing",
".",
"Tag",
"{",
"Key",
":",
"\"",
"\"",
",",
"Value",
":",
"\"",
"\"",
"}",
")",
"\n",
"}",
"else",
"{",
"span",
"=",
"opentracing",
".",
"GlobalTracer",
"(",
")",
".",
"StartSpan",
"(",
"operationName",
",",
"opentracing",
".",
"Tag",
"{",
"Key",
":",
"\"",
"\"",
",",
"Value",
":",
"c",
".",
"sb",
".",
"CollectionName",
"}",
",",
"opentracing",
".",
"Tag",
"{",
"Key",
":",
"\"",
"\"",
",",
"Value",
":",
"\"",
"\"",
"}",
",",
"opentracing",
".",
"ChildOf",
"(",
"parentSpanCtx",
")",
")",
"\n",
"}",
"\n\n",
"return",
"span",
"\n",
"}"
]
| // startKvOpTrace starts a new span for a given operationName. If parentSpanCtx is not nil then the span will be a
// ChildOf that span context. | [
"startKvOpTrace",
"starts",
"a",
"new",
"span",
"for",
"a",
"given",
"operationName",
".",
"If",
"parentSpanCtx",
"is",
"not",
"nil",
"then",
"the",
"span",
"will",
"be",
"a",
"ChildOf",
"that",
"span",
"context",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/collection.go#L73-L86 |
9,587 | couchbase/gocb | transcoding.go | DefaultDecode | func DefaultDecode(bytes []byte, flags uint32, out interface{}) error {
valueType, compression := gocbcore.DecodeCommonFlags(flags)
// Make sure compression is disabled
if compression != gocbcore.NoCompression {
return clientError{"Unexpected value compression"}
}
// Normal types of decoding
if valueType == gocbcore.BinaryType {
switch typedOut := out.(type) {
case *[]byte:
*typedOut = bytes
return nil
case *interface{}:
*typedOut = bytes
return nil
default:
return clientError{"You must encode binary in a byte array or interface"}
}
} else if valueType == gocbcore.StringType {
switch typedOut := out.(type) {
case *string:
*typedOut = string(bytes)
return nil
case *interface{}:
*typedOut = string(bytes)
return nil
default:
return clientError{"You must encode a string in a string or interface"}
}
} else if valueType == gocbcore.JsonType {
err := json.Unmarshal(bytes, &out)
if err != nil {
return err
}
return nil
}
return clientError{"Unexpected flags value"}
} | go | func DefaultDecode(bytes []byte, flags uint32, out interface{}) error {
valueType, compression := gocbcore.DecodeCommonFlags(flags)
// Make sure compression is disabled
if compression != gocbcore.NoCompression {
return clientError{"Unexpected value compression"}
}
// Normal types of decoding
if valueType == gocbcore.BinaryType {
switch typedOut := out.(type) {
case *[]byte:
*typedOut = bytes
return nil
case *interface{}:
*typedOut = bytes
return nil
default:
return clientError{"You must encode binary in a byte array or interface"}
}
} else if valueType == gocbcore.StringType {
switch typedOut := out.(type) {
case *string:
*typedOut = string(bytes)
return nil
case *interface{}:
*typedOut = string(bytes)
return nil
default:
return clientError{"You must encode a string in a string or interface"}
}
} else if valueType == gocbcore.JsonType {
err := json.Unmarshal(bytes, &out)
if err != nil {
return err
}
return nil
}
return clientError{"Unexpected flags value"}
} | [
"func",
"DefaultDecode",
"(",
"bytes",
"[",
"]",
"byte",
",",
"flags",
"uint32",
",",
"out",
"interface",
"{",
"}",
")",
"error",
"{",
"valueType",
",",
"compression",
":=",
"gocbcore",
".",
"DecodeCommonFlags",
"(",
"flags",
")",
"\n\n",
"// Make sure compression is disabled",
"if",
"compression",
"!=",
"gocbcore",
".",
"NoCompression",
"{",
"return",
"clientError",
"{",
"\"",
"\"",
"}",
"\n",
"}",
"\n\n",
"// Normal types of decoding",
"if",
"valueType",
"==",
"gocbcore",
".",
"BinaryType",
"{",
"switch",
"typedOut",
":=",
"out",
".",
"(",
"type",
")",
"{",
"case",
"*",
"[",
"]",
"byte",
":",
"*",
"typedOut",
"=",
"bytes",
"\n",
"return",
"nil",
"\n",
"case",
"*",
"interface",
"{",
"}",
":",
"*",
"typedOut",
"=",
"bytes",
"\n",
"return",
"nil",
"\n",
"default",
":",
"return",
"clientError",
"{",
"\"",
"\"",
"}",
"\n",
"}",
"\n",
"}",
"else",
"if",
"valueType",
"==",
"gocbcore",
".",
"StringType",
"{",
"switch",
"typedOut",
":=",
"out",
".",
"(",
"type",
")",
"{",
"case",
"*",
"string",
":",
"*",
"typedOut",
"=",
"string",
"(",
"bytes",
")",
"\n",
"return",
"nil",
"\n",
"case",
"*",
"interface",
"{",
"}",
":",
"*",
"typedOut",
"=",
"string",
"(",
"bytes",
")",
"\n",
"return",
"nil",
"\n",
"default",
":",
"return",
"clientError",
"{",
"\"",
"\"",
"}",
"\n",
"}",
"\n",
"}",
"else",
"if",
"valueType",
"==",
"gocbcore",
".",
"JsonType",
"{",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"bytes",
",",
"&",
"out",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"clientError",
"{",
"\"",
"\"",
"}",
"\n",
"}"
]
| // DefaultDecode applies the default Couchbase transcoding behaviour to decode into a Go type. | [
"DefaultDecode",
"applies",
"the",
"default",
"Couchbase",
"transcoding",
"behaviour",
"to",
"decode",
"into",
"a",
"Go",
"type",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/transcoding.go#L16-L56 |
9,588 | couchbase/gocb | transcoding.go | DefaultEncode | func DefaultEncode(value interface{}) ([]byte, uint32, error) {
var bytes []byte
var flags uint32
var err error
switch typeValue := value.(type) {
case []byte:
bytes = typeValue
flags = gocbcore.EncodeCommonFlags(gocbcore.BinaryType, gocbcore.NoCompression)
case *[]byte:
bytes = *typeValue
flags = gocbcore.EncodeCommonFlags(gocbcore.BinaryType, gocbcore.NoCompression)
case string:
bytes = []byte(typeValue)
flags = gocbcore.EncodeCommonFlags(gocbcore.StringType, gocbcore.NoCompression)
case *string:
bytes = []byte(*typeValue)
flags = gocbcore.EncodeCommonFlags(gocbcore.StringType, gocbcore.NoCompression)
case *interface{}:
return DefaultEncode(*typeValue)
default:
bytes, err = json.Marshal(value)
if err != nil {
return nil, 0, err
}
flags = gocbcore.EncodeCommonFlags(gocbcore.JsonType, gocbcore.NoCompression)
}
// No compression supported currently
return bytes, flags, nil
} | go | func DefaultEncode(value interface{}) ([]byte, uint32, error) {
var bytes []byte
var flags uint32
var err error
switch typeValue := value.(type) {
case []byte:
bytes = typeValue
flags = gocbcore.EncodeCommonFlags(gocbcore.BinaryType, gocbcore.NoCompression)
case *[]byte:
bytes = *typeValue
flags = gocbcore.EncodeCommonFlags(gocbcore.BinaryType, gocbcore.NoCompression)
case string:
bytes = []byte(typeValue)
flags = gocbcore.EncodeCommonFlags(gocbcore.StringType, gocbcore.NoCompression)
case *string:
bytes = []byte(*typeValue)
flags = gocbcore.EncodeCommonFlags(gocbcore.StringType, gocbcore.NoCompression)
case *interface{}:
return DefaultEncode(*typeValue)
default:
bytes, err = json.Marshal(value)
if err != nil {
return nil, 0, err
}
flags = gocbcore.EncodeCommonFlags(gocbcore.JsonType, gocbcore.NoCompression)
}
// No compression supported currently
return bytes, flags, nil
} | [
"func",
"DefaultEncode",
"(",
"value",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"uint32",
",",
"error",
")",
"{",
"var",
"bytes",
"[",
"]",
"byte",
"\n",
"var",
"flags",
"uint32",
"\n",
"var",
"err",
"error",
"\n\n",
"switch",
"typeValue",
":=",
"value",
".",
"(",
"type",
")",
"{",
"case",
"[",
"]",
"byte",
":",
"bytes",
"=",
"typeValue",
"\n",
"flags",
"=",
"gocbcore",
".",
"EncodeCommonFlags",
"(",
"gocbcore",
".",
"BinaryType",
",",
"gocbcore",
".",
"NoCompression",
")",
"\n",
"case",
"*",
"[",
"]",
"byte",
":",
"bytes",
"=",
"*",
"typeValue",
"\n",
"flags",
"=",
"gocbcore",
".",
"EncodeCommonFlags",
"(",
"gocbcore",
".",
"BinaryType",
",",
"gocbcore",
".",
"NoCompression",
")",
"\n",
"case",
"string",
":",
"bytes",
"=",
"[",
"]",
"byte",
"(",
"typeValue",
")",
"\n",
"flags",
"=",
"gocbcore",
".",
"EncodeCommonFlags",
"(",
"gocbcore",
".",
"StringType",
",",
"gocbcore",
".",
"NoCompression",
")",
"\n",
"case",
"*",
"string",
":",
"bytes",
"=",
"[",
"]",
"byte",
"(",
"*",
"typeValue",
")",
"\n",
"flags",
"=",
"gocbcore",
".",
"EncodeCommonFlags",
"(",
"gocbcore",
".",
"StringType",
",",
"gocbcore",
".",
"NoCompression",
")",
"\n",
"case",
"*",
"interface",
"{",
"}",
":",
"return",
"DefaultEncode",
"(",
"*",
"typeValue",
")",
"\n",
"default",
":",
"bytes",
",",
"err",
"=",
"json",
".",
"Marshal",
"(",
"value",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"0",
",",
"err",
"\n",
"}",
"\n",
"flags",
"=",
"gocbcore",
".",
"EncodeCommonFlags",
"(",
"gocbcore",
".",
"JsonType",
",",
"gocbcore",
".",
"NoCompression",
")",
"\n",
"}",
"\n\n",
"// No compression supported currently",
"return",
"bytes",
",",
"flags",
",",
"nil",
"\n",
"}"
]
| // DefaultEncode applies the default Couchbase transcoding behaviour to encode a Go type.
// For a byte array this will return the value supplied with Binary flags.
// For a string this will return the value supplied with String flags.
// For anything else this will try to return the value JSON encoded supplied, with JSON flags. | [
"DefaultEncode",
"applies",
"the",
"default",
"Couchbase",
"transcoding",
"behaviour",
"to",
"encode",
"a",
"Go",
"type",
".",
"For",
"a",
"byte",
"array",
"this",
"will",
"return",
"the",
"value",
"supplied",
"with",
"Binary",
"flags",
".",
"For",
"a",
"string",
"this",
"will",
"return",
"the",
"value",
"supplied",
"with",
"String",
"flags",
".",
"For",
"anything",
"else",
"this",
"will",
"try",
"to",
"return",
"the",
"value",
"JSON",
"encoded",
"supplied",
"with",
"JSON",
"flags",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/transcoding.go#L62-L93 |
9,589 | couchbase/gocb | transcoding.go | JSONEncode | func JSONEncode(value interface{}) ([]byte, uint32, error) {
var bytes []byte
flags := gocbcore.EncodeCommonFlags(gocbcore.JsonType, gocbcore.NoCompression)
var err error
switch typeValue := value.(type) {
case []byte:
bytes = typeValue
case *[]byte:
bytes = *typeValue
case *interface{}:
return JSONEncode(*typeValue)
default:
bytes, err = json.Marshal(value)
if err != nil {
return nil, 0, err
}
}
// No compression supported currently
return bytes, flags, nil
} | go | func JSONEncode(value interface{}) ([]byte, uint32, error) {
var bytes []byte
flags := gocbcore.EncodeCommonFlags(gocbcore.JsonType, gocbcore.NoCompression)
var err error
switch typeValue := value.(type) {
case []byte:
bytes = typeValue
case *[]byte:
bytes = *typeValue
case *interface{}:
return JSONEncode(*typeValue)
default:
bytes, err = json.Marshal(value)
if err != nil {
return nil, 0, err
}
}
// No compression supported currently
return bytes, flags, nil
} | [
"func",
"JSONEncode",
"(",
"value",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"uint32",
",",
"error",
")",
"{",
"var",
"bytes",
"[",
"]",
"byte",
"\n",
"flags",
":=",
"gocbcore",
".",
"EncodeCommonFlags",
"(",
"gocbcore",
".",
"JsonType",
",",
"gocbcore",
".",
"NoCompression",
")",
"\n",
"var",
"err",
"error",
"\n\n",
"switch",
"typeValue",
":=",
"value",
".",
"(",
"type",
")",
"{",
"case",
"[",
"]",
"byte",
":",
"bytes",
"=",
"typeValue",
"\n",
"case",
"*",
"[",
"]",
"byte",
":",
"bytes",
"=",
"*",
"typeValue",
"\n",
"case",
"*",
"interface",
"{",
"}",
":",
"return",
"JSONEncode",
"(",
"*",
"typeValue",
")",
"\n",
"default",
":",
"bytes",
",",
"err",
"=",
"json",
".",
"Marshal",
"(",
"value",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"0",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"// No compression supported currently",
"return",
"bytes",
",",
"flags",
",",
"nil",
"\n",
"}"
]
| // JSONEncode applies JSON encoding to a Go type. For byte array data this will just return the value passed
// to it as bytes with flags set to JSON. | [
"JSONEncode",
"applies",
"JSON",
"encoding",
"to",
"a",
"Go",
"type",
".",
"For",
"byte",
"array",
"data",
"this",
"will",
"just",
"return",
"the",
"value",
"passed",
"to",
"it",
"as",
"bytes",
"with",
"flags",
"set",
"to",
"JSON",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/transcoding.go#L97-L119 |
9,590 | couchbase/gocb | transcoding.go | JSONDecode | func JSONDecode(bytes []byte, _ uint32, out interface{}) error {
switch typedOut := out.(type) {
case *[]byte:
*typedOut = bytes
return nil
case *interface{}:
*typedOut = bytes
return nil
default:
err := json.Unmarshal(bytes, &out)
if err != nil {
return err
}
return nil
}
} | go | func JSONDecode(bytes []byte, _ uint32, out interface{}) error {
switch typedOut := out.(type) {
case *[]byte:
*typedOut = bytes
return nil
case *interface{}:
*typedOut = bytes
return nil
default:
err := json.Unmarshal(bytes, &out)
if err != nil {
return err
}
return nil
}
} | [
"func",
"JSONDecode",
"(",
"bytes",
"[",
"]",
"byte",
",",
"_",
"uint32",
",",
"out",
"interface",
"{",
"}",
")",
"error",
"{",
"switch",
"typedOut",
":=",
"out",
".",
"(",
"type",
")",
"{",
"case",
"*",
"[",
"]",
"byte",
":",
"*",
"typedOut",
"=",
"bytes",
"\n",
"return",
"nil",
"\n",
"case",
"*",
"interface",
"{",
"}",
":",
"*",
"typedOut",
"=",
"bytes",
"\n",
"return",
"nil",
"\n",
"default",
":",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"bytes",
",",
"&",
"out",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
]
| // JSONDecode applies JSON decoding behaviour to decode into a Go type.
// This function will ignore any flags passed to it, including compression.
// If a byte array is supplied as the out parameter then it will assign the
// raw bytes to it.
// For anything else it will apply JSON Unmarshal. | [
"JSONDecode",
"applies",
"JSON",
"decoding",
"behaviour",
"to",
"decode",
"into",
"a",
"Go",
"type",
".",
"This",
"function",
"will",
"ignore",
"any",
"flags",
"passed",
"to",
"it",
"including",
"compression",
".",
"If",
"a",
"byte",
"array",
"is",
"supplied",
"as",
"the",
"out",
"parameter",
"then",
"it",
"will",
"assign",
"the",
"raw",
"bytes",
"to",
"it",
".",
"For",
"anything",
"else",
"it",
"will",
"apply",
"JSON",
"Unmarshal",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/transcoding.go#L126-L141 |
9,591 | couchbase/gocb | error.go | IsScopeMissingError | func IsScopeMissingError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusScopeUnknown)
}
return false
} | go | func IsScopeMissingError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusScopeUnknown)
}
return false
} | [
"func",
"IsScopeMissingError",
"(",
"err",
"error",
")",
"bool",
"{",
"cause",
":=",
"errors",
".",
"Cause",
"(",
"err",
")",
"\n",
"if",
"kvErr",
",",
"ok",
":=",
"cause",
".",
"(",
"KeyValueError",
")",
";",
"ok",
"&&",
"kvErr",
".",
"KVError",
"(",
")",
"{",
"return",
"kvErr",
".",
"StatusCode",
"(",
")",
"==",
"int",
"(",
"gocbcore",
".",
"StatusScopeUnknown",
")",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
]
| // IsScopeMissingError verifies whether or not the cause for an error is scope unknown | [
"IsScopeMissingError",
"verifies",
"whether",
"or",
"not",
"the",
"cause",
"for",
"an",
"error",
"is",
"scope",
"unknown"
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/error.go#L72-L79 |
9,592 | couchbase/gocb | error.go | IsCollectionMissingError | func IsCollectionMissingError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusCollectionUnknown)
}
return false
} | go | func IsCollectionMissingError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusCollectionUnknown)
}
return false
} | [
"func",
"IsCollectionMissingError",
"(",
"err",
"error",
")",
"bool",
"{",
"cause",
":=",
"errors",
".",
"Cause",
"(",
"err",
")",
"\n",
"if",
"kvErr",
",",
"ok",
":=",
"cause",
".",
"(",
"KeyValueError",
")",
";",
"ok",
"&&",
"kvErr",
".",
"KVError",
"(",
")",
"{",
"return",
"kvErr",
".",
"StatusCode",
"(",
")",
"==",
"int",
"(",
"gocbcore",
".",
"StatusCollectionUnknown",
")",
"\n",
"}",
"\n\n",
"return",
"false",
"\n\n",
"}"
]
| // IsCollectionMissingError verifies whether or not the cause for an error is scope unknown | [
"IsCollectionMissingError",
"verifies",
"whether",
"or",
"not",
"the",
"cause",
"for",
"an",
"error",
"is",
"scope",
"unknown"
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/error.go#L82-L90 |
9,593 | couchbase/gocb | error.go | IsKeyExistsError | func IsKeyExistsError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusKeyExists)
}
return false
} | go | func IsKeyExistsError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusKeyExists)
}
return false
} | [
"func",
"IsKeyExistsError",
"(",
"err",
"error",
")",
"bool",
"{",
"cause",
":=",
"errors",
".",
"Cause",
"(",
"err",
")",
"\n",
"if",
"kvErr",
",",
"ok",
":=",
"cause",
".",
"(",
"KeyValueError",
")",
";",
"ok",
"&&",
"kvErr",
".",
"KVError",
"(",
")",
"{",
"return",
"kvErr",
".",
"StatusCode",
"(",
")",
"==",
"int",
"(",
"gocbcore",
".",
"StatusKeyExists",
")",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
]
| // IsKeyExistsError indicates whether the passed error is a
// key-value "Key Already Exists" error. | [
"IsKeyExistsError",
"indicates",
"whether",
"the",
"passed",
"error",
"is",
"a",
"key",
"-",
"value",
"Key",
"Already",
"Exists",
"error",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/error.go#L94-L101 |
9,594 | couchbase/gocb | error.go | IsKeyNotFoundError | func IsKeyNotFoundError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusKeyNotFound)
}
return false
} | go | func IsKeyNotFoundError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusKeyNotFound)
}
return false
} | [
"func",
"IsKeyNotFoundError",
"(",
"err",
"error",
")",
"bool",
"{",
"cause",
":=",
"errors",
".",
"Cause",
"(",
"err",
")",
"\n",
"if",
"kvErr",
",",
"ok",
":=",
"cause",
".",
"(",
"KeyValueError",
")",
";",
"ok",
"&&",
"kvErr",
".",
"KVError",
"(",
")",
"{",
"return",
"kvErr",
".",
"StatusCode",
"(",
")",
"==",
"int",
"(",
"gocbcore",
".",
"StatusKeyNotFound",
")",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
]
| // IsKeyNotFoundError indicates whether the passed error is a
// key-value "Key Not Found" error. | [
"IsKeyNotFoundError",
"indicates",
"whether",
"the",
"passed",
"error",
"is",
"a",
"key",
"-",
"value",
"Key",
"Not",
"Found",
"error",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/error.go#L105-L112 |
9,595 | couchbase/gocb | error.go | IsTempFailError | func IsTempFailError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusTmpFail)
}
return false
} | go | func IsTempFailError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusTmpFail)
}
return false
} | [
"func",
"IsTempFailError",
"(",
"err",
"error",
")",
"bool",
"{",
"cause",
":=",
"errors",
".",
"Cause",
"(",
"err",
")",
"\n",
"if",
"kvErr",
",",
"ok",
":=",
"cause",
".",
"(",
"KeyValueError",
")",
";",
"ok",
"&&",
"kvErr",
".",
"KVError",
"(",
")",
"{",
"return",
"kvErr",
".",
"StatusCode",
"(",
")",
"==",
"int",
"(",
"gocbcore",
".",
"StatusTmpFail",
")",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
]
| // IsTempFailError indicates whether the passed error is a
// key-value "temporary failure, try again later" error. | [
"IsTempFailError",
"indicates",
"whether",
"the",
"passed",
"error",
"is",
"a",
"key",
"-",
"value",
"temporary",
"failure",
"try",
"again",
"later",
"error",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/error.go#L116-L123 |
9,596 | couchbase/gocb | error.go | IsValueTooBigError | func IsValueTooBigError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusTooBig)
}
return false
} | go | func IsValueTooBigError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusTooBig)
}
return false
} | [
"func",
"IsValueTooBigError",
"(",
"err",
"error",
")",
"bool",
"{",
"cause",
":=",
"errors",
".",
"Cause",
"(",
"err",
")",
"\n",
"if",
"kvErr",
",",
"ok",
":=",
"cause",
".",
"(",
"KeyValueError",
")",
";",
"ok",
"&&",
"kvErr",
".",
"KVError",
"(",
")",
"{",
"return",
"kvErr",
".",
"StatusCode",
"(",
")",
"==",
"int",
"(",
"gocbcore",
".",
"StatusTooBig",
")",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
]
| // IsValueTooBigError indicates whether the passed error is a
// key-value "document value was too large" error. | [
"IsValueTooBigError",
"indicates",
"whether",
"the",
"passed",
"error",
"is",
"a",
"key",
"-",
"value",
"document",
"value",
"was",
"too",
"large",
"error",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/error.go#L127-L134 |
9,597 | couchbase/gocb | error.go | IsKeyLockedError | func IsKeyLockedError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusLocked)
}
return false
} | go | func IsKeyLockedError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusLocked)
}
return false
} | [
"func",
"IsKeyLockedError",
"(",
"err",
"error",
")",
"bool",
"{",
"cause",
":=",
"errors",
".",
"Cause",
"(",
"err",
")",
"\n",
"if",
"kvErr",
",",
"ok",
":=",
"cause",
".",
"(",
"KeyValueError",
")",
";",
"ok",
"&&",
"kvErr",
".",
"KVError",
"(",
")",
"{",
"return",
"kvErr",
".",
"StatusCode",
"(",
")",
"==",
"int",
"(",
"gocbcore",
".",
"StatusLocked",
")",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
]
| // IsKeyLockedError indicates whether the passed error is a
// key-value operation failed due to the document being locked. | [
"IsKeyLockedError",
"indicates",
"whether",
"the",
"passed",
"error",
"is",
"a",
"key",
"-",
"value",
"operation",
"failed",
"due",
"to",
"the",
"document",
"being",
"locked",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/error.go#L138-L145 |
9,598 | couchbase/gocb | error.go | IsPathExistsError | func IsPathExistsError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusSubDocPathExists)
}
return false
} | go | func IsPathExistsError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusSubDocPathExists)
}
return false
} | [
"func",
"IsPathExistsError",
"(",
"err",
"error",
")",
"bool",
"{",
"cause",
":=",
"errors",
".",
"Cause",
"(",
"err",
")",
"\n",
"if",
"kvErr",
",",
"ok",
":=",
"cause",
".",
"(",
"KeyValueError",
")",
";",
"ok",
"&&",
"kvErr",
".",
"KVError",
"(",
")",
"{",
"return",
"kvErr",
".",
"StatusCode",
"(",
")",
"==",
"int",
"(",
"gocbcore",
".",
"StatusSubDocPathExists",
")",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
]
| // IsPathExistsError indicates whether the passed error is a
// key-value "given path already exists in the document" error. | [
"IsPathExistsError",
"indicates",
"whether",
"the",
"passed",
"error",
"is",
"a",
"key",
"-",
"value",
"given",
"path",
"already",
"exists",
"in",
"the",
"document",
"error",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/error.go#L160-L167 |
9,599 | couchbase/gocb | error.go | IsInvalidRangeError | func IsInvalidRangeError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusRangeError)
}
return false
} | go | func IsInvalidRangeError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusRangeError)
}
return false
} | [
"func",
"IsInvalidRangeError",
"(",
"err",
"error",
")",
"bool",
"{",
"cause",
":=",
"errors",
".",
"Cause",
"(",
"err",
")",
"\n",
"if",
"kvErr",
",",
"ok",
":=",
"cause",
".",
"(",
"KeyValueError",
")",
";",
"ok",
"&&",
"kvErr",
".",
"KVError",
"(",
")",
"{",
"return",
"kvErr",
".",
"StatusCode",
"(",
")",
"==",
"int",
"(",
"gocbcore",
".",
"StatusRangeError",
")",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
]
| // IsInvalidRangeError indicates whether the passed error is a
// key-value "requested value is outside range" error. | [
"IsInvalidRangeError",
"indicates",
"whether",
"the",
"passed",
"error",
"is",
"a",
"key",
"-",
"value",
"requested",
"value",
"is",
"outside",
"range",
"error",
"."
]
| bca37798dd8f7c60a98041ed7089d39290c71718 | https://github.com/couchbase/gocb/blob/bca37798dd8f7c60a98041ed7089d39290c71718/error.go#L171-L178 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.