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
146,200
intelsdi-x/snap-plugin-lib-go
v1/plugin/config.go
GetFloat
func (c Config) GetFloat(key string) (float64, error) { var ( fout float64 val interface{} ok bool ) if val, ok = c[key]; !ok { return fout, ErrConfigNotFound } if fout, ok = val.(float64); !ok { return fout, ErrNotAFloat } return fout, nil }
go
func (c Config) GetFloat(key string) (float64, error) { var ( fout float64 val interface{} ok bool ) if val, ok = c[key]; !ok { return fout, ErrConfigNotFound } if fout, ok = val.(float64); !ok { return fout, ErrNotAFloat } return fout, nil }
[ "func", "(", "c", "Config", ")", "GetFloat", "(", "key", "string", ")", "(", "float64", ",", "error", ")", "{", "var", "(", "fout", "float64", "\n", "val", "interface", "{", "}", "\n", "ok", "bool", "\n", ")", "\n\n", "if", "val", ",", "ok", "=",...
// GetFloat takes a given key and checks the config for both // that the key exists, and that it is of type float64. // Returns an error if either of these is false.
[ "GetFloat", "takes", "a", "given", "key", "and", "checks", "the", "config", "for", "both", "that", "the", "key", "exists", "and", "that", "it", "is", "of", "type", "float64", ".", "Returns", "an", "error", "if", "either", "of", "these", "is", "false", ...
2f826c76a182b204f8c0d458e7b76d64fca38062
https://github.com/intelsdi-x/snap-plugin-lib-go/blob/2f826c76a182b204f8c0d458e7b76d64fca38062/v1/plugin/config.go#L74-L90
146,201
intelsdi-x/snap-plugin-lib-go
v1/plugin/config.go
GetInt
func (c Config) GetInt(key string) (int64, error) { var ( iout int64 val interface{} ok bool ) if val, ok = c[key]; !ok { return iout, ErrConfigNotFound } if iout, ok = val.(int64); !ok { return iout, ErrNotAnInt } return iout, nil }
go
func (c Config) GetInt(key string) (int64, error) { var ( iout int64 val interface{} ok bool ) if val, ok = c[key]; !ok { return iout, ErrConfigNotFound } if iout, ok = val.(int64); !ok { return iout, ErrNotAnInt } return iout, nil }
[ "func", "(", "c", "Config", ")", "GetInt", "(", "key", "string", ")", "(", "int64", ",", "error", ")", "{", "var", "(", "iout", "int64", "\n", "val", "interface", "{", "}", "\n", "ok", "bool", "\n", ")", "\n\n", "if", "val", ",", "ok", "=", "c"...
// GetInt takes a given key and checks the config for both // that the key exists, and that it is of type int64. // Returns an error if either of these is false.
[ "GetInt", "takes", "a", "given", "key", "and", "checks", "the", "config", "for", "both", "that", "the", "key", "exists", "and", "that", "it", "is", "of", "type", "int64", ".", "Returns", "an", "error", "if", "either", "of", "these", "is", "false", "." ...
2f826c76a182b204f8c0d458e7b76d64fca38062
https://github.com/intelsdi-x/snap-plugin-lib-go/blob/2f826c76a182b204f8c0d458e7b76d64fca38062/v1/plugin/config.go#L95-L111
146,202
intelsdi-x/snap-plugin-lib-go
v1/plugin/config.go
applyDefaults
func (c Config) applyDefaults(cp ConfigPolicy) { for key, val := range cp.getDefaults() { if _, exist := c[key]; !exist { // set default cfg retrieve from config policy c[key] = val } } }
go
func (c Config) applyDefaults(cp ConfigPolicy) { for key, val := range cp.getDefaults() { if _, exist := c[key]; !exist { // set default cfg retrieve from config policy c[key] = val } } }
[ "func", "(", "c", "Config", ")", "applyDefaults", "(", "cp", "ConfigPolicy", ")", "{", "for", "key", ",", "val", ":=", "range", "cp", ".", "getDefaults", "(", ")", "{", "if", "_", ",", "exist", ":=", "c", "[", "key", "]", ";", "!", "exist", "{", ...
// applyDefaults updates config with defaults from config policy
[ "applyDefaults", "updates", "config", "with", "defaults", "from", "config", "policy" ]
2f826c76a182b204f8c0d458e7b76d64fca38062
https://github.com/intelsdi-x/snap-plugin-lib-go/blob/2f826c76a182b204f8c0d458e7b76d64fca38062/v1/plugin/config.go#L114-L121
146,203
intelsdi-x/snap-plugin-lib-go
v1/plugin/plugin.go
readOSArg
func (io *standardInputOutput) readOSArg() string { if io.context != nil { return io.context.Args().First() } if len(os.Args) > 0 { return os.Args[0] } return "" }
go
func (io *standardInputOutput) readOSArg() string { if io.context != nil { return io.context.Args().First() } if len(os.Args) > 0 { return os.Args[0] } return "" }
[ "func", "(", "io", "*", "standardInputOutput", ")", "readOSArg", "(", ")", "string", "{", "if", "io", ".", "context", "!=", "nil", "{", "return", "io", ".", "context", ".", "Args", "(", ")", ".", "First", "(", ")", "\n", "}", "\n", "if", "len", "...
// readOSArgs implementation that returns application args passed by OS
[ "readOSArgs", "implementation", "that", "returns", "application", "args", "passed", "by", "OS" ]
2f826c76a182b204f8c0d458e7b76d64fca38062
https://github.com/intelsdi-x/snap-plugin-lib-go/blob/2f826c76a182b204f8c0d458e7b76d64fca38062/v1/plugin/plugin.go#L168-L176
146,204
intelsdi-x/snap-plugin-lib-go
v1/plugin/plugin.go
makeTLSConfig
func (ts tlsServerDefaultSetup) makeTLSConfig() *tls.Config { config := tls.Config{ ClientAuth: tls.RequireAndVerifyClientCert, PreferServerCipherSuites: true, CipherSuites: []uint16{ tls.TLS_RSA_WITH_AES_128_GCM_SHA256, tls.TLS_RSA_WITH_AES_256_GCM_SHA384, }, } return &config }
go
func (ts tlsServerDefaultSetup) makeTLSConfig() *tls.Config { config := tls.Config{ ClientAuth: tls.RequireAndVerifyClientCert, PreferServerCipherSuites: true, CipherSuites: []uint16{ tls.TLS_RSA_WITH_AES_128_GCM_SHA256, tls.TLS_RSA_WITH_AES_256_GCM_SHA384, }, } return &config }
[ "func", "(", "ts", "tlsServerDefaultSetup", ")", "makeTLSConfig", "(", ")", "*", "tls", ".", "Config", "{", "config", ":=", "tls", ".", "Config", "{", "ClientAuth", ":", "tls", ".", "RequireAndVerifyClientCert", ",", "PreferServerCipherSuites", ":", "true", ",...
// makeTLSConfig provides TLS configuration template for plugins, setting // required verification of client cert and preferred server suites.
[ "makeTLSConfig", "provides", "TLS", "configuration", "template", "for", "plugins", "setting", "required", "verification", "of", "client", "cert", "and", "preferred", "server", "suites", "." ]
2f826c76a182b204f8c0d458e7b76d64fca38062
https://github.com/intelsdi-x/snap-plugin-lib-go/blob/2f826c76a182b204f8c0d458e7b76d64fca38062/v1/plugin/plugin.go#L203-L213
146,205
intelsdi-x/snap-plugin-lib-go
v1/plugin/plugin.go
readRootCAs
func (ts tlsServerDefaultSetup) readRootCAs(rootCertPaths string) (*x509.CertPool, error) { if rootCertPaths == "" { return x509.SystemCertPool() } certPaths := filepath.SplitList(rootCertPaths) return ts.loadRootCerts(certPaths) }
go
func (ts tlsServerDefaultSetup) readRootCAs(rootCertPaths string) (*x509.CertPool, error) { if rootCertPaths == "" { return x509.SystemCertPool() } certPaths := filepath.SplitList(rootCertPaths) return ts.loadRootCerts(certPaths) }
[ "func", "(", "ts", "tlsServerDefaultSetup", ")", "readRootCAs", "(", "rootCertPaths", "string", ")", "(", "*", "x509", ".", "CertPool", ",", "error", ")", "{", "if", "rootCertPaths", "==", "\"", "\"", "{", "return", "x509", ".", "SystemCertPool", "(", ")",...
// readRootCAs delivers a standard source of root CAs from system
[ "readRootCAs", "delivers", "a", "standard", "source", "of", "root", "CAs", "from", "system" ]
2f826c76a182b204f8c0d458e7b76d64fca38062
https://github.com/intelsdi-x/snap-plugin-lib-go/blob/2f826c76a182b204f8c0d458e7b76d64fca38062/v1/plugin/plugin.go#L216-L222
146,206
intelsdi-x/snap-plugin-lib-go
v1/plugin/plugin.go
makeGRPCCredentials
func makeGRPCCredentials(m *meta) (creds credentials.TransportCredentials, err error) { var config *tls.Config if !m.TLSEnabled { config = &tls.Config{ InsecureSkipVerify: true, } } else { cert, err := tls.LoadX509KeyPair(m.CertPath, m.KeyPath) if err != nil { return nil, fmt.Errorf("unable to setup cr...
go
func makeGRPCCredentials(m *meta) (creds credentials.TransportCredentials, err error) { var config *tls.Config if !m.TLSEnabled { config = &tls.Config{ InsecureSkipVerify: true, } } else { cert, err := tls.LoadX509KeyPair(m.CertPath, m.KeyPath) if err != nil { return nil, fmt.Errorf("unable to setup cr...
[ "func", "makeGRPCCredentials", "(", "m", "*", "meta", ")", "(", "creds", "credentials", ".", "TransportCredentials", ",", "err", "error", ")", "{", "var", "config", "*", "tls", ".", "Config", "\n", "if", "!", "m", ".", "TLSEnabled", "{", "config", "=", ...
// makeGRPCCredentials delivers credentials object suitable for setting up gRPC // server, with TLS optionally turned on.
[ "makeGRPCCredentials", "delivers", "credentials", "object", "suitable", "for", "setting", "up", "gRPC", "server", "with", "TLS", "optionally", "turned", "on", "." ]
2f826c76a182b204f8c0d458e7b76d64fca38062
https://github.com/intelsdi-x/snap-plugin-lib-go/blob/2f826c76a182b204f8c0d458e7b76d64fca38062/v1/plugin/plugin.go#L277-L296
146,207
intelsdi-x/snap-plugin-lib-go
v1/plugin/plugin.go
applySecurityArgsToMeta
func applySecurityArgsToMeta(m *meta, args *Arg) error { if !args.TLSEnabled { if args.CertPath != "" || args.KeyPath != "" { return fmt.Errorf("excessive arguments given - CertPath and KeyPath are unused with TLS not enabled") } return nil } if args.CertPath == "" || args.KeyPath == "" { return fmt.Error...
go
func applySecurityArgsToMeta(m *meta, args *Arg) error { if !args.TLSEnabled { if args.CertPath != "" || args.KeyPath != "" { return fmt.Errorf("excessive arguments given - CertPath and KeyPath are unused with TLS not enabled") } return nil } if args.CertPath == "" || args.KeyPath == "" { return fmt.Error...
[ "func", "applySecurityArgsToMeta", "(", "m", "*", "meta", ",", "args", "*", "Arg", ")", "error", "{", "if", "!", "args", ".", "TLSEnabled", "{", "if", "args", ".", "CertPath", "!=", "\"", "\"", "||", "args", ".", "KeyPath", "!=", "\"", "\"", "{", "...
// applySecurityArgsToMeta validates plugin runtime arguments from OS, focusing on // TLS functionality.
[ "applySecurityArgsToMeta", "validates", "plugin", "runtime", "arguments", "from", "OS", "focusing", "on", "TLS", "functionality", "." ]
2f826c76a182b204f8c0d458e7b76d64fca38062
https://github.com/intelsdi-x/snap-plugin-lib-go/blob/2f826c76a182b204f8c0d458e7b76d64fca38062/v1/plugin/plugin.go#L300-L315
146,208
intelsdi-x/snap-plugin-lib-go
v1/plugin/plugin.go
buildGRPCServer
func buildGRPCServer(typeOfPlugin pluginType, name string, version int, arg *Arg, opts ...MetaOpt) (server *grpc.Server, m *meta, err error) { var grpcOptions []grpc.ServerOption m = newMeta(typeOfPlugin, name, version, opts...) grpcOptions = append(grpcOptions, m.grpcServerOptions...) if err := applySecurityArgs...
go
func buildGRPCServer(typeOfPlugin pluginType, name string, version int, arg *Arg, opts ...MetaOpt) (server *grpc.Server, m *meta, err error) { var grpcOptions []grpc.ServerOption m = newMeta(typeOfPlugin, name, version, opts...) grpcOptions = append(grpcOptions, m.grpcServerOptions...) if err := applySecurityArgs...
[ "func", "buildGRPCServer", "(", "typeOfPlugin", "pluginType", ",", "name", "string", ",", "version", "int", ",", "arg", "*", "Arg", ",", "opts", "...", "MetaOpt", ")", "(", "server", "*", "grpc", ".", "Server", ",", "m", "*", "meta", ",", "err", "error...
// buildGRPCServer configures and builds GRPC server ready to server a plugin // instance
[ "buildGRPCServer", "configures", "and", "builds", "GRPC", "server", "ready", "to", "server", "a", "plugin", "instance" ]
2f826c76a182b204f8c0d458e7b76d64fca38062
https://github.com/intelsdi-x/snap-plugin-lib-go/blob/2f826c76a182b204f8c0d458e7b76d64fca38062/v1/plugin/plugin.go#L319-L337
146,209
intelsdi-x/snap-plugin-lib-go
v1/plugin/plugin.go
getAddr
func getAddr(addr string) (string, error) { if strings.Compare(addr, "0.0.0.0") == 0 { addrs, err := net.InterfaceAddrs() if err != nil { return "", err } for _, address := range addrs { // check the address type and if it is not a loopback the display it if ipnet, ok := address.(*net.IPNet); ok && !i...
go
func getAddr(addr string) (string, error) { if strings.Compare(addr, "0.0.0.0") == 0 { addrs, err := net.InterfaceAddrs() if err != nil { return "", err } for _, address := range addrs { // check the address type and if it is not a loopback the display it if ipnet, ok := address.(*net.IPNet); ok && !i...
[ "func", "getAddr", "(", "addr", "string", ")", "(", "string", ",", "error", ")", "{", "if", "strings", ".", "Compare", "(", "addr", ",", "\"", "\"", ")", "==", "0", "{", "addrs", ",", "err", ":=", "net", ".", "InterfaceAddrs", "(", ")", "\n", "if...
// getAddr if we were provided the addr 0.0.0.0 we need to determine the // address we will advertise to the framework in the preamble.
[ "getAddr", "if", "we", "were", "provided", "the", "addr", "0", ".", "0", ".", "0", ".", "0", "we", "need", "to", "determine", "the", "address", "we", "will", "advertise", "to", "the", "framework", "in", "the", "preamble", "." ]
2f826c76a182b204f8c0d458e7b76d64fca38062
https://github.com/intelsdi-x/snap-plugin-lib-go/blob/2f826c76a182b204f8c0d458e7b76d64fca38062/v1/plugin/plugin.go#L668-L684
146,210
intelsdi-x/snap-plugin-lib-go
v1/plugin/metric.go
toProtoMetric
func toProtoMetric(mt Metric) (*rpc.Metric, error) { if mt.Timestamp == (time.Time{}) { //Timestamp is unitialized, set to time.Now() mt.Timestamp = time.Now() } if mt.lastAdvertisedTime == (time.Time{}) { // lastAdvertisedTime is unitialized, set to time.Now() mt.lastAdvertisedTime = time.Now() } metric ...
go
func toProtoMetric(mt Metric) (*rpc.Metric, error) { if mt.Timestamp == (time.Time{}) { //Timestamp is unitialized, set to time.Now() mt.Timestamp = time.Now() } if mt.lastAdvertisedTime == (time.Time{}) { // lastAdvertisedTime is unitialized, set to time.Now() mt.lastAdvertisedTime = time.Now() } metric ...
[ "func", "toProtoMetric", "(", "mt", "Metric", ")", "(", "*", "rpc", ".", "Metric", ",", "error", ")", "{", "if", "mt", ".", "Timestamp", "==", "(", "time", ".", "Time", "{", "}", ")", "{", "//Timestamp is unitialized, set to time.Now()", "mt", ".", "Time...
// Converts a metric to an protobuf metric. // Returns an error in the case where the metric.Data is not one of the // supported types.
[ "Converts", "a", "metric", "to", "an", "protobuf", "metric", ".", "Returns", "an", "error", "in", "the", "case", "where", "the", "metric", ".", "Data", "is", "not", "one", "of", "the", "supported", "types", "." ]
2f826c76a182b204f8c0d458e7b76d64fca38062
https://github.com/intelsdi-x/snap-plugin-lib-go/blob/2f826c76a182b204f8c0d458e7b76d64fca38062/v1/plugin/metric.go#L48-L101
146,211
intelsdi-x/snap-plugin-lib-go
v1/plugin/metric.go
CopyNamespace
func CopyNamespace(src Namespace) Namespace { dst := make([]NamespaceElement, len(src)) copy(dst, src) return dst }
go
func CopyNamespace(src Namespace) Namespace { dst := make([]NamespaceElement, len(src)) copy(dst, src) return dst }
[ "func", "CopyNamespace", "(", "src", "Namespace", ")", "Namespace", "{", "dst", ":=", "make", "(", "[", "]", "NamespaceElement", ",", "len", "(", "src", ")", ")", "\n", "copy", "(", "dst", ",", "src", ")", "\n", "return", "dst", "\n", "}" ]
// CopyNamespace copies array of namespace elements to new array
[ "CopyNamespace", "copies", "array", "of", "namespace", "elements", "to", "new", "array" ]
2f826c76a182b204f8c0d458e7b76d64fca38062
https://github.com/intelsdi-x/snap-plugin-lib-go/blob/2f826c76a182b204f8c0d458e7b76d64fca38062/v1/plugin/metric.go#L267-L271
146,212
intelsdi-x/snap-plugin-lib-go
examples/snap-plugin-publisher-file/file/file.go
Publish
func (f FPublisher) Publish(mts []plugin.Metric, cfg plugin.Config) error { file, err := cfg.GetString("file") if err != nil { return err } if val, err := cfg.GetBool("return_error"); err == nil && val { return errors.New("Houston we have a problem") } fileHandle, _ := os.Create(file) writer := bufio.NewWrit...
go
func (f FPublisher) Publish(mts []plugin.Metric, cfg plugin.Config) error { file, err := cfg.GetString("file") if err != nil { return err } if val, err := cfg.GetBool("return_error"); err == nil && val { return errors.New("Houston we have a problem") } fileHandle, _ := os.Create(file) writer := bufio.NewWrit...
[ "func", "(", "f", "FPublisher", ")", "Publish", "(", "mts", "[", "]", "plugin", ".", "Metric", ",", "cfg", "plugin", ".", "Config", ")", "error", "{", "file", ",", "err", ":=", "cfg", ".", "GetString", "(", "\"", "\"", ")", "\n", "if", "err", "!=...
// Publish test publish function
[ "Publish", "test", "publish", "function" ]
2f826c76a182b204f8c0d458e7b76d64fca38062
https://github.com/intelsdi-x/snap-plugin-lib-go/blob/2f826c76a182b204f8c0d458e7b76d64fca38062/examples/snap-plugin-publisher-file/file/file.go#L48-L75
146,213
intelsdi-x/snap-plugin-lib-go
v1/plugin/config_policy.go
getDefaults
func (c *ConfigPolicy) getDefaults() Config { config := NewConfig() for _, v := range c.stringRules { for key, val := range v.Rules { if val.HasDefault { config[key] = val.Default } } } for _, v := range c.boolRules { for key, val := range v.Rules { if val.HasDefault { config[key] = val.Defau...
go
func (c *ConfigPolicy) getDefaults() Config { config := NewConfig() for _, v := range c.stringRules { for key, val := range v.Rules { if val.HasDefault { config[key] = val.Default } } } for _, v := range c.boolRules { for key, val := range v.Rules { if val.HasDefault { config[key] = val.Defau...
[ "func", "(", "c", "*", "ConfigPolicy", ")", "getDefaults", "(", ")", "Config", "{", "config", ":=", "NewConfig", "(", ")", "\n", "for", "_", ",", "v", ":=", "range", "c", ".", "stringRules", "{", "for", "key", ",", "val", ":=", "range", "v", ".", ...
// getDefaults returns config with defaults from config policy
[ "getDefaults", "returns", "config", "with", "defaults", "from", "config", "policy" ]
2f826c76a182b204f8c0d458e7b76d64fca38062
https://github.com/intelsdi-x/snap-plugin-lib-go/blob/2f826c76a182b204f8c0d458e7b76d64fca38062/v1/plugin/config_policy.go#L153-L185
146,214
intelsdi-x/snap-plugin-lib-go
v1/plugin/meta.go
newMeta
func newMeta(plType pluginType, name string, version int, opts ...MetaOpt) *meta { p := meta{ Name: name, Version: version, Type: plType, ConcurrencyCount: defaultConcurrencyCount, RoutingStrategy: LRURouter, RPCType: gRPC, // GRPC type RPCVersion: 1, /...
go
func newMeta(plType pluginType, name string, version int, opts ...MetaOpt) *meta { p := meta{ Name: name, Version: version, Type: plType, ConcurrencyCount: defaultConcurrencyCount, RoutingStrategy: LRURouter, RPCType: gRPC, // GRPC type RPCVersion: 1, /...
[ "func", "newMeta", "(", "plType", "pluginType", ",", "name", "string", ",", "version", "int", ",", "opts", "...", "MetaOpt", ")", "*", "meta", "{", "p", ":=", "meta", "{", "Name", ":", "name", ",", "Version", ":", "version", ",", "Type", ":", "plType...
// newMeta sets defaults, applies options, and then returns a meta struct
[ "newMeta", "sets", "defaults", "applies", "options", "and", "then", "returns", "a", "meta", "struct" ]
2f826c76a182b204f8c0d458e7b76d64fca38062
https://github.com/intelsdi-x/snap-plugin-lib-go/blob/2f826c76a182b204f8c0d458e7b76d64fca38062/v1/plugin/meta.go#L141-L160
146,215
GiterLab/urllib
urllib.go
SetDefaultSetting
func SetDefaultSetting(setting HttpSettings) { settingMutex.Lock() defer settingMutex.Unlock() defaultSetting = setting if defaultSetting.ConnectTimeout == 0 { defaultSetting.ConnectTimeout = 60 * time.Second } if defaultSetting.ReadWriteTimeout == 0 { defaultSetting.ReadWriteTimeout = 60 * time.Second } }
go
func SetDefaultSetting(setting HttpSettings) { settingMutex.Lock() defer settingMutex.Unlock() defaultSetting = setting if defaultSetting.ConnectTimeout == 0 { defaultSetting.ConnectTimeout = 60 * time.Second } if defaultSetting.ReadWriteTimeout == 0 { defaultSetting.ReadWriteTimeout = 60 * time.Second } }
[ "func", "SetDefaultSetting", "(", "setting", "HttpSettings", ")", "{", "settingMutex", ".", "Lock", "(", ")", "\n", "defer", "settingMutex", ".", "Unlock", "(", ")", "\n", "defaultSetting", "=", "setting", "\n", "if", "defaultSetting", ".", "ConnectTimeout", "...
// Overwrite default settings
[ "Overwrite", "default", "settings" ]
ea0e875f90303d1469067f22ccda69f903380a87
https://github.com/GiterLab/urllib/blob/ea0e875f90303d1469067f22ccda69f903380a87/urllib.go#L52-L62
146,216
GiterLab/urllib
urllib.go
DumpBody
func (b *HttpRequest) DumpBody(isdump bool) *HttpRequest { b.setting.DumpBody = isdump return b }
go
func (b *HttpRequest) DumpBody(isdump bool) *HttpRequest { b.setting.DumpBody = isdump return b }
[ "func", "(", "b", "*", "HttpRequest", ")", "DumpBody", "(", "isdump", "bool", ")", "*", "HttpRequest", "{", "b", ".", "setting", ".", "DumpBody", "=", "isdump", "\n", "return", "b", "\n", "}" ]
// Dump Body.
[ "Dump", "Body", "." ]
ea0e875f90303d1469067f22ccda69f903380a87
https://github.com/GiterLab/urllib/blob/ea0e875f90303d1469067f22ccda69f903380a87/urllib.go#L187-L190
146,217
GiterLab/urllib
urllib.go
JsonBody
func (b *HttpRequest) JsonBody(obj interface{}) (*HttpRequest, error) { if b.req.Body == nil && obj != nil { buf := bytes.NewBuffer(nil) enc := json.NewEncoder(buf) if err := enc.Encode(obj); err != nil { return b, err } b.req.Body = ioutil.NopCloser(buf) b.req.ContentLength = int64(buf.Len()) b.req.H...
go
func (b *HttpRequest) JsonBody(obj interface{}) (*HttpRequest, error) { if b.req.Body == nil && obj != nil { buf := bytes.NewBuffer(nil) enc := json.NewEncoder(buf) if err := enc.Encode(obj); err != nil { return b, err } b.req.Body = ioutil.NopCloser(buf) b.req.ContentLength = int64(buf.Len()) b.req.H...
[ "func", "(", "b", "*", "HttpRequest", ")", "JsonBody", "(", "obj", "interface", "{", "}", ")", "(", "*", "HttpRequest", ",", "error", ")", "{", "if", "b", ".", "req", ".", "Body", "==", "nil", "&&", "obj", "!=", "nil", "{", "buf", ":=", "bytes", ...
// JsonBody adds request raw body encoding by JSON.
[ "JsonBody", "adds", "request", "raw", "body", "encoding", "by", "JSON", "." ]
ea0e875f90303d1469067f22ccda69f903380a87
https://github.com/GiterLab/urllib/blob/ea0e875f90303d1469067f22ccda69f903380a87/urllib.go#L302-L314
146,218
grokify/oauth2more
ringcentral/ringcentral_client_env.go
ApplicationCredentials
func (cfg *ApplicationConfigEnv) ApplicationCredentials() ApplicationCredentials { return ApplicationCredentials{ ServerURL: cfg.ServerURL, ClientID: cfg.ClientID, ClientSecret: cfg.ClientSecret} }
go
func (cfg *ApplicationConfigEnv) ApplicationCredentials() ApplicationCredentials { return ApplicationCredentials{ ServerURL: cfg.ServerURL, ClientID: cfg.ClientID, ClientSecret: cfg.ClientSecret} }
[ "func", "(", "cfg", "*", "ApplicationConfigEnv", ")", "ApplicationCredentials", "(", ")", "ApplicationCredentials", "{", "return", "ApplicationCredentials", "{", "ServerURL", ":", "cfg", ".", "ServerURL", ",", "ClientID", ":", "cfg", ".", "ClientID", ",", "ClientS...
// ApplicationCredentials returns a ApplicationCredentials struct.
[ "ApplicationCredentials", "returns", "a", "ApplicationCredentials", "struct", "." ]
6c3d769391e8ae6edd5cfe3d293f543150dc78ce
https://github.com/grokify/oauth2more/blob/6c3d769391e8ae6edd5cfe3d293f543150dc78ce/ringcentral/ringcentral_client_env.go#L36-L41
146,219
grokify/oauth2more
ringcentral/ringcentral_client_env.go
PasswordCredentials
func (cfg *ApplicationConfigEnv) PasswordCredentials() PasswordCredentials { return PasswordCredentials{ Username: cfg.Username, Extension: cfg.Extension, Password: cfg.Password} }
go
func (cfg *ApplicationConfigEnv) PasswordCredentials() PasswordCredentials { return PasswordCredentials{ Username: cfg.Username, Extension: cfg.Extension, Password: cfg.Password} }
[ "func", "(", "cfg", "*", "ApplicationConfigEnv", ")", "PasswordCredentials", "(", ")", "PasswordCredentials", "{", "return", "PasswordCredentials", "{", "Username", ":", "cfg", ".", "Username", ",", "Extension", ":", "cfg", ".", "Extension", ",", "Password", ":"...
// PasswordCredentials returns a PasswordCredentials struct.
[ "PasswordCredentials", "returns", "a", "PasswordCredentials", "struct", "." ]
6c3d769391e8ae6edd5cfe3d293f543150dc78ce
https://github.com/grokify/oauth2more/blob/6c3d769391e8ae6edd5cfe3d293f543150dc78ce/ringcentral/ringcentral_client_env.go#L44-L49
146,220
grokify/oauth2more
ringcentral/ringcentral_client_env.go
LoadToken
func (cfg *ApplicationConfigEnv) LoadToken() (*oauth2.Token, error) { tok, err := NewTokenPassword( cfg.ApplicationCredentials(), cfg.PasswordCredentials()) if err == nil { cfg.AccessToken = tok.AccessToken } return tok, err }
go
func (cfg *ApplicationConfigEnv) LoadToken() (*oauth2.Token, error) { tok, err := NewTokenPassword( cfg.ApplicationCredentials(), cfg.PasswordCredentials()) if err == nil { cfg.AccessToken = tok.AccessToken } return tok, err }
[ "func", "(", "cfg", "*", "ApplicationConfigEnv", ")", "LoadToken", "(", ")", "(", "*", "oauth2", ".", "Token", ",", "error", ")", "{", "tok", ",", "err", ":=", "NewTokenPassword", "(", "cfg", ".", "ApplicationCredentials", "(", ")", ",", "cfg", ".", "P...
// LoadToken loads and returns an OAuth token.
[ "LoadToken", "loads", "and", "returns", "an", "OAuth", "token", "." ]
6c3d769391e8ae6edd5cfe3d293f543150dc78ce
https://github.com/grokify/oauth2more/blob/6c3d769391e8ae6edd5cfe3d293f543150dc78ce/ringcentral/ringcentral_client_env.go#L52-L60
146,221
grokify/oauth2more
token_store.go
ReadTokenFile
func ReadTokenFile(fpath string) (*oauth2.Token, error) { f, err := os.Open(fpath) if err != nil { return nil, err } tok := &oauth2.Token{} err = json.NewDecoder(f).Decode(tok) defer f.Close() return tok, err }
go
func ReadTokenFile(fpath string) (*oauth2.Token, error) { f, err := os.Open(fpath) if err != nil { return nil, err } tok := &oauth2.Token{} err = json.NewDecoder(f).Decode(tok) defer f.Close() return tok, err }
[ "func", "ReadTokenFile", "(", "fpath", "string", ")", "(", "*", "oauth2", ".", "Token", ",", "error", ")", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "fpath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", ...
// ReadTokenFile retrieves a Token from a given filepath.
[ "ReadTokenFile", "retrieves", "a", "Token", "from", "a", "given", "filepath", "." ]
6c3d769391e8ae6edd5cfe3d293f543150dc78ce
https://github.com/grokify/oauth2more/blob/6c3d769391e8ae6edd5cfe3d293f543150dc78ce/token_store.go#L21-L30
146,222
grokify/oauth2more
token_store.go
WriteTokenFile
func WriteTokenFile(fpath string, tok *oauth2.Token) error { f, err := os.OpenFile(fpath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600) if err != nil { return errors.Wrap(err, "Unable to write OAuth token") } defer f.Close() return json.NewEncoder(f).Encode(tok) }
go
func WriteTokenFile(fpath string, tok *oauth2.Token) error { f, err := os.OpenFile(fpath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600) if err != nil { return errors.Wrap(err, "Unable to write OAuth token") } defer f.Close() return json.NewEncoder(f).Encode(tok) }
[ "func", "WriteTokenFile", "(", "fpath", "string", ",", "tok", "*", "oauth2", ".", "Token", ")", "error", "{", "f", ",", "err", ":=", "os", ".", "OpenFile", "(", "fpath", ",", "os", ".", "O_RDWR", "|", "os", ".", "O_CREATE", "|", "os", ".", "O_TRUNC...
// WriteTokenFile writes a token file to the the filepaths.
[ "WriteTokenFile", "writes", "a", "token", "file", "to", "the", "the", "filepaths", "." ]
6c3d769391e8ae6edd5cfe3d293f543150dc78ce
https://github.com/grokify/oauth2more/blob/6c3d769391e8ae6edd5cfe3d293f543150dc78ce/token_store.go#L33-L40
146,223
grokify/oauth2more
scim/definitions.go
AddEmail
func (user *User) AddEmail(emailAddr string, isPrimary bool) error { emailAddrCanonical := strings.ToLower(strings.TrimSpace(emailAddr)) if len(emailAddr) < 1 { return fmt.Errorf("Invalid Email Address: %v", emailAddr) } email := Item{ Value: emailAddrCanonical, Primary: isPrimary} user.Emails = append(use...
go
func (user *User) AddEmail(emailAddr string, isPrimary bool) error { emailAddrCanonical := strings.ToLower(strings.TrimSpace(emailAddr)) if len(emailAddr) < 1 { return fmt.Errorf("Invalid Email Address: %v", emailAddr) } email := Item{ Value: emailAddrCanonical, Primary: isPrimary} user.Emails = append(use...
[ "func", "(", "user", "*", "User", ")", "AddEmail", "(", "emailAddr", "string", ",", "isPrimary", "bool", ")", "error", "{", "emailAddrCanonical", ":=", "strings", ".", "ToLower", "(", "strings", ".", "TrimSpace", "(", "emailAddr", ")", ")", "\n", "if", "...
// AddEmail adds a canonical email address to the user. // it lowercases and trims preceding and trailing spaces // from the email address.
[ "AddEmail", "adds", "a", "canonical", "email", "address", "to", "the", "user", ".", "it", "lowercases", "and", "trims", "preceding", "and", "trailing", "spaces", "from", "the", "email", "address", "." ]
6c3d769391e8ae6edd5cfe3d293f543150dc78ce
https://github.com/grokify/oauth2more/blob/6c3d769391e8ae6edd5cfe3d293f543150dc78ce/scim/definitions.go#L33-L43
146,224
grokify/oauth2more
basicauth.go
BasicAuthToken
func BasicAuthToken(username, password string) (*oauth2.Token, error) { basicToken, err := RFC7617UserPass(username, password) if err != nil { return nil, err } return &oauth2.Token{ AccessToken: basicToken, TokenType: BasicPrefix, Expiry: timeutil.TimeRFC3339Zero()}, nil }
go
func BasicAuthToken(username, password string) (*oauth2.Token, error) { basicToken, err := RFC7617UserPass(username, password) if err != nil { return nil, err } return &oauth2.Token{ AccessToken: basicToken, TokenType: BasicPrefix, Expiry: timeutil.TimeRFC3339Zero()}, nil }
[ "func", "BasicAuthToken", "(", "username", ",", "password", "string", ")", "(", "*", "oauth2", ".", "Token", ",", "error", ")", "{", "basicToken", ",", "err", ":=", "RFC7617UserPass", "(", "username", ",", "password", ")", "\n", "if", "err", "!=", "nil",...
// BasicAuthToken provides Basic Authentication support via an oauth2.Token.
[ "BasicAuthToken", "provides", "Basic", "Authentication", "support", "via", "an", "oauth2", ".", "Token", "." ]
6c3d769391e8ae6edd5cfe3d293f543150dc78ce
https://github.com/grokify/oauth2more/blob/6c3d769391e8ae6edd5cfe3d293f543150dc78ce/basicauth.go#L34-L44
146,225
grokify/oauth2more
ringcentral/ringcentral_client.go
NewClientPassword
func NewClientPassword(app ApplicationCredentials, pwd PasswordCredentials) (*http.Client, error) { c := app.Config() token, err := RetrieveToken(c, pwd.URLValues()) if err != nil { return nil, err } httpClient := c.Client(oauth2.NoContext, token) header := getClientHeader(app) if len(header) > 0 { httpCli...
go
func NewClientPassword(app ApplicationCredentials, pwd PasswordCredentials) (*http.Client, error) { c := app.Config() token, err := RetrieveToken(c, pwd.URLValues()) if err != nil { return nil, err } httpClient := c.Client(oauth2.NoContext, token) header := getClientHeader(app) if len(header) > 0 { httpCli...
[ "func", "NewClientPassword", "(", "app", "ApplicationCredentials", ",", "pwd", "PasswordCredentials", ")", "(", "*", "http", ".", "Client", ",", "error", ")", "{", "c", ":=", "app", ".", "Config", "(", ")", "\n", "token", ",", "err", ":=", "RetrieveToken",...
// NewClientPassword uses dedicated password grant handling.
[ "NewClientPassword", "uses", "dedicated", "password", "grant", "handling", "." ]
6c3d769391e8ae6edd5cfe3d293f543150dc78ce
https://github.com/grokify/oauth2more/blob/6c3d769391e8ae6edd5cfe3d293f543150dc78ce/ringcentral/ringcentral_client.go#L104-L120
146,226
grokify/oauth2more
ringcentral/ringcentral_client.go
NewClientPasswordSimple
func NewClientPasswordSimple(app ApplicationCredentials, user UserCredentials) (*http.Client, error) { httpClient, err := om.NewClientPasswordConf( oauth2.Config{ ClientID: app.ClientID, ClientSecret: app.ClientSecret, Endpoint: NewEndpoint(app.ServerURL)}, user.UsernameSimple(), user.Password) ...
go
func NewClientPasswordSimple(app ApplicationCredentials, user UserCredentials) (*http.Client, error) { httpClient, err := om.NewClientPasswordConf( oauth2.Config{ ClientID: app.ClientID, ClientSecret: app.ClientSecret, Endpoint: NewEndpoint(app.ServerURL)}, user.UsernameSimple(), user.Password) ...
[ "func", "NewClientPasswordSimple", "(", "app", "ApplicationCredentials", ",", "user", "UserCredentials", ")", "(", "*", "http", ".", "Client", ",", "error", ")", "{", "httpClient", ",", "err", ":=", "om", ".", "NewClientPasswordConf", "(", "oauth2", ".", "Conf...
// NewClientPasswordSimple uses OAuth2 package password grant handling.
[ "NewClientPasswordSimple", "uses", "OAuth2", "package", "password", "grant", "handling", "." ]
6c3d769391e8ae6edd5cfe3d293f543150dc78ce
https://github.com/grokify/oauth2more/blob/6c3d769391e8ae6edd5cfe3d293f543150dc78ce/ringcentral/ringcentral_client.go#L123-L142
146,227
peterhellberg/giphy
translate.go
Translate
func (c *Client) Translate(args []string) (Translate, error) { argsStr := strings.Join(args, " ") req, err := c.NewRequest("/gifs/translate?s=" + argsStr) if err != nil { return Translate{}, err } var translate Translate if _, err = c.Do(req, &translate); err != nil { return Translate{}, err } if len(tra...
go
func (c *Client) Translate(args []string) (Translate, error) { argsStr := strings.Join(args, " ") req, err := c.NewRequest("/gifs/translate?s=" + argsStr) if err != nil { return Translate{}, err } var translate Translate if _, err = c.Do(req, &translate); err != nil { return Translate{}, err } if len(tra...
[ "func", "(", "c", "*", "Client", ")", "Translate", "(", "args", "[", "]", "string", ")", "(", "Translate", ",", "error", ")", "{", "argsStr", ":=", "strings", ".", "Join", "(", "args", ",", "\"", "\"", ")", "\n\n", "req", ",", "err", ":=", "c", ...
// Translate returns a translate response from the Giphy API
[ "Translate", "returns", "a", "translate", "response", "from", "the", "Giphy", "API" ]
091ba7d7516de5d780c612658d3e31f12e2c6bac
https://github.com/peterhellberg/giphy/blob/091ba7d7516de5d780c612658d3e31f12e2c6bac/translate.go#L9-L37
146,228
peterhellberg/giphy
search.go
Search
func (c *Client) Search(args []string) (Search, error) { argsStr := strings.Join(args, " ") path := fmt.Sprintf("/gifs/search?limit=%v&q=%s", c.Limit, argsStr) req, err := c.NewRequest(path) if err != nil { return Search{}, err } var search Search if _, err = c.Do(req, &search); err != nil { return Search{...
go
func (c *Client) Search(args []string) (Search, error) { argsStr := strings.Join(args, " ") path := fmt.Sprintf("/gifs/search?limit=%v&q=%s", c.Limit, argsStr) req, err := c.NewRequest(path) if err != nil { return Search{}, err } var search Search if _, err = c.Do(req, &search); err != nil { return Search{...
[ "func", "(", "c", "*", "Client", ")", "Search", "(", "args", "[", "]", "string", ")", "(", "Search", ",", "error", ")", "{", "argsStr", ":=", "strings", ".", "Join", "(", "args", ",", "\"", "\"", ")", "\n\n", "path", ":=", "fmt", ".", "Sprintf", ...
// Search returns a search response from the Giphy API
[ "Search", "returns", "a", "search", "response", "from", "the", "Giphy", "API" ]
091ba7d7516de5d780c612658d3e31f12e2c6bac
https://github.com/peterhellberg/giphy/blob/091ba7d7516de5d780c612658d3e31f12e2c6bac/search.go#L9-L24
146,229
peterhellberg/giphy
random.go
Random
func (c *Client) Random(args []string) (Random, error) { argsStr := strings.Join(args, " ") req, err := c.NewRequest("/gifs/random?tag=" + argsStr) if err != nil { return Random{}, err } var random Random if _, err = c.Do(req, &random); err != nil { return Random{}, err } // Check if the first character ...
go
func (c *Client) Random(args []string) (Random, error) { argsStr := strings.Join(args, " ") req, err := c.NewRequest("/gifs/random?tag=" + argsStr) if err != nil { return Random{}, err } var random Random if _, err = c.Do(req, &random); err != nil { return Random{}, err } // Check if the first character ...
[ "func", "(", "c", "*", "Client", ")", "Random", "(", "args", "[", "]", "string", ")", "(", "Random", ",", "error", ")", "{", "argsStr", ":=", "strings", ".", "Join", "(", "args", ",", "\"", "\"", ")", "\n\n", "req", ",", "err", ":=", "c", ".", ...
// Random returns a random response from the Giphy API
[ "Random", "returns", "a", "random", "response", "from", "the", "Giphy", "API" ]
091ba7d7516de5d780c612658d3e31f12e2c6bac
https://github.com/peterhellberg/giphy/blob/091ba7d7516de5d780c612658d3e31f12e2c6bac/random.go#L9-L37
146,230
peterhellberg/giphy
trending.go
Trending
func (c *Client) Trending(args ...[]string) (Trending, error) { path := fmt.Sprintf("/gifs/trending?limit=%v", c.Limit) req, err := c.NewRequest(path) if err != nil { return Trending{}, err } var res Trending if _, err = c.Do(req, &res); err != nil { return res, err } if len(res.Data) == 0 { return res,...
go
func (c *Client) Trending(args ...[]string) (Trending, error) { path := fmt.Sprintf("/gifs/trending?limit=%v", c.Limit) req, err := c.NewRequest(path) if err != nil { return Trending{}, err } var res Trending if _, err = c.Do(req, &res); err != nil { return res, err } if len(res.Data) == 0 { return res,...
[ "func", "(", "c", "*", "Client", ")", "Trending", "(", "args", "...", "[", "]", "string", ")", "(", "Trending", ",", "error", ")", "{", "path", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "c", ".", "Limit", ")", "\n", "req", ",", "err", ...
// Trending returns a trending response from the Giphy API
[ "Trending", "returns", "a", "trending", "response", "from", "the", "Giphy", "API" ]
091ba7d7516de5d780c612658d3e31f12e2c6bac
https://github.com/peterhellberg/giphy/blob/091ba7d7516de5d780c612658d3e31f12e2c6bac/trending.go#L6-L23
146,231
peterhellberg/giphy
env.go
Env
func Env(key, fallback string) string { v := os.Getenv(key) if v != "" { return v } return fallback }
go
func Env(key, fallback string) string { v := os.Getenv(key) if v != "" { return v } return fallback }
[ "func", "Env", "(", "key", ",", "fallback", "string", ")", "string", "{", "v", ":=", "os", ".", "Getenv", "(", "key", ")", "\n", "if", "v", "!=", "\"", "\"", "{", "return", "v", "\n", "}", "\n\n", "return", "fallback", "\n", "}" ]
// Env returns a string from the ENV, or fallback variable
[ "Env", "returns", "a", "string", "from", "the", "ENV", "or", "fallback", "variable" ]
091ba7d7516de5d780c612658d3e31f12e2c6bac
https://github.com/peterhellberg/giphy/blob/091ba7d7516de5d780c612658d3e31f12e2c6bac/env.go#L9-L16
146,232
peterhellberg/giphy
env.go
EnvBool
func EnvBool(key string, fallback bool) bool { if b, err := strconv.ParseBool(os.Getenv(key)); err == nil { return b } return fallback }
go
func EnvBool(key string, fallback bool) bool { if b, err := strconv.ParseBool(os.Getenv(key)); err == nil { return b } return fallback }
[ "func", "EnvBool", "(", "key", "string", ",", "fallback", "bool", ")", "bool", "{", "if", "b", ",", "err", ":=", "strconv", ".", "ParseBool", "(", "os", ".", "Getenv", "(", "key", ")", ")", ";", "err", "==", "nil", "{", "return", "b", "\n", "}", ...
// EnvBool returns a bool from the ENV, or fallback variable
[ "EnvBool", "returns", "a", "bool", "from", "the", "ENV", "or", "fallback", "variable" ]
091ba7d7516de5d780c612658d3e31f12e2c6bac
https://github.com/peterhellberg/giphy/blob/091ba7d7516de5d780c612658d3e31f12e2c6bac/env.go#L19-L25
146,233
peterhellberg/giphy
env.go
EnvInt
func EnvInt(key string, fallback int) int { if i, err := strconv.Atoi(os.Getenv(key)); err == nil { return i } return fallback }
go
func EnvInt(key string, fallback int) int { if i, err := strconv.Atoi(os.Getenv(key)); err == nil { return i } return fallback }
[ "func", "EnvInt", "(", "key", "string", ",", "fallback", "int", ")", "int", "{", "if", "i", ",", "err", ":=", "strconv", ".", "Atoi", "(", "os", ".", "Getenv", "(", "key", ")", ")", ";", "err", "==", "nil", "{", "return", "i", "\n", "}", "\n\n"...
// EnvInt returns an int from the ENV, or fallback variable
[ "EnvInt", "returns", "an", "int", "from", "the", "ENV", "or", "fallback", "variable" ]
091ba7d7516de5d780c612658d3e31f12e2c6bac
https://github.com/peterhellberg/giphy/blob/091ba7d7516de5d780c612658d3e31f12e2c6bac/env.go#L28-L34
146,234
peterhellberg/giphy
client.go
Do
func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error) { // Make sure to close the connection after replying to this request req.Close = true resp, err := c.httpClient.Do(req) if err != nil { return resp, err } defer resp.Body.Close() if v != nil { err = json.NewDecoder(resp.Body).De...
go
func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error) { // Make sure to close the connection after replying to this request req.Close = true resp, err := c.httpClient.Do(req) if err != nil { return resp, err } defer resp.Body.Close() if v != nil { err = json.NewDecoder(resp.Body).De...
[ "func", "(", "c", "*", "Client", ")", "Do", "(", "req", "*", "http", ".", "Request", ",", "v", "interface", "{", "}", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "// Make sure to close the connection after replying to this request", "req"...
// Do sends an API request and returns the API response. The API response is // decoded and stored in the value pointed to by v, or returned as an error if // an API error has occurred.
[ "Do", "sends", "an", "API", "request", "and", "returns", "the", "API", "response", ".", "The", "API", "response", "is", "decoded", "and", "stored", "in", "the", "value", "pointed", "to", "by", "v", "or", "returned", "as", "an", "error", "if", "an", "AP...
091ba7d7516de5d780c612658d3e31f12e2c6bac
https://github.com/peterhellberg/giphy/blob/091ba7d7516de5d780c612658d3e31f12e2c6bac/client.go#L98-L117
146,235
peterhellberg/giphy
gif.go
GIF
func (c *Client) GIF(id string) (GIF, error) { if strings.ContainsAny(id, "/&?") { return GIF{}, fmt.Errorf("Invalid giphy id: `%v`", id) } req, err := c.NewRequest("/gifs/" + id) if err != nil { return GIF{}, err } var gif GIF if _, err = c.Do(req, &gif); err != nil { return GIF{}, err } if gif.RawDa...
go
func (c *Client) GIF(id string) (GIF, error) { if strings.ContainsAny(id, "/&?") { return GIF{}, fmt.Errorf("Invalid giphy id: `%v`", id) } req, err := c.NewRequest("/gifs/" + id) if err != nil { return GIF{}, err } var gif GIF if _, err = c.Do(req, &gif); err != nil { return GIF{}, err } if gif.RawDa...
[ "func", "(", "c", "*", "Client", ")", "GIF", "(", "id", "string", ")", "(", "GIF", ",", "error", ")", "{", "if", "strings", ".", "ContainsAny", "(", "id", ",", "\"", "\"", ")", "{", "return", "GIF", "{", "}", ",", "fmt", ".", "Errorf", "(", "...
// GIF returns a ID response from the Giphy API
[ "GIF", "returns", "a", "ID", "response", "from", "the", "Giphy", "API" ]
091ba7d7516de5d780c612658d3e31f12e2c6bac
https://github.com/peterhellberg/giphy/blob/091ba7d7516de5d780c612658d3e31f12e2c6bac/gif.go#L10-L44
146,236
tidwall/redlog
redlog.go
New
func New(wr io.Writer) *Logger { return &Logger{ wr: wr, level: logLevelNotice, pid: os.Getpid(), tty: istty(wr), app: 'M', } }
go
func New(wr io.Writer) *Logger { return &Logger{ wr: wr, level: logLevelNotice, pid: os.Getpid(), tty: istty(wr), app: 'M', } }
[ "func", "New", "(", "wr", "io", ".", "Writer", ")", "*", "Logger", "{", "return", "&", "Logger", "{", "wr", ":", "wr", ",", "level", ":", "logLevelNotice", ",", "pid", ":", "os", ".", "Getpid", "(", ")", ",", "tty", ":", "istty", "(", "wr", ")"...
// New creates a new Logger
[ "New", "creates", "a", "new", "Logger" ]
bbed90f29893482876cba9f5f50d750bd7e9fb45
https://github.com/tidwall/redlog/blob/bbed90f29893482876cba9f5f50d750bd7e9fb45/redlog.go#L58-L66
146,237
tidwall/redlog
redlog.go
Sub
func (l *Logger) Sub(app byte) *Logger { l.mu.RLock() defer l.mu.RUnlock() return &Logger{ parent: l, app: app, } }
go
func (l *Logger) Sub(app byte) *Logger { l.mu.RLock() defer l.mu.RUnlock() return &Logger{ parent: l, app: app, } }
[ "func", "(", "l", "*", "Logger", ")", "Sub", "(", "app", "byte", ")", "*", "Logger", "{", "l", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "l", ".", "mu", ".", "RUnlock", "(", ")", "\n", "return", "&", "Logger", "{", "parent", ":", "l",...
// Sub creates a logger that inherits the properties of the caller logger. // The app parameter will be used in the output message.
[ "Sub", "creates", "a", "logger", "that", "inherits", "the", "properties", "of", "the", "caller", "logger", ".", "The", "app", "parameter", "will", "be", "used", "in", "the", "output", "message", "." ]
bbed90f29893482876cba9f5f50d750bd7e9fb45
https://github.com/tidwall/redlog/blob/bbed90f29893482876cba9f5f50d750bd7e9fb45/redlog.go#L70-L77
146,238
tidwall/redlog
redlog.go
SetLevel
func (l *Logger) SetLevel(level int) { if l.parent != nil { l.parent.SetLevel(level) return } l.mu.Lock() defer l.mu.Unlock() if level < int(logLevelDebug) { level = int(logLevelDebug) } else if level > int(logLevelWarning) { level = int(logLevelWarning) } l.level = logLevel(level) }
go
func (l *Logger) SetLevel(level int) { if l.parent != nil { l.parent.SetLevel(level) return } l.mu.Lock() defer l.mu.Unlock() if level < int(logLevelDebug) { level = int(logLevelDebug) } else if level > int(logLevelWarning) { level = int(logLevelWarning) } l.level = logLevel(level) }
[ "func", "(", "l", "*", "Logger", ")", "SetLevel", "(", "level", "int", ")", "{", "if", "l", ".", "parent", "!=", "nil", "{", "l", ".", "parent", ".", "SetLevel", "(", "level", ")", "\n", "return", "\n", "}", "\n", "l", ".", "mu", ".", "Lock", ...
// SetLevel sets the level of the logger. // 0 - Debug // 1 - Verbose // 2 - Notice // 3 - Warning
[ "SetLevel", "sets", "the", "level", "of", "the", "logger", ".", "0", "-", "Debug", "1", "-", "Verbose", "2", "-", "Notice", "3", "-", "Warning" ]
bbed90f29893482876cba9f5f50d750bd7e9fb45
https://github.com/tidwall/redlog/blob/bbed90f29893482876cba9f5f50d750bd7e9fb45/redlog.go#L94-L107
146,239
tidwall/redlog
redlog.go
SetFilter
func (l *Logger) SetFilter(filter func(line string, tty bool) (msg string, app byte, level logLevel)) { if l.parent != nil { l.parent.SetFilter(filter) return } l.mu.Lock() defer l.mu.Unlock() l.filter = filter }
go
func (l *Logger) SetFilter(filter func(line string, tty bool) (msg string, app byte, level logLevel)) { if l.parent != nil { l.parent.SetFilter(filter) return } l.mu.Lock() defer l.mu.Unlock() l.filter = filter }
[ "func", "(", "l", "*", "Logger", ")", "SetFilter", "(", "filter", "func", "(", "line", "string", ",", "tty", "bool", ")", "(", "msg", "string", ",", "app", "byte", ",", "level", "logLevel", ")", ")", "{", "if", "l", ".", "parent", "!=", "nil", "{...
// SetFilter set the logger filter. // A filter can be used to process standard writes into // structured redlog format.
[ "SetFilter", "set", "the", "logger", "filter", ".", "A", "filter", "can", "be", "used", "to", "process", "standard", "writes", "into", "structured", "redlog", "format", "." ]
bbed90f29893482876cba9f5f50d750bd7e9fb45
https://github.com/tidwall/redlog/blob/bbed90f29893482876cba9f5f50d750bd7e9fb45/redlog.go#L121-L129
146,240
tidwall/redlog
redlog.go
Debugf
func (l *Logger) Debugf(format string, args ...interface{}) { l.logf(l.app, logLevelDebug, format, false, args...) }
go
func (l *Logger) Debugf(format string, args ...interface{}) { l.logf(l.app, logLevelDebug, format, false, args...) }
[ "func", "(", "l", "*", "Logger", ")", "Debugf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "l", ".", "logf", "(", "l", ".", "app", ",", "logLevelDebug", ",", "format", ",", "false", ",", "args", "...", ")", "\n"...
// Debugf writes a debug message.
[ "Debugf", "writes", "a", "debug", "message", "." ]
bbed90f29893482876cba9f5f50d750bd7e9fb45
https://github.com/tidwall/redlog/blob/bbed90f29893482876cba9f5f50d750bd7e9fb45/redlog.go#L183-L185
146,241
tidwall/redlog
redlog.go
Verbosef
func (l *Logger) Verbosef(format string, args ...interface{}) { l.logf(l.app, logLevelVerbose, format, false, args...) }
go
func (l *Logger) Verbosef(format string, args ...interface{}) { l.logf(l.app, logLevelVerbose, format, false, args...) }
[ "func", "(", "l", "*", "Logger", ")", "Verbosef", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "l", ".", "logf", "(", "l", ".", "app", ",", "logLevelVerbose", ",", "format", ",", "false", ",", "args", "...", ")", ...
// Verbosef writes a verbose message.
[ "Verbosef", "writes", "a", "verbose", "message", "." ]
bbed90f29893482876cba9f5f50d750bd7e9fb45
https://github.com/tidwall/redlog/blob/bbed90f29893482876cba9f5f50d750bd7e9fb45/redlog.go#L188-L190
146,242
tidwall/redlog
redlog.go
Warningf
func (l *Logger) Warningf(format string, args ...interface{}) { l.logf(l.app, logLevelWarning, format, false, args...) }
go
func (l *Logger) Warningf(format string, args ...interface{}) { l.logf(l.app, logLevelWarning, format, false, args...) }
[ "func", "(", "l", "*", "Logger", ")", "Warningf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "l", ".", "logf", "(", "l", ".", "app", ",", "logLevelWarning", ",", "format", ",", "false", ",", "args", "...", ")", ...
// Warningf writes a warning message.
[ "Warningf", "writes", "a", "warning", "message", "." ]
bbed90f29893482876cba9f5f50d750bd7e9fb45
https://github.com/tidwall/redlog/blob/bbed90f29893482876cba9f5f50d750bd7e9fb45/redlog.go#L198-L200
146,243
tidwall/redlog
redlog.go
Fatalf
func (l *Logger) Fatalf(format string, args ...interface{}) { l.logf(l.app, logLevelWarning, format, false, args...) os.Exit(1) }
go
func (l *Logger) Fatalf(format string, args ...interface{}) { l.logf(l.app, logLevelWarning, format, false, args...) os.Exit(1) }
[ "func", "(", "l", "*", "Logger", ")", "Fatalf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "l", ".", "logf", "(", "l", ".", "app", ",", "logLevelWarning", ",", "format", ",", "false", ",", "args", "...", ")", "\...
// Fatalf writes a warning message and exit process with exit code 1.
[ "Fatalf", "writes", "a", "warning", "message", "and", "exit", "process", "with", "exit", "code", "1", "." ]
bbed90f29893482876cba9f5f50d750bd7e9fb45
https://github.com/tidwall/redlog/blob/bbed90f29893482876cba9f5f50d750bd7e9fb45/redlog.go#L203-L206
146,244
tidwall/redlog
redlog.go
Printf
func (l *Logger) Printf(format string, args ...interface{}) { l.logf(l.app, logLevelNotice, format, false, args...) }
go
func (l *Logger) Printf(format string, args ...interface{}) { l.logf(l.app, logLevelNotice, format, false, args...) }
[ "func", "(", "l", "*", "Logger", ")", "Printf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "l", ".", "logf", "(", "l", ".", "app", ",", "logLevelNotice", ",", "format", ",", "false", ",", "args", "...", ")", "\n...
// Printf writes a default message.
[ "Printf", "writes", "a", "default", "message", "." ]
bbed90f29893482876cba9f5f50d750bd7e9fb45
https://github.com/tidwall/redlog/blob/bbed90f29893482876cba9f5f50d750bd7e9fb45/redlog.go#L209-L211
146,245
tidwall/redlog
redlog.go
Debug
func (l *Logger) Debug(args ...interface{}) { l.logf(l.app, logLevelDebug, "", true, args...) }
go
func (l *Logger) Debug(args ...interface{}) { l.logf(l.app, logLevelDebug, "", true, args...) }
[ "func", "(", "l", "*", "Logger", ")", "Debug", "(", "args", "...", "interface", "{", "}", ")", "{", "l", ".", "logf", "(", "l", ".", "app", ",", "logLevelDebug", ",", "\"", "\"", ",", "true", ",", "args", "...", ")", "\n", "}" ]
// Debug writes a debug message.
[ "Debug", "writes", "a", "debug", "message", "." ]
bbed90f29893482876cba9f5f50d750bd7e9fb45
https://github.com/tidwall/redlog/blob/bbed90f29893482876cba9f5f50d750bd7e9fb45/redlog.go#L214-L216
146,246
tidwall/redlog
redlog.go
Verbose
func (l *Logger) Verbose(args ...interface{}) { l.logf(l.app, logLevelVerbose, "", true, args...) }
go
func (l *Logger) Verbose(args ...interface{}) { l.logf(l.app, logLevelVerbose, "", true, args...) }
[ "func", "(", "l", "*", "Logger", ")", "Verbose", "(", "args", "...", "interface", "{", "}", ")", "{", "l", ".", "logf", "(", "l", ".", "app", ",", "logLevelVerbose", ",", "\"", "\"", ",", "true", ",", "args", "...", ")", "\n", "}" ]
// Verbose writes a verbose message.
[ "Verbose", "writes", "a", "verbose", "message", "." ]
bbed90f29893482876cba9f5f50d750bd7e9fb45
https://github.com/tidwall/redlog/blob/bbed90f29893482876cba9f5f50d750bd7e9fb45/redlog.go#L219-L221
146,247
tidwall/redlog
redlog.go
Notice
func (l *Logger) Notice(args ...interface{}) { l.logf(l.app, logLevelNotice, "", true, args...) }
go
func (l *Logger) Notice(args ...interface{}) { l.logf(l.app, logLevelNotice, "", true, args...) }
[ "func", "(", "l", "*", "Logger", ")", "Notice", "(", "args", "...", "interface", "{", "}", ")", "{", "l", ".", "logf", "(", "l", ".", "app", ",", "logLevelNotice", ",", "\"", "\"", ",", "true", ",", "args", "...", ")", "\n", "}" ]
// Notice writes a notice message.
[ "Notice", "writes", "a", "notice", "message", "." ]
bbed90f29893482876cba9f5f50d750bd7e9fb45
https://github.com/tidwall/redlog/blob/bbed90f29893482876cba9f5f50d750bd7e9fb45/redlog.go#L224-L226
146,248
tidwall/redlog
redlog.go
Warning
func (l *Logger) Warning(args ...interface{}) { l.logf(l.app, logLevelWarning, "", true, args...) }
go
func (l *Logger) Warning(args ...interface{}) { l.logf(l.app, logLevelWarning, "", true, args...) }
[ "func", "(", "l", "*", "Logger", ")", "Warning", "(", "args", "...", "interface", "{", "}", ")", "{", "l", ".", "logf", "(", "l", ".", "app", ",", "logLevelWarning", ",", "\"", "\"", ",", "true", ",", "args", "...", ")", "\n", "}" ]
// Warning writes a warning message.
[ "Warning", "writes", "a", "warning", "message", "." ]
bbed90f29893482876cba9f5f50d750bd7e9fb45
https://github.com/tidwall/redlog/blob/bbed90f29893482876cba9f5f50d750bd7e9fb45/redlog.go#L229-L231
146,249
tidwall/redlog
redlog.go
Print
func (l *Logger) Print(args ...interface{}) { l.logf(l.app, logLevelNotice, "", true, args...) }
go
func (l *Logger) Print(args ...interface{}) { l.logf(l.app, logLevelNotice, "", true, args...) }
[ "func", "(", "l", "*", "Logger", ")", "Print", "(", "args", "...", "interface", "{", "}", ")", "{", "l", ".", "logf", "(", "l", ".", "app", ",", "logLevelNotice", ",", "\"", "\"", ",", "true", ",", "args", "...", ")", "\n", "}" ]
// Print writes a default message.
[ "Print", "writes", "a", "default", "message", "." ]
bbed90f29893482876cba9f5f50d750bd7e9fb45
https://github.com/tidwall/redlog/blob/bbed90f29893482876cba9f5f50d750bd7e9fb45/redlog.go#L240-L242
146,250
tidwall/redlog
redlog.go
Debugln
func (l *Logger) Debugln(args ...interface{}) { l.logf(l.app, logLevelDebug, "", true, args...) }
go
func (l *Logger) Debugln(args ...interface{}) { l.logf(l.app, logLevelDebug, "", true, args...) }
[ "func", "(", "l", "*", "Logger", ")", "Debugln", "(", "args", "...", "interface", "{", "}", ")", "{", "l", ".", "logf", "(", "l", ".", "app", ",", "logLevelDebug", ",", "\"", "\"", ",", "true", ",", "args", "...", ")", "\n", "}" ]
// Debugln writes a debug message.
[ "Debugln", "writes", "a", "debug", "message", "." ]
bbed90f29893482876cba9f5f50d750bd7e9fb45
https://github.com/tidwall/redlog/blob/bbed90f29893482876cba9f5f50d750bd7e9fb45/redlog.go#L245-L247
146,251
tidwall/redlog
redlog.go
Verboseln
func (l *Logger) Verboseln(args ...interface{}) { l.logf(l.app, logLevelVerbose, "", true, args...) }
go
func (l *Logger) Verboseln(args ...interface{}) { l.logf(l.app, logLevelVerbose, "", true, args...) }
[ "func", "(", "l", "*", "Logger", ")", "Verboseln", "(", "args", "...", "interface", "{", "}", ")", "{", "l", ".", "logf", "(", "l", ".", "app", ",", "logLevelVerbose", ",", "\"", "\"", ",", "true", ",", "args", "...", ")", "\n", "}" ]
// Verboseln writes a verbose message.
[ "Verboseln", "writes", "a", "verbose", "message", "." ]
bbed90f29893482876cba9f5f50d750bd7e9fb45
https://github.com/tidwall/redlog/blob/bbed90f29893482876cba9f5f50d750bd7e9fb45/redlog.go#L250-L252
146,252
tidwall/redlog
redlog.go
Noticeln
func (l *Logger) Noticeln(args ...interface{}) { l.logf(l.app, logLevelNotice, "", true, args...) }
go
func (l *Logger) Noticeln(args ...interface{}) { l.logf(l.app, logLevelNotice, "", true, args...) }
[ "func", "(", "l", "*", "Logger", ")", "Noticeln", "(", "args", "...", "interface", "{", "}", ")", "{", "l", ".", "logf", "(", "l", ".", "app", ",", "logLevelNotice", ",", "\"", "\"", ",", "true", ",", "args", "...", ")", "\n", "}" ]
// Noticeln writes a notice message.
[ "Noticeln", "writes", "a", "notice", "message", "." ]
bbed90f29893482876cba9f5f50d750bd7e9fb45
https://github.com/tidwall/redlog/blob/bbed90f29893482876cba9f5f50d750bd7e9fb45/redlog.go#L255-L257
146,253
tidwall/redlog
redlog.go
Warningln
func (l *Logger) Warningln(args ...interface{}) { l.logf(l.app, logLevelWarning, "", true, args...) }
go
func (l *Logger) Warningln(args ...interface{}) { l.logf(l.app, logLevelWarning, "", true, args...) }
[ "func", "(", "l", "*", "Logger", ")", "Warningln", "(", "args", "...", "interface", "{", "}", ")", "{", "l", ".", "logf", "(", "l", ".", "app", ",", "logLevelWarning", ",", "\"", "\"", ",", "true", ",", "args", "...", ")", "\n", "}" ]
// Warningln writes a warning message.
[ "Warningln", "writes", "a", "warning", "message", "." ]
bbed90f29893482876cba9f5f50d750bd7e9fb45
https://github.com/tidwall/redlog/blob/bbed90f29893482876cba9f5f50d750bd7e9fb45/redlog.go#L260-L262
146,254
tidwall/redlog
redlog.go
Fatalln
func (l *Logger) Fatalln(args ...interface{}) { l.logf(l.app, logLevelWarning, "", true, args...) os.Exit(1) }
go
func (l *Logger) Fatalln(args ...interface{}) { l.logf(l.app, logLevelWarning, "", true, args...) os.Exit(1) }
[ "func", "(", "l", "*", "Logger", ")", "Fatalln", "(", "args", "...", "interface", "{", "}", ")", "{", "l", ".", "logf", "(", "l", ".", "app", ",", "logLevelWarning", ",", "\"", "\"", ",", "true", ",", "args", "...", ")", "\n", "os", ".", "Exit"...
// Fatalln writes a warning message and exit process with exit code 1.
[ "Fatalln", "writes", "a", "warning", "message", "and", "exit", "process", "with", "exit", "code", "1", "." ]
bbed90f29893482876cba9f5f50d750bd7e9fb45
https://github.com/tidwall/redlog/blob/bbed90f29893482876cba9f5f50d750bd7e9fb45/redlog.go#L265-L268
146,255
tidwall/redlog
redlog.go
Println
func (l *Logger) Println(args ...interface{}) { l.logf(l.app, logLevelNotice, "", true, args...) }
go
func (l *Logger) Println(args ...interface{}) { l.logf(l.app, logLevelNotice, "", true, args...) }
[ "func", "(", "l", "*", "Logger", ")", "Println", "(", "args", "...", "interface", "{", "}", ")", "{", "l", ".", "logf", "(", "l", ".", "app", ",", "logLevelNotice", ",", "\"", "\"", ",", "true", ",", "args", "...", ")", "\n", "}" ]
// Println writes a default message.
[ "Println", "writes", "a", "default", "message", "." ]
bbed90f29893482876cba9f5f50d750bd7e9fb45
https://github.com/tidwall/redlog/blob/bbed90f29893482876cba9f5f50d750bd7e9fb45/redlog.go#L271-L273
146,256
tidwall/redlog
redlog.go
RedisLogColorizer
func RedisLogColorizer(wr io.Writer) io.Writer { if !istty(wr) { return wr } pr, pw := io.Pipe() go func() { rd := bufio.NewReader(pr) for { line, err := rd.ReadString('\n') if err != nil { return } parts := strings.Split(line, " ") if len(parts) > 5 { var color string switch parts[...
go
func RedisLogColorizer(wr io.Writer) io.Writer { if !istty(wr) { return wr } pr, pw := io.Pipe() go func() { rd := bufio.NewReader(pr) for { line, err := rd.ReadString('\n') if err != nil { return } parts := strings.Split(line, " ") if len(parts) > 5 { var color string switch parts[...
[ "func", "RedisLogColorizer", "(", "wr", "io", ".", "Writer", ")", "io", ".", "Writer", "{", "if", "!", "istty", "(", "wr", ")", "{", "return", "wr", "\n", "}", "\n", "pr", ",", "pw", ":=", "io", ".", "Pipe", "(", ")", "\n", "go", "func", "(", ...
// RedisLogColorizer filters the Redis log output and colorizes it.
[ "RedisLogColorizer", "filters", "the", "Redis", "log", "output", "and", "colorizes", "it", "." ]
bbed90f29893482876cba9f5f50d750bd7e9fb45
https://github.com/tidwall/redlog/blob/bbed90f29893482876cba9f5f50d750bd7e9fb45/redlog.go#L357-L392
146,257
tidwall/redlog
redlog.go
GoLogger
func (l *Logger) GoLogger() *log.Logger { rd, wr := io.Pipe() gl := log.New(wr, "", 0) go func() { brd := bufio.NewReader(rd) for { line, err := brd.ReadBytes('\n') if err != nil { continue } l.Printf("%s", line[:len(line)-1]) } }() return gl }
go
func (l *Logger) GoLogger() *log.Logger { rd, wr := io.Pipe() gl := log.New(wr, "", 0) go func() { brd := bufio.NewReader(rd) for { line, err := brd.ReadBytes('\n') if err != nil { continue } l.Printf("%s", line[:len(line)-1]) } }() return gl }
[ "func", "(", "l", "*", "Logger", ")", "GoLogger", "(", ")", "*", "log", ".", "Logger", "{", "rd", ",", "wr", ":=", "io", ".", "Pipe", "(", ")", "\n", "gl", ":=", "log", ".", "New", "(", "wr", ",", "\"", "\"", ",", "0", ")", "\n", "go", "f...
// GoLogger returns a standard Go log.Logger which when used, will print // in the Redlog format.
[ "GoLogger", "returns", "a", "standard", "Go", "log", ".", "Logger", "which", "when", "used", "will", "print", "in", "the", "Redlog", "format", "." ]
bbed90f29893482876cba9f5f50d750bd7e9fb45
https://github.com/tidwall/redlog/blob/bbed90f29893482876cba9f5f50d750bd7e9fb45/redlog.go#L396-L410
146,258
EverythingMe/go-disque
disqchan/disqchan.go
SendChan
func (c *Chan) SendChan() chan<- interface{} { c.mutx.Lock() defer c.mutx.Unlock() if c.sendch == nil { c.sendch = make(chan interface{}) go c.sendLoop() } return c.sendch }
go
func (c *Chan) SendChan() chan<- interface{} { c.mutx.Lock() defer c.mutx.Unlock() if c.sendch == nil { c.sendch = make(chan interface{}) go c.sendLoop() } return c.sendch }
[ "func", "(", "c", "*", "Chan", ")", "SendChan", "(", ")", "chan", "<-", "interface", "{", "}", "{", "c", ".", "mutx", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mutx", ".", "Unlock", "(", ")", "\n\n", "if", "c", ".", "sendch", "==", "ni...
// SendChan returns a channel to which objects can be sent
[ "SendChan", "returns", "a", "channel", "to", "which", "objects", "can", "be", "sent" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/disqchan/disqchan.go#L84-L94
146,259
EverythingMe/go-disque
disqchan/disqchan.go
RecvChan
func (c *Chan) RecvChan() <-chan interface{} { c.mutx.Lock() defer c.mutx.Unlock() if c.rcvch == nil { c.rcvch = make(chan interface{}) go c.receiveLoop() } return c.rcvch }
go
func (c *Chan) RecvChan() <-chan interface{} { c.mutx.Lock() defer c.mutx.Unlock() if c.rcvch == nil { c.rcvch = make(chan interface{}) go c.receiveLoop() } return c.rcvch }
[ "func", "(", "c", "*", "Chan", ")", "RecvChan", "(", ")", "<-", "chan", "interface", "{", "}", "{", "c", ".", "mutx", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mutx", ".", "Unlock", "(", ")", "\n", "if", "c", ".", "rcvch", "==", "nil",...
// RecvChan returns a channel from which received messages can be received. // // Before it is called, this Chan is not receiving from the queue
[ "RecvChan", "returns", "a", "channel", "from", "which", "received", "messages", "can", "be", "received", ".", "Before", "it", "is", "called", "this", "Chan", "is", "not", "receiving", "from", "the", "queue" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/disqchan/disqchan.go#L99-L107
146,260
EverythingMe/go-disque
tasque/worker.go
NewWorker
func NewWorker(numGoroutines int, addrs ...string) *Worker { pool := disque.NewPool(disque.DialFunc(func(addr string) (redis.Conn, error) { return redis.Dial("tcp", addr) }), addrs...) pool.RefreshNodes() pool.RunRefreshLoop() return &Worker{ pool: pool, numGoroutines: numGoroutines, workchan: ...
go
func NewWorker(numGoroutines int, addrs ...string) *Worker { pool := disque.NewPool(disque.DialFunc(func(addr string) (redis.Conn, error) { return redis.Dial("tcp", addr) }), addrs...) pool.RefreshNodes() pool.RunRefreshLoop() return &Worker{ pool: pool, numGoroutines: numGoroutines, workchan: ...
[ "func", "NewWorker", "(", "numGoroutines", "int", ",", "addrs", "...", "string", ")", "*", "Worker", "{", "pool", ":=", "disque", ".", "NewPool", "(", "disque", ".", "DialFunc", "(", "func", "(", "addr", "string", ")", "(", "redis", ".", "Conn", ",", ...
// Create a new worker that runs numGoroutines concurrently, connecting to disque addrs
[ "Create", "a", "new", "worker", "that", "runs", "numGoroutines", "concurrently", "connecting", "to", "disque", "addrs" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/tasque/worker.go#L26-L43
146,261
EverythingMe/go-disque
tasque/worker.go
Handle
func (w *Worker) Handle(h TaskHandler) { w.mutx.Lock() defer w.mutx.Unlock() w.handlers[h.Id()] = h w.channels = append(w.channels, qname(h.Id())) }
go
func (w *Worker) Handle(h TaskHandler) { w.mutx.Lock() defer w.mutx.Unlock() w.handlers[h.Id()] = h w.channels = append(w.channels, qname(h.Id())) }
[ "func", "(", "w", "*", "Worker", ")", "Handle", "(", "h", "TaskHandler", ")", "{", "w", ".", "mutx", ".", "Lock", "(", ")", "\n", "defer", "w", ".", "mutx", ".", "Unlock", "(", ")", "\n\n", "w", ".", "handlers", "[", "h", ".", "Id", "(", ")",...
// Register a task handler in the worker. This shoudl
[ "Register", "a", "task", "handler", "in", "the", "worker", ".", "This", "shoudl" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/tasque/worker.go#L46-L55
146,262
EverythingMe/go-disque
tasque/worker.go
runHandler
func (w *Worker) runHandler(h TaskHandler, t *Task) (err error) { defer func() { e := recover() if e != nil { err, _ = e.(error) log.Println("tasque: PANIC handling task: %s %s", t.Name, e) } }() err = h.Handle(t) return }
go
func (w *Worker) runHandler(h TaskHandler, t *Task) (err error) { defer func() { e := recover() if e != nil { err, _ = e.(error) log.Println("tasque: PANIC handling task: %s %s", t.Name, e) } }() err = h.Handle(t) return }
[ "func", "(", "w", "*", "Worker", ")", "runHandler", "(", "h", "TaskHandler", ",", "t", "*", "Task", ")", "(", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "e", ":=", "recover", "(", ")", "\n", "if", "e", "!=", "nil", "{", "err", ...
// runHandler safely wraps running a single task in a handler
[ "runHandler", "safely", "wraps", "running", "a", "single", "task", "in", "a", "handler" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/tasque/worker.go#L67-L79
146,263
EverythingMe/go-disque
tasque/worker.go
handlerLoop
func (w *Worker) handlerLoop() { for task := range w.workchan { handler, found := w.getHandler(task) if !found { log.Printf("tasque: ERROR no handler for task %s", task.Name) continue } // call a safe runner func err := w.runHandler(handler, task) if err != nil { log.Println("tasque: Error handl...
go
func (w *Worker) handlerLoop() { for task := range w.workchan { handler, found := w.getHandler(task) if !found { log.Printf("tasque: ERROR no handler for task %s", task.Name) continue } // call a safe runner func err := w.runHandler(handler, task) if err != nil { log.Println("tasque: Error handl...
[ "func", "(", "w", "*", "Worker", ")", "handlerLoop", "(", ")", "{", "for", "task", ":=", "range", "w", ".", "workchan", "{", "handler", ",", "found", ":=", "w", ".", "getHandler", "(", "task", ")", "\n", "if", "!", "found", "{", "log", ".", "Prin...
// a single worker loop
[ "a", "single", "worker", "loop" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/tasque/worker.go#L82-L106
146,264
EverythingMe/go-disque
tasque/worker.go
Run
func (w *Worker) Run() { // TODO: make this dynamic for i := 0; i < w.numGoroutines; i++ { log.Println("Starting handler routine ", i+1) go w.handlerLoop() } for { client, err := w.pool.Get() defer client.Close() if err != nil { log.Println("tasque: could not get client") select { case <-w.stop...
go
func (w *Worker) Run() { // TODO: make this dynamic for i := 0; i < w.numGoroutines; i++ { log.Println("Starting handler routine ", i+1) go w.handlerLoop() } for { client, err := w.pool.Get() defer client.Close() if err != nil { log.Println("tasque: could not get client") select { case <-w.stop...
[ "func", "(", "w", "*", "Worker", ")", "Run", "(", ")", "{", "// TODO: make this dynamic", "for", "i", ":=", "0", ";", "i", "<", "w", ".", "numGoroutines", ";", "i", "++", "{", "log", ".", "Println", "(", "\"", "\"", ",", "i", "+", "1", ")", "\n...
// Run starts the worker and makes it request jobs
[ "Run", "starts", "the", "worker", "and", "makes", "it", "request", "jobs" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/tasque/worker.go#L115-L171
146,265
EverythingMe/go-disque
disque/pool.go
selectNode
func (p *Pool) selectNode(selected nodeList) (Node, error) { defer scopedLock(&p.mutx)() if len(p.nodes) == 0 { return Node{}, errors.New("disque: no nodes in pool") } nodes := nodeList{} for _, node := range p.nodes { if node.Priority <= maxPriority && !selected.contains(node) { nodes = append(nodes, no...
go
func (p *Pool) selectNode(selected nodeList) (Node, error) { defer scopedLock(&p.mutx)() if len(p.nodes) == 0 { return Node{}, errors.New("disque: no nodes in pool") } nodes := nodeList{} for _, node := range p.nodes { if node.Priority <= maxPriority && !selected.contains(node) { nodes = append(nodes, no...
[ "func", "(", "p", "*", "Pool", ")", "selectNode", "(", "selected", "nodeList", ")", "(", "Node", ",", "error", ")", "{", "defer", "scopedLock", "(", "&", "p", ".", "mutx", ")", "(", ")", "\n\n", "if", "len", "(", "p", ".", "nodes", ")", "==", "...
// selectNode select a valid node by random. Currently only nodes with priority 1 are selected
[ "selectNode", "select", "a", "valid", "node", "by", "random", ".", "Currently", "only", "nodes", "with", "priority", "1", "are", "selected" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/disque/pool.go#L97-L117
146,266
EverythingMe/go-disque
disque/pool.go
getPool
func (p *Pool) getPool(addr string) *redis.Pool { defer scopedLock(&p.mutx)() pool, found := p.pools[addr] if !found { pool = redis.NewPool(func() (redis.Conn, error) { return p.dialFunc(addr) }, maxIdle) pool.TestOnBorrow = func(c redis.Conn, t time.Time) error { // for testing - count how many borr...
go
func (p *Pool) getPool(addr string) *redis.Pool { defer scopedLock(&p.mutx)() pool, found := p.pools[addr] if !found { pool = redis.NewPool(func() (redis.Conn, error) { return p.dialFunc(addr) }, maxIdle) pool.TestOnBorrow = func(c redis.Conn, t time.Time) error { // for testing - count how many borr...
[ "func", "(", "p", "*", "Pool", ")", "getPool", "(", "addr", "string", ")", "*", "redis", ".", "Pool", "{", "defer", "scopedLock", "(", "&", "p", ".", "mutx", ")", "(", ")", "\n\n", "pool", ",", "found", ":=", "p", ".", "pools", "[", "addr", "]"...
// getPool returns a redis connection pool for a given address
[ "getPool", "returns", "a", "redis", "connection", "pool", "for", "a", "given", "address" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/disque/pool.go#L126-L152
146,267
EverythingMe/go-disque
disque/pool.go
Close
func (p *Pool) Close() error { defer scopedLock(&p.mutx)() var err error for _, pool := range p.pools { if e := pool.Close(); e != nil { err = e } } return err }
go
func (p *Pool) Close() error { defer scopedLock(&p.mutx)() var err error for _, pool := range p.pools { if e := pool.Close(); e != nil { err = e } } return err }
[ "func", "(", "p", "*", "Pool", ")", "Close", "(", ")", "error", "{", "defer", "scopedLock", "(", "&", "p", ".", "mutx", ")", "(", ")", "\n\n", "var", "err", "error", "\n", "for", "_", ",", "pool", ":=", "range", "p", ".", "pools", "{", "if", ...
// Close closes all pools
[ "Close", "closes", "all", "pools" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/disque/pool.go#L155-L165
146,268
EverythingMe/go-disque
disque/pool.go
Get
func (p *Pool) Get() (Client, error) { selected := nodeList{} var node Node var err error // select node to connect to for { node, err = p.selectNode(selected) if err != nil { return nil, err } conn := p.getPool(node.Addr).Get() if conn.Err() != nil { selected = append(selected, node) continue...
go
func (p *Pool) Get() (Client, error) { selected := nodeList{} var node Node var err error // select node to connect to for { node, err = p.selectNode(selected) if err != nil { return nil, err } conn := p.getPool(node.Addr).Get() if conn.Err() != nil { selected = append(selected, node) continue...
[ "func", "(", "p", "*", "Pool", ")", "Get", "(", ")", "(", "Client", ",", "error", ")", "{", "selected", ":=", "nodeList", "{", "}", "\n", "var", "node", "Node", "\n", "var", "err", "error", "\n", "// select node to connect to", "for", "{", "node", ",...
// Get returns a client, or an error if we could not init one
[ "Get", "returns", "a", "client", "or", "an", "error", "if", "we", "could", "not", "init", "one" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/disque/pool.go#L168-L192
146,269
EverythingMe/go-disque
disque/pool.go
UpdateNodes
func (p *Pool) UpdateNodes(nodes nodeList) { defer scopedLock(&p.mutx)() p.nodes = nodes }
go
func (p *Pool) UpdateNodes(nodes nodeList) { defer scopedLock(&p.mutx)() p.nodes = nodes }
[ "func", "(", "p", "*", "Pool", ")", "UpdateNodes", "(", "nodes", "nodeList", ")", "{", "defer", "scopedLock", "(", "&", "p", ".", "mutx", ")", "(", ")", "\n", "p", ".", "nodes", "=", "nodes", "\n", "}" ]
// UpdateNodes explicitly sets the nodes of the pool
[ "UpdateNodes", "explicitly", "sets", "the", "nodes", "of", "the", "pool" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/disque/pool.go#L195-L198
146,270
EverythingMe/go-disque
disque/pool.go
RefreshNodes
func (p *Pool) RefreshNodes() error { client, err := p.Get() if err != nil { return err } defer client.Close() resp, err := client.Hello() if err != nil { return err } // update the node list based on the hello response p.UpdateNodes(resp.Nodes) return nil }
go
func (p *Pool) RefreshNodes() error { client, err := p.Get() if err != nil { return err } defer client.Close() resp, err := client.Hello() if err != nil { return err } // update the node list based on the hello response p.UpdateNodes(resp.Nodes) return nil }
[ "func", "(", "p", "*", "Pool", ")", "RefreshNodes", "(", ")", "error", "{", "client", ",", "err", ":=", "p", ".", "Get", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "client", ".", "Close", "(", ")",...
// RefreshNodes uses a HELLO call to refresh the node list in the cluster
[ "RefreshNodes", "uses", "a", "HELLO", "call", "to", "refresh", "the", "node", "list", "in", "the", "cluster" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/disque/pool.go#L201-L216
146,271
EverythingMe/go-disque
disque/pool.go
RunRefreshLoop
func (p *Pool) RunRefreshLoop() { go func() { for range time.Tick(refreshFrequency) { err := p.RefreshNodes() if err != nil { log.Println("disque pool: could not select client for refreshing") } } }() }
go
func (p *Pool) RunRefreshLoop() { go func() { for range time.Tick(refreshFrequency) { err := p.RefreshNodes() if err != nil { log.Println("disque pool: could not select client for refreshing") } } }() }
[ "func", "(", "p", "*", "Pool", ")", "RunRefreshLoop", "(", ")", "{", "go", "func", "(", ")", "{", "for", "range", "time", ".", "Tick", "(", "refreshFrequency", ")", "{", "err", ":=", "p", ".", "RefreshNodes", "(", ")", "\n", "if", "err", "!=", "n...
// RunRefreshLoop starts a goroutine that periodically refreshes the node list using HELLO
[ "RunRefreshLoop", "starts", "a", "goroutine", "that", "periodically", "refreshes", "the", "node", "list", "using", "HELLO" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/disque/pool.go#L219-L232
146,272
EverythingMe/go-disque
tasque/client.go
NewClient
func NewClient(enqueueTimeout time.Duration, addrs ...string) *Client { pool := disque.NewPool(disque.DialFunc(func(addr string) (redis.Conn, error) { return redis.DialTimeout("tcp", addr, enqueueTimeout, enqueueTimeout, enqueueTimeout) }), addrs...) pool.RefreshNodes() pool.RunRefreshLoop() return &Client{ ...
go
func NewClient(enqueueTimeout time.Duration, addrs ...string) *Client { pool := disque.NewPool(disque.DialFunc(func(addr string) (redis.Conn, error) { return redis.DialTimeout("tcp", addr, enqueueTimeout, enqueueTimeout, enqueueTimeout) }), addrs...) pool.RefreshNodes() pool.RunRefreshLoop() return &Client{ ...
[ "func", "NewClient", "(", "enqueueTimeout", "time", ".", "Duration", ",", "addrs", "...", "string", ")", "*", "Client", "{", "pool", ":=", "disque", ".", "NewPool", "(", "disque", ".", "DialFunc", "(", "func", "(", "addr", "string", ")", "(", "redis", ...
// Create a new client for the given disque addrs. enqueueTimeout is the amount of time after which // we fail
[ "Create", "a", "new", "client", "for", "the", "given", "disque", "addrs", ".", "enqueueTimeout", "is", "the", "amount", "of", "time", "after", "which", "we", "fail" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/tasque/client.go#L20-L34
146,273
EverythingMe/go-disque
tasque/client.go
Delay
func (c *Client) Delay(t *Task, delay time.Duration) error { client, err := c.pool.Get() if err != nil { return err } defer client.Close() b, err := t.marshal() if err != nil { return fmt.Errorf("Could not marshal task: %s", err) } ar := disque.AddRequest{ Job: disque.Job{ Queue: qname(t.Name), ...
go
func (c *Client) Delay(t *Task, delay time.Duration) error { client, err := c.pool.Get() if err != nil { return err } defer client.Close() b, err := t.marshal() if err != nil { return fmt.Errorf("Could not marshal task: %s", err) } ar := disque.AddRequest{ Job: disque.Job{ Queue: qname(t.Name), ...
[ "func", "(", "c", "*", "Client", ")", "Delay", "(", "t", "*", "Task", ",", "delay", "time", ".", "Duration", ")", "error", "{", "client", ",", "err", ":=", "c", ".", "pool", ".", "Get", "(", ")", "\n\n", "if", "err", "!=", "nil", "{", "return",...
// Delay puts the task in the queue for execution after the delay period of time. // This also sets the jobId of the task
[ "Delay", "puts", "the", "task", "in", "the", "queue", "for", "execution", "after", "the", "delay", "period", "of", "time", ".", "This", "also", "sets", "the", "jobId", "of", "the", "task" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/tasque/client.go#L47-L76
146,274
EverythingMe/go-disque
disque/disque.go
Add
func (c *RedisClient) Add(r AddRequest) (string, error) { //ADDJOB queue_name job <ms-timeout> [REPLICATE <count>] [DELAY <sec>] [RETRY <sec>] [TTL <sec>] [MAXLEN <count>] [ASYNC] id, err := redis.String(c.conn.Do("ADDJOB", addArgs(r)...)) if err != nil { return "", errors.New("disque: could not add job: " + err....
go
func (c *RedisClient) Add(r AddRequest) (string, error) { //ADDJOB queue_name job <ms-timeout> [REPLICATE <count>] [DELAY <sec>] [RETRY <sec>] [TTL <sec>] [MAXLEN <count>] [ASYNC] id, err := redis.String(c.conn.Do("ADDJOB", addArgs(r)...)) if err != nil { return "", errors.New("disque: could not add job: " + err....
[ "func", "(", "c", "*", "RedisClient", ")", "Add", "(", "r", "AddRequest", ")", "(", "string", ",", "error", ")", "{", "//ADDJOB queue_name job <ms-timeout> [REPLICATE <count>] [DELAY <sec>] [RETRY <sec>] [TTL <sec>] [MAXLEN <count>] [ASYNC]", "id", ",", "err", ":=", "redi...
// Add sents an ADDJOB command to disque, as specified by the AddRequest. Returns the job id or an error
[ "Add", "sents", "an", "ADDJOB", "command", "to", "disque", "as", "specified", "by", "the", "AddRequest", ".", "Returns", "the", "job", "id", "or", "an", "error" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/disque/disque.go#L101-L109
146,275
EverythingMe/go-disque
disque/disque.go
AddMulti
func (c *RedisClient) AddMulti(rs []AddRequest) ([]string, error) { for _, r := range rs { if err := c.conn.Send("ADDJOB", addArgs(r)...); err != nil { return nil, err } } // flush the output buffer and receive pending replies replies, err := redis.Values(c.conn.Do("")) ids := make([]string, len(replies)) ...
go
func (c *RedisClient) AddMulti(rs []AddRequest) ([]string, error) { for _, r := range rs { if err := c.conn.Send("ADDJOB", addArgs(r)...); err != nil { return nil, err } } // flush the output buffer and receive pending replies replies, err := redis.Values(c.conn.Do("")) ids := make([]string, len(replies)) ...
[ "func", "(", "c", "*", "RedisClient", ")", "AddMulti", "(", "rs", "[", "]", "AddRequest", ")", "(", "[", "]", "string", ",", "error", ")", "{", "for", "_", ",", "r", ":=", "range", "rs", "{", "if", "err", ":=", "c", ".", "conn", ".", "Send", ...
// AddMulti sends multiple ADDJOB in pipeline
[ "AddMulti", "sends", "multiple", "ADDJOB", "in", "pipeline" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/disque/disque.go#L112-L127
146,276
EverythingMe/go-disque
disque/disque.go
addArgs
func addArgs(r AddRequest) redis.Args { args := redis.Args{r.Job.Queue, r.Job.Data, int(r.Timeout / time.Millisecond)} if r.Replicate > 0 { args = args.Add("REPLICATE", r.Replicate) } if r.Delay > 0 { args = args.Add("DELAY", int64(r.Delay.Seconds())) } if r.Retry > 0 { args = args.Add("RETRY", int64(r.R...
go
func addArgs(r AddRequest) redis.Args { args := redis.Args{r.Job.Queue, r.Job.Data, int(r.Timeout / time.Millisecond)} if r.Replicate > 0 { args = args.Add("REPLICATE", r.Replicate) } if r.Delay > 0 { args = args.Add("DELAY", int64(r.Delay.Seconds())) } if r.Retry > 0 { args = args.Add("RETRY", int64(r.R...
[ "func", "addArgs", "(", "r", "AddRequest", ")", "redis", ".", "Args", "{", "args", ":=", "redis", ".", "Args", "{", "r", ".", "Job", ".", "Queue", ",", "r", ".", "Job", ".", "Data", ",", "int", "(", "r", ".", "Timeout", "/", "time", ".", "Milli...
// builds ADDJOB args
[ "builds", "ADDJOB", "args" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/disque/disque.go#L130-L157
146,277
EverythingMe/go-disque
disque/disque.go
Get
func (c *RedisClient) Get(timeout time.Duration, queues ...string) (Job, error) { ret, err := c.GetMulti(0, timeout, queues...) if err != nil { return Job{}, err } if ret == nil || len(ret) == 0 { return Job{}, errors.New("disque: no jobs returned") } return ret[0], nil }
go
func (c *RedisClient) Get(timeout time.Duration, queues ...string) (Job, error) { ret, err := c.GetMulti(0, timeout, queues...) if err != nil { return Job{}, err } if ret == nil || len(ret) == 0 { return Job{}, errors.New("disque: no jobs returned") } return ret[0], nil }
[ "func", "(", "c", "*", "RedisClient", ")", "Get", "(", "timeout", "time", ".", "Duration", ",", "queues", "...", "string", ")", "(", "Job", ",", "error", ")", "{", "ret", ",", "err", ":=", "c", ".", "GetMulti", "(", "0", ",", "timeout", ",", "que...
// Get gets one job from any of the given queues, or times out if timeout has elapsed without a job being available. // Returns a job or an error
[ "Get", "gets", "one", "job", "from", "any", "of", "the", "given", "queues", "or", "times", "out", "if", "timeout", "has", "elapsed", "without", "a", "job", "being", "available", ".", "Returns", "a", "job", "or", "an", "error" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/disque/disque.go#L161-L172
146,278
EverythingMe/go-disque
disque/disque.go
Ack
func (c *RedisClient) Ack(jobIds ...string) error { args := make(redis.Args, 0, len(jobIds)) args = args.AddFlat(jobIds) if _, err := c.conn.Do("ACKJOB", args...); err != nil { return fmt.Errorf("disque: error sending ACK: %s", err) } return nil }
go
func (c *RedisClient) Ack(jobIds ...string) error { args := make(redis.Args, 0, len(jobIds)) args = args.AddFlat(jobIds) if _, err := c.conn.Do("ACKJOB", args...); err != nil { return fmt.Errorf("disque: error sending ACK: %s", err) } return nil }
[ "func", "(", "c", "*", "RedisClient", ")", "Ack", "(", "jobIds", "...", "string", ")", "error", "{", "args", ":=", "make", "(", "redis", ".", "Args", ",", "0", ",", "len", "(", "jobIds", ")", ")", "\n", "args", "=", "args", ".", "AddFlat", "(", ...
// Ack sends and ACKJOB command with the given job ids
[ "Ack", "sends", "and", "ACKJOB", "command", "with", "the", "given", "job", "ids" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/disque/disque.go#L221-L229
146,279
EverythingMe/go-disque
disque/disque.go
Qlen
func (c *RedisClient) Qlen(qname string) (int, error) { return redis.Int(c.conn.Do("QLEN", qname)) }
go
func (c *RedisClient) Qlen(qname string) (int, error) { return redis.Int(c.conn.Do("QLEN", qname)) }
[ "func", "(", "c", "*", "RedisClient", ")", "Qlen", "(", "qname", "string", ")", "(", "int", ",", "error", ")", "{", "return", "redis", ".", "Int", "(", "c", ".", "conn", ".", "Do", "(", "\"", "\"", ",", "qname", ")", ")", "\n\n", "}" ]
// Qlen returns the length of a given queue
[ "Qlen", "returns", "the", "length", "of", "a", "given", "queue" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/disque/disque.go#L243-L247
146,280
EverythingMe/go-disque
disque/disque.go
Enqueue
func (c *RedisClient) Enqueue(jobIds ...string) error { args := redis.Args{} args.AddFlat(jobIds) _, err := c.conn.Do("ENQUEUE", args) return err }
go
func (c *RedisClient) Enqueue(jobIds ...string) error { args := redis.Args{} args.AddFlat(jobIds) _, err := c.conn.Do("ENQUEUE", args) return err }
[ "func", "(", "c", "*", "RedisClient", ")", "Enqueue", "(", "jobIds", "...", "string", ")", "error", "{", "args", ":=", "redis", ".", "Args", "{", "}", "\n", "args", ".", "AddFlat", "(", "jobIds", ")", "\n", "_", ",", "err", ":=", "c", ".", "conn"...
// Enqueue an already existing job by jobId. This can be used for fast retries
[ "Enqueue", "an", "already", "existing", "job", "by", "jobId", ".", "This", "can", "be", "used", "for", "fast", "retries" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/disque/disque.go#L250-L256
146,281
EverythingMe/go-disque
tasque/tasque.go
NewTask
func NewTask(id string) *Task { return &Task{ Name: id, Params: make(map[string]interface{}), } }
go
func NewTask(id string) *Task { return &Task{ Name: id, Params: make(map[string]interface{}), } }
[ "func", "NewTask", "(", "id", "string", ")", "*", "Task", "{", "return", "&", "Task", "{", "Name", ":", "id", ",", "Params", ":", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", ",", "}", "\n", "}" ]
// Create a new task with a given id
[ "Create", "a", "new", "task", "with", "a", "given", "id" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/tasque/tasque.go#L37-L42
146,282
EverythingMe/go-disque
tasque/tasque.go
Set
func (t *Task) Set(k string, v interface{}) *Task { t.Params[k] = v return t }
go
func (t *Task) Set(k string, v interface{}) *Task { t.Params[k] = v return t }
[ "func", "(", "t", "*", "Task", ")", "Set", "(", "k", "string", ",", "v", "interface", "{", "}", ")", "*", "Task", "{", "t", ".", "Params", "[", "k", "]", "=", "v", "\n", "return", "t", "\n", "}" ]
// Set a property in the task
[ "Set", "a", "property", "in", "the", "task" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/tasque/tasque.go#L45-L48
146,283
EverythingMe/go-disque
tasque/tasque.go
SetTTL
func (t *Task) SetTTL(ttl time.Duration) *Task { t.ttl = ttl return t }
go
func (t *Task) SetTTL(ttl time.Duration) *Task { t.ttl = ttl return t }
[ "func", "(", "t", "*", "Task", ")", "SetTTL", "(", "ttl", "time", ".", "Duration", ")", "*", "Task", "{", "t", ".", "ttl", "=", "ttl", "\n", "return", "t", "\n", "}" ]
// Set the task TTL - if it will not succeed after this time, disque will give up on it
[ "Set", "the", "task", "TTL", "-", "if", "it", "will", "not", "succeed", "after", "this", "time", "disque", "will", "give", "up", "on", "it" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/tasque/tasque.go#L51-L54
146,284
EverythingMe/go-disque
tasque/tasque.go
SetRetry
func (t *Task) SetRetry(d time.Duration) *Task { t.retry = d return t }
go
func (t *Task) SetRetry(d time.Duration) *Task { t.retry = d return t }
[ "func", "(", "t", "*", "Task", ")", "SetRetry", "(", "d", "time", ".", "Duration", ")", "*", "Task", "{", "t", ".", "retry", "=", "d", "\n", "return", "t", "\n", "}" ]
// Set the retry timeout. This must be greater than 1. If the worker does not ACK the task in this timeout, // disque will try to re-queue it
[ "Set", "the", "retry", "timeout", ".", "This", "must", "be", "greater", "than", "1", ".", "If", "the", "worker", "does", "not", "ACK", "the", "task", "in", "this", "timeout", "disque", "will", "try", "to", "re", "-", "queue", "it" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/tasque/tasque.go#L58-L61
146,285
EverythingMe/go-disque
tasque/tasque.go
Delay
func (t *Task) Delay(c *Client, d time.Duration) error { return c.Delay(t, d) }
go
func (t *Task) Delay(c *Client, d time.Duration) error { return c.Delay(t, d) }
[ "func", "(", "t", "*", "Task", ")", "Delay", "(", "c", "*", "Client", ",", "d", "time", ".", "Duration", ")", "error", "{", "return", "c", ".", "Delay", "(", "t", ",", "d", ")", "\n", "}" ]
// Delay executes the task, delayed for d duration
[ "Delay", "executes", "the", "task", "delayed", "for", "d", "duration" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/tasque/tasque.go#L69-L71
146,286
EverythingMe/go-disque
tasque/tasque.go
FuncHandler
func FuncHandler(f func(*Task) error, id string) FuncTaskHandler { return FuncTaskHandler{ f: f, id: id, } }
go
func FuncHandler(f func(*Task) error, id string) FuncTaskHandler { return FuncTaskHandler{ f: f, id: id, } }
[ "func", "FuncHandler", "(", "f", "func", "(", "*", "Task", ")", "error", ",", "id", "string", ")", "FuncTaskHandler", "{", "return", "FuncTaskHandler", "{", "f", ":", "f", ",", "id", ":", "id", ",", "}", "\n", "}" ]
// FuncHandler takes a func and its id and converts them into a FuncTaskHandler
[ "FuncHandler", "takes", "a", "func", "and", "its", "id", "and", "converts", "them", "into", "a", "FuncTaskHandler" ]
5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d
https://github.com/EverythingMe/go-disque/blob/5d0e3c9dd5366e0b4cb3bcab50cb4ae4f4dcf68d/tasque/tasque.go#L96-L101
146,287
wangjohn/quickselect
quickselect.go
IntQuickSelect
func IntQuickSelect(data []int, k int) error { return QuickSelect(IntSlice(data), k) }
go
func IntQuickSelect(data []int, k int) error { return QuickSelect(IntSlice(data), k) }
[ "func", "IntQuickSelect", "(", "data", "[", "]", "int", ",", "k", "int", ")", "error", "{", "return", "QuickSelect", "(", "IntSlice", "(", "data", ")", ",", "k", ")", "\n", "}" ]
// IntQuickSelect mutates the data so that the first k elements in the int // slice are the k smallest elements in the slice. This is a convenience // method for QuickSelect on int slices.
[ "IntQuickSelect", "mutates", "the", "data", "so", "that", "the", "first", "k", "elements", "in", "the", "int", "slice", "are", "the", "k", "smallest", "elements", "in", "the", "slice", ".", "This", "is", "a", "convenience", "method", "for", "QuickSelect", ...
ed8402a42d5f52ff8d3369f179e12243906f298a
https://github.com/wangjohn/quickselect/blob/ed8402a42d5f52ff8d3369f179e12243906f298a/quickselect.go#L328-L330
146,288
wangjohn/quickselect
quickselect.go
Float64QuickSelect
func Float64QuickSelect(data []float64, k int) error { return QuickSelect(Float64Slice(data), k) }
go
func Float64QuickSelect(data []float64, k int) error { return QuickSelect(Float64Slice(data), k) }
[ "func", "Float64QuickSelect", "(", "data", "[", "]", "float64", ",", "k", "int", ")", "error", "{", "return", "QuickSelect", "(", "Float64Slice", "(", "data", ")", ",", "k", ")", "\n", "}" ]
// Float64Select mutates the data so that the first k elements in the float64 // slice are the k smallest elements in the slice. This is a convenience // method for QuickSelect on float64 slices.
[ "Float64Select", "mutates", "the", "data", "so", "that", "the", "first", "k", "elements", "in", "the", "float64", "slice", "are", "the", "k", "smallest", "elements", "in", "the", "slice", ".", "This", "is", "a", "convenience", "method", "for", "QuickSelect",...
ed8402a42d5f52ff8d3369f179e12243906f298a
https://github.com/wangjohn/quickselect/blob/ed8402a42d5f52ff8d3369f179e12243906f298a/quickselect.go#L335-L337
146,289
wangjohn/quickselect
quickselect.go
StringQuickSelect
func StringQuickSelect(data []string, k int) error { return QuickSelect(StringSlice(data), k) }
go
func StringQuickSelect(data []string, k int) error { return QuickSelect(StringSlice(data), k) }
[ "func", "StringQuickSelect", "(", "data", "[", "]", "string", ",", "k", "int", ")", "error", "{", "return", "QuickSelect", "(", "StringSlice", "(", "data", ")", ",", "k", ")", "\n", "}" ]
// StringQuickSelect mutates the data so that the first k elements in the string // slice are the k smallest elements in the slice. This is a convenience // method for QuickSelect on string slices.
[ "StringQuickSelect", "mutates", "the", "data", "so", "that", "the", "first", "k", "elements", "in", "the", "string", "slice", "are", "the", "k", "smallest", "elements", "in", "the", "slice", ".", "This", "is", "a", "convenience", "method", "for", "QuickSelec...
ed8402a42d5f52ff8d3369f179e12243906f298a
https://github.com/wangjohn/quickselect/blob/ed8402a42d5f52ff8d3369f179e12243906f298a/quickselect.go#L342-L344
146,290
getlantern/ops
ops.go
RegisterReporter
func RegisterReporter(reporter Reporter) { reportersMutex.Lock() reporters = append(reporters, reporter) reportersMutex.Unlock() }
go
func RegisterReporter(reporter Reporter) { reportersMutex.Lock() reporters = append(reporters, reporter) reportersMutex.Unlock() }
[ "func", "RegisterReporter", "(", "reporter", "Reporter", ")", "{", "reportersMutex", ".", "Lock", "(", ")", "\n", "reporters", "=", "append", "(", "reporters", ",", "reporter", ")", "\n", "reportersMutex", ".", "Unlock", "(", ")", "\n", "}" ]
// RegisterReporter registers the given reporter.
[ "RegisterReporter", "registers", "the", "given", "reporter", "." ]
d70cb0d6f85f5066bcf4d693721f382e075b9366
https://github.com/getlantern/ops/blob/d70cb0d6f85f5066bcf4d693721f382e075b9366/ops.go#L62-L66
146,291
getlantern/ops
ops.go
Begin
func Begin(name string) Op { return &op{ctx: cm.Enter().Put("op", name).PutIfAbsent("root_op", name)} }
go
func Begin(name string) Op { return &op{ctx: cm.Enter().Put("op", name).PutIfAbsent("root_op", name)} }
[ "func", "Begin", "(", "name", "string", ")", "Op", "{", "return", "&", "op", "{", "ctx", ":", "cm", ".", "Enter", "(", ")", ".", "Put", "(", "\"", "\"", ",", "name", ")", ".", "PutIfAbsent", "(", "\"", "\"", ",", "name", ")", "}", "\n", "}" ]
// Begin marks the beginning of a new Op.
[ "Begin", "marks", "the", "beginning", "of", "a", "new", "Op", "." ]
d70cb0d6f85f5066bcf4d693721f382e075b9366
https://github.com/getlantern/ops/blob/d70cb0d6f85f5066bcf4d693721f382e075b9366/ops.go#L69-L71
146,292
getlantern/ops
ops.go
AsMap
func AsMap(obj interface{}, includeGlobals bool) context.Map { return cm.AsMap(obj, includeGlobals) }
go
func AsMap(obj interface{}, includeGlobals bool) context.Map { return cm.AsMap(obj, includeGlobals) }
[ "func", "AsMap", "(", "obj", "interface", "{", "}", ",", "includeGlobals", "bool", ")", "context", ".", "Map", "{", "return", "cm", ".", "AsMap", "(", "obj", ",", "includeGlobals", ")", "\n", "}" ]
// AsMap mimics the method from context.Manager.
[ "AsMap", "mimics", "the", "method", "from", "context", ".", "Manager", "." ]
d70cb0d6f85f5066bcf4d693721f382e075b9366
https://github.com/getlantern/ops/blob/d70cb0d6f85f5066bcf4d693721f382e075b9366/ops.go#L145-L147
146,293
Bren2010/proquint
proquint.go
IsProquint
func IsProquint(str string) (bool, error) { exp := "^([abdfghijklmnoprstuvz]{5}-)*[abdfghijklmnoprstuvz]{5}$" ok, err := regexp.MatchString(exp, str) return ok, err }
go
func IsProquint(str string) (bool, error) { exp := "^([abdfghijklmnoprstuvz]{5}-)*[abdfghijklmnoprstuvz]{5}$" ok, err := regexp.MatchString(exp, str) return ok, err }
[ "func", "IsProquint", "(", "str", "string", ")", "(", "bool", ",", "error", ")", "{", "exp", ":=", "\"", "\"", "\n", "ok", ",", "err", ":=", "regexp", ".", "MatchString", "(", "exp", ",", "str", ")", "\n", "return", "ok", ",", "err", "\n", "}" ]
/** * Tests if a given string is a Proquint identifier * * @param {string} str The candidate string. * * @return {bool} Whether or not it qualifies. * @return {error} Error */
[ "Tests", "if", "a", "given", "string", "is", "a", "Proquint", "identifier" ]
38337c27106d8f06e9b5cddc6df973ceece1c8ea
https://github.com/Bren2010/proquint/blob/38337c27106d8f06e9b5cddc6df973ceece1c8ea/proquint.go#L56-L61
146,294
Bren2010/proquint
proquint.go
Encode
func Encode(buf []byte) string { var out bytes.Buffer for i := 0; i < len(buf); i = i + 2 { var n uint16 = (uint16(buf[i]) * 256) + uint16(buf[i + 1]) var ( c1 = n & 0x0f v1 = (n >> 4) & 0x03 c2 = (n >> 6) & 0x0f v2 = (n >> ...
go
func Encode(buf []byte) string { var out bytes.Buffer for i := 0; i < len(buf); i = i + 2 { var n uint16 = (uint16(buf[i]) * 256) + uint16(buf[i + 1]) var ( c1 = n & 0x0f v1 = (n >> 4) & 0x03 c2 = (n >> 6) & 0x0f v2 = (n >> ...
[ "func", "Encode", "(", "buf", "[", "]", "byte", ")", "string", "{", "var", "out", "bytes", ".", "Buffer", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "buf", ")", ";", "i", "=", "i", "+", "2", "{", "var", "n", "uint16", "=", "(",...
/** * Encodes an arbitrary byte slice into an identifier. * * @param {[]byte} buf Slice of bytes to encode. * * @return {string} The given byte slice as an identifier. */
[ "Encodes", "an", "arbitrary", "byte", "slice", "into", "an", "identifier", "." ]
38337c27106d8f06e9b5cddc6df973ceece1c8ea
https://github.com/Bren2010/proquint/blob/38337c27106d8f06e9b5cddc6df973ceece1c8ea/proquint.go#L70-L96
146,295
Bren2010/proquint
proquint.go
Decode
func Decode(str string) []byte { var ( out bytes.Buffer bits []string = strings.Split(str, "-") ) for i := 0; i < len(bits); i++ { var x uint16 = consd[bits[i][0]] + (vowsd[bits[i][1]] << 4) + (consd[bits[i][2]] << 6) + (vowsd[bi...
go
func Decode(str string) []byte { var ( out bytes.Buffer bits []string = strings.Split(str, "-") ) for i := 0; i < len(bits); i++ { var x uint16 = consd[bits[i][0]] + (vowsd[bits[i][1]] << 4) + (consd[bits[i][2]] << 6) + (vowsd[bi...
[ "func", "Decode", "(", "str", "string", ")", "[", "]", "byte", "{", "var", "(", "out", "bytes", ".", "Buffer", "\n", "bits", "[", "]", "string", "=", "strings", ".", "Split", "(", "str", ",", "\"", "\"", ")", "\n", ")", "\n", "for", "i", ":=", ...
/** * Decodes an identifier into its corresponding byte slice. * * @param {string} str Identifier to convert. * * @return {[]byte} The identifier as a byte slice. */
[ "Decodes", "an", "identifier", "into", "its", "corresponding", "byte", "slice", "." ]
38337c27106d8f06e9b5cddc6df973ceece1c8ea
https://github.com/Bren2010/proquint/blob/38337c27106d8f06e9b5cddc6df973ceece1c8ea/proquint.go#L105-L123
146,296
divideandconquer/go-merge
merge/merge.go
Merge
func Merge(base, override interface{}) interface{} { //reflect and recurse b := reflect.ValueOf(base) o := reflect.ValueOf(override) ret := mergeRecursive(b, o) return ret.Interface() }
go
func Merge(base, override interface{}) interface{} { //reflect and recurse b := reflect.ValueOf(base) o := reflect.ValueOf(override) ret := mergeRecursive(b, o) return ret.Interface() }
[ "func", "Merge", "(", "base", ",", "override", "interface", "{", "}", ")", "interface", "{", "}", "{", "//reflect and recurse", "b", ":=", "reflect", ".", "ValueOf", "(", "base", ")", "\n", "o", ":=", "reflect", ".", "ValueOf", "(", "override", ")", "\...
// Merge will take two data sets and merge them together - returning a new data set
[ "Merge", "will", "take", "two", "data", "sets", "and", "merge", "them", "together", "-", "returning", "a", "new", "data", "set" ]
bc6b3a394b4e042e2dcfb62cb7bcd043a59adbea
https://github.com/divideandconquer/go-merge/blob/bc6b3a394b4e042e2dcfb62cb7bcd043a59adbea/merge/merge.go#L6-L13
146,297
nranchev/go-libGeoIP
libgeo.go
Load
func Load(filename string) (gi *GeoIP, err error) { // Try to open the requested file dbInfo, err := os.Lstat(filename) if err != nil { return } dbFile, err := os.Open(filename) if err != nil { return } // Copy the db into memory gi = new(GeoIP) gi.data = make([]byte, dbInfo.Size()) dbFile.Read(gi.data)...
go
func Load(filename string) (gi *GeoIP, err error) { // Try to open the requested file dbInfo, err := os.Lstat(filename) if err != nil { return } dbFile, err := os.Open(filename) if err != nil { return } // Copy the db into memory gi = new(GeoIP) gi.data = make([]byte, dbInfo.Size()) dbFile.Read(gi.data)...
[ "func", "Load", "(", "filename", "string", ")", "(", "gi", "*", "GeoIP", ",", "err", "error", ")", "{", "// Try to open the requested file", "dbInfo", ",", "err", ":=", "os", ".", "Lstat", "(", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "ret...
// Load the database file in memory, detect the db format and setup the GeoIP struct
[ "Load", "the", "database", "file", "in", "memory", "detect", "the", "db", "format", "and", "setup", "the", "GeoIP", "struct" ]
d6d4a9a4c7e8d750064c10550bbd4f9aae50d48e
https://github.com/nranchev/go-libGeoIP/blob/d6d4a9a4c7e8d750064c10550bbd4f9aae50d48e/libgeo.go#L150-L203
146,298
nranchev/go-libGeoIP
libgeo.go
GetLocationByIP
func (gi *GeoIP) GetLocationByIP(ip string) *Location { return gi.GetLocationByIPNum(addrToNum(ip)) }
go
func (gi *GeoIP) GetLocationByIP(ip string) *Location { return gi.GetLocationByIPNum(addrToNum(ip)) }
[ "func", "(", "gi", "*", "GeoIP", ")", "GetLocationByIP", "(", "ip", "string", ")", "*", "Location", "{", "return", "gi", ".", "GetLocationByIPNum", "(", "addrToNum", "(", "ip", ")", ")", "\n", "}" ]
// Lookup by IP address and return location
[ "Lookup", "by", "IP", "address", "and", "return", "location" ]
d6d4a9a4c7e8d750064c10550bbd4f9aae50d48e
https://github.com/nranchev/go-libGeoIP/blob/d6d4a9a4c7e8d750064c10550bbd4f9aae50d48e/libgeo.go#L206-L208
146,299
nranchev/go-libGeoIP
libgeo.go
GetLocationByIPNum
func (gi *GeoIP) GetLocationByIPNum(ipNum uint32) *Location { // Perform the lookup on the database to see if the record is found offset := gi.lookupByIPNum(ipNum) // Check if the country was found if gi.dbType == dbCountryEdition && offset-countryBegin == 0 || gi.dbType != dbCountryEdition && gi.databaseSegment...
go
func (gi *GeoIP) GetLocationByIPNum(ipNum uint32) *Location { // Perform the lookup on the database to see if the record is found offset := gi.lookupByIPNum(ipNum) // Check if the country was found if gi.dbType == dbCountryEdition && offset-countryBegin == 0 || gi.dbType != dbCountryEdition && gi.databaseSegment...
[ "func", "(", "gi", "*", "GeoIP", ")", "GetLocationByIPNum", "(", "ipNum", "uint32", ")", "*", "Location", "{", "// Perform the lookup on the database to see if the record is found", "offset", ":=", "gi", ".", "lookupByIPNum", "(", "ipNum", ")", "\n\n", "// Check if th...
// Lookup by IP number and return location
[ "Lookup", "by", "IP", "number", "and", "return", "location" ]
d6d4a9a4c7e8d750064c10550bbd4f9aae50d48e
https://github.com/nranchev/go-libGeoIP/blob/d6d4a9a4c7e8d750064c10550bbd4f9aae50d48e/libgeo.go#L211-L288