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
22,700
mesosphere/mesos-dns
resolver/resolver.go
formatNS
func (res *Resolver) formatNS(dom string) *dns.NS { ttl := uint32(res.config.TTL) return &dns.NS{ Hdr: dns.RR_Header{ Name: dom, Rrtype: dns.TypeNS, Class: dns.ClassINET, Ttl: ttl, }, Ns: res.config.SOAMname, } }
go
func (res *Resolver) formatNS(dom string) *dns.NS { ttl := uint32(res.config.TTL) return &dns.NS{ Hdr: dns.RR_Header{ Name: dom, Rrtype: dns.TypeNS, Class: dns.ClassINET, Ttl: ttl, }, Ns: res.config.SOAMname, } }
[ "func", "(", "res", "*", "Resolver", ")", "formatNS", "(", "dom", "string", ")", "*", "dns", ".", "NS", "{", "ttl", ":=", "uint32", "(", "res", ".", "config", ".", "TTL", ")", "\n\n", "return", "&", "dns", ".", "NS", "{", "Hdr", ":", "dns", "."...
// formatNS returns the NS record for the mesos domain
[ "formatNS", "returns", "the", "NS", "record", "for", "the", "mesos", "domain" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/resolver/resolver.go#L286-L298
22,701
mesosphere/mesos-dns
resolver/resolver.go
shuffleAnswers
func shuffleAnswers(rng *rand.Rand, answers []dns.RR) []dns.RR { n := len(answers) for i := 0; i < n; i++ { r := i + rng.Intn(n-i) answers[r], answers[i] = answers[i], answers[r] } return answers }
go
func shuffleAnswers(rng *rand.Rand, answers []dns.RR) []dns.RR { n := len(answers) for i := 0; i < n; i++ { r := i + rng.Intn(n-i) answers[r], answers[i] = answers[i], answers[r] } return answers }
[ "func", "shuffleAnswers", "(", "rng", "*", "rand", ".", "Rand", ",", "answers", "[", "]", "dns", ".", "RR", ")", "[", "]", "dns", ".", "RR", "{", "n", ":=", "len", "(", "answers", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "n", ";", "...
// reorders answers for very basic load balancing
[ "reorders", "answers", "for", "very", "basic", "load", "balancing" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/resolver/resolver.go#L301-L309
22,702
mesosphere/mesos-dns
resolver/resolver.go
HandleNonMesos
func (res *Resolver) HandleNonMesos(fwd exchanger.Forwarder) func( dns.ResponseWriter, *dns.Msg) { return func(w dns.ResponseWriter, r *dns.Msg) { logging.CurLog.NonMesosRequests.Inc() m, err := fwd(r, w.RemoteAddr().Network()) if err != nil { m = new(dns.Msg).SetRcode(r, rcode(err)) } else if len(m.Answer...
go
func (res *Resolver) HandleNonMesos(fwd exchanger.Forwarder) func( dns.ResponseWriter, *dns.Msg) { return func(w dns.ResponseWriter, r *dns.Msg) { logging.CurLog.NonMesosRequests.Inc() m, err := fwd(r, w.RemoteAddr().Network()) if err != nil { m = new(dns.Msg).SetRcode(r, rcode(err)) } else if len(m.Answer...
[ "func", "(", "res", "*", "Resolver", ")", "HandleNonMesos", "(", "fwd", "exchanger", ".", "Forwarder", ")", "func", "(", "dns", ".", "ResponseWriter", ",", "*", "dns", ".", "Msg", ")", "{", "return", "func", "(", "w", "dns", ".", "ResponseWriter", ",",...
// HandleNonMesos handles non-mesos queries by forwarding to configured // external DNS servers.
[ "HandleNonMesos", "handles", "non", "-", "mesos", "queries", "by", "forwarding", "to", "configured", "external", "DNS", "servers", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/resolver/resolver.go#L313-L325
22,703
mesosphere/mesos-dns
resolver/resolver.go
reply
func reply(w dns.ResponseWriter, m *dns.Msg, setTruncateBit bool) { m.Compress = true // https://github.com/mesosphere/mesos-dns/issues/{170,173,174} maxsize := maxMsgSize(isUDP(w), m.IsEdns0()) truncate(m, maxsize, setTruncateBit) if err := w.WriteMsg(m); err != nil { logging.Error.Println(err) } }
go
func reply(w dns.ResponseWriter, m *dns.Msg, setTruncateBit bool) { m.Compress = true // https://github.com/mesosphere/mesos-dns/issues/{170,173,174} maxsize := maxMsgSize(isUDP(w), m.IsEdns0()) truncate(m, maxsize, setTruncateBit) if err := w.WriteMsg(m); err != nil { logging.Error.Println(err) } }
[ "func", "reply", "(", "w", "dns", ".", "ResponseWriter", ",", "m", "*", "dns", ".", "Msg", ",", "setTruncateBit", "bool", ")", "{", "m", ".", "Compress", "=", "true", "// https://github.com/mesosphere/mesos-dns/issues/{170,173,174}", "\n", "maxsize", ":=", "maxM...
// reply writes the given dns.Msg out to the given dns.ResponseWriter, // compressing the message first and truncating it accordingly.
[ "reply", "writes", "the", "given", "dns", ".", "Msg", "out", "to", "the", "given", "dns", ".", "ResponseWriter", "compressing", "the", "message", "first", "and", "truncating", "it", "accordingly", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/resolver/resolver.go#L495-L502
22,704
mesosphere/mesos-dns
resolver/resolver.go
isUDP
func isUDP(w dns.ResponseWriter) bool { return strings.HasPrefix(w.RemoteAddr().Network(), "udp") }
go
func isUDP(w dns.ResponseWriter) bool { return strings.HasPrefix(w.RemoteAddr().Network(), "udp") }
[ "func", "isUDP", "(", "w", "dns", ".", "ResponseWriter", ")", "bool", "{", "return", "strings", ".", "HasPrefix", "(", "w", ".", "RemoteAddr", "(", ")", ".", "Network", "(", ")", ",", "\"", "\"", ")", "\n", "}" ]
// isUDP returns true if the transmission channel in use is UDP.
[ "isUDP", "returns", "true", "if", "the", "transmission", "channel", "in", "use", "is", "UDP", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/resolver/resolver.go#L505-L507
22,705
mesosphere/mesos-dns
resolver/resolver.go
LaunchHTTP
func (res *Resolver) LaunchHTTP() <-chan error { defer util.HandleCrash() res.configureHTTP() listenAddress := net.JoinHostPort(res.config.HTTPListener, strconv.Itoa(res.config.HTTPPort)) errCh := make(chan error, 1) go func() { var err error defer func() { errCh <- err }() if err = http.ListenAndServe(li...
go
func (res *Resolver) LaunchHTTP() <-chan error { defer util.HandleCrash() res.configureHTTP() listenAddress := net.JoinHostPort(res.config.HTTPListener, strconv.Itoa(res.config.HTTPPort)) errCh := make(chan error, 1) go func() { var err error defer func() { errCh <- err }() if err = http.ListenAndServe(li...
[ "func", "(", "res", "*", "Resolver", ")", "LaunchHTTP", "(", ")", "<-", "chan", "error", "{", "defer", "util", ".", "HandleCrash", "(", ")", "\n\n", "res", ".", "configureHTTP", "(", ")", "\n", "listenAddress", ":=", "net", ".", "JoinHostPort", "(", "r...
// LaunchHTTP starts an HTTP server for the Resolver, returning a error channel // to which errors are asynchronously sent.
[ "LaunchHTTP", "starts", "an", "HTTP", "server", "for", "the", "Resolver", "returning", "a", "error", "channel", "to", "which", "errors", "are", "asynchronously", "sent", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/resolver/resolver.go#L604-L622
22,706
mesosphere/mesos-dns
resolver/resolver.go
RestConfig
func (res *Resolver) RestConfig(req *restful.Request, resp *restful.Response) { if err := resp.WriteAsJson(res.config); err != nil { logging.Error.Println(err) } }
go
func (res *Resolver) RestConfig(req *restful.Request, resp *restful.Response) { if err := resp.WriteAsJson(res.config); err != nil { logging.Error.Println(err) } }
[ "func", "(", "res", "*", "Resolver", ")", "RestConfig", "(", "req", "*", "restful", ".", "Request", ",", "resp", "*", "restful", ".", "Response", ")", "{", "if", "err", ":=", "resp", ".", "WriteAsJson", "(", "res", ".", "config", ")", ";", "err", "...
// RestConfig handles HTTP requests of Resolver configuration.
[ "RestConfig", "handles", "HTTP", "requests", "of", "Resolver", "configuration", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/resolver/resolver.go#L625-L629
22,707
mesosphere/mesos-dns
resolver/resolver.go
RestEnumerate
func (res *Resolver) RestEnumerate(req *restful.Request, resp *restful.Response) { enumData := res.records().EnumData if err := resp.WriteAsJson(enumData); err != nil { logging.Error.Println(err) } }
go
func (res *Resolver) RestEnumerate(req *restful.Request, resp *restful.Response) { enumData := res.records().EnumData if err := resp.WriteAsJson(enumData); err != nil { logging.Error.Println(err) } }
[ "func", "(", "res", "*", "Resolver", ")", "RestEnumerate", "(", "req", "*", "restful", ".", "Request", ",", "resp", "*", "restful", ".", "Response", ")", "{", "enumData", ":=", "res", ".", "records", "(", ")", ".", "EnumData", "\n", "if", "err", ":="...
// RestEnumerate handles HTTP requests of the enumeration data
[ "RestEnumerate", "handles", "HTTP", "requests", "of", "the", "enumeration", "data" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/resolver/resolver.go#L632-L638
22,708
mesosphere/mesos-dns
resolver/resolver.go
RestAXFR
func (res *Resolver) RestAXFR(req *restful.Request, resp *restful.Response) { records := res.records() AXFRRecords := models.AXFRRecords{ SRVs: records.SRVs.ToAXFRResourceRecordSet(), As: records.As.ToAXFRResourceRecordSet(), AAAAs: records.AAAAs.ToAXFRResourceRecordSet(), } AXFR := models.AXFR{ Record...
go
func (res *Resolver) RestAXFR(req *restful.Request, resp *restful.Response) { records := res.records() AXFRRecords := models.AXFRRecords{ SRVs: records.SRVs.ToAXFRResourceRecordSet(), As: records.As.ToAXFRResourceRecordSet(), AAAAs: records.AAAAs.ToAXFRResourceRecordSet(), } AXFR := models.AXFR{ Record...
[ "func", "(", "res", "*", "Resolver", ")", "RestAXFR", "(", "req", "*", "restful", ".", "Request", ",", "resp", "*", "restful", ".", "Response", ")", "{", "records", ":=", "res", ".", "records", "(", ")", "\n\n", "AXFRRecords", ":=", "models", ".", "A...
// RestAXFR handles HTTP requests to turn the zone into a transferable format
[ "RestAXFR", "handles", "HTTP", "requests", "to", "turn", "the", "zone", "into", "a", "transferable", "format" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/resolver/resolver.go#L641-L662
22,709
mesosphere/mesos-dns
resolver/resolver.go
RestVersion
func (res *Resolver) RestVersion(req *restful.Request, resp *restful.Response) { err := resp.WriteAsJson(map[string]string{ "Service": "Mesos-DNS", "Version": res.version, "URL": "https://github.com/mesosphere/mesos-dns", }) if err != nil { logging.Error.Println(err) } }
go
func (res *Resolver) RestVersion(req *restful.Request, resp *restful.Response) { err := resp.WriteAsJson(map[string]string{ "Service": "Mesos-DNS", "Version": res.version, "URL": "https://github.com/mesosphere/mesos-dns", }) if err != nil { logging.Error.Println(err) } }
[ "func", "(", "res", "*", "Resolver", ")", "RestVersion", "(", "req", "*", "restful", ".", "Request", ",", "resp", "*", "restful", ".", "Response", ")", "{", "err", ":=", "resp", ".", "WriteAsJson", "(", "map", "[", "string", "]", "string", "{", "\"",...
// RestVersion handles HTTP requests of Mesos-DNS version.
[ "RestVersion", "handles", "HTTP", "requests", "of", "Mesos", "-", "DNS", "version", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/resolver/resolver.go#L665-L674
22,710
mesosphere/mesos-dns
resolver/resolver.go
RestHost
func (res *Resolver) RestHost(req *restful.Request, resp *restful.Response) { host := req.PathParameter("host") // clean up host name dom := strings.ToLower(cleanWild(host)) if dom[len(dom)-1] != '.' { dom += "." } rs := res.records() type record struct { Host string `json:"host"` IP string `json:"ip"` ...
go
func (res *Resolver) RestHost(req *restful.Request, resp *restful.Response) { host := req.PathParameter("host") // clean up host name dom := strings.ToLower(cleanWild(host)) if dom[len(dom)-1] != '.' { dom += "." } rs := res.records() type record struct { Host string `json:"host"` IP string `json:"ip"` ...
[ "func", "(", "res", "*", "Resolver", ")", "RestHost", "(", "req", "*", "restful", ".", "Request", ",", "resp", "*", "restful", ".", "Response", ")", "{", "host", ":=", "req", ".", "PathParameter", "(", "\"", "\"", ")", "\n", "// clean up host name", "d...
// RestHost handles HTTP requests of DNS A records of the given host.
[ "RestHost", "handles", "HTTP", "requests", "of", "DNS", "A", "records", "of", "the", "given", "host", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/resolver/resolver.go#L677-L710
22,711
mesosphere/mesos-dns
resolver/resolver.go
RestPorts
func (res *Resolver) RestPorts(req *restful.Request, resp *restful.Response) { err := resp.WriteErrorString(http.StatusNotImplemented, "To be implemented...") if err != nil { logging.Error.Println(err) } }
go
func (res *Resolver) RestPorts(req *restful.Request, resp *restful.Response) { err := resp.WriteErrorString(http.StatusNotImplemented, "To be implemented...") if err != nil { logging.Error.Println(err) } }
[ "func", "(", "res", "*", "Resolver", ")", "RestPorts", "(", "req", "*", "restful", ".", "Request", ",", "resp", "*", "restful", ".", "Response", ")", "{", "err", ":=", "resp", ".", "WriteErrorString", "(", "http", ".", "StatusNotImplemented", ",", "\"", ...
// RestPorts is an HTTP handler which is currently not implemented.
[ "RestPorts", "is", "an", "HTTP", "handler", "which", "is", "currently", "not", "implemented", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/resolver/resolver.go#L727-L732
22,712
mesosphere/mesos-dns
resolver/resolver.go
RestService
func (res *Resolver) RestService(req *restful.Request, resp *restful.Response) { service := req.PathParameter("service") // clean up service name dom := strings.ToLower(cleanWild(service)) if dom[len(dom)-1] != '.' { dom += "." } rs := res.records() type record struct { Service string `json:"service"` Hos...
go
func (res *Resolver) RestService(req *restful.Request, resp *restful.Response) { service := req.PathParameter("service") // clean up service name dom := strings.ToLower(cleanWild(service)) if dom[len(dom)-1] != '.' { dom += "." } rs := res.records() type record struct { Service string `json:"service"` Hos...
[ "func", "(", "res", "*", "Resolver", ")", "RestService", "(", "req", "*", "restful", ".", "Request", ",", "resp", "*", "restful", ".", "Response", ")", "{", "service", ":=", "req", ".", "PathParameter", "(", "\"", "\"", ")", "\n", "// clean up service na...
// RestService handles HTTP requests of DNS SRV records for the given name.
[ "RestService", "handles", "HTTP", "requests", "of", "DNS", "SRV", "records", "for", "the", "given", "name", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/resolver/resolver.go#L735-L776
22,713
mesosphere/mesos-dns
resolver/resolver.go
panicRecover
func panicRecover(f func(w dns.ResponseWriter, r *dns.Msg)) func(w dns.ResponseWriter, r *dns.Msg) { return func(w dns.ResponseWriter, r *dns.Msg) { defer func() { if rec := recover(); rec != nil { m := new(dns.Msg) m.SetRcode(r, 2) if err := w.WriteMsg(m); err != nil { logging.Error.Println(err)...
go
func panicRecover(f func(w dns.ResponseWriter, r *dns.Msg)) func(w dns.ResponseWriter, r *dns.Msg) { return func(w dns.ResponseWriter, r *dns.Msg) { defer func() { if rec := recover(); rec != nil { m := new(dns.Msg) m.SetRcode(r, 2) if err := w.WriteMsg(m); err != nil { logging.Error.Println(err)...
[ "func", "panicRecover", "(", "f", "func", "(", "w", "dns", ".", "ResponseWriter", ",", "r", "*", "dns", ".", "Msg", ")", ")", "func", "(", "w", "dns", ".", "ResponseWriter", ",", "r", "*", "dns", ".", "Msg", ")", "{", "return", "func", "(", "w", ...
// panicRecover catches any panics from the resolvers and sets an error // code of server failure
[ "panicRecover", "catches", "any", "panics", "from", "the", "resolvers", "and", "sets", "an", "error", "code", "of", "server", "failure" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/resolver/resolver.go#L780-L794
22,714
mesosphere/mesos-dns
resolver/resolver.go
cleanWild
func cleanWild(name string) string { if strings.Contains(name, ".*") { return strings.Replace(name, ".*", "", -1) } return name }
go
func cleanWild(name string) string { if strings.Contains(name, ".*") { return strings.Replace(name, ".*", "", -1) } return name }
[ "func", "cleanWild", "(", "name", "string", ")", "string", "{", "if", "strings", ".", "Contains", "(", "name", ",", "\"", "\"", ")", "{", "return", "strings", ".", "Replace", "(", "name", ",", "\"", "\"", ",", "\"", "\"", ",", "-", "1", ")", "\n"...
// cleanWild strips any wildcards out thus mapping cleanly to the // original serviceName
[ "cleanWild", "strips", "any", "wildcards", "out", "thus", "mapping", "cleanly", "to", "the", "original", "serviceName" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/resolver/resolver.go#L798-L803
22,715
mesosphere/mesos-dns
urls/urls.go
With
func (b Builder) With(options ...Option) Builder { for i := range options { if options[i] != nil { options[i](&b) } } return b }
go
func (b Builder) With(options ...Option) Builder { for i := range options { if options[i] != nil { options[i](&b) } } return b }
[ "func", "(", "b", "Builder", ")", "With", "(", "options", "...", "Option", ")", "Builder", "{", "for", "i", ":=", "range", "options", "{", "if", "options", "[", "i", "]", "!=", "nil", "{", "options", "[", "i", "]", "(", "&", "b", ")", "\n", "}"...
// With configures a net.URL via a Builder wrapper, returns the modified result
[ "With", "configures", "a", "net", ".", "URL", "via", "a", "Builder", "wrapper", "returns", "the", "modified", "result" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/urls/urls.go#L17-L24
22,716
mesosphere/mesos-dns
httpcli/basic/basic.go
Register
func Register() { httpcli.Register(httpcli.AuthBasic, httpcli.DoerFactory(func(cm httpcli.ConfigMap, c *http.Client) (doer httpcli.Doer) { obj := cm.FindOrPanic(httpcli.AuthBasic) config, ok := obj.(Credentials) if !ok { panic(fmt.Errorf("expected Credentials instead of %#+v", obj)) } validate(config) i...
go
func Register() { httpcli.Register(httpcli.AuthBasic, httpcli.DoerFactory(func(cm httpcli.ConfigMap, c *http.Client) (doer httpcli.Doer) { obj := cm.FindOrPanic(httpcli.AuthBasic) config, ok := obj.(Credentials) if !ok { panic(fmt.Errorf("expected Credentials instead of %#+v", obj)) } validate(config) i...
[ "func", "Register", "(", ")", "{", "httpcli", ".", "Register", "(", "httpcli", ".", "AuthBasic", ",", "httpcli", ".", "DoerFactory", "(", "func", "(", "cm", "httpcli", ".", "ConfigMap", ",", "c", "*", "http", ".", "Client", ")", "(", "doer", "httpcli",...
// Register registers a DoerFactory for HTTP Basic authentication
[ "Register", "registers", "a", "DoerFactory", "for", "HTTP", "Basic", "authentication" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/httpcli/basic/basic.go#L11-L24
22,717
mesosphere/mesos-dns
httpcli/basic/basic.go
Doer
func Doer(client httpcli.Doer, credentials Credentials) httpcli.Doer { return httpcli.DoerFunc(func(req *http.Request) (*http.Response, error) { req.SetBasicAuth(credentials.Principal, credentials.Secret) return client.Do(req) }) }
go
func Doer(client httpcli.Doer, credentials Credentials) httpcli.Doer { return httpcli.DoerFunc(func(req *http.Request) (*http.Response, error) { req.SetBasicAuth(credentials.Principal, credentials.Secret) return client.Do(req) }) }
[ "func", "Doer", "(", "client", "httpcli", ".", "Doer", ",", "credentials", "Credentials", ")", "httpcli", ".", "Doer", "{", "return", "httpcli", ".", "DoerFunc", "(", "func", "(", "req", "*", "http", ".", "Request", ")", "(", "*", "http", ".", "Respons...
// Doer wraps an HTTP transactor given basic credentials
[ "Doer", "wraps", "an", "HTTP", "transactor", "given", "basic", "credentials" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/httpcli/basic/basic.go#L33-L38
22,718
mesosphere/mesos-dns
httpcli/config.go
ToConfigMap
func (cmo ConfigMapOptions) ToConfigMap() (m ConfigMap) { m = make(ConfigMap) for _, opt := range cmo { if opt != nil { opt(m) } } if len(m) == 0 { m = nil } return m }
go
func (cmo ConfigMapOptions) ToConfigMap() (m ConfigMap) { m = make(ConfigMap) for _, opt := range cmo { if opt != nil { opt(m) } } if len(m) == 0 { m = nil } return m }
[ "func", "(", "cmo", "ConfigMapOptions", ")", "ToConfigMap", "(", ")", "(", "m", "ConfigMap", ")", "{", "m", "=", "make", "(", "ConfigMap", ")", "\n", "for", "_", ",", "opt", ":=", "range", "cmo", "{", "if", "opt", "!=", "nil", "{", "opt", "(", "m...
// ToConfigMap generates a ConfigMap from the given options. If no map entries are generated // then a nil ConfigMap is returned.
[ "ToConfigMap", "generates", "a", "ConfigMap", "from", "the", "given", "options", ".", "If", "no", "map", "entries", "are", "generated", "then", "a", "nil", "ConfigMap", "is", "returned", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/httpcli/config.go#L63-L74
22,719
mesosphere/mesos-dns
httpcli/config.go
FindOrPanic
func (cm ConfigMap) FindOrPanic(am AuthMechanism) interface{} { obj, ok := cm[am] if !ok { panic(ErrMissingConfiguration) } return obj }
go
func (cm ConfigMap) FindOrPanic(am AuthMechanism) interface{} { obj, ok := cm[am] if !ok { panic(ErrMissingConfiguration) } return obj }
[ "func", "(", "cm", "ConfigMap", ")", "FindOrPanic", "(", "am", "AuthMechanism", ")", "interface", "{", "}", "{", "obj", ",", "ok", ":=", "cm", "[", "am", "]", "\n", "if", "!", "ok", "{", "panic", "(", "ErrMissingConfiguration", ")", "\n", "}", "\n", ...
// FindOrPanic returns the mapped configuration for the given auth mechanism or else panics
[ "FindOrPanic", "returns", "the", "mapped", "configuration", "for", "the", "given", "auth", "mechanism", "or", "else", "panics" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/httpcli/config.go#L77-L83
22,720
mesosphere/mesos-dns
httpcli/config.go
Register
func Register(am AuthMechanism, df DoerFactory) { registry.Lock() defer registry.Unlock() if _, ok := registry.factories[am]; ok { panic(ErrDuplicateAuthRegistration) } registry.factories[am] = df }
go
func Register(am AuthMechanism, df DoerFactory) { registry.Lock() defer registry.Unlock() if _, ok := registry.factories[am]; ok { panic(ErrDuplicateAuthRegistration) } registry.factories[am] = df }
[ "func", "Register", "(", "am", "AuthMechanism", ",", "df", "DoerFactory", ")", "{", "registry", ".", "Lock", "(", ")", "\n", "defer", "registry", ".", "Unlock", "(", ")", "\n\n", "if", "_", ",", "ok", ":=", "registry", ".", "factories", "[", "am", "]...
// Register associates an AuthMechanism with a DoerFactory
[ "Register", "associates", "an", "AuthMechanism", "with", "a", "DoerFactory" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/httpcli/config.go#L86-L94
22,721
mesosphere/mesos-dns
httpcli/config.go
Validate
func Validate(am AuthMechanism, cm ConfigMap) (err error) { df, ok := factoryFor(am) if !ok { err = ErrUnregisteredFactory } else { defer func() { // recover from a factory panic if v := recover(); v != nil { if verr, ok := v.(error); ok { err = verr } else { panic(v) // unexpected, forwa...
go
func Validate(am AuthMechanism, cm ConfigMap) (err error) { df, ok := factoryFor(am) if !ok { err = ErrUnregisteredFactory } else { defer func() { // recover from a factory panic if v := recover(); v != nil { if verr, ok := v.(error); ok { err = verr } else { panic(v) // unexpected, forwa...
[ "func", "Validate", "(", "am", "AuthMechanism", ",", "cm", "ConfigMap", ")", "(", "err", "error", ")", "{", "df", ",", "ok", ":=", "factoryFor", "(", "am", ")", "\n", "if", "!", "ok", "{", "err", "=", "ErrUnregisteredFactory", "\n", "}", "else", "{",...
// Validate checks that the given AuthMechainsm and ConfigMap are compatible with the // registered set of DoerFactory instances.
[ "Validate", "checks", "that", "the", "given", "AuthMechainsm", "and", "ConfigMap", "are", "compatible", "with", "the", "registered", "set", "of", "DoerFactory", "instances", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/httpcli/config.go#L113-L133
22,722
mesosphere/mesos-dns
logging/logging.go
String
func (lc *LogCounter) String() string { return strconv.FormatUint(atomic.LoadUint64(&lc.value), 10) }
go
func (lc *LogCounter) String() string { return strconv.FormatUint(atomic.LoadUint64(&lc.value), 10) }
[ "func", "(", "lc", "*", "LogCounter", ")", "String", "(", ")", "string", "{", "return", "strconv", ".", "FormatUint", "(", "atomic", ".", "LoadUint64", "(", "&", "lc", ".", "value", ")", ",", "10", ")", "\n", "}" ]
// String returns a string represention of the counter.
[ "String", "returns", "a", "string", "represention", "of", "the", "counter", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/logging/logging.go#L43-L45
22,723
mesosphere/mesos-dns
logging/logging.go
SetupLogs
func SetupLogs() { // initialize logging flags if glog.V(2) { VeryVerboseFlag = true } else if glog.V(1) { VerboseFlag = true } logopts := log.Ldate | log.Ltime | log.Lshortfile if VerboseFlag { Verbose = log.New(os.Stdout, "VERBOSE: ", logopts) VeryVerbose = log.New(ioutil.Discard, "VERY VERBOSE: ", lo...
go
func SetupLogs() { // initialize logging flags if glog.V(2) { VeryVerboseFlag = true } else if glog.V(1) { VerboseFlag = true } logopts := log.Ldate | log.Ltime | log.Lshortfile if VerboseFlag { Verbose = log.New(os.Stdout, "VERBOSE: ", logopts) VeryVerbose = log.New(ioutil.Discard, "VERY VERBOSE: ", lo...
[ "func", "SetupLogs", "(", ")", "{", "// initialize logging flags", "if", "glog", ".", "V", "(", "2", ")", "{", "VeryVerboseFlag", "=", "true", "\n", "}", "else", "if", "glog", ".", "V", "(", "1", ")", "{", "VerboseFlag", "=", "true", "\n", "}", "\n\n...
// SetupLogs provides the following logs // Verbose = optional verbosity // VeryVerbose = optional verbosity // Error = stderr
[ "SetupLogs", "provides", "the", "following", "logs", "Verbose", "=", "optional", "verbosity", "VeryVerbose", "=", "optional", "verbosity", "Error", "=", "stderr" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/logging/logging.go#L82-L104
22,724
mesosphere/mesos-dns
detect/masters.go
NewMasters
func NewMasters(masters []string, changed chan<- []string) *Masters { return &Masters{ masters: append([]string{""}, masters...), changed: changed, } }
go
func NewMasters(masters []string, changed chan<- []string) *Masters { return &Masters{ masters: append([]string{""}, masters...), changed: changed, } }
[ "func", "NewMasters", "(", "masters", "[", "]", "string", ",", "changed", "chan", "<-", "[", "]", "string", ")", "*", "Masters", "{", "return", "&", "Masters", "{", "masters", ":", "append", "(", "[", "]", "string", "{", "\"", "\"", "}", ",", "mast...
// NewMasters returns a new Masters detector with the given initial masters // and the given changed channel to which master changes will be sent to. // Initially the leader is unknown which is represented by // setting the first item of the sent masters slice to be empty.
[ "NewMasters", "returns", "a", "new", "Masters", "detector", "with", "the", "given", "initial", "masters", "and", "the", "given", "changed", "channel", "to", "which", "master", "changes", "will", "be", "sent", "to", ".", "Initially", "the", "leader", "is", "u...
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/detect/masters.go#L36-L41
22,725
mesosphere/mesos-dns
detect/masters.go
OnMasterChanged
func (ms *Masters) OnMasterChanged(leader *mesos.MasterInfo) { logging.VeryVerbose.Println("Updated leader: ", leader) ms.masters = ordered(masterAddr(leader), ms.masters[1:]) emit(ms.changed, ms.masters) }
go
func (ms *Masters) OnMasterChanged(leader *mesos.MasterInfo) { logging.VeryVerbose.Println("Updated leader: ", leader) ms.masters = ordered(masterAddr(leader), ms.masters[1:]) emit(ms.changed, ms.masters) }
[ "func", "(", "ms", "*", "Masters", ")", "OnMasterChanged", "(", "leader", "*", "mesos", ".", "MasterInfo", ")", "{", "logging", ".", "VeryVerbose", ".", "Println", "(", "\"", "\"", ",", "leader", ")", "\n", "ms", ".", "masters", "=", "ordered", "(", ...
// OnMasterChanged sets the given MasterInfo as the current leader // leaving the remaining masters unchanged and emits the current masters state. // It implements the detector.MasterChanged interface.
[ "OnMasterChanged", "sets", "the", "given", "MasterInfo", "as", "the", "current", "leader", "leaving", "the", "remaining", "masters", "unchanged", "and", "emits", "the", "current", "masters", "state", ".", "It", "implements", "the", "detector", ".", "MasterChanged"...
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/detect/masters.go#L46-L50
22,726
mesosphere/mesos-dns
detect/masters.go
UpdatedMasters
func (ms *Masters) UpdatedMasters(infos []*mesos.MasterInfo) { logging.VeryVerbose.Println("Updated masters: ", infos) masters := make([]string, 0, len(infos)) for _, info := range infos { if addr := masterAddr(info); addr != "" { masters = append(masters, addr) } } ms.masters = ordered(ms.masters[0], maste...
go
func (ms *Masters) UpdatedMasters(infos []*mesos.MasterInfo) { logging.VeryVerbose.Println("Updated masters: ", infos) masters := make([]string, 0, len(infos)) for _, info := range infos { if addr := masterAddr(info); addr != "" { masters = append(masters, addr) } } ms.masters = ordered(ms.masters[0], maste...
[ "func", "(", "ms", "*", "Masters", ")", "UpdatedMasters", "(", "infos", "[", "]", "*", "mesos", ".", "MasterInfo", ")", "{", "logging", ".", "VeryVerbose", ".", "Println", "(", "\"", "\"", ",", "infos", ")", "\n", "masters", ":=", "make", "(", "[", ...
// UpdatedMasters sets the given slice of MasterInfo as the current remaining masters // leaving the current leader unchanged and emits the current masters state. // It implements the detector.AllMasters interface.
[ "UpdatedMasters", "sets", "the", "given", "slice", "of", "MasterInfo", "as", "the", "current", "remaining", "masters", "leaving", "the", "current", "leader", "unchanged", "and", "emits", "the", "current", "masters", "state", ".", "It", "implements", "the", "dete...
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/detect/masters.go#L55-L65
22,727
mesosphere/mesos-dns
detect/masters.go
ordered
func ordered(leader string, masters []string) []string { ms := append(make([]string, 0, len(masters)+1), leader) for _, m := range masters { if m != leader { ms = append(ms, m) } } return ms }
go
func ordered(leader string, masters []string) []string { ms := append(make([]string, 0, len(masters)+1), leader) for _, m := range masters { if m != leader { ms = append(ms, m) } } return ms }
[ "func", "ordered", "(", "leader", "string", ",", "masters", "[", "]", "string", ")", "[", "]", "string", "{", "ms", ":=", "append", "(", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "masters", ")", "+", "1", ")", ",", "leader", "...
// ordered returns a slice of masters with the given leader in the first position
[ "ordered", "returns", "a", "slice", "of", "masters", "with", "the", "given", "leader", "in", "the", "first", "position" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/detect/masters.go#L72-L80
22,728
mesosphere/mesos-dns
exchanger/forwarder.go
Forward
func (f Forwarder) Forward(m *dns.Msg, proto string) (*dns.Msg, error) { return f(m, proto) }
go
func (f Forwarder) Forward(m *dns.Msg, proto string) (*dns.Msg, error) { return f(m, proto) }
[ "func", "(", "f", "Forwarder", ")", "Forward", "(", "m", "*", "dns", ".", "Msg", ",", "proto", "string", ")", "(", "*", "dns", ".", "Msg", ",", "error", ")", "{", "return", "f", "(", "m", ",", "proto", ")", "\n", "}" ]
// Forward is an utility method that calls f itself.
[ "Forward", "is", "an", "utility", "method", "that", "calls", "f", "itself", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/exchanger/forwarder.go#L15-L17
22,729
mesosphere/mesos-dns
httpcli/iam/iam.go
Doer
func Doer(client *http.Client, config Config) httpcli.Doer { return httpcli.DoerFunc(func(req *http.Request) (*http.Response, error) { // TODO if we still have a valid token, try using it first token := jwt.New(jwt.SigningMethodRS256) token.Claims["uid"] = config.ID token.Claims["exp"] = time.Now().Add(time.Ho...
go
func Doer(client *http.Client, config Config) httpcli.Doer { return httpcli.DoerFunc(func(req *http.Request) (*http.Response, error) { // TODO if we still have a valid token, try using it first token := jwt.New(jwt.SigningMethodRS256) token.Claims["uid"] = config.ID token.Claims["exp"] = time.Now().Add(time.Ho...
[ "func", "Doer", "(", "client", "*", "http", ".", "Client", ",", "config", "Config", ")", "httpcli", ".", "Doer", "{", "return", "httpcli", ".", "DoerFunc", "(", "func", "(", "req", "*", "http", ".", "Request", ")", "(", "*", "http", ".", "Response", ...
// Doer wraps an HTTP transactor given an IAM configuration
[ "Doer", "wraps", "an", "HTTP", "transactor", "given", "an", "IAM", "configuration" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/httpcli/iam/iam.go#L38-L88
22,730
mesosphere/mesos-dns
records/labels/labels.go
DomainFrag
func DomainFrag(name, sep string, label Func) string { var labels []string for _, part := range strings.Split(name, sep) { if lab := label(part); lab != "" { labels = append(labels, lab) } } return strings.Join(labels, sep) }
go
func DomainFrag(name, sep string, label Func) string { var labels []string for _, part := range strings.Split(name, sep) { if lab := label(part); lab != "" { labels = append(labels, lab) } } return strings.Join(labels, sep) }
[ "func", "DomainFrag", "(", "name", ",", "sep", "string", ",", "label", "Func", ")", "string", "{", "var", "labels", "[", "]", "string", "\n", "for", "_", ",", "part", ":=", "range", "strings", ".", "Split", "(", "name", ",", "sep", ")", "{", "if", ...
// DomainFrag mangles the given name in order to produce a valid domain fragment. // A valid domain fragment will consist of one or more host name labels // concatenated by the given separator.
[ "DomainFrag", "mangles", "the", "given", "name", "in", "order", "to", "produce", "a", "valid", "domain", "fragment", ".", "A", "valid", "domain", "fragment", "will", "consist", "of", "one", "or", "more", "host", "name", "labels", "concatenated", "by", "the",...
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/labels/labels.go#L14-L22
22,731
mesosphere/mesos-dns
records/labels/labels.go
label
func label(name []byte, maxlen int, left, right string) []byte { return trimCut(bytes.Map(mapping, name), maxlen, left, right) }
go
func label(name []byte, maxlen int, left, right string) []byte { return trimCut(bytes.Map(mapping, name), maxlen, left, right) }
[ "func", "label", "(", "name", "[", "]", "byte", ",", "maxlen", "int", ",", "left", ",", "right", "string", ")", "[", "]", "byte", "{", "return", "trimCut", "(", "bytes", ".", "Map", "(", "mapping", ",", "name", ")", ",", "maxlen", ",", "left", ",...
// label computes a label from the given name with maxlen length and the // left and right cutsets trimmed from their respective ends.
[ "label", "computes", "a", "label", "from", "the", "given", "name", "with", "maxlen", "length", "and", "the", "left", "and", "right", "cutsets", "trimmed", "from", "their", "respective", "ends", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/labels/labels.go#L41-L43
22,732
mesosphere/mesos-dns
records/labels/labels.go
mapping
func mapping(r rune) rune { switch { case r >= 'A' && r <= 'Z': return r - ('A' - 'a') case r >= 'a' && r <= 'z': fallthrough case r >= '0' && r <= '9': return r case r == '-' || r == '.' || r == '_': return '-' default: return -1 } }
go
func mapping(r rune) rune { switch { case r >= 'A' && r <= 'Z': return r - ('A' - 'a') case r >= 'a' && r <= 'z': fallthrough case r >= '0' && r <= '9': return r case r == '-' || r == '.' || r == '_': return '-' default: return -1 } }
[ "func", "mapping", "(", "r", "rune", ")", "rune", "{", "switch", "{", "case", "r", ">=", "'A'", "&&", "r", "<=", "'Z'", ":", "return", "r", "-", "(", "'A'", "-", "'a'", ")", "\n", "case", "r", ">=", "'a'", "&&", "r", "<=", "'z'", ":", "fallth...
// mapping maps a given rune to its valid DNS label counterpart.
[ "mapping", "maps", "a", "given", "rune", "to", "its", "valid", "DNS", "label", "counterpart", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/labels/labels.go#L46-L59
22,733
mesosphere/mesos-dns
records/state/state.go
Ports
func (r Resources) Ports() []string { if r.PortRanges == "" || r.PortRanges == "[]" { return []string{} } rhs := strings.Split(r.PortRanges, "[")[1] lhs := strings.Split(rhs, "]")[0] yports := []string{} mports := strings.Split(lhs, ",") for _, port := range mports { tmp := strings.TrimSpace(port) pz :=...
go
func (r Resources) Ports() []string { if r.PortRanges == "" || r.PortRanges == "[]" { return []string{} } rhs := strings.Split(r.PortRanges, "[")[1] lhs := strings.Split(rhs, "]")[0] yports := []string{} mports := strings.Split(lhs, ",") for _, port := range mports { tmp := strings.TrimSpace(port) pz :=...
[ "func", "(", "r", "Resources", ")", "Ports", "(", ")", "[", "]", "string", "{", "if", "r", ".", "PortRanges", "==", "\"", "\"", "||", "r", ".", "PortRanges", "==", "\"", "\"", "{", "return", "[", "]", "string", "{", "}", "\n", "}", "\n\n", "rhs...
// Ports returns a slice of individual ports expanded from PortRanges.
[ "Ports", "returns", "a", "slice", "of", "individual", "ports", "expanded", "from", "PortRanges", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/state/state.go#L19-L49
22,734
mesosphere/mesos-dns
records/state/state.go
IP
func (t *Task) IP(srcs ...string) string { if ips := t.IPs(srcs...); len(ips) > 0 { return ips[0].String() } return "" }
go
func (t *Task) IP(srcs ...string) string { if ips := t.IPs(srcs...); len(ips) > 0 { return ips[0].String() } return "" }
[ "func", "(", "t", "*", "Task", ")", "IP", "(", "srcs", "...", "string", ")", "string", "{", "if", "ips", ":=", "t", ".", "IPs", "(", "srcs", "...", ")", ";", "len", "(", "ips", ")", ">", "0", "{", "return", "ips", "[", "0", "]", ".", "Strin...
// IP returns the first Task IP found in the given sources.
[ "IP", "returns", "the", "first", "Task", "IP", "found", "in", "the", "given", "sources", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/state/state.go#L106-L111
22,735
mesosphere/mesos-dns
records/state/state.go
IPs
func (t *Task) IPs(srcs ...string) (ips []net.IP) { if t == nil { return nil } for i := range srcs { if src, ok := sources[srcs[i]]; ok { for _, srcIP := range src(t) { if ip := net.ParseIP(srcIP); len(ip) > 0 { ips = append(ips, ip) } } } } return ips }
go
func (t *Task) IPs(srcs ...string) (ips []net.IP) { if t == nil { return nil } for i := range srcs { if src, ok := sources[srcs[i]]; ok { for _, srcIP := range src(t) { if ip := net.ParseIP(srcIP); len(ip) > 0 { ips = append(ips, ip) } } } } return ips }
[ "func", "(", "t", "*", "Task", ")", "IPs", "(", "srcs", "...", "string", ")", "(", "ips", "[", "]", "net", ".", "IP", ")", "{", "if", "t", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "for", "i", ":=", "range", "srcs", "{", "if", "sr...
// IPs returns a slice of IPs sourced from the given sources with ascending // priority.
[ "IPs", "returns", "a", "slice", "of", "IPs", "sourced", "from", "the", "given", "sources", "with", "ascending", "priority", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/state/state.go#L115-L129
22,736
mesosphere/mesos-dns
records/state/state.go
statusIPs
func statusIPs(st []Status, src func(*Status) []string) []string { // the state we extract from mesos makes no guarantees re: the order // of the task statuses so we should check the timestamps to avoid problems // down the line. we can't rely on seeing the same sequence. (@joris) // https://github.com/apache/mesos...
go
func statusIPs(st []Status, src func(*Status) []string) []string { // the state we extract from mesos makes no guarantees re: the order // of the task statuses so we should check the timestamps to avoid problems // down the line. we can't rely on seeing the same sequence. (@joris) // https://github.com/apache/mesos...
[ "func", "statusIPs", "(", "st", "[", "]", "Status", ",", "src", "func", "(", "*", "Status", ")", "[", "]", "string", ")", "[", "]", "string", "{", "// the state we extract from mesos makes no guarantees re: the order", "// of the task statuses so we should check the tim...
// statusIPs returns the latest running status IPs extracted with the given src
[ "statusIPs", "returns", "the", "latest", "running", "status", "IPs", "extracted", "with", "the", "given", "src" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/state/state.go#L186-L201
22,737
mesosphere/mesos-dns
records/state/state.go
HostPort
func (f Framework) HostPort() (string, string) { if f.PID.UPID != nil { return f.PID.Host, f.PID.Port } return f.Hostname, "" }
go
func (f Framework) HostPort() (string, string) { if f.PID.UPID != nil { return f.PID.Host, f.PID.Port } return f.Hostname, "" }
[ "func", "(", "f", "Framework", ")", "HostPort", "(", ")", "(", "string", ",", "string", ")", "{", "if", "f", ".", "PID", ".", "UPID", "!=", "nil", "{", "return", "f", ".", "PID", ".", "Host", ",", "f", ".", "PID", ".", "Port", "\n", "}", "\n"...
// HostPort returns the hostname and port where a framework's scheduler is // listening on.
[ "HostPort", "returns", "the", "hostname", "and", "port", "where", "a", "framework", "s", "scheduler", "is", "listening", "on", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/state/state.go#L227-L232
22,738
mesosphere/mesos-dns
records/state/state.go
UnmarshalJSON
func (p *PID) UnmarshalJSON(data []byte) (err error) { p.UPID, err = upid.Parse(string(bytes.Trim(data, `" `))) return err }
go
func (p *PID) UnmarshalJSON(data []byte) (err error) { p.UPID, err = upid.Parse(string(bytes.Trim(data, `" `))) return err }
[ "func", "(", "p", "*", "PID", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "(", "err", "error", ")", "{", "p", ".", "UPID", ",", "err", "=", "upid", ".", "Parse", "(", "string", "(", "bytes", ".", "Trim", "(", "data", ",", "`\" `",...
// UnmarshalJSON implements the json.Unmarshaler interface for PIDs.
[ "UnmarshalJSON", "implements", "the", "json", ".", "Unmarshaler", "interface", "for", "PIDs", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/state/state.go#L245-L248
22,739
mesosphere/mesos-dns
records/config.go
NewConfig
func NewConfig() Config { return Config{ ZkDetectionTimeout: 30, RefreshSeconds: 60, TTL: 60, SRVRecordDefaultWeight: 1, Domain: "mesos", Port: 53, Timeout: 5, StateTimeoutSeconds: 300, SOARname: "root.ns1.mesos", ...
go
func NewConfig() Config { return Config{ ZkDetectionTimeout: 30, RefreshSeconds: 60, TTL: 60, SRVRecordDefaultWeight: 1, Domain: "mesos", Port: 53, Timeout: 5, StateTimeoutSeconds: 300, SOARname: "root.ns1.mesos", ...
[ "func", "NewConfig", "(", ")", "Config", "{", "return", "Config", "{", "ZkDetectionTimeout", ":", "30", ",", "RefreshSeconds", ":", "60", ",", "TTL", ":", "60", ",", "SRVRecordDefaultWeight", ":", "1", ",", "Domain", ":", "\"", "\"", ",", "Port", ":", ...
// NewConfig return the default config of the resolver
[ "NewConfig", "return", "the", "default", "config", "of", "the", "resolver" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/config.go#L114-L144
22,740
mesosphere/mesos-dns
records/config.go
SetConfig
func SetConfig(cjson string) Config { c, err := readConfig(cjson) if err != nil { logging.Error.Fatal(err) } logging.Verbose.Printf("config loaded from %q", c.File) // validate and complete configuration file err = validateEnabledServices(c) if err != nil { logging.Error.Fatalf("service validation failed: %v...
go
func SetConfig(cjson string) Config { c, err := readConfig(cjson) if err != nil { logging.Error.Fatal(err) } logging.Verbose.Printf("config loaded from %q", c.File) // validate and complete configuration file err = validateEnabledServices(c) if err != nil { logging.Error.Fatalf("service validation failed: %v...
[ "func", "SetConfig", "(", "cjson", "string", ")", "Config", "{", "c", ",", "err", ":=", "readConfig", "(", "cjson", ")", "\n", "if", "err", "!=", "nil", "{", "logging", ".", "Error", ".", "Fatal", "(", "err", ")", "\n", "}", "\n", "logging", ".", ...
// SetConfig instantiates a Config struct read in from config.json
[ "SetConfig", "instantiates", "a", "Config", "struct", "read", "in", "from", "config", ".", "json" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/config.go#L147-L185
22,741
mesosphere/mesos-dns
records/config.go
nonLocalAddies
func nonLocalAddies(cservers []string) []string { bad := localAddies() good := []string{} for i := 0; i < len(cservers); i++ { local := false for x := 0; x < len(bad); x++ { if cservers[i] == bad[x] { local = true } } if !local { good = append(good, cservers[i]) } } return good }
go
func nonLocalAddies(cservers []string) []string { bad := localAddies() good := []string{} for i := 0; i < len(cservers); i++ { local := false for x := 0; x < len(bad); x++ { if cservers[i] == bad[x] { local = true } } if !local { good = append(good, cservers[i]) } } return good }
[ "func", "nonLocalAddies", "(", "cservers", "[", "]", "string", ")", "[", "]", "string", "{", "bad", ":=", "localAddies", "(", ")", "\n\n", "good", ":=", "[", "]", "string", "{", "}", "\n\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "cser...
// Returns non-local nameserver entries
[ "Returns", "non", "-", "local", "nameserver", "entries" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/config.go#L384-L403
22,742
mesosphere/mesos-dns
records/config.go
localAddies
func localAddies() []string { addies, err := net.InterfaceAddrs() if err != nil { logging.Error.Println(err) } bad := []string{} for i := 0; i < len(addies); i++ { ip, _, err := net.ParseCIDR(addies[i].String()) if err != nil { logging.Error.Println(err) } // The servers in cservers above could incl...
go
func localAddies() []string { addies, err := net.InterfaceAddrs() if err != nil { logging.Error.Println(err) } bad := []string{} for i := 0; i < len(addies); i++ { ip, _, err := net.ParseCIDR(addies[i].String()) if err != nil { logging.Error.Println(err) } // The servers in cservers above could incl...
[ "func", "localAddies", "(", ")", "[", "]", "string", "{", "addies", ",", "err", ":=", "net", ".", "InterfaceAddrs", "(", ")", "\n", "if", "err", "!=", "nil", "{", "logging", ".", "Error", ".", "Println", "(", "err", ")", "\n", "}", "\n\n", "bad", ...
// Returns an array of local ipv4 addresses
[ "Returns", "an", "array", "of", "local", "ipv4", "addresses" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/config.go#L406-L430
22,743
libp2p/go-reuseport
interface.go
Listen
func Listen(network, address string) (net.Listener, error) { return listenConfig.Listen(context.Background(), network, address) }
go
func Listen(network, address string) (net.Listener, error) { return listenConfig.Listen(context.Background(), network, address) }
[ "func", "Listen", "(", "network", ",", "address", "string", ")", "(", "net", ".", "Listener", ",", "error", ")", "{", "return", "listenConfig", ".", "Listen", "(", "context", ".", "Background", "(", ")", ",", "network", ",", "address", ")", "\n", "}" ]
// Listen listens at the given network and address. see net.Listen // Returns a net.Listener created from a file discriptor for a socket // with SO_REUSEPORT and SO_REUSEADDR option set.
[ "Listen", "listens", "at", "the", "given", "network", "and", "address", ".", "see", "net", ".", "Listen", "Returns", "a", "net", ".", "Listener", "created", "from", "a", "file", "discriptor", "for", "a", "socket", "with", "SO_REUSEPORT", "and", "SO_REUSEADDR...
b72b23b78b80078df1a7991f6ca39942cb8cc5e1
https://github.com/libp2p/go-reuseport/blob/b72b23b78b80078df1a7991f6ca39942cb8cc5e1/interface.go#L40-L42
22,744
libp2p/go-reuseport
interface.go
ListenPacket
func ListenPacket(network, address string) (net.PacketConn, error) { return listenConfig.ListenPacket(context.Background(), network, address) }
go
func ListenPacket(network, address string) (net.PacketConn, error) { return listenConfig.ListenPacket(context.Background(), network, address) }
[ "func", "ListenPacket", "(", "network", ",", "address", "string", ")", "(", "net", ".", "PacketConn", ",", "error", ")", "{", "return", "listenConfig", ".", "ListenPacket", "(", "context", ".", "Background", "(", ")", ",", "network", ",", "address", ")", ...
// ListenPacket listens at the given network and address. see net.ListenPacket // Returns a net.Listener created from a file discriptor for a socket // with SO_REUSEPORT and SO_REUSEADDR option set.
[ "ListenPacket", "listens", "at", "the", "given", "network", "and", "address", ".", "see", "net", ".", "ListenPacket", "Returns", "a", "net", ".", "Listener", "created", "from", "a", "file", "discriptor", "for", "a", "socket", "with", "SO_REUSEPORT", "and", "...
b72b23b78b80078df1a7991f6ca39942cb8cc5e1
https://github.com/libp2p/go-reuseport/blob/b72b23b78b80078df1a7991f6ca39942cb8cc5e1/interface.go#L47-L49
22,745
libp2p/go-reuseport
interface.go
Dial
func Dial(network, laddr, raddr string) (net.Conn, error) { nla, err := ResolveAddr(network, laddr) if err != nil { return nil, errors.Wrap(err, "resolving local addr") } d := net.Dialer{ Control: Control, LocalAddr: nla, } return d.Dial(network, raddr) }
go
func Dial(network, laddr, raddr string) (net.Conn, error) { nla, err := ResolveAddr(network, laddr) if err != nil { return nil, errors.Wrap(err, "resolving local addr") } d := net.Dialer{ Control: Control, LocalAddr: nla, } return d.Dial(network, raddr) }
[ "func", "Dial", "(", "network", ",", "laddr", ",", "raddr", "string", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "nla", ",", "err", ":=", "ResolveAddr", "(", "network", ",", "laddr", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// Dial dials the given network and address. see net.Dialer.Dial // Returns a net.Conn created from a file descriptor for a socket // with SO_REUSEPORT and SO_REUSEADDR option set.
[ "Dial", "dials", "the", "given", "network", "and", "address", ".", "see", "net", ".", "Dialer", ".", "Dial", "Returns", "a", "net", ".", "Conn", "created", "from", "a", "file", "descriptor", "for", "a", "socket", "with", "SO_REUSEPORT", "and", "SO_REUSEADD...
b72b23b78b80078df1a7991f6ca39942cb8cc5e1
https://github.com/libp2p/go-reuseport/blob/b72b23b78b80078df1a7991f6ca39942cb8cc5e1/interface.go#L54-L64
22,746
etcd-io/gofail
runtime/failpoint.go
Acquire
func (fp *Failpoint) Acquire() (interface{}, error) { fp.mu.RLock() if fp.t == nil { fp.mu.RUnlock() return nil, ErrDisabled } v, err := fp.t.eval() if v == nil { err = ErrDisabled } if err != nil { fp.mu.RUnlock() } return v, err }
go
func (fp *Failpoint) Acquire() (interface{}, error) { fp.mu.RLock() if fp.t == nil { fp.mu.RUnlock() return nil, ErrDisabled } v, err := fp.t.eval() if v == nil { err = ErrDisabled } if err != nil { fp.mu.RUnlock() } return v, err }
[ "func", "(", "fp", "*", "Failpoint", ")", "Acquire", "(", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "fp", ".", "mu", ".", "RLock", "(", ")", "\n", "if", "fp", ".", "t", "==", "nil", "{", "fp", ".", "mu", ".", "RUnlock", "(", ...
// Acquire gets evalutes the failpoint terms; if the failpoint // is active, it will return a value. Otherwise, returns a non-nil error.
[ "Acquire", "gets", "evalutes", "the", "failpoint", "terms", ";", "if", "the", "failpoint", "is", "active", "it", "will", "return", "a", "value", ".", "Otherwise", "returns", "a", "non", "-", "nil", "error", "." ]
51ce9a71510a58bad5ae66ddd278ef28762a1550
https://github.com/etcd-io/gofail/blob/51ce9a71510a58bad5ae66ddd278ef28762a1550/runtime/failpoint.go#L35-L49
22,747
etcd-io/gofail
runtime/failpoint.go
BadType
func (fp *Failpoint) BadType(v interface{}, t string) { fmt.Printf("failpoint: %q got value %v of type \"%T\" but expected type %q\n", fp.t.fpath, v, v, t) }
go
func (fp *Failpoint) BadType(v interface{}, t string) { fmt.Printf("failpoint: %q got value %v of type \"%T\" but expected type %q\n", fp.t.fpath, v, v, t) }
[ "func", "(", "fp", "*", "Failpoint", ")", "BadType", "(", "v", "interface", "{", "}", ",", "t", "string", ")", "{", "fmt", ".", "Printf", "(", "\"", "\\\"", "\\\"", "\\n", "\"", ",", "fp", ".", "t", ".", "fpath", ",", "v", ",", "v", ",", "t",...
// BadType is called when the failpoint evaluates to the wrong type.
[ "BadType", "is", "called", "when", "the", "failpoint", "evaluates", "to", "the", "wrong", "type", "." ]
51ce9a71510a58bad5ae66ddd278ef28762a1550
https://github.com/etcd-io/gofail/blob/51ce9a71510a58bad5ae66ddd278ef28762a1550/runtime/failpoint.go#L55-L57
22,748
etcd-io/gofail
code/failpoint.go
newFailpoint
func newFailpoint(l string) (*Failpoint, error) { if !strings.HasPrefix(strings.TrimSpace(l), "// gofail:") { // not a failpoint return nil, nil } cmd := strings.SplitAfter(l, "// gofail:")[1] fields := strings.Fields(cmd) if len(fields) != 3 || fields[0] != "var" { return nil, fmt.Errorf("failpoint: malform...
go
func newFailpoint(l string) (*Failpoint, error) { if !strings.HasPrefix(strings.TrimSpace(l), "// gofail:") { // not a failpoint return nil, nil } cmd := strings.SplitAfter(l, "// gofail:")[1] fields := strings.Fields(cmd) if len(fields) != 3 || fields[0] != "var" { return nil, fmt.Errorf("failpoint: malform...
[ "func", "newFailpoint", "(", "l", "string", ")", "(", "*", "Failpoint", ",", "error", ")", "{", "if", "!", "strings", ".", "HasPrefix", "(", "strings", ".", "TrimSpace", "(", "l", ")", ",", "\"", "\"", ")", "{", "// not a failpoint", "return", "nil", ...
// newFailpoint makes a new failpoint based on the a line containing a // failpoint comment header.
[ "newFailpoint", "makes", "a", "new", "failpoint", "based", "on", "the", "a", "line", "containing", "a", "failpoint", "comment", "header", "." ]
51ce9a71510a58bad5ae66ddd278ef28762a1550
https://github.com/etcd-io/gofail/blob/51ce9a71510a58bad5ae66ddd278ef28762a1550/code/failpoint.go#L34-L45
22,749
etcd-io/gofail
code/failpoint.go
flush
func (fp *Failpoint) flush(dst io.Writer) error { if len(fp.code) == 0 { return fp.flushSingle(dst) } return fp.flushMulti(dst) }
go
func (fp *Failpoint) flush(dst io.Writer) error { if len(fp.code) == 0 { return fp.flushSingle(dst) } return fp.flushMulti(dst) }
[ "func", "(", "fp", "*", "Failpoint", ")", "flush", "(", "dst", "io", ".", "Writer", ")", "error", "{", "if", "len", "(", "fp", ".", "code", ")", "==", "0", "{", "return", "fp", ".", "flushSingle", "(", "dst", ")", "\n", "}", "\n", "return", "fp...
// flush writes the failpoint code to a buffer
[ "flush", "writes", "the", "failpoint", "code", "to", "a", "buffer" ]
51ce9a71510a58bad5ae66ddd278ef28762a1550
https://github.com/etcd-io/gofail/blob/51ce9a71510a58bad5ae66ddd278ef28762a1550/code/failpoint.go#L48-L53
22,750
etcd-io/gofail
code/rewrite.go
ToFailpoints
func ToFailpoints(wdst io.Writer, rsrc io.Reader) (fps []*Failpoint, err error) { var curfp *Failpoint dst := bufio.NewWriter(wdst) defer func() { if err == nil && curfp != nil { err = curfp.flush(dst) } if err == nil { err = dst.Flush() } }() src := bufio.NewReader(rsrc) for err == nil { l, rer...
go
func ToFailpoints(wdst io.Writer, rsrc io.Reader) (fps []*Failpoint, err error) { var curfp *Failpoint dst := bufio.NewWriter(wdst) defer func() { if err == nil && curfp != nil { err = curfp.flush(dst) } if err == nil { err = dst.Flush() } }() src := bufio.NewReader(rsrc) for err == nil { l, rer...
[ "func", "ToFailpoints", "(", "wdst", "io", ".", "Writer", ",", "rsrc", "io", ".", "Reader", ")", "(", "fps", "[", "]", "*", "Failpoint", ",", "err", "error", ")", "{", "var", "curfp", "*", "Failpoint", "\n\n", "dst", ":=", "bufio", ".", "NewWriter", ...
// ToFailpoints turns all gofail comments into failpoint code. Returns a list of // all failpoints it activated.
[ "ToFailpoints", "turns", "all", "gofail", "comments", "into", "failpoint", "code", ".", "Returns", "a", "list", "of", "all", "failpoints", "it", "activated", "." ]
51ce9a71510a58bad5ae66ddd278ef28762a1550
https://github.com/etcd-io/gofail/blob/51ce9a71510a58bad5ae66ddd278ef28762a1550/code/rewrite.go#L26-L71
22,751
etcd-io/gofail
code/rewrite.go
ToComments
func ToComments(wdst io.Writer, rsrc io.Reader) (fps []*Failpoint, err error) { src := bufio.NewReader(rsrc) dst := bufio.NewWriter(wdst) ws := "" unmatchedBraces := 0 for err == nil { l, rerr := src.ReadString('\n') err = rerr lTrim := strings.TrimSpace(l) if unmatchedBraces > 0 { opening, closing := ...
go
func ToComments(wdst io.Writer, rsrc io.Reader) (fps []*Failpoint, err error) { src := bufio.NewReader(rsrc) dst := bufio.NewWriter(wdst) ws := "" unmatchedBraces := 0 for err == nil { l, rerr := src.ReadString('\n') err = rerr lTrim := strings.TrimSpace(l) if unmatchedBraces > 0 { opening, closing := ...
[ "func", "ToComments", "(", "wdst", "io", ".", "Writer", ",", "rsrc", "io", ".", "Reader", ")", "(", "fps", "[", "]", "*", "Failpoint", ",", "err", "error", ")", "{", "src", ":=", "bufio", ".", "NewReader", "(", "rsrc", ")", "\n", "dst", ":=", "bu...
// ToComments turns all failpoint code into GOFAIL comments. It returns // a list of all failpoints it deactivated.
[ "ToComments", "turns", "all", "failpoint", "code", "into", "GOFAIL", "comments", ".", "It", "returns", "a", "list", "of", "all", "failpoints", "it", "deactivated", "." ]
51ce9a71510a58bad5ae66ddd278ef28762a1550
https://github.com/etcd-io/gofail/blob/51ce9a71510a58bad5ae66ddd278ef28762a1550/code/rewrite.go#L75-L124
22,752
etcd-io/gofail
code/rewrite.go
wsPrefix
func wsPrefix(l, wsPfx string) string { lws := "" if len(wsPfx) == 0 { lws = l } else { wsSplit := strings.SplitAfter(l, wsPfx) if len(wsSplit) < 2 { return "" } lws = strings.Join(wsSplit[1:], "") } for i, c := range lws { if !unicode.IsSpace(c) { return lws[:i] } } return lws }
go
func wsPrefix(l, wsPfx string) string { lws := "" if len(wsPfx) == 0 { lws = l } else { wsSplit := strings.SplitAfter(l, wsPfx) if len(wsSplit) < 2 { return "" } lws = strings.Join(wsSplit[1:], "") } for i, c := range lws { if !unicode.IsSpace(c) { return lws[:i] } } return lws }
[ "func", "wsPrefix", "(", "l", ",", "wsPfx", "string", ")", "string", "{", "lws", ":=", "\"", "\"", "\n", "if", "len", "(", "wsPfx", ")", "==", "0", "{", "lws", "=", "l", "\n", "}", "else", "{", "wsSplit", ":=", "strings", ".", "SplitAfter", "(", ...
// wsPrefix computes the left padding of a line given a whitespace prefix.
[ "wsPrefix", "computes", "the", "left", "padding", "of", "a", "line", "given", "a", "whitespace", "prefix", "." ]
51ce9a71510a58bad5ae66ddd278ef28762a1550
https://github.com/etcd-io/gofail/blob/51ce9a71510a58bad5ae66ddd278ef28762a1550/code/rewrite.go#L150-L167
22,753
etcd-io/gofail
runtime/runtime.go
Enable
func Enable(failpath, inTerms string) error { unlock, err := enableAndLock(failpath, inTerms) if unlock != nil { unlock() } return err }
go
func Enable(failpath, inTerms string) error { unlock, err := enableAndLock(failpath, inTerms) if unlock != nil { unlock() } return err }
[ "func", "Enable", "(", "failpath", ",", "inTerms", "string", ")", "error", "{", "unlock", ",", "err", ":=", "enableAndLock", "(", "failpath", ",", "inTerms", ")", "\n", "if", "unlock", "!=", "nil", "{", "unlock", "(", ")", "\n", "}", "\n", "return", ...
// Enable sets a failpoint to a given failpoint description.
[ "Enable", "sets", "a", "failpoint", "to", "a", "given", "failpoint", "description", "." ]
51ce9a71510a58bad5ae66ddd278ef28762a1550
https://github.com/etcd-io/gofail/blob/51ce9a71510a58bad5ae66ddd278ef28762a1550/runtime/runtime.go#L56-L62
22,754
etcd-io/gofail
runtime/runtime.go
enableAndLock
func enableAndLock(failpath, inTerms string) (func(), error) { t, err := newTerms(failpath, inTerms) if err != nil { fmt.Printf("failed to enable \"%s=%s\" (%v)\n", failpath, inTerms, err) return nil, err } failpointsMu.RLock() fp := failpoints[failpath] failpointsMu.RUnlock() if fp == nil { return nil, Er...
go
func enableAndLock(failpath, inTerms string) (func(), error) { t, err := newTerms(failpath, inTerms) if err != nil { fmt.Printf("failed to enable \"%s=%s\" (%v)\n", failpath, inTerms, err) return nil, err } failpointsMu.RLock() fp := failpoints[failpath] failpointsMu.RUnlock() if fp == nil { return nil, Er...
[ "func", "enableAndLock", "(", "failpath", ",", "inTerms", "string", ")", "(", "func", "(", ")", ",", "error", ")", "{", "t", ",", "err", ":=", "newTerms", "(", "failpath", ",", "inTerms", ")", "\n", "if", "err", "!=", "nil", "{", "fmt", ".", "Print...
// enableAndLock enables a failpoint and returns a function to unlock it
[ "enableAndLock", "enables", "a", "failpoint", "and", "returns", "a", "function", "to", "unlock", "it" ]
51ce9a71510a58bad5ae66ddd278ef28762a1550
https://github.com/etcd-io/gofail/blob/51ce9a71510a58bad5ae66ddd278ef28762a1550/runtime/runtime.go#L65-L80
22,755
etcd-io/gofail
runtime/runtime.go
Disable
func Disable(failpath string) error { failpointsMu.RLock() fp := failpoints[failpath] failpointsMu.RUnlock() if fp == nil { return ErrNoExist } fp.mu.Lock() defer fp.mu.Unlock() if fp.t == nil { return ErrDisabled } fp.t = nil return nil }
go
func Disable(failpath string) error { failpointsMu.RLock() fp := failpoints[failpath] failpointsMu.RUnlock() if fp == nil { return ErrNoExist } fp.mu.Lock() defer fp.mu.Unlock() if fp.t == nil { return ErrDisabled } fp.t = nil return nil }
[ "func", "Disable", "(", "failpath", "string", ")", "error", "{", "failpointsMu", ".", "RLock", "(", ")", "\n", "fp", ":=", "failpoints", "[", "failpath", "]", "\n", "failpointsMu", ".", "RUnlock", "(", ")", "\n", "if", "fp", "==", "nil", "{", "return",...
// Disable stops a failpoint from firing.
[ "Disable", "stops", "a", "failpoint", "from", "firing", "." ]
51ce9a71510a58bad5ae66ddd278ef28762a1550
https://github.com/etcd-io/gofail/blob/51ce9a71510a58bad5ae66ddd278ef28762a1550/runtime/runtime.go#L83-L97
22,756
etcd-io/gofail
runtime/runtime.go
Status
func Status(failpath string) (string, error) { failpointsMu.RLock() fp := failpoints[failpath] failpointsMu.RUnlock() if fp == nil { return "", ErrNoExist } fp.mu.RLock() t := fp.t fp.mu.RUnlock() if t == nil { return "", ErrDisabled } return t.desc, nil }
go
func Status(failpath string) (string, error) { failpointsMu.RLock() fp := failpoints[failpath] failpointsMu.RUnlock() if fp == nil { return "", ErrNoExist } fp.mu.RLock() t := fp.t fp.mu.RUnlock() if t == nil { return "", ErrDisabled } return t.desc, nil }
[ "func", "Status", "(", "failpath", "string", ")", "(", "string", ",", "error", ")", "{", "failpointsMu", ".", "RLock", "(", ")", "\n", "fp", ":=", "failpoints", "[", "failpath", "]", "\n", "failpointsMu", ".", "RUnlock", "(", ")", "\n", "if", "fp", "...
// Status gives the current setting for the failpoint
[ "Status", "gives", "the", "current", "setting", "for", "the", "failpoint" ]
51ce9a71510a58bad5ae66ddd278ef28762a1550
https://github.com/etcd-io/gofail/blob/51ce9a71510a58bad5ae66ddd278ef28762a1550/runtime/runtime.go#L100-L114
22,757
etcd-io/gofail
code/binding.go
Write
func (b *Binding) Write(dst io.Writer) error { hdr := "// GENERATED BY GOFAIL. DO NOT EDIT.\n\n" + "package " + b.pkg + "\n\nimport \"github.com/etcd-io/gofail/runtime\"\n\n" if _, err := fmt.Fprint(dst, hdr); err != nil { return err } for _, fp := range b.fps { _, err := fmt.Fprintf( dst, "var %s *ru...
go
func (b *Binding) Write(dst io.Writer) error { hdr := "// GENERATED BY GOFAIL. DO NOT EDIT.\n\n" + "package " + b.pkg + "\n\nimport \"github.com/etcd-io/gofail/runtime\"\n\n" if _, err := fmt.Fprint(dst, hdr); err != nil { return err } for _, fp := range b.fps { _, err := fmt.Fprintf( dst, "var %s *ru...
[ "func", "(", "b", "*", "Binding", ")", "Write", "(", "dst", "io", ".", "Writer", ")", "error", "{", "hdr", ":=", "\"", "\\n", "\\n", "\"", "+", "\"", "\"", "+", "b", ".", "pkg", "+", "\"", "\\n", "\\n", "\\\"", "\\\"", "\\n", "\\n", "\"", "\n...
// Write writes the fp.generated.go file for a package.
[ "Write", "writes", "the", "fp", ".", "generated", ".", "go", "file", "for", "a", "package", "." ]
51ce9a71510a58bad5ae66ddd278ef28762a1550
https://github.com/etcd-io/gofail/blob/51ce9a71510a58bad5ae66ddd278ef28762a1550/code/binding.go#L33-L52
22,758
rjeczalik/notify
watcher_fen.go
Init
func (f *fen) Init() (err error) { f.p, err = f.cf.portCreate() return }
go
func (f *fen) Init() (err error) { f.p, err = f.cf.portCreate() return }
[ "func", "(", "f", "*", "fen", ")", "Init", "(", ")", "(", "err", "error", ")", "{", "f", ".", "p", ",", "err", "=", "f", ".", "cf", ".", "portCreate", "(", ")", "\n", "return", "\n", "}" ]
// init initializes FEN.
[ "init", "initializes", "FEN", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_fen.go#L87-L90
22,759
rjeczalik/notify
watchpoint.go
Add
func (wp watchpoint) Add(c chan<- EventInfo, e Event) (diff eventDiff) { wp[c] |= e diff[0] = wp[nil] diff[1] = diff[0] | e wp[nil] = diff[1] &^ omit // Strip diff from internal events. diff[0] &^= internal diff[1] &^= internal if diff[0] == diff[1] { return none } return }
go
func (wp watchpoint) Add(c chan<- EventInfo, e Event) (diff eventDiff) { wp[c] |= e diff[0] = wp[nil] diff[1] = diff[0] | e wp[nil] = diff[1] &^ omit // Strip diff from internal events. diff[0] &^= internal diff[1] &^= internal if diff[0] == diff[1] { return none } return }
[ "func", "(", "wp", "watchpoint", ")", "Add", "(", "c", "chan", "<-", "EventInfo", ",", "e", "Event", ")", "(", "diff", "eventDiff", ")", "{", "wp", "[", "c", "]", "|=", "e", "\n", "diff", "[", "0", "]", "=", "wp", "[", "nil", "]", "\n", "diff...
// Add assumes neither c nor e are nil or zero values.
[ "Add", "assumes", "neither", "c", "nor", "e", "are", "nil", "or", "zero", "values", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watchpoint.go#L44-L56
22,760
rjeczalik/notify
watcher_readdcw.go
readDirChanges
func (g *grip) readDirChanges() error { handle := syscall.Handle(atomic.LoadUintptr((*uintptr)(&g.handle))) if handle == syscall.InvalidHandle { return nil // Handle was closed. } return syscall.ReadDirectoryChanges( handle, &g.buffer[0], uint32(unsafe.Sizeof(g.buffer)), g.recursive, encode(g.filter), ...
go
func (g *grip) readDirChanges() error { handle := syscall.Handle(atomic.LoadUintptr((*uintptr)(&g.handle))) if handle == syscall.InvalidHandle { return nil // Handle was closed. } return syscall.ReadDirectoryChanges( handle, &g.buffer[0], uint32(unsafe.Sizeof(g.buffer)), g.recursive, encode(g.filter), ...
[ "func", "(", "g", "*", "grip", ")", "readDirChanges", "(", ")", "error", "{", "handle", ":=", "syscall", ".", "Handle", "(", "atomic", ".", "LoadUintptr", "(", "(", "*", "uintptr", ")", "(", "&", "g", ".", "handle", ")", ")", ")", "\n", "if", "ha...
// readDirChanges tells the system to store file change information in grip's // buffer. Directory changes that occur between calls to this function are added // to the buffer and then, returned with the next call.
[ "readDirChanges", "tells", "the", "system", "to", "store", "file", "change", "information", "in", "grip", "s", "buffer", ".", "Directory", "changes", "that", "occur", "between", "calls", "to", "this", "function", "are", "added", "to", "the", "buffer", "and", ...
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_readdcw.go#L111-L127
22,761
rjeczalik/notify
watcher_readdcw.go
encode
func encode(filter uint32) uint32 { e := Event(filter & (onlyNGlobalEvents | onlyNotifyChanges)) if e&dirmarker != 0 { return uint32(FileNotifyChangeDirName) } if e&Create != 0 { e = (e ^ Create) | FileNotifyChangeFileName } if e&Remove != 0 { e = (e ^ Remove) | FileNotifyChangeFileName } if e&Write != 0 ...
go
func encode(filter uint32) uint32 { e := Event(filter & (onlyNGlobalEvents | onlyNotifyChanges)) if e&dirmarker != 0 { return uint32(FileNotifyChangeDirName) } if e&Create != 0 { e = (e ^ Create) | FileNotifyChangeFileName } if e&Remove != 0 { e = (e ^ Remove) | FileNotifyChangeFileName } if e&Write != 0 ...
[ "func", "encode", "(", "filter", "uint32", ")", "uint32", "{", "e", ":=", "Event", "(", "filter", "&", "(", "onlyNGlobalEvents", "|", "onlyNotifyChanges", ")", ")", "\n", "if", "e", "&", "dirmarker", "!=", "0", "{", "return", "uint32", "(", "FileNotifyCh...
// encode transforms a generic filter, which contains platform independent and // implementation specific bit fields, to value that can be used as NotifyFilter // parameter in ReadDirectoryChangesW function.
[ "encode", "transforms", "a", "generic", "filter", "which", "contains", "platform", "independent", "and", "implementation", "specific", "bit", "fields", "to", "value", "that", "can", "be", "used", "as", "NotifyFilter", "parameter", "in", "ReadDirectoryChangesW", "fun...
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_readdcw.go#L132-L151
22,762
rjeczalik/notify
watcher_readdcw.go
closeHandle
func (wd *watched) closeHandle() (err error) { for _, g := range wd.digrip { if g == nil { continue } for { handle := syscall.Handle(atomic.LoadUintptr((*uintptr)(&g.handle))) if handle == syscall.InvalidHandle { break // Already closed. } e := syscall.CloseHandle(handle) if e != nil && e...
go
func (wd *watched) closeHandle() (err error) { for _, g := range wd.digrip { if g == nil { continue } for { handle := syscall.Handle(atomic.LoadUintptr((*uintptr)(&g.handle))) if handle == syscall.InvalidHandle { break // Already closed. } e := syscall.CloseHandle(handle) if e != nil && e...
[ "func", "(", "wd", "*", "watched", ")", "closeHandle", "(", ")", "(", "err", "error", ")", "{", "for", "_", ",", "g", ":=", "range", "wd", ".", "digrip", "{", "if", "g", "==", "nil", "{", "continue", "\n", "}", "\n\n", "for", "{", "handle", ":=...
// closeHandle closes handles that are stored in digrip array. Function always // tries to close all of the handlers before it exits, even when there are errors // returned from the operating system kernel.
[ "closeHandle", "closes", "handles", "that", "are", "stored", "in", "digrip", "array", ".", "Function", "always", "tries", "to", "close", "all", "of", "the", "handlers", "before", "it", "exits", "even", "when", "there", "are", "errors", "returned", "from", "t...
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_readdcw.go#L226-L253
22,763
rjeczalik/notify
watcher_readdcw.go
newWatcher
func newWatcher(c chan<- EventInfo) watcher { r := &readdcw{ m: make(map[string]*watched), cph: syscall.InvalidHandle, c: c, } runtime.SetFinalizer(r, func(r *readdcw) { if r.cph != syscall.InvalidHandle { syscall.CloseHandle(r.cph) } }) return r }
go
func newWatcher(c chan<- EventInfo) watcher { r := &readdcw{ m: make(map[string]*watched), cph: syscall.InvalidHandle, c: c, } runtime.SetFinalizer(r, func(r *readdcw) { if r.cph != syscall.InvalidHandle { syscall.CloseHandle(r.cph) } }) return r }
[ "func", "newWatcher", "(", "c", "chan", "<-", "EventInfo", ")", "watcher", "{", "r", ":=", "&", "readdcw", "{", "m", ":", "make", "(", "map", "[", "string", "]", "*", "watched", ")", ",", "cph", ":", "syscall", ".", "InvalidHandle", ",", "c", ":", ...
// NewWatcher creates new non-recursive watcher backed by ReadDirectoryChangesW.
[ "NewWatcher", "creates", "new", "non", "-", "recursive", "watcher", "backed", "by", "ReadDirectoryChangesW", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_readdcw.go#L268-L280
22,764
rjeczalik/notify
watcher_readdcw.go
Watch
func (r *readdcw) Watch(path string, event Event) error { return r.watch(path, event, false) }
go
func (r *readdcw) Watch(path string, event Event) error { return r.watch(path, event, false) }
[ "func", "(", "r", "*", "readdcw", ")", "Watch", "(", "path", "string", ",", "event", "Event", ")", "error", "{", "return", "r", ".", "watch", "(", "path", ",", "event", ",", "false", ")", "\n", "}" ]
// Watch implements notify.Watcher interface.
[ "Watch", "implements", "notify", ".", "Watcher", "interface", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_readdcw.go#L283-L285
22,765
rjeczalik/notify
watcher_readdcw.go
RecursiveWatch
func (r *readdcw) RecursiveWatch(path string, event Event) error { return r.watch(path, event, true) }
go
func (r *readdcw) RecursiveWatch(path string, event Event) error { return r.watch(path, event, true) }
[ "func", "(", "r", "*", "readdcw", ")", "RecursiveWatch", "(", "path", "string", ",", "event", "Event", ")", "error", "{", "return", "r", ".", "watch", "(", "path", ",", "event", ",", "true", ")", "\n", "}" ]
// RecursiveWatch implements notify.RecursiveWatcher interface.
[ "RecursiveWatch", "implements", "notify", ".", "RecursiveWatcher", "interface", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_readdcw.go#L288-L290
22,766
rjeczalik/notify
watcher_readdcw.go
Rewatch
func (r *readdcw) Rewatch(path string, oldevent, newevent Event) error { return r.rewatch(path, uint32(oldevent), uint32(newevent), false) }
go
func (r *readdcw) Rewatch(path string, oldevent, newevent Event) error { return r.rewatch(path, uint32(oldevent), uint32(newevent), false) }
[ "func", "(", "r", "*", "readdcw", ")", "Rewatch", "(", "path", "string", ",", "oldevent", ",", "newevent", "Event", ")", "error", "{", "return", "r", ".", "rewatch", "(", "path", ",", "uint32", "(", "oldevent", ")", ",", "uint32", "(", "newevent", ")...
// Rewatch implements notify.Rewatcher interface.
[ "Rewatch", "implements", "notify", ".", "Rewatcher", "interface", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_readdcw.go#L451-L453
22,767
rjeczalik/notify
watcher_readdcw.go
RecursiveRewatch
func (r *readdcw) RecursiveRewatch(oldpath, newpath string, oldevent, newevent Event) error { if oldpath != newpath { if err := r.unwatch(oldpath); err != nil { return err } return r.watch(newpath, newevent, true) } return r.rewatch(newpath, uint32(oldevent), uint32(newevent), true) }
go
func (r *readdcw) RecursiveRewatch(oldpath, newpath string, oldevent, newevent Event) error { if oldpath != newpath { if err := r.unwatch(oldpath); err != nil { return err } return r.watch(newpath, newevent, true) } return r.rewatch(newpath, uint32(oldevent), uint32(newevent), true) }
[ "func", "(", "r", "*", "readdcw", ")", "RecursiveRewatch", "(", "oldpath", ",", "newpath", "string", ",", "oldevent", ",", "newevent", "Event", ")", "error", "{", "if", "oldpath", "!=", "newpath", "{", "if", "err", ":=", "r", ".", "unwatch", "(", "oldp...
// RecursiveRewatch implements notify.RecursiveRewatcher interface.
[ "RecursiveRewatch", "implements", "notify", ".", "RecursiveRewatcher", "interface", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_readdcw.go#L456-L465
22,768
rjeczalik/notify
watcher_readdcw.go
Close
func (r *readdcw) Close() (err error) { r.Lock() if !r.start { r.Unlock() return nil } for _, wd := range r.m { wd.filter &^= onlyMachineStates wd.filter |= stateCPClose if e := wd.closeHandle(); e != nil && err == nil { err = e } } r.start = false r.Unlock() r.wg.Add(1) if e := syscall.PostQueu...
go
func (r *readdcw) Close() (err error) { r.Lock() if !r.start { r.Unlock() return nil } for _, wd := range r.m { wd.filter &^= onlyMachineStates wd.filter |= stateCPClose if e := wd.closeHandle(); e != nil && err == nil { err = e } } r.start = false r.Unlock() r.wg.Add(1) if e := syscall.PostQueu...
[ "func", "(", "r", "*", "readdcw", ")", "Close", "(", ")", "(", "err", "error", ")", "{", "r", ".", "Lock", "(", ")", "\n", "if", "!", "r", ".", "start", "{", "r", ".", "Unlock", "(", ")", "\n", "return", "nil", "\n", "}", "\n", "for", "_", ...
// Close resets the whole watcher object, closes all existing file descriptors, // and sends stateCPClose state as completion key to the main watcher's loop.
[ "Close", "resets", "the", "whole", "watcher", "object", "closes", "all", "existing", "file", "descriptors", "and", "sends", "stateCPClose", "state", "as", "completion", "key", "to", "the", "main", "watcher", "s", "loop", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_readdcw.go#L547-L568
22,769
rjeczalik/notify
watcher_readdcw.go
gensys
func gensys(filter uint32, ge, se Event) (gene, syse Event) { isdir := filter&uint32(dirmarker) != 0 if isdir && filter&uint32(FileNotifyChangeDirName) != 0 || !isdir && filter&uint32(FileNotifyChangeFileName) != 0 || filter&uint32(fileNotifyChangeModified) != 0 { syse = se } if filter&uint32(ge) != 0 { gen...
go
func gensys(filter uint32, ge, se Event) (gene, syse Event) { isdir := filter&uint32(dirmarker) != 0 if isdir && filter&uint32(FileNotifyChangeDirName) != 0 || !isdir && filter&uint32(FileNotifyChangeFileName) != 0 || filter&uint32(fileNotifyChangeModified) != 0 { syse = se } if filter&uint32(ge) != 0 { gen...
[ "func", "gensys", "(", "filter", "uint32", ",", "ge", ",", "se", "Event", ")", "(", "gene", ",", "syse", "Event", ")", "{", "isdir", ":=", "filter", "&", "uint32", "(", "dirmarker", ")", "!=", "0", "\n", "if", "isdir", "&&", "filter", "&", "uint32"...
// gensys decides whether the Windows action, system-independent event or both // of them should be returned. Since the grip's filter may be atomically changed // during watcher lifetime, it is possible that neither Windows nor notify masks // are watched by the user when this function is called.
[ "gensys", "decides", "whether", "the", "Windows", "action", "system", "-", "independent", "event", "or", "both", "of", "them", "should", "be", "returned", ".", "Since", "the", "grip", "s", "filter", "may", "be", "atomically", "changed", "during", "watcher", ...
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_readdcw.go#L594-L605
22,770
rjeczalik/notify
watcher_fsevents.go
splitflags
func splitflags(set uint32) (e []uint32) { for i := uint32(1); set != 0; i, set = i<<1, set>>1 { if (set & 1) != 0 { e = append(e, i) } } return }
go
func splitflags(set uint32) (e []uint32) { for i := uint32(1); set != 0; i, set = i<<1, set>>1 { if (set & 1) != 0 { e = append(e, i) } } return }
[ "func", "splitflags", "(", "set", "uint32", ")", "(", "e", "[", "]", "uint32", ")", "{", "for", "i", ":=", "uint32", "(", "1", ")", ";", "set", "!=", "0", ";", "i", ",", "set", "=", "i", "<<", "1", ",", "set", ">>", "1", "{", "if", "(", "...
// splitflags separates event flags from single set into slice of flags.
[ "splitflags", "separates", "event", "flags", "from", "single", "set", "into", "slice", "of", "flags", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_fsevents.go#L30-L37
22,771
rjeczalik/notify
watcher_fsevents.go
Dispatch
func (w *watch) Dispatch(ev []FSEvent) { events := atomic.LoadUint32(&w.events) isrec := (atomic.LoadInt32(&w.isrec) == 1) for i := range ev { if ev[i].Flags&FSEventsHistoryDone != 0 { w.flushed = true continue } if !w.flushed { continue } dbgprintf("%v (0x%x) (%s, i=%d, ID=%d, len=%d)\n", Event(e...
go
func (w *watch) Dispatch(ev []FSEvent) { events := atomic.LoadUint32(&w.events) isrec := (atomic.LoadInt32(&w.isrec) == 1) for i := range ev { if ev[i].Flags&FSEventsHistoryDone != 0 { w.flushed = true continue } if !w.flushed { continue } dbgprintf("%v (0x%x) (%s, i=%d, ID=%d, len=%d)\n", Event(e...
[ "func", "(", "w", "*", "watch", ")", "Dispatch", "(", "ev", "[", "]", "FSEvent", ")", "{", "events", ":=", "atomic", ".", "LoadUint32", "(", "&", "w", ".", "events", ")", "\n", "isrec", ":=", "(", "atomic", ".", "LoadInt32", "(", "&", "w", ".", ...
// Dispatch is a stream function which forwards given file events for the watched // path to underlying FileInfo channel.
[ "Dispatch", "is", "a", "stream", "function", "which", "forwards", "given", "file", "events", "for", "the", "watched", "path", "to", "underlying", "FileInfo", "channel", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_fsevents.go#L119-L163
22,772
rjeczalik/notify
watcher_fsevents.go
Stop
func (w *watch) Stop() { w.stream.Stop() // TODO(rjeczalik): make (*stream).Stop flush synchronously undelivered events, // so the following hack can be removed. It should flush all the streams // concurrently as we care not to block too much here. atomic.StoreUint32(&w.events, 0) atomic.StoreInt32(&w.isrec, 0) }
go
func (w *watch) Stop() { w.stream.Stop() // TODO(rjeczalik): make (*stream).Stop flush synchronously undelivered events, // so the following hack can be removed. It should flush all the streams // concurrently as we care not to block too much here. atomic.StoreUint32(&w.events, 0) atomic.StoreInt32(&w.isrec, 0) }
[ "func", "(", "w", "*", "watch", ")", "Stop", "(", ")", "{", "w", ".", "stream", ".", "Stop", "(", ")", "\n", "// TODO(rjeczalik): make (*stream).Stop flush synchronously undelivered events,", "// so the following hack can be removed. It should flush all the streams", "// conc...
// Stop closes underlying FSEvents stream and stops dispatching events.
[ "Stop", "closes", "underlying", "FSEvents", "stream", "and", "stops", "dispatching", "events", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_fsevents.go#L166-L173
22,773
rjeczalik/notify
watcher_fsevents.go
Watch
func (fse *fsevents) Watch(path string, event Event) error { return fse.watch(path, event, 0) }
go
func (fse *fsevents) Watch(path string, event Event) error { return fse.watch(path, event, 0) }
[ "func", "(", "fse", "*", "fsevents", ")", "Watch", "(", "path", "string", ",", "event", "Event", ")", "error", "{", "return", "fse", ".", "watch", "(", "path", ",", "event", ",", "0", ")", "\n", "}" ]
// Watch implements Watcher interface. It fails with non-nil error when setting // the watch-point by FSEvents fails or with errAlreadyWatched error when // the given path is already watched.
[ "Watch", "implements", "Watcher", "interface", ".", "It", "fails", "with", "non", "-", "nil", "error", "when", "setting", "the", "watch", "-", "point", "by", "FSEvents", "fails", "or", "with", "errAlreadyWatched", "error", "when", "the", "given", "path", "is...
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_fsevents.go#L221-L223
22,774
rjeczalik/notify
watcher_fsevents.go
Rewatch
func (fse *fsevents) Rewatch(path string, oldevent, newevent Event) error { w, ok := fse.watches[path] if !ok { return errNotWatched } if !atomic.CompareAndSwapUint32(&w.events, uint32(oldevent), uint32(newevent)) { return errInvalidEventSet } atomic.StoreInt32(&w.isrec, 0) return nil }
go
func (fse *fsevents) Rewatch(path string, oldevent, newevent Event) error { w, ok := fse.watches[path] if !ok { return errNotWatched } if !atomic.CompareAndSwapUint32(&w.events, uint32(oldevent), uint32(newevent)) { return errInvalidEventSet } atomic.StoreInt32(&w.isrec, 0) return nil }
[ "func", "(", "fse", "*", "fsevents", ")", "Rewatch", "(", "path", "string", ",", "oldevent", ",", "newevent", "Event", ")", "error", "{", "w", ",", "ok", ":=", "fse", ".", "watches", "[", "path", "]", "\n", "if", "!", "ok", "{", "return", "errNotWa...
// Rewatch implements Watcher interface. It fails with errNotWatched when // the given path is not being watched or with errInvalidEventSet when oldevent // does not match event set the watch-point currently holds.
[ "Rewatch", "implements", "Watcher", "interface", ".", "It", "fails", "with", "errNotWatched", "when", "the", "given", "path", "is", "not", "being", "watched", "or", "with", "errInvalidEventSet", "when", "oldevent", "does", "not", "match", "event", "set", "the", ...
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_fsevents.go#L234-L244
22,775
rjeczalik/notify
watcher_fsevents.go
Close
func (fse *fsevents) Close() error { for _, w := range fse.watches { w.Stop() } fse.watches = nil return nil }
go
func (fse *fsevents) Close() error { for _, w := range fse.watches { w.Stop() } fse.watches = nil return nil }
[ "func", "(", "fse", "*", "fsevents", ")", "Close", "(", ")", "error", "{", "for", "_", ",", "w", ":=", "range", "fse", ".", "watches", "{", "w", ".", "Stop", "(", ")", "\n", "}", "\n", "fse", ".", "watches", "=", "nil", "\n", "return", "nil", ...
// Close unwatches all watch-points.
[ "Close", "unwatches", "all", "watch", "-", "points", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_fsevents.go#L305-L311
22,776
rjeczalik/notify
watcher_fsevents_cgo.go
init
func init() { wg.Add(1) go func() { // There is exactly one run loop per thread. Lock this goroutine to its // thread to ensure that it's not rescheduled on a different thread while // setting up the run loop. runtime.LockOSThread() runloop = C.CFRunLoopGetCurrent() C.CFRunLoopAddSource(runloop, source, C...
go
func init() { wg.Add(1) go func() { // There is exactly one run loop per thread. Lock this goroutine to its // thread to ensure that it's not rescheduled on a different thread while // setting up the run loop. runtime.LockOSThread() runloop = C.CFRunLoopGetCurrent() C.CFRunLoopAddSource(runloop, source, C...
[ "func", "init", "(", ")", "{", "wg", ".", "Add", "(", "1", ")", "\n", "go", "func", "(", ")", "{", "// There is exactly one run loop per thread. Lock this goroutine to its", "// thread to ensure that it's not rescheduled on a different thread while", "// setting up the run loop...
// initializes the global runloop and ensures any created stream awaits its // readiness.
[ "initializes", "the", "global", "runloop", "and", "ensures", "any", "created", "stream", "awaits", "its", "readiness", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_fsevents_cgo.go#L63-L76
22,777
rjeczalik/notify
watcher_fsevents_cgo.go
newStream
func newStream(path string, fn streamFunc) *stream { return &stream{ path: path, info: streamFuncs.add(fn), } }
go
func newStream(path string, fn streamFunc) *stream { return &stream{ path: path, info: streamFuncs.add(fn), } }
[ "func", "newStream", "(", "path", "string", ",", "fn", "streamFunc", ")", "*", "stream", "{", "return", "&", "stream", "{", "path", ":", "path", ",", "info", ":", "streamFuncs", ".", "add", "(", "fn", ")", ",", "}", "\n", "}" ]
// NewStream creates a stream for given path, listening for file events and // calling fn upon receiving any.
[ "NewStream", "creates", "a", "stream", "for", "given", "path", "listening", "for", "file", "events", "and", "calling", "fn", "upon", "receiving", "any", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_fsevents_cgo.go#L155-L160
22,778
rjeczalik/notify
watcher_fsevents_cgo.go
Start
func (s *stream) Start() error { if s.ref != nilstream { return nil } wg.Wait() p := C.CFStringCreateWithCStringNoCopy(C.kCFAllocatorDefault, C.CString(s.path), C.kCFStringEncodingUTF8, C.kCFAllocatorDefault) path := C.CFArrayCreate(C.kCFAllocatorDefault, (*unsafe.Pointer)(unsafe.Pointer(&p)), 1, nil) ctx := C....
go
func (s *stream) Start() error { if s.ref != nilstream { return nil } wg.Wait() p := C.CFStringCreateWithCStringNoCopy(C.kCFAllocatorDefault, C.CString(s.path), C.kCFStringEncodingUTF8, C.kCFAllocatorDefault) path := C.CFArrayCreate(C.kCFAllocatorDefault, (*unsafe.Pointer)(unsafe.Pointer(&p)), 1, nil) ctx := C....
[ "func", "(", "s", "*", "stream", ")", "Start", "(", ")", "error", "{", "if", "s", ".", "ref", "!=", "nilstream", "{", "return", "nil", "\n", "}", "\n", "wg", ".", "Wait", "(", ")", "\n", "p", ":=", "C", ".", "CFStringCreateWithCStringNoCopy", "(", ...
// Start creates a FSEventStream for the given path and schedules it with // global runloop. It's a nop if the stream was already started.
[ "Start", "creates", "a", "FSEventStream", "for", "the", "given", "path", "and", "schedules", "it", "with", "global", "runloop", ".", "It", "s", "a", "nop", "if", "the", "stream", "was", "already", "started", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_fsevents_cgo.go#L164-L184
22,779
rjeczalik/notify
watcher_fsevents_cgo.go
Stop
func (s *stream) Stop() { if s.ref == nilstream { return } wg.Wait() C.FSEventStreamStop(s.ref) C.FSEventStreamInvalidate(s.ref) C.CFRunLoopWakeUp(runloop) s.ref = nilstream streamFuncs.delete(s.info) }
go
func (s *stream) Stop() { if s.ref == nilstream { return } wg.Wait() C.FSEventStreamStop(s.ref) C.FSEventStreamInvalidate(s.ref) C.CFRunLoopWakeUp(runloop) s.ref = nilstream streamFuncs.delete(s.info) }
[ "func", "(", "s", "*", "stream", ")", "Stop", "(", ")", "{", "if", "s", ".", "ref", "==", "nilstream", "{", "return", "\n", "}", "\n", "wg", ".", "Wait", "(", ")", "\n", "C", ".", "FSEventStreamStop", "(", "s", ".", "ref", ")", "\n", "C", "."...
// Stop stops underlying FSEventStream and unregisters it from global runloop.
[ "Stop", "stops", "underlying", "FSEventStream", "and", "unregisters", "it", "from", "global", "runloop", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_fsevents_cgo.go#L187-L197
22,780
rjeczalik/notify
util.go
nonil
func nonil(err ...error) error { for _, err := range err { if err != nil { return err } } return nil }
go
func nonil(err ...error) error { for _, err := range err { if err != nil { return err } } return nil }
[ "func", "nonil", "(", "err", "...", "error", ")", "error", "{", "for", "_", ",", "err", ":=", "range", "err", "{", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// nonil gives first non-nil error from the given arguments.
[ "nonil", "gives", "first", "non", "-", "nil", "error", "from", "the", "given", "arguments", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/util.go#L41-L48
22,781
rjeczalik/notify
util.go
canonical
func canonical(p string) (string, error) { p, err := filepath.Abs(p) if err != nil { return "", err } for i, j, depth := 1, 0, 1; i < len(p); i, depth = i+1, depth+1 { if depth > 128 { return "", &os.PathError{Op: "canonical", Path: p, Err: errDepth} } if j = strings.IndexRune(p[i:], '/'); j == -1 { j...
go
func canonical(p string) (string, error) { p, err := filepath.Abs(p) if err != nil { return "", err } for i, j, depth := 1, 0, 1; i < len(p); i, depth = i+1, depth+1 { if depth > 128 { return "", &os.PathError{Op: "canonical", Path: p, Err: errDepth} } if j = strings.IndexRune(p[i:], '/'); j == -1 { j...
[ "func", "canonical", "(", "p", "string", ")", "(", "string", ",", "error", ")", "{", "p", ",", "err", ":=", "filepath", ".", "Abs", "(", "p", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "for", ...
// canonical resolves any symlink in the given path and returns it in a clean form. // It expects the path to be absolute. It fails to resolve circular symlinks by // maintaining a simple iteration limit.
[ "canonical", "resolves", "any", "symlink", "in", "the", "given", "path", "and", "returns", "it", "in", "a", "clean", "form", ".", "It", "expects", "the", "path", "to", "be", "absolute", ".", "It", "fails", "to", "resolve", "circular", "symlinks", "by", "...
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/util.go#L67-L99
22,782
rjeczalik/notify
watcher_trigger.go
newWatcher
func newWatcher(c chan<- EventInfo) watcher { t := &trg{ s: make(chan struct{}, 1), pthLkp: make(map[string]*watched, 0), c: c, } t.t = newTrigger(t.pthLkp) if err := t.t.Init(); err != nil { t.Close() return watcherStub{fmt.Errorf("failed setting up watcher: %v", err)} } go t.monitor() retur...
go
func newWatcher(c chan<- EventInfo) watcher { t := &trg{ s: make(chan struct{}, 1), pthLkp: make(map[string]*watched, 0), c: c, } t.t = newTrigger(t.pthLkp) if err := t.t.Init(); err != nil { t.Close() return watcherStub{fmt.Errorf("failed setting up watcher: %v", err)} } go t.monitor() retur...
[ "func", "newWatcher", "(", "c", "chan", "<-", "EventInfo", ")", "watcher", "{", "t", ":=", "&", "trg", "{", "s", ":", "make", "(", "chan", "struct", "{", "}", ",", "1", ")", ",", "pthLkp", ":", "make", "(", "map", "[", "string", "]", "*", "watc...
// newWatcher returns new watcher's implementation.
[ "newWatcher", "returns", "new", "watcher", "s", "implementation", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_trigger.go#L101-L114
22,783
rjeczalik/notify
watcher_trigger.go
Close
func (t *trg) Close() (err error) { t.Lock() if err = t.t.Stop(); err != nil { t.Unlock() return } <-t.s var e error for _, w := range t.pthLkp { if e = t.unwatch(w.p, w.fi); e != nil { dbgprintf("trg: unwatch %q failed: %q\n", w.p, e) err = nonil(err, e) } } if e = t.t.Close(); e != nil { dbgpr...
go
func (t *trg) Close() (err error) { t.Lock() if err = t.t.Stop(); err != nil { t.Unlock() return } <-t.s var e error for _, w := range t.pthLkp { if e = t.unwatch(w.p, w.fi); e != nil { dbgprintf("trg: unwatch %q failed: %q\n", w.p, e) err = nonil(err, e) } } if e = t.t.Close(); e != nil { dbgpr...
[ "func", "(", "t", "*", "trg", ")", "Close", "(", ")", "(", "err", "error", ")", "{", "t", ".", "Lock", "(", ")", "\n", "if", "err", "=", "t", ".", "t", ".", "Stop", "(", ")", ";", "err", "!=", "nil", "{", "t", ".", "Unlock", "(", ")", "...
// Close implements watcher.
[ "Close", "implements", "watcher", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_trigger.go#L117-L140
22,784
rjeczalik/notify
watcher_trigger.go
send
func (t *trg) send(evn []event) { for i := range evn { t.c <- &evn[i] } }
go
func (t *trg) send(evn []event) { for i := range evn { t.c <- &evn[i] } }
[ "func", "(", "t", "*", "trg", ")", "send", "(", "evn", "[", "]", "event", ")", "{", "for", "i", ":=", "range", "evn", "{", "t", ".", "c", "<-", "&", "evn", "[", "i", "]", "\n", "}", "\n", "}" ]
// send reported events one by one through chan.
[ "send", "reported", "events", "one", "by", "one", "through", "chan", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_trigger.go#L143-L147
22,785
rjeczalik/notify
watcher_trigger.go
Watch
func (t *trg) Watch(p string, e Event) error { fi, err := os.Stat(p) if err != nil { return err } t.Lock() err = t.watch(p, e, fi) t.Unlock() return err }
go
func (t *trg) Watch(p string, e Event) error { fi, err := os.Stat(p) if err != nil { return err } t.Lock() err = t.watch(p, e, fi) t.Unlock() return err }
[ "func", "(", "t", "*", "trg", ")", "Watch", "(", "p", "string", ",", "e", "Event", ")", "error", "{", "fi", ",", "err", ":=", "os", ".", "Stat", "(", "p", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "t", ".",...
// Watch implements Watcher interface.
[ "Watch", "implements", "Watcher", "interface", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_trigger.go#L252-L261
22,786
rjeczalik/notify
watcher_trigger.go
Unwatch
func (t *trg) Unwatch(p string) error { fi, err := os.Stat(p) if err != nil { return err } t.Lock() err = t.unwatch(p, fi) t.Unlock() return err }
go
func (t *trg) Unwatch(p string) error { fi, err := os.Stat(p) if err != nil { return err } t.Lock() err = t.unwatch(p, fi) t.Unlock() return err }
[ "func", "(", "t", "*", "trg", ")", "Unwatch", "(", "p", "string", ")", "error", "{", "fi", ",", "err", ":=", "os", ".", "Stat", "(", "p", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "t", ".", "Lock", "(", ")"...
// Unwatch implements Watcher interface.
[ "Unwatch", "implements", "Watcher", "interface", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_trigger.go#L264-L273
22,787
rjeczalik/notify
watcher_trigger.go
process
func (t *trg) process(n interface{}) (evn []event) { t.Lock() w, ge, err := t.t.Watched(n) if err != nil { t.Unlock() dbgprintf("trg: %v event lookup failed: %q", Event(ge), err) return } e := decode(ge, w.eDir|w.eNonDir) if ge&int64(not2nat[Remove]|not2nat[Rename]) == 0 { switch fi, err := os.Stat(w.p);...
go
func (t *trg) process(n interface{}) (evn []event) { t.Lock() w, ge, err := t.t.Watched(n) if err != nil { t.Unlock() dbgprintf("trg: %v event lookup failed: %q", Event(ge), err) return } e := decode(ge, w.eDir|w.eNonDir) if ge&int64(not2nat[Remove]|not2nat[Rename]) == 0 { switch fi, err := os.Stat(w.p);...
[ "func", "(", "t", "*", "trg", ")", "process", "(", "n", "interface", "{", "}", ")", "(", "evn", "[", "]", "event", ")", "{", "t", ".", "Lock", "(", ")", "\n", "w", ",", "ge", ",", "err", ":=", "t", ".", "t", ".", "Watched", "(", "n", ")",...
// process event returned by native call.
[ "process", "event", "returned", "by", "native", "call", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_trigger.go#L415-L450
22,788
rjeczalik/notify
watcher_inotify.go
newWatcher
func newWatcher(c chan<- EventInfo) watcher { i := &inotify{ m: make(map[int32]*watched), fd: invalidDescriptor, pipefd: []int{invalidDescriptor, invalidDescriptor}, epfd: invalidDescriptor, epes: make([]unix.EpollEvent, 0), c: c, } runtime.SetFinalizer(i, func(i *inotify) { i.epollcl...
go
func newWatcher(c chan<- EventInfo) watcher { i := &inotify{ m: make(map[int32]*watched), fd: invalidDescriptor, pipefd: []int{invalidDescriptor, invalidDescriptor}, epfd: invalidDescriptor, epes: make([]unix.EpollEvent, 0), c: c, } runtime.SetFinalizer(i, func(i *inotify) { i.epollcl...
[ "func", "newWatcher", "(", "c", "chan", "<-", "EventInfo", ")", "watcher", "{", "i", ":=", "&", "inotify", "{", "m", ":", "make", "(", "map", "[", "int32", "]", "*", "watched", ")", ",", "fd", ":", "invalidDescriptor", ",", "pipefd", ":", "[", "]",...
// NewWatcher creates new non-recursive inotify backed by inotify.
[ "NewWatcher", "creates", "new", "non", "-", "recursive", "inotify", "backed", "by", "inotify", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_inotify.go#L54-L70
22,789
rjeczalik/notify
watcher_inotify.go
Watch
func (i *inotify) Watch(path string, e Event) error { return i.watch(path, e) }
go
func (i *inotify) Watch(path string, e Event) error { return i.watch(path, e) }
[ "func", "(", "i", "*", "inotify", ")", "Watch", "(", "path", "string", ",", "e", "Event", ")", "error", "{", "return", "i", ".", "watch", "(", "path", ",", "e", ")", "\n", "}" ]
// Watch implements notify.watcher interface.
[ "Watch", "implements", "notify", ".", "watcher", "interface", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_inotify.go#L73-L75
22,790
rjeczalik/notify
watcher_inotify.go
Rewatch
func (i *inotify) Rewatch(path string, _, newevent Event) error { return i.watch(path, newevent) }
go
func (i *inotify) Rewatch(path string, _, newevent Event) error { return i.watch(path, newevent) }
[ "func", "(", "i", "*", "inotify", ")", "Rewatch", "(", "path", "string", ",", "_", ",", "newevent", "Event", ")", "error", "{", "return", "i", ".", "watch", "(", "path", ",", "newevent", ")", "\n", "}" ]
// Rewatch implements notify.watcher interface.
[ "Rewatch", "implements", "notify", ".", "watcher", "interface", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_inotify.go#L78-L80
22,791
rjeczalik/notify
watcher_inotify.go
watch
func (i *inotify) watch(path string, e Event) (err error) { if e&^(All|Event(unix.IN_ALL_EVENTS)) != 0 { return errors.New("notify: unknown event") } if err = i.lazyinit(); err != nil { return } iwd, err := unix.InotifyAddWatch(int(i.fd), path, encode(e)) if err != nil { return } i.RLock() wd := i.m[int3...
go
func (i *inotify) watch(path string, e Event) (err error) { if e&^(All|Event(unix.IN_ALL_EVENTS)) != 0 { return errors.New("notify: unknown event") } if err = i.lazyinit(); err != nil { return } iwd, err := unix.InotifyAddWatch(int(i.fd), path, encode(e)) if err != nil { return } i.RLock() wd := i.m[int3...
[ "func", "(", "i", "*", "inotify", ")", "watch", "(", "path", "string", ",", "e", "Event", ")", "(", "err", "error", ")", "{", "if", "e", "&^", "(", "All", "|", "Event", "(", "unix", ".", "IN_ALL_EVENTS", ")", ")", "!=", "0", "{", "return", "err...
// watch adds a new watcher to the set of watched objects or modifies the existing // one. If called for the first time, this function initializes inotify filesystem // monitor and starts producer-consumers goroutines.
[ "watch", "adds", "a", "new", "watcher", "to", "the", "set", "of", "watched", "objects", "or", "modifies", "the", "existing", "one", ".", "If", "called", "for", "the", "first", "time", "this", "function", "initializes", "inotify", "filesystem", "monitor", "an...
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_inotify.go#L85-L111
22,792
rjeczalik/notify
watcher_inotify.go
lazyinit
func (i *inotify) lazyinit() error { if atomic.LoadInt32(&i.fd) == invalidDescriptor { i.Lock() defer i.Unlock() if atomic.LoadInt32(&i.fd) == invalidDescriptor { fd, err := unix.InotifyInit1(unix.IN_CLOEXEC) if err != nil { return err } i.fd = int32(fd) if err = i.epollinit(); err != nil { ...
go
func (i *inotify) lazyinit() error { if atomic.LoadInt32(&i.fd) == invalidDescriptor { i.Lock() defer i.Unlock() if atomic.LoadInt32(&i.fd) == invalidDescriptor { fd, err := unix.InotifyInit1(unix.IN_CLOEXEC) if err != nil { return err } i.fd = int32(fd) if err = i.epollinit(); err != nil { ...
[ "func", "(", "i", "*", "inotify", ")", "lazyinit", "(", ")", "error", "{", "if", "atomic", ".", "LoadInt32", "(", "&", "i", ".", "fd", ")", "==", "invalidDescriptor", "{", "i", ".", "Lock", "(", ")", "\n", "defer", "i", ".", "Unlock", "(", ")", ...
// lazyinit sets up all required file descriptors and starts 1+consumersCount // goroutines. The producer goroutine blocks until file-system notifications // occur. Then, all events are read from system buffer and sent to consumer // goroutines which construct valid notify events. This method uses // Double-Checked Loc...
[ "lazyinit", "sets", "up", "all", "required", "file", "descriptors", "and", "starts", "1", "+", "consumersCount", "goroutines", ".", "The", "producer", "goroutine", "blocks", "until", "file", "-", "system", "notifications", "occur", ".", "Then", "all", "events", ...
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_inotify.go#L118-L142
22,793
rjeczalik/notify
watcher_inotify.go
send
func (i *inotify) send(esch <-chan []*event) { for es := range esch { for _, e := range i.transform(es) { if e != nil { i.c <- e } } } i.wg.Done() }
go
func (i *inotify) send(esch <-chan []*event) { for es := range esch { for _, e := range i.transform(es) { if e != nil { i.c <- e } } } i.wg.Done() }
[ "func", "(", "i", "*", "inotify", ")", "send", "(", "esch", "<-", "chan", "[", "]", "*", "event", ")", "{", "for", "es", ":=", "range", "esch", "{", "for", "_", ",", "e", ":=", "range", "i", ".", "transform", "(", "es", ")", "{", "if", "e", ...
// send is a consumer function which sends events to event dispatcher channel. // It is run in a separate goroutine in order to not block loop method when // possibly expensive write operations are performed on inotify map.
[ "send", "is", "a", "consumer", "function", "which", "sends", "events", "to", "event", "dispatcher", "channel", ".", "It", "is", "run", "in", "a", "separate", "goroutine", "in", "order", "to", "not", "block", "loop", "method", "when", "possibly", "expensive",...
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_inotify.go#L253-L262
22,794
rjeczalik/notify
watcher_inotify.go
transform
func (i *inotify) transform(es []*event) []*event { var multi []*event i.RLock() for idx, e := range es { if e.sys.Mask&(unix.IN_IGNORED|unix.IN_Q_OVERFLOW) != 0 { es[idx] = nil continue } wd, ok := i.m[e.sys.Wd] if !ok || e.sys.Mask&encode(Event(wd.mask)) == 0 { es[idx] = nil continue } if e...
go
func (i *inotify) transform(es []*event) []*event { var multi []*event i.RLock() for idx, e := range es { if e.sys.Mask&(unix.IN_IGNORED|unix.IN_Q_OVERFLOW) != 0 { es[idx] = nil continue } wd, ok := i.m[e.sys.Wd] if !ok || e.sys.Mask&encode(Event(wd.mask)) == 0 { es[idx] = nil continue } if e...
[ "func", "(", "i", "*", "inotify", ")", "transform", "(", "es", "[", "]", "*", "event", ")", "[", "]", "*", "event", "{", "var", "multi", "[", "]", "*", "event", "\n", "i", ".", "RLock", "(", ")", "\n", "for", "idx", ",", "e", ":=", "range", ...
// transform prepares events read from inotify file descriptor for sending to // user. It removes invalid events and these which are no longer present in // inotify map. This method may also split one raw event into two different ones // when system-dependent result is required.
[ "transform", "prepares", "events", "read", "from", "inotify", "file", "descriptor", "for", "sending", "to", "user", ".", "It", "removes", "invalid", "events", "and", "these", "which", "are", "no", "longer", "present", "in", "inotify", "map", ".", "This", "me...
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_inotify.go#L268-L294
22,795
rjeczalik/notify
watcher_inotify.go
decode
func decode(mask Event, e *event) (syse *event) { if sysmask := uint32(mask) & e.sys.Mask; sysmask != 0 { syse = &event{sys: unix.InotifyEvent{ Wd: e.sys.Wd, Mask: e.sys.Mask, Cookie: e.sys.Cookie, }, event: Event(sysmask), path: e.path} } imask := encode(mask) switch { case mask&Create != 0 && ...
go
func decode(mask Event, e *event) (syse *event) { if sysmask := uint32(mask) & e.sys.Mask; sysmask != 0 { syse = &event{sys: unix.InotifyEvent{ Wd: e.sys.Wd, Mask: e.sys.Mask, Cookie: e.sys.Cookie, }, event: Event(sysmask), path: e.path} } imask := encode(mask) switch { case mask&Create != 0 && ...
[ "func", "decode", "(", "mask", "Event", ",", "e", "*", "event", ")", "(", "syse", "*", "event", ")", "{", "if", "sysmask", ":=", "uint32", "(", "mask", ")", "&", "e", ".", "sys", ".", "Mask", ";", "sysmask", "!=", "0", "{", "syse", "=", "&", ...
// decode uses internally stored mask to distinguish whether system-independent // or system-dependent event is requested. The first one is created by modifying // `e` argument. decode method sets e.event value to 0 when an event should be // skipped. System-dependent event is set as the function's return value which /...
[ "decode", "uses", "internally", "stored", "mask", "to", "distinguish", "whether", "system", "-", "independent", "or", "system", "-", "dependent", "event", "is", "requested", ".", "The", "first", "one", "is", "created", "by", "modifying", "e", "argument", ".", ...
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_inotify.go#L319-L341
22,796
rjeczalik/notify
watcher_inotify.go
Close
func (i *inotify) Close() (err error) { i.Lock() if fd := atomic.LoadInt32(&i.fd); fd == invalidDescriptor { i.Unlock() return nil } for iwd := range i.m { if e := removeInotifyWatch(i.fd, iwd); e != nil && err == nil { err = e } delete(i.m, iwd) } switch _, errwrite := unix.Write(i.pipefd[1], []byte...
go
func (i *inotify) Close() (err error) { i.Lock() if fd := atomic.LoadInt32(&i.fd); fd == invalidDescriptor { i.Unlock() return nil } for iwd := range i.m { if e := removeInotifyWatch(i.fd, iwd); e != nil && err == nil { err = e } delete(i.m, iwd) } switch _, errwrite := unix.Write(i.pipefd[1], []byte...
[ "func", "(", "i", "*", "inotify", ")", "Close", "(", ")", "(", "err", "error", ")", "{", "i", ".", "Lock", "(", ")", "\n", "if", "fd", ":=", "atomic", ".", "LoadInt32", "(", "&", "i", ".", "fd", ")", ";", "fd", "==", "invalidDescriptor", "{", ...
// Close implements notify.watcher interface. It removes all existing watch // descriptors and wakes up producer goroutine by sending data to the write end // of the pipe. The function waits for a signal from producer which means that // all operations on current monitoring instance are done.
[ "Close", "implements", "notify", ".", "watcher", "interface", ".", "It", "removes", "all", "existing", "watch", "descriptors", "and", "wakes", "up", "producer", "goroutine", "by", "sending", "data", "to", "the", "write", "end", "of", "the", "pipe", ".", "The...
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_inotify.go#L374-L397
22,797
rjeczalik/notify
watcher_inotify.go
removeInotifyWatch
func removeInotifyWatch(fd int32, iwd int32) (err error) { if _, err = unix.InotifyRmWatch(int(fd), uint32(iwd)); err != nil && err != unix.EINVAL { return } return nil }
go
func removeInotifyWatch(fd int32, iwd int32) (err error) { if _, err = unix.InotifyRmWatch(int(fd), uint32(iwd)); err != nil && err != unix.EINVAL { return } return nil }
[ "func", "removeInotifyWatch", "(", "fd", "int32", ",", "iwd", "int32", ")", "(", "err", "error", ")", "{", "if", "_", ",", "err", "=", "unix", ".", "InotifyRmWatch", "(", "int", "(", "fd", ")", ",", "uint32", "(", "iwd", ")", ")", ";", "err", "!=...
// if path was removed, notify already removed the watch and returns EINVAL error
[ "if", "path", "was", "removed", "notify", "already", "removed", "the", "watch", "and", "returns", "EINVAL", "error" ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_inotify.go#L400-L405
22,798
rjeczalik/notify
watcher_kqueue.go
Stop
func (k *kq) Stop() (err error) { // trigger event used to interrupt Kevent call. _, err = syscall.Write(k.pipefds[1], []byte{0x00}) return }
go
func (k *kq) Stop() (err error) { // trigger event used to interrupt Kevent call. _, err = syscall.Write(k.pipefds[1], []byte{0x00}) return }
[ "func", "(", "k", "*", "kq", ")", "Stop", "(", ")", "(", "err", "error", ")", "{", "// trigger event used to interrupt Kevent call.", "_", ",", "err", "=", "syscall", ".", "Write", "(", "k", ".", "pipefds", "[", "1", "]", ",", "[", "]", "byte", "{", ...
// Stop implements trigger.
[ "Stop", "implements", "trigger", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_kqueue.go#L45-L49
22,799
rjeczalik/notify
watcher_kqueue.go
Init
func (k *kq) Init() (err error) { if k.fd, err = syscall.Kqueue(); err != nil { return } // Creates pipe used to stop `Kevent` call by registering it, // watching read end and writing to other end of it. if err = syscall.Pipe(k.pipefds[:]); err != nil { return nonil(err, k.Close()) } var kevn [1]syscall.Keve...
go
func (k *kq) Init() (err error) { if k.fd, err = syscall.Kqueue(); err != nil { return } // Creates pipe used to stop `Kevent` call by registering it, // watching read end and writing to other end of it. if err = syscall.Pipe(k.pipefds[:]); err != nil { return nonil(err, k.Close()) } var kevn [1]syscall.Keve...
[ "func", "(", "k", "*", "kq", ")", "Init", "(", ")", "(", "err", "error", ")", "{", "if", "k", ".", "fd", ",", "err", "=", "syscall", ".", "Kqueue", "(", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "// Creates pipe used to stop `...
// Init implements trigger.
[ "Init", "implements", "trigger", "." ]
629144ba06a1c6af28c1e42c228e3d42594ce081
https://github.com/rjeczalik/notify/blob/629144ba06a1c6af28c1e42c228e3d42594ce081/watcher_kqueue.go#L89-L104