id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
132,500
kataras/go-template
mux.go
Find
func (entries Entries) Find(filename string) *Entry { extension := filepath.Ext(filename) // Read-Only no locks needed, at serve/runtime-time the library is not supposed to add new template engines for i, n := 0, len(entries); i < n; i++ { e := entries[i] if e.Loader.Extension == extension { return e } } ...
go
func (entries Entries) Find(filename string) *Entry { extension := filepath.Ext(filename) // Read-Only no locks needed, at serve/runtime-time the library is not supposed to add new template engines for i, n := 0, len(entries); i < n; i++ { e := entries[i] if e.Loader.Extension == extension { return e } } ...
[ "func", "(", "entries", "Entries", ")", "Find", "(", "filename", "string", ")", "*", "Entry", "{", "extension", ":=", "filepath", ".", "Ext", "(", "filename", ")", "\n", "// Read-Only no locks needed, at serve/runtime-time the library is not supposed to add new template e...
// Find receives a filename, gets its extension and returns the template engine responsible for that file extension
[ "Find", "receives", "a", "filename", "gets", "its", "extension", "and", "returns", "the", "template", "engine", "responsible", "for", "that", "file", "extension" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/mux.go#L60-L70
132,501
kataras/go-template
mux.go
UseFuncMap
func (m *Mux) UseFuncMap(funcMap map[string]interface{}) *Mux { if len(funcMap) == 0 { return m } for k, v := range m.SharedFuncs { m.SharedFuncs[k] = v } // if template engine is already added (but not loaded) // then it's valid to add these funcs there. for i, n := 0, len(m.Entries); i < n; i++ { // ad...
go
func (m *Mux) UseFuncMap(funcMap map[string]interface{}) *Mux { if len(funcMap) == 0 { return m } for k, v := range m.SharedFuncs { m.SharedFuncs[k] = v } // if template engine is already added (but not loaded) // then it's valid to add these funcs there. for i, n := 0, len(m.Entries); i < n; i++ { // ad...
[ "func", "(", "m", "*", "Mux", ")", "UseFuncMap", "(", "funcMap", "map", "[", "string", "]", "interface", "{", "}", ")", "*", "Mux", "{", "if", "len", "(", "funcMap", ")", "==", "0", "{", "return", "m", "\n", "}", "\n\n", "for", "k", ",", "v", ...
// UseFuncMap adds shared template funcs to the Mux // these funcs are applied to all template engines // // Should be called not called after Load.
[ "UseFuncMap", "adds", "shared", "template", "funcs", "to", "the", "Mux", "these", "funcs", "are", "applied", "to", "all", "template", "engines", "Should", "be", "called", "not", "called", "after", "Load", "." ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/mux.go#L111-L128
132,502
kataras/go-template
mux.go
AddEngine
func (m *Mux) AddEngine(e Engine) *Loader { // add the shared funcs m.SetFuncMapToEngine(m.SharedFuncs, e) entry := &Entry{Engine: e, Loader: NewLoader()} m.Entries = append(m.Entries, entry) // returns the entry's Loader(pointer) return entry.Loader }
go
func (m *Mux) AddEngine(e Engine) *Loader { // add the shared funcs m.SetFuncMapToEngine(m.SharedFuncs, e) entry := &Entry{Engine: e, Loader: NewLoader()} m.Entries = append(m.Entries, entry) // returns the entry's Loader(pointer) return entry.Loader }
[ "func", "(", "m", "*", "Mux", ")", "AddEngine", "(", "e", "Engine", ")", "*", "Loader", "{", "// add the shared funcs", "m", ".", "SetFuncMapToEngine", "(", "m", ".", "SharedFuncs", ",", "e", ")", "\n\n", "entry", ":=", "&", "Entry", "{", "Engine", ":...
// AddEngine adds but not loads a template engine, returns the entry's Loader
[ "AddEngine", "adds", "but", "not", "loads", "a", "template", "engine", "returns", "the", "entry", "s", "Loader" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/mux.go#L165-L174
132,503
kataras/go-template
django/config.go
DefaultConfig
func DefaultConfig() Config { return Config{ Filters: make(map[string]FilterFunction), Globals: make(map[string]interface{}, 0), DebugTemplates: false, } }
go
func DefaultConfig() Config { return Config{ Filters: make(map[string]FilterFunction), Globals: make(map[string]interface{}, 0), DebugTemplates: false, } }
[ "func", "DefaultConfig", "(", ")", "Config", "{", "return", "Config", "{", "Filters", ":", "make", "(", "map", "[", "string", "]", "FilterFunction", ")", ",", "Globals", ":", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ",", "0", ")...
// DefaultConfig returns the default configuration for the django template engine
[ "DefaultConfig", "returns", "the", "default", "configuration", "for", "the", "django", "template", "engine" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/django/config.go#L26-L32
132,504
kataras/go-template
pug/pug.go
New
func New(cfg ...Config) *html.Engine { c := DefaultConfig() if len(cfg) > 0 { c = cfg[0] } // pass the Pug/Jade configs to the html's configuration s := html.New(html.Config(c)) s.Middleware = jade.Parse return s }
go
func New(cfg ...Config) *html.Engine { c := DefaultConfig() if len(cfg) > 0 { c = cfg[0] } // pass the Pug/Jade configs to the html's configuration s := html.New(html.Config(c)) s.Middleware = jade.Parse return s }
[ "func", "New", "(", "cfg", "...", "Config", ")", "*", "html", ".", "Engine", "{", "c", ":=", "DefaultConfig", "(", ")", "\n", "if", "len", "(", "cfg", ")", ">", "0", "{", "c", "=", "cfg", "[", "0", "]", "\n", "}", "\n", "// pass the Pug/Jade conf...
// New creates and returns the Pug template engine
[ "New", "creates", "and", "returns", "the", "Pug", "template", "engine" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/pug/pug.go#L10-L20
132,505
kataras/go-template
django/django.go
convertFilters
func (p *Engine) convertFilters() map[string]pongo2.FilterFunction { filters := make(map[string]pongo2.FilterFunction, len(p.Config.Filters)) for k, v := range p.Config.Filters { func(filterName string, filterFunc FilterFunction) { fn := pongo2.FilterFunction(func(in *pongo2.Value, param *pongo2.Value) (*pongo2....
go
func (p *Engine) convertFilters() map[string]pongo2.FilterFunction { filters := make(map[string]pongo2.FilterFunction, len(p.Config.Filters)) for k, v := range p.Config.Filters { func(filterName string, filterFunc FilterFunction) { fn := pongo2.FilterFunction(func(in *pongo2.Value, param *pongo2.Value) (*pongo2....
[ "func", "(", "p", "*", "Engine", ")", "convertFilters", "(", ")", "map", "[", "string", "]", "pongo2", ".", "FilterFunction", "{", "filters", ":=", "make", "(", "map", "[", "string", "]", "pongo2", ".", "FilterFunction", ",", "len", "(", "p", ".", "C...
// this exists because of moving the pongo2 to the vendors without conflictitions if users // wants to register pongo2 filters they can use this django.FilterFunc to do so.
[ "this", "exists", "because", "of", "moving", "the", "pongo2", "to", "the", "vendors", "without", "conflictitions", "if", "users", "wants", "to", "register", "pongo2", "filters", "they", "can", "use", "this", "django", ".", "FilterFunc", "to", "do", "so", "."...
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/django/django.go#L56-L68
132,506
kataras/go-template
django/django.go
ExecuteWriter
func (p *Engine) ExecuteWriter(out io.Writer, name string, binding interface{}, options ...map[string]interface{}) error { if tmpl := p.fromCache(name); tmpl != nil { return tmpl.ExecuteWriter(getPongoContext(binding), out) } return fmt.Errorf("[IRIS TEMPLATES] Template with name %s doesn't exists in the dir", na...
go
func (p *Engine) ExecuteWriter(out io.Writer, name string, binding interface{}, options ...map[string]interface{}) error { if tmpl := p.fromCache(name); tmpl != nil { return tmpl.ExecuteWriter(getPongoContext(binding), out) } return fmt.Errorf("[IRIS TEMPLATES] Template with name %s doesn't exists in the dir", na...
[ "func", "(", "p", "*", "Engine", ")", "ExecuteWriter", "(", "out", "io", ".", "Writer", ",", "name", "string", ",", "binding", "interface", "{", "}", ",", "options", "...", "map", "[", "string", "]", "interface", "{", "}", ")", "error", "{", "if", ...
// ExecuteWriter executes a templates and write its results to the out writer // layout here is useless
[ "ExecuteWriter", "executes", "a", "templates", "and", "write", "its", "results", "to", "the", "out", "writer", "layout", "here", "is", "useless" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/django/django.go#L217-L223
132,507
kataras/go-template
html/config.go
DefaultConfig
func DefaultConfig() Config { return Config{ Left: "{{", Right: "}}", Layout: "", Funcs: make(map[string]interface{}, 0), LayoutFuncs: make(map[string]interface{}, 0), } }
go
func DefaultConfig() Config { return Config{ Left: "{{", Right: "}}", Layout: "", Funcs: make(map[string]interface{}, 0), LayoutFuncs: make(map[string]interface{}, 0), } }
[ "func", "DefaultConfig", "(", ")", "Config", "{", "return", "Config", "{", "Left", ":", "\"", "\"", ",", "Right", ":", "\"", "\"", ",", "Layout", ":", "\"", "\"", ",", "Funcs", ":", "make", "(", "map", "[", "string", "]", "interface", "{", "}", "...
// DefaultConfig returns the default configs for the html template engine
[ "DefaultConfig", "returns", "the", "default", "configs", "for", "the", "html", "template", "engine" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/html/config.go#L13-L21
132,508
kataras/go-template
engine.go
GetGzipOption
func GetGzipOption(defaultValue bool, options map[string]interface{}) bool { gzipOpt := options["gzip"] // we only need that, so don't create new map to keep the options. if b, isBool := gzipOpt.(bool); isBool { return b } return defaultValue }
go
func GetGzipOption(defaultValue bool, options map[string]interface{}) bool { gzipOpt := options["gzip"] // we only need that, so don't create new map to keep the options. if b, isBool := gzipOpt.(bool); isBool { return b } return defaultValue }
[ "func", "GetGzipOption", "(", "defaultValue", "bool", ",", "options", "map", "[", "string", "]", "interface", "{", "}", ")", "bool", "{", "gzipOpt", ":=", "options", "[", "\"", "\"", "]", "// we only need that, so don't create new map to keep the options.", "\n", ...
// GetGzipOption receives a default value and the render options map and returns if gzip is enabled for this render action
[ "GetGzipOption", "receives", "a", "default", "value", "and", "the", "render", "options", "map", "and", "returns", "if", "gzip", "is", "enabled", "for", "this", "render", "action" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/engine.go#L45-L51
132,509
kataras/go-template
engine.go
GetCharsetOption
func GetCharsetOption(defaultValue string, options map[string]interface{}) string { charsetOpt := options["charset"] if s, isString := charsetOpt.(string); isString { return s } return defaultValue }
go
func GetCharsetOption(defaultValue string, options map[string]interface{}) string { charsetOpt := options["charset"] if s, isString := charsetOpt.(string); isString { return s } return defaultValue }
[ "func", "GetCharsetOption", "(", "defaultValue", "string", ",", "options", "map", "[", "string", "]", "interface", "{", "}", ")", "string", "{", "charsetOpt", ":=", "options", "[", "\"", "\"", "]", "\n", "if", "s", ",", "isString", ":=", "charsetOpt", "....
// GetCharsetOption receives a default value and the render options map and returns the correct charset for this render action
[ "GetCharsetOption", "receives", "a", "default", "value", "and", "the", "render", "options", "map", "and", "returns", "the", "correct", "charset", "for", "this", "render", "action" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/engine.go#L54-L60
132,510
kataras/go-template
html/html.go
New
func New(cfg ...Config) *Engine { c := DefaultConfig() if len(cfg) > 0 { c = cfg[0] } // cuz mergo has a little bug on maps if c.Funcs == nil { c.Funcs = make(map[string]interface{}, 0) } if c.LayoutFuncs == nil { c.LayoutFuncs = make(map[string]interface{}, 0) } e := &Engine{Config: c} return e }
go
func New(cfg ...Config) *Engine { c := DefaultConfig() if len(cfg) > 0 { c = cfg[0] } // cuz mergo has a little bug on maps if c.Funcs == nil { c.Funcs = make(map[string]interface{}, 0) } if c.LayoutFuncs == nil { c.LayoutFuncs = make(map[string]interface{}, 0) } e := &Engine{Config: c} return e }
[ "func", "New", "(", "cfg", "...", "Config", ")", "*", "Engine", "{", "c", ":=", "DefaultConfig", "(", ")", "\n", "if", "len", "(", "cfg", ")", ">", "0", "{", "c", "=", "cfg", "[", "0", "]", "\n", "}", "\n", "// cuz mergo has a little bug on maps", ...
// New creates and returns the HTMLTemplate template engine
[ "New", "creates", "and", "returns", "the", "HTMLTemplate", "template", "engine" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/html/html.go#L48-L62
132,511
kataras/go-template
markdown/markdown.go
LoadDirectory
func (e *Engine) LoadDirectory(dir string, extension string) error { e.mu.Lock() defer e.mu.Unlock() var templateErr error // Walk the supplied directory and compile any files that match our extension list. filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { if info == nil || info.IsDir() ...
go
func (e *Engine) LoadDirectory(dir string, extension string) error { e.mu.Lock() defer e.mu.Unlock() var templateErr error // Walk the supplied directory and compile any files that match our extension list. filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { if info == nil || info.IsDir() ...
[ "func", "(", "e", "*", "Engine", ")", "LoadDirectory", "(", "dir", "string", ",", "extension", "string", ")", "error", "{", "e", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "e", ".", "mu", ".", "Unlock", "(", ")", "\n", "var", "templateErr", ...
// LoadDirectory builds the markdown templates
[ "LoadDirectory", "builds", "the", "markdown", "templates" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/markdown/markdown.go#L38-L83
132,512
micro/util
go/lib/addr/addr.go
IPs
func IPs() []string { ifaces, err := net.Interfaces() if err != nil { return nil } var ipAddrs []string for _, i := range ifaces { addrs, err := i.Addrs() if err != nil { continue } for _, addr := range addrs { var ip net.IP switch v := addr.(type) { case *net.IPNet: ip = v.IP case ...
go
func IPs() []string { ifaces, err := net.Interfaces() if err != nil { return nil } var ipAddrs []string for _, i := range ifaces { addrs, err := i.Addrs() if err != nil { continue } for _, addr := range addrs { var ip net.IP switch v := addr.(type) { case *net.IPNet: ip = v.IP case ...
[ "func", "IPs", "(", ")", "[", "]", "string", "{", "ifaces", ",", "err", ":=", "net", ".", "Interfaces", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", "\n", "}", "\n\n", "var", "ipAddrs", "[", "]", "string", "\n\n", "for", "_", ...
// IPs returns all known ips
[ "IPs", "returns", "all", "known", "ips" ]
b9d497e656ef2a7ae781bd909cfc938144a653ff
https://github.com/micro/util/blob/b9d497e656ef2a7ae781bd909cfc938144a653ff/go/lib/addr/addr.go#L83-L120
132,513
cloudfoundry/dropsonde
dropsonde_marshaller/dropsonde_marshaller.go
NewDropsondeMarshaller
func NewDropsondeMarshaller(logger *gosteno.Logger) *DropsondeMarshaller { messageCounts := make(map[events.Envelope_EventType]*uint64) for key := range events.Envelope_EventType_name { var count uint64 messageCounts[events.Envelope_EventType(key)] = &count } return &DropsondeMarshaller{ logger: logger...
go
func NewDropsondeMarshaller(logger *gosteno.Logger) *DropsondeMarshaller { messageCounts := make(map[events.Envelope_EventType]*uint64) for key := range events.Envelope_EventType_name { var count uint64 messageCounts[events.Envelope_EventType(key)] = &count } return &DropsondeMarshaller{ logger: logger...
[ "func", "NewDropsondeMarshaller", "(", "logger", "*", "gosteno", ".", "Logger", ")", "*", "DropsondeMarshaller", "{", "messageCounts", ":=", "make", "(", "map", "[", "events", ".", "Envelope_EventType", "]", "*", "uint64", ")", "\n", "for", "key", ":=", "ran...
// NewDropsondeMarshaller instantiates a DropsondeMarshaller and logs to the // provided logger.
[ "NewDropsondeMarshaller", "instantiates", "a", "DropsondeMarshaller", "and", "logs", "to", "the", "provided", "logger", "." ]
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/dropsonde_marshaller/dropsonde_marshaller.go#L50-L60
132,514
cloudfoundry/dropsonde
dropsonde_marshaller/dropsonde_marshaller.go
Run
func (u *DropsondeMarshaller) Run(inputChan <-chan *events.Envelope, outputChan chan<- []byte) { for message := range inputChan { messageBytes, err := proto.Marshal(message) if err != nil { u.logger.Errorf("dropsondeMarshaller: marshal error %v", err) metrics.BatchIncrementCounter("dropsondeMarshaller.marsh...
go
func (u *DropsondeMarshaller) Run(inputChan <-chan *events.Envelope, outputChan chan<- []byte) { for message := range inputChan { messageBytes, err := proto.Marshal(message) if err != nil { u.logger.Errorf("dropsondeMarshaller: marshal error %v", err) metrics.BatchIncrementCounter("dropsondeMarshaller.marsh...
[ "func", "(", "u", "*", "DropsondeMarshaller", ")", "Run", "(", "inputChan", "<-", "chan", "*", "events", ".", "Envelope", ",", "outputChan", "chan", "<-", "[", "]", "byte", ")", "{", "for", "message", ":=", "range", "inputChan", "{", "messageBytes", ",",...
// Run reads Envelopes from inputChan, marshals them to Protocol Buffer format, // and emits the binary messages onto outputChan. It operates one message at a // time, and will block if outputChan is not read.
[ "Run", "reads", "Envelopes", "from", "inputChan", "marshals", "them", "to", "Protocol", "Buffer", "format", "and", "emits", "the", "binary", "messages", "onto", "outputChan", ".", "It", "operates", "one", "message", "at", "a", "time", "and", "will", "block", ...
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/dropsonde_marshaller/dropsonde_marshaller.go#L65-L78
132,515
cloudfoundry/dropsonde
signature/signature_verifier.go
SignMessage
func SignMessage(message, secret []byte) []byte { signature := generateSignature(message, secret) return append(signature, message...) }
go
func SignMessage(message, secret []byte) []byte { signature := generateSignature(message, secret) return append(signature, message...) }
[ "func", "SignMessage", "(", "message", ",", "secret", "[", "]", "byte", ")", "[", "]", "byte", "{", "signature", ":=", "generateSignature", "(", "message", ",", "secret", ")", "\n", "return", "append", "(", "signature", ",", "message", "...", ")", "\n", ...
// SignMessage returns a message signed with the provided secret, with the // signature prepended to the original message.
[ "SignMessage", "returns", "a", "message", "signed", "with", "the", "provided", "secret", "with", "the", "signature", "prepended", "to", "the", "original", "message", "." ]
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/signature/signature_verifier.go#L63-L66
132,516
cloudfoundry/dropsonde
metricbatcher/metricbatcher.go
New
func New(metricSender MetricSender, batchDuration time.Duration) *MetricBatcher { mb := &MetricBatcher{ batchTicker: time.NewTicker(batchDuration), metricSender: metricSender, closed: false, closedChan: make(chan struct{}), } go func() { for { select { case <-mb.batchTicker.C: mb.flush(...
go
func New(metricSender MetricSender, batchDuration time.Duration) *MetricBatcher { mb := &MetricBatcher{ batchTicker: time.NewTicker(batchDuration), metricSender: metricSender, closed: false, closedChan: make(chan struct{}), } go func() { for { select { case <-mb.batchTicker.C: mb.flush(...
[ "func", "New", "(", "metricSender", "MetricSender", ",", "batchDuration", "time", ".", "Duration", ")", "*", "MetricBatcher", "{", "mb", ":=", "&", "MetricBatcher", "{", "batchTicker", ":", "time", ".", "NewTicker", "(", "batchDuration", ")", ",", "metricSende...
// New instantiates a running MetricBatcher. Eventswill be emitted once per batchDuration. All // updates to a given counter name will be combined into a single event and sent to metricSender.
[ "New", "instantiates", "a", "running", "MetricBatcher", ".", "Eventswill", "be", "emitted", "once", "per", "batchDuration", ".", "All", "updates", "to", "a", "given", "counter", "name", "will", "be", "combined", "into", "a", "single", "event", "and", "sent", ...
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/metricbatcher/metricbatcher.go#L36-L57
132,517
cloudfoundry/dropsonde
metricbatcher/metricbatcher.go
BatchAddCounter
func (mb *MetricBatcher) BatchAddCounter(name string, delta uint64) { mb.lock.Lock() defer mb.lock.Unlock() if mb.closed { panic("Attempting to send metrics after closed") } mb.add(batch{name: name, value: delta}) }
go
func (mb *MetricBatcher) BatchAddCounter(name string, delta uint64) { mb.lock.Lock() defer mb.lock.Unlock() if mb.closed { panic("Attempting to send metrics after closed") } mb.add(batch{name: name, value: delta}) }
[ "func", "(", "mb", "*", "MetricBatcher", ")", "BatchAddCounter", "(", "name", "string", ",", "delta", "uint64", ")", "{", "mb", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "mb", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "if", "mb", ".", ...
// BatchAddCounter increments the named counter by the provided delta, but does not // immediately send a CounterEvent.
[ "BatchAddCounter", "increments", "the", "named", "counter", "by", "the", "provided", "delta", "but", "does", "not", "immediately", "send", "a", "CounterEvent", "." ]
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/metricbatcher/metricbatcher.go#L67-L76
132,518
cloudfoundry/dropsonde
metricbatcher/metricbatcher.go
BatchCounter
func (mb *MetricBatcher) BatchCounter(name string) BatchCounterChainer { return batchCounterChainer{ batcher: mb, name: name, tags: make(map[string]string), } }
go
func (mb *MetricBatcher) BatchCounter(name string) BatchCounterChainer { return batchCounterChainer{ batcher: mb, name: name, tags: make(map[string]string), } }
[ "func", "(", "mb", "*", "MetricBatcher", ")", "BatchCounter", "(", "name", "string", ")", "BatchCounterChainer", "{", "return", "batchCounterChainer", "{", "batcher", ":", "mb", ",", "name", ":", "name", ",", "tags", ":", "make", "(", "map", "[", "string",...
// BatchCounter returns a BatchCounterChainer which can be used to prepare // a counter event before batching it up.
[ "BatchCounter", "returns", "a", "BatchCounterChainer", "which", "can", "be", "used", "to", "prepare", "a", "counter", "event", "before", "batching", "it", "up", "." ]
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/metricbatcher/metricbatcher.go#L104-L110
132,519
cloudfoundry/dropsonde
metricbatcher/metricbatcher.go
Close
func (mb *MetricBatcher) Close() { mb.lock.Lock() defer mb.lock.Unlock() mb.closed = true close(mb.closedChan) mb.flush(mb.unsafeResetAndReturnMetrics()) }
go
func (mb *MetricBatcher) Close() { mb.lock.Lock() defer mb.lock.Unlock() mb.closed = true close(mb.closedChan) mb.flush(mb.unsafeResetAndReturnMetrics()) }
[ "func", "(", "mb", "*", "MetricBatcher", ")", "Close", "(", ")", "{", "mb", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "mb", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "mb", ".", "closed", "=", "true", "\n", "close", "(", "mb", ".", ...
// Closes the metrics batcher. Using the batcher after closing, will cause a panic.
[ "Closes", "the", "metrics", "batcher", ".", "Using", "the", "batcher", "after", "closing", "will", "cause", "a", "panic", "." ]
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/metricbatcher/metricbatcher.go#L118-L126
132,520
cloudfoundry/dropsonde
metric_sender/metric_sender.go
Send
func (ms *MetricSender) Send(ev events.Event) error { return ms.eventEmitter.Emit(ev) }
go
func (ms *MetricSender) Send(ev events.Event) error { return ms.eventEmitter.Emit(ev) }
[ "func", "(", "ms", "*", "MetricSender", ")", "Send", "(", "ev", "events", ".", "Event", ")", "error", "{", "return", "ms", ".", "eventEmitter", ".", "Emit", "(", "ev", ")", "\n", "}" ]
// Send sends an events.Event.
[ "Send", "sends", "an", "events", ".", "Event", "." ]
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/metric_sender/metric_sender.go#L50-L52
132,521
cloudfoundry/dropsonde
logs/logs.go
SendAppLog
func SendAppLog(appID, message, sourceType, sourceInstance string) error { if logSender == nil { return nil } return logSender.SendAppLog(appID, message, sourceType, sourceInstance) }
go
func SendAppLog(appID, message, sourceType, sourceInstance string) error { if logSender == nil { return nil } return logSender.SendAppLog(appID, message, sourceType, sourceInstance) }
[ "func", "SendAppLog", "(", "appID", ",", "message", ",", "sourceType", ",", "sourceInstance", "string", ")", "error", "{", "if", "logSender", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "logSender", ".", "SendAppLog", "(", "appID", ",", ...
// SendAppLog sends a log message with the given appid, log message, source type // and source instance, with a message type of std out. // Returns an error if one occurs while sending the event.
[ "SendAppLog", "sends", "a", "log", "message", "with", "the", "given", "appid", "log", "message", "source", "type", "and", "source", "instance", "with", "a", "message", "type", "of", "std", "out", ".", "Returns", "an", "error", "if", "one", "occurs", "while...
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/logs/logs.go#L44-L49
132,522
cloudfoundry/dropsonde
dropsonde_unmarshaller/dropsonde_unmarshaller.go
Run
func (u *DropsondeUnmarshaller) Run(inputChan <-chan []byte, outputChan chan<- *events.Envelope) { for message := range inputChan { envelope, err := u.UnmarshallMessage(message) if err != nil { continue } outputChan <- envelope } }
go
func (u *DropsondeUnmarshaller) Run(inputChan <-chan []byte, outputChan chan<- *events.Envelope) { for message := range inputChan { envelope, err := u.UnmarshallMessage(message) if err != nil { continue } outputChan <- envelope } }
[ "func", "(", "u", "*", "DropsondeUnmarshaller", ")", "Run", "(", "inputChan", "<-", "chan", "[", "]", "byte", ",", "outputChan", "chan", "<-", "*", "events", ".", "Envelope", ")", "{", "for", "message", ":=", "range", "inputChan", "{", "envelope", ",", ...
// Run reads byte slices from inputChan, unmarshalls them to Envelopes, and // emits the Envelopes onto outputChan. It operates one message at a time, and // will block if outputChan is not read.
[ "Run", "reads", "byte", "slices", "from", "inputChan", "unmarshalls", "them", "to", "Envelopes", "and", "emits", "the", "Envelopes", "onto", "outputChan", ".", "It", "operates", "one", "message", "at", "a", "time", "and", "will", "block", "if", "outputChan", ...
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/dropsonde_unmarshaller/dropsonde_unmarshaller.go#L53-L61
132,523
cloudfoundry/dropsonde
instrumented_handler/instrumented_handler.go
InstrumentedHandler
func InstrumentedHandler(handler http.Handler, emitter EventEmitter) http.Handler { return &instrumentedHandler{handler, emitter} }
go
func InstrumentedHandler(handler http.Handler, emitter EventEmitter) http.Handler { return &instrumentedHandler{handler, emitter} }
[ "func", "InstrumentedHandler", "(", "handler", "http", ".", "Handler", ",", "emitter", "EventEmitter", ")", "http", ".", "Handler", "{", "return", "&", "instrumentedHandler", "{", "handler", ",", "emitter", "}", "\n", "}" ]
// InstrumentedHandler is a helper for creating an instrumented http.Handler // which will delegate to the given http.Handler.
[ "InstrumentedHandler", "is", "a", "helper", "for", "creating", "an", "instrumented", "http", ".", "Handler", "which", "will", "delegate", "to", "the", "given", "http", ".", "Handler", "." ]
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/instrumented_handler/instrumented_handler.go#L27-L29
132,524
cloudfoundry/dropsonde
dropsonde.go
Initialize
func Initialize(destination string, origin ...string) error { emitter, err := createDefaultEmitter(strings.Join(origin, originDelimiter), destination) if err != nil { DefaultEmitter = &NullEventEmitter{} return err } DefaultEmitter = emitter initialize() return nil }
go
func Initialize(destination string, origin ...string) error { emitter, err := createDefaultEmitter(strings.Join(origin, originDelimiter), destination) if err != nil { DefaultEmitter = &NullEventEmitter{} return err } DefaultEmitter = emitter initialize() return nil }
[ "func", "Initialize", "(", "destination", "string", ",", "origin", "...", "string", ")", "error", "{", "emitter", ",", "err", ":=", "createDefaultEmitter", "(", "strings", ".", "Join", "(", "origin", ",", "originDelimiter", ")", ",", "destination", ")", "\n"...
// Initialize creates default emitters and instruments the default HTTP // transport. // // The origin variable is required and specifies the // source name for all metrics emitted by this process. If it is not set, the // program will run normally but will not emit metrics. // // The destination variable sets the host...
[ "Initialize", "creates", "default", "emitters", "and", "instruments", "the", "default", "HTTP", "transport", ".", "The", "origin", "variable", "is", "required", "and", "specifies", "the", "source", "name", "for", "all", "metrics", "emitted", "by", "this", "proce...
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/dropsonde.go#L59-L70
132,525
cloudfoundry/dropsonde
dropsonde.go
InstrumentedHandler
func InstrumentedHandler(handler http.Handler) http.Handler { return instrumented_handler.InstrumentedHandler(handler, DefaultEmitter) }
go
func InstrumentedHandler(handler http.Handler) http.Handler { return instrumented_handler.InstrumentedHandler(handler, DefaultEmitter) }
[ "func", "InstrumentedHandler", "(", "handler", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "return", "instrumented_handler", ".", "InstrumentedHandler", "(", "handler", ",", "DefaultEmitter", ")", "\n", "}" ]
// InstrumentedHandler returns a Handler pre-configured to emit HTTP server // request metrics to AutowiredEmitter.
[ "InstrumentedHandler", "returns", "a", "Handler", "pre", "-", "configured", "to", "emit", "HTTP", "server", "request", "metrics", "to", "AutowiredEmitter", "." ]
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/dropsonde.go#L86-L88
132,526
cloudfoundry/dropsonde
dropsonde.go
InstrumentedRoundTripper
func InstrumentedRoundTripper(roundTripper http.RoundTripper) http.RoundTripper { return instrumented_round_tripper.InstrumentedRoundTripper(roundTripper, DefaultEmitter) }
go
func InstrumentedRoundTripper(roundTripper http.RoundTripper) http.RoundTripper { return instrumented_round_tripper.InstrumentedRoundTripper(roundTripper, DefaultEmitter) }
[ "func", "InstrumentedRoundTripper", "(", "roundTripper", "http", ".", "RoundTripper", ")", "http", ".", "RoundTripper", "{", "return", "instrumented_round_tripper", ".", "InstrumentedRoundTripper", "(", "roundTripper", ",", "DefaultEmitter", ")", "\n", "}" ]
// InstrumentedRoundTripper returns a RoundTripper pre-configured to emit // HTTP client request metrics to AutowiredEmitter.
[ "InstrumentedRoundTripper", "returns", "a", "RoundTripper", "pre", "-", "configured", "to", "emit", "HTTP", "client", "request", "metrics", "to", "AutowiredEmitter", "." ]
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/dropsonde.go#L92-L94
132,527
cloudfoundry/dropsonde
envelopes/envelopes.go
SendEnvelope
func SendEnvelope(envelope *events.Envelope) error { if envelopeSender == nil { return nil } return envelopeSender.SendEnvelope(envelope) }
go
func SendEnvelope(envelope *events.Envelope) error { if envelopeSender == nil { return nil } return envelopeSender.SendEnvelope(envelope) }
[ "func", "SendEnvelope", "(", "envelope", "*", "events", ".", "Envelope", ")", "error", "{", "if", "envelopeSender", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "envelopeSender", ".", "SendEnvelope", "(", "envelope", ")", "\n", "}" ]
// SendEnvelope sends the given Envelope.
[ "SendEnvelope", "sends", "the", "given", "Envelope", "." ]
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/envelopes/envelopes.go#L29-L34
132,528
cloudfoundry/dropsonde
log_sender/log_sender.go
SendAppLog
func (l *LogSender) SendAppLog(appID, message, sourceType, sourceInstance string) error { metrics.BatchIncrementCounter("logSenderTotalMessagesRead") return l.eventEmitter.Emit(makeLogMessage(appID, message, sourceType, sourceInstance, events.LogMessage_OUT)) }
go
func (l *LogSender) SendAppLog(appID, message, sourceType, sourceInstance string) error { metrics.BatchIncrementCounter("logSenderTotalMessagesRead") return l.eventEmitter.Emit(makeLogMessage(appID, message, sourceType, sourceInstance, events.LogMessage_OUT)) }
[ "func", "(", "l", "*", "LogSender", ")", "SendAppLog", "(", "appID", ",", "message", ",", "sourceType", ",", "sourceInstance", "string", ")", "error", "{", "metrics", ".", "BatchIncrementCounter", "(", "\"", "\"", ")", "\n", "return", "l", ".", "eventEmitt...
// SendAppLog sends a log message with the given appid and log message // with a message type of std out. // Returns an error if one occurs while sending the event.
[ "SendAppLog", "sends", "a", "log", "message", "with", "the", "given", "appid", "and", "log", "message", "with", "a", "message", "type", "of", "std", "out", ".", "Returns", "an", "error", "if", "one", "occurs", "while", "sending", "the", "event", "." ]
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/log_sender/log_sender.go#L53-L56
132,529
cloudfoundry/dropsonde
log_sender/log_sender.go
SendAppErrorLog
func (l *LogSender) SendAppErrorLog(appID, message, sourceType, sourceInstance string) error { metrics.BatchIncrementCounter("logSenderTotalMessagesRead") return l.eventEmitter.Emit(makeLogMessage(appID, message, sourceType, sourceInstance, events.LogMessage_ERR)) }
go
func (l *LogSender) SendAppErrorLog(appID, message, sourceType, sourceInstance string) error { metrics.BatchIncrementCounter("logSenderTotalMessagesRead") return l.eventEmitter.Emit(makeLogMessage(appID, message, sourceType, sourceInstance, events.LogMessage_ERR)) }
[ "func", "(", "l", "*", "LogSender", ")", "SendAppErrorLog", "(", "appID", ",", "message", ",", "sourceType", ",", "sourceInstance", "string", ")", "error", "{", "metrics", ".", "BatchIncrementCounter", "(", "\"", "\"", ")", "\n", "return", "l", ".", "event...
// SendAppErrorLog sends a log error message with the given appid and log message // with a message type of std err. // Returns an error if one occurs while sending the event.
[ "SendAppErrorLog", "sends", "a", "log", "error", "message", "with", "the", "given", "appid", "and", "log", "message", "with", "a", "message", "type", "of", "std", "err", ".", "Returns", "an", "error", "if", "one", "occurs", "while", "sending", "the", "even...
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/log_sender/log_sender.go#L61-L64
132,530
cloudfoundry/dropsonde
log_sender/log_sender.go
ScanErrorLogStream
func (l *LogSender) ScanErrorLogStream(appID, sourceType, sourceInstance string, reader io.Reader) { l.scanLogStream(appID, sourceType, sourceInstance, l.SendAppErrorLog, reader) }
go
func (l *LogSender) ScanErrorLogStream(appID, sourceType, sourceInstance string, reader io.Reader) { l.scanLogStream(appID, sourceType, sourceInstance, l.SendAppErrorLog, reader) }
[ "func", "(", "l", "*", "LogSender", ")", "ScanErrorLogStream", "(", "appID", ",", "sourceType", ",", "sourceInstance", "string", ",", "reader", "io", ".", "Reader", ")", "{", "l", ".", "scanLogStream", "(", "appID", ",", "sourceType", ",", "sourceInstance", ...
// ScanErrorLogStream sends a log error message with the given meta-data for each line from reader. // Restarts on read errors and continues until EOF.
[ "ScanErrorLogStream", "sends", "a", "log", "error", "message", "with", "the", "given", "meta", "-", "data", "for", "each", "line", "from", "reader", ".", "Restarts", "on", "read", "errors", "and", "continues", "until", "EOF", "." ]
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/log_sender/log_sender.go#L74-L76
132,531
cloudfoundry/dropsonde
log_sender/log_sender.go
Send
func (c logChainer) Send() error { if c.err != nil { return c.err } metrics.BatchIncrementCounter("logSenderTotalMessagesRead") c.envelope.Timestamp = proto.Int64(time.Now().UnixNano()) if c.envelope.LogMessage.Timestamp == nil { c.envelope.LogMessage.Timestamp = proto.Int64(time.Now().UnixNano()) } retur...
go
func (c logChainer) Send() error { if c.err != nil { return c.err } metrics.BatchIncrementCounter("logSenderTotalMessagesRead") c.envelope.Timestamp = proto.Int64(time.Now().UnixNano()) if c.envelope.LogMessage.Timestamp == nil { c.envelope.LogMessage.Timestamp = proto.Int64(time.Now().UnixNano()) } retur...
[ "func", "(", "c", "logChainer", ")", "Send", "(", ")", "error", "{", "if", "c", ".", "err", "!=", "nil", "{", "return", "c", ".", "err", "\n", "}", "\n\n", "metrics", ".", "BatchIncrementCounter", "(", "\"", "\"", ")", "\n\n", "c", ".", "envelope",...
// Send sends the log message with the envelope timestamp set to now and the // log message timestamp set to now if none was provided by SetTimestamp.
[ "Send", "sends", "the", "log", "message", "with", "the", "envelope", "timestamp", "set", "to", "now", "and", "the", "log", "message", "timestamp", "set", "to", "now", "if", "none", "was", "provided", "by", "SetTimestamp", "." ]
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/log_sender/log_sender.go#L201-L214
132,532
cloudfoundry/dropsonde
dropsonde_unmarshaller/dropsonde_unmarshaller_collection.go
NewDropsondeUnmarshallerCollection
func NewDropsondeUnmarshallerCollection(size int) *DropsondeUnmarshallerCollection { var unmarshallers []*DropsondeUnmarshaller for i := 0; i < size; i++ { unmarshallers = append(unmarshallers, NewDropsondeUnmarshaller()) } log.Printf("dropsondeUnmarshallerCollection: created %v unmarshallers", size) return &D...
go
func NewDropsondeUnmarshallerCollection(size int) *DropsondeUnmarshallerCollection { var unmarshallers []*DropsondeUnmarshaller for i := 0; i < size; i++ { unmarshallers = append(unmarshallers, NewDropsondeUnmarshaller()) } log.Printf("dropsondeUnmarshallerCollection: created %v unmarshallers", size) return &D...
[ "func", "NewDropsondeUnmarshallerCollection", "(", "size", "int", ")", "*", "DropsondeUnmarshallerCollection", "{", "var", "unmarshallers", "[", "]", "*", "DropsondeUnmarshaller", "\n", "for", "i", ":=", "0", ";", "i", "<", "size", ";", "i", "++", "{", "unmars...
// NewDropsondeUnmarshallerCollection instantiates a DropsondeUnmarshallerCollection, // creates the specified number of DropsondeUnmarshaller instances.
[ "NewDropsondeUnmarshallerCollection", "instantiates", "a", "DropsondeUnmarshallerCollection", "creates", "the", "specified", "number", "of", "DropsondeUnmarshaller", "instances", "." ]
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/dropsonde_unmarshaller/dropsonde_unmarshaller_collection.go#L17-L28
132,533
cloudfoundry/dropsonde
dropsonde_unmarshaller/dropsonde_unmarshaller_collection.go
Run
func (u *DropsondeUnmarshallerCollection) Run(inputChan <-chan []byte, outputChan chan<- *events.Envelope, waitGroup *sync.WaitGroup) { for _, unmarshaller := range u.unmarshallers { go func(um *DropsondeUnmarshaller) { defer waitGroup.Done() um.Run(inputChan, outputChan) }(unmarshaller) } }
go
func (u *DropsondeUnmarshallerCollection) Run(inputChan <-chan []byte, outputChan chan<- *events.Envelope, waitGroup *sync.WaitGroup) { for _, unmarshaller := range u.unmarshallers { go func(um *DropsondeUnmarshaller) { defer waitGroup.Done() um.Run(inputChan, outputChan) }(unmarshaller) } }
[ "func", "(", "u", "*", "DropsondeUnmarshallerCollection", ")", "Run", "(", "inputChan", "<-", "chan", "[", "]", "byte", ",", "outputChan", "chan", "<-", "*", "events", ".", "Envelope", ",", "waitGroup", "*", "sync", ".", "WaitGroup", ")", "{", "for", "_"...
// Run calls Run on each marshaller in its collection. // This is done in separate go routines.
[ "Run", "calls", "Run", "on", "each", "marshaller", "in", "its", "collection", ".", "This", "is", "done", "in", "separate", "go", "routines", "." ]
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/dropsonde_unmarshaller/dropsonde_unmarshaller_collection.go#L37-L44
132,534
cloudfoundry/dropsonde
envelope_sender/envelope_sender.go
SendEnvelope
func (ms *EnvelopeSender) SendEnvelope(envelope *events.Envelope) error { return ms.emitter.EmitEnvelope(envelope) }
go
func (ms *EnvelopeSender) SendEnvelope(envelope *events.Envelope) error { return ms.emitter.EmitEnvelope(envelope) }
[ "func", "(", "ms", "*", "EnvelopeSender", ")", "SendEnvelope", "(", "envelope", "*", "events", ".", "Envelope", ")", "error", "{", "return", "ms", ".", "emitter", ".", "EmitEnvelope", "(", "envelope", ")", "\n", "}" ]
// SendEnvelope sends the given envelope. // Returns an error if one occurs while sending the envelope.
[ "SendEnvelope", "sends", "the", "given", "envelope", ".", "Returns", "an", "error", "if", "one", "occurs", "while", "sending", "the", "envelope", "." ]
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/envelope_sender/envelope_sender.go#L21-L23
132,535
cloudfoundry/dropsonde
metrics/metrics.go
Initialize
func Initialize(ms MetricSender, mb MetricBatcher) { if metricBatcher != nil { metricBatcher.Close() } metricSender = ms metricBatcher = mb }
go
func Initialize(ms MetricSender, mb MetricBatcher) { if metricBatcher != nil { metricBatcher.Close() } metricSender = ms metricBatcher = mb }
[ "func", "Initialize", "(", "ms", "MetricSender", ",", "mb", "MetricBatcher", ")", "{", "if", "metricBatcher", "!=", "nil", "{", "metricBatcher", ".", "Close", "(", ")", "\n", "}", "\n", "metricSender", "=", "ms", "\n", "metricBatcher", "=", "mb", "\n", "...
// Initialize prepares the metrics package for use with the automatic Emitter.
[ "Initialize", "prepares", "the", "metrics", "package", "for", "use", "with", "the", "automatic", "Emitter", "." ]
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/metrics/metrics.go#L58-L64
132,536
cloudfoundry/dropsonde
metrics/metrics.go
IncrementCounter
func IncrementCounter(name string) error { if metricSender == nil { return nil } return metricSender.IncrementCounter(name) }
go
func IncrementCounter(name string) error { if metricSender == nil { return nil } return metricSender.IncrementCounter(name) }
[ "func", "IncrementCounter", "(", "name", "string", ")", "error", "{", "if", "metricSender", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "metricSender", ".", "IncrementCounter", "(", "name", ")", "\n", "}" ]
// IncrementCounter sends an event to increment the named counter by one. // Maintaining the value of the counter is the responsibility of the receiver of // the event, not the process that includes this package.
[ "IncrementCounter", "sends", "an", "event", "to", "increment", "the", "named", "counter", "by", "one", ".", "Maintaining", "the", "value", "of", "the", "counter", "is", "the", "responsibility", "of", "the", "receiver", "of", "the", "event", "not", "the", "pr...
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/metrics/metrics.go#L88-L93
132,537
cloudfoundry/dropsonde
metrics/metrics.go
BatchAddCounter
func BatchAddCounter(name string, delta uint64) { if metricBatcher == nil { return } metricBatcher.BatchAddCounter(name, delta) }
go
func BatchAddCounter(name string, delta uint64) { if metricBatcher == nil { return } metricBatcher.BatchAddCounter(name, delta) }
[ "func", "BatchAddCounter", "(", "name", "string", ",", "delta", "uint64", ")", "{", "if", "metricBatcher", "==", "nil", "{", "return", "\n", "}", "\n", "metricBatcher", ".", "BatchAddCounter", "(", "name", ",", "delta", ")", "\n", "}" ]
// BatchAddCounter adds delta to a counter but, unlike AddCounter, does not emit a // CounterEvent for each add; instead, the adds are batched and a single CounterEvent // is sent after the timeout.
[ "BatchAddCounter", "adds", "delta", "to", "a", "counter", "but", "unlike", "AddCounter", "does", "not", "emit", "a", "CounterEvent", "for", "each", "add", ";", "instead", "the", "adds", "are", "batched", "and", "a", "single", "CounterEvent", "is", "sent", "a...
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/metrics/metrics.go#L118-L123
132,538
leesper/go_rng
cauchy.go
Cauchy
func (crng CauchyGenerator) Cauchy(x0, gamma float64) float64 { if !(gamma > 0.0) { panic(fmt.Sprintf("Invalid parameter gamma: %.2f", gamma)) } return crng.cauchy(x0, gamma) }
go
func (crng CauchyGenerator) Cauchy(x0, gamma float64) float64 { if !(gamma > 0.0) { panic(fmt.Sprintf("Invalid parameter gamma: %.2f", gamma)) } return crng.cauchy(x0, gamma) }
[ "func", "(", "crng", "CauchyGenerator", ")", "Cauchy", "(", "x0", ",", "gamma", "float64", ")", "float64", "{", "if", "!", "(", "gamma", ">", "0.0", ")", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "gamma", ")", ")", "\n", "}"...
// Cauchy returns a random number of cauchy distribution
[ "Cauchy", "returns", "a", "random", "number", "of", "cauchy", "distribution" ]
5344a9259b21627d94279721ab1f27eb029194e7
https://github.com/leesper/go_rng/blob/5344a9259b21627d94279721ab1f27eb029194e7/cauchy.go#L23-L28
132,539
leesper/go_rng
uniform.go
Int32
func (ung UniformGenerator) Int32() int32 { ung.mu.Lock() defer ung.mu.Unlock() return ung.rd.Int31() }
go
func (ung UniformGenerator) Int32() int32 { ung.mu.Lock() defer ung.mu.Unlock() return ung.rd.Int31() }
[ "func", "(", "ung", "UniformGenerator", ")", "Int32", "(", ")", "int32", "{", "ung", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "ung", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "ung", ".", "rd", ".", "Int31", "(", ")", "\n", "}"...
// Int32 returns a random uint32
[ "Int32", "returns", "a", "random", "uint32" ]
5344a9259b21627d94279721ab1f27eb029194e7
https://github.com/leesper/go_rng/blob/5344a9259b21627d94279721ab1f27eb029194e7/uniform.go#L25-L29
132,540
leesper/go_rng
uniform.go
Int64
func (ung UniformGenerator) Int64() int64 { ung.mu.Lock() defer ung.mu.Unlock() return ung.rd.Int63() }
go
func (ung UniformGenerator) Int64() int64 { ung.mu.Lock() defer ung.mu.Unlock() return ung.rd.Int63() }
[ "func", "(", "ung", "UniformGenerator", ")", "Int64", "(", ")", "int64", "{", "ung", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "ung", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "ung", ".", "rd", ".", "Int63", "(", ")", "\n", "}"...
// Int64 returns a random uint64
[ "Int64", "returns", "a", "random", "uint64" ]
5344a9259b21627d94279721ab1f27eb029194e7
https://github.com/leesper/go_rng/blob/5344a9259b21627d94279721ab1f27eb029194e7/uniform.go#L32-L36
132,541
leesper/go_rng
uniform.go
Int32n
func (ung UniformGenerator) Int32n(n int32) int32 { if n <= 0 { panic(fmt.Sprintf("Illegal parameter n: %d", n)) } ung.mu.Lock() defer ung.mu.Unlock() return ung.rd.Int31n(n) }
go
func (ung UniformGenerator) Int32n(n int32) int32 { if n <= 0 { panic(fmt.Sprintf("Illegal parameter n: %d", n)) } ung.mu.Lock() defer ung.mu.Unlock() return ung.rd.Int31n(n) }
[ "func", "(", "ung", "UniformGenerator", ")", "Int32n", "(", "n", "int32", ")", "int32", "{", "if", "n", "<=", "0", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "n", ")", ")", "\n", "}", "\n", "ung", ".", "mu", ".", "Lock", ...
// Int32n returns a random uint32 in [0, n)
[ "Int32n", "returns", "a", "random", "uint32", "in", "[", "0", "n", ")" ]
5344a9259b21627d94279721ab1f27eb029194e7
https://github.com/leesper/go_rng/blob/5344a9259b21627d94279721ab1f27eb029194e7/uniform.go#L39-L46
132,542
leesper/go_rng
uniform.go
Int64n
func (ung UniformGenerator) Int64n(n int64) int64 { if n <= 0 { panic(fmt.Sprintf("Illegal parameter n: %d", n)) } ung.mu.Lock() defer ung.mu.Unlock() return ung.rd.Int63n(n) }
go
func (ung UniformGenerator) Int64n(n int64) int64 { if n <= 0 { panic(fmt.Sprintf("Illegal parameter n: %d", n)) } ung.mu.Lock() defer ung.mu.Unlock() return ung.rd.Int63n(n) }
[ "func", "(", "ung", "UniformGenerator", ")", "Int64n", "(", "n", "int64", ")", "int64", "{", "if", "n", "<=", "0", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "n", ")", ")", "\n", "}", "\n", "ung", ".", "mu", ".", "Lock", ...
// Int64n returns a random uint64 in [0, n)
[ "Int64n", "returns", "a", "random", "uint64", "in", "[", "0", "n", ")" ]
5344a9259b21627d94279721ab1f27eb029194e7
https://github.com/leesper/go_rng/blob/5344a9259b21627d94279721ab1f27eb029194e7/uniform.go#L49-L56
132,543
leesper/go_rng
uniform.go
Int32Range
func (ung UniformGenerator) Int32Range(a, b int32) int32 { if b <= a { panic(fmt.Sprintf("Illegal parameter a, b: %d, %d", a, b)) } if b-a > math.MaxInt32 { panic(fmt.Sprintf("Illegal parameter a, b: %d, %d", a, b)) } return a + ung.Int32n(b-a) }
go
func (ung UniformGenerator) Int32Range(a, b int32) int32 { if b <= a { panic(fmt.Sprintf("Illegal parameter a, b: %d, %d", a, b)) } if b-a > math.MaxInt32 { panic(fmt.Sprintf("Illegal parameter a, b: %d, %d", a, b)) } return a + ung.Int32n(b-a) }
[ "func", "(", "ung", "UniformGenerator", ")", "Int32Range", "(", "a", ",", "b", "int32", ")", "int32", "{", "if", "b", "<=", "a", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "a", ",", "b", ")", ")", "\n", "}", "\n", "if", "...
// Int32Range returns a random uint32 in [a, b)
[ "Int32Range", "returns", "a", "random", "uint32", "in", "[", "a", "b", ")" ]
5344a9259b21627d94279721ab1f27eb029194e7
https://github.com/leesper/go_rng/blob/5344a9259b21627d94279721ab1f27eb029194e7/uniform.go#L59-L67
132,544
leesper/go_rng
uniform.go
Int64Range
func (ung UniformGenerator) Int64Range(a, b int64) int64 { if b <= a { panic(fmt.Sprintf("Illegal parameter a, b: %d, %d", a, b)) } if b-a > math.MaxInt32 { panic(fmt.Sprintf("Illegal parameter a, b: %d, %d", a, b)) } return a + ung.Int64n(b-a) }
go
func (ung UniformGenerator) Int64Range(a, b int64) int64 { if b <= a { panic(fmt.Sprintf("Illegal parameter a, b: %d, %d", a, b)) } if b-a > math.MaxInt32 { panic(fmt.Sprintf("Illegal parameter a, b: %d, %d", a, b)) } return a + ung.Int64n(b-a) }
[ "func", "(", "ung", "UniformGenerator", ")", "Int64Range", "(", "a", ",", "b", "int64", ")", "int64", "{", "if", "b", "<=", "a", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "a", ",", "b", ")", ")", "\n", "}", "\n", "if", "...
// Int64Range returns a random uint64 in [a, b)
[ "Int64Range", "returns", "a", "random", "uint64", "in", "[", "a", "b", ")" ]
5344a9259b21627d94279721ab1f27eb029194e7
https://github.com/leesper/go_rng/blob/5344a9259b21627d94279721ab1f27eb029194e7/uniform.go#L70-L78
132,545
leesper/go_rng
uniform.go
Float32
func (ung UniformGenerator) Float32() float32 { ung.mu.Lock() defer ung.mu.Unlock() return ung.rd.Float32() }
go
func (ung UniformGenerator) Float32() float32 { ung.mu.Lock() defer ung.mu.Unlock() return ung.rd.Float32() }
[ "func", "(", "ung", "UniformGenerator", ")", "Float32", "(", ")", "float32", "{", "ung", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "ung", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "ung", ".", "rd", ".", "Float32", "(", ")", "\n",...
// Float32 returns a random float32 in [0.0, 1.0)
[ "Float32", "returns", "a", "random", "float32", "in", "[", "0", ".", "0", "1", ".", "0", ")" ]
5344a9259b21627d94279721ab1f27eb029194e7
https://github.com/leesper/go_rng/blob/5344a9259b21627d94279721ab1f27eb029194e7/uniform.go#L81-L85
132,546
leesper/go_rng
uniform.go
Float64
func (ung UniformGenerator) Float64() float64 { ung.mu.Lock() defer ung.mu.Unlock() return ung.rd.Float64() }
go
func (ung UniformGenerator) Float64() float64 { ung.mu.Lock() defer ung.mu.Unlock() return ung.rd.Float64() }
[ "func", "(", "ung", "UniformGenerator", ")", "Float64", "(", ")", "float64", "{", "ung", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "ung", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "ung", ".", "rd", ".", "Float64", "(", ")", "\n",...
// Float64 returns a random float64 in [0.0, 1.0)
[ "Float64", "returns", "a", "random", "float64", "in", "[", "0", ".", "0", "1", ".", "0", ")" ]
5344a9259b21627d94279721ab1f27eb029194e7
https://github.com/leesper/go_rng/blob/5344a9259b21627d94279721ab1f27eb029194e7/uniform.go#L88-L92
132,547
leesper/go_rng
uniform.go
Shuffle
func (ung UniformGenerator) Shuffle(arr []interface{}) { N := len(arr) for i := range arr { r := int32(i) + ung.Int32n(int32(N-i)) arr[i], arr[r] = arr[r], arr[i] } }
go
func (ung UniformGenerator) Shuffle(arr []interface{}) { N := len(arr) for i := range arr { r := int32(i) + ung.Int32n(int32(N-i)) arr[i], arr[r] = arr[r], arr[i] } }
[ "func", "(", "ung", "UniformGenerator", ")", "Shuffle", "(", "arr", "[", "]", "interface", "{", "}", ")", "{", "N", ":=", "len", "(", "arr", ")", "\n", "for", "i", ":=", "range", "arr", "{", "r", ":=", "int32", "(", "i", ")", "+", "ung", ".", ...
// Shuffle rearrange the elements of an array in random order
[ "Shuffle", "rearrange", "the", "elements", "of", "an", "array", "in", "random", "order" ]
5344a9259b21627d94279721ab1f27eb029194e7
https://github.com/leesper/go_rng/blob/5344a9259b21627d94279721ab1f27eb029194e7/uniform.go#L121-L127
132,548
leesper/go_rng
lognormal.go
Lognormal
func (lnng LognormalGenerator) Lognormal(mean, stddev float64) float64 { return math.Exp(mean + stddev*lnng.gauss.StdGaussian()) }
go
func (lnng LognormalGenerator) Lognormal(mean, stddev float64) float64 { return math.Exp(mean + stddev*lnng.gauss.StdGaussian()) }
[ "func", "(", "lnng", "LognormalGenerator", ")", "Lognormal", "(", "mean", ",", "stddev", "float64", ")", "float64", "{", "return", "math", ".", "Exp", "(", "mean", "+", "stddev", "*", "lnng", ".", "gauss", ".", "StdGaussian", "(", ")", ")", "\n", "}" ]
// Lognormal return a random number of lognormal distribution
[ "Lognormal", "return", "a", "random", "number", "of", "lognormal", "distribution" ]
5344a9259b21627d94279721ab1f27eb029194e7
https://github.com/leesper/go_rng/blob/5344a9259b21627d94279721ab1f27eb029194e7/lognormal.go#L22-L24
132,549
leesper/go_rng
logistic.go
Logistic
func (lrng LogisticGenerator) Logistic(mu, s float64) float64 { if !(s > 0.0) { panic(fmt.Sprintf("Invalid parameter s: %.2f", s)) } return lrng.logistic(mu, s) }
go
func (lrng LogisticGenerator) Logistic(mu, s float64) float64 { if !(s > 0.0) { panic(fmt.Sprintf("Invalid parameter s: %.2f", s)) } return lrng.logistic(mu, s) }
[ "func", "(", "lrng", "LogisticGenerator", ")", "Logistic", "(", "mu", ",", "s", "float64", ")", "float64", "{", "if", "!", "(", "s", ">", "0.0", ")", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "s", ")", ")", "\n", "}", "\n"...
// Logistic returns a random number of logistic distribution
[ "Logistic", "returns", "a", "random", "number", "of", "logistic", "distribution" ]
5344a9259b21627d94279721ab1f27eb029194e7
https://github.com/leesper/go_rng/blob/5344a9259b21627d94279721ab1f27eb029194e7/logistic.go#L23-L28
132,550
leesper/go_rng
bernoulli.go
Bernoulli_P
func (beng BernoulliGenerator) Bernoulli_P(p float64) bool { if !(0.0 <= p && p <= 1.0) { panic(fmt.Sprintf("Invalid probability: %.2f", p)) } return beng.uniform.Float64() < p }
go
func (beng BernoulliGenerator) Bernoulli_P(p float64) bool { if !(0.0 <= p && p <= 1.0) { panic(fmt.Sprintf("Invalid probability: %.2f", p)) } return beng.uniform.Float64() < p }
[ "func", "(", "beng", "BernoulliGenerator", ")", "Bernoulli_P", "(", "p", "float64", ")", "bool", "{", "if", "!", "(", "0.0", "<=", "p", "&&", "p", "<=", "1.0", ")", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "p", ")", ")", ...
// Bernoulli_P returns a bool, which is true with probablity p
[ "Bernoulli_P", "returns", "a", "bool", "which", "is", "true", "with", "probablity", "p" ]
5344a9259b21627d94279721ab1f27eb029194e7
https://github.com/leesper/go_rng/blob/5344a9259b21627d94279721ab1f27eb029194e7/bernoulli.go#L27-L32
132,551
leesper/go_rng
poisson.go
Poisson
func (prng PoissonGenerator) Poisson(lambda float64) int64 { if !(lambda > 0.0) { panic(fmt.Sprintf("Invalid lambda: %.2f", lambda)) } return prng.poisson(lambda) }
go
func (prng PoissonGenerator) Poisson(lambda float64) int64 { if !(lambda > 0.0) { panic(fmt.Sprintf("Invalid lambda: %.2f", lambda)) } return prng.poisson(lambda) }
[ "func", "(", "prng", "PoissonGenerator", ")", "Poisson", "(", "lambda", "float64", ")", "int64", "{", "if", "!", "(", "lambda", ">", "0.0", ")", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "lambda", ")", ")", "\n", "}", "\n", ...
// Poisson returns a random number of possion distribution
[ "Poisson", "returns", "a", "random", "number", "of", "possion", "distribution" ]
5344a9259b21627d94279721ab1f27eb029194e7
https://github.com/leesper/go_rng/blob/5344a9259b21627d94279721ab1f27eb029194e7/poisson.go#L23-L28
132,552
leesper/go_rng
exponential.go
Exp
func (erng ExpGenerator) Exp(lambda float64) float64 { if !(lambda > 0.0) { panic(fmt.Sprintf("Invalid lambda: %.2f", lambda)) } return erng.exp(lambda) }
go
func (erng ExpGenerator) Exp(lambda float64) float64 { if !(lambda > 0.0) { panic(fmt.Sprintf("Invalid lambda: %.2f", lambda)) } return erng.exp(lambda) }
[ "func", "(", "erng", "ExpGenerator", ")", "Exp", "(", "lambda", "float64", ")", "float64", "{", "if", "!", "(", "lambda", ">", "0.0", ")", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "lambda", ")", ")", "\n", "}", "\n", "retur...
// Exp returns a random number of exponential distribution
[ "Exp", "returns", "a", "random", "number", "of", "exponential", "distribution" ]
5344a9259b21627d94279721ab1f27eb029194e7
https://github.com/leesper/go_rng/blob/5344a9259b21627d94279721ab1f27eb029194e7/exponential.go#L23-L28
132,553
leesper/go_rng
gamma.go
gamma
func (grng GammaGenerator) gamma(alpha, beta float64) float64 { var MAGIC_CONST float64 = 4 * math.Exp(-0.5) / math.Sqrt(2.0) if alpha > 1.0 { // Use R.C.H Cheng "The generation of Gamma variables with // non-integral shape parameters", Applied Statistics, (1977), 26, No. 1, p71-74 ainv := math.Sqrt(2.0*alpha ...
go
func (grng GammaGenerator) gamma(alpha, beta float64) float64 { var MAGIC_CONST float64 = 4 * math.Exp(-0.5) / math.Sqrt(2.0) if alpha > 1.0 { // Use R.C.H Cheng "The generation of Gamma variables with // non-integral shape parameters", Applied Statistics, (1977), 26, No. 1, p71-74 ainv := math.Sqrt(2.0*alpha ...
[ "func", "(", "grng", "GammaGenerator", ")", "gamma", "(", "alpha", ",", "beta", "float64", ")", "float64", "{", "var", "MAGIC_CONST", "float64", "=", "4", "*", "math", ".", "Exp", "(", "-", "0.5", ")", "/", "math", ".", "Sqrt", "(", "2.0", ")", "\n...
// inspired by random.py
[ "inspired", "by", "random", ".", "py" ]
5344a9259b21627d94279721ab1f27eb029194e7
https://github.com/leesper/go_rng/blob/5344a9259b21627d94279721ab1f27eb029194e7/gamma.go#L32-L85
132,554
jaffee/commandeer
com.go
RunArgs
func RunArgs(flags Flagger, main interface{}, args []string) error { err := Flags(flags, main) if err != nil { return fmt.Errorf("calling Flags: %v", err) } err = flags.Parse(args) if err != nil { return fmt.Errorf("parsing flags: %v", err) } if main, ok := main.(Runner); ok { return main.Run() } return...
go
func RunArgs(flags Flagger, main interface{}, args []string) error { err := Flags(flags, main) if err != nil { return fmt.Errorf("calling Flags: %v", err) } err = flags.Parse(args) if err != nil { return fmt.Errorf("parsing flags: %v", err) } if main, ok := main.(Runner); ok { return main.Run() } return...
[ "func", "RunArgs", "(", "flags", "Flagger", ",", "main", "interface", "{", "}", ",", "args", "[", "]", "string", ")", "error", "{", "err", ":=", "Flags", "(", "flags", ",", "main", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "...
// RunArgs is similar to Run, but the caller must specify their own flag set and // args to be parsed by that flag set.
[ "RunArgs", "is", "similar", "to", "Run", "but", "the", "caller", "must", "specify", "their", "own", "flag", "set", "and", "args", "to", "be", "parsed", "by", "that", "flag", "set", "." ]
3bd317f80cbd12c38e6591dc67fa4623adc4741b
https://github.com/jaffee/commandeer/blob/3bd317f80cbd12c38e6591dc67fa4623adc4741b/com.go#L68-L82
132,555
jaffee/commandeer
com.go
flagName
func flagName(field reflect.StructField) (flagname string) { var ok bool if flagname, ok = field.Tag.Lookup("flag"); ok { return flagname } if flagname, ok = field.Tag.Lookup("json"); ok { return flagname } flagname = field.Name return downcaseAndDash(flagname) }
go
func flagName(field reflect.StructField) (flagname string) { var ok bool if flagname, ok = field.Tag.Lookup("flag"); ok { return flagname } if flagname, ok = field.Tag.Lookup("json"); ok { return flagname } flagname = field.Name return downcaseAndDash(flagname) }
[ "func", "flagName", "(", "field", "reflect", ".", "StructField", ")", "(", "flagname", "string", ")", "{", "var", "ok", "bool", "\n", "if", "flagname", ",", "ok", "=", "field", ".", "Tag", ".", "Lookup", "(", "\"", "\"", ")", ";", "ok", "{", "retur...
// flagName finds a field's flag name. It first looks for a "flag" tag, then // tries to use the "json" tag, and final falls back to using the name of the // field after running it through "downcaseAndDash".
[ "flagName", "finds", "a", "field", "s", "flag", "name", ".", "It", "first", "looks", "for", "a", "flag", "tag", "then", "tries", "to", "use", "the", "json", "tag", "and", "final", "falls", "back", "to", "using", "the", "name", "of", "the", "field", "...
3bd317f80cbd12c38e6591dc67fa4623adc4741b
https://github.com/jaffee/commandeer/blob/3bd317f80cbd12c38e6591dc67fa4623adc4741b/com.go#L251-L263
132,556
jaffee/commandeer
com.go
flagHelp
func flagHelp(field reflect.StructField) (flaghelp string) { if flaghelp, ok := field.Tag.Lookup("help"); ok { return flaghelp } return "" }
go
func flagHelp(field reflect.StructField) (flaghelp string) { if flaghelp, ok := field.Tag.Lookup("help"); ok { return flaghelp } return "" }
[ "func", "flagHelp", "(", "field", "reflect", ".", "StructField", ")", "(", "flaghelp", "string", ")", "{", "if", "flaghelp", ",", "ok", ":=", "field", ".", "Tag", ".", "Lookup", "(", "\"", "\"", ")", ";", "ok", "{", "return", "flaghelp", "\n", "}", ...
// flagHelp gets the help text from a field's tag or returns an empty string.
[ "flagHelp", "gets", "the", "help", "text", "from", "a", "field", "s", "tag", "or", "returns", "an", "empty", "string", "." ]
3bd317f80cbd12c38e6591dc67fa4623adc4741b
https://github.com/jaffee/commandeer/blob/3bd317f80cbd12c38e6591dc67fa4623adc4741b/com.go#L292-L297
132,557
jaffee/commandeer
com.go
newFlagTracker
func newFlagTracker(flagger Flagger) *flagTracker { fTr := &flagTracker{ flagger: flagger, shorts: map[rune]struct{}{ 'h': {}, // "h" is always used for help, so we can't set it. }, } fTr.pflagger, fTr.pflag = flagger.(PFlagger) return fTr }
go
func newFlagTracker(flagger Flagger) *flagTracker { fTr := &flagTracker{ flagger: flagger, shorts: map[rune]struct{}{ 'h': {}, // "h" is always used for help, so we can't set it. }, } fTr.pflagger, fTr.pflag = flagger.(PFlagger) return fTr }
[ "func", "newFlagTracker", "(", "flagger", "Flagger", ")", "*", "flagTracker", "{", "fTr", ":=", "&", "flagTracker", "{", "flagger", ":", "flagger", ",", "shorts", ":", "map", "[", "rune", "]", "struct", "{", "}", "{", "'h'", ":", "{", "}", ",", "// \...
// newFlagTracker sets up a flagTracker based on a flagger.
[ "newFlagTracker", "sets", "up", "a", "flagTracker", "based", "on", "a", "flagger", "." ]
3bd317f80cbd12c38e6591dc67fa4623adc4741b
https://github.com/jaffee/commandeer/blob/3bd317f80cbd12c38e6591dc67fa4623adc4741b/com.go#L309-L318
132,558
jaffee/commandeer
com.go
short
func (fTr *flagTracker) short(field reflect.StructField, flagName string) (letter string, err error) { if short, ok := field.Tag.Lookup("short"); ok { if short == "" { return "", nil // explicitly set to no shorthand } runeVal, width := utf8.DecodeRuneInString(short) if runeVal == utf8.RuneError || width > ...
go
func (fTr *flagTracker) short(field reflect.StructField, flagName string) (letter string, err error) { if short, ok := field.Tag.Lookup("short"); ok { if short == "" { return "", nil // explicitly set to no shorthand } runeVal, width := utf8.DecodeRuneInString(short) if runeVal == utf8.RuneError || width > ...
[ "func", "(", "fTr", "*", "flagTracker", ")", "short", "(", "field", "reflect", ".", "StructField", ",", "flagName", "string", ")", "(", "letter", "string", ",", "err", "error", ")", "{", "if", "short", ",", "ok", ":=", "field", ".", "Tag", ".", "Look...
// short gets the shorthand for a flag. flagName is the non-prefixed name // returned by flagName.
[ "short", "gets", "the", "shorthand", "for", "a", "flag", ".", "flagName", "is", "the", "non", "-", "prefixed", "name", "returned", "by", "flagName", "." ]
3bd317f80cbd12c38e6591dc67fa4623adc4741b
https://github.com/jaffee/commandeer/blob/3bd317f80cbd12c38e6591dc67fa4623adc4741b/com.go#L322-L348
132,559
jaffee/commandeer
examples/myapp/myapp.go
Run
func (m *Main) Run() error { if m.Num < 2 || m.Vehicle == "" { return fmt.Errorf("Need more gophers and/or vehicles.") } fmt.Printf("%d gophers stole my %s!\n", m.Num, m.Vehicle) return nil }
go
func (m *Main) Run() error { if m.Num < 2 || m.Vehicle == "" { return fmt.Errorf("Need more gophers and/or vehicles.") } fmt.Printf("%d gophers stole my %s!\n", m.Num, m.Vehicle) return nil }
[ "func", "(", "m", "*", "Main", ")", "Run", "(", ")", "error", "{", "if", "m", ".", "Num", "<", "2", "||", "m", ".", "Vehicle", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "fmt", ".", "Printf...
// Run implements the Runner interface so that commandeer.Run can be used with // Main.
[ "Run", "implements", "the", "Runner", "interface", "so", "that", "commandeer", ".", "Run", "can", "be", "used", "with", "Main", "." ]
3bd317f80cbd12c38e6591dc67fa4623adc4741b
https://github.com/jaffee/commandeer/blob/3bd317f80cbd12c38e6591dc67fa4623adc4741b/examples/myapp/myapp.go#L18-L24
132,560
Azure/azure-amqp-common-go
persist/file.go
NewFilePersister
func NewFilePersister(directory string) (*FilePersister, error) { err := os.MkdirAll(directory, 0777) return &FilePersister{ directory: directory, }, err }
go
func NewFilePersister(directory string) (*FilePersister, error) { err := os.MkdirAll(directory, 0777) return &FilePersister{ directory: directory, }, err }
[ "func", "NewFilePersister", "(", "directory", "string", ")", "(", "*", "FilePersister", ",", "error", ")", "{", "err", ":=", "os", ".", "MkdirAll", "(", "directory", ",", "0777", ")", "\n", "return", "&", "FilePersister", "{", "directory", ":", "directory"...
// NewFilePersister creates a FilePersister for saving to a given directory
[ "NewFilePersister", "creates", "a", "FilePersister", "for", "saving", "to", "a", "given", "directory" ]
b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a
https://github.com/Azure/azure-amqp-common-go/blob/b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a/persist/file.go#L44-L49
132,561
Azure/azure-amqp-common-go
persist/checkpoint.go
NewCheckpoint
func NewCheckpoint(offset string, sequence int64, enqueueTime time.Time) Checkpoint { return Checkpoint{ Offset: offset, SequenceNumber: sequence, EnqueueTime: enqueueTime, } }
go
func NewCheckpoint(offset string, sequence int64, enqueueTime time.Time) Checkpoint { return Checkpoint{ Offset: offset, SequenceNumber: sequence, EnqueueTime: enqueueTime, } }
[ "func", "NewCheckpoint", "(", "offset", "string", ",", "sequence", "int64", ",", "enqueueTime", "time", ".", "Time", ")", "Checkpoint", "{", "return", "Checkpoint", "{", "Offset", ":", "offset", ",", "SequenceNumber", ":", "sequence", ",", "EnqueueTime", ":", ...
// NewCheckpoint contains the information needed to checkpoint Event Hub progress
[ "NewCheckpoint", "contains", "the", "information", "needed", "to", "checkpoint", "Event", "Hub", "progress" ]
b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a
https://github.com/Azure/azure-amqp-common-go/blob/b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a/persist/checkpoint.go#L63-L69
132,562
Azure/azure-amqp-common-go
internal/tracing/tracing.go
StartSpanFromContext
func StartSpanFromContext(ctx context.Context, operationName string, opts ...trace.StartOption) (*trace.Span, context.Context) { ctx, span := trace.StartSpan(ctx, operationName, opts...) ApplyComponentInfo(span) return span, ctx }
go
func StartSpanFromContext(ctx context.Context, operationName string, opts ...trace.StartOption) (*trace.Span, context.Context) { ctx, span := trace.StartSpan(ctx, operationName, opts...) ApplyComponentInfo(span) return span, ctx }
[ "func", "StartSpanFromContext", "(", "ctx", "context", ".", "Context", ",", "operationName", "string", ",", "opts", "...", "trace", ".", "StartOption", ")", "(", "*", "trace", ".", "Span", ",", "context", ".", "Context", ")", "{", "ctx", ",", "span", ":=...
// StartSpanFromContext starts a span given a context and applies common library information
[ "StartSpanFromContext", "starts", "a", "span", "given", "a", "context", "and", "applies", "common", "library", "information" ]
b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a
https://github.com/Azure/azure-amqp-common-go/blob/b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a/internal/tracing/tracing.go#L12-L16
132,563
Azure/azure-amqp-common-go
internal/tracing/tracing.go
ApplyComponentInfo
func ApplyComponentInfo(span *trace.Span) { span.AddAttributes( trace.StringAttribute("component", "github.com/Azure/azure-amqp-common-go"), trace.StringAttribute("version", common.Version)) applyNetworkInfo(span) }
go
func ApplyComponentInfo(span *trace.Span) { span.AddAttributes( trace.StringAttribute("component", "github.com/Azure/azure-amqp-common-go"), trace.StringAttribute("version", common.Version)) applyNetworkInfo(span) }
[ "func", "ApplyComponentInfo", "(", "span", "*", "trace", ".", "Span", ")", "{", "span", ".", "AddAttributes", "(", "trace", ".", "StringAttribute", "(", "\"", "\"", ",", "\"", "\"", ")", ",", "trace", ".", "StringAttribute", "(", "\"", "\"", ",", "comm...
// ApplyComponentInfo applies eventhub library and network info to the span
[ "ApplyComponentInfo", "applies", "eventhub", "library", "and", "network", "info", "to", "the", "span" ]
b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a
https://github.com/Azure/azure-amqp-common-go/blob/b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a/internal/tracing/tracing.go#L19-L24
132,564
Azure/azure-amqp-common-go
sas/sas.go
NewTokenProvider
func NewTokenProvider(opts ...TokenProviderOption) (*TokenProvider, error) { provider := new(TokenProvider) for _, opt := range opts { err := opt(provider) if err != nil { return nil, err } } return provider, nil }
go
func NewTokenProvider(opts ...TokenProviderOption) (*TokenProvider, error) { provider := new(TokenProvider) for _, opt := range opts { err := opt(provider) if err != nil { return nil, err } } return provider, nil }
[ "func", "NewTokenProvider", "(", "opts", "...", "TokenProviderOption", ")", "(", "*", "TokenProvider", ",", "error", ")", "{", "provider", ":=", "new", "(", "TokenProvider", ")", "\n", "for", "_", ",", "opt", ":=", "range", "opts", "{", "err", ":=", "opt...
// NewTokenProvider builds a SAS claims-based security token provider
[ "NewTokenProvider", "builds", "a", "SAS", "claims", "-", "based", "security", "token", "provider" ]
b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a
https://github.com/Azure/azure-amqp-common-go/blob/b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a/sas/sas.go#L105-L114
132,565
Azure/azure-amqp-common-go
sas/sas.go
GetToken
func (t *TokenProvider) GetToken(audience string) (*auth.Token, error) { signature, expiry := t.signer.SignWithDuration(audience, 2*time.Hour) return auth.NewToken(auth.CBSTokenTypeSAS, signature, expiry), nil }
go
func (t *TokenProvider) GetToken(audience string) (*auth.Token, error) { signature, expiry := t.signer.SignWithDuration(audience, 2*time.Hour) return auth.NewToken(auth.CBSTokenTypeSAS, signature, expiry), nil }
[ "func", "(", "t", "*", "TokenProvider", ")", "GetToken", "(", "audience", "string", ")", "(", "*", "auth", ".", "Token", ",", "error", ")", "{", "signature", ",", "expiry", ":=", "t", ".", "signer", ".", "SignWithDuration", "(", "audience", ",", "2", ...
// GetToken gets a CBS SAS token
[ "GetToken", "gets", "a", "CBS", "SAS", "token" ]
b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a
https://github.com/Azure/azure-amqp-common-go/blob/b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a/sas/sas.go#L117-L120
132,566
Azure/azure-amqp-common-go
sas/sas.go
NewSigner
func NewSigner(keyName, key string) *Signer { return &Signer{ KeyName: keyName, Key: key, } }
go
func NewSigner(keyName, key string) *Signer { return &Signer{ KeyName: keyName, Key: key, } }
[ "func", "NewSigner", "(", "keyName", ",", "key", "string", ")", "*", "Signer", "{", "return", "&", "Signer", "{", "KeyName", ":", "keyName", ",", "Key", ":", "key", ",", "}", "\n", "}" ]
// NewSigner builds a new SAS signer for use in generation Service Bus and Event Hub SAS tokens
[ "NewSigner", "builds", "a", "new", "SAS", "signer", "for", "use", "in", "generation", "Service", "Bus", "and", "Event", "Hub", "SAS", "tokens" ]
b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a
https://github.com/Azure/azure-amqp-common-go/blob/b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a/sas/sas.go#L123-L128
132,567
Azure/azure-amqp-common-go
sas/sas.go
SignWithDuration
func (s *Signer) SignWithDuration(uri string, interval time.Duration) (signature, expiry string) { expiry = signatureExpiry(time.Now().UTC(), interval) return s.SignWithExpiry(uri, expiry), expiry }
go
func (s *Signer) SignWithDuration(uri string, interval time.Duration) (signature, expiry string) { expiry = signatureExpiry(time.Now().UTC(), interval) return s.SignWithExpiry(uri, expiry), expiry }
[ "func", "(", "s", "*", "Signer", ")", "SignWithDuration", "(", "uri", "string", ",", "interval", "time", ".", "Duration", ")", "(", "signature", ",", "expiry", "string", ")", "{", "expiry", "=", "signatureExpiry", "(", "time", ".", "Now", "(", ")", "."...
// SignWithDuration signs a given for a period of time from now
[ "SignWithDuration", "signs", "a", "given", "for", "a", "period", "of", "time", "from", "now" ]
b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a
https://github.com/Azure/azure-amqp-common-go/blob/b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a/sas/sas.go#L131-L134
132,568
Azure/azure-amqp-common-go
sas/sas.go
SignWithExpiry
func (s *Signer) SignWithExpiry(uri, expiry string) string { audience := strings.ToLower(url.QueryEscape(uri)) sts := stringToSign(audience, expiry) sig := s.signString(sts) return fmt.Sprintf("SharedAccessSignature sr=%s&sig=%s&se=%s&skn=%s", audience, sig, expiry, s.KeyName) }
go
func (s *Signer) SignWithExpiry(uri, expiry string) string { audience := strings.ToLower(url.QueryEscape(uri)) sts := stringToSign(audience, expiry) sig := s.signString(sts) return fmt.Sprintf("SharedAccessSignature sr=%s&sig=%s&se=%s&skn=%s", audience, sig, expiry, s.KeyName) }
[ "func", "(", "s", "*", "Signer", ")", "SignWithExpiry", "(", "uri", ",", "expiry", "string", ")", "string", "{", "audience", ":=", "strings", ".", "ToLower", "(", "url", ".", "QueryEscape", "(", "uri", ")", ")", "\n", "sts", ":=", "stringToSign", "(", ...
// SignWithExpiry signs a given uri with a given expiry string
[ "SignWithExpiry", "signs", "a", "given", "uri", "with", "a", "given", "expiry", "string" ]
b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a
https://github.com/Azure/azure-amqp-common-go/blob/b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a/sas/sas.go#L137-L142
132,569
Azure/azure-amqp-common-go
log/logger.go
For
func For(ctx context.Context) Logger { if span := trace.FromContext(ctx); span != nil { return &spanLogger{ span: span, } } return new(nopLogger) }
go
func For(ctx context.Context) Logger { if span := trace.FromContext(ctx); span != nil { return &spanLogger{ span: span, } } return new(nopLogger) }
[ "func", "For", "(", "ctx", "context", ".", "Context", ")", "Logger", "{", "if", "span", ":=", "trace", ".", "FromContext", "(", "ctx", ")", ";", "span", "!=", "nil", "{", "return", "&", "spanLogger", "{", "span", ":", "span", ",", "}", "\n", "}", ...
// For will return a logger for a given context
[ "For", "will", "return", "a", "logger", "for", "a", "given", "context" ]
b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a
https://github.com/Azure/azure-amqp-common-go/blob/b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a/log/logger.go#L26-L33
132,570
Azure/azure-amqp-common-go
retry.go
Retry
func Retry(times int, delay time.Duration, action func() (interface{}, error)) (interface{}, error) { var lastErr error for i := 0; i < times; i++ { item, err := action() if err != nil { if retryable, ok := err.(Retryable); ok { lastErr = retryable time.Sleep(delay) continue } else { return ...
go
func Retry(times int, delay time.Duration, action func() (interface{}, error)) (interface{}, error) { var lastErr error for i := 0; i < times; i++ { item, err := action() if err != nil { if retryable, ok := err.(Retryable); ok { lastErr = retryable time.Sleep(delay) continue } else { return ...
[ "func", "Retry", "(", "times", "int", ",", "delay", "time", ".", "Duration", ",", "action", "func", "(", ")", "(", "interface", "{", "}", ",", "error", ")", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "var", "lastErr", "error", "\n", ...
// Retry will attempt to retry an action a number of times if the action returns a retryable error
[ "Retry", "will", "attempt", "to", "retry", "an", "action", "a", "number", "of", "times", "if", "the", "action", "returns", "a", "retryable", "error" ]
b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a
https://github.com/Azure/azure-amqp-common-go/blob/b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a/retry.go#L38-L54
132,571
Azure/azure-amqp-common-go
conn/conn.go
newParsedConnection
func newParsedConnection(namespace, suffix, hubName, keyName, key string) *ParsedConn { return &ParsedConn{ Host: "amqps://" + namespace + "." + suffix, Suffix: suffix, Namespace: namespace, KeyName: keyName, Key: key, HubName: hubName, } }
go
func newParsedConnection(namespace, suffix, hubName, keyName, key string) *ParsedConn { return &ParsedConn{ Host: "amqps://" + namespace + "." + suffix, Suffix: suffix, Namespace: namespace, KeyName: keyName, Key: key, HubName: hubName, } }
[ "func", "newParsedConnection", "(", "namespace", ",", "suffix", ",", "hubName", ",", "keyName", ",", "key", "string", ")", "*", "ParsedConn", "{", "return", "&", "ParsedConn", "{", "Host", ":", "\"", "\"", "+", "namespace", "+", "\"", "\"", "+", "suffix"...
// newParsedConnection is a constructor for a parsedConn and verifies each of the inputs is non-null.
[ "newParsedConnection", "is", "a", "constructor", "for", "a", "parsedConn", "and", "verifies", "each", "of", "the", "inputs", "is", "non", "-", "null", "." ]
b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a
https://github.com/Azure/azure-amqp-common-go/blob/b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a/conn/conn.go#L52-L61
132,572
Azure/azure-amqp-common-go
conn/conn.go
ParsedConnectionFromStr
func ParsedConnectionFromStr(connStr string) (*ParsedConn, error) { var namespace, suffix, hubName, keyName, secret string splits := strings.Split(connStr, ";") for _, split := range splits { keyAndValue := strings.Split(split, "=") if len(keyAndValue) < 2 { return nil, errors.New("failed parsing connection s...
go
func ParsedConnectionFromStr(connStr string) (*ParsedConn, error) { var namespace, suffix, hubName, keyName, secret string splits := strings.Split(connStr, ";") for _, split := range splits { keyAndValue := strings.Split(split, "=") if len(keyAndValue) < 2 { return nil, errors.New("failed parsing connection s...
[ "func", "ParsedConnectionFromStr", "(", "connStr", "string", ")", "(", "*", "ParsedConn", ",", "error", ")", "{", "var", "namespace", ",", "suffix", ",", "hubName", ",", "keyName", ",", "secret", "string", "\n", "splits", ":=", "strings", ".", "Split", "("...
// ParsedConnectionFromStr takes a string connection string from the Azure portal and returns the parsed representation. // The method will return an error if the Endpoint, SharedAccessKeyName or SharedAccessKey is empty.
[ "ParsedConnectionFromStr", "takes", "a", "string", "connection", "string", "from", "the", "Azure", "portal", "and", "returns", "the", "parsed", "representation", ".", "The", "method", "will", "return", "an", "error", "if", "the", "Endpoint", "SharedAccessKeyName", ...
b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a
https://github.com/Azure/azure-amqp-common-go/blob/b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a/conn/conn.go#L65-L112
132,573
Azure/azure-amqp-common-go
rpc/rpc.go
NewLink
func NewLink(conn *amqp.Client, address string) (*Link, error) { authSession, err := conn.NewSession() if err != nil { return nil, err } return NewLinkWithSession(conn, authSession, address) }
go
func NewLink(conn *amqp.Client, address string) (*Link, error) { authSession, err := conn.NewSession() if err != nil { return nil, err } return NewLinkWithSession(conn, authSession, address) }
[ "func", "NewLink", "(", "conn", "*", "amqp", ".", "Client", ",", "address", "string", ")", "(", "*", "Link", ",", "error", ")", "{", "authSession", ",", "err", ":=", "conn", ".", "NewSession", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return"...
// NewLink will build a new request response link
[ "NewLink", "will", "build", "a", "new", "request", "response", "link" ]
b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a
https://github.com/Azure/azure-amqp-common-go/blob/b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a/rpc/rpc.go#L67-L74
132,574
Azure/azure-amqp-common-go
rpc/rpc.go
NewLinkWithSession
func NewLinkWithSession(conn *amqp.Client, session *amqp.Session, address string) (*Link, error) { authSender, err := session.NewSender( amqp.LinkTargetAddress(address), ) if err != nil { return nil, err } linkID, err := uuid.NewV4() if err != nil { return nil, err } id := linkID.String() clientAddres...
go
func NewLinkWithSession(conn *amqp.Client, session *amqp.Session, address string) (*Link, error) { authSender, err := session.NewSender( amqp.LinkTargetAddress(address), ) if err != nil { return nil, err } linkID, err := uuid.NewV4() if err != nil { return nil, err } id := linkID.String() clientAddres...
[ "func", "NewLinkWithSession", "(", "conn", "*", "amqp", ".", "Client", ",", "session", "*", "amqp", ".", "Session", ",", "address", "string", ")", "(", "*", "Link", ",", "error", ")", "{", "authSender", ",", "err", ":=", "session", ".", "NewSender", "(...
// NewLinkWithSession will build a new request response link, but will reuse an existing AMQP session
[ "NewLinkWithSession", "will", "build", "a", "new", "request", "response", "link", "but", "will", "reuse", "an", "existing", "AMQP", "session" ]
b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a
https://github.com/Azure/azure-amqp-common-go/blob/b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a/rpc/rpc.go#L77-L108
132,575
Azure/azure-amqp-common-go
rpc/rpc.go
RetryableRPC
func (l *Link) RetryableRPC(ctx context.Context, times int, delay time.Duration, msg *amqp.Message) (*Response, error) { span, ctx := tracing.StartSpanFromContext(ctx, "az-amqp-common.rpc.RetryableRPC") defer span.End() res, err := common.Retry(times, delay, func() (interface{}, error) { span, ctx := tracing.Star...
go
func (l *Link) RetryableRPC(ctx context.Context, times int, delay time.Duration, msg *amqp.Message) (*Response, error) { span, ctx := tracing.StartSpanFromContext(ctx, "az-amqp-common.rpc.RetryableRPC") defer span.End() res, err := common.Retry(times, delay, func() (interface{}, error) { span, ctx := tracing.Star...
[ "func", "(", "l", "*", "Link", ")", "RetryableRPC", "(", "ctx", "context", ".", "Context", ",", "times", "int", ",", "delay", "time", ".", "Duration", ",", "msg", "*", "amqp", ".", "Message", ")", "(", "*", "Response", ",", "error", ")", "{", "span...
// RetryableRPC attempts to retry a request a number of times with delay
[ "RetryableRPC", "attempts", "to", "retry", "a", "request", "a", "number", "of", "times", "with", "delay" ]
b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a
https://github.com/Azure/azure-amqp-common-go/blob/b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a/rpc/rpc.go#L111-L143
132,576
Azure/azure-amqp-common-go
rpc/rpc.go
RPC
func (l *Link) RPC(ctx context.Context, msg *amqp.Message) (*Response, error) { const altStatusCodeKey, altDescriptionKey = "statusCode", "statusDescription" l.rpcMu.Lock() defer l.rpcMu.Unlock() span, ctx := tracing.StartSpanFromContext(ctx, "az-amqp-common.rpc.RPC") defer span.End() if msg.Properties == nil ...
go
func (l *Link) RPC(ctx context.Context, msg *amqp.Message) (*Response, error) { const altStatusCodeKey, altDescriptionKey = "statusCode", "statusDescription" l.rpcMu.Lock() defer l.rpcMu.Unlock() span, ctx := tracing.StartSpanFromContext(ctx, "az-amqp-common.rpc.RPC") defer span.End() if msg.Properties == nil ...
[ "func", "(", "l", "*", "Link", ")", "RPC", "(", "ctx", "context", ".", "Context", ",", "msg", "*", "amqp", ".", "Message", ")", "(", "*", "Response", ",", "error", ")", "{", "const", "altStatusCodeKey", ",", "altDescriptionKey", "=", "\"", "\"", ",",...
// RPC sends a request and waits on a response for that request
[ "RPC", "sends", "a", "request", "and", "waits", "on", "a", "response", "for", "that", "request" ]
b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a
https://github.com/Azure/azure-amqp-common-go/blob/b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a/rpc/rpc.go#L146-L214
132,577
Azure/azure-amqp-common-go
rpc/rpc.go
Close
func (l *Link) Close(ctx context.Context) error { span, ctx := tracing.StartSpanFromContext(ctx, "az-amqp-common.rpc.Close") defer span.End() if err := l.closeReceiver(ctx); err != nil { _ = l.closeSender(ctx) _ = l.closeSession(ctx) return err } if err := l.closeSender(ctx); err != nil { _ = l.closeSess...
go
func (l *Link) Close(ctx context.Context) error { span, ctx := tracing.StartSpanFromContext(ctx, "az-amqp-common.rpc.Close") defer span.End() if err := l.closeReceiver(ctx); err != nil { _ = l.closeSender(ctx) _ = l.closeSession(ctx) return err } if err := l.closeSender(ctx); err != nil { _ = l.closeSess...
[ "func", "(", "l", "*", "Link", ")", "Close", "(", "ctx", "context", ".", "Context", ")", "error", "{", "span", ",", "ctx", ":=", "tracing", ".", "StartSpanFromContext", "(", "ctx", ",", "\"", "\"", ")", "\n", "defer", "span", ".", "End", "(", ")", ...
// Close the link receiver, sender and session
[ "Close", "the", "link", "receiver", "sender", "and", "session" ]
b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a
https://github.com/Azure/azure-amqp-common-go/blob/b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a/rpc/rpc.go#L217-L233
132,578
Azure/azure-amqp-common-go
aad/jwt.go
JWTProviderWithAzureEnvironment
func JWTProviderWithAzureEnvironment(env *azure.Environment) JWTProviderOption { return func(config *TokenProviderConfiguration) error { config.Env = env return nil } }
go
func JWTProviderWithAzureEnvironment(env *azure.Environment) JWTProviderOption { return func(config *TokenProviderConfiguration) error { config.Env = env return nil } }
[ "func", "JWTProviderWithAzureEnvironment", "(", "env", "*", "azure", ".", "Environment", ")", "JWTProviderOption", "{", "return", "func", "(", "config", "*", "TokenProviderConfiguration", ")", "error", "{", "config", ".", "Env", "=", "env", "\n", "return", "nil"...
// JWTProviderWithAzureEnvironment configures the token provider to use a specific Azure Environment
[ "JWTProviderWithAzureEnvironment", "configures", "the", "token", "provider", "to", "use", "a", "specific", "Azure", "Environment" ]
b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a
https://github.com/Azure/azure-amqp-common-go/blob/b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a/aad/jwt.go#L69-L74
132,579
Azure/azure-amqp-common-go
aad/jwt.go
JWTProviderWithResourceURI
func JWTProviderWithResourceURI(resourceURI string) JWTProviderOption { return func(config *TokenProviderConfiguration) error { config.ResourceURI = resourceURI return nil } }
go
func JWTProviderWithResourceURI(resourceURI string) JWTProviderOption { return func(config *TokenProviderConfiguration) error { config.ResourceURI = resourceURI return nil } }
[ "func", "JWTProviderWithResourceURI", "(", "resourceURI", "string", ")", "JWTProviderOption", "{", "return", "func", "(", "config", "*", "TokenProviderConfiguration", ")", "error", "{", "config", ".", "ResourceURI", "=", "resourceURI", "\n", "return", "nil", "\n", ...
// JWTProviderWithResourceURI configures the token provider to use a specific eventhubResourceURI URI
[ "JWTProviderWithResourceURI", "configures", "the", "token", "provider", "to", "use", "a", "specific", "eventhubResourceURI", "URI" ]
b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a
https://github.com/Azure/azure-amqp-common-go/blob/b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a/aad/jwt.go#L108-L113
132,580
Azure/azure-amqp-common-go
aad/jwt.go
JWTProviderWithAADToken
func JWTProviderWithAADToken(aadToken *adal.ServicePrincipalToken) JWTProviderOption { return func(config *TokenProviderConfiguration) error { config.aadToken = aadToken return nil } }
go
func JWTProviderWithAADToken(aadToken *adal.ServicePrincipalToken) JWTProviderOption { return func(config *TokenProviderConfiguration) error { config.aadToken = aadToken return nil } }
[ "func", "JWTProviderWithAADToken", "(", "aadToken", "*", "adal", ".", "ServicePrincipalToken", ")", "JWTProviderOption", "{", "return", "func", "(", "config", "*", "TokenProviderConfiguration", ")", "error", "{", "config", ".", "aadToken", "=", "aadToken", "\n", "...
// JWTProviderWithAADToken configures the token provider to use a specific Azure Active Directory Service Principal token
[ "JWTProviderWithAADToken", "configures", "the", "token", "provider", "to", "use", "a", "specific", "Azure", "Active", "Directory", "Service", "Principal", "token" ]
b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a
https://github.com/Azure/azure-amqp-common-go/blob/b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a/aad/jwt.go#L116-L121
132,581
Azure/azure-amqp-common-go
aad/jwt.go
NewJWTProvider
func NewJWTProvider(opts ...JWTProviderOption) (*TokenProvider, error) { config := &TokenProviderConfiguration{ ResourceURI: eventhubResourceURI, } for _, opt := range opts { err := opt(config) if err != nil { return nil, err } } if config.aadToken == nil { spToken, err := config.NewServicePrincipal...
go
func NewJWTProvider(opts ...JWTProviderOption) (*TokenProvider, error) { config := &TokenProviderConfiguration{ ResourceURI: eventhubResourceURI, } for _, opt := range opts { err := opt(config) if err != nil { return nil, err } } if config.aadToken == nil { spToken, err := config.NewServicePrincipal...
[ "func", "NewJWTProvider", "(", "opts", "...", "JWTProviderOption", ")", "(", "*", "TokenProvider", ",", "error", ")", "{", "config", ":=", "&", "TokenProviderConfiguration", "{", "ResourceURI", ":", "eventhubResourceURI", ",", "}", "\n\n", "for", "_", ",", "op...
// NewJWTProvider builds an Azure Active Directory claims-based security token provider
[ "NewJWTProvider", "builds", "an", "Azure", "Active", "Directory", "claims", "-", "based", "security", "token", "provider" ]
b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a
https://github.com/Azure/azure-amqp-common-go/blob/b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a/aad/jwt.go#L124-L144
132,582
Azure/azure-amqp-common-go
aad/jwt.go
NewServicePrincipalToken
func (c *TokenProviderConfiguration) NewServicePrincipalToken() (*adal.ServicePrincipalToken, error) { oauthConfig, err := adal.NewOAuthConfig(c.Env.ActiveDirectoryEndpoint, c.TenantID) if err != nil { return nil, err } // 1.Client Credentials if c.ClientSecret != "" { spToken, err := adal.NewServicePrincipal...
go
func (c *TokenProviderConfiguration) NewServicePrincipalToken() (*adal.ServicePrincipalToken, error) { oauthConfig, err := adal.NewOAuthConfig(c.Env.ActiveDirectoryEndpoint, c.TenantID) if err != nil { return nil, err } // 1.Client Credentials if c.ClientSecret != "" { spToken, err := adal.NewServicePrincipal...
[ "func", "(", "c", "*", "TokenProviderConfiguration", ")", "NewServicePrincipalToken", "(", ")", "(", "*", "adal", ".", "ServicePrincipalToken", ",", "error", ")", "{", "oauthConfig", ",", "err", ":=", "adal", ".", "NewOAuthConfig", "(", "c", ".", "Env", ".",...
// NewServicePrincipalToken creates a new Azure Active Directory Service Principal token provider
[ "NewServicePrincipalToken", "creates", "a", "new", "Azure", "Active", "Directory", "Service", "Principal", "token", "provider" ]
b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a
https://github.com/Azure/azure-amqp-common-go/blob/b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a/aad/jwt.go#L147-L198
132,583
Azure/azure-amqp-common-go
aad/jwt.go
GetToken
func (t *TokenProvider) GetToken(audience string) (*auth.Token, error) { token := t.tokenProvider.Token() expireTicks, err := strconv.ParseInt(string(token.ExpiresOn), 10, 64) if err != nil { return nil, err } expires := time.Unix(expireTicks, 0) if expires.Before(time.Now()) { if err := t.tokenProvider.Refr...
go
func (t *TokenProvider) GetToken(audience string) (*auth.Token, error) { token := t.tokenProvider.Token() expireTicks, err := strconv.ParseInt(string(token.ExpiresOn), 10, 64) if err != nil { return nil, err } expires := time.Unix(expireTicks, 0) if expires.Before(time.Now()) { if err := t.tokenProvider.Refr...
[ "func", "(", "t", "*", "TokenProvider", ")", "GetToken", "(", "audience", "string", ")", "(", "*", "auth", ".", "Token", ",", "error", ")", "{", "token", ":=", "t", ".", "tokenProvider", ".", "Token", "(", ")", "\n", "expireTicks", ",", "err", ":=", ...
// GetToken gets a CBS JWT
[ "GetToken", "gets", "a", "CBS", "JWT" ]
b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a
https://github.com/Azure/azure-amqp-common-go/blob/b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a/aad/jwt.go#L201-L217
132,584
Azure/azure-amqp-common-go
auth/token.go
NewToken
func NewToken(tokenType TokenType, token, expiry string) *Token { return &Token{ TokenType: tokenType, Token: token, Expiry: expiry, } }
go
func NewToken(tokenType TokenType, token, expiry string) *Token { return &Token{ TokenType: tokenType, Token: token, Expiry: expiry, } }
[ "func", "NewToken", "(", "tokenType", "TokenType", ",", "token", ",", "expiry", "string", ")", "*", "Token", "{", "return", "&", "Token", "{", "TokenType", ":", "tokenType", ",", "Token", ":", "token", ",", "Expiry", ":", "expiry", ",", "}", "\n", "}" ...
// NewToken constructs a new auth token
[ "NewToken", "constructs", "a", "new", "auth", "token" ]
b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a
https://github.com/Azure/azure-amqp-common-go/blob/b5ea4829bce0d96bc7b4d11bfc8ccd2afdf0ec4a/auth/token.go#L52-L58
132,585
cloudfoundry/auction
auctionrunner/scheduler.go
removeNonApplicableProblems
func removeNonApplicableProblems(problems map[string]struct{}, err error) { if ierr, ok := err.(rep.InsufficientResourcesError); ok { for problem, _ := range problems { if _, ok := ierr.Problems[problem]; !ok { delete(problems, problem) } } } }
go
func removeNonApplicableProblems(problems map[string]struct{}, err error) { if ierr, ok := err.(rep.InsufficientResourcesError); ok { for problem, _ := range problems { if _, ok := ierr.Problems[problem]; !ok { delete(problems, problem) } } } }
[ "func", "removeNonApplicableProblems", "(", "problems", "map", "[", "string", "]", "struct", "{", "}", ",", "err", "error", ")", "{", "if", "ierr", ",", "ok", ":=", "err", ".", "(", "rep", ".", "InsufficientResourcesError", ")", ";", "ok", "{", "for", ...
// removeNonApplicableProblems modifies the 'problems' map to remove any problems that didn't show up on err. // // The list of problems to report should only consist of the problems that exist on every cell // For example, if there is not enough memory on one cell and not enough disk on another, we should // not call ...
[ "removeNonApplicableProblems", "modifies", "the", "problems", "map", "to", "remove", "any", "problems", "that", "didn", "t", "show", "up", "on", "err", ".", "The", "list", "of", "problems", "to", "report", "should", "only", "consist", "of", "the", "problems", ...
f5726c4858daf51bfa1216c5b3aefb212fc59fd1
https://github.com/cloudfoundry/auction/blob/f5726c4858daf51bfa1216c5b3aefb212fc59fd1/auctionrunner/scheduler.go#L384-L392
132,586
cloudfoundry/auction
simulation/simulationrep/simulation_rep.go
StopLRPInstance
func (rep *SimulationRep) StopLRPInstance(lager.Logger, models.ActualLRPKey, models.ActualLRPInstanceKey) error { panic("UNIMPLEMENTED METHOD") }
go
func (rep *SimulationRep) StopLRPInstance(lager.Logger, models.ActualLRPKey, models.ActualLRPInstanceKey) error { panic("UNIMPLEMENTED METHOD") }
[ "func", "(", "rep", "*", "SimulationRep", ")", "StopLRPInstance", "(", "lager", ".", "Logger", ",", "models", ".", "ActualLRPKey", ",", "models", ".", "ActualLRPInstanceKey", ")", "error", "{", "panic", "(", "\"", "\"", ")", "\n", "}" ]
//these are rep client methods the auction does not use
[ "these", "are", "rep", "client", "methods", "the", "auction", "does", "not", "use" ]
f5726c4858daf51bfa1216c5b3aefb212fc59fd1
https://github.com/cloudfoundry/auction/blob/f5726c4858daf51bfa1216c5b3aefb212fc59fd1/simulation/simulationrep/simulation_rep.go#L137-L139
132,587
ipfans/echo-session
session.go
Default
func Default(ctx echo.Context) Session { session := ctx.Get(DefaultKey) if session == nil { return nil } return ctx.Get(DefaultKey).(Session) }
go
func Default(ctx echo.Context) Session { session := ctx.Get(DefaultKey) if session == nil { return nil } return ctx.Get(DefaultKey).(Session) }
[ "func", "Default", "(", "ctx", "echo", ".", "Context", ")", "Session", "{", "session", ":=", "ctx", ".", "Get", "(", "DefaultKey", ")", "\n", "if", "session", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "ctx", ".", "Get", "(", "De...
// shortcut to get session
[ "shortcut", "to", "get", "session" ]
acc7adbf89867d8c5be673e0000f5c6f57ad50c1
https://github.com/ipfans/echo-session/blob/acc7adbf89867d8c5be673e0000f5c6f57ad50c1/session.go#L151-L157
132,588
gravitational/trace
httplib.go
WriteError
func WriteError(w http.ResponseWriter, err error) { if IsAggregate(err) { for i := 0; i < maxHops; i++ { var aggErr Aggregate var ok bool if aggErr, ok = Unwrap(err).(Aggregate); !ok { break } errors := aggErr.Errors() if len(errors) == 0 { break } err = errors[0] } } replyJSON(w,...
go
func WriteError(w http.ResponseWriter, err error) { if IsAggregate(err) { for i := 0; i < maxHops; i++ { var aggErr Aggregate var ok bool if aggErr, ok = Unwrap(err).(Aggregate); !ok { break } errors := aggErr.Errors() if len(errors) == 0 { break } err = errors[0] } } replyJSON(w,...
[ "func", "WriteError", "(", "w", "http", ".", "ResponseWriter", ",", "err", "error", ")", "{", "if", "IsAggregate", "(", "err", ")", "{", "for", "i", ":=", "0", ";", "i", "<", "maxHops", ";", "i", "++", "{", "var", "aggErr", "Aggregate", "\n", "var"...
// WriteError sets up HTTP error response and writes it to writer w
[ "WriteError", "sets", "up", "HTTP", "error", "response", "and", "writes", "it", "to", "writer", "w" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/httplib.go#L10-L26
132,589
gravitational/trace
httplib.go
ErrorToCode
func ErrorToCode(err error) int { switch { case IsAggregate(err): return http.StatusGatewayTimeout case IsNotFound(err): return http.StatusNotFound case IsBadParameter(err) || IsOAuth2(err): return http.StatusBadRequest case IsNotImplemented(err): return http.StatusNotImplemented case IsCompareFailed(err)...
go
func ErrorToCode(err error) int { switch { case IsAggregate(err): return http.StatusGatewayTimeout case IsNotFound(err): return http.StatusNotFound case IsBadParameter(err) || IsOAuth2(err): return http.StatusBadRequest case IsNotImplemented(err): return http.StatusNotImplemented case IsCompareFailed(err)...
[ "func", "ErrorToCode", "(", "err", "error", ")", "int", "{", "switch", "{", "case", "IsAggregate", "(", "err", ")", ":", "return", "http", ".", "StatusGatewayTimeout", "\n", "case", "IsNotFound", "(", "err", ")", ":", "return", "http", ".", "StatusNotFound...
// ErrorToCode returns an appropriate HTTP status code based on the provided error type
[ "ErrorToCode", "returns", "an", "appropriate", "HTTP", "status", "code", "based", "on", "the", "provided", "error", "type" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/httplib.go#L29-L52
132,590
gravitational/trace
httplib.go
ReadError
func ReadError(statusCode int, re []byte) error { var e error switch statusCode { case http.StatusNotFound: e = &NotFoundError{Message: string(re)} case http.StatusBadRequest: e = &BadParameterError{Message: string(re)} case http.StatusNotImplemented: e = &NotImplementedError{Message: string(re)} case http....
go
func ReadError(statusCode int, re []byte) error { var e error switch statusCode { case http.StatusNotFound: e = &NotFoundError{Message: string(re)} case http.StatusBadRequest: e = &BadParameterError{Message: string(re)} case http.StatusNotImplemented: e = &NotImplementedError{Message: string(re)} case http....
[ "func", "ReadError", "(", "statusCode", "int", ",", "re", "[", "]", "byte", ")", "error", "{", "var", "e", "error", "\n", "switch", "statusCode", "{", "case", "http", ".", "StatusNotFound", ":", "e", "=", "&", "NotFoundError", "{", "Message", ":", "str...
// ReadError converts http error to internal error type // based on HTTP response code and HTTP body contents // if status code does not indicate error, it will return nil
[ "ReadError", "converts", "http", "error", "to", "internal", "error", "type", "based", "on", "HTTP", "response", "code", "and", "HTTP", "body", "contents", "if", "status", "code", "does", "not", "indicate", "error", "it", "will", "return", "nil" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/httplib.go#L57-L83
132,591
gravitational/trace
trail/trail.go
ToGRPC
func ToGRPC(err error) error { if err == nil { return nil } userMessage := trace.UserMessage(err) if trace.IsNotFound(err) { return grpc.Errorf(codes.NotFound, userMessage) } if trace.IsAlreadyExists(err) { return grpc.Errorf(codes.AlreadyExists, userMessage) } if trace.IsAccessDenied(err) { return grpc...
go
func ToGRPC(err error) error { if err == nil { return nil } userMessage := trace.UserMessage(err) if trace.IsNotFound(err) { return grpc.Errorf(codes.NotFound, userMessage) } if trace.IsAlreadyExists(err) { return grpc.Errorf(codes.AlreadyExists, userMessage) } if trace.IsAccessDenied(err) { return grpc...
[ "func", "ToGRPC", "(", "err", "error", ")", "error", "{", "if", "err", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "userMessage", ":=", "trace", ".", "UserMessage", "(", "err", ")", "\n", "if", "trace", ".", "IsNotFound", "(", "err", ")", "...
// ToGRPC converts error to GRPC-compatible error
[ "ToGRPC", "converts", "error", "to", "GRPC", "-", "compatible", "error" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/trail/trail.go#L80-L110
132,592
gravitational/trace
trail/trail.go
FromGRPC
func FromGRPC(err error, args ...interface{}) error { if err == nil { return nil } code := grpc.Code(err) message := grpc.ErrorDesc(err) var e error switch code { case codes.OK: return nil case codes.NotFound: e = &trace.NotFoundError{Message: message} case codes.AlreadyExists: e = &trace.AlreadyExists...
go
func FromGRPC(err error, args ...interface{}) error { if err == nil { return nil } code := grpc.Code(err) message := grpc.ErrorDesc(err) var e error switch code { case codes.OK: return nil case codes.NotFound: e = &trace.NotFoundError{Message: message} case codes.AlreadyExists: e = &trace.AlreadyExists...
[ "func", "FromGRPC", "(", "err", "error", ",", "args", "...", "interface", "{", "}", ")", "error", "{", "if", "err", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "code", ":=", "grpc", ".", "Code", "(", "err", ")", "\n", "message", ":=", "gr...
// FromGRPC converts error from GRPC error back to trace.Error // Debug information will be retrieved from the metadata if specified in args
[ "FromGRPC", "converts", "error", "from", "GRPC", "error", "back", "to", "trace", ".", "Error", "Debug", "information", "will", "be", "retrieved", "from", "the", "metadata", "if", "specified", "in", "args" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/trail/trail.go#L114-L149
132,593
gravitational/trace
trail/trail.go
DecodeDebugInfo
func DecodeDebugInfo(err error, meta metadata.MD) error { if len(meta) == 0 { return err } encoded, ok := meta[DebugReportMetadata] if !ok || len(encoded) != 1 { return err } data, decodeErr := base64.StdEncoding.DecodeString(encoded[0]) if decodeErr != nil { return err } var raw trace.RawTrace if unmar...
go
func DecodeDebugInfo(err error, meta metadata.MD) error { if len(meta) == 0 { return err } encoded, ok := meta[DebugReportMetadata] if !ok || len(encoded) != 1 { return err } data, decodeErr := base64.StdEncoding.DecodeString(encoded[0]) if decodeErr != nil { return err } var raw trace.RawTrace if unmar...
[ "func", "DecodeDebugInfo", "(", "err", "error", ",", "meta", "metadata", ".", "MD", ")", "error", "{", "if", "len", "(", "meta", ")", "==", "0", "{", "return", "err", "\n", "}", "\n", "encoded", ",", "ok", ":=", "meta", "[", "DebugReportMetadata", "]...
// DecodeDebugInfo decodes debug information about error // from the metadata and returns error with enriched metadata about it
[ "DecodeDebugInfo", "decodes", "debug", "information", "about", "error", "from", "the", "metadata", "and", "returns", "error", "with", "enriched", "metadata", "about", "it" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/trail/trail.go#L168-L188
132,594
gravitational/trace
errors.go
NotFound
func NotFound(message string, args ...interface{}) error { return WrapWithMessage(&NotFoundError{ Message: fmt.Sprintf(message, args...), }, message, args...) }
go
func NotFound(message string, args ...interface{}) error { return WrapWithMessage(&NotFoundError{ Message: fmt.Sprintf(message, args...), }, message, args...) }
[ "func", "NotFound", "(", "message", "string", ",", "args", "...", "interface", "{", "}", ")", "error", "{", "return", "WrapWithMessage", "(", "&", "NotFoundError", "{", "Message", ":", "fmt", ".", "Sprintf", "(", "message", ",", "args", "...", ")", ",", ...
// NotFound returns new instance of not found error
[ "NotFound", "returns", "new", "instance", "of", "not", "found", "error" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/errors.go#L29-L33
132,595
gravitational/trace
errors.go
IsNotFound
func IsNotFound(e error) bool { type nf interface { IsNotFoundError() bool } err := Unwrap(e) _, ok := err.(nf) if !ok { return os.IsNotExist(err) } return ok }
go
func IsNotFound(e error) bool { type nf interface { IsNotFoundError() bool } err := Unwrap(e) _, ok := err.(nf) if !ok { return os.IsNotExist(err) } return ok }
[ "func", "IsNotFound", "(", "e", "error", ")", "bool", "{", "type", "nf", "interface", "{", "IsNotFoundError", "(", ")", "bool", "\n", "}", "\n", "err", ":=", "Unwrap", "(", "e", ")", "\n", "_", ",", "ok", ":=", "err", ".", "(", "nf", ")", "\n", ...
// IsNotFound returns whether this error is of NotFoundError type
[ "IsNotFound", "returns", "whether", "this", "error", "is", "of", "NotFoundError", "type" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/errors.go#L59-L69
132,596
gravitational/trace
errors.go
AlreadyExists
func AlreadyExists(message string, args ...interface{}) error { return WrapWithMessage(&AlreadyExistsError{ fmt.Sprintf(message, args...), }, message, args...) }
go
func AlreadyExists(message string, args ...interface{}) error { return WrapWithMessage(&AlreadyExistsError{ fmt.Sprintf(message, args...), }, message, args...) }
[ "func", "AlreadyExists", "(", "message", "string", ",", "args", "...", "interface", "{", "}", ")", "error", "{", "return", "WrapWithMessage", "(", "&", "AlreadyExistsError", "{", "fmt", ".", "Sprintf", "(", "message", ",", "args", "...", ")", ",", "}", "...
// AlreadyExists returns a new instance of AlreadyExists error
[ "AlreadyExists", "returns", "a", "new", "instance", "of", "AlreadyExists", "error" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/errors.go#L72-L76
132,597
gravitational/trace
errors.go
IsAlreadyExists
func IsAlreadyExists(e error) bool { type ae interface { IsAlreadyExistsError() bool } _, ok := Unwrap(e).(ae) return ok }
go
func IsAlreadyExists(e error) bool { type ae interface { IsAlreadyExistsError() bool } _, ok := Unwrap(e).(ae) return ok }
[ "func", "IsAlreadyExists", "(", "e", "error", ")", "bool", "{", "type", "ae", "interface", "{", "IsAlreadyExistsError", "(", ")", "bool", "\n", "}", "\n", "_", ",", "ok", ":=", "Unwrap", "(", "e", ")", ".", "(", "ae", ")", "\n", "return", "ok", "\n...
// IsAlreadyExists returns whether this is error indicating that object // already exists
[ "IsAlreadyExists", "returns", "whether", "this", "is", "error", "indicating", "that", "object", "already", "exists" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/errors.go#L104-L110
132,598
gravitational/trace
errors.go
BadParameter
func BadParameter(message string, args ...interface{}) error { return WrapWithMessage(&BadParameterError{ Message: fmt.Sprintf(message, args...), }, message, args...) }
go
func BadParameter(message string, args ...interface{}) error { return WrapWithMessage(&BadParameterError{ Message: fmt.Sprintf(message, args...), }, message, args...) }
[ "func", "BadParameter", "(", "message", "string", ",", "args", "...", "interface", "{", "}", ")", "error", "{", "return", "WrapWithMessage", "(", "&", "BadParameterError", "{", "Message", ":", "fmt", ".", "Sprintf", "(", "message", ",", "args", "...", ")",...
// BadParameter returns a new instance of BadParameterError
[ "BadParameter", "returns", "a", "new", "instance", "of", "BadParameterError" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/errors.go#L113-L117
132,599
gravitational/trace
errors.go
IsBadParameter
func IsBadParameter(e error) bool { type bp interface { IsBadParameterError() bool } _, ok := Unwrap(e).(bp) return ok }
go
func IsBadParameter(e error) bool { type bp interface { IsBadParameterError() bool } _, ok := Unwrap(e).(bp) return ok }
[ "func", "IsBadParameter", "(", "e", "error", ")", "bool", "{", "type", "bp", "interface", "{", "IsBadParameterError", "(", ")", "bool", "\n", "}", "\n", "_", ",", "ok", ":=", "Unwrap", "(", "e", ")", ".", "(", "bp", ")", "\n", "return", "ok", "\n",...
// IsBadParameter returns whether this error is of BadParameterType
[ "IsBadParameter", "returns", "whether", "this", "error", "is", "of", "BadParameterType" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/errors.go#L141-L147