id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
28,000 | micro/go-plugins | broker/stomp/stomp.go | stompHeaderToMap | func stompHeaderToMap(h *frame.Header) map[string]string {
m := map[string]string{}
for i := 0; i < h.Len(); i++ {
k, v := h.GetAt(i)
m[k] = v
}
return m
} | go | func stompHeaderToMap(h *frame.Header) map[string]string {
m := map[string]string{}
for i := 0; i < h.Len(); i++ {
k, v := h.GetAt(i)
m[k] = v
}
return m
} | [
"func",
"stompHeaderToMap",
"(",
"h",
"*",
"frame",
".",
"Header",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"m",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"h",
".",
"Len",
"(",
")",
... | // stompHeaderToMap converts STOMP header to broker friendly header | [
"stompHeaderToMap",
"converts",
"STOMP",
"header",
"to",
"broker",
"friendly",
"header"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/broker/stomp/stomp.go#L29-L36 |
28,001 | micro/go-plugins | broker/stomp/stomp.go | defaults | func (r *rbroker) defaults() {
ConnectTimeout(30 * time.Second)(&r.opts)
VirtualHost("/")(&r.opts)
} | go | func (r *rbroker) defaults() {
ConnectTimeout(30 * time.Second)(&r.opts)
VirtualHost("/")(&r.opts)
} | [
"func",
"(",
"r",
"*",
"rbroker",
")",
"defaults",
"(",
")",
"{",
"ConnectTimeout",
"(",
"30",
"*",
"time",
".",
"Second",
")",
"(",
"&",
"r",
".",
"opts",
")",
"\n",
"VirtualHost",
"(",
"\"",
"\"",
")",
"(",
"&",
"r",
".",
"opts",
")",
"\n",
... | // defaults sets 'sane' STOMP default | [
"defaults",
"sets",
"sane",
"STOMP",
"default"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/broker/stomp/stomp.go#L39-L42 |
28,002 | micro/go-plugins | broker/stomp/stomp.go | NewBroker | func NewBroker(opts ...broker.Option) broker.Broker {
r := &rbroker{
opts: broker.Options{
Context: context.Background(),
},
}
r.Init(opts...)
return r
} | go | func NewBroker(opts ...broker.Option) broker.Broker {
r := &rbroker{
opts: broker.Options{
Context: context.Background(),
},
}
r.Init(opts...)
return r
} | [
"func",
"NewBroker",
"(",
"opts",
"...",
"broker",
".",
"Option",
")",
"broker",
".",
"Broker",
"{",
"r",
":=",
"&",
"rbroker",
"{",
"opts",
":",
"broker",
".",
"Options",
"{",
"Context",
":",
"context",
".",
"Background",
"(",
")",
",",
"}",
",",
... | // NewBroker returns a STOMP broker | [
"NewBroker",
"returns",
"a",
"STOMP",
"broker"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/broker/stomp/stomp.go#L236-L244 |
28,003 | micro/go-plugins | wrapper/trace/datadog/tracker.go | finishWithError | func (t *tracker) finishWithError(err error, noDebugStack bool) {
if t.span == nil {
return
}
statusCode := codes.OK
finishOptions := []tracer.FinishOption{
tracer.FinishTime(time.Now()),
}
microErr, ok := err.(*microerr.Error)
if ok {
finishOptions = append(finishOptions, tracer.WithError(
fmt.Error... | go | func (t *tracker) finishWithError(err error, noDebugStack bool) {
if t.span == nil {
return
}
statusCode := codes.OK
finishOptions := []tracer.FinishOption{
tracer.FinishTime(time.Now()),
}
microErr, ok := err.(*microerr.Error)
if ok {
finishOptions = append(finishOptions, tracer.WithError(
fmt.Error... | [
"func",
"(",
"t",
"*",
"tracker",
")",
"finishWithError",
"(",
"err",
"error",
",",
"noDebugStack",
"bool",
")",
"{",
"if",
"t",
".",
"span",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"statusCode",
":=",
"codes",
".",
"OK",
"\n",
"finishOptions",
... | // finishWithError end a request's monitoring session. If there is a span ongoing, it will
// be ended. | [
"finishWithError",
"end",
"a",
"request",
"s",
"monitoring",
"session",
".",
"If",
"there",
"is",
"a",
"span",
"ongoing",
"it",
"will",
"be",
"ended",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/wrapper/trace/datadog/tracker.go#L72-L105 |
28,004 | micro/go-plugins | client/grpc/options.go | AuthTLS | func AuthTLS(t *tls.Config) client.Option {
return func(o *client.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, tlsAuth{}, t)
}
} | go | func AuthTLS(t *tls.Config) client.Option {
return func(o *client.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, tlsAuth{}, t)
}
} | [
"func",
"AuthTLS",
"(",
"t",
"*",
"tls",
".",
"Config",
")",
"client",
".",
"Option",
"{",
"return",
"func",
"(",
"o",
"*",
"client",
".",
"Options",
")",
"{",
"if",
"o",
".",
"Context",
"==",
"nil",
"{",
"o",
".",
"Context",
"=",
"context",
".",... | // AuthTLS should be used to setup a secure authentication using TLS | [
"AuthTLS",
"should",
"be",
"used",
"to",
"setup",
"a",
"secure",
"authentication",
"using",
"TLS"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/client/grpc/options.go#L43-L50 |
28,005 | micro/go-plugins | client/grpc/options.go | MaxRecvMsgSize | func MaxRecvMsgSize(s int) client.Option {
return func(o *client.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, maxRecvMsgSizeKey{}, s)
}
} | go | func MaxRecvMsgSize(s int) client.Option {
return func(o *client.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, maxRecvMsgSizeKey{}, s)
}
} | [
"func",
"MaxRecvMsgSize",
"(",
"s",
"int",
")",
"client",
".",
"Option",
"{",
"return",
"func",
"(",
"o",
"*",
"client",
".",
"Options",
")",
"{",
"if",
"o",
".",
"Context",
"==",
"nil",
"{",
"o",
".",
"Context",
"=",
"context",
".",
"Background",
... | //
// MaxRecvMsgSize set the maximum size of message that client can receive.
// | [
"MaxRecvMsgSize",
"set",
"the",
"maximum",
"size",
"of",
"message",
"that",
"client",
"can",
"receive",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/client/grpc/options.go#L55-L62 |
28,006 | micro/go-plugins | client/grpc/options.go | MaxSendMsgSize | func MaxSendMsgSize(s int) client.Option {
return func(o *client.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, maxSendMsgSizeKey{}, s)
}
} | go | func MaxSendMsgSize(s int) client.Option {
return func(o *client.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, maxSendMsgSizeKey{}, s)
}
} | [
"func",
"MaxSendMsgSize",
"(",
"s",
"int",
")",
"client",
".",
"Option",
"{",
"return",
"func",
"(",
"o",
"*",
"client",
".",
"Options",
")",
"{",
"if",
"o",
".",
"Context",
"==",
"nil",
"{",
"o",
".",
"Context",
"=",
"context",
".",
"Background",
... | //
// MaxSendMsgSize set the maximum size of message that client can send.
// | [
"MaxSendMsgSize",
"set",
"the",
"maximum",
"size",
"of",
"message",
"that",
"client",
"can",
"send",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/client/grpc/options.go#L67-L74 |
28,007 | micro/go-plugins | broker/sqs/options.go | DeduplicationFunction | func DeduplicationFunction(dedup StringFromMessageFunc) broker.Option {
return func(o *broker.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, dedupFunctionKey{}, dedup)
}
} | go | func DeduplicationFunction(dedup StringFromMessageFunc) broker.Option {
return func(o *broker.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, dedupFunctionKey{}, dedup)
}
} | [
"func",
"DeduplicationFunction",
"(",
"dedup",
"StringFromMessageFunc",
")",
"broker",
".",
"Option",
"{",
"return",
"func",
"(",
"o",
"*",
"broker",
".",
"Options",
")",
"{",
"if",
"o",
".",
"Context",
"==",
"nil",
"{",
"o",
".",
"Context",
"=",
"contex... | // DeduplicationFunction sets the function used to create the deduplication string
// for a given message | [
"DeduplicationFunction",
"sets",
"the",
"function",
"used",
"to",
"create",
"the",
"deduplication",
"string",
"for",
"a",
"given",
"message"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/broker/sqs/options.go#L21-L28 |
28,008 | micro/go-plugins | broker/sqs/options.go | GroupIDFunction | func GroupIDFunction(groupfunc StringFromMessageFunc) broker.Option {
return func(o *broker.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, groupIdFunctionKey{}, groupfunc)
}
} | go | func GroupIDFunction(groupfunc StringFromMessageFunc) broker.Option {
return func(o *broker.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, groupIdFunctionKey{}, groupfunc)
}
} | [
"func",
"GroupIDFunction",
"(",
"groupfunc",
"StringFromMessageFunc",
")",
"broker",
".",
"Option",
"{",
"return",
"func",
"(",
"o",
"*",
"broker",
".",
"Options",
")",
"{",
"if",
"o",
".",
"Context",
"==",
"nil",
"{",
"o",
".",
"Context",
"=",
"context"... | // GroupIDFunction sets the function used to create the group ID string for a
// given message | [
"GroupIDFunction",
"sets",
"the",
"function",
"used",
"to",
"create",
"the",
"group",
"ID",
"string",
"for",
"a",
"given",
"message"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/broker/sqs/options.go#L32-L39 |
28,009 | micro/go-plugins | broker/sqs/options.go | MaxReceiveMessages | func MaxReceiveMessages(max int64) broker.SubscribeOption {
return func(o *broker.SubscribeOptions) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, maxMessagesKey{}, max)
}
} | go | func MaxReceiveMessages(max int64) broker.SubscribeOption {
return func(o *broker.SubscribeOptions) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, maxMessagesKey{}, max)
}
} | [
"func",
"MaxReceiveMessages",
"(",
"max",
"int64",
")",
"broker",
".",
"SubscribeOption",
"{",
"return",
"func",
"(",
"o",
"*",
"broker",
".",
"SubscribeOptions",
")",
"{",
"if",
"o",
".",
"Context",
"==",
"nil",
"{",
"o",
".",
"Context",
"=",
"context",... | // MaxReceiveMessages indicates how many messages a receive operation should pull
// during any single call | [
"MaxReceiveMessages",
"indicates",
"how",
"many",
"messages",
"a",
"receive",
"operation",
"should",
"pull",
"during",
"any",
"single",
"call"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/broker/sqs/options.go#L43-L50 |
28,010 | micro/go-plugins | broker/sqs/options.go | VisibilityTimeout | func VisibilityTimeout(seconds int64) broker.SubscribeOption {
return func(o *broker.SubscribeOptions) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, visiblityTimeoutKey{}, seconds)
}
} | go | func VisibilityTimeout(seconds int64) broker.SubscribeOption {
return func(o *broker.SubscribeOptions) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, visiblityTimeoutKey{}, seconds)
}
} | [
"func",
"VisibilityTimeout",
"(",
"seconds",
"int64",
")",
"broker",
".",
"SubscribeOption",
"{",
"return",
"func",
"(",
"o",
"*",
"broker",
".",
"SubscribeOptions",
")",
"{",
"if",
"o",
".",
"Context",
"==",
"nil",
"{",
"o",
".",
"Context",
"=",
"contex... | // VisibilityTimeout controls how long a message is hidden from other queue consumers
// before being put back. If a consumer does not delete the message, it will be put back
// even if it was "processed" | [
"VisibilityTimeout",
"controls",
"how",
"long",
"a",
"message",
"is",
"hidden",
"from",
"other",
"queue",
"consumers",
"before",
"being",
"put",
"back",
".",
"If",
"a",
"consumer",
"does",
"not",
"delete",
"the",
"message",
"it",
"will",
"be",
"put",
"back",... | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/broker/sqs/options.go#L55-L62 |
28,011 | micro/go-plugins | broker/sqs/options.go | WaitTimeSeconds | func WaitTimeSeconds(seconds int64) broker.SubscribeOption {
return func(o *broker.SubscribeOptions) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, waitTimeSecondsKey{}, seconds)
}
} | go | func WaitTimeSeconds(seconds int64) broker.SubscribeOption {
return func(o *broker.SubscribeOptions) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, waitTimeSecondsKey{}, seconds)
}
} | [
"func",
"WaitTimeSeconds",
"(",
"seconds",
"int64",
")",
"broker",
".",
"SubscribeOption",
"{",
"return",
"func",
"(",
"o",
"*",
"broker",
".",
"SubscribeOptions",
")",
"{",
"if",
"o",
".",
"Context",
"==",
"nil",
"{",
"o",
".",
"Context",
"=",
"context"... | // WaitTimeSeconds controls the length of long polling for available messages | [
"WaitTimeSeconds",
"controls",
"the",
"length",
"of",
"long",
"polling",
"for",
"available",
"messages"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/broker/sqs/options.go#L65-L72 |
28,012 | micro/go-plugins | broker/sqs/options.go | Client | func Client(c *sqs.SQS) broker.Option {
return func(o *broker.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, sqsClientKey{}, c)
}
} | go | func Client(c *sqs.SQS) broker.Option {
return func(o *broker.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, sqsClientKey{}, c)
}
} | [
"func",
"Client",
"(",
"c",
"*",
"sqs",
".",
"SQS",
")",
"broker",
".",
"Option",
"{",
"return",
"func",
"(",
"o",
"*",
"broker",
".",
"Options",
")",
"{",
"if",
"o",
".",
"Context",
"==",
"nil",
"{",
"o",
".",
"Context",
"=",
"context",
".",
"... | // Client receives an instantiated instance of an SQS client which is used instead of initialising a new client | [
"Client",
"receives",
"an",
"instantiated",
"instance",
"of",
"an",
"SQS",
"client",
"which",
"is",
"used",
"instead",
"of",
"initialising",
"a",
"new",
"client"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/broker/sqs/options.go#L75-L82 |
28,013 | micro/go-plugins | wrapper/ratelimiter/uber/uber.go | NewClientWrapper | func NewClientWrapper(rate int, opts ...ratelimit.Option) client.Wrapper {
r := ratelimit.New(rate, opts...)
return func(c client.Client) client.Client {
return &clientWrapper{r, c}
}
} | go | func NewClientWrapper(rate int, opts ...ratelimit.Option) client.Wrapper {
r := ratelimit.New(rate, opts...)
return func(c client.Client) client.Client {
return &clientWrapper{r, c}
}
} | [
"func",
"NewClientWrapper",
"(",
"rate",
"int",
",",
"opts",
"...",
"ratelimit",
".",
"Option",
")",
"client",
".",
"Wrapper",
"{",
"r",
":=",
"ratelimit",
".",
"New",
"(",
"rate",
",",
"opts",
"...",
")",
"\n\n",
"return",
"func",
"(",
"c",
"client",
... | // NewClientWrapper creates a blocking side rate limiter | [
"NewClientWrapper",
"creates",
"a",
"blocking",
"side",
"rate",
"limiter"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/wrapper/ratelimiter/uber/uber.go#L22-L28 |
28,014 | micro/go-plugins | wrapper/ratelimiter/uber/uber.go | NewHandlerWrapper | func NewHandlerWrapper(rate int, opts ...ratelimit.Option) server.HandlerWrapper {
r := ratelimit.New(rate, opts...)
return func(h server.HandlerFunc) server.HandlerFunc {
return func(ctx context.Context, req server.Request, rsp interface{}) error {
r.Take()
return h(ctx, req, rsp)
}
}
} | go | func NewHandlerWrapper(rate int, opts ...ratelimit.Option) server.HandlerWrapper {
r := ratelimit.New(rate, opts...)
return func(h server.HandlerFunc) server.HandlerFunc {
return func(ctx context.Context, req server.Request, rsp interface{}) error {
r.Take()
return h(ctx, req, rsp)
}
}
} | [
"func",
"NewHandlerWrapper",
"(",
"rate",
"int",
",",
"opts",
"...",
"ratelimit",
".",
"Option",
")",
"server",
".",
"HandlerWrapper",
"{",
"r",
":=",
"ratelimit",
".",
"New",
"(",
"rate",
",",
"opts",
"...",
")",
"\n\n",
"return",
"func",
"(",
"h",
"s... | // NewHandlerWrapper creates a blocking server side rate limiter | [
"NewHandlerWrapper",
"creates",
"a",
"blocking",
"server",
"side",
"rate",
"limiter"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/wrapper/ratelimiter/uber/uber.go#L31-L40 |
28,015 | micro/go-plugins | wrapper/select/roundrobin/roundrobin.go | NewClientWrapper | func NewClientWrapper() client.Wrapper {
return func(c client.Client) client.Client {
return &roundrobin{
rr: make(map[string]int),
Client: c,
}
}
} | go | func NewClientWrapper() client.Wrapper {
return func(c client.Client) client.Client {
return &roundrobin{
rr: make(map[string]int),
Client: c,
}
}
} | [
"func",
"NewClientWrapper",
"(",
")",
"client",
".",
"Wrapper",
"{",
"return",
"func",
"(",
"c",
"client",
".",
"Client",
")",
"client",
".",
"Client",
"{",
"return",
"&",
"roundrobin",
"{",
"rr",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"int",
"... | // NewClientWrapper is a wrapper which roundrobins requests | [
"NewClientWrapper",
"is",
"a",
"wrapper",
"which",
"roundrobins",
"requests"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/wrapper/select/roundrobin/roundrobin.go#L55-L62 |
28,016 | micro/go-plugins | micro/trace/awsxray/util.go | complete | func complete(s *awsxray.Segment, status int) {
switch {
case status >= 500:
s.Fault = true
case status >= 400:
s.Error = true
}
s.HTTP.Response.Status = status
s.EndTime = float64(time.Now().Truncate(time.Millisecond).UnixNano()) / 1e9
} | go | func complete(s *awsxray.Segment, status int) {
switch {
case status >= 500:
s.Fault = true
case status >= 400:
s.Error = true
}
s.HTTP.Response.Status = status
s.EndTime = float64(time.Now().Truncate(time.Millisecond).UnixNano()) / 1e9
} | [
"func",
"complete",
"(",
"s",
"*",
"awsxray",
".",
"Segment",
",",
"status",
"int",
")",
"{",
"switch",
"{",
"case",
"status",
">=",
"500",
":",
"s",
".",
"Fault",
"=",
"true",
"\n",
"case",
"status",
">=",
"400",
":",
"s",
".",
"Error",
"=",
"tr... | // complete sets the response status and end time | [
"complete",
"sets",
"the",
"response",
"status",
"and",
"end",
"time"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/micro/trace/awsxray/util.go#L15-L24 |
28,017 | micro/go-plugins | micro/trace/awsxray/util.go | getIp | func getIp(r *http.Request) string {
for _, h := range []string{"X-Forwarded-For", "X-Real-Ip"} {
for _, ip := range strings.Split(r.Header.Get(h), ",") {
if len(ip) == 0 {
continue
}
realIP := net.ParseIP(strings.Replace(ip, " ", "", -1))
return realIP.String()
}
}
// not found in header
host,... | go | func getIp(r *http.Request) string {
for _, h := range []string{"X-Forwarded-For", "X-Real-Ip"} {
for _, ip := range strings.Split(r.Header.Get(h), ",") {
if len(ip) == 0 {
continue
}
realIP := net.ParseIP(strings.Replace(ip, " ", "", -1))
return realIP.String()
}
}
// not found in header
host,... | [
"func",
"getIp",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"string",
"{",
"for",
"_",
",",
"h",
":=",
"range",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
"}",
"{",
"for",
"_",
",",
"ip",
":=",
"range",
"strings",
".",
"Split",
"(... | // getIp naively returns an ip for the request | [
"getIp",
"naively",
"returns",
"an",
"ip",
"for",
"the",
"request"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/micro/trace/awsxray/util.go#L27-L46 |
28,018 | micro/go-plugins | micro/trace/awsxray/util.go | newHTTP | func newHTTP(r *http.Request) *awsxray.HTTP {
scheme := "http"
host := r.Host
if len(r.URL.Scheme) > 0 {
scheme = r.URL.Scheme
}
if len(r.URL.Host) > 0 {
host = r.URL.Host
}
return &awsxray.HTTP{
Request: &awsxray.Request{
Method: r.Method,
URL: fmt.Sprintf("%s://%s%s", scheme, host, r.UR... | go | func newHTTP(r *http.Request) *awsxray.HTTP {
scheme := "http"
host := r.Host
if len(r.URL.Scheme) > 0 {
scheme = r.URL.Scheme
}
if len(r.URL.Host) > 0 {
host = r.URL.Host
}
return &awsxray.HTTP{
Request: &awsxray.Request{
Method: r.Method,
URL: fmt.Sprintf("%s://%s%s", scheme, host, r.UR... | [
"func",
"newHTTP",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"*",
"awsxray",
".",
"HTTP",
"{",
"scheme",
":=",
"\"",
"\"",
"\n",
"host",
":=",
"r",
".",
"Host",
"\n\n",
"if",
"len",
"(",
"r",
".",
"URL",
".",
"Scheme",
")",
">",
"0",
"{",
"... | // newHTTP returns a http struct | [
"newHTTP",
"returns",
"a",
"http",
"struct"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/micro/trace/awsxray/util.go#L81-L104 |
28,019 | micro/go-plugins | micro/trace/awsxray/util.go | newSegment | func newSegment(name string, r *http.Request) *awsxray.Segment {
// attempt to get IDs first
parentId := getParentId(r.Header)
traceId := getTraceId(r.Header)
// now set the trace ID
traceHdr := r.Header.Get(awsxray.TraceHeader)
traceHdr = awsxray.SetTraceId(traceHdr, traceId)
// create segment
s := &awsxray.... | go | func newSegment(name string, r *http.Request) *awsxray.Segment {
// attempt to get IDs first
parentId := getParentId(r.Header)
traceId := getTraceId(r.Header)
// now set the trace ID
traceHdr := r.Header.Get(awsxray.TraceHeader)
traceHdr = awsxray.SetTraceId(traceHdr, traceId)
// create segment
s := &awsxray.... | [
"func",
"newSegment",
"(",
"name",
"string",
",",
"r",
"*",
"http",
".",
"Request",
")",
"*",
"awsxray",
".",
"Segment",
"{",
"// attempt to get IDs first",
"parentId",
":=",
"getParentId",
"(",
"r",
".",
"Header",
")",
"\n",
"traceId",
":=",
"getTraceId",
... | // newSegment creates a new segment based on whether we're part of an existing flow | [
"newSegment",
"creates",
"a",
"new",
"segment",
"based",
"on",
"whether",
"we",
"re",
"part",
"of",
"an",
"existing",
"flow"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/micro/trace/awsxray/util.go#L107-L138 |
28,020 | micro/go-plugins | wrapper/breaker/gobreaker/gobreaker.go | NewClientWrapper | func NewClientWrapper() client.Wrapper {
return func(c client.Client) client.Client {
w := &clientWrapper{}
w.bs = gobreaker.Settings{}
w.cbs = make(map[string]*gobreaker.TwoStepCircuitBreaker)
w.Client = c
return w
}
} | go | func NewClientWrapper() client.Wrapper {
return func(c client.Client) client.Client {
w := &clientWrapper{}
w.bs = gobreaker.Settings{}
w.cbs = make(map[string]*gobreaker.TwoStepCircuitBreaker)
w.Client = c
return w
}
} | [
"func",
"NewClientWrapper",
"(",
")",
"client",
".",
"Wrapper",
"{",
"return",
"func",
"(",
"c",
"client",
".",
"Client",
")",
"client",
".",
"Client",
"{",
"w",
":=",
"&",
"clientWrapper",
"{",
"}",
"\n",
"w",
".",
"bs",
"=",
"gobreaker",
".",
"Sett... | // NewClientWrapper returns a client Wrapper. | [
"NewClientWrapper",
"returns",
"a",
"client",
"Wrapper",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/wrapper/breaker/gobreaker/gobreaker.go#L73-L81 |
28,021 | micro/go-plugins | wrapper/breaker/gobreaker/gobreaker.go | NewCustomClientWrapper | func NewCustomClientWrapper(bs gobreaker.Settings, bm BreakerMethod) client.Wrapper {
return func(c client.Client) client.Client {
w := &clientWrapper{}
w.bm = bm
w.bs = bs
w.cbs = make(map[string]*gobreaker.TwoStepCircuitBreaker)
w.Client = c
return w
}
} | go | func NewCustomClientWrapper(bs gobreaker.Settings, bm BreakerMethod) client.Wrapper {
return func(c client.Client) client.Client {
w := &clientWrapper{}
w.bm = bm
w.bs = bs
w.cbs = make(map[string]*gobreaker.TwoStepCircuitBreaker)
w.Client = c
return w
}
} | [
"func",
"NewCustomClientWrapper",
"(",
"bs",
"gobreaker",
".",
"Settings",
",",
"bm",
"BreakerMethod",
")",
"client",
".",
"Wrapper",
"{",
"return",
"func",
"(",
"c",
"client",
".",
"Client",
")",
"client",
".",
"Client",
"{",
"w",
":=",
"&",
"clientWrappe... | // NewCustomClientWrapper takes a gobreaker.Settings and BreakerMethod. Returns a client Wrapper. | [
"NewCustomClientWrapper",
"takes",
"a",
"gobreaker",
".",
"Settings",
"and",
"BreakerMethod",
".",
"Returns",
"a",
"client",
"Wrapper",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/wrapper/breaker/gobreaker/gobreaker.go#L84-L93 |
28,022 | micro/go-plugins | wrapper/trace/opencensus/opencensus.go | Call | func (w *clientWrapper) Call(
ctx context.Context,
req client.Request,
rsp interface{},
opts ...client.CallOption) (err error) {
t := newRequestTracker(req, ClientProfile)
ctx = t.start(ctx, true)
defer func() { t.end(ctx, err) }()
ctx = injectTraceIntoCtx(ctx, t.span)
err = w.Client.Call(ctx, req, rsp, opt... | go | func (w *clientWrapper) Call(
ctx context.Context,
req client.Request,
rsp interface{},
opts ...client.CallOption) (err error) {
t := newRequestTracker(req, ClientProfile)
ctx = t.start(ctx, true)
defer func() { t.end(ctx, err) }()
ctx = injectTraceIntoCtx(ctx, t.span)
err = w.Client.Call(ctx, req, rsp, opt... | [
"func",
"(",
"w",
"*",
"clientWrapper",
")",
"Call",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"client",
".",
"Request",
",",
"rsp",
"interface",
"{",
"}",
",",
"opts",
"...",
"client",
".",
"CallOption",
")",
"(",
"err",
"error",
")",
"{",
... | // Call implements client.Client.Call. | [
"Call",
"implements",
"client",
".",
"Client",
".",
"Call",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/wrapper/trace/opencensus/opencensus.go#L42-L56 |
28,023 | micro/go-plugins | wrapper/trace/opencensus/opencensus.go | Publish | func (w *clientWrapper) Publish(ctx context.Context, p client.Message, opts ...client.PublishOption) (err error) {
t := newPublicationTracker(p, ClientProfile)
ctx = t.start(ctx, true)
defer func() { t.end(ctx, err) }()
ctx = injectTraceIntoCtx(ctx, t.span)
err = w.Client.Publish(ctx, p, opts...)
return
} | go | func (w *clientWrapper) Publish(ctx context.Context, p client.Message, opts ...client.PublishOption) (err error) {
t := newPublicationTracker(p, ClientProfile)
ctx = t.start(ctx, true)
defer func() { t.end(ctx, err) }()
ctx = injectTraceIntoCtx(ctx, t.span)
err = w.Client.Publish(ctx, p, opts...)
return
} | [
"func",
"(",
"w",
"*",
"clientWrapper",
")",
"Publish",
"(",
"ctx",
"context",
".",
"Context",
",",
"p",
"client",
".",
"Message",
",",
"opts",
"...",
"client",
".",
"PublishOption",
")",
"(",
"err",
"error",
")",
"{",
"t",
":=",
"newPublicationTracker",... | // Publish implements client.Client.Publish. | [
"Publish",
"implements",
"client",
".",
"Client",
".",
"Publish",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/wrapper/trace/opencensus/opencensus.go#L59-L69 |
28,024 | micro/go-plugins | wrapper/trace/opencensus/opencensus.go | NewHandlerWrapper | func NewHandlerWrapper() server.HandlerWrapper {
return func(fn server.HandlerFunc) server.HandlerFunc {
return func(ctx context.Context, req server.Request, rsp interface{}) (err error) {
t := newRequestTracker(req, ServerProfile)
ctx = t.start(ctx, false)
defer func() { t.end(ctx, err) }()
spanCtx :=... | go | func NewHandlerWrapper() server.HandlerWrapper {
return func(fn server.HandlerFunc) server.HandlerFunc {
return func(ctx context.Context, req server.Request, rsp interface{}) (err error) {
t := newRequestTracker(req, ServerProfile)
ctx = t.start(ctx, false)
defer func() { t.end(ctx, err) }()
spanCtx :=... | [
"func",
"NewHandlerWrapper",
"(",
")",
"server",
".",
"HandlerWrapper",
"{",
"return",
"func",
"(",
"fn",
"server",
".",
"HandlerFunc",
")",
"server",
".",
"HandlerFunc",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"server",
"... | // NewHandlerWrapper returns a server.HandlerWrapper
// that adds tracing to incoming requests. | [
"NewHandlerWrapper",
"returns",
"a",
"server",
".",
"HandlerWrapper",
"that",
"adds",
"tracing",
"to",
"incoming",
"requests",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/wrapper/trace/opencensus/opencensus.go#L107-L133 |
28,025 | micro/go-plugins | wrapper/trace/opencensus/opencensus.go | NewSubscriberWrapper | func NewSubscriberWrapper() server.SubscriberWrapper {
return func(fn server.SubscriberFunc) server.SubscriberFunc {
return func(ctx context.Context, p server.Message) (err error) {
t := newPublicationTracker(p, ServerProfile)
ctx = t.start(ctx, false)
defer func() { t.end(ctx, err) }()
spanCtx := getT... | go | func NewSubscriberWrapper() server.SubscriberWrapper {
return func(fn server.SubscriberFunc) server.SubscriberFunc {
return func(ctx context.Context, p server.Message) (err error) {
t := newPublicationTracker(p, ServerProfile)
ctx = t.start(ctx, false)
defer func() { t.end(ctx, err) }()
spanCtx := getT... | [
"func",
"NewSubscriberWrapper",
"(",
")",
"server",
".",
"SubscriberWrapper",
"{",
"return",
"func",
"(",
"fn",
"server",
".",
"SubscriberFunc",
")",
"server",
".",
"SubscriberFunc",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"p",
"se... | // NewSubscriberWrapper returns a server.SubscriberWrapper
// that adds tracing to subscription requests. | [
"NewSubscriberWrapper",
"returns",
"a",
"server",
".",
"SubscriberWrapper",
"that",
"adds",
"tracing",
"to",
"subscription",
"requests",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/wrapper/trace/opencensus/opencensus.go#L137-L163 |
28,026 | micro/go-plugins | broker/googlepubsub/googlepubsub.go | Publish | func (b *pubsubBroker) Publish(topic string, msg *broker.Message, opts ...broker.PublishOption) error {
t := b.client.Topic(topic)
ctx := context.Background()
exists, err := t.Exists(ctx)
if err != nil {
return err
}
if !exists {
tt, err := b.client.CreateTopic(ctx, topic)
if err != nil {
return err
... | go | func (b *pubsubBroker) Publish(topic string, msg *broker.Message, opts ...broker.PublishOption) error {
t := b.client.Topic(topic)
ctx := context.Background()
exists, err := t.Exists(ctx)
if err != nil {
return err
}
if !exists {
tt, err := b.client.CreateTopic(ctx, topic)
if err != nil {
return err
... | [
"func",
"(",
"b",
"*",
"pubsubBroker",
")",
"Publish",
"(",
"topic",
"string",
",",
"msg",
"*",
"broker",
".",
"Message",
",",
"opts",
"...",
"broker",
".",
"PublishOption",
")",
"error",
"{",
"t",
":=",
"b",
".",
"client",
".",
"Topic",
"(",
"topic"... | // Publish checks if the topic exists and then publishes via google pubsub | [
"Publish",
"checks",
"if",
"the",
"topic",
"exists",
"and",
"then",
"publishes",
"via",
"google",
"pubsub"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/broker/googlepubsub/googlepubsub.go#L142-L168 |
28,027 | micro/go-plugins | broker/googlepubsub/googlepubsub.go | Subscribe | func (b *pubsubBroker) Subscribe(topic string, h broker.Handler, opts ...broker.SubscribeOption) (broker.Subscriber, error) {
options := broker.SubscribeOptions{
AutoAck: true,
Queue: "q-" + uuid.New().String(),
Context: b.options.Context,
}
for _, o := range opts {
o(&options)
}
ctx := context.Backgro... | go | func (b *pubsubBroker) Subscribe(topic string, h broker.Handler, opts ...broker.SubscribeOption) (broker.Subscriber, error) {
options := broker.SubscribeOptions{
AutoAck: true,
Queue: "q-" + uuid.New().String(),
Context: b.options.Context,
}
for _, o := range opts {
o(&options)
}
ctx := context.Backgro... | [
"func",
"(",
"b",
"*",
"pubsubBroker",
")",
"Subscribe",
"(",
"topic",
"string",
",",
"h",
"broker",
".",
"Handler",
",",
"opts",
"...",
"broker",
".",
"SubscribeOption",
")",
"(",
"broker",
".",
"Subscriber",
",",
"error",
")",
"{",
"options",
":=",
"... | // Subscribe registers a subscription to the given topic against the google pubsub api | [
"Subscribe",
"registers",
"a",
"subscription",
"to",
"the",
"given",
"topic",
"against",
"the",
"google",
"pubsub",
"api"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/broker/googlepubsub/googlepubsub.go#L171-L214 |
28,028 | micro/go-plugins | broker/googlepubsub/googlepubsub.go | NewBroker | func NewBroker(opts ...broker.Option) broker.Broker {
options := broker.Options{
Context: context.Background(),
}
for _, o := range opts {
o(&options)
}
// retrieve project id
prjID, _ := options.Context.Value(projectIDKey{}).(string)
// retrieve client opts
cOpts, _ := options.Context.Value(clientOptionK... | go | func NewBroker(opts ...broker.Option) broker.Broker {
options := broker.Options{
Context: context.Background(),
}
for _, o := range opts {
o(&options)
}
// retrieve project id
prjID, _ := options.Context.Value(projectIDKey{}).(string)
// retrieve client opts
cOpts, _ := options.Context.Value(clientOptionK... | [
"func",
"NewBroker",
"(",
"opts",
"...",
"broker",
".",
"Option",
")",
"broker",
".",
"Broker",
"{",
"options",
":=",
"broker",
".",
"Options",
"{",
"Context",
":",
"context",
".",
"Background",
"(",
")",
",",
"}",
"\n\n",
"for",
"_",
",",
"o",
":=",... | // NewBroker creates a new google pubsub broker | [
"NewBroker",
"creates",
"a",
"new",
"google",
"pubsub",
"broker"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/broker/googlepubsub/googlepubsub.go#L221-L245 |
28,029 | micro/go-plugins | server/grpc/options.go | Options | func Options(opts ...grpc.ServerOption) server.Option {
return func(o *server.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, grpcOptions{}, opts)
}
} | go | func Options(opts ...grpc.ServerOption) server.Option {
return func(o *server.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, grpcOptions{}, opts)
}
} | [
"func",
"Options",
"(",
"opts",
"...",
"grpc",
".",
"ServerOption",
")",
"server",
".",
"Option",
"{",
"return",
"func",
"(",
"o",
"*",
"server",
".",
"Options",
")",
"{",
"if",
"o",
".",
"Context",
"==",
"nil",
"{",
"o",
".",
"Context",
"=",
"cont... | // Options to be used to configure gRPC options | [
"Options",
"to",
"be",
"used",
"to",
"configure",
"gRPC",
"options"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/server/grpc/options.go#L48-L55 |
28,030 | micro/go-plugins | server/grpc/options.go | MaxMsgSize | func MaxMsgSize(s int) server.Option {
return func(o *server.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, maxMsgSizeKey{}, s)
}
} | go | func MaxMsgSize(s int) server.Option {
return func(o *server.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, maxMsgSizeKey{}, s)
}
} | [
"func",
"MaxMsgSize",
"(",
"s",
"int",
")",
"server",
".",
"Option",
"{",
"return",
"func",
"(",
"o",
"*",
"server",
".",
"Options",
")",
"{",
"if",
"o",
".",
"Context",
"==",
"nil",
"{",
"o",
".",
"Context",
"=",
"context",
".",
"Background",
"(",... | //
// MaxMsgSize set the maximum message in bytes the server can receive and
// send. Default maximum message size is 4 MB.
// | [
"MaxMsgSize",
"set",
"the",
"maximum",
"message",
"in",
"bytes",
"the",
"server",
"can",
"receive",
"and",
"send",
".",
"Default",
"maximum",
"message",
"size",
"is",
"4",
"MB",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/server/grpc/options.go#L61-L68 |
28,031 | micro/go-plugins | selector/shard/shard.go | NewSelector | func NewSelector(keys []string) selector.SelectOption {
return selector.WithStrategy(func(services []*registry.Service) selector.Next {
return Next(keys, services)
})
} | go | func NewSelector(keys []string) selector.SelectOption {
return selector.WithStrategy(func(services []*registry.Service) selector.Next {
return Next(keys, services)
})
} | [
"func",
"NewSelector",
"(",
"keys",
"[",
"]",
"string",
")",
"selector",
".",
"SelectOption",
"{",
"return",
"selector",
".",
"WithStrategy",
"(",
"func",
"(",
"services",
"[",
"]",
"*",
"registry",
".",
"Service",
")",
"selector",
".",
"Next",
"{",
"ret... | // NewSelector returns a `SelectOption` that directs all request according to the given `keys`. | [
"NewSelector",
"returns",
"a",
"SelectOption",
"that",
"directs",
"all",
"request",
"according",
"to",
"the",
"given",
"keys",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/selector/shard/shard.go#L27-L31 |
28,032 | micro/go-plugins | selector/shard/shard.go | Next | func Next(keys []string, services []*registry.Service) selector.Next {
possibleNodes, scores := ScoreNodes(keys, services)
return func() (*registry.Node, error) {
var best uint64
pos := -1
// Find the best scoring node from those available.
for i, score := range scores {
if score >= best && possibleNodes... | go | func Next(keys []string, services []*registry.Service) selector.Next {
possibleNodes, scores := ScoreNodes(keys, services)
return func() (*registry.Node, error) {
var best uint64
pos := -1
// Find the best scoring node from those available.
for i, score := range scores {
if score >= best && possibleNodes... | [
"func",
"Next",
"(",
"keys",
"[",
"]",
"string",
",",
"services",
"[",
"]",
"*",
"registry",
".",
"Service",
")",
"selector",
".",
"Next",
"{",
"possibleNodes",
",",
"scores",
":=",
"ScoreNodes",
"(",
"keys",
",",
"services",
")",
"\n\n",
"return",
"fu... | // Next returns a `Next` function which returns the next highest scoring node. | [
"Next",
"returns",
"a",
"Next",
"function",
"which",
"returns",
"the",
"next",
"highest",
"scoring",
"node",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/selector/shard/shard.go#L34-L60 |
28,033 | micro/go-plugins | selector/shard/shard.go | ScoreNodes | func ScoreNodes(keys []string, services []*registry.Service) (possibleNodes []*registry.Node, scores []uint64) {
// Generate a base hashing key based off the supplied keys values.
key := highwayhash.Sum([]byte(strings.Join(keys, ":")), zeroKey[:])
// Get all the possible nodes for the services, and assign a hash-ba... | go | func ScoreNodes(keys []string, services []*registry.Service) (possibleNodes []*registry.Node, scores []uint64) {
// Generate a base hashing key based off the supplied keys values.
key := highwayhash.Sum([]byte(strings.Join(keys, ":")), zeroKey[:])
// Get all the possible nodes for the services, and assign a hash-ba... | [
"func",
"ScoreNodes",
"(",
"keys",
"[",
"]",
"string",
",",
"services",
"[",
"]",
"*",
"registry",
".",
"Service",
")",
"(",
"possibleNodes",
"[",
"]",
"*",
"registry",
".",
"Node",
",",
"scores",
"[",
"]",
"uint64",
")",
"{",
"// Generate a base hashing... | // ScoreNodes returns a score for each node found in the given services. | [
"ScoreNodes",
"returns",
"a",
"score",
"for",
"each",
"node",
"found",
"in",
"the",
"given",
"services",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/selector/shard/shard.go#L63-L77 |
28,034 | micro/go-plugins | codec/msgpackrpc/codec.go | ReadHeader | func (c *msgpackCodec) ReadHeader(m *codec.Message, mt codec.MessageType) error {
c.mt = mt
switch mt {
case codec.Request:
var h Request
if err := msgp.Decode(c.rwc, &h); err != nil {
return err
}
c.body = h.hasBody
m.Id = h.ID
m.Endpoint = h.Method
case codec.Response:
var h Response
if er... | go | func (c *msgpackCodec) ReadHeader(m *codec.Message, mt codec.MessageType) error {
c.mt = mt
switch mt {
case codec.Request:
var h Request
if err := msgp.Decode(c.rwc, &h); err != nil {
return err
}
c.body = h.hasBody
m.Id = h.ID
m.Endpoint = h.Method
case codec.Response:
var h Response
if er... | [
"func",
"(",
"c",
"*",
"msgpackCodec",
")",
"ReadHeader",
"(",
"m",
"*",
"codec",
".",
"Message",
",",
"mt",
"codec",
".",
"MessageType",
")",
"error",
"{",
"c",
".",
"mt",
"=",
"mt",
"\n\n",
"switch",
"mt",
"{",
"case",
"codec",
".",
"Request",
":... | // ReadHeader reads the header from the wire. | [
"ReadHeader",
"reads",
"the",
"header",
"from",
"the",
"wire",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/codec/msgpackrpc/codec.go#L27-L68 |
28,035 | micro/go-plugins | codec/msgpackrpc/codec.go | ReadBody | func (c *msgpackCodec) ReadBody(v interface{}) error {
if !c.body {
return nil
}
r := msgp.NewReader(c.rwc)
// Body is present, but no value to decode into.
if v == nil {
return r.Skip()
}
switch c.mt {
case codec.Request, codec.Response, codec.Publication:
return decodeBody(r, v)
default:
return fm... | go | func (c *msgpackCodec) ReadBody(v interface{}) error {
if !c.body {
return nil
}
r := msgp.NewReader(c.rwc)
// Body is present, but no value to decode into.
if v == nil {
return r.Skip()
}
switch c.mt {
case codec.Request, codec.Response, codec.Publication:
return decodeBody(r, v)
default:
return fm... | [
"func",
"(",
"c",
"*",
"msgpackCodec",
")",
"ReadBody",
"(",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"!",
"c",
".",
"body",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"r",
":=",
"msgp",
".",
"NewReader",
"(",
"c",
".",
"rwc",
")",
"\... | // ReadBody reads the body of the message. It is assumed the value being
// decoded into is a satisfies the msgp.Decodable interface. | [
"ReadBody",
"reads",
"the",
"body",
"of",
"the",
"message",
".",
"It",
"is",
"assumed",
"the",
"value",
"being",
"decoded",
"into",
"is",
"a",
"satisfies",
"the",
"msgp",
".",
"Decodable",
"interface",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/codec/msgpackrpc/codec.go#L72-L90 |
28,036 | micro/go-plugins | codec/msgpackrpc/codec.go | Write | func (c *msgpackCodec) Write(m *codec.Message, b interface{}) error {
switch m.Type {
case codec.Request:
h := Request{
ID: m.Id,
Method: m.Endpoint,
Body: b,
}
return msgp.Encode(c.rwc, &h)
case codec.Response:
h := Response{
ID: m.Id,
Body: b,
}
h.Error = m.Error
return msg... | go | func (c *msgpackCodec) Write(m *codec.Message, b interface{}) error {
switch m.Type {
case codec.Request:
h := Request{
ID: m.Id,
Method: m.Endpoint,
Body: b,
}
return msgp.Encode(c.rwc, &h)
case codec.Response:
h := Response{
ID: m.Id,
Body: b,
}
h.Error = m.Error
return msg... | [
"func",
"(",
"c",
"*",
"msgpackCodec",
")",
"Write",
"(",
"m",
"*",
"codec",
".",
"Message",
",",
"b",
"interface",
"{",
"}",
")",
"error",
"{",
"switch",
"m",
".",
"Type",
"{",
"case",
"codec",
".",
"Request",
":",
"h",
":=",
"Request",
"{",
"ID... | // Write writes a message to the wire which contains the header followed by the body.
// The body is assumed to satisfy the msgp.Encodable interface. | [
"Write",
"writes",
"a",
"message",
"to",
"the",
"wire",
"which",
"contains",
"the",
"header",
"followed",
"by",
"the",
"body",
".",
"The",
"body",
"is",
"assumed",
"to",
"satisfy",
"the",
"msgp",
".",
"Encodable",
"interface",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/codec/msgpackrpc/codec.go#L94-L126 |
28,037 | micro/go-plugins | codec/jsonrpc2/errors.go | NewError | func NewError(code int, message string) *Error {
return &Error{Code: code, Message: message}
} | go | func NewError(code int, message string) *Error {
return &Error{Code: code, Message: message}
} | [
"func",
"NewError",
"(",
"code",
"int",
",",
"message",
"string",
")",
"*",
"Error",
"{",
"return",
"&",
"Error",
"{",
"Code",
":",
"code",
",",
"Message",
":",
"message",
"}",
"\n",
"}"
] | // NewError returns an Error with given code and message. | [
"NewError",
"returns",
"an",
"Error",
"with",
"given",
"code",
"and",
"message",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/codec/jsonrpc2/errors.go#L28-L30 |
28,038 | micro/go-plugins | codec/jsonrpc2/errors.go | newError | func newError(message string) *Error {
switch {
case strings.HasPrefix(message, "rpc: service/method request ill-formed"):
return NewError(errMethod.Code, message)
case strings.HasPrefix(message, "rpc: can't find service"):
return NewError(errMethod.Code, message)
case strings.HasPrefix(message, "rpc: can't fin... | go | func newError(message string) *Error {
switch {
case strings.HasPrefix(message, "rpc: service/method request ill-formed"):
return NewError(errMethod.Code, message)
case strings.HasPrefix(message, "rpc: can't find service"):
return NewError(errMethod.Code, message)
case strings.HasPrefix(message, "rpc: can't fin... | [
"func",
"newError",
"(",
"message",
"string",
")",
"*",
"Error",
"{",
"switch",
"{",
"case",
"strings",
".",
"HasPrefix",
"(",
"message",
",",
"\"",
"\"",
")",
":",
"return",
"NewError",
"(",
"errMethod",
".",
"Code",
",",
"message",
")",
"\n",
"case",... | // newError returns an Error with auto-detected code for given message. | [
"newError",
"returns",
"an",
"Error",
"with",
"auto",
"-",
"detected",
"code",
"for",
"given",
"message",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/codec/jsonrpc2/errors.go#L33-L44 |
28,039 | micro/go-plugins | codec/jsonrpc2/errors.go | Error | func (e *Error) Error() string {
buf, err := json.Marshal(e)
if err != nil {
msg, err := json.Marshal(err.Error())
if err != nil {
msg = []byte(`"` + errServerError.Message + `"`)
}
return fmt.Sprintf(`{"code":%d,"message":%s}`, errServerError.Code, string(msg))
}
return string(buf)
} | go | func (e *Error) Error() string {
buf, err := json.Marshal(e)
if err != nil {
msg, err := json.Marshal(err.Error())
if err != nil {
msg = []byte(`"` + errServerError.Message + `"`)
}
return fmt.Sprintf(`{"code":%d,"message":%s}`, errServerError.Code, string(msg))
}
return string(buf)
} | [
"func",
"(",
"e",
"*",
"Error",
")",
"Error",
"(",
")",
"string",
"{",
"buf",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"e",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"msg",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"err",
".",
"Err... | // Error returns JSON representation of Error. | [
"Error",
"returns",
"JSON",
"representation",
"of",
"Error",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/codec/jsonrpc2/errors.go#L82-L92 |
28,040 | micro/go-plugins | registry/kubernetes/kubernetes.go | serviceName | func serviceName(name string) string {
aname := make([]byte, len(name))
for i, r := range []byte(name) {
if !labelRe.Match([]byte{r}) {
aname[i] = '_'
continue
}
aname[i] = r
}
return string(aname)
} | go | func serviceName(name string) string {
aname := make([]byte, len(name))
for i, r := range []byte(name) {
if !labelRe.Match([]byte{r}) {
aname[i] = '_'
continue
}
aname[i] = r
}
return string(aname)
} | [
"func",
"serviceName",
"(",
"name",
"string",
")",
"string",
"{",
"aname",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"len",
"(",
"name",
")",
")",
"\n\n",
"for",
"i",
",",
"r",
":=",
"range",
"[",
"]",
"byte",
"(",
"name",
")",
"{",
"if",
"!",
... | // serviceName generates a valid service name for k8s labels | [
"serviceName",
"generates",
"a",
"valid",
"service",
"name",
"for",
"k8s",
"labels"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/registry/kubernetes/kubernetes.go#L84-L96 |
28,041 | micro/go-plugins | registry/kubernetes/kubernetes.go | Init | func (c *kregistry) Init(opts ...registry.Option) error {
return configure(c, opts...)
} | go | func (c *kregistry) Init(opts ...registry.Option) error {
return configure(c, opts...)
} | [
"func",
"(",
"c",
"*",
"kregistry",
")",
"Init",
"(",
"opts",
"...",
"registry",
".",
"Option",
")",
"error",
"{",
"return",
"configure",
"(",
"c",
",",
"opts",
"...",
")",
"\n",
"}"
] | // Init allows reconfig of options | [
"Init",
"allows",
"reconfig",
"of",
"options"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/registry/kubernetes/kubernetes.go#L99-L101 |
28,042 | micro/go-plugins | registry/kubernetes/kubernetes.go | Register | func (c *kregistry) Register(s *registry.Service, opts ...registry.RegisterOption) error {
if len(s.Nodes) == 0 {
return errors.New("you must register at least one node")
}
// TODO: grab podname from somewhere better than this.
podName := os.Getenv("HOSTNAME")
svcName := s.Name
// encode micro service
b, err... | go | func (c *kregistry) Register(s *registry.Service, opts ...registry.RegisterOption) error {
if len(s.Nodes) == 0 {
return errors.New("you must register at least one node")
}
// TODO: grab podname from somewhere better than this.
podName := os.Getenv("HOSTNAME")
svcName := s.Name
// encode micro service
b, err... | [
"func",
"(",
"c",
"*",
"kregistry",
")",
"Register",
"(",
"s",
"*",
"registry",
".",
"Service",
",",
"opts",
"...",
"registry",
".",
"RegisterOption",
")",
"error",
"{",
"if",
"len",
"(",
"s",
".",
"Nodes",
")",
"==",
"0",
"{",
"return",
"errors",
... | // Register sets a service selector label and an annotation with a
// serialised version of the service passed in. | [
"Register",
"sets",
"a",
"service",
"selector",
"label",
"and",
"an",
"annotation",
"with",
"a",
"serialised",
"version",
"of",
"the",
"service",
"passed",
"in",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/registry/kubernetes/kubernetes.go#L110-L144 |
28,043 | micro/go-plugins | registry/kubernetes/kubernetes.go | Deregister | func (c *kregistry) Deregister(s *registry.Service) error {
if len(s.Nodes) == 0 {
return errors.New("you must deregister at least one node")
}
// TODO: grab podname from somewhere better than this.
podName := os.Getenv("HOSTNAME")
svcName := s.Name
pod := &client.Pod{
Metadata: &client.Meta{
Labels: map... | go | func (c *kregistry) Deregister(s *registry.Service) error {
if len(s.Nodes) == 0 {
return errors.New("you must deregister at least one node")
}
// TODO: grab podname from somewhere better than this.
podName := os.Getenv("HOSTNAME")
svcName := s.Name
pod := &client.Pod{
Metadata: &client.Meta{
Labels: map... | [
"func",
"(",
"c",
"*",
"kregistry",
")",
"Deregister",
"(",
"s",
"*",
"registry",
".",
"Service",
")",
"error",
"{",
"if",
"len",
"(",
"s",
".",
"Nodes",
")",
"==",
"0",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\... | // Deregister nils out any things set in Register | [
"Deregister",
"nils",
"out",
"any",
"things",
"set",
"in",
"Register"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/registry/kubernetes/kubernetes.go#L147-L173 |
28,044 | micro/go-plugins | registry/kubernetes/kubernetes.go | GetService | func (c *kregistry) GetService(name string) ([]*registry.Service, error) {
pods, err := c.client.ListPods(map[string]string{
svcSelectorPrefix + serviceName(name): svcSelectorValue,
})
if err != nil {
return nil, err
}
if len(pods.Items) == 0 {
return nil, registry.ErrNotFound
}
// svcs mapped by version... | go | func (c *kregistry) GetService(name string) ([]*registry.Service, error) {
pods, err := c.client.ListPods(map[string]string{
svcSelectorPrefix + serviceName(name): svcSelectorValue,
})
if err != nil {
return nil, err
}
if len(pods.Items) == 0 {
return nil, registry.ErrNotFound
}
// svcs mapped by version... | [
"func",
"(",
"c",
"*",
"kregistry",
")",
"GetService",
"(",
"name",
"string",
")",
"(",
"[",
"]",
"*",
"registry",
".",
"Service",
",",
"error",
")",
"{",
"pods",
",",
"err",
":=",
"c",
".",
"client",
".",
"ListPods",
"(",
"map",
"[",
"string",
"... | // GetService will get all the pods with the given service selector,
// and build services from the annotations. | [
"GetService",
"will",
"get",
"all",
"the",
"pods",
"with",
"the",
"given",
"service",
"selector",
"and",
"build",
"services",
"from",
"the",
"annotations",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/registry/kubernetes/kubernetes.go#L177-L225 |
28,045 | micro/go-plugins | registry/kubernetes/kubernetes.go | ListServices | func (c *kregistry) ListServices() ([]*registry.Service, error) {
pods, err := c.client.ListPods(podSelector)
if err != nil {
return nil, err
}
// svcs mapped by name
svcs := make(map[string]bool)
for _, pod := range pods.Items {
if pod.Status.Phase != podRunning {
continue
}
for k, v := range pod.Me... | go | func (c *kregistry) ListServices() ([]*registry.Service, error) {
pods, err := c.client.ListPods(podSelector)
if err != nil {
return nil, err
}
// svcs mapped by name
svcs := make(map[string]bool)
for _, pod := range pods.Items {
if pod.Status.Phase != podRunning {
continue
}
for k, v := range pod.Me... | [
"func",
"(",
"c",
"*",
"kregistry",
")",
"ListServices",
"(",
")",
"(",
"[",
"]",
"*",
"registry",
".",
"Service",
",",
"error",
")",
"{",
"pods",
",",
"err",
":=",
"c",
".",
"client",
".",
"ListPods",
"(",
"podSelector",
")",
"\n",
"if",
"err",
... | // ListServices will list all the service names | [
"ListServices",
"will",
"list",
"all",
"the",
"service",
"names"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/registry/kubernetes/kubernetes.go#L228-L261 |
28,046 | micro/go-plugins | registry/kubernetes/kubernetes.go | Watch | func (c *kregistry) Watch(opts ...registry.WatchOption) (registry.Watcher, error) {
return newWatcher(c, opts...)
} | go | func (c *kregistry) Watch(opts ...registry.WatchOption) (registry.Watcher, error) {
return newWatcher(c, opts...)
} | [
"func",
"(",
"c",
"*",
"kregistry",
")",
"Watch",
"(",
"opts",
"...",
"registry",
".",
"WatchOption",
")",
"(",
"registry",
".",
"Watcher",
",",
"error",
")",
"{",
"return",
"newWatcher",
"(",
"c",
",",
"opts",
"...",
")",
"\n",
"}"
] | // Watch returns a kubernetes watcher | [
"Watch",
"returns",
"a",
"kubernetes",
"watcher"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/registry/kubernetes/kubernetes.go#L264-L266 |
28,047 | micro/go-plugins | registry/kubernetes/kubernetes.go | NewRegistry | func NewRegistry(opts ...registry.Option) registry.Registry {
k := &kregistry{
options: registry.Options{},
}
configure(k, opts...)
return k
} | go | func NewRegistry(opts ...registry.Option) registry.Registry {
k := &kregistry{
options: registry.Options{},
}
configure(k, opts...)
return k
} | [
"func",
"NewRegistry",
"(",
"opts",
"...",
"registry",
".",
"Option",
")",
"registry",
".",
"Registry",
"{",
"k",
":=",
"&",
"kregistry",
"{",
"options",
":",
"registry",
".",
"Options",
"{",
"}",
",",
"}",
"\n",
"configure",
"(",
"k",
",",
"opts",
"... | // NewRegistry creates a kubernetes registry | [
"NewRegistry",
"creates",
"a",
"kubernetes",
"registry"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/registry/kubernetes/kubernetes.go#L273-L279 |
28,048 | micro/go-plugins | micro/bot/input/discord/discord.go | CheckPrefixFactory | func CheckPrefixFactory(prefixes ...string) func(string) (string, bool) {
return func(content string) (string, bool) {
for _, prefix := range prefixes {
if strings.HasPrefix(content, prefix) {
return strings.TrimPrefix(content, prefix), true
}
}
return "", false
}
} | go | func CheckPrefixFactory(prefixes ...string) func(string) (string, bool) {
return func(content string) (string, bool) {
for _, prefix := range prefixes {
if strings.HasPrefix(content, prefix) {
return strings.TrimPrefix(content, prefix), true
}
}
return "", false
}
} | [
"func",
"CheckPrefixFactory",
"(",
"prefixes",
"...",
"string",
")",
"func",
"(",
"string",
")",
"(",
"string",
",",
"bool",
")",
"{",
"return",
"func",
"(",
"content",
"string",
")",
"(",
"string",
",",
"bool",
")",
"{",
"for",
"_",
",",
"prefix",
"... | // CheckPrefixFactory Creates a prefix checking function and stuff. | [
"CheckPrefixFactory",
"Creates",
"a",
"prefix",
"checking",
"function",
"and",
"stuff",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/micro/bot/input/discord/discord.go#L141-L150 |
28,049 | micro/go-plugins | registry/kubernetes/client/watch/body.go | Stop | func (wr *bodyWatcher) Stop() {
select {
case <-wr.stop:
return
default:
close(wr.stop)
close(wr.results)
}
} | go | func (wr *bodyWatcher) Stop() {
select {
case <-wr.stop:
return
default:
close(wr.stop)
close(wr.results)
}
} | [
"func",
"(",
"wr",
"*",
"bodyWatcher",
")",
"Stop",
"(",
")",
"{",
"select",
"{",
"case",
"<-",
"wr",
".",
"stop",
":",
"return",
"\n",
"default",
":",
"close",
"(",
"wr",
".",
"stop",
")",
"\n",
"close",
"(",
"wr",
".",
"results",
")",
"\n",
"... | // Stop cancels the request | [
"Stop",
"cancels",
"the",
"request"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/registry/kubernetes/client/watch/body.go#L24-L32 |
28,050 | micro/go-plugins | registry/kubernetes/client/watch/body.go | NewBodyWatcher | func NewBodyWatcher(req *http.Request, client *http.Client) (Watch, error) {
stop := make(chan struct{})
req.Cancel = stop
res, err := client.Do(req)
if err != nil {
return nil, err
}
wr := &bodyWatcher{
results: make(chan Event),
stop: stop,
req: req,
res: res,
}
go wr.stream()
return ... | go | func NewBodyWatcher(req *http.Request, client *http.Client) (Watch, error) {
stop := make(chan struct{})
req.Cancel = stop
res, err := client.Do(req)
if err != nil {
return nil, err
}
wr := &bodyWatcher{
results: make(chan Event),
stop: stop,
req: req,
res: res,
}
go wr.stream()
return ... | [
"func",
"NewBodyWatcher",
"(",
"req",
"*",
"http",
".",
"Request",
",",
"client",
"*",
"http",
".",
"Client",
")",
"(",
"Watch",
",",
"error",
")",
"{",
"stop",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n",
"req",
".",
"Cancel",
"=",
... | // NewBodyWatcher creates a k8s body watcher for
// a given http request | [
"NewBodyWatcher",
"creates",
"a",
"k8s",
"body",
"watcher",
"for",
"a",
"given",
"http",
"request"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/registry/kubernetes/client/watch/body.go#L74-L92 |
28,051 | micro/go-plugins | broker/gocloud/gocloud.go | NewBroker | func NewBroker(opts ...broker.Option) broker.Broker {
options := broker.Options{
Context: context.Background(),
}
for _, o := range opts {
o(&options)
}
var openTopic topicOpener
var openSub subOpener
var err error
if projID, ok := options.Context.Value(gcpProjectIDKey{}).(gcp.ProjectID); ok {
ts := opti... | go | func NewBroker(opts ...broker.Option) broker.Broker {
options := broker.Options{
Context: context.Background(),
}
for _, o := range opts {
o(&options)
}
var openTopic topicOpener
var openSub subOpener
var err error
if projID, ok := options.Context.Value(gcpProjectIDKey{}).(gcp.ProjectID); ok {
ts := opti... | [
"func",
"NewBroker",
"(",
"opts",
"...",
"broker",
".",
"Option",
")",
"broker",
".",
"Broker",
"{",
"options",
":=",
"broker",
".",
"Options",
"{",
"Context",
":",
"context",
".",
"Background",
"(",
")",
",",
"}",
"\n\n",
"for",
"_",
",",
"o",
":=",... | // NewBroker creates a new gocloud pubsubBroker.
// If the GCPProjectID option is set, Go Cloud uses its Google Cloud PubSub implementation.
// If the RabbitURL option is set, Go Cloud uses its RabbitMQ implementation.
// Otherwise, Go Cloud uses its in-memory implementation. | [
"NewBroker",
"creates",
"a",
"new",
"gocloud",
"pubsubBroker",
".",
"If",
"the",
"GCPProjectID",
"option",
"is",
"set",
"Go",
"Cloud",
"uses",
"its",
"Google",
"Cloud",
"PubSub",
"implementation",
".",
"If",
"the",
"RabbitURL",
"option",
"is",
"set",
"Go",
"... | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/broker/gocloud/gocloud.go#L47-L76 |
28,052 | micro/go-plugins | broker/gocloud/gocloud.go | Publish | func (b *pubsubBroker) Publish(topic string, msg *broker.Message, opts ...broker.PublishOption) error {
if b.err != nil {
return b.err
}
t := b.topic(topic)
return t.Send(context.Background(), &pubsub.Message{Metadata: msg.Header, Body: msg.Body})
} | go | func (b *pubsubBroker) Publish(topic string, msg *broker.Message, opts ...broker.PublishOption) error {
if b.err != nil {
return b.err
}
t := b.topic(topic)
return t.Send(context.Background(), &pubsub.Message{Metadata: msg.Header, Body: msg.Body})
} | [
"func",
"(",
"b",
"*",
"pubsubBroker",
")",
"Publish",
"(",
"topic",
"string",
",",
"msg",
"*",
"broker",
".",
"Message",
",",
"opts",
"...",
"broker",
".",
"PublishOption",
")",
"error",
"{",
"if",
"b",
".",
"err",
"!=",
"nil",
"{",
"return",
"b",
... | // Publish opens the topic if it hasn't been already, then publishes the message. | [
"Publish",
"opens",
"the",
"topic",
"if",
"it",
"hasn",
"t",
"been",
"already",
"then",
"publishes",
"the",
"message",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/broker/gocloud/gocloud.go#L131-L137 |
28,053 | micro/go-plugins | broker/gocloud/gocloud.go | topic | func (b *pubsubBroker) topic(name string) *pubsub.Topic {
b.mu.Lock()
defer b.mu.Unlock()
t := b.topics[name]
if t == nil {
t = b.openTopic(name)
b.topics[name] = t
}
return t
} | go | func (b *pubsubBroker) topic(name string) *pubsub.Topic {
b.mu.Lock()
defer b.mu.Unlock()
t := b.topics[name]
if t == nil {
t = b.openTopic(name)
b.topics[name] = t
}
return t
} | [
"func",
"(",
"b",
"*",
"pubsubBroker",
")",
"topic",
"(",
"name",
"string",
")",
"*",
"pubsub",
".",
"Topic",
"{",
"b",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"t",
":=",
"b",
".",
"topi... | // topic returns the topic with the given name if this broker has
// seen it before. Otherwise it opens a new topic. | [
"topic",
"returns",
"the",
"topic",
"with",
"the",
"given",
"name",
"if",
"this",
"broker",
"has",
"seen",
"it",
"before",
".",
"Otherwise",
"it",
"opens",
"a",
"new",
"topic",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/broker/gocloud/gocloud.go#L181-L190 |
28,054 | micro/go-plugins | wrapper/trace/opentracing/opentracing.go | NewClientWrapper | func NewClientWrapper(ot opentracing.Tracer) client.Wrapper {
return func(c client.Client) client.Client {
if ot == nil {
ot = opentracing.GlobalTracer()
}
return &otWrapper{ot, c}
}
} | go | func NewClientWrapper(ot opentracing.Tracer) client.Wrapper {
return func(c client.Client) client.Client {
if ot == nil {
ot = opentracing.GlobalTracer()
}
return &otWrapper{ot, c}
}
} | [
"func",
"NewClientWrapper",
"(",
"ot",
"opentracing",
".",
"Tracer",
")",
"client",
".",
"Wrapper",
"{",
"return",
"func",
"(",
"c",
"client",
".",
"Client",
")",
"client",
".",
"Client",
"{",
"if",
"ot",
"==",
"nil",
"{",
"ot",
"=",
"opentracing",
"."... | // NewClientWrapper accepts an open tracing Trace and returns a Client Wrapper | [
"NewClientWrapper",
"accepts",
"an",
"open",
"tracing",
"Trace",
"and",
"returns",
"a",
"Client",
"Wrapper"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/wrapper/trace/opentracing/opentracing.go#L74-L81 |
28,055 | micro/go-plugins | wrapper/trace/opentracing/opentracing.go | NewCallWrapper | func NewCallWrapper(ot opentracing.Tracer) client.CallWrapper {
return func(cf client.CallFunc) client.CallFunc {
return func(ctx context.Context, node *registry.Node, req client.Request, rsp interface{}, opts client.CallOptions) error {
if ot == nil {
ot = opentracing.GlobalTracer()
}
name := fmt.Sprin... | go | func NewCallWrapper(ot opentracing.Tracer) client.CallWrapper {
return func(cf client.CallFunc) client.CallFunc {
return func(ctx context.Context, node *registry.Node, req client.Request, rsp interface{}, opts client.CallOptions) error {
if ot == nil {
ot = opentracing.GlobalTracer()
}
name := fmt.Sprin... | [
"func",
"NewCallWrapper",
"(",
"ot",
"opentracing",
".",
"Tracer",
")",
"client",
".",
"CallWrapper",
"{",
"return",
"func",
"(",
"cf",
"client",
".",
"CallFunc",
")",
"client",
".",
"CallFunc",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",... | // NewCallWrapper accepts an opentracing Tracer and returns a Call Wrapper | [
"NewCallWrapper",
"accepts",
"an",
"opentracing",
"Tracer",
"and",
"returns",
"a",
"Call",
"Wrapper"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/wrapper/trace/opentracing/opentracing.go#L84-L99 |
28,056 | micro/go-plugins | wrapper/trace/opentracing/opentracing.go | NewHandlerWrapper | func NewHandlerWrapper(ot opentracing.Tracer) server.HandlerWrapper {
return func(h server.HandlerFunc) server.HandlerFunc {
return func(ctx context.Context, req server.Request, rsp interface{}) error {
if ot == nil {
ot = opentracing.GlobalTracer()
}
name := fmt.Sprintf("%s.%s", req.Service(), req.Endp... | go | func NewHandlerWrapper(ot opentracing.Tracer) server.HandlerWrapper {
return func(h server.HandlerFunc) server.HandlerFunc {
return func(ctx context.Context, req server.Request, rsp interface{}) error {
if ot == nil {
ot = opentracing.GlobalTracer()
}
name := fmt.Sprintf("%s.%s", req.Service(), req.Endp... | [
"func",
"NewHandlerWrapper",
"(",
"ot",
"opentracing",
".",
"Tracer",
")",
"server",
".",
"HandlerWrapper",
"{",
"return",
"func",
"(",
"h",
"server",
".",
"HandlerFunc",
")",
"server",
".",
"HandlerFunc",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
... | // NewHandlerWrapper accepts an opentracing Tracer and returns a Handler Wrapper | [
"NewHandlerWrapper",
"accepts",
"an",
"opentracing",
"Tracer",
"and",
"returns",
"a",
"Handler",
"Wrapper"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/wrapper/trace/opentracing/opentracing.go#L102-L117 |
28,057 | micro/go-plugins | wrapper/trace/opentracing/opentracing.go | NewSubscriberWrapper | func NewSubscriberWrapper(ot opentracing.Tracer) server.SubscriberWrapper {
return func(next server.SubscriberFunc) server.SubscriberFunc {
return func(ctx context.Context, msg server.Message) error {
name := "Pub to " + msg.Topic()
if ot == nil {
ot = opentracing.GlobalTracer()
}
ctx, span, err := S... | go | func NewSubscriberWrapper(ot opentracing.Tracer) server.SubscriberWrapper {
return func(next server.SubscriberFunc) server.SubscriberFunc {
return func(ctx context.Context, msg server.Message) error {
name := "Pub to " + msg.Topic()
if ot == nil {
ot = opentracing.GlobalTracer()
}
ctx, span, err := S... | [
"func",
"NewSubscriberWrapper",
"(",
"ot",
"opentracing",
".",
"Tracer",
")",
"server",
".",
"SubscriberWrapper",
"{",
"return",
"func",
"(",
"next",
"server",
".",
"SubscriberFunc",
")",
"server",
".",
"SubscriberFunc",
"{",
"return",
"func",
"(",
"ctx",
"con... | // NewSubscriberWrapper accepts an opentracing Tracer and returns a Subscriber Wrapper | [
"NewSubscriberWrapper",
"accepts",
"an",
"opentracing",
"Tracer",
"and",
"returns",
"a",
"Subscriber",
"Wrapper"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/wrapper/trace/opentracing/opentracing.go#L120-L135 |
28,058 | micro/go-plugins | wrapper/ratelimiter/ratelimit/ratelimit.go | NewClientWrapper | func NewClientWrapper(b *ratelimit.Bucket, wait bool) client.Wrapper {
fn := limit(b, wait, "go.micro.client")
return func(c client.Client) client.Client {
return &clientWrapper{fn, c}
}
} | go | func NewClientWrapper(b *ratelimit.Bucket, wait bool) client.Wrapper {
fn := limit(b, wait, "go.micro.client")
return func(c client.Client) client.Client {
return &clientWrapper{fn, c}
}
} | [
"func",
"NewClientWrapper",
"(",
"b",
"*",
"ratelimit",
".",
"Bucket",
",",
"wait",
"bool",
")",
"client",
".",
"Wrapper",
"{",
"fn",
":=",
"limit",
"(",
"b",
",",
"wait",
",",
"\"",
"\"",
")",
"\n\n",
"return",
"func",
"(",
"c",
"client",
".",
"Cl... | // NewClientWrapper takes a rate limiter and wait flag and returns a client Wrapper. | [
"NewClientWrapper",
"takes",
"a",
"rate",
"limiter",
"and",
"wait",
"flag",
"and",
"returns",
"a",
"client",
"Wrapper",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/wrapper/ratelimiter/ratelimit/ratelimit.go#L38-L44 |
28,059 | micro/go-plugins | wrapper/ratelimiter/ratelimit/ratelimit.go | NewHandlerWrapper | func NewHandlerWrapper(b *ratelimit.Bucket, wait bool) server.HandlerWrapper {
fn := limit(b, wait, "go.micro.server")
return func(h server.HandlerFunc) server.HandlerFunc {
return func(ctx context.Context, req server.Request, rsp interface{}) error {
if err := fn(); err != nil {
return err
}
return h... | go | func NewHandlerWrapper(b *ratelimit.Bucket, wait bool) server.HandlerWrapper {
fn := limit(b, wait, "go.micro.server")
return func(h server.HandlerFunc) server.HandlerFunc {
return func(ctx context.Context, req server.Request, rsp interface{}) error {
if err := fn(); err != nil {
return err
}
return h... | [
"func",
"NewHandlerWrapper",
"(",
"b",
"*",
"ratelimit",
".",
"Bucket",
",",
"wait",
"bool",
")",
"server",
".",
"HandlerWrapper",
"{",
"fn",
":=",
"limit",
"(",
"b",
",",
"wait",
",",
"\"",
"\"",
")",
"\n\n",
"return",
"func",
"(",
"h",
"server",
".... | // NewHandlerWrapper takes a rate limiter and wait flag and returns a client Wrapper. | [
"NewHandlerWrapper",
"takes",
"a",
"rate",
"limiter",
"and",
"wait",
"flag",
"and",
"returns",
"a",
"client",
"Wrapper",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/wrapper/ratelimiter/ratelimit/ratelimit.go#L47-L58 |
28,060 | micro/go-plugins | micro/trace/awsxray/options.go | WithClient | func WithClient(x *xray.XRay) Option {
return func(o *Options) {
o.Client = x
}
} | go | func WithClient(x *xray.XRay) Option {
return func(o *Options) {
o.Client = x
}
} | [
"func",
"WithClient",
"(",
"x",
"*",
"xray",
".",
"XRay",
")",
"Option",
"{",
"return",
"func",
"(",
"o",
"*",
"Options",
")",
"{",
"o",
".",
"Client",
"=",
"x",
"\n",
"}",
"\n",
"}"
] | // WithClient sets the XRay Client to use to send segments | [
"WithClient",
"sets",
"the",
"XRay",
"Client",
"to",
"use",
"to",
"send",
"segments"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/micro/trace/awsxray/options.go#L26-L30 |
28,061 | micro/go-plugins | wrapper/trace/opencensus/tracker.go | end | func (t *tracker) end(ctx context.Context, err error) {
status := getResponseStatus(err)
ctx, _ = tag.New(ctx, tag.Upsert(StatusCode, strconv.Itoa(int(status.Code))))
stats.Record(ctx, t.profile.LatencyMeasure.M(float64(time.Since(t.startedAt))/float64(time.Millisecond)))
if t.span != nil {
t.span.SetStatus(sta... | go | func (t *tracker) end(ctx context.Context, err error) {
status := getResponseStatus(err)
ctx, _ = tag.New(ctx, tag.Upsert(StatusCode, strconv.Itoa(int(status.Code))))
stats.Record(ctx, t.profile.LatencyMeasure.M(float64(time.Since(t.startedAt))/float64(time.Millisecond)))
if t.span != nil {
t.span.SetStatus(sta... | [
"func",
"(",
"t",
"*",
"tracker",
")",
"end",
"(",
"ctx",
"context",
".",
"Context",
",",
"err",
"error",
")",
"{",
"status",
":=",
"getResponseStatus",
"(",
"err",
")",
"\n\n",
"ctx",
",",
"_",
"=",
"tag",
".",
"New",
"(",
"ctx",
",",
"tag",
"."... | // end a request's monitoring session. If there is a span ongoing, it will
// be ended and metrics will be recorded. | [
"end",
"a",
"request",
"s",
"monitoring",
"session",
".",
"If",
"there",
"is",
"a",
"span",
"ongoing",
"it",
"will",
"be",
"ended",
"and",
"metrics",
"will",
"be",
"recorded",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/wrapper/trace/opencensus/tracker.go#L71-L81 |
28,062 | micro/go-plugins | registry/eureka/marshalling.go | serviceToInstance | func serviceToInstance(service *registry.Service) (*fargo.Instance, error) {
if len(service.Nodes) == 0 {
return nil, errors.New("Require nodes")
}
node := service.Nodes[0]
instance := &fargo.Instance{
App: service.Name,
HostName: node.Address,
IPAddr: node.Address,
VipAdd... | go | func serviceToInstance(service *registry.Service) (*fargo.Instance, error) {
if len(service.Nodes) == 0 {
return nil, errors.New("Require nodes")
}
node := service.Nodes[0]
instance := &fargo.Instance{
App: service.Name,
HostName: node.Address,
IPAddr: node.Address,
VipAdd... | [
"func",
"serviceToInstance",
"(",
"service",
"*",
"registry",
".",
"Service",
")",
"(",
"*",
"fargo",
".",
"Instance",
",",
"error",
")",
"{",
"if",
"len",
"(",
"service",
".",
"Nodes",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"errors",
".",
"New",... | // only parses first node | [
"only",
"parses",
"first",
"node"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/registry/eureka/marshalling.go#L74-L112 |
28,063 | micro/go-plugins | registry/kubernetes/watcher.go | updateCache | func (k *k8sWatcher) updateCache() ([]*registry.Result, error) {
podList, err := k.registry.client.ListPods(podSelector)
if err != nil {
return nil, err
}
k.RLock()
k.RUnlock()
var results []*registry.Result
for _, pod := range podList.Items {
rslts := k.buildPodResults(&pod, nil)
for _, r := range rsl... | go | func (k *k8sWatcher) updateCache() ([]*registry.Result, error) {
podList, err := k.registry.client.ListPods(podSelector)
if err != nil {
return nil, err
}
k.RLock()
k.RUnlock()
var results []*registry.Result
for _, pod := range podList.Items {
rslts := k.buildPodResults(&pod, nil)
for _, r := range rsl... | [
"func",
"(",
"k",
"*",
"k8sWatcher",
")",
"updateCache",
"(",
")",
"(",
"[",
"]",
"*",
"registry",
".",
"Result",
",",
"error",
")",
"{",
"podList",
",",
"err",
":=",
"k",
".",
"registry",
".",
"client",
".",
"ListPods",
"(",
"podSelector",
")",
"\... | // build a cache of pods when the watcher starts. | [
"build",
"a",
"cache",
"of",
"pods",
"when",
"the",
"watcher",
"starts",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/registry/kubernetes/watcher.go#L25-L49 |
28,064 | micro/go-plugins | registry/kubernetes/watcher.go | buildPodResults | func (k *k8sWatcher) buildPodResults(pod *client.Pod, cache *client.Pod) []*registry.Result {
var results []*registry.Result
ignore := make(map[string]bool)
if pod.Metadata != nil {
for ak, av := range pod.Metadata.Annotations {
// check this annotation kv is a service notation
if !strings.HasPrefix(ak, ann... | go | func (k *k8sWatcher) buildPodResults(pod *client.Pod, cache *client.Pod) []*registry.Result {
var results []*registry.Result
ignore := make(map[string]bool)
if pod.Metadata != nil {
for ak, av := range pod.Metadata.Annotations {
// check this annotation kv is a service notation
if !strings.HasPrefix(ak, ann... | [
"func",
"(",
"k",
"*",
"k8sWatcher",
")",
"buildPodResults",
"(",
"pod",
"*",
"client",
".",
"Pod",
",",
"cache",
"*",
"client",
".",
"Pod",
")",
"[",
"]",
"*",
"registry",
".",
"Result",
"{",
"var",
"results",
"[",
"]",
"*",
"registry",
".",
"Resu... | // look through pod annotations, compare against cache if present
// and return a list of results to send down the wire. | [
"look",
"through",
"pod",
"annotations",
"compare",
"against",
"cache",
"if",
"present",
"and",
"return",
"a",
"list",
"of",
"results",
"to",
"send",
"down",
"the",
"wire",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/registry/kubernetes/watcher.go#L53-L127 |
28,065 | micro/go-plugins | registry/kubernetes/watcher.go | handleEvent | func (k *k8sWatcher) handleEvent(event watch.Event) {
var pod client.Pod
if err := json.Unmarshal([]byte(event.Object), &pod); err != nil {
log.Log("K8s Watcher: Couldnt unmarshal event object from pod")
return
}
switch event.Type {
case watch.Modified:
// Pod was modified
k.RLock()
cache := k.pods[pod... | go | func (k *k8sWatcher) handleEvent(event watch.Event) {
var pod client.Pod
if err := json.Unmarshal([]byte(event.Object), &pod); err != nil {
log.Log("K8s Watcher: Couldnt unmarshal event object from pod")
return
}
switch event.Type {
case watch.Modified:
// Pod was modified
k.RLock()
cache := k.pods[pod... | [
"func",
"(",
"k",
"*",
"k8sWatcher",
")",
"handleEvent",
"(",
"event",
"watch",
".",
"Event",
")",
"{",
"var",
"pod",
"client",
".",
"Pod",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
"(",
"event",
".",
"Object",
")",
... | // handleEvent will taken an event from the k8s pods API and do the correct
// things with the result, based on the local cache. | [
"handleEvent",
"will",
"taken",
"an",
"event",
"from",
"the",
"k8s",
"pods",
"API",
"and",
"do",
"the",
"correct",
"things",
"with",
"the",
"result",
"based",
"on",
"the",
"local",
"cache",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/registry/kubernetes/watcher.go#L131-L185 |
28,066 | micro/go-plugins | registry/kubernetes/watcher.go | Next | func (k *k8sWatcher) Next() (*registry.Result, error) {
r, ok := <-k.next
if !ok {
return nil, errors.New("result chan closed")
}
return r, nil
} | go | func (k *k8sWatcher) Next() (*registry.Result, error) {
r, ok := <-k.next
if !ok {
return nil, errors.New("result chan closed")
}
return r, nil
} | [
"func",
"(",
"k",
"*",
"k8sWatcher",
")",
"Next",
"(",
")",
"(",
"*",
"registry",
".",
"Result",
",",
"error",
")",
"{",
"r",
",",
"ok",
":=",
"<-",
"k",
".",
"next",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"("... | // Next will block until a new result comes in | [
"Next",
"will",
"block",
"until",
"a",
"new",
"result",
"comes",
"in"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/registry/kubernetes/watcher.go#L188-L194 |
28,067 | micro/go-plugins | registry/kubernetes/watcher.go | Stop | func (k *k8sWatcher) Stop() {
k.watcher.Stop()
select {
case <-k.next:
return
default:
close(k.next)
}
} | go | func (k *k8sWatcher) Stop() {
k.watcher.Stop()
select {
case <-k.next:
return
default:
close(k.next)
}
} | [
"func",
"(",
"k",
"*",
"k8sWatcher",
")",
"Stop",
"(",
")",
"{",
"k",
".",
"watcher",
".",
"Stop",
"(",
")",
"\n\n",
"select",
"{",
"case",
"<-",
"k",
".",
"next",
":",
"return",
"\n",
"default",
":",
"close",
"(",
"k",
".",
"next",
")",
"\n",
... | // Stop will cancel any requests, and close channels | [
"Stop",
"will",
"cancel",
"any",
"requests",
"and",
"close",
"channels"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/registry/kubernetes/watcher.go#L197-L206 |
28,068 | micro/go-plugins | wrapper/trace/datadog/datadog.go | NewClientWrapper | func NewClientWrapper() client.Wrapper {
return func(c client.Client) client.Client {
return &ddWrapper{c}
}
} | go | func NewClientWrapper() client.Wrapper {
return func(c client.Client) client.Client {
return &ddWrapper{c}
}
} | [
"func",
"NewClientWrapper",
"(",
")",
"client",
".",
"Wrapper",
"{",
"return",
"func",
"(",
"c",
"client",
".",
"Client",
")",
"client",
".",
"Client",
"{",
"return",
"&",
"ddWrapper",
"{",
"c",
"}",
"\n",
"}",
"\n",
"}"
] | // NewClientWrapper returns a Client wrapped in tracer | [
"NewClientWrapper",
"returns",
"a",
"Client",
"wrapped",
"in",
"tracer"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/wrapper/trace/datadog/datadog.go#L49-L53 |
28,069 | micro/go-plugins | wrapper/trace/datadog/datadog.go | NewCallWrapper | func NewCallWrapper() client.CallWrapper {
return func(cf client.CallFunc) client.CallFunc {
return func(ctx context.Context, node *registry.Node, req client.Request, rsp interface{}, opts client.CallOptions) error {
t := newRequestTracker(req, ClientProfile)
ctx = t.StartSpanFromContext(ctx)
defer func() ... | go | func NewCallWrapper() client.CallWrapper {
return func(cf client.CallFunc) client.CallFunc {
return func(ctx context.Context, node *registry.Node, req client.Request, rsp interface{}, opts client.CallOptions) error {
t := newRequestTracker(req, ClientProfile)
ctx = t.StartSpanFromContext(ctx)
defer func() ... | [
"func",
"NewCallWrapper",
"(",
")",
"client",
".",
"CallWrapper",
"{",
"return",
"func",
"(",
"cf",
"client",
".",
"CallFunc",
")",
"client",
".",
"CallFunc",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"node",
"*",
"registry",
"."... | // NewCallWrapper returns a Call Wrapper | [
"NewCallWrapper",
"returns",
"a",
"Call",
"Wrapper"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/wrapper/trace/datadog/datadog.go#L56-L69 |
28,070 | micro/go-plugins | wrapper/trace/datadog/datadog.go | NewHandlerWrapper | func NewHandlerWrapper() server.HandlerWrapper {
return func(h server.HandlerFunc) server.HandlerFunc {
return func(ctx context.Context, req server.Request, rsp interface{}) (err error) {
if req.Endpoint() != "Debug.Health" {
t := newRequestTracker(req, ServerProfile)
ctx = t.StartSpanFromContext(ctx)
... | go | func NewHandlerWrapper() server.HandlerWrapper {
return func(h server.HandlerFunc) server.HandlerFunc {
return func(ctx context.Context, req server.Request, rsp interface{}) (err error) {
if req.Endpoint() != "Debug.Health" {
t := newRequestTracker(req, ServerProfile)
ctx = t.StartSpanFromContext(ctx)
... | [
"func",
"NewHandlerWrapper",
"(",
")",
"server",
".",
"HandlerWrapper",
"{",
"return",
"func",
"(",
"h",
"server",
".",
"HandlerFunc",
")",
"server",
".",
"HandlerFunc",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"server",
".... | // NewHandlerWrapper returns a Handler Wrapper | [
"NewHandlerWrapper",
"returns",
"a",
"Handler",
"Wrapper"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/wrapper/trace/datadog/datadog.go#L72-L88 |
28,071 | micro/go-plugins | wrapper/trace/datadog/datadog.go | NewSubscriberWrapper | func NewSubscriberWrapper() server.SubscriberWrapper {
return func(next server.SubscriberFunc) server.SubscriberFunc {
return func(ctx context.Context, msg server.Message) (err error) {
t := newPublicationTracker(msg, ServerProfile)
ctx = t.StartSpanFromContext(ctx)
defer func() {
t.finishWithError(err,... | go | func NewSubscriberWrapper() server.SubscriberWrapper {
return func(next server.SubscriberFunc) server.SubscriberFunc {
return func(ctx context.Context, msg server.Message) (err error) {
t := newPublicationTracker(msg, ServerProfile)
ctx = t.StartSpanFromContext(ctx)
defer func() {
t.finishWithError(err,... | [
"func",
"NewSubscriberWrapper",
"(",
")",
"server",
".",
"SubscriberWrapper",
"{",
"return",
"func",
"(",
"next",
"server",
".",
"SubscriberFunc",
")",
"server",
".",
"SubscriberFunc",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"msg",
... | // NewSubscriberWrapper returns a Subscriber Wrapper | [
"NewSubscriberWrapper",
"returns",
"a",
"Subscriber",
"Wrapper"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/wrapper/trace/datadog/datadog.go#L91-L104 |
28,072 | micro/go-plugins | registry/kubernetes/client/api/response.go | Into | func (r *Response) Into(data interface{}) error {
if r.err != nil {
return r.err
}
defer r.res.Body.Close()
decoder := json.NewDecoder(r.res.Body)
err := decoder.Decode(&data)
if err != nil {
return ErrDecode
}
return r.err
} | go | func (r *Response) Into(data interface{}) error {
if r.err != nil {
return r.err
}
defer r.res.Body.Close()
decoder := json.NewDecoder(r.res.Body)
err := decoder.Decode(&data)
if err != nil {
return ErrDecode
}
return r.err
} | [
"func",
"(",
"r",
"*",
"Response",
")",
"Into",
"(",
"data",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"r",
".",
"err",
"!=",
"nil",
"{",
"return",
"r",
".",
"err",
"\n",
"}",
"\n\n",
"defer",
"r",
".",
"res",
".",
"Body",
".",
"Close",
... | // Into decode body into `data` | [
"Into",
"decode",
"body",
"into",
"data"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/registry/kubernetes/client/api/response.go#L48-L61 |
28,073 | micro/go-plugins | registry/nats/options.go | Options | func Options(nopts nats.Options) registry.Option {
return func(o *registry.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, optionsKey{}, nopts)
}
} | go | func Options(nopts nats.Options) registry.Option {
return func(o *registry.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, optionsKey{}, nopts)
}
} | [
"func",
"Options",
"(",
"nopts",
"nats",
".",
"Options",
")",
"registry",
".",
"Option",
"{",
"return",
"func",
"(",
"o",
"*",
"registry",
".",
"Options",
")",
"{",
"if",
"o",
".",
"Context",
"==",
"nil",
"{",
"o",
".",
"Context",
"=",
"context",
"... | // Options allow to inject a nats.Options struct for configuring
// the nats connection | [
"Options",
"allow",
"to",
"inject",
"a",
"nats",
".",
"Options",
"struct",
"for",
"configuring",
"the",
"nats",
"connection"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/registry/nats/options.go#L40-L47 |
28,074 | micro/go-plugins | registry/kubernetes/client/client.go | NewClientByHost | func NewClientByHost(host string) Kubernetes {
tr := &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
DisableCompression: true,
}
c := &http.Client{
Transport: tr,
}
return &client{
opts: &api.Options{
Client: c,
Host: host,
Namespace: "default",
},
}
} | go | func NewClientByHost(host string) Kubernetes {
tr := &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
DisableCompression: true,
}
c := &http.Client{
Transport: tr,
}
return &client{
opts: &api.Options{
Client: c,
Host: host,
Namespace: "default",
},
}
} | [
"func",
"NewClientByHost",
"(",
"host",
"string",
")",
"Kubernetes",
"{",
"tr",
":=",
"&",
"http",
".",
"Transport",
"{",
"TLSClientConfig",
":",
"&",
"tls",
".",
"Config",
"{",
"InsecureSkipVerify",
":",
"true",
",",
"}",
",",
"DisableCompression",
":",
"... | // NewClientByHost sets up a client by host | [
"NewClientByHost",
"sets",
"up",
"a",
"client",
"by",
"host"
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/registry/kubernetes/client/client.go#L65-L84 |
28,075 | micro/go-plugins | registry/kubernetes/client/client.go | NewClientInCluster | func NewClientInCluster() Kubernetes {
host := "https://" + os.Getenv("KUBERNETES_SERVICE_HOST") + ":" + os.Getenv("KUBERNETES_SERVICE_PORT")
s, err := os.Stat(serviceAccountPath)
if err != nil {
log.Fatal(err)
}
if s == nil || !s.IsDir() {
log.Fatal(errors.New("no k8s service account found"))
}
token, err... | go | func NewClientInCluster() Kubernetes {
host := "https://" + os.Getenv("KUBERNETES_SERVICE_HOST") + ":" + os.Getenv("KUBERNETES_SERVICE_PORT")
s, err := os.Stat(serviceAccountPath)
if err != nil {
log.Fatal(err)
}
if s == nil || !s.IsDir() {
log.Fatal(errors.New("no k8s service account found"))
}
token, err... | [
"func",
"NewClientInCluster",
"(",
")",
"Kubernetes",
"{",
"host",
":=",
"\"",
"\"",
"+",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"+",
"\"",
"\"",
"+",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"\n\n",
"s",
",",
"err",
":=",
"os",
".",
"Sta... | // NewClientInCluster should work similarily to the official api
// NewInClient by setting up a client configuration for use within
// a k8s pod. | [
"NewClientInCluster",
"should",
"work",
"similarily",
"to",
"the",
"official",
"api",
"NewInClient",
"by",
"setting",
"up",
"a",
"client",
"configuration",
"for",
"use",
"within",
"a",
"k8s",
"pod",
"."
] | d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0 | https://github.com/micro/go-plugins/blob/d1cb339c5c5a3ab1e4be090c75a3cc03e38348e0/registry/kubernetes/client/client.go#L89-L133 |
28,076 | topfreegames/pitaya | examples/demo/cluster_grpc/services/room.go | Outbound | func (Stats *Stats) Outbound(ctx context.Context, in []byte) ([]byte, error) {
Stats.outboundBytes += len(in)
return in, nil
} | go | func (Stats *Stats) Outbound(ctx context.Context, in []byte) ([]byte, error) {
Stats.outboundBytes += len(in)
return in, nil
} | [
"func",
"(",
"Stats",
"*",
"Stats",
")",
"Outbound",
"(",
"ctx",
"context",
".",
"Context",
",",
"in",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"Stats",
".",
"outboundBytes",
"+=",
"len",
"(",
"in",
")",
"\n",
"return... | // Outbound gets the outbound status | [
"Outbound",
"gets",
"the",
"outbound",
"status"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/examples/demo/cluster_grpc/services/room.go#L64-L67 |
28,077 | topfreegames/pitaya | examples/demo/cluster_grpc/services/room.go | Inbound | func (Stats *Stats) Inbound(ctx context.Context, in []byte) ([]byte, error) {
Stats.inboundBytes += len(in)
return in, nil
} | go | func (Stats *Stats) Inbound(ctx context.Context, in []byte) ([]byte, error) {
Stats.inboundBytes += len(in)
return in, nil
} | [
"func",
"(",
"Stats",
"*",
"Stats",
")",
"Inbound",
"(",
"ctx",
"context",
".",
"Context",
",",
"in",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"Stats",
".",
"inboundBytes",
"+=",
"len",
"(",
"in",
")",
"\n",
"return",... | // Inbound gets the inbound status | [
"Inbound",
"gets",
"the",
"inbound",
"status"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/examples/demo/cluster_grpc/services/room.go#L70-L73 |
28,078 | topfreegames/pitaya | examples/demo/cluster_grpc/services/room.go | MessageRemote | func (r *Room) MessageRemote(ctx context.Context, msg *UserMessage, b bool, s string) (*UserMessage, error) {
return msg, nil
} | go | func (r *Room) MessageRemote(ctx context.Context, msg *UserMessage, b bool, s string) (*UserMessage, error) {
return msg, nil
} | [
"func",
"(",
"r",
"*",
"Room",
")",
"MessageRemote",
"(",
"ctx",
"context",
".",
"Context",
",",
"msg",
"*",
"UserMessage",
",",
"b",
"bool",
",",
"s",
"string",
")",
"(",
"*",
"UserMessage",
",",
"error",
")",
"{",
"return",
"msg",
",",
"nil",
"\n... | // MessageRemote just echoes the given message | [
"MessageRemote",
"just",
"echoes",
"the",
"given",
"message"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/examples/demo/cluster_grpc/services/room.go#L175-L177 |
28,079 | topfreegames/pitaya | session/mocks/session.go | NewMockNetworkEntity | func NewMockNetworkEntity(ctrl *gomock.Controller) *MockNetworkEntity {
mock := &MockNetworkEntity{ctrl: ctrl}
mock.recorder = &MockNetworkEntityMockRecorder{mock}
return mock
} | go | func NewMockNetworkEntity(ctrl *gomock.Controller) *MockNetworkEntity {
mock := &MockNetworkEntity{ctrl: ctrl}
mock.recorder = &MockNetworkEntityMockRecorder{mock}
return mock
} | [
"func",
"NewMockNetworkEntity",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockNetworkEntity",
"{",
"mock",
":=",
"&",
"MockNetworkEntity",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockNetworkEntityMockRecorder",
... | // NewMockNetworkEntity creates a new mock instance | [
"NewMockNetworkEntity",
"creates",
"a",
"new",
"mock",
"instance"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/mocks/session.go#L27-L31 |
28,080 | topfreegames/pitaya | session/mocks/session.go | Push | func (m *MockNetworkEntity) Push(route string, v interface{}) error {
ret := m.ctrl.Call(m, "Push", route, v)
ret0, _ := ret[0].(error)
return ret0
} | go | func (m *MockNetworkEntity) Push(route string, v interface{}) error {
ret := m.ctrl.Call(m, "Push", route, v)
ret0, _ := ret[0].(error)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockNetworkEntity",
")",
"Push",
"(",
"route",
"string",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"route",
",",
"v",
")",
"\n",
"ret0... | // Push mocks base method | [
"Push",
"mocks",
"base",
"method"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/mocks/session.go#L39-L43 |
28,081 | topfreegames/pitaya | session/mocks/session.go | Push | func (mr *MockNetworkEntityMockRecorder) Push(route, v interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Push", reflect.TypeOf((*MockNetworkEntity)(nil).Push), route, v)
} | go | func (mr *MockNetworkEntityMockRecorder) Push(route, v interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Push", reflect.TypeOf((*MockNetworkEntity)(nil).Push), route, v)
} | [
"func",
"(",
"mr",
"*",
"MockNetworkEntityMockRecorder",
")",
"Push",
"(",
"route",
",",
"v",
"interface",
"{",
"}",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".",
"mock",
... | // Push indicates an expected call of Push | [
"Push",
"indicates",
"an",
"expected",
"call",
"of",
"Push"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/mocks/session.go#L46-L48 |
28,082 | topfreegames/pitaya | session/mocks/session.go | ResponseMID | func (m *MockNetworkEntity) ResponseMID(ctx context.Context, mid uint, v interface{}, isError ...bool) error {
varargs := []interface{}{ctx, mid, v}
for _, a := range isError {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "ResponseMID", varargs...)
ret0, _ := ret[0].(error)
return ret0
} | go | func (m *MockNetworkEntity) ResponseMID(ctx context.Context, mid uint, v interface{}, isError ...bool) error {
varargs := []interface{}{ctx, mid, v}
for _, a := range isError {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "ResponseMID", varargs...)
ret0, _ := ret[0].(error)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockNetworkEntity",
")",
"ResponseMID",
"(",
"ctx",
"context",
".",
"Context",
",",
"mid",
"uint",
",",
"v",
"interface",
"{",
"}",
",",
"isError",
"...",
"bool",
")",
"error",
"{",
"varargs",
":=",
"[",
"]",
"interface",
"{",
... | // ResponseMID mocks base method | [
"ResponseMID",
"mocks",
"base",
"method"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/mocks/session.go#L51-L59 |
28,083 | topfreegames/pitaya | session/mocks/session.go | ResponseMID | func (mr *MockNetworkEntityMockRecorder) ResponseMID(ctx, mid, v interface{}, isError ...interface{}) *gomock.Call {
varargs := append([]interface{}{ctx, mid, v}, isError...)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ResponseMID", reflect.TypeOf((*MockNetworkEntity)(nil).ResponseMID), varargs...)
} | go | func (mr *MockNetworkEntityMockRecorder) ResponseMID(ctx, mid, v interface{}, isError ...interface{}) *gomock.Call {
varargs := append([]interface{}{ctx, mid, v}, isError...)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ResponseMID", reflect.TypeOf((*MockNetworkEntity)(nil).ResponseMID), varargs...)
} | [
"func",
"(",
"mr",
"*",
"MockNetworkEntityMockRecorder",
")",
"ResponseMID",
"(",
"ctx",
",",
"mid",
",",
"v",
"interface",
"{",
"}",
",",
"isError",
"...",
"interface",
"{",
"}",
")",
"*",
"gomock",
".",
"Call",
"{",
"varargs",
":=",
"append",
"(",
"[... | // ResponseMID indicates an expected call of ResponseMID | [
"ResponseMID",
"indicates",
"an",
"expected",
"call",
"of",
"ResponseMID"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/mocks/session.go#L62-L65 |
28,084 | topfreegames/pitaya | session/mocks/session.go | Kick | func (m *MockNetworkEntity) Kick(ctx context.Context) error {
ret := m.ctrl.Call(m, "Kick", ctx)
ret0, _ := ret[0].(error)
return ret0
} | go | func (m *MockNetworkEntity) Kick(ctx context.Context) error {
ret := m.ctrl.Call(m, "Kick", ctx)
ret0, _ := ret[0].(error)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockNetworkEntity",
")",
"Kick",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"ctx",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",... | // Kick mocks base method | [
"Kick",
"mocks",
"base",
"method"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/mocks/session.go#L80-L84 |
28,085 | topfreegames/pitaya | session/mocks/session.go | Kick | func (mr *MockNetworkEntityMockRecorder) Kick(ctx interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Kick", reflect.TypeOf((*MockNetworkEntity)(nil).Kick), ctx)
} | go | func (mr *MockNetworkEntityMockRecorder) Kick(ctx interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Kick", reflect.TypeOf((*MockNetworkEntity)(nil).Kick), ctx)
} | [
"func",
"(",
"mr",
"*",
"MockNetworkEntityMockRecorder",
")",
"Kick",
"(",
"ctx",
"interface",
"{",
"}",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".",
"mock",
",",
"\"",
... | // Kick indicates an expected call of Kick | [
"Kick",
"indicates",
"an",
"expected",
"call",
"of",
"Kick"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/mocks/session.go#L87-L89 |
28,086 | topfreegames/pitaya | session/mocks/session.go | RemoteAddr | func (mr *MockNetworkEntityMockRecorder) RemoteAddr() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoteAddr", reflect.TypeOf((*MockNetworkEntity)(nil).RemoteAddr))
} | go | func (mr *MockNetworkEntityMockRecorder) RemoteAddr() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoteAddr", reflect.TypeOf((*MockNetworkEntity)(nil).RemoteAddr))
} | [
"func",
"(",
"mr",
"*",
"MockNetworkEntityMockRecorder",
")",
"RemoteAddr",
"(",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".",
"mock",
",",
"\"",
"\"",
",",
"reflect",
"."... | // RemoteAddr indicates an expected call of RemoteAddr | [
"RemoteAddr",
"indicates",
"an",
"expected",
"call",
"of",
"RemoteAddr"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/mocks/session.go#L99-L101 |
28,087 | topfreegames/pitaya | session/mocks/session.go | SendRequest | func (m *MockNetworkEntity) SendRequest(ctx context.Context, serverID, route string, v interface{}) (*protos.Response, error) {
ret := m.ctrl.Call(m, "SendRequest", ctx, serverID, route, v)
ret0, _ := ret[0].(*protos.Response)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | func (m *MockNetworkEntity) SendRequest(ctx context.Context, serverID, route string, v interface{}) (*protos.Response, error) {
ret := m.ctrl.Call(m, "SendRequest", ctx, serverID, route, v)
ret0, _ := ret[0].(*protos.Response)
ret1, _ := ret[1].(error)
return ret0, ret1
} | [
"func",
"(",
"m",
"*",
"MockNetworkEntity",
")",
"SendRequest",
"(",
"ctx",
"context",
".",
"Context",
",",
"serverID",
",",
"route",
"string",
",",
"v",
"interface",
"{",
"}",
")",
"(",
"*",
"protos",
".",
"Response",
",",
"error",
")",
"{",
"ret",
... | // SendRequest mocks base method | [
"SendRequest",
"mocks",
"base",
"method"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/mocks/session.go#L104-L109 |
28,088 | topfreegames/pitaya | session/mocks/session.go | SendRequest | func (mr *MockNetworkEntityMockRecorder) SendRequest(ctx, serverID, route, v interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendRequest", reflect.TypeOf((*MockNetworkEntity)(nil).SendRequest), ctx, serverID, route, v)
} | go | func (mr *MockNetworkEntityMockRecorder) SendRequest(ctx, serverID, route, v interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendRequest", reflect.TypeOf((*MockNetworkEntity)(nil).SendRequest), ctx, serverID, route, v)
} | [
"func",
"(",
"mr",
"*",
"MockNetworkEntityMockRecorder",
")",
"SendRequest",
"(",
"ctx",
",",
"serverID",
",",
"route",
",",
"v",
"interface",
"{",
"}",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithM... | // SendRequest indicates an expected call of SendRequest | [
"SendRequest",
"indicates",
"an",
"expected",
"call",
"of",
"SendRequest"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/mocks/session.go#L112-L114 |
28,089 | topfreegames/pitaya | service/handler.go | NewHandlerService | func NewHandlerService(
dieChan chan bool,
packetDecoder codec.PacketDecoder,
packetEncoder codec.PacketEncoder,
serializer serialize.Serializer,
heartbeatTime time.Duration,
messagesBufferSize,
localProcessBufferSize,
remoteProcessBufferSize int,
server *cluster.Server,
remoteService *RemoteService,
message... | go | func NewHandlerService(
dieChan chan bool,
packetDecoder codec.PacketDecoder,
packetEncoder codec.PacketEncoder,
serializer serialize.Serializer,
heartbeatTime time.Duration,
messagesBufferSize,
localProcessBufferSize,
remoteProcessBufferSize int,
server *cluster.Server,
remoteService *RemoteService,
message... | [
"func",
"NewHandlerService",
"(",
"dieChan",
"chan",
"bool",
",",
"packetDecoder",
"codec",
".",
"PacketDecoder",
",",
"packetEncoder",
"codec",
".",
"PacketEncoder",
",",
"serializer",
"serialize",
".",
"Serializer",
",",
"heartbeatTime",
"time",
".",
"Duration",
... | // NewHandlerService creates and returns a new handler service | [
"NewHandlerService",
"creates",
"and",
"returns",
"a",
"new",
"handler",
"service"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/service/handler.go#L84-L115 |
28,090 | topfreegames/pitaya | service/handler.go | Dispatch | func (h *HandlerService) Dispatch(thread int) {
// TODO: This timer is being stopped multiple times, it probably doesn't need to be stopped here
defer timer.GlobalTicker.Stop()
for {
// Calls to remote servers block calls to local server
select {
case lm := <-h.chLocalProcess:
metrics.ReportMessageProcessD... | go | func (h *HandlerService) Dispatch(thread int) {
// TODO: This timer is being stopped multiple times, it probably doesn't need to be stopped here
defer timer.GlobalTicker.Stop()
for {
// Calls to remote servers block calls to local server
select {
case lm := <-h.chLocalProcess:
metrics.ReportMessageProcessD... | [
"func",
"(",
"h",
"*",
"HandlerService",
")",
"Dispatch",
"(",
"thread",
"int",
")",
"{",
"// TODO: This timer is being stopped multiple times, it probably doesn't need to be stopped here",
"defer",
"timer",
".",
"GlobalTicker",
".",
"Stop",
"(",
")",
"\n\n",
"for",
"{"... | // Dispatch message to corresponding logic handler | [
"Dispatch",
"message",
"to",
"corresponding",
"logic",
"handler"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/service/handler.go#L118-L143 |
28,091 | topfreegames/pitaya | service/handler.go | Handle | func (h *HandlerService) Handle(conn net.Conn) {
// create a client agent and startup write goroutine
a := agent.NewAgent(conn, h.decoder, h.encoder, h.serializer, h.heartbeatTimeout, h.messagesBufferSize, h.appDieChan, h.messageEncoder, h.metricsReporters)
// startup agent goroutine
go a.Handle()
logger.Log.Deb... | go | func (h *HandlerService) Handle(conn net.Conn) {
// create a client agent and startup write goroutine
a := agent.NewAgent(conn, h.decoder, h.encoder, h.serializer, h.heartbeatTimeout, h.messagesBufferSize, h.appDieChan, h.messageEncoder, h.metricsReporters)
// startup agent goroutine
go a.Handle()
logger.Log.Deb... | [
"func",
"(",
"h",
"*",
"HandlerService",
")",
"Handle",
"(",
"conn",
"net",
".",
"Conn",
")",
"{",
"// create a client agent and startup write goroutine",
"a",
":=",
"agent",
".",
"NewAgent",
"(",
"conn",
",",
"h",
".",
"decoder",
",",
"h",
".",
"encoder",
... | // Handle handles messages from a conn | [
"Handle",
"handles",
"messages",
"from",
"a",
"conn"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/service/handler.go#L166-L212 |
28,092 | topfreegames/pitaya | service/handler.go | DumpServices | func (h *HandlerService) DumpServices() {
for name := range handlers {
logger.Log.Infof("registered handler %s, isRawArg: %s", name, handlers[name].IsRawArg)
}
} | go | func (h *HandlerService) DumpServices() {
for name := range handlers {
logger.Log.Infof("registered handler %s, isRawArg: %s", name, handlers[name].IsRawArg)
}
} | [
"func",
"(",
"h",
"*",
"HandlerService",
")",
"DumpServices",
"(",
")",
"{",
"for",
"name",
":=",
"range",
"handlers",
"{",
"logger",
".",
"Log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"name",
",",
"handlers",
"[",
"name",
"]",
".",
"IsRawArg",
")",
"... | // DumpServices outputs all registered services | [
"DumpServices",
"outputs",
"all",
"registered",
"services"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/service/handler.go#L332-L336 |
28,093 | topfreegames/pitaya | service/handler.go | Docs | func (h *HandlerService) Docs(getPtrNames bool) (map[string]interface{}, error) {
if h == nil {
return map[string]interface{}{}, nil
}
return docgenerator.HandlersDocs(h.server.Type, h.services, getPtrNames)
} | go | func (h *HandlerService) Docs(getPtrNames bool) (map[string]interface{}, error) {
if h == nil {
return map[string]interface{}{}, nil
}
return docgenerator.HandlersDocs(h.server.Type, h.services, getPtrNames)
} | [
"func",
"(",
"h",
"*",
"HandlerService",
")",
"Docs",
"(",
"getPtrNames",
"bool",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
"h",
"==",
"nil",
"{",
"return",
"map",
"[",
"string",
"]",
"interface",
"{"... | // Docs returns documentation for handlers | [
"Docs",
"returns",
"documentation",
"for",
"handlers"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/service/handler.go#L339-L344 |
28,094 | topfreegames/pitaya | worker/worker.go | EnqueueRPC | func (w *Worker) EnqueueRPC(
routeStr string,
metadata map[string]interface{},
reply, arg proto.Message,
) (jid string, err error) {
opts := w.enqueueOptions(w.opts)
return workers.EnqueueWithOptions(rpcQueue, class, &rpcInfo{
Route: routeStr,
Metadata: metadata,
Arg: arg,
Reply: reply,
}, opts... | go | func (w *Worker) EnqueueRPC(
routeStr string,
metadata map[string]interface{},
reply, arg proto.Message,
) (jid string, err error) {
opts := w.enqueueOptions(w.opts)
return workers.EnqueueWithOptions(rpcQueue, class, &rpcInfo{
Route: routeStr,
Metadata: metadata,
Arg: arg,
Reply: reply,
}, opts... | [
"func",
"(",
"w",
"*",
"Worker",
")",
"EnqueueRPC",
"(",
"routeStr",
"string",
",",
"metadata",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"reply",
",",
"arg",
"proto",
".",
"Message",
",",
")",
"(",
"jid",
"string",
",",
"err",
"error",
... | // EnqueueRPC enqueues rpc job to worker | [
"EnqueueRPC",
"enqueues",
"rpc",
"job",
"to",
"worker"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/worker/worker.go#L83-L95 |
28,095 | topfreegames/pitaya | worker/worker.go | RegisterRPCJob | func (w *Worker) RegisterRPCJob(rpcJob RPCJob) error {
if w.registered {
return constants.ErrRPCJobAlreadyRegistered
}
job := w.parsedRPCJob(rpcJob)
workers.Process(rpcQueue, job, w.concurrency)
w.registered = true
return nil
} | go | func (w *Worker) RegisterRPCJob(rpcJob RPCJob) error {
if w.registered {
return constants.ErrRPCJobAlreadyRegistered
}
job := w.parsedRPCJob(rpcJob)
workers.Process(rpcQueue, job, w.concurrency)
w.registered = true
return nil
} | [
"func",
"(",
"w",
"*",
"Worker",
")",
"RegisterRPCJob",
"(",
"rpcJob",
"RPCJob",
")",
"error",
"{",
"if",
"w",
".",
"registered",
"{",
"return",
"constants",
".",
"ErrRPCJobAlreadyRegistered",
"\n",
"}",
"\n\n",
"job",
":=",
"w",
".",
"parsedRPCJob",
"(",
... | // RegisterRPCJob registers a RPC job | [
"RegisterRPCJob",
"registers",
"a",
"RPC",
"job"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/worker/worker.go#L113-L122 |
28,096 | topfreegames/pitaya | kick.go | SendKickToUsers | func SendKickToUsers(uids []string, frontendType string) ([]string, error) {
if !app.server.Frontend && frontendType == "" {
return uids, constants.ErrFrontendTypeNotSpecified
}
var notKickedUids []string
for _, uid := range uids {
if s := session.GetSessionByUID(uid); s != nil {
if err := s.Kick(context.B... | go | func SendKickToUsers(uids []string, frontendType string) ([]string, error) {
if !app.server.Frontend && frontendType == "" {
return uids, constants.ErrFrontendTypeNotSpecified
}
var notKickedUids []string
for _, uid := range uids {
if s := session.GetSessionByUID(uid); s != nil {
if err := s.Kick(context.B... | [
"func",
"SendKickToUsers",
"(",
"uids",
"[",
"]",
"string",
",",
"frontendType",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"if",
"!",
"app",
".",
"server",
".",
"Frontend",
"&&",
"frontendType",
"==",
"\"",
"\"",
"{",
"return",
... | // SendKickToUsers sends kick to an user array | [
"SendKickToUsers",
"sends",
"kick",
"to",
"an",
"user",
"array"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/kick.go#L33-L63 |
28,097 | topfreegames/pitaya | client/protoclient.go | unpackDescriptor | func unpackDescriptor(compressedDescriptor []byte) (*protobuf.FileDescriptorProto, error) {
r, err := gzip.NewReader(bytes.NewReader(compressedDescriptor))
if err != nil {
return nil, err
}
defer r.Close()
b, err := ioutil.ReadAll(r)
if err != nil {
return nil, err
}
var fileDescriptorProto protobuf.FileD... | go | func unpackDescriptor(compressedDescriptor []byte) (*protobuf.FileDescriptorProto, error) {
r, err := gzip.NewReader(bytes.NewReader(compressedDescriptor))
if err != nil {
return nil, err
}
defer r.Close()
b, err := ioutil.ReadAll(r)
if err != nil {
return nil, err
}
var fileDescriptorProto protobuf.FileD... | [
"func",
"unpackDescriptor",
"(",
"compressedDescriptor",
"[",
"]",
"byte",
")",
"(",
"*",
"protobuf",
".",
"FileDescriptorProto",
",",
"error",
")",
"{",
"r",
",",
"err",
":=",
"gzip",
".",
"NewReader",
"(",
"bytes",
".",
"NewReader",
"(",
"compressedDescrip... | // Receive a compressed byte slice and unpack it to a FileDescriptorProto | [
"Receive",
"a",
"compressed",
"byte",
"slice",
"and",
"unpack",
"it",
"to",
"a",
"FileDescriptorProto"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/client/protoclient.go#L75-L94 |
28,098 | topfreegames/pitaya | client/protoclient.go | buildProtosFromDescriptor | func (pc *ProtoClient) buildProtosFromDescriptor(descriptorArray []*protobuf.FileDescriptorProto) error {
descriptorsMap := make(map[string]*desc.MessageDescriptor)
descriptors, err := desc.CreateFileDescriptors(descriptorArray)
if err != nil {
return err
}
for name := range pc.descriptorsNames {
for _, v :... | go | func (pc *ProtoClient) buildProtosFromDescriptor(descriptorArray []*protobuf.FileDescriptorProto) error {
descriptorsMap := make(map[string]*desc.MessageDescriptor)
descriptors, err := desc.CreateFileDescriptors(descriptorArray)
if err != nil {
return err
}
for name := range pc.descriptorsNames {
for _, v :... | [
"func",
"(",
"pc",
"*",
"ProtoClient",
")",
"buildProtosFromDescriptor",
"(",
"descriptorArray",
"[",
"]",
"*",
"protobuf",
".",
"FileDescriptorProto",
")",
"error",
"{",
"descriptorsMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"desc",
".",
"Mess... | // Receive an array of descriptors in binary format. The function creates the
// protobuffer from this data and associates it to the message. | [
"Receive",
"an",
"array",
"of",
"descriptors",
"in",
"binary",
"format",
".",
"The",
"function",
"creates",
"the",
"protobuffer",
"from",
"this",
"data",
"and",
"associates",
"it",
"to",
"the",
"message",
"."
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/client/protoclient.go#L98-L126 |
28,099 | topfreegames/pitaya | client/protoclient.go | getOutputInputNames | func getOutputInputNames(command map[string]interface{}) (string, string, error) {
outputName := ""
inputName := ""
in := command["input"]
inputDocs, ok := in.(map[string]interface{})
if ok {
for k := range inputDocs {
if strings.Contains(k, "proto") {
inputName = strings.Replace(k, "*", "", 1)
}
}
... | go | func getOutputInputNames(command map[string]interface{}) (string, string, error) {
outputName := ""
inputName := ""
in := command["input"]
inputDocs, ok := in.(map[string]interface{})
if ok {
for k := range inputDocs {
if strings.Contains(k, "proto") {
inputName = strings.Replace(k, "*", "", 1)
}
}
... | [
"func",
"getOutputInputNames",
"(",
"command",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"string",
",",
"string",
",",
"error",
")",
"{",
"outputName",
":=",
"\"",
"\"",
"\n",
"inputName",
":=",
"\"",
"\"",
"\n\n",
"in",
":=",
"comman... | // Receives each entry from the Unmarshal json from the Docs and read the inputs and
// outputs associated with it. Return the output type, the input and the error. | [
"Receives",
"each",
"entry",
"from",
"the",
"Unmarshal",
"json",
"from",
"the",
"Docs",
"and",
"read",
"the",
"inputs",
"and",
"outputs",
"associated",
"with",
"it",
".",
"Return",
"the",
"output",
"type",
"the",
"input",
"and",
"the",
"error",
"."
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/client/protoclient.go#L130-L156 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.