id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
132,600
gravitational/trace
errors.go
NotImplemented
func NotImplemented(message string, args ...interface{}) error { return WrapWithMessage(&NotImplementedError{ Message: fmt.Sprintf(message, args...), }, message, args...) }
go
func NotImplemented(message string, args ...interface{}) error { return WrapWithMessage(&NotImplementedError{ Message: fmt.Sprintf(message, args...), }, message, args...) }
[ "func", "NotImplemented", "(", "message", "string", ",", "args", "...", "interface", "{", "}", ")", "error", "{", "return", "WrapWithMessage", "(", "&", "NotImplementedError", "{", "Message", ":", "fmt", ".", "Sprintf", "(", "message", ",", "args", "...", ...
// NotImplemented returns a new instance of NotImplementedError
[ "NotImplemented", "returns", "a", "new", "instance", "of", "NotImplementedError" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/errors.go#L150-L154
132,601
gravitational/trace
errors.go
IsNotImplemented
func IsNotImplemented(e error) bool { type ni interface { IsNotImplementedError() bool } err, ok := Unwrap(e).(ni) return ok && err.IsNotImplementedError() }
go
func IsNotImplemented(e error) bool { type ni interface { IsNotImplementedError() bool } err, ok := Unwrap(e).(ni) return ok && err.IsNotImplementedError() }
[ "func", "IsNotImplemented", "(", "e", "error", ")", "bool", "{", "type", "ni", "interface", "{", "IsNotImplementedError", "(", ")", "bool", "\n", "}", "\n", "err", ",", "ok", ":=", "Unwrap", "(", "e", ")", ".", "(", "ni", ")", "\n", "return", "ok", ...
// IsNotImplemented returns whether this error is of NotImplementedError type
[ "IsNotImplemented", "returns", "whether", "this", "error", "is", "of", "NotImplementedError", "type" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/errors.go#L178-L184
132,602
gravitational/trace
errors.go
CompareFailed
func CompareFailed(message string, args ...interface{}) error { return WrapWithMessage(&CompareFailedError{Message: fmt.Sprintf(message, args...)}, message, args...) }
go
func CompareFailed(message string, args ...interface{}) error { return WrapWithMessage(&CompareFailedError{Message: fmt.Sprintf(message, args...)}, message, args...) }
[ "func", "CompareFailed", "(", "message", "string", ",", "args", "...", "interface", "{", "}", ")", "error", "{", "return", "WrapWithMessage", "(", "&", "CompareFailedError", "{", "Message", ":", "fmt", ".", "Sprintf", "(", "message", ",", "args", "...", ")...
// CompareFailed returns new instance of CompareFailedError
[ "CompareFailed", "returns", "new", "instance", "of", "CompareFailedError" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/errors.go#L187-L189
132,603
gravitational/trace
errors.go
IsCompareFailed
func IsCompareFailed(e error) bool { type cf interface { IsCompareFailedError() bool } _, ok := Unwrap(e).(cf) return ok }
go
func IsCompareFailed(e error) bool { type cf interface { IsCompareFailedError() bool } _, ok := Unwrap(e).(cf) return ok }
[ "func", "IsCompareFailed", "(", "e", "error", ")", "bool", "{", "type", "cf", "interface", "{", "IsCompareFailedError", "(", ")", "bool", "\n", "}", "\n", "_", ",", "ok", ":=", "Unwrap", "(", "e", ")", ".", "(", "cf", ")", "\n", "return", "ok", "\n...
// IsCompareFailed detects if this error is of CompareFailed type
[ "IsCompareFailed", "detects", "if", "this", "error", "is", "of", "CompareFailed", "type" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/errors.go#L216-L222
132,604
gravitational/trace
errors.go
AccessDenied
func AccessDenied(message string, args ...interface{}) error { return WrapWithMessage(&AccessDeniedError{ Message: fmt.Sprintf(message, args...), }, message, args...) }
go
func AccessDenied(message string, args ...interface{}) error { return WrapWithMessage(&AccessDeniedError{ Message: fmt.Sprintf(message, args...), }, message, args...) }
[ "func", "AccessDenied", "(", "message", "string", ",", "args", "...", "interface", "{", "}", ")", "error", "{", "return", "WrapWithMessage", "(", "&", "AccessDeniedError", "{", "Message", ":", "fmt", ".", "Sprintf", "(", "message", ",", "args", "...", ")",...
// AccessDenied returns new instance of AccessDeniedError
[ "AccessDenied", "returns", "new", "instance", "of", "AccessDeniedError" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/errors.go#L225-L229
132,605
gravitational/trace
errors.go
IsAccessDenied
func IsAccessDenied(e error) bool { type ad interface { IsAccessDeniedError() bool } _, ok := Unwrap(e).(ad) return ok }
go
func IsAccessDenied(e error) bool { type ad interface { IsAccessDeniedError() bool } _, ok := Unwrap(e).(ad) return ok }
[ "func", "IsAccessDenied", "(", "e", "error", ")", "bool", "{", "type", "ad", "interface", "{", "IsAccessDeniedError", "(", ")", "bool", "\n", "}", "\n", "_", ",", "ok", ":=", "Unwrap", "(", "e", ")", ".", "(", "ad", ")", "\n", "return", "ok", "\n",...
// IsAccessDenied detects if this error is of AccessDeniedError type
[ "IsAccessDenied", "detects", "if", "this", "error", "is", "of", "AccessDeniedError", "type" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/errors.go#L255-L261
132,606
gravitational/trace
errors.go
ConvertSystemError
func ConvertSystemError(err error) error { innerError := Unwrap(err) if os.IsExist(innerError) { return WrapWithMessage(&AlreadyExistsError{Message: innerError.Error()}, innerError.Error()) } if os.IsNotExist(innerError) { return WrapWithMessage(&NotFoundError{Message: innerError.Error()}, innerError.Error()) ...
go
func ConvertSystemError(err error) error { innerError := Unwrap(err) if os.IsExist(innerError) { return WrapWithMessage(&AlreadyExistsError{Message: innerError.Error()}, innerError.Error()) } if os.IsNotExist(innerError) { return WrapWithMessage(&NotFoundError{Message: innerError.Error()}, innerError.Error()) ...
[ "func", "ConvertSystemError", "(", "err", "error", ")", "error", "{", "innerError", ":=", "Unwrap", "(", "err", ")", "\n\n", "if", "os", ".", "IsExist", "(", "innerError", ")", "{", "return", "WrapWithMessage", "(", "&", "AlreadyExistsError", "{", "Message",...
// ConvertSystemError converts system error to appropriate trace error // if it is possible, otherwise, returns original error
[ "ConvertSystemError", "converts", "system", "error", "to", "appropriate", "trace", "error", "if", "it", "is", "possible", "otherwise", "returns", "original", "error" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/errors.go#L265-L296
132,607
gravitational/trace
errors.go
ConnectionProblem
func ConnectionProblem(err error, message string, args ...interface{}) error { return WrapWithMessage(&ConnectionProblemError{ Message: fmt.Sprintf(message, args...), Err: err, }, message, args...) }
go
func ConnectionProblem(err error, message string, args ...interface{}) error { return WrapWithMessage(&ConnectionProblemError{ Message: fmt.Sprintf(message, args...), Err: err, }, message, args...) }
[ "func", "ConnectionProblem", "(", "err", "error", ",", "message", "string", ",", "args", "...", "interface", "{", "}", ")", "error", "{", "return", "WrapWithMessage", "(", "&", "ConnectionProblemError", "{", "Message", ":", "fmt", ".", "Sprintf", "(", "messa...
// ConnectionProblem returns new instance of ConnectionProblemError
[ "ConnectionProblem", "returns", "new", "instance", "of", "ConnectionProblemError" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/errors.go#L299-L304
132,608
gravitational/trace
errors.go
IsConnectionProblem
func IsConnectionProblem(e error) bool { type ad interface { IsConnectionProblemError() bool } _, ok := Unwrap(e).(ad) return ok }
go
func IsConnectionProblem(e error) bool { type ad interface { IsConnectionProblemError() bool } _, ok := Unwrap(e).(ad) return ok }
[ "func", "IsConnectionProblem", "(", "e", "error", ")", "bool", "{", "type", "ad", "interface", "{", "IsConnectionProblemError", "(", ")", "bool", "\n", "}", "\n", "_", ",", "ok", ":=", "Unwrap", "(", "e", ")", ".", "(", "ad", ")", "\n", "return", "ok...
// IsConnectionProblem returns whether this error is of ConnectionProblemError
[ "IsConnectionProblem", "returns", "whether", "this", "error", "is", "of", "ConnectionProblemError" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/errors.go#L331-L337
132,609
gravitational/trace
errors.go
LimitExceeded
func LimitExceeded(message string, args ...interface{}) error { return WrapWithMessage(&LimitExceededError{ Message: fmt.Sprintf(message, args...), }, message, args...) }
go
func LimitExceeded(message string, args ...interface{}) error { return WrapWithMessage(&LimitExceededError{ Message: fmt.Sprintf(message, args...), }, message, args...) }
[ "func", "LimitExceeded", "(", "message", "string", ",", "args", "...", "interface", "{", "}", ")", "error", "{", "return", "WrapWithMessage", "(", "&", "LimitExceededError", "{", "Message", ":", "fmt", ".", "Sprintf", "(", "message", ",", "args", "...", ")...
// LimitExceeded returns whether new instance of LimitExceededError
[ "LimitExceeded", "returns", "whether", "new", "instance", "of", "LimitExceededError" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/errors.go#L340-L344
132,610
gravitational/trace
errors.go
IsLimitExceeded
func IsLimitExceeded(e error) bool { type ad interface { IsLimitExceededError() bool } _, ok := Unwrap(e).(ad) return ok }
go
func IsLimitExceeded(e error) bool { type ad interface { IsLimitExceededError() bool } _, ok := Unwrap(e).(ad) return ok }
[ "func", "IsLimitExceeded", "(", "e", "error", ")", "bool", "{", "type", "ad", "interface", "{", "IsLimitExceededError", "(", ")", "bool", "\n", "}", "\n", "_", ",", "ok", ":=", "Unwrap", "(", "e", ")", ".", "(", "ad", ")", "\n", "return", "ok", "\n...
// IsLimitExceeded detects if this error is of LimitExceededError
[ "IsLimitExceeded", "detects", "if", "this", "error", "is", "of", "LimitExceededError" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/errors.go#L367-L373
132,611
gravitational/trace
errors.go
IsTrustError
func IsTrustError(e error) bool { type te interface { IsTrustError() bool } _, ok := Unwrap(e).(te) return ok }
go
func IsTrustError(e error) bool { type te interface { IsTrustError() bool } _, ok := Unwrap(e).(te) return ok }
[ "func", "IsTrustError", "(", "e", "error", ")", "bool", "{", "type", "te", "interface", "{", "IsTrustError", "(", ")", "bool", "\n", "}", "\n", "_", ",", "ok", ":=", "Unwrap", "(", "e", ")", ".", "(", "te", ")", "\n", "return", "ok", "\n", "}" ]
// IsTrustError returns if this is a trust error
[ "IsTrustError", "returns", "if", "this", "is", "a", "trust", "error" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/errors.go#L398-L404
132,612
gravitational/trace
errors.go
OAuth2
func OAuth2(code, message string, query url.Values) Error { return WrapWithMessage(&OAuth2Error{ Code: code, Message: message, Query: query, }, message) }
go
func OAuth2(code, message string, query url.Values) Error { return WrapWithMessage(&OAuth2Error{ Code: code, Message: message, Query: query, }, message) }
[ "func", "OAuth2", "(", "code", ",", "message", "string", ",", "query", "url", ".", "Values", ")", "Error", "{", "return", "WrapWithMessage", "(", "&", "OAuth2Error", "{", "Code", ":", "code", ",", "Message", ":", "message", ",", "Query", ":", "query", ...
// OAuth2 returns new instance of OAuth2Error
[ "OAuth2", "returns", "new", "instance", "of", "OAuth2Error" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/errors.go#L407-L413
132,613
gravitational/trace
errors.go
Error
func (o *OAuth2Error) Error() string { return fmt.Sprintf("OAuth2 error code=%v, message=%v", o.Code, o.Message) }
go
func (o *OAuth2Error) Error() string { return fmt.Sprintf("OAuth2 error code=%v, message=%v", o.Code, o.Message) }
[ "func", "(", "o", "*", "OAuth2Error", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "o", ".", "Code", ",", "o", ".", "Message", ")", "\n", "}" ]
//Error returns log friendly description of an error
[ "Error", "returns", "log", "friendly", "description", "of", "an", "error" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/errors.go#L423-L425
132,614
gravitational/trace
errors.go
IsOAuth2
func IsOAuth2(e error) bool { type oe interface { IsOAuth2Error() bool } _, ok := Unwrap(e).(oe) return ok }
go
func IsOAuth2(e error) bool { type oe interface { IsOAuth2Error() bool } _, ok := Unwrap(e).(oe) return ok }
[ "func", "IsOAuth2", "(", "e", "error", ")", "bool", "{", "type", "oe", "interface", "{", "IsOAuth2Error", "(", ")", "bool", "\n", "}", "\n", "_", ",", "ok", ":=", "Unwrap", "(", "e", ")", ".", "(", "oe", ")", "\n", "return", "ok", "\n", "}" ]
// IsOAuth2 returns if this is a OAuth2-related error
[ "IsOAuth2", "returns", "if", "this", "is", "a", "OAuth2", "-", "related", "error" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/errors.go#L433-L439
132,615
gravitational/trace
errors.go
Retry
func Retry(err error, message string, args ...interface{}) error { return WrapWithMessage(&RetryError{ Message: fmt.Sprintf(message, args...), Err: err, }, message, args...) }
go
func Retry(err error, message string, args ...interface{}) error { return WrapWithMessage(&RetryError{ Message: fmt.Sprintf(message, args...), Err: err, }, message, args...) }
[ "func", "Retry", "(", "err", "error", ",", "message", "string", ",", "args", "...", "interface", "{", "}", ")", "error", "{", "return", "WrapWithMessage", "(", "&", "RetryError", "{", "Message", ":", "fmt", ".", "Sprintf", "(", "message", ",", "args", ...
// Retry return new instance of RetryError which indicates a transient error type
[ "Retry", "return", "new", "instance", "of", "RetryError", "which", "indicates", "a", "transient", "error", "type" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/errors.go#L447-L452
132,616
gravitational/trace
errors.go
IsRetryError
func IsRetryError(e error) bool { type ad interface { IsRetryError() bool } _, ok := Unwrap(e).(ad) return ok }
go
func IsRetryError(e error) bool { type ad interface { IsRetryError() bool } _, ok := Unwrap(e).(ad) return ok }
[ "func", "IsRetryError", "(", "e", "error", ")", "bool", "{", "type", "ad", "interface", "{", "IsRetryError", "(", ")", "bool", "\n", "}", "\n", "_", ",", "ok", ":=", "Unwrap", "(", "e", ")", ".", "(", "ad", ")", "\n", "return", "ok", "\n", "}" ]
// IsRetryError returns whether this error is of ConnectionProblemError
[ "IsRetryError", "returns", "whether", "this", "error", "is", "of", "ConnectionProblemError" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/errors.go#L479-L485
132,617
gravitational/trace
log.go
IsTerminal
func IsTerminal(w io.Writer) bool { switch v := w.(type) { case *os.File: return terminal.IsTerminal(int(v.Fd())) default: return false } }
go
func IsTerminal(w io.Writer) bool { switch v := w.(type) { case *os.File: return terminal.IsTerminal(int(v.Fd())) default: return false } }
[ "func", "IsTerminal", "(", "w", "io", ".", "Writer", ")", "bool", "{", "switch", "v", ":=", "w", ".", "(", "type", ")", "{", "case", "*", "os", ".", "File", ":", "return", "terminal", ".", "IsTerminal", "(", "int", "(", "v", ".", "Fd", "(", ")"...
// IsTerminal checks whether writer is a terminal
[ "IsTerminal", "checks", "whether", "writer", "is", "a", "terminal" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/log.go#L57-L64
132,618
gravitational/trace
log.go
Format
func (tf *TextFormatter) Format(e *log.Entry) (data []byte, err error) { defer func() { if r := recover(); r != nil { data = append([]byte("panic in log formatter\n"), rundebug.Stack()...) return } }() var file string if cursor := findFrame(); cursor != nil { t := newTraceFromFrames(*cursor, nil) fil...
go
func (tf *TextFormatter) Format(e *log.Entry) (data []byte, err error) { defer func() { if r := recover(); r != nil { data = append([]byte("panic in log formatter\n"), rundebug.Stack()...) return } }() var file string if cursor := findFrame(); cursor != nil { t := newTraceFromFrames(*cursor, nil) fil...
[ "func", "(", "tf", "*", "TextFormatter", ")", "Format", "(", "e", "*", "log", ".", "Entry", ")", "(", "data", "[", "]", "byte", ",", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "if", "r", ":=", "recover", "(", ")", ";", "r", "!=...
// Format implements logrus.Formatter interface and adds file and line
[ "Format", "implements", "logrus", ".", "Formatter", "interface", "and", "adds", "file", "and", "line" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/log.go#L80-L154
132,619
gravitational/trace
log.go
Format
func (j *JSONFormatter) Format(e *log.Entry) ([]byte, error) { if cursor := findFrame(); cursor != nil { t := newTraceFromFrames(*cursor, nil) new := e.WithFields(log.Fields{ FileField: t.Loc(), FunctionField: t.FuncName(), }) new.Time = e.Time new.Level = e.Level new.Message = e.Message e = ne...
go
func (j *JSONFormatter) Format(e *log.Entry) ([]byte, error) { if cursor := findFrame(); cursor != nil { t := newTraceFromFrames(*cursor, nil) new := e.WithFields(log.Fields{ FileField: t.Loc(), FunctionField: t.FuncName(), }) new.Time = e.Time new.Level = e.Level new.Message = e.Message e = ne...
[ "func", "(", "j", "*", "JSONFormatter", ")", "Format", "(", "e", "*", "log", ".", "Entry", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "cursor", ":=", "findFrame", "(", ")", ";", "cursor", "!=", "nil", "{", "t", ":=", "newTraceFromF...
// Format implements logrus.Formatter interface
[ "Format", "implements", "logrus", ".", "Formatter", "interface" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/log.go#L163-L176
132,620
gravitational/trace
log.go
findFrame
func findFrame() *frameCursor { var buf [32]uintptr // Skip enough frames to start at user code. // This number is a mere hint to the following loop // to start as close to user code as possible and getting it right is not mandatory. // The skip count might need to get updated if the call to findFrame is // moved...
go
func findFrame() *frameCursor { var buf [32]uintptr // Skip enough frames to start at user code. // This number is a mere hint to the following loop // to start as close to user code as possible and getting it right is not mandatory. // The skip count might need to get updated if the call to findFrame is // moved...
[ "func", "findFrame", "(", ")", "*", "frameCursor", "{", "var", "buf", "[", "32", "]", "uintptr", "\n", "// Skip enough frames to start at user code.", "// This number is a mere hint to the following loop", "// to start as close to user code as possible and getting it right is not man...
// findFrames positions the stack pointer to the first // function that does not match the frameIngorePattern // and returns the rest of the stack frames
[ "findFrames", "positions", "the", "stack", "pointer", "to", "the", "first", "function", "that", "does", "not", "match", "the", "frameIngorePattern", "and", "returns", "the", "rest", "of", "the", "stack", "frames" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/log.go#L183-L204
132,621
gravitational/trace
trace.go
Wrap
func Wrap(err error, args ...interface{}) Error { if len(args) > 0 { format := args[0] args = args[1:] return WrapWithMessage(err, format, args...) } return wrapWithDepth(err, 2) }
go
func Wrap(err error, args ...interface{}) Error { if len(args) > 0 { format := args[0] args = args[1:] return WrapWithMessage(err, format, args...) } return wrapWithDepth(err, 2) }
[ "func", "Wrap", "(", "err", "error", ",", "args", "...", "interface", "{", "}", ")", "Error", "{", "if", "len", "(", "args", ")", ">", "0", "{", "format", ":=", "args", "[", "0", "]", "\n", "args", "=", "args", "[", "1", ":", "]", "\n", "retu...
// Wrap takes the original error and wraps it into the Trace struct // memorizing the context of the error.
[ "Wrap", "takes", "the", "original", "error", "and", "wraps", "it", "into", "the", "Trace", "struct", "memorizing", "the", "context", "of", "the", "error", "." ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/trace.go#L50-L57
132,622
gravitational/trace
trace.go
Unwrap
func Unwrap(err error) error { if terr, ok := err.(Error); ok { return terr.OrigError() } return err }
go
func Unwrap(err error) error { if terr, ok := err.(Error); ok { return terr.OrigError() } return err }
[ "func", "Unwrap", "(", "err", "error", ")", "error", "{", "if", "terr", ",", "ok", ":=", "err", ".", "(", "Error", ")", ";", "ok", "{", "return", "terr", ".", "OrigError", "(", ")", "\n", "}", "\n", "return", "err", "\n", "}" ]
// Unwrap unwraps error to it's original error
[ "Unwrap", "unwraps", "error", "to", "it", "s", "original", "error" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/trace.go#L60-L65
132,623
gravitational/trace
trace.go
UserMessage
func UserMessage(err error) string { if err == nil { return "" } if wrap, ok := err.(Error); ok { return wrap.UserMessage() } return err.Error() }
go
func UserMessage(err error) string { if err == nil { return "" } if wrap, ok := err.(Error); ok { return wrap.UserMessage() } return err.Error() }
[ "func", "UserMessage", "(", "err", "error", ")", "string", "{", "if", "err", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "wrap", ",", "ok", ":=", "err", ".", "(", "Error", ")", ";", "ok", "{", "return", "wrap", ".", "UserMessag...
// UserMessage returns user-friendly part of the error
[ "UserMessage", "returns", "user", "-", "friendly", "part", "of", "the", "error" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/trace.go#L68-L76
132,624
gravitational/trace
trace.go
DebugReport
func DebugReport(err error) string { if err == nil { return "" } if wrap, ok := err.(Error); ok { return wrap.DebugReport() } return err.Error() }
go
func DebugReport(err error) string { if err == nil { return "" } if wrap, ok := err.(Error); ok { return wrap.DebugReport() } return err.Error() }
[ "func", "DebugReport", "(", "err", "error", ")", "string", "{", "if", "err", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "wrap", ",", "ok", ":=", "err", ".", "(", "Error", ")", ";", "ok", "{", "return", "wrap", ".", "DebugRepor...
// DebugReport returns debug report with all known information // about the error including stack trace if it was captured
[ "DebugReport", "returns", "debug", "report", "with", "all", "known", "information", "about", "the", "error", "including", "stack", "trace", "if", "it", "was", "captured" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/trace.go#L80-L88
132,625
gravitational/trace
trace.go
WrapWithMessage
func WrapWithMessage(err error, message interface{}, args ...interface{}) Error { trace := wrapWithDepth(err, 3) if trace != nil { trace.AddUserMessage(message, args...) } return trace }
go
func WrapWithMessage(err error, message interface{}, args ...interface{}) Error { trace := wrapWithDepth(err, 3) if trace != nil { trace.AddUserMessage(message, args...) } return trace }
[ "func", "WrapWithMessage", "(", "err", "error", ",", "message", "interface", "{", "}", ",", "args", "...", "interface", "{", "}", ")", "Error", "{", "trace", ":=", "wrapWithDepth", "(", "err", ",", "3", ")", "\n", "if", "trace", "!=", "nil", "{", "tr...
// WrapWithMessage wraps the original error into Error and adds user message if any
[ "WrapWithMessage", "wraps", "the", "original", "error", "into", "Error", "and", "adds", "user", "message", "if", "any" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/trace.go#L91-L97
132,626
gravitational/trace
trace.go
Errorf
func Errorf(format string, args ...interface{}) (err error) { err = fmt.Errorf(format, args...) trace := wrapWithDepth(err, 2) trace.AddUserMessage(format, args...) return trace }
go
func Errorf(format string, args ...interface{}) (err error) { err = fmt.Errorf(format, args...) trace := wrapWithDepth(err, 2) trace.AddUserMessage(format, args...) return trace }
[ "func", "Errorf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "err", "error", ")", "{", "err", "=", "fmt", ".", "Errorf", "(", "format", ",", "args", "...", ")", "\n", "trace", ":=", "wrapWithDepth", "(", "err", ",...
// Errorf is similar to fmt.Errorf except that it captures // more information about the origin of error, such as // callee, line number and function that simplifies debugging
[ "Errorf", "is", "similar", "to", "fmt", ".", "Errorf", "except", "that", "it", "captures", "more", "information", "about", "the", "origin", "of", "error", "such", "as", "callee", "line", "number", "and", "function", "that", "simplifies", "debugging" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/trace.go#L116-L121
132,627
gravitational/trace
trace.go
Fatalf
func Fatalf(format string, args ...interface{}) error { if IsDebug() { panic(fmt.Sprintf(format, args...)) } else { return Errorf(format, args...) } }
go
func Fatalf(format string, args ...interface{}) error { if IsDebug() { panic(fmt.Sprintf(format, args...)) } else { return Errorf(format, args...) } }
[ "func", "Fatalf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "error", "{", "if", "IsDebug", "(", ")", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "format", ",", "args", "...", ")", ")", "\n", "}", "else", "{", "re...
// Fatalf - If debug is false Fatalf calls Errorf. If debug is // true Fatalf calls panic
[ "Fatalf", "-", "If", "debug", "is", "false", "Fatalf", "calls", "Errorf", ".", "If", "debug", "is", "true", "Fatalf", "calls", "panic" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/trace.go#L125-L131
132,628
gravitational/trace
trace.go
FuncName
func (s Traces) FuncName() string { if len(s) == 0 { return "" } fn := filepath.ToSlash(s[0].Func) idx := strings.LastIndex(fn, "/") if idx == -1 || idx == len(fn)-1 { return fn } return fn[idx+1:] }
go
func (s Traces) FuncName() string { if len(s) == 0 { return "" } fn := filepath.ToSlash(s[0].Func) idx := strings.LastIndex(fn, "/") if idx == -1 || idx == len(fn)-1 { return fn } return fn[idx+1:] }
[ "func", "(", "s", "Traces", ")", "FuncName", "(", ")", "string", "{", "if", "len", "(", "s", ")", "==", "0", "{", "return", "\"", "\"", "\n", "}", "\n", "fn", ":=", "filepath", ".", "ToSlash", "(", "s", "[", "0", "]", ".", "Func", ")", "\n", ...
// Func returns just function name
[ "Func", "returns", "just", "function", "name" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/trace.go#L198-L208
132,629
gravitational/trace
trace.go
String
func (s Traces) String() string { if len(s) == 0 { return "" } out := make([]string, len(s)) for i, t := range s { out[i] = fmt.Sprintf("\t%v:%v %v", t.Path, t.Line, t.Func) } return strings.Join(out, "\n") }
go
func (s Traces) String() string { if len(s) == 0 { return "" } out := make([]string, len(s)) for i, t := range s { out[i] = fmt.Sprintf("\t%v:%v %v", t.Path, t.Line, t.Func) } return strings.Join(out, "\n") }
[ "func", "(", "s", "Traces", ")", "String", "(", ")", "string", "{", "if", "len", "(", "s", ")", "==", "0", "{", "return", "\"", "\"", "\n", "}", "\n", "out", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "s", ")", ")", "\n", "for"...
// String returns debug-friendly representaton of trace stack
[ "String", "returns", "debug", "-", "friendly", "representaton", "of", "trace", "stack" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/trace.go#L219-L228
132,630
gravitational/trace
trace.go
String
func (t *Trace) String() string { dir, file := filepath.Split(t.Path) dirs := strings.Split(filepath.ToSlash(filepath.Clean(dir)), "/") if len(dirs) != 0 { file = filepath.Join(dirs[len(dirs)-1], file) } return fmt.Sprintf("%v:%v", file, t.Line) }
go
func (t *Trace) String() string { dir, file := filepath.Split(t.Path) dirs := strings.Split(filepath.ToSlash(filepath.Clean(dir)), "/") if len(dirs) != 0 { file = filepath.Join(dirs[len(dirs)-1], file) } return fmt.Sprintf("%v:%v", file, t.Line) }
[ "func", "(", "t", "*", "Trace", ")", "String", "(", ")", "string", "{", "dir", ",", "file", ":=", "filepath", ".", "Split", "(", "t", ".", "Path", ")", "\n", "dirs", ":=", "strings", ".", "Split", "(", "filepath", ".", "ToSlash", "(", "filepath", ...
// String returns debug-friendly representation of this trace
[ "String", "returns", "debug", "-", "friendly", "representation", "of", "this", "trace" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/trace.go#L241-L248
132,631
gravitational/trace
trace.go
AddUserMessage
func (e *TraceErr) AddUserMessage(formatArg interface{}, rest ...interface{}) { newMessage := fmt.Sprintf(fmt.Sprintf("%v", formatArg), rest...) if len(e.Message) == 0 { e.Message = newMessage } else { e.Message = strings.Join([]string{e.Message, newMessage}, ", ") } }
go
func (e *TraceErr) AddUserMessage(formatArg interface{}, rest ...interface{}) { newMessage := fmt.Sprintf(fmt.Sprintf("%v", formatArg), rest...) if len(e.Message) == 0 { e.Message = newMessage } else { e.Message = strings.Join([]string{e.Message, newMessage}, ", ") } }
[ "func", "(", "e", "*", "TraceErr", ")", "AddUserMessage", "(", "formatArg", "interface", "{", "}", ",", "rest", "...", "interface", "{", "}", ")", "{", "newMessage", ":=", "fmt", ".", "Sprintf", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "form...
// AddUserMessage adds user-friendly message describing the error nature
[ "AddUserMessage", "adds", "user", "-", "friendly", "message", "describing", "the", "error", "nature" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/trace.go#L265-L272
132,632
gravitational/trace
trace.go
UserMessage
func (e *TraceErr) UserMessage() string { if e.Message != "" { return e.Message } return UserMessage(e.Err) }
go
func (e *TraceErr) UserMessage() string { if e.Message != "" { return e.Message } return UserMessage(e.Err) }
[ "func", "(", "e", "*", "TraceErr", ")", "UserMessage", "(", ")", "string", "{", "if", "e", ".", "Message", "!=", "\"", "\"", "{", "return", "e", ".", "Message", "\n", "}", "\n", "return", "UserMessage", "(", "e", ".", "Err", ")", "\n", "}" ]
// UserMessage returns user-friendly error message
[ "UserMessage", "returns", "user", "-", "friendly", "error", "message" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/trace.go#L275-L280
132,633
gravitational/trace
trace.go
DebugReport
func (e *TraceErr) DebugReport() string { return fmt.Sprintf("\nERROR REPORT:\nOriginal Error: %T %v\nStack Trace:\n%v\nUser Message: %v\n", e.Err, e.Err.Error(), e.Traces.String(), e.Message) }
go
func (e *TraceErr) DebugReport() string { return fmt.Sprintf("\nERROR REPORT:\nOriginal Error: %T %v\nStack Trace:\n%v\nUser Message: %v\n", e.Err, e.Err.Error(), e.Traces.String(), e.Message) }
[ "func", "(", "e", "*", "TraceErr", ")", "DebugReport", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\\n", "\\n", "\\n", "\\n", "\\n", "\"", ",", "e", ".", "Err", ",", "e", ".", "Err", ".", "Error", "(", ")", ",",...
// DebugReport returns develeoper-friendly error report
[ "DebugReport", "returns", "develeoper", "-", "friendly", "error", "report" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/trace.go#L283-L285
132,634
gravitational/trace
trace.go
OrigError
func (e *TraceErr) OrigError() error { err := e.Err // this is not an endless loop because I'm being // paranoid, this is a safe protection against endless // loops for i := 0; i < maxHops; i++ { newerr, ok := err.(Error) if !ok { break } if newerr.OrigError() != err { err = newerr.OrigError() } }...
go
func (e *TraceErr) OrigError() error { err := e.Err // this is not an endless loop because I'm being // paranoid, this is a safe protection against endless // loops for i := 0; i < maxHops; i++ { newerr, ok := err.(Error) if !ok { break } if newerr.OrigError() != err { err = newerr.OrigError() } }...
[ "func", "(", "e", "*", "TraceErr", ")", "OrigError", "(", ")", "error", "{", "err", ":=", "e", ".", "Err", "\n", "// this is not an endless loop because I'm being", "// paranoid, this is a safe protection against endless", "// loops", "for", "i", ":=", "0", ";", "i"...
// OrigError returns original wrapped error
[ "OrigError", "returns", "original", "wrapped", "error" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/trace.go#L293-L308
132,635
gravitational/trace
trace.go
NewAggregate
func NewAggregate(errs ...error) error { // filter out possible nil values var nonNils []error for _, err := range errs { if err != nil { nonNils = append(nonNils, err) } } if len(nonNils) == 0 { return nil } return wrapWithDepth(aggregate(nonNils), 2) }
go
func NewAggregate(errs ...error) error { // filter out possible nil values var nonNils []error for _, err := range errs { if err != nil { nonNils = append(nonNils, err) } } if len(nonNils) == 0 { return nil } return wrapWithDepth(aggregate(nonNils), 2) }
[ "func", "NewAggregate", "(", "errs", "...", "error", ")", "error", "{", "// filter out possible nil values", "var", "nonNils", "[", "]", "error", "\n", "for", "_", ",", "err", ":=", "range", "errs", "{", "if", "err", "!=", "nil", "{", "nonNils", "=", "ap...
// NewAggregate creates a new aggregate instance from the specified // list of errors
[ "NewAggregate", "creates", "a", "new", "aggregate", "instance", "from", "the", "specified", "list", "of", "errors" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/trace.go#L342-L354
132,636
gravitational/trace
trace.go
IsAggregate
func IsAggregate(err error) bool { _, ok := Unwrap(err).(Aggregate) return ok }
go
func IsAggregate(err error) bool { _, ok := Unwrap(err).(Aggregate) return ok }
[ "func", "IsAggregate", "(", "err", "error", ")", "bool", "{", "_", ",", "ok", ":=", "Unwrap", "(", "err", ")", ".", "(", "Aggregate", ")", "\n", "return", "ok", "\n", "}" ]
// IsAggregate returns whether this error of Aggregate error type
[ "IsAggregate", "returns", "whether", "this", "error", "of", "Aggregate", "error", "type" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/trace.go#L408-L411
132,637
gravitational/trace
udphook.go
NewUDPHook
func NewUDPHook(opts ...UDPOptionSetter) (*UDPHook, error) { f := &UDPHook{} for _, o := range opts { o(f) } if f.Clock == nil { f.Clock = clockwork.NewRealClock() } if f.clientNet == "" { f.clientNet = UDPDefaultNet } if f.clientAddr == "" { f.clientAddr = UDPDefaultAddr } addr, err := net.ResolveUDP...
go
func NewUDPHook(opts ...UDPOptionSetter) (*UDPHook, error) { f := &UDPHook{} for _, o := range opts { o(f) } if f.Clock == nil { f.Clock = clockwork.NewRealClock() } if f.clientNet == "" { f.clientNet = UDPDefaultNet } if f.clientAddr == "" { f.clientAddr = UDPDefaultAddr } addr, err := net.ResolveUDP...
[ "func", "NewUDPHook", "(", "opts", "...", "UDPOptionSetter", ")", "(", "*", "UDPHook", ",", "error", ")", "{", "f", ":=", "&", "UDPHook", "{", "}", "\n", "for", "_", ",", "o", ":=", "range", "opts", "{", "o", "(", "f", ")", "\n", "}", "\n", "if...
// NewUDPHook returns logrus-compatible hook that sends data to UDP socket
[ "NewUDPHook", "returns", "logrus", "-", "compatible", "hook", "that", "sends", "data", "to", "UDP", "socket" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/udphook.go#L23-L48
132,638
gravitational/trace
udphook.go
Fire
func (elk *UDPHook) Fire(e *log.Entry) error { // Make a copy to safely modify entry := e.WithFields(nil) if cursor := findFrame(); cursor != nil { t := newTraceFromFrames(*cursor, nil) entry.Data[FileField] = t.String() entry.Data[FunctionField] = t.Func() } data, err := json.Marshal(Frame{ Time: elk.C...
go
func (elk *UDPHook) Fire(e *log.Entry) error { // Make a copy to safely modify entry := e.WithFields(nil) if cursor := findFrame(); cursor != nil { t := newTraceFromFrames(*cursor, nil) entry.Data[FileField] = t.String() entry.Data[FunctionField] = t.Func() } data, err := json.Marshal(Frame{ Time: elk.C...
[ "func", "(", "elk", "*", "UDPHook", ")", "Fire", "(", "e", "*", "log", ".", "Entry", ")", "error", "{", "// Make a copy to safely modify", "entry", ":=", "e", ".", "WithFields", "(", "nil", ")", "\n", "if", "cursor", ":=", "findFrame", "(", ")", ";", ...
// Fire fires the event to the ELK beat
[ "Fire", "fires", "the", "event", "to", "the", "ELK", "beat" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/udphook.go#L67-L100
132,639
gravitational/trace
udphook.go
Levels
func (elk *UDPHook) Levels() []log.Level { return []log.Level{ log.PanicLevel, log.FatalLevel, log.ErrorLevel, log.WarnLevel, log.InfoLevel, log.DebugLevel, } }
go
func (elk *UDPHook) Levels() []log.Level { return []log.Level{ log.PanicLevel, log.FatalLevel, log.ErrorLevel, log.WarnLevel, log.InfoLevel, log.DebugLevel, } }
[ "func", "(", "elk", "*", "UDPHook", ")", "Levels", "(", ")", "[", "]", "log", ".", "Level", "{", "return", "[", "]", "log", ".", "Level", "{", "log", ".", "PanicLevel", ",", "log", ".", "FatalLevel", ",", "log", ".", "ErrorLevel", ",", "log", "."...
// Levels returns logging levels supported by logrus
[ "Levels", "returns", "logging", "levels", "supported", "by", "logrus" ]
f30095ced5ff011085d26f160468dcc477607730
https://github.com/gravitational/trace/blob/f30095ced5ff011085d26f160468dcc477607730/udphook.go#L103-L112
132,640
wvanbergen/kazoo-go
topic_admin.go
CreateTopic
func (kz *Kazoo) CreateTopic(name string, partitionCount int, replicationFactor int, topicConfig map[string]string) error { topic := kz.Topic(name) // Official kafka sdk checks if topic exists, then always writes the config unconditionally // but only writes the partition map if ones does not exist. exists, err :=...
go
func (kz *Kazoo) CreateTopic(name string, partitionCount int, replicationFactor int, topicConfig map[string]string) error { topic := kz.Topic(name) // Official kafka sdk checks if topic exists, then always writes the config unconditionally // but only writes the partition map if ones does not exist. exists, err :=...
[ "func", "(", "kz", "*", "Kazoo", ")", "CreateTopic", "(", "name", "string", ",", "partitionCount", "int", ",", "replicationFactor", "int", ",", "topicConfig", "map", "[", "string", "]", "string", ")", "error", "{", "topic", ":=", "kz", ".", "Topic", "(",...
// CreateTopic creates a new kafka topic with the specified parameters and properties
[ "CreateTopic", "creates", "a", "new", "kafka", "topic", "with", "the", "specified", "parameters", "and", "properties" ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/topic_admin.go#L18-L59
132,641
wvanbergen/kazoo-go
topic_admin.go
DeleteTopic
func (kz *Kazoo) DeleteTopic(name string) error { node := fmt.Sprintf("%s/admin/delete_topics/%s", kz.conf.Chroot, name) exists, err := kz.exists(node) if err != nil { return err } if exists { return ErrTopicMarkedForDelete } if err := kz.create(node, nil, false); err != nil { return err } return nil }
go
func (kz *Kazoo) DeleteTopic(name string) error { node := fmt.Sprintf("%s/admin/delete_topics/%s", kz.conf.Chroot, name) exists, err := kz.exists(node) if err != nil { return err } if exists { return ErrTopicMarkedForDelete } if err := kz.create(node, nil, false); err != nil { return err } return nil }
[ "func", "(", "kz", "*", "Kazoo", ")", "DeleteTopic", "(", "name", "string", ")", "error", "{", "node", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "kz", ".", "conf", ".", "Chroot", ",", "name", ")", "\n\n", "exists", ",", "err", ":=", "kz"...
// DeleteTopic marks a kafka topic for deletion. Deleting a topic is asynchronous and // DeleteTopic will return before Kafka actually does the deletion.
[ "DeleteTopic", "marks", "a", "kafka", "topic", "for", "deletion", ".", "Deleting", "a", "topic", "is", "asynchronous", "and", "DeleteTopic", "will", "return", "before", "Kafka", "actually", "does", "the", "deletion", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/topic_admin.go#L63-L78
132,642
wvanbergen/kazoo-go
topic_admin.go
DeleteTopicSync
func (kz *Kazoo) DeleteTopicSync(name string, timeout time.Duration) error { err := kz.DeleteTopic(name) if err != nil { return err } topic := kz.Topic(name) if exists, err := topic.Exists(); err != nil { return err } else if !exists { return nil } changes, err := topic.Watch() if err != nil { ret...
go
func (kz *Kazoo) DeleteTopicSync(name string, timeout time.Duration) error { err := kz.DeleteTopic(name) if err != nil { return err } topic := kz.Topic(name) if exists, err := topic.Exists(); err != nil { return err } else if !exists { return nil } changes, err := topic.Watch() if err != nil { ret...
[ "func", "(", "kz", "*", "Kazoo", ")", "DeleteTopicSync", "(", "name", "string", ",", "timeout", "time", ".", "Duration", ")", "error", "{", "err", ":=", "kz", ".", "DeleteTopic", "(", "name", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err...
// DeleteTopicSync marks a kafka topic for deletion and waits until it is deleted // before returning.
[ "DeleteTopicSync", "marks", "a", "kafka", "topic", "for", "deletion", "and", "waits", "until", "it", "is", "deleted", "before", "returning", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/topic_admin.go#L82-L130
132,643
wvanbergen/kazoo-go
kazoo.go
NewKazoo
func NewKazoo(servers []string, conf *Config) (*Kazoo, error) { if conf == nil { conf = NewConfig() } conn, _, err := zk.Connect( servers, conf.Timeout, func(c *zk.Conn) { c.SetLogger(conf.Logger) }, ) if err != nil { return nil, err } return &Kazoo{conn, conf}, nil }
go
func NewKazoo(servers []string, conf *Config) (*Kazoo, error) { if conf == nil { conf = NewConfig() } conn, _, err := zk.Connect( servers, conf.Timeout, func(c *zk.Conn) { c.SetLogger(conf.Logger) }, ) if err != nil { return nil, err } return &Kazoo{conn, conf}, nil }
[ "func", "NewKazoo", "(", "servers", "[", "]", "string", ",", "conf", "*", "Config", ")", "(", "*", "Kazoo", ",", "error", ")", "{", "if", "conf", "==", "nil", "{", "conf", "=", "NewConfig", "(", ")", "\n", "}", "\n\n", "conn", ",", "_", ",", "e...
// NewKazoo creates a new connection instance
[ "NewKazoo", "creates", "a", "new", "connection", "instance" ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/kazoo.go#L72-L87
132,644
wvanbergen/kazoo-go
kazoo.go
NewKazooFromConnectionString
func NewKazooFromConnectionString(connectionString string, conf *Config) (*Kazoo, error) { if conf == nil { conf = NewConfig() } nodes, chroot := ParseConnectionString(connectionString) conf.Chroot = chroot return NewKazoo(nodes, conf) }
go
func NewKazooFromConnectionString(connectionString string, conf *Config) (*Kazoo, error) { if conf == nil { conf = NewConfig() } nodes, chroot := ParseConnectionString(connectionString) conf.Chroot = chroot return NewKazoo(nodes, conf) }
[ "func", "NewKazooFromConnectionString", "(", "connectionString", "string", ",", "conf", "*", "Config", ")", "(", "*", "Kazoo", ",", "error", ")", "{", "if", "conf", "==", "nil", "{", "conf", "=", "NewConfig", "(", ")", "\n", "}", "\n\n", "nodes", ",", ...
// NewKazooFromConnectionString creates a new connection instance // based on a zookeeer connection string that can include a chroot.
[ "NewKazooFromConnectionString", "creates", "a", "new", "connection", "instance", "based", "on", "a", "zookeeer", "connection", "string", "that", "can", "include", "a", "chroot", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/kazoo.go#L91-L99
132,645
wvanbergen/kazoo-go
kazoo.go
Brokers
func (kz *Kazoo) Brokers() (map[int32]string, error) { root := fmt.Sprintf("%s/brokers/ids", kz.conf.Chroot) children, _, err := kz.conn.Children(root) if err != nil { return nil, err } type brokerEntry struct { Host string `json:"host"` Port int `json:"port"` } result := make(map[int32]string) for _...
go
func (kz *Kazoo) Brokers() (map[int32]string, error) { root := fmt.Sprintf("%s/brokers/ids", kz.conf.Chroot) children, _, err := kz.conn.Children(root) if err != nil { return nil, err } type brokerEntry struct { Host string `json:"host"` Port int `json:"port"` } result := make(map[int32]string) for _...
[ "func", "(", "kz", "*", "Kazoo", ")", "Brokers", "(", ")", "(", "map", "[", "int32", "]", "string", ",", "error", ")", "{", "root", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "kz", ".", "conf", ".", "Chroot", ")", "\n", "children", ",",...
// Brokers returns a map of all the brokers that make part of the // Kafka cluster that is registered in Zookeeper.
[ "Brokers", "returns", "a", "map", "of", "all", "the", "brokers", "that", "make", "part", "of", "the", "Kafka", "cluster", "that", "is", "registered", "in", "Zookeeper", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/kazoo.go#L103-L136
132,646
wvanbergen/kazoo-go
kazoo.go
brokerIDList
func (kz *Kazoo) brokerIDList() ([]int32, error) { brokers, err := kz.Brokers() if err != nil { return nil, err } result := make([]int32, 0, len(brokers)) for id := range brokers { result = append(result, id) } // return sorted list to match the offical kafka sdks sort.Sort(int32Slice(result)) return re...
go
func (kz *Kazoo) brokerIDList() ([]int32, error) { brokers, err := kz.Brokers() if err != nil { return nil, err } result := make([]int32, 0, len(brokers)) for id := range brokers { result = append(result, id) } // return sorted list to match the offical kafka sdks sort.Sort(int32Slice(result)) return re...
[ "func", "(", "kz", "*", "Kazoo", ")", "brokerIDList", "(", ")", "(", "[", "]", "int32", ",", "error", ")", "{", "brokers", ",", "err", ":=", "kz", ".", "Brokers", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n",...
// BrokerIDList returns a sorted slice of broker ids that can be used for manipulating topics and partitions.`.
[ "BrokerIDList", "returns", "a", "sorted", "slice", "of", "broker", "ids", "that", "can", "be", "used", "for", "manipulating", "topics", "and", "partitions", ".", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/kazoo.go#L155-L170
132,647
wvanbergen/kazoo-go
kazoo.go
Controller
func (kz *Kazoo) Controller() (int32, error) { type controllerEntry struct { BrokerID int32 `json:"brokerid"` } node := fmt.Sprintf("%s/controller", kz.conf.Chroot) data, _, err := kz.conn.Get(node) if err != nil { return -1, err } var controllerNode controllerEntry if err := json.Unmarshal(data, &control...
go
func (kz *Kazoo) Controller() (int32, error) { type controllerEntry struct { BrokerID int32 `json:"brokerid"` } node := fmt.Sprintf("%s/controller", kz.conf.Chroot) data, _, err := kz.conn.Get(node) if err != nil { return -1, err } var controllerNode controllerEntry if err := json.Unmarshal(data, &control...
[ "func", "(", "kz", "*", "Kazoo", ")", "Controller", "(", ")", "(", "int32", ",", "error", ")", "{", "type", "controllerEntry", "struct", "{", "BrokerID", "int32", "`json:\"brokerid\"`", "\n", "}", "\n\n", "node", ":=", "fmt", ".", "Sprintf", "(", "\"", ...
// Controller returns what broker is currently acting as controller of the Kafka cluster
[ "Controller", "returns", "what", "broker", "is", "currently", "acting", "as", "controller", "of", "the", "Kafka", "cluster" ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/kazoo.go#L173-L190
132,648
wvanbergen/kazoo-go
kazoo.go
deleteRecursive
func (kz *Kazoo) deleteRecursive(node string) (err error) { children, stat, err := kz.conn.Children(node) if err == zk.ErrNoNode { return nil } else if err != nil { return } for _, child := range children { if err = kz.deleteRecursive(path.Join(node, child)); err != nil { return } } return kz.conn.D...
go
func (kz *Kazoo) deleteRecursive(node string) (err error) { children, stat, err := kz.conn.Children(node) if err == zk.ErrNoNode { return nil } else if err != nil { return } for _, child := range children { if err = kz.deleteRecursive(path.Join(node, child)); err != nil { return } } return kz.conn.D...
[ "func", "(", "kz", "*", "Kazoo", ")", "deleteRecursive", "(", "node", "string", ")", "(", "err", "error", ")", "{", "children", ",", "stat", ",", "err", ":=", "kz", ".", "conn", ".", "Children", "(", "node", ")", "\n", "if", "err", "==", "zk", "....
// DeleteAll deletes a node recursively
[ "DeleteAll", "deletes", "a", "node", "recursively" ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/kazoo.go#L209-L224
132,649
wvanbergen/kazoo-go
kazoo.go
mkdirRecursive
func (kz *Kazoo) mkdirRecursive(node string) (err error) { parent := path.Dir(node) if parent != "/" { if err = kz.mkdirRecursive(parent); err != nil { return } } exists, _, err := kz.conn.Exists(node) if err != nil { return } if !exists { _, err = kz.conn.Create(node, nil, 0, zk.WorldACL(zk.PermAll...
go
func (kz *Kazoo) mkdirRecursive(node string) (err error) { parent := path.Dir(node) if parent != "/" { if err = kz.mkdirRecursive(parent); err != nil { return } } exists, _, err := kz.conn.Exists(node) if err != nil { return } if !exists { _, err = kz.conn.Create(node, nil, 0, zk.WorldACL(zk.PermAll...
[ "func", "(", "kz", "*", "Kazoo", ")", "mkdirRecursive", "(", "node", "string", ")", "(", "err", "error", ")", "{", "parent", ":=", "path", ".", "Dir", "(", "node", ")", "\n", "if", "parent", "!=", "\"", "\"", "{", "if", "err", "=", "kz", ".", "...
// MkdirAll creates a directory recursively
[ "MkdirAll", "creates", "a", "directory", "recursively" ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/kazoo.go#L227-L246
132,650
wvanbergen/kazoo-go
kazoo.go
create
func (kz *Kazoo) create(node string, value []byte, ephemeral bool) (err error) { if err = kz.mkdirRecursive(path.Dir(node)); err != nil { return } flags := int32(0) if ephemeral { flags = zk.FlagEphemeral } _, err = kz.conn.Create(node, value, flags, zk.WorldACL(zk.PermAll)) return }
go
func (kz *Kazoo) create(node string, value []byte, ephemeral bool) (err error) { if err = kz.mkdirRecursive(path.Dir(node)); err != nil { return } flags := int32(0) if ephemeral { flags = zk.FlagEphemeral } _, err = kz.conn.Create(node, value, flags, zk.WorldACL(zk.PermAll)) return }
[ "func", "(", "kz", "*", "Kazoo", ")", "create", "(", "node", "string", ",", "value", "[", "]", "byte", ",", "ephemeral", "bool", ")", "(", "err", "error", ")", "{", "if", "err", "=", "kz", ".", "mkdirRecursive", "(", "path", ".", "Dir", "(", "nod...
// Create stores a new value at node. Fails if already set.
[ "Create", "stores", "a", "new", "value", "at", "node", ".", "Fails", "if", "already", "set", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/kazoo.go#L249-L260
132,651
wvanbergen/kazoo-go
kazoo.go
createOrUpdate
func (kz *Kazoo) createOrUpdate(node string, value []byte, ephemeral bool) (err error) { if _, err = kz.conn.Set(node, value, -1); err == nil { return } if err == zk.ErrNoNode { err = kz.create(node, value, ephemeral) } return }
go
func (kz *Kazoo) createOrUpdate(node string, value []byte, ephemeral bool) (err error) { if _, err = kz.conn.Set(node, value, -1); err == nil { return } if err == zk.ErrNoNode { err = kz.create(node, value, ephemeral) } return }
[ "func", "(", "kz", "*", "Kazoo", ")", "createOrUpdate", "(", "node", "string", ",", "value", "[", "]", "byte", ",", "ephemeral", "bool", ")", "(", "err", "error", ")", "{", "if", "_", ",", "err", "=", "kz", ".", "conn", ".", "Set", "(", "node", ...
// createOrUpdate first attempts to update a node. If the nodes does not exist it will create it.
[ "createOrUpdate", "first", "attempts", "to", "update", "a", "node", ".", "If", "the", "nodes", "does", "not", "exist", "it", "will", "create", "it", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/kazoo.go#L263-L272
132,652
wvanbergen/kazoo-go
consumergroup.go
Consumergroups
func (kz *Kazoo) Consumergroups() (ConsumergroupList, error) { root := fmt.Sprintf("%s/consumers", kz.conf.Chroot) cgs, _, err := kz.conn.Children(root) if err != nil { return nil, err } result := make(ConsumergroupList, 0, len(cgs)) for _, cg := range cgs { result = append(result, kz.Consumergroup(cg)) } ...
go
func (kz *Kazoo) Consumergroups() (ConsumergroupList, error) { root := fmt.Sprintf("%s/consumers", kz.conf.Chroot) cgs, _, err := kz.conn.Children(root) if err != nil { return nil, err } result := make(ConsumergroupList, 0, len(cgs)) for _, cg := range cgs { result = append(result, kz.Consumergroup(cg)) } ...
[ "func", "(", "kz", "*", "Kazoo", ")", "Consumergroups", "(", ")", "(", "ConsumergroupList", ",", "error", ")", "{", "root", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "kz", ".", "conf", ".", "Chroot", ")", "\n", "cgs", ",", "_", ",", "err...
// Consumergroups returns all the registered consumergroups
[ "Consumergroups", "returns", "all", "the", "registered", "consumergroups" ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/consumergroup.go#L64-L76
132,653
wvanbergen/kazoo-go
consumergroup.go
Consumergroup
func (kz *Kazoo) Consumergroup(name string) *Consumergroup { return &Consumergroup{Name: name, kz: kz} }
go
func (kz *Kazoo) Consumergroup(name string) *Consumergroup { return &Consumergroup{Name: name, kz: kz} }
[ "func", "(", "kz", "*", "Kazoo", ")", "Consumergroup", "(", "name", "string", ")", "*", "Consumergroup", "{", "return", "&", "Consumergroup", "{", "Name", ":", "name", ",", "kz", ":", "kz", "}", "\n", "}" ]
// Consumergroup instantiates a new consumergroup.
[ "Consumergroup", "instantiates", "a", "new", "consumergroup", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/consumergroup.go#L79-L81
132,654
wvanbergen/kazoo-go
consumergroup.go
Exists
func (cg *Consumergroup) Exists() (bool, error) { return cg.kz.exists(fmt.Sprintf("%s/consumers/%s", cg.kz.conf.Chroot, cg.Name)) }
go
func (cg *Consumergroup) Exists() (bool, error) { return cg.kz.exists(fmt.Sprintf("%s/consumers/%s", cg.kz.conf.Chroot, cg.Name)) }
[ "func", "(", "cg", "*", "Consumergroup", ")", "Exists", "(", ")", "(", "bool", ",", "error", ")", "{", "return", "cg", ".", "kz", ".", "exists", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "cg", ".", "kz", ".", "conf", ".", "Chroot", ",",...
// Exists checks whether the consumergroup has been registered in Zookeeper
[ "Exists", "checks", "whether", "the", "consumergroup", "has", "been", "registered", "in", "Zookeeper" ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/consumergroup.go#L84-L86
132,655
wvanbergen/kazoo-go
consumergroup.go
Create
func (cg *Consumergroup) Create() error { return cg.kz.mkdirRecursive(fmt.Sprintf("%s/consumers/%s", cg.kz.conf.Chroot, cg.Name)) }
go
func (cg *Consumergroup) Create() error { return cg.kz.mkdirRecursive(fmt.Sprintf("%s/consumers/%s", cg.kz.conf.Chroot, cg.Name)) }
[ "func", "(", "cg", "*", "Consumergroup", ")", "Create", "(", ")", "error", "{", "return", "cg", ".", "kz", ".", "mkdirRecursive", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "cg", ".", "kz", ".", "conf", ".", "Chroot", ",", "cg", ".", "Name...
// Create registers the consumergroup in zookeeper
[ "Create", "registers", "the", "consumergroup", "in", "zookeeper" ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/consumergroup.go#L89-L91
132,656
wvanbergen/kazoo-go
consumergroup.go
Delete
func (cg *Consumergroup) Delete() error { if instances, err := cg.Instances(); err != nil { return err } else if len(instances) > 0 { return ErrRunningInstances } return cg.kz.deleteRecursive(fmt.Sprintf("%s/consumers/%s", cg.kz.conf.Chroot, cg.Name)) }
go
func (cg *Consumergroup) Delete() error { if instances, err := cg.Instances(); err != nil { return err } else if len(instances) > 0 { return ErrRunningInstances } return cg.kz.deleteRecursive(fmt.Sprintf("%s/consumers/%s", cg.kz.conf.Chroot, cg.Name)) }
[ "func", "(", "cg", "*", "Consumergroup", ")", "Delete", "(", ")", "error", "{", "if", "instances", ",", "err", ":=", "cg", ".", "Instances", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "else", "if", "len", "(", "instances", ...
// Delete removes the consumergroup from zookeeper
[ "Delete", "removes", "the", "consumergroup", "from", "zookeeper" ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/consumergroup.go#L94-L102
132,657
wvanbergen/kazoo-go
consumergroup.go
Instances
func (cg *Consumergroup) Instances() (ConsumergroupInstanceList, error) { root := fmt.Sprintf("%s/consumers/%s/ids", cg.kz.conf.Chroot, cg.Name) cgis, _, err := cg.kz.conn.Children(root) if err != nil { if err == zk.ErrNoNode { result := make(ConsumergroupInstanceList, 0) return result, nil } return nil,...
go
func (cg *Consumergroup) Instances() (ConsumergroupInstanceList, error) { root := fmt.Sprintf("%s/consumers/%s/ids", cg.kz.conf.Chroot, cg.Name) cgis, _, err := cg.kz.conn.Children(root) if err != nil { if err == zk.ErrNoNode { result := make(ConsumergroupInstanceList, 0) return result, nil } return nil,...
[ "func", "(", "cg", "*", "Consumergroup", ")", "Instances", "(", ")", "(", "ConsumergroupInstanceList", ",", "error", ")", "{", "root", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "cg", ".", "kz", ".", "conf", ".", "Chroot", ",", "cg", ".", "...
// Instances returns a map of all running instances inside this consumergroup.
[ "Instances", "returns", "a", "map", "of", "all", "running", "instances", "inside", "this", "consumergroup", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/consumergroup.go#L105-L121
132,658
wvanbergen/kazoo-go
consumergroup.go
WatchInstances
func (cg *Consumergroup) WatchInstances() (ConsumergroupInstanceList, <-chan zk.Event, error) { node := fmt.Sprintf("%s/consumers/%s/ids", cg.kz.conf.Chroot, cg.Name) cgis, _, c, err := cg.kz.conn.ChildrenW(node) if err != nil { if err != zk.ErrNoNode { return nil, nil, err } if err := cg.kz.mkdirRecursive(...
go
func (cg *Consumergroup) WatchInstances() (ConsumergroupInstanceList, <-chan zk.Event, error) { node := fmt.Sprintf("%s/consumers/%s/ids", cg.kz.conf.Chroot, cg.Name) cgis, _, c, err := cg.kz.conn.ChildrenW(node) if err != nil { if err != zk.ErrNoNode { return nil, nil, err } if err := cg.kz.mkdirRecursive(...
[ "func", "(", "cg", "*", "Consumergroup", ")", "WatchInstances", "(", ")", "(", "ConsumergroupInstanceList", ",", "<-", "chan", "zk", ".", "Event", ",", "error", ")", "{", "node", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "cg", ".", "kz", "."...
// WatchInstances returns a ConsumergroupInstanceList, and a channel that will be closed // as soon the instance list changes.
[ "WatchInstances", "returns", "a", "ConsumergroupInstanceList", "and", "a", "channel", "that", "will", "be", "closed", "as", "soon", "the", "instance", "list", "changes", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/consumergroup.go#L125-L146
132,659
wvanbergen/kazoo-go
consumergroup.go
NewInstance
func (cg *Consumergroup) NewInstance() *ConsumergroupInstance { id, err := generateConsumerInstanceID() if err != nil { panic(err) } return cg.Instance(id) }
go
func (cg *Consumergroup) NewInstance() *ConsumergroupInstance { id, err := generateConsumerInstanceID() if err != nil { panic(err) } return cg.Instance(id) }
[ "func", "(", "cg", "*", "Consumergroup", ")", "NewInstance", "(", ")", "*", "ConsumergroupInstance", "{", "id", ",", "err", ":=", "generateConsumerInstanceID", "(", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "r...
// NewInstance instantiates a new ConsumergroupInstance inside this consumer group, // using a newly generated ID.
[ "NewInstance", "instantiates", "a", "new", "ConsumergroupInstance", "inside", "this", "consumer", "group", "using", "a", "newly", "generated", "ID", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/consumergroup.go#L150-L156
132,660
wvanbergen/kazoo-go
consumergroup.go
Instance
func (cg *Consumergroup) Instance(id string) *ConsumergroupInstance { return &ConsumergroupInstance{cg: cg, ID: id} }
go
func (cg *Consumergroup) Instance(id string) *ConsumergroupInstance { return &ConsumergroupInstance{cg: cg, ID: id} }
[ "func", "(", "cg", "*", "Consumergroup", ")", "Instance", "(", "id", "string", ")", "*", "ConsumergroupInstance", "{", "return", "&", "ConsumergroupInstance", "{", "cg", ":", "cg", ",", "ID", ":", "id", "}", "\n", "}" ]
// Instance instantiates a new ConsumergroupInstance inside this consumer group, // using an existing ID.
[ "Instance", "instantiates", "a", "new", "ConsumergroupInstance", "inside", "this", "consumer", "group", "using", "an", "existing", "ID", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/consumergroup.go#L160-L162
132,661
wvanbergen/kazoo-go
consumergroup.go
PartitionOwner
func (cg *Consumergroup) PartitionOwner(topic string, partition int32) (*ConsumergroupInstance, error) { node := fmt.Sprintf("%s/consumers/%s/owners/%s/%d", cg.kz.conf.Chroot, cg.Name, topic, partition) val, _, err := cg.kz.conn.Get(node) // If the node does not exists, nobody has claimed it. switch err { case ni...
go
func (cg *Consumergroup) PartitionOwner(topic string, partition int32) (*ConsumergroupInstance, error) { node := fmt.Sprintf("%s/consumers/%s/owners/%s/%d", cg.kz.conf.Chroot, cg.Name, topic, partition) val, _, err := cg.kz.conn.Get(node) // If the node does not exists, nobody has claimed it. switch err { case ni...
[ "func", "(", "cg", "*", "Consumergroup", ")", "PartitionOwner", "(", "topic", "string", ",", "partition", "int32", ")", "(", "*", "ConsumergroupInstance", ",", "error", ")", "{", "node", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "cg", ".", "kz...
// PartitionOwner returns the ConsumergroupInstance that has claimed the given partition. // This can be nil if nobody has claimed it yet.
[ "PartitionOwner", "returns", "the", "ConsumergroupInstance", "that", "has", "claimed", "the", "given", "partition", ".", "This", "can", "be", "nil", "if", "nobody", "has", "claimed", "it", "yet", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/consumergroup.go#L166-L179
132,662
wvanbergen/kazoo-go
consumergroup.go
WatchPartitionOwner
func (cg *Consumergroup) WatchPartitionOwner(topic string, partition int32) (*ConsumergroupInstance, <-chan zk.Event, error) { node := fmt.Sprintf("%s/consumers/%s/owners/%s/%d", cg.kz.conf.Chroot, cg.Name, topic, partition) instanceID, _, changed, err := cg.kz.conn.GetW(node) switch err { case nil: return &Cons...
go
func (cg *Consumergroup) WatchPartitionOwner(topic string, partition int32) (*ConsumergroupInstance, <-chan zk.Event, error) { node := fmt.Sprintf("%s/consumers/%s/owners/%s/%d", cg.kz.conf.Chroot, cg.Name, topic, partition) instanceID, _, changed, err := cg.kz.conn.GetW(node) switch err { case nil: return &Cons...
[ "func", "(", "cg", "*", "Consumergroup", ")", "WatchPartitionOwner", "(", "topic", "string", ",", "partition", "int32", ")", "(", "*", "ConsumergroupInstance", ",", "<-", "chan", "zk", ".", "Event", ",", "error", ")", "{", "node", ":=", "fmt", ".", "Spri...
// WatchPartitionOwner retrieves what instance is currently owning the partition, and sets a // Zookeeper watch to be notified of changes. If the partition currently does not have an owner, // the function returns nil for every return value. In this case is should be safe to claim // the partition for an instance.
[ "WatchPartitionOwner", "retrieves", "what", "instance", "is", "currently", "owning", "the", "partition", "and", "sets", "a", "Zookeeper", "watch", "to", "be", "notified", "of", "changes", ".", "If", "the", "partition", "currently", "does", "not", "have", "an", ...
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/consumergroup.go#L185-L199
132,663
wvanbergen/kazoo-go
consumergroup.go
Registered
func (cgi *ConsumergroupInstance) Registered() (bool, error) { node := fmt.Sprintf("%s/consumers/%s/ids/%s", cgi.cg.kz.conf.Chroot, cgi.cg.Name, cgi.ID) return cgi.cg.kz.exists(node) }
go
func (cgi *ConsumergroupInstance) Registered() (bool, error) { node := fmt.Sprintf("%s/consumers/%s/ids/%s", cgi.cg.kz.conf.Chroot, cgi.cg.Name, cgi.ID) return cgi.cg.kz.exists(node) }
[ "func", "(", "cgi", "*", "ConsumergroupInstance", ")", "Registered", "(", ")", "(", "bool", ",", "error", ")", "{", "node", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "cgi", ".", "cg", ".", "kz", ".", "conf", ".", "Chroot", ",", "cgi", "....
// Registered checks whether the consumergroup instance is registered in Zookeeper.
[ "Registered", "checks", "whether", "the", "consumergroup", "instance", "is", "registered", "in", "Zookeeper", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/consumergroup.go#L202-L205
132,664
wvanbergen/kazoo-go
consumergroup.go
Registration
func (cgi *ConsumergroupInstance) Registration() (*Registration, error) { node := fmt.Sprintf("%s/consumers/%s/ids/%s", cgi.cg.kz.conf.Chroot, cgi.cg.Name, cgi.ID) val, _, err := cgi.cg.kz.conn.Get(node) if err != nil { if err == zk.ErrNoNode { return nil, ErrInstanceNotRegistered } return nil, err } reg...
go
func (cgi *ConsumergroupInstance) Registration() (*Registration, error) { node := fmt.Sprintf("%s/consumers/%s/ids/%s", cgi.cg.kz.conf.Chroot, cgi.cg.Name, cgi.ID) val, _, err := cgi.cg.kz.conn.Get(node) if err != nil { if err == zk.ErrNoNode { return nil, ErrInstanceNotRegistered } return nil, err } reg...
[ "func", "(", "cgi", "*", "ConsumergroupInstance", ")", "Registration", "(", ")", "(", "*", "Registration", ",", "error", ")", "{", "node", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "cgi", ".", "cg", ".", "kz", ".", "conf", ".", "Chroot", "...
// Registered returns current registration of the consumer group instance.
[ "Registered", "returns", "current", "registration", "of", "the", "consumer", "group", "instance", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/consumergroup.go#L208-L223
132,665
wvanbergen/kazoo-go
consumergroup.go
RegisterWithSubscription
func (cgi *ConsumergroupInstance) RegisterWithSubscription(subscriptionJSON []byte) error { node := fmt.Sprintf("%s/consumers/%s/ids/%s", cgi.cg.kz.conf.Chroot, cgi.cg.Name, cgi.ID) err := cgi.cg.kz.create(node, subscriptionJSON, true) if err == zk.ErrNodeExists { return ErrInstanceAlreadyRegistered } return err...
go
func (cgi *ConsumergroupInstance) RegisterWithSubscription(subscriptionJSON []byte) error { node := fmt.Sprintf("%s/consumers/%s/ids/%s", cgi.cg.kz.conf.Chroot, cgi.cg.Name, cgi.ID) err := cgi.cg.kz.create(node, subscriptionJSON, true) if err == zk.ErrNodeExists { return ErrInstanceAlreadyRegistered } return err...
[ "func", "(", "cgi", "*", "ConsumergroupInstance", ")", "RegisterWithSubscription", "(", "subscriptionJSON", "[", "]", "byte", ")", "error", "{", "node", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "cgi", ".", "cg", ".", "kz", ".", "conf", ".", "...
// RegisterSubscription registers the consumer instance in Zookeeper, with its subscription.
[ "RegisterSubscription", "registers", "the", "consumer", "instance", "in", "Zookeeper", "with", "its", "subscription", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/consumergroup.go#L245-L252
132,666
wvanbergen/kazoo-go
consumergroup.go
UpdateRegistration
func (cgi *ConsumergroupInstance) UpdateRegistration(topics []string) error { subscriptionJSON, err := cgi.marshalSubscription(topics) if err != nil { return err } node := fmt.Sprintf("%s/consumers/%s/ids/%s", cgi.cg.kz.conf.Chroot, cgi.cg.Name, cgi.ID) _, stat, err := cgi.cg.kz.conn.Get(node) if err != nil { ...
go
func (cgi *ConsumergroupInstance) UpdateRegistration(topics []string) error { subscriptionJSON, err := cgi.marshalSubscription(topics) if err != nil { return err } node := fmt.Sprintf("%s/consumers/%s/ids/%s", cgi.cg.kz.conf.Chroot, cgi.cg.Name, cgi.ID) _, stat, err := cgi.cg.kz.conn.Get(node) if err != nil { ...
[ "func", "(", "cgi", "*", "ConsumergroupInstance", ")", "UpdateRegistration", "(", "topics", "[", "]", "string", ")", "error", "{", "subscriptionJSON", ",", "err", ":=", "cgi", ".", "marshalSubscription", "(", "topics", ")", "\n", "if", "err", "!=", "nil", ...
// UpdateRegistration updates a consumer group member registration. If the // consumer group member has not been registered yet, then an error is returned.
[ "UpdateRegistration", "updates", "a", "consumer", "group", "member", "registration", ".", "If", "the", "consumer", "group", "member", "has", "not", "been", "registered", "yet", "then", "an", "error", "is", "returned", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/consumergroup.go#L266-L286
132,667
wvanbergen/kazoo-go
consumergroup.go
Deregister
func (cgi *ConsumergroupInstance) Deregister() error { node := fmt.Sprintf("%s/consumers/%s/ids/%s", cgi.cg.kz.conf.Chroot, cgi.cg.Name, cgi.ID) exists, stat, err := cgi.cg.kz.conn.Exists(node) if err != nil { return err } else if !exists { return ErrInstanceNotRegistered } err = cgi.cg.kz.conn.Delete(node, ...
go
func (cgi *ConsumergroupInstance) Deregister() error { node := fmt.Sprintf("%s/consumers/%s/ids/%s", cgi.cg.kz.conf.Chroot, cgi.cg.Name, cgi.ID) exists, stat, err := cgi.cg.kz.conn.Exists(node) if err != nil { return err } else if !exists { return ErrInstanceNotRegistered } err = cgi.cg.kz.conn.Delete(node, ...
[ "func", "(", "cgi", "*", "ConsumergroupInstance", ")", "Deregister", "(", ")", "error", "{", "node", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "cgi", ".", "cg", ".", "kz", ".", "conf", ".", "Chroot", ",", "cgi", ".", "cg", ".", "Name", "...
// Deregister removes the registration of the instance from zookeeper.
[ "Deregister", "removes", "the", "registration", "of", "the", "instance", "from", "zookeeper", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/consumergroup.go#L307-L321
132,668
wvanbergen/kazoo-go
consumergroup.go
ReleasePartition
func (cgi *ConsumergroupInstance) ReleasePartition(topic string, partition int32) error { owner, err := cgi.cg.PartitionOwner(topic, partition) if err != nil { return err } if owner == nil || owner.ID != cgi.ID { return ErrPartitionNotClaimed } node := fmt.Sprintf("%s/consumers/%s/owners/%s/%d", cgi.cg.kz.co...
go
func (cgi *ConsumergroupInstance) ReleasePartition(topic string, partition int32) error { owner, err := cgi.cg.PartitionOwner(topic, partition) if err != nil { return err } if owner == nil || owner.ID != cgi.ID { return ErrPartitionNotClaimed } node := fmt.Sprintf("%s/consumers/%s/owners/%s/%d", cgi.cg.kz.co...
[ "func", "(", "cgi", "*", "ConsumergroupInstance", ")", "ReleasePartition", "(", "topic", "string", ",", "partition", "int32", ")", "error", "{", "owner", ",", "err", ":=", "cgi", ".", "cg", ".", "PartitionOwner", "(", "topic", ",", "partition", ")", "\n", ...
// ReleasePartition releases a claim to a partition.
[ "ReleasePartition", "releases", "a", "claim", "to", "a", "partition", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/consumergroup.go#L351-L362
132,669
wvanbergen/kazoo-go
consumergroup.go
FetchAllOffsets
func (cg *Consumergroup) FetchAllOffsets() (map[string]map[int32]int64, error) { result := make(map[string]map[int32]int64) offsetsNode := fmt.Sprintf("%s/consumers/%s/offsets", cg.kz.conf.Chroot, cg.Name) topics, _, err := cg.kz.conn.Children(offsetsNode) if err == zk.ErrNoNode { return result, nil } else if e...
go
func (cg *Consumergroup) FetchAllOffsets() (map[string]map[int32]int64, error) { result := make(map[string]map[int32]int64) offsetsNode := fmt.Sprintf("%s/consumers/%s/offsets", cg.kz.conf.Chroot, cg.Name) topics, _, err := cg.kz.conn.Children(offsetsNode) if err == zk.ErrNoNode { return result, nil } else if e...
[ "func", "(", "cg", "*", "Consumergroup", ")", "FetchAllOffsets", "(", ")", "(", "map", "[", "string", "]", "map", "[", "int32", "]", "int64", ",", "error", ")", "{", "result", ":=", "make", "(", "map", "[", "string", "]", "map", "[", "int32", "]", ...
// FetchOffset retrieves all the commmitted offsets for a group
[ "FetchOffset", "retrieves", "all", "the", "commmitted", "offsets", "for", "a", "group" ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/consumergroup.go#L411-L452
132,670
wvanbergen/kazoo-go
consumergroup.go
generateConsumerInstanceID
func generateConsumerInstanceID() (string, error) { uuid, err := generateUUID() if err != nil { return "", err } hostname, err := os.Hostname() if err != nil { return "", err } return fmt.Sprintf("%s:%s", hostname, uuid), nil }
go
func generateConsumerInstanceID() (string, error) { uuid, err := generateUUID() if err != nil { return "", err } hostname, err := os.Hostname() if err != nil { return "", err } return fmt.Sprintf("%s:%s", hostname, uuid), nil }
[ "func", "generateConsumerInstanceID", "(", ")", "(", "string", ",", "error", ")", "{", "uuid", ",", "err", ":=", "generateUUID", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "hostname", ",", "err...
// generateConsumerInstanceID generates a consumergroup Instance ID // that is almost certain to be unique.
[ "generateConsumerInstanceID", "generates", "a", "consumergroup", "Instance", "ID", "that", "is", "almost", "certain", "to", "be", "unique", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/consumergroup.go#L508-L520
132,671
wvanbergen/kazoo-go
consumergroup.go
Find
func (cgl ConsumergroupList) Find(name string) *Consumergroup { for _, cg := range cgl { if cg.Name == name { return cg } } return nil }
go
func (cgl ConsumergroupList) Find(name string) *Consumergroup { for _, cg := range cgl { if cg.Name == name { return cg } } return nil }
[ "func", "(", "cgl", "ConsumergroupList", ")", "Find", "(", "name", "string", ")", "*", "Consumergroup", "{", "for", "_", ",", "cg", ":=", "range", "cgl", "{", "if", "cg", ".", "Name", "==", "name", "{", "return", "cg", "\n", "}", "\n", "}", "\n", ...
// Find returns the consumergroup with the given name if it exists in the list. // Otherwise it will return `nil`.
[ "Find", "returns", "the", "consumergroup", "with", "the", "given", "name", "if", "it", "exists", "in", "the", "list", ".", "Otherwise", "it", "will", "return", "nil", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/consumergroup.go#L524-L531
132,672
wvanbergen/kazoo-go
consumergroup.go
Find
func (cgil ConsumergroupInstanceList) Find(id string) *ConsumergroupInstance { for _, cgi := range cgil { if cgi.ID == id { return cgi } } return nil }
go
func (cgil ConsumergroupInstanceList) Find(id string) *ConsumergroupInstance { for _, cgi := range cgil { if cgi.ID == id { return cgi } } return nil }
[ "func", "(", "cgil", "ConsumergroupInstanceList", ")", "Find", "(", "id", "string", ")", "*", "ConsumergroupInstance", "{", "for", "_", ",", "cgi", ":=", "range", "cgil", "{", "if", "cgi", ".", "ID", "==", "id", "{", "return", "cgi", "\n", "}", "\n", ...
// Find returns the consumergroup instance with the given ID if it exists in the list. // Otherwise it will return `nil`.
[ "Find", "returns", "the", "consumergroup", "instance", "with", "the", "given", "ID", "if", "it", "exists", "in", "the", "list", ".", "Otherwise", "it", "will", "return", "nil", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/consumergroup.go#L547-L554
132,673
wvanbergen/kazoo-go
topic_metadata.go
Topics
func (kz *Kazoo) Topics() (TopicList, error) { root := fmt.Sprintf("%s/brokers/topics", kz.conf.Chroot) children, _, err := kz.conn.Children(root) if err != nil { return nil, err } result := make(TopicList, 0, len(children)) for _, name := range children { result = append(result, kz.Topic(name)) } return r...
go
func (kz *Kazoo) Topics() (TopicList, error) { root := fmt.Sprintf("%s/brokers/topics", kz.conf.Chroot) children, _, err := kz.conn.Children(root) if err != nil { return nil, err } result := make(TopicList, 0, len(children)) for _, name := range children { result = append(result, kz.Topic(name)) } return r...
[ "func", "(", "kz", "*", "Kazoo", ")", "Topics", "(", ")", "(", "TopicList", ",", "error", ")", "{", "root", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "kz", ".", "conf", ".", "Chroot", ")", "\n", "children", ",", "_", ",", "err", ":=", ...
// Topics returns a list of all registered Kafka topics.
[ "Topics", "returns", "a", "list", "of", "all", "registered", "Kafka", "topics", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/topic_metadata.go#L43-L55
132,674
wvanbergen/kazoo-go
topic_metadata.go
WatchTopics
func (kz *Kazoo) WatchTopics() (TopicList, <-chan zk.Event, error) { root := fmt.Sprintf("%s/brokers/topics", kz.conf.Chroot) children, _, c, err := kz.conn.ChildrenW(root) if err != nil { return nil, nil, err } result := make(TopicList, 0, len(children)) for _, name := range children { result = append(resul...
go
func (kz *Kazoo) WatchTopics() (TopicList, <-chan zk.Event, error) { root := fmt.Sprintf("%s/brokers/topics", kz.conf.Chroot) children, _, c, err := kz.conn.ChildrenW(root) if err != nil { return nil, nil, err } result := make(TopicList, 0, len(children)) for _, name := range children { result = append(resul...
[ "func", "(", "kz", "*", "Kazoo", ")", "WatchTopics", "(", ")", "(", "TopicList", ",", "<-", "chan", "zk", ".", "Event", ",", "error", ")", "{", "root", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "kz", ".", "conf", ".", "Chroot", ")", "\...
// WatchTopics returns a list of all registered Kafka topics, and // watches that list for changes.
[ "WatchTopics", "returns", "a", "list", "of", "all", "registered", "Kafka", "topics", "and", "watches", "that", "list", "for", "changes", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/topic_metadata.go#L59-L71
132,675
wvanbergen/kazoo-go
topic_metadata.go
Topic
func (kz *Kazoo) Topic(topic string) *Topic { return &Topic{Name: topic, kz: kz} }
go
func (kz *Kazoo) Topic(topic string) *Topic { return &Topic{Name: topic, kz: kz} }
[ "func", "(", "kz", "*", "Kazoo", ")", "Topic", "(", "topic", "string", ")", "*", "Topic", "{", "return", "&", "Topic", "{", "Name", ":", "topic", ",", "kz", ":", "kz", "}", "\n", "}" ]
// Topic returns a Topic instance for a given topic name
[ "Topic", "returns", "a", "Topic", "instance", "for", "a", "given", "topic", "name" ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/topic_metadata.go#L74-L76
132,676
wvanbergen/kazoo-go
topic_metadata.go
Exists
func (t *Topic) Exists() (bool, error) { return t.kz.exists(t.metadataPath()) }
go
func (t *Topic) Exists() (bool, error) { return t.kz.exists(t.metadataPath()) }
[ "func", "(", "t", "*", "Topic", ")", "Exists", "(", ")", "(", "bool", ",", "error", ")", "{", "return", "t", ".", "kz", ".", "exists", "(", "t", ".", "metadataPath", "(", ")", ")", "\n", "}" ]
// Exists returns true if the topic exists on the Kafka cluster.
[ "Exists", "returns", "true", "if", "the", "topic", "exists", "on", "the", "Kafka", "cluster", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/topic_metadata.go#L79-L81
132,677
wvanbergen/kazoo-go
topic_metadata.go
Partitions
func (t *Topic) Partitions() (PartitionList, error) { value, _, err := t.kz.conn.Get(t.metadataPath()) if err != nil { return nil, err } return t.parsePartitions(value) }
go
func (t *Topic) Partitions() (PartitionList, error) { value, _, err := t.kz.conn.Get(t.metadataPath()) if err != nil { return nil, err } return t.parsePartitions(value) }
[ "func", "(", "t", "*", "Topic", ")", "Partitions", "(", ")", "(", "PartitionList", ",", "error", ")", "{", "value", ",", "_", ",", "err", ":=", "t", ".", "kz", ".", "conn", ".", "Get", "(", "t", ".", "metadataPath", "(", ")", ")", "\n", "if", ...
// Partitions returns a list of all partitions for the topic.
[ "Partitions", "returns", "a", "list", "of", "all", "partitions", "for", "the", "topic", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/topic_metadata.go#L84-L91
132,678
wvanbergen/kazoo-go
topic_metadata.go
WatchPartitions
func (t *Topic) WatchPartitions() (PartitionList, <-chan zk.Event, error) { value, _, c, err := t.kz.conn.GetW(t.metadataPath()) if err != nil { return nil, nil, err } list, err := t.parsePartitions(value) return list, c, err }
go
func (t *Topic) WatchPartitions() (PartitionList, <-chan zk.Event, error) { value, _, c, err := t.kz.conn.GetW(t.metadataPath()) if err != nil { return nil, nil, err } list, err := t.parsePartitions(value) return list, c, err }
[ "func", "(", "t", "*", "Topic", ")", "WatchPartitions", "(", ")", "(", "PartitionList", ",", "<-", "chan", "zk", ".", "Event", ",", "error", ")", "{", "value", ",", "_", ",", "c", ",", "err", ":=", "t", ".", "kz", ".", "conn", ".", "GetW", "(",...
// WatchPartitions returns a list of all partitions for the topic, and watches the topic for changes.
[ "WatchPartitions", "returns", "a", "list", "of", "all", "partitions", "for", "the", "topic", "and", "watches", "the", "topic", "for", "changes", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/topic_metadata.go#L94-L102
132,679
wvanbergen/kazoo-go
topic_metadata.go
Watch
func (t *Topic) Watch() (<-chan zk.Event, error) { _, _, c, err := t.kz.conn.GetW(t.metadataPath()) if err != nil { return nil, err } return c, err }
go
func (t *Topic) Watch() (<-chan zk.Event, error) { _, _, c, err := t.kz.conn.GetW(t.metadataPath()) if err != nil { return nil, err } return c, err }
[ "func", "(", "t", "*", "Topic", ")", "Watch", "(", ")", "(", "<-", "chan", "zk", ".", "Event", ",", "error", ")", "{", "_", ",", "_", ",", "c", ",", "err", ":=", "t", ".", "kz", ".", "conn", ".", "GetW", "(", "t", ".", "metadataPath", "(", ...
// Watch watches the topic for changes.
[ "Watch", "watches", "the", "topic", "for", "changes", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/topic_metadata.go#L105-L112
132,680
wvanbergen/kazoo-go
topic_metadata.go
parsePartitions
func (t *Topic) parsePartitions(value []byte) (PartitionList, error) { var tm topicMetadata if err := json.Unmarshal(value, &tm); err != nil { return nil, err } result := make(PartitionList, len(tm.Partitions)) for partitionNumber, replicas := range tm.Partitions { partitionID, err := strconv.ParseInt(partiti...
go
func (t *Topic) parsePartitions(value []byte) (PartitionList, error) { var tm topicMetadata if err := json.Unmarshal(value, &tm); err != nil { return nil, err } result := make(PartitionList, len(tm.Partitions)) for partitionNumber, replicas := range tm.Partitions { partitionID, err := strconv.ParseInt(partiti...
[ "func", "(", "t", "*", "Topic", ")", "parsePartitions", "(", "value", "[", "]", "byte", ")", "(", "PartitionList", ",", "error", ")", "{", "var", "tm", "topicMetadata", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "value", ",", "&", "tm", ...
// parsePartitions parses the JSON representation of the partitions // that is stored as data on the topic node in Zookeeper.
[ "parsePartitions", "parses", "the", "JSON", "representation", "of", "the", "partitions", "that", "is", "stored", "as", "data", "on", "the", "topic", "node", "in", "Zookeeper", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/topic_metadata.go#L125-L146
132,681
wvanbergen/kazoo-go
topic_metadata.go
marshalPartitions
func (t *Topic) marshalPartitions(partitions PartitionList) ([]byte, error) { tm := topicMetadata{Version: 1, Partitions: make(map[string][]int32, len(partitions))} for _, part := range partitions { tm.Partitions[fmt.Sprintf("%d", part.ID)] = part.Replicas } return json.Marshal(tm) }
go
func (t *Topic) marshalPartitions(partitions PartitionList) ([]byte, error) { tm := topicMetadata{Version: 1, Partitions: make(map[string][]int32, len(partitions))} for _, part := range partitions { tm.Partitions[fmt.Sprintf("%d", part.ID)] = part.Replicas } return json.Marshal(tm) }
[ "func", "(", "t", "*", "Topic", ")", "marshalPartitions", "(", "partitions", "PartitionList", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "tm", ":=", "topicMetadata", "{", "Version", ":", "1", ",", "Partitions", ":", "make", "(", "map", "[", ...
// marshalPartitions turns a PartitionList into the JSON representation // to be stored in Zookeeper.
[ "marshalPartitions", "turns", "a", "PartitionList", "into", "the", "JSON", "representation", "to", "be", "stored", "in", "Zookeeper", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/topic_metadata.go#L150-L156
132,682
wvanbergen/kazoo-go
topic_metadata.go
generatePartitionAssignments
func (t *Topic) generatePartitionAssignments(brokers []int32, partitionCount int, replicationFactor int) (PartitionList, error) { if partitionCount <= 0 { return nil, ErrInvalidPartitionCount } if replicationFactor <= 0 || len(brokers) < replicationFactor { return nil, ErrInvalidReplicationFactor } result := ...
go
func (t *Topic) generatePartitionAssignments(brokers []int32, partitionCount int, replicationFactor int) (PartitionList, error) { if partitionCount <= 0 { return nil, ErrInvalidPartitionCount } if replicationFactor <= 0 || len(brokers) < replicationFactor { return nil, ErrInvalidReplicationFactor } result := ...
[ "func", "(", "t", "*", "Topic", ")", "generatePartitionAssignments", "(", "brokers", "[", "]", "int32", ",", "partitionCount", "int", ",", "replicationFactor", "int", ")", "(", "PartitionList", ",", "error", ")", "{", "if", "partitionCount", "<=", "0", "{", ...
// generatePartitionAssignments creates a partition list for a topic. The primary replica for // each partition is assigned in a round-robin fashion starting at a random broker. // Additional replicas are assigned to subsequent brokers to ensure there is no overlap
[ "generatePartitionAssignments", "creates", "a", "partition", "list", "for", "a", "topic", ".", "The", "primary", "replica", "for", "each", "partition", "is", "assigned", "in", "a", "round", "-", "robin", "fashion", "starting", "at", "a", "random", "broker", "....
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/topic_metadata.go#L161-L188
132,683
wvanbergen/kazoo-go
topic_metadata.go
validatePartitionAssignments
func (t *Topic) validatePartitionAssignments(brokers []int32, assignment PartitionList) error { if len(assignment) == 0 { return ErrInvalidPartitionCount } // get the first replica count to compare against. Every partition should have the same. var replicaCount int for _, part := range assignment { replicaCou...
go
func (t *Topic) validatePartitionAssignments(brokers []int32, assignment PartitionList) error { if len(assignment) == 0 { return ErrInvalidPartitionCount } // get the first replica count to compare against. Every partition should have the same. var replicaCount int for _, part := range assignment { replicaCou...
[ "func", "(", "t", "*", "Topic", ")", "validatePartitionAssignments", "(", "brokers", "[", "]", "int32", ",", "assignment", "PartitionList", ")", "error", "{", "if", "len", "(", "assignment", ")", "==", "0", "{", "return", "ErrInvalidPartitionCount", "\n", "}...
// validatePartitionAssignments ensures that all partitions are assigned to valid brokers, // have the same number of replicas, and each replica is assigned to a unique broker
[ "validatePartitionAssignments", "ensures", "that", "all", "partitions", "are", "assigned", "to", "valid", "brokers", "have", "the", "same", "number", "of", "replicas", "and", "each", "replica", "is", "assigned", "to", "a", "unique", "broker" ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/topic_metadata.go#L192-L257
132,684
wvanbergen/kazoo-go
topic_metadata.go
Partition
func (t *Topic) Partition(id int32, replicas []int32) *Partition { return &Partition{ID: id, Replicas: replicas, topic: t} }
go
func (t *Topic) Partition(id int32, replicas []int32) *Partition { return &Partition{ID: id, Replicas: replicas, topic: t} }
[ "func", "(", "t", "*", "Topic", ")", "Partition", "(", "id", "int32", ",", "replicas", "[", "]", "int32", ")", "*", "Partition", "{", "return", "&", "Partition", "{", "ID", ":", "id", ",", "Replicas", ":", "replicas", ",", "topic", ":", "t", "}", ...
// Partition returns a Partition instance for the topic.
[ "Partition", "returns", "a", "Partition", "instance", "for", "the", "topic", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/topic_metadata.go#L260-L262
132,685
wvanbergen/kazoo-go
topic_metadata.go
configPath
func (t *Topic) configPath() string { return fmt.Sprintf("%s/config/topics/%s", t.kz.conf.Chroot, t.Name) }
go
func (t *Topic) configPath() string { return fmt.Sprintf("%s/config/topics/%s", t.kz.conf.Chroot, t.Name) }
[ "func", "(", "t", "*", "Topic", ")", "configPath", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "t", ".", "kz", ".", "conf", ".", "Chroot", ",", "t", ".", "Name", ")", "\n", "}" ]
// getConfigPath returns the zk node path for a topic's config
[ "getConfigPath", "returns", "the", "zk", "node", "path", "for", "a", "topic", "s", "config" ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/topic_metadata.go#L270-L272
132,686
wvanbergen/kazoo-go
topic_metadata.go
parseConfig
func (t *Topic) parseConfig(data []byte) (map[string]string, error) { var cfg topicConfig if err := json.Unmarshal(data, &cfg); err != nil { return nil, err } return cfg.ConfigMap, nil }
go
func (t *Topic) parseConfig(data []byte) (map[string]string, error) { var cfg topicConfig if err := json.Unmarshal(data, &cfg); err != nil { return nil, err } return cfg.ConfigMap, nil }
[ "func", "(", "t", "*", "Topic", ")", "parseConfig", "(", "data", "[", "]", "byte", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "var", "cfg", "topicConfig", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "data", ...
// parseConfig parses the json representation of a topic config // and returns the configuration values
[ "parseConfig", "parses", "the", "json", "representation", "of", "a", "topic", "config", "and", "returns", "the", "configuration", "values" ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/topic_metadata.go#L276-L282
132,687
wvanbergen/kazoo-go
topic_metadata.go
marshalConfig
func (t *Topic) marshalConfig(data map[string]string) ([]byte, error) { cfg := topicConfig{Version: 1, ConfigMap: data} if cfg.ConfigMap == nil { cfg.ConfigMap = make(map[string]string) } return json.Marshal(&cfg) }
go
func (t *Topic) marshalConfig(data map[string]string) ([]byte, error) { cfg := topicConfig{Version: 1, ConfigMap: data} if cfg.ConfigMap == nil { cfg.ConfigMap = make(map[string]string) } return json.Marshal(&cfg) }
[ "func", "(", "t", "*", "Topic", ")", "marshalConfig", "(", "data", "map", "[", "string", "]", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "cfg", ":=", "topicConfig", "{", "Version", ":", "1", ",", "ConfigMap", ":", "data", "}", ...
// marshalConfig turns a config map into the json representation // needed for Zookeeper
[ "marshalConfig", "turns", "a", "config", "map", "into", "the", "json", "representation", "needed", "for", "Zookeeper" ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/topic_metadata.go#L286-L292
132,688
wvanbergen/kazoo-go
topic_metadata.go
Config
func (t *Topic) Config() (map[string]string, error) { value, _, err := t.kz.conn.Get(t.configPath()) if err != nil { return nil, err } return t.parseConfig(value) }
go
func (t *Topic) Config() (map[string]string, error) { value, _, err := t.kz.conn.Get(t.configPath()) if err != nil { return nil, err } return t.parseConfig(value) }
[ "func", "(", "t", "*", "Topic", ")", "Config", "(", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "value", ",", "_", ",", "err", ":=", "t", ".", "kz", ".", "conn", ".", "Get", "(", "t", ".", "configPath", "(", ")", ...
// Config returns topic-level configuration settings as a map.
[ "Config", "returns", "topic", "-", "level", "configuration", "settings", "as", "a", "map", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/topic_metadata.go#L295-L302
132,689
wvanbergen/kazoo-go
topic_metadata.go
Leader
func (p *Partition) Leader() (int32, error) { if state, err := p.state(); err != nil { return -1, err } else { return state.Leader, nil } }
go
func (p *Partition) Leader() (int32, error) { if state, err := p.state(); err != nil { return -1, err } else { return state.Leader, nil } }
[ "func", "(", "p", "*", "Partition", ")", "Leader", "(", ")", "(", "int32", ",", "error", ")", "{", "if", "state", ",", "err", ":=", "p", ".", "state", "(", ")", ";", "err", "!=", "nil", "{", "return", "-", "1", ",", "err", "\n", "}", "else", ...
// Leader returns the broker ID of the broker that is currently the leader for the partition.
[ "Leader", "returns", "the", "broker", "ID", "of", "the", "broker", "that", "is", "currently", "the", "leader", "for", "the", "partition", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/topic_metadata.go#L324-L330
132,690
wvanbergen/kazoo-go
topic_metadata.go
ISR
func (p *Partition) ISR() ([]int32, error) { if state, err := p.state(); err != nil { return nil, err } else { return state.ISR, nil } }
go
func (p *Partition) ISR() ([]int32, error) { if state, err := p.state(); err != nil { return nil, err } else { return state.ISR, nil } }
[ "func", "(", "p", "*", "Partition", ")", "ISR", "(", ")", "(", "[", "]", "int32", ",", "error", ")", "{", "if", "state", ",", "err", ":=", "p", ".", "state", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "e...
// ISR returns the broker IDs of the current in-sync replica set for the partition
[ "ISR", "returns", "the", "broker", "IDs", "of", "the", "current", "in", "-", "sync", "replica", "set", "for", "the", "partition" ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/topic_metadata.go#L333-L339
132,691
wvanbergen/kazoo-go
topic_metadata.go
state
func (p *Partition) state() (partitionState, error) { var state partitionState node := fmt.Sprintf("%s/brokers/topics/%s/partitions/%d/state", p.topic.kz.conf.Chroot, p.topic.Name, p.ID) value, _, err := p.topic.kz.conn.Get(node) if err != nil { return state, err } if err := json.Unmarshal(value, &state); err ...
go
func (p *Partition) state() (partitionState, error) { var state partitionState node := fmt.Sprintf("%s/brokers/topics/%s/partitions/%d/state", p.topic.kz.conf.Chroot, p.topic.Name, p.ID) value, _, err := p.topic.kz.conn.Get(node) if err != nil { return state, err } if err := json.Unmarshal(value, &state); err ...
[ "func", "(", "p", "*", "Partition", ")", "state", "(", ")", "(", "partitionState", ",", "error", ")", "{", "var", "state", "partitionState", "\n", "node", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "p", ".", "topic", ".", "kz", ".", "conf",...
// state retrieves and parses the partition State
[ "state", "retrieves", "and", "parses", "the", "partition", "State" ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/topic_metadata.go#L365-L378
132,692
wvanbergen/kazoo-go
topic_metadata.go
Find
func (tl TopicList) Find(name string) *Topic { for _, topic := range tl { if topic.Name == name { return topic } } return nil }
go
func (tl TopicList) Find(name string) *Topic { for _, topic := range tl { if topic.Name == name { return topic } } return nil }
[ "func", "(", "tl", "TopicList", ")", "Find", "(", "name", "string", ")", "*", "Topic", "{", "for", "_", ",", "topic", ":=", "range", "tl", "{", "if", "topic", ".", "Name", "==", "name", "{", "return", "topic", "\n", "}", "\n", "}", "\n", "return"...
// Find returns the topic with the given name if it exists in the topic list, // and will return `nil` otherwise.
[ "Find", "returns", "the", "topic", "with", "the", "given", "name", "if", "it", "exists", "in", "the", "topic", "list", "and", "will", "return", "nil", "otherwise", "." ]
f72d8611297a7cf105da904c04198ad701a60101
https://github.com/wvanbergen/kazoo-go/blob/f72d8611297a7cf105da904c04198ad701a60101/topic_metadata.go#L382-L389
132,693
go-chef/chef
reader.go
JSONReader
func JSONReader(v interface{}) (r io.Reader, err error) { buf := new(bytes.Buffer) err = json.NewEncoder(buf).Encode(v) r = bytes.NewReader(buf.Bytes()) return }
go
func JSONReader(v interface{}) (r io.Reader, err error) { buf := new(bytes.Buffer) err = json.NewEncoder(buf).Encode(v) r = bytes.NewReader(buf.Bytes()) return }
[ "func", "JSONReader", "(", "v", "interface", "{", "}", ")", "(", "r", "io", ".", "Reader", ",", "err", "error", ")", "{", "buf", ":=", "new", "(", "bytes", ".", "Buffer", ")", "\n", "err", "=", "json", ".", "NewEncoder", "(", "buf", ")", ".", "...
// JSONReader handles arbitrary types and synthesizes a streaming encoder for them.
[ "JSONReader", "handles", "arbitrary", "types", "and", "synthesizes", "a", "streaming", "encoder", "for", "them", "." ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/reader.go#L10-L15
132,694
go-chef/chef
authentication.go
privateEncrypt
func privateEncrypt(key *rsa.PrivateKey, data []byte) (enc []byte, err error) { k := (key.N.BitLen() + 7) / 8 tLen := len(data) // rfc2313, section 8: // The length of the data D shall not be more than k-11 octets if tLen > k-11 { err = errors.New("Data too long") return } em := make([]byte, k) em[1] = 1 ...
go
func privateEncrypt(key *rsa.PrivateKey, data []byte) (enc []byte, err error) { k := (key.N.BitLen() + 7) / 8 tLen := len(data) // rfc2313, section 8: // The length of the data D shall not be more than k-11 octets if tLen > k-11 { err = errors.New("Data too long") return } em := make([]byte, k) em[1] = 1 ...
[ "func", "privateEncrypt", "(", "key", "*", "rsa", ".", "PrivateKey", ",", "data", "[", "]", "byte", ")", "(", "enc", "[", "]", "byte", ",", "err", "error", ")", "{", "k", ":=", "(", "key", ".", "N", ".", "BitLen", "(", ")", "+", "7", ")", "/"...
// privateEncrypt implements OpenSSL's RSA_private_encrypt function
[ "privateEncrypt", "implements", "OpenSSL", "s", "RSA_private_encrypt", "function" ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/authentication.go#L23-L82
132,695
go-chef/chef
authentication.go
HashStr
func HashStr(toHash string) string { h := sha1.New() io.WriteString(h, toHash) hashed := base64.StdEncoding.EncodeToString(h.Sum(nil)) return hashed }
go
func HashStr(toHash string) string { h := sha1.New() io.WriteString(h, toHash) hashed := base64.StdEncoding.EncodeToString(h.Sum(nil)) return hashed }
[ "func", "HashStr", "(", "toHash", "string", ")", "string", "{", "h", ":=", "sha1", ".", "New", "(", ")", "\n", "io", ".", "WriteString", "(", "h", ",", "toHash", ")", "\n", "hashed", ":=", "base64", ".", "StdEncoding", ".", "EncodeToString", "(", "h"...
// HashStr returns the base64 encoded SHA1 sum of the toHash string
[ "HashStr", "returns", "the", "base64", "encoded", "SHA1", "sum", "of", "the", "toHash", "string" ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/authentication.go#L85-L90
132,696
go-chef/chef
authentication.go
Base64BlockEncode
func Base64BlockEncode(content []byte, limit int) []string { resultString := base64.StdEncoding.EncodeToString(content) var resultSlice []string index := 0 var maxLengthPerSlice int // No limit if limit == 0 { maxLengthPerSlice = len(resultString) } else { maxLengthPerSlice = limit } // Iterate through...
go
func Base64BlockEncode(content []byte, limit int) []string { resultString := base64.StdEncoding.EncodeToString(content) var resultSlice []string index := 0 var maxLengthPerSlice int // No limit if limit == 0 { maxLengthPerSlice = len(resultString) } else { maxLengthPerSlice = limit } // Iterate through...
[ "func", "Base64BlockEncode", "(", "content", "[", "]", "byte", ",", "limit", "int", ")", "[", "]", "string", "{", "resultString", ":=", "base64", ".", "StdEncoding", ".", "EncodeToString", "(", "content", ")", "\n", "var", "resultSlice", "[", "]", "string"...
// Base64BlockEncode takes a byte slice and breaks it up into a // slice of base64 encoded strings
[ "Base64BlockEncode", "takes", "a", "byte", "slice", "and", "breaks", "it", "up", "into", "a", "slice", "of", "base64", "encoded", "strings" ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/authentication.go#L94-L122
132,697
go-chef/chef
examples/sandboxes/sandboxes.go
random_data
func random_data(size int) (b []byte) { b = make([]byte, size) rand.Read(b) return }
go
func random_data(size int) (b []byte) { b = make([]byte, size) rand.Read(b) return }
[ "func", "random_data", "(", "size", "int", ")", "(", "b", "[", "]", "byte", ")", "{", "b", "=", "make", "(", "[", "]", "byte", ",", "size", ")", "\n", "rand", ".", "Read", "(", "b", ")", "\n", "return", "\n", "}" ]
//random_data makes random byte slice for building junk sandbox data
[ "random_data", "makes", "random", "byte", "slice", "for", "building", "junk", "sandbox", "data" ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/examples/sandboxes/sandboxes.go#L18-L22
132,698
go-chef/chef
client.go
String
func (c ApiClientListResult) String() (out string) { for k, v := range c { out += fmt.Sprintf("%s => %s\n", k, v) } return out }
go
func (c ApiClientListResult) String() (out string) { for k, v := range c { out += fmt.Sprintf("%s => %s\n", k, v) } return out }
[ "func", "(", "c", "ApiClientListResult", ")", "String", "(", ")", "(", "out", "string", ")", "{", "for", "k", ",", "v", ":=", "range", "c", "{", "out", "+=", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "k", ",", "v", ")", "\n", "}", "...
// String makes ApiClientListResult implement the string result
[ "String", "makes", "ApiClientListResult", "implement", "the", "string", "result" ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/client.go#L50-L55
132,699
go-chef/chef
node.go
NewNode
func NewNode(name string) (node Node) { node = Node{ Name: name, Environment: "_default", ChefType: "node", JsonClass: "Chef::Node", } return }
go
func NewNode(name string) (node Node) { node = Node{ Name: name, Environment: "_default", ChefType: "node", JsonClass: "Chef::Node", } return }
[ "func", "NewNode", "(", "name", "string", ")", "(", "node", "Node", ")", "{", "node", "=", "Node", "{", "Name", ":", "name", ",", "Environment", ":", "\"", "\"", ",", "ChefType", ":", "\"", "\"", ",", "JsonClass", ":", "\"", "\"", ",", "}", "\n",...
// NewNode is the Node constructor method
[ "NewNode", "is", "the", "Node", "constructor", "method" ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/node.go#L29-L37