id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c10400
// No remote address available. return nil, opError(opListen, err, &Addr{ ContextID: cid, Port: port, }, nil) } return l, nil }
c10401
{ return l.opError(opClose, l.l.Close()) }
c10402
l.opError(opSet, l.l.SetDeadline(t)) }
c10403
return opError(op, err, l.Addr(), nil) }
c10404
but we have a remote address we can return. return nil, opError(opDial, err, nil, &Addr{ ContextID: contextID, Port: port, }) } return c, nil }
c10405
c.opError(opClose, c.fd.Shutdown(shutRd)) }
c10406
c.opError(opClose, c.fd.Shutdown(shutWr)) }
c10407
} return &rawConn{ rc: rc, local: c.local, remote: c.remote, }, nil }
c10408
opError(op, err, c.local, c.remote) }
c10409
rc.opError(opRawControl, rc.rc.Control(fn)) }
c10410
return rc.opError(opRawRead, rc.rc.Read(fn)) }
c10411
return rc.opError(opRawWrite, rc.rc.Write(fn)) }
c10412
return opError(op, err, rc.local, rc.remote) }
c10413
host = fmt.Sprintf("reserved(%d)", a.ContextID) case Host: host = fmt.Sprintf("host(%d)", a.ContextID) default: host = fmt.Sprintf("vm(%d)", a.ContextID) } return fmt.Sprintf("%s:%d", host, a.Port) }
c10414
fmt.Sprintf("%s:%s", a.Network(), a.String()) }
c10415
// To rectify the differences, net.TCPConn uses an error with this text // from internal/poll for the backing file already being closed. err = errors.New("use of closed network connection") default: // Nothing to do, return this directly. } // Determine source and addr using the rules defined by net.OpErro...
c10416
err } savm := sa.(*unix.SockaddrVM) remote := &Addr{ ContextID: savm.CID, Port: savm.Port, } return newConn(cfd, l.addr, remote) }
c10417
return nil, err } return listenLinux(lfd, cid, port) }
c10418
Note: if any calls fail after this point, lfd.Close should be invoked // for cleanup because the socket is now non-blocking. if err := lfd.SetNonblocking("vsock-listen"); err != nil { return nil, err } lsavm := lsa.(*unix.SockaddrVM) addr := &Addr{ ContextID: lsavm.CID, Port: lsavm.Port, } return &...
c10419
return nil, err } return &sysListenFD{ fd: fd, }, nil }
c10420
// Create a non-blocking connFD which will be used to implement net.Conn. cfd := &sysConnFD{fd: newFD} return cfd, sa, nil }
c10421
return nil, err } return &sysConnFD{ fd: fd, }, nil }
c10422
panicf("vsock: isErrno called with unhandled error number parameter: %d", errno) return false } }
c10423
if err := cfd.SetNonblocking(local.fileName()); err != nil { return nil, err } return &Conn{ fd: cfd, local: local, remote: remote, }, nil }
c10424
return nil, err } return dialLinux(cfd, cid, port) }
c10425
err != nil { return nil, err } lsavm := lsa.(*unix.SockaddrVM) local := &Addr{ ContextID: lsavm.CID, Port: lsavm.Port, } remote := &Addr{ ContextID: cid, Port: port, } return newConn(cfd, local, remote) }
c10426
// Accept a single connection, and receive stream from that connection. c, err := vsutil.Accept(l, timeout) if err != nil { fatalf("failed to accept: %v", err) } _ = l.Close() defer c.Close() if timeout != 0 { if err := c.SetDeadline(time.Now().Add(timeout)); err != nil { fatalf("failed to set timeout:...
c10427
cid, port) // Dial a remote server and send a stream to that server. c, err := vsock.Dial(cid, port) if err != nil { fatalf("failed to dial: %v", err) } defer c.Close() logf("client: %s", c.LocalAddr()) logf("server: %s", c.RemoteAddr()) logf("sending data") if _, err := io.Copy(c, r); err != nil { fat...
c10428
implemented: %v", err) return true } return false }
c10429
buf := _pool.Get().(*buffer) written, err := io.CopyBuffer(dst, src, buf.b) _pool.Put(buf) return written, err }
c10430
} return Headers{ items: make(map[string]string, capacity), originalItems: make(map[string]string, capacity), } }
c10431
CanonicalizeHeaderKey(k)) delete(h.originalItems, k) }
c10432
:= h.items[CanonicalizeHeaderKey(k)] return v, ok }
c10433
v := range m { headers = headers.With(k, v) } return headers }
c10434
*listOptions) { options.capacity = capacity }) }
c10435
*listOptions) { options.seed = seed }) }
c10436
return nil } pl.lock.Lock() defer pl.lock.Unlock() if pl.shouldRetainPeers.Load() { return pl.updateInitialized(updates) } return pl.updateUninitialized(updates) }
c10437
unavailablePeers := pl.removeAllUnavailablePeers(pl.unavailablePeers) errs = pl.releaseAll(errs, unavailablePeers) pl.addToUninitialized(unavailablePeers) pl.shouldRetainPeers.Store(false) return errs }
c10438
err != nil { errs = multierr.Append(errs, err) } } return errs }
c10439
p != nil { // A nil peer is an indication that there are no more peers // available for pending choices. // A non-nil peer indicates that we have drained the waiting // channel but there may be other peer lists waiting for a peer. // We re-fill the channel enabling those choices to proceed // concurr...
c10440
pl.lock.RUnlock() if t != nil { t.NotifyStatusChanged(t.id) } }
c10441
return t } return pl.unavailablePeers[pid.Identifier()] }
c10442
if t := pl.unavailablePeers[pid.Identifier()]; t != nil { // TODO: log error _ = pl.handleUnavailablePeerStatusChange(t) } // No action required }
c10443
ok := pl.availablePeers[p.Identifier()] return ok }
c10444
ok := pl.uninitializedPeers[p.Identifier()] return ok }
c10445
ps.ConnectionStatus.String(), ps.PendingRequestCount), } } for _, peer := range availables { peersStatus = append(peersStatus, buildPeerStatus(peer)) } for _, peer := range unavailables { peersStatus = append(peersStatus, buildPeerStatus(peer)) } return introspection.ChooserStatus{ Name: "Single...
c10446
:= make([]peer.Identifier, 0, len(m)) for _, v := range m { vs = append(vs, v) } return vs }
c10447
} return fmt.Sprintf("KeyValue_GetValue_Args{%v}", strings.Join(fields[:i], ", ")) }
c10448
} if !_String_EqualsPtr(v.Key, rhs.Key) { return false } return true }
c10449
!= nil { enc.AddString("key", *v.Key) } return err }
c10450
*(v.Success)) i++ } if v.DoesNotExist != nil { fields[i] = fmt.Sprintf("DoesNotExist: %v", v.DoesNotExist) i++ } return fmt.Sprintf("KeyValue_GetValue_Result{%v}", strings.Join(fields[:i], ", ")) }
c10451
(v.DoesNotExist != nil && rhs.DoesNotExist != nil && v.DoesNotExist.Equals(rhs.DoesNotExist))) { return false } return true }
c10452
err = multierr.Append(err, enc.AddObject("doesNotExist", v.DoesNotExist)) } return err }
c10453
{ if v != nil && v.DoesNotExist != nil { return v.DoesNotExist } return }
c10454
} return fmt.Sprintf("Oneway_Echo_Args{%v}", strings.Join(fields[:i], ", ")) }
c10455
if !_String_EqualsPtr(v.Token, rhs.Token) { return false } return true }
c10456
nil { enc.AddString("token", *v.Token) } return err }
c10457
nil { return *v.Token } return }
c10458
examplepb.NewKeyValueYARPCClient(clientInfo.ClientConfig), examplepb.NewSinkYARPCClient(clientInfo.ClientConfig), examplepb.NewFooYARPCClient(clientInfo.ClientConfig), examplepb.NewKeyValueYARPCClient(clientInfo.ClientConfig, protobuf.UseJSON), examplepb.NewSinkYARPCClient(clientInfo.ClientConfi...
c10459
return yarpcerrors.Newf(code, format, args...).WithName(name) }
c10460
yarpcerrors.Newf(status.Code(), "%s: %s", fmt.Sprintf(format, args...), status.Message()) }
c10461
encoding { case "raw": runRaw(t, call) case "json": runJSON(t, call) case "thrift": runThrift(t, call) default: fatals.Fail("", "unknown encoding %q", encoding) } }
c10462
nil { m.graph.failLevel = *lvl } if lvl := cfg.ApplicationErrorLevel; lvl != nil { m.graph.appErrLevel = *lvl } return m }
c10463
:= h.Handle(ctx, req, wrappedWriter) call.EndWithAppError(err, wrappedWriter.isApplicationError) wrappedWriter.free() return err }
c10464
nil { isApplicationError = res.ApplicationError } call.EndWithAppError(err, isApplicationError) return res, err }
c10465
error { call := m.graph.begin(ctx, transport.Oneway, _directionInbound, req) err := h.HandleOneway(ctx, req) call.End(err) return err }
c10466
error) { call := m.graph.begin(ctx, transport.Oneway, _directionOutbound, req) ack, err := out.CallOneway(ctx, req) call.End(err) return ack, err }
c10467
err := h.HandleStream(serverStream) // TODO(pedge): wrap the *transport.ServerStream? call.End(err) return err }
c10468
out.CallStream(ctx, request) // TODO(pedge): wrap the *transport.ClientStream? call.End(err) return clientStream, err }
c10469
nil, false /*isResponse*/, false /*isHeader*/, err) }
c10470
nil, true /*isResponse*/, false /*isHeader*/, err) }
c10471
newServerEncodingError(req, nil, true /*isResponse*/, true /*isHeader*/, err) }
c10472
} return newServerEncodingError(req, want, false /*isResponse*/, false /*isHeader*/, newEncodingMismatchError(want, got)) }
c10473
return h } return unaryHandlerWithMiddleware{h: h, i: i} }
c10474
resw transport.ResponseWriter, h transport.UnaryHandler) error { return f(ctx, req, resw, h) }
c10475
return h } return onewayHandlerWithMiddleware{h: h, i: i} }
c10476
req *transport.Request, h transport.OnewayHandler) error { return f(ctx, req, h) }
c10477
return h } return streamHandlerWithMiddleware{h: h, i: i} }
c10478
h transport.StreamHandler) error { return f(s, h) }
c10479
} // // So Config is really the internal config as far as consumers of the // generated client are concerned. var cc clientConfig for _, opt := range opts { opt.applyClientOption(&cc) } p := protocol.Binary if cc.Protocol != nil { p = cc.Protocol } svc := c.Service if cc.ServiceName != "" { svc = c...
c10480
if req.Encoding == "" { missingParams = append(missingParams, "encoding") } if len(missingParams) > 0 { return yarpcerrors.Newf(yarpcerrors.CodeInvalidArgument, "missing %s", strings.Join(missingParams, ", ")) } return nil }
c10481
return yarpcerrors.Newf(yarpcerrors.CodeInvalidArgument, "missing TTL") } return nil }
c10482
r.Headers, ShardKey: r.ShardKey, RoutingKey: r.RoutingKey, RoutingDelegate: r.RoutingDelegate, } }
c10483
WriteTimeout: 5 * time.Second, }) if err := server.ListenAndServe(); err != nil { log.Fatalf("failed to start HTTP server: %v", err) } }
c10484
err } transportRequest.Transport = transportName procedure, err := procedureFromStreamMethod(streamMethod) if err != nil { return nil, err } transportRequest.Procedure = procedure if err := transport.ValidateRequest(transportRequest); err != nil { return nil, err } return transportRequest, nil }
c10485
= append(ts.transportOptions, opt) default: panic(fmt.Sprintf("unknown option of type %T: %v", o, o)) } } return ts.Spec() }
c10486
}) case transport.Oneway: spec = transport.NewOnewayHandlerSpec(thriftOnewayHandler{ OnewayHandler: method.HandlerSpec.Oneway, Protocol: proto, Enveloping: rc.Enveloping, }) default: panic(fmt.Sprintf("Invalid handler type for %T", method)) } rs = append(rs, transport.Procedure{...
c10487
nil { return nil, err } return result.(transport.Transport), nil }
c10488
{ result, err := cv.Build(t, k) if err != nil { return nil, err } return result.(transport.Inbound), nil }
c10489
err != nil { return nil, err } return result.(transport.UnaryOutbound), nil }
c10490
err != nil { return nil, err } return result.(transport.OnewayOutbound), nil }
c10491
err != nil { return nil, err } return result.(transport.StreamOutbound), nil }
c10492
make(map[string]*peerThunk, options.capacity), availableChooser: availableChooser, transport: transport, noShuffle: options.noShuffle, randSrc: rand.NewSource(options.seed), peerAvailableEvent: make(chan struct{}, 1), } }
c10493
if err := call.WriteResponseHeader(k, call.Header(k)); err != nil { return nil, err } } return body, nil }
c10494
if err := call.WriteResponseHeader(k, call.Header(k)); err != nil { return nil, err } } return &echo.Pong{Boop: ping.Beep}, nil }
c10495
return nil, nil } return &crossdockpb.Pong{Boop: request.Beep}, nil }
c10496
return func(transportOptions *transportOptions) { transportOptions.backoffStrategy = backoffStrategy } }
c10497
*inboundOptions) { inboundOptions.creds = creds } }
c10498
t.Subscriber() if s != nil { s.NotifyStatusChanged(pid) } }
c10499
t.subscriber = s t.lock.Unlock() }