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
25,300
hashicorp/yamux
session.go
exitErr
func (s *Session) exitErr(err error) { s.shutdownLock.Lock() if s.shutdownErr == nil { s.shutdownErr = err } s.shutdownLock.Unlock() s.Close() }
go
func (s *Session) exitErr(err error) { s.shutdownLock.Lock() if s.shutdownErr == nil { s.shutdownErr = err } s.shutdownLock.Unlock() s.Close() }
[ "func", "(", "s", "*", "Session", ")", "exitErr", "(", "err", "error", ")", "{", "s", ".", "shutdownLock", ".", "Lock", "(", ")", "\n", "if", "s", ".", "shutdownErr", "==", "nil", "{", "s", ".", "shutdownErr", "=", "err", "\n", "}", "\n", "s", ...
// exitErr is used to handle an error that is causing the // session to terminate.
[ "exitErr", "is", "used", "to", "handle", "an", "error", "that", "is", "causing", "the", "session", "to", "terminate", "." ]
2f1d1f20f75d5404f53b9edf6b53ed5505508675
https://github.com/hashicorp/yamux/blob/2f1d1f20f75d5404f53b9edf6b53ed5505508675/session.go#L250-L257
25,301
hashicorp/yamux
session.go
GoAway
func (s *Session) GoAway() error { return s.waitForSend(s.goAway(goAwayNormal), nil) }
go
func (s *Session) GoAway() error { return s.waitForSend(s.goAway(goAwayNormal), nil) }
[ "func", "(", "s", "*", "Session", ")", "GoAway", "(", ")", "error", "{", "return", "s", ".", "waitForSend", "(", "s", ".", "goAway", "(", "goAwayNormal", ")", ",", "nil", ")", "\n", "}" ]
// GoAway can be used to prevent accepting further // connections. It does not close the underlying conn.
[ "GoAway", "can", "be", "used", "to", "prevent", "accepting", "further", "connections", ".", "It", "does", "not", "close", "the", "underlying", "conn", "." ]
2f1d1f20f75d5404f53b9edf6b53ed5505508675
https://github.com/hashicorp/yamux/blob/2f1d1f20f75d5404f53b9edf6b53ed5505508675/session.go#L261-L263
25,302
hashicorp/yamux
session.go
goAway
func (s *Session) goAway(reason uint32) header { atomic.SwapInt32(&s.localGoAway, 1) hdr := header(make([]byte, headerSize)) hdr.encode(typeGoAway, 0, 0, reason) return hdr }
go
func (s *Session) goAway(reason uint32) header { atomic.SwapInt32(&s.localGoAway, 1) hdr := header(make([]byte, headerSize)) hdr.encode(typeGoAway, 0, 0, reason) return hdr }
[ "func", "(", "s", "*", "Session", ")", "goAway", "(", "reason", "uint32", ")", "header", "{", "atomic", ".", "SwapInt32", "(", "&", "s", ".", "localGoAway", ",", "1", ")", "\n", "hdr", ":=", "header", "(", "make", "(", "[", "]", "byte", ",", "hea...
// goAway is used to send a goAway message
[ "goAway", "is", "used", "to", "send", "a", "goAway", "message" ]
2f1d1f20f75d5404f53b9edf6b53ed5505508675
https://github.com/hashicorp/yamux/blob/2f1d1f20f75d5404f53b9edf6b53ed5505508675/session.go#L266-L271
25,303
hashicorp/yamux
session.go
Ping
func (s *Session) Ping() (time.Duration, error) { // Get a channel for the ping ch := make(chan struct{}) // Get a new ping id, mark as pending s.pingLock.Lock() id := s.pingID s.pingID++ s.pings[id] = ch s.pingLock.Unlock() // Send the ping request hdr := header(make([]byte, headerSize)) hdr.encode(typePi...
go
func (s *Session) Ping() (time.Duration, error) { // Get a channel for the ping ch := make(chan struct{}) // Get a new ping id, mark as pending s.pingLock.Lock() id := s.pingID s.pingID++ s.pings[id] = ch s.pingLock.Unlock() // Send the ping request hdr := header(make([]byte, headerSize)) hdr.encode(typePi...
[ "func", "(", "s", "*", "Session", ")", "Ping", "(", ")", "(", "time", ".", "Duration", ",", "error", ")", "{", "// Get a channel for the ping", "ch", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n\n", "// Get a new ping id, mark as pending", "s", ...
// Ping is used to measure the RTT response time
[ "Ping", "is", "used", "to", "measure", "the", "RTT", "response", "time" ]
2f1d1f20f75d5404f53b9edf6b53ed5505508675
https://github.com/hashicorp/yamux/blob/2f1d1f20f75d5404f53b9edf6b53ed5505508675/session.go#L274-L307
25,304
hashicorp/yamux
session.go
keepalive
func (s *Session) keepalive() { for { select { case <-time.After(s.config.KeepAliveInterval): _, err := s.Ping() if err != nil { if err != ErrSessionShutdown { s.logger.Printf("[ERR] yamux: keepalive failed: %v", err) s.exitErr(ErrKeepAliveTimeout) } return } case <-s.shutdownCh: ...
go
func (s *Session) keepalive() { for { select { case <-time.After(s.config.KeepAliveInterval): _, err := s.Ping() if err != nil { if err != ErrSessionShutdown { s.logger.Printf("[ERR] yamux: keepalive failed: %v", err) s.exitErr(ErrKeepAliveTimeout) } return } case <-s.shutdownCh: ...
[ "func", "(", "s", "*", "Session", ")", "keepalive", "(", ")", "{", "for", "{", "select", "{", "case", "<-", "time", ".", "After", "(", "s", ".", "config", ".", "KeepAliveInterval", ")", ":", "_", ",", "err", ":=", "s", ".", "Ping", "(", ")", "\...
// keepalive is a long running goroutine that periodically does // a ping to keep the connection alive.
[ "keepalive", "is", "a", "long", "running", "goroutine", "that", "periodically", "does", "a", "ping", "to", "keep", "the", "connection", "alive", "." ]
2f1d1f20f75d5404f53b9edf6b53ed5505508675
https://github.com/hashicorp/yamux/blob/2f1d1f20f75d5404f53b9edf6b53ed5505508675/session.go#L311-L327
25,305
hashicorp/yamux
session.go
waitForSend
func (s *Session) waitForSend(hdr header, body io.Reader) error { errCh := make(chan error, 1) return s.waitForSendErr(hdr, body, errCh) }
go
func (s *Session) waitForSend(hdr header, body io.Reader) error { errCh := make(chan error, 1) return s.waitForSendErr(hdr, body, errCh) }
[ "func", "(", "s", "*", "Session", ")", "waitForSend", "(", "hdr", "header", ",", "body", "io", ".", "Reader", ")", "error", "{", "errCh", ":=", "make", "(", "chan", "error", ",", "1", ")", "\n", "return", "s", ".", "waitForSendErr", "(", "hdr", ","...
// waitForSendErr waits to send a header, checking for a potential shutdown
[ "waitForSendErr", "waits", "to", "send", "a", "header", "checking", "for", "a", "potential", "shutdown" ]
2f1d1f20f75d5404f53b9edf6b53ed5505508675
https://github.com/hashicorp/yamux/blob/2f1d1f20f75d5404f53b9edf6b53ed5505508675/session.go#L330-L333
25,306
hashicorp/yamux
session.go
waitForSendErr
func (s *Session) waitForSendErr(hdr header, body io.Reader, errCh chan error) error { t := timerPool.Get() timer := t.(*time.Timer) timer.Reset(s.config.ConnectionWriteTimeout) defer func() { timer.Stop() select { case <-timer.C: default: } timerPool.Put(t) }() ready := sendReady{Hdr: hdr, Body: bod...
go
func (s *Session) waitForSendErr(hdr header, body io.Reader, errCh chan error) error { t := timerPool.Get() timer := t.(*time.Timer) timer.Reset(s.config.ConnectionWriteTimeout) defer func() { timer.Stop() select { case <-timer.C: default: } timerPool.Put(t) }() ready := sendReady{Hdr: hdr, Body: bod...
[ "func", "(", "s", "*", "Session", ")", "waitForSendErr", "(", "hdr", "header", ",", "body", "io", ".", "Reader", ",", "errCh", "chan", "error", ")", "error", "{", "t", ":=", "timerPool", ".", "Get", "(", ")", "\n", "timer", ":=", "t", ".", "(", "...
// waitForSendErr waits to send a header with optional data, checking for a // potential shutdown. Since there's the expectation that sends can happen // in a timely manner, we enforce the connection write timeout here.
[ "waitForSendErr", "waits", "to", "send", "a", "header", "with", "optional", "data", "checking", "for", "a", "potential", "shutdown", ".", "Since", "there", "s", "the", "expectation", "that", "sends", "can", "happen", "in", "a", "timely", "manner", "we", "enf...
2f1d1f20f75d5404f53b9edf6b53ed5505508675
https://github.com/hashicorp/yamux/blob/2f1d1f20f75d5404f53b9edf6b53ed5505508675/session.go#L338-L368
25,307
hashicorp/yamux
session.go
sendNoWait
func (s *Session) sendNoWait(hdr header) error { t := timerPool.Get() timer := t.(*time.Timer) timer.Reset(s.config.ConnectionWriteTimeout) defer func() { timer.Stop() select { case <-timer.C: default: } timerPool.Put(t) }() select { case s.sendCh <- sendReady{Hdr: hdr}: return nil case <-s.shutd...
go
func (s *Session) sendNoWait(hdr header) error { t := timerPool.Get() timer := t.(*time.Timer) timer.Reset(s.config.ConnectionWriteTimeout) defer func() { timer.Stop() select { case <-timer.C: default: } timerPool.Put(t) }() select { case s.sendCh <- sendReady{Hdr: hdr}: return nil case <-s.shutd...
[ "func", "(", "s", "*", "Session", ")", "sendNoWait", "(", "hdr", "header", ")", "error", "{", "t", ":=", "timerPool", ".", "Get", "(", ")", "\n", "timer", ":=", "t", ".", "(", "*", "time", ".", "Timer", ")", "\n", "timer", ".", "Reset", "(", "s...
// sendNoWait does a send without waiting. Since there's the expectation that // the send happens right here, we enforce the connection write timeout if we // can't queue the header to be sent.
[ "sendNoWait", "does", "a", "send", "without", "waiting", ".", "Since", "there", "s", "the", "expectation", "that", "the", "send", "happens", "right", "here", "we", "enforce", "the", "connection", "write", "timeout", "if", "we", "can", "t", "queue", "the", ...
2f1d1f20f75d5404f53b9edf6b53ed5505508675
https://github.com/hashicorp/yamux/blob/2f1d1f20f75d5404f53b9edf6b53ed5505508675/session.go#L373-L394
25,308
hashicorp/yamux
session.go
send
func (s *Session) send() { for { select { case ready := <-s.sendCh: // Send a header if ready if ready.Hdr != nil { sent := 0 for sent < len(ready.Hdr) { n, err := s.conn.Write(ready.Hdr[sent:]) if err != nil { s.logger.Printf("[ERR] yamux: Failed to write header: %v", err) asyn...
go
func (s *Session) send() { for { select { case ready := <-s.sendCh: // Send a header if ready if ready.Hdr != nil { sent := 0 for sent < len(ready.Hdr) { n, err := s.conn.Write(ready.Hdr[sent:]) if err != nil { s.logger.Printf("[ERR] yamux: Failed to write header: %v", err) asyn...
[ "func", "(", "s", "*", "Session", ")", "send", "(", ")", "{", "for", "{", "select", "{", "case", "ready", ":=", "<-", "s", ".", "sendCh", ":", "// Send a header if ready", "if", "ready", ".", "Hdr", "!=", "nil", "{", "sent", ":=", "0", "\n", "for",...
// send is a long running goroutine that sends data
[ "send", "is", "a", "long", "running", "goroutine", "that", "sends", "data" ]
2f1d1f20f75d5404f53b9edf6b53ed5505508675
https://github.com/hashicorp/yamux/blob/2f1d1f20f75d5404f53b9edf6b53ed5505508675/session.go#L397-L433
25,309
hashicorp/yamux
session.go
recv
func (s *Session) recv() { if err := s.recvLoop(); err != nil { s.exitErr(err) } }
go
func (s *Session) recv() { if err := s.recvLoop(); err != nil { s.exitErr(err) } }
[ "func", "(", "s", "*", "Session", ")", "recv", "(", ")", "{", "if", "err", ":=", "s", ".", "recvLoop", "(", ")", ";", "err", "!=", "nil", "{", "s", ".", "exitErr", "(", "err", ")", "\n", "}", "\n", "}" ]
// recv is a long running goroutine that accepts new data
[ "recv", "is", "a", "long", "running", "goroutine", "that", "accepts", "new", "data" ]
2f1d1f20f75d5404f53b9edf6b53ed5505508675
https://github.com/hashicorp/yamux/blob/2f1d1f20f75d5404f53b9edf6b53ed5505508675/session.go#L436-L440
25,310
hashicorp/yamux
session.go
recvLoop
func (s *Session) recvLoop() error { defer close(s.recvDoneCh) hdr := header(make([]byte, headerSize)) for { // Read the header if _, err := io.ReadFull(s.bufRead, hdr); err != nil { if err != io.EOF && !strings.Contains(err.Error(), "closed") && !strings.Contains(err.Error(), "reset by peer") { s.logger....
go
func (s *Session) recvLoop() error { defer close(s.recvDoneCh) hdr := header(make([]byte, headerSize)) for { // Read the header if _, err := io.ReadFull(s.bufRead, hdr); err != nil { if err != io.EOF && !strings.Contains(err.Error(), "closed") && !strings.Contains(err.Error(), "reset by peer") { s.logger....
[ "func", "(", "s", "*", "Session", ")", "recvLoop", "(", ")", "error", "{", "defer", "close", "(", "s", ".", "recvDoneCh", ")", "\n", "hdr", ":=", "header", "(", "make", "(", "[", "]", "byte", ",", "headerSize", ")", ")", "\n", "for", "{", "// Rea...
// recvLoop continues to receive data until a fatal error is encountered
[ "recvLoop", "continues", "to", "receive", "data", "until", "a", "fatal", "error", "is", "encountered" ]
2f1d1f20f75d5404f53b9edf6b53ed5505508675
https://github.com/hashicorp/yamux/blob/2f1d1f20f75d5404f53b9edf6b53ed5505508675/session.go#L453-L480
25,311
hashicorp/yamux
session.go
handleStreamMessage
func (s *Session) handleStreamMessage(hdr header) error { // Check for a new stream creation id := hdr.StreamID() flags := hdr.Flags() if flags&flagSYN == flagSYN { if err := s.incomingStream(id); err != nil { return err } } // Get the stream s.streamLock.Lock() stream := s.streams[id] s.streamLock.Unl...
go
func (s *Session) handleStreamMessage(hdr header) error { // Check for a new stream creation id := hdr.StreamID() flags := hdr.Flags() if flags&flagSYN == flagSYN { if err := s.incomingStream(id); err != nil { return err } } // Get the stream s.streamLock.Lock() stream := s.streams[id] s.streamLock.Unl...
[ "func", "(", "s", "*", "Session", ")", "handleStreamMessage", "(", "hdr", "header", ")", "error", "{", "// Check for a new stream creation", "id", ":=", "hdr", ".", "StreamID", "(", ")", "\n", "flags", ":=", "hdr", ".", "Flags", "(", ")", "\n", "if", "fl...
// handleStreamMessage handles either a data or window update frame
[ "handleStreamMessage", "handles", "either", "a", "data", "or", "window", "update", "frame" ]
2f1d1f20f75d5404f53b9edf6b53ed5505508675
https://github.com/hashicorp/yamux/blob/2f1d1f20f75d5404f53b9edf6b53ed5505508675/session.go#L483-L532
25,312
hashicorp/yamux
session.go
handlePing
func (s *Session) handlePing(hdr header) error { flags := hdr.Flags() pingID := hdr.Length() // Check if this is a query, respond back in a separate context so we // don't interfere with the receiving thread blocking for the write. if flags&flagSYN == flagSYN { go func() { hdr := header(make([]byte, headerSi...
go
func (s *Session) handlePing(hdr header) error { flags := hdr.Flags() pingID := hdr.Length() // Check if this is a query, respond back in a separate context so we // don't interfere with the receiving thread blocking for the write. if flags&flagSYN == flagSYN { go func() { hdr := header(make([]byte, headerSi...
[ "func", "(", "s", "*", "Session", ")", "handlePing", "(", "hdr", "header", ")", "error", "{", "flags", ":=", "hdr", ".", "Flags", "(", ")", "\n", "pingID", ":=", "hdr", ".", "Length", "(", ")", "\n\n", "// Check if this is a query, respond back in a separate...
// handlePing is invokde for a typePing frame
[ "handlePing", "is", "invokde", "for", "a", "typePing", "frame" ]
2f1d1f20f75d5404f53b9edf6b53ed5505508675
https://github.com/hashicorp/yamux/blob/2f1d1f20f75d5404f53b9edf6b53ed5505508675/session.go#L535-L561
25,313
hashicorp/yamux
session.go
handleGoAway
func (s *Session) handleGoAway(hdr header) error { code := hdr.Length() switch code { case goAwayNormal: atomic.SwapInt32(&s.remoteGoAway, 1) case goAwayProtoErr: s.logger.Printf("[ERR] yamux: received protocol error go away") return fmt.Errorf("yamux protocol error") case goAwayInternalErr: s.logger.Print...
go
func (s *Session) handleGoAway(hdr header) error { code := hdr.Length() switch code { case goAwayNormal: atomic.SwapInt32(&s.remoteGoAway, 1) case goAwayProtoErr: s.logger.Printf("[ERR] yamux: received protocol error go away") return fmt.Errorf("yamux protocol error") case goAwayInternalErr: s.logger.Print...
[ "func", "(", "s", "*", "Session", ")", "handleGoAway", "(", "hdr", "header", ")", "error", "{", "code", ":=", "hdr", ".", "Length", "(", ")", "\n", "switch", "code", "{", "case", "goAwayNormal", ":", "atomic", ".", "SwapInt32", "(", "&", "s", ".", ...
// handleGoAway is invokde for a typeGoAway frame
[ "handleGoAway", "is", "invokde", "for", "a", "typeGoAway", "frame" ]
2f1d1f20f75d5404f53b9edf6b53ed5505508675
https://github.com/hashicorp/yamux/blob/2f1d1f20f75d5404f53b9edf6b53ed5505508675/session.go#L564-L580
25,314
hashicorp/yamux
session.go
incomingStream
func (s *Session) incomingStream(id uint32) error { // Reject immediately if we are doing a go away if atomic.LoadInt32(&s.localGoAway) == 1 { hdr := header(make([]byte, headerSize)) hdr.encode(typeWindowUpdate, flagRST, id, 0) return s.sendNoWait(hdr) } // Allocate a new stream stream := newStream(s, id, s...
go
func (s *Session) incomingStream(id uint32) error { // Reject immediately if we are doing a go away if atomic.LoadInt32(&s.localGoAway) == 1 { hdr := header(make([]byte, headerSize)) hdr.encode(typeWindowUpdate, flagRST, id, 0) return s.sendNoWait(hdr) } // Allocate a new stream stream := newStream(s, id, s...
[ "func", "(", "s", "*", "Session", ")", "incomingStream", "(", "id", "uint32", ")", "error", "{", "// Reject immediately if we are doing a go away", "if", "atomic", ".", "LoadInt32", "(", "&", "s", ".", "localGoAway", ")", "==", "1", "{", "hdr", ":=", "header...
// incomingStream is used to create a new incoming stream
[ "incomingStream", "is", "used", "to", "create", "a", "new", "incoming", "stream" ]
2f1d1f20f75d5404f53b9edf6b53ed5505508675
https://github.com/hashicorp/yamux/blob/2f1d1f20f75d5404f53b9edf6b53ed5505508675/session.go#L583-L620
25,315
hashicorp/yamux
session.go
closeStream
func (s *Session) closeStream(id uint32) { s.streamLock.Lock() if _, ok := s.inflight[id]; ok { select { case <-s.synCh: default: s.logger.Printf("[ERR] yamux: SYN tracking out of sync") } } delete(s.streams, id) s.streamLock.Unlock() }
go
func (s *Session) closeStream(id uint32) { s.streamLock.Lock() if _, ok := s.inflight[id]; ok { select { case <-s.synCh: default: s.logger.Printf("[ERR] yamux: SYN tracking out of sync") } } delete(s.streams, id) s.streamLock.Unlock() }
[ "func", "(", "s", "*", "Session", ")", "closeStream", "(", "id", "uint32", ")", "{", "s", ".", "streamLock", ".", "Lock", "(", ")", "\n", "if", "_", ",", "ok", ":=", "s", ".", "inflight", "[", "id", "]", ";", "ok", "{", "select", "{", "case", ...
// closeStream is used to close a stream once both sides have // issued a close. If there was an in-flight SYN and the stream // was not yet established, then this will give the credit back.
[ "closeStream", "is", "used", "to", "close", "a", "stream", "once", "both", "sides", "have", "issued", "a", "close", ".", "If", "there", "was", "an", "in", "-", "flight", "SYN", "and", "the", "stream", "was", "not", "yet", "established", "then", "this", ...
2f1d1f20f75d5404f53b9edf6b53ed5505508675
https://github.com/hashicorp/yamux/blob/2f1d1f20f75d5404f53b9edf6b53ed5505508675/session.go#L625-L636
25,316
afex/hystrix-go
plugins/graphite_aggregator.go
InitializeGraphiteCollector
func InitializeGraphiteCollector(config *GraphiteCollectorConfig) { go metrics.Graphite(metrics.DefaultRegistry, config.TickInterval, config.Prefix, config.GraphiteAddr) }
go
func InitializeGraphiteCollector(config *GraphiteCollectorConfig) { go metrics.Graphite(metrics.DefaultRegistry, config.TickInterval, config.Prefix, config.GraphiteAddr) }
[ "func", "InitializeGraphiteCollector", "(", "config", "*", "GraphiteCollectorConfig", ")", "{", "go", "metrics", ".", "Graphite", "(", "metrics", ".", "DefaultRegistry", ",", "config", ".", "TickInterval", ",", "config", ".", "Prefix", ",", "config", ".", "Graph...
// InitializeGraphiteCollector creates the connection to the graphite server // and should be called before any metrics are recorded.
[ "InitializeGraphiteCollector", "creates", "the", "connection", "to", "the", "graphite", "server", "and", "should", "be", "called", "before", "any", "metrics", "are", "recorded", "." ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/plugins/graphite_aggregator.go#L49-L51
25,317
afex/hystrix-go
hystrix/circuit.go
GetCircuit
func GetCircuit(name string) (*CircuitBreaker, bool, error) { circuitBreakersMutex.RLock() _, ok := circuitBreakers[name] if !ok { circuitBreakersMutex.RUnlock() circuitBreakersMutex.Lock() defer circuitBreakersMutex.Unlock() // because we released the rlock before we obtained the exclusive lock, // we nee...
go
func GetCircuit(name string) (*CircuitBreaker, bool, error) { circuitBreakersMutex.RLock() _, ok := circuitBreakers[name] if !ok { circuitBreakersMutex.RUnlock() circuitBreakersMutex.Lock() defer circuitBreakersMutex.Unlock() // because we released the rlock before we obtained the exclusive lock, // we nee...
[ "func", "GetCircuit", "(", "name", "string", ")", "(", "*", "CircuitBreaker", ",", "bool", ",", "error", ")", "{", "circuitBreakersMutex", ".", "RLock", "(", ")", "\n", "_", ",", "ok", ":=", "circuitBreakers", "[", "name", "]", "\n", "if", "!", "ok", ...
// GetCircuit returns the circuit for the given command and whether this call created it.
[ "GetCircuit", "returns", "the", "circuit", "for", "the", "given", "command", "and", "whether", "this", "call", "created", "it", "." ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/circuit.go#L34-L53
25,318
afex/hystrix-go
hystrix/circuit.go
Flush
func Flush() { circuitBreakersMutex.Lock() defer circuitBreakersMutex.Unlock() for name, cb := range circuitBreakers { cb.metrics.Reset() cb.executorPool.Metrics.Reset() delete(circuitBreakers, name) } }
go
func Flush() { circuitBreakersMutex.Lock() defer circuitBreakersMutex.Unlock() for name, cb := range circuitBreakers { cb.metrics.Reset() cb.executorPool.Metrics.Reset() delete(circuitBreakers, name) } }
[ "func", "Flush", "(", ")", "{", "circuitBreakersMutex", ".", "Lock", "(", ")", "\n", "defer", "circuitBreakersMutex", ".", "Unlock", "(", ")", "\n\n", "for", "name", ",", "cb", ":=", "range", "circuitBreakers", "{", "cb", ".", "metrics", ".", "Reset", "(...
// Flush purges all circuit and metric information from memory.
[ "Flush", "purges", "all", "circuit", "and", "metric", "information", "from", "memory", "." ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/circuit.go#L56-L65
25,319
afex/hystrix-go
hystrix/circuit.go
newCircuitBreaker
func newCircuitBreaker(name string) *CircuitBreaker { c := &CircuitBreaker{} c.Name = name c.metrics = newMetricExchange(name) c.executorPool = newExecutorPool(name) c.mutex = &sync.RWMutex{} return c }
go
func newCircuitBreaker(name string) *CircuitBreaker { c := &CircuitBreaker{} c.Name = name c.metrics = newMetricExchange(name) c.executorPool = newExecutorPool(name) c.mutex = &sync.RWMutex{} return c }
[ "func", "newCircuitBreaker", "(", "name", "string", ")", "*", "CircuitBreaker", "{", "c", ":=", "&", "CircuitBreaker", "{", "}", "\n", "c", ".", "Name", "=", "name", "\n", "c", ".", "metrics", "=", "newMetricExchange", "(", "name", ")", "\n", "c", ".",...
// newCircuitBreaker creates a CircuitBreaker with associated Health
[ "newCircuitBreaker", "creates", "a", "CircuitBreaker", "with", "associated", "Health" ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/circuit.go#L68-L76
25,320
afex/hystrix-go
hystrix/circuit.go
toggleForceOpen
func (circuit *CircuitBreaker) toggleForceOpen(toggle bool) error { circuit, _, err := GetCircuit(circuit.Name) if err != nil { return err } circuit.forceOpen = toggle return nil }
go
func (circuit *CircuitBreaker) toggleForceOpen(toggle bool) error { circuit, _, err := GetCircuit(circuit.Name) if err != nil { return err } circuit.forceOpen = toggle return nil }
[ "func", "(", "circuit", "*", "CircuitBreaker", ")", "toggleForceOpen", "(", "toggle", "bool", ")", "error", "{", "circuit", ",", "_", ",", "err", ":=", "GetCircuit", "(", "circuit", ".", "Name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err"...
// toggleForceOpen allows manually causing the fallback logic for all instances // of a given command.
[ "toggleForceOpen", "allows", "manually", "causing", "the", "fallback", "logic", "for", "all", "instances", "of", "a", "given", "command", "." ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/circuit.go#L80-L88
25,321
afex/hystrix-go
hystrix/circuit.go
IsOpen
func (circuit *CircuitBreaker) IsOpen() bool { circuit.mutex.RLock() o := circuit.forceOpen || circuit.open circuit.mutex.RUnlock() if o { return true } if uint64(circuit.metrics.Requests().Sum(time.Now())) < getSettings(circuit.Name).RequestVolumeThreshold { return false } if !circuit.metrics.IsHealthy(...
go
func (circuit *CircuitBreaker) IsOpen() bool { circuit.mutex.RLock() o := circuit.forceOpen || circuit.open circuit.mutex.RUnlock() if o { return true } if uint64(circuit.metrics.Requests().Sum(time.Now())) < getSettings(circuit.Name).RequestVolumeThreshold { return false } if !circuit.metrics.IsHealthy(...
[ "func", "(", "circuit", "*", "CircuitBreaker", ")", "IsOpen", "(", ")", "bool", "{", "circuit", ".", "mutex", ".", "RLock", "(", ")", "\n", "o", ":=", "circuit", ".", "forceOpen", "||", "circuit", ".", "open", "\n", "circuit", ".", "mutex", ".", "RUn...
// IsOpen is called before any Command execution to check whether or // not it should be attempted. An "open" circuit means it is disabled.
[ "IsOpen", "is", "called", "before", "any", "Command", "execution", "to", "check", "whether", "or", "not", "it", "should", "be", "attempted", ".", "An", "open", "circuit", "means", "it", "is", "disabled", "." ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/circuit.go#L92-L112
25,322
afex/hystrix-go
hystrix/circuit.go
ReportEvent
func (circuit *CircuitBreaker) ReportEvent(eventTypes []string, start time.Time, runDuration time.Duration) error { if len(eventTypes) == 0 { return fmt.Errorf("no event types sent for metrics") } circuit.mutex.RLock() o := circuit.open circuit.mutex.RUnlock() if eventTypes[0] == "success" && o { circuit.set...
go
func (circuit *CircuitBreaker) ReportEvent(eventTypes []string, start time.Time, runDuration time.Duration) error { if len(eventTypes) == 0 { return fmt.Errorf("no event types sent for metrics") } circuit.mutex.RLock() o := circuit.open circuit.mutex.RUnlock() if eventTypes[0] == "success" && o { circuit.set...
[ "func", "(", "circuit", "*", "CircuitBreaker", ")", "ReportEvent", "(", "eventTypes", "[", "]", "string", ",", "start", "time", ".", "Time", ",", "runDuration", "time", ".", "Duration", ")", "error", "{", "if", "len", "(", "eventTypes", ")", "==", "0", ...
// ReportEvent records command metrics for tracking recent error rates and exposing data to the dashboard.
[ "ReportEvent", "records", "command", "metrics", "for", "tracking", "recent", "error", "rates", "and", "exposing", "data", "to", "the", "dashboard", "." ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/circuit.go#L167-L196
25,323
afex/hystrix-go
hystrix/rolling/rolling.go
NewNumber
func NewNumber() *Number { r := &Number{ Buckets: make(map[int64]*numberBucket), Mutex: &sync.RWMutex{}, } return r }
go
func NewNumber() *Number { r := &Number{ Buckets: make(map[int64]*numberBucket), Mutex: &sync.RWMutex{}, } return r }
[ "func", "NewNumber", "(", ")", "*", "Number", "{", "r", ":=", "&", "Number", "{", "Buckets", ":", "make", "(", "map", "[", "int64", "]", "*", "numberBucket", ")", ",", "Mutex", ":", "&", "sync", ".", "RWMutex", "{", "}", ",", "}", "\n", "return",...
// NewNumber initializes a RollingNumber struct.
[ "NewNumber", "initializes", "a", "RollingNumber", "struct", "." ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/rolling/rolling.go#L20-L26
25,324
afex/hystrix-go
hystrix/rolling/rolling.go
Increment
func (r *Number) Increment(i float64) { if i == 0 { return } r.Mutex.Lock() defer r.Mutex.Unlock() b := r.getCurrentBucket() b.Value += i r.removeOldBuckets() }
go
func (r *Number) Increment(i float64) { if i == 0 { return } r.Mutex.Lock() defer r.Mutex.Unlock() b := r.getCurrentBucket() b.Value += i r.removeOldBuckets() }
[ "func", "(", "r", "*", "Number", ")", "Increment", "(", "i", "float64", ")", "{", "if", "i", "==", "0", "{", "return", "\n", "}", "\n\n", "r", ".", "Mutex", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "Mutex", ".", "Unlock", "(", ")", "\n...
// Increment increments the number in current timeBucket.
[ "Increment", "increments", "the", "number", "in", "current", "timeBucket", "." ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/rolling/rolling.go#L53-L64
25,325
afex/hystrix-go
hystrix/rolling/rolling.go
UpdateMax
func (r *Number) UpdateMax(n float64) { r.Mutex.Lock() defer r.Mutex.Unlock() b := r.getCurrentBucket() if n > b.Value { b.Value = n } r.removeOldBuckets() }
go
func (r *Number) UpdateMax(n float64) { r.Mutex.Lock() defer r.Mutex.Unlock() b := r.getCurrentBucket() if n > b.Value { b.Value = n } r.removeOldBuckets() }
[ "func", "(", "r", "*", "Number", ")", "UpdateMax", "(", "n", "float64", ")", "{", "r", ".", "Mutex", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "Mutex", ".", "Unlock", "(", ")", "\n\n", "b", ":=", "r", ".", "getCurrentBucket", "(", ")", "\...
// UpdateMax updates the maximum value in the current bucket.
[ "UpdateMax", "updates", "the", "maximum", "value", "in", "the", "current", "bucket", "." ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/rolling/rolling.go#L67-L76
25,326
afex/hystrix-go
hystrix/rolling/rolling.go
Sum
func (r *Number) Sum(now time.Time) float64 { sum := float64(0) r.Mutex.RLock() defer r.Mutex.RUnlock() for timestamp, bucket := range r.Buckets { // TODO: configurable rolling window if timestamp >= now.Unix()-10 { sum += bucket.Value } } return sum }
go
func (r *Number) Sum(now time.Time) float64 { sum := float64(0) r.Mutex.RLock() defer r.Mutex.RUnlock() for timestamp, bucket := range r.Buckets { // TODO: configurable rolling window if timestamp >= now.Unix()-10 { sum += bucket.Value } } return sum }
[ "func", "(", "r", "*", "Number", ")", "Sum", "(", "now", "time", ".", "Time", ")", "float64", "{", "sum", ":=", "float64", "(", "0", ")", "\n\n", "r", ".", "Mutex", ".", "RLock", "(", ")", "\n", "defer", "r", ".", "Mutex", ".", "RUnlock", "(", ...
// Sum sums the values over the buckets in the last 10 seconds.
[ "Sum", "sums", "the", "values", "over", "the", "buckets", "in", "the", "last", "10", "seconds", "." ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/rolling/rolling.go#L79-L93
25,327
afex/hystrix-go
hystrix/rolling/rolling.go
Max
func (r *Number) Max(now time.Time) float64 { var max float64 r.Mutex.RLock() defer r.Mutex.RUnlock() for timestamp, bucket := range r.Buckets { // TODO: configurable rolling window if timestamp >= now.Unix()-10 { if bucket.Value > max { max = bucket.Value } } } return max }
go
func (r *Number) Max(now time.Time) float64 { var max float64 r.Mutex.RLock() defer r.Mutex.RUnlock() for timestamp, bucket := range r.Buckets { // TODO: configurable rolling window if timestamp >= now.Unix()-10 { if bucket.Value > max { max = bucket.Value } } } return max }
[ "func", "(", "r", "*", "Number", ")", "Max", "(", "now", "time", ".", "Time", ")", "float64", "{", "var", "max", "float64", "\n\n", "r", ".", "Mutex", ".", "RLock", "(", ")", "\n", "defer", "r", ".", "Mutex", ".", "RUnlock", "(", ")", "\n\n", "...
// Max returns the maximum value seen in the last 10 seconds.
[ "Max", "returns", "the", "maximum", "value", "seen", "in", "the", "last", "10", "seconds", "." ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/rolling/rolling.go#L96-L112
25,328
afex/hystrix-go
hystrix/hystrix.go
Go
func Go(name string, run runFunc, fallback fallbackFunc) chan error { runC := func(ctx context.Context) error { return run() } var fallbackC fallbackFuncC if fallback != nil { fallbackC = func(ctx context.Context, err error) error { return fallback(err) } } return GoC(context.Background(), name, runC, fa...
go
func Go(name string, run runFunc, fallback fallbackFunc) chan error { runC := func(ctx context.Context) error { return run() } var fallbackC fallbackFuncC if fallback != nil { fallbackC = func(ctx context.Context, err error) error { return fallback(err) } } return GoC(context.Background(), name, runC, fa...
[ "func", "Go", "(", "name", "string", ",", "run", "runFunc", ",", "fallback", "fallbackFunc", ")", "chan", "error", "{", "runC", ":=", "func", "(", "ctx", "context", ".", "Context", ")", "error", "{", "return", "run", "(", ")", "\n", "}", "\n", "var",...
// Go runs your function while tracking the health of previous calls to it. // If your function begins slowing down or failing repeatedly, we will block // new calls to it for you to give the dependent service time to repair. // // Define a fallback function if you want to define some code to execute during outages.
[ "Go", "runs", "your", "function", "while", "tracking", "the", "health", "of", "previous", "calls", "to", "it", ".", "If", "your", "function", "begins", "slowing", "down", "or", "failing", "repeatedly", "we", "will", "block", "new", "calls", "to", "it", "fo...
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/hystrix.go#L55-L66
25,329
afex/hystrix-go
hystrix/hystrix.go
DoC
func DoC(ctx context.Context, name string, run runFuncC, fallback fallbackFuncC) error { done := make(chan struct{}, 1) r := func(ctx context.Context) error { err := run(ctx) if err != nil { return err } done <- struct{}{} return nil } f := func(ctx context.Context, e error) error { err := fallbac...
go
func DoC(ctx context.Context, name string, run runFuncC, fallback fallbackFuncC) error { done := make(chan struct{}, 1) r := func(ctx context.Context) error { err := run(ctx) if err != nil { return err } done <- struct{}{} return nil } f := func(ctx context.Context, e error) error { err := fallbac...
[ "func", "DoC", "(", "ctx", "context", ".", "Context", ",", "name", "string", ",", "run", "runFuncC", ",", "fallback", "fallbackFuncC", ")", "error", "{", "done", ":=", "make", "(", "chan", "struct", "{", "}", ",", "1", ")", "\n\n", "r", ":=", "func",...
// DoC runs your function in a synchronous manner, blocking until either your function succeeds // or an error is returned, including hystrix circuit errors
[ "DoC", "runs", "your", "function", "in", "a", "synchronous", "manner", "blocking", "until", "either", "your", "function", "succeeds", "or", "an", "error", "is", "returned", "including", "hystrix", "circuit", "errors" ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/hystrix.go#L217-L253
25,330
afex/hystrix-go
hystrix/hystrix.go
errorWithFallback
func (c *command) errorWithFallback(ctx context.Context, err error) { eventType := "failure" if err == ErrCircuitOpen { eventType = "short-circuit" } else if err == ErrMaxConcurrency { eventType = "rejected" } else if err == ErrTimeout { eventType = "timeout" } else if err == context.Canceled { eventType =...
go
func (c *command) errorWithFallback(ctx context.Context, err error) { eventType := "failure" if err == ErrCircuitOpen { eventType = "short-circuit" } else if err == ErrMaxConcurrency { eventType = "rejected" } else if err == ErrTimeout { eventType = "timeout" } else if err == context.Canceled { eventType =...
[ "func", "(", "c", "*", "command", ")", "errorWithFallback", "(", "ctx", "context", ".", "Context", ",", "err", "error", ")", "{", "eventType", ":=", "\"", "\"", "\n", "if", "err", "==", "ErrCircuitOpen", "{", "eventType", "=", "\"", "\"", "\n", "}", ...
// errorWithFallback triggers the fallback while reporting the appropriate metric events.
[ "errorWithFallback", "triggers", "the", "fallback", "while", "reporting", "the", "appropriate", "metric", "events", "." ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/hystrix.go#L263-L282
25,331
afex/hystrix-go
hystrix/settings.go
Configure
func Configure(cmds map[string]CommandConfig) { for k, v := range cmds { ConfigureCommand(k, v) } }
go
func Configure(cmds map[string]CommandConfig) { for k, v := range cmds { ConfigureCommand(k, v) } }
[ "func", "Configure", "(", "cmds", "map", "[", "string", "]", "CommandConfig", ")", "{", "for", "k", ",", "v", ":=", "range", "cmds", "{", "ConfigureCommand", "(", "k", ",", "v", ")", "\n", "}", "\n", "}" ]
// Configure applies settings for a set of circuits
[ "Configure", "applies", "settings", "for", "a", "set", "of", "circuits" ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/settings.go#L51-L55
25,332
afex/hystrix-go
hystrix/settings.go
ConfigureCommand
func ConfigureCommand(name string, config CommandConfig) { settingsMutex.Lock() defer settingsMutex.Unlock() timeout := DefaultTimeout if config.Timeout != 0 { timeout = config.Timeout } max := DefaultMaxConcurrent if config.MaxConcurrentRequests != 0 { max = config.MaxConcurrentRequests } volume := Def...
go
func ConfigureCommand(name string, config CommandConfig) { settingsMutex.Lock() defer settingsMutex.Unlock() timeout := DefaultTimeout if config.Timeout != 0 { timeout = config.Timeout } max := DefaultMaxConcurrent if config.MaxConcurrentRequests != 0 { max = config.MaxConcurrentRequests } volume := Def...
[ "func", "ConfigureCommand", "(", "name", "string", ",", "config", "CommandConfig", ")", "{", "settingsMutex", ".", "Lock", "(", ")", "\n", "defer", "settingsMutex", ".", "Unlock", "(", ")", "\n\n", "timeout", ":=", "DefaultTimeout", "\n", "if", "config", "."...
// ConfigureCommand applies settings for a circuit
[ "ConfigureCommand", "applies", "settings", "for", "a", "circuit" ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/settings.go#L58-L94
25,333
afex/hystrix-go
hystrix/metric_collector/default_metric_collector.go
NumRequests
func (d *DefaultMetricCollector) NumRequests() *rolling.Number { d.mutex.RLock() defer d.mutex.RUnlock() return d.numRequests }
go
func (d *DefaultMetricCollector) NumRequests() *rolling.Number { d.mutex.RLock() defer d.mutex.RUnlock() return d.numRequests }
[ "func", "(", "d", "*", "DefaultMetricCollector", ")", "NumRequests", "(", ")", "*", "rolling", ".", "Number", "{", "d", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "d", ".", "mutex", ".", "RUnlock", "(", ")", "\n", "return", "d", ".", "num...
// NumRequests returns the rolling number of requests
[ "NumRequests", "returns", "the", "rolling", "number", "of", "requests" ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/metric_collector/default_metric_collector.go#L43-L47
25,334
afex/hystrix-go
hystrix/metric_collector/default_metric_collector.go
Errors
func (d *DefaultMetricCollector) Errors() *rolling.Number { d.mutex.RLock() defer d.mutex.RUnlock() return d.errors }
go
func (d *DefaultMetricCollector) Errors() *rolling.Number { d.mutex.RLock() defer d.mutex.RUnlock() return d.errors }
[ "func", "(", "d", "*", "DefaultMetricCollector", ")", "Errors", "(", ")", "*", "rolling", ".", "Number", "{", "d", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "d", ".", "mutex", ".", "RUnlock", "(", ")", "\n", "return", "d", ".", "errors",...
// Errors returns the rolling number of errors
[ "Errors", "returns", "the", "rolling", "number", "of", "errors" ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/metric_collector/default_metric_collector.go#L50-L54
25,335
afex/hystrix-go
hystrix/metric_collector/default_metric_collector.go
Successes
func (d *DefaultMetricCollector) Successes() *rolling.Number { d.mutex.RLock() defer d.mutex.RUnlock() return d.successes }
go
func (d *DefaultMetricCollector) Successes() *rolling.Number { d.mutex.RLock() defer d.mutex.RUnlock() return d.successes }
[ "func", "(", "d", "*", "DefaultMetricCollector", ")", "Successes", "(", ")", "*", "rolling", ".", "Number", "{", "d", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "d", ".", "mutex", ".", "RUnlock", "(", ")", "\n", "return", "d", ".", "succe...
// Successes returns the rolling number of successes
[ "Successes", "returns", "the", "rolling", "number", "of", "successes" ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/metric_collector/default_metric_collector.go#L57-L61
25,336
afex/hystrix-go
hystrix/metric_collector/default_metric_collector.go
Failures
func (d *DefaultMetricCollector) Failures() *rolling.Number { d.mutex.RLock() defer d.mutex.RUnlock() return d.failures }
go
func (d *DefaultMetricCollector) Failures() *rolling.Number { d.mutex.RLock() defer d.mutex.RUnlock() return d.failures }
[ "func", "(", "d", "*", "DefaultMetricCollector", ")", "Failures", "(", ")", "*", "rolling", ".", "Number", "{", "d", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "d", ".", "mutex", ".", "RUnlock", "(", ")", "\n", "return", "d", ".", "failur...
// Failures returns the rolling number of failures
[ "Failures", "returns", "the", "rolling", "number", "of", "failures" ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/metric_collector/default_metric_collector.go#L64-L68
25,337
afex/hystrix-go
hystrix/metric_collector/default_metric_collector.go
Rejects
func (d *DefaultMetricCollector) Rejects() *rolling.Number { d.mutex.RLock() defer d.mutex.RUnlock() return d.rejects }
go
func (d *DefaultMetricCollector) Rejects() *rolling.Number { d.mutex.RLock() defer d.mutex.RUnlock() return d.rejects }
[ "func", "(", "d", "*", "DefaultMetricCollector", ")", "Rejects", "(", ")", "*", "rolling", ".", "Number", "{", "d", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "d", ".", "mutex", ".", "RUnlock", "(", ")", "\n", "return", "d", ".", "rejects...
// Rejects returns the rolling number of rejects
[ "Rejects", "returns", "the", "rolling", "number", "of", "rejects" ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/metric_collector/default_metric_collector.go#L71-L75
25,338
afex/hystrix-go
hystrix/metric_collector/default_metric_collector.go
ShortCircuits
func (d *DefaultMetricCollector) ShortCircuits() *rolling.Number { d.mutex.RLock() defer d.mutex.RUnlock() return d.shortCircuits }
go
func (d *DefaultMetricCollector) ShortCircuits() *rolling.Number { d.mutex.RLock() defer d.mutex.RUnlock() return d.shortCircuits }
[ "func", "(", "d", "*", "DefaultMetricCollector", ")", "ShortCircuits", "(", ")", "*", "rolling", ".", "Number", "{", "d", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "d", ".", "mutex", ".", "RUnlock", "(", ")", "\n", "return", "d", ".", "s...
// ShortCircuits returns the rolling number of short circuits
[ "ShortCircuits", "returns", "the", "rolling", "number", "of", "short", "circuits" ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/metric_collector/default_metric_collector.go#L78-L82
25,339
afex/hystrix-go
hystrix/metric_collector/default_metric_collector.go
Timeouts
func (d *DefaultMetricCollector) Timeouts() *rolling.Number { d.mutex.RLock() defer d.mutex.RUnlock() return d.timeouts }
go
func (d *DefaultMetricCollector) Timeouts() *rolling.Number { d.mutex.RLock() defer d.mutex.RUnlock() return d.timeouts }
[ "func", "(", "d", "*", "DefaultMetricCollector", ")", "Timeouts", "(", ")", "*", "rolling", ".", "Number", "{", "d", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "d", ".", "mutex", ".", "RUnlock", "(", ")", "\n", "return", "d", ".", "timeou...
// Timeouts returns the rolling number of timeouts
[ "Timeouts", "returns", "the", "rolling", "number", "of", "timeouts" ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/metric_collector/default_metric_collector.go#L85-L89
25,340
afex/hystrix-go
hystrix/metric_collector/default_metric_collector.go
FallbackSuccesses
func (d *DefaultMetricCollector) FallbackSuccesses() *rolling.Number { d.mutex.RLock() defer d.mutex.RUnlock() return d.fallbackSuccesses }
go
func (d *DefaultMetricCollector) FallbackSuccesses() *rolling.Number { d.mutex.RLock() defer d.mutex.RUnlock() return d.fallbackSuccesses }
[ "func", "(", "d", "*", "DefaultMetricCollector", ")", "FallbackSuccesses", "(", ")", "*", "rolling", ".", "Number", "{", "d", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "d", ".", "mutex", ".", "RUnlock", "(", ")", "\n", "return", "d", ".", ...
// FallbackSuccesses returns the rolling number of fallback successes
[ "FallbackSuccesses", "returns", "the", "rolling", "number", "of", "fallback", "successes" ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/metric_collector/default_metric_collector.go#L92-L96
25,341
afex/hystrix-go
hystrix/metric_collector/default_metric_collector.go
FallbackFailures
func (d *DefaultMetricCollector) FallbackFailures() *rolling.Number { d.mutex.RLock() defer d.mutex.RUnlock() return d.fallbackFailures }
go
func (d *DefaultMetricCollector) FallbackFailures() *rolling.Number { d.mutex.RLock() defer d.mutex.RUnlock() return d.fallbackFailures }
[ "func", "(", "d", "*", "DefaultMetricCollector", ")", "FallbackFailures", "(", ")", "*", "rolling", ".", "Number", "{", "d", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "d", ".", "mutex", ".", "RUnlock", "(", ")", "\n", "return", "d", ".", ...
// FallbackFailures returns the rolling number of fallback failures
[ "FallbackFailures", "returns", "the", "rolling", "number", "of", "fallback", "failures" ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/metric_collector/default_metric_collector.go#L111-L115
25,342
afex/hystrix-go
hystrix/metric_collector/default_metric_collector.go
TotalDuration
func (d *DefaultMetricCollector) TotalDuration() *rolling.Timing { d.mutex.RLock() defer d.mutex.RUnlock() return d.totalDuration }
go
func (d *DefaultMetricCollector) TotalDuration() *rolling.Timing { d.mutex.RLock() defer d.mutex.RUnlock() return d.totalDuration }
[ "func", "(", "d", "*", "DefaultMetricCollector", ")", "TotalDuration", "(", ")", "*", "rolling", ".", "Timing", "{", "d", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "d", ".", "mutex", ".", "RUnlock", "(", ")", "\n", "return", "d", ".", "t...
// TotalDuration returns the rolling total duration
[ "TotalDuration", "returns", "the", "rolling", "total", "duration" ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/metric_collector/default_metric_collector.go#L118-L122
25,343
afex/hystrix-go
hystrix/metric_collector/default_metric_collector.go
RunDuration
func (d *DefaultMetricCollector) RunDuration() *rolling.Timing { d.mutex.RLock() defer d.mutex.RUnlock() return d.runDuration }
go
func (d *DefaultMetricCollector) RunDuration() *rolling.Timing { d.mutex.RLock() defer d.mutex.RUnlock() return d.runDuration }
[ "func", "(", "d", "*", "DefaultMetricCollector", ")", "RunDuration", "(", ")", "*", "rolling", ".", "Timing", "{", "d", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "d", ".", "mutex", ".", "RUnlock", "(", ")", "\n", "return", "d", ".", "run...
// RunDuration returns the rolling run duration
[ "RunDuration", "returns", "the", "rolling", "run", "duration" ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/metric_collector/default_metric_collector.go#L125-L129
25,344
afex/hystrix-go
hystrix/metric_collector/default_metric_collector.go
Reset
func (d *DefaultMetricCollector) Reset() { d.mutex.Lock() defer d.mutex.Unlock() d.numRequests = rolling.NewNumber() d.errors = rolling.NewNumber() d.successes = rolling.NewNumber() d.rejects = rolling.NewNumber() d.shortCircuits = rolling.NewNumber() d.failures = rolling.NewNumber() d.timeouts = rolling.NewN...
go
func (d *DefaultMetricCollector) Reset() { d.mutex.Lock() defer d.mutex.Unlock() d.numRequests = rolling.NewNumber() d.errors = rolling.NewNumber() d.successes = rolling.NewNumber() d.rejects = rolling.NewNumber() d.shortCircuits = rolling.NewNumber() d.failures = rolling.NewNumber() d.timeouts = rolling.NewN...
[ "func", "(", "d", "*", "DefaultMetricCollector", ")", "Reset", "(", ")", "{", "d", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "d", ".", "mutex", ".", "Unlock", "(", ")", "\n\n", "d", ".", "numRequests", "=", "rolling", ".", "NewNumber", "(...
// Reset resets all metrics in this collector to 0.
[ "Reset", "resets", "all", "metrics", "in", "this", "collector", "to", "0", "." ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/metric_collector/default_metric_collector.go#L152-L169
25,345
afex/hystrix-go
hystrix/rolling/rolling_timing.go
NewTiming
func NewTiming() *Timing { r := &Timing{ Buckets: make(map[int64]*timingBucket), Mutex: &sync.RWMutex{}, } return r }
go
func NewTiming() *Timing { r := &Timing{ Buckets: make(map[int64]*timingBucket), Mutex: &sync.RWMutex{}, } return r }
[ "func", "NewTiming", "(", ")", "*", "Timing", "{", "r", ":=", "&", "Timing", "{", "Buckets", ":", "make", "(", "map", "[", "int64", "]", "*", "timingBucket", ")", ",", "Mutex", ":", "&", "sync", ".", "RWMutex", "{", "}", ",", "}", "\n", "return",...
// NewTiming creates a RollingTiming struct.
[ "NewTiming", "creates", "a", "RollingTiming", "struct", "." ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/rolling/rolling_timing.go#L26-L32
25,346
afex/hystrix-go
hystrix/rolling/rolling_timing.go
SortedDurations
func (r *Timing) SortedDurations() []time.Duration { r.Mutex.RLock() t := r.LastCachedTime r.Mutex.RUnlock() if t+time.Duration(1*time.Second).Nanoseconds() > time.Now().UnixNano() { // don't recalculate if current cache is still fresh return r.CachedSortedDurations } var durations byDuration now := time.N...
go
func (r *Timing) SortedDurations() []time.Duration { r.Mutex.RLock() t := r.LastCachedTime r.Mutex.RUnlock() if t+time.Duration(1*time.Second).Nanoseconds() > time.Now().UnixNano() { // don't recalculate if current cache is still fresh return r.CachedSortedDurations } var durations byDuration now := time.N...
[ "func", "(", "r", "*", "Timing", ")", "SortedDurations", "(", ")", "[", "]", "time", ".", "Duration", "{", "r", ".", "Mutex", ".", "RLock", "(", ")", "\n", "t", ":=", "r", ".", "LastCachedTime", "\n", "r", ".", "Mutex", ".", "RUnlock", "(", ")", ...
// SortedDurations returns an array of time.Duration sorted from shortest // to longest that have occurred in the last 60 seconds.
[ "SortedDurations", "returns", "an", "array", "of", "time", ".", "Duration", "sorted", "from", "shortest", "to", "longest", "that", "have", "occurred", "in", "the", "last", "60", "seconds", "." ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/rolling/rolling_timing.go#L42-L73
25,347
afex/hystrix-go
hystrix/rolling/rolling_timing.go
Add
func (r *Timing) Add(duration time.Duration) { b := r.getCurrentBucket() r.Mutex.Lock() defer r.Mutex.Unlock() b.Durations = append(b.Durations, duration) r.removeOldBuckets() }
go
func (r *Timing) Add(duration time.Duration) { b := r.getCurrentBucket() r.Mutex.Lock() defer r.Mutex.Unlock() b.Durations = append(b.Durations, duration) r.removeOldBuckets() }
[ "func", "(", "r", "*", "Timing", ")", "Add", "(", "duration", "time", ".", "Duration", ")", "{", "b", ":=", "r", ".", "getCurrentBucket", "(", ")", "\n\n", "r", ".", "Mutex", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "Mutex", ".", "Unlock",...
// Add appends the time.Duration given to the current time bucket.
[ "Add", "appends", "the", "time", ".", "Duration", "given", "to", "the", "current", "time", "bucket", "." ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/rolling/rolling_timing.go#L104-L112
25,348
afex/hystrix-go
hystrix/rolling/rolling_timing.go
Percentile
func (r *Timing) Percentile(p float64) uint32 { sortedDurations := r.SortedDurations() length := len(sortedDurations) if length <= 0 { return 0 } pos := r.ordinal(len(sortedDurations), p) - 1 return uint32(sortedDurations[pos].Nanoseconds() / 1000000) }
go
func (r *Timing) Percentile(p float64) uint32 { sortedDurations := r.SortedDurations() length := len(sortedDurations) if length <= 0 { return 0 } pos := r.ordinal(len(sortedDurations), p) - 1 return uint32(sortedDurations[pos].Nanoseconds() / 1000000) }
[ "func", "(", "r", "*", "Timing", ")", "Percentile", "(", "p", "float64", ")", "uint32", "{", "sortedDurations", ":=", "r", ".", "SortedDurations", "(", ")", "\n", "length", ":=", "len", "(", "sortedDurations", ")", "\n", "if", "length", "<=", "0", "{",...
// Percentile computes the percentile given with a linear interpolation.
[ "Percentile", "computes", "the", "percentile", "given", "with", "a", "linear", "interpolation", "." ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/rolling/rolling_timing.go#L115-L124
25,349
afex/hystrix-go
hystrix/rolling/rolling_timing.go
Mean
func (r *Timing) Mean() uint32 { sortedDurations := r.SortedDurations() var sum time.Duration for _, d := range sortedDurations { sum += d } length := int64(len(sortedDurations)) if length == 0 { return 0 } return uint32(sum.Nanoseconds()/length) / 1000000 }
go
func (r *Timing) Mean() uint32 { sortedDurations := r.SortedDurations() var sum time.Duration for _, d := range sortedDurations { sum += d } length := int64(len(sortedDurations)) if length == 0 { return 0 } return uint32(sum.Nanoseconds()/length) / 1000000 }
[ "func", "(", "r", "*", "Timing", ")", "Mean", "(", ")", "uint32", "{", "sortedDurations", ":=", "r", ".", "SortedDurations", "(", ")", "\n", "var", "sum", "time", ".", "Duration", "\n", "for", "_", ",", "d", ":=", "range", "sortedDurations", "{", "su...
// Mean computes the average timing in the last 60 seconds.
[ "Mean", "computes", "the", "average", "timing", "in", "the", "last", "60", "seconds", "." ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/rolling/rolling_timing.go#L135-L148
25,350
afex/hystrix-go
hystrix/metrics.go
DefaultCollector
func (m *metricExchange) DefaultCollector() *metricCollector.DefaultMetricCollector { if len(m.metricCollectors) < 1 { panic("No Metric Collectors Registered.") } collection, ok := m.metricCollectors[0].(*metricCollector.DefaultMetricCollector) if !ok { panic("Default metric collector is not registered correctl...
go
func (m *metricExchange) DefaultCollector() *metricCollector.DefaultMetricCollector { if len(m.metricCollectors) < 1 { panic("No Metric Collectors Registered.") } collection, ok := m.metricCollectors[0].(*metricCollector.DefaultMetricCollector) if !ok { panic("Default metric collector is not registered correctl...
[ "func", "(", "m", "*", "metricExchange", ")", "DefaultCollector", "(", ")", "*", "metricCollector", ".", "DefaultMetricCollector", "{", "if", "len", "(", "m", ".", "metricCollectors", ")", "<", "1", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", ...
// The Default Collector function will panic if collectors are not setup to specification.
[ "The", "Default", "Collector", "function", "will", "panic", "if", "collectors", "are", "not", "setup", "to", "specification", "." ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/metrics.go#L41-L50
25,351
afex/hystrix-go
hystrix/eventstream.go
Start
func (sh *StreamHandler) Start() { sh.requests = make(map[*http.Request]chan []byte) sh.done = make(chan struct{}) go sh.loop() }
go
func (sh *StreamHandler) Start() { sh.requests = make(map[*http.Request]chan []byte) sh.done = make(chan struct{}) go sh.loop() }
[ "func", "(", "sh", "*", "StreamHandler", ")", "Start", "(", ")", "{", "sh", ".", "requests", "=", "make", "(", "map", "[", "*", "http", ".", "Request", "]", "chan", "[", "]", "byte", ")", "\n", "sh", ".", "done", "=", "make", "(", "chan", "stru...
// Start begins watching the in-memory circuit breakers for metrics
[ "Start", "begins", "watching", "the", "in", "-", "memory", "circuit", "breakers", "for", "metrics" ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/eventstream.go#L30-L34
25,352
afex/hystrix-go
hystrix/metric_collector/metric_collector.go
InitializeMetricCollectors
func (m *metricCollectorRegistry) InitializeMetricCollectors(name string) []MetricCollector { m.lock.RLock() defer m.lock.RUnlock() metrics := make([]MetricCollector, len(m.registry)) for i, metricCollectorInitializer := range m.registry { metrics[i] = metricCollectorInitializer(name) } return metrics }
go
func (m *metricCollectorRegistry) InitializeMetricCollectors(name string) []MetricCollector { m.lock.RLock() defer m.lock.RUnlock() metrics := make([]MetricCollector, len(m.registry)) for i, metricCollectorInitializer := range m.registry { metrics[i] = metricCollectorInitializer(name) } return metrics }
[ "func", "(", "m", "*", "metricCollectorRegistry", ")", "InitializeMetricCollectors", "(", "name", "string", ")", "[", "]", "MetricCollector", "{", "m", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "m", ".", "lock", ".", "RUnlock", "(", ")", "\n\n"...
// InitializeMetricCollectors runs the registried MetricCollector Initializers to create an array of MetricCollectors.
[ "InitializeMetricCollectors", "runs", "the", "registried", "MetricCollector", "Initializers", "to", "create", "an", "array", "of", "MetricCollectors", "." ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/metric_collector/metric_collector.go#L23-L32
25,353
afex/hystrix-go
hystrix/metric_collector/metric_collector.go
Register
func (m *metricCollectorRegistry) Register(initMetricCollector func(string) MetricCollector) { m.lock.Lock() defer m.lock.Unlock() m.registry = append(m.registry, initMetricCollector) }
go
func (m *metricCollectorRegistry) Register(initMetricCollector func(string) MetricCollector) { m.lock.Lock() defer m.lock.Unlock() m.registry = append(m.registry, initMetricCollector) }
[ "func", "(", "m", "*", "metricCollectorRegistry", ")", "Register", "(", "initMetricCollector", "func", "(", "string", ")", "MetricCollector", ")", "{", "m", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "lock", ".", "Unlock", "(", ")", "...
// Register places a MetricCollector Initializer in the registry maintained by this metricCollectorRegistry.
[ "Register", "places", "a", "MetricCollector", "Initializer", "in", "the", "registry", "maintained", "by", "this", "metricCollectorRegistry", "." ]
fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a
https://github.com/afex/hystrix-go/blob/fa1af6a1f4f56e0e50d427fe901cd604d8c6fb8a/hystrix/metric_collector/metric_collector.go#L35-L40
25,354
kardianos/service
version.go
versionAtMost
func versionAtMost(version, max []int) (bool, error) { if comp, err := versionCompare(version, max); err != nil { return false, err } else if comp == 1 { return false, nil } return true, nil }
go
func versionAtMost(version, max []int) (bool, error) { if comp, err := versionCompare(version, max); err != nil { return false, err } else if comp == 1 { return false, nil } return true, nil }
[ "func", "versionAtMost", "(", "version", ",", "max", "[", "]", "int", ")", "(", "bool", ",", "error", ")", "{", "if", "comp", ",", "err", ":=", "versionCompare", "(", "version", ",", "max", ")", ";", "err", "!=", "nil", "{", "return", "false", ",",...
// versionAtMost will return true if the provided version is less than or equal to max
[ "versionAtMost", "will", "return", "true", "if", "the", "provided", "version", "is", "less", "than", "or", "equal", "to", "max" ]
0e5bec1b9eec14f9070a6f49ad7e0242f1545d66
https://github.com/kardianos/service/blob/0e5bec1b9eec14f9070a6f49ad7e0242f1545d66/version.go#L10-L17
25,355
kardianos/service
version.go
versionCompare
func versionCompare(v1, v2 []int) (int, error) { if len(v1) != len(v2) { return 0, errors.New("version length mismatch") } for idx, v2S := range v2 { v1S := v1[idx] if v1S > v2S { return 1, nil } if v1S < v2S { return -1, nil } } return 0, nil }
go
func versionCompare(v1, v2 []int) (int, error) { if len(v1) != len(v2) { return 0, errors.New("version length mismatch") } for idx, v2S := range v2 { v1S := v1[idx] if v1S > v2S { return 1, nil } if v1S < v2S { return -1, nil } } return 0, nil }
[ "func", "versionCompare", "(", "v1", ",", "v2", "[", "]", "int", ")", "(", "int", ",", "error", ")", "{", "if", "len", "(", "v1", ")", "!=", "len", "(", "v2", ")", "{", "return", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "...
// versionCompare take to versions split into integer arrays and attempts to compare them // An error will be returned if there is an array length mismatch. // Return values are as follows // -1 - v1 is less than v2 // 0 - v1 is equal to v2 // 1 - v1 is greater than v2
[ "versionCompare", "take", "to", "versions", "split", "into", "integer", "arrays", "and", "attempts", "to", "compare", "them", "An", "error", "will", "be", "returned", "if", "there", "is", "an", "array", "length", "mismatch", ".", "Return", "values", "are", "...
0e5bec1b9eec14f9070a6f49ad7e0242f1545d66
https://github.com/kardianos/service/blob/0e5bec1b9eec14f9070a6f49ad7e0242f1545d66/version.go#L25-L41
25,356
kardianos/service
version.go
parseVersion
func parseVersion(v string) []int { version := make([]int, 3) for idx, vStr := range strings.Split(v, ".") { vS, err := strconv.Atoi(vStr) if err != nil { return nil } version[idx] = vS } return version }
go
func parseVersion(v string) []int { version := make([]int, 3) for idx, vStr := range strings.Split(v, ".") { vS, err := strconv.Atoi(vStr) if err != nil { return nil } version[idx] = vS } return version }
[ "func", "parseVersion", "(", "v", "string", ")", "[", "]", "int", "{", "version", ":=", "make", "(", "[", "]", "int", ",", "3", ")", "\n\n", "for", "idx", ",", "vStr", ":=", "range", "strings", ".", "Split", "(", "v", ",", "\"", "\"", ")", "{",...
// parseVersion will parse any integer type version seperated by periods. // This does not fully support semver style versions.
[ "parseVersion", "will", "parse", "any", "integer", "type", "version", "seperated", "by", "periods", ".", "This", "does", "not", "fully", "support", "semver", "style", "versions", "." ]
0e5bec1b9eec14f9070a6f49ad7e0242f1545d66
https://github.com/kardianos/service/blob/0e5bec1b9eec14f9070a6f49ad7e0242f1545d66/version.go#L45-L57
25,357
kardianos/service
service.go
New
func New(i Interface, c *Config) (Service, error) { if len(c.Name) == 0 { return nil, ErrNameFieldRequired } if system == nil { return nil, ErrNoServiceSystemDetected } return system.New(i, c) }
go
func New(i Interface, c *Config) (Service, error) { if len(c.Name) == 0 { return nil, ErrNameFieldRequired } if system == nil { return nil, ErrNoServiceSystemDetected } return system.New(i, c) }
[ "func", "New", "(", "i", "Interface", ",", "c", "*", "Config", ")", "(", "Service", ",", "error", ")", "{", "if", "len", "(", "c", ".", "Name", ")", "==", "0", "{", "return", "nil", ",", "ErrNameFieldRequired", "\n", "}", "\n", "if", "system", "=...
// New creates a new service based on a service interface and configuration.
[ "New", "creates", "a", "new", "service", "based", "on", "a", "service", "interface", "and", "configuration", "." ]
0e5bec1b9eec14f9070a6f49ad7e0242f1545d66
https://github.com/kardianos/service/blob/0e5bec1b9eec14f9070a6f49ad7e0242f1545d66/service.go#L160-L168
25,358
kardianos/service
service.go
bool
func (kv KeyValue) bool(name string, defaultValue bool) bool { if v, found := kv[name]; found { if castValue, is := v.(bool); is { return castValue } } return defaultValue }
go
func (kv KeyValue) bool(name string, defaultValue bool) bool { if v, found := kv[name]; found { if castValue, is := v.(bool); is { return castValue } } return defaultValue }
[ "func", "(", "kv", "KeyValue", ")", "bool", "(", "name", "string", ",", "defaultValue", "bool", ")", "bool", "{", "if", "v", ",", "found", ":=", "kv", "[", "name", "]", ";", "found", "{", "if", "castValue", ",", "is", ":=", "v", ".", "(", "bool",...
// bool returns the value of the given name, assuming the value is a boolean. // If the value isn't found or is not of the type, the defaultValue is returned.
[ "bool", "returns", "the", "value", "of", "the", "given", "name", "assuming", "the", "value", "is", "a", "boolean", ".", "If", "the", "value", "isn", "t", "found", "or", "is", "not", "of", "the", "type", "the", "defaultValue", "is", "returned", "." ]
0e5bec1b9eec14f9070a6f49ad7e0242f1545d66
https://github.com/kardianos/service/blob/0e5bec1b9eec14f9070a6f49ad7e0242f1545d66/service.go#L176-L183
25,359
kardianos/service
service.go
Control
func Control(s Service, action string) error { var err error switch action { case ControlAction[0]: err = s.Start() case ControlAction[1]: err = s.Stop() case ControlAction[2]: err = s.Restart() case ControlAction[3]: err = s.Install() case ControlAction[4]: err = s.Uninstall() default: err = fmt.Er...
go
func Control(s Service, action string) error { var err error switch action { case ControlAction[0]: err = s.Start() case ControlAction[1]: err = s.Stop() case ControlAction[2]: err = s.Restart() case ControlAction[3]: err = s.Install() case ControlAction[4]: err = s.Uninstall() default: err = fmt.Er...
[ "func", "Control", "(", "s", "Service", ",", "action", "string", ")", "error", "{", "var", "err", "error", "\n", "switch", "action", "{", "case", "ControlAction", "[", "0", "]", ":", "err", "=", "s", ".", "Start", "(", ")", "\n", "case", "ControlActi...
// Control issues control functions to the service from a given action string.
[ "Control", "issues", "control", "functions", "to", "the", "service", "from", "a", "given", "action", "string", "." ]
0e5bec1b9eec14f9070a6f49ad7e0242f1545d66
https://github.com/kardianos/service/blob/0e5bec1b9eec14f9070a6f49ad7e0242f1545d66/service.go#L368-L388
25,360
kardianos/service
service_windows.go
Errorf
func (l WindowsLogger) Errorf(format string, a ...interface{}) error { return l.send(l.ev.Error(3, fmt.Sprintf(format, a...))) }
go
func (l WindowsLogger) Errorf(format string, a ...interface{}) error { return l.send(l.ev.Error(3, fmt.Sprintf(format, a...))) }
[ "func", "(", "l", "WindowsLogger", ")", "Errorf", "(", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "error", "{", "return", "l", ".", "send", "(", "l", ".", "ev", ".", "Error", "(", "3", ",", "fmt", ".", "Sprintf", "(", "forma...
// Errorf logs an error message.
[ "Errorf", "logs", "an", "error", "message", "." ]
0e5bec1b9eec14f9070a6f49ad7e0242f1545d66
https://github.com/kardianos/service/blob/0e5bec1b9eec14f9070a6f49ad7e0242f1545d66/service_windows.go#L87-L89
25,361
kardianos/service
service_windows.go
Warningf
func (l WindowsLogger) Warningf(format string, a ...interface{}) error { return l.send(l.ev.Warning(2, fmt.Sprintf(format, a...))) }
go
func (l WindowsLogger) Warningf(format string, a ...interface{}) error { return l.send(l.ev.Warning(2, fmt.Sprintf(format, a...))) }
[ "func", "(", "l", "WindowsLogger", ")", "Warningf", "(", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "error", "{", "return", "l", ".", "send", "(", "l", ".", "ev", ".", "Warning", "(", "2", ",", "fmt", ".", "Sprintf", "(", "f...
// Warningf logs an warning message.
[ "Warningf", "logs", "an", "warning", "message", "." ]
0e5bec1b9eec14f9070a6f49ad7e0242f1545d66
https://github.com/kardianos/service/blob/0e5bec1b9eec14f9070a6f49ad7e0242f1545d66/service_windows.go#L92-L94
25,362
kardianos/service
service_windows.go
Infof
func (l WindowsLogger) Infof(format string, a ...interface{}) error { return l.send(l.ev.Info(1, fmt.Sprintf(format, a...))) }
go
func (l WindowsLogger) Infof(format string, a ...interface{}) error { return l.send(l.ev.Info(1, fmt.Sprintf(format, a...))) }
[ "func", "(", "l", "WindowsLogger", ")", "Infof", "(", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "error", "{", "return", "l", ".", "send", "(", "l", ".", "ev", ".", "Info", "(", "1", ",", "fmt", ".", "Sprintf", "(", "format"...
// Infof logs an info message.
[ "Infof", "logs", "an", "info", "message", "." ]
0e5bec1b9eec14f9070a6f49ad7e0242f1545d66
https://github.com/kardianos/service/blob/0e5bec1b9eec14f9070a6f49ad7e0242f1545d66/service_windows.go#L97-L99
25,363
kardianos/service
service_windows.go
NError
func (l WindowsLogger) NError(eventID uint32, v ...interface{}) error { return l.send(l.ev.Error(eventID, fmt.Sprint(v...))) }
go
func (l WindowsLogger) NError(eventID uint32, v ...interface{}) error { return l.send(l.ev.Error(eventID, fmt.Sprint(v...))) }
[ "func", "(", "l", "WindowsLogger", ")", "NError", "(", "eventID", "uint32", ",", "v", "...", "interface", "{", "}", ")", "error", "{", "return", "l", ".", "send", "(", "l", ".", "ev", ".", "Error", "(", "eventID", ",", "fmt", ".", "Sprint", "(", ...
// NError logs an error message and an event ID.
[ "NError", "logs", "an", "error", "message", "and", "an", "event", "ID", "." ]
0e5bec1b9eec14f9070a6f49ad7e0242f1545d66
https://github.com/kardianos/service/blob/0e5bec1b9eec14f9070a6f49ad7e0242f1545d66/service_windows.go#L102-L104
25,364
kardianos/service
service_windows.go
NWarning
func (l WindowsLogger) NWarning(eventID uint32, v ...interface{}) error { return l.send(l.ev.Warning(eventID, fmt.Sprint(v...))) }
go
func (l WindowsLogger) NWarning(eventID uint32, v ...interface{}) error { return l.send(l.ev.Warning(eventID, fmt.Sprint(v...))) }
[ "func", "(", "l", "WindowsLogger", ")", "NWarning", "(", "eventID", "uint32", ",", "v", "...", "interface", "{", "}", ")", "error", "{", "return", "l", ".", "send", "(", "l", ".", "ev", ".", "Warning", "(", "eventID", ",", "fmt", ".", "Sprint", "("...
// NWarning logs an warning message and an event ID.
[ "NWarning", "logs", "an", "warning", "message", "and", "an", "event", "ID", "." ]
0e5bec1b9eec14f9070a6f49ad7e0242f1545d66
https://github.com/kardianos/service/blob/0e5bec1b9eec14f9070a6f49ad7e0242f1545d66/service_windows.go#L107-L109
25,365
kardianos/service
service_windows.go
NInfo
func (l WindowsLogger) NInfo(eventID uint32, v ...interface{}) error { return l.send(l.ev.Info(eventID, fmt.Sprint(v...))) }
go
func (l WindowsLogger) NInfo(eventID uint32, v ...interface{}) error { return l.send(l.ev.Info(eventID, fmt.Sprint(v...))) }
[ "func", "(", "l", "WindowsLogger", ")", "NInfo", "(", "eventID", "uint32", ",", "v", "...", "interface", "{", "}", ")", "error", "{", "return", "l", ".", "send", "(", "l", ".", "ev", ".", "Info", "(", "eventID", ",", "fmt", ".", "Sprint", "(", "v...
// NInfo logs an info message and an event ID.
[ "NInfo", "logs", "an", "info", "message", "and", "an", "event", "ID", "." ]
0e5bec1b9eec14f9070a6f49ad7e0242f1545d66
https://github.com/kardianos/service/blob/0e5bec1b9eec14f9070a6f49ad7e0242f1545d66/service_windows.go#L112-L114
25,366
kardianos/service
service_windows.go
NErrorf
func (l WindowsLogger) NErrorf(eventID uint32, format string, a ...interface{}) error { return l.send(l.ev.Error(eventID, fmt.Sprintf(format, a...))) }
go
func (l WindowsLogger) NErrorf(eventID uint32, format string, a ...interface{}) error { return l.send(l.ev.Error(eventID, fmt.Sprintf(format, a...))) }
[ "func", "(", "l", "WindowsLogger", ")", "NErrorf", "(", "eventID", "uint32", ",", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "error", "{", "return", "l", ".", "send", "(", "l", ".", "ev", ".", "Error", "(", "eventID", ",", "fm...
// NErrorf logs an error message and an event ID.
[ "NErrorf", "logs", "an", "error", "message", "and", "an", "event", "ID", "." ]
0e5bec1b9eec14f9070a6f49ad7e0242f1545d66
https://github.com/kardianos/service/blob/0e5bec1b9eec14f9070a6f49ad7e0242f1545d66/service_windows.go#L117-L119
25,367
kardianos/service
service_windows.go
NWarningf
func (l WindowsLogger) NWarningf(eventID uint32, format string, a ...interface{}) error { return l.send(l.ev.Warning(eventID, fmt.Sprintf(format, a...))) }
go
func (l WindowsLogger) NWarningf(eventID uint32, format string, a ...interface{}) error { return l.send(l.ev.Warning(eventID, fmt.Sprintf(format, a...))) }
[ "func", "(", "l", "WindowsLogger", ")", "NWarningf", "(", "eventID", "uint32", ",", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "error", "{", "return", "l", ".", "send", "(", "l", ".", "ev", ".", "Warning", "(", "eventID", ",", ...
// NWarningf logs an warning message and an event ID.
[ "NWarningf", "logs", "an", "warning", "message", "and", "an", "event", "ID", "." ]
0e5bec1b9eec14f9070a6f49ad7e0242f1545d66
https://github.com/kardianos/service/blob/0e5bec1b9eec14f9070a6f49ad7e0242f1545d66/service_windows.go#L122-L124
25,368
kardianos/service
service_windows.go
NInfof
func (l WindowsLogger) NInfof(eventID uint32, format string, a ...interface{}) error { return l.send(l.ev.Info(eventID, fmt.Sprintf(format, a...))) }
go
func (l WindowsLogger) NInfof(eventID uint32, format string, a ...interface{}) error { return l.send(l.ev.Info(eventID, fmt.Sprintf(format, a...))) }
[ "func", "(", "l", "WindowsLogger", ")", "NInfof", "(", "eventID", "uint32", ",", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "error", "{", "return", "l", ".", "send", "(", "l", ".", "ev", ".", "Info", "(", "eventID", ",", "fmt"...
// NInfof logs an info message and an event ID.
[ "NInfof", "logs", "an", "info", "message", "and", "an", "event", "ID", "." ]
0e5bec1b9eec14f9070a6f49ad7e0242f1545d66
https://github.com/kardianos/service/blob/0e5bec1b9eec14f9070a6f49ad7e0242f1545d66/service_windows.go#L127-L129
25,369
kardianos/service
service_windows.go
getStopTimeout
func getStopTimeout() time.Duration { // For default and paths see https://support.microsoft.com/en-us/kb/146092 defaultTimeout := time.Millisecond * 20000 key, err := registry.OpenKey(registry.LOCAL_MACHINE, `SYSTEM\CurrentControlSet\Control`, registry.READ) if err != nil { return defaultTimeout } sv, _, err :...
go
func getStopTimeout() time.Duration { // For default and paths see https://support.microsoft.com/en-us/kb/146092 defaultTimeout := time.Millisecond * 20000 key, err := registry.OpenKey(registry.LOCAL_MACHINE, `SYSTEM\CurrentControlSet\Control`, registry.READ) if err != nil { return defaultTimeout } sv, _, err :...
[ "func", "getStopTimeout", "(", ")", "time", ".", "Duration", "{", "// For default and paths see https://support.microsoft.com/en-us/kb/146092", "defaultTimeout", ":=", "time", ".", "Millisecond", "*", "20000", "\n", "key", ",", "err", ":=", "registry", ".", "OpenKey", ...
// getStopTimeout fetches the time before windows will kill the service.
[ "getStopTimeout", "fetches", "the", "time", "before", "windows", "will", "kill", "the", "service", "." ]
0e5bec1b9eec14f9070a6f49ad7e0242f1545d66
https://github.com/kardianos/service/blob/0e5bec1b9eec14f9070a6f49ad7e0242f1545d66/service_windows.go#L406-L422
25,370
jroimartin/gocui
edit.go
simpleEditor
func simpleEditor(v *View, key Key, ch rune, mod Modifier) { switch { case ch != 0 && mod == 0: v.EditWrite(ch) case key == KeySpace: v.EditWrite(' ') case key == KeyBackspace || key == KeyBackspace2: v.EditDelete(true) case key == KeyDelete: v.EditDelete(false) case key == KeyInsert: v.Overwrite = !v.O...
go
func simpleEditor(v *View, key Key, ch rune, mod Modifier) { switch { case ch != 0 && mod == 0: v.EditWrite(ch) case key == KeySpace: v.EditWrite(' ') case key == KeyBackspace || key == KeyBackspace2: v.EditDelete(true) case key == KeyDelete: v.EditDelete(false) case key == KeyInsert: v.Overwrite = !v.O...
[ "func", "simpleEditor", "(", "v", "*", "View", ",", "key", "Key", ",", "ch", "rune", ",", "mod", "Modifier", ")", "{", "switch", "{", "case", "ch", "!=", "0", "&&", "mod", "==", "0", ":", "v", ".", "EditWrite", "(", "ch", ")", "\n", "case", "ke...
// simpleEditor is used as the default gocui editor.
[ "simpleEditor", "is", "used", "as", "the", "default", "gocui", "editor", "." ]
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/edit.go#L30-L53
25,371
jroimartin/gocui
edit.go
EditWrite
func (v *View) EditWrite(ch rune) { v.writeRune(v.cx, v.cy, ch) v.MoveCursor(1, 0, true) }
go
func (v *View) EditWrite(ch rune) { v.writeRune(v.cx, v.cy, ch) v.MoveCursor(1, 0, true) }
[ "func", "(", "v", "*", "View", ")", "EditWrite", "(", "ch", "rune", ")", "{", "v", ".", "writeRune", "(", "v", ".", "cx", ",", "v", ".", "cy", ",", "ch", ")", "\n", "v", ".", "MoveCursor", "(", "1", ",", "0", ",", "true", ")", "\n", "}" ]
// EditWrite writes a rune at the cursor position.
[ "EditWrite", "writes", "a", "rune", "at", "the", "cursor", "position", "." ]
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/edit.go#L56-L59
25,372
jroimartin/gocui
edit.go
EditDelete
func (v *View) EditDelete(back bool) { x, y := v.ox+v.cx, v.oy+v.cy if y < 0 { return } else if y >= len(v.viewLines) { v.MoveCursor(-1, 0, true) return } maxX, _ := v.Size() if back { if x == 0 { // start of the line if y < 1 { return } var maxPrevWidth int if v.Wrap { maxPrevWidth ...
go
func (v *View) EditDelete(back bool) { x, y := v.ox+v.cx, v.oy+v.cy if y < 0 { return } else if y >= len(v.viewLines) { v.MoveCursor(-1, 0, true) return } maxX, _ := v.Size() if back { if x == 0 { // start of the line if y < 1 { return } var maxPrevWidth int if v.Wrap { maxPrevWidth ...
[ "func", "(", "v", "*", "View", ")", "EditDelete", "(", "back", "bool", ")", "{", "x", ",", "y", ":=", "v", ".", "ox", "+", "v", ".", "cx", ",", "v", ".", "oy", "+", "v", ".", "cy", "\n", "if", "y", "<", "0", "{", "return", "\n", "}", "e...
// EditDelete deletes a rune at the cursor position. back determines the // direction.
[ "EditDelete", "deletes", "a", "rune", "at", "the", "cursor", "position", ".", "back", "determines", "the", "direction", "." ]
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/edit.go#L63-L106
25,373
jroimartin/gocui
edit.go
EditNewLine
func (v *View) EditNewLine() { v.breakLine(v.cx, v.cy) v.ox = 0 v.cx = 0 v.MoveCursor(0, 1, true) }
go
func (v *View) EditNewLine() { v.breakLine(v.cx, v.cy) v.ox = 0 v.cx = 0 v.MoveCursor(0, 1, true) }
[ "func", "(", "v", "*", "View", ")", "EditNewLine", "(", ")", "{", "v", ".", "breakLine", "(", "v", ".", "cx", ",", "v", ".", "cy", ")", "\n", "v", ".", "ox", "=", "0", "\n", "v", ".", "cx", "=", "0", "\n", "v", ".", "MoveCursor", "(", "0"...
// EditNewLine inserts a new line under the cursor.
[ "EditNewLine", "inserts", "a", "new", "line", "under", "the", "cursor", "." ]
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/edit.go#L109-L114
25,374
jroimartin/gocui
edit.go
mergeLines
func (v *View) mergeLines(y int) error { v.tainted = true _, y, err := v.realPosition(0, y) if err != nil { return err } if y < 0 || y >= len(v.lines) { return errors.New("invalid point") } if y < len(v.lines)-1 { // otherwise we don't need to merge anything v.lines[y] = append(v.lines[y], v.lines[y+1]....
go
func (v *View) mergeLines(y int) error { v.tainted = true _, y, err := v.realPosition(0, y) if err != nil { return err } if y < 0 || y >= len(v.lines) { return errors.New("invalid point") } if y < len(v.lines)-1 { // otherwise we don't need to merge anything v.lines[y] = append(v.lines[y], v.lines[y+1]....
[ "func", "(", "v", "*", "View", ")", "mergeLines", "(", "y", "int", ")", "error", "{", "v", ".", "tainted", "=", "true", "\n\n", "_", ",", "y", ",", "err", ":=", "v", ".", "realPosition", "(", "0", ",", "y", ")", "\n", "if", "err", "!=", "nil"...
// mergeLines merges the lines "y" and "y+1" if possible.
[ "mergeLines", "merges", "the", "lines", "y", "and", "y", "+", "1", "if", "possible", "." ]
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/edit.go#L294-L311
25,375
jroimartin/gocui
keybinding.go
newKeybinding
func newKeybinding(viewname string, key Key, ch rune, mod Modifier, handler func(*Gui, *View) error) (kb *keybinding) { kb = &keybinding{ viewName: viewname, key: key, ch: ch, mod: mod, handler: handler, } return kb }
go
func newKeybinding(viewname string, key Key, ch rune, mod Modifier, handler func(*Gui, *View) error) (kb *keybinding) { kb = &keybinding{ viewName: viewname, key: key, ch: ch, mod: mod, handler: handler, } return kb }
[ "func", "newKeybinding", "(", "viewname", "string", ",", "key", "Key", ",", "ch", "rune", ",", "mod", "Modifier", ",", "handler", "func", "(", "*", "Gui", ",", "*", "View", ")", "error", ")", "(", "kb", "*", "keybinding", ")", "{", "kb", "=", "&", ...
// newKeybinding returns a new Keybinding object.
[ "newKeybinding", "returns", "a", "new", "Keybinding", "object", "." ]
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/keybinding.go#L19-L28
25,376
jroimartin/gocui
keybinding.go
matchKeypress
func (kb *keybinding) matchKeypress(key Key, ch rune, mod Modifier) bool { return kb.key == key && kb.ch == ch && kb.mod == mod }
go
func (kb *keybinding) matchKeypress(key Key, ch rune, mod Modifier) bool { return kb.key == key && kb.ch == ch && kb.mod == mod }
[ "func", "(", "kb", "*", "keybinding", ")", "matchKeypress", "(", "key", "Key", ",", "ch", "rune", ",", "mod", "Modifier", ")", "bool", "{", "return", "kb", ".", "key", "==", "key", "&&", "kb", ".", "ch", "==", "ch", "&&", "kb", ".", "mod", "==", ...
// matchKeypress returns if the keybinding matches the keypress.
[ "matchKeypress", "returns", "if", "the", "keybinding", "matches", "the", "keypress", "." ]
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/keybinding.go#L31-L33
25,377
jroimartin/gocui
keybinding.go
matchView
func (kb *keybinding) matchView(v *View) bool { if kb.viewName == "" { return true } return v != nil && kb.viewName == v.name }
go
func (kb *keybinding) matchView(v *View) bool { if kb.viewName == "" { return true } return v != nil && kb.viewName == v.name }
[ "func", "(", "kb", "*", "keybinding", ")", "matchView", "(", "v", "*", "View", ")", "bool", "{", "if", "kb", ".", "viewName", "==", "\"", "\"", "{", "return", "true", "\n", "}", "\n", "return", "v", "!=", "nil", "&&", "kb", ".", "viewName", "==",...
// matchView returns if the keybinding matches the current view.
[ "matchView", "returns", "if", "the", "keybinding", "matches", "the", "current", "view", "." ]
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/keybinding.go#L36-L41
25,378
jroimartin/gocui
view.go
String
func (l lineType) String() string { str := "" for _, c := range l { str += string(c.chr) } return str }
go
func (l lineType) String() string { str := "" for _, c := range l { str += string(c.chr) } return str }
[ "func", "(", "l", "lineType", ")", "String", "(", ")", "string", "{", "str", ":=", "\"", "\"", "\n", "for", "_", ",", "c", ":=", "range", "l", "{", "str", "+=", "string", "(", "c", ".", "chr", ")", "\n", "}", "\n", "return", "str", "\n", "}" ...
// String returns a string from a given cell slice.
[ "String", "returns", "a", "string", "from", "a", "given", "cell", "slice", "." ]
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/view.go#L89-L95
25,379
jroimartin/gocui
view.go
newView
func newView(name string, x0, y0, x1, y1 int, mode OutputMode) *View { v := &View{ name: name, x0: x0, y0: y0, x1: x1, y1: y1, Frame: true, Editor: DefaultEditor, tainted: true, ei: newEscapeInterpreter(mode), } return v }
go
func newView(name string, x0, y0, x1, y1 int, mode OutputMode) *View { v := &View{ name: name, x0: x0, y0: y0, x1: x1, y1: y1, Frame: true, Editor: DefaultEditor, tainted: true, ei: newEscapeInterpreter(mode), } return v }
[ "func", "newView", "(", "name", "string", ",", "x0", ",", "y0", ",", "x1", ",", "y1", "int", ",", "mode", "OutputMode", ")", "*", "View", "{", "v", ":=", "&", "View", "{", "name", ":", "name", ",", "x0", ":", "x0", ",", "y0", ":", "y0", ",", ...
// newView returns a new View object.
[ "newView", "returns", "a", "new", "View", "object", "." ]
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/view.go#L98-L111
25,380
jroimartin/gocui
view.go
Size
func (v *View) Size() (x, y int) { return v.x1 - v.x0 - 1, v.y1 - v.y0 - 1 }
go
func (v *View) Size() (x, y int) { return v.x1 - v.x0 - 1, v.y1 - v.y0 - 1 }
[ "func", "(", "v", "*", "View", ")", "Size", "(", ")", "(", "x", ",", "y", "int", ")", "{", "return", "v", ".", "x1", "-", "v", ".", "x0", "-", "1", ",", "v", ".", "y1", "-", "v", ".", "y0", "-", "1", "\n", "}" ]
// Size returns the number of visible columns and rows in the View.
[ "Size", "returns", "the", "number", "of", "visible", "columns", "and", "rows", "in", "the", "View", "." ]
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/view.go#L114-L116
25,381
jroimartin/gocui
view.go
setRune
func (v *View) setRune(x, y int, ch rune, fgColor, bgColor Attribute) error { maxX, maxY := v.Size() if x < 0 || x >= maxX || y < 0 || y >= maxY { return errors.New("invalid point") } var ( ry, rcy int err error ) if v.Highlight { _, ry, err = v.realPosition(x, y) if err != nil { return err } ...
go
func (v *View) setRune(x, y int, ch rune, fgColor, bgColor Attribute) error { maxX, maxY := v.Size() if x < 0 || x >= maxX || y < 0 || y >= maxY { return errors.New("invalid point") } var ( ry, rcy int err error ) if v.Highlight { _, ry, err = v.realPosition(x, y) if err != nil { return err } ...
[ "func", "(", "v", "*", "View", ")", "setRune", "(", "x", ",", "y", "int", ",", "ch", "rune", ",", "fgColor", ",", "bgColor", "Attribute", ")", "error", "{", "maxX", ",", "maxY", ":=", "v", ".", "Size", "(", ")", "\n", "if", "x", "<", "0", "||...
// setRune sets a rune at the given point relative to the view. It applies the // specified colors, taking into account if the cell must be highlighted. Also, // it checks if the position is valid.
[ "setRune", "sets", "a", "rune", "at", "the", "given", "point", "relative", "to", "the", "view", ".", "It", "applies", "the", "specified", "colors", "taking", "into", "account", "if", "the", "cell", "must", "be", "highlighted", ".", "Also", "it", "checks", ...
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/view.go#L126-L160
25,382
jroimartin/gocui
view.go
SetCursor
func (v *View) SetCursor(x, y int) error { maxX, maxY := v.Size() if x < 0 || x >= maxX || y < 0 || y >= maxY { return errors.New("invalid point") } v.cx = x v.cy = y return nil }
go
func (v *View) SetCursor(x, y int) error { maxX, maxY := v.Size() if x < 0 || x >= maxX || y < 0 || y >= maxY { return errors.New("invalid point") } v.cx = x v.cy = y return nil }
[ "func", "(", "v", "*", "View", ")", "SetCursor", "(", "x", ",", "y", "int", ")", "error", "{", "maxX", ",", "maxY", ":=", "v", ".", "Size", "(", ")", "\n", "if", "x", "<", "0", "||", "x", ">=", "maxX", "||", "y", "<", "0", "||", "y", ">="...
// SetCursor sets the cursor position of the view at the given point, // relative to the view. It checks if the position is valid.
[ "SetCursor", "sets", "the", "cursor", "position", "of", "the", "view", "at", "the", "given", "point", "relative", "to", "the", "view", ".", "It", "checks", "if", "the", "position", "is", "valid", "." ]
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/view.go#L164-L172
25,383
jroimartin/gocui
view.go
Cursor
func (v *View) Cursor() (x, y int) { return v.cx, v.cy }
go
func (v *View) Cursor() (x, y int) { return v.cx, v.cy }
[ "func", "(", "v", "*", "View", ")", "Cursor", "(", ")", "(", "x", ",", "y", "int", ")", "{", "return", "v", ".", "cx", ",", "v", ".", "cy", "\n", "}" ]
// Cursor returns the cursor position of the view.
[ "Cursor", "returns", "the", "cursor", "position", "of", "the", "view", "." ]
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/view.go#L175-L177
25,384
jroimartin/gocui
view.go
SetOrigin
func (v *View) SetOrigin(x, y int) error { if x < 0 || y < 0 { return errors.New("invalid point") } v.ox = x v.oy = y return nil }
go
func (v *View) SetOrigin(x, y int) error { if x < 0 || y < 0 { return errors.New("invalid point") } v.ox = x v.oy = y return nil }
[ "func", "(", "v", "*", "View", ")", "SetOrigin", "(", "x", ",", "y", "int", ")", "error", "{", "if", "x", "<", "0", "||", "y", "<", "0", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "v", ".", "ox", "=", "x",...
// SetOrigin sets the origin position of the view's internal buffer, // so the buffer starts to be printed from this point, which means that // it is linked with the origin point of view. It can be used to // implement Horizontal and Vertical scrolling with just incrementing // or decrementing ox and oy.
[ "SetOrigin", "sets", "the", "origin", "position", "of", "the", "view", "s", "internal", "buffer", "so", "the", "buffer", "starts", "to", "be", "printed", "from", "this", "point", "which", "means", "that", "it", "is", "linked", "with", "the", "origin", "poi...
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/view.go#L184-L191
25,385
jroimartin/gocui
view.go
Origin
func (v *View) Origin() (x, y int) { return v.ox, v.oy }
go
func (v *View) Origin() (x, y int) { return v.ox, v.oy }
[ "func", "(", "v", "*", "View", ")", "Origin", "(", ")", "(", "x", ",", "y", "int", ")", "{", "return", "v", ".", "ox", ",", "v", ".", "oy", "\n", "}" ]
// Origin returns the origin position of the view.
[ "Origin", "returns", "the", "origin", "position", "of", "the", "view", "." ]
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/view.go#L194-L196
25,386
jroimartin/gocui
view.go
Write
func (v *View) Write(p []byte) (n int, err error) { v.tainted = true for _, ch := range bytes.Runes(p) { switch ch { case '\n': v.lines = append(v.lines, nil) case '\r': nl := len(v.lines) if nl > 0 { v.lines[nl-1] = nil } else { v.lines = make([][]cell, 1) } default: cells := v.par...
go
func (v *View) Write(p []byte) (n int, err error) { v.tainted = true for _, ch := range bytes.Runes(p) { switch ch { case '\n': v.lines = append(v.lines, nil) case '\r': nl := len(v.lines) if nl > 0 { v.lines[nl-1] = nil } else { v.lines = make([][]cell, 1) } default: cells := v.par...
[ "func", "(", "v", "*", "View", ")", "Write", "(", "p", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "v", ".", "tainted", "=", "true", "\n\n", "for", "_", ",", "ch", ":=", "range", "bytes", ".", "Runes", "(", "p", "...
// Write appends a byte slice into the view's internal buffer. Because // View implements the io.Writer interface, it can be passed as parameter // of functions like fmt.Fprintf, fmt.Fprintln, io.Copy, etc. Clear must // be called to clear the view's buffer.
[ "Write", "appends", "a", "byte", "slice", "into", "the", "view", "s", "internal", "buffer", ".", "Because", "View", "implements", "the", "io", ".", "Writer", "interface", "it", "can", "be", "passed", "as", "parameter", "of", "functions", "like", "fmt", "."...
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/view.go#L202-L231
25,387
jroimartin/gocui
view.go
parseInput
func (v *View) parseInput(ch rune) []cell { cells := []cell{} isEscape, err := v.ei.parseOne(ch) if err != nil { for _, r := range v.ei.runes() { c := cell{ fgColor: v.FgColor, bgColor: v.BgColor, chr: r, } cells = append(cells, c) } v.ei.reset() } else { if isEscape { return ni...
go
func (v *View) parseInput(ch rune) []cell { cells := []cell{} isEscape, err := v.ei.parseOne(ch) if err != nil { for _, r := range v.ei.runes() { c := cell{ fgColor: v.FgColor, bgColor: v.BgColor, chr: r, } cells = append(cells, c) } v.ei.reset() } else { if isEscape { return ni...
[ "func", "(", "v", "*", "View", ")", "parseInput", "(", "ch", "rune", ")", "[", "]", "cell", "{", "cells", ":=", "[", "]", "cell", "{", "}", "\n\n", "isEscape", ",", "err", ":=", "v", ".", "ei", ".", "parseOne", "(", "ch", ")", "\n", "if", "er...
// parseInput parses char by char the input written to the View. It returns nil // while processing ESC sequences. Otherwise, it returns a cell slice that // contains the processed data.
[ "parseInput", "parses", "char", "by", "char", "the", "input", "written", "to", "the", "View", ".", "It", "returns", "nil", "while", "processing", "ESC", "sequences", ".", "Otherwise", "it", "returns", "a", "cell", "slice", "that", "contains", "the", "process...
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/view.go#L236-L263
25,388
jroimartin/gocui
view.go
draw
func (v *View) draw() error { maxX, maxY := v.Size() if v.Wrap { if maxX == 0 { return errors.New("X size of the view cannot be 0") } v.ox = 0 } if v.tainted { v.viewLines = nil for i, line := range v.lines { if v.Wrap { if len(line) < maxX { vline := viewLine{linesX: 0, linesY: i, line: l...
go
func (v *View) draw() error { maxX, maxY := v.Size() if v.Wrap { if maxX == 0 { return errors.New("X size of the view cannot be 0") } v.ox = 0 } if v.tainted { v.viewLines = nil for i, line := range v.lines { if v.Wrap { if len(line) < maxX { vline := viewLine{linesX: 0, linesY: i, line: l...
[ "func", "(", "v", "*", "View", ")", "draw", "(", ")", "error", "{", "maxX", ",", "maxY", ":=", "v", ".", "Size", "(", ")", "\n\n", "if", "v", ".", "Wrap", "{", "if", "maxX", "==", "0", "{", "return", "errors", ".", "New", "(", "\"", "\"", "...
// draw re-draws the view's contents.
[ "draw", "re", "-", "draws", "the", "view", "s", "contents", "." ]
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/view.go#L288-L361
25,389
jroimartin/gocui
view.go
Clear
func (v *View) Clear() { v.tainted = true v.lines = nil v.viewLines = nil v.readOffset = 0 v.clearRunes() }
go
func (v *View) Clear() { v.tainted = true v.lines = nil v.viewLines = nil v.readOffset = 0 v.clearRunes() }
[ "func", "(", "v", "*", "View", ")", "Clear", "(", ")", "{", "v", ".", "tainted", "=", "true", "\n\n", "v", ".", "lines", "=", "nil", "\n", "v", ".", "viewLines", "=", "nil", "\n", "v", ".", "readOffset", "=", "0", "\n", "v", ".", "clearRunes", ...
// Clear empties the view's internal buffer.
[ "Clear", "empties", "the", "view", "s", "internal", "buffer", "." ]
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/view.go#L391-L398
25,390
jroimartin/gocui
view.go
clearRunes
func (v *View) clearRunes() { maxX, maxY := v.Size() for x := 0; x < maxX; x++ { for y := 0; y < maxY; y++ { termbox.SetCell(v.x0+x+1, v.y0+y+1, ' ', termbox.Attribute(v.FgColor), termbox.Attribute(v.BgColor)) } } }
go
func (v *View) clearRunes() { maxX, maxY := v.Size() for x := 0; x < maxX; x++ { for y := 0; y < maxY; y++ { termbox.SetCell(v.x0+x+1, v.y0+y+1, ' ', termbox.Attribute(v.FgColor), termbox.Attribute(v.BgColor)) } } }
[ "func", "(", "v", "*", "View", ")", "clearRunes", "(", ")", "{", "maxX", ",", "maxY", ":=", "v", ".", "Size", "(", ")", "\n", "for", "x", ":=", "0", ";", "x", "<", "maxX", ";", "x", "++", "{", "for", "y", ":=", "0", ";", "y", "<", "maxY",...
// clearRunes erases all the cells in the view.
[ "clearRunes", "erases", "all", "the", "cells", "in", "the", "view", "." ]
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/view.go#L401-L409
25,391
jroimartin/gocui
view.go
BufferLines
func (v *View) BufferLines() []string { lines := make([]string, len(v.lines)) for i, l := range v.lines { str := lineType(l).String() str = strings.Replace(str, "\x00", " ", -1) lines[i] = str } return lines }
go
func (v *View) BufferLines() []string { lines := make([]string, len(v.lines)) for i, l := range v.lines { str := lineType(l).String() str = strings.Replace(str, "\x00", " ", -1) lines[i] = str } return lines }
[ "func", "(", "v", "*", "View", ")", "BufferLines", "(", ")", "[", "]", "string", "{", "lines", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "v", ".", "lines", ")", ")", "\n", "for", "i", ",", "l", ":=", "range", "v", ".", "lines", ...
// BufferLines returns the lines in the view's internal // buffer.
[ "BufferLines", "returns", "the", "lines", "in", "the", "view", "s", "internal", "buffer", "." ]
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/view.go#L413-L421
25,392
jroimartin/gocui
view.go
Buffer
func (v *View) Buffer() string { str := "" for _, l := range v.lines { str += lineType(l).String() + "\n" } return strings.Replace(str, "\x00", " ", -1) }
go
func (v *View) Buffer() string { str := "" for _, l := range v.lines { str += lineType(l).String() + "\n" } return strings.Replace(str, "\x00", " ", -1) }
[ "func", "(", "v", "*", "View", ")", "Buffer", "(", ")", "string", "{", "str", ":=", "\"", "\"", "\n", "for", "_", ",", "l", ":=", "range", "v", ".", "lines", "{", "str", "+=", "lineType", "(", "l", ")", ".", "String", "(", ")", "+", "\"", "...
// Buffer returns a string with the contents of the view's internal // buffer.
[ "Buffer", "returns", "a", "string", "with", "the", "contents", "of", "the", "view", "s", "internal", "buffer", "." ]
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/view.go#L425-L431
25,393
jroimartin/gocui
view.go
ViewBufferLines
func (v *View) ViewBufferLines() []string { lines := make([]string, len(v.viewLines)) for i, l := range v.viewLines { str := lineType(l.line).String() str = strings.Replace(str, "\x00", " ", -1) lines[i] = str } return lines }
go
func (v *View) ViewBufferLines() []string { lines := make([]string, len(v.viewLines)) for i, l := range v.viewLines { str := lineType(l.line).String() str = strings.Replace(str, "\x00", " ", -1) lines[i] = str } return lines }
[ "func", "(", "v", "*", "View", ")", "ViewBufferLines", "(", ")", "[", "]", "string", "{", "lines", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "v", ".", "viewLines", ")", ")", "\n", "for", "i", ",", "l", ":=", "range", "v", ".", "...
// ViewBufferLines returns the lines in the view's internal // buffer that is shown to the user.
[ "ViewBufferLines", "returns", "the", "lines", "in", "the", "view", "s", "internal", "buffer", "that", "is", "shown", "to", "the", "user", "." ]
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/view.go#L435-L443
25,394
jroimartin/gocui
view.go
ViewBuffer
func (v *View) ViewBuffer() string { str := "" for _, l := range v.viewLines { str += lineType(l.line).String() + "\n" } return strings.Replace(str, "\x00", " ", -1) }
go
func (v *View) ViewBuffer() string { str := "" for _, l := range v.viewLines { str += lineType(l.line).String() + "\n" } return strings.Replace(str, "\x00", " ", -1) }
[ "func", "(", "v", "*", "View", ")", "ViewBuffer", "(", ")", "string", "{", "str", ":=", "\"", "\"", "\n", "for", "_", ",", "l", ":=", "range", "v", ".", "viewLines", "{", "str", "+=", "lineType", "(", "l", ".", "line", ")", ".", "String", "(", ...
// ViewBuffer returns a string with the contents of the view's buffer that is // shown to the user.
[ "ViewBuffer", "returns", "a", "string", "with", "the", "contents", "of", "the", "view", "s", "buffer", "that", "is", "shown", "to", "the", "user", "." ]
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/view.go#L447-L453
25,395
jroimartin/gocui
escape.go
runes
func (ei *escapeInterpreter) runes() []rune { switch ei.state { case stateNone: return []rune{0x1b} case stateEscape: return []rune{0x1b, ei.curch} case stateCSI: return []rune{0x1b, '[', ei.curch} case stateParams: ret := []rune{0x1b, '['} for _, s := range ei.csiParam { ret = append(ret, []rune(s).....
go
func (ei *escapeInterpreter) runes() []rune { switch ei.state { case stateNone: return []rune{0x1b} case stateEscape: return []rune{0x1b, ei.curch} case stateCSI: return []rune{0x1b, '[', ei.curch} case stateParams: ret := []rune{0x1b, '['} for _, s := range ei.csiParam { ret = append(ret, []rune(s).....
[ "func", "(", "ei", "*", "escapeInterpreter", ")", "runes", "(", ")", "[", "]", "rune", "{", "switch", "ei", ".", "state", "{", "case", "stateNone", ":", "return", "[", "]", "rune", "{", "0x1b", "}", "\n", "case", "stateEscape", ":", "return", "[", ...
// runes in case of error will output the non-parsed runes as a string.
[ "runes", "in", "case", "of", "error", "will", "output", "the", "non", "-", "parsed", "runes", "as", "a", "string", "." ]
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/escape.go#L36-L53
25,396
jroimartin/gocui
escape.go
newEscapeInterpreter
func newEscapeInterpreter(mode OutputMode) *escapeInterpreter { ei := &escapeInterpreter{ state: stateNone, curFgColor: ColorDefault, curBgColor: ColorDefault, mode: mode, } return ei }
go
func newEscapeInterpreter(mode OutputMode) *escapeInterpreter { ei := &escapeInterpreter{ state: stateNone, curFgColor: ColorDefault, curBgColor: ColorDefault, mode: mode, } return ei }
[ "func", "newEscapeInterpreter", "(", "mode", "OutputMode", ")", "*", "escapeInterpreter", "{", "ei", ":=", "&", "escapeInterpreter", "{", "state", ":", "stateNone", ",", "curFgColor", ":", "ColorDefault", ",", "curBgColor", ":", "ColorDefault", ",", "mode", ":",...
// newEscapeInterpreter returns an escapeInterpreter that will be able to parse // terminal escape sequences.
[ "newEscapeInterpreter", "returns", "an", "escapeInterpreter", "that", "will", "be", "able", "to", "parse", "terminal", "escape", "sequences", "." ]
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/escape.go#L57-L65
25,397
jroimartin/gocui
escape.go
reset
func (ei *escapeInterpreter) reset() { ei.state = stateNone ei.curFgColor = ColorDefault ei.curBgColor = ColorDefault ei.csiParam = nil }
go
func (ei *escapeInterpreter) reset() { ei.state = stateNone ei.curFgColor = ColorDefault ei.curBgColor = ColorDefault ei.csiParam = nil }
[ "func", "(", "ei", "*", "escapeInterpreter", ")", "reset", "(", ")", "{", "ei", ".", "state", "=", "stateNone", "\n", "ei", ".", "curFgColor", "=", "ColorDefault", "\n", "ei", ".", "curBgColor", "=", "ColorDefault", "\n", "ei", ".", "csiParam", "=", "n...
// reset sets the escapeInterpreter in initial state.
[ "reset", "sets", "the", "escapeInterpreter", "in", "initial", "state", "." ]
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/escape.go#L68-L73
25,398
jroimartin/gocui
escape.go
parseOne
func (ei *escapeInterpreter) parseOne(ch rune) (isEscape bool, err error) { // Sanity checks if len(ei.csiParam) > 20 { return false, errCSITooLong } if len(ei.csiParam) > 0 && len(ei.csiParam[len(ei.csiParam)-1]) > 255 { return false, errCSITooLong } ei.curch = ch switch ei.state { case stateNone: if c...
go
func (ei *escapeInterpreter) parseOne(ch rune) (isEscape bool, err error) { // Sanity checks if len(ei.csiParam) > 20 { return false, errCSITooLong } if len(ei.csiParam) > 0 && len(ei.csiParam[len(ei.csiParam)-1]) > 255 { return false, errCSITooLong } ei.curch = ch switch ei.state { case stateNone: if c...
[ "func", "(", "ei", "*", "escapeInterpreter", ")", "parseOne", "(", "ch", "rune", ")", "(", "isEscape", "bool", ",", "err", "error", ")", "{", "// Sanity checks", "if", "len", "(", "ei", ".", "csiParam", ")", ">", "20", "{", "return", "false", ",", "e...
// parseOne parses a rune. If isEscape is true, it means that the rune is part // of an escape sequence, and as such should not be printed verbatim. Otherwise, // it's not an escape sequence.
[ "parseOne", "parses", "a", "rune", ".", "If", "isEscape", "is", "true", "it", "means", "that", "the", "rune", "is", "part", "of", "an", "escape", "sequence", "and", "as", "such", "should", "not", "be", "printed", "verbatim", ".", "Otherwise", "it", "s", ...
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/escape.go#L78-L141
25,399
jroimartin/gocui
gui.go
NewGui
func NewGui(mode OutputMode) (*Gui, error) { if err := termbox.Init(); err != nil { return nil, err } g := &Gui{} g.outputMode = mode termbox.SetOutputMode(termbox.OutputMode(mode)) g.tbEvents = make(chan termbox.Event, 20) g.userEvents = make(chan userEvent, 20) g.maxX, g.maxY = termbox.Size() g.BgColo...
go
func NewGui(mode OutputMode) (*Gui, error) { if err := termbox.Init(); err != nil { return nil, err } g := &Gui{} g.outputMode = mode termbox.SetOutputMode(termbox.OutputMode(mode)) g.tbEvents = make(chan termbox.Event, 20) g.userEvents = make(chan userEvent, 20) g.maxX, g.maxY = termbox.Size() g.BgColo...
[ "func", "NewGui", "(", "mode", "OutputMode", ")", "(", "*", "Gui", ",", "error", ")", "{", "if", "err", ":=", "termbox", ".", "Init", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "g", ":=", "&", "Gui",...
// NewGui returns a new Gui object with a given output mode.
[ "NewGui", "returns", "a", "new", "Gui", "object", "with", "a", "given", "output", "mode", "." ]
c055c87ae801372cd74a0839b972db4f7697ae5f
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/gui.go#L72-L91