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
147,900
goraft/raft
snapshot.go
Encode
func (req *SnapshotRecoveryRequest) Encode(w io.Writer) (int, error) { protoPeers := make([]*protobuf.SnapshotRecoveryRequest_Peer, len(req.Peers)) for i, peer := range req.Peers { protoPeers[i] = &protobuf.SnapshotRecoveryRequest_Peer{ Name: proto.String(peer.Name), ConnectionString: proto.Stri...
go
func (req *SnapshotRecoveryRequest) Encode(w io.Writer) (int, error) { protoPeers := make([]*protobuf.SnapshotRecoveryRequest_Peer, len(req.Peers)) for i, peer := range req.Peers { protoPeers[i] = &protobuf.SnapshotRecoveryRequest_Peer{ Name: proto.String(peer.Name), ConnectionString: proto.Stri...
[ "func", "(", "req", "*", "SnapshotRecoveryRequest", ")", "Encode", "(", "w", "io", ".", "Writer", ")", "(", "int", ",", "error", ")", "{", "protoPeers", ":=", "make", "(", "[", "]", "*", "protobuf", ".", "SnapshotRecoveryRequest_Peer", ",", "len", "(", ...
// Encodes the SnapshotRecoveryRequest to a buffer. Returns the number of bytes // written and any error that may have occurred.
[ "Encodes", "the", "SnapshotRecoveryRequest", "to", "a", "buffer", ".", "Returns", "the", "number", "of", "bytes", "written", "and", "any", "error", "that", "may", "have", "occurred", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/snapshot.go#L109-L133
147,901
goraft/raft
snapshot.go
Decode
func (req *SnapshotRecoveryRequest) Decode(r io.Reader) (int, error) { data, err := ioutil.ReadAll(r) if err != nil { return 0, err } totalBytes := len(data) pb := &protobuf.SnapshotRecoveryRequest{} if err = proto.Unmarshal(data, pb); err != nil { return -1, err } req.LeaderName = pb.GetLeaderName() r...
go
func (req *SnapshotRecoveryRequest) Decode(r io.Reader) (int, error) { data, err := ioutil.ReadAll(r) if err != nil { return 0, err } totalBytes := len(data) pb := &protobuf.SnapshotRecoveryRequest{} if err = proto.Unmarshal(data, pb); err != nil { return -1, err } req.LeaderName = pb.GetLeaderName() r...
[ "func", "(", "req", "*", "SnapshotRecoveryRequest", ")", "Decode", "(", "r", "io", ".", "Reader", ")", "(", "int", ",", "error", ")", "{", "data", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "r", ")", "\n\n", "if", "err", "!=", "nil", "{", "...
// Decodes the SnapshotRecoveryRequest from a buffer. Returns the number of bytes read and // any error that occurs.
[ "Decodes", "the", "SnapshotRecoveryRequest", "from", "a", "buffer", ".", "Returns", "the", "number", "of", "bytes", "read", "and", "any", "error", "that", "occurs", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/snapshot.go#L137-L166
147,902
goraft/raft
snapshot.go
newSnapshotRecoveryResponse
func newSnapshotRecoveryResponse(term uint64, success bool, commitIndex uint64) *SnapshotRecoveryResponse { return &SnapshotRecoveryResponse{ Term: term, Success: success, CommitIndex: commitIndex, } }
go
func newSnapshotRecoveryResponse(term uint64, success bool, commitIndex uint64) *SnapshotRecoveryResponse { return &SnapshotRecoveryResponse{ Term: term, Success: success, CommitIndex: commitIndex, } }
[ "func", "newSnapshotRecoveryResponse", "(", "term", "uint64", ",", "success", "bool", ",", "commitIndex", "uint64", ")", "*", "SnapshotRecoveryResponse", "{", "return", "&", "SnapshotRecoveryResponse", "{", "Term", ":", "term", ",", "Success", ":", "success", ",",...
// Creates a new Snapshot response.
[ "Creates", "a", "new", "Snapshot", "response", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/snapshot.go#L169-L175
147,903
goraft/raft
snapshot.go
Encode
func (req *SnapshotRecoveryResponse) Encode(w io.Writer) (int, error) { pb := &protobuf.SnapshotRecoveryResponse{ Term: proto.Uint64(req.Term), Success: proto.Bool(req.Success), CommitIndex: proto.Uint64(req.CommitIndex), } p, err := proto.Marshal(pb) if err != nil { return -1, err } return w....
go
func (req *SnapshotRecoveryResponse) Encode(w io.Writer) (int, error) { pb := &protobuf.SnapshotRecoveryResponse{ Term: proto.Uint64(req.Term), Success: proto.Bool(req.Success), CommitIndex: proto.Uint64(req.CommitIndex), } p, err := proto.Marshal(pb) if err != nil { return -1, err } return w....
[ "func", "(", "req", "*", "SnapshotRecoveryResponse", ")", "Encode", "(", "w", "io", ".", "Writer", ")", "(", "int", ",", "error", ")", "{", "pb", ":=", "&", "protobuf", ".", "SnapshotRecoveryResponse", "{", "Term", ":", "proto", ".", "Uint64", "(", "re...
// Encode writes the response to a writer. // Returns the number of bytes written and any error that occurs.
[ "Encode", "writes", "the", "response", "to", "a", "writer", ".", "Returns", "the", "number", "of", "bytes", "written", "and", "any", "error", "that", "occurs", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/snapshot.go#L179-L191
147,904
goraft/raft
snapshot.go
Decode
func (req *SnapshotRecoveryResponse) Decode(r io.Reader) (int, error) { data, err := ioutil.ReadAll(r) if err != nil { return 0, err } totalBytes := len(data) pb := &protobuf.SnapshotRecoveryResponse{} if err := proto.Unmarshal(data, pb); err != nil { return -1, err } req.Term = pb.GetTerm() req.Succes...
go
func (req *SnapshotRecoveryResponse) Decode(r io.Reader) (int, error) { data, err := ioutil.ReadAll(r) if err != nil { return 0, err } totalBytes := len(data) pb := &protobuf.SnapshotRecoveryResponse{} if err := proto.Unmarshal(data, pb); err != nil { return -1, err } req.Term = pb.GetTerm() req.Succes...
[ "func", "(", "req", "*", "SnapshotRecoveryResponse", ")", "Decode", "(", "r", "io", ".", "Reader", ")", "(", "int", ",", "error", ")", "{", "data", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "r", ")", "\n\n", "if", "err", "!=", "nil", "{", ...
// Decodes the SnapshotRecoveryResponse from a buffer.
[ "Decodes", "the", "SnapshotRecoveryResponse", "from", "a", "buffer", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/snapshot.go#L194-L213
147,905
goraft/raft
snapshot.go
Encode
func (req *SnapshotRequest) Encode(w io.Writer) (int, error) { pb := &protobuf.SnapshotRequest{ LeaderName: proto.String(req.LeaderName), LastIndex: proto.Uint64(req.LastIndex), LastTerm: proto.Uint64(req.LastTerm), } p, err := proto.Marshal(pb) if err != nil { return -1, err } return w.Write(p) }
go
func (req *SnapshotRequest) Encode(w io.Writer) (int, error) { pb := &protobuf.SnapshotRequest{ LeaderName: proto.String(req.LeaderName), LastIndex: proto.Uint64(req.LastIndex), LastTerm: proto.Uint64(req.LastTerm), } p, err := proto.Marshal(pb) if err != nil { return -1, err } return w.Write(p) }
[ "func", "(", "req", "*", "SnapshotRequest", ")", "Encode", "(", "w", "io", ".", "Writer", ")", "(", "int", ",", "error", ")", "{", "pb", ":=", "&", "protobuf", ".", "SnapshotRequest", "{", "LeaderName", ":", "proto", ".", "String", "(", "req", ".", ...
// Encodes the SnapshotRequest to a buffer. Returns the number of bytes // written and any error that may have occurred.
[ "Encodes", "the", "SnapshotRequest", "to", "a", "buffer", ".", "Returns", "the", "number", "of", "bytes", "written", "and", "any", "error", "that", "may", "have", "occurred", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/snapshot.go#L226-L238
147,906
goraft/raft
snapshot.go
Decode
func (req *SnapshotRequest) Decode(r io.Reader) (int, error) { data, err := ioutil.ReadAll(r) if err != nil { return 0, err } totalBytes := len(data) pb := &protobuf.SnapshotRequest{} if err := proto.Unmarshal(data, pb); err != nil { return -1, err } req.LeaderName = pb.GetLeaderName() req.LastIndex =...
go
func (req *SnapshotRequest) Decode(r io.Reader) (int, error) { data, err := ioutil.ReadAll(r) if err != nil { return 0, err } totalBytes := len(data) pb := &protobuf.SnapshotRequest{} if err := proto.Unmarshal(data, pb); err != nil { return -1, err } req.LeaderName = pb.GetLeaderName() req.LastIndex =...
[ "func", "(", "req", "*", "SnapshotRequest", ")", "Decode", "(", "r", "io", ".", "Reader", ")", "(", "int", ",", "error", ")", "{", "data", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "r", ")", "\n\n", "if", "err", "!=", "nil", "{", "return",...
// Decodes the SnapshotRequest from a buffer. Returns the number of bytes read and // any error that occurs.
[ "Decodes", "the", "SnapshotRequest", "from", "a", "buffer", ".", "Returns", "the", "number", "of", "bytes", "read", "and", "any", "error", "that", "occurs", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/snapshot.go#L242-L262
147,907
goraft/raft
snapshot.go
Encode
func (resp *SnapshotResponse) Encode(w io.Writer) (int, error) { pb := &protobuf.SnapshotResponse{ Success: proto.Bool(resp.Success), } p, err := proto.Marshal(pb) if err != nil { return -1, err } return w.Write(p) }
go
func (resp *SnapshotResponse) Encode(w io.Writer) (int, error) { pb := &protobuf.SnapshotResponse{ Success: proto.Bool(resp.Success), } p, err := proto.Marshal(pb) if err != nil { return -1, err } return w.Write(p) }
[ "func", "(", "resp", "*", "SnapshotResponse", ")", "Encode", "(", "w", "io", ".", "Writer", ")", "(", "int", ",", "error", ")", "{", "pb", ":=", "&", "protobuf", ".", "SnapshotResponse", "{", "Success", ":", "proto", ".", "Bool", "(", "resp", ".", ...
// Encodes the SnapshotResponse to a buffer. Returns the number of bytes // written and any error that may have occurred.
[ "Encodes", "the", "SnapshotResponse", "to", "a", "buffer", ".", "Returns", "the", "number", "of", "bytes", "written", "and", "any", "error", "that", "may", "have", "occurred", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/snapshot.go#L273-L283
147,908
goraft/raft
snapshot.go
Decode
func (resp *SnapshotResponse) Decode(r io.Reader) (int, error) { data, err := ioutil.ReadAll(r) if err != nil { return 0, err } totalBytes := len(data) pb := &protobuf.SnapshotResponse{} if err := proto.Unmarshal(data, pb); err != nil { return -1, err } resp.Success = pb.GetSuccess() return totalBytes...
go
func (resp *SnapshotResponse) Decode(r io.Reader) (int, error) { data, err := ioutil.ReadAll(r) if err != nil { return 0, err } totalBytes := len(data) pb := &protobuf.SnapshotResponse{} if err := proto.Unmarshal(data, pb); err != nil { return -1, err } resp.Success = pb.GetSuccess() return totalBytes...
[ "func", "(", "resp", "*", "SnapshotResponse", ")", "Decode", "(", "r", "io", ".", "Reader", ")", "(", "int", ",", "error", ")", "{", "data", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "r", ")", "\n\n", "if", "err", "!=", "nil", "{", "return...
// Decodes the SnapshotResponse from a buffer. Returns the number of bytes read and // any error that occurs.
[ "Decodes", "the", "SnapshotResponse", "from", "a", "buffer", ".", "Returns", "the", "number", "of", "bytes", "read", "and", "any", "error", "that", "occurs", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/snapshot.go#L287-L304
147,909
goraft/raft
log_entry.go
newLogEntry
func newLogEntry(log *Log, event *ev, index uint64, term uint64, command Command) (*LogEntry, error) { var buf bytes.Buffer var commandName string if command != nil { commandName = command.CommandName() if encoder, ok := command.(CommandEncoder); ok { if err := encoder.Encode(&buf); err != nil { return ni...
go
func newLogEntry(log *Log, event *ev, index uint64, term uint64, command Command) (*LogEntry, error) { var buf bytes.Buffer var commandName string if command != nil { commandName = command.CommandName() if encoder, ok := command.(CommandEncoder); ok { if err := encoder.Encode(&buf); err != nil { return ni...
[ "func", "newLogEntry", "(", "log", "*", "Log", ",", "event", "*", "ev", ",", "index", "uint64", ",", "term", "uint64", ",", "command", "Command", ")", "(", "*", "LogEntry", ",", "error", ")", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "var", ...
// Creates a new log entry associated with a log.
[ "Creates", "a", "new", "log", "entry", "associated", "with", "a", "log", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/log_entry.go#L22-L52
147,910
goraft/raft
log_entry.go
Encode
func (e *LogEntry) Encode(w io.Writer) (int, error) { b, err := proto.Marshal(e.pb) if err != nil { return -1, err } if _, err = fmt.Fprintf(w, "%8x\n", len(b)); err != nil { return -1, err } return w.Write(b) }
go
func (e *LogEntry) Encode(w io.Writer) (int, error) { b, err := proto.Marshal(e.pb) if err != nil { return -1, err } if _, err = fmt.Fprintf(w, "%8x\n", len(b)); err != nil { return -1, err } return w.Write(b) }
[ "func", "(", "e", "*", "LogEntry", ")", "Encode", "(", "w", "io", ".", "Writer", ")", "(", "int", ",", "error", ")", "{", "b", ",", "err", ":=", "proto", ".", "Marshal", "(", "e", ".", "pb", ")", "\n", "if", "err", "!=", "nil", "{", "return",...
// Encodes the log entry to a buffer. Returns the number of bytes // written and any error that may have occurred.
[ "Encodes", "the", "log", "entry", "to", "a", "buffer", ".", "Returns", "the", "number", "of", "bytes", "written", "and", "any", "error", "that", "may", "have", "occurred", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/log_entry.go#L72-L83
147,911
goraft/raft
log_entry.go
Decode
func (e *LogEntry) Decode(r io.Reader) (int, error) { var length int _, err := fmt.Fscanf(r, "%8x\n", &length) if err != nil { return -1, err } data := make([]byte, length) _, err = io.ReadFull(r, data) if err != nil { return -1, err } if err = proto.Unmarshal(data, e.pb); err != nil { return -1, err...
go
func (e *LogEntry) Decode(r io.Reader) (int, error) { var length int _, err := fmt.Fscanf(r, "%8x\n", &length) if err != nil { return -1, err } data := make([]byte, length) _, err = io.ReadFull(r, data) if err != nil { return -1, err } if err = proto.Unmarshal(data, e.pb); err != nil { return -1, err...
[ "func", "(", "e", "*", "LogEntry", ")", "Decode", "(", "r", "io", ".", "Reader", ")", "(", "int", ",", "error", ")", "{", "var", "length", "int", "\n", "_", ",", "err", ":=", "fmt", ".", "Fscanf", "(", "r", ",", "\"", "\\n", "\"", ",", "&", ...
// Decodes the log entry from a buffer. Returns the number of bytes read and // any error that occurs.
[ "Decodes", "the", "log", "entry", "from", "a", "buffer", ".", "Returns", "the", "number", "of", "bytes", "read", "and", "any", "error", "that", "occurs", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/log_entry.go#L87-L107
147,912
goraft/raft
util.go
afterBetween
func afterBetween(min time.Duration, max time.Duration) <-chan time.Time { rand := rand.New(rand.NewSource(time.Now().UnixNano())) d, delta := min, (max - min) if delta > 0 { d += time.Duration(rand.Int63n(int64(delta))) } return time.After(d) }
go
func afterBetween(min time.Duration, max time.Duration) <-chan time.Time { rand := rand.New(rand.NewSource(time.Now().UnixNano())) d, delta := min, (max - min) if delta > 0 { d += time.Duration(rand.Int63n(int64(delta))) } return time.After(d) }
[ "func", "afterBetween", "(", "min", "time", ".", "Duration", ",", "max", "time", ".", "Duration", ")", "<-", "chan", "time", ".", "Time", "{", "rand", ":=", "rand", ".", "New", "(", "rand", ".", "NewSource", "(", "time", ".", "Now", "(", ")", ".", ...
// Waits for a random time between two durations and sends the current time on // the returned channel.
[ "Waits", "for", "a", "random", "time", "between", "two", "durations", "and", "sends", "the", "current", "time", "on", "the", "returned", "channel", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/util.go#L46-L53
147,913
goraft/raft
command.go
newCommand
func newCommand(name string, data []byte) (Command, error) { // Find the registered command. command := commandTypes[name] if command == nil { return nil, fmt.Errorf("raft.Command: Unregistered command type: %s", name) } // Make a copy of the command. v := reflect.New(reflect.Indirect(reflect.ValueOf(command))...
go
func newCommand(name string, data []byte) (Command, error) { // Find the registered command. command := commandTypes[name] if command == nil { return nil, fmt.Errorf("raft.Command: Unregistered command type: %s", name) } // Make a copy of the command. v := reflect.New(reflect.Indirect(reflect.ValueOf(command))...
[ "func", "newCommand", "(", "name", "string", ",", "data", "[", "]", "byte", ")", "(", "Command", ",", "error", ")", "{", "// Find the registered command.", "command", ":=", "commandTypes", "[", "name", "]", "\n", "if", "command", "==", "nil", "{", "return"...
// Creates a new instance of a command by name.
[ "Creates", "a", "new", "instance", "of", "a", "command", "by", "name", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/command.go#L38-L66
147,914
goraft/raft
command.go
RegisterCommand
func RegisterCommand(command Command) { if command == nil { panic(fmt.Sprintf("raft: Cannot register nil")) } else if commandTypes[command.CommandName()] != nil { panic(fmt.Sprintf("raft: Duplicate registration: %s", command.CommandName())) } commandTypes[command.CommandName()] = command }
go
func RegisterCommand(command Command) { if command == nil { panic(fmt.Sprintf("raft: Cannot register nil")) } else if commandTypes[command.CommandName()] != nil { panic(fmt.Sprintf("raft: Duplicate registration: %s", command.CommandName())) } commandTypes[command.CommandName()] = command }
[ "func", "RegisterCommand", "(", "command", "Command", ")", "{", "if", "command", "==", "nil", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ")", ")", "\n", "}", "else", "if", "commandTypes", "[", "command", ".", "CommandName", "(", ")", ...
// Registers a command by storing a reference to an instance of it.
[ "Registers", "a", "command", "by", "storing", "a", "reference", "to", "an", "instance", "of", "it", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/command.go#L69-L76
147,915
goraft/raft
http_transporter.go
SendVoteRequest
func (t *HTTPTransporter) SendVoteRequest(server Server, peer *Peer, req *RequestVoteRequest) *RequestVoteResponse { var b bytes.Buffer if _, err := req.Encode(&b); err != nil { traceln("transporter.rv.encoding.error:", err) return nil } url := fmt.Sprintf("%s%s", peer.ConnectionString, t.RequestVotePath()) t...
go
func (t *HTTPTransporter) SendVoteRequest(server Server, peer *Peer, req *RequestVoteRequest) *RequestVoteResponse { var b bytes.Buffer if _, err := req.Encode(&b); err != nil { traceln("transporter.rv.encoding.error:", err) return nil } url := fmt.Sprintf("%s%s", peer.ConnectionString, t.RequestVotePath()) t...
[ "func", "(", "t", "*", "HTTPTransporter", ")", "SendVoteRequest", "(", "server", "Server", ",", "peer", "*", "Peer", ",", "req", "*", "RequestVoteRequest", ")", "*", "RequestVoteResponse", "{", "var", "b", "bytes", ".", "Buffer", "\n", "if", "_", ",", "e...
// Sends a RequestVote RPC to a peer.
[ "Sends", "a", "RequestVote", "RPC", "to", "a", "peer", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/http_transporter.go#L142-L166
147,916
goraft/raft
append_entries.go
newAppendEntriesRequest
func newAppendEntriesRequest(term uint64, prevLogIndex uint64, prevLogTerm uint64, commitIndex uint64, leaderName string, entries []*LogEntry) *AppendEntriesRequest { pbEntries := make([]*protobuf.LogEntry, len(entries)) for i := range entries { pbEntries[i] = entries[i].pb } return &AppendEntriesRequest{ Te...
go
func newAppendEntriesRequest(term uint64, prevLogIndex uint64, prevLogTerm uint64, commitIndex uint64, leaderName string, entries []*LogEntry) *AppendEntriesRequest { pbEntries := make([]*protobuf.LogEntry, len(entries)) for i := range entries { pbEntries[i] = entries[i].pb } return &AppendEntriesRequest{ Te...
[ "func", "newAppendEntriesRequest", "(", "term", "uint64", ",", "prevLogIndex", "uint64", ",", "prevLogTerm", "uint64", ",", "commitIndex", "uint64", ",", "leaderName", "string", ",", "entries", "[", "]", "*", "LogEntry", ")", "*", "AppendEntriesRequest", "{", "p...
// Creates a new AppendEntries request.
[ "Creates", "a", "new", "AppendEntries", "request", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/append_entries.go#L29-L45
147,917
goraft/raft
append_entries.go
Encode
func (req *AppendEntriesRequest) Encode(w io.Writer) (int, error) { pb := &protobuf.AppendEntriesRequest{ Term: proto.Uint64(req.Term), PrevLogIndex: proto.Uint64(req.PrevLogIndex), PrevLogTerm: proto.Uint64(req.PrevLogTerm), CommitIndex: proto.Uint64(req.CommitIndex), LeaderName: proto.String(re...
go
func (req *AppendEntriesRequest) Encode(w io.Writer) (int, error) { pb := &protobuf.AppendEntriesRequest{ Term: proto.Uint64(req.Term), PrevLogIndex: proto.Uint64(req.PrevLogIndex), PrevLogTerm: proto.Uint64(req.PrevLogTerm), CommitIndex: proto.Uint64(req.CommitIndex), LeaderName: proto.String(re...
[ "func", "(", "req", "*", "AppendEntriesRequest", ")", "Encode", "(", "w", "io", ".", "Writer", ")", "(", "int", ",", "error", ")", "{", "pb", ":=", "&", "protobuf", ".", "AppendEntriesRequest", "{", "Term", ":", "proto", ".", "Uint64", "(", "req", "....
// Encodes the AppendEntriesRequest to a buffer. Returns the number of bytes // written and any error that may have occurred.
[ "Encodes", "the", "AppendEntriesRequest", "to", "a", "buffer", ".", "Returns", "the", "number", "of", "bytes", "written", "and", "any", "error", "that", "may", "have", "occurred", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/append_entries.go#L49-L65
147,918
goraft/raft
append_entries.go
Decode
func (req *AppendEntriesRequest) Decode(r io.Reader) (int, error) { data, err := ioutil.ReadAll(r) if err != nil { return -1, err } pb := new(protobuf.AppendEntriesRequest) if err := proto.Unmarshal(data, pb); err != nil { return -1, err } req.Term = pb.GetTerm() req.PrevLogIndex = pb.GetPrevLogIndex() ...
go
func (req *AppendEntriesRequest) Decode(r io.Reader) (int, error) { data, err := ioutil.ReadAll(r) if err != nil { return -1, err } pb := new(protobuf.AppendEntriesRequest) if err := proto.Unmarshal(data, pb); err != nil { return -1, err } req.Term = pb.GetTerm() req.PrevLogIndex = pb.GetPrevLogIndex() ...
[ "func", "(", "req", "*", "AppendEntriesRequest", ")", "Decode", "(", "r", "io", ".", "Reader", ")", "(", "int", ",", "error", ")", "{", "data", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "r", ")", "\n\n", "if", "err", "!=", "nil", "{", "ret...
// Decodes the AppendEntriesRequest from a buffer. Returns the number of bytes read and // any error that occurs.
[ "Decodes", "the", "AppendEntriesRequest", "from", "a", "buffer", ".", "Returns", "the", "number", "of", "bytes", "read", "and", "any", "error", "that", "occurs", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/append_entries.go#L69-L89
147,919
goraft/raft
append_entries.go
newAppendEntriesResponse
func newAppendEntriesResponse(term uint64, success bool, index uint64, commitIndex uint64) *AppendEntriesResponse { pb := &protobuf.AppendEntriesResponse{ Term: proto.Uint64(term), Index: proto.Uint64(index), Success: proto.Bool(success), CommitIndex: proto.Uint64(commitIndex), } return &Ap...
go
func newAppendEntriesResponse(term uint64, success bool, index uint64, commitIndex uint64) *AppendEntriesResponse { pb := &protobuf.AppendEntriesResponse{ Term: proto.Uint64(term), Index: proto.Uint64(index), Success: proto.Bool(success), CommitIndex: proto.Uint64(commitIndex), } return &Ap...
[ "func", "newAppendEntriesResponse", "(", "term", "uint64", ",", "success", "bool", ",", "index", "uint64", ",", "commitIndex", "uint64", ")", "*", "AppendEntriesResponse", "{", "pb", ":=", "&", "protobuf", ".", "AppendEntriesResponse", "{", "Term", ":", "proto",...
// Creates a new AppendEntries response.
[ "Creates", "a", "new", "AppendEntries", "response", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/append_entries.go#L92-L103
147,920
goraft/raft
append_entries.go
Encode
func (resp *AppendEntriesResponse) Encode(w io.Writer) (int, error) { b, err := proto.Marshal(resp.pb) if err != nil { return -1, err } return w.Write(b) }
go
func (resp *AppendEntriesResponse) Encode(w io.Writer) (int, error) { b, err := proto.Marshal(resp.pb) if err != nil { return -1, err } return w.Write(b) }
[ "func", "(", "resp", "*", "AppendEntriesResponse", ")", "Encode", "(", "w", "io", ".", "Writer", ")", "(", "int", ",", "error", ")", "{", "b", ",", "err", ":=", "proto", ".", "Marshal", "(", "resp", ".", "pb", ")", "\n", "if", "err", "!=", "nil",...
// Encodes the AppendEntriesResponse to a buffer. Returns the number of bytes // written and any error that may have occurred.
[ "Encodes", "the", "AppendEntriesResponse", "to", "a", "buffer", ".", "Returns", "the", "number", "of", "bytes", "written", "and", "any", "error", "that", "may", "have", "occurred", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/append_entries.go#L123-L130
147,921
goraft/raft
append_entries.go
Decode
func (resp *AppendEntriesResponse) Decode(r io.Reader) (int, error) { data, err := ioutil.ReadAll(r) if err != nil { return -1, err } resp.pb = new(protobuf.AppendEntriesResponse) if err := proto.Unmarshal(data, resp.pb); err != nil { return -1, err } return len(data), nil }
go
func (resp *AppendEntriesResponse) Decode(r io.Reader) (int, error) { data, err := ioutil.ReadAll(r) if err != nil { return -1, err } resp.pb = new(protobuf.AppendEntriesResponse) if err := proto.Unmarshal(data, resp.pb); err != nil { return -1, err } return len(data), nil }
[ "func", "(", "resp", "*", "AppendEntriesResponse", ")", "Decode", "(", "r", "io", ".", "Reader", ")", "(", "int", ",", "error", ")", "{", "data", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "r", ")", "\n", "if", "err", "!=", "nil", "{", "ret...
// Decodes the AppendEntriesResponse from a buffer. Returns the number of bytes read and // any error that occurs.
[ "Decodes", "the", "AppendEntriesResponse", "from", "a", "buffer", ".", "Returns", "the", "number", "of", "bytes", "read", "and", "any", "error", "that", "occurs", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/append_entries.go#L134-L146
147,922
goraft/raft
server.go
Peers
func (s *server) Peers() map[string]*Peer { s.mutex.Lock() defer s.mutex.Unlock() peers := make(map[string]*Peer) for name, peer := range s.peers { peers[name] = peer.clone() } return peers }
go
func (s *server) Peers() map[string]*Peer { s.mutex.Lock() defer s.mutex.Unlock() peers := make(map[string]*Peer) for name, peer := range s.peers { peers[name] = peer.clone() } return peers }
[ "func", "(", "s", "*", "server", ")", "Peers", "(", ")", "map", "[", "string", "]", "*", "Peer", "{", "s", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mutex", ".", "Unlock", "(", ")", "\n\n", "peers", ":=", "make", "(", "ma...
// Retrieves a copy of the peer data.
[ "Retrieves", "a", "copy", "of", "the", "peer", "data", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/server.go#L241-L250
147,923
goraft/raft
server.go
Transporter
func (s *server) Transporter() Transporter { s.mutex.RLock() defer s.mutex.RUnlock() return s.transporter }
go
func (s *server) Transporter() Transporter { s.mutex.RLock() defer s.mutex.RUnlock() return s.transporter }
[ "func", "(", "s", "*", "server", ")", "Transporter", "(", ")", "Transporter", "{", "s", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "mutex", ".", "RUnlock", "(", ")", "\n", "return", "s", ".", "transporter", "\n", "}" ]
// Retrieves the object that transports requests.
[ "Retrieves", "the", "object", "that", "transports", "requests", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/server.go#L253-L257
147,924
goraft/raft
server.go
State
func (s *server) State() string { s.mutex.RLock() defer s.mutex.RUnlock() return s.state }
go
func (s *server) State() string { s.mutex.RLock() defer s.mutex.RUnlock() return s.state }
[ "func", "(", "s", "*", "server", ")", "State", "(", ")", "string", "{", "s", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "mutex", ".", "RUnlock", "(", ")", "\n", "return", "s", ".", "state", "\n", "}" ]
// Retrieves the current state of the server.
[ "Retrieves", "the", "current", "state", "of", "the", "server", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/server.go#L281-L285
147,925
goraft/raft
server.go
setState
func (s *server) setState(state string) { s.mutex.Lock() defer s.mutex.Unlock() // Temporarily store previous values. prevState := s.state prevLeader := s.leader // Update state and leader. s.state = state if state == Leader { s.leader = s.Name() s.syncedPeer = make(map[string]bool) } // Dispatch state...
go
func (s *server) setState(state string) { s.mutex.Lock() defer s.mutex.Unlock() // Temporarily store previous values. prevState := s.state prevLeader := s.leader // Update state and leader. s.state = state if state == Leader { s.leader = s.Name() s.syncedPeer = make(map[string]bool) } // Dispatch state...
[ "func", "(", "s", "*", "server", ")", "setState", "(", "state", "string", ")", "{", "s", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mutex", ".", "Unlock", "(", ")", "\n\n", "// Temporarily store previous values.", "prevState", ":=", ...
// Sets the state of the server.
[ "Sets", "the", "state", "of", "the", "server", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/server.go#L288-L309
147,926
goraft/raft
server.go
Term
func (s *server) Term() uint64 { s.mutex.RLock() defer s.mutex.RUnlock() return s.currentTerm }
go
func (s *server) Term() uint64 { s.mutex.RLock() defer s.mutex.RUnlock() return s.currentTerm }
[ "func", "(", "s", "*", "server", ")", "Term", "(", ")", "uint64", "{", "s", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "mutex", ".", "RUnlock", "(", ")", "\n", "return", "s", ".", "currentTerm", "\n", "}" ]
// Retrieves the current term of the server.
[ "Retrieves", "the", "current", "term", "of", "the", "server", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/server.go#L312-L316
147,927
goraft/raft
server.go
CommitIndex
func (s *server) CommitIndex() uint64 { s.log.mutex.RLock() defer s.log.mutex.RUnlock() return s.log.commitIndex }
go
func (s *server) CommitIndex() uint64 { s.log.mutex.RLock() defer s.log.mutex.RUnlock() return s.log.commitIndex }
[ "func", "(", "s", "*", "server", ")", "CommitIndex", "(", ")", "uint64", "{", "s", ".", "log", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "log", ".", "mutex", ".", "RUnlock", "(", ")", "\n", "return", "s", ".", "log", ".", ...
// Retrieves the current commit index of the server.
[ "Retrieves", "the", "current", "commit", "index", "of", "the", "server", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/server.go#L319-L323
147,928
goraft/raft
server.go
LogEntries
func (s *server) LogEntries() []*LogEntry { s.log.mutex.RLock() defer s.log.mutex.RUnlock() return s.log.entries }
go
func (s *server) LogEntries() []*LogEntry { s.log.mutex.RLock() defer s.log.mutex.RUnlock() return s.log.entries }
[ "func", "(", "s", "*", "server", ")", "LogEntries", "(", ")", "[", "]", "*", "LogEntry", "{", "s", ".", "log", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "log", ".", "mutex", ".", "RUnlock", "(", ")", "\n", "return", "s", ...
// A list of all the log entries. This should only be used for debugging purposes.
[ "A", "list", "of", "all", "the", "log", "entries", ".", "This", "should", "only", "be", "used", "for", "debugging", "purposes", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/server.go#L336-L340
147,929
goraft/raft
server.go
GetState
func (s *server) GetState() string { s.mutex.RLock() defer s.mutex.RUnlock() return fmt.Sprintf("Name: %s, State: %s, Term: %v, CommitedIndex: %v ", s.name, s.state, s.currentTerm, s.log.commitIndex) }
go
func (s *server) GetState() string { s.mutex.RLock() defer s.mutex.RUnlock() return fmt.Sprintf("Name: %s, State: %s, Term: %v, CommitedIndex: %v ", s.name, s.state, s.currentTerm, s.log.commitIndex) }
[ "func", "(", "s", "*", "server", ")", "GetState", "(", ")", "string", "{", "s", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "mutex", ".", "RUnlock", "(", ")", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "s", ...
// Get the state of the server for debugging
[ "Get", "the", "state", "of", "the", "server", "for", "debugging" ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/server.go#L348-L352
147,930
goraft/raft
server.go
SetElectionTimeout
func (s *server) SetElectionTimeout(duration time.Duration) { s.mutex.Lock() defer s.mutex.Unlock() s.electionTimeout = duration }
go
func (s *server) SetElectionTimeout(duration time.Duration) { s.mutex.Lock() defer s.mutex.Unlock() s.electionTimeout = duration }
[ "func", "(", "s", "*", "server", ")", "SetElectionTimeout", "(", "duration", "time", ".", "Duration", ")", "{", "s", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mutex", ".", "Unlock", "(", ")", "\n", "s", ".", "electionTimeout", ...
// Sets the election timeout.
[ "Sets", "the", "election", "timeout", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/server.go#L387-L391
147,931
goraft/raft
server.go
SetHeartbeatInterval
func (s *server) SetHeartbeatInterval(duration time.Duration) { s.mutex.Lock() defer s.mutex.Unlock() s.heartbeatInterval = duration for _, peer := range s.peers { peer.setHeartbeatInterval(duration) } }
go
func (s *server) SetHeartbeatInterval(duration time.Duration) { s.mutex.Lock() defer s.mutex.Unlock() s.heartbeatInterval = duration for _, peer := range s.peers { peer.setHeartbeatInterval(duration) } }
[ "func", "(", "s", "*", "server", ")", "SetHeartbeatInterval", "(", "duration", "time", ".", "Duration", ")", "{", "s", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mutex", ".", "Unlock", "(", ")", "\n\n", "s", ".", "heartbeatInterva...
// Sets the heartbeat timeout.
[ "Sets", "the", "heartbeat", "timeout", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/server.go#L405-L413
147,932
goraft/raft
server.go
Start
func (s *server) Start() error { // Exit if the server is already running. if s.Running() { return fmt.Errorf("raft.Server: Server already running[%v]", s.state) } if err := s.Init(); err != nil { return err } // stopped needs to be allocated each time server starts // because it is closed at `Stop`. s.st...
go
func (s *server) Start() error { // Exit if the server is already running. if s.Running() { return fmt.Errorf("raft.Server: Server already running[%v]", s.state) } if err := s.Init(); err != nil { return err } // stopped needs to be allocated each time server starts // because it is closed at `Stop`. s.st...
[ "func", "(", "s", "*", "server", ")", "Start", "(", ")", "error", "{", "// Exit if the server is already running.", "if", "s", ".", "Running", "(", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "s", ".", "state", ")", "\n", "}", "\n...
// Start the raft server // If log entries exist then allow promotion to candidate if no AEs received. // If no log entries exist then wait for AEs from another node. // If no log entries exist and a self-join command is issued then // immediately become leader and commit entry.
[ "Start", "the", "raft", "server", "If", "log", "entries", "exist", "then", "allow", "promotion", "to", "candidate", "if", "no", "AEs", "received", ".", "If", "no", "log", "entries", "exist", "then", "wait", "for", "AEs", "from", "another", "node", ".", "...
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/server.go#L437-L474
147,933
goraft/raft
server.go
Stop
func (s *server) Stop() { if s.State() == Stopped { return } close(s.stopped) // make sure all goroutines have stopped before we close the log s.routineGroup.Wait() s.log.close() s.setState(Stopped) }
go
func (s *server) Stop() { if s.State() == Stopped { return } close(s.stopped) // make sure all goroutines have stopped before we close the log s.routineGroup.Wait() s.log.close() s.setState(Stopped) }
[ "func", "(", "s", "*", "server", ")", "Stop", "(", ")", "{", "if", "s", ".", "State", "(", ")", "==", "Stopped", "{", "return", "\n", "}", "\n\n", "close", "(", "s", ".", "stopped", ")", "\n\n", "// make sure all goroutines have stopped before we close the...
// Shuts down the server.
[ "Shuts", "down", "the", "server", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/server.go#L518-L530
147,934
goraft/raft
server.go
Running
func (s *server) Running() bool { s.mutex.RLock() defer s.mutex.RUnlock() return (s.state != Stopped && s.state != Initialized) }
go
func (s *server) Running() bool { s.mutex.RLock() defer s.mutex.RUnlock() return (s.state != Stopped && s.state != Initialized) }
[ "func", "(", "s", "*", "server", ")", "Running", "(", ")", "bool", "{", "s", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "mutex", ".", "RUnlock", "(", ")", "\n", "return", "(", "s", ".", "state", "!=", "Stopped", "&&", "s", ...
// Checks if the server is currently running.
[ "Checks", "if", "the", "server", "is", "currently", "running", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/server.go#L533-L537
147,935
goraft/raft
server.go
send
func (s *server) send(value interface{}) (interface{}, error) { if !s.Running() { return nil, StopError } event := &ev{target: value, c: make(chan error, 1)} select { case s.c <- event: case <-s.stopped: return nil, StopError } select { case <-s.stopped: return nil, StopError case err := <-event.c: r...
go
func (s *server) send(value interface{}) (interface{}, error) { if !s.Running() { return nil, StopError } event := &ev{target: value, c: make(chan error, 1)} select { case s.c <- event: case <-s.stopped: return nil, StopError } select { case <-s.stopped: return nil, StopError case err := <-event.c: r...
[ "func", "(", "s", "*", "server", ")", "send", "(", "value", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "if", "!", "s", ".", "Running", "(", ")", "{", "return", "nil", ",", "StopError", "\n", "}", "\n\n", "ev...
// Sends an event to the event loop to be processed. The function will wait // until the event is actually processed before returning.
[ "Sends", "an", "event", "to", "the", "event", "loop", "to", "be", "processed", ".", "The", "function", "will", "wait", "until", "the", "event", "is", "actually", "processed", "before", "returning", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/server.go#L619-L636
147,936
goraft/raft
server.go
candidateLoop
func (s *server) candidateLoop() { // Clear leader value. prevLeader := s.leader s.leader = "" if prevLeader != s.leader { s.DispatchEvent(newEvent(LeaderChangeEventType, s.leader, prevLeader)) } lastLogIndex, lastLogTerm := s.log.lastInfo() doVote := true votesGranted := 0 var timeoutChan <-chan time.Time ...
go
func (s *server) candidateLoop() { // Clear leader value. prevLeader := s.leader s.leader = "" if prevLeader != s.leader { s.DispatchEvent(newEvent(LeaderChangeEventType, s.leader, prevLeader)) } lastLogIndex, lastLogTerm := s.log.lastInfo() doVote := true votesGranted := 0 var timeoutChan <-chan time.Time ...
[ "func", "(", "s", "*", "server", ")", "candidateLoop", "(", ")", "{", "// Clear leader value.", "prevLeader", ":=", "s", ".", "leader", "\n", "s", ".", "leader", "=", "\"", "\"", "\n", "if", "prevLeader", "!=", "s", ".", "leader", "{", "s", ".", "Dis...
// The event loop that is run when the server is in a Candidate state.
[ "The", "event", "loop", "that", "is", "run", "when", "the", "server", "is", "in", "a", "Candidate", "state", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/server.go#L730-L808
147,937
goraft/raft
server.go
leaderLoop
func (s *server) leaderLoop() { logIndex, _ := s.log.lastInfo() // Update the peers prevLogIndex to leader's lastLogIndex and start heartbeat. s.debugln("leaderLoop.set.PrevIndex to ", logIndex) for _, peer := range s.peers { peer.setPrevLogIndex(logIndex) peer.startHeartbeat() } // Commit a NOP after the s...
go
func (s *server) leaderLoop() { logIndex, _ := s.log.lastInfo() // Update the peers prevLogIndex to leader's lastLogIndex and start heartbeat. s.debugln("leaderLoop.set.PrevIndex to ", logIndex) for _, peer := range s.peers { peer.setPrevLogIndex(logIndex) peer.startHeartbeat() } // Commit a NOP after the s...
[ "func", "(", "s", "*", "server", ")", "leaderLoop", "(", ")", "{", "logIndex", ",", "_", ":=", "s", ".", "log", ".", "lastInfo", "(", ")", "\n\n", "// Update the peers prevLogIndex to leader's lastLogIndex and start heartbeat.", "s", ".", "debugln", "(", "\"", ...
// The event loop that is run when the server is in a Leader state.
[ "The", "event", "loop", "that", "is", "run", "when", "the", "server", "is", "in", "a", "Leader", "state", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/server.go#L811-L862
147,938
goraft/raft
server.go
processCommand
func (s *server) processCommand(command Command, e *ev) { s.debugln("server.command.process") // Create an entry for the command in the log. entry, err := s.log.createEntry(s.currentTerm, command, e) if err != nil { s.debugln("server.command.log.entry.error:", err) e.c <- err return } if err := s.log.app...
go
func (s *server) processCommand(command Command, e *ev) { s.debugln("server.command.process") // Create an entry for the command in the log. entry, err := s.log.createEntry(s.currentTerm, command, e) if err != nil { s.debugln("server.command.log.entry.error:", err) e.c <- err return } if err := s.log.app...
[ "func", "(", "s", "*", "server", ")", "processCommand", "(", "command", "Command", ",", "e", "*", "ev", ")", "{", "s", ".", "debugln", "(", "\"", "\"", ")", "\n\n", "// Create an entry for the command in the log.", "entry", ",", "err", ":=", "s", ".", "l...
// Processes a command.
[ "Processes", "a", "command", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/server.go#L901-L925
147,939
goraft/raft
server.go
processAppendEntriesRequest
func (s *server) processAppendEntriesRequest(req *AppendEntriesRequest) (*AppendEntriesResponse, bool) { s.traceln("server.ae.process") if req.Term < s.currentTerm { s.debugln("server.ae.error: stale term") return newAppendEntriesResponse(s.currentTerm, false, s.log.currentIndex(), s.log.CommitIndex()), false }...
go
func (s *server) processAppendEntriesRequest(req *AppendEntriesRequest) (*AppendEntriesResponse, bool) { s.traceln("server.ae.process") if req.Term < s.currentTerm { s.debugln("server.ae.error: stale term") return newAppendEntriesResponse(s.currentTerm, false, s.log.currentIndex(), s.log.CommitIndex()), false }...
[ "func", "(", "s", "*", "server", ")", "processAppendEntriesRequest", "(", "req", "*", "AppendEntriesRequest", ")", "(", "*", "AppendEntriesResponse", ",", "bool", ")", "{", "s", ".", "traceln", "(", "\"", "\"", ")", "\n\n", "if", "req", ".", "Term", "<",...
// Processes the "append entries" request.
[ "Processes", "the", "append", "entries", "request", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/server.go#L939-L985
147,940
goraft/raft
server.go
processAppendEntriesResponse
func (s *server) processAppendEntriesResponse(resp *AppendEntriesResponse) { // If we find a higher term then change to a follower and exit. if resp.Term() > s.Term() { s.updateCurrentTerm(resp.Term(), "") return } // panic response if it's not successful. if !resp.Success() { return } // if one peer suc...
go
func (s *server) processAppendEntriesResponse(resp *AppendEntriesResponse) { // If we find a higher term then change to a follower and exit. if resp.Term() > s.Term() { s.updateCurrentTerm(resp.Term(), "") return } // panic response if it's not successful. if !resp.Success() { return } // if one peer suc...
[ "func", "(", "s", "*", "server", ")", "processAppendEntriesResponse", "(", "resp", "*", "AppendEntriesResponse", ")", "{", "// If we find a higher term then change to a follower and exit.", "if", "resp", ".", "Term", "(", ")", ">", "s", ".", "Term", "(", ")", "{",...
// Processes the "append entries" response from the peer. This is only // processed when the server is a leader. Responses received during other // states are dropped.
[ "Processes", "the", "append", "entries", "response", "from", "the", "peer", ".", "This", "is", "only", "processed", "when", "the", "server", "is", "a", "leader", ".", "Responses", "received", "during", "other", "states", "are", "dropped", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/server.go#L990-L1031
147,941
goraft/raft
server.go
processRequestVoteRequest
func (s *server) processRequestVoteRequest(req *RequestVoteRequest) (*RequestVoteResponse, bool) { // If the request is coming from an old term then reject it. if req.Term < s.Term() { s.debugln("server.rv.deny.vote: cause stale term") return newRequestVoteResponse(s.currentTerm, false), false } // If the ter...
go
func (s *server) processRequestVoteRequest(req *RequestVoteRequest) (*RequestVoteResponse, bool) { // If the request is coming from an old term then reject it. if req.Term < s.Term() { s.debugln("server.rv.deny.vote: cause stale term") return newRequestVoteResponse(s.currentTerm, false), false } // If the ter...
[ "func", "(", "s", "*", "server", ")", "processRequestVoteRequest", "(", "req", "*", "RequestVoteRequest", ")", "(", "*", "RequestVoteResponse", ",", "bool", ")", "{", "// If the request is coming from an old term then reject it.", "if", "req", ".", "Term", "<", "s",...
// Processes a "request vote" request.
[ "Processes", "a", "request", "vote", "request", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/server.go#L1066-L1099
147,942
goraft/raft
server.go
RemovePeer
func (s *server) RemovePeer(name string) error { s.debugln("server.peer.remove: ", name, len(s.peers)) // Skip the Peer if it has the same name as the Server if name != s.Name() { // Return error if peer doesn't exist. peer := s.peers[name] if peer == nil { return fmt.Errorf("raft: Peer not found: %s", nam...
go
func (s *server) RemovePeer(name string) error { s.debugln("server.peer.remove: ", name, len(s.peers)) // Skip the Peer if it has the same name as the Server if name != s.Name() { // Return error if peer doesn't exist. peer := s.peers[name] if peer == nil { return fmt.Errorf("raft: Peer not found: %s", nam...
[ "func", "(", "s", "*", "server", ")", "RemovePeer", "(", "name", "string", ")", "error", "{", "s", ".", "debugln", "(", "\"", "\"", ",", "name", ",", "len", "(", "s", ".", "peers", ")", ")", "\n\n", "// Skip the Peer if it has the same name as the Server",...
// Removes a peer from the server.
[ "Removes", "a", "peer", "from", "the", "server", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/server.go#L1134-L1171
147,943
goraft/raft
server.go
LoadSnapshot
func (s *server) LoadSnapshot() error { // Open snapshot/ directory. dir, err := os.OpenFile(path.Join(s.path, "snapshot"), os.O_RDONLY, 0) if err != nil { s.debugln("cannot.open.snapshot: ", err) return err } // Retrieve a list of all snapshots. filenames, err := dir.Readdirnames(-1) if err != nil { dir....
go
func (s *server) LoadSnapshot() error { // Open snapshot/ directory. dir, err := os.OpenFile(path.Join(s.path, "snapshot"), os.O_RDONLY, 0) if err != nil { s.debugln("cannot.open.snapshot: ", err) return err } // Retrieve a list of all snapshots. filenames, err := dir.Readdirnames(-1) if err != nil { dir....
[ "func", "(", "s", "*", "server", ")", "LoadSnapshot", "(", ")", "error", "{", "// Open snapshot/ directory.", "dir", ",", "err", ":=", "os", ".", "OpenFile", "(", "path", ".", "Join", "(", "s", ".", "path", ",", "\"", "\"", ")", ",", "os", ".", "O_...
// Load a snapshot at restart
[ "Load", "a", "snapshot", "at", "restart" ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/server.go#L1316-L1393
147,944
goraft/raft
server.go
readConf
func (s *server) readConf() error { confPath := path.Join(s.path, "conf") s.debugln("readConf.open ", confPath) // open conf file b, err := ioutil.ReadFile(confPath) if err != nil { return nil } conf := &Config{} if err = json.Unmarshal(b, conf); err != nil { return err } s.log.updateCommitIndex(conf...
go
func (s *server) readConf() error { confPath := path.Join(s.path, "conf") s.debugln("readConf.open ", confPath) // open conf file b, err := ioutil.ReadFile(confPath) if err != nil { return nil } conf := &Config{} if err = json.Unmarshal(b, conf); err != nil { return err } s.log.updateCommitIndex(conf...
[ "func", "(", "s", "*", "server", ")", "readConf", "(", ")", "error", "{", "confPath", ":=", "path", ".", "Join", "(", "s", ".", "path", ",", "\"", "\"", ")", "\n", "s", ".", "debugln", "(", "\"", "\"", ",", "confPath", ")", "\n\n", "// open conf ...
// Read the configuration for the server.
[ "Read", "the", "configuration", "for", "the", "server", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/server.go#L1437-L1457
147,945
goraft/raft
event.go
newEvent
func newEvent(typ string, value interface{}, prevValue interface{}) *event { return &event{ typ: typ, value: value, prevValue: prevValue, } }
go
func newEvent(typ string, value interface{}, prevValue interface{}) *event { return &event{ typ: typ, value: value, prevValue: prevValue, } }
[ "func", "newEvent", "(", "typ", "string", ",", "value", "interface", "{", "}", ",", "prevValue", "interface", "{", "}", ")", "*", "event", "{", "return", "&", "event", "{", "typ", ":", "typ", ",", "value", ":", "value", ",", "prevValue", ":", "prevVa...
// newEvent creates a new event.
[ "newEvent", "creates", "a", "new", "event", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/event.go#L35-L41
147,946
goraft/raft
peer.go
setPrevLogIndex
func (p *Peer) setPrevLogIndex(value uint64) { p.Lock() defer p.Unlock() p.prevLogIndex = value }
go
func (p *Peer) setPrevLogIndex(value uint64) { p.Lock() defer p.Unlock() p.prevLogIndex = value }
[ "func", "(", "p", "*", "Peer", ")", "setPrevLogIndex", "(", "value", "uint64", ")", "{", "p", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "Unlock", "(", ")", "\n", "p", ".", "prevLogIndex", "=", "value", "\n", "}" ]
// Sets the previous log index.
[ "Sets", "the", "previous", "log", "index", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/peer.go#L65-L69
147,947
goraft/raft
peer.go
stopHeartbeat
func (p *Peer) stopHeartbeat(flush bool) { p.setLastActivity(time.Time{}) p.stopChan <- flush }
go
func (p *Peer) stopHeartbeat(flush bool) { p.setLastActivity(time.Time{}) p.stopChan <- flush }
[ "func", "(", "p", "*", "Peer", ")", "stopHeartbeat", "(", "flush", "bool", ")", "{", "p", ".", "setLastActivity", "(", "time", ".", "Time", "{", "}", ")", "\n\n", "p", ".", "stopChan", "<-", "flush", "\n", "}" ]
// Stops the peer heartbeat.
[ "Stops", "the", "peer", "heartbeat", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/peer.go#L103-L107
147,948
goraft/raft
peer.go
LastActivity
func (p *Peer) LastActivity() time.Time { p.RLock() defer p.RUnlock() return p.lastActivity }
go
func (p *Peer) LastActivity() time.Time { p.RLock() defer p.RUnlock() return p.lastActivity }
[ "func", "(", "p", "*", "Peer", ")", "LastActivity", "(", ")", "time", ".", "Time", "{", "p", ".", "RLock", "(", ")", "\n", "defer", "p", ".", "RUnlock", "(", ")", "\n", "return", "p", ".", "lastActivity", "\n", "}" ]
// LastActivity returns the last time any response was received from the peer.
[ "LastActivity", "returns", "the", "last", "time", "any", "response", "was", "received", "from", "the", "peer", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/peer.go#L110-L114
147,949
goraft/raft
peer.go
sendSnapshotRequest
func (p *Peer) sendSnapshotRequest(req *SnapshotRequest) { debugln("peer.snap.send: ", p.Name) resp := p.server.Transporter().SendSnapshotRequest(p.server, p, req) if resp == nil { debugln("peer.snap.timeout: ", p.Name) return } debugln("peer.snap.recv: ", p.Name) // If successful, the peer should have bee...
go
func (p *Peer) sendSnapshotRequest(req *SnapshotRequest) { debugln("peer.snap.send: ", p.Name) resp := p.server.Transporter().SendSnapshotRequest(p.server, p, req) if resp == nil { debugln("peer.snap.timeout: ", p.Name) return } debugln("peer.snap.recv: ", p.Name) // If successful, the peer should have bee...
[ "func", "(", "p", "*", "Peer", ")", "sendSnapshotRequest", "(", "req", "*", "SnapshotRequest", ")", "{", "debugln", "(", "\"", "\"", ",", "p", ".", "Name", ")", "\n\n", "resp", ":=", "p", ".", "server", ".", "Transporter", "(", ")", ".", "SendSnapsho...
// Sends an Snapshot request to the peer through the transport.
[ "Sends", "an", "Snapshot", "request", "to", "the", "peer", "through", "the", "transport", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/peer.go#L258-L280
147,950
goraft/raft
peer.go
sendSnapshotRecoveryRequest
func (p *Peer) sendSnapshotRecoveryRequest() { req := newSnapshotRecoveryRequest(p.server.name, p.server.snapshot) debugln("peer.snap.recovery.send: ", p.Name) resp := p.server.Transporter().SendSnapshotRecoveryRequest(p.server, p, req) if resp == nil { debugln("peer.snap.recovery.timeout: ", p.Name) return }...
go
func (p *Peer) sendSnapshotRecoveryRequest() { req := newSnapshotRecoveryRequest(p.server.name, p.server.snapshot) debugln("peer.snap.recovery.send: ", p.Name) resp := p.server.Transporter().SendSnapshotRecoveryRequest(p.server, p, req) if resp == nil { debugln("peer.snap.recovery.timeout: ", p.Name) return }...
[ "func", "(", "p", "*", "Peer", ")", "sendSnapshotRecoveryRequest", "(", ")", "{", "req", ":=", "newSnapshotRecoveryRequest", "(", "p", ".", "server", ".", "name", ",", "p", ".", "server", ".", "snapshot", ")", "\n", "debugln", "(", "\"", "\"", ",", "p"...
// Sends an Snapshot Recovery request to the peer through the transport.
[ "Sends", "an", "Snapshot", "Recovery", "request", "to", "the", "peer", "through", "the", "transport", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/peer.go#L283-L302
147,951
goraft/raft
debug.go
debugf
func debugf(format string, v ...interface{}) { if logLevel >= Debug { logger.Printf(format, v...) } }
go
func debugf(format string, v ...interface{}) { if logLevel >= Debug { logger.Printf(format, v...) } }
[ "func", "debugf", "(", "format", "string", ",", "v", "...", "interface", "{", "}", ")", "{", "if", "logLevel", ">=", "Debug", "{", "logger", ".", "Printf", "(", "format", ",", "v", "...", ")", "\n", "}", "\n", "}" ]
// Prints to the standard logger if debug mode is enabled. Arguments // are handled in the manner of fmt.Printf.
[ "Prints", "to", "the", "standard", "logger", "if", "debug", "mode", "is", "enabled", ".", "Arguments", "are", "handled", "in", "the", "manner", "of", "fmt", ".", "Printf", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/debug.go#L76-L80
147,952
goraft/raft
debug.go
tracef
func tracef(format string, v ...interface{}) { if logLevel >= Trace { logger.Printf(format, v...) } }
go
func tracef(format string, v ...interface{}) { if logLevel >= Trace { logger.Printf(format, v...) } }
[ "func", "tracef", "(", "format", "string", ",", "v", "...", "interface", "{", "}", ")", "{", "if", "logLevel", ">=", "Trace", "{", "logger", ".", "Printf", "(", "format", ",", "v", "...", ")", "\n", "}", "\n", "}" ]
// Prints to the standard logger if trace debugging is enabled. Arguments // are handled in the manner of fmt.Printf.
[ "Prints", "to", "the", "standard", "logger", "if", "trace", "debugging", "is", "enabled", ".", "Arguments", "are", "handled", "in", "the", "manner", "of", "fmt", ".", "Printf", "." ]
0061b6c82526bd96292f41fa72358ec13ee3853c
https://github.com/goraft/raft/blob/0061b6c82526bd96292f41fa72358ec13ee3853c/debug.go#L104-L108
147,953
tebeka/selenium
common.go
filteredURL
func filteredURL(u string) string { // Hide password if set in URL m, err := url.Parse(u) if err != nil { return "" } if m.User != nil { if _, ok := m.User.Password(); ok { m.User = url.UserPassword(m.User.Username(), "__password__") } } return m.String() }
go
func filteredURL(u string) string { // Hide password if set in URL m, err := url.Parse(u) if err != nil { return "" } if m.User != nil { if _, ok := m.User.Password(); ok { m.User = url.UserPassword(m.User.Username(), "__password__") } } return m.String() }
[ "func", "filteredURL", "(", "u", "string", ")", "string", "{", "// Hide password if set in URL", "m", ",", "err", ":=", "url", ".", "Parse", "(", "u", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "m", ".", ...
// filteredURL replaces existing password from the given URL.
[ "filteredURL", "replaces", "existing", "password", "from", "the", "given", "URL", "." ]
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/common.go#L23-L35
147,954
tebeka/selenium
selenium.go
AddChrome
func (c Capabilities) AddChrome(f chrome.Capabilities) { c[chrome.CapabilitiesKey] = f c[chrome.DeprecatedCapabilitiesKey] = f }
go
func (c Capabilities) AddChrome(f chrome.Capabilities) { c[chrome.CapabilitiesKey] = f c[chrome.DeprecatedCapabilitiesKey] = f }
[ "func", "(", "c", "Capabilities", ")", "AddChrome", "(", "f", "chrome", ".", "Capabilities", ")", "{", "c", "[", "chrome", ".", "CapabilitiesKey", "]", "=", "f", "\n", "c", "[", "chrome", ".", "DeprecatedCapabilitiesKey", "]", "=", "f", "\n", "}" ]
// AddChrome adds Chrome-specific capabilities.
[ "AddChrome", "adds", "Chrome", "-", "specific", "capabilities", "." ]
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/selenium.go#L96-L99
147,955
tebeka/selenium
selenium.go
AddFirefox
func (c Capabilities) AddFirefox(f firefox.Capabilities) { c[firefox.CapabilitiesKey] = f }
go
func (c Capabilities) AddFirefox(f firefox.Capabilities) { c[firefox.CapabilitiesKey] = f }
[ "func", "(", "c", "Capabilities", ")", "AddFirefox", "(", "f", "firefox", ".", "Capabilities", ")", "{", "c", "[", "firefox", ".", "CapabilitiesKey", "]", "=", "f", "\n", "}" ]
// AddFirefox adds Firefox-specific capabilities.
[ "AddFirefox", "adds", "Firefox", "-", "specific", "capabilities", "." ]
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/selenium.go#L102-L104
147,956
tebeka/selenium
selenium.go
AddLogging
func (c Capabilities) AddLogging(l log.Capabilities) { c[log.CapabilitiesKey] = l }
go
func (c Capabilities) AddLogging(l log.Capabilities) { c[log.CapabilitiesKey] = l }
[ "func", "(", "c", "Capabilities", ")", "AddLogging", "(", "l", "log", ".", "Capabilities", ")", "{", "c", "[", "log", ".", "CapabilitiesKey", "]", "=", "l", "\n", "}" ]
// AddLogging adds logging configuration to the capabilities.
[ "AddLogging", "adds", "logging", "configuration", "to", "the", "capabilities", "." ]
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/selenium.go#L112-L114
147,957
tebeka/selenium
selenium.go
SetLogLevel
func (c Capabilities) SetLogLevel(typ log.Type, level log.Level) { if _, ok := c[log.CapabilitiesKey]; !ok { c[log.CapabilitiesKey] = make(log.Capabilities) } m := c[log.CapabilitiesKey].(log.Capabilities) m[typ] = level }
go
func (c Capabilities) SetLogLevel(typ log.Type, level log.Level) { if _, ok := c[log.CapabilitiesKey]; !ok { c[log.CapabilitiesKey] = make(log.Capabilities) } m := c[log.CapabilitiesKey].(log.Capabilities) m[typ] = level }
[ "func", "(", "c", "Capabilities", ")", "SetLogLevel", "(", "typ", "log", ".", "Type", ",", "level", "log", ".", "Level", ")", "{", "if", "_", ",", "ok", ":=", "c", "[", "log", ".", "CapabilitiesKey", "]", ";", "!", "ok", "{", "c", "[", "log", "...
// SetLogLevel sets the logging level of a component. It is a shortcut for // passing a log.Capabilities instance to AddLogging.
[ "SetLogLevel", "sets", "the", "logging", "level", "of", "a", "component", ".", "It", "is", "a", "shortcut", "for", "passing", "a", "log", ".", "Capabilities", "instance", "to", "AddLogging", "." ]
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/selenium.go#L118-L124
147,958
tebeka/selenium
service.go
Display
func Display(d, xauthPath string) ServiceOption { return func(s *Service) error { if s.display != "" { return fmt.Errorf("service display already set: %v", s.display) } if s.xauthPath != "" { return fmt.Errorf("service xauth path already set: %v", s.xauthPath) } if !isDisplay(d) { return fmt.Errorf(...
go
func Display(d, xauthPath string) ServiceOption { return func(s *Service) error { if s.display != "" { return fmt.Errorf("service display already set: %v", s.display) } if s.xauthPath != "" { return fmt.Errorf("service xauth path already set: %v", s.xauthPath) } if !isDisplay(d) { return fmt.Errorf(...
[ "func", "Display", "(", "d", ",", "xauthPath", "string", ")", "ServiceOption", "{", "return", "func", "(", "s", "*", "Service", ")", "error", "{", "if", "s", ".", "display", "!=", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",...
// Display specifies the value to which set the DISPLAY environment variable, // as well as the path to the Xauthority file containing credentials needed to // write to that X server.
[ "Display", "specifies", "the", "value", "to", "which", "set", "the", "DISPLAY", "environment", "variable", "as", "well", "as", "the", "path", "to", "the", "Xauthority", "file", "containing", "credentials", "needed", "to", "write", "to", "that", "X", "server", ...
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/service.go#L24-L39
147,959
tebeka/selenium
service.go
isDisplay
func isDisplay(disp string) bool { ds := strings.Split(disp, ".") if len(ds) > 2 { return false } for _, d := range ds { if _, err := strconv.Atoi(d); err != nil { return false } } return true }
go
func isDisplay(disp string) bool { ds := strings.Split(disp, ".") if len(ds) > 2 { return false } for _, d := range ds { if _, err := strconv.Atoi(d); err != nil { return false } } return true }
[ "func", "isDisplay", "(", "disp", "string", ")", "bool", "{", "ds", ":=", "strings", ".", "Split", "(", "disp", ",", "\"", "\"", ")", "\n", "if", "len", "(", "ds", ")", ">", "2", "{", "return", "false", "\n", "}", "\n\n", "for", "_", ",", "d", ...
// isDisplay validates that the given disp is in the format "x" or "x.y", where // x and y are both integers.
[ "isDisplay", "validates", "that", "the", "given", "disp", "is", "in", "the", "format", "x", "or", "x", ".", "y", "where", "x", "and", "y", "are", "both", "integers", "." ]
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/service.go#L43-L55
147,960
tebeka/selenium
service.go
StartFrameBufferWithOptions
func StartFrameBufferWithOptions(options FrameBufferOptions) ServiceOption { return func(s *Service) error { if s.display != "" { return fmt.Errorf("service display already set: %v", s.display) } if s.xauthPath != "" { return fmt.Errorf("service xauth path already set: %v", s.xauthPath) } if s.xvfb != ...
go
func StartFrameBufferWithOptions(options FrameBufferOptions) ServiceOption { return func(s *Service) error { if s.display != "" { return fmt.Errorf("service display already set: %v", s.display) } if s.xauthPath != "" { return fmt.Errorf("service xauth path already set: %v", s.xauthPath) } if s.xvfb != ...
[ "func", "StartFrameBufferWithOptions", "(", "options", "FrameBufferOptions", ")", "ServiceOption", "{", "return", "func", "(", "s", "*", "Service", ")", "error", "{", "if", "s", ".", "display", "!=", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\...
// StartFrameBufferWithOptions causes an X virtual frame buffer to start before // the WebDriver service. The frame buffer process will be terminated when the // service itself is stopped.
[ "StartFrameBufferWithOptions", "causes", "an", "X", "virtual", "frame", "buffer", "to", "start", "before", "the", "WebDriver", "service", ".", "The", "frame", "buffer", "process", "will", "be", "terminated", "when", "the", "service", "itself", "is", "stopped", "...
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/service.go#L77-L95
147,961
tebeka/selenium
service.go
Output
func Output(w io.Writer) ServiceOption { return func(s *Service) error { s.output = w return nil } }
go
func Output(w io.Writer) ServiceOption { return func(s *Service) error { s.output = w return nil } }
[ "func", "Output", "(", "w", "io", ".", "Writer", ")", "ServiceOption", "{", "return", "func", "(", "s", "*", "Service", ")", "error", "{", "s", ".", "output", "=", "w", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// Output specifies that the WebDriver service should log to the provided // writer.
[ "Output", "specifies", "that", "the", "WebDriver", "service", "should", "log", "to", "the", "provided", "writer", "." ]
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/service.go#L99-L104
147,962
tebeka/selenium
service.go
GeckoDriver
func GeckoDriver(path string) ServiceOption { return func(s *Service) error { s.geckoDriverPath = path return nil } }
go
func GeckoDriver(path string) ServiceOption { return func(s *Service) error { s.geckoDriverPath = path return nil } }
[ "func", "GeckoDriver", "(", "path", "string", ")", "ServiceOption", "{", "return", "func", "(", "s", "*", "Service", ")", "error", "{", "s", ".", "geckoDriverPath", "=", "path", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// GeckoDriver sets the path to the geckodriver binary for the Selenium Server. // Unlike other drivers, Selenium Server does not support specifying the // geckodriver path at runtime. This ServiceOption is only useful when calling // NewSeleniumService.
[ "GeckoDriver", "sets", "the", "path", "to", "the", "geckodriver", "binary", "for", "the", "Selenium", "Server", ".", "Unlike", "other", "drivers", "Selenium", "Server", "does", "not", "support", "specifying", "the", "geckodriver", "path", "at", "runtime", ".", ...
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/service.go#L110-L115
147,963
tebeka/selenium
service.go
JavaPath
func JavaPath(path string) ServiceOption { return func(s *Service) error { s.javaPath = path return nil } }
go
func JavaPath(path string) ServiceOption { return func(s *Service) error { s.javaPath = path return nil } }
[ "func", "JavaPath", "(", "path", "string", ")", "ServiceOption", "{", "return", "func", "(", "s", "*", "Service", ")", "error", "{", "s", ".", "javaPath", "=", "path", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// JavaPath specifies the path to the JRE for a Selenium service.
[ "JavaPath", "specifies", "the", "path", "to", "the", "JRE", "for", "a", "Selenium", "service", "." ]
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/service.go#L125-L130
147,964
tebeka/selenium
service.go
NewSeleniumService
func NewSeleniumService(jarPath string, port int, opts ...ServiceOption) (*Service, error) { cmd := exec.Command("java", "-jar", jarPath, "-port", strconv.Itoa(port)) s, err := newService(cmd, "/wd/hub", port, opts...) if err != nil { return nil, err } if s.javaPath != "" { s.cmd.Path = s.javaPath } if s.gec...
go
func NewSeleniumService(jarPath string, port int, opts ...ServiceOption) (*Service, error) { cmd := exec.Command("java", "-jar", jarPath, "-port", strconv.Itoa(port)) s, err := newService(cmd, "/wd/hub", port, opts...) if err != nil { return nil, err } if s.javaPath != "" { s.cmd.Path = s.javaPath } if s.gec...
[ "func", "NewSeleniumService", "(", "jarPath", "string", ",", "port", "int", ",", "opts", "...", "ServiceOption", ")", "(", "*", "Service", ",", "error", ")", "{", "cmd", ":=", "exec", ".", "Command", "(", "\"", "\"", ",", "\"", "\"", ",", "jarPath", ...
// NewSeleniumService starts a Selenium instance in the background.
[ "NewSeleniumService", "starts", "a", "Selenium", "instance", "in", "the", "background", "." ]
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/service.go#L154-L173
147,965
tebeka/selenium
service.go
NewChromeDriverService
func NewChromeDriverService(path string, port int, opts ...ServiceOption) (*Service, error) { cmd := exec.Command(path, "--port="+strconv.Itoa(port), "--url-base=wd/hub", "--verbose") s, err := newService(cmd, "/wd/hub", port, opts...) if err != nil { return nil, err } s.shutdownURLPath = "/shutdown" if err := ...
go
func NewChromeDriverService(path string, port int, opts ...ServiceOption) (*Service, error) { cmd := exec.Command(path, "--port="+strconv.Itoa(port), "--url-base=wd/hub", "--verbose") s, err := newService(cmd, "/wd/hub", port, opts...) if err != nil { return nil, err } s.shutdownURLPath = "/shutdown" if err := ...
[ "func", "NewChromeDriverService", "(", "path", "string", ",", "port", "int", ",", "opts", "...", "ServiceOption", ")", "(", "*", "Service", ",", "error", ")", "{", "cmd", ":=", "exec", ".", "Command", "(", "path", ",", "\"", "\"", "+", "strconv", ".", ...
// NewChromeDriverService starts a ChromeDriver instance in the background.
[ "NewChromeDriverService", "starts", "a", "ChromeDriver", "instance", "in", "the", "background", "." ]
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/service.go#L176-L187
147,966
tebeka/selenium
service.go
Stop
func (s *Service) Stop() error { // Selenium 3 stopped supporting the shutdown URL by default. // https://github.com/SeleniumHQ/selenium/issues/2852 if s.shutdownURLPath == "" { if err := s.cmd.Process.Kill(); err != nil { return err } } else { resp, err := http.Get(s.addr + s.shutdownURLPath) if err != ...
go
func (s *Service) Stop() error { // Selenium 3 stopped supporting the shutdown URL by default. // https://github.com/SeleniumHQ/selenium/issues/2852 if s.shutdownURLPath == "" { if err := s.cmd.Process.Kill(); err != nil { return err } } else { resp, err := http.Get(s.addr + s.shutdownURLPath) if err != ...
[ "func", "(", "s", "*", "Service", ")", "Stop", "(", ")", "error", "{", "// Selenium 3 stopped supporting the shutdown URL by default.", "// https://github.com/SeleniumHQ/selenium/issues/2852", "if", "s", ".", "shutdownURLPath", "==", "\"", "\"", "{", "if", "err", ":=", ...
// Stop shuts down the WebDriver service, and the X virtual frame buffer // if one was started.
[ "Stop", "shuts", "down", "the", "WebDriver", "service", "and", "the", "X", "virtual", "frame", "buffer", "if", "one", "was", "started", "." ]
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/service.go#L250-L271
147,967
tebeka/selenium
service.go
NewFrameBufferWithOptions
func NewFrameBufferWithOptions(options FrameBufferOptions) (*FrameBuffer, error) { r, w, err := os.Pipe() if err != nil { return nil, err } defer r.Close() auth, err := ioutil.TempFile("", "selenium-xvfb") if err != nil { return nil, err } authPath := auth.Name() if err := auth.Close(); err != nil { ret...
go
func NewFrameBufferWithOptions(options FrameBufferOptions) (*FrameBuffer, error) { r, w, err := os.Pipe() if err != nil { return nil, err } defer r.Close() auth, err := ioutil.TempFile("", "selenium-xvfb") if err != nil { return nil, err } authPath := auth.Name() if err := auth.Close(); err != nil { ret...
[ "func", "NewFrameBufferWithOptions", "(", "options", "FrameBufferOptions", ")", "(", "*", "FrameBuffer", ",", "error", ")", "{", "r", ",", "w", ",", "err", ":=", "os", ".", "Pipe", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", ...
// NewFrameBufferWithOptions starts an X virtual frame buffer running in the background. // FrameBufferOptions may be populated to change the behavior of the frame buffer.
[ "NewFrameBufferWithOptions", "starts", "an", "X", "virtual", "frame", "buffer", "running", "in", "the", "background", ".", "FrameBufferOptions", "may", "be", "populated", "to", "change", "the", "behavior", "of", "the", "frame", "buffer", "." ]
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/service.go#L296-L369
147,968
tebeka/selenium
service.go
Stop
func (f FrameBuffer) Stop() error { if err := f.cmd.Process.Kill(); err != nil { return err } os.Remove(f.AuthPath) // best effort removal; ignore error if err := f.cmd.Wait(); err != nil && err.Error() != "signal: killed" { return err } return nil }
go
func (f FrameBuffer) Stop() error { if err := f.cmd.Process.Kill(); err != nil { return err } os.Remove(f.AuthPath) // best effort removal; ignore error if err := f.cmd.Wait(); err != nil && err.Error() != "signal: killed" { return err } return nil }
[ "func", "(", "f", "FrameBuffer", ")", "Stop", "(", ")", "error", "{", "if", "err", ":=", "f", ".", "cmd", ".", "Process", ".", "Kill", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "os", ".", "Remove", "(", "f", "....
// Stop kills the background frame buffer process and removes the X // authorization file.
[ "Stop", "kills", "the", "background", "frame", "buffer", "process", "and", "removes", "the", "X", "authorization", "file", "." ]
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/service.go#L373-L382
147,969
tebeka/selenium
sauce/connect.go
Start
func (c *Connect) Start() error { c.cmd = exec.Command(c.Path, c.Args...) if c.UserName != "" { c.cmd.Args = append(c.cmd.Args, "--user", c.UserName) } if c.AccessKey != "" { c.cmd.Args = append(c.cmd.Args, "--api-key", c.AccessKey) } if c.SeleniumPort > 0 { c.cmd.Args = append(c.cmd.Args, "--se-port", strc...
go
func (c *Connect) Start() error { c.cmd = exec.Command(c.Path, c.Args...) if c.UserName != "" { c.cmd.Args = append(c.cmd.Args, "--user", c.UserName) } if c.AccessKey != "" { c.cmd.Args = append(c.cmd.Args, "--api-key", c.AccessKey) } if c.SeleniumPort > 0 { c.cmd.Args = append(c.cmd.Args, "--se-port", strc...
[ "func", "(", "c", "*", "Connect", ")", "Start", "(", ")", "error", "{", "c", ".", "cmd", "=", "exec", ".", "Command", "(", "c", ".", "Path", ",", "c", ".", "Args", "...", ")", "\n", "if", "c", ".", "UserName", "!=", "\"", "\"", "{", "c", "....
// Start starts the Sauce Connect Proxy.
[ "Start", "starts", "the", "Sauce", "Connect", "Proxy", "." ]
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/sauce/connect.go#L47-L121
147,970
tebeka/selenium
sauce/connect.go
Addr
func (c *Connect) Addr() string { return fmt.Sprintf("http://%s:%s@localhost:%d/wd/hub", c.UserName, c.AccessKey, c.SeleniumPort) }
go
func (c *Connect) Addr() string { return fmt.Sprintf("http://%s:%s@localhost:%d/wd/hub", c.UserName, c.AccessKey, c.SeleniumPort) }
[ "func", "(", "c", "*", "Connect", ")", "Addr", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "c", ".", "UserName", ",", "c", ".", "AccessKey", ",", "c", ".", "SeleniumPort", ")", "\n", "}" ]
// Addr returns the URL of the WebDriver endpoint to use for driving the // browser.
[ "Addr", "returns", "the", "URL", "of", "the", "WebDriver", "endpoint", "to", "use", "for", "driving", "the", "browser", "." ]
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/sauce/connect.go#L125-L127
147,971
tebeka/selenium
chrome/capabilities.go
AddExtension
func (c *Capabilities) AddExtension(path string) error { f, err := os.Open(path) if err != nil { return err } defer f.Close() return c.addExtension(f) }
go
func (c *Capabilities) AddExtension(path string) error { f, err := os.Open(path) if err != nil { return err } defer f.Close() return c.addExtension(f) }
[ "func", "(", "c", "*", "Capabilities", ")", "AddExtension", "(", "path", "string", ")", "error", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "f",...
// AddExtension adds an extension for the browser to load at startup. The path // parameter should be a path to an extension file (which typically has a // `.crx` file extension. Note that the contents of the file will be loaded // into memory, as required by the protocol.
[ "AddExtension", "adds", "an", "extension", "for", "the", "browser", "to", "load", "at", "startup", ".", "The", "path", "parameter", "should", "be", "a", "path", "to", "an", "extension", "file", "(", "which", "typically", "has", "a", ".", "crx", "file", "...
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/chrome/capabilities.go#L128-L135
147,972
tebeka/selenium
chrome/capabilities.go
addExtension
func (c *Capabilities) addExtension(r io.Reader) error { var buf bytes.Buffer encoder := base64.NewEncoder(base64.StdEncoding, &buf) if _, err := io.Copy(encoder, bufio.NewReader(r)); err != nil { return err } encoder.Close() c.Extensions = append(c.Extensions, buf.String()) return nil }
go
func (c *Capabilities) addExtension(r io.Reader) error { var buf bytes.Buffer encoder := base64.NewEncoder(base64.StdEncoding, &buf) if _, err := io.Copy(encoder, bufio.NewReader(r)); err != nil { return err } encoder.Close() c.Extensions = append(c.Extensions, buf.String()) return nil }
[ "func", "(", "c", "*", "Capabilities", ")", "addExtension", "(", "r", "io", ".", "Reader", ")", "error", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "encoder", ":=", "base64", ".", "NewEncoder", "(", "base64", ".", "StdEncoding", ",", "&", "buf", ...
// addExtension reads a Chrome extension's data from r, base64-encodes it, and // attaches it to the Capabilities instance.
[ "addExtension", "reads", "a", "Chrome", "extension", "s", "data", "from", "r", "base64", "-", "encodes", "it", "and", "attaches", "it", "to", "the", "Capabilities", "instance", "." ]
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/chrome/capabilities.go#L139-L148
147,973
tebeka/selenium
chrome/capabilities.go
AddUnpackedExtension
func (c *Capabilities) AddUnpackedExtension(basePath string) error { buf, _, err := NewExtension(basePath) if err != nil { return err } return c.addExtension(bytes.NewBuffer(buf)) }
go
func (c *Capabilities) AddUnpackedExtension(basePath string) error { buf, _, err := NewExtension(basePath) if err != nil { return err } return c.addExtension(bytes.NewBuffer(buf)) }
[ "func", "(", "c", "*", "Capabilities", ")", "AddUnpackedExtension", "(", "basePath", "string", ")", "error", "{", "buf", ",", "_", ",", "err", ":=", "NewExtension", "(", "basePath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", ...
// AddUnpackedExtension creates a packaged Chrome extension with the files // below the provided directory path and causes the browser to load that // extension at startup.
[ "AddUnpackedExtension", "creates", "a", "packaged", "Chrome", "extension", "with", "the", "files", "below", "the", "provided", "directory", "path", "and", "causes", "the", "browser", "to", "load", "that", "extension", "at", "startup", "." ]
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/chrome/capabilities.go#L153-L159
147,974
tebeka/selenium
chrome/capabilities.go
NewExtension
func NewExtension(basePath string) ([]byte, *rsa.PrivateKey, error) { key, err := rsa.GenerateKey(rand.Reader, 2048) if err != nil { return nil, nil, err } data, err := NewExtensionWithKey(basePath, key) if err != nil { return nil, nil, err } return data, key, nil }
go
func NewExtension(basePath string) ([]byte, *rsa.PrivateKey, error) { key, err := rsa.GenerateKey(rand.Reader, 2048) if err != nil { return nil, nil, err } data, err := NewExtensionWithKey(basePath, key) if err != nil { return nil, nil, err } return data, key, nil }
[ "func", "NewExtension", "(", "basePath", "string", ")", "(", "[", "]", "byte", ",", "*", "rsa", ".", "PrivateKey", ",", "error", ")", "{", "key", ",", "err", ":=", "rsa", ".", "GenerateKey", "(", "rand", ".", "Reader", ",", "2048", ")", "\n", "if",...
// NewExtension creates the payload of a Chrome extension file which is signed // using the returned private key.
[ "NewExtension", "creates", "the", "payload", "of", "a", "Chrome", "extension", "file", "which", "is", "signed", "using", "the", "returned", "private", "key", "." ]
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/chrome/capabilities.go#L163-L173
147,975
tebeka/selenium
chrome/capabilities.go
NewExtensionWithKey
func NewExtensionWithKey(basePath string, key *rsa.PrivateKey) ([]byte, error) { zip, err := zip.New(basePath) if err != nil { return nil, err } h := sha1.New() if _, err := io.Copy(h, bytes.NewReader(zip.Bytes())); err != nil { return nil, err } hashed := h.Sum(nil) signature, err := rsa.SignPKCS1v15(ran...
go
func NewExtensionWithKey(basePath string, key *rsa.PrivateKey) ([]byte, error) { zip, err := zip.New(basePath) if err != nil { return nil, err } h := sha1.New() if _, err := io.Copy(h, bytes.NewReader(zip.Bytes())); err != nil { return nil, err } hashed := h.Sum(nil) signature, err := rsa.SignPKCS1v15(ran...
[ "func", "NewExtensionWithKey", "(", "basePath", "string", ",", "key", "*", "rsa", ".", "PrivateKey", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "zip", ",", "err", ":=", "zip", ".", "New", "(", "basePath", ")", "\n", "if", "err", "!=", "nil...
// NewExtensionWithKey creates the payload of a Chrome extension file which is // signed by the provided private key.
[ "NewExtensionWithKey", "creates", "the", "payload", "of", "a", "Chrome", "extension", "file", "which", "is", "signed", "by", "the", "provided", "private", "key", "." ]
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/chrome/capabilities.go#L177-L235
147,976
tebeka/selenium
remote.go
execute
func (wd *remoteWD) execute(method, url string, data []byte) (json.RawMessage, error) { debugLog("-> %s %s\n%s", method, filteredURL(url), data) request, err := newRequest(method, url, data) if err != nil { return nil, err } response, err := HTTPClient.Do(request) if err != nil { return nil, err } buf, er...
go
func (wd *remoteWD) execute(method, url string, data []byte) (json.RawMessage, error) { debugLog("-> %s %s\n%s", method, filteredURL(url), data) request, err := newRequest(method, url, data) if err != nil { return nil, err } response, err := HTTPClient.Do(request) if err != nil { return nil, err } buf, er...
[ "func", "(", "wd", "*", "remoteWD", ")", "execute", "(", "method", ",", "url", "string", ",", "data", "[", "]", "byte", ")", "(", "json", ".", "RawMessage", ",", "error", ")", "{", "debugLog", "(", "\"", "\\n", "\"", ",", "method", ",", "filteredUR...
// execute performs an HTTP request and inspects the returned data for an error // encoded by the remote end in a JSON structure. If no error is present, the // entire, raw request payload is returned.
[ "execute", "performs", "an", "HTTP", "request", "and", "inspects", "the", "returned", "data", "for", "an", "error", "encoded", "by", "the", "remote", "end", "in", "a", "JSON", "structure", ".", "If", "no", "error", "is", "present", "the", "entire", "raw", ...
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/remote.go#L124-L204
147,977
tebeka/selenium
remote.go
parseVersion
func parseVersion(v string) (semver.Version, error) { parts := strings.Split(v, ".") var err error for i := len(parts); i > 0; i-- { var ver semver.Version ver, err = semver.ParseTolerant(strings.Join(parts[:i], ".")) if err == nil { return ver, nil } } return semver.Version{}, err }
go
func parseVersion(v string) (semver.Version, error) { parts := strings.Split(v, ".") var err error for i := len(parts); i > 0; i-- { var ver semver.Version ver, err = semver.ParseTolerant(strings.Join(parts[:i], ".")) if err == nil { return ver, nil } } return semver.Version{}, err }
[ "func", "parseVersion", "(", "v", "string", ")", "(", "semver", ".", "Version", ",", "error", ")", "{", "parts", ":=", "strings", ".", "Split", "(", "v", ",", "\"", "\"", ")", "\n", "var", "err", "error", "\n", "for", "i", ":=", "len", "(", "part...
// parseVersion sanitizes the browser version enough for semver.ParseTolerant // to parse it.
[ "parseVersion", "sanitizes", "the", "browser", "version", "enough", "for", "semver", ".", "ParseTolerant", "to", "parse", "it", "." ]
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/remote.go#L311-L322
147,978
tebeka/selenium
remote.go
newW3CCapabilities
func newW3CCapabilities(caps Capabilities) Capabilities { alwaysMatch := make(Capabilities) for name, value := range caps { if isValidW3CCapability[name] || strings.Contains(name, ":") { alwaysMatch[name] = value } } // Move the Firefox profile setting from the old location to the new // location. if prof...
go
func newW3CCapabilities(caps Capabilities) Capabilities { alwaysMatch := make(Capabilities) for name, value := range caps { if isValidW3CCapability[name] || strings.Contains(name, ":") { alwaysMatch[name] = value } } // Move the Firefox profile setting from the old location to the new // location. if prof...
[ "func", "newW3CCapabilities", "(", "caps", "Capabilities", ")", "Capabilities", "{", "alwaysMatch", ":=", "make", "(", "Capabilities", ")", "\n", "for", "name", ",", "value", ":=", "range", "caps", "{", "if", "isValidW3CCapability", "[", "name", "]", "||", "...
// Create a W3C-compatible capabilities instance.
[ "Create", "a", "W3C", "-", "compatible", "capabilities", "instance", "." ]
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/remote.go#L350-L376
147,979
tebeka/selenium
remote.go
rect
func (elem *remoteWE) rect() (*rect, error) { wd := elem.parent url := wd.requestURL("/session/%s/element/%s/rect", wd.id, elem.id) response, err := wd.execute("GET", url, nil) if err != nil { return nil, err } r := new(struct{ Value rect }) if err := json.Unmarshal(response, r); err != nil { return nil, err...
go
func (elem *remoteWE) rect() (*rect, error) { wd := elem.parent url := wd.requestURL("/session/%s/element/%s/rect", wd.id, elem.id) response, err := wd.execute("GET", url, nil) if err != nil { return nil, err } r := new(struct{ Value rect }) if err := json.Unmarshal(response, r); err != nil { return nil, err...
[ "func", "(", "elem", "*", "remoteWE", ")", "rect", "(", ")", "(", "*", "rect", ",", "error", ")", "{", "wd", ":=", "elem", ".", "parent", "\n", "url", ":=", "wd", ".", "requestURL", "(", "\"", "\"", ",", "wd", ".", "id", ",", "elem", ".", "id...
// rect implements the "Get Element Rect" method of the W3C standard.
[ "rect", "implements", "the", "Get", "Element", "Rect", "method", "of", "the", "W3C", "standard", "." ]
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/remote.go#L1416-L1428
147,980
tebeka/selenium
internal/zip/zip.go
New
func New(basePath string) (*bytes.Buffer, error) { fi, err := os.Stat(basePath) if err != nil { return nil, err } if !fi.IsDir() { return nil, fmt.Errorf("path %q is not a directory, which is required for a Firefox profile", basePath) } buf := new(bytes.Buffer) w := zip.NewWriter(buf) err = filepath.Walk(b...
go
func New(basePath string) (*bytes.Buffer, error) { fi, err := os.Stat(basePath) if err != nil { return nil, err } if !fi.IsDir() { return nil, fmt.Errorf("path %q is not a directory, which is required for a Firefox profile", basePath) } buf := new(bytes.Buffer) w := zip.NewWriter(buf) err = filepath.Walk(b...
[ "func", "New", "(", "basePath", "string", ")", "(", "*", "bytes", ".", "Buffer", ",", "error", ")", "{", "fi", ",", "err", ":=", "os", ".", "Stat", "(", "basePath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}...
// New returns a buffer that contains the payload of a Zip file.
[ "New", "returns", "a", "buffer", "that", "contains", "the", "payload", "of", "a", "Zip", "file", "." ]
edf31bb7fd715ad505d9190f8d65d13f39a7c825
https://github.com/tebeka/selenium/blob/edf31bb7fd715ad505d9190f8d65d13f39a7c825/internal/zip/zip.go#L15-L68
147,981
cheggaaa/pb
pool.go
NewPool
func NewPool(pbs ...*ProgressBar) (pool *Pool) { pool = new(Pool) pool.Add(pbs...) return }
go
func NewPool(pbs ...*ProgressBar) (pool *Pool) { pool = new(Pool) pool.Add(pbs...) return }
[ "func", "NewPool", "(", "pbs", "...", "*", "ProgressBar", ")", "(", "pool", "*", "Pool", ")", "{", "pool", "=", "new", "(", "Pool", ")", "\n", "pool", ".", "Add", "(", "pbs", "...", ")", "\n", "return", "\n", "}" ]
// NewPool initialises a pool with progress bars, but // doesn't start it. You need to call Start manually
[ "NewPool", "initialises", "a", "pool", "with", "progress", "bars", "but", "doesn", "t", "start", "it", ".", "You", "need", "to", "call", "Start", "manually" ]
f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11
https://github.com/cheggaaa/pb/blob/f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11/pool.go#L24-L28
147,982
cheggaaa/pb
pool.go
Add
func (p *Pool) Add(pbs ...*ProgressBar) { p.m.Lock() defer p.m.Unlock() for _, bar := range pbs { bar.ManualUpdate = true bar.NotPrint = true bar.Start() p.bars = append(p.bars, bar) } }
go
func (p *Pool) Add(pbs ...*ProgressBar) { p.m.Lock() defer p.m.Unlock() for _, bar := range pbs { bar.ManualUpdate = true bar.NotPrint = true bar.Start() p.bars = append(p.bars, bar) } }
[ "func", "(", "p", "*", "Pool", ")", "Add", "(", "pbs", "...", "*", "ProgressBar", ")", "{", "p", ".", "m", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "m", ".", "Unlock", "(", ")", "\n", "for", "_", ",", "bar", ":=", "range", "pbs", "{"...
// Add progress bars.
[ "Add", "progress", "bars", "." ]
f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11
https://github.com/cheggaaa/pb/blob/f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11/pool.go#L42-L51
147,983
cheggaaa/pb
pool.go
Stop
func (p *Pool) Stop() error { p.finishOnce.Do(func() { if p.shutdownCh != nil { close(p.shutdownCh) } }) // Wait for the worker to complete select { case <-p.workerCh: } return unlockEcho() }
go
func (p *Pool) Stop() error { p.finishOnce.Do(func() { if p.shutdownCh != nil { close(p.shutdownCh) } }) // Wait for the worker to complete select { case <-p.workerCh: } return unlockEcho() }
[ "func", "(", "p", "*", "Pool", ")", "Stop", "(", ")", "error", "{", "p", ".", "finishOnce", ".", "Do", "(", "func", "(", ")", "{", "if", "p", ".", "shutdownCh", "!=", "nil", "{", "close", "(", "p", ".", "shutdownCh", ")", "\n", "}", "\n", "}"...
// Restore terminal state and close pool
[ "Restore", "terminal", "state", "and", "close", "pool" ]
f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11
https://github.com/cheggaaa/pb/blob/f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11/pool.go#L91-L104
147,984
cheggaaa/pb
format.go
formatBytes
func formatBytes(i int64) (result string) { switch { case i >= TiB: result = fmt.Sprintf("%.02f TiB", float64(i)/TiB) case i >= GiB: result = fmt.Sprintf("%.02f GiB", float64(i)/GiB) case i >= MiB: result = fmt.Sprintf("%.02f MiB", float64(i)/MiB) case i >= KiB: result = fmt.Sprintf("%.02f KiB", float64(i)...
go
func formatBytes(i int64) (result string) { switch { case i >= TiB: result = fmt.Sprintf("%.02f TiB", float64(i)/TiB) case i >= GiB: result = fmt.Sprintf("%.02f GiB", float64(i)/GiB) case i >= MiB: result = fmt.Sprintf("%.02f MiB", float64(i)/MiB) case i >= KiB: result = fmt.Sprintf("%.02f KiB", float64(i)...
[ "func", "formatBytes", "(", "i", "int64", ")", "(", "result", "string", ")", "{", "switch", "{", "case", "i", ">=", "TiB", ":", "result", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "float64", "(", "i", ")", "/", "TiB", ")", "\n", "case", ...
// Convert bytes to human readable string. Like 2 MiB, 64.2 KiB, 52 B
[ "Convert", "bytes", "to", "human", "readable", "string", ".", "Like", "2", "MiB", "64", ".", "2", "KiB", "52", "B" ]
f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11
https://github.com/cheggaaa/pb/blob/f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11/format.go#L77-L91
147,985
cheggaaa/pb
format.go
formatBytesDec
func formatBytesDec(i int64) (result string) { switch { case i >= TB: result = fmt.Sprintf("%.02f TB", float64(i)/TB) case i >= GB: result = fmt.Sprintf("%.02f GB", float64(i)/GB) case i >= MB: result = fmt.Sprintf("%.02f MB", float64(i)/MB) case i >= KB: result = fmt.Sprintf("%.02f KB", float64(i)/KB) de...
go
func formatBytesDec(i int64) (result string) { switch { case i >= TB: result = fmt.Sprintf("%.02f TB", float64(i)/TB) case i >= GB: result = fmt.Sprintf("%.02f GB", float64(i)/GB) case i >= MB: result = fmt.Sprintf("%.02f MB", float64(i)/MB) case i >= KB: result = fmt.Sprintf("%.02f KB", float64(i)/KB) de...
[ "func", "formatBytesDec", "(", "i", "int64", ")", "(", "result", "string", ")", "{", "switch", "{", "case", "i", ">=", "TB", ":", "result", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "float64", "(", "i", ")", "/", "TB", ")", "\n", "case", ...
// Convert bytes to base-10 human readable string. Like 2 MB, 64.2 KB, 52 B
[ "Convert", "bytes", "to", "base", "-", "10", "human", "readable", "string", ".", "Like", "2", "MB", "64", ".", "2", "KB", "52", "B" ]
f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11
https://github.com/cheggaaa/pb/blob/f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11/format.go#L94-L108
147,986
cheggaaa/pb
pb.go
Get
func (pb *ProgressBar) Get() int64 { c := atomic.LoadInt64(&pb.current) return c }
go
func (pb *ProgressBar) Get() int64 { c := atomic.LoadInt64(&pb.current) return c }
[ "func", "(", "pb", "*", "ProgressBar", ")", "Get", "(", ")", "int64", "{", "c", ":=", "atomic", ".", "LoadInt64", "(", "&", "pb", ".", "current", ")", "\n", "return", "c", "\n", "}" ]
// Get current value
[ "Get", "current", "value" ]
f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11
https://github.com/cheggaaa/pb/blob/f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11/pb.go#L135-L138
147,987
cheggaaa/pb
pb.go
Set
func (pb *ProgressBar) Set(current int) *ProgressBar { return pb.Set64(int64(current)) }
go
func (pb *ProgressBar) Set(current int) *ProgressBar { return pb.Set64(int64(current)) }
[ "func", "(", "pb", "*", "ProgressBar", ")", "Set", "(", "current", "int", ")", "*", "ProgressBar", "{", "return", "pb", ".", "Set64", "(", "int64", "(", "current", ")", ")", "\n", "}" ]
// Set current value
[ "Set", "current", "value" ]
f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11
https://github.com/cheggaaa/pb/blob/f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11/pb.go#L141-L143
147,988
cheggaaa/pb
pb.go
Add
func (pb *ProgressBar) Add(add int) int { return int(pb.Add64(int64(add))) }
go
func (pb *ProgressBar) Add(add int) int { return int(pb.Add64(int64(add))) }
[ "func", "(", "pb", "*", "ProgressBar", ")", "Add", "(", "add", "int", ")", "int", "{", "return", "int", "(", "pb", ".", "Add64", "(", "int64", "(", "add", ")", ")", ")", "\n", "}" ]
// Add to current value
[ "Add", "to", "current", "value" ]
f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11
https://github.com/cheggaaa/pb/blob/f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11/pb.go#L152-L154
147,989
cheggaaa/pb
pb.go
IsFinished
func (pb *ProgressBar) IsFinished() bool { pb.mu.Lock() defer pb.mu.Unlock() return pb.isFinish }
go
func (pb *ProgressBar) IsFinished() bool { pb.mu.Lock() defer pb.mu.Unlock() return pb.isFinish }
[ "func", "(", "pb", "*", "ProgressBar", ")", "IsFinished", "(", ")", "bool", "{", "pb", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "pb", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "pb", ".", "isFinish", "\n", "}" ]
// IsFinished return boolean
[ "IsFinished", "return", "boolean" ]
f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11
https://github.com/cheggaaa/pb/blob/f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11/pb.go#L243-L247
147,990
cheggaaa/pb
pb.go
FinishPrint
func (pb *ProgressBar) FinishPrint(str string) { pb.Finish() if pb.Output != nil { fmt.Fprintln(pb.Output, str) } else { fmt.Println(str) } }
go
func (pb *ProgressBar) FinishPrint(str string) { pb.Finish() if pb.Output != nil { fmt.Fprintln(pb.Output, str) } else { fmt.Println(str) } }
[ "func", "(", "pb", "*", "ProgressBar", ")", "FinishPrint", "(", "str", "string", ")", "{", "pb", ".", "Finish", "(", ")", "\n", "if", "pb", ".", "Output", "!=", "nil", "{", "fmt", ".", "Fprintln", "(", "pb", ".", "Output", ",", "str", ")", "\n", ...
// End print and write string 'str'
[ "End", "print", "and", "write", "string", "str" ]
f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11
https://github.com/cheggaaa/pb/blob/f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11/pb.go#L250-L257
147,991
cheggaaa/pb
pb.go
Write
func (pb *ProgressBar) Write(p []byte) (n int, err error) { n = len(p) pb.Add(n) return }
go
func (pb *ProgressBar) Write(p []byte) (n int, err error) { n = len(p) pb.Add(n) return }
[ "func", "(", "pb", "*", "ProgressBar", ")", "Write", "(", "p", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "n", "=", "len", "(", "p", ")", "\n", "pb", ".", "Add", "(", "n", ")", "\n", "return", "\n", "}" ]
// implement io.Writer
[ "implement", "io", ".", "Writer" ]
f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11
https://github.com/cheggaaa/pb/blob/f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11/pb.go#L260-L264
147,992
cheggaaa/pb
pb.go
NewProxyReader
func (pb *ProgressBar) NewProxyReader(r io.Reader) *Reader { return &Reader{r, pb} }
go
func (pb *ProgressBar) NewProxyReader(r io.Reader) *Reader { return &Reader{r, pb} }
[ "func", "(", "pb", "*", "ProgressBar", ")", "NewProxyReader", "(", "r", "io", ".", "Reader", ")", "*", "Reader", "{", "return", "&", "Reader", "{", "r", ",", "pb", "}", "\n", "}" ]
// Create new proxy reader over bar // Takes io.Reader or io.ReadCloser
[ "Create", "new", "proxy", "reader", "over", "bar", "Takes", "io", ".", "Reader", "or", "io", ".", "ReadCloser" ]
f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11
https://github.com/cheggaaa/pb/blob/f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11/pb.go#L275-L277
147,993
cheggaaa/pb
pb.go
String
func (pb *ProgressBar) String() string { pb.mu.Lock() defer pb.mu.Unlock() return pb.lastPrint }
go
func (pb *ProgressBar) String() string { pb.mu.Lock() defer pb.mu.Unlock() return pb.lastPrint }
[ "func", "(", "pb", "*", "ProgressBar", ")", "String", "(", ")", "string", "{", "pb", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "pb", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "pb", ".", "lastPrint", "\n", "}" ]
// String return the last bar print
[ "String", "return", "the", "last", "bar", "print" ]
f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11
https://github.com/cheggaaa/pb/blob/f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11/pb.go#L461-L465
147,994
cheggaaa/pb
pb.go
SetTotal
func (pb *ProgressBar) SetTotal(total int) *ProgressBar { return pb.SetTotal64(int64(total)) }
go
func (pb *ProgressBar) SetTotal(total int) *ProgressBar { return pb.SetTotal64(int64(total)) }
[ "func", "(", "pb", "*", "ProgressBar", ")", "SetTotal", "(", "total", "int", ")", "*", "ProgressBar", "{", "return", "pb", ".", "SetTotal64", "(", "int64", "(", "total", ")", ")", "\n", "}" ]
// SetTotal atomically sets new total count
[ "SetTotal", "atomically", "sets", "new", "total", "count" ]
f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11
https://github.com/cheggaaa/pb/blob/f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11/pb.go#L468-L470
147,995
cheggaaa/pb
pb.go
SetTotal64
func (pb *ProgressBar) SetTotal64(total int64) *ProgressBar { atomic.StoreInt64(&pb.Total, total) return pb }
go
func (pb *ProgressBar) SetTotal64(total int64) *ProgressBar { atomic.StoreInt64(&pb.Total, total) return pb }
[ "func", "(", "pb", "*", "ProgressBar", ")", "SetTotal64", "(", "total", "int64", ")", "*", "ProgressBar", "{", "atomic", ".", "StoreInt64", "(", "&", "pb", ".", "Total", ",", "total", ")", "\n", "return", "pb", "\n", "}" ]
// SetTotal64 atomically sets new total count
[ "SetTotal64", "atomically", "sets", "new", "total", "count" ]
f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11
https://github.com/cheggaaa/pb/blob/f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11/pb.go#L473-L476
147,996
cheggaaa/pb
pb.go
Reset
func (pb *ProgressBar) Reset(total int) *ProgressBar { pb.mu.Lock() defer pb.mu.Unlock() if pb.isFinish { pb.SetTotal(total).Set(0) atomic.StoreInt64(&pb.previous, 0) } return pb }
go
func (pb *ProgressBar) Reset(total int) *ProgressBar { pb.mu.Lock() defer pb.mu.Unlock() if pb.isFinish { pb.SetTotal(total).Set(0) atomic.StoreInt64(&pb.previous, 0) } return pb }
[ "func", "(", "pb", "*", "ProgressBar", ")", "Reset", "(", "total", "int", ")", "*", "ProgressBar", "{", "pb", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "pb", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "pb", ".", "isFinish", "{", "pb...
// Reset bar and set new total count // Does effect only on finished bar
[ "Reset", "bar", "and", "set", "new", "total", "count", "Does", "effect", "only", "on", "finished", "bar" ]
f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11
https://github.com/cheggaaa/pb/blob/f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11/pb.go#L480-L488
147,997
cheggaaa/pb
pb.go
refresher
func (pb *ProgressBar) refresher() { for { select { case <-pb.finish: return case <-time.After(pb.RefreshRate): pb.Update() } } }
go
func (pb *ProgressBar) refresher() { for { select { case <-pb.finish: return case <-time.After(pb.RefreshRate): pb.Update() } } }
[ "func", "(", "pb", "*", "ProgressBar", ")", "refresher", "(", ")", "{", "for", "{", "select", "{", "case", "<-", "pb", ".", "finish", ":", "return", "\n", "case", "<-", "time", ".", "After", "(", "pb", ".", "RefreshRate", ")", ":", "pb", ".", "Up...
// Internal loop for refreshing the progressbar
[ "Internal", "loop", "for", "refreshing", "the", "progressbar" ]
f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11
https://github.com/cheggaaa/pb/blob/f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11/pb.go#L491-L500
147,998
cheggaaa/pb
pb_x.go
catchTerminate
func catchTerminate(shutdownCh chan struct{}) { sig := make(chan os.Signal, 1) signal.Notify(sig, os.Interrupt, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGKILL) defer signal.Stop(sig) select { case <-shutdownCh: unlockEcho() case <-sig: unlockEcho() } }
go
func catchTerminate(shutdownCh chan struct{}) { sig := make(chan os.Signal, 1) signal.Notify(sig, os.Interrupt, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGKILL) defer signal.Stop(sig) select { case <-shutdownCh: unlockEcho() case <-sig: unlockEcho() } }
[ "func", "catchTerminate", "(", "shutdownCh", "chan", "struct", "{", "}", ")", "{", "sig", ":=", "make", "(", "chan", "os", ".", "Signal", ",", "1", ")", "\n", "signal", ".", "Notify", "(", "sig", ",", "os", ".", "Interrupt", ",", "syscall", ".", "S...
// listen exit signals and restore terminal state
[ "listen", "exit", "signals", "and", "restore", "terminal", "state" ]
f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11
https://github.com/cheggaaa/pb/blob/f907f6f5dd81f77c2bbc1cde92e4c5a04720cb11/pb_x.go#L108-L118
147,999
coocood/freecache
iterator.go
Next
func (it *Iterator) Next() *Entry { for it.segmentIdx < 256 { entry := it.nextForSegment(it.segmentIdx) if entry != nil { return entry } it.segmentIdx++ it.slotIdx = 0 it.entryIdx = 0 } return nil }
go
func (it *Iterator) Next() *Entry { for it.segmentIdx < 256 { entry := it.nextForSegment(it.segmentIdx) if entry != nil { return entry } it.segmentIdx++ it.slotIdx = 0 it.entryIdx = 0 } return nil }
[ "func", "(", "it", "*", "Iterator", ")", "Next", "(", ")", "*", "Entry", "{", "for", "it", ".", "segmentIdx", "<", "256", "{", "entry", ":=", "it", ".", "nextForSegment", "(", "it", ".", "segmentIdx", ")", "\n", "if", "entry", "!=", "nil", "{", "...
// Next returns the next entry for the iterator. // The order of the entries is not guaranteed. // If there is no more entries to return, nil will be returned.
[ "Next", "returns", "the", "next", "entry", "for", "the", "iterator", ".", "The", "order", "of", "the", "entries", "is", "not", "guaranteed", ".", "If", "there", "is", "no", "more", "entries", "to", "return", "nil", "will", "be", "returned", "." ]
142b9e1225b0ecdbe420d8fe6cef33f268670c42
https://github.com/coocood/freecache/blob/142b9e1225b0ecdbe420d8fe6cef33f268670c42/iterator.go#L25-L36