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 list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
24,200 | docker/go-connections | nat/nat.go | Int | func (p Port) Int() int {
portStr := p.Port()
// We don't need to check for an error because we're going to
// assume that any error would have been found, and reported, in NewPort()
port, _ := ParsePort(portStr)
return port
} | go | func (p Port) Int() int {
portStr := p.Port()
// We don't need to check for an error because we're going to
// assume that any error would have been found, and reported, in NewPort()
port, _ := ParsePort(portStr)
return port
} | [
"func",
"(",
"p",
"Port",
")",
"Int",
"(",
")",
"int",
"{",
"portStr",
":=",
"p",
".",
"Port",
"(",
")",
"\n",
"// We don't need to check for an error because we're going to",
"// assume that any error would have been found, and reported, in NewPort()",
"port",
",",
"_",
... | // Int returns the port number of a Port as an int | [
"Int",
"returns",
"the",
"port",
"number",
"of",
"a",
"Port",
"as",
"an",
"int"
] | b44139defdac517e3f71df1e60826f8a262a2482 | https://github.com/docker/go-connections/blob/b44139defdac517e3f71df1e60826f8a262a2482/nat/nat.go#L86-L92 |
24,201 | docker/go-connections | nat/nat.go | ParsePortSpec | func ParsePortSpec(rawPort string) ([]PortMapping, error) {
var proto string
rawIP, hostPort, containerPort := splitParts(rawPort)
proto, containerPort = SplitProtoPort(containerPort)
// Strip [] from IPV6 addresses
ip, _, err := net.SplitHostPort(rawIP + ":")
if err != nil {
return nil, fmt.Errorf("Invalid ip... | go | func ParsePortSpec(rawPort string) ([]PortMapping, error) {
var proto string
rawIP, hostPort, containerPort := splitParts(rawPort)
proto, containerPort = SplitProtoPort(containerPort)
// Strip [] from IPV6 addresses
ip, _, err := net.SplitHostPort(rawIP + ":")
if err != nil {
return nil, fmt.Errorf("Invalid ip... | [
"func",
"ParsePortSpec",
"(",
"rawPort",
"string",
")",
"(",
"[",
"]",
"PortMapping",
",",
"error",
")",
"{",
"var",
"proto",
"string",
"\n",
"rawIP",
",",
"hostPort",
",",
"containerPort",
":=",
"splitParts",
"(",
"rawPort",
")",
"\n",
"proto",
",",
"co... | // ParsePortSpec parses a port specification string into a slice of PortMappings | [
"ParsePortSpec",
"parses",
"a",
"port",
"specification",
"string",
"into",
"a",
"slice",
"of",
"PortMappings"
] | b44139defdac517e3f71df1e60826f8a262a2482 | https://github.com/docker/go-connections/blob/b44139defdac517e3f71df1e60826f8a262a2482/nat/nat.go#L176-L242 |
24,202 | docker/go-connections | tlsconfig/config.go | ServerDefault | func ServerDefault(ops ...func(*tls.Config)) *tls.Config {
tlsconfig := &tls.Config{
// Avoid fallback by default to SSL protocols < TLS1.2
MinVersion: tls.VersionTLS12,
PreferServerCipherSuites: true,
CipherSuites: DefaultServerAcceptedCiphers,
}
for _, op := range ops {
op(tlsc... | go | func ServerDefault(ops ...func(*tls.Config)) *tls.Config {
tlsconfig := &tls.Config{
// Avoid fallback by default to SSL protocols < TLS1.2
MinVersion: tls.VersionTLS12,
PreferServerCipherSuites: true,
CipherSuites: DefaultServerAcceptedCiphers,
}
for _, op := range ops {
op(tlsc... | [
"func",
"ServerDefault",
"(",
"ops",
"...",
"func",
"(",
"*",
"tls",
".",
"Config",
")",
")",
"*",
"tls",
".",
"Config",
"{",
"tlsconfig",
":=",
"&",
"tls",
".",
"Config",
"{",
"// Avoid fallback by default to SSL protocols < TLS1.2",
"MinVersion",
":",
"tls",... | // ServerDefault returns a secure-enough TLS configuration for the server TLS configuration. | [
"ServerDefault",
"returns",
"a",
"secure",
"-",
"enough",
"TLS",
"configuration",
"for",
"the",
"server",
"TLS",
"configuration",
"."
] | b44139defdac517e3f71df1e60826f8a262a2482 | https://github.com/docker/go-connections/blob/b44139defdac517e3f71df1e60826f8a262a2482/tlsconfig/config.go#L66-L79 |
24,203 | docker/go-connections | tlsconfig/config.go | ClientDefault | func ClientDefault(ops ...func(*tls.Config)) *tls.Config {
tlsconfig := &tls.Config{
// Prefer TLS1.2 as the client minimum
MinVersion: tls.VersionTLS12,
CipherSuites: clientCipherSuites,
}
for _, op := range ops {
op(tlsconfig)
}
return tlsconfig
} | go | func ClientDefault(ops ...func(*tls.Config)) *tls.Config {
tlsconfig := &tls.Config{
// Prefer TLS1.2 as the client minimum
MinVersion: tls.VersionTLS12,
CipherSuites: clientCipherSuites,
}
for _, op := range ops {
op(tlsconfig)
}
return tlsconfig
} | [
"func",
"ClientDefault",
"(",
"ops",
"...",
"func",
"(",
"*",
"tls",
".",
"Config",
")",
")",
"*",
"tls",
".",
"Config",
"{",
"tlsconfig",
":=",
"&",
"tls",
".",
"Config",
"{",
"// Prefer TLS1.2 as the client minimum",
"MinVersion",
":",
"tls",
".",
"Versi... | // ClientDefault returns a secure-enough TLS configuration for the client TLS configuration. | [
"ClientDefault",
"returns",
"a",
"secure",
"-",
"enough",
"TLS",
"configuration",
"for",
"the",
"client",
"TLS",
"configuration",
"."
] | b44139defdac517e3f71df1e60826f8a262a2482 | https://github.com/docker/go-connections/blob/b44139defdac517e3f71df1e60826f8a262a2482/tlsconfig/config.go#L82-L94 |
24,204 | docker/go-connections | tlsconfig/config.go | certPool | func certPool(caFile string, exclusivePool bool) (*x509.CertPool, error) {
// If we should verify the server, we need to load a trusted ca
var (
certPool *x509.CertPool
err error
)
if exclusivePool {
certPool = x509.NewCertPool()
} else {
certPool, err = SystemCertPool()
if err != nil {
return ni... | go | func certPool(caFile string, exclusivePool bool) (*x509.CertPool, error) {
// If we should verify the server, we need to load a trusted ca
var (
certPool *x509.CertPool
err error
)
if exclusivePool {
certPool = x509.NewCertPool()
} else {
certPool, err = SystemCertPool()
if err != nil {
return ni... | [
"func",
"certPool",
"(",
"caFile",
"string",
",",
"exclusivePool",
"bool",
")",
"(",
"*",
"x509",
".",
"CertPool",
",",
"error",
")",
"{",
"// If we should verify the server, we need to load a trusted ca",
"var",
"(",
"certPool",
"*",
"x509",
".",
"CertPool",
"\n"... | // certPool returns an X.509 certificate pool from `caFile`, the certificate file. | [
"certPool",
"returns",
"an",
"X",
".",
"509",
"certificate",
"pool",
"from",
"caFile",
"the",
"certificate",
"file",
"."
] | b44139defdac517e3f71df1e60826f8a262a2482 | https://github.com/docker/go-connections/blob/b44139defdac517e3f71df1e60826f8a262a2482/tlsconfig/config.go#L97-L119 |
24,205 | docker/go-connections | tlsconfig/config.go | adjustMinVersion | func adjustMinVersion(options Options, config *tls.Config) error {
if options.MinVersion > 0 {
if !isValidMinVersion(options.MinVersion) {
return fmt.Errorf("Invalid minimum TLS version: %x", options.MinVersion)
}
if options.MinVersion < config.MinVersion {
return fmt.Errorf("Requested minimum TLS version ... | go | func adjustMinVersion(options Options, config *tls.Config) error {
if options.MinVersion > 0 {
if !isValidMinVersion(options.MinVersion) {
return fmt.Errorf("Invalid minimum TLS version: %x", options.MinVersion)
}
if options.MinVersion < config.MinVersion {
return fmt.Errorf("Requested minimum TLS version ... | [
"func",
"adjustMinVersion",
"(",
"options",
"Options",
",",
"config",
"*",
"tls",
".",
"Config",
")",
"error",
"{",
"if",
"options",
".",
"MinVersion",
">",
"0",
"{",
"if",
"!",
"isValidMinVersion",
"(",
"options",
".",
"MinVersion",
")",
"{",
"return",
... | // adjustMinVersion sets the MinVersion on `config`, the input configuration.
// It assumes the current MinVersion on the `config` is the lowest allowed. | [
"adjustMinVersion",
"sets",
"the",
"MinVersion",
"on",
"config",
"the",
"input",
"configuration",
".",
"It",
"assumes",
"the",
"current",
"MinVersion",
"on",
"the",
"config",
"is",
"the",
"lowest",
"allowed",
"."
] | b44139defdac517e3f71df1e60826f8a262a2482 | https://github.com/docker/go-connections/blob/b44139defdac517e3f71df1e60826f8a262a2482/tlsconfig/config.go#L129-L141 |
24,206 | docker/go-connections | tlsconfig/config.go | getPrivateKey | func getPrivateKey(keyBytes []byte, passphrase string) ([]byte, error) {
// this section makes some small changes to code from notary/tuf/utils/x509.go
pemBlock, _ := pem.Decode(keyBytes)
if pemBlock == nil {
return nil, fmt.Errorf("no valid private key found")
}
var err error
if x509.IsEncryptedPEMBlock(pemBl... | go | func getPrivateKey(keyBytes []byte, passphrase string) ([]byte, error) {
// this section makes some small changes to code from notary/tuf/utils/x509.go
pemBlock, _ := pem.Decode(keyBytes)
if pemBlock == nil {
return nil, fmt.Errorf("no valid private key found")
}
var err error
if x509.IsEncryptedPEMBlock(pemBl... | [
"func",
"getPrivateKey",
"(",
"keyBytes",
"[",
"]",
"byte",
",",
"passphrase",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// this section makes some small changes to code from notary/tuf/utils/x509.go",
"pemBlock",
",",
"_",
":=",
"pem",
".",
"... | // getPrivateKey returns the private key in 'keyBytes', in PEM-encoded format.
// If the private key is encrypted, 'passphrase' is used to decrypted the
// private key. | [
"getPrivateKey",
"returns",
"the",
"private",
"key",
"in",
"keyBytes",
"in",
"PEM",
"-",
"encoded",
"format",
".",
"If",
"the",
"private",
"key",
"is",
"encrypted",
"passphrase",
"is",
"used",
"to",
"decrypted",
"the",
"private",
"key",
"."
] | b44139defdac517e3f71df1e60826f8a262a2482 | https://github.com/docker/go-connections/blob/b44139defdac517e3f71df1e60826f8a262a2482/tlsconfig/config.go#L152-L169 |
24,207 | docker/go-connections | tlsconfig/config.go | getCert | func getCert(options Options) ([]tls.Certificate, error) {
if options.CertFile == "" && options.KeyFile == "" {
return nil, nil
}
errMessage := "Could not load X509 key pair"
cert, err := ioutil.ReadFile(options.CertFile)
if err != nil {
return nil, errors.Wrap(err, errMessage)
}
prKeyBytes, err := ioutil... | go | func getCert(options Options) ([]tls.Certificate, error) {
if options.CertFile == "" && options.KeyFile == "" {
return nil, nil
}
errMessage := "Could not load X509 key pair"
cert, err := ioutil.ReadFile(options.CertFile)
if err != nil {
return nil, errors.Wrap(err, errMessage)
}
prKeyBytes, err := ioutil... | [
"func",
"getCert",
"(",
"options",
"Options",
")",
"(",
"[",
"]",
"tls",
".",
"Certificate",
",",
"error",
")",
"{",
"if",
"options",
".",
"CertFile",
"==",
"\"",
"\"",
"&&",
"options",
".",
"KeyFile",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"... | // getCert returns a Certificate from the CertFile and KeyFile in 'options',
// if the key is encrypted, the Passphrase in 'options' will be used to
// decrypt it. | [
"getCert",
"returns",
"a",
"Certificate",
"from",
"the",
"CertFile",
"and",
"KeyFile",
"in",
"options",
"if",
"the",
"key",
"is",
"encrypted",
"the",
"Passphrase",
"in",
"options",
"will",
"be",
"used",
"to",
"decrypt",
"it",
"."
] | b44139defdac517e3f71df1e60826f8a262a2482 | https://github.com/docker/go-connections/blob/b44139defdac517e3f71df1e60826f8a262a2482/tlsconfig/config.go#L174-L202 |
24,208 | docker/go-connections | tlsconfig/config.go | Client | func Client(options Options) (*tls.Config, error) {
tlsConfig := ClientDefault()
tlsConfig.InsecureSkipVerify = options.InsecureSkipVerify
if !options.InsecureSkipVerify && options.CAFile != "" {
CAs, err := certPool(options.CAFile, options.ExclusiveRootPools)
if err != nil {
return nil, err
}
tlsConfig.R... | go | func Client(options Options) (*tls.Config, error) {
tlsConfig := ClientDefault()
tlsConfig.InsecureSkipVerify = options.InsecureSkipVerify
if !options.InsecureSkipVerify && options.CAFile != "" {
CAs, err := certPool(options.CAFile, options.ExclusiveRootPools)
if err != nil {
return nil, err
}
tlsConfig.R... | [
"func",
"Client",
"(",
"options",
"Options",
")",
"(",
"*",
"tls",
".",
"Config",
",",
"error",
")",
"{",
"tlsConfig",
":=",
"ClientDefault",
"(",
")",
"\n",
"tlsConfig",
".",
"InsecureSkipVerify",
"=",
"options",
".",
"InsecureSkipVerify",
"\n",
"if",
"!"... | // Client returns a TLS configuration meant to be used by a client. | [
"Client",
"returns",
"a",
"TLS",
"configuration",
"meant",
"to",
"be",
"used",
"by",
"a",
"client",
"."
] | b44139defdac517e3f71df1e60826f8a262a2482 | https://github.com/docker/go-connections/blob/b44139defdac517e3f71df1e60826f8a262a2482/tlsconfig/config.go#L205-L227 |
24,209 | docker/go-connections | tlsconfig/config.go | Server | func Server(options Options) (*tls.Config, error) {
tlsConfig := ServerDefault()
tlsConfig.ClientAuth = options.ClientAuth
tlsCert, err := tls.LoadX509KeyPair(options.CertFile, options.KeyFile)
if err != nil {
if os.IsNotExist(err) {
return nil, fmt.Errorf("Could not load X509 key pair (cert: %q, key: %q): %v"... | go | func Server(options Options) (*tls.Config, error) {
tlsConfig := ServerDefault()
tlsConfig.ClientAuth = options.ClientAuth
tlsCert, err := tls.LoadX509KeyPair(options.CertFile, options.KeyFile)
if err != nil {
if os.IsNotExist(err) {
return nil, fmt.Errorf("Could not load X509 key pair (cert: %q, key: %q): %v"... | [
"func",
"Server",
"(",
"options",
"Options",
")",
"(",
"*",
"tls",
".",
"Config",
",",
"error",
")",
"{",
"tlsConfig",
":=",
"ServerDefault",
"(",
")",
"\n",
"tlsConfig",
".",
"ClientAuth",
"=",
"options",
".",
"ClientAuth",
"\n",
"tlsCert",
",",
"err",
... | // Server returns a TLS configuration meant to be used by a server. | [
"Server",
"returns",
"a",
"TLS",
"configuration",
"meant",
"to",
"be",
"used",
"by",
"a",
"server",
"."
] | b44139defdac517e3f71df1e60826f8a262a2482 | https://github.com/docker/go-connections/blob/b44139defdac517e3f71df1e60826f8a262a2482/tlsconfig/config.go#L230-L254 |
24,210 | docker/go-connections | sockets/unix_socket.go | WithChown | func WithChown(uid, gid int) SockOption {
return func(path string) error {
if err := os.Chown(path, uid, gid); err != nil {
return err
}
return nil
}
} | go | func WithChown(uid, gid int) SockOption {
return func(path string) error {
if err := os.Chown(path, uid, gid); err != nil {
return err
}
return nil
}
} | [
"func",
"WithChown",
"(",
"uid",
",",
"gid",
"int",
")",
"SockOption",
"{",
"return",
"func",
"(",
"path",
"string",
")",
"error",
"{",
"if",
"err",
":=",
"os",
".",
"Chown",
"(",
"path",
",",
"uid",
",",
"gid",
")",
";",
"err",
"!=",
"nil",
"{",... | // WithChown modifies the socket file's uid and gid | [
"WithChown",
"modifies",
"the",
"socket",
"file",
"s",
"uid",
"and",
"gid"
] | b44139defdac517e3f71df1e60826f8a262a2482 | https://github.com/docker/go-connections/blob/b44139defdac517e3f71df1e60826f8a262a2482/sockets/unix_socket.go#L61-L68 |
24,211 | docker/go-connections | sockets/unix_socket.go | WithChmod | func WithChmod(mask os.FileMode) SockOption {
return func(path string) error {
if err := os.Chmod(path, mask); err != nil {
return err
}
return nil
}
} | go | func WithChmod(mask os.FileMode) SockOption {
return func(path string) error {
if err := os.Chmod(path, mask); err != nil {
return err
}
return nil
}
} | [
"func",
"WithChmod",
"(",
"mask",
"os",
".",
"FileMode",
")",
"SockOption",
"{",
"return",
"func",
"(",
"path",
"string",
")",
"error",
"{",
"if",
"err",
":=",
"os",
".",
"Chmod",
"(",
"path",
",",
"mask",
")",
";",
"err",
"!=",
"nil",
"{",
"return... | // WithChmod modifies socket file's access mode | [
"WithChmod",
"modifies",
"socket",
"file",
"s",
"access",
"mode"
] | b44139defdac517e3f71df1e60826f8a262a2482 | https://github.com/docker/go-connections/blob/b44139defdac517e3f71df1e60826f8a262a2482/sockets/unix_socket.go#L71-L78 |
24,212 | docker/go-connections | sockets/unix_socket.go | NewUnixSocketWithOpts | func NewUnixSocketWithOpts(path string, opts ...SockOption) (net.Listener, error) {
if err := syscall.Unlink(path); err != nil && !os.IsNotExist(err) {
return nil, err
}
mask := syscall.Umask(0777)
defer syscall.Umask(mask)
l, err := net.Listen("unix", path)
if err != nil {
return nil, err
}
for _, op := ... | go | func NewUnixSocketWithOpts(path string, opts ...SockOption) (net.Listener, error) {
if err := syscall.Unlink(path); err != nil && !os.IsNotExist(err) {
return nil, err
}
mask := syscall.Umask(0777)
defer syscall.Umask(mask)
l, err := net.Listen("unix", path)
if err != nil {
return nil, err
}
for _, op := ... | [
"func",
"NewUnixSocketWithOpts",
"(",
"path",
"string",
",",
"opts",
"...",
"SockOption",
")",
"(",
"net",
".",
"Listener",
",",
"error",
")",
"{",
"if",
"err",
":=",
"syscall",
".",
"Unlink",
"(",
"path",
")",
";",
"err",
"!=",
"nil",
"&&",
"!",
"os... | // NewUnixSocketWithOpts creates a unix socket with the specified options | [
"NewUnixSocketWithOpts",
"creates",
"a",
"unix",
"socket",
"with",
"the",
"specified",
"options"
] | b44139defdac517e3f71df1e60826f8a262a2482 | https://github.com/docker/go-connections/blob/b44139defdac517e3f71df1e60826f8a262a2482/sockets/unix_socket.go#L81-L101 |
24,213 | docker/go-connections | sockets/unix_socket.go | NewUnixSocket | func NewUnixSocket(path string, gid int) (net.Listener, error) {
return NewUnixSocketWithOpts(path, WithChown(0, gid), WithChmod(0660))
} | go | func NewUnixSocket(path string, gid int) (net.Listener, error) {
return NewUnixSocketWithOpts(path, WithChown(0, gid), WithChmod(0660))
} | [
"func",
"NewUnixSocket",
"(",
"path",
"string",
",",
"gid",
"int",
")",
"(",
"net",
".",
"Listener",
",",
"error",
")",
"{",
"return",
"NewUnixSocketWithOpts",
"(",
"path",
",",
"WithChown",
"(",
"0",
",",
"gid",
")",
",",
"WithChmod",
"(",
"0660",
")"... | // NewUnixSocket creates a unix socket with the specified path and group. | [
"NewUnixSocket",
"creates",
"a",
"unix",
"socket",
"with",
"the",
"specified",
"path",
"and",
"group",
"."
] | b44139defdac517e3f71df1e60826f8a262a2482 | https://github.com/docker/go-connections/blob/b44139defdac517e3f71df1e60826f8a262a2482/sockets/unix_socket.go#L104-L106 |
24,214 | docker/go-connections | sockets/sockets_windows.go | DialPipe | func DialPipe(addr string, timeout time.Duration) (net.Conn, error) {
return winio.DialPipe(addr, &timeout)
} | go | func DialPipe(addr string, timeout time.Duration) (net.Conn, error) {
return winio.DialPipe(addr, &timeout)
} | [
"func",
"DialPipe",
"(",
"addr",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"return",
"winio",
".",
"DialPipe",
"(",
"addr",
",",
"&",
"timeout",
")",
"\n",
"}"
] | // DialPipe connects to a Windows named pipe. | [
"DialPipe",
"connects",
"to",
"a",
"Windows",
"named",
"pipe",
"."
] | b44139defdac517e3f71df1e60826f8a262a2482 | https://github.com/docker/go-connections/blob/b44139defdac517e3f71df1e60826f8a262a2482/sockets/sockets_windows.go#L33-L35 |
24,215 | ipfs/go-dnslink | dnslink/main.go | printLink | func printLink(domain string) error {
link, err := dnslink.Resolve(domain)
if err != nil {
return err
}
fmt.Println(link)
return nil
} | go | func printLink(domain string) error {
link, err := dnslink.Resolve(domain)
if err != nil {
return err
}
fmt.Println(link)
return nil
} | [
"func",
"printLink",
"(",
"domain",
"string",
")",
"error",
"{",
"link",
",",
"err",
":=",
"dnslink",
".",
"Resolve",
"(",
"domain",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"fmt",
".",
"Println",
"(",
"link",
")"... | // print a single link | [
"print",
"a",
"single",
"link"
] | 47ab53fda3fac2f043084406e6da47232efa91d1 | https://github.com/ipfs/go-dnslink/blob/47ab53fda3fac2f043084406e6da47232efa91d1/dnslink/main.go#L57-L64 |
24,216 | ipfs/go-dnslink | dnslink/main.go | printLinks | func printLinks(domains []string) error {
for _, domain := range domains {
fmt.Print(domain, ": ")
result, err := dnslink.Resolve(domain)
if result != "" {
fmt.Print(result)
}
if err != nil {
fmt.Print("error: ", err)
}
fmt.Println()
}
return nil
} | go | func printLinks(domains []string) error {
for _, domain := range domains {
fmt.Print(domain, ": ")
result, err := dnslink.Resolve(domain)
if result != "" {
fmt.Print(result)
}
if err != nil {
fmt.Print("error: ", err)
}
fmt.Println()
}
return nil
} | [
"func",
"printLinks",
"(",
"domains",
"[",
"]",
"string",
")",
"error",
"{",
"for",
"_",
",",
"domain",
":=",
"range",
"domains",
"{",
"fmt",
".",
"Print",
"(",
"domain",
",",
"\"",
"\"",
")",
"\n\n",
"result",
",",
"err",
":=",
"dnslink",
".",
"Re... | // print multiple links.
// errors printed as output, and do not fail the entire process. | [
"print",
"multiple",
"links",
".",
"errors",
"printed",
"as",
"output",
"and",
"do",
"not",
"fail",
"the",
"entire",
"process",
"."
] | 47ab53fda3fac2f043084406e6da47232efa91d1 | https://github.com/ipfs/go-dnslink/blob/47ab53fda3fac2f043084406e6da47232efa91d1/dnslink/main.go#L68-L82 |
24,217 | ipfs/go-dnslink | dnslink.go | Resolve | func (r *Resolver) Resolve(domain string) (string, error) {
return r.ResolveN(domain, DefaultDepthLimit)
} | go | func (r *Resolver) Resolve(domain string) (string, error) {
return r.ResolveN(domain, DefaultDepthLimit)
} | [
"func",
"(",
"r",
"*",
"Resolver",
")",
"Resolve",
"(",
"domain",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"r",
".",
"ResolveN",
"(",
"domain",
",",
"DefaultDepthLimit",
")",
"\n",
"}"
] | // Resolve resolves the dnslink at a particular domain. It will recursively
// keep resolving until reaching the defaultDepth of Resolver. If the depth
// is reached, Resolve will return the last value retrieved, and ErrResolveLimit.
// If TXT records are found but are not valid dnslink records, Resolve will
// return ... | [
"Resolve",
"resolves",
"the",
"dnslink",
"at",
"a",
"particular",
"domain",
".",
"It",
"will",
"recursively",
"keep",
"resolving",
"until",
"reaching",
"the",
"defaultDepth",
"of",
"Resolver",
".",
"If",
"the",
"depth",
"is",
"reached",
"Resolve",
"will",
"ret... | 47ab53fda3fac2f043084406e6da47232efa91d1 | https://github.com/ipfs/go-dnslink/blob/47ab53fda3fac2f043084406e6da47232efa91d1/dnslink.go#L142-L144 |
24,218 | Joker/jade | template.go | ParseFile | func ParseFile(filename string) (string, error) {
bs, err := ioutil.ReadFile(filename)
if err != nil {
return "", err
}
return Parse(filepath.Base(filename), bs)
} | go | func ParseFile(filename string) (string, error) {
bs, err := ioutil.ReadFile(filename)
if err != nil {
return "", err
}
return Parse(filepath.Base(filename), bs)
} | [
"func",
"ParseFile",
"(",
"filename",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"bs",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"filename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
... | // ParseFile parse the jade template file in given filename | [
"ParseFile",
"parse",
"the",
"jade",
"template",
"file",
"in",
"given",
"filename"
] | 9ffefa50b5f31416ac643e9d9ad6116f4688705f | https://github.com/Joker/jade/blob/9ffefa50b5f31416ac643e9d9ad6116f4688705f/template.go#L48-L54 |
24,219 | Joker/jade | jade_node.go | filterString | func filterString(in string) string {
var (
rs = []rune(in)
flag, prev rune
psn int
)
for k, r := range rs {
// fmt.Println(string(r), " ", r)
switch r {
case '"':
if flag == '\'' && prev != '\\' {
rs[k] = 0 // bookmark for replace
}
if flag == 0 {
flag = '"'
psn = k
... | go | func filterString(in string) string {
var (
rs = []rune(in)
flag, prev rune
psn int
)
for k, r := range rs {
// fmt.Println(string(r), " ", r)
switch r {
case '"':
if flag == '\'' && prev != '\\' {
rs[k] = 0 // bookmark for replace
}
if flag == 0 {
flag = '"'
psn = k
... | [
"func",
"filterString",
"(",
"in",
"string",
")",
"string",
"{",
"var",
"(",
"rs",
"=",
"[",
"]",
"rune",
"(",
"in",
")",
"\n",
"flag",
",",
"prev",
"rune",
"\n",
"psn",
"int",
"\n",
")",
"\n",
"for",
"k",
",",
"r",
":=",
"range",
"rs",
"{",
... | // `"aaa'a" + 'b\"bb"b' + 'c'` >>> `"aaa'a" + "b\"bb\"b" + "c"` | [
"aaa",
"a",
"+",
"b",
"\\",
"bb",
"b",
"+",
"c",
">>>",
"aaa",
"a",
"+",
"b",
"\\",
"bb",
"\\",
"b",
"+",
"c"
] | 9ffefa50b5f31416ac643e9d9ad6116f4688705f | https://github.com/Joker/jade/blob/9ffefa50b5f31416ac643e9d9ad6116f4688705f/jade_node.go#L65-L112 |
24,220 | Joker/jade | jade_node.go | filterPlus | func filterPlus(rs []rune) {
var (
flag, prev rune
psn int
)
for k, r := range rs {
switch r {
case '"':
if flag == 0 {
flag = '"'
if psn > 0 {
for i := psn; i < k+1; i++ {
// fmt.Println(string(rs[i]), rs[i])
rs[i] = 1
}
}
} else if r == flag && prev != '\\' {
... | go | func filterPlus(rs []rune) {
var (
flag, prev rune
psn int
)
for k, r := range rs {
switch r {
case '"':
if flag == 0 {
flag = '"'
if psn > 0 {
for i := psn; i < k+1; i++ {
// fmt.Println(string(rs[i]), rs[i])
rs[i] = 1
}
}
} else if r == flag && prev != '\\' {
... | [
"func",
"filterPlus",
"(",
"rs",
"[",
"]",
"rune",
")",
"{",
"var",
"(",
"flag",
",",
"prev",
"rune",
"\n",
"psn",
"int",
"\n",
")",
"\n",
"for",
"k",
",",
"r",
":=",
"range",
"rs",
"{",
"switch",
"r",
"{",
"case",
"'\"'",
":",
"if",
"flag",
... | // "aaa" + "bbb" >>> "aaabbb" | [
"aaa",
"+",
"bbb",
">>>",
"aaabbb"
] | 9ffefa50b5f31416ac643e9d9ad6116f4688705f | https://github.com/Joker/jade/blob/9ffefa50b5f31416ac643e9d9ad6116f4688705f/jade_node.go#L115-L147 |
24,221 | Joker/jade | parse.go | Copy | func (t *Tree) Copy() *Tree {
if t == nil {
return nil
}
return &Tree{
Name: t.Name,
Root: t.Root.CopyList(),
text: t.text,
}
} | go | func (t *Tree) Copy() *Tree {
if t == nil {
return nil
}
return &Tree{
Name: t.Name,
Root: t.Root.CopyList(),
text: t.text,
}
} | [
"func",
"(",
"t",
"*",
"Tree",
")",
"Copy",
"(",
")",
"*",
"Tree",
"{",
"if",
"t",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"&",
"Tree",
"{",
"Name",
":",
"t",
".",
"Name",
",",
"Root",
":",
"t",
".",
"Root",
".",
"Copy... | // Copy returns a copy of the Tree. Any parsing state is discarded. | [
"Copy",
"returns",
"a",
"copy",
"of",
"the",
"Tree",
".",
"Any",
"parsing",
"state",
"is",
"discarded",
"."
] | 9ffefa50b5f31416ac643e9d9ad6116f4688705f | https://github.com/Joker/jade/blob/9ffefa50b5f31416ac643e9d9ad6116f4688705f/parse.go#L28-L37 |
24,222 | Joker/jade | parse.go | New | func New(name string) *Tree {
return &Tree{
Name: name,
mixin: map[string]*MixinNode{},
block: map[string]*ListNode{},
}
} | go | func New(name string) *Tree {
return &Tree{
Name: name,
mixin: map[string]*MixinNode{},
block: map[string]*ListNode{},
}
} | [
"func",
"New",
"(",
"name",
"string",
")",
"*",
"Tree",
"{",
"return",
"&",
"Tree",
"{",
"Name",
":",
"name",
",",
"mixin",
":",
"map",
"[",
"string",
"]",
"*",
"MixinNode",
"{",
"}",
",",
"block",
":",
"map",
"[",
"string",
"]",
"*",
"ListNode",... | // New allocates a new parse tree with the given name. | [
"New",
"allocates",
"a",
"new",
"parse",
"tree",
"with",
"the",
"given",
"name",
"."
] | 9ffefa50b5f31416ac643e9d9ad6116f4688705f | https://github.com/Joker/jade/blob/9ffefa50b5f31416ac643e9d9ad6116f4688705f/parse.go#L139-L145 |
24,223 | Joker/jade | lex.go | backup | func (l *lexer) backup() {
l.pos -= l.width
// Correct newline count.
if l.width == 1 && l.input[l.pos] == '\n' {
l.line--
}
} | go | func (l *lexer) backup() {
l.pos -= l.width
// Correct newline count.
if l.width == 1 && l.input[l.pos] == '\n' {
l.line--
}
} | [
"func",
"(",
"l",
"*",
"lexer",
")",
"backup",
"(",
")",
"{",
"l",
".",
"pos",
"-=",
"l",
".",
"width",
"\n",
"// Correct newline count.",
"if",
"l",
".",
"width",
"==",
"1",
"&&",
"l",
".",
"input",
"[",
"l",
".",
"pos",
"]",
"==",
"'\\n'",
"{... | // backup steps back one rune. Can only be called once per call of next. | [
"backup",
"steps",
"back",
"one",
"rune",
".",
"Can",
"only",
"be",
"called",
"once",
"per",
"call",
"of",
"next",
"."
] | 9ffefa50b5f31416ac643e9d9ad6116f4688705f | https://github.com/Joker/jade/blob/9ffefa50b5f31416ac643e9d9ad6116f4688705f/lex.go#L83-L89 |
24,224 | couchbase/go-couchbase | conn_pool.go | Discard | func (cp *connectionPool) Discard(c *memcached.Client) {
<-cp.createsem
c.Close()
} | go | func (cp *connectionPool) Discard(c *memcached.Client) {
<-cp.createsem
c.Close()
} | [
"func",
"(",
"cp",
"*",
"connectionPool",
")",
"Discard",
"(",
"c",
"*",
"memcached",
".",
"Client",
")",
"{",
"<-",
"cp",
".",
"createsem",
"\n",
"c",
".",
"Close",
"(",
")",
"\n",
"}"
] | // give the ability to discard a connection from a pool
// useful for ditching connections to the wrong node after a rebalance | [
"give",
"the",
"ability",
"to",
"discard",
"a",
"connection",
"from",
"a",
"pool",
"useful",
"for",
"ditching",
"connections",
"to",
"the",
"wrong",
"node",
"after",
"a",
"rebalance"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/conn_pool.go#L292-L295 |
24,225 | couchbase/go-couchbase | conn_pool.go | connCloser | func (cp *connectionPool) connCloser() {
var connCount uint64
t := time.NewTimer(ConnCloserInterval)
defer t.Stop()
for {
connCount = cp.connCount
// we don't exist anymore! bail out!
select {
case <-cp.bailOut:
return
case <-t.C:
}
t.Reset(ConnCloserInterval)
// no overflow connections open ... | go | func (cp *connectionPool) connCloser() {
var connCount uint64
t := time.NewTimer(ConnCloserInterval)
defer t.Stop()
for {
connCount = cp.connCount
// we don't exist anymore! bail out!
select {
case <-cp.bailOut:
return
case <-t.C:
}
t.Reset(ConnCloserInterval)
// no overflow connections open ... | [
"func",
"(",
"cp",
"*",
"connectionPool",
")",
"connCloser",
"(",
")",
"{",
"var",
"connCount",
"uint64",
"\n\n",
"t",
":=",
"time",
".",
"NewTimer",
"(",
"ConnCloserInterval",
")",
"\n",
"defer",
"t",
".",
"Stop",
"(",
")",
"\n\n",
"for",
"{",
"connCo... | // asynchronous connection closer | [
"asynchronous",
"connection",
"closer"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/conn_pool.go#L298-L339 |
24,226 | couchbase/go-couchbase | conn_pool.go | connCleanup | func (cp *connectionPool) connCleanup(c *memcached.Client) (rv bool) {
// just in case we are closing a connection after
// bailOut has been sent but we haven't yet read it
defer func() {
if recover() != nil {
rv = false
}
}()
rv = true
c.Close()
<-cp.createsem
return
} | go | func (cp *connectionPool) connCleanup(c *memcached.Client) (rv bool) {
// just in case we are closing a connection after
// bailOut has been sent but we haven't yet read it
defer func() {
if recover() != nil {
rv = false
}
}()
rv = true
c.Close()
<-cp.createsem
return
} | [
"func",
"(",
"cp",
"*",
"connectionPool",
")",
"connCleanup",
"(",
"c",
"*",
"memcached",
".",
"Client",
")",
"(",
"rv",
"bool",
")",
"{",
"// just in case we are closing a connection after",
"// bailOut has been sent but we haven't yet read it",
"defer",
"func",
"(",
... | // close connection with recovery on error | [
"close",
"connection",
"with",
"recovery",
"on",
"error"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/conn_pool.go#L342-L356 |
24,227 | couchbase/go-couchbase | trace/trace.go | ConsolidateByTitle | func ConsolidateByTitle(next *Msg, prev *Msg) *Msg {
if prev == nil || prev.Title != next.Title {
return next
}
prev.Repeats++
return nil
} | go | func ConsolidateByTitle(next *Msg, prev *Msg) *Msg {
if prev == nil || prev.Title != next.Title {
return next
}
prev.Repeats++
return nil
} | [
"func",
"ConsolidateByTitle",
"(",
"next",
"*",
"Msg",
",",
"prev",
"*",
"Msg",
")",
"*",
"Msg",
"{",
"if",
"prev",
"==",
"nil",
"||",
"prev",
".",
"Title",
"!=",
"next",
".",
"Title",
"{",
"return",
"next",
"\n",
"}",
"\n\n",
"prev",
".",
"Repeats... | // ConsolidateByTitle implements the MsgConsolidateFunc signature
// by consolidating trace message when their titles are the same. | [
"ConsolidateByTitle",
"implements",
"the",
"MsgConsolidateFunc",
"signature",
"by",
"consolidating",
"trace",
"message",
"when",
"their",
"titles",
"are",
"the",
"same",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/trace/trace.go#L57-L64 |
24,228 | couchbase/go-couchbase | trace/trace.go | NewRingBuffer | func NewRingBuffer(
capacity int,
consolidateFunc MsgConsolidateFunc) *RingBuffer {
return &RingBuffer{
consolidateFunc: consolidateFunc,
next: 0,
msgs: make([]Msg, capacity),
}
} | go | func NewRingBuffer(
capacity int,
consolidateFunc MsgConsolidateFunc) *RingBuffer {
return &RingBuffer{
consolidateFunc: consolidateFunc,
next: 0,
msgs: make([]Msg, capacity),
}
} | [
"func",
"NewRingBuffer",
"(",
"capacity",
"int",
",",
"consolidateFunc",
"MsgConsolidateFunc",
")",
"*",
"RingBuffer",
"{",
"return",
"&",
"RingBuffer",
"{",
"consolidateFunc",
":",
"consolidateFunc",
",",
"next",
":",
"0",
",",
"msgs",
":",
"make",
"(",
"[",
... | // NewRingBuffer returns a RingBuffer initialized with the
// given capacity and optional consolidateFunc. | [
"NewRingBuffer",
"returns",
"a",
"RingBuffer",
"initialized",
"with",
"the",
"given",
"capacity",
"and",
"optional",
"consolidateFunc",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/trace/trace.go#L68-L76 |
24,229 | couchbase/go-couchbase | trace/trace.go | Add | func (trb *RingBuffer) Add(title string, body []byte) {
if len(trb.msgs) <= 0 {
return
}
msg := &Msg{
Title: title,
Body: body,
Repeats: 1,
}
trb.m.Lock()
if trb.consolidateFunc != nil {
msg = trb.consolidateFunc(msg, trb.lastUNLOCKED())
if msg == nil {
trb.m.Unlock()
return
}
}
tr... | go | func (trb *RingBuffer) Add(title string, body []byte) {
if len(trb.msgs) <= 0 {
return
}
msg := &Msg{
Title: title,
Body: body,
Repeats: 1,
}
trb.m.Lock()
if trb.consolidateFunc != nil {
msg = trb.consolidateFunc(msg, trb.lastUNLOCKED())
if msg == nil {
trb.m.Unlock()
return
}
}
tr... | [
"func",
"(",
"trb",
"*",
"RingBuffer",
")",
"Add",
"(",
"title",
"string",
",",
"body",
"[",
"]",
"byte",
")",
"{",
"if",
"len",
"(",
"trb",
".",
"msgs",
")",
"<=",
"0",
"{",
"return",
"\n",
"}",
"\n\n",
"msg",
":=",
"&",
"Msg",
"{",
"Title",
... | // Add appens a trace message to the ring buffer, consolidating trace
// messages based on the optional consolidation function. | [
"Add",
"appens",
"a",
"trace",
"message",
"to",
"the",
"ring",
"buffer",
"consolidating",
"trace",
"messages",
"based",
"on",
"the",
"optional",
"consolidation",
"function",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/trace/trace.go#L80-L110 |
24,230 | couchbase/go-couchbase | trace/trace.go | Last | func (trb *RingBuffer) Last() *Msg {
trb.m.Lock()
last := trb.lastUNLOCKED()
trb.m.Unlock()
return last
} | go | func (trb *RingBuffer) Last() *Msg {
trb.m.Lock()
last := trb.lastUNLOCKED()
trb.m.Unlock()
return last
} | [
"func",
"(",
"trb",
"*",
"RingBuffer",
")",
"Last",
"(",
")",
"*",
"Msg",
"{",
"trb",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"last",
":=",
"trb",
".",
"lastUNLOCKED",
"(",
")",
"\n",
"trb",
".",
"m",
".",
"Unlock",
"(",
")",
"\n",
"return",
"... | // Last returns the last trace in the ring buffer. | [
"Last",
"returns",
"the",
"last",
"trace",
"in",
"the",
"ring",
"buffer",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/trace/trace.go#L118-L123 |
24,231 | couchbase/go-couchbase | trace/trace.go | Msgs | func (trb *RingBuffer) Msgs() []Msg {
rv := make([]Msg, 0, len(trb.msgs))
trb.m.Lock()
i := trb.next
for {
if trb.msgs[i].Title != "" {
rv = append(rv, trb.msgs[i])
}
i++
if i >= len(trb.msgs) {
i = 0
}
if i == trb.next { // We've returned to the beginning.
break
}
}
trb.m.Unlock()
r... | go | func (trb *RingBuffer) Msgs() []Msg {
rv := make([]Msg, 0, len(trb.msgs))
trb.m.Lock()
i := trb.next
for {
if trb.msgs[i].Title != "" {
rv = append(rv, trb.msgs[i])
}
i++
if i >= len(trb.msgs) {
i = 0
}
if i == trb.next { // We've returned to the beginning.
break
}
}
trb.m.Unlock()
r... | [
"func",
"(",
"trb",
"*",
"RingBuffer",
")",
"Msgs",
"(",
")",
"[",
"]",
"Msg",
"{",
"rv",
":=",
"make",
"(",
"[",
"]",
"Msg",
",",
"0",
",",
"len",
"(",
"trb",
".",
"msgs",
")",
")",
"\n\n",
"trb",
".",
"m",
".",
"Lock",
"(",
")",
"\n\n",
... | // Msgs returns a copy of all the trace messages, as an array with the
// oldest trace message first. | [
"Msgs",
"returns",
"a",
"copy",
"of",
"all",
"the",
"trace",
"messages",
"as",
"an",
"array",
"with",
"the",
"oldest",
"trace",
"message",
"first",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/trace/trace.go#L138-L162 |
24,232 | couchbase/go-couchbase | perf/generate-json.go | generateRandomDocument | func generateRandomDocument() ([]byte, error) {
c := &contacts{}
c.Name = randomdata.FullName(randomdata.RandomGender)
c.Email = randomdata.Email()
c.Age = randomdata.Number(20, 50)
c.Address = randomdata.Address()
c.City = randomdata.City()
c.State = randomdata.State(randomdata.Large)
c.Country = randomdata.Co... | go | func generateRandomDocument() ([]byte, error) {
c := &contacts{}
c.Name = randomdata.FullName(randomdata.RandomGender)
c.Email = randomdata.Email()
c.Age = randomdata.Number(20, 50)
c.Address = randomdata.Address()
c.City = randomdata.City()
c.State = randomdata.State(randomdata.Large)
c.Country = randomdata.Co... | [
"func",
"generateRandomDocument",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"c",
":=",
"&",
"contacts",
"{",
"}",
"\n",
"c",
".",
"Name",
"=",
"randomdata",
".",
"FullName",
"(",
"randomdata",
".",
"RandomGender",
")",
"\n",
"c",
".",
... | // return a json marshalled document | [
"return",
"a",
"json",
"marshalled",
"document"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/perf/generate-json.go#L19-L30 |
24,233 | couchbase/go-couchbase | platform/platform_windows.go | HideConsole | func HideConsole(hide bool) {
var k32 = syscall.NewLazyDLL("kernel32.dll")
var cw = k32.NewProc("GetConsoleWindow")
var u32 = syscall.NewLazyDLL("user32.dll")
var sw = u32.NewProc("ShowWindow")
hwnd, _, _ := cw.Call()
if hwnd == 0 {
return
}
if hide {
var SW_HIDE uintptr = 0
sw.Call(hwnd, SW_HIDE)
} else... | go | func HideConsole(hide bool) {
var k32 = syscall.NewLazyDLL("kernel32.dll")
var cw = k32.NewProc("GetConsoleWindow")
var u32 = syscall.NewLazyDLL("user32.dll")
var sw = u32.NewProc("ShowWindow")
hwnd, _, _ := cw.Call()
if hwnd == 0 {
return
}
if hide {
var SW_HIDE uintptr = 0
sw.Call(hwnd, SW_HIDE)
} else... | [
"func",
"HideConsole",
"(",
"hide",
"bool",
")",
"{",
"var",
"k32",
"=",
"syscall",
".",
"NewLazyDLL",
"(",
"\"",
"\"",
")",
"\n",
"var",
"cw",
"=",
"k32",
".",
"NewProc",
"(",
"\"",
"\"",
")",
"\n",
"var",
"u32",
"=",
"syscall",
".",
"NewLazyDLL",... | // Hide console on windows without removing it unlike -H windowsgui. | [
"Hide",
"console",
"on",
"windows",
"without",
"removing",
"it",
"unlike",
"-",
"H",
"windowsgui",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/platform/platform_windows.go#L20-L36 |
24,234 | couchbase/go-couchbase | ddocs.go | GetDDocs | func (b *Bucket) GetDDocs() (DDocsResult, error) {
var ddocsResult DDocsResult
b.RLock()
pool := b.pool
uri := b.DDocs.URI
b.RUnlock()
// MB-23555 ephemeral buckets have no ddocs
if uri == "" {
return DDocsResult{}, nil
}
err := pool.client.parseURLResponse(uri, &ddocsResult)
if err != nil {
return DDoc... | go | func (b *Bucket) GetDDocs() (DDocsResult, error) {
var ddocsResult DDocsResult
b.RLock()
pool := b.pool
uri := b.DDocs.URI
b.RUnlock()
// MB-23555 ephemeral buckets have no ddocs
if uri == "" {
return DDocsResult{}, nil
}
err := pool.client.parseURLResponse(uri, &ddocsResult)
if err != nil {
return DDoc... | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"GetDDocs",
"(",
")",
"(",
"DDocsResult",
",",
"error",
")",
"{",
"var",
"ddocsResult",
"DDocsResult",
"\n",
"b",
".",
"RLock",
"(",
")",
"\n",
"pool",
":=",
"b",
".",
"pool",
"\n",
"uri",
":=",
"b",
".",
"DD... | // GetDDocs lists all design documents | [
"GetDDocs",
"lists",
"all",
"design",
"documents"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/ddocs.go#L36-L53 |
24,235 | couchbase/go-couchbase | ddocs.go | PutDDoc | func (b *Bucket) PutDDoc(docname string, value interface{}) error {
var Err error
maxRetries, err := b.getMaxRetries()
if err != nil {
return err
}
lastNode := START_NODE_ID
for retryCount := 0; retryCount < maxRetries; retryCount++ {
Err = nil
ddocU, selectedNode, err := b.ddocURLNext(lastNode, docna... | go | func (b *Bucket) PutDDoc(docname string, value interface{}) error {
var Err error
maxRetries, err := b.getMaxRetries()
if err != nil {
return err
}
lastNode := START_NODE_ID
for retryCount := 0; retryCount < maxRetries; retryCount++ {
Err = nil
ddocU, selectedNode, err := b.ddocURLNext(lastNode, docna... | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"PutDDoc",
"(",
"docname",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"error",
"{",
"var",
"Err",
"error",
"\n\n",
"maxRetries",
",",
"err",
":=",
"b",
".",
"getMaxRetries",
"(",
")",
"\n",
"if",
"err",
... | // PutDDoc installs a design document. | [
"PutDDoc",
"installs",
"a",
"design",
"document",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/ddocs.go#L121-L179 |
24,236 | couchbase/go-couchbase | util.go | CleanupHost | func CleanupHost(h, commonSuffix string) string {
if strings.HasSuffix(h, commonSuffix) {
return h[:len(h)-len(commonSuffix)]
}
return h
} | go | func CleanupHost(h, commonSuffix string) string {
if strings.HasSuffix(h, commonSuffix) {
return h[:len(h)-len(commonSuffix)]
}
return h
} | [
"func",
"CleanupHost",
"(",
"h",
",",
"commonSuffix",
"string",
")",
"string",
"{",
"if",
"strings",
".",
"HasSuffix",
"(",
"h",
",",
"commonSuffix",
")",
"{",
"return",
"h",
"[",
":",
"len",
"(",
"h",
")",
"-",
"len",
"(",
"commonSuffix",
")",
"]",
... | // CleanupHost returns the hostname with the given suffix removed. | [
"CleanupHost",
"returns",
"the",
"hostname",
"with",
"the",
"given",
"suffix",
"removed",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/util.go#L10-L15 |
24,237 | couchbase/go-couchbase | util.go | FindCommonSuffix | func FindCommonSuffix(input []string) string {
rv := ""
if len(input) < 2 {
return ""
}
from := input
for i := len(input[0]); i > 0; i-- {
common := true
suffix := input[0][i:]
for _, s := range from {
if !strings.HasSuffix(s, suffix) {
common = false
break
}
}
if common {
rv = suffix
... | go | func FindCommonSuffix(input []string) string {
rv := ""
if len(input) < 2 {
return ""
}
from := input
for i := len(input[0]); i > 0; i-- {
common := true
suffix := input[0][i:]
for _, s := range from {
if !strings.HasSuffix(s, suffix) {
common = false
break
}
}
if common {
rv = suffix
... | [
"func",
"FindCommonSuffix",
"(",
"input",
"[",
"]",
"string",
")",
"string",
"{",
"rv",
":=",
"\"",
"\"",
"\n",
"if",
"len",
"(",
"input",
")",
"<",
"2",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"from",
":=",
"input",
"\n",
"for",
"i",
":=",
... | // FindCommonSuffix returns the longest common suffix from the given
// strings. | [
"FindCommonSuffix",
"returns",
"the",
"longest",
"common",
"suffix",
"from",
"the",
"given",
"strings",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/util.go#L19-L39 |
24,238 | couchbase/go-couchbase | util.go | ParseURL | func ParseURL(urlStr string) (result *url.URL, err error) {
result, err = url.Parse(urlStr)
if result != nil && result.Scheme == "" {
result = nil
err = fmt.Errorf("invalid URL <%s>", urlStr)
}
return
} | go | func ParseURL(urlStr string) (result *url.URL, err error) {
result, err = url.Parse(urlStr)
if result != nil && result.Scheme == "" {
result = nil
err = fmt.Errorf("invalid URL <%s>", urlStr)
}
return
} | [
"func",
"ParseURL",
"(",
"urlStr",
"string",
")",
"(",
"result",
"*",
"url",
".",
"URL",
",",
"err",
"error",
")",
"{",
"result",
",",
"err",
"=",
"url",
".",
"Parse",
"(",
"urlStr",
")",
"\n",
"if",
"result",
"!=",
"nil",
"&&",
"result",
".",
"S... | // ParseURL is a wrapper around url.Parse with some sanity-checking | [
"ParseURL",
"is",
"a",
"wrapper",
"around",
"url",
".",
"Parse",
"with",
"some",
"sanity",
"-",
"checking"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/util.go#L42-L49 |
24,239 | couchbase/go-couchbase | vbmap.go | VBHash | func (b *Bucket) VBHash(key string) uint32 {
crc := uint32(0xffffffff)
for x := 0; x < len(key); x++ {
crc = (crc >> 8) ^ crc32tab[(uint64(crc)^uint64(key[x]))&0xff]
}
vbm := b.VBServerMap()
return ((^crc) >> 16) & 0x7fff & (uint32(len(vbm.VBucketMap)) - 1)
} | go | func (b *Bucket) VBHash(key string) uint32 {
crc := uint32(0xffffffff)
for x := 0; x < len(key); x++ {
crc = (crc >> 8) ^ crc32tab[(uint64(crc)^uint64(key[x]))&0xff]
}
vbm := b.VBServerMap()
return ((^crc) >> 16) & 0x7fff & (uint32(len(vbm.VBucketMap)) - 1)
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"VBHash",
"(",
"key",
"string",
")",
"uint32",
"{",
"crc",
":=",
"uint32",
"(",
"0xffffffff",
")",
"\n",
"for",
"x",
":=",
"0",
";",
"x",
"<",
"len",
"(",
"key",
")",
";",
"x",
"++",
"{",
"crc",
"=",
"(",... | // VBHash finds the vbucket for the given key. | [
"VBHash",
"finds",
"the",
"vbucket",
"for",
"the",
"given",
"key",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/vbmap.go#L70-L77 |
24,240 | couchbase/go-couchbase | pools.go | SetConnectionPoolParams | func SetConnectionPoolParams(size, overflow int) {
if size > 0 {
PoolSize = size
}
if overflow > 0 {
PoolOverflow = overflow
}
} | go | func SetConnectionPoolParams(size, overflow int) {
if size > 0 {
PoolSize = size
}
if overflow > 0 {
PoolOverflow = overflow
}
} | [
"func",
"SetConnectionPoolParams",
"(",
"size",
",",
"overflow",
"int",
")",
"{",
"if",
"size",
">",
"0",
"{",
"PoolSize",
"=",
"size",
"\n",
"}",
"\n\n",
"if",
"overflow",
">",
"0",
"{",
"PoolOverflow",
"=",
"overflow",
"\n",
"}",
"\n",
"}"
] | // Allow applications to speciify the Poolsize and Overflow | [
"Allow",
"applications",
"to",
"speciify",
"the",
"Poolsize",
"and",
"Overflow"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/pools.go#L87-L96 |
24,241 | couchbase/go-couchbase | pools.go | SetTcpKeepalive | func SetTcpKeepalive(enabled bool, interval int) {
TCPKeepalive = enabled
if interval > 0 {
TCPKeepaliveInterval = interval
}
} | go | func SetTcpKeepalive(enabled bool, interval int) {
TCPKeepalive = enabled
if interval > 0 {
TCPKeepaliveInterval = interval
}
} | [
"func",
"SetTcpKeepalive",
"(",
"enabled",
"bool",
",",
"interval",
"int",
")",
"{",
"TCPKeepalive",
"=",
"enabled",
"\n\n",
"if",
"interval",
">",
"0",
"{",
"TCPKeepaliveInterval",
"=",
"interval",
"\n",
"}",
"\n",
"}"
] | // Allow TCP keepalive parameters to be set by the application | [
"Allow",
"TCP",
"keepalive",
"parameters",
"to",
"be",
"set",
"by",
"the",
"application"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/pools.go#L109-L116 |
24,242 | couchbase/go-couchbase | pools.go | VBServerMap | func (b *Bucket) VBServerMap() *VBucketServerMap {
b.RLock()
defer b.RUnlock()
ret := (*VBucketServerMap)(b.vBucketServerMap)
return ret
} | go | func (b *Bucket) VBServerMap() *VBucketServerMap {
b.RLock()
defer b.RUnlock()
ret := (*VBucketServerMap)(b.vBucketServerMap)
return ret
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"VBServerMap",
"(",
")",
"*",
"VBucketServerMap",
"{",
"b",
".",
"RLock",
"(",
")",
"\n",
"defer",
"b",
".",
"RUnlock",
"(",
")",
"\n",
"ret",
":=",
"(",
"*",
"VBucketServerMap",
")",
"(",
"b",
".",
"vBucketSer... | // VBServerMap returns the current VBucketServerMap. | [
"VBServerMap",
"returns",
"the",
"current",
"VBucketServerMap",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/pools.go#L288-L293 |
24,243 | couchbase/go-couchbase | pools.go | checkVBmap | func (b *Bucket) checkVBmap(node string) bool {
vbmap := b.VBServerMap()
servers := vbmap.ServerList
for _, idxs := range vbmap.VBucketMap {
if len(idxs) == 0 {
return true
} else if idxs[0] < 0 || idxs[0] >= len(servers) {
return true
}
if servers[idxs[0]] == node {
return false
}
}
return tru... | go | func (b *Bucket) checkVBmap(node string) bool {
vbmap := b.VBServerMap()
servers := vbmap.ServerList
for _, idxs := range vbmap.VBucketMap {
if len(idxs) == 0 {
return true
} else if idxs[0] < 0 || idxs[0] >= len(servers) {
return true
}
if servers[idxs[0]] == node {
return false
}
}
return tru... | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"checkVBmap",
"(",
"node",
"string",
")",
"bool",
"{",
"vbmap",
":=",
"b",
".",
"VBServerMap",
"(",
")",
"\n",
"servers",
":=",
"vbmap",
".",
"ServerList",
"\n\n",
"for",
"_",
",",
"idxs",
":=",
"range",
"vbmap",... | // true if node is not on the bucket VBmap | [
"true",
"if",
"node",
"is",
"not",
"on",
"the",
"bucket",
"VBmap"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/pools.go#L321-L336 |
24,244 | couchbase/go-couchbase | pools.go | Nodes | func (b *Bucket) Nodes() []Node {
b.RLock()
defer b.RUnlock()
ret := *(*[]Node)(b.nodeList)
return ret
} | go | func (b *Bucket) Nodes() []Node {
b.RLock()
defer b.RUnlock()
ret := *(*[]Node)(b.nodeList)
return ret
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"Nodes",
"(",
")",
"[",
"]",
"Node",
"{",
"b",
".",
"RLock",
"(",
")",
"\n",
"defer",
"b",
".",
"RUnlock",
"(",
")",
"\n",
"ret",
":=",
"*",
"(",
"*",
"[",
"]",
"Node",
")",
"(",
"b",
".",
"nodeList",
... | // Nodes returns the current list of nodes servicing this bucket. | [
"Nodes",
"returns",
"the",
"current",
"list",
"of",
"nodes",
"servicing",
"this",
"bucket",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/pools.go#L346-L351 |
24,245 | couchbase/go-couchbase | pools.go | HealthyNodes | func (b *Bucket) HealthyNodes() []Node {
nodes := []Node{}
for _, n := range b.Nodes() {
if n.Status == "healthy" && n.CouchAPIBase != "" {
nodes = append(nodes, n)
}
if n.Status != "healthy" { // log non-healthy node
logging.Infof("Non-healthy node; node details:")
logging.Infof("Hostname=%v, Status=... | go | func (b *Bucket) HealthyNodes() []Node {
nodes := []Node{}
for _, n := range b.Nodes() {
if n.Status == "healthy" && n.CouchAPIBase != "" {
nodes = append(nodes, n)
}
if n.Status != "healthy" { // log non-healthy node
logging.Infof("Non-healthy node; node details:")
logging.Infof("Hostname=%v, Status=... | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"HealthyNodes",
"(",
")",
"[",
"]",
"Node",
"{",
"nodes",
":=",
"[",
"]",
"Node",
"{",
"}",
"\n\n",
"for",
"_",
",",
"n",
":=",
"range",
"b",
".",
"Nodes",
"(",
")",
"{",
"if",
"n",
".",
"Status",
"==",
... | // return the list of healthy nodes | [
"return",
"the",
"list",
"of",
"healthy",
"nodes"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/pools.go#L354-L368 |
24,246 | couchbase/go-couchbase | pools.go | getConnectionToVBucket | func (b *Bucket) getConnectionToVBucket(vb uint32) (*memcached.Client, *connectionPool, error) {
for {
vbm := b.VBServerMap()
if len(vbm.VBucketMap) < int(vb) {
return nil, nil, fmt.Errorf("go-couchbase: vbmap smaller than vbucket list: %v vs. %v",
vb, vbm.VBucketMap)
}
masterId := vbm.VBucketMap[vb][0]... | go | func (b *Bucket) getConnectionToVBucket(vb uint32) (*memcached.Client, *connectionPool, error) {
for {
vbm := b.VBServerMap()
if len(vbm.VBucketMap) < int(vb) {
return nil, nil, fmt.Errorf("go-couchbase: vbmap smaller than vbucket list: %v vs. %v",
vb, vbm.VBucketMap)
}
masterId := vbm.VBucketMap[vb][0]... | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"getConnectionToVBucket",
"(",
"vb",
"uint32",
")",
"(",
"*",
"memcached",
".",
"Client",
",",
"*",
"connectionPool",
",",
"error",
")",
"{",
"for",
"{",
"vbm",
":=",
"b",
".",
"VBServerMap",
"(",
")",
"\n",
"if"... | // Given a vbucket number, returns a memcached connection to it.
// The connection must be returned to its pool after use. | [
"Given",
"a",
"vbucket",
"number",
"returns",
"a",
"memcached",
"connection",
"to",
"it",
".",
"The",
"connection",
"must",
"be",
"returned",
"to",
"its",
"pool",
"after",
"use",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/pools.go#L425-L443 |
24,247 | couchbase/go-couchbase | pools.go | getRandomConnection | func (b *Bucket) getRandomConnection() (*memcached.Client, *connectionPool, error) {
for {
var currentPool = 0
pools := b.getConnPools(false /* not already locked */)
if len(pools) == 0 {
return nil, nil, fmt.Errorf("No connection pool found")
} else if len(pools) > 1 { // choose a random connection
curr... | go | func (b *Bucket) getRandomConnection() (*memcached.Client, *connectionPool, error) {
for {
var currentPool = 0
pools := b.getConnPools(false /* not already locked */)
if len(pools) == 0 {
return nil, nil, fmt.Errorf("No connection pool found")
} else if len(pools) > 1 { // choose a random connection
curr... | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"getRandomConnection",
"(",
")",
"(",
"*",
"memcached",
".",
"Client",
",",
"*",
"connectionPool",
",",
"error",
")",
"{",
"for",
"{",
"var",
"currentPool",
"=",
"0",
"\n",
"pools",
":=",
"b",
".",
"getConnPools",
... | // To get random documents, we need to cover all the nodes, so select
// a connection at random. | [
"To",
"get",
"random",
"documents",
"we",
"need",
"to",
"cover",
"all",
"the",
"nodes",
"so",
"select",
"a",
"connection",
"at",
"random",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/pools.go#L448-L467 |
24,248 | couchbase/go-couchbase | pools.go | ConnectWithAuth | func ConnectWithAuth(baseU string, ah AuthHandler) (c Client, err error) {
c.BaseURL, err = ParseURL(baseU)
if err != nil {
return
}
c.ah = ah
return c, c.parseURLResponse("/pools", &c.Info)
} | go | func ConnectWithAuth(baseU string, ah AuthHandler) (c Client, err error) {
c.BaseURL, err = ParseURL(baseU)
if err != nil {
return
}
c.ah = ah
return c, c.parseURLResponse("/pools", &c.Info)
} | [
"func",
"ConnectWithAuth",
"(",
"baseU",
"string",
",",
"ah",
"AuthHandler",
")",
"(",
"c",
"Client",
",",
"err",
"error",
")",
"{",
"c",
".",
"BaseURL",
",",
"err",
"=",
"ParseURL",
"(",
"baseU",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // ConnectWithAuth connects to a couchbase cluster with the given
// authentication handler. | [
"ConnectWithAuth",
"connects",
"to",
"a",
"couchbase",
"cluster",
"with",
"the",
"given",
"authentication",
"handler",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/pools.go#L938-L946 |
24,249 | couchbase/go-couchbase | pools.go | ConnectWithAuthCreds | func ConnectWithAuthCreds(baseU, username, password string) (c Client, err error) {
c.BaseURL, err = ParseURL(baseU)
if err != nil {
return
}
c.ah = newBucketAuth(username, password, "")
return c, c.parseURLResponse("/pools", &c.Info)
} | go | func ConnectWithAuthCreds(baseU, username, password string) (c Client, err error) {
c.BaseURL, err = ParseURL(baseU)
if err != nil {
return
}
c.ah = newBucketAuth(username, password, "")
return c, c.parseURLResponse("/pools", &c.Info)
} | [
"func",
"ConnectWithAuthCreds",
"(",
"baseU",
",",
"username",
",",
"password",
"string",
")",
"(",
"c",
"Client",
",",
"err",
"error",
")",
"{",
"c",
".",
"BaseURL",
",",
"err",
"=",
"ParseURL",
"(",
"baseU",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{"... | // ConnectWithAuthCreds connects to a couchbase cluster with the give
// authorization creds returned by cb_auth | [
"ConnectWithAuthCreds",
"connects",
"to",
"a",
"couchbase",
"cluster",
"with",
"the",
"give",
"authorization",
"creds",
"returned",
"by",
"cb_auth"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/pools.go#L969-L977 |
24,250 | couchbase/go-couchbase | pools.go | GetBucketList | func GetBucketList(baseU string) (bInfo []BucketInfo, err error) {
c := &Client{}
c.BaseURL, err = ParseURL(baseU)
if err != nil {
return
}
c.ah = basicAuthFromURL(baseU)
var buckets []Bucket
err = c.parseURLResponse("/pools/default/buckets", &buckets)
if err != nil {
return
}
bInfo = make([]BucketInfo,... | go | func GetBucketList(baseU string) (bInfo []BucketInfo, err error) {
c := &Client{}
c.BaseURL, err = ParseURL(baseU)
if err != nil {
return
}
c.ah = basicAuthFromURL(baseU)
var buckets []Bucket
err = c.parseURLResponse("/pools/default/buckets", &buckets)
if err != nil {
return
}
bInfo = make([]BucketInfo,... | [
"func",
"GetBucketList",
"(",
"baseU",
"string",
")",
"(",
"bInfo",
"[",
"]",
"BucketInfo",
",",
"err",
"error",
")",
"{",
"c",
":=",
"&",
"Client",
"{",
"}",
"\n",
"c",
".",
"BaseURL",
",",
"err",
"=",
"ParseURL",
"(",
"baseU",
")",
"\n",
"if",
... | //Get SASL buckets | [
"Get",
"SASL",
"buckets"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/pools.go#L991-L1011 |
24,251 | couchbase/go-couchbase | pools.go | GetCollectionsManifest | func (b *Bucket) GetCollectionsManifest() (*Manifest, error) {
// Collections not used?
if !EnableCollections {
return nil, fmt.Errorf("Collections not enabled.")
}
b.RLock()
pools := b.getConnPools(true /* already locked */)
pool := pools[0] // Any pool will do, so use the first one.
b.RUnlock()
client, err... | go | func (b *Bucket) GetCollectionsManifest() (*Manifest, error) {
// Collections not used?
if !EnableCollections {
return nil, fmt.Errorf("Collections not enabled.")
}
b.RLock()
pools := b.getConnPools(true /* already locked */)
pool := pools[0] // Any pool will do, so use the first one.
b.RUnlock()
client, err... | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"GetCollectionsManifest",
"(",
")",
"(",
"*",
"Manifest",
",",
"error",
")",
"{",
"// Collections not used?",
"if",
"!",
"EnableCollections",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n... | // This function assumes the bucket is locked. | [
"This",
"function",
"assumes",
"the",
"bucket",
"is",
"locked",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/pools.go#L1152-L1191 |
24,252 | couchbase/go-couchbase | pools.go | Close | func (b *Bucket) Close() {
b.Lock()
defer b.Unlock()
if b.connPools != nil {
for _, c := range b.getConnPools(true /* already locked */) {
if c != nil {
c.Close()
}
}
b.connPools = nil
}
} | go | func (b *Bucket) Close() {
b.Lock()
defer b.Unlock()
if b.connPools != nil {
for _, c := range b.getConnPools(true /* already locked */) {
if c != nil {
c.Close()
}
}
b.connPools = nil
}
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"Close",
"(",
")",
"{",
"b",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"Unlock",
"(",
")",
"\n",
"if",
"b",
".",
"connPools",
"!=",
"nil",
"{",
"for",
"_",
",",
"c",
":=",
"range",
"b",
".",
"getC... | // Close marks this bucket as no longer needed, closing connections it
// may have open. | [
"Close",
"marks",
"this",
"bucket",
"as",
"no",
"longer",
"needed",
"closing",
"connections",
"it",
"may",
"have",
"open",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/pools.go#L1362-L1373 |
24,253 | couchbase/go-couchbase | pools.go | GetPool | func (b *Bucket) GetPool() *Pool {
b.RLock()
defer b.RUnlock()
ret := b.pool
return ret
} | go | func (b *Bucket) GetPool() *Pool {
b.RLock()
defer b.RUnlock()
ret := b.pool
return ret
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"GetPool",
"(",
")",
"*",
"Pool",
"{",
"b",
".",
"RLock",
"(",
")",
"\n",
"defer",
"b",
".",
"RUnlock",
"(",
")",
"\n",
"ret",
":=",
"b",
".",
"pool",
"\n",
"return",
"ret",
"\n",
"}"
] | // GetPool gets the pool to which this bucket belongs. | [
"GetPool",
"gets",
"the",
"pool",
"to",
"which",
"this",
"bucket",
"belongs",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/pools.go#L1414-L1419 |
24,254 | couchbase/go-couchbase | pools.go | Close | func (p *Pool) Close() {
// fine to loop through the buckets unlocked
// locking happens at the bucket level
for b, _ := range p.BucketMap {
// MB-33208 defer closing connection pools until the bucket is no longer used
bucket := p.BucketMap[b]
bucket.Lock()
bucket.closed = true
bucket.Unlock()
}
} | go | func (p *Pool) Close() {
// fine to loop through the buckets unlocked
// locking happens at the bucket level
for b, _ := range p.BucketMap {
// MB-33208 defer closing connection pools until the bucket is no longer used
bucket := p.BucketMap[b]
bucket.Lock()
bucket.closed = true
bucket.Unlock()
}
} | [
"func",
"(",
"p",
"*",
"Pool",
")",
"Close",
"(",
")",
"{",
"// fine to loop through the buckets unlocked",
"// locking happens at the bucket level",
"for",
"b",
",",
"_",
":=",
"range",
"p",
".",
"BucketMap",
"{",
"// MB-33208 defer closing connection pools until the buc... | // Release bucket connections when the pool is no longer in use | [
"Release",
"bucket",
"connections",
"when",
"the",
"pool",
"is",
"no",
"longer",
"in",
"use"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/pools.go#L1427-L1438 |
24,255 | couchbase/go-couchbase | pools.go | GetBucket | func GetBucket(endpoint, poolname, bucketname string) (*Bucket, error) {
var err error
client, err := Connect(endpoint)
if err != nil {
return nil, err
}
pool, err := client.GetPool(poolname)
if err != nil {
return nil, err
}
return pool.GetBucket(bucketname)
} | go | func GetBucket(endpoint, poolname, bucketname string) (*Bucket, error) {
var err error
client, err := Connect(endpoint)
if err != nil {
return nil, err
}
pool, err := client.GetPool(poolname)
if err != nil {
return nil, err
}
return pool.GetBucket(bucketname)
} | [
"func",
"GetBucket",
"(",
"endpoint",
",",
"poolname",
",",
"bucketname",
"string",
")",
"(",
"*",
"Bucket",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"client",
",",
"err",
":=",
"Connect",
"(",
"endpoint",
")",
"\n",
"if",
"err",
"!=",
"n... | // GetBucket is a convenience function for getting a named bucket from
// a URL | [
"GetBucket",
"is",
"a",
"convenience",
"function",
"for",
"getting",
"a",
"named",
"bucket",
"from",
"a",
"URL"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/pools.go#L1442-L1455 |
24,256 | couchbase/go-couchbase | pools.go | ConnectWithAuthAndGetBucket | func ConnectWithAuthAndGetBucket(endpoint, poolname, bucketname string,
ah AuthHandler) (*Bucket, error) {
client, err := ConnectWithAuth(endpoint, ah)
if err != nil {
return nil, err
}
pool, err := client.GetPool(poolname)
if err != nil {
return nil, err
}
return pool.GetBucket(bucketname)
} | go | func ConnectWithAuthAndGetBucket(endpoint, poolname, bucketname string,
ah AuthHandler) (*Bucket, error) {
client, err := ConnectWithAuth(endpoint, ah)
if err != nil {
return nil, err
}
pool, err := client.GetPool(poolname)
if err != nil {
return nil, err
}
return pool.GetBucket(bucketname)
} | [
"func",
"ConnectWithAuthAndGetBucket",
"(",
"endpoint",
",",
"poolname",
",",
"bucketname",
"string",
",",
"ah",
"AuthHandler",
")",
"(",
"*",
"Bucket",
",",
"error",
")",
"{",
"client",
",",
"err",
":=",
"ConnectWithAuth",
"(",
"endpoint",
",",
"ah",
")",
... | // ConnectWithAuthAndGetBucket is a convenience function for
// getting a named bucket from a given URL and an auth callback | [
"ConnectWithAuthAndGetBucket",
"is",
"a",
"convenience",
"function",
"for",
"getting",
"a",
"named",
"bucket",
"from",
"a",
"given",
"URL",
"and",
"an",
"auth",
"callback"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/pools.go#L1459-L1472 |
24,257 | couchbase/go-couchbase | observe.go | Get | func (p *OPpool) Get() *ObservePersistJob {
var o *ObservePersistJob
select {
case o = <-p.pool:
default:
o = &ObservePersistJob{}
}
return o
} | go | func (p *OPpool) Get() *ObservePersistJob {
var o *ObservePersistJob
select {
case o = <-p.pool:
default:
o = &ObservePersistJob{}
}
return o
} | [
"func",
"(",
"p",
"*",
"OPpool",
")",
"Get",
"(",
")",
"*",
"ObservePersistJob",
"{",
"var",
"o",
"*",
"ObservePersistJob",
"\n",
"select",
"{",
"case",
"o",
"=",
"<-",
"p",
".",
"pool",
":",
"default",
":",
"o",
"=",
"&",
"ObservePersistJob",
"{",
... | // Borrow a Client from the pool. | [
"Borrow",
"a",
"Client",
"from",
"the",
"pool",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/observe.go#L283-L291 |
24,258 | couchbase/go-couchbase | cbdatasource/cbdatasource.go | workerStart | func (d *bucketDataSource) workerStart(server string, workerCh chan []uint16, tlsConfig *tls.Config) {
backoffFactor := d.options.DataManagerBackoffFactor
if backoffFactor <= 0.0 {
backoffFactor = DefaultBucketDataSourceOptions.DataManagerBackoffFactor
}
sleepInitMS := d.options.DataManagerSleepInitMS
if sleepIn... | go | func (d *bucketDataSource) workerStart(server string, workerCh chan []uint16, tlsConfig *tls.Config) {
backoffFactor := d.options.DataManagerBackoffFactor
if backoffFactor <= 0.0 {
backoffFactor = DefaultBucketDataSourceOptions.DataManagerBackoffFactor
}
sleepInitMS := d.options.DataManagerSleepInitMS
if sleepIn... | [
"func",
"(",
"d",
"*",
"bucketDataSource",
")",
"workerStart",
"(",
"server",
"string",
",",
"workerCh",
"chan",
"[",
"]",
"uint16",
",",
"tlsConfig",
"*",
"tls",
".",
"Config",
")",
"{",
"backoffFactor",
":=",
"d",
".",
"options",
".",
"DataManagerBackoff... | // A worker connects to one data manager server. | [
"A",
"worker",
"connects",
"to",
"one",
"data",
"manager",
"server",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/cbdatasource/cbdatasource.go#L927-L951 |
24,259 | couchbase/go-couchbase | cbdatasource/cbdatasource.go | ConnectBucket | func ConnectBucket(serverURL, poolName, bucketName string,
auth couchbase.AuthHandler) (Bucket, error) {
var bucket *couchbase.Bucket
var err error
if auth != nil {
bucket, err = couchbase.ConnectWithAuthAndGetBucket(serverURL, poolName, bucketName, auth)
} else {
bucket, err = couchbase.GetBucket(serverURL, ... | go | func ConnectBucket(serverURL, poolName, bucketName string,
auth couchbase.AuthHandler) (Bucket, error) {
var bucket *couchbase.Bucket
var err error
if auth != nil {
bucket, err = couchbase.ConnectWithAuthAndGetBucket(serverURL, poolName, bucketName, auth)
} else {
bucket, err = couchbase.GetBucket(serverURL, ... | [
"func",
"ConnectBucket",
"(",
"serverURL",
",",
"poolName",
",",
"bucketName",
"string",
",",
"auth",
"couchbase",
".",
"AuthHandler",
")",
"(",
"Bucket",
",",
"error",
")",
"{",
"var",
"bucket",
"*",
"couchbase",
".",
"Bucket",
"\n",
"var",
"err",
"error"... | // ConnectBucket is the default function used by BucketDataSource
// to connect to a Couchbase cluster to retrieve Bucket information.
// It is exposed for testability and to allow applications to
// override or wrap via BucketDataSourceOptions. | [
"ConnectBucket",
"is",
"the",
"default",
"function",
"used",
"by",
"BucketDataSource",
"to",
"connect",
"to",
"a",
"Couchbase",
"cluster",
"to",
"retrieve",
"Bucket",
"information",
".",
"It",
"is",
"exposed",
"for",
"testability",
"and",
"to",
"allow",
"applica... | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/cbdatasource/cbdatasource.go#L1959-L1978 |
24,260 | couchbase/go-couchbase | cbdatasource/cbdatasource.go | UPROpen | func UPROpen(mc *memcached.Client, name string,
option *BucketDataSourceOptions, openFlags uint32) error {
rq := &gomemcached.MCRequest{
Opcode: gomemcached.UPR_OPEN,
Key: []byte(name),
Opaque: 0xf00d1234,
Extras: make([]byte, 8),
}
bufSize := option.FeedBufferSizeBytes
noopInterval := option.NoopTimeIn... | go | func UPROpen(mc *memcached.Client, name string,
option *BucketDataSourceOptions, openFlags uint32) error {
rq := &gomemcached.MCRequest{
Opcode: gomemcached.UPR_OPEN,
Key: []byte(name),
Opaque: 0xf00d1234,
Extras: make([]byte, 8),
}
bufSize := option.FeedBufferSizeBytes
noopInterval := option.NoopTimeIn... | [
"func",
"UPROpen",
"(",
"mc",
"*",
"memcached",
".",
"Client",
",",
"name",
"string",
",",
"option",
"*",
"BucketDataSourceOptions",
",",
"openFlags",
"uint32",
")",
"error",
"{",
"rq",
":=",
"&",
"gomemcached",
".",
"MCRequest",
"{",
"Opcode",
":",
"gomem... | // UPROpen starts a UPR_OPEN stream on a memcached client connection.
// It is exposed for testability. | [
"UPROpen",
"starts",
"a",
"UPR_OPEN",
"stream",
"on",
"a",
"memcached",
"client",
"connection",
".",
"It",
"is",
"exposed",
"for",
"testability",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/cbdatasource/cbdatasource.go#L2037-L2105 |
24,261 | couchbase/go-couchbase | upr.go | GetFailoverLogs | func (b *Bucket) GetFailoverLogs(vBuckets []uint16) (FailoverLog, error) {
// map vbids to their corresponding hosts
vbHostList := make(map[string][]uint16)
vbm := b.VBServerMap()
if len(vbm.VBucketMap) < len(vBuckets) {
return nil, fmt.Errorf("vbmap smaller than vbucket list: %v vs. %v",
vbm.VBucketMap, vBuc... | go | func (b *Bucket) GetFailoverLogs(vBuckets []uint16) (FailoverLog, error) {
// map vbids to their corresponding hosts
vbHostList := make(map[string][]uint16)
vbm := b.VBServerMap()
if len(vbm.VBucketMap) < len(vBuckets) {
return nil, fmt.Errorf("vbmap smaller than vbucket list: %v vs. %v",
vbm.VBucketMap, vBuc... | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"GetFailoverLogs",
"(",
"vBuckets",
"[",
"]",
"uint16",
")",
"(",
"FailoverLog",
",",
"error",
")",
"{",
"// map vbids to their corresponding hosts",
"vbHostList",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
... | // GetFailoverLogs, get the failover logs for a set of vbucket ids | [
"GetFailoverLogs",
"get",
"the",
"failover",
"logs",
"for",
"a",
"set",
"of",
"vbucket",
"ids"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/upr.go#L48-L104 |
24,262 | couchbase/go-couchbase | upr.go | StartUprFeedWithConfig | func (b *Bucket) StartUprFeedWithConfig(name string, sequence uint32, data_chan_size int, dcp_buffer_size uint32) (*UprFeed, error) {
feed := &UprFeed{
bucket: b,
output: make(chan *memcached.UprEvent, data_chan_size),
quit: make(chan bool),
nodeFeeds: make(map[string]*FeedI... | go | func (b *Bucket) StartUprFeedWithConfig(name string, sequence uint32, data_chan_size int, dcp_buffer_size uint32) (*UprFeed, error) {
feed := &UprFeed{
bucket: b,
output: make(chan *memcached.UprEvent, data_chan_size),
quit: make(chan bool),
nodeFeeds: make(map[string]*FeedI... | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"StartUprFeedWithConfig",
"(",
"name",
"string",
",",
"sequence",
"uint32",
",",
"data_chan_size",
"int",
",",
"dcp_buffer_size",
"uint32",
")",
"(",
"*",
"UprFeed",
",",
"error",
")",
"{",
"feed",
":=",
"&",
"UprFeed"... | // StartUprFeed creates and starts a new Upr feed
// No data will be sent on the channel unless vbuckets streams are requested | [
"StartUprFeed",
"creates",
"and",
"starts",
"a",
"new",
"Upr",
"feed",
"No",
"data",
"will",
"be",
"sent",
"on",
"the",
"channel",
"unless",
"vbuckets",
"streams",
"are",
"requested"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/upr.go#L112-L135 |
24,263 | couchbase/go-couchbase | upr.go | UprRequestStream | func (feed *UprFeed) UprRequestStream(vb uint16, opaque uint16, flags uint32,
vuuid, startSequence, endSequence, snapStart, snapEnd uint64) error {
defer func() {
if r := recover(); r != nil {
log.Panicf("Panic in UprRequestStream. Feed %v Bucket %v", feed, feed.bucket)
}
}()
vbm := feed.bucket.VBServerMap... | go | func (feed *UprFeed) UprRequestStream(vb uint16, opaque uint16, flags uint32,
vuuid, startSequence, endSequence, snapStart, snapEnd uint64) error {
defer func() {
if r := recover(); r != nil {
log.Panicf("Panic in UprRequestStream. Feed %v Bucket %v", feed, feed.bucket)
}
}()
vbm := feed.bucket.VBServerMap... | [
"func",
"(",
"feed",
"*",
"UprFeed",
")",
"UprRequestStream",
"(",
"vb",
"uint16",
",",
"opaque",
"uint16",
",",
"flags",
"uint32",
",",
"vuuid",
",",
"startSequence",
",",
"endSequence",
",",
"snapStart",
",",
"snapEnd",
"uint64",
")",
"error",
"{",
"defe... | // UprRequestStream starts a stream for a vb on a feed | [
"UprRequestStream",
"starts",
"a",
"stream",
"for",
"a",
"vb",
"on",
"a",
"feed"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/upr.go#L138-L173 |
24,264 | couchbase/go-couchbase | upr.go | UprCloseStream | func (feed *UprFeed) UprCloseStream(vb, opaqueMSB uint16) error {
defer func() {
if r := recover(); r != nil {
log.Panicf("Panic in UprCloseStream. Feed %v Bucket %v ", feed, feed.bucket)
}
}()
vbm := feed.bucket.VBServerMap()
if len(vbm.VBucketMap) < int(vb) {
return fmt.Errorf("vbmap smaller than vbuck... | go | func (feed *UprFeed) UprCloseStream(vb, opaqueMSB uint16) error {
defer func() {
if r := recover(); r != nil {
log.Panicf("Panic in UprCloseStream. Feed %v Bucket %v ", feed, feed.bucket)
}
}()
vbm := feed.bucket.VBServerMap()
if len(vbm.VBucketMap) < int(vb) {
return fmt.Errorf("vbmap smaller than vbuck... | [
"func",
"(",
"feed",
"*",
"UprFeed",
")",
"UprCloseStream",
"(",
"vb",
",",
"opaqueMSB",
"uint16",
")",
"error",
"{",
"defer",
"func",
"(",
")",
"{",
"if",
"r",
":=",
"recover",
"(",
")",
";",
"r",
"!=",
"nil",
"{",
"log",
".",
"Panicf",
"(",
"\"... | // UprCloseStream ends a vbucket stream. | [
"UprCloseStream",
"ends",
"a",
"vbucket",
"stream",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/upr.go#L176-L208 |
24,265 | couchbase/go-couchbase | upr.go | forwardUprEvents | func (feed *UprFeed) forwardUprEvents(nodeFeed *FeedInfo, killSwitch chan bool, host string) {
singleFeed := nodeFeed.uprFeed
defer func() {
feed.wg.Done()
if r := recover(); r != nil {
//if feed is not closing, re-throw the panic
if feed.outputClosed != true && feed.closing != true {
panic(r)
} els... | go | func (feed *UprFeed) forwardUprEvents(nodeFeed *FeedInfo, killSwitch chan bool, host string) {
singleFeed := nodeFeed.uprFeed
defer func() {
feed.wg.Done()
if r := recover(); r != nil {
//if feed is not closing, re-throw the panic
if feed.outputClosed != true && feed.closing != true {
panic(r)
} els... | [
"func",
"(",
"feed",
"*",
"UprFeed",
")",
"forwardUprEvents",
"(",
"nodeFeed",
"*",
"FeedInfo",
",",
"killSwitch",
"chan",
"bool",
",",
"host",
"string",
")",
"{",
"singleFeed",
":=",
"nodeFeed",
".",
"uprFeed",
"\n\n",
"defer",
"func",
"(",
")",
"{",
"f... | // Goroutine that forwards Upr events from a single node's feed to the aggregate feed. | [
"Goroutine",
"that",
"forwards",
"Upr",
"events",
"from",
"a",
"single",
"node",
"s",
"feed",
"to",
"the",
"aggregate",
"feed",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/upr.go#L315-L368 |
24,266 | couchbase/go-couchbase | upr.go | Close | func (feed *UprFeed) Close() error {
select {
case <-feed.quit:
return nil
default:
}
feed.closing = true
feed.closeNodeFeeds()
close(feed.quit)
feed.wg.Wait()
if feed.outputClosed == false {
feed.outputClosed = true
close(feed.output)
}
return nil
} | go | func (feed *UprFeed) Close() error {
select {
case <-feed.quit:
return nil
default:
}
feed.closing = true
feed.closeNodeFeeds()
close(feed.quit)
feed.wg.Wait()
if feed.outputClosed == false {
feed.outputClosed = true
close(feed.output)
}
return nil
} | [
"func",
"(",
"feed",
"*",
"UprFeed",
")",
"Close",
"(",
")",
"error",
"{",
"select",
"{",
"case",
"<-",
"feed",
".",
"quit",
":",
"return",
"nil",
"\n",
"default",
":",
"}",
"\n\n",
"feed",
".",
"closing",
"=",
"true",
"\n",
"feed",
".",
"closeNode... | // Close a Upr feed. | [
"Close",
"a",
"Upr",
"feed",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/upr.go#L380-L398 |
24,267 | couchbase/go-couchbase | client.go | IsRefreshRequired | func IsRefreshRequired(err error) bool {
res, ok := err.(*gomemcached.MCResponse)
if ok && (res.Status == gomemcached.NO_BUCKET || res.Status == gomemcached.NOT_MY_VBUCKET) {
return true
}
return false
} | go | func IsRefreshRequired(err error) bool {
res, ok := err.(*gomemcached.MCResponse)
if ok && (res.Status == gomemcached.NO_BUCKET || res.Status == gomemcached.NOT_MY_VBUCKET) {
return true
}
return false
} | [
"func",
"IsRefreshRequired",
"(",
"err",
"error",
")",
"bool",
"{",
"res",
",",
"ok",
":=",
"err",
".",
"(",
"*",
"gomemcached",
".",
"MCResponse",
")",
"\n",
"if",
"ok",
"&&",
"(",
"res",
".",
"Status",
"==",
"gomemcached",
".",
"NO_BUCKET",
"||",
"... | // Return true if error suggests a bucket refresh is required. Required by cbq-engine | [
"Return",
"true",
"if",
"error",
"suggests",
"a",
"bucket",
"refresh",
"is",
"required",
".",
"Required",
"by",
"cbq",
"-",
"engine"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L91-L99 |
24,268 | couchbase/go-couchbase | client.go | Do | func (b *Bucket) Do(k string, f func(mc *memcached.Client, vb uint16) error) (err error) {
return b.Do2(k, f, true)
} | go | func (b *Bucket) Do(k string, f func(mc *memcached.Client, vb uint16) error) (err error) {
return b.Do2(k, f, true)
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"Do",
"(",
"k",
"string",
",",
"f",
"func",
"(",
"mc",
"*",
"memcached",
".",
"Client",
",",
"vb",
"uint16",
")",
"error",
")",
"(",
"err",
"error",
")",
"{",
"return",
"b",
".",
"Do2",
"(",
"k",
",",
"f"... | // Do executes a function on a memcached connection to the node owning key "k"
//
// Note that this automatically handles transient errors by replaying
// your function on a "not-my-vbucket" error, so don't assume
// your command will only be executed only once. | [
"Do",
"executes",
"a",
"function",
"on",
"a",
"memcached",
"connection",
"to",
"the",
"node",
"owning",
"key",
"k",
"Note",
"that",
"this",
"automatically",
"handles",
"transient",
"errors",
"by",
"replaying",
"your",
"function",
"on",
"a",
"not",
"-",
"my",... | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L109-L111 |
24,269 | couchbase/go-couchbase | client.go | GetStats | func (b *Bucket) GetStats(which string) map[string]map[string]string {
rv := map[string]map[string]string{}
for server, gs := range b.GatherStats(which) {
if len(gs.Stats) > 0 {
rv[server] = gs.Stats
}
}
return rv
} | go | func (b *Bucket) GetStats(which string) map[string]map[string]string {
rv := map[string]map[string]string{}
for server, gs := range b.GatherStats(which) {
if len(gs.Stats) > 0 {
rv[server] = gs.Stats
}
}
return rv
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"GetStats",
"(",
"which",
"string",
")",
"map",
"[",
"string",
"]",
"map",
"[",
"string",
"]",
"string",
"{",
"rv",
":=",
"map",
"[",
"string",
"]",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n",
"for",... | // GetStats gets a set of stats from all servers.
//
// Returns a map of server ID -> map of stat key to map value. | [
"GetStats",
"gets",
"a",
"set",
"of",
"stats",
"from",
"all",
"servers",
".",
"Returns",
"a",
"map",
"of",
"server",
"ID",
"-",
">",
"map",
"of",
"stat",
"key",
"to",
"map",
"value",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L206-L214 |
24,270 | couchbase/go-couchbase | client.go | GatherStats | func (b *Bucket) GatherStats(which string) map[string]GatheredStats {
vsm := b.VBServerMap()
if vsm.ServerList == nil {
return nil
}
// Go grab all the things at once.
ch := make(chan GatheredStats, len(vsm.ServerList))
for i, sn := range vsm.ServerList {
go getStatsParallel(sn, b, i, which, ch)
}
// Gath... | go | func (b *Bucket) GatherStats(which string) map[string]GatheredStats {
vsm := b.VBServerMap()
if vsm.ServerList == nil {
return nil
}
// Go grab all the things at once.
ch := make(chan GatheredStats, len(vsm.ServerList))
for i, sn := range vsm.ServerList {
go getStatsParallel(sn, b, i, which, ch)
}
// Gath... | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"GatherStats",
"(",
"which",
"string",
")",
"map",
"[",
"string",
"]",
"GatheredStats",
"{",
"vsm",
":=",
"b",
".",
"VBServerMap",
"(",
")",
"\n",
"if",
"vsm",
".",
"ServerList",
"==",
"nil",
"{",
"return",
"nil"... | // GatherStats returns a map of server ID -> GatheredStats from all servers. | [
"GatherStats",
"returns",
"a",
"map",
"of",
"server",
"ID",
"-",
">",
"GatheredStats",
"from",
"all",
"servers",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L217-L236 |
24,271 | couchbase/go-couchbase | client.go | GetCount | func (b *Bucket) GetCount(refresh bool) (count int64, err error) {
if refresh {
b.Refresh()
}
var cnt int64
for _, gs := range b.GatherStats("") {
if len(gs.Stats) > 0 {
cnt, err = strconv.ParseInt(gs.Stats["curr_items"], 10, 64)
if err != nil {
return 0, err
}
count += cnt
}
}
return coun... | go | func (b *Bucket) GetCount(refresh bool) (count int64, err error) {
if refresh {
b.Refresh()
}
var cnt int64
for _, gs := range b.GatherStats("") {
if len(gs.Stats) > 0 {
cnt, err = strconv.ParseInt(gs.Stats["curr_items"], 10, 64)
if err != nil {
return 0, err
}
count += cnt
}
}
return coun... | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"GetCount",
"(",
"refresh",
"bool",
")",
"(",
"count",
"int64",
",",
"err",
"error",
")",
"{",
"if",
"refresh",
"{",
"b",
".",
"Refresh",
"(",
")",
"\n",
"}",
"\n\n",
"var",
"cnt",
"int64",
"\n",
"for",
"_",
... | // Get bucket count through the bucket stats | [
"Get",
"bucket",
"count",
"through",
"the",
"bucket",
"stats"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L239-L256 |
24,272 | couchbase/go-couchbase | client.go | GetSize | func (b *Bucket) GetSize(refresh bool) (size int64, err error) {
if refresh {
b.Refresh()
}
var sz int64
for _, gs := range b.GatherStats("") {
if len(gs.Stats) > 0 {
sz, err = strconv.ParseInt(gs.Stats["ep_value_size"], 10, 64)
if err != nil {
return 0, err
}
size += sz
}
}
return size, n... | go | func (b *Bucket) GetSize(refresh bool) (size int64, err error) {
if refresh {
b.Refresh()
}
var sz int64
for _, gs := range b.GatherStats("") {
if len(gs.Stats) > 0 {
sz, err = strconv.ParseInt(gs.Stats["ep_value_size"], 10, 64)
if err != nil {
return 0, err
}
size += sz
}
}
return size, n... | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"GetSize",
"(",
"refresh",
"bool",
")",
"(",
"size",
"int64",
",",
"err",
"error",
")",
"{",
"if",
"refresh",
"{",
"b",
".",
"Refresh",
"(",
")",
"\n",
"}",
"\n\n",
"var",
"sz",
"int64",
"\n",
"for",
"_",
"... | // Get bucket document size through the bucket stats | [
"Get",
"bucket",
"document",
"size",
"through",
"the",
"bucket",
"stats"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L259-L276 |
24,273 | couchbase/go-couchbase | client.go | isConnError | func isConnError(err error) bool {
if err == io.EOF {
return true
}
estr := err.Error()
return strings.Contains(estr, "broken pipe") ||
strings.Contains(estr, "connection reset") ||
strings.Contains(estr, "connection refused") ||
strings.Contains(estr, "connection pool is closed")
} | go | func isConnError(err error) bool {
if err == io.EOF {
return true
}
estr := err.Error()
return strings.Contains(estr, "broken pipe") ||
strings.Contains(estr, "connection reset") ||
strings.Contains(estr, "connection refused") ||
strings.Contains(estr, "connection pool is closed")
} | [
"func",
"isConnError",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"err",
"==",
"io",
".",
"EOF",
"{",
"return",
"true",
"\n",
"}",
"\n",
"estr",
":=",
"err",
".",
"Error",
"(",
")",
"\n",
"return",
"strings",
".",
"Contains",
"(",
"estr",
",",
... | // Errors that are not considered fatal for our fetch loop | [
"Errors",
"that",
"are",
"not",
"considered",
"fatal",
"for",
"our",
"fetch",
"loop"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L297-L306 |
24,274 | couchbase/go-couchbase | client.go | GetBulk | func (b *Bucket) GetBulk(keys []string, reqDeadline time.Time, subPaths []string) (map[string]*gomemcached.MCResponse, error) {
return b.getBulk(keys, reqDeadline, subPaths)
} | go | func (b *Bucket) GetBulk(keys []string, reqDeadline time.Time, subPaths []string) (map[string]*gomemcached.MCResponse, error) {
return b.getBulk(keys, reqDeadline, subPaths)
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"GetBulk",
"(",
"keys",
"[",
"]",
"string",
",",
"reqDeadline",
"time",
".",
"Time",
",",
"subPaths",
"[",
"]",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"*",
"gomemcached",
".",
"MCResponse",
",",
"error",
... | // GetBulk fetches multiple keys concurrently.
//
// Unlike more convenient GETs, the entire response is returned in the
// map array for each key. Keys that were not found will not be included in
// the map. | [
"GetBulk",
"fetches",
"multiple",
"keys",
"concurrently",
".",
"Unlike",
"more",
"convenient",
"GETs",
"the",
"entire",
"response",
"is",
"returned",
"in",
"the",
"map",
"array",
"for",
"each",
"key",
".",
"Keys",
"that",
"were",
"not",
"found",
"will",
"not... | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L635-L637 |
24,275 | couchbase/go-couchbase | client.go | String | func (w WriteOptions) String() string {
f := []string{}
for _, on := range optNames {
if w&on.opt != 0 {
f = append(f, on.name)
w &= ^on.opt
}
}
if len(f) == 0 || w != 0 {
f = append(f, fmt.Sprintf("0x%x", int(w)))
}
return strings.Join(f, "|")
} | go | func (w WriteOptions) String() string {
f := []string{}
for _, on := range optNames {
if w&on.opt != 0 {
f = append(f, on.name)
w &= ^on.opt
}
}
if len(f) == 0 || w != 0 {
f = append(f, fmt.Sprintf("0x%x", int(w)))
}
return strings.Join(f, "|")
} | [
"func",
"(",
"w",
"WriteOptions",
")",
"String",
"(",
")",
"string",
"{",
"f",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"_",
",",
"on",
":=",
"range",
"optNames",
"{",
"if",
"w",
"&",
"on",
".",
"opt",
"!=",
"0",
"{",
"f",
"=",
"appen... | // String representation of WriteOptions | [
"String",
"representation",
"of",
"WriteOptions"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L716-L728 |
24,276 | couchbase/go-couchbase | client.go | Cas | func (b *Bucket) Cas(k string, exp int, cas uint64, v interface{}) (uint64, error) {
return b.WriteCas(k, 0, exp, cas, v, 0)
} | go | func (b *Bucket) Cas(k string, exp int, cas uint64, v interface{}) (uint64, error) {
return b.WriteCas(k, 0, exp, cas, v, 0)
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"Cas",
"(",
"k",
"string",
",",
"exp",
"int",
",",
"cas",
"uint64",
",",
"v",
"interface",
"{",
"}",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"return",
"b",
".",
"WriteCas",
"(",
"k",
",",
"0",
",",
"e... | // Set a value in this bucket with Cas and return the new Cas value | [
"Set",
"a",
"value",
"in",
"this",
"bucket",
"with",
"Cas",
"and",
"return",
"the",
"new",
"Cas",
"value"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L846-L848 |
24,277 | couchbase/go-couchbase | client.go | CasRaw | func (b *Bucket) CasRaw(k string, exp int, cas uint64, v interface{}) (uint64, error) {
return b.WriteCas(k, 0, exp, cas, v, Raw)
} | go | func (b *Bucket) CasRaw(k string, exp int, cas uint64, v interface{}) (uint64, error) {
return b.WriteCas(k, 0, exp, cas, v, Raw)
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"CasRaw",
"(",
"k",
"string",
",",
"exp",
"int",
",",
"cas",
"uint64",
",",
"v",
"interface",
"{",
"}",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"return",
"b",
".",
"WriteCas",
"(",
"k",
",",
"0",
",",
... | // Set a value in this bucket with Cas without json encoding it | [
"Set",
"a",
"value",
"in",
"this",
"bucket",
"with",
"Cas",
"without",
"json",
"encoding",
"it"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L851-L853 |
24,278 | couchbase/go-couchbase | client.go | CasWithMeta | func (b *Bucket) CasWithMeta(k string, flags int, exp int, cas uint64, v interface{}) (uint64, *MutationToken, error) {
return b.WriteCasWithMT(k, flags, exp, cas, v, 0)
} | go | func (b *Bucket) CasWithMeta(k string, flags int, exp int, cas uint64, v interface{}) (uint64, *MutationToken, error) {
return b.WriteCasWithMT(k, flags, exp, cas, v, 0)
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"CasWithMeta",
"(",
"k",
"string",
",",
"flags",
"int",
",",
"exp",
"int",
",",
"cas",
"uint64",
",",
"v",
"interface",
"{",
"}",
")",
"(",
"uint64",
",",
"*",
"MutationToken",
",",
"error",
")",
"{",
"return",... | // Extended CAS operation. These functions will return the mutation token, i.e vbuuid & guard | [
"Extended",
"CAS",
"operation",
".",
"These",
"functions",
"will",
"return",
"the",
"mutation",
"token",
"i",
".",
"e",
"vbuuid",
"&",
"guard"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L888-L890 |
24,279 | couchbase/go-couchbase | client.go | Set | func (b *Bucket) Set(k string, exp int, v interface{}) error {
return b.Write(k, 0, exp, v, 0)
} | go | func (b *Bucket) Set(k string, exp int, v interface{}) error {
return b.Write(k, 0, exp, v, 0)
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"Set",
"(",
"k",
"string",
",",
"exp",
"int",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"b",
".",
"Write",
"(",
"k",
",",
"0",
",",
"exp",
",",
"v",
",",
"0",
")",
"\n",
"}"
] | // Set a value in this bucket.
// The value will be serialized into a JSON document. | [
"Set",
"a",
"value",
"in",
"this",
"bucket",
".",
"The",
"value",
"will",
"be",
"serialized",
"into",
"a",
"JSON",
"document",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L942-L944 |
24,280 | couchbase/go-couchbase | client.go | SetWithMeta | func (b *Bucket) SetWithMeta(k string, flags int, exp int, v interface{}) (*MutationToken, error) {
return b.WriteWithMT(k, flags, exp, v, 0)
} | go | func (b *Bucket) SetWithMeta(k string, flags int, exp int, v interface{}) (*MutationToken, error) {
return b.WriteWithMT(k, flags, exp, v, 0)
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"SetWithMeta",
"(",
"k",
"string",
",",
"flags",
"int",
",",
"exp",
"int",
",",
"v",
"interface",
"{",
"}",
")",
"(",
"*",
"MutationToken",
",",
"error",
")",
"{",
"return",
"b",
".",
"WriteWithMT",
"(",
"k",
... | // Set a value in this bucket with with flags | [
"Set",
"a",
"value",
"in",
"this",
"bucket",
"with",
"with",
"flags"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L947-L949 |
24,281 | couchbase/go-couchbase | client.go | SetRaw | func (b *Bucket) SetRaw(k string, exp int, v []byte) error {
return b.Write(k, 0, exp, v, Raw)
} | go | func (b *Bucket) SetRaw(k string, exp int, v []byte) error {
return b.Write(k, 0, exp, v, Raw)
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"SetRaw",
"(",
"k",
"string",
",",
"exp",
"int",
",",
"v",
"[",
"]",
"byte",
")",
"error",
"{",
"return",
"b",
".",
"Write",
"(",
"k",
",",
"0",
",",
"exp",
",",
"v",
",",
"Raw",
")",
"\n",
"}"
] | // SetRaw sets a value in this bucket without JSON encoding it. | [
"SetRaw",
"sets",
"a",
"value",
"in",
"this",
"bucket",
"without",
"JSON",
"encoding",
"it",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L952-L954 |
24,282 | couchbase/go-couchbase | client.go | Append | func (b *Bucket) Append(k string, data []byte) error {
return b.Write(k, 0, 0, data, Append|Raw)
} | go | func (b *Bucket) Append(k string, data []byte) error {
return b.Write(k, 0, 0, data, Append|Raw)
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"Append",
"(",
"k",
"string",
",",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"return",
"b",
".",
"Write",
"(",
"k",
",",
"0",
",",
"0",
",",
"data",
",",
"Append",
"|",
"Raw",
")",
"\n",
"}"
] | // Append appends raw data to an existing item. | [
"Append",
"appends",
"raw",
"data",
"to",
"an",
"existing",
"item",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L999-L1001 |
24,283 | couchbase/go-couchbase | client.go | GetCollectionCID | func (b *Bucket) GetCollectionCID(scope string, collection string, reqDeadline time.Time) (uint32, uint32, error) {
var err error
var response *gomemcached.MCResponse
if ClientOpCallback != nil {
defer func(t time.Time) { ClientOpCallback("GetCollectionCID", scope+"."+collection, t, err) }(time.Now())
}
var ke... | go | func (b *Bucket) GetCollectionCID(scope string, collection string, reqDeadline time.Time) (uint32, uint32, error) {
var err error
var response *gomemcached.MCResponse
if ClientOpCallback != nil {
defer func(t time.Time) { ClientOpCallback("GetCollectionCID", scope+"."+collection, t, err) }(time.Now())
}
var ke... | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"GetCollectionCID",
"(",
"scope",
"string",
",",
"collection",
"string",
",",
"reqDeadline",
"time",
".",
"Time",
")",
"(",
"uint32",
",",
"uint32",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"var",
"resp... | // Returns collectionUid, manifestUid, error. | [
"Returns",
"collectionUid",
"manifestUid",
"error",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L1039-L1073 |
24,284 | couchbase/go-couchbase | client.go | GetsMC | func (b *Bucket) GetsMC(key string, reqDeadline time.Time) (*gomemcached.MCResponse, error) {
var err error
var response *gomemcached.MCResponse
if key == "" {
return nil, nil
}
if ClientOpCallback != nil {
defer func(t time.Time) { ClientOpCallback("GetsMC", key, t, err) }(time.Now())
}
err = b.Do2(key, ... | go | func (b *Bucket) GetsMC(key string, reqDeadline time.Time) (*gomemcached.MCResponse, error) {
var err error
var response *gomemcached.MCResponse
if key == "" {
return nil, nil
}
if ClientOpCallback != nil {
defer func(t time.Time) { ClientOpCallback("GetsMC", key, t, err) }(time.Now())
}
err = b.Do2(key, ... | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"GetsMC",
"(",
"key",
"string",
",",
"reqDeadline",
"time",
".",
"Time",
")",
"(",
"*",
"gomemcached",
".",
"MCResponse",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"var",
"response",
"*",
"gomemcached",
... | // Get a value straight from Memcached | [
"Get",
"a",
"value",
"straight",
"from",
"Memcached"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L1076-L1100 |
24,285 | couchbase/go-couchbase | client.go | GetsRaw | func (b *Bucket) GetsRaw(k string) (data []byte, flags int,
cas uint64, err error) {
if ClientOpCallback != nil {
defer func(t time.Time) { ClientOpCallback("GetsRaw", k, t, err) }(time.Now())
}
err = b.Do(k, func(mc *memcached.Client, vb uint16) error {
res, err := mc.Get(vb, k)
if err != nil {
return e... | go | func (b *Bucket) GetsRaw(k string) (data []byte, flags int,
cas uint64, err error) {
if ClientOpCallback != nil {
defer func(t time.Time) { ClientOpCallback("GetsRaw", k, t, err) }(time.Now())
}
err = b.Do(k, func(mc *memcached.Client, vb uint16) error {
res, err := mc.Get(vb, k)
if err != nil {
return e... | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"GetsRaw",
"(",
"k",
"string",
")",
"(",
"data",
"[",
"]",
"byte",
",",
"flags",
"int",
",",
"cas",
"uint64",
",",
"err",
"error",
")",
"{",
"if",
"ClientOpCallback",
"!=",
"nil",
"{",
"defer",
"func",
"(",
"... | // GetsRaw gets a raw value from this bucket including its CAS
// counter and flags. | [
"GetsRaw",
"gets",
"a",
"raw",
"value",
"from",
"this",
"bucket",
"including",
"its",
"CAS",
"counter",
"and",
"flags",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L1131-L1151 |
24,286 | couchbase/go-couchbase | client.go | Gets | func (b *Bucket) Gets(k string, rv interface{}, caso *uint64) error {
data, _, cas, err := b.GetsRaw(k)
if err != nil {
return err
}
if caso != nil {
*caso = cas
}
return json.Unmarshal(data, rv)
} | go | func (b *Bucket) Gets(k string, rv interface{}, caso *uint64) error {
data, _, cas, err := b.GetsRaw(k)
if err != nil {
return err
}
if caso != nil {
*caso = cas
}
return json.Unmarshal(data, rv)
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"Gets",
"(",
"k",
"string",
",",
"rv",
"interface",
"{",
"}",
",",
"caso",
"*",
"uint64",
")",
"error",
"{",
"data",
",",
"_",
",",
"cas",
",",
"err",
":=",
"b",
".",
"GetsRaw",
"(",
"k",
")",
"\n",
"if",... | // Gets gets a value from this bucket, including its CAS counter. The
// value is expected to be a JSON stream and will be deserialized into
// rv. | [
"Gets",
"gets",
"a",
"value",
"from",
"this",
"bucket",
"including",
"its",
"CAS",
"counter",
".",
"The",
"value",
"is",
"expected",
"to",
"be",
"a",
"JSON",
"stream",
"and",
"will",
"be",
"deserialized",
"into",
"rv",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L1156-L1165 |
24,287 | couchbase/go-couchbase | client.go | Get | func (b *Bucket) Get(k string, rv interface{}) error {
return b.Gets(k, rv, nil)
} | go | func (b *Bucket) Get(k string, rv interface{}) error {
return b.Gets(k, rv, nil)
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"Get",
"(",
"k",
"string",
",",
"rv",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"b",
".",
"Gets",
"(",
"k",
",",
"rv",
",",
"nil",
")",
"\n",
"}"
] | // Get a value from this bucket.
// The value is expected to be a JSON stream and will be deserialized
// into rv. | [
"Get",
"a",
"value",
"from",
"this",
"bucket",
".",
"The",
"value",
"is",
"expected",
"to",
"be",
"a",
"JSON",
"stream",
"and",
"will",
"be",
"deserialized",
"into",
"rv",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L1170-L1172 |
24,288 | couchbase/go-couchbase | client.go | GetRaw | func (b *Bucket) GetRaw(k string) ([]byte, error) {
d, _, _, err := b.GetsRaw(k)
return d, err
} | go | func (b *Bucket) GetRaw(k string) ([]byte, error) {
d, _, _, err := b.GetsRaw(k)
return d, err
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"GetRaw",
"(",
"k",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"d",
",",
"_",
",",
"_",
",",
"err",
":=",
"b",
".",
"GetsRaw",
"(",
"k",
")",
"\n",
"return",
"d",
",",
"err",
"\n",
... | // GetRaw gets a raw value from this bucket. No marshaling is performed. | [
"GetRaw",
"gets",
"a",
"raw",
"value",
"from",
"this",
"bucket",
".",
"No",
"marshaling",
"is",
"performed",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L1175-L1178 |
24,289 | couchbase/go-couchbase | client.go | GetAndTouchRaw | func (b *Bucket) GetAndTouchRaw(k string, exp int) (data []byte,
cas uint64, err error) {
if ClientOpCallback != nil {
defer func(t time.Time) { ClientOpCallback("GetsRaw", k, t, err) }(time.Now())
}
err = b.Do(k, func(mc *memcached.Client, vb uint16) error {
res, err := mc.GetAndTouch(vb, k, exp)
if err !=... | go | func (b *Bucket) GetAndTouchRaw(k string, exp int) (data []byte,
cas uint64, err error) {
if ClientOpCallback != nil {
defer func(t time.Time) { ClientOpCallback("GetsRaw", k, t, err) }(time.Now())
}
err = b.Do(k, func(mc *memcached.Client, vb uint16) error {
res, err := mc.GetAndTouch(vb, k, exp)
if err !=... | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"GetAndTouchRaw",
"(",
"k",
"string",
",",
"exp",
"int",
")",
"(",
"data",
"[",
"]",
"byte",
",",
"cas",
"uint64",
",",
"err",
"error",
")",
"{",
"if",
"ClientOpCallback",
"!=",
"nil",
"{",
"defer",
"func",
"("... | // GetAndTouchRaw gets a raw value from this bucket including its CAS
// counter and flags, and updates the expiry on the doc. | [
"GetAndTouchRaw",
"gets",
"a",
"raw",
"value",
"from",
"this",
"bucket",
"including",
"its",
"CAS",
"counter",
"and",
"flags",
"and",
"updates",
"the",
"expiry",
"on",
"the",
"doc",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L1182-L1199 |
24,290 | couchbase/go-couchbase | client.go | GetMeta | func (b *Bucket) GetMeta(k string, flags *int, expiry *int, cas *uint64, seqNo *uint64) (err error) {
if ClientOpCallback != nil {
defer func(t time.Time) { ClientOpCallback("GetsMeta", k, t, err) }(time.Now())
}
err = b.Do(k, func(mc *memcached.Client, vb uint16) error {
res, err := mc.GetMeta(vb, k)
if err... | go | func (b *Bucket) GetMeta(k string, flags *int, expiry *int, cas *uint64, seqNo *uint64) (err error) {
if ClientOpCallback != nil {
defer func(t time.Time) { ClientOpCallback("GetsMeta", k, t, err) }(time.Now())
}
err = b.Do(k, func(mc *memcached.Client, vb uint16) error {
res, err := mc.GetMeta(vb, k)
if err... | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"GetMeta",
"(",
"k",
"string",
",",
"flags",
"*",
"int",
",",
"expiry",
"*",
"int",
",",
"cas",
"*",
"uint64",
",",
"seqNo",
"*",
"uint64",
")",
"(",
"err",
"error",
")",
"{",
"if",
"ClientOpCallback",
"!=",
... | // GetMeta returns the meta values for a key | [
"GetMeta",
"returns",
"the",
"meta",
"values",
"for",
"a",
"key"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L1202-L1231 |
24,291 | couchbase/go-couchbase | client.go | Delete | func (b *Bucket) Delete(k string) error {
return b.Write(k, 0, 0, nil, Raw)
} | go | func (b *Bucket) Delete(k string) error {
return b.Write(k, 0, 0, nil, Raw)
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"Delete",
"(",
"k",
"string",
")",
"error",
"{",
"return",
"b",
".",
"Write",
"(",
"k",
",",
"0",
",",
"0",
",",
"nil",
",",
"Raw",
")",
"\n",
"}"
] | // Delete a key from this bucket. | [
"Delete",
"a",
"key",
"from",
"this",
"bucket",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L1234-L1236 |
24,292 | couchbase/go-couchbase | client.go | Incr | func (b *Bucket) Incr(k string, amt, def uint64, exp int) (val uint64, err error) {
if ClientOpCallback != nil {
defer func(t time.Time) { ClientOpCallback("Incr", k, t, err) }(time.Now())
}
var rv uint64
err = b.Do(k, func(mc *memcached.Client, vb uint16) error {
res, err := mc.Incr(vb, k, amt, def, exp)
if... | go | func (b *Bucket) Incr(k string, amt, def uint64, exp int) (val uint64, err error) {
if ClientOpCallback != nil {
defer func(t time.Time) { ClientOpCallback("Incr", k, t, err) }(time.Now())
}
var rv uint64
err = b.Do(k, func(mc *memcached.Client, vb uint16) error {
res, err := mc.Incr(vb, k, amt, def, exp)
if... | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"Incr",
"(",
"k",
"string",
",",
"amt",
",",
"def",
"uint64",
",",
"exp",
"int",
")",
"(",
"val",
"uint64",
",",
"err",
"error",
")",
"{",
"if",
"ClientOpCallback",
"!=",
"nil",
"{",
"defer",
"func",
"(",
"t"... | // Incr increments the value at a given key by amt and defaults to def if no value present. | [
"Incr",
"increments",
"the",
"value",
"at",
"a",
"given",
"key",
"by",
"amt",
"and",
"defaults",
"to",
"def",
"if",
"no",
"value",
"present",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L1239-L1254 |
24,293 | couchbase/go-couchbase | client.go | update | func (b *Bucket) update(k string, exp int, callback UpdateFunc) (newCas uint64, err error) {
var state memcached.CASState
for b.casNext(k, exp, &state) {
var err error
if state.Value, err = callback(state.Value); err != nil {
return 0, err
}
}
return state.Cas, state.Err
} | go | func (b *Bucket) update(k string, exp int, callback UpdateFunc) (newCas uint64, err error) {
var state memcached.CASState
for b.casNext(k, exp, &state) {
var err error
if state.Value, err = callback(state.Value); err != nil {
return 0, err
}
}
return state.Cas, state.Err
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"update",
"(",
"k",
"string",
",",
"exp",
"int",
",",
"callback",
"UpdateFunc",
")",
"(",
"newCas",
"uint64",
",",
"err",
"error",
")",
"{",
"var",
"state",
"memcached",
".",
"CASState",
"\n",
"for",
"b",
".",
... | // internal version of Update that returns a CAS value | [
"internal",
"version",
"of",
"Update",
"that",
"returns",
"a",
"CAS",
"value"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L1313-L1322 |
24,294 | couchbase/go-couchbase | client.go | Observe | func (b *Bucket) Observe(k string) (result memcached.ObserveResult, err error) {
if ClientOpCallback != nil {
defer func(t time.Time) { ClientOpCallback("Observe", k, t, err) }(time.Now())
}
err = b.Do(k, func(mc *memcached.Client, vb uint16) error {
result, err = mc.Observe(vb, k)
return err
})
return
} | go | func (b *Bucket) Observe(k string) (result memcached.ObserveResult, err error) {
if ClientOpCallback != nil {
defer func(t time.Time) { ClientOpCallback("Observe", k, t, err) }(time.Now())
}
err = b.Do(k, func(mc *memcached.Client, vb uint16) error {
result, err = mc.Observe(vb, k)
return err
})
return
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"Observe",
"(",
"k",
"string",
")",
"(",
"result",
"memcached",
".",
"ObserveResult",
",",
"err",
"error",
")",
"{",
"if",
"ClientOpCallback",
"!=",
"nil",
"{",
"defer",
"func",
"(",
"t",
"time",
".",
"Time",
")"... | // Observe observes the current state of a document. | [
"Observe",
"observes",
"the",
"current",
"state",
"of",
"a",
"document",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L1355-L1365 |
24,295 | couchbase/go-couchbase | client.go | WaitForPersistence | func (b *Bucket) WaitForPersistence(k string, cas uint64, deletion bool) error {
timeout := 10 * time.Second
sleepDelay := 5 * time.Millisecond
start := time.Now()
for {
time.Sleep(sleepDelay)
sleepDelay += sleepDelay / 2 // multiply delay by 1.5 every time
result, err := b.Observe(k)
if err != nil {
re... | go | func (b *Bucket) WaitForPersistence(k string, cas uint64, deletion bool) error {
timeout := 10 * time.Second
sleepDelay := 5 * time.Millisecond
start := time.Now()
for {
time.Sleep(sleepDelay)
sleepDelay += sleepDelay / 2 // multiply delay by 1.5 every time
result, err := b.Observe(k)
if err != nil {
re... | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"WaitForPersistence",
"(",
"k",
"string",
",",
"cas",
"uint64",
",",
"deletion",
"bool",
")",
"error",
"{",
"timeout",
":=",
"10",
"*",
"time",
".",
"Second",
"\n",
"sleepDelay",
":=",
"5",
"*",
"time",
".",
"Mil... | // WaitForPersistence waits for an item to be considered durable.
//
// Besides transport errors, ErrOverwritten may be returned if the
// item is overwritten before it reaches durability. ErrTimeout may
// occur if the item isn't found durable in a reasonable amount of
// time. | [
"WaitForPersistence",
"waits",
"for",
"an",
"item",
"to",
"be",
"considered",
"durable",
".",
"Besides",
"transport",
"errors",
"ErrOverwritten",
"may",
"be",
"returned",
"if",
"the",
"item",
"is",
"overwritten",
"before",
"it",
"reaches",
"durability",
".",
"Er... | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/client.go#L1381-L1406 |
24,296 | couchbase/go-couchbase | tap.go | StartTapFeed | func (b *Bucket) StartTapFeed(args *memcached.TapArguments) (*TapFeed, error) {
if args == nil {
defaultArgs := memcached.DefaultTapArguments()
args = &defaultArgs
}
feed := &TapFeed{
bucket: b,
args: args,
output: make(chan memcached.TapEvent, 10),
quit: make(chan bool),
}
go feed.run()
feed.C... | go | func (b *Bucket) StartTapFeed(args *memcached.TapArguments) (*TapFeed, error) {
if args == nil {
defaultArgs := memcached.DefaultTapArguments()
args = &defaultArgs
}
feed := &TapFeed{
bucket: b,
args: args,
output: make(chan memcached.TapEvent, 10),
quit: make(chan bool),
}
go feed.run()
feed.C... | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"StartTapFeed",
"(",
"args",
"*",
"memcached",
".",
"TapArguments",
")",
"(",
"*",
"TapFeed",
",",
"error",
")",
"{",
"if",
"args",
"==",
"nil",
"{",
"defaultArgs",
":=",
"memcached",
".",
"DefaultTapArguments",
"(",... | // StartTapFeed creates and starts a new Tap feed | [
"StartTapFeed",
"creates",
"and",
"starts",
"a",
"new",
"Tap",
"feed"
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/tap.go#L30-L47 |
24,297 | couchbase/go-couchbase | tap.go | forwardTapEvents | func (feed *TapFeed) forwardTapEvents(singleFeed *memcached.TapFeed, killSwitch chan bool, host string) {
defer feed.wg.Done()
for {
select {
case event, ok := <-singleFeed.C:
if !ok {
if singleFeed.Error != nil {
logging.Errorf("go-couchbase: Tap feed from %s failed: %v", host, singleFeed.Error)
... | go | func (feed *TapFeed) forwardTapEvents(singleFeed *memcached.TapFeed, killSwitch chan bool, host string) {
defer feed.wg.Done()
for {
select {
case event, ok := <-singleFeed.C:
if !ok {
if singleFeed.Error != nil {
logging.Errorf("go-couchbase: Tap feed from %s failed: %v", host, singleFeed.Error)
... | [
"func",
"(",
"feed",
"*",
"TapFeed",
")",
"forwardTapEvents",
"(",
"singleFeed",
"*",
"memcached",
".",
"TapFeed",
",",
"killSwitch",
"chan",
"bool",
",",
"host",
"string",
")",
"{",
"defer",
"feed",
".",
"wg",
".",
"Done",
"(",
")",
"\n",
"for",
"{",
... | // Goroutine that forwards Tap events from a single node's feed to the aggregate feed. | [
"Goroutine",
"that",
"forwards",
"Tap",
"events",
"from",
"a",
"single",
"node",
"s",
"feed",
"to",
"the",
"aggregate",
"feed",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/tap.go#L104-L121 |
24,298 | couchbase/go-couchbase | tap.go | Close | func (feed *TapFeed) Close() error {
select {
case <-feed.quit:
return nil
default:
}
feed.closeNodeFeeds()
close(feed.quit)
feed.wg.Wait()
close(feed.output)
return nil
} | go | func (feed *TapFeed) Close() error {
select {
case <-feed.quit:
return nil
default:
}
feed.closeNodeFeeds()
close(feed.quit)
feed.wg.Wait()
close(feed.output)
return nil
} | [
"func",
"(",
"feed",
"*",
"TapFeed",
")",
"Close",
"(",
")",
"error",
"{",
"select",
"{",
"case",
"<-",
"feed",
".",
"quit",
":",
"return",
"nil",
"\n",
"default",
":",
"}",
"\n\n",
"feed",
".",
"closeNodeFeeds",
"(",
")",
"\n",
"close",
"(",
"feed... | // Close a Tap feed. | [
"Close",
"a",
"Tap",
"feed",
"."
] | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/tap.go#L131-L143 |
24,299 | couchbase/go-couchbase | util/viewmgmt.go | UpdateView | func UpdateView(d *couchbase.Bucket,
ddocName, markerKey, ddocBody string, version int) error {
marker := ViewMarker{}
err := d.Get(markerKey, &marker)
if err != nil {
log.Printf("Error checking view version: %v", err)
}
if marker.Version < version {
log.Printf("Installing new version of views (old version=%... | go | func UpdateView(d *couchbase.Bucket,
ddocName, markerKey, ddocBody string, version int) error {
marker := ViewMarker{}
err := d.Get(markerKey, &marker)
if err != nil {
log.Printf("Error checking view version: %v", err)
}
if marker.Version < version {
log.Printf("Installing new version of views (old version=%... | [
"func",
"UpdateView",
"(",
"d",
"*",
"couchbase",
".",
"Bucket",
",",
"ddocName",
",",
"markerKey",
",",
"ddocBody",
"string",
",",
"version",
"int",
")",
"error",
"{",
"marker",
":=",
"ViewMarker",
"{",
"}",
"\n",
"err",
":=",
"d",
".",
"Get",
"(",
... | // UpdateView installs or updates a view.
//
// This creates a document that tracks the version of design document
// in couchbase and updates it if it's behind the version specified.
//
// A ViewMarker is stored with a type of "viewmarker" under the key
// specified by `markerKey` to keep up with the view info. | [
"UpdateView",
"installs",
"or",
"updates",
"a",
"view",
".",
"This",
"creates",
"a",
"document",
"that",
"tracks",
"the",
"version",
"of",
"design",
"document",
"in",
"couchbase",
"and",
"updates",
"it",
"if",
"it",
"s",
"behind",
"the",
"version",
"specifie... | 6aeabeae85e5645306382779e3ee55a330ec558c | https://github.com/couchbase/go-couchbase/blob/6aeabeae85e5645306382779e3ee55a330ec558c/util/viewmgmt.go#L28-L51 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.