id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c28000
{ k, v := h.GetAt(i) m[k] = v } return m }
c28001
* time.Second)(&r.opts) VirtualHost("/")(&r.opts) }
c28002
opts: broker.Options{ Context: context.Background(), }, } r.Init(opts...) return r }
c28003
statusCode = codes.Unknown } } t.span.SetTag(tagStatus, statusCode.String()) if noDebugStack { finishOptions = append(finishOptions, tracer.NoDebugStack()) } t.span.Finish(finishOptions...) t.span = nil }
c28004
context.Background() } o.Context = context.WithValue(o.Context, tlsAuth{}, t) } }
c28005
} o.Context = context.WithValue(o.Context, maxRecvMsgSizeKey{}, s) } }
c28006
} o.Context = context.WithValue(o.Context, maxSendMsgSizeKey{}, s) } }
c28007
o.Context = context.WithValue(o.Context, dedupFunctionKey{}, dedup) } }
c28008
o.Context = context.WithValue(o.Context, groupIdFunctionKey{}, groupfunc) } }
c28009
if o.Context == nil { o.Context = context.Background() } o.Context = context.WithValue(o.Context, maxMessagesKey{}, max) } }
c28010
o.Context = context.WithValue(o.Context, visiblityTimeoutKey{}, seconds) } }
c28011
o.Context = context.WithValue(o.Context, waitTimeSecondsKey{}, seconds) } }
c28012
} o.Context = context.WithValue(o.Context, sqsClientKey{}, c) } }
c28013
:= ratelimit.New(rate, opts...) return func(c client.Client) client.Client { return &clientWrapper{r, c} } }
c28014
req server.Request, rsp interface{}) error { r.Take() return h(ctx, req, rsp) } } }
c28015
rr: make(map[string]int), Client: c, } } }
c28016
>= 400: s.Error = true } s.HTTP.Response.Status = status s.EndTime = float64(time.Now().Truncate(time.Millisecond).UnixNano()) / 1e9 }
c28017
host, _, err := net.SplitHostPort(r.RemoteAddr) if err != nil { // just return remote addr return r.RemoteAddr } return host }
c28018
URL: fmt.Sprintf("%s://%s%s", scheme, host, r.URL.Path), ClientIP: getIp(r), UserAgent: r.UserAgent(), }, Response: &awsxray.Response{ Status: 200, }, } }
c28019
StartTime: float64(time.Now().Truncate(time.Millisecond).UnixNano()) / 1e9, } // if we have a parent then we are a subsegment if len(parentId) > 0 { s.ParentId = parentId s.Type = "subsegment" } else { // set a new parent Id traceHdr = awsxray.SetParentId(traceHdr, s.Id) } // now save the header for t...
c28020
= make(map[string]*gobreaker.TwoStepCircuitBreaker) w.Client = c return w } }
c28021
w.cbs = make(map[string]*gobreaker.TwoStepCircuitBreaker) w.Client = c return w } }
c28022
defer func() { t.end(ctx, err) }() ctx = injectTraceIntoCtx(ctx, t.span) err = w.Client.Call(ctx, req, rsp, opts...) return }
c28023
func() { t.end(ctx, err) }() ctx = injectTraceIntoCtx(ctx, t.span) err = w.Client.Publish(ctx, p, opts...) return }
c28024
fmt.Sprintf("rpc/%s/%s/%s", ServerProfile.Role, req.Service(), req.Endpoint()), *spanCtx, ) } else { ctx, t.span = trace.StartSpan( ctx, fmt.Sprintf("rpc/%s/%s/%s", ServerProfile.Role, req.Service(), req.Endpoint()), ) } err = fn(ctx, req, rsp) return } } }
c28025
fmt.Sprintf("rpc/%s/pubsub/%s", ServerProfile.Role, p.Topic()), *spanCtx, ) } else { ctx, t.span = trace.StartSpan( ctx, fmt.Sprintf("rpc/%s/pubsub/%s", ServerProfile.Role, p.Topic()), ) } err = fn(ctx, p) return } } }
c28026
t = tt } m := &pubsub.Message{ ID: "m-" + uuid.New().String(), Data: msg.Body, Attributes: msg.Header, } pr := t.Publish(ctx, m) _, err = pr.Get(ctx) return err }
c28027
tt := b.client.Topic(topic) subb, err := b.client.CreateSubscription(ctx, options.Queue, pubsub.SubscriptionConfig{ Topic: tt, AckDeadline: time.Duration(0), }) if err != nil { return nil, err } sub = subb } } subscriber := &subscriber{ options: options, topic: topic, ex...
c28028
err := pubsub.NewClient(context.Background(), prjID, cOpts...) if err != nil { panic(err.Error()) } return &pubsubBroker{ client: c, options: options, } }
c28029
o.Context = context.WithValue(o.Context, grpcOptions{}, opts) } }
c28030
} o.Context = context.WithValue(o.Context, maxMsgSizeKey{}, s) } }
c28031
[]*registry.Service) selector.Next { return Next(keys, services) }) }
c28032
} if pos < 0 { // There was no node found. return nil, selector.ErrNoneAvailable } // Choose this node and set it's score to zero to stop it being selected again. node := possibleNodes[pos] possibleNodes[pos] = nil scores[pos] = 0 return node, nil } }
c28033
the base key from above to calculate a derivative 64 bit hash number based off the instance ID. score := highwayhash.Sum64([]byte(n.Id), key[:]) scores = append(scores, score) possibleNodes = append(possibleNodes, n) } } return }
c28034
m.Id = h.ID m.Error = h.Error case codec.Publication: var h Notification if err := msgp.Decode(c.rwc, &h); err != nil { return err } c.body = h.hasBody m.Endpoint = h.Method default: return errors.New("Unrecognized message type") } return nil }
c28035
c.mt { case codec.Request, codec.Response, codec.Publication: return decodeBody(r, v) default: return fmt.Errorf("Unrecognized message type: %v", c.mt) } }
c28036
case codec.Publication: h := Notification{ Method: m.Endpoint, Body: b, } return msgp.Encode(c.rwc, &h) default: return fmt.Errorf("Unrecognized message type: %v", m.Type) } }
c28037
&Error{Code: code, Message: message} }
c28038
message) case strings.HasPrefix(message, "rpc: can't find method"): return NewError(errMethod.Code, message) default: return NewError(errServer.Code, message) } }
c28039
return fmt.Sprintf(`{"code":%d,"message":%s}`, errServerError.Code, string(msg)) } return string(buf) }
c28040
aname[i] = '_' continue } aname[i] = r } return string(aname) }
c28041
error { return configure(c, opts...) }
c28042
nil { return err } svc := string(b) pod := &client.Pod{ Metadata: &client.Meta{ Labels: map[string]*string{ labelTypeKey: &labelTypeValueService, svcSelectorPrefix + serviceName(svcName): &svcSelectorValue, }, Annotations: map[string]*string{ annotationServiceKe...
c28043
:= s.Name pod := &client.Pod{ Metadata: &client.Meta{ Labels: map[string]*string{ svcSelectorPrefix + serviceName(svcName): nil, }, Annotations: map[string]*string{ annotationServiceKeyPrefix + serviceName(svcName): nil, }, }, } if _, err := c.client.UpdatePod(podName, pod); err != nil { ...
c28044
continue } // get serialised service from annotation svcStr, ok := pod.Metadata.Annotations[annotationServiceKeyPrefix+serviceName(name)] if !ok { continue } // unmarshal service string var svc registry.Service err := json.Unmarshal([]byte(*svcStr), &svc) if err != nil { return nil, fmt.Errorf...
c28045
is encoded to match the regex restriction. var svc registry.Service if err := json.Unmarshal([]byte(*v), &svc); err != nil { continue } svcs[svc.Name] = true } } var list []*registry.Service for val := range svcs { list = append(list, &registry.Service{Name: val}) } return list, nil }
c28046
{ return newWatcher(c, opts...) }
c28047
{ k := &kregistry{ options: registry.Options{}, } configure(k, opts...) return k }
c28048
for _, prefix := range prefixes { if strings.HasPrefix(content, prefix) { return strings.TrimPrefix(content, prefix), true } } return "", false } }
c28049
<-wr.stop: return default: close(wr.stop) close(wr.results) } }
c28050
wr := &bodyWatcher{ results: make(chan Event), stop: stop, req: req, res: res, } go wr.stream() return wr, nil }
c28051
openTopic, openSub, err = setupGCP(options.Context, projID, ts) } else if rurl, ok := options.Context.Value(rabbitURLKey{}).(string); ok { openTopic, openSub, err = setupRabbit(options.Context, rurl) } else { openTopic, openSub, err = setupMem() } if err != nil { return &pubsubBroker{err: err} } return &pu...
c28052
t.Send(context.Background(), &pubsub.Message{Metadata: msg.Header, Body: msg.Body}) }
c28053
nil { t = b.openTopic(name) b.topics[name] = t } return t }
c28054
ot = opentracing.GlobalTracer() } return &otWrapper{ot, c} } }
c28055
{ if ot == nil { ot = opentracing.GlobalTracer() } name := fmt.Sprintf("%s.%s", req.Service(), req.Endpoint()) ctx, span, err := StartSpanFromContext(ctx, ot, name) if err != nil { return err } defer span.Finish() return cf(ctx, node, req, rsp, opts) } } }
c28056
if ot == nil { ot = opentracing.GlobalTracer() } name := fmt.Sprintf("%s.%s", req.Service(), req.Endpoint()) ctx, span, err := StartSpanFromContext(ctx, ot, name) if err != nil { return err } defer span.Finish() return h(ctx, req, rsp) } } }
c28057
err := StartSpanFromContext(ctx, ot, name) if err != nil { return err } defer span.Finish() return next(ctx, msg) } } }
c28058
limit(b, wait, "go.micro.client") return func(c client.Client) client.Client { return &clientWrapper{fn, c} } }
c28059
rsp interface{}) error { if err := fn(); err != nil { return err } return h(ctx, req, rsp) } } }
c28060
*Options) { o.Client = x } }
c28061
t.profile.LatencyMeasure.M(float64(time.Since(t.startedAt))/float64(time.Millisecond))) if t.span != nil { t.span.SetStatus(status) t.span.End() } }
c28062
// set version instance.SetMetadataString("version", service.Version) // set instance ID instance.SetMetadataString("instanceId", node.Id) // set endpoints if b, err := json.Marshal(service.Endpoints); err == nil { instance.SetMetadataString("endpoints", string(b)) } // set metadata if b, err := json.Mar...
c28063
k.buildPodResults(&pod, nil) for _, r := range rslts { results = append(results, r) } k.Lock() k.pods[pod.Metadata.Name] = &pod k.Unlock() } return results, nil }
c28064
"delete" them. if cache != nil && cache.Metadata != nil { for ak, av := range cache.Metadata.Annotations { if ignore[ak] { continue } // check this annotation kv is a service notation if !strings.HasPrefix(ak, annotationServiceKeyPrefix) { continue } rslt := &registry.Result{Action: "del...
c28065
k.next <- result } k.Lock() k.pods[pod.Metadata.Name] = &pod k.Unlock() return case watch.Deleted: // Pod was deleted // passing in cache might not return all results results := k.buildPodResults(&pod, nil) for _, result := range results { result.Action = "delete" k.next <- result } ...
c28066
nil, errors.New("result chan closed") } return r, nil }
c28067
return default: close(k.next) } }
c28068
client.Client { return &ddWrapper{c} } }
c28069
t.StartSpanFromContext(ctx) defer func() { t.finishWithError(nil, noDebugStack) }() return cf(ctx, node, req, rsp, opts) } } }
c28070
ServerProfile) ctx = t.StartSpanFromContext(ctx) defer func() { t.finishWithError(err, noDebugStack) }() } err = h(ctx, req, rsp) return } } }
c28071
server.Message) (err error) { t := newPublicationTracker(msg, ServerProfile) ctx = t.StartSpanFromContext(ctx) defer func() { t.finishWithError(err, noDebugStack) }() err = next(ctx, msg) return } } }
c28072
decoder := json.NewDecoder(r.res.Body) err := decoder.Decode(&data) if err != nil { return ErrDecode } return r.err }
c28073
if o.Context == nil { o.Context = context.Background() } o.Context = context.WithValue(o.Context, optionsKey{}, nopts) } }
c28074
} return &client{ opts: &api.Options{ Client: c, Host: host, Namespace: "default", }, } }
c28075
err := CertPoolFromFile(path.Join(serviceAccountPath, "ca.crt")) if err != nil { log.Fatal(err) } c := &http.Client{ Transport: &http.Transport{ TLSClientConfig: &tls.Config{ RootCAs: crt, }, DisableCompression: true, }, } return &client{ opts: &api.Options{ Client: c, Host: ...
c28076
Stats.outboundBytes += len(in) return in, nil }
c28077
Stats.inboundBytes += len(in) return in, nil }
c28078
string) (*UserMessage, error) { return msg, nil }
c28079
mock.recorder = &MockNetworkEntityMockRecorder{mock} return mock }
c28080
error { ret := m.ctrl.Call(m, "Push", route, v) ret0, _ := ret[0].(error) return ret0 }
c28081
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Push", reflect.TypeOf((*MockNetworkEntity)(nil).Push), route, v) }
c28082
} ret := m.ctrl.Call(m, "ResponseMID", varargs...) ret0, _ := ret[0].(error) return ret0 }
c28083
:= append([]interface{}{ctx, mid, v}, isError...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ResponseMID", reflect.TypeOf((*MockNetworkEntity)(nil).ResponseMID), varargs...) }
c28084
{ ret := m.ctrl.Call(m, "Kick", ctx) ret0, _ := ret[0].(error) return ret0 }
c28085
"Kick", reflect.TypeOf((*MockNetworkEntity)(nil).Kick), ctx) }
c28086
"RemoteAddr", reflect.TypeOf((*MockNetworkEntity)(nil).RemoteAddr)) }
c28087
route, v) ret0, _ := ret[0].(*protos.Response) ret1, _ := ret[1].(error) return ret0, ret1 }
c28088
"SendRequest", reflect.TypeOf((*MockNetworkEntity)(nil).SendRequest), ctx, serverID, route, v) }
c28089
services: make(map[string]*component.Service), chLocalProcess: make(chan unhandledMessage, localProcessBufferSize), chRemoteProcess: make(chan unhandledMessage, remoteProcessBufferSize), decoder: packetDecoder, encoder: packetEncoder, messagesBufferSize: messagesBufferS...
c28090
metrics.ReportMessageProcessDelayFromCtx(rm.ctx, h.metricsReporters, "remote") h.remoteService.remoteProcess(rm.ctx, nil, rm.agent, rm.route, rm.msg) case <-timer.GlobalTicker.C: // execute cron task timer.Cron() case t := <-timer.Manager.ChCreatedTimer: // new Timers timer.AddTimer(t) case id := <-t...
c28091
packets, err := h.decoder.Decode(buf[:n]) if err != nil { logger.Log.Errorf("Failed to decode message: %s", err.Error()) return } if len(packets) < 1 { logger.Log.Warnf("Read no packets, data: %v", buf[:n]) continue } // process all packet for i := range packets { if err := h.processPack...
c28092
handler %s, isRawArg: %s", name, handlers[name].IsRawArg) } }
c28093
} return docgenerator.HandlersDocs(h.server.Type, h.services, getPtrNames) }
c28094
&rpcInfo{ Route: routeStr, Metadata: metadata, Arg: arg, Reply: reply, }, opts) }
c28095
} job := w.parsedRPCJob(rpcJob) workers.Process(rpcQueue, job, w.concurrency) w.registered = true return nil }
c28096
if err := app.rpcClient.SendKick(uid, frontendType, kick); err != nil { notKickedUids = append(notKickedUids, uid) logger.Log.Errorf("RPCClient send kick error, UID=%d, SvType=%s, Error=%s", uid, frontendType, err.Error()) } } else { notKickedUids = append(notKickedUids, uid) } } if len(notKicked...
c28097
return nil, err } var fileDescriptorProto protobuf.FileDescriptorProto if err = proto.Unmarshal(b, &fileDescriptorProto); err != nil { return nil, err } return &fileDescriptorProto, nil }
c28098
} } for name, cmd := range pc.info.Commands { if msg, ok := descriptorsMap[cmd.input]; ok { pc.info.Commands[name].inputMsgDescriptor = msg } if msg, ok := descriptorsMap[cmd.output]; ok { pc.info.Commands[name].outputMsgDescriptor = msg } } return nil }
c28099
inputName = strings.Replace(k, "*", "", 1) } } } out := command["output"] outputDocsArr := out.([]interface{}) outputDocs, ok := outputDocsArr[0].(map[string]interface{}) if ok { for k := range outputDocs { if strings.Contains(k, "proto") { outputName = strings.Replace(k, "*", "", 1) } } ...