id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
137,100 | danryan/hal | adapter.go | RegisterAdapter | func RegisterAdapter(name string, newFunc func(*Robot) (Adapter, error)) {
AvailableAdapters[name] = adapter{
name: name,
newFunc: newFunc,
}
} | go | func RegisterAdapter(name string, newFunc func(*Robot) (Adapter, error)) {
AvailableAdapters[name] = adapter{
name: name,
newFunc: newFunc,
}
} | [
"func",
"RegisterAdapter",
"(",
"name",
"string",
",",
"newFunc",
"func",
"(",
"*",
"Robot",
")",
"(",
"Adapter",
",",
"error",
")",
")",
"{",
"AvailableAdapters",
"[",
"name",
"]",
"=",
"adapter",
"{",
"name",
":",
"name",
",",
"newFunc",
":",
"newFun... | // RegisterAdapter registers an adapter | [
"RegisterAdapter",
"registers",
"an",
"adapter"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/adapter.go#L48-L53 |
137,101 | danryan/hal | adapter/shell/shell.go | Run | func (a *adapter) Run() error {
prompt()
go func() {
for {
line, _, err := a.in.ReadLine()
message := a.newMessage(string(line))
if err != nil {
if err == io.EOF {
break
// a.Robot.signalChan <- syscall.SIGTERM
}
fmt.Println("error:", err)
}
a.Receive(message)
prompt()
}
... | go | func (a *adapter) Run() error {
prompt()
go func() {
for {
line, _, err := a.in.ReadLine()
message := a.newMessage(string(line))
if err != nil {
if err == io.EOF {
break
// a.Robot.signalChan <- syscall.SIGTERM
}
fmt.Println("error:", err)
}
a.Receive(message)
prompt()
}
... | [
"func",
"(",
"a",
"*",
"adapter",
")",
"Run",
"(",
")",
"error",
"{",
"prompt",
"(",
")",
"\n\n",
"go",
"func",
"(",
")",
"{",
"for",
"{",
"line",
",",
"_",
",",
"err",
":=",
"a",
".",
"in",
".",
"ReadLine",
"(",
")",
"\n",
"message",
":=",
... | // Run executes the adapter run loop | [
"Run",
"executes",
"the",
"adapter",
"run",
"loop"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/adapter/shell/shell.go#L84-L106 |
137,102 | danryan/hal | adapter/irc/irc.go | Stop | func (a *adapter) Stop() error {
hal.Logger.Debug("irc - stopping IRC connection")
a.stopIRCConnection()
hal.Logger.Debug("irc - stopped IRC connection")
return nil
} | go | func (a *adapter) Stop() error {
hal.Logger.Debug("irc - stopping IRC connection")
a.stopIRCConnection()
hal.Logger.Debug("irc - stopped IRC connection")
return nil
} | [
"func",
"(",
"a",
"*",
"adapter",
")",
"Stop",
"(",
")",
"error",
"{",
"hal",
".",
"Logger",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"a",
".",
"stopIRCConnection",
"(",
")",
"\n",
"hal",
".",
"Logger",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n\... | // Stop shuts down the adapter | [
"Stop",
"shuts",
"down",
"the",
"adapter"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/adapter/irc/irc.go#L124-L130 |
137,103 | danryan/hal | config.go | newRouter | func newRouter() *http.ServeMux {
router := http.NewServeMux()
router.HandleFunc("/hal/ping", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "PONG")
})
router.HandleFunc("/hal/time", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Server time is: %s\n", time.Now().UTC())
})
re... | go | func newRouter() *http.ServeMux {
router := http.NewServeMux()
router.HandleFunc("/hal/ping", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "PONG")
})
router.HandleFunc("/hal/time", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Server time is: %s\n", time.Now().UTC())
})
re... | [
"func",
"newRouter",
"(",
")",
"*",
"http",
".",
"ServeMux",
"{",
"router",
":=",
"http",
".",
"NewServeMux",
"(",
")",
"\n",
"router",
".",
"HandleFunc",
"(",
"\"",
"\"",
",",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
... | // newRouter initializes a new http.ServeMux and sets up several default routes | [
"newRouter",
"initializes",
"a",
"new",
"http",
".",
"ServeMux",
"and",
"sets",
"up",
"several",
"default",
"routes"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/config.go#L40-L51 |
137,104 | danryan/hal | handler.go | NewHandler | func NewHandler(h interface{}) (handler, error) {
switch v := h.(type) {
case fullHandler:
return &FullHandler{handler: v}, nil
case handler:
return v, nil
default:
return nil, fmt.Errorf("%v does not implement the handler interface", v)
}
} | go | func NewHandler(h interface{}) (handler, error) {
switch v := h.(type) {
case fullHandler:
return &FullHandler{handler: v}, nil
case handler:
return v, nil
default:
return nil, fmt.Errorf("%v does not implement the handler interface", v)
}
} | [
"func",
"NewHandler",
"(",
"h",
"interface",
"{",
"}",
")",
"(",
"handler",
",",
"error",
")",
"{",
"switch",
"v",
":=",
"h",
".",
"(",
"type",
")",
"{",
"case",
"fullHandler",
":",
"return",
"&",
"FullHandler",
"{",
"handler",
":",
"v",
"}",
",",
... | // NewHandler checks whether h implements the handler interface, wrapping it in a FullHandler | [
"NewHandler",
"checks",
"whether",
"h",
"implements",
"the",
"handler",
"interface",
"wrapping",
"it",
"in",
"a",
"FullHandler"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/handler.go#L39-L48 |
137,105 | danryan/hal | hal.go | Hear | func Hear(pattern string, fn func(res *Response) error) handler {
return &Handler{Method: HEAR, Pattern: pattern, Run: fn}
} | go | func Hear(pattern string, fn func(res *Response) error) handler {
return &Handler{Method: HEAR, Pattern: pattern, Run: fn}
} | [
"func",
"Hear",
"(",
"pattern",
"string",
",",
"fn",
"func",
"(",
"res",
"*",
"Response",
")",
"error",
")",
"handler",
"{",
"return",
"&",
"Handler",
"{",
"Method",
":",
"HEAR",
",",
"Pattern",
":",
"pattern",
",",
"Run",
":",
"fn",
"}",
"\n",
"}"... | // Hear a message | [
"Hear",
"a",
"message"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/hal.go#L27-L29 |
137,106 | danryan/hal | hal.go | Respond | func Respond(pattern string, fn func(res *Response) error) handler {
return &Handler{Method: RESPOND, Pattern: pattern, Run: fn}
} | go | func Respond(pattern string, fn func(res *Response) error) handler {
return &Handler{Method: RESPOND, Pattern: pattern, Run: fn}
} | [
"func",
"Respond",
"(",
"pattern",
"string",
",",
"fn",
"func",
"(",
"res",
"*",
"Response",
")",
"error",
")",
"handler",
"{",
"return",
"&",
"Handler",
"{",
"Method",
":",
"RESPOND",
",",
"Pattern",
":",
"pattern",
",",
"Run",
":",
"fn",
"}",
"\n",... | // Respond creates a new listener for Respond messages | [
"Respond",
"creates",
"a",
"new",
"listener",
"for",
"Respond",
"messages"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/hal.go#L32-L34 |
137,107 | danryan/hal | hal.go | Topic | func Topic(pattern string, fn func(res *Response) error) handler {
return &Handler{Method: TOPIC, Run: fn}
} | go | func Topic(pattern string, fn func(res *Response) error) handler {
return &Handler{Method: TOPIC, Run: fn}
} | [
"func",
"Topic",
"(",
"pattern",
"string",
",",
"fn",
"func",
"(",
"res",
"*",
"Response",
")",
"error",
")",
"handler",
"{",
"return",
"&",
"Handler",
"{",
"Method",
":",
"TOPIC",
",",
"Run",
":",
"fn",
"}",
"\n",
"}"
] | // Topic returns a new listener for Topic messages | [
"Topic",
"returns",
"a",
"new",
"listener",
"for",
"Topic",
"messages"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/hal.go#L37-L39 |
137,108 | danryan/hal | hal.go | Enter | func Enter(fn func(res *Response) error) handler {
return &Handler{Method: ENTER, Run: fn}
} | go | func Enter(fn func(res *Response) error) handler {
return &Handler{Method: ENTER, Run: fn}
} | [
"func",
"Enter",
"(",
"fn",
"func",
"(",
"res",
"*",
"Response",
")",
"error",
")",
"handler",
"{",
"return",
"&",
"Handler",
"{",
"Method",
":",
"ENTER",
",",
"Run",
":",
"fn",
"}",
"\n",
"}"
] | // Enter returns a new listener for Enter messages | [
"Enter",
"returns",
"a",
"new",
"listener",
"for",
"Enter",
"messages"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/hal.go#L42-L44 |
137,109 | danryan/hal | hal.go | Leave | func Leave(fn func(res *Response) error) handler {
return &Handler{Method: LEAVE, Run: fn}
} | go | func Leave(fn func(res *Response) error) handler {
return &Handler{Method: LEAVE, Run: fn}
} | [
"func",
"Leave",
"(",
"fn",
"func",
"(",
"res",
"*",
"Response",
")",
"error",
")",
"handler",
"{",
"return",
"&",
"Handler",
"{",
"Method",
":",
"LEAVE",
",",
"Run",
":",
"fn",
"}",
"\n",
"}"
] | // Leave creates a new listener for Leave messages | [
"Leave",
"creates",
"a",
"new",
"listener",
"for",
"Leave",
"messages"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/hal.go#L47-L49 |
137,110 | danryan/hal | robot.go | NewRobot | func NewRobot() (*Robot, error) {
robot := &Robot{
Name: Config.Name,
Alias: Config.Alias,
signalChan: make(chan os.Signal, 1),
}
adapter, err := NewAdapter(robot)
if err != nil {
Logger.Error(err)
return nil, err
}
robot.SetAdapter(adapter)
store, err := NewStore(robot)
if err != nil {
... | go | func NewRobot() (*Robot, error) {
robot := &Robot{
Name: Config.Name,
Alias: Config.Alias,
signalChan: make(chan os.Signal, 1),
}
adapter, err := NewAdapter(robot)
if err != nil {
Logger.Error(err)
return nil, err
}
robot.SetAdapter(adapter)
store, err := NewStore(robot)
if err != nil {
... | [
"func",
"NewRobot",
"(",
")",
"(",
"*",
"Robot",
",",
"error",
")",
"{",
"robot",
":=",
"&",
"Robot",
"{",
"Name",
":",
"Config",
".",
"Name",
",",
"Alias",
":",
"Config",
".",
"Alias",
",",
"signalChan",
":",
"make",
"(",
"chan",
"os",
".",
"Sig... | // NewRobot returns a new Robot instance | [
"NewRobot",
"returns",
"a",
"new",
"Robot",
"instance"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/robot.go#L29-L54 |
137,111 | danryan/hal | robot.go | Handle | func (robot *Robot) Handle(handlers ...interface{}) {
for _, h := range handlers {
nh, err := NewHandler(h)
if err != nil {
Logger.Fatal(err)
panic(err)
}
robot.handlers = append(robot.handlers, nh)
}
} | go | func (robot *Robot) Handle(handlers ...interface{}) {
for _, h := range handlers {
nh, err := NewHandler(h)
if err != nil {
Logger.Fatal(err)
panic(err)
}
robot.handlers = append(robot.handlers, nh)
}
} | [
"func",
"(",
"robot",
"*",
"Robot",
")",
"Handle",
"(",
"handlers",
"...",
"interface",
"{",
"}",
")",
"{",
"for",
"_",
",",
"h",
":=",
"range",
"handlers",
"{",
"nh",
",",
"err",
":=",
"NewHandler",
"(",
"h",
")",
"\n",
"if",
"err",
"!=",
"nil",... | // Handle registers a new handler with the robot | [
"Handle",
"registers",
"a",
"new",
"handler",
"with",
"the",
"robot"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/robot.go#L57-L67 |
137,112 | danryan/hal | robot.go | Receive | func (robot *Robot) Receive(msg *Message) error {
Logger.Debugf("%s - robot received message", Config.AdapterName)
// check if we've seen this user yet, and add if we haven't.
user := msg.User
if _, err := robot.Users.Get(user.ID); err != nil {
Logger.Debug(err)
robot.Users.Set(user.ID, user)
robot.Users.Sav... | go | func (robot *Robot) Receive(msg *Message) error {
Logger.Debugf("%s - robot received message", Config.AdapterName)
// check if we've seen this user yet, and add if we haven't.
user := msg.User
if _, err := robot.Users.Get(user.ID); err != nil {
Logger.Debug(err)
robot.Users.Set(user.ID, user)
robot.Users.Sav... | [
"func",
"(",
"robot",
"*",
"Robot",
")",
"Receive",
"(",
"msg",
"*",
"Message",
")",
"error",
"{",
"Logger",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"Config",
".",
"AdapterName",
")",
"\n\n",
"// check if we've seen this user yet, and add if we haven't.",
"user",
... | // Receive dispatches messages to our handlers | [
"Receive",
"dispatches",
"messages",
"to",
"our",
"handlers"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/robot.go#L70-L90 |
137,113 | danryan/hal | robot.go | Run | func (robot *Robot) Run() error {
Logger.Info("starting robot")
// HACK
Logger.Debugf("opening %s store connection", Config.StoreName)
go func() {
robot.Store.Open()
Logger.Debug("loading users from store")
robot.Users.Load()
}()
Logger.Debugf("starting %s adapter", Config.AdapterName)
go robot.Adapter.... | go | func (robot *Robot) Run() error {
Logger.Info("starting robot")
// HACK
Logger.Debugf("opening %s store connection", Config.StoreName)
go func() {
robot.Store.Open()
Logger.Debug("loading users from store")
robot.Users.Load()
}()
Logger.Debugf("starting %s adapter", Config.AdapterName)
go robot.Adapter.... | [
"func",
"(",
"robot",
"*",
"Robot",
")",
"Run",
"(",
")",
"error",
"{",
"Logger",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"// HACK",
"Logger",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"Config",
".",
"StoreName",
")",
"\n",
"go",
"func",
"(",
")",
... | // Run initiates the startup process | [
"Run",
"initiates",
"the",
"startup",
"process"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/robot.go#L93-L136 |
137,114 | danryan/hal | robot.go | Stop | func (robot *Robot) Stop() error {
Logger.Info() // so we don't break up the log formatting when running interactively ;)
Logger.Debugf("stopping %s adapter", Config.AdapterName)
if err := robot.Adapter.Stop(); err != nil {
return err
}
Logger.Debugf("closing %s store connection", Config.StoreName)
if err := ... | go | func (robot *Robot) Stop() error {
Logger.Info() // so we don't break up the log formatting when running interactively ;)
Logger.Debugf("stopping %s adapter", Config.AdapterName)
if err := robot.Adapter.Stop(); err != nil {
return err
}
Logger.Debugf("closing %s store connection", Config.StoreName)
if err := ... | [
"func",
"(",
"robot",
"*",
"Robot",
")",
"Stop",
"(",
")",
"error",
"{",
"Logger",
".",
"Info",
"(",
")",
"// so we don't break up the log formatting when running interactively ;)",
"\n\n",
"Logger",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"Config",
".",
"AdapterNa... | // Stop initiates the shutdown process | [
"Stop",
"initiates",
"the",
"shutdown",
"process"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/robot.go#L139-L154 |
137,115 | danryan/hal | user.go | NewUserMap | func NewUserMap(robot *Robot) *UserMap {
return &UserMap{
Map: make(map[string]User, 0),
robot: robot,
}
} | go | func NewUserMap(robot *Robot) *UserMap {
return &UserMap{
Map: make(map[string]User, 0),
robot: robot,
}
} | [
"func",
"NewUserMap",
"(",
"robot",
"*",
"Robot",
")",
"*",
"UserMap",
"{",
"return",
"&",
"UserMap",
"{",
"Map",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"User",
",",
"0",
")",
",",
"robot",
":",
"robot",
",",
"}",
"\n",
"}"
] | // NewUserMap returns an initialized UserMap | [
"NewUserMap",
"returns",
"an",
"initialized",
"UserMap"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/user.go#L39-L44 |
137,116 | danryan/hal | user.go | All | func (um *UserMap) All() []User {
um.Lock()
users := make([]User, len(um.Map))
for _, user := range um.Map {
users = append(users, user)
}
um.Unlock()
return users
} | go | func (um *UserMap) All() []User {
um.Lock()
users := make([]User, len(um.Map))
for _, user := range um.Map {
users = append(users, user)
}
um.Unlock()
return users
} | [
"func",
"(",
"um",
"*",
"UserMap",
")",
"All",
"(",
")",
"[",
"]",
"User",
"{",
"um",
".",
"Lock",
"(",
")",
"\n\n",
"users",
":=",
"make",
"(",
"[",
"]",
"User",
",",
"len",
"(",
"um",
".",
"Map",
")",
")",
"\n",
"for",
"_",
",",
"user",
... | // All returns the underlying map of all users | [
"All",
"returns",
"the",
"underlying",
"map",
"of",
"all",
"users"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/user.go#L47-L57 |
137,117 | danryan/hal | user.go | Get | func (um *UserMap) Get(id string) (User, error) {
um.Lock()
defer um.Unlock()
user, ok := um.Map[id]
if !ok {
return User{}, fmt.Errorf("could not find user with id %s", id)
}
return user, nil
} | go | func (um *UserMap) Get(id string) (User, error) {
um.Lock()
defer um.Unlock()
user, ok := um.Map[id]
if !ok {
return User{}, fmt.Errorf("could not find user with id %s", id)
}
return user, nil
} | [
"func",
"(",
"um",
"*",
"UserMap",
")",
"Get",
"(",
"id",
"string",
")",
"(",
"User",
",",
"error",
")",
"{",
"um",
".",
"Lock",
"(",
")",
"\n",
"defer",
"um",
".",
"Unlock",
"(",
")",
"\n\n",
"user",
",",
"ok",
":=",
"um",
".",
"Map",
"[",
... | // Get looks up a user by id and returns a User object | [
"Get",
"looks",
"up",
"a",
"user",
"by",
"id",
"and",
"returns",
"a",
"User",
"object"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/user.go#L60-L69 |
137,118 | danryan/hal | user.go | GetByName | func (um *UserMap) GetByName(name string) (User, error) {
um.Lock()
defer um.Unlock()
for _, user := range um.Map {
if user.Name == name {
if user.Options == nil {
user.Options = make(map[string]interface{})
}
return user, nil
}
}
return User{Options: make(map[string]interface{})}, fmt.Errorf("co... | go | func (um *UserMap) GetByName(name string) (User, error) {
um.Lock()
defer um.Unlock()
for _, user := range um.Map {
if user.Name == name {
if user.Options == nil {
user.Options = make(map[string]interface{})
}
return user, nil
}
}
return User{Options: make(map[string]interface{})}, fmt.Errorf("co... | [
"func",
"(",
"um",
"*",
"UserMap",
")",
"GetByName",
"(",
"name",
"string",
")",
"(",
"User",
",",
"error",
")",
"{",
"um",
".",
"Lock",
"(",
")",
"\n",
"defer",
"um",
".",
"Unlock",
"(",
")",
"\n\n",
"for",
"_",
",",
"user",
":=",
"range",
"um... | // GetByName looks up a user by name and returns a User object | [
"GetByName",
"looks",
"up",
"a",
"user",
"by",
"name",
"and",
"returns",
"a",
"User",
"object"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/user.go#L72-L85 |
137,119 | danryan/hal | user.go | Set | func (um *UserMap) Set(id string, user User) error {
um.Lock()
// initialize user.Options if nothing's in there yet
if user.Options == nil {
user.Options = make(map[string]interface{})
}
um.Map[id] = user
if err := um.Save(); err != nil {
um.Unlock()
return err
}
um.Unlock()
return nil
} | go | func (um *UserMap) Set(id string, user User) error {
um.Lock()
// initialize user.Options if nothing's in there yet
if user.Options == nil {
user.Options = make(map[string]interface{})
}
um.Map[id] = user
if err := um.Save(); err != nil {
um.Unlock()
return err
}
um.Unlock()
return nil
} | [
"func",
"(",
"um",
"*",
"UserMap",
")",
"Set",
"(",
"id",
"string",
",",
"user",
"User",
")",
"error",
"{",
"um",
".",
"Lock",
"(",
")",
"\n\n",
"// initialize user.Options if nothing's in there yet",
"if",
"user",
".",
"Options",
"==",
"nil",
"{",
"user",... | // Set adds or updates a user in the UserMap and persists it to the store | [
"Set",
"adds",
"or",
"updates",
"a",
"user",
"in",
"the",
"UserMap",
"and",
"persists",
"it",
"to",
"the",
"store"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/user.go#L88-L103 |
137,120 | danryan/hal | user.go | Encode | func (um *UserMap) Encode() ([]byte, error) {
data, err := json.Marshal(um.Map)
if err != nil {
return []byte{}, err
}
return data, err
} | go | func (um *UserMap) Encode() ([]byte, error) {
data, err := json.Marshal(um.Map)
if err != nil {
return []byte{}, err
}
return data, err
} | [
"func",
"(",
"um",
"*",
"UserMap",
")",
"Encode",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"um",
".",
"Map",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"[",
"]",
... | // Encode marshals a UserMap to JSON | [
"Encode",
"marshals",
"a",
"UserMap",
"to",
"JSON"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/user.go#L106-L112 |
137,121 | danryan/hal | user.go | Decode | func (um *UserMap) Decode() (map[string]User, error) {
data, err := um.robot.Store.Get("users")
if err != nil {
return nil, err
}
users := map[string]User{}
if err := json.Unmarshal(data, &users); err != nil {
return users, err
}
return users, nil
} | go | func (um *UserMap) Decode() (map[string]User, error) {
data, err := um.robot.Store.Get("users")
if err != nil {
return nil, err
}
users := map[string]User{}
if err := json.Unmarshal(data, &users); err != nil {
return users, err
}
return users, nil
} | [
"func",
"(",
"um",
"*",
"UserMap",
")",
"Decode",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"User",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"um",
".",
"robot",
".",
"Store",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",... | // Decode unmarshals a JSON object into a map of strings to Users | [
"Decode",
"unmarshals",
"a",
"JSON",
"object",
"into",
"a",
"map",
"of",
"strings",
"to",
"Users"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/user.go#L115-L127 |
137,122 | danryan/hal | user.go | Load | func (um *UserMap) Load() error {
um.Lock()
data, err := um.Decode()
if err != nil {
um.Unlock()
return err
}
um.Map = data
um.Unlock()
return nil
} | go | func (um *UserMap) Load() error {
um.Lock()
data, err := um.Decode()
if err != nil {
um.Unlock()
return err
}
um.Map = data
um.Unlock()
return nil
} | [
"func",
"(",
"um",
"*",
"UserMap",
")",
"Load",
"(",
")",
"error",
"{",
"um",
".",
"Lock",
"(",
")",
"\n\n",
"data",
",",
"err",
":=",
"um",
".",
"Decode",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"um",
".",
"Unlock",
"(",
")",
"\n",
... | // Load retrieves known users from the store and populates the UserMap | [
"Load",
"retrieves",
"known",
"users",
"from",
"the",
"store",
"and",
"populates",
"the",
"UserMap"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/user.go#L130-L143 |
137,123 | danryan/hal | user.go | Save | func (um *UserMap) Save() error {
data, err := um.Encode()
if err != nil {
return err
}
return um.robot.Store.Set("users", data)
} | go | func (um *UserMap) Save() error {
data, err := um.Encode()
if err != nil {
return err
}
return um.robot.Store.Set("users", data)
} | [
"func",
"(",
"um",
"*",
"UserMap",
")",
"Save",
"(",
")",
"error",
"{",
"data",
",",
"err",
":=",
"um",
".",
"Encode",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"um",
".",
"robot",
".",
"Store"... | // Save persists known users to the store | [
"Save",
"persists",
"known",
"users",
"to",
"the",
"store"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/user.go#L146-L153 |
137,124 | danryan/hal | response.go | NewResponseFromMessage | func NewResponseFromMessage(robot *Robot, msg *Message) *Response {
return &Response{
Robot: robot,
Envelope: &Envelope{
Room: msg.Room,
User: &msg.User,
},
Message: msg,
}
} | go | func NewResponseFromMessage(robot *Robot, msg *Message) *Response {
return &Response{
Robot: robot,
Envelope: &Envelope{
Room: msg.Room,
User: &msg.User,
},
Message: msg,
}
} | [
"func",
"NewResponseFromMessage",
"(",
"robot",
"*",
"Robot",
",",
"msg",
"*",
"Message",
")",
"*",
"Response",
"{",
"return",
"&",
"Response",
"{",
"Robot",
":",
"robot",
",",
"Envelope",
":",
"&",
"Envelope",
"{",
"Room",
":",
"msg",
".",
"Room",
","... | // NewResponseFromMessage returns a new Response object with an associated Message | [
"NewResponseFromMessage",
"returns",
"a",
"new",
"Response",
"object",
"with",
"an",
"associated",
"Message"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/response.go#L27-L36 |
137,125 | danryan/hal | response.go | Send | func (res *Response) Send(strings ...string) error {
if err := res.Robot.Adapter.Send(res, strings...); err != nil {
Logger.Error(err)
return err
}
return nil
} | go | func (res *Response) Send(strings ...string) error {
if err := res.Robot.Adapter.Send(res, strings...); err != nil {
Logger.Error(err)
return err
}
return nil
} | [
"func",
"(",
"res",
"*",
"Response",
")",
"Send",
"(",
"strings",
"...",
"string",
")",
"error",
"{",
"if",
"err",
":=",
"res",
".",
"Robot",
".",
"Adapter",
".",
"Send",
"(",
"res",
",",
"strings",
"...",
")",
";",
"err",
"!=",
"nil",
"{",
"Logg... | // Send posts a message back to the chat source | [
"Send",
"posts",
"a",
"message",
"back",
"to",
"the",
"chat",
"source"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/response.go#L72-L78 |
137,126 | danryan/hal | store.go | RegisterStore | func RegisterStore(name string, newFunc func(*Robot) (Store, error)) {
Stores[name] = store{
name: name,
newFunc: newFunc,
}
} | go | func RegisterStore(name string, newFunc func(*Robot) (Store, error)) {
Stores[name] = store{
name: name,
newFunc: newFunc,
}
} | [
"func",
"RegisterStore",
"(",
"name",
"string",
",",
"newFunc",
"func",
"(",
"*",
"Robot",
")",
"(",
"Store",
",",
"error",
")",
")",
"{",
"Stores",
"[",
"name",
"]",
"=",
"store",
"{",
"name",
":",
"name",
",",
"newFunc",
":",
"newFunc",
",",
"}",... | // RegisterStore registers a new store | [
"RegisterStore",
"registers",
"a",
"new",
"store"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/store.go#L35-L40 |
137,127 | danryan/hal | store.go | NewStore | func NewStore(robot *Robot) (Store, error) {
name := Config.StoreName
if _, ok := Stores[name]; !ok {
return nil, fmt.Errorf("%s is not a registered store", Config.StoreName)
}
store, err := Stores[name].newFunc(robot)
if err != nil {
return nil, err
}
return store, nil
} | go | func NewStore(robot *Robot) (Store, error) {
name := Config.StoreName
if _, ok := Stores[name]; !ok {
return nil, fmt.Errorf("%s is not a registered store", Config.StoreName)
}
store, err := Stores[name].newFunc(robot)
if err != nil {
return nil, err
}
return store, nil
} | [
"func",
"NewStore",
"(",
"robot",
"*",
"Robot",
")",
"(",
"Store",
",",
"error",
")",
"{",
"name",
":=",
"Config",
".",
"StoreName",
"\n",
"if",
"_",
",",
"ok",
":=",
"Stores",
"[",
"name",
"]",
";",
"!",
"ok",
"{",
"return",
"nil",
",",
"fmt",
... | // NewStore returns an initialized store | [
"NewStore",
"returns",
"an",
"initialized",
"store"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/store.go#L43-L54 |
137,128 | danryan/hal | auth.go | UserHasRole | func UserHasRole(res *Response, role string) bool {
user := res.Envelope.User
for _, r := range user.Roles {
if r == role {
return true
}
}
return false
} | go | func UserHasRole(res *Response, role string) bool {
user := res.Envelope.User
for _, r := range user.Roles {
if r == role {
return true
}
}
return false
} | [
"func",
"UserHasRole",
"(",
"res",
"*",
"Response",
",",
"role",
"string",
")",
"bool",
"{",
"user",
":=",
"res",
".",
"Envelope",
".",
"User",
"\n",
"for",
"_",
",",
"r",
":=",
"range",
"user",
".",
"Roles",
"{",
"if",
"r",
"==",
"role",
"{",
"r... | // UserHasRole determines whether the Response's user has a given role | [
"UserHasRole",
"determines",
"whether",
"the",
"Response",
"s",
"user",
"has",
"a",
"given",
"role"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/auth.go#L10-L19 |
137,129 | danryan/hal | auth.go | NewAuth | func NewAuth(r *Robot) *Auth {
a := &Auth{robot: r}
c := &authConfig{}
env.MustProcess(c)
if c.Enabled {
if c.Admins != "" {
a.admins = strings.Split(c.Admins, ",")
}
r.Handle(
addUserRoleHandler,
removeUserRoleHandler,
listUserRolesHandler,
listAdminsHandler,
)
}
return a
} | go | func NewAuth(r *Robot) *Auth {
a := &Auth{robot: r}
c := &authConfig{}
env.MustProcess(c)
if c.Enabled {
if c.Admins != "" {
a.admins = strings.Split(c.Admins, ",")
}
r.Handle(
addUserRoleHandler,
removeUserRoleHandler,
listUserRolesHandler,
listAdminsHandler,
)
}
return a
} | [
"func",
"NewAuth",
"(",
"r",
"*",
"Robot",
")",
"*",
"Auth",
"{",
"a",
":=",
"&",
"Auth",
"{",
"robot",
":",
"r",
"}",
"\n\n",
"c",
":=",
"&",
"authConfig",
"{",
"}",
"\n",
"env",
".",
"MustProcess",
"(",
"c",
")",
"\n\n",
"if",
"c",
".",
"En... | // NewAuth returns a pointer to an initialized Auth | [
"NewAuth",
"returns",
"a",
"pointer",
"to",
"an",
"initialized",
"Auth"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/auth.go#L33-L53 |
137,130 | danryan/hal | auth.go | Admins | func (a *Auth) Admins() (admins []User) {
for _, name := range a.admins {
user, err := a.robot.Users.GetByName(name)
if err != nil {
continue
}
admins = append(admins, user)
}
return
} | go | func (a *Auth) Admins() (admins []User) {
for _, name := range a.admins {
user, err := a.robot.Users.GetByName(name)
if err != nil {
continue
}
admins = append(admins, user)
}
return
} | [
"func",
"(",
"a",
"*",
"Auth",
")",
"Admins",
"(",
")",
"(",
"admins",
"[",
"]",
"User",
")",
"{",
"for",
"_",
",",
"name",
":=",
"range",
"a",
".",
"admins",
"{",
"user",
",",
"err",
":=",
"a",
".",
"robot",
".",
"Users",
".",
"GetByName",
"... | // Admins returns a slice of admin Users | [
"Admins",
"returns",
"a",
"slice",
"of",
"admin",
"Users"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/auth.go#L56-L66 |
137,131 | danryan/hal | auth.go | UsersWithRole | func (a *Auth) UsersWithRole(role string) (users []User) {
for _, user := range a.robot.Users.All() {
if a.HasRole(user.ID, role) {
users = append(users, user)
}
}
return
} | go | func (a *Auth) UsersWithRole(role string) (users []User) {
for _, user := range a.robot.Users.All() {
if a.HasRole(user.ID, role) {
users = append(users, user)
}
}
return
} | [
"func",
"(",
"a",
"*",
"Auth",
")",
"UsersWithRole",
"(",
"role",
"string",
")",
"(",
"users",
"[",
"]",
"User",
")",
"{",
"for",
"_",
",",
"user",
":=",
"range",
"a",
".",
"robot",
".",
"Users",
".",
"All",
"(",
")",
"{",
"if",
"a",
".",
"Ha... | // UsersWithRole returns a slice of Users that have a given role | [
"UsersWithRole",
"returns",
"a",
"slice",
"of",
"Users",
"that",
"have",
"a",
"given",
"role"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/auth.go#L91-L98 |
137,132 | danryan/hal | auth.go | AddRole | func (a *Auth) AddRole(user User, r string) error {
if r == "admin" {
return fmt.Errorf(`the "admin" role can only be defined by the HAL_AUTH_ADMIN environment variable`)
}
if a.HasRole(user.ID, r) {
return fmt.Errorf("%s already has the %s role", user.Name, r)
}
user.Roles = append(user.Roles, r)
a.robot.U... | go | func (a *Auth) AddRole(user User, r string) error {
if r == "admin" {
return fmt.Errorf(`the "admin" role can only be defined by the HAL_AUTH_ADMIN environment variable`)
}
if a.HasRole(user.ID, r) {
return fmt.Errorf("%s already has the %s role", user.Name, r)
}
user.Roles = append(user.Roles, r)
a.robot.U... | [
"func",
"(",
"a",
"*",
"Auth",
")",
"AddRole",
"(",
"user",
"User",
",",
"r",
"string",
")",
"error",
"{",
"if",
"r",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"`the \"admin\" role can only be defined by the HAL_AUTH_ADMIN environment variable`... | // AddRole adds a role to a User | [
"AddRole",
"adds",
"a",
"role",
"to",
"a",
"User"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/auth.go#L101-L114 |
137,133 | danryan/hal | auth.go | RemoveRole | func (a *Auth) RemoveRole(user User, role string) error {
if role == "admin" {
return fmt.Errorf(`the "admin" role can only be defined by the HAL_AUTH_ADMIN environment variable`)
}
if !a.HasRole(user.ID, role) {
return fmt.Errorf("%s already does not have the %s role", user.Name, role)
}
roles := make([]str... | go | func (a *Auth) RemoveRole(user User, role string) error {
if role == "admin" {
return fmt.Errorf(`the "admin" role can only be defined by the HAL_AUTH_ADMIN environment variable`)
}
if !a.HasRole(user.ID, role) {
return fmt.Errorf("%s already does not have the %s role", user.Name, role)
}
roles := make([]str... | [
"func",
"(",
"a",
"*",
"Auth",
")",
"RemoveRole",
"(",
"user",
"User",
",",
"role",
"string",
")",
"error",
"{",
"if",
"role",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"`the \"admin\" role can only be defined by the HAL_AUTH_ADMIN environment ... | // RemoveRole adds a role to a User | [
"RemoveRole",
"adds",
"a",
"role",
"to",
"a",
"User"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/auth.go#L117-L138 |
137,134 | danryan/hal | auth.go | IsAdmin | func (a *Auth) IsAdmin(user User) bool {
for _, a := range a.admins {
if a == user.Name {
return true
}
}
return false
} | go | func (a *Auth) IsAdmin(user User) bool {
for _, a := range a.admins {
if a == user.Name {
return true
}
}
return false
} | [
"func",
"(",
"a",
"*",
"Auth",
")",
"IsAdmin",
"(",
"user",
"User",
")",
"bool",
"{",
"for",
"_",
",",
"a",
":=",
"range",
"a",
".",
"admins",
"{",
"if",
"a",
"==",
"user",
".",
"Name",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"re... | // IsAdmin checks whether a user is an admin | [
"IsAdmin",
"checks",
"whether",
"a",
"user",
"is",
"an",
"admin"
] | c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7 | https://github.com/danryan/hal/blob/c4a180833c0b8fd4f4f5c6fcaa611b8cb72c23c7/auth.go#L141-L149 |
137,135 | tylertreat/bench | bench.go | Run | func (b *Benchmark) Run() (*Summary, error) {
var (
start = make(chan struct{})
results = make(chan *result, b.connections)
wg sync.WaitGroup
)
// Prepare connection benchmarks
for _, benchmark := range b.benchmarks {
if err := benchmark.setup(); err != nil {
return nil, err
}
wg.Add(1)
go ... | go | func (b *Benchmark) Run() (*Summary, error) {
var (
start = make(chan struct{})
results = make(chan *result, b.connections)
wg sync.WaitGroup
)
// Prepare connection benchmarks
for _, benchmark := range b.benchmarks {
if err := benchmark.setup(); err != nil {
return nil, err
}
wg.Add(1)
go ... | [
"func",
"(",
"b",
"*",
"Benchmark",
")",
"Run",
"(",
")",
"(",
"*",
"Summary",
",",
"error",
")",
"{",
"var",
"(",
"start",
"=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n",
"results",
"=",
"make",
"(",
"chan",
"*",
"result",
",",
"b",
... | // Run the benchmark and return a summary of the results. An error is returned
// if something went wrong along the way. | [
"Run",
"the",
"benchmark",
"and",
"return",
"a",
"summary",
"of",
"the",
"results",
".",
"An",
"error",
"is",
"returned",
"if",
"something",
"went",
"wrong",
"along",
"the",
"way",
"."
] | eb938b1b5e35aa6937565aa805d4da9c1fbde7b3 | https://github.com/tylertreat/bench/blob/eb938b1b5e35aa6937565aa805d4da9c1fbde7b3/bench.go#L77-L126 |
137,136 | tylertreat/bench | bench.go | newConnectionBenchmark | func newConnectionBenchmark(requester Requester, requestRate uint64, duration time.Duration, burst uint64) *connectionBenchmark {
var interval time.Duration
if requestRate > 0 {
interval = time.Duration(1000000000 / requestRate)
}
if burst == 0 {
// burst is at least 1 - otherwise it's the smaller of DefaultB... | go | func newConnectionBenchmark(requester Requester, requestRate uint64, duration time.Duration, burst uint64) *connectionBenchmark {
var interval time.Duration
if requestRate > 0 {
interval = time.Duration(1000000000 / requestRate)
}
if burst == 0 {
// burst is at least 1 - otherwise it's the smaller of DefaultB... | [
"func",
"newConnectionBenchmark",
"(",
"requester",
"Requester",
",",
"requestRate",
"uint64",
",",
"duration",
"time",
".",
"Duration",
",",
"burst",
"uint64",
")",
"*",
"connectionBenchmark",
"{",
"var",
"interval",
"time",
".",
"Duration",
"\n",
"if",
"reques... | // newConnectionBenchmark creates a connectionBenchmark which runs a system
// benchmark using the given Requester. The requestRate argument specifies the
// number of requests per second to issue. A zero value disables rate limiting
// entirely. The duration argument specifies how long to run the benchmark. | [
"newConnectionBenchmark",
"creates",
"a",
"connectionBenchmark",
"which",
"runs",
"a",
"system",
"benchmark",
"using",
"the",
"given",
"Requester",
".",
"The",
"requestRate",
"argument",
"specifies",
"the",
"number",
"of",
"requests",
"per",
"second",
"to",
"issue",... | eb938b1b5e35aa6937565aa805d4da9c1fbde7b3 | https://github.com/tylertreat/bench/blob/eb938b1b5e35aa6937565aa805d4da9c1fbde7b3/bench.go#L155-L178 |
137,137 | tylertreat/bench | bench.go | setup | func (c *connectionBenchmark) setup() error {
c.successHistogram.Reset()
c.uncorrectedSuccessHistogram.Reset()
c.errorHistogram.Reset()
c.uncorrectedErrorHistogram.Reset()
c.successTotal = 0
c.errorTotal = 0
return c.requester.Setup()
} | go | func (c *connectionBenchmark) setup() error {
c.successHistogram.Reset()
c.uncorrectedSuccessHistogram.Reset()
c.errorHistogram.Reset()
c.uncorrectedErrorHistogram.Reset()
c.successTotal = 0
c.errorTotal = 0
return c.requester.Setup()
} | [
"func",
"(",
"c",
"*",
"connectionBenchmark",
")",
"setup",
"(",
")",
"error",
"{",
"c",
".",
"successHistogram",
".",
"Reset",
"(",
")",
"\n",
"c",
".",
"uncorrectedSuccessHistogram",
".",
"Reset",
"(",
")",
"\n",
"c",
".",
"errorHistogram",
".",
"Reset... | // setup prepares the benchmark for running. | [
"setup",
"prepares",
"the",
"benchmark",
"for",
"running",
"."
] | eb938b1b5e35aa6937565aa805d4da9c1fbde7b3 | https://github.com/tylertreat/bench/blob/eb938b1b5e35aa6937565aa805d4da9c1fbde7b3/bench.go#L181-L189 |
137,138 | tylertreat/bench | bench.go | run | func (c *connectionBenchmark) run() *result {
var err error
if c.requestRate == 0 {
c.elapsed, err = c.runFullThrottle()
} else {
c.elapsed, err = c.runRateLimited()
}
return &result{summary: c.summarize(), err: err}
} | go | func (c *connectionBenchmark) run() *result {
var err error
if c.requestRate == 0 {
c.elapsed, err = c.runFullThrottle()
} else {
c.elapsed, err = c.runRateLimited()
}
return &result{summary: c.summarize(), err: err}
} | [
"func",
"(",
"c",
"*",
"connectionBenchmark",
")",
"run",
"(",
")",
"*",
"result",
"{",
"var",
"err",
"error",
"\n",
"if",
"c",
".",
"requestRate",
"==",
"0",
"{",
"c",
".",
"elapsed",
",",
"err",
"=",
"c",
".",
"runFullThrottle",
"(",
")",
"\n",
... | // run the benchmark and return the result. Result contains an error if
// something went wrong along the way. | [
"run",
"the",
"benchmark",
"and",
"return",
"the",
"result",
".",
"Result",
"contains",
"an",
"error",
"if",
"something",
"went",
"wrong",
"along",
"the",
"way",
"."
] | eb938b1b5e35aa6937565aa805d4da9c1fbde7b3 | https://github.com/tylertreat/bench/blob/eb938b1b5e35aa6937565aa805d4da9c1fbde7b3/bench.go#L198-L206 |
137,139 | tylertreat/bench | bench.go | runRateLimited | func (c *connectionBenchmark) runRateLimited() (time.Duration, error) {
var (
interval = c.expectedInterval.Nanoseconds()
stop = time.After(c.duration)
start = time.Now()
limit = rate.Every(c.expectedInterval)
limiter = rate.NewLimiter(limit, c.burst)
ctx = context.Background()
)
for {
... | go | func (c *connectionBenchmark) runRateLimited() (time.Duration, error) {
var (
interval = c.expectedInterval.Nanoseconds()
stop = time.After(c.duration)
start = time.Now()
limit = rate.Every(c.expectedInterval)
limiter = rate.NewLimiter(limit, c.burst)
ctx = context.Background()
)
for {
... | [
"func",
"(",
"c",
"*",
"connectionBenchmark",
")",
"runRateLimited",
"(",
")",
"(",
"time",
".",
"Duration",
",",
"error",
")",
"{",
"var",
"(",
"interval",
"=",
"c",
".",
"expectedInterval",
".",
"Nanoseconds",
"(",
")",
"\n",
"stop",
"=",
"time",
"."... | // runRateLimited runs the benchmark by attempting to issue the configured
// number of requests per second. | [
"runRateLimited",
"runs",
"the",
"benchmark",
"by",
"attempting",
"to",
"issue",
"the",
"configured",
"number",
"of",
"requests",
"per",
"second",
"."
] | eb938b1b5e35aa6937565aa805d4da9c1fbde7b3 | https://github.com/tylertreat/bench/blob/eb938b1b5e35aa6937565aa805d4da9c1fbde7b3/bench.go#L210-L250 |
137,140 | tylertreat/bench | bench.go | runFullThrottle | func (c *connectionBenchmark) runFullThrottle() (time.Duration, error) {
var (
stop = time.After(c.duration)
start = time.Now()
)
for {
select {
case <-stop:
return time.Since(start), nil
default:
}
before := time.Now()
err := c.requester.Request()
latency := time.Since(before).Nanoseconds()
... | go | func (c *connectionBenchmark) runFullThrottle() (time.Duration, error) {
var (
stop = time.After(c.duration)
start = time.Now()
)
for {
select {
case <-stop:
return time.Since(start), nil
default:
}
before := time.Now()
err := c.requester.Request()
latency := time.Since(before).Nanoseconds()
... | [
"func",
"(",
"c",
"*",
"connectionBenchmark",
")",
"runFullThrottle",
"(",
")",
"(",
"time",
".",
"Duration",
",",
"error",
")",
"{",
"var",
"(",
"stop",
"=",
"time",
".",
"After",
"(",
"c",
".",
"duration",
")",
"\n",
"start",
"=",
"time",
".",
"N... | // runFullThrottle runs the benchmark without a limit on requests per second. | [
"runFullThrottle",
"runs",
"the",
"benchmark",
"without",
"a",
"limit",
"on",
"requests",
"per",
"second",
"."
] | eb938b1b5e35aa6937565aa805d4da9c1fbde7b3 | https://github.com/tylertreat/bench/blob/eb938b1b5e35aa6937565aa805d4da9c1fbde7b3/bench.go#L253-L280 |
137,141 | tylertreat/bench | bench.go | summarize | func (c *connectionBenchmark) summarize() *Summary {
return &Summary{
SuccessTotal: c.successTotal,
ErrorTotal: c.errorTotal,
TimeElapsed: c.elapsed,
SuccessHistogram: hdrhistogram.Import(c.successHistogram.Export()),
UncorrectedSuccessHistogram: hdr... | go | func (c *connectionBenchmark) summarize() *Summary {
return &Summary{
SuccessTotal: c.successTotal,
ErrorTotal: c.errorTotal,
TimeElapsed: c.elapsed,
SuccessHistogram: hdrhistogram.Import(c.successHistogram.Export()),
UncorrectedSuccessHistogram: hdr... | [
"func",
"(",
"c",
"*",
"connectionBenchmark",
")",
"summarize",
"(",
")",
"*",
"Summary",
"{",
"return",
"&",
"Summary",
"{",
"SuccessTotal",
":",
"c",
".",
"successTotal",
",",
"ErrorTotal",
":",
"c",
".",
"errorTotal",
",",
"TimeElapsed",
":",
"c",
"."... | // summarize returns a Summary of the last benchmark run. | [
"summarize",
"returns",
"a",
"Summary",
"of",
"the",
"last",
"benchmark",
"run",
"."
] | eb938b1b5e35aa6937565aa805d4da9c1fbde7b3 | https://github.com/tylertreat/bench/blob/eb938b1b5e35aa6937565aa805d4da9c1fbde7b3/bench.go#L283-L295 |
137,142 | tylertreat/bench | summary.go | String | func (s *Summary) String() string {
return fmt.Sprintf(
"\n{Connections: %d, RequestRate: %d, RequestTotal: %d, SuccessTotal: %d, ErrorTotal: %d, TimeElapsed: %s, Throughput: %.2f/s}",
s.Connections, s.RequestRate, (s.SuccessTotal + s.ErrorTotal), s.SuccessTotal, s.ErrorTotal, s.TimeElapsed, s.Throughput)
} | go | func (s *Summary) String() string {
return fmt.Sprintf(
"\n{Connections: %d, RequestRate: %d, RequestTotal: %d, SuccessTotal: %d, ErrorTotal: %d, TimeElapsed: %s, Throughput: %.2f/s}",
s.Connections, s.RequestRate, (s.SuccessTotal + s.ErrorTotal), s.SuccessTotal, s.ErrorTotal, s.TimeElapsed, s.Throughput)
} | [
"func",
"(",
"s",
"*",
"Summary",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\"",
",",
"s",
".",
"Connections",
",",
"s",
".",
"RequestRate",
",",
"(",
"s",
".",
"SuccessTotal",
"+",
"s",
".",
"Err... | // String returns a stringified version of the Summary. | [
"String",
"returns",
"a",
"stringified",
"version",
"of",
"the",
"Summary",
"."
] | eb938b1b5e35aa6937565aa805d4da9c1fbde7b3 | https://github.com/tylertreat/bench/blob/eb938b1b5e35aa6937565aa805d4da9c1fbde7b3/summary.go#L26-L30 |
137,143 | tylertreat/bench | summary.go | merge | func (s *Summary) merge(o *Summary) {
if o.TimeElapsed > s.TimeElapsed {
s.TimeElapsed = o.TimeElapsed
}
s.SuccessHistogram.Merge(o.SuccessHistogram)
s.UncorrectedSuccessHistogram.Merge(o.UncorrectedSuccessHistogram)
s.ErrorHistogram.Merge(o.ErrorHistogram)
s.UncorrectedErrorHistogram.Merge(o.UncorrectedErrorHi... | go | func (s *Summary) merge(o *Summary) {
if o.TimeElapsed > s.TimeElapsed {
s.TimeElapsed = o.TimeElapsed
}
s.SuccessHistogram.Merge(o.SuccessHistogram)
s.UncorrectedSuccessHistogram.Merge(o.UncorrectedSuccessHistogram)
s.ErrorHistogram.Merge(o.ErrorHistogram)
s.UncorrectedErrorHistogram.Merge(o.UncorrectedErrorHi... | [
"func",
"(",
"s",
"*",
"Summary",
")",
"merge",
"(",
"o",
"*",
"Summary",
")",
"{",
"if",
"o",
".",
"TimeElapsed",
">",
"s",
".",
"TimeElapsed",
"{",
"s",
".",
"TimeElapsed",
"=",
"o",
".",
"TimeElapsed",
"\n",
"}",
"\n",
"s",
".",
"SuccessHistogra... | // merge the other Summary into this one. | [
"merge",
"the",
"other",
"Summary",
"into",
"this",
"one",
"."
] | eb938b1b5e35aa6937565aa805d4da9c1fbde7b3 | https://github.com/tylertreat/bench/blob/eb938b1b5e35aa6937565aa805d4da9c1fbde7b3/summary.go#L80-L92 |
137,144 | sajari/storage | storage.go | IsNotExist | func IsNotExist(err error) bool {
e, ok := err.(isNotExister)
return ok && e.isNotExist()
} | go | func IsNotExist(err error) bool {
e, ok := err.(isNotExister)
return ok && e.isNotExist()
} | [
"func",
"IsNotExist",
"(",
"err",
"error",
")",
"bool",
"{",
"e",
",",
"ok",
":=",
"err",
".",
"(",
"isNotExister",
")",
"\n",
"return",
"ok",
"&&",
"e",
".",
"isNotExist",
"(",
")",
"\n",
"}"
] | // IsNotExist returns a boolean indicating whether the error is known to report that
// a path does not exist. | [
"IsNotExist",
"returns",
"a",
"boolean",
"indicating",
"whether",
"the",
"error",
"is",
"known",
"to",
"report",
"that",
"a",
"path",
"does",
"not",
"exist",
"."
] | 95d05f4fe2fc65826211af4e613586fd109a1152 | https://github.com/sajari/storage/blob/95d05f4fe2fc65826211af4e613586fd109a1152/storage.go#L30-L33 |
137,145 | sajari/storage | storage.go | Prefix | func Prefix(fs FS, prefix string) FS {
return pfx{
fs: fs,
prefix: prefix,
}
} | go | func Prefix(fs FS, prefix string) FS {
return pfx{
fs: fs,
prefix: prefix,
}
} | [
"func",
"Prefix",
"(",
"fs",
"FS",
",",
"prefix",
"string",
")",
"FS",
"{",
"return",
"pfx",
"{",
"fs",
":",
"fs",
",",
"prefix",
":",
"prefix",
",",
"}",
"\n",
"}"
] | // Prefix creates a FS which wraps fs and prefixes all paths with prefix. | [
"Prefix",
"creates",
"a",
"FS",
"which",
"wraps",
"fs",
"and",
"prefixes",
"all",
"paths",
"with",
"prefix",
"."
] | 95d05f4fe2fc65826211af4e613586fd109a1152 | https://github.com/sajari/storage/blob/95d05f4fe2fc65826211af4e613586fd109a1152/storage.go#L79-L84 |
137,146 | sajari/storage | storage.go | Walk | func (p pfx) Walk(ctx context.Context, path string, fn WalkFn) error {
return p.fs.Walk(ctx, p.addPrefix(path), func(path string) error {
path = strings.TrimPrefix(path, p.prefix)
return fn(path)
})
} | go | func (p pfx) Walk(ctx context.Context, path string, fn WalkFn) error {
return p.fs.Walk(ctx, p.addPrefix(path), func(path string) error {
path = strings.TrimPrefix(path, p.prefix)
return fn(path)
})
} | [
"func",
"(",
"p",
"pfx",
")",
"Walk",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
",",
"fn",
"WalkFn",
")",
"error",
"{",
"return",
"p",
".",
"fs",
".",
"Walk",
"(",
"ctx",
",",
"p",
".",
"addPrefix",
"(",
"path",
")",
",",
"f... | // Walk transverses all paths underneath path, calling fn on each visited path. | [
"Walk",
"transverses",
"all",
"paths",
"underneath",
"path",
"calling",
"fn",
"on",
"each",
"visited",
"path",
"."
] | 95d05f4fe2fc65826211af4e613586fd109a1152 | https://github.com/sajari/storage/blob/95d05f4fe2fc65826211af4e613586fd109a1152/storage.go#L111-L116 |
137,147 | sajari/storage | cache.go | Cache | func Cache(src, cache FS) FS {
return &cachedFS{
src: src,
cache: cache,
}
} | go | func Cache(src, cache FS) FS {
return &cachedFS{
src: src,
cache: cache,
}
} | [
"func",
"Cache",
"(",
"src",
",",
"cache",
"FS",
")",
"FS",
"{",
"return",
"&",
"cachedFS",
"{",
"src",
":",
"src",
",",
"cache",
":",
"cache",
",",
"}",
"\n",
"}"
] | // Cache creates an FS implementation which caches files opened from src into cache. | [
"Cache",
"creates",
"an",
"FS",
"implementation",
"which",
"caches",
"files",
"opened",
"from",
"src",
"into",
"cache",
"."
] | 95d05f4fe2fc65826211af4e613586fd109a1152 | https://github.com/sajari/storage/blob/95d05f4fe2fc65826211af4e613586fd109a1152/cache.go#L10-L15 |
137,148 | sajari/storage | local.go | Create | func (l Local) Create(_ context.Context, path string) (io.WriteCloser, error) {
dir := l.fullPath(filepath.Dir(path))
if _, err := os.Stat(dir); os.IsNotExist(err) {
if err := os.MkdirAll(dir, LocalCreatePathMode); err != nil {
return nil, err
}
}
f, err := os.Create(l.fullPath(path))
if err != nil {
ret... | go | func (l Local) Create(_ context.Context, path string) (io.WriteCloser, error) {
dir := l.fullPath(filepath.Dir(path))
if _, err := os.Stat(dir); os.IsNotExist(err) {
if err := os.MkdirAll(dir, LocalCreatePathMode); err != nil {
return nil, err
}
}
f, err := os.Create(l.fullPath(path))
if err != nil {
ret... | [
"func",
"(",
"l",
"Local",
")",
"Create",
"(",
"_",
"context",
".",
"Context",
",",
"path",
"string",
")",
"(",
"io",
".",
"WriteCloser",
",",
"error",
")",
"{",
"dir",
":=",
"l",
".",
"fullPath",
"(",
"filepath",
".",
"Dir",
"(",
"path",
")",
")... | // Create implements FS. If the path contains any directories which do not already exist
// then Create will try to make them, returning an error if it fails. | [
"Create",
"implements",
"FS",
".",
"If",
"the",
"path",
"contains",
"any",
"directories",
"which",
"do",
"not",
"already",
"exist",
"then",
"Create",
"will",
"try",
"to",
"make",
"them",
"returning",
"an",
"error",
"if",
"it",
"fails",
"."
] | 95d05f4fe2fc65826211af4e613586fd109a1152 | https://github.com/sajari/storage/blob/95d05f4fe2fc65826211af4e613586fd109a1152/local.go#L58-L71 |
137,149 | sajari/storage | local.go | Delete | func (l Local) Delete(_ context.Context, path string) error {
return os.RemoveAll(l.fullPath(path))
} | go | func (l Local) Delete(_ context.Context, path string) error {
return os.RemoveAll(l.fullPath(path))
} | [
"func",
"(",
"l",
"Local",
")",
"Delete",
"(",
"_",
"context",
".",
"Context",
",",
"path",
"string",
")",
"error",
"{",
"return",
"os",
".",
"RemoveAll",
"(",
"l",
".",
"fullPath",
"(",
"path",
")",
")",
"\n",
"}"
] | // Delete implements FS. All files underneath path will be removed. | [
"Delete",
"implements",
"FS",
".",
"All",
"files",
"underneath",
"path",
"will",
"be",
"removed",
"."
] | 95d05f4fe2fc65826211af4e613586fd109a1152 | https://github.com/sajari/storage/blob/95d05f4fe2fc65826211af4e613586fd109a1152/local.go#L74-L76 |
137,150 | sajari/storage | walk.go | List | func List(ctx context.Context, w Walker, path string) ([]string, error) {
var out []string
if err := w.Walk(ctx, path, func(path string) error {
out = append(out, path)
return nil
}); err != nil {
return nil, err
}
return out, nil
} | go | func List(ctx context.Context, w Walker, path string) ([]string, error) {
var out []string
if err := w.Walk(ctx, path, func(path string) error {
out = append(out, path)
return nil
}); err != nil {
return nil, err
}
return out, nil
} | [
"func",
"List",
"(",
"ctx",
"context",
".",
"Context",
",",
"w",
"Walker",
",",
"path",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"out",
"[",
"]",
"string",
"\n",
"if",
"err",
":=",
"w",
".",
"Walk",
"(",
"ctx",
","... | // List runs the Walker on the given path and returns the list of visited paths. | [
"List",
"runs",
"the",
"Walker",
"on",
"the",
"given",
"path",
"and",
"returns",
"the",
"list",
"of",
"visited",
"paths",
"."
] | 95d05f4fe2fc65826211af4e613586fd109a1152 | https://github.com/sajari/storage/blob/95d05f4fe2fc65826211af4e613586fd109a1152/walk.go#L19-L28 |
137,151 | sajari/storage | walk.go | WalkN | func WalkN(ctx context.Context, w Walker, path string, n int, fn WalkFn) error {
errCh := make(chan error, n)
ch := make(chan string)
wg := sync.WaitGroup{}
for i := 0; i < n; i++ {
wg.Add(1)
go func() {
for f := range ch {
if err := fn(f); err != nil {
errCh <- err
break
}
}
wg.Done... | go | func WalkN(ctx context.Context, w Walker, path string, n int, fn WalkFn) error {
errCh := make(chan error, n)
ch := make(chan string)
wg := sync.WaitGroup{}
for i := 0; i < n; i++ {
wg.Add(1)
go func() {
for f := range ch {
if err := fn(f); err != nil {
errCh <- err
break
}
}
wg.Done... | [
"func",
"WalkN",
"(",
"ctx",
"context",
".",
"Context",
",",
"w",
"Walker",
",",
"path",
"string",
",",
"n",
"int",
",",
"fn",
"WalkFn",
")",
"error",
"{",
"errCh",
":=",
"make",
"(",
"chan",
"error",
",",
"n",
")",
"\n",
"ch",
":=",
"make",
"(",... | // WalkN creates n workers which accept paths from the Walker. If a WalkFn
// returns non-nil error we wait for other running WalkFns to finish before
// returning. | [
"WalkN",
"creates",
"n",
"workers",
"which",
"accept",
"paths",
"from",
"the",
"Walker",
".",
"If",
"a",
"WalkFn",
"returns",
"non",
"-",
"nil",
"error",
"we",
"wait",
"for",
"other",
"running",
"WalkFns",
"to",
"finish",
"before",
"returning",
"."
] | 95d05f4fe2fc65826211af4e613586fd109a1152 | https://github.com/sajari/storage/blob/95d05f4fe2fc65826211af4e613586fd109a1152/walk.go#L33-L65 |
137,152 | sajari/storage | log.go | NewLogFS | func NewLogFS(fs FS, name string, l *log.Logger) *LogFS {
return &LogFS{
fs: fs,
name: name,
logger: l,
}
} | go | func NewLogFS(fs FS, name string, l *log.Logger) *LogFS {
return &LogFS{
fs: fs,
name: name,
logger: l,
}
} | [
"func",
"NewLogFS",
"(",
"fs",
"FS",
",",
"name",
"string",
",",
"l",
"*",
"log",
".",
"Logger",
")",
"*",
"LogFS",
"{",
"return",
"&",
"LogFS",
"{",
"fs",
":",
"fs",
",",
"name",
":",
"name",
",",
"logger",
":",
"l",
",",
"}",
"\n",
"}"
] | // NewLogFS creates a new FS which logs all calls to FS. | [
"NewLogFS",
"creates",
"a",
"new",
"FS",
"which",
"logs",
"all",
"calls",
"to",
"FS",
"."
] | 95d05f4fe2fc65826211af4e613586fd109a1152 | https://github.com/sajari/storage/blob/95d05f4fe2fc65826211af4e613586fd109a1152/log.go#L13-L19 |
137,153 | sajari/storage | log.go | Open | func (l *LogFS) Open(ctx context.Context, path string) (*File, error) {
l.logger.Printf("%v: open: %v", l.name, path)
f, err := l.fs.Open(ctx, path)
if err != nil {
l.logger.Printf("%v: open error: %v: %v", l.name, path, err)
}
return f, err
} | go | func (l *LogFS) Open(ctx context.Context, path string) (*File, error) {
l.logger.Printf("%v: open: %v", l.name, path)
f, err := l.fs.Open(ctx, path)
if err != nil {
l.logger.Printf("%v: open error: %v: %v", l.name, path, err)
}
return f, err
} | [
"func",
"(",
"l",
"*",
"LogFS",
")",
"Open",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
")",
"(",
"*",
"File",
",",
"error",
")",
"{",
"l",
".",
"logger",
".",
"Printf",
"(",
"\"",
"\"",
",",
"l",
".",
"name",
",",
"path",
... | // Open implements FS. All calls to Open are logged and errors are logged seperately. | [
"Open",
"implements",
"FS",
".",
"All",
"calls",
"to",
"Open",
"are",
"logged",
"and",
"errors",
"are",
"logged",
"seperately",
"."
] | 95d05f4fe2fc65826211af4e613586fd109a1152 | https://github.com/sajari/storage/blob/95d05f4fe2fc65826211af4e613586fd109a1152/log.go#L30-L37 |
137,154 | sajari/storage | log.go | Create | func (l *LogFS) Create(ctx context.Context, path string) (io.WriteCloser, error) {
l.logger.Printf("%v: create: %v", l.name, path)
wc, err := l.fs.Create(ctx, path)
if err != nil {
l.logger.Printf("%v: create error: %v: %v", l.name, path, err)
}
return wc, err
} | go | func (l *LogFS) Create(ctx context.Context, path string) (io.WriteCloser, error) {
l.logger.Printf("%v: create: %v", l.name, path)
wc, err := l.fs.Create(ctx, path)
if err != nil {
l.logger.Printf("%v: create error: %v: %v", l.name, path, err)
}
return wc, err
} | [
"func",
"(",
"l",
"*",
"LogFS",
")",
"Create",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
")",
"(",
"io",
".",
"WriteCloser",
",",
"error",
")",
"{",
"l",
".",
"logger",
".",
"Printf",
"(",
"\"",
"\"",
",",
"l",
".",
"name",
... | // Create implements FS. All calls to Create are logged and errors are logged seperately. | [
"Create",
"implements",
"FS",
".",
"All",
"calls",
"to",
"Create",
"are",
"logged",
"and",
"errors",
"are",
"logged",
"seperately",
"."
] | 95d05f4fe2fc65826211af4e613586fd109a1152 | https://github.com/sajari/storage/blob/95d05f4fe2fc65826211af4e613586fd109a1152/log.go#L40-L47 |
137,155 | sajari/storage | log.go | Delete | func (l *LogFS) Delete(ctx context.Context, path string) error {
l.logger.Printf("%v: delete: %v", l.name, path)
err := l.fs.Delete(ctx, path)
if err != nil {
l.logger.Printf("%v: delete error: %v: %v", l.name, path, err)
}
return err
} | go | func (l *LogFS) Delete(ctx context.Context, path string) error {
l.logger.Printf("%v: delete: %v", l.name, path)
err := l.fs.Delete(ctx, path)
if err != nil {
l.logger.Printf("%v: delete error: %v: %v", l.name, path, err)
}
return err
} | [
"func",
"(",
"l",
"*",
"LogFS",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
")",
"error",
"{",
"l",
".",
"logger",
".",
"Printf",
"(",
"\"",
"\"",
",",
"l",
".",
"name",
",",
"path",
")",
"\n",
"err",
":=",
"l",... | // Delete implements FS. All calls to Delete are logged and errors are logged seperately. | [
"Delete",
"implements",
"FS",
".",
"All",
"calls",
"to",
"Delete",
"are",
"logged",
"and",
"errors",
"are",
"logged",
"seperately",
"."
] | 95d05f4fe2fc65826211af4e613586fd109a1152 | https://github.com/sajari/storage/blob/95d05f4fe2fc65826211af4e613586fd109a1152/log.go#L50-L57 |
137,156 | sajari/storage | log.go | Walk | func (l *LogFS) Walk(ctx context.Context, path string, fn WalkFn) error {
return l.fs.Walk(ctx, path, fn)
} | go | func (l *LogFS) Walk(ctx context.Context, path string, fn WalkFn) error {
return l.fs.Walk(ctx, path, fn)
} | [
"func",
"(",
"l",
"*",
"LogFS",
")",
"Walk",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
",",
"fn",
"WalkFn",
")",
"error",
"{",
"return",
"l",
".",
"fs",
".",
"Walk",
"(",
"ctx",
",",
"path",
",",
"fn",
")",
"\n",
"}"
] | // Walk implements FS. No logs are written at this time. | [
"Walk",
"implements",
"FS",
".",
"No",
"logs",
"are",
"written",
"at",
"this",
"time",
"."
] | 95d05f4fe2fc65826211af4e613586fd109a1152 | https://github.com/sajari/storage/blob/95d05f4fe2fc65826211af4e613586fd109a1152/log.go#L60-L62 |
137,157 | sajari/storage | log.go | Walk | func (t *TraceFS) Walk(ctx context.Context, path string, fn WalkFn) error {
return t.fs.Walk(ctx, path, fn)
} | go | func (t *TraceFS) Walk(ctx context.Context, path string, fn WalkFn) error {
return t.fs.Walk(ctx, path, fn)
} | [
"func",
"(",
"t",
"*",
"TraceFS",
")",
"Walk",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
",",
"fn",
"WalkFn",
")",
"error",
"{",
"return",
"t",
".",
"fs",
".",
"Walk",
"(",
"ctx",
",",
"path",
",",
"fn",
")",
"\n",
"}"
] | // Walk implements FS. Nothing is traced at this time. | [
"Walk",
"implements",
"FS",
".",
"Nothing",
"is",
"traced",
"at",
"this",
"time",
"."
] | 95d05f4fe2fc65826211af4e613586fd109a1152 | https://github.com/sajari/storage/blob/95d05f4fe2fc65826211af4e613586fd109a1152/log.go#L124-L126 |
137,158 | sajari/storage | log.go | NewErrCountFS | func NewErrCountFS(fs FS, name string, err error) *ErrCountFS {
status := expvar.NewMap(name)
status.Set("open.total", new(expvar.Int))
status.Set("open.count", new(expvar.Int))
status.Set("create.total", new(expvar.Int))
status.Set("create.count", new(expvar.Int))
status.Set("delete.total", new(expvar.Int))
s... | go | func NewErrCountFS(fs FS, name string, err error) *ErrCountFS {
status := expvar.NewMap(name)
status.Set("open.total", new(expvar.Int))
status.Set("open.count", new(expvar.Int))
status.Set("create.total", new(expvar.Int))
status.Set("create.count", new(expvar.Int))
status.Set("delete.total", new(expvar.Int))
s... | [
"func",
"NewErrCountFS",
"(",
"fs",
"FS",
",",
"name",
"string",
",",
"err",
"error",
")",
"*",
"ErrCountFS",
"{",
"status",
":=",
"expvar",
".",
"NewMap",
"(",
"name",
")",
"\n",
"status",
".",
"Set",
"(",
"\"",
"\"",
",",
"new",
"(",
"expvar",
".... | // NewErrCountFS creates an FS which records stats based on usage. | [
"NewErrCountFS",
"creates",
"an",
"FS",
"which",
"records",
"stats",
"based",
"on",
"usage",
"."
] | 95d05f4fe2fc65826211af4e613586fd109a1152 | https://github.com/sajari/storage/blob/95d05f4fe2fc65826211af4e613586fd109a1152/log.go#L129-L145 |
137,159 | sajari/storage | log.go | Open | func (s ErrCountFS) Open(ctx context.Context, path string) (*File, error) {
f, err := s.fs.Open(ctx, path)
if err == s.err {
s.status.Add("open.count", 1)
}
s.status.Add("open.total", 1)
return f, err
} | go | func (s ErrCountFS) Open(ctx context.Context, path string) (*File, error) {
f, err := s.fs.Open(ctx, path)
if err == s.err {
s.status.Add("open.count", 1)
}
s.status.Add("open.total", 1)
return f, err
} | [
"func",
"(",
"s",
"ErrCountFS",
")",
"Open",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
")",
"(",
"*",
"File",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"s",
".",
"fs",
".",
"Open",
"(",
"ctx",
",",
"path",
")",
"\n",
... | // Open implements FS. All errors from Open are counted. | [
"Open",
"implements",
"FS",
".",
"All",
"errors",
"from",
"Open",
"are",
"counted",
"."
] | 95d05f4fe2fc65826211af4e613586fd109a1152 | https://github.com/sajari/storage/blob/95d05f4fe2fc65826211af4e613586fd109a1152/log.go#L156-L163 |
137,160 | sajari/storage | log.go | Create | func (s ErrCountFS) Create(ctx context.Context, path string) (io.WriteCloser, error) {
wc, err := s.fs.Create(ctx, path)
if err == s.err {
s.status.Add("create.count", 1)
}
s.status.Add("create.total", 1)
return wc, err
} | go | func (s ErrCountFS) Create(ctx context.Context, path string) (io.WriteCloser, error) {
wc, err := s.fs.Create(ctx, path)
if err == s.err {
s.status.Add("create.count", 1)
}
s.status.Add("create.total", 1)
return wc, err
} | [
"func",
"(",
"s",
"ErrCountFS",
")",
"Create",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
")",
"(",
"io",
".",
"WriteCloser",
",",
"error",
")",
"{",
"wc",
",",
"err",
":=",
"s",
".",
"fs",
".",
"Create",
"(",
"ctx",
",",
"path... | // Create implements FS. All errors from Create are counted. | [
"Create",
"implements",
"FS",
".",
"All",
"errors",
"from",
"Create",
"are",
"counted",
"."
] | 95d05f4fe2fc65826211af4e613586fd109a1152 | https://github.com/sajari/storage/blob/95d05f4fe2fc65826211af4e613586fd109a1152/log.go#L166-L173 |
137,161 | sajari/storage | log.go | Delete | func (s ErrCountFS) Delete(ctx context.Context, path string) error {
err := s.fs.Delete(ctx, path)
if err == s.err {
s.status.Add("delete.count", 1)
}
s.status.Add("delete.total", 1)
return err
} | go | func (s ErrCountFS) Delete(ctx context.Context, path string) error {
err := s.fs.Delete(ctx, path)
if err == s.err {
s.status.Add("delete.count", 1)
}
s.status.Add("delete.total", 1)
return err
} | [
"func",
"(",
"s",
"ErrCountFS",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
")",
"error",
"{",
"err",
":=",
"s",
".",
"fs",
".",
"Delete",
"(",
"ctx",
",",
"path",
")",
"\n",
"if",
"err",
"==",
"s",
".",
"err",
... | // Delete implements FS. All errors from Delete are counted. | [
"Delete",
"implements",
"FS",
".",
"All",
"errors",
"from",
"Delete",
"are",
"counted",
"."
] | 95d05f4fe2fc65826211af4e613586fd109a1152 | https://github.com/sajari/storage/blob/95d05f4fe2fc65826211af4e613586fd109a1152/log.go#L176-L183 |
137,162 | sajari/storage | log.go | Walk | func (s ErrCountFS) Walk(ctx context.Context, path string, fn WalkFn) error {
return s.fs.Walk(ctx, path, fn)
} | go | func (s ErrCountFS) Walk(ctx context.Context, path string, fn WalkFn) error {
return s.fs.Walk(ctx, path, fn)
} | [
"func",
"(",
"s",
"ErrCountFS",
")",
"Walk",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
",",
"fn",
"WalkFn",
")",
"error",
"{",
"return",
"s",
".",
"fs",
".",
"Walk",
"(",
"ctx",
",",
"path",
",",
"fn",
")",
"\n",
"}"
] | // Walk implements FS. No stats are recorded at this time. | [
"Walk",
"implements",
"FS",
".",
"No",
"stats",
"are",
"recorded",
"at",
"this",
"time",
"."
] | 95d05f4fe2fc65826211af4e613586fd109a1152 | https://github.com/sajari/storage/blob/95d05f4fe2fc65826211af4e613586fd109a1152/log.go#L186-L188 |
137,163 | sajari/storage | hash.go | HashFS | func HashFS(h hash.Hash, fs FS, gs GetSetter) FS {
return &hashFS{
h: h,
fs: fs,
gs: gs,
}
} | go | func HashFS(h hash.Hash, fs FS, gs GetSetter) FS {
return &hashFS{
h: h,
fs: fs,
gs: gs,
}
} | [
"func",
"HashFS",
"(",
"h",
"hash",
".",
"Hash",
",",
"fs",
"FS",
",",
"gs",
"GetSetter",
")",
"FS",
"{",
"return",
"&",
"hashFS",
"{",
"h",
":",
"h",
",",
"fs",
":",
"fs",
",",
"gs",
":",
"gs",
",",
"}",
"\n",
"}"
] | // HashFS creates a content addressable filesystem using hash.Hash
// to sum the content and store it using that name. | [
"HashFS",
"creates",
"a",
"content",
"addressable",
"filesystem",
"using",
"hash",
".",
"Hash",
"to",
"sum",
"the",
"content",
"and",
"store",
"it",
"using",
"that",
"name",
"."
] | 95d05f4fe2fc65826211af4e613586fd109a1152 | https://github.com/sajari/storage/blob/95d05f4fe2fc65826211af4e613586fd109a1152/hash.go#L15-L21 |
137,164 | cenkalti/rpc2 | client.go | readLoop | func (c *Client) readLoop() {
var err error
var req Request
var resp Response
for err == nil {
req = Request{}
resp = Response{}
if err = c.codec.ReadHeader(&req, &resp); err != nil {
break
}
if req.Method != "" {
// request comes to server
if err = c.readRequest(&req); err != nil {
debugln(... | go | func (c *Client) readLoop() {
var err error
var req Request
var resp Response
for err == nil {
req = Request{}
resp = Response{}
if err = c.codec.ReadHeader(&req, &resp); err != nil {
break
}
if req.Method != "" {
// request comes to server
if err = c.readRequest(&req); err != nil {
debugln(... | [
"func",
"(",
"c",
"*",
"Client",
")",
"readLoop",
"(",
")",
"{",
"var",
"err",
"error",
"\n",
"var",
"req",
"Request",
"\n",
"var",
"resp",
"Response",
"\n",
"for",
"err",
"==",
"nil",
"{",
"req",
"=",
"Request",
"{",
"}",
"\n",
"resp",
"=",
"Res... | // readLoop reads messages from codec.
// It reads a reqeust or a response to the previous request.
// If the message is request, calls the handler function.
// If the message is response, sends the reply to the associated call. | [
"readLoop",
"reads",
"messages",
"from",
"codec",
".",
"It",
"reads",
"a",
"reqeust",
"or",
"a",
"response",
"to",
"the",
"previous",
"request",
".",
"If",
"the",
"message",
"is",
"request",
"calls",
"the",
"handler",
"function",
".",
"If",
"the",
"message... | 9642ea02d0aad04b8efb5e1a6bbc63daf8d0903d | https://github.com/cenkalti/rpc2/blob/9642ea02d0aad04b8efb5e1a6bbc63daf8d0903d/client.go#L80-L125 |
137,165 | cenkalti/rpc2 | client.go | Close | func (c *Client) Close() error {
c.mutex.Lock()
if c.shutdown || c.closing {
c.mutex.Unlock()
return ErrShutdown
}
c.closing = true
c.mutex.Unlock()
return c.codec.Close()
} | go | func (c *Client) Close() error {
c.mutex.Lock()
if c.shutdown || c.closing {
c.mutex.Unlock()
return ErrShutdown
}
c.closing = true
c.mutex.Unlock()
return c.codec.Close()
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Close",
"(",
")",
"error",
"{",
"c",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"if",
"c",
".",
"shutdown",
"||",
"c",
".",
"closing",
"{",
"c",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"return",
"Er... | // Close waits for active calls to finish and closes the codec. | [
"Close",
"waits",
"for",
"active",
"calls",
"to",
"finish",
"and",
"closes",
"the",
"codec",
"."
] | 9642ea02d0aad04b8efb5e1a6bbc63daf8d0903d | https://github.com/cenkalti/rpc2/blob/9642ea02d0aad04b8efb5e1a6bbc63daf8d0903d/client.go#L228-L237 |
137,166 | cenkalti/rpc2 | client.go | Notify | func (c *Client) Notify(method string, args interface{}) error {
c.sending.Lock()
defer c.sending.Unlock()
if c.shutdown || c.closing {
return ErrShutdown
}
c.request.Seq = 0
c.request.Method = method
return c.codec.WriteRequest(&c.request, args)
} | go | func (c *Client) Notify(method string, args interface{}) error {
c.sending.Lock()
defer c.sending.Unlock()
if c.shutdown || c.closing {
return ErrShutdown
}
c.request.Seq = 0
c.request.Method = method
return c.codec.WriteRequest(&c.request, args)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Notify",
"(",
"method",
"string",
",",
"args",
"interface",
"{",
"}",
")",
"error",
"{",
"c",
".",
"sending",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"sending",
".",
"Unlock",
"(",
")",
"\n\n",
"if",... | // Notify sends a request to the receiver but does not wait for a return value. | [
"Notify",
"sends",
"a",
"request",
"to",
"the",
"receiver",
"but",
"does",
"not",
"wait",
"for",
"a",
"return",
"value",
"."
] | 9642ea02d0aad04b8efb5e1a6bbc63daf8d0903d | https://github.com/cenkalti/rpc2/blob/9642ea02d0aad04b8efb5e1a6bbc63daf8d0903d/client.go#L335-L346 |
137,167 | cenkalti/rpc2 | jsonrpc/jsonrpc.go | NewJSONCodec | func NewJSONCodec(conn io.ReadWriteCloser) rpc2.Codec {
return &jsonCodec{
dec: json.NewDecoder(conn),
enc: json.NewEncoder(conn),
c: conn,
pending: make(map[uint64]*json.RawMessage),
}
} | go | func NewJSONCodec(conn io.ReadWriteCloser) rpc2.Codec {
return &jsonCodec{
dec: json.NewDecoder(conn),
enc: json.NewEncoder(conn),
c: conn,
pending: make(map[uint64]*json.RawMessage),
}
} | [
"func",
"NewJSONCodec",
"(",
"conn",
"io",
".",
"ReadWriteCloser",
")",
"rpc2",
".",
"Codec",
"{",
"return",
"&",
"jsonCodec",
"{",
"dec",
":",
"json",
".",
"NewDecoder",
"(",
"conn",
")",
",",
"enc",
":",
"json",
".",
"NewEncoder",
"(",
"conn",
")",
... | // NewJSONCodec returns a new rpc2.Codec using JSON-RPC on conn. | [
"NewJSONCodec",
"returns",
"a",
"new",
"rpc2",
".",
"Codec",
"using",
"JSON",
"-",
"RPC",
"on",
"conn",
"."
] | 9642ea02d0aad04b8efb5e1a6bbc63daf8d0903d | https://github.com/cenkalti/rpc2/blob/9642ea02d0aad04b8efb5e1a6bbc63daf8d0903d/jsonrpc/jsonrpc.go#L49-L56 |
137,168 | cenkalti/rpc2 | server.go | OnConnect | func (s *Server) OnConnect(f func(*Client)) {
s.eventHub.Subscribe(clientConnected, func(e hub.Event) {
go f(e.(connectionEvent).Client)
})
} | go | func (s *Server) OnConnect(f func(*Client)) {
s.eventHub.Subscribe(clientConnected, func(e hub.Event) {
go f(e.(connectionEvent).Client)
})
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"OnConnect",
"(",
"f",
"func",
"(",
"*",
"Client",
")",
")",
"{",
"s",
".",
"eventHub",
".",
"Subscribe",
"(",
"clientConnected",
",",
"func",
"(",
"e",
"hub",
".",
"Event",
")",
"{",
"go",
"f",
"(",
"e",
"... | // OnConnect registers a function to run when a client connects. | [
"OnConnect",
"registers",
"a",
"function",
"to",
"run",
"when",
"a",
"client",
"connects",
"."
] | 9642ea02d0aad04b8efb5e1a6bbc63daf8d0903d | https://github.com/cenkalti/rpc2/blob/9642ea02d0aad04b8efb5e1a6bbc63daf8d0903d/server.go#L125-L129 |
137,169 | cenkalti/rpc2 | server.go | OnDisconnect | func (s *Server) OnDisconnect(f func(*Client)) {
s.eventHub.Subscribe(clientDisconnected, func(e hub.Event) {
go f(e.(disconnectionEvent).Client)
})
} | go | func (s *Server) OnDisconnect(f func(*Client)) {
s.eventHub.Subscribe(clientDisconnected, func(e hub.Event) {
go f(e.(disconnectionEvent).Client)
})
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"OnDisconnect",
"(",
"f",
"func",
"(",
"*",
"Client",
")",
")",
"{",
"s",
".",
"eventHub",
".",
"Subscribe",
"(",
"clientDisconnected",
",",
"func",
"(",
"e",
"hub",
".",
"Event",
")",
"{",
"go",
"f",
"(",
"e... | // OnDisconnect registers a function to run when a client disconnects. | [
"OnDisconnect",
"registers",
"a",
"function",
"to",
"run",
"when",
"a",
"client",
"disconnects",
"."
] | 9642ea02d0aad04b8efb5e1a6bbc63daf8d0903d | https://github.com/cenkalti/rpc2/blob/9642ea02d0aad04b8efb5e1a6bbc63daf8d0903d/server.go#L132-L136 |
137,170 | cenkalti/rpc2 | server.go | ServeCodecWithState | func (s *Server) ServeCodecWithState(codec Codec, state *State) {
defer codec.Close()
// Client also handles the incoming connections.
c := NewClientWithCodec(codec)
c.server = true
c.handlers = s.handlers
c.State = state
s.eventHub.Publish(connectionEvent{c})
c.Run()
s.eventHub.Publish(disconnectionEvent{c}... | go | func (s *Server) ServeCodecWithState(codec Codec, state *State) {
defer codec.Close()
// Client also handles the incoming connections.
c := NewClientWithCodec(codec)
c.server = true
c.handlers = s.handlers
c.State = state
s.eventHub.Publish(connectionEvent{c})
c.Run()
s.eventHub.Publish(disconnectionEvent{c}... | [
"func",
"(",
"s",
"*",
"Server",
")",
"ServeCodecWithState",
"(",
"codec",
"Codec",
",",
"state",
"*",
"State",
")",
"{",
"defer",
"codec",
".",
"Close",
"(",
")",
"\n\n",
"// Client also handles the incoming connections.",
"c",
":=",
"NewClientWithCodec",
"(",
... | // ServeCodecWithState is like ServeCodec but also gives the ability to
// associate a state variable with the client that persists across RPC calls. | [
"ServeCodecWithState",
"is",
"like",
"ServeCodec",
"but",
"also",
"gives",
"the",
"ability",
"to",
"associate",
"a",
"state",
"variable",
"with",
"the",
"client",
"that",
"persists",
"across",
"RPC",
"calls",
"."
] | 9642ea02d0aad04b8efb5e1a6bbc63daf8d0903d | https://github.com/cenkalti/rpc2/blob/9642ea02d0aad04b8efb5e1a6bbc63daf8d0903d/server.go#L168-L180 |
137,171 | DeanThompson/syncmap | syncmap.go | locate | func (m *SyncMap) locate(key string) *syncMap {
return m.shards[bkdrHash(key)&uint32((m.shardCount-1))]
} | go | func (m *SyncMap) locate(key string) *syncMap {
return m.shards[bkdrHash(key)&uint32((m.shardCount-1))]
} | [
"func",
"(",
"m",
"*",
"SyncMap",
")",
"locate",
"(",
"key",
"string",
")",
"*",
"syncMap",
"{",
"return",
"m",
".",
"shards",
"[",
"bkdrHash",
"(",
"key",
")",
"&",
"uint32",
"(",
"(",
"m",
".",
"shardCount",
"-",
"1",
")",
")",
"]",
"\n",
"}"... | // Find the specific shard with the given key | [
"Find",
"the",
"specific",
"shard",
"with",
"the",
"given",
"key"
] | 05cfe1984971e6e97ad4f92c3feb375f47597d71 | https://github.com/DeanThompson/syncmap/blob/05cfe1984971e6e97ad4f92c3feb375f47597d71/syncmap.go#L48-L50 |
137,172 | DeanThompson/syncmap | syncmap.go | Get | func (m *SyncMap) Get(key string) (value interface{}, ok bool) {
shard := m.locate(key)
shard.RLock()
value, ok = shard.items[key]
shard.RUnlock()
return
} | go | func (m *SyncMap) Get(key string) (value interface{}, ok bool) {
shard := m.locate(key)
shard.RLock()
value, ok = shard.items[key]
shard.RUnlock()
return
} | [
"func",
"(",
"m",
"*",
"SyncMap",
")",
"Get",
"(",
"key",
"string",
")",
"(",
"value",
"interface",
"{",
"}",
",",
"ok",
"bool",
")",
"{",
"shard",
":=",
"m",
".",
"locate",
"(",
"key",
")",
"\n",
"shard",
".",
"RLock",
"(",
")",
"\n",
"value",... | // Retrieves a value | [
"Retrieves",
"a",
"value"
] | 05cfe1984971e6e97ad4f92c3feb375f47597d71 | https://github.com/DeanThompson/syncmap/blob/05cfe1984971e6e97ad4f92c3feb375f47597d71/syncmap.go#L53-L59 |
137,173 | DeanThompson/syncmap | syncmap.go | Set | func (m *SyncMap) Set(key string, value interface{}) {
shard := m.locate(key)
shard.Lock()
shard.items[key] = value
shard.Unlock()
} | go | func (m *SyncMap) Set(key string, value interface{}) {
shard := m.locate(key)
shard.Lock()
shard.items[key] = value
shard.Unlock()
} | [
"func",
"(",
"m",
"*",
"SyncMap",
")",
"Set",
"(",
"key",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"{",
"shard",
":=",
"m",
".",
"locate",
"(",
"key",
")",
"\n",
"shard",
".",
"Lock",
"(",
")",
"\n",
"shard",
".",
"items",
"[",
"key"... | // Sets value with the given key | [
"Sets",
"value",
"with",
"the",
"given",
"key"
] | 05cfe1984971e6e97ad4f92c3feb375f47597d71 | https://github.com/DeanThompson/syncmap/blob/05cfe1984971e6e97ad4f92c3feb375f47597d71/syncmap.go#L62-L67 |
137,174 | DeanThompson/syncmap | syncmap.go | Delete | func (m *SyncMap) Delete(key string) {
shard := m.locate(key)
shard.Lock()
delete(shard.items, key)
shard.Unlock()
} | go | func (m *SyncMap) Delete(key string) {
shard := m.locate(key)
shard.Lock()
delete(shard.items, key)
shard.Unlock()
} | [
"func",
"(",
"m",
"*",
"SyncMap",
")",
"Delete",
"(",
"key",
"string",
")",
"{",
"shard",
":=",
"m",
".",
"locate",
"(",
"key",
")",
"\n",
"shard",
".",
"Lock",
"(",
")",
"\n",
"delete",
"(",
"shard",
".",
"items",
",",
"key",
")",
"\n",
"shard... | // Removes an item | [
"Removes",
"an",
"item"
] | 05cfe1984971e6e97ad4f92c3feb375f47597d71 | https://github.com/DeanThompson/syncmap/blob/05cfe1984971e6e97ad4f92c3feb375f47597d71/syncmap.go#L70-L75 |
137,175 | DeanThompson/syncmap | syncmap.go | Pop | func (m *SyncMap) Pop() (string, interface{}) {
if m.Size() == 0 {
panic("syncmap: map is empty")
}
var (
key string
value interface{}
found = false
n = int(m.shardCount)
)
for !found {
idx := rand.Intn(n)
shard := m.shards[idx]
shard.Lock()
if len(shard.items) > 0 {
found = true
fo... | go | func (m *SyncMap) Pop() (string, interface{}) {
if m.Size() == 0 {
panic("syncmap: map is empty")
}
var (
key string
value interface{}
found = false
n = int(m.shardCount)
)
for !found {
idx := rand.Intn(n)
shard := m.shards[idx]
shard.Lock()
if len(shard.items) > 0 {
found = true
fo... | [
"func",
"(",
"m",
"*",
"SyncMap",
")",
"Pop",
"(",
")",
"(",
"string",
",",
"interface",
"{",
"}",
")",
"{",
"if",
"m",
".",
"Size",
"(",
")",
"==",
"0",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"var",
"(",
"key",
"string",
"\... | // Pop delete and return a random item in the cache | [
"Pop",
"delete",
"and",
"return",
"a",
"random",
"item",
"in",
"the",
"cache"
] | 05cfe1984971e6e97ad4f92c3feb375f47597d71 | https://github.com/DeanThompson/syncmap/blob/05cfe1984971e6e97ad4f92c3feb375f47597d71/syncmap.go#L78-L105 |
137,176 | DeanThompson/syncmap | syncmap.go | Has | func (m *SyncMap) Has(key string) bool {
_, ok := m.Get(key)
return ok
} | go | func (m *SyncMap) Has(key string) bool {
_, ok := m.Get(key)
return ok
} | [
"func",
"(",
"m",
"*",
"SyncMap",
")",
"Has",
"(",
"key",
"string",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"m",
".",
"Get",
"(",
"key",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // Whether SyncMap has the given key | [
"Whether",
"SyncMap",
"has",
"the",
"given",
"key"
] | 05cfe1984971e6e97ad4f92c3feb375f47597d71 | https://github.com/DeanThompson/syncmap/blob/05cfe1984971e6e97ad4f92c3feb375f47597d71/syncmap.go#L108-L111 |
137,177 | DeanThompson/syncmap | syncmap.go | Size | func (m *SyncMap) Size() int {
size := 0
for _, shard := range m.shards {
shard.RLock()
size += len(shard.items)
shard.RUnlock()
}
return size
} | go | func (m *SyncMap) Size() int {
size := 0
for _, shard := range m.shards {
shard.RLock()
size += len(shard.items)
shard.RUnlock()
}
return size
} | [
"func",
"(",
"m",
"*",
"SyncMap",
")",
"Size",
"(",
")",
"int",
"{",
"size",
":=",
"0",
"\n",
"for",
"_",
",",
"shard",
":=",
"range",
"m",
".",
"shards",
"{",
"shard",
".",
"RLock",
"(",
")",
"\n",
"size",
"+=",
"len",
"(",
"shard",
".",
"it... | // Returns the number of items | [
"Returns",
"the",
"number",
"of",
"items"
] | 05cfe1984971e6e97ad4f92c3feb375f47597d71 | https://github.com/DeanThompson/syncmap/blob/05cfe1984971e6e97ad4f92c3feb375f47597d71/syncmap.go#L114-L122 |
137,178 | DeanThompson/syncmap | syncmap.go | Flush | func (m *SyncMap) Flush() int {
size := 0
for _, shard := range m.shards {
shard.Lock()
size += len(shard.items)
shard.items = make(map[string]interface{})
shard.Unlock()
}
return size
} | go | func (m *SyncMap) Flush() int {
size := 0
for _, shard := range m.shards {
shard.Lock()
size += len(shard.items)
shard.items = make(map[string]interface{})
shard.Unlock()
}
return size
} | [
"func",
"(",
"m",
"*",
"SyncMap",
")",
"Flush",
"(",
")",
"int",
"{",
"size",
":=",
"0",
"\n",
"for",
"_",
",",
"shard",
":=",
"range",
"m",
".",
"shards",
"{",
"shard",
".",
"Lock",
"(",
")",
"\n",
"size",
"+=",
"len",
"(",
"shard",
".",
"it... | // Wipes all items from the map | [
"Wipes",
"all",
"items",
"from",
"the",
"map"
] | 05cfe1984971e6e97ad4f92c3feb375f47597d71 | https://github.com/DeanThompson/syncmap/blob/05cfe1984971e6e97ad4f92c3feb375f47597d71/syncmap.go#L125-L134 |
137,179 | DeanThompson/syncmap | syncmap.go | IterKeys | func (m *SyncMap) IterKeys() <-chan string {
ch := make(chan string)
go func() {
m.EachKey(func(key string) {
ch <- key
})
close(ch)
}()
return ch
} | go | func (m *SyncMap) IterKeys() <-chan string {
ch := make(chan string)
go func() {
m.EachKey(func(key string) {
ch <- key
})
close(ch)
}()
return ch
} | [
"func",
"(",
"m",
"*",
"SyncMap",
")",
"IterKeys",
"(",
")",
"<-",
"chan",
"string",
"{",
"ch",
":=",
"make",
"(",
"chan",
"string",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"m",
".",
"EachKey",
"(",
"func",
"(",
"key",
"string",
")",
"{",
"ch",... | // Returns a channel from which each key in the map can be read | [
"Returns",
"a",
"channel",
"from",
"which",
"each",
"key",
"in",
"the",
"map",
"can",
"be",
"read"
] | 05cfe1984971e6e97ad4f92c3feb375f47597d71 | https://github.com/DeanThompson/syncmap/blob/05cfe1984971e6e97ad4f92c3feb375f47597d71/syncmap.go#L175-L184 |
137,180 | terra-farm/go-xen-api-client | pgpu_gen.go | GetAllRecords | func (_class PGPUClass) GetAllRecords(sessionID SessionRef) (_retval map[PGPURef]PGPURecord, _err error) {
_method := "PGPU.get_all_records"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_result, _err := _class.client.APICall(_met... | go | func (_class PGPUClass) GetAllRecords(sessionID SessionRef) (_retval map[PGPURef]PGPURecord, _err error) {
_method := "PGPU.get_all_records"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_result, _err := _class.client.APICall(_met... | [
"func",
"(",
"_class",
"PGPUClass",
")",
"GetAllRecords",
"(",
"sessionID",
"SessionRef",
")",
"(",
"_retval",
"map",
"[",
"PGPURef",
"]",
"PGPURecord",
",",
"_err",
"error",
")",
"{",
"_method",
":=",
"\"",
"\"",
"\n",
"_sessionIDArg",
",",
"_err",
":=",
... | // Return a map of PGPU references to PGPU records for all PGPUs known to the system. | [
"Return",
"a",
"map",
"of",
"PGPU",
"references",
"to",
"PGPU",
"records",
"for",
"all",
"PGPUs",
"known",
"to",
"the",
"system",
"."
] | edb53e3930c18c373c1a5e6c0eacd0b5c669fefb | https://github.com/terra-farm/go-xen-api-client/blob/edb53e3930c18c373c1a5e6c0eacd0b5c669fefb/pgpu_gen.go#L71-L83 |
137,181 | terra-farm/go-xen-api-client | pgpu_gen.go | GetAll | func (_class PGPUClass) GetAll(sessionID SessionRef) (_retval []PGPURef, _err error) {
_method := "PGPU.get_all"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_result, _err := _class.client.APICall(_method, _sessionIDArg)
if _err... | go | func (_class PGPUClass) GetAll(sessionID SessionRef) (_retval []PGPURef, _err error) {
_method := "PGPU.get_all"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_result, _err := _class.client.APICall(_method, _sessionIDArg)
if _err... | [
"func",
"(",
"_class",
"PGPUClass",
")",
"GetAll",
"(",
"sessionID",
"SessionRef",
")",
"(",
"_retval",
"[",
"]",
"PGPURef",
",",
"_err",
"error",
")",
"{",
"_method",
":=",
"\"",
"\"",
"\n",
"_sessionIDArg",
",",
"_err",
":=",
"convertSessionRefToXen",
"(... | // Return a list of all the PGPUs known to the system. | [
"Return",
"a",
"list",
"of",
"all",
"the",
"PGPUs",
"known",
"to",
"the",
"system",
"."
] | edb53e3930c18c373c1a5e6c0eacd0b5c669fefb | https://github.com/terra-farm/go-xen-api-client/blob/edb53e3930c18c373c1a5e6c0eacd0b5c669fefb/pgpu_gen.go#L86-L98 |
137,182 | terra-farm/go-xen-api-client | pgpu_gen.go | GetIsSystemDisplayDevice | func (_class PGPUClass) GetIsSystemDisplayDevice(sessionID SessionRef, self PGPURef) (_retval bool, _err error) {
_method := "PGPU.get_is_system_display_device"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_selfArg, _err := conve... | go | func (_class PGPUClass) GetIsSystemDisplayDevice(sessionID SessionRef, self PGPURef) (_retval bool, _err error) {
_method := "PGPU.get_is_system_display_device"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_selfArg, _err := conve... | [
"func",
"(",
"_class",
"PGPUClass",
")",
"GetIsSystemDisplayDevice",
"(",
"sessionID",
"SessionRef",
",",
"self",
"PGPURef",
")",
"(",
"_retval",
"bool",
",",
"_err",
"error",
")",
"{",
"_method",
":=",
"\"",
"\"",
"\n",
"_sessionIDArg",
",",
"_err",
":=",
... | // Get the is_system_display_device field of the given PGPU. | [
"Get",
"the",
"is_system_display_device",
"field",
"of",
"the",
"given",
"PGPU",
"."
] | edb53e3930c18c373c1a5e6c0eacd0b5c669fefb | https://github.com/terra-farm/go-xen-api-client/blob/edb53e3930c18c373c1a5e6c0eacd0b5c669fefb/pgpu_gen.go#L318-L334 |
137,183 | terra-farm/go-xen-api-client | pgpu_gen.go | GetDom0Access | func (_class PGPUClass) GetDom0Access(sessionID SessionRef, self PGPURef) (_retval PgpuDom0Access, _err error) {
_method := "PGPU.get_dom0_access"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_selfArg, _err := convertPGPURefToXen... | go | func (_class PGPUClass) GetDom0Access(sessionID SessionRef, self PGPURef) (_retval PgpuDom0Access, _err error) {
_method := "PGPU.get_dom0_access"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_selfArg, _err := convertPGPURefToXen... | [
"func",
"(",
"_class",
"PGPUClass",
")",
"GetDom0Access",
"(",
"sessionID",
"SessionRef",
",",
"self",
"PGPURef",
")",
"(",
"_retval",
"PgpuDom0Access",
",",
"_err",
"error",
")",
"{",
"_method",
":=",
"\"",
"\"",
"\n",
"_sessionIDArg",
",",
"_err",
":=",
... | // Get the dom0_access field of the given PGPU. | [
"Get",
"the",
"dom0_access",
"field",
"of",
"the",
"given",
"PGPU",
"."
] | edb53e3930c18c373c1a5e6c0eacd0b5c669fefb | https://github.com/terra-farm/go-xen-api-client/blob/edb53e3930c18c373c1a5e6c0eacd0b5c669fefb/pgpu_gen.go#L337-L353 |
137,184 | terra-farm/go-xen-api-client | pgpu_gen.go | GetSupportedVGPUMaxCapacities | func (_class PGPUClass) GetSupportedVGPUMaxCapacities(sessionID SessionRef, self PGPURef) (_retval map[VGPUTypeRef]int, _err error) {
_method := "PGPU.get_supported_VGPU_max_capacities"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}... | go | func (_class PGPUClass) GetSupportedVGPUMaxCapacities(sessionID SessionRef, self PGPURef) (_retval map[VGPUTypeRef]int, _err error) {
_method := "PGPU.get_supported_VGPU_max_capacities"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}... | [
"func",
"(",
"_class",
"PGPUClass",
")",
"GetSupportedVGPUMaxCapacities",
"(",
"sessionID",
"SessionRef",
",",
"self",
"PGPURef",
")",
"(",
"_retval",
"map",
"[",
"VGPUTypeRef",
"]",
"int",
",",
"_err",
"error",
")",
"{",
"_method",
":=",
"\"",
"\"",
"\n",
... | // Get the supported_VGPU_max_capacities field of the given PGPU. | [
"Get",
"the",
"supported_VGPU_max_capacities",
"field",
"of",
"the",
"given",
"PGPU",
"."
] | edb53e3930c18c373c1a5e6c0eacd0b5c669fefb | https://github.com/terra-farm/go-xen-api-client/blob/edb53e3930c18c373c1a5e6c0eacd0b5c669fefb/pgpu_gen.go#L356-L372 |
137,185 | terra-farm/go-xen-api-client | pgpu_gen.go | GetResidentVGPUs | func (_class PGPUClass) GetResidentVGPUs(sessionID SessionRef, self PGPURef) (_retval []VGPURef, _err error) {
_method := "PGPU.get_resident_VGPUs"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_selfArg, _err := convertPGPURefToXe... | go | func (_class PGPUClass) GetResidentVGPUs(sessionID SessionRef, self PGPURef) (_retval []VGPURef, _err error) {
_method := "PGPU.get_resident_VGPUs"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_selfArg, _err := convertPGPURefToXe... | [
"func",
"(",
"_class",
"PGPUClass",
")",
"GetResidentVGPUs",
"(",
"sessionID",
"SessionRef",
",",
"self",
"PGPURef",
")",
"(",
"_retval",
"[",
"]",
"VGPURef",
",",
"_err",
"error",
")",
"{",
"_method",
":=",
"\"",
"\"",
"\n",
"_sessionIDArg",
",",
"_err",
... | // Get the resident_VGPUs field of the given PGPU. | [
"Get",
"the",
"resident_VGPUs",
"field",
"of",
"the",
"given",
"PGPU",
"."
] | edb53e3930c18c373c1a5e6c0eacd0b5c669fefb | https://github.com/terra-farm/go-xen-api-client/blob/edb53e3930c18c373c1a5e6c0eacd0b5c669fefb/pgpu_gen.go#L375-L391 |
137,186 | terra-farm/go-xen-api-client | pgpu_gen.go | GetHost | func (_class PGPUClass) GetHost(sessionID SessionRef, self PGPURef) (_retval HostRef, _err error) {
_method := "PGPU.get_host"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_selfArg, _err := convertPGPURefToXen(fmt.Sprintf("%s(%s)... | go | func (_class PGPUClass) GetHost(sessionID SessionRef, self PGPURef) (_retval HostRef, _err error) {
_method := "PGPU.get_host"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_selfArg, _err := convertPGPURefToXen(fmt.Sprintf("%s(%s)... | [
"func",
"(",
"_class",
"PGPUClass",
")",
"GetHost",
"(",
"sessionID",
"SessionRef",
",",
"self",
"PGPURef",
")",
"(",
"_retval",
"HostRef",
",",
"_err",
"error",
")",
"{",
"_method",
":=",
"\"",
"\"",
"\n",
"_sessionIDArg",
",",
"_err",
":=",
"convertSessi... | // Get the host field of the given PGPU. | [
"Get",
"the",
"host",
"field",
"of",
"the",
"given",
"PGPU",
"."
] | edb53e3930c18c373c1a5e6c0eacd0b5c669fefb | https://github.com/terra-farm/go-xen-api-client/blob/edb53e3930c18c373c1a5e6c0eacd0b5c669fefb/pgpu_gen.go#L451-L467 |
137,187 | terra-farm/go-xen-api-client | pgpu_gen.go | GetGPUGroup | func (_class PGPUClass) GetGPUGroup(sessionID SessionRef, self PGPURef) (_retval GPUGroupRef, _err error) {
_method := "PGPU.get_GPU_group"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_selfArg, _err := convertPGPURefToXen(fmt.Sp... | go | func (_class PGPUClass) GetGPUGroup(sessionID SessionRef, self PGPURef) (_retval GPUGroupRef, _err error) {
_method := "PGPU.get_GPU_group"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_selfArg, _err := convertPGPURefToXen(fmt.Sp... | [
"func",
"(",
"_class",
"PGPUClass",
")",
"GetGPUGroup",
"(",
"sessionID",
"SessionRef",
",",
"self",
"PGPURef",
")",
"(",
"_retval",
"GPUGroupRef",
",",
"_err",
"error",
")",
"{",
"_method",
":=",
"\"",
"\"",
"\n",
"_sessionIDArg",
",",
"_err",
":=",
"conv... | // Get the GPU_group field of the given PGPU. | [
"Get",
"the",
"GPU_group",
"field",
"of",
"the",
"given",
"PGPU",
"."
] | edb53e3930c18c373c1a5e6c0eacd0b5c669fefb | https://github.com/terra-farm/go-xen-api-client/blob/edb53e3930c18c373c1a5e6c0eacd0b5c669fefb/pgpu_gen.go#L470-L486 |
137,188 | terra-farm/go-xen-api-client | pgpu_gen.go | GetPCI | func (_class PGPUClass) GetPCI(sessionID SessionRef, self PGPURef) (_retval PCIRef, _err error) {
_method := "PGPU.get_PCI"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_selfArg, _err := convertPGPURefToXen(fmt.Sprintf("%s(%s)", ... | go | func (_class PGPUClass) GetPCI(sessionID SessionRef, self PGPURef) (_retval PCIRef, _err error) {
_method := "PGPU.get_PCI"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_selfArg, _err := convertPGPURefToXen(fmt.Sprintf("%s(%s)", ... | [
"func",
"(",
"_class",
"PGPUClass",
")",
"GetPCI",
"(",
"sessionID",
"SessionRef",
",",
"self",
"PGPURef",
")",
"(",
"_retval",
"PCIRef",
",",
"_err",
"error",
")",
"{",
"_method",
":=",
"\"",
"\"",
"\n",
"_sessionIDArg",
",",
"_err",
":=",
"convertSession... | // Get the PCI field of the given PGPU. | [
"Get",
"the",
"PCI",
"field",
"of",
"the",
"given",
"PGPU",
"."
] | edb53e3930c18c373c1a5e6c0eacd0b5c669fefb | https://github.com/terra-farm/go-xen-api-client/blob/edb53e3930c18c373c1a5e6c0eacd0b5c669fefb/pgpu_gen.go#L489-L505 |
137,189 | terra-farm/go-xen-api-client | pgpu_gen.go | GetRecord | func (_class PGPUClass) GetRecord(sessionID SessionRef, self PGPURef) (_retval PGPURecord, _err error) {
_method := "PGPU.get_record"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_selfArg, _err := convertPGPURefToXen(fmt.Sprintf(... | go | func (_class PGPUClass) GetRecord(sessionID SessionRef, self PGPURef) (_retval PGPURecord, _err error) {
_method := "PGPU.get_record"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_selfArg, _err := convertPGPURefToXen(fmt.Sprintf(... | [
"func",
"(",
"_class",
"PGPUClass",
")",
"GetRecord",
"(",
"sessionID",
"SessionRef",
",",
"self",
"PGPURef",
")",
"(",
"_retval",
"PGPURecord",
",",
"_err",
"error",
")",
"{",
"_method",
":=",
"\"",
"\"",
"\n",
"_sessionIDArg",
",",
"_err",
":=",
"convert... | // Get a record containing the current state of the given PGPU. | [
"Get",
"a",
"record",
"containing",
"the",
"current",
"state",
"of",
"the",
"given",
"PGPU",
"."
] | edb53e3930c18c373c1a5e6c0eacd0b5c669fefb | https://github.com/terra-farm/go-xen-api-client/blob/edb53e3930c18c373c1a5e6c0eacd0b5c669fefb/pgpu_gen.go#L546-L562 |
137,190 | terra-farm/go-xen-api-client | pbd_gen.go | GetAllRecords | func (_class PBDClass) GetAllRecords(sessionID SessionRef) (_retval map[PBDRef]PBDRecord, _err error) {
_method := "PBD.get_all_records"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_result, _err := _class.client.APICall(_method,... | go | func (_class PBDClass) GetAllRecords(sessionID SessionRef) (_retval map[PBDRef]PBDRecord, _err error) {
_method := "PBD.get_all_records"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_result, _err := _class.client.APICall(_method,... | [
"func",
"(",
"_class",
"PBDClass",
")",
"GetAllRecords",
"(",
"sessionID",
"SessionRef",
")",
"(",
"_retval",
"map",
"[",
"PBDRef",
"]",
"PBDRecord",
",",
"_err",
"error",
")",
"{",
"_method",
":=",
"\"",
"\"",
"\n",
"_sessionIDArg",
",",
"_err",
":=",
"... | // Return a map of PBD references to PBD records for all PBDs known to the system. | [
"Return",
"a",
"map",
"of",
"PBD",
"references",
"to",
"PBD",
"records",
"for",
"all",
"PBDs",
"known",
"to",
"the",
"system",
"."
] | edb53e3930c18c373c1a5e6c0eacd0b5c669fefb | https://github.com/terra-farm/go-xen-api-client/blob/edb53e3930c18c373c1a5e6c0eacd0b5c669fefb/pbd_gen.go#L46-L58 |
137,191 | terra-farm/go-xen-api-client | pbd_gen.go | GetAll | func (_class PBDClass) GetAll(sessionID SessionRef) (_retval []PBDRef, _err error) {
_method := "PBD.get_all"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_result, _err := _class.client.APICall(_method, _sessionIDArg)
if _err !=... | go | func (_class PBDClass) GetAll(sessionID SessionRef) (_retval []PBDRef, _err error) {
_method := "PBD.get_all"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_result, _err := _class.client.APICall(_method, _sessionIDArg)
if _err !=... | [
"func",
"(",
"_class",
"PBDClass",
")",
"GetAll",
"(",
"sessionID",
"SessionRef",
")",
"(",
"_retval",
"[",
"]",
"PBDRef",
",",
"_err",
"error",
")",
"{",
"_method",
":=",
"\"",
"\"",
"\n",
"_sessionIDArg",
",",
"_err",
":=",
"convertSessionRefToXen",
"(",... | // Return a list of all the PBDs known to the system. | [
"Return",
"a",
"list",
"of",
"all",
"the",
"PBDs",
"known",
"to",
"the",
"system",
"."
] | edb53e3930c18c373c1a5e6c0eacd0b5c669fefb | https://github.com/terra-farm/go-xen-api-client/blob/edb53e3930c18c373c1a5e6c0eacd0b5c669fefb/pbd_gen.go#L61-L73 |
137,192 | terra-farm/go-xen-api-client | pbd_gen.go | Unplug | func (_class PBDClass) Unplug(sessionID SessionRef, self PBDRef) (_err error) {
_method := "PBD.unplug"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_selfArg, _err := convertPBDRefToXen(fmt.Sprintf("%s(%s)", _method, "self"), sel... | go | func (_class PBDClass) Unplug(sessionID SessionRef, self PBDRef) (_err error) {
_method := "PBD.unplug"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_selfArg, _err := convertPBDRefToXen(fmt.Sprintf("%s(%s)", _method, "self"), sel... | [
"func",
"(",
"_class",
"PBDClass",
")",
"Unplug",
"(",
"sessionID",
"SessionRef",
",",
"self",
"PBDRef",
")",
"(",
"_err",
"error",
")",
"{",
"_method",
":=",
"\"",
"\"",
"\n",
"_sessionIDArg",
",",
"_err",
":=",
"convertSessionRefToXen",
"(",
"fmt",
".",
... | // Deactivate the specified PBD, causing the referenced SR to be detached and nolonger scanned | [
"Deactivate",
"the",
"specified",
"PBD",
"causing",
"the",
"referenced",
"SR",
"to",
"be",
"detached",
"and",
"nolonger",
"scanned"
] | edb53e3930c18c373c1a5e6c0eacd0b5c669fefb | https://github.com/terra-farm/go-xen-api-client/blob/edb53e3930c18c373c1a5e6c0eacd0b5c669fefb/pbd_gen.go#L95-L107 |
137,193 | terra-farm/go-xen-api-client | pbd_gen.go | GetCurrentlyAttached | func (_class PBDClass) GetCurrentlyAttached(sessionID SessionRef, self PBDRef) (_retval bool, _err error) {
_method := "PBD.get_currently_attached"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_selfArg, _err := convertPBDRefToXen... | go | func (_class PBDClass) GetCurrentlyAttached(sessionID SessionRef, self PBDRef) (_retval bool, _err error) {
_method := "PBD.get_currently_attached"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_selfArg, _err := convertPBDRefToXen... | [
"func",
"(",
"_class",
"PBDClass",
")",
"GetCurrentlyAttached",
"(",
"sessionID",
"SessionRef",
",",
"self",
"PBDRef",
")",
"(",
"_retval",
"bool",
",",
"_err",
"error",
")",
"{",
"_method",
":=",
"\"",
"\"",
"\n",
"_sessionIDArg",
",",
"_err",
":=",
"conv... | // Get the currently_attached field of the given PBD. | [
"Get",
"the",
"currently_attached",
"field",
"of",
"the",
"given",
"PBD",
"."
] | edb53e3930c18c373c1a5e6c0eacd0b5c669fefb | https://github.com/terra-farm/go-xen-api-client/blob/edb53e3930c18c373c1a5e6c0eacd0b5c669fefb/pbd_gen.go#L208-L224 |
137,194 | terra-farm/go-xen-api-client | pbd_gen.go | GetSR | func (_class PBDClass) GetSR(sessionID SessionRef, self PBDRef) (_retval SRRef, _err error) {
_method := "PBD.get_SR"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_selfArg, _err := convertPBDRefToXen(fmt.Sprintf("%s(%s)", _method... | go | func (_class PBDClass) GetSR(sessionID SessionRef, self PBDRef) (_retval SRRef, _err error) {
_method := "PBD.get_SR"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_selfArg, _err := convertPBDRefToXen(fmt.Sprintf("%s(%s)", _method... | [
"func",
"(",
"_class",
"PBDClass",
")",
"GetSR",
"(",
"sessionID",
"SessionRef",
",",
"self",
"PBDRef",
")",
"(",
"_retval",
"SRRef",
",",
"_err",
"error",
")",
"{",
"_method",
":=",
"\"",
"\"",
"\n",
"_sessionIDArg",
",",
"_err",
":=",
"convertSessionRefT... | // Get the SR field of the given PBD. | [
"Get",
"the",
"SR",
"field",
"of",
"the",
"given",
"PBD",
"."
] | edb53e3930c18c373c1a5e6c0eacd0b5c669fefb | https://github.com/terra-farm/go-xen-api-client/blob/edb53e3930c18c373c1a5e6c0eacd0b5c669fefb/pbd_gen.go#L246-L262 |
137,195 | terra-farm/go-xen-api-client | pbd_gen.go | GetHost | func (_class PBDClass) GetHost(sessionID SessionRef, self PBDRef) (_retval HostRef, _err error) {
_method := "PBD.get_host"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_selfArg, _err := convertPBDRefToXen(fmt.Sprintf("%s(%s)", _... | go | func (_class PBDClass) GetHost(sessionID SessionRef, self PBDRef) (_retval HostRef, _err error) {
_method := "PBD.get_host"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_selfArg, _err := convertPBDRefToXen(fmt.Sprintf("%s(%s)", _... | [
"func",
"(",
"_class",
"PBDClass",
")",
"GetHost",
"(",
"sessionID",
"SessionRef",
",",
"self",
"PBDRef",
")",
"(",
"_retval",
"HostRef",
",",
"_err",
"error",
")",
"{",
"_method",
":=",
"\"",
"\"",
"\n",
"_sessionIDArg",
",",
"_err",
":=",
"convertSession... | // Get the host field of the given PBD. | [
"Get",
"the",
"host",
"field",
"of",
"the",
"given",
"PBD",
"."
] | edb53e3930c18c373c1a5e6c0eacd0b5c669fefb | https://github.com/terra-farm/go-xen-api-client/blob/edb53e3930c18c373c1a5e6c0eacd0b5c669fefb/pbd_gen.go#L265-L281 |
137,196 | terra-farm/go-xen-api-client | pbd_gen.go | GetRecord | func (_class PBDClass) GetRecord(sessionID SessionRef, self PBDRef) (_retval PBDRecord, _err error) {
_method := "PBD.get_record"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_selfArg, _err := convertPBDRefToXen(fmt.Sprintf("%s(%... | go | func (_class PBDClass) GetRecord(sessionID SessionRef, self PBDRef) (_retval PBDRecord, _err error) {
_method := "PBD.get_record"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_selfArg, _err := convertPBDRefToXen(fmt.Sprintf("%s(%... | [
"func",
"(",
"_class",
"PBDClass",
")",
"GetRecord",
"(",
"sessionID",
"SessionRef",
",",
"self",
"PBDRef",
")",
"(",
"_retval",
"PBDRecord",
",",
"_err",
"error",
")",
"{",
"_method",
":=",
"\"",
"\"",
"\n",
"_sessionIDArg",
",",
"_err",
":=",
"convertSes... | // Get a record containing the current state of the given PBD. | [
"Get",
"a",
"record",
"containing",
"the",
"current",
"state",
"of",
"the",
"given",
"PBD",
"."
] | edb53e3930c18c373c1a5e6c0eacd0b5c669fefb | https://github.com/terra-farm/go-xen-api-client/blob/edb53e3930c18c373c1a5e6c0eacd0b5c669fefb/pbd_gen.go#L357-L373 |
137,197 | terra-farm/go-xen-api-client | vm_appliance_gen.go | GetAllRecords | func (_class VMApplianceClass) GetAllRecords(sessionID SessionRef) (_retval map[VMApplianceRef]VMApplianceRecord, _err error) {
_method := "VM_appliance.get_all_records"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_result, _err ... | go | func (_class VMApplianceClass) GetAllRecords(sessionID SessionRef) (_retval map[VMApplianceRef]VMApplianceRecord, _err error) {
_method := "VM_appliance.get_all_records"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_result, _err ... | [
"func",
"(",
"_class",
"VMApplianceClass",
")",
"GetAllRecords",
"(",
"sessionID",
"SessionRef",
")",
"(",
"_retval",
"map",
"[",
"VMApplianceRef",
"]",
"VMApplianceRecord",
",",
"_err",
"error",
")",
"{",
"_method",
":=",
"\"",
"\"",
"\n",
"_sessionIDArg",
",... | // Return a map of VM_appliance references to VM_appliance records for all VM_appliances known to the system. | [
"Return",
"a",
"map",
"of",
"VM_appliance",
"references",
"to",
"VM_appliance",
"records",
"for",
"all",
"VM_appliances",
"known",
"to",
"the",
"system",
"."
] | edb53e3930c18c373c1a5e6c0eacd0b5c669fefb | https://github.com/terra-farm/go-xen-api-client/blob/edb53e3930c18c373c1a5e6c0eacd0b5c669fefb/vm_appliance_gen.go#L59-L71 |
137,198 | terra-farm/go-xen-api-client | vm_appliance_gen.go | GetAll | func (_class VMApplianceClass) GetAll(sessionID SessionRef) (_retval []VMApplianceRef, _err error) {
_method := "VM_appliance.get_all"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_result, _err := _class.client.APICall(_method, _... | go | func (_class VMApplianceClass) GetAll(sessionID SessionRef) (_retval []VMApplianceRef, _err error) {
_method := "VM_appliance.get_all"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_result, _err := _class.client.APICall(_method, _... | [
"func",
"(",
"_class",
"VMApplianceClass",
")",
"GetAll",
"(",
"sessionID",
"SessionRef",
")",
"(",
"_retval",
"[",
"]",
"VMApplianceRef",
",",
"_err",
"error",
")",
"{",
"_method",
":=",
"\"",
"\"",
"\n",
"_sessionIDArg",
",",
"_err",
":=",
"convertSessionR... | // Return a list of all the VM_appliances known to the system. | [
"Return",
"a",
"list",
"of",
"all",
"the",
"VM_appliances",
"known",
"to",
"the",
"system",
"."
] | edb53e3930c18c373c1a5e6c0eacd0b5c669fefb | https://github.com/terra-farm/go-xen-api-client/blob/edb53e3930c18c373c1a5e6c0eacd0b5c669fefb/vm_appliance_gen.go#L74-L86 |
137,199 | terra-farm/go-xen-api-client | vm_appliance_gen.go | GetSRsRequiredForRecovery | func (_class VMApplianceClass) GetSRsRequiredForRecovery(sessionID SessionRef, self VMApplianceRef, sessionTo SessionRef) (_retval []SRRef, _err error) {
_method := "VM_appliance.get_SRs_required_for_recovery"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _... | go | func (_class VMApplianceClass) GetSRsRequiredForRecovery(sessionID SessionRef, self VMApplianceRef, sessionTo SessionRef) (_retval []SRRef, _err error) {
_method := "VM_appliance.get_SRs_required_for_recovery"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _... | [
"func",
"(",
"_class",
"VMApplianceClass",
")",
"GetSRsRequiredForRecovery",
"(",
"sessionID",
"SessionRef",
",",
"self",
"VMApplianceRef",
",",
"sessionTo",
"SessionRef",
")",
"(",
"_retval",
"[",
"]",
"SRRef",
",",
"_err",
"error",
")",
"{",
"_method",
":=",
... | // Get the list of SRs required by the VM appliance to recover. | [
"Get",
"the",
"list",
"of",
"SRs",
"required",
"by",
"the",
"VM",
"appliance",
"to",
"recover",
"."
] | edb53e3930c18c373c1a5e6c0eacd0b5c669fefb | https://github.com/terra-farm/go-xen-api-client/blob/edb53e3930c18c373c1a5e6c0eacd0b5c669fefb/vm_appliance_gen.go#L115-L135 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.