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
127,900
fsnotify/fsevents
wrap.go
flush
func flush(stream FSEventStreamRef, sync bool) { if sync { C.FSEventStreamFlushSync(stream) } else { C.FSEventStreamFlushAsync(stream) } }
go
func flush(stream FSEventStreamRef, sync bool) { if sync { C.FSEventStreamFlushSync(stream) } else { C.FSEventStreamFlushAsync(stream) } }
[ "func", "flush", "(", "stream", "FSEventStreamRef", ",", "sync", "bool", ")", "{", "if", "sync", "{", "C", ".", "FSEventStreamFlushSync", "(", "stream", ")", "\n", "}", "else", "{", "C", ".", "FSEventStreamFlushAsync", "(", "stream", ")", "\n", "}", "\n"...
// flush drains the event stream of undelivered events
[ "flush", "drains", "the", "event", "stream", "of", "undelivered", "events" ]
f721bd2b045774a566e8f7f5fa2a9985e04c875d
https://github.com/fsnotify/fsevents/blob/f721bd2b045774a566e8f7f5fa2a9985e04c875d/wrap.go#L252-L258
127,901
fsnotify/fsevents
wrap.go
stop
func stop(stream FSEventStreamRef, rlref CFRunLoopRef) { C.FSEventStreamStop(stream) C.FSEventStreamInvalidate(stream) C.FSEventStreamRelease(stream) C.CFRunLoopStop(C.CFRunLoopRef(rlref)) C.CFRelease(C.CFTypeRef(rlref)) }
go
func stop(stream FSEventStreamRef, rlref CFRunLoopRef) { C.FSEventStreamStop(stream) C.FSEventStreamInvalidate(stream) C.FSEventStreamRelease(stream) C.CFRunLoopStop(C.CFRunLoopRef(rlref)) C.CFRelease(C.CFTypeRef(rlref)) }
[ "func", "stop", "(", "stream", "FSEventStreamRef", ",", "rlref", "CFRunLoopRef", ")", "{", "C", ".", "FSEventStreamStop", "(", "stream", ")", "\n", "C", ".", "FSEventStreamInvalidate", "(", "stream", ")", "\n", "C", ".", "FSEventStreamRelease", "(", "stream", ...
// stop requests fsevents stops streaming events
[ "stop", "requests", "fsevents", "stops", "streaming", "events" ]
f721bd2b045774a566e8f7f5fa2a9985e04c875d
https://github.com/fsnotify/fsevents/blob/f721bd2b045774a566e8f7f5fa2a9985e04c875d/wrap.go#L261-L267
127,902
cloudfoundry/bbs
db/sqldb/helpers/upsert.go
Upsert
func (h *sqlHelper) Upsert( logger lager.Logger, q Queryable, table string, attributes SQLAttributes, wheres string, whereBindings ...interface{}, ) (bool, error) { res, err := h.Update( logger, q, table, attributes, wheres, whereBindings..., ) if err != nil { return false, err } rowsAffected,...
go
func (h *sqlHelper) Upsert( logger lager.Logger, q Queryable, table string, attributes SQLAttributes, wheres string, whereBindings ...interface{}, ) (bool, error) { res, err := h.Update( logger, q, table, attributes, wheres, whereBindings..., ) if err != nil { return false, err } rowsAffected,...
[ "func", "(", "h", "*", "sqlHelper", ")", "Upsert", "(", "logger", "lager", ".", "Logger", ",", "q", "Queryable", ",", "table", "string", ",", "attributes", "SQLAttributes", ",", "wheres", "string", ",", "whereBindings", "...", "interface", "{", "}", ",", ...
// Upsert insert a record if it doesn't exist or update the record if one // already exists. Returns true if a new record was inserted in the database.
[ "Upsert", "insert", "a", "record", "if", "it", "doesn", "t", "exist", "or", "update", "the", "record", "if", "one", "already", "exists", ".", "Returns", "true", "if", "a", "new", "record", "was", "inserted", "in", "the", "database", "." ]
1978bb997cbd2527cc4fa52798b0af6f6d899698
https://github.com/cloudfoundry/bbs/blob/1978bb997cbd2527cc4fa52798b0af6f6d899698/db/sqldb/helpers/upsert.go#L9-L51
127,903
cloudfoundry/bbs
db/sqldb/helpers/transact.go
Transact
func (h *sqlHelper) Transact(logger lager.Logger, db QueryableDB, f func(logger lager.Logger, tx Tx) error) error { var err error for attempts := 0; attempts < 3; attempts++ { err = func() error { tx, err := db.Begin() if err != nil { logger.Error("failed-starting-transaction", err) return err } ...
go
func (h *sqlHelper) Transact(logger lager.Logger, db QueryableDB, f func(logger lager.Logger, tx Tx) error) error { var err error for attempts := 0; attempts < 3; attempts++ { err = func() error { tx, err := db.Begin() if err != nil { logger.Error("failed-starting-transaction", err) return err } ...
[ "func", "(", "h", "*", "sqlHelper", ")", "Transact", "(", "logger", "lager", ".", "Logger", ",", "db", "QueryableDB", ",", "f", "func", "(", "logger", "lager", ".", "Logger", ",", "tx", "Tx", ")", "error", ")", "error", "{", "var", "err", "error", ...
// BEGIN TRANSACTION; f ... ; COMMIT; or // BEGIN TRANSACTION; f ... ; ROLLBACK; if f returns an error.
[ "BEGIN", "TRANSACTION", ";", "f", "...", ";", "COMMIT", ";", "or", "BEGIN", "TRANSACTION", ";", "f", "...", ";", "ROLLBACK", ";", "if", "f", "returns", "an", "error", "." ]
1978bb997cbd2527cc4fa52798b0af6f6d899698
https://github.com/cloudfoundry/bbs/blob/1978bb997cbd2527cc4fa52798b0af6f6d899698/db/sqldb/helpers/transact.go#L14-L53
127,904
cloudfoundry/bbs
models/actual_lrp.go
hasHigherPriority
func hasHigherPriority(lrp1, lrp2 *ActualLRP) bool { if lrp1 == nil { return false } if lrp2 == nil { return true } if lrp1.Presence == ActualLRP_Ordinary { switch lrp1.State { case ActualLRPStateRunning: return true case ActualLRPStateClaimed: return lrp2.State != ActualLRPStateRunning && lrp2.S...
go
func hasHigherPriority(lrp1, lrp2 *ActualLRP) bool { if lrp1 == nil { return false } if lrp2 == nil { return true } if lrp1.Presence == ActualLRP_Ordinary { switch lrp1.State { case ActualLRPStateRunning: return true case ActualLRPStateClaimed: return lrp2.State != ActualLRPStateRunning && lrp2.S...
[ "func", "hasHigherPriority", "(", "lrp1", ",", "lrp2", "*", "ActualLRP", ")", "bool", "{", "if", "lrp1", "==", "nil", "{", "return", "false", "\n", "}", "\n\n", "if", "lrp2", "==", "nil", "{", "return", "true", "\n", "}", "\n\n", "if", "lrp1", ".", ...
// hasHigherPriority returns true if lrp1 takes precendence over lrp2
[ "hasHigherPriority", "returns", "true", "if", "lrp1", "takes", "precendence", "over", "lrp2" ]
1978bb997cbd2527cc4fa52798b0af6f6d899698
https://github.com/cloudfoundry/bbs/blob/1978bb997cbd2527cc4fa52798b0af6f6d899698/models/actual_lrp.go#L409-L436
127,905
cloudfoundry/bbs
models/actual_lrp.go
ResolveActualLRPGroups
func ResolveActualLRPGroups(lrps []*ActualLRP) []*ActualLRPGroup { mapOfGroups := map[ActualLRPKey]*ActualLRPGroup{} result := []*ActualLRPGroup{} for _, actualLRP := range lrps { // Every actual LRP has potentially 2 rows in the database: one for the instance // one for the evacuating. When building the list o...
go
func ResolveActualLRPGroups(lrps []*ActualLRP) []*ActualLRPGroup { mapOfGroups := map[ActualLRPKey]*ActualLRPGroup{} result := []*ActualLRPGroup{} for _, actualLRP := range lrps { // Every actual LRP has potentially 2 rows in the database: one for the instance // one for the evacuating. When building the list o...
[ "func", "ResolveActualLRPGroups", "(", "lrps", "[", "]", "*", "ActualLRP", ")", "[", "]", "*", "ActualLRPGroup", "{", "mapOfGroups", ":=", "map", "[", "ActualLRPKey", "]", "*", "ActualLRPGroup", "{", "}", "\n", "result", ":=", "[", "]", "*", "ActualLRPGrou...
// DEPRECATED // ResolveActualLRPGroups convert the given set of lrp instances into // ActualLRPGroup. This conversion is lossy. A suspect LRP is given // precendence over an Ordinary instance if it is Running. Otherwise, the // Ordinary instance is returned in the Instance field of the ActualLRPGroup.
[ "DEPRECATED", "ResolveActualLRPGroups", "convert", "the", "given", "set", "of", "lrp", "instances", "into", "ActualLRPGroup", ".", "This", "conversion", "is", "lossy", ".", "A", "suspect", "LRP", "is", "given", "precendence", "over", "an", "Ordinary", "instance", ...
1978bb997cbd2527cc4fa52798b0af6f6d899698
https://github.com/cloudfoundry/bbs/blob/1978bb997cbd2527cc4fa52798b0af6f6d899698/models/actual_lrp.go#L443-L463
127,906
cloudfoundry/bbs
models/actual_lrp.go
ResolveActualLRPGroup
func ResolveActualLRPGroup(lrps []*ActualLRP) *ActualLRPGroup { actualLRPGroups := ResolveActualLRPGroups(lrps) switch len(actualLRPGroups) { case 0: return &ActualLRPGroup{} case 1: return actualLRPGroups[0] default: panic("shouldn't get here") } }
go
func ResolveActualLRPGroup(lrps []*ActualLRP) *ActualLRPGroup { actualLRPGroups := ResolveActualLRPGroups(lrps) switch len(actualLRPGroups) { case 0: return &ActualLRPGroup{} case 1: return actualLRPGroups[0] default: panic("shouldn't get here") } }
[ "func", "ResolveActualLRPGroup", "(", "lrps", "[", "]", "*", "ActualLRP", ")", "*", "ActualLRPGroup", "{", "actualLRPGroups", ":=", "ResolveActualLRPGroups", "(", "lrps", ")", "\n", "switch", "len", "(", "actualLRPGroups", ")", "{", "case", "0", ":", "return",...
// DEPRECATED // ResolveToActualLRPGroup calls ResolveActualLRPGroups and return the first // LRP group. It panics if there are more than one group. If there no LRP // groups were returned by ResolveActualLRPGroups, then an empty ActualLRPGroup // is returned.
[ "DEPRECATED", "ResolveToActualLRPGroup", "calls", "ResolveActualLRPGroups", "and", "return", "the", "first", "LRP", "group", ".", "It", "panics", "if", "there", "are", "more", "than", "one", "group", ".", "If", "there", "no", "LRP", "groups", "were", "returned",...
1978bb997cbd2527cc4fa52798b0af6f6d899698
https://github.com/cloudfoundry/bbs/blob/1978bb997cbd2527cc4fa52798b0af6f6d899698/models/actual_lrp.go#L470-L480
127,907
cloudfoundry/bbs
db/sqldb/task_db.go
ResolvingTask
func (db *SQLDB) ResolvingTask(logger lager.Logger, taskGuid string) (*models.Task, *models.Task, error) { logger = logger.Session("resolving-task", lager.Data{"task_guid": taskGuid}) logger.Info("starting") defer logger.Info("complete") var beforeTask models.Task var afterTask *models.Task err := db.transact(l...
go
func (db *SQLDB) ResolvingTask(logger lager.Logger, taskGuid string) (*models.Task, *models.Task, error) { logger = logger.Session("resolving-task", lager.Data{"task_guid": taskGuid}) logger.Info("starting") defer logger.Info("complete") var beforeTask models.Task var afterTask *models.Task err := db.transact(l...
[ "func", "(", "db", "*", "SQLDB", ")", "ResolvingTask", "(", "logger", "lager", ".", "Logger", ",", "taskGuid", "string", ")", "(", "*", "models", ".", "Task", ",", "*", "models", ".", "Task", ",", "error", ")", "{", "logger", "=", "logger", ".", "S...
// The stager calls this when it wants to claim a completed task. This ensures that only one // stager ever attempts to handle a completed task
[ "The", "stager", "calls", "this", "when", "it", "wants", "to", "claim", "a", "completed", "task", ".", "This", "ensures", "that", "only", "one", "stager", "ever", "attempts", "to", "handle", "a", "completed", "task" ]
1978bb997cbd2527cc4fa52798b0af6f6d899698
https://github.com/cloudfoundry/bbs/blob/1978bb997cbd2527cc4fa52798b0af6f6d899698/db/sqldb/task_db.go#L331-L374
127,908
cloudfoundry/bbs
events/calculator/actual_lrp_event_calculator.go
EmitEvents
func (e ActualLRPEventCalculator) EmitEvents(beforeSet, afterSet []*models.ActualLRP) { events := []models.Event{} beforeGroup := models.ResolveActualLRPGroup(beforeSet) afterGroup := models.ResolveActualLRPGroup(removeNilLRPs(afterSet)) for _, ev := range generateLRPGroupEvents(beforeGroup, afterGroup) { e.Act...
go
func (e ActualLRPEventCalculator) EmitEvents(beforeSet, afterSet []*models.ActualLRP) { events := []models.Event{} beforeGroup := models.ResolveActualLRPGroup(beforeSet) afterGroup := models.ResolveActualLRPGroup(removeNilLRPs(afterSet)) for _, ev := range generateLRPGroupEvents(beforeGroup, afterGroup) { e.Act...
[ "func", "(", "e", "ActualLRPEventCalculator", ")", "EmitEvents", "(", "beforeSet", ",", "afterSet", "[", "]", "*", "models", ".", "ActualLRP", ")", "{", "events", ":=", "[", "]", "models", ".", "Event", "{", "}", "\n\n", "beforeGroup", ":=", "models", "....
// EmitEvents emits the events such as when the changes identified in the // events are applied to the beforeSet the resulting state is equal to // afterSet. The beforeSet and afterSet are assumed to have the same process // guid and index.
[ "EmitEvents", "emits", "the", "events", "such", "as", "when", "the", "changes", "identified", "in", "the", "events", "are", "applied", "to", "the", "beforeSet", "the", "resulting", "state", "is", "equal", "to", "afterSet", ".", "The", "beforeSet", "and", "af...
1978bb997cbd2527cc4fa52798b0af6f6d899698
https://github.com/cloudfoundry/bbs/blob/1978bb997cbd2527cc4fa52798b0af6f6d899698/events/calculator/actual_lrp_event_calculator.go#L85-L111
127,909
cloudfoundry/bbs
events/calculator/actual_lrp_event_calculator.go
getEventLRP
func getEventLRP(e models.Event) (*models.ActualLRP, bool) { switch x := e.(type) { case *models.ActualLRPCreatedEvent: lrp, _, _ := x.ActualLrpGroup.Resolve() return lrp, false case *models.ActualLRPChangedEvent: lrp, _, _ := x.After.Resolve() return lrp, false case *models.ActualLRPInstanceCreatedEvent: ...
go
func getEventLRP(e models.Event) (*models.ActualLRP, bool) { switch x := e.(type) { case *models.ActualLRPCreatedEvent: lrp, _, _ := x.ActualLrpGroup.Resolve() return lrp, false case *models.ActualLRPChangedEvent: lrp, _, _ := x.After.Resolve() return lrp, false case *models.ActualLRPInstanceCreatedEvent: ...
[ "func", "getEventLRP", "(", "e", "models", ".", "Event", ")", "(", "*", "models", ".", "ActualLRP", ",", "bool", ")", "{", "switch", "x", ":=", "e", ".", "(", "type", ")", "{", "case", "*", "models", ".", "ActualLRPCreatedEvent", ":", "lrp", ",", "...
// return the resulting lrp of the given event, that is the lrp being created // or the lrp in the new lrp in a ActualLRPChanged event. Returns nil for // crashed and removed events. Returns true iff this is a crashed event.
[ "return", "the", "resulting", "lrp", "of", "the", "given", "event", "that", "is", "the", "lrp", "being", "created", "or", "the", "lrp", "in", "the", "new", "lrp", "in", "a", "ActualLRPChanged", "event", ".", "Returns", "nil", "for", "crashed", "and", "re...
1978bb997cbd2527cc4fa52798b0af6f6d899698
https://github.com/cloudfoundry/bbs/blob/1978bb997cbd2527cc4fa52798b0af6f6d899698/events/calculator/actual_lrp_event_calculator.go#L273-L290
127,910
cloudfoundry/bbs
events/calculator/actual_lrp_event_calculator.go
EventScore
func EventScore(e models.Event) int { lrp, crashed := getEventLRP(e) // sort crashed events first to be backward compatible with the old // event stream which emitted the crashed event before the // remove/changed events. if crashed { return 2 } // this is an event with a running instance, this should be emi...
go
func EventScore(e models.Event) int { lrp, crashed := getEventLRP(e) // sort crashed events first to be backward compatible with the old // event stream which emitted the crashed event before the // remove/changed events. if crashed { return 2 } // this is an event with a running instance, this should be emi...
[ "func", "EventScore", "(", "e", "models", ".", "Event", ")", "int", "{", "lrp", ",", "crashed", ":=", "getEventLRP", "(", "e", ")", "\n\n", "// sort crashed events first to be backward compatible with the old", "// event stream which emitted the crashed event before the", "...
// Determine the score of an event. An event with higher score should be // emitted before lower ones. The score based ordering ensures continuous // routability, so events with running instances should be emitted first // followed by remove events.
[ "Determine", "the", "score", "of", "an", "event", ".", "An", "event", "with", "higher", "score", "should", "be", "emitted", "before", "lower", "ones", ".", "The", "score", "based", "ordering", "ensures", "continuous", "routability", "so", "events", "with", "...
1978bb997cbd2527cc4fa52798b0af6f6d899698
https://github.com/cloudfoundry/bbs/blob/1978bb997cbd2527cc4fa52798b0af6f6d899698/events/calculator/actual_lrp_event_calculator.go#L296-L316
127,911
cloudfoundry/bbs
events/calculator/actual_lrp_event_calculator.go
removeNilLRPs
func removeNilLRPs(lrps []*models.ActualLRP) []*models.ActualLRP { newLRPs := []*models.ActualLRP{} for _, l := range lrps { if l == nil { continue } newLRPs = append(newLRPs, l) } return newLRPs }
go
func removeNilLRPs(lrps []*models.ActualLRP) []*models.ActualLRP { newLRPs := []*models.ActualLRP{} for _, l := range lrps { if l == nil { continue } newLRPs = append(newLRPs, l) } return newLRPs }
[ "func", "removeNilLRPs", "(", "lrps", "[", "]", "*", "models", ".", "ActualLRP", ")", "[", "]", "*", "models", ".", "ActualLRP", "{", "newLRPs", ":=", "[", "]", "*", "models", ".", "ActualLRP", "{", "}", "\n", "for", "_", ",", "l", ":=", "range", ...
// A Helper function to remove null lrps that could be added to the set if an // LRP is removed.
[ "A", "Helper", "function", "to", "remove", "null", "lrps", "that", "could", "be", "added", "to", "the", "set", "if", "an", "LRP", "is", "removed", "." ]
1978bb997cbd2527cc4fa52798b0af6f6d899698
https://github.com/cloudfoundry/bbs/blob/1978bb997cbd2527cc4fa52798b0af6f6d899698/events/calculator/actual_lrp_event_calculator.go#L331-L340
127,912
cloudfoundry/bbs
models/volume_mount.go
Validate
func (v *VolumeMount) Validate() error { var ve ValidationError if v.Driver == "" { ve = ve.Append(errors.New("invalid volume_mount driver")) } if !(v.Mode == "r" || v.Mode == "rw") { ve = ve.Append(errors.New("invalid volume_mount mode")) } if v.Shared != nil && v.Shared.VolumeId == "" { ve = ve.Append(err...
go
func (v *VolumeMount) Validate() error { var ve ValidationError if v.Driver == "" { ve = ve.Append(errors.New("invalid volume_mount driver")) } if !(v.Mode == "r" || v.Mode == "rw") { ve = ve.Append(errors.New("invalid volume_mount mode")) } if v.Shared != nil && v.Shared.VolumeId == "" { ve = ve.Append(err...
[ "func", "(", "v", "*", "VolumeMount", ")", "Validate", "(", ")", "error", "{", "var", "ve", "ValidationError", "\n", "if", "v", ".", "Driver", "==", "\"", "\"", "{", "ve", "=", "ve", ".", "Append", "(", "errors", ".", "New", "(", "\"", "\"", ")",...
// while volume mounts are experimental, we should never persist a "old" volume // mount to the db layer, so the handler must convert old data models to the new ones // when volume mounts are no longer experimental, this validation strategy must be reconsidered
[ "while", "volume", "mounts", "are", "experimental", "we", "should", "never", "persist", "a", "old", "volume", "mount", "to", "the", "db", "layer", "so", "the", "handler", "must", "convert", "old", "data", "models", "to", "the", "new", "ones", "when", "volu...
1978bb997cbd2527cc4fa52798b0af6f6d899698
https://github.com/cloudfoundry/bbs/blob/1978bb997cbd2527cc4fa52798b0af6f6d899698/models/volume_mount.go#L20-L37
127,913
cloudfoundry/bbs
db/sqldb/desired_lrp_db.go
fetchDesiredLRPSchedulingInfoAndMore
func (db *SQLDB) fetchDesiredLRPSchedulingInfoAndMore(logger lager.Logger, scanner helpers.RowScanner, dest ...interface{}) (*models.DesiredLRPSchedulingInfo, error) { schedulingInfo := &models.DesiredLRPSchedulingInfo{} var routeData, volumePlacementData, placementTagData []byte values := []interface{}{ &scheduli...
go
func (db *SQLDB) fetchDesiredLRPSchedulingInfoAndMore(logger lager.Logger, scanner helpers.RowScanner, dest ...interface{}) (*models.DesiredLRPSchedulingInfo, error) { schedulingInfo := &models.DesiredLRPSchedulingInfo{} var routeData, volumePlacementData, placementTagData []byte values := []interface{}{ &scheduli...
[ "func", "(", "db", "*", "SQLDB", ")", "fetchDesiredLRPSchedulingInfoAndMore", "(", "logger", "lager", ".", "Logger", ",", "scanner", "helpers", ".", "RowScanner", ",", "dest", "...", "interface", "{", "}", ")", "(", "*", "models", ".", "DesiredLRPSchedulingInf...
// "rows" needs to have the columns defined in the schedulingInfoColumns constant
[ "rows", "needs", "to", "have", "the", "columns", "defined", "in", "the", "schedulingInfoColumns", "constant" ]
1978bb997cbd2527cc4fa52798b0af6f6d899698
https://github.com/cloudfoundry/bbs/blob/1978bb997cbd2527cc4fa52798b0af6f6d899698/db/sqldb/desired_lrp_db.go#L293-L353
127,914
cloudfoundry/bbs
db/sqldb/lrp_convergence.go
staleUnclaimedActualLRPs
func (c *convergence) staleUnclaimedActualLRPs(logger lager.Logger, now time.Time) { logger = logger.Session("stale-unclaimed-actual-lrps") rows, err := c.selectStaleUnclaimedLRPs(logger, c.db, now) if err != nil { logger.Error("failed-query", err) return } for rows.Next() { var index int schedulingInfo,...
go
func (c *convergence) staleUnclaimedActualLRPs(logger lager.Logger, now time.Time) { logger = logger.Session("stale-unclaimed-actual-lrps") rows, err := c.selectStaleUnclaimedLRPs(logger, c.db, now) if err != nil { logger.Error("failed-query", err) return } for rows.Next() { var index int schedulingInfo,...
[ "func", "(", "c", "*", "convergence", ")", "staleUnclaimedActualLRPs", "(", "logger", "lager", ".", "Logger", ",", "now", "time", ".", "Time", ")", "{", "logger", "=", "logger", ".", "Session", "(", "\"", "\"", ")", "\n\n", "rows", ",", "err", ":=", ...
// Adds stale UNCLAIMED Actual LRPs to the list of start requests.
[ "Adds", "stale", "UNCLAIMED", "Actual", "LRPs", "to", "the", "list", "of", "start", "requests", "." ]
1978bb997cbd2527cc4fa52798b0af6f6d899698
https://github.com/cloudfoundry/bbs/blob/1978bb997cbd2527cc4fa52798b0af6f6d899698/db/sqldb/lrp_convergence.go#L81-L110
127,915
cloudfoundry/bbs
db/sqldb/lrp_convergence.go
crashedActualLRPs
func (c *convergence) crashedActualLRPs(logger lager.Logger, now time.Time) { logger = logger.Session("crashed-actual-lrps") restartCalculator := models.NewDefaultRestartCalculator() rows, err := c.selectCrashedLRPs(logger, c.db) if err != nil { logger.Error("failed-query", err) return } for rows.Next() { ...
go
func (c *convergence) crashedActualLRPs(logger lager.Logger, now time.Time) { logger = logger.Session("crashed-actual-lrps") restartCalculator := models.NewDefaultRestartCalculator() rows, err := c.selectCrashedLRPs(logger, c.db) if err != nil { logger.Error("failed-query", err) return } for rows.Next() { ...
[ "func", "(", "c", "*", "convergence", ")", "crashedActualLRPs", "(", "logger", "lager", ".", "Logger", ",", "now", "time", ".", "Time", ")", "{", "logger", "=", "logger", ".", "Session", "(", "\"", "\"", ")", "\n", "restartCalculator", ":=", "models", ...
// Adds CRASHED Actual LRPs that can be restarted to the list of start requests // and transitions them to UNCLAIMED.
[ "Adds", "CRASHED", "Actual", "LRPs", "that", "can", "be", "restarted", "to", "the", "list", "of", "start", "requests", "and", "transitions", "them", "to", "UNCLAIMED", "." ]
1978bb997cbd2527cc4fa52798b0af6f6d899698
https://github.com/cloudfoundry/bbs/blob/1978bb997cbd2527cc4fa52798b0af6f6d899698/db/sqldb/lrp_convergence.go#L114-L151
127,916
cloudfoundry/bbs
db/sqldb/lrp_convergence.go
lrpInstanceCounts
func (c *convergence) lrpInstanceCounts(logger lager.Logger, domainSet map[string]struct{}) { logger = logger.Session("lrp-instance-counts") rows, err := c.selectLRPInstanceCounts(logger, c.db) if err != nil { logger.Error("failed-query", err) return } for rows.Next() { var existingIndicesStr sql.NullStrin...
go
func (c *convergence) lrpInstanceCounts(logger lager.Logger, domainSet map[string]struct{}) { logger = logger.Session("lrp-instance-counts") rows, err := c.selectLRPInstanceCounts(logger, c.db) if err != nil { logger.Error("failed-query", err) return } for rows.Next() { var existingIndicesStr sql.NullStrin...
[ "func", "(", "c", "*", "convergence", ")", "lrpInstanceCounts", "(", "logger", "lager", ".", "Logger", ",", "domainSet", "map", "[", "string", "]", "struct", "{", "}", ")", "{", "logger", "=", "logger", ".", "Session", "(", "\"", "\"", ")", "\n\n", "...
// Creates and adds missing Actual LRPs to the list of start requests. // Adds extra Actual LRPs to the list of keys to retire.
[ "Creates", "and", "adds", "missing", "Actual", "LRPs", "to", "the", "list", "of", "start", "requests", ".", "Adds", "extra", "Actual", "LRPs", "to", "the", "list", "of", "keys", "to", "retire", "." ]
1978bb997cbd2527cc4fa52798b0af6f6d899698
https://github.com/cloudfoundry/bbs/blob/1978bb997cbd2527cc4fa52798b0af6f6d899698/db/sqldb/lrp_convergence.go#L241-L314
127,917
cloudfoundry/buildpackapplifecycle
buildpackrunner/runner.go
runSupplyBuildpacks
func (runner *Runner) runSupplyBuildpacks() (string, string, error) { if err := runner.validateSupplyBuildpacks(); err != nil { return "", "", err } for i, buildpack := range runner.config.SupplyBuildpacks() { buildpackPath, err := runner.buildpackPath(buildpack) if err != nil { printError(err.Error()) r...
go
func (runner *Runner) runSupplyBuildpacks() (string, string, error) { if err := runner.validateSupplyBuildpacks(); err != nil { return "", "", err } for i, buildpack := range runner.config.SupplyBuildpacks() { buildpackPath, err := runner.buildpackPath(buildpack) if err != nil { printError(err.Error()) r...
[ "func", "(", "runner", "*", "Runner", ")", "runSupplyBuildpacks", "(", ")", "(", "string", ",", "string", ",", "error", ")", "{", "if", "err", ":=", "runner", ".", "validateSupplyBuildpacks", "(", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\""...
// returns buildpack path, ok
[ "returns", "buildpack", "path", "ok" ]
5a0eeb8db891a528b4e44a7cd1fd47123a874ad1
https://github.com/cloudfoundry/buildpackapplifecycle/blob/5a0eeb8db891a528b4e44a7cd1fd47123a874ad1/buildpackrunner/runner.go#L337-L361
127,918
cloudfoundry/buildpackapplifecycle
buildpackrunner/runner.go
detect
func (runner *Runner) detect() (string, string, string, bool) { for _, buildpack := range runner.config.BuildpackOrder() { buildpackPath, err := runner.buildpackPath(buildpack) if err != nil { printError(err.Error()) continue } if runner.config.SkipDetect() { return buildpack, buildpackPath, "", tru...
go
func (runner *Runner) detect() (string, string, string, bool) { for _, buildpack := range runner.config.BuildpackOrder() { buildpackPath, err := runner.buildpackPath(buildpack) if err != nil { printError(err.Error()) continue } if runner.config.SkipDetect() { return buildpack, buildpackPath, "", tru...
[ "func", "(", "runner", "*", "Runner", ")", "detect", "(", ")", "(", "string", ",", "string", ",", "string", ",", "bool", ")", "{", "for", "_", ",", "buildpack", ":=", "range", "runner", ".", "config", ".", "BuildpackOrder", "(", ")", "{", "buildpackP...
// returns buildpack name, buildpack path, buildpack detect output, ok
[ "returns", "buildpack", "name", "buildpack", "path", "buildpack", "detect", "output", "ok" ]
5a0eeb8db891a528b4e44a7cd1fd47123a874ad1
https://github.com/cloudfoundry/buildpackapplifecycle/blob/5a0eeb8db891a528b4e44a7cd1fd47123a874ad1/buildpackrunner/runner.go#L423-L450
127,919
yhat/scrape
scrape.go
FindAll
func FindAll(node *html.Node, matcher Matcher) []*html.Node { return findAllInternal(node, matcher, false) }
go
func FindAll(node *html.Node, matcher Matcher) []*html.Node { return findAllInternal(node, matcher, false) }
[ "func", "FindAll", "(", "node", "*", "html", ".", "Node", ",", "matcher", "Matcher", ")", "[", "]", "*", "html", ".", "Node", "{", "return", "findAllInternal", "(", "node", ",", "matcher", ",", "false", ")", "\n", "}" ]
// FindAll returns all nodes which match the provided Matcher. After discovering a matching // node, it will _not_ discover matching subnodes of that node.
[ "FindAll", "returns", "all", "nodes", "which", "match", "the", "provided", "Matcher", ".", "After", "discovering", "a", "matching", "node", "it", "will", "_not_", "discover", "matching", "subnodes", "of", "that", "node", "." ]
24b7890b0945459dbf91743e4d2ac5d75a51fee2
https://github.com/yhat/scrape/blob/24b7890b0945459dbf91743e4d2ac5d75a51fee2/scrape.go#L16-L18
127,920
yhat/scrape
scrape.go
FindAllNested
func FindAllNested(node *html.Node, matcher Matcher) []*html.Node { return findAllInternal(node, matcher, true) }
go
func FindAllNested(node *html.Node, matcher Matcher) []*html.Node { return findAllInternal(node, matcher, true) }
[ "func", "FindAllNested", "(", "node", "*", "html", ".", "Node", ",", "matcher", "Matcher", ")", "[", "]", "*", "html", ".", "Node", "{", "return", "findAllInternal", "(", "node", ",", "matcher", ",", "true", ")", "\n", "}" ]
// FindAllNested returns all nodes which match the provided Matcher and _will_ discover // matching subnodes of matching nodes.
[ "FindAllNested", "returns", "all", "nodes", "which", "match", "the", "provided", "Matcher", "and", "_will_", "discover", "matching", "subnodes", "of", "matching", "nodes", "." ]
24b7890b0945459dbf91743e4d2ac5d75a51fee2
https://github.com/yhat/scrape/blob/24b7890b0945459dbf91743e4d2ac5d75a51fee2/scrape.go#L22-L24
127,921
yhat/scrape
scrape.go
FindParent
func FindParent(node *html.Node, matcher Matcher) (n *html.Node, ok bool) { for p := node.Parent; p != nil; p = p.Parent { if matcher(p) { return p, true } } return nil, false }
go
func FindParent(node *html.Node, matcher Matcher) (n *html.Node, ok bool) { for p := node.Parent; p != nil; p = p.Parent { if matcher(p) { return p, true } } return nil, false }
[ "func", "FindParent", "(", "node", "*", "html", ".", "Node", ",", "matcher", "Matcher", ")", "(", "n", "*", "html", ".", "Node", ",", "ok", "bool", ")", "{", "for", "p", ":=", "node", ".", "Parent", ";", "p", "!=", "nil", ";", "p", "=", "p", ...
// FindParent searches up HTML tree from the current node until either a // match is found or the top is hit.
[ "FindParent", "searches", "up", "HTML", "tree", "from", "the", "current", "node", "until", "either", "a", "match", "is", "found", "or", "the", "top", "is", "hit", "." ]
24b7890b0945459dbf91743e4d2ac5d75a51fee2
https://github.com/yhat/scrape/blob/24b7890b0945459dbf91743e4d2ac5d75a51fee2/scrape.go#L53-L60
127,922
yhat/scrape
scrape.go
Text
func Text(node *html.Node) string { joiner := func(s []string) string { n := 0 for i := range s { trimmed := strings.TrimSpace(s[i]) if trimmed != "" { s[n] = trimmed n++ } } return strings.Join(s[:n], " ") } return TextJoin(node, joiner) }
go
func Text(node *html.Node) string { joiner := func(s []string) string { n := 0 for i := range s { trimmed := strings.TrimSpace(s[i]) if trimmed != "" { s[n] = trimmed n++ } } return strings.Join(s[:n], " ") } return TextJoin(node, joiner) }
[ "func", "Text", "(", "node", "*", "html", ".", "Node", ")", "string", "{", "joiner", ":=", "func", "(", "s", "[", "]", "string", ")", "string", "{", "n", ":=", "0", "\n", "for", "i", ":=", "range", "s", "{", "trimmed", ":=", "strings", ".", "Tr...
// Text returns text from all descendant text nodes joined. // For control over the join function, see TextJoin.
[ "Text", "returns", "text", "from", "all", "descendant", "text", "nodes", "joined", ".", "For", "control", "over", "the", "join", "function", "see", "TextJoin", "." ]
24b7890b0945459dbf91743e4d2ac5d75a51fee2
https://github.com/yhat/scrape/blob/24b7890b0945459dbf91743e4d2ac5d75a51fee2/scrape.go#L64-L77
127,923
yhat/scrape
scrape.go
TextJoin
func TextJoin(node *html.Node, join func([]string) string) string { nodes := FindAll(node, func(n *html.Node) bool { return n.Type == html.TextNode }) parts := make([]string, len(nodes)) for i, n := range nodes { parts[i] = n.Data } return join(parts) }
go
func TextJoin(node *html.Node, join func([]string) string) string { nodes := FindAll(node, func(n *html.Node) bool { return n.Type == html.TextNode }) parts := make([]string, len(nodes)) for i, n := range nodes { parts[i] = n.Data } return join(parts) }
[ "func", "TextJoin", "(", "node", "*", "html", ".", "Node", ",", "join", "func", "(", "[", "]", "string", ")", "string", ")", "string", "{", "nodes", ":=", "FindAll", "(", "node", ",", "func", "(", "n", "*", "html", ".", "Node", ")", "bool", "{", ...
// TextJoin returns a string from all descendant text nodes joined by a // caller provided join function.
[ "TextJoin", "returns", "a", "string", "from", "all", "descendant", "text", "nodes", "joined", "by", "a", "caller", "provided", "join", "function", "." ]
24b7890b0945459dbf91743e4d2ac5d75a51fee2
https://github.com/yhat/scrape/blob/24b7890b0945459dbf91743e4d2ac5d75a51fee2/scrape.go#L81-L88
127,924
yhat/scrape
scrape.go
Attr
func Attr(node *html.Node, key string) string { for _, a := range node.Attr { if a.Key == key { return a.Val } } return "" }
go
func Attr(node *html.Node, key string) string { for _, a := range node.Attr { if a.Key == key { return a.Val } } return "" }
[ "func", "Attr", "(", "node", "*", "html", ".", "Node", ",", "key", "string", ")", "string", "{", "for", "_", ",", "a", ":=", "range", "node", ".", "Attr", "{", "if", "a", ".", "Key", "==", "key", "{", "return", "a", ".", "Val", "\n", "}", "\n...
// Attr returns the value of an HTML attribute.
[ "Attr", "returns", "the", "value", "of", "an", "HTML", "attribute", "." ]
24b7890b0945459dbf91743e4d2ac5d75a51fee2
https://github.com/yhat/scrape/blob/24b7890b0945459dbf91743e4d2ac5d75a51fee2/scrape.go#L91-L98
127,925
yhat/scrape
scrape.go
ById
func ById(id string) Matcher { return func(node *html.Node) bool { return Attr(node, "id") == id } }
go
func ById(id string) Matcher { return func(node *html.Node) bool { return Attr(node, "id") == id } }
[ "func", "ById", "(", "id", "string", ")", "Matcher", "{", "return", "func", "(", "node", "*", "html", ".", "Node", ")", "bool", "{", "return", "Attr", "(", "node", ",", "\"", "\"", ")", "==", "id", "}", "\n", "}" ]
// ById returns a Matcher which matches all nodes with the provided id.
[ "ById", "returns", "a", "Matcher", "which", "matches", "all", "nodes", "with", "the", "provided", "id", "." ]
24b7890b0945459dbf91743e4d2ac5d75a51fee2
https://github.com/yhat/scrape/blob/24b7890b0945459dbf91743e4d2ac5d75a51fee2/scrape.go#L112-L114
127,926
yhat/scrape
scrape.go
ByClass
func ByClass(class string) Matcher { return func(node *html.Node) bool { classes := strings.Fields(Attr(node, "class")) for _, c := range classes { if c == class { return true } } return false } }
go
func ByClass(class string) Matcher { return func(node *html.Node) bool { classes := strings.Fields(Attr(node, "class")) for _, c := range classes { if c == class { return true } } return false } }
[ "func", "ByClass", "(", "class", "string", ")", "Matcher", "{", "return", "func", "(", "node", "*", "html", ".", "Node", ")", "bool", "{", "classes", ":=", "strings", ".", "Fields", "(", "Attr", "(", "node", ",", "\"", "\"", ")", ")", "\n", "for", ...
// ByClass returns a Matcher which matches all nodes with the provided class.
[ "ByClass", "returns", "a", "Matcher", "which", "matches", "all", "nodes", "with", "the", "provided", "class", "." ]
24b7890b0945459dbf91743e4d2ac5d75a51fee2
https://github.com/yhat/scrape/blob/24b7890b0945459dbf91743e4d2ac5d75a51fee2/scrape.go#L117-L127
127,927
yhat/scrape
scrape.go
findAllInternal
func findAllInternal(node *html.Node, matcher Matcher, searchNested bool) []*html.Node { matched := []*html.Node{} if matcher(node) { matched = append(matched, node) if !searchNested { return matched } } for c := node.FirstChild; c != nil; c = c.NextSibling { found := findAllInternal(c, matcher, searc...
go
func findAllInternal(node *html.Node, matcher Matcher, searchNested bool) []*html.Node { matched := []*html.Node{} if matcher(node) { matched = append(matched, node) if !searchNested { return matched } } for c := node.FirstChild; c != nil; c = c.NextSibling { found := findAllInternal(c, matcher, searc...
[ "func", "findAllInternal", "(", "node", "*", "html", ".", "Node", ",", "matcher", "Matcher", ",", "searchNested", "bool", ")", "[", "]", "*", "html", ".", "Node", "{", "matched", ":=", "[", "]", "*", "html", ".", "Node", "{", "}", "\n\n", "if", "ma...
// findAllInternal encapsulates the node tree traversal
[ "findAllInternal", "encapsulates", "the", "node", "tree", "traversal" ]
24b7890b0945459dbf91743e4d2ac5d75a51fee2
https://github.com/yhat/scrape/blob/24b7890b0945459dbf91743e4d2ac5d75a51fee2/scrape.go#L130-L148
127,928
docker/go-units
size.go
CustomSize
func CustomSize(format string, size float64, base float64, _map []string) string { size, unit := getSizeAndUnit(size, base, _map) return fmt.Sprintf(format, size, unit) }
go
func CustomSize(format string, size float64, base float64, _map []string) string { size, unit := getSizeAndUnit(size, base, _map) return fmt.Sprintf(format, size, unit) }
[ "func", "CustomSize", "(", "format", "string", ",", "size", "float64", ",", "base", "float64", ",", "_map", "[", "]", "string", ")", "string", "{", "size", ",", "unit", ":=", "getSizeAndUnit", "(", "size", ",", "base", ",", "_map", ")", "\n", "return",...
// CustomSize returns a human-readable approximation of a size // using custom format.
[ "CustomSize", "returns", "a", "human", "-", "readable", "approximation", "of", "a", "size", "using", "custom", "format", "." ]
519db1ee28dcc9fd2474ae59fca29a810482bfb1
https://github.com/docker/go-units/blob/519db1ee28dcc9fd2474ae59fca29a810482bfb1/size.go#L52-L55
127,929
docker/go-units
size.go
HumanSizeWithPrecision
func HumanSizeWithPrecision(size float64, precision int) string { size, unit := getSizeAndUnit(size, 1000.0, decimapAbbrs) return fmt.Sprintf("%.*g%s", precision, size, unit) }
go
func HumanSizeWithPrecision(size float64, precision int) string { size, unit := getSizeAndUnit(size, 1000.0, decimapAbbrs) return fmt.Sprintf("%.*g%s", precision, size, unit) }
[ "func", "HumanSizeWithPrecision", "(", "size", "float64", ",", "precision", "int", ")", "string", "{", "size", ",", "unit", ":=", "getSizeAndUnit", "(", "size", ",", "1000.0", ",", "decimapAbbrs", ")", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\""...
// HumanSizeWithPrecision allows the size to be in any precision, // instead of 4 digit precision used in units.HumanSize.
[ "HumanSizeWithPrecision", "allows", "the", "size", "to", "be", "in", "any", "precision", "instead", "of", "4", "digit", "precision", "used", "in", "units", ".", "HumanSize", "." ]
519db1ee28dcc9fd2474ae59fca29a810482bfb1
https://github.com/docker/go-units/blob/519db1ee28dcc9fd2474ae59fca29a810482bfb1/size.go#L59-L62
127,930
STNS/STNS
model/backend_toml_file.go
tomlHighLowID
func tomlHighLowID(highorlow int, list map[string]UserGroup) int { current := 0 if list != nil { for _, v := range list { if current == 0 || (highorlow == 0 && current < v.GetID()) || (highorlow == 1 && current > v.GetID()) { current = v.GetID() } } } return current }
go
func tomlHighLowID(highorlow int, list map[string]UserGroup) int { current := 0 if list != nil { for _, v := range list { if current == 0 || (highorlow == 0 && current < v.GetID()) || (highorlow == 1 && current > v.GetID()) { current = v.GetID() } } } return current }
[ "func", "tomlHighLowID", "(", "highorlow", "int", ",", "list", "map", "[", "string", "]", "UserGroup", ")", "int", "{", "current", ":=", "0", "\n", "if", "list", "!=", "nil", "{", "for", "_", ",", "v", ":=", "range", "list", "{", "if", "current", "...
// highest=0 lowest= 1
[ "highest", "=", "0", "lowest", "=", "1" ]
189a00a7b4e36662d238e7a389464622c9561735
https://github.com/STNS/STNS/blob/189a00a7b4e36662d238e7a389464622c9561735/model/backend_toml_file.go#L213-L223
127,931
cpuguy83/go-md2man
md2man/roff.go
NewRoffRenderer
func NewRoffRenderer() *roffRenderer { // nolint: golint var extensions blackfriday.Extensions extensions |= blackfriday.NoIntraEmphasis extensions |= blackfriday.Tables extensions |= blackfriday.FencedCode extensions |= blackfriday.SpaceHeadings extensions |= blackfriday.Footnotes extensions |= blackfriday.Tit...
go
func NewRoffRenderer() *roffRenderer { // nolint: golint var extensions blackfriday.Extensions extensions |= blackfriday.NoIntraEmphasis extensions |= blackfriday.Tables extensions |= blackfriday.FencedCode extensions |= blackfriday.SpaceHeadings extensions |= blackfriday.Footnotes extensions |= blackfriday.Tit...
[ "func", "NewRoffRenderer", "(", ")", "*", "roffRenderer", "{", "// nolint: golint", "var", "extensions", "blackfriday", ".", "Extensions", "\n\n", "extensions", "|=", "blackfriday", ".", "NoIntraEmphasis", "\n", "extensions", "|=", "blackfriday", ".", "Tables", "\n"...
// NewRoffRenderer creates a new blackfriday Renderer for generating roff documents // from markdown
[ "NewRoffRenderer", "creates", "a", "new", "blackfriday", "Renderer", "for", "generating", "roff", "documents", "from", "markdown" ]
f79a8a8ca69da163eee19ab442bedad7a35bba5a
https://github.com/cpuguy83/go-md2man/blob/f79a8a8ca69da163eee19ab442bedad7a35bba5a/md2man/roff.go#L54-L67
127,932
cpuguy83/go-md2man
md2man/roff.go
RenderHeader
func (r *roffRenderer) RenderHeader(w io.Writer, ast *blackfriday.Node) { // disable hyphenation out(w, ".nh\n") }
go
func (r *roffRenderer) RenderHeader(w io.Writer, ast *blackfriday.Node) { // disable hyphenation out(w, ".nh\n") }
[ "func", "(", "r", "*", "roffRenderer", ")", "RenderHeader", "(", "w", "io", ".", "Writer", ",", "ast", "*", "blackfriday", ".", "Node", ")", "{", "// disable hyphenation", "out", "(", "w", ",", "\"", "\\n", "\"", ")", "\n", "}" ]
// RenderHeader handles outputting the header at document start
[ "RenderHeader", "handles", "outputting", "the", "header", "at", "document", "start" ]
f79a8a8ca69da163eee19ab442bedad7a35bba5a
https://github.com/cpuguy83/go-md2man/blob/f79a8a8ca69da163eee19ab442bedad7a35bba5a/md2man/roff.go#L75-L78
127,933
cpuguy83/go-md2man
md2man/roff.go
RenderNode
func (r *roffRenderer) RenderNode(w io.Writer, node *blackfriday.Node, entering bool) blackfriday.WalkStatus { var walkAction = blackfriday.GoToNext switch node.Type { case blackfriday.Text: r.handleText(w, node, entering) case blackfriday.Softbreak: out(w, crTag) case blackfriday.Hardbreak: out(w, breakTa...
go
func (r *roffRenderer) RenderNode(w io.Writer, node *blackfriday.Node, entering bool) blackfriday.WalkStatus { var walkAction = blackfriday.GoToNext switch node.Type { case blackfriday.Text: r.handleText(w, node, entering) case blackfriday.Softbreak: out(w, crTag) case blackfriday.Hardbreak: out(w, breakTa...
[ "func", "(", "r", "*", "roffRenderer", ")", "RenderNode", "(", "w", "io", ".", "Writer", ",", "node", "*", "blackfriday", ".", "Node", ",", "entering", "bool", ")", "blackfriday", ".", "WalkStatus", "{", "var", "walkAction", "=", "blackfriday", ".", "GoT...
// RenderNode is called for each node in a markdown document; based on the node // type the equivalent roff output is sent to the writer
[ "RenderNode", "is", "called", "for", "each", "node", "in", "a", "markdown", "document", ";", "based", "on", "the", "node", "type", "the", "equivalent", "roff", "output", "is", "sent", "to", "the", "writer" ]
f79a8a8ca69da163eee19ab442bedad7a35bba5a
https://github.com/cpuguy83/go-md2man/blob/f79a8a8ca69da163eee19ab442bedad7a35bba5a/md2man/roff.go#L87-L164
127,934
cpuguy83/go-md2man
md2man/roff.go
countColumns
func countColumns(node *blackfriday.Node) int { var columns int node.Walk(func(node *blackfriday.Node, entering bool) blackfriday.WalkStatus { switch node.Type { case blackfriday.TableRow: if !entering { return blackfriday.Terminate } case blackfriday.TableCell: if entering { columns++ } ...
go
func countColumns(node *blackfriday.Node) int { var columns int node.Walk(func(node *blackfriday.Node, entering bool) blackfriday.WalkStatus { switch node.Type { case blackfriday.TableRow: if !entering { return blackfriday.Terminate } case blackfriday.TableCell: if entering { columns++ } ...
[ "func", "countColumns", "(", "node", "*", "blackfriday", ".", "Node", ")", "int", "{", "var", "columns", "int", "\n\n", "node", ".", "Walk", "(", "func", "(", "node", "*", "blackfriday", ".", "Node", ",", "entering", "bool", ")", "blackfriday", ".", "W...
// because roff format requires knowing the column count before outputting any table // data we need to walk a table tree and count the columns
[ "because", "roff", "format", "requires", "knowing", "the", "column", "count", "before", "outputting", "any", "table", "data", "we", "need", "to", "walk", "a", "table", "tree", "and", "count", "the", "columns" ]
f79a8a8ca69da163eee19ab442bedad7a35bba5a
https://github.com/cpuguy83/go-md2man/blob/f79a8a8ca69da163eee19ab442bedad7a35bba5a/md2man/roff.go#L288-L306
127,935
cpuguy83/go-md2man
md2man/md2man.go
Render
func Render(doc []byte) []byte { renderer := NewRoffRenderer() return blackfriday.Run(doc, []blackfriday.Option{blackfriday.WithRenderer(renderer), blackfriday.WithExtensions(renderer.GetExtensions())}...) }
go
func Render(doc []byte) []byte { renderer := NewRoffRenderer() return blackfriday.Run(doc, []blackfriday.Option{blackfriday.WithRenderer(renderer), blackfriday.WithExtensions(renderer.GetExtensions())}...) }
[ "func", "Render", "(", "doc", "[", "]", "byte", ")", "[", "]", "byte", "{", "renderer", ":=", "NewRoffRenderer", "(", ")", "\n\n", "return", "blackfriday", ".", "Run", "(", "doc", ",", "[", "]", "blackfriday", ".", "Option", "{", "blackfriday", ".", ...
// Render converts a markdown document into a roff formatted document.
[ "Render", "converts", "a", "markdown", "document", "into", "a", "roff", "formatted", "document", "." ]
f79a8a8ca69da163eee19ab442bedad7a35bba5a
https://github.com/cpuguy83/go-md2man/blob/f79a8a8ca69da163eee19ab442bedad7a35bba5a/md2man/md2man.go#L8-L14
127,936
RobotsAndPencils/buford
payload/badge/badge.go
String
func (b Badge) String() string { if b.isSet { return fmt.Sprintf("set %d", b.number) } return "preserve" }
go
func (b Badge) String() string { if b.isSet { return fmt.Sprintf("set %d", b.number) } return "preserve" }
[ "func", "(", "b", "Badge", ")", "String", "(", ")", "string", "{", "if", "b", ".", "isSet", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "b", ".", "number", ")", "\n", "}", "\n", "return", "\"", "\"", "\n", "}" ]
// String prints out a badge
[ "String", "prints", "out", "a", "badge" ]
75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31
https://github.com/RobotsAndPencils/buford/blob/75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31/payload/badge/badge.go#L32-L37
127,937
RobotsAndPencils/buford
push/service.go
NewService
func NewService(client *http.Client, host string) *Service { return &Service{ Client: client, Host: host, } }
go
func NewService(client *http.Client, host string) *Service { return &Service{ Client: client, Host: host, } }
[ "func", "NewService", "(", "client", "*", "http", ".", "Client", ",", "host", "string", ")", "*", "Service", "{", "return", "&", "Service", "{", "Client", ":", "client", ",", "Host", ":", "host", ",", "}", "\n", "}" ]
// NewService creates a new service to connect to APN.
[ "NewService", "creates", "a", "new", "service", "to", "connect", "to", "APN", "." ]
75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31
https://github.com/RobotsAndPencils/buford/blob/75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31/push/service.go#L36-L41
127,938
RobotsAndPencils/buford
push/service.go
Push
func (s *Service) Push(deviceToken string, headers *Headers, payload []byte) (string, error) { // check payload length before even hitting Apple. if len(payload) > maxPayload { return "", &Error{ Reason: ErrPayloadTooLarge, Status: http.StatusRequestEntityTooLarge, } } urlStr := fmt.Sprintf("%v/3/device/...
go
func (s *Service) Push(deviceToken string, headers *Headers, payload []byte) (string, error) { // check payload length before even hitting Apple. if len(payload) > maxPayload { return "", &Error{ Reason: ErrPayloadTooLarge, Status: http.StatusRequestEntityTooLarge, } } urlStr := fmt.Sprintf("%v/3/device/...
[ "func", "(", "s", "*", "Service", ")", "Push", "(", "deviceToken", "string", ",", "headers", "*", "Headers", ",", "payload", "[", "]", "byte", ")", "(", "string", ",", "error", ")", "{", "// check payload length before even hitting Apple.", "if", "len", "(",...
// Push sends a notification and waits for a response.
[ "Push", "sends", "a", "notification", "and", "waits", "for", "a", "response", "." ]
75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31
https://github.com/RobotsAndPencils/buford/blob/75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31/push/service.go#L59-L95
127,939
RobotsAndPencils/buford
pushpackage/pushpackage.go
New
func New(w io.Writer) Package { return Package{ z: zip.NewWriter(w), manifest: make(map[string]string), } }
go
func New(w io.Writer) Package { return Package{ z: zip.NewWriter(w), manifest: make(map[string]string), } }
[ "func", "New", "(", "w", "io", ".", "Writer", ")", "Package", "{", "return", "Package", "{", "z", ":", "zip", ".", "NewWriter", "(", "w", ")", ",", "manifest", ":", "make", "(", "map", "[", "string", "]", "string", ")", ",", "}", "\n", "}" ]
// New push package will be written to w.
[ "New", "push", "package", "will", "be", "written", "to", "w", "." ]
75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31
https://github.com/RobotsAndPencils/buford/blob/75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31/pushpackage/pushpackage.go#L29-L34
127,940
RobotsAndPencils/buford
pushpackage/pushpackage.go
EncodeJSON
func (p *Package) EncodeJSON(name string, e interface{}) { if p.err != nil { return } b, err := json.Marshal(e) if err != nil { p.err = err return } r := bytes.NewReader(b) p.Copy(name, r) }
go
func (p *Package) EncodeJSON(name string, e interface{}) { if p.err != nil { return } b, err := json.Marshal(e) if err != nil { p.err = err return } r := bytes.NewReader(b) p.Copy(name, r) }
[ "func", "(", "p", "*", "Package", ")", "EncodeJSON", "(", "name", "string", ",", "e", "interface", "{", "}", ")", "{", "if", "p", ".", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "b", ",", "err", ":=", "json", ".", "Marshal", "(", "e"...
// EncodeJSON to the push package.
[ "EncodeJSON", "to", "the", "push", "package", "." ]
75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31
https://github.com/RobotsAndPencils/buford/blob/75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31/pushpackage/pushpackage.go#L37-L50
127,941
RobotsAndPencils/buford
pushpackage/pushpackage.go
Copy
func (p *Package) Copy(name string, r io.Reader) { if p.err != nil { return } zf, err := p.z.Create(name) if err != nil { p.err = err return } checksum, err := copyAndChecksum(zf, r) if err != nil { p.err = err return } p.manifest[name] = checksum }
go
func (p *Package) Copy(name string, r io.Reader) { if p.err != nil { return } zf, err := p.z.Create(name) if err != nil { p.err = err return } checksum, err := copyAndChecksum(zf, r) if err != nil { p.err = err return } p.manifest[name] = checksum }
[ "func", "(", "p", "*", "Package", ")", "Copy", "(", "name", "string", ",", "r", "io", ".", "Reader", ")", "{", "if", "p", ".", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "zf", ",", "err", ":=", "p", ".", "z", ".", "Create", "(", ...
// Copy reader to the push package.
[ "Copy", "reader", "to", "the", "push", "package", "." ]
75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31
https://github.com/RobotsAndPencils/buford/blob/75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31/pushpackage/pushpackage.go#L53-L71
127,942
RobotsAndPencils/buford
pushpackage/pushpackage.go
Sign
func (p *Package) Sign(cert tls.Certificate, wwdr *x509.Certificate) error { if p.err != nil { return p.err } // assert that private key is RSA key, ok := cert.PrivateKey.(*rsa.PrivateKey) if !ok { return errors.New("expected RSA private key type") } manifestBytes, err := json.Marshal(p.manifest) if err !...
go
func (p *Package) Sign(cert tls.Certificate, wwdr *x509.Certificate) error { if p.err != nil { return p.err } // assert that private key is RSA key, ok := cert.PrivateKey.(*rsa.PrivateKey) if !ok { return errors.New("expected RSA private key type") } manifestBytes, err := json.Marshal(p.manifest) if err !...
[ "func", "(", "p", "*", "Package", ")", "Sign", "(", "cert", "tls", ".", "Certificate", ",", "wwdr", "*", "x509", ".", "Certificate", ")", "error", "{", "if", "p", ".", "err", "!=", "nil", "{", "return", "p", ".", "err", "\n", "}", "\n\n", "// ass...
// Sign the package and close. // Passbook needs Apple's intermediate WWDR certificate.
[ "Sign", "the", "package", "and", "close", ".", "Passbook", "needs", "Apple", "s", "intermediate", "WWDR", "certificate", "." ]
75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31
https://github.com/RobotsAndPencils/buford/blob/75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31/pushpackage/pushpackage.go#L92-L127
127,943
RobotsAndPencils/buford
push/queue.go
NewQueue
func NewQueue(service *Service, workers uint) *Queue { // unbuffered channels q := &Queue{ service: service, notifications: make(chan notification), Responses: make(chan Response), } // startup workers to send notifications for i := uint(0); i < workers; i++ { go worker(q) } return q }
go
func NewQueue(service *Service, workers uint) *Queue { // unbuffered channels q := &Queue{ service: service, notifications: make(chan notification), Responses: make(chan Response), } // startup workers to send notifications for i := uint(0); i < workers; i++ { go worker(q) } return q }
[ "func", "NewQueue", "(", "service", "*", "Service", ",", "workers", "uint", ")", "*", "Queue", "{", "// unbuffered channels", "q", ":=", "&", "Queue", "{", "service", ":", "service", ",", "notifications", ":", "make", "(", "chan", "notification", ")", ",",...
// NewQueue wraps a service with a queue for sending notifications asynchronously.
[ "NewQueue", "wraps", "a", "service", "with", "a", "queue", "for", "sending", "notifications", "asynchronously", "." ]
75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31
https://github.com/RobotsAndPencils/buford/blob/75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31/push/queue.go#L25-L37
127,944
RobotsAndPencils/buford
push/queue.go
Push
func (q *Queue) Push(deviceToken string, headers *Headers, payload []byte) { n := notification{ DeviceToken: deviceToken, Headers: headers, Payload: payload, } q.notifications <- n }
go
func (q *Queue) Push(deviceToken string, headers *Headers, payload []byte) { n := notification{ DeviceToken: deviceToken, Headers: headers, Payload: payload, } q.notifications <- n }
[ "func", "(", "q", "*", "Queue", ")", "Push", "(", "deviceToken", "string", ",", "headers", "*", "Headers", ",", "payload", "[", "]", "byte", ")", "{", "n", ":=", "notification", "{", "DeviceToken", ":", "deviceToken", ",", "Headers", ":", "headers", ",...
// Push queues a notification to the APN service.
[ "Push", "queues", "a", "notification", "to", "the", "APN", "service", "." ]
75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31
https://github.com/RobotsAndPencils/buford/blob/75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31/push/queue.go#L40-L47
127,945
RobotsAndPencils/buford
payload/aps.go
isSimple
func (a *Alert) isSimple() bool { return len(a.Title) == 0 && len(a.Subtitle) == 0 && len(a.LaunchImage) == 0 && len(a.TitleLocKey) == 0 && len(a.TitleLocArgs) == 0 && len(a.LocKey) == 0 && len(a.LocArgs) == 0 && len(a.ActionLocKey) == 0 }
go
func (a *Alert) isSimple() bool { return len(a.Title) == 0 && len(a.Subtitle) == 0 && len(a.LaunchImage) == 0 && len(a.TitleLocKey) == 0 && len(a.TitleLocArgs) == 0 && len(a.LocKey) == 0 && len(a.LocArgs) == 0 && len(a.ActionLocKey) == 0 }
[ "func", "(", "a", "*", "Alert", ")", "isSimple", "(", ")", "bool", "{", "return", "len", "(", "a", ".", "Title", ")", "==", "0", "&&", "len", "(", "a", ".", "Subtitle", ")", "==", "0", "&&", "len", "(", "a", ".", "LaunchImage", ")", "==", "0"...
// isSimple alert with only Body set.
[ "isSimple", "alert", "with", "only", "Body", "set", "." ]
75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31
https://github.com/RobotsAndPencils/buford/blob/75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31/payload/aps.go#L60-L65
127,946
RobotsAndPencils/buford
payload/aps.go
Map
func (a *APS) Map() map[string]interface{} { aps := make(map[string]interface{}, 5) if !a.Alert.isZero() { if a.Alert.isSimple() { aps["alert"] = a.Alert.Body } else { aps["alert"] = a.Alert } } if n, ok := a.Badge.Number(); ok { aps["badge"] = n } if a.Sound != "" { aps["sound"] = a.Sound } if...
go
func (a *APS) Map() map[string]interface{} { aps := make(map[string]interface{}, 5) if !a.Alert.isZero() { if a.Alert.isSimple() { aps["alert"] = a.Alert.Body } else { aps["alert"] = a.Alert } } if n, ok := a.Badge.Number(); ok { aps["badge"] = n } if a.Sound != "" { aps["sound"] = a.Sound } if...
[ "func", "(", "a", "*", "APS", ")", "Map", "(", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "aps", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ",", "5", ")", "\n\n", "if", "!", "a", ".", "Alert", ".", ...
// Map returns the payload as a map that you can customize // before serializing it to JSON.
[ "Map", "returns", "the", "payload", "as", "a", "map", "that", "you", "can", "customize", "before", "serializing", "it", "to", "JSON", "." ]
75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31
https://github.com/RobotsAndPencils/buford/blob/75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31/payload/aps.go#L74-L105
127,947
RobotsAndPencils/buford
payload/aps.go
Validate
func (a *APS) Validate() error { if a == nil { return ErrIncomplete } // must have a body or a badge (or custom data) if len(a.Alert.Body) == 0 && a.Badge == badge.Preserve { return ErrIncomplete } return nil }
go
func (a *APS) Validate() error { if a == nil { return ErrIncomplete } // must have a body or a badge (or custom data) if len(a.Alert.Body) == 0 && a.Badge == badge.Preserve { return ErrIncomplete } return nil }
[ "func", "(", "a", "*", "APS", ")", "Validate", "(", ")", "error", "{", "if", "a", "==", "nil", "{", "return", "ErrIncomplete", "\n", "}", "\n\n", "// must have a body or a badge (or custom data)", "if", "len", "(", "a", ".", "Alert", ".", "Body", ")", "=...
// Validate that a payload has the correct fields.
[ "Validate", "that", "a", "payload", "has", "the", "correct", "fields", "." ]
75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31
https://github.com/RobotsAndPencils/buford/blob/75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31/payload/aps.go#L113-L123
127,948
RobotsAndPencils/buford
payload/browser.go
Validate
func (p *Browser) Validate() error { if p == nil { return ErrIncomplete } // must have both a title and body. action and url-args are optional. if len(p.Alert.Title) == 0 || len(p.Alert.Body) == 0 { return ErrIncomplete } return nil }
go
func (p *Browser) Validate() error { if p == nil { return ErrIncomplete } // must have both a title and body. action and url-args are optional. if len(p.Alert.Title) == 0 || len(p.Alert.Body) == 0 { return ErrIncomplete } return nil }
[ "func", "(", "p", "*", "Browser", ")", "Validate", "(", ")", "error", "{", "if", "p", "==", "nil", "{", "return", "ErrIncomplete", "\n", "}", "\n\n", "// must have both a title and body. action and url-args are optional.", "if", "len", "(", "p", ".", "Alert", ...
// Validate browser payload.
[ "Validate", "browser", "payload", "." ]
75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31
https://github.com/RobotsAndPencils/buford/blob/75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31/payload/browser.go#L27-L37
127,949
RobotsAndPencils/buford
push/header.go
set
func (h *Headers) set(reqHeader http.Header) { // headers are optional if h == nil { return } if h.ID != "" { reqHeader.Set("apns-id", h.ID) } // when omitted, Apple will generate a UUID for you if h.CollapseID != "" { reqHeader.Set("apns-collapse-id", h.CollapseID) } if !h.Expiration.IsZero() { reqH...
go
func (h *Headers) set(reqHeader http.Header) { // headers are optional if h == nil { return } if h.ID != "" { reqHeader.Set("apns-id", h.ID) } // when omitted, Apple will generate a UUID for you if h.CollapseID != "" { reqHeader.Set("apns-collapse-id", h.CollapseID) } if !h.Expiration.IsZero() { reqH...
[ "func", "(", "h", "*", "Headers", ")", "set", "(", "reqHeader", "http", ".", "Header", ")", "{", "// headers are optional", "if", "h", "==", "nil", "{", "return", "\n", "}", "\n\n", "if", "h", ".", "ID", "!=", "\"", "\"", "{", "reqHeader", ".", "Se...
// set headers for an HTTP request
[ "set", "headers", "for", "an", "HTTP", "request" ]
75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31
https://github.com/RobotsAndPencils/buford/blob/75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31/push/header.go#L31-L57
127,950
RobotsAndPencils/buford
payload/mdm.go
Validate
func (p *MDM) Validate() error { if p == nil { return ErrIncomplete } // must have a token. if len(p.Token) == 0 { return ErrIncomplete } return nil }
go
func (p *MDM) Validate() error { if p == nil { return ErrIncomplete } // must have a token. if len(p.Token) == 0 { return ErrIncomplete } return nil }
[ "func", "(", "p", "*", "MDM", ")", "Validate", "(", ")", "error", "{", "if", "p", "==", "nil", "{", "return", "ErrIncomplete", "\n", "}", "\n\n", "// must have a token.", "if", "len", "(", "p", ".", "Token", ")", "==", "0", "{", "return", "ErrIncompl...
// Validate MDM payload.
[ "Validate", "MDM", "payload", "." ]
75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31
https://github.com/RobotsAndPencils/buford/blob/75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31/payload/mdm.go#L9-L19
127,951
RobotsAndPencils/buford
certificate/cert.go
Load
func Load(filename, password string) (tls.Certificate, error) { p12, err := ioutil.ReadFile(filename) if err != nil { return tls.Certificate{}, fmt.Errorf("Unable to load %s: %v", filename, err) } return Decode(p12, password) }
go
func Load(filename, password string) (tls.Certificate, error) { p12, err := ioutil.ReadFile(filename) if err != nil { return tls.Certificate{}, fmt.Errorf("Unable to load %s: %v", filename, err) } return Decode(p12, password) }
[ "func", "Load", "(", "filename", ",", "password", "string", ")", "(", "tls", ".", "Certificate", ",", "error", ")", "{", "p12", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "return", "tls", ...
// Load a .p12 certificate from disk.
[ "Load", "a", ".", "p12", "certificate", "from", "disk", "." ]
75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31
https://github.com/RobotsAndPencils/buford/blob/75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31/certificate/cert.go#L25-L31
127,952
RobotsAndPencils/buford
certificate/cert.go
TopicFromCert
func TopicFromCert(cert tls.Certificate) string { commonName := cert.Leaf.Subject.CommonName var topic string // Apple Push Services: {bundle} // Apple Development IOS Push Services: {bundle} n := strings.Index(commonName, ":") if n != -1 { topic = strings.TrimSpace(commonName[n+1:]) } return topic }
go
func TopicFromCert(cert tls.Certificate) string { commonName := cert.Leaf.Subject.CommonName var topic string // Apple Push Services: {bundle} // Apple Development IOS Push Services: {bundle} n := strings.Index(commonName, ":") if n != -1 { topic = strings.TrimSpace(commonName[n+1:]) } return topic }
[ "func", "TopicFromCert", "(", "cert", "tls", ".", "Certificate", ")", "string", "{", "commonName", ":=", "cert", ".", "Leaf", ".", "Subject", ".", "CommonName", "\n\n", "var", "topic", "string", "\n", "// Apple Push Services: {bundle}", "// Apple Development IOS Pus...
// TopicFromCert extracts topic from a certificate's common name.
[ "TopicFromCert", "extracts", "topic", "from", "a", "certificate", "s", "common", "name", "." ]
75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31
https://github.com/RobotsAndPencils/buford/blob/75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31/certificate/cert.go#L53-L64
127,953
RobotsAndPencils/buford
certificate/cert.go
verify
func verify(cert *x509.Certificate) error { _, err := cert.Verify(x509.VerifyOptions{}) if err == nil { return nil } switch e := err.(type) { case x509.CertificateInvalidError: switch e.Reason { case x509.Expired: return ErrExpired case x509.IncompatibleUsage: // Apple cert fail on go 1.10 return...
go
func verify(cert *x509.Certificate) error { _, err := cert.Verify(x509.VerifyOptions{}) if err == nil { return nil } switch e := err.(type) { case x509.CertificateInvalidError: switch e.Reason { case x509.Expired: return ErrExpired case x509.IncompatibleUsage: // Apple cert fail on go 1.10 return...
[ "func", "verify", "(", "cert", "*", "x509", ".", "Certificate", ")", "error", "{", "_", ",", "err", ":=", "cert", ".", "Verify", "(", "x509", ".", "VerifyOptions", "{", "}", ")", "\n", "if", "err", "==", "nil", "{", "return", "nil", "\n", "}", "\...
// verify checks if a certificate has expired
[ "verify", "checks", "if", "a", "certificate", "has", "expired" ]
75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31
https://github.com/RobotsAndPencils/buford/blob/75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31/certificate/cert.go#L67-L91
127,954
RobotsAndPencils/buford
pushpackage/checksum.go
copyAndChecksum
func copyAndChecksum(w io.Writer, r io.Reader) (string, error) { h := sha1.New() mw := io.MultiWriter(w, h) if _, err := io.Copy(mw, r); err != nil { return "", err } return hex.EncodeToString(h.Sum(nil)), nil }
go
func copyAndChecksum(w io.Writer, r io.Reader) (string, error) { h := sha1.New() mw := io.MultiWriter(w, h) if _, err := io.Copy(mw, r); err != nil { return "", err } return hex.EncodeToString(h.Sum(nil)), nil }
[ "func", "copyAndChecksum", "(", "w", "io", ".", "Writer", ",", "r", "io", ".", "Reader", ")", "(", "string", ",", "error", ")", "{", "h", ":=", "sha1", ".", "New", "(", ")", "\n", "mw", ":=", "io", ".", "MultiWriter", "(", "w", ",", "h", ")", ...
// copyAndChecksum calculates a checksum while writing to another output
[ "copyAndChecksum", "calculates", "a", "checksum", "while", "writing", "to", "another", "output" ]
75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31
https://github.com/RobotsAndPencils/buford/blob/75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31/pushpackage/checksum.go#L10-L17
127,955
RobotsAndPencils/buford
push/errors.go
mapErrorReason
func mapErrorReason(reason string) error { var e error switch reason { case "PayloadEmpty": e = ErrPayloadEmpty case "PayloadTooLarge": e = ErrPayloadTooLarge case "BadTopic": e = ErrBadTopic case "TopicDisallowed": e = ErrTopicDisallowed case "BadMessageId": e = ErrBadMessageID case "BadExpirationDat...
go
func mapErrorReason(reason string) error { var e error switch reason { case "PayloadEmpty": e = ErrPayloadEmpty case "PayloadTooLarge": e = ErrPayloadTooLarge case "BadTopic": e = ErrBadTopic case "TopicDisallowed": e = ErrTopicDisallowed case "BadMessageId": e = ErrBadMessageID case "BadExpirationDat...
[ "func", "mapErrorReason", "(", "reason", "string", ")", "error", "{", "var", "e", "error", "\n", "switch", "reason", "{", "case", "\"", "\"", ":", "e", "=", "ErrPayloadEmpty", "\n", "case", "\"", "\"", ":", "e", "=", "ErrPayloadTooLarge", "\n", "case", ...
// mapErrorReason converts Apple error responses into exported Err variables // for comparisons.
[ "mapErrorReason", "converts", "Apple", "error", "responses", "into", "exported", "Err", "variables", "for", "comparisons", "." ]
75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31
https://github.com/RobotsAndPencils/buford/blob/75d85f30d5ffbe02a1fa39cb15c7a526ee70ab31/push/errors.go#L56-L109
127,956
tsuru/docker-cluster
cluster/container.go
CreateContainer
func (c *Cluster) CreateContainer(opts docker.CreateContainerOptions, inactivityTimeout time.Duration, nodes ...string) (string, *docker.Container, error) { return c.CreateContainerSchedulerOpts(opts, nil, inactivityTimeout, nodes...) }
go
func (c *Cluster) CreateContainer(opts docker.CreateContainerOptions, inactivityTimeout time.Duration, nodes ...string) (string, *docker.Container, error) { return c.CreateContainerSchedulerOpts(opts, nil, inactivityTimeout, nodes...) }
[ "func", "(", "c", "*", "Cluster", ")", "CreateContainer", "(", "opts", "docker", ".", "CreateContainerOptions", ",", "inactivityTimeout", "time", ".", "Duration", ",", "nodes", "...", "string", ")", "(", "string", ",", "*", "docker", ".", "Container", ",", ...
// CreateContainer creates a container in the specified node. If no node is // specified, it will create the container in a node selected by the scheduler. // // It returns the container, or an error, in case of failures.
[ "CreateContainer", "creates", "a", "container", "in", "the", "specified", "node", ".", "If", "no", "node", "is", "specified", "it", "will", "create", "the", "container", "in", "a", "node", "selected", "by", "the", "scheduler", ".", "It", "returns", "the", ...
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/container.go#L29-L31
127,957
tsuru/docker-cluster
cluster/container.go
CreateContainerSchedulerOpts
func (c *Cluster) CreateContainerSchedulerOpts(opts docker.CreateContainerOptions, schedulerOpts SchedulerOptions, inactivityTimeout time.Duration, nodes ...string) (string, *docker.Container, error) { return c.CreateContainerPullOptsSchedulerOpts(opts, docker.PullImageOptions{ Repository: opts.Config.Image, ...
go
func (c *Cluster) CreateContainerSchedulerOpts(opts docker.CreateContainerOptions, schedulerOpts SchedulerOptions, inactivityTimeout time.Duration, nodes ...string) (string, *docker.Container, error) { return c.CreateContainerPullOptsSchedulerOpts(opts, docker.PullImageOptions{ Repository: opts.Config.Image, ...
[ "func", "(", "c", "*", "Cluster", ")", "CreateContainerSchedulerOpts", "(", "opts", "docker", ".", "CreateContainerOptions", ",", "schedulerOpts", "SchedulerOptions", ",", "inactivityTimeout", "time", ".", "Duration", ",", "nodes", "...", "string", ")", "(", "stri...
// Similar to CreateContainer but allows arbritary options to be passed to // the scheduler.
[ "Similar", "to", "CreateContainer", "but", "allows", "arbritary", "options", "to", "be", "passed", "to", "the", "scheduler", "." ]
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/container.go#L35-L41
127,958
tsuru/docker-cluster
cluster/container.go
CreateContainerPullOptsSchedulerOpts
func (c *Cluster) CreateContainerPullOptsSchedulerOpts(opts docker.CreateContainerOptions, pullOpts docker.PullImageOptions, pullAuth docker.AuthConfiguration, schedulerOpts SchedulerOptions, nodes ...string) (string, *docker.Container, error) { var ( addr string container *docker.Container err error ...
go
func (c *Cluster) CreateContainerPullOptsSchedulerOpts(opts docker.CreateContainerOptions, pullOpts docker.PullImageOptions, pullAuth docker.AuthConfiguration, schedulerOpts SchedulerOptions, nodes ...string) (string, *docker.Container, error) { var ( addr string container *docker.Container err error ...
[ "func", "(", "c", "*", "Cluster", ")", "CreateContainerPullOptsSchedulerOpts", "(", "opts", "docker", ".", "CreateContainerOptions", ",", "pullOpts", "docker", ".", "PullImageOptions", ",", "pullAuth", "docker", ".", "AuthConfiguration", ",", "schedulerOpts", "Schedul...
// Similar to CreateContainer but allows arbritary options to be passed to // the scheduler and to the pull image call.
[ "Similar", "to", "CreateContainer", "but", "allows", "arbritary", "options", "to", "be", "passed", "to", "the", "scheduler", "and", "to", "the", "pull", "image", "call", "." ]
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/container.go#L45-L112
127,959
tsuru/docker-cluster
cluster/container.go
InspectContainer
func (c *Cluster) InspectContainer(id string) (*docker.Container, error) { node, err := c.getNodeForContainer(id) if err != nil { return nil, err } cont, err := node.InspectContainer(id) return cont, wrapError(node, err) }
go
func (c *Cluster) InspectContainer(id string) (*docker.Container, error) { node, err := c.getNodeForContainer(id) if err != nil { return nil, err } cont, err := node.InspectContainer(id) return cont, wrapError(node, err) }
[ "func", "(", "c", "*", "Cluster", ")", "InspectContainer", "(", "id", "string", ")", "(", "*", "docker", ".", "Container", ",", "error", ")", "{", "node", ",", "err", ":=", "c", ".", "getNodeForContainer", "(", "id", ")", "\n", "if", "err", "!=", "...
// InspectContainer returns information about a container by its ID, getting // the information from the right node.
[ "InspectContainer", "returns", "information", "about", "a", "container", "by", "its", "ID", "getting", "the", "information", "from", "the", "right", "node", "." ]
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/container.go#L132-L139
127,960
tsuru/docker-cluster
cluster/container.go
KillContainer
func (c *Cluster) KillContainer(opts docker.KillContainerOptions) error { node, err := c.getNodeForContainer(opts.ID) if err != nil { return err } return wrapError(node, node.KillContainer(opts)) }
go
func (c *Cluster) KillContainer(opts docker.KillContainerOptions) error { node, err := c.getNodeForContainer(opts.ID) if err != nil { return err } return wrapError(node, node.KillContainer(opts)) }
[ "func", "(", "c", "*", "Cluster", ")", "KillContainer", "(", "opts", "docker", ".", "KillContainerOptions", ")", "error", "{", "node", ",", "err", ":=", "c", ".", "getNodeForContainer", "(", "opts", ".", "ID", ")", "\n", "if", "err", "!=", "nil", "{", ...
// KillContainer kills a container, returning an error in case of failure.
[ "KillContainer", "kills", "a", "container", "returning", "an", "error", "in", "case", "of", "failure", "." ]
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/container.go#L142-L148
127,961
tsuru/docker-cluster
cluster/container.go
ListContainers
func (c *Cluster) ListContainers(opts docker.ListContainersOptions) ([]docker.APIContainers, error) { nodes, err := c.Nodes() if err != nil { return nil, err } var wg sync.WaitGroup result := make(chan []docker.APIContainers, len(nodes)) errs := make(chan error, len(nodes)) for _, n := range nodes { wg.Add(1...
go
func (c *Cluster) ListContainers(opts docker.ListContainersOptions) ([]docker.APIContainers, error) { nodes, err := c.Nodes() if err != nil { return nil, err } var wg sync.WaitGroup result := make(chan []docker.APIContainers, len(nodes)) errs := make(chan error, len(nodes)) for _, n := range nodes { wg.Add(1...
[ "func", "(", "c", "*", "Cluster", ")", "ListContainers", "(", "opts", "docker", ".", "ListContainersOptions", ")", "(", "[", "]", "docker", ".", "APIContainers", ",", "error", ")", "{", "nodes", ",", "err", ":=", "c", ".", "Nodes", "(", ")", "\n", "i...
// ListContainers returns a slice of all containers in the cluster matching the // given criteria.
[ "ListContainers", "returns", "a", "slice", "of", "all", "containers", "in", "the", "cluster", "matching", "the", "given", "criteria", "." ]
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/container.go#L152-L183
127,962
tsuru/docker-cluster
cluster/container.go
RemoveContainer
func (c *Cluster) RemoveContainer(opts docker.RemoveContainerOptions) error { return c.removeFromStorage(opts) }
go
func (c *Cluster) RemoveContainer(opts docker.RemoveContainerOptions) error { return c.removeFromStorage(opts) }
[ "func", "(", "c", "*", "Cluster", ")", "RemoveContainer", "(", "opts", "docker", ".", "RemoveContainerOptions", ")", "error", "{", "return", "c", ".", "removeFromStorage", "(", "opts", ")", "\n", "}" ]
// RemoveContainer removes a container from the cluster.
[ "RemoveContainer", "removes", "a", "container", "from", "the", "cluster", "." ]
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/container.go#L186-L188
127,963
tsuru/docker-cluster
cluster/container.go
StopContainer
func (c *Cluster) StopContainer(id string, timeout uint) error { node, err := c.getNodeForContainer(id) if err != nil { return err } return wrapError(node, node.StopContainer(id, timeout)) }
go
func (c *Cluster) StopContainer(id string, timeout uint) error { node, err := c.getNodeForContainer(id) if err != nil { return err } return wrapError(node, node.StopContainer(id, timeout)) }
[ "func", "(", "c", "*", "Cluster", ")", "StopContainer", "(", "id", "string", ",", "timeout", "uint", ")", "error", "{", "node", ",", "err", ":=", "c", ".", "getNodeForContainer", "(", "id", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", ...
// StopContainer stops a container, killing it after the given timeout, if it // fails to stop nicely.
[ "StopContainer", "stops", "a", "container", "killing", "it", "after", "the", "given", "timeout", "if", "it", "fails", "to", "stop", "nicely", "." ]
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/container.go#L224-L230
127,964
tsuru/docker-cluster
cluster/container.go
PauseContainer
func (c *Cluster) PauseContainer(id string) error { node, err := c.getNodeForContainer(id) if err != nil { return err } return wrapError(node, node.PauseContainer(id)) }
go
func (c *Cluster) PauseContainer(id string) error { node, err := c.getNodeForContainer(id) if err != nil { return err } return wrapError(node, node.PauseContainer(id)) }
[ "func", "(", "c", "*", "Cluster", ")", "PauseContainer", "(", "id", "string", ")", "error", "{", "node", ",", "err", ":=", "c", ".", "getNodeForContainer", "(", "id", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "retu...
// PauseContainer changes the container to the paused state.
[ "PauseContainer", "changes", "the", "container", "to", "the", "paused", "state", "." ]
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/container.go#L243-L249
127,965
tsuru/docker-cluster
cluster/container.go
WaitContainer
func (c *Cluster) WaitContainer(id string) (int, error) { node, err := c.getNodeForContainer(id) if err != nil { return -1, err } node.setPersistentClient() code, err := node.WaitContainer(id) return code, wrapError(node, err) }
go
func (c *Cluster) WaitContainer(id string) (int, error) { node, err := c.getNodeForContainer(id) if err != nil { return -1, err } node.setPersistentClient() code, err := node.WaitContainer(id) return code, wrapError(node, err) }
[ "func", "(", "c", "*", "Cluster", ")", "WaitContainer", "(", "id", "string", ")", "(", "int", ",", "error", ")", "{", "node", ",", "err", ":=", "c", ".", "getNodeForContainer", "(", "id", ")", "\n", "if", "err", "!=", "nil", "{", "return", "-", "...
// WaitContainer blocks until the given container stops, returning the exit // code of the container command.
[ "WaitContainer", "blocks", "until", "the", "given", "container", "stops", "returning", "the", "exit", "code", "of", "the", "container", "command", "." ]
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/container.go#L262-L270
127,966
tsuru/docker-cluster
cluster/container.go
AttachToContainer
func (c *Cluster) AttachToContainer(opts docker.AttachToContainerOptions) error { node, err := c.getNodeForContainer(opts.Container) if err != nil { return err } node.setPersistentClient() return wrapError(node, node.AttachToContainer(opts)) }
go
func (c *Cluster) AttachToContainer(opts docker.AttachToContainerOptions) error { node, err := c.getNodeForContainer(opts.Container) if err != nil { return err } node.setPersistentClient() return wrapError(node, node.AttachToContainer(opts)) }
[ "func", "(", "c", "*", "Cluster", ")", "AttachToContainer", "(", "opts", "docker", ".", "AttachToContainerOptions", ")", "error", "{", "node", ",", "err", ":=", "c", ".", "getNodeForContainer", "(", "opts", ".", "Container", ")", "\n", "if", "err", "!=", ...
// AttachToContainer attaches to a container, using the given options.
[ "AttachToContainer", "attaches", "to", "a", "container", "using", "the", "given", "options", "." ]
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/container.go#L273-L280
127,967
tsuru/docker-cluster
cluster/container.go
AttachToContainerNonBlocking
func (c *Cluster) AttachToContainerNonBlocking(opts docker.AttachToContainerOptions) (docker.CloseWaiter, error) { node, err := c.getNodeForContainer(opts.Container) if err != nil { return nil, err } node.setPersistentClient() return node.AttachToContainerNonBlocking(opts) }
go
func (c *Cluster) AttachToContainerNonBlocking(opts docker.AttachToContainerOptions) (docker.CloseWaiter, error) { node, err := c.getNodeForContainer(opts.Container) if err != nil { return nil, err } node.setPersistentClient() return node.AttachToContainerNonBlocking(opts) }
[ "func", "(", "c", "*", "Cluster", ")", "AttachToContainerNonBlocking", "(", "opts", "docker", ".", "AttachToContainerOptions", ")", "(", "docker", ".", "CloseWaiter", ",", "error", ")", "{", "node", ",", "err", ":=", "c", ".", "getNodeForContainer", "(", "op...
// AttachToContainerNonBlocking attaches to a container and returns a docker.CloseWaiter, using given options.
[ "AttachToContainerNonBlocking", "attaches", "to", "a", "container", "and", "returns", "a", "docker", ".", "CloseWaiter", "using", "given", "options", "." ]
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/container.go#L283-L290
127,968
tsuru/docker-cluster
cluster/container.go
Logs
func (c *Cluster) Logs(opts docker.LogsOptions) error { node, err := c.getNodeForContainer(opts.Container) if err != nil { return err } return wrapError(node, node.Logs(opts)) }
go
func (c *Cluster) Logs(opts docker.LogsOptions) error { node, err := c.getNodeForContainer(opts.Container) if err != nil { return err } return wrapError(node, node.Logs(opts)) }
[ "func", "(", "c", "*", "Cluster", ")", "Logs", "(", "opts", "docker", ".", "LogsOptions", ")", "error", "{", "node", ",", "err", ":=", "c", ".", "getNodeForContainer", "(", "opts", ".", "Container", ")", "\n", "if", "err", "!=", "nil", "{", "return",...
// Logs retrieves the logs of the specified container.
[ "Logs", "retrieves", "the", "logs", "of", "the", "specified", "container", "." ]
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/container.go#L293-L299
127,969
tsuru/docker-cluster
cluster/container.go
CommitContainer
func (c *Cluster) CommitContainer(opts docker.CommitContainerOptions) (*docker.Image, error) { node, err := c.getNodeForContainer(opts.Container) if err != nil { return nil, err } node.setPersistentClient() image, err := node.CommitContainer(opts) if err != nil { return nil, wrapError(node, err) } key := im...
go
func (c *Cluster) CommitContainer(opts docker.CommitContainerOptions) (*docker.Image, error) { node, err := c.getNodeForContainer(opts.Container) if err != nil { return nil, err } node.setPersistentClient() image, err := node.CommitContainer(opts) if err != nil { return nil, wrapError(node, err) } key := im...
[ "func", "(", "c", "*", "Cluster", ")", "CommitContainer", "(", "opts", "docker", ".", "CommitContainerOptions", ")", "(", "*", "docker", ".", "Image", ",", "error", ")", "{", "node", ",", "err", ":=", "c", ".", "getNodeForContainer", "(", "opts", ".", ...
// CommitContainer commits a container and returns the image id.
[ "CommitContainer", "commits", "a", "container", "and", "returns", "the", "image", "id", "." ]
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/container.go#L302-L320
127,970
tsuru/docker-cluster
cluster/container.go
ExportContainer
func (c *Cluster) ExportContainer(opts docker.ExportContainerOptions) error { node, err := c.getNodeForContainer(opts.ID) if err != nil { return err } return wrapError(node, node.ExportContainer(opts)) }
go
func (c *Cluster) ExportContainer(opts docker.ExportContainerOptions) error { node, err := c.getNodeForContainer(opts.ID) if err != nil { return err } return wrapError(node, node.ExportContainer(opts)) }
[ "func", "(", "c", "*", "Cluster", ")", "ExportContainer", "(", "opts", "docker", ".", "ExportContainerOptions", ")", "error", "{", "node", ",", "err", ":=", "c", ".", "getNodeForContainer", "(", "opts", ".", "ID", ")", "\n", "if", "err", "!=", "nil", "...
// ExportContainer exports a container as a tar and writes // the result in out.
[ "ExportContainer", "exports", "a", "container", "as", "a", "tar", "and", "writes", "the", "result", "in", "out", "." ]
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/container.go#L324-L330
127,971
tsuru/docker-cluster
cluster/container.go
TopContainer
func (c *Cluster) TopContainer(id string, psArgs string) (docker.TopResult, error) { node, err := c.getNodeForContainer(id) if err != nil { return docker.TopResult{}, err } result, err := node.TopContainer(id, psArgs) return result, wrapError(node, err) }
go
func (c *Cluster) TopContainer(id string, psArgs string) (docker.TopResult, error) { node, err := c.getNodeForContainer(id) if err != nil { return docker.TopResult{}, err } result, err := node.TopContainer(id, psArgs) return result, wrapError(node, err) }
[ "func", "(", "c", "*", "Cluster", ")", "TopContainer", "(", "id", "string", ",", "psArgs", "string", ")", "(", "docker", ".", "TopResult", ",", "error", ")", "{", "node", ",", "err", ":=", "c", ".", "getNodeForContainer", "(", "id", ")", "\n", "if", ...
// TopContainer returns information about running processes inside a container // by its ID, getting the information from the right node.
[ "TopContainer", "returns", "information", "about", "running", "processes", "inside", "a", "container", "by", "its", "ID", "getting", "the", "information", "from", "the", "right", "node", "." ]
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/container.go#L334-L341
127,972
tsuru/docker-cluster
cluster/cluster.go
New
func New(scheduler Scheduler, storage Storage, caPath string, nodes ...Node) (*Cluster, error) { var ( c Cluster err error ) if storage == nil { return nil, errStorageMandatory } c.stor = storage c.scheduler = scheduler if caPath != "" { tlsConfig, errTLS := readTLSConfig(caPath) if errTLS != nil { ...
go
func New(scheduler Scheduler, storage Storage, caPath string, nodes ...Node) (*Cluster, error) { var ( c Cluster err error ) if storage == nil { return nil, errStorageMandatory } c.stor = storage c.scheduler = scheduler if caPath != "" { tlsConfig, errTLS := readTLSConfig(caPath) if errTLS != nil { ...
[ "func", "New", "(", "scheduler", "Scheduler", ",", "storage", "Storage", ",", "caPath", "string", ",", "nodes", "...", "Node", ")", "(", "*", "Cluster", ",", "error", ")", "{", "var", "(", "c", "Cluster", "\n", "err", "error", "\n", ")", "\n", "if", ...
// New creates a new Cluster, initially composed by the given nodes. // // The scheduler parameter defines the scheduling strategy. It defaults // to round robin if nil. // The storage parameter is the storage the cluster instance will use.
[ "New", "creates", "a", "new", "Cluster", "initially", "composed", "by", "the", "given", "nodes", ".", "The", "scheduler", "parameter", "defines", "the", "scheduling", "strategy", ".", "It", "defaults", "to", "round", "robin", "if", "nil", ".", "The", "storag...
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/cluster.go#L163-L193
127,973
tsuru/docker-cluster
cluster/cluster.go
Register
func (c *Cluster) Register(node Node) error { if node.Address == "" { return errors.New("Invalid address") } node.defTLSConfig = c.tlsConfig err := c.runHooks(HookEventBeforeNodeRegister, &node) if err != nil { return err } return c.storage().StoreNode(node) }
go
func (c *Cluster) Register(node Node) error { if node.Address == "" { return errors.New("Invalid address") } node.defTLSConfig = c.tlsConfig err := c.runHooks(HookEventBeforeNodeRegister, &node) if err != nil { return err } return c.storage().StoreNode(node) }
[ "func", "(", "c", "*", "Cluster", ")", "Register", "(", "node", "Node", ")", "error", "{", "if", "node", ".", "Address", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "node", ".", "defTLSConfig", "=...
// Register adds new nodes to the cluster.
[ "Register", "adds", "new", "nodes", "to", "the", "cluster", "." ]
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/cluster.go#L223-L233
127,974
tsuru/docker-cluster
cluster/cluster.go
Unregister
func (c *Cluster) Unregister(address string) error { err := c.runHookForAddr(HookEventBeforeNodeUnregister, address) if err != nil { return err } return c.storage().RemoveNode(address) }
go
func (c *Cluster) Unregister(address string) error { err := c.runHookForAddr(HookEventBeforeNodeUnregister, address) if err != nil { return err } return c.storage().RemoveNode(address) }
[ "func", "(", "c", "*", "Cluster", ")", "Unregister", "(", "address", "string", ")", "error", "{", "err", ":=", "c", ".", "runHookForAddr", "(", "HookEventBeforeNodeUnregister", ",", "address", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\...
// Unregister removes nodes from the cluster.
[ "Unregister", "removes", "nodes", "from", "the", "cluster", "." ]
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/cluster.go#L274-L280
127,975
tsuru/docker-cluster
cluster/image.go
RemoveImage
func (c *Cluster) RemoveImage(name string) error { stor := c.storage() image, err := stor.RetrieveImage(name) if err != nil { return err } hosts := []string{} idMap := map[string][]string{} for _, entry := range image.History { _, isOld := idMap[entry.Node] idMap[entry.Node] = append(idMap[entry.Node], ent...
go
func (c *Cluster) RemoveImage(name string) error { stor := c.storage() image, err := stor.RetrieveImage(name) if err != nil { return err } hosts := []string{} idMap := map[string][]string{} for _, entry := range image.History { _, isOld := idMap[entry.Node] idMap[entry.Node] = append(idMap[entry.Node], ent...
[ "func", "(", "c", "*", "Cluster", ")", "RemoveImage", "(", "name", "string", ")", "error", "{", "stor", ":=", "c", ".", "storage", "(", ")", "\n", "image", ",", "err", ":=", "stor", ".", "RetrieveImage", "(", "name", ")", "\n", "if", "err", "!=", ...
// RemoveImage removes an image from the nodes where this images exists, // returning an error in case of failure. Will wait for the image to be // removed on all nodes.
[ "RemoveImage", "removes", "an", "image", "from", "the", "nodes", "where", "this", "images", "exists", "returning", "an", "error", "in", "case", "of", "failure", ".", "Will", "wait", "for", "the", "image", "to", "be", "removed", "on", "all", "nodes", "." ]
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/image.go#L37-L72
127,976
tsuru/docker-cluster
cluster/image.go
PullImage
func (c *Cluster) PullImage(opts docker.PullImageOptions, auth docker.AuthConfiguration, nodes ...string) error { var w safe.Buffer if opts.OutputStream != nil { mw := io.MultiWriter(&w, opts.OutputStream) opts.OutputStream = mw } else { opts.OutputStream = &w } key := imageKey(opts.Repository, opts.Tag) _,...
go
func (c *Cluster) PullImage(opts docker.PullImageOptions, auth docker.AuthConfiguration, nodes ...string) error { var w safe.Buffer if opts.OutputStream != nil { mw := io.MultiWriter(&w, opts.OutputStream) opts.OutputStream = mw } else { opts.OutputStream = &w } key := imageKey(opts.Repository, opts.Tag) _,...
[ "func", "(", "c", "*", "Cluster", ")", "PullImage", "(", "opts", "docker", ".", "PullImageOptions", ",", "auth", "docker", ".", "AuthConfiguration", ",", "nodes", "...", "string", ")", "error", "{", "var", "w", "safe", ".", "Buffer", "\n", "if", "opts", ...
// PullImage pulls an image from a remote registry server, returning an error // in case of failure. // // It will pull all images in parallel, so users need to make sure that the // given buffer is safe.
[ "PullImage", "pulls", "an", "image", "from", "a", "remote", "registry", "server", "returning", "an", "error", "in", "case", "of", "failure", ".", "It", "will", "pull", "all", "images", "in", "parallel", "so", "users", "need", "to", "make", "sure", "that", ...
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/image.go#L90-L116
127,977
tsuru/docker-cluster
cluster/image.go
TagImage
func (c *Cluster) TagImage(name string, opts docker.TagImageOptions) error { img, err := c.storage().RetrieveImage(name) if err != nil { return err } node, err := c.getNodeByAddr(img.LastNode) if err != nil { return err } err = node.TagImage(name, opts) if err != nil { return wrapError(node, err) } key ...
go
func (c *Cluster) TagImage(name string, opts docker.TagImageOptions) error { img, err := c.storage().RetrieveImage(name) if err != nil { return err } node, err := c.getNodeByAddr(img.LastNode) if err != nil { return err } err = node.TagImage(name, opts) if err != nil { return wrapError(node, err) } key ...
[ "func", "(", "c", "*", "Cluster", ")", "TagImage", "(", "name", "string", ",", "opts", "docker", ".", "TagImageOptions", ")", "error", "{", "img", ",", "err", ":=", "c", ".", "storage", "(", ")", ".", "RetrieveImage", "(", "name", ")", "\n", "if", ...
// TagImage adds a tag to the given image, returning an error in case of // failure.
[ "TagImage", "adds", "a", "tag", "to", "the", "given", "image", "returning", "an", "error", "in", "case", "of", "failure", "." ]
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/image.go#L120-L135
127,978
tsuru/docker-cluster
cluster/image.go
PushImage
func (c *Cluster) PushImage(opts docker.PushImageOptions, auth docker.AuthConfiguration) error { key := imageKey(opts.Name, opts.Tag) img, err := c.storage().RetrieveImage(key) if err != nil { return err } node, err := c.getNodeByAddr(img.LastNode) if err != nil { return err } node.setPersistentClient() re...
go
func (c *Cluster) PushImage(opts docker.PushImageOptions, auth docker.AuthConfiguration) error { key := imageKey(opts.Name, opts.Tag) img, err := c.storage().RetrieveImage(key) if err != nil { return err } node, err := c.getNodeByAddr(img.LastNode) if err != nil { return err } node.setPersistentClient() re...
[ "func", "(", "c", "*", "Cluster", ")", "PushImage", "(", "opts", "docker", ".", "PushImageOptions", ",", "auth", "docker", ".", "AuthConfiguration", ")", "error", "{", "key", ":=", "imageKey", "(", "opts", ".", "Name", ",", "opts", ".", "Tag", ")", "\n...
// PushImage pushes an image to a remote registry server, returning an error in // case of failure.
[ "PushImage", "pushes", "an", "image", "to", "a", "remote", "registry", "server", "returning", "an", "error", "in", "case", "of", "failure", "." ]
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/image.go#L139-L151
127,979
tsuru/docker-cluster
cluster/image.go
InspectImage
func (c *Cluster) InspectImage(repo string) (*docker.Image, error) { img, err := c.storage().RetrieveImage(repo) if err != nil { return nil, err } node, err := c.getNodeByAddr(img.LastNode) if err != nil { return nil, err } dockerImg, err := node.InspectImage(repo) return dockerImg, wrapError(node, err) }
go
func (c *Cluster) InspectImage(repo string) (*docker.Image, error) { img, err := c.storage().RetrieveImage(repo) if err != nil { return nil, err } node, err := c.getNodeByAddr(img.LastNode) if err != nil { return nil, err } dockerImg, err := node.InspectImage(repo) return dockerImg, wrapError(node, err) }
[ "func", "(", "c", "*", "Cluster", ")", "InspectImage", "(", "repo", "string", ")", "(", "*", "docker", ".", "Image", ",", "error", ")", "{", "img", ",", "err", ":=", "c", ".", "storage", "(", ")", ".", "RetrieveImage", "(", "repo", ")", "\n", "if...
// InspectImage inspects an image based on its repo name
[ "InspectImage", "inspects", "an", "image", "based", "on", "its", "repo", "name" ]
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/image.go#L154-L165
127,980
tsuru/docker-cluster
cluster/image.go
ImageHistory
func (c *Cluster) ImageHistory(repo string) ([]docker.ImageHistory, error) { img, err := c.storage().RetrieveImage(repo) if err != nil { return nil, err } node, err := c.getNodeByAddr(img.LastNode) if err != nil { return nil, err } imgHistory, err := node.ImageHistory(repo) return imgHistory, wrapError(node...
go
func (c *Cluster) ImageHistory(repo string) ([]docker.ImageHistory, error) { img, err := c.storage().RetrieveImage(repo) if err != nil { return nil, err } node, err := c.getNodeByAddr(img.LastNode) if err != nil { return nil, err } imgHistory, err := node.ImageHistory(repo) return imgHistory, wrapError(node...
[ "func", "(", "c", "*", "Cluster", ")", "ImageHistory", "(", "repo", "string", ")", "(", "[", "]", "docker", ".", "ImageHistory", ",", "error", ")", "{", "img", ",", "err", ":=", "c", ".", "storage", "(", ")", ".", "RetrieveImage", "(", "repo", ")",...
// ImageHistory returns the history of a given image
[ "ImageHistory", "returns", "the", "history", "of", "a", "given", "image" ]
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/image.go#L168-L179
127,981
tsuru/docker-cluster
cluster/image.go
ListImages
func (c *Cluster) ListImages(opts docker.ListImagesOptions) ([]docker.APIImages, error) { nodes, err := c.UnfilteredNodes() if err != nil { return nil, err } resultChan := make(chan []docker.APIImages, len(nodes)) errChan := make(chan error, len(nodes)) var wg sync.WaitGroup for _, node := range nodes { wg.A...
go
func (c *Cluster) ListImages(opts docker.ListImagesOptions) ([]docker.APIImages, error) { nodes, err := c.UnfilteredNodes() if err != nil { return nil, err } resultChan := make(chan []docker.APIImages, len(nodes)) errChan := make(chan error, len(nodes)) var wg sync.WaitGroup for _, node := range nodes { wg.A...
[ "func", "(", "c", "*", "Cluster", ")", "ListImages", "(", "opts", "docker", ".", "ListImagesOptions", ")", "(", "[", "]", "docker", ".", "APIImages", ",", "error", ")", "{", "nodes", ",", "err", ":=", "c", ".", "UnfilteredNodes", "(", ")", "\n", "if"...
// ListImages lists images existing in each cluster node
[ "ListImages", "lists", "images", "existing", "in", "each", "cluster", "node" ]
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/image.go#L182-L218
127,982
tsuru/docker-cluster
cluster/image.go
ImportImage
func (c *Cluster) ImportImage(opts docker.ImportImageOptions) error { _, err := c.runOnNodes(func(n node) (interface{}, error) { return nil, n.ImportImage(opts) }, docker.ErrNoSuchImage, false) return err }
go
func (c *Cluster) ImportImage(opts docker.ImportImageOptions) error { _, err := c.runOnNodes(func(n node) (interface{}, error) { return nil, n.ImportImage(opts) }, docker.ErrNoSuchImage, false) return err }
[ "func", "(", "c", "*", "Cluster", ")", "ImportImage", "(", "opts", "docker", ".", "ImportImageOptions", ")", "error", "{", "_", ",", "err", ":=", "c", ".", "runOnNodes", "(", "func", "(", "n", "node", ")", "(", "interface", "{", "}", ",", "error", ...
// ImportImage imports an image from a url or stdin
[ "ImportImage", "imports", "an", "image", "from", "a", "url", "or", "stdin" ]
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/image.go#L221-L226
127,983
tsuru/docker-cluster
cluster/image.go
BuildImage
func (c *Cluster) BuildImage(buildOptions docker.BuildImageOptions) error { nodes, err := c.Nodes() if err != nil { return err } if len(nodes) < 1 { return errors.New("There is no docker node. Please list one in tsuru.conf or add one with `tsuru node-add`.") } nodeAddress := nodes[rand.Intn(len(nodes))].Addre...
go
func (c *Cluster) BuildImage(buildOptions docker.BuildImageOptions) error { nodes, err := c.Nodes() if err != nil { return err } if len(nodes) < 1 { return errors.New("There is no docker node. Please list one in tsuru.conf or add one with `tsuru node-add`.") } nodeAddress := nodes[rand.Intn(len(nodes))].Addre...
[ "func", "(", "c", "*", "Cluster", ")", "BuildImage", "(", "buildOptions", "docker", ".", "BuildImageOptions", ")", "error", "{", "nodes", ",", "err", ":=", "c", ".", "Nodes", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", ...
//BuildImage build an image and pushes it to registry
[ "BuildImage", "build", "an", "image", "and", "pushes", "it", "to", "registry" ]
f372d8d4e3549863e8ca98c233f645bf3d2c1055
https://github.com/tsuru/docker-cluster/blob/f372d8d4e3549863e8ca98c233f645bf3d2c1055/cluster/image.go#L229-L252
127,984
vrischmann/envconfig
envconfig.go
InitWithPrefix
func InitWithPrefix(conf interface{}, prefix string) error { return InitWithOptions(conf, Options{Prefix: prefix}) }
go
func InitWithPrefix(conf interface{}, prefix string) error { return InitWithOptions(conf, Options{Prefix: prefix}) }
[ "func", "InitWithPrefix", "(", "conf", "interface", "{", "}", ",", "prefix", "string", ")", "error", "{", "return", "InitWithOptions", "(", "conf", ",", "Options", "{", "Prefix", ":", "prefix", "}", ")", "\n", "}" ]
// InitWithPrefix reads the configuration from environment variables and populates the conf object. conf must be a pointer. // Each key read will be prefixed with the prefix string.
[ "InitWithPrefix", "reads", "the", "configuration", "from", "environment", "variables", "and", "populates", "the", "conf", "object", ".", "conf", "must", "be", "a", "pointer", ".", "Each", "key", "read", "will", "be", "prefixed", "with", "the", "prefix", "strin...
d647766a494a7182c05fa4ddd1702c2c307a770d
https://github.com/vrischmann/envconfig/blob/d647766a494a7182c05fa4ddd1702c2c307a770d/envconfig.go#L84-L86
127,985
vrischmann/envconfig
envconfig.go
InitWithOptions
func InitWithOptions(conf interface{}, opts Options) error { value := reflect.ValueOf(conf) if value.Kind() != reflect.Ptr { return ErrNotAPointer } elem := value.Elem() ctx := context{ name: opts.Prefix, optional: opts.AllOptional, leaveNil: opts.LeaveNil, allowUnexported: opt...
go
func InitWithOptions(conf interface{}, opts Options) error { value := reflect.ValueOf(conf) if value.Kind() != reflect.Ptr { return ErrNotAPointer } elem := value.Elem() ctx := context{ name: opts.Prefix, optional: opts.AllOptional, leaveNil: opts.LeaveNil, allowUnexported: opt...
[ "func", "InitWithOptions", "(", "conf", "interface", "{", "}", ",", "opts", "Options", ")", "error", "{", "value", ":=", "reflect", ".", "ValueOf", "(", "conf", ")", "\n", "if", "value", ".", "Kind", "(", ")", "!=", "reflect", ".", "Ptr", "{", "retur...
// InitWithOptions reads the configuration from environment variables and populates the conf object. // conf must be a pointer.
[ "InitWithOptions", "reads", "the", "configuration", "from", "environment", "variables", "and", "populates", "the", "conf", "object", ".", "conf", "must", "be", "a", "pointer", "." ]
d647766a494a7182c05fa4ddd1702c2c307a770d
https://github.com/vrischmann/envconfig/blob/d647766a494a7182c05fa4ddd1702c2c307a770d/envconfig.go#L90-L117
127,986
mgutz/ansi
ansi.go
colorCode
func colorCode(style string) *bytes.Buffer { buf := bytes.NewBufferString("") if plain || style == "" { return buf } if style == "reset" { buf.WriteString(Reset) return buf } else if style == "off" { return buf } foregroundBackground := strings.Split(style, ":") foreground := strings.Split(foregroundBa...
go
func colorCode(style string) *bytes.Buffer { buf := bytes.NewBufferString("") if plain || style == "" { return buf } if style == "reset" { buf.WriteString(Reset) return buf } else if style == "off" { return buf } foregroundBackground := strings.Split(style, ":") foreground := strings.Split(foregroundBa...
[ "func", "colorCode", "(", "style", "string", ")", "*", "bytes", ".", "Buffer", "{", "buf", ":=", "bytes", ".", "NewBufferString", "(", "\"", "\"", ")", "\n", "if", "plain", "||", "style", "==", "\"", "\"", "{", "return", "buf", "\n", "}", "\n", "if...
// Gets the ANSI color code for a style.
[ "Gets", "the", "ANSI", "color", "code", "for", "a", "style", "." ]
9520e82c474b0a04dd04f8a40959027271bab992
https://github.com/mgutz/ansi/blob/9520e82c474b0a04dd04f8a40959027271bab992/ansi.go#L134-L214
127,987
mgutz/ansi
ansi.go
Color
func Color(s, style string) string { if plain || len(style) < 1 { return s } buf := colorCode(style) buf.WriteString(s) buf.WriteString(Reset) return buf.String() }
go
func Color(s, style string) string { if plain || len(style) < 1 { return s } buf := colorCode(style) buf.WriteString(s) buf.WriteString(Reset) return buf.String() }
[ "func", "Color", "(", "s", ",", "style", "string", ")", "string", "{", "if", "plain", "||", "len", "(", "style", ")", "<", "1", "{", "return", "s", "\n", "}", "\n", "buf", ":=", "colorCode", "(", "style", ")", "\n", "buf", ".", "WriteString", "("...
// Color colors a string based on the ANSI color code for style.
[ "Color", "colors", "a", "string", "based", "on", "the", "ANSI", "color", "code", "for", "style", "." ]
9520e82c474b0a04dd04f8a40959027271bab992
https://github.com/mgutz/ansi/blob/9520e82c474b0a04dd04f8a40959027271bab992/ansi.go#L217-L225
127,988
mgutz/ansi
ansi.go
ColorFunc
func ColorFunc(style string) func(string) string { if style == "" { return func(s string) string { return s } } color := ColorCode(style) return func(s string) string { if plain || s == "" { return s } buf := bytes.NewBufferString(color) buf.WriteString(s) buf.WriteString(Reset) result := buf....
go
func ColorFunc(style string) func(string) string { if style == "" { return func(s string) string { return s } } color := ColorCode(style) return func(s string) string { if plain || s == "" { return s } buf := bytes.NewBufferString(color) buf.WriteString(s) buf.WriteString(Reset) result := buf....
[ "func", "ColorFunc", "(", "style", "string", ")", "func", "(", "string", ")", "string", "{", "if", "style", "==", "\"", "\"", "{", "return", "func", "(", "s", "string", ")", "string", "{", "return", "s", "\n", "}", "\n", "}", "\n", "color", ":=", ...
// ColorFunc creates a closure to avoid computation ANSI color code.
[ "ColorFunc", "creates", "a", "closure", "to", "avoid", "computation", "ANSI", "color", "code", "." ]
9520e82c474b0a04dd04f8a40959027271bab992
https://github.com/mgutz/ansi/blob/9520e82c474b0a04dd04f8a40959027271bab992/ansi.go#L228-L245
127,989
mgutz/ansi
print.go
PrintStyles
func PrintStyles() { // for compatibility with Windows, not needed for *nix stdout := colorable.NewColorableStdout() bgColors := []string{ "", ":black", ":red", ":green", ":yellow", ":blue", ":magenta", ":cyan", ":white", } keys := make([]string, 0, len(Colors)) for k := range Colors { keys ...
go
func PrintStyles() { // for compatibility with Windows, not needed for *nix stdout := colorable.NewColorableStdout() bgColors := []string{ "", ":black", ":red", ":green", ":yellow", ":blue", ":magenta", ":cyan", ":white", } keys := make([]string, 0, len(Colors)) for k := range Colors { keys ...
[ "func", "PrintStyles", "(", ")", "{", "// for compatibility with Windows, not needed for *nix", "stdout", ":=", "colorable", ".", "NewColorableStdout", "(", ")", "\n\n", "bgColors", ":=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "...
// PrintStyles prints all style combinations to the terminal.
[ "PrintStyles", "prints", "all", "style", "combinations", "to", "the", "terminal", "." ]
9520e82c474b0a04dd04f8a40959027271bab992
https://github.com/mgutz/ansi/blob/9520e82c474b0a04dd04f8a40959027271bab992/print.go#L11-L42
127,990
libp2p/go-tcp-transport
tcp.go
tryLinger
func tryLinger(conn net.Conn, sec int) { type canLinger interface { SetLinger(int) error } if lingerConn, ok := conn.(canLinger); ok { _ = lingerConn.SetLinger(sec) } }
go
func tryLinger(conn net.Conn, sec int) { type canLinger interface { SetLinger(int) error } if lingerConn, ok := conn.(canLinger); ok { _ = lingerConn.SetLinger(sec) } }
[ "func", "tryLinger", "(", "conn", "net", ".", "Conn", ",", "sec", "int", ")", "{", "type", "canLinger", "interface", "{", "SetLinger", "(", "int", ")", "error", "\n", "}", "\n\n", "if", "lingerConn", ",", "ok", ":=", "conn", ".", "(", "canLinger", ")...
// try to set linger on the connection, if possible.
[ "try", "to", "set", "linger", "on", "the", "connection", "if", "possible", "." ]
d3b107842331578fe29ed84341f9f30a421f3e20
https://github.com/libp2p/go-tcp-transport/blob/d3b107842331578fe29ed84341f9f30a421f3e20/tcp.go#L25-L33
127,991
libp2p/go-tcp-transport
tcp.go
CanDial
func (t *TcpTransport) CanDial(addr ma.Multiaddr) bool { return mafmt.TCP.Matches(addr) }
go
func (t *TcpTransport) CanDial(addr ma.Multiaddr) bool { return mafmt.TCP.Matches(addr) }
[ "func", "(", "t", "*", "TcpTransport", ")", "CanDial", "(", "addr", "ma", ".", "Multiaddr", ")", "bool", "{", "return", "mafmt", ".", "TCP", ".", "Matches", "(", "addr", ")", "\n", "}" ]
// CanDial returns true if this transport believes it can dial the given // multiaddr.
[ "CanDial", "returns", "true", "if", "this", "transport", "believes", "it", "can", "dial", "the", "given", "multiaddr", "." ]
d3b107842331578fe29ed84341f9f30a421f3e20
https://github.com/libp2p/go-tcp-transport/blob/d3b107842331578fe29ed84341f9f30a421f3e20/tcp.go#L74-L76
127,992
libp2p/go-tcp-transport
tcp.go
Dial
func (t *TcpTransport) Dial(ctx context.Context, raddr ma.Multiaddr, p peer.ID) (tpt.Conn, error) { conn, err := t.maDial(ctx, raddr) if err != nil { return nil, err } // Set linger to 0 so we never get stuck in the TIME-WAIT state. When // linger is 0, connections are _reset_ instead of closed with a FIN. // T...
go
func (t *TcpTransport) Dial(ctx context.Context, raddr ma.Multiaddr, p peer.ID) (tpt.Conn, error) { conn, err := t.maDial(ctx, raddr) if err != nil { return nil, err } // Set linger to 0 so we never get stuck in the TIME-WAIT state. When // linger is 0, connections are _reset_ instead of closed with a FIN. // T...
[ "func", "(", "t", "*", "TcpTransport", ")", "Dial", "(", "ctx", "context", ".", "Context", ",", "raddr", "ma", ".", "Multiaddr", ",", "p", "peer", ".", "ID", ")", "(", "tpt", ".", "Conn", ",", "error", ")", "{", "conn", ",", "err", ":=", "t", "...
// Dial dials the peer at the remote address.
[ "Dial", "dials", "the", "peer", "at", "the", "remote", "address", "." ]
d3b107842331578fe29ed84341f9f30a421f3e20
https://github.com/libp2p/go-tcp-transport/blob/d3b107842331578fe29ed84341f9f30a421f3e20/tcp.go#L97-L107
127,993
libp2p/go-tcp-transport
tcp.go
Listen
func (t *TcpTransport) Listen(laddr ma.Multiaddr) (tpt.Listener, error) { list, err := t.maListen(laddr) if err != nil { return nil, err } list = &lingerListener{list, 0} return t.Upgrader.UpgradeListener(t, list), nil }
go
func (t *TcpTransport) Listen(laddr ma.Multiaddr) (tpt.Listener, error) { list, err := t.maListen(laddr) if err != nil { return nil, err } list = &lingerListener{list, 0} return t.Upgrader.UpgradeListener(t, list), nil }
[ "func", "(", "t", "*", "TcpTransport", ")", "Listen", "(", "laddr", "ma", ".", "Multiaddr", ")", "(", "tpt", ".", "Listener", ",", "error", ")", "{", "list", ",", "err", ":=", "t", ".", "maListen", "(", "laddr", ")", "\n", "if", "err", "!=", "nil...
// Listen listens on the given multiaddr.
[ "Listen", "listens", "on", "the", "given", "multiaddr", "." ]
d3b107842331578fe29ed84341f9f30a421f3e20
https://github.com/libp2p/go-tcp-transport/blob/d3b107842331578fe29ed84341f9f30a421f3e20/tcp.go#L122-L129
127,994
cloudfoundry/bosh-init
ui/ui.go
PrintLinef
func (ui *ui) PrintLinef(pattern string, args ...interface{}) { message := fmt.Sprintf(pattern, args...) _, err := fmt.Fprintln(ui.outWriter, message) if err != nil { ui.logger.Error(ui.logTag, "UI.PrintLinef failed (message='%s'): %s", message, err) } }
go
func (ui *ui) PrintLinef(pattern string, args ...interface{}) { message := fmt.Sprintf(pattern, args...) _, err := fmt.Fprintln(ui.outWriter, message) if err != nil { ui.logger.Error(ui.logTag, "UI.PrintLinef failed (message='%s'): %s", message, err) } }
[ "func", "(", "ui", "*", "ui", ")", "PrintLinef", "(", "pattern", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "message", ":=", "fmt", ".", "Sprintf", "(", "pattern", ",", "args", "...", ")", "\n", "_", ",", "err", ":=", "fmt", "...
// Printlnf starts and ends a text line
[ "Printlnf", "starts", "and", "ends", "a", "text", "line" ]
25ef2dbc1de0e6bb7c49f3075eaa8d1999764de6
https://github.com/cloudfoundry/bosh-init/blob/25ef2dbc1de0e6bb7c49f3075eaa8d1999764de6/ui/ui.go#L48-L54
127,995
cloudfoundry/bosh-init
ui/ui.go
BeginLinef
func (ui *ui) BeginLinef(pattern string, args ...interface{}) { message := fmt.Sprintf(pattern, args...) _, err := fmt.Fprint(ui.outWriter, message) if err != nil { ui.logger.Error(ui.logTag, "UI.BeginLinef failed (message='%s'): %s", message, err) } }
go
func (ui *ui) BeginLinef(pattern string, args ...interface{}) { message := fmt.Sprintf(pattern, args...) _, err := fmt.Fprint(ui.outWriter, message) if err != nil { ui.logger.Error(ui.logTag, "UI.BeginLinef failed (message='%s'): %s", message, err) } }
[ "func", "(", "ui", "*", "ui", ")", "BeginLinef", "(", "pattern", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "message", ":=", "fmt", ".", "Sprintf", "(", "pattern", ",", "args", "...", ")", "\n", "_", ",", "err", ":=", "fmt", "...
// PrintBeginf starts a text line
[ "PrintBeginf", "starts", "a", "text", "line" ]
25ef2dbc1de0e6bb7c49f3075eaa8d1999764de6
https://github.com/cloudfoundry/bosh-init/blob/25ef2dbc1de0e6bb7c49f3075eaa8d1999764de6/ui/ui.go#L57-L63
127,996
cloudfoundry/bosh-init
release/pkg/sort.go
Sort
func Sort(releasePackages []*Package) ([]*Package, error) { sortedPackages := []*Package{} incomingEdges, outgoingEdges := getEdgeMaps(releasePackages) noIncomingEdgesSet := []*Package{} for pkg, edgeList := range incomingEdges { if len(edgeList) == 0 { noIncomingEdgesSet = append(noIncomingEdgesSet, pkg) ...
go
func Sort(releasePackages []*Package) ([]*Package, error) { sortedPackages := []*Package{} incomingEdges, outgoingEdges := getEdgeMaps(releasePackages) noIncomingEdgesSet := []*Package{} for pkg, edgeList := range incomingEdges { if len(edgeList) == 0 { noIncomingEdgesSet = append(noIncomingEdgesSet, pkg) ...
[ "func", "Sort", "(", "releasePackages", "[", "]", "*", "Package", ")", "(", "[", "]", "*", "Package", ",", "error", ")", "{", "sortedPackages", ":=", "[", "]", "*", "Package", "{", "}", "\n\n", "incomingEdges", ",", "outgoingEdges", ":=", "getEdgeMaps", ...
// Topologically sorts an array of packages
[ "Topologically", "sorts", "an", "array", "of", "packages" ]
25ef2dbc1de0e6bb7c49f3075eaa8d1999764de6
https://github.com/cloudfoundry/bosh-init/blob/25ef2dbc1de0e6bb7c49f3075eaa8d1999764de6/release/pkg/sort.go#L9-L39
127,997
gorilla/pat
pat.go
Add
func (r *Router) Add(meth, pat string, h http.Handler) *mux.Route { return r.NewRoute().PathPrefix(pat).Handler(h).Methods(meth) }
go
func (r *Router) Add(meth, pat string, h http.Handler) *mux.Route { return r.NewRoute().PathPrefix(pat).Handler(h).Methods(meth) }
[ "func", "(", "r", "*", "Router", ")", "Add", "(", "meth", ",", "pat", "string", ",", "h", "http", ".", "Handler", ")", "*", "mux", ".", "Route", "{", "return", "r", ".", "NewRoute", "(", ")", ".", "PathPrefix", "(", "pat", ")", ".", "Handler", ...
// Add registers a pattern with a handler for the given request method.
[ "Add", "registers", "a", "pattern", "with", "a", "handler", "for", "the", "given", "request", "method", "." ]
199c85a7f6d1ed2ecd6f071892d312c00d43b031
https://github.com/gorilla/pat/blob/199c85a7f6d1ed2ecd6f071892d312c00d43b031/pat.go#L30-L32
127,998
gorilla/pat
pat.go
Options
func (r *Router) Options(pat string, h http.HandlerFunc) *mux.Route { return r.Add("OPTIONS", pat, h) }
go
func (r *Router) Options(pat string, h http.HandlerFunc) *mux.Route { return r.Add("OPTIONS", pat, h) }
[ "func", "(", "r", "*", "Router", ")", "Options", "(", "pat", "string", ",", "h", "http", ".", "HandlerFunc", ")", "*", "mux", ".", "Route", "{", "return", "r", ".", "Add", "(", "\"", "\"", ",", "pat", ",", "h", ")", "\n", "}" ]
// Options registers a pattern with a handler for OPTIONS requests.
[ "Options", "registers", "a", "pattern", "with", "a", "handler", "for", "OPTIONS", "requests", "." ]
199c85a7f6d1ed2ecd6f071892d312c00d43b031
https://github.com/gorilla/pat/blob/199c85a7f6d1ed2ecd6f071892d312c00d43b031/pat.go#L35-L37
127,999
gorilla/pat
pat.go
ServeHTTP
func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) { // Clean path to canonical form and redirect. if p := cleanPath(req.URL.Path); p != req.URL.Path { w.Header().Set("Location", p) w.WriteHeader(http.StatusMovedPermanently) return } var match mux.RouteMatch var handler http.Handler if mat...
go
func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) { // Clean path to canonical form and redirect. if p := cleanPath(req.URL.Path); p != req.URL.Path { w.Header().Set("Location", p) w.WriteHeader(http.StatusMovedPermanently) return } var match mux.RouteMatch var handler http.Handler if mat...
[ "func", "(", "r", "*", "Router", ")", "ServeHTTP", "(", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "// Clean path to canonical form and redirect.", "if", "p", ":=", "cleanPath", "(", "req", ".", "URL", ".", "Path...
// ServeHTTP dispatches the handler registered in the matched route.
[ "ServeHTTP", "dispatches", "the", "handler", "registered", "in", "the", "matched", "route", "." ]
199c85a7f6d1ed2ecd6f071892d312c00d43b031
https://github.com/gorilla/pat/blob/199c85a7f6d1ed2ecd6f071892d312c00d43b031/pat.go#L70-L93