repo stringlengths 5 67 | path stringlengths 4 218 | func_name stringlengths 0 151 | original_string stringlengths 52 373k | language stringclasses 6
values | code stringlengths 52 373k | code_tokens listlengths 10 512 | docstring stringlengths 3 47.2k | docstring_tokens listlengths 3 234 | sha stringlengths 40 40 | url stringlengths 85 339 | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
uber/tchannel-go | reqres.go | argReader | func (r *reqResReader) argReader(last bool, inState reqResReaderState, outState reqResReaderState) (ArgReader, error) {
if r.state != inState {
return nil, r.failed(errReqResReaderStateMismatch{state: r.state, expectedState: inState})
}
argReader, err := r.contents.ArgReader(last)
if err != nil {
return nil, r... | go | func (r *reqResReader) argReader(last bool, inState reqResReaderState, outState reqResReaderState) (ArgReader, error) {
if r.state != inState {
return nil, r.failed(errReqResReaderStateMismatch{state: r.state, expectedState: inState})
}
argReader, err := r.contents.ArgReader(last)
if err != nil {
return nil, r... | [
"func",
"(",
"r",
"*",
"reqResReader",
")",
"argReader",
"(",
"last",
"bool",
",",
"inState",
"reqResReaderState",
",",
"outState",
"reqResReaderState",
")",
"(",
"ArgReader",
",",
"error",
")",
"{",
"if",
"r",
".",
"state",
"!=",
"inState",
"{",
"return",... | // argReader returns an ArgReader that can be used to read an argument. The
// ReadCloser must be closed once the argument has been read. | [
"argReader",
"returns",
"an",
"ArgReader",
"that",
"can",
"be",
"used",
"to",
"read",
"an",
"argument",
".",
"The",
"ReadCloser",
"must",
"be",
"closed",
"once",
"the",
"argument",
"has",
"been",
"read",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/reqres.go#L211-L223 | test |
uber/tchannel-go | reqres.go | recvNextFragment | func (r *reqResReader) recvNextFragment(initial bool) (*readableFragment, error) {
if r.initialFragment != nil {
fragment := r.initialFragment
r.initialFragment = nil
r.previousFragment = fragment
return fragment, nil
}
// Wait for the appropriate message from the peer
message := r.messageForFragment(initi... | go | func (r *reqResReader) recvNextFragment(initial bool) (*readableFragment, error) {
if r.initialFragment != nil {
fragment := r.initialFragment
r.initialFragment = nil
r.previousFragment = fragment
return fragment, nil
}
// Wait for the appropriate message from the peer
message := r.messageForFragment(initi... | [
"func",
"(",
"r",
"*",
"reqResReader",
")",
"recvNextFragment",
"(",
"initial",
"bool",
")",
"(",
"*",
"readableFragment",
",",
"error",
")",
"{",
"if",
"r",
".",
"initialFragment",
"!=",
"nil",
"{",
"fragment",
":=",
"r",
".",
"initialFragment",
"\n",
"... | // recvNextFragment receives the next fragment from the underlying message exchange. | [
"recvNextFragment",
"receives",
"the",
"next",
"fragment",
"from",
"the",
"underlying",
"message",
"exchange",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/reqres.go#L226-L256 | test |
uber/tchannel-go | reqres.go | releasePreviousFragment | func (r *reqResReader) releasePreviousFragment() {
fragment := r.previousFragment
r.previousFragment = nil
if fragment != nil {
fragment.done()
}
} | go | func (r *reqResReader) releasePreviousFragment() {
fragment := r.previousFragment
r.previousFragment = nil
if fragment != nil {
fragment.done()
}
} | [
"func",
"(",
"r",
"*",
"reqResReader",
")",
"releasePreviousFragment",
"(",
")",
"{",
"fragment",
":=",
"r",
".",
"previousFragment",
"\n",
"r",
".",
"previousFragment",
"=",
"nil",
"\n",
"if",
"fragment",
"!=",
"nil",
"{",
"fragment",
".",
"done",
"(",
... | // releasePreviousFrament releases the last fragment returned by the reader if
// it's still around. This operation is idempotent. | [
"releasePreviousFrament",
"releases",
"the",
"last",
"fragment",
"returned",
"by",
"the",
"reader",
"if",
"it",
"s",
"still",
"around",
".",
"This",
"operation",
"is",
"idempotent",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/reqres.go#L260-L266 | test |
uber/tchannel-go | reqres.go | failed | func (r *reqResReader) failed(err error) error {
r.log.Debugf("reader failed: %v existing err: %v", err, r.err)
if r.err != nil {
return r.err
}
r.mex.shutdown()
r.err = err
return r.err
} | go | func (r *reqResReader) failed(err error) error {
r.log.Debugf("reader failed: %v existing err: %v", err, r.err)
if r.err != nil {
return r.err
}
r.mex.shutdown()
r.err = err
return r.err
} | [
"func",
"(",
"r",
"*",
"reqResReader",
")",
"failed",
"(",
"err",
"error",
")",
"error",
"{",
"r",
".",
"log",
".",
"Debugf",
"(",
"\"reader failed: %v existing err: %v\"",
",",
"err",
",",
"r",
".",
"err",
")",
"\n",
"if",
"r",
".",
"err",
"!=",
"ni... | // failed indicates the reader failed | [
"failed",
"indicates",
"the",
"reader",
"failed"
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/reqres.go#L269-L278 | test |
uber/tchannel-go | reqres.go | parseInboundFragment | func parseInboundFragment(framePool FramePool, frame *Frame, message message) (*readableFragment, error) {
rbuf := typed.NewReadBuffer(frame.SizedPayload())
fragment := new(readableFragment)
fragment.flags = rbuf.ReadSingleByte()
if err := message.read(rbuf); err != nil {
return nil, err
}
fragment.checksumTyp... | go | func parseInboundFragment(framePool FramePool, frame *Frame, message message) (*readableFragment, error) {
rbuf := typed.NewReadBuffer(frame.SizedPayload())
fragment := new(readableFragment)
fragment.flags = rbuf.ReadSingleByte()
if err := message.read(rbuf); err != nil {
return nil, err
}
fragment.checksumTyp... | [
"func",
"parseInboundFragment",
"(",
"framePool",
"FramePool",
",",
"frame",
"*",
"Frame",
",",
"message",
"message",
")",
"(",
"*",
"readableFragment",
",",
"error",
")",
"{",
"rbuf",
":=",
"typed",
".",
"NewReadBuffer",
"(",
"frame",
".",
"SizedPayload",
"... | // parseInboundFragment parses an incoming fragment based on the given message | [
"parseInboundFragment",
"parses",
"an",
"incoming",
"fragment",
"based",
"on",
"the",
"given",
"message"
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/reqres.go#L281-L296 | test |
uber/tchannel-go | thrift/context.go | NewContext | func NewContext(timeout time.Duration) (Context, context.CancelFunc) {
ctx, cancel := tchannel.NewContext(timeout)
return Wrap(ctx), cancel
} | go | func NewContext(timeout time.Duration) (Context, context.CancelFunc) {
ctx, cancel := tchannel.NewContext(timeout)
return Wrap(ctx), cancel
} | [
"func",
"NewContext",
"(",
"timeout",
"time",
".",
"Duration",
")",
"(",
"Context",
",",
"context",
".",
"CancelFunc",
")",
"{",
"ctx",
",",
"cancel",
":=",
"tchannel",
".",
"NewContext",
"(",
"timeout",
")",
"\n",
"return",
"Wrap",
"(",
"ctx",
")",
",... | // NewContext returns a Context that can be used to make Thrift calls. | [
"NewContext",
"returns",
"a",
"Context",
"that",
"can",
"be",
"used",
"to",
"make",
"Thrift",
"calls",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/context.go#L34-L37 | test |
uber/tchannel-go | thrift/context.go | WithHeaders | func WithHeaders(ctx context.Context, headers map[string]string) Context {
return tchannel.WrapWithHeaders(ctx, headers)
} | go | func WithHeaders(ctx context.Context, headers map[string]string) Context {
return tchannel.WrapWithHeaders(ctx, headers)
} | [
"func",
"WithHeaders",
"(",
"ctx",
"context",
".",
"Context",
",",
"headers",
"map",
"[",
"string",
"]",
"string",
")",
"Context",
"{",
"return",
"tchannel",
".",
"WrapWithHeaders",
"(",
"ctx",
",",
"headers",
")",
"\n",
"}"
] | // WithHeaders returns a Context that can be used to make a call with request headers. | [
"WithHeaders",
"returns",
"a",
"Context",
"that",
"can",
"be",
"used",
"to",
"make",
"a",
"call",
"with",
"request",
"headers",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/context.go#L45-L47 | test |
uber/tchannel-go | health.go | healthCheck | func (c *Connection) healthCheck(connID uint32) {
defer close(c.healthCheckDone)
opts := c.opts.HealthChecks
ticker := c.timeTicker(opts.Interval)
defer ticker.Stop()
consecutiveFailures := 0
for {
select {
case <-ticker.C:
case <-c.healthCheckCtx.Done():
return
}
ctx, cancel := context.WithTimeo... | go | func (c *Connection) healthCheck(connID uint32) {
defer close(c.healthCheckDone)
opts := c.opts.HealthChecks
ticker := c.timeTicker(opts.Interval)
defer ticker.Stop()
consecutiveFailures := 0
for {
select {
case <-ticker.C:
case <-c.healthCheckCtx.Done():
return
}
ctx, cancel := context.WithTimeo... | [
"func",
"(",
"c",
"*",
"Connection",
")",
"healthCheck",
"(",
"connID",
"uint32",
")",
"{",
"defer",
"close",
"(",
"c",
".",
"healthCheckDone",
")",
"\n",
"opts",
":=",
"c",
".",
"opts",
".",
"HealthChecks",
"\n",
"ticker",
":=",
"c",
".",
"timeTicker"... | // healthCheck will do periodic pings on the connection to check the state of the connection.
// We accept connID on the stack so can more easily debug panics or leaked goroutines. | [
"healthCheck",
"will",
"do",
"periodic",
"pings",
"on",
"the",
"connection",
"to",
"check",
"the",
"state",
"of",
"the",
"connection",
".",
"We",
"accept",
"connID",
"on",
"the",
"stack",
"so",
"can",
"more",
"easily",
"debug",
"panics",
"or",
"leaked",
"g... | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/health.go#L111-L161 | test |
uber/tchannel-go | context_builder.go | SetTimeout | func (cb *ContextBuilder) SetTimeout(timeout time.Duration) *ContextBuilder {
cb.Timeout = timeout
return cb
} | go | func (cb *ContextBuilder) SetTimeout(timeout time.Duration) *ContextBuilder {
cb.Timeout = timeout
return cb
} | [
"func",
"(",
"cb",
"*",
"ContextBuilder",
")",
"SetTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"ContextBuilder",
"{",
"cb",
".",
"Timeout",
"=",
"timeout",
"\n",
"return",
"cb",
"\n",
"}"
] | // SetTimeout sets the timeout for the Context. | [
"SetTimeout",
"sets",
"the",
"timeout",
"for",
"the",
"Context",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/context_builder.go#L77-L80 | test |
uber/tchannel-go | context_builder.go | AddHeader | func (cb *ContextBuilder) AddHeader(key, value string) *ContextBuilder {
if cb.Headers == nil {
cb.Headers = map[string]string{key: value}
} else {
cb.Headers[key] = value
}
return cb
} | go | func (cb *ContextBuilder) AddHeader(key, value string) *ContextBuilder {
if cb.Headers == nil {
cb.Headers = map[string]string{key: value}
} else {
cb.Headers[key] = value
}
return cb
} | [
"func",
"(",
"cb",
"*",
"ContextBuilder",
")",
"AddHeader",
"(",
"key",
",",
"value",
"string",
")",
"*",
"ContextBuilder",
"{",
"if",
"cb",
".",
"Headers",
"==",
"nil",
"{",
"cb",
".",
"Headers",
"=",
"map",
"[",
"string",
"]",
"string",
"{",
"key",... | // AddHeader adds a single application header to the Context. | [
"AddHeader",
"adds",
"a",
"single",
"application",
"header",
"to",
"the",
"Context",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/context_builder.go#L83-L90 | test |
uber/tchannel-go | context_builder.go | SetHeaders | func (cb *ContextBuilder) SetHeaders(headers map[string]string) *ContextBuilder {
cb.Headers = headers
cb.replaceParentHeaders = true
return cb
} | go | func (cb *ContextBuilder) SetHeaders(headers map[string]string) *ContextBuilder {
cb.Headers = headers
cb.replaceParentHeaders = true
return cb
} | [
"func",
"(",
"cb",
"*",
"ContextBuilder",
")",
"SetHeaders",
"(",
"headers",
"map",
"[",
"string",
"]",
"string",
")",
"*",
"ContextBuilder",
"{",
"cb",
".",
"Headers",
"=",
"headers",
"\n",
"cb",
".",
"replaceParentHeaders",
"=",
"true",
"\n",
"return",
... | // SetHeaders sets the application headers for this Context.
// If there is a ParentContext, its headers will be ignored after the call to this method. | [
"SetHeaders",
"sets",
"the",
"application",
"headers",
"for",
"this",
"Context",
".",
"If",
"there",
"is",
"a",
"ParentContext",
"its",
"headers",
"will",
"be",
"ignored",
"after",
"the",
"call",
"to",
"this",
"method",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/context_builder.go#L94-L98 | test |
uber/tchannel-go | context_builder.go | SetConnectTimeout | func (cb *ContextBuilder) SetConnectTimeout(d time.Duration) *ContextBuilder {
cb.ConnectTimeout = d
return cb
} | go | func (cb *ContextBuilder) SetConnectTimeout(d time.Duration) *ContextBuilder {
cb.ConnectTimeout = d
return cb
} | [
"func",
"(",
"cb",
"*",
"ContextBuilder",
")",
"SetConnectTimeout",
"(",
"d",
"time",
".",
"Duration",
")",
"*",
"ContextBuilder",
"{",
"cb",
".",
"ConnectTimeout",
"=",
"d",
"\n",
"return",
"cb",
"\n",
"}"
] | // SetConnectTimeout sets the ConnectionTimeout for this context.
// The context timeout applies to the whole call, while the connect
// timeout only applies to creating a new connection. | [
"SetConnectTimeout",
"sets",
"the",
"ConnectionTimeout",
"for",
"this",
"context",
".",
"The",
"context",
"timeout",
"applies",
"to",
"the",
"whole",
"call",
"while",
"the",
"connect",
"timeout",
"only",
"applies",
"to",
"creating",
"a",
"new",
"connection",
"."... | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/context_builder.go#L139-L142 | test |
uber/tchannel-go | context_builder.go | SetRetryOptions | func (cb *ContextBuilder) SetRetryOptions(retryOptions *RetryOptions) *ContextBuilder {
cb.RetryOptions = retryOptions
return cb
} | go | func (cb *ContextBuilder) SetRetryOptions(retryOptions *RetryOptions) *ContextBuilder {
cb.RetryOptions = retryOptions
return cb
} | [
"func",
"(",
"cb",
"*",
"ContextBuilder",
")",
"SetRetryOptions",
"(",
"retryOptions",
"*",
"RetryOptions",
")",
"*",
"ContextBuilder",
"{",
"cb",
".",
"RetryOptions",
"=",
"retryOptions",
"\n",
"return",
"cb",
"\n",
"}"
] | // SetRetryOptions sets RetryOptions in the context. | [
"SetRetryOptions",
"sets",
"RetryOptions",
"in",
"the",
"context",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/context_builder.go#L164-L167 | test |
uber/tchannel-go | context_builder.go | SetTimeoutPerAttempt | func (cb *ContextBuilder) SetTimeoutPerAttempt(timeoutPerAttempt time.Duration) *ContextBuilder {
if cb.RetryOptions == nil {
cb.RetryOptions = &RetryOptions{}
}
cb.RetryOptions.TimeoutPerAttempt = timeoutPerAttempt
return cb
} | go | func (cb *ContextBuilder) SetTimeoutPerAttempt(timeoutPerAttempt time.Duration) *ContextBuilder {
if cb.RetryOptions == nil {
cb.RetryOptions = &RetryOptions{}
}
cb.RetryOptions.TimeoutPerAttempt = timeoutPerAttempt
return cb
} | [
"func",
"(",
"cb",
"*",
"ContextBuilder",
")",
"SetTimeoutPerAttempt",
"(",
"timeoutPerAttempt",
"time",
".",
"Duration",
")",
"*",
"ContextBuilder",
"{",
"if",
"cb",
".",
"RetryOptions",
"==",
"nil",
"{",
"cb",
".",
"RetryOptions",
"=",
"&",
"RetryOptions",
... | // SetTimeoutPerAttempt sets TimeoutPerAttempt in RetryOptions. | [
"SetTimeoutPerAttempt",
"sets",
"TimeoutPerAttempt",
"in",
"RetryOptions",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/context_builder.go#L170-L176 | test |
uber/tchannel-go | context_builder.go | SetParentContext | func (cb *ContextBuilder) SetParentContext(ctx context.Context) *ContextBuilder {
cb.ParentContext = ctx
return cb
} | go | func (cb *ContextBuilder) SetParentContext(ctx context.Context) *ContextBuilder {
cb.ParentContext = ctx
return cb
} | [
"func",
"(",
"cb",
"*",
"ContextBuilder",
")",
"SetParentContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"ContextBuilder",
"{",
"cb",
".",
"ParentContext",
"=",
"ctx",
"\n",
"return",
"cb",
"\n",
"}"
] | // SetParentContext sets the parent for the Context. | [
"SetParentContext",
"sets",
"the",
"parent",
"for",
"the",
"Context",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/context_builder.go#L179-L182 | test |
uber/tchannel-go | context_builder.go | Build | func (cb *ContextBuilder) Build() (ContextWithHeaders, context.CancelFunc) {
params := &tchannelCtxParams{
options: cb.CallOptions,
call: cb.incomingCall,
retryOptions: cb.RetryOptions,
connectTimeout: cb.ConnectTimeout,
hideListeningOnOutbound: cb.hideL... | go | func (cb *ContextBuilder) Build() (ContextWithHeaders, context.CancelFunc) {
params := &tchannelCtxParams{
options: cb.CallOptions,
call: cb.incomingCall,
retryOptions: cb.RetryOptions,
connectTimeout: cb.ConnectTimeout,
hideListeningOnOutbound: cb.hideL... | [
"func",
"(",
"cb",
"*",
"ContextBuilder",
")",
"Build",
"(",
")",
"(",
"ContextWithHeaders",
",",
"context",
".",
"CancelFunc",
")",
"{",
"params",
":=",
"&",
"tchannelCtxParams",
"{",
"options",
":",
"cb",
".",
"CallOptions",
",",
"call",
":",
"cb",
"."... | // Build returns a ContextWithHeaders that can be used to make calls. | [
"Build",
"returns",
"a",
"ContextWithHeaders",
"that",
"can",
"be",
"used",
"to",
"make",
"calls",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/context_builder.go#L210-L244 | test |
uber/tchannel-go | calloptions.go | overrideHeaders | func (c *CallOptions) overrideHeaders(headers transportHeaders) {
if c.Format != "" {
headers[ArgScheme] = c.Format.String()
}
if c.ShardKey != "" {
headers[ShardKey] = c.ShardKey
}
if c.RoutingKey != "" {
headers[RoutingKey] = c.RoutingKey
}
if c.RoutingDelegate != "" {
headers[RoutingDelegate] = c.Rout... | go | func (c *CallOptions) overrideHeaders(headers transportHeaders) {
if c.Format != "" {
headers[ArgScheme] = c.Format.String()
}
if c.ShardKey != "" {
headers[ShardKey] = c.ShardKey
}
if c.RoutingKey != "" {
headers[RoutingKey] = c.RoutingKey
}
if c.RoutingDelegate != "" {
headers[RoutingDelegate] = c.Rout... | [
"func",
"(",
"c",
"*",
"CallOptions",
")",
"overrideHeaders",
"(",
"headers",
"transportHeaders",
")",
"{",
"if",
"c",
".",
"Format",
"!=",
"\"\"",
"{",
"headers",
"[",
"ArgScheme",
"]",
"=",
"c",
".",
"Format",
".",
"String",
"(",
")",
"\n",
"}",
"\... | // overrideHeaders sets headers if the call options contains non-default values. | [
"overrideHeaders",
"sets",
"headers",
"if",
"the",
"call",
"options",
"contains",
"non",
"-",
"default",
"values",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/calloptions.go#L72-L88 | test |
uber/tchannel-go | arguments.go | Read | func (r ArgReadHelper) Read(bs *[]byte) error {
return r.read(func() error {
var err error
*bs, err = ioutil.ReadAll(r.reader)
return err
})
} | go | func (r ArgReadHelper) Read(bs *[]byte) error {
return r.read(func() error {
var err error
*bs, err = ioutil.ReadAll(r.reader)
return err
})
} | [
"func",
"(",
"r",
"ArgReadHelper",
")",
"Read",
"(",
"bs",
"*",
"[",
"]",
"byte",
")",
"error",
"{",
"return",
"r",
".",
"read",
"(",
"func",
"(",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"*",
"bs",
",",
"err",
"=",
"ioutil",
".",
"ReadA... | // Read reads from the reader into the byte slice. | [
"Read",
"reads",
"from",
"the",
"reader",
"into",
"the",
"byte",
"slice",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/arguments.go#L86-L92 | test |
uber/tchannel-go | arguments.go | ReadJSON | func (r ArgReadHelper) ReadJSON(data interface{}) error {
return r.read(func() error {
// TChannel allows for 0 length values (not valid JSON), so we use a bufio.Reader
// to check whether data is of 0 length.
reader := bufio.NewReader(r.reader)
if _, err := reader.Peek(1); err == io.EOF {
// If the data is... | go | func (r ArgReadHelper) ReadJSON(data interface{}) error {
return r.read(func() error {
// TChannel allows for 0 length values (not valid JSON), so we use a bufio.Reader
// to check whether data is of 0 length.
reader := bufio.NewReader(r.reader)
if _, err := reader.Peek(1); err == io.EOF {
// If the data is... | [
"func",
"(",
"r",
"ArgReadHelper",
")",
"ReadJSON",
"(",
"data",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"r",
".",
"read",
"(",
"func",
"(",
")",
"error",
"{",
"reader",
":=",
"bufio",
".",
"NewReader",
"(",
"r",
".",
"reader",
")",
"\n... | // ReadJSON deserializes JSON from the underlying reader into data. | [
"ReadJSON",
"deserializes",
"JSON",
"from",
"the",
"underlying",
"reader",
"into",
"data",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/arguments.go#L95-L110 | test |
uber/tchannel-go | arguments.go | NewArgWriter | func NewArgWriter(writer io.WriteCloser, err error) ArgWriteHelper {
return ArgWriteHelper{writer, err}
} | go | func NewArgWriter(writer io.WriteCloser, err error) ArgWriteHelper {
return ArgWriteHelper{writer, err}
} | [
"func",
"NewArgWriter",
"(",
"writer",
"io",
".",
"WriteCloser",
",",
"err",
"error",
")",
"ArgWriteHelper",
"{",
"return",
"ArgWriteHelper",
"{",
"writer",
",",
"err",
"}",
"\n",
"}"
] | // NewArgWriter wraps the result of calling ArgXWriter to provider a simpler
// interface for writing arguments. | [
"NewArgWriter",
"wraps",
"the",
"result",
"of",
"calling",
"ArgXWriter",
"to",
"provider",
"a",
"simpler",
"interface",
"for",
"writing",
"arguments",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/arguments.go#L120-L122 | test |
uber/tchannel-go | arguments.go | Write | func (w ArgWriteHelper) Write(bs []byte) error {
return w.write(func() error {
_, err := w.writer.Write(bs)
return err
})
} | go | func (w ArgWriteHelper) Write(bs []byte) error {
return w.write(func() error {
_, err := w.writer.Write(bs)
return err
})
} | [
"func",
"(",
"w",
"ArgWriteHelper",
")",
"Write",
"(",
"bs",
"[",
"]",
"byte",
")",
"error",
"{",
"return",
"w",
".",
"write",
"(",
"func",
"(",
")",
"error",
"{",
"_",
",",
"err",
":=",
"w",
".",
"writer",
".",
"Write",
"(",
"bs",
")",
"\n",
... | // Write writes the given bytes to the underlying writer. | [
"Write",
"writes",
"the",
"given",
"bytes",
"to",
"the",
"underlying",
"writer",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/arguments.go#L137-L142 | test |
uber/tchannel-go | arguments.go | WriteJSON | func (w ArgWriteHelper) WriteJSON(data interface{}) error {
return w.write(func() error {
e := json.NewEncoder(w.writer)
return e.Encode(data)
})
} | go | func (w ArgWriteHelper) WriteJSON(data interface{}) error {
return w.write(func() error {
e := json.NewEncoder(w.writer)
return e.Encode(data)
})
} | [
"func",
"(",
"w",
"ArgWriteHelper",
")",
"WriteJSON",
"(",
"data",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"w",
".",
"write",
"(",
"func",
"(",
")",
"error",
"{",
"e",
":=",
"json",
".",
"NewEncoder",
"(",
"w",
".",
"writer",
")",
"\n",... | // WriteJSON writes the given object as JSON. | [
"WriteJSON",
"writes",
"the",
"given",
"object",
"as",
"JSON",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/arguments.go#L145-L150 | test |
uber/tchannel-go | pprof/pprof.go | Register | func Register(registrar tchannel.Registrar) {
handler := func(ctx context.Context, call *tchannel.InboundCall) {
req, err := thttp.ReadRequest(call)
if err != nil {
registrar.Logger().WithFields(
tchannel.LogField{Key: "err", Value: err.Error()},
).Warn("Failed to read HTTP request.")
return
}
se... | go | func Register(registrar tchannel.Registrar) {
handler := func(ctx context.Context, call *tchannel.InboundCall) {
req, err := thttp.ReadRequest(call)
if err != nil {
registrar.Logger().WithFields(
tchannel.LogField{Key: "err", Value: err.Error()},
).Warn("Failed to read HTTP request.")
return
}
se... | [
"func",
"Register",
"(",
"registrar",
"tchannel",
".",
"Registrar",
")",
"{",
"handler",
":=",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"call",
"*",
"tchannel",
".",
"InboundCall",
")",
"{",
"req",
",",
"err",
":=",
"thttp",
".",
"ReadRequest"... | // Register registers pprof endpoints on the given registrar under _pprof.
// The _pprof endpoint uses as-http and is a tunnel to the default serve mux. | [
"Register",
"registers",
"pprof",
"endpoints",
"on",
"the",
"given",
"registrar",
"under",
"_pprof",
".",
"The",
"_pprof",
"endpoint",
"uses",
"as",
"-",
"http",
"and",
"is",
"a",
"tunnel",
"to",
"the",
"default",
"serve",
"mux",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/pprof/pprof.go#L41-L54 | test |
uber/tchannel-go | relay.go | Count | func (r *relayItems) Count() int {
r.RLock()
n := len(r.items) - int(r.tombs)
r.RUnlock()
return n
} | go | func (r *relayItems) Count() int {
r.RLock()
n := len(r.items) - int(r.tombs)
r.RUnlock()
return n
} | [
"func",
"(",
"r",
"*",
"relayItems",
")",
"Count",
"(",
")",
"int",
"{",
"r",
".",
"RLock",
"(",
")",
"\n",
"n",
":=",
"len",
"(",
"r",
".",
"items",
")",
"-",
"int",
"(",
"r",
".",
"tombs",
")",
"\n",
"r",
".",
"RUnlock",
"(",
")",
"\n",
... | // Count returns the number of non-tombstone items in the relay. | [
"Count",
"returns",
"the",
"number",
"of",
"non",
"-",
"tombstone",
"items",
"in",
"the",
"relay",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/relay.go#L86-L91 | test |
uber/tchannel-go | relay.go | Get | func (r *relayItems) Get(id uint32) (relayItem, bool) {
r.RLock()
item, ok := r.items[id]
r.RUnlock()
return item, ok
} | go | func (r *relayItems) Get(id uint32) (relayItem, bool) {
r.RLock()
item, ok := r.items[id]
r.RUnlock()
return item, ok
} | [
"func",
"(",
"r",
"*",
"relayItems",
")",
"Get",
"(",
"id",
"uint32",
")",
"(",
"relayItem",
",",
"bool",
")",
"{",
"r",
".",
"RLock",
"(",
")",
"\n",
"item",
",",
"ok",
":=",
"r",
".",
"items",
"[",
"id",
"]",
"\n",
"r",
".",
"RUnlock",
"(",... | // Get checks for a relay item by ID, returning the item and a bool indicating
// whether the item was found. | [
"Get",
"checks",
"for",
"a",
"relay",
"item",
"by",
"ID",
"returning",
"the",
"item",
"and",
"a",
"bool",
"indicating",
"whether",
"the",
"item",
"was",
"found",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/relay.go#L95-L101 | test |
uber/tchannel-go | relay.go | Add | func (r *relayItems) Add(id uint32, item relayItem) {
r.Lock()
r.items[id] = item
r.Unlock()
} | go | func (r *relayItems) Add(id uint32, item relayItem) {
r.Lock()
r.items[id] = item
r.Unlock()
} | [
"func",
"(",
"r",
"*",
"relayItems",
")",
"Add",
"(",
"id",
"uint32",
",",
"item",
"relayItem",
")",
"{",
"r",
".",
"Lock",
"(",
")",
"\n",
"r",
".",
"items",
"[",
"id",
"]",
"=",
"item",
"\n",
"r",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // Add adds a relay item. | [
"Add",
"adds",
"a",
"relay",
"item",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/relay.go#L104-L108 | test |
uber/tchannel-go | relay.go | Entomb | func (r *relayItems) Entomb(id uint32, deleteAfter time.Duration) (relayItem, bool) {
r.Lock()
if r.tombs > _maxRelayTombs {
r.Unlock()
r.logger.WithFields(LogField{"id", id}).Warn("Too many tombstones, deleting relay item immediately.")
return r.Delete(id)
}
item, ok := r.items[id]
if !ok {
r.Unlock()
r... | go | func (r *relayItems) Entomb(id uint32, deleteAfter time.Duration) (relayItem, bool) {
r.Lock()
if r.tombs > _maxRelayTombs {
r.Unlock()
r.logger.WithFields(LogField{"id", id}).Warn("Too many tombstones, deleting relay item immediately.")
return r.Delete(id)
}
item, ok := r.items[id]
if !ok {
r.Unlock()
r... | [
"func",
"(",
"r",
"*",
"relayItems",
")",
"Entomb",
"(",
"id",
"uint32",
",",
"deleteAfter",
"time",
".",
"Duration",
")",
"(",
"relayItem",
",",
"bool",
")",
"{",
"r",
".",
"Lock",
"(",
")",
"\n",
"if",
"r",
".",
"tombs",
">",
"_maxRelayTombs",
"{... | // Entomb sets the tomb bit on a relayItem and schedules a garbage collection. It
// returns the entombed item, along with a bool indicating whether we completed
// a relayed call. | [
"Entomb",
"sets",
"the",
"tomb",
"bit",
"on",
"a",
"relayItem",
"and",
"schedules",
"a",
"garbage",
"collection",
".",
"It",
"returns",
"the",
"entombed",
"item",
"along",
"with",
"a",
"bool",
"indicating",
"whether",
"we",
"completed",
"a",
"relayed",
"call... | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/relay.go#L135-L162 | test |
uber/tchannel-go | relay.go | NewRelayer | func NewRelayer(ch *Channel, conn *Connection) *Relayer {
r := &Relayer{
relayHost: ch.RelayHost(),
maxTimeout: ch.relayMaxTimeout,
localHandler: ch.relayLocal,
outbound: newRelayItems(conn.log.WithFields(LogField{"relayItems", "outbound"})),
inbound: newRelayItems(conn.log.WithFields(LogField{... | go | func NewRelayer(ch *Channel, conn *Connection) *Relayer {
r := &Relayer{
relayHost: ch.RelayHost(),
maxTimeout: ch.relayMaxTimeout,
localHandler: ch.relayLocal,
outbound: newRelayItems(conn.log.WithFields(LogField{"relayItems", "outbound"})),
inbound: newRelayItems(conn.log.WithFields(LogField{... | [
"func",
"NewRelayer",
"(",
"ch",
"*",
"Channel",
",",
"conn",
"*",
"Connection",
")",
"*",
"Relayer",
"{",
"r",
":=",
"&",
"Relayer",
"{",
"relayHost",
":",
"ch",
".",
"RelayHost",
"(",
")",
",",
"maxTimeout",
":",
"ch",
".",
"relayMaxTimeout",
",",
... | // NewRelayer constructs a Relayer. | [
"NewRelayer",
"constructs",
"a",
"Relayer",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/relay.go#L202-L220 | test |
uber/tchannel-go | relay.go | Relay | func (r *Relayer) Relay(f *Frame) error {
if f.messageType() != messageTypeCallReq {
err := r.handleNonCallReq(f)
if err == errUnknownID {
// This ID may be owned by an outgoing call, so check the outbound
// message exchange, and if it succeeds, then the frame has been
// handled successfully.
if err ... | go | func (r *Relayer) Relay(f *Frame) error {
if f.messageType() != messageTypeCallReq {
err := r.handleNonCallReq(f)
if err == errUnknownID {
// This ID may be owned by an outgoing call, so check the outbound
// message exchange, and if it succeeds, then the frame has been
// handled successfully.
if err ... | [
"func",
"(",
"r",
"*",
"Relayer",
")",
"Relay",
"(",
"f",
"*",
"Frame",
")",
"error",
"{",
"if",
"f",
".",
"messageType",
"(",
")",
"!=",
"messageTypeCallReq",
"{",
"err",
":=",
"r",
".",
"handleNonCallReq",
"(",
"f",
")",
"\n",
"if",
"err",
"==",
... | // Relay is called for each frame that is read on the connection. | [
"Relay",
"is",
"called",
"for",
"each",
"frame",
"that",
"is",
"read",
"on",
"the",
"connection",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/relay.go#L223-L237 | test |
uber/tchannel-go | relay.go | Receive | func (r *Relayer) Receive(f *Frame, fType frameType) (sent bool, failureReason string) {
id := f.Header.ID
// If we receive a response frame, we expect to find that ID in our outbound.
// If we receive a request frame, we expect to find that ID in our inbound.
items := r.receiverItems(fType)
item, ok := items.Ge... | go | func (r *Relayer) Receive(f *Frame, fType frameType) (sent bool, failureReason string) {
id := f.Header.ID
// If we receive a response frame, we expect to find that ID in our outbound.
// If we receive a request frame, we expect to find that ID in our inbound.
items := r.receiverItems(fType)
item, ok := items.Ge... | [
"func",
"(",
"r",
"*",
"Relayer",
")",
"Receive",
"(",
"f",
"*",
"Frame",
",",
"fType",
"frameType",
")",
"(",
"sent",
"bool",
",",
"failureReason",
"string",
")",
"{",
"id",
":=",
"f",
".",
"Header",
".",
"ID",
"\n",
"items",
":=",
"r",
".",
"re... | // Receive receives frames intended for this connection.
// It returns whether the frame was sent and a reason for failure if it failed. | [
"Receive",
"receives",
"frames",
"intended",
"for",
"this",
"connection",
".",
"It",
"returns",
"whether",
"the",
"frame",
"was",
"sent",
"and",
"a",
"reason",
"for",
"failure",
"if",
"it",
"failed",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/relay.go#L241-L299 | test |
uber/tchannel-go | relay.go | handleNonCallReq | func (r *Relayer) handleNonCallReq(f *Frame) error {
frameType := frameTypeFor(f)
finished := finishesCall(f)
// If we read a request frame, we need to use the outbound map to decide
// the destination. Otherwise, we use the inbound map.
items := r.outbound
if frameType == responseFrame {
items = r.inbound
}
... | go | func (r *Relayer) handleNonCallReq(f *Frame) error {
frameType := frameTypeFor(f)
finished := finishesCall(f)
// If we read a request frame, we need to use the outbound map to decide
// the destination. Otherwise, we use the inbound map.
items := r.outbound
if frameType == responseFrame {
items = r.inbound
}
... | [
"func",
"(",
"r",
"*",
"Relayer",
")",
"handleNonCallReq",
"(",
"f",
"*",
"Frame",
")",
"error",
"{",
"frameType",
":=",
"frameTypeFor",
"(",
"f",
")",
"\n",
"finished",
":=",
"finishesCall",
"(",
"f",
")",
"\n",
"items",
":=",
"r",
".",
"outbound",
... | // Handle all frames except messageTypeCallReq. | [
"Handle",
"all",
"frames",
"except",
"messageTypeCallReq",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/relay.go#L439-L473 | test |
uber/tchannel-go | relay.go | addRelayItem | func (r *Relayer) addRelayItem(isOriginator bool, id, remapID uint32, destination *Relayer, ttl time.Duration, span Span, call RelayCall) relayItem {
item := relayItem{
call: call,
remapID: remapID,
destination: destination,
span: span,
}
items := r.inbound
if isOriginator {
items = r.o... | go | func (r *Relayer) addRelayItem(isOriginator bool, id, remapID uint32, destination *Relayer, ttl time.Duration, span Span, call RelayCall) relayItem {
item := relayItem{
call: call,
remapID: remapID,
destination: destination,
span: span,
}
items := r.inbound
if isOriginator {
items = r.o... | [
"func",
"(",
"r",
"*",
"Relayer",
")",
"addRelayItem",
"(",
"isOriginator",
"bool",
",",
"id",
",",
"remapID",
"uint32",
",",
"destination",
"*",
"Relayer",
",",
"ttl",
"time",
".",
"Duration",
",",
"span",
"Span",
",",
"call",
"RelayCall",
")",
"relayIt... | // addRelayItem adds a relay item to either outbound or inbound. | [
"addRelayItem",
"adds",
"a",
"relay",
"item",
"to",
"either",
"outbound",
"or",
"inbound",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/relay.go#L476-L492 | test |
uber/tchannel-go | relay.go | failRelayItem | func (r *Relayer) failRelayItem(items *relayItems, id uint32, failure string) {
item, ok := items.Get(id)
if !ok {
items.logger.WithFields(LogField{"id", id}).Warn("Attempted to fail non-existent relay item.")
return
}
// The call could time-out right as we entomb it, which would cause spurious
// error logs,... | go | func (r *Relayer) failRelayItem(items *relayItems, id uint32, failure string) {
item, ok := items.Get(id)
if !ok {
items.logger.WithFields(LogField{"id", id}).Warn("Attempted to fail non-existent relay item.")
return
}
// The call could time-out right as we entomb it, which would cause spurious
// error logs,... | [
"func",
"(",
"r",
"*",
"Relayer",
")",
"failRelayItem",
"(",
"items",
"*",
"relayItems",
",",
"id",
"uint32",
",",
"failure",
"string",
")",
"{",
"item",
",",
"ok",
":=",
"items",
".",
"Get",
"(",
"id",
")",
"\n",
"if",
"!",
"ok",
"{",
"items",
"... | // failRelayItem tombs the relay item so that future frames for this call are not
// forwarded. We keep the relay item tombed, rather than delete it to ensure that
// future frames do not cause error logs. | [
"failRelayItem",
"tombs",
"the",
"relay",
"item",
"so",
"that",
"future",
"frames",
"for",
"this",
"call",
"are",
"not",
"forwarded",
".",
"We",
"keep",
"the",
"relay",
"item",
"tombed",
"rather",
"than",
"delete",
"it",
"to",
"ensure",
"that",
"future",
"... | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/relay.go#L511-L540 | test |
uber/tchannel-go | thrift/struct.go | WriteStruct | func WriteStruct(writer io.Writer, s thrift.TStruct) error {
wp := getProtocolWriter(writer)
err := s.Write(wp.protocol)
thriftProtocolPool.Put(wp)
return err
} | go | func WriteStruct(writer io.Writer, s thrift.TStruct) error {
wp := getProtocolWriter(writer)
err := s.Write(wp.protocol)
thriftProtocolPool.Put(wp)
return err
} | [
"func",
"WriteStruct",
"(",
"writer",
"io",
".",
"Writer",
",",
"s",
"thrift",
".",
"TStruct",
")",
"error",
"{",
"wp",
":=",
"getProtocolWriter",
"(",
"writer",
")",
"\n",
"err",
":=",
"s",
".",
"Write",
"(",
"wp",
".",
"protocol",
")",
"\n",
"thrif... | // WriteStruct writes the given Thrift struct to a writer. It pools TProtocols. | [
"WriteStruct",
"writes",
"the",
"given",
"Thrift",
"struct",
"to",
"a",
"writer",
".",
"It",
"pools",
"TProtocols",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/struct.go#L30-L35 | test |
uber/tchannel-go | thrift/struct.go | ReadStruct | func ReadStruct(reader io.Reader, s thrift.TStruct) error {
wp := getProtocolReader(reader)
err := s.Read(wp.protocol)
thriftProtocolPool.Put(wp)
return err
} | go | func ReadStruct(reader io.Reader, s thrift.TStruct) error {
wp := getProtocolReader(reader)
err := s.Read(wp.protocol)
thriftProtocolPool.Put(wp)
return err
} | [
"func",
"ReadStruct",
"(",
"reader",
"io",
".",
"Reader",
",",
"s",
"thrift",
".",
"TStruct",
")",
"error",
"{",
"wp",
":=",
"getProtocolReader",
"(",
"reader",
")",
"\n",
"err",
":=",
"s",
".",
"Read",
"(",
"wp",
".",
"protocol",
")",
"\n",
"thriftP... | // ReadStruct reads the given Thrift struct. It pools TProtocols. | [
"ReadStruct",
"reads",
"the",
"given",
"Thrift",
"struct",
".",
"It",
"pools",
"TProtocols",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/struct.go#L38-L43 | test |
uber/tchannel-go | internal/argreader/empty.go | EnsureEmpty | func EnsureEmpty(r io.Reader, stage string) error {
buf := _bufPool.Get().(*[]byte)
defer _bufPool.Put(buf)
n, err := r.Read(*buf)
if n > 0 {
return fmt.Errorf("found unexpected bytes after %s, found (upto 128 bytes): %x", stage, (*buf)[:n])
}
if err == io.EOF {
return nil
}
return err
} | go | func EnsureEmpty(r io.Reader, stage string) error {
buf := _bufPool.Get().(*[]byte)
defer _bufPool.Put(buf)
n, err := r.Read(*buf)
if n > 0 {
return fmt.Errorf("found unexpected bytes after %s, found (upto 128 bytes): %x", stage, (*buf)[:n])
}
if err == io.EOF {
return nil
}
return err
} | [
"func",
"EnsureEmpty",
"(",
"r",
"io",
".",
"Reader",
",",
"stage",
"string",
")",
"error",
"{",
"buf",
":=",
"_bufPool",
".",
"Get",
"(",
")",
".",
"(",
"*",
"[",
"]",
"byte",
")",
"\n",
"defer",
"_bufPool",
".",
"Put",
"(",
"buf",
")",
"\n",
... | // EnsureEmpty ensures that the specified reader is empty. If the reader is
// not empty, it returns an error with the specified stage in the message. | [
"EnsureEmpty",
"ensures",
"that",
"the",
"specified",
"reader",
"is",
"empty",
".",
"If",
"the",
"reader",
"is",
"not",
"empty",
"it",
"returns",
"an",
"error",
"with",
"the",
"specified",
"stage",
"in",
"the",
"message",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/internal/argreader/empty.go#L38-L50 | test |
uber/tchannel-go | benchmark/internal_server.go | NewServer | func NewServer(optFns ...Option) Server {
opts := getOptions(optFns)
if opts.external {
return newExternalServer(opts)
}
ch, err := tchannel.NewChannel(opts.svcName, &tchannel.ChannelOptions{
Logger: tchannel.NewLevelLogger(tchannel.NewLogger(os.Stderr), tchannel.LogLevelWarn),
})
if err != nil {
panic("fa... | go | func NewServer(optFns ...Option) Server {
opts := getOptions(optFns)
if opts.external {
return newExternalServer(opts)
}
ch, err := tchannel.NewChannel(opts.svcName, &tchannel.ChannelOptions{
Logger: tchannel.NewLevelLogger(tchannel.NewLogger(os.Stderr), tchannel.LogLevelWarn),
})
if err != nil {
panic("fa... | [
"func",
"NewServer",
"(",
"optFns",
"...",
"Option",
")",
"Server",
"{",
"opts",
":=",
"getOptions",
"(",
"optFns",
")",
"\n",
"if",
"opts",
".",
"external",
"{",
"return",
"newExternalServer",
"(",
"opts",
")",
"\n",
"}",
"\n",
"ch",
",",
"err",
":=",... | // NewServer returns a new Server that can recieve Thrift calls or raw calls. | [
"NewServer",
"returns",
"a",
"new",
"Server",
"that",
"can",
"recieve",
"Thrift",
"calls",
"or",
"raw",
"calls",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/benchmark/internal_server.go#L46-L78 | test |
uber/tchannel-go | benchmark/internal_server.go | Advertise | func (s *internalServer) Advertise(hyperbahnHosts []string) error {
config := hyperbahn.Configuration{InitialNodes: hyperbahnHosts}
hc, err := hyperbahn.NewClient(s.ch, config, nil)
if err != nil {
panic("failed to setup Hyperbahn client: " + err.Error())
}
return hc.Advertise()
} | go | func (s *internalServer) Advertise(hyperbahnHosts []string) error {
config := hyperbahn.Configuration{InitialNodes: hyperbahnHosts}
hc, err := hyperbahn.NewClient(s.ch, config, nil)
if err != nil {
panic("failed to setup Hyperbahn client: " + err.Error())
}
return hc.Advertise()
} | [
"func",
"(",
"s",
"*",
"internalServer",
")",
"Advertise",
"(",
"hyperbahnHosts",
"[",
"]",
"string",
")",
"error",
"{",
"config",
":=",
"hyperbahn",
".",
"Configuration",
"{",
"InitialNodes",
":",
"hyperbahnHosts",
"}",
"\n",
"hc",
",",
"err",
":=",
"hype... | // Advertise advertises with Hyperbahn. | [
"Advertise",
"advertises",
"with",
"Hyperbahn",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/benchmark/internal_server.go#L86-L93 | test |
uber/tchannel-go | inbound.go | handleCallReqContinue | func (c *Connection) handleCallReqContinue(frame *Frame) bool {
if err := c.inbound.forwardPeerFrame(frame); err != nil {
// If forward fails, it's due to a timeout. We can free this frame.
return true
}
return false
} | go | func (c *Connection) handleCallReqContinue(frame *Frame) bool {
if err := c.inbound.forwardPeerFrame(frame); err != nil {
// If forward fails, it's due to a timeout. We can free this frame.
return true
}
return false
} | [
"func",
"(",
"c",
"*",
"Connection",
")",
"handleCallReqContinue",
"(",
"frame",
"*",
"Frame",
")",
"bool",
"{",
"if",
"err",
":=",
"c",
".",
"inbound",
".",
"forwardPeerFrame",
"(",
"frame",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"true",
"\n",
... | // handleCallReqContinue handles the continuation of a call request, forwarding
// it to the request channel for that request, where it can be pulled during
// defragmentation | [
"handleCallReqContinue",
"handles",
"the",
"continuation",
"of",
"a",
"call",
"request",
"forwarding",
"it",
"to",
"the",
"request",
"channel",
"for",
"that",
"request",
"where",
"it",
"can",
"be",
"pulled",
"during",
"defragmentation"
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/inbound.go#L132-L138 | test |
uber/tchannel-go | inbound.go | dispatchInbound | func (c *Connection) dispatchInbound(_ uint32, _ uint32, call *InboundCall, frame *Frame) {
if call.log.Enabled(LogLevelDebug) {
call.log.Debugf("Received incoming call for %s from %s", call.ServiceName(), c.remotePeerInfo)
}
if err := call.readMethod(); err != nil {
call.log.WithFields(
LogField{"remotePeer... | go | func (c *Connection) dispatchInbound(_ uint32, _ uint32, call *InboundCall, frame *Frame) {
if call.log.Enabled(LogLevelDebug) {
call.log.Debugf("Received incoming call for %s from %s", call.ServiceName(), c.remotePeerInfo)
}
if err := call.readMethod(); err != nil {
call.log.WithFields(
LogField{"remotePeer... | [
"func",
"(",
"c",
"*",
"Connection",
")",
"dispatchInbound",
"(",
"_",
"uint32",
",",
"_",
"uint32",
",",
"call",
"*",
"InboundCall",
",",
"frame",
"*",
"Frame",
")",
"{",
"if",
"call",
".",
"log",
".",
"Enabled",
"(",
"LogLevelDebug",
")",
"{",
"cal... | // dispatchInbound ispatches an inbound call to the appropriate handler | [
"dispatchInbound",
"ispatches",
"an",
"inbound",
"call",
"to",
"the",
"appropriate",
"handler"
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/inbound.go#L151-L195 | test |
uber/tchannel-go | inbound.go | CallOptions | func (call *InboundCall) CallOptions() *CallOptions {
return &CallOptions{
callerName: call.CallerName(),
Format: call.Format(),
ShardKey: call.ShardKey(),
RoutingDelegate: call.RoutingDelegate(),
RoutingKey: call.RoutingKey(),
}
} | go | func (call *InboundCall) CallOptions() *CallOptions {
return &CallOptions{
callerName: call.CallerName(),
Format: call.Format(),
ShardKey: call.ShardKey(),
RoutingDelegate: call.RoutingDelegate(),
RoutingKey: call.RoutingKey(),
}
} | [
"func",
"(",
"call",
"*",
"InboundCall",
")",
"CallOptions",
"(",
")",
"*",
"CallOptions",
"{",
"return",
"&",
"CallOptions",
"{",
"callerName",
":",
"call",
".",
"CallerName",
"(",
")",
",",
"Format",
":",
"call",
".",
"Format",
"(",
")",
",",
"ShardK... | // CallOptions returns a CallOptions struct suitable for forwarding a request. | [
"CallOptions",
"returns",
"a",
"CallOptions",
"struct",
"suitable",
"for",
"forwarding",
"a",
"request",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/inbound.go#L262-L270 | test |
uber/tchannel-go | inbound.go | Response | func (call *InboundCall) Response() *InboundCallResponse {
if call.err != nil {
// While reading Thrift, we cannot distinguish between malformed Thrift and other errors,
// and so we may try to respond with a bad request. We should ensure that the response
// is marked as failed if the request has failed so that... | go | func (call *InboundCall) Response() *InboundCallResponse {
if call.err != nil {
// While reading Thrift, we cannot distinguish between malformed Thrift and other errors,
// and so we may try to respond with a bad request. We should ensure that the response
// is marked as failed if the request has failed so that... | [
"func",
"(",
"call",
"*",
"InboundCall",
")",
"Response",
"(",
")",
"*",
"InboundCallResponse",
"{",
"if",
"call",
".",
"err",
"!=",
"nil",
"{",
"call",
".",
"response",
".",
"err",
"=",
"call",
".",
"err",
"\n",
"}",
"\n",
"return",
"call",
".",
"... | // Response provides access to the InboundCallResponse object which can be used
// to write back to the calling peer | [
"Response",
"provides",
"access",
"to",
"the",
"InboundCallResponse",
"object",
"which",
"can",
"be",
"used",
"to",
"write",
"back",
"to",
"the",
"calling",
"peer"
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/inbound.go#L298-L307 | test |
uber/tchannel-go | inbound.go | SendSystemError | func (response *InboundCallResponse) SendSystemError(err error) error {
if response.err != nil {
return response.err
}
// Fail all future attempts to read fragments
response.state = reqResWriterComplete
response.systemError = true
response.doneSending()
response.call.releasePreviousFragment()
span := Current... | go | func (response *InboundCallResponse) SendSystemError(err error) error {
if response.err != nil {
return response.err
}
// Fail all future attempts to read fragments
response.state = reqResWriterComplete
response.systemError = true
response.doneSending()
response.call.releasePreviousFragment()
span := Current... | [
"func",
"(",
"response",
"*",
"InboundCallResponse",
")",
"SendSystemError",
"(",
"err",
"error",
")",
"error",
"{",
"if",
"response",
".",
"err",
"!=",
"nil",
"{",
"return",
"response",
".",
"err",
"\n",
"}",
"\n",
"response",
".",
"state",
"=",
"reqRes... | // SendSystemError returns a system error response to the peer. The call is considered
// complete after this method is called, and no further data can be written. | [
"SendSystemError",
"returns",
"a",
"system",
"error",
"response",
"to",
"the",
"peer",
".",
"The",
"call",
"is",
"considered",
"complete",
"after",
"this",
"method",
"is",
"called",
"and",
"no",
"further",
"data",
"can",
"be",
"written",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/inbound.go#L330-L343 | test |
uber/tchannel-go | inbound.go | SetApplicationError | func (response *InboundCallResponse) SetApplicationError() error {
if response.state > reqResWriterPreArg2 {
return response.failed(errReqResWriterStateMismatch{
state: response.state,
expectedState: reqResWriterPreArg2,
})
}
response.applicationError = true
return nil
} | go | func (response *InboundCallResponse) SetApplicationError() error {
if response.state > reqResWriterPreArg2 {
return response.failed(errReqResWriterStateMismatch{
state: response.state,
expectedState: reqResWriterPreArg2,
})
}
response.applicationError = true
return nil
} | [
"func",
"(",
"response",
"*",
"InboundCallResponse",
")",
"SetApplicationError",
"(",
")",
"error",
"{",
"if",
"response",
".",
"state",
">",
"reqResWriterPreArg2",
"{",
"return",
"response",
".",
"failed",
"(",
"errReqResWriterStateMismatch",
"{",
"state",
":",
... | // SetApplicationError marks the response as being an application error. This method can
// only be called before any arguments have been sent to the calling peer. | [
"SetApplicationError",
"marks",
"the",
"response",
"as",
"being",
"an",
"application",
"error",
".",
"This",
"method",
"can",
"only",
"be",
"called",
"before",
"any",
"arguments",
"have",
"been",
"sent",
"to",
"the",
"calling",
"peer",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/inbound.go#L347-L356 | test |
uber/tchannel-go | inbound.go | Arg2Writer | func (response *InboundCallResponse) Arg2Writer() (ArgWriter, error) {
if err := NewArgWriter(response.arg1Writer()).Write(nil); err != nil {
return nil, err
}
return response.arg2Writer()
} | go | func (response *InboundCallResponse) Arg2Writer() (ArgWriter, error) {
if err := NewArgWriter(response.arg1Writer()).Write(nil); err != nil {
return nil, err
}
return response.arg2Writer()
} | [
"func",
"(",
"response",
"*",
"InboundCallResponse",
")",
"Arg2Writer",
"(",
")",
"(",
"ArgWriter",
",",
"error",
")",
"{",
"if",
"err",
":=",
"NewArgWriter",
"(",
"response",
".",
"arg1Writer",
"(",
")",
")",
".",
"Write",
"(",
"nil",
")",
";",
"err",... | // Arg2Writer returns a WriteCloser that can be used to write the second argument.
// The returned writer must be closed once the write is complete. | [
"Arg2Writer",
"returns",
"a",
"WriteCloser",
"that",
"can",
"be",
"used",
"to",
"write",
"the",
"second",
"argument",
".",
"The",
"returned",
"writer",
"must",
"be",
"closed",
"once",
"the",
"write",
"is",
"complete",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/inbound.go#L367-L372 | test |
uber/tchannel-go | inbound.go | doneSending | func (response *InboundCallResponse) doneSending() {
// TODO(prashant): Move this to when the message is actually being sent.
now := response.timeNow()
if span := response.span; span != nil {
if response.applicationError || response.systemError {
ext.Error.Set(span, true)
}
span.FinishWithOptions(opentraci... | go | func (response *InboundCallResponse) doneSending() {
// TODO(prashant): Move this to when the message is actually being sent.
now := response.timeNow()
if span := response.span; span != nil {
if response.applicationError || response.systemError {
ext.Error.Set(span, true)
}
span.FinishWithOptions(opentraci... | [
"func",
"(",
"response",
"*",
"InboundCallResponse",
")",
"doneSending",
"(",
")",
"{",
"now",
":=",
"response",
".",
"timeNow",
"(",
")",
"\n",
"if",
"span",
":=",
"response",
".",
"span",
";",
"span",
"!=",
"nil",
"{",
"if",
"response",
".",
"applica... | // doneSending shuts down the message exchange for this call.
// For incoming calls, the last message is sending the call response. | [
"doneSending",
"shuts",
"down",
"the",
"message",
"exchange",
"for",
"this",
"call",
".",
"For",
"incoming",
"calls",
"the",
"last",
"message",
"is",
"sending",
"the",
"call",
"response",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/inbound.go#L382-L412 | test |
uber/tchannel-go | thrift/thrift-gen/typestate.go | newState | func newState(v *parser.Thrift, all map[string]parseState) *State {
typedefs := make(map[string]*parser.Type)
for k, v := range v.Typedefs {
typedefs[k] = v.Type
}
// Enums are typedefs to an int64.
i64Type := &parser.Type{Name: "i64"}
for k := range v.Enums {
typedefs[k] = i64Type
}
return &State{typedef... | go | func newState(v *parser.Thrift, all map[string]parseState) *State {
typedefs := make(map[string]*parser.Type)
for k, v := range v.Typedefs {
typedefs[k] = v.Type
}
// Enums are typedefs to an int64.
i64Type := &parser.Type{Name: "i64"}
for k := range v.Enums {
typedefs[k] = i64Type
}
return &State{typedef... | [
"func",
"newState",
"(",
"v",
"*",
"parser",
".",
"Thrift",
",",
"all",
"map",
"[",
"string",
"]",
"parseState",
")",
"*",
"State",
"{",
"typedefs",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"parser",
".",
"Type",
")",
"\n",
"for",
"k",
... | // newState parses the type information for a parsed Thrift file and returns the state. | [
"newState",
"parses",
"the",
"type",
"information",
"for",
"a",
"parsed",
"Thrift",
"file",
"and",
"returns",
"the",
"state",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/thrift-gen/typestate.go#L42-L55 | test |
uber/tchannel-go | thrift/thrift-gen/typestate.go | rootType | func (s *State) rootType(thriftType *parser.Type) *parser.Type {
if state, newType, include := s.checkInclude(thriftType); include != nil {
return state.rootType(newType)
}
if v, ok := s.typedefs[thriftType.Name]; ok {
return s.rootType(v)
}
return thriftType
} | go | func (s *State) rootType(thriftType *parser.Type) *parser.Type {
if state, newType, include := s.checkInclude(thriftType); include != nil {
return state.rootType(newType)
}
if v, ok := s.typedefs[thriftType.Name]; ok {
return s.rootType(v)
}
return thriftType
} | [
"func",
"(",
"s",
"*",
"State",
")",
"rootType",
"(",
"thriftType",
"*",
"parser",
".",
"Type",
")",
"*",
"parser",
".",
"Type",
"{",
"if",
"state",
",",
"newType",
",",
"include",
":=",
"s",
".",
"checkInclude",
"(",
"thriftType",
")",
";",
"include... | // rootType recurses through typedefs and returns the underlying type. | [
"rootType",
"recurses",
"through",
"typedefs",
"and",
"returns",
"the",
"underlying",
"type",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/thrift-gen/typestate.go#L69-L78 | test |
uber/tchannel-go | thrift/thrift-gen/typestate.go | checkInclude | func (s *State) checkInclude(thriftType *parser.Type) (*State, *parser.Type, *Include) {
parts := strings.SplitN(thriftType.Name, ".", 2)
if len(parts) < 2 {
return nil, nil, nil
}
newType := *thriftType
newType.Name = parts[1]
include := s.includes[parts[0]]
state := s.all[include.file]
return state.global... | go | func (s *State) checkInclude(thriftType *parser.Type) (*State, *parser.Type, *Include) {
parts := strings.SplitN(thriftType.Name, ".", 2)
if len(parts) < 2 {
return nil, nil, nil
}
newType := *thriftType
newType.Name = parts[1]
include := s.includes[parts[0]]
state := s.all[include.file]
return state.global... | [
"func",
"(",
"s",
"*",
"State",
")",
"checkInclude",
"(",
"thriftType",
"*",
"parser",
".",
"Type",
")",
"(",
"*",
"State",
",",
"*",
"parser",
".",
"Type",
",",
"*",
"Include",
")",
"{",
"parts",
":=",
"strings",
".",
"SplitN",
"(",
"thriftType",
... | // checkInclude will check if the type is an included type, and if so, return the
// state and type from the state for that file. | [
"checkInclude",
"will",
"check",
"if",
"the",
"type",
"is",
"an",
"included",
"type",
"and",
"if",
"so",
"return",
"the",
"state",
"and",
"type",
"from",
"the",
"state",
"for",
"that",
"file",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/thrift-gen/typestate.go#L82-L94 | test |
uber/tchannel-go | thrift/thrift-gen/typestate.go | isResultPointer | func (s *State) isResultPointer(thriftType *parser.Type) bool {
_, basicGoType := thriftToGo[s.rootType(thriftType).Name]
return !basicGoType
} | go | func (s *State) isResultPointer(thriftType *parser.Type) bool {
_, basicGoType := thriftToGo[s.rootType(thriftType).Name]
return !basicGoType
} | [
"func",
"(",
"s",
"*",
"State",
")",
"isResultPointer",
"(",
"thriftType",
"*",
"parser",
".",
"Type",
")",
"bool",
"{",
"_",
",",
"basicGoType",
":=",
"thriftToGo",
"[",
"s",
".",
"rootType",
"(",
"thriftType",
")",
".",
"Name",
"]",
"\n",
"return",
... | // isResultPointer returns whether the result for this method is a pointer. | [
"isResultPointer",
"returns",
"whether",
"the",
"result",
"for",
"this",
"method",
"is",
"a",
"pointer",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/thrift-gen/typestate.go#L97-L100 | test |
uber/tchannel-go | thrift/thrift-gen/typestate.go | goType | func (s *State) goType(thriftType *parser.Type) string {
return s.goTypePrefix("", thriftType)
} | go | func (s *State) goType(thriftType *parser.Type) string {
return s.goTypePrefix("", thriftType)
} | [
"func",
"(",
"s",
"*",
"State",
")",
"goType",
"(",
"thriftType",
"*",
"parser",
".",
"Type",
")",
"string",
"{",
"return",
"s",
".",
"goTypePrefix",
"(",
"\"\"",
",",
"thriftType",
")",
"\n",
"}"
] | // goType returns the Go type name for the given thrift type. | [
"goType",
"returns",
"the",
"Go",
"type",
"name",
"for",
"the",
"given",
"thrift",
"type",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/thrift-gen/typestate.go#L103-L105 | test |
uber/tchannel-go | thrift/thrift-gen/typestate.go | goTypePrefix | func (s *State) goTypePrefix(prefix string, thriftType *parser.Type) string {
switch thriftType.Name {
case "binary":
return "[]byte"
case "list":
return "[]" + s.goType(thriftType.ValueType)
case "set":
return "map[" + s.goType(thriftType.ValueType) + "]bool"
case "map":
return "map[" + s.goType(thriftTyp... | go | func (s *State) goTypePrefix(prefix string, thriftType *parser.Type) string {
switch thriftType.Name {
case "binary":
return "[]byte"
case "list":
return "[]" + s.goType(thriftType.ValueType)
case "set":
return "map[" + s.goType(thriftType.ValueType) + "]bool"
case "map":
return "map[" + s.goType(thriftTyp... | [
"func",
"(",
"s",
"*",
"State",
")",
"goTypePrefix",
"(",
"prefix",
"string",
",",
"thriftType",
"*",
"parser",
".",
"Type",
")",
"string",
"{",
"switch",
"thriftType",
".",
"Name",
"{",
"case",
"\"binary\"",
":",
"return",
"\"[]byte\"",
"\n",
"case",
"\... | // goTypePrefix returns the Go type name for the given thrift type with the prefix. | [
"goTypePrefix",
"returns",
"the",
"Go",
"type",
"name",
"for",
"the",
"given",
"thrift",
"type",
"with",
"the",
"prefix",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/thrift-gen/typestate.go#L108-L152 | test |
uber/tchannel-go | context.go | NewContext | func NewContext(timeout time.Duration) (context.Context, context.CancelFunc) {
return NewContextBuilder(timeout).Build()
} | go | func NewContext(timeout time.Duration) (context.Context, context.CancelFunc) {
return NewContextBuilder(timeout).Build()
} | [
"func",
"NewContext",
"(",
"timeout",
"time",
".",
"Duration",
")",
"(",
"context",
".",
"Context",
",",
"context",
".",
"CancelFunc",
")",
"{",
"return",
"NewContextBuilder",
"(",
"timeout",
")",
".",
"Build",
"(",
")",
"\n",
"}"
] | // NewContext returns a new root context used to make TChannel requests. | [
"NewContext",
"returns",
"a",
"new",
"root",
"context",
"used",
"to",
"make",
"TChannel",
"requests",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/context.go#L85-L87 | test |
uber/tchannel-go | context.go | newIncomingContext | func newIncomingContext(call IncomingCall, timeout time.Duration) (context.Context, context.CancelFunc) {
return NewContextBuilder(timeout).
setIncomingCall(call).
Build()
} | go | func newIncomingContext(call IncomingCall, timeout time.Duration) (context.Context, context.CancelFunc) {
return NewContextBuilder(timeout).
setIncomingCall(call).
Build()
} | [
"func",
"newIncomingContext",
"(",
"call",
"IncomingCall",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"context",
".",
"Context",
",",
"context",
".",
"CancelFunc",
")",
"{",
"return",
"NewContextBuilder",
"(",
"timeout",
")",
".",
"setIncomingCall",
"(... | // newIncomingContext creates a new context for an incoming call with the given span. | [
"newIncomingContext",
"creates",
"a",
"new",
"context",
"for",
"an",
"incoming",
"call",
"with",
"the",
"given",
"span",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/context.go#L98-L102 | test |
uber/tchannel-go | context.go | CurrentCall | func CurrentCall(ctx context.Context) IncomingCall {
if params := getTChannelParams(ctx); params != nil {
return params.call
}
return nil
} | go | func CurrentCall(ctx context.Context) IncomingCall {
if params := getTChannelParams(ctx); params != nil {
return params.call
}
return nil
} | [
"func",
"CurrentCall",
"(",
"ctx",
"context",
".",
"Context",
")",
"IncomingCall",
"{",
"if",
"params",
":=",
"getTChannelParams",
"(",
"ctx",
")",
";",
"params",
"!=",
"nil",
"{",
"return",
"params",
".",
"call",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
... | // CurrentCall returns the current incoming call, or nil if this is not an incoming call context. | [
"CurrentCall",
"returns",
"the",
"current",
"incoming",
"call",
"or",
"nil",
"if",
"this",
"is",
"not",
"an",
"incoming",
"call",
"context",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/context.go#L105-L110 | test |
uber/tchannel-go | trand/rand.go | New | func New(seed int64) *rand.Rand {
return rand.New(&lockedSource{src: rand.NewSource(seed)})
} | go | func New(seed int64) *rand.Rand {
return rand.New(&lockedSource{src: rand.NewSource(seed)})
} | [
"func",
"New",
"(",
"seed",
"int64",
")",
"*",
"rand",
".",
"Rand",
"{",
"return",
"rand",
".",
"New",
"(",
"&",
"lockedSource",
"{",
"src",
":",
"rand",
".",
"NewSource",
"(",
"seed",
")",
"}",
")",
"\n",
"}"
] | // New returns a rand.Rand that is threadsafe. | [
"New",
"returns",
"a",
"rand",
".",
"Rand",
"that",
"is",
"threadsafe",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/trand/rand.go#L40-L42 | test |
uber/tchannel-go | thrift/meta.go | Health | func (h *metaHandler) Health(ctx Context, req *meta.HealthRequest) (*meta.HealthStatus, error) {
ok, message := h.healthFn(ctx, metaReqToReq(req))
if message == "" {
return &meta.HealthStatus{Ok: ok}, nil
}
return &meta.HealthStatus{Ok: ok, Message: &message}, nil
} | go | func (h *metaHandler) Health(ctx Context, req *meta.HealthRequest) (*meta.HealthStatus, error) {
ok, message := h.healthFn(ctx, metaReqToReq(req))
if message == "" {
return &meta.HealthStatus{Ok: ok}, nil
}
return &meta.HealthStatus{Ok: ok, Message: &message}, nil
} | [
"func",
"(",
"h",
"*",
"metaHandler",
")",
"Health",
"(",
"ctx",
"Context",
",",
"req",
"*",
"meta",
".",
"HealthRequest",
")",
"(",
"*",
"meta",
".",
"HealthStatus",
",",
"error",
")",
"{",
"ok",
",",
"message",
":=",
"h",
".",
"healthFn",
"(",
"c... | // Health returns true as default Health endpoint. | [
"Health",
"returns",
"true",
"as",
"default",
"Health",
"endpoint",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/meta.go#L71-L77 | test |
uber/tchannel-go | context_header.go | Headers | func (c headerCtx) Headers() map[string]string {
if h := c.headers(); h != nil {
return h.reqHeaders
}
return nil
} | go | func (c headerCtx) Headers() map[string]string {
if h := c.headers(); h != nil {
return h.reqHeaders
}
return nil
} | [
"func",
"(",
"c",
"headerCtx",
")",
"Headers",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"if",
"h",
":=",
"c",
".",
"headers",
"(",
")",
";",
"h",
"!=",
"nil",
"{",
"return",
"h",
".",
"reqHeaders",
"\n",
"}",
"\n",
"return",
"nil",
"... | // Headers gets application headers out of the context. | [
"Headers",
"gets",
"application",
"headers",
"out",
"of",
"the",
"context",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/context_header.go#L61-L66 | test |
uber/tchannel-go | context_header.go | ResponseHeaders | func (c headerCtx) ResponseHeaders() map[string]string {
if h := c.headers(); h != nil {
return h.respHeaders
}
return nil
} | go | func (c headerCtx) ResponseHeaders() map[string]string {
if h := c.headers(); h != nil {
return h.respHeaders
}
return nil
} | [
"func",
"(",
"c",
"headerCtx",
")",
"ResponseHeaders",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"if",
"h",
":=",
"c",
".",
"headers",
"(",
")",
";",
"h",
"!=",
"nil",
"{",
"return",
"h",
".",
"respHeaders",
"\n",
"}",
"\n",
"return",
"... | // ResponseHeaders returns the response headers. | [
"ResponseHeaders",
"returns",
"the",
"response",
"headers",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/context_header.go#L69-L74 | test |
uber/tchannel-go | context_header.go | SetResponseHeaders | func (c headerCtx) SetResponseHeaders(headers map[string]string) {
if h := c.headers(); h != nil {
h.respHeaders = headers
return
}
panic("SetResponseHeaders called on ContextWithHeaders not created via WrapWithHeaders")
} | go | func (c headerCtx) SetResponseHeaders(headers map[string]string) {
if h := c.headers(); h != nil {
h.respHeaders = headers
return
}
panic("SetResponseHeaders called on ContextWithHeaders not created via WrapWithHeaders")
} | [
"func",
"(",
"c",
"headerCtx",
")",
"SetResponseHeaders",
"(",
"headers",
"map",
"[",
"string",
"]",
"string",
")",
"{",
"if",
"h",
":=",
"c",
".",
"headers",
"(",
")",
";",
"h",
"!=",
"nil",
"{",
"h",
".",
"respHeaders",
"=",
"headers",
"\n",
"ret... | // SetResponseHeaders sets the response headers. | [
"SetResponseHeaders",
"sets",
"the",
"response",
"headers",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/context_header.go#L77-L83 | test |
uber/tchannel-go | context_header.go | Child | func (c headerCtx) Child() ContextWithHeaders {
var headersCopy headersContainer
if h := c.headers(); h != nil {
headersCopy = *h
}
return Wrap(context.WithValue(c.Context, contextKeyHeaders, &headersCopy))
} | go | func (c headerCtx) Child() ContextWithHeaders {
var headersCopy headersContainer
if h := c.headers(); h != nil {
headersCopy = *h
}
return Wrap(context.WithValue(c.Context, contextKeyHeaders, &headersCopy))
} | [
"func",
"(",
"c",
"headerCtx",
")",
"Child",
"(",
")",
"ContextWithHeaders",
"{",
"var",
"headersCopy",
"headersContainer",
"\n",
"if",
"h",
":=",
"c",
".",
"headers",
"(",
")",
";",
"h",
"!=",
"nil",
"{",
"headersCopy",
"=",
"*",
"h",
"\n",
"}",
"\n... | // Child creates a child context with a separate container for headers. | [
"Child",
"creates",
"a",
"child",
"context",
"with",
"a",
"separate",
"container",
"for",
"headers",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/context_header.go#L86-L93 | test |
uber/tchannel-go | context_header.go | Wrap | func Wrap(ctx context.Context) ContextWithHeaders {
hctx := headerCtx{Context: ctx}
if h := hctx.headers(); h != nil {
return hctx
}
// If there is no header container, we should create an empty one.
return WrapWithHeaders(ctx, nil)
} | go | func Wrap(ctx context.Context) ContextWithHeaders {
hctx := headerCtx{Context: ctx}
if h := hctx.headers(); h != nil {
return hctx
}
// If there is no header container, we should create an empty one.
return WrapWithHeaders(ctx, nil)
} | [
"func",
"Wrap",
"(",
"ctx",
"context",
".",
"Context",
")",
"ContextWithHeaders",
"{",
"hctx",
":=",
"headerCtx",
"{",
"Context",
":",
"ctx",
"}",
"\n",
"if",
"h",
":=",
"hctx",
".",
"headers",
"(",
")",
";",
"h",
"!=",
"nil",
"{",
"return",
"hctx",
... | // Wrap wraps an existing context.Context into a ContextWithHeaders.
// If the underlying context has headers, they are preserved. | [
"Wrap",
"wraps",
"an",
"existing",
"context",
".",
"Context",
"into",
"a",
"ContextWithHeaders",
".",
"If",
"the",
"underlying",
"context",
"has",
"headers",
"they",
"are",
"preserved",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/context_header.go#L97-L105 | test |
uber/tchannel-go | context_header.go | WrapWithHeaders | func WrapWithHeaders(ctx context.Context, headers map[string]string) ContextWithHeaders {
h := &headersContainer{
reqHeaders: headers,
}
newCtx := context.WithValue(ctx, contextKeyHeaders, h)
return headerCtx{Context: newCtx}
} | go | func WrapWithHeaders(ctx context.Context, headers map[string]string) ContextWithHeaders {
h := &headersContainer{
reqHeaders: headers,
}
newCtx := context.WithValue(ctx, contextKeyHeaders, h)
return headerCtx{Context: newCtx}
} | [
"func",
"WrapWithHeaders",
"(",
"ctx",
"context",
".",
"Context",
",",
"headers",
"map",
"[",
"string",
"]",
"string",
")",
"ContextWithHeaders",
"{",
"h",
":=",
"&",
"headersContainer",
"{",
"reqHeaders",
":",
"headers",
",",
"}",
"\n",
"newCtx",
":=",
"c... | // WrapWithHeaders returns a Context that can be used to make a call with request headers.
// If the parent `ctx` is already an instance of ContextWithHeaders, its existing headers
// will be ignored. In order to merge new headers with parent headers, use ContextBuilder. | [
"WrapWithHeaders",
"returns",
"a",
"Context",
"that",
"can",
"be",
"used",
"to",
"make",
"a",
"call",
"with",
"request",
"headers",
".",
"If",
"the",
"parent",
"ctx",
"is",
"already",
"an",
"instance",
"of",
"ContextWithHeaders",
"its",
"existing",
"headers",
... | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/context_header.go#L110-L116 | test |
uber/tchannel-go | context_header.go | WithoutHeaders | func WithoutHeaders(ctx context.Context) context.Context {
return context.WithValue(context.WithValue(ctx, contextKeyTChannel, nil), contextKeyHeaders, nil)
} | go | func WithoutHeaders(ctx context.Context) context.Context {
return context.WithValue(context.WithValue(ctx, contextKeyTChannel, nil), contextKeyHeaders, nil)
} | [
"func",
"WithoutHeaders",
"(",
"ctx",
"context",
".",
"Context",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"contextKeyTChannel",
",",
"nil",
")",
",",
"contextKeyHeaders",
"... | // WithoutHeaders hides any TChannel headers from the given context. | [
"WithoutHeaders",
"hides",
"any",
"TChannel",
"headers",
"from",
"the",
"given",
"context",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/context_header.go#L119-L121 | test |
uber/tchannel-go | mex.go | Notify | func (e *errNotifier) Notify(err error) error {
// The code should never try to Notify(nil).
if err == nil {
panic("cannot Notify with no error")
}
// There may be some sort of race where we try to notify the mex twice.
if !e.notified.CAS(false, true) {
return fmt.Errorf("cannot broadcast error: %v, already h... | go | func (e *errNotifier) Notify(err error) error {
// The code should never try to Notify(nil).
if err == nil {
panic("cannot Notify with no error")
}
// There may be some sort of race where we try to notify the mex twice.
if !e.notified.CAS(false, true) {
return fmt.Errorf("cannot broadcast error: %v, already h... | [
"func",
"(",
"e",
"*",
"errNotifier",
")",
"Notify",
"(",
"err",
"error",
")",
"error",
"{",
"if",
"err",
"==",
"nil",
"{",
"panic",
"(",
"\"cannot Notify with no error\"",
")",
"\n",
"}",
"\n",
"if",
"!",
"e",
".",
"notified",
".",
"CAS",
"(",
"fals... | // Notify will store the error and notify all waiters on c that there's an error. | [
"Notify",
"will",
"store",
"the",
"error",
"and",
"notify",
"all",
"waiters",
"on",
"c",
"that",
"there",
"s",
"an",
"error",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/mex.go#L61-L75 | test |
uber/tchannel-go | mex.go | forwardPeerFrame | func (mex *messageExchange) forwardPeerFrame(frame *Frame) error {
// We want a very specific priority here:
// 1. Timeouts/cancellation (mex.ctx errors)
// 2. Whether recvCh has buffer space (non-blocking select over mex.recvCh)
// 3. Other mex errors (mex.errCh)
// Which is why we check the context error only (i... | go | func (mex *messageExchange) forwardPeerFrame(frame *Frame) error {
// We want a very specific priority here:
// 1. Timeouts/cancellation (mex.ctx errors)
// 2. Whether recvCh has buffer space (non-blocking select over mex.recvCh)
// 3. Other mex errors (mex.errCh)
// Which is why we check the context error only (i... | [
"func",
"(",
"mex",
"*",
"messageExchange",
")",
"forwardPeerFrame",
"(",
"frame",
"*",
"Frame",
")",
"error",
"{",
"if",
"err",
":=",
"mex",
".",
"ctx",
".",
"Err",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"GetContextError",
"(",
"err",
")"... | // forwardPeerFrame forwards a frame from a peer to the message exchange, where
// it can be pulled by whatever application thread is handling the exchange | [
"forwardPeerFrame",
"forwards",
"a",
"frame",
"from",
"a",
"peer",
"to",
"the",
"message",
"exchange",
"where",
"it",
"can",
"be",
"pulled",
"by",
"whatever",
"application",
"thread",
"is",
"handling",
"the",
"exchange"
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/mex.go#L116-L144 | test |
uber/tchannel-go | mex.go | recvPeerFrame | func (mex *messageExchange) recvPeerFrame() (*Frame, error) {
// We have to check frames/errors in a very specific order here:
// 1. Timeouts/cancellation (mex.ctx errors)
// 2. Any pending frames (non-blocking select over mex.recvCh)
// 3. Other mex errors (mex.errCh)
// Which is why we check the context error on... | go | func (mex *messageExchange) recvPeerFrame() (*Frame, error) {
// We have to check frames/errors in a very specific order here:
// 1. Timeouts/cancellation (mex.ctx errors)
// 2. Any pending frames (non-blocking select over mex.recvCh)
// 3. Other mex errors (mex.errCh)
// Which is why we check the context error on... | [
"func",
"(",
"mex",
"*",
"messageExchange",
")",
"recvPeerFrame",
"(",
")",
"(",
"*",
"Frame",
",",
"error",
")",
"{",
"if",
"err",
":=",
"mex",
".",
"ctx",
".",
"Err",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"GetContextError"... | // recvPeerFrame waits for a new frame from the peer, or until the context
// expires or is cancelled | [
"recvPeerFrame",
"waits",
"for",
"a",
"new",
"frame",
"from",
"the",
"peer",
"or",
"until",
"the",
"context",
"expires",
"or",
"is",
"cancelled"
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/mex.go#L159-L191 | test |
uber/tchannel-go | mex.go | recvPeerFrameOfType | func (mex *messageExchange) recvPeerFrameOfType(msgType messageType) (*Frame, error) {
frame, err := mex.recvPeerFrame()
if err != nil {
return nil, err
}
switch frame.Header.messageType {
case msgType:
return frame, nil
case messageTypeError:
// If we read an error frame, we can release it once we deseri... | go | func (mex *messageExchange) recvPeerFrameOfType(msgType messageType) (*Frame, error) {
frame, err := mex.recvPeerFrame()
if err != nil {
return nil, err
}
switch frame.Header.messageType {
case msgType:
return frame, nil
case messageTypeError:
// If we read an error frame, we can release it once we deseri... | [
"func",
"(",
"mex",
"*",
"messageExchange",
")",
"recvPeerFrameOfType",
"(",
"msgType",
"messageType",
")",
"(",
"*",
"Frame",
",",
"error",
")",
"{",
"frame",
",",
"err",
":=",
"mex",
".",
"recvPeerFrame",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{"... | // recvPeerFrameOfType waits for a new frame of a given type from the peer, failing
// if the next frame received is not of that type.
// If an error frame is returned, then the errorMessage is returned as the error. | [
"recvPeerFrameOfType",
"waits",
"for",
"a",
"new",
"frame",
"of",
"a",
"given",
"type",
"from",
"the",
"peer",
"failing",
"if",
"the",
"next",
"frame",
"received",
"is",
"not",
"of",
"that",
"type",
".",
"If",
"an",
"error",
"frame",
"is",
"returned",
"t... | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/mex.go#L196-L229 | test |
uber/tchannel-go | mex.go | shutdown | func (mex *messageExchange) shutdown() {
// The reader and writer side can both hit errors and try to shutdown the mex,
// so we ensure that it's only shut down once.
if !mex.shutdownAtomic.CAS(false, true) {
return
}
if mex.errChNotified.CAS(false, true) {
mex.errCh.Notify(errMexShutdown)
}
mex.mexset.rem... | go | func (mex *messageExchange) shutdown() {
// The reader and writer side can both hit errors and try to shutdown the mex,
// so we ensure that it's only shut down once.
if !mex.shutdownAtomic.CAS(false, true) {
return
}
if mex.errChNotified.CAS(false, true) {
mex.errCh.Notify(errMexShutdown)
}
mex.mexset.rem... | [
"func",
"(",
"mex",
"*",
"messageExchange",
")",
"shutdown",
"(",
")",
"{",
"if",
"!",
"mex",
".",
"shutdownAtomic",
".",
"CAS",
"(",
"false",
",",
"true",
")",
"{",
"return",
"\n",
"}",
"\n",
"if",
"mex",
".",
"errChNotified",
".",
"CAS",
"(",
"fa... | // shutdown shuts down the message exchange, removing it from the message
// exchange set so that it cannot receive more messages from the peer. The
// receive channel remains open, however, in case there are concurrent
// goroutines sending to it. | [
"shutdown",
"shuts",
"down",
"the",
"message",
"exchange",
"removing",
"it",
"from",
"the",
"message",
"exchange",
"set",
"so",
"that",
"it",
"cannot",
"receive",
"more",
"messages",
"from",
"the",
"peer",
".",
"The",
"receive",
"channel",
"remains",
"open",
... | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/mex.go#L235-L247 | test |
uber/tchannel-go | mex.go | newMessageExchangeSet | func newMessageExchangeSet(log Logger, name string) *messageExchangeSet {
return &messageExchangeSet{
name: name,
log: log.WithFields(LogField{"exchange", name}),
exchanges: make(map[uint32]*messageExchange),
expiredExchanges: make(map[uint32]struct{}),
}
} | go | func newMessageExchangeSet(log Logger, name string) *messageExchangeSet {
return &messageExchangeSet{
name: name,
log: log.WithFields(LogField{"exchange", name}),
exchanges: make(map[uint32]*messageExchange),
expiredExchanges: make(map[uint32]struct{}),
}
} | [
"func",
"newMessageExchangeSet",
"(",
"log",
"Logger",
",",
"name",
"string",
")",
"*",
"messageExchangeSet",
"{",
"return",
"&",
"messageExchangeSet",
"{",
"name",
":",
"name",
",",
"log",
":",
"log",
".",
"WithFields",
"(",
"LogField",
"{",
"\"exchange\"",
... | // newMessageExchangeSet creates a new messageExchangeSet with a given name. | [
"newMessageExchangeSet",
"creates",
"a",
"new",
"messageExchangeSet",
"with",
"a",
"given",
"name",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/mex.go#L280-L287 | test |
uber/tchannel-go | mex.go | addExchange | func (mexset *messageExchangeSet) addExchange(mex *messageExchange) error {
if mexset.shutdown {
return errMexSetShutdown
}
if _, ok := mexset.exchanges[mex.msgID]; ok {
return errDuplicateMex
}
mexset.exchanges[mex.msgID] = mex
return nil
} | go | func (mexset *messageExchangeSet) addExchange(mex *messageExchange) error {
if mexset.shutdown {
return errMexSetShutdown
}
if _, ok := mexset.exchanges[mex.msgID]; ok {
return errDuplicateMex
}
mexset.exchanges[mex.msgID] = mex
return nil
} | [
"func",
"(",
"mexset",
"*",
"messageExchangeSet",
")",
"addExchange",
"(",
"mex",
"*",
"messageExchange",
")",
"error",
"{",
"if",
"mexset",
".",
"shutdown",
"{",
"return",
"errMexSetShutdown",
"\n",
"}",
"\n",
"if",
"_",
",",
"ok",
":=",
"mexset",
".",
... | // addExchange adds an exchange, it must be called with the mexset locked. | [
"addExchange",
"adds",
"an",
"exchange",
"it",
"must",
"be",
"called",
"with",
"the",
"mexset",
"locked",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/mex.go#L290-L301 | test |
uber/tchannel-go | mex.go | newExchange | func (mexset *messageExchangeSet) newExchange(ctx context.Context, framePool FramePool,
msgType messageType, msgID uint32, bufferSize int) (*messageExchange, error) {
if mexset.log.Enabled(LogLevelDebug) {
mexset.log.Debugf("Creating new %s message exchange for [%v:%d]", mexset.name, msgType, msgID)
}
mex := &me... | go | func (mexset *messageExchangeSet) newExchange(ctx context.Context, framePool FramePool,
msgType messageType, msgID uint32, bufferSize int) (*messageExchange, error) {
if mexset.log.Enabled(LogLevelDebug) {
mexset.log.Debugf("Creating new %s message exchange for [%v:%d]", mexset.name, msgType, msgID)
}
mex := &me... | [
"func",
"(",
"mexset",
"*",
"messageExchangeSet",
")",
"newExchange",
"(",
"ctx",
"context",
".",
"Context",
",",
"framePool",
"FramePool",
",",
"msgType",
"messageType",
",",
"msgID",
"uint32",
",",
"bufferSize",
"int",
")",
"(",
"*",
"messageExchange",
",",
... | // newExchange creates and adds a new message exchange to this set | [
"newExchange",
"creates",
"and",
"adds",
"a",
"new",
"message",
"exchange",
"to",
"this",
"set"
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/mex.go#L304-L343 | test |
uber/tchannel-go | mex.go | deleteExchange | func (mexset *messageExchangeSet) deleteExchange(msgID uint32) (found, timedOut bool) {
if _, found := mexset.exchanges[msgID]; found {
delete(mexset.exchanges, msgID)
return true, false
}
if _, expired := mexset.expiredExchanges[msgID]; expired {
delete(mexset.expiredExchanges, msgID)
return false, true
}... | go | func (mexset *messageExchangeSet) deleteExchange(msgID uint32) (found, timedOut bool) {
if _, found := mexset.exchanges[msgID]; found {
delete(mexset.exchanges, msgID)
return true, false
}
if _, expired := mexset.expiredExchanges[msgID]; expired {
delete(mexset.expiredExchanges, msgID)
return false, true
}... | [
"func",
"(",
"mexset",
"*",
"messageExchangeSet",
")",
"deleteExchange",
"(",
"msgID",
"uint32",
")",
"(",
"found",
",",
"timedOut",
"bool",
")",
"{",
"if",
"_",
",",
"found",
":=",
"mexset",
".",
"exchanges",
"[",
"msgID",
"]",
";",
"found",
"{",
"del... | // deleteExchange will delete msgID, and return whether it was found or whether it was
// timed out. This method must be called with the lock. | [
"deleteExchange",
"will",
"delete",
"msgID",
"and",
"return",
"whether",
"it",
"was",
"found",
"or",
"whether",
"it",
"was",
"timed",
"out",
".",
"This",
"method",
"must",
"be",
"called",
"with",
"the",
"lock",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/mex.go#L347-L359 | test |
uber/tchannel-go | mex.go | removeExchange | func (mexset *messageExchangeSet) removeExchange(msgID uint32) {
if mexset.log.Enabled(LogLevelDebug) {
mexset.log.Debugf("Removing %s message exchange %d", mexset.name, msgID)
}
mexset.Lock()
found, expired := mexset.deleteExchange(msgID)
mexset.Unlock()
if !found && !expired {
mexset.log.WithFields(
Lo... | go | func (mexset *messageExchangeSet) removeExchange(msgID uint32) {
if mexset.log.Enabled(LogLevelDebug) {
mexset.log.Debugf("Removing %s message exchange %d", mexset.name, msgID)
}
mexset.Lock()
found, expired := mexset.deleteExchange(msgID)
mexset.Unlock()
if !found && !expired {
mexset.log.WithFields(
Lo... | [
"func",
"(",
"mexset",
"*",
"messageExchangeSet",
")",
"removeExchange",
"(",
"msgID",
"uint32",
")",
"{",
"if",
"mexset",
".",
"log",
".",
"Enabled",
"(",
"LogLevelDebug",
")",
"{",
"mexset",
".",
"log",
".",
"Debugf",
"(",
"\"Removing %s message exchange %d\... | // removeExchange removes a message exchange from the set, if it exists. | [
"removeExchange",
"removes",
"a",
"message",
"exchange",
"from",
"the",
"set",
"if",
"it",
"exists",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/mex.go#L362-L381 | test |
uber/tchannel-go | mex.go | expireExchange | func (mexset *messageExchangeSet) expireExchange(msgID uint32) {
mexset.log.Debugf(
"Removing %s message exchange %d due to timeout, cancellation or blackhole",
mexset.name,
msgID,
)
mexset.Lock()
// TODO(aniketp): explore if cancel can be called everytime we expire an exchange
found, expired := mexset.dele... | go | func (mexset *messageExchangeSet) expireExchange(msgID uint32) {
mexset.log.Debugf(
"Removing %s message exchange %d due to timeout, cancellation or blackhole",
mexset.name,
msgID,
)
mexset.Lock()
// TODO(aniketp): explore if cancel can be called everytime we expire an exchange
found, expired := mexset.dele... | [
"func",
"(",
"mexset",
"*",
"messageExchangeSet",
")",
"expireExchange",
"(",
"msgID",
"uint32",
")",
"{",
"mexset",
".",
"log",
".",
"Debugf",
"(",
"\"Removing %s message exchange %d due to timeout, cancellation or blackhole\"",
",",
"mexset",
".",
"name",
",",
"msgI... | // expireExchange is similar to removeExchange, but it marks the exchange as
// expired. | [
"expireExchange",
"is",
"similar",
"to",
"removeExchange",
"but",
"it",
"marks",
"the",
"exchange",
"as",
"expired",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/mex.go#L385-L406 | test |
uber/tchannel-go | mex.go | forwardPeerFrame | func (mexset *messageExchangeSet) forwardPeerFrame(frame *Frame) error {
if mexset.log.Enabled(LogLevelDebug) {
mexset.log.Debugf("forwarding %s %s", mexset.name, frame.Header)
}
mexset.RLock()
mex := mexset.exchanges[frame.Header.ID]
mexset.RUnlock()
if mex == nil {
// This is ok since the exchange might h... | go | func (mexset *messageExchangeSet) forwardPeerFrame(frame *Frame) error {
if mexset.log.Enabled(LogLevelDebug) {
mexset.log.Debugf("forwarding %s %s", mexset.name, frame.Header)
}
mexset.RLock()
mex := mexset.exchanges[frame.Header.ID]
mexset.RUnlock()
if mex == nil {
// This is ok since the exchange might h... | [
"func",
"(",
"mexset",
"*",
"messageExchangeSet",
")",
"forwardPeerFrame",
"(",
"frame",
"*",
"Frame",
")",
"error",
"{",
"if",
"mexset",
".",
"log",
".",
"Enabled",
"(",
"LogLevelDebug",
")",
"{",
"mexset",
".",
"log",
".",
"Debugf",
"(",
"\"forwarding %s... | // forwardPeerFrame forwards a frame from the peer to the appropriate message
// exchange | [
"forwardPeerFrame",
"forwards",
"a",
"frame",
"from",
"the",
"peer",
"to",
"the",
"appropriate",
"message",
"exchange"
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/mex.go#L418-L447 | test |
uber/tchannel-go | mex.go | copyExchanges | func (mexset *messageExchangeSet) copyExchanges() (shutdown bool, exchanges map[uint32]*messageExchange) {
if mexset.shutdown {
return true, nil
}
exchangesCopy := make(map[uint32]*messageExchange, len(mexset.exchanges))
for k, mex := range mexset.exchanges {
exchangesCopy[k] = mex
}
return false, exchanges... | go | func (mexset *messageExchangeSet) copyExchanges() (shutdown bool, exchanges map[uint32]*messageExchange) {
if mexset.shutdown {
return true, nil
}
exchangesCopy := make(map[uint32]*messageExchange, len(mexset.exchanges))
for k, mex := range mexset.exchanges {
exchangesCopy[k] = mex
}
return false, exchanges... | [
"func",
"(",
"mexset",
"*",
"messageExchangeSet",
")",
"copyExchanges",
"(",
")",
"(",
"shutdown",
"bool",
",",
"exchanges",
"map",
"[",
"uint32",
"]",
"*",
"messageExchange",
")",
"{",
"if",
"mexset",
".",
"shutdown",
"{",
"return",
"true",
",",
"nil",
... | // copyExchanges returns a copy of the exchanges if the exchange is active.
// The caller must lock the mexset. | [
"copyExchanges",
"returns",
"a",
"copy",
"of",
"the",
"exchanges",
"if",
"the",
"exchange",
"is",
"active",
".",
"The",
"caller",
"must",
"lock",
"the",
"mexset",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/mex.go#L451-L462 | test |
uber/tchannel-go | mex.go | stopExchanges | func (mexset *messageExchangeSet) stopExchanges(err error) {
if mexset.log.Enabled(LogLevelDebug) {
mexset.log.Debugf("stopping %v exchanges due to error: %v", mexset.count(), err)
}
mexset.Lock()
shutdown, exchanges := mexset.copyExchanges()
mexset.shutdown = true
mexset.Unlock()
if shutdown {
mexset.log.... | go | func (mexset *messageExchangeSet) stopExchanges(err error) {
if mexset.log.Enabled(LogLevelDebug) {
mexset.log.Debugf("stopping %v exchanges due to error: %v", mexset.count(), err)
}
mexset.Lock()
shutdown, exchanges := mexset.copyExchanges()
mexset.shutdown = true
mexset.Unlock()
if shutdown {
mexset.log.... | [
"func",
"(",
"mexset",
"*",
"messageExchangeSet",
")",
"stopExchanges",
"(",
"err",
"error",
")",
"{",
"if",
"mexset",
".",
"log",
".",
"Enabled",
"(",
"LogLevelDebug",
")",
"{",
"mexset",
".",
"log",
".",
"Debugf",
"(",
"\"stopping %v exchanges due to error: ... | // stopExchanges stops all message exchanges to unblock all waiters on the mex.
// This should only be called on connection failures. | [
"stopExchanges",
"stops",
"all",
"message",
"exchanges",
"to",
"unblock",
"all",
"waiters",
"on",
"the",
"mex",
".",
"This",
"should",
"only",
"be",
"called",
"on",
"connection",
"failures",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/mex.go#L466-L492 | test |
uber/tchannel-go | frame.go | NewFrame | func NewFrame(payloadCapacity int) *Frame {
f := &Frame{}
f.buffer = make([]byte, payloadCapacity+FrameHeaderSize)
f.Payload = f.buffer[FrameHeaderSize:]
f.headerBuffer = f.buffer[:FrameHeaderSize]
return f
} | go | func NewFrame(payloadCapacity int) *Frame {
f := &Frame{}
f.buffer = make([]byte, payloadCapacity+FrameHeaderSize)
f.Payload = f.buffer[FrameHeaderSize:]
f.headerBuffer = f.buffer[:FrameHeaderSize]
return f
} | [
"func",
"NewFrame",
"(",
"payloadCapacity",
"int",
")",
"*",
"Frame",
"{",
"f",
":=",
"&",
"Frame",
"{",
"}",
"\n",
"f",
".",
"buffer",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"payloadCapacity",
"+",
"FrameHeaderSize",
")",
"\n",
"f",
".",
"Payload"... | // NewFrame allocates a new frame with the given payload capacity | [
"NewFrame",
"allocates",
"a",
"new",
"frame",
"with",
"the",
"given",
"payload",
"capacity"
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/frame.go#L119-L125 | test |
uber/tchannel-go | frame.go | ReadBody | func (f *Frame) ReadBody(header []byte, r io.Reader) error {
// Copy the header into the underlying buffer so we have an assembled frame
// that can be directly forwarded.
copy(f.buffer, header)
// Parse the header into our typed struct.
if err := f.Header.read(typed.NewReadBuffer(header)); err != nil {
return ... | go | func (f *Frame) ReadBody(header []byte, r io.Reader) error {
// Copy the header into the underlying buffer so we have an assembled frame
// that can be directly forwarded.
copy(f.buffer, header)
// Parse the header into our typed struct.
if err := f.Header.read(typed.NewReadBuffer(header)); err != nil {
return ... | [
"func",
"(",
"f",
"*",
"Frame",
")",
"ReadBody",
"(",
"header",
"[",
"]",
"byte",
",",
"r",
"io",
".",
"Reader",
")",
"error",
"{",
"copy",
"(",
"f",
".",
"buffer",
",",
"header",
")",
"\n",
"if",
"err",
":=",
"f",
".",
"Header",
".",
"read",
... | // ReadBody takes in a previously read frame header, and only reads in the body
// based on the size specified in the header. This allows callers to defer
// the frame allocation till the body needs to be read. | [
"ReadBody",
"takes",
"in",
"a",
"previously",
"read",
"frame",
"header",
"and",
"only",
"reads",
"in",
"the",
"body",
"based",
"on",
"the",
"size",
"specified",
"in",
"the",
"header",
".",
"This",
"allows",
"callers",
"to",
"defer",
"the",
"frame",
"alloca... | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/frame.go#L130-L150 | test |
uber/tchannel-go | frame.go | WriteOut | func (f *Frame) WriteOut(w io.Writer) error {
var wbuf typed.WriteBuffer
wbuf.Wrap(f.headerBuffer)
if err := f.Header.write(&wbuf); err != nil {
return err
}
fullFrame := f.buffer[:f.Header.FrameSize()]
if _, err := w.Write(fullFrame); err != nil {
return err
}
return nil
} | go | func (f *Frame) WriteOut(w io.Writer) error {
var wbuf typed.WriteBuffer
wbuf.Wrap(f.headerBuffer)
if err := f.Header.write(&wbuf); err != nil {
return err
}
fullFrame := f.buffer[:f.Header.FrameSize()]
if _, err := w.Write(fullFrame); err != nil {
return err
}
return nil
} | [
"func",
"(",
"f",
"*",
"Frame",
")",
"WriteOut",
"(",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"var",
"wbuf",
"typed",
".",
"WriteBuffer",
"\n",
"wbuf",
".",
"Wrap",
"(",
"f",
".",
"headerBuffer",
")",
"\n",
"if",
"err",
":=",
"f",
".",
"Head... | // WriteOut writes the frame to the given io.Writer | [
"WriteOut",
"writes",
"the",
"frame",
"to",
"the",
"given",
"io",
".",
"Writer"
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/frame.go#L165-L179 | test |
uber/tchannel-go | retry.go | CanRetry | func (r RetryOn) CanRetry(err error) bool {
if r == RetryNever {
return false
}
if r == RetryDefault {
r = RetryConnectionError
}
code := getErrCode(err)
if code == ErrCodeBusy || code == ErrCodeDeclined {
return true
}
// Never retry bad requests, since it will probably cause another bad request.
if c... | go | func (r RetryOn) CanRetry(err error) bool {
if r == RetryNever {
return false
}
if r == RetryDefault {
r = RetryConnectionError
}
code := getErrCode(err)
if code == ErrCodeBusy || code == ErrCodeDeclined {
return true
}
// Never retry bad requests, since it will probably cause another bad request.
if c... | [
"func",
"(",
"r",
"RetryOn",
")",
"CanRetry",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"r",
"==",
"RetryNever",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"r",
"==",
"RetryDefault",
"{",
"r",
"=",
"RetryConnectionError",
"\n",
"}",
"\n",
"cod... | // CanRetry returns whether an error can be retried for the given retry option. | [
"CanRetry",
"returns",
"whether",
"an",
"error",
"can",
"be",
"retried",
"for",
"the",
"given",
"retry",
"option",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/retry.go#L89-L117 | test |
uber/tchannel-go | retry.go | HasRetries | func (rs *RequestState) HasRetries(err error) bool {
if rs == nil {
return false
}
rOpts := rs.retryOpts
return rs.Attempt < rOpts.MaxAttempts && rOpts.RetryOn.CanRetry(err)
} | go | func (rs *RequestState) HasRetries(err error) bool {
if rs == nil {
return false
}
rOpts := rs.retryOpts
return rs.Attempt < rOpts.MaxAttempts && rOpts.RetryOn.CanRetry(err)
} | [
"func",
"(",
"rs",
"*",
"RequestState",
")",
"HasRetries",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"rs",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"rOpts",
":=",
"rs",
".",
"retryOpts",
"\n",
"return",
"rs",
".",
"Attempt",
"<",
"r... | // HasRetries will return true if there are more retries left. | [
"HasRetries",
"will",
"return",
"true",
"if",
"there",
"are",
"more",
"retries",
"left",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/retry.go#L159-L165 | test |
uber/tchannel-go | retry.go | SinceStart | func (rs *RequestState) SinceStart(now time.Time, fallback time.Duration) time.Duration {
if rs == nil {
return fallback
}
return now.Sub(rs.Start)
} | go | func (rs *RequestState) SinceStart(now time.Time, fallback time.Duration) time.Duration {
if rs == nil {
return fallback
}
return now.Sub(rs.Start)
} | [
"func",
"(",
"rs",
"*",
"RequestState",
")",
"SinceStart",
"(",
"now",
"time",
".",
"Time",
",",
"fallback",
"time",
".",
"Duration",
")",
"time",
".",
"Duration",
"{",
"if",
"rs",
"==",
"nil",
"{",
"return",
"fallback",
"\n",
"}",
"\n",
"return",
"n... | // SinceStart returns the time since the start of the request. If there is no request state,
// then the fallback is returned. | [
"SinceStart",
"returns",
"the",
"time",
"since",
"the",
"start",
"of",
"the",
"request",
".",
"If",
"there",
"is",
"no",
"request",
"state",
"then",
"the",
"fallback",
"is",
"returned",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/retry.go#L169-L174 | test |
uber/tchannel-go | retry.go | AddSelectedPeer | func (rs *RequestState) AddSelectedPeer(hostPort string) {
if rs == nil {
return
}
host := getHost(hostPort)
if rs.SelectedPeers == nil {
rs.SelectedPeers = map[string]struct{}{
hostPort: {},
host: {},
}
} else {
rs.SelectedPeers[hostPort] = struct{}{}
rs.SelectedPeers[host] = struct{}{}
}
} | go | func (rs *RequestState) AddSelectedPeer(hostPort string) {
if rs == nil {
return
}
host := getHost(hostPort)
if rs.SelectedPeers == nil {
rs.SelectedPeers = map[string]struct{}{
hostPort: {},
host: {},
}
} else {
rs.SelectedPeers[hostPort] = struct{}{}
rs.SelectedPeers[host] = struct{}{}
}
} | [
"func",
"(",
"rs",
"*",
"RequestState",
")",
"AddSelectedPeer",
"(",
"hostPort",
"string",
")",
"{",
"if",
"rs",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"host",
":=",
"getHost",
"(",
"hostPort",
")",
"\n",
"if",
"rs",
".",
"SelectedPeers",
"==",
... | // AddSelectedPeer adds a given peer to the set of selected peers. | [
"AddSelectedPeer",
"adds",
"a",
"given",
"peer",
"to",
"the",
"set",
"of",
"selected",
"peers",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/retry.go#L185-L200 | test |
uber/tchannel-go | retry.go | RunWithRetry | func (ch *Channel) RunWithRetry(runCtx context.Context, f RetriableFunc) error {
var err error
opts := getRetryOptions(runCtx)
rs := ch.getRequestState(opts)
defer requestStatePool.Put(rs)
for i := 0; i < opts.MaxAttempts; i++ {
rs.Attempt++
if opts.TimeoutPerAttempt == 0 {
err = f(runCtx, rs)
} else {... | go | func (ch *Channel) RunWithRetry(runCtx context.Context, f RetriableFunc) error {
var err error
opts := getRetryOptions(runCtx)
rs := ch.getRequestState(opts)
defer requestStatePool.Put(rs)
for i := 0; i < opts.MaxAttempts; i++ {
rs.Attempt++
if opts.TimeoutPerAttempt == 0 {
err = f(runCtx, rs)
} else {... | [
"func",
"(",
"ch",
"*",
"Channel",
")",
"RunWithRetry",
"(",
"runCtx",
"context",
".",
"Context",
",",
"f",
"RetriableFunc",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"opts",
":=",
"getRetryOptions",
"(",
"runCtx",
")",
"\n",
"rs",
":=",
"ch",
".... | // RunWithRetry will take a function that makes the TChannel call, and will
// rerun it as specifed in the RetryOptions in the Context. | [
"RunWithRetry",
"will",
"take",
"a",
"function",
"that",
"makes",
"the",
"TChannel",
"call",
"and",
"will",
"rerun",
"it",
"as",
"specifed",
"in",
"the",
"RetryOptions",
"in",
"the",
"Context",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/retry.go#L212-L249 | test |
uber/tchannel-go | checksum.go | ChecksumSize | func (t ChecksumType) ChecksumSize() int {
switch t {
case ChecksumTypeNone:
return 0
case ChecksumTypeCrc32, ChecksumTypeCrc32C:
return crc32.Size
case ChecksumTypeFarmhash:
return 4
default:
return 0
}
} | go | func (t ChecksumType) ChecksumSize() int {
switch t {
case ChecksumTypeNone:
return 0
case ChecksumTypeCrc32, ChecksumTypeCrc32C:
return crc32.Size
case ChecksumTypeFarmhash:
return 4
default:
return 0
}
} | [
"func",
"(",
"t",
"ChecksumType",
")",
"ChecksumSize",
"(",
")",
"int",
"{",
"switch",
"t",
"{",
"case",
"ChecksumTypeNone",
":",
"return",
"0",
"\n",
"case",
"ChecksumTypeCrc32",
",",
"ChecksumTypeCrc32C",
":",
"return",
"crc32",
".",
"Size",
"\n",
"case",
... | // ChecksumSize returns the size in bytes of the checksum calculation | [
"ChecksumSize",
"returns",
"the",
"size",
"in",
"bytes",
"of",
"the",
"checksum",
"calculation"
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/checksum.go#L70-L81 | test |
uber/tchannel-go | checksum.go | New | func (t ChecksumType) New() Checksum {
s := t.pool().Get().(Checksum)
s.Reset()
return s
} | go | func (t ChecksumType) New() Checksum {
s := t.pool().Get().(Checksum)
s.Reset()
return s
} | [
"func",
"(",
"t",
"ChecksumType",
")",
"New",
"(",
")",
"Checksum",
"{",
"s",
":=",
"t",
".",
"pool",
"(",
")",
".",
"Get",
"(",
")",
".",
"(",
"Checksum",
")",
"\n",
"s",
".",
"Reset",
"(",
")",
"\n",
"return",
"s",
"\n",
"}"
] | // New creates a new Checksum of the given type | [
"New",
"creates",
"a",
"new",
"Checksum",
"of",
"the",
"given",
"type"
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/checksum.go#L89-L93 | test |
uber/tchannel-go | thrift/thrift-gen/main.go | parseTemplates | func parseTemplates(skipTChannel bool, templateFiles []string) ([]*Template, error) {
var templates []*Template
if !skipTChannel {
templates = append(templates, &Template{
name: "tchan",
template: template.Must(parseTemplate(tchannelTmpl)),
})
}
for _, f := range templateFiles {
t, err := parseTem... | go | func parseTemplates(skipTChannel bool, templateFiles []string) ([]*Template, error) {
var templates []*Template
if !skipTChannel {
templates = append(templates, &Template{
name: "tchan",
template: template.Must(parseTemplate(tchannelTmpl)),
})
}
for _, f := range templateFiles {
t, err := parseTem... | [
"func",
"parseTemplates",
"(",
"skipTChannel",
"bool",
",",
"templateFiles",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"*",
"Template",
",",
"error",
")",
"{",
"var",
"templates",
"[",
"]",
"*",
"Template",
"\n",
"if",
"!",
"skipTChannel",
"{",
"templates"... | // parseTemplates returns a list of Templates that must be rendered given the template files. | [
"parseTemplates",
"returns",
"a",
"list",
"of",
"Templates",
"that",
"must",
"be",
"rendered",
"given",
"the",
"template",
"files",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/thrift-gen/main.go#L139-L159 | test |
uber/tchannel-go | thrift/thrift-gen/main.go | NewStringSliceFlag | func NewStringSliceFlag(name string, usage string) *[]string {
var ss stringSliceFlag
flag.Var(&ss, name, usage)
return (*[]string)(&ss)
} | go | func NewStringSliceFlag(name string, usage string) *[]string {
var ss stringSliceFlag
flag.Var(&ss, name, usage)
return (*[]string)(&ss)
} | [
"func",
"NewStringSliceFlag",
"(",
"name",
"string",
",",
"usage",
"string",
")",
"*",
"[",
"]",
"string",
"{",
"var",
"ss",
"stringSliceFlag",
"\n",
"flag",
".",
"Var",
"(",
"&",
"ss",
",",
"name",
",",
"usage",
")",
"\n",
"return",
"(",
"*",
"[",
... | // NewStringSliceFlag creates a new string slice flag. The default value is always nil. | [
"NewStringSliceFlag",
"creates",
"a",
"new",
"string",
"slice",
"flag",
".",
"The",
"default",
"value",
"is",
"always",
"nil",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/thrift-gen/main.go#L232-L236 | test |
uber/tchannel-go | thrift/thrift-gen/template.go | withStateFuncs | func (t *Template) withStateFuncs(td TemplateData) *template.Template {
return t.template.Funcs(map[string]interface{}{
"goType": td.global.goType,
})
} | go | func (t *Template) withStateFuncs(td TemplateData) *template.Template {
return t.template.Funcs(map[string]interface{}{
"goType": td.global.goType,
})
} | [
"func",
"(",
"t",
"*",
"Template",
")",
"withStateFuncs",
"(",
"td",
"TemplateData",
")",
"*",
"template",
".",
"Template",
"{",
"return",
"t",
".",
"template",
".",
"Funcs",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"goType\"",
":"... | // withStateFuncs adds functions to the template that are dependent upon state. | [
"withStateFuncs",
"adds",
"functions",
"to",
"the",
"template",
"that",
"are",
"dependent",
"upon",
"state",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/thrift-gen/template.go#L87-L91 | test |
uber/tchannel-go | introspection.go | IntrospectOthers | func (ch *Channel) IntrospectOthers(opts *IntrospectionOptions) map[string][]ChannelInfo {
if !opts.IncludeOtherChannels {
return nil
}
channelMap.Lock()
defer channelMap.Unlock()
states := make(map[string][]ChannelInfo)
for svc, channels := range channelMap.existing {
channelInfos := make([]ChannelInfo, 0,... | go | func (ch *Channel) IntrospectOthers(opts *IntrospectionOptions) map[string][]ChannelInfo {
if !opts.IncludeOtherChannels {
return nil
}
channelMap.Lock()
defer channelMap.Unlock()
states := make(map[string][]ChannelInfo)
for svc, channels := range channelMap.existing {
channelInfos := make([]ChannelInfo, 0,... | [
"func",
"(",
"ch",
"*",
"Channel",
")",
"IntrospectOthers",
"(",
"opts",
"*",
"IntrospectionOptions",
")",
"map",
"[",
"string",
"]",
"[",
"]",
"ChannelInfo",
"{",
"if",
"!",
"opts",
".",
"IncludeOtherChannels",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"ch... | // IntrospectOthers returns the ChannelInfo for all other channels in this process. | [
"IntrospectOthers",
"returns",
"the",
"ChannelInfo",
"for",
"all",
"other",
"channels",
"in",
"this",
"process",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/introspection.go#L244-L265 | test |
uber/tchannel-go | introspection.go | ReportInfo | func (ch *Channel) ReportInfo(opts *IntrospectionOptions) ChannelInfo {
return ChannelInfo{
ID: ch.chID,
CreatedStack: ch.createdStack,
LocalPeer: ch.PeerInfo(),
}
} | go | func (ch *Channel) ReportInfo(opts *IntrospectionOptions) ChannelInfo {
return ChannelInfo{
ID: ch.chID,
CreatedStack: ch.createdStack,
LocalPeer: ch.PeerInfo(),
}
} | [
"func",
"(",
"ch",
"*",
"Channel",
")",
"ReportInfo",
"(",
"opts",
"*",
"IntrospectionOptions",
")",
"ChannelInfo",
"{",
"return",
"ChannelInfo",
"{",
"ID",
":",
"ch",
".",
"chID",
",",
"CreatedStack",
":",
"ch",
".",
"createdStack",
",",
"LocalPeer",
":",... | // ReportInfo returns ChannelInfo for a channel. | [
"ReportInfo",
"returns",
"ChannelInfo",
"for",
"a",
"channel",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/introspection.go#L268-L274 | test |
uber/tchannel-go | introspection.go | IntrospectState | func (l *RootPeerList) IntrospectState(opts *IntrospectionOptions) map[string]PeerRuntimeState {
return fromPeerList(l, opts)
} | go | func (l *RootPeerList) IntrospectState(opts *IntrospectionOptions) map[string]PeerRuntimeState {
return fromPeerList(l, opts)
} | [
"func",
"(",
"l",
"*",
"RootPeerList",
")",
"IntrospectState",
"(",
"opts",
"*",
"IntrospectionOptions",
")",
"map",
"[",
"string",
"]",
"PeerRuntimeState",
"{",
"return",
"fromPeerList",
"(",
"l",
",",
"opts",
")",
"\n",
"}"
] | // IntrospectState returns the runtime state of the | [
"IntrospectState",
"returns",
"the",
"runtime",
"state",
"of",
"the"
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/introspection.go#L292-L294 | test |
uber/tchannel-go | introspection.go | IntrospectState | func (subChMap *subChannelMap) IntrospectState(opts *IntrospectionOptions) map[string]SubChannelRuntimeState {
m := make(map[string]SubChannelRuntimeState)
subChMap.RLock()
for k, sc := range subChMap.subchannels {
state := SubChannelRuntimeState{
Service: k,
Isolated: sc.Isolated(),
}
if state.Isolated... | go | func (subChMap *subChannelMap) IntrospectState(opts *IntrospectionOptions) map[string]SubChannelRuntimeState {
m := make(map[string]SubChannelRuntimeState)
subChMap.RLock()
for k, sc := range subChMap.subchannels {
state := SubChannelRuntimeState{
Service: k,
Isolated: sc.Isolated(),
}
if state.Isolated... | [
"func",
"(",
"subChMap",
"*",
"subChannelMap",
")",
"IntrospectState",
"(",
"opts",
"*",
"IntrospectionOptions",
")",
"map",
"[",
"string",
"]",
"SubChannelRuntimeState",
"{",
"m",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"SubChannelRuntimeState",
")",
"\... | // IntrospectState returns the runtime state of the subchannels. | [
"IntrospectState",
"returns",
"the",
"runtime",
"state",
"of",
"the",
"subchannels",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/introspection.go#L297-L323 | test |
uber/tchannel-go | introspection.go | IntrospectState | func (p *Peer) IntrospectState(opts *IntrospectionOptions) PeerRuntimeState {
p.RLock()
defer p.RUnlock()
return PeerRuntimeState{
HostPort: p.hostPort,
InboundConnections: getConnectionRuntimeState(p.inboundConnections, opts),
OutboundConnections: getConnectionRuntimeState(p.outboundConnections, ... | go | func (p *Peer) IntrospectState(opts *IntrospectionOptions) PeerRuntimeState {
p.RLock()
defer p.RUnlock()
return PeerRuntimeState{
HostPort: p.hostPort,
InboundConnections: getConnectionRuntimeState(p.inboundConnections, opts),
OutboundConnections: getConnectionRuntimeState(p.outboundConnections, ... | [
"func",
"(",
"p",
"*",
"Peer",
")",
"IntrospectState",
"(",
"opts",
"*",
"IntrospectionOptions",
")",
"PeerRuntimeState",
"{",
"p",
".",
"RLock",
"(",
")",
"\n",
"defer",
"p",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"PeerRuntimeState",
"{",
"HostPort",
... | // IntrospectState returns the runtime state for this peer. | [
"IntrospectState",
"returns",
"the",
"runtime",
"state",
"for",
"this",
"peer",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/introspection.go#L336-L347 | test |
uber/tchannel-go | introspection.go | IntrospectState | func (c *Connection) IntrospectState(opts *IntrospectionOptions) ConnectionRuntimeState {
c.stateMut.RLock()
defer c.stateMut.RUnlock()
// TODO(prashantv): Add total number of health checks, and health check options.
state := ConnectionRuntimeState{
ID: c.connID,
ConnectionState: c.state.String(... | go | func (c *Connection) IntrospectState(opts *IntrospectionOptions) ConnectionRuntimeState {
c.stateMut.RLock()
defer c.stateMut.RUnlock()
// TODO(prashantv): Add total number of health checks, and health check options.
state := ConnectionRuntimeState{
ID: c.connID,
ConnectionState: c.state.String(... | [
"func",
"(",
"c",
"*",
"Connection",
")",
"IntrospectState",
"(",
"opts",
"*",
"IntrospectionOptions",
")",
"ConnectionRuntimeState",
"{",
"c",
".",
"stateMut",
".",
"RLock",
"(",
")",
"\n",
"defer",
"c",
".",
"stateMut",
".",
"RUnlock",
"(",
")",
"\n",
... | // IntrospectState returns the runtime state for this connection. | [
"IntrospectState",
"returns",
"the",
"runtime",
"state",
"for",
"this",
"connection",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/introspection.go#L350-L371 | test |
uber/tchannel-go | introspection.go | IntrospectState | func (r *Relayer) IntrospectState(opts *IntrospectionOptions) RelayerRuntimeState {
count := r.inbound.Count() + r.outbound.Count()
return RelayerRuntimeState{
Count: count,
InboundItems: r.inbound.IntrospectState(opts, "inbound"),
OutboundItems: r.outbound.IntrospectState(opts, "outbound"),
MaxTimeo... | go | func (r *Relayer) IntrospectState(opts *IntrospectionOptions) RelayerRuntimeState {
count := r.inbound.Count() + r.outbound.Count()
return RelayerRuntimeState{
Count: count,
InboundItems: r.inbound.IntrospectState(opts, "inbound"),
OutboundItems: r.outbound.IntrospectState(opts, "outbound"),
MaxTimeo... | [
"func",
"(",
"r",
"*",
"Relayer",
")",
"IntrospectState",
"(",
"opts",
"*",
"IntrospectionOptions",
")",
"RelayerRuntimeState",
"{",
"count",
":=",
"r",
".",
"inbound",
".",
"Count",
"(",
")",
"+",
"r",
".",
"outbound",
".",
"Count",
"(",
")",
"\n",
"r... | // IntrospectState returns the runtime state for this relayer. | [
"IntrospectState",
"returns",
"the",
"runtime",
"state",
"for",
"this",
"relayer",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/introspection.go#L374-L382 | test |
uber/tchannel-go | introspection.go | IntrospectState | func (ri *relayItems) IntrospectState(opts *IntrospectionOptions, name string) RelayItemSetState {
ri.RLock()
defer ri.RUnlock()
setState := RelayItemSetState{
Name: name,
Count: ri.Count(),
}
if opts.IncludeExchanges {
setState.Items = make(map[string]RelayItemState, len(ri.items))
for k, v := range ri.... | go | func (ri *relayItems) IntrospectState(opts *IntrospectionOptions, name string) RelayItemSetState {
ri.RLock()
defer ri.RUnlock()
setState := RelayItemSetState{
Name: name,
Count: ri.Count(),
}
if opts.IncludeExchanges {
setState.Items = make(map[string]RelayItemState, len(ri.items))
for k, v := range ri.... | [
"func",
"(",
"ri",
"*",
"relayItems",
")",
"IntrospectState",
"(",
"opts",
"*",
"IntrospectionOptions",
",",
"name",
"string",
")",
"RelayItemSetState",
"{",
"ri",
".",
"RLock",
"(",
")",
"\n",
"defer",
"ri",
".",
"RUnlock",
"(",
")",
"\n",
"setState",
"... | // IntrospectState returns the runtime state for this relayItems. | [
"IntrospectState",
"returns",
"the",
"runtime",
"state",
"for",
"this",
"relayItems",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/introspection.go#L385-L410 | test |
uber/tchannel-go | introspection.go | IntrospectState | func (mexset *messageExchangeSet) IntrospectState(opts *IntrospectionOptions) ExchangeSetRuntimeState {
mexset.RLock()
setState := ExchangeSetRuntimeState{
Name: mexset.name,
Count: len(mexset.exchanges),
}
if opts.IncludeExchanges {
setState.Exchanges = make(map[string]ExchangeRuntimeState, len(mexset.exch... | go | func (mexset *messageExchangeSet) IntrospectState(opts *IntrospectionOptions) ExchangeSetRuntimeState {
mexset.RLock()
setState := ExchangeSetRuntimeState{
Name: mexset.name,
Count: len(mexset.exchanges),
}
if opts.IncludeExchanges {
setState.Exchanges = make(map[string]ExchangeRuntimeState, len(mexset.exch... | [
"func",
"(",
"mexset",
"*",
"messageExchangeSet",
")",
"IntrospectState",
"(",
"opts",
"*",
"IntrospectionOptions",
")",
"ExchangeSetRuntimeState",
"{",
"mexset",
".",
"RLock",
"(",
")",
"\n",
"setState",
":=",
"ExchangeSetRuntimeState",
"{",
"Name",
":",
"mexset"... | // IntrospectState returns the runtime state for this messsage exchange set. | [
"IntrospectState",
"returns",
"the",
"runtime",
"state",
"for",
"this",
"messsage",
"exchange",
"set",
"."
] | 3c9ced6d946fe2fec6c915703a533e966c09e07a | https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/introspection.go#L413-L433 | test |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.