repo
stringlengths
5
67
path
stringlengths
4
218
func_name
stringlengths
0
151
original_string
stringlengths
52
373k
language
stringclasses
6 values
code
stringlengths
52
373k
code_tokens
listlengths
10
512
docstring
stringlengths
3
47.2k
docstring_tokens
listlengths
3
234
sha
stringlengths
40
40
url
stringlengths
85
339
partition
stringclasses
3 values
uber/tchannel-go
json/context.go
NewContext
func NewContext(timeout time.Duration) (Context, context.CancelFunc) { ctx, cancel := tchannel.NewContext(timeout) return tchannel.WrapWithHeaders(ctx, nil), cancel }
go
func NewContext(timeout time.Duration) (Context, context.CancelFunc) { ctx, cancel := tchannel.NewContext(timeout) return tchannel.WrapWithHeaders(ctx, nil), cancel }
[ "func", "NewContext", "(", "timeout", "time", ".", "Duration", ")", "(", "Context", ",", "context", ".", "CancelFunc", ")", "{", "ctx", ",", "cancel", ":=", "tchannel", ".", "NewContext", "(", "timeout", ")", "\n", "return", "tchannel", ".", "WrapWithHeade...
// NewContext returns a Context that can be used to make JSON calls.
[ "NewContext", "returns", "a", "Context", "that", "can", "be", "used", "to", "make", "JSON", "calls", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/json/context.go#L35-L38
test
uber/tchannel-go
raw/handler.go
WriteResponse
func WriteResponse(response *tchannel.InboundCallResponse, resp *Res) error { if resp.SystemErr != nil { return response.SendSystemError(resp.SystemErr) } if resp.IsErr { if err := response.SetApplicationError(); err != nil { return err } } if err := tchannel.NewArgWriter(response.Arg2Writer()).Write(resp...
go
func WriteResponse(response *tchannel.InboundCallResponse, resp *Res) error { if resp.SystemErr != nil { return response.SendSystemError(resp.SystemErr) } if resp.IsErr { if err := response.SetApplicationError(); err != nil { return err } } if err := tchannel.NewArgWriter(response.Arg2Writer()).Write(resp...
[ "func", "WriteResponse", "(", "response", "*", "tchannel", ".", "InboundCallResponse", ",", "resp", "*", "Res", ")", "error", "{", "if", "resp", ".", "SystemErr", "!=", "nil", "{", "return", "response", ".", "SendSystemError", "(", "resp", ".", "SystemErr", ...
// WriteResponse writes the given Res to the InboundCallResponse.
[ "WriteResponse", "writes", "the", "given", "Res", "to", "the", "InboundCallResponse", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/raw/handler.go#L71-L84
test
uber/tchannel-go
raw/handler.go
Wrap
func Wrap(handler Handler) tchannel.Handler { return tchannel.HandlerFunc(func(ctx context.Context, call *tchannel.InboundCall) { args, err := ReadArgs(call) if err != nil { handler.OnError(ctx, err) return } resp, err := handler.Handle(ctx, args) response := call.Response() if err != nil { resp ...
go
func Wrap(handler Handler) tchannel.Handler { return tchannel.HandlerFunc(func(ctx context.Context, call *tchannel.InboundCall) { args, err := ReadArgs(call) if err != nil { handler.OnError(ctx, err) return } resp, err := handler.Handle(ctx, args) response := call.Response() if err != nil { resp ...
[ "func", "Wrap", "(", "handler", "Handler", ")", "tchannel", ".", "Handler", "{", "return", "tchannel", ".", "HandlerFunc", "(", "func", "(", "ctx", "context", ".", "Context", ",", "call", "*", "tchannel", ".", "InboundCall", ")", "{", "args", ",", "err",...
// Wrap wraps a Handler as a tchannel.Handler that can be passed to tchannel.Register.
[ "Wrap", "wraps", "a", "Handler", "as", "a", "tchannel", ".", "Handler", "that", "can", "be", "passed", "to", "tchannel", ".", "Register", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/raw/handler.go#L87-L106
test
uber/tchannel-go
tracing.go
initFromOpenTracing
func (s *injectableSpan) initFromOpenTracing(span opentracing.Span) error { return span.Tracer().Inject(span.Context(), zipkinSpanFormat, s) }
go
func (s *injectableSpan) initFromOpenTracing(span opentracing.Span) error { return span.Tracer().Inject(span.Context(), zipkinSpanFormat, s) }
[ "func", "(", "s", "*", "injectableSpan", ")", "initFromOpenTracing", "(", "span", "opentracing", ".", "Span", ")", "error", "{", "return", "span", ".", "Tracer", "(", ")", ".", "Inject", "(", "span", ".", "Context", "(", ")", ",", "zipkinSpanFormat", ","...
// initFromOpenTracing initializes injectableSpan fields from an OpenTracing Span, // assuming the tracing implementation supports Zipkin-style span IDs.
[ "initFromOpenTracing", "initializes", "injectableSpan", "fields", "from", "an", "OpenTracing", "Span", "assuming", "the", "tracing", "implementation", "supports", "Zipkin", "-", "style", "span", "IDs", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/tracing.go#L114-L116
test
uber/tchannel-go
tracing.go
startOutboundSpan
func (c *Connection) startOutboundSpan(ctx context.Context, serviceName, methodName string, call *OutboundCall, startTime time.Time) opentracing.Span { var parent opentracing.SpanContext // ok to be nil if s := opentracing.SpanFromContext(ctx); s != nil { parent = s.Context() } span := c.Tracer().StartSpan( met...
go
func (c *Connection) startOutboundSpan(ctx context.Context, serviceName, methodName string, call *OutboundCall, startTime time.Time) opentracing.Span { var parent opentracing.SpanContext // ok to be nil if s := opentracing.SpanFromContext(ctx); s != nil { parent = s.Context() } span := c.Tracer().StartSpan( met...
[ "func", "(", "c", "*", "Connection", ")", "startOutboundSpan", "(", "ctx", "context", ".", "Context", ",", "serviceName", ",", "methodName", "string", ",", "call", "*", "OutboundCall", ",", "startTime", "time", ".", "Time", ")", "opentracing", ".", "Span", ...
// startOutboundSpan creates a new tracing span to represent the outbound RPC call. // If the context already contains a span, it will be used as a parent, otherwise // a new root span is created. // // If the tracer supports Zipkin-style trace IDs, then call.callReq.Tracing is // initialized with those IDs. Otherwise ...
[ "startOutboundSpan", "creates", "a", "new", "tracing", "span", "to", "represent", "the", "outbound", "RPC", "call", ".", "If", "the", "context", "already", "contains", "a", "span", "it", "will", "be", "used", "as", "a", "parent", "otherwise", "a", "new", "...
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/tracing.go#L139-L163
test
uber/tchannel-go
hyperbahn/utils.go
intToIP4
func intToIP4(ip uint32) net.IP { return net.IP{ byte(ip >> 24 & 0xff), byte(ip >> 16 & 0xff), byte(ip >> 8 & 0xff), byte(ip & 0xff), } }
go
func intToIP4(ip uint32) net.IP { return net.IP{ byte(ip >> 24 & 0xff), byte(ip >> 16 & 0xff), byte(ip >> 8 & 0xff), byte(ip & 0xff), } }
[ "func", "intToIP4", "(", "ip", "uint32", ")", "net", ".", "IP", "{", "return", "net", ".", "IP", "{", "byte", "(", "ip", ">>", "24", "&", "0xff", ")", ",", "byte", "(", "ip", ">>", "16", "&", "0xff", ")", ",", "byte", "(", "ip", ">>", "8", ...
// intToIP4 converts an integer IP representation into a 4-byte net.IP struct
[ "intToIP4", "converts", "an", "integer", "IP", "representation", "into", "a", "4", "-", "byte", "net", ".", "IP", "struct" ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/hyperbahn/utils.go#L31-L38
test
uber/tchannel-go
hyperbahn/utils.go
servicePeerToHostPort
func servicePeerToHostPort(peer *hyperbahn.ServicePeer) string { host := intToIP4(uint32(*peer.IP.Ipv4)).String() port := strconv.Itoa(int(peer.Port)) return net.JoinHostPort(host, port) }
go
func servicePeerToHostPort(peer *hyperbahn.ServicePeer) string { host := intToIP4(uint32(*peer.IP.Ipv4)).String() port := strconv.Itoa(int(peer.Port)) return net.JoinHostPort(host, port) }
[ "func", "servicePeerToHostPort", "(", "peer", "*", "hyperbahn", ".", "ServicePeer", ")", "string", "{", "host", ":=", "intToIP4", "(", "uint32", "(", "*", "peer", ".", "IP", ".", "Ipv4", ")", ")", ".", "String", "(", ")", "\n", "port", ":=", "strconv",...
// servicePeerToHostPort converts a Hyperbahn ServicePeer into a hostPort string.
[ "servicePeerToHostPort", "converts", "a", "Hyperbahn", "ServicePeer", "into", "a", "hostPort", "string", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/hyperbahn/utils.go#L41-L45
test
uber/tchannel-go
stats/statsdreporter.go
NewStatsdReporter
func NewStatsdReporter(addr, prefix string) (tchannel.StatsReporter, error) { client, err := statsd.NewBufferedClient(addr, prefix, time.Second, 0) if err != nil { return nil, err } return NewStatsdReporterClient(client), nil }
go
func NewStatsdReporter(addr, prefix string) (tchannel.StatsReporter, error) { client, err := statsd.NewBufferedClient(addr, prefix, time.Second, 0) if err != nil { return nil, err } return NewStatsdReporterClient(client), nil }
[ "func", "NewStatsdReporter", "(", "addr", ",", "prefix", "string", ")", "(", "tchannel", ".", "StatsReporter", ",", "error", ")", "{", "client", ",", "err", ":=", "statsd", ".", "NewBufferedClient", "(", "addr", ",", "prefix", ",", "time", ".", "Second", ...
// NewStatsdReporter returns a StatsReporter that reports to statsd on the given addr.
[ "NewStatsdReporter", "returns", "a", "StatsReporter", "that", "reports", "to", "statsd", "on", "the", "given", "addr", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/stats/statsdreporter.go#L40-L47
test
uber/tchannel-go
tos/tos_string.go
UnmarshalText
func (r *ToS) UnmarshalText(data []byte) error { if v, ok := _tosNameToValue[string(data)]; ok { *r = v return nil } return fmt.Errorf("invalid ToS %q", string(data)) }
go
func (r *ToS) UnmarshalText(data []byte) error { if v, ok := _tosNameToValue[string(data)]; ok { *r = v return nil } return fmt.Errorf("invalid ToS %q", string(data)) }
[ "func", "(", "r", "*", "ToS", ")", "UnmarshalText", "(", "data", "[", "]", "byte", ")", "error", "{", "if", "v", ",", "ok", ":=", "_tosNameToValue", "[", "string", "(", "data", ")", "]", ";", "ok", "{", "*", "r", "=", "v", "\n", "return", "nil"...
// UnmarshalText implements TextUnMarshaler from encoding
[ "UnmarshalText", "implements", "TextUnMarshaler", "from", "encoding" ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/tos/tos_string.go#L46-L53
test
uber/tchannel-go
peer_heap.go
Push
func (ph *peerHeap) Push(x interface{}) { n := len(ph.peerScores) item := x.(*peerScore) item.index = n ph.peerScores = append(ph.peerScores, item) }
go
func (ph *peerHeap) Push(x interface{}) { n := len(ph.peerScores) item := x.(*peerScore) item.index = n ph.peerScores = append(ph.peerScores, item) }
[ "func", "(", "ph", "*", "peerHeap", ")", "Push", "(", "x", "interface", "{", "}", ")", "{", "n", ":=", "len", "(", "ph", ".", "peerScores", ")", "\n", "item", ":=", "x", ".", "(", "*", "peerScore", ")", "\n", "item", ".", "index", "=", "n", "...
// Push implements heap Push interface
[ "Push", "implements", "heap", "Push", "interface" ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/peer_heap.go#L58-L63
test
uber/tchannel-go
peer_heap.go
Pop
func (ph *peerHeap) Pop() interface{} { old := *ph n := len(old.peerScores) item := old.peerScores[n-1] item.index = -1 // for safety ph.peerScores = old.peerScores[:n-1] return item }
go
func (ph *peerHeap) Pop() interface{} { old := *ph n := len(old.peerScores) item := old.peerScores[n-1] item.index = -1 // for safety ph.peerScores = old.peerScores[:n-1] return item }
[ "func", "(", "ph", "*", "peerHeap", ")", "Pop", "(", ")", "interface", "{", "}", "{", "old", ":=", "*", "ph", "\n", "n", ":=", "len", "(", "old", ".", "peerScores", ")", "\n", "item", ":=", "old", ".", "peerScores", "[", "n", "-", "1", "]", "...
// Pop implements heap Pop interface
[ "Pop", "implements", "heap", "Pop", "interface" ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/peer_heap.go#L66-L73
test
uber/tchannel-go
peer_heap.go
updatePeer
func (ph *peerHeap) updatePeer(peerScore *peerScore) { heap.Fix(ph, peerScore.index) }
go
func (ph *peerHeap) updatePeer(peerScore *peerScore) { heap.Fix(ph, peerScore.index) }
[ "func", "(", "ph", "*", "peerHeap", ")", "updatePeer", "(", "peerScore", "*", "peerScore", ")", "{", "heap", ".", "Fix", "(", "ph", ",", "peerScore", ".", "index", ")", "\n", "}" ]
// updatePeer updates the score for the given peer.
[ "updatePeer", "updates", "the", "score", "for", "the", "given", "peer", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/peer_heap.go#L76-L78
test
uber/tchannel-go
peer_heap.go
removePeer
func (ph *peerHeap) removePeer(peerScore *peerScore) { heap.Remove(ph, peerScore.index) }
go
func (ph *peerHeap) removePeer(peerScore *peerScore) { heap.Remove(ph, peerScore.index) }
[ "func", "(", "ph", "*", "peerHeap", ")", "removePeer", "(", "peerScore", "*", "peerScore", ")", "{", "heap", ".", "Remove", "(", "ph", ",", "peerScore", ".", "index", ")", "\n", "}" ]
// removePeer remove peer at specific index.
[ "removePeer", "remove", "peer", "at", "specific", "index", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/peer_heap.go#L81-L83
test
uber/tchannel-go
peer_heap.go
pushPeer
func (ph *peerHeap) pushPeer(peerScore *peerScore) { ph.order++ newOrder := ph.order // randRange will affect the deviation of peer's chosenCount randRange := ph.Len()/2 + 1 peerScore.order = newOrder + uint64(ph.rng.Intn(randRange)) heap.Push(ph, peerScore) }
go
func (ph *peerHeap) pushPeer(peerScore *peerScore) { ph.order++ newOrder := ph.order // randRange will affect the deviation of peer's chosenCount randRange := ph.Len()/2 + 1 peerScore.order = newOrder + uint64(ph.rng.Intn(randRange)) heap.Push(ph, peerScore) }
[ "func", "(", "ph", "*", "peerHeap", ")", "pushPeer", "(", "peerScore", "*", "peerScore", ")", "{", "ph", ".", "order", "++", "\n", "newOrder", ":=", "ph", ".", "order", "\n", "randRange", ":=", "ph", ".", "Len", "(", ")", "/", "2", "+", "1", "\n"...
// pushPeer pushes the new peer into the heap.
[ "pushPeer", "pushes", "the", "new", "peer", "into", "the", "heap", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/peer_heap.go#L91-L98
test
uber/tchannel-go
peer_heap.go
addPeer
func (ph *peerHeap) addPeer(peerScore *peerScore) { ph.pushPeer(peerScore) // Pick a random element, and swap the order with that peerScore. r := ph.rng.Intn(ph.Len()) ph.swapOrder(peerScore.index, r) }
go
func (ph *peerHeap) addPeer(peerScore *peerScore) { ph.pushPeer(peerScore) // Pick a random element, and swap the order with that peerScore. r := ph.rng.Intn(ph.Len()) ph.swapOrder(peerScore.index, r) }
[ "func", "(", "ph", "*", "peerHeap", ")", "addPeer", "(", "peerScore", "*", "peerScore", ")", "{", "ph", ".", "pushPeer", "(", "peerScore", ")", "\n", "r", ":=", "ph", ".", "rng", ".", "Intn", "(", "ph", ".", "Len", "(", ")", ")", "\n", "ph", "....
// AddPeer adds a peer to the peer heap.
[ "AddPeer", "adds", "a", "peer", "to", "the", "peer", "heap", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/peer_heap.go#L111-L117
test
uber/tchannel-go
thrift/client.go
NewClient
func NewClient(ch *tchannel.Channel, serviceName string, opts *ClientOptions) TChanClient { client := &client{ ch: ch, sc: ch.GetSubChannel(serviceName), serviceName: serviceName, } if opts != nil { client.opts = *opts } return client }
go
func NewClient(ch *tchannel.Channel, serviceName string, opts *ClientOptions) TChanClient { client := &client{ ch: ch, sc: ch.GetSubChannel(serviceName), serviceName: serviceName, } if opts != nil { client.opts = *opts } return client }
[ "func", "NewClient", "(", "ch", "*", "tchannel", ".", "Channel", ",", "serviceName", "string", ",", "opts", "*", "ClientOptions", ")", "TChanClient", "{", "client", ":=", "&", "client", "{", "ch", ":", "ch", ",", "sc", ":", "ch", ".", "GetSubChannel", ...
// NewClient returns a Client that makes calls over the given tchannel to the given Hyperbahn service.
[ "NewClient", "returns", "a", "Client", "that", "makes", "calls", "over", "the", "given", "tchannel", "to", "the", "given", "Hyperbahn", "service", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/client.go#L46-L56
test
uber/tchannel-go
root_peer_list.go
Add
func (l *RootPeerList) Add(hostPort string) *Peer { l.RLock() if p, ok := l.peersByHostPort[hostPort]; ok { l.RUnlock() return p } l.RUnlock() l.Lock() defer l.Unlock() if p, ok := l.peersByHostPort[hostPort]; ok { return p } var p *Peer // To avoid duplicate connections, only the root list should c...
go
func (l *RootPeerList) Add(hostPort string) *Peer { l.RLock() if p, ok := l.peersByHostPort[hostPort]; ok { l.RUnlock() return p } l.RUnlock() l.Lock() defer l.Unlock() if p, ok := l.peersByHostPort[hostPort]; ok { return p } var p *Peer // To avoid duplicate connections, only the root list should c...
[ "func", "(", "l", "*", "RootPeerList", ")", "Add", "(", "hostPort", "string", ")", "*", "Peer", "{", "l", ".", "RLock", "(", ")", "\n", "if", "p", ",", "ok", ":=", "l", ".", "peersByHostPort", "[", "hostPort", "]", ";", "ok", "{", "l", ".", "RU...
// Add adds a peer to the root peer list if it does not exist, or return // an existing peer if it exists.
[ "Add", "adds", "a", "peer", "to", "the", "root", "peer", "list", "if", "it", "does", "not", "exist", "or", "return", "an", "existing", "peer", "if", "it", "exists", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/root_peer_list.go#L51-L73
test
uber/tchannel-go
root_peer_list.go
Get
func (l *RootPeerList) Get(hostPort string) (*Peer, bool) { l.RLock() p, ok := l.peersByHostPort[hostPort] l.RUnlock() return p, ok }
go
func (l *RootPeerList) Get(hostPort string) (*Peer, bool) { l.RLock() p, ok := l.peersByHostPort[hostPort] l.RUnlock() return p, ok }
[ "func", "(", "l", "*", "RootPeerList", ")", "Get", "(", "hostPort", "string", ")", "(", "*", "Peer", ",", "bool", ")", "{", "l", ".", "RLock", "(", ")", "\n", "p", ",", "ok", ":=", "l", ".", "peersByHostPort", "[", "hostPort", "]", "\n", "l", "...
// Get returns a peer for the given hostPort if it exists.
[ "Get", "returns", "a", "peer", "for", "the", "given", "hostPort", "if", "it", "exists", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/root_peer_list.go#L86-L91
test
uber/tchannel-go
benchmark/options.go
WithTimeout
func WithTimeout(timeout time.Duration) Option { return func(opts *options) { opts.timeout = timeout } }
go
func WithTimeout(timeout time.Duration) Option { return func(opts *options) { opts.timeout = timeout } }
[ "func", "WithTimeout", "(", "timeout", "time", ".", "Duration", ")", "Option", "{", "return", "func", "(", "opts", "*", "options", ")", "{", "opts", ".", "timeout", "=", "timeout", "\n", "}", "\n", "}" ]
// WithTimeout sets the timeout to use for each call.
[ "WithTimeout", "sets", "the", "timeout", "to", "use", "for", "each", "call", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/benchmark/options.go#L48-L52
test
uber/tchannel-go
thrift/thrift-gen/wrap.go
Methods
func (s *Service) Methods() []*Method { if s.methods != nil { return s.methods } for _, m := range s.Service.Methods { s.methods = append(s.methods, &Method{m, s, s.state}) } sort.Sort(byMethodName(s.methods)) return s.methods }
go
func (s *Service) Methods() []*Method { if s.methods != nil { return s.methods } for _, m := range s.Service.Methods { s.methods = append(s.methods, &Method{m, s, s.state}) } sort.Sort(byMethodName(s.methods)) return s.methods }
[ "func", "(", "s", "*", "Service", ")", "Methods", "(", ")", "[", "]", "*", "Method", "{", "if", "s", ".", "methods", "!=", "nil", "{", "return", "s", ".", "methods", "\n", "}", "\n", "for", "_", ",", "m", ":=", "range", "s", ".", "Service", "...
// Methods returns the methods on this service, not including methods from inherited services.
[ "Methods", "returns", "the", "methods", "on", "this", "service", "not", "including", "methods", "from", "inherited", "services", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/thrift-gen/wrap.go#L107-L117
test
uber/tchannel-go
thrift/thrift-gen/wrap.go
InheritedMethods
func (s *Service) InheritedMethods() []string { if s.inheritedMethods != nil { return s.inheritedMethods } for svc := s.ExtendsService; svc != nil; svc = svc.ExtendsService { for m := range svc.Service.Methods { s.inheritedMethods = append(s.inheritedMethods, m) } } sort.Strings(s.inheritedMethods) ret...
go
func (s *Service) InheritedMethods() []string { if s.inheritedMethods != nil { return s.inheritedMethods } for svc := s.ExtendsService; svc != nil; svc = svc.ExtendsService { for m := range svc.Service.Methods { s.inheritedMethods = append(s.inheritedMethods, m) } } sort.Strings(s.inheritedMethods) ret...
[ "func", "(", "s", "*", "Service", ")", "InheritedMethods", "(", ")", "[", "]", "string", "{", "if", "s", ".", "inheritedMethods", "!=", "nil", "{", "return", "s", ".", "inheritedMethods", "\n", "}", "\n", "for", "svc", ":=", "s", ".", "ExtendsService",...
// InheritedMethods returns names for inherited methods on this service.
[ "InheritedMethods", "returns", "names", "for", "inherited", "methods", "on", "this", "service", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/thrift-gen/wrap.go#L120-L133
test
uber/tchannel-go
thrift/thrift-gen/wrap.go
Arguments
func (m *Method) Arguments() []*Field { var args []*Field for _, f := range m.Method.Arguments { args = append(args, &Field{f, m.state}) } return args }
go
func (m *Method) Arguments() []*Field { var args []*Field for _, f := range m.Method.Arguments { args = append(args, &Field{f, m.state}) } return args }
[ "func", "(", "m", "*", "Method", ")", "Arguments", "(", ")", "[", "]", "*", "Field", "{", "var", "args", "[", "]", "*", "Field", "\n", "for", "_", ",", "f", ":=", "range", "m", ".", "Method", ".", "Arguments", "{", "args", "=", "append", "(", ...
// Arguments returns the argument declarations for this method.
[ "Arguments", "returns", "the", "argument", "declarations", "for", "this", "method", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/thrift-gen/wrap.go#L159-L165
test
uber/tchannel-go
thrift/thrift-gen/wrap.go
ArgList
func (m *Method) ArgList() string { args := []string{"ctx " + contextType()} for _, arg := range m.Arguments() { args = append(args, arg.Declaration()) } return strings.Join(args, ", ") }
go
func (m *Method) ArgList() string { args := []string{"ctx " + contextType()} for _, arg := range m.Arguments() { args = append(args, arg.Declaration()) } return strings.Join(args, ", ") }
[ "func", "(", "m", "*", "Method", ")", "ArgList", "(", ")", "string", "{", "args", ":=", "[", "]", "string", "{", "\"ctx \"", "+", "contextType", "(", ")", "}", "\n", "for", "_", ",", "arg", ":=", "range", "m", ".", "Arguments", "(", ")", "{", "...
// ArgList returns the argument list for the function.
[ "ArgList", "returns", "the", "argument", "list", "for", "the", "function", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/thrift-gen/wrap.go#L201-L207
test
uber/tchannel-go
thrift/thrift-gen/wrap.go
CallList
func (m *Method) CallList(reqStruct string) string { args := []string{"ctx"} for _, arg := range m.Arguments() { args = append(args, reqStruct+"."+arg.ArgStructName()) } return strings.Join(args, ", ") }
go
func (m *Method) CallList(reqStruct string) string { args := []string{"ctx"} for _, arg := range m.Arguments() { args = append(args, reqStruct+"."+arg.ArgStructName()) } return strings.Join(args, ", ") }
[ "func", "(", "m", "*", "Method", ")", "CallList", "(", "reqStruct", "string", ")", "string", "{", "args", ":=", "[", "]", "string", "{", "\"ctx\"", "}", "\n", "for", "_", ",", "arg", ":=", "range", "m", ".", "Arguments", "(", ")", "{", "args", "=...
// CallList creates the call to a function satisfying Interface from an Args struct.
[ "CallList", "creates", "the", "call", "to", "a", "function", "satisfying", "Interface", "from", "an", "Args", "struct", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/thrift-gen/wrap.go#L210-L216
test
uber/tchannel-go
thrift/thrift-gen/wrap.go
RetType
func (m *Method) RetType() string { if !m.HasReturn() { return "error" } return fmt.Sprintf("(%v, %v)", m.state.goType(m.Method.ReturnType), "error") }
go
func (m *Method) RetType() string { if !m.HasReturn() { return "error" } return fmt.Sprintf("(%v, %v)", m.state.goType(m.Method.ReturnType), "error") }
[ "func", "(", "m", "*", "Method", ")", "RetType", "(", ")", "string", "{", "if", "!", "m", ".", "HasReturn", "(", ")", "{", "return", "\"error\"", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"(%v, %v)\"", ",", "m", ".", "state", ".", ...
// RetType returns the go return type of the method.
[ "RetType", "returns", "the", "go", "return", "type", "of", "the", "method", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/thrift-gen/wrap.go#L219-L224
test
uber/tchannel-go
thrift/thrift-gen/wrap.go
WrapResult
func (m *Method) WrapResult(respVar string) string { if !m.HasReturn() { panic("cannot wrap a return when there is no return mode") } if m.state.isResultPointer(m.ReturnType) { return respVar } return "&" + respVar }
go
func (m *Method) WrapResult(respVar string) string { if !m.HasReturn() { panic("cannot wrap a return when there is no return mode") } if m.state.isResultPointer(m.ReturnType) { return respVar } return "&" + respVar }
[ "func", "(", "m", "*", "Method", ")", "WrapResult", "(", "respVar", "string", ")", "string", "{", "if", "!", "m", ".", "HasReturn", "(", ")", "{", "panic", "(", "\"cannot wrap a return when there is no return mode\"", ")", "\n", "}", "\n", "if", "m", ".", ...
// WrapResult wraps the result variable before being used in the result struct.
[ "WrapResult", "wraps", "the", "result", "variable", "before", "being", "used", "in", "the", "result", "struct", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/thrift-gen/wrap.go#L227-L236
test
uber/tchannel-go
thrift/thrift-gen/wrap.go
ReturnWith
func (m *Method) ReturnWith(respName string, errName string) string { if !m.HasReturn() { return errName } return fmt.Sprintf("%v, %v", respName, errName) }
go
func (m *Method) ReturnWith(respName string, errName string) string { if !m.HasReturn() { return errName } return fmt.Sprintf("%v, %v", respName, errName) }
[ "func", "(", "m", "*", "Method", ")", "ReturnWith", "(", "respName", "string", ",", "errName", "string", ")", "string", "{", "if", "!", "m", ".", "HasReturn", "(", ")", "{", "return", "errName", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", ...
// ReturnWith takes the result name and the error name, and generates the return expression.
[ "ReturnWith", "takes", "the", "result", "name", "and", "the", "error", "name", "and", "generates", "the", "return", "expression", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/thrift-gen/wrap.go#L239-L244
test
uber/tchannel-go
thrift/thrift-gen/wrap.go
Declaration
func (a *Field) Declaration() string { return fmt.Sprintf("%s %s", a.Name(), a.ArgType()) }
go
func (a *Field) Declaration() string { return fmt.Sprintf("%s %s", a.Name(), a.ArgType()) }
[ "func", "(", "a", "*", "Field", ")", "Declaration", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"%s %s\"", ",", "a", ".", "Name", "(", ")", ",", "a", ".", "ArgType", "(", ")", ")", "\n", "}" ]
// Declaration returns the declaration for this field.
[ "Declaration", "returns", "the", "declaration", "for", "this", "field", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/thrift-gen/wrap.go#L254-L256
test
uber/tchannel-go
idle_sweep.go
startIdleSweep
func startIdleSweep(ch *Channel, opts *ChannelOptions) *idleSweep { is := &idleSweep{ ch: ch, maxIdleTime: opts.MaxIdleTime, idleCheckInterval: opts.IdleCheckInterval, } is.start() return is }
go
func startIdleSweep(ch *Channel, opts *ChannelOptions) *idleSweep { is := &idleSweep{ ch: ch, maxIdleTime: opts.MaxIdleTime, idleCheckInterval: opts.IdleCheckInterval, } is.start() return is }
[ "func", "startIdleSweep", "(", "ch", "*", "Channel", ",", "opts", "*", "ChannelOptions", ")", "*", "idleSweep", "{", "is", ":=", "&", "idleSweep", "{", "ch", ":", "ch", ",", "maxIdleTime", ":", "opts", ".", "MaxIdleTime", ",", "idleCheckInterval", ":", "...
// startIdleSweep starts a poller that checks for idle connections at given // intervals.
[ "startIdleSweep", "starts", "a", "poller", "that", "checks", "for", "idle", "connections", "at", "given", "intervals", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/idle_sweep.go#L39-L48
test
uber/tchannel-go
idle_sweep.go
start
func (is *idleSweep) start() { if is.started || is.idleCheckInterval <= 0 { return } is.ch.log.WithFields( LogField{"idleCheckInterval", is.idleCheckInterval}, LogField{"maxIdleTime", is.maxIdleTime}, ).Info("Starting idle connections poller.") is.started = true is.stopCh = make(chan struct{}) go is.poll...
go
func (is *idleSweep) start() { if is.started || is.idleCheckInterval <= 0 { return } is.ch.log.WithFields( LogField{"idleCheckInterval", is.idleCheckInterval}, LogField{"maxIdleTime", is.maxIdleTime}, ).Info("Starting idle connections poller.") is.started = true is.stopCh = make(chan struct{}) go is.poll...
[ "func", "(", "is", "*", "idleSweep", ")", "start", "(", ")", "{", "if", "is", ".", "started", "||", "is", ".", "idleCheckInterval", "<=", "0", "{", "return", "\n", "}", "\n", "is", ".", "ch", ".", "log", ".", "WithFields", "(", "LogField", "{", "...
// Start runs the goroutine responsible for checking idle connections.
[ "Start", "runs", "the", "goroutine", "responsible", "for", "checking", "idle", "connections", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/idle_sweep.go#L51-L64
test
uber/tchannel-go
idle_sweep.go
Stop
func (is *idleSweep) Stop() { if !is.started { return } is.started = false is.ch.log.Info("Stopping idle connections poller.") close(is.stopCh) }
go
func (is *idleSweep) Stop() { if !is.started { return } is.started = false is.ch.log.Info("Stopping idle connections poller.") close(is.stopCh) }
[ "func", "(", "is", "*", "idleSweep", ")", "Stop", "(", ")", "{", "if", "!", "is", ".", "started", "{", "return", "\n", "}", "\n", "is", ".", "started", "=", "false", "\n", "is", ".", "ch", ".", "log", ".", "Info", "(", "\"Stopping idle connections ...
// Stop kills the poller checking for idle connections.
[ "Stop", "kills", "the", "poller", "checking", "for", "idle", "connections", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/idle_sweep.go#L67-L75
test
uber/tchannel-go
thrift/thrift-gen/gopath.go
ResolveWithGoPath
func ResolveWithGoPath(filename string) (string, error) { for _, file := range goPathCandidates(filename) { if _, err := os.Stat(file); !os.IsNotExist(err) { return file, nil } } return "", fmt.Errorf("file not found on GOPATH: %q", filename) }
go
func ResolveWithGoPath(filename string) (string, error) { for _, file := range goPathCandidates(filename) { if _, err := os.Stat(file); !os.IsNotExist(err) { return file, nil } } return "", fmt.Errorf("file not found on GOPATH: %q", filename) }
[ "func", "ResolveWithGoPath", "(", "filename", "string", ")", "(", "string", ",", "error", ")", "{", "for", "_", ",", "file", ":=", "range", "goPathCandidates", "(", "filename", ")", "{", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "file", ")...
// ResolveWithGoPath will resolve the filename relative to GOPATH and returns // the first file that exists, or an error otherwise.
[ "ResolveWithGoPath", "will", "resolve", "the", "filename", "relative", "to", "GOPATH", "and", "returns", "the", "first", "file", "that", "exists", "or", "an", "error", "otherwise", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/thrift-gen/gopath.go#L31-L39
test
uber/tchannel-go
thrift/thrift-gen/extends.go
setExtends
func setExtends(state map[string]parseState) error { for _, v := range state { for _, s := range v.services { if s.Extends == "" { continue } var searchServices []*Service var searchFor string parts := strings.SplitN(s.Extends, ".", 2) // If it's not imported, then look at the current file's s...
go
func setExtends(state map[string]parseState) error { for _, v := range state { for _, s := range v.services { if s.Extends == "" { continue } var searchServices []*Service var searchFor string parts := strings.SplitN(s.Extends, ".", 2) // If it's not imported, then look at the current file's s...
[ "func", "setExtends", "(", "state", "map", "[", "string", "]", "parseState", ")", "error", "{", "for", "_", ",", "v", ":=", "range", "state", "{", "for", "_", ",", "s", ":=", "range", "v", ".", "services", "{", "if", "s", ".", "Extends", "==", "\...
// setExtends will set the ExtendsService for all services. // It is done after all files are parsed, as services may extend those // found in an included file.
[ "setExtends", "will", "set", "the", "ExtendsService", "for", "all", "services", ".", "It", "is", "done", "after", "all", "files", "are", "parsed", "as", "services", "may", "extend", "those", "found", "in", "an", "included", "file", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/thrift-gen/extends.go#L32-L64
test
uber/tchannel-go
handlers.go
register
func (hmap *handlerMap) register(h Handler, method string) { hmap.Lock() defer hmap.Unlock() if hmap.handlers == nil { hmap.handlers = make(map[string]Handler) } hmap.handlers[method] = h }
go
func (hmap *handlerMap) register(h Handler, method string) { hmap.Lock() defer hmap.Unlock() if hmap.handlers == nil { hmap.handlers = make(map[string]Handler) } hmap.handlers[method] = h }
[ "func", "(", "hmap", "*", "handlerMap", ")", "register", "(", "h", "Handler", ",", "method", "string", ")", "{", "hmap", ".", "Lock", "(", ")", "\n", "defer", "hmap", ".", "Unlock", "(", ")", "\n", "if", "hmap", ".", "handlers", "==", "nil", "{", ...
// Registers a handler
[ "Registers", "a", "handler" ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/handlers.go#L81-L90
test
uber/tchannel-go
benchmark/internal_client.go
NewClient
func NewClient(hosts []string, optFns ...Option) Client { opts := getOptions(optFns) if opts.external { return newExternalClient(hosts, opts) } if opts.numClients > 1 { return newInternalMultiClient(hosts, opts) } return newClient(hosts, opts) }
go
func NewClient(hosts []string, optFns ...Option) Client { opts := getOptions(optFns) if opts.external { return newExternalClient(hosts, opts) } if opts.numClients > 1 { return newInternalMultiClient(hosts, opts) } return newClient(hosts, opts) }
[ "func", "NewClient", "(", "hosts", "[", "]", "string", ",", "optFns", "...", "Option", ")", "Client", "{", "opts", ":=", "getOptions", "(", "optFns", ")", "\n", "if", "opts", ".", "external", "{", "return", "newExternalClient", "(", "hosts", ",", "opts",...
// NewClient returns a new Client that can make calls to a benchmark server.
[ "NewClient", "returns", "a", "new", "Client", "that", "can", "make", "calls", "to", "a", "benchmark", "server", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/benchmark/internal_client.go#L47-L56
test
uber/tchannel-go
localip.go
ListenIP
func ListenIP() (net.IP, error) { interfaces, err := net.Interfaces() if err != nil { return nil, err } return listenIP(interfaces) }
go
func ListenIP() (net.IP, error) { interfaces, err := net.Interfaces() if err != nil { return nil, err } return listenIP(interfaces) }
[ "func", "ListenIP", "(", ")", "(", "net", ".", "IP", ",", "error", ")", "{", "interfaces", ",", "err", ":=", "net", ".", "Interfaces", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "listenI...
// ListenIP returns the IP to bind to in Listen. It tries to find an IP that can be used // by other machines to reach this machine.
[ "ListenIP", "returns", "the", "IP", "to", "bind", "to", "in", "Listen", ".", "It", "tries", "to", "find", "an", "IP", "that", "can", "be", "used", "by", "other", "machines", "to", "reach", "this", "machine", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/localip.go#L89-L95
test
uber/tchannel-go
tnet/listener.go
Close
func (s *listener) Close() error { if err := s.Listener.Close(); err != nil { return err } s.cond.L.Lock() for s.refs > 0 { s.cond.Wait() } s.cond.L.Unlock() return nil }
go
func (s *listener) Close() error { if err := s.Listener.Close(); err != nil { return err } s.cond.L.Lock() for s.refs > 0 { s.cond.Wait() } s.cond.L.Unlock() return nil }
[ "func", "(", "s", "*", "listener", ")", "Close", "(", ")", "error", "{", "if", "err", ":=", "s", ".", "Listener", ".", "Close", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "s", ".", "cond", ".", "L", ".", "Lock",...
// Close closes the listener. // Any blocked Accept operations will be unblocked and return errors.
[ "Close", "closes", "the", "listener", ".", "Any", "blocked", "Accept", "operations", "will", "be", "unblocked", "and", "return", "errors", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/tnet/listener.go#L85-L96
test
uber/tchannel-go
raw/call.go
ReadArgsV2
func ReadArgsV2(r tchannel.ArgReadable) ([]byte, []byte, error) { var arg2, arg3 []byte if err := tchannel.NewArgReader(r.Arg2Reader()).Read(&arg2); err != nil { return nil, nil, err } if err := tchannel.NewArgReader(r.Arg3Reader()).Read(&arg3); err != nil { return nil, nil, err } return arg2, arg3, nil }
go
func ReadArgsV2(r tchannel.ArgReadable) ([]byte, []byte, error) { var arg2, arg3 []byte if err := tchannel.NewArgReader(r.Arg2Reader()).Read(&arg2); err != nil { return nil, nil, err } if err := tchannel.NewArgReader(r.Arg3Reader()).Read(&arg3); err != nil { return nil, nil, err } return arg2, arg3, nil }
[ "func", "ReadArgsV2", "(", "r", "tchannel", ".", "ArgReadable", ")", "(", "[", "]", "byte", ",", "[", "]", "byte", ",", "error", ")", "{", "var", "arg2", ",", "arg3", "[", "]", "byte", "\n", "if", "err", ":=", "tchannel", ".", "NewArgReader", "(", ...
// ReadArgsV2 reads arg2 and arg3 from a reader.
[ "ReadArgsV2", "reads", "arg2", "and", "arg3", "from", "a", "reader", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/raw/call.go#L35-L47
test
uber/tchannel-go
raw/call.go
WriteArgs
func WriteArgs(call *tchannel.OutboundCall, arg2, arg3 []byte) ([]byte, []byte, *tchannel.OutboundCallResponse, error) { if err := tchannel.NewArgWriter(call.Arg2Writer()).Write(arg2); err != nil { return nil, nil, nil, err } if err := tchannel.NewArgWriter(call.Arg3Writer()).Write(arg3); err != nil { return ni...
go
func WriteArgs(call *tchannel.OutboundCall, arg2, arg3 []byte) ([]byte, []byte, *tchannel.OutboundCallResponse, error) { if err := tchannel.NewArgWriter(call.Arg2Writer()).Write(arg2); err != nil { return nil, nil, nil, err } if err := tchannel.NewArgWriter(call.Arg3Writer()).Write(arg3); err != nil { return ni...
[ "func", "WriteArgs", "(", "call", "*", "tchannel", ".", "OutboundCall", ",", "arg2", ",", "arg3", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "[", "]", "byte", ",", "*", "tchannel", ".", "OutboundCallResponse", ",", "error", ")", "{", "if", ...
// WriteArgs writes the given arguments to the call, and returns the response args.
[ "WriteArgs", "writes", "the", "given", "arguments", "to", "the", "call", "and", "returns", "the", "response", "args", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/raw/call.go#L50-L71
test
uber/tchannel-go
raw/call.go
Call
func Call(ctx context.Context, ch *tchannel.Channel, hostPort string, serviceName, method string, arg2, arg3 []byte) ([]byte, []byte, *tchannel.OutboundCallResponse, error) { call, err := ch.BeginCall(ctx, hostPort, serviceName, method, nil) if err != nil { return nil, nil, nil, err } return WriteArgs(call, ar...
go
func Call(ctx context.Context, ch *tchannel.Channel, hostPort string, serviceName, method string, arg2, arg3 []byte) ([]byte, []byte, *tchannel.OutboundCallResponse, error) { call, err := ch.BeginCall(ctx, hostPort, serviceName, method, nil) if err != nil { return nil, nil, nil, err } return WriteArgs(call, ar...
[ "func", "Call", "(", "ctx", "context", ".", "Context", ",", "ch", "*", "tchannel", ".", "Channel", ",", "hostPort", "string", ",", "serviceName", ",", "method", "string", ",", "arg2", ",", "arg3", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", ...
// Call makes a call to the given hostPort with the given arguments and returns the response args.
[ "Call", "makes", "a", "call", "to", "the", "given", "hostPort", "with", "the", "given", "arguments", "and", "returns", "the", "response", "args", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/raw/call.go#L74-L83
test
uber/tchannel-go
raw/call.go
CallSC
func CallSC(ctx context.Context, sc *tchannel.SubChannel, method string, arg2, arg3 []byte) ( []byte, []byte, *tchannel.OutboundCallResponse, error) { call, err := sc.BeginCall(ctx, method, nil) if err != nil { return nil, nil, nil, err } return WriteArgs(call, arg2, arg3) }
go
func CallSC(ctx context.Context, sc *tchannel.SubChannel, method string, arg2, arg3 []byte) ( []byte, []byte, *tchannel.OutboundCallResponse, error) { call, err := sc.BeginCall(ctx, method, nil) if err != nil { return nil, nil, nil, err } return WriteArgs(call, arg2, arg3) }
[ "func", "CallSC", "(", "ctx", "context", ".", "Context", ",", "sc", "*", "tchannel", ".", "SubChannel", ",", "method", "string", ",", "arg2", ",", "arg3", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "[", "]", "byte", ",", "*", "tchannel", ...
// CallSC makes a call using the given subcahnnel
[ "CallSC", "makes", "a", "call", "using", "the", "given", "subcahnnel" ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/raw/call.go#L86-L95
test
uber/tchannel-go
raw/call.go
CallV2
func CallV2(ctx context.Context, sc *tchannel.SubChannel, cArgs CArgs) (*CRes, error) { call, err := sc.BeginCall(ctx, cArgs.Method, cArgs.CallOptions) if err != nil { return nil, err } arg2, arg3, res, err := WriteArgs(call, cArgs.Arg2, cArgs.Arg3) if err != nil { return nil, err } return &CRes{ Arg2: ...
go
func CallV2(ctx context.Context, sc *tchannel.SubChannel, cArgs CArgs) (*CRes, error) { call, err := sc.BeginCall(ctx, cArgs.Method, cArgs.CallOptions) if err != nil { return nil, err } arg2, arg3, res, err := WriteArgs(call, cArgs.Arg2, cArgs.Arg3) if err != nil { return nil, err } return &CRes{ Arg2: ...
[ "func", "CallV2", "(", "ctx", "context", ".", "Context", ",", "sc", "*", "tchannel", ".", "SubChannel", ",", "cArgs", "CArgs", ")", "(", "*", "CRes", ",", "error", ")", "{", "call", ",", "err", ":=", "sc", ".", "BeginCall", "(", "ctx", ",", "cArgs"...
// CallV2 makes a call and does not attempt any retries.
[ "CallV2", "makes", "a", "call", "and", "does", "not", "attempt", "any", "retries", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/raw/call.go#L113-L129
test
uber/tchannel-go
benchmark/real_relay.go
NewRealRelay
func NewRealRelay(services map[string][]string) (Relay, error) { hosts := &fixedHosts{hosts: services} ch, err := tchannel.NewChannel("relay", &tchannel.ChannelOptions{ RelayHost: relaytest.HostFunc(hosts.Get), Logger: tchannel.NewLevelLogger(tchannel.NewLogger(os.Stderr), tchannel.LogLevelWarn), }) if err !...
go
func NewRealRelay(services map[string][]string) (Relay, error) { hosts := &fixedHosts{hosts: services} ch, err := tchannel.NewChannel("relay", &tchannel.ChannelOptions{ RelayHost: relaytest.HostFunc(hosts.Get), Logger: tchannel.NewLevelLogger(tchannel.NewLogger(os.Stderr), tchannel.LogLevelWarn), }) if err !...
[ "func", "NewRealRelay", "(", "services", "map", "[", "string", "]", "[", "]", "string", ")", "(", "Relay", ",", "error", ")", "{", "hosts", ":=", "&", "fixedHosts", "{", "hosts", ":", "services", "}", "\n", "ch", ",", "err", ":=", "tchannel", ".", ...
// NewRealRelay creates a TChannel relay.
[ "NewRealRelay", "creates", "a", "TChannel", "relay", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/benchmark/real_relay.go#L55-L73
test
uber/tchannel-go
thrift/server.go
NewServer
func NewServer(registrar tchannel.Registrar) *Server { metaHandler := newMetaHandler() server := &Server{ ch: registrar, log: registrar.Logger(), handlers: make(map[string]handler), metaHandler: metaHandler, ctxFn: defaultContextFn, } server.Register(newTChanMetaServer(metaHandle...
go
func NewServer(registrar tchannel.Registrar) *Server { metaHandler := newMetaHandler() server := &Server{ ch: registrar, log: registrar.Logger(), handlers: make(map[string]handler), metaHandler: metaHandler, ctxFn: defaultContextFn, } server.Register(newTChanMetaServer(metaHandle...
[ "func", "NewServer", "(", "registrar", "tchannel", ".", "Registrar", ")", "*", "Server", "{", "metaHandler", ":=", "newMetaHandler", "(", ")", "\n", "server", ":=", "&", "Server", "{", "ch", ":", "registrar", ",", "log", ":", "registrar", ".", "Logger", ...
// NewServer returns a server that can serve thrift services over TChannel.
[ "NewServer", "returns", "a", "server", "that", "can", "serve", "thrift", "services", "over", "TChannel", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/server.go#L51-L66
test
uber/tchannel-go
thrift/server.go
RegisterHealthHandler
func (s *Server) RegisterHealthHandler(f HealthFunc) { wrapped := func(ctx Context, r HealthRequest) (bool, string) { return f(ctx) } s.metaHandler.setHandler(wrapped) }
go
func (s *Server) RegisterHealthHandler(f HealthFunc) { wrapped := func(ctx Context, r HealthRequest) (bool, string) { return f(ctx) } s.metaHandler.setHandler(wrapped) }
[ "func", "(", "s", "*", "Server", ")", "RegisterHealthHandler", "(", "f", "HealthFunc", ")", "{", "wrapped", ":=", "func", "(", "ctx", "Context", ",", "r", "HealthRequest", ")", "(", "bool", ",", "string", ")", "{", "return", "f", "(", "ctx", ")", "\n...
// RegisterHealthHandler uses the user-specified function f for the Health endpoint.
[ "RegisterHealthHandler", "uses", "the", "user", "-", "specified", "function", "f", "for", "the", "Health", "endpoint", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/server.go#L87-L92
test
uber/tchannel-go
thrift/server.go
Handle
func (s *Server) Handle(ctx context.Context, call *tchannel.InboundCall) { op := call.MethodString() service, method, ok := getServiceMethod(op) if !ok { log.Fatalf("Handle got call for %s which does not match the expected call format", op) } s.RLock() handler, ok := s.handlers[service] s.RUnlock() if !ok { ...
go
func (s *Server) Handle(ctx context.Context, call *tchannel.InboundCall) { op := call.MethodString() service, method, ok := getServiceMethod(op) if !ok { log.Fatalf("Handle got call for %s which does not match the expected call format", op) } s.RLock() handler, ok := s.handlers[service] s.RUnlock() if !ok { ...
[ "func", "(", "s", "*", "Server", ")", "Handle", "(", "ctx", "context", ".", "Context", ",", "call", "*", "tchannel", ".", "InboundCall", ")", "{", "op", ":=", "call", ".", "MethodString", "(", ")", "\n", "service", ",", "method", ",", "ok", ":=", "...
// Handle handles an incoming TChannel call and forwards it to the correct handler.
[ "Handle", "handles", "an", "incoming", "TChannel", "call", "and", "forwards", "it", "to", "the", "correct", "handler", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/server.go#L223-L240
test
uber/tchannel-go
errors.go
MetricsKey
func (c SystemErrCode) MetricsKey() string { switch c { case ErrCodeInvalid: // Shouldn't ever need this. return "invalid" case ErrCodeTimeout: return "timeout" case ErrCodeCancelled: return "cancelled" case ErrCodeBusy: return "busy" case ErrCodeDeclined: return "declined" case ErrCodeUnexpected: ...
go
func (c SystemErrCode) MetricsKey() string { switch c { case ErrCodeInvalid: // Shouldn't ever need this. return "invalid" case ErrCodeTimeout: return "timeout" case ErrCodeCancelled: return "cancelled" case ErrCodeBusy: return "busy" case ErrCodeDeclined: return "declined" case ErrCodeUnexpected: ...
[ "func", "(", "c", "SystemErrCode", ")", "MetricsKey", "(", ")", "string", "{", "switch", "c", "{", "case", "ErrCodeInvalid", ":", "return", "\"invalid\"", "\n", "case", "ErrCodeTimeout", ":", "return", "\"timeout\"", "\n", "case", "ErrCodeCancelled", ":", "ret...
// MetricsKey is a string representation of the error code that's suitable for // inclusion in metrics tags.
[ "MetricsKey", "is", "a", "string", "representation", "of", "the", "error", "code", "that", "s", "suitable", "for", "inclusion", "in", "metrics", "tags", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/errors.go#L102-L126
test
uber/tchannel-go
errors.go
NewSystemError
func NewSystemError(code SystemErrCode, msg string, args ...interface{}) error { return SystemError{code: code, msg: fmt.Sprintf(msg, args...)} }
go
func NewSystemError(code SystemErrCode, msg string, args ...interface{}) error { return SystemError{code: code, msg: fmt.Sprintf(msg, args...)} }
[ "func", "NewSystemError", "(", "code", "SystemErrCode", ",", "msg", "string", ",", "args", "...", "interface", "{", "}", ")", "error", "{", "return", "SystemError", "{", "code", ":", "code", ",", "msg", ":", "fmt", ".", "Sprintf", "(", "msg", ",", "arg...
// NewSystemError defines a new SystemError with a code and message
[ "NewSystemError", "defines", "a", "new", "SystemError", "with", "a", "code", "and", "message" ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/errors.go#L163-L165
test
uber/tchannel-go
errors.go
NewWrappedSystemError
func NewWrappedSystemError(code SystemErrCode, wrapped error) error { if se, ok := wrapped.(SystemError); ok { return se } return SystemError{code: code, msg: fmt.Sprint(wrapped), wrapped: wrapped} }
go
func NewWrappedSystemError(code SystemErrCode, wrapped error) error { if se, ok := wrapped.(SystemError); ok { return se } return SystemError{code: code, msg: fmt.Sprint(wrapped), wrapped: wrapped} }
[ "func", "NewWrappedSystemError", "(", "code", "SystemErrCode", ",", "wrapped", "error", ")", "error", "{", "if", "se", ",", "ok", ":=", "wrapped", ".", "(", "SystemError", ")", ";", "ok", "{", "return", "se", "\n", "}", "\n", "return", "SystemError", "{"...
// NewWrappedSystemError defines a new SystemError wrapping an existing error
[ "NewWrappedSystemError", "defines", "a", "new", "SystemError", "wrapping", "an", "existing", "error" ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/errors.go#L168-L174
test
uber/tchannel-go
errors.go
Error
func (se SystemError) Error() string { return fmt.Sprintf("tchannel error %v: %s", se.Code(), se.msg) }
go
func (se SystemError) Error() string { return fmt.Sprintf("tchannel error %v: %s", se.Code(), se.msg) }
[ "func", "(", "se", "SystemError", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"tchannel error %v: %s\"", ",", "se", ".", "Code", "(", ")", ",", "se", ".", "msg", ")", "\n", "}" ]
// Error returns the code and message, conforming to the error interface
[ "Error", "returns", "the", "code", "and", "message", "conforming", "to", "the", "error", "interface" ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/errors.go#L177-L179
test
uber/tchannel-go
errors.go
GetContextError
func GetContextError(err error) error { if err == context.DeadlineExceeded { return ErrTimeout } if err == context.Canceled { return ErrRequestCancelled } return err }
go
func GetContextError(err error) error { if err == context.DeadlineExceeded { return ErrTimeout } if err == context.Canceled { return ErrRequestCancelled } return err }
[ "func", "GetContextError", "(", "err", "error", ")", "error", "{", "if", "err", "==", "context", ".", "DeadlineExceeded", "{", "return", "ErrTimeout", "\n", "}", "\n", "if", "err", "==", "context", ".", "Canceled", "{", "return", "ErrRequestCancelled", "\n",...
// GetContextError converts the context error to a tchannel error.
[ "GetContextError", "converts", "the", "context", "error", "to", "a", "tchannel", "error", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/errors.go#L195-L203
test
uber/tchannel-go
errors.go
GetSystemErrorCode
func GetSystemErrorCode(err error) SystemErrCode { if err == nil { return ErrCodeInvalid } if se, ok := err.(SystemError); ok { return se.Code() } return ErrCodeUnexpected }
go
func GetSystemErrorCode(err error) SystemErrCode { if err == nil { return ErrCodeInvalid } if se, ok := err.(SystemError); ok { return se.Code() } return ErrCodeUnexpected }
[ "func", "GetSystemErrorCode", "(", "err", "error", ")", "SystemErrCode", "{", "if", "err", "==", "nil", "{", "return", "ErrCodeInvalid", "\n", "}", "\n", "if", "se", ",", "ok", ":=", "err", ".", "(", "SystemError", ")", ";", "ok", "{", "return", "se", ...
// GetSystemErrorCode returns the code to report for the given error. If the error is a // SystemError, we can get the code directly. Otherwise treat it as an unexpected error
[ "GetSystemErrorCode", "returns", "the", "code", "to", "report", "for", "the", "given", "error", ".", "If", "the", "error", "is", "a", "SystemError", "we", "can", "get", "the", "code", "directly", ".", "Otherwise", "treat", "it", "as", "an", "unexpected", "...
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/errors.go#L207-L217
test
uber/tchannel-go
connection.go
ping
func (c *Connection) ping(ctx context.Context) error { req := &pingReq{id: c.NextMessageID()} mex, err := c.outbound.newExchange(ctx, c.opts.FramePool, req.messageType(), req.ID(), 1) if err != nil { return c.connectionError("create ping exchange", err) } defer c.outbound.removeExchange(req.ID()) if err := c.s...
go
func (c *Connection) ping(ctx context.Context) error { req := &pingReq{id: c.NextMessageID()} mex, err := c.outbound.newExchange(ctx, c.opts.FramePool, req.messageType(), req.ID(), 1) if err != nil { return c.connectionError("create ping exchange", err) } defer c.outbound.removeExchange(req.ID()) if err := c.s...
[ "func", "(", "c", "*", "Connection", ")", "ping", "(", "ctx", "context", ".", "Context", ")", "error", "{", "req", ":=", "&", "pingReq", "{", "id", ":", "c", ".", "NextMessageID", "(", ")", "}", "\n", "mex", ",", "err", ":=", "c", ".", "outbound"...
// ping sends a ping message and waits for a ping response.
[ "ping", "sends", "a", "ping", "message", "and", "waits", "for", "a", "ping", "response", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/connection.go#L390-L403
test
uber/tchannel-go
connection.go
handlePingRes
func (c *Connection) handlePingRes(frame *Frame) bool { if err := c.outbound.forwardPeerFrame(frame); err != nil { c.log.WithFields(LogField{"response", frame.Header}).Warn("Unexpected ping response.") return true } // ping req is waiting for this frame, and will release it. return false }
go
func (c *Connection) handlePingRes(frame *Frame) bool { if err := c.outbound.forwardPeerFrame(frame); err != nil { c.log.WithFields(LogField{"response", frame.Header}).Warn("Unexpected ping response.") return true } // ping req is waiting for this frame, and will release it. return false }
[ "func", "(", "c", "*", "Connection", ")", "handlePingRes", "(", "frame", "*", "Frame", ")", "bool", "{", "if", "err", ":=", "c", ".", "outbound", ".", "forwardPeerFrame", "(", "frame", ")", ";", "err", "!=", "nil", "{", "c", ".", "log", ".", "WithF...
// handlePingRes calls registered ping handlers.
[ "handlePingRes", "calls", "registered", "ping", "handlers", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/connection.go#L406-L413
test
uber/tchannel-go
connection.go
handlePingReq
func (c *Connection) handlePingReq(frame *Frame) { if state := c.readState(); state != connectionActive { c.protocolError(frame.Header.ID, errConnNotActive{"ping on incoming", state}) return } pingRes := &pingRes{id: frame.Header.ID} if err := c.sendMessage(pingRes); err != nil { c.connectionError("send pong...
go
func (c *Connection) handlePingReq(frame *Frame) { if state := c.readState(); state != connectionActive { c.protocolError(frame.Header.ID, errConnNotActive{"ping on incoming", state}) return } pingRes := &pingRes{id: frame.Header.ID} if err := c.sendMessage(pingRes); err != nil { c.connectionError("send pong...
[ "func", "(", "c", "*", "Connection", ")", "handlePingReq", "(", "frame", "*", "Frame", ")", "{", "if", "state", ":=", "c", ".", "readState", "(", ")", ";", "state", "!=", "connectionActive", "{", "c", ".", "protocolError", "(", "frame", ".", "Header", ...
// handlePingReq responds to the pingReq message with a pingRes.
[ "handlePingReq", "responds", "to", "the", "pingReq", "message", "with", "a", "pingRes", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/connection.go#L416-L426
test
uber/tchannel-go
connection.go
SendSystemError
func (c *Connection) SendSystemError(id uint32, span Span, err error) error { frame := c.opts.FramePool.Get() if err := frame.write(&errorMessage{ id: id, errCode: GetSystemErrorCode(err), tracing: span, message: GetSystemErrorMessage(err), }); err != nil { // This shouldn't happen - it means writin...
go
func (c *Connection) SendSystemError(id uint32, span Span, err error) error { frame := c.opts.FramePool.Get() if err := frame.write(&errorMessage{ id: id, errCode: GetSystemErrorCode(err), tracing: span, message: GetSystemErrorMessage(err), }); err != nil { // This shouldn't happen - it means writin...
[ "func", "(", "c", "*", "Connection", ")", "SendSystemError", "(", "id", "uint32", ",", "span", "Span", ",", "err", "error", ")", "error", "{", "frame", ":=", "c", ".", "opts", ".", "FramePool", ".", "Get", "(", ")", "\n", "if", "err", ":=", "frame"...
// SendSystemError sends an error frame for the given system error.
[ "SendSystemError", "sends", "an", "error", "frame", "for", "the", "given", "system", "error", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/connection.go#L471-L514
test
uber/tchannel-go
connection.go
connectionError
func (c *Connection) connectionError(site string, err error) error { var closeLogFields LogFields if err == io.EOF { closeLogFields = LogFields{{"reason", "network connection EOF"}} } else { closeLogFields = LogFields{ {"reason", "connection error"}, ErrField(err), } } c.stopHealthCheck() err = c.log...
go
func (c *Connection) connectionError(site string, err error) error { var closeLogFields LogFields if err == io.EOF { closeLogFields = LogFields{{"reason", "network connection EOF"}} } else { closeLogFields = LogFields{ {"reason", "connection error"}, ErrField(err), } } c.stopHealthCheck() err = c.log...
[ "func", "(", "c", "*", "Connection", ")", "connectionError", "(", "site", "string", ",", "err", "error", ")", "error", "{", "var", "closeLogFields", "LogFields", "\n", "if", "err", "==", "io", ".", "EOF", "{", "closeLogFields", "=", "LogFields", "{", "{"...
// connectionError handles a connection level error
[ "connectionError", "handles", "a", "connection", "level", "error" ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/connection.go#L539-L563
test
uber/tchannel-go
connection.go
withStateLock
func (c *Connection) withStateLock(f func() error) error { c.stateMut.Lock() err := f() c.stateMut.Unlock() return err }
go
func (c *Connection) withStateLock(f func() error) error { c.stateMut.Lock() err := f() c.stateMut.Unlock() return err }
[ "func", "(", "c", "*", "Connection", ")", "withStateLock", "(", "f", "func", "(", ")", "error", ")", "error", "{", "c", ".", "stateMut", ".", "Lock", "(", ")", "\n", "err", ":=", "f", "(", ")", "\n", "c", ".", "stateMut", ".", "Unlock", "(", ")...
// withStateLock performs an action with the connection state mutex locked
[ "withStateLock", "performs", "an", "action", "with", "the", "connection", "state", "mutex", "locked" ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/connection.go#L584-L590
test
uber/tchannel-go
connection.go
withStateRLock
func (c *Connection) withStateRLock(f func() error) error { c.stateMut.RLock() err := f() c.stateMut.RUnlock() return err }
go
func (c *Connection) withStateRLock(f func() error) error { c.stateMut.RLock() err := f() c.stateMut.RUnlock() return err }
[ "func", "(", "c", "*", "Connection", ")", "withStateRLock", "(", "f", "func", "(", ")", "error", ")", "error", "{", "c", ".", "stateMut", ".", "RLock", "(", ")", "\n", "err", ":=", "f", "(", ")", "\n", "c", ".", "stateMut", ".", "RUnlock", "(", ...
// withStateRLock performs an action with the connection state mutex rlocked.
[ "withStateRLock", "performs", "an", "action", "with", "the", "connection", "state", "mutex", "rlocked", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/connection.go#L593-L599
test
uber/tchannel-go
connection.go
readFrames
func (c *Connection) readFrames(_ uint32) { headerBuf := make([]byte, FrameHeaderSize) handleErr := func(err error) { if !c.closeNetworkCalled.Load() { c.connectionError("read frames", err) } else { c.log.Debugf("Ignoring error after connection was closed: %v", err) } } for { // Read the header, avo...
go
func (c *Connection) readFrames(_ uint32) { headerBuf := make([]byte, FrameHeaderSize) handleErr := func(err error) { if !c.closeNetworkCalled.Load() { c.connectionError("read frames", err) } else { c.log.Debugf("Ignoring error after connection was closed: %v", err) } } for { // Read the header, avo...
[ "func", "(", "c", "*", "Connection", ")", "readFrames", "(", "_", "uint32", ")", "{", "headerBuf", ":=", "make", "(", "[", "]", "byte", ",", "FrameHeaderSize", ")", "\n", "handleErr", ":=", "func", "(", "err", "error", ")", "{", "if", "!", "c", "."...
// readFrames is the loop that reads frames from the network connection and // dispatches to the appropriate handler. Run within its own goroutine to // prevent overlapping reads on the socket. Most handlers simply send the // incoming frame to a channel; the init handlers are a notable exception, // since we cannot p...
[ "readFrames", "is", "the", "loop", "that", "reads", "frames", "from", "the", "network", "connection", "and", "dispatches", "to", "the", "appropriate", "handler", ".", "Run", "within", "its", "own", "goroutine", "to", "prevent", "overlapping", "reads", "on", "t...
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/connection.go#L613-L651
test
uber/tchannel-go
connection.go
writeFrames
func (c *Connection) writeFrames(_ uint32) { for { select { case f := <-c.sendCh: if c.log.Enabled(LogLevelDebug) { c.log.Debugf("Writing frame %s", f.Header) } c.updateLastActivity(f) err := f.WriteOut(c.conn) c.opts.FramePool.Release(f) if err != nil { c.connectionError("write frames",...
go
func (c *Connection) writeFrames(_ uint32) { for { select { case f := <-c.sendCh: if c.log.Enabled(LogLevelDebug) { c.log.Debugf("Writing frame %s", f.Header) } c.updateLastActivity(f) err := f.WriteOut(c.conn) c.opts.FramePool.Release(f) if err != nil { c.connectionError("write frames",...
[ "func", "(", "c", "*", "Connection", ")", "writeFrames", "(", "_", "uint32", ")", "{", "for", "{", "select", "{", "case", "f", ":=", "<-", "c", ".", "sendCh", ":", "if", "c", ".", "log", ".", "Enabled", "(", "LogLevelDebug", ")", "{", "c", ".", ...
// writeFrames is the main loop that pulls frames from the send channel and // writes them to the connection.
[ "writeFrames", "is", "the", "main", "loop", "that", "pulls", "frames", "from", "the", "send", "channel", "and", "writes", "them", "to", "the", "connection", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/connection.go#L701-L726
test
uber/tchannel-go
connection.go
hasPendingCalls
func (c *Connection) hasPendingCalls() bool { if c.inbound.count() > 0 || c.outbound.count() > 0 { return true } if !c.relay.canClose() { return true } return false }
go
func (c *Connection) hasPendingCalls() bool { if c.inbound.count() > 0 || c.outbound.count() > 0 { return true } if !c.relay.canClose() { return true } return false }
[ "func", "(", "c", "*", "Connection", ")", "hasPendingCalls", "(", ")", "bool", "{", "if", "c", ".", "inbound", ".", "count", "(", ")", ">", "0", "||", "c", ".", "outbound", ".", "count", "(", ")", ">", "0", "{", "return", "true", "\n", "}", "\n...
// hasPendingCalls returns whether there's any pending inbound or outbound calls on this connection.
[ "hasPendingCalls", "returns", "whether", "there", "s", "any", "pending", "inbound", "or", "outbound", "calls", "on", "this", "connection", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/connection.go#L739-L748
test
uber/tchannel-go
connection.go
checkExchanges
func (c *Connection) checkExchanges() { c.callOnExchangeChange() moveState := func(fromState, toState connectionState) bool { err := c.withStateLock(func() error { if c.state != fromState { return errors.New("") } c.state = toState return nil }) return err == nil } curState := c.readState() ...
go
func (c *Connection) checkExchanges() { c.callOnExchangeChange() moveState := func(fromState, toState connectionState) bool { err := c.withStateLock(func() error { if c.state != fromState { return errors.New("") } c.state = toState return nil }) return err == nil } curState := c.readState() ...
[ "func", "(", "c", "*", "Connection", ")", "checkExchanges", "(", ")", "{", "c", ".", "callOnExchangeChange", "(", ")", "\n", "moveState", ":=", "func", "(", "fromState", ",", "toState", "connectionState", ")", "bool", "{", "err", ":=", "c", ".", "withSta...
// checkExchanges is called whenever an exchange is removed, and when Close is called.
[ "checkExchanges", "is", "called", "whenever", "an", "exchange", "is", "removed", "and", "when", "Close", "is", "called", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/connection.go#L751-L809
test
uber/tchannel-go
connection.go
closeNetwork
func (c *Connection) closeNetwork() { // NB(mmihic): The sender goroutine will exit once the connection is // closed; no need to close the send channel (and closing the send // channel would be dangerous since other goroutine might be sending) c.log.Debugf("Closing underlying network connection") c.stopHealthCheck...
go
func (c *Connection) closeNetwork() { // NB(mmihic): The sender goroutine will exit once the connection is // closed; no need to close the send channel (and closing the send // channel would be dangerous since other goroutine might be sending) c.log.Debugf("Closing underlying network connection") c.stopHealthCheck...
[ "func", "(", "c", "*", "Connection", ")", "closeNetwork", "(", ")", "{", "c", ".", "log", ".", "Debugf", "(", "\"Closing underlying network connection\"", ")", "\n", "c", ".", "stopHealthCheck", "(", ")", "\n", "c", ".", "closeNetworkCalled", ".", "Store", ...
// closeNetwork closes the network connection and all network-related channels. // This should only be done in response to a fatal connection or protocol // error, or after all pending frames have been sent.
[ "closeNetwork", "closes", "the", "network", "connection", "and", "all", "network", "-", "related", "channels", ".", "This", "should", "only", "be", "done", "in", "response", "to", "a", "fatal", "connection", "or", "protocol", "error", "or", "after", "all", "...
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/connection.go#L853-L866
test
uber/tchannel-go
connection.go
getLastActivityTime
func (c *Connection) getLastActivityTime() time.Time { return time.Unix(0, c.lastActivity.Load()) }
go
func (c *Connection) getLastActivityTime() time.Time { return time.Unix(0, c.lastActivity.Load()) }
[ "func", "(", "c", "*", "Connection", ")", "getLastActivityTime", "(", ")", "time", ".", "Time", "{", "return", "time", ".", "Unix", "(", "0", ",", "c", ".", "lastActivity", ".", "Load", "(", ")", ")", "\n", "}" ]
// getLastActivityTime returns the timestamp of the last frame read or written, // excluding pings. If no frames were transmitted yet, it will return the time // this connection was created.
[ "getLastActivityTime", "returns", "the", "timestamp", "of", "the", "last", "frame", "read", "or", "written", "excluding", "pings", ".", "If", "no", "frames", "were", "transmitted", "yet", "it", "will", "return", "the", "time", "this", "connection", "was", "cre...
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/connection.go#L871-L873
test
uber/tchannel-go
thrift/thrift-gen/validate.go
Validate
func Validate(svc *parser.Service) error { for _, m := range svc.Methods { if err := validateMethod(svc, m); err != nil { return err } } return nil }
go
func Validate(svc *parser.Service) error { for _, m := range svc.Methods { if err := validateMethod(svc, m); err != nil { return err } } return nil }
[ "func", "Validate", "(", "svc", "*", "parser", ".", "Service", ")", "error", "{", "for", "_", ",", "m", ":=", "range", "svc", ".", "Methods", "{", "if", "err", ":=", "validateMethod", "(", "svc", ",", "m", ")", ";", "err", "!=", "nil", "{", "retu...
// Validate validates that the given spec is supported by thrift-gen.
[ "Validate", "validates", "that", "the", "given", "spec", "is", "supported", "by", "thrift", "-", "gen", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/thrift-gen/validate.go#L30-L37
test
uber/tchannel-go
hyperbahn/advertise.go
logFailedRegistrationRetry
func (c *Client) logFailedRegistrationRetry(errLogger tchannel.Logger, consecutiveFailures uint) { logFn := errLogger.Info if consecutiveFailures > maxAdvertiseFailures { logFn = errLogger.Warn } logFn("Hyperbahn client registration failed, will retry.") }
go
func (c *Client) logFailedRegistrationRetry(errLogger tchannel.Logger, consecutiveFailures uint) { logFn := errLogger.Info if consecutiveFailures > maxAdvertiseFailures { logFn = errLogger.Warn } logFn("Hyperbahn client registration failed, will retry.") }
[ "func", "(", "c", "*", "Client", ")", "logFailedRegistrationRetry", "(", "errLogger", "tchannel", ".", "Logger", ",", "consecutiveFailures", "uint", ")", "{", "logFn", ":=", "errLogger", ".", "Info", "\n", "if", "consecutiveFailures", ">", "maxAdvertiseFailures", ...
// logFailedRegistrationRetry logs either a warning or info depending on the number of // consecutiveFailures. If consecutiveFailures > maxAdvertiseFailures, then we log a warning.
[ "logFailedRegistrationRetry", "logs", "either", "a", "warning", "or", "info", "depending", "on", "the", "number", "of", "consecutiveFailures", ".", "If", "consecutiveFailures", ">", "maxAdvertiseFailures", "then", "we", "log", "a", "warning", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/hyperbahn/advertise.go#L69-L76
test
uber/tchannel-go
hyperbahn/advertise.go
initialAdvertise
func (c *Client) initialAdvertise() error { var err error for attempt := uint(0); attempt < maxAdvertiseFailures; attempt++ { err = c.sendAdvertise() if err == nil || err == errEphemeralPeer { break } c.tchan.Logger().WithFields(tchannel.ErrField(err)).Info( "Hyperbahn client initial registration failu...
go
func (c *Client) initialAdvertise() error { var err error for attempt := uint(0); attempt < maxAdvertiseFailures; attempt++ { err = c.sendAdvertise() if err == nil || err == errEphemeralPeer { break } c.tchan.Logger().WithFields(tchannel.ErrField(err)).Info( "Hyperbahn client initial registration failu...
[ "func", "(", "c", "*", "Client", ")", "initialAdvertise", "(", ")", "error", "{", "var", "err", "error", "\n", "for", "attempt", ":=", "uint", "(", "0", ")", ";", "attempt", "<", "maxAdvertiseFailures", ";", "attempt", "++", "{", "err", "=", "c", "."...
// initialAdvertise will do the initial Advertise call to Hyperbahn with additional // retries on top of the built-in TChannel retries. It will use exponential backoff // between each of the call attempts.
[ "initialAdvertise", "will", "do", "the", "initial", "Advertise", "call", "to", "Hyperbahn", "with", "additional", "retries", "on", "top", "of", "the", "built", "-", "in", "TChannel", "retries", ".", "It", "will", "use", "exponential", "backoff", "between", "ea...
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/hyperbahn/advertise.go#L116-L132
test
uber/tchannel-go
relay_messages.go
Service
func (f lazyCallReq) Service() []byte { l := f.Payload[_serviceLenIndex] return f.Payload[_serviceNameIndex : _serviceNameIndex+l] }
go
func (f lazyCallReq) Service() []byte { l := f.Payload[_serviceLenIndex] return f.Payload[_serviceNameIndex : _serviceNameIndex+l] }
[ "func", "(", "f", "lazyCallReq", ")", "Service", "(", ")", "[", "]", "byte", "{", "l", ":=", "f", ".", "Payload", "[", "_serviceLenIndex", "]", "\n", "return", "f", ".", "Payload", "[", "_serviceNameIndex", ":", "_serviceNameIndex", "+", "l", "]", "\n"...
// Service returns the name of the destination service for this callReq.
[ "Service", "returns", "the", "name", "of", "the", "destination", "service", "for", "this", "callReq", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/relay_messages.go#L144-L147
test
uber/tchannel-go
relay_messages.go
TTL
func (f lazyCallReq) TTL() time.Duration { ttl := binary.BigEndian.Uint32(f.Payload[_ttlIndex : _ttlIndex+_ttlLen]) return time.Duration(ttl) * time.Millisecond }
go
func (f lazyCallReq) TTL() time.Duration { ttl := binary.BigEndian.Uint32(f.Payload[_ttlIndex : _ttlIndex+_ttlLen]) return time.Duration(ttl) * time.Millisecond }
[ "func", "(", "f", "lazyCallReq", ")", "TTL", "(", ")", "time", ".", "Duration", "{", "ttl", ":=", "binary", ".", "BigEndian", ".", "Uint32", "(", "f", ".", "Payload", "[", "_ttlIndex", ":", "_ttlIndex", "+", "_ttlLen", "]", ")", "\n", "return", "time...
// TTL returns the time to live for this callReq.
[ "TTL", "returns", "the", "time", "to", "live", "for", "this", "callReq", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/relay_messages.go#L165-L168
test
uber/tchannel-go
relay_messages.go
SetTTL
func (f lazyCallReq) SetTTL(d time.Duration) { ttl := uint32(d / time.Millisecond) binary.BigEndian.PutUint32(f.Payload[_ttlIndex:_ttlIndex+_ttlLen], ttl) }
go
func (f lazyCallReq) SetTTL(d time.Duration) { ttl := uint32(d / time.Millisecond) binary.BigEndian.PutUint32(f.Payload[_ttlIndex:_ttlIndex+_ttlLen], ttl) }
[ "func", "(", "f", "lazyCallReq", ")", "SetTTL", "(", "d", "time", ".", "Duration", ")", "{", "ttl", ":=", "uint32", "(", "d", "/", "time", ".", "Millisecond", ")", "\n", "binary", ".", "BigEndian", ".", "PutUint32", "(", "f", ".", "Payload", "[", "...
// SetTTL overwrites the frame's TTL.
[ "SetTTL", "overwrites", "the", "frame", "s", "TTL", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/relay_messages.go#L171-L174
test
uber/tchannel-go
relay_messages.go
finishesCall
func finishesCall(f *Frame) bool { switch f.messageType() { case messageTypeError: return true case messageTypeCallRes, messageTypeCallResContinue: flags := f.Payload[_flagsIndex] return flags&hasMoreFragmentsFlag == 0 default: return false } }
go
func finishesCall(f *Frame) bool { switch f.messageType() { case messageTypeError: return true case messageTypeCallRes, messageTypeCallResContinue: flags := f.Payload[_flagsIndex] return flags&hasMoreFragmentsFlag == 0 default: return false } }
[ "func", "finishesCall", "(", "f", "*", "Frame", ")", "bool", "{", "switch", "f", ".", "messageType", "(", ")", "{", "case", "messageTypeError", ":", "return", "true", "\n", "case", "messageTypeCallRes", ",", "messageTypeCallResContinue", ":", "flags", ":=", ...
// finishesCall checks whether this frame is the last one we should expect for // this RPC req-res.
[ "finishesCall", "checks", "whether", "this", "frame", "is", "the", "last", "one", "we", "should", "expect", "for", "this", "RPC", "req", "-", "res", "." ]
3c9ced6d946fe2fec6c915703a533e966c09e07a
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/relay_messages.go#L188-L198
test
bazelbuild/bazel-gazelle
rule/platform_strings.go
Flat
func (ps *PlatformStrings) Flat() []string { unique := make(map[string]struct{}) for _, s := range ps.Generic { unique[s] = struct{}{} } for _, ss := range ps.OS { for _, s := range ss { unique[s] = struct{}{} } } for _, ss := range ps.Arch { for _, s := range ss { unique[s] = struct{}{} } } for...
go
func (ps *PlatformStrings) Flat() []string { unique := make(map[string]struct{}) for _, s := range ps.Generic { unique[s] = struct{}{} } for _, ss := range ps.OS { for _, s := range ss { unique[s] = struct{}{} } } for _, ss := range ps.Arch { for _, s := range ss { unique[s] = struct{}{} } } for...
[ "func", "(", "ps", "*", "PlatformStrings", ")", "Flat", "(", ")", "[", "]", "string", "{", "unique", ":=", "make", "(", "map", "[", "string", "]", "struct", "{", "}", ")", "\n", "for", "_", ",", "s", ":=", "range", "ps", ".", "Generic", "{", "u...
// Flat returns all the strings in the set, sorted and de-duplicated.
[ "Flat", "returns", "all", "the", "strings", "in", "the", "set", "sorted", "and", "de", "-", "duplicated", "." ]
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/rule/platform_strings.go#L59-L85
test
bazelbuild/bazel-gazelle
rule/platform_strings.go
Map
func (ps *PlatformStrings) Map(f func(s string) (string, error)) (PlatformStrings, []error) { var errors []error mapSlice := func(ss []string) ([]string, error) { rs := make([]string, 0, len(ss)) for _, s := range ss { if r, err := f(s); err != nil { errors = append(errors, err) } else if r != "" { ...
go
func (ps *PlatformStrings) Map(f func(s string) (string, error)) (PlatformStrings, []error) { var errors []error mapSlice := func(ss []string) ([]string, error) { rs := make([]string, 0, len(ss)) for _, s := range ss { if r, err := f(s); err != nil { errors = append(errors, err) } else if r != "" { ...
[ "func", "(", "ps", "*", "PlatformStrings", ")", "Map", "(", "f", "func", "(", "s", "string", ")", "(", "string", ",", "error", ")", ")", "(", "PlatformStrings", ",", "[", "]", "error", ")", "{", "var", "errors", "[", "]", "error", "\n", "mapSlice",...
// Map applies a function that processes individual strings to the strings // in "ps" and returns a new PlatformStrings with the result. Empty strings // returned by the function are dropped.
[ "Map", "applies", "a", "function", "that", "processes", "individual", "strings", "to", "the", "strings", "in", "ps", "and", "returns", "a", "new", "PlatformStrings", "with", "the", "result", ".", "Empty", "strings", "returned", "by", "the", "function", "are", ...
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/rule/platform_strings.go#L120-L135
test
bazelbuild/bazel-gazelle
rule/platform_strings.go
MapSlice
func (ps *PlatformStrings) MapSlice(f func([]string) ([]string, error)) (PlatformStrings, []error) { var errors []error mapSlice := func(ss []string) []string { rs, err := f(ss) if err != nil { errors = append(errors, err) return nil } return rs } mapStringMap := func(m map[string][]string) map[stri...
go
func (ps *PlatformStrings) MapSlice(f func([]string) ([]string, error)) (PlatformStrings, []error) { var errors []error mapSlice := func(ss []string) []string { rs, err := f(ss) if err != nil { errors = append(errors, err) return nil } return rs } mapStringMap := func(m map[string][]string) map[stri...
[ "func", "(", "ps", "*", "PlatformStrings", ")", "MapSlice", "(", "f", "func", "(", "[", "]", "string", ")", "(", "[", "]", "string", ",", "error", ")", ")", "(", "PlatformStrings", ",", "[", "]", "error", ")", "{", "var", "errors", "[", "]", "err...
// MapSlice applies a function that processes slices of strings to the strings // in "ps" and returns a new PlatformStrings with the results.
[ "MapSlice", "applies", "a", "function", "that", "processes", "slices", "of", "strings", "to", "the", "strings", "in", "ps", "and", "returns", "a", "new", "PlatformStrings", "with", "the", "results", "." ]
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/rule/platform_strings.go#L139-L192
test
bazelbuild/bazel-gazelle
language/proto/config.go
GetProtoConfig
func GetProtoConfig(c *config.Config) *ProtoConfig { pc := c.Exts[protoName] if pc == nil { return nil } return pc.(*ProtoConfig) }
go
func GetProtoConfig(c *config.Config) *ProtoConfig { pc := c.Exts[protoName] if pc == nil { return nil } return pc.(*ProtoConfig) }
[ "func", "GetProtoConfig", "(", "c", "*", "config", ".", "Config", ")", "*", "ProtoConfig", "{", "pc", ":=", "c", ".", "Exts", "[", "protoName", "]", "\n", "if", "pc", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "pc", ".", "(", "...
// GetProtoConfig returns the proto language configuration. If the proto // extension was not run, it will return nil.
[ "GetProtoConfig", "returns", "the", "proto", "language", "configuration", ".", "If", "the", "proto", "extension", "was", "not", "run", "it", "will", "return", "nil", "." ]
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/language/proto/config.go#L64-L70
test
bazelbuild/bazel-gazelle
rule/expr.go
MapExprStrings
func MapExprStrings(e bzl.Expr, f func(string) string) bzl.Expr { if e == nil { return nil } switch expr := e.(type) { case *bzl.StringExpr: s := f(expr.Value) if s == "" { return nil } ret := *expr ret.Value = s return &ret case *bzl.ListExpr: var list []bzl.Expr for _, elem := range expr.Li...
go
func MapExprStrings(e bzl.Expr, f func(string) string) bzl.Expr { if e == nil { return nil } switch expr := e.(type) { case *bzl.StringExpr: s := f(expr.Value) if s == "" { return nil } ret := *expr ret.Value = s return &ret case *bzl.ListExpr: var list []bzl.Expr for _, elem := range expr.Li...
[ "func", "MapExprStrings", "(", "e", "bzl", ".", "Expr", ",", "f", "func", "(", "string", ")", "string", ")", "bzl", ".", "Expr", "{", "if", "e", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "switch", "expr", ":=", "e", ".", "(", "type", ...
// MapExprStrings applies a function to string sub-expressions within e. // An expression containing the results with the same structure as e is // returned.
[ "MapExprStrings", "applies", "a", "function", "to", "string", "sub", "-", "expressions", "within", "e", ".", "An", "expression", "containing", "the", "results", "with", "the", "same", "structure", "as", "e", "is", "returned", "." ]
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/rule/expr.go#L30-L111
test
bazelbuild/bazel-gazelle
rule/expr.go
FlattenExpr
func FlattenExpr(e bzl.Expr) bzl.Expr { ps, err := extractPlatformStringsExprs(e) if err != nil { return e } ls := makeListSquasher() addElem := func(e bzl.Expr) bool { s, ok := e.(*bzl.StringExpr) if !ok { return false } ls.add(s) return true } addList := func(e bzl.Expr) bool { l, ok := e.(*b...
go
func FlattenExpr(e bzl.Expr) bzl.Expr { ps, err := extractPlatformStringsExprs(e) if err != nil { return e } ls := makeListSquasher() addElem := func(e bzl.Expr) bool { s, ok := e.(*bzl.StringExpr) if !ok { return false } ls.add(s) return true } addList := func(e bzl.Expr) bool { l, ok := e.(*b...
[ "func", "FlattenExpr", "(", "e", "bzl", ".", "Expr", ")", "bzl", ".", "Expr", "{", "ps", ",", "err", ":=", "extractPlatformStringsExprs", "(", "e", ")", "\n", "if", "err", "!=", "nil", "{", "return", "e", "\n", "}", "\n", "ls", ":=", "makeListSquashe...
// FlattenExpr takes an expression that may have been generated from // PlatformStrings and returns its values in a flat, sorted, de-duplicated // list. Comments are accumulated and de-duplicated across duplicate // expressions. If the expression could not have been generted by // PlatformStrings, the expression will b...
[ "FlattenExpr", "takes", "an", "expression", "that", "may", "have", "been", "generated", "from", "PlatformStrings", "and", "returns", "its", "values", "in", "a", "flat", "sorted", "de", "-", "duplicated", "list", ".", "Comments", "are", "accumulated", "and", "d...
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/rule/expr.go#L118-L169
test
bazelbuild/bazel-gazelle
rule/expr.go
makePlatformStringsExpr
func makePlatformStringsExpr(ps platformStringsExprs) bzl.Expr { makeSelect := func(dict *bzl.DictExpr) bzl.Expr { return &bzl.CallExpr{ X: &bzl.Ident{Name: "select"}, List: []bzl.Expr{dict}, } } forceMultiline := func(e bzl.Expr) { switch e := e.(type) { case *bzl.ListExpr: e.ForceMultiLine = tr...
go
func makePlatformStringsExpr(ps platformStringsExprs) bzl.Expr { makeSelect := func(dict *bzl.DictExpr) bzl.Expr { return &bzl.CallExpr{ X: &bzl.Ident{Name: "select"}, List: []bzl.Expr{dict}, } } forceMultiline := func(e bzl.Expr) { switch e := e.(type) { case *bzl.ListExpr: e.ForceMultiLine = tr...
[ "func", "makePlatformStringsExpr", "(", "ps", "platformStringsExprs", ")", "bzl", ".", "Expr", "{", "makeSelect", ":=", "func", "(", "dict", "*", "bzl", ".", "DictExpr", ")", "bzl", ".", "Expr", "{", "return", "&", "bzl", ".", "CallExpr", "{", "X", ":", ...
// makePlatformStringsExpr constructs a single expression from the // sub-expressions in ps.
[ "makePlatformStringsExpr", "constructs", "a", "single", "expression", "from", "the", "sub", "-", "expressions", "in", "ps", "." ]
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/rule/expr.go#L307-L354
test
bazelbuild/bazel-gazelle
rule/platform.go
String
func (p Platform) String() string { switch { case p.OS != "" && p.Arch != "": return p.OS + "_" + p.Arch case p.OS != "": return p.OS case p.Arch != "": return p.Arch default: return "" } }
go
func (p Platform) String() string { switch { case p.OS != "" && p.Arch != "": return p.OS + "_" + p.Arch case p.OS != "": return p.OS case p.Arch != "": return p.Arch default: return "" } }
[ "func", "(", "p", "Platform", ")", "String", "(", ")", "string", "{", "switch", "{", "case", "p", ".", "OS", "!=", "\"\"", "&&", "p", ".", "Arch", "!=", "\"\"", ":", "return", "p", ".", "OS", "+", "\"_\"", "+", "p", ".", "Arch", "\n", "case", ...
// String returns OS, Arch, or "OS_Arch" if both are set. This must match // the names of config_setting rules in @io_bazel_rules_go//go/platform.
[ "String", "returns", "OS", "Arch", "or", "OS_Arch", "if", "both", "are", "set", ".", "This", "must", "match", "the", "names", "of", "config_setting", "rules", "in" ]
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/rule/platform.go#L30-L41
test
bazelbuild/bazel-gazelle
internal/wspace/finder.go
Find
func Find(dir string) (string, error) { dir, err := filepath.Abs(dir) if err != nil { return "", err } for { _, err = os.Stat(filepath.Join(dir, workspaceFile)) if err == nil { return dir, nil } if !os.IsNotExist(err) { return "", err } if strings.HasSuffix(dir, string(os.PathSeparator)) { // s...
go
func Find(dir string) (string, error) { dir, err := filepath.Abs(dir) if err != nil { return "", err } for { _, err = os.Stat(filepath.Join(dir, workspaceFile)) if err == nil { return dir, nil } if !os.IsNotExist(err) { return "", err } if strings.HasSuffix(dir, string(os.PathSeparator)) { // s...
[ "func", "Find", "(", "dir", "string", ")", "(", "string", ",", "error", ")", "{", "dir", ",", "err", ":=", "filepath", ".", "Abs", "(", "dir", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"\"", ",", "err", "\n", "}", "\n", "for", "{", ...
// Find searches from the given dir and up for the WORKSPACE file // returning the directory containing it, or an error if none found in the tree.
[ "Find", "searches", "from", "the", "given", "dir", "and", "up", "for", "the", "WORKSPACE", "file", "returning", "the", "directory", "containing", "it", "or", "an", "error", "if", "none", "found", "in", "the", "tree", "." ]
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/internal/wspace/finder.go#L26-L45
test
bazelbuild/bazel-gazelle
cmd/autogazelle/autogazelle.go
runGazelle
func runGazelle(mode mode, dirs []string) error { if mode == fastMode && len(dirs) == 0 { return nil } args := []string{os.Getenv("BAZEL_REAL"), "run", *gazelleLabel, "--", "-args"} args = append(args, "-index=false") if mode == fastMode { args = append(args, "-r=false") args = append(args, dirs...) } cm...
go
func runGazelle(mode mode, dirs []string) error { if mode == fastMode && len(dirs) == 0 { return nil } args := []string{os.Getenv("BAZEL_REAL"), "run", *gazelleLabel, "--", "-args"} args = append(args, "-index=false") if mode == fastMode { args = append(args, "-r=false") args = append(args, dirs...) } cm...
[ "func", "runGazelle", "(", "mode", "mode", ",", "dirs", "[", "]", "string", ")", "error", "{", "if", "mode", "==", "fastMode", "&&", "len", "(", "dirs", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "args", ":=", "[", "]", "string", "{",...
// runGazelle invokes gazelle with "bazel run". In fullMode, gazelle will // run in the entire repository. In fastMode, gazelle will only run // in the given directories.
[ "runGazelle", "invokes", "gazelle", "with", "bazel", "run", ".", "In", "fullMode", "gazelle", "will", "run", "in", "the", "entire", "repository", ".", "In", "fastMode", "gazelle", "will", "only", "run", "in", "the", "given", "directories", "." ]
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/cmd/autogazelle/autogazelle.go#L99-L116
test
bazelbuild/bazel-gazelle
cmd/autogazelle/autogazelle.go
restoreBuildFilesInRepo
func restoreBuildFilesInRepo() { err := filepath.Walk(".", func(path string, info os.FileInfo, err error) error { if err != nil { log.Print(err) return nil } restoreBuildFilesInDir(path) return nil }) if err != nil { log.Print(err) } }
go
func restoreBuildFilesInRepo() { err := filepath.Walk(".", func(path string, info os.FileInfo, err error) error { if err != nil { log.Print(err) return nil } restoreBuildFilesInDir(path) return nil }) if err != nil { log.Print(err) } }
[ "func", "restoreBuildFilesInRepo", "(", ")", "{", "err", ":=", "filepath", ".", "Walk", "(", "\".\"", ",", "func", "(", "path", "string", ",", "info", "os", ".", "FileInfo", ",", "err", "error", ")", "error", "{", "if", "err", "!=", "nil", "{", "log"...
// restoreBuildFilesInRepo copies BUILD.in and BUILD.bazel.in files and // copies them to BUILD and BUILD.bazel.
[ "restoreBuildFilesInRepo", "copies", "BUILD", ".", "in", "and", "BUILD", ".", "bazel", ".", "in", "files", "and", "copies", "them", "to", "BUILD", "and", "BUILD", ".", "bazel", "." ]
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/cmd/autogazelle/autogazelle.go#L120-L132
test
bazelbuild/bazel-gazelle
merger/fix.go
FixLoads
func FixLoads(f *rule.File, knownLoads []rule.LoadInfo) { knownFiles := make(map[string]bool) knownKinds := make(map[string]string) for _, l := range knownLoads { knownFiles[l.Name] = true for _, k := range l.Symbols { knownKinds[k] = l.Name } } // Sync the file. We need File.Loads and File.Rules to cont...
go
func FixLoads(f *rule.File, knownLoads []rule.LoadInfo) { knownFiles := make(map[string]bool) knownKinds := make(map[string]string) for _, l := range knownLoads { knownFiles[l.Name] = true for _, k := range l.Symbols { knownKinds[k] = l.Name } } // Sync the file. We need File.Loads and File.Rules to cont...
[ "func", "FixLoads", "(", "f", "*", "rule", ".", "File", ",", "knownLoads", "[", "]", "rule", ".", "LoadInfo", ")", "{", "knownFiles", ":=", "make", "(", "map", "[", "string", "]", "bool", ")", "\n", "knownKinds", ":=", "make", "(", "map", "[", "str...
// FixLoads removes loads of unused go rules and adds loads of newly used rules. // This should be called after FixFile and MergeFile, since symbols // may be introduced that aren't loaded. // // This function calls File.Sync before processing loads.
[ "FixLoads", "removes", "loads", "of", "unused", "go", "rules", "and", "adds", "loads", "of", "newly", "used", "rules", ".", "This", "should", "be", "called", "after", "FixFile", "and", "MergeFile", "since", "symbols", "may", "be", "introduced", "that", "aren...
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/merger/fix.go#L30-L98
test
bazelbuild/bazel-gazelle
merger/fix.go
fixLoad
func fixLoad(load *rule.Load, file string, kinds map[string]bool, knownKinds map[string]string) *rule.Load { if load == nil { if len(kinds) == 0 { return nil } load = rule.NewLoad(file) } for k := range kinds { load.Add(k) } for _, k := range load.Symbols() { if knownKinds[k] != "" && !kinds[k] { ...
go
func fixLoad(load *rule.Load, file string, kinds map[string]bool, knownKinds map[string]string) *rule.Load { if load == nil { if len(kinds) == 0 { return nil } load = rule.NewLoad(file) } for k := range kinds { load.Add(k) } for _, k := range load.Symbols() { if knownKinds[k] != "" && !kinds[k] { ...
[ "func", "fixLoad", "(", "load", "*", "rule", ".", "Load", ",", "file", "string", ",", "kinds", "map", "[", "string", "]", "bool", ",", "knownKinds", "map", "[", "string", "]", "string", ")", "*", "rule", ".", "Load", "{", "if", "load", "==", "nil",...
// fixLoad updates a load statement with the given symbols. If load is nil, // a new load may be created and returned. Symbols in kinds will be added // to the load if they're not already present. Known symbols not in kinds // will be removed if present. Other symbols will be preserved. If load is // empty, nil is retu...
[ "fixLoad", "updates", "a", "load", "statement", "with", "the", "given", "symbols", ".", "If", "load", "is", "nil", "a", "new", "load", "may", "be", "created", "and", "returned", ".", "Symbols", "in", "kinds", "will", "be", "added", "to", "the", "load", ...
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/merger/fix.go#L105-L122
test
bazelbuild/bazel-gazelle
merger/fix.go
newLoadIndex
func newLoadIndex(f *rule.File, after []string) int { if len(after) == 0 { return 0 } index := 0 for _, r := range f.Rules { for _, a := range after { if r.Kind() == a && r.Index() >= index { index = r.Index() + 1 } } } return index }
go
func newLoadIndex(f *rule.File, after []string) int { if len(after) == 0 { return 0 } index := 0 for _, r := range f.Rules { for _, a := range after { if r.Kind() == a && r.Index() >= index { index = r.Index() + 1 } } } return index }
[ "func", "newLoadIndex", "(", "f", "*", "rule", ".", "File", ",", "after", "[", "]", "string", ")", "int", "{", "if", "len", "(", "after", ")", "==", "0", "{", "return", "0", "\n", "}", "\n", "index", ":=", "0", "\n", "for", "_", ",", "r", ":=...
// newLoadIndex returns the index in stmts where a new load statement should // be inserted. after is a list of function names that the load should not // be inserted before.
[ "newLoadIndex", "returns", "the", "index", "in", "stmts", "where", "a", "new", "load", "statement", "should", "be", "inserted", ".", "after", "is", "a", "list", "of", "function", "names", "that", "the", "load", "should", "not", "be", "inserted", "before", ...
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/merger/fix.go#L127-L140
test
bazelbuild/bazel-gazelle
merger/fix.go
removeLegacyGoRepository
func removeLegacyGoRepository(f *rule.File) { for _, l := range f.Loads { if l.Name() == "@io_bazel_rules_go//go:def.bzl" { l.Remove("go_repository") if l.IsEmpty() { l.Delete() } } } }
go
func removeLegacyGoRepository(f *rule.File) { for _, l := range f.Loads { if l.Name() == "@io_bazel_rules_go//go:def.bzl" { l.Remove("go_repository") if l.IsEmpty() { l.Delete() } } } }
[ "func", "removeLegacyGoRepository", "(", "f", "*", "rule", ".", "File", ")", "{", "for", "_", ",", "l", ":=", "range", "f", ".", "Loads", "{", "if", "l", ".", "Name", "(", ")", "==", "\"@io_bazel_rules_go//go:def.bzl\"", "{", "l", ".", "Remove", "(", ...
// removeLegacyGoRepository removes loads of go_repository from // @io_bazel_rules_go. FixLoads should be called after this; it will load from // @bazel_gazelle.
[ "removeLegacyGoRepository", "removes", "loads", "of", "go_repository", "from" ]
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/merger/fix.go#L190-L199
test
bazelbuild/bazel-gazelle
internal/version/version.go
Compare
func (x Version) Compare(y Version) int { n := len(x) if len(y) < n { n = len(y) } for i := 0; i < n; i++ { cmp := x[i] - y[i] if cmp != 0 { return cmp } } return len(x) - len(y) }
go
func (x Version) Compare(y Version) int { n := len(x) if len(y) < n { n = len(y) } for i := 0; i < n; i++ { cmp := x[i] - y[i] if cmp != 0 { return cmp } } return len(x) - len(y) }
[ "func", "(", "x", "Version", ")", "Compare", "(", "y", "Version", ")", "int", "{", "n", ":=", "len", "(", "x", ")", "\n", "if", "len", "(", "y", ")", "<", "n", "{", "n", "=", "len", "(", "y", ")", "\n", "}", "\n", "for", "i", ":=", "0", ...
// Compare returns an integer comparing two versions lexicographically.
[ "Compare", "returns", "an", "integer", "comparing", "two", "versions", "lexicographically", "." ]
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/internal/version/version.go#L37-L49
test
bazelbuild/bazel-gazelle
internal/version/version.go
ParseVersion
func ParseVersion(vs string) (Version, error) { i := strings.IndexByte(vs, '-') if i >= 0 { vs = vs[:i] } cstrs := strings.Split(vs, ".") v := make(Version, len(cstrs)) for i, cstr := range cstrs { cn, err := strconv.Atoi(cstr) if err != nil { return nil, fmt.Errorf("could not parse version string: %q is...
go
func ParseVersion(vs string) (Version, error) { i := strings.IndexByte(vs, '-') if i >= 0 { vs = vs[:i] } cstrs := strings.Split(vs, ".") v := make(Version, len(cstrs)) for i, cstr := range cstrs { cn, err := strconv.Atoi(cstr) if err != nil { return nil, fmt.Errorf("could not parse version string: %q is...
[ "func", "ParseVersion", "(", "vs", "string", ")", "(", "Version", ",", "error", ")", "{", "i", ":=", "strings", ".", "IndexByte", "(", "vs", ",", "'-'", ")", "\n", "if", "i", ">=", "0", "{", "vs", "=", "vs", "[", ":", "i", "]", "\n", "}", "\n...
// ParseVersion parses a version of the form "12.34.56-abcd". Non-negative // integer components are separated by dots. An arbitrary suffix may appear // after '-', which is ignored.
[ "ParseVersion", "parses", "a", "version", "of", "the", "form", "12", ".", "34", ".", "56", "-", "abcd", ".", "Non", "-", "negative", "integer", "components", "are", "separated", "by", "dots", ".", "An", "arbitrary", "suffix", "may", "appear", "after", "-...
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/internal/version/version.go#L54-L72
test
bazelbuild/bazel-gazelle
rule/rule.go
EmptyFile
func EmptyFile(path, pkg string) *File { return &File{ File: &bzl.File{Path: path, Type: bzl.TypeBuild}, Path: path, Pkg: pkg, } }
go
func EmptyFile(path, pkg string) *File { return &File{ File: &bzl.File{Path: path, Type: bzl.TypeBuild}, Path: path, Pkg: pkg, } }
[ "func", "EmptyFile", "(", "path", ",", "pkg", "string", ")", "*", "File", "{", "return", "&", "File", "{", "File", ":", "&", "bzl", ".", "File", "{", "Path", ":", "path", ",", "Type", ":", "bzl", ".", "TypeBuild", "}", ",", "Path", ":", "path", ...
// EmptyFile creates a File wrapped around an empty syntax tree.
[ "EmptyFile", "creates", "a", "File", "wrapped", "around", "an", "empty", "syntax", "tree", "." ]
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/rule/rule.go#L73-L79
test
bazelbuild/bazel-gazelle
rule/rule.go
LoadWorkspaceFile
func LoadWorkspaceFile(path, pkg string) (*File, error) { data, err := ioutil.ReadFile(path) if err != nil { return nil, err } return LoadWorkspaceData(path, pkg, data) }
go
func LoadWorkspaceFile(path, pkg string) (*File, error) { data, err := ioutil.ReadFile(path) if err != nil { return nil, err } return LoadWorkspaceData(path, pkg, data) }
[ "func", "LoadWorkspaceFile", "(", "path", ",", "pkg", "string", ")", "(", "*", "File", ",", "error", ")", "{", "data", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", ...
// LoadWorkspaceFile is similar to LoadFile but parses the file as a WORKSPACE // file.
[ "LoadWorkspaceFile", "is", "similar", "to", "LoadFile", "but", "parses", "the", "file", "as", "a", "WORKSPACE", "file", "." ]
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/rule/rule.go#L97-L103
test
bazelbuild/bazel-gazelle
rule/rule.go
LoadMacroFile
func LoadMacroFile(path, pkg, defName string) (*File, error) { data, err := ioutil.ReadFile(path) if err != nil { return nil, err } return LoadMacroData(path, pkg, defName, data) }
go
func LoadMacroFile(path, pkg, defName string) (*File, error) { data, err := ioutil.ReadFile(path) if err != nil { return nil, err } return LoadMacroData(path, pkg, defName, data) }
[ "func", "LoadMacroFile", "(", "path", ",", "pkg", ",", "defName", "string", ")", "(", "*", "File", ",", "error", ")", "{", "data", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ...
// LoadMacroFile loads a bzl file from disk, parses it, then scans for the load // statements and the rules called from the given Starlark function. If there is // no matching function name, then a new function with that name will be created. // The function's syntax tree will be returned within File and can be modifie...
[ "LoadMacroFile", "loads", "a", "bzl", "file", "from", "disk", "parses", "it", "then", "scans", "for", "the", "load", "statements", "and", "the", "rules", "called", "from", "the", "given", "Starlark", "function", ".", "If", "there", "is", "no", "matching", ...
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/rule/rule.go#L110-L116
test
bazelbuild/bazel-gazelle
rule/rule.go
EmptyMacroFile
func EmptyMacroFile(path, pkg, defName string) (*File, error) { _, err := os.Create(path) if err != nil { return nil, err } return LoadMacroData(path, pkg, defName, nil) }
go
func EmptyMacroFile(path, pkg, defName string) (*File, error) { _, err := os.Create(path) if err != nil { return nil, err } return LoadMacroData(path, pkg, defName, nil) }
[ "func", "EmptyMacroFile", "(", "path", ",", "pkg", ",", "defName", "string", ")", "(", "*", "File", ",", "error", ")", "{", "_", ",", "err", ":=", "os", ".", "Create", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", ...
// EmptyMacroFile creates a bzl file at the given path and within the file creates // a Starlark function with the provided name. The function can then be modified // by Sync and Save calls.
[ "EmptyMacroFile", "creates", "a", "bzl", "file", "at", "the", "given", "path", "and", "within", "the", "file", "creates", "a", "Starlark", "function", "with", "the", "provided", "name", ".", "The", "function", "can", "then", "be", "modified", "by", "Sync", ...
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/rule/rule.go#L121-L127
test
bazelbuild/bazel-gazelle
rule/rule.go
LoadData
func LoadData(path, pkg string, data []byte) (*File, error) { ast, err := bzl.ParseBuild(path, data) if err != nil { return nil, err } return ScanAST(pkg, ast), nil }
go
func LoadData(path, pkg string, data []byte) (*File, error) { ast, err := bzl.ParseBuild(path, data) if err != nil { return nil, err } return ScanAST(pkg, ast), nil }
[ "func", "LoadData", "(", "path", ",", "pkg", "string", ",", "data", "[", "]", "byte", ")", "(", "*", "File", ",", "error", ")", "{", "ast", ",", "err", ":=", "bzl", ".", "ParseBuild", "(", "path", ",", "data", ")", "\n", "if", "err", "!=", "nil...
// LoadData parses a build file from a byte slice and scans it for rules and // load statements. The syntax tree within the returned File will be modified // by editing methods.
[ "LoadData", "parses", "a", "build", "file", "from", "a", "byte", "slice", "and", "scans", "it", "for", "rules", "and", "load", "statements", ".", "The", "syntax", "tree", "within", "the", "returned", "File", "will", "be", "modified", "by", "editing", "meth...
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/rule/rule.go#L132-L138
test
bazelbuild/bazel-gazelle
rule/rule.go
LoadWorkspaceData
func LoadWorkspaceData(path, pkg string, data []byte) (*File, error) { ast, err := bzl.ParseWorkspace(path, data) if err != nil { return nil, err } return ScanAST(pkg, ast), nil }
go
func LoadWorkspaceData(path, pkg string, data []byte) (*File, error) { ast, err := bzl.ParseWorkspace(path, data) if err != nil { return nil, err } return ScanAST(pkg, ast), nil }
[ "func", "LoadWorkspaceData", "(", "path", ",", "pkg", "string", ",", "data", "[", "]", "byte", ")", "(", "*", "File", ",", "error", ")", "{", "ast", ",", "err", ":=", "bzl", ".", "ParseWorkspace", "(", "path", ",", "data", ")", "\n", "if", "err", ...
// LoadWorkspaceData is similar to LoadData but parses the data as a // WORKSPACE file.
[ "LoadWorkspaceData", "is", "similar", "to", "LoadData", "but", "parses", "the", "data", "as", "a", "WORKSPACE", "file", "." ]
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/rule/rule.go#L142-L148
test
bazelbuild/bazel-gazelle
rule/rule.go
LoadMacroData
func LoadMacroData(path, pkg, defName string, data []byte) (*File, error) { ast, err := bzl.ParseBzl(path, data) if err != nil { return nil, err } return ScanASTBody(pkg, defName, ast), nil }
go
func LoadMacroData(path, pkg, defName string, data []byte) (*File, error) { ast, err := bzl.ParseBzl(path, data) if err != nil { return nil, err } return ScanASTBody(pkg, defName, ast), nil }
[ "func", "LoadMacroData", "(", "path", ",", "pkg", ",", "defName", "string", ",", "data", "[", "]", "byte", ")", "(", "*", "File", ",", "error", ")", "{", "ast", ",", "err", ":=", "bzl", ".", "ParseBzl", "(", "path", ",", "data", ")", "\n", "if", ...
// LoadMacroData parses a bzl file from a byte slice and scans for the load // statements and the rules called from the given Starlark function. If there is // no matching function name, then a new function will be created, and added to the // File the next time Sync is called. The function's syntax tree will be return...
[ "LoadMacroData", "parses", "a", "bzl", "file", "from", "a", "byte", "slice", "and", "scans", "for", "the", "load", "statements", "and", "the", "rules", "called", "from", "the", "given", "Starlark", "function", ".", "If", "there", "is", "no", "matching", "f...
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/rule/rule.go#L155-L161
test
bazelbuild/bazel-gazelle
rule/rule.go
ScanAST
func ScanAST(pkg string, bzlFile *bzl.File) *File { return ScanASTBody(pkg, "", bzlFile) }
go
func ScanAST(pkg string, bzlFile *bzl.File) *File { return ScanASTBody(pkg, "", bzlFile) }
[ "func", "ScanAST", "(", "pkg", "string", ",", "bzlFile", "*", "bzl", ".", "File", ")", "*", "File", "{", "return", "ScanASTBody", "(", "pkg", ",", "\"\"", ",", "bzlFile", ")", "\n", "}" ]
// ScanAST creates a File wrapped around the given syntax tree. This tree // will be modified by editing methods.
[ "ScanAST", "creates", "a", "File", "wrapped", "around", "the", "given", "syntax", "tree", ".", "This", "tree", "will", "be", "modified", "by", "editing", "methods", "." ]
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/rule/rule.go#L165-L167
test
bazelbuild/bazel-gazelle
rule/rule.go
ScanASTBody
func ScanASTBody(pkg, defName string, bzlFile *bzl.File) *File { f := &File{ File: bzlFile, Pkg: pkg, Path: bzlFile.Path, } var defStmt *bzl.DefStmt f.Rules, f.Loads, defStmt = scanExprs(defName, bzlFile.Stmt) if defStmt != nil { f.Rules, _, _ = scanExprs("", defStmt.Body) f.function = &function{ stm...
go
func ScanASTBody(pkg, defName string, bzlFile *bzl.File) *File { f := &File{ File: bzlFile, Pkg: pkg, Path: bzlFile.Path, } var defStmt *bzl.DefStmt f.Rules, f.Loads, defStmt = scanExprs(defName, bzlFile.Stmt) if defStmt != nil { f.Rules, _, _ = scanExprs("", defStmt.Body) f.function = &function{ stm...
[ "func", "ScanASTBody", "(", "pkg", ",", "defName", "string", ",", "bzlFile", "*", "bzl", ".", "File", ")", "*", "File", "{", "f", ":=", "&", "File", "{", "File", ":", "bzlFile", ",", "Pkg", ":", "pkg", ",", "Path", ":", "bzlFile", ".", "Path", ",...
// ScanASTBody creates a File wrapped around the given syntax tree. It will also // scan the AST for a function matching the given defName, and if the function // does not exist it will create a new one and mark it to be added to the File // the next time Sync is called.
[ "ScanASTBody", "creates", "a", "File", "wrapped", "around", "the", "given", "syntax", "tree", ".", "It", "will", "also", "scan", "the", "AST", "for", "a", "function", "matching", "the", "given", "defName", "and", "if", "the", "function", "does", "not", "ex...
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/rule/rule.go#L178-L205
test
bazelbuild/bazel-gazelle
rule/rule.go
MatchBuildFileName
func MatchBuildFileName(dir string, names []string, files []os.FileInfo) string { for _, name := range names { for _, fi := range files { if fi.Name() == name && !fi.IsDir() { return filepath.Join(dir, name) } } } return "" }
go
func MatchBuildFileName(dir string, names []string, files []os.FileInfo) string { for _, name := range names { for _, fi := range files { if fi.Name() == name && !fi.IsDir() { return filepath.Join(dir, name) } } } return "" }
[ "func", "MatchBuildFileName", "(", "dir", "string", ",", "names", "[", "]", "string", ",", "files", "[", "]", "os", ".", "FileInfo", ")", "string", "{", "for", "_", ",", "name", ":=", "range", "names", "{", "for", "_", ",", "fi", ":=", "range", "fi...
// MatchBuildFileName looks for a file in files that has a name from names. // If there is at least one matching file, a path will be returned by joining // dir and the first matching name. If there are no matching files, the // empty string is returned.
[ "MatchBuildFileName", "looks", "for", "a", "file", "in", "files", "that", "has", "a", "name", "from", "names", ".", "If", "there", "is", "at", "least", "one", "matching", "file", "a", "path", "will", "be", "returned", "by", "joining", "dir", "and", "the"...
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/rule/rule.go#L230-L239
test
bazelbuild/bazel-gazelle
rule/rule.go
SyncMacroFile
func (f *File) SyncMacroFile(from *File) { fromFunc := *from.function.stmt _, _, toFunc := scanExprs(from.function.stmt.Name, f.File.Stmt) if toFunc != nil { *toFunc = fromFunc } else { f.File.Stmt = append(f.File.Stmt, &fromFunc) } }
go
func (f *File) SyncMacroFile(from *File) { fromFunc := *from.function.stmt _, _, toFunc := scanExprs(from.function.stmt.Name, f.File.Stmt) if toFunc != nil { *toFunc = fromFunc } else { f.File.Stmt = append(f.File.Stmt, &fromFunc) } }
[ "func", "(", "f", "*", "File", ")", "SyncMacroFile", "(", "from", "*", "File", ")", "{", "fromFunc", ":=", "*", "from", ".", "function", ".", "stmt", "\n", "_", ",", "_", ",", "toFunc", ":=", "scanExprs", "(", "from", ".", "function", ".", "stmt", ...
// SyncMacroFile syncs the file's syntax tree with another file's. This is // useful for keeping multiple macro definitions from the same .bzl file in sync.
[ "SyncMacroFile", "syncs", "the", "file", "s", "syntax", "tree", "with", "another", "file", "s", ".", "This", "is", "useful", "for", "keeping", "multiple", "macro", "definitions", "from", "the", "same", ".", "bzl", "file", "in", "sync", "." ]
e3805aaca69a9deb949b47bfc45b9b1870712f4f
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/rule/rule.go#L243-L251
test