id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
127,100 | grpc/grpc-go | reflection/serverreflection.go | fileDescEncodingContainingSymbol | func (s *serverReflectionServer) fileDescEncodingContainingSymbol(name string) ([]byte, error) {
_, symbols := s.getSymbols()
fd := symbols[name]
if fd == nil {
// Check if it's a type name that was not present in the
// transitive dependencies of the registered services.
if st, err := typeForName(name); err =... | go | func (s *serverReflectionServer) fileDescEncodingContainingSymbol(name string) ([]byte, error) {
_, symbols := s.getSymbols()
fd := symbols[name]
if fd == nil {
// Check if it's a type name that was not present in the
// transitive dependencies of the registered services.
if st, err := typeForName(name); err =... | [
"func",
"(",
"s",
"*",
"serverReflectionServer",
")",
"fileDescEncodingContainingSymbol",
"(",
"name",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"_",
",",
"symbols",
":=",
"s",
".",
"getSymbols",
"(",
")",
"\n",
"fd",
":=",
"symbols",... | // fileDescEncodingContainingSymbol finds the file descriptor containing the given symbol,
// does marshalling on it and returns the marshalled result.
// The given symbol can be a type, a service or a method. | [
"fileDescEncodingContainingSymbol",
"finds",
"the",
"file",
"descriptor",
"containing",
"the",
"given",
"symbol",
"does",
"marshalling",
"on",
"it",
"and",
"returns",
"the",
"marshalled",
"result",
".",
"The",
"given",
"symbol",
"can",
"be",
"a",
"type",
"a",
"s... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/reflection/serverreflection.go#L308-L327 |
127,101 | grpc/grpc-go | reflection/serverreflection.go | fileDescEncodingContainingExtension | func (s *serverReflectionServer) fileDescEncodingContainingExtension(typeName string, extNum int32) ([]byte, error) {
st, err := typeForName(typeName)
if err != nil {
return nil, err
}
fd, err := fileDescContainingExtension(st, extNum)
if err != nil {
return nil, err
}
return proto.Marshal(fd)
} | go | func (s *serverReflectionServer) fileDescEncodingContainingExtension(typeName string, extNum int32) ([]byte, error) {
st, err := typeForName(typeName)
if err != nil {
return nil, err
}
fd, err := fileDescContainingExtension(st, extNum)
if err != nil {
return nil, err
}
return proto.Marshal(fd)
} | [
"func",
"(",
"s",
"*",
"serverReflectionServer",
")",
"fileDescEncodingContainingExtension",
"(",
"typeName",
"string",
",",
"extNum",
"int32",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"st",
",",
"err",
":=",
"typeForName",
"(",
"typeName",
")",
... | // fileDescEncodingContainingExtension finds the file descriptor containing given extension,
// does marshalling on it and returns the marshalled result. | [
"fileDescEncodingContainingExtension",
"finds",
"the",
"file",
"descriptor",
"containing",
"given",
"extension",
"does",
"marshalling",
"on",
"it",
"and",
"returns",
"the",
"marshalled",
"result",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/reflection/serverreflection.go#L331-L341 |
127,102 | grpc/grpc-go | reflection/serverreflection.go | allExtensionNumbersForTypeName | func (s *serverReflectionServer) allExtensionNumbersForTypeName(name string) ([]int32, error) {
st, err := typeForName(name)
if err != nil {
return nil, err
}
extNums, err := s.allExtensionNumbersForType(st)
if err != nil {
return nil, err
}
return extNums, nil
} | go | func (s *serverReflectionServer) allExtensionNumbersForTypeName(name string) ([]int32, error) {
st, err := typeForName(name)
if err != nil {
return nil, err
}
extNums, err := s.allExtensionNumbersForType(st)
if err != nil {
return nil, err
}
return extNums, nil
} | [
"func",
"(",
"s",
"*",
"serverReflectionServer",
")",
"allExtensionNumbersForTypeName",
"(",
"name",
"string",
")",
"(",
"[",
"]",
"int32",
",",
"error",
")",
"{",
"st",
",",
"err",
":=",
"typeForName",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // allExtensionNumbersForTypeName returns all extension numbers for the given type. | [
"allExtensionNumbersForTypeName",
"returns",
"all",
"extension",
"numbers",
"for",
"the",
"given",
"type",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/reflection/serverreflection.go#L344-L354 |
127,103 | grpc/grpc-go | balancer.go | down | func (rr *roundRobin) down(addr Address, err error) {
rr.mu.Lock()
defer rr.mu.Unlock()
for _, a := range rr.addrs {
if addr == a.addr {
a.connected = false
break
}
}
} | go | func (rr *roundRobin) down(addr Address, err error) {
rr.mu.Lock()
defer rr.mu.Unlock()
for _, a := range rr.addrs {
if addr == a.addr {
a.connected = false
break
}
}
} | [
"func",
"(",
"rr",
"*",
"roundRobin",
")",
"down",
"(",
"addr",
"Address",
",",
"err",
"error",
")",
"{",
"rr",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"rr",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"for",
"_",
",",
"a",
":=",
"rang... | // down unsets the connected state of addr. | [
"down",
"unsets",
"the",
"connected",
"state",
"of",
"addr",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/balancer.go#L256-L265 |
127,104 | grpc/grpc-go | balancer.go | Get | func (rr *roundRobin) Get(ctx context.Context, opts BalancerGetOptions) (addr Address, put func(), err error) {
var ch chan struct{}
rr.mu.Lock()
if rr.done {
rr.mu.Unlock()
err = ErrClientConnClosing
return
}
if len(rr.addrs) > 0 {
if rr.next >= len(rr.addrs) {
rr.next = 0
}
next := rr.next
for ... | go | func (rr *roundRobin) Get(ctx context.Context, opts BalancerGetOptions) (addr Address, put func(), err error) {
var ch chan struct{}
rr.mu.Lock()
if rr.done {
rr.mu.Unlock()
err = ErrClientConnClosing
return
}
if len(rr.addrs) > 0 {
if rr.next >= len(rr.addrs) {
rr.next = 0
}
next := rr.next
for ... | [
"func",
"(",
"rr",
"*",
"roundRobin",
")",
"Get",
"(",
"ctx",
"context",
".",
"Context",
",",
"opts",
"BalancerGetOptions",
")",
"(",
"addr",
"Address",
",",
"put",
"func",
"(",
")",
",",
"err",
"error",
")",
"{",
"var",
"ch",
"chan",
"struct",
"{",
... | // Get returns the next addr in the rotation. | [
"Get",
"returns",
"the",
"next",
"addr",
"in",
"the",
"rotation",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/balancer.go#L268-L360 |
127,105 | grpc/grpc-go | balancer/balancer.go | Get | func Get(name string) Builder {
if b, ok := m[strings.ToLower(name)]; ok {
return b
}
return nil
} | go | func Get(name string) Builder {
if b, ok := m[strings.ToLower(name)]; ok {
return b
}
return nil
} | [
"func",
"Get",
"(",
"name",
"string",
")",
"Builder",
"{",
"if",
"b",
",",
"ok",
":=",
"m",
"[",
"strings",
".",
"ToLower",
"(",
"name",
")",
"]",
";",
"ok",
"{",
"return",
"b",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Get returns the resolver builder registered with the given name.
// Note that the compare is done in a case-insensitive fashion.
// If no builder is register with the name, nil will be returned. | [
"Get",
"returns",
"the",
"resolver",
"builder",
"registered",
"with",
"the",
"given",
"name",
".",
"Note",
"that",
"the",
"compare",
"is",
"done",
"in",
"a",
"case",
"-",
"insensitive",
"fashion",
".",
"If",
"no",
"builder",
"is",
"register",
"with",
"the"... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/balancer/balancer.go#L66-L71 |
127,106 | grpc/grpc-go | balancer/balancer.go | RecordTransition | func (cse *ConnectivityStateEvaluator) RecordTransition(oldState, newState connectivity.State) connectivity.State {
// Update counters.
for idx, state := range []connectivity.State{oldState, newState} {
updateVal := 2*uint64(idx) - 1 // -1 for oldState and +1 for new.
switch state {
case connectivity.Ready:
... | go | func (cse *ConnectivityStateEvaluator) RecordTransition(oldState, newState connectivity.State) connectivity.State {
// Update counters.
for idx, state := range []connectivity.State{oldState, newState} {
updateVal := 2*uint64(idx) - 1 // -1 for oldState and +1 for new.
switch state {
case connectivity.Ready:
... | [
"func",
"(",
"cse",
"*",
"ConnectivityStateEvaluator",
")",
"RecordTransition",
"(",
"oldState",
",",
"newState",
"connectivity",
".",
"State",
")",
"connectivity",
".",
"State",
"{",
"// Update counters.",
"for",
"idx",
",",
"state",
":=",
"range",
"[",
"]",
... | // RecordTransition records state change happening in subConn and based on that
// it evaluates what aggregated state should be.
//
// - If at least one SubConn in Ready, the aggregated state is Ready;
// - Else if at least one SubConn in Connecting, the aggregated state is Connecting;
// - Else the aggregated state... | [
"RecordTransition",
"records",
"state",
"change",
"happening",
"in",
"subConn",
"and",
"based",
"on",
"that",
"it",
"evaluates",
"what",
"aggregated",
"state",
"should",
"be",
".",
"-",
"If",
"at",
"least",
"one",
"SubConn",
"in",
"Ready",
"the",
"aggregated",... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/balancer/balancer.go#L314-L336 |
127,107 | grpc/grpc-go | examples/route_guide/server/server.go | GetFeature | func (s *routeGuideServer) GetFeature(ctx context.Context, point *pb.Point) (*pb.Feature, error) {
for _, feature := range s.savedFeatures {
if proto.Equal(feature.Location, point) {
return feature, nil
}
}
// No feature was found, return an unnamed feature
return &pb.Feature{Location: point}, nil
} | go | func (s *routeGuideServer) GetFeature(ctx context.Context, point *pb.Point) (*pb.Feature, error) {
for _, feature := range s.savedFeatures {
if proto.Equal(feature.Location, point) {
return feature, nil
}
}
// No feature was found, return an unnamed feature
return &pb.Feature{Location: point}, nil
} | [
"func",
"(",
"s",
"*",
"routeGuideServer",
")",
"GetFeature",
"(",
"ctx",
"context",
".",
"Context",
",",
"point",
"*",
"pb",
".",
"Point",
")",
"(",
"*",
"pb",
".",
"Feature",
",",
"error",
")",
"{",
"for",
"_",
",",
"feature",
":=",
"range",
"s",... | // GetFeature returns the feature at the given point. | [
"GetFeature",
"returns",
"the",
"feature",
"at",
"the",
"given",
"point",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/examples/route_guide/server/server.go#L66-L74 |
127,108 | grpc/grpc-go | examples/route_guide/server/server.go | ListFeatures | func (s *routeGuideServer) ListFeatures(rect *pb.Rectangle, stream pb.RouteGuide_ListFeaturesServer) error {
for _, feature := range s.savedFeatures {
if inRange(feature.Location, rect) {
if err := stream.Send(feature); err != nil {
return err
}
}
}
return nil
} | go | func (s *routeGuideServer) ListFeatures(rect *pb.Rectangle, stream pb.RouteGuide_ListFeaturesServer) error {
for _, feature := range s.savedFeatures {
if inRange(feature.Location, rect) {
if err := stream.Send(feature); err != nil {
return err
}
}
}
return nil
} | [
"func",
"(",
"s",
"*",
"routeGuideServer",
")",
"ListFeatures",
"(",
"rect",
"*",
"pb",
".",
"Rectangle",
",",
"stream",
"pb",
".",
"RouteGuide_ListFeaturesServer",
")",
"error",
"{",
"for",
"_",
",",
"feature",
":=",
"range",
"s",
".",
"savedFeatures",
"{... | // ListFeatures lists all features contained within the given bounding Rectangle. | [
"ListFeatures",
"lists",
"all",
"features",
"contained",
"within",
"the",
"given",
"bounding",
"Rectangle",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/examples/route_guide/server/server.go#L77-L86 |
127,109 | grpc/grpc-go | examples/route_guide/server/server.go | loadFeatures | func (s *routeGuideServer) loadFeatures(filePath string) {
var data []byte
if filePath != "" {
var err error
data, err = ioutil.ReadFile(filePath)
if err != nil {
log.Fatalf("Failed to load default features: %v", err)
}
} else {
data = exampleData
}
if err := json.Unmarshal(data, &s.savedFeatures); er... | go | func (s *routeGuideServer) loadFeatures(filePath string) {
var data []byte
if filePath != "" {
var err error
data, err = ioutil.ReadFile(filePath)
if err != nil {
log.Fatalf("Failed to load default features: %v", err)
}
} else {
data = exampleData
}
if err := json.Unmarshal(data, &s.savedFeatures); er... | [
"func",
"(",
"s",
"*",
"routeGuideServer",
")",
"loadFeatures",
"(",
"filePath",
"string",
")",
"{",
"var",
"data",
"[",
"]",
"byte",
"\n",
"if",
"filePath",
"!=",
"\"",
"\"",
"{",
"var",
"err",
"error",
"\n",
"data",
",",
"err",
"=",
"ioutil",
".",
... | // loadFeatures loads features from a JSON file. | [
"loadFeatures",
"loads",
"features",
"from",
"a",
"JSON",
"file",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/examples/route_guide/server/server.go#L155-L169 |
127,110 | grpc/grpc-go | internal/leakcheck/leakcheck.go | interestingGoroutines | func interestingGoroutines() (gs []string) {
buf := make([]byte, 2<<20)
buf = buf[:runtime.Stack(buf, true)]
for _, g := range strings.Split(string(buf), "\n\n") {
if !ignore(g) {
gs = append(gs, g)
}
}
sort.Strings(gs)
return
} | go | func interestingGoroutines() (gs []string) {
buf := make([]byte, 2<<20)
buf = buf[:runtime.Stack(buf, true)]
for _, g := range strings.Split(string(buf), "\n\n") {
if !ignore(g) {
gs = append(gs, g)
}
}
sort.Strings(gs)
return
} | [
"func",
"interestingGoroutines",
"(",
")",
"(",
"gs",
"[",
"]",
"string",
")",
"{",
"buf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"2",
"<<",
"20",
")",
"\n",
"buf",
"=",
"buf",
"[",
":",
"runtime",
".",
"Stack",
"(",
"buf",
",",
"true",
")",... | // interestingGoroutines returns all goroutines we care about for the purpose of
// leak checking. It excludes testing or runtime ones. | [
"interestingGoroutines",
"returns",
"all",
"goroutines",
"we",
"care",
"about",
"for",
"the",
"purpose",
"of",
"leak",
"checking",
".",
"It",
"excludes",
"testing",
"or",
"runtime",
"ones",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/leakcheck/leakcheck.go#L79-L89 |
127,111 | grpc/grpc-go | internal/transport/bdp_estimator.go | calculate | func (b *bdpEstimator) calculate(d [8]byte) {
// Check if the ping acked for was the bdp ping.
if bdpPing.data != d {
return
}
b.mu.Lock()
rttSample := time.Since(b.sentAt).Seconds()
if b.sampleCount < 10 {
// Bootstrap rtt with an average of first 10 rtt samples.
b.rtt += (rttSample - b.rtt) / float64(b.sa... | go | func (b *bdpEstimator) calculate(d [8]byte) {
// Check if the ping acked for was the bdp ping.
if bdpPing.data != d {
return
}
b.mu.Lock()
rttSample := time.Since(b.sentAt).Seconds()
if b.sampleCount < 10 {
// Bootstrap rtt with an average of first 10 rtt samples.
b.rtt += (rttSample - b.rtt) / float64(b.sa... | [
"func",
"(",
"b",
"*",
"bdpEstimator",
")",
"calculate",
"(",
"d",
"[",
"8",
"]",
"byte",
")",
"{",
"// Check if the ping acked for was the bdp ping.",
"if",
"bdpPing",
".",
"data",
"!=",
"d",
"{",
"return",
"\n",
"}",
"\n",
"b",
".",
"mu",
".",
"Lock",
... | // calculate is called when an ack for a bdp ping is received.
// Here we calculate the current bdp and bandwidth sample and
// decide if the flow control windows should go up. | [
"calculate",
"is",
"called",
"when",
"an",
"ack",
"for",
"a",
"bdp",
"ping",
"is",
"received",
".",
"Here",
"we",
"calculate",
"the",
"current",
"bdp",
"and",
"bandwidth",
"sample",
"and",
"decide",
"if",
"the",
"flow",
"control",
"windows",
"should",
"go"... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/bdp_estimator.go#L105-L141 |
127,112 | grpc/grpc-go | interop/http2/negative_http2_client.go | goaway | func goaway(tc testpb.TestServiceClient) {
interop.DoLargeUnaryCall(tc)
// sleep to ensure that the client has time to recv the GOAWAY.
// TODO(ncteisen): make this less hacky.
time.Sleep(1 * time.Second)
interop.DoLargeUnaryCall(tc)
} | go | func goaway(tc testpb.TestServiceClient) {
interop.DoLargeUnaryCall(tc)
// sleep to ensure that the client has time to recv the GOAWAY.
// TODO(ncteisen): make this less hacky.
time.Sleep(1 * time.Second)
interop.DoLargeUnaryCall(tc)
} | [
"func",
"goaway",
"(",
"tc",
"testpb",
".",
"TestServiceClient",
")",
"{",
"interop",
".",
"DoLargeUnaryCall",
"(",
"tc",
")",
"\n",
"// sleep to ensure that the client has time to recv the GOAWAY.",
"// TODO(ncteisen): make this less hacky.",
"time",
".",
"Sleep",
"(",
"... | // sends two unary calls. The server asserts that the calls use different connections. | [
"sends",
"two",
"unary",
"calls",
".",
"The",
"server",
"asserts",
"that",
"the",
"calls",
"use",
"different",
"connections",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/interop/http2/negative_http2_client.go#L67-L73 |
127,113 | grpc/grpc-go | picker_wrapper.go | updatePicker | func (bp *pickerWrapper) updatePicker(p balancer.Picker) {
bp.mu.Lock()
if bp.done {
bp.mu.Unlock()
return
}
bp.picker = p
// bp.blockingCh should never be nil.
close(bp.blockingCh)
bp.blockingCh = make(chan struct{})
bp.mu.Unlock()
} | go | func (bp *pickerWrapper) updatePicker(p balancer.Picker) {
bp.mu.Lock()
if bp.done {
bp.mu.Unlock()
return
}
bp.picker = p
// bp.blockingCh should never be nil.
close(bp.blockingCh)
bp.blockingCh = make(chan struct{})
bp.mu.Unlock()
} | [
"func",
"(",
"bp",
"*",
"pickerWrapper",
")",
"updatePicker",
"(",
"p",
"balancer",
".",
"Picker",
")",
"{",
"bp",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"if",
"bp",
".",
"done",
"{",
"bp",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"return",
"... | // updatePicker is called by UpdateBalancerState. It unblocks all blocked pick. | [
"updatePicker",
"is",
"called",
"by",
"UpdateBalancerState",
".",
"It",
"unblocks",
"all",
"blocked",
"pick",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/picker_wrapper.go#L66-L77 |
127,114 | grpc/grpc-go | credentials/alts/utils.go | isRunningOnGCP | func isRunningOnGCP() bool {
manufacturer, err := readManufacturer()
if err != nil {
log.Fatalf("failure to read manufacturer information: %v", err)
}
name := string(manufacturer)
switch runningOS {
case "linux":
name = strings.TrimSpace(name)
return name == "Google" || name == "Google Compute Engine"
case... | go | func isRunningOnGCP() bool {
manufacturer, err := readManufacturer()
if err != nil {
log.Fatalf("failure to read manufacturer information: %v", err)
}
name := string(manufacturer)
switch runningOS {
case "linux":
name = strings.TrimSpace(name)
return name == "Google" || name == "Google Compute Engine"
case... | [
"func",
"isRunningOnGCP",
"(",
")",
"bool",
"{",
"manufacturer",
",",
"err",
":=",
"readManufacturer",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"name",
":=",
"string",
"... | // isRunningOnGCP checks whether the local system, without doing a network request is
// running on GCP. | [
"isRunningOnGCP",
"checks",
"whether",
"the",
"local",
"system",
"without",
"doing",
"a",
"network",
"request",
"is",
"running",
"on",
"GCP",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/utils.go#L84-L103 |
127,115 | grpc/grpc-go | credentials/alts/internal/conn/record.go | RegisterProtocol | func RegisterProtocol(protocol string, f ALTSRecordFunc) error {
if _, ok := protocols[protocol]; ok {
return fmt.Errorf("protocol %v is already registered", protocol)
}
protocols[protocol] = f
return nil
} | go | func RegisterProtocol(protocol string, f ALTSRecordFunc) error {
if _, ok := protocols[protocol]; ok {
return fmt.Errorf("protocol %v is already registered", protocol)
}
protocols[protocol] = f
return nil
} | [
"func",
"RegisterProtocol",
"(",
"protocol",
"string",
",",
"f",
"ALTSRecordFunc",
")",
"error",
"{",
"if",
"_",
",",
"ok",
":=",
"protocols",
"[",
"protocol",
"]",
";",
"ok",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"protocol",
")",
... | // RegisterProtocol register a ALTS record encryption protocol. | [
"RegisterProtocol",
"register",
"a",
"ALTS",
"record",
"encryption",
"protocol",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/internal/conn/record.go#L73-L79 |
127,116 | grpc/grpc-go | credentials/alts/internal/conn/record.go | NewConn | func NewConn(c net.Conn, side core.Side, recordProtocol string, key []byte, protected []byte) (net.Conn, error) {
newCrypto := protocols[recordProtocol]
if newCrypto == nil {
return nil, fmt.Errorf("negotiated unknown next_protocol %q", recordProtocol)
}
crypto, err := newCrypto(side, key)
if err != nil {
retu... | go | func NewConn(c net.Conn, side core.Side, recordProtocol string, key []byte, protected []byte) (net.Conn, error) {
newCrypto := protocols[recordProtocol]
if newCrypto == nil {
return nil, fmt.Errorf("negotiated unknown next_protocol %q", recordProtocol)
}
crypto, err := newCrypto(side, key)
if err != nil {
retu... | [
"func",
"NewConn",
"(",
"c",
"net",
".",
"Conn",
",",
"side",
"core",
".",
"Side",
",",
"recordProtocol",
"string",
",",
"key",
"[",
"]",
"byte",
",",
"protected",
"[",
"]",
"byte",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"newCrypto",... | // NewConn creates a new secure channel instance given the other party role and
// handshaking result. | [
"NewConn",
"creates",
"a",
"new",
"secure",
"channel",
"instance",
"given",
"the",
"other",
"party",
"role",
"and",
"handshaking",
"result",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/internal/conn/record.go#L103-L136 |
127,117 | grpc/grpc-go | credentials/alts/internal/conn/record.go | Write | func (p *conn) Write(b []byte) (n int, err error) {
n = len(b)
// Calculate the output buffer size with framing and encryption overhead.
numOfFrames := int(math.Ceil(float64(len(b)) / float64(p.payloadLengthLimit)))
size := len(b) + numOfFrames*p.overhead
// If writeBuf is too small, increase its size up to the ma... | go | func (p *conn) Write(b []byte) (n int, err error) {
n = len(b)
// Calculate the output buffer size with framing and encryption overhead.
numOfFrames := int(math.Ceil(float64(len(b)) / float64(p.payloadLengthLimit)))
size := len(b) + numOfFrames*p.overhead
// If writeBuf is too small, increase its size up to the ma... | [
"func",
"(",
"p",
"*",
"conn",
")",
"Write",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"n",
"=",
"len",
"(",
"b",
")",
"\n",
"// Calculate the output buffer size with framing and encryption overhead.",
"numOfFrames",
... | // Write encrypts, frames, and writes bytes from b to the underlying connection. | [
"Write",
"encrypts",
"frames",
"and",
"writes",
"bytes",
"from",
"b",
"to",
"the",
"underlying",
"connection",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/internal/conn/record.go#L203-L264 |
127,118 | grpc/grpc-go | codes/codes.go | UnmarshalJSON | func (c *Code) UnmarshalJSON(b []byte) error {
// From json.Unmarshaler: By convention, to approximate the behavior of
// Unmarshal itself, Unmarshalers implement UnmarshalJSON([]byte("null")) as
// a no-op.
if string(b) == "null" {
return nil
}
if c == nil {
return fmt.Errorf("nil receiver passed to Unmarsha... | go | func (c *Code) UnmarshalJSON(b []byte) error {
// From json.Unmarshaler: By convention, to approximate the behavior of
// Unmarshal itself, Unmarshalers implement UnmarshalJSON([]byte("null")) as
// a no-op.
if string(b) == "null" {
return nil
}
if c == nil {
return fmt.Errorf("nil receiver passed to Unmarsha... | [
"func",
"(",
"c",
"*",
"Code",
")",
"UnmarshalJSON",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"// From json.Unmarshaler: By convention, to approximate the behavior of",
"// Unmarshal itself, Unmarshalers implement UnmarshalJSON([]byte(\"null\")) as",
"// a no-op.",
"if",
... | // UnmarshalJSON unmarshals b into the Code. | [
"UnmarshalJSON",
"unmarshals",
"b",
"into",
"the",
"Code",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/codes/codes.go#L173-L198 |
127,119 | grpc/grpc-go | balancer/base/balancer.go | regeneratePicker | func (b *baseBalancer) regeneratePicker() {
if b.state == connectivity.TransientFailure {
b.picker = NewErrPicker(balancer.ErrTransientFailure)
return
}
readySCs := make(map[resolver.Address]balancer.SubConn)
// Filter out all ready SCs from full subConn map.
for addr, sc := range b.subConns {
if st, ok := ... | go | func (b *baseBalancer) regeneratePicker() {
if b.state == connectivity.TransientFailure {
b.picker = NewErrPicker(balancer.ErrTransientFailure)
return
}
readySCs := make(map[resolver.Address]balancer.SubConn)
// Filter out all ready SCs from full subConn map.
for addr, sc := range b.subConns {
if st, ok := ... | [
"func",
"(",
"b",
"*",
"baseBalancer",
")",
"regeneratePicker",
"(",
")",
"{",
"if",
"b",
".",
"state",
"==",
"connectivity",
".",
"TransientFailure",
"{",
"b",
".",
"picker",
"=",
"NewErrPicker",
"(",
"balancer",
".",
"ErrTransientFailure",
")",
"\n",
"re... | // regeneratePicker takes a snapshot of the balancer, and generates a picker
// from it. The picker is
// - errPicker with ErrTransientFailure if the balancer is in TransientFailure,
// - built by the pickerBuilder with all READY SubConns otherwise. | [
"regeneratePicker",
"takes",
"a",
"snapshot",
"of",
"the",
"balancer",
"and",
"generates",
"a",
"picker",
"from",
"it",
".",
"The",
"picker",
"is",
"-",
"errPicker",
"with",
"ErrTransientFailure",
"if",
"the",
"balancer",
"is",
"in",
"TransientFailure",
"-",
"... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/balancer/base/balancer.go#L108-L122 |
127,120 | grpc/grpc-go | balancer/xds/edsbalancer/balancergroup.go | add | func (bg *balancerGroup) add(id string, weight uint32, builder balancer.Builder) {
bg.mu.Lock()
if _, ok := bg.idToBalancer[id]; ok {
bg.mu.Unlock()
grpclog.Warningf("balancer group: adding a balancer with existing ID: %s", id)
return
}
bg.mu.Unlock()
bgcc := &balancerGroupCC{
id: id,
group: bg,
}
b... | go | func (bg *balancerGroup) add(id string, weight uint32, builder balancer.Builder) {
bg.mu.Lock()
if _, ok := bg.idToBalancer[id]; ok {
bg.mu.Unlock()
grpclog.Warningf("balancer group: adding a balancer with existing ID: %s", id)
return
}
bg.mu.Unlock()
bgcc := &balancerGroupCC{
id: id,
group: bg,
}
b... | [
"func",
"(",
"bg",
"*",
"balancerGroup",
")",
"add",
"(",
"id",
"string",
",",
"weight",
"uint32",
",",
"builder",
"balancer",
".",
"Builder",
")",
"{",
"bg",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"if",
"_",
",",
"ok",
":=",
"bg",
".",
"idToBal... | // add adds a balancer built by builder to the group, with given id and weight. | [
"add",
"adds",
"a",
"balancer",
"built",
"by",
"builder",
"to",
"the",
"group",
"with",
"given",
"id",
"and",
"weight",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/balancer/xds/edsbalancer/balancergroup.go#L82-L108 |
127,121 | grpc/grpc-go | balancer/xds/edsbalancer/balancergroup.go | remove | func (bg *balancerGroup) remove(id string) {
bg.mu.Lock()
// Close balancer.
if b, ok := bg.idToBalancer[id]; ok {
b.Close()
delete(bg.idToBalancer, id)
}
// Remove SubConns.
for sc, bid := range bg.scToID {
if bid == id {
bg.cc.RemoveSubConn(sc)
delete(bg.scToID, sc)
}
}
bg.mu.Unlock()
bg.picke... | go | func (bg *balancerGroup) remove(id string) {
bg.mu.Lock()
// Close balancer.
if b, ok := bg.idToBalancer[id]; ok {
b.Close()
delete(bg.idToBalancer, id)
}
// Remove SubConns.
for sc, bid := range bg.scToID {
if bid == id {
bg.cc.RemoveSubConn(sc)
delete(bg.scToID, sc)
}
}
bg.mu.Unlock()
bg.picke... | [
"func",
"(",
"bg",
"*",
"balancerGroup",
")",
"remove",
"(",
"id",
"string",
")",
"{",
"bg",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"// Close balancer.",
"if",
"b",
",",
"ok",
":=",
"bg",
".",
"idToBalancer",
"[",
"id",
"]",
";",
"ok",
"{",
"b",... | // remove removes the balancer with id from the group, and closes the balancer.
//
// It also removes the picker generated from this balancer from the picker
// group. It always results in a picker update. | [
"remove",
"removes",
"the",
"balancer",
"with",
"id",
"from",
"the",
"group",
"and",
"closes",
"the",
"balancer",
".",
"It",
"also",
"removes",
"the",
"picker",
"generated",
"from",
"this",
"balancer",
"from",
"the",
"picker",
"group",
".",
"It",
"always",
... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/balancer/xds/edsbalancer/balancergroup.go#L114-L137 |
127,122 | grpc/grpc-go | benchmark/benchmark.go | AddOne | func AddOne(features []int, featuresMaxPosition []int) {
for i := len(features) - 1; i >= 0; i-- {
features[i] = (features[i] + 1)
if features[i]/featuresMaxPosition[i] == 0 {
break
}
features[i] = features[i] % featuresMaxPosition[i]
}
} | go | func AddOne(features []int, featuresMaxPosition []int) {
for i := len(features) - 1; i >= 0; i-- {
features[i] = (features[i] + 1)
if features[i]/featuresMaxPosition[i] == 0 {
break
}
features[i] = features[i] % featuresMaxPosition[i]
}
} | [
"func",
"AddOne",
"(",
"features",
"[",
"]",
"int",
",",
"featuresMaxPosition",
"[",
"]",
"int",
")",
"{",
"for",
"i",
":=",
"len",
"(",
"features",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"features",
"[",
"i",
"]",
"=",
"(",
... | // AddOne add 1 to the features slice | [
"AddOne",
"add",
"1",
"to",
"the",
"features",
"slice"
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/benchmark.go#L46-L54 |
127,123 | grpc/grpc-go | benchmark/benchmark.go | setPayload | func setPayload(p *testpb.Payload, t testpb.PayloadType, size int) {
if size < 0 {
grpclog.Fatalf("Requested a response with invalid length %d", size)
}
body := make([]byte, size)
switch t {
case testpb.PayloadType_COMPRESSABLE:
case testpb.PayloadType_UNCOMPRESSABLE:
grpclog.Fatalf("PayloadType UNCOMPRESSABL... | go | func setPayload(p *testpb.Payload, t testpb.PayloadType, size int) {
if size < 0 {
grpclog.Fatalf("Requested a response with invalid length %d", size)
}
body := make([]byte, size)
switch t {
case testpb.PayloadType_COMPRESSABLE:
case testpb.PayloadType_UNCOMPRESSABLE:
grpclog.Fatalf("PayloadType UNCOMPRESSABL... | [
"func",
"setPayload",
"(",
"p",
"*",
"testpb",
".",
"Payload",
",",
"t",
"testpb",
".",
"PayloadType",
",",
"size",
"int",
")",
"{",
"if",
"size",
"<",
"0",
"{",
"grpclog",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"size",
")",
"\n",
"}",
"\n",
"body"... | // Allows reuse of the same testpb.Payload object. | [
"Allows",
"reuse",
"of",
"the",
"same",
"testpb",
".",
"Payload",
"object",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/benchmark.go#L57-L71 |
127,124 | grpc/grpc-go | benchmark/benchmark.go | NewPayload | func NewPayload(t testpb.PayloadType, size int) *testpb.Payload {
p := new(testpb.Payload)
setPayload(p, t, size)
return p
} | go | func NewPayload(t testpb.PayloadType, size int) *testpb.Payload {
p := new(testpb.Payload)
setPayload(p, t, size)
return p
} | [
"func",
"NewPayload",
"(",
"t",
"testpb",
".",
"PayloadType",
",",
"size",
"int",
")",
"*",
"testpb",
".",
"Payload",
"{",
"p",
":=",
"new",
"(",
"testpb",
".",
"Payload",
")",
"\n",
"setPayload",
"(",
"p",
",",
"t",
",",
"size",
")",
"\n",
"return... | // NewPayload creates a payload with the given type and size. | [
"NewPayload",
"creates",
"a",
"payload",
"with",
"the",
"given",
"type",
"and",
"size",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/benchmark.go#L74-L78 |
127,125 | grpc/grpc-go | benchmark/benchmark.go | UnaryCall | func (s *byteBufServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
return &testpb.SimpleResponse{}, nil
} | go | func (s *byteBufServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
return &testpb.SimpleResponse{}, nil
} | [
"func",
"(",
"s",
"*",
"byteBufServer",
")",
"UnaryCall",
"(",
"ctx",
"context",
".",
"Context",
",",
"in",
"*",
"testpb",
".",
"SimpleRequest",
")",
"(",
"*",
"testpb",
".",
"SimpleResponse",
",",
"error",
")",
"{",
"return",
"&",
"testpb",
".",
"Simp... | // UnaryCall is an empty function and is not used for benchmark.
// If bytebuf UnaryCall benchmark is needed later, the function body needs to be updated. | [
"UnaryCall",
"is",
"an",
"empty",
"function",
"and",
"is",
"not",
"used",
"for",
"benchmark",
".",
"If",
"bytebuf",
"UnaryCall",
"benchmark",
"is",
"needed",
"later",
"the",
"function",
"body",
"needs",
"to",
"be",
"updated",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/benchmark.go#L165-L167 |
127,126 | grpc/grpc-go | benchmark/benchmark.go | StartServer | func StartServer(info ServerInfo, opts ...grpc.ServerOption) func() {
opts = append(opts, grpc.WriteBufferSize(128*1024))
opts = append(opts, grpc.ReadBufferSize(128*1024))
s := grpc.NewServer(opts...)
switch info.Type {
case "protobuf":
testpb.RegisterBenchmarkServiceServer(s, &testServer{})
case "bytebuf":
... | go | func StartServer(info ServerInfo, opts ...grpc.ServerOption) func() {
opts = append(opts, grpc.WriteBufferSize(128*1024))
opts = append(opts, grpc.ReadBufferSize(128*1024))
s := grpc.NewServer(opts...)
switch info.Type {
case "protobuf":
testpb.RegisterBenchmarkServiceServer(s, &testServer{})
case "bytebuf":
... | [
"func",
"StartServer",
"(",
"info",
"ServerInfo",
",",
"opts",
"...",
"grpc",
".",
"ServerOption",
")",
"func",
"(",
")",
"{",
"opts",
"=",
"append",
"(",
"opts",
",",
"grpc",
".",
"WriteBufferSize",
"(",
"128",
"*",
"1024",
")",
")",
"\n",
"opts",
"... | // StartServer starts a gRPC server serving a benchmark service according to info.
// It returns a function to stop the server. | [
"StartServer",
"starts",
"a",
"gRPC",
"server",
"serving",
"a",
"benchmark",
"service",
"according",
"to",
"info",
".",
"It",
"returns",
"a",
"function",
"to",
"stop",
"the",
"server",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/benchmark.go#L220-L240 |
127,127 | grpc/grpc-go | benchmark/benchmark.go | DoUnaryCall | func DoUnaryCall(tc testpb.BenchmarkServiceClient, reqSize, respSize int) error {
pl := NewPayload(testpb.PayloadType_COMPRESSABLE, reqSize)
req := &testpb.SimpleRequest{
ResponseType: pl.Type,
ResponseSize: int32(respSize),
Payload: pl,
}
if _, err := tc.UnaryCall(context.Background(), req); err != nil ... | go | func DoUnaryCall(tc testpb.BenchmarkServiceClient, reqSize, respSize int) error {
pl := NewPayload(testpb.PayloadType_COMPRESSABLE, reqSize)
req := &testpb.SimpleRequest{
ResponseType: pl.Type,
ResponseSize: int32(respSize),
Payload: pl,
}
if _, err := tc.UnaryCall(context.Background(), req); err != nil ... | [
"func",
"DoUnaryCall",
"(",
"tc",
"testpb",
".",
"BenchmarkServiceClient",
",",
"reqSize",
",",
"respSize",
"int",
")",
"error",
"{",
"pl",
":=",
"NewPayload",
"(",
"testpb",
".",
"PayloadType_COMPRESSABLE",
",",
"reqSize",
")",
"\n",
"req",
":=",
"&",
"test... | // DoUnaryCall performs an unary RPC with given stub and request and response sizes. | [
"DoUnaryCall",
"performs",
"an",
"unary",
"RPC",
"with",
"given",
"stub",
"and",
"request",
"and",
"response",
"sizes",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/benchmark.go#L243-L254 |
127,128 | grpc/grpc-go | benchmark/benchmark.go | DoStreamingRoundTrip | func DoStreamingRoundTrip(stream testpb.BenchmarkService_StreamingCallClient, reqSize, respSize int) error {
pl := NewPayload(testpb.PayloadType_COMPRESSABLE, reqSize)
req := &testpb.SimpleRequest{
ResponseType: pl.Type,
ResponseSize: int32(respSize),
Payload: pl,
}
if err := stream.Send(req); err != nil... | go | func DoStreamingRoundTrip(stream testpb.BenchmarkService_StreamingCallClient, reqSize, respSize int) error {
pl := NewPayload(testpb.PayloadType_COMPRESSABLE, reqSize)
req := &testpb.SimpleRequest{
ResponseType: pl.Type,
ResponseSize: int32(respSize),
Payload: pl,
}
if err := stream.Send(req); err != nil... | [
"func",
"DoStreamingRoundTrip",
"(",
"stream",
"testpb",
".",
"BenchmarkService_StreamingCallClient",
",",
"reqSize",
",",
"respSize",
"int",
")",
"error",
"{",
"pl",
":=",
"NewPayload",
"(",
"testpb",
".",
"PayloadType_COMPRESSABLE",
",",
"reqSize",
")",
"\n",
"r... | // DoStreamingRoundTrip performs a round trip for a single streaming rpc. | [
"DoStreamingRoundTrip",
"performs",
"a",
"round",
"trip",
"for",
"a",
"single",
"streaming",
"rpc",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/benchmark.go#L257-L275 |
127,129 | grpc/grpc-go | benchmark/benchmark.go | DoByteBufStreamingRoundTrip | func DoByteBufStreamingRoundTrip(stream testpb.BenchmarkService_StreamingCallClient, reqSize, respSize int) error {
out := make([]byte, reqSize)
if err := stream.(grpc.ClientStream).SendMsg(&out); err != nil {
return fmt.Errorf("/BenchmarkService/StreamingCall.(ClientStream).SendMsg(_) = %v, want <nil>", err)
}
v... | go | func DoByteBufStreamingRoundTrip(stream testpb.BenchmarkService_StreamingCallClient, reqSize, respSize int) error {
out := make([]byte, reqSize)
if err := stream.(grpc.ClientStream).SendMsg(&out); err != nil {
return fmt.Errorf("/BenchmarkService/StreamingCall.(ClientStream).SendMsg(_) = %v, want <nil>", err)
}
v... | [
"func",
"DoByteBufStreamingRoundTrip",
"(",
"stream",
"testpb",
".",
"BenchmarkService_StreamingCallClient",
",",
"reqSize",
",",
"respSize",
"int",
")",
"error",
"{",
"out",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"reqSize",
")",
"\n",
"if",
"err",
":=",
... | // DoByteBufStreamingRoundTrip performs a round trip for a single streaming rpc, using a custom codec for byte buffer. | [
"DoByteBufStreamingRoundTrip",
"performs",
"a",
"round",
"trip",
"for",
"a",
"single",
"streaming",
"rpc",
"using",
"a",
"custom",
"codec",
"for",
"byte",
"buffer",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/benchmark.go#L278-L292 |
127,130 | grpc/grpc-go | benchmark/benchmark.go | NewClientConn | func NewClientConn(addr string, opts ...grpc.DialOption) *grpc.ClientConn {
return NewClientConnWithContext(context.Background(), addr, opts...)
} | go | func NewClientConn(addr string, opts ...grpc.DialOption) *grpc.ClientConn {
return NewClientConnWithContext(context.Background(), addr, opts...)
} | [
"func",
"NewClientConn",
"(",
"addr",
"string",
",",
"opts",
"...",
"grpc",
".",
"DialOption",
")",
"*",
"grpc",
".",
"ClientConn",
"{",
"return",
"NewClientConnWithContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"addr",
",",
"opts",
"...",
")"... | // NewClientConn creates a gRPC client connection to addr. | [
"NewClientConn",
"creates",
"a",
"gRPC",
"client",
"connection",
"to",
"addr",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/benchmark.go#L295-L297 |
127,131 | grpc/grpc-go | benchmark/benchmark.go | NewClientConnWithContext | func NewClientConnWithContext(ctx context.Context, addr string, opts ...grpc.DialOption) *grpc.ClientConn {
opts = append(opts, grpc.WithWriteBufferSize(128*1024))
opts = append(opts, grpc.WithReadBufferSize(128*1024))
conn, err := grpc.DialContext(ctx, addr, opts...)
if err != nil {
grpclog.Fatalf("NewClientConn... | go | func NewClientConnWithContext(ctx context.Context, addr string, opts ...grpc.DialOption) *grpc.ClientConn {
opts = append(opts, grpc.WithWriteBufferSize(128*1024))
opts = append(opts, grpc.WithReadBufferSize(128*1024))
conn, err := grpc.DialContext(ctx, addr, opts...)
if err != nil {
grpclog.Fatalf("NewClientConn... | [
"func",
"NewClientConnWithContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"addr",
"string",
",",
"opts",
"...",
"grpc",
".",
"DialOption",
")",
"*",
"grpc",
".",
"ClientConn",
"{",
"opts",
"=",
"append",
"(",
"opts",
",",
"grpc",
".",
"WithWriteBuffe... | // NewClientConnWithContext creates a gRPC client connection to addr using ctx. | [
"NewClientConnWithContext",
"creates",
"a",
"gRPC",
"client",
"connection",
"to",
"addr",
"using",
"ctx",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/benchmark.go#L300-L308 |
127,132 | grpc/grpc-go | internal/transport/transport.go | RecvCompress | func (s *Stream) RecvCompress() string {
if err := s.waitOnHeader(); err != nil {
return ""
}
return s.recvCompress
} | go | func (s *Stream) RecvCompress() string {
if err := s.waitOnHeader(); err != nil {
return ""
}
return s.recvCompress
} | [
"func",
"(",
"s",
"*",
"Stream",
")",
"RecvCompress",
"(",
")",
"string",
"{",
"if",
"err",
":=",
"s",
".",
"waitOnHeader",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"s",
".",
"recvCompress",
"\n",
"... | // RecvCompress returns the compression algorithm applied to the inbound
// message. It is empty string if there is no compression applied. | [
"RecvCompress",
"returns",
"the",
"compression",
"algorithm",
"applied",
"to",
"the",
"inbound",
"message",
".",
"It",
"is",
"empty",
"string",
"if",
"there",
"is",
"no",
"compression",
"applied",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/transport.go#L277-L282 |
127,133 | grpc/grpc-go | internal/transport/transport.go | TrailersOnly | func (s *Stream) TrailersOnly() (bool, error) {
err := s.waitOnHeader()
if err != nil {
return false, err
}
return s.noHeaders, nil
} | go | func (s *Stream) TrailersOnly() (bool, error) {
err := s.waitOnHeader()
if err != nil {
return false, err
}
return s.noHeaders, nil
} | [
"func",
"(",
"s",
"*",
"Stream",
")",
"TrailersOnly",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"err",
":=",
"s",
".",
"waitOnHeader",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n",
"return",
... | // TrailersOnly blocks until a header or trailers-only frame is received and
// then returns true if the stream was trailers-only. If the stream ends
// before headers are received, returns true, nil. If a context error happens
// first, returns it as a status error. Client-side only. | [
"TrailersOnly",
"blocks",
"until",
"a",
"header",
"or",
"trailers",
"-",
"only",
"frame",
"is",
"received",
"and",
"then",
"returns",
"true",
"if",
"the",
"stream",
"was",
"trailers",
"-",
"only",
".",
"If",
"the",
"stream",
"ends",
"before",
"headers",
"a... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/transport.go#L325-L331 |
127,134 | grpc/grpc-go | internal/transport/transport.go | Trailer | func (s *Stream) Trailer() metadata.MD {
c := s.trailer.Copy()
return c
} | go | func (s *Stream) Trailer() metadata.MD {
c := s.trailer.Copy()
return c
} | [
"func",
"(",
"s",
"*",
"Stream",
")",
"Trailer",
"(",
")",
"metadata",
".",
"MD",
"{",
"c",
":=",
"s",
".",
"trailer",
".",
"Copy",
"(",
")",
"\n",
"return",
"c",
"\n",
"}"
] | // Trailer returns the cached trailer metedata. Note that if it is not called
// after the entire stream is done, it could return an empty MD. Client
// side only.
// It can be safely read only after stream has ended that is either read
// or write have returned io.EOF. | [
"Trailer",
"returns",
"the",
"cached",
"trailer",
"metedata",
".",
"Note",
"that",
"if",
"it",
"is",
"not",
"called",
"after",
"the",
"entire",
"stream",
"is",
"done",
"it",
"could",
"return",
"an",
"empty",
"MD",
".",
"Client",
"side",
"only",
".",
"It"... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/transport.go#L338-L341 |
127,135 | grpc/grpc-go | internal/transport/transport.go | SetHeader | func (s *Stream) SetHeader(md metadata.MD) error {
if md.Len() == 0 {
return nil
}
if s.isHeaderSent() || s.getState() == streamDone {
return ErrIllegalHeaderWrite
}
s.hdrMu.Lock()
s.header = metadata.Join(s.header, md)
s.hdrMu.Unlock()
return nil
} | go | func (s *Stream) SetHeader(md metadata.MD) error {
if md.Len() == 0 {
return nil
}
if s.isHeaderSent() || s.getState() == streamDone {
return ErrIllegalHeaderWrite
}
s.hdrMu.Lock()
s.header = metadata.Join(s.header, md)
s.hdrMu.Unlock()
return nil
} | [
"func",
"(",
"s",
"*",
"Stream",
")",
"SetHeader",
"(",
"md",
"metadata",
".",
"MD",
")",
"error",
"{",
"if",
"md",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"s",
".",
"isHeaderSent",
"(",
")",
"||",
"s",
"... | // SetHeader sets the header metadata. This can be called multiple times.
// Server side only.
// This should not be called in parallel to other data writes. | [
"SetHeader",
"sets",
"the",
"header",
"metadata",
".",
"This",
"can",
"be",
"called",
"multiple",
"times",
".",
"Server",
"side",
"only",
".",
"This",
"should",
"not",
"be",
"called",
"in",
"parallel",
"to",
"other",
"data",
"writes",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/transport.go#L372-L383 |
127,136 | grpc/grpc-go | internal/transport/transport.go | SendHeader | func (s *Stream) SendHeader(md metadata.MD) error {
return s.st.WriteHeader(s, md)
} | go | func (s *Stream) SendHeader(md metadata.MD) error {
return s.st.WriteHeader(s, md)
} | [
"func",
"(",
"s",
"*",
"Stream",
")",
"SendHeader",
"(",
"md",
"metadata",
".",
"MD",
")",
"error",
"{",
"return",
"s",
".",
"st",
".",
"WriteHeader",
"(",
"s",
",",
"md",
")",
"\n",
"}"
] | // SendHeader sends the given header metadata. The given metadata is
// combined with any metadata set by previous calls to SetHeader and
// then written to the transport stream. | [
"SendHeader",
"sends",
"the",
"given",
"header",
"metadata",
".",
"The",
"given",
"metadata",
"is",
"combined",
"with",
"any",
"metadata",
"set",
"by",
"previous",
"calls",
"to",
"SetHeader",
"and",
"then",
"written",
"to",
"the",
"transport",
"stream",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/transport.go#L388-L390 |
127,137 | grpc/grpc-go | internal/transport/transport.go | SetTrailer | func (s *Stream) SetTrailer(md metadata.MD) error {
if md.Len() == 0 {
return nil
}
if s.getState() == streamDone {
return ErrIllegalHeaderWrite
}
s.hdrMu.Lock()
s.trailer = metadata.Join(s.trailer, md)
s.hdrMu.Unlock()
return nil
} | go | func (s *Stream) SetTrailer(md metadata.MD) error {
if md.Len() == 0 {
return nil
}
if s.getState() == streamDone {
return ErrIllegalHeaderWrite
}
s.hdrMu.Lock()
s.trailer = metadata.Join(s.trailer, md)
s.hdrMu.Unlock()
return nil
} | [
"func",
"(",
"s",
"*",
"Stream",
")",
"SetTrailer",
"(",
"md",
"metadata",
".",
"MD",
")",
"error",
"{",
"if",
"md",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"s",
".",
"getState",
"(",
")",
"==",
"streamDone... | // SetTrailer sets the trailer metadata which will be sent with the RPC status
// by the server. This can be called multiple times. Server side only.
// This should not be called parallel to other data writes. | [
"SetTrailer",
"sets",
"the",
"trailer",
"metadata",
"which",
"will",
"be",
"sent",
"with",
"the",
"RPC",
"status",
"by",
"the",
"server",
".",
"This",
"can",
"be",
"called",
"multiple",
"times",
".",
"Server",
"side",
"only",
".",
"This",
"should",
"not",
... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/transport.go#L395-L406 |
127,138 | grpc/grpc-go | internal/transport/transport.go | Read | func (s *Stream) Read(p []byte) (n int, err error) {
// Don't request a read if there was an error earlier
if er := s.trReader.(*transportReader).er; er != nil {
return 0, er
}
s.requestRead(len(p))
return io.ReadFull(s.trReader, p)
} | go | func (s *Stream) Read(p []byte) (n int, err error) {
// Don't request a read if there was an error earlier
if er := s.trReader.(*transportReader).er; er != nil {
return 0, er
}
s.requestRead(len(p))
return io.ReadFull(s.trReader, p)
} | [
"func",
"(",
"s",
"*",
"Stream",
")",
"Read",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"// Don't request a read if there was an error earlier",
"if",
"er",
":=",
"s",
".",
"trReader",
".",
"(",
"*",
"transportReade... | // Read reads all p bytes from the wire for this stream. | [
"Read",
"reads",
"all",
"p",
"bytes",
"from",
"the",
"wire",
"for",
"this",
"stream",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/transport.go#L413-L420 |
127,139 | grpc/grpc-go | internal/transport/transport.go | NewServerTransport | func NewServerTransport(protocol string, conn net.Conn, config *ServerConfig) (ServerTransport, error) {
return newHTTP2Server(conn, config)
} | go | func NewServerTransport(protocol string, conn net.Conn, config *ServerConfig) (ServerTransport, error) {
return newHTTP2Server(conn, config)
} | [
"func",
"NewServerTransport",
"(",
"protocol",
"string",
",",
"conn",
"net",
".",
"Conn",
",",
"config",
"*",
"ServerConfig",
")",
"(",
"ServerTransport",
",",
"error",
")",
"{",
"return",
"newHTTP2Server",
"(",
"conn",
",",
"config",
")",
"\n",
"}"
] | // NewServerTransport creates a ServerTransport with conn or non-nil error
// if it fails. | [
"NewServerTransport",
"creates",
"a",
"ServerTransport",
"with",
"conn",
"or",
"non",
"-",
"nil",
"error",
"if",
"it",
"fails",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/transport.go#L488-L490 |
127,140 | grpc/grpc-go | internal/transport/transport.go | NewClientTransport | func NewClientTransport(connectCtx, ctx context.Context, target TargetInfo, opts ConnectOptions, onPrefaceReceipt func(), onGoAway func(GoAwayReason), onClose func()) (ClientTransport, error) {
return newHTTP2Client(connectCtx, ctx, target, opts, onPrefaceReceipt, onGoAway, onClose)
} | go | func NewClientTransport(connectCtx, ctx context.Context, target TargetInfo, opts ConnectOptions, onPrefaceReceipt func(), onGoAway func(GoAwayReason), onClose func()) (ClientTransport, error) {
return newHTTP2Client(connectCtx, ctx, target, opts, onPrefaceReceipt, onGoAway, onClose)
} | [
"func",
"NewClientTransport",
"(",
"connectCtx",
",",
"ctx",
"context",
".",
"Context",
",",
"target",
"TargetInfo",
",",
"opts",
"ConnectOptions",
",",
"onPrefaceReceipt",
"func",
"(",
")",
",",
"onGoAway",
"func",
"(",
"GoAwayReason",
")",
",",
"onClose",
"f... | // NewClientTransport establishes the transport with the required ConnectOptions
// and returns it to the caller. | [
"NewClientTransport",
"establishes",
"the",
"transport",
"with",
"the",
"required",
"ConnectOptions",
"and",
"returns",
"it",
"to",
"the",
"caller",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/transport.go#L535-L537 |
127,141 | grpc/grpc-go | internal/transport/transport.go | connectionErrorf | func connectionErrorf(temp bool, e error, format string, a ...interface{}) ConnectionError {
return ConnectionError{
Desc: fmt.Sprintf(format, a...),
temp: temp,
err: e,
}
} | go | func connectionErrorf(temp bool, e error, format string, a ...interface{}) ConnectionError {
return ConnectionError{
Desc: fmt.Sprintf(format, a...),
temp: temp,
err: e,
}
} | [
"func",
"connectionErrorf",
"(",
"temp",
"bool",
",",
"e",
"error",
",",
"format",
"string",
",",
"a",
"...",
"interface",
"{",
"}",
")",
"ConnectionError",
"{",
"return",
"ConnectionError",
"{",
"Desc",
":",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"a... | // connectionErrorf creates an ConnectionError with the specified error description. | [
"connectionErrorf",
"creates",
"an",
"ConnectionError",
"with",
"the",
"specified",
"error",
"description",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/transport.go#L666-L672 |
127,142 | grpc/grpc-go | internal/transport/transport.go | Origin | func (e ConnectionError) Origin() error {
// Never return nil error here.
// If the original error is nil, return itself.
if e.err == nil {
return e
}
return e.err
} | go | func (e ConnectionError) Origin() error {
// Never return nil error here.
// If the original error is nil, return itself.
if e.err == nil {
return e
}
return e.err
} | [
"func",
"(",
"e",
"ConnectionError",
")",
"Origin",
"(",
")",
"error",
"{",
"// Never return nil error here.",
"// If the original error is nil, return itself.",
"if",
"e",
".",
"err",
"==",
"nil",
"{",
"return",
"e",
"\n",
"}",
"\n",
"return",
"e",
".",
"err",
... | // Origin returns the original error of this connection error. | [
"Origin",
"returns",
"the",
"original",
"error",
"of",
"this",
"connection",
"error",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/transport.go#L692-L699 |
127,143 | grpc/grpc-go | internal/transport/transport.go | ContextErr | func ContextErr(err error) error {
switch err {
case context.DeadlineExceeded:
return status.Error(codes.DeadlineExceeded, err.Error())
case context.Canceled:
return status.Error(codes.Canceled, err.Error())
}
return status.Errorf(codes.Internal, "Unexpected error from context packet: %v", err)
} | go | func ContextErr(err error) error {
switch err {
case context.DeadlineExceeded:
return status.Error(codes.DeadlineExceeded, err.Error())
case context.Canceled:
return status.Error(codes.Canceled, err.Error())
}
return status.Errorf(codes.Internal, "Unexpected error from context packet: %v", err)
} | [
"func",
"ContextErr",
"(",
"err",
"error",
")",
"error",
"{",
"switch",
"err",
"{",
"case",
"context",
".",
"DeadlineExceeded",
":",
"return",
"status",
".",
"Error",
"(",
"codes",
".",
"DeadlineExceeded",
",",
"err",
".",
"Error",
"(",
")",
")",
"\n",
... | // ContextErr converts the error from context package into a status error. | [
"ContextErr",
"converts",
"the",
"error",
"from",
"context",
"package",
"into",
"a",
"status",
"error",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/transport.go#L755-L763 |
127,144 | grpc/grpc-go | internal/backoff/backoff.go | Backoff | func (bc Exponential) Backoff(retries int) time.Duration {
if retries == 0 {
return baseDelay
}
backoff, max := float64(baseDelay), float64(bc.MaxDelay)
for backoff < max && retries > 0 {
backoff *= factor
retries--
}
if backoff > max {
backoff = max
}
// Randomize backoff delays so that if a cluster of... | go | func (bc Exponential) Backoff(retries int) time.Duration {
if retries == 0 {
return baseDelay
}
backoff, max := float64(baseDelay), float64(bc.MaxDelay)
for backoff < max && retries > 0 {
backoff *= factor
retries--
}
if backoff > max {
backoff = max
}
// Randomize backoff delays so that if a cluster of... | [
"func",
"(",
"bc",
"Exponential",
")",
"Backoff",
"(",
"retries",
"int",
")",
"time",
".",
"Duration",
"{",
"if",
"retries",
"==",
"0",
"{",
"return",
"baseDelay",
"\n",
"}",
"\n",
"backoff",
",",
"max",
":=",
"float64",
"(",
"baseDelay",
")",
",",
"... | // Backoff returns the amount of time to wait before the next retry given the
// number of retries. | [
"Backoff",
"returns",
"the",
"amount",
"of",
"time",
"to",
"wait",
"before",
"the",
"next",
"retry",
"given",
"the",
"number",
"of",
"retries",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/backoff/backoff.go#L59-L78 |
127,145 | grpc/grpc-go | peer/peer.go | NewContext | func NewContext(ctx context.Context, p *Peer) context.Context {
return context.WithValue(ctx, peerKey{}, p)
} | go | func NewContext(ctx context.Context, p *Peer) context.Context {
return context.WithValue(ctx, peerKey{}, p)
} | [
"func",
"NewContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"p",
"*",
"Peer",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"peerKey",
"{",
"}",
",",
"p",
")",
"\n",
"}"
] | // NewContext creates a new context with peer information attached. | [
"NewContext",
"creates",
"a",
"new",
"context",
"with",
"peer",
"information",
"attached",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/peer/peer.go#L43-L45 |
127,146 | grpc/grpc-go | peer/peer.go | FromContext | func FromContext(ctx context.Context) (p *Peer, ok bool) {
p, ok = ctx.Value(peerKey{}).(*Peer)
return
} | go | func FromContext(ctx context.Context) (p *Peer, ok bool) {
p, ok = ctx.Value(peerKey{}).(*Peer)
return
} | [
"func",
"FromContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"p",
"*",
"Peer",
",",
"ok",
"bool",
")",
"{",
"p",
",",
"ok",
"=",
"ctx",
".",
"Value",
"(",
"peerKey",
"{",
"}",
")",
".",
"(",
"*",
"Peer",
")",
"\n",
"return",
"\n",
... | // FromContext returns the peer information in ctx if it exists. | [
"FromContext",
"returns",
"the",
"peer",
"information",
"in",
"ctx",
"if",
"it",
"exists",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/peer/peer.go#L48-L51 |
127,147 | grpc/grpc-go | balancer_conn_wrappers.go | watcher | func (ccb *ccBalancerWrapper) watcher() {
for {
select {
case t := <-ccb.stateChangeQueue.get():
ccb.stateChangeQueue.load()
select {
case <-ccb.done:
ccb.balancer.Close()
return
default:
}
if ub, ok := ccb.balancer.(balancer.V2Balancer); ok {
ub.UpdateSubConnState(t.sc, balancer.SubC... | go | func (ccb *ccBalancerWrapper) watcher() {
for {
select {
case t := <-ccb.stateChangeQueue.get():
ccb.stateChangeQueue.load()
select {
case <-ccb.done:
ccb.balancer.Close()
return
default:
}
if ub, ok := ccb.balancer.(balancer.V2Balancer); ok {
ub.UpdateSubConnState(t.sc, balancer.SubC... | [
"func",
"(",
"ccb",
"*",
"ccBalancerWrapper",
")",
"watcher",
"(",
")",
"{",
"for",
"{",
"select",
"{",
"case",
"t",
":=",
"<-",
"ccb",
".",
"stateChangeQueue",
".",
"get",
"(",
")",
":",
"ccb",
".",
"stateChangeQueue",
".",
"load",
"(",
")",
"\n",
... | // watcher balancer functions sequentially, so the balancer can be implemented
// lock-free. | [
"watcher",
"balancer",
"functions",
"sequentially",
"so",
"the",
"balancer",
"can",
"be",
"implemented",
"lock",
"-",
"free",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/balancer_conn_wrappers.go#L113-L158 |
127,148 | grpc/grpc-go | benchmark/stats/util.go | startStatsInjector | func startStatsInjector() {
orgStdout = os.Stdout
r, w, _ := os.Pipe()
os.Stdout = w
nextOutPos = 0
resetCurBenchStats()
injectCond = sync.NewCond(&sync.Mutex{})
injectDone = make(chan struct{})
go func() {
defer close(injectDone)
scanner := bufio.NewScanner(r)
scanner.Split(splitLines)
for scanner.S... | go | func startStatsInjector() {
orgStdout = os.Stdout
r, w, _ := os.Pipe()
os.Stdout = w
nextOutPos = 0
resetCurBenchStats()
injectCond = sync.NewCond(&sync.Mutex{})
injectDone = make(chan struct{})
go func() {
defer close(injectDone)
scanner := bufio.NewScanner(r)
scanner.Split(splitLines)
for scanner.S... | [
"func",
"startStatsInjector",
"(",
")",
"{",
"orgStdout",
"=",
"os",
".",
"Stdout",
"\n",
"r",
",",
"w",
",",
"_",
":=",
"os",
".",
"Pipe",
"(",
")",
"\n",
"os",
".",
"Stdout",
"=",
"w",
"\n",
"nextOutPos",
"=",
"0",
"\n\n",
"resetCurBenchStats",
"... | // startStatsInjector starts stats injection to benchmark results. | [
"startStatsInjector",
"starts",
"stats",
"injection",
"to",
"benchmark",
"results",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/stats/util.go#L109-L131 |
127,149 | grpc/grpc-go | benchmark/stats/util.go | stopStatsInjector | func stopStatsInjector() {
os.Stdout.Close()
<-injectDone
injectCond = nil
os.Stdout = orgStdout
} | go | func stopStatsInjector() {
os.Stdout.Close()
<-injectDone
injectCond = nil
os.Stdout = orgStdout
} | [
"func",
"stopStatsInjector",
"(",
")",
"{",
"os",
".",
"Stdout",
".",
"Close",
"(",
")",
"\n",
"<-",
"injectDone",
"\n",
"injectCond",
"=",
"nil",
"\n",
"os",
".",
"Stdout",
"=",
"orgStdout",
"\n",
"}"
] | // stopStatsInjector stops stats injection and restores os.Stdout. | [
"stopStatsInjector",
"stops",
"stats",
"injection",
"and",
"restores",
"os",
".",
"Stdout",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/stats/util.go#L134-L139 |
127,150 | grpc/grpc-go | benchmark/stats/util.go | splitLines | func splitLines(data []byte, eof bool) (advance int, token []byte, err error) {
if eof && len(data) == 0 {
return 0, nil, nil
}
if i := bytes.IndexByte(data, '\n'); i >= 0 {
orgStdout.Write(data[nextOutPos : i+1])
nextOutPos = 0
return i + 1, data[0:i], nil
}
orgStdout.Write(data[nextOutPos:])
nextOutPo... | go | func splitLines(data []byte, eof bool) (advance int, token []byte, err error) {
if eof && len(data) == 0 {
return 0, nil, nil
}
if i := bytes.IndexByte(data, '\n'); i >= 0 {
orgStdout.Write(data[nextOutPos : i+1])
nextOutPos = 0
return i + 1, data[0:i], nil
}
orgStdout.Write(data[nextOutPos:])
nextOutPo... | [
"func",
"splitLines",
"(",
"data",
"[",
"]",
"byte",
",",
"eof",
"bool",
")",
"(",
"advance",
"int",
",",
"token",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"if",
"eof",
"&&",
"len",
"(",
"data",
")",
"==",
"0",
"{",
"return",
"0",
",",
... | // splitLines is a split function for a bufio.Scanner that returns each line
// of text, teeing texts to the original stdout even before each line ends. | [
"splitLines",
"is",
"a",
"split",
"function",
"for",
"a",
"bufio",
".",
"Scanner",
"that",
"returns",
"each",
"line",
"of",
"text",
"teeing",
"texts",
"to",
"the",
"original",
"stdout",
"even",
"before",
"each",
"line",
"ends",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/stats/util.go#L143-L163 |
127,151 | grpc/grpc-go | benchmark/stats/util.go | injectStatsIfFinished | func injectStatsIfFinished(line string) {
injectCond.L.Lock()
defer injectCond.L.Unlock()
// We assume that the benchmark results start with "Benchmark".
if curB == nil || !strings.HasPrefix(line, "Benchmark") {
return
}
if !curB.Failed() {
// Output all stats in alphabetical order.
names := make([]string,... | go | func injectStatsIfFinished(line string) {
injectCond.L.Lock()
defer injectCond.L.Unlock()
// We assume that the benchmark results start with "Benchmark".
if curB == nil || !strings.HasPrefix(line, "Benchmark") {
return
}
if !curB.Failed() {
// Output all stats in alphabetical order.
names := make([]string,... | [
"func",
"injectStatsIfFinished",
"(",
"line",
"string",
")",
"{",
"injectCond",
".",
"L",
".",
"Lock",
"(",
")",
"\n",
"defer",
"injectCond",
".",
"L",
".",
"Unlock",
"(",
")",
"\n",
"// We assume that the benchmark results start with \"Benchmark\".",
"if",
"curB"... | // injectStatsIfFinished prints out the stats if the current benchmark finishes. | [
"injectStatsIfFinished",
"prints",
"out",
"the",
"stats",
"if",
"the",
"current",
"benchmark",
"finishes",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/stats/util.go#L166-L201 |
127,152 | grpc/grpc-go | internal/channelz/funcs.go | GetTopChannels | func GetTopChannels(id int64, maxResults int64) ([]*ChannelMetric, bool) {
return db.get().GetTopChannels(id, maxResults)
} | go | func GetTopChannels(id int64, maxResults int64) ([]*ChannelMetric, bool) {
return db.get().GetTopChannels(id, maxResults)
} | [
"func",
"GetTopChannels",
"(",
"id",
"int64",
",",
"maxResults",
"int64",
")",
"(",
"[",
"]",
"*",
"ChannelMetric",
",",
"bool",
")",
"{",
"return",
"db",
".",
"get",
"(",
")",
".",
"GetTopChannels",
"(",
"id",
",",
"maxResults",
")",
"\n",
"}"
] | // GetTopChannels returns a slice of top channel's ChannelMetric, along with a
// boolean indicating whether there's more top channels to be queried for.
//
// The arg id specifies that only top channel with id at or above it will be included
// in the result. The returned slice is up to a length of the arg maxResults ... | [
"GetTopChannels",
"returns",
"a",
"slice",
"of",
"top",
"channel",
"s",
"ChannelMetric",
"along",
"with",
"a",
"boolean",
"indicating",
"whether",
"there",
"s",
"more",
"top",
"channels",
"to",
"be",
"queried",
"for",
".",
"The",
"arg",
"id",
"specifies",
"t... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/channelz/funcs.go#L146-L148 |
127,153 | grpc/grpc-go | internal/channelz/funcs.go | GetServers | func GetServers(id int64, maxResults int64) ([]*ServerMetric, bool) {
return db.get().GetServers(id, maxResults)
} | go | func GetServers(id int64, maxResults int64) ([]*ServerMetric, bool) {
return db.get().GetServers(id, maxResults)
} | [
"func",
"GetServers",
"(",
"id",
"int64",
",",
"maxResults",
"int64",
")",
"(",
"[",
"]",
"*",
"ServerMetric",
",",
"bool",
")",
"{",
"return",
"db",
".",
"get",
"(",
")",
".",
"GetServers",
"(",
"id",
",",
"maxResults",
")",
"\n",
"}"
] | // GetServers returns a slice of server's ServerMetric, along with a
// boolean indicating whether there's more servers to be queried for.
//
// The arg id specifies that only server with id at or above it will be included
// in the result. The returned slice is up to a length of the arg maxResults or
// EntryPerPage i... | [
"GetServers",
"returns",
"a",
"slice",
"of",
"server",
"s",
"ServerMetric",
"along",
"with",
"a",
"boolean",
"indicating",
"whether",
"there",
"s",
"more",
"servers",
"to",
"be",
"queried",
"for",
".",
"The",
"arg",
"id",
"specifies",
"that",
"only",
"server... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/channelz/funcs.go#L156-L158 |
127,154 | grpc/grpc-go | internal/channelz/funcs.go | RegisterServer | func RegisterServer(s Server, ref string) int64 {
id := idGen.genID()
svr := &server{
refName: ref,
s: s,
sockets: make(map[int64]string),
listenSockets: make(map[int64]string),
id: id,
}
db.get().addServer(id, svr)
return id
} | go | func RegisterServer(s Server, ref string) int64 {
id := idGen.genID()
svr := &server{
refName: ref,
s: s,
sockets: make(map[int64]string),
listenSockets: make(map[int64]string),
id: id,
}
db.get().addServer(id, svr)
return id
} | [
"func",
"RegisterServer",
"(",
"s",
"Server",
",",
"ref",
"string",
")",
"int64",
"{",
"id",
":=",
"idGen",
".",
"genID",
"(",
")",
"\n",
"svr",
":=",
"&",
"server",
"{",
"refName",
":",
"ref",
",",
"s",
":",
"s",
",",
"sockets",
":",
"make",
"("... | // RegisterServer registers the given server s in channelz database. It returns
// the unique channelz tracking id assigned to this server. | [
"RegisterServer",
"registers",
"the",
"given",
"server",
"s",
"in",
"channelz",
"database",
".",
"It",
"returns",
"the",
"unique",
"channelz",
"tracking",
"id",
"assigned",
"to",
"this",
"server",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/channelz/funcs.go#L237-L248 |
127,155 | grpc/grpc-go | internal/channelz/funcs.go | AddTraceEvent | func AddTraceEvent(id int64, desc *TraceEventDesc) {
if getMaxTraceEntry() == 0 {
return
}
db.get().traceEvent(id, desc)
} | go | func AddTraceEvent(id int64, desc *TraceEventDesc) {
if getMaxTraceEntry() == 0 {
return
}
db.get().traceEvent(id, desc)
} | [
"func",
"AddTraceEvent",
"(",
"id",
"int64",
",",
"desc",
"*",
"TraceEventDesc",
")",
"{",
"if",
"getMaxTraceEntry",
"(",
")",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n",
"db",
".",
"get",
"(",
")",
".",
"traceEvent",
"(",
"id",
",",
"desc",
")",
"\... | // AddTraceEvent adds trace related to the entity with specified id, using the provided TraceEventDesc. | [
"AddTraceEvent",
"adds",
"trace",
"related",
"to",
"the",
"entity",
"with",
"specified",
"id",
"using",
"the",
"provided",
"TraceEventDesc",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/channelz/funcs.go#L297-L302 |
127,156 | grpc/grpc-go | internal/channelz/funcs.go | removeEntry | func (c *channelMap) removeEntry(id int64) {
c.mu.Lock()
c.findEntry(id).triggerDelete()
c.mu.Unlock()
} | go | func (c *channelMap) removeEntry(id int64) {
c.mu.Lock()
c.findEntry(id).triggerDelete()
c.mu.Unlock()
} | [
"func",
"(",
"c",
"*",
"channelMap",
")",
"removeEntry",
"(",
"id",
"int64",
")",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"c",
".",
"findEntry",
"(",
"id",
")",
".",
"triggerDelete",
"(",
")",
"\n",
"c",
".",
"mu",
".",
"Unlock",
"(",... | // removeEntry triggers the removal of an entry, which may not indeed delete the entry, if it has to
// wait on the deletion of its children and until no other entity's channel trace references it.
// It may lead to a chain of entry deletion. For example, deleting the last socket of a gracefully
// shutting down server... | [
"removeEntry",
"triggers",
"the",
"removal",
"of",
"an",
"entry",
"which",
"may",
"not",
"indeed",
"delete",
"the",
"entry",
"if",
"it",
"has",
"to",
"wait",
"on",
"the",
"deletion",
"of",
"its",
"children",
"and",
"until",
"no",
"other",
"entity",
"s",
... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/channelz/funcs.go#L368-L372 |
127,157 | grpc/grpc-go | internal/channelz/funcs.go | decrTraceRefCount | func (c *channelMap) decrTraceRefCount(id int64) {
e := c.findEntry(id)
if v, ok := e.(tracedChannel); ok {
v.decrTraceRefCount()
e.deleteSelfIfReady()
}
} | go | func (c *channelMap) decrTraceRefCount(id int64) {
e := c.findEntry(id)
if v, ok := e.(tracedChannel); ok {
v.decrTraceRefCount()
e.deleteSelfIfReady()
}
} | [
"func",
"(",
"c",
"*",
"channelMap",
")",
"decrTraceRefCount",
"(",
"id",
"int64",
")",
"{",
"e",
":=",
"c",
".",
"findEntry",
"(",
"id",
")",
"\n",
"if",
"v",
",",
"ok",
":=",
"e",
".",
"(",
"tracedChannel",
")",
";",
"ok",
"{",
"v",
".",
"dec... | // c.mu must be held by the caller | [
"c",
".",
"mu",
"must",
"be",
"held",
"by",
"the",
"caller"
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/channelz/funcs.go#L375-L381 |
127,158 | grpc/grpc-go | internal/channelz/funcs.go | findEntry | func (c *channelMap) findEntry(id int64) entry {
var v entry
var ok bool
if v, ok = c.channels[id]; ok {
return v
}
if v, ok = c.subChannels[id]; ok {
return v
}
if v, ok = c.servers[id]; ok {
return v
}
if v, ok = c.listenSockets[id]; ok {
return v
}
if v, ok = c.normalSockets[id]; ok {
return v
... | go | func (c *channelMap) findEntry(id int64) entry {
var v entry
var ok bool
if v, ok = c.channels[id]; ok {
return v
}
if v, ok = c.subChannels[id]; ok {
return v
}
if v, ok = c.servers[id]; ok {
return v
}
if v, ok = c.listenSockets[id]; ok {
return v
}
if v, ok = c.normalSockets[id]; ok {
return v
... | [
"func",
"(",
"c",
"*",
"channelMap",
")",
"findEntry",
"(",
"id",
"int64",
")",
"entry",
"{",
"var",
"v",
"entry",
"\n",
"var",
"ok",
"bool",
"\n",
"if",
"v",
",",
"ok",
"=",
"c",
".",
"channels",
"[",
"id",
"]",
";",
"ok",
"{",
"return",
"v",
... | // c.mu must be held by the caller. | [
"c",
".",
"mu",
"must",
"be",
"held",
"by",
"the",
"caller",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/channelz/funcs.go#L384-L403 |
127,159 | grpc/grpc-go | preloader.go | Encode | func (p *PreparedMsg) Encode(s Stream, msg interface{}) error {
ctx := s.Context()
rpcInfo, ok := rpcInfoFromContext(ctx)
if !ok {
return status.Errorf(codes.Internal, "grpc: unable to get rpcInfo")
}
// check if the context has the relevant information to prepareMsg
if rpcInfo.preloaderInfo == nil {
return ... | go | func (p *PreparedMsg) Encode(s Stream, msg interface{}) error {
ctx := s.Context()
rpcInfo, ok := rpcInfoFromContext(ctx)
if !ok {
return status.Errorf(codes.Internal, "grpc: unable to get rpcInfo")
}
// check if the context has the relevant information to prepareMsg
if rpcInfo.preloaderInfo == nil {
return ... | [
"func",
"(",
"p",
"*",
"PreparedMsg",
")",
"Encode",
"(",
"s",
"Stream",
",",
"msg",
"interface",
"{",
"}",
")",
"error",
"{",
"ctx",
":=",
"s",
".",
"Context",
"(",
")",
"\n",
"rpcInfo",
",",
"ok",
":=",
"rpcInfoFromContext",
"(",
"ctx",
")",
"\n"... | // Encode marshalls and compresses the message using the codec and compressor for the stream. | [
"Encode",
"marshalls",
"and",
"compresses",
"the",
"message",
"using",
"the",
"codec",
"and",
"compressor",
"for",
"the",
"stream",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/preloader.go#L37-L64 |
127,160 | grpc/grpc-go | proxy.go | newProxyDialer | func newProxyDialer(dialer func(context.Context, string) (net.Conn, error)) func(context.Context, string) (net.Conn, error) {
return func(ctx context.Context, addr string) (conn net.Conn, err error) {
var newAddr string
proxyURL, err := mapAddress(ctx, addr)
if err != nil {
if err != errDisabled {
return ... | go | func newProxyDialer(dialer func(context.Context, string) (net.Conn, error)) func(context.Context, string) (net.Conn, error) {
return func(ctx context.Context, addr string) (conn net.Conn, err error) {
var newAddr string
proxyURL, err := mapAddress(ctx, addr)
if err != nil {
if err != errDisabled {
return ... | [
"func",
"newProxyDialer",
"(",
"dialer",
"func",
"(",
"context",
".",
"Context",
",",
"string",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
")",
"func",
"(",
"context",
".",
"Context",
",",
"string",
")",
"(",
"net",
".",
"Conn",
",",
"error",
... | // newProxyDialer returns a dialer that connects to proxy first if necessary.
// The returned dialer checks if a proxy is necessary, dial to the proxy with the
// provided dialer, does HTTP CONNECT handshake and returns the connection. | [
"newProxyDialer",
"returns",
"a",
"dialer",
"that",
"connects",
"to",
"proxy",
"first",
"if",
"necessary",
".",
"The",
"returned",
"dialer",
"checks",
"if",
"a",
"proxy",
"is",
"necessary",
"dial",
"to",
"the",
"proxy",
"with",
"the",
"provided",
"dialer",
"... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/proxy.go#L121-L144 |
127,161 | grpc/grpc-go | stress/client/main.go | GetAllGauges | func (s *server) GetAllGauges(in *metricspb.EmptyMessage, stream metricspb.MetricsService_GetAllGaugesServer) error {
s.mutex.RLock()
defer s.mutex.RUnlock()
for name, gauge := range s.gauges {
if err := stream.Send(&metricspb.GaugeResponse{Name: name, Value: &metricspb.GaugeResponse_LongValue{LongValue: gauge.ge... | go | func (s *server) GetAllGauges(in *metricspb.EmptyMessage, stream metricspb.MetricsService_GetAllGaugesServer) error {
s.mutex.RLock()
defer s.mutex.RUnlock()
for name, gauge := range s.gauges {
if err := stream.Send(&metricspb.GaugeResponse{Name: name, Value: &metricspb.GaugeResponse_LongValue{LongValue: gauge.ge... | [
"func",
"(",
"s",
"*",
"server",
")",
"GetAllGauges",
"(",
"in",
"*",
"metricspb",
".",
"EmptyMessage",
",",
"stream",
"metricspb",
".",
"MetricsService_GetAllGaugesServer",
")",
"error",
"{",
"s",
".",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
... | // GetAllGauges returns all gauges. | [
"GetAllGauges",
"returns",
"all",
"gauges",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/stress/client/main.go#L160-L170 |
127,162 | grpc/grpc-go | stress/client/main.go | GetGauge | func (s *server) GetGauge(ctx context.Context, in *metricspb.GaugeRequest) (*metricspb.GaugeResponse, error) {
s.mutex.RLock()
defer s.mutex.RUnlock()
if g, ok := s.gauges[in.Name]; ok {
return &metricspb.GaugeResponse{Name: in.Name, Value: &metricspb.GaugeResponse_LongValue{LongValue: g.get()}}, nil
}
return n... | go | func (s *server) GetGauge(ctx context.Context, in *metricspb.GaugeRequest) (*metricspb.GaugeResponse, error) {
s.mutex.RLock()
defer s.mutex.RUnlock()
if g, ok := s.gauges[in.Name]; ok {
return &metricspb.GaugeResponse{Name: in.Name, Value: &metricspb.GaugeResponse_LongValue{LongValue: g.get()}}, nil
}
return n... | [
"func",
"(",
"s",
"*",
"server",
")",
"GetGauge",
"(",
"ctx",
"context",
".",
"Context",
",",
"in",
"*",
"metricspb",
".",
"GaugeRequest",
")",
"(",
"*",
"metricspb",
".",
"GaugeResponse",
",",
"error",
")",
"{",
"s",
".",
"mutex",
".",
"RLock",
"(",... | // GetGauge returns the gauge for the given name. | [
"GetGauge",
"returns",
"the",
"gauge",
"for",
"the",
"given",
"name",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/stress/client/main.go#L173-L181 |
127,163 | grpc/grpc-go | stress/client/main.go | createGauge | func (s *server) createGauge(name string) *gauge {
s.mutex.Lock()
defer s.mutex.Unlock()
if _, ok := s.gauges[name]; ok {
// gauge already exists.
panic(fmt.Sprintf("gauge %s already exists", name))
}
var g gauge
s.gauges[name] = &g
return &g
} | go | func (s *server) createGauge(name string) *gauge {
s.mutex.Lock()
defer s.mutex.Unlock()
if _, ok := s.gauges[name]; ok {
// gauge already exists.
panic(fmt.Sprintf("gauge %s already exists", name))
}
var g gauge
s.gauges[name] = &g
return &g
} | [
"func",
"(",
"s",
"*",
"server",
")",
"createGauge",
"(",
"name",
"string",
")",
"*",
"gauge",
"{",
"s",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"_",
",",
"ok",
":=",
"s",
... | // createGauge creates a gauge using the given name in metrics server. | [
"createGauge",
"creates",
"a",
"gauge",
"using",
"the",
"given",
"name",
"in",
"metrics",
"server",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/stress/client/main.go#L184-L195 |
127,164 | grpc/grpc-go | stress/client/main.go | performRPCs | func performRPCs(gauge *gauge, conn *grpc.ClientConn, selector *weightedRandomTestSelector, stop <-chan bool) {
client := testpb.NewTestServiceClient(conn)
var numCalls int64
startTime := time.Now()
for {
test := selector.getNextTest()
switch test {
case "empty_unary":
interop.DoEmptyUnaryCall(client, grpc... | go | func performRPCs(gauge *gauge, conn *grpc.ClientConn, selector *weightedRandomTestSelector, stop <-chan bool) {
client := testpb.NewTestServiceClient(conn)
var numCalls int64
startTime := time.Now()
for {
test := selector.getNextTest()
switch test {
case "empty_unary":
interop.DoEmptyUnaryCall(client, grpc... | [
"func",
"performRPCs",
"(",
"gauge",
"*",
"gauge",
",",
"conn",
"*",
"grpc",
".",
"ClientConn",
",",
"selector",
"*",
"weightedRandomTestSelector",
",",
"stop",
"<-",
"chan",
"bool",
")",
"{",
"client",
":=",
"testpb",
".",
"NewTestServiceClient",
"(",
"conn... | // performRPCs uses weightedRandomTestSelector to select test case and runs the tests. | [
"performRPCs",
"uses",
"weightedRandomTestSelector",
"to",
"select",
"test",
"case",
"and",
"runs",
"the",
"tests",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/stress/client/main.go#L210-L249 |
127,165 | grpc/grpc-go | internal/binarylog/sink.go | NewTempFileSink | func NewTempFileSink() (Sink, error) {
tempFile, err := ioutil.TempFile("/tmp", "grpcgo_binarylog_*.txt")
if err != nil {
return nil, fmt.Errorf("failed to create temp file: %v", err)
}
return newBufWriteCloserSink(tempFile), nil
} | go | func NewTempFileSink() (Sink, error) {
tempFile, err := ioutil.TempFile("/tmp", "grpcgo_binarylog_*.txt")
if err != nil {
return nil, fmt.Errorf("failed to create temp file: %v", err)
}
return newBufWriteCloserSink(tempFile), nil
} | [
"func",
"NewTempFileSink",
"(",
")",
"(",
"Sink",
",",
"error",
")",
"{",
"tempFile",
",",
"err",
":=",
"ioutil",
".",
"TempFile",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Erro... | // NewTempFileSink creates a temp file and returns a Sink that writes to this
// file. | [
"NewTempFileSink",
"creates",
"a",
"temp",
"file",
"and",
"returns",
"a",
"Sink",
"that",
"writes",
"to",
"this",
"file",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/binarylog/sink.go#L156-L162 |
127,166 | grpc/grpc-go | call.go | Invoke | func (cc *ClientConn) Invoke(ctx context.Context, method string, args, reply interface{}, opts ...CallOption) error {
// allow interceptor to see all applicable call options, which means those
// configured as defaults from dial option as well as per-call options
opts = combine(cc.dopts.callOptions, opts)
if cc.do... | go | func (cc *ClientConn) Invoke(ctx context.Context, method string, args, reply interface{}, opts ...CallOption) error {
// allow interceptor to see all applicable call options, which means those
// configured as defaults from dial option as well as per-call options
opts = combine(cc.dopts.callOptions, opts)
if cc.do... | [
"func",
"(",
"cc",
"*",
"ClientConn",
")",
"Invoke",
"(",
"ctx",
"context",
".",
"Context",
",",
"method",
"string",
",",
"args",
",",
"reply",
"interface",
"{",
"}",
",",
"opts",
"...",
"CallOption",
")",
"error",
"{",
"// allow interceptor to see all appli... | // Invoke sends the RPC request on the wire and returns after response is
// received. This is typically called by generated code.
//
// All errors returned by Invoke are compatible with the status package. | [
"Invoke",
"sends",
"the",
"RPC",
"request",
"on",
"the",
"wire",
"and",
"returns",
"after",
"response",
"is",
"received",
".",
"This",
"is",
"typically",
"called",
"by",
"generated",
"code",
".",
"All",
"errors",
"returned",
"by",
"Invoke",
"are",
"compatibl... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/call.go#L29-L38 |
127,167 | grpc/grpc-go | metadata/metadata.go | Get | func (md MD) Get(k string) []string {
k = strings.ToLower(k)
return md[k]
} | go | func (md MD) Get(k string) []string {
k = strings.ToLower(k)
return md[k]
} | [
"func",
"(",
"md",
"MD",
")",
"Get",
"(",
"k",
"string",
")",
"[",
"]",
"string",
"{",
"k",
"=",
"strings",
".",
"ToLower",
"(",
"k",
")",
"\n",
"return",
"md",
"[",
"k",
"]",
"\n",
"}"
] | // Get obtains the values for a given key. | [
"Get",
"obtains",
"the",
"values",
"for",
"a",
"given",
"key",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/metadata/metadata.go#L100-L103 |
127,168 | grpc/grpc-go | metadata/metadata.go | Set | func (md MD) Set(k string, vals ...string) {
if len(vals) == 0 {
return
}
k = strings.ToLower(k)
md[k] = vals
} | go | func (md MD) Set(k string, vals ...string) {
if len(vals) == 0 {
return
}
k = strings.ToLower(k)
md[k] = vals
} | [
"func",
"(",
"md",
"MD",
")",
"Set",
"(",
"k",
"string",
",",
"vals",
"...",
"string",
")",
"{",
"if",
"len",
"(",
"vals",
")",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n",
"k",
"=",
"strings",
".",
"ToLower",
"(",
"k",
")",
"\n",
"md",
"[",
... | // Set sets the value of a given key with a slice of values. | [
"Set",
"sets",
"the",
"value",
"of",
"a",
"given",
"key",
"with",
"a",
"slice",
"of",
"values",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/metadata/metadata.go#L106-L112 |
127,169 | grpc/grpc-go | metadata/metadata.go | Append | func (md MD) Append(k string, vals ...string) {
if len(vals) == 0 {
return
}
k = strings.ToLower(k)
md[k] = append(md[k], vals...)
} | go | func (md MD) Append(k string, vals ...string) {
if len(vals) == 0 {
return
}
k = strings.ToLower(k)
md[k] = append(md[k], vals...)
} | [
"func",
"(",
"md",
"MD",
")",
"Append",
"(",
"k",
"string",
",",
"vals",
"...",
"string",
")",
"{",
"if",
"len",
"(",
"vals",
")",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n",
"k",
"=",
"strings",
".",
"ToLower",
"(",
"k",
")",
"\n",
"md",
"[",... | // Append adds the values to key k, not overwriting what was already stored at that key. | [
"Append",
"adds",
"the",
"values",
"to",
"key",
"k",
"not",
"overwriting",
"what",
"was",
"already",
"stored",
"at",
"that",
"key",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/metadata/metadata.go#L115-L121 |
127,170 | grpc/grpc-go | metadata/metadata.go | Join | func Join(mds ...MD) MD {
out := MD{}
for _, md := range mds {
for k, v := range md {
out[k] = append(out[k], v...)
}
}
return out
} | go | func Join(mds ...MD) MD {
out := MD{}
for _, md := range mds {
for k, v := range md {
out[k] = append(out[k], v...)
}
}
return out
} | [
"func",
"Join",
"(",
"mds",
"...",
"MD",
")",
"MD",
"{",
"out",
":=",
"MD",
"{",
"}",
"\n",
"for",
"_",
",",
"md",
":=",
"range",
"mds",
"{",
"for",
"k",
",",
"v",
":=",
"range",
"md",
"{",
"out",
"[",
"k",
"]",
"=",
"append",
"(",
"out",
... | // Join joins any number of mds into a single MD.
// The order of values for each key is determined by the order in which
// the mds containing those values are presented to Join. | [
"Join",
"joins",
"any",
"number",
"of",
"mds",
"into",
"a",
"single",
"MD",
".",
"The",
"order",
"of",
"values",
"for",
"each",
"key",
"is",
"determined",
"by",
"the",
"order",
"in",
"which",
"the",
"mds",
"containing",
"those",
"values",
"are",
"present... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/metadata/metadata.go#L126-L134 |
127,171 | grpc/grpc-go | metadata/metadata.go | NewIncomingContext | func NewIncomingContext(ctx context.Context, md MD) context.Context {
return context.WithValue(ctx, mdIncomingKey{}, md)
} | go | func NewIncomingContext(ctx context.Context, md MD) context.Context {
return context.WithValue(ctx, mdIncomingKey{}, md)
} | [
"func",
"NewIncomingContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"md",
"MD",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"mdIncomingKey",
"{",
"}",
",",
"md",
")",
"\n",
"}"
] | // NewIncomingContext creates a new context with incoming md attached. | [
"NewIncomingContext",
"creates",
"a",
"new",
"context",
"with",
"incoming",
"md",
"attached",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/metadata/metadata.go#L140-L142 |
127,172 | grpc/grpc-go | metadata/metadata.go | NewOutgoingContext | func NewOutgoingContext(ctx context.Context, md MD) context.Context {
return context.WithValue(ctx, mdOutgoingKey{}, rawMD{md: md})
} | go | func NewOutgoingContext(ctx context.Context, md MD) context.Context {
return context.WithValue(ctx, mdOutgoingKey{}, rawMD{md: md})
} | [
"func",
"NewOutgoingContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"md",
"MD",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"mdOutgoingKey",
"{",
"}",
",",
"rawMD",
"{",
"md",
":",
"md",
"}",
")",
... | // NewOutgoingContext creates a new context with outgoing md attached. If used
// in conjunction with AppendToOutgoingContext, NewOutgoingContext will
// overwrite any previously-appended metadata. | [
"NewOutgoingContext",
"creates",
"a",
"new",
"context",
"with",
"outgoing",
"md",
"attached",
".",
"If",
"used",
"in",
"conjunction",
"with",
"AppendToOutgoingContext",
"NewOutgoingContext",
"will",
"overwrite",
"any",
"previously",
"-",
"appended",
"metadata",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/metadata/metadata.go#L147-L149 |
127,173 | grpc/grpc-go | metadata/metadata.go | AppendToOutgoingContext | func AppendToOutgoingContext(ctx context.Context, kv ...string) context.Context {
if len(kv)%2 == 1 {
panic(fmt.Sprintf("metadata: AppendToOutgoingContext got an odd number of input pairs for metadata: %d", len(kv)))
}
md, _ := ctx.Value(mdOutgoingKey{}).(rawMD)
added := make([][]string, len(md.added)+1)
copy(ad... | go | func AppendToOutgoingContext(ctx context.Context, kv ...string) context.Context {
if len(kv)%2 == 1 {
panic(fmt.Sprintf("metadata: AppendToOutgoingContext got an odd number of input pairs for metadata: %d", len(kv)))
}
md, _ := ctx.Value(mdOutgoingKey{}).(rawMD)
added := make([][]string, len(md.added)+1)
copy(ad... | [
"func",
"AppendToOutgoingContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"kv",
"...",
"string",
")",
"context",
".",
"Context",
"{",
"if",
"len",
"(",
"kv",
")",
"%",
"2",
"==",
"1",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
... | // AppendToOutgoingContext returns a new context with the provided kv merged
// with any existing metadata in the context. Please refer to the
// documentation of Pairs for a description of kv. | [
"AppendToOutgoingContext",
"returns",
"a",
"new",
"context",
"with",
"the",
"provided",
"kv",
"merged",
"with",
"any",
"existing",
"metadata",
"in",
"the",
"context",
".",
"Please",
"refer",
"to",
"the",
"documentation",
"of",
"Pairs",
"for",
"a",
"description",... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/metadata/metadata.go#L154-L164 |
127,174 | grpc/grpc-go | metadata/metadata.go | FromIncomingContext | func FromIncomingContext(ctx context.Context) (md MD, ok bool) {
md, ok = ctx.Value(mdIncomingKey{}).(MD)
return
} | go | func FromIncomingContext(ctx context.Context) (md MD, ok bool) {
md, ok = ctx.Value(mdIncomingKey{}).(MD)
return
} | [
"func",
"FromIncomingContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"md",
"MD",
",",
"ok",
"bool",
")",
"{",
"md",
",",
"ok",
"=",
"ctx",
".",
"Value",
"(",
"mdIncomingKey",
"{",
"}",
")",
".",
"(",
"MD",
")",
"\n",
"return",
"\n",
"}... | // FromIncomingContext returns the incoming metadata in ctx if it exists. The
// returned MD should not be modified. Writing to it may cause races.
// Modification should be made to copies of the returned MD. | [
"FromIncomingContext",
"returns",
"the",
"incoming",
"metadata",
"in",
"ctx",
"if",
"it",
"exists",
".",
"The",
"returned",
"MD",
"should",
"not",
"be",
"modified",
".",
"Writing",
"to",
"it",
"may",
"cause",
"races",
".",
"Modification",
"should",
"be",
"ma... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/metadata/metadata.go#L169-L172 |
127,175 | grpc/grpc-go | metadata/metadata.go | FromOutgoingContextRaw | func FromOutgoingContextRaw(ctx context.Context) (MD, [][]string, bool) {
raw, ok := ctx.Value(mdOutgoingKey{}).(rawMD)
if !ok {
return nil, nil, false
}
return raw.md, raw.added, true
} | go | func FromOutgoingContextRaw(ctx context.Context) (MD, [][]string, bool) {
raw, ok := ctx.Value(mdOutgoingKey{}).(rawMD)
if !ok {
return nil, nil, false
}
return raw.md, raw.added, true
} | [
"func",
"FromOutgoingContextRaw",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"MD",
",",
"[",
"]",
"[",
"]",
"string",
",",
"bool",
")",
"{",
"raw",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"mdOutgoingKey",
"{",
"}",
")",
".",
"(",
"rawMD",
... | // FromOutgoingContextRaw returns the un-merged, intermediary contents
// of rawMD. Remember to perform strings.ToLower on the keys. The returned
// MD should not be modified. Writing to it may cause races. Modification
// should be made to copies of the returned MD.
//
// This is intended for gRPC-internal use ONLY. | [
"FromOutgoingContextRaw",
"returns",
"the",
"un",
"-",
"merged",
"intermediary",
"contents",
"of",
"rawMD",
".",
"Remember",
"to",
"perform",
"strings",
".",
"ToLower",
"on",
"the",
"keys",
".",
"The",
"returned",
"MD",
"should",
"not",
"be",
"modified",
".",
... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/metadata/metadata.go#L180-L187 |
127,176 | grpc/grpc-go | metadata/metadata.go | FromOutgoingContext | func FromOutgoingContext(ctx context.Context) (MD, bool) {
raw, ok := ctx.Value(mdOutgoingKey{}).(rawMD)
if !ok {
return nil, false
}
mds := make([]MD, 0, len(raw.added)+1)
mds = append(mds, raw.md)
for _, vv := range raw.added {
mds = append(mds, Pairs(vv...))
}
return Join(mds...), ok
} | go | func FromOutgoingContext(ctx context.Context) (MD, bool) {
raw, ok := ctx.Value(mdOutgoingKey{}).(rawMD)
if !ok {
return nil, false
}
mds := make([]MD, 0, len(raw.added)+1)
mds = append(mds, raw.md)
for _, vv := range raw.added {
mds = append(mds, Pairs(vv...))
}
return Join(mds...), ok
} | [
"func",
"FromOutgoingContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"MD",
",",
"bool",
")",
"{",
"raw",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"mdOutgoingKey",
"{",
"}",
")",
".",
"(",
"rawMD",
")",
"\n",
"if",
"!",
"ok",
"{",
"re... | // FromOutgoingContext returns the outgoing metadata in ctx if it exists. The
// returned MD should not be modified. Writing to it may cause races.
// Modification should be made to copies of the returned MD. | [
"FromOutgoingContext",
"returns",
"the",
"outgoing",
"metadata",
"in",
"ctx",
"if",
"it",
"exists",
".",
"The",
"returned",
"MD",
"should",
"not",
"be",
"modified",
".",
"Writing",
"to",
"it",
"may",
"cause",
"races",
".",
"Modification",
"should",
"be",
"ma... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/metadata/metadata.go#L192-L204 |
127,177 | grpc/grpc-go | internal/binarylog/method_logger.go | Log | func (ml *MethodLogger) Log(c LogEntryConfig) {
m := c.toProto()
timestamp, _ := ptypes.TimestampProto(time.Now())
m.Timestamp = timestamp
m.CallId = ml.callID
m.SequenceIdWithinCall = ml.idWithinCallGen.next()
switch pay := m.Payload.(type) {
case *pb.GrpcLogEntry_ClientHeader:
m.PayloadTruncated = ml.trunca... | go | func (ml *MethodLogger) Log(c LogEntryConfig) {
m := c.toProto()
timestamp, _ := ptypes.TimestampProto(time.Now())
m.Timestamp = timestamp
m.CallId = ml.callID
m.SequenceIdWithinCall = ml.idWithinCallGen.next()
switch pay := m.Payload.(type) {
case *pb.GrpcLogEntry_ClientHeader:
m.PayloadTruncated = ml.trunca... | [
"func",
"(",
"ml",
"*",
"MethodLogger",
")",
"Log",
"(",
"c",
"LogEntryConfig",
")",
"{",
"m",
":=",
"c",
".",
"toProto",
"(",
")",
"\n",
"timestamp",
",",
"_",
":=",
"ptypes",
".",
"TimestampProto",
"(",
"time",
".",
"Now",
"(",
")",
")",
"\n",
... | // Log creates a proto binary log entry, and logs it to the sink. | [
"Log",
"creates",
"a",
"proto",
"binary",
"log",
"entry",
"and",
"logs",
"it",
"to",
"the",
"sink",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/binarylog/method_logger.go#L74-L91 |
127,178 | grpc/grpc-go | internal/binarylog/method_logger.go | metadataKeyOmit | func metadataKeyOmit(key string) bool {
switch key {
case "lb-token", ":path", ":authority", "content-encoding", "content-type", "user-agent", "te":
return true
case "grpc-trace-bin": // grpc-trace-bin is special because it's visiable to users.
return false
}
return strings.HasPrefix(key, "grpc-")
} | go | func metadataKeyOmit(key string) bool {
switch key {
case "lb-token", ":path", ":authority", "content-encoding", "content-type", "user-agent", "te":
return true
case "grpc-trace-bin": // grpc-trace-bin is special because it's visiable to users.
return false
}
return strings.HasPrefix(key, "grpc-")
} | [
"func",
"metadataKeyOmit",
"(",
"key",
"string",
")",
"bool",
"{",
"switch",
"key",
"{",
"case",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
":",
"return",
"true",
"\n",
"cas... | // metadataKeyOmit returns whether the metadata entry with this key should be
// omitted. | [
"metadataKeyOmit",
"returns",
"whether",
"the",
"metadata",
"entry",
"with",
"this",
"key",
"should",
"be",
"omitted",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/binarylog/method_logger.go#L373-L381 |
127,179 | grpc/grpc-go | stream.go | NewClientStream | func NewClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, opts ...CallOption) (ClientStream, error) {
return cc.NewStream(ctx, desc, method, opts...)
} | go | func NewClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, opts ...CallOption) (ClientStream, error) {
return cc.NewStream(ctx, desc, method, opts...)
} | [
"func",
"NewClientStream",
"(",
"ctx",
"context",
".",
"Context",
",",
"desc",
"*",
"StreamDesc",
",",
"cc",
"*",
"ClientConn",
",",
"method",
"string",
",",
"opts",
"...",
"CallOption",
")",
"(",
"ClientStream",
",",
"error",
")",
"{",
"return",
"cc",
"... | // NewClientStream is a wrapper for ClientConn.NewStream. | [
"NewClientStream",
"is",
"a",
"wrapper",
"for",
"ClientConn",
".",
"NewStream",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/stream.go#L155-L157 |
127,180 | grpc/grpc-go | stream.go | retryLocked | func (cs *clientStream) retryLocked(lastErr error) error {
for {
cs.attempt.finish(lastErr)
if err := cs.shouldRetry(lastErr); err != nil {
cs.commitAttemptLocked()
return err
}
if err := cs.newAttemptLocked(nil, nil); err != nil {
return err
}
if lastErr = cs.replayBufferLocked(); lastErr == nil ... | go | func (cs *clientStream) retryLocked(lastErr error) error {
for {
cs.attempt.finish(lastErr)
if err := cs.shouldRetry(lastErr); err != nil {
cs.commitAttemptLocked()
return err
}
if err := cs.newAttemptLocked(nil, nil); err != nil {
return err
}
if lastErr = cs.replayBufferLocked(); lastErr == nil ... | [
"func",
"(",
"cs",
"*",
"clientStream",
")",
"retryLocked",
"(",
"lastErr",
"error",
")",
"error",
"{",
"for",
"{",
"cs",
".",
"attempt",
".",
"finish",
"(",
"lastErr",
")",
"\n",
"if",
"err",
":=",
"cs",
".",
"shouldRetry",
"(",
"lastErr",
")",
";",... | // Returns nil if a retry was performed and succeeded; error otherwise. | [
"Returns",
"nil",
"if",
"a",
"retry",
"was",
"performed",
"and",
"succeeded",
";",
"error",
"otherwise",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/stream.go#L545-L559 |
127,181 | grpc/grpc-go | stream.go | prepareMsg | func prepareMsg(m interface{}, codec baseCodec, cp Compressor, comp encoding.Compressor) (hdr, payload, data []byte, err error) {
if preparedMsg, ok := m.(*PreparedMsg); ok {
return preparedMsg.hdr, preparedMsg.payload, preparedMsg.encodedData, nil
}
// The input interface is not a prepared msg.
// Marshal and Co... | go | func prepareMsg(m interface{}, codec baseCodec, cp Compressor, comp encoding.Compressor) (hdr, payload, data []byte, err error) {
if preparedMsg, ok := m.(*PreparedMsg); ok {
return preparedMsg.hdr, preparedMsg.payload, preparedMsg.encodedData, nil
}
// The input interface is not a prepared msg.
// Marshal and Co... | [
"func",
"prepareMsg",
"(",
"m",
"interface",
"{",
"}",
",",
"codec",
"baseCodec",
",",
"cp",
"Compressor",
",",
"comp",
"encoding",
".",
"Compressor",
")",
"(",
"hdr",
",",
"payload",
",",
"data",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"if"... | // prepareMsg returns the hdr, payload and data
// using the compressors passed or using the
// passed preparedmsg | [
"prepareMsg",
"returns",
"the",
"hdr",
"payload",
"and",
"data",
"using",
"the",
"compressors",
"passed",
"or",
"using",
"the",
"passed",
"preparedmsg"
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/stream.go#L1497-L1513 |
127,182 | grpc/grpc-go | credentials/alts/internal/conn/common.go | ParseFramedMsg | func ParseFramedMsg(b []byte, maxLen uint32) ([]byte, []byte, error) {
// If the size field is not complete, return the provided buffer as
// remaining buffer.
if len(b) < MsgLenFieldSize {
return nil, b, nil
}
msgLenField := b[:MsgLenFieldSize]
length := binary.LittleEndian.Uint32(msgLenField)
if length > max... | go | func ParseFramedMsg(b []byte, maxLen uint32) ([]byte, []byte, error) {
// If the size field is not complete, return the provided buffer as
// remaining buffer.
if len(b) < MsgLenFieldSize {
return nil, b, nil
}
msgLenField := b[:MsgLenFieldSize]
length := binary.LittleEndian.Uint32(msgLenField)
if length > max... | [
"func",
"ParseFramedMsg",
"(",
"b",
"[",
"]",
"byte",
",",
"maxLen",
"uint32",
")",
"(",
"[",
"]",
"byte",
",",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// If the size field is not complete, return the provided buffer as",
"// remaining buffer.",
"if",
"len",
... | // ParseFramedMsg parse the provided buffer and returns a frame of the format
// msgLength+msg and any remaining bytes in that buffer. | [
"ParseFramedMsg",
"parse",
"the",
"provided",
"buffer",
"and",
"returns",
"a",
"frame",
"of",
"the",
"format",
"msgLength",
"+",
"msg",
"and",
"any",
"remaining",
"bytes",
"in",
"that",
"buffer",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/internal/conn/common.go#L54-L70 |
127,183 | grpc/grpc-go | internal/transport/flowcontrol.go | newLimit | func (f *inFlow) newLimit(n uint32) uint32 {
f.mu.Lock()
d := n - f.limit
f.limit = n
f.mu.Unlock()
return d
} | go | func (f *inFlow) newLimit(n uint32) uint32 {
f.mu.Lock()
d := n - f.limit
f.limit = n
f.mu.Unlock()
return d
} | [
"func",
"(",
"f",
"*",
"inFlow",
")",
"newLimit",
"(",
"n",
"uint32",
")",
"uint32",
"{",
"f",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"d",
":=",
"n",
"-",
"f",
".",
"limit",
"\n",
"f",
".",
"limit",
"=",
"n",
"\n",
"f",
".",
"mu",
".",
"... | // newLimit updates the inflow window to a new value n.
// It assumes that n is always greater than the old limit. | [
"newLimit",
"updates",
"the",
"inflow",
"window",
"to",
"a",
"new",
"value",
"n",
".",
"It",
"assumes",
"that",
"n",
"is",
"always",
"greater",
"than",
"the",
"old",
"limit",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/flowcontrol.go#L139-L145 |
127,184 | grpc/grpc-go | internal/transport/flowcontrol.go | onData | func (f *inFlow) onData(n uint32) error {
f.mu.Lock()
f.pendingData += n
if f.pendingData+f.pendingUpdate > f.limit+f.delta {
limit := f.limit
rcvd := f.pendingData + f.pendingUpdate
f.mu.Unlock()
return fmt.Errorf("received %d-bytes data exceeding the limit %d bytes", rcvd, limit)
}
f.mu.Unlock()
return ... | go | func (f *inFlow) onData(n uint32) error {
f.mu.Lock()
f.pendingData += n
if f.pendingData+f.pendingUpdate > f.limit+f.delta {
limit := f.limit
rcvd := f.pendingData + f.pendingUpdate
f.mu.Unlock()
return fmt.Errorf("received %d-bytes data exceeding the limit %d bytes", rcvd, limit)
}
f.mu.Unlock()
return ... | [
"func",
"(",
"f",
"*",
"inFlow",
")",
"onData",
"(",
"n",
"uint32",
")",
"error",
"{",
"f",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"f",
".",
"pendingData",
"+=",
"n",
"\n",
"if",
"f",
".",
"pendingData",
"+",
"f",
".",
"pendingUpdate",
">",
"f... | // onData is invoked when some data frame is received. It updates pendingData. | [
"onData",
"is",
"invoked",
"when",
"some",
"data",
"frame",
"is",
"received",
".",
"It",
"updates",
"pendingData",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/flowcontrol.go#L180-L191 |
127,185 | grpc/grpc-go | internal/transport/flowcontrol.go | onRead | func (f *inFlow) onRead(n uint32) uint32 {
f.mu.Lock()
if f.pendingData == 0 {
f.mu.Unlock()
return 0
}
f.pendingData -= n
if n > f.delta {
n -= f.delta
f.delta = 0
} else {
f.delta -= n
n = 0
}
f.pendingUpdate += n
if f.pendingUpdate >= f.limit/4 {
wu := f.pendingUpdate
f.pendingUpdate = 0
f... | go | func (f *inFlow) onRead(n uint32) uint32 {
f.mu.Lock()
if f.pendingData == 0 {
f.mu.Unlock()
return 0
}
f.pendingData -= n
if n > f.delta {
n -= f.delta
f.delta = 0
} else {
f.delta -= n
n = 0
}
f.pendingUpdate += n
if f.pendingUpdate >= f.limit/4 {
wu := f.pendingUpdate
f.pendingUpdate = 0
f... | [
"func",
"(",
"f",
"*",
"inFlow",
")",
"onRead",
"(",
"n",
"uint32",
")",
"uint32",
"{",
"f",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"if",
"f",
".",
"pendingData",
"==",
"0",
"{",
"f",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"return",
"0",
... | // onRead is invoked when the application reads the data. It returns the window size
// to be sent to the peer. | [
"onRead",
"is",
"invoked",
"when",
"the",
"application",
"reads",
"the",
"data",
".",
"It",
"returns",
"the",
"window",
"size",
"to",
"be",
"sent",
"to",
"the",
"peer",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/flowcontrol.go#L195-L218 |
127,186 | grpc/grpc-go | benchmark/worker/benchmark_client.go | swap | func (h *lockingHistogram) swap(o *stats.Histogram) *stats.Histogram {
h.mu.Lock()
defer h.mu.Unlock()
old := h.histogram
h.histogram = o
return old
} | go | func (h *lockingHistogram) swap(o *stats.Histogram) *stats.Histogram {
h.mu.Lock()
defer h.mu.Unlock()
old := h.histogram
h.histogram = o
return old
} | [
"func",
"(",
"h",
"*",
"lockingHistogram",
")",
"swap",
"(",
"o",
"*",
"stats",
".",
"Histogram",
")",
"*",
"stats",
".",
"Histogram",
"{",
"h",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"h",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"ol... | // swap sets h.histogram to o and returns its old value. | [
"swap",
"sets",
"h",
".",
"histogram",
"to",
"o",
"and",
"returns",
"its",
"old",
"value",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/worker/benchmark_client.go#L55-L61 |
127,187 | grpc/grpc-go | benchmark/worker/benchmark_client.go | createConns | func createConns(config *testpb.ClientConfig) ([]*grpc.ClientConn, func(), error) {
var opts []grpc.DialOption
// Sanity check for client type.
switch config.ClientType {
case testpb.ClientType_SYNC_CLIENT:
case testpb.ClientType_ASYNC_CLIENT:
default:
return nil, nil, status.Errorf(codes.InvalidArgument, "unk... | go | func createConns(config *testpb.ClientConfig) ([]*grpc.ClientConn, func(), error) {
var opts []grpc.DialOption
// Sanity check for client type.
switch config.ClientType {
case testpb.ClientType_SYNC_CLIENT:
case testpb.ClientType_ASYNC_CLIENT:
default:
return nil, nil, status.Errorf(codes.InvalidArgument, "unk... | [
"func",
"createConns",
"(",
"config",
"*",
"testpb",
".",
"ClientConfig",
")",
"(",
"[",
"]",
"*",
"grpc",
".",
"ClientConn",
",",
"func",
"(",
")",
",",
"error",
")",
"{",
"var",
"opts",
"[",
"]",
"grpc",
".",
"DialOption",
"\n\n",
"// Sanity check fo... | // createConns creates connections according to given config.
// It returns the connections and corresponding function to close them.
// It returns non-nil error if there is anything wrong. | [
"createConns",
"creates",
"connections",
"according",
"to",
"given",
"config",
".",
"It",
"returns",
"the",
"connections",
"and",
"corresponding",
"function",
"to",
"close",
"them",
".",
"It",
"returns",
"non",
"-",
"nil",
"error",
"if",
"there",
"is",
"anythi... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/worker/benchmark_client.go#L113-L161 |
127,188 | grpc/grpc-go | benchmark/worker/benchmark_client.go | getStats | func (bc *benchmarkClient) getStats(reset bool) *testpb.ClientStats {
var wallTimeElapsed, uTimeElapsed, sTimeElapsed float64
mergedHistogram := stats.NewHistogram(bc.histogramOptions)
if reset {
// Merging histogram may take some time.
// Put all histograms aside and merge later.
toMerge := make([]*stats.His... | go | func (bc *benchmarkClient) getStats(reset bool) *testpb.ClientStats {
var wallTimeElapsed, uTimeElapsed, sTimeElapsed float64
mergedHistogram := stats.NewHistogram(bc.histogramOptions)
if reset {
// Merging histogram may take some time.
// Put all histograms aside and merge later.
toMerge := make([]*stats.His... | [
"func",
"(",
"bc",
"*",
"benchmarkClient",
")",
"getStats",
"(",
"reset",
"bool",
")",
"*",
"testpb",
".",
"ClientStats",
"{",
"var",
"wallTimeElapsed",
",",
"uTimeElapsed",
",",
"sTimeElapsed",
"float64",
"\n",
"mergedHistogram",
":=",
"stats",
".",
"NewHisto... | // getStats returns the stats for benchmark client.
// It resets lastResetTime and all histograms if argument reset is true. | [
"getStats",
"returns",
"the",
"stats",
"for",
"benchmark",
"client",
".",
"It",
"resets",
"lastResetTime",
"and",
"all",
"histograms",
"if",
"argument",
"reset",
"is",
"true",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/worker/benchmark_client.go#L332-L381 |
127,189 | grpc/grpc-go | balancer/grpclb/grpclb_picker.go | toClientStats | func (s *rpcStats) toClientStats() *lbpb.ClientStats {
stats := &lbpb.ClientStats{
NumCallsStarted: atomic.SwapInt64(&s.numCallsStarted, 0),
NumCallsFinished: atomic.SwapInt64(&s.numCallsFinished, 0),
NumCallsFinishedWithClientFailedToSend: atomic.SwapInt64(&s.numCall... | go | func (s *rpcStats) toClientStats() *lbpb.ClientStats {
stats := &lbpb.ClientStats{
NumCallsStarted: atomic.SwapInt64(&s.numCallsStarted, 0),
NumCallsFinished: atomic.SwapInt64(&s.numCallsFinished, 0),
NumCallsFinishedWithClientFailedToSend: atomic.SwapInt64(&s.numCall... | [
"func",
"(",
"s",
"*",
"rpcStats",
")",
"toClientStats",
"(",
")",
"*",
"lbpb",
".",
"ClientStats",
"{",
"stats",
":=",
"&",
"lbpb",
".",
"ClientStats",
"{",
"NumCallsStarted",
":",
"atomic",
".",
"SwapInt64",
"(",
"&",
"s",
".",
"numCallsStarted",
",",
... | // toClientStats converts rpcStats to lbpb.ClientStats, and clears rpcStats. | [
"toClientStats",
"converts",
"rpcStats",
"to",
"lbpb",
".",
"ClientStats",
"and",
"clears",
"rpcStats",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/balancer/grpclb/grpclb_picker.go#L54-L72 |
127,190 | grpc/grpc-go | balancer/base/base.go | NewBalancerBuilder | func NewBalancerBuilder(name string, pb PickerBuilder) balancer.Builder {
return NewBalancerBuilderWithConfig(name, pb, Config{})
} | go | func NewBalancerBuilder(name string, pb PickerBuilder) balancer.Builder {
return NewBalancerBuilderWithConfig(name, pb, Config{})
} | [
"func",
"NewBalancerBuilder",
"(",
"name",
"string",
",",
"pb",
"PickerBuilder",
")",
"balancer",
".",
"Builder",
"{",
"return",
"NewBalancerBuilderWithConfig",
"(",
"name",
",",
"pb",
",",
"Config",
"{",
"}",
")",
"\n",
"}"
] | // NewBalancerBuilder returns a balancer builder. The balancers
// built by this builder will use the picker builder to build pickers. | [
"NewBalancerBuilder",
"returns",
"a",
"balancer",
"builder",
".",
"The",
"balancers",
"built",
"by",
"this",
"builder",
"will",
"use",
"the",
"picker",
"builder",
"to",
"build",
"pickers",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/balancer/base/base.go#L47-L49 |
127,191 | grpc/grpc-go | balancer/base/base.go | NewBalancerBuilderWithConfig | func NewBalancerBuilderWithConfig(name string, pb PickerBuilder, config Config) balancer.Builder {
return &baseBuilder{
name: name,
pickerBuilder: pb,
config: config,
}
} | go | func NewBalancerBuilderWithConfig(name string, pb PickerBuilder, config Config) balancer.Builder {
return &baseBuilder{
name: name,
pickerBuilder: pb,
config: config,
}
} | [
"func",
"NewBalancerBuilderWithConfig",
"(",
"name",
"string",
",",
"pb",
"PickerBuilder",
",",
"config",
"Config",
")",
"balancer",
".",
"Builder",
"{",
"return",
"&",
"baseBuilder",
"{",
"name",
":",
"name",
",",
"pickerBuilder",
":",
"pb",
",",
"config",
... | // NewBalancerBuilderWithConfig returns a base balancer builder configured by the provided config. | [
"NewBalancerBuilderWithConfig",
"returns",
"a",
"base",
"balancer",
"builder",
"configured",
"by",
"the",
"provided",
"config",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/balancer/base/base.go#L58-L64 |
127,192 | grpc/grpc-go | credentials/credentials.go | GetSecurityValue | func (t TLSInfo) GetSecurityValue() ChannelzSecurityValue {
v := &TLSChannelzSecurityValue{
StandardName: cipherSuiteLookup[t.State.CipherSuite],
}
// Currently there's no way to get LocalCertificate info from tls package.
if len(t.State.PeerCertificates) > 0 {
v.RemoteCertificate = t.State.PeerCertificates[0].... | go | func (t TLSInfo) GetSecurityValue() ChannelzSecurityValue {
v := &TLSChannelzSecurityValue{
StandardName: cipherSuiteLookup[t.State.CipherSuite],
}
// Currently there's no way to get LocalCertificate info from tls package.
if len(t.State.PeerCertificates) > 0 {
v.RemoteCertificate = t.State.PeerCertificates[0].... | [
"func",
"(",
"t",
"TLSInfo",
")",
"GetSecurityValue",
"(",
")",
"ChannelzSecurityValue",
"{",
"v",
":=",
"&",
"TLSChannelzSecurityValue",
"{",
"StandardName",
":",
"cipherSuiteLookup",
"[",
"t",
".",
"State",
".",
"CipherSuite",
"]",
",",
"}",
"\n",
"// Curren... | // GetSecurityValue returns security info requested by channelz. | [
"GetSecurityValue",
"returns",
"security",
"info",
"requested",
"by",
"channelz",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/credentials.go#L140-L149 |
127,193 | grpc/grpc-go | credentials/credentials.go | NewTLS | func NewTLS(c *tls.Config) TransportCredentials {
tc := &tlsCreds{cloneTLSConfig(c)}
tc.config.NextProtos = appendH2ToNextProtos(tc.config.NextProtos)
return tc
} | go | func NewTLS(c *tls.Config) TransportCredentials {
tc := &tlsCreds{cloneTLSConfig(c)}
tc.config.NextProtos = appendH2ToNextProtos(tc.config.NextProtos)
return tc
} | [
"func",
"NewTLS",
"(",
"c",
"*",
"tls",
".",
"Config",
")",
"TransportCredentials",
"{",
"tc",
":=",
"&",
"tlsCreds",
"{",
"cloneTLSConfig",
"(",
"c",
")",
"}",
"\n",
"tc",
".",
"config",
".",
"NextProtos",
"=",
"appendH2ToNextProtos",
"(",
"tc",
".",
... | // NewTLS uses c to construct a TransportCredentials based on TLS. | [
"NewTLS",
"uses",
"c",
"to",
"construct",
"a",
"TransportCredentials",
"based",
"on",
"TLS",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/credentials.go#L222-L226 |
127,194 | grpc/grpc-go | credentials/credentials.go | NewServerTLSFromCert | func NewServerTLSFromCert(cert *tls.Certificate) TransportCredentials {
return NewTLS(&tls.Config{Certificates: []tls.Certificate{*cert}})
} | go | func NewServerTLSFromCert(cert *tls.Certificate) TransportCredentials {
return NewTLS(&tls.Config{Certificates: []tls.Certificate{*cert}})
} | [
"func",
"NewServerTLSFromCert",
"(",
"cert",
"*",
"tls",
".",
"Certificate",
")",
"TransportCredentials",
"{",
"return",
"NewTLS",
"(",
"&",
"tls",
".",
"Config",
"{",
"Certificates",
":",
"[",
"]",
"tls",
".",
"Certificate",
"{",
"*",
"cert",
"}",
"}",
... | // NewServerTLSFromCert constructs TLS credentials from the input certificate for server. | [
"NewServerTLSFromCert",
"constructs",
"TLS",
"credentials",
"from",
"the",
"input",
"certificate",
"for",
"server",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/credentials.go#L251-L253 |
127,195 | grpc/grpc-go | credentials/credentials.go | NewServerTLSFromFile | func NewServerTLSFromFile(certFile, keyFile string) (TransportCredentials, error) {
cert, err := tls.LoadX509KeyPair(certFile, keyFile)
if err != nil {
return nil, err
}
return NewTLS(&tls.Config{Certificates: []tls.Certificate{cert}}), nil
} | go | func NewServerTLSFromFile(certFile, keyFile string) (TransportCredentials, error) {
cert, err := tls.LoadX509KeyPair(certFile, keyFile)
if err != nil {
return nil, err
}
return NewTLS(&tls.Config{Certificates: []tls.Certificate{cert}}), nil
} | [
"func",
"NewServerTLSFromFile",
"(",
"certFile",
",",
"keyFile",
"string",
")",
"(",
"TransportCredentials",
",",
"error",
")",
"{",
"cert",
",",
"err",
":=",
"tls",
".",
"LoadX509KeyPair",
"(",
"certFile",
",",
"keyFile",
")",
"\n",
"if",
"err",
"!=",
"ni... | // NewServerTLSFromFile constructs TLS credentials from the input certificate file and key
// file for server. | [
"NewServerTLSFromFile",
"constructs",
"TLS",
"credentials",
"from",
"the",
"input",
"certificate",
"file",
"and",
"key",
"file",
"for",
"server",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/credentials.go#L257-L263 |
127,196 | grpc/grpc-go | internal/transport/handler_server.go | do | func (ht *serverHandlerTransport) do(fn func()) error {
select {
case <-ht.closedCh:
return ErrConnClosing
case ht.writes <- fn:
return nil
}
} | go | func (ht *serverHandlerTransport) do(fn func()) error {
select {
case <-ht.closedCh:
return ErrConnClosing
case ht.writes <- fn:
return nil
}
} | [
"func",
"(",
"ht",
"*",
"serverHandlerTransport",
")",
"do",
"(",
"fn",
"func",
"(",
")",
")",
"error",
"{",
"select",
"{",
"case",
"<-",
"ht",
".",
"closedCh",
":",
"return",
"ErrConnClosing",
"\n",
"case",
"ht",
".",
"writes",
"<-",
"fn",
":",
"ret... | // do runs fn in the ServeHTTP goroutine. | [
"do",
"runs",
"fn",
"in",
"the",
"ServeHTTP",
"goroutine",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/handler_server.go#L175-L182 |
127,197 | grpc/grpc-go | examples/route_guide/client/client.go | printFeature | func printFeature(client pb.RouteGuideClient, point *pb.Point) {
log.Printf("Getting feature for point (%d, %d)", point.Latitude, point.Longitude)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
feature, err := client.GetFeature(ctx, point)
if err != nil {
log.Fatalf("%v.G... | go | func printFeature(client pb.RouteGuideClient, point *pb.Point) {
log.Printf("Getting feature for point (%d, %d)", point.Latitude, point.Longitude)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
feature, err := client.GetFeature(ctx, point)
if err != nil {
log.Fatalf("%v.G... | [
"func",
"printFeature",
"(",
"client",
"pb",
".",
"RouteGuideClient",
",",
"point",
"*",
"pb",
".",
"Point",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"point",
".",
"Latitude",
",",
"point",
".",
"Longitude",
")",
"\n",
"ctx",
",",
"cance... | // printFeature gets the feature for the given point. | [
"printFeature",
"gets",
"the",
"feature",
"for",
"the",
"given",
"point",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/examples/route_guide/client/client.go#L47-L56 |
127,198 | grpc/grpc-go | examples/route_guide/client/client.go | printFeatures | func printFeatures(client pb.RouteGuideClient, rect *pb.Rectangle) {
log.Printf("Looking for features within %v", rect)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
stream, err := client.ListFeatures(ctx, rect)
if err != nil {
log.Fatalf("%v.ListFeatures(_) = _, %v", cl... | go | func printFeatures(client pb.RouteGuideClient, rect *pb.Rectangle) {
log.Printf("Looking for features within %v", rect)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
stream, err := client.ListFeatures(ctx, rect)
if err != nil {
log.Fatalf("%v.ListFeatures(_) = _, %v", cl... | [
"func",
"printFeatures",
"(",
"client",
"pb",
".",
"RouteGuideClient",
",",
"rect",
"*",
"pb",
".",
"Rectangle",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"rect",
")",
"\n",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
... | // printFeatures lists all the features within the given bounding Rectangle. | [
"printFeatures",
"lists",
"all",
"the",
"features",
"within",
"the",
"given",
"bounding",
"Rectangle",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/examples/route_guide/client/client.go#L59-L77 |
127,199 | grpc/grpc-go | examples/route_guide/client/client.go | runRecordRoute | func runRecordRoute(client pb.RouteGuideClient) {
// Create a random number of random points
r := rand.New(rand.NewSource(time.Now().UnixNano()))
pointCount := int(r.Int31n(100)) + 2 // Traverse at least two points
var points []*pb.Point
for i := 0; i < pointCount; i++ {
points = append(points, randomPoint(r))
... | go | func runRecordRoute(client pb.RouteGuideClient) {
// Create a random number of random points
r := rand.New(rand.NewSource(time.Now().UnixNano()))
pointCount := int(r.Int31n(100)) + 2 // Traverse at least two points
var points []*pb.Point
for i := 0; i < pointCount; i++ {
points = append(points, randomPoint(r))
... | [
"func",
"runRecordRoute",
"(",
"client",
"pb",
".",
"RouteGuideClient",
")",
"{",
"// Create a random number of random points",
"r",
":=",
"rand",
".",
"New",
"(",
"rand",
".",
"NewSource",
"(",
"time",
".",
"Now",
"(",
")",
".",
"UnixNano",
"(",
")",
")",
... | // runRecordRoute sends a sequence of points to server and expects to get a RouteSummary from server. | [
"runRecordRoute",
"sends",
"a",
"sequence",
"of",
"points",
"to",
"server",
"and",
"expects",
"to",
"get",
"a",
"RouteSummary",
"from",
"server",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/examples/route_guide/client/client.go#L80-L105 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.