id
stringlengths
95
167
text
stringlengths
69
15.9k
title
stringclasses
1 value
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/embed/config.go#L798-L828
func (cfg *Config) UpdateDefaultClusterFromName(defaultInitialCluster string) (string, error) { if defaultHostname == "" || defaultHostStatus != nil { // update 'initial-cluster' when only the name is specified (e.g. 'etcd --name=abc') if cfg.Name != DefaultName && cfg.InitialCluster == defaultInitialCluster { ...
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/raft.go#L122-L143
func (r *Raft) run() { for { // Check if we are doing a shutdown select { case <-r.shutdownCh: // Clear the leader to prevent forwarding r.setLeader("") return default: } // Enter into a sub-FSM switch r.getState() { case Follower: r.runFollower() case Candidate: r.runCandidate() ca...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/expect/expect.go#L53-L71
func NewExpectWithEnv(name string, args []string, env []string) (ep *ExpectProcess, err error) { cmd := exec.Command(name, args...) cmd.Env = env ep = &ExpectProcess{ cmd: cmd, StopSignal: syscall.SIGKILL, } ep.cond = sync.NewCond(&ep.mu) ep.cmd.Stderr = ep.cmd.Stdout ep.cmd.Stdin = nil if ep.fpty, ...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/integration/cluster.go#L213-L215
func NewClusterByConfig(t testing.TB, cfg *ClusterConfig) *cluster { return newCluster(t, cfg) }
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/genny/actions/build_actions.go#L14-L27
func buildActions(pres *presenter) genny.RunFn { return func(r *genny.Runner) error { fn := fmt.Sprintf("actions/%s.go", pres.Name.File()) xf, err := r.FindFile(fn) if err != nil { return buildNewActions(fn, pres)(r) } if err := appendActions(xf, pres)(r); err != nil { return err } return nil } }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/golint/suggestion/golint_suggestion.go#L47-L57
func SuggestCodeChange(p lint.Problem) string { var suggestion = "" for regex, handler := range lintHandlersMap { matches := regex.FindStringSubmatch(p.Text) suggestion = handler(p, matches) if suggestion != "" && suggestion != p.LineText { return formatSuggestion(suggestion) } } return "" }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/server.go#L1917-L1955
func (s *EtcdServer) apply( es []raftpb.Entry, confState *raftpb.ConfState, ) (appliedt uint64, appliedi uint64, shouldStop bool) { for i := range es { e := es[i] switch e.Type { case raftpb.EntryNormal: s.applyEntryNormal(&e) s.setAppliedIndex(e.Index) s.setTerm(e.Term) case raftpb.EntryConfChange...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2store/node.go#L57-L67
func newKV(store *store, nodePath string, value string, createdIndex uint64, parent *node, expireTime time.Time) *node { return &node{ Path: nodePath, CreatedIndex: createdIndex, ModifiedIndex: createdIndex, Parent: parent, store: store, ExpireTime: expireTime, Value: ...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/fakegithub/fakegithub.go#L273-L286
func (f *FakeClient) GetIssueLabels(owner, repo string, number int) ([]github.Label, error) { re := regexp.MustCompile(fmt.Sprintf(`^%s/%s#%d:(.*)$`, owner, repo, number)) la := []github.Label{} allLabels := sets.NewString(f.IssueLabelsExisting...) allLabels.Insert(f.IssueLabelsAdded...) allLabels.Delete(f.IssueLa...
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/batch.go#L104-L108
func (wb *WriteBatch) SetWithTTL(key, val []byte, dur time.Duration) error { expire := time.Now().Add(dur).Unix() e := &Entry{Key: key, Value: val, ExpiresAt: uint64(expire)} return wb.SetEntry(e) }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/robots/coverage/cmd/downloader/downloader.go#L37-L52
func MakeCommand() *cobra.Command { flags := &flags{} cmd := &cobra.Command{ Use: "download [bucket] [prowjob]", Short: "Finds and downloads the coverage profile file from the latest healthy build", Long: `Finds and downloads the coverage profile file from the latest healthy build stored in given gcs directo...
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/file_snapshot.go#L296-L346
func (f *FileSnapshotStore) Open(id string) (*SnapshotMeta, io.ReadCloser, error) { // Get the metadata meta, err := f.readMeta(id) if err != nil { f.logger.Printf("[ERR] snapshot: Failed to get meta data to open snapshot: %v", err) return nil, nil, err } // Open the state file statePath := filepath.Join(f.p...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/fakegithub/fakegithub.go#L410-L413
func (f *FakeClient) ClearMilestone(org, repo string, issueNum int) error { f.Milestone = 0 return nil }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/watch.go#L282-L362
func (w *watcher) Watch(ctx context.Context, key string, opts ...OpOption) WatchChan { ow := opWatch(key, opts...) var filters []pb.WatchCreateRequest_FilterType if ow.filterPut { filters = append(filters, pb.WatchCreateRequest_NOPUT) } if ow.filterDelete { filters = append(filters, pb.WatchCreateRequest_NODE...
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/file_snapshot.go#L375-L377
func (s *FileSnapshotSink) Write(b []byte) (int, error) { return s.buffered.Write(b) }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2stats/queue.go#L52-L59
func (q *statsQueue) frontAndBack() (*RequestStats, *RequestStats) { q.rwl.RLock() defer q.rwl.RUnlock() if q.size != 0 { return q.items[q.front], q.items[q.back] } return nil, nil }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/artifact-uploader/main.go#L86-L88
func (o *Options) LoadConfig(config string) error { return json.Unmarshal([]byte(config), o) }
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/default_context.go#L265-L279
func (d *DefaultContext) MarshalJSON() ([]byte, error) { m := map[string]interface{}{} data := d.Data() for k, v := range data { // don't try and marshal ourself if _, ok := v.(*DefaultContext); ok { continue } if _, err := json.Marshal(v); err == nil { // it can be marshaled, so add it: m[k] = v ...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv2/command/ls_command.go#L80-L90
func rPrint(c *cli.Context, n *client.Node) { if n.Dir && c.Bool("p") { fmt.Println(fmt.Sprintf("%v/", n.Key)) } else { fmt.Println(n.Key) } for _, node := range n.Nodes { rPrint(c, node) } }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/inmem_store.go#L99-L104
func (i *InmemStore) Set(key []byte, val []byte) error { i.l.Lock() defer i.l.Unlock() i.kv[string(key)] = val return nil }
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/render/html.go#L16-L19
func HTML(names ...string) Renderer { e := New(Options{}) return e.HTML(names...) }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/auth_command.go#L84-L97
func authDisableCommandFunc(cmd *cobra.Command, args []string) { if len(args) != 0 { ExitWithError(ExitBadArgs, fmt.Errorf("auth disable command does not accept any arguments")) } ctx, cancel := commandCtx(cmd) _, err := mustClientFromCmd(cmd).Auth.AuthDisable(ctx) cancel() if err != nil { ExitWithError(Exit...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/kube/dry_run_client.go#L50-L52
func (c *dryRunProwJobClient) Create(*prowapi.ProwJob) (*prowapi.ProwJob, error) { return nil, nil }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/config/secret/agent.go#L35-L49
func (a *Agent) Start(paths []string) error { secretsMap, err := LoadSecrets(paths) if err != nil { return err } a.secretsMap = secretsMap // Start one goroutine for each file to monitor and update the secret's values. for secretPath := range secretsMap { go a.reloadSecret(secretPath) } return nil }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2http/client.go#L370-L551
func parseKeyRequest(r *http.Request, clock clockwork.Clock) (etcdserverpb.Request, bool, error) { var noValueOnSuccess bool emptyReq := etcdserverpb.Request{} err := r.ParseForm() if err != nil { return emptyReq, false, v2error.NewRequestError( v2error.EcodeInvalidForm, err.Error(), ) } if !strings.H...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/fakegithub/fakegithub.go#L588-L596
func (f *FakeClient) TeamHasMember(teamID int, memberLogin string) (bool, error) { teamMembers, _ := f.ListTeamMembers(teamID, github.RoleAll) for _, member := range teamMembers { if member.Login == memberLogin { return true, nil } } return false, nil }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/configuration.go#L280-L297
func encodePeers(configuration Configuration, trans Transport) []byte { // Gather up all the voters, other suffrage types are not supported by // this data format. var encPeers [][]byte for _, server := range configuration.Servers { if server.Suffrage == Voter { encPeers = append(encPeers, trans.EncodePeer(ser...
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/servers/tls.go#L23-L26
func (s *TLS) Start(c context.Context, h http.Handler) error { s.Handler = h return s.ListenAndServeTLS(s.CertFile, s.KeyFile) }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/peersjson.go#L64-L98
func ReadConfigJSON(path string) (Configuration, error) { // Read in the file. buf, err := ioutil.ReadFile(path) if err != nil { return Configuration{}, err } // Parse it as JSON. var peers []configEntry dec := json.NewDecoder(bytes.NewReader(buf)) if err := dec.Decode(&peers); err != nil { return Configur...
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/configuration.go#L327-L333
func encodeConfiguration(configuration Configuration) []byte { buf, err := encodeMsgPack(configuration) if err != nil { panic(fmt.Errorf("failed to encode configuration: %v", err)) } return buf.Bytes() }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/transform/plugins/multiplexer_wrapper.go#L38-L46
func (m *MultiplexerPluginWrapper) ReceiveIssue(issue sql.Issue) []Point { points := []Point{} for _, plugin := range m.plugins { points = append(points, plugin.ReceiveIssue(issue)...) } return points }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/server.go#L2218-L2223
func (s *EtcdServer) CutPeer(id types.ID) { tr, ok := s.r.transport.(*rafthttp.Transport) if ok { tr.CutPeer(id) } }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/client/clientset/versioned/typed/prowjobs/v1/prowjob.go#L112-L122
func (c *prowJobs) Update(prowJob *v1.ProwJob) (result *v1.ProwJob, err error) { result = &v1.ProwJob{} err = c.client.Put(). Namespace(c.ns). Resource("prowjobs"). Name(prowJob.Name). Body(prowJob). Do(). Into(result) return }
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/render/sse.go#L64-L77
func NewEventSource(w http.ResponseWriter) (*EventSource, error) { es := &EventSource{w: w} var ok bool es.fl, ok = w.(http.Flusher) if !ok { return es, errors.New("streaming is not supported") } es.w.Header().Set("Content-Type", "text/event-stream") es.w.Header().Set("Cache-Control", "no-cache") es.w.Header...
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/iterator.go#L74-L76
func (item *Item) KeyCopy(dst []byte) []byte { return y.SafeCopy(dst, item.key) }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2auth/auth.go#L468-L517
func (ou User) merge(lg *zap.Logger, nu User, s PasswordStore) (User, error) { var out User if ou.User != nu.User { return out, authErr(http.StatusConflict, "Merging user data with conflicting usernames: %s %s", ou.User, nu.User) } out.User = ou.User if nu.Password != "" { hash, err := s.HashPassword(nu.Passwo...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/proxy/grpcproxy/cluster.go#L156-L177
func (cp *clusterProxy) MemberList(ctx context.Context, r *pb.MemberListRequest) (*pb.MemberListResponse, error) { if cp.advaddr != "" { if cp.prefix != "" { mbs, err := cp.membersFromUpdates() if err != nil { return nil, err } if len(mbs) > 0 { return &pb.MemberListResponse{Members: mbs}, nil ...
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/server.go#L101-L108
func (a *App) Stop(err error) error { a.cancel() if err != nil && errors.Cause(err) != context.Canceled { a.Logger.Error(err) return err } return nil }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/transform/plugins/multiplexer_wrapper.go#L60-L68
func (m *MultiplexerPluginWrapper) ReceiveComment(comment sql.Comment) []Point { points := []Point{} for _, plugin := range m.plugins { points = append(points, plugin.ReceiveComment(comment)...) } return points }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/artifact-uploader/main.go#L127-L151
func (o *Options) Run() error { clusterConfig, err := loadClusterConfig() if err != nil { return fmt.Errorf("failed to load cluster config: %v", err) } client, err := kubernetes.NewForConfig(clusterConfig) if err != nil { return err } prowJobClient, err := kube.NewClientInCluster(o.ProwJobNamespace) if er...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/cluster_util.go#L231-L240
func isCompatibleWithCluster(lg *zap.Logger, cl *membership.RaftCluster, local types.ID, rt http.RoundTripper) bool { vers := getVersions(lg, cl, local, rt) minV := semver.Must(semver.NewVersion(version.MinClusterVersion)) maxV := semver.Must(semver.NewVersion(version.Version)) maxV = &semver.Version{ Major: maxV...
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/mail/internal/mail/message.go#L135-L163
func (m *Message) FormatAddress(address, name string) string { if name == "" { return address } enc := m.encodeString(name) if enc == name { m.buf.WriteByte('"') for i := 0; i < len(name); i++ { b := name[i] if b == '\\' || b == '"' { m.buf.WriteByte('\\') } m.buf.WriteByte(b) } m.buf.Wri...
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/batch.go#L38-L47
func (db *DB) NewWriteBatch() *WriteBatch { txn := db.newTransaction(true, true) // If we let it stay at zero, compactions would not allow older key versions to be deleted, // because the read timestamps of pending txns, would be zero. Therefore, we set it to the // maximum read timestamp that's done. This allows c...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/retry.go#L103-L107
func RetryKVClient(c *Client) pb.KVClient { return &retryKVClient{ kc: pb.NewKVClient(c.conn), } }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/functional/rpcpb/member.go#L255-L314
func (m *Member) SaveSnapshot(lg *zap.Logger) (err error) { // remove existing snapshot first if err = os.RemoveAll(m.SnapshotPath); err != nil { return err } var ccfg *clientv3.Config ccfg, err = m.CreateEtcdClientConfig() if err != nil { return fmt.Errorf("%v (%q)", err, m.EtcdClientEndpoint) } lg.Info(...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/server.go#L2248-L2288
func (s *EtcdServer) monitorVersions() { for { select { case <-s.forceVersionC: case <-time.After(monitorVersionInterval): case <-s.stopping: return } if s.Leader() != s.ID() { continue } v := decideClusterVersion(s.getLogger(), getVersions(s.getLogger(), s.cluster, s.id, s.peerRt)) if v != n...
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/mail/internal/mail/message.go#L304-L306
func (m *Message) Attach(filename string, settings ...FileSetting) { m.attachments = m.appendFile(m.attachments, fileFromFilename(filename), settings) }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/check.go#L106-L116
func NewCheckCommand() *cobra.Command { cc := &cobra.Command{ Use: "check <subcommand>", Short: "commands for checking properties of the etcd cluster", } cc.AddCommand(NewCheckPerfCommand()) cc.AddCommand(NewCheckDatascaleCommand()) return cc }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/fakegithub/fakegithub.go#L140-L149
func (f *FakeClient) CreateComment(owner, repo string, number int, comment string) error { f.IssueCommentsAdded = append(f.IssueCommentsAdded, fmt.Sprintf("%s/%s#%d:%s", owner, repo, number, comment)) f.IssueComments[number] = append(f.IssueComments[number], github.IssueComment{ ID: f.IssueCommentID, Body: comm...
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/y/iterator.go#L241-L246
func (s *MergeIterator) Rewind() { for _, itr := range s.all { itr.Rewind() } s.initHeap() }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/etcdhttp/base.go#L87-L109
func logHandleFunc(w http.ResponseWriter, r *http.Request) { if !allowMethod(w, r, "PUT") { return } in := struct{ Level string }{} d := json.NewDecoder(r.Body) if err := d.Decode(&in); err != nil { WriteError(nil, w, r, httptypes.NewHTTPError(http.StatusBadRequest, "Invalid json body")) return } logl, ...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/retry_interceptor.go#L102-L131
func (c *Client) streamClientInterceptor(logger *zap.Logger, optFuncs ...retryOption) grpc.StreamClientInterceptor { intOpts := reuseOrNewWithCallOptions(defaultOptions, optFuncs) return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOptio...
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/genny/build/validate.go#L67-L73
func PlushValidator(f genny.File) error { if !genny.HasExt(f, ".html", ".md", ".plush") { return nil } _, err := plush.Parse(f.String()) return err }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/fakegithub/fakegithub.go#L360-L371
func (f *FakeClient) ListTeams(org string) ([]github.Team, error) { return []github.Team{ { ID: 0, Name: "Admins", }, { ID: 42, Name: "Leads", }, }, nil }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/transport.go#L22-L24
func (r *RPC) Respond(resp interface{}, err error) { r.RespChan <- RPCResponse{resp, err} }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/mock/mockserver/mockserver.go#L123-L143
func (ms *MockServers) StartAt(idx int) (err error) { ms.mu.Lock() defer ms.mu.Unlock() if ms.Servers[idx].ln == nil { ms.Servers[idx].ln, err = net.Listen(ms.Servers[idx].Network, ms.Servers[idx].Address) if err != nil { return fmt.Errorf("failed to listen %v", err) } } svr := grpc.NewServer() pb.Regi...
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/runtime/build.go#L16-L18
func (b BuildInfo) String() string { return fmt.Sprintf("%s (%s)", b.Version, b.Time) }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2store/event_history.go#L58-L109
func (eh *EventHistory) scan(key string, recursive bool, index uint64) (*Event, *v2error.Error) { eh.rwl.RLock() defer eh.rwl.RUnlock() // index should be after the event history's StartIndex if index < eh.StartIndex { return nil, v2error.NewError(v2error.EcodeEventIndexCleared, fmt.Sprintf("the requested...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/etcdserverpb/rpc.pb.go#L1111-L1119
func (*Compare) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { return _Compare_OneofMarshaler, _Compare_OneofUnmarshaler, _Compare_OneofSizer, []interface{}{ (*Compare_Version)(...
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/net_transport.go#L414-L449
func (n *NetworkTransport) InstallSnapshot(id ServerID, target ServerAddress, args *InstallSnapshotRequest, resp *InstallSnapshotResponse, data io.Reader) error { // Get a conn, always close for InstallSnapshot conn, err := n.getConnFromAddressProvider(id, target) if err != nil { return err } defer conn.Release(...
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/raft.go#L1164-L1251
func (r *Raft) requestVote(rpc RPC, req *RequestVoteRequest) { defer metrics.MeasureSince([]string{"raft", "rpc", "requestVote"}, time.Now()) r.observe(*req) // Setup a response resp := &RequestVoteResponse{ RPCHeader: r.getRPCHeader(), Term: r.getCurrentTerm(), Granted: false, } var rpcErr error d...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv2/command/rmdir_command.go#L38-L54
func rmdirCommandFunc(c *cli.Context, ki client.KeysAPI) { if len(c.Args()) == 0 { handleError(c, ExitBadArgs, errors.New("key required")) } key := c.Args()[0] ctx, cancel := contextWithTotalTimeout(c) resp, err := ki.Delete(ctx, key, &client.DeleteOptions{Dir: true}) cancel() if err != nil { handleError(c,...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/progress.go#L183-L185
func (pr *Progress) needSnapshotAbort() bool { return pr.State == ProgressStateSnapshot && pr.Match >= pr.PendingSnapshot }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/flagutil/github.go#L119-L146
func (o *GitHubOptions) GitClient(secretAgent *secret.Agent, dryRun bool) (client *git.Client, err error) { client, err = git.NewClient() if err != nil { return nil, err } // We must capture the value of client here to prevent issues related // to the use of named return values when an error is encountered. //...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/proxy/grpcproxy/health.go#L28-L30
func HandleHealth(mux *http.ServeMux, c *clientv3.Client) { mux.Handle(etcdhttp.PathHealth, etcdhttp.NewHealthHandler(func() etcdhttp.Health { return checkHealth(c) })) }
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/render/plain.go#L20-L27
func (e *Engine) Plain(names ...string) Renderer { hr := &templateRenderer{ Engine: e, contentType: "text/plain; charset=utf-8", names: names, } return hr }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/lease.go#L558-L589
func (l *lessor) sendKeepAliveLoop(stream pb.Lease_LeaseKeepAliveClient) { for { var tosend []LeaseID now := time.Now() l.mu.Lock() for id, ka := range l.keepAlives { if ka.nextKeepAlive.Before(now) { tosend = append(tosend, id) } } l.mu.Unlock() for _, id := range tosend { r := &pb.LeaseK...
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/batch.go#L145-L154
func (wb *WriteBatch) Flush() error { wb.Lock() _ = wb.commit() wb.txn.Discard() wb.Unlock() wb.wg.Wait() // Safe to access error without any synchronization here. return wb.err }
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/y/y.go#L137-L144
func ParseKey(key []byte) []byte { if key == nil { return nil } AssertTrue(len(key) > 8) return key[:len(key)-8] }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/config/agent.go#L106-L110
func (ca *Agent) Subscribe(subscription DeltaChan) { ca.mut.Lock() defer ca.mut.Unlock() ca.subscriptions = append(ca.subscriptions, subscription) }
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/genny/build/validate.go#L78-L85
func GoTemplateValidator(f genny.File) error { if !genny.HasExt(f, ".tmpl") { return nil } t := template.New(f.Name()) _, err := t.Parse(f.String()) return err }
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/mail/internal/mail/message.go#L130-L132
func (m *Message) SetAddressHeader(field, address, name string) { m.header[field] = []string{m.FormatAddress(address, name)} }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/net_transport.go#L506-L532
func (n *NetworkTransport) handleConn(connCtx context.Context, conn net.Conn) { defer conn.Close() r := bufio.NewReader(conn) w := bufio.NewWriter(conn) dec := codec.NewDecoder(r, &codec.MsgpackHandle{}) enc := codec.NewEncoder(w, &codec.MsgpackHandle{}) for { select { case <-connCtx.Done(): n.logger.Prin...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/schedule/schedule.go#L63-L72
func NewFIFOScheduler() Scheduler { f := &fifo{ resume: make(chan struct{}, 1), donec: make(chan struct{}, 1), } f.finishCond = sync.NewCond(&f.mu) f.ctx, f.cancel = context.WithCancel(context.Background()) go f.run() return f }
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/genny/mail/options.go#L18-L27
func (opts *Options) Validate() error { if opts.App.IsZero() { opts.App = meta.New(".") } if len(opts.Name.String()) == 0 { return errors.New("you must supply a name for your mailer") } return nil }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv2/command/set_command.go#L27-L48
func NewSetCommand() cli.Command { return cli.Command{ Name: "set", Usage: "set the value of a key", ArgsUsage: "<key> <value>", Description: `Set sets the value of a key. When <value> begins with '-', <value> is interpreted as a flag. Insert '--' for workaround: $ set -- <key> <value>`, ...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/member_command.go#L171-L188
func memberRemoveCommandFunc(cmd *cobra.Command, args []string) { if len(args) != 1 { ExitWithError(ExitBadArgs, fmt.Errorf("member ID is not provided")) } id, err := strconv.ParseUint(args[0], 16, 64) if err != nil { ExitWithError(ExitBadArgs, fmt.Errorf("bad member ID arg (%v), expecting ID in Hex", err)) }...
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/genny/assets/standard/standard.go#L13-L33
func New(opts *Options) (*genny.Generator, error) { g := genny.New() g.Box(packr.New("buffalo:genny:assets:standard", "../standard/templates")) data := map[string]interface{}{} h := template.FuncMap{} t := gogen.TemplateTransformer(data, h) g.Transformer(t) g.RunFn(func(r *genny.Runner) error { f, err := r.F...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/tide/history/history.go#L140-L153
func (h *History) Record(poolKey, action, baseSHA, err string, targets []prowapi.Pull) { t := now() sort.Sort(ByNum(targets)) h.addRecord( poolKey, &Record{ Time: t, Action: action, BaseSHA: baseSHA, Target: targets, Err: err, }, ) }
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/value.go#L902-L929
func (vlog *valueLog) sync(fid uint32) error { if vlog.opt.SyncWrites { return nil } vlog.filesLock.RLock() maxFid := atomic.LoadUint32(&vlog.maxFid) // During replay it is possible to get sync call with fid less than maxFid. // Because older file has already been synced, we can return from here. if fid < max...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/fakegithub/fakegithub.go#L229-L231
func (f *FakeClient) GetSingleCommit(org, repo, SHA string) (github.SingleCommit, error) { return f.Commits[SHA], nil }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/integration/cluster.go#L475-L492
func (c *cluster) waitNoLeader(membs []*member) { noLeader := false for !noLeader { noLeader = true for _, m := range membs { select { case <-m.s.StopNotify(): continue default: } if m.s.Lead() != 0 { noLeader = false time.Sleep(10 * tickDuration) break } } } }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/config/tide.go#L258-L284
func (tqs TideQueries) OrgExceptionsAndRepos() (map[string]sets.String, sets.String) { orgs := make(map[string]sets.String) for i := range tqs { for _, org := range tqs[i].Orgs { applicableRepos := sets.NewString(reposInOrg(org, tqs[i].ExcludedRepos)...) if excepts, ok := orgs[org]; !ok { // We have not s...
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/servers/simple.go#L14-L18
func (s *Simple) SetAddr(addr string) { if s.Server.Addr == "" { s.Server.Addr = addr } }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2store/watcher_hub.go#L180-L186
func (wh *watcherHub) clone() *watcherHub { clonedHistory := wh.EventHistory.clone() return &watcherHub{ EventHistory: clonedHistory, } }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/errorutil/aggregate.go#L60-L66
func (agg aggregate) Error() string { if len(agg) == 0 { // This should never happen, really. return "" } return fmt.Sprintf("[%s]", strings.Join(agg.Strings(), ", ")) }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/tcp_transport.go#L100-L102
func (t *TCPStreamLayer) Accept() (c net.Conn, err error) { return t.listener.Accept() }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2v3/store.go#L582-L586
func (s *v2v3Store) mkPathDepth(nodePath string, depth int) string { normalForm := path.Clean(path.Join("/", nodePath)) n := strings.Count(normalForm, "/") + depth return fmt.Sprintf("%s/%03d/k/%s", s.pfx, n, normalForm) }
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/skl/arena.go#L130-L136
func (s *Arena) getNodeOffset(nd *node) uint32 { if nd == nil { return 0 } return uint32(uintptr(unsafe.Pointer(nd)) - uintptr(unsafe.Pointer(&s.buf[0]))) }
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/genny/build/_fixtures/coke/actions/app.go#L72-L78
func translations() buffalo.MiddlewareFunc { var err error if T, err = i18n.New(packr.New("../locales", "../locales"), "en-US"); err != nil { app.Stop(err) } return T.Middleware() }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/tcp_transport.go#L38-L48
func NewTCPTransportWithLogger( bindAddr string, advertise net.Addr, maxPool int, timeout time.Duration, logger *log.Logger, ) (*NetworkTransport, error) { return newTCPTransport(bindAddr, advertise, func(stream StreamLayer) *NetworkTransport { return NewNetworkTransportWithLogger(stream, maxPool, timeout, logg...
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/file_snapshot.go#L227-L271
func (f *FileSnapshotStore) getSnapshots() ([]*fileSnapshotMeta, error) { // Get the eligible snapshots snapshots, err := ioutil.ReadDir(f.path) if err != nil { f.logger.Printf("[ERR] snapshot: Failed to scan snapshot dir: %v", err) return nil, err } // Populate the metadata var snapMeta []*fileSnapshotMeta ...
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/value.go#L74-L94
func (lf *logFile) openReadOnly() error { var err error lf.fd, err = os.OpenFile(lf.path, os.O_RDONLY, 0666) if err != nil { return errors.Wrapf(err, "Unable to open %q as RDONLY.", lf.path) } fi, err := lf.fd.Stat() if err != nil { return errors.Wrapf(err, "Unable to check stat for %q", lf.path) } y.Asser...
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/stream.go#L114-L125
func (st *Stream) produceRanges(ctx context.Context) { splits := st.db.KeySplits(st.Prefix) start := y.SafeCopy(nil, st.Prefix) for _, key := range splits { st.rangeCh <- keyRange{left: start, right: y.SafeCopy(nil, []byte(key))} start = y.SafeCopy(nil, []byte(key)) } // Edge case: prefix is empty and no split...
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/route_mappings.go#L234-L241
func (a *App) RouteHelpers() map[string]RouteHelperFunc { rh := map[string]RouteHelperFunc{} for _, route := range a.Routes() { cRoute := route rh[cRoute.PathName] = cRoute.BuildPathHelper() } return rh }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/adt/interval_tree.go#L406-L408
func (ivt *IntervalTree) MaxHeight() int { return int((2 * math.Log2(float64(ivt.Len()+1))) + 0.5) }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/raft.go#L931-L965
func (r *Raft) processLog(l *Log, future *logFuture) { switch l.Type { case LogBarrier: // Barrier is handled by the FSM fallthrough case LogCommand: // Forward to the fsm handler select { case r.fsmMutateCh <- &commitTuple{l, future}: case <-r.shutdownCh: if future != nil { future.respond(ErrRaf...
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/render/template.go#L56-L64
func (s templateRenderer) partialFeeder(name string) (string, error) { ct := strings.ToLower(s.contentType) d, f := filepath.Split(name) name = filepath.Join(d, "_"+f) name = fixExtension(name, ct) return s.TemplatesBox.FindString(name) }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/config.go#L203-L252
func (c *ServerConfig) advertiseMatchesCluster() error { urls, apurls := c.InitialPeerURLsMap[c.Name], c.PeerURLs.StringSlice() urls.Sort() sort.Strings(apurls) ctx, cancel := context.WithTimeout(context.TODO(), 30*time.Second) defer cancel() ok, err := netutil.URLStringsEqual(ctx, c.Logger, apurls, urls.StringSl...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/config/branch_protection.go#L184-L192
func (o Org) GetRepo(name string) *Repo { r, ok := o.Repos[name] if ok { r.Policy = o.Apply(r.Policy) } else { r.Policy = o.Policy } return &r }