repo
stringlengths
5
67
path
stringlengths
4
218
func_name
stringlengths
0
151
original_string
stringlengths
52
373k
language
stringclasses
6 values
code
stringlengths
52
373k
code_tokens
listlengths
10
512
docstring
stringlengths
3
47.2k
docstring_tokens
listlengths
3
234
sha
stringlengths
40
40
url
stringlengths
85
339
partition
stringclasses
3 values
aarzilli/nucular
text.go
tonl
func (state *TextEditor) tonl(start int, dir int) int { sz := len(state.Buffer) i := start if i < 0 { return 0 } if i >= sz { i = sz - 1 } for ; (i >= 0) && (i < sz); i += dir { c := state.Buffer[i] if c == '\n' { if dir >= 0 { return i } else { return i + 1 } } } if dir < 0 { return 0 } else { return sz } }
go
func (state *TextEditor) tonl(start int, dir int) int { sz := len(state.Buffer) i := start if i < 0 { return 0 } if i >= sz { i = sz - 1 } for ; (i >= 0) && (i < sz); i += dir { c := state.Buffer[i] if c == '\n' { if dir >= 0 { return i } else { return i + 1 } } } if dir < 0 { return 0 } else { return sz } }
[ "func", "(", "state", "*", "TextEditor", ")", "tonl", "(", "start", "int", ",", "dir", "int", ")", "int", "{", "sz", ":=", "len", "(", "state", ".", "Buffer", ")", "\n", "i", ":=", "start", "\n", "if", "i", "<", "0", "{", "return", "0", "\n", ...
// Moves to the beginning or end of a line
[ "Moves", "to", "the", "beginning", "or", "end", "of", "a", "line" ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/text.go#L519-L545
train
aarzilli/nucular
text.go
towd
func (state *TextEditor) towd(start int, dir int, dontForceAdvance bool) int { first := (dir < 0) notfirst := !first var i int for i = start; (i >= 0) && (i < len(state.Buffer)); i += dir { c := state.Buffer[i] if !(unicode.IsLetter(c) || unicode.IsDigit(c) || (c == '_')) { if !first && !dontForceAdvance { i++ } break } first = notfirst } if i < 0 { i = 0 } return i }
go
func (state *TextEditor) towd(start int, dir int, dontForceAdvance bool) int { first := (dir < 0) notfirst := !first var i int for i = start; (i >= 0) && (i < len(state.Buffer)); i += dir { c := state.Buffer[i] if !(unicode.IsLetter(c) || unicode.IsDigit(c) || (c == '_')) { if !first && !dontForceAdvance { i++ } break } first = notfirst } if i < 0 { i = 0 } return i }
[ "func", "(", "state", "*", "TextEditor", ")", "towd", "(", "start", "int", ",", "dir", "int", ",", "dontForceAdvance", "bool", ")", "int", "{", "first", ":=", "(", "dir", "<", "0", ")", "\n", "notfirst", ":=", "!", "first", "\n", "var", "i", "int",...
// Moves to the beginning or end of an alphanumerically delimited word
[ "Moves", "to", "the", "beginning", "or", "end", "of", "an", "alphanumerically", "delimited", "word" ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/text.go#L548-L566
train
aarzilli/nucular
text.go
tospc
func (state *TextEditor) tospc(start int, dir int) int { return state.tof(start, dir, unicode.IsSpace) }
go
func (state *TextEditor) tospc(start int, dir int) int { return state.tof(start, dir, unicode.IsSpace) }
[ "func", "(", "state", "*", "TextEditor", ")", "tospc", "(", "start", "int", ",", "dir", "int", ")", "int", "{", "return", "state", ".", "tof", "(", "start", ",", "dir", ",", "unicode", ".", "IsSpace", ")", "\n", "}" ]
// Moves to the beginning or end of a space delimited word
[ "Moves", "to", "the", "beginning", "or", "end", "of", "a", "space", "delimited", "word" ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/text.go#L569-L571
train
aarzilli/nucular
text.go
tof
func (state *TextEditor) tof(start int, dir int, f func(rune) bool) int { first := (dir < 0) notfirst := !first var i int for i = start; (i >= 0) && (i < len(state.Buffer)); i += dir { c := state.Buffer[i] if f(c) { if !first { i++ } break } first = notfirst } if i < 0 { i = 0 } return i }
go
func (state *TextEditor) tof(start int, dir int, f func(rune) bool) int { first := (dir < 0) notfirst := !first var i int for i = start; (i >= 0) && (i < len(state.Buffer)); i += dir { c := state.Buffer[i] if f(c) { if !first { i++ } break } first = notfirst } if i < 0 { i = 0 } return i }
[ "func", "(", "state", "*", "TextEditor", ")", "tof", "(", "start", "int", ",", "dir", "int", ",", "f", "func", "(", "rune", ")", "bool", ")", "int", "{", "first", ":=", "(", "dir", "<", "0", ")", "\n", "notfirst", ":=", "!", "first", "\n", "var...
// Moves to the first position where f returns true
[ "Moves", "to", "the", "first", "position", "where", "f", "returns", "true" ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/text.go#L574-L592
train
aarzilli/nucular
text.go
tofp
func (state *TextEditor) tofp(start int, dir int) int { first := (dir < 0) notfirst := !first var i int for i = start; (i >= 0) && (i < len(state.Buffer)); i += dir { c := state.Buffer[i] if !(unicode.IsLetter(c) || unicode.IsDigit(c) || (c == '_') || (c == '-') || (c == '+') || (c == '/') || (c == '=') || (c == '~') || (c == '!') || (c == ':') || (c == ',') || (c == '.')) { if !first { i++ } break } first = notfirst } if i < 0 { i = 0 } return i }
go
func (state *TextEditor) tofp(start int, dir int) int { first := (dir < 0) notfirst := !first var i int for i = start; (i >= 0) && (i < len(state.Buffer)); i += dir { c := state.Buffer[i] if !(unicode.IsLetter(c) || unicode.IsDigit(c) || (c == '_') || (c == '-') || (c == '+') || (c == '/') || (c == '=') || (c == '~') || (c == '!') || (c == ':') || (c == ',') || (c == '.')) { if !first { i++ } break } first = notfirst } if i < 0 { i = 0 } return i }
[ "func", "(", "state", "*", "TextEditor", ")", "tofp", "(", "start", "int", ",", "dir", "int", ")", "int", "{", "first", ":=", "(", "dir", "<", "0", ")", "\n", "notfirst", ":=", "!", "first", "\n", "var", "i", "int", "\n", "for", "i", "=", "star...
// Moves to the beginning or end of something that looks like a file path
[ "Moves", "to", "the", "beginning", "or", "end", "of", "something", "that", "looks", "like", "a", "file", "path" ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/text.go#L595-L614
train
aarzilli/nucular
text.go
Paste
func (edit *TextEditor) Paste(ctext string) { if edit.Flags&EditReadOnly != 0 { return } /* if there's a selection, the paste should delete it */ edit.clamp() edit.DeleteSelection() text := []rune(ctext) edit.Buffer = strInsertText(edit.Buffer, edit.Cursor, text) edit.makeundoInsert(edit.Cursor, len(text)) edit.Cursor += len(text) edit.HasPreferredX = false }
go
func (edit *TextEditor) Paste(ctext string) { if edit.Flags&EditReadOnly != 0 { return } /* if there's a selection, the paste should delete it */ edit.clamp() edit.DeleteSelection() text := []rune(ctext) edit.Buffer = strInsertText(edit.Buffer, edit.Cursor, text) edit.makeundoInsert(edit.Cursor, len(text)) edit.Cursor += len(text) edit.HasPreferredX = false }
[ "func", "(", "edit", "*", "TextEditor", ")", "Paste", "(", "ctext", "string", ")", "{", "if", "edit", ".", "Flags", "&", "EditReadOnly", "!=", "0", "{", "return", "\n", "}", "\n", "edit", ".", "clamp", "(", ")", "\n", "edit", ".", "DeleteSelection", ...
// Paste from clipboard
[ "Paste", "from", "clipboard" ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/text.go#L641-L658
train
aarzilli/nucular
text.go
Edit
func (edit *TextEditor) Edit(win *Window) EditEvents { edit.init(win) if edit.Maxlen > 0 { if len(edit.Buffer) > edit.Maxlen { edit.Buffer = edit.Buffer[:edit.Maxlen] } } if edit.Flags&EditNoCursor != 0 { edit.Cursor = len(edit.Buffer) } if edit.Flags&EditSelectable == 0 { edit.SelectStart = edit.Cursor edit.SelectEnd = edit.Cursor } var bounds rect.Rect style := &edit.win.ctx.Style widget_state, bounds, _ := edit.win.widget() if !widget_state { return 0 } in := edit.win.inputMaybe(widget_state) var cut, copy, paste bool if w := win.ContextualOpen(0, image.Point{}, bounds, nil); w != nil { w.Row(20).Dynamic(1) visible := false if edit.Flags&EditClipboard != 0 { visible = true if w.MenuItem(label.TA("Cut", "LC")) { cut = true } if w.MenuItem(label.TA("Copy", "LC")) { copy = true } if w.MenuItem(label.TA("Paste", "LC")) { paste = true } } if edit.Flags&EditMultiline != 0 { visible = true if w.MenuItem(label.TA("Find...", "LC")) { edit.popupFind() } } if !visible { w.Close() } } ev := edit.doEdit(bounds, &style.Edit, in, cut, copy, paste) return ev }
go
func (edit *TextEditor) Edit(win *Window) EditEvents { edit.init(win) if edit.Maxlen > 0 { if len(edit.Buffer) > edit.Maxlen { edit.Buffer = edit.Buffer[:edit.Maxlen] } } if edit.Flags&EditNoCursor != 0 { edit.Cursor = len(edit.Buffer) } if edit.Flags&EditSelectable == 0 { edit.SelectStart = edit.Cursor edit.SelectEnd = edit.Cursor } var bounds rect.Rect style := &edit.win.ctx.Style widget_state, bounds, _ := edit.win.widget() if !widget_state { return 0 } in := edit.win.inputMaybe(widget_state) var cut, copy, paste bool if w := win.ContextualOpen(0, image.Point{}, bounds, nil); w != nil { w.Row(20).Dynamic(1) visible := false if edit.Flags&EditClipboard != 0 { visible = true if w.MenuItem(label.TA("Cut", "LC")) { cut = true } if w.MenuItem(label.TA("Copy", "LC")) { copy = true } if w.MenuItem(label.TA("Paste", "LC")) { paste = true } } if edit.Flags&EditMultiline != 0 { visible = true if w.MenuItem(label.TA("Find...", "LC")) { edit.popupFind() } } if !visible { w.Close() } } ev := edit.doEdit(bounds, &style.Edit, in, cut, copy, paste) return ev }
[ "func", "(", "edit", "*", "TextEditor", ")", "Edit", "(", "win", "*", "Window", ")", "EditEvents", "{", "edit", ".", "init", "(", "win", ")", "\n", "if", "edit", ".", "Maxlen", ">", "0", "{", "if", "len", "(", "edit", ".", "Buffer", ")", ">", "...
// Adds text editor edit to win. // Initial contents of the text editor will be set to text. If // alwaysSet is specified the contents of the editor will be reset // to text.
[ "Adds", "text", "editor", "edit", "to", "win", ".", "Initial", "contents", "of", "the", "text", "editor", "will", "be", "set", "to", "text", ".", "If", "alwaysSet", "is", "specified", "the", "contents", "of", "the", "editor", "will", "be", "reset", "to",...
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/text.go#L1780-L1835
train
aarzilli/nucular
context.go
SetColor
func (r *myRGBAPainter) SetColor(c color.Color) { r.cr, r.cg, r.cb, r.ca = c.RGBA() }
go
func (r *myRGBAPainter) SetColor(c color.Color) { r.cr, r.cg, r.cb, r.ca = c.RGBA() }
[ "func", "(", "r", "*", "myRGBAPainter", ")", "SetColor", "(", "c", "color", ".", "Color", ")", "{", "r", ".", "cr", ",", "r", ".", "cg", ",", "r", ".", "cb", ",", "r", ".", "ca", "=", "c", ".", "RGBA", "(", ")", "\n", "}" ]
// SetColor sets the color to paint the spans.
[ "SetColor", "sets", "the", "color", "to", "paint", "the", "spans", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/context.go#L724-L726
train
aarzilli/nucular
nucular.go
MenubarBegin
func (win *Window) MenubarBegin() { layout := win.layout layout.Menu.X = layout.AtX layout.Menu.Y = layout.Bounds.Y + layout.HeaderH layout.Menu.W = layout.Width layout.Menu.Offset = *layout.Offset layout.Offset.Y = 0 }
go
func (win *Window) MenubarBegin() { layout := win.layout layout.Menu.X = layout.AtX layout.Menu.Y = layout.Bounds.Y + layout.HeaderH layout.Menu.W = layout.Width layout.Menu.Offset = *layout.Offset layout.Offset.Y = 0 }
[ "func", "(", "win", "*", "Window", ")", "MenubarBegin", "(", ")", "{", "layout", ":=", "win", ".", "layout", "\n", "layout", ".", "Menu", ".", "X", "=", "layout", ".", "AtX", "\n", "layout", ".", "Menu", ".", "Y", "=", "layout", ".", "Bounds", "....
// MenubarBegin adds a menubar to the current window. // A menubar is an area displayed at the top of the window that is unaffected by scrolling. // Remember to call MenubarEnd when you are done adding elements to the menubar.
[ "MenubarBegin", "adds", "a", "menubar", "to", "the", "current", "window", ".", "A", "menubar", "is", "an", "area", "displayed", "at", "the", "top", "of", "the", "window", "that", "is", "unaffected", "by", "scrolling", ".", "Remember", "to", "call", "Menuba...
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L704-L712
train
aarzilli/nucular
nucular.go
MenubarEnd
func (win *Window) MenubarEnd() { layout := win.layout layout.Menu.H = layout.AtY - layout.Menu.Y layout.Clip.Y = layout.Bounds.Y + layout.HeaderH + layout.Menu.H + layout.Row.Height layout.Height -= layout.Menu.H *layout.Offset = layout.Menu.Offset layout.Clip.H -= layout.Menu.H + layout.Row.Height layout.AtY = layout.Menu.Y + layout.Menu.H win.cmds.PushScissor(layout.Clip) }
go
func (win *Window) MenubarEnd() { layout := win.layout layout.Menu.H = layout.AtY - layout.Menu.Y layout.Clip.Y = layout.Bounds.Y + layout.HeaderH + layout.Menu.H + layout.Row.Height layout.Height -= layout.Menu.H *layout.Offset = layout.Menu.Offset layout.Clip.H -= layout.Menu.H + layout.Row.Height layout.AtY = layout.Menu.Y + layout.Menu.H win.cmds.PushScissor(layout.Clip) }
[ "func", "(", "win", "*", "Window", ")", "MenubarEnd", "(", ")", "{", "layout", ":=", "win", ".", "layout", "\n", "layout", ".", "Menu", ".", "H", "=", "layout", ".", "AtY", "-", "layout", ".", "Menu", ".", "Y", "\n", "layout", ".", "Clip", ".", ...
// MenubarEnd signals that all widgets have been added to the menubar.
[ "MenubarEnd", "signals", "that", "all", "widgets", "have", "been", "added", "to", "the", "menubar", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L745-L755
train
aarzilli/nucular
nucular.go
LayoutReserveRow
func (win *Window) LayoutReserveRow(height int, num int) { win.LayoutReserveRowScaled(win.ctx.scale(height), num) }
go
func (win *Window) LayoutReserveRow(height int, num int) { win.LayoutReserveRowScaled(win.ctx.scale(height), num) }
[ "func", "(", "win", "*", "Window", ")", "LayoutReserveRow", "(", "height", "int", ",", "num", "int", ")", "{", "win", ".", "LayoutReserveRowScaled", "(", "win", ".", "ctx", ".", "scale", "(", "height", ")", ",", "num", ")", "\n", "}" ]
// Reserves space for num rows of the specified height at the bottom // of the panel. // If a row of height == 0 is inserted it will take reserved space // into account.
[ "Reserves", "space", "for", "num", "rows", "of", "the", "specified", "height", "at", "the", "bottom", "of", "the", "panel", ".", "If", "a", "row", "of", "height", "==", "0", "is", "inserted", "it", "will", "take", "reserved", "space", "into", "account", ...
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L995-L997
train
aarzilli/nucular
nucular.go
LayoutReserveRowScaled
func (win *Window) LayoutReserveRowScaled(height int, num int) { win.layout.ReservedHeight += height*num + win.style().Spacing.Y*num }
go
func (win *Window) LayoutReserveRowScaled(height int, num int) { win.layout.ReservedHeight += height*num + win.style().Spacing.Y*num }
[ "func", "(", "win", "*", "Window", ")", "LayoutReserveRowScaled", "(", "height", "int", ",", "num", "int", ")", "{", "win", ".", "layout", ".", "ReservedHeight", "+=", "height", "*", "num", "+", "win", ".", "style", "(", ")", ".", "Spacing", ".", "Y"...
// Like LayoutReserveRow but with a scaled height.
[ "Like", "LayoutReserveRow", "but", "with", "a", "scaled", "height", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L1000-L1002
train
aarzilli/nucular
nucular.go
RowScaled
func (win *Window) RowScaled(height int) *rowConstructor { win.rowCtor.height = height return &win.rowCtor }
go
func (win *Window) RowScaled(height int) *rowConstructor { win.rowCtor.height = height return &win.rowCtor }
[ "func", "(", "win", "*", "Window", ")", "RowScaled", "(", "height", "int", ")", "*", "rowConstructor", "{", "win", ".", "rowCtor", ".", "height", "=", "height", "\n", "return", "&", "win", ".", "rowCtor", "\n", "}" ]
// Same as Row but with scaled units.
[ "Same", "as", "Row", "but", "with", "scaled", "units", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L1014-L1017
train
aarzilli/nucular
nucular.go
Dynamic
func (ctr *rowConstructor) Dynamic(cols int) { rowLayoutCtr(ctr.win, ctr.height, cols, 0) }
go
func (ctr *rowConstructor) Dynamic(cols int) { rowLayoutCtr(ctr.win, ctr.height, cols, 0) }
[ "func", "(", "ctr", "*", "rowConstructor", ")", "Dynamic", "(", "cols", "int", ")", "{", "rowLayoutCtr", "(", "ctr", ".", "win", ",", "ctr", ".", "height", ",", "cols", ",", "0", ")", "\n", "}" ]
// Starts new row that has cols columns of equal width that automatically // resize to fill the available space.
[ "Starts", "new", "row", "that", "has", "cols", "columns", "of", "equal", "width", "that", "automatically", "resize", "to", "fill", "the", "available", "space", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L1026-L1028
train
aarzilli/nucular
nucular.go
Ratio
func (ctr *rowConstructor) Ratio(ratio ...float64) { layout := ctr.win.layout panelLayout(ctr.win.ctx, ctr.win, ctr.height, len(ratio), 0) /* calculate width of undefined widget ratios */ r := 0.0 n_undef := 0 layout.Row.Ratio = ratio for i := range ratio { if ratio[i] < 0.0 { n_undef++ } else { r += ratio[i] } } r = saturateFloat(1.0 - r) layout.Row.Type = layoutDynamic layout.Row.ItemWidth = 0 layout.Row.ItemRatio = 0.0 if r > 0 && n_undef > 0 { layout.Row.ItemRatio = (r / float64(n_undef)) } layout.Row.ItemOffset = 0 layout.Row.Filled = 0 }
go
func (ctr *rowConstructor) Ratio(ratio ...float64) { layout := ctr.win.layout panelLayout(ctr.win.ctx, ctr.win, ctr.height, len(ratio), 0) /* calculate width of undefined widget ratios */ r := 0.0 n_undef := 0 layout.Row.Ratio = ratio for i := range ratio { if ratio[i] < 0.0 { n_undef++ } else { r += ratio[i] } } r = saturateFloat(1.0 - r) layout.Row.Type = layoutDynamic layout.Row.ItemWidth = 0 layout.Row.ItemRatio = 0.0 if r > 0 && n_undef > 0 { layout.Row.ItemRatio = (r / float64(n_undef)) } layout.Row.ItemOffset = 0 layout.Row.Filled = 0 }
[ "func", "(", "ctr", "*", "rowConstructor", ")", "Ratio", "(", "ratio", "...", "float64", ")", "{", "layout", ":=", "ctr", ".", "win", ".", "layout", "\n", "panelLayout", "(", "ctr", ".", "win", ".", "ctx", ",", "ctr", ".", "win", ",", "ctr", ".", ...
// Starts new row with a fixed number of columns of width proportional // to the size of the window.
[ "Starts", "new", "row", "with", "a", "fixed", "number", "of", "columns", "of", "width", "proportional", "to", "the", "size", "of", "the", "window", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L1032-L1059
train
aarzilli/nucular
nucular.go
StaticScaled
func (ctr *rowConstructor) StaticScaled(width ...int) { layout := ctr.win.layout cnt := 0 if len(width) == 0 { if len(layout.Row.WidthArr) == 0 { cnt = layout.Cnt } else { cnt = ctr.win.lastLayoutCnt + 1 ctr.win.lastLayoutCnt = cnt } } panelLayout(ctr.win.ctx, ctr.win, ctr.height, len(width), cnt) ctr.win.staticZeros(width) layout.Row.WidthArr = width layout.Row.Type = layoutStatic layout.Row.ItemWidth = 0 layout.Row.ItemRatio = 0.0 layout.Row.ItemOffset = 0 layout.Row.Filled = 0 }
go
func (ctr *rowConstructor) StaticScaled(width ...int) { layout := ctr.win.layout cnt := 0 if len(width) == 0 { if len(layout.Row.WidthArr) == 0 { cnt = layout.Cnt } else { cnt = ctr.win.lastLayoutCnt + 1 ctr.win.lastLayoutCnt = cnt } } panelLayout(ctr.win.ctx, ctr.win, ctr.height, len(width), cnt) ctr.win.staticZeros(width) layout.Row.WidthArr = width layout.Row.Type = layoutStatic layout.Row.ItemWidth = 0 layout.Row.ItemRatio = 0.0 layout.Row.ItemOffset = 0 layout.Row.Filled = 0 }
[ "func", "(", "ctr", "*", "rowConstructor", ")", "StaticScaled", "(", "width", "...", "int", ")", "{", "layout", ":=", "ctr", ".", "win", ".", "layout", "\n", "cnt", ":=", "0", "\n", "if", "len", "(", "width", ")", "==", "0", "{", "if", "len", "("...
// Like Static but with scaled sizes.
[ "Like", "Static", "but", "with", "scaled", "sizes", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L1106-L1130
train
aarzilli/nucular
nucular.go
LayoutResetStatic
func (win *Window) LayoutResetStatic(width ...int) { for i := range width { width[i] = win.ctx.scale(width[i]) } win.LayoutResetStaticScaled(width...) }
go
func (win *Window) LayoutResetStatic(width ...int) { for i := range width { width[i] = win.ctx.scale(width[i]) } win.LayoutResetStaticScaled(width...) }
[ "func", "(", "win", "*", "Window", ")", "LayoutResetStatic", "(", "width", "...", "int", ")", "{", "for", "i", ":=", "range", "width", "{", "width", "[", "i", "]", "=", "win", ".", "ctx", ".", "scale", "(", "width", "[", "i", "]", ")", "\n", "}...
// Reset static row
[ "Reset", "static", "row" ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L1133-L1138
train
aarzilli/nucular
nucular.go
SpaceBeginRatio
func (ctr *rowConstructor) SpaceBeginRatio(widget_count int) { layout := ctr.win.layout panelLayout(ctr.win.ctx, ctr.win, ctr.height, widget_count, 0) layout.Row.Type = layoutDynamicFree layout.Row.Ratio = nil layout.Row.ItemWidth = 0 layout.Row.ItemRatio = 0.0 layout.Row.ItemOffset = 0 layout.Row.Filled = 0 }
go
func (ctr *rowConstructor) SpaceBeginRatio(widget_count int) { layout := ctr.win.layout panelLayout(ctr.win.ctx, ctr.win, ctr.height, widget_count, 0) layout.Row.Type = layoutDynamicFree layout.Row.Ratio = nil layout.Row.ItemWidth = 0 layout.Row.ItemRatio = 0.0 layout.Row.ItemOffset = 0 layout.Row.Filled = 0 }
[ "func", "(", "ctr", "*", "rowConstructor", ")", "SpaceBeginRatio", "(", "widget_count", "int", ")", "{", "layout", ":=", "ctr", ".", "win", ".", "layout", "\n", "panelLayout", "(", "ctr", ".", "win", ".", "ctx", ",", "ctr", ".", "win", ",", "ctr", "....
// Starts new row that will contain widget_count widgets. // The size and position of widgets inside this row will be specified // by callling LayoutSpacePushRatio.
[ "Starts", "new", "row", "that", "will", "contain", "widget_count", "widgets", ".", "The", "size", "and", "position", "of", "widgets", "inside", "this", "row", "will", "be", "specified", "by", "callling", "LayoutSpacePushRatio", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L1184-L1194
train
aarzilli/nucular
nucular.go
LayoutSetWidth
func (win *Window) LayoutSetWidth(width int) { layout := win.layout if layout.Row.Type != layoutStatic || len(layout.Row.WidthArr) > 0 { panic(WrongLayoutErr) } layout.Row.Index2++ layout.Row.CalcMaxWidth = false layout.Row.ItemWidth = win.ctx.scale(width) }
go
func (win *Window) LayoutSetWidth(width int) { layout := win.layout if layout.Row.Type != layoutStatic || len(layout.Row.WidthArr) > 0 { panic(WrongLayoutErr) } layout.Row.Index2++ layout.Row.CalcMaxWidth = false layout.Row.ItemWidth = win.ctx.scale(width) }
[ "func", "(", "win", "*", "Window", ")", "LayoutSetWidth", "(", "width", "int", ")", "{", "layout", ":=", "win", ".", "layout", "\n", "if", "layout", ".", "Row", ".", "Type", "!=", "layoutStatic", "||", "len", "(", "layout", ".", "Row", ".", "WidthArr...
// LayoutSetWidth adds a new column with the specified width to a static // layout.
[ "LayoutSetWidth", "adds", "a", "new", "column", "with", "the", "specified", "width", "to", "a", "static", "layout", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L1198-L1206
train
aarzilli/nucular
nucular.go
LayoutFitWidth
func (win *Window) LayoutFitWidth(id int, minwidth int) { layout := win.layout if layout.Row.Type != layoutStatic || len(layout.Row.WidthArr) > 0 { panic(WrongLayoutErr) } if win.adjust == nil { win.adjust = make(map[int]map[int]*adjustCol) } adjust, ok := win.adjust[layout.Cnt] if !ok { adjust = make(map[int]*adjustCol) win.adjust[layout.Cnt] = adjust } col, ok := adjust[layout.Row.Index2] if !ok || col.id != id || col.font != win.ctx.Style.Font { if !ok { col = &adjustCol{id: id, width: minwidth} win.adjust[layout.Cnt][layout.Row.Index2] = col } col.id = id col.font = win.ctx.Style.Font col.width = minwidth col.first = true win.ctx.trashFrame = true win.LayoutSetWidth(minwidth) layout.Row.CalcMaxWidth = true return } win.LayoutSetWidthScaled(col.width) layout.Row.CalcMaxWidth = col.first }
go
func (win *Window) LayoutFitWidth(id int, minwidth int) { layout := win.layout if layout.Row.Type != layoutStatic || len(layout.Row.WidthArr) > 0 { panic(WrongLayoutErr) } if win.adjust == nil { win.adjust = make(map[int]map[int]*adjustCol) } adjust, ok := win.adjust[layout.Cnt] if !ok { adjust = make(map[int]*adjustCol) win.adjust[layout.Cnt] = adjust } col, ok := adjust[layout.Row.Index2] if !ok || col.id != id || col.font != win.ctx.Style.Font { if !ok { col = &adjustCol{id: id, width: minwidth} win.adjust[layout.Cnt][layout.Row.Index2] = col } col.id = id col.font = win.ctx.Style.Font col.width = minwidth col.first = true win.ctx.trashFrame = true win.LayoutSetWidth(minwidth) layout.Row.CalcMaxWidth = true return } win.LayoutSetWidthScaled(col.width) layout.Row.CalcMaxWidth = col.first }
[ "func", "(", "win", "*", "Window", ")", "LayoutFitWidth", "(", "id", "int", ",", "minwidth", "int", ")", "{", "layout", ":=", "win", ".", "layout", "\n", "if", "layout", ".", "Row", ".", "Type", "!=", "layoutStatic", "||", "len", "(", "layout", ".", ...
// LayoutFitWidth adds a new column to a static layout. // The width of the column will be large enough to fit the largest widget // exactly. The largest widget will only be calculated once per id, if the // dataset changes the id should change.
[ "LayoutFitWidth", "adds", "a", "new", "column", "to", "a", "static", "layout", ".", "The", "width", "of", "the", "column", "will", "be", "large", "enough", "to", "fit", "the", "largest", "widget", "exactly", ".", "The", "largest", "widget", "will", "only",...
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L1224-L1254
train
aarzilli/nucular
nucular.go
LayoutSpacePushScaled
func (win *Window) LayoutSpacePushScaled(rect rect.Rect) { if win.layout.Row.Type != layoutStaticFree { panic(WrongLayoutErr) } win.layout.Row.Item = rect }
go
func (win *Window) LayoutSpacePushScaled(rect rect.Rect) { if win.layout.Row.Type != layoutStaticFree { panic(WrongLayoutErr) } win.layout.Row.Item = rect }
[ "func", "(", "win", "*", "Window", ")", "LayoutSpacePushScaled", "(", "rect", "rect", ".", "Rect", ")", "{", "if", "win", ".", "layout", ".", "Row", ".", "Type", "!=", "layoutStaticFree", "{", "panic", "(", "WrongLayoutErr", ")", "\n", "}", "\n", "win"...
// Like LayoutSpacePush but with scaled units
[ "Like", "LayoutSpacePush", "but", "with", "scaled", "units" ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L1271-L1276
train
aarzilli/nucular
nucular.go
WidgetBounds
func (win *Window) WidgetBounds() rect.Rect { var bounds rect.Rect win.layoutPeek(&bounds) return bounds }
go
func (win *Window) WidgetBounds() rect.Rect { var bounds rect.Rect win.layoutPeek(&bounds) return bounds }
[ "func", "(", "win", "*", "Window", ")", "WidgetBounds", "(", ")", "rect", ".", "Rect", "{", "var", "bounds", "rect", ".", "Rect", "\n", "win", ".", "layoutPeek", "(", "&", "bounds", ")", "\n", "return", "bounds", "\n", "}" ]
// Returns the position and size of the next widget that will be // added to the current row. // Note that the return value is in scaled units.
[ "Returns", "the", "position", "and", "size", "of", "the", "next", "widget", "that", "will", "be", "added", "to", "the", "current", "row", ".", "Note", "that", "the", "return", "value", "is", "in", "scaled", "units", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L1307-L1311
train
aarzilli/nucular
nucular.go
LayoutAvailableHeight
func (win *Window) LayoutAvailableHeight() int { return win.layout.Clip.H - (win.layout.AtY - win.layout.Bounds.Y) - win.style().Spacing.Y - win.layout.Row.Height }
go
func (win *Window) LayoutAvailableHeight() int { return win.layout.Clip.H - (win.layout.AtY - win.layout.Bounds.Y) - win.style().Spacing.Y - win.layout.Row.Height }
[ "func", "(", "win", "*", "Window", ")", "LayoutAvailableHeight", "(", ")", "int", "{", "return", "win", ".", "layout", ".", "Clip", ".", "H", "-", "(", "win", ".", "layout", ".", "AtY", "-", "win", ".", "layout", ".", "Bounds", ".", "Y", ")", "-"...
// Returns remaining available height of win in scaled units.
[ "Returns", "remaining", "available", "height", "of", "win", "in", "scaled", "units", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L1314-L1316
train
aarzilli/nucular
nucular.go
TreePushNamed
func (win *Window) TreePushNamed(type_ TreeType, name, title string, initial_open bool) bool { labelBounds, _, ok := win.TreePushCustom(type_, name, initial_open) style := win.style() z := &win.ctx.Style out := &win.cmds var text textWidget if type_ == TreeTab { var background *nstyle.Item = &z.Tab.Background if background.Type == nstyle.ItemImage { text.Background = color.RGBA{0, 0, 0, 0} } else { text.Background = background.Data.Color } } else { text.Background = style.Background } text.Text = z.Tab.Text widgetText(out, labelBounds, title, &text, "LC", z.Font) return ok }
go
func (win *Window) TreePushNamed(type_ TreeType, name, title string, initial_open bool) bool { labelBounds, _, ok := win.TreePushCustom(type_, name, initial_open) style := win.style() z := &win.ctx.Style out := &win.cmds var text textWidget if type_ == TreeTab { var background *nstyle.Item = &z.Tab.Background if background.Type == nstyle.ItemImage { text.Background = color.RGBA{0, 0, 0, 0} } else { text.Background = background.Data.Color } } else { text.Background = style.Background } text.Text = z.Tab.Text widgetText(out, labelBounds, title, &text, "LC", z.Font) return ok }
[ "func", "(", "win", "*", "Window", ")", "TreePushNamed", "(", "type_", "TreeType", ",", "name", ",", "title", "string", ",", "initial_open", "bool", ")", "bool", "{", "labelBounds", ",", "_", ",", "ok", ":=", "win", ".", "TreePushCustom", "(", "type_", ...
// Creates a new collapsable section inside win. Returns true // when the section is open. Widgets that are inside this collapsable // section should be added to win only when this function returns true. // Once you are done adding elements to the collapsable section // call TreePop. // Initial_open will determine whether this collapsable section // will be initially open. // Type_ will determine the style of this collapsable section.
[ "Creates", "a", "new", "collapsable", "section", "inside", "win", ".", "Returns", "true", "when", "the", "section", "is", "open", ".", "Widgets", "that", "are", "inside", "this", "collapsable", "section", "should", "be", "added", "to", "win", "only", "when",...
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L1362-L1385
train
aarzilli/nucular
nucular.go
TreeIsOpen
func (win *Window) TreeIsOpen(name string) bool { node := win.curNode.Children[name] if node != nil { return node.Open } return false }
go
func (win *Window) TreeIsOpen(name string) bool { node := win.curNode.Children[name] if node != nil { return node.Open } return false }
[ "func", "(", "win", "*", "Window", ")", "TreeIsOpen", "(", "name", "string", ")", "bool", "{", "node", ":=", "win", ".", "curNode", ".", "Children", "[", "name", "]", "\n", "if", "node", "!=", "nil", "{", "return", "node", ".", "Open", "\n", "}", ...
// Returns true if the specified node is open
[ "Returns", "true", "if", "the", "specified", "node", "is", "open" ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L1492-L1498
train
aarzilli/nucular
nucular.go
TreePop
func (win *Window) TreePop() { layout := win.layout panel_padding := win.style().Padding layout.AtX -= panel_padding.X + win.ctx.Style.Tab.Indent layout.Width += panel_padding.X + win.ctx.Style.Tab.Indent if layout.Row.TreeDepth == 0 { panic("TreePop called without opened tree nodes") } win.curNode = win.curNode.Parent layout.Row.TreeDepth-- }
go
func (win *Window) TreePop() { layout := win.layout panel_padding := win.style().Padding layout.AtX -= panel_padding.X + win.ctx.Style.Tab.Indent layout.Width += panel_padding.X + win.ctx.Style.Tab.Indent if layout.Row.TreeDepth == 0 { panic("TreePop called without opened tree nodes") } win.curNode = win.curNode.Parent layout.Row.TreeDepth-- }
[ "func", "(", "win", "*", "Window", ")", "TreePop", "(", ")", "{", "layout", ":=", "win", ".", "layout", "\n", "panel_padding", ":=", "win", ".", "style", "(", ")", ".", "Padding", "\n", "layout", ".", "AtX", "-=", "panel_padding", ".", "X", "+", "w...
// TreePop signals that the program is done adding elements to the // current collapsable section.
[ "TreePop", "signals", "that", "the", "program", "is", "done", "adding", "elements", "to", "the", "current", "collapsable", "section", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L1502-L1512
train
aarzilli/nucular
nucular.go
LabelWrapColored
func (win *Window) LabelWrapColored(str string, color color.RGBA) { var bounds rect.Rect var text textWidget style := &win.ctx.Style panelAllocSpace(&bounds, win) item_padding := style.Text.Padding text.Padding.X = item_padding.X text.Padding.Y = item_padding.Y text.Background = win.style().Background text.Text = color win.widgets.Add(nstyle.WidgetStateInactive, bounds) widgetTextWrap(&win.cmds, bounds, []rune(str), &text, win.ctx.Style.Font) }
go
func (win *Window) LabelWrapColored(str string, color color.RGBA) { var bounds rect.Rect var text textWidget style := &win.ctx.Style panelAllocSpace(&bounds, win) item_padding := style.Text.Padding text.Padding.X = item_padding.X text.Padding.Y = item_padding.Y text.Background = win.style().Background text.Text = color win.widgets.Add(nstyle.WidgetStateInactive, bounds) widgetTextWrap(&win.cmds, bounds, []rune(str), &text, win.ctx.Style.Font) }
[ "func", "(", "win", "*", "Window", ")", "LabelWrapColored", "(", "str", "string", ",", "color", "color", ".", "RGBA", ")", "{", "var", "bounds", "rect", ".", "Rect", "\n", "var", "text", "textWidget", "\n", "style", ":=", "&", "win", ".", "ctx", ".",...
// LabelWrapColored draws a text label with the specified background // color autowrappping the text.
[ "LabelWrapColored", "draws", "a", "text", "label", "with", "the", "specified", "background", "color", "autowrappping", "the", "text", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L1541-L1555
train
aarzilli/nucular
nucular.go
Label
func (win *Window) Label(str string, alignment label.Align) { win.LabelColored(str, alignment, win.ctx.Style.Text.Color) }
go
func (win *Window) Label(str string, alignment label.Align) { win.LabelColored(str, alignment, win.ctx.Style.Text.Color) }
[ "func", "(", "win", "*", "Window", ")", "Label", "(", "str", "string", ",", "alignment", "label", ".", "Align", ")", "{", "win", ".", "LabelColored", "(", "str", ",", "alignment", ",", "win", ".", "ctx", ".", "Style", ".", "Text", ".", "Color", ")"...
// Label draws a text label.
[ "Label", "draws", "a", "text", "label", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L1558-L1560
train
aarzilli/nucular
nucular.go
LabelWrap
func (win *Window) LabelWrap(str string) { win.LabelWrapColored(str, win.ctx.Style.Text.Color) }
go
func (win *Window) LabelWrap(str string) { win.LabelWrapColored(str, win.ctx.Style.Text.Color) }
[ "func", "(", "win", "*", "Window", ")", "LabelWrap", "(", "str", "string", ")", "{", "win", ".", "LabelWrapColored", "(", "str", ",", "win", ".", "ctx", ".", "Style", ".", "Text", ".", "Color", ")", "\n", "}" ]
// LabelWrap draws a text label, autowrapping its contents.
[ "LabelWrap", "draws", "a", "text", "label", "autowrapping", "its", "contents", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L1563-L1565
train
aarzilli/nucular
nucular.go
Image
func (win *Window) Image(img *image.RGBA) { s, bounds, fitting := win.widget() if fitting != nil { fitting(img.Bounds().Dx()) } if !s { return } win.widgets.Add(nstyle.WidgetStateInactive, bounds) win.cmds.DrawImage(bounds, img) }
go
func (win *Window) Image(img *image.RGBA) { s, bounds, fitting := win.widget() if fitting != nil { fitting(img.Bounds().Dx()) } if !s { return } win.widgets.Add(nstyle.WidgetStateInactive, bounds) win.cmds.DrawImage(bounds, img) }
[ "func", "(", "win", "*", "Window", ")", "Image", "(", "img", "*", "image", ".", "RGBA", ")", "{", "s", ",", "bounds", ",", "fitting", ":=", "win", ".", "widget", "(", ")", "\n", "if", "fitting", "!=", "nil", "{", "fitting", "(", "img", ".", "Bo...
// Image draws an image.
[ "Image", "draws", "an", "image", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L1568-L1578
train
aarzilli/nucular
nucular.go
Spacing
func (win *Window) Spacing(cols int) { for i := 0; i < cols; i++ { win.widget() } }
go
func (win *Window) Spacing(cols int) { for i := 0; i < cols; i++ { win.widget() } }
[ "func", "(", "win", "*", "Window", ")", "Spacing", "(", "cols", "int", ")", "{", "for", "i", ":=", "0", ";", "i", "<", "cols", ";", "i", "++", "{", "win", ".", "widget", "(", ")", "\n", "}", "\n", "}" ]
// Spacing adds empty space
[ "Spacing", "adds", "empty", "space" ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L1581-L1585
train
aarzilli/nucular
nucular.go
CustomState
func (win *Window) CustomState() nstyle.WidgetStates { bounds := win.WidgetBounds() s := true if !win.layout.Clip.Intersect(&bounds) { s = false } ws := win.widgets.PrevState(bounds) basicWidgetStateControl(&ws, win.inputMaybe(s), bounds) return ws }
go
func (win *Window) CustomState() nstyle.WidgetStates { bounds := win.WidgetBounds() s := true if !win.layout.Clip.Intersect(&bounds) { s = false } ws := win.widgets.PrevState(bounds) basicWidgetStateControl(&ws, win.inputMaybe(s), bounds) return ws }
[ "func", "(", "win", "*", "Window", ")", "CustomState", "(", ")", "nstyle", ".", "WidgetStates", "{", "bounds", ":=", "win", ".", "WidgetBounds", "(", ")", "\n", "s", ":=", "true", "\n", "if", "!", "win", ".", "layout", ".", "Clip", ".", "Intersect", ...
// CustomState returns the widget state of a custom widget.
[ "CustomState", "returns", "the", "widget", "state", "of", "a", "custom", "widget", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L1588-L1598
train
aarzilli/nucular
nucular.go
Custom
func (win *Window) Custom(state nstyle.WidgetStates) (bounds rect.Rect, out *command.Buffer) { var s bool if s, bounds, _ = win.widget(); !s { return } prevstate := win.widgets.PrevState(bounds) exitstate := basicWidgetStateControl(&prevstate, win.inputMaybe(s), bounds) if state != nstyle.WidgetStateActive { state = exitstate } win.widgets.Add(state, bounds) return bounds, &win.cmds }
go
func (win *Window) Custom(state nstyle.WidgetStates) (bounds rect.Rect, out *command.Buffer) { var s bool if s, bounds, _ = win.widget(); !s { return } prevstate := win.widgets.PrevState(bounds) exitstate := basicWidgetStateControl(&prevstate, win.inputMaybe(s), bounds) if state != nstyle.WidgetStateActive { state = exitstate } win.widgets.Add(state, bounds) return bounds, &win.cmds }
[ "func", "(", "win", "*", "Window", ")", "Custom", "(", "state", "nstyle", ".", "WidgetStates", ")", "(", "bounds", "rect", ".", "Rect", ",", "out", "*", "command", ".", "Buffer", ")", "{", "var", "s", "bool", "\n", "if", "s", ",", "bounds", ",", ...
// Custom adds a custom widget.
[ "Custom", "adds", "a", "custom", "widget", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L1601-L1614
train
aarzilli/nucular
nucular.go
Button
func (win *Window) Button(lbl label.Label, repeat bool) bool { style := &win.ctx.Style state, bounds, fitting := win.widget() if fitting != nil { buttonWidth(lbl, &style.Button, style.Font) } if !state { return false } in := win.inputMaybe(state) return doButton(win, lbl, bounds, &style.Button, in, repeat) }
go
func (win *Window) Button(lbl label.Label, repeat bool) bool { style := &win.ctx.Style state, bounds, fitting := win.widget() if fitting != nil { buttonWidth(lbl, &style.Button, style.Font) } if !state { return false } in := win.inputMaybe(state) return doButton(win, lbl, bounds, &style.Button, in, repeat) }
[ "func", "(", "win", "*", "Window", ")", "Button", "(", "lbl", "label", ".", "Label", ",", "repeat", "bool", ")", "bool", "{", "style", ":=", "&", "win", ".", "ctx", ".", "Style", "\n", "state", ",", "bounds", ",", "fitting", ":=", "win", ".", "wi...
// Button adds a button
[ "Button", "adds", "a", "button" ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L1774-L1785
train
aarzilli/nucular
nucular.go
SelectableLabel
func (win *Window) SelectableLabel(str string, align label.Align, value *bool) bool { style := &win.ctx.Style state, bounds, fitting := win.widget() if fitting != nil { fitting(selectableWidth(str, &style.Selectable, style.Font)) } if !state { return false } in := win.inputMaybe(state) return doSelectable(win, bounds, str, align, value, &style.Selectable, in) }
go
func (win *Window) SelectableLabel(str string, align label.Align, value *bool) bool { style := &win.ctx.Style state, bounds, fitting := win.widget() if fitting != nil { fitting(selectableWidth(str, &style.Selectable, style.Font)) } if !state { return false } in := win.inputMaybe(state) return doSelectable(win, bounds, str, align, value, &style.Selectable, in) }
[ "func", "(", "win", "*", "Window", ")", "SelectableLabel", "(", "str", "string", ",", "align", "label", ".", "Align", ",", "value", "*", "bool", ")", "bool", "{", "style", ":=", "&", "win", ".", "ctx", ".", "Style", "\n", "state", ",", "bounds", ",...
// SelectableLabel adds a selectable label. Value is a pointer // to a flag that will be changed to reflect the selected state of // this label. // Returns true when the label is clicked.
[ "SelectableLabel", "adds", "a", "selectable", "label", ".", "Value", "is", "a", "pointer", "to", "a", "flag", "that", "will", "be", "changed", "to", "reflect", "the", "selected", "state", "of", "this", "label", ".", "Returns", "true", "when", "the", "label...
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L1827-L1838
train
aarzilli/nucular
nucular.go
OptionText
func (win *Window) OptionText(text string, is_active bool) bool { style := &win.ctx.Style state, bounds, fitting := win.widget() if fitting != nil { fitting(toggleWidth(text, toggleOption, &style.Option, style.Font)) } if !state { return false } in := win.inputMaybe(state) is_active = doToggle(win, bounds, is_active, text, toggleOption, &style.Option, in, style.Font) return is_active }
go
func (win *Window) OptionText(text string, is_active bool) bool { style := &win.ctx.Style state, bounds, fitting := win.widget() if fitting != nil { fitting(toggleWidth(text, toggleOption, &style.Option, style.Font)) } if !state { return false } in := win.inputMaybe(state) is_active = doToggle(win, bounds, is_active, text, toggleOption, &style.Option, in, style.Font) return is_active }
[ "func", "(", "win", "*", "Window", ")", "OptionText", "(", "text", "string", ",", "is_active", "bool", ")", "bool", "{", "style", ":=", "&", "win", ".", "ctx", ".", "Style", "\n", "state", ",", "bounds", ",", "fitting", ":=", "win", ".", "widget", ...
// OptionText adds a radio button to win. If is_active is true the // radio button will be drawn selected. Returns true when the button // is clicked once. // You are responsible for ensuring that only one radio button is selected at once.
[ "OptionText", "adds", "a", "radio", "button", "to", "win", ".", "If", "is_active", "is", "true", "the", "radio", "button", "will", "be", "drawn", "selected", ".", "Returns", "true", "when", "the", "button", "is", "clicked", "once", ".", "You", "are", "re...
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L2178-L2190
train
aarzilli/nucular
nucular.go
CheckboxText
func (win *Window) CheckboxText(text string, active *bool) bool { state, bounds, fitting := win.widget() if fitting != nil { fitting(toggleWidth(text, toggleCheck, &win.ctx.Style.Checkbox, win.ctx.Style.Font)) } if !state { return false } in := win.inputMaybe(state) old_active := *active *active = doToggle(win, bounds, *active, text, toggleCheck, &win.ctx.Style.Checkbox, in, win.ctx.Style.Font) return *active != old_active }
go
func (win *Window) CheckboxText(text string, active *bool) bool { state, bounds, fitting := win.widget() if fitting != nil { fitting(toggleWidth(text, toggleCheck, &win.ctx.Style.Checkbox, win.ctx.Style.Font)) } if !state { return false } in := win.inputMaybe(state) old_active := *active *active = doToggle(win, bounds, *active, text, toggleCheck, &win.ctx.Style.Checkbox, in, win.ctx.Style.Font) return *active != old_active }
[ "func", "(", "win", "*", "Window", ")", "CheckboxText", "(", "text", "string", ",", "active", "*", "bool", ")", "bool", "{", "state", ",", "bounds", ",", "fitting", ":=", "win", ".", "widget", "(", ")", "\n", "if", "fitting", "!=", "nil", "{", "fit...
// CheckboxText adds a checkbox button to win. Active will contain // the checkbox value. // Returns true when value changes.
[ "CheckboxText", "adds", "a", "checkbox", "button", "to", "win", ".", "Active", "will", "contain", "the", "checkbox", "value", ".", "Returns", "true", "when", "value", "changes", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L2195-L2207
train
aarzilli/nucular
nucular.go
SliderFloat
func (win *Window) SliderFloat(min_value float64, value *float64, max_value float64, value_step float64) bool { style := &win.ctx.Style state, bounds, _ := win.widget() if !state { return false } in := win.inputMaybe(state) old_value := *value *value = doSlider(win, bounds, min_value, old_value, max_value, value_step, &style.Slider, in) return old_value > *value || old_value < *value }
go
func (win *Window) SliderFloat(min_value float64, value *float64, max_value float64, value_step float64) bool { style := &win.ctx.Style state, bounds, _ := win.widget() if !state { return false } in := win.inputMaybe(state) old_value := *value *value = doSlider(win, bounds, min_value, old_value, max_value, value_step, &style.Slider, in) return old_value > *value || old_value < *value }
[ "func", "(", "win", "*", "Window", ")", "SliderFloat", "(", "min_value", "float64", ",", "value", "*", "float64", ",", "max_value", "float64", ",", "value_step", "float64", ")", "bool", "{", "style", ":=", "&", "win", ".", "ctx", ".", "Style", "\n", "s...
// Adds a slider with a floating point value to win. // Returns true when the slider's value is changed.
[ "Adds", "a", "slider", "with", "a", "floating", "point", "value", "to", "win", ".", "Returns", "true", "when", "the", "slider", "s", "value", "is", "changed", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L2301-L2312
train
aarzilli/nucular
nucular.go
SliderInt
func (win *Window) SliderInt(min int, val *int, max int, step int) bool { value := float64(*val) ret := win.SliderFloat(float64(min), &value, float64(max), float64(step)) *val = int(value) return ret }
go
func (win *Window) SliderInt(min int, val *int, max int, step int) bool { value := float64(*val) ret := win.SliderFloat(float64(min), &value, float64(max), float64(step)) *val = int(value) return ret }
[ "func", "(", "win", "*", "Window", ")", "SliderInt", "(", "min", "int", ",", "val", "*", "int", ",", "max", "int", ",", "step", "int", ")", "bool", "{", "value", ":=", "float64", "(", "*", "val", ")", "\n", "ret", ":=", "win", ".", "SliderFloat",...
// Adds a slider with an integer value to win. // Returns true when the slider's value changes.
[ "Adds", "a", "slider", "with", "an", "integer", "value", "to", "win", ".", "Returns", "true", "when", "the", "slider", "s", "value", "changes", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L2316-L2321
train
aarzilli/nucular
nucular.go
Progress
func (win *Window) Progress(cur *int, maxval int, is_modifiable bool) bool { style := &win.ctx.Style state, bounds, _ := win.widget() if !state { return false } in := win.inputMaybe(state) old_value := *cur *cur = doProgress(win, bounds, *cur, maxval, is_modifiable, &style.Progress, in) return *cur != old_value }
go
func (win *Window) Progress(cur *int, maxval int, is_modifiable bool) bool { style := &win.ctx.Style state, bounds, _ := win.widget() if !state { return false } in := win.inputMaybe(state) old_value := *cur *cur = doProgress(win, bounds, *cur, maxval, is_modifiable, &style.Progress, in) return *cur != old_value }
[ "func", "(", "win", "*", "Window", ")", "Progress", "(", "cur", "*", "int", ",", "maxval", "int", ",", "is_modifiable", "bool", ")", "bool", "{", "style", ":=", "&", "win", ".", "ctx", ".", "Style", "\n", "state", ",", "bounds", ",", "_", ":=", "...
// Adds a progress bar to win. if is_modifiable is true the progress // bar will be user modifiable through click-and-drag. // Returns true when the progress bar values is modified.
[ "Adds", "a", "progress", "bar", "to", "win", ".", "if", "is_modifiable", "is", "true", "the", "progress", "bar", "will", "be", "user", "modifiable", "through", "click", "-", "and", "-", "drag", ".", "Returns", "true", "when", "the", "progress", "bar", "v...
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L2378-L2389
train
aarzilli/nucular
nucular.go
PropertyInt
func (win *Window) PropertyInt(name string, min int, val *int, max, step, inc_per_pixel int) (changed bool) { s, bounds, fitting := win.widget() if fitting != nil { fitting(propertyWidth(max, &win.ctx.Style.Property, win.ctx.Style.Font)) } if !s { return } in := win.inputMaybe(s) text := strconv.Itoa(*val) ret, delta, ed := win.doProperty(bounds, name, text, FilterDecimal, in) switch ret { case doPropertyDec: *val -= step case doPropertyInc: *val += step case doPropertyDrag: *val += delta * inc_per_pixel case doPropertySet: *val, _ = strconv.Atoi(string(ed.Buffer)) } changed = ret != doPropertyStay if changed { *val = clampInt(min, *val, max) } return }
go
func (win *Window) PropertyInt(name string, min int, val *int, max, step, inc_per_pixel int) (changed bool) { s, bounds, fitting := win.widget() if fitting != nil { fitting(propertyWidth(max, &win.ctx.Style.Property, win.ctx.Style.Font)) } if !s { return } in := win.inputMaybe(s) text := strconv.Itoa(*val) ret, delta, ed := win.doProperty(bounds, name, text, FilterDecimal, in) switch ret { case doPropertyDec: *val -= step case doPropertyInc: *val += step case doPropertyDrag: *val += delta * inc_per_pixel case doPropertySet: *val, _ = strconv.Atoi(string(ed.Buffer)) } changed = ret != doPropertyStay if changed { *val = clampInt(min, *val, max) } return }
[ "func", "(", "win", "*", "Window", ")", "PropertyInt", "(", "name", "string", ",", "min", "int", ",", "val", "*", "int", ",", "max", ",", "step", ",", "inc_per_pixel", "int", ")", "(", "changed", "bool", ")", "{", "s", ",", "bounds", ",", "fitting"...
// Same as PropertyFloat but with integer values.
[ "Same", "as", "PropertyFloat", "but", "with", "integer", "values", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L2599-L2625
train
aarzilli/nucular
nucular.go
MenuItem
func (win *Window) MenuItem(lbl label.Label) bool { style := &win.ctx.Style state, bounds := win.widgetFitting(style.ContextualButton.Padding) if !state { return false } if win.flags&windowHDynamic != 0 { w := FontWidth(style.Font, lbl.Text) + 2*style.ContextualButton.Padding.X if w > win.menuItemWidth { win.menuItemWidth = w } } in := win.inputMaybe(state) if doButton(win, lbl, bounds, &style.ContextualButton, in, false) { win.Close() return true } return false }
go
func (win *Window) MenuItem(lbl label.Label) bool { style := &win.ctx.Style state, bounds := win.widgetFitting(style.ContextualButton.Padding) if !state { return false } if win.flags&windowHDynamic != 0 { w := FontWidth(style.Font, lbl.Text) + 2*style.ContextualButton.Padding.X if w > win.menuItemWidth { win.menuItemWidth = w } } in := win.inputMaybe(state) if doButton(win, lbl, bounds, &style.ContextualButton, in, false) { win.Close() return true } return false }
[ "func", "(", "win", "*", "Window", ")", "MenuItem", "(", "lbl", "label", ".", "Label", ")", "bool", "{", "style", ":=", "&", "win", ".", "ctx", ".", "Style", "\n", "state", ",", "bounds", ":=", "win", ".", "widgetFitting", "(", "style", ".", "Conte...
// MenuItem adds a menu item
[ "MenuItem", "adds", "a", "menu", "item" ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L2745-L2766
train
aarzilli/nucular
nucular.go
TooltipOpen
func (win *Window) TooltipOpen(width int, scale bool, updateFn UpdateFn) { in := &win.ctx.Input if scale { width = win.ctx.scale(width) } var bounds rect.Rect bounds.W = width bounds.H = nk_null_rect.H bounds.X = (in.Mouse.Pos.X + 1) bounds.Y = (in.Mouse.Pos.Y + 1) win.ctx.popupOpen(tooltipWindowTitle, WindowDynamic|WindowNoScrollbar|windowTooltip, bounds, false, updateFn) }
go
func (win *Window) TooltipOpen(width int, scale bool, updateFn UpdateFn) { in := &win.ctx.Input if scale { width = win.ctx.scale(width) } var bounds rect.Rect bounds.W = width bounds.H = nk_null_rect.H bounds.X = (in.Mouse.Pos.X + 1) bounds.Y = (in.Mouse.Pos.Y + 1) win.ctx.popupOpen(tooltipWindowTitle, WindowDynamic|WindowNoScrollbar|windowTooltip, bounds, false, updateFn) }
[ "func", "(", "win", "*", "Window", ")", "TooltipOpen", "(", "width", "int", ",", "scale", "bool", ",", "updateFn", "UpdateFn", ")", "{", "in", ":=", "&", "win", ".", "ctx", ".", "Input", "\n", "if", "scale", "{", "width", "=", "win", ".", "ctx", ...
// Displays a tooltip window.
[ "Displays", "a", "tooltip", "window", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L2775-L2789
train
aarzilli/nucular
nucular.go
Tooltip
func (win *Window) Tooltip(text string) { if text == "" { return } /* fetch configuration data */ padding := win.ctx.Style.TooltipWindow.Padding item_spacing := win.ctx.Style.TooltipWindow.Spacing /* calculate size of the text and tooltip */ text_width := FontWidth(win.ctx.Style.Font, text) + win.ctx.scale(4*padding.X) + win.ctx.scale(2*item_spacing.X) text_height := FontHeight(win.ctx.Style.Font) win.TooltipOpen(text_width, false, func(tw *Window) { tw.RowScaled(text_height).Dynamic(1) tw.Label(text, "LC") }) }
go
func (win *Window) Tooltip(text string) { if text == "" { return } /* fetch configuration data */ padding := win.ctx.Style.TooltipWindow.Padding item_spacing := win.ctx.Style.TooltipWindow.Spacing /* calculate size of the text and tooltip */ text_width := FontWidth(win.ctx.Style.Font, text) + win.ctx.scale(4*padding.X) + win.ctx.scale(2*item_spacing.X) text_height := FontHeight(win.ctx.Style.Font) win.TooltipOpen(text_width, false, func(tw *Window) { tw.RowScaled(text_height).Dynamic(1) tw.Label(text, "LC") }) }
[ "func", "(", "win", "*", "Window", ")", "Tooltip", "(", "text", "string", ")", "{", "if", "text", "==", "\"\"", "{", "return", "\n", "}", "\n", "padding", ":=", "win", ".", "ctx", ".", "Style", ".", "TooltipWindow", ".", "Padding", "\n", "item_spacin...
// Shows a tooltip window containing the specified text.
[ "Shows", "a", "tooltip", "window", "containing", "the", "specified", "text", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L2792-L2809
train
aarzilli/nucular
nucular.go
ComboSimple
func (win *Window) ComboSimple(items []string, selected int, item_height int) int { if len(items) == 0 { return selected } item_height = win.ctx.scale(item_height) item_padding := win.ctx.Style.Combo.ButtonPadding.Y window_padding := win.style().Padding.Y max_height := (len(items)+1)*item_height + item_padding*3 + window_padding*2 if w := win.Combo(label.T(items[selected]), max_height, nil); w != nil { w.RowScaled(item_height).Dynamic(1) for i := range items { if w.MenuItem(label.TA(items[i], "LC")) { selected = i } } } return selected }
go
func (win *Window) ComboSimple(items []string, selected int, item_height int) int { if len(items) == 0 { return selected } item_height = win.ctx.scale(item_height) item_padding := win.ctx.Style.Combo.ButtonPadding.Y window_padding := win.style().Padding.Y max_height := (len(items)+1)*item_height + item_padding*3 + window_padding*2 if w := win.Combo(label.T(items[selected]), max_height, nil); w != nil { w.RowScaled(item_height).Dynamic(1) for i := range items { if w.MenuItem(label.TA(items[i], "LC")) { selected = i } } } return selected }
[ "func", "(", "win", "*", "Window", ")", "ComboSimple", "(", "items", "[", "]", "string", ",", "selected", "int", ",", "item_height", "int", ")", "int", "{", "if", "len", "(", "items", ")", "==", "0", "{", "return", "selected", "\n", "}", "\n", "ite...
// Adds a drop-down list to win. The contents are specified by items, // with selected being the index of the selected item.
[ "Adds", "a", "drop", "-", "down", "list", "to", "win", ".", "The", "contents", "are", "specified", "by", "items", "with", "selected", "being", "the", "index", "of", "the", "selected", "item", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L2869-L2887
train
aarzilli/nucular
nucular.go
GroupEnd
func (win *Window) GroupEnd() { panelEnd(win.ctx, win) win.parent.usingSub = false // immediate drawing win.parent.cmds.Commands = append(win.parent.cmds.Commands, win.cmds.Commands...) }
go
func (win *Window) GroupEnd() { panelEnd(win.ctx, win) win.parent.usingSub = false // immediate drawing win.parent.cmds.Commands = append(win.parent.cmds.Commands, win.cmds.Commands...) }
[ "func", "(", "win", "*", "Window", ")", "GroupEnd", "(", ")", "{", "panelEnd", "(", "win", ".", "ctx", ",", "win", ")", "\n", "win", ".", "parent", ".", "usingSub", "=", "false", "\n", "win", ".", "parent", ".", "cmds", ".", "Commands", "=", "app...
// Signals that you are done adding widgets to a group.
[ "Signals", "that", "you", "are", "done", "adding", "widgets", "to", "a", "group", "." ]
64ec1eba91814ebb417978927206070dd1fc44e1
https://github.com/aarzilli/nucular/blob/64ec1eba91814ebb417978927206070dd1fc44e1/nucular.go#L2989-L2995
train
goadapp/goad
lambda/lambda.go
newLambda
func newLambda(s LambdaSettings) *goadLambda { setLambdaExecTimeout(&s) setDefaultConcurrencyCount(&s) l := &goadLambda{} l.Settings = s l.Metrics = NewRequestMetric(s.LambdaRegion, s.RunnerID) remainingRequestCount := s.MaxRequestCount - s.CompletedRequestCount if remainingRequestCount < 0 { remainingRequestCount = 0 } l.setupHTTPClientForSelfsignedTLS() awsSqsConfig := l.setupAwsConfig() l.setupAwsSqsAdapter(awsSqsConfig) l.setupJobQueue(remainingRequestCount) l.results = make(chan requestResult) return l }
go
func newLambda(s LambdaSettings) *goadLambda { setLambdaExecTimeout(&s) setDefaultConcurrencyCount(&s) l := &goadLambda{} l.Settings = s l.Metrics = NewRequestMetric(s.LambdaRegion, s.RunnerID) remainingRequestCount := s.MaxRequestCount - s.CompletedRequestCount if remainingRequestCount < 0 { remainingRequestCount = 0 } l.setupHTTPClientForSelfsignedTLS() awsSqsConfig := l.setupAwsConfig() l.setupAwsSqsAdapter(awsSqsConfig) l.setupJobQueue(remainingRequestCount) l.results = make(chan requestResult) return l }
[ "func", "newLambda", "(", "s", "LambdaSettings", ")", "*", "goadLambda", "{", "setLambdaExecTimeout", "(", "&", "s", ")", "\n", "setDefaultConcurrencyCount", "(", "&", "s", ")", "\n", "l", ":=", "&", "goadLambda", "{", "}", "\n", "l", ".", "Settings", "=...
// newLambda creates a new Lambda to execute a load test from a given // LambdaSettings
[ "newLambda", "creates", "a", "new", "Lambda", "to", "execute", "a", "load", "test", "from", "a", "given", "LambdaSettings" ]
612187f4fd0d04b18f7181e8434717a175341ada
https://github.com/goadapp/goad/blob/612187f4fd0d04b18f7181e8434717a175341ada/lambda/lambda.go#L200-L218
train
goadapp/goad
result/result.go
Regions
func (r *LambdaResults) Regions() []string { regions := make([]string, 0) for _, lambda := range r.Lambdas { if lambda.Region != "" { regions = append(regions, lambda.Region) } } regions = util.RemoveDuplicates(regions) sort.Strings(regions) return regions }
go
func (r *LambdaResults) Regions() []string { regions := make([]string, 0) for _, lambda := range r.Lambdas { if lambda.Region != "" { regions = append(regions, lambda.Region) } } regions = util.RemoveDuplicates(regions) sort.Strings(regions) return regions }
[ "func", "(", "r", "*", "LambdaResults", ")", "Regions", "(", ")", "[", "]", "string", "{", "regions", ":=", "make", "(", "[", "]", "string", ",", "0", ")", "\n", "for", "_", ",", "lambda", ":=", "range", "r", ".", "Lambdas", "{", "if", "lambda", ...
// Regions the LambdaResults were collected from
[ "Regions", "the", "LambdaResults", "were", "collected", "from" ]
612187f4fd0d04b18f7181e8434717a175341ada
https://github.com/goadapp/goad/blob/612187f4fd0d04b18f7181e8434717a175341ada/result/result.go#L37-L47
train
goadapp/goad
result/result.go
RegionsData
func (r *LambdaResults) RegionsData() map[string]AggData { regionsMap := make(map[string]AggData) for _, region := range r.Regions() { regionsMap[region] = sumAggData(r.ResultsForRegion(region)) } return regionsMap }
go
func (r *LambdaResults) RegionsData() map[string]AggData { regionsMap := make(map[string]AggData) for _, region := range r.Regions() { regionsMap[region] = sumAggData(r.ResultsForRegion(region)) } return regionsMap }
[ "func", "(", "r", "*", "LambdaResults", ")", "RegionsData", "(", ")", "map", "[", "string", "]", "AggData", "{", "regionsMap", ":=", "make", "(", "map", "[", "string", "]", "AggData", ")", "\n", "for", "_", ",", "region", ":=", "range", "r", ".", "...
// RegionsData aggregates the individual lambda functions results per region
[ "RegionsData", "aggregates", "the", "individual", "lambda", "functions", "results", "per", "region" ]
612187f4fd0d04b18f7181e8434717a175341ada
https://github.com/goadapp/goad/blob/612187f4fd0d04b18f7181e8434717a175341ada/result/result.go#L50-L56
train
goadapp/goad
result/result.go
ResultsForRegion
func (r *LambdaResults) ResultsForRegion(region string) []AggData { lambdasOfRegion := make([]AggData, 0) for _, lambda := range r.Lambdas { if lambda.Region == region { lambdasOfRegion = append(lambdasOfRegion, lambda) } } return lambdasOfRegion }
go
func (r *LambdaResults) ResultsForRegion(region string) []AggData { lambdasOfRegion := make([]AggData, 0) for _, lambda := range r.Lambdas { if lambda.Region == region { lambdasOfRegion = append(lambdasOfRegion, lambda) } } return lambdasOfRegion }
[ "func", "(", "r", "*", "LambdaResults", ")", "ResultsForRegion", "(", "region", "string", ")", "[", "]", "AggData", "{", "lambdasOfRegion", ":=", "make", "(", "[", "]", "AggData", ",", "0", ")", "\n", "for", "_", ",", "lambda", ":=", "range", "r", "....
//ResultsForRegion return the sum of results for a given regions
[ "ResultsForRegion", "return", "the", "sum", "of", "results", "for", "a", "given", "regions" ]
612187f4fd0d04b18f7181e8434717a175341ada
https://github.com/goadapp/goad/blob/612187f4fd0d04b18f7181e8434717a175341ada/result/result.go#L64-L72
train
goadapp/goad
cli/cli.go
Run
func Run() { app.HelpFlag.Short('h') app.Version(version.String()) app.VersionFlag.Short('V') config := aggregateConfiguration() err := config.Check() goad.HandleErr(err) sigChan := make(chan os.Signal, 1) signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM) // but interrupts from kbd are blocked by termbox result := start(config, sigChan) defer printSummary(result) if config.Output != "" { defer saveJSONSummary(*outputFile, result) } }
go
func Run() { app.HelpFlag.Short('h') app.Version(version.String()) app.VersionFlag.Short('V') config := aggregateConfiguration() err := config.Check() goad.HandleErr(err) sigChan := make(chan os.Signal, 1) signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM) // but interrupts from kbd are blocked by termbox result := start(config, sigChan) defer printSummary(result) if config.Output != "" { defer saveJSONSummary(*outputFile, result) } }
[ "func", "Run", "(", ")", "{", "app", ".", "HelpFlag", ".", "Short", "(", "'h'", ")", "\n", "app", ".", "Version", "(", "version", ".", "String", "(", ")", ")", "\n", "app", ".", "VersionFlag", ".", "Short", "(", "'V'", ")", "\n", "config", ":=", ...
// Run the goad cli
[ "Run", "the", "goad", "cli" ]
612187f4fd0d04b18f7181e8434717a175341ada
https://github.com/goadapp/goad/blob/612187f4fd0d04b18f7181e8434717a175341ada/cli/cli.go#L77-L94
train
goadapp/goad
cli/cli.go
clearLogo
func clearLogo() { w, h := termbox.Size() clearStr := strings.Repeat(" ", w) for i := 0; i < h-1; i++ { renderString(0, i, clearStr, coldef, coldef) } }
go
func clearLogo() { w, h := termbox.Size() clearStr := strings.Repeat(" ", w) for i := 0; i < h-1; i++ { renderString(0, i, clearStr, coldef, coldef) } }
[ "func", "clearLogo", "(", ")", "{", "w", ",", "h", ":=", "termbox", ".", "Size", "(", ")", "\n", "clearStr", ":=", "strings", ".", "Repeat", "(", "\" \"", ",", "w", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "h", "-", "1", ";", "i", "...
// Also clears loading message
[ "Also", "clears", "loading", "message" ]
612187f4fd0d04b18f7181e8434717a175341ada
https://github.com/goadapp/goad/blob/612187f4fd0d04b18f7181e8434717a175341ada/cli/cli.go#L381-L387
train
goadapp/goad
cli/cli.go
renderRegion
func renderRegion(data result.AggData, y int) int { x := 0 renderString(x, y, "Region: ", termbox.ColorWhite, termbox.ColorBlue) x += 8 regionStr := fmt.Sprintf("%s", data.Region) renderString(x, y, regionStr, termbox.ColorWhite|termbox.AttrBold, termbox.ColorBlue) x = 0 y++ headingStr := " TotReqs TotBytes AvgTime AvgReq/s (post)unzip" renderString(x, y, headingStr, coldef|termbox.AttrBold, coldef) y++ resultStr := fmt.Sprintf("%10d %10s %7.3fs %10.2f %10s/s", data.TotalReqs, humanize.Bytes(uint64(data.TotBytesRead)), float64(data.AveTimeForReq)/nano, data.AveReqPerSec, humanize.Bytes(uint64(data.AveKBytesPerSec))) renderString(x, y, resultStr, coldef, coldef) y++ headingStr = " Slowest Fastest Timeouts TotErrors" renderString(x, y, headingStr, coldef|termbox.AttrBold, coldef) y++ resultStr = fmt.Sprintf(" %7.3fs %7.3fs %10d %10d", float64(data.Slowest)/nano, float64(data.Fastest)/nano, data.TotalTimedOut, totErrors(data)) renderString(x, y, resultStr, coldef, coldef) y++ return y }
go
func renderRegion(data result.AggData, y int) int { x := 0 renderString(x, y, "Region: ", termbox.ColorWhite, termbox.ColorBlue) x += 8 regionStr := fmt.Sprintf("%s", data.Region) renderString(x, y, regionStr, termbox.ColorWhite|termbox.AttrBold, termbox.ColorBlue) x = 0 y++ headingStr := " TotReqs TotBytes AvgTime AvgReq/s (post)unzip" renderString(x, y, headingStr, coldef|termbox.AttrBold, coldef) y++ resultStr := fmt.Sprintf("%10d %10s %7.3fs %10.2f %10s/s", data.TotalReqs, humanize.Bytes(uint64(data.TotBytesRead)), float64(data.AveTimeForReq)/nano, data.AveReqPerSec, humanize.Bytes(uint64(data.AveKBytesPerSec))) renderString(x, y, resultStr, coldef, coldef) y++ headingStr = " Slowest Fastest Timeouts TotErrors" renderString(x, y, headingStr, coldef|termbox.AttrBold, coldef) y++ resultStr = fmt.Sprintf(" %7.3fs %7.3fs %10d %10d", float64(data.Slowest)/nano, float64(data.Fastest)/nano, data.TotalTimedOut, totErrors(data)) renderString(x, y, resultStr, coldef, coldef) y++ return y }
[ "func", "renderRegion", "(", "data", "result", ".", "AggData", ",", "y", "int", ")", "int", "{", "x", ":=", "0", "\n", "renderString", "(", "x", ",", "y", ",", "\"Region: \"", ",", "termbox", ".", "ColorWhite", ",", "termbox", ".", "ColorBlue", ")", ...
// renderRegion returns the y for the next empty line
[ "renderRegion", "returns", "the", "y", "for", "the", "next", "empty", "line" ]
612187f4fd0d04b18f7181e8434717a175341ada
https://github.com/goadapp/goad/blob/612187f4fd0d04b18f7181e8434717a175341ada/cli/cli.go#L390-L412
train
goadapp/goad
goad/goad.go
Start
func Start(t *types.TestConfig) (<-chan *result.LambdaResults, func()) { var infra infrastructure.Infrastructure if t.RunDocker { infra = dockerinfra.New(t) } else { infra = awsinfra.New(t) } teardown, err := infra.Setup() HandleErr(err) t.Lambdas = numberOfLambdas(t.Concurrency, len(t.Regions)) infrastructure.InvokeLambdas(infra) results := make(chan *result.LambdaResults) go func() { for result := range infrastructure.Aggregate(infra) { results <- result } close(results) }() return results, teardown }
go
func Start(t *types.TestConfig) (<-chan *result.LambdaResults, func()) { var infra infrastructure.Infrastructure if t.RunDocker { infra = dockerinfra.New(t) } else { infra = awsinfra.New(t) } teardown, err := infra.Setup() HandleErr(err) t.Lambdas = numberOfLambdas(t.Concurrency, len(t.Regions)) infrastructure.InvokeLambdas(infra) results := make(chan *result.LambdaResults) go func() { for result := range infrastructure.Aggregate(infra) { results <- result } close(results) }() return results, teardown }
[ "func", "Start", "(", "t", "*", "types", ".", "TestConfig", ")", "(", "<-", "chan", "*", "result", ".", "LambdaResults", ",", "func", "(", ")", ")", "{", "var", "infra", "infrastructure", ".", "Infrastructure", "\n", "if", "t", ".", "RunDocker", "{", ...
// Start a test
[ "Start", "a", "test" ]
612187f4fd0d04b18f7181e8434717a175341ada
https://github.com/goadapp/goad/blob/612187f4fd0d04b18f7181e8434717a175341ada/goad/goad.go#L12-L35
train
goadapp/goad
infrastructure/aws/sqsadapter/sqsadapter.go
New
func New(awsConfig *aws.Config, queueURL string) *Adapter { return &Adapter{getClient(awsConfig), queueURL} }
go
func New(awsConfig *aws.Config, queueURL string) *Adapter { return &Adapter{getClient(awsConfig), queueURL} }
[ "func", "New", "(", "awsConfig", "*", "aws", ".", "Config", ",", "queueURL", "string", ")", "*", "Adapter", "{", "return", "&", "Adapter", "{", "getClient", "(", "awsConfig", ")", ",", "queueURL", "}", "\n", "}" ]
// NewSQSAdapter returns a new sqs adator object
[ "NewSQSAdapter", "returns", "a", "new", "sqs", "adator", "object" ]
612187f4fd0d04b18f7181e8434717a175341ada
https://github.com/goadapp/goad/blob/612187f4fd0d04b18f7181e8434717a175341ada/infrastructure/aws/sqsadapter/sqsadapter.go#L26-L28
train
goadapp/goad
infrastructure/aws/sqsadapter/sqsadapter.go
Receive
func (adaptor Adapter) Receive() []*api.RunnerResult { params := &sqs.ReceiveMessageInput{ QueueUrl: aws.String(adaptor.QueueURL), MaxNumberOfMessages: aws.Int64(10), VisibilityTimeout: aws.Int64(1), WaitTimeSeconds: aws.Int64(1), } resp, err := adaptor.Client.ReceiveMessage(params) if err != nil { fmt.Println(err.Error()) return nil } if len(resp.Messages) == 0 { return nil } items := resp.Messages results := make([]*api.RunnerResult, 0) deleteEntries := make([]*sqs.DeleteMessageBatchRequestEntry, 0) for _, item := range items { result, jsonerr := resultFromJSON(*item.Body) if jsonerr != nil { fmt.Println(err.Error()) return nil } deleteEntries = append(deleteEntries, &sqs.DeleteMessageBatchRequestEntry{ Id: aws.String(*item.MessageId), ReceiptHandle: aws.String(*item.ReceiptHandle), }) results = append(results, result) } deleteParams := &sqs.DeleteMessageBatchInput{ Entries: deleteEntries, QueueUrl: aws.String(adaptor.QueueURL), } _, delerr := adaptor.Client.DeleteMessageBatch(deleteParams) if delerr != nil { fmt.Println(delerr.Error()) return nil } return results }
go
func (adaptor Adapter) Receive() []*api.RunnerResult { params := &sqs.ReceiveMessageInput{ QueueUrl: aws.String(adaptor.QueueURL), MaxNumberOfMessages: aws.Int64(10), VisibilityTimeout: aws.Int64(1), WaitTimeSeconds: aws.Int64(1), } resp, err := adaptor.Client.ReceiveMessage(params) if err != nil { fmt.Println(err.Error()) return nil } if len(resp.Messages) == 0 { return nil } items := resp.Messages results := make([]*api.RunnerResult, 0) deleteEntries := make([]*sqs.DeleteMessageBatchRequestEntry, 0) for _, item := range items { result, jsonerr := resultFromJSON(*item.Body) if jsonerr != nil { fmt.Println(err.Error()) return nil } deleteEntries = append(deleteEntries, &sqs.DeleteMessageBatchRequestEntry{ Id: aws.String(*item.MessageId), ReceiptHandle: aws.String(*item.ReceiptHandle), }) results = append(results, result) } deleteParams := &sqs.DeleteMessageBatchInput{ Entries: deleteEntries, QueueUrl: aws.String(adaptor.QueueURL), } _, delerr := adaptor.Client.DeleteMessageBatch(deleteParams) if delerr != nil { fmt.Println(delerr.Error()) return nil } return results }
[ "func", "(", "adaptor", "Adapter", ")", "Receive", "(", ")", "[", "]", "*", "api", ".", "RunnerResult", "{", "params", ":=", "&", "sqs", ".", "ReceiveMessageInput", "{", "QueueUrl", ":", "aws", ".", "String", "(", "adaptor", ".", "QueueURL", ")", ",", ...
// Receive a result, or timeout in 1 second
[ "Receive", "a", "result", "or", "timeout", "in", "1", "second" ]
612187f4fd0d04b18f7181e8434717a175341ada
https://github.com/goadapp/goad/blob/612187f4fd0d04b18f7181e8434717a175341ada/infrastructure/aws/sqsadapter/sqsadapter.go#L41-L87
train
goadapp/goad
infrastructure/aws/sqsadapter/sqsadapter.go
SendResult
func (adaptor Adapter) SendResult(result api.RunnerResult) error { str, jsonerr := jsonFromResult(result) if jsonerr != nil { fmt.Println(jsonerr) panic(jsonerr) } params := &sqs.SendMessageInput{ MessageBody: aws.String(str), MessageGroupId: aws.String("goad-lambda"), MessageDeduplicationId: aws.String(uuid.NewV4().String()), QueueUrl: aws.String(adaptor.QueueURL), } _, err := adaptor.Client.SendMessage(params) return err }
go
func (adaptor Adapter) SendResult(result api.RunnerResult) error { str, jsonerr := jsonFromResult(result) if jsonerr != nil { fmt.Println(jsonerr) panic(jsonerr) } params := &sqs.SendMessageInput{ MessageBody: aws.String(str), MessageGroupId: aws.String("goad-lambda"), MessageDeduplicationId: aws.String(uuid.NewV4().String()), QueueUrl: aws.String(adaptor.QueueURL), } _, err := adaptor.Client.SendMessage(params) return err }
[ "func", "(", "adaptor", "Adapter", ")", "SendResult", "(", "result", "api", ".", "RunnerResult", ")", "error", "{", "str", ",", "jsonerr", ":=", "jsonFromResult", "(", "result", ")", "\n", "if", "jsonerr", "!=", "nil", "{", "fmt", ".", "Println", "(", ...
// SendResult adds a result to the queue
[ "SendResult", "adds", "a", "result", "to", "the", "queue" ]
612187f4fd0d04b18f7181e8434717a175341ada
https://github.com/goadapp/goad/blob/612187f4fd0d04b18f7181e8434717a175341ada/infrastructure/aws/sqsadapter/sqsadapter.go#L109-L124
train
goadapp/goad
infrastructure/aws/sqsadapter/sqsadapter.go
SendResult
func (adaptor DummyAdapter) SendResult(result api.RunnerResult) { str, jsonerr := jsonFromResult(result) if jsonerr != nil { fmt.Println(jsonerr) return } fmt.Println("\n" + str) }
go
func (adaptor DummyAdapter) SendResult(result api.RunnerResult) { str, jsonerr := jsonFromResult(result) if jsonerr != nil { fmt.Println(jsonerr) return } fmt.Println("\n" + str) }
[ "func", "(", "adaptor", "DummyAdapter", ")", "SendResult", "(", "result", "api", ".", "RunnerResult", ")", "{", "str", ",", "jsonerr", ":=", "jsonFromResult", "(", "result", ")", "\n", "if", "jsonerr", "!=", "nil", "{", "fmt", ".", "Println", "(", "jsone...
// SendResult prints the result
[ "SendResult", "prints", "the", "result" ]
612187f4fd0d04b18f7181e8434717a175341ada
https://github.com/goadapp/goad/blob/612187f4fd0d04b18f7181e8434717a175341ada/infrastructure/aws/sqsadapter/sqsadapter.go#L127-L134
train
goadapp/goad
webapi/webapi.go
Serve
func Serve() { http.HandleFunc("/goad", serveResults) http.HandleFunc("/_health", health) err := http.ListenAndServe(*addr, nil) if err != nil { log.Fatal("ListenAndServe: ", err) } }
go
func Serve() { http.HandleFunc("/goad", serveResults) http.HandleFunc("/_health", health) err := http.ListenAndServe(*addr, nil) if err != nil { log.Fatal("ListenAndServe: ", err) } }
[ "func", "Serve", "(", ")", "{", "http", ".", "HandleFunc", "(", "\"/goad\"", ",", "serveResults", ")", "\n", "http", ".", "HandleFunc", "(", "\"/_health\"", ",", "health", ")", "\n", "err", ":=", "http", ".", "ListenAndServe", "(", "*", "addr", ",", "n...
// Serve waits for connections and serves the results
[ "Serve", "waits", "for", "connections", "and", "serves", "the", "results" ]
612187f4fd0d04b18f7181e8434717a175341ada
https://github.com/goadapp/goad/blob/612187f4fd0d04b18f7181e8434717a175341ada/webapi/webapi.go#L141-L148
train
goadapp/goad
infrastructure/aws/aws.go
New
func New(config *types.TestConfig) infrastructure.Infrastructure { awsConfig := aws.NewConfig().WithRegion(config.Regions[0]) infra := &AwsInfrastructure{config: config, awsConfig: awsConfig} return infra }
go
func New(config *types.TestConfig) infrastructure.Infrastructure { awsConfig := aws.NewConfig().WithRegion(config.Regions[0]) infra := &AwsInfrastructure{config: config, awsConfig: awsConfig} return infra }
[ "func", "New", "(", "config", "*", "types", ".", "TestConfig", ")", "infrastructure", ".", "Infrastructure", "{", "awsConfig", ":=", "aws", ".", "NewConfig", "(", ")", ".", "WithRegion", "(", "config", ".", "Regions", "[", "0", "]", ")", "\n", "infra", ...
// New creates the required infrastructure to run the load tests in Lambda // functions.
[ "New", "creates", "the", "required", "infrastructure", "to", "run", "the", "load", "tests", "in", "Lambda", "functions", "." ]
612187f4fd0d04b18f7181e8434717a175341ada
https://github.com/goadapp/goad/blob/612187f4fd0d04b18f7181e8434717a175341ada/infrastructure/aws/aws.go#L43-L47
train
opencontainers/image-spec
schema/validator.go
Validate
func (v Validator) Validate(src io.Reader) error { buf, err := ioutil.ReadAll(src) if err != nil { return errors.Wrap(err, "unable to read the document file") } if f, ok := mapValidate[v]; ok { if f == nil { return fmt.Errorf("internal error: mapValidate[%q] is nil", v) } err = f(bytes.NewReader(buf)) if err != nil { return err } } sl := newFSLoaderFactory(schemaNamespaces, fs).New(specs[v]) ml := gojsonschema.NewStringLoader(string(buf)) result, err := gojsonschema.Validate(sl, ml) if err != nil { return errors.Wrapf( WrapSyntaxError(bytes.NewReader(buf), err), "schema %s: unable to validate", v) } if result.Valid() { return nil } errs := make([]error, 0, len(result.Errors())) for _, desc := range result.Errors() { errs = append(errs, fmt.Errorf("%s", desc)) } return ValidationError{ Errs: errs, } }
go
func (v Validator) Validate(src io.Reader) error { buf, err := ioutil.ReadAll(src) if err != nil { return errors.Wrap(err, "unable to read the document file") } if f, ok := mapValidate[v]; ok { if f == nil { return fmt.Errorf("internal error: mapValidate[%q] is nil", v) } err = f(bytes.NewReader(buf)) if err != nil { return err } } sl := newFSLoaderFactory(schemaNamespaces, fs).New(specs[v]) ml := gojsonschema.NewStringLoader(string(buf)) result, err := gojsonschema.Validate(sl, ml) if err != nil { return errors.Wrapf( WrapSyntaxError(bytes.NewReader(buf), err), "schema %s: unable to validate", v) } if result.Valid() { return nil } errs := make([]error, 0, len(result.Errors())) for _, desc := range result.Errors() { errs = append(errs, fmt.Errorf("%s", desc)) } return ValidationError{ Errs: errs, } }
[ "func", "(", "v", "Validator", ")", "Validate", "(", "src", "io", ".", "Reader", ")", "error", "{", "buf", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "src", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "er...
// Validate validates the given reader against the schema of the wrapped media type.
[ "Validate", "validates", "the", "given", "reader", "against", "the", "schema", "of", "the", "wrapped", "media", "type", "." ]
da296dcb1e473a9b4e2d148941d7faa9ac8fea3f
https://github.com/opencontainers/image-spec/blob/da296dcb1e473a9b4e2d148941d7faa9ac8fea3f/schema/validator.go#L54-L92
train
opencontainers/image-spec
identity/chainid.go
ChainID
func ChainID(dgsts []digest.Digest) digest.Digest { chainIDs := make([]digest.Digest, len(dgsts)) copy(chainIDs, dgsts) ChainIDs(chainIDs) if len(chainIDs) == 0 { return "" } return chainIDs[len(chainIDs)-1] }
go
func ChainID(dgsts []digest.Digest) digest.Digest { chainIDs := make([]digest.Digest, len(dgsts)) copy(chainIDs, dgsts) ChainIDs(chainIDs) if len(chainIDs) == 0 { return "" } return chainIDs[len(chainIDs)-1] }
[ "func", "ChainID", "(", "dgsts", "[", "]", "digest", ".", "Digest", ")", "digest", ".", "Digest", "{", "chainIDs", ":=", "make", "(", "[", "]", "digest", ".", "Digest", ",", "len", "(", "dgsts", ")", ")", "\n", "copy", "(", "chainIDs", ",", "dgsts"...
// ChainID takes a slice of digests and returns the ChainID corresponding to // the last entry. Typically, these are a list of layer DiffIDs, with the // result providing the ChainID identifying the result of sequential // application of the preceding layers.
[ "ChainID", "takes", "a", "slice", "of", "digests", "and", "returns", "the", "ChainID", "corresponding", "to", "the", "last", "entry", ".", "Typically", "these", "are", "a", "list", "of", "layer", "DiffIDs", "with", "the", "result", "providing", "the", "Chain...
da296dcb1e473a9b4e2d148941d7faa9ac8fea3f
https://github.com/opencontainers/image-spec/blob/da296dcb1e473a9b4e2d148941d7faa9ac8fea3f/identity/chainid.go#L30-L39
train
opencontainers/image-spec
identity/helpers.go
FromReader
func FromReader(rd io.Reader) (digest.Digest, error) { return digest.Canonical.FromReader(rd) }
go
func FromReader(rd io.Reader) (digest.Digest, error) { return digest.Canonical.FromReader(rd) }
[ "func", "FromReader", "(", "rd", "io", ".", "Reader", ")", "(", "digest", ".", "Digest", ",", "error", ")", "{", "return", "digest", ".", "Canonical", ".", "FromReader", "(", "rd", ")", "\n", "}" ]
// FromReader consumes the content of rd until io.EOF, returning canonical // digest.
[ "FromReader", "consumes", "the", "content", "of", "rd", "until", "io", ".", "EOF", "returning", "canonical", "digest", "." ]
da296dcb1e473a9b4e2d148941d7faa9ac8fea3f
https://github.com/opencontainers/image-spec/blob/da296dcb1e473a9b4e2d148941d7faa9ac8fea3f/identity/helpers.go#L28-L30
train
opencontainers/image-spec
schema/loader.go
newFSLoaderFactory
func newFSLoaderFactory(namespaces []string, fs http.FileSystem) *fsLoaderFactory { return &fsLoaderFactory{ namespaces: namespaces, fs: fs, } }
go
func newFSLoaderFactory(namespaces []string, fs http.FileSystem) *fsLoaderFactory { return &fsLoaderFactory{ namespaces: namespaces, fs: fs, } }
[ "func", "newFSLoaderFactory", "(", "namespaces", "[", "]", "string", ",", "fs", "http", ".", "FileSystem", ")", "*", "fsLoaderFactory", "{", "return", "&", "fsLoaderFactory", "{", "namespaces", ":", "namespaces", ",", "fs", ":", "fs", ",", "}", "\n", "}" ]
// newFSLoaderFactory returns a fsLoaderFactory reading files under the specified namespaces from the root of fs.
[ "newFSLoaderFactory", "returns", "a", "fsLoaderFactory", "reading", "files", "under", "the", "specified", "namespaces", "from", "the", "root", "of", "fs", "." ]
da296dcb1e473a9b4e2d148941d7faa9ac8fea3f
https://github.com/opencontainers/image-spec/blob/da296dcb1e473a9b4e2d148941d7faa9ac8fea3f/schema/loader.go#L37-L42
train
opencontainers/image-spec
schema/loader.go
refContents
func (factory *fsLoaderFactory) refContents(ref gojsonreference.JsonReference) ([]byte, error) { refStr := ref.String() path := "" for _, ns := range factory.namespaces { if strings.HasPrefix(refStr, ns) { path = "/" + strings.TrimPrefix(refStr, ns) break } } if path == "" { return nil, fmt.Errorf("Schema reference %#v unexpectedly not available in fsLoaderFactory with namespaces %#v", path, factory.namespaces) } f, err := factory.fs.Open(path) if err != nil { return nil, err } defer f.Close() return ioutil.ReadAll(f) }
go
func (factory *fsLoaderFactory) refContents(ref gojsonreference.JsonReference) ([]byte, error) { refStr := ref.String() path := "" for _, ns := range factory.namespaces { if strings.HasPrefix(refStr, ns) { path = "/" + strings.TrimPrefix(refStr, ns) break } } if path == "" { return nil, fmt.Errorf("Schema reference %#v unexpectedly not available in fsLoaderFactory with namespaces %#v", path, factory.namespaces) } f, err := factory.fs.Open(path) if err != nil { return nil, err } defer f.Close() return ioutil.ReadAll(f) }
[ "func", "(", "factory", "*", "fsLoaderFactory", ")", "refContents", "(", "ref", "gojsonreference", ".", "JsonReference", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "refStr", ":=", "ref", ".", "String", "(", ")", "\n", "path", ":=", "\"\"", "\n...
// refContents returns the contents of ref, if available in fsLoaderFactory.
[ "refContents", "returns", "the", "contents", "of", "ref", "if", "available", "in", "fsLoaderFactory", "." ]
da296dcb1e473a9b4e2d148941d7faa9ac8fea3f
https://github.com/opencontainers/image-spec/blob/da296dcb1e473a9b4e2d148941d7faa9ac8fea3f/schema/loader.go#L52-L72
train
opencontainers/image-spec
schema/loader.go
decodeJSONUsingNumber
func decodeJSONUsingNumber(r io.Reader) (interface{}, error) { // Copied from gojsonschema. var document interface{} decoder := json.NewDecoder(r) decoder.UseNumber() err := decoder.Decode(&document) if err != nil { return nil, err } return document, nil }
go
func decodeJSONUsingNumber(r io.Reader) (interface{}, error) { // Copied from gojsonschema. var document interface{} decoder := json.NewDecoder(r) decoder.UseNumber() err := decoder.Decode(&document) if err != nil { return nil, err } return document, nil }
[ "func", "decodeJSONUsingNumber", "(", "r", "io", ".", "Reader", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "var", "document", "interface", "{", "}", "\n", "decoder", ":=", "json", ".", "NewDecoder", "(", "r", ")", "\n", "decoder", ".", ...
// decodeJSONUsingNumber returns JSON parsed from an io.Reader
[ "decodeJSONUsingNumber", "returns", "JSON", "parsed", "from", "an", "io", ".", "Reader" ]
da296dcb1e473a9b4e2d148941d7faa9ac8fea3f
https://github.com/opencontainers/image-spec/blob/da296dcb1e473a9b4e2d148941d7faa9ac8fea3f/schema/loader.go#L104-L117
train
opencontainers/image-spec
schema/loader.go
JsonReference
func (l *fsLoader) JsonReference() (gojsonreference.JsonReference, error) { // nolint: golint return gojsonreference.NewJsonReference(l.JsonSource().(string)) }
go
func (l *fsLoader) JsonReference() (gojsonreference.JsonReference, error) { // nolint: golint return gojsonreference.NewJsonReference(l.JsonSource().(string)) }
[ "func", "(", "l", "*", "fsLoader", ")", "JsonReference", "(", ")", "(", "gojsonreference", ".", "JsonReference", ",", "error", ")", "{", "return", "gojsonreference", ".", "NewJsonReference", "(", "l", ".", "JsonSource", "(", ")", ".", "(", "string", ")", ...
// JsonReference implements gojsonschema.JSONLoader.JsonReference. The "Json" capitalization needs to be maintained to conform to the interface.
[ "JsonReference", "implements", "gojsonschema", ".", "JSONLoader", ".", "JsonReference", ".", "The", "Json", "capitalization", "needs", "to", "be", "maintained", "to", "conform", "to", "the", "interface", "." ]
da296dcb1e473a9b4e2d148941d7faa9ac8fea3f
https://github.com/opencontainers/image-spec/blob/da296dcb1e473a9b4e2d148941d7faa9ac8fea3f/schema/loader.go#L120-L122
train
gocraft/work
enqueue.go
NewEnqueuer
func NewEnqueuer(namespace string, pool *redis.Pool) *Enqueuer { if pool == nil { panic("NewEnqueuer needs a non-nil *redis.Pool") } return &Enqueuer{ Namespace: namespace, Pool: pool, queuePrefix: redisKeyJobsPrefix(namespace), knownJobs: make(map[string]int64), enqueueUniqueScript: redis.NewScript(2, redisLuaEnqueueUnique), enqueueUniqueInScript: redis.NewScript(2, redisLuaEnqueueUniqueIn), } }
go
func NewEnqueuer(namespace string, pool *redis.Pool) *Enqueuer { if pool == nil { panic("NewEnqueuer needs a non-nil *redis.Pool") } return &Enqueuer{ Namespace: namespace, Pool: pool, queuePrefix: redisKeyJobsPrefix(namespace), knownJobs: make(map[string]int64), enqueueUniqueScript: redis.NewScript(2, redisLuaEnqueueUnique), enqueueUniqueInScript: redis.NewScript(2, redisLuaEnqueueUniqueIn), } }
[ "func", "NewEnqueuer", "(", "namespace", "string", ",", "pool", "*", "redis", ".", "Pool", ")", "*", "Enqueuer", "{", "if", "pool", "==", "nil", "{", "panic", "(", "\"NewEnqueuer needs a non-nil *redis.Pool\"", ")", "\n", "}", "\n", "return", "&", "Enqueuer"...
// NewEnqueuer creates a new enqueuer with the specified Redis namespace and Redis pool.
[ "NewEnqueuer", "creates", "a", "new", "enqueuer", "with", "the", "specified", "Redis", "namespace", "and", "Redis", "pool", "." ]
c85b71e20062f3ab71d4749604faf956d364614f
https://github.com/gocraft/work/blob/c85b71e20062f3ab71d4749604faf956d364614f/enqueue.go#L23-L36
train
gocraft/work
enqueue.go
EnqueueIn
func (e *Enqueuer) EnqueueIn(jobName string, secondsFromNow int64, args map[string]interface{}) (*ScheduledJob, error) { job := &Job{ Name: jobName, ID: makeIdentifier(), EnqueuedAt: nowEpochSeconds(), Args: args, } rawJSON, err := job.serialize() if err != nil { return nil, err } conn := e.Pool.Get() defer conn.Close() scheduledJob := &ScheduledJob{ RunAt: nowEpochSeconds() + secondsFromNow, Job: job, } _, err = conn.Do("ZADD", redisKeyScheduled(e.Namespace), scheduledJob.RunAt, rawJSON) if err != nil { return nil, err } if err := e.addToKnownJobs(conn, jobName); err != nil { return scheduledJob, err } return scheduledJob, nil }
go
func (e *Enqueuer) EnqueueIn(jobName string, secondsFromNow int64, args map[string]interface{}) (*ScheduledJob, error) { job := &Job{ Name: jobName, ID: makeIdentifier(), EnqueuedAt: nowEpochSeconds(), Args: args, } rawJSON, err := job.serialize() if err != nil { return nil, err } conn := e.Pool.Get() defer conn.Close() scheduledJob := &ScheduledJob{ RunAt: nowEpochSeconds() + secondsFromNow, Job: job, } _, err = conn.Do("ZADD", redisKeyScheduled(e.Namespace), scheduledJob.RunAt, rawJSON) if err != nil { return nil, err } if err := e.addToKnownJobs(conn, jobName); err != nil { return scheduledJob, err } return scheduledJob, nil }
[ "func", "(", "e", "*", "Enqueuer", ")", "EnqueueIn", "(", "jobName", "string", ",", "secondsFromNow", "int64", ",", "args", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "*", "ScheduledJob", ",", "error", ")", "{", "job", ":=", "&", "Jo...
// EnqueueIn enqueues a job in the scheduled job queue for execution in secondsFromNow seconds.
[ "EnqueueIn", "enqueues", "a", "job", "in", "the", "scheduled", "job", "queue", "for", "execution", "in", "secondsFromNow", "seconds", "." ]
c85b71e20062f3ab71d4749604faf956d364614f
https://github.com/gocraft/work/blob/c85b71e20062f3ab71d4749604faf956d364614f/enqueue.go#L68-L99
train
gocraft/work
enqueue.go
EnqueueUniqueIn
func (e *Enqueuer) EnqueueUniqueIn(jobName string, secondsFromNow int64, args map[string]interface{}) (*ScheduledJob, error) { return e.EnqueueUniqueInByKey(jobName, secondsFromNow, args, nil) }
go
func (e *Enqueuer) EnqueueUniqueIn(jobName string, secondsFromNow int64, args map[string]interface{}) (*ScheduledJob, error) { return e.EnqueueUniqueInByKey(jobName, secondsFromNow, args, nil) }
[ "func", "(", "e", "*", "Enqueuer", ")", "EnqueueUniqueIn", "(", "jobName", "string", ",", "secondsFromNow", "int64", ",", "args", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "*", "ScheduledJob", ",", "error", ")", "{", "return", "e", "....
// EnqueueUniqueIn enqueues a unique job in the scheduled job queue for execution in secondsFromNow seconds. See EnqueueUnique for the semantics of unique jobs.
[ "EnqueueUniqueIn", "enqueues", "a", "unique", "job", "in", "the", "scheduled", "job", "queue", "for", "execution", "in", "secondsFromNow", "seconds", ".", "See", "EnqueueUnique", "for", "the", "semantics", "of", "unique", "jobs", "." ]
c85b71e20062f3ab71d4749604faf956d364614f
https://github.com/gocraft/work/blob/c85b71e20062f3ab71d4749604faf956d364614f/enqueue.go#L112-L114
train
gocraft/work
enqueue.go
EnqueueUniqueInByKey
func (e *Enqueuer) EnqueueUniqueInByKey(jobName string, secondsFromNow int64, args map[string]interface{}, keyMap map[string]interface{}) (*ScheduledJob, error) { enqueue, job, err := e.uniqueJobHelper(jobName, args, keyMap) if err != nil { return nil, err } scheduledJob := &ScheduledJob{ RunAt: nowEpochSeconds() + secondsFromNow, Job: job, } res, err := enqueue(&scheduledJob.RunAt) if res == "ok" && err == nil { return scheduledJob, nil } return nil, err }
go
func (e *Enqueuer) EnqueueUniqueInByKey(jobName string, secondsFromNow int64, args map[string]interface{}, keyMap map[string]interface{}) (*ScheduledJob, error) { enqueue, job, err := e.uniqueJobHelper(jobName, args, keyMap) if err != nil { return nil, err } scheduledJob := &ScheduledJob{ RunAt: nowEpochSeconds() + secondsFromNow, Job: job, } res, err := enqueue(&scheduledJob.RunAt) if res == "ok" && err == nil { return scheduledJob, nil } return nil, err }
[ "func", "(", "e", "*", "Enqueuer", ")", "EnqueueUniqueInByKey", "(", "jobName", "string", ",", "secondsFromNow", "int64", ",", "args", "map", "[", "string", "]", "interface", "{", "}", ",", "keyMap", "map", "[", "string", "]", "interface", "{", "}", ")",...
// EnqueueUniqueInByKey enqueues a job in the scheduled job queue that is unique on specified key for execution in secondsFromNow seconds. See EnqueueUnique for the semantics of unique jobs. // Subsequent calls with same key will update arguments
[ "EnqueueUniqueInByKey", "enqueues", "a", "job", "in", "the", "scheduled", "job", "queue", "that", "is", "unique", "on", "specified", "key", "for", "execution", "in", "secondsFromNow", "seconds", ".", "See", "EnqueueUnique", "for", "the", "semantics", "of", "uniq...
c85b71e20062f3ab71d4749604faf956d364614f
https://github.com/gocraft/work/blob/c85b71e20062f3ab71d4749604faf956d364614f/enqueue.go#L138-L154
train
gocraft/work
client.go
NewClient
func NewClient(namespace string, pool *redis.Pool) *Client { return &Client{ namespace: namespace, pool: pool, } }
go
func NewClient(namespace string, pool *redis.Pool) *Client { return &Client{ namespace: namespace, pool: pool, } }
[ "func", "NewClient", "(", "namespace", "string", ",", "pool", "*", "redis", ".", "Pool", ")", "*", "Client", "{", "return", "&", "Client", "{", "namespace", ":", "namespace", ",", "pool", ":", "pool", ",", "}", "\n", "}" ]
// NewClient creates a new Client with the specified redis namespace and connection pool.
[ "NewClient", "creates", "a", "new", "Client", "with", "the", "specified", "redis", "namespace", "and", "connection", "pool", "." ]
c85b71e20062f3ab71d4749604faf956d364614f
https://github.com/gocraft/work/blob/c85b71e20062f3ab71d4749604faf956d364614f/client.go#L27-L32
train
gocraft/work
client.go
WorkerObservations
func (c *Client) WorkerObservations() ([]*WorkerObservation, error) { conn := c.pool.Get() defer conn.Close() hbs, err := c.WorkerPoolHeartbeats() if err != nil { logError("worker_observations.worker_pool_heartbeats", err) return nil, err } var workerIDs []string for _, hb := range hbs { workerIDs = append(workerIDs, hb.WorkerIDs...) } for _, wid := range workerIDs { key := redisKeyWorkerObservation(c.namespace, wid) conn.Send("HGETALL", key) } if err := conn.Flush(); err != nil { logError("worker_observations.flush", err) return nil, err } observations := make([]*WorkerObservation, 0, len(workerIDs)) for _, wid := range workerIDs { vals, err := redis.Strings(conn.Receive()) if err != nil { logError("worker_observations.receive", err) return nil, err } ob := &WorkerObservation{ WorkerID: wid, } for i := 0; i < len(vals)-1; i += 2 { key := vals[i] value := vals[i+1] ob.IsBusy = true var err error if key == "job_name" { ob.JobName = value } else if key == "job_id" { ob.JobID = value } else if key == "started_at" { ob.StartedAt, err = strconv.ParseInt(value, 10, 64) } else if key == "args" { ob.ArgsJSON = value } else if key == "checkin" { ob.Checkin = value } else if key == "checkin_at" { ob.CheckinAt, err = strconv.ParseInt(value, 10, 64) } if err != nil { logError("worker_observations.parse", err) return nil, err } } observations = append(observations, ob) } return observations, nil }
go
func (c *Client) WorkerObservations() ([]*WorkerObservation, error) { conn := c.pool.Get() defer conn.Close() hbs, err := c.WorkerPoolHeartbeats() if err != nil { logError("worker_observations.worker_pool_heartbeats", err) return nil, err } var workerIDs []string for _, hb := range hbs { workerIDs = append(workerIDs, hb.WorkerIDs...) } for _, wid := range workerIDs { key := redisKeyWorkerObservation(c.namespace, wid) conn.Send("HGETALL", key) } if err := conn.Flush(); err != nil { logError("worker_observations.flush", err) return nil, err } observations := make([]*WorkerObservation, 0, len(workerIDs)) for _, wid := range workerIDs { vals, err := redis.Strings(conn.Receive()) if err != nil { logError("worker_observations.receive", err) return nil, err } ob := &WorkerObservation{ WorkerID: wid, } for i := 0; i < len(vals)-1; i += 2 { key := vals[i] value := vals[i+1] ob.IsBusy = true var err error if key == "job_name" { ob.JobName = value } else if key == "job_id" { ob.JobID = value } else if key == "started_at" { ob.StartedAt, err = strconv.ParseInt(value, 10, 64) } else if key == "args" { ob.ArgsJSON = value } else if key == "checkin" { ob.Checkin = value } else if key == "checkin_at" { ob.CheckinAt, err = strconv.ParseInt(value, 10, 64) } if err != nil { logError("worker_observations.parse", err) return nil, err } } observations = append(observations, ob) } return observations, nil }
[ "func", "(", "c", "*", "Client", ")", "WorkerObservations", "(", ")", "(", "[", "]", "*", "WorkerObservation", ",", "error", ")", "{", "conn", ":=", "c", ".", "pool", ".", "Get", "(", ")", "\n", "defer", "conn", ".", "Close", "(", ")", "\n", "hbs...
// WorkerObservations returns all of the WorkerObservation's it finds for all worker pools' workers.
[ "WorkerObservations", "returns", "all", "of", "the", "WorkerObservation", "s", "it", "finds", "for", "all", "worker", "pools", "workers", "." ]
c85b71e20062f3ab71d4749604faf956d364614f
https://github.com/gocraft/work/blob/c85b71e20062f3ab71d4749604faf956d364614f/client.go#L135-L203
train
gocraft/work
client.go
Queues
func (c *Client) Queues() ([]*Queue, error) { conn := c.pool.Get() defer conn.Close() key := redisKeyKnownJobs(c.namespace) jobNames, err := redis.Strings(conn.Do("SMEMBERS", key)) if err != nil { return nil, err } sort.Strings(jobNames) for _, jobName := range jobNames { conn.Send("LLEN", redisKeyJobs(c.namespace, jobName)) } if err := conn.Flush(); err != nil { logError("client.queues.flush", err) return nil, err } queues := make([]*Queue, 0, len(jobNames)) for _, jobName := range jobNames { count, err := redis.Int64(conn.Receive()) if err != nil { logError("client.queues.receive", err) return nil, err } queue := &Queue{ JobName: jobName, Count: count, } queues = append(queues, queue) } for _, s := range queues { if s.Count > 0 { conn.Send("LINDEX", redisKeyJobs(c.namespace, s.JobName), -1) } } if err := conn.Flush(); err != nil { logError("client.queues.flush2", err) return nil, err } now := nowEpochSeconds() for _, s := range queues { if s.Count > 0 { b, err := redis.Bytes(conn.Receive()) if err != nil { logError("client.queues.receive2", err) return nil, err } job, err := newJob(b, nil, nil) if err != nil { logError("client.queues.new_job", err) } s.Latency = now - job.EnqueuedAt } } return queues, nil }
go
func (c *Client) Queues() ([]*Queue, error) { conn := c.pool.Get() defer conn.Close() key := redisKeyKnownJobs(c.namespace) jobNames, err := redis.Strings(conn.Do("SMEMBERS", key)) if err != nil { return nil, err } sort.Strings(jobNames) for _, jobName := range jobNames { conn.Send("LLEN", redisKeyJobs(c.namespace, jobName)) } if err := conn.Flush(); err != nil { logError("client.queues.flush", err) return nil, err } queues := make([]*Queue, 0, len(jobNames)) for _, jobName := range jobNames { count, err := redis.Int64(conn.Receive()) if err != nil { logError("client.queues.receive", err) return nil, err } queue := &Queue{ JobName: jobName, Count: count, } queues = append(queues, queue) } for _, s := range queues { if s.Count > 0 { conn.Send("LINDEX", redisKeyJobs(c.namespace, s.JobName), -1) } } if err := conn.Flush(); err != nil { logError("client.queues.flush2", err) return nil, err } now := nowEpochSeconds() for _, s := range queues { if s.Count > 0 { b, err := redis.Bytes(conn.Receive()) if err != nil { logError("client.queues.receive2", err) return nil, err } job, err := newJob(b, nil, nil) if err != nil { logError("client.queues.new_job", err) } s.Latency = now - job.EnqueuedAt } } return queues, nil }
[ "func", "(", "c", "*", "Client", ")", "Queues", "(", ")", "(", "[", "]", "*", "Queue", ",", "error", ")", "{", "conn", ":=", "c", ".", "pool", ".", "Get", "(", ")", "\n", "defer", "conn", ".", "Close", "(", ")", "\n", "key", ":=", "redisKeyKn...
// Queues returns the Queue's it finds.
[ "Queues", "returns", "the", "Queue", "s", "it", "finds", "." ]
c85b71e20062f3ab71d4749604faf956d364614f
https://github.com/gocraft/work/blob/c85b71e20062f3ab71d4749604faf956d364614f/client.go#L213-L280
train
gocraft/work
client.go
DeleteDeadJob
func (c *Client) DeleteDeadJob(diedAt int64, jobID string) error { ok, _, err := c.deleteZsetJob(redisKeyDead(c.namespace), diedAt, jobID) if err != nil { return err } if !ok { return ErrNotDeleted } return nil }
go
func (c *Client) DeleteDeadJob(diedAt int64, jobID string) error { ok, _, err := c.deleteZsetJob(redisKeyDead(c.namespace), diedAt, jobID) if err != nil { return err } if !ok { return ErrNotDeleted } return nil }
[ "func", "(", "c", "*", "Client", ")", "DeleteDeadJob", "(", "diedAt", "int64", ",", "jobID", "string", ")", "error", "{", "ok", ",", "_", ",", "err", ":=", "c", ".", "deleteZsetJob", "(", "redisKeyDead", "(", "c", ".", "namespace", ")", ",", "diedAt"...
// DeleteDeadJob deletes a dead job from Redis.
[ "DeleteDeadJob", "deletes", "a", "dead", "job", "from", "Redis", "." ]
c85b71e20062f3ab71d4749604faf956d364614f
https://github.com/gocraft/work/blob/c85b71e20062f3ab71d4749604faf956d364614f/client.go#L355-L364
train
gocraft/work
client.go
RetryDeadJob
func (c *Client) RetryDeadJob(diedAt int64, jobID string) error { // Get queues for job names queues, err := c.Queues() if err != nil { logError("client.retry_all_dead_jobs.queues", err) return err } // Extract job names var jobNames []string for _, q := range queues { jobNames = append(jobNames, q.JobName) } script := redis.NewScript(len(jobNames)+1, redisLuaRequeueSingleDeadCmd) args := make([]interface{}, 0, len(jobNames)+1+3) args = append(args, redisKeyDead(c.namespace)) // KEY[1] for _, jobName := range jobNames { args = append(args, redisKeyJobs(c.namespace, jobName)) // KEY[2, 3, ...] } args = append(args, redisKeyJobsPrefix(c.namespace)) // ARGV[1] args = append(args, nowEpochSeconds()) args = append(args, diedAt) args = append(args, jobID) conn := c.pool.Get() defer conn.Close() cnt, err := redis.Int64(script.Do(conn, args...)) if err != nil { logError("client.retry_dead_job.do", err) return err } if cnt == 0 { return ErrNotRetried } return nil }
go
func (c *Client) RetryDeadJob(diedAt int64, jobID string) error { // Get queues for job names queues, err := c.Queues() if err != nil { logError("client.retry_all_dead_jobs.queues", err) return err } // Extract job names var jobNames []string for _, q := range queues { jobNames = append(jobNames, q.JobName) } script := redis.NewScript(len(jobNames)+1, redisLuaRequeueSingleDeadCmd) args := make([]interface{}, 0, len(jobNames)+1+3) args = append(args, redisKeyDead(c.namespace)) // KEY[1] for _, jobName := range jobNames { args = append(args, redisKeyJobs(c.namespace, jobName)) // KEY[2, 3, ...] } args = append(args, redisKeyJobsPrefix(c.namespace)) // ARGV[1] args = append(args, nowEpochSeconds()) args = append(args, diedAt) args = append(args, jobID) conn := c.pool.Get() defer conn.Close() cnt, err := redis.Int64(script.Do(conn, args...)) if err != nil { logError("client.retry_dead_job.do", err) return err } if cnt == 0 { return ErrNotRetried } return nil }
[ "func", "(", "c", "*", "Client", ")", "RetryDeadJob", "(", "diedAt", "int64", ",", "jobID", "string", ")", "error", "{", "queues", ",", "err", ":=", "c", ".", "Queues", "(", ")", "\n", "if", "err", "!=", "nil", "{", "logError", "(", "\"client.retry_a...
// RetryDeadJob retries a dead job. The job will be re-queued on the normal work queue for eventual processing by a worker.
[ "RetryDeadJob", "retries", "a", "dead", "job", ".", "The", "job", "will", "be", "re", "-", "queued", "on", "the", "normal", "work", "queue", "for", "eventual", "processing", "by", "a", "worker", "." ]
c85b71e20062f3ab71d4749604faf956d364614f
https://github.com/gocraft/work/blob/c85b71e20062f3ab71d4749604faf956d364614f/client.go#L367-L407
train
gocraft/work
client.go
RetryAllDeadJobs
func (c *Client) RetryAllDeadJobs() error { // Get queues for job names queues, err := c.Queues() if err != nil { logError("client.retry_all_dead_jobs.queues", err) return err } // Extract job names var jobNames []string for _, q := range queues { jobNames = append(jobNames, q.JobName) } script := redis.NewScript(len(jobNames)+1, redisLuaRequeueAllDeadCmd) args := make([]interface{}, 0, len(jobNames)+1+3) args = append(args, redisKeyDead(c.namespace)) // KEY[1] for _, jobName := range jobNames { args = append(args, redisKeyJobs(c.namespace, jobName)) // KEY[2, 3, ...] } args = append(args, redisKeyJobsPrefix(c.namespace)) // ARGV[1] args = append(args, nowEpochSeconds()) args = append(args, 1000) conn := c.pool.Get() defer conn.Close() // Cap iterations for safety (which could reprocess 1k*1k jobs). // This is conceptually an infinite loop but let's be careful. for i := 0; i < 1000; i++ { res, err := redis.Int64(script.Do(conn, args...)) if err != nil { logError("client.retry_all_dead_jobs.do", err) return err } if res == 0 { break } } return nil }
go
func (c *Client) RetryAllDeadJobs() error { // Get queues for job names queues, err := c.Queues() if err != nil { logError("client.retry_all_dead_jobs.queues", err) return err } // Extract job names var jobNames []string for _, q := range queues { jobNames = append(jobNames, q.JobName) } script := redis.NewScript(len(jobNames)+1, redisLuaRequeueAllDeadCmd) args := make([]interface{}, 0, len(jobNames)+1+3) args = append(args, redisKeyDead(c.namespace)) // KEY[1] for _, jobName := range jobNames { args = append(args, redisKeyJobs(c.namespace, jobName)) // KEY[2, 3, ...] } args = append(args, redisKeyJobsPrefix(c.namespace)) // ARGV[1] args = append(args, nowEpochSeconds()) args = append(args, 1000) conn := c.pool.Get() defer conn.Close() // Cap iterations for safety (which could reprocess 1k*1k jobs). // This is conceptually an infinite loop but let's be careful. for i := 0; i < 1000; i++ { res, err := redis.Int64(script.Do(conn, args...)) if err != nil { logError("client.retry_all_dead_jobs.do", err) return err } if res == 0 { break } } return nil }
[ "func", "(", "c", "*", "Client", ")", "RetryAllDeadJobs", "(", ")", "error", "{", "queues", ",", "err", ":=", "c", ".", "Queues", "(", ")", "\n", "if", "err", "!=", "nil", "{", "logError", "(", "\"client.retry_all_dead_jobs.queues\"", ",", "err", ")", ...
// RetryAllDeadJobs requeues all dead jobs. In other words, it puts them all back on the normal work queue for workers to pull from and process.
[ "RetryAllDeadJobs", "requeues", "all", "dead", "jobs", ".", "In", "other", "words", "it", "puts", "them", "all", "back", "on", "the", "normal", "work", "queue", "for", "workers", "to", "pull", "from", "and", "process", "." ]
c85b71e20062f3ab71d4749604faf956d364614f
https://github.com/gocraft/work/blob/c85b71e20062f3ab71d4749604faf956d364614f/client.go#L410-L453
train
gocraft/work
client.go
DeleteAllDeadJobs
func (c *Client) DeleteAllDeadJobs() error { conn := c.pool.Get() defer conn.Close() _, err := conn.Do("DEL", redisKeyDead(c.namespace)) if err != nil { logError("client.delete_all_dead_jobs", err) return err } return nil }
go
func (c *Client) DeleteAllDeadJobs() error { conn := c.pool.Get() defer conn.Close() _, err := conn.Do("DEL", redisKeyDead(c.namespace)) if err != nil { logError("client.delete_all_dead_jobs", err) return err } return nil }
[ "func", "(", "c", "*", "Client", ")", "DeleteAllDeadJobs", "(", ")", "error", "{", "conn", ":=", "c", ".", "pool", ".", "Get", "(", ")", "\n", "defer", "conn", ".", "Close", "(", ")", "\n", "_", ",", "err", ":=", "conn", ".", "Do", "(", "\"DEL\...
// DeleteAllDeadJobs deletes all dead jobs.
[ "DeleteAllDeadJobs", "deletes", "all", "dead", "jobs", "." ]
c85b71e20062f3ab71d4749604faf956d364614f
https://github.com/gocraft/work/blob/c85b71e20062f3ab71d4749604faf956d364614f/client.go#L456-L466
train
gocraft/work
client.go
DeleteScheduledJob
func (c *Client) DeleteScheduledJob(scheduledFor int64, jobID string) error { ok, jobBytes, err := c.deleteZsetJob(redisKeyScheduled(c.namespace), scheduledFor, jobID) if err != nil { return err } // If we get a job back, parse it and see if it's a unique job. If it is, we need to delete the unique key. if len(jobBytes) > 0 { job, err := newJob(jobBytes, nil, nil) if err != nil { logError("client.delete_scheduled_job.new_job", err) return err } if job.Unique { uniqueKey, err := redisKeyUniqueJob(c.namespace, job.Name, job.Args) if err != nil { logError("client.delete_scheduled_job.redis_key_unique_job", err) return err } conn := c.pool.Get() defer conn.Close() _, err = conn.Do("DEL", uniqueKey) if err != nil { logError("worker.delete_unique_job.del", err) return err } } } if !ok { return ErrNotDeleted } return nil }
go
func (c *Client) DeleteScheduledJob(scheduledFor int64, jobID string) error { ok, jobBytes, err := c.deleteZsetJob(redisKeyScheduled(c.namespace), scheduledFor, jobID) if err != nil { return err } // If we get a job back, parse it and see if it's a unique job. If it is, we need to delete the unique key. if len(jobBytes) > 0 { job, err := newJob(jobBytes, nil, nil) if err != nil { logError("client.delete_scheduled_job.new_job", err) return err } if job.Unique { uniqueKey, err := redisKeyUniqueJob(c.namespace, job.Name, job.Args) if err != nil { logError("client.delete_scheduled_job.redis_key_unique_job", err) return err } conn := c.pool.Get() defer conn.Close() _, err = conn.Do("DEL", uniqueKey) if err != nil { logError("worker.delete_unique_job.del", err) return err } } } if !ok { return ErrNotDeleted } return nil }
[ "func", "(", "c", "*", "Client", ")", "DeleteScheduledJob", "(", "scheduledFor", "int64", ",", "jobID", "string", ")", "error", "{", "ok", ",", "jobBytes", ",", "err", ":=", "c", ".", "deleteZsetJob", "(", "redisKeyScheduled", "(", "c", ".", "namespace", ...
// DeleteScheduledJob deletes a job in the scheduled queue.
[ "DeleteScheduledJob", "deletes", "a", "job", "in", "the", "scheduled", "queue", "." ]
c85b71e20062f3ab71d4749604faf956d364614f
https://github.com/gocraft/work/blob/c85b71e20062f3ab71d4749604faf956d364614f/client.go#L469-L504
train
gocraft/work
client.go
DeleteRetryJob
func (c *Client) DeleteRetryJob(retryAt int64, jobID string) error { ok, _, err := c.deleteZsetJob(redisKeyRetry(c.namespace), retryAt, jobID) if err != nil { return err } if !ok { return ErrNotDeleted } return nil }
go
func (c *Client) DeleteRetryJob(retryAt int64, jobID string) error { ok, _, err := c.deleteZsetJob(redisKeyRetry(c.namespace), retryAt, jobID) if err != nil { return err } if !ok { return ErrNotDeleted } return nil }
[ "func", "(", "c", "*", "Client", ")", "DeleteRetryJob", "(", "retryAt", "int64", ",", "jobID", "string", ")", "error", "{", "ok", ",", "_", ",", "err", ":=", "c", ".", "deleteZsetJob", "(", "redisKeyRetry", "(", "c", ".", "namespace", ")", ",", "retr...
// DeleteRetryJob deletes a job in the retry queue.
[ "DeleteRetryJob", "deletes", "a", "job", "in", "the", "retry", "queue", "." ]
c85b71e20062f3ab71d4749604faf956d364614f
https://github.com/gocraft/work/blob/c85b71e20062f3ab71d4749604faf956d364614f/client.go#L507-L516
train
gocraft/work
job.go
setArg
func (j *Job) setArg(key string, val interface{}) { if j.Args == nil { j.Args = make(map[string]interface{}) } j.Args[key] = val }
go
func (j *Job) setArg(key string, val interface{}) { if j.Args == nil { j.Args = make(map[string]interface{}) } j.Args[key] = val }
[ "func", "(", "j", "*", "Job", ")", "setArg", "(", "key", "string", ",", "val", "interface", "{", "}", ")", "{", "if", "j", ".", "Args", "==", "nil", "{", "j", ".", "Args", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")...
// setArg sets a single named argument on the job.
[ "setArg", "sets", "a", "single", "named", "argument", "on", "the", "job", "." ]
c85b71e20062f3ab71d4749604faf956d364614f
https://github.com/gocraft/work/blob/c85b71e20062f3ab71d4749604faf956d364614f/job.go#L53-L58
train
gocraft/work
job.go
Checkin
func (j *Job) Checkin(msg string) { if j.observer != nil { j.observer.observeCheckin(j.Name, j.ID, msg) } }
go
func (j *Job) Checkin(msg string) { if j.observer != nil { j.observer.observeCheckin(j.Name, j.ID, msg) } }
[ "func", "(", "j", "*", "Job", ")", "Checkin", "(", "msg", "string", ")", "{", "if", "j", ".", "observer", "!=", "nil", "{", "j", ".", "observer", ".", "observeCheckin", "(", "j", ".", "Name", ",", "j", ".", "ID", ",", "msg", ")", "\n", "}", "...
// Checkin will update the status of the executing job to the specified messages. This message is visible within the web UI. This is useful for indicating some sort of progress on very long running jobs. For instance, on a job that has to process a million records over the course of an hour, the job could call Checkin with the current job number every 10k jobs.
[ "Checkin", "will", "update", "the", "status", "of", "the", "executing", "job", "to", "the", "specified", "messages", ".", "This", "message", "is", "visible", "within", "the", "web", "UI", ".", "This", "is", "useful", "for", "indicating", "some", "sort", "o...
c85b71e20062f3ab71d4749604faf956d364614f
https://github.com/gocraft/work/blob/c85b71e20062f3ab71d4749604faf956d364614f/job.go#L67-L71
train
gocraft/work
worker.go
defaultBackoffCalculator
func defaultBackoffCalculator(job *Job) int64 { fails := job.Fails return (fails * fails * fails * fails) + 15 + (rand.Int63n(30) * (fails + 1)) }
go
func defaultBackoffCalculator(job *Job) int64 { fails := job.Fails return (fails * fails * fails * fails) + 15 + (rand.Int63n(30) * (fails + 1)) }
[ "func", "defaultBackoffCalculator", "(", "job", "*", "Job", ")", "int64", "{", "fails", ":=", "job", ".", "Fails", "\n", "return", "(", "fails", "*", "fails", "*", "fails", "*", "fails", ")", "+", "15", "+", "(", "rand", ".", "Int63n", "(", "30", "...
// Default algorithm returns an fastly increasing backoff counter which grows in an unbounded fashion
[ "Default", "algorithm", "returns", "an", "fastly", "increasing", "backoff", "counter", "which", "grows", "in", "an", "unbounded", "fashion" ]
c85b71e20062f3ab71d4749604faf956d364614f
https://github.com/gocraft/work/blob/c85b71e20062f3ab71d4749604faf956d364614f/worker.go#L324-L327
train
gocraft/work
webui/webui.go
NewServer
func NewServer(namespace string, pool *redis.Pool, hostPort string) *Server { router := web.New(context{}) server := &Server{ namespace: namespace, pool: pool, client: work.NewClient(namespace, pool), hostPort: hostPort, server: manners.NewWithServer(&http.Server{Addr: hostPort, Handler: router}), router: router, } router.Middleware(func(c *context, rw web.ResponseWriter, r *web.Request, next web.NextMiddlewareFunc) { c.Server = server next(rw, r) }) router.Middleware(func(rw web.ResponseWriter, r *web.Request, next web.NextMiddlewareFunc) { rw.Header().Set("Content-Type", "application/json; charset=utf-8") next(rw, r) }) router.Get("/queues", (*context).queues) router.Get("/worker_pools", (*context).workerPools) router.Get("/busy_workers", (*context).busyWorkers) router.Get("/retry_jobs", (*context).retryJobs) router.Get("/scheduled_jobs", (*context).scheduledJobs) router.Get("/dead_jobs", (*context).deadJobs) router.Post("/delete_dead_job/:died_at:\\d.*/:job_id", (*context).deleteDeadJob) router.Post("/retry_dead_job/:died_at:\\d.*/:job_id", (*context).retryDeadJob) router.Post("/delete_all_dead_jobs", (*context).deleteAllDeadJobs) router.Post("/retry_all_dead_jobs", (*context).retryAllDeadJobs) // // Build the HTML page: // assetRouter := router.Subrouter(context{}, "") assetRouter.Get("/", func(c *context, rw web.ResponseWriter, req *web.Request) { rw.Header().Set("Content-Type", "text/html; charset=utf-8") rw.Write(assets.MustAsset("index.html")) }) assetRouter.Get("/work.js", func(c *context, rw web.ResponseWriter, req *web.Request) { rw.Header().Set("Content-Type", "application/javascript; charset=utf-8") rw.Write(assets.MustAsset("work.js")) }) return server }
go
func NewServer(namespace string, pool *redis.Pool, hostPort string) *Server { router := web.New(context{}) server := &Server{ namespace: namespace, pool: pool, client: work.NewClient(namespace, pool), hostPort: hostPort, server: manners.NewWithServer(&http.Server{Addr: hostPort, Handler: router}), router: router, } router.Middleware(func(c *context, rw web.ResponseWriter, r *web.Request, next web.NextMiddlewareFunc) { c.Server = server next(rw, r) }) router.Middleware(func(rw web.ResponseWriter, r *web.Request, next web.NextMiddlewareFunc) { rw.Header().Set("Content-Type", "application/json; charset=utf-8") next(rw, r) }) router.Get("/queues", (*context).queues) router.Get("/worker_pools", (*context).workerPools) router.Get("/busy_workers", (*context).busyWorkers) router.Get("/retry_jobs", (*context).retryJobs) router.Get("/scheduled_jobs", (*context).scheduledJobs) router.Get("/dead_jobs", (*context).deadJobs) router.Post("/delete_dead_job/:died_at:\\d.*/:job_id", (*context).deleteDeadJob) router.Post("/retry_dead_job/:died_at:\\d.*/:job_id", (*context).retryDeadJob) router.Post("/delete_all_dead_jobs", (*context).deleteAllDeadJobs) router.Post("/retry_all_dead_jobs", (*context).retryAllDeadJobs) // // Build the HTML page: // assetRouter := router.Subrouter(context{}, "") assetRouter.Get("/", func(c *context, rw web.ResponseWriter, req *web.Request) { rw.Header().Set("Content-Type", "text/html; charset=utf-8") rw.Write(assets.MustAsset("index.html")) }) assetRouter.Get("/work.js", func(c *context, rw web.ResponseWriter, req *web.Request) { rw.Header().Set("Content-Type", "application/javascript; charset=utf-8") rw.Write(assets.MustAsset("work.js")) }) return server }
[ "func", "NewServer", "(", "namespace", "string", ",", "pool", "*", "redis", ".", "Pool", ",", "hostPort", "string", ")", "*", "Server", "{", "router", ":=", "web", ".", "New", "(", "context", "{", "}", ")", "\n", "server", ":=", "&", "Server", "{", ...
// NewServer creates and returns a new server. The 'namespace' param is the redis namespace to use. The hostPort param is the address to bind on to expose the API.
[ "NewServer", "creates", "and", "returns", "a", "new", "server", ".", "The", "namespace", "param", "is", "the", "redis", "namespace", "to", "use", ".", "The", "hostPort", "param", "is", "the", "address", "to", "bind", "on", "to", "expose", "the", "API", "...
c85b71e20062f3ab71d4749604faf956d364614f
https://github.com/gocraft/work/blob/c85b71e20062f3ab71d4749604faf956d364614f/webui/webui.go#L33-L77
train
gocraft/work
webui/webui.go
Start
func (w *Server) Start() { w.wg.Add(1) go func(w *Server) { w.server.ListenAndServe() w.wg.Done() }(w) }
go
func (w *Server) Start() { w.wg.Add(1) go func(w *Server) { w.server.ListenAndServe() w.wg.Done() }(w) }
[ "func", "(", "w", "*", "Server", ")", "Start", "(", ")", "{", "w", ".", "wg", ".", "Add", "(", "1", ")", "\n", "go", "func", "(", "w", "*", "Server", ")", "{", "w", ".", "server", ".", "ListenAndServe", "(", ")", "\n", "w", ".", "wg", ".", ...
// Start starts the server listening for requests on the hostPort specified in NewServer.
[ "Start", "starts", "the", "server", "listening", "for", "requests", "on", "the", "hostPort", "specified", "in", "NewServer", "." ]
c85b71e20062f3ab71d4749604faf956d364614f
https://github.com/gocraft/work/blob/c85b71e20062f3ab71d4749604faf956d364614f/webui/webui.go#L80-L86
train
gocraft/work
run.go
runJob
func runJob(job *Job, ctxType reflect.Type, middleware []*middlewareHandler, jt *jobType) (returnCtx reflect.Value, returnError error) { returnCtx = reflect.New(ctxType) currentMiddleware := 0 maxMiddleware := len(middleware) var next NextMiddlewareFunc next = func() error { if currentMiddleware < maxMiddleware { mw := middleware[currentMiddleware] currentMiddleware++ if mw.IsGeneric { return mw.GenericMiddlewareHandler(job, next) } res := mw.DynamicMiddleware.Call([]reflect.Value{returnCtx, reflect.ValueOf(job), reflect.ValueOf(next)}) x := res[0].Interface() if x == nil { return nil } return x.(error) } if jt.IsGeneric { return jt.GenericHandler(job) } res := jt.DynamicHandler.Call([]reflect.Value{returnCtx, reflect.ValueOf(job)}) x := res[0].Interface() if x == nil { return nil } return x.(error) } defer func() { if panicErr := recover(); panicErr != nil { // err turns out to be interface{}, of actual type "runtime.errorCString" // Luckily, the err sprints nicely via fmt. errorishError := fmt.Errorf("%v", panicErr) logError("runJob.panic", errorishError) returnError = errorishError } }() returnError = next() return }
go
func runJob(job *Job, ctxType reflect.Type, middleware []*middlewareHandler, jt *jobType) (returnCtx reflect.Value, returnError error) { returnCtx = reflect.New(ctxType) currentMiddleware := 0 maxMiddleware := len(middleware) var next NextMiddlewareFunc next = func() error { if currentMiddleware < maxMiddleware { mw := middleware[currentMiddleware] currentMiddleware++ if mw.IsGeneric { return mw.GenericMiddlewareHandler(job, next) } res := mw.DynamicMiddleware.Call([]reflect.Value{returnCtx, reflect.ValueOf(job), reflect.ValueOf(next)}) x := res[0].Interface() if x == nil { return nil } return x.(error) } if jt.IsGeneric { return jt.GenericHandler(job) } res := jt.DynamicHandler.Call([]reflect.Value{returnCtx, reflect.ValueOf(job)}) x := res[0].Interface() if x == nil { return nil } return x.(error) } defer func() { if panicErr := recover(); panicErr != nil { // err turns out to be interface{}, of actual type "runtime.errorCString" // Luckily, the err sprints nicely via fmt. errorishError := fmt.Errorf("%v", panicErr) logError("runJob.panic", errorishError) returnError = errorishError } }() returnError = next() return }
[ "func", "runJob", "(", "job", "*", "Job", ",", "ctxType", "reflect", ".", "Type", ",", "middleware", "[", "]", "*", "middlewareHandler", ",", "jt", "*", "jobType", ")", "(", "returnCtx", "reflect", ".", "Value", ",", "returnError", "error", ")", "{", "...
// returns an error if the job fails, or there's a panic, or we couldn't reflect correctly. // if we return an error, it signals we want the job to be retried.
[ "returns", "an", "error", "if", "the", "job", "fails", "or", "there", "s", "a", "panic", "or", "we", "couldn", "t", "reflect", "correctly", ".", "if", "we", "return", "an", "error", "it", "signals", "we", "want", "the", "job", "to", "be", "retried", ...
c85b71e20062f3ab71d4749604faf956d364614f
https://github.com/gocraft/work/blob/c85b71e20062f3ab71d4749604faf956d364614f/run.go#L10-L54
train
gocraft/work
worker_pool.go
NewWorkerPool
func NewWorkerPool(ctx interface{}, concurrency uint, namespace string, pool *redis.Pool) *WorkerPool { return NewWorkerPoolWithOptions(ctx, concurrency, namespace, pool, WorkerPoolOptions{}) }
go
func NewWorkerPool(ctx interface{}, concurrency uint, namespace string, pool *redis.Pool) *WorkerPool { return NewWorkerPoolWithOptions(ctx, concurrency, namespace, pool, WorkerPoolOptions{}) }
[ "func", "NewWorkerPool", "(", "ctx", "interface", "{", "}", ",", "concurrency", "uint", ",", "namespace", "string", ",", "pool", "*", "redis", ".", "Pool", ")", "*", "WorkerPool", "{", "return", "NewWorkerPoolWithOptions", "(", "ctx", ",", "concurrency", ","...
// NewWorkerPool creates a new worker pool. ctx should be a struct literal whose type will be used for middleware and handlers. // concurrency specifies how many workers to spin up - each worker can process jobs concurrently.
[ "NewWorkerPool", "creates", "a", "new", "worker", "pool", ".", "ctx", "should", "be", "a", "struct", "literal", "whose", "type", "will", "be", "used", "for", "middleware", "and", "handlers", ".", "concurrency", "specifies", "how", "many", "workers", "to", "s...
c85b71e20062f3ab71d4749604faf956d364614f
https://github.com/gocraft/work/blob/c85b71e20062f3ab71d4749604faf956d364614f/worker_pool.go#L88-L90
train
gocraft/work
worker_pool.go
NewWorkerPoolWithOptions
func NewWorkerPoolWithOptions(ctx interface{}, concurrency uint, namespace string, pool *redis.Pool, workerPoolOpts WorkerPoolOptions) *WorkerPool { if pool == nil { panic("NewWorkerPool needs a non-nil *redis.Pool") } ctxType := reflect.TypeOf(ctx) validateContextType(ctxType) wp := &WorkerPool{ workerPoolID: makeIdentifier(), concurrency: concurrency, namespace: namespace, pool: pool, sleepBackoffs: workerPoolOpts.SleepBackoffs, contextType: ctxType, jobTypes: make(map[string]*jobType), } for i := uint(0); i < wp.concurrency; i++ { w := newWorker(wp.namespace, wp.workerPoolID, wp.pool, wp.contextType, nil, wp.jobTypes, wp.sleepBackoffs) wp.workers = append(wp.workers, w) } return wp }
go
func NewWorkerPoolWithOptions(ctx interface{}, concurrency uint, namespace string, pool *redis.Pool, workerPoolOpts WorkerPoolOptions) *WorkerPool { if pool == nil { panic("NewWorkerPool needs a non-nil *redis.Pool") } ctxType := reflect.TypeOf(ctx) validateContextType(ctxType) wp := &WorkerPool{ workerPoolID: makeIdentifier(), concurrency: concurrency, namespace: namespace, pool: pool, sleepBackoffs: workerPoolOpts.SleepBackoffs, contextType: ctxType, jobTypes: make(map[string]*jobType), } for i := uint(0); i < wp.concurrency; i++ { w := newWorker(wp.namespace, wp.workerPoolID, wp.pool, wp.contextType, nil, wp.jobTypes, wp.sleepBackoffs) wp.workers = append(wp.workers, w) } return wp }
[ "func", "NewWorkerPoolWithOptions", "(", "ctx", "interface", "{", "}", ",", "concurrency", "uint", ",", "namespace", "string", ",", "pool", "*", "redis", ".", "Pool", ",", "workerPoolOpts", "WorkerPoolOptions", ")", "*", "WorkerPool", "{", "if", "pool", "==", ...
// NewWorkerPoolWithOptions creates a new worker pool as per the NewWorkerPool function, but permits you to specify // additional options such as sleep backoffs.
[ "NewWorkerPoolWithOptions", "creates", "a", "new", "worker", "pool", "as", "per", "the", "NewWorkerPool", "function", "but", "permits", "you", "to", "specify", "additional", "options", "such", "as", "sleep", "backoffs", "." ]
c85b71e20062f3ab71d4749604faf956d364614f
https://github.com/gocraft/work/blob/c85b71e20062f3ab71d4749604faf956d364614f/worker_pool.go#L94-L117
train
gocraft/work
worker_pool.go
JobWithOptions
func (wp *WorkerPool) JobWithOptions(name string, jobOpts JobOptions, fn interface{}) *WorkerPool { jobOpts = applyDefaultsAndValidate(jobOpts) vfn := reflect.ValueOf(fn) validateHandlerType(wp.contextType, vfn) jt := &jobType{ Name: name, DynamicHandler: vfn, JobOptions: jobOpts, } if gh, ok := fn.(func(*Job) error); ok { jt.IsGeneric = true jt.GenericHandler = gh } wp.jobTypes[name] = jt for _, w := range wp.workers { w.updateMiddlewareAndJobTypes(wp.middleware, wp.jobTypes) } return wp }
go
func (wp *WorkerPool) JobWithOptions(name string, jobOpts JobOptions, fn interface{}) *WorkerPool { jobOpts = applyDefaultsAndValidate(jobOpts) vfn := reflect.ValueOf(fn) validateHandlerType(wp.contextType, vfn) jt := &jobType{ Name: name, DynamicHandler: vfn, JobOptions: jobOpts, } if gh, ok := fn.(func(*Job) error); ok { jt.IsGeneric = true jt.GenericHandler = gh } wp.jobTypes[name] = jt for _, w := range wp.workers { w.updateMiddlewareAndJobTypes(wp.middleware, wp.jobTypes) } return wp }
[ "func", "(", "wp", "*", "WorkerPool", ")", "JobWithOptions", "(", "name", "string", ",", "jobOpts", "JobOptions", ",", "fn", "interface", "{", "}", ")", "*", "WorkerPool", "{", "jobOpts", "=", "applyDefaultsAndValidate", "(", "jobOpts", ")", "\n", "vfn", "...
// JobWithOptions adds a handler for 'name' jobs as per the Job function, but permits you specify additional options // such as a job's priority, retry count, and whether to send dead jobs to the dead job queue or trash them.
[ "JobWithOptions", "adds", "a", "handler", "for", "name", "jobs", "as", "per", "the", "Job", "function", "but", "permits", "you", "specify", "additional", "options", "such", "as", "a", "job", "s", "priority", "retry", "count", "and", "whether", "to", "send", ...
c85b71e20062f3ab71d4749604faf956d364614f
https://github.com/gocraft/work/blob/c85b71e20062f3ab71d4749604faf956d364614f/worker_pool.go#L154-L176
train
gocraft/work
worker_pool.go
Start
func (wp *WorkerPool) Start() { if wp.started { return } wp.started = true // TODO: we should cleanup stale keys on startup from previously registered jobs wp.writeConcurrencyControlsToRedis() go wp.writeKnownJobsToRedis() for _, w := range wp.workers { go w.start() } wp.heartbeater = newWorkerPoolHeartbeater(wp.namespace, wp.pool, wp.workerPoolID, wp.jobTypes, wp.concurrency, wp.workerIDs()) wp.heartbeater.start() wp.startRequeuers() wp.periodicEnqueuer = newPeriodicEnqueuer(wp.namespace, wp.pool, wp.periodicJobs) wp.periodicEnqueuer.start() }
go
func (wp *WorkerPool) Start() { if wp.started { return } wp.started = true // TODO: we should cleanup stale keys on startup from previously registered jobs wp.writeConcurrencyControlsToRedis() go wp.writeKnownJobsToRedis() for _, w := range wp.workers { go w.start() } wp.heartbeater = newWorkerPoolHeartbeater(wp.namespace, wp.pool, wp.workerPoolID, wp.jobTypes, wp.concurrency, wp.workerIDs()) wp.heartbeater.start() wp.startRequeuers() wp.periodicEnqueuer = newPeriodicEnqueuer(wp.namespace, wp.pool, wp.periodicJobs) wp.periodicEnqueuer.start() }
[ "func", "(", "wp", "*", "WorkerPool", ")", "Start", "(", ")", "{", "if", "wp", ".", "started", "{", "return", "\n", "}", "\n", "wp", ".", "started", "=", "true", "\n", "wp", ".", "writeConcurrencyControlsToRedis", "(", ")", "\n", "go", "wp", ".", "...
// Start starts the workers and associated processes.
[ "Start", "starts", "the", "workers", "and", "associated", "processes", "." ]
c85b71e20062f3ab71d4749604faf956d364614f
https://github.com/gocraft/work/blob/c85b71e20062f3ab71d4749604faf956d364614f/worker_pool.go#L194-L213
train
gocraft/work
worker_pool.go
Stop
func (wp *WorkerPool) Stop() { if !wp.started { return } wp.started = false wg := sync.WaitGroup{} for _, w := range wp.workers { wg.Add(1) go func(w *worker) { w.stop() wg.Done() }(w) } wg.Wait() wp.heartbeater.stop() wp.retrier.stop() wp.scheduler.stop() wp.deadPoolReaper.stop() wp.periodicEnqueuer.stop() }
go
func (wp *WorkerPool) Stop() { if !wp.started { return } wp.started = false wg := sync.WaitGroup{} for _, w := range wp.workers { wg.Add(1) go func(w *worker) { w.stop() wg.Done() }(w) } wg.Wait() wp.heartbeater.stop() wp.retrier.stop() wp.scheduler.stop() wp.deadPoolReaper.stop() wp.periodicEnqueuer.stop() }
[ "func", "(", "wp", "*", "WorkerPool", ")", "Stop", "(", ")", "{", "if", "!", "wp", ".", "started", "{", "return", "\n", "}", "\n", "wp", ".", "started", "=", "false", "\n", "wg", ":=", "sync", ".", "WaitGroup", "{", "}", "\n", "for", "_", ",", ...
// Stop stops the workers and associated processes.
[ "Stop", "stops", "the", "workers", "and", "associated", "processes", "." ]
c85b71e20062f3ab71d4749604faf956d364614f
https://github.com/gocraft/work/blob/c85b71e20062f3ab71d4749604faf956d364614f/worker_pool.go#L216-L236
train
gocraft/work
worker_pool.go
Drain
func (wp *WorkerPool) Drain() { wg := sync.WaitGroup{} for _, w := range wp.workers { wg.Add(1) go func(w *worker) { w.drain() wg.Done() }(w) } wg.Wait() }
go
func (wp *WorkerPool) Drain() { wg := sync.WaitGroup{} for _, w := range wp.workers { wg.Add(1) go func(w *worker) { w.drain() wg.Done() }(w) } wg.Wait() }
[ "func", "(", "wp", "*", "WorkerPool", ")", "Drain", "(", ")", "{", "wg", ":=", "sync", ".", "WaitGroup", "{", "}", "\n", "for", "_", ",", "w", ":=", "range", "wp", ".", "workers", "{", "wg", ".", "Add", "(", "1", ")", "\n", "go", "func", "(",...
// Drain drains all jobs in the queue before returning. Note that if jobs are added faster than we can process them, this function wouldn't return.
[ "Drain", "drains", "all", "jobs", "in", "the", "queue", "before", "returning", ".", "Note", "that", "if", "jobs", "are", "added", "faster", "than", "we", "can", "process", "them", "this", "function", "wouldn", "t", "return", "." ]
c85b71e20062f3ab71d4749604faf956d364614f
https://github.com/gocraft/work/blob/c85b71e20062f3ab71d4749604faf956d364614f/worker_pool.go#L239-L249
train
pilosa/pilosa
api.go
NewAPI
func NewAPI(opts ...apiOption) (*API, error) { api := &API{} for _, opt := range opts { err := opt(api) if err != nil { return nil, errors.Wrap(err, "applying option") } } return api, nil }
go
func NewAPI(opts ...apiOption) (*API, error) { api := &API{} for _, opt := range opts { err := opt(api) if err != nil { return nil, errors.Wrap(err, "applying option") } } return api, nil }
[ "func", "NewAPI", "(", "opts", "...", "apiOption", ")", "(", "*", "API", ",", "error", ")", "{", "api", ":=", "&", "API", "{", "}", "\n", "for", "_", ",", "opt", ":=", "range", "opts", "{", "err", ":=", "opt", "(", "api", ")", "\n", "if", "er...
// NewAPI returns a new API instance.
[ "NewAPI", "returns", "a", "new", "API", "instance", "." ]
67d53f6b48a43f7fe090f48e35518ca8d024747c
https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/api.go#L62-L72
train
pilosa/pilosa
api.go
Query
func (api *API) Query(ctx context.Context, req *QueryRequest) (QueryResponse, error) { span, ctx := tracing.StartSpanFromContext(ctx, "API.Query") defer span.Finish() if err := api.validate(apiQuery); err != nil { return QueryResponse{}, errors.Wrap(err, "validating api method") } q, err := pql.NewParser(strings.NewReader(req.Query)).Parse() if err != nil { return QueryResponse{}, errors.Wrap(err, "parsing") } execOpts := &execOptions{ Remote: req.Remote, ExcludeRowAttrs: req.ExcludeRowAttrs, // NOTE: Kept for Pilosa 1.x compat. ExcludeColumns: req.ExcludeColumns, // NOTE: Kept for Pilosa 1.x compat. ColumnAttrs: req.ColumnAttrs, // NOTE: Kept for Pilosa 1.x compat. } resp, err := api.server.executor.Execute(ctx, req.Index, q, req.Shards, execOpts) if err != nil { return QueryResponse{}, errors.Wrap(err, "executing") } return resp, nil }
go
func (api *API) Query(ctx context.Context, req *QueryRequest) (QueryResponse, error) { span, ctx := tracing.StartSpanFromContext(ctx, "API.Query") defer span.Finish() if err := api.validate(apiQuery); err != nil { return QueryResponse{}, errors.Wrap(err, "validating api method") } q, err := pql.NewParser(strings.NewReader(req.Query)).Parse() if err != nil { return QueryResponse{}, errors.Wrap(err, "parsing") } execOpts := &execOptions{ Remote: req.Remote, ExcludeRowAttrs: req.ExcludeRowAttrs, // NOTE: Kept for Pilosa 1.x compat. ExcludeColumns: req.ExcludeColumns, // NOTE: Kept for Pilosa 1.x compat. ColumnAttrs: req.ColumnAttrs, // NOTE: Kept for Pilosa 1.x compat. } resp, err := api.server.executor.Execute(ctx, req.Index, q, req.Shards, execOpts) if err != nil { return QueryResponse{}, errors.Wrap(err, "executing") } return resp, nil }
[ "func", "(", "api", "*", "API", ")", "Query", "(", "ctx", "context", ".", "Context", ",", "req", "*", "QueryRequest", ")", "(", "QueryResponse", ",", "error", ")", "{", "span", ",", "ctx", ":=", "tracing", ".", "StartSpanFromContext", "(", "ctx", ",", ...
// Query parses a PQL query out of the request and executes it.
[ "Query", "parses", "a", "PQL", "query", "out", "of", "the", "request", "and", "executes", "it", "." ]
67d53f6b48a43f7fe090f48e35518ca8d024747c
https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/api.go#L103-L127
train
pilosa/pilosa
api.go
CreateIndex
func (api *API) CreateIndex(ctx context.Context, indexName string, options IndexOptions) (*Index, error) { span, _ := tracing.StartSpanFromContext(ctx, "API.CreateIndex") defer span.Finish() if err := api.validate(apiCreateIndex); err != nil { return nil, errors.Wrap(err, "validating api method") } // Create index. index, err := api.holder.CreateIndex(indexName, options) if err != nil { return nil, errors.Wrap(err, "creating index") } // Send the create index message to all nodes. err = api.server.SendSync( &CreateIndexMessage{ Index: indexName, Meta: &options, }) if err != nil { return nil, errors.Wrap(err, "sending CreateIndex message") } api.holder.Stats.Count("createIndex", 1, 1.0) return index, nil }
go
func (api *API) CreateIndex(ctx context.Context, indexName string, options IndexOptions) (*Index, error) { span, _ := tracing.StartSpanFromContext(ctx, "API.CreateIndex") defer span.Finish() if err := api.validate(apiCreateIndex); err != nil { return nil, errors.Wrap(err, "validating api method") } // Create index. index, err := api.holder.CreateIndex(indexName, options) if err != nil { return nil, errors.Wrap(err, "creating index") } // Send the create index message to all nodes. err = api.server.SendSync( &CreateIndexMessage{ Index: indexName, Meta: &options, }) if err != nil { return nil, errors.Wrap(err, "sending CreateIndex message") } api.holder.Stats.Count("createIndex", 1, 1.0) return index, nil }
[ "func", "(", "api", "*", "API", ")", "CreateIndex", "(", "ctx", "context", ".", "Context", ",", "indexName", "string", ",", "options", "IndexOptions", ")", "(", "*", "Index", ",", "error", ")", "{", "span", ",", "_", ":=", "tracing", ".", "StartSpanFro...
// CreateIndex makes a new Pilosa index.
[ "CreateIndex", "makes", "a", "new", "Pilosa", "index", "." ]
67d53f6b48a43f7fe090f48e35518ca8d024747c
https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/api.go#L130-L154
train
pilosa/pilosa
api.go
Index
func (api *API) Index(ctx context.Context, indexName string) (*Index, error) { span, _ := tracing.StartSpanFromContext(ctx, "API.Index") defer span.Finish() if err := api.validate(apiIndex); err != nil { return nil, errors.Wrap(err, "validating api method") } index := api.holder.Index(indexName) if index == nil { return nil, newNotFoundError(ErrIndexNotFound) } return index, nil }
go
func (api *API) Index(ctx context.Context, indexName string) (*Index, error) { span, _ := tracing.StartSpanFromContext(ctx, "API.Index") defer span.Finish() if err := api.validate(apiIndex); err != nil { return nil, errors.Wrap(err, "validating api method") } index := api.holder.Index(indexName) if index == nil { return nil, newNotFoundError(ErrIndexNotFound) } return index, nil }
[ "func", "(", "api", "*", "API", ")", "Index", "(", "ctx", "context", ".", "Context", ",", "indexName", "string", ")", "(", "*", "Index", ",", "error", ")", "{", "span", ",", "_", ":=", "tracing", ".", "StartSpanFromContext", "(", "ctx", ",", "\"API.I...
// Index retrieves the named index.
[ "Index", "retrieves", "the", "named", "index", "." ]
67d53f6b48a43f7fe090f48e35518ca8d024747c
https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/api.go#L157-L170
train
pilosa/pilosa
api.go
DeleteIndex
func (api *API) DeleteIndex(ctx context.Context, indexName string) error { span, _ := tracing.StartSpanFromContext(ctx, "API.DeleteIndex") defer span.Finish() if err := api.validate(apiDeleteIndex); err != nil { return errors.Wrap(err, "validating api method") } // Delete index from the holder. err := api.holder.DeleteIndex(indexName) if err != nil { return errors.Wrap(err, "deleting index") } // Send the delete index message to all nodes. err = api.server.SendSync( &DeleteIndexMessage{ Index: indexName, }) if err != nil { api.server.logger.Printf("problem sending DeleteIndex message: %s", err) return errors.Wrap(err, "sending DeleteIndex message") } api.holder.Stats.Count("deleteIndex", 1, 1.0) return nil }
go
func (api *API) DeleteIndex(ctx context.Context, indexName string) error { span, _ := tracing.StartSpanFromContext(ctx, "API.DeleteIndex") defer span.Finish() if err := api.validate(apiDeleteIndex); err != nil { return errors.Wrap(err, "validating api method") } // Delete index from the holder. err := api.holder.DeleteIndex(indexName) if err != nil { return errors.Wrap(err, "deleting index") } // Send the delete index message to all nodes. err = api.server.SendSync( &DeleteIndexMessage{ Index: indexName, }) if err != nil { api.server.logger.Printf("problem sending DeleteIndex message: %s", err) return errors.Wrap(err, "sending DeleteIndex message") } api.holder.Stats.Count("deleteIndex", 1, 1.0) return nil }
[ "func", "(", "api", "*", "API", ")", "DeleteIndex", "(", "ctx", "context", ".", "Context", ",", "indexName", "string", ")", "error", "{", "span", ",", "_", ":=", "tracing", ".", "StartSpanFromContext", "(", "ctx", ",", "\"API.DeleteIndex\"", ")", "\n", "...
// DeleteIndex removes the named index. If the index is not found it does // nothing and returns no error.
[ "DeleteIndex", "removes", "the", "named", "index", ".", "If", "the", "index", "is", "not", "found", "it", "does", "nothing", "and", "returns", "no", "error", "." ]
67d53f6b48a43f7fe090f48e35518ca8d024747c
https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/api.go#L174-L198
train
pilosa/pilosa
api.go
CreateField
func (api *API) CreateField(ctx context.Context, indexName string, fieldName string, opts ...FieldOption) (*Field, error) { span, _ := tracing.StartSpanFromContext(ctx, "API.CreateField") defer span.Finish() if err := api.validate(apiCreateField); err != nil { return nil, errors.Wrap(err, "validating api method") } // Apply functional options. fo := FieldOptions{} for _, opt := range opts { err := opt(&fo) if err != nil { return nil, errors.Wrap(err, "applying option") } } // Find index. index := api.holder.Index(indexName) if index == nil { return nil, newNotFoundError(ErrIndexNotFound) } // Create field. field, err := index.CreateField(fieldName, opts...) if err != nil { return nil, errors.Wrap(err, "creating field") } // Send the create field message to all nodes. err = api.server.SendSync( &CreateFieldMessage{ Index: indexName, Field: fieldName, Meta: &fo, }) if err != nil { api.server.logger.Printf("problem sending CreateField message: %s", err) return nil, errors.Wrap(err, "sending CreateField message") } api.holder.Stats.CountWithCustomTags("createField", 1, 1.0, []string{fmt.Sprintf("index:%s", indexName)}) return field, nil }
go
func (api *API) CreateField(ctx context.Context, indexName string, fieldName string, opts ...FieldOption) (*Field, error) { span, _ := tracing.StartSpanFromContext(ctx, "API.CreateField") defer span.Finish() if err := api.validate(apiCreateField); err != nil { return nil, errors.Wrap(err, "validating api method") } // Apply functional options. fo := FieldOptions{} for _, opt := range opts { err := opt(&fo) if err != nil { return nil, errors.Wrap(err, "applying option") } } // Find index. index := api.holder.Index(indexName) if index == nil { return nil, newNotFoundError(ErrIndexNotFound) } // Create field. field, err := index.CreateField(fieldName, opts...) if err != nil { return nil, errors.Wrap(err, "creating field") } // Send the create field message to all nodes. err = api.server.SendSync( &CreateFieldMessage{ Index: indexName, Field: fieldName, Meta: &fo, }) if err != nil { api.server.logger.Printf("problem sending CreateField message: %s", err) return nil, errors.Wrap(err, "sending CreateField message") } api.holder.Stats.CountWithCustomTags("createField", 1, 1.0, []string{fmt.Sprintf("index:%s", indexName)}) return field, nil }
[ "func", "(", "api", "*", "API", ")", "CreateField", "(", "ctx", "context", ".", "Context", ",", "indexName", "string", ",", "fieldName", "string", ",", "opts", "...", "FieldOption", ")", "(", "*", "Field", ",", "error", ")", "{", "span", ",", "_", ":...
// CreateField makes the named field in the named index with the given options. // This method currently only takes a single functional option, but that may be // changed in the future to support multiple options.
[ "CreateField", "makes", "the", "named", "field", "in", "the", "named", "index", "with", "the", "given", "options", ".", "This", "method", "currently", "only", "takes", "a", "single", "functional", "option", "but", "that", "may", "be", "changed", "in", "the",...
67d53f6b48a43f7fe090f48e35518ca8d024747c
https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/api.go#L203-L245
train
pilosa/pilosa
api.go
Field
func (api *API) Field(ctx context.Context, indexName, fieldName string) (*Field, error) { span, _ := tracing.StartSpanFromContext(ctx, "API.Field") defer span.Finish() if err := api.validate(apiField); err != nil { return nil, errors.Wrap(err, "validating api method") } field := api.holder.Field(indexName, fieldName) if field == nil { return nil, newNotFoundError(ErrFieldNotFound) } return field, nil }
go
func (api *API) Field(ctx context.Context, indexName, fieldName string) (*Field, error) { span, _ := tracing.StartSpanFromContext(ctx, "API.Field") defer span.Finish() if err := api.validate(apiField); err != nil { return nil, errors.Wrap(err, "validating api method") } field := api.holder.Field(indexName, fieldName) if field == nil { return nil, newNotFoundError(ErrFieldNotFound) } return field, nil }
[ "func", "(", "api", "*", "API", ")", "Field", "(", "ctx", "context", ".", "Context", ",", "indexName", ",", "fieldName", "string", ")", "(", "*", "Field", ",", "error", ")", "{", "span", ",", "_", ":=", "tracing", ".", "StartSpanFromContext", "(", "c...
// Field retrieves the named field.
[ "Field", "retrieves", "the", "named", "field", "." ]
67d53f6b48a43f7fe090f48e35518ca8d024747c
https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/api.go#L248-L261
train
pilosa/pilosa
api.go
DeleteField
func (api *API) DeleteField(ctx context.Context, indexName string, fieldName string) error { span, _ := tracing.StartSpanFromContext(ctx, "API.DeleteField") defer span.Finish() if err := api.validate(apiDeleteField); err != nil { return errors.Wrap(err, "validating api method") } // Find index. index := api.holder.Index(indexName) if index == nil { return newNotFoundError(ErrIndexNotFound) } // Delete field from the index. if err := index.DeleteField(fieldName); err != nil { return errors.Wrap(err, "deleting field") } // Send the delete field message to all nodes. err := api.server.SendSync( &DeleteFieldMessage{ Index: indexName, Field: fieldName, }) if err != nil { api.server.logger.Printf("problem sending DeleteField message: %s", err) return errors.Wrap(err, "sending DeleteField message") } api.holder.Stats.CountWithCustomTags("deleteField", 1, 1.0, []string{fmt.Sprintf("index:%s", indexName)}) return nil }
go
func (api *API) DeleteField(ctx context.Context, indexName string, fieldName string) error { span, _ := tracing.StartSpanFromContext(ctx, "API.DeleteField") defer span.Finish() if err := api.validate(apiDeleteField); err != nil { return errors.Wrap(err, "validating api method") } // Find index. index := api.holder.Index(indexName) if index == nil { return newNotFoundError(ErrIndexNotFound) } // Delete field from the index. if err := index.DeleteField(fieldName); err != nil { return errors.Wrap(err, "deleting field") } // Send the delete field message to all nodes. err := api.server.SendSync( &DeleteFieldMessage{ Index: indexName, Field: fieldName, }) if err != nil { api.server.logger.Printf("problem sending DeleteField message: %s", err) return errors.Wrap(err, "sending DeleteField message") } api.holder.Stats.CountWithCustomTags("deleteField", 1, 1.0, []string{fmt.Sprintf("index:%s", indexName)}) return nil }
[ "func", "(", "api", "*", "API", ")", "DeleteField", "(", "ctx", "context", ".", "Context", ",", "indexName", "string", ",", "fieldName", "string", ")", "error", "{", "span", ",", "_", ":=", "tracing", ".", "StartSpanFromContext", "(", "ctx", ",", "\"API....
// DeleteField removes the named field from the named index. If the index is not // found, an error is returned. If the field is not found, it is ignored and no // action is taken.
[ "DeleteField", "removes", "the", "named", "field", "from", "the", "named", "index", ".", "If", "the", "index", "is", "not", "found", "an", "error", "is", "returned", ".", "If", "the", "field", "is", "not", "found", "it", "is", "ignored", "and", "no", "...
67d53f6b48a43f7fe090f48e35518ca8d024747c
https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/api.go#L360-L391
train