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,500 | yarpc/yarpc-go | peer/peerlist/peer.go | Subscriber | func (t *peerThunk) Subscriber() peer.Subscriber {
t.lock.RLock()
s := t.subscriber
t.lock.RUnlock()
return s
} | go | func (t *peerThunk) Subscriber() peer.Subscriber {
t.lock.RLock()
s := t.subscriber
t.lock.RUnlock()
return s
} | [
"func",
"(",
"t",
"*",
"peerThunk",
")",
"Subscriber",
"(",
")",
"peer",
".",
"Subscriber",
"{",
"t",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"s",
":=",
"t",
".",
"subscriber",
"\n",
"t",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n",
"return",
... | // Subscriber returns the subscriber. | [
"Subscriber",
"returns",
"the",
"subscriber",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/peer/peerlist/peer.go#L83-L88 |
10,501 | yarpc/yarpc-go | internal/examples/thrift-hello/hello/echo/hello_echo.go | String | func (v *Hello_Echo_Args) String() string {
if v == nil {
return "<nil>"
}
var fields [1]string
i := 0
if v.Echo != nil {
fields[i] = fmt.Sprintf("Echo: %v", v.Echo)
i++
}
return fmt.Sprintf("Hello_Echo_Args{%v}", strings.Join(fields[:i], ", "))
} | go | func (v *Hello_Echo_Args) String() string {
if v == nil {
return "<nil>"
}
var fields [1]string
i := 0
if v.Echo != nil {
fields[i] = fmt.Sprintf("Echo: %v", v.Echo)
i++
}
return fmt.Sprintf("Hello_Echo_Args{%v}", strings.Join(fields[:i], ", "))
} | [
"func",
"(",
"v",
"*",
"Hello_Echo_Args",
")",
"String",
"(",
")",
"string",
"{",
"if",
"v",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"var",
"fields",
"[",
"1",
"]",
"string",
"\n",
"i",
":=",
"0",
"\n",
"if",
"v",
".",
"Echo"... | // String returns a readable string representation of a Hello_Echo_Args
// struct. | [
"String",
"returns",
"a",
"readable",
"string",
"representation",
"of",
"a",
"Hello_Echo_Args",
"struct",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/thrift-hello/hello/echo/hello_echo.go#L121-L134 |
10,502 | yarpc/yarpc-go | internal/examples/thrift-hello/hello/echo/hello_echo.go | Equals | func (v *Hello_Echo_Args) Equals(rhs *Hello_Echo_Args) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
if !((v.Echo == nil && rhs.Echo == nil) || (v.Echo != nil && rhs.Echo != nil && v.Echo.Equals(rhs.Echo))) {
return false
}
return true
} | go | func (v *Hello_Echo_Args) Equals(rhs *Hello_Echo_Args) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
if !((v.Echo == nil && rhs.Echo == nil) || (v.Echo != nil && rhs.Echo != nil && v.Echo.Equals(rhs.Echo))) {
return false
}
return true
} | [
"func",
"(",
"v",
"*",
"Hello_Echo_Args",
")",
"Equals",
"(",
"rhs",
"*",
"Hello_Echo_Args",
")",
"bool",
"{",
"if",
"v",
"==",
"nil",
"{",
"return",
"rhs",
"==",
"nil",
"\n",
"}",
"else",
"if",
"rhs",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}"... | // Equals returns true if all the fields of this Hello_Echo_Args match the
// provided Hello_Echo_Args.
//
// This function performs a deep comparison. | [
"Equals",
"returns",
"true",
"if",
"all",
"the",
"fields",
"of",
"this",
"Hello_Echo_Args",
"match",
"the",
"provided",
"Hello_Echo_Args",
".",
"This",
"function",
"performs",
"a",
"deep",
"comparison",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/thrift-hello/hello/echo/hello_echo.go#L140-L151 |
10,503 | yarpc/yarpc-go | internal/examples/thrift-hello/hello/echo/hello_echo.go | MarshalLogObject | func (v *Hello_Echo_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
if v.Echo != nil {
err = multierr.Append(err, enc.AddObject("echo", v.Echo))
}
return err
} | go | func (v *Hello_Echo_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
if v.Echo != nil {
err = multierr.Append(err, enc.AddObject("echo", v.Echo))
}
return err
} | [
"func",
"(",
"v",
"*",
"Hello_Echo_Args",
")",
"MarshalLogObject",
"(",
"enc",
"zapcore",
".",
"ObjectEncoder",
")",
"(",
"err",
"error",
")",
"{",
"if",
"v",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"v",
".",
"Echo",
"!=",
"nil",
... | // MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of Hello_Echo_Args. | [
"MarshalLogObject",
"implements",
"zapcore",
".",
"ObjectMarshaler",
"enabling",
"fast",
"logging",
"of",
"Hello_Echo_Args",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/thrift-hello/hello/echo/hello_echo.go#L155-L163 |
10,504 | yarpc/yarpc-go | internal/examples/thrift-hello/hello/echo/hello_echo.go | GetEcho | func (v *Hello_Echo_Args) GetEcho() (o *EchoRequest) {
if v != nil && v.Echo != nil {
return v.Echo
}
return
} | go | func (v *Hello_Echo_Args) GetEcho() (o *EchoRequest) {
if v != nil && v.Echo != nil {
return v.Echo
}
return
} | [
"func",
"(",
"v",
"*",
"Hello_Echo_Args",
")",
"GetEcho",
"(",
")",
"(",
"o",
"*",
"EchoRequest",
")",
"{",
"if",
"v",
"!=",
"nil",
"&&",
"v",
".",
"Echo",
"!=",
"nil",
"{",
"return",
"v",
".",
"Echo",
"\n",
"}",
"\n\n",
"return",
"\n",
"}"
] | // GetEcho returns the value of Echo if it is set or its
// zero value if it is unset. | [
"GetEcho",
"returns",
"the",
"value",
"of",
"Echo",
"if",
"it",
"is",
"set",
"or",
"its",
"zero",
"value",
"if",
"it",
"is",
"unset",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/thrift-hello/hello/echo/hello_echo.go#L167-L173 |
10,505 | yarpc/yarpc-go | yarpcerrors/errors.go | Newf | func Newf(code Code, format string, args ...interface{}) *Status {
if code == CodeOK {
return nil
}
return &Status{
code: code,
message: sprintf(format, args...),
}
} | go | func Newf(code Code, format string, args ...interface{}) *Status {
if code == CodeOK {
return nil
}
return &Status{
code: code,
message: sprintf(format, args...),
}
} | [
"func",
"Newf",
"(",
"code",
"Code",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"*",
"Status",
"{",
"if",
"code",
"==",
"CodeOK",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"&",
"Status",
"{",
"code",
":",
"code"... | // Newf returns a new Status.
//
// The Code should never be CodeOK, if it is, this will return nil. | [
"Newf",
"returns",
"a",
"new",
"Status",
".",
"The",
"Code",
"should",
"never",
"be",
"CodeOK",
"if",
"it",
"is",
"this",
"will",
"return",
"nil",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/yarpcerrors/errors.go#L31-L39 |
10,506 | yarpc/yarpc-go | yarpcerrors/errors.go | FromError | func FromError(err error) *Status {
if err == nil {
return nil
}
if status, ok := err.(*Status); ok {
return status
}
return &Status{
code: CodeUnknown,
message: err.Error(),
}
} | go | func FromError(err error) *Status {
if err == nil {
return nil
}
if status, ok := err.(*Status); ok {
return status
}
return &Status{
code: CodeUnknown,
message: err.Error(),
}
} | [
"func",
"FromError",
"(",
"err",
"error",
")",
"*",
"Status",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"status",
",",
"ok",
":=",
"err",
".",
"(",
"*",
"Status",
")",
";",
"ok",
"{",
"return",
"status",
"\n",
... | // FromError returns the Status for the provided error. If the provided error
// is not a Status, a new error with code CodeUnknown is returned.
//
// Returns nil if the provided error is nil. | [
"FromError",
"returns",
"the",
"Status",
"for",
"the",
"provided",
"error",
".",
"If",
"the",
"provided",
"error",
"is",
"not",
"a",
"Status",
"a",
"new",
"error",
"with",
"code",
"CodeUnknown",
"is",
"returned",
".",
"Returns",
"nil",
"if",
"the",
"provid... | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/yarpcerrors/errors.go#L45-L56 |
10,507 | yarpc/yarpc-go | yarpcconfig/configurator.go | New | func New(opts ...Option) *Configurator {
c := &Configurator{
knownTransports: make(map[string]*compiledTransportSpec),
knownPeerChoosers: make(map[string]*compiledPeerChooserSpec),
knownPeerLists: make(map[string]*compiledPeerListSpec),
knownPeerListUpdaters: make(map[string]*compiledPeerListUpdaterSpec),
resolver: os.LookupEnv,
}
for _, opt := range opts {
opt(c)
}
return c
} | go | func New(opts ...Option) *Configurator {
c := &Configurator{
knownTransports: make(map[string]*compiledTransportSpec),
knownPeerChoosers: make(map[string]*compiledPeerChooserSpec),
knownPeerLists: make(map[string]*compiledPeerListSpec),
knownPeerListUpdaters: make(map[string]*compiledPeerListUpdaterSpec),
resolver: os.LookupEnv,
}
for _, opt := range opts {
opt(c)
}
return c
} | [
"func",
"New",
"(",
"opts",
"...",
"Option",
")",
"*",
"Configurator",
"{",
"c",
":=",
"&",
"Configurator",
"{",
"knownTransports",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"compiledTransportSpec",
")",
",",
"knownPeerChoosers",
":",
"make",
"(",
... | // New sets up a new empty Configurator. The returned Configurator does not
// know about any Transports, peer lists, or peer list updaters. | [
"New",
"sets",
"up",
"a",
"new",
"empty",
"Configurator",
".",
"The",
"returned",
"Configurator",
"does",
"not",
"know",
"about",
"any",
"Transports",
"peer",
"lists",
"or",
"peer",
"list",
"updaters",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/yarpcconfig/configurator.go#L53-L67 |
10,508 | yarpc/yarpc-go | yarpcconfig/configurator.go | RegisterTransport | func (c *Configurator) RegisterTransport(t TransportSpec) error {
if t.Name == "" {
return errors.New("name is required")
}
spec, err := compileTransportSpec(&t)
if err != nil {
return fmt.Errorf("invalid TransportSpec for %q: %v", t.Name, err)
}
c.knownTransports[t.Name] = spec
return nil
} | go | func (c *Configurator) RegisterTransport(t TransportSpec) error {
if t.Name == "" {
return errors.New("name is required")
}
spec, err := compileTransportSpec(&t)
if err != nil {
return fmt.Errorf("invalid TransportSpec for %q: %v", t.Name, err)
}
c.knownTransports[t.Name] = spec
return nil
} | [
"func",
"(",
"c",
"*",
"Configurator",
")",
"RegisterTransport",
"(",
"t",
"TransportSpec",
")",
"error",
"{",
"if",
"t",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"spec",
",",
"err... | // RegisterTransport registers a TransportSpec with the Configurator, teaching
// it how to load configuration and build inbounds and outbounds for that
// transport.
//
// An error is returned if the TransportSpec is invalid. Use
// MustRegisterTransport if you want to panic in case of registration failure.
//
// If a transport with the same name already exists, it will be replaced.
//
// See TransportSpec for details on how to integrate your own transport with
// the system. | [
"RegisterTransport",
"registers",
"a",
"TransportSpec",
"with",
"the",
"Configurator",
"teaching",
"it",
"how",
"to",
"load",
"configuration",
"and",
"build",
"inbounds",
"and",
"outbounds",
"for",
"that",
"transport",
".",
"An",
"error",
"is",
"returned",
"if",
... | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/yarpcconfig/configurator.go#L80-L92 |
10,509 | yarpc/yarpc-go | yarpcconfig/configurator.go | MustRegisterTransport | func (c *Configurator) MustRegisterTransport(t TransportSpec) {
if err := c.RegisterTransport(t); err != nil {
panic(err)
}
} | go | func (c *Configurator) MustRegisterTransport(t TransportSpec) {
if err := c.RegisterTransport(t); err != nil {
panic(err)
}
} | [
"func",
"(",
"c",
"*",
"Configurator",
")",
"MustRegisterTransport",
"(",
"t",
"TransportSpec",
")",
"{",
"if",
"err",
":=",
"c",
".",
"RegisterTransport",
"(",
"t",
")",
";",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"}"
] | // MustRegisterTransport registers the given TransportSpec with the
// Configurator. This function panics if the TransportSpec is invalid. | [
"MustRegisterTransport",
"registers",
"the",
"given",
"TransportSpec",
"with",
"the",
"Configurator",
".",
"This",
"function",
"panics",
"if",
"the",
"TransportSpec",
"is",
"invalid",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/yarpcconfig/configurator.go#L96-L100 |
10,510 | yarpc/yarpc-go | yarpcconfig/configurator.go | RegisterPeerChooser | func (c *Configurator) RegisterPeerChooser(s PeerChooserSpec) error {
if s.Name == "" {
return errors.New("name is required")
}
spec, err := compilePeerChooserSpec(&s)
if err != nil {
return fmt.Errorf("invalid PeerChooserSpec for %q: %v", s.Name, err)
}
c.knownPeerChoosers[s.Name] = spec
return nil
} | go | func (c *Configurator) RegisterPeerChooser(s PeerChooserSpec) error {
if s.Name == "" {
return errors.New("name is required")
}
spec, err := compilePeerChooserSpec(&s)
if err != nil {
return fmt.Errorf("invalid PeerChooserSpec for %q: %v", s.Name, err)
}
c.knownPeerChoosers[s.Name] = spec
return nil
} | [
"func",
"(",
"c",
"*",
"Configurator",
")",
"RegisterPeerChooser",
"(",
"s",
"PeerChooserSpec",
")",
"error",
"{",
"if",
"s",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"spec",
",",
... | // RegisterPeerChooser registers a PeerChooserSpec with the given Configurator,
// teaching it how to build peer choosers of this kind from configuration.
//
// An error is returned if the PeerChooserSpec is invalid. Use
// MustRegisterPeerChooser to panic in the case of registration failure.
//
// If a peer chooser with the same name already exists, it will be replaced.
//
// If a peer list is registered with the same name, it will be ignored.
//
// See PeerChooserSpec for details on how to integrate your own peer chooser
// with the system. | [
"RegisterPeerChooser",
"registers",
"a",
"PeerChooserSpec",
"with",
"the",
"given",
"Configurator",
"teaching",
"it",
"how",
"to",
"build",
"peer",
"choosers",
"of",
"this",
"kind",
"from",
"configuration",
".",
"An",
"error",
"is",
"returned",
"if",
"the",
"Pee... | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/yarpcconfig/configurator.go#L114-L126 |
10,511 | yarpc/yarpc-go | yarpcconfig/configurator.go | MustRegisterPeerChooser | func (c *Configurator) MustRegisterPeerChooser(s PeerChooserSpec) {
if err := c.RegisterPeerChooser(s); err != nil {
panic(err)
}
} | go | func (c *Configurator) MustRegisterPeerChooser(s PeerChooserSpec) {
if err := c.RegisterPeerChooser(s); err != nil {
panic(err)
}
} | [
"func",
"(",
"c",
"*",
"Configurator",
")",
"MustRegisterPeerChooser",
"(",
"s",
"PeerChooserSpec",
")",
"{",
"if",
"err",
":=",
"c",
".",
"RegisterPeerChooser",
"(",
"s",
")",
";",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
... | // MustRegisterPeerChooser registers the given PeerChooserSpec with the
// Configurator.
// This function panics if the PeerChooserSpec is invalid. | [
"MustRegisterPeerChooser",
"registers",
"the",
"given",
"PeerChooserSpec",
"with",
"the",
"Configurator",
".",
"This",
"function",
"panics",
"if",
"the",
"PeerChooserSpec",
"is",
"invalid",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/yarpcconfig/configurator.go#L131-L135 |
10,512 | yarpc/yarpc-go | yarpcconfig/configurator.go | RegisterPeerList | func (c *Configurator) RegisterPeerList(s PeerListSpec) error {
if s.Name == "" {
return errors.New("name is required")
}
spec, err := compilePeerListSpec(&s)
if err != nil {
return fmt.Errorf("invalid PeerListSpec for %q: %v", s.Name, err)
}
c.knownPeerLists[s.Name] = spec
return nil
} | go | func (c *Configurator) RegisterPeerList(s PeerListSpec) error {
if s.Name == "" {
return errors.New("name is required")
}
spec, err := compilePeerListSpec(&s)
if err != nil {
return fmt.Errorf("invalid PeerListSpec for %q: %v", s.Name, err)
}
c.knownPeerLists[s.Name] = spec
return nil
} | [
"func",
"(",
"c",
"*",
"Configurator",
")",
"RegisterPeerList",
"(",
"s",
"PeerListSpec",
")",
"error",
"{",
"if",
"s",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"spec",
",",
"err",... | // RegisterPeerList registers a PeerListSpec with the given Configurator,
// teaching it how to build peer lists of this kind from configuration.
//
// An error is returned if the PeerListSpec is invalid. Use
// MustRegisterPeerList to panic in the case of registration failure.
//
// If a peer list with the same name already exists, it will be replaced.
//
// If a peer chooser is registered with the same name, this list will be
// ignored.
//
// See PeerListSpec for details on how to integrate your own peer list with
// the system. | [
"RegisterPeerList",
"registers",
"a",
"PeerListSpec",
"with",
"the",
"given",
"Configurator",
"teaching",
"it",
"how",
"to",
"build",
"peer",
"lists",
"of",
"this",
"kind",
"from",
"configuration",
".",
"An",
"error",
"is",
"returned",
"if",
"the",
"PeerListSpec... | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/yarpcconfig/configurator.go#L150-L162 |
10,513 | yarpc/yarpc-go | yarpcconfig/configurator.go | MustRegisterPeerList | func (c *Configurator) MustRegisterPeerList(s PeerListSpec) {
if err := c.RegisterPeerList(s); err != nil {
panic(err)
}
} | go | func (c *Configurator) MustRegisterPeerList(s PeerListSpec) {
if err := c.RegisterPeerList(s); err != nil {
panic(err)
}
} | [
"func",
"(",
"c",
"*",
"Configurator",
")",
"MustRegisterPeerList",
"(",
"s",
"PeerListSpec",
")",
"{",
"if",
"err",
":=",
"c",
".",
"RegisterPeerList",
"(",
"s",
")",
";",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"}"
] | // MustRegisterPeerList registers the given PeerListSpec with the Configurator.
// This function panics if the PeerListSpec is invalid. | [
"MustRegisterPeerList",
"registers",
"the",
"given",
"PeerListSpec",
"with",
"the",
"Configurator",
".",
"This",
"function",
"panics",
"if",
"the",
"PeerListSpec",
"is",
"invalid",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/yarpcconfig/configurator.go#L166-L170 |
10,514 | yarpc/yarpc-go | yarpcconfig/configurator.go | RegisterPeerListUpdater | func (c *Configurator) RegisterPeerListUpdater(s PeerListUpdaterSpec) error {
if s.Name == "" {
return errors.New("name is required")
}
spec, err := compilePeerListUpdaterSpec(&s)
if err != nil {
return fmt.Errorf("invalid PeerListUpdaterSpec for %q: %v", s.Name, err)
}
c.knownPeerListUpdaters[s.Name] = spec
return nil
} | go | func (c *Configurator) RegisterPeerListUpdater(s PeerListUpdaterSpec) error {
if s.Name == "" {
return errors.New("name is required")
}
spec, err := compilePeerListUpdaterSpec(&s)
if err != nil {
return fmt.Errorf("invalid PeerListUpdaterSpec for %q: %v", s.Name, err)
}
c.knownPeerListUpdaters[s.Name] = spec
return nil
} | [
"func",
"(",
"c",
"*",
"Configurator",
")",
"RegisterPeerListUpdater",
"(",
"s",
"PeerListUpdaterSpec",
")",
"error",
"{",
"if",
"s",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"spec",
... | // RegisterPeerListUpdater registers a PeerListUpdaterSpec with the given
// Configurator, teaching it how to build peer list updaters of this kind from
// configuration.
//
// Returns an error if the PeerListUpdaterSpec is invalid. Use
// MustRegisterPeerListUpdater to panic if the registration fails.
//
// If a peer list updater with the same name already exists, it will be
// replaced.
//
// See PeerListUpdaterSpec for details on how to integrate your own peer list
// updater with the system. | [
"RegisterPeerListUpdater",
"registers",
"a",
"PeerListUpdaterSpec",
"with",
"the",
"given",
"Configurator",
"teaching",
"it",
"how",
"to",
"build",
"peer",
"list",
"updaters",
"of",
"this",
"kind",
"from",
"configuration",
".",
"Returns",
"an",
"error",
"if",
"the... | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/yarpcconfig/configurator.go#L184-L196 |
10,515 | yarpc/yarpc-go | yarpcconfig/configurator.go | MustRegisterPeerListUpdater | func (c *Configurator) MustRegisterPeerListUpdater(s PeerListUpdaterSpec) {
if err := c.RegisterPeerListUpdater(s); err != nil {
panic(err)
}
} | go | func (c *Configurator) MustRegisterPeerListUpdater(s PeerListUpdaterSpec) {
if err := c.RegisterPeerListUpdater(s); err != nil {
panic(err)
}
} | [
"func",
"(",
"c",
"*",
"Configurator",
")",
"MustRegisterPeerListUpdater",
"(",
"s",
"PeerListUpdaterSpec",
")",
"{",
"if",
"err",
":=",
"c",
".",
"RegisterPeerListUpdater",
"(",
"s",
")",
";",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}"... | // MustRegisterPeerListUpdater registers the given PeerListUpdaterSpec with
// the Configurator. This function panics if the PeerListUpdaterSpec is
// invalid. | [
"MustRegisterPeerListUpdater",
"registers",
"the",
"given",
"PeerListUpdaterSpec",
"with",
"the",
"Configurator",
".",
"This",
"function",
"panics",
"if",
"the",
"PeerListUpdaterSpec",
"is",
"invalid",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/yarpcconfig/configurator.go#L201-L205 |
10,516 | yarpc/yarpc-go | yarpcconfig/configurator.go | NewDispatcherFromYAML | func (c *Configurator) NewDispatcherFromYAML(serviceName string, r io.Reader) (*yarpc.Dispatcher, error) {
cfg, err := c.LoadConfigFromYAML(serviceName, r)
if err != nil {
return nil, err
}
return yarpc.NewDispatcher(cfg), nil
} | go | func (c *Configurator) NewDispatcherFromYAML(serviceName string, r io.Reader) (*yarpc.Dispatcher, error) {
cfg, err := c.LoadConfigFromYAML(serviceName, r)
if err != nil {
return nil, err
}
return yarpc.NewDispatcher(cfg), nil
} | [
"func",
"(",
"c",
"*",
"Configurator",
")",
"NewDispatcherFromYAML",
"(",
"serviceName",
"string",
",",
"r",
"io",
".",
"Reader",
")",
"(",
"*",
"yarpc",
".",
"Dispatcher",
",",
"error",
")",
"{",
"cfg",
",",
"err",
":=",
"c",
".",
"LoadConfigFromYAML",
... | // NewDispatcherFromYAML builds a Dispatcher from the given YAML
// configuration. | [
"NewDispatcherFromYAML",
"builds",
"a",
"Dispatcher",
"from",
"the",
"given",
"YAML",
"configuration",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/yarpcconfig/configurator.go#L238-L244 |
10,517 | yarpc/yarpc-go | yarpcconfig/configurator.go | NewDispatcher | func (c *Configurator) NewDispatcher(serviceName string, data interface{}) (*yarpc.Dispatcher, error) {
cfg, err := c.LoadConfig(serviceName, data)
if err != nil {
return nil, err
}
return yarpc.NewDispatcher(cfg), nil
} | go | func (c *Configurator) NewDispatcher(serviceName string, data interface{}) (*yarpc.Dispatcher, error) {
cfg, err := c.LoadConfig(serviceName, data)
if err != nil {
return nil, err
}
return yarpc.NewDispatcher(cfg), nil
} | [
"func",
"(",
"c",
"*",
"Configurator",
")",
"NewDispatcher",
"(",
"serviceName",
"string",
",",
"data",
"interface",
"{",
"}",
")",
"(",
"*",
"yarpc",
".",
"Dispatcher",
",",
"error",
")",
"{",
"cfg",
",",
"err",
":=",
"c",
".",
"LoadConfig",
"(",
"s... | // NewDispatcher builds a new Dispatcher from the given configuration data. | [
"NewDispatcher",
"builds",
"a",
"new",
"Dispatcher",
"from",
"the",
"given",
"configuration",
"data",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/yarpcconfig/configurator.go#L247-L253 |
10,518 | yarpc/yarpc-go | yarpcconfig/configurator.go | spec | func (c *Configurator) spec(name string) (*compiledTransportSpec, error) {
spec, ok := c.knownTransports[name]
if !ok {
return nil, fmt.Errorf("unknown transport %q", name)
}
return spec, nil
} | go | func (c *Configurator) spec(name string) (*compiledTransportSpec, error) {
spec, ok := c.knownTransports[name]
if !ok {
return nil, fmt.Errorf("unknown transport %q", name)
}
return spec, nil
} | [
"func",
"(",
"c",
"*",
"Configurator",
")",
"spec",
"(",
"name",
"string",
")",
"(",
"*",
"compiledTransportSpec",
",",
"error",
")",
"{",
"spec",
",",
"ok",
":=",
"c",
".",
"knownTransports",
"[",
"name",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
... | // Returns the compiled spec for the transport with the given name or an error | [
"Returns",
"the",
"compiled",
"spec",
"for",
"the",
"transport",
"with",
"the",
"given",
"name",
"or",
"an",
"error"
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/yarpcconfig/configurator.go#L358-L364 |
10,519 | yarpc/yarpc-go | internal/crossdock/server/yarpc/phone.go | Phone | func Phone(ctx context.Context, body *PhoneRequest) (*PhoneResponse, error) {
var outbound transport.UnaryOutbound
httpTransport := http.NewTransport()
tchannelTransport, err := tchannel.NewChannelTransport(tchannel.ServiceName("yarpc-test-client"))
if err != nil {
return nil, fmt.Errorf("failed to build ChannelTransport: %v", err)
}
switch {
case body.Transport.HTTP != nil:
t := body.Transport.HTTP
outbound = httpTransport.NewSingleOutbound(fmt.Sprintf("http://%s:%d", t.Host, t.Port))
case body.Transport.TChannel != nil:
t := body.Transport.TChannel
hostport := fmt.Sprintf("%s:%d", t.Host, t.Port)
outbound = tchannelTransport.NewSingleOutbound(hostport)
default:
return nil, fmt.Errorf("unconfigured transport")
}
if err := outbound.Start(); err != nil {
return nil, err
}
defer outbound.Stop()
// TODO use yarpc.Service for caller
client := json.New(clientconfig.MultiOutbound("yarpc-test", body.Service, transport.Outbounds{
Unary: outbound,
}))
resBody := PhoneResponse{
Service: "yarpc-test", // TODO use yarpc.Service
Procedure: yarpc.CallFromContext(ctx).Procedure(),
}
ctx, cancel := context.WithTimeout(ctx, 500*time.Millisecond)
defer cancel()
if err := client.Call(ctx, body.Procedure, body.Body, &resBody.Body); err != nil {
return nil, err
}
return &resBody, nil
} | go | func Phone(ctx context.Context, body *PhoneRequest) (*PhoneResponse, error) {
var outbound transport.UnaryOutbound
httpTransport := http.NewTransport()
tchannelTransport, err := tchannel.NewChannelTransport(tchannel.ServiceName("yarpc-test-client"))
if err != nil {
return nil, fmt.Errorf("failed to build ChannelTransport: %v", err)
}
switch {
case body.Transport.HTTP != nil:
t := body.Transport.HTTP
outbound = httpTransport.NewSingleOutbound(fmt.Sprintf("http://%s:%d", t.Host, t.Port))
case body.Transport.TChannel != nil:
t := body.Transport.TChannel
hostport := fmt.Sprintf("%s:%d", t.Host, t.Port)
outbound = tchannelTransport.NewSingleOutbound(hostport)
default:
return nil, fmt.Errorf("unconfigured transport")
}
if err := outbound.Start(); err != nil {
return nil, err
}
defer outbound.Stop()
// TODO use yarpc.Service for caller
client := json.New(clientconfig.MultiOutbound("yarpc-test", body.Service, transport.Outbounds{
Unary: outbound,
}))
resBody := PhoneResponse{
Service: "yarpc-test", // TODO use yarpc.Service
Procedure: yarpc.CallFromContext(ctx).Procedure(),
}
ctx, cancel := context.WithTimeout(ctx, 500*time.Millisecond)
defer cancel()
if err := client.Call(ctx, body.Procedure, body.Body, &resBody.Body); err != nil {
return nil, err
}
return &resBody, nil
} | [
"func",
"Phone",
"(",
"ctx",
"context",
".",
"Context",
",",
"body",
"*",
"PhoneRequest",
")",
"(",
"*",
"PhoneResponse",
",",
"error",
")",
"{",
"var",
"outbound",
"transport",
".",
"UnaryOutbound",
"\n\n",
"httpTransport",
":=",
"http",
".",
"NewTransport"... | // Phone implements the phone procedure | [
"Phone",
"implements",
"the",
"phone",
"procedure"
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/server/yarpc/phone.go#L71-L114 |
10,520 | yarpc/yarpc-go | internal/crossdock/server/start.go | Start | func Start() {
tch.Start()
yarpc.Start()
http.Start()
apachethrift.Start()
oneway.Start()
googlegrpc.Start()
} | go | func Start() {
tch.Start()
yarpc.Start()
http.Start()
apachethrift.Start()
oneway.Start()
googlegrpc.Start()
} | [
"func",
"Start",
"(",
")",
"{",
"tch",
".",
"Start",
"(",
")",
"\n",
"yarpc",
".",
"Start",
"(",
")",
"\n",
"http",
".",
"Start",
"(",
")",
"\n",
"apachethrift",
".",
"Start",
"(",
")",
"\n",
"oneway",
".",
"Start",
"(",
")",
"\n",
"googlegrpc",
... | // Start starts all required Crossdock test servers | [
"Start",
"starts",
"all",
"required",
"Crossdock",
"test",
"servers"
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/server/start.go#L33-L40 |
10,521 | yarpc/yarpc-go | internal/crossdock/server/start.go | Stop | func Stop() {
tch.Stop()
yarpc.Stop()
http.Stop()
apachethrift.Stop()
oneway.Stop()
googlegrpc.Stop()
} | go | func Stop() {
tch.Stop()
yarpc.Stop()
http.Stop()
apachethrift.Stop()
oneway.Stop()
googlegrpc.Stop()
} | [
"func",
"Stop",
"(",
")",
"{",
"tch",
".",
"Stop",
"(",
")",
"\n",
"yarpc",
".",
"Stop",
"(",
")",
"\n",
"http",
".",
"Stop",
"(",
")",
"\n",
"apachethrift",
".",
"Stop",
"(",
")",
"\n",
"oneway",
".",
"Stop",
"(",
")",
"\n",
"googlegrpc",
".",... | // Stop stops all required Crossdock test servers | [
"Stop",
"stops",
"all",
"required",
"Crossdock",
"test",
"servers"
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/server/start.go#L43-L50 |
10,522 | yarpc/yarpc-go | encoding/thrift/thriftrw-plugin-yarpc/template.go | AllFunctions | func (s *Svc) AllFunctions() []*api.Function {
var (
functions []*api.Function
added = make(map[string]struct{})
services = append([]*Svc{s}, s.Parents...)
)
for _, s := range services {
for _, f := range s.Functions {
if _, taken := added[f.ThriftName]; taken {
continue
}
functions = append(functions, f)
}
}
return functions
} | go | func (s *Svc) AllFunctions() []*api.Function {
var (
functions []*api.Function
added = make(map[string]struct{})
services = append([]*Svc{s}, s.Parents...)
)
for _, s := range services {
for _, f := range s.Functions {
if _, taken := added[f.ThriftName]; taken {
continue
}
functions = append(functions, f)
}
}
return functions
} | [
"func",
"(",
"s",
"*",
"Svc",
")",
"AllFunctions",
"(",
")",
"[",
"]",
"*",
"api",
".",
"Function",
"{",
"var",
"(",
"functions",
"[",
"]",
"*",
"api",
".",
"Function",
"\n",
"added",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"struct",
"{",
... | // AllFunctions returns a list of all functions for this service including
// inherited functions. | [
"AllFunctions",
"returns",
"a",
"list",
"of",
"all",
"functions",
"for",
"this",
"service",
"including",
"inherited",
"functions",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/encoding/thrift/thriftrw-plugin-yarpc/template.go#L45-L63 |
10,523 | yarpc/yarpc-go | encoding/thrift/thriftrw-plugin-yarpc/template.go | Parent | func (s *Svc) Parent() *api.Service {
if len(s.Parents) > 0 {
return s.Parents[0].Service
}
return nil
} | go | func (s *Svc) Parent() *api.Service {
if len(s.Parents) > 0 {
return s.Parents[0].Service
}
return nil
} | [
"func",
"(",
"s",
"*",
"Svc",
")",
"Parent",
"(",
")",
"*",
"api",
".",
"Service",
"{",
"if",
"len",
"(",
"s",
".",
"Parents",
")",
">",
"0",
"{",
"return",
"s",
".",
"Parents",
"[",
"0",
"]",
".",
"Service",
"\n",
"}",
"\n",
"return",
"nil",... | // Parent returns the immediate parent of this service or nil if it doesn't
// have any. | [
"Parent",
"returns",
"the",
"immediate",
"parent",
"of",
"this",
"service",
"or",
"nil",
"if",
"it",
"doesn",
"t",
"have",
"any",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/encoding/thrift/thriftrw-plugin-yarpc/template.go#L67-L72 |
10,524 | yarpc/yarpc-go | encoding/thrift/thriftrw-plugin-yarpc/template.go | ServerPackagePath | func (s *Svc) ServerPackagePath() string {
return fmt.Sprintf("%s/%sserver", s.Module.ImportPath, strings.ToLower(s.Name))
} | go | func (s *Svc) ServerPackagePath() string {
return fmt.Sprintf("%s/%sserver", s.Module.ImportPath, strings.ToLower(s.Name))
} | [
"func",
"(",
"s",
"*",
"Svc",
")",
"ServerPackagePath",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"s",
".",
"Module",
".",
"ImportPath",
",",
"strings",
".",
"ToLower",
"(",
"s",
".",
"Name",
")",
")",
"\n",
... | // ServerPackagePath returns the import path to the server package for this
// service. | [
"ServerPackagePath",
"returns",
"the",
"import",
"path",
"to",
"the",
"server",
"package",
"for",
"this",
"service",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/encoding/thrift/thriftrw-plugin-yarpc/template.go#L76-L78 |
10,525 | yarpc/yarpc-go | encoding/thrift/thriftrw-plugin-yarpc/template.go | ParentServerPackagePath | func (d *templateData) ParentServerPackagePath() string {
if len(d.Parents) == 0 {
return ""
}
return d.Parents[0].ServerPackagePath()
} | go | func (d *templateData) ParentServerPackagePath() string {
if len(d.Parents) == 0 {
return ""
}
return d.Parents[0].ServerPackagePath()
} | [
"func",
"(",
"d",
"*",
"templateData",
")",
"ParentServerPackagePath",
"(",
")",
"string",
"{",
"if",
"len",
"(",
"d",
".",
"Parents",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"d",
".",
"Parents",
"[",
"0",
"]",
".",
... | // ParentServerPackagePath returns the import path for the immediate parent
// service's YARPC server package or an empty string if this service doesn't
// extend another service. | [
"ParentServerPackagePath",
"returns",
"the",
"import",
"path",
"for",
"the",
"immediate",
"parent",
"service",
"s",
"YARPC",
"server",
"package",
"or",
"an",
"empty",
"string",
"if",
"this",
"service",
"doesn",
"t",
"extend",
"another",
"service",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/encoding/thrift/thriftrw-plugin-yarpc/template.go#L113-L118 |
10,526 | yarpc/yarpc-go | encoding/thrift/thriftrw-plugin-yarpc/template.go | ParentClientPackagePath | func (d *templateData) ParentClientPackagePath() string {
if len(d.Parents) == 0 {
return ""
}
return d.Parents[0].ClientPackagePath()
} | go | func (d *templateData) ParentClientPackagePath() string {
if len(d.Parents) == 0 {
return ""
}
return d.Parents[0].ClientPackagePath()
} | [
"func",
"(",
"d",
"*",
"templateData",
")",
"ParentClientPackagePath",
"(",
")",
"string",
"{",
"if",
"len",
"(",
"d",
".",
"Parents",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"d",
".",
"Parents",
"[",
"0",
"]",
".",
... | // ParentClientPackagePath returns the import path for the immediate parent
// service's YARPC client package or an empty string if this service doesn't
// extend another service. | [
"ParentClientPackagePath",
"returns",
"the",
"import",
"path",
"for",
"the",
"immediate",
"parent",
"service",
"s",
"YARPC",
"client",
"package",
"or",
"an",
"empty",
"string",
"if",
"this",
"service",
"doesn",
"t",
"extend",
"another",
"service",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/encoding/thrift/thriftrw-plugin-yarpc/template.go#L123-L128 |
10,527 | yarpc/yarpc-go | internal/crossdock/client/googlegrpcclient/googlegrpcclient.go | Run | func Run(t crossdock.T) {
fatals := crossdock.Fatals(t)
server := t.Param(params.Server)
fatals.NotEmpty(server, "server is required")
clientConn, err := ggrpc.Dial(fmt.Sprintf("%s:8089", server), ggrpc.WithInsecure())
fatals.NoError(err, "grpc.Dial failed")
client := crossdockpb.NewEchoClient(clientConn)
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
token := random.String(5)
pong, err := client.Echo(wrap(ctx), &crossdockpb.Ping{Beep: token})
crossdock.Fatals(t).NoError(err, "call to Echo::echo failed: %v", err)
crossdock.Assert(t).Equal(token, pong.Boop, "server said: %v", pong.Boop)
} | go | func Run(t crossdock.T) {
fatals := crossdock.Fatals(t)
server := t.Param(params.Server)
fatals.NotEmpty(server, "server is required")
clientConn, err := ggrpc.Dial(fmt.Sprintf("%s:8089", server), ggrpc.WithInsecure())
fatals.NoError(err, "grpc.Dial failed")
client := crossdockpb.NewEchoClient(clientConn)
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
token := random.String(5)
pong, err := client.Echo(wrap(ctx), &crossdockpb.Ping{Beep: token})
crossdock.Fatals(t).NoError(err, "call to Echo::echo failed: %v", err)
crossdock.Assert(t).Equal(token, pong.Boop, "server said: %v", pong.Boop)
} | [
"func",
"Run",
"(",
"t",
"crossdock",
".",
"T",
")",
"{",
"fatals",
":=",
"crossdock",
".",
"Fatals",
"(",
"t",
")",
"\n\n",
"server",
":=",
"t",
".",
"Param",
"(",
"params",
".",
"Server",
")",
"\n",
"fatals",
".",
"NotEmpty",
"(",
"server",
",",
... | // Run tests a grpc-go call to the yarpc server. | [
"Run",
"tests",
"a",
"grpc",
"-",
"go",
"call",
"to",
"the",
"yarpc",
"server",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/client/googlegrpcclient/googlegrpcclient.go#L42-L62 |
10,528 | yarpc/yarpc-go | introspection.go | Introspect | func (d *Dispatcher) Introspect() introspection.DispatcherStatus {
var inbounds []introspection.InboundStatus
for _, i := range d.inbounds {
var status introspection.InboundStatus
if i, ok := i.(introspection.IntrospectableInbound); ok {
status = i.Introspect()
} else {
status = introspection.InboundStatus{
Transport: "Introspection not supported",
}
}
inbounds = append(inbounds, status)
}
var outbounds []introspection.OutboundStatus
for outboundKey, o := range d.outbounds {
if o.Unary != nil {
var status introspection.OutboundStatus
if o, ok := o.Unary.(introspection.IntrospectableOutbound); ok {
status = o.Introspect()
} else {
status.Transport = "Introspection not supported"
}
status.RPCType = "unary"
status.Service = o.ServiceName
status.OutboundKey = outboundKey
outbounds = append(outbounds, status)
}
if o.Oneway != nil {
var status introspection.OutboundStatus
if o, ok := o.Oneway.(introspection.IntrospectableOutbound); ok {
status = o.Introspect()
} else {
status.Transport = "Introspection not supported"
}
status.RPCType = "oneway"
status.Service = o.ServiceName
status.OutboundKey = outboundKey
outbounds = append(outbounds, status)
}
}
procedures := introspection.IntrospectProcedures(d.table.Procedures())
return introspection.DispatcherStatus{
Name: d.name,
ID: fmt.Sprintf("%p", d),
Procedures: procedures,
Inbounds: inbounds,
Outbounds: outbounds,
PackageVersions: PackageVersions,
}
} | go | func (d *Dispatcher) Introspect() introspection.DispatcherStatus {
var inbounds []introspection.InboundStatus
for _, i := range d.inbounds {
var status introspection.InboundStatus
if i, ok := i.(introspection.IntrospectableInbound); ok {
status = i.Introspect()
} else {
status = introspection.InboundStatus{
Transport: "Introspection not supported",
}
}
inbounds = append(inbounds, status)
}
var outbounds []introspection.OutboundStatus
for outboundKey, o := range d.outbounds {
if o.Unary != nil {
var status introspection.OutboundStatus
if o, ok := o.Unary.(introspection.IntrospectableOutbound); ok {
status = o.Introspect()
} else {
status.Transport = "Introspection not supported"
}
status.RPCType = "unary"
status.Service = o.ServiceName
status.OutboundKey = outboundKey
outbounds = append(outbounds, status)
}
if o.Oneway != nil {
var status introspection.OutboundStatus
if o, ok := o.Oneway.(introspection.IntrospectableOutbound); ok {
status = o.Introspect()
} else {
status.Transport = "Introspection not supported"
}
status.RPCType = "oneway"
status.Service = o.ServiceName
status.OutboundKey = outboundKey
outbounds = append(outbounds, status)
}
}
procedures := introspection.IntrospectProcedures(d.table.Procedures())
return introspection.DispatcherStatus{
Name: d.name,
ID: fmt.Sprintf("%p", d),
Procedures: procedures,
Inbounds: inbounds,
Outbounds: outbounds,
PackageVersions: PackageVersions,
}
} | [
"func",
"(",
"d",
"*",
"Dispatcher",
")",
"Introspect",
"(",
")",
"introspection",
".",
"DispatcherStatus",
"{",
"var",
"inbounds",
"[",
"]",
"introspection",
".",
"InboundStatus",
"\n",
"for",
"_",
",",
"i",
":=",
"range",
"d",
".",
"inbounds",
"{",
"va... | // Introspect returns detailed information about the dispatcher. This function
// acquires a lots of locks throughout and should only be called with some
// reserve. This method is public merely for use by the package yarpcmeta. The
// result of this function is internal to yarpc anyway. | [
"Introspect",
"returns",
"detailed",
"information",
"about",
"the",
"dispatcher",
".",
"This",
"function",
"acquires",
"a",
"lots",
"of",
"locks",
"throughout",
"and",
"should",
"only",
"be",
"called",
"with",
"some",
"reserve",
".",
"This",
"method",
"is",
"p... | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/introspection.go#L36-L85 |
10,529 | yarpc/yarpc-go | internal/net/httpserver.go | NewHTTPServer | func NewHTTPServer(s *http.Server) *HTTPServer {
return &HTTPServer{
Server: s,
done: make(chan error, 1),
}
} | go | func NewHTTPServer(s *http.Server) *HTTPServer {
return &HTTPServer{
Server: s,
done: make(chan error, 1),
}
} | [
"func",
"NewHTTPServer",
"(",
"s",
"*",
"http",
".",
"Server",
")",
"*",
"HTTPServer",
"{",
"return",
"&",
"HTTPServer",
"{",
"Server",
":",
"s",
",",
"done",
":",
"make",
"(",
"chan",
"error",
",",
"1",
")",
",",
"}",
"\n",
"}"
] | // NewHTTPServer wraps the given http.Server into an HTTPServer. | [
"NewHTTPServer",
"wraps",
"the",
"given",
"http",
".",
"Server",
"into",
"an",
"HTTPServer",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/net/httpserver.go#L50-L55 |
10,530 | yarpc/yarpc-go | internal/net/httpserver.go | Listener | func (h *HTTPServer) Listener() net.Listener {
h.lock.RLock()
listener := h.listener
h.lock.RUnlock()
return listener
} | go | func (h *HTTPServer) Listener() net.Listener {
h.lock.RLock()
listener := h.listener
h.lock.RUnlock()
return listener
} | [
"func",
"(",
"h",
"*",
"HTTPServer",
")",
"Listener",
"(",
")",
"net",
".",
"Listener",
"{",
"h",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"listener",
":=",
"h",
".",
"listener",
"\n",
"h",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n",
"return",... | // Listener returns the listener for this server or nil if the server isn't
// yet listening. | [
"Listener",
"returns",
"the",
"listener",
"for",
"this",
"server",
"or",
"nil",
"if",
"the",
"server",
"isn",
"t",
"yet",
"listening",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/net/httpserver.go#L59-L64 |
10,531 | yarpc/yarpc-go | internal/net/httpserver.go | Shutdown | func (h *HTTPServer) Shutdown(ctx context.Context) error {
if h.stopped.Swap(true) {
return nil
}
wasRunning, closeErr := h.shutdownServer(ctx)
if !wasRunning {
return nil
}
serveErr := <-h.done // wait until Serve() stops
if closeErr != nil {
return closeErr
}
return serveErr
} | go | func (h *HTTPServer) Shutdown(ctx context.Context) error {
if h.stopped.Swap(true) {
return nil
}
wasRunning, closeErr := h.shutdownServer(ctx)
if !wasRunning {
return nil
}
serveErr := <-h.done // wait until Serve() stops
if closeErr != nil {
return closeErr
}
return serveErr
} | [
"func",
"(",
"h",
"*",
"HTTPServer",
")",
"Shutdown",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"if",
"h",
".",
"stopped",
".",
"Swap",
"(",
"true",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"wasRunning",
",",
"closeErr",
":=",
... | // Shutdown stops the server. An error is returned if the server stopped
// unexpectedly.
//
// Once a server is stopped, it cannot be started again with ListenAndServe. | [
"Shutdown",
"stops",
"the",
"server",
".",
"An",
"error",
"is",
"returned",
"if",
"the",
"server",
"stopped",
"unexpectedly",
".",
"Once",
"a",
"server",
"is",
"stopped",
"it",
"cannot",
"be",
"started",
"again",
"with",
"ListenAndServe",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/net/httpserver.go#L114-L129 |
10,532 | yarpc/yarpc-go | transport/grpc/dialer.go | NewDialer | func (t *Transport) NewDialer(options ...DialOption) *Dialer {
return &Dialer{trans: t, options: newDialOptions(options)}
} | go | func (t *Transport) NewDialer(options ...DialOption) *Dialer {
return &Dialer{trans: t, options: newDialOptions(options)}
} | [
"func",
"(",
"t",
"*",
"Transport",
")",
"NewDialer",
"(",
"options",
"...",
"DialOption",
")",
"*",
"Dialer",
"{",
"return",
"&",
"Dialer",
"{",
"trans",
":",
"t",
",",
"options",
":",
"newDialOptions",
"(",
"options",
")",
"}",
"\n",
"}"
] | // NewDialer creates a transport that is decorated to retain peers with
// additional gRPC dial options. | [
"NewDialer",
"creates",
"a",
"transport",
"that",
"is",
"decorated",
"to",
"retain",
"peers",
"with",
"additional",
"gRPC",
"dial",
"options",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/transport/grpc/dialer.go#L29-L31 |
10,533 | yarpc/yarpc-go | transport/grpc/dialer.go | RetainPeer | func (d *Dialer) RetainPeer(id peer.Identifier, ps peer.Subscriber) (peer.Peer, error) {
return d.trans.retainPeer(id, d.options, ps)
} | go | func (d *Dialer) RetainPeer(id peer.Identifier, ps peer.Subscriber) (peer.Peer, error) {
return d.trans.retainPeer(id, d.options, ps)
} | [
"func",
"(",
"d",
"*",
"Dialer",
")",
"RetainPeer",
"(",
"id",
"peer",
".",
"Identifier",
",",
"ps",
"peer",
".",
"Subscriber",
")",
"(",
"peer",
".",
"Peer",
",",
"error",
")",
"{",
"return",
"d",
".",
"trans",
".",
"retainPeer",
"(",
"id",
",",
... | // RetainPeer retains the identified peer, passing dial options. | [
"RetainPeer",
"retains",
"the",
"identified",
"peer",
"passing",
"dial",
"options",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/transport/grpc/dialer.go#L43-L45 |
10,534 | yarpc/yarpc-go | transport/grpc/dialer.go | ReleasePeer | func (d *Dialer) ReleasePeer(id peer.Identifier, ps peer.Subscriber) error {
return d.trans.ReleasePeer(id, ps)
} | go | func (d *Dialer) ReleasePeer(id peer.Identifier, ps peer.Subscriber) error {
return d.trans.ReleasePeer(id, ps)
} | [
"func",
"(",
"d",
"*",
"Dialer",
")",
"ReleasePeer",
"(",
"id",
"peer",
".",
"Identifier",
",",
"ps",
"peer",
".",
"Subscriber",
")",
"error",
"{",
"return",
"d",
".",
"trans",
".",
"ReleasePeer",
"(",
"id",
",",
"ps",
")",
"\n",
"}"
] | // ReleasePeer releases the identified peer. | [
"ReleasePeer",
"releases",
"the",
"identified",
"peer",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/transport/grpc/dialer.go#L48-L50 |
10,535 | yarpc/yarpc-go | internal/examples/protobuf/example/example.go | GetValue | func (k *KeyValueYARPCServer) GetValue(ctx context.Context, request *examplepb.GetValueRequest) (*examplepb.GetValueResponse, error) {
if request == nil {
return nil, errRequestNil
}
if request.Key == "" {
return nil, errRequestKeyNil
}
k.RLock()
if value, ok := k.items[request.Key]; ok {
k.RUnlock()
var nextError error
k.Lock()
if k.nextError != nil {
nextError = k.nextError
k.nextError = nil
}
k.Unlock()
return &examplepb.GetValueResponse{Value: value}, nextError
}
k.RUnlock()
return nil, yarpcerrors.Newf(yarpcerrors.CodeNotFound, request.Key)
} | go | func (k *KeyValueYARPCServer) GetValue(ctx context.Context, request *examplepb.GetValueRequest) (*examplepb.GetValueResponse, error) {
if request == nil {
return nil, errRequestNil
}
if request.Key == "" {
return nil, errRequestKeyNil
}
k.RLock()
if value, ok := k.items[request.Key]; ok {
k.RUnlock()
var nextError error
k.Lock()
if k.nextError != nil {
nextError = k.nextError
k.nextError = nil
}
k.Unlock()
return &examplepb.GetValueResponse{Value: value}, nextError
}
k.RUnlock()
return nil, yarpcerrors.Newf(yarpcerrors.CodeNotFound, request.Key)
} | [
"func",
"(",
"k",
"*",
"KeyValueYARPCServer",
")",
"GetValue",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"examplepb",
".",
"GetValueRequest",
")",
"(",
"*",
"examplepb",
".",
"GetValueResponse",
",",
"error",
")",
"{",
"if",
"request",
"=... | // GetValue implements GetValue. | [
"GetValue",
"implements",
"GetValue",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/protobuf/example/example.go#L63-L84 |
10,536 | yarpc/yarpc-go | internal/examples/protobuf/example/example.go | SetValue | func (k *KeyValueYARPCServer) SetValue(ctx context.Context, request *examplepb.SetValueRequest) (*examplepb.SetValueResponse, error) {
if request == nil {
return nil, errRequestNil
}
if request.Key == "" {
return nil, errRequestKeyNil
}
k.Lock()
if request.Value == "" {
delete(k.items, request.Key)
} else {
k.items[request.Key] = request.Value
}
var nextError error
if k.nextError != nil {
nextError = k.nextError
k.nextError = nil
}
k.Unlock()
return nil, nextError
} | go | func (k *KeyValueYARPCServer) SetValue(ctx context.Context, request *examplepb.SetValueRequest) (*examplepb.SetValueResponse, error) {
if request == nil {
return nil, errRequestNil
}
if request.Key == "" {
return nil, errRequestKeyNil
}
k.Lock()
if request.Value == "" {
delete(k.items, request.Key)
} else {
k.items[request.Key] = request.Value
}
var nextError error
if k.nextError != nil {
nextError = k.nextError
k.nextError = nil
}
k.Unlock()
return nil, nextError
} | [
"func",
"(",
"k",
"*",
"KeyValueYARPCServer",
")",
"SetValue",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"examplepb",
".",
"SetValueRequest",
")",
"(",
"*",
"examplepb",
".",
"SetValueResponse",
",",
"error",
")",
"{",
"if",
"request",
"=... | // SetValue implements SetValue. | [
"SetValue",
"implements",
"SetValue",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/protobuf/example/example.go#L87-L107 |
10,537 | yarpc/yarpc-go | internal/examples/protobuf/example/example.go | SetNextError | func (k *KeyValueYARPCServer) SetNextError(err error) {
k.Lock()
defer k.Unlock()
k.nextError = err
} | go | func (k *KeyValueYARPCServer) SetNextError(err error) {
k.Lock()
defer k.Unlock()
k.nextError = err
} | [
"func",
"(",
"k",
"*",
"KeyValueYARPCServer",
")",
"SetNextError",
"(",
"err",
"error",
")",
"{",
"k",
".",
"Lock",
"(",
")",
"\n",
"defer",
"k",
".",
"Unlock",
"(",
")",
"\n",
"k",
".",
"nextError",
"=",
"err",
"\n",
"}"
] | // SetNextError sets the error to return on the next call to KeyValueYARPCServer. | [
"SetNextError",
"sets",
"the",
"error",
"to",
"return",
"on",
"the",
"next",
"call",
"to",
"KeyValueYARPCServer",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/protobuf/example/example.go#L110-L114 |
10,538 | yarpc/yarpc-go | internal/examples/protobuf/example/example.go | NewSinkYARPCServer | func NewSinkYARPCServer(withFireDone bool) *SinkYARPCServer {
var fireDone chan struct{}
if withFireDone {
fireDone = make(chan struct{})
}
return &SinkYARPCServer{sync.RWMutex{}, make([]string, 0), fireDone}
} | go | func NewSinkYARPCServer(withFireDone bool) *SinkYARPCServer {
var fireDone chan struct{}
if withFireDone {
fireDone = make(chan struct{})
}
return &SinkYARPCServer{sync.RWMutex{}, make([]string, 0), fireDone}
} | [
"func",
"NewSinkYARPCServer",
"(",
"withFireDone",
"bool",
")",
"*",
"SinkYARPCServer",
"{",
"var",
"fireDone",
"chan",
"struct",
"{",
"}",
"\n",
"if",
"withFireDone",
"{",
"fireDone",
"=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n",
"}",
"\n",
"... | // NewSinkYARPCServer returns a new SinkYARPCServer. | [
"NewSinkYARPCServer",
"returns",
"a",
"new",
"SinkYARPCServer",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/protobuf/example/example.go#L124-L130 |
10,539 | yarpc/yarpc-go | internal/examples/protobuf/example/example.go | Fire | func (s *SinkYARPCServer) Fire(ctx context.Context, request *examplepb.FireRequest) error {
if request == nil {
return errRequestNil
}
if request.Value == "" {
return errRequestValueNil
}
s.Lock()
s.values = append(s.values, request.Value)
s.Unlock()
if s.fireDone == nil {
return nil
}
select {
case s.fireDone <- struct{}{}:
case <-time.After(FireDoneTimeout):
return yarpcerrors.Newf(yarpcerrors.CodeDeadlineExceeded, "fire done not handled after %v", FireDoneTimeout)
}
return nil
} | go | func (s *SinkYARPCServer) Fire(ctx context.Context, request *examplepb.FireRequest) error {
if request == nil {
return errRequestNil
}
if request.Value == "" {
return errRequestValueNil
}
s.Lock()
s.values = append(s.values, request.Value)
s.Unlock()
if s.fireDone == nil {
return nil
}
select {
case s.fireDone <- struct{}{}:
case <-time.After(FireDoneTimeout):
return yarpcerrors.Newf(yarpcerrors.CodeDeadlineExceeded, "fire done not handled after %v", FireDoneTimeout)
}
return nil
} | [
"func",
"(",
"s",
"*",
"SinkYARPCServer",
")",
"Fire",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"examplepb",
".",
"FireRequest",
")",
"error",
"{",
"if",
"request",
"==",
"nil",
"{",
"return",
"errRequestNil",
"\n",
"}",
"\n",
"if",
... | // Fire implements Fire. | [
"Fire",
"implements",
"Fire",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/protobuf/example/example.go#L133-L152 |
10,540 | yarpc/yarpc-go | internal/examples/protobuf/example/example.go | Values | func (s *SinkYARPCServer) Values() []string {
s.RLock()
values := make([]string, len(s.values))
copy(values, s.values)
s.RUnlock()
return values
} | go | func (s *SinkYARPCServer) Values() []string {
s.RLock()
values := make([]string, len(s.values))
copy(values, s.values)
s.RUnlock()
return values
} | [
"func",
"(",
"s",
"*",
"SinkYARPCServer",
")",
"Values",
"(",
")",
"[",
"]",
"string",
"{",
"s",
".",
"RLock",
"(",
")",
"\n",
"values",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"s",
".",
"values",
")",
")",
"\n",
"copy",
"(",
... | // Values returns a copy of the values that have been fired. | [
"Values",
"returns",
"a",
"copy",
"of",
"the",
"values",
"that",
"have",
"been",
"fired",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/protobuf/example/example.go#L155-L161 |
10,541 | yarpc/yarpc-go | internal/examples/protobuf/example/example.go | WaitFireDone | func (s *SinkYARPCServer) WaitFireDone() error {
if s.fireDone == nil {
return nil
}
select {
case <-s.fireDone:
case <-time.After(FireDoneTimeout):
return yarpcerrors.Newf(yarpcerrors.CodeDeadlineExceeded, "fire not done after %v", FireDoneTimeout)
}
return nil
} | go | func (s *SinkYARPCServer) WaitFireDone() error {
if s.fireDone == nil {
return nil
}
select {
case <-s.fireDone:
case <-time.After(FireDoneTimeout):
return yarpcerrors.Newf(yarpcerrors.CodeDeadlineExceeded, "fire not done after %v", FireDoneTimeout)
}
return nil
} | [
"func",
"(",
"s",
"*",
"SinkYARPCServer",
")",
"WaitFireDone",
"(",
")",
"error",
"{",
"if",
"s",
".",
"fireDone",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"select",
"{",
"case",
"<-",
"s",
".",
"fireDone",
":",
"case",
"<-",
"time",
"."... | // WaitFireDone blocks until a fire is done, if withFireDone is set.
//
// If will timeout after FireDoneTimeout and return error. | [
"WaitFireDone",
"blocks",
"until",
"a",
"fire",
"is",
"done",
"if",
"withFireDone",
"is",
"set",
".",
"If",
"will",
"timeout",
"after",
"FireDoneTimeout",
"and",
"return",
"error",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/protobuf/example/example.go#L166-L176 |
10,542 | yarpc/yarpc-go | internal/examples/protobuf/example/example.go | EchoOut | func (f *FooYARPCServer) EchoOut(server examplepb.FooServiceEchoOutYARPCServer) (*examplepb.EchoOutResponse, error) {
var allMessages []string
call := yarpc.CallFromContext(server.Context())
for k, v := range f.expectedHeaders.Items() {
if call.Header(k) != v {
return nil, yarpcerrors.InvalidArgumentErrorf("did not receive proper headers, missing %q:%q", k, v)
}
}
for request, err := server.Recv(); err != io.EOF; request, err = server.Recv() {
if err != nil {
return nil, err
}
if request == nil {
return nil, errRequestNil
}
if request.Message == "" {
return nil, errRequestMessageNil
}
allMessages = append(allMessages, request.Message)
}
return &examplepb.EchoOutResponse{
AllMessages: allMessages,
}, nil
} | go | func (f *FooYARPCServer) EchoOut(server examplepb.FooServiceEchoOutYARPCServer) (*examplepb.EchoOutResponse, error) {
var allMessages []string
call := yarpc.CallFromContext(server.Context())
for k, v := range f.expectedHeaders.Items() {
if call.Header(k) != v {
return nil, yarpcerrors.InvalidArgumentErrorf("did not receive proper headers, missing %q:%q", k, v)
}
}
for request, err := server.Recv(); err != io.EOF; request, err = server.Recv() {
if err != nil {
return nil, err
}
if request == nil {
return nil, errRequestNil
}
if request.Message == "" {
return nil, errRequestMessageNil
}
allMessages = append(allMessages, request.Message)
}
return &examplepb.EchoOutResponse{
AllMessages: allMessages,
}, nil
} | [
"func",
"(",
"f",
"*",
"FooYARPCServer",
")",
"EchoOut",
"(",
"server",
"examplepb",
".",
"FooServiceEchoOutYARPCServer",
")",
"(",
"*",
"examplepb",
".",
"EchoOutResponse",
",",
"error",
")",
"{",
"var",
"allMessages",
"[",
"]",
"string",
"\n",
"call",
":="... | // EchoOut reads from a stream and echos all requests in the response. | [
"EchoOut",
"reads",
"from",
"a",
"stream",
"and",
"echos",
"all",
"requests",
"in",
"the",
"response",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/protobuf/example/example.go#L191-L214 |
10,543 | yarpc/yarpc-go | internal/examples/protobuf/example/example.go | EchoIn | func (f *FooYARPCServer) EchoIn(request *examplepb.EchoInRequest, server examplepb.FooServiceEchoInYARPCServer) error {
if request == nil {
return errRequestNil
}
if request.Message == "" {
return errRequestMessageNil
}
if request.NumResponses == 0 {
return errRequestNumResponsesNil
}
call := yarpc.CallFromContext(server.Context())
for k, v := range f.expectedHeaders.Items() {
if call.Header(k) != v {
return yarpcerrors.InvalidArgumentErrorf("did not receive proper headers, missing %q:%q", k, v)
}
}
for i := 0; i < int(request.NumResponses); i++ {
if err := server.Send(&examplepb.EchoInResponse{Message: request.Message}); err != nil {
return err
}
}
return nil
} | go | func (f *FooYARPCServer) EchoIn(request *examplepb.EchoInRequest, server examplepb.FooServiceEchoInYARPCServer) error {
if request == nil {
return errRequestNil
}
if request.Message == "" {
return errRequestMessageNil
}
if request.NumResponses == 0 {
return errRequestNumResponsesNil
}
call := yarpc.CallFromContext(server.Context())
for k, v := range f.expectedHeaders.Items() {
if call.Header(k) != v {
return yarpcerrors.InvalidArgumentErrorf("did not receive proper headers, missing %q:%q", k, v)
}
}
for i := 0; i < int(request.NumResponses); i++ {
if err := server.Send(&examplepb.EchoInResponse{Message: request.Message}); err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"f",
"*",
"FooYARPCServer",
")",
"EchoIn",
"(",
"request",
"*",
"examplepb",
".",
"EchoInRequest",
",",
"server",
"examplepb",
".",
"FooServiceEchoInYARPCServer",
")",
"error",
"{",
"if",
"request",
"==",
"nil",
"{",
"return",
"errRequestNil",
"\n... | // EchoIn echos a series of requests back on a stream. | [
"EchoIn",
"echos",
"a",
"series",
"of",
"requests",
"back",
"on",
"a",
"stream",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/protobuf/example/example.go#L217-L239 |
10,544 | yarpc/yarpc-go | internal/examples/protobuf/example/example.go | EchoBoth | func (f *FooYARPCServer) EchoBoth(server examplepb.FooServiceEchoBothYARPCServer) error {
call := yarpc.CallFromContext(server.Context())
for k, v := range f.expectedHeaders.Items() {
if call.Header(k) != v {
return yarpcerrors.InvalidArgumentErrorf("did not receive proper headers, missing %q:%q", k, v)
}
}
for request, err := server.Recv(); err != io.EOF; request, err = server.Recv() {
if err != nil {
return err
}
if request == nil {
return errRequestNil
}
if request.Message == "" {
return errRequestMessageNil
}
if request.NumResponses == 0 {
return errRequestNumResponsesNil
}
for i := 0; i < int(request.NumResponses); i++ {
if err := server.Send(&examplepb.EchoBothResponse{Message: request.Message}); err != nil {
return err
}
}
}
return nil
} | go | func (f *FooYARPCServer) EchoBoth(server examplepb.FooServiceEchoBothYARPCServer) error {
call := yarpc.CallFromContext(server.Context())
for k, v := range f.expectedHeaders.Items() {
if call.Header(k) != v {
return yarpcerrors.InvalidArgumentErrorf("did not receive proper headers, missing %q:%q", k, v)
}
}
for request, err := server.Recv(); err != io.EOF; request, err = server.Recv() {
if err != nil {
return err
}
if request == nil {
return errRequestNil
}
if request.Message == "" {
return errRequestMessageNil
}
if request.NumResponses == 0 {
return errRequestNumResponsesNil
}
for i := 0; i < int(request.NumResponses); i++ {
if err := server.Send(&examplepb.EchoBothResponse{Message: request.Message}); err != nil {
return err
}
}
}
return nil
} | [
"func",
"(",
"f",
"*",
"FooYARPCServer",
")",
"EchoBoth",
"(",
"server",
"examplepb",
".",
"FooServiceEchoBothYARPCServer",
")",
"error",
"{",
"call",
":=",
"yarpc",
".",
"CallFromContext",
"(",
"server",
".",
"Context",
"(",
")",
")",
"\n",
"for",
"k",
",... | // EchoBoth immediately echos a request back to the client. | [
"EchoBoth",
"immediately",
"echos",
"a",
"request",
"back",
"to",
"the",
"client",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/protobuf/example/example.go#L242-L269 |
10,545 | yarpc/yarpc-go | transport/tchannel/outbound.go | NewOutbound | func (t *Transport) NewOutbound(chooser peer.Chooser) *Outbound {
return &Outbound{
once: lifecycle.NewOnce(),
transport: t,
chooser: chooser,
}
} | go | func (t *Transport) NewOutbound(chooser peer.Chooser) *Outbound {
return &Outbound{
once: lifecycle.NewOnce(),
transport: t,
chooser: chooser,
}
} | [
"func",
"(",
"t",
"*",
"Transport",
")",
"NewOutbound",
"(",
"chooser",
"peer",
".",
"Chooser",
")",
"*",
"Outbound",
"{",
"return",
"&",
"Outbound",
"{",
"once",
":",
"lifecycle",
".",
"NewOnce",
"(",
")",
",",
"transport",
":",
"t",
",",
"chooser",
... | // NewOutbound builds a new TChannel outbound that selects a peer for each
// request using the given peer chooser. | [
"NewOutbound",
"builds",
"a",
"new",
"TChannel",
"outbound",
"that",
"selects",
"a",
"peer",
"for",
"each",
"request",
"using",
"the",
"given",
"peer",
"chooser",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/transport/tchannel/outbound.go#L56-L62 |
10,546 | yarpc/yarpc-go | transport/tchannel/outbound.go | NewSingleOutbound | func (t *Transport) NewSingleOutbound(addr string) *Outbound {
chooser := peerchooser.NewSingle(hostport.PeerIdentifier(addr), t)
return t.NewOutbound(chooser)
} | go | func (t *Transport) NewSingleOutbound(addr string) *Outbound {
chooser := peerchooser.NewSingle(hostport.PeerIdentifier(addr), t)
return t.NewOutbound(chooser)
} | [
"func",
"(",
"t",
"*",
"Transport",
")",
"NewSingleOutbound",
"(",
"addr",
"string",
")",
"*",
"Outbound",
"{",
"chooser",
":=",
"peerchooser",
".",
"NewSingle",
"(",
"hostport",
".",
"PeerIdentifier",
"(",
"addr",
")",
",",
"t",
")",
"\n",
"return",
"t"... | // NewSingleOutbound builds a new TChannel outbound always using the peer with
// the given address. | [
"NewSingleOutbound",
"builds",
"a",
"new",
"TChannel",
"outbound",
"always",
"using",
"the",
"peer",
"with",
"the",
"given",
"address",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/transport/tchannel/outbound.go#L66-L69 |
10,547 | yarpc/yarpc-go | transport/tchannel/outbound.go | Call | func (p *tchannelPeer) Call(ctx context.Context, req *transport.Request) (*transport.Response, error) {
root := p.transport.ch.RootPeers()
tp := root.GetOrAdd(p.HostPort())
return callWithPeer(ctx, req, tp, p.transport.headerCase)
} | go | func (p *tchannelPeer) Call(ctx context.Context, req *transport.Request) (*transport.Response, error) {
root := p.transport.ch.RootPeers()
tp := root.GetOrAdd(p.HostPort())
return callWithPeer(ctx, req, tp, p.transport.headerCase)
} | [
"func",
"(",
"p",
"*",
"tchannelPeer",
")",
"Call",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"transport",
".",
"Request",
")",
"(",
"*",
"transport",
".",
"Response",
",",
"error",
")",
"{",
"root",
":=",
"p",
".",
"transport",
".",
... | // Call sends an RPC to this specific peer. | [
"Call",
"sends",
"an",
"RPC",
"to",
"this",
"specific",
"peer",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/transport/tchannel/outbound.go#L97-L101 |
10,548 | yarpc/yarpc-go | transport/tchannel/outbound.go | callWithPeer | func callWithPeer(ctx context.Context, req *transport.Request, peer *tchannel.Peer, headerCase headerCase) (*transport.Response, error) {
// NB(abg): Under the current API, the local service's name is required
// twice: once when constructing the TChannel and then again when
// constructing the RPC.
var call *tchannel.OutboundCall
var err error
format := tchannel.Format(req.Encoding)
callOptions := tchannel.CallOptions{
Format: format,
ShardKey: req.ShardKey,
RoutingKey: req.RoutingKey,
RoutingDelegate: req.RoutingDelegate,
}
// If the hostport is given, we use the BeginCall on the channel
// instead of the subchannel.
call, err = peer.BeginCall(
// TODO(abg): Set TimeoutPerAttempt in the context's retry options if
// TTL is set.
// (kris): Consider instead moving TimeoutPerAttempt to an outer
// layer, just clamp the context on outbound call.
ctx,
req.Service,
req.Procedure,
&callOptions,
)
if err != nil {
return nil, err
}
reqHeaders := headerMap(req.Headers, headerCase)
// baggage headers are transport implementation details that are stripped out (and stored in the context). Users don't interact with it
tracingBaggage := tchannel.InjectOutboundSpan(call.Response(), nil)
if err := writeHeaders(format, reqHeaders, tracingBaggage, call.Arg2Writer); err != nil {
// TODO(abg): This will wrap IO errors while writing headers as encode
// errors. We should fix that.
return nil, errors.RequestHeadersEncodeError(req, err)
}
if err := writeBody(req.Body, call); err != nil {
return nil, err
}
res := call.Response()
headers, err := readHeaders(format, res.Arg2Reader)
if err != nil {
if err, ok := err.(tchannel.SystemError); ok {
return nil, fromSystemError(err)
}
// TODO(abg): This will wrap IO errors while reading headers as decode
// errors. We should fix that.
return nil, errors.ResponseHeadersDecodeError(req, err)
}
resBody, err := res.Arg3Reader()
if err != nil {
if err, ok := err.(tchannel.SystemError); ok {
return nil, fromSystemError(err)
}
return nil, err
}
respService, _ := headers.Get(ServiceHeaderKey) // validateServiceName handles empty strings
if err := validateServiceName(req.Service, respService); err != nil {
return nil, err
}
err = getResponseError(headers)
deleteReservedHeaders(headers)
resp := &transport.Response{
Headers: headers,
Body: resBody,
ApplicationError: res.ApplicationError(),
}
return resp, err
} | go | func callWithPeer(ctx context.Context, req *transport.Request, peer *tchannel.Peer, headerCase headerCase) (*transport.Response, error) {
// NB(abg): Under the current API, the local service's name is required
// twice: once when constructing the TChannel and then again when
// constructing the RPC.
var call *tchannel.OutboundCall
var err error
format := tchannel.Format(req.Encoding)
callOptions := tchannel.CallOptions{
Format: format,
ShardKey: req.ShardKey,
RoutingKey: req.RoutingKey,
RoutingDelegate: req.RoutingDelegate,
}
// If the hostport is given, we use the BeginCall on the channel
// instead of the subchannel.
call, err = peer.BeginCall(
// TODO(abg): Set TimeoutPerAttempt in the context's retry options if
// TTL is set.
// (kris): Consider instead moving TimeoutPerAttempt to an outer
// layer, just clamp the context on outbound call.
ctx,
req.Service,
req.Procedure,
&callOptions,
)
if err != nil {
return nil, err
}
reqHeaders := headerMap(req.Headers, headerCase)
// baggage headers are transport implementation details that are stripped out (and stored in the context). Users don't interact with it
tracingBaggage := tchannel.InjectOutboundSpan(call.Response(), nil)
if err := writeHeaders(format, reqHeaders, tracingBaggage, call.Arg2Writer); err != nil {
// TODO(abg): This will wrap IO errors while writing headers as encode
// errors. We should fix that.
return nil, errors.RequestHeadersEncodeError(req, err)
}
if err := writeBody(req.Body, call); err != nil {
return nil, err
}
res := call.Response()
headers, err := readHeaders(format, res.Arg2Reader)
if err != nil {
if err, ok := err.(tchannel.SystemError); ok {
return nil, fromSystemError(err)
}
// TODO(abg): This will wrap IO errors while reading headers as decode
// errors. We should fix that.
return nil, errors.ResponseHeadersDecodeError(req, err)
}
resBody, err := res.Arg3Reader()
if err != nil {
if err, ok := err.(tchannel.SystemError); ok {
return nil, fromSystemError(err)
}
return nil, err
}
respService, _ := headers.Get(ServiceHeaderKey) // validateServiceName handles empty strings
if err := validateServiceName(req.Service, respService); err != nil {
return nil, err
}
err = getResponseError(headers)
deleteReservedHeaders(headers)
resp := &transport.Response{
Headers: headers,
Body: resBody,
ApplicationError: res.ApplicationError(),
}
return resp, err
} | [
"func",
"callWithPeer",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"transport",
".",
"Request",
",",
"peer",
"*",
"tchannel",
".",
"Peer",
",",
"headerCase",
"headerCase",
")",
"(",
"*",
"transport",
".",
"Response",
",",
"error",
")",
"{",
... | // callWithPeer sends a request with the chosen peer. | [
"callWithPeer",
"sends",
"a",
"request",
"with",
"the",
"chosen",
"peer",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/transport/tchannel/outbound.go#L104-L182 |
10,549 | yarpc/yarpc-go | transport/tchannel/outbound.go | Start | func (o *Outbound) Start() error {
return o.once.Start(o.chooser.Start)
} | go | func (o *Outbound) Start() error {
return o.once.Start(o.chooser.Start)
} | [
"func",
"(",
"o",
"*",
"Outbound",
")",
"Start",
"(",
")",
"error",
"{",
"return",
"o",
".",
"once",
".",
"Start",
"(",
"o",
".",
"chooser",
".",
"Start",
")",
"\n",
"}"
] | // Start starts the TChannel outbound. | [
"Start",
"starts",
"the",
"TChannel",
"outbound",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/transport/tchannel/outbound.go#L207-L209 |
10,550 | yarpc/yarpc-go | transport/tchannel/outbound.go | Stop | func (o *Outbound) Stop() error {
return o.once.Stop(o.chooser.Stop)
} | go | func (o *Outbound) Stop() error {
return o.once.Stop(o.chooser.Stop)
} | [
"func",
"(",
"o",
"*",
"Outbound",
")",
"Stop",
"(",
")",
"error",
"{",
"return",
"o",
".",
"once",
".",
"Stop",
"(",
"o",
".",
"chooser",
".",
"Stop",
")",
"\n",
"}"
] | // Stop stops the TChannel outbound. | [
"Stop",
"stops",
"the",
"TChannel",
"outbound",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/transport/tchannel/outbound.go#L212-L214 |
10,551 | yarpc/yarpc-go | pkg/procedure/procedure.go | ToName | func ToName(serviceName string, methodName string) string {
return fmt.Sprintf("%s::%s", serviceName, methodName)
} | go | func ToName(serviceName string, methodName string) string {
return fmt.Sprintf("%s::%s", serviceName, methodName)
} | [
"func",
"ToName",
"(",
"serviceName",
"string",
",",
"methodName",
"string",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"serviceName",
",",
"methodName",
")",
"\n",
"}"
] | // ToName gets the procedure name we should use for a method
// with the given service name and method name. | [
"ToName",
"gets",
"the",
"procedure",
"name",
"we",
"should",
"use",
"for",
"a",
"method",
"with",
"the",
"given",
"service",
"name",
"and",
"method",
"name",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/pkg/procedure/procedure.go#L31-L33 |
10,552 | yarpc/yarpc-go | pkg/procedure/procedure.go | FromName | func FromName(name string) (serviceName string, methodName string) {
parts := strings.SplitN(name, "::", 2)
if len(parts) == 1 {
return parts[0], ""
}
return parts[0], parts[1]
} | go | func FromName(name string) (serviceName string, methodName string) {
parts := strings.SplitN(name, "::", 2)
if len(parts) == 1 {
return parts[0], ""
}
return parts[0], parts[1]
} | [
"func",
"FromName",
"(",
"name",
"string",
")",
"(",
"serviceName",
"string",
",",
"methodName",
"string",
")",
"{",
"parts",
":=",
"strings",
".",
"SplitN",
"(",
"name",
",",
"\"",
"\"",
",",
"2",
")",
"\n",
"if",
"len",
"(",
"parts",
")",
"==",
"... | // FromName gets the service name and method name from a procdure name. | [
"FromName",
"gets",
"the",
"service",
"name",
"and",
"method",
"name",
"from",
"a",
"procdure",
"name",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/pkg/procedure/procedure.go#L36-L42 |
10,553 | yarpc/yarpc-go | peer/pendingheap/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),
}
if !cfg.shuffle {
plOpts = append(plOpts, peerlist.NoShuffle())
}
nextRandFn := nextRand(cfg.seed)
if cfg.nextRand != nil {
// only true in tests
nextRandFn = cfg.nextRand
}
return &List{
List: peerlist.New(
"fewest-pending-requests",
transport,
&pendingHeap{
nextRand: nextRandFn,
},
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),
}
if !cfg.shuffle {
plOpts = append(plOpts, peerlist.NoShuffle())
}
nextRandFn := nextRand(cfg.seed)
if cfg.nextRand != nil {
// only true in tests
nextRandFn = cfg.nextRand
}
return &List{
List: peerlist.New(
"fewest-pending-requests",
transport,
&pendingHeap{
nextRand: nextRandFn,
},
plOpts...,
),
}
} | [
"func",
"New",
"(",
"transport",
"peer",
".",
"Transport",
",",
"opts",
"...",
"ListOption",
")",
"*",
"List",
"{",
"cfg",
":=",
"defaultListConfig",
"\n",
"for",
"_",
",",
"o",
":=",
"range",
"opts",
"{",
"o",
"(",
"&",
"cfg",
")",
"\n",
"}",
"\n\... | // New creates a new pending heap. | [
"New",
"creates",
"a",
"new",
"pending",
"heap",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/peer/pendingheap/list.go#L67-L96 |
10,554 | yarpc/yarpc-go | peer/pendingheap/list.go | nextRand | func nextRand(seed int64) func(int) int {
r := rand.New(rand.NewSource(seed))
return func(numPeers int) int {
if numPeers == 0 {
return 0
}
return r.Intn(numPeers)
}
} | go | func nextRand(seed int64) func(int) int {
r := rand.New(rand.NewSource(seed))
return func(numPeers int) int {
if numPeers == 0 {
return 0
}
return r.Intn(numPeers)
}
} | [
"func",
"nextRand",
"(",
"seed",
"int64",
")",
"func",
"(",
"int",
")",
"int",
"{",
"r",
":=",
"rand",
".",
"New",
"(",
"rand",
".",
"NewSource",
"(",
"seed",
")",
")",
"\n\n",
"return",
"func",
"(",
"numPeers",
"int",
")",
"int",
"{",
"if",
"num... | // nextRand is a convenience function for creating a new rand.Rand from a given
// seed. | [
"nextRand",
"is",
"a",
"convenience",
"function",
"for",
"creating",
"a",
"new",
"rand",
".",
"Rand",
"from",
"a",
"given",
"seed",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/peer/pendingheap/list.go#L105-L114 |
10,555 | yarpc/yarpc-go | internal/examples/thrift-keyvalue/keyvalue/kv/types.go | String | func (v *ResourceDoesNotExist) String() string {
if v == nil {
return "<nil>"
}
var fields [2]string
i := 0
fields[i] = fmt.Sprintf("Key: %v", v.Key)
i++
if v.Message != nil {
fields[i] = fmt.Sprintf("Message: %v", *(v.Message))
i++
}
return fmt.Sprintf("ResourceDoesNotExist{%v}", strings.Join(fields[:i], ", "))
} | go | func (v *ResourceDoesNotExist) String() string {
if v == nil {
return "<nil>"
}
var fields [2]string
i := 0
fields[i] = fmt.Sprintf("Key: %v", v.Key)
i++
if v.Message != nil {
fields[i] = fmt.Sprintf("Message: %v", *(v.Message))
i++
}
return fmt.Sprintf("ResourceDoesNotExist{%v}", strings.Join(fields[:i], ", "))
} | [
"func",
"(",
"v",
"*",
"ResourceDoesNotExist",
")",
"String",
"(",
")",
"string",
"{",
"if",
"v",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"var",
"fields",
"[",
"2",
"]",
"string",
"\n",
"i",
":=",
"0",
"\n",
"fields",
"[",
"i",... | // String returns a readable string representation of a ResourceDoesNotExist
// struct. | [
"String",
"returns",
"a",
"readable",
"string",
"representation",
"of",
"a",
"ResourceDoesNotExist",
"struct",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/thrift-keyvalue/keyvalue/kv/types.go#L134-L149 |
10,556 | yarpc/yarpc-go | internal/examples/thrift-keyvalue/keyvalue/kv/types.go | Equals | func (v *ResourceDoesNotExist) Equals(rhs *ResourceDoesNotExist) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
if !(v.Key == rhs.Key) {
return false
}
if !_String_EqualsPtr(v.Message, rhs.Message) {
return false
}
return true
} | go | func (v *ResourceDoesNotExist) Equals(rhs *ResourceDoesNotExist) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
if !(v.Key == rhs.Key) {
return false
}
if !_String_EqualsPtr(v.Message, rhs.Message) {
return false
}
return true
} | [
"func",
"(",
"v",
"*",
"ResourceDoesNotExist",
")",
"Equals",
"(",
"rhs",
"*",
"ResourceDoesNotExist",
")",
"bool",
"{",
"if",
"v",
"==",
"nil",
"{",
"return",
"rhs",
"==",
"nil",
"\n",
"}",
"else",
"if",
"rhs",
"==",
"nil",
"{",
"return",
"false",
"... | // Equals returns true if all the fields of this ResourceDoesNotExist match the
// provided ResourceDoesNotExist.
//
// This function performs a deep comparison. | [
"Equals",
"returns",
"true",
"if",
"all",
"the",
"fields",
"of",
"this",
"ResourceDoesNotExist",
"match",
"the",
"provided",
"ResourceDoesNotExist",
".",
"This",
"function",
"performs",
"a",
"deep",
"comparison",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/thrift-keyvalue/keyvalue/kv/types.go#L165-L179 |
10,557 | yarpc/yarpc-go | internal/examples/thrift-keyvalue/keyvalue/kv/types.go | MarshalLogObject | func (v *ResourceDoesNotExist) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
enc.AddString("key", v.Key)
if v.Message != nil {
enc.AddString("message", *v.Message)
}
return err
} | go | func (v *ResourceDoesNotExist) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
enc.AddString("key", v.Key)
if v.Message != nil {
enc.AddString("message", *v.Message)
}
return err
} | [
"func",
"(",
"v",
"*",
"ResourceDoesNotExist",
")",
"MarshalLogObject",
"(",
"enc",
"zapcore",
".",
"ObjectEncoder",
")",
"(",
"err",
"error",
")",
"{",
"if",
"v",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"enc",
".",
"AddString",
"(",
"\"",
... | // MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of ResourceDoesNotExist. | [
"MarshalLogObject",
"implements",
"zapcore",
".",
"ObjectMarshaler",
"enabling",
"fast",
"logging",
"of",
"ResourceDoesNotExist",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/thrift-keyvalue/keyvalue/kv/types.go#L183-L192 |
10,558 | yarpc/yarpc-go | internal/examples/protobuf/examplepb/example.pb.yarpc.go | NewKeyValueYARPCClient | func NewKeyValueYARPCClient(clientConfig transport.ClientConfig, options ...protobuf.ClientOption) KeyValueYARPCClient {
return &_KeyValueYARPCCaller{protobuf.NewStreamClient(
protobuf.ClientParams{
ServiceName: "uber.yarpc.internal.examples.protobuf.example.KeyValue",
ClientConfig: clientConfig,
Options: options,
},
)}
} | go | func NewKeyValueYARPCClient(clientConfig transport.ClientConfig, options ...protobuf.ClientOption) KeyValueYARPCClient {
return &_KeyValueYARPCCaller{protobuf.NewStreamClient(
protobuf.ClientParams{
ServiceName: "uber.yarpc.internal.examples.protobuf.example.KeyValue",
ClientConfig: clientConfig,
Options: options,
},
)}
} | [
"func",
"NewKeyValueYARPCClient",
"(",
"clientConfig",
"transport",
".",
"ClientConfig",
",",
"options",
"...",
"protobuf",
".",
"ClientOption",
")",
"KeyValueYARPCClient",
"{",
"return",
"&",
"_KeyValueYARPCCaller",
"{",
"protobuf",
".",
"NewStreamClient",
"(",
"prot... | // NewKeyValueYARPCClient builds a new YARPC client for the KeyValue service. | [
"NewKeyValueYARPCClient",
"builds",
"a",
"new",
"YARPC",
"client",
"for",
"the",
"KeyValue",
"service",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/protobuf/examplepb/example.pb.yarpc.go#L50-L58 |
10,559 | yarpc/yarpc-go | internal/examples/protobuf/examplepb/example.pb.yarpc.go | BuildKeyValueYARPCProcedures | func BuildKeyValueYARPCProcedures(server KeyValueYARPCServer) []transport.Procedure {
handler := &_KeyValueYARPCHandler{server}
return protobuf.BuildProcedures(
protobuf.BuildProceduresParams{
ServiceName: "uber.yarpc.internal.examples.protobuf.example.KeyValue",
UnaryHandlerParams: []protobuf.BuildProceduresUnaryHandlerParams{
{
MethodName: "GetValue",
Handler: protobuf.NewUnaryHandler(
protobuf.UnaryHandlerParams{
Handle: handler.GetValue,
NewRequest: newKeyValueServiceGetValueYARPCRequest,
},
),
},
{
MethodName: "SetValue",
Handler: protobuf.NewUnaryHandler(
protobuf.UnaryHandlerParams{
Handle: handler.SetValue,
NewRequest: newKeyValueServiceSetValueYARPCRequest,
},
),
},
},
OnewayHandlerParams: []protobuf.BuildProceduresOnewayHandlerParams{},
StreamHandlerParams: []protobuf.BuildProceduresStreamHandlerParams{},
},
)
} | go | func BuildKeyValueYARPCProcedures(server KeyValueYARPCServer) []transport.Procedure {
handler := &_KeyValueYARPCHandler{server}
return protobuf.BuildProcedures(
protobuf.BuildProceduresParams{
ServiceName: "uber.yarpc.internal.examples.protobuf.example.KeyValue",
UnaryHandlerParams: []protobuf.BuildProceduresUnaryHandlerParams{
{
MethodName: "GetValue",
Handler: protobuf.NewUnaryHandler(
protobuf.UnaryHandlerParams{
Handle: handler.GetValue,
NewRequest: newKeyValueServiceGetValueYARPCRequest,
},
),
},
{
MethodName: "SetValue",
Handler: protobuf.NewUnaryHandler(
protobuf.UnaryHandlerParams{
Handle: handler.SetValue,
NewRequest: newKeyValueServiceSetValueYARPCRequest,
},
),
},
},
OnewayHandlerParams: []protobuf.BuildProceduresOnewayHandlerParams{},
StreamHandlerParams: []protobuf.BuildProceduresStreamHandlerParams{},
},
)
} | [
"func",
"BuildKeyValueYARPCProcedures",
"(",
"server",
"KeyValueYARPCServer",
")",
"[",
"]",
"transport",
".",
"Procedure",
"{",
"handler",
":=",
"&",
"_KeyValueYARPCHandler",
"{",
"server",
"}",
"\n",
"return",
"protobuf",
".",
"BuildProcedures",
"(",
"protobuf",
... | // BuildKeyValueYARPCProcedures prepares an implementation of the KeyValue service for YARPC registration. | [
"BuildKeyValueYARPCProcedures",
"prepares",
"an",
"implementation",
"of",
"the",
"KeyValue",
"service",
"for",
"YARPC",
"registration",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/protobuf/examplepb/example.pb.yarpc.go#L67-L96 |
10,560 | yarpc/yarpc-go | internal/examples/protobuf/examplepb/example.pb.yarpc.go | NewSinkYARPCClient | func NewSinkYARPCClient(clientConfig transport.ClientConfig, options ...protobuf.ClientOption) SinkYARPCClient {
return &_SinkYARPCCaller{protobuf.NewStreamClient(
protobuf.ClientParams{
ServiceName: "uber.yarpc.internal.examples.protobuf.example.Sink",
ClientConfig: clientConfig,
Options: options,
},
)}
} | go | func NewSinkYARPCClient(clientConfig transport.ClientConfig, options ...protobuf.ClientOption) SinkYARPCClient {
return &_SinkYARPCCaller{protobuf.NewStreamClient(
protobuf.ClientParams{
ServiceName: "uber.yarpc.internal.examples.protobuf.example.Sink",
ClientConfig: clientConfig,
Options: options,
},
)}
} | [
"func",
"NewSinkYARPCClient",
"(",
"clientConfig",
"transport",
".",
"ClientConfig",
",",
"options",
"...",
"protobuf",
".",
"ClientOption",
")",
"SinkYARPCClient",
"{",
"return",
"&",
"_SinkYARPCCaller",
"{",
"protobuf",
".",
"NewStreamClient",
"(",
"protobuf",
"."... | // NewSinkYARPCClient builds a new YARPC client for the Sink service. | [
"NewSinkYARPCClient",
"builds",
"a",
"new",
"YARPC",
"client",
"for",
"the",
"Sink",
"service",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/protobuf/examplepb/example.pb.yarpc.go#L271-L279 |
10,561 | yarpc/yarpc-go | internal/examples/protobuf/examplepb/example.pb.yarpc.go | BuildSinkYARPCProcedures | func BuildSinkYARPCProcedures(server SinkYARPCServer) []transport.Procedure {
handler := &_SinkYARPCHandler{server}
return protobuf.BuildProcedures(
protobuf.BuildProceduresParams{
ServiceName: "uber.yarpc.internal.examples.protobuf.example.Sink",
UnaryHandlerParams: []protobuf.BuildProceduresUnaryHandlerParams{},
OnewayHandlerParams: []protobuf.BuildProceduresOnewayHandlerParams{
{
MethodName: "Fire",
Handler: protobuf.NewOnewayHandler(
protobuf.OnewayHandlerParams{
Handle: handler.Fire,
NewRequest: newSinkServiceFireYARPCRequest,
},
),
},
},
StreamHandlerParams: []protobuf.BuildProceduresStreamHandlerParams{},
},
)
} | go | func BuildSinkYARPCProcedures(server SinkYARPCServer) []transport.Procedure {
handler := &_SinkYARPCHandler{server}
return protobuf.BuildProcedures(
protobuf.BuildProceduresParams{
ServiceName: "uber.yarpc.internal.examples.protobuf.example.Sink",
UnaryHandlerParams: []protobuf.BuildProceduresUnaryHandlerParams{},
OnewayHandlerParams: []protobuf.BuildProceduresOnewayHandlerParams{
{
MethodName: "Fire",
Handler: protobuf.NewOnewayHandler(
protobuf.OnewayHandlerParams{
Handle: handler.Fire,
NewRequest: newSinkServiceFireYARPCRequest,
},
),
},
},
StreamHandlerParams: []protobuf.BuildProceduresStreamHandlerParams{},
},
)
} | [
"func",
"BuildSinkYARPCProcedures",
"(",
"server",
"SinkYARPCServer",
")",
"[",
"]",
"transport",
".",
"Procedure",
"{",
"handler",
":=",
"&",
"_SinkYARPCHandler",
"{",
"server",
"}",
"\n",
"return",
"protobuf",
".",
"BuildProcedures",
"(",
"protobuf",
".",
"Bui... | // BuildSinkYARPCProcedures prepares an implementation of the Sink service for YARPC registration. | [
"BuildSinkYARPCProcedures",
"prepares",
"an",
"implementation",
"of",
"the",
"Sink",
"service",
"for",
"YARPC",
"registration",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/protobuf/examplepb/example.pb.yarpc.go#L287-L307 |
10,562 | yarpc/yarpc-go | internal/examples/protobuf/examplepb/example.pb.yarpc.go | NewFooYARPCClient | func NewFooYARPCClient(clientConfig transport.ClientConfig, options ...protobuf.ClientOption) FooYARPCClient {
return &_FooYARPCCaller{protobuf.NewStreamClient(
protobuf.ClientParams{
ServiceName: "uber.yarpc.internal.examples.protobuf.example.Foo",
ClientConfig: clientConfig,
Options: options,
},
)}
} | go | func NewFooYARPCClient(clientConfig transport.ClientConfig, options ...protobuf.ClientOption) FooYARPCClient {
return &_FooYARPCCaller{protobuf.NewStreamClient(
protobuf.ClientParams{
ServiceName: "uber.yarpc.internal.examples.protobuf.example.Foo",
ClientConfig: clientConfig,
Options: options,
},
)}
} | [
"func",
"NewFooYARPCClient",
"(",
"clientConfig",
"transport",
".",
"ClientConfig",
",",
"options",
"...",
"protobuf",
".",
"ClientOption",
")",
"FooYARPCClient",
"{",
"return",
"&",
"_FooYARPCCaller",
"{",
"protobuf",
".",
"NewStreamClient",
"(",
"protobuf",
".",
... | // NewFooYARPCClient builds a new YARPC client for the Foo service. | [
"NewFooYARPCClient",
"builds",
"a",
"new",
"YARPC",
"client",
"for",
"the",
"Foo",
"service",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/protobuf/examplepb/example.pb.yarpc.go#L456-L464 |
10,563 | yarpc/yarpc-go | internal/examples/protobuf/examplepb/example.pb.yarpc.go | BuildFooYARPCProcedures | func BuildFooYARPCProcedures(server FooYARPCServer) []transport.Procedure {
handler := &_FooYARPCHandler{server}
return protobuf.BuildProcedures(
protobuf.BuildProceduresParams{
ServiceName: "uber.yarpc.internal.examples.protobuf.example.Foo",
UnaryHandlerParams: []protobuf.BuildProceduresUnaryHandlerParams{},
OnewayHandlerParams: []protobuf.BuildProceduresOnewayHandlerParams{},
StreamHandlerParams: []protobuf.BuildProceduresStreamHandlerParams{
{
MethodName: "EchoBoth",
Handler: protobuf.NewStreamHandler(
protobuf.StreamHandlerParams{
Handle: handler.EchoBoth,
},
),
},
{
MethodName: "EchoIn",
Handler: protobuf.NewStreamHandler(
protobuf.StreamHandlerParams{
Handle: handler.EchoIn,
},
),
},
{
MethodName: "EchoOut",
Handler: protobuf.NewStreamHandler(
protobuf.StreamHandlerParams{
Handle: handler.EchoOut,
},
),
},
},
},
)
} | go | func BuildFooYARPCProcedures(server FooYARPCServer) []transport.Procedure {
handler := &_FooYARPCHandler{server}
return protobuf.BuildProcedures(
protobuf.BuildProceduresParams{
ServiceName: "uber.yarpc.internal.examples.protobuf.example.Foo",
UnaryHandlerParams: []protobuf.BuildProceduresUnaryHandlerParams{},
OnewayHandlerParams: []protobuf.BuildProceduresOnewayHandlerParams{},
StreamHandlerParams: []protobuf.BuildProceduresStreamHandlerParams{
{
MethodName: "EchoBoth",
Handler: protobuf.NewStreamHandler(
protobuf.StreamHandlerParams{
Handle: handler.EchoBoth,
},
),
},
{
MethodName: "EchoIn",
Handler: protobuf.NewStreamHandler(
protobuf.StreamHandlerParams{
Handle: handler.EchoIn,
},
),
},
{
MethodName: "EchoOut",
Handler: protobuf.NewStreamHandler(
protobuf.StreamHandlerParams{
Handle: handler.EchoOut,
},
),
},
},
},
)
} | [
"func",
"BuildFooYARPCProcedures",
"(",
"server",
"FooYARPCServer",
")",
"[",
"]",
"transport",
".",
"Procedure",
"{",
"handler",
":=",
"&",
"_FooYARPCHandler",
"{",
"server",
"}",
"\n",
"return",
"protobuf",
".",
"BuildProcedures",
"(",
"protobuf",
".",
"BuildP... | // BuildFooYARPCProcedures prepares an implementation of the Foo service for YARPC registration. | [
"BuildFooYARPCProcedures",
"prepares",
"an",
"implementation",
"of",
"the",
"Foo",
"service",
"for",
"YARPC",
"registration",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/examples/protobuf/examplepb/example.pb.yarpc.go#L493-L530 |
10,564 | yarpc/yarpc-go | peer/randpeer/list.go | Seed | func Seed(seed int64) ListOption {
return listOptionFunc(func(options *listOptions) {
options.source = rand.NewSource(seed)
})
} | go | func Seed(seed int64) ListOption {
return listOptionFunc(func(options *listOptions) {
options.source = rand.NewSource(seed)
})
} | [
"func",
"Seed",
"(",
"seed",
"int64",
")",
"ListOption",
"{",
"return",
"listOptionFunc",
"(",
"func",
"(",
"options",
"*",
"listOptions",
")",
"{",
"options",
".",
"source",
"=",
"rand",
".",
"NewSource",
"(",
"seed",
")",
"\n",
"}",
")",
"\n",
"}"
] | // Seed specifies the seed for generating random choices. | [
"Seed",
"specifies",
"the",
"seed",
"for",
"generating",
"random",
"choices",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/peer/randpeer/list.go#L60-L64 |
10,565 | yarpc/yarpc-go | peer/randpeer/list.go | Source | func Source(source rand.Source) ListOption {
return listOptionFunc(func(options *listOptions) {
options.source = source
})
} | go | func Source(source rand.Source) ListOption {
return listOptionFunc(func(options *listOptions) {
options.source = source
})
} | [
"func",
"Source",
"(",
"source",
"rand",
".",
"Source",
")",
"ListOption",
"{",
"return",
"listOptionFunc",
"(",
"func",
"(",
"options",
"*",
"listOptions",
")",
"{",
"options",
".",
"source",
"=",
"source",
"\n",
"}",
")",
"\n",
"}"
] | // Source is a source of randomness for the peer list. | [
"Source",
"is",
"a",
"source",
"of",
"randomness",
"for",
"the",
"peer",
"list",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/peer/randpeer/list.go#L67-L71 |
10,566 | yarpc/yarpc-go | peer/randpeer/list.go | New | func New(transport peer.Transport, opts ...ListOption) *List {
options := defaultListOptions
for _, opt := range opts {
opt.apply(&options)
}
if options.source == nil {
options.source = rand.NewSource(time.Now().UnixNano())
}
plOpts := []peerlist.ListOption{
peerlist.Capacity(options.capacity),
peerlist.NoShuffle(),
}
return &List{
List: peerlist.New(
"random",
transport,
newRandomList(options.capacity, options.source),
plOpts...,
),
}
} | go | func New(transport peer.Transport, opts ...ListOption) *List {
options := defaultListOptions
for _, opt := range opts {
opt.apply(&options)
}
if options.source == nil {
options.source = rand.NewSource(time.Now().UnixNano())
}
plOpts := []peerlist.ListOption{
peerlist.Capacity(options.capacity),
peerlist.NoShuffle(),
}
return &List{
List: peerlist.New(
"random",
transport,
newRandomList(options.capacity, options.source),
plOpts...,
),
}
} | [
"func",
"New",
"(",
"transport",
"peer",
".",
"Transport",
",",
"opts",
"...",
"ListOption",
")",
"*",
"List",
"{",
"options",
":=",
"defaultListOptions",
"\n",
"for",
"_",
",",
"opt",
":=",
"range",
"opts",
"{",
"opt",
".",
"apply",
"(",
"&",
"options... | // New creates a new random peer list. | [
"New",
"creates",
"a",
"new",
"random",
"peer",
"list",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/peer/randpeer/list.go#L74-L97 |
10,567 | yarpc/yarpc-go | internal/errorsync/err.go | Submit | func (ew *ErrorWaiter) Submit(f func() error) {
ew.wait.Add(1)
go func() {
defer ew.wait.Done()
if err := f(); err != nil {
ew.lock.Lock()
ew.errors = append(ew.errors, err)
ew.lock.Unlock()
}
}()
} | go | func (ew *ErrorWaiter) Submit(f func() error) {
ew.wait.Add(1)
go func() {
defer ew.wait.Done()
if err := f(); err != nil {
ew.lock.Lock()
ew.errors = append(ew.errors, err)
ew.lock.Unlock()
}
}()
} | [
"func",
"(",
"ew",
"*",
"ErrorWaiter",
")",
"Submit",
"(",
"f",
"func",
"(",
")",
"error",
")",
"{",
"ew",
".",
"wait",
".",
"Add",
"(",
"1",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"defer",
"ew",
".",
"wait",
".",
"Done",
"(",
")",
"\n",
"... | // Submit submits a task for execution on the ErrorWaiter.
//
// The function returns immediately. | [
"Submit",
"submits",
"a",
"task",
"for",
"execution",
"on",
"the",
"ErrorWaiter",
".",
"The",
"function",
"returns",
"immediately",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/errorsync/err.go#L36-L46 |
10,568 | yarpc/yarpc-go | encoding/raw/register.go | Procedure | func Procedure(name string, handler UnaryHandler) []transport.Procedure {
return []transport.Procedure{
{
Name: name,
HandlerSpec: transport.NewUnaryHandlerSpec(rawUnaryHandler{handler}),
},
}
} | go | func Procedure(name string, handler UnaryHandler) []transport.Procedure {
return []transport.Procedure{
{
Name: name,
HandlerSpec: transport.NewUnaryHandlerSpec(rawUnaryHandler{handler}),
},
}
} | [
"func",
"Procedure",
"(",
"name",
"string",
",",
"handler",
"UnaryHandler",
")",
"[",
"]",
"transport",
".",
"Procedure",
"{",
"return",
"[",
"]",
"transport",
".",
"Procedure",
"{",
"{",
"Name",
":",
"name",
",",
"HandlerSpec",
":",
"transport",
".",
"N... | // Procedure builds a Procedure from the given raw handler. | [
"Procedure",
"builds",
"a",
"Procedure",
"from",
"the",
"given",
"raw",
"handler",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/encoding/raw/register.go#L43-L50 |
10,569 | yarpc/yarpc-go | encoding/raw/register.go | OnewayProcedure | func OnewayProcedure(name string, handler OnewayHandler) []transport.Procedure {
return []transport.Procedure{
{
Name: name,
HandlerSpec: transport.NewOnewayHandlerSpec(rawOnewayHandler{handler}),
},
}
} | go | func OnewayProcedure(name string, handler OnewayHandler) []transport.Procedure {
return []transport.Procedure{
{
Name: name,
HandlerSpec: transport.NewOnewayHandlerSpec(rawOnewayHandler{handler}),
},
}
} | [
"func",
"OnewayProcedure",
"(",
"name",
"string",
",",
"handler",
"OnewayHandler",
")",
"[",
"]",
"transport",
".",
"Procedure",
"{",
"return",
"[",
"]",
"transport",
".",
"Procedure",
"{",
"{",
"Name",
":",
"name",
",",
"HandlerSpec",
":",
"transport",
".... | // OnewayProcedure builds a Procedure from the given raw handler | [
"OnewayProcedure",
"builds",
"a",
"Procedure",
"from",
"the",
"given",
"raw",
"handler"
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/encoding/raw/register.go#L56-L63 |
10,570 | yarpc/yarpc-go | internal/crossdock/server/yarpc/sleep.go | SleepRaw | func SleepRaw(ctx context.Context, body []byte) ([]byte, error) {
time.Sleep(1 * time.Second)
return nil, nil
} | go | func SleepRaw(ctx context.Context, body []byte) ([]byte, error) {
time.Sleep(1 * time.Second)
return nil, nil
} | [
"func",
"SleepRaw",
"(",
"ctx",
"context",
".",
"Context",
",",
"body",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"time",
".",
"Sleep",
"(",
"1",
"*",
"time",
".",
"Second",
")",
"\n",
"return",
"nil",
",",
"nil",
"\... | // SleepRaw responds to raw requests over any transport by sleeping for one
// second. | [
"SleepRaw",
"responds",
"to",
"raw",
"requests",
"over",
"any",
"transport",
"by",
"sleeping",
"for",
"one",
"second",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/server/yarpc/sleep.go#L31-L34 |
10,571 | yarpc/yarpc-go | internal/crossdock/server/yarpc/sleep.go | WaitForTimeoutRaw | func WaitForTimeoutRaw(ctx context.Context, body []byte) ([]byte, error) {
if _, ok := ctx.Deadline(); !ok {
return nil, fmt.Errorf("no deadline set in context")
}
<-ctx.Done()
return nil, ctx.Err()
} | go | func WaitForTimeoutRaw(ctx context.Context, body []byte) ([]byte, error) {
if _, ok := ctx.Deadline(); !ok {
return nil, fmt.Errorf("no deadline set in context")
}
<-ctx.Done()
return nil, ctx.Err()
} | [
"func",
"WaitForTimeoutRaw",
"(",
"ctx",
"context",
".",
"Context",
",",
"body",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"_",
",",
"ok",
":=",
"ctx",
".",
"Deadline",
"(",
")",
";",
"!",
"ok",
"{",
"return",
... | // WaitForTimeoutRaw waits after the context deadline then returns the context
// error. yarpc should interpret this as an handler timeout, which in turns
// should be forwarded to the yarpc client as a remote handler timeout. | [
"WaitForTimeoutRaw",
"waits",
"after",
"the",
"context",
"deadline",
"then",
"returns",
"the",
"context",
"error",
".",
"yarpc",
"should",
"interpret",
"this",
"as",
"an",
"handler",
"timeout",
"which",
"in",
"turns",
"should",
"be",
"forwarded",
"to",
"the",
... | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/server/yarpc/sleep.go#L46-L52 |
10,572 | yarpc/yarpc-go | pkg/errors/client.go | RequestBodyEncodeError | func RequestBodyEncodeError(req *transport.Request, err error) error {
return newClientEncodingError(req, false /*isResponse*/, false /*isHeader*/, err)
} | go | func RequestBodyEncodeError(req *transport.Request, err error) error {
return newClientEncodingError(req, false /*isResponse*/, false /*isHeader*/, err)
} | [
"func",
"RequestBodyEncodeError",
"(",
"req",
"*",
"transport",
".",
"Request",
",",
"err",
"error",
")",
"error",
"{",
"return",
"newClientEncodingError",
"(",
"req",
",",
"false",
"/*isResponse*/",
",",
"false",
"/*isHeader*/",
",",
"err",
")",
"\n",
"}"
] | // RequestBodyEncodeError builds a YARPC error with code
// yarpcerrors.CodeInvalidArgument that represents a failure to encode
// the request body. | [
"RequestBodyEncodeError",
"builds",
"a",
"YARPC",
"error",
"with",
"code",
"yarpcerrors",
".",
"CodeInvalidArgument",
"that",
"represents",
"a",
"failure",
"to",
"encode",
"the",
"request",
"body",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/pkg/errors/client.go#L34-L36 |
10,573 | yarpc/yarpc-go | pkg/errors/client.go | RequestHeadersEncodeError | func RequestHeadersEncodeError(req *transport.Request, err error) error {
return newClientEncodingError(req, false /*isResponse*/, true /*isHeader*/, err)
} | go | func RequestHeadersEncodeError(req *transport.Request, err error) error {
return newClientEncodingError(req, false /*isResponse*/, true /*isHeader*/, err)
} | [
"func",
"RequestHeadersEncodeError",
"(",
"req",
"*",
"transport",
".",
"Request",
",",
"err",
"error",
")",
"error",
"{",
"return",
"newClientEncodingError",
"(",
"req",
",",
"false",
"/*isResponse*/",
",",
"true",
"/*isHeader*/",
",",
"err",
")",
"\n",
"}"
] | // RequestHeadersEncodeError builds a YARPC error with code
// yarpcerrors.CodeInvalidArgument that represents a failure to
// encode the request headers. | [
"RequestHeadersEncodeError",
"builds",
"a",
"YARPC",
"error",
"with",
"code",
"yarpcerrors",
".",
"CodeInvalidArgument",
"that",
"represents",
"a",
"failure",
"to",
"encode",
"the",
"request",
"headers",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/pkg/errors/client.go#L48-L50 |
10,574 | yarpc/yarpc-go | pkg/errors/client.go | ResponseHeadersDecodeError | func ResponseHeadersDecodeError(req *transport.Request, err error) error {
return newClientEncodingError(req, true /*isResponse*/, true /*isHeader*/, err)
} | go | func ResponseHeadersDecodeError(req *transport.Request, err error) error {
return newClientEncodingError(req, true /*isResponse*/, true /*isHeader*/, err)
} | [
"func",
"ResponseHeadersDecodeError",
"(",
"req",
"*",
"transport",
".",
"Request",
",",
"err",
"error",
")",
"error",
"{",
"return",
"newClientEncodingError",
"(",
"req",
",",
"true",
"/*isResponse*/",
",",
"true",
"/*isHeader*/",
",",
"err",
")",
"\n",
"}"
] | // ResponseHeadersDecodeError builds a YARPC error with code
// yarpcerrors.CodeInvalidArgument that represents a failure to
// decode the response headers. | [
"ResponseHeadersDecodeError",
"builds",
"a",
"YARPC",
"error",
"with",
"code",
"yarpcerrors",
".",
"CodeInvalidArgument",
"that",
"represents",
"a",
"failure",
"to",
"decode",
"the",
"response",
"headers",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/pkg/errors/client.go#L55-L57 |
10,575 | yarpc/yarpc-go | encoding/protobuf/stream.go | readFromStream | func readFromStream(
ctx context.Context,
stream transport.Stream,
newMessage func() proto.Message,
) (proto.Message, error) {
streamMsg, err := stream.ReceiveMessage(ctx)
if err != nil {
return nil, err
}
message := newMessage()
if err := unmarshal(stream.Request().Meta.Encoding, streamMsg.Body, message); err != nil {
streamMsg.Body.Close()
return nil, err
}
if streamMsg.Body != nil {
streamMsg.Body.Close()
}
return message, nil
} | go | func readFromStream(
ctx context.Context,
stream transport.Stream,
newMessage func() proto.Message,
) (proto.Message, error) {
streamMsg, err := stream.ReceiveMessage(ctx)
if err != nil {
return nil, err
}
message := newMessage()
if err := unmarshal(stream.Request().Meta.Encoding, streamMsg.Body, message); err != nil {
streamMsg.Body.Close()
return nil, err
}
if streamMsg.Body != nil {
streamMsg.Body.Close()
}
return message, nil
} | [
"func",
"readFromStream",
"(",
"ctx",
"context",
".",
"Context",
",",
"stream",
"transport",
".",
"Stream",
",",
"newMessage",
"func",
"(",
")",
"proto",
".",
"Message",
",",
")",
"(",
"proto",
".",
"Message",
",",
"error",
")",
"{",
"streamMsg",
",",
... | // readFromStream reads a proto.Message from a stream. | [
"readFromStream",
"reads",
"a",
"proto",
".",
"Message",
"from",
"a",
"stream",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/encoding/protobuf/stream.go#L33-L51 |
10,576 | yarpc/yarpc-go | encoding/protobuf/stream.go | writeToStream | func writeToStream(ctx context.Context, stream transport.Stream, message proto.Message) error {
messageData, cleanup, err := marshal(stream.Request().Meta.Encoding, message)
if err != nil {
return err
}
return stream.SendMessage(
ctx,
&transport.StreamMessage{
Body: readCloser{Reader: bytes.NewReader(messageData), closer: cleanup},
},
)
} | go | func writeToStream(ctx context.Context, stream transport.Stream, message proto.Message) error {
messageData, cleanup, err := marshal(stream.Request().Meta.Encoding, message)
if err != nil {
return err
}
return stream.SendMessage(
ctx,
&transport.StreamMessage{
Body: readCloser{Reader: bytes.NewReader(messageData), closer: cleanup},
},
)
} | [
"func",
"writeToStream",
"(",
"ctx",
"context",
".",
"Context",
",",
"stream",
"transport",
".",
"Stream",
",",
"message",
"proto",
".",
"Message",
")",
"error",
"{",
"messageData",
",",
"cleanup",
",",
"err",
":=",
"marshal",
"(",
"stream",
".",
"Request"... | // writeToStream writes a proto.Message to a stream. | [
"writeToStream",
"writes",
"a",
"proto",
".",
"Message",
"to",
"a",
"stream",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/encoding/protobuf/stream.go#L54-L65 |
10,577 | yarpc/yarpc-go | x/debug/debug.go | NewHandler | func NewHandler(dispatcher *yarpc.Dispatcher, opts ...Option) http.HandlerFunc {
return newHandler(dispatcher, opts...).handle
} | go | func NewHandler(dispatcher *yarpc.Dispatcher, opts ...Option) http.HandlerFunc {
return newHandler(dispatcher, opts...).handle
} | [
"func",
"NewHandler",
"(",
"dispatcher",
"*",
"yarpc",
".",
"Dispatcher",
",",
"opts",
"...",
"Option",
")",
"http",
".",
"HandlerFunc",
"{",
"return",
"newHandler",
"(",
"dispatcher",
",",
"opts",
"...",
")",
".",
"handle",
"\n",
"}"
] | // NewHandler returns a http.HandlerFunc to expose dispatcher status and package versions. | [
"NewHandler",
"returns",
"a",
"http",
".",
"HandlerFunc",
"to",
"expose",
"dispatcher",
"status",
"and",
"package",
"versions",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/x/debug/debug.go#L180-L182 |
10,578 | yarpc/yarpc-go | peer/x/peerheap/heap.go | Swap | func (ph *peerHeap) Swap(i, j int) {
p1 := ph.peers[i]
p2 := ph.peers[j]
ph.peers[i], ph.peers[j] = ph.peers[j], ph.peers[i]
p1.idx = j
p2.idx = i
} | go | func (ph *peerHeap) Swap(i, j int) {
p1 := ph.peers[i]
p2 := ph.peers[j]
ph.peers[i], ph.peers[j] = ph.peers[j], ph.peers[i]
p1.idx = j
p2.idx = i
} | [
"func",
"(",
"ph",
"*",
"peerHeap",
")",
"Swap",
"(",
"i",
",",
"j",
"int",
")",
"{",
"p1",
":=",
"ph",
".",
"peers",
"[",
"i",
"]",
"\n",
"p2",
":=",
"ph",
".",
"peers",
"[",
"j",
"]",
"\n\n",
"ph",
".",
"peers",
"[",
"i",
"]",
",",
"ph"... | // Swap implements the heap.Interface. Do NOT use this method directly. | [
"Swap",
"implements",
"the",
"heap",
".",
"Interface",
".",
"Do",
"NOT",
"use",
"this",
"method",
"directly",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/peer/x/peerheap/heap.go#L53-L60 |
10,579 | yarpc/yarpc-go | peer/x/peerheap/heap.go | Push | func (ph *peerHeap) Push(x interface{}) {
ps := x.(*peerScore)
ps.idx = len(ph.peers)
ph.peers = append(ph.peers, ps)
} | go | func (ph *peerHeap) Push(x interface{}) {
ps := x.(*peerScore)
ps.idx = len(ph.peers)
ph.peers = append(ph.peers, ps)
} | [
"func",
"(",
"ph",
"*",
"peerHeap",
")",
"Push",
"(",
"x",
"interface",
"{",
"}",
")",
"{",
"ps",
":=",
"x",
".",
"(",
"*",
"peerScore",
")",
"\n",
"ps",
".",
"idx",
"=",
"len",
"(",
"ph",
".",
"peers",
")",
"\n",
"ph",
".",
"peers",
"=",
"... | // Push implements the heap.Interface. Do NOT use this method directly.
// Use pushPeer instead. | [
"Push",
"implements",
"the",
"heap",
".",
"Interface",
".",
"Do",
"NOT",
"use",
"this",
"method",
"directly",
".",
"Use",
"pushPeer",
"instead",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/peer/x/peerheap/heap.go#L64-L68 |
10,580 | yarpc/yarpc-go | peer/x/peerheap/heap.go | Pop | func (ph *peerHeap) Pop() interface{} {
lastIdx := len(ph.peers) - 1
last := ph.peers[lastIdx]
ph.peers = ph.peers[:lastIdx]
return last
} | go | func (ph *peerHeap) Pop() interface{} {
lastIdx := len(ph.peers) - 1
last := ph.peers[lastIdx]
ph.peers = ph.peers[:lastIdx]
return last
} | [
"func",
"(",
"ph",
"*",
"peerHeap",
")",
"Pop",
"(",
")",
"interface",
"{",
"}",
"{",
"lastIdx",
":=",
"len",
"(",
"ph",
".",
"peers",
")",
"-",
"1",
"\n",
"last",
":=",
"ph",
".",
"peers",
"[",
"lastIdx",
"]",
"\n",
"ph",
".",
"peers",
"=",
... | // Pop implements the heap.Interface. Do NOT use this method directly.
// Use popPeer instead. | [
"Pop",
"implements",
"the",
"heap",
".",
"Interface",
".",
"Do",
"NOT",
"use",
"this",
"method",
"directly",
".",
"Use",
"popPeer",
"instead",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/peer/x/peerheap/heap.go#L72-L77 |
10,581 | yarpc/yarpc-go | internal/crossdock/client/random/rand.go | Bytes | func Bytes(length int) []byte {
out := make([]byte, length)
if _, err := io.ReadFull(rand.Reader, out); err != nil {
panic(err)
}
return out
} | go | func Bytes(length int) []byte {
out := make([]byte, length)
if _, err := io.ReadFull(rand.Reader, out); err != nil {
panic(err)
}
return out
} | [
"func",
"Bytes",
"(",
"length",
"int",
")",
"[",
"]",
"byte",
"{",
"out",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"length",
")",
"\n",
"if",
"_",
",",
"err",
":=",
"io",
".",
"ReadFull",
"(",
"rand",
".",
"Reader",
",",
"out",
")",
";",
"er... | // Bytes generates the given number of random bytes. | [
"Bytes",
"generates",
"the",
"given",
"number",
"of",
"random",
"bytes",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/client/random/rand.go#L30-L36 |
10,582 | yarpc/yarpc-go | internal/crossdock/client/random/rand.go | String | func String(length int) string {
return base64.RawStdEncoding.EncodeToString(Bytes(length))[:length]
} | go | func String(length int) string {
return base64.RawStdEncoding.EncodeToString(Bytes(length))[:length]
} | [
"func",
"String",
"(",
"length",
"int",
")",
"string",
"{",
"return",
"base64",
".",
"RawStdEncoding",
".",
"EncodeToString",
"(",
"Bytes",
"(",
"length",
")",
")",
"[",
":",
"length",
"]",
"\n",
"}"
] | // String generates a random string of the given size. | [
"String",
"generates",
"a",
"random",
"string",
"of",
"the",
"given",
"size",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/internal/crossdock/client/random/rand.go#L39-L41 |
10,583 | yarpc/yarpc-go | yarpcerrors/codes.go | String | func (c Code) String() string {
s, ok := _codeToString[c]
if ok {
return s
}
return strconv.Itoa(int(c))
} | go | func (c Code) String() string {
s, ok := _codeToString[c]
if ok {
return s
}
return strconv.Itoa(int(c))
} | [
"func",
"(",
"c",
"Code",
")",
"String",
"(",
")",
"string",
"{",
"s",
",",
"ok",
":=",
"_codeToString",
"[",
"c",
"]",
"\n",
"if",
"ok",
"{",
"return",
"s",
"\n",
"}",
"\n",
"return",
"strconv",
".",
"Itoa",
"(",
"int",
"(",
"c",
")",
")",
"... | // String returns the the string representation of the Code. | [
"String",
"returns",
"the",
"the",
"string",
"representation",
"of",
"the",
"Code",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/yarpcerrors/codes.go#L194-L200 |
10,584 | yarpc/yarpc-go | transport/http/outbound.go | NewSingleOutbound | func (t *Transport) NewSingleOutbound(uri string, opts ...OutboundOption) *Outbound {
parsedURL, err := url.Parse(uri)
if err != nil {
panic(err.Error())
}
chooser := peerchooser.NewSingle(hostport.PeerIdentifier(parsedURL.Host), t)
o := t.NewOutbound(chooser)
for _, opt := range opts {
opt(o)
}
o.setURLTemplate(uri)
return o
} | go | func (t *Transport) NewSingleOutbound(uri string, opts ...OutboundOption) *Outbound {
parsedURL, err := url.Parse(uri)
if err != nil {
panic(err.Error())
}
chooser := peerchooser.NewSingle(hostport.PeerIdentifier(parsedURL.Host), t)
o := t.NewOutbound(chooser)
for _, opt := range opts {
opt(o)
}
o.setURLTemplate(uri)
return o
} | [
"func",
"(",
"t",
"*",
"Transport",
")",
"NewSingleOutbound",
"(",
"uri",
"string",
",",
"opts",
"...",
"OutboundOption",
")",
"*",
"Outbound",
"{",
"parsedURL",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"uri",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // NewSingleOutbound builds an outbound that sends YARPC requests over HTTP
// to the specified URL.
//
// The URLTemplate option has no effect in this form. | [
"NewSingleOutbound",
"builds",
"an",
"outbound",
"that",
"sends",
"YARPC",
"requests",
"over",
"HTTP",
"to",
"the",
"specified",
"URL",
".",
"The",
"URLTemplate",
"option",
"has",
"no",
"effect",
"in",
"this",
"form",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/transport/http/outbound.go#L135-L148 |
10,585 | yarpc/yarpc-go | transport/http/outbound.go | Call | func (o *Outbound) Call(ctx context.Context, treq *transport.Request) (*transport.Response, error) {
if treq == nil {
return nil, yarpcerrors.InvalidArgumentErrorf("request for http unary outbound was nil")
}
return o.call(ctx, treq)
} | go | func (o *Outbound) Call(ctx context.Context, treq *transport.Request) (*transport.Response, error) {
if treq == nil {
return nil, yarpcerrors.InvalidArgumentErrorf("request for http unary outbound was nil")
}
return o.call(ctx, treq)
} | [
"func",
"(",
"o",
"*",
"Outbound",
")",
"Call",
"(",
"ctx",
"context",
".",
"Context",
",",
"treq",
"*",
"transport",
".",
"Request",
")",
"(",
"*",
"transport",
".",
"Response",
",",
"error",
")",
"{",
"if",
"treq",
"==",
"nil",
"{",
"return",
"ni... | // Call makes a HTTP request | [
"Call",
"makes",
"a",
"HTTP",
"request"
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/transport/http/outbound.go#L208-L214 |
10,586 | yarpc/yarpc-go | transport/http/outbound.go | CallOneway | func (o *Outbound) CallOneway(ctx context.Context, treq *transport.Request) (transport.Ack, error) {
if treq == nil {
return nil, yarpcerrors.InvalidArgumentErrorf("request for http oneway outbound was nil")
}
_, err := o.call(ctx, treq)
if err != nil {
return nil, err
}
return time.Now(), nil
} | go | func (o *Outbound) CallOneway(ctx context.Context, treq *transport.Request) (transport.Ack, error) {
if treq == nil {
return nil, yarpcerrors.InvalidArgumentErrorf("request for http oneway outbound was nil")
}
_, err := o.call(ctx, treq)
if err != nil {
return nil, err
}
return time.Now(), nil
} | [
"func",
"(",
"o",
"*",
"Outbound",
")",
"CallOneway",
"(",
"ctx",
"context",
".",
"Context",
",",
"treq",
"*",
"transport",
".",
"Request",
")",
"(",
"transport",
".",
"Ack",
",",
"error",
")",
"{",
"if",
"treq",
"==",
"nil",
"{",
"return",
"nil",
... | // CallOneway makes a oneway request | [
"CallOneway",
"makes",
"a",
"oneway",
"request"
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/transport/http/outbound.go#L217-L228 |
10,587 | yarpc/yarpc-go | transport/http/outbound.go | checkServiceMatch | func checkServiceMatch(reqSvcName string, resHeaders http.Header) (bool, string) {
serviceName := resHeaders.Get(ServiceHeader)
return serviceName == "" || serviceName == reqSvcName, serviceName
} | go | func checkServiceMatch(reqSvcName string, resHeaders http.Header) (bool, string) {
serviceName := resHeaders.Get(ServiceHeader)
return serviceName == "" || serviceName == reqSvcName, serviceName
} | [
"func",
"checkServiceMatch",
"(",
"reqSvcName",
"string",
",",
"resHeaders",
"http",
".",
"Header",
")",
"(",
"bool",
",",
"string",
")",
"{",
"serviceName",
":=",
"resHeaders",
".",
"Get",
"(",
"ServiceHeader",
")",
"\n",
"return",
"serviceName",
"==",
"\""... | // Only does verification if there is a response header | [
"Only",
"does",
"verification",
"if",
"there",
"is",
"a",
"response",
"header"
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/transport/http/outbound.go#L412-L415 |
10,588 | yarpc/yarpc-go | serialize/internal/types.go | String | func (v *RPC) String() string {
if v == nil {
return "<nil>"
}
var fields [10]string
i := 0
fields[i] = fmt.Sprintf("SpanContext: %v", v.SpanContext)
i++
fields[i] = fmt.Sprintf("CallerName: %v", v.CallerName)
i++
fields[i] = fmt.Sprintf("ServiceName: %v", v.ServiceName)
i++
fields[i] = fmt.Sprintf("Encoding: %v", v.Encoding)
i++
fields[i] = fmt.Sprintf("Procedure: %v", v.Procedure)
i++
if v.Headers != nil {
fields[i] = fmt.Sprintf("Headers: %v", v.Headers)
i++
}
if v.ShardKey != nil {
fields[i] = fmt.Sprintf("ShardKey: %v", *(v.ShardKey))
i++
}
if v.RoutingKey != nil {
fields[i] = fmt.Sprintf("RoutingKey: %v", *(v.RoutingKey))
i++
}
if v.RoutingDelegate != nil {
fields[i] = fmt.Sprintf("RoutingDelegate: %v", *(v.RoutingDelegate))
i++
}
if v.Body != nil {
fields[i] = fmt.Sprintf("Body: %v", v.Body)
i++
}
return fmt.Sprintf("RPC{%v}", strings.Join(fields[:i], ", "))
} | go | func (v *RPC) String() string {
if v == nil {
return "<nil>"
}
var fields [10]string
i := 0
fields[i] = fmt.Sprintf("SpanContext: %v", v.SpanContext)
i++
fields[i] = fmt.Sprintf("CallerName: %v", v.CallerName)
i++
fields[i] = fmt.Sprintf("ServiceName: %v", v.ServiceName)
i++
fields[i] = fmt.Sprintf("Encoding: %v", v.Encoding)
i++
fields[i] = fmt.Sprintf("Procedure: %v", v.Procedure)
i++
if v.Headers != nil {
fields[i] = fmt.Sprintf("Headers: %v", v.Headers)
i++
}
if v.ShardKey != nil {
fields[i] = fmt.Sprintf("ShardKey: %v", *(v.ShardKey))
i++
}
if v.RoutingKey != nil {
fields[i] = fmt.Sprintf("RoutingKey: %v", *(v.RoutingKey))
i++
}
if v.RoutingDelegate != nil {
fields[i] = fmt.Sprintf("RoutingDelegate: %v", *(v.RoutingDelegate))
i++
}
if v.Body != nil {
fields[i] = fmt.Sprintf("Body: %v", v.Body)
i++
}
return fmt.Sprintf("RPC{%v}", strings.Join(fields[:i], ", "))
} | [
"func",
"(",
"v",
"*",
"RPC",
")",
"String",
"(",
")",
"string",
"{",
"if",
"v",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"var",
"fields",
"[",
"10",
"]",
"string",
"\n",
"i",
":=",
"0",
"\n",
"fields",
"[",
"i",
"]",
"=",
... | // String returns a readable string representation of a RPC
// struct. | [
"String",
"returns",
"a",
"readable",
"string",
"representation",
"of",
"a",
"RPC",
"struct",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/serialize/internal/types.go#L359-L398 |
10,589 | yarpc/yarpc-go | serialize/internal/types.go | Equals | func (v *RPC) Equals(rhs *RPC) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
if !bytes.Equal(v.SpanContext, rhs.SpanContext) {
return false
}
if !(v.CallerName == rhs.CallerName) {
return false
}
if !(v.ServiceName == rhs.ServiceName) {
return false
}
if !(v.Encoding == rhs.Encoding) {
return false
}
if !(v.Procedure == rhs.Procedure) {
return false
}
if !((v.Headers == nil && rhs.Headers == nil) || (v.Headers != nil && rhs.Headers != nil && _Map_String_String_Equals(v.Headers, rhs.Headers))) {
return false
}
if !_String_EqualsPtr(v.ShardKey, rhs.ShardKey) {
return false
}
if !_String_EqualsPtr(v.RoutingKey, rhs.RoutingKey) {
return false
}
if !_String_EqualsPtr(v.RoutingDelegate, rhs.RoutingDelegate) {
return false
}
if !((v.Body == nil && rhs.Body == nil) || (v.Body != nil && rhs.Body != nil && bytes.Equal(v.Body, rhs.Body))) {
return false
}
return true
} | go | func (v *RPC) Equals(rhs *RPC) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
if !bytes.Equal(v.SpanContext, rhs.SpanContext) {
return false
}
if !(v.CallerName == rhs.CallerName) {
return false
}
if !(v.ServiceName == rhs.ServiceName) {
return false
}
if !(v.Encoding == rhs.Encoding) {
return false
}
if !(v.Procedure == rhs.Procedure) {
return false
}
if !((v.Headers == nil && rhs.Headers == nil) || (v.Headers != nil && rhs.Headers != nil && _Map_String_String_Equals(v.Headers, rhs.Headers))) {
return false
}
if !_String_EqualsPtr(v.ShardKey, rhs.ShardKey) {
return false
}
if !_String_EqualsPtr(v.RoutingKey, rhs.RoutingKey) {
return false
}
if !_String_EqualsPtr(v.RoutingDelegate, rhs.RoutingDelegate) {
return false
}
if !((v.Body == nil && rhs.Body == nil) || (v.Body != nil && rhs.Body != nil && bytes.Equal(v.Body, rhs.Body))) {
return false
}
return true
} | [
"func",
"(",
"v",
"*",
"RPC",
")",
"Equals",
"(",
"rhs",
"*",
"RPC",
")",
"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 RPC match the
// provided RPC.
//
// This function performs a deep comparison. | [
"Equals",
"returns",
"true",
"if",
"all",
"the",
"fields",
"of",
"this",
"RPC",
"match",
"the",
"provided",
"RPC",
".",
"This",
"function",
"performs",
"a",
"deep",
"comparison",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/serialize/internal/types.go#L431-L469 |
10,590 | yarpc/yarpc-go | serialize/internal/types.go | MarshalLogObject | func (m _Map_String_String_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
for k, v := range m {
enc.AddString((string)(k), v)
}
return err
} | go | func (m _Map_String_String_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
for k, v := range m {
enc.AddString((string)(k), v)
}
return err
} | [
"func",
"(",
"m",
"_Map_String_String_Zapper",
")",
"MarshalLogObject",
"(",
"enc",
"zapcore",
".",
"ObjectEncoder",
")",
"(",
"err",
"error",
")",
"{",
"for",
"k",
",",
"v",
":=",
"range",
"m",
"{",
"enc",
".",
"AddString",
"(",
"(",
"string",
")",
"(... | // MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of _Map_String_String_Zapper. | [
"MarshalLogObject",
"implements",
"zapcore",
".",
"ObjectMarshaler",
"enabling",
"fast",
"logging",
"of",
"_Map_String_String_Zapper",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/serialize/internal/types.go#L475-L480 |
10,591 | yarpc/yarpc-go | serialize/internal/types.go | MarshalLogObject | func (v *RPC) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
enc.AddString("spanContext", base64.StdEncoding.EncodeToString(v.SpanContext))
enc.AddString("callerName", v.CallerName)
enc.AddString("serviceName", v.ServiceName)
enc.AddString("encoding", v.Encoding)
enc.AddString("procedure", v.Procedure)
if v.Headers != nil {
err = multierr.Append(err, enc.AddObject("headers", (_Map_String_String_Zapper)(v.Headers)))
}
if v.ShardKey != nil {
enc.AddString("shardKey", *v.ShardKey)
}
if v.RoutingKey != nil {
enc.AddString("routingKey", *v.RoutingKey)
}
if v.RoutingDelegate != nil {
enc.AddString("routingDelegate", *v.RoutingDelegate)
}
if v.Body != nil {
enc.AddString("body", base64.StdEncoding.EncodeToString(v.Body))
}
return err
} | go | func (v *RPC) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
enc.AddString("spanContext", base64.StdEncoding.EncodeToString(v.SpanContext))
enc.AddString("callerName", v.CallerName)
enc.AddString("serviceName", v.ServiceName)
enc.AddString("encoding", v.Encoding)
enc.AddString("procedure", v.Procedure)
if v.Headers != nil {
err = multierr.Append(err, enc.AddObject("headers", (_Map_String_String_Zapper)(v.Headers)))
}
if v.ShardKey != nil {
enc.AddString("shardKey", *v.ShardKey)
}
if v.RoutingKey != nil {
enc.AddString("routingKey", *v.RoutingKey)
}
if v.RoutingDelegate != nil {
enc.AddString("routingDelegate", *v.RoutingDelegate)
}
if v.Body != nil {
enc.AddString("body", base64.StdEncoding.EncodeToString(v.Body))
}
return err
} | [
"func",
"(",
"v",
"*",
"RPC",
")",
"MarshalLogObject",
"(",
"enc",
"zapcore",
".",
"ObjectEncoder",
")",
"(",
"err",
"error",
")",
"{",
"if",
"v",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"enc",
".",
"AddString",
"(",
"\"",
"\"",
",",
... | // MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of RPC. | [
"MarshalLogObject",
"implements",
"zapcore",
".",
"ObjectMarshaler",
"enabling",
"fast",
"logging",
"of",
"RPC",
"."
] | bd70ffbd17e635243988ba62be97eebff738204d | https://github.com/yarpc/yarpc-go/blob/bd70ffbd17e635243988ba62be97eebff738204d/serialize/internal/types.go#L484-L509 |
10,592 | yarpc/yarpc-go | serialize/internal/types.go | GetSpanContext | func (v *RPC) GetSpanContext() (o []byte) {
if v != nil {
o = v.SpanContext
}
return
} | go | func (v *RPC) GetSpanContext() (o []byte) {
if v != nil {
o = v.SpanContext
}
return
} | [
"func",
"(",
"v",
"*",
"RPC",
")",
"GetSpanContext",
"(",
")",
"(",
"o",
"[",
"]",
"byte",
")",
"{",
"if",
"v",
"!=",
"nil",
"{",
"o",
"=",
"v",
".",
"SpanContext",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // GetSpanContext returns the value of SpanContext if it is set or its
// zero value if it is unset. | [
"GetSpanContext",
"returns",
"the",
"value",
"of",
"SpanContext",
"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#L513-L518 |
10,593 | yarpc/yarpc-go | serialize/internal/types.go | GetCallerName | func (v *RPC) GetCallerName() (o string) {
if v != nil {
o = v.CallerName
}
return
} | go | func (v *RPC) GetCallerName() (o string) {
if v != nil {
o = v.CallerName
}
return
} | [
"func",
"(",
"v",
"*",
"RPC",
")",
"GetCallerName",
"(",
")",
"(",
"o",
"string",
")",
"{",
"if",
"v",
"!=",
"nil",
"{",
"o",
"=",
"v",
".",
"CallerName",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // GetCallerName returns the value of CallerName if it is set or its
// zero value if it is unset. | [
"GetCallerName",
"returns",
"the",
"value",
"of",
"CallerName",
"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#L527-L532 |
10,594 | yarpc/yarpc-go | serialize/internal/types.go | GetServiceName | func (v *RPC) GetServiceName() (o string) {
if v != nil {
o = v.ServiceName
}
return
} | go | func (v *RPC) GetServiceName() (o string) {
if v != nil {
o = v.ServiceName
}
return
} | [
"func",
"(",
"v",
"*",
"RPC",
")",
"GetServiceName",
"(",
")",
"(",
"o",
"string",
")",
"{",
"if",
"v",
"!=",
"nil",
"{",
"o",
"=",
"v",
".",
"ServiceName",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // GetServiceName returns the value of ServiceName if it is set or its
// zero value if it is unset. | [
"GetServiceName",
"returns",
"the",
"value",
"of",
"ServiceName",
"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#L536-L541 |
10,595 | yarpc/yarpc-go | serialize/internal/types.go | GetEncoding | func (v *RPC) GetEncoding() (o string) {
if v != nil {
o = v.Encoding
}
return
} | go | func (v *RPC) GetEncoding() (o string) {
if v != nil {
o = v.Encoding
}
return
} | [
"func",
"(",
"v",
"*",
"RPC",
")",
"GetEncoding",
"(",
")",
"(",
"o",
"string",
")",
"{",
"if",
"v",
"!=",
"nil",
"{",
"o",
"=",
"v",
".",
"Encoding",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // GetEncoding returns the value of Encoding if it is set or its
// zero value if it is unset. | [
"GetEncoding",
"returns",
"the",
"value",
"of",
"Encoding",
"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#L545-L550 |
10,596 | yarpc/yarpc-go | serialize/internal/types.go | GetProcedure | func (v *RPC) GetProcedure() (o string) {
if v != nil {
o = v.Procedure
}
return
} | go | func (v *RPC) GetProcedure() (o string) {
if v != nil {
o = v.Procedure
}
return
} | [
"func",
"(",
"v",
"*",
"RPC",
")",
"GetProcedure",
"(",
")",
"(",
"o",
"string",
")",
"{",
"if",
"v",
"!=",
"nil",
"{",
"o",
"=",
"v",
".",
"Procedure",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // GetProcedure returns the value of Procedure if it is set or its
// zero value if it is unset. | [
"GetProcedure",
"returns",
"the",
"value",
"of",
"Procedure",
"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#L554-L559 |
10,597 | yarpc/yarpc-go | serialize/internal/types.go | GetHeaders | func (v *RPC) GetHeaders() (o map[string]string) {
if v != nil && v.Headers != nil {
return v.Headers
}
return
} | go | func (v *RPC) GetHeaders() (o map[string]string) {
if v != nil && v.Headers != nil {
return v.Headers
}
return
} | [
"func",
"(",
"v",
"*",
"RPC",
")",
"GetHeaders",
"(",
")",
"(",
"o",
"map",
"[",
"string",
"]",
"string",
")",
"{",
"if",
"v",
"!=",
"nil",
"&&",
"v",
".",
"Headers",
"!=",
"nil",
"{",
"return",
"v",
".",
"Headers",
"\n",
"}",
"\n\n",
"return",... | // GetHeaders returns the value of Headers if it is set or its
// zero value if it is unset. | [
"GetHeaders",
"returns",
"the",
"value",
"of",
"Headers",
"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#L563-L569 |
10,598 | yarpc/yarpc-go | serialize/internal/types.go | GetShardKey | func (v *RPC) GetShardKey() (o string) {
if v != nil && v.ShardKey != nil {
return *v.ShardKey
}
return
} | go | func (v *RPC) GetShardKey() (o string) {
if v != nil && v.ShardKey != nil {
return *v.ShardKey
}
return
} | [
"func",
"(",
"v",
"*",
"RPC",
")",
"GetShardKey",
"(",
")",
"(",
"o",
"string",
")",
"{",
"if",
"v",
"!=",
"nil",
"&&",
"v",
".",
"ShardKey",
"!=",
"nil",
"{",
"return",
"*",
"v",
".",
"ShardKey",
"\n",
"}",
"\n\n",
"return",
"\n",
"}"
] | // GetShardKey returns the value of ShardKey if it is set or its
// zero value if it is unset. | [
"GetShardKey",
"returns",
"the",
"value",
"of",
"ShardKey",
"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#L578-L584 |
10,599 | yarpc/yarpc-go | serialize/internal/types.go | GetRoutingKey | func (v *RPC) GetRoutingKey() (o string) {
if v != nil && v.RoutingKey != nil {
return *v.RoutingKey
}
return
} | go | func (v *RPC) GetRoutingKey() (o string) {
if v != nil && v.RoutingKey != nil {
return *v.RoutingKey
}
return
} | [
"func",
"(",
"v",
"*",
"RPC",
")",
"GetRoutingKey",
"(",
")",
"(",
"o",
"string",
")",
"{",
"if",
"v",
"!=",
"nil",
"&&",
"v",
".",
"RoutingKey",
"!=",
"nil",
"{",
"return",
"*",
"v",
".",
"RoutingKey",
"\n",
"}",
"\n\n",
"return",
"\n",
"}"
] | // GetRoutingKey returns the value of RoutingKey if it is set or its
// zero value if it is unset. | [
"GetRoutingKey",
"returns",
"the",
"value",
"of",
"RoutingKey",
"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#L593-L599 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.