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 listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
10,600 | yarpc/yarpc-go | serialize/internal/types.go | GetRoutingDelegate | func (v *RPC) GetRoutingDelegate() (o string) {
if v != nil && v.RoutingDelegate != nil {
return *v.RoutingDelegate
}
return
} | go | func (v *RPC) GetRoutingDelegate() (o string) {
if v != nil && v.RoutingDelegate != nil {
return *v.RoutingDelegate
}
return
} | [
"func",
"(",
"v",
"*",
"RPC",
")",
"GetRoutingDelegate",
"(",
")",
"(",
"o",
"string",
")",
"{",
"if",
"v",
"!=",
"nil",
"&&",
"v",
".",
"RoutingDelegate",
"!=",
"nil",
"{",
"return",
"*",
"v",
".",
"RoutingDelegate",
"\n",
"}",
"\n\n",
"return",
"... | // GetRoutingDelegate returns the value of RoutingDelegate if it is set or its
// zero value if it is unset. | [
"GetRoutingDelegate",
"returns",
"the",
"value",
"of",
"RoutingDelegate",
"if",
"it",
"is",
"set",
"or",
"its",
"zero",
"value",
"if",
"it",
"is",
"unset",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/serialize/internal/types.go#L608-L614 |
10,601 | yarpc/yarpc-go | serialize/internal/types.go | GetBody | func (v *RPC) GetBody() (o []byte) {
if v != nil && v.Body != nil {
return v.Body
}
return
} | go | func (v *RPC) GetBody() (o []byte) {
if v != nil && v.Body != nil {
return v.Body
}
return
} | [
"func",
"(",
"v",
"*",
"RPC",
")",
"GetBody",
"(",
")",
"(",
"o",
"[",
"]",
"byte",
")",
"{",
"if",
"v",
"!=",
"nil",
"&&",
"v",
".",
"Body",
"!=",
"nil",
"{",
"return",
"v",
".",
"Body",
"\n",
"}",
"\n\n",
"return",
"\n",
"}"
] | // GetBody returns the value of Body if it is set or its
// zero value if it is unset. | [
"GetBody",
"returns",
"the",
"value",
"of",
"Body",
"if",
"it",
"is",
"set",
"or",
"its",
"zero",
"value",
"if",
"it",
"is",
"unset",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/serialize/internal/types.go#L623-L629 |
10,602 | yarpc/yarpc-go | peer/roundrobin/list.go | New | func New(transport peer.Transport, opts ...ListOption) *List {
cfg := defaultListConfig
for _, o := range opts {
o(&cfg)
}
plOpts := []peerlist.ListOption{
peerlist.Capacity(cfg.capacity),
peerlist.Seed(cfg.seed),
}
if !cfg.shuffle {
plOpts = append(plOpts, peerlist.NoShuffle())
}
return &List{
List: peerlist.New(
"roundrobin",
transport,
newPeerRing(),
plOpts...,
),
}
} | go | func New(transport peer.Transport, opts ...ListOption) *List {
cfg := defaultListConfig
for _, o := range opts {
o(&cfg)
}
plOpts := []peerlist.ListOption{
peerlist.Capacity(cfg.capacity),
peerlist.Seed(cfg.seed),
}
if !cfg.shuffle {
plOpts = append(plOpts, peerlist.NoShuffle())
}
return &List{
List: peerlist.New(
"roundrobin",
transport,
newPeerRing(),
plOpts...,
),
}
} | [
"func",
"New",
"(",
"transport",
"peer",
".",
"Transport",
",",
"opts",
"...",
"ListOption",
")",
"*",
"List",
"{",
"cfg",
":=",
"defaultListConfig",
"\n",
"for",
"_",
",",
"o",
":=",
"range",
"opts",
"{",
"o",
"(",
"&",
"cfg",
")",
"\n",
"}",
"\n\... | // New creates a new round robin peer list. | [
"New",
"creates",
"a",
"new",
"round",
"robin",
"peer",
"list",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/peer/roundrobin/list.go#L56-L78 |
10,603 | yarpc/yarpc-go | encoding/thrift/inbound.go | decodeRequest | func decodeRequest(
// call is an inboundCall populated from the transport request and context.
call *encodingapi.InboundCall,
// buf is a byte buffer from the buffer pool, that will be released back to
// the buffer pool by the caller after it is finished with the decoded
// request payload. Thrift requests read sets, maps, and lists lazilly.
buf *bufferpool.Buffer,
treq *transport.Request,
// reqEnvelopeType indicates the expected envelope type, if an envelope is
// present.
reqEnvelopeType wire.EnvelopeType,
// proto is the encoding protocol (e.g., Binary) or an
// EnvelopeAgnosticProtocol (e.g., EnvelopeAgnosticBinary)
proto protocol.Protocol,
// enveloping indicates that requests must be enveloped, used only if the
// protocol is not envelope agnostic.
enveloping bool,
) (
// the wire representation of the decoded request.
// decodeRequest does not surface the envelope.
wire.Value,
// how to encode the response, with the enveloping
// strategy corresponding to the request. It is not used for oneway handlers.
protocol.Responder,
error,
) {
if err := errors.ExpectEncodings(treq, Encoding); err != nil {
return wire.Value{}, nil, err
}
if err := call.ReadFromRequest(treq); err != nil {
// not reachable
return wire.Value{}, nil, err
}
if _, err := buf.ReadFrom(treq.Body); err != nil {
return wire.Value{}, nil, err
}
reader := bytes.NewReader(buf.Bytes())
// Discover or choose the appropriate envelope
if agnosticProto, ok := proto.(protocol.EnvelopeAgnosticProtocol); ok {
return agnosticProto.DecodeRequest(reqEnvelopeType, reader)
}
if enveloping {
return decodeEnvelopedRequest(treq, reqEnvelopeType, proto, reader)
}
return decodeUnenvelopedRequest(proto, reader)
} | go | func decodeRequest(
// call is an inboundCall populated from the transport request and context.
call *encodingapi.InboundCall,
// buf is a byte buffer from the buffer pool, that will be released back to
// the buffer pool by the caller after it is finished with the decoded
// request payload. Thrift requests read sets, maps, and lists lazilly.
buf *bufferpool.Buffer,
treq *transport.Request,
// reqEnvelopeType indicates the expected envelope type, if an envelope is
// present.
reqEnvelopeType wire.EnvelopeType,
// proto is the encoding protocol (e.g., Binary) or an
// EnvelopeAgnosticProtocol (e.g., EnvelopeAgnosticBinary)
proto protocol.Protocol,
// enveloping indicates that requests must be enveloped, used only if the
// protocol is not envelope agnostic.
enveloping bool,
) (
// the wire representation of the decoded request.
// decodeRequest does not surface the envelope.
wire.Value,
// how to encode the response, with the enveloping
// strategy corresponding to the request. It is not used for oneway handlers.
protocol.Responder,
error,
) {
if err := errors.ExpectEncodings(treq, Encoding); err != nil {
return wire.Value{}, nil, err
}
if err := call.ReadFromRequest(treq); err != nil {
// not reachable
return wire.Value{}, nil, err
}
if _, err := buf.ReadFrom(treq.Body); err != nil {
return wire.Value{}, nil, err
}
reader := bytes.NewReader(buf.Bytes())
// Discover or choose the appropriate envelope
if agnosticProto, ok := proto.(protocol.EnvelopeAgnosticProtocol); ok {
return agnosticProto.DecodeRequest(reqEnvelopeType, reader)
}
if enveloping {
return decodeEnvelopedRequest(treq, reqEnvelopeType, proto, reader)
}
return decodeUnenvelopedRequest(proto, reader)
} | [
"func",
"decodeRequest",
"(",
"// call is an inboundCall populated from the transport request and context.",
"call",
"*",
"encodingapi",
".",
"InboundCall",
",",
"// buf is a byte buffer from the buffer pool, that will be released back to",
"// the buffer pool by the caller after it is finishe... | // decodeRequest is a utility shared by Unary and Oneway handlers, to decode
// the request, regardless of enveloping. | [
"decodeRequest",
"is",
"a",
"utility",
"shared",
"by",
"Unary",
"and",
"Oneway",
"handlers",
"to",
"decode",
"the",
"request",
"regardless",
"of",
"enveloping",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/encoding/thrift/inbound.go#L107-L156 |
10,604 | yarpc/yarpc-go | encoding/json/register.go | wrapUnaryHandler | func wrapUnaryHandler(name string, handler interface{}) transport.UnaryHandler {
reqBodyType := verifyUnarySignature(name, reflect.TypeOf(handler))
return newJSONHandler(reqBodyType, handler)
} | go | func wrapUnaryHandler(name string, handler interface{}) transport.UnaryHandler {
reqBodyType := verifyUnarySignature(name, reflect.TypeOf(handler))
return newJSONHandler(reqBodyType, handler)
} | [
"func",
"wrapUnaryHandler",
"(",
"name",
"string",
",",
"handler",
"interface",
"{",
"}",
")",
"transport",
".",
"UnaryHandler",
"{",
"reqBodyType",
":=",
"verifyUnarySignature",
"(",
"name",
",",
"reflect",
".",
"TypeOf",
"(",
"handler",
")",
")",
"\n",
"re... | // wrapUnaryHandler takes a valid JSON handler function and converts it into a
// transport.UnaryHandler. | [
"wrapUnaryHandler",
"takes",
"a",
"valid",
"JSON",
"handler",
"function",
"and",
"converts",
"it",
"into",
"a",
"transport",
".",
"UnaryHandler",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/encoding/json/register.go#L85-L88 |
10,605 | yarpc/yarpc-go | encoding/json/register.go | wrapOnewayHandler | func wrapOnewayHandler(name string, handler interface{}) transport.OnewayHandler {
reqBodyType := verifyOnewaySignature(name, reflect.TypeOf(handler))
return newJSONHandler(reqBodyType, handler)
} | go | func wrapOnewayHandler(name string, handler interface{}) transport.OnewayHandler {
reqBodyType := verifyOnewaySignature(name, reflect.TypeOf(handler))
return newJSONHandler(reqBodyType, handler)
} | [
"func",
"wrapOnewayHandler",
"(",
"name",
"string",
",",
"handler",
"interface",
"{",
"}",
")",
"transport",
".",
"OnewayHandler",
"{",
"reqBodyType",
":=",
"verifyOnewaySignature",
"(",
"name",
",",
"reflect",
".",
"TypeOf",
"(",
"handler",
")",
")",
"\n",
... | // wrapOnewayHandler takes a valid JSON handler function and converts it into a
// transport.OnewayHandler. | [
"wrapOnewayHandler",
"takes",
"a",
"valid",
"JSON",
"handler",
"function",
"and",
"converts",
"it",
"into",
"a",
"transport",
".",
"OnewayHandler",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/encoding/json/register.go#L92-L95 |
10,606 | yarpc/yarpc-go | encoding/json/register.go | verifyUnarySignature | func verifyUnarySignature(n string, t reflect.Type) reflect.Type {
reqBodyType := verifyInputSignature(n, t)
if t.NumOut() != 2 {
panic(fmt.Sprintf(
"expected handler for %q to have 2 results but it had %v",
n, t.NumOut(),
))
}
if t.Out(1) != _errorType {
panic(fmt.Sprintf(
"handler for %q must return error as its second reuslt, not %v",
n, t.Out(1),
))
}
resBodyType := t.Out(0)
if !isValidReqResType(resBodyType) {
panic(fmt.Sprintf(
"the first result of the handler for %q must be "+
"a struct pointer, a map[string]interface{}, or interface{], and not: %v",
n, resBodyType,
))
}
return reqBodyType
} | go | func verifyUnarySignature(n string, t reflect.Type) reflect.Type {
reqBodyType := verifyInputSignature(n, t)
if t.NumOut() != 2 {
panic(fmt.Sprintf(
"expected handler for %q to have 2 results but it had %v",
n, t.NumOut(),
))
}
if t.Out(1) != _errorType {
panic(fmt.Sprintf(
"handler for %q must return error as its second reuslt, not %v",
n, t.Out(1),
))
}
resBodyType := t.Out(0)
if !isValidReqResType(resBodyType) {
panic(fmt.Sprintf(
"the first result of the handler for %q must be "+
"a struct pointer, a map[string]interface{}, or interface{], and not: %v",
n, resBodyType,
))
}
return reqBodyType
} | [
"func",
"verifyUnarySignature",
"(",
"n",
"string",
",",
"t",
"reflect",
".",
"Type",
")",
"reflect",
".",
"Type",
"{",
"reqBodyType",
":=",
"verifyInputSignature",
"(",
"n",
",",
"t",
")",
"\n\n",
"if",
"t",
".",
"NumOut",
"(",
")",
"!=",
"2",
"{",
... | // verifyUnarySignature verifies that the given type matches what we expect from
// JSON unary handlers and returns the request type. | [
"verifyUnarySignature",
"verifies",
"that",
"the",
"given",
"type",
"matches",
"what",
"we",
"expect",
"from",
"JSON",
"unary",
"handlers",
"and",
"returns",
"the",
"request",
"type",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/encoding/json/register.go#L116-L144 |
10,607 | yarpc/yarpc-go | encoding/json/register.go | verifyOnewaySignature | func verifyOnewaySignature(n string, t reflect.Type) reflect.Type {
reqBodyType := verifyInputSignature(n, t)
if t.NumOut() != 1 {
panic(fmt.Sprintf(
"expected handler for %q to have 1 result but it had %v",
n, t.NumOut(),
))
}
if t.Out(0) != _errorType {
panic(fmt.Sprintf(
"the result of the handler for %q must be of type error, and not: %v",
n, t.Out(0),
))
}
return reqBodyType
} | go | func verifyOnewaySignature(n string, t reflect.Type) reflect.Type {
reqBodyType := verifyInputSignature(n, t)
if t.NumOut() != 1 {
panic(fmt.Sprintf(
"expected handler for %q to have 1 result but it had %v",
n, t.NumOut(),
))
}
if t.Out(0) != _errorType {
panic(fmt.Sprintf(
"the result of the handler for %q must be of type error, and not: %v",
n, t.Out(0),
))
}
return reqBodyType
} | [
"func",
"verifyOnewaySignature",
"(",
"n",
"string",
",",
"t",
"reflect",
".",
"Type",
")",
"reflect",
".",
"Type",
"{",
"reqBodyType",
":=",
"verifyInputSignature",
"(",
"n",
",",
"t",
")",
"\n\n",
"if",
"t",
".",
"NumOut",
"(",
")",
"!=",
"1",
"{",
... | // verifyOnewaySignature verifies that the given type matches what we expect
// from oneway JSON handlers.
//
// Returns the request type. | [
"verifyOnewaySignature",
"verifies",
"that",
"the",
"given",
"type",
"matches",
"what",
"we",
"expect",
"from",
"oneway",
"JSON",
"handlers",
".",
"Returns",
"the",
"request",
"type",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/encoding/json/register.go#L150-L168 |
10,608 | yarpc/yarpc-go | encoding/json/register.go | verifyInputSignature | func verifyInputSignature(n string, t reflect.Type) reflect.Type {
if t.Kind() != reflect.Func {
panic(fmt.Sprintf(
"handler for %q is not a function but a %v", n, t.Kind(),
))
}
if t.NumIn() != 2 {
panic(fmt.Sprintf(
"expected handler for %q to have 2 arguments but it had %v",
n, t.NumIn(),
))
}
if t.In(0) != _ctxType {
panic(fmt.Sprintf(
"the first argument of the handler for %q must be of type "+
"context.Context, and not: %v", n, t.In(0),
))
}
reqBodyType := t.In(1)
if !isValidReqResType(reqBodyType) {
panic(fmt.Sprintf(
"the second argument of the handler for %q must be "+
"a struct pointer, a map[string]interface{}, or interface{}, and not: %v",
n, reqBodyType,
))
}
return reqBodyType
} | go | func verifyInputSignature(n string, t reflect.Type) reflect.Type {
if t.Kind() != reflect.Func {
panic(fmt.Sprintf(
"handler for %q is not a function but a %v", n, t.Kind(),
))
}
if t.NumIn() != 2 {
panic(fmt.Sprintf(
"expected handler for %q to have 2 arguments but it had %v",
n, t.NumIn(),
))
}
if t.In(0) != _ctxType {
panic(fmt.Sprintf(
"the first argument of the handler for %q must be of type "+
"context.Context, and not: %v", n, t.In(0),
))
}
reqBodyType := t.In(1)
if !isValidReqResType(reqBodyType) {
panic(fmt.Sprintf(
"the second argument of the handler for %q must be "+
"a struct pointer, a map[string]interface{}, or interface{}, and not: %v",
n, reqBodyType,
))
}
return reqBodyType
} | [
"func",
"verifyInputSignature",
"(",
"n",
"string",
",",
"t",
"reflect",
".",
"Type",
")",
"reflect",
".",
"Type",
"{",
"if",
"t",
".",
"Kind",
"(",
")",
"!=",
"reflect",
".",
"Func",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
... | // verifyInputSignature verifies that the given input argument types match
// what we expect from JSON handlers and returns the request body type. | [
"verifyInputSignature",
"verifies",
"that",
"the",
"given",
"input",
"argument",
"types",
"match",
"what",
"we",
"expect",
"from",
"JSON",
"handlers",
"and",
"returns",
"the",
"request",
"body",
"type",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/encoding/json/register.go#L172-L205 |
10,609 | yarpc/yarpc-go | transport/grpc/inbound.go | newInbound | func newInbound(t *Transport, listener net.Listener, options ...InboundOption) *Inbound {
return &Inbound{
once: lifecycle.NewOnce(),
t: t,
listener: listener,
options: newInboundOptions(options),
}
} | go | func newInbound(t *Transport, listener net.Listener, options ...InboundOption) *Inbound {
return &Inbound{
once: lifecycle.NewOnce(),
t: t,
listener: listener,
options: newInboundOptions(options),
}
} | [
"func",
"newInbound",
"(",
"t",
"*",
"Transport",
",",
"listener",
"net",
".",
"Listener",
",",
"options",
"...",
"InboundOption",
")",
"*",
"Inbound",
"{",
"return",
"&",
"Inbound",
"{",
"once",
":",
"lifecycle",
".",
"NewOnce",
"(",
")",
",",
"t",
":... | // newInbound returns a new Inbound for the given listener. | [
"newInbound",
"returns",
"a",
"new",
"Inbound",
"for",
"the",
"given",
"listener",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/transport/grpc/inbound.go#L52-L59 |
10,610 | yarpc/yarpc-go | transport/grpc/inbound.go | Addr | func (i *Inbound) Addr() net.Addr {
i.lock.RLock()
defer i.lock.RUnlock()
// i.server is set in start, so checking against nil checks
// if Start has been called
// we check if i.listener is nil just for safety
if i.server == nil || i.listener == nil {
return nil
}
return i.listener.Addr()
} | go | func (i *Inbound) Addr() net.Addr {
i.lock.RLock()
defer i.lock.RUnlock()
// i.server is set in start, so checking against nil checks
// if Start has been called
// we check if i.listener is nil just for safety
if i.server == nil || i.listener == nil {
return nil
}
return i.listener.Addr()
} | [
"func",
"(",
"i",
"*",
"Inbound",
")",
"Addr",
"(",
")",
"net",
".",
"Addr",
"{",
"i",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"i",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n",
"// i.server is set in start, so checking against nil checks",
"/... | // Addr returns the address on which the server is listening.
//
// Returns nil if Start has not been called yet | [
"Addr",
"returns",
"the",
"address",
"on",
"which",
"the",
"server",
"is",
"listening",
".",
"Returns",
"nil",
"if",
"Start",
"has",
"not",
"been",
"called",
"yet"
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/transport/grpc/inbound.go#L86-L96 |
10,611 | yarpc/yarpc-go | transport/tchannel/options.go | newTransportOptions | func newTransportOptions() transportOptions {
return transportOptions{
tracer: opentracing.GlobalTracer(),
connTimeout: defaultConnTimeout,
connBackoffStrategy: backoff.DefaultExponential,
}
} | go | func newTransportOptions() transportOptions {
return transportOptions{
tracer: opentracing.GlobalTracer(),
connTimeout: defaultConnTimeout,
connBackoffStrategy: backoff.DefaultExponential,
}
} | [
"func",
"newTransportOptions",
"(",
")",
"transportOptions",
"{",
"return",
"transportOptions",
"{",
"tracer",
":",
"opentracing",
".",
"GlobalTracer",
"(",
")",
",",
"connTimeout",
":",
"defaultConnTimeout",
",",
"connBackoffStrategy",
":",
"backoff",
".",
"Default... | // newTransportOptions constructs the default transport options struct | [
"newTransportOptions",
"constructs",
"the",
"default",
"transport",
"options",
"struct"
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/transport/tchannel/options.go#L63-L69 |
10,612 | yarpc/yarpc-go | transport/tchannel/options.go | Tracer | func Tracer(tracer opentracing.Tracer) TransportOption {
return func(t *transportOptions) {
t.tracer = tracer
}
} | go | func Tracer(tracer opentracing.Tracer) TransportOption {
return func(t *transportOptions) {
t.tracer = tracer
}
} | [
"func",
"Tracer",
"(",
"tracer",
"opentracing",
".",
"Tracer",
")",
"TransportOption",
"{",
"return",
"func",
"(",
"t",
"*",
"transportOptions",
")",
"{",
"t",
".",
"tracer",
"=",
"tracer",
"\n",
"}",
"\n",
"}"
] | // Tracer specifies the request tracer used for RPCs passing through the
// TChannel transport. | [
"Tracer",
"specifies",
"the",
"request",
"tracer",
"used",
"for",
"RPCs",
"passing",
"through",
"the",
"TChannel",
"transport",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/transport/tchannel/options.go#L80-L84 |
10,613 | yarpc/yarpc-go | transport/tchannel/options.go | ConnTimeout | func ConnTimeout(d time.Duration) TransportOption {
return func(options *transportOptions) {
options.connTimeout = d
}
} | go | func ConnTimeout(d time.Duration) TransportOption {
return func(options *transportOptions) {
options.connTimeout = d
}
} | [
"func",
"ConnTimeout",
"(",
"d",
"time",
".",
"Duration",
")",
"TransportOption",
"{",
"return",
"func",
"(",
"options",
"*",
"transportOptions",
")",
"{",
"options",
".",
"connTimeout",
"=",
"d",
"\n",
"}",
"\n",
"}"
] | // ConnTimeout specifies the time that TChannel will wait for a
// connection attempt to any retained peer.
//
// The default is half of a second. | [
"ConnTimeout",
"specifies",
"the",
"time",
"that",
"TChannel",
"will",
"wait",
"for",
"a",
"connection",
"attempt",
"to",
"any",
"retained",
"peer",
".",
"The",
"default",
"is",
"half",
"of",
"a",
"second",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/transport/tchannel/options.go#L156-L160 |
10,614 | yarpc/yarpc-go | transport/tchannel/options.go | ConnBackoff | func ConnBackoff(s backoffapi.Strategy) TransportOption {
return func(options *transportOptions) {
options.connBackoffStrategy = s
}
} | go | func ConnBackoff(s backoffapi.Strategy) TransportOption {
return func(options *transportOptions) {
options.connBackoffStrategy = s
}
} | [
"func",
"ConnBackoff",
"(",
"s",
"backoffapi",
".",
"Strategy",
")",
"TransportOption",
"{",
"return",
"func",
"(",
"options",
"*",
"transportOptions",
")",
"{",
"options",
".",
"connBackoffStrategy",
"=",
"s",
"\n",
"}",
"\n",
"}"
] | // ConnBackoff specifies the connection backoff strategy for delays between
// connection attempts for each peer.
//
// ConnBackoff accepts a function that creates new backoff instances.
// The transport uses this to make referentially independent backoff instances
// that will not be shared across goroutines.
//
// The backoff instance is a function that accepts connection attempts and
// returns a duration.
//
// The default is exponential backoff starting with 10ms fully jittered,
// doubling each attempt, with a maximum interval of 30s. | [
"ConnBackoff",
"specifies",
"the",
"connection",
"backoff",
"strategy",
"for",
"delays",
"between",
"connection",
"attempts",
"for",
"each",
"peer",
".",
"ConnBackoff",
"accepts",
"a",
"function",
"that",
"creates",
"new",
"backoff",
"instances",
".",
"The",
"tran... | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/transport/tchannel/options.go#L174-L178 |
10,615 | yarpc/yarpc-go | internal/crossdock/client/dispatcher/dispatcher.go | CreateDispatcherForTransport | func CreateDispatcherForTransport(t crossdock.T, trans string) *yarpc.Dispatcher {
fatals := crossdock.Fatals(t)
server := t.Param(params.Server)
fatals.NotEmpty(server, "server is required")
var unaryOutbound transport.UnaryOutbound
if trans == "" {
trans = t.Param(params.Transport)
}
switch trans {
case "http":
httpTransport := http.NewTransport()
unaryOutbound = httpTransport.NewSingleOutbound(fmt.Sprintf("http://%s:8081", server))
case "tchannel":
tchannelTransport, err := tchannel.NewChannelTransport(tchannel.ServiceName("client"))
fatals.NoError(err, "Failed to build ChannelTransport")
unaryOutbound = tchannelTransport.NewSingleOutbound(server + ":8082")
case "grpc":
unaryOutbound = grpc.NewTransport().NewSingleOutbound(server + ":8089")
default:
fatals.Fail("", "unknown transport %q", trans)
}
return yarpc.NewDispatcher(yarpc.Config{
Name: "client",
Outbounds: yarpc.Outbounds{
"yarpc-test": {
Unary: unaryOutbound,
},
},
})
} | go | func CreateDispatcherForTransport(t crossdock.T, trans string) *yarpc.Dispatcher {
fatals := crossdock.Fatals(t)
server := t.Param(params.Server)
fatals.NotEmpty(server, "server is required")
var unaryOutbound transport.UnaryOutbound
if trans == "" {
trans = t.Param(params.Transport)
}
switch trans {
case "http":
httpTransport := http.NewTransport()
unaryOutbound = httpTransport.NewSingleOutbound(fmt.Sprintf("http://%s:8081", server))
case "tchannel":
tchannelTransport, err := tchannel.NewChannelTransport(tchannel.ServiceName("client"))
fatals.NoError(err, "Failed to build ChannelTransport")
unaryOutbound = tchannelTransport.NewSingleOutbound(server + ":8082")
case "grpc":
unaryOutbound = grpc.NewTransport().NewSingleOutbound(server + ":8089")
default:
fatals.Fail("", "unknown transport %q", trans)
}
return yarpc.NewDispatcher(yarpc.Config{
Name: "client",
Outbounds: yarpc.Outbounds{
"yarpc-test": {
Unary: unaryOutbound,
},
},
})
} | [
"func",
"CreateDispatcherForTransport",
"(",
"t",
"crossdock",
".",
"T",
",",
"trans",
"string",
")",
"*",
"yarpc",
".",
"Dispatcher",
"{",
"fatals",
":=",
"crossdock",
".",
"Fatals",
"(",
"t",
")",
"\n\n",
"server",
":=",
"t",
".",
"Param",
"(",
"params... | // CreateDispatcherForTransport creates an RPC from the given parameters or fails the whole behavior.
//
// If trans is non-empty, this will be used instead of the behavior transport. | [
"CreateDispatcherForTransport",
"creates",
"an",
"RPC",
"from",
"the",
"given",
"parameters",
"or",
"fails",
"the",
"whole",
"behavior",
".",
"If",
"trans",
"is",
"non",
"-",
"empty",
"this",
"will",
"be",
"used",
"instead",
"of",
"the",
"behavior",
"transport... | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/client/dispatcher/dispatcher.go#L45-L78 |
10,616 | yarpc/yarpc-go | internal/digester/digester.go | New | func New() *Digester {
d := _digesterPool.Get().(*Digester)
d.bs = d.bs[:0]
return d
} | go | func New() *Digester {
d := _digesterPool.Get().(*Digester)
d.bs = d.bs[:0]
return d
} | [
"func",
"New",
"(",
")",
"*",
"Digester",
"{",
"d",
":=",
"_digesterPool",
".",
"Get",
"(",
")",
".",
"(",
"*",
"Digester",
")",
"\n",
"d",
".",
"bs",
"=",
"d",
".",
"bs",
"[",
":",
"0",
"]",
"\n",
"return",
"d",
"\n",
"}"
] | // New creates a new Digester.
// For optimal performance, be sure to call "Free" on each digester. | [
"New",
"creates",
"a",
"new",
"Digester",
".",
"For",
"optimal",
"performance",
"be",
"sure",
"to",
"call",
"Free",
"on",
"each",
"digester",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/digester/digester.go#L43-L47 |
10,617 | yarpc/yarpc-go | internal/digester/digester.go | Add | func (d *Digester) Add(s string) {
if len(d.bs) > 0 {
// separate labels with a null byte
d.bs = append(d.bs, '\x00')
}
d.bs = append(d.bs, s...)
} | go | func (d *Digester) Add(s string) {
if len(d.bs) > 0 {
// separate labels with a null byte
d.bs = append(d.bs, '\x00')
}
d.bs = append(d.bs, s...)
} | [
"func",
"(",
"d",
"*",
"Digester",
")",
"Add",
"(",
"s",
"string",
")",
"{",
"if",
"len",
"(",
"d",
".",
"bs",
")",
">",
"0",
"{",
"// separate labels with a null byte",
"d",
".",
"bs",
"=",
"append",
"(",
"d",
".",
"bs",
",",
"'\\x00'",
")",
"\n... | // Add adds a string to the digester slice. | [
"Add",
"adds",
"a",
"string",
"to",
"the",
"digester",
"slice",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/digester/digester.go#L50-L56 |
10,618 | yarpc/yarpc-go | internal/protoplugin/registry.go | loadFile | func (r *registry) loadFile(file *descriptor.FileDescriptorProto) {
pkg := &GoPackage{
Path: r.goPackagePath(file),
Name: defaultGoPackageName(file),
}
if err := r.ReserveGoPackageAlias(pkg.Name, pkg.Path); err != nil {
for i := 0; ; i++ {
alias := fmt.Sprintf("%s_%d", pkg.Name, i)
if err := r.ReserveGoPackageAlias(alias, pkg.Path); err == nil {
pkg.Alias = alias
break
}
}
}
f := &File{
FileDescriptorProto: file,
GoPackage: pkg,
}
r.files[file.GetName()] = f
r.registerMsg(f, nil, file.GetMessageType())
r.registerEnum(f, nil, file.GetEnumType())
} | go | func (r *registry) loadFile(file *descriptor.FileDescriptorProto) {
pkg := &GoPackage{
Path: r.goPackagePath(file),
Name: defaultGoPackageName(file),
}
if err := r.ReserveGoPackageAlias(pkg.Name, pkg.Path); err != nil {
for i := 0; ; i++ {
alias := fmt.Sprintf("%s_%d", pkg.Name, i)
if err := r.ReserveGoPackageAlias(alias, pkg.Path); err == nil {
pkg.Alias = alias
break
}
}
}
f := &File{
FileDescriptorProto: file,
GoPackage: pkg,
}
r.files[file.GetName()] = f
r.registerMsg(f, nil, file.GetMessageType())
r.registerEnum(f, nil, file.GetEnumType())
} | [
"func",
"(",
"r",
"*",
"registry",
")",
"loadFile",
"(",
"file",
"*",
"descriptor",
".",
"FileDescriptorProto",
")",
"{",
"pkg",
":=",
"&",
"GoPackage",
"{",
"Path",
":",
"r",
".",
"goPackagePath",
"(",
"file",
")",
",",
"Name",
":",
"defaultGoPackageNam... | // loadFile loads messages, enumerations and fields from "file".
// It does not loads services and methods in "file". You need to call
// loadServices after loadFiles is called for all files to load services and methods. | [
"loadFile",
"loads",
"messages",
"enumerations",
"and",
"fields",
"from",
"file",
".",
"It",
"does",
"not",
"loads",
"services",
"and",
"methods",
"in",
"file",
".",
"You",
"need",
"to",
"call",
"loadServices",
"after",
"loadFiles",
"is",
"called",
"for",
"a... | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/protoplugin/registry.go#L139-L160 |
10,619 | yarpc/yarpc-go | internal/protoplugin/registry.go | loadTransitiveFileDependencies | func (r *registry) loadTransitiveFileDependencies(file *File) error {
seen := make(map[string]struct{})
files, err := r.loadTransitiveFileDependenciesRecurse(file, seen)
if err != nil {
return err
}
file.TransitiveDependencies = files
return nil
} | go | func (r *registry) loadTransitiveFileDependencies(file *File) error {
seen := make(map[string]struct{})
files, err := r.loadTransitiveFileDependenciesRecurse(file, seen)
if err != nil {
return err
}
file.TransitiveDependencies = files
return nil
} | [
"func",
"(",
"r",
"*",
"registry",
")",
"loadTransitiveFileDependencies",
"(",
"file",
"*",
"File",
")",
"error",
"{",
"seen",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
")",
"\n",
"files",
",",
"err",
":=",
"r",
".",
"loadTran... | // loadTransitiveFileDependencies registers services and their methods from "targetFile" to "r".
// It must be called after loadFile is called for all files so that loadTransitiveFileDependencies
// can resolve file descriptors as depdendencies. | [
"loadTransitiveFileDependencies",
"registers",
"services",
"and",
"their",
"methods",
"from",
"targetFile",
"to",
"r",
".",
"It",
"must",
"be",
"called",
"after",
"loadFile",
"is",
"called",
"for",
"all",
"files",
"so",
"that",
"loadTransitiveFileDependencies",
"can... | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/protoplugin/registry.go#L262-L270 |
10,620 | yarpc/yarpc-go | transport/tchannel/inbound.go | NewInbound | func (t *Transport) NewInbound() *Inbound {
return &Inbound{
once: lifecycle.NewOnce(),
transport: t,
}
} | go | func (t *Transport) NewInbound() *Inbound {
return &Inbound{
once: lifecycle.NewOnce(),
transport: t,
}
} | [
"func",
"(",
"t",
"*",
"Transport",
")",
"NewInbound",
"(",
")",
"*",
"Inbound",
"{",
"return",
"&",
"Inbound",
"{",
"once",
":",
"lifecycle",
".",
"NewOnce",
"(",
")",
",",
"transport",
":",
"t",
",",
"}",
"\n",
"}"
] | // NewInbound returns a new TChannel inbound backed by a shared TChannel
// transport.
// There should only be one inbound for TChannel since all outbounds send the
// listening port over non-ephemeral connections so a service can deduplicate
// locally- and remotely-initiated persistent connections. | [
"NewInbound",
"returns",
"a",
"new",
"TChannel",
"inbound",
"backed",
"by",
"a",
"shared",
"TChannel",
"transport",
".",
"There",
"should",
"only",
"be",
"one",
"inbound",
"for",
"TChannel",
"since",
"all",
"outbounds",
"send",
"the",
"listening",
"port",
"ove... | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/transport/tchannel/inbound.go#L42-L47 |
10,621 | yarpc/yarpc-go | internal/examples/thrift-keyvalue/keyvalue/kv/keyvalue_setvalue.go | String | func (v *KeyValue_SetValue_Args) String() string {
if v == nil {
return "<nil>"
}
var fields [2]string
i := 0
if v.Key != nil {
fields[i] = fmt.Sprintf("Key: %v", *(v.Key))
i++
}
if v.Value != nil {
fields[i] = fmt.Sprintf("Value: %v", *(v.Value))
i++
}
return fmt.Sprintf("KeyValue_SetValue_Args{%v}", strings.Join(fields[:i], ", "))
} | go | func (v *KeyValue_SetValue_Args) String() string {
if v == nil {
return "<nil>"
}
var fields [2]string
i := 0
if v.Key != nil {
fields[i] = fmt.Sprintf("Key: %v", *(v.Key))
i++
}
if v.Value != nil {
fields[i] = fmt.Sprintf("Value: %v", *(v.Value))
i++
}
return fmt.Sprintf("KeyValue_SetValue_Args{%v}", strings.Join(fields[:i], ", "))
} | [
"func",
"(",
"v",
"*",
"KeyValue_SetValue_Args",
")",
"String",
"(",
")",
"string",
"{",
"if",
"v",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"var",
"fields",
"[",
"2",
"]",
"string",
"\n",
"i",
":=",
"0",
"\n",
"if",
"v",
".",
... | // String returns a readable string representation of a KeyValue_SetValue_Args
// struct. | [
"String",
"returns",
"a",
"readable",
"string",
"representation",
"of",
"a",
"KeyValue_SetValue_Args",
"struct",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/thrift-keyvalue/keyvalue/kv/keyvalue_setvalue.go#L134-L151 |
10,622 | yarpc/yarpc-go | internal/examples/thrift-keyvalue/keyvalue/kv/keyvalue_setvalue.go | Equals | func (v *KeyValue_SetValue_Args) Equals(rhs *KeyValue_SetValue_Args) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
if !_String_EqualsPtr(v.Key, rhs.Key) {
return false
}
if !_String_EqualsPtr(v.Value, rhs.Value) {
return false
}
return true
} | go | func (v *KeyValue_SetValue_Args) Equals(rhs *KeyValue_SetValue_Args) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
if !_String_EqualsPtr(v.Key, rhs.Key) {
return false
}
if !_String_EqualsPtr(v.Value, rhs.Value) {
return false
}
return true
} | [
"func",
"(",
"v",
"*",
"KeyValue_SetValue_Args",
")",
"Equals",
"(",
"rhs",
"*",
"KeyValue_SetValue_Args",
")",
"bool",
"{",
"if",
"v",
"==",
"nil",
"{",
"return",
"rhs",
"==",
"nil",
"\n",
"}",
"else",
"if",
"rhs",
"==",
"nil",
"{",
"return",
"false",... | // Equals returns true if all the fields of this KeyValue_SetValue_Args match the
// provided KeyValue_SetValue_Args.
//
// This function performs a deep comparison. | [
"Equals",
"returns",
"true",
"if",
"all",
"the",
"fields",
"of",
"this",
"KeyValue_SetValue_Args",
"match",
"the",
"provided",
"KeyValue_SetValue_Args",
".",
"This",
"function",
"performs",
"a",
"deep",
"comparison",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/thrift-keyvalue/keyvalue/kv/keyvalue_setvalue.go#L157-L171 |
10,623 | yarpc/yarpc-go | internal/examples/thrift-keyvalue/keyvalue/kv/keyvalue_setvalue.go | MarshalLogObject | func (v *KeyValue_SetValue_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
if v.Key != nil {
enc.AddString("key", *v.Key)
}
if v.Value != nil {
enc.AddString("value", *v.Value)
}
return err
} | go | func (v *KeyValue_SetValue_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
if v.Key != nil {
enc.AddString("key", *v.Key)
}
if v.Value != nil {
enc.AddString("value", *v.Value)
}
return err
} | [
"func",
"(",
"v",
"*",
"KeyValue_SetValue_Args",
")",
"MarshalLogObject",
"(",
"enc",
"zapcore",
".",
"ObjectEncoder",
")",
"(",
"err",
"error",
")",
"{",
"if",
"v",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"v",
".",
"Key",
"!=",
"ni... | // MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of KeyValue_SetValue_Args. | [
"MarshalLogObject",
"implements",
"zapcore",
".",
"ObjectMarshaler",
"enabling",
"fast",
"logging",
"of",
"KeyValue_SetValue_Args",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/thrift-keyvalue/keyvalue/kv/keyvalue_setvalue.go#L175-L186 |
10,624 | yarpc/yarpc-go | internal/examples/thrift-keyvalue/keyvalue/kv/keyvalue_setvalue.go | GetValue | func (v *KeyValue_SetValue_Args) GetValue() (o string) {
if v != nil && v.Value != nil {
return *v.Value
}
return
} | go | func (v *KeyValue_SetValue_Args) GetValue() (o string) {
if v != nil && v.Value != nil {
return *v.Value
}
return
} | [
"func",
"(",
"v",
"*",
"KeyValue_SetValue_Args",
")",
"GetValue",
"(",
")",
"(",
"o",
"string",
")",
"{",
"if",
"v",
"!=",
"nil",
"&&",
"v",
".",
"Value",
"!=",
"nil",
"{",
"return",
"*",
"v",
".",
"Value",
"\n",
"}",
"\n\n",
"return",
"\n",
"}"
... | // GetValue returns the value of Value if it is set or its
// zero value if it is unset. | [
"GetValue",
"returns",
"the",
"value",
"of",
"Value",
"if",
"it",
"is",
"set",
"or",
"its",
"zero",
"value",
"if",
"it",
"is",
"unset",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/thrift-keyvalue/keyvalue/kv/keyvalue_setvalue.go#L205-L211 |
10,625 | yarpc/yarpc-go | internal/examples/thrift-keyvalue/keyvalue/kv/keyvalue_setvalue.go | Equals | func (v *KeyValue_SetValue_Result) Equals(rhs *KeyValue_SetValue_Result) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
return true
} | go | func (v *KeyValue_SetValue_Result) Equals(rhs *KeyValue_SetValue_Result) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
return true
} | [
"func",
"(",
"v",
"*",
"KeyValue_SetValue_Result",
")",
"Equals",
"(",
"rhs",
"*",
"KeyValue_SetValue_Result",
")",
"bool",
"{",
"if",
"v",
"==",
"nil",
"{",
"return",
"rhs",
"==",
"nil",
"\n",
"}",
"else",
"if",
"rhs",
"==",
"nil",
"{",
"return",
"fal... | // Equals returns true if all the fields of this KeyValue_SetValue_Result match the
// provided KeyValue_SetValue_Result.
//
// This function performs a deep comparison. | [
"Equals",
"returns",
"true",
"if",
"all",
"the",
"fields",
"of",
"this",
"KeyValue_SetValue_Result",
"match",
"the",
"provided",
"KeyValue_SetValue_Result",
".",
"This",
"function",
"performs",
"a",
"deep",
"comparison",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/thrift-keyvalue/keyvalue/kv/keyvalue_setvalue.go#L385-L393 |
10,626 | yarpc/yarpc-go | api/transport/propagation.go | Do | func (c *CreateOpenTracingSpan) Do(
ctx context.Context,
req *Request,
) (context.Context, opentracing.Span) {
var parent opentracing.SpanContext
if parentSpan := opentracing.SpanFromContext(ctx); parentSpan != nil {
parent = parentSpan.Context()
}
tags := opentracing.Tags{
"rpc.caller": req.Caller,
"rpc.service": req.Service,
"rpc.encoding": req.Encoding,
"rpc.transport": c.TransportName,
}
for k, v := range c.ExtraTags {
tags[k] = v
}
span := c.Tracer.StartSpan(
req.Procedure,
opentracing.StartTime(c.StartTime),
opentracing.ChildOf(parent),
tags,
)
ext.PeerService.Set(span, req.Service)
ext.SpanKindRPCClient.Set(span)
ctx = opentracing.ContextWithSpan(ctx, span)
return ctx, span
} | go | func (c *CreateOpenTracingSpan) Do(
ctx context.Context,
req *Request,
) (context.Context, opentracing.Span) {
var parent opentracing.SpanContext
if parentSpan := opentracing.SpanFromContext(ctx); parentSpan != nil {
parent = parentSpan.Context()
}
tags := opentracing.Tags{
"rpc.caller": req.Caller,
"rpc.service": req.Service,
"rpc.encoding": req.Encoding,
"rpc.transport": c.TransportName,
}
for k, v := range c.ExtraTags {
tags[k] = v
}
span := c.Tracer.StartSpan(
req.Procedure,
opentracing.StartTime(c.StartTime),
opentracing.ChildOf(parent),
tags,
)
ext.PeerService.Set(span, req.Service)
ext.SpanKindRPCClient.Set(span)
ctx = opentracing.ContextWithSpan(ctx, span)
return ctx, span
} | [
"func",
"(",
"c",
"*",
"CreateOpenTracingSpan",
")",
"Do",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"Request",
",",
")",
"(",
"context",
".",
"Context",
",",
"opentracing",
".",
"Span",
")",
"{",
"var",
"parent",
"opentracing",
".",
"Spa... | // Do creates a new context that has a reference to the started span.
// This should be called before a Outbound makes a call | [
"Do",
"creates",
"a",
"new",
"context",
"that",
"has",
"a",
"reference",
"to",
"the",
"started",
"span",
".",
"This",
"should",
"be",
"called",
"before",
"a",
"Outbound",
"makes",
"a",
"call"
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/api/transport/propagation.go#L42-L71 |
10,627 | yarpc/yarpc-go | api/transport/propagation.go | Do | func (e *ExtractOpenTracingSpan) Do(
ctx context.Context,
req *Request,
) (context.Context, opentracing.Span) {
tags := opentracing.Tags{
"rpc.caller": req.Caller,
"rpc.service": req.Service,
"rpc.encoding": req.Encoding,
"rpc.transport": e.TransportName,
}
for k, v := range e.ExtraTags {
tags[k] = v
}
span := e.Tracer.StartSpan(
req.Procedure,
opentracing.StartTime(e.StartTime),
tags,
// parentSpanCtx may be nil
// this implies ChildOf
ext.RPCServerOption(e.ParentSpanContext),
)
ext.PeerService.Set(span, req.Caller)
ext.SpanKindRPCServer.Set(span)
ctx = opentracing.ContextWithSpan(ctx, span)
return ctx, span
} | go | func (e *ExtractOpenTracingSpan) Do(
ctx context.Context,
req *Request,
) (context.Context, opentracing.Span) {
tags := opentracing.Tags{
"rpc.caller": req.Caller,
"rpc.service": req.Service,
"rpc.encoding": req.Encoding,
"rpc.transport": e.TransportName,
}
for k, v := range e.ExtraTags {
tags[k] = v
}
span := e.Tracer.StartSpan(
req.Procedure,
opentracing.StartTime(e.StartTime),
tags,
// parentSpanCtx may be nil
// this implies ChildOf
ext.RPCServerOption(e.ParentSpanContext),
)
ext.PeerService.Set(span, req.Caller)
ext.SpanKindRPCServer.Set(span)
ctx = opentracing.ContextWithSpan(ctx, span)
return ctx, span
} | [
"func",
"(",
"e",
"*",
"ExtractOpenTracingSpan",
")",
"Do",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"Request",
",",
")",
"(",
"context",
".",
"Context",
",",
"opentracing",
".",
"Span",
")",
"{",
"tags",
":=",
"opentracing",
".",
"Tags"... | // Do derives a new context from SpanContext. The created context has a
// reference to the started span. parentSpanCtx may be nil.
// This should be called before a Inbound handles a request | [
"Do",
"derives",
"a",
"new",
"context",
"from",
"SpanContext",
".",
"The",
"created",
"context",
"has",
"a",
"reference",
"to",
"the",
"started",
"span",
".",
"parentSpanCtx",
"may",
"be",
"nil",
".",
"This",
"should",
"be",
"called",
"before",
"a",
"Inbou... | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/api/transport/propagation.go#L85-L111 |
10,628 | yarpc/yarpc-go | api/transport/propagation.go | UpdateSpanWithErr | func UpdateSpanWithErr(span opentracing.Span, err error) error {
if err != nil {
span.SetTag("error", true)
span.LogFields(opentracinglog.String("event", err.Error()))
}
return err
} | go | func UpdateSpanWithErr(span opentracing.Span, err error) error {
if err != nil {
span.SetTag("error", true)
span.LogFields(opentracinglog.String("event", err.Error()))
}
return err
} | [
"func",
"UpdateSpanWithErr",
"(",
"span",
"opentracing",
".",
"Span",
",",
"err",
"error",
")",
"error",
"{",
"if",
"err",
"!=",
"nil",
"{",
"span",
".",
"SetTag",
"(",
"\"",
"\"",
",",
"true",
")",
"\n",
"span",
".",
"LogFields",
"(",
"opentracinglog"... | // UpdateSpanWithErr sets the error tag on a span, if an error is given.
// Returns the given error | [
"UpdateSpanWithErr",
"sets",
"the",
"error",
"tag",
"on",
"a",
"span",
"if",
"an",
"error",
"is",
"given",
".",
"Returns",
"the",
"given",
"error"
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/api/transport/propagation.go#L115-L121 |
10,629 | yarpc/yarpc-go | internal/observability/graph.go | begin | func (g *graph) begin(ctx context.Context, rpcType transport.Type, direction directionName, req *transport.Request) call {
now := _timeNow()
d := digester.New()
d.Add(req.Caller)
d.Add(req.Service)
d.Add(req.Transport)
d.Add(string(req.Encoding))
d.Add(req.Procedure)
d.Add(req.RoutingKey)
d.Add(req.RoutingDelegate)
d.Add(string(direction))
e := g.getOrCreateEdge(d.Digest(), req, string(direction))
d.Free()
return call{
edge: e,
extract: g.extract,
started: now,
ctx: ctx,
req: req,
rpcType: rpcType,
direction: direction,
succLevel: g.succLevel,
failLevel: g.failLevel,
appErrLevel: g.appErrLevel,
}
} | go | func (g *graph) begin(ctx context.Context, rpcType transport.Type, direction directionName, req *transport.Request) call {
now := _timeNow()
d := digester.New()
d.Add(req.Caller)
d.Add(req.Service)
d.Add(req.Transport)
d.Add(string(req.Encoding))
d.Add(req.Procedure)
d.Add(req.RoutingKey)
d.Add(req.RoutingDelegate)
d.Add(string(direction))
e := g.getOrCreateEdge(d.Digest(), req, string(direction))
d.Free()
return call{
edge: e,
extract: g.extract,
started: now,
ctx: ctx,
req: req,
rpcType: rpcType,
direction: direction,
succLevel: g.succLevel,
failLevel: g.failLevel,
appErrLevel: g.appErrLevel,
}
} | [
"func",
"(",
"g",
"*",
"graph",
")",
"begin",
"(",
"ctx",
"context",
".",
"Context",
",",
"rpcType",
"transport",
".",
"Type",
",",
"direction",
"directionName",
",",
"req",
"*",
"transport",
".",
"Request",
")",
"call",
"{",
"now",
":=",
"_timeNow",
"... | // begin starts a call along an edge. | [
"begin",
"starts",
"a",
"call",
"along",
"an",
"edge",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/observability/graph.go#L77-L104 |
10,630 | yarpc/yarpc-go | internal/backoff/exponential.go | FirstBackoff | func FirstBackoff(t time.Duration) ExponentialOption {
return func(options *exponentialOptions) {
options.first = t
}
} | go | func FirstBackoff(t time.Duration) ExponentialOption {
return func(options *exponentialOptions) {
options.first = t
}
} | [
"func",
"FirstBackoff",
"(",
"t",
"time",
".",
"Duration",
")",
"ExponentialOption",
"{",
"return",
"func",
"(",
"options",
"*",
"exponentialOptions",
")",
"{",
"options",
".",
"first",
"=",
"t",
"\n",
"}",
"\n",
"}"
] | // FirstBackoff sets the initial range of durations that the first backoff
// duration will provide.
// The range of durations will double for each successive attempt. | [
"FirstBackoff",
"sets",
"the",
"initial",
"range",
"of",
"durations",
"that",
"the",
"first",
"backoff",
"duration",
"will",
"provide",
".",
"The",
"range",
"of",
"durations",
"will",
"double",
"for",
"each",
"successive",
"attempt",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/backoff/exponential.go#L81-L85 |
10,631 | yarpc/yarpc-go | internal/backoff/exponential.go | MaxBackoff | func MaxBackoff(t time.Duration) ExponentialOption {
return func(options *exponentialOptions) {
options.max = t
}
} | go | func MaxBackoff(t time.Duration) ExponentialOption {
return func(options *exponentialOptions) {
options.max = t
}
} | [
"func",
"MaxBackoff",
"(",
"t",
"time",
".",
"Duration",
")",
"ExponentialOption",
"{",
"return",
"func",
"(",
"options",
"*",
"exponentialOptions",
")",
"{",
"options",
".",
"max",
"=",
"t",
"\n",
"}",
"\n",
"}"
] | // MaxBackoff sets absolute max time that will ever be returned for a backoff. | [
"MaxBackoff",
"sets",
"absolute",
"max",
"time",
"that",
"will",
"ever",
"be",
"returned",
"for",
"a",
"backoff",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/backoff/exponential.go#L88-L92 |
10,632 | yarpc/yarpc-go | internal/backoff/exponential.go | randGenerator | func randGenerator(newRand func() *rand.Rand) ExponentialOption {
return func(options *exponentialOptions) {
options.newRand = newRand
}
} | go | func randGenerator(newRand func() *rand.Rand) ExponentialOption {
return func(options *exponentialOptions) {
options.newRand = newRand
}
} | [
"func",
"randGenerator",
"(",
"newRand",
"func",
"(",
")",
"*",
"rand",
".",
"Rand",
")",
"ExponentialOption",
"{",
"return",
"func",
"(",
"options",
"*",
"exponentialOptions",
")",
"{",
"options",
".",
"newRand",
"=",
"newRand",
"\n",
"}",
"\n",
"}"
] | // randGenerator is an internal option for overriding the random number
// generator. | [
"randGenerator",
"is",
"an",
"internal",
"option",
"for",
"overriding",
"the",
"random",
"number",
"generator",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/backoff/exponential.go#L96-L100 |
10,633 | yarpc/yarpc-go | internal/backoff/exponential.go | Backoff | func (e *ExponentialStrategy) Backoff() backoff.Backoff {
return &exponentialBackoff{
first: e.opts.first,
max: e.opts.max.Nanoseconds(),
rand: e.opts.newRand(),
}
} | go | func (e *ExponentialStrategy) Backoff() backoff.Backoff {
return &exponentialBackoff{
first: e.opts.first,
max: e.opts.max.Nanoseconds(),
rand: e.opts.newRand(),
}
} | [
"func",
"(",
"e",
"*",
"ExponentialStrategy",
")",
"Backoff",
"(",
")",
"backoff",
".",
"Backoff",
"{",
"return",
"&",
"exponentialBackoff",
"{",
"first",
":",
"e",
".",
"opts",
".",
"first",
",",
"max",
":",
"e",
".",
"opts",
".",
"max",
".",
"Nanos... | // Backoff returns an instance of the exponential backoff strategy with its own
// random number generator. | [
"Backoff",
"returns",
"an",
"instance",
"of",
"the",
"exponential",
"backoff",
"strategy",
"with",
"its",
"own",
"random",
"number",
"generator",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/backoff/exponential.go#L139-L145 |
10,634 | yarpc/yarpc-go | internal/backoff/exponential.go | IsEqual | func (e *ExponentialStrategy) IsEqual(o *ExponentialStrategy) bool {
if e.opts.first != o.opts.first {
return false
}
if e.opts.max != o.opts.max {
return false
}
return true
} | go | func (e *ExponentialStrategy) IsEqual(o *ExponentialStrategy) bool {
if e.opts.first != o.opts.first {
return false
}
if e.opts.max != o.opts.max {
return false
}
return true
} | [
"func",
"(",
"e",
"*",
"ExponentialStrategy",
")",
"IsEqual",
"(",
"o",
"*",
"ExponentialStrategy",
")",
"bool",
"{",
"if",
"e",
".",
"opts",
".",
"first",
"!=",
"o",
".",
"opts",
".",
"first",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"e",
".... | // IsEqual returns whether this strategy is equivalent to another strategy. | [
"IsEqual",
"returns",
"whether",
"this",
"strategy",
"is",
"equivalent",
"to",
"another",
"strategy",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/backoff/exponential.go#L148-L156 |
10,635 | yarpc/yarpc-go | internal/backoff/exponential.go | Duration | func (e *exponentialBackoff) Duration(attempts uint) time.Duration {
spread := (1 << attempts) * e.first.Nanoseconds()
if spread <= 0 || spread > e.max {
spread = e.max
}
// Adding 1 to the spread ensures that the upper bound of the range of
// possible durations includes the maximum.
return time.Duration(e.rand.Int63n(spread + 1))
} | go | func (e *exponentialBackoff) Duration(attempts uint) time.Duration {
spread := (1 << attempts) * e.first.Nanoseconds()
if spread <= 0 || spread > e.max {
spread = e.max
}
// Adding 1 to the spread ensures that the upper bound of the range of
// possible durations includes the maximum.
return time.Duration(e.rand.Int63n(spread + 1))
} | [
"func",
"(",
"e",
"*",
"exponentialBackoff",
")",
"Duration",
"(",
"attempts",
"uint",
")",
"time",
".",
"Duration",
"{",
"spread",
":=",
"(",
"1",
"<<",
"attempts",
")",
"*",
"e",
".",
"first",
".",
"Nanoseconds",
"(",
")",
"\n",
"if",
"spread",
"<=... | // Duration takes an attempt number and returns the duration the caller should
// wait. | [
"Duration",
"takes",
"an",
"attempt",
"number",
"and",
"returns",
"the",
"duration",
"the",
"caller",
"should",
"wait",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/backoff/exponential.go#L168-L176 |
10,636 | yarpc/yarpc-go | internal/crossdock/thrift/gauntlet/secondservice_blahblah.go | Equals | func (v *SecondService_BlahBlah_Args) Equals(rhs *SecondService_BlahBlah_Args) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
return true
} | go | func (v *SecondService_BlahBlah_Args) Equals(rhs *SecondService_BlahBlah_Args) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
return true
} | [
"func",
"(",
"v",
"*",
"SecondService_BlahBlah_Args",
")",
"Equals",
"(",
"rhs",
"*",
"SecondService_BlahBlah_Args",
")",
"bool",
"{",
"if",
"v",
"==",
"nil",
"{",
"return",
"rhs",
"==",
"nil",
"\n",
"}",
"else",
"if",
"rhs",
"==",
"nil",
"{",
"return",
... | // Equals returns true if all the fields of this SecondService_BlahBlah_Args match the
// provided SecondService_BlahBlah_Args.
//
// This function performs a deep comparison. | [
"Equals",
"returns",
"true",
"if",
"all",
"the",
"fields",
"of",
"this",
"SecondService_BlahBlah_Args",
"match",
"the",
"provided",
"SecondService_BlahBlah_Args",
".",
"This",
"function",
"performs",
"a",
"deep",
"comparison",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/thrift/gauntlet/secondservice_blahblah.go#L107-L115 |
10,637 | yarpc/yarpc-go | internal/crossdock/thrift/gauntlet/secondservice_blahblah.go | Equals | func (v *SecondService_BlahBlah_Result) Equals(rhs *SecondService_BlahBlah_Result) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
return true
} | go | func (v *SecondService_BlahBlah_Result) Equals(rhs *SecondService_BlahBlah_Result) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
return true
} | [
"func",
"(",
"v",
"*",
"SecondService_BlahBlah_Result",
")",
"Equals",
"(",
"rhs",
"*",
"SecondService_BlahBlah_Result",
")",
"bool",
"{",
"if",
"v",
"==",
"nil",
"{",
"return",
"rhs",
"==",
"nil",
"\n",
"}",
"else",
"if",
"rhs",
"==",
"nil",
"{",
"retur... | // Equals returns true if all the fields of this SecondService_BlahBlah_Result match the
// provided SecondService_BlahBlah_Result.
//
// This function performs a deep comparison. | [
"Equals",
"returns",
"true",
"if",
"all",
"the",
"fields",
"of",
"this",
"SecondService_BlahBlah_Result",
"match",
"the",
"provided",
"SecondService_BlahBlah_Result",
".",
"This",
"function",
"performs",
"a",
"deep",
"comparison",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/thrift/gauntlet/secondservice_blahblah.go#L284-L292 |
10,638 | yarpc/yarpc-go | peer/bind.go | Bind | func Bind(chooserList peer.ChooserList, bind peer.Binder) *BoundChooser {
return &BoundChooser{
once: lifecycle.NewOnce(),
chooserList: chooserList,
updater: bind(chooserList),
}
} | go | func Bind(chooserList peer.ChooserList, bind peer.Binder) *BoundChooser {
return &BoundChooser{
once: lifecycle.NewOnce(),
chooserList: chooserList,
updater: bind(chooserList),
}
} | [
"func",
"Bind",
"(",
"chooserList",
"peer",
".",
"ChooserList",
",",
"bind",
"peer",
".",
"Binder",
")",
"*",
"BoundChooser",
"{",
"return",
"&",
"BoundChooser",
"{",
"once",
":",
"lifecycle",
".",
"NewOnce",
"(",
")",
",",
"chooserList",
":",
"chooserList... | // Bind couples a peer list with a peer list updater.
// Bind accepts a peer list and passes that peer list to a binder.
// The binder must return a peer list updater bound to the peer list.
// The peer list updater must implement Lifecycle so the bound peer list
// can start and stop updates. | [
"Bind",
"couples",
"a",
"peer",
"list",
"with",
"a",
"peer",
"list",
"updater",
".",
"Bind",
"accepts",
"a",
"peer",
"list",
"and",
"passes",
"that",
"peer",
"list",
"to",
"a",
"binder",
".",
"The",
"binder",
"must",
"return",
"a",
"peer",
"list",
"upd... | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/peer/bind.go#L38-L44 |
10,639 | yarpc/yarpc-go | peer/bind.go | Choose | func (c *BoundChooser) Choose(ctx context.Context, treq *transport.Request) (peer peer.Peer, onFinish func(error), err error) {
return c.chooserList.Choose(ctx, treq)
} | go | func (c *BoundChooser) Choose(ctx context.Context, treq *transport.Request) (peer peer.Peer, onFinish func(error), err error) {
return c.chooserList.Choose(ctx, treq)
} | [
"func",
"(",
"c",
"*",
"BoundChooser",
")",
"Choose",
"(",
"ctx",
"context",
".",
"Context",
",",
"treq",
"*",
"transport",
".",
"Request",
")",
"(",
"peer",
"peer",
".",
"Peer",
",",
"onFinish",
"func",
"(",
"error",
")",
",",
"err",
"error",
")",
... | // Choose returns a peer from the bound peer list. | [
"Choose",
"returns",
"a",
"peer",
"from",
"the",
"bound",
"peer",
"list",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/peer/bind.go#L65-L67 |
10,640 | yarpc/yarpc-go | peer/bind.go | IsRunning | func (c *BoundChooser) IsRunning() bool {
return c.chooserList.IsRunning() && c.updater.IsRunning()
} | go | func (c *BoundChooser) IsRunning() bool {
return c.chooserList.IsRunning() && c.updater.IsRunning()
} | [
"func",
"(",
"c",
"*",
"BoundChooser",
")",
"IsRunning",
"(",
")",
"bool",
"{",
"return",
"c",
".",
"chooserList",
".",
"IsRunning",
"(",
")",
"&&",
"c",
".",
"updater",
".",
"IsRunning",
"(",
")",
"\n",
"}"
] | // IsRunning returns whether the peer list and its peer list updater are both
// running, regardless of whether they should be running according to the bound
// chooser's lifecycle. | [
"IsRunning",
"returns",
"whether",
"the",
"peer",
"list",
"and",
"its",
"peer",
"list",
"updater",
"are",
"both",
"running",
"regardless",
"of",
"whether",
"they",
"should",
"be",
"running",
"according",
"to",
"the",
"bound",
"chooser",
"s",
"lifecycle",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/peer/bind.go#L115-L117 |
10,641 | yarpc/yarpc-go | peer/bind.go | Introspect | func (c *BoundChooser) Introspect() introspection.ChooserStatus {
if ic, ok := c.chooserList.(introspection.IntrospectableChooser); ok {
return ic.Introspect()
}
return introspection.ChooserStatus{}
} | go | func (c *BoundChooser) Introspect() introspection.ChooserStatus {
if ic, ok := c.chooserList.(introspection.IntrospectableChooser); ok {
return ic.Introspect()
}
return introspection.ChooserStatus{}
} | [
"func",
"(",
"c",
"*",
"BoundChooser",
")",
"Introspect",
"(",
")",
"introspection",
".",
"ChooserStatus",
"{",
"if",
"ic",
",",
"ok",
":=",
"c",
".",
"chooserList",
".",
"(",
"introspection",
".",
"IntrospectableChooser",
")",
";",
"ok",
"{",
"return",
... | // Introspect introspects the bound chooser. | [
"Introspect",
"introspects",
"the",
"bound",
"chooser",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/peer/bind.go#L120-L125 |
10,642 | yarpc/yarpc-go | internal/outboundmiddleware/chain.go | UnaryChain | func UnaryChain(mw ...middleware.UnaryOutbound) middleware.UnaryOutbound {
unchained := make([]middleware.UnaryOutbound, 0, len(mw))
for _, m := range mw {
if m == nil {
continue
}
if c, ok := m.(unaryChain); ok {
unchained = append(unchained, c...)
continue
}
unchained = append(unchained, m)
}
switch len(unchained) {
case 0:
return middleware.NopUnaryOutbound
case 1:
return unchained[0]
default:
return unaryChain(unchained)
}
} | go | func UnaryChain(mw ...middleware.UnaryOutbound) middleware.UnaryOutbound {
unchained := make([]middleware.UnaryOutbound, 0, len(mw))
for _, m := range mw {
if m == nil {
continue
}
if c, ok := m.(unaryChain); ok {
unchained = append(unchained, c...)
continue
}
unchained = append(unchained, m)
}
switch len(unchained) {
case 0:
return middleware.NopUnaryOutbound
case 1:
return unchained[0]
default:
return unaryChain(unchained)
}
} | [
"func",
"UnaryChain",
"(",
"mw",
"...",
"middleware",
".",
"UnaryOutbound",
")",
"middleware",
".",
"UnaryOutbound",
"{",
"unchained",
":=",
"make",
"(",
"[",
"]",
"middleware",
".",
"UnaryOutbound",
",",
"0",
",",
"len",
"(",
"mw",
")",
")",
"\n",
"for"... | // UnaryChain combines a series of `UnaryOutbound`s into a single `UnaryOutbound`. | [
"UnaryChain",
"combines",
"a",
"series",
"of",
"UnaryOutbound",
"s",
"into",
"a",
"single",
"UnaryOutbound",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/outboundmiddleware/chain.go#L32-L53 |
10,643 | yarpc/yarpc-go | internal/outboundmiddleware/chain.go | OnewayChain | func OnewayChain(mw ...middleware.OnewayOutbound) middleware.OnewayOutbound {
unchained := make([]middleware.OnewayOutbound, 0, len(mw))
for _, m := range mw {
if m == nil {
continue
}
if c, ok := m.(onewayChain); ok {
unchained = append(unchained, c...)
continue
}
unchained = append(unchained, m)
}
switch len(unchained) {
case 0:
return middleware.NopOnewayOutbound
case 1:
return unchained[0]
default:
return onewayChain(unchained)
}
} | go | func OnewayChain(mw ...middleware.OnewayOutbound) middleware.OnewayOutbound {
unchained := make([]middleware.OnewayOutbound, 0, len(mw))
for _, m := range mw {
if m == nil {
continue
}
if c, ok := m.(onewayChain); ok {
unchained = append(unchained, c...)
continue
}
unchained = append(unchained, m)
}
switch len(unchained) {
case 0:
return middleware.NopOnewayOutbound
case 1:
return unchained[0]
default:
return onewayChain(unchained)
}
} | [
"func",
"OnewayChain",
"(",
"mw",
"...",
"middleware",
".",
"OnewayOutbound",
")",
"middleware",
".",
"OnewayOutbound",
"{",
"unchained",
":=",
"make",
"(",
"[",
"]",
"middleware",
".",
"OnewayOutbound",
",",
"0",
",",
"len",
"(",
"mw",
")",
")",
"\n",
"... | // OnewayChain combines a series of `OnewayOutbound`s into a single `OnewayOutbound`. | [
"OnewayChain",
"combines",
"a",
"series",
"of",
"OnewayOutbound",
"s",
"into",
"a",
"single",
"OnewayOutbound",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/outboundmiddleware/chain.go#L104-L125 |
10,644 | yarpc/yarpc-go | internal/outboundmiddleware/chain.go | StreamChain | func StreamChain(mw ...middleware.StreamOutbound) middleware.StreamOutbound {
unchained := make([]middleware.StreamOutbound, 0, len(mw))
for _, m := range mw {
if m == nil {
continue
}
if c, ok := m.(streamChain); ok {
unchained = append(unchained, c...)
continue
}
unchained = append(unchained, m)
}
switch len(unchained) {
case 0:
return middleware.NopStreamOutbound
case 1:
return unchained[0]
default:
return streamChain(unchained)
}
} | go | func StreamChain(mw ...middleware.StreamOutbound) middleware.StreamOutbound {
unchained := make([]middleware.StreamOutbound, 0, len(mw))
for _, m := range mw {
if m == nil {
continue
}
if c, ok := m.(streamChain); ok {
unchained = append(unchained, c...)
continue
}
unchained = append(unchained, m)
}
switch len(unchained) {
case 0:
return middleware.NopStreamOutbound
case 1:
return unchained[0]
default:
return streamChain(unchained)
}
} | [
"func",
"StreamChain",
"(",
"mw",
"...",
"middleware",
".",
"StreamOutbound",
")",
"middleware",
".",
"StreamOutbound",
"{",
"unchained",
":=",
"make",
"(",
"[",
"]",
"middleware",
".",
"StreamOutbound",
",",
"0",
",",
"len",
"(",
"mw",
")",
")",
"\n",
"... | // StreamChain combines a series of `StreamOutbound`s into a single `StreamOutbound`. | [
"StreamChain",
"combines",
"a",
"series",
"of",
"StreamOutbound",
"s",
"into",
"a",
"single",
"StreamOutbound",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/outboundmiddleware/chain.go#L176-L197 |
10,645 | yarpc/yarpc-go | yarpcconfig/spec.go | validateConfigFunc | func validateConfigFunc(t reflect.Type, outputType reflect.Type) error {
switch {
case t.Kind() != reflect.Func:
return errors.New("must be a function")
case t.NumIn() != 3:
return fmt.Errorf("must accept exactly three arguments, found %v", t.NumIn())
case !isDecodable(t.In(0)):
return fmt.Errorf("must accept a struct or struct pointer as its first argument, found %v", t.In(0))
case t.In(1) != _typeOfTransport:
// TODO: We can make this smarter by making transport.Transport
// optional and either the first or the second argument instead of
// requiring it as the second argument.
return fmt.Errorf("must accept a transport.Transport as its second argument, found %v", t.In(1))
case t.In(2) != _typeOfKit:
return fmt.Errorf("must accept a %v as its third argument, found %v", _typeOfKit, t.In(2))
case t.NumOut() != 2:
return fmt.Errorf("must return exactly two results, found %v", t.NumOut())
case t.Out(0) != outputType:
return fmt.Errorf("must return a %v as its first result, found %v", outputType, t.Out(0))
case t.Out(1) != _typeOfError:
return fmt.Errorf("must return an error as its second result, found %v", t.Out(1))
}
return nil
} | go | func validateConfigFunc(t reflect.Type, outputType reflect.Type) error {
switch {
case t.Kind() != reflect.Func:
return errors.New("must be a function")
case t.NumIn() != 3:
return fmt.Errorf("must accept exactly three arguments, found %v", t.NumIn())
case !isDecodable(t.In(0)):
return fmt.Errorf("must accept a struct or struct pointer as its first argument, found %v", t.In(0))
case t.In(1) != _typeOfTransport:
// TODO: We can make this smarter by making transport.Transport
// optional and either the first or the second argument instead of
// requiring it as the second argument.
return fmt.Errorf("must accept a transport.Transport as its second argument, found %v", t.In(1))
case t.In(2) != _typeOfKit:
return fmt.Errorf("must accept a %v as its third argument, found %v", _typeOfKit, t.In(2))
case t.NumOut() != 2:
return fmt.Errorf("must return exactly two results, found %v", t.NumOut())
case t.Out(0) != outputType:
return fmt.Errorf("must return a %v as its first result, found %v", outputType, t.Out(0))
case t.Out(1) != _typeOfError:
return fmt.Errorf("must return an error as its second result, found %v", t.Out(1))
}
return nil
} | [
"func",
"validateConfigFunc",
"(",
"t",
"reflect",
".",
"Type",
",",
"outputType",
"reflect",
".",
"Type",
")",
"error",
"{",
"switch",
"{",
"case",
"t",
".",
"Kind",
"(",
")",
"!=",
"reflect",
".",
"Func",
":",
"return",
"errors",
".",
"New",
"(",
"... | // Common validation for all build functions except Tranport. | [
"Common",
"validation",
"for",
"all",
"build",
"functions",
"except",
"Tranport",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/yarpcconfig/spec.go#L440-L464 |
10,646 | yarpc/yarpc-go | yarpcconfig/spec.go | Build | func (c *compiledPeerChooserPreset) Build(t peer.Transport, k *Kit) (peer.Chooser, error) {
results := c.factory.Call([]reflect.Value{reflect.ValueOf(t), reflect.ValueOf(k)})
chooser, _ := results[0].Interface().(peer.Chooser)
err, _ := results[1].Interface().(error)
return chooser, err
} | go | func (c *compiledPeerChooserPreset) Build(t peer.Transport, k *Kit) (peer.Chooser, error) {
results := c.factory.Call([]reflect.Value{reflect.ValueOf(t), reflect.ValueOf(k)})
chooser, _ := results[0].Interface().(peer.Chooser)
err, _ := results[1].Interface().(error)
return chooser, err
} | [
"func",
"(",
"c",
"*",
"compiledPeerChooserPreset",
")",
"Build",
"(",
"t",
"peer",
".",
"Transport",
",",
"k",
"*",
"Kit",
")",
"(",
"peer",
".",
"Chooser",
",",
"error",
")",
"{",
"results",
":=",
"c",
".",
"factory",
".",
"Call",
"(",
"[",
"]",
... | // Build builds the peer.Chooser from the compiled peer chooser preset. | [
"Build",
"builds",
"the",
"peer",
".",
"Chooser",
"from",
"the",
"compiled",
"peer",
"chooser",
"preset",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/yarpcconfig/spec.go#L472-L477 |
10,647 | yarpc/yarpc-go | yarpcconfig/spec.go | Decode | func (cs *configSpec) Decode(attrs config.AttributeMap, opts ...mapdecode.Option) (*buildable, error) {
inputConfig := reflect.New(cs.inputType)
if err := attrs.Decode(inputConfig.Interface(), opts...); err != nil {
return nil, fmt.Errorf("failed to decode %v: %v", cs.inputType, err)
}
return &buildable{factory: cs.factory, inputData: inputConfig.Elem()}, nil
} | go | func (cs *configSpec) Decode(attrs config.AttributeMap, opts ...mapdecode.Option) (*buildable, error) {
inputConfig := reflect.New(cs.inputType)
if err := attrs.Decode(inputConfig.Interface(), opts...); err != nil {
return nil, fmt.Errorf("failed to decode %v: %v", cs.inputType, err)
}
return &buildable{factory: cs.factory, inputData: inputConfig.Elem()}, nil
} | [
"func",
"(",
"cs",
"*",
"configSpec",
")",
"Decode",
"(",
"attrs",
"config",
".",
"AttributeMap",
",",
"opts",
"...",
"mapdecode",
".",
"Option",
")",
"(",
"*",
"buildable",
",",
"error",
")",
"{",
"inputConfig",
":=",
"reflect",
".",
"New",
"(",
"cs",... | // Decode the configuration for this type from the data map. | [
"Decode",
"the",
"configuration",
"for",
"this",
"type",
"from",
"the",
"data",
"map",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/yarpcconfig/spec.go#L699-L705 |
10,648 | yarpc/yarpc-go | yarpcconfig/spec.go | Build | func (cv *buildable) Build(args ...interface{}) (interface{}, error) {
// This function roughly translates to,
//
// return factory(inputData, args...)
callArgs := make([]reflect.Value, len(args)+1)
callArgs[0] = cv.inputData
for i, v := range args {
if value, ok := v.(reflect.Value); ok {
callArgs[i+1] = value
} else {
callArgs[i+1] = reflect.ValueOf(v)
}
}
result := cv.factory.Call(callArgs)
err, _ := result[1].Interface().(error)
return result[0].Interface(), err
} | go | func (cv *buildable) Build(args ...interface{}) (interface{}, error) {
// This function roughly translates to,
//
// return factory(inputData, args...)
callArgs := make([]reflect.Value, len(args)+1)
callArgs[0] = cv.inputData
for i, v := range args {
if value, ok := v.(reflect.Value); ok {
callArgs[i+1] = value
} else {
callArgs[i+1] = reflect.ValueOf(v)
}
}
result := cv.factory.Call(callArgs)
err, _ := result[1].Interface().(error)
return result[0].Interface(), err
} | [
"func",
"(",
"cv",
"*",
"buildable",
")",
"Build",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"// This function roughly translates to,",
"//",
"// \treturn factory(inputData, args...)",
"callArgs",
":=",
"... | // Build the object configured by this value. The arguments are passed to the
// build function with the underlying configuration as the first parameter.
//
// Arguments may be reflect.Value objects or any other type. | [
"Build",
"the",
"object",
"configured",
"by",
"this",
"value",
".",
"The",
"arguments",
"are",
"passed",
"to",
"the",
"build",
"function",
"with",
"the",
"underlying",
"configuration",
"as",
"the",
"first",
"parameter",
".",
"Arguments",
"may",
"be",
"reflect"... | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/yarpcconfig/spec.go#L730-L749 |
10,649 | yarpc/yarpc-go | internal/introspection/router.go | IntrospectProcedures | func IntrospectProcedures(routerProcs []transport.Procedure) []Procedure {
procedures := make([]Procedure, 0, len(routerProcs))
for _, p := range routerProcs {
procedures = append(procedures, Procedure{
Name: p.Name,
Encoding: string(p.Encoding),
Signature: p.Signature,
RPCType: p.HandlerSpec.Type().String(),
})
}
return procedures
} | go | func IntrospectProcedures(routerProcs []transport.Procedure) []Procedure {
procedures := make([]Procedure, 0, len(routerProcs))
for _, p := range routerProcs {
procedures = append(procedures, Procedure{
Name: p.Name,
Encoding: string(p.Encoding),
Signature: p.Signature,
RPCType: p.HandlerSpec.Type().String(),
})
}
return procedures
} | [
"func",
"IntrospectProcedures",
"(",
"routerProcs",
"[",
"]",
"transport",
".",
"Procedure",
")",
"[",
"]",
"Procedure",
"{",
"procedures",
":=",
"make",
"(",
"[",
"]",
"Procedure",
",",
"0",
",",
"len",
"(",
"routerProcs",
")",
")",
"\n",
"for",
"_",
... | // IntrospectProcedures is a convenience function that translate a slice of
// transport.Procedure to a slice of introspection.Procedure. This output is
// used in debug and yarpcmeta. | [
"IntrospectProcedures",
"is",
"a",
"convenience",
"function",
"that",
"translate",
"a",
"slice",
"of",
"transport",
".",
"Procedure",
"to",
"a",
"slice",
"of",
"introspection",
".",
"Procedure",
".",
"This",
"output",
"is",
"used",
"in",
"debug",
"and",
"yarpc... | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/introspection/router.go#L38-L49 |
10,650 | yarpc/yarpc-go | api/transport/handler_invoker.go | InvokeUnaryHandler | func InvokeUnaryHandler(
i UnaryInvokeRequest,
) (err error) {
defer func() {
if r := recover(); r != nil {
err = handlePanic(Unary, i.Logger, r, i.Request.ToRequestMeta())
}
}()
err = i.Handler.Handle(i.Context, i.Request, i.ResponseWriter)
// The handler stopped work on context deadline.
if err == context.DeadlineExceeded && err == i.Context.Err() {
deadline, _ := i.Context.Deadline()
err = yarpcerrors.Newf(
yarpcerrors.CodeDeadlineExceeded,
"call to procedure %q of service %q from caller %q timed out after %v",
i.Request.Procedure, i.Request.Service, i.Request.Caller, deadline.Sub(i.StartTime))
}
return err
} | go | func InvokeUnaryHandler(
i UnaryInvokeRequest,
) (err error) {
defer func() {
if r := recover(); r != nil {
err = handlePanic(Unary, i.Logger, r, i.Request.ToRequestMeta())
}
}()
err = i.Handler.Handle(i.Context, i.Request, i.ResponseWriter)
// The handler stopped work on context deadline.
if err == context.DeadlineExceeded && err == i.Context.Err() {
deadline, _ := i.Context.Deadline()
err = yarpcerrors.Newf(
yarpcerrors.CodeDeadlineExceeded,
"call to procedure %q of service %q from caller %q timed out after %v",
i.Request.Procedure, i.Request.Service, i.Request.Caller, deadline.Sub(i.StartTime))
}
return err
} | [
"func",
"InvokeUnaryHandler",
"(",
"i",
"UnaryInvokeRequest",
",",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"if",
"r",
":=",
"recover",
"(",
")",
";",
"r",
"!=",
"nil",
"{",
"err",
"=",
"handlePanic",
"(",
"Unary",
",",
"... | // InvokeUnaryHandler calls the handler h, recovering panics and timeout errors,
// converting them to YARPC errors. All other errors are passed through. | [
"InvokeUnaryHandler",
"calls",
"the",
"handler",
"h",
"recovering",
"panics",
"and",
"timeout",
"errors",
"converting",
"them",
"to",
"YARPC",
"errors",
".",
"All",
"other",
"errors",
"are",
"passed",
"through",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/api/transport/handler_invoker.go#L61-L81 |
10,651 | yarpc/yarpc-go | api/transport/handler_invoker.go | InvokeOnewayHandler | func InvokeOnewayHandler(
i OnewayInvokeRequest,
) (err error) {
defer func() {
if r := recover(); r != nil {
err = handlePanic(Oneway, i.Logger, r, i.Request.ToRequestMeta())
}
}()
return i.Handler.HandleOneway(i.Context, i.Request)
} | go | func InvokeOnewayHandler(
i OnewayInvokeRequest,
) (err error) {
defer func() {
if r := recover(); r != nil {
err = handlePanic(Oneway, i.Logger, r, i.Request.ToRequestMeta())
}
}()
return i.Handler.HandleOneway(i.Context, i.Request)
} | [
"func",
"InvokeOnewayHandler",
"(",
"i",
"OnewayInvokeRequest",
",",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"if",
"r",
":=",
"recover",
"(",
")",
";",
"r",
"!=",
"nil",
"{",
"err",
"=",
"handlePanic",
"(",
"Oneway",
",",
... | // InvokeOnewayHandler calls the oneway handler, recovering from panics as
// errors. | [
"InvokeOnewayHandler",
"calls",
"the",
"oneway",
"handler",
"recovering",
"from",
"panics",
"as",
"errors",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/api/transport/handler_invoker.go#L85-L95 |
10,652 | yarpc/yarpc-go | api/transport/handler_invoker.go | InvokeStreamHandler | func InvokeStreamHandler(
i StreamInvokeRequest,
) (err error) {
defer func() {
if r := recover(); r != nil {
err = handlePanic(Streaming, i.Logger, r, i.Stream.Request().Meta)
}
}()
return i.Handler.HandleStream(i.Stream)
} | go | func InvokeStreamHandler(
i StreamInvokeRequest,
) (err error) {
defer func() {
if r := recover(); r != nil {
err = handlePanic(Streaming, i.Logger, r, i.Stream.Request().Meta)
}
}()
return i.Handler.HandleStream(i.Stream)
} | [
"func",
"InvokeStreamHandler",
"(",
"i",
"StreamInvokeRequest",
",",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"if",
"r",
":=",
"recover",
"(",
")",
";",
"r",
"!=",
"nil",
"{",
"err",
"=",
"handlePanic",
"(",
"Streaming",
",... | // InvokeStreamHandler calls the stream handler, recovering from panics as
// errors. | [
"InvokeStreamHandler",
"calls",
"the",
"stream",
"handler",
"recovering",
"from",
"panics",
"as",
"errors",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/api/transport/handler_invoker.go#L99-L109 |
10,653 | yarpc/yarpc-go | internal/crossdock/client/gauntlet/behavior.go | Run | func Run(t crossdock.T) {
fatals := crossdock.Fatals(t)
dispatcher := disp.Create(t)
fatals.NoError(dispatcher.Start(), "could not start Dispatcher")
defer dispatcher.Stop()
t.Tag("transport", t.Param(params.Transport))
t.Tag("server", t.Param(params.Server))
RunGauntlet(t, Config{
Dispatcher: dispatcher,
ServerName: serverName,
})
} | go | func Run(t crossdock.T) {
fatals := crossdock.Fatals(t)
dispatcher := disp.Create(t)
fatals.NoError(dispatcher.Start(), "could not start Dispatcher")
defer dispatcher.Stop()
t.Tag("transport", t.Param(params.Transport))
t.Tag("server", t.Param(params.Server))
RunGauntlet(t, Config{
Dispatcher: dispatcher,
ServerName: serverName,
})
} | [
"func",
"Run",
"(",
"t",
"crossdock",
".",
"T",
")",
"{",
"fatals",
":=",
"crossdock",
".",
"Fatals",
"(",
"t",
")",
"\n\n",
"dispatcher",
":=",
"disp",
".",
"Create",
"(",
"t",
")",
"\n",
"fatals",
".",
"NoError",
"(",
"dispatcher",
".",
"Start",
... | // Run executes the thriftgauntlet behavior. | [
"Run",
"executes",
"the",
"thriftgauntlet",
"behavior",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/client/gauntlet/behavior.go#L60-L73 |
10,654 | yarpc/yarpc-go | internal/crossdock/client/gauntlet/behavior.go | Assert | func Assert(t crossdock.T, tt TT, desc string, got interface{}, err error) {
checks := crossdock.Checks(t)
assert := crossdock.Assert(t)
if tt.WantError != nil || tt.WantErrorLike != "" {
if !checks.Error(err, "%v: expected failure but got: %v", desc, got) {
return
}
if tt.WantError != nil {
assert.Equal(tt.WantError, err, "%v: server returned error: %v", desc, err)
}
if tt.WantErrorLike != "" {
assert.Contains(err.Error(), tt.WantErrorLike, "%v: server returned error: %v", desc, err)
}
} else {
if !checks.NoError(err, "%v: call failed", desc) {
return
}
if tt.Want != nil {
assert.Equal(tt.Want, got, "%v: server returned: %v", desc, got)
}
}
} | go | func Assert(t crossdock.T, tt TT, desc string, got interface{}, err error) {
checks := crossdock.Checks(t)
assert := crossdock.Assert(t)
if tt.WantError != nil || tt.WantErrorLike != "" {
if !checks.Error(err, "%v: expected failure but got: %v", desc, got) {
return
}
if tt.WantError != nil {
assert.Equal(tt.WantError, err, "%v: server returned error: %v", desc, err)
}
if tt.WantErrorLike != "" {
assert.Contains(err.Error(), tt.WantErrorLike, "%v: server returned error: %v", desc, err)
}
} else {
if !checks.NoError(err, "%v: call failed", desc) {
return
}
if tt.Want != nil {
assert.Equal(tt.Want, got, "%v: server returned: %v", desc, got)
}
}
} | [
"func",
"Assert",
"(",
"t",
"crossdock",
".",
"T",
",",
"tt",
"TT",
",",
"desc",
"string",
",",
"got",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"{",
"checks",
":=",
"crossdock",
".",
"Checks",
"(",
"t",
")",
"\n",
"assert",
":=",
"crossdock... | // Assert verifies the call response against TT | [
"Assert",
"verifies",
"the",
"call",
"response",
"against",
"TT"
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/client/gauntlet/behavior.go#L558-L580 |
10,655 | yarpc/yarpc-go | internal/crossdock/client/grpc/grpc.go | Run | func Run(t crossdock.T) {
encoding := t.Param(params.Encoding)
f, ok := encodingToRunFunc[encoding]
if !ok {
crossdock.Fatals(t).Fail("unknown encoding", "%v", encoding)
}
f(t, "grpc")
} | go | func Run(t crossdock.T) {
encoding := t.Param(params.Encoding)
f, ok := encodingToRunFunc[encoding]
if !ok {
crossdock.Fatals(t).Fail("unknown encoding", "%v", encoding)
}
f(t, "grpc")
} | [
"func",
"Run",
"(",
"t",
"crossdock",
".",
"T",
")",
"{",
"encoding",
":=",
"t",
".",
"Param",
"(",
"params",
".",
"Encoding",
")",
"\n",
"f",
",",
"ok",
":=",
"encodingToRunFunc",
"[",
"encoding",
"]",
"\n",
"if",
"!",
"ok",
"{",
"crossdock",
".",... | // Run starts the grpc behavior, testing grpc over encodings. | [
"Run",
"starts",
"the",
"grpc",
"behavior",
"testing",
"grpc",
"over",
"encodings",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/client/grpc/grpc.go#L37-L44 |
10,656 | yarpc/yarpc-go | internal/request/validator_outbound.go | Call | func (o UnaryValidatorOutbound) Call(ctx context.Context, request *transport.Request) (*transport.Response, error) {
if err := transport.ValidateRequest(request); err != nil {
return nil, err
}
if err := transport.ValidateRequestContext(ctx); err != nil {
return nil, err
}
return o.UnaryOutbound.Call(ctx, request)
} | go | func (o UnaryValidatorOutbound) Call(ctx context.Context, request *transport.Request) (*transport.Response, error) {
if err := transport.ValidateRequest(request); err != nil {
return nil, err
}
if err := transport.ValidateRequestContext(ctx); err != nil {
return nil, err
}
return o.UnaryOutbound.Call(ctx, request)
} | [
"func",
"(",
"o",
"UnaryValidatorOutbound",
")",
"Call",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"transport",
".",
"Request",
")",
"(",
"*",
"transport",
".",
"Response",
",",
"error",
")",
"{",
"if",
"err",
":=",
"transport",
".",
... | // Call performs the given request, failing early if the request is invalid. | [
"Call",
"performs",
"the",
"given",
"request",
"failing",
"early",
"if",
"the",
"request",
"is",
"invalid",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/request/validator_outbound.go#L34-L44 |
10,657 | yarpc/yarpc-go | internal/request/validator_outbound.go | CallOneway | func (o OnewayValidatorOutbound) CallOneway(ctx context.Context, request *transport.Request) (transport.Ack, error) {
if err := transport.ValidateRequest(request); err != nil {
return nil, err
}
if err := transport.ValidateRequestContext(ctx); err != nil {
return nil, err
}
return o.OnewayOutbound.CallOneway(ctx, request)
} | go | func (o OnewayValidatorOutbound) CallOneway(ctx context.Context, request *transport.Request) (transport.Ack, error) {
if err := transport.ValidateRequest(request); err != nil {
return nil, err
}
if err := transport.ValidateRequestContext(ctx); err != nil {
return nil, err
}
return o.OnewayOutbound.CallOneway(ctx, request)
} | [
"func",
"(",
"o",
"OnewayValidatorOutbound",
")",
"CallOneway",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"transport",
".",
"Request",
")",
"(",
"transport",
".",
"Ack",
",",
"error",
")",
"{",
"if",
"err",
":=",
"transport",
".",
"Vali... | // CallOneway performs the given request, failing early if the request is invalid. | [
"CallOneway",
"performs",
"the",
"given",
"request",
"failing",
"early",
"if",
"the",
"request",
"is",
"invalid",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/request/validator_outbound.go#L58-L68 |
10,658 | yarpc/yarpc-go | internal/request/validator_outbound.go | CallStream | func (o StreamValidatorOutbound) CallStream(ctx context.Context, request *transport.StreamRequest) (*transport.ClientStream, error) {
if err := transport.ValidateRequest(request.Meta.ToRequest()); err != nil {
return nil, err
}
return o.StreamOutbound.CallStream(ctx, request)
} | go | func (o StreamValidatorOutbound) CallStream(ctx context.Context, request *transport.StreamRequest) (*transport.ClientStream, error) {
if err := transport.ValidateRequest(request.Meta.ToRequest()); err != nil {
return nil, err
}
return o.StreamOutbound.CallStream(ctx, request)
} | [
"func",
"(",
"o",
"StreamValidatorOutbound",
")",
"CallStream",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"transport",
".",
"StreamRequest",
")",
"(",
"*",
"transport",
".",
"ClientStream",
",",
"error",
")",
"{",
"if",
"err",
":=",
"tran... | // CallStream performs the given request, failing early if the request is invalid. | [
"CallStream",
"performs",
"the",
"given",
"request",
"failing",
"early",
"if",
"the",
"request",
"is",
"invalid",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/request/validator_outbound.go#L82-L88 |
10,659 | yarpc/yarpc-go | internal/interpolate/types.go | Render | func (s String) Render(resolve VariableResolver) (string, error) {
var buff bytes.Buffer
if err := s.RenderTo(&buff, resolve); err != nil {
return "", err
}
return buff.String(), nil
} | go | func (s String) Render(resolve VariableResolver) (string, error) {
var buff bytes.Buffer
if err := s.RenderTo(&buff, resolve); err != nil {
return "", err
}
return buff.String(), nil
} | [
"func",
"(",
"s",
"String",
")",
"Render",
"(",
"resolve",
"VariableResolver",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"buff",
"bytes",
".",
"Buffer",
"\n",
"if",
"err",
":=",
"s",
".",
"RenderTo",
"(",
"&",
"buff",
",",
"resolve",
")",
... | // Render renders and returns the string. The provided VariableResolver will
// be used to determine values for the different variables mentioned in the
// string. | [
"Render",
"renders",
"and",
"returns",
"the",
"string",
".",
"The",
"provided",
"VariableResolver",
"will",
"be",
"used",
"to",
"determine",
"values",
"for",
"the",
"different",
"variables",
"mentioned",
"in",
"the",
"string",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/interpolate/types.go#L65-L71 |
10,660 | yarpc/yarpc-go | internal/interpolate/types.go | RenderTo | func (s String) RenderTo(w io.Writer, resolve VariableResolver) error {
for _, term := range s {
var value string
switch t := term.(type) {
case literal:
value = string(t)
case variable:
if val, ok := resolve(t.Name); ok {
value = val
} else if t.HasDefault {
value = t.Default
} else {
return errUnknownVariable{Name: t.Name}
}
}
if _, err := io.WriteString(w, value); err != nil {
return err
}
}
return nil
} | go | func (s String) RenderTo(w io.Writer, resolve VariableResolver) error {
for _, term := range s {
var value string
switch t := term.(type) {
case literal:
value = string(t)
case variable:
if val, ok := resolve(t.Name); ok {
value = val
} else if t.HasDefault {
value = t.Default
} else {
return errUnknownVariable{Name: t.Name}
}
}
if _, err := io.WriteString(w, value); err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"s",
"String",
")",
"RenderTo",
"(",
"w",
"io",
".",
"Writer",
",",
"resolve",
"VariableResolver",
")",
"error",
"{",
"for",
"_",
",",
"term",
":=",
"range",
"s",
"{",
"var",
"value",
"string",
"\n",
"switch",
"t",
":=",
"term",
".",
"... | // RenderTo renders the string into the given writer. The provided
// VariableResolver will be used to determine values for the different
// variables mentioned in the string. | [
"RenderTo",
"renders",
"the",
"string",
"into",
"the",
"given",
"writer",
".",
"The",
"provided",
"VariableResolver",
"will",
"be",
"used",
"to",
"determine",
"values",
"for",
"the",
"different",
"variables",
"mentioned",
"in",
"the",
"string",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/interpolate/types.go#L76-L96 |
10,661 | yarpc/yarpc-go | internal/crossdock/internal/header.go | RemoveVariableMapKeys | func RemoveVariableMapKeys(headers map[string]string) {
delete(headers, "$tracing$uber-trace-id")
delete(headers, tchannel.ServiceHeaderKey)
} | go | func RemoveVariableMapKeys(headers map[string]string) {
delete(headers, "$tracing$uber-trace-id")
delete(headers, tchannel.ServiceHeaderKey)
} | [
"func",
"RemoveVariableMapKeys",
"(",
"headers",
"map",
"[",
"string",
"]",
"string",
")",
"{",
"delete",
"(",
"headers",
",",
"\"",
"\"",
")",
"\n",
"delete",
"(",
"headers",
",",
"tchannel",
".",
"ServiceHeaderKey",
")",
"\n",
"}"
] | // RemoveVariableMapKeys removes any headers that might have been added by tracing
// or server handler | [
"RemoveVariableMapKeys",
"removes",
"any",
"headers",
"that",
"might",
"have",
"been",
"added",
"by",
"tracing",
"or",
"server",
"handler"
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/internal/header.go#L27-L30 |
10,662 | yarpc/yarpc-go | internal/crossdock/client/onewayctxpropagation/behavior.go | Run | func Run(t crossdock.T) {
assert := crossdock.Assert(t)
fatals := crossdock.Fatals(t)
baggage := map[string]string{
"hello": "world",
"foo": "bar",
}
// create handler
callBackHandler, serverCalledBack := newCallBackHandler()
dispatcher, callBackAddr := dispatcher.CreateOnewayDispatcher(t, callBackHandler)
defer dispatcher.Stop()
client := raw.New(dispatcher.ClientConfig("oneway-server"))
// make call
ctx, cancel := context.WithTimeout(newContextWithBaggage(baggage), time.Second)
defer cancel()
ack, err := client.CallOneway(
ctx, "echo/raw", []byte{}, yarpc.WithHeader("callBackAddr", callBackAddr))
fatals.NoError(err, "call to oneway/raw failed: %v", err)
fatals.NotNil(ack, "ack is nil")
// wait for server to call us back
gotBaggage := <-serverCalledBack
assert.Equal(baggage, gotBaggage, "server baggage: %s", gotBaggage)
} | go | func Run(t crossdock.T) {
assert := crossdock.Assert(t)
fatals := crossdock.Fatals(t)
baggage := map[string]string{
"hello": "world",
"foo": "bar",
}
// create handler
callBackHandler, serverCalledBack := newCallBackHandler()
dispatcher, callBackAddr := dispatcher.CreateOnewayDispatcher(t, callBackHandler)
defer dispatcher.Stop()
client := raw.New(dispatcher.ClientConfig("oneway-server"))
// make call
ctx, cancel := context.WithTimeout(newContextWithBaggage(baggage), time.Second)
defer cancel()
ack, err := client.CallOneway(
ctx, "echo/raw", []byte{}, yarpc.WithHeader("callBackAddr", callBackAddr))
fatals.NoError(err, "call to oneway/raw failed: %v", err)
fatals.NotNil(ack, "ack is nil")
// wait for server to call us back
gotBaggage := <-serverCalledBack
assert.Equal(baggage, gotBaggage, "server baggage: %s", gotBaggage)
} | [
"func",
"Run",
"(",
"t",
"crossdock",
".",
"T",
")",
"{",
"assert",
":=",
"crossdock",
".",
"Assert",
"(",
"t",
")",
"\n",
"fatals",
":=",
"crossdock",
".",
"Fatals",
"(",
"t",
")",
"\n\n",
"baggage",
":=",
"map",
"[",
"string",
"]",
"string",
"{",... | // Run starts the behavior, testing oneway context propagation | [
"Run",
"starts",
"the",
"behavior",
"testing",
"oneway",
"context",
"propagation"
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/client/onewayctxpropagation/behavior.go#L35-L63 |
10,663 | yarpc/yarpc-go | internal/crossdock/client/onewayctxpropagation/behavior.go | newCallBackHandler | func newCallBackHandler() (raw.OnewayHandler, <-chan map[string]string) {
serverCalledBack := make(chan map[string]string)
return func(ctx context.Context, body []byte) error {
serverCalledBack <- extractBaggage(ctx)
return nil
}, serverCalledBack
} | go | func newCallBackHandler() (raw.OnewayHandler, <-chan map[string]string) {
serverCalledBack := make(chan map[string]string)
return func(ctx context.Context, body []byte) error {
serverCalledBack <- extractBaggage(ctx)
return nil
}, serverCalledBack
} | [
"func",
"newCallBackHandler",
"(",
")",
"(",
"raw",
".",
"OnewayHandler",
",",
"<-",
"chan",
"map",
"[",
"string",
"]",
"string",
")",
"{",
"serverCalledBack",
":=",
"make",
"(",
"chan",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"return",
"func",
... | // newCallBackHandler creates a oneway handler that fills a channel
// with the received body | [
"newCallBackHandler",
"creates",
"a",
"oneway",
"handler",
"that",
"fills",
"a",
"channel",
"with",
"the",
"received",
"body"
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/client/onewayctxpropagation/behavior.go#L67-L73 |
10,664 | yarpc/yarpc-go | peer/roundrobin/peerring.go | Add | func (pr *peerRing) Add(p peer.StatusPeer, _ peer.Identifier) peer.Subscriber {
sub := &subscriber{peer: p}
newNode := ring.New(1)
newNode.Value = sub
sub.node = newNode
if pr.nextNode == nil {
// Empty ring, add the first node
pr.nextNode = newNode
} else {
// Push the node to the ring
pushBeforeNode(pr.nextNode, newNode)
}
return sub
} | go | func (pr *peerRing) Add(p peer.StatusPeer, _ peer.Identifier) peer.Subscriber {
sub := &subscriber{peer: p}
newNode := ring.New(1)
newNode.Value = sub
sub.node = newNode
if pr.nextNode == nil {
// Empty ring, add the first node
pr.nextNode = newNode
} else {
// Push the node to the ring
pushBeforeNode(pr.nextNode, newNode)
}
return sub
} | [
"func",
"(",
"pr",
"*",
"peerRing",
")",
"Add",
"(",
"p",
"peer",
".",
"StatusPeer",
",",
"_",
"peer",
".",
"Identifier",
")",
"peer",
".",
"Subscriber",
"{",
"sub",
":=",
"&",
"subscriber",
"{",
"peer",
":",
"p",
"}",
"\n",
"newNode",
":=",
"ring"... | // Add a peer.StatusPeer to the end of the peerRing, if the ring is empty it
// initializes the nextNode marker | [
"Add",
"a",
"peer",
".",
"StatusPeer",
"to",
"the",
"end",
"of",
"the",
"peerRing",
"if",
"the",
"ring",
"is",
"empty",
"it",
"initializes",
"the",
"nextNode",
"marker"
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/peer/roundrobin/peerring.go#L56-L70 |
10,665 | yarpc/yarpc-go | peer/roundrobin/peerring.go | Remove | func (pr *peerRing) Remove(p peer.StatusPeer, _ peer.Identifier, s peer.Subscriber) {
sub, ok := s.(*subscriber)
if !ok {
// Don't panic.
return
}
node := sub.node
if isLastRingNode(node) {
pr.nextNode = nil
} else {
if pr.isNextNode(node) {
pr.nextNode = pr.nextNode.Next()
}
popNodeFromRing(node)
}
} | go | func (pr *peerRing) Remove(p peer.StatusPeer, _ peer.Identifier, s peer.Subscriber) {
sub, ok := s.(*subscriber)
if !ok {
// Don't panic.
return
}
node := sub.node
if isLastRingNode(node) {
pr.nextNode = nil
} else {
if pr.isNextNode(node) {
pr.nextNode = pr.nextNode.Next()
}
popNodeFromRing(node)
}
} | [
"func",
"(",
"pr",
"*",
"peerRing",
")",
"Remove",
"(",
"p",
"peer",
".",
"StatusPeer",
",",
"_",
"peer",
".",
"Identifier",
",",
"s",
"peer",
".",
"Subscriber",
")",
"{",
"sub",
",",
"ok",
":=",
"s",
".",
"(",
"*",
"subscriber",
")",
"\n",
"if",... | // Remove the peer from the ring. Use the subscriber to address the node of the
// ring directly. | [
"Remove",
"the",
"peer",
"from",
"the",
"ring",
".",
"Use",
"the",
"subscriber",
"to",
"address",
"the",
"node",
"of",
"the",
"ring",
"directly",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/peer/roundrobin/peerring.go#L74-L90 |
10,666 | yarpc/yarpc-go | peer/roundrobin/peerring.go | Choose | func (pr *peerRing) Choose(_ context.Context, _ *transport.Request) peer.StatusPeer {
if pr.nextNode == nil {
return nil
}
p := getPeerForRingNode(pr.nextNode)
pr.nextNode = pr.nextNode.Next()
return p
} | go | func (pr *peerRing) Choose(_ context.Context, _ *transport.Request) peer.StatusPeer {
if pr.nextNode == nil {
return nil
}
p := getPeerForRingNode(pr.nextNode)
pr.nextNode = pr.nextNode.Next()
return p
} | [
"func",
"(",
"pr",
"*",
"peerRing",
")",
"Choose",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"*",
"transport",
".",
"Request",
")",
"peer",
".",
"StatusPeer",
"{",
"if",
"pr",
".",
"nextNode",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\... | // Choose returns the next peer in the ring, or nil if there is no peer in the ring
// after it has the next peer, it increments the nextPeer marker in the ring | [
"Choose",
"returns",
"the",
"next",
"peer",
"in",
"the",
"ring",
"or",
"nil",
"if",
"there",
"is",
"no",
"peer",
"in",
"the",
"ring",
"after",
"it",
"has",
"the",
"next",
"peer",
"it",
"increments",
"the",
"nextPeer",
"marker",
"in",
"the",
"ring"
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/peer/roundrobin/peerring.go#L98-L107 |
10,667 | yarpc/yarpc-go | transport/http/ttl.go | parseTTL | func parseTTL(ctx context.Context, req *transport.Request, ttl string) (_ context.Context, cancel func(), _ error) {
if ttl == "" {
return ctx, func() {}, nil
}
ttlms, err := strconv.Atoi(ttl)
if err != nil {
return ctx, func() {}, newInvalidTTLError(
req.Service,
req.Procedure,
ttl,
)
}
// negative TTLs are invalid
if ttlms < 0 {
return ctx, func() {}, newInvalidTTLError(
req.Service,
req.Procedure,
fmt.Sprint(ttlms),
)
}
ctx, cancel = context.WithTimeout(ctx, time.Duration(ttlms)*time.Millisecond)
return ctx, cancel, nil
} | go | func parseTTL(ctx context.Context, req *transport.Request, ttl string) (_ context.Context, cancel func(), _ error) {
if ttl == "" {
return ctx, func() {}, nil
}
ttlms, err := strconv.Atoi(ttl)
if err != nil {
return ctx, func() {}, newInvalidTTLError(
req.Service,
req.Procedure,
ttl,
)
}
// negative TTLs are invalid
if ttlms < 0 {
return ctx, func() {}, newInvalidTTLError(
req.Service,
req.Procedure,
fmt.Sprint(ttlms),
)
}
ctx, cancel = context.WithTimeout(ctx, time.Duration(ttlms)*time.Millisecond)
return ctx, cancel, nil
} | [
"func",
"parseTTL",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"transport",
".",
"Request",
",",
"ttl",
"string",
")",
"(",
"_",
"context",
".",
"Context",
",",
"cancel",
"func",
"(",
")",
",",
"_",
"error",
")",
"{",
"if",
"ttl",
"=="... | // parseTTL takes a context parses the given TTL, clamping the context to that
// TTL and as a side-effect, tracking any errors encountered while attempting
// to parse and validate that TTL.
//
// Leaves the context unchanged if the TTL is empty. | [
"parseTTL",
"takes",
"a",
"context",
"parses",
"the",
"given",
"TTL",
"clamping",
"the",
"context",
"to",
"that",
"TTL",
"and",
"as",
"a",
"side",
"-",
"effect",
"tracking",
"any",
"errors",
"encountered",
"while",
"attempting",
"to",
"parse",
"and",
"valida... | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/transport/http/ttl.go#L38-L63 |
10,668 | yarpc/yarpc-go | peer/single.go | NewSingle | func NewSingle(pid peer.Identifier, transport peer.Transport) *Single {
s := &Single{
once: lifecycle.NewOnce(),
pid: pid,
t: transport,
}
s.boundOnFinish = s.onFinish
return s
} | go | func NewSingle(pid peer.Identifier, transport peer.Transport) *Single {
s := &Single{
once: lifecycle.NewOnce(),
pid: pid,
t: transport,
}
s.boundOnFinish = s.onFinish
return s
} | [
"func",
"NewSingle",
"(",
"pid",
"peer",
".",
"Identifier",
",",
"transport",
"peer",
".",
"Transport",
")",
"*",
"Single",
"{",
"s",
":=",
"&",
"Single",
"{",
"once",
":",
"lifecycle",
".",
"NewOnce",
"(",
")",
",",
"pid",
":",
"pid",
",",
"t",
":... | // NewSingle creates a static Chooser with a single Peer | [
"NewSingle",
"creates",
"a",
"static",
"Chooser",
"with",
"a",
"single",
"Peer"
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/peer/single.go#L44-L52 |
10,669 | yarpc/yarpc-go | peer/single.go | Choose | func (s *Single) Choose(ctx context.Context, _ *transport.Request) (peer.Peer, func(error), error) {
if err := s.once.WaitUntilRunning(ctx); err != nil {
return nil, nil, err
}
s.p.StartRequest()
return s.p, s.boundOnFinish, s.err
} | go | func (s *Single) Choose(ctx context.Context, _ *transport.Request) (peer.Peer, func(error), error) {
if err := s.once.WaitUntilRunning(ctx); err != nil {
return nil, nil, err
}
s.p.StartRequest()
return s.p, s.boundOnFinish, s.err
} | [
"func",
"(",
"s",
"*",
"Single",
")",
"Choose",
"(",
"ctx",
"context",
".",
"Context",
",",
"_",
"*",
"transport",
".",
"Request",
")",
"(",
"peer",
".",
"Peer",
",",
"func",
"(",
"error",
")",
",",
"error",
")",
"{",
"if",
"err",
":=",
"s",
".... | // Choose returns the single peer | [
"Choose",
"returns",
"the",
"single",
"peer"
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/peer/single.go#L60-L66 |
10,670 | yarpc/yarpc-go | peer/single.go | Introspect | func (s *Single) Introspect() introspection.ChooserStatus {
if !s.once.IsRunning() {
return introspection.ChooserStatus{
Name: "Single",
Peers: []introspection.PeerStatus{
{
Identifier: s.pid.Identifier(),
State: "uninitialized",
},
},
}
}
peerStatus := s.p.Status()
peer := introspection.PeerStatus{
Identifier: s.p.Identifier(),
State: fmt.Sprintf("%s, %d pending request(s)",
peerStatus.ConnectionStatus.String(),
peerStatus.PendingRequestCount),
}
return introspection.ChooserStatus{
Name: "Single",
Peers: []introspection.PeerStatus{peer},
}
} | go | func (s *Single) Introspect() introspection.ChooserStatus {
if !s.once.IsRunning() {
return introspection.ChooserStatus{
Name: "Single",
Peers: []introspection.PeerStatus{
{
Identifier: s.pid.Identifier(),
State: "uninitialized",
},
},
}
}
peerStatus := s.p.Status()
peer := introspection.PeerStatus{
Identifier: s.p.Identifier(),
State: fmt.Sprintf("%s, %d pending request(s)",
peerStatus.ConnectionStatus.String(),
peerStatus.PendingRequestCount),
}
return introspection.ChooserStatus{
Name: "Single",
Peers: []introspection.PeerStatus{peer},
}
} | [
"func",
"(",
"s",
"*",
"Single",
")",
"Introspect",
"(",
")",
"introspection",
".",
"ChooserStatus",
"{",
"if",
"!",
"s",
".",
"once",
".",
"IsRunning",
"(",
")",
"{",
"return",
"introspection",
".",
"ChooserStatus",
"{",
"Name",
":",
"\"",
"\"",
",",
... | // Introspect returns a ChooserStatus with a single PeerStatus. | [
"Introspect",
"returns",
"a",
"ChooserStatus",
"with",
"a",
"single",
"PeerStatus",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/peer/single.go#L104-L129 |
10,671 | yarpc/yarpc-go | dispatcher.go | NewDispatcher | func NewDispatcher(cfg Config) *Dispatcher {
if cfg.Name == "" {
panic("yarpc.NewDispatcher expects a service name")
}
if err := internal.ValidateServiceName(cfg.Name); err != nil {
panic("yarpc.NewDispatcher expects a valid service name: " + err.Error())
}
logger := cfg.Logging.logger(cfg.Name)
extractor := cfg.Logging.extractor()
meter, stopMeter := cfg.Metrics.scope(cfg.Name, logger)
cfg = addObservingMiddleware(cfg, meter, logger, extractor)
return &Dispatcher{
name: cfg.Name,
table: middleware.ApplyRouteTable(NewMapRouter(cfg.Name), cfg.RouterMiddleware),
inbounds: cfg.Inbounds,
outbounds: convertOutbounds(cfg.Outbounds, cfg.OutboundMiddleware),
transports: collectTransports(cfg.Inbounds, cfg.Outbounds),
inboundMiddleware: cfg.InboundMiddleware,
log: logger,
meter: meter,
stopMeter: stopMeter,
once: lifecycle.NewOnce(),
}
} | go | func NewDispatcher(cfg Config) *Dispatcher {
if cfg.Name == "" {
panic("yarpc.NewDispatcher expects a service name")
}
if err := internal.ValidateServiceName(cfg.Name); err != nil {
panic("yarpc.NewDispatcher expects a valid service name: " + err.Error())
}
logger := cfg.Logging.logger(cfg.Name)
extractor := cfg.Logging.extractor()
meter, stopMeter := cfg.Metrics.scope(cfg.Name, logger)
cfg = addObservingMiddleware(cfg, meter, logger, extractor)
return &Dispatcher{
name: cfg.Name,
table: middleware.ApplyRouteTable(NewMapRouter(cfg.Name), cfg.RouterMiddleware),
inbounds: cfg.Inbounds,
outbounds: convertOutbounds(cfg.Outbounds, cfg.OutboundMiddleware),
transports: collectTransports(cfg.Inbounds, cfg.Outbounds),
inboundMiddleware: cfg.InboundMiddleware,
log: logger,
meter: meter,
stopMeter: stopMeter,
once: lifecycle.NewOnce(),
}
} | [
"func",
"NewDispatcher",
"(",
"cfg",
"Config",
")",
"*",
"Dispatcher",
"{",
"if",
"cfg",
".",
"Name",
"==",
"\"",
"\"",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"err",
":=",
"internal",
".",
"ValidateServiceName",
"(",
"cfg",
".",
... | // NewDispatcher builds a new Dispatcher using the specified Config. At
// minimum, a service name must be specified.
//
// Invalid configurations or errors in constructing the Dispatcher will cause
// panics. | [
"NewDispatcher",
"builds",
"a",
"new",
"Dispatcher",
"using",
"the",
"specified",
"Config",
".",
"At",
"minimum",
"a",
"service",
"name",
"must",
"be",
"specified",
".",
"Invalid",
"configurations",
"or",
"errors",
"in",
"constructing",
"the",
"Dispatcher",
"wil... | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/dispatcher.go#L70-L96 |
10,672 | yarpc/yarpc-go | dispatcher.go | convertOutbounds | func convertOutbounds(outbounds Outbounds, mw OutboundMiddleware) Outbounds {
outboundSpecs := make(Outbounds, len(outbounds))
for outboundKey, outs := range outbounds {
if outs.Unary == nil && outs.Oneway == nil && outs.Stream == nil {
panic(fmt.Sprintf("no outbound set for outbound key %q in dispatcher", outboundKey))
}
var (
unaryOutbound transport.UnaryOutbound
onewayOutbound transport.OnewayOutbound
streamOutbound transport.StreamOutbound
)
serviceName := outboundKey
// apply outbound middleware and create ValidatorOutbounds
if outs.Unary != nil {
unaryOutbound = middleware.ApplyUnaryOutbound(outs.Unary, mw.Unary)
unaryOutbound = request.UnaryValidatorOutbound{UnaryOutbound: unaryOutbound}
}
if outs.Oneway != nil {
onewayOutbound = middleware.ApplyOnewayOutbound(outs.Oneway, mw.Oneway)
onewayOutbound = request.OnewayValidatorOutbound{OnewayOutbound: onewayOutbound}
}
if outs.Stream != nil {
streamOutbound = middleware.ApplyStreamOutbound(outs.Stream, mw.Stream)
streamOutbound = request.StreamValidatorOutbound{StreamOutbound: streamOutbound}
}
if outs.ServiceName != "" {
serviceName = outs.ServiceName
}
outboundSpecs[outboundKey] = transport.Outbounds{
ServiceName: serviceName,
Unary: unaryOutbound,
Oneway: onewayOutbound,
Stream: streamOutbound,
}
}
return outboundSpecs
} | go | func convertOutbounds(outbounds Outbounds, mw OutboundMiddleware) Outbounds {
outboundSpecs := make(Outbounds, len(outbounds))
for outboundKey, outs := range outbounds {
if outs.Unary == nil && outs.Oneway == nil && outs.Stream == nil {
panic(fmt.Sprintf("no outbound set for outbound key %q in dispatcher", outboundKey))
}
var (
unaryOutbound transport.UnaryOutbound
onewayOutbound transport.OnewayOutbound
streamOutbound transport.StreamOutbound
)
serviceName := outboundKey
// apply outbound middleware and create ValidatorOutbounds
if outs.Unary != nil {
unaryOutbound = middleware.ApplyUnaryOutbound(outs.Unary, mw.Unary)
unaryOutbound = request.UnaryValidatorOutbound{UnaryOutbound: unaryOutbound}
}
if outs.Oneway != nil {
onewayOutbound = middleware.ApplyOnewayOutbound(outs.Oneway, mw.Oneway)
onewayOutbound = request.OnewayValidatorOutbound{OnewayOutbound: onewayOutbound}
}
if outs.Stream != nil {
streamOutbound = middleware.ApplyStreamOutbound(outs.Stream, mw.Stream)
streamOutbound = request.StreamValidatorOutbound{StreamOutbound: streamOutbound}
}
if outs.ServiceName != "" {
serviceName = outs.ServiceName
}
outboundSpecs[outboundKey] = transport.Outbounds{
ServiceName: serviceName,
Unary: unaryOutbound,
Oneway: onewayOutbound,
Stream: streamOutbound,
}
}
return outboundSpecs
} | [
"func",
"convertOutbounds",
"(",
"outbounds",
"Outbounds",
",",
"mw",
"OutboundMiddleware",
")",
"Outbounds",
"{",
"outboundSpecs",
":=",
"make",
"(",
"Outbounds",
",",
"len",
"(",
"outbounds",
")",
")",
"\n\n",
"for",
"outboundKey",
",",
"outs",
":=",
"range"... | // convertOutbounds applies outbound middleware and creates validator outbounds | [
"convertOutbounds",
"applies",
"outbound",
"middleware",
"and",
"creates",
"validator",
"outbounds"
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/dispatcher.go#L122-L166 |
10,673 | yarpc/yarpc-go | dispatcher.go | collectTransports | func collectTransports(inbounds Inbounds, outbounds Outbounds) []transport.Transport {
// Collect all unique transports from inbounds and outbounds.
transports := make(map[transport.Transport]struct{})
for _, inbound := range inbounds {
for _, transport := range inbound.Transports() {
transports[transport] = struct{}{}
}
}
for _, outbound := range outbounds {
if unary := outbound.Unary; unary != nil {
for _, transport := range unary.Transports() {
transports[transport] = struct{}{}
}
}
if oneway := outbound.Oneway; oneway != nil {
for _, transport := range oneway.Transports() {
transports[transport] = struct{}{}
}
}
if stream := outbound.Stream; stream != nil {
for _, transport := range stream.Transports() {
transports[transport] = struct{}{}
}
}
}
keys := make([]transport.Transport, 0, len(transports))
for key := range transports {
keys = append(keys, key)
}
return keys
} | go | func collectTransports(inbounds Inbounds, outbounds Outbounds) []transport.Transport {
// Collect all unique transports from inbounds and outbounds.
transports := make(map[transport.Transport]struct{})
for _, inbound := range inbounds {
for _, transport := range inbound.Transports() {
transports[transport] = struct{}{}
}
}
for _, outbound := range outbounds {
if unary := outbound.Unary; unary != nil {
for _, transport := range unary.Transports() {
transports[transport] = struct{}{}
}
}
if oneway := outbound.Oneway; oneway != nil {
for _, transport := range oneway.Transports() {
transports[transport] = struct{}{}
}
}
if stream := outbound.Stream; stream != nil {
for _, transport := range stream.Transports() {
transports[transport] = struct{}{}
}
}
}
keys := make([]transport.Transport, 0, len(transports))
for key := range transports {
keys = append(keys, key)
}
return keys
} | [
"func",
"collectTransports",
"(",
"inbounds",
"Inbounds",
",",
"outbounds",
"Outbounds",
")",
"[",
"]",
"transport",
".",
"Transport",
"{",
"// Collect all unique transports from inbounds and outbounds.",
"transports",
":=",
"make",
"(",
"map",
"[",
"transport",
".",
... | // collectTransports iterates over all inbounds and outbounds and collects all
// of their unique underlying transports. Multiple inbounds and outbounds may
// share a transport, and we only want the dispatcher to manage their lifecycle
// once. | [
"collectTransports",
"iterates",
"over",
"all",
"inbounds",
"and",
"outbounds",
"and",
"collects",
"all",
"of",
"their",
"unique",
"underlying",
"transports",
".",
"Multiple",
"inbounds",
"and",
"outbounds",
"may",
"share",
"a",
"transport",
"and",
"we",
"only",
... | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/dispatcher.go#L172-L202 |
10,674 | yarpc/yarpc-go | dispatcher.go | Inbounds | func (d *Dispatcher) Inbounds() Inbounds {
inbounds := make(Inbounds, len(d.inbounds))
copy(inbounds, d.inbounds)
return inbounds
} | go | func (d *Dispatcher) Inbounds() Inbounds {
inbounds := make(Inbounds, len(d.inbounds))
copy(inbounds, d.inbounds)
return inbounds
} | [
"func",
"(",
"d",
"*",
"Dispatcher",
")",
"Inbounds",
"(",
")",
"Inbounds",
"{",
"inbounds",
":=",
"make",
"(",
"Inbounds",
",",
"len",
"(",
"d",
".",
"inbounds",
")",
")",
"\n",
"copy",
"(",
"inbounds",
",",
"d",
".",
"inbounds",
")",
"\n",
"retur... | // Inbounds returns a copy of the list of inbounds for this RPC object.
//
// The Inbounds will be returned in the same order that was used in the
// configuration. | [
"Inbounds",
"returns",
"a",
"copy",
"of",
"the",
"list",
"of",
"inbounds",
"for",
"this",
"RPC",
"object",
".",
"The",
"Inbounds",
"will",
"be",
"returned",
"in",
"the",
"same",
"order",
"that",
"was",
"used",
"in",
"the",
"configuration",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/dispatcher.go#L226-L230 |
10,675 | yarpc/yarpc-go | dispatcher.go | Outbounds | func (d *Dispatcher) Outbounds() Outbounds {
outbounds := make(Outbounds, len(d.outbounds))
for k, v := range d.outbounds {
outbounds[k] = v
}
return outbounds
} | go | func (d *Dispatcher) Outbounds() Outbounds {
outbounds := make(Outbounds, len(d.outbounds))
for k, v := range d.outbounds {
outbounds[k] = v
}
return outbounds
} | [
"func",
"(",
"d",
"*",
"Dispatcher",
")",
"Outbounds",
"(",
")",
"Outbounds",
"{",
"outbounds",
":=",
"make",
"(",
"Outbounds",
",",
"len",
"(",
"d",
".",
"outbounds",
")",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"d",
".",
"outbounds",
"{",... | // Outbounds returns a copy of the list of outbounds for this RPC object. | [
"Outbounds",
"returns",
"a",
"copy",
"of",
"the",
"list",
"of",
"outbounds",
"for",
"this",
"RPC",
"object",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/dispatcher.go#L233-L239 |
10,676 | yarpc/yarpc-go | dispatcher.go | Register | func (d *Dispatcher) Register(rs []transport.Procedure) {
procedures := make([]transport.Procedure, 0, len(rs))
for _, r := range rs {
switch r.HandlerSpec.Type() {
case transport.Unary:
h := middleware.ApplyUnaryInbound(r.HandlerSpec.Unary(),
d.inboundMiddleware.Unary)
r.HandlerSpec = transport.NewUnaryHandlerSpec(h)
case transport.Oneway:
h := middleware.ApplyOnewayInbound(r.HandlerSpec.Oneway(),
d.inboundMiddleware.Oneway)
r.HandlerSpec = transport.NewOnewayHandlerSpec(h)
case transport.Streaming:
h := middleware.ApplyStreamInbound(r.HandlerSpec.Stream(),
d.inboundMiddleware.Stream)
r.HandlerSpec = transport.NewStreamHandlerSpec(h)
default:
panic(fmt.Sprintf("unknown handler type %q for service %q, procedure %q",
r.HandlerSpec.Type(), r.Service, r.Name))
}
procedures = append(procedures, r)
d.log.Info("Registration succeeded.", zap.Object("registeredProcedure", r))
}
d.table.Register(procedures)
} | go | func (d *Dispatcher) Register(rs []transport.Procedure) {
procedures := make([]transport.Procedure, 0, len(rs))
for _, r := range rs {
switch r.HandlerSpec.Type() {
case transport.Unary:
h := middleware.ApplyUnaryInbound(r.HandlerSpec.Unary(),
d.inboundMiddleware.Unary)
r.HandlerSpec = transport.NewUnaryHandlerSpec(h)
case transport.Oneway:
h := middleware.ApplyOnewayInbound(r.HandlerSpec.Oneway(),
d.inboundMiddleware.Oneway)
r.HandlerSpec = transport.NewOnewayHandlerSpec(h)
case transport.Streaming:
h := middleware.ApplyStreamInbound(r.HandlerSpec.Stream(),
d.inboundMiddleware.Stream)
r.HandlerSpec = transport.NewStreamHandlerSpec(h)
default:
panic(fmt.Sprintf("unknown handler type %q for service %q, procedure %q",
r.HandlerSpec.Type(), r.Service, r.Name))
}
procedures = append(procedures, r)
d.log.Info("Registration succeeded.", zap.Object("registeredProcedure", r))
}
d.table.Register(procedures)
} | [
"func",
"(",
"d",
"*",
"Dispatcher",
")",
"Register",
"(",
"rs",
"[",
"]",
"transport",
".",
"Procedure",
")",
"{",
"procedures",
":=",
"make",
"(",
"[",
"]",
"transport",
".",
"Procedure",
",",
"0",
",",
"len",
"(",
"rs",
")",
")",
"\n\n",
"for",
... | // Register registers zero or more procedures with this dispatcher. Incoming
// requests to these procedures will be routed to the handlers specified in
// the given Procedures. | [
"Register",
"registers",
"zero",
"or",
"more",
"procedures",
"with",
"this",
"dispatcher",
".",
"Incoming",
"requests",
"to",
"these",
"procedures",
"will",
"be",
"routed",
"to",
"the",
"handlers",
"specified",
"in",
"the",
"given",
"Procedures",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/dispatcher.go#L295-L322 |
10,677 | yarpc/yarpc-go | dispatcher.go | Stop | func (d *Dispatcher) Stop() error {
stopper := &PhasedStopper{
dispatcher: d,
log: d.log,
}
return d.once.Stop(func() error {
d.log.Info("shutting down dispatcher")
return multierr.Combine(
stopper.StopInbounds(),
stopper.StopOutbounds(),
stopper.StopTransports(),
)
})
} | go | func (d *Dispatcher) Stop() error {
stopper := &PhasedStopper{
dispatcher: d,
log: d.log,
}
return d.once.Stop(func() error {
d.log.Info("shutting down dispatcher")
return multierr.Combine(
stopper.StopInbounds(),
stopper.StopOutbounds(),
stopper.StopTransports(),
)
})
} | [
"func",
"(",
"d",
"*",
"Dispatcher",
")",
"Stop",
"(",
")",
"error",
"{",
"stopper",
":=",
"&",
"PhasedStopper",
"{",
"dispatcher",
":",
"d",
",",
"log",
":",
"d",
".",
"log",
",",
"}",
"\n",
"return",
"d",
".",
"once",
".",
"Stop",
"(",
"func",
... | // Stop stops the Dispatcher, shutting down all inbounds, outbounds, and
// transports. This function returns after everything has been stopped.
//
// Stop and PhasedStop are mutually exclusive. See the PhasedStop
// documentation for details. | [
"Stop",
"stops",
"the",
"Dispatcher",
"shutting",
"down",
"all",
"inbounds",
"outbounds",
"and",
"transports",
".",
"This",
"function",
"returns",
"after",
"everything",
"has",
"been",
"stopped",
".",
"Stop",
"and",
"PhasedStop",
"are",
"mutually",
"exclusive",
... | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/dispatcher.go#L391-L404 |
10,678 | yarpc/yarpc-go | internal/crossdock/thrift/echo/types.go | String | func (v *Ping) String() string {
if v == nil {
return "<nil>"
}
var fields [1]string
i := 0
fields[i] = fmt.Sprintf("Beep: %v", v.Beep)
i++
return fmt.Sprintf("Ping{%v}", strings.Join(fields[:i], ", "))
} | go | func (v *Ping) String() string {
if v == nil {
return "<nil>"
}
var fields [1]string
i := 0
fields[i] = fmt.Sprintf("Beep: %v", v.Beep)
i++
return fmt.Sprintf("Ping{%v}", strings.Join(fields[:i], ", "))
} | [
"func",
"(",
"v",
"*",
"Ping",
")",
"String",
"(",
")",
"string",
"{",
"if",
"v",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"var",
"fields",
"[",
"1",
"]",
"string",
"\n",
"i",
":=",
"0",
"\n",
"fields",
"[",
"i",
"]",
"=",
... | // String returns a readable string representation of a Ping
// struct. | [
"String",
"returns",
"a",
"readable",
"string",
"representation",
"of",
"a",
"Ping",
"struct",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/thrift/echo/types.go#L115-L126 |
10,679 | yarpc/yarpc-go | internal/crossdock/thrift/echo/types.go | Equals | func (v *Ping) Equals(rhs *Ping) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
if !(v.Beep == rhs.Beep) {
return false
}
return true
} | go | func (v *Ping) Equals(rhs *Ping) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
if !(v.Beep == rhs.Beep) {
return false
}
return true
} | [
"func",
"(",
"v",
"*",
"Ping",
")",
"Equals",
"(",
"rhs",
"*",
"Ping",
")",
"bool",
"{",
"if",
"v",
"==",
"nil",
"{",
"return",
"rhs",
"==",
"nil",
"\n",
"}",
"else",
"if",
"rhs",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"!... | // Equals returns true if all the fields of this Ping match the
// provided Ping.
//
// This function performs a deep comparison. | [
"Equals",
"returns",
"true",
"if",
"all",
"the",
"fields",
"of",
"this",
"Ping",
"match",
"the",
"provided",
"Ping",
".",
"This",
"function",
"performs",
"a",
"deep",
"comparison",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/thrift/echo/types.go#L132-L143 |
10,680 | yarpc/yarpc-go | internal/crossdock/thrift/echo/types.go | MarshalLogObject | func (v *Ping) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
enc.AddString("beep", v.Beep)
return err
} | go | func (v *Ping) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
enc.AddString("beep", v.Beep)
return err
} | [
"func",
"(",
"v",
"*",
"Ping",
")",
"MarshalLogObject",
"(",
"enc",
"zapcore",
".",
"ObjectEncoder",
")",
"(",
"err",
"error",
")",
"{",
"if",
"v",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"enc",
".",
"AddString",
"(",
"\"",
"\"",
",",
... | // MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of Ping. | [
"MarshalLogObject",
"implements",
"zapcore",
".",
"ObjectMarshaler",
"enabling",
"fast",
"logging",
"of",
"Ping",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/thrift/echo/types.go#L147-L153 |
10,681 | yarpc/yarpc-go | internal/crossdock/thrift/echo/types.go | GetBeep | func (v *Ping) GetBeep() (o string) {
if v != nil {
o = v.Beep
}
return
} | go | func (v *Ping) GetBeep() (o string) {
if v != nil {
o = v.Beep
}
return
} | [
"func",
"(",
"v",
"*",
"Ping",
")",
"GetBeep",
"(",
")",
"(",
"o",
"string",
")",
"{",
"if",
"v",
"!=",
"nil",
"{",
"o",
"=",
"v",
".",
"Beep",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // GetBeep returns the value of Beep if it is set or its
// zero value if it is unset. | [
"GetBeep",
"returns",
"the",
"value",
"of",
"Beep",
"if",
"it",
"is",
"set",
"or",
"its",
"zero",
"value",
"if",
"it",
"is",
"unset",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/thrift/echo/types.go#L157-L162 |
10,682 | yarpc/yarpc-go | internal/crossdock/thrift/echo/types.go | String | func (v *Pong) String() string {
if v == nil {
return "<nil>"
}
var fields [1]string
i := 0
fields[i] = fmt.Sprintf("Boop: %v", v.Boop)
i++
return fmt.Sprintf("Pong{%v}", strings.Join(fields[:i], ", "))
} | go | func (v *Pong) String() string {
if v == nil {
return "<nil>"
}
var fields [1]string
i := 0
fields[i] = fmt.Sprintf("Boop: %v", v.Boop)
i++
return fmt.Sprintf("Pong{%v}", strings.Join(fields[:i], ", "))
} | [
"func",
"(",
"v",
"*",
"Pong",
")",
"String",
"(",
")",
"string",
"{",
"if",
"v",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"var",
"fields",
"[",
"1",
"]",
"string",
"\n",
"i",
":=",
"0",
"\n",
"fields",
"[",
"i",
"]",
"=",
... | // String returns a readable string representation of a Pong
// struct. | [
"String",
"returns",
"a",
"readable",
"string",
"representation",
"of",
"a",
"Pong",
"struct",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/thrift/echo/types.go#L245-L256 |
10,683 | yarpc/yarpc-go | internal/crossdock/thrift/echo/types.go | Equals | func (v *Pong) Equals(rhs *Pong) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
if !(v.Boop == rhs.Boop) {
return false
}
return true
} | go | func (v *Pong) Equals(rhs *Pong) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
if !(v.Boop == rhs.Boop) {
return false
}
return true
} | [
"func",
"(",
"v",
"*",
"Pong",
")",
"Equals",
"(",
"rhs",
"*",
"Pong",
")",
"bool",
"{",
"if",
"v",
"==",
"nil",
"{",
"return",
"rhs",
"==",
"nil",
"\n",
"}",
"else",
"if",
"rhs",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"!... | // Equals returns true if all the fields of this Pong match the
// provided Pong.
//
// This function performs a deep comparison. | [
"Equals",
"returns",
"true",
"if",
"all",
"the",
"fields",
"of",
"this",
"Pong",
"match",
"the",
"provided",
"Pong",
".",
"This",
"function",
"performs",
"a",
"deep",
"comparison",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/thrift/echo/types.go#L262-L273 |
10,684 | yarpc/yarpc-go | internal/crossdock/thrift/echo/types.go | MarshalLogObject | func (v *Pong) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
enc.AddString("boop", v.Boop)
return err
} | go | func (v *Pong) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
enc.AddString("boop", v.Boop)
return err
} | [
"func",
"(",
"v",
"*",
"Pong",
")",
"MarshalLogObject",
"(",
"enc",
"zapcore",
".",
"ObjectEncoder",
")",
"(",
"err",
"error",
")",
"{",
"if",
"v",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"enc",
".",
"AddString",
"(",
"\"",
"\"",
",",
... | // MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of Pong. | [
"MarshalLogObject",
"implements",
"zapcore",
".",
"ObjectMarshaler",
"enabling",
"fast",
"logging",
"of",
"Pong",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/thrift/echo/types.go#L277-L283 |
10,685 | yarpc/yarpc-go | internal/crossdock/thrift/echo/types.go | GetBoop | func (v *Pong) GetBoop() (o string) {
if v != nil {
o = v.Boop
}
return
} | go | func (v *Pong) GetBoop() (o string) {
if v != nil {
o = v.Boop
}
return
} | [
"func",
"(",
"v",
"*",
"Pong",
")",
"GetBoop",
"(",
")",
"(",
"o",
"string",
")",
"{",
"if",
"v",
"!=",
"nil",
"{",
"o",
"=",
"v",
".",
"Boop",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // GetBoop returns the value of Boop if it is set or its
// zero value if it is unset. | [
"GetBoop",
"returns",
"the",
"value",
"of",
"Boop",
"if",
"it",
"is",
"set",
"or",
"its",
"zero",
"value",
"if",
"it",
"is",
"unset",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/thrift/echo/types.go#L287-L292 |
10,686 | yarpc/yarpc-go | internal/crossdock/client/tchserver/raw.go | remoteTimeout | func remoteTimeout(t crossdock.T, dispatcher *yarpc.Dispatcher) {
assert := crossdock.Assert(t)
token := random.Bytes(5)
_, _, err := rawCall(dispatcher, nil, "handlertimeout/raw", token)
if skipOnConnRefused(t, err) {
return
}
if !assert.Error(err, "expected an error") {
return
}
if yarpcerrors.FromError(err).Code() == yarpcerrors.CodeInvalidArgument {
t.Skipf("handlertimeout/raw procedure not implemented: %v", err)
return
}
assert.Equal(yarpcerrors.CodeDeadlineExceeded, yarpcerrors.FromError(err).Code(), "is an error with code CodeDeadlineExceeded: %v", err)
} | go | func remoteTimeout(t crossdock.T, dispatcher *yarpc.Dispatcher) {
assert := crossdock.Assert(t)
token := random.Bytes(5)
_, _, err := rawCall(dispatcher, nil, "handlertimeout/raw", token)
if skipOnConnRefused(t, err) {
return
}
if !assert.Error(err, "expected an error") {
return
}
if yarpcerrors.FromError(err).Code() == yarpcerrors.CodeInvalidArgument {
t.Skipf("handlertimeout/raw procedure not implemented: %v", err)
return
}
assert.Equal(yarpcerrors.CodeDeadlineExceeded, yarpcerrors.FromError(err).Code(), "is an error with code CodeDeadlineExceeded: %v", err)
} | [
"func",
"remoteTimeout",
"(",
"t",
"crossdock",
".",
"T",
",",
"dispatcher",
"*",
"yarpc",
".",
"Dispatcher",
")",
"{",
"assert",
":=",
"crossdock",
".",
"Assert",
"(",
"t",
")",
"\n\n",
"token",
":=",
"random",
".",
"Bytes",
"(",
"5",
")",
"\n\n",
"... | // remoteTimeout tests if a yarpc client returns a remote timeout error behind
// the TimeoutError interface when a remote tchannel handler returns a handler
// timeout. | [
"remoteTimeout",
"tests",
"if",
"a",
"yarpc",
"client",
"returns",
"a",
"remote",
"timeout",
"error",
"behind",
"the",
"TimeoutError",
"interface",
"when",
"a",
"remote",
"tchannel",
"handler",
"returns",
"a",
"handler",
"timeout",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/client/tchserver/raw.go#L62-L81 |
10,687 | yarpc/yarpc-go | transport/http/peer.go | isAvailable | func (p *httpPeer) isAvailable() bool {
// If there's no open connection, we probe by connecting.
dialer := &net.Dialer{Timeout: p.transport.connTimeout}
conn, err := dialer.Dial("tcp", p.addr)
if conn != nil {
conn.Close()
}
if conn != nil && err == nil {
return true
}
return false
} | go | func (p *httpPeer) isAvailable() bool {
// If there's no open connection, we probe by connecting.
dialer := &net.Dialer{Timeout: p.transport.connTimeout}
conn, err := dialer.Dial("tcp", p.addr)
if conn != nil {
conn.Close()
}
if conn != nil && err == nil {
return true
}
return false
} | [
"func",
"(",
"p",
"*",
"httpPeer",
")",
"isAvailable",
"(",
")",
"bool",
"{",
"// If there's no open connection, we probe by connecting.",
"dialer",
":=",
"&",
"net",
".",
"Dialer",
"{",
"Timeout",
":",
"p",
".",
"transport",
".",
"connTimeout",
"}",
"\n",
"co... | // The HTTP transport polls for whether a peer is available by attempting to
// connect. The transport does not preserve the connection because HTTP servers
// may behave oddly if they don't receive a request immediately.
// Instead, we treat the peer as available until proven otherwise with a fresh
// connection attempt. | [
"The",
"HTTP",
"transport",
"polls",
"for",
"whether",
"a",
"peer",
"is",
"available",
"by",
"attempting",
"to",
"connect",
".",
"The",
"transport",
"does",
"not",
"preserve",
"the",
"connection",
"because",
"HTTP",
"servers",
"may",
"behave",
"oddly",
"if",
... | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/transport/http/peer.go#L69-L80 |
10,688 | yarpc/yarpc-go | internal/clientconfig/multioutbound.go | MultiOutbound | func MultiOutbound(caller, service string, outbounds transport.Outbounds) transport.ClientConfig {
return &transport.OutboundConfig{
CallerName: caller,
Outbounds: transport.Outbounds{
ServiceName: service,
Unary: outbounds.Unary,
Oneway: outbounds.Oneway,
},
}
} | go | func MultiOutbound(caller, service string, outbounds transport.Outbounds) transport.ClientConfig {
return &transport.OutboundConfig{
CallerName: caller,
Outbounds: transport.Outbounds{
ServiceName: service,
Unary: outbounds.Unary,
Oneway: outbounds.Oneway,
},
}
} | [
"func",
"MultiOutbound",
"(",
"caller",
",",
"service",
"string",
",",
"outbounds",
"transport",
".",
"Outbounds",
")",
"transport",
".",
"ClientConfig",
"{",
"return",
"&",
"transport",
".",
"OutboundConfig",
"{",
"CallerName",
":",
"caller",
",",
"Outbounds",
... | // MultiOutbound constructs a ClientConfig backed by multiple outbound types | [
"MultiOutbound",
"constructs",
"a",
"ClientConfig",
"backed",
"by",
"multiple",
"outbound",
"types"
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/clientconfig/multioutbound.go#L28-L37 |
10,689 | yarpc/yarpc-go | internal/crossdock/server/tch/server.go | Start | func Start() {
ch, err := tchannel.NewChannel("tchannel-server", &tchannel.ChannelOptions{Logger: tchannel.SimpleLogger})
if err != nil {
log.WithFields(tchannel.ErrField(err)).Fatal("Couldn't create new channel.")
}
if err := register(ch); err != nil {
log.WithFields(tchannel.ErrField(err)).Fatal("Couldn't register channel.")
}
if err := ch.ListenAndServe(hostPort); err != nil {
log.WithFields(
tchannel.LogField{Key: "hostPort", Value: hostPort},
tchannel.ErrField(err),
).Fatal("Couldn't listen.")
}
} | go | func Start() {
ch, err := tchannel.NewChannel("tchannel-server", &tchannel.ChannelOptions{Logger: tchannel.SimpleLogger})
if err != nil {
log.WithFields(tchannel.ErrField(err)).Fatal("Couldn't create new channel.")
}
if err := register(ch); err != nil {
log.WithFields(tchannel.ErrField(err)).Fatal("Couldn't register channel.")
}
if err := ch.ListenAndServe(hostPort); err != nil {
log.WithFields(
tchannel.LogField{Key: "hostPort", Value: hostPort},
tchannel.ErrField(err),
).Fatal("Couldn't listen.")
}
} | [
"func",
"Start",
"(",
")",
"{",
"ch",
",",
"err",
":=",
"tchannel",
".",
"NewChannel",
"(",
"\"",
"\"",
",",
"&",
"tchannel",
".",
"ChannelOptions",
"{",
"Logger",
":",
"tchannel",
".",
"SimpleLogger",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // Start starts the tch testing server | [
"Start",
"starts",
"the",
"tch",
"testing",
"server"
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/server/tch/server.go#L40-L56 |
10,690 | yarpc/yarpc-go | internal/crossdock/server/tch/server.go | register | func register(ch *tchannel.Channel) error {
ch.Register(raw.Wrap(echoRawHandler{}), "echo/raw")
ch.Register(raw.Wrap(handlerTimeoutRawHandler{}), "handlertimeout/raw")
if err := json.Register(ch, json.Handlers{"echo": echoJSONHandler}, onError); err != nil {
return err
}
tserver := thrift.NewServer(ch)
tserver.Register(echo.NewTChanEchoServer(&echoThriftHandler{}))
tserver.Register(gauntlet_tchannel.NewTChanThriftTestServer(&thriftTestHandler{}))
tserver.Register(gauntlet_tchannel.NewTChanSecondServiceServer(&secondServiceHandler{}))
return nil
} | go | func register(ch *tchannel.Channel) error {
ch.Register(raw.Wrap(echoRawHandler{}), "echo/raw")
ch.Register(raw.Wrap(handlerTimeoutRawHandler{}), "handlertimeout/raw")
if err := json.Register(ch, json.Handlers{"echo": echoJSONHandler}, onError); err != nil {
return err
}
tserver := thrift.NewServer(ch)
tserver.Register(echo.NewTChanEchoServer(&echoThriftHandler{}))
tserver.Register(gauntlet_tchannel.NewTChanThriftTestServer(&thriftTestHandler{}))
tserver.Register(gauntlet_tchannel.NewTChanSecondServiceServer(&secondServiceHandler{}))
return nil
} | [
"func",
"register",
"(",
"ch",
"*",
"tchannel",
".",
"Channel",
")",
"error",
"{",
"ch",
".",
"Register",
"(",
"raw",
".",
"Wrap",
"(",
"echoRawHandler",
"{",
"}",
")",
",",
"\"",
"\"",
")",
"\n",
"ch",
".",
"Register",
"(",
"raw",
".",
"Wrap",
"... | // Register the different endpoints of the test subject | [
"Register",
"the",
"different",
"endpoints",
"of",
"the",
"test",
"subject"
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/server/tch/server.go#L66-L79 |
10,691 | yarpc/yarpc-go | pkg/lifecycle/once.go | Start | func (o *Once) Start(f func() error) error {
if o.state.CAS(int32(Idle), int32(Starting)) {
var err error
if f != nil {
err = f()
}
// skip forward to error state
if err != nil {
o.setError(err)
o.state.Store(int32(Errored))
close(o.stoppingCh)
close(o.stopCh)
} else {
o.state.Store(int32(Running))
}
close(o.startCh)
return err
}
<-o.startCh
return o.loadError()
} | go | func (o *Once) Start(f func() error) error {
if o.state.CAS(int32(Idle), int32(Starting)) {
var err error
if f != nil {
err = f()
}
// skip forward to error state
if err != nil {
o.setError(err)
o.state.Store(int32(Errored))
close(o.stoppingCh)
close(o.stopCh)
} else {
o.state.Store(int32(Running))
}
close(o.startCh)
return err
}
<-o.startCh
return o.loadError()
} | [
"func",
"(",
"o",
"*",
"Once",
")",
"Start",
"(",
"f",
"func",
"(",
")",
"error",
")",
"error",
"{",
"if",
"o",
".",
"state",
".",
"CAS",
"(",
"int32",
"(",
"Idle",
")",
",",
"int32",
"(",
"Starting",
")",
")",
"{",
"var",
"err",
"error",
"\n... | // Start will run the `f` function once and return the error.
// If Start is called multiple times it will return the error
// from the first time it was called. | [
"Start",
"will",
"run",
"the",
"f",
"function",
"once",
"and",
"return",
"the",
"error",
".",
"If",
"Start",
"is",
"called",
"multiple",
"times",
"it",
"will",
"return",
"the",
"error",
"from",
"the",
"first",
"time",
"it",
"was",
"called",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/pkg/lifecycle/once.go#L117-L140 |
10,692 | yarpc/yarpc-go | pkg/lifecycle/once.go | WaitUntilRunning | func (o *Once) WaitUntilRunning(ctx context.Context) error {
state := State(o.state.Load())
if state == Running {
return nil
}
if state > Running {
return yarpcerrors.FailedPreconditionErrorf("could not wait for instance to start running: current state is %q", getStateName(state))
}
if _, ok := ctx.Deadline(); !ok {
return yarpcerrors.InvalidArgumentErrorf("could not wait for instance to start running: deadline required on request context")
}
select {
case <-o.startCh:
state := State(o.state.Load())
if state == Running {
return nil
}
return yarpcerrors.FailedPreconditionErrorf("instance did not enter running state, current state is %q", getStateName(state))
case <-ctx.Done():
return yarpcerrors.FailedPreconditionErrorf("context finished while waiting for instance to start: %s", ctx.Err().Error())
}
} | go | func (o *Once) WaitUntilRunning(ctx context.Context) error {
state := State(o.state.Load())
if state == Running {
return nil
}
if state > Running {
return yarpcerrors.FailedPreconditionErrorf("could not wait for instance to start running: current state is %q", getStateName(state))
}
if _, ok := ctx.Deadline(); !ok {
return yarpcerrors.InvalidArgumentErrorf("could not wait for instance to start running: deadline required on request context")
}
select {
case <-o.startCh:
state := State(o.state.Load())
if state == Running {
return nil
}
return yarpcerrors.FailedPreconditionErrorf("instance did not enter running state, current state is %q", getStateName(state))
case <-ctx.Done():
return yarpcerrors.FailedPreconditionErrorf("context finished while waiting for instance to start: %s", ctx.Err().Error())
}
} | [
"func",
"(",
"o",
"*",
"Once",
")",
"WaitUntilRunning",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"state",
":=",
"State",
"(",
"o",
".",
"state",
".",
"Load",
"(",
")",
")",
"\n",
"if",
"state",
"==",
"Running",
"{",
"return",
"nil"... | // WaitUntilRunning blocks until the instance enters the running state, or the
// context times out. | [
"WaitUntilRunning",
"blocks",
"until",
"the",
"instance",
"enters",
"the",
"running",
"state",
"or",
"the",
"context",
"times",
"out",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/pkg/lifecycle/once.go#L144-L167 |
10,693 | yarpc/yarpc-go | pkg/lifecycle/once.go | Stop | func (o *Once) Stop(f func() error) error {
if o.state.CAS(int32(Idle), int32(Stopped)) {
close(o.startCh)
close(o.stoppingCh)
close(o.stopCh)
return nil
}
<-o.startCh
if o.state.CAS(int32(Running), int32(Stopping)) {
close(o.stoppingCh)
var err error
if f != nil {
err = f()
}
if err != nil {
o.setError(err)
o.state.Store(int32(Errored))
} else {
o.state.Store(int32(Stopped))
}
close(o.stopCh)
return err
}
<-o.stopCh
return o.loadError()
} | go | func (o *Once) Stop(f func() error) error {
if o.state.CAS(int32(Idle), int32(Stopped)) {
close(o.startCh)
close(o.stoppingCh)
close(o.stopCh)
return nil
}
<-o.startCh
if o.state.CAS(int32(Running), int32(Stopping)) {
close(o.stoppingCh)
var err error
if f != nil {
err = f()
}
if err != nil {
o.setError(err)
o.state.Store(int32(Errored))
} else {
o.state.Store(int32(Stopped))
}
close(o.stopCh)
return err
}
<-o.stopCh
return o.loadError()
} | [
"func",
"(",
"o",
"*",
"Once",
")",
"Stop",
"(",
"f",
"func",
"(",
")",
"error",
")",
"error",
"{",
"if",
"o",
".",
"state",
".",
"CAS",
"(",
"int32",
"(",
"Idle",
")",
",",
"int32",
"(",
"Stopped",
")",
")",
"{",
"close",
"(",
"o",
".",
"s... | // Stop will run the `f` function once and return the error.
// If Stop is called multiple times it will return the error
// from the first time it was called. | [
"Stop",
"will",
"run",
"the",
"f",
"function",
"once",
"and",
"return",
"the",
"error",
".",
"If",
"Stop",
"is",
"called",
"multiple",
"times",
"it",
"will",
"return",
"the",
"error",
"from",
"the",
"first",
"time",
"it",
"was",
"called",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/pkg/lifecycle/once.go#L172-L202 |
10,694 | yarpc/yarpc-go | internal/crossdock/client/echo/behavior.go | createEchoT | func createEchoT(encoding string, transport string, t crossdock.T) crossdock.T {
if transport == "" {
transport = t.Param(params.Transport)
}
t.Tag("transport", transport)
t.Tag("encoding", encoding)
t.Tag("server", t.Param(params.Server))
return t
} | go | func createEchoT(encoding string, transport string, t crossdock.T) crossdock.T {
if transport == "" {
transport = t.Param(params.Transport)
}
t.Tag("transport", transport)
t.Tag("encoding", encoding)
t.Tag("server", t.Param(params.Server))
return t
} | [
"func",
"createEchoT",
"(",
"encoding",
"string",
",",
"transport",
"string",
",",
"t",
"crossdock",
".",
"T",
")",
"crossdock",
".",
"T",
"{",
"if",
"transport",
"==",
"\"",
"\"",
"{",
"transport",
"=",
"t",
".",
"Param",
"(",
"params",
".",
"Transpor... | // createEchoT tags the given T with the transport, encoding and server. | [
"createEchoT",
"tags",
"the",
"given",
"T",
"with",
"the",
"transport",
"encoding",
"and",
"server",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/client/echo/behavior.go#L29-L37 |
10,695 | yarpc/yarpc-go | transport/grpc/transport.go | NewInbound | func (t *Transport) NewInbound(listener net.Listener, options ...InboundOption) *Inbound {
return newInbound(t, listener, options...)
} | go | func (t *Transport) NewInbound(listener net.Listener, options ...InboundOption) *Inbound {
return newInbound(t, listener, options...)
} | [
"func",
"(",
"t",
"*",
"Transport",
")",
"NewInbound",
"(",
"listener",
"net",
".",
"Listener",
",",
"options",
"...",
"InboundOption",
")",
"*",
"Inbound",
"{",
"return",
"newInbound",
"(",
"t",
",",
"listener",
",",
"options",
"...",
")",
"\n",
"}"
] | // NewInbound returns a new Inbound for the given listener. | [
"NewInbound",
"returns",
"a",
"new",
"Inbound",
"for",
"the",
"given",
"listener",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/transport/grpc/transport.go#L83-L85 |
10,696 | yarpc/yarpc-go | transport/grpc/transport.go | NewOutbound | func (t *Transport) NewOutbound(peerChooser peer.Chooser, options ...OutboundOption) *Outbound {
return newOutbound(t, peerChooser, options...)
} | go | func (t *Transport) NewOutbound(peerChooser peer.Chooser, options ...OutboundOption) *Outbound {
return newOutbound(t, peerChooser, options...)
} | [
"func",
"(",
"t",
"*",
"Transport",
")",
"NewOutbound",
"(",
"peerChooser",
"peer",
".",
"Chooser",
",",
"options",
"...",
"OutboundOption",
")",
"*",
"Outbound",
"{",
"return",
"newOutbound",
"(",
"t",
",",
"peerChooser",
",",
"options",
"...",
")",
"\n",... | // NewOutbound returns a new Outbound for the given peer.Chooser. | [
"NewOutbound",
"returns",
"a",
"new",
"Outbound",
"for",
"the",
"given",
"peer",
".",
"Chooser",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/transport/grpc/transport.go#L94-L96 |
10,697 | yarpc/yarpc-go | x/yarpcmeta/service.go | Register | func Register(d *yarpc.Dispatcher) {
ms := &service{d}
d.Register(ms.Procedures())
} | go | func Register(d *yarpc.Dispatcher) {
ms := &service{d}
d.Register(ms.Procedures())
} | [
"func",
"Register",
"(",
"d",
"*",
"yarpc",
".",
"Dispatcher",
")",
"{",
"ms",
":=",
"&",
"service",
"{",
"d",
"}",
"\n",
"d",
".",
"Register",
"(",
"ms",
".",
"Procedures",
"(",
")",
")",
"\n",
"}"
] | // Register new yarpc meta procedures a dispatcher, exposing information about
// the dispatcher itself. | [
"Register",
"new",
"yarpc",
"meta",
"procedures",
"a",
"dispatcher",
"exposing",
"information",
"about",
"the",
"dispatcher",
"itself",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/x/yarpcmeta/service.go#L34-L37 |
10,698 | yarpc/yarpc-go | x/yarpcmeta/service.go | Procedures | func (m *service) Procedures() []transport.Procedure {
methods := []struct {
Name string
Handler interface{}
Signature string
}{
{"yarpc::procedures", m.procs,
`procedures() {"service": "...", "procedures": [{"name": "..."}]}`},
{"yarpc::introspect", m.introspect,
`introspect() {...}`},
}
var r []transport.Procedure
for _, m := range methods {
p := json.Procedure(m.Name, m.Handler)[0]
p.Signature = m.Signature
r = append(r, p)
}
return r
} | go | func (m *service) Procedures() []transport.Procedure {
methods := []struct {
Name string
Handler interface{}
Signature string
}{
{"yarpc::procedures", m.procs,
`procedures() {"service": "...", "procedures": [{"name": "..."}]}`},
{"yarpc::introspect", m.introspect,
`introspect() {...}`},
}
var r []transport.Procedure
for _, m := range methods {
p := json.Procedure(m.Name, m.Handler)[0]
p.Signature = m.Signature
r = append(r, p)
}
return r
} | [
"func",
"(",
"m",
"*",
"service",
")",
"Procedures",
"(",
")",
"[",
"]",
"transport",
".",
"Procedure",
"{",
"methods",
":=",
"[",
"]",
"struct",
"{",
"Name",
"string",
"\n",
"Handler",
"interface",
"{",
"}",
"\n",
"Signature",
"string",
"\n",
"}",
"... | // Procedures returns the procedures to register on a dispatcher. | [
"Procedures",
"returns",
"the",
"procedures",
"to",
"register",
"on",
"a",
"dispatcher",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/x/yarpcmeta/service.go#L63-L81 |
10,699 | yarpc/yarpc-go | transport/tchannel/channel_outbound.go | NewOutbound | func (t *ChannelTransport) NewOutbound() *ChannelOutbound {
return &ChannelOutbound{
once: lifecycle.NewOnce(),
channel: t.ch,
transport: t,
}
} | go | func (t *ChannelTransport) NewOutbound() *ChannelOutbound {
return &ChannelOutbound{
once: lifecycle.NewOnce(),
channel: t.ch,
transport: t,
}
} | [
"func",
"(",
"t",
"*",
"ChannelTransport",
")",
"NewOutbound",
"(",
")",
"*",
"ChannelOutbound",
"{",
"return",
"&",
"ChannelOutbound",
"{",
"once",
":",
"lifecycle",
".",
"NewOnce",
"(",
")",
",",
"channel",
":",
"t",
".",
"ch",
",",
"transport",
":",
... | // NewOutbound builds a new TChannel outbound using the transport's shared
// channel to make requests to any connected peer. | [
"NewOutbound",
"builds",
"a",
"new",
"TChannel",
"outbound",
"using",
"the",
"transport",
"s",
"shared",
"channel",
"to",
"make",
"requests",
"to",
"any",
"connected",
"peer",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/transport/tchannel/channel_outbound.go#L44-L50 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.