id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
32,000
perkeep/perkeep
pkg/importer/twitter/twitter.go
importTweets
func (r *run) importTweets(userID string, apiPath string) error { maxId := "" continueRequests := true var tweetsNode *importer.Object var err error var importType string if apiPath == userLikesAPIPath { importType = "likes" } else { importType = "tweets" } tweetsNode, err = r.getTopLevelNode(importType) ...
go
func (r *run) importTweets(userID string, apiPath string) error { maxId := "" continueRequests := true var tweetsNode *importer.Object var err error var importType string if apiPath == userLikesAPIPath { importType = "likes" } else { importType = "tweets" } tweetsNode, err = r.getTopLevelNode(importType) ...
[ "func", "(", "r", "*", "run", ")", "importTweets", "(", "userID", "string", ",", "apiPath", "string", ")", "error", "{", "maxId", ":=", "\"", "\"", "\n", "continueRequests", ":=", "true", "\n\n", "var", "tweetsNode", "*", "importer", ".", "Object", "\n",...
// importTweets imports the tweets related to userID, through apiPath. // If apiPath is userTimeLineAPIPath, the tweets and retweets posted by userID are imported. // If apiPath is userLikesAPIPath, the tweets liked by userID are imported.
[ "importTweets", "imports", "the", "tweets", "related", "to", "userID", "through", "apiPath", ".", "If", "apiPath", "is", "userTimeLineAPIPath", "the", "tweets", "and", "retweets", "posted", "by", "userID", "are", "imported", ".", "If", "apiPath", "is", "userLike...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/twitter/twitter.go#L374-L468
32,001
perkeep/perkeep
pkg/serverinit/serverinit.go
detectConfigChange
func detectConfigChange(conf jsonconfig.Obj) error { oldHTTPSKey, oldHTTPSCert := conf.OptionalString("HTTPSKeyFile", ""), conf.OptionalString("HTTPSCertFile", "") if oldHTTPSKey != "" || oldHTTPSCert != "" { return fmt.Errorf("config keys %q and %q have respectively been renamed to %q and %q, please fix your serve...
go
func detectConfigChange(conf jsonconfig.Obj) error { oldHTTPSKey, oldHTTPSCert := conf.OptionalString("HTTPSKeyFile", ""), conf.OptionalString("HTTPSCertFile", "") if oldHTTPSKey != "" || oldHTTPSCert != "" { return fmt.Errorf("config keys %q and %q have respectively been renamed to %q and %q, please fix your serve...
[ "func", "detectConfigChange", "(", "conf", "jsonconfig", ".", "Obj", ")", "error", "{", "oldHTTPSKey", ",", "oldHTTPSCert", ":=", "conf", ".", "OptionalString", "(", "\"", "\"", ",", "\"", "\"", ")", ",", "conf", ".", "OptionalString", "(", "\"", "\"", "...
// detectConfigChange returns an informative error if conf contains obsolete keys.
[ "detectConfigChange", "returns", "an", "informative", "error", "if", "conf", "contains", "obsolete", "keys", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/serverinit/serverinit.go#L467-L474
32,002
perkeep/perkeep
pkg/serverinit/serverinit.go
Load
func Load(config []byte) (*Config, error) { return load("", func(filename string) (jsonconfig.File, error) { if filename != "" { return nil, errors.New("JSON files with includes not supported with jsonconfig.Load") } return jsonFileImpl{bytes.NewReader(config), "config file"}, nil }) }
go
func Load(config []byte) (*Config, error) { return load("", func(filename string) (jsonconfig.File, error) { if filename != "" { return nil, errors.New("JSON files with includes not supported with jsonconfig.Load") } return jsonFileImpl{bytes.NewReader(config), "config file"}, nil }) }
[ "func", "Load", "(", "config", "[", "]", "byte", ")", "(", "*", "Config", ",", "error", ")", "{", "return", "load", "(", "\"", "\"", ",", "func", "(", "filename", "string", ")", "(", "jsonconfig", ".", "File", ",", "error", ")", "{", "if", "filen...
// Load returns a low-level "handler config" from the provided config. // If the config doesn't contain a top-level JSON key of "handlerConfig" // with boolean value true, the configuration is assumed to be a high-level // "user config" file, and transformed into a low-level config.
[ "Load", "returns", "a", "low", "-", "level", "handler", "config", "from", "the", "provided", "config", ".", "If", "the", "config", "doesn", "t", "contain", "a", "top", "-", "level", "JSON", "key", "of", "handlerConfig", "with", "boolean", "value", "true", ...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/serverinit/serverinit.go#L498-L505
32,003
perkeep/perkeep
pkg/serverinit/serverinit.go
readFields
func (c *Config) readFields() error { c.camliNetIP = c.jconf.OptionalString("camliNetIP", "") c.listenAddr = c.jconf.OptionalString("listen", "") c.baseURL = strings.TrimSuffix(c.jconf.OptionalString("baseURL", ""), "/") c.httpsCert = c.jconf.OptionalString("httpsCert", "") c.httpsKey = c.jconf.OptionalString("htt...
go
func (c *Config) readFields() error { c.camliNetIP = c.jconf.OptionalString("camliNetIP", "") c.listenAddr = c.jconf.OptionalString("listen", "") c.baseURL = strings.TrimSuffix(c.jconf.OptionalString("baseURL", ""), "/") c.httpsCert = c.jconf.OptionalString("httpsCert", "") c.httpsKey = c.jconf.OptionalString("htt...
[ "func", "(", "c", "*", "Config", ")", "readFields", "(", ")", "error", "{", "c", ".", "camliNetIP", "=", "c", ".", "jconf", ".", "OptionalString", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "c", ".", "listenAddr", "=", "c", ".", "jconf", ".", ...
// readFields reads the low-level jsonconfig fields using the jsonconfig package // and copies them into c. This marks them as known fields before a future call to InstallerHandlers
[ "readFields", "reads", "the", "low", "-", "level", "jsonconfig", "fields", "using", "the", "jsonconfig", "package", "and", "copies", "them", "into", "c", ".", "This", "marks", "them", "as", "known", "fields", "before", "a", "future", "call", "to", "Installer...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/serverinit/serverinit.go#L573-L589
32,004
perkeep/perkeep
pkg/serverinit/serverinit.go
StartApps
func (c *Config) StartApps() error { for _, ap := range c.apps { if err := ap.Start(); err != nil { return fmt.Errorf("error starting app %v: %v", ap.ProgramName(), err) } } return nil }
go
func (c *Config) StartApps() error { for _, ap := range c.apps { if err := ap.Start(); err != nil { return fmt.Errorf("error starting app %v: %v", ap.ProgramName(), err) } } return nil }
[ "func", "(", "c", "*", "Config", ")", "StartApps", "(", ")", "error", "{", "for", "_", ",", "ap", ":=", "range", "c", ".", "apps", "{", "if", "err", ":=", "ap", ".", "Start", "(", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Erro...
// StartApps starts all the server applications that were configured // during InstallHandlers. It should only be called after perkeepd // has started serving, since these apps might request some configuration // from Perkeep to finish initializing.
[ "StartApps", "starts", "all", "the", "server", "applications", "that", "were", "configured", "during", "InstallHandlers", ".", "It", "should", "only", "be", "called", "after", "perkeepd", "has", "started", "serving", "since", "these", "apps", "might", "request", ...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/serverinit/serverinit.go#L773-L780
32,005
perkeep/perkeep
pkg/serverinit/serverinit.go
UploadPublicKey
func (c *Config) UploadPublicKey(ctx context.Context) error { if c.signHandler == nil { return nil } return c.signHandler.UploadPublicKey(ctx) }
go
func (c *Config) UploadPublicKey(ctx context.Context) error { if c.signHandler == nil { return nil } return c.signHandler.UploadPublicKey(ctx) }
[ "func", "(", "c", "*", "Config", ")", "UploadPublicKey", "(", "ctx", "context", ".", "Context", ")", "error", "{", "if", "c", ".", "signHandler", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "c", ".", "signHandler", ".", "UploadPublicK...
// UploadPublicKey uploads the public key blob with the sign handler that was // configured during InstallHandlers.
[ "UploadPublicKey", "uploads", "the", "public", "key", "blob", "with", "the", "sign", "handler", "that", "was", "configured", "during", "InstallHandlers", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/serverinit/serverinit.go#L784-L789
32,006
perkeep/perkeep
pkg/serverinit/serverinit.go
AppURL
func (c *Config) AppURL() map[string]string { appURL := make(map[string]string, len(c.apps)) for _, ap := range c.apps { appURL[ap.ProgramName()] = ap.BackendURL() } return appURL }
go
func (c *Config) AppURL() map[string]string { appURL := make(map[string]string, len(c.apps)) for _, ap := range c.apps { appURL[ap.ProgramName()] = ap.BackendURL() } return appURL }
[ "func", "(", "c", "*", "Config", ")", "AppURL", "(", ")", "map", "[", "string", "]", "string", "{", "appURL", ":=", "make", "(", "map", "[", "string", "]", "string", ",", "len", "(", "c", ".", "apps", ")", ")", "\n", "for", "_", ",", "ap", ":...
// AppURL returns a map of app name to app base URL for all the configured // server apps.
[ "AppURL", "returns", "a", "map", "of", "app", "name", "to", "app", "base", "URL", "for", "all", "the", "configured", "server", "apps", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/serverinit/serverinit.go#L793-L799
32,007
perkeep/perkeep
pkg/serverinit/serverinit.go
highLevelConfFields
func highLevelConfFields() map[string]bool { knownFields := make(map[string]bool) var c serverconfig.Config s := reflect.ValueOf(&c).Elem() for i := 0; i < s.NumField(); i++ { f := s.Type().Field(i) jsonTag, ok := f.Tag.Lookup("json") if !ok { panic(fmt.Sprintf("%q field in serverconfig.Config does not hav...
go
func highLevelConfFields() map[string]bool { knownFields := make(map[string]bool) var c serverconfig.Config s := reflect.ValueOf(&c).Elem() for i := 0; i < s.NumField(); i++ { f := s.Type().Field(i) jsonTag, ok := f.Tag.Lookup("json") if !ok { panic(fmt.Sprintf("%q field in serverconfig.Config does not hav...
[ "func", "highLevelConfFields", "(", ")", "map", "[", "string", "]", "bool", "{", "knownFields", ":=", "make", "(", "map", "[", "string", "]", "bool", ")", "\n", "var", "c", "serverconfig", ".", "Config", "\n", "s", ":=", "reflect", ".", "ValueOf", "(",...
// highLevelConfFields returns all the possible fields of a serverconfig.Config, // in their JSON form. This allows checking that the parameters in the high-level // server configuration file are at least valid names, which is useful to catch // typos.
[ "highLevelConfFields", "returns", "all", "the", "possible", "fields", "of", "a", "serverconfig", ".", "Config", "in", "their", "JSON", "form", ".", "This", "allows", "checking", "that", "the", "parameters", "in", "the", "high", "-", "level", "server", "configu...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/serverinit/serverinit.go#L915-L933
32,008
perkeep/perkeep
internal/azure/storage/client.go
containerURL
func (c *Client) containerURL(container string) string { return fmt.Sprintf("https://%s/%s/", c.hostname(), container) }
go
func (c *Client) containerURL(container string) string { return fmt.Sprintf("https://%s/%s/", c.hostname(), container) }
[ "func", "(", "c", "*", "Client", ")", "containerURL", "(", "container", "string", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "c", ".", "hostname", "(", ")", ",", "container", ")", "\n", "}" ]
// containerURL returns the URL prefix of the container, with trailing slash
[ "containerURL", "returns", "the", "URL", "prefix", "of", "the", "container", "with", "trailing", "slash" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/azure/storage/client.go#L76-L78
32,009
perkeep/perkeep
internal/azure/storage/client.go
Containers
func (c *Client) Containers(ctx context.Context) ([]*Container, error) { req := newReq(ctx, "https://"+c.hostname()+"/") c.Auth.SignRequest(req) res, err := c.transport().RoundTrip(req) if err != nil { return nil, err } defer res.Body.Close() if res.StatusCode != http.StatusOK { return nil, fmt.Errorf("azure...
go
func (c *Client) Containers(ctx context.Context) ([]*Container, error) { req := newReq(ctx, "https://"+c.hostname()+"/") c.Auth.SignRequest(req) res, err := c.transport().RoundTrip(req) if err != nil { return nil, err } defer res.Body.Close() if res.StatusCode != http.StatusOK { return nil, fmt.Errorf("azure...
[ "func", "(", "c", "*", "Client", ")", "Containers", "(", "ctx", "context", ".", "Context", ")", "(", "[", "]", "*", "Container", ",", "error", ")", "{", "req", ":=", "newReq", "(", "ctx", ",", "\"", "\"", "+", "c", ".", "hostname", "(", ")", "+...
// Containers list the containers active under the current account.
[ "Containers", "list", "the", "containers", "active", "under", "the", "current", "account", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/azure/storage/client.go#L95-L107
32,010
perkeep/perkeep
internal/azure/storage/client.go
Stat
func (c *Client) Stat(ctx context.Context, key, container string) (size int64, reterr error) { req := newReq(ctx, c.keyURL(container, key)) req.Method = "HEAD" c.Auth.SignRequest(req) res, err := c.transport().RoundTrip(req) if err != nil { return 0, err } if res.Body != nil { defer res.Body.Close() } swit...
go
func (c *Client) Stat(ctx context.Context, key, container string) (size int64, reterr error) { req := newReq(ctx, c.keyURL(container, key)) req.Method = "HEAD" c.Auth.SignRequest(req) res, err := c.transport().RoundTrip(req) if err != nil { return 0, err } if res.Body != nil { defer res.Body.Close() } swit...
[ "func", "(", "c", "*", "Client", ")", "Stat", "(", "ctx", "context", ".", "Context", ",", "key", ",", "container", "string", ")", "(", "size", "int64", ",", "reterr", "error", ")", "{", "req", ":=", "newReq", "(", "ctx", ",", "c", ".", "keyURL", ...
// Stat Stats a blob in Azure. // It returns 0, os.ErrNotExist if not found on Azure, otherwise reterr is real.
[ "Stat", "Stats", "a", "blob", "in", "Azure", ".", "It", "returns", "0", "os", ".", "ErrNotExist", "if", "not", "found", "on", "Azure", "otherwise", "reterr", "is", "real", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/azure/storage/client.go#L124-L142
32,011
perkeep/perkeep
internal/azure/storage/client.go
PutObject
func (c *Client) PutObject(ctx context.Context, key, container string, md5 hash.Hash, size int64, body io.Reader) error { req := newReq(ctx, c.keyURL(container, key)) req.Method = "PUT" req.ContentLength = size if md5 != nil { b64 := new(bytes.Buffer) encoder := base64.NewEncoder(base64.StdEncoding, b64) enco...
go
func (c *Client) PutObject(ctx context.Context, key, container string, md5 hash.Hash, size int64, body io.Reader) error { req := newReq(ctx, c.keyURL(container, key)) req.Method = "PUT" req.ContentLength = size if md5 != nil { b64 := new(bytes.Buffer) encoder := base64.NewEncoder(base64.StdEncoding, b64) enco...
[ "func", "(", "c", "*", "Client", ")", "PutObject", "(", "ctx", "context", ".", "Context", ",", "key", ",", "container", "string", ",", "md5", "hash", ".", "Hash", ",", "size", "int64", ",", "body", "io", ".", "Reader", ")", "error", "{", "req", ":=...
// PutObject puts a blob to the specified container on Azure
[ "PutObject", "puts", "a", "blob", "to", "the", "specified", "container", "on", "Azure" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/azure/storage/client.go#L145-L176
32,012
perkeep/perkeep
internal/azure/storage/client.go
Get
func (c *Client) Get(ctx context.Context, container, key string) (body io.ReadCloser, size int64, err error) { req := newReq(ctx, c.keyURL(container, key)) c.Auth.SignRequest(req) res, err := c.transport().RoundTrip(req) if err != nil { return } switch res.StatusCode { case http.StatusOK: return res.Body, re...
go
func (c *Client) Get(ctx context.Context, container, key string) (body io.ReadCloser, size int64, err error) { req := newReq(ctx, c.keyURL(container, key)) c.Auth.SignRequest(req) res, err := c.transport().RoundTrip(req) if err != nil { return } switch res.StatusCode { case http.StatusOK: return res.Body, re...
[ "func", "(", "c", "*", "Client", ")", "Get", "(", "ctx", "context", ".", "Context", ",", "container", ",", "key", "string", ")", "(", "body", "io", ".", "ReadCloser", ",", "size", "int64", ",", "err", "error", ")", "{", "req", ":=", "newReq", "(", ...
// Get retrieves a blob from Azure or returns os.ErrNotExist if not found
[ "Get", "retrieves", "a", "blob", "from", "Azure", "or", "returns", "os", ".", "ErrNotExist", "if", "not", "found" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/azure/storage/client.go#L274-L291
32,013
perkeep/perkeep
internal/azure/storage/client.go
GetPartial
func (c *Client) GetPartial(ctx context.Context, container, key string, offset, length int64) (rc io.ReadCloser, err error) { if offset < 0 { return nil, errors.New("invalid negative length") } req := newReq(ctx, c.keyURL(container, key)) if length >= 0 { req.Header.Set("Range", fmt.Sprintf("bytes=%d-%d", offs...
go
func (c *Client) GetPartial(ctx context.Context, container, key string, offset, length int64) (rc io.ReadCloser, err error) { if offset < 0 { return nil, errors.New("invalid negative length") } req := newReq(ctx, c.keyURL(container, key)) if length >= 0 { req.Header.Set("Range", fmt.Sprintf("bytes=%d-%d", offs...
[ "func", "(", "c", "*", "Client", ")", "GetPartial", "(", "ctx", "context", ".", "Context", ",", "container", ",", "key", "string", ",", "offset", ",", "length", "int64", ")", "(", "rc", "io", ".", "ReadCloser", ",", "err", "error", ")", "{", "if", ...
// GetPartial fetches part of the blob in container. // If length is negative, the rest of the object is returned. // The caller must close rc.
[ "GetPartial", "fetches", "part", "of", "the", "blob", "in", "container", ".", "If", "length", "is", "negative", "the", "rest", "of", "the", "object", "is", "returned", ".", "The", "caller", "must", "close", "rc", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/azure/storage/client.go#L296-L323
32,014
perkeep/perkeep
internal/azure/storage/client.go
Delete
func (c *Client) Delete(ctx context.Context, container, key string) error { req := newReq(ctx, c.keyURL(container, key)) req.Method = "DELETE" c.Auth.SignRequest(req) res, err := c.transport().RoundTrip(req) if err != nil { return err } if res != nil && res.Body != nil { defer res.Body.Close() } if res.Sta...
go
func (c *Client) Delete(ctx context.Context, container, key string) error { req := newReq(ctx, c.keyURL(container, key)) req.Method = "DELETE" c.Auth.SignRequest(req) res, err := c.transport().RoundTrip(req) if err != nil { return err } if res != nil && res.Body != nil { defer res.Body.Close() } if res.Sta...
[ "func", "(", "c", "*", "Client", ")", "Delete", "(", "ctx", "context", ".", "Context", ",", "container", ",", "key", "string", ")", "error", "{", "req", ":=", "newReq", "(", "ctx", ",", "c", ".", "keyURL", "(", "container", ",", "key", ")", ")", ...
// Delete deletes a blob from the specified container. // It may take a few moments before the blob is actually deleted by Azure.
[ "Delete", "deletes", "a", "blob", "from", "the", "specified", "container", ".", "It", "may", "take", "a", "few", "moments", "before", "the", "blob", "is", "actually", "deleted", "by", "Azure", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/azure/storage/client.go#L327-L343
32,015
perkeep/perkeep
internal/azure/storage/client.go
Error
func (e *Error) Error() string { if e.AzureError.Code != "" { return fmt.Sprintf("azure.%s: status %d, code: %s", e.Op, e.Code, e.AzureError.Code) } return fmt.Sprintf("azure.%s: status %d", e.Op, e.Code) }
go
func (e *Error) Error() string { if e.AzureError.Code != "" { return fmt.Sprintf("azure.%s: status %d, code: %s", e.Op, e.Code, e.AzureError.Code) } return fmt.Sprintf("azure.%s: status %d", e.Op, e.Code) }
[ "func", "(", "e", "*", "Error", ")", "Error", "(", ")", "string", "{", "if", "e", ".", "AzureError", ".", "Code", "!=", "\"", "\"", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ".", "Op", ",", "e", ".", "Code", ",", "e", ...
// Error returns a formatted error message
[ "Error", "returns", "a", "formatted", "error", "message" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/azure/storage/client.go#L391-L396
32,016
perkeep/perkeep
pkg/fs/fs.go
NewDefaultCamliFileSystem
func NewDefaultCamliFileSystem(client *client.Client, fetcher blob.Fetcher) *CamliFileSystem { if client == nil || fetcher == nil { panic("nil argument") } fs := newCamliFileSystem(fetcher) fs.root = &root{fs: fs} // root.go fs.client = client return fs }
go
func NewDefaultCamliFileSystem(client *client.Client, fetcher blob.Fetcher) *CamliFileSystem { if client == nil || fetcher == nil { panic("nil argument") } fs := newCamliFileSystem(fetcher) fs.root = &root{fs: fs} // root.go fs.client = client return fs }
[ "func", "NewDefaultCamliFileSystem", "(", "client", "*", "client", ".", "Client", ",", "fetcher", "blob", ".", "Fetcher", ")", "*", "CamliFileSystem", "{", "if", "client", "==", "nil", "||", "fetcher", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n...
// NewDefaultCamliFileSystem returns a filesystem with a generic base, from which // users can navigate by blobref, tag, date, etc.
[ "NewDefaultCamliFileSystem", "returns", "a", "filesystem", "with", "a", "generic", "base", "from", "which", "users", "can", "navigate", "by", "blobref", "tag", "date", "etc", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fs/fs.go#L76-L84
32,017
perkeep/perkeep
pkg/fs/fs.go
NewRootedCamliFileSystem
func NewRootedCamliFileSystem(cli *client.Client, fetcher blob.Fetcher, root blob.Ref) (*CamliFileSystem, error) { fs := newCamliFileSystem(fetcher) fs.client = cli n, err := fs.newNodeFromBlobRef(root) if err != nil { return nil, err } fs.root = n return fs, nil }
go
func NewRootedCamliFileSystem(cli *client.Client, fetcher blob.Fetcher, root blob.Ref) (*CamliFileSystem, error) { fs := newCamliFileSystem(fetcher) fs.client = cli n, err := fs.newNodeFromBlobRef(root) if err != nil { return nil, err } fs.root = n return fs, nil }
[ "func", "NewRootedCamliFileSystem", "(", "cli", "*", "client", ".", "Client", ",", "fetcher", "blob", ".", "Fetcher", ",", "root", "blob", ".", "Ref", ")", "(", "*", "CamliFileSystem", ",", "error", ")", "{", "fs", ":=", "newCamliFileSystem", "(", "fetcher...
// NewRootedCamliFileSystem returns a CamliFileSystem with a node based on a blobref // as its base.
[ "NewRootedCamliFileSystem", "returns", "a", "CamliFileSystem", "with", "a", "node", "based", "on", "a", "blobref", "as", "its", "base", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fs/fs.go#L88-L101
32,018
perkeep/perkeep
pkg/fs/fs.go
populateAttr
func (n *node) populateAttr() error { meta := n.meta n.attr.Mode = meta.FileMode() if n.fs.IgnoreOwners { n.attr.Uid = uint32(os.Getuid()) n.attr.Gid = uint32(os.Getgid()) executeBit := n.attr.Mode & 0100 n.attr.Mode = (n.attr.Mode ^ n.attr.Mode.Perm()) | 0400 | executeBit } else { n.attr.Uid = uint32(m...
go
func (n *node) populateAttr() error { meta := n.meta n.attr.Mode = meta.FileMode() if n.fs.IgnoreOwners { n.attr.Uid = uint32(os.Getuid()) n.attr.Gid = uint32(os.Getgid()) executeBit := n.attr.Mode & 0100 n.attr.Mode = (n.attr.Mode ^ n.attr.Mode.Perm()) | 0400 | executeBit } else { n.attr.Uid = uint32(m...
[ "func", "(", "n", "*", "node", ")", "populateAttr", "(", ")", "error", "{", "meta", ":=", "n", ".", "meta", "\n\n", "n", ".", "attr", ".", "Mode", "=", "meta", ".", "FileMode", "(", ")", "\n\n", "if", "n", ".", "fs", ".", "IgnoreOwners", "{", "...
// populateAttr should only be called once n.ss is known to be set and // non-nil
[ "populateAttr", "should", "only", "be", "called", "once", "n", ".", "ss", "is", "known", "to", "be", "set", "and", "non", "-", "nil" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fs/fs.go#L283-L319
32,019
perkeep/perkeep
pkg/fs/fs.go
newNodeFromBlobRef
func (fs *CamliFileSystem) newNodeFromBlobRef(root blob.Ref) (fusefs.Node, error) { blob, err := fs.fetchSchemaMeta(context.TODO(), root) if err != nil { return nil, err } switch blob.Type() { case "directory": n := &node{fs: fs, blobref: root, meta: blob} n.populateAttr() return n, nil case "permanode"...
go
func (fs *CamliFileSystem) newNodeFromBlobRef(root blob.Ref) (fusefs.Node, error) { blob, err := fs.fetchSchemaMeta(context.TODO(), root) if err != nil { return nil, err } switch blob.Type() { case "directory": n := &node{fs: fs, blobref: root, meta: blob} n.populateAttr() return n, nil case "permanode"...
[ "func", "(", "fs", "*", "CamliFileSystem", ")", "newNodeFromBlobRef", "(", "root", "blob", ".", "Ref", ")", "(", "fusefs", ".", "Node", ",", "error", ")", "{", "blob", ",", "err", ":=", "fs", ".", "fetchSchemaMeta", "(", "context", ".", "TODO", "(", ...
// consolated logic for determining a node to mount based on an arbitrary blobref
[ "consolated", "logic", "for", "determining", "a", "node", "to", "mount", "based", "on", "an", "arbitrary", "blobref" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fs/fs.go#L367-L385
32,020
perkeep/perkeep
dev/devcam/devcam.go
build
func build(targets ...string) error { if v, _ := strconv.ParseBool(os.Getenv("CAMLI_FAST_DEV")); v { // Demo mode. See dev/demo.sh. return nil } var fullTargets []string for _, t := range targets { t = filepath.ToSlash(t) if !strings.HasPrefix(t, "perkeep.org") { t = pathpkg.Join("perkeep.org", t) } ...
go
func build(targets ...string) error { if v, _ := strconv.ParseBool(os.Getenv("CAMLI_FAST_DEV")); v { // Demo mode. See dev/demo.sh. return nil } var fullTargets []string for _, t := range targets { t = filepath.ToSlash(t) if !strings.HasPrefix(t, "perkeep.org") { t = pathpkg.Join("perkeep.org", t) } ...
[ "func", "build", "(", "targets", "...", "string", ")", "error", "{", "if", "v", ",", "_", ":=", "strconv", ".", "ParseBool", "(", "os", ".", "Getenv", "(", "\"", "\"", ")", ")", ";", "v", "{", "// Demo mode. See dev/demo.sh.", "return", "nil", "\n", ...
// build builds the named perkeep targets. // Each target may have its "perkeep.org" prefix removed.
[ "build", "builds", "the", "named", "perkeep", "targets", ".", "Each", "target", "may", "have", "its", "perkeep", ".", "org", "prefix", "removed", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/dev/devcam/devcam.go#L238-L267
32,021
perkeep/perkeep
pkg/index/location.go
NewLocationHelper
func NewLocationHelper(ix *Index) *LocationHelper { lh := &LocationHelper{index: ix} if ix.corpus != nil { lh.corpus = ix.corpus } return lh }
go
func NewLocationHelper(ix *Index) *LocationHelper { lh := &LocationHelper{index: ix} if ix.corpus != nil { lh.corpus = ix.corpus } return lh }
[ "func", "NewLocationHelper", "(", "ix", "*", "Index", ")", "*", "LocationHelper", "{", "lh", ":=", "&", "LocationHelper", "{", "index", ":", "ix", "}", "\n", "if", "ix", ".", "corpus", "!=", "nil", "{", "lh", ".", "corpus", "=", "ix", ".", "corpus", ...
// NewLocationHelper returns a new location handler // that uses ix to query blob attributes.
[ "NewLocationHelper", "returns", "a", "new", "location", "handler", "that", "uses", "ix", "to", "query", "blob", "attributes", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/location.go#L26-L32
32,022
perkeep/perkeep
pkg/index/location.go
get
func (pa permAttr) get(attr string) string { if pa.attrs != nil { v := pa.attrs[attr] if len(v) != 0 { return v[0] } return "" } if pa.claims != nil { return claimsIntfAttrValue(pa.claims, attr, pa.at, pa.signerFilter) } return "" }
go
func (pa permAttr) get(attr string) string { if pa.attrs != nil { v := pa.attrs[attr] if len(v) != 0 { return v[0] } return "" } if pa.claims != nil { return claimsIntfAttrValue(pa.claims, attr, pa.at, pa.signerFilter) } return "" }
[ "func", "(", "pa", "permAttr", ")", "get", "(", "attr", "string", ")", "string", "{", "if", "pa", ".", "attrs", "!=", "nil", "{", "v", ":=", "pa", ".", "attrs", "[", "attr", "]", "\n", "if", "len", "(", "v", ")", "!=", "0", "{", "return", "v"...
// get returns the value of attr.
[ "get", "returns", "the", "value", "of", "attr", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/location.go#L147-L161
32,023
perkeep/perkeep
pkg/fileembed/fileembed.go
IsEmpty
func (f *Files) IsEmpty() bool { f.lk.Lock() defer f.lk.Unlock() return len(f.file) == 0 }
go
func (f *Files) IsEmpty() bool { f.lk.Lock() defer f.lk.Unlock() return len(f.file) == 0 }
[ "func", "(", "f", "*", "Files", ")", "IsEmpty", "(", ")", "bool", "{", "f", ".", "lk", ".", "Lock", "(", ")", "\n", "defer", "f", ".", "lk", ".", "Unlock", "(", ")", "\n", "return", "len", "(", "f", ".", "file", ")", "==", "0", "\n", "}" ]
// IsEmpty reports whether f is empty.
[ "IsEmpty", "reports", "whether", "f", "is", "empty", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fileembed/fileembed.go#L121-L125
32,024
perkeep/perkeep
pkg/fileembed/fileembed.go
Add
func (f *Files) Add(filename string, size int64, modtime time.Time, o Opener) { f.lk.Lock() defer f.lk.Unlock() r, err := o.Open() if err != nil { log.Printf("Could not add file %v: %v", filename, err) return } contents, err := ioutil.ReadAll(r) if err != nil { log.Printf("Could not read contents of file ...
go
func (f *Files) Add(filename string, size int64, modtime time.Time, o Opener) { f.lk.Lock() defer f.lk.Unlock() r, err := o.Open() if err != nil { log.Printf("Could not add file %v: %v", filename, err) return } contents, err := ioutil.ReadAll(r) if err != nil { log.Printf("Could not read contents of file ...
[ "func", "(", "f", "*", "Files", ")", "Add", "(", "filename", "string", ",", "size", "int64", ",", "modtime", "time", ".", "Time", ",", "o", "Opener", ")", "{", "f", ".", "lk", ".", "Lock", "(", ")", "\n", "defer", "f", ".", "lk", ".", "Unlock",...
// Add adds a file to the file set.
[ "Add", "adds", "a", "file", "to", "the", "file", "set", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fileembed/fileembed.go#L128-L148
32,025
perkeep/perkeep
pkg/fileembed/fileembed.go
add
func (f *Files) add(filename string, sf *staticFile) { if f.file == nil { f.file = make(map[string]*staticFile) } f.file[filename] = sf }
go
func (f *Files) add(filename string, sf *staticFile) { if f.file == nil { f.file = make(map[string]*staticFile) } f.file[filename] = sf }
[ "func", "(", "f", "*", "Files", ")", "add", "(", "filename", "string", ",", "sf", "*", "staticFile", ")", "{", "if", "f", ".", "file", "==", "nil", "{", "f", ".", "file", "=", "make", "(", "map", "[", "string", "]", "*", "staticFile", ")", "\n"...
// f.lk must be locked
[ "f", ".", "lk", "must", "be", "locked" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fileembed/fileembed.go#L151-L156
32,026
perkeep/perkeep
pkg/fileembed/fileembed.go
openFallback
func (f *Files) openFallback(filename string) (http.File, error) { if f.DirFallback == "" { return nil, os.ErrNotExist } of, err := os.Open(filepath.Join(f.DirFallback, filename)) switch { case err != nil: return nil, err case f.SlurpToMemory: defer of.Close() bs, err := ioutil.ReadAll(of) if err != nil...
go
func (f *Files) openFallback(filename string) (http.File, error) { if f.DirFallback == "" { return nil, os.ErrNotExist } of, err := os.Open(filepath.Join(f.DirFallback, filename)) switch { case err != nil: return nil, err case f.SlurpToMemory: defer of.Close() bs, err := ioutil.ReadAll(of) if err != nil...
[ "func", "(", "f", "*", "Files", ")", "openFallback", "(", "filename", "string", ")", "(", "http", ".", "File", ",", "error", ")", "{", "if", "f", ".", "DirFallback", "==", "\"", "\"", "{", "return", "nil", ",", "os", ".", "ErrNotExist", "\n", "}", ...
// f.lk is held
[ "f", ".", "lk", "is", "held" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fileembed/fileembed.go#L180-L205
32,027
perkeep/perkeep
website/pk-web/format.go
commentSelection
func commentSelection(src []byte) Selection { var s scanner.Scanner fset := token.NewFileSet() file := fset.AddFile("", fset.Base(), len(src)) s.Init(file, src, nil, scanner.ScanComments) return func() (seg []int) { for { pos, tok, lit := s.Scan() if tok == token.EOF { break } offs := file.Offset...
go
func commentSelection(src []byte) Selection { var s scanner.Scanner fset := token.NewFileSet() file := fset.AddFile("", fset.Base(), len(src)) s.Init(file, src, nil, scanner.ScanComments) return func() (seg []int) { for { pos, tok, lit := s.Scan() if tok == token.EOF { break } offs := file.Offset...
[ "func", "commentSelection", "(", "src", "[", "]", "byte", ")", "Selection", "{", "var", "s", "scanner", ".", "Scanner", "\n", "fset", ":=", "token", ".", "NewFileSet", "(", ")", "\n", "file", ":=", "fset", ".", "AddFile", "(", "\"", "\"", ",", "fset"...
// commentSelection returns the sequence of consecutive comments // in the Go src text as a Selection. //
[ "commentSelection", "returns", "the", "sequence", "of", "consecutive", "comments", "in", "the", "Go", "src", "text", "as", "a", "Selection", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/website/pk-web/format.go#L232-L251
32,028
perkeep/perkeep
website/pk-web/format.go
makeSelection
func makeSelection(matches [][]int) Selection { return func() (seg []int) { if len(matches) > 0 { seg = matches[0] matches = matches[1:] } return } }
go
func makeSelection(matches [][]int) Selection { return func() (seg []int) { if len(matches) > 0 { seg = matches[0] matches = matches[1:] } return } }
[ "func", "makeSelection", "(", "matches", "[", "]", "[", "]", "int", ")", "Selection", "{", "return", "func", "(", ")", "(", "seg", "[", "]", "int", ")", "{", "if", "len", "(", "matches", ")", ">", "0", "{", "seg", "=", "matches", "[", "0", "]",...
// makeSelection is a helper function to make a Selection from a slice of pairs.
[ "makeSelection", "is", "a", "helper", "function", "to", "make", "a", "Selection", "from", "a", "slice", "of", "pairs", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/website/pk-web/format.go#L254-L262
32,029
perkeep/perkeep
website/pk-web/format.go
regexpSelection
func regexpSelection(text []byte, expr string) Selection { var matches [][]int if rx, err := regexp.Compile(expr); err == nil { matches = rx.FindAllIndex(text, -1) } return makeSelection(matches) }
go
func regexpSelection(text []byte, expr string) Selection { var matches [][]int if rx, err := regexp.Compile(expr); err == nil { matches = rx.FindAllIndex(text, -1) } return makeSelection(matches) }
[ "func", "regexpSelection", "(", "text", "[", "]", "byte", ",", "expr", "string", ")", "Selection", "{", "var", "matches", "[", "]", "[", "]", "int", "\n", "if", "rx", ",", "err", ":=", "regexp", ".", "Compile", "(", "expr", ")", ";", "err", "==", ...
// regexpSelection computes the Selection for the regular expression expr in text.
[ "regexpSelection", "computes", "the", "Selection", "for", "the", "regular", "expression", "expr", "in", "text", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/website/pk-web/format.go#L265-L271
32,030
perkeep/perkeep
website/pk-web/format.go
rangeSelection
func rangeSelection(str string) Selection { m := selRx.FindStringSubmatch(str) if len(m) >= 2 { from, _ := strconv.Atoi(m[1]) to, _ := strconv.Atoi(m[2]) if from < to { return makeSelection([][]int{{from, to}}) } } return nil }
go
func rangeSelection(str string) Selection { m := selRx.FindStringSubmatch(str) if len(m) >= 2 { from, _ := strconv.Atoi(m[1]) to, _ := strconv.Atoi(m[2]) if from < to { return makeSelection([][]int{{from, to}}) } } return nil }
[ "func", "rangeSelection", "(", "str", "string", ")", "Selection", "{", "m", ":=", "selRx", ".", "FindStringSubmatch", "(", "str", ")", "\n", "if", "len", "(", "m", ")", ">=", "2", "{", "from", ",", "_", ":=", "strconv", ".", "Atoi", "(", "m", "[", ...
// rangeSelection computes the Selection for a text range described // by the argument str; the range description must match the selRx // regular expression. //
[ "rangeSelection", "computes", "the", "Selection", "for", "a", "text", "range", "described", "by", "the", "argument", "str", ";", "the", "range", "description", "must", "match", "the", "selRx", "regular", "expression", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/website/pk-web/format.go#L279-L289
32,031
perkeep/perkeep
clients/android/build-in-docker.go
getVersion
func getVersion() string { slurp, err := ioutil.ReadFile(filepath.Join(camliDir, "VERSION")) if err == nil { return strings.TrimSpace(string(slurp)) } return gitVersion() }
go
func getVersion() string { slurp, err := ioutil.ReadFile(filepath.Join(camliDir, "VERSION")) if err == nil { return strings.TrimSpace(string(slurp)) } return gitVersion() }
[ "func", "getVersion", "(", ")", "string", "{", "slurp", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "filepath", ".", "Join", "(", "camliDir", ",", "\"", "\"", ")", ")", "\n", "if", "err", "==", "nil", "{", "return", "strings", ".", "TrimSpace",...
// getVersion returns the version of Perkeep. Either from a VERSION file at the root, // or from git.
[ "getVersion", "returns", "the", "version", "of", "Perkeep", ".", "Either", "from", "a", "VERSION", "file", "at", "the", "root", "or", "from", "git", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/clients/android/build-in-docker.go#L107-L113
32,032
perkeep/perkeep
clients/android/build-in-docker.go
gitVersion
func gitVersion() string { cmd := exec.Command("git", "rev-list", "--max-count=1", "--pretty=format:'%ad-%h'", "--date=short", "--abbrev=10", "HEAD") cmd.Dir = camliDir out, err := cmd.Output() if err != nil { log.Fatalf("Error running git rev-list in %s: %v", camliDir, err) } v := strings.TrimSpace(string(ou...
go
func gitVersion() string { cmd := exec.Command("git", "rev-list", "--max-count=1", "--pretty=format:'%ad-%h'", "--date=short", "--abbrev=10", "HEAD") cmd.Dir = camliDir out, err := cmd.Output() if err != nil { log.Fatalf("Error running git rev-list in %s: %v", camliDir, err) } v := strings.TrimSpace(string(ou...
[ "func", "gitVersion", "(", ")", "string", "{", "cmd", ":=", "exec", ".", "Command", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "cmd", ".", "Dir", "=", "c...
// gitVersion returns the git version of the git repo at camRoot as a // string of the form "yyyy-mm-dd-xxxxxxx", with an optional trailing // '+' if there are any local uncommitted modifications to the tree.
[ "gitVersion", "returns", "the", "git", "version", "of", "the", "git", "repo", "at", "camRoot", "as", "a", "string", "of", "the", "form", "yyyy", "-", "mm", "-", "dd", "-", "xxxxxxx", "with", "an", "optional", "trailing", "+", "if", "there", "are", "any...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/clients/android/build-in-docker.go#L120-L140
32,033
perkeep/perkeep
pkg/importer/picasa/picasa.go
findExistingPermanode
func findExistingPermanode(ctx context.Context, qs search.QueryDescriber, wholeRef blob.Ref) (pn blob.Ref, err error) { res, err := qs.Query(ctx, &search.SearchQuery{ Constraint: &search.Constraint{ Permanode: &search.PermanodeConstraint{ Attr: "camliContent", ValueInSet: &search.Constraint{ File: &s...
go
func findExistingPermanode(ctx context.Context, qs search.QueryDescriber, wholeRef blob.Ref) (pn blob.Ref, err error) { res, err := qs.Query(ctx, &search.SearchQuery{ Constraint: &search.Constraint{ Permanode: &search.PermanodeConstraint{ Attr: "camliContent", ValueInSet: &search.Constraint{ File: &s...
[ "func", "findExistingPermanode", "(", "ctx", "context", ".", "Context", ",", "qs", "search", ".", "QueryDescriber", ",", "wholeRef", "blob", ".", "Ref", ")", "(", "pn", "blob", ".", "Ref", ",", "err", "error", ")", "{", "res", ",", "err", ":=", "qs", ...
// findExistingPermanode finds an existing permanode that has a // camliContent pointing to a file with the provided wholeRef and // doesn't have any conflicting attributes that would prevent the // picasa importer from re-using that permanode for its own use.
[ "findExistingPermanode", "finds", "an", "existing", "permanode", "that", "has", "a", "camliContent", "pointing", "to", "a", "file", "with", "the", "provided", "wholeRef", "and", "doesn", "t", "have", "any", "conflicting", "attributes", "that", "would", "prevent", ...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/picasa/picasa.go#L550-L588
32,034
perkeep/perkeep
server/perkeepd/ui/goui/importshare/importshare.go
Import
func Import(ctx context.Context, config map[string]string, shareURL string, updateDialogFunc func(message string, importedBlobRef string)) { printerr := func(msg string) { showError(msg, func(msg string) { updateDialogFunc(msg, "") }) } if config == nil { printerr("Nil config for Import share") return }...
go
func Import(ctx context.Context, config map[string]string, shareURL string, updateDialogFunc func(message string, importedBlobRef string)) { printerr := func(msg string) { showError(msg, func(msg string) { updateDialogFunc(msg, "") }) } if config == nil { printerr("Nil config for Import share") return }...
[ "func", "Import", "(", "ctx", "context", ".", "Context", ",", "config", "map", "[", "string", "]", "string", ",", "shareURL", "string", ",", "updateDialogFunc", "func", "(", "message", "string", ",", "importedBlobRef", "string", ")", ")", "{", "printerr", ...
// Import sends the shareURL to the server, so it can import all the blobs // transitively reachable through the claim in that share URL. It then regularly // polls the server to get the state of the currently running import process, and // it uses updateDialogFunc to update the web UI with that state. Message is // pr...
[ "Import", "sends", "the", "shareURL", "to", "the", "server", "so", "it", "can", "import", "all", "the", "blobs", "transitively", "reachable", "through", "the", "claim", "in", "that", "share", "URL", ".", "It", "then", "regularly", "polls", "the", "server", ...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/perkeepd/ui/goui/importshare/importshare.go#L45-L107
32,035
perkeep/perkeep
server/perkeepd/ui/goui/importshare/importshare.go
updateDialog
func updateDialog(progress camtypes.ShareImportProgress, updateDialogFunc func(message string, importedBlobRef string)) { if progress.Running { if progress.Assembled { updateDialogFunc("Importing file in progress", "") return } updateDialogFunc(fmt.Sprintf("Working - %d/%d files imported", progress.FilesC...
go
func updateDialog(progress camtypes.ShareImportProgress, updateDialogFunc func(message string, importedBlobRef string)) { if progress.Running { if progress.Assembled { updateDialogFunc("Importing file in progress", "") return } updateDialogFunc(fmt.Sprintf("Working - %d/%d files imported", progress.FilesC...
[ "func", "updateDialog", "(", "progress", "camtypes", ".", "ShareImportProgress", ",", "updateDialogFunc", "func", "(", "message", "string", ",", "importedBlobRef", "string", ")", ")", "{", "if", "progress", ".", "Running", "{", "if", "progress", ".", "Assembled"...
// updateDialog uses updateDialogFunc to refresh the dialog that displays the // status of the import. Message is printed first in the dialog, and // importBlobRef is only passed when the import is done, to be displayed below as a // link to the newly imported file or directory.
[ "updateDialog", "uses", "updateDialogFunc", "to", "refresh", "the", "dialog", "that", "displays", "the", "status", "of", "the", "import", ".", "Message", "is", "printed", "first", "in", "the", "dialog", "and", "importBlobRef", "is", "only", "passed", "when", "...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/perkeepd/ui/goui/importshare/importshare.go#L113-L129
32,036
perkeep/perkeep
pkg/webserver/listen/listen.go
NewFlag
func NewFlag(flagName, defaultValue string, serverType string) *Addr { addr := &Addr{ s: defaultValue, } flag.Var(addr, flagName, Usage(serverType)) return addr }
go
func NewFlag(flagName, defaultValue string, serverType string) *Addr { addr := &Addr{ s: defaultValue, } flag.Var(addr, flagName, Usage(serverType)) return addr }
[ "func", "NewFlag", "(", "flagName", ",", "defaultValue", "string", ",", "serverType", "string", ")", "*", "Addr", "{", "addr", ":=", "&", "Addr", "{", "s", ":", "defaultValue", ",", "}", "\n", "flag", ".", "Var", "(", "addr", ",", "flagName", ",", "U...
// NewFlag returns a flag that implements the flag.Value interface.
[ "NewFlag", "returns", "a", "flag", "that", "implements", "the", "flag", ".", "Value", "interface", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/webserver/listen/listen.go#L31-L37
32,037
perkeep/perkeep
pkg/webserver/listen/listen.go
Usage
func Usage(name string) string { if name == "" { name = "Listen address" } if !strings.HasSuffix(name, " address") { name += " address" } return name + "; may be port, :port, ip:port, or FD:<fd_num>" }
go
func Usage(name string) string { if name == "" { name = "Listen address" } if !strings.HasSuffix(name, " address") { name += " address" } return name + "; may be port, :port, ip:port, or FD:<fd_num>" }
[ "func", "Usage", "(", "name", "string", ")", "string", "{", "if", "name", "==", "\"", "\"", "{", "name", "=", "\"", "\"", "\n", "}", "\n", "if", "!", "strings", ".", "HasSuffix", "(", "name", ",", "\"", "\"", ")", "{", "name", "+=", "\"", "\"",...
// Usage returns a descriptive usage message for a flag given the name // of thing being addressed.
[ "Usage", "returns", "a", "descriptive", "usage", "message", "for", "a", "flag", "given", "the", "name", "of", "thing", "being", "addressed", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/webserver/listen/listen.go#L49-L57
32,038
perkeep/perkeep
pkg/webserver/listen/listen.go
Listen
func (a *Addr) Listen() (net.Listener, error) { // Start the listener now, if there's a default // and nothing's called Set yet. if a.err == nil && a.ln == nil && a.s != "" { if err := a.Set(a.s); err != nil { return nil, err } } if a.err != nil { return nil, a.err } if a.ln != nil { return a.ln, nil ...
go
func (a *Addr) Listen() (net.Listener, error) { // Start the listener now, if there's a default // and nothing's called Set yet. if a.err == nil && a.ln == nil && a.s != "" { if err := a.Set(a.s); err != nil { return nil, err } } if a.err != nil { return nil, a.err } if a.ln != nil { return a.ln, nil ...
[ "func", "(", "a", "*", "Addr", ")", "Listen", "(", ")", "(", "net", ".", "Listener", ",", "error", ")", "{", "// Start the listener now, if there's a default", "// and nothing's called Set yet.", "if", "a", ".", "err", "==", "nil", "&&", "a", ".", "ln", "=="...
// Listen returns the address's TCP listener.
[ "Listen", "returns", "the", "address", "s", "TCP", "listener", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/webserver/listen/listen.go#L118-L133
32,039
perkeep/perkeep
pkg/schema/dirreader.go
NewDirReader
func NewDirReader(ctx context.Context, fetcher blob.Fetcher, dirBlobRef blob.Ref) (*DirReader, error) { ss := new(superset) err := ss.setFromBlobRef(ctx, fetcher, dirBlobRef) if err != nil { return nil, err } if ss.Type != "directory" { return nil, fmt.Errorf("schema/dirreader: expected \"directory\" schema bl...
go
func NewDirReader(ctx context.Context, fetcher blob.Fetcher, dirBlobRef blob.Ref) (*DirReader, error) { ss := new(superset) err := ss.setFromBlobRef(ctx, fetcher, dirBlobRef) if err != nil { return nil, err } if ss.Type != "directory" { return nil, fmt.Errorf("schema/dirreader: expected \"directory\" schema bl...
[ "func", "NewDirReader", "(", "ctx", "context", ".", "Context", ",", "fetcher", "blob", ".", "Fetcher", ",", "dirBlobRef", "blob", ".", "Ref", ")", "(", "*", "DirReader", ",", "error", ")", "{", "ss", ":=", "new", "(", "superset", ")", "\n", "err", ":...
// NewDirReader creates a new directory reader and prepares to // fetch the static-set entries
[ "NewDirReader", "creates", "a", "new", "directory", "reader", "and", "prepares", "to", "fetch", "the", "static", "-", "set", "entries" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/schema/dirreader.go#L43-L58
32,040
perkeep/perkeep
pkg/schema/dirreader.go
StaticSet
func (dr *DirReader) StaticSet(ctx context.Context) ([]blob.Ref, error) { if dr.staticSet != nil { return dr.staticSet, nil } staticSetBlobref := dr.ss.Entries if !staticSetBlobref.Valid() { return nil, errors.New("schema/dirreader: Invalid blobref") } members, err := staticSet(ctx, staticSetBlobref, dr.fetch...
go
func (dr *DirReader) StaticSet(ctx context.Context) ([]blob.Ref, error) { if dr.staticSet != nil { return dr.staticSet, nil } staticSetBlobref := dr.ss.Entries if !staticSetBlobref.Valid() { return nil, errors.New("schema/dirreader: Invalid blobref") } members, err := staticSet(ctx, staticSetBlobref, dr.fetch...
[ "func", "(", "dr", "*", "DirReader", ")", "StaticSet", "(", "ctx", "context", ".", "Context", ")", "(", "[", "]", "blob", ".", "Ref", ",", "error", ")", "{", "if", "dr", ".", "staticSet", "!=", "nil", "{", "return", "dr", ".", "staticSet", ",", "...
// StaticSet returns the whole of the static set members of that directory
[ "StaticSet", "returns", "the", "whole", "of", "the", "static", "set", "members", "of", "that", "directory" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/schema/dirreader.go#L88-L102
32,041
perkeep/perkeep
pkg/schema/dirreader.go
Readdir
func (dr *DirReader) Readdir(ctx context.Context, n int) (entries []DirectoryEntry, err error) { sts, err := dr.StaticSet(ctx) if err != nil { return nil, fmt.Errorf("schema/dirreader: can't get StaticSet: %v", err) } up := dr.current + n if n <= 0 { dr.current = 0 up = len(sts) } else { if n > (len(sts) ...
go
func (dr *DirReader) Readdir(ctx context.Context, n int) (entries []DirectoryEntry, err error) { sts, err := dr.StaticSet(ctx) if err != nil { return nil, fmt.Errorf("schema/dirreader: can't get StaticSet: %v", err) } up := dr.current + n if n <= 0 { dr.current = 0 up = len(sts) } else { if n > (len(sts) ...
[ "func", "(", "dr", "*", "DirReader", ")", "Readdir", "(", "ctx", "context", ".", "Context", ",", "n", "int", ")", "(", "entries", "[", "]", "DirectoryEntry", ",", "err", "error", ")", "{", "sts", ",", "err", ":=", "dr", ".", "StaticSet", "(", "ctx"...
// Readdir implements the Directory interface.
[ "Readdir", "implements", "the", "Directory", "interface", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/schema/dirreader.go#L146-L197
32,042
perkeep/perkeep
server/perkeepd/ui/goui/selectallbutton/gen_SelectAllBtn_reactGen.go
Props
func (s SelectAllBtnDef) Props() SelectAllBtnProps { uprops := s.ComponentDef.Props() return uprops.(SelectAllBtnProps) }
go
func (s SelectAllBtnDef) Props() SelectAllBtnProps { uprops := s.ComponentDef.Props() return uprops.(SelectAllBtnProps) }
[ "func", "(", "s", "SelectAllBtnDef", ")", "Props", "(", ")", "SelectAllBtnProps", "{", "uprops", ":=", "s", ".", "ComponentDef", ".", "Props", "(", ")", "\n", "return", "uprops", ".", "(", "SelectAllBtnProps", ")", "\n", "}" ]
// Props is an auto-generated proxy to the current props of SelectAllBtn
[ "Props", "is", "an", "auto", "-", "generated", "proxy", "to", "the", "current", "props", "of", "SelectAllBtn" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/perkeepd/ui/goui/selectallbutton/gen_SelectAllBtn_reactGen.go#L30-L33
32,043
perkeep/perkeep
pkg/blobserver/dir/dir.go
New
func New(dir string) (blobserver.Storage, error) { if v, err := diskpacked.IsDir(dir); err != nil { return nil, err } else if v { return diskpacked.New(dir) } if v, err := localdisk.IsDir(dir); err != nil { return nil, err } else if v { return localdisk.New(dir) } return diskpacked.New(dir) }
go
func New(dir string) (blobserver.Storage, error) { if v, err := diskpacked.IsDir(dir); err != nil { return nil, err } else if v { return diskpacked.New(dir) } if v, err := localdisk.IsDir(dir); err != nil { return nil, err } else if v { return localdisk.New(dir) } return diskpacked.New(dir) }
[ "func", "New", "(", "dir", "string", ")", "(", "blobserver", ".", "Storage", ",", "error", ")", "{", "if", "v", ",", "err", ":=", "diskpacked", ".", "IsDir", "(", "dir", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", ...
// New returns a new blobserver Storage implementation, storing blobs in the provided dir. // If dir has an index.kv file, a diskpacked implementation is returned.
[ "New", "returns", "a", "new", "blobserver", "Storage", "implementation", "storing", "blobs", "in", "the", "provided", "dir", ".", "If", "dir", "has", "an", "index", ".", "kv", "file", "a", "diskpacked", "implementation", "is", "returned", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/dir/dir.go#L30-L42
32,044
perkeep/perkeep
pkg/blobserver/localdisk/localdisk.go
New
func New(root string) (*DiskStorage, error) { // Local disk. fi, err := os.Stat(root) if os.IsNotExist(err) { // As a special case, we auto-created the "packed" directory for subpacked. if filepath.Base(root) == "packed" { if err := os.Mkdir(root, 0700); err != nil { return nil, fmt.Errorf("failed to mkdi...
go
func New(root string) (*DiskStorage, error) { // Local disk. fi, err := os.Stat(root) if os.IsNotExist(err) { // As a special case, we auto-created the "packed" directory for subpacked. if filepath.Base(root) == "packed" { if err := os.Mkdir(root, 0700); err != nil { return nil, fmt.Errorf("failed to mkdi...
[ "func", "New", "(", "root", "string", ")", "(", "*", "DiskStorage", ",", "error", ")", "{", "// Local disk.", "fi", ",", "err", ":=", "os", ".", "Stat", "(", "root", ")", "\n", "if", "os", ".", "IsNotExist", "(", "err", ")", "{", "// As a special cas...
// New returns a new local disk storage implementation at the provided // root directory, which must already exist.
[ "New", "returns", "a", "new", "local", "disk", "storage", "implementation", "at", "the", "provided", "root", "directory", "which", "must", "already", "exist", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/localdisk/localdisk.go#L96-L146
32,045
perkeep/perkeep
app/scanningcabinet/models.go
MakeMediaObjectViewModels
func MakeMediaObjectViewModels(mediaObjects []mediaObject) []MediaObjectVM { models := make([]MediaObjectVM, len(mediaObjects)) for i := 0; i < len(mediaObjects); i++ { models[i] = mediaObjects[i].MakeViewModel() } return models }
go
func MakeMediaObjectViewModels(mediaObjects []mediaObject) []MediaObjectVM { models := make([]MediaObjectVM, len(mediaObjects)) for i := 0; i < len(mediaObjects); i++ { models[i] = mediaObjects[i].MakeViewModel() } return models }
[ "func", "MakeMediaObjectViewModels", "(", "mediaObjects", "[", "]", "mediaObject", ")", "[", "]", "MediaObjectVM", "{", "models", ":=", "make", "(", "[", "]", "MediaObjectVM", ",", "len", "(", "mediaObjects", ")", ")", "\n", "for", "i", ":=", "0", ";", "...
// MakeMediaObjectViewModels takes a slice of MediaObjects and returns a slice of // the same number of MediaObjectVMs with the data converted.
[ "MakeMediaObjectViewModels", "takes", "a", "slice", "of", "MediaObjects", "and", "returns", "a", "slice", "of", "the", "same", "number", "of", "MediaObjectVMs", "with", "the", "data", "converted", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/scanningcabinet/models.go#L93-L99
32,046
perkeep/perkeep
app/scanningcabinet/models.go
someTitle
func (doc *document) someTitle() string { if doc.title != "" { return doc.title } if doc.tags.isEmpty() { return fmt.Sprintf("Doc Ref %s", doc.permanode) } return strings.Join(doc.tags, ",") }
go
func (doc *document) someTitle() string { if doc.title != "" { return doc.title } if doc.tags.isEmpty() { return fmt.Sprintf("Doc Ref %s", doc.permanode) } return strings.Join(doc.tags, ",") }
[ "func", "(", "doc", "*", "document", ")", "someTitle", "(", ")", "string", "{", "if", "doc", ".", "title", "!=", "\"", "\"", "{", "return", "doc", ".", "title", "\n", "}", "\n", "if", "doc", ".", "tags", ".", "isEmpty", "(", ")", "{", "return", ...
// SomeTitle returns this struct's title or, failing that, its tags - // and even failing that, its IntID
[ "SomeTitle", "returns", "this", "struct", "s", "title", "or", "failing", "that", "its", "tags", "-", "and", "even", "failing", "that", "its", "IntID" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/scanningcabinet/models.go#L154-L162
32,047
perkeep/perkeep
app/scanningcabinet/models.go
formatYyyyMmDd
func formatYyyyMmDd(indate time.Time) string { if indate.IsZero() { return "" } return indate.Format(dateformatYyyyMmDd) }
go
func formatYyyyMmDd(indate time.Time) string { if indate.IsZero() { return "" } return indate.Format(dateformatYyyyMmDd) }
[ "func", "formatYyyyMmDd", "(", "indate", "time", ".", "Time", ")", "string", "{", "if", "indate", ".", "IsZero", "(", ")", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "indate", ".", "Format", "(", "dateformatYyyyMmDd", ")", "\n", "}" ]
// formatYyyyMmDd is a convenience function that formats a given Time according to // the DateformatYyyyMmDd const
[ "formatYyyyMmDd", "is", "a", "convenience", "function", "that", "formats", "a", "given", "Time", "according", "to", "the", "DateformatYyyyMmDd", "const" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/scanningcabinet/models.go#L176-L181
32,048
perkeep/perkeep
app/scanningcabinet/models.go
MakeDocumentViewModels
func MakeDocumentViewModels(docs []*document) []DocumentVM { models := make([]DocumentVM, len(docs)) for i := 0; i < len(docs); i++ { models[i] = docs[i].MakeViewModel() } return models }
go
func MakeDocumentViewModels(docs []*document) []DocumentVM { models := make([]DocumentVM, len(docs)) for i := 0; i < len(docs); i++ { models[i] = docs[i].MakeViewModel() } return models }
[ "func", "MakeDocumentViewModels", "(", "docs", "[", "]", "*", "document", ")", "[", "]", "DocumentVM", "{", "models", ":=", "make", "(", "[", "]", "DocumentVM", ",", "len", "(", "docs", ")", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", ...
// MakeDocumentViewModels takes a slice of Documents and returns a slice of // the same number of DocumentVMs with the data converted.
[ "MakeDocumentViewModels", "takes", "a", "slice", "of", "Documents", "and", "returns", "a", "slice", "of", "the", "same", "number", "of", "DocumentVMs", "with", "the", "data", "converted", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/scanningcabinet/models.go#L211-L217
32,049
perkeep/perkeep
pkg/blobserver/gethandler/get.go
ServeBlobRef
func ServeBlobRef(rw http.ResponseWriter, req *http.Request, blobRef blob.Ref, fetcher blob.Fetcher) { ctx := req.Context() if fetcher == nil { log.Printf("gethandler: no fetcher configured for %s (ref=%v)", req.URL.Path, blobRef) rw.WriteHeader(http.StatusNotFound) io.WriteString(rw, "no fetcher configured") ...
go
func ServeBlobRef(rw http.ResponseWriter, req *http.Request, blobRef blob.Ref, fetcher blob.Fetcher) { ctx := req.Context() if fetcher == nil { log.Printf("gethandler: no fetcher configured for %s (ref=%v)", req.URL.Path, blobRef) rw.WriteHeader(http.StatusNotFound) io.WriteString(rw, "no fetcher configured") ...
[ "func", "ServeBlobRef", "(", "rw", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ",", "blobRef", "blob", ".", "Ref", ",", "fetcher", "blob", ".", "Fetcher", ")", "{", "ctx", ":=", "req", ".", "Context", "(", ")", "\n", "if",...
// ServeBlobRef serves a blob.
[ "ServeBlobRef", "serves", "a", "blob", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/gethandler/get.go#L65-L121
32,050
perkeep/perkeep
pkg/blobserver/gethandler/get.go
simulatePrematurelyClosedConnection
func simulatePrematurelyClosedConnection(rw http.ResponseWriter, req *http.Request) { flusher, ok := rw.(http.Flusher) if !ok { return } hj, ok := rw.(http.Hijacker) if !ok { return } for n := 1; n <= 100; n++ { fmt.Fprintf(rw, "line %d\n", n) flusher.Flush() } wrc, _, _ := hj.Hijack() wrc.Close() // ...
go
func simulatePrematurelyClosedConnection(rw http.ResponseWriter, req *http.Request) { flusher, ok := rw.(http.Flusher) if !ok { return } hj, ok := rw.(http.Hijacker) if !ok { return } for n := 1; n <= 100; n++ { fmt.Fprintf(rw, "line %d\n", n) flusher.Flush() } wrc, _, _ := hj.Hijack() wrc.Close() // ...
[ "func", "simulatePrematurelyClosedConnection", "(", "rw", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "flusher", ",", "ok", ":=", "rw", ".", "(", "http", ".", "Flusher", ")", "\n", "if", "!", "ok", "{", "return", "...
// For client testing.
[ "For", "client", "testing", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/gethandler/get.go#L138-L153
32,051
perkeep/perkeep
pkg/fileembed/genfileembed/genfileembed.go
matchingFiles
func matchingFiles(p *regexp.Regexp) []string { var f []string err := filepath.Walk(".", func(path string, fi os.FileInfo, err error) error { if err != nil { return err } n := filepath.Base(path) if !fi.IsDir() && !strings.HasPrefix(n, "zembed_") && p.MatchString(n) { f = append(f, path) } return ni...
go
func matchingFiles(p *regexp.Regexp) []string { var f []string err := filepath.Walk(".", func(path string, fi os.FileInfo, err error) error { if err != nil { return err } n := filepath.Base(path) if !fi.IsDir() && !strings.HasPrefix(n, "zembed_") && p.MatchString(n) { f = append(f, path) } return ni...
[ "func", "matchingFiles", "(", "p", "*", "regexp", ".", "Regexp", ")", "[", "]", "string", "{", "var", "f", "[", "]", "string", "\n", "err", ":=", "filepath", ".", "Walk", "(", "\"", "\"", ",", "func", "(", "path", "string", ",", "fi", "os", ".", ...
// matchingFiles finds all files matching a regex that should be embedded. This // skips files prefixed with "zembed_", since those are an implementation // detail of the embedding process itself.
[ "matchingFiles", "finds", "all", "files", "matching", "a", "regex", "that", "should", "be", "embedded", ".", "This", "skips", "files", "prefixed", "with", "zembed_", "since", "those", "are", "an", "implementation", "detail", "of", "the", "embedding", "process", ...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fileembed/genfileembed/genfileembed.go#L265-L282
32,052
perkeep/perkeep
pkg/jsonsign/signhandler/sig.go
UploadPublicKey
func (h *Handler) UploadPublicKey(ctx context.Context) error { h.pubKeyUploadMu.RLock() if h.pubKeyUploaded { h.pubKeyUploadMu.RUnlock() return nil } h.pubKeyUploadMu.RUnlock() sto := h.pubKeyDest h.pubKeyUploadMu.Lock() defer h.pubKeyUploadMu.Unlock() if h.pubKeyUploaded { return nil } _, err := blob...
go
func (h *Handler) UploadPublicKey(ctx context.Context) error { h.pubKeyUploadMu.RLock() if h.pubKeyUploaded { h.pubKeyUploadMu.RUnlock() return nil } h.pubKeyUploadMu.RUnlock() sto := h.pubKeyDest h.pubKeyUploadMu.Lock() defer h.pubKeyUploadMu.Unlock() if h.pubKeyUploaded { return nil } _, err := blob...
[ "func", "(", "h", "*", "Handler", ")", "UploadPublicKey", "(", "ctx", "context", ".", "Context", ")", "error", "{", "h", ".", "pubKeyUploadMu", ".", "RLock", "(", ")", "\n", "if", "h", ".", "pubKeyUploaded", "{", "h", ".", "pubKeyUploadMu", ".", "RUnlo...
// UploadPublicKey writes the public key to the destination blobserver // defined for the handler, if needed.
[ "UploadPublicKey", "writes", "the", "public", "key", "to", "the", "destination", "blobserver", "defined", "for", "the", "handler", "if", "needed", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/jsonsign/signhandler/sig.go#L136-L159
32,053
perkeep/perkeep
pkg/jsonsign/signhandler/sig.go
Discovery
func (h *Handler) Discovery(base string) *camtypes.SignDiscovery { sd := &camtypes.SignDiscovery{ PublicKeyID: h.entity.PrimaryKey.KeyIdString(), SignHandler: base + "camli/sig/sign", VerifyHandler: base + "camli/sig/verify", } if h.pubKeyBlobRef.Valid() { sd.PublicKeyBlobRef = h.pubKeyBlobRef sd.Publi...
go
func (h *Handler) Discovery(base string) *camtypes.SignDiscovery { sd := &camtypes.SignDiscovery{ PublicKeyID: h.entity.PrimaryKey.KeyIdString(), SignHandler: base + "camli/sig/sign", VerifyHandler: base + "camli/sig/verify", } if h.pubKeyBlobRef.Valid() { sd.PublicKeyBlobRef = h.pubKeyBlobRef sd.Publi...
[ "func", "(", "h", "*", "Handler", ")", "Discovery", "(", "base", "string", ")", "*", "camtypes", ".", "SignDiscovery", "{", "sd", ":=", "&", "camtypes", ".", "SignDiscovery", "{", "PublicKeyID", ":", "h", ".", "entity", ".", "PrimaryKey", ".", "KeyIdStri...
// Discovery returns the Discovery response for the signing handler.
[ "Discovery", "returns", "the", "Discovery", "response", "for", "the", "signing", "handler", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/jsonsign/signhandler/sig.go#L162-L173
32,054
jwilder/docker-gen
template.go
generalizedGroupBy
func generalizedGroupBy(funcName string, entries interface{}, getValue func(interface{}) (interface{}, error), addEntry func(map[string][]interface{}, interface{}, interface{})) (map[string][]interface{}, error) { entriesVal, err := getArrayValues(funcName, entries) if err != nil { return nil, err } groups := m...
go
func generalizedGroupBy(funcName string, entries interface{}, getValue func(interface{}) (interface{}, error), addEntry func(map[string][]interface{}, interface{}, interface{})) (map[string][]interface{}, error) { entriesVal, err := getArrayValues(funcName, entries) if err != nil { return nil, err } groups := m...
[ "func", "generalizedGroupBy", "(", "funcName", "string", ",", "entries", "interface", "{", "}", ",", "getValue", "func", "(", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "error", ")", ",", "addEntry", "func", "(", "map", "[", "string", ...
// Generalized groupBy function
[ "Generalized", "groupBy", "function" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L54-L73
32,055
jwilder/docker-gen
template.go
groupBy
func groupBy(entries interface{}, key string) (map[string][]interface{}, error) { return generalizedGroupByKey("groupBy", entries, key, func(groups map[string][]interface{}, value interface{}, v interface{}) { groups[value.(string)] = append(groups[value.(string)], v) }) }
go
func groupBy(entries interface{}, key string) (map[string][]interface{}, error) { return generalizedGroupByKey("groupBy", entries, key, func(groups map[string][]interface{}, value interface{}, v interface{}) { groups[value.(string)] = append(groups[value.(string)], v) }) }
[ "func", "groupBy", "(", "entries", "interface", "{", "}", ",", "key", "string", ")", "(", "map", "[", "string", "]", "[", "]", "interface", "{", "}", ",", "error", ")", "{", "return", "generalizedGroupByKey", "(", "\"", "\"", ",", "entries", ",", "ke...
// groupBy groups a generic array or slice by the path property key
[ "groupBy", "groups", "a", "generic", "array", "or", "slice", "by", "the", "path", "property", "key" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L92-L96
32,056
jwilder/docker-gen
template.go
groupByKeys
func groupByKeys(entries interface{}, key string) ([]string, error) { keys, err := generalizedGroupByKey("groupByKeys", entries, key, func(groups map[string][]interface{}, value interface{}, v interface{}) { groups[value.(string)] = append(groups[value.(string)], v) }) if err != nil { return nil, err } ret :...
go
func groupByKeys(entries interface{}, key string) ([]string, error) { keys, err := generalizedGroupByKey("groupByKeys", entries, key, func(groups map[string][]interface{}, value interface{}, v interface{}) { groups[value.(string)] = append(groups[value.(string)], v) }) if err != nil { return nil, err } ret :...
[ "func", "groupByKeys", "(", "entries", "interface", "{", "}", ",", "key", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "keys", ",", "err", ":=", "generalizedGroupByKey", "(", "\"", "\"", ",", "entries", ",", "key", ",", "func", "("...
// groupByKeys is the same as groupBy but only returns a list of keys
[ "groupByKeys", "is", "the", "same", "as", "groupBy", "but", "only", "returns", "a", "list", "of", "keys" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L99-L113
32,057
jwilder/docker-gen
template.go
groupByLabel
func groupByLabel(entries interface{}, label string) (map[string][]interface{}, error) { getLabel := func(v interface{}) (interface{}, error) { if container, ok := v.(RuntimeContainer); ok { if value, ok := container.Labels[label]; ok { return value, nil } return nil, nil } return nil, fmt.Errorf("M...
go
func groupByLabel(entries interface{}, label string) (map[string][]interface{}, error) { getLabel := func(v interface{}) (interface{}, error) { if container, ok := v.(RuntimeContainer); ok { if value, ok := container.Labels[label]; ok { return value, nil } return nil, nil } return nil, fmt.Errorf("M...
[ "func", "groupByLabel", "(", "entries", "interface", "{", "}", ",", "label", "string", ")", "(", "map", "[", "string", "]", "[", "]", "interface", "{", "}", ",", "error", ")", "{", "getLabel", ":=", "func", "(", "v", "interface", "{", "}", ")", "("...
// groupByLabel is the same as groupBy but over a given label
[ "groupByLabel", "is", "the", "same", "as", "groupBy", "but", "over", "a", "given", "label" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L116-L129
32,058
jwilder/docker-gen
template.go
generalizedWhere
func generalizedWhere(funcName string, entries interface{}, key string, test func(interface{}) bool) (interface{}, error) { entriesVal, err := getArrayValues(funcName, entries) if err != nil { return nil, err } selection := make([]interface{}, 0) for i := 0; i < entriesVal.Len(); i++ { v := reflect.Indirect(...
go
func generalizedWhere(funcName string, entries interface{}, key string, test func(interface{}) bool) (interface{}, error) { entriesVal, err := getArrayValues(funcName, entries) if err != nil { return nil, err } selection := make([]interface{}, 0) for i := 0; i < entriesVal.Len(); i++ { v := reflect.Indirect(...
[ "func", "generalizedWhere", "(", "funcName", "string", ",", "entries", "interface", "{", "}", ",", "key", "string", ",", "test", "func", "(", "interface", "{", "}", ")", "bool", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "entriesVal", ","...
// Generalized where function
[ "Generalized", "where", "function" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L132-L150
32,059
jwilder/docker-gen
template.go
where
func where(entries interface{}, key string, cmp interface{}) (interface{}, error) { return generalizedWhere("where", entries, key, func(value interface{}) bool { return reflect.DeepEqual(value, cmp) }) }
go
func where(entries interface{}, key string, cmp interface{}) (interface{}, error) { return generalizedWhere("where", entries, key, func(value interface{}) bool { return reflect.DeepEqual(value, cmp) }) }
[ "func", "where", "(", "entries", "interface", "{", "}", ",", "key", "string", ",", "cmp", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "generalizedWhere", "(", "\"", "\"", ",", "entries", ",", "key", ",", ...
// selects entries based on key
[ "selects", "entries", "based", "on", "key" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L153-L157
32,060
jwilder/docker-gen
template.go
whereExist
func whereExist(entries interface{}, key string) (interface{}, error) { return generalizedWhere("whereExist", entries, key, func(value interface{}) bool { return value != nil }) }
go
func whereExist(entries interface{}, key string) (interface{}, error) { return generalizedWhere("whereExist", entries, key, func(value interface{}) bool { return value != nil }) }
[ "func", "whereExist", "(", "entries", "interface", "{", "}", ",", "key", "string", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "generalizedWhere", "(", "\"", "\"", ",", "entries", ",", "key", ",", "func", "(", "value", "interface...
// selects entries where a key exists
[ "selects", "entries", "where", "a", "key", "exists" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L167-L171
32,061
jwilder/docker-gen
template.go
whereAny
func whereAny(entries interface{}, key, sep string, cmp []string) (interface{}, error) { return generalizedWhere("whereAny", entries, key, func(value interface{}) bool { if value == nil { return false } else { items := strings.Split(value.(string), sep) return len(intersect(cmp, items)) > 0 } }) }
go
func whereAny(entries interface{}, key, sep string, cmp []string) (interface{}, error) { return generalizedWhere("whereAny", entries, key, func(value interface{}) bool { if value == nil { return false } else { items := strings.Split(value.(string), sep) return len(intersect(cmp, items)) > 0 } }) }
[ "func", "whereAny", "(", "entries", "interface", "{", "}", ",", "key", ",", "sep", "string", ",", "cmp", "[", "]", "string", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "generalizedWhere", "(", "\"", "\"", ",", "entries", ",", ...
// selects entries based on key. Assumes key is delimited and breaks it apart before comparing
[ "selects", "entries", "based", "on", "key", ".", "Assumes", "key", "is", "delimited", "and", "breaks", "it", "apart", "before", "comparing" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L181-L190
32,062
jwilder/docker-gen
template.go
generalizedWhereLabel
func generalizedWhereLabel(funcName string, containers Context, label string, test func(string, bool) bool) (Context, error) { selection := make([]*RuntimeContainer, 0) for i := 0; i < len(containers); i++ { container := containers[i] value, ok := container.Labels[label] if test(value, ok) { selection = ap...
go
func generalizedWhereLabel(funcName string, containers Context, label string, test func(string, bool) bool) (Context, error) { selection := make([]*RuntimeContainer, 0) for i := 0; i < len(containers); i++ { container := containers[i] value, ok := container.Labels[label] if test(value, ok) { selection = ap...
[ "func", "generalizedWhereLabel", "(", "funcName", "string", ",", "containers", "Context", ",", "label", "string", ",", "test", "func", "(", "string", ",", "bool", ")", "bool", ")", "(", "Context", ",", "error", ")", "{", "selection", ":=", "make", "(", "...
// generalized whereLabel function
[ "generalized", "whereLabel", "function" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L206-L219
32,063
jwilder/docker-gen
template.go
whereLabelExists
func whereLabelExists(containers Context, label string) (Context, error) { return generalizedWhereLabel("whereLabelExists", containers, label, func(_ string, ok bool) bool { return ok }) }
go
func whereLabelExists(containers Context, label string) (Context, error) { return generalizedWhereLabel("whereLabelExists", containers, label, func(_ string, ok bool) bool { return ok }) }
[ "func", "whereLabelExists", "(", "containers", "Context", ",", "label", "string", ")", "(", "Context", ",", "error", ")", "{", "return", "generalizedWhereLabel", "(", "\"", "\"", ",", "containers", ",", "label", ",", "func", "(", "_", "string", ",", "ok", ...
// selects containers that have a particular label
[ "selects", "containers", "that", "have", "a", "particular", "label" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L222-L226
32,064
jwilder/docker-gen
template.go
whereLabelValueMatches
func whereLabelValueMatches(containers Context, label, pattern string) (Context, error) { rx, err := regexp.Compile(pattern) if err != nil { return nil, err } return generalizedWhereLabel("whereLabelValueMatches", containers, label, func(value string, ok bool) bool { return ok && rx.MatchString(value) }) }
go
func whereLabelValueMatches(containers Context, label, pattern string) (Context, error) { rx, err := regexp.Compile(pattern) if err != nil { return nil, err } return generalizedWhereLabel("whereLabelValueMatches", containers, label, func(value string, ok bool) bool { return ok && rx.MatchString(value) }) }
[ "func", "whereLabelValueMatches", "(", "containers", "Context", ",", "label", ",", "pattern", "string", ")", "(", "Context", ",", "error", ")", "{", "rx", ",", "err", ":=", "regexp", ".", "Compile", "(", "pattern", ")", "\n", "if", "err", "!=", "nil", ...
// selects containers with a particular label whose value matches a regular expression
[ "selects", "containers", "with", "a", "particular", "label", "whose", "value", "matches", "a", "regular", "expression" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L236-L245
32,065
jwilder/docker-gen
template.go
arrayFirst
func arrayFirst(input interface{}) interface{} { if input == nil { return nil } arr := reflect.ValueOf(input) if arr.Len() == 0 { return nil } return arr.Index(0).Interface() }
go
func arrayFirst(input interface{}) interface{} { if input == nil { return nil } arr := reflect.ValueOf(input) if arr.Len() == 0 { return nil } return arr.Index(0).Interface() }
[ "func", "arrayFirst", "(", "input", "interface", "{", "}", ")", "interface", "{", "}", "{", "if", "input", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "arr", ":=", "reflect", ".", "ValueOf", "(", "input", ")", "\n\n", "if", "arr", ".", "L...
// arrayFirst returns first item in the array or nil if the // input is nil or empty
[ "arrayFirst", "returns", "first", "item", "in", "the", "array", "or", "nil", "if", "the", "input", "is", "nil", "or", "empty" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L341-L353
32,066
jwilder/docker-gen
template.go
arrayLast
func arrayLast(input interface{}) interface{} { arr := reflect.ValueOf(input) return arr.Index(arr.Len() - 1).Interface() }
go
func arrayLast(input interface{}) interface{} { arr := reflect.ValueOf(input) return arr.Index(arr.Len() - 1).Interface() }
[ "func", "arrayLast", "(", "input", "interface", "{", "}", ")", "interface", "{", "}", "{", "arr", ":=", "reflect", ".", "ValueOf", "(", "input", ")", "\n", "return", "arr", ".", "Index", "(", "arr", ".", "Len", "(", ")", "-", "1", ")", ".", "Inte...
// arrayLast returns last item in the array
[ "arrayLast", "returns", "last", "item", "in", "the", "array" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L356-L359
32,067
jwilder/docker-gen
template.go
arrayClosest
func arrayClosest(values []string, input string) string { best := "" for _, v := range values { if strings.Contains(input, v) && len(v) > len(best) { best = v } } return best }
go
func arrayClosest(values []string, input string) string { best := "" for _, v := range values { if strings.Contains(input, v) && len(v) > len(best) { best = v } } return best }
[ "func", "arrayClosest", "(", "values", "[", "]", "string", ",", "input", "string", ")", "string", "{", "best", ":=", "\"", "\"", "\n", "for", "_", ",", "v", ":=", "range", "values", "{", "if", "strings", ".", "Contains", "(", "input", ",", "v", ")"...
// arrayClosest find the longest matching substring in values // that matches input
[ "arrayClosest", "find", "the", "longest", "matching", "substring", "in", "values", "that", "matches", "input" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L363-L371
32,068
jwilder/docker-gen
template.go
dirList
func dirList(path string) ([]string, error) { names := []string{} files, err := ioutil.ReadDir(path) if err != nil { log.Printf("Template error: %v", err) return names, nil } for _, f := range files { names = append(names, f.Name()) } return names, nil }
go
func dirList(path string) ([]string, error) { names := []string{} files, err := ioutil.ReadDir(path) if err != nil { log.Printf("Template error: %v", err) return names, nil } for _, f := range files { names = append(names, f.Name()) } return names, nil }
[ "func", "dirList", "(", "path", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "names", ":=", "[", "]", "string", "{", "}", "\n", "files", ",", "err", ":=", "ioutil", ".", "ReadDir", "(", "path", ")", "\n", "if", "err", "!=", "...
// dirList returns a list of files in the specified path
[ "dirList", "returns", "a", "list", "of", "files", "in", "the", "specified", "path" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L374-L385
32,069
gliderlabs/logspout
httpstream/httpstream.go
LogStreamer
func LogStreamer() http.Handler { logs := mux.NewRouter() logsHandler := func(w http.ResponseWriter, req *http.Request) { params := mux.Vars(req) route := new(router.Route) if params["value"] != "" { switch params["predicate"] { case "id": route.FilterID = params["value"] if len(route.ID) > 12 { ...
go
func LogStreamer() http.Handler { logs := mux.NewRouter() logsHandler := func(w http.ResponseWriter, req *http.Request) { params := mux.Vars(req) route := new(router.Route) if params["value"] != "" { switch params["predicate"] { case "id": route.FilterID = params["value"] if len(route.ID) > 12 { ...
[ "func", "LogStreamer", "(", ")", "http", ".", "Handler", "{", "logs", ":=", "mux", ".", "NewRouter", "(", ")", "\n", "logsHandler", ":=", "func", "(", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "params", ":...
// LogStreamer returns a http.Handler that can stream logs
[ "LogStreamer", "returns", "a", "http", ".", "Handler", "that", "can", "stream", "logs" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/httpstream/httpstream.go#L27-L72
32,070
gliderlabs/logspout
routesapi/routesapi.go
RoutesAPI
func RoutesAPI() http.Handler { routes := router.Routes r := mux.NewRouter() r.HandleFunc("/routes/{id}", func(w http.ResponseWriter, req *http.Request) { params := mux.Vars(req) route, _ := routes.Get(params["id"]) if route == nil { http.NotFound(w, req) return } w.Write(append(marshal(route), '\n'...
go
func RoutesAPI() http.Handler { routes := router.Routes r := mux.NewRouter() r.HandleFunc("/routes/{id}", func(w http.ResponseWriter, req *http.Request) { params := mux.Vars(req) route, _ := routes.Get(params["id"]) if route == nil { http.NotFound(w, req) return } w.Write(append(marshal(route), '\n'...
[ "func", "RoutesAPI", "(", ")", "http", ".", "Handler", "{", "routes", ":=", "router", ".", "Routes", "\n", "r", ":=", "mux", ".", "NewRouter", "(", ")", "\n\n", "r", ".", "HandleFunc", "(", "\"", "\"", ",", "func", "(", "w", "http", ".", "ResponseW...
// RoutesAPI returns a handler for the routes API
[ "RoutesAPI", "returns", "a", "handler", "for", "the", "routes", "API" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/routesapi/routesapi.go#L18-L63
32,071
gliderlabs/logspout
transports/tls/tls.go
createTLSConfig
func createTLSConfig() (tlsConfig *tls.Config, err error) { tlsConfig = &tls.Config{} // use stronger TLS settings if enabled // TODO: perhaps this should be default setting if os.Getenv(envTLSHardening) == "true" { tlsConfig.InsecureSkipVerify = false tlsConfig.MinVersion = hardenedMinVersion tlsConfig.Ciph...
go
func createTLSConfig() (tlsConfig *tls.Config, err error) { tlsConfig = &tls.Config{} // use stronger TLS settings if enabled // TODO: perhaps this should be default setting if os.Getenv(envTLSHardening) == "true" { tlsConfig.InsecureSkipVerify = false tlsConfig.MinVersion = hardenedMinVersion tlsConfig.Ciph...
[ "func", "createTLSConfig", "(", ")", "(", "tlsConfig", "*", "tls", ".", "Config", ",", "err", "error", ")", "{", "tlsConfig", "=", "&", "tls", ".", "Config", "{", "}", "\n\n", "// use stronger TLS settings if enabled", "// TODO: perhaps this should be default settin...
// createTLSConfig creates the required TLS configuration that we need to establish a TLS connection
[ "createTLSConfig", "creates", "the", "required", "TLS", "configuration", "that", "we", "need", "to", "establish", "a", "TLS", "connection" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/transports/tls/tls.go#L95-L161
32,072
gliderlabs/logspout
adapters/syslog/syslog.go
NewSyslogAdapter
func NewSyslogAdapter(route *router.Route) (router.LogAdapter, error) { transport, found := router.AdapterTransports.Lookup(route.AdapterTransport("udp")) if !found { return nil, errors.New("bad transport: " + route.Adapter) } conn, err := transport.Dial(route.Address, route.Options) if err != nil { return nil...
go
func NewSyslogAdapter(route *router.Route) (router.LogAdapter, error) { transport, found := router.AdapterTransports.Lookup(route.AdapterTransport("udp")) if !found { return nil, errors.New("bad transport: " + route.Adapter) } conn, err := transport.Dial(route.Address, route.Options) if err != nil { return nil...
[ "func", "NewSyslogAdapter", "(", "route", "*", "router", ".", "Route", ")", "(", "router", ".", "LogAdapter", ",", "error", ")", "{", "transport", ",", "found", ":=", "router", ".", "AdapterTransports", ".", "Lookup", "(", "route", ".", "AdapterTransport", ...
// NewSyslogAdapter returnas a configured syslog.Adapter
[ "NewSyslogAdapter", "returnas", "a", "configured", "syslog", ".", "Adapter" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/adapters/syslog/syslog.go#L70-L120
32,073
gliderlabs/logspout
adapters/syslog/syslog.go
Render
func (m *Message) Render(tmpl *template.Template) ([]byte, error) { buf := new(bytes.Buffer) err := tmpl.Execute(buf, m) if err != nil { return nil, err } return buf.Bytes(), nil }
go
func (m *Message) Render(tmpl *template.Template) ([]byte, error) { buf := new(bytes.Buffer) err := tmpl.Execute(buf, m) if err != nil { return nil, err } return buf.Bytes(), nil }
[ "func", "(", "m", "*", "Message", ")", "Render", "(", "tmpl", "*", "template", ".", "Template", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "buf", ":=", "new", "(", "bytes", ".", "Buffer", ")", "\n", "err", ":=", "tmpl", ".", "Execute", ...
// Render transforms the log message using the Syslog template
[ "Render", "transforms", "the", "log", "message", "using", "the", "Syslog", "template" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/adapters/syslog/syslog.go#L234-L241
32,074
gliderlabs/logspout
adapters/syslog/syslog.go
Priority
func (m *Message) Priority() syslog.Priority { switch m.Message.Source { case "stdout": return syslog.LOG_USER | syslog.LOG_INFO case "stderr": return syslog.LOG_USER | syslog.LOG_ERR default: return syslog.LOG_DAEMON | syslog.LOG_INFO } }
go
func (m *Message) Priority() syslog.Priority { switch m.Message.Source { case "stdout": return syslog.LOG_USER | syslog.LOG_INFO case "stderr": return syslog.LOG_USER | syslog.LOG_ERR default: return syslog.LOG_DAEMON | syslog.LOG_INFO } }
[ "func", "(", "m", "*", "Message", ")", "Priority", "(", ")", "syslog", ".", "Priority", "{", "switch", "m", ".", "Message", ".", "Source", "{", "case", "\"", "\"", ":", "return", "syslog", ".", "LOG_USER", "|", "syslog", ".", "LOG_INFO", "\n", "case"...
// Priority returns a syslog.Priority based on the message source
[ "Priority", "returns", "a", "syslog", ".", "Priority", "based", "on", "the", "message", "source" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/adapters/syslog/syslog.go#L244-L253
32,075
gliderlabs/logspout
adapters/syslog/syslog.go
Timestamp
func (m *Message) Timestamp() string { return m.Message.Time.Format(time.RFC3339) }
go
func (m *Message) Timestamp() string { return m.Message.Time.Format(time.RFC3339) }
[ "func", "(", "m", "*", "Message", ")", "Timestamp", "(", ")", "string", "{", "return", "m", ".", "Message", ".", "Time", ".", "Format", "(", "time", ".", "RFC3339", ")", "\n", "}" ]
// Timestamp returns the message's syslog formatted timestamp
[ "Timestamp", "returns", "the", "message", "s", "syslog", "formatted", "timestamp" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/adapters/syslog/syslog.go#L261-L263
32,076
gliderlabs/logspout
healthcheck/healthcheck.go
HealthCheck
func HealthCheck() http.Handler { r := mux.NewRouter() r.HandleFunc("/health", func(w http.ResponseWriter, req *http.Request) { w.Write([]byte("Healthy!\n")) }) return r }
go
func HealthCheck() http.Handler { r := mux.NewRouter() r.HandleFunc("/health", func(w http.ResponseWriter, req *http.Request) { w.Write([]byte("Healthy!\n")) }) return r }
[ "func", "HealthCheck", "(", ")", "http", ".", "Handler", "{", "r", ":=", "mux", ".", "NewRouter", "(", ")", "\n", "r", ".", "HandleFunc", "(", "\"", "\"", ",", "func", "(", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request"...
// HealthCheck returns a http.Handler for the health check
[ "HealthCheck", "returns", "a", "http", ".", "Handler", "for", "the", "health", "check" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/healthcheck/healthcheck.go#L15-L21
32,077
gliderlabs/logspout
router/types.go
AdapterTransport
func (r *Route) AdapterTransport(dfault string) string { parts := strings.Split(r.Adapter, "+") if len(parts) > 1 { return parts[1] } return dfault }
go
func (r *Route) AdapterTransport(dfault string) string { parts := strings.Split(r.Adapter, "+") if len(parts) > 1 { return parts[1] } return dfault }
[ "func", "(", "r", "*", "Route", ")", "AdapterTransport", "(", "dfault", "string", ")", "string", "{", "parts", ":=", "strings", ".", "Split", "(", "r", ".", "Adapter", ",", "\"", "\"", ")", "\n", "if", "len", "(", "parts", ")", ">", "1", "{", "re...
// AdapterTransport returns a route's adapter transport string
[ "AdapterTransport", "returns", "a", "route", "s", "adapter", "transport", "string" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/router/types.go#L81-L87
32,078
gliderlabs/logspout
router/types.go
Closer
func (r *Route) Closer() <-chan bool { if r.closerRcv != nil { return r.closerRcv } return r.closer }
go
func (r *Route) Closer() <-chan bool { if r.closerRcv != nil { return r.closerRcv } return r.closer }
[ "func", "(", "r", "*", "Route", ")", "Closer", "(", ")", "<-", "chan", "bool", "{", "if", "r", ".", "closerRcv", "!=", "nil", "{", "return", "r", ".", "closerRcv", "\n", "}", "\n", "return", "r", ".", "closer", "\n", "}" ]
// Closer returns a route's closerRcv
[ "Closer", "returns", "a", "route", "s", "closerRcv" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/router/types.go#L90-L95
32,079
gliderlabs/logspout
router/types.go
MultiContainer
func (r *Route) MultiContainer() bool { return r.matchAll() || strings.Contains(r.FilterName, "*") }
go
func (r *Route) MultiContainer() bool { return r.matchAll() || strings.Contains(r.FilterName, "*") }
[ "func", "(", "r", "*", "Route", ")", "MultiContainer", "(", ")", "bool", "{", "return", "r", ".", "matchAll", "(", ")", "||", "strings", ".", "Contains", "(", "r", ".", "FilterName", ",", "\"", "\"", ")", "\n", "}" ]
// MultiContainer returns whether the Route is matching multiple containers or not
[ "MultiContainer", "returns", "whether", "the", "Route", "is", "matching", "multiple", "containers", "or", "not" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/router/types.go#L115-L117
32,080
gliderlabs/logspout
router/types.go
MatchContainer
func (r *Route) MatchContainer(id, name string, labels map[string]string) bool { if r.matchAll() { return true } if r.FilterID != "" && !strings.HasPrefix(id, r.FilterID) { return false } match, err := path.Match(r.FilterName, name) if err != nil || (r.FilterName != "" && !match) { return false } for _, l...
go
func (r *Route) MatchContainer(id, name string, labels map[string]string) bool { if r.matchAll() { return true } if r.FilterID != "" && !strings.HasPrefix(id, r.FilterID) { return false } match, err := path.Match(r.FilterName, name) if err != nil || (r.FilterName != "" && !match) { return false } for _, l...
[ "func", "(", "r", "*", "Route", ")", "MatchContainer", "(", "id", ",", "name", "string", ",", "labels", "map", "[", "string", "]", "string", ")", "bool", "{", "if", "r", ".", "matchAll", "(", ")", "{", "return", "true", "\n", "}", "\n", "if", "r"...
// MatchContainer returns whether the Route is responsible for a given container
[ "MatchContainer", "returns", "whether", "the", "Route", "is", "responsible", "for", "a", "given", "container" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/router/types.go#L120-L144
32,081
gliderlabs/logspout
router/types.go
MatchMessage
func (r *Route) MatchMessage(message *Message) bool { if r.matchAll() { return true } if len(r.FilterSources) > 0 && !contains(r.FilterSources, message.Source) { return false } return true }
go
func (r *Route) MatchMessage(message *Message) bool { if r.matchAll() { return true } if len(r.FilterSources) > 0 && !contains(r.FilterSources, message.Source) { return false } return true }
[ "func", "(", "r", "*", "Route", ")", "MatchMessage", "(", "message", "*", "Message", ")", "bool", "{", "if", "r", ".", "matchAll", "(", ")", "{", "return", "true", "\n", "}", "\n", "if", "len", "(", "r", ".", "FilterSources", ")", ">", "0", "&&",...
// MatchMessage returns whether the Route is responsible for a given Message
[ "MatchMessage", "returns", "whether", "the", "Route", "is", "responsible", "for", "a", "given", "Message" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/router/types.go#L147-L155
32,082
gliderlabs/logspout
router/persist.go
Remove
func (fs RouteFileStore) Remove(id string) bool { if _, err := os.Stat(fs.Filename(id)); err == nil { if err := os.Remove(fs.Filename(id)); err != nil { return true } } return false }
go
func (fs RouteFileStore) Remove(id string) bool { if _, err := os.Stat(fs.Filename(id)); err == nil { if err := os.Remove(fs.Filename(id)); err != nil { return true } } return false }
[ "func", "(", "fs", "RouteFileStore", ")", "Remove", "(", "id", "string", ")", "bool", "{", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "fs", ".", "Filename", "(", "id", ")", ")", ";", "err", "==", "nil", "{", "if", "err", ":=", "os", ...
// Remove removes route from the RouteFileStore based on id
[ "Remove", "removes", "route", "from", "the", "RouteFileStore", "based", "on", "id" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/router/persist.go#L58-L65
32,083
gliderlabs/logspout
router/routes.go
Load
func (rm *RouteManager) Load(persistor RouteStore) error { routes, err := persistor.GetAll() if err != nil { return err } for _, route := range routes { rm.Add(route) } rm.persistor = persistor return nil }
go
func (rm *RouteManager) Load(persistor RouteStore) error { routes, err := persistor.GetAll() if err != nil { return err } for _, route := range routes { rm.Add(route) } rm.persistor = persistor return nil }
[ "func", "(", "rm", "*", "RouteManager", ")", "Load", "(", "persistor", "RouteStore", ")", "error", "{", "routes", ",", "err", ":=", "persistor", ".", "GetAll", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "for", ...
// Load loads all route from a RouteStore
[ "Load", "loads", "all", "route", "from", "a", "RouteStore" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/router/routes.go#L35-L45
32,084
gliderlabs/logspout
router/routes.go
Get
func (rm *RouteManager) Get(id string) (*Route, error) { rm.Lock() defer rm.Unlock() route, ok := rm.routes[id] if !ok { return nil, os.ErrNotExist } return route, nil }
go
func (rm *RouteManager) Get(id string) (*Route, error) { rm.Lock() defer rm.Unlock() route, ok := rm.routes[id] if !ok { return nil, os.ErrNotExist } return route, nil }
[ "func", "(", "rm", "*", "RouteManager", ")", "Get", "(", "id", "string", ")", "(", "*", "Route", ",", "error", ")", "{", "rm", ".", "Lock", "(", ")", "\n", "defer", "rm", ".", "Unlock", "(", ")", "\n", "route", ",", "ok", ":=", "rm", ".", "ro...
// Get returns a Route based on id
[ "Get", "returns", "a", "Route", "based", "on", "id" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/router/routes.go#L48-L56
32,085
gliderlabs/logspout
router/routes.go
GetAll
func (rm *RouteManager) GetAll() ([]*Route, error) { rm.Lock() defer rm.Unlock() routes := make([]*Route, 0) for _, route := range rm.routes { routes = append(routes, route) } return routes, nil }
go
func (rm *RouteManager) GetAll() ([]*Route, error) { rm.Lock() defer rm.Unlock() routes := make([]*Route, 0) for _, route := range rm.routes { routes = append(routes, route) } return routes, nil }
[ "func", "(", "rm", "*", "RouteManager", ")", "GetAll", "(", ")", "(", "[", "]", "*", "Route", ",", "error", ")", "{", "rm", ".", "Lock", "(", ")", "\n", "defer", "rm", ".", "Unlock", "(", ")", "\n", "routes", ":=", "make", "(", "[", "]", "*",...
// GetAll returns all routes in the RouteManager
[ "GetAll", "returns", "all", "routes", "in", "the", "RouteManager" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/router/routes.go#L59-L67
32,086
gliderlabs/logspout
router/routes.go
Remove
func (rm *RouteManager) Remove(id string) bool { rm.Lock() defer rm.Unlock() route, ok := rm.routes[id] if ok && route.closer != nil { route.closer <- true } delete(rm.routes, id) if rm.persistor != nil { rm.persistor.Remove(id) } return ok }
go
func (rm *RouteManager) Remove(id string) bool { rm.Lock() defer rm.Unlock() route, ok := rm.routes[id] if ok && route.closer != nil { route.closer <- true } delete(rm.routes, id) if rm.persistor != nil { rm.persistor.Remove(id) } return ok }
[ "func", "(", "rm", "*", "RouteManager", ")", "Remove", "(", "id", "string", ")", "bool", "{", "rm", ".", "Lock", "(", ")", "\n", "defer", "rm", ".", "Unlock", "(", ")", "\n", "route", ",", "ok", ":=", "rm", ".", "routes", "[", "id", "]", "\n", ...
// Remove removes a route from a RouteManager based on id
[ "Remove", "removes", "a", "route", "from", "a", "RouteManager", "based", "on", "id" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/router/routes.go#L70-L82
32,087
gliderlabs/logspout
router/routes.go
AddFromURI
func (rm *RouteManager) AddFromURI(uri string) error { expandedRoute := os.ExpandEnv(uri) u, err := url.Parse(expandedRoute) if err != nil { return err } r := &Route{ Address: u.Host, Adapter: u.Scheme, Options: make(map[string]string), } if u.RawQuery != "" { params, err := url.ParseQuery(u.RawQuery) ...
go
func (rm *RouteManager) AddFromURI(uri string) error { expandedRoute := os.ExpandEnv(uri) u, err := url.Parse(expandedRoute) if err != nil { return err } r := &Route{ Address: u.Host, Adapter: u.Scheme, Options: make(map[string]string), } if u.RawQuery != "" { params, err := url.ParseQuery(u.RawQuery) ...
[ "func", "(", "rm", "*", "RouteManager", ")", "AddFromURI", "(", "uri", "string", ")", "error", "{", "expandedRoute", ":=", "os", ".", "ExpandEnv", "(", "uri", ")", "\n", "u", ",", "err", ":=", "url", ".", "Parse", "(", "expandedRoute", ")", "\n", "if...
// AddFromURI creates a new route from an URI string and adds it to the RouteManager
[ "AddFromURI", "creates", "a", "new", "route", "from", "an", "URI", "string", "and", "adds", "it", "to", "the", "RouteManager" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/router/routes.go#L85-L118
32,088
gliderlabs/logspout
router/routes.go
Add
func (rm *RouteManager) Add(route *Route) error { rm.Lock() defer rm.Unlock() factory, found := AdapterFactories.Lookup(route.AdapterType()) if !found { return errors.New("bad adapter: " + route.Adapter) } adapter, err := factory(route) if err != nil { return err } if route.ID == "" { h := sha1.New() i...
go
func (rm *RouteManager) Add(route *Route) error { rm.Lock() defer rm.Unlock() factory, found := AdapterFactories.Lookup(route.AdapterType()) if !found { return errors.New("bad adapter: " + route.Adapter) } adapter, err := factory(route) if err != nil { return err } if route.ID == "" { h := sha1.New() i...
[ "func", "(", "rm", "*", "RouteManager", ")", "Add", "(", "route", "*", "Route", ")", "error", "{", "rm", ".", "Lock", "(", ")", "\n", "defer", "rm", ".", "Unlock", "(", ")", "\n", "factory", ",", "found", ":=", "AdapterFactories", ".", "Lookup", "(...
// Add adds a route to the RouteManager
[ "Add", "adds", "a", "route", "to", "the", "RouteManager" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/router/routes.go#L121-L154
32,089
gliderlabs/logspout
router/routes.go
Route
func (rm *RouteManager) Route(route *Route, logstream chan *Message) { for _, router := range LogRouters.All() { go router.Route(route, logstream) } }
go
func (rm *RouteManager) Route(route *Route, logstream chan *Message) { for _, router := range LogRouters.All() { go router.Route(route, logstream) } }
[ "func", "(", "rm", "*", "RouteManager", ")", "Route", "(", "route", "*", "Route", ",", "logstream", "chan", "*", "Message", ")", "{", "for", "_", ",", "router", ":=", "range", "LogRouters", ".", "All", "(", ")", "{", "go", "router", ".", "Route", "...
// Route takes a logstream and route and passes them off to all configure LogRouters
[ "Route", "takes", "a", "logstream", "and", "route", "and", "passes", "them", "off", "to", "all", "configure", "LogRouters" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/router/routes.go#L164-L168
32,090
gliderlabs/logspout
router/routes.go
RoutingFrom
func (rm *RouteManager) RoutingFrom(containerID string) bool { for _, router := range LogRouters.All() { if router.RoutingFrom(containerID) { return true } } return false }
go
func (rm *RouteManager) RoutingFrom(containerID string) bool { for _, router := range LogRouters.All() { if router.RoutingFrom(containerID) { return true } } return false }
[ "func", "(", "rm", "*", "RouteManager", ")", "RoutingFrom", "(", "containerID", "string", ")", "bool", "{", "for", "_", ",", "router", ":=", "range", "LogRouters", ".", "All", "(", ")", "{", "if", "router", ".", "RoutingFrom", "(", "containerID", ")", ...
// RoutingFrom returns whether a given container is routing through the RouteManager
[ "RoutingFrom", "returns", "whether", "a", "given", "container", "is", "routing", "through", "the", "RouteManager" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/router/routes.go#L171-L178
32,091
gliderlabs/logspout
router/routes.go
Run
func (rm *RouteManager) Run() error { rm.Lock() for _, route := range rm.routes { rm.wg.Add(1) go func(route *Route) { rm.route(route) rm.wg.Done() }(route) } rm.routing = true rm.Unlock() rm.wg.Wait() // Temp fix to allow logspout to run without routes defined. if len(rm.routes) == 0 { select {} ...
go
func (rm *RouteManager) Run() error { rm.Lock() for _, route := range rm.routes { rm.wg.Add(1) go func(route *Route) { rm.route(route) rm.wg.Done() }(route) } rm.routing = true rm.Unlock() rm.wg.Wait() // Temp fix to allow logspout to run without routes defined. if len(rm.routes) == 0 { select {} ...
[ "func", "(", "rm", "*", "RouteManager", ")", "Run", "(", ")", "error", "{", "rm", ".", "Lock", "(", ")", "\n", "for", "_", ",", "route", ":=", "range", "rm", ".", "routes", "{", "rm", ".", "wg", ".", "Add", "(", "1", ")", "\n", "go", "func", ...
// Run executes the RouteManager
[ "Run", "executes", "the", "RouteManager" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/router/routes.go#L181-L198
32,092
gliderlabs/logspout
router/routes.go
Setup
func (rm *RouteManager) Setup() error { var uris string if os.Getenv("ROUTE_URIS") != "" { uris = os.Getenv("ROUTE_URIS") } if len(os.Args) > 1 { uris = os.Args[1] } if uris != "" { for _, uri := range strings.Split(uris, ",") { err := rm.AddFromURI(uri) if err != nil { return err } } } pe...
go
func (rm *RouteManager) Setup() error { var uris string if os.Getenv("ROUTE_URIS") != "" { uris = os.Getenv("ROUTE_URIS") } if len(os.Args) > 1 { uris = os.Args[1] } if uris != "" { for _, uri := range strings.Split(uris, ",") { err := rm.AddFromURI(uri) if err != nil { return err } } } pe...
[ "func", "(", "rm", "*", "RouteManager", ")", "Setup", "(", ")", "error", "{", "var", "uris", "string", "\n", "if", "os", ".", "Getenv", "(", "\"", "\"", ")", "!=", "\"", "\"", "{", "uris", "=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", ...
// Setup configures the RouteManager
[ "Setup", "configures", "the", "RouteManager" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/router/routes.go#L206-L228
32,093
gliderlabs/logspout
adapters/raw/raw.go
NewRawAdapter
func NewRawAdapter(route *router.Route) (router.LogAdapter, error) { transport, found := router.AdapterTransports.Lookup(route.AdapterTransport("udp")) if !found { return nil, errors.New("bad transport: " + route.Adapter) } conn, err := transport.Dial(route.Address, route.Options) if err != nil { return nil, e...
go
func NewRawAdapter(route *router.Route) (router.LogAdapter, error) { transport, found := router.AdapterTransports.Lookup(route.AdapterTransport("udp")) if !found { return nil, errors.New("bad transport: " + route.Adapter) } conn, err := transport.Dial(route.Address, route.Options) if err != nil { return nil, e...
[ "func", "NewRawAdapter", "(", "route", "*", "router", ".", "Route", ")", "(", "router", ".", "LogAdapter", ",", "error", ")", "{", "transport", ",", "found", ":=", "router", ".", "AdapterTransports", ".", "Lookup", "(", "route", ".", "AdapterTransport", "(...
// NewRawAdapter returns a configured raw.Adapter
[ "NewRawAdapter", "returns", "a", "configured", "raw", ".", "Adapter" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/adapters/raw/raw.go#L32-L54
32,094
gliderlabs/logspout
adapters/multiline/multiline.go
NewMultilineAdapter
func NewMultilineAdapter(route *router.Route) (a router.LogAdapter, err error) { enableByDefault := true enableStr := os.Getenv("MULTILINE_ENABLE_DEFAULT") if enableStr != "" { var err error enableByDefault, err = strconv.ParseBool(enableStr) if err != nil { return nil, errors.New("multiline: invalid value ...
go
func NewMultilineAdapter(route *router.Route) (a router.LogAdapter, err error) { enableByDefault := true enableStr := os.Getenv("MULTILINE_ENABLE_DEFAULT") if enableStr != "" { var err error enableByDefault, err = strconv.ParseBool(enableStr) if err != nil { return nil, errors.New("multiline: invalid value ...
[ "func", "NewMultilineAdapter", "(", "route", "*", "router", ".", "Route", ")", "(", "a", "router", ".", "LogAdapter", ",", "err", "error", ")", "{", "enableByDefault", ":=", "true", "\n", "enableStr", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\...
// NewMultilineAdapter returns a configured multiline.Adapter
[ "NewMultilineAdapter", "returns", "a", "configured", "multiline", ".", "Adapter" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/adapters/multiline/multiline.go#L43-L135
32,095
gliderlabs/logspout
adapters/multiline/multiline.go
Stream
func (a *Adapter) Stream(logstream chan *router.Message) { wg := sync.WaitGroup{} wg.Add(1) go func() { a.subAdapter.Stream(a.out) wg.Done() }() defer func() { for _, message := range a.buffers { a.out <- message } close(a.out) wg.Wait() }() for { select { case message, ok := <-logstream: ...
go
func (a *Adapter) Stream(logstream chan *router.Message) { wg := sync.WaitGroup{} wg.Add(1) go func() { a.subAdapter.Stream(a.out) wg.Done() }() defer func() { for _, message := range a.buffers { a.out <- message } close(a.out) wg.Wait() }() for { select { case message, ok := <-logstream: ...
[ "func", "(", "a", "*", "Adapter", ")", "Stream", "(", "logstream", "chan", "*", "router", ".", "Message", ")", "{", "wg", ":=", "sync", ".", "WaitGroup", "{", "}", "\n", "wg", ".", "Add", "(", "1", ")", "\n", "go", "func", "(", ")", "{", "a", ...
// Stream sends log data to the next adapter
[ "Stream", "sends", "log", "data", "to", "the", "next", "adapter" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/adapters/multiline/multiline.go#L138-L204
32,096
gliderlabs/logspout
router/pump.go
Setup
func (p *LogsPump) Setup() error { var err error p.client, err = docker.NewClientFromEnv() return err }
go
func (p *LogsPump) Setup() error { var err error p.client, err = docker.NewClientFromEnv() return err }
[ "func", "(", "p", "*", "LogsPump", ")", "Setup", "(", ")", "error", "{", "var", "err", "error", "\n", "p", ".", "client", ",", "err", "=", "docker", ".", "NewClientFromEnv", "(", ")", "\n", "return", "err", "\n", "}" ]
// Setup configures the pump
[ "Setup", "configures", "the", "pump" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/router/pump.go#L137-L141
32,097
gliderlabs/logspout
router/pump.go
Run
func (p *LogsPump) Run() error { inactivityTimeout := getInactivityTimeoutFromEnv() debug("pump.Run(): using inactivity timeout: ", inactivityTimeout) containers, err := p.client.ListContainers(docker.ListContainersOptions{}) if err != nil { return err } for _, listing := range containers { p.pumpLogs(&docke...
go
func (p *LogsPump) Run() error { inactivityTimeout := getInactivityTimeoutFromEnv() debug("pump.Run(): using inactivity timeout: ", inactivityTimeout) containers, err := p.client.ListContainers(docker.ListContainersOptions{}) if err != nil { return err } for _, listing := range containers { p.pumpLogs(&docke...
[ "func", "(", "p", "*", "LogsPump", ")", "Run", "(", ")", "error", "{", "inactivityTimeout", ":=", "getInactivityTimeoutFromEnv", "(", ")", "\n", "debug", "(", "\"", "\"", ",", "inactivityTimeout", ")", "\n\n", "containers", ",", "err", ":=", "p", ".", "c...
// Run executes the pump
[ "Run", "executes", "the", "pump" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/router/pump.go#L157-L188
32,098
gliderlabs/logspout
router/pump.go
RoutingFrom
func (p *LogsPump) RoutingFrom(id string) bool { p.mu.Lock() defer p.mu.Unlock() _, monitoring := p.pumps[normalID(id)] return monitoring }
go
func (p *LogsPump) RoutingFrom(id string) bool { p.mu.Lock() defer p.mu.Unlock() _, monitoring := p.pumps[normalID(id)] return monitoring }
[ "func", "(", "p", "*", "LogsPump", ")", "RoutingFrom", "(", "id", "string", ")", "bool", "{", "p", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "mu", ".", "Unlock", "(", ")", "\n", "_", ",", "monitoring", ":=", "p", ".", "pumps", ...
// RoutingFrom returns whether a container id is routing from this pump
[ "RoutingFrom", "returns", "whether", "a", "container", "id", "is", "routing", "from", "this", "pump" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/router/pump.go#L297-L302
32,099
gliderlabs/logspout
router/pump.go
Route
func (p *LogsPump) Route(route *Route, logstream chan *Message) { p.mu.Lock() for _, pump := range p.pumps { if route.MatchContainer( normalID(pump.container.ID), normalName(pump.container.Name), pump.container.Config.Labels) { pump.add(logstream, route) defer pump.remove(logstream) } } updates ...
go
func (p *LogsPump) Route(route *Route, logstream chan *Message) { p.mu.Lock() for _, pump := range p.pumps { if route.MatchContainer( normalID(pump.container.ID), normalName(pump.container.Name), pump.container.Config.Labels) { pump.add(logstream, route) defer pump.remove(logstream) } } updates ...
[ "func", "(", "p", "*", "LogsPump", ")", "Route", "(", "route", "*", "Route", ",", "logstream", "chan", "*", "Message", ")", "{", "p", ".", "mu", ".", "Lock", "(", ")", "\n", "for", "_", ",", "pump", ":=", "range", "p", ".", "pumps", "{", "if", ...
// Route takes a logstream and routes it according to the supplied Route
[ "Route", "takes", "a", "logstream", "and", "routes", "it", "according", "to", "the", "supplied", "Route" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/router/pump.go#L305-L350