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
133,800
fluffle/goirc
client/handlers.go
h_CTCP
func (conn *Conn) h_CTCP(line *Line) { if line.Args[0] == VERSION { conn.CtcpReply(line.Nick, VERSION, conn.cfg.Version) } else if line.Args[0] == PING && line.argslen(2) { conn.CtcpReply(line.Nick, PING, line.Args[2]) } }
go
func (conn *Conn) h_CTCP(line *Line) { if line.Args[0] == VERSION { conn.CtcpReply(line.Nick, VERSION, conn.cfg.Version) } else if line.Args[0] == PING && line.argslen(2) { conn.CtcpReply(line.Nick, PING, line.Args[2]) } }
[ "func", "(", "conn", "*", "Conn", ")", "h_CTCP", "(", "line", "*", "Line", ")", "{", "if", "line", ".", "Args", "[", "0", "]", "==", "VERSION", "{", "conn", ".", "CtcpReply", "(", "line", ".", "Nick", ",", "VERSION", ",", "conn", ".", "cfg", "....
// Handle VERSION requests and CTCP PING
[ "Handle", "VERSION", "requests", "and", "CTCP", "PING" ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/handlers.go#L92-L98
133,801
fluffle/goirc
client/handlers.go
h_NICK
func (conn *Conn) h_NICK(line *Line) { if conn.st == nil && line.Nick == conn.cfg.Me.Nick { conn.cfg.Me.Nick = line.Args[0] } }
go
func (conn *Conn) h_NICK(line *Line) { if conn.st == nil && line.Nick == conn.cfg.Me.Nick { conn.cfg.Me.Nick = line.Args[0] } }
[ "func", "(", "conn", "*", "Conn", ")", "h_NICK", "(", "line", "*", "Line", ")", "{", "if", "conn", ".", "st", "==", "nil", "&&", "line", ".", "Nick", "==", "conn", ".", "cfg", ".", "Me", ".", "Nick", "{", "conn", ".", "cfg", ".", "Me", ".", ...
// Handle updating our own NICK if we're not using the state tracker
[ "Handle", "updating", "our", "own", "NICK", "if", "we", "re", "not", "using", "the", "state", "tracker" ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/handlers.go#L101-L105
133,802
howeyc/crc16
hash.go
tableSum
func tableSum(t *Table) uint16 { var a [1024]byte b := a[:0] if t != nil { for _, x := range t.entries { b = appendUint16(b, x) } } return ChecksumIBM(b) }
go
func tableSum(t *Table) uint16 { var a [1024]byte b := a[:0] if t != nil { for _, x := range t.entries { b = appendUint16(b, x) } } return ChecksumIBM(b) }
[ "func", "tableSum", "(", "t", "*", "Table", ")", "uint16", "{", "var", "a", "[", "1024", "]", "byte", "\n", "b", ":=", "a", "[", ":", "0", "]", "\n", "if", "t", "!=", "nil", "{", "for", "_", ",", "x", ":=", "range", "t", ".", "entries", "{"...
// tableSum returns the IBM checksum of table t.
[ "tableSum", "returns", "the", "IBM", "checksum", "of", "table", "t", "." ]
2b2a61e366a66d3efb279e46176e7291001e0354
https://github.com/howeyc/crc16/blob/2b2a61e366a66d3efb279e46176e7291001e0354/hash.go#L107-L116
133,803
howeyc/crc16
crc16.go
MakeTableNoXOR
func MakeTableNoXOR(poly uint16) *Table { tab := makeTable(poly) tab.noXOR = true return tab }
go
func MakeTableNoXOR(poly uint16) *Table { tab := makeTable(poly) tab.noXOR = true return tab }
[ "func", "MakeTableNoXOR", "(", "poly", "uint16", ")", "*", "Table", "{", "tab", ":=", "makeTable", "(", "poly", ")", "\n", "tab", ".", "noXOR", "=", "true", "\n", "return", "tab", "\n", "}" ]
// MakeTableNoXOR returns the Table constructed from the specified polynomial. // Updates happen without XOR in and XOR out.
[ "MakeTableNoXOR", "returns", "the", "Table", "constructed", "from", "the", "specified", "polynomial", ".", "Updates", "happen", "without", "XOR", "in", "and", "XOR", "out", "." ]
2b2a61e366a66d3efb279e46176e7291001e0354
https://github.com/howeyc/crc16/blob/2b2a61e366a66d3efb279e46176e7291001e0354/crc16.go#L58-L62
133,804
howeyc/crc16
crc16.go
makeBitsReversedTable
func makeBitsReversedTable(poly uint16) *Table { t := &Table{ reversed: true, } width := uint16(16) for i := uint16(0); i < 256; i++ { crc := i << (width - 8) for j := 0; j < 8; j++ { if crc&(1<<(width-1)) != 0 { crc = (crc << 1) ^ poly } else { crc <<= 1 } } t.entries[i] = crc } return...
go
func makeBitsReversedTable(poly uint16) *Table { t := &Table{ reversed: true, } width := uint16(16) for i := uint16(0); i < 256; i++ { crc := i << (width - 8) for j := 0; j < 8; j++ { if crc&(1<<(width-1)) != 0 { crc = (crc << 1) ^ poly } else { crc <<= 1 } } t.entries[i] = crc } return...
[ "func", "makeBitsReversedTable", "(", "poly", "uint16", ")", "*", "Table", "{", "t", ":=", "&", "Table", "{", "reversed", ":", "true", ",", "}", "\n", "width", ":=", "uint16", "(", "16", ")", "\n", "for", "i", ":=", "uint16", "(", "0", ")", ";", ...
// makeTable returns the Table constructed from the specified polynomial.
[ "makeTable", "returns", "the", "Table", "constructed", "from", "the", "specified", "polynomial", "." ]
2b2a61e366a66d3efb279e46176e7291001e0354
https://github.com/howeyc/crc16/blob/2b2a61e366a66d3efb279e46176e7291001e0354/crc16.go#L65-L82
133,805
gopherjs/websocket
websocketjs/websocketjs.go
New
func New(url string) (ws *WebSocket, err error) { defer func() { e := recover() if e == nil { return } if jsErr, ok := e.(*js.Error); ok && jsErr != nil { ws = nil err = jsErr } else { panic(e) } }() object := js.Global.Get("WebSocket").New(url) ws = &WebSocket{ Object: object, } retu...
go
func New(url string) (ws *WebSocket, err error) { defer func() { e := recover() if e == nil { return } if jsErr, ok := e.(*js.Error); ok && jsErr != nil { ws = nil err = jsErr } else { panic(e) } }() object := js.Global.Get("WebSocket").New(url) ws = &WebSocket{ Object: object, } retu...
[ "func", "New", "(", "url", "string", ")", "(", "ws", "*", "WebSocket", ",", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "e", ":=", "recover", "(", ")", "\n", "if", "e", "==", "nil", "{", "return", "\n", "}", "\n", "if", "jsErr", ...
// New creates a new low-level WebSocket. It immediately returns the new // WebSocket.
[ "New", "creates", "a", "new", "low", "-", "level", "WebSocket", ".", "It", "immediately", "returns", "the", "new", "WebSocket", "." ]
87ee47603f137e7f8419765b3621b3c36e715a08
https://github.com/gopherjs/websocket/blob/87ee47603f137e7f8419765b3621b3c36e715a08/websocketjs/websocketjs.go#L70-L91
133,806
gopherjs/websocket
conn.go
initialize
func (c *conn) initialize() { // We need this so that received binary data is in ArrayBufferView format so // that it can easily be read. c.BinaryType = "arraybuffer" c.AddEventListener("message", false, c.onMessage) c.AddEventListener("close", false, c.onClose) }
go
func (c *conn) initialize() { // We need this so that received binary data is in ArrayBufferView format so // that it can easily be read. c.BinaryType = "arraybuffer" c.AddEventListener("message", false, c.onMessage) c.AddEventListener("close", false, c.onClose) }
[ "func", "(", "c", "*", "conn", ")", "initialize", "(", ")", "{", "// We need this so that received binary data is in ArrayBufferView format so", "// that it can easily be read.", "c", ".", "BinaryType", "=", "\"", "\"", "\n\n", "c", ".", "AddEventListener", "(", "\"", ...
// initialize adds all of the event handlers necessary for a conn to function. // It should never be called more than once and is already called if Dial was // used to create the conn.
[ "initialize", "adds", "all", "of", "the", "event", "handlers", "necessary", "for", "a", "conn", "to", "function", ".", "It", "should", "never", "be", "called", "more", "than", "once", "and", "is", "already", "called", "if", "Dial", "was", "used", "to", "...
87ee47603f137e7f8419765b3621b3c36e715a08
https://github.com/gopherjs/websocket/blob/87ee47603f137e7f8419765b3621b3c36e715a08/conn.go#L141-L148
133,807
gopherjs/websocket
conn.go
handleFrame
func (c *conn) handleFrame(message *messageEvent, ok bool) (*messageEvent, error) { if !ok { // The channel has been closed return nil, io.EOF } else if message == nil { // See onClose for the explanation about sending a nil item. close(c.ch) return nil, io.EOF } return message, nil }
go
func (c *conn) handleFrame(message *messageEvent, ok bool) (*messageEvent, error) { if !ok { // The channel has been closed return nil, io.EOF } else if message == nil { // See onClose for the explanation about sending a nil item. close(c.ch) return nil, io.EOF } return message, nil }
[ "func", "(", "c", "*", "conn", ")", "handleFrame", "(", "message", "*", "messageEvent", ",", "ok", "bool", ")", "(", "*", "messageEvent", ",", "error", ")", "{", "if", "!", "ok", "{", "// The channel has been closed", "return", "nil", ",", "io", ".", "...
// handleFrame handles a single frame received from the channel. This is a // convenience funciton to dedupe code for the multiple deadline cases.
[ "handleFrame", "handles", "a", "single", "frame", "received", "from", "the", "channel", ".", "This", "is", "a", "convenience", "funciton", "to", "dedupe", "code", "for", "the", "multiple", "deadline", "cases", "." ]
87ee47603f137e7f8419765b3621b3c36e715a08
https://github.com/gopherjs/websocket/blob/87ee47603f137e7f8419765b3621b3c36e715a08/conn.go#L152-L162
133,808
gopherjs/websocket
conn.go
receiveFrame
func (c *conn) receiveFrame(observeDeadline bool) (*messageEvent, error) { var deadlineChan <-chan time.Time // Receiving on a nil channel always blocks indefinitely if observeDeadline && !c.readDeadline.IsZero() { now := time.Now() if now.After(c.readDeadline) { select { case item, ok := <-c.ch: retur...
go
func (c *conn) receiveFrame(observeDeadline bool) (*messageEvent, error) { var deadlineChan <-chan time.Time // Receiving on a nil channel always blocks indefinitely if observeDeadline && !c.readDeadline.IsZero() { now := time.Now() if now.After(c.readDeadline) { select { case item, ok := <-c.ch: retur...
[ "func", "(", "c", "*", "conn", ")", "receiveFrame", "(", "observeDeadline", "bool", ")", "(", "*", "messageEvent", ",", "error", ")", "{", "var", "deadlineChan", "<-", "chan", "time", ".", "Time", "// Receiving on a nil channel always blocks indefinitely", "\n\n",...
// receiveFrame receives one full frame from the WebSocket. It blocks until the // frame is received.
[ "receiveFrame", "receives", "one", "full", "frame", "from", "the", "WebSocket", ".", "It", "blocks", "until", "the", "frame", "is", "received", "." ]
87ee47603f137e7f8419765b3621b3c36e715a08
https://github.com/gopherjs/websocket/blob/87ee47603f137e7f8419765b3621b3c36e715a08/conn.go#L166-L192
133,809
gopherjs/websocket
conn.go
Write
func (c *conn) Write(b []byte) (n int, err error) { // []byte is converted to an Uint8Array by GopherJS, which fullfils the // ArrayBufferView definition. err = c.Send(b) if err != nil { return 0, err } return len(b), nil }
go
func (c *conn) Write(b []byte) (n int, err error) { // []byte is converted to an Uint8Array by GopherJS, which fullfils the // ArrayBufferView definition. err = c.Send(b) if err != nil { return 0, err } return len(b), nil }
[ "func", "(", "c", "*", "conn", ")", "Write", "(", "b", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "// []byte is converted to an Uint8Array by GopherJS, which fullfils the", "// ArrayBufferView definition.", "err", "=", "c", ".", "Send...
// Write writes the contents of b to the WebSocket using a binary opcode.
[ "Write", "writes", "the", "contents", "of", "b", "to", "the", "WebSocket", "using", "a", "binary", "opcode", "." ]
87ee47603f137e7f8419765b3621b3c36e715a08
https://github.com/gopherjs/websocket/blob/87ee47603f137e7f8419765b3621b3c36e715a08/conn.go#L237-L245
133,810
gopherjs/websocket
conn.go
RemoteAddr
func (c *conn) RemoteAddr() net.Addr { wsURL, err := url.Parse(c.URL) if err != nil { // TODO(nightexcessive): Should we be panicking for this? panic(err) } return &addr{wsURL} }
go
func (c *conn) RemoteAddr() net.Addr { wsURL, err := url.Parse(c.URL) if err != nil { // TODO(nightexcessive): Should we be panicking for this? panic(err) } return &addr{wsURL} }
[ "func", "(", "c", "*", "conn", ")", "RemoteAddr", "(", ")", "net", ".", "Addr", "{", "wsURL", ",", "err", ":=", "url", ".", "Parse", "(", "c", ".", "URL", ")", "\n", "if", "err", "!=", "nil", "{", "// TODO(nightexcessive): Should we be panicking for this...
// RemoteAddr returns the remote network address, based on // websocket.WebSocket.URL.
[ "RemoteAddr", "returns", "the", "remote", "network", "address", "based", "on", "websocket", ".", "WebSocket", ".", "URL", "." ]
87ee47603f137e7f8419765b3621b3c36e715a08
https://github.com/gopherjs/websocket/blob/87ee47603f137e7f8419765b3621b3c36e715a08/conn.go#L260-L267
133,811
xxtea/xxtea-go
xxtea/xxtea.go
Encrypt
func Encrypt(data []byte, key []byte) []byte { if data == nil || len(data) == 0 { return data } return toBytes(encrypt(toUint32s(data, true), toUint32s(key, false)), false) }
go
func Encrypt(data []byte, key []byte) []byte { if data == nil || len(data) == 0 { return data } return toBytes(encrypt(toUint32s(data, true), toUint32s(key, false)), false) }
[ "func", "Encrypt", "(", "data", "[", "]", "byte", ",", "key", "[", "]", "byte", ")", "[", "]", "byte", "{", "if", "data", "==", "nil", "||", "len", "(", "data", ")", "==", "0", "{", "return", "data", "\n", "}", "\n", "return", "toBytes", "(", ...
// Encrypt the data with key. // data is the bytes to be encrypted. // key is the encrypt key. It is the same as the decrypt key.
[ "Encrypt", "the", "data", "with", "key", ".", "data", "is", "the", "bytes", "to", "be", "encrypted", ".", "key", "is", "the", "encrypt", "key", ".", "It", "is", "the", "same", "as", "the", "decrypt", "key", "." ]
35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242
https://github.com/xxtea/xxtea-go/blob/35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242/xxtea/xxtea.go#L120-L125
133,812
xxtea/xxtea-go
xxtea/xxtea.go
Decrypt
func Decrypt(data []byte, key []byte) []byte { if data == nil || len(data) == 0 { return data } return toBytes(decrypt(toUint32s(data, false), toUint32s(key, false)), true) }
go
func Decrypt(data []byte, key []byte) []byte { if data == nil || len(data) == 0 { return data } return toBytes(decrypt(toUint32s(data, false), toUint32s(key, false)), true) }
[ "func", "Decrypt", "(", "data", "[", "]", "byte", ",", "key", "[", "]", "byte", ")", "[", "]", "byte", "{", "if", "data", "==", "nil", "||", "len", "(", "data", ")", "==", "0", "{", "return", "data", "\n", "}", "\n", "return", "toBytes", "(", ...
// Decrypt the data with key. // data is the bytes to be decrypted. // key is the decrypted key. It is the same as the encrypt key.
[ "Decrypt", "the", "data", "with", "key", ".", "data", "is", "the", "bytes", "to", "be", "decrypted", ".", "key", "is", "the", "decrypted", "key", ".", "It", "is", "the", "same", "as", "the", "encrypt", "key", "." ]
35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242
https://github.com/xxtea/xxtea-go/blob/35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242/xxtea/xxtea.go#L130-L135
133,813
xxtea/xxtea-go
xxtea/xxtea.go
EncryptString
func EncryptString(str, key string) string { s := []byte(str) k := []byte(key) b64 := base64.StdEncoding return b64.EncodeToString(Encrypt(s, k)) }
go
func EncryptString(str, key string) string { s := []byte(str) k := []byte(key) b64 := base64.StdEncoding return b64.EncodeToString(Encrypt(s, k)) }
[ "func", "EncryptString", "(", "str", ",", "key", "string", ")", "string", "{", "s", ":=", "[", "]", "byte", "(", "str", ")", "\n", "k", ":=", "[", "]", "byte", "(", "key", ")", "\n", "b64", ":=", "base64", ".", "StdEncoding", "\n", "return", "b64...
// Encrypt the data with key. // data is the string to be encrypted. // key is the string of encrypt key.
[ "Encrypt", "the", "data", "with", "key", ".", "data", "is", "the", "string", "to", "be", "encrypted", ".", "key", "is", "the", "string", "of", "encrypt", "key", "." ]
35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242
https://github.com/xxtea/xxtea-go/blob/35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242/xxtea/xxtea.go#L140-L145
133,814
xxtea/xxtea-go
xxtea/xxtea.go
DecryptString
func DecryptString(str, key string) (string, error) { k := []byte(key) b64 := base64.StdEncoding decodeStr, err := b64.DecodeString(str) if err != nil { return "", err } result := Decrypt([]byte(decodeStr), k) return string(result), nil }
go
func DecryptString(str, key string) (string, error) { k := []byte(key) b64 := base64.StdEncoding decodeStr, err := b64.DecodeString(str) if err != nil { return "", err } result := Decrypt([]byte(decodeStr), k) return string(result), nil }
[ "func", "DecryptString", "(", "str", ",", "key", "string", ")", "(", "string", ",", "error", ")", "{", "k", ":=", "[", "]", "byte", "(", "key", ")", "\n", "b64", ":=", "base64", ".", "StdEncoding", "\n", "decodeStr", ",", "err", ":=", "b64", ".", ...
// Decrypt the data with key. // data is the string to be decrypted. // key is the decrypted key. It is the same as the encrypt key.
[ "Decrypt", "the", "data", "with", "key", ".", "data", "is", "the", "string", "to", "be", "decrypted", ".", "key", "is", "the", "decrypted", "key", ".", "It", "is", "the", "same", "as", "the", "encrypt", "key", "." ]
35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242
https://github.com/xxtea/xxtea-go/blob/35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242/xxtea/xxtea.go#L150-L159
133,815
xxtea/xxtea-go
xxtea/xxtea.go
DecryptURLToStdString
func DecryptURLToStdString(str, key string) (string, error) { return DecryptString(decryptBase64ToStdFormat(str), key) }
go
func DecryptURLToStdString(str, key string) (string, error) { return DecryptString(decryptBase64ToStdFormat(str), key) }
[ "func", "DecryptURLToStdString", "(", "str", ",", "key", "string", ")", "(", "string", ",", "error", ")", "{", "return", "DecryptString", "(", "decryptBase64ToStdFormat", "(", "str", ")", ",", "key", ")", "\n", "}" ]
// Decrypt the URL string with key and convert the URL string to the origin string
[ "Decrypt", "the", "URL", "string", "with", "key", "and", "convert", "the", "URL", "string", "to", "the", "origin", "string" ]
35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242
https://github.com/xxtea/xxtea-go/blob/35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242/xxtea/xxtea.go#L167-L169
133,816
xxtea/xxtea-go
xxtea/xxtea.go
encryptBase64ToUrlFormat
func encryptBase64ToUrlFormat(str string) string { str = strings.Replace(str, "+", "-", -1) str = strings.Replace(str, "/", "_", -1) str = strings.Replace(str, "=", "~", -1) return str }
go
func encryptBase64ToUrlFormat(str string) string { str = strings.Replace(str, "+", "-", -1) str = strings.Replace(str, "/", "_", -1) str = strings.Replace(str, "=", "~", -1) return str }
[ "func", "encryptBase64ToUrlFormat", "(", "str", "string", ")", "string", "{", "str", "=", "strings", ".", "Replace", "(", "str", ",", "\"", "\"", ",", "\"", "\"", ",", "-", "1", ")", "\n", "str", "=", "strings", ".", "Replace", "(", "str", ",", "\"...
// Replace std character to URL character in base64 string
[ "Replace", "std", "character", "to", "URL", "character", "in", "base64", "string" ]
35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242
https://github.com/xxtea/xxtea-go/blob/35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242/xxtea/xxtea.go#L172-L177
133,817
xxtea/xxtea-go
xxtea/xxtea.go
decryptBase64ToStdFormat
func decryptBase64ToStdFormat(str string) string { str = strings.Replace(str, "-", "+", -1) str = strings.Replace(str, "_", "/", -1) str = strings.Replace(str, "~", "=", -1) return str }
go
func decryptBase64ToStdFormat(str string) string { str = strings.Replace(str, "-", "+", -1) str = strings.Replace(str, "_", "/", -1) str = strings.Replace(str, "~", "=", -1) return str }
[ "func", "decryptBase64ToStdFormat", "(", "str", "string", ")", "string", "{", "str", "=", "strings", ".", "Replace", "(", "str", ",", "\"", "\"", ",", "\"", "\"", ",", "-", "1", ")", "\n", "str", "=", "strings", ".", "Replace", "(", "str", ",", "\"...
// Replace URL character to origin character in base64 string
[ "Replace", "URL", "character", "to", "origin", "character", "in", "base64", "string" ]
35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242
https://github.com/xxtea/xxtea-go/blob/35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242/xxtea/xxtea.go#L180-L185
133,818
dustin/gomemcached
mc_constants.go
IsQuiet
func (o CommandCode) IsQuiet() bool { switch o { case GETQ, GETKQ, SETQ, ADDQ, REPLACEQ, DELETEQ, INCREMENTQ, DECREMENTQ, QUITQ, FLUSHQ, APPENDQ, PREPENDQ, RSETQ, RAPPENDQ, RPREPENDQ, RDELETEQ, RINCRQ, RDECRQ: return true } return false }
go
func (o CommandCode) IsQuiet() bool { switch o { case GETQ, GETKQ, SETQ, ADDQ, REPLACEQ, DELETEQ, INCREMENTQ, DECREMENTQ, QUITQ, FLUSHQ, APPENDQ, PREPENDQ, RSETQ, RAPPENDQ, RPREPENDQ, RDELETEQ, RINCRQ, RDECRQ: return true } return false }
[ "func", "(", "o", "CommandCode", ")", "IsQuiet", "(", ")", "bool", "{", "switch", "o", "{", "case", "GETQ", ",", "GETKQ", ",", "SETQ", ",", "ADDQ", ",", "REPLACEQ", ",", "DELETEQ", ",", "INCREMENTQ", ",", "DECREMENTQ", ",", "QUITQ", ",", "FLUSHQ", ",...
// Return true if a command is a "quiet" command.
[ "Return", "true", "if", "a", "command", "is", "a", "quiet", "command", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/mc_constants.go#L194-L217
133,819
dustin/gomemcached
mc_res.go
String
func (res MCResponse) String() string { return fmt.Sprintf("{MCResponse status=%v keylen=%d, extralen=%d, bodylen=%d}", res.Status, len(res.Key), len(res.Extras), len(res.Body)) }
go
func (res MCResponse) String() string { return fmt.Sprintf("{MCResponse status=%v keylen=%d, extralen=%d, bodylen=%d}", res.Status, len(res.Key), len(res.Extras), len(res.Body)) }
[ "func", "(", "res", "MCResponse", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "res", ".", "Status", ",", "len", "(", "res", ".", "Key", ")", ",", "len", "(", "res", ".", "Extras", ")", ",", "le...
// A debugging string representation of this response
[ "A", "debugging", "string", "representation", "of", "this", "response" ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/mc_res.go#L26-L29
133,820
dustin/gomemcached
mc_res.go
Error
func (res *MCResponse) Error() string { return fmt.Sprintf("MCResponse status=%v, opcode=%v, opaque=%v, msg: %s", res.Status, res.Opcode, res.Opaque, string(res.Body)) }
go
func (res *MCResponse) Error() string { return fmt.Sprintf("MCResponse status=%v, opcode=%v, opaque=%v, msg: %s", res.Status, res.Opcode, res.Opaque, string(res.Body)) }
[ "func", "(", "res", "*", "MCResponse", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "res", ".", "Status", ",", "res", ".", "Opcode", ",", "res", ".", "Opaque", ",", "string", "(", "res", ".", "Body...
// Response as an error.
[ "Response", "as", "an", "error", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/mc_res.go#L32-L35
133,821
dustin/gomemcached
mc_res.go
IsFatal
func IsFatal(e error) bool { if e == nil { return false } switch errStatus(e) { case KEY_ENOENT, KEY_EEXISTS, NOT_STORED, TMPFAIL: return false } return true }
go
func IsFatal(e error) bool { if e == nil { return false } switch errStatus(e) { case KEY_ENOENT, KEY_EEXISTS, NOT_STORED, TMPFAIL: return false } return true }
[ "func", "IsFatal", "(", "e", "error", ")", "bool", "{", "if", "e", "==", "nil", "{", "return", "false", "\n", "}", "\n", "switch", "errStatus", "(", "e", ")", "{", "case", "KEY_ENOENT", ",", "KEY_EEXISTS", ",", "NOT_STORED", ",", "TMPFAIL", ":", "ret...
// False if this error isn't believed to be fatal to a connection.
[ "False", "if", "this", "error", "isn", "t", "believed", "to", "be", "fatal", "to", "a", "connection", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/mc_res.go#L51-L60
133,822
dustin/gomemcached
mc_res.go
Size
func (res *MCResponse) Size() int { return HDR_LEN + len(res.Extras) + len(res.Key) + len(res.Body) }
go
func (res *MCResponse) Size() int { return HDR_LEN + len(res.Extras) + len(res.Key) + len(res.Body) }
[ "func", "(", "res", "*", "MCResponse", ")", "Size", "(", ")", "int", "{", "return", "HDR_LEN", "+", "len", "(", "res", ".", "Extras", ")", "+", "len", "(", "res", ".", "Key", ")", "+", "len", "(", "res", ".", "Body", ")", "\n", "}" ]
// Number of bytes this response consumes on the wire.
[ "Number", "of", "bytes", "this", "response", "consumes", "on", "the", "wire", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/mc_res.go#L63-L65
133,823
dustin/gomemcached
mc_res.go
HeaderBytes
func (res *MCResponse) HeaderBytes() []byte { data := make([]byte, HDR_LEN+len(res.Extras)+len(res.Key)) res.fillHeaderBytes(data) return data }
go
func (res *MCResponse) HeaderBytes() []byte { data := make([]byte, HDR_LEN+len(res.Extras)+len(res.Key)) res.fillHeaderBytes(data) return data }
[ "func", "(", "res", "*", "MCResponse", ")", "HeaderBytes", "(", ")", "[", "]", "byte", "{", "data", ":=", "make", "(", "[", "]", "byte", ",", "HDR_LEN", "+", "len", "(", "res", ".", "Extras", ")", "+", "len", "(", "res", ".", "Key", ")", ")", ...
// Get just the header bytes for this response.
[ "Get", "just", "the", "header", "bytes", "for", "this", "response", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/mc_res.go#L112-L118
133,824
dustin/gomemcached
mc_res.go
Bytes
func (res *MCResponse) Bytes() []byte { data := make([]byte, res.Size()) pos := res.fillHeaderBytes(data) copy(data[pos:pos+len(res.Body)], res.Body) return data }
go
func (res *MCResponse) Bytes() []byte { data := make([]byte, res.Size()) pos := res.fillHeaderBytes(data) copy(data[pos:pos+len(res.Body)], res.Body) return data }
[ "func", "(", "res", "*", "MCResponse", ")", "Bytes", "(", ")", "[", "]", "byte", "{", "data", ":=", "make", "(", "[", "]", "byte", ",", "res", ".", "Size", "(", ")", ")", "\n\n", "pos", ":=", "res", ".", "fillHeaderBytes", "(", "data", ")", "\n...
// The actual bytes transmitted for this response.
[ "The", "actual", "bytes", "transmitted", "for", "this", "response", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/mc_res.go#L121-L129
133,825
dustin/gomemcached
mc_res.go
Transmit
func (res *MCResponse) Transmit(w io.Writer) (n int, err error) { if len(res.Body) < 128 { n, err = w.Write(res.Bytes()) } else { n, err = w.Write(res.HeaderBytes()) if err == nil { m := 0 m, err = w.Write(res.Body) m += n } } return }
go
func (res *MCResponse) Transmit(w io.Writer) (n int, err error) { if len(res.Body) < 128 { n, err = w.Write(res.Bytes()) } else { n, err = w.Write(res.HeaderBytes()) if err == nil { m := 0 m, err = w.Write(res.Body) m += n } } return }
[ "func", "(", "res", "*", "MCResponse", ")", "Transmit", "(", "w", "io", ".", "Writer", ")", "(", "n", "int", ",", "err", "error", ")", "{", "if", "len", "(", "res", ".", "Body", ")", "<", "128", "{", "n", ",", "err", "=", "w", ".", "Write", ...
// Send this response message across a writer.
[ "Send", "this", "response", "message", "across", "a", "writer", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/mc_res.go#L132-L144
133,826
dustin/gomemcached
client/mc.go
Connect
func Connect(prot, dest string) (rv *Client, err error) { conn, err := dialFun(prot, dest) if err != nil { return nil, err } return Wrap(conn) }
go
func Connect(prot, dest string) (rv *Client, err error) { conn, err := dialFun(prot, dest) if err != nil { return nil, err } return Wrap(conn) }
[ "func", "Connect", "(", "prot", ",", "dest", "string", ")", "(", "rv", "*", "Client", ",", "err", "error", ")", "{", "conn", ",", "err", ":=", "dialFun", "(", "prot", ",", "dest", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", ...
// Connect to a memcached server.
[ "Connect", "to", "a", "memcached", "server", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/client/mc.go#L30-L36
133,827
dustin/gomemcached
client/mc.go
Wrap
func Wrap(rwc io.ReadWriteCloser) (rv *Client, err error) { return &Client{ conn: rwc, healthy: true, hdrBuf: make([]byte, gomemcached.HDR_LEN), }, nil }
go
func Wrap(rwc io.ReadWriteCloser) (rv *Client, err error) { return &Client{ conn: rwc, healthy: true, hdrBuf: make([]byte, gomemcached.HDR_LEN), }, nil }
[ "func", "Wrap", "(", "rwc", "io", ".", "ReadWriteCloser", ")", "(", "rv", "*", "Client", ",", "err", "error", ")", "{", "return", "&", "Client", "{", "conn", ":", "rwc", ",", "healthy", ":", "true", ",", "hdrBuf", ":", "make", "(", "[", "]", "byt...
// Wrap an existing transport.
[ "Wrap", "an", "existing", "transport", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/client/mc.go#L39-L45
133,828
dustin/gomemcached
client/mc.go
Send
func (c *Client) Send(req *gomemcached.MCRequest) (rv *gomemcached.MCResponse, err error) { _, err = transmitRequest(c.conn, req) if err != nil { c.healthy = false return } resp, _, err := getResponse(c.conn, c.hdrBuf) c.healthy = !gomemcached.IsFatal(err) return resp, err }
go
func (c *Client) Send(req *gomemcached.MCRequest) (rv *gomemcached.MCResponse, err error) { _, err = transmitRequest(c.conn, req) if err != nil { c.healthy = false return } resp, _, err := getResponse(c.conn, c.hdrBuf) c.healthy = !gomemcached.IsFatal(err) return resp, err }
[ "func", "(", "c", "*", "Client", ")", "Send", "(", "req", "*", "gomemcached", ".", "MCRequest", ")", "(", "rv", "*", "gomemcached", ".", "MCResponse", ",", "err", "error", ")", "{", "_", ",", "err", "=", "transmitRequest", "(", "c", ".", "conn", ",...
// Send a custom request and get the response.
[ "Send", "a", "custom", "request", "and", "get", "the", "response", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/client/mc.go#L62-L71
133,829
dustin/gomemcached
client/mc.go
Transmit
func (c *Client) Transmit(req *gomemcached.MCRequest) error { _, err := transmitRequest(c.conn, req) if err != nil { c.healthy = false } return err }
go
func (c *Client) Transmit(req *gomemcached.MCRequest) error { _, err := transmitRequest(c.conn, req) if err != nil { c.healthy = false } return err }
[ "func", "(", "c", "*", "Client", ")", "Transmit", "(", "req", "*", "gomemcached", ".", "MCRequest", ")", "error", "{", "_", ",", "err", ":=", "transmitRequest", "(", "c", ".", "conn", ",", "req", ")", "\n", "if", "err", "!=", "nil", "{", "c", "."...
// Transmit send a request, but does not wait for a response.
[ "Transmit", "send", "a", "request", "but", "does", "not", "wait", "for", "a", "response", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/client/mc.go#L74-L80
133,830
dustin/gomemcached
client/mc.go
Receive
func (c *Client) Receive() (*gomemcached.MCResponse, error) { resp, _, err := getResponse(c.conn, c.hdrBuf) if err != nil { c.healthy = false } return resp, err }
go
func (c *Client) Receive() (*gomemcached.MCResponse, error) { resp, _, err := getResponse(c.conn, c.hdrBuf) if err != nil { c.healthy = false } return resp, err }
[ "func", "(", "c", "*", "Client", ")", "Receive", "(", ")", "(", "*", "gomemcached", ".", "MCResponse", ",", "error", ")", "{", "resp", ",", "_", ",", "err", ":=", "getResponse", "(", "c", ".", "conn", ",", "c", ".", "hdrBuf", ")", "\n", "if", "...
// Receive a response
[ "Receive", "a", "response" ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/client/mc.go#L83-L89
133,831
dustin/gomemcached
client/mc.go
Get
func (c *Client) Get(vb uint16, key string) (*gomemcached.MCResponse, error) { return c.Send(&gomemcached.MCRequest{ Opcode: gomemcached.GET, VBucket: vb, Key: []byte(key), }) }
go
func (c *Client) Get(vb uint16, key string) (*gomemcached.MCResponse, error) { return c.Send(&gomemcached.MCRequest{ Opcode: gomemcached.GET, VBucket: vb, Key: []byte(key), }) }
[ "func", "(", "c", "*", "Client", ")", "Get", "(", "vb", "uint16", ",", "key", "string", ")", "(", "*", "gomemcached", ".", "MCResponse", ",", "error", ")", "{", "return", "c", ".", "Send", "(", "&", "gomemcached", ".", "MCRequest", "{", "Opcode", "...
// Get the value for a key.
[ "Get", "the", "value", "for", "a", "key", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/client/mc.go#L92-L98
133,832
dustin/gomemcached
client/mc.go
Del
func (c *Client) Del(vb uint16, key string) (*gomemcached.MCResponse, error) { return c.Send(&gomemcached.MCRequest{ Opcode: gomemcached.DELETE, VBucket: vb, Key: []byte(key)}) }
go
func (c *Client) Del(vb uint16, key string) (*gomemcached.MCResponse, error) { return c.Send(&gomemcached.MCRequest{ Opcode: gomemcached.DELETE, VBucket: vb, Key: []byte(key)}) }
[ "func", "(", "c", "*", "Client", ")", "Del", "(", "vb", "uint16", ",", "key", "string", ")", "(", "*", "gomemcached", ".", "MCResponse", ",", "error", ")", "{", "return", "c", ".", "Send", "(", "&", "gomemcached", ".", "MCRequest", "{", "Opcode", "...
// Del deletes a key.
[ "Del", "deletes", "a", "key", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/client/mc.go#L101-L106
133,833
dustin/gomemcached
client/mc.go
AuthList
func (c *Client) AuthList() (*gomemcached.MCResponse, error) { return c.Send(&gomemcached.MCRequest{ Opcode: gomemcached.SASL_LIST_MECHS}) }
go
func (c *Client) AuthList() (*gomemcached.MCResponse, error) { return c.Send(&gomemcached.MCRequest{ Opcode: gomemcached.SASL_LIST_MECHS}) }
[ "func", "(", "c", "*", "Client", ")", "AuthList", "(", ")", "(", "*", "gomemcached", ".", "MCResponse", ",", "error", ")", "{", "return", "c", ".", "Send", "(", "&", "gomemcached", ".", "MCRequest", "{", "Opcode", ":", "gomemcached", ".", "SASL_LIST_ME...
// AuthList lists SASL auth mechanisms.
[ "AuthList", "lists", "SASL", "auth", "mechanisms", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/client/mc.go#L109-L112
133,834
dustin/gomemcached
client/mc.go
Auth
func (c *Client) Auth(user, pass string) (*gomemcached.MCResponse, error) { res, err := c.AuthList() if err != nil { return res, err } authMech := string(res.Body) if strings.Index(authMech, "PLAIN") != -1 { return c.Send(&gomemcached.MCRequest{ Opcode: gomemcached.SASL_AUTH, Key: []byte("PLAIN"), ...
go
func (c *Client) Auth(user, pass string) (*gomemcached.MCResponse, error) { res, err := c.AuthList() if err != nil { return res, err } authMech := string(res.Body) if strings.Index(authMech, "PLAIN") != -1 { return c.Send(&gomemcached.MCRequest{ Opcode: gomemcached.SASL_AUTH, Key: []byte("PLAIN"), ...
[ "func", "(", "c", "*", "Client", ")", "Auth", "(", "user", ",", "pass", "string", ")", "(", "*", "gomemcached", ".", "MCResponse", ",", "error", ")", "{", "res", ",", "err", ":=", "c", ".", "AuthList", "(", ")", "\n\n", "if", "err", "!=", "nil", ...
// Auth performs SASL PLAIN authentication against the server.
[ "Auth", "performs", "SASL", "PLAIN", "authentication", "against", "the", "server", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/client/mc.go#L115-L130
133,835
dustin/gomemcached
client/mc.go
Incr
func (c *Client) Incr(vb uint16, key string, amt, def uint64, exp int) (uint64, error) { req := &gomemcached.MCRequest{ Opcode: gomemcached.INCREMENT, VBucket: vb, Key: []byte(key), Extras: make([]byte, 8+8+4), } binary.BigEndian.PutUint64(req.Extras[:8], amt) binary.BigEndian.PutUint64(req.Extras[8...
go
func (c *Client) Incr(vb uint16, key string, amt, def uint64, exp int) (uint64, error) { req := &gomemcached.MCRequest{ Opcode: gomemcached.INCREMENT, VBucket: vb, Key: []byte(key), Extras: make([]byte, 8+8+4), } binary.BigEndian.PutUint64(req.Extras[:8], amt) binary.BigEndian.PutUint64(req.Extras[8...
[ "func", "(", "c", "*", "Client", ")", "Incr", "(", "vb", "uint16", ",", "key", "string", ",", "amt", ",", "def", "uint64", ",", "exp", "int", ")", "(", "uint64", ",", "error", ")", "{", "req", ":=", "&", "gomemcached", ".", "MCRequest", "{", "Opc...
// Incr increments the value at the given key.
[ "Incr", "increments", "the", "value", "at", "the", "given", "key", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/client/mc.go#L149-L168
133,836
dustin/gomemcached
client/mc.go
Set
func (c *Client) Set(vb uint16, key string, flags int, exp int, body []byte) (*gomemcached.MCResponse, error) { return c.store(gomemcached.SET, vb, key, flags, exp, body) }
go
func (c *Client) Set(vb uint16, key string, flags int, exp int, body []byte) (*gomemcached.MCResponse, error) { return c.store(gomemcached.SET, vb, key, flags, exp, body) }
[ "func", "(", "c", "*", "Client", ")", "Set", "(", "vb", "uint16", ",", "key", "string", ",", "flags", "int", ",", "exp", "int", ",", "body", "[", "]", "byte", ")", "(", "*", "gomemcached", ".", "MCResponse", ",", "error", ")", "{", "return", "c",...
// Set the value for a key.
[ "Set", "the", "value", "for", "a", "key", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/client/mc.go#L177-L180
133,837
dustin/gomemcached
client/mc.go
Append
func (c *Client) Append(vb uint16, key string, data []byte) (*gomemcached.MCResponse, error) { req := &gomemcached.MCRequest{ Opcode: gomemcached.APPEND, VBucket: vb, Key: []byte(key), Cas: 0, Opaque: 0, Body: data} return c.Send(req) }
go
func (c *Client) Append(vb uint16, key string, data []byte) (*gomemcached.MCResponse, error) { req := &gomemcached.MCRequest{ Opcode: gomemcached.APPEND, VBucket: vb, Key: []byte(key), Cas: 0, Opaque: 0, Body: data} return c.Send(req) }
[ "func", "(", "c", "*", "Client", ")", "Append", "(", "vb", "uint16", ",", "key", "string", ",", "data", "[", "]", "byte", ")", "(", "*", "gomemcached", ".", "MCResponse", ",", "error", ")", "{", "req", ":=", "&", "gomemcached", ".", "MCRequest", "{...
// Append data to the value of a key.
[ "Append", "data", "to", "the", "value", "of", "a", "key", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/client/mc.go#L183-L193
133,838
dustin/gomemcached
client/mc.go
GetBulk
func (c *Client) GetBulk(vb uint16, keys []string) (map[string]*gomemcached.MCResponse, error) { rv := map[string]*gomemcached.MCResponse{} going := true defer func() { going = false }() errch := make(chan error, 2) go func() { defer func() { errch <- nil }() for going { res, err := c.Receive() if ...
go
func (c *Client) GetBulk(vb uint16, keys []string) (map[string]*gomemcached.MCResponse, error) { rv := map[string]*gomemcached.MCResponse{} going := true defer func() { going = false }() errch := make(chan error, 2) go func() { defer func() { errch <- nil }() for going { res, err := c.Receive() if ...
[ "func", "(", "c", "*", "Client", ")", "GetBulk", "(", "vb", "uint16", ",", "keys", "[", "]", "string", ")", "(", "map", "[", "string", "]", "*", "gomemcached", ".", "MCResponse", ",", "error", ")", "{", "rv", ":=", "map", "[", "string", "]", "*",...
// GetBulk gets keys in bulk
[ "GetBulk", "gets", "keys", "in", "bulk" ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/client/mc.go#L196-L243
133,839
dustin/gomemcached
client/mc.go
CheckPersistence
func (result ObserveResult) CheckPersistence(cas uint64, deletion bool) (persisted bool, overwritten bool) { switch { case result.Status == ObservedNotFound && deletion: persisted = true case result.Cas != cas: overwritten = true case result.Status == ObservedPersisted: persisted = true } return }
go
func (result ObserveResult) CheckPersistence(cas uint64, deletion bool) (persisted bool, overwritten bool) { switch { case result.Status == ObservedNotFound && deletion: persisted = true case result.Cas != cas: overwritten = true case result.Status == ObservedPersisted: persisted = true } return }
[ "func", "(", "result", "ObserveResult", ")", "CheckPersistence", "(", "cas", "uint64", ",", "deletion", "bool", ")", "(", "persisted", "bool", ",", "overwritten", "bool", ")", "{", "switch", "{", "case", "result", ".", "Status", "==", "ObservedNotFound", "&&...
// CheckPersistence checks whether a stored value has been persisted to disk yet.
[ "CheckPersistence", "checks", "whether", "a", "stored", "value", "has", "been", "persisted", "to", "disk", "yet", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/client/mc.go#L306-L316
133,840
dustin/gomemcached
client/mc.go
CAS
func (c *Client) CAS(vb uint16, k string, f CasFunc, initexp int) (*gomemcached.MCResponse, error) { var state CASState for c.CASNext(vb, k, initexp, &state) { newValue, operation := f(state.Value) if operation == CASQuit || (operation == CASDelete && state.Value == nil) { return nil, operation } state.Va...
go
func (c *Client) CAS(vb uint16, k string, f CasFunc, initexp int) (*gomemcached.MCResponse, error) { var state CASState for c.CASNext(vb, k, initexp, &state) { newValue, operation := f(state.Value) if operation == CASQuit || (operation == CASDelete && state.Value == nil) { return nil, operation } state.Va...
[ "func", "(", "c", "*", "Client", ")", "CAS", "(", "vb", "uint16", ",", "k", "string", ",", "f", "CasFunc", ",", "initexp", "int", ")", "(", "*", "gomemcached", ".", "MCResponse", ",", "error", ")", "{", "var", "state", "CASState", "\n", "for", "c",...
// CAS performs a CAS transform with the given function. // // If the value does not exist, a nil current value will be sent to f.
[ "CAS", "performs", "a", "CAS", "transform", "with", "the", "given", "function", ".", "If", "the", "value", "does", "not", "exist", "a", "nil", "current", "value", "will", "be", "sent", "to", "f", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/client/mc.go#L430-L441
133,841
dustin/gomemcached
client/mc.go
Stats
func (c *Client) Stats(key string) ([]StatValue, error) { rv := make([]StatValue, 0, 128) req := &gomemcached.MCRequest{ Opcode: gomemcached.STAT, Key: []byte(key), Opaque: 918494, } _, err := transmitRequest(c.conn, req) if err != nil { return rv, err } for { res, _, err := getResponse(c.conn, c...
go
func (c *Client) Stats(key string) ([]StatValue, error) { rv := make([]StatValue, 0, 128) req := &gomemcached.MCRequest{ Opcode: gomemcached.STAT, Key: []byte(key), Opaque: 918494, } _, err := transmitRequest(c.conn, req) if err != nil { return rv, err } for { res, _, err := getResponse(c.conn, c...
[ "func", "(", "c", "*", "Client", ")", "Stats", "(", "key", "string", ")", "(", "[", "]", "StatValue", ",", "error", ")", "{", "rv", ":=", "make", "(", "[", "]", "StatValue", ",", "0", ",", "128", ")", "\n\n", "req", ":=", "&", "gomemcached", "....
// Stats requests server-side stats. // // Use "" as the stat key for toplevel stats.
[ "Stats", "requests", "server", "-", "side", "stats", ".", "Use", "as", "the", "stat", "key", "for", "toplevel", "stats", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/client/mc.go#L454-L484
133,842
dustin/gomemcached
client/mc.go
StatsMap
func (c *Client) StatsMap(key string) (map[string]string, error) { rv := make(map[string]string) st, err := c.Stats(key) if err != nil { return rv, err } for _, sv := range st { rv[sv.Key] = sv.Val } return rv, nil }
go
func (c *Client) StatsMap(key string) (map[string]string, error) { rv := make(map[string]string) st, err := c.Stats(key) if err != nil { return rv, err } for _, sv := range st { rv[sv.Key] = sv.Val } return rv, nil }
[ "func", "(", "c", "*", "Client", ")", "StatsMap", "(", "key", "string", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "rv", ":=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "st", ",", "err", ":=", "c",...
// StatsMap requests server-side stats similarly to Stats, but returns // them as a map. // // Use "" as the stat key for toplevel stats.
[ "StatsMap", "requests", "server", "-", "side", "stats", "similarly", "to", "Stats", "but", "returns", "them", "as", "a", "map", ".", "Use", "as", "the", "stat", "key", "for", "toplevel", "stats", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/client/mc.go#L490-L500
133,843
dustin/gomemcached
client/mc.go
Hijack
func (c *Client) Hijack() io.ReadWriteCloser { c.healthy = false return c.conn }
go
func (c *Client) Hijack() io.ReadWriteCloser { c.healthy = false return c.conn }
[ "func", "(", "c", "*", "Client", ")", "Hijack", "(", ")", "io", ".", "ReadWriteCloser", "{", "c", ".", "healthy", "=", "false", "\n", "return", "c", ".", "conn", "\n", "}" ]
// Hijack exposes the underlying connection from this client. // // It also marks the connection as unhealthy since the client will // have lost control over the connection and can't otherwise verify // things are in good shape for connection pools.
[ "Hijack", "exposes", "the", "underlying", "connection", "from", "this", "client", ".", "It", "also", "marks", "the", "connection", "as", "unhealthy", "since", "the", "client", "will", "have", "lost", "control", "over", "the", "connection", "and", "can", "t", ...
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/client/mc.go#L507-L510
133,844
dustin/gomemcached
client/transport.go
UnwrapMemcachedError
func UnwrapMemcachedError(rv *gomemcached.MCResponse, err error) (*gomemcached.MCResponse, error) { if rv == err { return rv, nil } return rv, err }
go
func UnwrapMemcachedError(rv *gomemcached.MCResponse, err error) (*gomemcached.MCResponse, error) { if rv == err { return rv, nil } return rv, err }
[ "func", "UnwrapMemcachedError", "(", "rv", "*", "gomemcached", ".", "MCResponse", ",", "err", "error", ")", "(", "*", "gomemcached", ".", "MCResponse", ",", "error", ")", "{", "if", "rv", "==", "err", "{", "return", "rv", ",", "nil", "\n", "}", "\n", ...
// UnwrapMemcachedError converts memcached errors to normal responses. // // If the error is a memcached response, declare the error to be nil // so a client can handle the status without worrying about whether it // indicates success or failure.
[ "UnwrapMemcachedError", "converts", "memcached", "errors", "to", "normal", "responses", ".", "If", "the", "error", "is", "a", "memcached", "response", "declare", "the", "error", "to", "be", "nil", "so", "a", "client", "can", "handle", "the", "status", "without...
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/client/transport.go#L17-L24
133,845
dustin/gomemcached
client/tap_feed.go
StartTapFeed
func (mc *Client) StartTapFeed(args TapArguments) (*TapFeed, error) { rq := &gomemcached.MCRequest{ Opcode: gomemcached.TAP_CONNECT, Key: []byte(args.ClientName), Extras: args.flags(), Body: args.bytes()} err := mc.Transmit(rq) if err != nil { return nil, err } ch := make(chan TapEvent) feed := &...
go
func (mc *Client) StartTapFeed(args TapArguments) (*TapFeed, error) { rq := &gomemcached.MCRequest{ Opcode: gomemcached.TAP_CONNECT, Key: []byte(args.ClientName), Extras: args.flags(), Body: args.bytes()} err := mc.Transmit(rq) if err != nil { return nil, err } ch := make(chan TapEvent) feed := &...
[ "func", "(", "mc", "*", "Client", ")", "StartTapFeed", "(", "args", "TapArguments", ")", "(", "*", "TapFeed", ",", "error", ")", "{", "rq", ":=", "&", "gomemcached", ".", "MCRequest", "{", "Opcode", ":", "gomemcached", ".", "TAP_CONNECT", ",", "Key", "...
// StartTapFeed starts a TAP feed on a client connection. // // The events can be read from the returned channel. The connection // can no longer be used for other purposes; it's now reserved for // receiving the TAP messages. To stop receiving events, close the // client connection.
[ "StartTapFeed", "starts", "a", "TAP", "feed", "on", "a", "client", "connection", ".", "The", "events", "can", "be", "read", "from", "the", "returned", "channel", ".", "The", "connection", "can", "no", "longer", "be", "used", "for", "other", "purposes", ";"...
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/client/tap_feed.go#L234-L253
133,846
dustin/gomemcached
client/tap_feed.go
runFeed
func (mc *Client) runFeed(ch chan TapEvent, feed *TapFeed) { defer close(ch) var headerBuf [gomemcached.HDR_LEN]byte loop: for { // Read the next request from the server. // // (Can't call mc.Receive() because it reads a // _response_ not a request.) var pkt gomemcached.MCRequest n, err := pkt.Receive(...
go
func (mc *Client) runFeed(ch chan TapEvent, feed *TapFeed) { defer close(ch) var headerBuf [gomemcached.HDR_LEN]byte loop: for { // Read the next request from the server. // // (Can't call mc.Receive() because it reads a // _response_ not a request.) var pkt gomemcached.MCRequest n, err := pkt.Receive(...
[ "func", "(", "mc", "*", "Client", ")", "runFeed", "(", "ch", "chan", "TapEvent", ",", "feed", "*", "TapFeed", ")", "{", "defer", "close", "(", "ch", ")", "\n", "var", "headerBuf", "[", "gomemcached", ".", "HDR_LEN", "]", "byte", "\n", "loop", ":", ...
// Internal goroutine that reads from the socket and writes events to // the channel
[ "Internal", "goroutine", "that", "reads", "from", "the", "socket", "and", "writes", "events", "to", "the", "channel" ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/client/tap_feed.go#L260-L317
133,847
dustin/gomemcached
mc_req.go
Size
func (req *MCRequest) Size() int { return HDR_LEN + len(req.Extras) + len(req.Key) + len(req.Body) }
go
func (req *MCRequest) Size() int { return HDR_LEN + len(req.Extras) + len(req.Key) + len(req.Body) }
[ "func", "(", "req", "*", "MCRequest", ")", "Size", "(", ")", "int", "{", "return", "HDR_LEN", "+", "len", "(", "req", ".", "Extras", ")", "+", "len", "(", "req", ".", "Key", ")", "+", "len", "(", "req", ".", "Body", ")", "\n", "}" ]
// The number of bytes this request requires.
[ "The", "number", "of", "bytes", "this", "request", "requires", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/mc_req.go#L28-L30
133,848
dustin/gomemcached
mc_req.go
String
func (req MCRequest) String() string { return fmt.Sprintf("{MCRequest opcode=%s, bodylen=%d, key='%s'}", req.Opcode, len(req.Body), req.Key) }
go
func (req MCRequest) String() string { return fmt.Sprintf("{MCRequest opcode=%s, bodylen=%d, key='%s'}", req.Opcode, len(req.Body), req.Key) }
[ "func", "(", "req", "MCRequest", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "req", ".", "Opcode", ",", "len", "(", "req", ".", "Body", ")", ",", "req", ".", "Key", ")", "\n", "}" ]
// A debugging string representation of this request
[ "A", "debugging", "string", "representation", "of", "this", "request" ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/mc_req.go#L33-L36
133,849
dustin/gomemcached
mc_req.go
Bytes
func (req *MCRequest) Bytes() []byte { data := make([]byte, req.Size()) pos := req.fillHeaderBytes(data) if len(req.Body) > 0 { copy(data[pos:pos+len(req.Body)], req.Body) } return data }
go
func (req *MCRequest) Bytes() []byte { data := make([]byte, req.Size()) pos := req.fillHeaderBytes(data) if len(req.Body) > 0 { copy(data[pos:pos+len(req.Body)], req.Body) } return data }
[ "func", "(", "req", "*", "MCRequest", ")", "Bytes", "(", ")", "[", "]", "byte", "{", "data", ":=", "make", "(", "[", "]", "byte", ",", "req", ".", "Size", "(", ")", ")", "\n\n", "pos", ":=", "req", ".", "fillHeaderBytes", "(", "data", ")", "\n\...
// The wire representation of this request.
[ "The", "wire", "representation", "of", "this", "request", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/mc_req.go#L94-L104
133,850
dustin/gomemcached
mc_req.go
Transmit
func (req *MCRequest) Transmit(w io.Writer) (n int, err error) { if len(req.Body) < 128 { n, err = w.Write(req.Bytes()) } else { n, err = w.Write(req.HeaderBytes()) if err == nil { m := 0 m, err = w.Write(req.Body) n += m } } return }
go
func (req *MCRequest) Transmit(w io.Writer) (n int, err error) { if len(req.Body) < 128 { n, err = w.Write(req.Bytes()) } else { n, err = w.Write(req.HeaderBytes()) if err == nil { m := 0 m, err = w.Write(req.Body) n += m } } return }
[ "func", "(", "req", "*", "MCRequest", ")", "Transmit", "(", "w", "io", ".", "Writer", ")", "(", "n", "int", ",", "err", "error", ")", "{", "if", "len", "(", "req", ".", "Body", ")", "<", "128", "{", "n", ",", "err", "=", "w", ".", "Write", ...
// Send this request message across a writer.
[ "Send", "this", "request", "message", "across", "a", "writer", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/mc_req.go#L107-L119
133,851
dustin/gomemcached
mc_req.go
Receive
func (req *MCRequest) Receive(r io.Reader, hdrBytes []byte) (int, error) { if len(hdrBytes) < HDR_LEN { hdrBytes = []byte{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} } n, err := io.ReadFull(r, hdrBytes) if err != nil { return n, err } if hdrBytes[0] != RES_MAGIC && hdrBy...
go
func (req *MCRequest) Receive(r io.Reader, hdrBytes []byte) (int, error) { if len(hdrBytes) < HDR_LEN { hdrBytes = []byte{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} } n, err := io.ReadFull(r, hdrBytes) if err != nil { return n, err } if hdrBytes[0] != RES_MAGIC && hdrBy...
[ "func", "(", "req", "*", "MCRequest", ")", "Receive", "(", "r", "io", ".", "Reader", ",", "hdrBytes", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "if", "len", "(", "hdrBytes", ")", "<", "HDR_LEN", "{", "hdrBytes", "=", "[", "]", ...
// Fill this MCRequest with the data from this reader.
[ "Fill", "this", "MCRequest", "with", "the", "data", "from", "this", "reader", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/mc_req.go#L122-L177
133,852
dustin/gomemcached
tap.go
SplitFlags
func (f TapConnectFlag) SplitFlags() []TapConnectFlag { rv := []TapConnectFlag{} for i := uint32(1); f != 0; i = i << 1 { if uint32(f)&i == i { rv = append(rv, TapConnectFlag(i)) } f = TapConnectFlag(uint32(f) & (^i)) } return rv }
go
func (f TapConnectFlag) SplitFlags() []TapConnectFlag { rv := []TapConnectFlag{} for i := uint32(1); f != 0; i = i << 1 { if uint32(f)&i == i { rv = append(rv, TapConnectFlag(i)) } f = TapConnectFlag(uint32(f) & (^i)) } return rv }
[ "func", "(", "f", "TapConnectFlag", ")", "SplitFlags", "(", ")", "[", "]", "TapConnectFlag", "{", "rv", ":=", "[", "]", "TapConnectFlag", "{", "}", "\n", "for", "i", ":=", "uint32", "(", "1", ")", ";", "f", "!=", "0", ";", "i", "=", "i", "<<", ...
// Split the ORed flags into the individual bit flags.
[ "Split", "the", "ORed", "flags", "into", "the", "individual", "bit", "flags", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/tap.go#L99-L108
133,853
dustin/gomemcached
tap.go
ParseTapCommands
func (req *MCRequest) ParseTapCommands() (TapConnect, error) { rv := TapConnect{ Flags: map[TapConnectFlag]interface{}{}, Name: string(req.Key), } if len(req.Extras) < 4 { return rv, fmt.Errorf("not enough extra bytes: %x", req.Extras) } flags := TapConnectFlag(binary.BigEndian.Uint32(req.Extras)) r := ...
go
func (req *MCRequest) ParseTapCommands() (TapConnect, error) { rv := TapConnect{ Flags: map[TapConnectFlag]interface{}{}, Name: string(req.Key), } if len(req.Extras) < 4 { return rv, fmt.Errorf("not enough extra bytes: %x", req.Extras) } flags := TapConnectFlag(binary.BigEndian.Uint32(req.Extras)) r := ...
[ "func", "(", "req", "*", "MCRequest", ")", "ParseTapCommands", "(", ")", "(", "TapConnect", ",", "error", ")", "{", "rv", ":=", "TapConnect", "{", "Flags", ":", "map", "[", "TapConnectFlag", "]", "interface", "{", "}", "{", "}", ",", "Name", ":", "st...
// Parse the tap request into the interesting bits we may need to do something with.
[ "Parse", "the", "tap", "request", "into", "the", "interesting", "bits", "we", "may", "need", "to", "do", "something", "with", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/tap.go#L129-L161
133,854
dustin/gomemcached
server/mc_conn_handler.go
FuncHandler
func FuncHandler(f func(io.Writer, *gomemcached.MCRequest) *gomemcached.MCResponse) RequestHandler { return funcHandler(f) }
go
func FuncHandler(f func(io.Writer, *gomemcached.MCRequest) *gomemcached.MCResponse) RequestHandler { return funcHandler(f) }
[ "func", "FuncHandler", "(", "f", "func", "(", "io", ".", "Writer", ",", "*", "gomemcached", ".", "MCRequest", ")", "*", "gomemcached", ".", "MCResponse", ")", "RequestHandler", "{", "return", "funcHandler", "(", "f", ")", "\n", "}" ]
// Convert a request handler function as a RequestHandler.
[ "Convert", "a", "request", "handler", "function", "as", "a", "RequestHandler", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/server/mc_conn_handler.go#L29-L31
133,855
dustin/gomemcached
server/mc_conn_handler.go
HandleIO
func HandleIO(s io.ReadWriteCloser, handler RequestHandler) error { defer func() { must(s.Close()) }() var err error for err == nil { err = HandleMessage(s, s, handler) } return err }
go
func HandleIO(s io.ReadWriteCloser, handler RequestHandler) error { defer func() { must(s.Close()) }() var err error for err == nil { err = HandleMessage(s, s, handler) } return err }
[ "func", "HandleIO", "(", "s", "io", ".", "ReadWriteCloser", ",", "handler", "RequestHandler", ")", "error", "{", "defer", "func", "(", ")", "{", "must", "(", "s", ".", "Close", "(", ")", ")", "}", "(", ")", "\n", "var", "err", "error", "\n", "for",...
// Handle until the handler returns a fatal message or a read or write // on the socket fails.
[ "Handle", "until", "the", "handler", "returns", "a", "fatal", "message", "or", "a", "read", "or", "write", "on", "the", "socket", "fails", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/server/mc_conn_handler.go#L41-L48
133,856
dustin/gomemcached
server/mc_conn_handler.go
HandleMessage
func HandleMessage(r io.Reader, w io.Writer, handler RequestHandler) error { req, err := ReadPacket(r) if err != nil { return err } res := handler.HandleMessage(w, &req) if res == nil { // Quiet command return nil } if !res.Fatal { res.Opcode = req.Opcode res.Opaque = req.Opaque _, err = res.Transm...
go
func HandleMessage(r io.Reader, w io.Writer, handler RequestHandler) error { req, err := ReadPacket(r) if err != nil { return err } res := handler.HandleMessage(w, &req) if res == nil { // Quiet command return nil } if !res.Fatal { res.Opcode = req.Opcode res.Opaque = req.Opaque _, err = res.Transm...
[ "func", "HandleMessage", "(", "r", "io", ".", "Reader", ",", "w", "io", ".", "Writer", ",", "handler", "RequestHandler", ")", "error", "{", "req", ",", "err", ":=", "ReadPacket", "(", "r", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", ...
// Handle an individual message.
[ "Handle", "an", "individual", "message", "." ]
a2284a01c143e355985d192edf3b62a053747c70
https://github.com/dustin/gomemcached/blob/a2284a01c143e355985d192edf3b62a053747c70/server/mc_conn_handler.go#L51-L74
133,857
Rican7/retry
retry.go
Retry
func Retry(action Action, strategies ...strategy.Strategy) error { var err error for attempt := uint(0); (0 == attempt || nil != err) && shouldAttempt(attempt, strategies...); attempt++ { err = action(attempt) } return err }
go
func Retry(action Action, strategies ...strategy.Strategy) error { var err error for attempt := uint(0); (0 == attempt || nil != err) && shouldAttempt(attempt, strategies...); attempt++ { err = action(attempt) } return err }
[ "func", "Retry", "(", "action", "Action", ",", "strategies", "...", "strategy", ".", "Strategy", ")", "error", "{", "var", "err", "error", "\n\n", "for", "attempt", ":=", "uint", "(", "0", ")", ";", "(", "0", "==", "attempt", "||", "nil", "!=", "err"...
// Retry takes an action and performs it, repetitively, until successful. // // Optionally, strategies may be passed that assess whether or not an attempt // should be made.
[ "Retry", "takes", "an", "action", "and", "performs", "it", "repetitively", "until", "successful", ".", "Optionally", "strategies", "may", "be", "passed", "that", "assess", "whether", "or", "not", "an", "attempt", "should", "be", "made", "." ]
272ad122d6e5ce1be757544007cf8bcd1c9c9ab0
https://github.com/Rican7/retry/blob/272ad122d6e5ce1be757544007cf8bcd1c9c9ab0/retry.go#L16-L24
133,858
Rican7/retry
retry.go
shouldAttempt
func shouldAttempt(attempt uint, strategies ...strategy.Strategy) bool { shouldAttempt := true for i := 0; shouldAttempt && i < len(strategies); i++ { shouldAttempt = shouldAttempt && strategies[i](attempt) } return shouldAttempt }
go
func shouldAttempt(attempt uint, strategies ...strategy.Strategy) bool { shouldAttempt := true for i := 0; shouldAttempt && i < len(strategies); i++ { shouldAttempt = shouldAttempt && strategies[i](attempt) } return shouldAttempt }
[ "func", "shouldAttempt", "(", "attempt", "uint", ",", "strategies", "...", "strategy", ".", "Strategy", ")", "bool", "{", "shouldAttempt", ":=", "true", "\n\n", "for", "i", ":=", "0", ";", "shouldAttempt", "&&", "i", "<", "len", "(", "strategies", ")", "...
// shouldAttempt evaluates the provided strategies with the given attempt to // determine if the Retry loop should make another attempt.
[ "shouldAttempt", "evaluates", "the", "provided", "strategies", "with", "the", "given", "attempt", "to", "determine", "if", "the", "Retry", "loop", "should", "make", "another", "attempt", "." ]
272ad122d6e5ce1be757544007cf8bcd1c9c9ab0
https://github.com/Rican7/retry/blob/272ad122d6e5ce1be757544007cf8bcd1c9c9ab0/retry.go#L28-L36
133,859
Rican7/retry
backoff/backoff.go
Incremental
func Incremental(initial, increment time.Duration) Algorithm { return func(attempt uint) time.Duration { return initial + (increment * time.Duration(attempt)) } }
go
func Incremental(initial, increment time.Duration) Algorithm { return func(attempt uint) time.Duration { return initial + (increment * time.Duration(attempt)) } }
[ "func", "Incremental", "(", "initial", ",", "increment", "time", ".", "Duration", ")", "Algorithm", "{", "return", "func", "(", "attempt", "uint", ")", "time", ".", "Duration", "{", "return", "initial", "+", "(", "increment", "*", "time", ".", "Duration", ...
// Incremental creates a Algorithm that increments the initial duration // by the given increment for each attempt.
[ "Incremental", "creates", "a", "Algorithm", "that", "increments", "the", "initial", "duration", "by", "the", "given", "increment", "for", "each", "attempt", "." ]
272ad122d6e5ce1be757544007cf8bcd1c9c9ab0
https://github.com/Rican7/retry/blob/272ad122d6e5ce1be757544007cf8bcd1c9c9ab0/backoff/backoff.go#L18-L22
133,860
Rican7/retry
backoff/backoff.go
Linear
func Linear(factor time.Duration) Algorithm { return func(attempt uint) time.Duration { return (factor * time.Duration(attempt)) } }
go
func Linear(factor time.Duration) Algorithm { return func(attempt uint) time.Duration { return (factor * time.Duration(attempt)) } }
[ "func", "Linear", "(", "factor", "time", ".", "Duration", ")", "Algorithm", "{", "return", "func", "(", "attempt", "uint", ")", "time", ".", "Duration", "{", "return", "(", "factor", "*", "time", ".", "Duration", "(", "attempt", ")", ")", "\n", "}", ...
// Linear creates a Algorithm that linearly multiplies the factor // duration by the attempt number for each attempt.
[ "Linear", "creates", "a", "Algorithm", "that", "linearly", "multiplies", "the", "factor", "duration", "by", "the", "attempt", "number", "for", "each", "attempt", "." ]
272ad122d6e5ce1be757544007cf8bcd1c9c9ab0
https://github.com/Rican7/retry/blob/272ad122d6e5ce1be757544007cf8bcd1c9c9ab0/backoff/backoff.go#L26-L30
133,861
Rican7/retry
backoff/backoff.go
Exponential
func Exponential(factor time.Duration, base float64) Algorithm { return func(attempt uint) time.Duration { return (factor * time.Duration(math.Pow(base, float64(attempt)))) } }
go
func Exponential(factor time.Duration, base float64) Algorithm { return func(attempt uint) time.Duration { return (factor * time.Duration(math.Pow(base, float64(attempt)))) } }
[ "func", "Exponential", "(", "factor", "time", ".", "Duration", ",", "base", "float64", ")", "Algorithm", "{", "return", "func", "(", "attempt", "uint", ")", "time", ".", "Duration", "{", "return", "(", "factor", "*", "time", ".", "Duration", "(", "math",...
// Exponential creates a Algorithm that multiplies the factor duration by // an exponentially increasing factor for each attempt, where the factor is // calculated as the given base raised to the attempt number.
[ "Exponential", "creates", "a", "Algorithm", "that", "multiplies", "the", "factor", "duration", "by", "an", "exponentially", "increasing", "factor", "for", "each", "attempt", "where", "the", "factor", "is", "calculated", "as", "the", "given", "base", "raised", "t...
272ad122d6e5ce1be757544007cf8bcd1c9c9ab0
https://github.com/Rican7/retry/blob/272ad122d6e5ce1be757544007cf8bcd1c9c9ab0/backoff/backoff.go#L35-L39
133,862
Rican7/retry
backoff/backoff.go
Fibonacci
func Fibonacci(factor time.Duration) Algorithm { return func(attempt uint) time.Duration { return (factor * time.Duration(fibonacciNumber(attempt))) } }
go
func Fibonacci(factor time.Duration) Algorithm { return func(attempt uint) time.Duration { return (factor * time.Duration(fibonacciNumber(attempt))) } }
[ "func", "Fibonacci", "(", "factor", "time", ".", "Duration", ")", "Algorithm", "{", "return", "func", "(", "attempt", "uint", ")", "time", ".", "Duration", "{", "return", "(", "factor", "*", "time", ".", "Duration", "(", "fibonacciNumber", "(", "attempt", ...
// Fibonacci creates a Algorithm that multiplies the factor duration by // an increasing factor for each attempt, where the factor is the Nth number in // the Fibonacci sequence.
[ "Fibonacci", "creates", "a", "Algorithm", "that", "multiplies", "the", "factor", "duration", "by", "an", "increasing", "factor", "for", "each", "attempt", "where", "the", "factor", "is", "the", "Nth", "number", "in", "the", "Fibonacci", "sequence", "." ]
272ad122d6e5ce1be757544007cf8bcd1c9c9ab0
https://github.com/Rican7/retry/blob/272ad122d6e5ce1be757544007cf8bcd1c9c9ab0/backoff/backoff.go#L51-L55
133,863
Rican7/retry
backoff/backoff.go
fibonacciNumber
func fibonacciNumber(n uint) uint { if 0 == n { return 0 } else if 1 == n { return 1 } else { return fibonacciNumber(n-1) + fibonacciNumber(n-2) } }
go
func fibonacciNumber(n uint) uint { if 0 == n { return 0 } else if 1 == n { return 1 } else { return fibonacciNumber(n-1) + fibonacciNumber(n-2) } }
[ "func", "fibonacciNumber", "(", "n", "uint", ")", "uint", "{", "if", "0", "==", "n", "{", "return", "0", "\n", "}", "else", "if", "1", "==", "n", "{", "return", "1", "\n", "}", "else", "{", "return", "fibonacciNumber", "(", "n", "-", "1", ")", ...
// fibonacciNumber calculates the Fibonacci sequence number for the given // sequence position.
[ "fibonacciNumber", "calculates", "the", "Fibonacci", "sequence", "number", "for", "the", "given", "sequence", "position", "." ]
272ad122d6e5ce1be757544007cf8bcd1c9c9ab0
https://github.com/Rican7/retry/blob/272ad122d6e5ce1be757544007cf8bcd1c9c9ab0/backoff/backoff.go#L59-L67
133,864
Rican7/retry
jitter/jitter.go
NormalDistribution
func NormalDistribution(generator *rand.Rand, standardDeviation float64) Transformation { random := fallbackNewRandom(generator) return func(duration time.Duration) time.Duration { return time.Duration(random.NormFloat64()*standardDeviation + float64(duration)) } }
go
func NormalDistribution(generator *rand.Rand, standardDeviation float64) Transformation { random := fallbackNewRandom(generator) return func(duration time.Duration) time.Duration { return time.Duration(random.NormFloat64()*standardDeviation + float64(duration)) } }
[ "func", "NormalDistribution", "(", "generator", "*", "rand", ".", "Rand", ",", "standardDeviation", "float64", ")", "Transformation", "{", "random", ":=", "fallbackNewRandom", "(", "generator", ")", "\n\n", "return", "func", "(", "duration", "time", ".", "Durati...
// NormalDistribution creates a Transformation that transforms a duration into a // result duration based on a normal distribution of the input and the given // standard deviation. // // The given generator is what is used to determine the random transformation. // If a nil generator is passed, a default one will be pr...
[ "NormalDistribution", "creates", "a", "Transformation", "that", "transforms", "a", "duration", "into", "a", "result", "duration", "based", "on", "a", "normal", "distribution", "of", "the", "input", "and", "the", "given", "standard", "deviation", ".", "The", "giv...
272ad122d6e5ce1be757544007cf8bcd1c9c9ab0
https://github.com/Rican7/retry/blob/272ad122d6e5ce1be757544007cf8bcd1c9c9ab0/jitter/jitter.go#L70-L76
133,865
Rican7/retry
jitter/jitter.go
fallbackNewRandom
func fallbackNewRandom(random *rand.Rand) *rand.Rand { // Return the passed in value if it's already not null if nil != random { return random } seed := time.Now().UnixNano() return rand.New(rand.NewSource(seed)) }
go
func fallbackNewRandom(random *rand.Rand) *rand.Rand { // Return the passed in value if it's already not null if nil != random { return random } seed := time.Now().UnixNano() return rand.New(rand.NewSource(seed)) }
[ "func", "fallbackNewRandom", "(", "random", "*", "rand", ".", "Rand", ")", "*", "rand", ".", "Rand", "{", "// Return the passed in value if it's already not null", "if", "nil", "!=", "random", "{", "return", "random", "\n", "}", "\n\n", "seed", ":=", "time", "...
// fallbackNewRandom returns the passed in random instance if it's not nil, // and otherwise returns a new random instance seeded with the current time.
[ "fallbackNewRandom", "returns", "the", "passed", "in", "random", "instance", "if", "it", "s", "not", "nil", "and", "otherwise", "returns", "a", "new", "random", "instance", "seeded", "with", "the", "current", "time", "." ]
272ad122d6e5ce1be757544007cf8bcd1c9c9ab0
https://github.com/Rican7/retry/blob/272ad122d6e5ce1be757544007cf8bcd1c9c9ab0/jitter/jitter.go#L80-L89
133,866
Rican7/retry
strategy/strategy.go
Delay
func Delay(duration time.Duration) Strategy { return func(attempt uint) bool { if 0 == attempt { time.Sleep(duration) } return true } }
go
func Delay(duration time.Duration) Strategy { return func(attempt uint) bool { if 0 == attempt { time.Sleep(duration) } return true } }
[ "func", "Delay", "(", "duration", "time", ".", "Duration", ")", "Strategy", "{", "return", "func", "(", "attempt", "uint", ")", "bool", "{", "if", "0", "==", "attempt", "{", "time", ".", "Sleep", "(", "duration", ")", "\n", "}", "\n\n", "return", "tr...
// Delay creates a Strategy that waits the given duration before the first // attempt is made.
[ "Delay", "creates", "a", "Strategy", "that", "waits", "the", "given", "duration", "before", "the", "first", "attempt", "is", "made", "." ]
272ad122d6e5ce1be757544007cf8bcd1c9c9ab0
https://github.com/Rican7/retry/blob/272ad122d6e5ce1be757544007cf8bcd1c9c9ab0/strategy/strategy.go#L33-L41
133,867
Rican7/retry
strategy/strategy.go
Wait
func Wait(durations ...time.Duration) Strategy { return func(attempt uint) bool { if 0 < attempt && 0 < len(durations) { durationIndex := int(attempt - 1) if len(durations) <= durationIndex { durationIndex = len(durations) - 1 } time.Sleep(durations[durationIndex]) } return true } }
go
func Wait(durations ...time.Duration) Strategy { return func(attempt uint) bool { if 0 < attempt && 0 < len(durations) { durationIndex := int(attempt - 1) if len(durations) <= durationIndex { durationIndex = len(durations) - 1 } time.Sleep(durations[durationIndex]) } return true } }
[ "func", "Wait", "(", "durations", "...", "time", ".", "Duration", ")", "Strategy", "{", "return", "func", "(", "attempt", "uint", ")", "bool", "{", "if", "0", "<", "attempt", "&&", "0", "<", "len", "(", "durations", ")", "{", "durationIndex", ":=", "...
// Wait creates a Strategy that waits the given durations for each attempt after // the first. If the number of attempts is greater than the number of durations // provided, then the strategy uses the last duration provided.
[ "Wait", "creates", "a", "Strategy", "that", "waits", "the", "given", "durations", "for", "each", "attempt", "after", "the", "first", ".", "If", "the", "number", "of", "attempts", "is", "greater", "than", "the", "number", "of", "durations", "provided", "then"...
272ad122d6e5ce1be757544007cf8bcd1c9c9ab0
https://github.com/Rican7/retry/blob/272ad122d6e5ce1be757544007cf8bcd1c9c9ab0/strategy/strategy.go#L46-L60
133,868
Rican7/retry
strategy/strategy.go
BackoffWithJitter
func BackoffWithJitter(algorithm backoff.Algorithm, transformation jitter.Transformation) Strategy { return func(attempt uint) bool { if 0 < attempt { time.Sleep(transformation(algorithm(attempt))) } return true } }
go
func BackoffWithJitter(algorithm backoff.Algorithm, transformation jitter.Transformation) Strategy { return func(attempt uint) bool { if 0 < attempt { time.Sleep(transformation(algorithm(attempt))) } return true } }
[ "func", "BackoffWithJitter", "(", "algorithm", "backoff", ".", "Algorithm", ",", "transformation", "jitter", ".", "Transformation", ")", "Strategy", "{", "return", "func", "(", "attempt", "uint", ")", "bool", "{", "if", "0", "<", "attempt", "{", "time", ".",...
// BackoffWithJitter creates a Strategy that waits before each attempt, with a // duration as defined by the given backoff.Algorithm and jitter.Transformation.
[ "BackoffWithJitter", "creates", "a", "Strategy", "that", "waits", "before", "each", "attempt", "with", "a", "duration", "as", "defined", "by", "the", "given", "backoff", ".", "Algorithm", "and", "jitter", ".", "Transformation", "." ]
272ad122d6e5ce1be757544007cf8bcd1c9c9ab0
https://github.com/Rican7/retry/blob/272ad122d6e5ce1be757544007cf8bcd1c9c9ab0/strategy/strategy.go#L70-L78
133,869
bndr/gopencils
api.go
Api
func Api(baseUrl string, options ...interface{}) *Resource { u, err := url.Parse(baseUrl) if err != nil { // TODO: don't panic.. panic("Api() - url.Parse(baseUrl) Error:" + err.Error()) } apiInstance := &ApiStruct{BaseUrl: u, BasicAuth: nil} for _, o := range options { switch v := o.(type) { case *BasicA...
go
func Api(baseUrl string, options ...interface{}) *Resource { u, err := url.Parse(baseUrl) if err != nil { // TODO: don't panic.. panic("Api() - url.Parse(baseUrl) Error:" + err.Error()) } apiInstance := &ApiStruct{BaseUrl: u, BasicAuth: nil} for _, o := range options { switch v := o.(type) { case *BasicA...
[ "func", "Api", "(", "baseUrl", "string", ",", "options", "...", "interface", "{", "}", ")", "*", "Resource", "{", "u", ",", "err", ":=", "url", ".", "Parse", "(", "baseUrl", ")", "\n", "if", "err", "!=", "nil", "{", "// TODO: don't panic..", "panic", ...
// Create a new API Instance and returns a Resource // Accepts URL as parameter, and either a Basic Auth or a OAuth2 Client.
[ "Create", "a", "new", "API", "Instance", "and", "returns", "a", "Resource", "Accepts", "URL", "as", "parameter", "and", "either", "a", "Basic", "Auth", "or", "a", "OAuth2", "Client", "." ]
22e283ad76118c1e1f3812b4a3553809cd434e6a
https://github.com/bndr/gopencils/blob/22e283ad76118c1e1f3812b4a3553809cd434e6a/api.go#L42-L77
133,870
bndr/gopencils
resource.go
Res
func (r *Resource) Res(options ...interface{}) *Resource { if len(options) > 0 { var url string if len(r.Url) > 0 { url = r.Url + "/" + options[0].(string) } else { url = options[0].(string) } header := r.Headers if header == nil { header = http.Header{} } newR := &Resource{Url: url, Api: r.A...
go
func (r *Resource) Res(options ...interface{}) *Resource { if len(options) > 0 { var url string if len(r.Url) > 0 { url = r.Url + "/" + options[0].(string) } else { url = options[0].(string) } header := r.Headers if header == nil { header = http.Header{} } newR := &Resource{Url: url, Api: r.A...
[ "func", "(", "r", "*", "Resource", ")", "Res", "(", "options", "...", "interface", "{", "}", ")", "*", "Resource", "{", "if", "len", "(", "options", ")", ">", "0", "{", "var", "url", "string", "\n", "if", "len", "(", "r", ".", "Url", ")", ">", ...
// Creates a new Resource.
[ "Creates", "a", "new", "Resource", "." ]
22e283ad76118c1e1f3812b4a3553809cd434e6a
https://github.com/bndr/gopencils/blob/22e283ad76118c1e1f3812b4a3553809cd434e6a/resource.go#L43-L65
133,871
bndr/gopencils
resource.go
SetQuery
func (r *Resource) SetQuery(querystring map[string]string) *Resource { r.QueryValues = make(url.Values) for k, v := range querystring { r.QueryValues.Set(k, v) } return r }
go
func (r *Resource) SetQuery(querystring map[string]string) *Resource { r.QueryValues = make(url.Values) for k, v := range querystring { r.QueryValues.Set(k, v) } return r }
[ "func", "(", "r", "*", "Resource", ")", "SetQuery", "(", "querystring", "map", "[", "string", "]", "string", ")", "*", "Resource", "{", "r", ".", "QueryValues", "=", "make", "(", "url", ".", "Values", ")", "\n", "for", "k", ",", "v", ":=", "range",...
// Sets QueryValues for current Resource
[ "Sets", "QueryValues", "for", "current", "Resource" ]
22e283ad76118c1e1f3812b4a3553809cd434e6a
https://github.com/bndr/gopencils/blob/22e283ad76118c1e1f3812b4a3553809cd434e6a/resource.go#L95-L101
133,872
bndr/gopencils
resource.go
do
func (r *Resource) do(method string) (*Resource, error) { url := *r.Api.BaseUrl if len(url.Path) > 0 { url.Path += "/" + r.Url } else { url.Path = r.Url } if r.Api.PathSuffix != "" { url.Path += r.Api.PathSuffix } url.RawQuery = r.QueryValues.Encode() req, err := http.NewRequest(method, url.String(), r.P...
go
func (r *Resource) do(method string) (*Resource, error) { url := *r.Api.BaseUrl if len(url.Path) > 0 { url.Path += "/" + r.Url } else { url.Path = r.Url } if r.Api.PathSuffix != "" { url.Path += r.Api.PathSuffix } url.RawQuery = r.QueryValues.Encode() req, err := http.NewRequest(method, url.String(), r.P...
[ "func", "(", "r", "*", "Resource", ")", "do", "(", "method", "string", ")", "(", "*", "Resource", ",", "error", ")", "{", "url", ":=", "*", "r", ".", "Api", ".", "BaseUrl", "\n", "if", "len", "(", "url", ".", "Path", ")", ">", "0", "{", "url"...
// Main method, opens the connection, sets basic auth, applies headers, // parses response json.
[ "Main", "method", "opens", "the", "connection", "sets", "basic", "auth", "applies", "headers", "parses", "response", "json", "." ]
22e283ad76118c1e1f3812b4a3553809cd434e6a
https://github.com/bndr/gopencils/blob/22e283ad76118c1e1f3812b4a3553809cd434e6a/resource.go#L185-L235
133,873
bndr/gopencils
resource.go
SetPayload
func (r *Resource) SetPayload(args interface{}) io.Reader { var b []byte b, _ = json.Marshal(args) r.SetHeader("Content-Type", "application/json") return bytes.NewBuffer(b) }
go
func (r *Resource) SetPayload(args interface{}) io.Reader { var b []byte b, _ = json.Marshal(args) r.SetHeader("Content-Type", "application/json") return bytes.NewBuffer(b) }
[ "func", "(", "r", "*", "Resource", ")", "SetPayload", "(", "args", "interface", "{", "}", ")", "io", ".", "Reader", "{", "var", "b", "[", "]", "byte", "\n", "b", ",", "_", "=", "json", ".", "Marshal", "(", "args", ")", "\n", "r", ".", "SetHeade...
// Sets Payload for current Resource
[ "Sets", "Payload", "for", "current", "Resource" ]
22e283ad76118c1e1f3812b4a3553809cd434e6a
https://github.com/bndr/gopencils/blob/22e283ad76118c1e1f3812b4a3553809cd434e6a/resource.go#L238-L243
133,874
bndr/gopencils
resource.go
SetClient
func (r *Resource) SetClient(c *http.Client) { r.Api.Client = c }
go
func (r *Resource) SetClient(c *http.Client) { r.Api.Client = c }
[ "func", "(", "r", "*", "Resource", ")", "SetClient", "(", "c", "*", "http", ".", "Client", ")", "{", "r", ".", "Api", ".", "Client", "=", "c", "\n", "}" ]
// Overwrites the client that will be used for requests. // For example if you want to use your own client with OAuth2
[ "Overwrites", "the", "client", "that", "will", "be", "used", "for", "requests", ".", "For", "example", "if", "you", "want", "to", "use", "your", "own", "client", "with", "OAuth2" ]
22e283ad76118c1e1f3812b4a3553809cd434e6a
https://github.com/bndr/gopencils/blob/22e283ad76118c1e1f3812b4a3553809cd434e6a/resource.go#L252-L254
133,875
bndr/gopencils
examples/example_oauth.go
landing
func landing(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, config.AuthCodeURL("foo"), http.StatusFound) }
go
func landing(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, config.AuthCodeURL("foo"), http.StatusFound) }
[ "func", "landing", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "http", ".", "Redirect", "(", "w", ",", "r", ",", "config", ".", "AuthCodeURL", "(", "\"", "\"", ")", ",", "http", ".", "StatusFound", ")",...
// A landing page redirects to the OAuth provider to get the auth code.
[ "A", "landing", "page", "redirects", "to", "the", "OAuth", "provider", "to", "get", "the", "auth", "code", "." ]
22e283ad76118c1e1f3812b4a3553809cd434e6a
https://github.com/bndr/gopencils/blob/22e283ad76118c1e1f3812b4a3553809cd434e6a/examples/example_oauth.go#L31-L33
133,876
bndr/gopencils
examples/example_oauth.go
handler
func handler(w http.ResponseWriter, r *http.Request) { t := &oauth2.Transport{Config: config} t.Exchange(r.FormValue("code")) // The Transport now has a valid Token. Create an *http.Client // with which we can make authenticated API requests. c := t.Client() // Now you can pass the authenticated Client to gopenc...
go
func handler(w http.ResponseWriter, r *http.Request) { t := &oauth2.Transport{Config: config} t.Exchange(r.FormValue("code")) // The Transport now has a valid Token. Create an *http.Client // with which we can make authenticated API requests. c := t.Client() // Now you can pass the authenticated Client to gopenc...
[ "func", "handler", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "t", ":=", "&", "oauth2", ".", "Transport", "{", "Config", ":", "config", "}", "\n", "t", ".", "Exchange", "(", "r", ".", "FormValue", "(",...
// The user will be redirected back to this handler, that takes the // "code" query parameter and Exchanges it for an access token.
[ "The", "user", "will", "be", "redirected", "back", "to", "this", "handler", "that", "takes", "the", "code", "query", "parameter", "and", "Exchanges", "it", "for", "an", "access", "token", "." ]
22e283ad76118c1e1f3812b4a3553809cd434e6a
https://github.com/bndr/gopencils/blob/22e283ad76118c1e1f3812b4a3553809cd434e6a/examples/example_oauth.go#L37-L65
133,877
gmallard/stompngo
senv/senv.go
Login
func Login() string { // Login l := os.Getenv("STOMP_LOGIN") if l != "" { login = l } if l == "NONE" { login = "" } return login }
go
func Login() string { // Login l := os.Getenv("STOMP_LOGIN") if l != "" { login = l } if l == "NONE" { login = "" } return login }
[ "func", "Login", "(", ")", "string", "{", "// Login", "l", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "l", "!=", "\"", "\"", "{", "login", "=", "l", "\n", "}", "\n", "if", "l", "==", "\"", "\"", "{", "login", "=", "\"", "\...
// Login returns a default login ID.
[ "Login", "returns", "a", "default", "login", "ID", "." ]
b61c67049c28a4361e7b2cb69200d9d137411822
https://github.com/gmallard/stompngo/blob/b61c67049c28a4361e7b2cb69200d9d137411822/senv/senv.go#L85-L95
133,878
gmallard/stompngo
senv/senv.go
Nmsgs
func Nmsgs() int { // Number of messages nmLock.Lock() defer nmLock.Unlock() ns := os.Getenv("STOMP_NMSGS") if ns == "" { return nmsgs } n, e := strconv.ParseInt(ns, 10, 0) if e != nil { log.Printf("NMSGS Conversion error: %v\n", e) return nmsgs } nmsgs = int(n) return nmsgs }
go
func Nmsgs() int { // Number of messages nmLock.Lock() defer nmLock.Unlock() ns := os.Getenv("STOMP_NMSGS") if ns == "" { return nmsgs } n, e := strconv.ParseInt(ns, 10, 0) if e != nil { log.Printf("NMSGS Conversion error: %v\n", e) return nmsgs } nmsgs = int(n) return nmsgs }
[ "func", "Nmsgs", "(", ")", "int", "{", "// Number of messages", "nmLock", ".", "Lock", "(", ")", "\n", "defer", "nmLock", ".", "Unlock", "(", ")", "\n", "ns", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "ns", "==", "\"", "\"", "{...
// Number of messages
[ "Number", "of", "messages" ]
b61c67049c28a4361e7b2cb69200d9d137411822
https://github.com/gmallard/stompngo/blob/b61c67049c28a4361e7b2cb69200d9d137411822/senv/senv.go#L98-L113
133,879
gmallard/stompngo
senv/senv.go
Passcode
func Passcode() string { // Passcode pc := os.Getenv("STOMP_PASSCODE") if pc != "" { passcode = pc } if pc == "NONE" { passcode = "" } return passcode }
go
func Passcode() string { // Passcode pc := os.Getenv("STOMP_PASSCODE") if pc != "" { passcode = pc } if pc == "NONE" { passcode = "" } return passcode }
[ "func", "Passcode", "(", ")", "string", "{", "// Passcode", "pc", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "pc", "!=", "\"", "\"", "{", "passcode", "=", "pc", "\n", "}", "\n", "if", "pc", "==", "\"", "\"", "{", "passcode", "...
// Passcode returns a default passcode.
[ "Passcode", "returns", "a", "default", "passcode", "." ]
b61c67049c28a4361e7b2cb69200d9d137411822
https://github.com/gmallard/stompngo/blob/b61c67049c28a4361e7b2cb69200d9d137411822/senv/senv.go#L116-L126
133,880
gmallard/stompngo
senv/senv.go
Vhost
func Vhost() string { // Vhost vhLock.Lock() defer vhLock.Unlock() vh := os.Getenv("STOMP_VHOST") if vh != "" { vhost = vh } else { vhost = Host() } return vhost }
go
func Vhost() string { // Vhost vhLock.Lock() defer vhLock.Unlock() vh := os.Getenv("STOMP_VHOST") if vh != "" { vhost = vh } else { vhost = Host() } return vhost }
[ "func", "Vhost", "(", ")", "string", "{", "// Vhost", "vhLock", ".", "Lock", "(", ")", "\n", "defer", "vhLock", ".", "Unlock", "(", ")", "\n", "vh", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "vh", "!=", "\"", "\"", "{", "vhos...
// Vhost returns a default vhost name.
[ "Vhost", "returns", "a", "default", "vhost", "name", "." ]
b61c67049c28a4361e7b2cb69200d9d137411822
https://github.com/gmallard/stompngo/blob/b61c67049c28a4361e7b2cb69200d9d137411822/senv/senv.go#L170-L181
133,881
toorop/go-bittrex
ws.go
SubscribeExchangeUpdate
func (b *Bittrex) SubscribeExchangeUpdate(market string, dataCh chan<- ExchangeState, stop <-chan bool) error { const timeout = 5 * time.Second client := signalr.NewWebsocketClient() client.OnClientMethod = func(hub string, method string, messages []json.RawMessage) { if hub != WS_HUB || method != "updateExchangeS...
go
func (b *Bittrex) SubscribeExchangeUpdate(market string, dataCh chan<- ExchangeState, stop <-chan bool) error { const timeout = 5 * time.Second client := signalr.NewWebsocketClient() client.OnClientMethod = func(hub string, method string, messages []json.RawMessage) { if hub != WS_HUB || method != "updateExchangeS...
[ "func", "(", "b", "*", "Bittrex", ")", "SubscribeExchangeUpdate", "(", "market", "string", ",", "dataCh", "chan", "<-", "ExchangeState", ",", "stop", "<-", "chan", "bool", ")", "error", "{", "const", "timeout", "=", "5", "*", "time", ".", "Second", "\n",...
// SubscribeExchangeUpdate subscribes for updates of the market. // Updates will be sent to dataCh. // To stop subscription, send to, or close 'stop'.
[ "SubscribeExchangeUpdate", "subscribes", "for", "updates", "of", "the", "market", ".", "Updates", "will", "be", "sent", "to", "dataCh", ".", "To", "stop", "subscription", "send", "to", "or", "close", "stop", "." ]
b4a20c2db009afea9ceca5d1592e34618ce3b324
https://github.com/toorop/go-bittrex/blob/b4a20c2db009afea9ceca5d1592e34618ce3b324/ws.go#L86-L127
133,882
toorop/go-bittrex
client.go
NewClientWithCustomHttpConfig
func NewClientWithCustomHttpConfig(apiKey, apiSecret string, httpClient *http.Client) (c *client) { timeout := httpClient.Timeout if timeout <= 0 { timeout = 30 * time.Second } return &client{apiKey, apiSecret, httpClient, timeout, false} }
go
func NewClientWithCustomHttpConfig(apiKey, apiSecret string, httpClient *http.Client) (c *client) { timeout := httpClient.Timeout if timeout <= 0 { timeout = 30 * time.Second } return &client{apiKey, apiSecret, httpClient, timeout, false} }
[ "func", "NewClientWithCustomHttpConfig", "(", "apiKey", ",", "apiSecret", "string", ",", "httpClient", "*", "http", ".", "Client", ")", "(", "c", "*", "client", ")", "{", "timeout", ":=", "httpClient", ".", "Timeout", "\n", "if", "timeout", "<=", "0", "{",...
// NewClientWithCustomHttpConfig returns a new Bittrex HTTP client using the predefined http client
[ "NewClientWithCustomHttpConfig", "returns", "a", "new", "Bittrex", "HTTP", "client", "using", "the", "predefined", "http", "client" ]
b4a20c2db009afea9ceca5d1592e34618ce3b324
https://github.com/toorop/go-bittrex/blob/b4a20c2db009afea9ceca5d1592e34618ce3b324/client.go#L31-L37
133,883
toorop/go-bittrex
client.go
doTimeoutRequest
func (c *client) doTimeoutRequest(timer *time.Timer, req *http.Request) (*http.Response, error) { // Do the request in the background so we can check the timeout type result struct { resp *http.Response err error } done := make(chan result, 1) go func() { if c.debug { c.dumpRequest(req) } resp, err :...
go
func (c *client) doTimeoutRequest(timer *time.Timer, req *http.Request) (*http.Response, error) { // Do the request in the background so we can check the timeout type result struct { resp *http.Response err error } done := make(chan result, 1) go func() { if c.debug { c.dumpRequest(req) } resp, err :...
[ "func", "(", "c", "*", "client", ")", "doTimeoutRequest", "(", "timer", "*", "time", ".", "Timer", ",", "req", "*", "http", ".", "Request", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "// Do the request in the background so we can check t...
// doTimeoutRequest do a HTTP request with timeout
[ "doTimeoutRequest", "do", "a", "HTTP", "request", "with", "timeout" ]
b4a20c2db009afea9ceca5d1592e34618ce3b324
https://github.com/toorop/go-bittrex/blob/b4a20c2db009afea9ceca5d1592e34618ce3b324/client.go#L71-L95
133,884
toorop/go-bittrex
client.go
do
func (c *client) do(method string, resource string, payload string, authNeeded bool) (response []byte, err error) { connectTimer := time.NewTimer(c.httpTimeout) var rawurl string if strings.HasPrefix(resource, "http") { rawurl = resource } else { rawurl = fmt.Sprintf("%s%s/%s", API_BASE, API_VERSION, resource)...
go
func (c *client) do(method string, resource string, payload string, authNeeded bool) (response []byte, err error) { connectTimer := time.NewTimer(c.httpTimeout) var rawurl string if strings.HasPrefix(resource, "http") { rawurl = resource } else { rawurl = fmt.Sprintf("%s%s/%s", API_BASE, API_VERSION, resource)...
[ "func", "(", "c", "*", "client", ")", "do", "(", "method", "string", ",", "resource", "string", ",", "payload", "string", ",", "authNeeded", "bool", ")", "(", "response", "[", "]", "byte", ",", "err", "error", ")", "{", "connectTimer", ":=", "time", ...
// do prepare and process HTTP request to Bittrex API
[ "do", "prepare", "and", "process", "HTTP", "request", "to", "Bittrex", "API" ]
b4a20c2db009afea9ceca5d1592e34618ce3b324
https://github.com/toorop/go-bittrex/blob/b4a20c2db009afea9ceca5d1592e34618ce3b324/client.go#L98-L149
133,885
toorop/go-bittrex
bittrex.go
New
func New(apiKey, apiSecret string) *Bittrex { client := NewClient(apiKey, apiSecret) return &Bittrex{client} }
go
func New(apiKey, apiSecret string) *Bittrex { client := NewClient(apiKey, apiSecret) return &Bittrex{client} }
[ "func", "New", "(", "apiKey", ",", "apiSecret", "string", ")", "*", "Bittrex", "{", "client", ":=", "NewClient", "(", "apiKey", ",", "apiSecret", ")", "\n", "return", "&", "Bittrex", "{", "client", "}", "\n", "}" ]
// New returns an instantiated bittrex struct
[ "New", "returns", "an", "instantiated", "bittrex", "struct" ]
b4a20c2db009afea9ceca5d1592e34618ce3b324
https://github.com/toorop/go-bittrex/blob/b4a20c2db009afea9ceca5d1592e34618ce3b324/bittrex.go#L23-L26
133,886
toorop/go-bittrex
bittrex.go
NewWithCustomHttpClient
func NewWithCustomHttpClient(apiKey, apiSecret string, httpClient *http.Client) *Bittrex { client := NewClientWithCustomHttpConfig(apiKey, apiSecret, httpClient) return &Bittrex{client} }
go
func NewWithCustomHttpClient(apiKey, apiSecret string, httpClient *http.Client) *Bittrex { client := NewClientWithCustomHttpConfig(apiKey, apiSecret, httpClient) return &Bittrex{client} }
[ "func", "NewWithCustomHttpClient", "(", "apiKey", ",", "apiSecret", "string", ",", "httpClient", "*", "http", ".", "Client", ")", "*", "Bittrex", "{", "client", ":=", "NewClientWithCustomHttpConfig", "(", "apiKey", ",", "apiSecret", ",", "httpClient", ")", "\n",...
// NewWithCustomHttpClient returns an instantiated bittrex struct with custom http client
[ "NewWithCustomHttpClient", "returns", "an", "instantiated", "bittrex", "struct", "with", "custom", "http", "client" ]
b4a20c2db009afea9ceca5d1592e34618ce3b324
https://github.com/toorop/go-bittrex/blob/b4a20c2db009afea9ceca5d1592e34618ce3b324/bittrex.go#L29-L32
133,887
toorop/go-bittrex
bittrex.go
NewWithCustomTimeout
func NewWithCustomTimeout(apiKey, apiSecret string, timeout time.Duration) *Bittrex { client := NewClientWithCustomTimeout(apiKey, apiSecret, timeout) return &Bittrex{client} }
go
func NewWithCustomTimeout(apiKey, apiSecret string, timeout time.Duration) *Bittrex { client := NewClientWithCustomTimeout(apiKey, apiSecret, timeout) return &Bittrex{client} }
[ "func", "NewWithCustomTimeout", "(", "apiKey", ",", "apiSecret", "string", ",", "timeout", "time", ".", "Duration", ")", "*", "Bittrex", "{", "client", ":=", "NewClientWithCustomTimeout", "(", "apiKey", ",", "apiSecret", ",", "timeout", ")", "\n", "return", "&...
// NewWithCustomTimeout returns an instantiated bittrex struct with custom timeout
[ "NewWithCustomTimeout", "returns", "an", "instantiated", "bittrex", "struct", "with", "custom", "timeout" ]
b4a20c2db009afea9ceca5d1592e34618ce3b324
https://github.com/toorop/go-bittrex/blob/b4a20c2db009afea9ceca5d1592e34618ce3b324/bittrex.go#L35-L38
133,888
toorop/go-bittrex
bittrex.go
handleErr
func handleErr(r jsonResponse) error { if !r.Success { return errors.New(r.Message) } return nil }
go
func handleErr(r jsonResponse) error { if !r.Success { return errors.New(r.Message) } return nil }
[ "func", "handleErr", "(", "r", "jsonResponse", ")", "error", "{", "if", "!", "r", ".", "Success", "{", "return", "errors", ".", "New", "(", "r", ".", "Message", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// handleErr gets JSON response from Bittrex API en deal with error
[ "handleErr", "gets", "JSON", "response", "from", "Bittrex", "API", "en", "deal", "with", "error" ]
b4a20c2db009afea9ceca5d1592e34618ce3b324
https://github.com/toorop/go-bittrex/blob/b4a20c2db009afea9ceca5d1592e34618ce3b324/bittrex.go#L41-L46
133,889
toorop/go-bittrex
bittrex.go
GetDistribution
func (b *Bittrex) GetDistribution(market string) (distribution Distribution, err error) { r, err := b.client.do("GET", "https://bittrex.com/Api/v2.0/pub/currency/GetBalanceDistribution?currencyName="+strings.ToUpper(market), "", false) if err != nil { return } var response jsonResponse if err = json.Unmarshal(r...
go
func (b *Bittrex) GetDistribution(market string) (distribution Distribution, err error) { r, err := b.client.do("GET", "https://bittrex.com/Api/v2.0/pub/currency/GetBalanceDistribution?currencyName="+strings.ToUpper(market), "", false) if err != nil { return } var response jsonResponse if err = json.Unmarshal(r...
[ "func", "(", "b", "*", "Bittrex", ")", "GetDistribution", "(", "market", "string", ")", "(", "distribution", "Distribution", ",", "err", "error", ")", "{", "r", ",", "err", ":=", "b", ".", "client", ".", "do", "(", "\"", "\"", ",", "\"", "\"", "+",...
// GetDistribution is used to get the distribution.
[ "GetDistribution", "is", "used", "to", "get", "the", "distribution", "." ]
b4a20c2db009afea9ceca5d1592e34618ce3b324
https://github.com/toorop/go-bittrex/blob/b4a20c2db009afea9ceca5d1592e34618ce3b324/bittrex.go#L59-L76
133,890
toorop/go-bittrex
bittrex.go
GetCurrencies
func (b *Bittrex) GetCurrencies() (currencies []Currency, err error) { r, err := b.client.do("GET", "public/getcurrencies", "", false) if err != nil { return } var response jsonResponse if err = json.Unmarshal(r, &response); err != nil { return } if err = handleErr(response); err != nil { return } err = ...
go
func (b *Bittrex) GetCurrencies() (currencies []Currency, err error) { r, err := b.client.do("GET", "public/getcurrencies", "", false) if err != nil { return } var response jsonResponse if err = json.Unmarshal(r, &response); err != nil { return } if err = handleErr(response); err != nil { return } err = ...
[ "func", "(", "b", "*", "Bittrex", ")", "GetCurrencies", "(", ")", "(", "currencies", "[", "]", "Currency", ",", "err", "error", ")", "{", "r", ",", "err", ":=", "b", ".", "client", ".", "do", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ...
// GetCurrencies is used to get all supported currencies at Bittrex along with other meta data.
[ "GetCurrencies", "is", "used", "to", "get", "all", "supported", "currencies", "at", "Bittrex", "along", "with", "other", "meta", "data", "." ]
b4a20c2db009afea9ceca5d1592e34618ce3b324
https://github.com/toorop/go-bittrex/blob/b4a20c2db009afea9ceca5d1592e34618ce3b324/bittrex.go#L79-L93
133,891
toorop/go-bittrex
bittrex.go
GetMarkets
func (b *Bittrex) GetMarkets() (markets []Market, err error) { r, err := b.client.do("GET", "public/getmarkets", "", false) if err != nil { return } var response jsonResponse if err = json.Unmarshal(r, &response); err != nil { return } if err = handleErr(response); err != nil { return } err = json.Unmars...
go
func (b *Bittrex) GetMarkets() (markets []Market, err error) { r, err := b.client.do("GET", "public/getmarkets", "", false) if err != nil { return } var response jsonResponse if err = json.Unmarshal(r, &response); err != nil { return } if err = handleErr(response); err != nil { return } err = json.Unmars...
[ "func", "(", "b", "*", "Bittrex", ")", "GetMarkets", "(", ")", "(", "markets", "[", "]", "Market", ",", "err", "error", ")", "{", "r", ",", "err", ":=", "b", ".", "client", ".", "do", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", ...
// GetMarkets is used to get the open and available trading markets at Bittrex along with other meta data.
[ "GetMarkets", "is", "used", "to", "get", "the", "open", "and", "available", "trading", "markets", "at", "Bittrex", "along", "with", "other", "meta", "data", "." ]
b4a20c2db009afea9ceca5d1592e34618ce3b324
https://github.com/toorop/go-bittrex/blob/b4a20c2db009afea9ceca5d1592e34618ce3b324/bittrex.go#L96-L110
133,892
toorop/go-bittrex
bittrex.go
GetTicker
func (b *Bittrex) GetTicker(market string) (ticker Ticker, err error) { r, err := b.client.do("GET", "public/getticker?market="+strings.ToUpper(market), "", false) if err != nil { return } var response jsonResponse if err = json.Unmarshal(r, &response); err != nil { return } if err = handleErr(response); err...
go
func (b *Bittrex) GetTicker(market string) (ticker Ticker, err error) { r, err := b.client.do("GET", "public/getticker?market="+strings.ToUpper(market), "", false) if err != nil { return } var response jsonResponse if err = json.Unmarshal(r, &response); err != nil { return } if err = handleErr(response); err...
[ "func", "(", "b", "*", "Bittrex", ")", "GetTicker", "(", "market", "string", ")", "(", "ticker", "Ticker", ",", "err", "error", ")", "{", "r", ",", "err", ":=", "b", ".", "client", ".", "do", "(", "\"", "\"", ",", "\"", "\"", "+", "strings", "....
// GetTicker is used to get the current ticker values for a market.
[ "GetTicker", "is", "used", "to", "get", "the", "current", "ticker", "values", "for", "a", "market", "." ]
b4a20c2db009afea9ceca5d1592e34618ce3b324
https://github.com/toorop/go-bittrex/blob/b4a20c2db009afea9ceca5d1592e34618ce3b324/bittrex.go#L113-L127
133,893
toorop/go-bittrex
bittrex.go
GetMarketSummaries
func (b *Bittrex) GetMarketSummaries() (marketSummaries []MarketSummary, err error) { r, err := b.client.do("GET", "public/getmarketsummaries", "", false) if err != nil { return } var response jsonResponse if err = json.Unmarshal(r, &response); err != nil { return } if err = handleErr(response); err != nil {...
go
func (b *Bittrex) GetMarketSummaries() (marketSummaries []MarketSummary, err error) { r, err := b.client.do("GET", "public/getmarketsummaries", "", false) if err != nil { return } var response jsonResponse if err = json.Unmarshal(r, &response); err != nil { return } if err = handleErr(response); err != nil {...
[ "func", "(", "b", "*", "Bittrex", ")", "GetMarketSummaries", "(", ")", "(", "marketSummaries", "[", "]", "MarketSummary", ",", "err", "error", ")", "{", "r", ",", "err", ":=", "b", ".", "client", ".", "do", "(", "\"", "\"", ",", "\"", "\"", ",", ...
// GetMarketSummaries is used to get the last 24 hour summary of all active exchanges
[ "GetMarketSummaries", "is", "used", "to", "get", "the", "last", "24", "hour", "summary", "of", "all", "active", "exchanges" ]
b4a20c2db009afea9ceca5d1592e34618ce3b324
https://github.com/toorop/go-bittrex/blob/b4a20c2db009afea9ceca5d1592e34618ce3b324/bittrex.go#L130-L144
133,894
toorop/go-bittrex
bittrex.go
GetMarketSummary
func (b *Bittrex) GetMarketSummary(market string) (marketSummary []MarketSummary, err error) { r, err := b.client.do("GET", fmt.Sprintf("public/getmarketsummary?market=%s", strings.ToUpper(market)), "", false) if err != nil { return } var response jsonResponse if err = json.Unmarshal(r, &response); err != nil { ...
go
func (b *Bittrex) GetMarketSummary(market string) (marketSummary []MarketSummary, err error) { r, err := b.client.do("GET", fmt.Sprintf("public/getmarketsummary?market=%s", strings.ToUpper(market)), "", false) if err != nil { return } var response jsonResponse if err = json.Unmarshal(r, &response); err != nil { ...
[ "func", "(", "b", "*", "Bittrex", ")", "GetMarketSummary", "(", "market", "string", ")", "(", "marketSummary", "[", "]", "MarketSummary", ",", "err", "error", ")", "{", "r", ",", "err", ":=", "b", ".", "client", ".", "do", "(", "\"", "\"", ",", "fm...
// GetMarketSummary is used to get the last 24 hour summary for a given market
[ "GetMarketSummary", "is", "used", "to", "get", "the", "last", "24", "hour", "summary", "for", "a", "given", "market" ]
b4a20c2db009afea9ceca5d1592e34618ce3b324
https://github.com/toorop/go-bittrex/blob/b4a20c2db009afea9ceca5d1592e34618ce3b324/bittrex.go#L147-L161
133,895
toorop/go-bittrex
bittrex.go
BuyLimit
func (b *Bittrex) BuyLimit(market string, quantity, rate decimal.Decimal) (uuid string, err error) { r, err := b.client.do("GET", fmt.Sprintf("market/buylimit?market=%s&quantity=%s&rate=%s", market, quantity, rate), "", true) if err != nil { return } var response jsonResponse if err = json.Unmarshal(r, &response...
go
func (b *Bittrex) BuyLimit(market string, quantity, rate decimal.Decimal) (uuid string, err error) { r, err := b.client.do("GET", fmt.Sprintf("market/buylimit?market=%s&quantity=%s&rate=%s", market, quantity, rate), "", true) if err != nil { return } var response jsonResponse if err = json.Unmarshal(r, &response...
[ "func", "(", "b", "*", "Bittrex", ")", "BuyLimit", "(", "market", "string", ",", "quantity", ",", "rate", "decimal", ".", "Decimal", ")", "(", "uuid", "string", ",", "err", "error", ")", "{", "r", ",", "err", ":=", "b", ".", "client", ".", "do", ...
// Market // BuyLimit is used to place a limited buy order in a specific market.
[ "Market", "BuyLimit", "is", "used", "to", "place", "a", "limited", "buy", "order", "in", "a", "specific", "market", "." ]
b4a20c2db009afea9ceca5d1592e34618ce3b324
https://github.com/toorop/go-bittrex/blob/b4a20c2db009afea9ceca5d1592e34618ce3b324/bittrex.go#L237-L253
133,896
toorop/go-bittrex
bittrex.go
CancelOrder
func (b *Bittrex) CancelOrder(orderID string) (err error) { r, err := b.client.do("GET", "market/cancel?uuid="+orderID, "", true) if err != nil { return } var response jsonResponse if err = json.Unmarshal(r, &response); err != nil { return } err = handleErr(response) return }
go
func (b *Bittrex) CancelOrder(orderID string) (err error) { r, err := b.client.do("GET", "market/cancel?uuid="+orderID, "", true) if err != nil { return } var response jsonResponse if err = json.Unmarshal(r, &response); err != nil { return } err = handleErr(response) return }
[ "func", "(", "b", "*", "Bittrex", ")", "CancelOrder", "(", "orderID", "string", ")", "(", "err", "error", ")", "{", "r", ",", "err", ":=", "b", ".", "client", ".", "do", "(", "\"", "\"", ",", "\"", "\"", "+", "orderID", ",", "\"", "\"", ",", ...
// CancelOrder is used to cancel a buy or sell order.
[ "CancelOrder", "is", "used", "to", "cancel", "a", "buy", "or", "sell", "order", "." ]
b4a20c2db009afea9ceca5d1592e34618ce3b324
https://github.com/toorop/go-bittrex/blob/b4a20c2db009afea9ceca5d1592e34618ce3b324/bittrex.go#L275-L286
133,897
toorop/go-bittrex
bittrex.go
GetOpenOrders
func (b *Bittrex) GetOpenOrders(market string) (openOrders []Order, err error) { resource := "market/getopenorders" if market != "all" { resource += "?market=" + strings.ToUpper(market) } r, err := b.client.do("GET", resource, "", true) if err != nil { return } var response jsonResponse if err = json.Unmars...
go
func (b *Bittrex) GetOpenOrders(market string) (openOrders []Order, err error) { resource := "market/getopenorders" if market != "all" { resource += "?market=" + strings.ToUpper(market) } r, err := b.client.do("GET", resource, "", true) if err != nil { return } var response jsonResponse if err = json.Unmars...
[ "func", "(", "b", "*", "Bittrex", ")", "GetOpenOrders", "(", "market", "string", ")", "(", "openOrders", "[", "]", "Order", ",", "err", "error", ")", "{", "resource", ":=", "\"", "\"", "\n", "if", "market", "!=", "\"", "\"", "{", "resource", "+=", ...
// GetOpenOrders returns orders that you currently have opened. // If market is set to "all", GetOpenOrders return all orders // If market is set to a specific order, GetOpenOrders return orders for this market
[ "GetOpenOrders", "returns", "orders", "that", "you", "currently", "have", "opened", ".", "If", "market", "is", "set", "to", "all", "GetOpenOrders", "return", "all", "orders", "If", "market", "is", "set", "to", "a", "specific", "order", "GetOpenOrders", "return...
b4a20c2db009afea9ceca5d1592e34618ce3b324
https://github.com/toorop/go-bittrex/blob/b4a20c2db009afea9ceca5d1592e34618ce3b324/bittrex.go#L291-L309
133,898
toorop/go-bittrex
bittrex.go
GetBalances
func (b *Bittrex) GetBalances() (balances []Balance, err error) { r, err := b.client.do("GET", "account/getbalances", "", true) if err != nil { return } var response jsonResponse if err = json.Unmarshal(r, &response); err != nil { return } if err = handleErr(response); err != nil { return } err = json.Un...
go
func (b *Bittrex) GetBalances() (balances []Balance, err error) { r, err := b.client.do("GET", "account/getbalances", "", true) if err != nil { return } var response jsonResponse if err = json.Unmarshal(r, &response); err != nil { return } if err = handleErr(response); err != nil { return } err = json.Un...
[ "func", "(", "b", "*", "Bittrex", ")", "GetBalances", "(", ")", "(", "balances", "[", "]", "Balance", ",", "err", "error", ")", "{", "r", ",", "err", ":=", "b", ".", "client", ".", "do", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",",...
// Account // GetBalances is used to retrieve all balances from your account
[ "Account", "GetBalances", "is", "used", "to", "retrieve", "all", "balances", "from", "your", "account" ]
b4a20c2db009afea9ceca5d1592e34618ce3b324
https://github.com/toorop/go-bittrex/blob/b4a20c2db009afea9ceca5d1592e34618ce3b324/bittrex.go#L314-L328
133,899
tstranex/u2f
register.go
Register
func Register(resp RegisterResponse, c Challenge, config *Config) (*Registration, error) { if config == nil { config = &Config{} } if time.Now().Sub(c.Timestamp) > timeout { return nil, errors.New("u2f: challenge has expired") } regData, err := decodeBase64(resp.RegistrationData) if err != nil { return ni...
go
func Register(resp RegisterResponse, c Challenge, config *Config) (*Registration, error) { if config == nil { config = &Config{} } if time.Now().Sub(c.Timestamp) > timeout { return nil, errors.New("u2f: challenge has expired") } regData, err := decodeBase64(resp.RegistrationData) if err != nil { return ni...
[ "func", "Register", "(", "resp", "RegisterResponse", ",", "c", "Challenge", ",", "config", "*", "Config", ")", "(", "*", "Registration", ",", "error", ")", "{", "if", "config", "==", "nil", "{", "config", "=", "&", "Config", "{", "}", "\n", "}", "\n\...
// Register validates a RegisterResponse message to enrol a new token. // An error is returned if any part of the response fails to validate. // The returned Registration should be stored by the caller.
[ "Register", "validates", "a", "RegisterResponse", "message", "to", "enrol", "a", "new", "token", ".", "An", "error", "is", "returned", "if", "any", "part", "of", "the", "response", "fails", "to", "validate", ".", "The", "returned", "Registration", "should", ...
d21a03e0b1d9fc1df59ff54e7a513655c1748b0c
https://github.com/tstranex/u2f/blob/d21a03e0b1d9fc1df59ff54e7a513655c1748b0c/register.go#L49-L86