id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
20,600
trivago/gollum
core/metadata.go
SetValue
func (meta Metadata) SetValue(key string, value []byte) { meta[key] = value }
go
func (meta Metadata) SetValue(key string, value []byte) { meta[key] = value }
[ "func", "(", "meta", "Metadata", ")", "SetValue", "(", "key", "string", ",", "value", "[", "]", "byte", ")", "{", "meta", "[", "key", "]", "=", "value", "\n", "}" ]
// SetValue set a key value pair at meta data
[ "SetValue", "set", "a", "key", "value", "pair", "at", "meta", "data" ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/core/metadata.go#L21-L23
20,601
trivago/gollum
core/metadata.go
TrySetValue
func (meta Metadata) TrySetValue(key string, value []byte) bool { if _, exists := meta[key]; exists { meta[key] = value return true } return false }
go
func (meta Metadata) TrySetValue(key string, value []byte) bool { if _, exists := meta[key]; exists { meta[key] = value return true } return false }
[ "func", "(", "meta", "Metadata", ")", "TrySetValue", "(", "key", "string", ",", "value", "[", "]", "byte", ")", "bool", "{", "if", "_", ",", "exists", ":=", "meta", "[", "key", "]", ";", "exists", "{", "meta", "[", "key", "]", "=", "value", "\n",...
// TrySetValue sets a key value pair only if the key is already existing
[ "TrySetValue", "sets", "a", "key", "value", "pair", "only", "if", "the", "key", "is", "already", "existing" ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/core/metadata.go#L26-L32
20,602
trivago/gollum
core/metadata.go
GetValue
func (meta Metadata) GetValue(key string) []byte { if value, isSet := meta[key]; isSet { return value } return []byte{} }
go
func (meta Metadata) GetValue(key string) []byte { if value, isSet := meta[key]; isSet { return value } return []byte{} }
[ "func", "(", "meta", "Metadata", ")", "GetValue", "(", "key", "string", ")", "[", "]", "byte", "{", "if", "value", ",", "isSet", ":=", "meta", "[", "key", "]", ";", "isSet", "{", "return", "value", "\n", "}", "\n\n", "return", "[", "]", "byte", "...
// GetValue returns a meta data value by key. This function returns a value if // key is not set, too. In that case it will return an empty byte array.
[ "GetValue", "returns", "a", "meta", "data", "value", "by", "key", ".", "This", "function", "returns", "a", "value", "if", "key", "is", "not", "set", "too", ".", "In", "that", "case", "it", "will", "return", "an", "empty", "byte", "array", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/core/metadata.go#L36-L42
20,603
trivago/gollum
core/metadata.go
TryGetValue
func (meta Metadata) TryGetValue(key string) ([]byte, bool) { if value, isSet := meta[key]; isSet { return value, true } return []byte{}, false }
go
func (meta Metadata) TryGetValue(key string) ([]byte, bool) { if value, isSet := meta[key]; isSet { return value, true } return []byte{}, false }
[ "func", "(", "meta", "Metadata", ")", "TryGetValue", "(", "key", "string", ")", "(", "[", "]", "byte", ",", "bool", ")", "{", "if", "value", ",", "isSet", ":=", "meta", "[", "key", "]", ";", "isSet", "{", "return", "value", ",", "true", "\n", "}"...
// TryGetValue behaves like GetValue but returns a second value which denotes // if the key was set or not.
[ "TryGetValue", "behaves", "like", "GetValue", "but", "returns", "a", "second", "value", "which", "denotes", "if", "the", "key", "was", "set", "or", "not", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/core/metadata.go#L46-L51
20,604
trivago/gollum
core/metadata.go
GetValueString
func (meta Metadata) GetValueString(key string) string { return string(meta.GetValue(key)) }
go
func (meta Metadata) GetValueString(key string) string { return string(meta.GetValue(key)) }
[ "func", "(", "meta", "Metadata", ")", "GetValueString", "(", "key", "string", ")", "string", "{", "return", "string", "(", "meta", ".", "GetValue", "(", "key", ")", ")", "\n", "}" ]
// GetValueString casts the results of GetValue to a string
[ "GetValueString", "casts", "the", "results", "of", "GetValue", "to", "a", "string" ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/core/metadata.go#L54-L56
20,605
trivago/gollum
core/metadata.go
TryGetValueString
func (meta Metadata) TryGetValueString(key string) (string, bool) { data, exists := meta.TryGetValue(key) return string(data), exists }
go
func (meta Metadata) TryGetValueString(key string) (string, bool) { data, exists := meta.TryGetValue(key) return string(data), exists }
[ "func", "(", "meta", "Metadata", ")", "TryGetValueString", "(", "key", "string", ")", "(", "string", ",", "bool", ")", "{", "data", ",", "exists", ":=", "meta", ".", "TryGetValue", "(", "key", ")", "\n", "return", "string", "(", "data", ")", ",", "ex...
// TryGetValueString casts the data result of TryGetValue to string
[ "TryGetValueString", "casts", "the", "data", "result", "of", "TryGetValue", "to", "string" ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/core/metadata.go#L59-L62
20,606
trivago/gollum
core/metadata.go
Clone
func (meta Metadata) Clone() (clone Metadata) { clone = Metadata{} for k, v := range meta { vCopy := make([]byte, len(v)) copy(vCopy, v) clone[k] = vCopy } return }
go
func (meta Metadata) Clone() (clone Metadata) { clone = Metadata{} for k, v := range meta { vCopy := make([]byte, len(v)) copy(vCopy, v) clone[k] = vCopy } return }
[ "func", "(", "meta", "Metadata", ")", "Clone", "(", ")", "(", "clone", "Metadata", ")", "{", "clone", "=", "Metadata", "{", "}", "\n", "for", "k", ",", "v", ":=", "range", "meta", "{", "vCopy", ":=", "make", "(", "[", "]", "byte", ",", "len", "...
// Clone creates an exact copy of this metadata map.
[ "Clone", "creates", "an", "exact", "copy", "of", "this", "metadata", "map", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/core/metadata.go#L70-L78
20,607
trivago/gollum
core/simpleproducer.go
Modulate
func (prod *SimpleProducer) Modulate(msg *Message) ModulateResult { if len(prod.modulators) > 0 { msg.FreezeOriginal() return prod.modulators.Modulate(msg) } return ModulateResultContinue }
go
func (prod *SimpleProducer) Modulate(msg *Message) ModulateResult { if len(prod.modulators) > 0 { msg.FreezeOriginal() return prod.modulators.Modulate(msg) } return ModulateResultContinue }
[ "func", "(", "prod", "*", "SimpleProducer", ")", "Modulate", "(", "msg", "*", "Message", ")", "ModulateResult", "{", "if", "len", "(", "prod", ".", "modulators", ")", ">", "0", "{", "msg", ".", "FreezeOriginal", "(", ")", "\n", "return", "prod", ".", ...
// Modulate applies all modulators from this producer to a given message. // This implementation handles routing and discarding of messages.
[ "Modulate", "applies", "all", "modulators", "from", "this", "producer", "to", "a", "given", "message", ".", "This", "implementation", "handles", "routing", "and", "discarding", "of", "messages", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/core/simpleproducer.go#L191-L197
20,608
trivago/gollum
core/simpleproducer.go
HasContinueAfterModulate
func (prod *SimpleProducer) HasContinueAfterModulate(msg *Message) bool { switch result := prod.Modulate(msg); result { case ModulateResultDiscard: DiscardMessage(msg, prod.GetID(), "Producer discarded") return false case ModulateResultFallback: if err := Route(msg, msg.GetRouter()); err != nil { prod.Logg...
go
func (prod *SimpleProducer) HasContinueAfterModulate(msg *Message) bool { switch result := prod.Modulate(msg); result { case ModulateResultDiscard: DiscardMessage(msg, prod.GetID(), "Producer discarded") return false case ModulateResultFallback: if err := Route(msg, msg.GetRouter()); err != nil { prod.Logg...
[ "func", "(", "prod", "*", "SimpleProducer", ")", "HasContinueAfterModulate", "(", "msg", "*", "Message", ")", "bool", "{", "switch", "result", ":=", "prod", ".", "Modulate", "(", "msg", ")", ";", "result", "{", "case", "ModulateResultDiscard", ":", "DiscardM...
// HasContinueAfterModulate applies all modulators by Modulate, handle the ModulateResult // and return if you have to continue the message process. // This method is a default producer modulate handling.
[ "HasContinueAfterModulate", "applies", "all", "modulators", "by", "Modulate", "handle", "the", "ModulateResult", "and", "return", "if", "you", "have", "to", "continue", "the", "message", "process", ".", "This", "method", "is", "a", "default", "producer", "modulate...
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/core/simpleproducer.go#L202-L222
20,609
trivago/gollum
core/simpleproducer.go
TryFallback
func (prod *SimpleProducer) TryFallback(msg *Message) { if err := RouteOriginal(msg, prod.fallbackStream); err != nil { prod.Logger.WithError(err).Error("Failed to route to fallback") } }
go
func (prod *SimpleProducer) TryFallback(msg *Message) { if err := RouteOriginal(msg, prod.fallbackStream); err != nil { prod.Logger.WithError(err).Error("Failed to route to fallback") } }
[ "func", "(", "prod", "*", "SimpleProducer", ")", "TryFallback", "(", "msg", "*", "Message", ")", "{", "if", "err", ":=", "RouteOriginal", "(", "msg", ",", "prod", ".", "fallbackStream", ")", ";", "err", "!=", "nil", "{", "prod", ".", "Logger", ".", "...
// TryFallback routes the message to the configured fallback stream.
[ "TryFallback", "routes", "the", "message", "to", "the", "configured", "fallback", "stream", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/core/simpleproducer.go#L225-L229
20,610
trivago/gollum
core/simpleproducer.go
ControlLoop
func (prod *SimpleProducer) ControlLoop() { prod.setState(PluginStateActive) defer prod.setState(PluginStateDead) defer prod.Logger.Debug("Stopped") for { command := <-prod.control switch command { default: prod.Logger.Debug("Received untracked command") // Do nothing case PluginControlStopProducer:...
go
func (prod *SimpleProducer) ControlLoop() { prod.setState(PluginStateActive) defer prod.setState(PluginStateDead) defer prod.Logger.Debug("Stopped") for { command := <-prod.control switch command { default: prod.Logger.Debug("Received untracked command") // Do nothing case PluginControlStopProducer:...
[ "func", "(", "prod", "*", "SimpleProducer", ")", "ControlLoop", "(", ")", "{", "prod", ".", "setState", "(", "PluginStateActive", ")", "\n", "defer", "prod", ".", "setState", "(", "PluginStateDead", ")", "\n", "defer", "prod", ".", "Logger", ".", "Debug", ...
// ControlLoop listens to the control channel and triggers callbacks for these // messags. Upon stop control message doExit will be set to true.
[ "ControlLoop", "listens", "to", "the", "control", "channel", "and", "triggers", "callbacks", "for", "these", "messags", ".", "Upon", "stop", "control", "message", "doExit", "will", "be", "set", "to", "true", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/core/simpleproducer.go#L233-L272
20,611
trivago/gollum
core/simpleproducer.go
TickerControlLoop
func (prod *SimpleProducer) TickerControlLoop(interval time.Duration, onTimeOut func()) { prod.setState(PluginStateActive) go prod.ControlLoop() prod.tickerLoop(interval, onTimeOut) }
go
func (prod *SimpleProducer) TickerControlLoop(interval time.Duration, onTimeOut func()) { prod.setState(PluginStateActive) go prod.ControlLoop() prod.tickerLoop(interval, onTimeOut) }
[ "func", "(", "prod", "*", "SimpleProducer", ")", "TickerControlLoop", "(", "interval", "time", ".", "Duration", ",", "onTimeOut", "func", "(", ")", ")", "{", "prod", ".", "setState", "(", "PluginStateActive", ")", "\n", "go", "prod", ".", "ControlLoop", "(...
// TickerControlLoop is like ControlLoop but executes a given function at // every given interval tick, too. If the onTick function takes longer than // interval, the next tick will be delayed until onTick finishes.
[ "TickerControlLoop", "is", "like", "ControlLoop", "but", "executes", "a", "given", "function", "at", "every", "given", "interval", "tick", "too", ".", "If", "the", "onTick", "function", "takes", "longer", "than", "interval", "the", "next", "tick", "will", "be"...
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/core/simpleproducer.go#L277-L281
20,612
trivago/gollum
producer/proxy.go
Produce
func (prod *Proxy) Produce(workers *sync.WaitGroup) { prod.AddMainWorker(workers) prod.MessageControlLoop(prod.sendMessage) }
go
func (prod *Proxy) Produce(workers *sync.WaitGroup) { prod.AddMainWorker(workers) prod.MessageControlLoop(prod.sendMessage) }
[ "func", "(", "prod", "*", "Proxy", ")", "Produce", "(", "workers", "*", "sync", ".", "WaitGroup", ")", "{", "prod", ".", "AddMainWorker", "(", "workers", ")", "\n", "prod", ".", "MessageControlLoop", "(", "prod", ".", "sendMessage", ")", "\n", "}" ]
// Produce writes to a buffer that is sent to a given Proxy.
[ "Produce", "writes", "to", "a", "buffer", "that", "is", "sent", "to", "a", "given", "Proxy", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/producer/proxy.go#L213-L216
20,613
trivago/gollum
consumer/http.go
requestHandler
func (cons *HTTP) requestHandler(resp http.ResponseWriter, req *http.Request) { if cons.htpasswd != "" { if !cons.checkAuth(req) { resp.WriteHeader(http.StatusUnauthorized) return } } if cons.withHeaders { // Read the whole package requestBuffer := bytes.NewBuffer(nil) if err := req.Write(requestBuf...
go
func (cons *HTTP) requestHandler(resp http.ResponseWriter, req *http.Request) { if cons.htpasswd != "" { if !cons.checkAuth(req) { resp.WriteHeader(http.StatusUnauthorized) return } } if cons.withHeaders { // Read the whole package requestBuffer := bytes.NewBuffer(nil) if err := req.Write(requestBuf...
[ "func", "(", "cons", "*", "HTTP", ")", "requestHandler", "(", "resp", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "if", "cons", ".", "htpasswd", "!=", "\"", "\"", "{", "if", "!", "cons", ".", "checkAuth", "(", ...
// requestHandler will handle a single web request.
[ "requestHandler", "will", "handle", "a", "single", "web", "request", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/consumer/http.go#L124-L161
20,614
trivago/gollum
producer/InfluxDBWriter10.go
configure
func (writer *influxDBWriter10) configure(conf core.PluginConfigReader, prod *InfluxDB) error { writer.host = conf.GetString("Host", "localhost:8086") writer.username = conf.GetString("User", "") writer.password = conf.GetString("Password", "") writer.databaseTemplate = conf.GetString("Database", "default") writer...
go
func (writer *influxDBWriter10) configure(conf core.PluginConfigReader, prod *InfluxDB) error { writer.host = conf.GetString("Host", "localhost:8086") writer.username = conf.GetString("User", "") writer.password = conf.GetString("Password", "") writer.databaseTemplate = conf.GetString("Database", "default") writer...
[ "func", "(", "writer", "*", "influxDBWriter10", ")", "configure", "(", "conf", "core", ".", "PluginConfigReader", ",", "prod", "*", "InfluxDB", ")", "error", "{", "writer", ".", "host", "=", "conf", ".", "GetString", "(", "\"", "\"", ",", "\"", "\"", "...
// Configure sets the database connection values
[ "Configure", "sets", "the", "database", "connection", "values" ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/producer/InfluxDBWriter10.go#L49-L74
20,615
trivago/gollum
producer/awsS3.go
Produce
func (prod *AwsS3) Produce(workers *sync.WaitGroup) { prod.initS3Client() prod.AddMainWorker(workers) prod.TickerMessageControlLoop(prod.writeMessage, prod.BatchConfig.BatchTimeout, prod.writeBatchOnTimeOut) }
go
func (prod *AwsS3) Produce(workers *sync.WaitGroup) { prod.initS3Client() prod.AddMainWorker(workers) prod.TickerMessageControlLoop(prod.writeMessage, prod.BatchConfig.BatchTimeout, prod.writeBatchOnTimeOut) }
[ "func", "(", "prod", "*", "AwsS3", ")", "Produce", "(", "workers", "*", "sync", ".", "WaitGroup", ")", "{", "prod", ".", "initS3Client", "(", ")", "\n\n", "prod", ".", "AddMainWorker", "(", "workers", ")", "\n", "prod", ".", "TickerMessageControlLoop", "...
// Produce writes to a buffer that is send to S3 as a multipart upload.
[ "Produce", "writes", "to", "a", "buffer", "that", "is", "send", "to", "S3", "as", "a", "multipart", "upload", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/producer/awsS3.go#L118-L123
20,616
trivago/gollum
core/pluginstructtag.go
GetBool
func (tag PluginStructTag) GetBool() bool { tagValue, tagSet := reflect.StructTag(tag).Lookup(PluginStructTagDefault) if !tagSet || tagValue == "" { return false } value, err := strconv.ParseBool(tagValue) if err != nil { panic(err) } return value }
go
func (tag PluginStructTag) GetBool() bool { tagValue, tagSet := reflect.StructTag(tag).Lookup(PluginStructTagDefault) if !tagSet || tagValue == "" { return false } value, err := strconv.ParseBool(tagValue) if err != nil { panic(err) } return value }
[ "func", "(", "tag", "PluginStructTag", ")", "GetBool", "(", ")", "bool", "{", "tagValue", ",", "tagSet", ":=", "reflect", ".", "StructTag", "(", "tag", ")", ".", "Lookup", "(", "PluginStructTagDefault", ")", "\n", "if", "!", "tagSet", "||", "tagValue", "...
// GetBool returns the default boolean value for an auto configured field. // When not set, false is returned.
[ "GetBool", "returns", "the", "default", "boolean", "value", "for", "an", "auto", "configured", "field", ".", "When", "not", "set", "false", "is", "returned", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/core/pluginstructtag.go#L38-L48
20,617
trivago/gollum
core/pluginstructtag.go
GetInt
func (tag PluginStructTag) GetInt() int64 { tagValue, tagSet := reflect.StructTag(tag).Lookup(PluginStructTagDefault) if !tagSet || len(tagValue) == 0 { return 0 } value, err := tstrings.AtoI64(tagValue) if err != nil { panic(err) } return value }
go
func (tag PluginStructTag) GetInt() int64 { tagValue, tagSet := reflect.StructTag(tag).Lookup(PluginStructTagDefault) if !tagSet || len(tagValue) == 0 { return 0 } value, err := tstrings.AtoI64(tagValue) if err != nil { panic(err) } return value }
[ "func", "(", "tag", "PluginStructTag", ")", "GetInt", "(", ")", "int64", "{", "tagValue", ",", "tagSet", ":=", "reflect", ".", "StructTag", "(", "tag", ")", ".", "Lookup", "(", "PluginStructTagDefault", ")", "\n", "if", "!", "tagSet", "||", "len", "(", ...
// GetInt returns the default integer value for an auto configured field. // When not set, 0 is returned. Metrics are not applied to this value.
[ "GetInt", "returns", "the", "default", "integer", "value", "for", "an", "auto", "configured", "field", ".", "When", "not", "set", "0", "is", "returned", ".", "Metrics", "are", "not", "applied", "to", "this", "value", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/core/pluginstructtag.go#L52-L63
20,618
trivago/gollum
core/pluginstructtag.go
GetUint
func (tag PluginStructTag) GetUint() uint64 { tagValue, tagSet := reflect.StructTag(tag).Lookup(PluginStructTagDefault) if !tagSet || len(tagValue) == 0 { return 0 } value, err := tstrings.AtoU64(tagValue) if err != nil { panic(err) } return value }
go
func (tag PluginStructTag) GetUint() uint64 { tagValue, tagSet := reflect.StructTag(tag).Lookup(PluginStructTagDefault) if !tagSet || len(tagValue) == 0 { return 0 } value, err := tstrings.AtoU64(tagValue) if err != nil { panic(err) } return value }
[ "func", "(", "tag", "PluginStructTag", ")", "GetUint", "(", ")", "uint64", "{", "tagValue", ",", "tagSet", ":=", "reflect", ".", "StructTag", "(", "tag", ")", ".", "Lookup", "(", "PluginStructTagDefault", ")", "\n", "if", "!", "tagSet", "||", "len", "(",...
// GetUint returns the default unsigned integer value for an auto configured // field. When not set, 0 is returned. Metrics are not applied to this value.
[ "GetUint", "returns", "the", "default", "unsigned", "integer", "value", "for", "an", "auto", "configured", "field", ".", "When", "not", "set", "0", "is", "returned", ".", "Metrics", "are", "not", "applied", "to", "this", "value", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/core/pluginstructtag.go#L67-L78
20,619
trivago/gollum
core/pluginstructtag.go
GetString
func (tag PluginStructTag) GetString() string { tagValue, tagSet := reflect.StructTag(tag).Lookup(PluginStructTagDefault) if !tagSet { return "" } return tstrings.Unescape(tagValue) }
go
func (tag PluginStructTag) GetString() string { tagValue, tagSet := reflect.StructTag(tag).Lookup(PluginStructTagDefault) if !tagSet { return "" } return tstrings.Unescape(tagValue) }
[ "func", "(", "tag", "PluginStructTag", ")", "GetString", "(", ")", "string", "{", "tagValue", ",", "tagSet", ":=", "reflect", ".", "StructTag", "(", "tag", ")", ".", "Lookup", "(", "PluginStructTagDefault", ")", "\n", "if", "!", "tagSet", "{", "return", ...
// GetString returns the default string value for an auto configured field. // When not set, "" is returned.
[ "GetString", "returns", "the", "default", "string", "value", "for", "an", "auto", "configured", "field", ".", "When", "not", "set", "is", "returned", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/core/pluginstructtag.go#L82-L88
20,620
trivago/gollum
core/pluginstructtag.go
GetStream
func (tag PluginStructTag) GetStream() MessageStreamID { tagValue, tagSet := reflect.StructTag(tag).Lookup(PluginStructTagDefault) if !tagSet { return InvalidStreamID } return GetStreamID(tagValue) }
go
func (tag PluginStructTag) GetStream() MessageStreamID { tagValue, tagSet := reflect.StructTag(tag).Lookup(PluginStructTagDefault) if !tagSet { return InvalidStreamID } return GetStreamID(tagValue) }
[ "func", "(", "tag", "PluginStructTag", ")", "GetStream", "(", ")", "MessageStreamID", "{", "tagValue", ",", "tagSet", ":=", "reflect", ".", "StructTag", "(", "tag", ")", ".", "Lookup", "(", "PluginStructTagDefault", ")", "\n", "if", "!", "tagSet", "{", "re...
// GetStream returns the default message stream value for an auto configured // field. When not set, InvalidStream is returned.
[ "GetStream", "returns", "the", "default", "message", "stream", "value", "for", "an", "auto", "configured", "field", ".", "When", "not", "set", "InvalidStream", "is", "returned", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/core/pluginstructtag.go#L92-L98
20,621
trivago/gollum
core/pluginstructtag.go
GetStringArray
func (tag PluginStructTag) GetStringArray() []string { tagValue, tagSet := reflect.StructTag(tag).Lookup(PluginStructTagDefault) if !tagSet { return []string{} } return strings.Split(tagValue, ",") }
go
func (tag PluginStructTag) GetStringArray() []string { tagValue, tagSet := reflect.StructTag(tag).Lookup(PluginStructTagDefault) if !tagSet { return []string{} } return strings.Split(tagValue, ",") }
[ "func", "(", "tag", "PluginStructTag", ")", "GetStringArray", "(", ")", "[", "]", "string", "{", "tagValue", ",", "tagSet", ":=", "reflect", ".", "StructTag", "(", "tag", ")", ".", "Lookup", "(", "PluginStructTagDefault", ")", "\n", "if", "!", "tagSet", ...
// GetStringArray returns the default string array value for an auto configured // field. When not set an empty array is returned.
[ "GetStringArray", "returns", "the", "default", "string", "array", "value", "for", "an", "auto", "configured", "field", ".", "When", "not", "set", "an", "empty", "array", "is", "returned", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/core/pluginstructtag.go#L102-L108
20,622
trivago/gollum
core/pluginstructtag.go
GetByteArray
func (tag PluginStructTag) GetByteArray() []byte { tagValue, tagSet := reflect.StructTag(tag).Lookup(PluginStructTagDefault) if !tagSet { return []byte{} } return []byte(tagValue) }
go
func (tag PluginStructTag) GetByteArray() []byte { tagValue, tagSet := reflect.StructTag(tag).Lookup(PluginStructTagDefault) if !tagSet { return []byte{} } return []byte(tagValue) }
[ "func", "(", "tag", "PluginStructTag", ")", "GetByteArray", "(", ")", "[", "]", "byte", "{", "tagValue", ",", "tagSet", ":=", "reflect", ".", "StructTag", "(", "tag", ")", ".", "Lookup", "(", "PluginStructTagDefault", ")", "\n", "if", "!", "tagSet", "{",...
// GetByteArray returns the default byte array value for an auto configured // field. When not set an empty array is returned.
[ "GetByteArray", "returns", "the", "default", "byte", "array", "value", "for", "an", "auto", "configured", "field", ".", "When", "not", "set", "an", "empty", "array", "is", "returned", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/core/pluginstructtag.go#L112-L118
20,623
trivago/gollum
core/pluginstructtag.go
GetStreamArray
func (tag PluginStructTag) GetStreamArray() []MessageStreamID { streamNames := tag.GetStringArray() streamIDs := make([]MessageStreamID, 0, len(streamNames)) for _, name := range streamNames { streamIDs = append(streamIDs, GetStreamID(strings.TrimSpace(name))) } return streamIDs }
go
func (tag PluginStructTag) GetStreamArray() []MessageStreamID { streamNames := tag.GetStringArray() streamIDs := make([]MessageStreamID, 0, len(streamNames)) for _, name := range streamNames { streamIDs = append(streamIDs, GetStreamID(strings.TrimSpace(name))) } return streamIDs }
[ "func", "(", "tag", "PluginStructTag", ")", "GetStreamArray", "(", ")", "[", "]", "MessageStreamID", "{", "streamNames", ":=", "tag", ".", "GetStringArray", "(", ")", "\n", "streamIDs", ":=", "make", "(", "[", "]", "MessageStreamID", ",", "0", ",", "len", ...
// GetStreamArray returns the default message stream array value for an auto // configured field. When not set an empty array is returned.
[ "GetStreamArray", "returns", "the", "default", "message", "stream", "array", "value", "for", "an", "auto", "configured", "field", ".", "When", "not", "set", "an", "empty", "array", "is", "returned", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/core/pluginstructtag.go#L122-L130
20,624
trivago/gollum
core/pluginstructtag.go
GetMetricScale
func (tag PluginStructTag) GetMetricScale() int64 { tagValue, tagSet := reflect.StructTag(tag).Lookup(PluginStructTagMetric) if !tagSet { return 1 } return metricScale[strings.ToLower(tagValue)] }
go
func (tag PluginStructTag) GetMetricScale() int64 { tagValue, tagSet := reflect.StructTag(tag).Lookup(PluginStructTagMetric) if !tagSet { return 1 } return metricScale[strings.ToLower(tagValue)] }
[ "func", "(", "tag", "PluginStructTag", ")", "GetMetricScale", "(", ")", "int64", "{", "tagValue", ",", "tagSet", ":=", "reflect", ".", "StructTag", "(", "tag", ")", ".", "Lookup", "(", "PluginStructTagMetric", ")", "\n", "if", "!", "tagSet", "{", "return",...
// GetMetricScale returns the scale as defined by the "metric" tag as a number.
[ "GetMetricScale", "returns", "the", "scale", "as", "defined", "by", "the", "metric", "tag", "as", "a", "number", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/core/pluginstructtag.go#L133-L140
20,625
trivago/gollum
format/groktojson.go
applyGrok
func (format *GrokToJSON) applyGrok(content string) (map[string]string, error) { for _, exp := range format.exp { values := exp.ParseString(content) if len(values) > 0 { return values, nil } } format.Logger.Warningf("Message does not match any pattern: %s", content) return nil, fmt.Errorf("grok parsing err...
go
func (format *GrokToJSON) applyGrok(content string) (map[string]string, error) { for _, exp := range format.exp { values := exp.ParseString(content) if len(values) > 0 { return values, nil } } format.Logger.Warningf("Message does not match any pattern: %s", content) return nil, fmt.Errorf("grok parsing err...
[ "func", "(", "format", "*", "GrokToJSON", ")", "applyGrok", "(", "content", "string", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "for", "_", ",", "exp", ":=", "range", "format", ".", "exp", "{", "values", ":=", "exp", "....
// grok iterates over all defined patterns and parses the content based on the first match. // It returns a map of the defined values.
[ "grok", "iterates", "over", "all", "defined", "patterns", "and", "parses", "the", "content", "based", "on", "the", "first", "match", ".", "It", "returns", "a", "map", "of", "the", "defined", "values", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/format/groktojson.go#L130-L139
20,626
trivago/gollum
consumer/console.go
Enqueue
func (cons *Console) Enqueue(data []byte) { if cons.hasToSetMetadata { metaData := core.Metadata{} metaData.SetValue("pipe", []byte(cons.pipeName)) cons.EnqueueWithMetadata(data, metaData) } else { cons.SimpleConsumer.Enqueue(data) } }
go
func (cons *Console) Enqueue(data []byte) { if cons.hasToSetMetadata { metaData := core.Metadata{} metaData.SetValue("pipe", []byte(cons.pipeName)) cons.EnqueueWithMetadata(data, metaData) } else { cons.SimpleConsumer.Enqueue(data) } }
[ "func", "(", "cons", "*", "Console", ")", "Enqueue", "(", "data", "[", "]", "byte", ")", "{", "if", "cons", ".", "hasToSetMetadata", "{", "metaData", ":=", "core", ".", "Metadata", "{", "}", "\n", "metaData", ".", "SetValue", "(", "\"", "\"", ",", ...
// Enqueue creates a new message
[ "Enqueue", "creates", "a", "new", "message" ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/consumer/console.go#L96-L105
20,627
trivago/gollum
docs/generator/tree.go
NewTree
func NewTree(rootAstNode ast.Node) *TreeNode { treeCursor := treeCursor{} // Stub root treeCursor.root = &TreeNode{ AstNode: nil, Parent: nil, Children: []*TreeNode{}, } treeCursor.current = treeCursor.root treeCursor.currentDepth = 0 // Populate the tree ast.Inspect(rootAstNode, treeCursor.insert) ...
go
func NewTree(rootAstNode ast.Node) *TreeNode { treeCursor := treeCursor{} // Stub root treeCursor.root = &TreeNode{ AstNode: nil, Parent: nil, Children: []*TreeNode{}, } treeCursor.current = treeCursor.root treeCursor.currentDepth = 0 // Populate the tree ast.Inspect(rootAstNode, treeCursor.insert) ...
[ "func", "NewTree", "(", "rootAstNode", "ast", ".", "Node", ")", "*", "TreeNode", "{", "treeCursor", ":=", "treeCursor", "{", "}", "\n\n", "// Stub root", "treeCursor", ".", "root", "=", "&", "TreeNode", "{", "AstNode", ":", "nil", ",", "Parent", ":", "ni...
// NewTree creates a new tree of TreeNodes from the contents of the Go AST rooted at rootAstNode. // Returns a pointer to the root TreeNode.
[ "NewTree", "creates", "a", "new", "tree", "of", "TreeNodes", "from", "the", "contents", "of", "the", "Go", "AST", "rooted", "at", "rootAstNode", ".", "Returns", "a", "pointer", "to", "the", "root", "TreeNode", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/docs/generator/tree.go#L59-L76
20,628
trivago/gollum
docs/generator/tree.go
Search
func (treeNode *TreeNode) Search(patternNode PatternNode) []*TreeNode { results := []*TreeNode{} // Current node if treeNode.compare(patternNode) { results = append(results, treeNode) } // Current node's children for _, child := range treeNode.Children { for _, subResult := range child.Search(patternNode) {...
go
func (treeNode *TreeNode) Search(patternNode PatternNode) []*TreeNode { results := []*TreeNode{} // Current node if treeNode.compare(patternNode) { results = append(results, treeNode) } // Current node's children for _, child := range treeNode.Children { for _, subResult := range child.Search(patternNode) {...
[ "func", "(", "treeNode", "*", "TreeNode", ")", "Search", "(", "patternNode", "PatternNode", ")", "[", "]", "*", "TreeNode", "{", "results", ":=", "[", "]", "*", "TreeNode", "{", "}", "\n\n", "// Current node", "if", "treeNode", ".", "compare", "(", "patt...
// Search iterates recursively through all subtrees of TreeNode and compares them to // the pattern three rooted at patternNode. It returns a flat list containing the // matching subtrees' roots.
[ "Search", "iterates", "recursively", "through", "all", "subtrees", "of", "TreeNode", "and", "compares", "them", "to", "the", "pattern", "three", "rooted", "at", "patternNode", ".", "It", "returns", "a", "flat", "list", "containing", "the", "matching", "subtrees"...
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/docs/generator/tree.go#L107-L123
20,629
trivago/gollum
docs/generator/tree.go
Dump
func (treeNode *TreeNode) Dump() { fmt.Printf("%s<%p>%q\n", strings.Repeat(" ", 4*treeNode.Depth), treeNode, treeNode.astNodeDump()) for _, child := range treeNode.Children { child.Dump() } }
go
func (treeNode *TreeNode) Dump() { fmt.Printf("%s<%p>%q\n", strings.Repeat(" ", 4*treeNode.Depth), treeNode, treeNode.astNodeDump()) for _, child := range treeNode.Children { child.Dump() } }
[ "func", "(", "treeNode", "*", "TreeNode", ")", "Dump", "(", ")", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "strings", ".", "Repeat", "(", "\"", "\"", ",", "4", "*", "treeNode", ".", "Depth", ")", ",", "treeNode", ",", "treeNode", "....
// Dump prints a dumpString of the tree rooted at `treeNode` to stdout
[ "Dump", "prints", "a", "dumpString", "of", "the", "tree", "rooted", "at", "treeNode", "to", "stdout" ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/docs/generator/tree.go#L168-L173
20,630
trivago/gollum
consumer/profiler.go
Consume
func (cons *Profiler) Consume(workers *sync.WaitGroup) { cons.AddMainWorker(workers) go tgo.WithRecoverShutdown(cons.profile) cons.ControlLoop() }
go
func (cons *Profiler) Consume(workers *sync.WaitGroup) { cons.AddMainWorker(workers) go tgo.WithRecoverShutdown(cons.profile) cons.ControlLoop() }
[ "func", "(", "cons", "*", "Profiler", ")", "Consume", "(", "workers", "*", "sync", ".", "WaitGroup", ")", "{", "cons", ".", "AddMainWorker", "(", "workers", ")", "\n\n", "go", "tgo", ".", "WithRecoverShutdown", "(", "cons", ".", "profile", ")", "\n", "...
// Consume starts a profile run and exits gollum when done
[ "Consume", "starts", "a", "profile", "run", "and", "exits", "gollum", "when", "done" ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/consumer/profiler.go#L230-L235
20,631
trivago/gollum
producer/file/batchedFileWriter.go
IsAccessible
func (w *BatchedFileWriter) IsAccessible() bool { _, err := w.getStats() return err == nil }
go
func (w *BatchedFileWriter) IsAccessible() bool { _, err := w.getStats() return err == nil }
[ "func", "(", "w", "*", "BatchedFileWriter", ")", "IsAccessible", "(", ")", "bool", "{", "_", ",", "err", ":=", "w", ".", "getStats", "(", ")", "\n", "return", "err", "==", "nil", "\n", "}" ]
// IsAccessible is part of the BatchedWriter interface and check if the writer can access his file
[ "IsAccessible", "is", "part", "of", "the", "BatchedWriter", "interface", "and", "check", "if", "the", "writer", "can", "access", "his", "file" ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/producer/file/batchedFileWriter.go#L66-L69
20,632
trivago/gollum
contrib/native/pcap/pcapsession.go
newPcapSession
func newPcapSession(client string, logger logrus.FieldLogger) *pcapSession { return &pcapSession{ client: client, logger: logger, } }
go
func newPcapSession(client string, logger logrus.FieldLogger) *pcapSession { return &pcapSession{ client: client, logger: logger, } }
[ "func", "newPcapSession", "(", "client", "string", ",", "logger", "logrus", ".", "FieldLogger", ")", "*", "pcapSession", "{", "return", "&", "pcapSession", "{", "client", ":", "client", ",", "logger", ":", "logger", ",", "}", "\n", "}" ]
// create a new TCP session buffer
[ "create", "a", "new", "TCP", "session", "buffer" ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/contrib/native/pcap/pcapsession.go#L57-L62
20,633
trivago/gollum
contrib/native/pcap/pcapsession.go
findPacketSlot
func findPacketSlot(seq uint32, list packetList) (int, bool) { offset := 0 partLen := len(list) for partLen > 1 { median := partLen / 2 TCPHeader, _ := tcpFromPcap(list[offset+median]) switch { case seq < TCPHeader.Seq: partLen = median case seq > TCPHeader.Seq: offset += median + 1 partLen -= me...
go
func findPacketSlot(seq uint32, list packetList) (int, bool) { offset := 0 partLen := len(list) for partLen > 1 { median := partLen / 2 TCPHeader, _ := tcpFromPcap(list[offset+median]) switch { case seq < TCPHeader.Seq: partLen = median case seq > TCPHeader.Seq: offset += median + 1 partLen -= me...
[ "func", "findPacketSlot", "(", "seq", "uint32", ",", "list", "packetList", ")", "(", "int", ",", "bool", ")", "{", "offset", ":=", "0", "\n", "partLen", ":=", "len", "(", "list", ")", "\n\n", "for", "partLen", ">", "1", "{", "median", ":=", "partLen"...
// binary search for an insertion point in the packet list
[ "binary", "search", "for", "an", "insertion", "point", "in", "the", "packet", "list" ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/contrib/native/pcap/pcapsession.go#L97-L125
20,634
trivago/gollum
contrib/native/pcap/pcapsession.go
insert
func (list packetList) insert(newPkt *pcap.Packet) packetList { if len(list) == 0 { return packetList{newPkt} } // 32-Bit integer overflow handling (stable for 65k blocks). // If the smallest (leftmost) number in the stored packages is much smaller // or much larger than the incoming number there is an overflow...
go
func (list packetList) insert(newPkt *pcap.Packet) packetList { if len(list) == 0 { return packetList{newPkt} } // 32-Bit integer overflow handling (stable for 65k blocks). // If the smallest (leftmost) number in the stored packages is much smaller // or much larger than the incoming number there is an overflow...
[ "func", "(", "list", "packetList", ")", "insert", "(", "newPkt", "*", "pcap", ".", "Packet", ")", "packetList", "{", "if", "len", "(", "list", ")", "==", "0", "{", "return", "packetList", "{", "newPkt", "}", "\n", "}", "\n\n", "// 32-Bit integer overflow...
// insertion sort for new packages by sequence number
[ "insertion", "sort", "for", "new", "packages", "by", "sequence", "number" ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/contrib/native/pcap/pcapsession.go#L128-L198
20,635
trivago/gollum
contrib/native/pcap/pcapsession.go
isComplete
func (list packetList) isComplete() (bool, int) { numPackets := len(list) // Trivial cases switch numPackets { case 0: return false, 0 case 1: return true, len(list[0].Payload) case 2: TCPHeader0, _ := tcpFromPcap(list[0]) TCPHeader1, _ := tcpFromPcap(list[1]) size0 := len(list[0].Payload) if TCPHe...
go
func (list packetList) isComplete() (bool, int) { numPackets := len(list) // Trivial cases switch numPackets { case 0: return false, 0 case 1: return true, len(list[0].Payload) case 2: TCPHeader0, _ := tcpFromPcap(list[0]) TCPHeader1, _ := tcpFromPcap(list[1]) size0 := len(list[0].Payload) if TCPHe...
[ "func", "(", "list", "packetList", ")", "isComplete", "(", ")", "(", "bool", ",", "int", ")", "{", "numPackets", ":=", "len", "(", "list", ")", "\n\n", "// Trivial cases", "switch", "numPackets", "{", "case", "0", ":", "return", "false", ",", "0", "\n"...
// check if all packets have consecutive sequence numbers and calculate the // buffer size required for processing
[ "check", "if", "all", "packets", "have", "consecutive", "sequence", "numbers", "and", "calculate", "the", "buffer", "size", "required", "for", "processing" ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/contrib/native/pcap/pcapsession.go#L202-L243
20,636
trivago/gollum
contrib/native/pcap/pcapsession.go
dropPackets
func (session *pcapSession) dropPackets(size int) { chunkSize := 0 for i, pkt := range session.packets { chunkSize += len(pkt.Payload) if chunkSize > size { session.packets = session.packets[i:] } } session.packets = session.packets[:0] }
go
func (session *pcapSession) dropPackets(size int) { chunkSize := 0 for i, pkt := range session.packets { chunkSize += len(pkt.Payload) if chunkSize > size { session.packets = session.packets[i:] } } session.packets = session.packets[:0] }
[ "func", "(", "session", "*", "pcapSession", ")", "dropPackets", "(", "size", "int", ")", "{", "chunkSize", ":=", "0", "\n", "for", "i", ",", "pkt", ":=", "range", "session", ".", "packets", "{", "chunkSize", "+=", "len", "(", "pkt", ".", "Payload", "...
// remove processed packets from the list.
[ "remove", "processed", "packets", "from", "the", "list", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/contrib/native/pcap/pcapsession.go#L255-L264
20,637
trivago/gollum
contrib/native/pcap/pcapsession.go
addPacket
func (session *pcapSession) addPacket(cons *PcapHTTPConsumer, pkt *pcap.Packet) { if len(pkt.Payload) == 0 { return // ### return, no payload ### } session.packets = session.packets.insert(pkt) if complete, size := session.packets.isComplete(); complete { payload := bytes.NewBuffer(make([]byte, 0, size)) ...
go
func (session *pcapSession) addPacket(cons *PcapHTTPConsumer, pkt *pcap.Packet) { if len(pkt.Payload) == 0 { return // ### return, no payload ### } session.packets = session.packets.insert(pkt) if complete, size := session.packets.isComplete(); complete { payload := bytes.NewBuffer(make([]byte, 0, size)) ...
[ "func", "(", "session", "*", "pcapSession", ")", "addPacket", "(", "cons", "*", "PcapHTTPConsumer", ",", "pkt", "*", "pcap", ".", "Packet", ")", "{", "if", "len", "(", "pkt", ".", "Payload", ")", "==", "0", "{", "return", "// ### return, no payload ###",...
// add a TCP packet to the session and try to generate a HTTP packet
[ "add", "a", "TCP", "packet", "to", "the", "session", "and", "try", "to", "generate", "a", "HTTP", "packet" ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/contrib/native/pcap/pcapsession.go#L267-L315
20,638
trivago/gollum
core/simpleconsumer.go
Configure
func (cons *SimpleConsumer) Configure(conf PluginConfigReader) { cons.id = conf.GetID() cons.Logger = conf.GetLogger() cons.runState = NewPluginRunState() cons.control = make(chan PluginControl, 1) numRoutines := conf.GetInt("ModulatorRoutines", 0) queueSize := conf.GetInt("ModulatorQueueSize", 1024) if numRou...
go
func (cons *SimpleConsumer) Configure(conf PluginConfigReader) { cons.id = conf.GetID() cons.Logger = conf.GetLogger() cons.runState = NewPluginRunState() cons.control = make(chan PluginControl, 1) numRoutines := conf.GetInt("ModulatorRoutines", 0) queueSize := conf.GetInt("ModulatorQueueSize", 1024) if numRou...
[ "func", "(", "cons", "*", "SimpleConsumer", ")", "Configure", "(", "conf", "PluginConfigReader", ")", "{", "cons", ".", "id", "=", "conf", ".", "GetID", "(", ")", "\n", "cons", ".", "Logger", "=", "conf", ".", "GetLogger", "(", ")", "\n", "cons", "."...
// Configure initializes standard consumer values from a plugin config.
[ "Configure", "initializes", "standard", "consumer", "values", "from", "a", "plugin", "config", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/core/simpleconsumer.go#L77-L106
20,639
trivago/gollum
core/simpleconsumer.go
EnqueueWithMetadata
func (cons *SimpleConsumer) EnqueueWithMetadata(data []byte, metaData Metadata) { msg := NewMessage(cons, data, metaData, InvalidStreamID) cons.enqueueMessage(msg) }
go
func (cons *SimpleConsumer) EnqueueWithMetadata(data []byte, metaData Metadata) { msg := NewMessage(cons, data, metaData, InvalidStreamID) cons.enqueueMessage(msg) }
[ "func", "(", "cons", "*", "SimpleConsumer", ")", "EnqueueWithMetadata", "(", "data", "[", "]", "byte", ",", "metaData", "Metadata", ")", "{", "msg", ":=", "NewMessage", "(", "cons", ",", "data", ",", "metaData", ",", "InvalidStreamID", ")", "\n", "cons", ...
// EnqueueWithMetadata works like EnqueueWithSequence and allows to set meta data directly
[ "EnqueueWithMetadata", "works", "like", "EnqueueWithSequence", "and", "allows", "to", "set", "meta", "data", "directly" ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/core/simpleconsumer.go#L207-L210
20,640
trivago/gollum
core/simpleconsumer.go
ControlLoop
func (cons *SimpleConsumer) ControlLoop() { cons.setState(PluginStateActive) defer cons.setState(PluginStateDead) defer cons.Logger.Debug("Stopped") for { command := <-cons.control switch command { default: cons.Logger.Debug("Received untracked command") // Do nothing case PluginControlStopConsumer:...
go
func (cons *SimpleConsumer) ControlLoop() { cons.setState(PluginStateActive) defer cons.setState(PluginStateDead) defer cons.Logger.Debug("Stopped") for { command := <-cons.control switch command { default: cons.Logger.Debug("Received untracked command") // Do nothing case PluginControlStopConsumer:...
[ "func", "(", "cons", "*", "SimpleConsumer", ")", "ControlLoop", "(", ")", "{", "cons", ".", "setState", "(", "PluginStateActive", ")", "\n", "defer", "cons", ".", "setState", "(", "PluginStateDead", ")", "\n", "defer", "cons", ".", "Logger", ".", "Debug", ...
// ControlLoop listens to the control channel and triggers callbacks for these // messages. Upon stop control message doExit will be set to true.
[ "ControlLoop", "listens", "to", "the", "control", "channel", "and", "triggers", "callbacks", "for", "these", "messages", ".", "Upon", "stop", "control", "message", "doExit", "will", "be", "set", "to", "true", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/core/simpleconsumer.go#L266-L309
20,641
trivago/gollum
core/simpleconsumer.go
TickerControlLoop
func (cons *SimpleConsumer) TickerControlLoop(interval time.Duration, onTick func()) { cons.setState(PluginStateActive) go cons.tickerLoop(interval, onTick) cons.ControlLoop() }
go
func (cons *SimpleConsumer) TickerControlLoop(interval time.Duration, onTick func()) { cons.setState(PluginStateActive) go cons.tickerLoop(interval, onTick) cons.ControlLoop() }
[ "func", "(", "cons", "*", "SimpleConsumer", ")", "TickerControlLoop", "(", "interval", "time", ".", "Duration", ",", "onTick", "func", "(", ")", ")", "{", "cons", ".", "setState", "(", "PluginStateActive", ")", "\n", "go", "cons", ".", "tickerLoop", "(", ...
// TickerControlLoop is like MessageLoop but executes a given function at // every given interval tick, too. Note that the interval is not exact. If the // onTick function takes longer than interval, the next tick will be delayed // until onTick finishes.
[ "TickerControlLoop", "is", "like", "MessageLoop", "but", "executes", "a", "given", "function", "at", "every", "given", "interval", "tick", "too", ".", "Note", "that", "the", "interval", "is", "not", "exact", ".", "If", "the", "onTick", "function", "takes", "...
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/core/simpleconsumer.go#L315-L319
20,642
trivago/gollum
producer/awsCloudwatchlogs.go
numEvents
func (prod *AwsCloudwatchLogs) numEvents(messages []*core.Message, checkFn ...indexNumFn) int { index := maxBatchEvents for _, fn := range checkFn { result := fn(messages) if result < index { index = result } } return index }
go
func (prod *AwsCloudwatchLogs) numEvents(messages []*core.Message, checkFn ...indexNumFn) int { index := maxBatchEvents for _, fn := range checkFn { result := fn(messages) if result < index { index = result } } return index }
[ "func", "(", "prod", "*", "AwsCloudwatchLogs", ")", "numEvents", "(", "messages", "[", "]", "*", "core", ".", "Message", ",", "checkFn", "...", "indexNumFn", ")", "int", "{", "index", ":=", "maxBatchEvents", "\n", "for", "_", ",", "fn", ":=", "range", ...
// Return lowest index based on all check functions // This function assumes that messages are sorted by timestamp in ascending order
[ "Return", "lowest", "index", "based", "on", "all", "check", "functions", "This", "function", "assumes", "that", "messages", "are", "sorted", "by", "timestamp", "in", "ascending", "order" ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/producer/awsCloudwatchlogs.go#L112-L121
20,643
trivago/gollum
producer/awsCloudwatchlogs.go
sizeIndex
func (prod *AwsCloudwatchLogs) sizeIndex(messages []*core.Message) int { size, index := 0, 0 for i, message := range messages { size += len(message.String()) + eventSizeOverhead if size > maxBatchSize { break } index = i + 1 } return index }
go
func (prod *AwsCloudwatchLogs) sizeIndex(messages []*core.Message) int { size, index := 0, 0 for i, message := range messages { size += len(message.String()) + eventSizeOverhead if size > maxBatchSize { break } index = i + 1 } return index }
[ "func", "(", "prod", "*", "AwsCloudwatchLogs", ")", "sizeIndex", "(", "messages", "[", "]", "*", "core", ".", "Message", ")", "int", "{", "size", ",", "index", ":=", "0", ",", "0", "\n", "for", "i", ",", "message", ":=", "range", "messages", "{", "...
// Return lowest index based on message size
[ "Return", "lowest", "index", "based", "on", "message", "size" ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/producer/awsCloudwatchlogs.go#L126-L136
20,644
trivago/gollum
producer/awsCloudwatchlogs.go
timeIndex
func (prod *AwsCloudwatchLogs) timeIndex(messages []*core.Message) (index int) { if len(messages) == 0 { return 0 } firstTimestamp := messages[0].GetCreationTime().Unix() for i, message := range messages { if (message.GetCreationTime().Unix() - firstTimestamp) > int64(maxBatchTimeSpan) { break } index = ...
go
func (prod *AwsCloudwatchLogs) timeIndex(messages []*core.Message) (index int) { if len(messages) == 0 { return 0 } firstTimestamp := messages[0].GetCreationTime().Unix() for i, message := range messages { if (message.GetCreationTime().Unix() - firstTimestamp) > int64(maxBatchTimeSpan) { break } index = ...
[ "func", "(", "prod", "*", "AwsCloudwatchLogs", ")", "timeIndex", "(", "messages", "[", "]", "*", "core", ".", "Message", ")", "(", "index", "int", ")", "{", "if", "len", "(", "messages", ")", "==", "0", "{", "return", "0", "\n", "}", "\n", "firstTi...
// Return lowest index based on timespan // This function assumes that messages are sorted by timestamp in ascending order
[ "Return", "lowest", "index", "based", "on", "timespan", "This", "function", "assumes", "that", "messages", "are", "sorted", "by", "timestamp", "in", "ascending", "order" ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/producer/awsCloudwatchlogs.go#L140-L152
20,645
trivago/gollum
producer/awsCloudwatchlogs.go
handleResult
func (prod *AwsCloudwatchLogs) handleResult(resp *cloudwatchlogs.PutLogEventsOutput, result error) { switch err := result.(type) { case awserr.Error: switch err.Code() { case "InvalidSequenceTokenException": prod.Logger.Debugf("invalid sequence token, updating") prod.setToken() case "ResourceNotFoundExcep...
go
func (prod *AwsCloudwatchLogs) handleResult(resp *cloudwatchlogs.PutLogEventsOutput, result error) { switch err := result.(type) { case awserr.Error: switch err.Code() { case "InvalidSequenceTokenException": prod.Logger.Debugf("invalid sequence token, updating") prod.setToken() case "ResourceNotFoundExcep...
[ "func", "(", "prod", "*", "AwsCloudwatchLogs", ")", "handleResult", "(", "resp", "*", "cloudwatchlogs", ".", "PutLogEventsOutput", ",", "result", "error", ")", "{", "switch", "err", ":=", "result", ".", "(", "type", ")", "{", "case", "awserr", ".", "Error"...
// When rejectedLogEventsInfo is not empty, app can not // do anything reasonable with rejected logs. Ignore it.
[ "When", "rejectedLogEventsInfo", "is", "not", "empty", "app", "can", "not", "do", "anything", "reasonable", "with", "rejected", "logs", ".", "Ignore", "it", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/producer/awsCloudwatchlogs.go#L184-L203
20,646
trivago/gollum
producer/awsCloudwatchlogs.go
setToken
func (prod *AwsCloudwatchLogs) setToken() error { params := &cloudwatchlogs.DescribeLogStreamsInput{ LogGroupName: &prod.group, LogStreamNamePrefix: &prod.stream, } return prod.service.DescribeLogStreamsPages(params, func(page *cloudwatchlogs.DescribeLogStreamsOutput, lastPage bool) bool { return !f...
go
func (prod *AwsCloudwatchLogs) setToken() error { params := &cloudwatchlogs.DescribeLogStreamsInput{ LogGroupName: &prod.group, LogStreamNamePrefix: &prod.stream, } return prod.service.DescribeLogStreamsPages(params, func(page *cloudwatchlogs.DescribeLogStreamsOutput, lastPage bool) bool { return !f...
[ "func", "(", "prod", "*", "AwsCloudwatchLogs", ")", "setToken", "(", ")", "error", "{", "params", ":=", "&", "cloudwatchlogs", ".", "DescribeLogStreamsInput", "{", "LogGroupName", ":", "&", "prod", ".", "group", ",", "LogStreamNamePrefix", ":", "&", "prod", ...
// For newly created log streams, token is an empty string.
[ "For", "newly", "created", "log", "streams", "token", "is", "an", "empty", "string", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/producer/awsCloudwatchlogs.go#L240-L250
20,647
trivago/gollum
producer/awsCloudwatchlogs.go
create
func (prod *AwsCloudwatchLogs) create() error { if err := prod.createGroup(); err != nil { return err } return prod.createStream() }
go
func (prod *AwsCloudwatchLogs) create() error { if err := prod.createGroup(); err != nil { return err } return prod.createStream() }
[ "func", "(", "prod", "*", "AwsCloudwatchLogs", ")", "create", "(", ")", "error", "{", "if", "err", ":=", "prod", ".", "createGroup", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "prod", ".", "createStream", "(",...
// Create log group and stream. If an error is returned, PutLogEvents cannot succeed.
[ "Create", "log", "group", "and", "stream", ".", "If", "an", "error", "is", "returned", "PutLogEvents", "cannot", "succeed", "." ]
de2faa584cd526bb852e8a4b693982ba4216757f
https://github.com/trivago/gollum/blob/de2faa584cd526bb852e8a4b693982ba4216757f/producer/awsCloudwatchlogs.go#L263-L268
20,648
microcosm-cc/bluemonday
policies.go
UGCPolicy
func UGCPolicy() *Policy { p := NewPolicy() /////////////////////// // Global attributes // /////////////////////// // "class" is not permitted as we are not allowing users to style their own // content p.AllowStandardAttributes() ////////////////////////////// // Global URL format policy // ////////////...
go
func UGCPolicy() *Policy { p := NewPolicy() /////////////////////// // Global attributes // /////////////////////// // "class" is not permitted as we are not allowing users to style their own // content p.AllowStandardAttributes() ////////////////////////////// // Global URL format policy // ////////////...
[ "func", "UGCPolicy", "(", ")", "*", "Policy", "{", "p", ":=", "NewPolicy", "(", ")", "\n\n", "///////////////////////", "// Global attributes //", "///////////////////////", "// \"class\" is not permitted as we are not allowing users to style their own", "// content", "p", ".",...
// UGCPolicy returns a policy aimed at user generated content that is a result // of HTML WYSIWYG tools and Markdown conversions. // // This is expected to be a fairly rich document where as much markup as // possible should be retained. Markdown permits raw HTML so we are basically // providing a policy to sanitise HT...
[ "UGCPolicy", "returns", "a", "policy", "aimed", "at", "user", "generated", "content", "that", "is", "a", "result", "of", "HTML", "WYSIWYG", "tools", "and", "Markdown", "conversions", ".", "This", "is", "expected", "to", "be", "a", "fairly", "rich", "document...
89802068f71166e95c92040512bf2e11767721ed
https://github.com/microcosm-cc/bluemonday/blob/89802068f71166e95c92040512bf2e11767721ed/policies.go#L54-L253
20,649
microcosm-cc/bluemonday
helpers.go
AllowStandardAttributes
func (p *Policy) AllowStandardAttributes() { // "dir" "lang" are permitted as both language attributes affect charsets // and direction of text. p.AllowAttrs("dir").Matching(Direction).Globally() p.AllowAttrs( "lang", ).Matching(regexp.MustCompile(`[a-zA-Z]{2,20}`)).Globally() // "id" is permitted. This is pre...
go
func (p *Policy) AllowStandardAttributes() { // "dir" "lang" are permitted as both language attributes affect charsets // and direction of text. p.AllowAttrs("dir").Matching(Direction).Globally() p.AllowAttrs( "lang", ).Matching(regexp.MustCompile(`[a-zA-Z]{2,20}`)).Globally() // "id" is permitted. This is pre...
[ "func", "(", "p", "*", "Policy", ")", "AllowStandardAttributes", "(", ")", "{", "// \"dir\" \"lang\" are permitted as both language attributes affect charsets", "// and direction of text.", "p", ".", "AllowAttrs", "(", "\"", "\"", ")", ".", "Matching", "(", "Direction", ...
// AllowStandardAttributes will enable "id", "title" and the language specific // attributes "dir" and "lang" on all elements that are whitelisted
[ "AllowStandardAttributes", "will", "enable", "id", "title", "and", "the", "language", "specific", "attributes", "dir", "and", "lang", "on", "all", "elements", "that", "are", "whitelisted" ]
89802068f71166e95c92040512bf2e11767721ed
https://github.com/microcosm-cc/bluemonday/blob/89802068f71166e95c92040512bf2e11767721ed/helpers.go#L145-L164
20,650
microcosm-cc/bluemonday
helpers.go
AllowLists
func (p *Policy) AllowLists() { // "ol" "ul" are permitted p.AllowAttrs("type").Matching(ListType).OnElements("ol", "ul") // "li" is permitted p.AllowAttrs("type").Matching(ListType).OnElements("li") p.AllowAttrs("value").Matching(Integer).OnElements("li") // "dl" "dt" "dd" are permitted p.AllowElements("dl", ...
go
func (p *Policy) AllowLists() { // "ol" "ul" are permitted p.AllowAttrs("type").Matching(ListType).OnElements("ol", "ul") // "li" is permitted p.AllowAttrs("type").Matching(ListType).OnElements("li") p.AllowAttrs("value").Matching(Integer).OnElements("li") // "dl" "dt" "dd" are permitted p.AllowElements("dl", ...
[ "func", "(", "p", "*", "Policy", ")", "AllowLists", "(", ")", "{", "// \"ol\" \"ul\" are permitted", "p", ".", "AllowAttrs", "(", "\"", "\"", ")", ".", "Matching", "(", "ListType", ")", ".", "OnElements", "(", "\"", "\"", ",", "\"", "\"", ")", "\n\n", ...
// AllowLists will enabled ordered and unordered lists, as well as definition // lists
[ "AllowLists", "will", "enabled", "ordered", "and", "unordered", "lists", "as", "well", "as", "definition", "lists" ]
89802068f71166e95c92040512bf2e11767721ed
https://github.com/microcosm-cc/bluemonday/blob/89802068f71166e95c92040512bf2e11767721ed/helpers.go#L235-L245
20,651
microcosm-cc/bluemonday
helpers.go
AllowTables
func (p *Policy) AllowTables() { // "table" is permitted p.AllowAttrs("height", "width").Matching(NumberOrPercent).OnElements("table") p.AllowAttrs("summary").Matching(Paragraph).OnElements("table") // "caption" is permitted p.AllowElements("caption") // "col" "colgroup" are permitted p.AllowAttrs("align").Ma...
go
func (p *Policy) AllowTables() { // "table" is permitted p.AllowAttrs("height", "width").Matching(NumberOrPercent).OnElements("table") p.AllowAttrs("summary").Matching(Paragraph).OnElements("table") // "caption" is permitted p.AllowElements("caption") // "col" "colgroup" are permitted p.AllowAttrs("align").Ma...
[ "func", "(", "p", "*", "Policy", ")", "AllowTables", "(", ")", "{", "// \"table\" is permitted", "p", ".", "AllowAttrs", "(", "\"", "\"", ",", "\"", "\"", ")", ".", "Matching", "(", "NumberOrPercent", ")", ".", "OnElements", "(", "\"", "\"", ")", "\n",...
// AllowTables will enable a rich set of elements and attributes to describe // HTML tables
[ "AllowTables", "will", "enable", "a", "rich", "set", "of", "elements", "and", "attributes", "to", "describe", "HTML", "tables" ]
89802068f71166e95c92040512bf2e11767721ed
https://github.com/microcosm-cc/bluemonday/blob/89802068f71166e95c92040512bf2e11767721ed/helpers.go#L249-L297
20,652
microcosm-cc/bluemonday
sanitize.go
SanitizeReader
func (p *Policy) SanitizeReader(r io.Reader) *bytes.Buffer { return p.sanitize(r) }
go
func (p *Policy) SanitizeReader(r io.Reader) *bytes.Buffer { return p.sanitize(r) }
[ "func", "(", "p", "*", "Policy", ")", "SanitizeReader", "(", "r", "io", ".", "Reader", ")", "*", "bytes", ".", "Buffer", "{", "return", "p", ".", "sanitize", "(", "r", ")", "\n", "}" ]
// SanitizeReader takes an io.Reader that contains a HTML fragment or document // and applies the given policy whitelist. // // It returns a bytes.Buffer containing the HTML that has been sanitized by the // policy. Errors during sanitization will merely return an empty result.
[ "SanitizeReader", "takes", "an", "io", ".", "Reader", "that", "contains", "a", "HTML", "fragment", "or", "document", "and", "applies", "the", "given", "policy", "whitelist", ".", "It", "returns", "a", "bytes", ".", "Buffer", "containing", "the", "HTML", "tha...
89802068f71166e95c92040512bf2e11767721ed
https://github.com/microcosm-cc/bluemonday/blob/89802068f71166e95c92040512bf2e11767721ed/sanitize.go#L81-L83
20,653
microcosm-cc/bluemonday
policy.go
init
func (p *Policy) init() { if !p.initialized { p.elsAndAttrs = make(map[string]map[string]attrPolicy) p.globalAttrs = make(map[string]attrPolicy) p.allowURLSchemes = make(map[string]urlPolicy) p.setOfElementsAllowedWithoutAttrs = make(map[string]struct{}) p.setOfElementsToSkipContent = make(map[string]struct{...
go
func (p *Policy) init() { if !p.initialized { p.elsAndAttrs = make(map[string]map[string]attrPolicy) p.globalAttrs = make(map[string]attrPolicy) p.allowURLSchemes = make(map[string]urlPolicy) p.setOfElementsAllowedWithoutAttrs = make(map[string]struct{}) p.setOfElementsToSkipContent = make(map[string]struct{...
[ "func", "(", "p", "*", "Policy", ")", "init", "(", ")", "{", "if", "!", "p", ".", "initialized", "{", "p", ".", "elsAndAttrs", "=", "make", "(", "map", "[", "string", "]", "map", "[", "string", "]", "attrPolicy", ")", "\n", "p", ".", "globalAttrs...
// init initializes the maps if this has not been done already
[ "init", "initializes", "the", "maps", "if", "this", "has", "not", "been", "done", "already" ]
89802068f71166e95c92040512bf2e11767721ed
https://github.com/microcosm-cc/bluemonday/blob/89802068f71166e95c92040512bf2e11767721ed/policy.go#L117-L126
20,654
microcosm-cc/bluemonday
policy.go
Matching
func (abp *attrPolicyBuilder) Matching(regex *regexp.Regexp) *attrPolicyBuilder { abp.regexp = regex return abp }
go
func (abp *attrPolicyBuilder) Matching(regex *regexp.Regexp) *attrPolicyBuilder { abp.regexp = regex return abp }
[ "func", "(", "abp", "*", "attrPolicyBuilder", ")", "Matching", "(", "regex", "*", "regexp", ".", "Regexp", ")", "*", "attrPolicyBuilder", "{", "abp", ".", "regexp", "=", "regex", "\n\n", "return", "abp", "\n", "}" ]
// Matching allows a regular expression to be applied to a nascent attribute // policy, and returns the attribute policy. Calling this more than once will // replace the existing regexp.
[ "Matching", "allows", "a", "regular", "expression", "to", "be", "applied", "to", "a", "nascent", "attribute", "policy", "and", "returns", "the", "attribute", "policy", ".", "Calling", "this", "more", "than", "once", "will", "replace", "the", "existing", "regex...
89802068f71166e95c92040512bf2e11767721ed
https://github.com/microcosm-cc/bluemonday/blob/89802068f71166e95c92040512bf2e11767721ed/policy.go#L208-L213
20,655
microcosm-cc/bluemonday
policy.go
OnElements
func (abp *attrPolicyBuilder) OnElements(elements ...string) *Policy { for _, element := range elements { element = strings.ToLower(element) for _, attr := range abp.attrNames { if _, ok := abp.p.elsAndAttrs[element]; !ok { abp.p.elsAndAttrs[element] = make(map[string]attrPolicy) } ap := attrPolic...
go
func (abp *attrPolicyBuilder) OnElements(elements ...string) *Policy { for _, element := range elements { element = strings.ToLower(element) for _, attr := range abp.attrNames { if _, ok := abp.p.elsAndAttrs[element]; !ok { abp.p.elsAndAttrs[element] = make(map[string]attrPolicy) } ap := attrPolic...
[ "func", "(", "abp", "*", "attrPolicyBuilder", ")", "OnElements", "(", "elements", "...", "string", ")", "*", "Policy", "{", "for", "_", ",", "element", ":=", "range", "elements", "{", "element", "=", "strings", ".", "ToLower", "(", "element", ")", "\n\n"...
// OnElements will bind an attribute policy to a given range of HTML elements // and return the updated policy
[ "OnElements", "will", "bind", "an", "attribute", "policy", "to", "a", "given", "range", "of", "HTML", "elements", "and", "return", "the", "updated", "policy" ]
89802068f71166e95c92040512bf2e11767721ed
https://github.com/microcosm-cc/bluemonday/blob/89802068f71166e95c92040512bf2e11767721ed/policy.go#L217-L246
20,656
microcosm-cc/bluemonday
policy.go
Globally
func (abp *attrPolicyBuilder) Globally() *Policy { for _, attr := range abp.attrNames { if _, ok := abp.p.globalAttrs[attr]; !ok { abp.p.globalAttrs[attr] = attrPolicy{} } ap := attrPolicy{} if abp.regexp != nil { ap.regexp = abp.regexp } abp.p.globalAttrs[attr] = ap } return abp.p }
go
func (abp *attrPolicyBuilder) Globally() *Policy { for _, attr := range abp.attrNames { if _, ok := abp.p.globalAttrs[attr]; !ok { abp.p.globalAttrs[attr] = attrPolicy{} } ap := attrPolicy{} if abp.regexp != nil { ap.regexp = abp.regexp } abp.p.globalAttrs[attr] = ap } return abp.p }
[ "func", "(", "abp", "*", "attrPolicyBuilder", ")", "Globally", "(", ")", "*", "Policy", "{", "for", "_", ",", "attr", ":=", "range", "abp", ".", "attrNames", "{", "if", "_", ",", "ok", ":=", "abp", ".", "p", ".", "globalAttrs", "[", "attr", "]", ...
// Globally will bind an attribute policy to all HTML elements and return the // updated policy
[ "Globally", "will", "bind", "an", "attribute", "policy", "to", "all", "HTML", "elements", "and", "return", "the", "updated", "policy" ]
89802068f71166e95c92040512bf2e11767721ed
https://github.com/microcosm-cc/bluemonday/blob/89802068f71166e95c92040512bf2e11767721ed/policy.go#L250-L266
20,657
microcosm-cc/bluemonday
policy.go
SkipElementsContent
func (p *Policy) SkipElementsContent(names ...string) *Policy { p.init() for _, element := range names { element = strings.ToLower(element) if _, ok := p.setOfElementsToSkipContent[element]; !ok { p.setOfElementsToSkipContent[element] = struct{}{} } } return p }
go
func (p *Policy) SkipElementsContent(names ...string) *Policy { p.init() for _, element := range names { element = strings.ToLower(element) if _, ok := p.setOfElementsToSkipContent[element]; !ok { p.setOfElementsToSkipContent[element] = struct{}{} } } return p }
[ "func", "(", "p", "*", "Policy", ")", "SkipElementsContent", "(", "names", "...", "string", ")", "*", "Policy", "{", "p", ".", "init", "(", ")", "\n\n", "for", "_", ",", "element", ":=", "range", "names", "{", "element", "=", "strings", ".", "ToLower...
// SkipElementsContent adds the HTML elements whose tags is needed to be removed // with its content.
[ "SkipElementsContent", "adds", "the", "HTML", "elements", "whose", "tags", "is", "needed", "to", "be", "removed", "with", "its", "content", "." ]
89802068f71166e95c92040512bf2e11767721ed
https://github.com/microcosm-cc/bluemonday/blob/89802068f71166e95c92040512bf2e11767721ed/policy.go#L406-L419
20,658
microcosm-cc/bluemonday
policy.go
AllowElementsContent
func (p *Policy) AllowElementsContent(names ...string) *Policy { p.init() for _, element := range names { delete(p.setOfElementsToSkipContent, strings.ToLower(element)) } return p }
go
func (p *Policy) AllowElementsContent(names ...string) *Policy { p.init() for _, element := range names { delete(p.setOfElementsToSkipContent, strings.ToLower(element)) } return p }
[ "func", "(", "p", "*", "Policy", ")", "AllowElementsContent", "(", "names", "...", "string", ")", "*", "Policy", "{", "p", ".", "init", "(", ")", "\n\n", "for", "_", ",", "element", ":=", "range", "names", "{", "delete", "(", "p", ".", "setOfElements...
// AllowElementsContent marks the HTML elements whose content should be // retained after removing the tag.
[ "AllowElementsContent", "marks", "the", "HTML", "elements", "whose", "content", "should", "be", "retained", "after", "removing", "the", "tag", "." ]
89802068f71166e95c92040512bf2e11767721ed
https://github.com/microcosm-cc/bluemonday/blob/89802068f71166e95c92040512bf2e11767721ed/policy.go#L423-L432
20,659
pierrre/imageserver
source/file/file.go
IdentifyMime
func IdentifyMime(pth string, data []byte) (format string, err error) { ext := filepath.Ext(pth) if ext == "" { return "", fmt.Errorf("no file extension: %s", pth) } typ := mime.TypeByExtension(ext) if typ == "" { return "", fmt.Errorf("unkwnon file type for extension %s", ext) } const pref = "image/" if !s...
go
func IdentifyMime(pth string, data []byte) (format string, err error) { ext := filepath.Ext(pth) if ext == "" { return "", fmt.Errorf("no file extension: %s", pth) } typ := mime.TypeByExtension(ext) if typ == "" { return "", fmt.Errorf("unkwnon file type for extension %s", ext) } const pref = "image/" if !s...
[ "func", "IdentifyMime", "(", "pth", "string", ",", "data", "[", "]", "byte", ")", "(", "format", "string", ",", "err", "error", ")", "{", "ext", ":=", "filepath", ".", "Ext", "(", "pth", ")", "\n", "if", "ext", "==", "\"", "\"", "{", "return", "\...
// IdentifyMime identifies the Image format with the "mime" package.
[ "IdentifyMime", "identifies", "the", "Image", "format", "with", "the", "mime", "package", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/source/file/file.go#L87-L101
20,660
pierrre/imageserver
http/parser.go
Parse
func (lp ListParser) Parse(req *http.Request, params imageserver.Params) error { for _, subParser := range lp { err := subParser.Parse(req, params) if err != nil { return err } } return nil }
go
func (lp ListParser) Parse(req *http.Request, params imageserver.Params) error { for _, subParser := range lp { err := subParser.Parse(req, params) if err != nil { return err } } return nil }
[ "func", "(", "lp", "ListParser", ")", "Parse", "(", "req", "*", "http", ".", "Request", ",", "params", "imageserver", ".", "Params", ")", "error", "{", "for", "_", ",", "subParser", ":=", "range", "lp", "{", "err", ":=", "subParser", ".", "Parse", "(...
// Parse implements Parser. // // It iterates through all sub parsers. // An error interrupts the iteration.
[ "Parse", "implements", "Parser", ".", "It", "iterates", "through", "all", "sub", "parsers", ".", "An", "error", "interrupts", "the", "iteration", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/http/parser.go#L30-L38
20,661
pierrre/imageserver
http/parser.go
Resolve
func (lp ListParser) Resolve(param string) string { for _, subParser := range lp { httpParam := subParser.Resolve(param) if httpParam != "" { return httpParam } } return "" }
go
func (lp ListParser) Resolve(param string) string { for _, subParser := range lp { httpParam := subParser.Resolve(param) if httpParam != "" { return httpParam } } return "" }
[ "func", "(", "lp", "ListParser", ")", "Resolve", "(", "param", "string", ")", "string", "{", "for", "_", ",", "subParser", ":=", "range", "lp", "{", "httpParam", ":=", "subParser", ".", "Resolve", "(", "param", ")", "\n", "if", "httpParam", "!=", "\"",...
// Resolve implements Parser. // // It iterates through sub parsers, and return the first non-empty string.
[ "Resolve", "implements", "Parser", ".", "It", "iterates", "through", "sub", "parsers", "and", "return", "the", "first", "non", "-", "empty", "string", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/http/parser.go#L43-L51
20,662
pierrre/imageserver
http/parser.go
Resolve
func (parser *SourceParser) Resolve(param string) string { if param == imageserver_source.Param { return imageserver_source.Param } return "" }
go
func (parser *SourceParser) Resolve(param string) string { if param == imageserver_source.Param { return imageserver_source.Param } return "" }
[ "func", "(", "parser", "*", "SourceParser", ")", "Resolve", "(", "param", "string", ")", "string", "{", "if", "param", "==", "imageserver_source", ".", "Param", "{", "return", "imageserver_source", ".", "Param", "\n", "}", "\n", "return", "\"", "\"", "\n",...
// Resolve implements Parser.
[ "Resolve", "implements", "Parser", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/http/parser.go#L63-L68
20,663
pierrre/imageserver
http/parser.go
ParseQueryString
func ParseQueryString(param string, req *http.Request, params imageserver.Params) { s := req.URL.Query().Get(param) if s != "" { params.Set(param, s) } }
go
func ParseQueryString(param string, req *http.Request, params imageserver.Params) { s := req.URL.Query().Get(param) if s != "" { params.Set(param, s) } }
[ "func", "ParseQueryString", "(", "param", "string", ",", "req", "*", "http", ".", "Request", ",", "params", "imageserver", ".", "Params", ")", "{", "s", ":=", "req", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "param", ")", "\n", "if", "s"...
// ParseQueryString takes the param from the HTTP URL query and add it to the Params.
[ "ParseQueryString", "takes", "the", "param", "from", "the", "HTTP", "URL", "query", "and", "add", "it", "to", "the", "Params", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/http/parser.go#L131-L136
20,664
pierrre/imageserver
http/parser.go
ParseQueryInt
func ParseQueryInt(param string, req *http.Request, params imageserver.Params) error { s := req.URL.Query().Get(param) if s == "" { return nil } i, err := strconv.Atoi(s) if err != nil { return newParseTypeParamError(param, "int", err) } params.Set(param, i) return nil }
go
func ParseQueryInt(param string, req *http.Request, params imageserver.Params) error { s := req.URL.Query().Get(param) if s == "" { return nil } i, err := strconv.Atoi(s) if err != nil { return newParseTypeParamError(param, "int", err) } params.Set(param, i) return nil }
[ "func", "ParseQueryInt", "(", "param", "string", ",", "req", "*", "http", ".", "Request", ",", "params", "imageserver", ".", "Params", ")", "error", "{", "s", ":=", "req", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "param", ")", "\n", "if...
// ParseQueryInt takes the param from the HTTP URL query, parse it as an int and add it to the Params.
[ "ParseQueryInt", "takes", "the", "param", "from", "the", "HTTP", "URL", "query", "parse", "it", "as", "an", "int", "and", "add", "it", "to", "the", "Params", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/http/parser.go#L139-L150
20,665
pierrre/imageserver
http/parser.go
ParseQueryFloat
func ParseQueryFloat(param string, req *http.Request, params imageserver.Params) error { s := req.URL.Query().Get(param) if s == "" { return nil } f, err := strconv.ParseFloat(s, 64) if err != nil { return newParseTypeParamError(param, "float", err) } params.Set(param, f) return nil }
go
func ParseQueryFloat(param string, req *http.Request, params imageserver.Params) error { s := req.URL.Query().Get(param) if s == "" { return nil } f, err := strconv.ParseFloat(s, 64) if err != nil { return newParseTypeParamError(param, "float", err) } params.Set(param, f) return nil }
[ "func", "ParseQueryFloat", "(", "param", "string", ",", "req", "*", "http", ".", "Request", ",", "params", "imageserver", ".", "Params", ")", "error", "{", "s", ":=", "req", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "param", ")", "\n", "...
// ParseQueryFloat takes the param from the HTTP URL query, parse it as a float64 and add it to the Params.
[ "ParseQueryFloat", "takes", "the", "param", "from", "the", "HTTP", "URL", "query", "parse", "it", "as", "a", "float64", "and", "add", "it", "to", "the", "Params", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/http/parser.go#L167-L178
20,666
pierrre/imageserver
http/parser.go
ParseQueryBool
func ParseQueryBool(param string, req *http.Request, params imageserver.Params) error { s := req.URL.Query().Get(param) if s == "" { return nil } b, err := strconv.ParseBool(s) if err != nil { return newParseTypeParamError(param, "bool", err) } params.Set(param, b) return nil }
go
func ParseQueryBool(param string, req *http.Request, params imageserver.Params) error { s := req.URL.Query().Get(param) if s == "" { return nil } b, err := strconv.ParseBool(s) if err != nil { return newParseTypeParamError(param, "bool", err) } params.Set(param, b) return nil }
[ "func", "ParseQueryBool", "(", "param", "string", ",", "req", "*", "http", ".", "Request", ",", "params", "imageserver", ".", "Params", ")", "error", "{", "s", ":=", "req", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "param", ")", "\n", "i...
// ParseQueryBool takes the param from the HTTP URL query, parse it as an bool and add it to the Params.
[ "ParseQueryBool", "takes", "the", "param", "from", "the", "HTTP", "URL", "query", "parse", "it", "as", "an", "bool", "and", "add", "it", "to", "the", "Params", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/http/parser.go#L181-L192
20,667
pierrre/imageserver
cache/groupcache/http.go
HTTPPoolContext
func HTTPPoolContext(req *http.Request) groupcache.Context { ctx, err := getContext(req) if err != nil { return nil } return ctx }
go
func HTTPPoolContext(req *http.Request) groupcache.Context { ctx, err := getContext(req) if err != nil { return nil } return ctx }
[ "func", "HTTPPoolContext", "(", "req", "*", "http", ".", "Request", ")", "groupcache", ".", "Context", "{", "ctx", ",", "err", ":=", "getContext", "(", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "ctx"...
// HTTPPoolContext must be used in groupcache.HTTPPool.Context.
[ "HTTPPoolContext", "must", "be", "used", "in", "groupcache", ".", "HTTPPool", ".", "Context", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/cache/groupcache/http.go#L18-L24
20,668
pierrre/imageserver
cache/groupcache/http.go
NewHTTPPoolTransport
func NewHTTPPoolTransport(rt http.RoundTripper) func(groupcache.Context) http.RoundTripper { if rt == nil { rt = http.DefaultTransport } return func(ctx groupcache.Context) http.RoundTripper { return roundTripperFunc(func(req *http.Request) (*http.Response, error) { if ctx, ok := ctx.(*Context); ok && ctx != ...
go
func NewHTTPPoolTransport(rt http.RoundTripper) func(groupcache.Context) http.RoundTripper { if rt == nil { rt = http.DefaultTransport } return func(ctx groupcache.Context) http.RoundTripper { return roundTripperFunc(func(req *http.Request) (*http.Response, error) { if ctx, ok := ctx.(*Context); ok && ctx != ...
[ "func", "NewHTTPPoolTransport", "(", "rt", "http", ".", "RoundTripper", ")", "func", "(", "groupcache", ".", "Context", ")", "http", ".", "RoundTripper", "{", "if", "rt", "==", "nil", "{", "rt", "=", "http", ".", "DefaultTransport", "\n", "}", "\n", "ret...
// NewHTTPPoolTransport returns a function that must be used in groupcache.HTTPPool.Transport. // // rt is optional, http.DefaultTransport is used by default.
[ "NewHTTPPoolTransport", "returns", "a", "function", "that", "must", "be", "used", "in", "groupcache", ".", "HTTPPool", ".", "Transport", ".", "rt", "is", "optional", "http", ".", "DefaultTransport", "is", "used", "by", "default", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/cache/groupcache/http.go#L50-L65
20,669
pierrre/imageserver
params.go
Get
func (params Params) Get(key string) (interface{}, error) { v, ok := params[key] if !ok { return nil, &ParamError{Param: key, Message: "not set"} } return v, nil }
go
func (params Params) Get(key string) (interface{}, error) { v, ok := params[key] if !ok { return nil, &ParamError{Param: key, Message: "not set"} } return v, nil }
[ "func", "(", "params", "Params", ")", "Get", "(", "key", "string", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "v", ",", "ok", ":=", "params", "[", "key", "]", "\n", "if", "!", "ok", "{", "return", "nil", ",", "&", "ParamError", "{...
// Get returns the value for the key.
[ "Get", "returns", "the", "value", "for", "the", "key", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/params.go#L24-L30
20,670
pierrre/imageserver
params.go
GetString
func (params Params) GetString(key string) (string, error) { v, err := params.Get(key) if err != nil { return "", err } vt, ok := v.(string) if !ok { return vt, newErrorType(key, v, "string") } return vt, nil }
go
func (params Params) GetString(key string) (string, error) { v, err := params.Get(key) if err != nil { return "", err } vt, ok := v.(string) if !ok { return vt, newErrorType(key, v, "string") } return vt, nil }
[ "func", "(", "params", "Params", ")", "GetString", "(", "key", "string", ")", "(", "string", ",", "error", ")", "{", "v", ",", "err", ":=", "params", ".", "Get", "(", "key", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "...
// GetString returns the string value for the key.
[ "GetString", "returns", "the", "string", "value", "for", "the", "key", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/params.go#L33-L43
20,671
pierrre/imageserver
params.go
GetBool
func (params Params) GetBool(key string) (bool, error) { v, err := params.Get(key) if err != nil { return false, err } vt, ok := v.(bool) if !ok { return false, newErrorType(key, v, "bool") } return vt, nil }
go
func (params Params) GetBool(key string) (bool, error) { v, err := params.Get(key) if err != nil { return false, err } vt, ok := v.(bool) if !ok { return false, newErrorType(key, v, "bool") } return vt, nil }
[ "func", "(", "params", "Params", ")", "GetBool", "(", "key", "string", ")", "(", "bool", ",", "error", ")", "{", "v", ",", "err", ":=", "params", ".", "Get", "(", "key", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "...
// GetBool returns the bool value for the key.
[ "GetBool", "returns", "the", "bool", "value", "for", "the", "key", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/params.go#L85-L95
20,672
pierrre/imageserver
params.go
Has
func (params Params) Has(key string) bool { _, ok := params[key] return ok }
go
func (params Params) Has(key string) bool { _, ok := params[key] return ok }
[ "func", "(", "params", "Params", ")", "Has", "(", "key", "string", ")", "bool", "{", "_", ",", "ok", ":=", "params", "[", "key", "]", "\n", "return", "ok", "\n", "}" ]
// Has returns true if the key exists and false otherwise.
[ "Has", "returns", "true", "if", "the", "key", "exists", "and", "false", "otherwise", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/params.go#L115-L118
20,673
pierrre/imageserver
params.go
Keys
func (params Params) Keys() []string { length := params.Len() keys := make([]string, length) i := 0 for key := range params { keys[i] = key i++ } return keys }
go
func (params Params) Keys() []string { length := params.Len() keys := make([]string, length) i := 0 for key := range params { keys[i] = key i++ } return keys }
[ "func", "(", "params", "Params", ")", "Keys", "(", ")", "[", "]", "string", "{", "length", ":=", "params", ".", "Len", "(", ")", "\n", "keys", ":=", "make", "(", "[", "]", "string", ",", "length", ")", "\n", "i", ":=", "0", "\n", "for", "key", ...
// Keys returns the keys.
[ "Keys", "returns", "the", "keys", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/params.go#L131-L140
20,674
pierrre/imageserver
params.go
String
func (params Params) String() string { buf := bufferPool.Get().(*bytes.Buffer) buf.Reset() defer bufferPool.Put(buf) params.toBuffer(buf) return buf.String() }
go
func (params Params) String() string { buf := bufferPool.Get().(*bytes.Buffer) buf.Reset() defer bufferPool.Put(buf) params.toBuffer(buf) return buf.String() }
[ "func", "(", "params", "Params", ")", "String", "(", ")", "string", "{", "buf", ":=", "bufferPool", ".", "Get", "(", ")", ".", "(", "*", "bytes", ".", "Buffer", ")", "\n", "buf", ".", "Reset", "(", ")", "\n", "defer", "bufferPool", ".", "Put", "(...
// String returns the string representation. // // Keys are sorted alphabetically.
[ "String", "returns", "the", "string", "representation", ".", "Keys", "are", "sorted", "alphabetically", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/params.go#L151-L157
20,675
pierrre/imageserver
params.go
Copy
func (params Params) Copy() Params { p := Params{} for k, v := range params { if q, ok := v.(Params); ok { v = q.Copy() } p[k] = v } return p }
go
func (params Params) Copy() Params { p := Params{} for k, v := range params { if q, ok := v.(Params); ok { v = q.Copy() } p[k] = v } return p }
[ "func", "(", "params", "Params", ")", "Copy", "(", ")", "Params", "{", "p", ":=", "Params", "{", "}", "\n", "for", "k", ",", "v", ":=", "range", "params", "{", "if", "q", ",", "ok", ":=", "v", ".", "(", "Params", ")", ";", "ok", "{", "v", "...
// Copy returns a deep copy of the Params.
[ "Copy", "returns", "a", "deep", "copy", "of", "the", "Params", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/params.go#L181-L190
20,676
pierrre/imageserver
image.go
UnmarshalBinaryNoCopy
func (im *Image) UnmarshalBinaryNoCopy(data []byte) error { readData := func(length int) ([]byte, error) { if length > len(data) { return nil, &ImageError{Message: "unmarshal: unexpected end of data"} } res := data[:length] data = data[length:] return res, nil } var buf []byte var err error buf, err...
go
func (im *Image) UnmarshalBinaryNoCopy(data []byte) error { readData := func(length int) ([]byte, error) { if length > len(data) { return nil, &ImageError{Message: "unmarshal: unexpected end of data"} } res := data[:length] data = data[length:] return res, nil } var buf []byte var err error buf, err...
[ "func", "(", "im", "*", "Image", ")", "UnmarshalBinaryNoCopy", "(", "data", "[", "]", "byte", ")", "error", "{", "readData", ":=", "func", "(", "length", "int", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "length", ">", "len", "(", ...
// UnmarshalBinaryNoCopy is like encoding.BinaryUnmarshaler but does no copy. // // The caller must not reuse data after that.
[ "UnmarshalBinaryNoCopy", "is", "like", "encoding", ".", "BinaryUnmarshaler", "but", "does", "no", "copy", ".", "The", "caller", "must", "not", "reuse", "data", "after", "that", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/image.go#L72-L116
20,677
pierrre/imageserver
server.go
NewLimitServer
func NewLimitServer(s Server, limit int) Server { return &limitServer{ Server: s, limitCh: make(chan struct{}, limit), } }
go
func NewLimitServer(s Server, limit int) Server { return &limitServer{ Server: s, limitCh: make(chan struct{}, limit), } }
[ "func", "NewLimitServer", "(", "s", "Server", ",", "limit", "int", ")", "Server", "{", "return", "&", "limitServer", "{", "Server", ":", "s", ",", "limitCh", ":", "make", "(", "chan", "struct", "{", "}", ",", "limit", ")", ",", "}", "\n", "}" ]
// NewLimitServer creates a new Server that limits the number of concurrent executions. // // It uses a buffered channel to limit the number of concurrent executions.
[ "NewLimitServer", "creates", "a", "new", "Server", "that", "limits", "the", "number", "of", "concurrent", "executions", ".", "It", "uses", "a", "buffered", "channel", "to", "limit", "the", "number", "of", "concurrent", "executions", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/server.go#L20-L25
20,678
pierrre/imageserver
source/http/http.go
IdentifyHeader
func IdentifyHeader(resp *http.Response, data []byte) (format string, err error) { ct := resp.Header.Get("Content-Type") if ct == "" { return "", fmt.Errorf("no HTTP \"Content-Type\" header") } const pref = "image/" if !strings.HasPrefix(ct, pref) { return "", fmt.Errorf("HTTP \"Content-Type\" header does not ...
go
func IdentifyHeader(resp *http.Response, data []byte) (format string, err error) { ct := resp.Header.Get("Content-Type") if ct == "" { return "", fmt.Errorf("no HTTP \"Content-Type\" header") } const pref = "image/" if !strings.HasPrefix(ct, pref) { return "", fmt.Errorf("HTTP \"Content-Type\" header does not ...
[ "func", "IdentifyHeader", "(", "resp", "*", "http", ".", "Response", ",", "data", "[", "]", "byte", ")", "(", "format", "string", ",", "err", "error", ")", "{", "ct", ":=", "resp", ".", "Header", ".", "Get", "(", "\"", "\"", ")", "\n", "if", "ct"...
// IdentifyHeader identifies the Image format with the "Content-Type" header.
[ "IdentifyHeader", "identifies", "the", "Image", "format", "with", "the", "Content", "-", "Type", "header", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/source/http/http.go#L102-L112
20,679
pierrre/imageserver
image/processor.go
Change
func (prc ListProcessor) Change(params imageserver.Params) bool { for _, p := range prc { if p.Change(params) { return true } } return false }
go
func (prc ListProcessor) Change(params imageserver.Params) bool { for _, p := range prc { if p.Change(params) { return true } } return false }
[ "func", "(", "prc", "ListProcessor", ")", "Change", "(", "params", "imageserver", ".", "Params", ")", "bool", "{", "for", "_", ",", "p", ":=", "range", "prc", "{", "if", "p", ".", "Change", "(", "params", ")", "{", "return", "true", "\n", "}", "\n"...
// Change implements Processor.
[ "Change", "implements", "Processor", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/image/processor.go#L46-L53
20,680
pierrre/imageserver
image/gamma/gamma.go
NewProcessor
func NewProcessor(gamma float64, highQuality bool) *Processor { prc := new(Processor) gammaInv := 1 / gamma for i := range prc.vals { prc.vals[i] = uint16(math.Pow(float64(i)/65535, gammaInv)*65535 + 0.5) } if highQuality { prc.newDrawable = func(p image.Image) draw.Image { return image.NewNRGBA64(p.Bounds(...
go
func NewProcessor(gamma float64, highQuality bool) *Processor { prc := new(Processor) gammaInv := 1 / gamma for i := range prc.vals { prc.vals[i] = uint16(math.Pow(float64(i)/65535, gammaInv)*65535 + 0.5) } if highQuality { prc.newDrawable = func(p image.Image) draw.Image { return image.NewNRGBA64(p.Bounds(...
[ "func", "NewProcessor", "(", "gamma", "float64", ",", "highQuality", "bool", ")", "*", "Processor", "{", "prc", ":=", "new", "(", "Processor", ")", "\n", "gammaInv", ":=", "1", "/", "gamma", "\n", "for", "i", ":=", "range", "prc", ".", "vals", "{", "...
// NewProcessor creates a Processor. // // "highQuality" indicates if the Processor return a NRGBA64 Image or an Image with the same quality as the given Image.
[ "NewProcessor", "creates", "a", "Processor", ".", "highQuality", "indicates", "if", "the", "Processor", "return", "a", "NRGBA64", "Image", "or", "an", "Image", "with", "the", "same", "quality", "as", "the", "given", "Image", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/image/gamma/gamma.go#L24-L38
20,681
pierrre/imageserver
image/gamma/gamma.go
NewCorrectionProcessor
func NewCorrectionProcessor(prc imageserver_image.Processor, enabled bool) *CorrectionProcessor { return &CorrectionProcessor{ Processor: prc, enabled: enabled, before: NewProcessor(1/correct, true), after: NewProcessor(correct, true), } }
go
func NewCorrectionProcessor(prc imageserver_image.Processor, enabled bool) *CorrectionProcessor { return &CorrectionProcessor{ Processor: prc, enabled: enabled, before: NewProcessor(1/correct, true), after: NewProcessor(correct, true), } }
[ "func", "NewCorrectionProcessor", "(", "prc", "imageserver_image", ".", "Processor", ",", "enabled", "bool", ")", "*", "CorrectionProcessor", "{", "return", "&", "CorrectionProcessor", "{", "Processor", ":", "prc", ",", "enabled", ":", "enabled", ",", "before", ...
// NewCorrectionProcessor creates a CorrectionProcessor. // // "enabled" indicated if the CorrectionProcessor is enabled by default.
[ "NewCorrectionProcessor", "creates", "a", "CorrectionProcessor", ".", "enabled", "indicated", "if", "the", "CorrectionProcessor", "is", "enabled", "by", "default", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/image/gamma/gamma.go#L91-L98
20,682
pierrre/imageserver
handler.go
Handle
func (f HandlerFunc) Handle(im *Image, params Params) (*Image, error) { return f(im, params) }
go
func (f HandlerFunc) Handle(im *Image, params Params) (*Image, error) { return f(im, params) }
[ "func", "(", "f", "HandlerFunc", ")", "Handle", "(", "im", "*", "Image", ",", "params", "Params", ")", "(", "*", "Image", ",", "error", ")", "{", "return", "f", "(", "im", ",", "params", ")", "\n", "}" ]
// Handle implements Handler.
[ "Handle", "implements", "Handler", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/handler.go#L12-L14
20,683
pierrre/imageserver
handler.go
Get
func (srv *HandlerServer) Get(params Params) (*Image, error) { im, err := srv.Server.Get(params) if err != nil { return nil, err } im, err = srv.Handler.Handle(im, params) if err != nil { return nil, err } return im, nil }
go
func (srv *HandlerServer) Get(params Params) (*Image, error) { im, err := srv.Server.Get(params) if err != nil { return nil, err } im, err = srv.Handler.Handle(im, params) if err != nil { return nil, err } return im, nil }
[ "func", "(", "srv", "*", "HandlerServer", ")", "Get", "(", "params", "Params", ")", "(", "*", "Image", ",", "error", ")", "{", "im", ",", "err", ":=", "srv", ".", "Server", ".", "Get", "(", "params", ")", "\n", "if", "err", "!=", "nil", "{", "r...
// Get implements Server.
[ "Get", "implements", "Server", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/handler.go#L23-L33
20,684
pierrre/imageserver
cache/groupcache/groupcache.go
NewServer
func NewServer(srv imageserver.Server, kg imageserver_cache.KeyGenerator, name string, cacheBytes int64) *Server { return &Server{ Group: groupcache.NewGroup(name, cacheBytes, &Getter{Server: srv}), KeyGenerator: kg, } }
go
func NewServer(srv imageserver.Server, kg imageserver_cache.KeyGenerator, name string, cacheBytes int64) *Server { return &Server{ Group: groupcache.NewGroup(name, cacheBytes, &Getter{Server: srv}), KeyGenerator: kg, } }
[ "func", "NewServer", "(", "srv", "imageserver", ".", "Server", ",", "kg", "imageserver_cache", ".", "KeyGenerator", ",", "name", "string", ",", "cacheBytes", "int64", ")", "*", "Server", "{", "return", "&", "Server", "{", "Group", ":", "groupcache", ".", "...
// NewServer is a helper to create a new groupcache Server.
[ "NewServer", "is", "a", "helper", "to", "create", "a", "new", "groupcache", "Server", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/cache/groupcache/groupcache.go#L13-L18
20,685
pierrre/imageserver
cache/groupcache/groupcache.go
Get
func (gt *Getter) Get(ctx groupcache.Context, key string, dest groupcache.Sink) error { myctx, ok := ctx.(*Context) if !ok { return fmt.Errorf("invalid context type: %T", ctx) } if myctx == nil { return fmt.Errorf("context is nil") } if myctx.Params == nil { return fmt.Errorf("context has nil Params") } i...
go
func (gt *Getter) Get(ctx groupcache.Context, key string, dest groupcache.Sink) error { myctx, ok := ctx.(*Context) if !ok { return fmt.Errorf("invalid context type: %T", ctx) } if myctx == nil { return fmt.Errorf("context is nil") } if myctx.Params == nil { return fmt.Errorf("context has nil Params") } i...
[ "func", "(", "gt", "*", "Getter", ")", "Get", "(", "ctx", "groupcache", ".", "Context", ",", "key", "string", ",", "dest", "groupcache", ".", "Sink", ")", "error", "{", "myctx", ",", "ok", ":=", "ctx", ".", "(", "*", "Context", ")", "\n", "if", "...
// Get implements groupcache.Getter.
[ "Get", "implements", "groupcache", ".", "Getter", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/cache/groupcache/groupcache.go#L54-L74
20,686
pierrre/imageserver
http/error.go
NewErrorDefaultText
func NewErrorDefaultText(code int) *Error { return &Error{Code: code, Text: http.StatusText(code)} }
go
func NewErrorDefaultText(code int) *Error { return &Error{Code: code, Text: http.StatusText(code)} }
[ "func", "NewErrorDefaultText", "(", "code", "int", ")", "*", "Error", "{", "return", "&", "Error", "{", "Code", ":", "code", ",", "Text", ":", "http", ".", "StatusText", "(", "code", ")", "}", "\n", "}" ]
// NewErrorDefaultText creates an Error with the default message associated with the code.
[ "NewErrorDefaultText", "creates", "an", "Error", "with", "the", "default", "message", "associated", "with", "the", "code", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/http/error.go#L17-L19
20,687
pierrre/imageserver
image/encoder.go
Encode
func (f EncoderFunc) Encode(w io.Writer, nim image.Image, params imageserver.Params) error { return f(w, nim, params) }
go
func (f EncoderFunc) Encode(w io.Writer, nim image.Image, params imageserver.Params) error { return f(w, nim, params) }
[ "func", "(", "f", "EncoderFunc", ")", "Encode", "(", "w", "io", ".", "Writer", ",", "nim", "image", ".", "Image", ",", "params", "imageserver", ".", "Params", ")", "error", "{", "return", "f", "(", "w", ",", "nim", ",", "params", ")", "\n", "}" ]
// Encode implements Encoder.
[ "Encode", "implements", "Encoder", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/image/encoder.go#L24-L26
20,688
pierrre/imageserver
image/encoder.go
Decode
func Decode(im *imageserver.Image) (image.Image, error) { nim, format, err := image.Decode(bytes.NewReader(im.Data)) if err != nil { return nil, &imageserver.ImageError{Message: err.Error()} } if format != im.Format { return nil, &imageserver.ImageError{Message: fmt.Sprintf("decoded format \"%s\" does not match...
go
func Decode(im *imageserver.Image) (image.Image, error) { nim, format, err := image.Decode(bytes.NewReader(im.Data)) if err != nil { return nil, &imageserver.ImageError{Message: err.Error()} } if format != im.Format { return nil, &imageserver.ImageError{Message: fmt.Sprintf("decoded format \"%s\" does not match...
[ "func", "Decode", "(", "im", "*", "imageserver", ".", "Image", ")", "(", "image", ".", "Image", ",", "error", ")", "{", "nim", ",", "format", ",", "err", ":=", "image", ".", "Decode", "(", "bytes", ".", "NewReader", "(", "im", ".", "Data", ")", "...
// Decode decodes a raw Image to a Go Image. // // It returns an error if the decoded Image format does not match the raw Image format.
[ "Decode", "decodes", "a", "raw", "Image", "to", "a", "Go", "Image", ".", "It", "returns", "an", "error", "if", "the", "decoded", "Image", "format", "does", "not", "match", "the", "raw", "Image", "format", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/image/encoder.go#L85-L94
20,689
pierrre/imageserver
cache/server.go
NewParamsHashKeyGenerator
func NewParamsHashKeyGenerator(newHashFunc func() hash.Hash) KeyGenerator { pool := &sync.Pool{ New: func() interface{} { return newHashFunc() }, } return KeyGeneratorFunc(func(params imageserver.Params) string { h := pool.Get().(hash.Hash) _, _ = io.WriteString(h, params.String()) data := h.Sum(nil) ...
go
func NewParamsHashKeyGenerator(newHashFunc func() hash.Hash) KeyGenerator { pool := &sync.Pool{ New: func() interface{} { return newHashFunc() }, } return KeyGeneratorFunc(func(params imageserver.Params) string { h := pool.Get().(hash.Hash) _, _ = io.WriteString(h, params.String()) data := h.Sum(nil) ...
[ "func", "NewParamsHashKeyGenerator", "(", "newHashFunc", "func", "(", ")", "hash", ".", "Hash", ")", "KeyGenerator", "{", "pool", ":=", "&", "sync", ".", "Pool", "{", "New", ":", "func", "(", ")", "interface", "{", "}", "{", "return", "newHashFunc", "(",...
// NewParamsHashKeyGenerator returns a new KeyGenerator that hashes the Params.
[ "NewParamsHashKeyGenerator", "returns", "a", "new", "KeyGenerator", "that", "hashes", "the", "Params", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/cache/server.go#L61-L75
20,690
pierrre/imageserver
cache/server.go
GetKey
func (g *PrefixKeyGenerator) GetKey(params imageserver.Params) string { return g.Prefix + g.KeyGenerator.GetKey(params) }
go
func (g *PrefixKeyGenerator) GetKey(params imageserver.Params) string { return g.Prefix + g.KeyGenerator.GetKey(params) }
[ "func", "(", "g", "*", "PrefixKeyGenerator", ")", "GetKey", "(", "params", "imageserver", ".", "Params", ")", "string", "{", "return", "g", ".", "Prefix", "+", "g", ".", "KeyGenerator", ".", "GetKey", "(", "params", ")", "\n", "}" ]
// GetKey implements KeyGenerator.
[ "GetKey", "implements", "KeyGenerator", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/cache/server.go#L84-L86
20,691
pierrre/imageserver
image/internal/internal.go
NewDrawable
func NewDrawable(p image.Image) draw.Image { r := p.Bounds() if _, ok := p.(*image.Uniform); ok { r = image.Rect(0, 0, 1, 1) } return NewDrawableSize(p, r) }
go
func NewDrawable(p image.Image) draw.Image { r := p.Bounds() if _, ok := p.(*image.Uniform); ok { r = image.Rect(0, 0, 1, 1) } return NewDrawableSize(p, r) }
[ "func", "NewDrawable", "(", "p", "image", ".", "Image", ")", "draw", ".", "Image", "{", "r", ":=", "p", ".", "Bounds", "(", ")", "\n", "if", "_", ",", "ok", ":=", "p", ".", "(", "*", "image", ".", "Uniform", ")", ";", "ok", "{", "r", "=", "...
// NewDrawable returns a new draw.Image with the same type and size as p. // // If p has no size, 1x1 is used. // // See NewDrawableSize.
[ "NewDrawable", "returns", "a", "new", "draw", ".", "Image", "with", "the", "same", "type", "and", "size", "as", "p", ".", "If", "p", "has", "no", "size", "1x1", "is", "used", ".", "See", "NewDrawableSize", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/image/internal/internal.go#L17-L23
20,692
pierrre/imageserver
image/internal/internal.go
Copy
func Copy(dst draw.Image, src image.Image) { bd := src.Bounds().Intersect(dst.Bounds()) at := imageutil.NewAtFunc(src) set := imageutil.NewSetFunc(dst) imageutil.Parallel1D(bd, func(bd image.Rectangle) { for y := bd.Min.Y; y < bd.Max.Y; y++ { for x := bd.Min.X; x < bd.Max.X; x++ { r, g, b, a := at(x, y) ...
go
func Copy(dst draw.Image, src image.Image) { bd := src.Bounds().Intersect(dst.Bounds()) at := imageutil.NewAtFunc(src) set := imageutil.NewSetFunc(dst) imageutil.Parallel1D(bd, func(bd image.Rectangle) { for y := bd.Min.Y; y < bd.Max.Y; y++ { for x := bd.Min.X; x < bd.Max.X; x++ { r, g, b, a := at(x, y) ...
[ "func", "Copy", "(", "dst", "draw", ".", "Image", ",", "src", "image", ".", "Image", ")", "{", "bd", ":=", "src", ".", "Bounds", "(", ")", ".", "Intersect", "(", "dst", ".", "Bounds", "(", ")", ")", "\n", "at", ":=", "imageutil", ".", "NewAtFunc"...
// Copy copies src to dst.
[ "Copy", "copies", "src", "to", "dst", "." ]
05bccbfbe5b29f4842ff43827f6768b04b1d3a55
https://github.com/pierrre/imageserver/blob/05bccbfbe5b29f4842ff43827f6768b04b1d3a55/image/internal/internal.go#L60-L72
20,693
c9s/goprocinfo
linux/diskstat.go
GetReadTicks
func (ds *DiskStat) GetReadTicks() time.Duration { return time.Duration(ds.ReadTicks) * time.Millisecond }
go
func (ds *DiskStat) GetReadTicks() time.Duration { return time.Duration(ds.ReadTicks) * time.Millisecond }
[ "func", "(", "ds", "*", "DiskStat", ")", "GetReadTicks", "(", ")", "time", ".", "Duration", "{", "return", "time", ".", "Duration", "(", "ds", ".", "ReadTicks", ")", "*", "time", ".", "Millisecond", "\n", "}" ]
// GetReadTicks returns the duration waited for read requests.
[ "GetReadTicks", "returns", "the", "duration", "waited", "for", "read", "requests", "." ]
0b2ad9ac246b05c4f5750721d0c4d230888cac5e
https://github.com/c9s/goprocinfo/blob/0b2ad9ac246b05c4f5750721d0c4d230888cac5e/linux/diskstat.go#L78-L80
20,694
c9s/goprocinfo
linux/diskstat.go
GetWriteTicks
func (ds *DiskStat) GetWriteTicks() time.Duration { return time.Duration(ds.WriteTicks) * time.Millisecond }
go
func (ds *DiskStat) GetWriteTicks() time.Duration { return time.Duration(ds.WriteTicks) * time.Millisecond }
[ "func", "(", "ds", "*", "DiskStat", ")", "GetWriteTicks", "(", ")", "time", ".", "Duration", "{", "return", "time", ".", "Duration", "(", "ds", ".", "WriteTicks", ")", "*", "time", ".", "Millisecond", "\n", "}" ]
// GetWriteTicks returns the duration waited for write requests.
[ "GetWriteTicks", "returns", "the", "duration", "waited", "for", "write", "requests", "." ]
0b2ad9ac246b05c4f5750721d0c4d230888cac5e
https://github.com/c9s/goprocinfo/blob/0b2ad9ac246b05c4f5750721d0c4d230888cac5e/linux/diskstat.go#L88-L90
20,695
c9s/goprocinfo
linux/diskstat.go
GetIOTicks
func (ds *DiskStat) GetIOTicks() time.Duration { return time.Duration(ds.IOTicks) * time.Millisecond }
go
func (ds *DiskStat) GetIOTicks() time.Duration { return time.Duration(ds.IOTicks) * time.Millisecond }
[ "func", "(", "ds", "*", "DiskStat", ")", "GetIOTicks", "(", ")", "time", ".", "Duration", "{", "return", "time", ".", "Duration", "(", "ds", ".", "IOTicks", ")", "*", "time", ".", "Millisecond", "\n", "}" ]
// GetIOTicks returns the duration the disk has been active.
[ "GetIOTicks", "returns", "the", "duration", "the", "disk", "has", "been", "active", "." ]
0b2ad9ac246b05c4f5750721d0c4d230888cac5e
https://github.com/c9s/goprocinfo/blob/0b2ad9ac246b05c4f5750721d0c4d230888cac5e/linux/diskstat.go#L93-L95
20,696
c9s/goprocinfo
linux/diskstat.go
GetTimeInQueue
func (ds *DiskStat) GetTimeInQueue() time.Duration { return time.Duration(ds.TimeInQueue) * time.Millisecond }
go
func (ds *DiskStat) GetTimeInQueue() time.Duration { return time.Duration(ds.TimeInQueue) * time.Millisecond }
[ "func", "(", "ds", "*", "DiskStat", ")", "GetTimeInQueue", "(", ")", "time", ".", "Duration", "{", "return", "time", ".", "Duration", "(", "ds", ".", "TimeInQueue", ")", "*", "time", ".", "Millisecond", "\n", "}" ]
// GetTimeInQueue returns the duration waited for all requests.
[ "GetTimeInQueue", "returns", "the", "duration", "waited", "for", "all", "requests", "." ]
0b2ad9ac246b05c4f5750721d0c4d230888cac5e
https://github.com/c9s/goprocinfo/blob/0b2ad9ac246b05c4f5750721d0c4d230888cac5e/linux/diskstat.go#L98-L100
20,697
ugorji/go
codec/decode.go
NewDecoderBytes
func NewDecoderBytes(in []byte, h Handle) *Decoder { d := newDecoder(h) d.ResetBytes(in) return d }
go
func NewDecoderBytes(in []byte, h Handle) *Decoder { d := newDecoder(h) d.ResetBytes(in) return d }
[ "func", "NewDecoderBytes", "(", "in", "[", "]", "byte", ",", "h", "Handle", ")", "*", "Decoder", "{", "d", ":=", "newDecoder", "(", "h", ")", "\n", "d", ".", "ResetBytes", "(", "in", ")", "\n", "return", "d", "\n", "}" ]
// NewDecoderBytes returns a Decoder which efficiently decodes directly // from a byte slice with zero copying.
[ "NewDecoderBytes", "returns", "a", "Decoder", "which", "efficiently", "decodes", "directly", "from", "a", "byte", "slice", "with", "zero", "copying", "." ]
1d7ab5c50b36701116070c4c612259f93c262367
https://github.com/ugorji/go/blob/1d7ab5c50b36701116070c4c612259f93c262367/codec/decode.go#L2336-L2340
20,698
ugorji/go
codec/decode.go
newDecoder
func newDecoder(h Handle) *Decoder { d := &Decoder{h: basicHandle(h), err: errDecoderNotInitialized} d.bytes = true if useFinalizers { runtime.SetFinalizer(d, (*Decoder).finalize) // xdebugf(">>>> new(Decoder) with finalizer") } d.r = &d.decReaderSwitch d.hh = h d.be = h.isBinary() // NOTE: do not initializ...
go
func newDecoder(h Handle) *Decoder { d := &Decoder{h: basicHandle(h), err: errDecoderNotInitialized} d.bytes = true if useFinalizers { runtime.SetFinalizer(d, (*Decoder).finalize) // xdebugf(">>>> new(Decoder) with finalizer") } d.r = &d.decReaderSwitch d.hh = h d.be = h.isBinary() // NOTE: do not initializ...
[ "func", "newDecoder", "(", "h", "Handle", ")", "*", "Decoder", "{", "d", ":=", "&", "Decoder", "{", "h", ":", "basicHandle", "(", "h", ")", ",", "err", ":", "errDecoderNotInitialized", "}", "\n", "d", ".", "bytes", "=", "true", "\n", "if", "useFinali...
// var defaultDecNaked decNaked
[ "var", "defaultDecNaked", "decNaked" ]
1d7ab5c50b36701116070c4c612259f93c262367
https://github.com/ugorji/go/blob/1d7ab5c50b36701116070c4c612259f93c262367/codec/decode.go#L2344-L2367
20,699
ugorji/go
codec/decode.go
nextValueBytes
func (d *Decoder) nextValueBytes() (bs []byte) { d.d.uncacheRead() d.r.track() d.swallow() bs = d.r.stopTrack() return }
go
func (d *Decoder) nextValueBytes() (bs []byte) { d.d.uncacheRead() d.r.track() d.swallow() bs = d.r.stopTrack() return }
[ "func", "(", "d", "*", "Decoder", ")", "nextValueBytes", "(", ")", "(", "bs", "[", "]", "byte", ")", "{", "d", ".", "d", ".", "uncacheRead", "(", ")", "\n", "d", ".", "r", ".", "track", "(", ")", "\n", "d", ".", "swallow", "(", ")", "\n", "...
// nextValueBytes returns the next value in the stream as a set of bytes.
[ "nextValueBytes", "returns", "the", "next", "value", "in", "the", "stream", "as", "a", "set", "of", "bytes", "." ]
1d7ab5c50b36701116070c4c612259f93c262367
https://github.com/ugorji/go/blob/1d7ab5c50b36701116070c4c612259f93c262367/codec/decode.go#L2899-L2905