id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
24,700 | dropbox/godropbox | database/binlog/query_event.go | Parse | func (p *QueryEventParser) Parse(raw *RawV4Event) (Event, error) {
query := &QueryEvent{
Event: raw,
}
type fixedBodyStruct struct {
ThreadId uint32
Duration uint32
DatabaseNameLength uint8
ErrorCode uint16
StatusLength uint16
}
fixed := fixedBodyStruct{}
_, err :... | go | func (p *QueryEventParser) Parse(raw *RawV4Event) (Event, error) {
query := &QueryEvent{
Event: raw,
}
type fixedBodyStruct struct {
ThreadId uint32
Duration uint32
DatabaseNameLength uint8
ErrorCode uint16
StatusLength uint16
}
fixed := fixedBodyStruct{}
_, err :... | [
"func",
"(",
"p",
"*",
"QueryEventParser",
")",
"Parse",
"(",
"raw",
"*",
"RawV4Event",
")",
"(",
"Event",
",",
"error",
")",
"{",
"query",
":=",
"&",
"QueryEvent",
"{",
"Event",
":",
"raw",
",",
"}",
"\n\n",
"type",
"fixedBodyStruct",
"struct",
"{",
... | // QueryEventParser's Parse processes a raw query event into a QueryEvent. | [
"QueryEventParser",
"s",
"Parse",
"processes",
"a",
"raw",
"query",
"event",
"into",
"a",
"QueryEvent",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/binlog/query_event.go#L259-L302 |
24,701 | dropbox/godropbox | database/binlog/rotate_event.go | Parse | func (p *RotateEventParser) Parse(raw *RawV4Event) (Event, error) {
rotate := &RotateEvent{
Event: raw,
newLogName: raw.VariableLengthData(),
}
_, err := readLittleEndian(raw.FixedLengthData(), &rotate.newPosition)
if err != nil {
return raw, errors.Wrap(err, "Failed to read new log position")
}
retu... | go | func (p *RotateEventParser) Parse(raw *RawV4Event) (Event, error) {
rotate := &RotateEvent{
Event: raw,
newLogName: raw.VariableLengthData(),
}
_, err := readLittleEndian(raw.FixedLengthData(), &rotate.newPosition)
if err != nil {
return raw, errors.Wrap(err, "Failed to read new log position")
}
retu... | [
"func",
"(",
"p",
"*",
"RotateEventParser",
")",
"Parse",
"(",
"raw",
"*",
"RawV4Event",
")",
"(",
"Event",
",",
"error",
")",
"{",
"rotate",
":=",
"&",
"RotateEvent",
"{",
"Event",
":",
"raw",
",",
"newLogName",
":",
"raw",
".",
"VariableLengthData",
... | // RotateEventParser's Parse processes a raw rotate event into a RotateEvent. | [
"RotateEventParser",
"s",
"Parse",
"processes",
"a",
"raw",
"rotate",
"event",
"into",
"a",
"RotateEvent",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/binlog/rotate_event.go#L57-L69 |
24,702 | dropbox/godropbox | database/binlog/format_description_event.go | FixedLengthDataSizeForType | func (e *FormatDescriptionEvent) FixedLengthDataSizeForType(
eventType mysql_proto.LogEventType_Type) int {
return e.fixedLengthSizes[eventType]
} | go | func (e *FormatDescriptionEvent) FixedLengthDataSizeForType(
eventType mysql_proto.LogEventType_Type) int {
return e.fixedLengthSizes[eventType]
} | [
"func",
"(",
"e",
"*",
"FormatDescriptionEvent",
")",
"FixedLengthDataSizeForType",
"(",
"eventType",
"mysql_proto",
".",
"LogEventType_Type",
")",
"int",
"{",
"return",
"e",
".",
"fixedLengthSizes",
"[",
"eventType",
"]",
"\n",
"}"
] | // FixedLengthDataSizeForType returns the size of fixed length data for each
// event type. | [
"FixedLengthDataSizeForType",
"returns",
"the",
"size",
"of",
"fixed",
"length",
"data",
"for",
"each",
"event",
"type",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/binlog/format_description_event.go#L73-L77 |
24,703 | dropbox/godropbox | database/binlog/format_description_event.go | Parse | func (p *FormatDescriptionEventParser) Parse(raw *RawV4Event) (Event, error) {
fde := &FormatDescriptionEvent{
Event: raw,
fixedLengthSizes: make(map[mysql_proto.LogEventType_Type]int),
}
data := raw.VariableLengthData()
data, err := readLittleEndian(data, &fde.binlogVersion)
if err != nil {
ret... | go | func (p *FormatDescriptionEventParser) Parse(raw *RawV4Event) (Event, error) {
fde := &FormatDescriptionEvent{
Event: raw,
fixedLengthSizes: make(map[mysql_proto.LogEventType_Type]int),
}
data := raw.VariableLengthData()
data, err := readLittleEndian(data, &fde.binlogVersion)
if err != nil {
ret... | [
"func",
"(",
"p",
"*",
"FormatDescriptionEventParser",
")",
"Parse",
"(",
"raw",
"*",
"RawV4Event",
")",
"(",
"Event",
",",
"error",
")",
"{",
"fde",
":=",
"&",
"FormatDescriptionEvent",
"{",
"Event",
":",
"raw",
",",
"fixedLengthSizes",
":",
"make",
"(",
... | // FormatDecriptionEventParser's Parse processes a raw FDE event into a
// FormatDescriptionEvent. | [
"FormatDecriptionEventParser",
"s",
"Parse",
"processes",
"a",
"raw",
"FDE",
"event",
"into",
"a",
"FormatDescriptionEvent",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/binlog/format_description_event.go#L116-L182 |
24,704 | dropbox/godropbox | lockstore/store.go | New | func New(options LockStoreOptions) LockStore {
testTryLockCallback := options.testTryLockCallback
if testTryLockCallback == nil {
testTryLockCallback = func() {}
}
lock := _LockStoreImp{
granularity: options.Granularity,
testTryLockCallback: testTryLockCallback,
}
switch options.Granularity {
cas... | go | func New(options LockStoreOptions) LockStore {
testTryLockCallback := options.testTryLockCallback
if testTryLockCallback == nil {
testTryLockCallback = func() {}
}
lock := _LockStoreImp{
granularity: options.Granularity,
testTryLockCallback: testTryLockCallback,
}
switch options.Granularity {
cas... | [
"func",
"New",
"(",
"options",
"LockStoreOptions",
")",
"LockStore",
"{",
"testTryLockCallback",
":=",
"options",
".",
"testTryLockCallback",
"\n",
"if",
"testTryLockCallback",
"==",
"nil",
"{",
"testTryLockCallback",
"=",
"func",
"(",
")",
"{",
"}",
"\n",
"}",
... | // New creates a new LockStore given the options | [
"New",
"creates",
"a",
"new",
"LockStore",
"given",
"the",
"options"
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/lockstore/store.go#L91-L113 |
24,705 | dropbox/godropbox | memcache/sharded_client.go | NewShardedClient | func NewShardedClient(
manager ShardManager,
builder ClientShardBuilder) Client {
return &ShardedClient{
manager: manager,
builder: builder,
}
} | go | func NewShardedClient(
manager ShardManager,
builder ClientShardBuilder) Client {
return &ShardedClient{
manager: manager,
builder: builder,
}
} | [
"func",
"NewShardedClient",
"(",
"manager",
"ShardManager",
",",
"builder",
"ClientShardBuilder",
")",
"Client",
"{",
"return",
"&",
"ShardedClient",
"{",
"manager",
":",
"manager",
",",
"builder",
":",
"builder",
",",
"}",
"\n",
"}"
] | // This creates a new ShardedClient. | [
"This",
"creates",
"a",
"new",
"ShardedClient",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/memcache/sharded_client.go#L24-L32 |
24,706 | dropbox/godropbox | memcache/sharded_client.go | setMultiMutator | func setMultiMutator(shardClient Client, mapping *ShardMapping) []MutateResponse {
return shardClient.SetMulti(mapping.Items)
} | go | func setMultiMutator(shardClient Client, mapping *ShardMapping) []MutateResponse {
return shardClient.SetMulti(mapping.Items)
} | [
"func",
"setMultiMutator",
"(",
"shardClient",
"Client",
",",
"mapping",
"*",
"ShardMapping",
")",
"[",
"]",
"MutateResponse",
"{",
"return",
"shardClient",
".",
"SetMulti",
"(",
"mapping",
".",
"Items",
")",
"\n",
"}"
] | // A helper used to specify a SetMulti mutation operation on a shard client. | [
"A",
"helper",
"used",
"to",
"specify",
"a",
"SetMulti",
"mutation",
"operation",
"on",
"a",
"shard",
"client",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/memcache/sharded_client.go#L260-L262 |
24,707 | dropbox/godropbox | memcache/sharded_client.go | casMultiMutator | func casMultiMutator(shardClient Client, mapping *ShardMapping) []MutateResponse {
return shardClient.CasMulti(mapping.Items)
} | go | func casMultiMutator(shardClient Client, mapping *ShardMapping) []MutateResponse {
return shardClient.CasMulti(mapping.Items)
} | [
"func",
"casMultiMutator",
"(",
"shardClient",
"Client",
",",
"mapping",
"*",
"ShardMapping",
")",
"[",
"]",
"MutateResponse",
"{",
"return",
"shardClient",
".",
"CasMulti",
"(",
"mapping",
".",
"Items",
")",
"\n",
"}"
] | // A helper used to specify a CasMulti mutation operation on a shard client. | [
"A",
"helper",
"used",
"to",
"specify",
"a",
"CasMulti",
"mutation",
"operation",
"on",
"a",
"shard",
"client",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/memcache/sharded_client.go#L265-L267 |
24,708 | dropbox/godropbox | memcache/sharded_client.go | addMultiMutator | func addMultiMutator(shardClient Client, mapping *ShardMapping) []MutateResponse {
return shardClient.AddMulti(mapping.Items)
} | go | func addMultiMutator(shardClient Client, mapping *ShardMapping) []MutateResponse {
return shardClient.AddMulti(mapping.Items)
} | [
"func",
"addMultiMutator",
"(",
"shardClient",
"Client",
",",
"mapping",
"*",
"ShardMapping",
")",
"[",
"]",
"MutateResponse",
"{",
"return",
"shardClient",
".",
"AddMulti",
"(",
"mapping",
".",
"Items",
")",
"\n",
"}"
] | // A helper used to specify a AddMulti mutation operation on a shard client. | [
"A",
"helper",
"used",
"to",
"specify",
"a",
"AddMulti",
"mutation",
"operation",
"on",
"a",
"shard",
"client",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/memcache/sharded_client.go#L299-L301 |
24,709 | dropbox/godropbox | memcache/sharded_client.go | deleteMultiMutator | func deleteMultiMutator(shardClient Client, mapping *ShardMapping) []MutateResponse {
return shardClient.DeleteMulti(mapping.Keys)
} | go | func deleteMultiMutator(shardClient Client, mapping *ShardMapping) []MutateResponse {
return shardClient.DeleteMulti(mapping.Keys)
} | [
"func",
"deleteMultiMutator",
"(",
"shardClient",
"Client",
",",
"mapping",
"*",
"ShardMapping",
")",
"[",
"]",
"MutateResponse",
"{",
"return",
"shardClient",
".",
"DeleteMulti",
"(",
"mapping",
".",
"Keys",
")",
"\n",
"}"
] | // A helper used to specify a DeleteMulti mutation operation on a shard client. | [
"A",
"helper",
"used",
"to",
"specify",
"a",
"DeleteMulti",
"mutation",
"operation",
"on",
"a",
"shard",
"client",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/memcache/sharded_client.go#L327-L329 |
24,710 | dropbox/godropbox | database/binlog/event_parser.go | NewV4EventParserMap | func NewV4EventParserMap() V4EventParserMap {
m := &v4EventParserMap{
extraHeadersSize: nonFDEExtraHeadersSize,
checksumSize: 0,
parsers: make(map[mysql_proto.LogEventType_Type]V4EventParser),
}
// TODO(patrick): implement parsers
m.set(&FormatDescriptionEventParser{})
m.set(&QueryEventParser{}... | go | func NewV4EventParserMap() V4EventParserMap {
m := &v4EventParserMap{
extraHeadersSize: nonFDEExtraHeadersSize,
checksumSize: 0,
parsers: make(map[mysql_proto.LogEventType_Type]V4EventParser),
}
// TODO(patrick): implement parsers
m.set(&FormatDescriptionEventParser{})
m.set(&QueryEventParser{}... | [
"func",
"NewV4EventParserMap",
"(",
")",
"V4EventParserMap",
"{",
"m",
":=",
"&",
"v4EventParserMap",
"{",
"extraHeadersSize",
":",
"nonFDEExtraHeadersSize",
",",
"checksumSize",
":",
"0",
",",
"parsers",
":",
"make",
"(",
"map",
"[",
"mysql_proto",
".",
"LogEve... | // NewV4EventParserMap returns an initialize V4EventParserMap with all handled
// event types' parsers registered. | [
"NewV4EventParserMap",
"returns",
"an",
"initialize",
"V4EventParserMap",
"with",
"all",
"handled",
"event",
"types",
"parsers",
"registered",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/binlog/event_parser.go#L92-L119 |
24,711 | dropbox/godropbox | errors/errors.go | GetMessage | func GetMessage(err interface{}) string {
switch e := err.(type) {
case DropboxError:
return extractFullErrorMessage(e, false)
case runtime.Error:
return runtime.Error(e).Error()
case error:
return e.Error()
default:
return "Passed a non-error to GetMessage"
}
} | go | func GetMessage(err interface{}) string {
switch e := err.(type) {
case DropboxError:
return extractFullErrorMessage(e, false)
case runtime.Error:
return runtime.Error(e).Error()
case error:
return e.Error()
default:
return "Passed a non-error to GetMessage"
}
} | [
"func",
"GetMessage",
"(",
"err",
"interface",
"{",
"}",
")",
"string",
"{",
"switch",
"e",
":=",
"err",
".",
"(",
"type",
")",
"{",
"case",
"DropboxError",
":",
"return",
"extractFullErrorMessage",
"(",
"e",
",",
"false",
")",
"\n",
"case",
"runtime",
... | // This returns the error string without stack trace information. | [
"This",
"returns",
"the",
"error",
"string",
"without",
"stack",
"trace",
"information",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/errors/errors.go#L72-L83 |
24,712 | dropbox/godropbox | errors/errors.go | Newf | func Newf(format string, args ...interface{}) DropboxError {
return new(nil, fmt.Sprintf(format, args...))
} | go | func Newf(format string, args ...interface{}) DropboxError {
return new(nil, fmt.Sprintf(format, args...))
} | [
"func",
"Newf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"DropboxError",
"{",
"return",
"new",
"(",
"nil",
",",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",
")",
")",
"\n",
"}"
] | // Same as New, but with fmt.Printf-style parameters. | [
"Same",
"as",
"New",
"but",
"with",
"fmt",
".",
"Printf",
"-",
"style",
"parameters",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/errors/errors.go#L148-L150 |
24,713 | dropbox/godropbox | errors/errors.go | Wrapf | func Wrapf(err error, format string, args ...interface{}) DropboxError {
return new(err, fmt.Sprintf(format, args...))
} | go | func Wrapf(err error, format string, args ...interface{}) DropboxError {
return new(err, fmt.Sprintf(format, args...))
} | [
"func",
"Wrapf",
"(",
"err",
"error",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"DropboxError",
"{",
"return",
"new",
"(",
"err",
",",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",
")",
")",
"\n",
"}"
] | // Same as Wrap, but with fmt.Printf-style parameters. | [
"Same",
"as",
"Wrap",
"but",
"with",
"fmt",
".",
"Printf",
"-",
"style",
"parameters",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/errors/errors.go#L158-L160 |
24,714 | dropbox/godropbox | errors/errors.go | new | func new(err error, msg string) *baseError {
stack := make([]uintptr, 200)
stackLength := runtime.Callers(3, stack)
return &baseError{
msg: msg,
stack: stack[:stackLength],
inner: err,
}
} | go | func new(err error, msg string) *baseError {
stack := make([]uintptr, 200)
stackLength := runtime.Callers(3, stack)
return &baseError{
msg: msg,
stack: stack[:stackLength],
inner: err,
}
} | [
"func",
"new",
"(",
"err",
"error",
",",
"msg",
"string",
")",
"*",
"baseError",
"{",
"stack",
":=",
"make",
"(",
"[",
"]",
"uintptr",
",",
"200",
")",
"\n",
"stackLength",
":=",
"runtime",
".",
"Callers",
"(",
"3",
",",
"stack",
")",
"\n",
"return... | // Internal helper function to create new baseError objects,
// note that if there is more than one level of redirection to call this function,
// stack frame information will include that level too. | [
"Internal",
"helper",
"function",
"to",
"create",
"new",
"baseError",
"objects",
"note",
"that",
"if",
"there",
"is",
"more",
"than",
"one",
"level",
"of",
"redirection",
"to",
"call",
"this",
"function",
"stack",
"frame",
"information",
"will",
"include",
"th... | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/errors/errors.go#L165-L173 |
24,715 | dropbox/godropbox | errors/errors.go | extractFullErrorMessage | func extractFullErrorMessage(e DropboxError, includeStack bool) string {
var ok bool
var lastDbxErr DropboxError
errMsg := bytes.NewBuffer(make([]byte, 0, 1024))
dbxErr := e
for {
lastDbxErr = dbxErr
errMsg.WriteString(dbxErr.GetMessage())
innerErr := dbxErr.GetInner()
if innerErr == nil {
break
}
... | go | func extractFullErrorMessage(e DropboxError, includeStack bool) string {
var ok bool
var lastDbxErr DropboxError
errMsg := bytes.NewBuffer(make([]byte, 0, 1024))
dbxErr := e
for {
lastDbxErr = dbxErr
errMsg.WriteString(dbxErr.GetMessage())
innerErr := dbxErr.GetInner()
if innerErr == nil {
break
}
... | [
"func",
"extractFullErrorMessage",
"(",
"e",
"DropboxError",
",",
"includeStack",
"bool",
")",
"string",
"{",
"var",
"ok",
"bool",
"\n",
"var",
"lastDbxErr",
"DropboxError",
"\n",
"errMsg",
":=",
"bytes",
".",
"NewBuffer",
"(",
"make",
"(",
"[",
"]",
"byte",... | // Constructs full error message for a given DropboxError by traversing
// all of its inner errors. If includeStack is True it will also include
// stack trace from deepest DropboxError in the chain. | [
"Constructs",
"full",
"error",
"message",
"for",
"a",
"given",
"DropboxError",
"by",
"traversing",
"all",
"of",
"its",
"inner",
"errors",
".",
"If",
"includeStack",
"is",
"True",
"it",
"will",
"also",
"include",
"stack",
"trace",
"from",
"deepest",
"DropboxErr... | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/errors/errors.go#L178-L206 |
24,716 | dropbox/godropbox | errors/errors.go | unwrapError | func unwrapError(ierr error) (nerr error) {
// Internal errors have a well defined bit of context.
if dbxErr, ok := ierr.(DropboxError); ok {
return dbxErr.GetInner()
}
// At this point, if anything goes wrong, just return nil.
defer func() {
if x := recover(); x != nil {
nerr = nil
}
}()
// Go system... | go | func unwrapError(ierr error) (nerr error) {
// Internal errors have a well defined bit of context.
if dbxErr, ok := ierr.(DropboxError); ok {
return dbxErr.GetInner()
}
// At this point, if anything goes wrong, just return nil.
defer func() {
if x := recover(); x != nil {
nerr = nil
}
}()
// Go system... | [
"func",
"unwrapError",
"(",
"ierr",
"error",
")",
"(",
"nerr",
"error",
")",
"{",
"// Internal errors have a well defined bit of context.",
"if",
"dbxErr",
",",
"ok",
":=",
"ierr",
".",
"(",
"DropboxError",
")",
";",
"ok",
"{",
"return",
"dbxErr",
".",
"GetInn... | // Return a wrapped error or nil if there is none. | [
"Return",
"a",
"wrapped",
"error",
"or",
"nil",
"if",
"there",
"is",
"none",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/errors/errors.go#L209-L227 |
24,717 | dropbox/godropbox | errors/errors.go | RootError | func RootError(ierr error) (nerr error) {
nerr = ierr
for i := 0; i < 20; i++ {
terr := unwrapError(nerr)
if terr == nil {
return nerr
}
nerr = terr
}
return fmt.Errorf("too many iterations: %T", nerr)
} | go | func RootError(ierr error) (nerr error) {
nerr = ierr
for i := 0; i < 20; i++ {
terr := unwrapError(nerr)
if terr == nil {
return nerr
}
nerr = terr
}
return fmt.Errorf("too many iterations: %T", nerr)
} | [
"func",
"RootError",
"(",
"ierr",
"error",
")",
"(",
"nerr",
"error",
")",
"{",
"nerr",
"=",
"ierr",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"20",
";",
"i",
"++",
"{",
"terr",
":=",
"unwrapError",
"(",
"nerr",
")",
"\n",
"if",
"terr",
"==",... | // Keep peeling away layers or context until a primitive error is revealed. | [
"Keep",
"peeling",
"away",
"layers",
"or",
"context",
"until",
"a",
"primitive",
"error",
"is",
"revealed",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/errors/errors.go#L230-L240 |
24,718 | dropbox/godropbox | errors/errors.go | IsError | func IsError(err, errConst error) bool {
if err == errConst {
return true
}
// Must rely on string equivalence, otherwise a value is not equal
// to its pointer value.
rootErrStr := ""
rootErr := RootError(err)
if rootErr != nil {
rootErrStr = rootErr.Error()
}
errConstStr := ""
if errConst != nil {
err... | go | func IsError(err, errConst error) bool {
if err == errConst {
return true
}
// Must rely on string equivalence, otherwise a value is not equal
// to its pointer value.
rootErrStr := ""
rootErr := RootError(err)
if rootErr != nil {
rootErrStr = rootErr.Error()
}
errConstStr := ""
if errConst != nil {
err... | [
"func",
"IsError",
"(",
"err",
",",
"errConst",
"error",
")",
"bool",
"{",
"if",
"err",
"==",
"errConst",
"{",
"return",
"true",
"\n",
"}",
"\n",
"// Must rely on string equivalence, otherwise a value is not equal",
"// to its pointer value.",
"rootErrStr",
":=",
"\""... | // Perform a deep check, unwrapping errors as much as possilbe and
// comparing the string version of the error. | [
"Perform",
"a",
"deep",
"check",
"unwrapping",
"errors",
"as",
"much",
"as",
"possilbe",
"and",
"comparing",
"the",
"string",
"version",
"of",
"the",
"error",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/errors/errors.go#L244-L260 |
24,719 | dropbox/godropbox | database/binlog/rows_query_event.go | Parse | func (p *RowsQueryEventParser) Parse(raw *RawV4Event) (Event, error) {
query := &RowsQueryEvent{
Event: raw,
}
data := raw.VariableLengthData()
if len(data) < 1 {
return raw, errors.Newf("Invalid message length")
}
query.truncatedQuery = data[1:]
return query, nil
} | go | func (p *RowsQueryEventParser) Parse(raw *RawV4Event) (Event, error) {
query := &RowsQueryEvent{
Event: raw,
}
data := raw.VariableLengthData()
if len(data) < 1 {
return raw, errors.Newf("Invalid message length")
}
query.truncatedQuery = data[1:]
return query, nil
} | [
"func",
"(",
"p",
"*",
"RowsQueryEventParser",
")",
"Parse",
"(",
"raw",
"*",
"RawV4Event",
")",
"(",
"Event",
",",
"error",
")",
"{",
"query",
":=",
"&",
"RowsQueryEvent",
"{",
"Event",
":",
"raw",
",",
"}",
"\n\n",
"data",
":=",
"raw",
".",
"Variab... | // RowsQueryEventParser's Parse processes a raw query event into a
// RowsQueryEvent. | [
"RowsQueryEventParser",
"s",
"Parse",
"processes",
"a",
"raw",
"query",
"event",
"into",
"a",
"RowsQueryEvent",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/binlog/rows_query_event.go#L49-L62 |
24,720 | dropbox/godropbox | resource_pool/simple_resource_pool.go | NewSimpleResourcePool | func NewSimpleResourcePool(options Options) ResourcePool {
numActive := new(int32)
atomic.StoreInt32(numActive, 0)
activeHighWaterMark := new(int32)
atomic.StoreInt32(activeHighWaterMark, 0)
var tokens sync2.Semaphore
if options.OpenMaxConcurrency > 0 {
tokens = sync2.NewBoundedSemaphore(uint(options.OpenMaxC... | go | func NewSimpleResourcePool(options Options) ResourcePool {
numActive := new(int32)
atomic.StoreInt32(numActive, 0)
activeHighWaterMark := new(int32)
atomic.StoreInt32(activeHighWaterMark, 0)
var tokens sync2.Semaphore
if options.OpenMaxConcurrency > 0 {
tokens = sync2.NewBoundedSemaphore(uint(options.OpenMaxC... | [
"func",
"NewSimpleResourcePool",
"(",
"options",
"Options",
")",
"ResourcePool",
"{",
"numActive",
":=",
"new",
"(",
"int32",
")",
"\n",
"atomic",
".",
"StoreInt32",
"(",
"numActive",
",",
"0",
")",
"\n\n",
"activeHighWaterMark",
":=",
"new",
"(",
"int32",
"... | // This returns a SimpleResourcePool, where all handles are associated to a
// single resource location. | [
"This",
"returns",
"a",
"SimpleResourcePool",
"where",
"all",
"handles",
"are",
"associated",
"to",
"a",
"single",
"resource",
"location",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/resource_pool/simple_resource_pool.go#L54-L76 |
24,721 | dropbox/godropbox | resource_pool/simple_resource_pool.go | getIdleHandle | func (p *simpleResourcePool) getIdleHandle() ManagedHandle {
var toClose []*idleHandle
defer func() {
// NOTE: Must keep the closure around to late bind the toClose slice.
p.closeHandles(toClose)
}()
now := p.options.getCurrentTime()
p.mutex.Lock()
defer p.mutex.Unlock()
var i int
for i = 0; i < len(p.id... | go | func (p *simpleResourcePool) getIdleHandle() ManagedHandle {
var toClose []*idleHandle
defer func() {
// NOTE: Must keep the closure around to late bind the toClose slice.
p.closeHandles(toClose)
}()
now := p.options.getCurrentTime()
p.mutex.Lock()
defer p.mutex.Unlock()
var i int
for i = 0; i < len(p.id... | [
"func",
"(",
"p",
"*",
"simpleResourcePool",
")",
"getIdleHandle",
"(",
")",
"ManagedHandle",
"{",
"var",
"toClose",
"[",
"]",
"*",
"idleHandle",
"\n",
"defer",
"func",
"(",
")",
"{",
"// NOTE: Must keep the closure around to late bind the toClose slice.",
"p",
".",... | // This returns an idle resource, if there is one. | [
"This",
"returns",
"an",
"idle",
"resource",
"if",
"there",
"is",
"one",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/resource_pool/simple_resource_pool.go#L263-L296 |
24,722 | dropbox/godropbox | resource_pool/simple_resource_pool.go | queueIdleHandles | func (p *simpleResourcePool) queueIdleHandles(handle interface{}) {
var toClose []*idleHandle
defer func() {
// NOTE: Must keep the closure around to late bind the toClose slice.
p.closeHandles(toClose)
}()
now := p.options.getCurrentTime()
var keepUntil *time.Time
if p.options.MaxIdleTime != nil {
// NOTE... | go | func (p *simpleResourcePool) queueIdleHandles(handle interface{}) {
var toClose []*idleHandle
defer func() {
// NOTE: Must keep the closure around to late bind the toClose slice.
p.closeHandles(toClose)
}()
now := p.options.getCurrentTime()
var keepUntil *time.Time
if p.options.MaxIdleTime != nil {
// NOTE... | [
"func",
"(",
"p",
"*",
"simpleResourcePool",
")",
"queueIdleHandles",
"(",
"handle",
"interface",
"{",
"}",
")",
"{",
"var",
"toClose",
"[",
"]",
"*",
"idleHandle",
"\n",
"defer",
"func",
"(",
")",
"{",
"// NOTE: Must keep the closure around to late bind the toClo... | // This adds an idle resource to the pool. | [
"This",
"adds",
"an",
"idle",
"resource",
"to",
"the",
"pool",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/resource_pool/simple_resource_pool.go#L299-L337 |
24,723 | dropbox/godropbox | resource_pool/simple_resource_pool.go | closeHandles | func (p *simpleResourcePool) closeHandles(handles []*idleHandle) {
for _, handle := range handles {
_ = p.options.Close(handle.handle)
}
} | go | func (p *simpleResourcePool) closeHandles(handles []*idleHandle) {
for _, handle := range handles {
_ = p.options.Close(handle.handle)
}
} | [
"func",
"(",
"p",
"*",
"simpleResourcePool",
")",
"closeHandles",
"(",
"handles",
"[",
"]",
"*",
"idleHandle",
")",
"{",
"for",
"_",
",",
"handle",
":=",
"range",
"handles",
"{",
"_",
"=",
"p",
".",
"options",
".",
"Close",
"(",
"handle",
".",
"handl... | // Closes resources, at this point it is assumed that this resources
// are no longer referenced from the main idleHandles slice. | [
"Closes",
"resources",
"at",
"this",
"point",
"it",
"is",
"assumed",
"that",
"this",
"resources",
"are",
"no",
"longer",
"referenced",
"from",
"the",
"main",
"idleHandles",
"slice",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/resource_pool/simple_resource_pool.go#L341-L345 |
24,724 | dropbox/godropbox | database/sqlbuilder/table.go | NewTable | func NewTable(name string, columns ...NonAliasColumn) *Table {
if !validIdentifierName(name) {
panic("Invalid table name")
}
t := &Table{
name: name,
columns: columns,
columnLookup: make(map[string]NonAliasColumn),
}
for _, c := range columns {
err := c.setTableName(name)
if err != nil {
... | go | func NewTable(name string, columns ...NonAliasColumn) *Table {
if !validIdentifierName(name) {
panic("Invalid table name")
}
t := &Table{
name: name,
columns: columns,
columnLookup: make(map[string]NonAliasColumn),
}
for _, c := range columns {
err := c.setTableName(name)
if err != nil {
... | [
"func",
"NewTable",
"(",
"name",
"string",
",",
"columns",
"...",
"NonAliasColumn",
")",
"*",
"Table",
"{",
"if",
"!",
"validIdentifierName",
"(",
"name",
")",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"t",
":=",
"&",
"Table",
"{",
"name... | // Defines a physical table in the database that is both readable and writable.
// This function will panic if name is not valid | [
"Defines",
"a",
"physical",
"table",
"in",
"the",
"database",
"that",
"is",
"both",
"readable",
"and",
"writable",
".",
"This",
"function",
"will",
"panic",
"if",
"name",
"is",
"not",
"valid"
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/sqlbuilder/table.go#L53-L76 |
24,725 | dropbox/godropbox | database/sqlbuilder/table.go | getColumn | func (t *Table) getColumn(name string) (NonAliasColumn, error) {
if c, ok := t.columnLookup[name]; ok {
return c, nil
}
return nil, errors.Newf("No such column '%s' in table '%s'", name, t.name)
} | go | func (t *Table) getColumn(name string) (NonAliasColumn, error) {
if c, ok := t.columnLookup[name]; ok {
return c, nil
}
return nil, errors.Newf("No such column '%s' in table '%s'", name, t.name)
} | [
"func",
"(",
"t",
"*",
"Table",
")",
"getColumn",
"(",
"name",
"string",
")",
"(",
"NonAliasColumn",
",",
"error",
")",
"{",
"if",
"c",
",",
"ok",
":=",
"t",
".",
"columnLookup",
"[",
"name",
"]",
";",
"ok",
"{",
"return",
"c",
",",
"nil",
"\n",
... | // Returns the specified column, or errors if it doesn't exist in the table | [
"Returns",
"the",
"specified",
"column",
"or",
"errors",
"if",
"it",
"doesn",
"t",
"exist",
"in",
"the",
"table"
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/sqlbuilder/table.go#L87-L92 |
24,726 | dropbox/godropbox | database/sqlbuilder/table.go | C | func (t *Table) C(name string) NonAliasColumn {
return &deferredLookupColumn{
table: t,
colName: name,
}
} | go | func (t *Table) C(name string) NonAliasColumn {
return &deferredLookupColumn{
table: t,
colName: name,
}
} | [
"func",
"(",
"t",
"*",
"Table",
")",
"C",
"(",
"name",
"string",
")",
"NonAliasColumn",
"{",
"return",
"&",
"deferredLookupColumn",
"{",
"table",
":",
"t",
",",
"colName",
":",
"name",
",",
"}",
"\n",
"}"
] | // Returns a pseudo column representation of the column name. Error checking
// is deferred to SerializeSql. | [
"Returns",
"a",
"pseudo",
"column",
"representation",
"of",
"the",
"column",
"name",
".",
"Error",
"checking",
"is",
"deferred",
"to",
"SerializeSql",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/sqlbuilder/table.go#L96-L101 |
24,727 | dropbox/godropbox | database/sqlbuilder/table.go | Projections | func (t *Table) Projections() []Projection {
result := make([]Projection, 0)
for _, col := range t.columns {
result = append(result, col)
}
return result
} | go | func (t *Table) Projections() []Projection {
result := make([]Projection, 0)
for _, col := range t.columns {
result = append(result, col)
}
return result
} | [
"func",
"(",
"t",
"*",
"Table",
")",
"Projections",
"(",
")",
"[",
"]",
"Projection",
"{",
"result",
":=",
"make",
"(",
"[",
"]",
"Projection",
",",
"0",
")",
"\n\n",
"for",
"_",
",",
"col",
":=",
"range",
"t",
".",
"columns",
"{",
"result",
"=",... | // Returns all columns for a table as a slice of projections | [
"Returns",
"all",
"columns",
"for",
"a",
"table",
"as",
"a",
"slice",
"of",
"projections"
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/sqlbuilder/table.go#L104-L112 |
24,728 | dropbox/godropbox | database/sqlbuilder/table.go | ForceIndex | func (t *Table) ForceIndex(index string) *Table {
newTable := *t
newTable.forcedIndex = index
return &newTable
} | go | func (t *Table) ForceIndex(index string) *Table {
newTable := *t
newTable.forcedIndex = index
return &newTable
} | [
"func",
"(",
"t",
"*",
"Table",
")",
"ForceIndex",
"(",
"index",
"string",
")",
"*",
"Table",
"{",
"newTable",
":=",
"*",
"t",
"\n",
"newTable",
".",
"forcedIndex",
"=",
"index",
"\n",
"return",
"&",
"newTable",
"\n",
"}"
] | // Returns a copy of this table, but with the specified index forced. | [
"Returns",
"a",
"copy",
"of",
"this",
"table",
"but",
"with",
"the",
"specified",
"index",
"forced",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/sqlbuilder/table.go#L125-L129 |
24,729 | dropbox/godropbox | database/sqlbuilder/table.go | InnerJoinOn | func (t *Table) InnerJoinOn(
table ReadableTable,
onCondition BoolExpression) ReadableTable {
return InnerJoinOn(t, table, onCondition)
} | go | func (t *Table) InnerJoinOn(
table ReadableTable,
onCondition BoolExpression) ReadableTable {
return InnerJoinOn(t, table, onCondition)
} | [
"func",
"(",
"t",
"*",
"Table",
")",
"InnerJoinOn",
"(",
"table",
"ReadableTable",
",",
"onCondition",
"BoolExpression",
")",
"ReadableTable",
"{",
"return",
"InnerJoinOn",
"(",
"t",
",",
"table",
",",
"onCondition",
")",
"\n",
"}"
] | // Creates a inner join table expression using onCondition. | [
"Creates",
"a",
"inner",
"join",
"table",
"expression",
"using",
"onCondition",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/sqlbuilder/table.go#L158-L163 |
24,730 | dropbox/godropbox | database/sqlbuilder/table.go | LeftJoinOn | func (t *Table) LeftJoinOn(
table ReadableTable,
onCondition BoolExpression) ReadableTable {
return LeftJoinOn(t, table, onCondition)
} | go | func (t *Table) LeftJoinOn(
table ReadableTable,
onCondition BoolExpression) ReadableTable {
return LeftJoinOn(t, table, onCondition)
} | [
"func",
"(",
"t",
"*",
"Table",
")",
"LeftJoinOn",
"(",
"table",
"ReadableTable",
",",
"onCondition",
"BoolExpression",
")",
"ReadableTable",
"{",
"return",
"LeftJoinOn",
"(",
"t",
",",
"table",
",",
"onCondition",
")",
"\n",
"}"
] | // Creates a left join table expression using onCondition. | [
"Creates",
"a",
"left",
"join",
"table",
"expression",
"using",
"onCondition",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/sqlbuilder/table.go#L166-L171 |
24,731 | dropbox/godropbox | database/sqlbuilder/table.go | RightJoinOn | func (t *Table) RightJoinOn(
table ReadableTable,
onCondition BoolExpression) ReadableTable {
return RightJoinOn(t, table, onCondition)
} | go | func (t *Table) RightJoinOn(
table ReadableTable,
onCondition BoolExpression) ReadableTable {
return RightJoinOn(t, table, onCondition)
} | [
"func",
"(",
"t",
"*",
"Table",
")",
"RightJoinOn",
"(",
"table",
"ReadableTable",
",",
"onCondition",
"BoolExpression",
")",
"ReadableTable",
"{",
"return",
"RightJoinOn",
"(",
"t",
",",
"table",
",",
"onCondition",
")",
"\n",
"}"
] | // Creates a right join table expression using onCondition. | [
"Creates",
"a",
"right",
"join",
"table",
"expression",
"using",
"onCondition",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/sqlbuilder/table.go#L174-L179 |
24,732 | dropbox/godropbox | database/binlog/previous_gtid_log_event.go | Parse | func (p *PreviousGtidsLogEventParser) Parse(raw *RawV4Event) (Event, error) {
pgle := &PreviousGtidsLogEvent{
Event: raw,
set: make(map[string][]GtidRange),
}
data := raw.VariableLengthData()
if len(data) < 8 {
return nil, errors.Newf("Not enough bytes for n_sids: %v", data)
}
nSids, data := LittleEndia... | go | func (p *PreviousGtidsLogEventParser) Parse(raw *RawV4Event) (Event, error) {
pgle := &PreviousGtidsLogEvent{
Event: raw,
set: make(map[string][]GtidRange),
}
data := raw.VariableLengthData()
if len(data) < 8 {
return nil, errors.Newf("Not enough bytes for n_sids: %v", data)
}
nSids, data := LittleEndia... | [
"func",
"(",
"p",
"*",
"PreviousGtidsLogEventParser",
")",
"Parse",
"(",
"raw",
"*",
"RawV4Event",
")",
"(",
"Event",
",",
"error",
")",
"{",
"pgle",
":=",
"&",
"PreviousGtidsLogEvent",
"{",
"Event",
":",
"raw",
",",
"set",
":",
"make",
"(",
"map",
"["... | // PreviousGtidLogEventParser's Parse processes a raw gtid log event into a PreviousGtidLogEvent. | [
"PreviousGtidLogEventParser",
"s",
"Parse",
"processes",
"a",
"raw",
"gtid",
"log",
"event",
"into",
"a",
"PreviousGtidLogEvent",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/binlog/previous_gtid_log_event.go#L54-L97 |
24,733 | dropbox/godropbox | encoding2/hex.go | HexEncodeToWriter | func HexEncodeToWriter(w BinaryWriter, data []byte) {
for _, b := range data {
w.Write(hexMap[b])
}
} | go | func HexEncodeToWriter(w BinaryWriter, data []byte) {
for _, b := range data {
w.Write(hexMap[b])
}
} | [
"func",
"HexEncodeToWriter",
"(",
"w",
"BinaryWriter",
",",
"data",
"[",
"]",
"byte",
")",
"{",
"for",
"_",
",",
"b",
":=",
"range",
"data",
"{",
"w",
".",
"Write",
"(",
"hexMap",
"[",
"b",
"]",
")",
"\n",
"}",
"\n",
"}"
] | // This hex encodes the binary data and writes the encoded data to the writer. | [
"This",
"hex",
"encodes",
"the",
"binary",
"data",
"and",
"writes",
"the",
"encoded",
"data",
"to",
"the",
"writer",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/encoding2/hex.go#L10-L14 |
24,734 | dropbox/godropbox | resource_pool/round_robin_resource_pool.go | NewRoundRobinResourcePool | func NewRoundRobinResourcePool(
options Options,
createPool func(Options) ResourcePool,
pools ...*ResourceLocationPool) (ResourcePool, error) {
locations := make(map[string]bool)
for _, pool := range pools {
if pool.ResourceLocation == "" {
return nil, errors.New("Invalid resource location")
}
if locat... | go | func NewRoundRobinResourcePool(
options Options,
createPool func(Options) ResourcePool,
pools ...*ResourceLocationPool) (ResourcePool, error) {
locations := make(map[string]bool)
for _, pool := range pools {
if pool.ResourceLocation == "" {
return nil, errors.New("Invalid resource location")
}
if locat... | [
"func",
"NewRoundRobinResourcePool",
"(",
"options",
"Options",
",",
"createPool",
"func",
"(",
"Options",
")",
"ResourcePool",
",",
"pools",
"...",
"*",
"ResourceLocationPool",
")",
"(",
"ResourcePool",
",",
"error",
")",
"{",
"locations",
":=",
"make",
"(",
... | // This returns a RoundRobinResourcePool. | [
"This",
"returns",
"a",
"RoundRobinResourcePool",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/resource_pool/round_robin_resource_pool.go#L38-L79 |
24,735 | dropbox/godropbox | database/binlog/event.go | EventType | func (e *RawV4Event) EventType() mysql_proto.LogEventType_Type {
return mysql_proto.LogEventType_Type(e.header.EventType)
} | go | func (e *RawV4Event) EventType() mysql_proto.LogEventType_Type {
return mysql_proto.LogEventType_Type(e.header.EventType)
} | [
"func",
"(",
"e",
"*",
"RawV4Event",
")",
"EventType",
"(",
")",
"mysql_proto",
".",
"LogEventType_Type",
"{",
"return",
"mysql_proto",
".",
"LogEventType_Type",
"(",
"e",
".",
"header",
".",
"EventType",
")",
"\n",
"}"
] | // EventType returns the event's type. | [
"EventType",
"returns",
"the",
"event",
"s",
"type",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/binlog/event.go#L108-L110 |
24,736 | dropbox/godropbox | database/binlog/event.go | VariableLengthData | func (e *RawV4Event) VariableLengthData() []byte {
begin := (sizeOfBasicV4EventHeader +
e.extraHeadersSize +
e.fixedLengthDataSize)
end := len(e.data) - e.checksumSize
return e.data[begin:end]
} | go | func (e *RawV4Event) VariableLengthData() []byte {
begin := (sizeOfBasicV4EventHeader +
e.extraHeadersSize +
e.fixedLengthDataSize)
end := len(e.data) - e.checksumSize
return e.data[begin:end]
} | [
"func",
"(",
"e",
"*",
"RawV4Event",
")",
"VariableLengthData",
"(",
")",
"[",
"]",
"byte",
"{",
"begin",
":=",
"(",
"sizeOfBasicV4EventHeader",
"+",
"e",
".",
"extraHeadersSize",
"+",
"e",
".",
"fixedLengthDataSize",
")",
"\n",
"end",
":=",
"len",
"(",
... | // VariableLengthData returns the variable length data associated to the event.
// By default, the variable length data also include the extra headers, the
// fixed length data and the optional checksum footer. | [
"VariableLengthData",
"returns",
"the",
"variable",
"length",
"data",
"associated",
"to",
"the",
"event",
".",
"By",
"default",
"the",
"variable",
"length",
"data",
"also",
"include",
"the",
"extra",
"headers",
"the",
"fixed",
"length",
"data",
"and",
"the",
"... | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/binlog/event.go#L167-L173 |
24,737 | dropbox/godropbox | database/binlog/event.go | SetExtraHeadersSize | func (e *RawV4Event) SetExtraHeadersSize(size int) error {
newFixedSize := (size +
sizeOfBasicV4EventHeader +
e.fixedLengthDataSize +
e.checksumSize)
if size < 0 || newFixedSize > len(e.data) {
return errors.Newf(
"Invalid extra headers size (data size: %d basic header size: %d"+
"fixed length data siz... | go | func (e *RawV4Event) SetExtraHeadersSize(size int) error {
newFixedSize := (size +
sizeOfBasicV4EventHeader +
e.fixedLengthDataSize +
e.checksumSize)
if size < 0 || newFixedSize > len(e.data) {
return errors.Newf(
"Invalid extra headers size (data size: %d basic header size: %d"+
"fixed length data siz... | [
"func",
"(",
"e",
"*",
"RawV4Event",
")",
"SetExtraHeadersSize",
"(",
"size",
"int",
")",
"error",
"{",
"newFixedSize",
":=",
"(",
"size",
"+",
"sizeOfBasicV4EventHeader",
"+",
"e",
".",
"fixedLengthDataSize",
"+",
"e",
".",
"checksumSize",
")",
"\n",
"if",
... | // Set the extra headers' size. | [
"Set",
"the",
"extra",
"headers",
"size",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/binlog/event.go#L183-L200 |
24,738 | dropbox/godropbox | caching/cache_on_storage.go | NewCacheOnStorage | func NewCacheOnStorage(
cache Storage,
storage Storage) Storage {
return &CacheOnStorage{
cache: cache,
storage: storage,
}
} | go | func NewCacheOnStorage(
cache Storage,
storage Storage) Storage {
return &CacheOnStorage{
cache: cache,
storage: storage,
}
} | [
"func",
"NewCacheOnStorage",
"(",
"cache",
"Storage",
",",
"storage",
"Storage",
")",
"Storage",
"{",
"return",
"&",
"CacheOnStorage",
"{",
"cache",
":",
"cache",
",",
"storage",
":",
"storage",
",",
"}",
"\n",
"}"
] | // This returns a CacheOnStorage, which adds a cache layer on top of the
// storage. | [
"This",
"returns",
"a",
"CacheOnStorage",
"which",
"adds",
"a",
"cache",
"layer",
"on",
"top",
"of",
"the",
"storage",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/caching/cache_on_storage.go#L17-L25 |
24,739 | dropbox/godropbox | cinterop/maximally_batched_work.go | readUntilNullWorkSizeBatch | func readUntilNullWorkSizeBatch(socketRead io.ReadCloser,
batch []byte, workSize int) (size int, err error) {
err = nil
size = 0
if workSize == 0 {
size, err = io.ReadFull(socketRead, batch)
} else {
lastCheckedForNull := 0
for err == nil {
var offset int
offset, err = socketRead.Read(batch[size:])
... | go | func readUntilNullWorkSizeBatch(socketRead io.ReadCloser,
batch []byte, workSize int) (size int, err error) {
err = nil
size = 0
if workSize == 0 {
size, err = io.ReadFull(socketRead, batch)
} else {
lastCheckedForNull := 0
for err == nil {
var offset int
offset, err = socketRead.Read(batch[size:])
... | [
"func",
"readUntilNullWorkSizeBatch",
"(",
"socketRead",
"io",
".",
"ReadCloser",
",",
"batch",
"[",
"]",
"byte",
",",
"workSize",
"int",
")",
"(",
"size",
"int",
",",
"err",
"error",
")",
"{",
"err",
"=",
"nil",
"\n",
"size",
"=",
"0",
"\n",
"if",
"... | // this reads socketRead to fill up the given buffer unless an error is encountered or
// workSize zeros in a row are discovered, aligned with WorkSize, causing a flush | [
"this",
"reads",
"socketRead",
"to",
"fill",
"up",
"the",
"given",
"buffer",
"unless",
"an",
"error",
"is",
"encountered",
"or",
"workSize",
"zeros",
"in",
"a",
"row",
"are",
"discovered",
"aligned",
"with",
"WorkSize",
"causing",
"a",
"flush"
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/cinterop/maximally_batched_work.go#L30-L59 |
24,740 | dropbox/godropbox | cinterop/maximally_batched_work.go | readBatch | func readBatch(copyTo chan<- []byte, socketRead io.ReadCloser, batchSize int, workSize int) {
defer close(copyTo)
for {
batch := make([]byte, batchSize)
size, err := readUntilNullWorkSizeBatch(socketRead, batch, workSize)
if size > 0 {
if err != nil && workSize != 0 {
size -= (size % workSize)
}
co... | go | func readBatch(copyTo chan<- []byte, socketRead io.ReadCloser, batchSize int, workSize int) {
defer close(copyTo)
for {
batch := make([]byte, batchSize)
size, err := readUntilNullWorkSizeBatch(socketRead, batch, workSize)
if size > 0 {
if err != nil && workSize != 0 {
size -= (size % workSize)
}
co... | [
"func",
"readBatch",
"(",
"copyTo",
"chan",
"<-",
"[",
"]",
"byte",
",",
"socketRead",
"io",
".",
"ReadCloser",
",",
"batchSize",
"int",
",",
"workSize",
"int",
")",
"{",
"defer",
"close",
"(",
"copyTo",
")",
"\n",
"for",
"{",
"batch",
":=",
"make",
... | // this reads in a loop from socketRead putting batchSize bytes of work to copyTo until
// the socketRead is empty.
// Batches may be shorter than batchSize if a whole workSize element is all zeros
// If workSize of zero is passed in, then the entire batchSize will be filled up regardless,
// unless socketRead returns ... | [
"this",
"reads",
"in",
"a",
"loop",
"from",
"socketRead",
"putting",
"batchSize",
"bytes",
"of",
"work",
"to",
"copyTo",
"until",
"the",
"socketRead",
"is",
"empty",
".",
"Batches",
"may",
"be",
"shorter",
"than",
"batchSize",
"if",
"a",
"whole",
"workSize",... | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/cinterop/maximally_batched_work.go#L66-L84 |
24,741 | dropbox/godropbox | time2/mock_clock.go | Advance | func (c *MockClock) Advance(delta time.Duration) {
c.mutex.Lock()
defer c.mutex.Unlock()
end := c.now.Add(delta)
c.advanceTo(end)
} | go | func (c *MockClock) Advance(delta time.Duration) {
c.mutex.Lock()
defer c.mutex.Unlock()
end := c.now.Add(delta)
c.advanceTo(end)
} | [
"func",
"(",
"c",
"*",
"MockClock",
")",
"Advance",
"(",
"delta",
"time",
".",
"Duration",
")",
"{",
"c",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"end",
":=",
"c",
".",
"now",
".",... | // Advances the mock clock by the specified duration. | [
"Advances",
"the",
"mock",
"clock",
"by",
"the",
"specified",
"duration",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/time2/mock_clock.go#L65-L71 |
24,742 | dropbox/godropbox | time2/mock_clock.go | AdvanceTo | func (c *MockClock) AdvanceTo(t time.Time) {
c.mutex.Lock()
defer c.mutex.Unlock()
c.advanceTo(t)
} | go | func (c *MockClock) AdvanceTo(t time.Time) {
c.mutex.Lock()
defer c.mutex.Unlock()
c.advanceTo(t)
} | [
"func",
"(",
"c",
"*",
"MockClock",
")",
"AdvanceTo",
"(",
"t",
"time",
".",
"Time",
")",
"{",
"c",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"c",
".",
"advanceTo",
"(",
"t",
")",
... | // Advance to a specific time. | [
"Advance",
"to",
"a",
"specific",
"time",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/time2/mock_clock.go#L74-L79 |
24,743 | dropbox/godropbox | time2/mock_clock.go | Now | func (c *MockClock) Now() time.Time {
c.mutex.Lock()
defer c.mutex.Unlock()
return c.now
} | go | func (c *MockClock) Now() time.Time {
c.mutex.Lock()
defer c.mutex.Unlock()
return c.now
} | [
"func",
"(",
"c",
"*",
"MockClock",
")",
"Now",
"(",
")",
"time",
".",
"Time",
"{",
"c",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"c",
".",
"now",
"\n",
"}"
] | // Returns the fake current time. | [
"Returns",
"the",
"fake",
"current",
"time",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/time2/mock_clock.go#L89-L94 |
24,744 | dropbox/godropbox | net2/http2/simple_pool.go | Do | func (pool *SimplePool) Do(req *http.Request) (resp *http.Response, err error) {
conn, err := pool.Get()
if err != nil {
return nil, errors.Wrap(err, err.Error())
}
if pool.params.UseSSL {
req.URL.Scheme = "https"
} else {
req.URL.Scheme = "http"
}
if pool.params.UseRequestHost && req.Host != "" {
req.... | go | func (pool *SimplePool) Do(req *http.Request) (resp *http.Response, err error) {
conn, err := pool.Get()
if err != nil {
return nil, errors.Wrap(err, err.Error())
}
if pool.params.UseSSL {
req.URL.Scheme = "https"
} else {
req.URL.Scheme = "http"
}
if pool.params.UseRequestHost && req.Host != "" {
req.... | [
"func",
"(",
"pool",
"*",
"SimplePool",
")",
"Do",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"resp",
"*",
"http",
".",
"Response",
",",
"err",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"pool",
".",
"Get",
"(",
")",
"\n",
"if",
"err"... | // Performs the HTTP request using our HTTP client | [
"Performs",
"the",
"HTTP",
"request",
"using",
"our",
"HTTP",
"client"
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/net2/http2/simple_pool.go#L163-L221 |
24,745 | dropbox/godropbox | net2/http2/simple_pool.go | DoWithTimeout | func (pool *SimplePool) DoWithTimeout(req *http.Request,
timeout time.Duration) (resp *http.Response, err error) {
return pool.DoWithParams(req, DoParams{Timeout: timeout})
} | go | func (pool *SimplePool) DoWithTimeout(req *http.Request,
timeout time.Duration) (resp *http.Response, err error) {
return pool.DoWithParams(req, DoParams{Timeout: timeout})
} | [
"func",
"(",
"pool",
"*",
"SimplePool",
")",
"DoWithTimeout",
"(",
"req",
"*",
"http",
".",
"Request",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"resp",
"*",
"http",
".",
"Response",
",",
"err",
"error",
")",
"{",
"return",
"pool",
".",
"DoW... | // Set a local timeout the actually cancels the request if we've given up. | [
"Set",
"a",
"local",
"timeout",
"the",
"actually",
"cancels",
"the",
"request",
"if",
"we",
"ve",
"given",
"up",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/net2/http2/simple_pool.go#L241-L244 |
24,746 | dropbox/godropbox | net2/http2/simple_pool.go | GetWithKey | func (pool *SimplePool) GetWithKey(key []byte, limit int) (*http.Client, error) {
return pool.Get()
} | go | func (pool *SimplePool) GetWithKey(key []byte, limit int) (*http.Client, error) {
return pool.Get()
} | [
"func",
"(",
"pool",
"*",
"SimplePool",
")",
"GetWithKey",
"(",
"key",
"[",
"]",
"byte",
",",
"limit",
"int",
")",
"(",
"*",
"http",
".",
"Client",
",",
"error",
")",
"{",
"return",
"pool",
".",
"Get",
"(",
")",
"\n",
"}"
] | // SimplePool doesn't care about the key | [
"SimplePool",
"doesn",
"t",
"care",
"about",
"the",
"key"
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/net2/http2/simple_pool.go#L256-L258 |
24,747 | dropbox/godropbox | net2/http2/load_balanced_pool.go | SetActiveSetSize | func (pool *LoadBalancedPool) SetActiveSetSize(size uint64) {
pool.lock.Lock()
defer pool.lock.Unlock()
pool.activeSetSize = size
} | go | func (pool *LoadBalancedPool) SetActiveSetSize(size uint64) {
pool.lock.Lock()
defer pool.lock.Unlock()
pool.activeSetSize = size
} | [
"func",
"(",
"pool",
"*",
"LoadBalancedPool",
")",
"SetActiveSetSize",
"(",
"size",
"uint64",
")",
"{",
"pool",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"pool",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"pool",
".",
"activeSetSize",
"=",
... | // For the round robin strategy, sets the number of servers to round-robin
// between. The default is 6. | [
"For",
"the",
"round",
"robin",
"strategy",
"sets",
"the",
"number",
"of",
"servers",
"to",
"round",
"-",
"robin",
"between",
".",
"The",
"default",
"is",
"6",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/net2/http2/load_balanced_pool.go#L137-L141 |
24,748 | dropbox/godropbox | net2/http2/load_balanced_pool.go | Do | func (pool *LoadBalancedPool) Do(req *http.Request) (resp *http.Response, err error) {
return pool.DoWithTimeout(req, 0)
} | go | func (pool *LoadBalancedPool) Do(req *http.Request) (resp *http.Response, err error) {
return pool.DoWithTimeout(req, 0)
} | [
"func",
"(",
"pool",
"*",
"LoadBalancedPool",
")",
"Do",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"resp",
"*",
"http",
".",
"Response",
",",
"err",
"error",
")",
"{",
"return",
"pool",
".",
"DoWithTimeout",
"(",
"req",
",",
"0",
")",
"\n"... | //
// Pool interface methods
// | [
"Pool",
"interface",
"methods"
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/net2/http2/load_balanced_pool.go#L223-L225 |
24,749 | dropbox/godropbox | net2/http2/load_balanced_pool.go | DoWithTimeout | func (pool *LoadBalancedPool) DoWithTimeout(req *http.Request,
timeout time.Duration) (*http.Response, error) {
return pool.DoWithParams(req, DoParams{Timeout: timeout})
} | go | func (pool *LoadBalancedPool) DoWithTimeout(req *http.Request,
timeout time.Duration) (*http.Response, error) {
return pool.DoWithParams(req, DoParams{Timeout: timeout})
} | [
"func",
"(",
"pool",
"*",
"LoadBalancedPool",
")",
"DoWithTimeout",
"(",
"req",
"*",
"http",
".",
"Request",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"return",
"pool",
".",
"DoWithParams",
... | // Issues an HTTP request, distributing more load to relatively unloaded instances. | [
"Issues",
"an",
"HTTP",
"request",
"distributing",
"more",
"load",
"to",
"relatively",
"unloaded",
"instances",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/net2/http2/load_balanced_pool.go#L288-L291 |
24,750 | dropbox/godropbox | net2/http2/load_balanced_pool.go | getInstance | func (pool *LoadBalancedPool) getInstance(key []byte, maxInstances int) (
idx int,
instance *instancePool,
isDown bool,
err error) {
pool.lock.RLock()
defer pool.lock.RUnlock()
if len(pool.instanceList) == 0 {
return 0, nil, false, errors.Newf("no available instances")
}
now := time.Now().Unix()
numInstanc... | go | func (pool *LoadBalancedPool) getInstance(key []byte, maxInstances int) (
idx int,
instance *instancePool,
isDown bool,
err error) {
pool.lock.RLock()
defer pool.lock.RUnlock()
if len(pool.instanceList) == 0 {
return 0, nil, false, errors.Newf("no available instances")
}
now := time.Now().Unix()
numInstanc... | [
"func",
"(",
"pool",
"*",
"LoadBalancedPool",
")",
"getInstance",
"(",
"key",
"[",
"]",
"byte",
",",
"maxInstances",
"int",
")",
"(",
"idx",
"int",
",",
"instance",
"*",
"instancePool",
",",
"isDown",
"bool",
",",
"err",
"error",
")",
"{",
"pool",
".",... | // Returns instance that isn't marked down, if all instances are
// marked as down it will just choose a next one. | [
"Returns",
"instance",
"that",
"isn",
"t",
"marked",
"down",
"if",
"all",
"instances",
"are",
"marked",
"as",
"down",
"it",
"will",
"just",
"choose",
"a",
"next",
"one",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/net2/http2/load_balanced_pool.go#L312-L412 |
24,751 | dropbox/godropbox | net2/http2/load_balanced_pool.go | GetSingleInstance | func (pool *LoadBalancedPool) GetSingleInstance() (Pool, error) {
_, instance, _, err := pool.getInstance(nil, 1)
return instance, err
} | go | func (pool *LoadBalancedPool) GetSingleInstance() (Pool, error) {
_, instance, _, err := pool.getInstance(nil, 1)
return instance, err
} | [
"func",
"(",
"pool",
"*",
"LoadBalancedPool",
")",
"GetSingleInstance",
"(",
")",
"(",
"Pool",
",",
"error",
")",
"{",
"_",
",",
"instance",
",",
"_",
",",
"err",
":=",
"pool",
".",
"getInstance",
"(",
"nil",
",",
"1",
")",
"\n",
"return",
"instance"... | // Returns a Pool for an instance selected based on load balancing strategy. | [
"Returns",
"a",
"Pool",
"for",
"an",
"instance",
"selected",
"based",
"on",
"load",
"balancing",
"strategy",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/net2/http2/load_balanced_pool.go#L415-L418 |
24,752 | dropbox/godropbox | net2/http2/load_balanced_pool.go | markInstanceDown | func (pool *LoadBalancedPool) markInstanceDown(
idx int, instance *instancePool, downUntil int64) {
pool.lock.Lock()
defer pool.lock.Unlock()
if idx < len(pool.instanceList) && pool.instanceList[idx] == instance {
pool.markDownUntil[idx] = downUntil
}
} | go | func (pool *LoadBalancedPool) markInstanceDown(
idx int, instance *instancePool, downUntil int64) {
pool.lock.Lock()
defer pool.lock.Unlock()
if idx < len(pool.instanceList) && pool.instanceList[idx] == instance {
pool.markDownUntil[idx] = downUntil
}
} | [
"func",
"(",
"pool",
"*",
"LoadBalancedPool",
")",
"markInstanceDown",
"(",
"idx",
"int",
",",
"instance",
"*",
"instancePool",
",",
"downUntil",
"int64",
")",
"{",
"pool",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"pool",
".",
"lock",
".",
"U... | // Marks instance down till downUntil epoch in seconds. | [
"Marks",
"instance",
"down",
"till",
"downUntil",
"epoch",
"in",
"seconds",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/net2/http2/load_balanced_pool.go#L441-L448 |
24,753 | dropbox/godropbox | net2/http2/load_balanced_pool.go | markInstanceUp | func (pool *LoadBalancedPool) markInstanceUp(
idx int, instance *instancePool) {
pool.markInstanceDown(idx, instance, 0)
} | go | func (pool *LoadBalancedPool) markInstanceUp(
idx int, instance *instancePool) {
pool.markInstanceDown(idx, instance, 0)
} | [
"func",
"(",
"pool",
"*",
"LoadBalancedPool",
")",
"markInstanceUp",
"(",
"idx",
"int",
",",
"instance",
"*",
"instancePool",
")",
"{",
"pool",
".",
"markInstanceDown",
"(",
"idx",
",",
"instance",
",",
"0",
")",
"\n",
"}"
] | // Marks instance as ready to be used. | [
"Marks",
"instance",
"as",
"ready",
"to",
"be",
"used",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/net2/http2/load_balanced_pool.go#L451-L454 |
24,754 | dropbox/godropbox | lockstore/map.go | NewLockingMap | func NewLockingMap(options LockingMapOptions) LockingMap {
return &lockingMap{
lock: &sync.RWMutex{},
keyLocker: New(options.LockStoreOptions),
data: make(map[string]interface{}),
checkFunc: options.ValueCheckFunc,
}
} | go | func NewLockingMap(options LockingMapOptions) LockingMap {
return &lockingMap{
lock: &sync.RWMutex{},
keyLocker: New(options.LockStoreOptions),
data: make(map[string]interface{}),
checkFunc: options.ValueCheckFunc,
}
} | [
"func",
"NewLockingMap",
"(",
"options",
"LockingMapOptions",
")",
"LockingMap",
"{",
"return",
"&",
"lockingMap",
"{",
"lock",
":",
"&",
"sync",
".",
"RWMutex",
"{",
"}",
",",
"keyLocker",
":",
"New",
"(",
"options",
".",
"LockStoreOptions",
")",
",",
"da... | // NewLockingMap returns a new instance of LockingMap | [
"NewLockingMap",
"returns",
"a",
"new",
"instance",
"of",
"LockingMap"
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/lockstore/map.go#L71-L78 |
24,755 | dropbox/godropbox | lockstore/map.go | Get | func (m *lockingMap) Get(key string) (interface{}, bool) {
m.keyLocker.RLock(key)
defer m.keyLocker.RUnlock(key)
m.lock.RLock()
defer m.lock.RUnlock()
val, ok := m.data[key]
if ok && (m.checkFunc == nil || m.checkFunc(key, val)) {
return val, true
} else {
// No value or it failed to check
return nil, fa... | go | func (m *lockingMap) Get(key string) (interface{}, bool) {
m.keyLocker.RLock(key)
defer m.keyLocker.RUnlock(key)
m.lock.RLock()
defer m.lock.RUnlock()
val, ok := m.data[key]
if ok && (m.checkFunc == nil || m.checkFunc(key, val)) {
return val, true
} else {
// No value or it failed to check
return nil, fa... | [
"func",
"(",
"m",
"*",
"lockingMap",
")",
"Get",
"(",
"key",
"string",
")",
"(",
"interface",
"{",
"}",
",",
"bool",
")",
"{",
"m",
".",
"keyLocker",
".",
"RLock",
"(",
"key",
")",
"\n",
"defer",
"m",
".",
"keyLocker",
".",
"RUnlock",
"(",
"key",... | // Get returns the value, ok for a given key from within the map. If a ValueCheckFunc
// was defined for the map, the value is only returned if that function returns true. | [
"Get",
"returns",
"the",
"value",
"ok",
"for",
"a",
"given",
"key",
"from",
"within",
"the",
"map",
".",
"If",
"a",
"ValueCheckFunc",
"was",
"defined",
"for",
"the",
"map",
"the",
"value",
"is",
"only",
"returned",
"if",
"that",
"function",
"returns",
"t... | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/lockstore/map.go#L82-L96 |
24,756 | dropbox/godropbox | lockstore/map.go | Delete | func (m *lockingMap) Delete(key string) {
m.keyLocker.Lock(key)
defer m.keyLocker.Unlock(key)
m.lock.Lock()
defer m.lock.Unlock()
delete(m.data, key)
} | go | func (m *lockingMap) Delete(key string) {
m.keyLocker.Lock(key)
defer m.keyLocker.Unlock(key)
m.lock.Lock()
defer m.lock.Unlock()
delete(m.data, key)
} | [
"func",
"(",
"m",
"*",
"lockingMap",
")",
"Delete",
"(",
"key",
"string",
")",
"{",
"m",
".",
"keyLocker",
".",
"Lock",
"(",
"key",
")",
"\n",
"defer",
"m",
".",
"keyLocker",
".",
"Unlock",
"(",
"key",
")",
"\n\n",
"m",
".",
"lock",
".",
"Lock",
... | // Delete removes a key from the map if it exists. Returns nothing. | [
"Delete",
"removes",
"a",
"key",
"from",
"the",
"map",
"if",
"it",
"exists",
".",
"Returns",
"nothing",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/lockstore/map.go#L99-L107 |
24,757 | dropbox/godropbox | net2/managed_connection.go | NewManagedConn | func NewManagedConn(
network string,
address string,
handle resource_pool.ManagedHandle,
pool ConnectionPool,
options ConnectionOptions) ManagedConn {
addr := NetworkAddress{
Network: network,
Address: address,
}
return &managedConnImpl{
addr: addr,
handle: handle,
pool: pool,
options: opti... | go | func NewManagedConn(
network string,
address string,
handle resource_pool.ManagedHandle,
pool ConnectionPool,
options ConnectionOptions) ManagedConn {
addr := NetworkAddress{
Network: network,
Address: address,
}
return &managedConnImpl{
addr: addr,
handle: handle,
pool: pool,
options: opti... | [
"func",
"NewManagedConn",
"(",
"network",
"string",
",",
"address",
"string",
",",
"handle",
"resource_pool",
".",
"ManagedHandle",
",",
"pool",
"ConnectionPool",
",",
"options",
"ConnectionOptions",
")",
"ManagedConn",
"{",
"addr",
":=",
"NetworkAddress",
"{",
"N... | // This creates a managed connection wrapper. | [
"This",
"creates",
"a",
"managed",
"connection",
"wrapper",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/net2/managed_connection.go#L51-L69 |
24,758 | dropbox/godropbox | net2/managed_connection.go | RawConn | func (c *managedConnImpl) RawConn() net.Conn {
h, _ := c.handle.Handle()
return h.(net.Conn)
} | go | func (c *managedConnImpl) RawConn() net.Conn {
h, _ := c.handle.Handle()
return h.(net.Conn)
} | [
"func",
"(",
"c",
"*",
"managedConnImpl",
")",
"RawConn",
"(",
")",
"net",
".",
"Conn",
"{",
"h",
",",
"_",
":=",
"c",
".",
"handle",
".",
"Handle",
"(",
")",
"\n",
"return",
"h",
".",
"(",
"net",
".",
"Conn",
")",
"\n",
"}"
] | // See ManagedConn for documentation. | [
"See",
"ManagedConn",
"for",
"documentation",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/net2/managed_connection.go#L77-L80 |
24,759 | dropbox/godropbox | net2/port.go | GetPort | func GetPort(addr net.Addr) (int, error) {
_, lport, err := net.SplitHostPort(addr.String())
if err != nil {
return -1, err
}
lportInt, err := strconv.Atoi(lport)
if err != nil {
return -1, err
}
return lportInt, nil
} | go | func GetPort(addr net.Addr) (int, error) {
_, lport, err := net.SplitHostPort(addr.String())
if err != nil {
return -1, err
}
lportInt, err := strconv.Atoi(lport)
if err != nil {
return -1, err
}
return lportInt, nil
} | [
"func",
"GetPort",
"(",
"addr",
"net",
".",
"Addr",
")",
"(",
"int",
",",
"error",
")",
"{",
"_",
",",
"lport",
",",
"err",
":=",
"net",
".",
"SplitHostPort",
"(",
"addr",
".",
"String",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"retu... | // Returns the port information. | [
"Returns",
"the",
"port",
"information",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/net2/port.go#L9-L19 |
24,760 | dropbox/godropbox | math2/rand2/rand.go | NewSource | func NewSource(seed int64) rand.Source {
return &lockedSource{
src: rand.NewSource(seed),
}
} | go | func NewSource(seed int64) rand.Source {
return &lockedSource{
src: rand.NewSource(seed),
}
} | [
"func",
"NewSource",
"(",
"seed",
"int64",
")",
"rand",
".",
"Source",
"{",
"return",
"&",
"lockedSource",
"{",
"src",
":",
"rand",
".",
"NewSource",
"(",
"seed",
")",
",",
"}",
"\n",
"}"
] | // This returns a thread-safe random source. | [
"This",
"returns",
"a",
"thread",
"-",
"safe",
"random",
"source",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/math2/rand2/rand.go#L37-L41 |
24,761 | dropbox/godropbox | math2/rand2/rand.go | GetSeed | func GetSeed() int64 {
now := time.Now()
return now.Unix() + int64(now.Nanosecond()) + 12345*int64(os.Getpid())
} | go | func GetSeed() int64 {
now := time.Now()
return now.Unix() + int64(now.Nanosecond()) + 12345*int64(os.Getpid())
} | [
"func",
"GetSeed",
"(",
")",
"int64",
"{",
"now",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"return",
"now",
".",
"Unix",
"(",
")",
"+",
"int64",
"(",
"now",
".",
"Nanosecond",
"(",
")",
")",
"+",
"12345",
"*",
"int64",
"(",
"os",
".",
"Getpid"... | // Generates a seed based on the current time and the process ID. | [
"Generates",
"a",
"seed",
"based",
"on",
"the",
"current",
"time",
"and",
"the",
"process",
"ID",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/math2/rand2/rand.go#L44-L47 |
24,762 | dropbox/godropbox | math2/rand2/rand.go | Dur | func Dur(max time.Duration) time.Duration {
return time.Duration(Int63n(int64(max)))
} | go | func Dur(max time.Duration) time.Duration {
return time.Duration(Int63n(int64(max)))
} | [
"func",
"Dur",
"(",
"max",
"time",
".",
"Duration",
")",
"time",
".",
"Duration",
"{",
"return",
"time",
".",
"Duration",
"(",
"Int63n",
"(",
"int64",
"(",
"max",
")",
")",
")",
"\n",
"}"
] | // Dur returns a pseudo-random Duration in [0, max) | [
"Dur",
"returns",
"a",
"pseudo",
"-",
"random",
"Duration",
"in",
"[",
"0",
"max",
")"
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/math2/rand2/rand.go#L101-L103 |
24,763 | dropbox/godropbox | math2/rand2/rand.go | SampleInts | func SampleInts(n int, k int) (res []int, err error) {
if k < 0 {
err = errors.Newf("invalid sample size k")
return
}
if n < k {
err = errors.Newf("sample size k larger than n")
return
}
picked := set.NewSet()
for picked.Len() < k {
i := Intn(n)
picked.Add(i)
}
res = make([]int, k)
e := 0
for i... | go | func SampleInts(n int, k int) (res []int, err error) {
if k < 0 {
err = errors.Newf("invalid sample size k")
return
}
if n < k {
err = errors.Newf("sample size k larger than n")
return
}
picked := set.NewSet()
for picked.Len() < k {
i := Intn(n)
picked.Add(i)
}
res = make([]int, k)
e := 0
for i... | [
"func",
"SampleInts",
"(",
"n",
"int",
",",
"k",
"int",
")",
"(",
"res",
"[",
"]",
"int",
",",
"err",
"error",
")",
"{",
"if",
"k",
"<",
"0",
"{",
"err",
"=",
"errors",
".",
"Newf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"... | // Samples 'k' unique ints from the range [0, n) | [
"Samples",
"k",
"unique",
"ints",
"from",
"the",
"range",
"[",
"0",
"n",
")"
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/math2/rand2/rand.go#L118-L143 |
24,764 | dropbox/godropbox | math2/rand2/rand.go | Sample | func Sample(population []interface{}, k int) (res []interface{}, err error) {
n := len(population)
idxs, err := SampleInts(n, k)
if err != nil {
return
}
res = []interface{}{}
for _, idx := range idxs {
res = append(res, population[idx])
}
return
} | go | func Sample(population []interface{}, k int) (res []interface{}, err error) {
n := len(population)
idxs, err := SampleInts(n, k)
if err != nil {
return
}
res = []interface{}{}
for _, idx := range idxs {
res = append(res, population[idx])
}
return
} | [
"func",
"Sample",
"(",
"population",
"[",
"]",
"interface",
"{",
"}",
",",
"k",
"int",
")",
"(",
"res",
"[",
"]",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"{",
"n",
":=",
"len",
"(",
"population",
")",
"\n",
"idxs",
",",
"err",
":=",
"S... | // Samples 'k' elements from the given slice | [
"Samples",
"k",
"elements",
"from",
"the",
"given",
"slice"
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/math2/rand2/rand.go#L146-L159 |
24,765 | dropbox/godropbox | math2/rand2/rand.go | PickN | func PickN(population []interface{}, n int) (
picked []interface{}, remaining []interface{}, err error) {
total := len(population)
idxs, err := SampleInts(total, n)
if err != nil {
return
}
sort.Ints(idxs)
picked, remaining = []interface{}{}, []interface{}{}
for x, elem := range population {
if len(idxs) ... | go | func PickN(population []interface{}, n int) (
picked []interface{}, remaining []interface{}, err error) {
total := len(population)
idxs, err := SampleInts(total, n)
if err != nil {
return
}
sort.Ints(idxs)
picked, remaining = []interface{}{}, []interface{}{}
for x, elem := range population {
if len(idxs) ... | [
"func",
"PickN",
"(",
"population",
"[",
"]",
"interface",
"{",
"}",
",",
"n",
"int",
")",
"(",
"picked",
"[",
"]",
"interface",
"{",
"}",
",",
"remaining",
"[",
"]",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"{",
"total",
":=",
"len",
"("... | // Same as 'Sample' except it returns both the 'picked' sample set and the
// 'remaining' elements. | [
"Same",
"as",
"Sample",
"except",
"it",
"returns",
"both",
"the",
"picked",
"sample",
"set",
"and",
"the",
"remaining",
"elements",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/math2/rand2/rand.go#L163-L184 |
24,766 | dropbox/godropbox | math2/rand2/rand.go | Shuffle | func Shuffle(collection Swapper) {
// Fisher-Yates shuffle.
for i := collection.Len() - 1; i >= 0; i-- {
collection.Swap(i, Intn(i+1))
}
} | go | func Shuffle(collection Swapper) {
// Fisher-Yates shuffle.
for i := collection.Len() - 1; i >= 0; i-- {
collection.Swap(i, Intn(i+1))
}
} | [
"func",
"Shuffle",
"(",
"collection",
"Swapper",
")",
"{",
"// Fisher-Yates shuffle.",
"for",
"i",
":=",
"collection",
".",
"Len",
"(",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"collection",
".",
"Swap",
"(",
"i",
",",
"Intn",
"(",
... | // Randomly shuffles the collection in place. | [
"Randomly",
"shuffles",
"the",
"collection",
"in",
"place",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/math2/rand2/rand.go#L195-L200 |
24,767 | dropbox/godropbox | sync2/semaphore.go | TryAcquire | func (sem *boundedSemaphore) TryAcquire(timeout time.Duration) bool {
if timeout > 0 {
// Wait until we get a slot or timeout expires.
tm := time.NewTimer(timeout)
defer tm.Stop()
select {
case <-sem.slots:
return true
case <-tm.C:
// Timeout expired. In very rare cases this might happen even if
/... | go | func (sem *boundedSemaphore) TryAcquire(timeout time.Duration) bool {
if timeout > 0 {
// Wait until we get a slot or timeout expires.
tm := time.NewTimer(timeout)
defer tm.Stop()
select {
case <-sem.slots:
return true
case <-tm.C:
// Timeout expired. In very rare cases this might happen even if
/... | [
"func",
"(",
"sem",
"*",
"boundedSemaphore",
")",
"TryAcquire",
"(",
"timeout",
"time",
".",
"Duration",
")",
"bool",
"{",
"if",
"timeout",
">",
"0",
"{",
"// Wait until we get a slot or timeout expires.",
"tm",
":=",
"time",
".",
"NewTimer",
"(",
"timeout",
"... | // TryAcquire returns true if it acquires a resource slot within the
// timeout, false otherwise. | [
"TryAcquire",
"returns",
"true",
"if",
"it",
"acquires",
"a",
"resource",
"slot",
"within",
"the",
"timeout",
"false",
"otherwise",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sync2/semaphore.go#L47-L70 |
24,768 | dropbox/godropbox | database/sqlbuilder/expression.go | Literal | func Literal(v interface{}) Expression {
value, err := sqltypes.BuildValue(v)
if err != nil {
panic(errors.Wrap(err, "Invalid literal value"))
}
return &literalExpression{value: value}
} | go | func Literal(v interface{}) Expression {
value, err := sqltypes.BuildValue(v)
if err != nil {
panic(errors.Wrap(err, "Invalid literal value"))
}
return &literalExpression{value: value}
} | [
"func",
"Literal",
"(",
"v",
"interface",
"{",
"}",
")",
"Expression",
"{",
"value",
",",
"err",
":=",
"sqltypes",
".",
"BuildValue",
"(",
"v",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
... | // Returns an escaped literal string | [
"Returns",
"an",
"escaped",
"literal",
"string"
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/sqlbuilder/expression.go#L368-L374 |
24,769 | dropbox/godropbox | database/sqlbuilder/expression.go | Eq | func Eq(lhs, rhs Expression) BoolExpression {
lit, ok := rhs.(*literalExpression)
if ok && sqltypes.Value(lit.value).IsNull() {
return newBoolExpression(lhs, rhs, []byte(" IS "))
}
return newBoolExpression(lhs, rhs, []byte("="))
} | go | func Eq(lhs, rhs Expression) BoolExpression {
lit, ok := rhs.(*literalExpression)
if ok && sqltypes.Value(lit.value).IsNull() {
return newBoolExpression(lhs, rhs, []byte(" IS "))
}
return newBoolExpression(lhs, rhs, []byte("="))
} | [
"func",
"Eq",
"(",
"lhs",
",",
"rhs",
"Expression",
")",
"BoolExpression",
"{",
"lit",
",",
"ok",
":=",
"rhs",
".",
"(",
"*",
"literalExpression",
")",
"\n",
"if",
"ok",
"&&",
"sqltypes",
".",
"Value",
"(",
"lit",
".",
"value",
")",
".",
"IsNull",
... | // Returns a representation of "a=b" | [
"Returns",
"a",
"representation",
"of",
"a",
"=",
"b"
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/sqlbuilder/expression.go#L441-L447 |
24,770 | dropbox/godropbox | database/sqlbuilder/expression.go | Lt | func Lt(lhs Expression, rhs Expression) BoolExpression {
return newBoolExpression(lhs, rhs, []byte("<"))
} | go | func Lt(lhs Expression, rhs Expression) BoolExpression {
return newBoolExpression(lhs, rhs, []byte("<"))
} | [
"func",
"Lt",
"(",
"lhs",
"Expression",
",",
"rhs",
"Expression",
")",
"BoolExpression",
"{",
"return",
"newBoolExpression",
"(",
"lhs",
",",
"rhs",
",",
"[",
"]",
"byte",
"(",
"\"",
"\"",
")",
")",
"\n",
"}"
] | // Returns a representation of "a<b" | [
"Returns",
"a",
"representation",
"of",
"a<b"
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/sqlbuilder/expression.go#L469-L471 |
24,771 | dropbox/godropbox | memcache/raw_ascii_client.go | NewRawAsciiClient | func NewRawAsciiClient(shard int, channel io.ReadWriter) ClientShard {
return &RawAsciiClient{
shard: shard,
channel: channel,
validState: true,
writer: bufio.NewWriter(channel),
reader: bufio.NewReader(channel),
}
} | go | func NewRawAsciiClient(shard int, channel io.ReadWriter) ClientShard {
return &RawAsciiClient{
shard: shard,
channel: channel,
validState: true,
writer: bufio.NewWriter(channel),
reader: bufio.NewReader(channel),
}
} | [
"func",
"NewRawAsciiClient",
"(",
"shard",
"int",
",",
"channel",
"io",
".",
"ReadWriter",
")",
"ClientShard",
"{",
"return",
"&",
"RawAsciiClient",
"{",
"shard",
":",
"shard",
",",
"channel",
":",
"channel",
",",
"validState",
":",
"true",
",",
"writer",
... | // This creates a new memcache RawAsciiClient. | [
"This",
"creates",
"a",
"new",
"memcache",
"RawAsciiClient",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/memcache/raw_ascii_client.go#L30-L38 |
24,772 | dropbox/godropbox | sync2/boundedrwlock.go | NewBoundedRWLock | func NewBoundedRWLock(capacity int) *BoundedRWLock {
return &BoundedRWLock{
waiters: make(chan *rwwait, capacity),
control: &sync.Mutex{},
}
} | go | func NewBoundedRWLock(capacity int) *BoundedRWLock {
return &BoundedRWLock{
waiters: make(chan *rwwait, capacity),
control: &sync.Mutex{},
}
} | [
"func",
"NewBoundedRWLock",
"(",
"capacity",
"int",
")",
"*",
"BoundedRWLock",
"{",
"return",
"&",
"BoundedRWLock",
"{",
"waiters",
":",
"make",
"(",
"chan",
"*",
"rwwait",
",",
"capacity",
")",
",",
"control",
":",
"&",
"sync",
".",
"Mutex",
"{",
"}",
... | // Create a new BoundedRWLock with the given capacity.
//
// RLocks or WLocks beyond this capacity will fail fast with an error. | [
"Create",
"a",
"new",
"BoundedRWLock",
"with",
"the",
"given",
"capacity",
".",
"RLocks",
"or",
"WLocks",
"beyond",
"this",
"capacity",
"will",
"fail",
"fast",
"with",
"an",
"error",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sync2/boundedrwlock.go#L32-L37 |
24,773 | dropbox/godropbox | sync2/boundedrwlock.go | RLock | func (rw *BoundedRWLock) RLock(timeout time.Duration) (err error) {
deadline := time.After(timeout)
rw.control.Lock()
if rw.nextWriter != nil {
me := newWait(false)
select {
case rw.waiters <- me:
default:
err = errors.New("Waiter capacity reached in RLock")
}
rw.control.Unlock()
if err != nil {
... | go | func (rw *BoundedRWLock) RLock(timeout time.Duration) (err error) {
deadline := time.After(timeout)
rw.control.Lock()
if rw.nextWriter != nil {
me := newWait(false)
select {
case rw.waiters <- me:
default:
err = errors.New("Waiter capacity reached in RLock")
}
rw.control.Unlock()
if err != nil {
... | [
"func",
"(",
"rw",
"*",
"BoundedRWLock",
")",
"RLock",
"(",
"timeout",
"time",
".",
"Duration",
")",
"(",
"err",
"error",
")",
"{",
"deadline",
":=",
"time",
".",
"After",
"(",
"timeout",
")",
"\n",
"rw",
".",
"control",
".",
"Lock",
"(",
")",
"\n"... | // Wait for a read lock for up to 'timeout'.
//
// Error will be non-nil on timeout or when the wait list is at capacity. | [
"Wait",
"for",
"a",
"read",
"lock",
"for",
"up",
"to",
"timeout",
".",
"Error",
"will",
"be",
"non",
"-",
"nil",
"on",
"timeout",
"or",
"when",
"the",
"wait",
"list",
"is",
"at",
"capacity",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sync2/boundedrwlock.go#L42-L66 |
24,774 | dropbox/godropbox | sync2/boundedrwlock.go | WLock | func (rw *BoundedRWLock) WLock(timeout time.Duration) (err error) {
deadline := time.After(timeout)
rw.control.Lock()
if rw.readers != 0 || rw.nextWriter != nil {
me := newWait(true)
if rw.nextWriter == nil {
rw.nextWriter = me
} else {
select {
case rw.waiters <- me:
default:
err = errors.New(... | go | func (rw *BoundedRWLock) WLock(timeout time.Duration) (err error) {
deadline := time.After(timeout)
rw.control.Lock()
if rw.readers != 0 || rw.nextWriter != nil {
me := newWait(true)
if rw.nextWriter == nil {
rw.nextWriter = me
} else {
select {
case rw.waiters <- me:
default:
err = errors.New(... | [
"func",
"(",
"rw",
"*",
"BoundedRWLock",
")",
"WLock",
"(",
"timeout",
"time",
".",
"Duration",
")",
"(",
"err",
"error",
")",
"{",
"deadline",
":=",
"time",
".",
"After",
"(",
"timeout",
")",
"\n",
"rw",
".",
"control",
".",
"Lock",
"(",
")",
"\n"... | // Lock for writing, waiting up to 'timeout' for successful exclusive
// acquisition of the lock. | [
"Lock",
"for",
"writing",
"waiting",
"up",
"to",
"timeout",
"for",
"successful",
"exclusive",
"acquisition",
"of",
"the",
"lock",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sync2/boundedrwlock.go#L83-L118 |
24,775 | dropbox/godropbox | sync2/boundedrwlock.go | WaitAtomic | func (wait *rwwait) WaitAtomic(after <-chan time.Time) bool {
select {
case <-wait.wake:
return true
case <-after:
}
swapped := atomic.CompareAndSwapInt32(&wait.alive, 1, 0)
// They're gonna put it.
if !swapped {
<-wait.wake
return true
}
return false
} | go | func (wait *rwwait) WaitAtomic(after <-chan time.Time) bool {
select {
case <-wait.wake:
return true
case <-after:
}
swapped := atomic.CompareAndSwapInt32(&wait.alive, 1, 0)
// They're gonna put it.
if !swapped {
<-wait.wake
return true
}
return false
} | [
"func",
"(",
"wait",
"*",
"rwwait",
")",
"WaitAtomic",
"(",
"after",
"<-",
"chan",
"time",
".",
"Time",
")",
"bool",
"{",
"select",
"{",
"case",
"<-",
"wait",
".",
"wake",
":",
"return",
"true",
"\n",
"case",
"<-",
"after",
":",
"}",
"\n",
"swapped... | // Wait for a signal on the waiter, with the guarantee that both goroutines
// will agree on whether or not the signal was delivered.
//
// Returns true if the wake occurred, false on timeout. | [
"Wait",
"for",
"a",
"signal",
"on",
"the",
"waiter",
"with",
"the",
"guarantee",
"that",
"both",
"goroutines",
"will",
"agree",
"on",
"whether",
"or",
"not",
"the",
"signal",
"was",
"delivered",
".",
"Returns",
"true",
"if",
"the",
"wake",
"occurred",
"fal... | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sync2/boundedrwlock.go#L191-L204 |
24,776 | dropbox/godropbox | sync2/boundedrwlock.go | WakeAtomic | func (wait *rwwait) WakeAtomic() bool {
swapped := atomic.CompareAndSwapInt32(&wait.alive, 1, 0)
if !swapped {
// They've moved on.
return false
}
wait.wake <- true
return true
} | go | func (wait *rwwait) WakeAtomic() bool {
swapped := atomic.CompareAndSwapInt32(&wait.alive, 1, 0)
if !swapped {
// They've moved on.
return false
}
wait.wake <- true
return true
} | [
"func",
"(",
"wait",
"*",
"rwwait",
")",
"WakeAtomic",
"(",
")",
"bool",
"{",
"swapped",
":=",
"atomic",
".",
"CompareAndSwapInt32",
"(",
"&",
"wait",
".",
"alive",
",",
"1",
",",
"0",
")",
"\n",
"if",
"!",
"swapped",
"{",
"// They've moved on.",
"retu... | // Signal the wait to wake.
//
// Returns true of the waiter got the signal, false if the waiter timed out
// before we could deliver the signal. | [
"Signal",
"the",
"wait",
"to",
"wake",
".",
"Returns",
"true",
"of",
"the",
"waiter",
"got",
"the",
"signal",
"false",
"if",
"the",
"waiter",
"timed",
"out",
"before",
"we",
"could",
"deliver",
"the",
"signal",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sync2/boundedrwlock.go#L210-L218 |
24,777 | dropbox/godropbox | database/binlog/xid_event.go | Parse | func (p *XidEventParser) Parse(raw *RawV4Event) (Event, error) {
xe := &XidEvent{
Event: raw,
}
// For convenience, we'll interpret the bytes as little endian, our
// dominate computing (intel) platform.
_, err := readLittleEndian(raw.VariableLengthData(), &xe.xid)
if err != nil {
return raw, errors.Wrap(err... | go | func (p *XidEventParser) Parse(raw *RawV4Event) (Event, error) {
xe := &XidEvent{
Event: raw,
}
// For convenience, we'll interpret the bytes as little endian, our
// dominate computing (intel) platform.
_, err := readLittleEndian(raw.VariableLengthData(), &xe.xid)
if err != nil {
return raw, errors.Wrap(err... | [
"func",
"(",
"p",
"*",
"XidEventParser",
")",
"Parse",
"(",
"raw",
"*",
"RawV4Event",
")",
"(",
"Event",
",",
"error",
")",
"{",
"xe",
":=",
"&",
"XidEvent",
"{",
"Event",
":",
"raw",
",",
"}",
"\n\n",
"// For convenience, we'll interpret the bytes as little... | // XidEventParser's Parse processes a raw xid event into a XidEvent. | [
"XidEventParser",
"s",
"Parse",
"processes",
"a",
"raw",
"xid",
"event",
"into",
"a",
"XidEvent",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/binlog/xid_event.go#L50-L63 |
24,778 | dropbox/godropbox | memcache/mock_client.go | Get | func (c *MockClient) Get(key string) GetResponse {
c.mutex.Lock()
defer c.mutex.Unlock()
return c.getHelper(key)
} | go | func (c *MockClient) Get(key string) GetResponse {
c.mutex.Lock()
defer c.mutex.Unlock()
return c.getHelper(key)
} | [
"func",
"(",
"c",
"*",
"MockClient",
")",
"Get",
"(",
"key",
"string",
")",
"GetResponse",
"{",
"c",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"c",
".",
"getHelper",
"(",
"ke... | // This retrieves a single entry from memcache. | [
"This",
"retrieves",
"a",
"single",
"entry",
"from",
"memcache",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/memcache/mock_client.go#L58-L63 |
24,779 | dropbox/godropbox | memcache/mock_client.go | GetMulti | func (c *MockClient) GetMulti(keys []string) map[string]GetResponse {
c.mutex.Lock()
defer c.mutex.Unlock()
res := make(map[string]GetResponse)
for _, key := range keys {
res[key] = c.getHelper(key)
}
return res
} | go | func (c *MockClient) GetMulti(keys []string) map[string]GetResponse {
c.mutex.Lock()
defer c.mutex.Unlock()
res := make(map[string]GetResponse)
for _, key := range keys {
res[key] = c.getHelper(key)
}
return res
} | [
"func",
"(",
"c",
"*",
"MockClient",
")",
"GetMulti",
"(",
"keys",
"[",
"]",
"string",
")",
"map",
"[",
"string",
"]",
"GetResponse",
"{",
"c",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n"... | // Batch version of the Get method. | [
"Batch",
"version",
"of",
"the",
"Get",
"method",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/memcache/mock_client.go#L66-L75 |
24,780 | dropbox/godropbox | memcache/mock_client.go | Delete | func (c *MockClient) Delete(key string) MutateResponse {
c.mutex.Lock()
defer c.mutex.Unlock()
if c.forceFailEverything {
return NewMutateResponse(
key,
StatusInternalError,
0)
}
_, ok := c.data[key]
if !ok {
return NewMutateResponse(
key,
StatusKeyNotFound,
0)
}
delete(c.data, key)
r... | go | func (c *MockClient) Delete(key string) MutateResponse {
c.mutex.Lock()
defer c.mutex.Unlock()
if c.forceFailEverything {
return NewMutateResponse(
key,
StatusInternalError,
0)
}
_, ok := c.data[key]
if !ok {
return NewMutateResponse(
key,
StatusKeyNotFound,
0)
}
delete(c.data, key)
r... | [
"func",
"(",
"c",
"*",
"MockClient",
")",
"Delete",
"(",
"key",
"string",
")",
"MutateResponse",
"{",
"c",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"c",
".",
"forceFailEverything",
... | // This deletes a single entry from memcache. | [
"This",
"deletes",
"a",
"single",
"entry",
"from",
"memcache",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/memcache/mock_client.go#L235-L260 |
24,781 | dropbox/godropbox | memcache/mock_client.go | Append | func (c *MockClient) Append(key string, value []byte) MutateResponse {
return NewMutateErrorResponse(key, errors.Newf("Append not implemented"))
} | go | func (c *MockClient) Append(key string, value []byte) MutateResponse {
return NewMutateErrorResponse(key, errors.Newf("Append not implemented"))
} | [
"func",
"(",
"c",
"*",
"MockClient",
")",
"Append",
"(",
"key",
"string",
",",
"value",
"[",
"]",
"byte",
")",
"MutateResponse",
"{",
"return",
"NewMutateErrorResponse",
"(",
"key",
",",
"errors",
".",
"Newf",
"(",
"\"",
"\"",
")",
")",
"\n",
"}"
] | // This appends the value bytes to the end of an existing entry. Note that
// this does not allow you to extend past the item limit. | [
"This",
"appends",
"the",
"value",
"bytes",
"to",
"the",
"end",
"of",
"an",
"existing",
"entry",
".",
"Note",
"that",
"this",
"does",
"not",
"allow",
"you",
"to",
"extend",
"past",
"the",
"item",
"limit",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/memcache/mock_client.go#L274-L276 |
24,782 | dropbox/godropbox | memcache/mock_client.go | Flush | func (c *MockClient) Flush(expiration uint32) Response {
c.mutex.Lock()
defer c.mutex.Unlock()
// TODO(patrick): Use expiration argument
c.data = make(map[string]*Item)
return NewResponse(StatusNoError)
} | go | func (c *MockClient) Flush(expiration uint32) Response {
c.mutex.Lock()
defer c.mutex.Unlock()
// TODO(patrick): Use expiration argument
c.data = make(map[string]*Item)
return NewResponse(StatusNoError)
} | [
"func",
"(",
"c",
"*",
"MockClient",
")",
"Flush",
"(",
"expiration",
"uint32",
")",
"Response",
"{",
"c",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"// TODO(patrick): Use expiration argument",
... | // This invalidates all existing cache items after expiration number of
// seconds. | [
"This",
"invalidates",
"all",
"existing",
"cache",
"items",
"after",
"expiration",
"number",
"of",
"seconds",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/memcache/mock_client.go#L395-L402 |
24,783 | dropbox/godropbox | memcache/mock_client.go | Stat | func (c *MockClient) Stat(statsKey string) StatResponse {
return NewStatErrorResponse(errors.Newf("Stat not implemented"), nil)
} | go | func (c *MockClient) Stat(statsKey string) StatResponse {
return NewStatErrorResponse(errors.Newf("Stat not implemented"), nil)
} | [
"func",
"(",
"c",
"*",
"MockClient",
")",
"Stat",
"(",
"statsKey",
"string",
")",
"StatResponse",
"{",
"return",
"NewStatErrorResponse",
"(",
"errors",
".",
"Newf",
"(",
"\"",
"\"",
")",
",",
"nil",
")",
"\n",
"}"
] | // This requests the server statistics. When the key is an empty string,
// the server will respond with a "default" set of statistics information. | [
"This",
"requests",
"the",
"server",
"statistics",
".",
"When",
"the",
"key",
"is",
"an",
"empty",
"string",
"the",
"server",
"will",
"respond",
"with",
"a",
"default",
"set",
"of",
"statistics",
"information",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/memcache/mock_client.go#L406-L408 |
24,784 | dropbox/godropbox | net2/ip.go | MyHostname | func MyHostname() string {
myHostnameOnce.Do(func() {
var err error
myHostname, err = os.Hostname()
if err != nil {
log.Fatal(err)
}
})
return myHostname
} | go | func MyHostname() string {
myHostnameOnce.Do(func() {
var err error
myHostname, err = os.Hostname()
if err != nil {
log.Fatal(err)
}
})
return myHostname
} | [
"func",
"MyHostname",
"(",
")",
"string",
"{",
"myHostnameOnce",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"var",
"err",
"error",
"\n",
"myHostname",
",",
"err",
"=",
"os",
".",
"Hostname",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
... | // Like os.Hostname but caches first successful result, making it cheap to call it
// over and over.
// It will also crash whole process if fetching Hostname fails! | [
"Like",
"os",
".",
"Hostname",
"but",
"caches",
"first",
"successful",
"result",
"making",
"it",
"cheap",
"to",
"call",
"it",
"over",
"and",
"over",
".",
"It",
"will",
"also",
"crash",
"whole",
"process",
"if",
"fetching",
"Hostname",
"fails!"
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/net2/ip.go#L19-L28 |
24,785 | dropbox/godropbox | database/binlog/event_reader.go | IsRetryableError | func IsRetryableError(err error) bool {
if err == io.EOF {
return true
}
if _, ok := err.(*FailedToOpenFileError); ok {
return true
}
return false
} | go | func IsRetryableError(err error) bool {
if err == io.EOF {
return true
}
if _, ok := err.(*FailedToOpenFileError); ok {
return true
}
return false
} | [
"func",
"IsRetryableError",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"err",
"==",
"io",
".",
"EOF",
"{",
"return",
"true",
"\n",
"}",
"\n",
"if",
"_",
",",
"ok",
":=",
"err",
".",
"(",
"*",
"FailedToOpenFileError",
")",
";",
"ok",
"{",
"return"... | // This returns true if the error returned by the event parser is retryable. | [
"This",
"returns",
"true",
"if",
"the",
"error",
"returned",
"by",
"the",
"event",
"parser",
"is",
"retryable",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/binlog/event_reader.go#L52-L61 |
24,786 | dropbox/godropbox | database/sqlbuilder/statement.go | String | func (q *selectStatementImpl) String(database string) (sql string, err error) {
if !validIdentifierName(database) {
return "", errors.New("Invalid database name specified")
}
buf := new(bytes.Buffer)
_, _ = buf.WriteString("SELECT ")
if err = writeComment(q.comment, buf); err != nil {
return
}
if q.distin... | go | func (q *selectStatementImpl) String(database string) (sql string, err error) {
if !validIdentifierName(database) {
return "", errors.New("Invalid database name specified")
}
buf := new(bytes.Buffer)
_, _ = buf.WriteString("SELECT ")
if err = writeComment(q.comment, buf); err != nil {
return
}
if q.distin... | [
"func",
"(",
"q",
"*",
"selectStatementImpl",
")",
"String",
"(",
"database",
"string",
")",
"(",
"sql",
"string",
",",
"err",
"error",
")",
"{",
"if",
"!",
"validIdentifierName",
"(",
"database",
")",
"{",
"return",
"\"",
"\"",
",",
"errors",
".",
"Ne... | // Return the properly escaped SQL statement, against the specified database | [
"Return",
"the",
"properly",
"escaped",
"SQL",
"statement",
"against",
"the",
"specified",
"database"
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/sqlbuilder/statement.go#L386-L466 |
24,787 | dropbox/godropbox | database/sqlbuilder/statement.go | AddReadLock | func (s *lockStatementImpl) AddReadLock(t *Table) LockStatement {
s.locks = append(s.locks, tableLock{t: t, w: false})
return s
} | go | func (s *lockStatementImpl) AddReadLock(t *Table) LockStatement {
s.locks = append(s.locks, tableLock{t: t, w: false})
return s
} | [
"func",
"(",
"s",
"*",
"lockStatementImpl",
")",
"AddReadLock",
"(",
"t",
"*",
"Table",
")",
"LockStatement",
"{",
"s",
".",
"locks",
"=",
"append",
"(",
"s",
".",
"locks",
",",
"tableLock",
"{",
"t",
":",
"t",
",",
"w",
":",
"false",
"}",
")",
"... | // AddReadLock takes read lock on the table. | [
"AddReadLock",
"takes",
"read",
"lock",
"on",
"the",
"table",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/sqlbuilder/statement.go#L899-L902 |
24,788 | dropbox/godropbox | database/sqlbuilder/statement.go | AddWriteLock | func (s *lockStatementImpl) AddWriteLock(t *Table) LockStatement {
s.locks = append(s.locks, tableLock{t: t, w: true})
return s
} | go | func (s *lockStatementImpl) AddWriteLock(t *Table) LockStatement {
s.locks = append(s.locks, tableLock{t: t, w: true})
return s
} | [
"func",
"(",
"s",
"*",
"lockStatementImpl",
")",
"AddWriteLock",
"(",
"t",
"*",
"Table",
")",
"LockStatement",
"{",
"s",
".",
"locks",
"=",
"append",
"(",
"s",
".",
"locks",
",",
"tableLock",
"{",
"t",
":",
"t",
",",
"w",
":",
"true",
"}",
")",
"... | // AddWriteLock takes write lock on the table. | [
"AddWriteLock",
"takes",
"write",
"lock",
"on",
"the",
"table",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/sqlbuilder/statement.go#L905-L908 |
24,789 | dropbox/godropbox | database/sqlbuilder/statement.go | NewGtidNextStatement | func NewGtidNextStatement(sid []byte, gno uint64) GtidNextStatement {
return >idNextStatementImpl{
sid: sid,
gno: gno,
}
} | go | func NewGtidNextStatement(sid []byte, gno uint64) GtidNextStatement {
return >idNextStatementImpl{
sid: sid,
gno: gno,
}
} | [
"func",
"NewGtidNextStatement",
"(",
"sid",
"[",
"]",
"byte",
",",
"gno",
"uint64",
")",
"GtidNextStatement",
"{",
"return",
"&",
"gtidNextStatementImpl",
"{",
"sid",
":",
"sid",
",",
"gno",
":",
"gno",
",",
"}",
"\n",
"}"
] | // Set GTID_NEXT statement returns a SQL statement that can be used to explicitly set the next GTID. | [
"Set",
"GTID_NEXT",
"statement",
"returns",
"a",
"SQL",
"statement",
"that",
"can",
"be",
"used",
"to",
"explicitly",
"set",
"the",
"next",
"GTID",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/sqlbuilder/statement.go#L959-L964 |
24,790 | dropbox/godropbox | database/binlog/gtid_log_event.go | Parse | func (p *GtidLogEventParser) Parse(raw *RawV4Event) (Event, error) {
gle := &GtidLogEvent{
Event: raw,
}
if len(raw.VariableLengthData()) > 0 {
return raw, errors.New("GTID binlog event larger than expected size")
}
data := raw.FixedLengthData()
var commitData uint8
data, err := readLittleEndian(data, &co... | go | func (p *GtidLogEventParser) Parse(raw *RawV4Event) (Event, error) {
gle := &GtidLogEvent{
Event: raw,
}
if len(raw.VariableLengthData()) > 0 {
return raw, errors.New("GTID binlog event larger than expected size")
}
data := raw.FixedLengthData()
var commitData uint8
data, err := readLittleEndian(data, &co... | [
"func",
"(",
"p",
"*",
"GtidLogEventParser",
")",
"Parse",
"(",
"raw",
"*",
"RawV4Event",
")",
"(",
"Event",
",",
"error",
")",
"{",
"gle",
":=",
"&",
"GtidLogEvent",
"{",
"Event",
":",
"raw",
",",
"}",
"\n\n",
"if",
"len",
"(",
"raw",
".",
"Variab... | // GtidLogEventParser's Parse processes a raw gtid log event into a GtidLogEvent. | [
"GtidLogEventParser",
"s",
"Parse",
"processes",
"a",
"raw",
"gtid",
"log",
"event",
"into",
"a",
"GtidLogEvent",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/binlog/gtid_log_event.go#L53-L88 |
24,791 | dropbox/godropbox | resource_pool/multi_resource_pool.go | NewMultiResourcePool | func NewMultiResourcePool(
options Options,
createPool func(Options) ResourcePool) ResourcePool {
if createPool == nil {
createPool = NewSimpleResourcePool
}
return &multiResourcePool{
options: options,
createPool: createPool,
rwMutex: sync.RWMutex{},
isLameDuck: false,
locationPool... | go | func NewMultiResourcePool(
options Options,
createPool func(Options) ResourcePool) ResourcePool {
if createPool == nil {
createPool = NewSimpleResourcePool
}
return &multiResourcePool{
options: options,
createPool: createPool,
rwMutex: sync.RWMutex{},
isLameDuck: false,
locationPool... | [
"func",
"NewMultiResourcePool",
"(",
"options",
"Options",
",",
"createPool",
"func",
"(",
"Options",
")",
"ResourcePool",
")",
"ResourcePool",
"{",
"if",
"createPool",
"==",
"nil",
"{",
"createPool",
"=",
"NewSimpleResourcePool",
"\n",
"}",
"\n\n",
"return",
"&... | // This returns a MultiResourcePool, which manages multiple
// resource location entries. The handles to each resource location
// entry acts independently.
//
// When createPool is nil, NewSimpleResourcePool is used as default. | [
"This",
"returns",
"a",
"MultiResourcePool",
"which",
"manages",
"multiple",
"resource",
"location",
"entries",
".",
"The",
"handles",
"to",
"each",
"resource",
"location",
"entry",
"acts",
"independently",
".",
"When",
"createPool",
"is",
"nil",
"NewSimpleResourceP... | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/resource_pool/multi_resource_pool.go#L30-L45 |
24,792 | dropbox/godropbox | database/sqltypes/sqltypes.go | String | func (v Value) String() string {
if v.Inner == nil {
return ""
}
return string(v.Inner.raw())
} | go | func (v Value) String() string {
if v.Inner == nil {
return ""
}
return string(v.Inner.raw())
} | [
"func",
"(",
"v",
"Value",
")",
"String",
"(",
")",
"string",
"{",
"if",
"v",
".",
"Inner",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"string",
"(",
"v",
".",
"Inner",
".",
"raw",
"(",
")",
")",
"\n",
"}"
] | // String returns the raw value as a string | [
"String",
"returns",
"the",
"raw",
"value",
"as",
"a",
"string"
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/sqltypes/sqltypes.go#L87-L92 |
24,793 | dropbox/godropbox | database/sqltypes/sqltypes.go | EncodeSql | func (v Value) EncodeSql(b encoding2.BinaryWriter) {
if v.Inner == nil {
if _, err := b.Write(nullstr); err != nil {
panic(err)
}
} else {
v.Inner.encodeSql(b)
}
} | go | func (v Value) EncodeSql(b encoding2.BinaryWriter) {
if v.Inner == nil {
if _, err := b.Write(nullstr); err != nil {
panic(err)
}
} else {
v.Inner.encodeSql(b)
}
} | [
"func",
"(",
"v",
"Value",
")",
"EncodeSql",
"(",
"b",
"encoding2",
".",
"BinaryWriter",
")",
"{",
"if",
"v",
".",
"Inner",
"==",
"nil",
"{",
"if",
"_",
",",
"err",
":=",
"b",
".",
"Write",
"(",
"nullstr",
")",
";",
"err",
"!=",
"nil",
"{",
"pa... | // EncodeSql encodes the value into an SQL statement. Can be binary. | [
"EncodeSql",
"encodes",
"the",
"value",
"into",
"an",
"SQL",
"statement",
".",
"Can",
"be",
"binary",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/sqltypes/sqltypes.go#L95-L103 |
24,794 | dropbox/godropbox | database/sqltypes/sqltypes.go | EncodeAscii | func (v Value) EncodeAscii(b encoding2.BinaryWriter) {
if v.Inner == nil {
if _, err := b.Write(nullstr); err != nil {
panic(err)
}
} else {
v.Inner.encodeAscii(b)
}
} | go | func (v Value) EncodeAscii(b encoding2.BinaryWriter) {
if v.Inner == nil {
if _, err := b.Write(nullstr); err != nil {
panic(err)
}
} else {
v.Inner.encodeAscii(b)
}
} | [
"func",
"(",
"v",
"Value",
")",
"EncodeAscii",
"(",
"b",
"encoding2",
".",
"BinaryWriter",
")",
"{",
"if",
"v",
".",
"Inner",
"==",
"nil",
"{",
"if",
"_",
",",
"err",
":=",
"b",
".",
"Write",
"(",
"nullstr",
")",
";",
"err",
"!=",
"nil",
"{",
"... | // EncodeAscii encodes the value using 7-bit clean ascii bytes. | [
"EncodeAscii",
"encodes",
"the",
"value",
"using",
"7",
"-",
"bit",
"clean",
"ascii",
"bytes",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/sqltypes/sqltypes.go#L106-L114 |
24,795 | dropbox/godropbox | database/sqltypes/sqltypes.go | MarshalBinary | func (v Value) MarshalBinary() ([]byte, error) {
if v.IsNull() {
return []byte{byte(NullType)}, nil
}
return v.Inner.MarshalBinary()
} | go | func (v Value) MarshalBinary() ([]byte, error) {
if v.IsNull() {
return []byte{byte(NullType)}, nil
}
return v.Inner.MarshalBinary()
} | [
"func",
"(",
"v",
"Value",
")",
"MarshalBinary",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"v",
".",
"IsNull",
"(",
")",
"{",
"return",
"[",
"]",
"byte",
"{",
"byte",
"(",
"NullType",
")",
"}",
",",
"nil",
"\n",
"}",
"\n"... | // MarshalBinary helps implement BinaryMarshaler interface for Value. | [
"MarshalBinary",
"helps",
"implement",
"BinaryMarshaler",
"interface",
"for",
"Value",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/sqltypes/sqltypes.go#L117-L122 |
24,796 | dropbox/godropbox | database/sqltypes/sqltypes.go | UnmarshalBinary | func (v *Value) UnmarshalBinary(data []byte) error {
reader := bytes.NewReader(data)
b, err := reader.ReadByte()
if err != nil {
return err
}
typ := ValueType(b)
if typ == NullType {
*v = Value{}
return nil
}
length, err := binary.ReadUvarint(reader)
if err != nil {
return err
}
raw := make([]byt... | go | func (v *Value) UnmarshalBinary(data []byte) error {
reader := bytes.NewReader(data)
b, err := reader.ReadByte()
if err != nil {
return err
}
typ := ValueType(b)
if typ == NullType {
*v = Value{}
return nil
}
length, err := binary.ReadUvarint(reader)
if err != nil {
return err
}
raw := make([]byt... | [
"func",
"(",
"v",
"*",
"Value",
")",
"UnmarshalBinary",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"reader",
":=",
"bytes",
".",
"NewReader",
"(",
"data",
")",
"\n\n",
"b",
",",
"err",
":=",
"reader",
".",
"ReadByte",
"(",
")",
"\n",
"if",
... | // UnmarshalBinary helps implement BinaryUnmarshaler interface for Value. | [
"UnmarshalBinary",
"helps",
"implement",
"BinaryUnmarshaler",
"interface",
"for",
"Value",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/sqltypes/sqltypes.go#L125-L168 |
24,797 | dropbox/godropbox | database/sqltypes/sqltypes.go | ConvertAssignRowNullable | func ConvertAssignRowNullable(row []Value, dest ...interface{}) error {
if len(row) != len(dest) {
return errors.Newf(
"# of row entries %d does not match # of destinations %d",
len(row),
len(dest))
}
if row == nil {
return nil
}
for i := 0; i < len(row); i++ {
if row[i].IsNull() {
continue
}... | go | func ConvertAssignRowNullable(row []Value, dest ...interface{}) error {
if len(row) != len(dest) {
return errors.Newf(
"# of row entries %d does not match # of destinations %d",
len(row),
len(dest))
}
if row == nil {
return nil
}
for i := 0; i < len(row); i++ {
if row[i].IsNull() {
continue
}... | [
"func",
"ConvertAssignRowNullable",
"(",
"row",
"[",
"]",
"Value",
",",
"dest",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"len",
"(",
"row",
")",
"!=",
"len",
"(",
"dest",
")",
"{",
"return",
"errors",
".",
"Newf",
"(",
"\"",
"\"",
","... | // ConverAssignRowNullable is the same as ConvertAssignRow except that it allows
// nil as a value for the row or any of the row values. In thoses cases, the
// corresponding values are ignored. | [
"ConverAssignRowNullable",
"is",
"the",
"same",
"as",
"ConvertAssignRow",
"except",
"that",
"it",
"allows",
"nil",
"as",
"a",
"value",
"for",
"the",
"row",
"or",
"any",
"of",
"the",
"row",
"values",
".",
"In",
"thoses",
"cases",
"the",
"corresponding",
"valu... | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/sqltypes/sqltypes.go#L268-L292 |
24,798 | dropbox/godropbox | database/sqltypes/sqltypes.go | ConvertAssignDefault | func ConvertAssignDefault(src Value, dest interface{}, defaultValue interface{}) error {
if src.IsNull() {
// This is not the most efficient way of doing things, but it's certainly cleaner
v, err := BuildValue(defaultValue)
if err != nil {
return err
}
return ConvertAssign(v, dest)
}
return ConvertAssig... | go | func ConvertAssignDefault(src Value, dest interface{}, defaultValue interface{}) error {
if src.IsNull() {
// This is not the most efficient way of doing things, but it's certainly cleaner
v, err := BuildValue(defaultValue)
if err != nil {
return err
}
return ConvertAssign(v, dest)
}
return ConvertAssig... | [
"func",
"ConvertAssignDefault",
"(",
"src",
"Value",
",",
"dest",
"interface",
"{",
"}",
",",
"defaultValue",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"src",
".",
"IsNull",
"(",
")",
"{",
"// This is not the most efficient way of doing things, but it's certai... | // ConvertAssign, but with support for default values | [
"ConvertAssign",
"but",
"with",
"support",
"for",
"default",
"values"
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/sqltypes/sqltypes.go#L420-L430 |
24,799 | dropbox/godropbox | database/sqltypes/sqltypes.go | Uint64EncodeSql | func Uint64EncodeSql(b encoding2.BinaryWriter, num uint64) {
numVal, _ := BuildValue(num)
numVal.EncodeSql(b)
} | go | func Uint64EncodeSql(b encoding2.BinaryWriter, num uint64) {
numVal, _ := BuildValue(num)
numVal.EncodeSql(b)
} | [
"func",
"Uint64EncodeSql",
"(",
"b",
"encoding2",
".",
"BinaryWriter",
",",
"num",
"uint64",
")",
"{",
"numVal",
",",
"_",
":=",
"BuildValue",
"(",
"num",
")",
"\n",
"numVal",
".",
"EncodeSql",
"(",
"b",
")",
"\n",
"}"
] | // Helper function for converting a uint64 to a string suitable for SQL. | [
"Helper",
"function",
"for",
"converting",
"a",
"uint64",
"to",
"a",
"string",
"suitable",
"for",
"SQL",
"."
] | 5749d3b71cbefd8eacc316df3f0a6fcb9991bb51 | https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/database/sqltypes/sqltypes.go#L555-L558 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.