_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q178400 | New | test | func (t ChecksumType) New() Checksum {
s := t.pool().Get().(Checksum)
s.Reset()
return s
} | go | {
"resource": ""
} |
q178401 | parseTemplates | test | func parseTemplates(skipTChannel bool, templateFiles []string) ([]*Template, error) {
var templates []*Template
if !skipTChannel {
templates = append(templates, &Template{
name: "tchan",
template: template.Must(parseTemplate(tchannelTmpl)),
})
}
for _, f := range templateFiles {
t, err := parseTem... | go | {
"resource": ""
} |
q178402 | NewStringSliceFlag | test | func NewStringSliceFlag(name string, usage string) *[]string {
var ss stringSliceFlag
flag.Var(&ss, name, usage)
return (*[]string)(&ss)
} | go | {
"resource": ""
} |
q178403 | withStateFuncs | test | func (t *Template) withStateFuncs(td TemplateData) *template.Template {
return t.template.Funcs(map[string]interface{}{
"goType": td.global.goType,
})
} | go | {
"resource": ""
} |
q178404 | IntrospectOthers | test | func (ch *Channel) IntrospectOthers(opts *IntrospectionOptions) map[string][]ChannelInfo {
if !opts.IncludeOtherChannels {
return nil
}
channelMap.Lock()
defer channelMap.Unlock()
states := make(map[string][]ChannelInfo)
for svc, channels := range channelMap.existing {
channelInfos := make([]ChannelInfo, 0,... | go | {
"resource": ""
} |
q178405 | ReportInfo | test | func (ch *Channel) ReportInfo(opts *IntrospectionOptions) ChannelInfo {
return ChannelInfo{
ID: ch.chID,
CreatedStack: ch.createdStack,
LocalPeer: ch.PeerInfo(),
}
} | go | {
"resource": ""
} |
q178406 | IntrospectState | test | func (l *RootPeerList) IntrospectState(opts *IntrospectionOptions) map[string]PeerRuntimeState {
return fromPeerList(l, opts)
} | go | {
"resource": ""
} |
q178407 | IntrospectState | test | func (subChMap *subChannelMap) IntrospectState(opts *IntrospectionOptions) map[string]SubChannelRuntimeState {
m := make(map[string]SubChannelRuntimeState)
subChMap.RLock()
for k, sc := range subChMap.subchannels {
state := SubChannelRuntimeState{
Service: k,
Isolated: sc.Isolated(),
}
if state.Isolated... | go | {
"resource": ""
} |
q178408 | IntrospectState | test | func (p *Peer) IntrospectState(opts *IntrospectionOptions) PeerRuntimeState {
p.RLock()
defer p.RUnlock()
return PeerRuntimeState{
HostPort: p.hostPort,
InboundConnections: getConnectionRuntimeState(p.inboundConnections, opts),
OutboundConnections: getConnectionRuntimeState(p.outboundConnections, ... | go | {
"resource": ""
} |
q178409 | IntrospectState | test | func (c *Connection) IntrospectState(opts *IntrospectionOptions) ConnectionRuntimeState {
c.stateMut.RLock()
defer c.stateMut.RUnlock()
// TODO(prashantv): Add total number of health checks, and health check options.
state := ConnectionRuntimeState{
ID: c.connID,
ConnectionState: c.state.String(... | go | {
"resource": ""
} |
q178410 | IntrospectState | test | func (r *Relayer) IntrospectState(opts *IntrospectionOptions) RelayerRuntimeState {
count := r.inbound.Count() + r.outbound.Count()
return RelayerRuntimeState{
Count: count,
InboundItems: r.inbound.IntrospectState(opts, "inbound"),
OutboundItems: r.outbound.IntrospectState(opts, "outbound"),
MaxTimeo... | go | {
"resource": ""
} |
q178411 | IntrospectState | test | func (ri *relayItems) IntrospectState(opts *IntrospectionOptions, name string) RelayItemSetState {
ri.RLock()
defer ri.RUnlock()
setState := RelayItemSetState{
Name: name,
Count: ri.Count(),
}
if opts.IncludeExchanges {
setState.Items = make(map[string]RelayItemState, len(ri.items))
for k, v := range ri.... | go | {
"resource": ""
} |
q178412 | IntrospectState | test | func (mexset *messageExchangeSet) IntrospectState(opts *IntrospectionOptions) ExchangeSetRuntimeState {
mexset.RLock()
setState := ExchangeSetRuntimeState{
Name: mexset.name,
Count: len(mexset.exchanges),
}
if opts.IncludeExchanges {
setState.Exchanges = make(map[string]ExchangeRuntimeState, len(mexset.exch... | go | {
"resource": ""
} |
q178413 | NewContext | test | func NewContext(timeout time.Duration) (Context, context.CancelFunc) {
ctx, cancel := tchannel.NewContext(timeout)
return tchannel.WrapWithHeaders(ctx, nil), cancel
} | go | {
"resource": ""
} |
q178414 | WriteResponse | test | 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 | {
"resource": ""
} |
q178415 | Wrap | test | 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 | {
"resource": ""
} |
q178416 | initFromOpenTracing | test | func (s *injectableSpan) initFromOpenTracing(span opentracing.Span) error {
return span.Tracer().Inject(span.Context(), zipkinSpanFormat, s)
} | go | {
"resource": ""
} |
q178417 | startOutboundSpan | test | 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 | {
"resource": ""
} |
q178418 | intToIP4 | test | 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 | {
"resource": ""
} |
q178419 | servicePeerToHostPort | test | 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 | {
"resource": ""
} |
q178420 | NewStatsdReporter | test | 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 | {
"resource": ""
} |
q178421 | UnmarshalText | test | 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 | {
"resource": ""
} |
q178422 | Push | test | func (ph *peerHeap) Push(x interface{}) {
n := len(ph.peerScores)
item := x.(*peerScore)
item.index = n
ph.peerScores = append(ph.peerScores, item)
} | go | {
"resource": ""
} |
q178423 | Pop | test | 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 | {
"resource": ""
} |
q178424 | updatePeer | test | func (ph *peerHeap) updatePeer(peerScore *peerScore) {
heap.Fix(ph, peerScore.index)
} | go | {
"resource": ""
} |
q178425 | removePeer | test | func (ph *peerHeap) removePeer(peerScore *peerScore) {
heap.Remove(ph, peerScore.index)
} | go | {
"resource": ""
} |
q178426 | pushPeer | test | 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 | {
"resource": ""
} |
q178427 | addPeer | test | 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 | {
"resource": ""
} |
q178428 | NewClient | test | 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 | {
"resource": ""
} |
q178429 | Add | test | 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 | {
"resource": ""
} |
q178430 | Get | test | func (l *RootPeerList) Get(hostPort string) (*Peer, bool) {
l.RLock()
p, ok := l.peersByHostPort[hostPort]
l.RUnlock()
return p, ok
} | go | {
"resource": ""
} |
q178431 | WithTimeout | test | func WithTimeout(timeout time.Duration) Option {
return func(opts *options) {
opts.timeout = timeout
}
} | go | {
"resource": ""
} |
q178432 | Methods | test | 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 | {
"resource": ""
} |
q178433 | InheritedMethods | test | 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 | {
"resource": ""
} |
q178434 | Arguments | test | func (m *Method) Arguments() []*Field {
var args []*Field
for _, f := range m.Method.Arguments {
args = append(args, &Field{f, m.state})
}
return args
} | go | {
"resource": ""
} |
q178435 | ArgList | test | func (m *Method) ArgList() string {
args := []string{"ctx " + contextType()}
for _, arg := range m.Arguments() {
args = append(args, arg.Declaration())
}
return strings.Join(args, ", ")
} | go | {
"resource": ""
} |
q178436 | CallList | test | 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 | {
"resource": ""
} |
q178437 | RetType | test | func (m *Method) RetType() string {
if !m.HasReturn() {
return "error"
}
return fmt.Sprintf("(%v, %v)", m.state.goType(m.Method.ReturnType), "error")
} | go | {
"resource": ""
} |
q178438 | WrapResult | test | 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 | {
"resource": ""
} |
q178439 | ReturnWith | test | func (m *Method) ReturnWith(respName string, errName string) string {
if !m.HasReturn() {
return errName
}
return fmt.Sprintf("%v, %v", respName, errName)
} | go | {
"resource": ""
} |
q178440 | Declaration | test | func (a *Field) Declaration() string {
return fmt.Sprintf("%s %s", a.Name(), a.ArgType())
} | go | {
"resource": ""
} |
q178441 | startIdleSweep | test | func startIdleSweep(ch *Channel, opts *ChannelOptions) *idleSweep {
is := &idleSweep{
ch: ch,
maxIdleTime: opts.MaxIdleTime,
idleCheckInterval: opts.IdleCheckInterval,
}
is.start()
return is
} | go | {
"resource": ""
} |
q178442 | start | test | 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 | {
"resource": ""
} |
q178443 | Stop | test | func (is *idleSweep) Stop() {
if !is.started {
return
}
is.started = false
is.ch.log.Info("Stopping idle connections poller.")
close(is.stopCh)
} | go | {
"resource": ""
} |
q178444 | ResolveWithGoPath | test | 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 | {
"resource": ""
} |
q178445 | setExtends | test | 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 | {
"resource": ""
} |
q178446 | register | test | 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 | {
"resource": ""
} |
q178447 | NewClient | test | 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 | {
"resource": ""
} |
q178448 | ListenIP | test | func ListenIP() (net.IP, error) {
interfaces, err := net.Interfaces()
if err != nil {
return nil, err
}
return listenIP(interfaces)
} | go | {
"resource": ""
} |
q178449 | Close | test | 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 | {
"resource": ""
} |
q178450 | ReadArgsV2 | test | 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 | {
"resource": ""
} |
q178451 | WriteArgs | test | 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 | {
"resource": ""
} |
q178452 | Call | test | 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 | {
"resource": ""
} |
q178453 | CallSC | test | 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 | {
"resource": ""
} |
q178454 | CallV2 | test | 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 | {
"resource": ""
} |
q178455 | NewRealRelay | test | 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 | {
"resource": ""
} |
q178456 | NewServer | test | 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 | {
"resource": ""
} |
q178457 | RegisterHealthHandler | test | func (s *Server) RegisterHealthHandler(f HealthFunc) {
wrapped := func(ctx Context, r HealthRequest) (bool, string) {
return f(ctx)
}
s.metaHandler.setHandler(wrapped)
} | go | {
"resource": ""
} |
q178458 | Handle | test | 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 | {
"resource": ""
} |
q178459 | MetricsKey | test | 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 | {
"resource": ""
} |
q178460 | NewSystemError | test | func NewSystemError(code SystemErrCode, msg string, args ...interface{}) error {
return SystemError{code: code, msg: fmt.Sprintf(msg, args...)}
} | go | {
"resource": ""
} |
q178461 | NewWrappedSystemError | test | 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 | {
"resource": ""
} |
q178462 | Error | test | func (se SystemError) Error() string {
return fmt.Sprintf("tchannel error %v: %s", se.Code(), se.msg)
} | go | {
"resource": ""
} |
q178463 | GetContextError | test | func GetContextError(err error) error {
if err == context.DeadlineExceeded {
return ErrTimeout
}
if err == context.Canceled {
return ErrRequestCancelled
}
return err
} | go | {
"resource": ""
} |
q178464 | GetSystemErrorCode | test | func GetSystemErrorCode(err error) SystemErrCode {
if err == nil {
return ErrCodeInvalid
}
if se, ok := err.(SystemError); ok {
return se.Code()
}
return ErrCodeUnexpected
} | go | {
"resource": ""
} |
q178465 | ping | test | 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 | {
"resource": ""
} |
q178466 | handlePingRes | test | 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 | {
"resource": ""
} |
q178467 | handlePingReq | test | 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 | {
"resource": ""
} |
q178468 | SendSystemError | test | 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 | {
"resource": ""
} |
q178469 | connectionError | test | 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 | {
"resource": ""
} |
q178470 | withStateLock | test | func (c *Connection) withStateLock(f func() error) error {
c.stateMut.Lock()
err := f()
c.stateMut.Unlock()
return err
} | go | {
"resource": ""
} |
q178471 | withStateRLock | test | func (c *Connection) withStateRLock(f func() error) error {
c.stateMut.RLock()
err := f()
c.stateMut.RUnlock()
return err
} | go | {
"resource": ""
} |
q178472 | readFrames | test | 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 | {
"resource": ""
} |
q178473 | writeFrames | test | 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 | {
"resource": ""
} |
q178474 | hasPendingCalls | test | 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 | {
"resource": ""
} |
q178475 | checkExchanges | test | 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 | {
"resource": ""
} |
q178476 | closeNetwork | test | 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 | {
"resource": ""
} |
q178477 | getLastActivityTime | test | func (c *Connection) getLastActivityTime() time.Time {
return time.Unix(0, c.lastActivity.Load())
} | go | {
"resource": ""
} |
q178478 | Validate | test | func Validate(svc *parser.Service) error {
for _, m := range svc.Methods {
if err := validateMethod(svc, m); err != nil {
return err
}
}
return nil
} | go | {
"resource": ""
} |
q178479 | logFailedRegistrationRetry | test | 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 | {
"resource": ""
} |
q178480 | initialAdvertise | test | 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 | {
"resource": ""
} |
q178481 | Service | test | func (f lazyCallReq) Service() []byte {
l := f.Payload[_serviceLenIndex]
return f.Payload[_serviceNameIndex : _serviceNameIndex+l]
} | go | {
"resource": ""
} |
q178482 | TTL | test | func (f lazyCallReq) TTL() time.Duration {
ttl := binary.BigEndian.Uint32(f.Payload[_ttlIndex : _ttlIndex+_ttlLen])
return time.Duration(ttl) * time.Millisecond
} | go | {
"resource": ""
} |
q178483 | SetTTL | test | func (f lazyCallReq) SetTTL(d time.Duration) {
ttl := uint32(d / time.Millisecond)
binary.BigEndian.PutUint32(f.Payload[_ttlIndex:_ttlIndex+_ttlLen], ttl)
} | go | {
"resource": ""
} |
q178484 | finishesCall | test | 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 | {
"resource": ""
} |
q178485 | Flat | test | 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 | {
"resource": ""
} |
q178486 | Map | test | 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 | {
"resource": ""
} |
q178487 | MapSlice | test | 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 | {
"resource": ""
} |
q178488 | GetProtoConfig | test | func GetProtoConfig(c *config.Config) *ProtoConfig {
pc := c.Exts[protoName]
if pc == nil {
return nil
}
return pc.(*ProtoConfig)
} | go | {
"resource": ""
} |
q178489 | MapExprStrings | test | 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 | {
"resource": ""
} |
q178490 | FlattenExpr | test | 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 | {
"resource": ""
} |
q178491 | makePlatformStringsExpr | test | 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 | {
"resource": ""
} |
q178492 | String | test | 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 | {
"resource": ""
} |
q178493 | Find | test | 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 | {
"resource": ""
} |
q178494 | runGazelle | test | 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 | {
"resource": ""
} |
q178495 | restoreBuildFilesInRepo | test | 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 | {
"resource": ""
} |
q178496 | FixLoads | test | 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 | {
"resource": ""
} |
q178497 | fixLoad | test | 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 | {
"resource": ""
} |
q178498 | newLoadIndex | test | 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 | {
"resource": ""
} |
q178499 | removeLegacyGoRepository | test | 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 | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.