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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
126,900 | go-kit/kit | examples/shipping/handling/transport.go | MakeHandler | func MakeHandler(hs Service, logger kitlog.Logger) http.Handler {
r := mux.NewRouter()
opts := []kithttp.ServerOption{
kithttp.ServerErrorHandler(transport.NewLogErrorHandler(logger)),
kithttp.ServerErrorEncoder(encodeError),
}
registerIncidentHandler := kithttp.NewServer(
makeRegisterIncidentEndpoint(hs),
... | go | func MakeHandler(hs Service, logger kitlog.Logger) http.Handler {
r := mux.NewRouter()
opts := []kithttp.ServerOption{
kithttp.ServerErrorHandler(transport.NewLogErrorHandler(logger)),
kithttp.ServerErrorEncoder(encodeError),
}
registerIncidentHandler := kithttp.NewServer(
makeRegisterIncidentEndpoint(hs),
... | [
"func",
"MakeHandler",
"(",
"hs",
"Service",
",",
"logger",
"kitlog",
".",
"Logger",
")",
"http",
".",
"Handler",
"{",
"r",
":=",
"mux",
".",
"NewRouter",
"(",
")",
"\n\n",
"opts",
":=",
"[",
"]",
"kithttp",
".",
"ServerOption",
"{",
"kithttp",
".",
... | // MakeHandler returns a handler for the handling service. | [
"MakeHandler",
"returns",
"a",
"handler",
"for",
"the",
"handling",
"service",
"."
] | da68e7640663097af890b9bdd76da9cb816ebb82 | https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/examples/shipping/handling/transport.go#L21-L39 |
126,901 | go-kit/kit | examples/shipping/handling/service.go | NewService | func NewService(r cargo.HandlingEventRepository, f cargo.HandlingEventFactory, h EventHandler) Service {
return &service{
handlingEventRepository: r,
handlingEventFactory: f,
handlingEventHandler: h,
}
} | go | func NewService(r cargo.HandlingEventRepository, f cargo.HandlingEventFactory, h EventHandler) Service {
return &service{
handlingEventRepository: r,
handlingEventFactory: f,
handlingEventHandler: h,
}
} | [
"func",
"NewService",
"(",
"r",
"cargo",
".",
"HandlingEventRepository",
",",
"f",
"cargo",
".",
"HandlingEventFactory",
",",
"h",
"EventHandler",
")",
"Service",
"{",
"return",
"&",
"service",
"{",
"handlingEventRepository",
":",
"r",
",",
"handlingEventFactory",... | // NewService creates a handling event service with necessary dependencies. | [
"NewService",
"creates",
"a",
"handling",
"event",
"service",
"with",
"necessary",
"dependencies",
"."
] | da68e7640663097af890b9bdd76da9cb816ebb82 | https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/examples/shipping/handling/service.go#L55-L61 |
126,902 | go-kit/kit | examples/shipping/cargo/itinerary.go | NewLeg | func NewLeg(voyageNumber voyage.Number, loadLocation, unloadLocation location.UNLocode, loadTime, unloadTime time.Time) Leg {
return Leg{
VoyageNumber: voyageNumber,
LoadLocation: loadLocation,
UnloadLocation: unloadLocation,
LoadTime: loadTime,
UnloadTime: unloadTime,
}
} | go | func NewLeg(voyageNumber voyage.Number, loadLocation, unloadLocation location.UNLocode, loadTime, unloadTime time.Time) Leg {
return Leg{
VoyageNumber: voyageNumber,
LoadLocation: loadLocation,
UnloadLocation: unloadLocation,
LoadTime: loadTime,
UnloadTime: unloadTime,
}
} | [
"func",
"NewLeg",
"(",
"voyageNumber",
"voyage",
".",
"Number",
",",
"loadLocation",
",",
"unloadLocation",
"location",
".",
"UNLocode",
",",
"loadTime",
",",
"unloadTime",
"time",
".",
"Time",
")",
"Leg",
"{",
"return",
"Leg",
"{",
"VoyageNumber",
":",
"voy... | // NewLeg creates a new itinerary leg. | [
"NewLeg",
"creates",
"a",
"new",
"itinerary",
"leg",
"."
] | da68e7640663097af890b9bdd76da9cb816ebb82 | https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/examples/shipping/cargo/itinerary.go#L20-L28 |
126,903 | go-kit/kit | examples/shipping/cargo/itinerary.go | InitialDepartureLocation | func (i Itinerary) InitialDepartureLocation() location.UNLocode {
if i.IsEmpty() {
return location.UNLocode("")
}
return i.Legs[0].LoadLocation
} | go | func (i Itinerary) InitialDepartureLocation() location.UNLocode {
if i.IsEmpty() {
return location.UNLocode("")
}
return i.Legs[0].LoadLocation
} | [
"func",
"(",
"i",
"Itinerary",
")",
"InitialDepartureLocation",
"(",
")",
"location",
".",
"UNLocode",
"{",
"if",
"i",
".",
"IsEmpty",
"(",
")",
"{",
"return",
"location",
".",
"UNLocode",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"i",
".",
"L... | // InitialDepartureLocation returns the start of the itinerary. | [
"InitialDepartureLocation",
"returns",
"the",
"start",
"of",
"the",
"itinerary",
"."
] | da68e7640663097af890b9bdd76da9cb816ebb82 | https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/examples/shipping/cargo/itinerary.go#L37-L42 |
126,904 | go-kit/kit | examples/shipping/cargo/itinerary.go | FinalArrivalLocation | func (i Itinerary) FinalArrivalLocation() location.UNLocode {
if i.IsEmpty() {
return location.UNLocode("")
}
return i.Legs[len(i.Legs)-1].UnloadLocation
} | go | func (i Itinerary) FinalArrivalLocation() location.UNLocode {
if i.IsEmpty() {
return location.UNLocode("")
}
return i.Legs[len(i.Legs)-1].UnloadLocation
} | [
"func",
"(",
"i",
"Itinerary",
")",
"FinalArrivalLocation",
"(",
")",
"location",
".",
"UNLocode",
"{",
"if",
"i",
".",
"IsEmpty",
"(",
")",
"{",
"return",
"location",
".",
"UNLocode",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"i",
".",
"Legs"... | // FinalArrivalLocation returns the end of the itinerary. | [
"FinalArrivalLocation",
"returns",
"the",
"end",
"of",
"the",
"itinerary",
"."
] | da68e7640663097af890b9bdd76da9cb816ebb82 | https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/examples/shipping/cargo/itinerary.go#L45-L50 |
126,905 | go-kit/kit | examples/shipping/cargo/itinerary.go | FinalArrivalTime | func (i Itinerary) FinalArrivalTime() time.Time {
return i.Legs[len(i.Legs)-1].UnloadTime
} | go | func (i Itinerary) FinalArrivalTime() time.Time {
return i.Legs[len(i.Legs)-1].UnloadTime
} | [
"func",
"(",
"i",
"Itinerary",
")",
"FinalArrivalTime",
"(",
")",
"time",
".",
"Time",
"{",
"return",
"i",
".",
"Legs",
"[",
"len",
"(",
"i",
".",
"Legs",
")",
"-",
"1",
"]",
".",
"UnloadTime",
"\n",
"}"
] | // FinalArrivalTime returns the expected arrival time at final destination. | [
"FinalArrivalTime",
"returns",
"the",
"expected",
"arrival",
"time",
"at",
"final",
"destination",
"."
] | da68e7640663097af890b9bdd76da9cb816ebb82 | https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/examples/shipping/cargo/itinerary.go#L53-L55 |
126,906 | go-kit/kit | examples/shipping/cargo/itinerary.go | IsEmpty | func (i Itinerary) IsEmpty() bool {
return i.Legs == nil || len(i.Legs) == 0
} | go | func (i Itinerary) IsEmpty() bool {
return i.Legs == nil || len(i.Legs) == 0
} | [
"func",
"(",
"i",
"Itinerary",
")",
"IsEmpty",
"(",
")",
"bool",
"{",
"return",
"i",
".",
"Legs",
"==",
"nil",
"||",
"len",
"(",
"i",
".",
"Legs",
")",
"==",
"0",
"\n",
"}"
] | // IsEmpty checks if the itinerary contains at least one leg. | [
"IsEmpty",
"checks",
"if",
"the",
"itinerary",
"contains",
"at",
"least",
"one",
"leg",
"."
] | da68e7640663097af890b9bdd76da9cb816ebb82 | https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/examples/shipping/cargo/itinerary.go#L58-L60 |
126,907 | go-kit/kit | examples/shipping/cargo/itinerary.go | IsExpected | func (i Itinerary) IsExpected(event HandlingEvent) bool {
if i.IsEmpty() {
return true
}
switch event.Activity.Type {
case Receive:
return i.InitialDepartureLocation() == event.Activity.Location
case Load:
for _, l := range i.Legs {
if l.LoadLocation == event.Activity.Location && l.VoyageNumber == event.... | go | func (i Itinerary) IsExpected(event HandlingEvent) bool {
if i.IsEmpty() {
return true
}
switch event.Activity.Type {
case Receive:
return i.InitialDepartureLocation() == event.Activity.Location
case Load:
for _, l := range i.Legs {
if l.LoadLocation == event.Activity.Location && l.VoyageNumber == event.... | [
"func",
"(",
"i",
"Itinerary",
")",
"IsExpected",
"(",
"event",
"HandlingEvent",
")",
"bool",
"{",
"if",
"i",
".",
"IsEmpty",
"(",
")",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"switch",
"event",
".",
"Activity",
".",
"Type",
"{",
"case",
"Receive",
... | // IsExpected checks if the given handling event is expected when executing
// this itinerary. | [
"IsExpected",
"checks",
"if",
"the",
"given",
"handling",
"event",
"is",
"expected",
"when",
"executing",
"this",
"itinerary",
"."
] | da68e7640663097af890b9bdd76da9cb816ebb82 | https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/examples/shipping/cargo/itinerary.go#L64-L91 |
126,908 | go-kit/kit | log/term/colorwriter_windows.go | NewColorWriter | func NewColorWriter(w io.Writer) io.Writer {
if !IsConsole(w) {
return w
}
var csbi consoleScreenBufferInfo
handle := syscall.Handle(w.(fder).Fd())
procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
return &colorWriter{
out: w,
handle: handle,
oldattr: csbi.attribu... | go | func NewColorWriter(w io.Writer) io.Writer {
if !IsConsole(w) {
return w
}
var csbi consoleScreenBufferInfo
handle := syscall.Handle(w.(fder).Fd())
procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
return &colorWriter{
out: w,
handle: handle,
oldattr: csbi.attribu... | [
"func",
"NewColorWriter",
"(",
"w",
"io",
".",
"Writer",
")",
"io",
".",
"Writer",
"{",
"if",
"!",
"IsConsole",
"(",
"w",
")",
"{",
"return",
"w",
"\n",
"}",
"\n\n",
"var",
"csbi",
"consoleScreenBufferInfo",
"\n",
"handle",
":=",
"syscall",
".",
"Handl... | // NewColorWriter returns an io.Writer that writes to w and provides cross
// platform support for ANSI color codes. If w is not a terminal it is
// returned unmodified. | [
"NewColorWriter",
"returns",
"an",
"io",
".",
"Writer",
"that",
"writes",
"to",
"w",
"and",
"provides",
"cross",
"platform",
"support",
"for",
"ANSI",
"color",
"codes",
".",
"If",
"w",
"is",
"not",
"a",
"terminal",
"it",
"is",
"returned",
"unmodified",
"."... | da68e7640663097af890b9bdd76da9cb816ebb82 | https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/log/term/colorwriter_windows.go#L25-L39 |
126,909 | go-kit/kit | metrics/timer.go | NewTimer | func NewTimer(h Histogram) *Timer {
return &Timer{
h: h,
t: time.Now(),
u: time.Second,
}
} | go | func NewTimer(h Histogram) *Timer {
return &Timer{
h: h,
t: time.Now(),
u: time.Second,
}
} | [
"func",
"NewTimer",
"(",
"h",
"Histogram",
")",
"*",
"Timer",
"{",
"return",
"&",
"Timer",
"{",
"h",
":",
"h",
",",
"t",
":",
"time",
".",
"Now",
"(",
")",
",",
"u",
":",
"time",
".",
"Second",
",",
"}",
"\n",
"}"
] | // NewTimer wraps the given histogram and records the current time. | [
"NewTimer",
"wraps",
"the",
"given",
"histogram",
"and",
"records",
"the",
"current",
"time",
"."
] | da68e7640663097af890b9bdd76da9cb816ebb82 | https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/metrics/timer.go#L14-L20 |
126,910 | go-kit/kit | metrics/timer.go | ObserveDuration | func (t *Timer) ObserveDuration() {
d := float64(time.Since(t.t).Nanoseconds()) / float64(t.u)
if d < 0 {
d = 0
}
t.h.Observe(d)
} | go | func (t *Timer) ObserveDuration() {
d := float64(time.Since(t.t).Nanoseconds()) / float64(t.u)
if d < 0 {
d = 0
}
t.h.Observe(d)
} | [
"func",
"(",
"t",
"*",
"Timer",
")",
"ObserveDuration",
"(",
")",
"{",
"d",
":=",
"float64",
"(",
"time",
".",
"Since",
"(",
"t",
".",
"t",
")",
".",
"Nanoseconds",
"(",
")",
")",
"/",
"float64",
"(",
"t",
".",
"u",
")",
"\n",
"if",
"d",
"<",... | // ObserveDuration captures the number of seconds since the timer was
// constructed, and forwards that observation to the histogram. | [
"ObserveDuration",
"captures",
"the",
"number",
"of",
"seconds",
"since",
"the",
"timer",
"was",
"constructed",
"and",
"forwards",
"that",
"observation",
"to",
"the",
"histogram",
"."
] | da68e7640663097af890b9bdd76da9cb816ebb82 | https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/metrics/timer.go#L24-L30 |
126,911 | go-kit/kit | sd/eureka/registrar.go | NewRegistrar | func NewRegistrar(conn fargoConnection, instance *fargo.Instance, logger log.Logger) *Registrar {
return &Registrar{
conn: conn,
instance: instance,
logger: log.With(logger, "service", instance.App, "address", fmt.Sprintf("%s:%d", instance.IPAddr, instance.Port)),
}
} | go | func NewRegistrar(conn fargoConnection, instance *fargo.Instance, logger log.Logger) *Registrar {
return &Registrar{
conn: conn,
instance: instance,
logger: log.With(logger, "service", instance.App, "address", fmt.Sprintf("%s:%d", instance.IPAddr, instance.Port)),
}
} | [
"func",
"NewRegistrar",
"(",
"conn",
"fargoConnection",
",",
"instance",
"*",
"fargo",
".",
"Instance",
",",
"logger",
"log",
".",
"Logger",
")",
"*",
"Registrar",
"{",
"return",
"&",
"Registrar",
"{",
"conn",
":",
"conn",
",",
"instance",
":",
"instance",... | // NewRegistrar returns an Eureka Registrar acting on behalf of the provided
// Fargo connection and instance. See the integration test for usage examples. | [
"NewRegistrar",
"returns",
"an",
"Eureka",
"Registrar",
"acting",
"on",
"behalf",
"of",
"the",
"provided",
"Fargo",
"connection",
"and",
"instance",
".",
"See",
"the",
"integration",
"test",
"for",
"usage",
"examples",
"."
] | da68e7640663097af890b9bdd76da9cb816ebb82 | https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/sd/eureka/registrar.go#L50-L56 |
126,912 | go-kit/kit | sd/eureka/registrar.go | Register | func (r *Registrar) Register() {
r.Lock()
defer r.Unlock()
if r.quitc != nil {
return // Already in the registration loop.
}
if err := r.conn.RegisterInstance(r.instance); err != nil {
r.logger.Log("during", "Register", "err", err)
}
r.quitc = make(chan chan struct{})
go r.loop()
} | go | func (r *Registrar) Register() {
r.Lock()
defer r.Unlock()
if r.quitc != nil {
return // Already in the registration loop.
}
if err := r.conn.RegisterInstance(r.instance); err != nil {
r.logger.Log("during", "Register", "err", err)
}
r.quitc = make(chan chan struct{})
go r.loop()
} | [
"func",
"(",
"r",
"*",
"Registrar",
")",
"Register",
"(",
")",
"{",
"r",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"r",
".",
"quitc",
"!=",
"nil",
"{",
"return",
"// Already in the registration loop.",
"\n",
"}... | // Register implements sd.Registrar. | [
"Register",
"implements",
"sd",
".",
"Registrar",
"."
] | da68e7640663097af890b9bdd76da9cb816ebb82 | https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/sd/eureka/registrar.go#L59-L73 |
126,913 | go-kit/kit | sd/eureka/registrar.go | Deregister | func (r *Registrar) Deregister() {
r.Lock()
defer r.Unlock()
if r.quitc == nil {
return // Already deregistered.
}
q := make(chan struct{})
r.quitc <- q
<-q
r.quitc = nil
} | go | func (r *Registrar) Deregister() {
r.Lock()
defer r.Unlock()
if r.quitc == nil {
return // Already deregistered.
}
q := make(chan struct{})
r.quitc <- q
<-q
r.quitc = nil
} | [
"func",
"(",
"r",
"*",
"Registrar",
")",
"Deregister",
"(",
")",
"{",
"r",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"r",
".",
"quitc",
"==",
"nil",
"{",
"return",
"// Already deregistered.",
"\n",
"}",
"\n\n... | // Deregister implements sd.Registrar. | [
"Deregister",
"implements",
"sd",
".",
"Registrar",
"."
] | da68e7640663097af890b9bdd76da9cb816ebb82 | https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/sd/eureka/registrar.go#L76-L88 |
126,914 | go-kit/kit | metrics/dogstatsd/dogstatsd.go | NewGauge | func (d *Dogstatsd) NewGauge(name string) *Gauge {
d.mtx.Lock()
n, ok := d.gauges[name]
if !ok {
n = &gaugeNode{gauge: &Gauge{g: generic.NewGauge(name), ddog: d}}
d.gauges[name] = n
}
d.mtx.Unlock()
return n.gauge
} | go | func (d *Dogstatsd) NewGauge(name string) *Gauge {
d.mtx.Lock()
n, ok := d.gauges[name]
if !ok {
n = &gaugeNode{gauge: &Gauge{g: generic.NewGauge(name), ddog: d}}
d.gauges[name] = n
}
d.mtx.Unlock()
return n.gauge
} | [
"func",
"(",
"d",
"*",
"Dogstatsd",
")",
"NewGauge",
"(",
"name",
"string",
")",
"*",
"Gauge",
"{",
"d",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"n",
",",
"ok",
":=",
"d",
".",
"gauges",
"[",
"name",
"]",
"\n",
"if",
"!",
"ok",
"{",
"n",
"... | // NewGauge returns a gauge, sending observations to this Dogstatsd object. | [
"NewGauge",
"returns",
"a",
"gauge",
"sending",
"observations",
"to",
"this",
"Dogstatsd",
"object",
"."
] | da68e7640663097af890b9bdd76da9cb816ebb82 | https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/metrics/dogstatsd/dogstatsd.go#L81-L90 |
126,915 | go-kit/kit | metrics/dogstatsd/dogstatsd.go | WriteLoop | func (d *Dogstatsd) WriteLoop(ctx context.Context, c <-chan time.Time, w io.Writer) {
for {
select {
case <-c:
if _, err := d.WriteTo(w); err != nil {
d.logger.Log("during", "WriteTo", "err", err)
}
case <-ctx.Done():
return
}
}
} | go | func (d *Dogstatsd) WriteLoop(ctx context.Context, c <-chan time.Time, w io.Writer) {
for {
select {
case <-c:
if _, err := d.WriteTo(w); err != nil {
d.logger.Log("during", "WriteTo", "err", err)
}
case <-ctx.Done():
return
}
}
} | [
"func",
"(",
"d",
"*",
"Dogstatsd",
")",
"WriteLoop",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"<-",
"chan",
"time",
".",
"Time",
",",
"w",
"io",
".",
"Writer",
")",
"{",
"for",
"{",
"select",
"{",
"case",
"<-",
"c",
":",
"if",
"_",
","... | // WriteLoop is a helper method that invokes WriteTo to the passed writer every
// time the passed channel fires. This method blocks until ctx is canceled,
// so clients probably want to run it in its own goroutine. For typical
// usage, create a time.Ticker and pass its C channel to this method. | [
"WriteLoop",
"is",
"a",
"helper",
"method",
"that",
"invokes",
"WriteTo",
"to",
"the",
"passed",
"writer",
"every",
"time",
"the",
"passed",
"channel",
"fires",
".",
"This",
"method",
"blocks",
"until",
"ctx",
"is",
"canceled",
"so",
"clients",
"probably",
"... | da68e7640663097af890b9bdd76da9cb816ebb82 | https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/metrics/dogstatsd/dogstatsd.go#L116-L127 |
126,916 | go-kit/kit | metrics/dogstatsd/dogstatsd.go | WriteTo | func (d *Dogstatsd) WriteTo(w io.Writer) (count int64, err error) {
var n int
d.counters.Reset().Walk(func(name string, lvs lv.LabelValues, values []float64) bool {
n, err = fmt.Fprintf(w, "%s%s:%f|c%s%s\n", d.prefix, name, sum(values), sampling(d.rates.Get(name)), d.tagValues(lvs))
if err != nil {
return fal... | go | func (d *Dogstatsd) WriteTo(w io.Writer) (count int64, err error) {
var n int
d.counters.Reset().Walk(func(name string, lvs lv.LabelValues, values []float64) bool {
n, err = fmt.Fprintf(w, "%s%s:%f|c%s%s\n", d.prefix, name, sum(values), sampling(d.rates.Get(name)), d.tagValues(lvs))
if err != nil {
return fal... | [
"func",
"(",
"d",
"*",
"Dogstatsd",
")",
"WriteTo",
"(",
"w",
"io",
".",
"Writer",
")",
"(",
"count",
"int64",
",",
"err",
"error",
")",
"{",
"var",
"n",
"int",
"\n\n",
"d",
".",
"counters",
".",
"Reset",
"(",
")",
".",
"Walk",
"(",
"func",
"("... | // WriteTo flushes the buffered content of the metrics to the writer, in
// DogStatsD format. WriteTo abides best-effort semantics, so observations are
// lost if there is a problem with the write. Clients should be sure to call
// WriteTo regularly, ideally through the WriteLoop or SendLoop helper methods. | [
"WriteTo",
"flushes",
"the",
"buffered",
"content",
"of",
"the",
"metrics",
"to",
"the",
"writer",
"in",
"DogStatsD",
"format",
".",
"WriteTo",
"abides",
"best",
"-",
"effort",
"semantics",
"so",
"observations",
"are",
"lost",
"if",
"there",
"is",
"a",
"prob... | da68e7640663097af890b9bdd76da9cb816ebb82 | https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/metrics/dogstatsd/dogstatsd.go#L142-L201 |
126,917 | grpc/grpc-go | credentials/oauth/oauth.go | GetRequestMetadata | func (ts TokenSource) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {
token, err := ts.Token()
if err != nil {
return nil, err
}
return map[string]string{
"authorization": token.Type() + " " + token.AccessToken,
}, nil
} | go | func (ts TokenSource) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {
token, err := ts.Token()
if err != nil {
return nil, err
}
return map[string]string{
"authorization": token.Type() + " " + token.AccessToken,
}, nil
} | [
"func",
"(",
"ts",
"TokenSource",
")",
"GetRequestMetadata",
"(",
"ctx",
"context",
".",
"Context",
",",
"uri",
"...",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"token",
",",
"err",
":=",
"ts",
".",
"Token",
"("... | // GetRequestMetadata gets the request metadata as a map from a TokenSource. | [
"GetRequestMetadata",
"gets",
"the",
"request",
"metadata",
"as",
"a",
"map",
"from",
"a",
"TokenSource",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/oauth/oauth.go#L40-L48 |
126,918 | grpc/grpc-go | credentials/oauth/oauth.go | NewJWTAccessFromFile | func NewJWTAccessFromFile(keyFile string) (credentials.PerRPCCredentials, error) {
jsonKey, err := ioutil.ReadFile(keyFile)
if err != nil {
return nil, fmt.Errorf("credentials: failed to read the service account key file: %v", err)
}
return NewJWTAccessFromKey(jsonKey)
} | go | func NewJWTAccessFromFile(keyFile string) (credentials.PerRPCCredentials, error) {
jsonKey, err := ioutil.ReadFile(keyFile)
if err != nil {
return nil, fmt.Errorf("credentials: failed to read the service account key file: %v", err)
}
return NewJWTAccessFromKey(jsonKey)
} | [
"func",
"NewJWTAccessFromFile",
"(",
"keyFile",
"string",
")",
"(",
"credentials",
".",
"PerRPCCredentials",
",",
"error",
")",
"{",
"jsonKey",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"keyFile",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",... | // NewJWTAccessFromFile creates PerRPCCredentials from the given keyFile. | [
"NewJWTAccessFromFile",
"creates",
"PerRPCCredentials",
"from",
"the",
"given",
"keyFile",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/oauth/oauth.go#L60-L66 |
126,919 | grpc/grpc-go | credentials/oauth/oauth.go | NewServiceAccountFromKey | func NewServiceAccountFromKey(jsonKey []byte, scope ...string) (credentials.PerRPCCredentials, error) {
config, err := google.JWTConfigFromJSON(jsonKey, scope...)
if err != nil {
return nil, err
}
return &serviceAccount{config: config}, nil
} | go | func NewServiceAccountFromKey(jsonKey []byte, scope ...string) (credentials.PerRPCCredentials, error) {
config, err := google.JWTConfigFromJSON(jsonKey, scope...)
if err != nil {
return nil, err
}
return &serviceAccount{config: config}, nil
} | [
"func",
"NewServiceAccountFromKey",
"(",
"jsonKey",
"[",
"]",
"byte",
",",
"scope",
"...",
"string",
")",
"(",
"credentials",
".",
"PerRPCCredentials",
",",
"error",
")",
"{",
"config",
",",
"err",
":=",
"google",
".",
"JWTConfigFromJSON",
"(",
"jsonKey",
",... | // NewServiceAccountFromKey constructs the PerRPCCredentials using the JSON key slice
// from a Google Developers service account. | [
"NewServiceAccountFromKey",
"constructs",
"the",
"PerRPCCredentials",
"using",
"the",
"JSON",
"key",
"slice",
"from",
"a",
"Google",
"Developers",
"service",
"account",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/oauth/oauth.go#L147-L153 |
126,920 | grpc/grpc-go | credentials/oauth/oauth.go | NewServiceAccountFromFile | func NewServiceAccountFromFile(keyFile string, scope ...string) (credentials.PerRPCCredentials, error) {
jsonKey, err := ioutil.ReadFile(keyFile)
if err != nil {
return nil, fmt.Errorf("credentials: failed to read the service account key file: %v", err)
}
return NewServiceAccountFromKey(jsonKey, scope...)
} | go | func NewServiceAccountFromFile(keyFile string, scope ...string) (credentials.PerRPCCredentials, error) {
jsonKey, err := ioutil.ReadFile(keyFile)
if err != nil {
return nil, fmt.Errorf("credentials: failed to read the service account key file: %v", err)
}
return NewServiceAccountFromKey(jsonKey, scope...)
} | [
"func",
"NewServiceAccountFromFile",
"(",
"keyFile",
"string",
",",
"scope",
"...",
"string",
")",
"(",
"credentials",
".",
"PerRPCCredentials",
",",
"error",
")",
"{",
"jsonKey",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"keyFile",
")",
"\n",
"if",
... | // NewServiceAccountFromFile constructs the PerRPCCredentials using the JSON key file
// of a Google Developers service account. | [
"NewServiceAccountFromFile",
"constructs",
"the",
"PerRPCCredentials",
"using",
"the",
"JSON",
"key",
"file",
"of",
"a",
"Google",
"Developers",
"service",
"account",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/oauth/oauth.go#L157-L163 |
126,921 | grpc/grpc-go | internal/balancerload/orca/orca.go | toBytes | func toBytes(r *orcapb.LoadReport) []byte {
if r == nil {
return nil
}
b, err := proto.Marshal(r)
if err != nil {
grpclog.Warningf("orca: failed to marshal load report: %v", err)
return nil
}
return b
} | go | func toBytes(r *orcapb.LoadReport) []byte {
if r == nil {
return nil
}
b, err := proto.Marshal(r)
if err != nil {
grpclog.Warningf("orca: failed to marshal load report: %v", err)
return nil
}
return b
} | [
"func",
"toBytes",
"(",
"r",
"*",
"orcapb",
".",
"LoadReport",
")",
"[",
"]",
"byte",
"{",
"if",
"r",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"b",
",",
"err",
":=",
"proto",
".",
"Marshal",
"(",
"r",
")",
"\n",
"if",
"err",
"!=",
... | // toBytes converts a orca load report into bytes. | [
"toBytes",
"converts",
"a",
"orca",
"load",
"report",
"into",
"bytes",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/balancerload/orca/orca.go#L33-L44 |
126,922 | grpc/grpc-go | internal/balancerload/orca/orca.go | ToMetadata | func ToMetadata(r *orcapb.LoadReport) metadata.MD {
b := toBytes(r)
if b == nil {
return nil
}
return metadata.Pairs(mdKey, string(b))
} | go | func ToMetadata(r *orcapb.LoadReport) metadata.MD {
b := toBytes(r)
if b == nil {
return nil
}
return metadata.Pairs(mdKey, string(b))
} | [
"func",
"ToMetadata",
"(",
"r",
"*",
"orcapb",
".",
"LoadReport",
")",
"metadata",
".",
"MD",
"{",
"b",
":=",
"toBytes",
"(",
"r",
")",
"\n",
"if",
"b",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"metadata",
".",
"Pairs",
"(",
... | // ToMetadata converts a orca load report into grpc metadata. | [
"ToMetadata",
"converts",
"a",
"orca",
"load",
"report",
"into",
"grpc",
"metadata",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/balancerload/orca/orca.go#L47-L53 |
126,923 | grpc/grpc-go | internal/balancerload/orca/orca.go | fromBytes | func fromBytes(b []byte) *orcapb.LoadReport {
ret := new(orcapb.LoadReport)
if err := proto.Unmarshal(b, ret); err != nil {
grpclog.Warningf("orca: failed to unmarshal load report: %v", err)
return nil
}
return ret
} | go | func fromBytes(b []byte) *orcapb.LoadReport {
ret := new(orcapb.LoadReport)
if err := proto.Unmarshal(b, ret); err != nil {
grpclog.Warningf("orca: failed to unmarshal load report: %v", err)
return nil
}
return ret
} | [
"func",
"fromBytes",
"(",
"b",
"[",
"]",
"byte",
")",
"*",
"orcapb",
".",
"LoadReport",
"{",
"ret",
":=",
"new",
"(",
"orcapb",
".",
"LoadReport",
")",
"\n",
"if",
"err",
":=",
"proto",
".",
"Unmarshal",
"(",
"b",
",",
"ret",
")",
";",
"err",
"!=... | // fromBytes reads load report bytes and converts it to orca. | [
"fromBytes",
"reads",
"load",
"report",
"bytes",
"and",
"converts",
"it",
"to",
"orca",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/balancerload/orca/orca.go#L56-L63 |
126,924 | grpc/grpc-go | internal/balancerload/orca/orca.go | FromMetadata | func FromMetadata(md metadata.MD) *orcapb.LoadReport {
vs := md.Get(mdKey)
if len(vs) == 0 {
return nil
}
return fromBytes([]byte(vs[0]))
} | go | func FromMetadata(md metadata.MD) *orcapb.LoadReport {
vs := md.Get(mdKey)
if len(vs) == 0 {
return nil
}
return fromBytes([]byte(vs[0]))
} | [
"func",
"FromMetadata",
"(",
"md",
"metadata",
".",
"MD",
")",
"*",
"orcapb",
".",
"LoadReport",
"{",
"vs",
":=",
"md",
".",
"Get",
"(",
"mdKey",
")",
"\n",
"if",
"len",
"(",
"vs",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
... | // FromMetadata reads load report from metadata and converts it to orca.
//
// It returns nil if report is not found in metadata. | [
"FromMetadata",
"reads",
"load",
"report",
"from",
"metadata",
"and",
"converts",
"it",
"to",
"orca",
".",
"It",
"returns",
"nil",
"if",
"report",
"is",
"not",
"found",
"in",
"metadata",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/balancerload/orca/orca.go#L68-L74 |
126,925 | grpc/grpc-go | internal/channelz/types.go | deleteSelfFromTree | func (c *channel) deleteSelfFromTree() (deleted bool) {
if !c.closeCalled || len(c.subChans)+len(c.nestedChans) != 0 {
return false
}
// not top channel
if c.pid != 0 {
c.cm.findEntry(c.pid).deleteChild(c.id)
}
return true
} | go | func (c *channel) deleteSelfFromTree() (deleted bool) {
if !c.closeCalled || len(c.subChans)+len(c.nestedChans) != 0 {
return false
}
// not top channel
if c.pid != 0 {
c.cm.findEntry(c.pid).deleteChild(c.id)
}
return true
} | [
"func",
"(",
"c",
"*",
"channel",
")",
"deleteSelfFromTree",
"(",
")",
"(",
"deleted",
"bool",
")",
"{",
"if",
"!",
"c",
".",
"closeCalled",
"||",
"len",
"(",
"c",
".",
"subChans",
")",
"+",
"len",
"(",
"c",
".",
"nestedChans",
")",
"!=",
"0",
"{... | // deleteSelfFromTree tries to delete the channel from the channelz entry relation tree, which means
// deleting the channel reference from its parent's child list.
//
// In order for a channel to be deleted from the tree, it must meet the criteria that, removal of the
// corresponding grpc object has been invoked, and... | [
"deleteSelfFromTree",
"tries",
"to",
"delete",
"the",
"channel",
"from",
"the",
"channelz",
"entry",
"relation",
"tree",
"which",
"means",
"deleting",
"the",
"channel",
"reference",
"from",
"its",
"parent",
"s",
"child",
"list",
".",
"In",
"order",
"for",
"a",... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/channelz/types.go#L244-L253 |
126,926 | grpc/grpc-go | internal/channelz/types.go | deleteSelfFromMap | func (c *channel) deleteSelfFromMap() (delete bool) {
if c.getTraceRefCount() != 0 {
c.c = &dummyChannel{}
return false
}
return true
} | go | func (c *channel) deleteSelfFromMap() (delete bool) {
if c.getTraceRefCount() != 0 {
c.c = &dummyChannel{}
return false
}
return true
} | [
"func",
"(",
"c",
"*",
"channel",
")",
"deleteSelfFromMap",
"(",
")",
"(",
"delete",
"bool",
")",
"{",
"if",
"c",
".",
"getTraceRefCount",
"(",
")",
"!=",
"0",
"{",
"c",
".",
"c",
"=",
"&",
"dummyChannel",
"{",
"}",
"\n",
"return",
"false",
"\n",
... | // deleteSelfFromMap checks whether it is valid to delete the channel from the map, which means
// deleting the channel from channelz's tracking entirely. Users can no longer use id to query the
// channel, and its memory will be garbage collected.
//
// The trace reference count of the channel must be 0 in order to be... | [
"deleteSelfFromMap",
"checks",
"whether",
"it",
"is",
"valid",
"to",
"delete",
"the",
"channel",
"from",
"the",
"map",
"which",
"means",
"deleting",
"the",
"channel",
"from",
"channelz",
"s",
"tracking",
"entirely",
".",
"Users",
"can",
"no",
"longer",
"use",
... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/channelz/types.go#L267-L273 |
126,927 | grpc/grpc-go | internal/channelz/types.go | deleteSelfFromTree | func (sc *subChannel) deleteSelfFromTree() (deleted bool) {
if !sc.closeCalled || len(sc.sockets) != 0 {
return false
}
sc.cm.findEntry(sc.pid).deleteChild(sc.id)
return true
} | go | func (sc *subChannel) deleteSelfFromTree() (deleted bool) {
if !sc.closeCalled || len(sc.sockets) != 0 {
return false
}
sc.cm.findEntry(sc.pid).deleteChild(sc.id)
return true
} | [
"func",
"(",
"sc",
"*",
"subChannel",
")",
"deleteSelfFromTree",
"(",
")",
"(",
"deleted",
"bool",
")",
"{",
"if",
"!",
"sc",
".",
"closeCalled",
"||",
"len",
"(",
"sc",
".",
"sockets",
")",
"!=",
"0",
"{",
"return",
"false",
"\n",
"}",
"\n",
"sc",... | // deleteSelfFromTree tries to delete the subchannel from the channelz entry relation tree, which
// means deleting the subchannel reference from its parent's child list.
//
// In order for a subchannel to be deleted from the tree, it must meet the criteria that, removal of
// the corresponding grpc object has been inv... | [
"deleteSelfFromTree",
"tries",
"to",
"delete",
"the",
"subchannel",
"from",
"the",
"channelz",
"entry",
"relation",
"tree",
"which",
"means",
"deleting",
"the",
"subchannel",
"reference",
"from",
"its",
"parent",
"s",
"child",
"list",
".",
"In",
"order",
"for",
... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/channelz/types.go#L354-L360 |
126,928 | grpc/grpc-go | internal/channelz/types.go | deleteSelfFromMap | func (sc *subChannel) deleteSelfFromMap() (delete bool) {
if sc.getTraceRefCount() != 0 {
// free the grpc struct (i.e. addrConn)
sc.c = &dummyChannel{}
return false
}
return true
} | go | func (sc *subChannel) deleteSelfFromMap() (delete bool) {
if sc.getTraceRefCount() != 0 {
// free the grpc struct (i.e. addrConn)
sc.c = &dummyChannel{}
return false
}
return true
} | [
"func",
"(",
"sc",
"*",
"subChannel",
")",
"deleteSelfFromMap",
"(",
")",
"(",
"delete",
"bool",
")",
"{",
"if",
"sc",
".",
"getTraceRefCount",
"(",
")",
"!=",
"0",
"{",
"// free the grpc struct (i.e. addrConn)",
"sc",
".",
"c",
"=",
"&",
"dummyChannel",
"... | // deleteSelfFromMap checks whether it is valid to delete the subchannel from the map, which means
// deleting the subchannel from channelz's tracking entirely. Users can no longer use id to query
// the subchannel, and its memory will be garbage collected.
//
// The trace reference count of the subchannel must be 0 in... | [
"deleteSelfFromMap",
"checks",
"whether",
"it",
"is",
"valid",
"to",
"delete",
"the",
"subchannel",
"from",
"the",
"map",
"which",
"means",
"deleting",
"the",
"subchannel",
"from",
"channelz",
"s",
"tracking",
"entirely",
".",
"Users",
"can",
"no",
"longer",
"... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/channelz/types.go#L374-L381 |
126,929 | grpc/grpc-go | internal/channelz/util_linux.go | GetSocketOption | func GetSocketOption(socket interface{}) *SocketOptionData {
c, ok := socket.(syscall.Conn)
if !ok {
return nil
}
data := &SocketOptionData{}
if rawConn, err := c.SyscallConn(); err == nil {
rawConn.Control(data.Getsockopt)
return data
}
return nil
} | go | func GetSocketOption(socket interface{}) *SocketOptionData {
c, ok := socket.(syscall.Conn)
if !ok {
return nil
}
data := &SocketOptionData{}
if rawConn, err := c.SyscallConn(); err == nil {
rawConn.Control(data.Getsockopt)
return data
}
return nil
} | [
"func",
"GetSocketOption",
"(",
"socket",
"interface",
"{",
"}",
")",
"*",
"SocketOptionData",
"{",
"c",
",",
"ok",
":=",
"socket",
".",
"(",
"syscall",
".",
"Conn",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"data",
":=",
"... | // GetSocketOption gets the socket option info of the conn. | [
"GetSocketOption",
"gets",
"the",
"socket",
"option",
"info",
"of",
"the",
"conn",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/channelz/util_linux.go#L28-L39 |
126,930 | grpc/grpc-go | benchmark/latency/latency.go | Conn | func (n *Network) Conn(c net.Conn) (net.Conn, error) {
start := now()
nc := &conn{Conn: c, network: n, readBuf: new(bytes.Buffer)}
if err := nc.sync(); err != nil {
return nil, err
}
sleep(start.Add(nc.delay).Sub(now()))
return nc, nil
} | go | func (n *Network) Conn(c net.Conn) (net.Conn, error) {
start := now()
nc := &conn{Conn: c, network: n, readBuf: new(bytes.Buffer)}
if err := nc.sync(); err != nil {
return nil, err
}
sleep(start.Add(nc.delay).Sub(now()))
return nc, nil
} | [
"func",
"(",
"n",
"*",
"Network",
")",
"Conn",
"(",
"c",
"net",
".",
"Conn",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"start",
":=",
"now",
"(",
")",
"\n",
"nc",
":=",
"&",
"conn",
"{",
"Conn",
":",
"c",
",",
"network",
":",
"n... | // Conn returns a net.Conn that wraps c and injects n's latency into that
// connection. This function also imposes latency for connection creation.
// If n's Latency is lower than the measured latency in c, an error is
// returned. | [
"Conn",
"returns",
"a",
"net",
".",
"Conn",
"that",
"wraps",
"c",
"and",
"injects",
"n",
"s",
"latency",
"into",
"that",
"connection",
".",
"This",
"function",
"also",
"imposes",
"latency",
"for",
"connection",
"creation",
".",
"If",
"n",
"s",
"Latency",
... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/latency/latency.go#L80-L88 |
126,931 | grpc/grpc-go | benchmark/latency/latency.go | sync | func (c *conn) sync() error {
const (
pingMsg = "syncPing"
warmup = 10 // minimum number of iterations to measure latency
giveUp = 50 // maximum number of iterations to measure latency
accuracy = time.Millisecond // req'd accuracy to stop early
goodRun = 3 // ... | go | func (c *conn) sync() error {
const (
pingMsg = "syncPing"
warmup = 10 // minimum number of iterations to measure latency
giveUp = 50 // maximum number of iterations to measure latency
accuracy = time.Millisecond // req'd accuracy to stop early
goodRun = 3 // ... | [
"func",
"(",
"c",
"*",
"conn",
")",
"sync",
"(",
")",
"error",
"{",
"const",
"(",
"pingMsg",
"=",
"\"",
"\"",
"\n",
"warmup",
"=",
"10",
"// minimum number of iterations to measure latency",
"\n",
"giveUp",
"=",
"50",
"// maximum number of iterations to measure la... | // sync does a handshake and then measures the latency on the network in
// coordination with the other side. | [
"sync",
"does",
"a",
"handshake",
"and",
"then",
"measures",
"the",
"latency",
"on",
"the",
"network",
"in",
"coordination",
"with",
"the",
"other",
"side",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/latency/latency.go#L157-L244 |
126,932 | grpc/grpc-go | benchmark/latency/latency.go | Listener | func (n *Network) Listener(l net.Listener) net.Listener {
return &listener{Listener: l, network: n}
} | go | func (n *Network) Listener(l net.Listener) net.Listener {
return &listener{Listener: l, network: n}
} | [
"func",
"(",
"n",
"*",
"Network",
")",
"Listener",
"(",
"l",
"net",
".",
"Listener",
")",
"net",
".",
"Listener",
"{",
"return",
"&",
"listener",
"{",
"Listener",
":",
"l",
",",
"network",
":",
"n",
"}",
"\n",
"}"
] | // Listener returns a net.Listener that wraps l and injects n's latency in its
// connections. | [
"Listener",
"returns",
"a",
"net",
".",
"Listener",
"that",
"wraps",
"l",
"and",
"injects",
"n",
"s",
"latency",
"in",
"its",
"connections",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/latency/latency.go#L248-L250 |
126,933 | grpc/grpc-go | benchmark/latency/latency.go | Dialer | func (n *Network) Dialer(d Dialer) Dialer {
return func(network, address string) (net.Conn, error) {
conn, err := d(network, address)
if err != nil {
return nil, err
}
return n.Conn(conn)
}
} | go | func (n *Network) Dialer(d Dialer) Dialer {
return func(network, address string) (net.Conn, error) {
conn, err := d(network, address)
if err != nil {
return nil, err
}
return n.Conn(conn)
}
} | [
"func",
"(",
"n",
"*",
"Network",
")",
"Dialer",
"(",
"d",
"Dialer",
")",
"Dialer",
"{",
"return",
"func",
"(",
"network",
",",
"address",
"string",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"d",
"(",
"networ... | // Dialer returns a Dialer that wraps d and injects n's latency in its
// connections. n's Latency is also injected to the connection's creation. | [
"Dialer",
"returns",
"a",
"Dialer",
"that",
"wraps",
"d",
"and",
"injects",
"n",
"s",
"latency",
"in",
"its",
"connections",
".",
"n",
"s",
"Latency",
"is",
"also",
"injected",
"to",
"the",
"connection",
"s",
"creation",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/latency/latency.go#L267-L275 |
126,934 | grpc/grpc-go | benchmark/latency/latency.go | TimeoutDialer | func (n *Network) TimeoutDialer(d TimeoutDialer) TimeoutDialer {
return func(network, address string, timeout time.Duration) (net.Conn, error) {
conn, err := d(network, address, timeout)
if err != nil {
return nil, err
}
return n.Conn(conn)
}
} | go | func (n *Network) TimeoutDialer(d TimeoutDialer) TimeoutDialer {
return func(network, address string, timeout time.Duration) (net.Conn, error) {
conn, err := d(network, address, timeout)
if err != nil {
return nil, err
}
return n.Conn(conn)
}
} | [
"func",
"(",
"n",
"*",
"Network",
")",
"TimeoutDialer",
"(",
"d",
"TimeoutDialer",
")",
"TimeoutDialer",
"{",
"return",
"func",
"(",
"network",
",",
"address",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"net",
".",
"Conn",
",",
"error",... | // TimeoutDialer returns a TimeoutDialer that wraps d and injects n's latency
// in its connections. n's Latency is also injected to the connection's
// creation. | [
"TimeoutDialer",
"returns",
"a",
"TimeoutDialer",
"that",
"wraps",
"d",
"and",
"injects",
"n",
"s",
"latency",
"in",
"its",
"connections",
".",
"n",
"s",
"Latency",
"is",
"also",
"injected",
"to",
"the",
"connection",
"s",
"creation",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/latency/latency.go#L280-L288 |
126,935 | grpc/grpc-go | benchmark/latency/latency.go | ContextDialer | func (n *Network) ContextDialer(d ContextDialer) ContextDialer {
return func(ctx context.Context, network, address string) (net.Conn, error) {
conn, err := d(ctx, network, address)
if err != nil {
return nil, err
}
return n.Conn(conn)
}
} | go | func (n *Network) ContextDialer(d ContextDialer) ContextDialer {
return func(ctx context.Context, network, address string) (net.Conn, error) {
conn, err := d(ctx, network, address)
if err != nil {
return nil, err
}
return n.Conn(conn)
}
} | [
"func",
"(",
"n",
"*",
"Network",
")",
"ContextDialer",
"(",
"d",
"ContextDialer",
")",
"ContextDialer",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"network",
",",
"address",
"string",
")",
"(",
"net",
".",
"Conn",
",",
"error",
... | // ContextDialer returns a ContextDialer that wraps d and injects n's latency
// in its connections. n's Latency is also injected to the connection's
// creation. | [
"ContextDialer",
"returns",
"a",
"ContextDialer",
"that",
"wraps",
"d",
"and",
"injects",
"n",
"s",
"latency",
"in",
"its",
"connections",
".",
"n",
"s",
"Latency",
"is",
"also",
"injected",
"to",
"the",
"connection",
"s",
"creation",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/latency/latency.go#L293-L301 |
126,936 | grpc/grpc-go | benchmark/latency/latency.go | pktTime | func (n *Network) pktTime(b int) time.Duration {
if n.Kbps <= 0 {
return time.Duration(0)
}
return time.Duration(b) * time.Second / time.Duration(n.Kbps*(1024/8))
} | go | func (n *Network) pktTime(b int) time.Duration {
if n.Kbps <= 0 {
return time.Duration(0)
}
return time.Duration(b) * time.Second / time.Duration(n.Kbps*(1024/8))
} | [
"func",
"(",
"n",
"*",
"Network",
")",
"pktTime",
"(",
"b",
"int",
")",
"time",
".",
"Duration",
"{",
"if",
"n",
".",
"Kbps",
"<=",
"0",
"{",
"return",
"time",
".",
"Duration",
"(",
"0",
")",
"\n",
"}",
"\n",
"return",
"time",
".",
"Duration",
... | // pktTime returns the time it takes to transmit one packet of data of size b
// in bytes. | [
"pktTime",
"returns",
"the",
"time",
"it",
"takes",
"to",
"transmit",
"one",
"packet",
"of",
"data",
"of",
"size",
"b",
"in",
"bytes",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/latency/latency.go#L305-L310 |
126,937 | grpc/grpc-go | dialoptions.go | WithReadBufferSize | func WithReadBufferSize(s int) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.copts.ReadBufferSize = s
})
} | go | func WithReadBufferSize(s int) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.copts.ReadBufferSize = s
})
} | [
"func",
"WithReadBufferSize",
"(",
"s",
"int",
")",
"DialOption",
"{",
"return",
"newFuncDialOption",
"(",
"func",
"(",
"o",
"*",
"dialOptions",
")",
"{",
"o",
".",
"copts",
".",
"ReadBufferSize",
"=",
"s",
"\n",
"}",
")",
"\n",
"}"
] | // WithReadBufferSize lets you set the size of read buffer, this determines how
// much data can be read at most for each read syscall.
//
// The default value for this buffer is 32KB. Zero will disable read buffer for
// a connection so data framer can access the underlying conn directly. | [
"WithReadBufferSize",
"lets",
"you",
"set",
"the",
"size",
"of",
"read",
"buffer",
"this",
"determines",
"how",
"much",
"data",
"can",
"be",
"read",
"at",
"most",
"for",
"each",
"read",
"syscall",
".",
"The",
"default",
"value",
"for",
"this",
"buffer",
"i... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/dialoptions.go#L132-L136 |
126,938 | grpc/grpc-go | dialoptions.go | WithInitialWindowSize | func WithInitialWindowSize(s int32) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.copts.InitialWindowSize = s
})
} | go | func WithInitialWindowSize(s int32) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.copts.InitialWindowSize = s
})
} | [
"func",
"WithInitialWindowSize",
"(",
"s",
"int32",
")",
"DialOption",
"{",
"return",
"newFuncDialOption",
"(",
"func",
"(",
"o",
"*",
"dialOptions",
")",
"{",
"o",
".",
"copts",
".",
"InitialWindowSize",
"=",
"s",
"\n",
"}",
")",
"\n",
"}"
] | // WithInitialWindowSize returns a DialOption which sets the value for initial
// window size on a stream. The lower bound for window size is 64K and any value
// smaller than that will be ignored. | [
"WithInitialWindowSize",
"returns",
"a",
"DialOption",
"which",
"sets",
"the",
"value",
"for",
"initial",
"window",
"size",
"on",
"a",
"stream",
".",
"The",
"lower",
"bound",
"for",
"window",
"size",
"is",
"64K",
"and",
"any",
"value",
"smaller",
"than",
"th... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/dialoptions.go#L141-L145 |
126,939 | grpc/grpc-go | dialoptions.go | WithInitialConnWindowSize | func WithInitialConnWindowSize(s int32) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.copts.InitialConnWindowSize = s
})
} | go | func WithInitialConnWindowSize(s int32) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.copts.InitialConnWindowSize = s
})
} | [
"func",
"WithInitialConnWindowSize",
"(",
"s",
"int32",
")",
"DialOption",
"{",
"return",
"newFuncDialOption",
"(",
"func",
"(",
"o",
"*",
"dialOptions",
")",
"{",
"o",
".",
"copts",
".",
"InitialConnWindowSize",
"=",
"s",
"\n",
"}",
")",
"\n",
"}"
] | // WithInitialConnWindowSize returns a DialOption which sets the value for
// initial window size on a connection. The lower bound for window size is 64K
// and any value smaller than that will be ignored. | [
"WithInitialConnWindowSize",
"returns",
"a",
"DialOption",
"which",
"sets",
"the",
"value",
"for",
"initial",
"window",
"size",
"on",
"a",
"connection",
".",
"The",
"lower",
"bound",
"for",
"window",
"size",
"is",
"64K",
"and",
"any",
"value",
"smaller",
"than... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/dialoptions.go#L150-L154 |
126,940 | grpc/grpc-go | dialoptions.go | WithDefaultCallOptions | func WithDefaultCallOptions(cos ...CallOption) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.callOptions = append(o.callOptions, cos...)
})
} | go | func WithDefaultCallOptions(cos ...CallOption) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.callOptions = append(o.callOptions, cos...)
})
} | [
"func",
"WithDefaultCallOptions",
"(",
"cos",
"...",
"CallOption",
")",
"DialOption",
"{",
"return",
"newFuncDialOption",
"(",
"func",
"(",
"o",
"*",
"dialOptions",
")",
"{",
"o",
".",
"callOptions",
"=",
"append",
"(",
"o",
".",
"callOptions",
",",
"cos",
... | // WithDefaultCallOptions returns a DialOption which sets the default
// CallOptions for calls over the connection. | [
"WithDefaultCallOptions",
"returns",
"a",
"DialOption",
"which",
"sets",
"the",
"default",
"CallOptions",
"for",
"calls",
"over",
"the",
"connection",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/dialoptions.go#L166-L170 |
126,941 | grpc/grpc-go | dialoptions.go | WithBalancerName | func WithBalancerName(balancerName string) DialOption {
builder := balancer.Get(balancerName)
if builder == nil {
panic(fmt.Sprintf("grpc.WithBalancerName: no balancer is registered for name %v", balancerName))
}
return newFuncDialOption(func(o *dialOptions) {
o.balancerBuilder = builder
})
} | go | func WithBalancerName(balancerName string) DialOption {
builder := balancer.Get(balancerName)
if builder == nil {
panic(fmt.Sprintf("grpc.WithBalancerName: no balancer is registered for name %v", balancerName))
}
return newFuncDialOption(func(o *dialOptions) {
o.balancerBuilder = builder
})
} | [
"func",
"WithBalancerName",
"(",
"balancerName",
"string",
")",
"DialOption",
"{",
"builder",
":=",
"balancer",
".",
"Get",
"(",
"balancerName",
")",
"\n",
"if",
"builder",
"==",
"nil",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"bal... | // WithBalancerName sets the balancer that the ClientConn will be initialized
// with. Balancer registered with balancerName will be used. This function
// panics if no balancer was registered by balancerName.
//
// The balancer cannot be overridden by balancer option specified by service
// config.
//
// This is an EX... | [
"WithBalancerName",
"sets",
"the",
"balancer",
"that",
"the",
"ClientConn",
"will",
"be",
"initialized",
"with",
".",
"Balancer",
"registered",
"with",
"balancerName",
"will",
"be",
"used",
".",
"This",
"function",
"panics",
"if",
"no",
"balancer",
"was",
"regis... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/dialoptions.go#L227-L235 |
126,942 | grpc/grpc-go | dialoptions.go | withResolverBuilder | func withResolverBuilder(b resolver.Builder) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.resolverBuilder = b
})
} | go | func withResolverBuilder(b resolver.Builder) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.resolverBuilder = b
})
} | [
"func",
"withResolverBuilder",
"(",
"b",
"resolver",
".",
"Builder",
")",
"DialOption",
"{",
"return",
"newFuncDialOption",
"(",
"func",
"(",
"o",
"*",
"dialOptions",
")",
"{",
"o",
".",
"resolverBuilder",
"=",
"b",
"\n",
"}",
")",
"\n",
"}"
] | // withResolverBuilder is only for grpclb. | [
"withResolverBuilder",
"is",
"only",
"for",
"grpclb",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/dialoptions.go#L238-L242 |
126,943 | grpc/grpc-go | dialoptions.go | WithBackoffConfig | func WithBackoffConfig(b BackoffConfig) DialOption {
return withBackoff(backoff.Exponential{
MaxDelay: b.MaxDelay,
})
} | go | func WithBackoffConfig(b BackoffConfig) DialOption {
return withBackoff(backoff.Exponential{
MaxDelay: b.MaxDelay,
})
} | [
"func",
"WithBackoffConfig",
"(",
"b",
"BackoffConfig",
")",
"DialOption",
"{",
"return",
"withBackoff",
"(",
"backoff",
".",
"Exponential",
"{",
"MaxDelay",
":",
"b",
".",
"MaxDelay",
",",
"}",
")",
"\n",
"}"
] | // WithBackoffConfig configures the dialer to use the provided backoff
// parameters after connection failures.
//
// Use WithBackoffMaxDelay until more parameters on BackoffConfig are opened up
// for use. | [
"WithBackoffConfig",
"configures",
"the",
"dialer",
"to",
"use",
"the",
"provided",
"backoff",
"parameters",
"after",
"connection",
"failures",
".",
"Use",
"WithBackoffMaxDelay",
"until",
"more",
"parameters",
"on",
"BackoffConfig",
"are",
"opened",
"up",
"for",
"us... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/dialoptions.go#L267-L271 |
126,944 | grpc/grpc-go | dialoptions.go | withBackoff | func withBackoff(bs backoff.Strategy) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.bs = bs
})
} | go | func withBackoff(bs backoff.Strategy) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.bs = bs
})
} | [
"func",
"withBackoff",
"(",
"bs",
"backoff",
".",
"Strategy",
")",
"DialOption",
"{",
"return",
"newFuncDialOption",
"(",
"func",
"(",
"o",
"*",
"dialOptions",
")",
"{",
"o",
".",
"bs",
"=",
"bs",
"\n",
"}",
")",
"\n",
"}"
] | // withBackoff sets the backoff strategy used for connectRetryNum after a failed
// connection attempt.
//
// This can be exported if arbitrary backoff strategies are allowed by gRPC. | [
"withBackoff",
"sets",
"the",
"backoff",
"strategy",
"used",
"for",
"connectRetryNum",
"after",
"a",
"failed",
"connection",
"attempt",
".",
"This",
"can",
"be",
"exported",
"if",
"arbitrary",
"backoff",
"strategies",
"are",
"allowed",
"by",
"gRPC",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/dialoptions.go#L277-L281 |
126,945 | grpc/grpc-go | dialoptions.go | WithPerRPCCredentials | func WithPerRPCCredentials(creds credentials.PerRPCCredentials) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.copts.PerRPCCredentials = append(o.copts.PerRPCCredentials, creds)
})
} | go | func WithPerRPCCredentials(creds credentials.PerRPCCredentials) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.copts.PerRPCCredentials = append(o.copts.PerRPCCredentials, creds)
})
} | [
"func",
"WithPerRPCCredentials",
"(",
"creds",
"credentials",
".",
"PerRPCCredentials",
")",
"DialOption",
"{",
"return",
"newFuncDialOption",
"(",
"func",
"(",
"o",
"*",
"dialOptions",
")",
"{",
"o",
".",
"copts",
".",
"PerRPCCredentials",
"=",
"append",
"(",
... | // WithPerRPCCredentials returns a DialOption which sets credentials and places
// auth state on each outbound RPC. | [
"WithPerRPCCredentials",
"returns",
"a",
"DialOption",
"which",
"sets",
"credentials",
"and",
"places",
"auth",
"state",
"on",
"each",
"outbound",
"RPC",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/dialoptions.go#L312-L316 |
126,946 | grpc/grpc-go | dialoptions.go | WithCredentialsBundle | func WithCredentialsBundle(b credentials.Bundle) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.copts.CredsBundle = b
})
} | go | func WithCredentialsBundle(b credentials.Bundle) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.copts.CredsBundle = b
})
} | [
"func",
"WithCredentialsBundle",
"(",
"b",
"credentials",
".",
"Bundle",
")",
"DialOption",
"{",
"return",
"newFuncDialOption",
"(",
"func",
"(",
"o",
"*",
"dialOptions",
")",
"{",
"o",
".",
"copts",
".",
"CredsBundle",
"=",
"b",
"\n",
"}",
")",
"\n",
"}... | // WithCredentialsBundle returns a DialOption to set a credentials bundle for
// the ClientConn.WithCreds. This should not be used together with
// WithTransportCredentials.
//
// This API is experimental. | [
"WithCredentialsBundle",
"returns",
"a",
"DialOption",
"to",
"set",
"a",
"credentials",
"bundle",
"for",
"the",
"ClientConn",
".",
"WithCreds",
".",
"This",
"should",
"not",
"be",
"used",
"together",
"with",
"WithTransportCredentials",
".",
"This",
"API",
"is",
... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/dialoptions.go#L323-L327 |
126,947 | grpc/grpc-go | dialoptions.go | WithStatsHandler | func WithStatsHandler(h stats.Handler) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.copts.StatsHandler = h
})
} | go | func WithStatsHandler(h stats.Handler) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.copts.StatsHandler = h
})
} | [
"func",
"WithStatsHandler",
"(",
"h",
"stats",
".",
"Handler",
")",
"DialOption",
"{",
"return",
"newFuncDialOption",
"(",
"func",
"(",
"o",
"*",
"dialOptions",
")",
"{",
"o",
".",
"copts",
".",
"StatsHandler",
"=",
"h",
"\n",
"}",
")",
"\n",
"}"
] | // WithStatsHandler returns a DialOption that specifies the stats handler for
// all the RPCs and underlying network connections in this ClientConn. | [
"WithStatsHandler",
"returns",
"a",
"DialOption",
"that",
"specifies",
"the",
"stats",
"handler",
"for",
"all",
"the",
"RPCs",
"and",
"underlying",
"network",
"connections",
"in",
"this",
"ClientConn",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/dialoptions.go#L372-L376 |
126,948 | grpc/grpc-go | dialoptions.go | WithUserAgent | func WithUserAgent(s string) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.copts.UserAgent = s
})
} | go | func WithUserAgent(s string) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.copts.UserAgent = s
})
} | [
"func",
"WithUserAgent",
"(",
"s",
"string",
")",
"DialOption",
"{",
"return",
"newFuncDialOption",
"(",
"func",
"(",
"o",
"*",
"dialOptions",
")",
"{",
"o",
".",
"copts",
".",
"UserAgent",
"=",
"s",
"\n",
"}",
")",
"\n",
"}"
] | // WithUserAgent returns a DialOption that specifies a user agent string for all
// the RPCs. | [
"WithUserAgent",
"returns",
"a",
"DialOption",
"that",
"specifies",
"a",
"user",
"agent",
"string",
"for",
"all",
"the",
"RPCs",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/dialoptions.go#L395-L399 |
126,949 | grpc/grpc-go | dialoptions.go | WithKeepaliveParams | func WithKeepaliveParams(kp keepalive.ClientParameters) DialOption {
if kp.Time < internal.KeepaliveMinPingTime {
grpclog.Warningf("Adjusting keepalive ping interval to minimum period of %v", internal.KeepaliveMinPingTime)
kp.Time = internal.KeepaliveMinPingTime
}
return newFuncDialOption(func(o *dialOptions) {
... | go | func WithKeepaliveParams(kp keepalive.ClientParameters) DialOption {
if kp.Time < internal.KeepaliveMinPingTime {
grpclog.Warningf("Adjusting keepalive ping interval to minimum period of %v", internal.KeepaliveMinPingTime)
kp.Time = internal.KeepaliveMinPingTime
}
return newFuncDialOption(func(o *dialOptions) {
... | [
"func",
"WithKeepaliveParams",
"(",
"kp",
"keepalive",
".",
"ClientParameters",
")",
"DialOption",
"{",
"if",
"kp",
".",
"Time",
"<",
"internal",
".",
"KeepaliveMinPingTime",
"{",
"grpclog",
".",
"Warningf",
"(",
"\"",
"\"",
",",
"internal",
".",
"KeepaliveMin... | // WithKeepaliveParams returns a DialOption that specifies keepalive parameters
// for the client transport. | [
"WithKeepaliveParams",
"returns",
"a",
"DialOption",
"that",
"specifies",
"keepalive",
"parameters",
"for",
"the",
"client",
"transport",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/dialoptions.go#L403-L411 |
126,950 | grpc/grpc-go | dialoptions.go | WithUnaryInterceptor | func WithUnaryInterceptor(f UnaryClientInterceptor) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.unaryInt = f
})
} | go | func WithUnaryInterceptor(f UnaryClientInterceptor) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.unaryInt = f
})
} | [
"func",
"WithUnaryInterceptor",
"(",
"f",
"UnaryClientInterceptor",
")",
"DialOption",
"{",
"return",
"newFuncDialOption",
"(",
"func",
"(",
"o",
"*",
"dialOptions",
")",
"{",
"o",
".",
"unaryInt",
"=",
"f",
"\n",
"}",
")",
"\n",
"}"
] | // WithUnaryInterceptor returns a DialOption that specifies the interceptor for
// unary RPCs. | [
"WithUnaryInterceptor",
"returns",
"a",
"DialOption",
"that",
"specifies",
"the",
"interceptor",
"for",
"unary",
"RPCs",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/dialoptions.go#L415-L419 |
126,951 | grpc/grpc-go | dialoptions.go | WithChainUnaryInterceptor | func WithChainUnaryInterceptor(interceptors ...UnaryClientInterceptor) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.chainUnaryInts = append(o.chainUnaryInts, interceptors...)
})
} | go | func WithChainUnaryInterceptor(interceptors ...UnaryClientInterceptor) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.chainUnaryInts = append(o.chainUnaryInts, interceptors...)
})
} | [
"func",
"WithChainUnaryInterceptor",
"(",
"interceptors",
"...",
"UnaryClientInterceptor",
")",
"DialOption",
"{",
"return",
"newFuncDialOption",
"(",
"func",
"(",
"o",
"*",
"dialOptions",
")",
"{",
"o",
".",
"chainUnaryInts",
"=",
"append",
"(",
"o",
".",
"chai... | // WithChainUnaryInterceptor returns a DialOption that specifies the chained
// interceptor for unary RPCs. The first interceptor will be the outer most,
// while the last interceptor will be the inner most wrapper around the real call.
// All interceptors added by this method will be chained, and the interceptor
// de... | [
"WithChainUnaryInterceptor",
"returns",
"a",
"DialOption",
"that",
"specifies",
"the",
"chained",
"interceptor",
"for",
"unary",
"RPCs",
".",
"The",
"first",
"interceptor",
"will",
"be",
"the",
"outer",
"most",
"while",
"the",
"last",
"interceptor",
"will",
"be",
... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/dialoptions.go#L426-L430 |
126,952 | grpc/grpc-go | dialoptions.go | WithStreamInterceptor | func WithStreamInterceptor(f StreamClientInterceptor) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.streamInt = f
})
} | go | func WithStreamInterceptor(f StreamClientInterceptor) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.streamInt = f
})
} | [
"func",
"WithStreamInterceptor",
"(",
"f",
"StreamClientInterceptor",
")",
"DialOption",
"{",
"return",
"newFuncDialOption",
"(",
"func",
"(",
"o",
"*",
"dialOptions",
")",
"{",
"o",
".",
"streamInt",
"=",
"f",
"\n",
"}",
")",
"\n",
"}"
] | // WithStreamInterceptor returns a DialOption that specifies the interceptor for
// streaming RPCs. | [
"WithStreamInterceptor",
"returns",
"a",
"DialOption",
"that",
"specifies",
"the",
"interceptor",
"for",
"streaming",
"RPCs",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/dialoptions.go#L434-L438 |
126,953 | grpc/grpc-go | dialoptions.go | WithChainStreamInterceptor | func WithChainStreamInterceptor(interceptors ...StreamClientInterceptor) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.chainStreamInts = append(o.chainStreamInts, interceptors...)
})
} | go | func WithChainStreamInterceptor(interceptors ...StreamClientInterceptor) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.chainStreamInts = append(o.chainStreamInts, interceptors...)
})
} | [
"func",
"WithChainStreamInterceptor",
"(",
"interceptors",
"...",
"StreamClientInterceptor",
")",
"DialOption",
"{",
"return",
"newFuncDialOption",
"(",
"func",
"(",
"o",
"*",
"dialOptions",
")",
"{",
"o",
".",
"chainStreamInts",
"=",
"append",
"(",
"o",
".",
"c... | // WithChainStreamInterceptor returns a DialOption that specifies the chained
// interceptor for unary RPCs. The first interceptor will be the outer most,
// while the last interceptor will be the inner most wrapper around the real call.
// All interceptors added by this method will be chained, and the interceptor
// d... | [
"WithChainStreamInterceptor",
"returns",
"a",
"DialOption",
"that",
"specifies",
"the",
"chained",
"interceptor",
"for",
"unary",
"RPCs",
".",
"The",
"first",
"interceptor",
"will",
"be",
"the",
"outer",
"most",
"while",
"the",
"last",
"interceptor",
"will",
"be",... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/dialoptions.go#L445-L449 |
126,954 | grpc/grpc-go | dialoptions.go | withHealthCheckFunc | func withHealthCheckFunc(f internal.HealthChecker) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.healthCheckFunc = f
})
} | go | func withHealthCheckFunc(f internal.HealthChecker) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.healthCheckFunc = f
})
} | [
"func",
"withHealthCheckFunc",
"(",
"f",
"internal",
".",
"HealthChecker",
")",
"DialOption",
"{",
"return",
"newFuncDialOption",
"(",
"func",
"(",
"o",
"*",
"dialOptions",
")",
"{",
"o",
".",
"healthCheckFunc",
"=",
"f",
"\n",
"}",
")",
"\n",
"}"
] | // withHealthCheckFunc replaces the default health check function with the
// provided one. It makes tests easier to change the health check function.
//
// For testing purpose only. | [
"withHealthCheckFunc",
"replaces",
"the",
"default",
"health",
"check",
"function",
"with",
"the",
"provided",
"one",
".",
"It",
"makes",
"tests",
"easier",
"to",
"change",
"the",
"health",
"check",
"function",
".",
"For",
"testing",
"purpose",
"only",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/dialoptions.go#L531-L535 |
126,955 | grpc/grpc-go | internal/grpcsync/event.go | Fire | func (e *Event) Fire() bool {
ret := false
e.o.Do(func() {
atomic.StoreInt32(&e.fired, 1)
close(e.c)
ret = true
})
return ret
} | go | func (e *Event) Fire() bool {
ret := false
e.o.Do(func() {
atomic.StoreInt32(&e.fired, 1)
close(e.c)
ret = true
})
return ret
} | [
"func",
"(",
"e",
"*",
"Event",
")",
"Fire",
"(",
")",
"bool",
"{",
"ret",
":=",
"false",
"\n",
"e",
".",
"o",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"atomic",
".",
"StoreInt32",
"(",
"&",
"e",
".",
"fired",
",",
"1",
")",
"\n",
"close",
"(... | // Fire causes e to complete. It is safe to call multiple times, and
// concurrently. It returns true iff this call to Fire caused the signaling
// channel returned by Done to close. | [
"Fire",
"causes",
"e",
"to",
"complete",
".",
"It",
"is",
"safe",
"to",
"call",
"multiple",
"times",
"and",
"concurrently",
".",
"It",
"returns",
"true",
"iff",
"this",
"call",
"to",
"Fire",
"caused",
"the",
"signaling",
"channel",
"returned",
"by",
"Done"... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/grpcsync/event.go#L38-L46 |
126,956 | grpc/grpc-go | credentials/alts/internal/conn/aes128gcmrekey.go | NewAES128GCMRekey | func NewAES128GCMRekey(side core.Side, key []byte) (ALTSRecordCrypto, error) {
inCounter := NewInCounter(side, overflowLenAES128GCMRekey)
outCounter := NewOutCounter(side, overflowLenAES128GCMRekey)
inAEAD, err := newRekeyAEAD(key)
if err != nil {
return nil, err
}
outAEAD, err := newRekeyAEAD(key)
if err != n... | go | func NewAES128GCMRekey(side core.Side, key []byte) (ALTSRecordCrypto, error) {
inCounter := NewInCounter(side, overflowLenAES128GCMRekey)
outCounter := NewOutCounter(side, overflowLenAES128GCMRekey)
inAEAD, err := newRekeyAEAD(key)
if err != nil {
return nil, err
}
outAEAD, err := newRekeyAEAD(key)
if err != n... | [
"func",
"NewAES128GCMRekey",
"(",
"side",
"core",
".",
"Side",
",",
"key",
"[",
"]",
"byte",
")",
"(",
"ALTSRecordCrypto",
",",
"error",
")",
"{",
"inCounter",
":=",
"NewInCounter",
"(",
"side",
",",
"overflowLenAES128GCMRekey",
")",
"\n",
"outCounter",
":="... | // NewAES128GCMRekey creates an instance that uses aes128gcm with rekeying
// for ALTS record. The key argument should be 44 bytes, the first 32 bytes
// are used as a key for HKDF-expand and the remainining 12 bytes are used
// as a random mask for the counter. | [
"NewAES128GCMRekey",
"creates",
"an",
"instance",
"that",
"uses",
"aes128gcm",
"with",
"rekeying",
"for",
"ALTS",
"record",
".",
"The",
"key",
"argument",
"should",
"be",
"44",
"bytes",
"the",
"first",
"32",
"bytes",
"are",
"used",
"as",
"a",
"key",
"for",
... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/internal/conn/aes128gcmrekey.go#L56-L73 |
126,957 | grpc/grpc-go | benchmark/stats/stats.go | String | func (f Features) String() string {
return fmt.Sprintf("traceMode_%t-latency_%s-kbps_%#v-MTU_%#v-maxConcurrentCalls_"+
"%#v-reqSize_%#vB-respSize_%#vB-Compressor_%s-Preloader_%t", f.EnableTrace,
f.Latency.String(), f.Kbps, f.Mtu, f.MaxConcurrentCalls, f.ReqSizeBytes, f.RespSizeBytes, f.ModeCompressor, f.EnablePrel... | go | func (f Features) String() string {
return fmt.Sprintf("traceMode_%t-latency_%s-kbps_%#v-MTU_%#v-maxConcurrentCalls_"+
"%#v-reqSize_%#vB-respSize_%#vB-Compressor_%s-Preloader_%t", f.EnableTrace,
f.Latency.String(), f.Kbps, f.Mtu, f.MaxConcurrentCalls, f.ReqSizeBytes, f.RespSizeBytes, f.ModeCompressor, f.EnablePrel... | [
"func",
"(",
"f",
"Features",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"f",
".",
"EnableTrace",
",",
"f",
".",
"Latency",
".",
"String",
"(",
")",
",",
"f",
".",
"Kbps",
","... | // String returns the textual output of the Features as string. | [
"String",
"returns",
"the",
"textual",
"output",
"of",
"the",
"Features",
"as",
"string",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/stats/stats.go#L48-L52 |
126,958 | grpc/grpc-go | benchmark/stats/stats.go | ConciseString | func (f Features) ConciseString() string {
noneEmptyPos := []bool{f.EnableTrace, f.Latency != 0, f.Kbps != 0, f.Mtu != 0, true, true, true, f.ModeCompressor != "off", f.EnableChannelz, f.EnablePreloader}
return PartialPrintString(noneEmptyPos, f, false)
} | go | func (f Features) ConciseString() string {
noneEmptyPos := []bool{f.EnableTrace, f.Latency != 0, f.Kbps != 0, f.Mtu != 0, true, true, true, f.ModeCompressor != "off", f.EnableChannelz, f.EnablePreloader}
return PartialPrintString(noneEmptyPos, f, false)
} | [
"func",
"(",
"f",
"Features",
")",
"ConciseString",
"(",
")",
"string",
"{",
"noneEmptyPos",
":=",
"[",
"]",
"bool",
"{",
"f",
".",
"EnableTrace",
",",
"f",
".",
"Latency",
"!=",
"0",
",",
"f",
".",
"Kbps",
"!=",
"0",
",",
"f",
".",
"Mtu",
"!=",
... | // ConciseString returns the concise textual output of the Features as string, skipping
// setting with default value. | [
"ConciseString",
"returns",
"the",
"concise",
"textual",
"output",
"of",
"the",
"Features",
"as",
"string",
"skipping",
"setting",
"with",
"default",
"value",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/stats/stats.go#L56-L59 |
126,959 | grpc/grpc-go | benchmark/stats/stats.go | PartialPrintString | func PartialPrintString(noneEmptyPos []bool, f Features, shared bool) string {
s := ""
var (
prefix, suffix, linker string
isNetwork bool
)
if shared {
suffix = "\n"
linker = ": "
} else {
prefix = "-"
linker = "_"
}
if noneEmptyPos[0] {
s += fmt.Sprintf("%sTrace%s%t%s", prefix, linker... | go | func PartialPrintString(noneEmptyPos []bool, f Features, shared bool) string {
s := ""
var (
prefix, suffix, linker string
isNetwork bool
)
if shared {
suffix = "\n"
linker = ": "
} else {
prefix = "-"
linker = "_"
}
if noneEmptyPos[0] {
s += fmt.Sprintf("%sTrace%s%t%s", prefix, linker... | [
"func",
"PartialPrintString",
"(",
"noneEmptyPos",
"[",
"]",
"bool",
",",
"f",
"Features",
",",
"shared",
"bool",
")",
"string",
"{",
"s",
":=",
"\"",
"\"",
"\n",
"var",
"(",
"prefix",
",",
"suffix",
",",
"linker",
"string",
"\n",
"isNetwork",
"bool",
... | // PartialPrintString can print certain features with different format. | [
"PartialPrintString",
"can",
"print",
"certain",
"features",
"with",
"different",
"format",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/stats/stats.go#L62-L112 |
126,960 | grpc/grpc-go | benchmark/stats/stats.go | SetBenchmarkResult | func (stats *Stats) SetBenchmarkResult(mode string, features Features, o int, allocdBytes, allocs int64, sharedPos []bool) {
stats.result.RunMode = mode
stats.result.Features = features
stats.result.Operations = o
stats.result.AllocedBytesPerOp = allocdBytes
stats.result.AllocsPerOp = allocs
stats.result.SharedPo... | go | func (stats *Stats) SetBenchmarkResult(mode string, features Features, o int, allocdBytes, allocs int64, sharedPos []bool) {
stats.result.RunMode = mode
stats.result.Features = features
stats.result.Operations = o
stats.result.AllocedBytesPerOp = allocdBytes
stats.result.AllocsPerOp = allocs
stats.result.SharedPo... | [
"func",
"(",
"stats",
"*",
"Stats",
")",
"SetBenchmarkResult",
"(",
"mode",
"string",
",",
"features",
"Features",
",",
"o",
"int",
",",
"allocdBytes",
",",
"allocs",
"int64",
",",
"sharedPos",
"[",
"]",
"bool",
")",
"{",
"stats",
".",
"result",
".",
"... | // SetBenchmarkResult sets features of benchmark and basic results. | [
"SetBenchmarkResult",
"sets",
"features",
"of",
"benchmark",
"and",
"basic",
"results",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/stats/stats.go#L132-L139 |
126,961 | grpc/grpc-go | benchmark/stats/stats.go | BenchString | func (stats *Stats) BenchString() string {
stats.maybeUpdate()
s := stats.result
res := s.RunMode + "-" + s.Features.String() + ": \n"
if len(s.Latency) != 0 {
var statsUnit = s.Latency[0].Value
var timeUnit = fmt.Sprintf("%v", statsUnit)[1:]
for i := 1; i < len(s.Latency)-1; i++ {
res += fmt.Sprintf("%d_L... | go | func (stats *Stats) BenchString() string {
stats.maybeUpdate()
s := stats.result
res := s.RunMode + "-" + s.Features.String() + ": \n"
if len(s.Latency) != 0 {
var statsUnit = s.Latency[0].Value
var timeUnit = fmt.Sprintf("%v", statsUnit)[1:]
for i := 1; i < len(s.Latency)-1; i++ {
res += fmt.Sprintf("%d_L... | [
"func",
"(",
"stats",
"*",
"Stats",
")",
"BenchString",
"(",
")",
"string",
"{",
"stats",
".",
"maybeUpdate",
"(",
")",
"\n",
"s",
":=",
"stats",
".",
"result",
"\n",
"res",
":=",
"s",
".",
"RunMode",
"+",
"\"",
"\"",
"+",
"s",
".",
"Features",
"... | // BenchString output latency stats as the format as time + unit. | [
"BenchString",
"output",
"latency",
"stats",
"as",
"the",
"format",
"as",
"time",
"+",
"unit",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/stats/stats.go#L147-L166 |
126,962 | grpc/grpc-go | benchmark/stats/stats.go | Add | func (stats *Stats) Add(d time.Duration) {
stats.durations = append(stats.durations, d)
stats.dirty = true
} | go | func (stats *Stats) Add(d time.Duration) {
stats.durations = append(stats.durations, d)
stats.dirty = true
} | [
"func",
"(",
"stats",
"*",
"Stats",
")",
"Add",
"(",
"d",
"time",
".",
"Duration",
")",
"{",
"stats",
".",
"durations",
"=",
"append",
"(",
"stats",
".",
"durations",
",",
"d",
")",
"\n",
"stats",
".",
"dirty",
"=",
"true",
"\n",
"}"
] | // Add adds an elapsed time per operation to the stats. | [
"Add",
"adds",
"an",
"elapsed",
"time",
"per",
"operation",
"to",
"the",
"stats",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/stats/stats.go#L199-L202 |
126,963 | grpc/grpc-go | benchmark/stats/stats.go | Clear | func (stats *Stats) Clear() {
stats.durations = stats.durations[:0]
stats.histogram = nil
stats.dirty = false
stats.result = BenchResults{}
} | go | func (stats *Stats) Clear() {
stats.durations = stats.durations[:0]
stats.histogram = nil
stats.dirty = false
stats.result = BenchResults{}
} | [
"func",
"(",
"stats",
"*",
"Stats",
")",
"Clear",
"(",
")",
"{",
"stats",
".",
"durations",
"=",
"stats",
".",
"durations",
"[",
":",
"0",
"]",
"\n",
"stats",
".",
"histogram",
"=",
"nil",
"\n",
"stats",
".",
"dirty",
"=",
"false",
"\n",
"stats",
... | // Clear resets the stats, removing all values. | [
"Clear",
"resets",
"the",
"stats",
"removing",
"all",
"values",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/stats/stats.go#L205-L210 |
126,964 | grpc/grpc-go | benchmark/stats/stats.go | maybeUpdate | func (stats *Stats) maybeUpdate() {
if !stats.dirty {
return
}
if stats.sortLatency {
sort.Sort(stats.durations)
stats.min = int64(stats.durations[0])
stats.max = int64(stats.durations[len(stats.durations)-1])
}
stats.min = math.MaxInt64
stats.max = 0
for _, d := range stats.durations {
if stats.min ... | go | func (stats *Stats) maybeUpdate() {
if !stats.dirty {
return
}
if stats.sortLatency {
sort.Sort(stats.durations)
stats.min = int64(stats.durations[0])
stats.max = int64(stats.durations[len(stats.durations)-1])
}
stats.min = math.MaxInt64
stats.max = 0
for _, d := range stats.durations {
if stats.min ... | [
"func",
"(",
"stats",
"*",
"Stats",
")",
"maybeUpdate",
"(",
")",
"{",
"if",
"!",
"stats",
".",
"dirty",
"{",
"return",
"\n",
"}",
"\n\n",
"if",
"stats",
".",
"sortLatency",
"{",
"sort",
".",
"Sort",
"(",
"stats",
".",
"durations",
")",
"\n",
"stat... | // maybeUpdate updates internal stat data if there was any newly added
// stats since this was updated. | [
"maybeUpdate",
"updates",
"internal",
"stat",
"data",
"if",
"there",
"was",
"any",
"newly",
"added",
"stats",
"since",
"this",
"was",
"updated",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/stats/stats.go#L225-L284 |
126,965 | grpc/grpc-go | benchmark/stats/stats.go | Print | func (stats *Stats) Print(w io.Writer) {
stats.maybeUpdate()
if stats.histogram == nil {
fmt.Fprint(w, "Histogram (empty)\n")
} else {
fmt.Fprintf(w, "Histogram (unit: %s)\n", fmt.Sprintf("%v", stats.unit)[1:])
stats.histogram.PrintWithUnit(w, float64(stats.unit))
}
} | go | func (stats *Stats) Print(w io.Writer) {
stats.maybeUpdate()
if stats.histogram == nil {
fmt.Fprint(w, "Histogram (empty)\n")
} else {
fmt.Fprintf(w, "Histogram (unit: %s)\n", fmt.Sprintf("%v", stats.unit)[1:])
stats.histogram.PrintWithUnit(w, float64(stats.unit))
}
} | [
"func",
"(",
"stats",
"*",
"Stats",
")",
"Print",
"(",
"w",
"io",
".",
"Writer",
")",
"{",
"stats",
".",
"maybeUpdate",
"(",
")",
"\n",
"if",
"stats",
".",
"histogram",
"==",
"nil",
"{",
"fmt",
".",
"Fprint",
"(",
"w",
",",
"\"",
"\\n",
"\"",
"... | // Print writes textual output of the Stats. | [
"Print",
"writes",
"textual",
"output",
"of",
"the",
"Stats",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/stats/stats.go#L292-L300 |
126,966 | grpc/grpc-go | benchmark/stats/stats.go | String | func (stats *Stats) String() string {
var b bytes.Buffer
stats.Print(&b)
return b.String()
} | go | func (stats *Stats) String() string {
var b bytes.Buffer
stats.Print(&b)
return b.String()
} | [
"func",
"(",
"stats",
"*",
"Stats",
")",
"String",
"(",
")",
"string",
"{",
"var",
"b",
"bytes",
".",
"Buffer",
"\n",
"stats",
".",
"Print",
"(",
"&",
"b",
")",
"\n",
"return",
"b",
".",
"String",
"(",
")",
"\n",
"}"
] | // String returns the textual output of the Stats as string. | [
"String",
"returns",
"the",
"textual",
"output",
"of",
"the",
"Stats",
"as",
"string",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/benchmark/stats/stats.go#L303-L307 |
126,967 | grpc/grpc-go | internal/syscall/syscall_linux.go | GetCPUTime | func GetCPUTime() int64 {
var ts unix.Timespec
if err := unix.ClockGettime(unix.CLOCK_PROCESS_CPUTIME_ID, &ts); err != nil {
grpclog.Fatal(err)
}
return ts.Nano()
} | go | func GetCPUTime() int64 {
var ts unix.Timespec
if err := unix.ClockGettime(unix.CLOCK_PROCESS_CPUTIME_ID, &ts); err != nil {
grpclog.Fatal(err)
}
return ts.Nano()
} | [
"func",
"GetCPUTime",
"(",
")",
"int64",
"{",
"var",
"ts",
"unix",
".",
"Timespec",
"\n",
"if",
"err",
":=",
"unix",
".",
"ClockGettime",
"(",
"unix",
".",
"CLOCK_PROCESS_CPUTIME_ID",
",",
"&",
"ts",
")",
";",
"err",
"!=",
"nil",
"{",
"grpclog",
".",
... | // GetCPUTime returns the how much CPU time has passed since the start of this process. | [
"GetCPUTime",
"returns",
"the",
"how",
"much",
"CPU",
"time",
"has",
"passed",
"since",
"the",
"start",
"of",
"this",
"process",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/syscall/syscall_linux.go#L36-L42 |
126,968 | grpc/grpc-go | internal/syscall/syscall_linux.go | GetRusage | func GetRusage() (rusage *Rusage) {
rusage = new(Rusage)
syscall.Getrusage(syscall.RUSAGE_SELF, (*syscall.Rusage)(rusage))
return
} | go | func GetRusage() (rusage *Rusage) {
rusage = new(Rusage)
syscall.Getrusage(syscall.RUSAGE_SELF, (*syscall.Rusage)(rusage))
return
} | [
"func",
"GetRusage",
"(",
")",
"(",
"rusage",
"*",
"Rusage",
")",
"{",
"rusage",
"=",
"new",
"(",
"Rusage",
")",
"\n",
"syscall",
".",
"Getrusage",
"(",
"syscall",
".",
"RUSAGE_SELF",
",",
"(",
"*",
"syscall",
".",
"Rusage",
")",
"(",
"rusage",
")",
... | // GetRusage returns the resource usage of current process. | [
"GetRusage",
"returns",
"the",
"resource",
"usage",
"of",
"current",
"process",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/syscall/syscall_linux.go#L48-L52 |
126,969 | grpc/grpc-go | internal/syscall/syscall_linux.go | CPUTimeDiff | func CPUTimeDiff(first *Rusage, latest *Rusage) (float64, float64) {
f := (*syscall.Rusage)(first)
l := (*syscall.Rusage)(latest)
var (
utimeDiffs = l.Utime.Sec - f.Utime.Sec
utimeDiffus = l.Utime.Usec - f.Utime.Usec
stimeDiffs = l.Stime.Sec - f.Stime.Sec
stimeDiffus = l.Stime.Usec - f.Stime.Usec
)
uTim... | go | func CPUTimeDiff(first *Rusage, latest *Rusage) (float64, float64) {
f := (*syscall.Rusage)(first)
l := (*syscall.Rusage)(latest)
var (
utimeDiffs = l.Utime.Sec - f.Utime.Sec
utimeDiffus = l.Utime.Usec - f.Utime.Usec
stimeDiffs = l.Stime.Sec - f.Stime.Sec
stimeDiffus = l.Stime.Usec - f.Stime.Usec
)
uTim... | [
"func",
"CPUTimeDiff",
"(",
"first",
"*",
"Rusage",
",",
"latest",
"*",
"Rusage",
")",
"(",
"float64",
",",
"float64",
")",
"{",
"f",
":=",
"(",
"*",
"syscall",
".",
"Rusage",
")",
"(",
"first",
")",
"\n",
"l",
":=",
"(",
"*",
"syscall",
".",
"Ru... | // CPUTimeDiff returns the differences of user CPU time and system CPU time used
// between two Rusage structs. | [
"CPUTimeDiff",
"returns",
"the",
"differences",
"of",
"user",
"CPU",
"time",
"and",
"system",
"CPU",
"time",
"used",
"between",
"two",
"Rusage",
"structs",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/syscall/syscall_linux.go#L56-L70 |
126,970 | grpc/grpc-go | internal/syscall/syscall_linux.go | SetTCPUserTimeout | func SetTCPUserTimeout(conn net.Conn, timeout time.Duration) error {
tcpconn, ok := conn.(*net.TCPConn)
if !ok {
// not a TCP connection. exit early
return nil
}
rawConn, err := tcpconn.SyscallConn()
if err != nil {
return fmt.Errorf("error getting raw connection: %v", err)
}
err = rawConn.Control(func(fd ... | go | func SetTCPUserTimeout(conn net.Conn, timeout time.Duration) error {
tcpconn, ok := conn.(*net.TCPConn)
if !ok {
// not a TCP connection. exit early
return nil
}
rawConn, err := tcpconn.SyscallConn()
if err != nil {
return fmt.Errorf("error getting raw connection: %v", err)
}
err = rawConn.Control(func(fd ... | [
"func",
"SetTCPUserTimeout",
"(",
"conn",
"net",
".",
"Conn",
",",
"timeout",
"time",
".",
"Duration",
")",
"error",
"{",
"tcpconn",
",",
"ok",
":=",
"conn",
".",
"(",
"*",
"net",
".",
"TCPConn",
")",
"\n",
"if",
"!",
"ok",
"{",
"// not a TCP connectio... | // SetTCPUserTimeout sets the TCP user timeout on a connection's socket | [
"SetTCPUserTimeout",
"sets",
"the",
"TCP",
"user",
"timeout",
"on",
"a",
"connection",
"s",
"socket"
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/syscall/syscall_linux.go#L73-L91 |
126,971 | grpc/grpc-go | internal/syscall/syscall_linux.go | GetTCPUserTimeout | func GetTCPUserTimeout(conn net.Conn) (opt int, err error) {
tcpconn, ok := conn.(*net.TCPConn)
if !ok {
err = fmt.Errorf("conn is not *net.TCPConn. got %T", conn)
return
}
rawConn, err := tcpconn.SyscallConn()
if err != nil {
err = fmt.Errorf("error getting raw connection: %v", err)
return
}
err = rawCo... | go | func GetTCPUserTimeout(conn net.Conn) (opt int, err error) {
tcpconn, ok := conn.(*net.TCPConn)
if !ok {
err = fmt.Errorf("conn is not *net.TCPConn. got %T", conn)
return
}
rawConn, err := tcpconn.SyscallConn()
if err != nil {
err = fmt.Errorf("error getting raw connection: %v", err)
return
}
err = rawCo... | [
"func",
"GetTCPUserTimeout",
"(",
"conn",
"net",
".",
"Conn",
")",
"(",
"opt",
"int",
",",
"err",
"error",
")",
"{",
"tcpconn",
",",
"ok",
":=",
"conn",
".",
"(",
"*",
"net",
".",
"TCPConn",
")",
"\n",
"if",
"!",
"ok",
"{",
"err",
"=",
"fmt",
"... | // GetTCPUserTimeout gets the TCP user timeout on a connection's socket | [
"GetTCPUserTimeout",
"gets",
"the",
"TCP",
"user",
"timeout",
"on",
"a",
"connection",
"s",
"socket"
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/syscall/syscall_linux.go#L94-L114 |
126,972 | grpc/grpc-go | credentials/alts/internal/conn/aes128gcm.go | NewAES128GCM | func NewAES128GCM(side core.Side, key []byte) (ALTSRecordCrypto, error) {
c, err := aes.NewCipher(key)
if err != nil {
return nil, err
}
a, err := cipher.NewGCM(c)
if err != nil {
return nil, err
}
return &aes128gcm{
inCounter: NewInCounter(side, overflowLenAES128GCM),
outCounter: NewOutCounter(side, ov... | go | func NewAES128GCM(side core.Side, key []byte) (ALTSRecordCrypto, error) {
c, err := aes.NewCipher(key)
if err != nil {
return nil, err
}
a, err := cipher.NewGCM(c)
if err != nil {
return nil, err
}
return &aes128gcm{
inCounter: NewInCounter(side, overflowLenAES128GCM),
outCounter: NewOutCounter(side, ov... | [
"func",
"NewAES128GCM",
"(",
"side",
"core",
".",
"Side",
",",
"key",
"[",
"]",
"byte",
")",
"(",
"ALTSRecordCrypto",
",",
"error",
")",
"{",
"c",
",",
"err",
":=",
"aes",
".",
"NewCipher",
"(",
"key",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"r... | // NewAES128GCM creates an instance that uses aes128gcm for ALTS record. | [
"NewAES128GCM",
"creates",
"an",
"instance",
"that",
"uses",
"aes128gcm",
"for",
"ALTS",
"record",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/internal/conn/aes128gcm.go#L47-L61 |
126,973 | grpc/grpc-go | credentials/alts/internal/conn/aes128gcm.go | Encrypt | func (s *aes128gcm) Encrypt(dst, plaintext []byte) ([]byte, error) {
// If we need to allocate an output buffer, we want to include space for
// GCM tag to avoid forcing ALTS record to reallocate as well.
dlen := len(dst)
dst, out := SliceForAppend(dst, len(plaintext)+GcmTagSize)
seq, err := s.outCounter.Value()
... | go | func (s *aes128gcm) Encrypt(dst, plaintext []byte) ([]byte, error) {
// If we need to allocate an output buffer, we want to include space for
// GCM tag to avoid forcing ALTS record to reallocate as well.
dlen := len(dst)
dst, out := SliceForAppend(dst, len(plaintext)+GcmTagSize)
seq, err := s.outCounter.Value()
... | [
"func",
"(",
"s",
"*",
"aes128gcm",
")",
"Encrypt",
"(",
"dst",
",",
"plaintext",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// If we need to allocate an output buffer, we want to include space for",
"// GCM tag to avoid forcing ALTS record... | // Encrypt is the encryption function. dst can contain bytes at the beginning of
// the ciphertext that will not be encrypted but will be authenticated. If dst
// has enough capacity to hold these bytes, the ciphertext and the tag, no
// allocation and copy operations will be performed. dst and plaintext do not
// over... | [
"Encrypt",
"is",
"the",
"encryption",
"function",
".",
"dst",
"can",
"contain",
"bytes",
"at",
"the",
"beginning",
"of",
"the",
"ciphertext",
"that",
"will",
"not",
"be",
"encrypted",
"but",
"will",
"be",
"authenticated",
".",
"If",
"dst",
"has",
"enough",
... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/internal/conn/aes128gcm.go#L68-L87 |
126,974 | grpc/grpc-go | credentials/alts/internal/handshaker/service/service.go | Dial | func Dial(hsAddress string) (*grpc.ClientConn, error) {
mu.Lock()
defer mu.Unlock()
if hsConn == nil {
// Create a new connection to the handshaker service. Note that
// this connection stays open until the application is closed.
var err error
hsConn, err = hsDialer(hsAddress, grpc.WithInsecure())
if err ... | go | func Dial(hsAddress string) (*grpc.ClientConn, error) {
mu.Lock()
defer mu.Unlock()
if hsConn == nil {
// Create a new connection to the handshaker service. Note that
// this connection stays open until the application is closed.
var err error
hsConn, err = hsDialer(hsAddress, grpc.WithInsecure())
if err ... | [
"func",
"Dial",
"(",
"hsAddress",
"string",
")",
"(",
"*",
"grpc",
".",
"ClientConn",
",",
"error",
")",
"{",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"hsConn",
"==",
"nil",
"{",
"// Create a new connec... | // Dial dials the handshake service in the hypervisor. If a connection has
// already been established, this function returns it. Otherwise, a new
// connection is created. | [
"Dial",
"dials",
"the",
"handshake",
"service",
"in",
"the",
"hypervisor",
".",
"If",
"a",
"connection",
"has",
"already",
"been",
"established",
"this",
"function",
"returns",
"it",
".",
"Otherwise",
"a",
"new",
"connection",
"is",
"created",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/internal/handshaker/service/service.go#L40-L54 |
126,975 | grpc/grpc-go | internal/syscall/syscall_nonlinux.go | SetTCPUserTimeout | func SetTCPUserTimeout(conn net.Conn, timeout time.Duration) error {
log()
return nil
} | go | func SetTCPUserTimeout(conn net.Conn, timeout time.Duration) error {
log()
return nil
} | [
"func",
"SetTCPUserTimeout",
"(",
"conn",
"net",
".",
"Conn",
",",
"timeout",
"time",
".",
"Duration",
")",
"error",
"{",
"log",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // SetTCPUserTimeout is a no-op function under non-linux or appengine environments | [
"SetTCPUserTimeout",
"is",
"a",
"no",
"-",
"op",
"function",
"under",
"non",
"-",
"linux",
"or",
"appengine",
"environments"
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/syscall/syscall_nonlinux.go#L63-L66 |
126,976 | grpc/grpc-go | credentials/tls13.go | init | func init() {
cipherSuiteLookup[tls.TLS_AES_128_GCM_SHA256] = "TLS_AES_128_GCM_SHA256"
cipherSuiteLookup[tls.TLS_AES_256_GCM_SHA384] = "TLS_AES_256_GCM_SHA384"
cipherSuiteLookup[tls.TLS_CHACHA20_POLY1305_SHA256] = "TLS_CHACHA20_POLY1305_SHA256"
} | go | func init() {
cipherSuiteLookup[tls.TLS_AES_128_GCM_SHA256] = "TLS_AES_128_GCM_SHA256"
cipherSuiteLookup[tls.TLS_AES_256_GCM_SHA384] = "TLS_AES_256_GCM_SHA384"
cipherSuiteLookup[tls.TLS_CHACHA20_POLY1305_SHA256] = "TLS_CHACHA20_POLY1305_SHA256"
} | [
"func",
"init",
"(",
")",
"{",
"cipherSuiteLookup",
"[",
"tls",
".",
"TLS_AES_128_GCM_SHA256",
"]",
"=",
"\"",
"\"",
"\n",
"cipherSuiteLookup",
"[",
"tls",
".",
"TLS_AES_256_GCM_SHA384",
"]",
"=",
"\"",
"\"",
"\n",
"cipherSuiteLookup",
"[",
"tls",
".",
"TLS_... | // This init function adds cipher suite constants only defined in Go 1.12. | [
"This",
"init",
"function",
"adds",
"cipher",
"suite",
"constants",
"only",
"defined",
"in",
"Go",
"1",
".",
"12",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/tls13.go#L26-L30 |
126,977 | grpc/grpc-go | examples/features/multiplex/client/main.go | callSayHello | func callSayHello(c hwpb.GreeterClient, name string) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
r, err := c.SayHello(ctx, &hwpb.HelloRequest{Name: name})
if err != nil {
log.Fatalf("client.SayHello(_) = _, %v", err)
}
fmt.Println("Greeting: ", r.Message)
} | go | func callSayHello(c hwpb.GreeterClient, name string) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
r, err := c.SayHello(ctx, &hwpb.HelloRequest{Name: name})
if err != nil {
log.Fatalf("client.SayHello(_) = _, %v", err)
}
fmt.Println("Greeting: ", r.Message)
} | [
"func",
"callSayHello",
"(",
"c",
"hwpb",
".",
"GreeterClient",
",",
"name",
"string",
")",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"context",
".",
"Background",
"(",
")",
",",
"time",
".",
"Second",
")",
"\n",
"defer",
"ca... | // callSayHello calls SayHello on c with the given name, and prints the
// response. | [
"callSayHello",
"calls",
"SayHello",
"on",
"c",
"with",
"the",
"given",
"name",
"and",
"prints",
"the",
"response",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/examples/features/multiplex/client/main.go#L38-L46 |
126,978 | grpc/grpc-go | balancer/xds/edsbalancer/edsbalancer.go | NewXDSBalancer | func NewXDSBalancer(cc balancer.ClientConn) *EDSBalancer {
xdsB := &EDSBalancer{
ClientConn: cc,
subBalancerBuilder: balancer.Get(roundrobin.Name),
lidToConfig: make(map[string]*localityConfig),
}
// Don't start balancer group here. Start it when handling the first EDS
// response. Otherwise the bala... | go | func NewXDSBalancer(cc balancer.ClientConn) *EDSBalancer {
xdsB := &EDSBalancer{
ClientConn: cc,
subBalancerBuilder: balancer.Get(roundrobin.Name),
lidToConfig: make(map[string]*localityConfig),
}
// Don't start balancer group here. Start it when handling the first EDS
// response. Otherwise the bala... | [
"func",
"NewXDSBalancer",
"(",
"cc",
"balancer",
".",
"ClientConn",
")",
"*",
"EDSBalancer",
"{",
"xdsB",
":=",
"&",
"EDSBalancer",
"{",
"ClientConn",
":",
"cc",
",",
"subBalancerBuilder",
":",
"balancer",
".",
"Get",
"(",
"roundrobin",
".",
"Name",
")",
"... | // NewXDSBalancer create a new EDSBalancer. | [
"NewXDSBalancer",
"create",
"a",
"new",
"EDSBalancer",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/balancer/xds/edsbalancer/edsbalancer.go#L67-L79 |
126,979 | grpc/grpc-go | balancer/xds/edsbalancer/edsbalancer.go | HandleChildPolicy | func (xdsB *EDSBalancer) HandleChildPolicy(name string, config json.RawMessage) {
// name could come from cdsResp.GetLbPolicy().String(). LbPolicy.String()
// are all UPPER_CASE with underscore.
//
// No conversion is needed here because balancer package converts all names
// into lower_case before registering/loo... | go | func (xdsB *EDSBalancer) HandleChildPolicy(name string, config json.RawMessage) {
// name could come from cdsResp.GetLbPolicy().String(). LbPolicy.String()
// are all UPPER_CASE with underscore.
//
// No conversion is needed here because balancer package converts all names
// into lower_case before registering/loo... | [
"func",
"(",
"xdsB",
"*",
"EDSBalancer",
")",
"HandleChildPolicy",
"(",
"name",
"string",
",",
"config",
"json",
".",
"RawMessage",
")",
"{",
"// name could come from cdsResp.GetLbPolicy().String(). LbPolicy.String()",
"// are all UPPER_CASE with underscore.",
"//",
"// No co... | // HandleChildPolicy updates the child balancers handling endpoints. Child
// policy is roundrobin by default. If the specified balancer is not installed,
// the old child balancer will be used.
//
// HandleChildPolicy and HandleEDSResponse must be called by the same goroutine. | [
"HandleChildPolicy",
"updates",
"the",
"child",
"balancers",
"handling",
"endpoints",
".",
"Child",
"policy",
"is",
"roundrobin",
"by",
"default",
".",
"If",
"the",
"specified",
"balancer",
"is",
"not",
"installed",
"the",
"old",
"child",
"balancer",
"will",
"be... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/balancer/xds/edsbalancer/edsbalancer.go#L86-L94 |
126,980 | grpc/grpc-go | balancer/xds/edsbalancer/edsbalancer.go | updateDrops | func (xdsB *EDSBalancer) updateDrops(dropPolicies []*edspb.ClusterLoadAssignment_Policy_DropOverload) {
var (
newDrops []*dropper
dropsChanged bool
)
for i, dropPolicy := range dropPolicies {
percentage := dropPolicy.GetDropPercentage()
var (
numerator = percentage.GetNumerator()
denominator uint... | go | func (xdsB *EDSBalancer) updateDrops(dropPolicies []*edspb.ClusterLoadAssignment_Policy_DropOverload) {
var (
newDrops []*dropper
dropsChanged bool
)
for i, dropPolicy := range dropPolicies {
percentage := dropPolicy.GetDropPercentage()
var (
numerator = percentage.GetNumerator()
denominator uint... | [
"func",
"(",
"xdsB",
"*",
"EDSBalancer",
")",
"updateDrops",
"(",
"dropPolicies",
"[",
"]",
"*",
"edspb",
".",
"ClusterLoadAssignment_Policy_DropOverload",
")",
"{",
"var",
"(",
"newDrops",
"[",
"]",
"*",
"dropper",
"\n",
"dropsChanged",
"bool",
"\n",
")",
"... | // updateDrops compares new drop policies with the old. If they are different,
// it updates the drop policies and send ClientConn an updated picker. | [
"updateDrops",
"compares",
"new",
"drop",
"policies",
"with",
"the",
"old",
".",
"If",
"they",
"are",
"different",
"it",
"updates",
"the",
"drop",
"policies",
"and",
"send",
"ClientConn",
"an",
"updated",
"picker",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/balancer/xds/edsbalancer/edsbalancer.go#L122-L165 |
126,981 | grpc/grpc-go | balancer/xds/edsbalancer/edsbalancer.go | HandleSubConnStateChange | func (xdsB *EDSBalancer) HandleSubConnStateChange(sc balancer.SubConn, s connectivity.State) {
xdsB.bg.handleSubConnStateChange(sc, s)
} | go | func (xdsB *EDSBalancer) HandleSubConnStateChange(sc balancer.SubConn, s connectivity.State) {
xdsB.bg.handleSubConnStateChange(sc, s)
} | [
"func",
"(",
"xdsB",
"*",
"EDSBalancer",
")",
"HandleSubConnStateChange",
"(",
"sc",
"balancer",
".",
"SubConn",
",",
"s",
"connectivity",
".",
"State",
")",
"{",
"xdsB",
".",
"bg",
".",
"handleSubConnStateChange",
"(",
"sc",
",",
"s",
")",
"\n",
"}"
] | // HandleSubConnStateChange handles the state change and update pickers accordingly. | [
"HandleSubConnStateChange",
"handles",
"the",
"state",
"change",
"and",
"update",
"pickers",
"accordingly",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/balancer/xds/edsbalancer/edsbalancer.go#L260-L262 |
126,982 | grpc/grpc-go | balancer/xds/edsbalancer/edsbalancer.go | UpdateBalancerState | func (xdsB *EDSBalancer) UpdateBalancerState(s connectivity.State, p balancer.Picker) {
xdsB.pickerMu.Lock()
defer xdsB.pickerMu.Unlock()
xdsB.innerPicker = p
xdsB.innerState = s
// Don't reset drops when it's a state change.
xdsB.ClientConn.UpdateBalancerState(s, newDropPicker(p, xdsB.drops))
} | go | func (xdsB *EDSBalancer) UpdateBalancerState(s connectivity.State, p balancer.Picker) {
xdsB.pickerMu.Lock()
defer xdsB.pickerMu.Unlock()
xdsB.innerPicker = p
xdsB.innerState = s
// Don't reset drops when it's a state change.
xdsB.ClientConn.UpdateBalancerState(s, newDropPicker(p, xdsB.drops))
} | [
"func",
"(",
"xdsB",
"*",
"EDSBalancer",
")",
"UpdateBalancerState",
"(",
"s",
"connectivity",
".",
"State",
",",
"p",
"balancer",
".",
"Picker",
")",
"{",
"xdsB",
".",
"pickerMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"xdsB",
".",
"pickerMu",
".",
"Un... | // UpdateBalancerState overrides balancer.ClientConn to wrap the picker in a
// dropPicker. | [
"UpdateBalancerState",
"overrides",
"balancer",
".",
"ClientConn",
"to",
"wrap",
"the",
"picker",
"in",
"a",
"dropPicker",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/balancer/xds/edsbalancer/edsbalancer.go#L266-L273 |
126,983 | grpc/grpc-go | credentials/google/google.go | NewDefaultCredentials | func NewDefaultCredentials() credentials.Bundle {
c := &creds{
newPerRPCCreds: func() credentials.PerRPCCredentials {
ctx, cancel := context.WithTimeout(context.Background(), tokenRequestTimeout)
defer cancel()
perRPCCreds, err := oauth.NewApplicationDefault(ctx)
if err != nil {
grpclog.Warningf("goo... | go | func NewDefaultCredentials() credentials.Bundle {
c := &creds{
newPerRPCCreds: func() credentials.PerRPCCredentials {
ctx, cancel := context.WithTimeout(context.Background(), tokenRequestTimeout)
defer cancel()
perRPCCreds, err := oauth.NewApplicationDefault(ctx)
if err != nil {
grpclog.Warningf("goo... | [
"func",
"NewDefaultCredentials",
"(",
")",
"credentials",
".",
"Bundle",
"{",
"c",
":=",
"&",
"creds",
"{",
"newPerRPCCreds",
":",
"func",
"(",
")",
"credentials",
".",
"PerRPCCredentials",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",... | // NewDefaultCredentials returns a credentials bundle that is configured to work
// with google services.
//
// This API is experimental. | [
"NewDefaultCredentials",
"returns",
"a",
"credentials",
"bundle",
"that",
"is",
"configured",
"to",
"work",
"with",
"google",
"services",
".",
"This",
"API",
"is",
"experimental",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/google/google.go#L40-L57 |
126,984 | grpc/grpc-go | credentials/google/google.go | NewComputeEngineCredentials | func NewComputeEngineCredentials() credentials.Bundle {
c := &creds{
newPerRPCCreds: func() credentials.PerRPCCredentials {
return oauth.NewComputeEngine()
},
}
bundle, err := c.NewWithMode(internal.CredsBundleModeFallback)
if err != nil {
grpclog.Warningf("compute engine creds: failed to create new creds:... | go | func NewComputeEngineCredentials() credentials.Bundle {
c := &creds{
newPerRPCCreds: func() credentials.PerRPCCredentials {
return oauth.NewComputeEngine()
},
}
bundle, err := c.NewWithMode(internal.CredsBundleModeFallback)
if err != nil {
grpclog.Warningf("compute engine creds: failed to create new creds:... | [
"func",
"NewComputeEngineCredentials",
"(",
")",
"credentials",
".",
"Bundle",
"{",
"c",
":=",
"&",
"creds",
"{",
"newPerRPCCreds",
":",
"func",
"(",
")",
"credentials",
".",
"PerRPCCredentials",
"{",
"return",
"oauth",
".",
"NewComputeEngine",
"(",
")",
"\n",... | // NewComputeEngineCredentials returns a credentials bundle that is configured to work
// with google services. This API must only be used when running on GCE. Authentication configured
// by this API represents the GCE VM's default service account.
//
// This API is experimental. | [
"NewComputeEngineCredentials",
"returns",
"a",
"credentials",
"bundle",
"that",
"is",
"configured",
"to",
"work",
"with",
"google",
"services",
".",
"This",
"API",
"must",
"only",
"be",
"used",
"when",
"running",
"on",
"GCE",
".",
"Authentication",
"configured",
... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/google/google.go#L64-L75 |
126,985 | grpc/grpc-go | credentials/google/google.go | NewWithMode | func (c *creds) NewWithMode(mode string) (credentials.Bundle, error) {
newCreds := &creds{
mode: mode,
newPerRPCCreds: c.newPerRPCCreds,
}
// Create transport credentials.
switch mode {
case internal.CredsBundleModeFallback:
newCreds.transportCreds = credentials.NewTLS(nil)
case internal.CredsBun... | go | func (c *creds) NewWithMode(mode string) (credentials.Bundle, error) {
newCreds := &creds{
mode: mode,
newPerRPCCreds: c.newPerRPCCreds,
}
// Create transport credentials.
switch mode {
case internal.CredsBundleModeFallback:
newCreds.transportCreds = credentials.NewTLS(nil)
case internal.CredsBun... | [
"func",
"(",
"c",
"*",
"creds",
")",
"NewWithMode",
"(",
"mode",
"string",
")",
"(",
"credentials",
".",
"Bundle",
",",
"error",
")",
"{",
"newCreds",
":=",
"&",
"creds",
"{",
"mode",
":",
"mode",
",",
"newPerRPCCreds",
":",
"c",
".",
"newPerRPCCreds",... | // NewWithMode should make a copy of Bundle, and switch mode. Modifying the
// existing Bundle may cause races. | [
"NewWithMode",
"should",
"make",
"a",
"copy",
"of",
"Bundle",
"and",
"switch",
"mode",
".",
"Modifying",
"the",
"existing",
"Bundle",
"may",
"cause",
"races",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/google/google.go#L102-L125 |
126,986 | grpc/grpc-go | examples/features/wait_for_ready/main.go | serve | func serve() {
lis, err := net.Listen("tcp", ":50053")
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
s := grpc.NewServer()
pb.RegisterEchoServer(s, &server{})
if err := s.Serve(lis); err != nil {
log.Fatalf("failed to serve: %v", err)
}
} | go | func serve() {
lis, err := net.Listen("tcp", ":50053")
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
s := grpc.NewServer()
pb.RegisterEchoServer(s, &server{})
if err := s.Serve(lis); err != nil {
log.Fatalf("failed to serve: %v", err)
}
} | [
"func",
"serve",
"(",
")",
"{",
"lis",
",",
"err",
":=",
"net",
".",
"Listen",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"s",
":=",
... | // serve starts listening with a 2 seconds delay. | [
"serve",
"starts",
"listening",
"with",
"a",
"2",
"seconds",
"delay",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/examples/features/wait_for_ready/main.go#L56-L67 |
126,987 | grpc/grpc-go | balancer/roundrobin/roundrobin.go | newBuilder | func newBuilder() balancer.Builder {
return base.NewBalancerBuilderWithConfig(Name, &rrPickerBuilder{}, base.Config{HealthCheck: true})
} | go | func newBuilder() balancer.Builder {
return base.NewBalancerBuilderWithConfig(Name, &rrPickerBuilder{}, base.Config{HealthCheck: true})
} | [
"func",
"newBuilder",
"(",
")",
"balancer",
".",
"Builder",
"{",
"return",
"base",
".",
"NewBalancerBuilderWithConfig",
"(",
"Name",
",",
"&",
"rrPickerBuilder",
"{",
"}",
",",
"base",
".",
"Config",
"{",
"HealthCheck",
":",
"true",
"}",
")",
"\n",
"}"
] | // newBuilder creates a new roundrobin balancer builder. | [
"newBuilder",
"creates",
"a",
"new",
"roundrobin",
"balancer",
"builder",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/balancer/roundrobin/roundrobin.go#L39-L41 |
126,988 | grpc/grpc-go | credentials/alts/internal/conn/counter.go | Value | func (c *Counter) Value() ([]byte, error) {
if c.invalid {
return nil, errInvalidCounter
}
return c.value[:], nil
} | go | func (c *Counter) Value() ([]byte, error) {
if c.invalid {
return nil, errInvalidCounter
}
return c.value[:], nil
} | [
"func",
"(",
"c",
"*",
"Counter",
")",
"Value",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"c",
".",
"invalid",
"{",
"return",
"nil",
",",
"errInvalidCounter",
"\n",
"}",
"\n",
"return",
"c",
".",
"value",
"[",
":",
"]",
","... | // Value returns the current value of the counter as a byte slice. | [
"Value",
"returns",
"the",
"current",
"value",
"of",
"the",
"counter",
"as",
"a",
"byte",
"slice",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/internal/conn/counter.go#L39-L44 |
126,989 | grpc/grpc-go | credentials/alts/internal/conn/counter.go | Inc | func (c *Counter) Inc() {
// If the counter is already invalid, there is no need to increase it.
if c.invalid {
return
}
i := 0
for ; i < c.overflowLen; i++ {
c.value[i]++
if c.value[i] != 0 {
break
}
}
if i == c.overflowLen {
c.invalid = true
}
} | go | func (c *Counter) Inc() {
// If the counter is already invalid, there is no need to increase it.
if c.invalid {
return
}
i := 0
for ; i < c.overflowLen; i++ {
c.value[i]++
if c.value[i] != 0 {
break
}
}
if i == c.overflowLen {
c.invalid = true
}
} | [
"func",
"(",
"c",
"*",
"Counter",
")",
"Inc",
"(",
")",
"{",
"// If the counter is already invalid, there is no need to increase it.",
"if",
"c",
".",
"invalid",
"{",
"return",
"\n",
"}",
"\n",
"i",
":=",
"0",
"\n",
"for",
";",
"i",
"<",
"c",
".",
"overflo... | // Inc increments the counter and checks for overflow. | [
"Inc",
"increments",
"the",
"counter",
"and",
"checks",
"for",
"overflow",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/internal/conn/counter.go#L47-L62 |
126,990 | grpc/grpc-go | balancer/grpclb/grpclb_util.go | ResolveNow | func (r *lbManualResolver) ResolveNow(o resolver.ResolveNowOption) {
r.ccb.ResolveNow(o)
} | go | func (r *lbManualResolver) ResolveNow(o resolver.ResolveNowOption) {
r.ccb.ResolveNow(o)
} | [
"func",
"(",
"r",
"*",
"lbManualResolver",
")",
"ResolveNow",
"(",
"o",
"resolver",
".",
"ResolveNowOption",
")",
"{",
"r",
".",
"ccb",
".",
"ResolveNow",
"(",
"o",
")",
"\n",
"}"
] | // ResolveNow calls resolveNow on the parent ClientConn. | [
"ResolveNow",
"calls",
"resolveNow",
"on",
"the",
"parent",
"ClientConn",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/balancer/grpclb/grpclb_util.go#L80-L82 |
126,991 | grpc/grpc-go | rpc_util.go | encode | func encode(c baseCodec, msg interface{}) ([]byte, error) {
if msg == nil { // NOTE: typed nils will not be caught by this check
return nil, nil
}
b, err := c.Marshal(msg)
if err != nil {
return nil, status.Errorf(codes.Internal, "grpc: error while marshaling: %v", err.Error())
}
if uint(len(b)) > math.MaxUin... | go | func encode(c baseCodec, msg interface{}) ([]byte, error) {
if msg == nil { // NOTE: typed nils will not be caught by this check
return nil, nil
}
b, err := c.Marshal(msg)
if err != nil {
return nil, status.Errorf(codes.Internal, "grpc: error while marshaling: %v", err.Error())
}
if uint(len(b)) > math.MaxUin... | [
"func",
"encode",
"(",
"c",
"baseCodec",
",",
"msg",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"msg",
"==",
"nil",
"{",
"// NOTE: typed nils will not be caught by this check",
"return",
"nil",
",",
"nil",
"\n",
"}",
... | // encode serializes msg and returns a buffer containing the message, or an
// error if it is too large to be transmitted by grpc. If msg is nil, it
// generates an empty message. | [
"encode",
"serializes",
"msg",
"and",
"returns",
"a",
"buffer",
"containing",
"the",
"message",
"or",
"an",
"error",
"if",
"it",
"is",
"too",
"large",
"to",
"be",
"transmitted",
"by",
"grpc",
".",
"If",
"msg",
"is",
"nil",
"it",
"generates",
"an",
"empty... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/rpc_util.go#L539-L551 |
126,992 | grpc/grpc-go | rpc_util.go | msgHeader | func msgHeader(data, compData []byte) (hdr []byte, payload []byte) {
hdr = make([]byte, headerLen)
if compData != nil {
hdr[0] = byte(compressionMade)
data = compData
} else {
hdr[0] = byte(compressionNone)
}
// Write length of payload into buf
binary.BigEndian.PutUint32(hdr[payloadLen:], uint32(len(data))... | go | func msgHeader(data, compData []byte) (hdr []byte, payload []byte) {
hdr = make([]byte, headerLen)
if compData != nil {
hdr[0] = byte(compressionMade)
data = compData
} else {
hdr[0] = byte(compressionNone)
}
// Write length of payload into buf
binary.BigEndian.PutUint32(hdr[payloadLen:], uint32(len(data))... | [
"func",
"msgHeader",
"(",
"data",
",",
"compData",
"[",
"]",
"byte",
")",
"(",
"hdr",
"[",
"]",
"byte",
",",
"payload",
"[",
"]",
"byte",
")",
"{",
"hdr",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"headerLen",
")",
"\n",
"if",
"compData",
"!=",
... | // msgHeader returns a 5-byte header for the message being transmitted and the
// payload, which is compData if non-nil or data otherwise. | [
"msgHeader",
"returns",
"a",
"5",
"-",
"byte",
"header",
"for",
"the",
"message",
"being",
"transmitted",
"and",
"the",
"payload",
"which",
"is",
"compData",
"if",
"non",
"-",
"nil",
"or",
"data",
"otherwise",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/rpc_util.go#L592-L604 |
126,993 | grpc/grpc-go | rpc_util.go | toRPCErr | func toRPCErr(err error) error {
if err == nil || err == io.EOF {
return err
}
if err == io.ErrUnexpectedEOF {
return status.Error(codes.Internal, err.Error())
}
if _, ok := status.FromError(err); ok {
return err
}
switch e := err.(type) {
case transport.ConnectionError:
return status.Error(codes.Unavai... | go | func toRPCErr(err error) error {
if err == nil || err == io.EOF {
return err
}
if err == io.ErrUnexpectedEOF {
return status.Error(codes.Internal, err.Error())
}
if _, ok := status.FromError(err); ok {
return err
}
switch e := err.(type) {
case transport.ConnectionError:
return status.Error(codes.Unavai... | [
"func",
"toRPCErr",
"(",
"err",
"error",
")",
"error",
"{",
"if",
"err",
"==",
"nil",
"||",
"err",
"==",
"io",
".",
"EOF",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"err",
"==",
"io",
".",
"ErrUnexpectedEOF",
"{",
"return",
"status",
".",
"Error... | // toRPCErr converts an error into an error from the status package. | [
"toRPCErr",
"converts",
"an",
"error",
"into",
"an",
"error",
"from",
"the",
"status",
"package",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/rpc_util.go#L757-L779 |
126,994 | grpc/grpc-go | rpc_util.go | setCallInfoCodec | func setCallInfoCodec(c *callInfo) error {
if c.codec != nil {
// codec was already set by a CallOption; use it.
return nil
}
if c.contentSubtype == "" {
// No codec specified in CallOptions; use proto by default.
c.codec = encoding.GetCodec(proto.Name)
return nil
}
// c.contentSubtype is already lower... | go | func setCallInfoCodec(c *callInfo) error {
if c.codec != nil {
// codec was already set by a CallOption; use it.
return nil
}
if c.contentSubtype == "" {
// No codec specified in CallOptions; use proto by default.
c.codec = encoding.GetCodec(proto.Name)
return nil
}
// c.contentSubtype is already lower... | [
"func",
"setCallInfoCodec",
"(",
"c",
"*",
"callInfo",
")",
"error",
"{",
"if",
"c",
".",
"codec",
"!=",
"nil",
"{",
"// codec was already set by a CallOption; use it.",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"c",
".",
"contentSubtype",
"==",
"\"",
"\"",
... | // setCallInfoCodec should only be called after CallOptions have been applied. | [
"setCallInfoCodec",
"should",
"only",
"be",
"called",
"after",
"CallOptions",
"have",
"been",
"applied",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/rpc_util.go#L782-L800 |
126,995 | grpc/grpc-go | rpc_util.go | parseDialTarget | func parseDialTarget(target string) (net string, addr string) {
net = "tcp"
m1 := strings.Index(target, ":")
m2 := strings.Index(target, ":/")
// handle unix:addr which will fail with url.Parse
if m1 >= 0 && m2 < 0 {
if n := target[0:m1]; n == "unix" {
net = n
addr = target[m1+1:]
return net, addr
}... | go | func parseDialTarget(target string) (net string, addr string) {
net = "tcp"
m1 := strings.Index(target, ":")
m2 := strings.Index(target, ":/")
// handle unix:addr which will fail with url.Parse
if m1 >= 0 && m2 < 0 {
if n := target[0:m1]; n == "unix" {
net = n
addr = target[m1+1:]
return net, addr
}... | [
"func",
"parseDialTarget",
"(",
"target",
"string",
")",
"(",
"net",
"string",
",",
"addr",
"string",
")",
"{",
"net",
"=",
"\"",
"\"",
"\n\n",
"m1",
":=",
"strings",
".",
"Index",
"(",
"target",
",",
"\"",
"\"",
")",
"\n",
"m2",
":=",
"strings",
"... | // parseDialTarget returns the network and address to pass to dialer | [
"parseDialTarget",
"returns",
"the",
"network",
"and",
"address",
"to",
"pass",
"to",
"dialer"
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/rpc_util.go#L803-L834 |
126,996 | grpc/grpc-go | balancer/xds/xds.go | run | func (x *xdsBalancer) run() {
for {
select {
case update := <-x.grpcUpdate:
x.handleGRPCUpdate(update)
case update := <-x.xdsClientUpdate:
x.handleXDSClientUpdate(update)
case <-x.timer.C: // x.timer.C will block if we are not in fallback monitoring stage.
x.switchFallback()
case <-x.noSubConnAlert:... | go | func (x *xdsBalancer) run() {
for {
select {
case update := <-x.grpcUpdate:
x.handleGRPCUpdate(update)
case update := <-x.xdsClientUpdate:
x.handleXDSClientUpdate(update)
case <-x.timer.C: // x.timer.C will block if we are not in fallback monitoring stage.
x.switchFallback()
case <-x.noSubConnAlert:... | [
"func",
"(",
"x",
"*",
"xdsBalancer",
")",
"run",
"(",
")",
"{",
"for",
"{",
"select",
"{",
"case",
"update",
":=",
"<-",
"x",
".",
"grpcUpdate",
":",
"x",
".",
"handleGRPCUpdate",
"(",
"update",
")",
"\n",
"case",
"update",
":=",
"<-",
"x",
".",
... | // run gets executed in a goroutine once xdsBalancer is created. It monitors updates from grpc,
// xdsClient and load balancer. It synchronizes the operations that happen inside xdsBalancer. It
// exits when xdsBalancer is closed. | [
"run",
"gets",
"executed",
"in",
"a",
"goroutine",
"once",
"xdsBalancer",
"is",
"created",
".",
"It",
"monitors",
"updates",
"from",
"grpc",
"xdsClient",
"and",
"load",
"balancer",
".",
"It",
"synchronizes",
"the",
"operations",
"that",
"happen",
"inside",
"xd... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/balancer/xds/xds.go#L194-L218 |
126,997 | grpc/grpc-go | server.go | ReadBufferSize | func ReadBufferSize(s int) ServerOption {
return newFuncServerOption(func(o *serverOptions) {
o.readBufferSize = s
})
} | go | func ReadBufferSize(s int) ServerOption {
return newFuncServerOption(func(o *serverOptions) {
o.readBufferSize = s
})
} | [
"func",
"ReadBufferSize",
"(",
"s",
"int",
")",
"ServerOption",
"{",
"return",
"newFuncServerOption",
"(",
"func",
"(",
"o",
"*",
"serverOptions",
")",
"{",
"o",
".",
"readBufferSize",
"=",
"s",
"\n",
"}",
")",
"\n",
"}"
] | // ReadBufferSize lets you set the size of read buffer, this determines how much data can be read at most
// for one read syscall.
// The default value for this buffer is 32KB.
// Zero will disable read buffer for a connection so data framer can access the underlying
// conn directly. | [
"ReadBufferSize",
"lets",
"you",
"set",
"the",
"size",
"of",
"read",
"buffer",
"this",
"determines",
"how",
"much",
"data",
"can",
"be",
"read",
"at",
"most",
"for",
"one",
"read",
"syscall",
".",
"The",
"default",
"value",
"for",
"this",
"buffer",
"is",
... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/server.go#L187-L191 |
126,998 | grpc/grpc-go | server.go | InitialWindowSize | func InitialWindowSize(s int32) ServerOption {
return newFuncServerOption(func(o *serverOptions) {
o.initialWindowSize = s
})
} | go | func InitialWindowSize(s int32) ServerOption {
return newFuncServerOption(func(o *serverOptions) {
o.initialWindowSize = s
})
} | [
"func",
"InitialWindowSize",
"(",
"s",
"int32",
")",
"ServerOption",
"{",
"return",
"newFuncServerOption",
"(",
"func",
"(",
"o",
"*",
"serverOptions",
")",
"{",
"o",
".",
"initialWindowSize",
"=",
"s",
"\n",
"}",
")",
"\n",
"}"
] | // InitialWindowSize returns a ServerOption that sets window size for stream.
// The lower bound for window size is 64K and any value smaller than that will be ignored. | [
"InitialWindowSize",
"returns",
"a",
"ServerOption",
"that",
"sets",
"window",
"size",
"for",
"stream",
".",
"The",
"lower",
"bound",
"for",
"window",
"size",
"is",
"64K",
"and",
"any",
"value",
"smaller",
"than",
"that",
"will",
"be",
"ignored",
"."
] | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/server.go#L195-L199 |
126,999 | grpc/grpc-go | server.go | InitialConnWindowSize | func InitialConnWindowSize(s int32) ServerOption {
return newFuncServerOption(func(o *serverOptions) {
o.initialConnWindowSize = s
})
} | go | func InitialConnWindowSize(s int32) ServerOption {
return newFuncServerOption(func(o *serverOptions) {
o.initialConnWindowSize = s
})
} | [
"func",
"InitialConnWindowSize",
"(",
"s",
"int32",
")",
"ServerOption",
"{",
"return",
"newFuncServerOption",
"(",
"func",
"(",
"o",
"*",
"serverOptions",
")",
"{",
"o",
".",
"initialConnWindowSize",
"=",
"s",
"\n",
"}",
")",
"\n",
"}"
] | // InitialConnWindowSize returns a ServerOption that sets window size for a connection.
// The lower bound for window size is 64K and any value smaller than that will be ignored. | [
"InitialConnWindowSize",
"returns",
"a",
"ServerOption",
"that",
"sets",
"window",
"size",
"for",
"a",
"connection",
".",
"The",
"lower",
"bound",
"for",
"window",
"size",
"is",
"64K",
"and",
"any",
"value",
"smaller",
"than",
"that",
"will",
"be",
"ignored",
... | 028242f87445bf2cc2807399d403cbbada8c0e85 | https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/server.go#L203-L207 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.