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
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
alicebob/miniredis
miniredis.go
RequireAuth
func (m *Miniredis) RequireAuth(pw string) { m.Lock() defer m.Unlock() m.password = pw }
go
func (m *Miniredis) RequireAuth(pw string) { m.Lock() defer m.Unlock() m.password = pw }
[ "func", "(", "m", "*", "Miniredis", ")", "RequireAuth", "(", "pw", "string", ")", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n", "m", ".", "password", "=", "pw", "\n", "}" ]
// RequireAuth makes every connection need to AUTH first. Disable again by // setting an empty string.
[ "RequireAuth", "makes", "every", "connection", "need", "to", "AUTH", "first", ".", "Disable", "again", "by", "setting", "an", "empty", "string", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/miniredis.go#L177-L181
train
alicebob/miniredis
miniredis.go
DB
func (m *Miniredis) DB(i int) *RedisDB { m.Lock() defer m.Unlock() return m.db(i) }
go
func (m *Miniredis) DB(i int) *RedisDB { m.Lock() defer m.Unlock() return m.db(i) }
[ "func", "(", "m", "*", "Miniredis", ")", "DB", "(", "i", "int", ")", "*", "RedisDB", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n", "return", "m", ".", "db", "(", "i", ")", "\n", "}" ]
// DB returns a DB by ID.
[ "DB", "returns", "a", "DB", "by", "ID", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/miniredis.go#L184-L188
train
alicebob/miniredis
miniredis.go
db
func (m *Miniredis) db(i int) *RedisDB { if db, ok := m.dbs[i]; ok { return db } db := newRedisDB(i, &m.Mutex) // the DB has our lock. m.dbs[i] = &db return &db }
go
func (m *Miniredis) db(i int) *RedisDB { if db, ok := m.dbs[i]; ok { return db } db := newRedisDB(i, &m.Mutex) // the DB has our lock. m.dbs[i] = &db return &db }
[ "func", "(", "m", "*", "Miniredis", ")", "db", "(", "i", "int", ")", "*", "RedisDB", "{", "if", "db", ",", "ok", ":=", "m", ".", "dbs", "[", "i", "]", ";", "ok", "{", "return", "db", "\n", "}", "\n", "db", ":=", "newRedisDB", "(", "i", ",",...
// get DB. No locks!
[ "get", "DB", ".", "No", "locks!" ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/miniredis.go#L191-L198
train
alicebob/miniredis
miniredis.go
SwapDB
func (m *Miniredis) SwapDB(i, j int) bool { m.Lock() defer m.Unlock() return m.swapDB(i, j) }
go
func (m *Miniredis) SwapDB(i, j int) bool { m.Lock() defer m.Unlock() return m.swapDB(i, j) }
[ "func", "(", "m", "*", "Miniredis", ")", "SwapDB", "(", "i", ",", "j", "int", ")", "bool", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n", "return", "m", ".", "swapDB", "(", "i", ",", "j", ")", "\n", "}" ...
// SwapDB swaps DBs by IDs.
[ "SwapDB", "swaps", "DBs", "by", "IDs", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/miniredis.go#L201-L205
train
alicebob/miniredis
miniredis.go
swapDB
func (m *Miniredis) swapDB(i, j int) bool { db1 := m.db(i) db2 := m.db(j) db1.id = j db2.id = i m.dbs[i] = db2 m.dbs[j] = db1 return true }
go
func (m *Miniredis) swapDB(i, j int) bool { db1 := m.db(i) db2 := m.db(j) db1.id = j db2.id = i m.dbs[i] = db2 m.dbs[j] = db1 return true }
[ "func", "(", "m", "*", "Miniredis", ")", "swapDB", "(", "i", ",", "j", "int", ")", "bool", "{", "db1", ":=", "m", ".", "db", "(", "i", ")", "\n", "db2", ":=", "m", ".", "db", "(", "j", ")", "\n\n", "db1", ".", "id", "=", "j", "\n", "db2",...
// swap DB. No locks!
[ "swap", "DB", ".", "No", "locks!" ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/miniredis.go#L208-L219
train
alicebob/miniredis
miniredis.go
CommandCount
func (m *Miniredis) CommandCount() int { m.Lock() defer m.Unlock() return int(m.srv.TotalCommands()) }
go
func (m *Miniredis) CommandCount() int { m.Lock() defer m.Unlock() return int(m.srv.TotalCommands()) }
[ "func", "(", "m", "*", "Miniredis", ")", "CommandCount", "(", ")", "int", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n", "return", "int", "(", "m", ".", "srv", ".", "TotalCommands", "(", ")", ")", "\n", "}" ...
// CommandCount returns the number of processed commands.
[ "CommandCount", "returns", "the", "number", "of", "processed", "commands", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/miniredis.go#L244-L248
train
alicebob/miniredis
miniredis.go
CurrentConnectionCount
func (m *Miniredis) CurrentConnectionCount() int { m.Lock() defer m.Unlock() return m.srv.ClientsLen() }
go
func (m *Miniredis) CurrentConnectionCount() int { m.Lock() defer m.Unlock() return m.srv.ClientsLen() }
[ "func", "(", "m", "*", "Miniredis", ")", "CurrentConnectionCount", "(", ")", "int", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n", "return", "m", ".", "srv", ".", "ClientsLen", "(", ")", "\n", "}" ]
// CurrentConnectionCount returns the number of currently connected clients.
[ "CurrentConnectionCount", "returns", "the", "number", "of", "currently", "connected", "clients", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/miniredis.go#L251-L255
train
alicebob/miniredis
miniredis.go
TotalConnectionCount
func (m *Miniredis) TotalConnectionCount() int { m.Lock() defer m.Unlock() return int(m.srv.TotalConnections()) }
go
func (m *Miniredis) TotalConnectionCount() int { m.Lock() defer m.Unlock() return int(m.srv.TotalConnections()) }
[ "func", "(", "m", "*", "Miniredis", ")", "TotalConnectionCount", "(", ")", "int", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n", "return", "int", "(", "m", ".", "srv", ".", "TotalConnections", "(", ")", ")", "...
// TotalConnectionCount returns the number of client connections since server start.
[ "TotalConnectionCount", "returns", "the", "number", "of", "client", "connections", "since", "server", "start", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/miniredis.go#L258-L262
train
alicebob/miniredis
miniredis.go
FastForward
func (m *Miniredis) FastForward(duration time.Duration) { m.Lock() defer m.Unlock() for _, db := range m.dbs { db.fastForward(duration) } }
go
func (m *Miniredis) FastForward(duration time.Duration) { m.Lock() defer m.Unlock() for _, db := range m.dbs { db.fastForward(duration) } }
[ "func", "(", "m", "*", "Miniredis", ")", "FastForward", "(", "duration", "time", ".", "Duration", ")", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n", "for", "_", ",", "db", ":=", "range", "m", ".", "dbs", "{...
// FastForward decreases all TTLs by the given duration. All TTLs <= 0 will be // expired.
[ "FastForward", "decreases", "all", "TTLs", "by", "the", "given", "duration", ".", "All", "TTLs", "<", "=", "0", "will", "be", "expired", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/miniredis.go#L266-L272
train
alicebob/miniredis
miniredis.go
redigo
func (m *Miniredis) redigo() redigo.Conn { c1, c2 := net.Pipe() m.srv.ServeConn(c1) c := redigo.NewConn(c2, 0, 0) if m.password != "" { if _, err := c.Do("AUTH", m.password); err != nil { // ? } } return c }
go
func (m *Miniredis) redigo() redigo.Conn { c1, c2 := net.Pipe() m.srv.ServeConn(c1) c := redigo.NewConn(c2, 0, 0) if m.password != "" { if _, err := c.Do("AUTH", m.password); err != nil { // ? } } return c }
[ "func", "(", "m", "*", "Miniredis", ")", "redigo", "(", ")", "redigo", ".", "Conn", "{", "c1", ",", "c2", ":=", "net", ".", "Pipe", "(", ")", "\n", "m", ".", "srv", ".", "ServeConn", "(", "c1", ")", "\n", "c", ":=", "redigo", ".", "NewConn", ...
// redigo returns a redigo.Conn, connected using net.Pipe
[ "redigo", "returns", "a", "redigo", ".", "Conn", "connected", "using", "net", ".", "Pipe" ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/miniredis.go#L275-L285
train
alicebob/miniredis
miniredis.go
Dump
func (m *Miniredis) Dump() string { m.Lock() defer m.Unlock() var ( maxLen = 60 indent = " " db = m.db(m.selectedDB) r = "" v = func(s string) string { suffix := "" if len(s) > maxLen { suffix = fmt.Sprintf("...(%d)", len(s)) s = s[:maxLen-len(suffix)] } return fmt.Spri...
go
func (m *Miniredis) Dump() string { m.Lock() defer m.Unlock() var ( maxLen = 60 indent = " " db = m.db(m.selectedDB) r = "" v = func(s string) string { suffix := "" if len(s) > maxLen { suffix = fmt.Sprintf("...(%d)", len(s)) s = s[:maxLen-len(suffix)] } return fmt.Spri...
[ "func", "(", "m", "*", "Miniredis", ")", "Dump", "(", ")", "string", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n\n", "var", "(", "maxLen", "=", "60", "\n", "indent", "=", "\"", "\"", "\n", "db", "=", "m",...
// Dump returns a text version of the selected DB, usable for debugging.
[ "Dump", "returns", "a", "text", "version", "of", "the", "selected", "DB", "usable", "for", "debugging", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/miniredis.go#L288-L333
train
alicebob/miniredis
miniredis.go
handleAuth
func (m *Miniredis) handleAuth(c *server.Peer) bool { m.Lock() defer m.Unlock() if m.password == "" { return true } if !getCtx(c).authenticated { c.WriteError("NOAUTH Authentication required.") return false } return true }
go
func (m *Miniredis) handleAuth(c *server.Peer) bool { m.Lock() defer m.Unlock() if m.password == "" { return true } if !getCtx(c).authenticated { c.WriteError("NOAUTH Authentication required.") return false } return true }
[ "func", "(", "m", "*", "Miniredis", ")", "handleAuth", "(", "c", "*", "server", ".", "Peer", ")", "bool", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n", "if", "m", ".", "password", "==", "\"", "\"", "{", "...
// handleAuth returns false if connection has no access. It sends the reply.
[ "handleAuth", "returns", "false", "if", "connection", "has", "no", "access", ".", "It", "sends", "the", "reply", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/miniredis.go#L344-L355
train
alicebob/miniredis
miniredis.go
checkPubsub
func (m *Miniredis) checkPubsub(c *server.Peer) bool { m.Lock() defer m.Unlock() ctx := getCtx(c) if ctx.subscriber == nil { return false } c.WriteError("ERR only (P)SUBSCRIBE / (P)UNSUBSCRIBE / PING / QUIT allowed in this context") return true }
go
func (m *Miniredis) checkPubsub(c *server.Peer) bool { m.Lock() defer m.Unlock() ctx := getCtx(c) if ctx.subscriber == nil { return false } c.WriteError("ERR only (P)SUBSCRIBE / (P)UNSUBSCRIBE / PING / QUIT allowed in this context") return true }
[ "func", "(", "m", "*", "Miniredis", ")", "checkPubsub", "(", "c", "*", "server", ".", "Peer", ")", "bool", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n\n", "ctx", ":=", "getCtx", "(", "c", ")", "\n", "if", ...
// handlePubsub sends an error to the user if the connection is in PUBSUB mode. // It'll return true if it did.
[ "handlePubsub", "sends", "an", "error", "to", "the", "user", "if", "the", "connection", "is", "in", "PUBSUB", "mode", ".", "It", "ll", "return", "true", "if", "it", "did", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/miniredis.go#L359-L370
train
alicebob/miniredis
miniredis.go
setDirty
func setDirty(c *server.Peer) { if c.Ctx == nil { // No transaction. Not relevant. return } getCtx(c).dirtyTransaction = true }
go
func setDirty(c *server.Peer) { if c.Ctx == nil { // No transaction. Not relevant. return } getCtx(c).dirtyTransaction = true }
[ "func", "setDirty", "(", "c", "*", "server", ".", "Peer", ")", "{", "if", "c", ".", "Ctx", "==", "nil", "{", "// No transaction. Not relevant.", "return", "\n", "}", "\n", "getCtx", "(", "c", ")", ".", "dirtyTransaction", "=", "true", "\n", "}" ]
// setDirty can be called even when not in an tx. Is an no-op then.
[ "setDirty", "can", "be", "called", "even", "when", "not", "in", "an", "tx", ".", "Is", "an", "no", "-", "op", "then", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/miniredis.go#L409-L415
train
alicebob/miniredis
miniredis.go
removeSubscriber
func (m *Miniredis) removeSubscriber(s *Subscriber) { _, ok := m.subscribers[s] delete(m.subscribers, s) if ok { s.Close() } }
go
func (m *Miniredis) removeSubscriber(s *Subscriber) { _, ok := m.subscribers[s] delete(m.subscribers, s) if ok { s.Close() } }
[ "func", "(", "m", "*", "Miniredis", ")", "removeSubscriber", "(", "s", "*", "Subscriber", ")", "{", "_", ",", "ok", ":=", "m", ".", "subscribers", "[", "s", "]", "\n", "delete", "(", "m", ".", "subscribers", ",", "s", ")", "\n", "if", "ok", "{", ...
// closes and remove the subscriber.
[ "closes", "and", "remove", "the", "subscriber", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/miniredis.go#L426-L432
train
alicebob/miniredis
miniredis.go
subscribedState
func (m *Miniredis) subscribedState(c *server.Peer) *Subscriber { ctx := getCtx(c) sub := ctx.subscriber if sub != nil { return sub } sub = newSubscriber() m.addSubscriber(sub) c.OnDisconnect(func() { m.Lock() m.removeSubscriber(sub) m.Unlock() }) ctx.subscriber = sub go monitorPublish(c, sub.publ...
go
func (m *Miniredis) subscribedState(c *server.Peer) *Subscriber { ctx := getCtx(c) sub := ctx.subscriber if sub != nil { return sub } sub = newSubscriber() m.addSubscriber(sub) c.OnDisconnect(func() { m.Lock() m.removeSubscriber(sub) m.Unlock() }) ctx.subscriber = sub go monitorPublish(c, sub.publ...
[ "func", "(", "m", "*", "Miniredis", ")", "subscribedState", "(", "c", "*", "server", ".", "Peer", ")", "*", "Subscriber", "{", "ctx", ":=", "getCtx", "(", "c", ")", "\n", "sub", ":=", "ctx", ".", "subscriber", "\n", "if", "sub", "!=", "nil", "{", ...
// enter 'subscribed state', or return the existing one.
[ "enter", "subscribed", "state", "or", "return", "the", "existing", "one", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/miniredis.go#L443-L464
train
alicebob/miniredis
miniredis.go
endSubscriber
func endSubscriber(m *Miniredis, c *server.Peer) { ctx := getCtx(c) if sub := ctx.subscriber; sub != nil { m.removeSubscriber(sub) // will Close() the sub } ctx.subscriber = nil }
go
func endSubscriber(m *Miniredis, c *server.Peer) { ctx := getCtx(c) if sub := ctx.subscriber; sub != nil { m.removeSubscriber(sub) // will Close() the sub } ctx.subscriber = nil }
[ "func", "endSubscriber", "(", "m", "*", "Miniredis", ",", "c", "*", "server", ".", "Peer", ")", "{", "ctx", ":=", "getCtx", "(", "c", ")", "\n", "if", "sub", ":=", "ctx", ".", "subscriber", ";", "sub", "!=", "nil", "{", "m", ".", "removeSubscriber"...
// whenever the p?sub count drops to 0 subscribed state should be stopped, and // all redis commands are allowed again.
[ "whenever", "the", "p?sub", "count", "drops", "to", "0", "subscribed", "state", "should", "be", "stopped", "and", "all", "redis", "commands", "are", "allowed", "again", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/miniredis.go#L468-L474
train
alicebob/miniredis
sorted_set.go
elems
func (ss *sortedSet) elems() ssElems { elems := make(ssElems, 0, len(*ss)) for e, s := range *ss { elems = append(elems, ssElem{s, e}) } return elems }
go
func (ss *sortedSet) elems() ssElems { elems := make(ssElems, 0, len(*ss)) for e, s := range *ss { elems = append(elems, ssElem{s, e}) } return elems }
[ "func", "(", "ss", "*", "sortedSet", ")", "elems", "(", ")", "ssElems", "{", "elems", ":=", "make", "(", "ssElems", ",", "0", ",", "len", "(", "*", "ss", ")", ")", "\n", "for", "e", ",", "s", ":=", "range", "*", "ss", "{", "elems", "=", "appe...
// elems gives the list of ssElem, ready to sort.
[ "elems", "gives", "the", "list", "of", "ssElem", "ready", "to", "sort", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/sorted_set.go#L54-L60
train
alicebob/miniredis
cmd_generic.go
commandsGeneric
func commandsGeneric(m *Miniredis) { m.srv.Register("DEL", m.cmdDel) // DUMP m.srv.Register("EXISTS", m.cmdExists) m.srv.Register("EXPIRE", makeCmdExpire(m, false, time.Second)) m.srv.Register("EXPIREAT", makeCmdExpire(m, true, time.Second)) m.srv.Register("KEYS", m.cmdKeys) // MIGRATE m.srv.Register("MOVE", m....
go
func commandsGeneric(m *Miniredis) { m.srv.Register("DEL", m.cmdDel) // DUMP m.srv.Register("EXISTS", m.cmdExists) m.srv.Register("EXPIRE", makeCmdExpire(m, false, time.Second)) m.srv.Register("EXPIREAT", makeCmdExpire(m, true, time.Second)) m.srv.Register("KEYS", m.cmdKeys) // MIGRATE m.srv.Register("MOVE", m....
[ "func", "commandsGeneric", "(", "m", "*", "Miniredis", ")", "{", "m", ".", "srv", ".", "Register", "(", "\"", "\"", ",", "m", ".", "cmdDel", ")", "\n", "// DUMP", "m", ".", "srv", ".", "Register", "(", "\"", "\"", ",", "m", ".", "cmdExists", ")",...
// commandsGeneric handles EXPIRE, TTL, PERSIST, &c.
[ "commandsGeneric", "handles", "EXPIRE", "TTL", "PERSIST", "&c", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/cmd_generic.go#L15-L37
train
alicebob/miniredis
cmd_generic.go
makeCmdExpire
func makeCmdExpire(m *Miniredis, unix bool, d time.Duration) func(*server.Peer, string, []string) { return func(c *server.Peer, cmd string, args []string) { if len(args) != 2 { setDirty(c) c.WriteError(errWrongNumber(cmd)) return } if !m.handleAuth(c) { return } if m.checkPubsub(c) { return ...
go
func makeCmdExpire(m *Miniredis, unix bool, d time.Duration) func(*server.Peer, string, []string) { return func(c *server.Peer, cmd string, args []string) { if len(args) != 2 { setDirty(c) c.WriteError(errWrongNumber(cmd)) return } if !m.handleAuth(c) { return } if m.checkPubsub(c) { return ...
[ "func", "makeCmdExpire", "(", "m", "*", "Miniredis", ",", "unix", "bool", ",", "d", "time", ".", "Duration", ")", "func", "(", "*", "server", ".", "Peer", ",", "string", ",", "[", "]", "string", ")", "{", "return", "func", "(", "c", "*", "server", ...
// generic expire command for EXPIRE, PEXPIRE, EXPIREAT, PEXPIREAT // d is the time unit. If unix is set it'll be seen as a unixtimestamp and // converted to a duration.
[ "generic", "expire", "command", "for", "EXPIRE", "PEXPIRE", "EXPIREAT", "PEXPIREAT", "d", "is", "the", "time", "unit", ".", "If", "unix", "is", "set", "it", "ll", "be", "seen", "as", "a", "unixtimestamp", "and", "converted", "to", "a", "duration", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/cmd_generic.go#L42-L96
train
alicebob/miniredis
redis.go
withTx
func withTx( m *Miniredis, c *server.Peer, cb txCmd, ) { ctx := getCtx(c) if inTx(ctx) { addTxCmd(ctx, cb) c.WriteInline("QUEUED") return } m.Lock() cb(c, ctx) // done, wake up anyone who waits on anything. m.signal.Broadcast() m.Unlock() }
go
func withTx( m *Miniredis, c *server.Peer, cb txCmd, ) { ctx := getCtx(c) if inTx(ctx) { addTxCmd(ctx, cb) c.WriteInline("QUEUED") return } m.Lock() cb(c, ctx) // done, wake up anyone who waits on anything. m.signal.Broadcast() m.Unlock() }
[ "func", "withTx", "(", "m", "*", "Miniredis", ",", "c", "*", "server", ".", "Peer", ",", "cb", "txCmd", ",", ")", "{", "ctx", ":=", "getCtx", "(", "c", ")", "\n", "if", "inTx", "(", "ctx", ")", "{", "addTxCmd", "(", "ctx", ",", "cb", ")", "\n...
// withTx wraps the non-argument-checking part of command handling code in // transaction logic.
[ "withTx", "wraps", "the", "non", "-", "argument", "-", "checking", "part", "of", "command", "handling", "code", "in", "transaction", "logic", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/redis.go#L47-L63
train
alicebob/miniredis
redis.go
matchKeys
func matchKeys(keys []string, match string) []string { re := patternRE(match) if re == nil { // Special case, the given pattern won't match anything / is // invalid. return nil } res := []string{} for _, k := range keys { if !re.MatchString(k) { continue } res = append(res, k) } return res }
go
func matchKeys(keys []string, match string) []string { re := patternRE(match) if re == nil { // Special case, the given pattern won't match anything / is // invalid. return nil } res := []string{} for _, k := range keys { if !re.MatchString(k) { continue } res = append(res, k) } return res }
[ "func", "matchKeys", "(", "keys", "[", "]", "string", ",", "match", "string", ")", "[", "]", "string", "{", "re", ":=", "patternRE", "(", "match", ")", "\n", "if", "re", "==", "nil", "{", "// Special case, the given pattern won't match anything / is", "// inva...
// matchKeys filters only matching keys. // Will return an empty list on invalid match expression.
[ "matchKeys", "filters", "only", "matching", "keys", ".", "Will", "return", "an", "empty", "list", "on", "invalid", "match", "expression", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/redis.go#L194-L209
train
alicebob/miniredis
db.go
allKeys
func (db *RedisDB) allKeys() []string { res := make([]string, 0, len(db.keys)) for k := range db.keys { res = append(res, k) } sort.Strings(res) // To make things deterministic. return res }
go
func (db *RedisDB) allKeys() []string { res := make([]string, 0, len(db.keys)) for k := range db.keys { res = append(res, k) } sort.Strings(res) // To make things deterministic. return res }
[ "func", "(", "db", "*", "RedisDB", ")", "allKeys", "(", ")", "[", "]", "string", "{", "res", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "db", ".", "keys", ")", ")", "\n", "for", "k", ":=", "range", "db", ".", "keys", ...
// allKeys returns all keys. Sorted.
[ "allKeys", "returns", "all", "keys", ".", "Sorted", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L20-L27
train
alicebob/miniredis
db.go
flush
func (db *RedisDB) flush() { db.keys = map[string]string{} db.stringKeys = map[string]string{} db.hashKeys = map[string]hashKey{} db.listKeys = map[string]listKey{} db.setKeys = map[string]setKey{} db.sortedsetKeys = map[string]sortedSet{} db.ttl = map[string]time.Duration{} }
go
func (db *RedisDB) flush() { db.keys = map[string]string{} db.stringKeys = map[string]string{} db.hashKeys = map[string]hashKey{} db.listKeys = map[string]listKey{} db.setKeys = map[string]setKey{} db.sortedsetKeys = map[string]sortedSet{} db.ttl = map[string]time.Duration{} }
[ "func", "(", "db", "*", "RedisDB", ")", "flush", "(", ")", "{", "db", ".", "keys", "=", "map", "[", "string", "]", "string", "{", "}", "\n", "db", ".", "stringKeys", "=", "map", "[", "string", "]", "string", "{", "}", "\n", "db", ".", "hashKeys...
// flush removes all keys and values.
[ "flush", "removes", "all", "keys", "and", "values", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L30-L38
train
alicebob/miniredis
db.go
move
func (db *RedisDB) move(key string, to *RedisDB) bool { if _, ok := to.keys[key]; ok { return false } t, ok := db.keys[key] if !ok { return false } to.keys[key] = db.keys[key] switch t { case "string": to.stringKeys[key] = db.stringKeys[key] case "hash": to.hashKeys[key] = db.hashKeys[key] case "list...
go
func (db *RedisDB) move(key string, to *RedisDB) bool { if _, ok := to.keys[key]; ok { return false } t, ok := db.keys[key] if !ok { return false } to.keys[key] = db.keys[key] switch t { case "string": to.stringKeys[key] = db.stringKeys[key] case "hash": to.hashKeys[key] = db.hashKeys[key] case "list...
[ "func", "(", "db", "*", "RedisDB", ")", "move", "(", "key", "string", ",", "to", "*", "RedisDB", ")", "bool", "{", "if", "_", ",", "ok", ":=", "to", ".", "keys", "[", "key", "]", ";", "ok", "{", "return", "false", "\n", "}", "\n\n", "t", ",",...
// move something to another db. Will return ok. Or not.
[ "move", "something", "to", "another", "db", ".", "Will", "return", "ok", ".", "Or", "not", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L41-L71
train
alicebob/miniredis
db.go
stringIncr
func (db *RedisDB) stringIncr(k string, delta int) (int, error) { v := 0 if sv, ok := db.stringKeys[k]; ok { var err error v, err = strconv.Atoi(sv) if err != nil { return 0, ErrIntValueError } } v += delta db.stringSet(k, strconv.Itoa(v)) return v, nil }
go
func (db *RedisDB) stringIncr(k string, delta int) (int, error) { v := 0 if sv, ok := db.stringKeys[k]; ok { var err error v, err = strconv.Atoi(sv) if err != nil { return 0, ErrIntValueError } } v += delta db.stringSet(k, strconv.Itoa(v)) return v, nil }
[ "func", "(", "db", "*", "RedisDB", ")", "stringIncr", "(", "k", "string", ",", "delta", "int", ")", "(", "int", ",", "error", ")", "{", "v", ":=", "0", "\n", "if", "sv", ",", "ok", ":=", "db", ".", "stringKeys", "[", "k", "]", ";", "ok", "{",...
// change int key value
[ "change", "int", "key", "value" ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L139-L151
train
alicebob/miniredis
db.go
stringIncrfloat
func (db *RedisDB) stringIncrfloat(k string, delta float64) (float64, error) { v := 0.0 if sv, ok := db.stringKeys[k]; ok { var err error v, err = strconv.ParseFloat(sv, 64) if err != nil { return 0, ErrFloatValueError } } v += delta db.stringSet(k, formatFloat(v)) return v, nil }
go
func (db *RedisDB) stringIncrfloat(k string, delta float64) (float64, error) { v := 0.0 if sv, ok := db.stringKeys[k]; ok { var err error v, err = strconv.ParseFloat(sv, 64) if err != nil { return 0, ErrFloatValueError } } v += delta db.stringSet(k, formatFloat(v)) return v, nil }
[ "func", "(", "db", "*", "RedisDB", ")", "stringIncrfloat", "(", "k", "string", ",", "delta", "float64", ")", "(", "float64", ",", "error", ")", "{", "v", ":=", "0.0", "\n", "if", "sv", ",", "ok", ":=", "db", ".", "stringKeys", "[", "k", "]", ";",...
// change float key value
[ "change", "float", "key", "value" ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L154-L166
train
alicebob/miniredis
db.go
listLpush
func (db *RedisDB) listLpush(k, v string) int { l, ok := db.listKeys[k] if !ok { db.keys[k] = "list" } l = append([]string{v}, l...) db.listKeys[k] = l db.keyVersion[k]++ return len(l) }
go
func (db *RedisDB) listLpush(k, v string) int { l, ok := db.listKeys[k] if !ok { db.keys[k] = "list" } l = append([]string{v}, l...) db.listKeys[k] = l db.keyVersion[k]++ return len(l) }
[ "func", "(", "db", "*", "RedisDB", ")", "listLpush", "(", "k", ",", "v", "string", ")", "int", "{", "l", ",", "ok", ":=", "db", ".", "listKeys", "[", "k", "]", "\n", "if", "!", "ok", "{", "db", ".", "keys", "[", "k", "]", "=", "\"", "\"", ...
// listLpush is 'left push', aka unshift. Returns the new length.
[ "listLpush", "is", "left", "push", "aka", "unshift", ".", "Returns", "the", "new", "length", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L169-L178
train
alicebob/miniredis
db.go
listLpop
func (db *RedisDB) listLpop(k string) string { l := db.listKeys[k] el := l[0] l = l[1:] if len(l) == 0 { db.del(k, true) } else { db.listKeys[k] = l } db.keyVersion[k]++ return el }
go
func (db *RedisDB) listLpop(k string) string { l := db.listKeys[k] el := l[0] l = l[1:] if len(l) == 0 { db.del(k, true) } else { db.listKeys[k] = l } db.keyVersion[k]++ return el }
[ "func", "(", "db", "*", "RedisDB", ")", "listLpop", "(", "k", "string", ")", "string", "{", "l", ":=", "db", ".", "listKeys", "[", "k", "]", "\n", "el", ":=", "l", "[", "0", "]", "\n", "l", "=", "l", "[", "1", ":", "]", "\n", "if", "len", ...
// 'left pop', aka shift.
[ "left", "pop", "aka", "shift", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L181-L192
train
alicebob/miniredis
db.go
setSet
func (db *RedisDB) setSet(k string, set setKey) { db.keys[k] = "set" db.setKeys[k] = set db.keyVersion[k]++ }
go
func (db *RedisDB) setSet(k string, set setKey) { db.keys[k] = "set" db.setKeys[k] = set db.keyVersion[k]++ }
[ "func", "(", "db", "*", "RedisDB", ")", "setSet", "(", "k", "string", ",", "set", "setKey", ")", "{", "db", ".", "keys", "[", "k", "]", "=", "\"", "\"", "\n", "db", ".", "setKeys", "[", "k", "]", "=", "set", "\n", "db", ".", "keyVersion", "["...
// setset replaces a whole set.
[ "setset", "replaces", "a", "whole", "set", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L219-L223
train
alicebob/miniredis
db.go
setAdd
func (db *RedisDB) setAdd(k string, elems ...string) int { s, ok := db.setKeys[k] if !ok { s = setKey{} db.keys[k] = "set" } added := 0 for _, e := range elems { if _, ok := s[e]; !ok { added++ } s[e] = struct{}{} } db.setKeys[k] = s db.keyVersion[k]++ return added }
go
func (db *RedisDB) setAdd(k string, elems ...string) int { s, ok := db.setKeys[k] if !ok { s = setKey{} db.keys[k] = "set" } added := 0 for _, e := range elems { if _, ok := s[e]; !ok { added++ } s[e] = struct{}{} } db.setKeys[k] = s db.keyVersion[k]++ return added }
[ "func", "(", "db", "*", "RedisDB", ")", "setAdd", "(", "k", "string", ",", "elems", "...", "string", ")", "int", "{", "s", ",", "ok", ":=", "db", ".", "setKeys", "[", "k", "]", "\n", "if", "!", "ok", "{", "s", "=", "setKey", "{", "}", "\n", ...
// setadd adds members to a set. Returns nr of new keys.
[ "setadd", "adds", "members", "to", "a", "set", ".", "Returns", "nr", "of", "new", "keys", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L226-L242
train
alicebob/miniredis
db.go
setRem
func (db *RedisDB) setRem(k string, fields ...string) int { s, ok := db.setKeys[k] if !ok { return 0 } removed := 0 for _, f := range fields { if _, ok := s[f]; ok { removed++ delete(s, f) } } if len(s) == 0 { db.del(k, true) } else { db.setKeys[k] = s } db.keyVersion[k]++ return removed }
go
func (db *RedisDB) setRem(k string, fields ...string) int { s, ok := db.setKeys[k] if !ok { return 0 } removed := 0 for _, f := range fields { if _, ok := s[f]; ok { removed++ delete(s, f) } } if len(s) == 0 { db.del(k, true) } else { db.setKeys[k] = s } db.keyVersion[k]++ return removed }
[ "func", "(", "db", "*", "RedisDB", ")", "setRem", "(", "k", "string", ",", "fields", "...", "string", ")", "int", "{", "s", ",", "ok", ":=", "db", ".", "setKeys", "[", "k", "]", "\n", "if", "!", "ok", "{", "return", "0", "\n", "}", "\n", "rem...
// setrem removes members from a set. Returns nr of deleted keys.
[ "setrem", "removes", "members", "from", "a", "set", ".", "Returns", "nr", "of", "deleted", "keys", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L245-L264
train
alicebob/miniredis
db.go
setMembers
func (db *RedisDB) setMembers(k string) []string { set := db.setKeys[k] members := make([]string, 0, len(set)) for k := range set { members = append(members, k) } sort.Strings(members) return members }
go
func (db *RedisDB) setMembers(k string) []string { set := db.setKeys[k] members := make([]string, 0, len(set)) for k := range set { members = append(members, k) } sort.Strings(members) return members }
[ "func", "(", "db", "*", "RedisDB", ")", "setMembers", "(", "k", "string", ")", "[", "]", "string", "{", "set", ":=", "db", ".", "setKeys", "[", "k", "]", "\n", "members", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "set", ...
// All members of a set.
[ "All", "members", "of", "a", "set", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L267-L275
train
alicebob/miniredis
db.go
setIsMember
func (db *RedisDB) setIsMember(k, v string) bool { set, ok := db.setKeys[k] if !ok { return false } _, ok = set[v] return ok }
go
func (db *RedisDB) setIsMember(k, v string) bool { set, ok := db.setKeys[k] if !ok { return false } _, ok = set[v] return ok }
[ "func", "(", "db", "*", "RedisDB", ")", "setIsMember", "(", "k", ",", "v", "string", ")", "bool", "{", "set", ",", "ok", ":=", "db", ".", "setKeys", "[", "k", "]", "\n", "if", "!", "ok", "{", "return", "false", "\n", "}", "\n", "_", ",", "ok"...
// Is a SET value present?
[ "Is", "a", "SET", "value", "present?" ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L278-L285
train
alicebob/miniredis
db.go
hashGet
func (db *RedisDB) hashGet(key, field string) string { return db.hashKeys[key][field] }
go
func (db *RedisDB) hashGet(key, field string) string { return db.hashKeys[key][field] }
[ "func", "(", "db", "*", "RedisDB", ")", "hashGet", "(", "key", ",", "field", "string", ")", "string", "{", "return", "db", ".", "hashKeys", "[", "key", "]", "[", "field", "]", "\n", "}" ]
// hashGet a value
[ "hashGet", "a", "value" ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L299-L301
train
alicebob/miniredis
db.go
hashSet
func (db *RedisDB) hashSet(k, f, v string) bool { if t, ok := db.keys[k]; ok && t != "hash" { db.del(k, true) } db.keys[k] = "hash" if _, ok := db.hashKeys[k]; !ok { db.hashKeys[k] = map[string]string{} } _, ok := db.hashKeys[k][f] db.hashKeys[k][f] = v db.keyVersion[k]++ return ok }
go
func (db *RedisDB) hashSet(k, f, v string) bool { if t, ok := db.keys[k]; ok && t != "hash" { db.del(k, true) } db.keys[k] = "hash" if _, ok := db.hashKeys[k]; !ok { db.hashKeys[k] = map[string]string{} } _, ok := db.hashKeys[k][f] db.hashKeys[k][f] = v db.keyVersion[k]++ return ok }
[ "func", "(", "db", "*", "RedisDB", ")", "hashSet", "(", "k", ",", "f", ",", "v", "string", ")", "bool", "{", "if", "t", ",", "ok", ":=", "db", ".", "keys", "[", "k", "]", ";", "ok", "&&", "t", "!=", "\"", "\"", "{", "db", ".", "del", "(",...
// hashSet returns whether the key already existed
[ "hashSet", "returns", "whether", "the", "key", "already", "existed" ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L304-L316
train
alicebob/miniredis
db.go
hashIncr
func (db *RedisDB) hashIncr(key, field string, delta int) (int, error) { v := 0 if h, ok := db.hashKeys[key]; ok { if f, ok := h[field]; ok { var err error v, err = strconv.Atoi(f) if err != nil { return 0, ErrIntValueError } } } v += delta db.hashSet(key, field, strconv.Itoa(v)) return v, nil...
go
func (db *RedisDB) hashIncr(key, field string, delta int) (int, error) { v := 0 if h, ok := db.hashKeys[key]; ok { if f, ok := h[field]; ok { var err error v, err = strconv.Atoi(f) if err != nil { return 0, ErrIntValueError } } } v += delta db.hashSet(key, field, strconv.Itoa(v)) return v, nil...
[ "func", "(", "db", "*", "RedisDB", ")", "hashIncr", "(", "key", ",", "field", "string", ",", "delta", "int", ")", "(", "int", ",", "error", ")", "{", "v", ":=", "0", "\n", "if", "h", ",", "ok", ":=", "db", ".", "hashKeys", "[", "key", "]", ";...
// hashIncr changes int key value
[ "hashIncr", "changes", "int", "key", "value" ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L319-L333
train
alicebob/miniredis
db.go
hashIncrfloat
func (db *RedisDB) hashIncrfloat(key, field string, delta float64) (float64, error) { v := 0.0 if h, ok := db.hashKeys[key]; ok { if f, ok := h[field]; ok { var err error v, err = strconv.ParseFloat(f, 64) if err != nil { return 0, ErrFloatValueError } } } v += delta db.hashSet(key, field, form...
go
func (db *RedisDB) hashIncrfloat(key, field string, delta float64) (float64, error) { v := 0.0 if h, ok := db.hashKeys[key]; ok { if f, ok := h[field]; ok { var err error v, err = strconv.ParseFloat(f, 64) if err != nil { return 0, ErrFloatValueError } } } v += delta db.hashSet(key, field, form...
[ "func", "(", "db", "*", "RedisDB", ")", "hashIncrfloat", "(", "key", ",", "field", "string", ",", "delta", "float64", ")", "(", "float64", ",", "error", ")", "{", "v", ":=", "0.0", "\n", "if", "h", ",", "ok", ":=", "db", ".", "hashKeys", "[", "ke...
// hashIncrfloat changes float key value
[ "hashIncrfloat", "changes", "float", "key", "value" ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L336-L350
train
alicebob/miniredis
db.go
sortedSet
func (db *RedisDB) sortedSet(key string) map[string]float64 { ss := db.sortedsetKeys[key] return map[string]float64(ss) }
go
func (db *RedisDB) sortedSet(key string) map[string]float64 { ss := db.sortedsetKeys[key] return map[string]float64(ss) }
[ "func", "(", "db", "*", "RedisDB", ")", "sortedSet", "(", "key", "string", ")", "map", "[", "string", "]", "float64", "{", "ss", ":=", "db", ".", "sortedsetKeys", "[", "key", "]", "\n", "return", "map", "[", "string", "]", "float64", "(", "ss", ")"...
// sortedSet set returns a sortedSet as map
[ "sortedSet", "set", "returns", "a", "sortedSet", "as", "map" ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L353-L356
train
alicebob/miniredis
db.go
ssetSet
func (db *RedisDB) ssetSet(key string, sset sortedSet) { db.keys[key] = "zset" db.keyVersion[key]++ db.sortedsetKeys[key] = sset }
go
func (db *RedisDB) ssetSet(key string, sset sortedSet) { db.keys[key] = "zset" db.keyVersion[key]++ db.sortedsetKeys[key] = sset }
[ "func", "(", "db", "*", "RedisDB", ")", "ssetSet", "(", "key", "string", ",", "sset", "sortedSet", ")", "{", "db", ".", "keys", "[", "key", "]", "=", "\"", "\"", "\n", "db", ".", "keyVersion", "[", "key", "]", "++", "\n", "db", ".", "sortedsetKey...
// ssetSet sets a complete sorted set.
[ "ssetSet", "sets", "a", "complete", "sorted", "set", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L359-L363
train
alicebob/miniredis
db.go
ssetAdd
func (db *RedisDB) ssetAdd(key string, score float64, member string) bool { ss, ok := db.sortedsetKeys[key] if !ok { ss = newSortedSet() db.keys[key] = "zset" } _, ok = ss[member] ss[member] = score db.sortedsetKeys[key] = ss db.keyVersion[key]++ return !ok }
go
func (db *RedisDB) ssetAdd(key string, score float64, member string) bool { ss, ok := db.sortedsetKeys[key] if !ok { ss = newSortedSet() db.keys[key] = "zset" } _, ok = ss[member] ss[member] = score db.sortedsetKeys[key] = ss db.keyVersion[key]++ return !ok }
[ "func", "(", "db", "*", "RedisDB", ")", "ssetAdd", "(", "key", "string", ",", "score", "float64", ",", "member", "string", ")", "bool", "{", "ss", ",", "ok", ":=", "db", ".", "sortedsetKeys", "[", "key", "]", "\n", "if", "!", "ok", "{", "ss", "="...
// ssetAdd adds member to a sorted set. Returns whether this was a new member.
[ "ssetAdd", "adds", "member", "to", "a", "sorted", "set", ".", "Returns", "whether", "this", "was", "a", "new", "member", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L366-L377
train
alicebob/miniredis
db.go
ssetMembers
func (db *RedisDB) ssetMembers(key string) []string { ss, ok := db.sortedsetKeys[key] if !ok { return nil } elems := ss.byScore(asc) members := make([]string, 0, len(elems)) for _, e := range elems { members = append(members, e.member) } return members }
go
func (db *RedisDB) ssetMembers(key string) []string { ss, ok := db.sortedsetKeys[key] if !ok { return nil } elems := ss.byScore(asc) members := make([]string, 0, len(elems)) for _, e := range elems { members = append(members, e.member) } return members }
[ "func", "(", "db", "*", "RedisDB", ")", "ssetMembers", "(", "key", "string", ")", "[", "]", "string", "{", "ss", ",", "ok", ":=", "db", ".", "sortedsetKeys", "[", "key", "]", "\n", "if", "!", "ok", "{", "return", "nil", "\n", "}", "\n", "elems", ...
// All members from a sorted set, ordered by score.
[ "All", "members", "from", "a", "sorted", "set", "ordered", "by", "score", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L380-L391
train
alicebob/miniredis
db.go
ssetElements
func (db *RedisDB) ssetElements(key string) ssElems { ss, ok := db.sortedsetKeys[key] if !ok { return nil } return ss.byScore(asc) }
go
func (db *RedisDB) ssetElements(key string) ssElems { ss, ok := db.sortedsetKeys[key] if !ok { return nil } return ss.byScore(asc) }
[ "func", "(", "db", "*", "RedisDB", ")", "ssetElements", "(", "key", "string", ")", "ssElems", "{", "ss", ",", "ok", ":=", "db", ".", "sortedsetKeys", "[", "key", "]", "\n", "if", "!", "ok", "{", "return", "nil", "\n", "}", "\n", "return", "ss", "...
// All members+scores from a sorted set, ordered by score.
[ "All", "members", "+", "scores", "from", "a", "sorted", "set", "ordered", "by", "score", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L394-L400
train
alicebob/miniredis
db.go
ssetCard
func (db *RedisDB) ssetCard(key string) int { ss := db.sortedsetKeys[key] return ss.card() }
go
func (db *RedisDB) ssetCard(key string) int { ss := db.sortedsetKeys[key] return ss.card() }
[ "func", "(", "db", "*", "RedisDB", ")", "ssetCard", "(", "key", "string", ")", "int", "{", "ss", ":=", "db", ".", "sortedsetKeys", "[", "key", "]", "\n", "return", "ss", ".", "card", "(", ")", "\n", "}" ]
// ssetCard is the sorted set cardinality.
[ "ssetCard", "is", "the", "sorted", "set", "cardinality", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L403-L406
train
alicebob/miniredis
db.go
ssetRank
func (db *RedisDB) ssetRank(key, member string, d direction) (int, bool) { ss := db.sortedsetKeys[key] return ss.rankByScore(member, d) }
go
func (db *RedisDB) ssetRank(key, member string, d direction) (int, bool) { ss := db.sortedsetKeys[key] return ss.rankByScore(member, d) }
[ "func", "(", "db", "*", "RedisDB", ")", "ssetRank", "(", "key", ",", "member", "string", ",", "d", "direction", ")", "(", "int", ",", "bool", ")", "{", "ss", ":=", "db", ".", "sortedsetKeys", "[", "key", "]", "\n", "return", "ss", ".", "rankByScore...
// ssetRank is the sorted set rank.
[ "ssetRank", "is", "the", "sorted", "set", "rank", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L409-L412
train
alicebob/miniredis
db.go
ssetScore
func (db *RedisDB) ssetScore(key, member string) float64 { ss := db.sortedsetKeys[key] return ss[member] }
go
func (db *RedisDB) ssetScore(key, member string) float64 { ss := db.sortedsetKeys[key] return ss[member] }
[ "func", "(", "db", "*", "RedisDB", ")", "ssetScore", "(", "key", ",", "member", "string", ")", "float64", "{", "ss", ":=", "db", ".", "sortedsetKeys", "[", "key", "]", "\n", "return", "ss", "[", "member", "]", "\n", "}" ]
// ssetScore is sorted set score.
[ "ssetScore", "is", "sorted", "set", "score", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L415-L418
train
alicebob/miniredis
db.go
ssetRem
func (db *RedisDB) ssetRem(key, member string) bool { ss := db.sortedsetKeys[key] _, ok := ss[member] delete(ss, member) if len(ss) == 0 { // Delete key on removal of last member db.del(key, true) } return ok }
go
func (db *RedisDB) ssetRem(key, member string) bool { ss := db.sortedsetKeys[key] _, ok := ss[member] delete(ss, member) if len(ss) == 0 { // Delete key on removal of last member db.del(key, true) } return ok }
[ "func", "(", "db", "*", "RedisDB", ")", "ssetRem", "(", "key", ",", "member", "string", ")", "bool", "{", "ss", ":=", "db", ".", "sortedsetKeys", "[", "key", "]", "\n", "_", ",", "ok", ":=", "ss", "[", "member", "]", "\n", "delete", "(", "ss", ...
// ssetRem is sorted set key delete.
[ "ssetRem", "is", "sorted", "set", "key", "delete", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L421-L430
train
alicebob/miniredis
db.go
ssetExists
func (db *RedisDB) ssetExists(key, member string) bool { ss := db.sortedsetKeys[key] _, ok := ss[member] return ok }
go
func (db *RedisDB) ssetExists(key, member string) bool { ss := db.sortedsetKeys[key] _, ok := ss[member] return ok }
[ "func", "(", "db", "*", "RedisDB", ")", "ssetExists", "(", "key", ",", "member", "string", ")", "bool", "{", "ss", ":=", "db", ".", "sortedsetKeys", "[", "key", "]", "\n", "_", ",", "ok", ":=", "ss", "[", "member", "]", "\n", "return", "ok", "\n"...
// ssetExists tells if a member exists in a sorted set.
[ "ssetExists", "tells", "if", "a", "member", "exists", "in", "a", "sorted", "set", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L433-L437
train
alicebob/miniredis
db.go
ssetIncrby
func (db *RedisDB) ssetIncrby(k, m string, delta float64) float64 { ss, ok := db.sortedsetKeys[k] if !ok { ss = newSortedSet() db.keys[k] = "zset" db.sortedsetKeys[k] = ss } v, _ := ss.get(m) v += delta ss.set(v, m) db.keyVersion[k]++ return v }
go
func (db *RedisDB) ssetIncrby(k, m string, delta float64) float64 { ss, ok := db.sortedsetKeys[k] if !ok { ss = newSortedSet() db.keys[k] = "zset" db.sortedsetKeys[k] = ss } v, _ := ss.get(m) v += delta ss.set(v, m) db.keyVersion[k]++ return v }
[ "func", "(", "db", "*", "RedisDB", ")", "ssetIncrby", "(", "k", ",", "m", "string", ",", "delta", "float64", ")", "float64", "{", "ss", ",", "ok", ":=", "db", ".", "sortedsetKeys", "[", "k", "]", "\n", "if", "!", "ok", "{", "ss", "=", "newSortedS...
// ssetIncrby changes float sorted set score.
[ "ssetIncrby", "changes", "float", "sorted", "set", "score", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L440-L453
train
alicebob/miniredis
db.go
fastForward
func (db *RedisDB) fastForward(duration time.Duration) { for _, key := range db.allKeys() { if value, ok := db.ttl[key]; ok { db.ttl[key] = value - duration db.checkTTL(key) } } }
go
func (db *RedisDB) fastForward(duration time.Duration) { for _, key := range db.allKeys() { if value, ok := db.ttl[key]; ok { db.ttl[key] = value - duration db.checkTTL(key) } } }
[ "func", "(", "db", "*", "RedisDB", ")", "fastForward", "(", "duration", "time", ".", "Duration", ")", "{", "for", "_", ",", "key", ":=", "range", "db", ".", "allKeys", "(", ")", "{", "if", "value", ",", "ok", ":=", "db", ".", "ttl", "[", "key", ...
// fastForward proceeds the current timestamp with duration, works as a time machine
[ "fastForward", "proceeds", "the", "current", "timestamp", "with", "duration", "works", "as", "a", "time", "machine" ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/db.go#L538-L545
train
alicebob/miniredis
cmd_sorted_set.go
commandsSortedSet
func commandsSortedSet(m *Miniredis) { m.srv.Register("ZADD", m.cmdZadd) m.srv.Register("ZCARD", m.cmdZcard) m.srv.Register("ZCOUNT", m.cmdZcount) m.srv.Register("ZINCRBY", m.cmdZincrby) m.srv.Register("ZINTERSTORE", m.cmdZinterstore) m.srv.Register("ZLEXCOUNT", m.cmdZlexcount) m.srv.Register("ZRANGE", m.makeCmd...
go
func commandsSortedSet(m *Miniredis) { m.srv.Register("ZADD", m.cmdZadd) m.srv.Register("ZCARD", m.cmdZcard) m.srv.Register("ZCOUNT", m.cmdZcount) m.srv.Register("ZINCRBY", m.cmdZincrby) m.srv.Register("ZINTERSTORE", m.cmdZinterstore) m.srv.Register("ZLEXCOUNT", m.cmdZlexcount) m.srv.Register("ZRANGE", m.makeCmd...
[ "func", "commandsSortedSet", "(", "m", "*", "Miniredis", ")", "{", "m", ".", "srv", ".", "Register", "(", "\"", "\"", ",", "m", ".", "cmdZadd", ")", "\n", "m", ".", "srv", ".", "Register", "(", "\"", "\"", ",", "m", ".", "cmdZcard", ")", "\n", ...
// commandsSortedSet handles all sorted set operations.
[ "commandsSortedSet", "handles", "all", "sorted", "set", "operations", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/cmd_sorted_set.go#L19-L43
train
alicebob/miniredis
cmd_sorted_set.go
makeCmdZrank
func (m *Miniredis) makeCmdZrank(reverse bool) server.Cmd { return func(c *server.Peer, cmd string, args []string) { if len(args) != 2 { setDirty(c) c.WriteError(errWrongNumber(cmd)) return } if !m.handleAuth(c) { return } if m.checkPubsub(c) { return } key, member := args[0], args[1] ...
go
func (m *Miniredis) makeCmdZrank(reverse bool) server.Cmd { return func(c *server.Peer, cmd string, args []string) { if len(args) != 2 { setDirty(c) c.WriteError(errWrongNumber(cmd)) return } if !m.handleAuth(c) { return } if m.checkPubsub(c) { return } key, member := args[0], args[1] ...
[ "func", "(", "m", "*", "Miniredis", ")", "makeCmdZrank", "(", "reverse", "bool", ")", "server", ".", "Cmd", "{", "return", "func", "(", "c", "*", "server", ".", "Peer", ",", "cmd", "string", ",", "args", "[", "]", "string", ")", "{", "if", "len", ...
// ZRANK and ZREVRANK
[ "ZRANK", "and", "ZREVRANK" ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/cmd_sorted_set.go#L778-L819
train
alicebob/miniredis
cmd_sorted_set.go
parseFloatRange
func parseFloatRange(s string) (float64, bool, error) { if len(s) == 0 { return 0, false, nil } inclusive := true if s[0] == '(' { s = s[1:] inclusive = false } f, err := strconv.ParseFloat(s, 64) return f, inclusive, err }
go
func parseFloatRange(s string) (float64, bool, error) { if len(s) == 0 { return 0, false, nil } inclusive := true if s[0] == '(' { s = s[1:] inclusive = false } f, err := strconv.ParseFloat(s, 64) return f, inclusive, err }
[ "func", "parseFloatRange", "(", "s", "string", ")", "(", "float64", ",", "bool", ",", "error", ")", "{", "if", "len", "(", "s", ")", "==", "0", "{", "return", "0", ",", "false", ",", "nil", "\n", "}", "\n", "inclusive", ":=", "true", "\n", "if", ...
// parseFloatRange handles ZRANGEBYSCORE floats. They are inclusive unless the // string starts with '('
[ "parseFloatRange", "handles", "ZRANGEBYSCORE", "floats", ".", "They", "are", "inclusive", "unless", "the", "string", "starts", "with", "(" ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/cmd_sorted_set.go#L1054-L1065
train
alicebob/miniredis
cmd_sorted_set.go
parseLexrange
func parseLexrange(s string) (string, bool, error) { if len(s) == 0 { return "", false, errInvalidRangeItem } if s == "+" || s == "-" { return s, false, nil } switch s[0] { case '(': return s[1:], false, nil case '[': return s[1:], true, nil default: return "", false, errInvalidRangeItem } }
go
func parseLexrange(s string) (string, bool, error) { if len(s) == 0 { return "", false, errInvalidRangeItem } if s == "+" || s == "-" { return s, false, nil } switch s[0] { case '(': return s[1:], false, nil case '[': return s[1:], true, nil default: return "", false, errInvalidRangeItem } }
[ "func", "parseLexrange", "(", "s", "string", ")", "(", "string", ",", "bool", ",", "error", ")", "{", "if", "len", "(", "s", ")", "==", "0", "{", "return", "\"", "\"", ",", "false", ",", "errInvalidRangeItem", "\n", "}", "\n", "if", "s", "==", "\...
// parseLexrange handles ZRANGEBYLEX ranges. They start with '[', '(', or are // '+' or '-'. // Returns range, inclusive, error. // On '+' or '-' that's just returned.
[ "parseLexrange", "handles", "ZRANGEBYLEX", "ranges", ".", "They", "start", "with", "[", "(", "or", "are", "+", "or", "-", ".", "Returns", "range", "inclusive", "error", ".", "On", "+", "or", "-", "that", "s", "just", "returned", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/cmd_sorted_set.go#L1071-L1086
train
alicebob/miniredis
cmd_sorted_set.go
withSSRange
func withSSRange(members ssElems, min float64, minIncl bool, max float64, maxIncl bool) ssElems { gt := func(a, b float64) bool { return a > b } gteq := func(a, b float64) bool { return a >= b } mincmp := gt if minIncl { mincmp = gteq } for i, m := range members { if mincmp(m.score, min) { members = membe...
go
func withSSRange(members ssElems, min float64, minIncl bool, max float64, maxIncl bool) ssElems { gt := func(a, b float64) bool { return a > b } gteq := func(a, b float64) bool { return a >= b } mincmp := gt if minIncl { mincmp = gteq } for i, m := range members { if mincmp(m.score, min) { members = membe...
[ "func", "withSSRange", "(", "members", "ssElems", ",", "min", "float64", ",", "minIncl", "bool", ",", "max", "float64", ",", "maxIncl", "bool", ")", "ssElems", "{", "gt", ":=", "func", "(", "a", ",", "b", "float64", ")", "bool", "{", "return", "a", "...
// withSSRange limits a list of sorted set elements by the ZRANGEBYSCORE range // logic.
[ "withSSRange", "limits", "a", "list", "of", "sorted", "set", "elements", "by", "the", "ZRANGEBYSCORE", "range", "logic", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/cmd_sorted_set.go#L1090-L1120
train
alicebob/miniredis
cmd_sorted_set.go
withLexRange
func withLexRange(members []string, min string, minIncl bool, max string, maxIncl bool) []string { if max == "-" || min == "+" { return nil } if min != "-" { if minIncl { for i, m := range members { if m >= min { members = members[i:] break } } } else { // Excluding min for i, m :...
go
func withLexRange(members []string, min string, minIncl bool, max string, maxIncl bool) []string { if max == "-" || min == "+" { return nil } if min != "-" { if minIncl { for i, m := range members { if m >= min { members = members[i:] break } } } else { // Excluding min for i, m :...
[ "func", "withLexRange", "(", "members", "[", "]", "string", ",", "min", "string", ",", "minIncl", "bool", ",", "max", "string", ",", "maxIncl", "bool", ")", "[", "]", "string", "{", "if", "max", "==", "\"", "\"", "||", "min", "==", "\"", "\"", "{",...
// withLexRange limits a list of sorted set elements.
[ "withLexRange", "limits", "a", "list", "of", "sorted", "set", "elements", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/cmd_sorted_set.go#L1123-L1164
train
alicebob/miniredis
cmd_sorted_set.go
cmdZpopmax
func (m *Miniredis) cmdZpopmax(reverse bool) server.Cmd { return func(c *server.Peer, cmd string, args []string) { if len(args) < 1 { setDirty(c) c.WriteError(errWrongNumber(cmd)) return } if !m.handleAuth(c) { return } key := args[0] count := 1 var err error if len(args) > 1 { count, e...
go
func (m *Miniredis) cmdZpopmax(reverse bool) server.Cmd { return func(c *server.Peer, cmd string, args []string) { if len(args) < 1 { setDirty(c) c.WriteError(errWrongNumber(cmd)) return } if !m.handleAuth(c) { return } key := args[0] count := 1 var err error if len(args) > 1 { count, e...
[ "func", "(", "m", "*", "Miniredis", ")", "cmdZpopmax", "(", "reverse", "bool", ")", "server", ".", "Cmd", "{", "return", "func", "(", "c", "*", "server", ".", "Peer", ",", "cmd", "string", ",", "args", "[", "]", "string", ")", "{", "if", "len", "...
// ZPOPMAX and ZPOPMIN
[ "ZPOPMAX", "and", "ZPOPMIN" ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/cmd_sorted_set.go#L1388-L1450
train
alicebob/miniredis
cmd_transactions.go
commandsTransaction
func commandsTransaction(m *Miniredis) { m.srv.Register("DISCARD", m.cmdDiscard) m.srv.Register("EXEC", m.cmdExec) m.srv.Register("MULTI", m.cmdMulti) m.srv.Register("UNWATCH", m.cmdUnwatch) m.srv.Register("WATCH", m.cmdWatch) }
go
func commandsTransaction(m *Miniredis) { m.srv.Register("DISCARD", m.cmdDiscard) m.srv.Register("EXEC", m.cmdExec) m.srv.Register("MULTI", m.cmdMulti) m.srv.Register("UNWATCH", m.cmdUnwatch) m.srv.Register("WATCH", m.cmdWatch) }
[ "func", "commandsTransaction", "(", "m", "*", "Miniredis", ")", "{", "m", ".", "srv", ".", "Register", "(", "\"", "\"", ",", "m", ".", "cmdDiscard", ")", "\n", "m", ".", "srv", ".", "Register", "(", "\"", "\"", ",", "m", ".", "cmdExec", ")", "\n"...
// commandsTransaction handles MULTI &c.
[ "commandsTransaction", "handles", "MULTI", "&c", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/cmd_transactions.go#L10-L16
train
alicebob/miniredis
cmd_set.go
commandsSet
func commandsSet(m *Miniredis) { m.srv.Register("SADD", m.cmdSadd) m.srv.Register("SCARD", m.cmdScard) m.srv.Register("SDIFF", m.cmdSdiff) m.srv.Register("SDIFFSTORE", m.cmdSdiffstore) m.srv.Register("SINTER", m.cmdSinter) m.srv.Register("SINTERSTORE", m.cmdSinterstore) m.srv.Register("SISMEMBER", m.cmdSismember...
go
func commandsSet(m *Miniredis) { m.srv.Register("SADD", m.cmdSadd) m.srv.Register("SCARD", m.cmdScard) m.srv.Register("SDIFF", m.cmdSdiff) m.srv.Register("SDIFFSTORE", m.cmdSdiffstore) m.srv.Register("SINTER", m.cmdSinter) m.srv.Register("SINTERSTORE", m.cmdSinterstore) m.srv.Register("SISMEMBER", m.cmdSismember...
[ "func", "commandsSet", "(", "m", "*", "Miniredis", ")", "{", "m", ".", "srv", ".", "Register", "(", "\"", "\"", ",", "m", ".", "cmdSadd", ")", "\n", "m", ".", "srv", ".", "Register", "(", "\"", "\"", ",", "m", ".", "cmdScard", ")", "\n", "m", ...
// commandsSet handles all set value operations.
[ "commandsSet", "handles", "all", "set", "value", "operations", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/cmd_set.go#L14-L30
train
alicebob/miniredis
cmd_set.go
shuffle
func shuffle(m []string) { for _ = range m { i := rand.Intn(len(m)) j := rand.Intn(len(m)) m[i], m[j] = m[j], m[i] } }
go
func shuffle(m []string) { for _ = range m { i := rand.Intn(len(m)) j := rand.Intn(len(m)) m[i], m[j] = m[j], m[i] } }
[ "func", "shuffle", "(", "m", "[", "]", "string", ")", "{", "for", "_", "=", "range", "m", "{", "i", ":=", "rand", ".", "Intn", "(", "len", "(", "m", ")", ")", "\n", "j", ":=", "rand", ".", "Intn", "(", "len", "(", "m", ")", ")", "\n", "m"...
// shuffle shuffles a string. Kinda.
[ "shuffle", "shuffles", "a", "string", ".", "Kinda", "." ]
3d7aa1333af56ab862d446678d93aaa6803e0938
https://github.com/alicebob/miniredis/blob/3d7aa1333af56ab862d446678d93aaa6803e0938/cmd_set.go#L678-L684
train
minio/mc
pkg/ioutils/filepath.go
IsDirEmpty
func IsDirEmpty(dirname string) (status bool, err error) { f, err := os.Open(dirname) if err == nil { defer f.Close() if _, err = f.Readdirnames(1); err == io.EOF { status = true err = nil } } return }
go
func IsDirEmpty(dirname string) (status bool, err error) { f, err := os.Open(dirname) if err == nil { defer f.Close() if _, err = f.Readdirnames(1); err == io.EOF { status = true err = nil } } return }
[ "func", "IsDirEmpty", "(", "dirname", "string", ")", "(", "status", "bool", ",", "err", "error", ")", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "dirname", ")", "\n", "if", "err", "==", "nil", "{", "defer", "f", ".", "Close", "(", ")", ...
// IsDirEmpty Check if a directory is empty
[ "IsDirEmpty", "Check", "if", "a", "directory", "is", "empty" ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/pkg/ioutils/filepath.go#L28-L39
train
minio/mc
pkg/ioutils/filepath.go
FTW
func FTW(root string, walkFn FTWFunc) error { info, err := os.Lstat(root) if err != nil { return walkFn(root, nil, err) } return walk(root, info, walkFn) }
go
func FTW(root string, walkFn FTWFunc) error { info, err := os.Lstat(root) if err != nil { return walkFn(root, nil, err) } return walk(root, info, walkFn) }
[ "func", "FTW", "(", "root", "string", ",", "walkFn", "FTWFunc", ")", "error", "{", "info", ",", "err", ":=", "os", ".", "Lstat", "(", "root", ")", "\n", "if", "err", "!=", "nil", "{", "return", "walkFn", "(", "root", ",", "nil", ",", "err", ")", ...
// FTW walks the file tree rooted at root, calling walkFn for each file or // directory in the tree, including root.
[ "FTW", "walks", "the", "file", "tree", "rooted", "at", "root", "calling", "walkFn", "for", "each", "file", "or", "directory", "in", "the", "tree", "including", "root", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/pkg/ioutils/filepath.go#L43-L49
train
minio/mc
pkg/ioutils/filepath.go
readDir
func readDir(dirname string) (fi []os.FileInfo, err error) { f, err := os.Open(dirname) if err == nil { defer f.Close() if fi, err = f.Readdir(-1); fi != nil { sort.Sort(byName(fi)) } } return }
go
func readDir(dirname string) (fi []os.FileInfo, err error) { f, err := os.Open(dirname) if err == nil { defer f.Close() if fi, err = f.Readdir(-1); fi != nil { sort.Sort(byName(fi)) } } return }
[ "func", "readDir", "(", "dirname", "string", ")", "(", "fi", "[", "]", "os", ".", "FileInfo", ",", "err", "error", ")", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "dirname", ")", "\n", "if", "err", "==", "nil", "{", "defer", "f", ".", ...
// readDir reads the directory named by dirname and returns // a sorted list of directory entries.
[ "readDir", "reads", "the", "directory", "named", "by", "dirname", "and", "returns", "a", "sorted", "list", "of", "directory", "entries", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/pkg/ioutils/filepath.go#L72-L82
train
minio/mc
cmd/config-host-list.go
printHosts
func printHosts(hosts ...hostMessage) { var maxAlias = 0 for _, host := range hosts { if len(host.Alias) > maxAlias { maxAlias = len(host.Alias) } } for _, host := range hosts { if !globalJSON { // Format properly for alignment based on alias length only in non json mode. host.Alias = fmt.Sprintf("%-...
go
func printHosts(hosts ...hostMessage) { var maxAlias = 0 for _, host := range hosts { if len(host.Alias) > maxAlias { maxAlias = len(host.Alias) } } for _, host := range hosts { if !globalJSON { // Format properly for alignment based on alias length only in non json mode. host.Alias = fmt.Sprintf("%-...
[ "func", "printHosts", "(", "hosts", "...", "hostMessage", ")", "{", "var", "maxAlias", "=", "0", "\n", "for", "_", ",", "host", ":=", "range", "hosts", "{", "if", "len", "(", "host", ".", "Alias", ")", ">", "maxAlias", "{", "maxAlias", "=", "len", ...
// Prints all the hosts.
[ "Prints", "all", "the", "hosts", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config-host-list.go#L88-L107
train
minio/mc
cmd/config-host-list.go
listHosts
func listHosts(alias string) { conf, err := loadMcConfig() fatalIf(err.Trace(globalMCConfigVersion), "Unable to load config version `"+globalMCConfigVersion+"`.") // If specific alias is requested, look for it and print. if alias != "" { if v, ok := conf.Hosts[alias]; ok { printHosts(hostMessage{ op: ...
go
func listHosts(alias string) { conf, err := loadMcConfig() fatalIf(err.Trace(globalMCConfigVersion), "Unable to load config version `"+globalMCConfigVersion+"`.") // If specific alias is requested, look for it and print. if alias != "" { if v, ok := conf.Hosts[alias]; ok { printHosts(hostMessage{ op: ...
[ "func", "listHosts", "(", "alias", "string", ")", "{", "conf", ",", "err", ":=", "loadMcConfig", "(", ")", "\n", "fatalIf", "(", "err", ".", "Trace", "(", "globalMCConfigVersion", ")", ",", "\"", "\"", "+", "globalMCConfigVersion", "+", "\"", "\"", ")", ...
// listHosts - list all host URLs or a requested host.
[ "listHosts", "-", "list", "all", "host", "URLs", "or", "a", "requested", "host", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config-host-list.go#L117-L158
train
minio/mc
cmd/session-resume.go
sessionExecute
func sessionExecute(s *sessionV8) { switch s.Header.CommandType { case "cp": sseKeys := s.Header.CommandStringFlags["encrypt-key"] sseServer := s.Header.CommandStringFlags["encrypt"] encKeyDB, _ := parseAndValidateEncryptionKeys(sseKeys, sseServer) doCopySession(s, encKeyDB) } }
go
func sessionExecute(s *sessionV8) { switch s.Header.CommandType { case "cp": sseKeys := s.Header.CommandStringFlags["encrypt-key"] sseServer := s.Header.CommandStringFlags["encrypt"] encKeyDB, _ := parseAndValidateEncryptionKeys(sseKeys, sseServer) doCopySession(s, encKeyDB) } }
[ "func", "sessionExecute", "(", "s", "*", "sessionV8", ")", "{", "switch", "s", ".", "Header", ".", "CommandType", "{", "case", "\"", "\"", ":", "sseKeys", ":=", "s", ".", "Header", ".", "CommandStringFlags", "[", "\"", "\"", "]", "\n", "sseServer", ":=...
// sessionExecute - run a given session.
[ "sessionExecute", "-", "run", "a", "given", "session", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-resume.go#L63-L71
train
minio/mc
cmd/session-resume.go
findClosestSessions
func findClosestSessions(session string) []string { sessionsTree := trie.NewTrie() // Allocate a new trie for sessions strings. for _, sid := range getSessionIDs() { sessionsTree.Insert(sid) } var closestSessions []string for _, value := range sessionsTree.PrefixMatch(session) { closestSessions = append(closes...
go
func findClosestSessions(session string) []string { sessionsTree := trie.NewTrie() // Allocate a new trie for sessions strings. for _, sid := range getSessionIDs() { sessionsTree.Insert(sid) } var closestSessions []string for _, value := range sessionsTree.PrefixMatch(session) { closestSessions = append(closes...
[ "func", "findClosestSessions", "(", "session", "string", ")", "[", "]", "string", "{", "sessionsTree", ":=", "trie", ".", "NewTrie", "(", ")", "// Allocate a new trie for sessions strings.", "\n", "for", "_", ",", "sid", ":=", "range", "getSessionIDs", "(", ")",...
// findClosestSessions to match a given string with sessions trie tree.
[ "findClosestSessions", "to", "match", "a", "given", "string", "with", "sessions", "trie", "tree", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-resume.go#L74-L85
train
minio/mc
cmd/session-resume.go
checkSessionResumeSyntax
func checkSessionResumeSyntax(ctx *cli.Context) { if len(ctx.Args()) == 0 || len(ctx.Args()) > 2 { cli.ShowCommandHelpAndExit(ctx, "resume", 1) // last argument is exit code } }
go
func checkSessionResumeSyntax(ctx *cli.Context) { if len(ctx.Args()) == 0 || len(ctx.Args()) > 2 { cli.ShowCommandHelpAndExit(ctx, "resume", 1) // last argument is exit code } }
[ "func", "checkSessionResumeSyntax", "(", "ctx", "*", "cli", ".", "Context", ")", "{", "if", "len", "(", "ctx", ".", "Args", "(", ")", ")", "==", "0", "||", "len", "(", "ctx", ".", "Args", "(", ")", ")", ">", "2", "{", "cli", ".", "ShowCommandHelp...
// checkSessionResumeSyntax - Validate session resume command.
[ "checkSessionResumeSyntax", "-", "Validate", "session", "resume", "command", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-resume.go#L88-L92
train
minio/mc
cmd/session-resume.go
mainSessionResume
func mainSessionResume(ctx *cli.Context) error { // Validate session resume syntax. checkSessionResumeSyntax(ctx) // Additional command specific theme customization. console.SetColor("Command", color.New(color.FgWhite, color.Bold)) console.SetColor("SessionID", color.New(color.FgYellow, color.Bold)) console.SetC...
go
func mainSessionResume(ctx *cli.Context) error { // Validate session resume syntax. checkSessionResumeSyntax(ctx) // Additional command specific theme customization. console.SetColor("Command", color.New(color.FgWhite, color.Bold)) console.SetColor("SessionID", color.New(color.FgYellow, color.Bold)) console.SetC...
[ "func", "mainSessionResume", "(", "ctx", "*", "cli", ".", "Context", ")", "error", "{", "// Validate session resume syntax.", "checkSessionResumeSyntax", "(", "ctx", ")", "\n\n", "// Additional command specific theme customization.", "console", ".", "SetColor", "(", "\"",...
// mainSessionResume - Main session resume function.
[ "mainSessionResume", "-", "Main", "session", "resume", "function", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-resume.go#L95-L124
train
minio/mc
cmd/session-resume.go
resumeSession
func resumeSession(sessionID string) { s, err := loadSessionV8(sessionID) fatalIf(err.Trace(sessionID), "Unable to load session.") // Restore the state of global variables from this previous session. s.restoreGlobals() savedCwd, e := os.Getwd() fatalIf(probe.NewError(e), "Unable to determine current working fold...
go
func resumeSession(sessionID string) { s, err := loadSessionV8(sessionID) fatalIf(err.Trace(sessionID), "Unable to load session.") // Restore the state of global variables from this previous session. s.restoreGlobals() savedCwd, e := os.Getwd() fatalIf(probe.NewError(e), "Unable to determine current working fold...
[ "func", "resumeSession", "(", "sessionID", "string", ")", "{", "s", ",", "err", ":=", "loadSessionV8", "(", "sessionID", ")", "\n", "fatalIf", "(", "err", ".", "Trace", "(", "sessionID", ")", ",", "\"", "\"", ")", "\n", "// Restore the state of global variab...
// resumeSession - Resumes a session specified by sessionID.
[ "resumeSession", "-", "Resumes", "a", "session", "specified", "by", "sessionID", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-resume.go#L127-L152
train
minio/mc
cmd/signals.go
signalTrap
func signalTrap(sig ...os.Signal) <-chan bool { // channel to notify the caller. trapCh := make(chan bool, 1) go func(chan<- bool) { // channel to receive signals. sigCh := make(chan os.Signal, 1) defer close(sigCh) // `signal.Notify` registers the given channel to // receive notifications of the specifi...
go
func signalTrap(sig ...os.Signal) <-chan bool { // channel to notify the caller. trapCh := make(chan bool, 1) go func(chan<- bool) { // channel to receive signals. sigCh := make(chan os.Signal, 1) defer close(sigCh) // `signal.Notify` registers the given channel to // receive notifications of the specifi...
[ "func", "signalTrap", "(", "sig", "...", "os", ".", "Signal", ")", "<-", "chan", "bool", "{", "// channel to notify the caller.", "trapCh", ":=", "make", "(", "chan", "bool", ",", "1", ")", "\n\n", "go", "func", "(", "chan", "<-", "bool", ")", "{", "//...
// signalTrap traps the registered signals and notifies the caller.
[ "signalTrap", "traps", "the", "registered", "signals", "and", "notifies", "the", "caller", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/signals.go#L25-L49
train
minio/mc
cmd/session-old.go
loadSessionV7
func loadSessionV7(sid string) (*sessionV7, *probe.Error) { if !isSessionDirExists() { return nil, errInvalidArgument().Trace() } sessionFile, err := getSessionFile(sid) if err != nil { return nil, err.Trace(sid) } if _, e := os.Stat(sessionFile); e != nil { return nil, probe.NewError(e) } s := &session...
go
func loadSessionV7(sid string) (*sessionV7, *probe.Error) { if !isSessionDirExists() { return nil, errInvalidArgument().Trace() } sessionFile, err := getSessionFile(sid) if err != nil { return nil, err.Trace(sid) } if _, e := os.Stat(sessionFile); e != nil { return nil, probe.NewError(e) } s := &session...
[ "func", "loadSessionV7", "(", "sid", "string", ")", "(", "*", "sessionV7", ",", "*", "probe", ".", "Error", ")", "{", "if", "!", "isSessionDirExists", "(", ")", "{", "return", "nil", ",", "errInvalidArgument", "(", ")", ".", "Trace", "(", ")", "\n", ...
// loadSessionV7 - reads session file if exists and re-initiates internal variables
[ "loadSessionV7", "-", "reads", "session", "file", "if", "exists", "and", "re", "-", "initiates", "internal", "variables" ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-old.go#L108-L149
train
minio/mc
cmd/client-fs_linux.go
IsGetEvent
func IsGetEvent(event notify.Event) bool { for _, ev := range EventTypeGet { if event&ev != 0 { return true } } return false }
go
func IsGetEvent(event notify.Event) bool { for _, ev := range EventTypeGet { if event&ev != 0 { return true } } return false }
[ "func", "IsGetEvent", "(", "event", "notify", ".", "Event", ")", "bool", "{", "for", "_", ",", "ev", ":=", "range", "EventTypeGet", "{", "if", "event", "&", "ev", "!=", "0", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n"...
// IsGetEvent checks if the event return is a get event.
[ "IsGetEvent", "checks", "if", "the", "event", "return", "is", "a", "get", "event", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-fs_linux.go#L41-L48
train
minio/mc
cmd/client-fs_linux.go
IsPutEvent
func IsPutEvent(event notify.Event) bool { for _, ev := range EventTypePut { if event&ev != 0 { return true } } return false }
go
func IsPutEvent(event notify.Event) bool { for _, ev := range EventTypePut { if event&ev != 0 { return true } } return false }
[ "func", "IsPutEvent", "(", "event", "notify", ".", "Event", ")", "bool", "{", "for", "_", ",", "ev", ":=", "range", "EventTypePut", "{", "if", "event", "&", "ev", "!=", "0", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n"...
// IsPutEvent checks if the event returned is a put event
[ "IsPutEvent", "checks", "if", "the", "event", "returned", "is", "a", "put", "event" ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-fs_linux.go#L51-L58
train
minio/mc
cmd/client-fs_linux.go
IsDeleteEvent
func IsDeleteEvent(event notify.Event) bool { for _, ev := range EventTypeDelete { if event&ev != 0 { return true } } return false }
go
func IsDeleteEvent(event notify.Event) bool { for _, ev := range EventTypeDelete { if event&ev != 0 { return true } } return false }
[ "func", "IsDeleteEvent", "(", "event", "notify", ".", "Event", ")", "bool", "{", "for", "_", ",", "ev", ":=", "range", "EventTypeDelete", "{", "if", "event", "&", "ev", "!=", "0", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", ...
// IsDeleteEvent checks if the event returned is a delete event
[ "IsDeleteEvent", "checks", "if", "the", "event", "returned", "is", "a", "delete", "event" ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-fs_linux.go#L61-L68
train
minio/mc
cmd/client-fs_linux.go
getAllXattrs
func getAllXattrs(path string) (map[string]string, error) { xMetadata := make(map[string]string) list, e := xattr.List(path) if e != nil { if isNotSupported(e) { return nil, nil } return nil, e } for _, key := range list { // filter out system specific xattr if strings.HasPrefix(key, "system.") { c...
go
func getAllXattrs(path string) (map[string]string, error) { xMetadata := make(map[string]string) list, e := xattr.List(path) if e != nil { if isNotSupported(e) { return nil, nil } return nil, e } for _, key := range list { // filter out system specific xattr if strings.HasPrefix(key, "system.") { c...
[ "func", "getAllXattrs", "(", "path", "string", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "xMetadata", ":=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "list", ",", "e", ":=", "xattr", ".", "List", "(",...
// getAllXattrs returns the extended attributes for a file if supported // by the OS
[ "getAllXattrs", "returns", "the", "extended", "attributes", "for", "a", "file", "if", "supported", "by", "the", "OS" ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-fs_linux.go#L85-L108
train
minio/mc
cmd/cat-main.go
newPrettyStdout
func newPrettyStdout(w io.Writer) *prettyStdout { return &prettyStdout{ writer: w, buffer: bytes.NewBuffer([]byte{}), } }
go
func newPrettyStdout(w io.Writer) *prettyStdout { return &prettyStdout{ writer: w, buffer: bytes.NewBuffer([]byte{}), } }
[ "func", "newPrettyStdout", "(", "w", "io", ".", "Writer", ")", "*", "prettyStdout", "{", "return", "&", "prettyStdout", "{", "writer", ":", "w", ",", "buffer", ":", "bytes", ".", "NewBuffer", "(", "[", "]", "byte", "{", "}", ")", ",", "}", "\n", "}...
// newPrettyStdout returns an initialized prettyStdout struct
[ "newPrettyStdout", "returns", "an", "initialized", "prettyStdout", "struct" ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/cat-main.go#L88-L93
train
minio/mc
cmd/cat-main.go
checkCatSyntax
func checkCatSyntax(ctx *cli.Context) { args := ctx.Args() if !args.Present() { args = []string{"-"} } for _, arg := range args { if strings.HasPrefix(arg, "-") && len(arg) > 1 { fatalIf(probe.NewError(errors.New("")), fmt.Sprintf("Unknown flag `%s` passed.", arg)) } } }
go
func checkCatSyntax(ctx *cli.Context) { args := ctx.Args() if !args.Present() { args = []string{"-"} } for _, arg := range args { if strings.HasPrefix(arg, "-") && len(arg) > 1 { fatalIf(probe.NewError(errors.New("")), fmt.Sprintf("Unknown flag `%s` passed.", arg)) } } }
[ "func", "checkCatSyntax", "(", "ctx", "*", "cli", ".", "Context", ")", "{", "args", ":=", "ctx", ".", "Args", "(", ")", "\n", "if", "!", "args", ".", "Present", "(", ")", "{", "args", "=", "[", "]", "string", "{", "\"", "\"", "}", "\n", "}", ...
// checkCatSyntax performs command-line input validation for cat command.
[ "checkCatSyntax", "performs", "command", "-", "line", "input", "validation", "for", "cat", "command", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/cat-main.go#L127-L137
train
minio/mc
cmd/cat-main.go
catURL
func catURL(sourceURL string, encKeyDB map[string][]prefixSSEPair) *probe.Error { var reader io.ReadCloser size := int64(-1) switch sourceURL { case "-": reader = os.Stdin default: var err *probe.Error // Try to stat the object, the purpose is to extract the // size of S3 object so we can check if the size...
go
func catURL(sourceURL string, encKeyDB map[string][]prefixSSEPair) *probe.Error { var reader io.ReadCloser size := int64(-1) switch sourceURL { case "-": reader = os.Stdin default: var err *probe.Error // Try to stat the object, the purpose is to extract the // size of S3 object so we can check if the size...
[ "func", "catURL", "(", "sourceURL", "string", ",", "encKeyDB", "map", "[", "string", "]", "[", "]", "prefixSSEPair", ")", "*", "probe", ".", "Error", "{", "var", "reader", "io", ".", "ReadCloser", "\n", "size", ":=", "int64", "(", "-", "1", ")", "\n"...
// catURL displays contents of a URL to stdout.
[ "catURL", "displays", "contents", "of", "a", "URL", "to", "stdout", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/cat-main.go#L140-L163
train
minio/mc
cmd/cat-main.go
mainCat
func mainCat(ctx *cli.Context) error { // Parse encryption keys per command. encKeyDB, err := getEncKeys(ctx) fatalIf(err, "Unable to parse encryption keys.") // check 'cat' cli arguments. checkCatSyntax(ctx) // Set command flags from context. stdinMode := false if !ctx.Args().Present() { stdinMode = true ...
go
func mainCat(ctx *cli.Context) error { // Parse encryption keys per command. encKeyDB, err := getEncKeys(ctx) fatalIf(err, "Unable to parse encryption keys.") // check 'cat' cli arguments. checkCatSyntax(ctx) // Set command flags from context. stdinMode := false if !ctx.Args().Present() { stdinMode = true ...
[ "func", "mainCat", "(", "ctx", "*", "cli", ".", "Context", ")", "error", "{", "// Parse encryption keys per command.", "encKeyDB", ",", "err", ":=", "getEncKeys", "(", "ctx", ")", "\n", "fatalIf", "(", "err", ",", "\"", "\"", ")", "\n\n", "// check 'cat' cli...
// mainCat is the main entry point for cat command.
[ "mainCat", "is", "the", "main", "entry", "point", "for", "cat", "command", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/cat-main.go#L211-L249
train
minio/mc
cmd/mb-main.go
mainMakeBucket
func mainMakeBucket(ctx *cli.Context) error { // check 'mb' cli arguments. checkMakeBucketSyntax(ctx) // Additional command speific theme customization. console.SetColor("MakeBucket", color.New(color.FgGreen, color.Bold)) // Save region. region := ctx.String("region") ignoreExisting := ctx.Bool("p") var cEr...
go
func mainMakeBucket(ctx *cli.Context) error { // check 'mb' cli arguments. checkMakeBucketSyntax(ctx) // Additional command speific theme customization. console.SetColor("MakeBucket", color.New(color.FgGreen, color.Bold)) // Save region. region := ctx.String("region") ignoreExisting := ctx.Bool("p") var cEr...
[ "func", "mainMakeBucket", "(", "ctx", "*", "cli", ".", "Context", ")", "error", "{", "// check 'mb' cli arguments.", "checkMakeBucketSyntax", "(", "ctx", ")", "\n\n", "// Additional command speific theme customization.", "console", ".", "SetColor", "(", "\"", "\"", ",...
// mainMakeBucket is entry point for mb command.
[ "mainMakeBucket", "is", "entry", "point", "for", "mb", "command", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/mb-main.go#L104-L145
train
minio/mc
cmd/humanized-duration.go
timeDurationToHumanizedDuration
func timeDurationToHumanizedDuration(duration time.Duration) humanizedDuration { r := humanizedDuration{} if duration.Seconds() < 60.0 { r.Seconds = int64(duration.Seconds()) return r } if duration.Minutes() < 60.0 { remainingSeconds := math.Mod(duration.Seconds(), 60) r.Seconds = int64(remainingSeconds) ...
go
func timeDurationToHumanizedDuration(duration time.Duration) humanizedDuration { r := humanizedDuration{} if duration.Seconds() < 60.0 { r.Seconds = int64(duration.Seconds()) return r } if duration.Minutes() < 60.0 { remainingSeconds := math.Mod(duration.Seconds(), 60) r.Seconds = int64(remainingSeconds) ...
[ "func", "timeDurationToHumanizedDuration", "(", "duration", "time", ".", "Duration", ")", "humanizedDuration", "{", "r", ":=", "humanizedDuration", "{", "}", "\n", "if", "duration", ".", "Seconds", "(", ")", "<", "60.0", "{", "r", ".", "Seconds", "=", "int64...
// timeDurationToHumanizedDuration convert golang time.Duration to a custom more readable humanizedDuration.
[ "timeDurationToHumanizedDuration", "convert", "golang", "time", ".", "Duration", "to", "a", "custom", "more", "readable", "humanizedDuration", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/humanized-duration.go#L60-L88
train
minio/mc
cmd/admin-heal-result-item.go
getObjectHCCChange
func (h hri) getObjectHCCChange() (b, a col, err error) { parityShards := h.ParityBlocks dataShards := h.DataBlocks onlineBefore, onlineAfter := h.GetOnlineCounts() surplusShardsBeforeHeal := onlineBefore - dataShards surplusShardsAfterHeal := onlineAfter - dataShards b, err = getHColCode(surplusShardsBeforeHea...
go
func (h hri) getObjectHCCChange() (b, a col, err error) { parityShards := h.ParityBlocks dataShards := h.DataBlocks onlineBefore, onlineAfter := h.GetOnlineCounts() surplusShardsBeforeHeal := onlineBefore - dataShards surplusShardsAfterHeal := onlineAfter - dataShards b, err = getHColCode(surplusShardsBeforeHea...
[ "func", "(", "h", "hri", ")", "getObjectHCCChange", "(", ")", "(", "b", ",", "a", "col", ",", "err", "error", ")", "{", "parityShards", ":=", "h", ".", "ParityBlocks", "\n", "dataShards", ":=", "h", ".", "DataBlocks", "\n\n", "onlineBefore", ",", "onli...
// getObjectHCCChange - returns before and after color change for // objects
[ "getObjectHCCChange", "-", "returns", "before", "and", "after", "color", "change", "for", "objects" ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/admin-heal-result-item.go#L35-L50
train
minio/mc
cmd/admin-heal-result-item.go
getReplicatedFileHCCChange
func (h hri) getReplicatedFileHCCChange() (b, a col, err error) { getColCode := func(numAvail int) (c col, err error) { // calculate color code for replicated object similar // to erasure coded objects quorum := h.DiskCount/h.SetCount/2 + 1 surplus := numAvail/h.SetCount - quorum parity := h.DiskCount/h.SetC...
go
func (h hri) getReplicatedFileHCCChange() (b, a col, err error) { getColCode := func(numAvail int) (c col, err error) { // calculate color code for replicated object similar // to erasure coded objects quorum := h.DiskCount/h.SetCount/2 + 1 surplus := numAvail/h.SetCount - quorum parity := h.DiskCount/h.SetC...
[ "func", "(", "h", "hri", ")", "getReplicatedFileHCCChange", "(", ")", "(", "b", ",", "a", "col", ",", "err", "error", ")", "{", "getColCode", ":=", "func", "(", "numAvail", "int", ")", "(", "c", "col", ",", "err", "error", ")", "{", "// calculate col...
// getReplicatedFileHCCChange - fetches health color code for metadata // files that are replicated.
[ "getReplicatedFileHCCChange", "-", "fetches", "health", "color", "code", "for", "metadata", "files", "that", "are", "replicated", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/admin-heal-result-item.go#L54-L72
train
minio/mc
cmd/event-list.go
checkEventListSyntax
func checkEventListSyntax(ctx *cli.Context) { if len(ctx.Args()) != 2 && len(ctx.Args()) != 1 { cli.ShowCommandHelpAndExit(ctx, "list", 1) // last argument is exit code } }
go
func checkEventListSyntax(ctx *cli.Context) { if len(ctx.Args()) != 2 && len(ctx.Args()) != 1 { cli.ShowCommandHelpAndExit(ctx, "list", 1) // last argument is exit code } }
[ "func", "checkEventListSyntax", "(", "ctx", "*", "cli", ".", "Context", ")", "{", "if", "len", "(", "ctx", ".", "Args", "(", ")", ")", "!=", "2", "&&", "len", "(", "ctx", ".", "Args", "(", ")", ")", "!=", "1", "{", "cli", ".", "ShowCommandHelpAnd...
// checkEventListSyntax - validate all the passed arguments
[ "checkEventListSyntax", "-", "validate", "all", "the", "passed", "arguments" ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/event-list.go#L59-L63
train
minio/mc
cmd/config-host-add.go
checkConfigHostAddSyntax
func checkConfigHostAddSyntax(ctx *cli.Context) { args := ctx.Args() argsNr := len(args) if argsNr < 4 || argsNr > 5 { fatalIf(errInvalidArgument().Trace(ctx.Args().Tail()...), "Incorrect number of arguments for host add command.") } alias := args.Get(0) url := args.Get(1) accessKey := args.Get(2) secretK...
go
func checkConfigHostAddSyntax(ctx *cli.Context) { args := ctx.Args() argsNr := len(args) if argsNr < 4 || argsNr > 5 { fatalIf(errInvalidArgument().Trace(ctx.Args().Tail()...), "Incorrect number of arguments for host add command.") } alias := args.Get(0) url := args.Get(1) accessKey := args.Get(2) secretK...
[ "func", "checkConfigHostAddSyntax", "(", "ctx", "*", "cli", ".", "Context", ")", "{", "args", ":=", "ctx", ".", "Args", "(", ")", "\n", "argsNr", ":=", "len", "(", "args", ")", "\n", "if", "argsNr", "<", "4", "||", "argsNr", ">", "5", "{", "fatalIf...
// checkConfigHostAddSyntax - verifies input arguments to 'config host add'.
[ "checkConfigHostAddSyntax", "-", "verifies", "input", "arguments", "to", "config", "host", "add", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config-host-add.go#L87-L128
train
minio/mc
cmd/config-host-add.go
addHost
func addHost(alias string, hostCfgV9 hostConfigV9) { mcCfgV9, err := loadMcConfig() fatalIf(err.Trace(globalMCConfigVersion), "Unable to load config `"+mustGetMcConfigPath()+"`.") // Add new host. mcCfgV9.Hosts[alias] = hostCfgV9 err = saveMcConfig(mcCfgV9) fatalIf(err.Trace(alias), "Unable to update hosts in c...
go
func addHost(alias string, hostCfgV9 hostConfigV9) { mcCfgV9, err := loadMcConfig() fatalIf(err.Trace(globalMCConfigVersion), "Unable to load config `"+mustGetMcConfigPath()+"`.") // Add new host. mcCfgV9.Hosts[alias] = hostCfgV9 err = saveMcConfig(mcCfgV9) fatalIf(err.Trace(alias), "Unable to update hosts in c...
[ "func", "addHost", "(", "alias", "string", ",", "hostCfgV9", "hostConfigV9", ")", "{", "mcCfgV9", ",", "err", ":=", "loadMcConfig", "(", ")", "\n", "fatalIf", "(", "err", ".", "Trace", "(", "globalMCConfigVersion", ")", ",", "\"", "\"", "+", "mustGetMcConf...
// addHost - add a host config.
[ "addHost", "-", "add", "a", "host", "config", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config-host-add.go#L131-L150
train
minio/mc
cmd/config-host-add.go
buildS3Config
func buildS3Config(url, accessKey, secretKey, api, lookup string) (*Config, *probe.Error) { s3Config := newS3Config(url, &hostConfigV9{ AccessKey: accessKey, SecretKey: secretKey, URL: url, Lookup: lookup, }) // If api is provided we do not auto probe signature, this is // required in situations ...
go
func buildS3Config(url, accessKey, secretKey, api, lookup string) (*Config, *probe.Error) { s3Config := newS3Config(url, &hostConfigV9{ AccessKey: accessKey, SecretKey: secretKey, URL: url, Lookup: lookup, }) // If api is provided we do not auto probe signature, this is // required in situations ...
[ "func", "buildS3Config", "(", "url", ",", "accessKey", ",", "secretKey", ",", "api", ",", "lookup", "string", ")", "(", "*", "Config", ",", "*", "probe", ".", "Error", ")", "{", "s3Config", ":=", "newS3Config", "(", "url", ",", "&", "hostConfigV9", "{"...
// buildS3Config constructs an S3 Config and does // signature auto-probe when needed.
[ "buildS3Config", "constructs", "an", "S3", "Config", "and", "does", "signature", "auto", "-", "probe", "when", "needed", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config-host-add.go#L198-L222
train
minio/mc
pkg/colorjson/scanner.go
eof
func (s *scanner) eof() int { if s.err != nil { return scanError } if s.endTop { return scanEnd } s.step(s, ' ') if s.endTop { return scanEnd } if s.err == nil { s.err = &SyntaxError{"unexpected end of JSON input", s.bytes} } return scanError }
go
func (s *scanner) eof() int { if s.err != nil { return scanError } if s.endTop { return scanEnd } s.step(s, ' ') if s.endTop { return scanEnd } if s.err == nil { s.err = &SyntaxError{"unexpected end of JSON input", s.bytes} } return scanError }
[ "func", "(", "s", "*", "scanner", ")", "eof", "(", ")", "int", "{", "if", "s", ".", "err", "!=", "nil", "{", "return", "scanError", "\n", "}", "\n", "if", "s", ".", "endTop", "{", "return", "scanEnd", "\n", "}", "\n", "s", ".", "step", "(", "...
// eof tells the scanner that the end of input has been reached. // It returns a scan status just as s.step does.
[ "eof", "tells", "the", "scanner", "that", "the", "end", "of", "input", "has", "been", "reached", ".", "It", "returns", "a", "scan", "status", "just", "as", "s", ".", "step", "does", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/pkg/colorjson/scanner.go#L137-L152
train
minio/mc
pkg/colorjson/scanner.go
stateBeginColorESC
func stateBeginColorESC(s *scanner, c byte) int { switch c { case '[': s.step = stateBeginColorRest return scanContinue } return s.error(c, "in string color escape code") }
go
func stateBeginColorESC(s *scanner, c byte) int { switch c { case '[': s.step = stateBeginColorRest return scanContinue } return s.error(c, "in string color escape code") }
[ "func", "stateBeginColorESC", "(", "s", "*", "scanner", ",", "c", "byte", ")", "int", "{", "switch", "c", "{", "case", "'['", ":", "s", ".", "step", "=", "stateBeginColorRest", "\n", "return", "scanContinue", "\n", "}", "\n", "return", "s", ".", "error...
// stateInStringColorFirst is the state after reading the beginning of a color representation // which is \x1b
[ "stateInStringColorFirst", "is", "the", "state", "after", "reading", "the", "beginning", "of", "a", "color", "representation", "which", "is", "\\", "x1b" ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/pkg/colorjson/scanner.go#L358-L365
train
minio/mc
pkg/colorjson/scanner.go
stateBeginColorRest
func stateBeginColorRest(s *scanner, c byte) int { if c <= ' ' && isSpace(c) { return scanSkipSpace } if '0' <= c && c <= '9' { s.step = stateBeginColorRest return scanContinue } switch c { case ';': s.step = stateBeginColorRest return scanContinue case 'm': s.step = stateBeginValue return scanCont...
go
func stateBeginColorRest(s *scanner, c byte) int { if c <= ' ' && isSpace(c) { return scanSkipSpace } if '0' <= c && c <= '9' { s.step = stateBeginColorRest return scanContinue } switch c { case ';': s.step = stateBeginColorRest return scanContinue case 'm': s.step = stateBeginValue return scanCont...
[ "func", "stateBeginColorRest", "(", "s", "*", "scanner", ",", "c", "byte", ")", "int", "{", "if", "c", "<=", "' '", "&&", "isSpace", "(", "c", ")", "{", "return", "scanSkipSpace", "\n", "}", "\n", "if", "'0'", "<=", "c", "&&", "c", "<=", "'9'", "...
// stateInStringColorSecond is the state after reading the second character of a color representation // which is \x1b[
[ "stateInStringColorSecond", "is", "the", "state", "after", "reading", "the", "second", "character", "of", "a", "color", "representation", "which", "is", "\\", "x1b", "[" ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/pkg/colorjson/scanner.go#L369-L386
train
minio/mc
pkg/colorjson/scanner.go
stateInStringEscU
func stateInStringEscU(s *scanner, c byte) int { if '0' <= c && c <= '9' || 'a' <= c && c <= 'f' || 'A' <= c && c <= 'F' { s.step = stateInStringEscU1 return scanContinue } // numbers return s.error(c, "in \\u hexadecimal character escape") }
go
func stateInStringEscU(s *scanner, c byte) int { if '0' <= c && c <= '9' || 'a' <= c && c <= 'f' || 'A' <= c && c <= 'F' { s.step = stateInStringEscU1 return scanContinue } // numbers return s.error(c, "in \\u hexadecimal character escape") }
[ "func", "stateInStringEscU", "(", "s", "*", "scanner", ",", "c", "byte", ")", "int", "{", "if", "'0'", "<=", "c", "&&", "c", "<=", "'9'", "||", "'a'", "<=", "c", "&&", "c", "<=", "'f'", "||", "'A'", "<=", "c", "&&", "c", "<=", "'F'", "{", "s"...
// stateInStringEscU is the state after reading `"\u` during a quoted string.
[ "stateInStringEscU", "is", "the", "state", "after", "reading", "\\", "u", "during", "a", "quoted", "string", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/pkg/colorjson/scanner.go#L407-L414
train
minio/mc
cmd/admin-info.go
checkAdminInfoSyntax
func checkAdminInfoSyntax(ctx *cli.Context) { if len(ctx.Args()) == 0 || len(ctx.Args()) > 2 { cli.ShowCommandHelpAndExit(ctx, "info", 1) // last argument is exit code } }
go
func checkAdminInfoSyntax(ctx *cli.Context) { if len(ctx.Args()) == 0 || len(ctx.Args()) > 2 { cli.ShowCommandHelpAndExit(ctx, "info", 1) // last argument is exit code } }
[ "func", "checkAdminInfoSyntax", "(", "ctx", "*", "cli", ".", "Context", ")", "{", "if", "len", "(", "ctx", ".", "Args", "(", ")", ")", "==", "0", "||", "len", "(", "ctx", ".", "Args", "(", ")", ")", ">", "2", "{", "cli", ".", "ShowCommandHelpAndE...
// checkAdminInfoSyntax - validate all the passed arguments
[ "checkAdminInfoSyntax", "-", "validate", "all", "the", "passed", "arguments" ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/admin-info.go#L204-L208
train
minio/mc
cmd/session-clear.go
String
func (c clearSessionMessage) String() string { msg := "Session `" + c.SessionID + "`" var colorizedMsg string switch c.Status { case "success": colorizedMsg = console.Colorize("ClearSession", msg+" cleared successfully.") case "forced": colorizedMsg = console.Colorize("ClearSession", msg+" cleared forcefully."...
go
func (c clearSessionMessage) String() string { msg := "Session `" + c.SessionID + "`" var colorizedMsg string switch c.Status { case "success": colorizedMsg = console.Colorize("ClearSession", msg+" cleared successfully.") case "forced": colorizedMsg = console.Colorize("ClearSession", msg+" cleared forcefully."...
[ "func", "(", "c", "clearSessionMessage", ")", "String", "(", ")", "string", "{", "msg", ":=", "\"", "\"", "+", "c", ".", "SessionID", "+", "\"", "\"", "\n", "var", "colorizedMsg", "string", "\n", "switch", "c", ".", "Status", "{", "case", "\"", "\"",...
// String colorized clear session message.
[ "String", "colorized", "clear", "session", "message", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-clear.go#L70-L80
train
minio/mc
cmd/session-clear.go
JSON
func (c clearSessionMessage) JSON() string { clearSessionJSONBytes, e := json.MarshalIndent(c, "", " ") fatalIf(probe.NewError(e), "Unable to marshal into JSON.") return string(clearSessionJSONBytes) }
go
func (c clearSessionMessage) JSON() string { clearSessionJSONBytes, e := json.MarshalIndent(c, "", " ") fatalIf(probe.NewError(e), "Unable to marshal into JSON.") return string(clearSessionJSONBytes) }
[ "func", "(", "c", "clearSessionMessage", ")", "JSON", "(", ")", "string", "{", "clearSessionJSONBytes", ",", "e", ":=", "json", ".", "MarshalIndent", "(", "c", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "fatalIf", "(", "probe", ".", "NewError", "(", ...
// JSON jsonified clear session message.
[ "JSON", "jsonified", "clear", "session", "message", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-clear.go#L83-L88
train
minio/mc
cmd/session-clear.go
clearSession
func clearSession(sid string, isForce bool) { var toRemove []string if sid == "all" { toRemove = getSessionIDs() } else { toRemove = append(toRemove, sid) } for _, sid := range toRemove { session, err := loadSessionV8(sid) if !isForce { fatalIf(err.Trace(sid), "Unable to load session `"+sid+"`. Use --fo...
go
func clearSession(sid string, isForce bool) { var toRemove []string if sid == "all" { toRemove = getSessionIDs() } else { toRemove = append(toRemove, sid) } for _, sid := range toRemove { session, err := loadSessionV8(sid) if !isForce { fatalIf(err.Trace(sid), "Unable to load session `"+sid+"`. Use --fo...
[ "func", "clearSession", "(", "sid", "string", ",", "isForce", "bool", ")", "{", "var", "toRemove", "[", "]", "string", "\n", "if", "sid", "==", "\"", "\"", "{", "toRemove", "=", "getSessionIDs", "(", ")", "\n", "}", "else", "{", "toRemove", "=", "app...
// clearSession clear sessions.
[ "clearSession", "clear", "sessions", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-clear.go#L107-L128
train
minio/mc
cmd/session-clear.go
checkSessionClearSyntax
func checkSessionClearSyntax(ctx *cli.Context) { if len(ctx.Args()) == 0 || len(ctx.Args()) > 2 { cli.ShowCommandHelpAndExit(ctx, "clear", 1) // last argument is exit code } }
go
func checkSessionClearSyntax(ctx *cli.Context) { if len(ctx.Args()) == 0 || len(ctx.Args()) > 2 { cli.ShowCommandHelpAndExit(ctx, "clear", 1) // last argument is exit code } }
[ "func", "checkSessionClearSyntax", "(", "ctx", "*", "cli", ".", "Context", ")", "{", "if", "len", "(", "ctx", ".", "Args", "(", ")", ")", "==", "0", "||", "len", "(", "ctx", ".", "Args", "(", ")", ")", ">", "2", "{", "cli", ".", "ShowCommandHelpA...
// checkSessionClearSyntax - Check syntax of 'session clear sid'.
[ "checkSessionClearSyntax", "-", "Check", "syntax", "of", "session", "clear", "sid", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-clear.go#L131-L135
train
minio/mc
cmd/session-clear.go
mainSessionClear
func mainSessionClear(ctx *cli.Context) error { // Check command arguments checkSessionClearSyntax(ctx) // Additional command specific theme customization. console.SetColor("Command", color.New(color.FgWhite, color.Bold)) console.SetColor("SessionID", color.New(color.FgYellow, color.Bold)) console.SetColor("Sess...
go
func mainSessionClear(ctx *cli.Context) error { // Check command arguments checkSessionClearSyntax(ctx) // Additional command specific theme customization. console.SetColor("Command", color.New(color.FgWhite, color.Bold)) console.SetColor("SessionID", color.New(color.FgYellow, color.Bold)) console.SetColor("Sess...
[ "func", "mainSessionClear", "(", "ctx", "*", "cli", ".", "Context", ")", "error", "{", "// Check command arguments", "checkSessionClearSyntax", "(", "ctx", ")", "\n\n", "// Additional command specific theme customization.", "console", ".", "SetColor", "(", "\"", "\"", ...
// mainSessionClear - Main session clear.
[ "mainSessionClear", "-", "Main", "session", "clear", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-clear.go#L138-L160
train
minio/mc
cmd/admin-monitor.go
checkAdminMonitorSyntax
func checkAdminMonitorSyntax(ctx *cli.Context) { if len(ctx.Args()) == 0 || len(ctx.Args()) > 1 { exit := globalErrorExitStatus cli.ShowCommandHelpAndExit(ctx, "monitor", exit) } }
go
func checkAdminMonitorSyntax(ctx *cli.Context) { if len(ctx.Args()) == 0 || len(ctx.Args()) > 1 { exit := globalErrorExitStatus cli.ShowCommandHelpAndExit(ctx, "monitor", exit) } }
[ "func", "checkAdminMonitorSyntax", "(", "ctx", "*", "cli", ".", "Context", ")", "{", "if", "len", "(", "ctx", ".", "Args", "(", ")", ")", "==", "0", "||", "len", "(", "ctx", ".", "Args", "(", ")", ")", ">", "1", "{", "exit", ":=", "globalErrorExi...
// checkAdminMonitorSyntax - validate all the passed arguments
[ "checkAdminMonitorSyntax", "-", "validate", "all", "the", "passed", "arguments" ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/admin-monitor.go#L246-L252
train
minio/mc
cmd/client-admin.go
newAdminFactory
func newAdminFactory() func(config *Config) (*madmin.AdminClient, *probe.Error) { clientCache := make(map[uint32]*madmin.AdminClient) mutex := &sync.Mutex{} // Return New function. return func(config *Config) (*madmin.AdminClient, *probe.Error) { // Creates a parsed URL. targetURL, e := url.Parse(config.HostUR...
go
func newAdminFactory() func(config *Config) (*madmin.AdminClient, *probe.Error) { clientCache := make(map[uint32]*madmin.AdminClient) mutex := &sync.Mutex{} // Return New function. return func(config *Config) (*madmin.AdminClient, *probe.Error) { // Creates a parsed URL. targetURL, e := url.Parse(config.HostUR...
[ "func", "newAdminFactory", "(", ")", "func", "(", "config", "*", "Config", ")", "(", "*", "madmin", ".", "AdminClient", ",", "*", "probe", ".", "Error", ")", "{", "clientCache", ":=", "make", "(", "map", "[", "uint32", "]", "*", "madmin", ".", "Admin...
// newAdminFactory encloses New function with client cache.
[ "newAdminFactory", "encloses", "New", "function", "with", "client", "cache", "." ]
f0f156aca82e451c80b05d5be8eb01a04fee29dd
https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-admin.go#L35-L109
train