id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
16,100
paypal/gorealis
gen-go/apache/aurora/auroraAPI.go
GetRoleSummary
func (p *ReadOnlySchedulerClient) GetRoleSummary(ctx context.Context) (r *Response, err error) { var _args52 ReadOnlySchedulerGetRoleSummaryArgs var _result53 ReadOnlySchedulerGetRoleSummaryResult if err = p.Client_().Call(ctx, "getRoleSummary", &_args52, &_result53); err != nil { return } return _result53.GetSuccess(), nil }
go
func (p *ReadOnlySchedulerClient) GetRoleSummary(ctx context.Context) (r *Response, err error) { var _args52 ReadOnlySchedulerGetRoleSummaryArgs var _result53 ReadOnlySchedulerGetRoleSummaryResult if err = p.Client_().Call(ctx, "getRoleSummary", &_args52, &_result53); err != nil { return } return _result53.GetSuccess(), nil }
[ "func", "(", "p", "*", "ReadOnlySchedulerClient", ")", "GetRoleSummary", "(", "ctx", "context", ".", "Context", ")", "(", "r", "*", "Response", ",", "err", "error", ")", "{", "var", "_args52", "ReadOnlySchedulerGetRoleSummaryArgs", "\n", "var", "_result53", "R...
// Returns a summary of the jobs grouped by role.
[ "Returns", "a", "summary", "of", "the", "jobs", "grouped", "by", "role", "." ]
e16e390afe057e029334bbbac63942323d4ea50d
https://github.com/paypal/gorealis/blob/e16e390afe057e029334bbbac63942323d4ea50d/gen-go/apache/aurora/auroraAPI.go#L16850-L16857
16,101
paypal/gorealis
gen-go/apache/aurora/auroraAPI.go
GetTierConfigs
func (p *ReadOnlySchedulerClient) GetTierConfigs(ctx context.Context) (r *Response, err error) { var _args76 ReadOnlySchedulerGetTierConfigsArgs var _result77 ReadOnlySchedulerGetTierConfigsResult if err = p.Client_().Call(ctx, "getTierConfigs", &_args76, &_result77); err != nil { return } return _result77.GetSuccess(), nil }
go
func (p *ReadOnlySchedulerClient) GetTierConfigs(ctx context.Context) (r *Response, err error) { var _args76 ReadOnlySchedulerGetTierConfigsArgs var _result77 ReadOnlySchedulerGetTierConfigsResult if err = p.Client_().Call(ctx, "getTierConfigs", &_args76, &_result77); err != nil { return } return _result77.GetSuccess(), nil }
[ "func", "(", "p", "*", "ReadOnlySchedulerClient", ")", "GetTierConfigs", "(", "ctx", "context", ".", "Context", ")", "(", "r", "*", "Response", ",", "err", "error", ")", "{", "var", "_args76", "ReadOnlySchedulerGetTierConfigsArgs", "\n", "var", "_result77", "R...
// Gets tier configurations.
[ "Gets", "tier", "configurations", "." ]
e16e390afe057e029334bbbac63942323d4ea50d
https://github.com/paypal/gorealis/blob/e16e390afe057e029334bbbac63942323d4ea50d/gen-go/apache/aurora/auroraAPI.go#L17017-L17024
16,102
paypal/gorealis
gen-go/apache/aurora/auroraAPI.go
PerformBackup
func (p *AuroraAdminClient) PerformBackup(ctx context.Context) (r *Response, err error) { var _args320 AuroraAdminPerformBackupArgs var _result321 AuroraAdminPerformBackupResult if err = p.Client_().Call(ctx, "performBackup", &_args320, &_result321); err != nil { return } return _result321.GetSuccess(), nil }
go
func (p *AuroraAdminClient) PerformBackup(ctx context.Context) (r *Response, err error) { var _args320 AuroraAdminPerformBackupArgs var _result321 AuroraAdminPerformBackupResult if err = p.Client_().Call(ctx, "performBackup", &_args320, &_result321); err != nil { return } return _result321.GetSuccess(), nil }
[ "func", "(", "p", "*", "AuroraAdminClient", ")", "PerformBackup", "(", "ctx", "context", ".", "Context", ")", "(", "r", "*", "Response", ",", "err", "error", ")", "{", "var", "_args320", "AuroraAdminPerformBackupArgs", "\n", "var", "_result321", "AuroraAdminPe...
// Immediately writes a storage snapshot to disk.
[ "Immediately", "writes", "a", "storage", "snapshot", "to", "disk", "." ]
e16e390afe057e029334bbbac63942323d4ea50d
https://github.com/paypal/gorealis/blob/e16e390afe057e029334bbbac63942323d4ea50d/gen-go/apache/aurora/auroraAPI.go#L24499-L24506
16,103
paypal/gorealis
gen-go/apache/aurora/auroraAPI.go
ListBackups
func (p *AuroraAdminClient) ListBackups(ctx context.Context) (r *Response, err error) { var _args322 AuroraAdminListBackupsArgs var _result323 AuroraAdminListBackupsResult if err = p.Client_().Call(ctx, "listBackups", &_args322, &_result323); err != nil { return } return _result323.GetSuccess(), nil }
go
func (p *AuroraAdminClient) ListBackups(ctx context.Context) (r *Response, err error) { var _args322 AuroraAdminListBackupsArgs var _result323 AuroraAdminListBackupsResult if err = p.Client_().Call(ctx, "listBackups", &_args322, &_result323); err != nil { return } return _result323.GetSuccess(), nil }
[ "func", "(", "p", "*", "AuroraAdminClient", ")", "ListBackups", "(", "ctx", "context", ".", "Context", ")", "(", "r", "*", "Response", ",", "err", "error", ")", "{", "var", "_args322", "AuroraAdminListBackupsArgs", "\n", "var", "_result323", "AuroraAdminListBa...
// Lists backups that are available for recovery.
[ "Lists", "backups", "that", "are", "available", "for", "recovery", "." ]
e16e390afe057e029334bbbac63942323d4ea50d
https://github.com/paypal/gorealis/blob/e16e390afe057e029334bbbac63942323d4ea50d/gen-go/apache/aurora/auroraAPI.go#L24509-L24516
16,104
paypal/gorealis
gen-go/apache/aurora/auroraAPI.go
CommitRecovery
func (p *AuroraAdminClient) CommitRecovery(ctx context.Context) (r *Response, err error) { var _args330 AuroraAdminCommitRecoveryArgs var _result331 AuroraAdminCommitRecoveryResult if err = p.Client_().Call(ctx, "commitRecovery", &_args330, &_result331); err != nil { return } return _result331.GetSuccess(), nil }
go
func (p *AuroraAdminClient) CommitRecovery(ctx context.Context) (r *Response, err error) { var _args330 AuroraAdminCommitRecoveryArgs var _result331 AuroraAdminCommitRecoveryResult if err = p.Client_().Call(ctx, "commitRecovery", &_args330, &_result331); err != nil { return } return _result331.GetSuccess(), nil }
[ "func", "(", "p", "*", "AuroraAdminClient", ")", "CommitRecovery", "(", "ctx", "context", ".", "Context", ")", "(", "r", "*", "Response", ",", "err", "error", ")", "{", "var", "_args330", "AuroraAdminCommitRecoveryArgs", "\n", "var", "_result331", "AuroraAdmin...
// Commits a staged recovery, completely replacing the previous storage state.
[ "Commits", "a", "staged", "recovery", "completely", "replacing", "the", "previous", "storage", "state", "." ]
e16e390afe057e029334bbbac63942323d4ea50d
https://github.com/paypal/gorealis/blob/e16e390afe057e029334bbbac63942323d4ea50d/gen-go/apache/aurora/auroraAPI.go#L24561-L24568
16,105
paypal/gorealis
gen-go/apache/aurora/auroraAPI.go
Snapshot
func (p *AuroraAdminClient) Snapshot(ctx context.Context) (r *Response, err error) { var _args344 AuroraAdminSnapshotArgs var _result345 AuroraAdminSnapshotResult if err = p.Client_().Call(ctx, "snapshot", &_args344, &_result345); err != nil { return } return _result345.GetSuccess(), nil }
go
func (p *AuroraAdminClient) Snapshot(ctx context.Context) (r *Response, err error) { var _args344 AuroraAdminSnapshotArgs var _result345 AuroraAdminSnapshotResult if err = p.Client_().Call(ctx, "snapshot", &_args344, &_result345); err != nil { return } return _result345.GetSuccess(), nil }
[ "func", "(", "p", "*", "AuroraAdminClient", ")", "Snapshot", "(", "ctx", "context", ".", "Context", ")", "(", "r", "*", "Response", ",", "err", "error", ")", "{", "var", "_args344", "AuroraAdminSnapshotArgs", "\n", "var", "_result345", "AuroraAdminSnapshotResu...
// Start a storage snapshot and block until it completes.
[ "Start", "a", "storage", "snapshot", "and", "block", "until", "it", "completes", "." ]
e16e390afe057e029334bbbac63942323d4ea50d
https://github.com/paypal/gorealis/blob/e16e390afe057e029334bbbac63942323d4ea50d/gen-go/apache/aurora/auroraAPI.go#L24657-L24664
16,106
paypal/gorealis
gen-go/apache/aurora/auroraAPI.go
TriggerImplicitTaskReconciliation
func (p *AuroraAdminClient) TriggerImplicitTaskReconciliation(ctx context.Context) (r *Response, err error) { var _args348 AuroraAdminTriggerImplicitTaskReconciliationArgs var _result349 AuroraAdminTriggerImplicitTaskReconciliationResult if err = p.Client_().Call(ctx, "triggerImplicitTaskReconciliation", &_args348, &_result349); err != nil { return } return _result349.GetSuccess(), nil }
go
func (p *AuroraAdminClient) TriggerImplicitTaskReconciliation(ctx context.Context) (r *Response, err error) { var _args348 AuroraAdminTriggerImplicitTaskReconciliationArgs var _result349 AuroraAdminTriggerImplicitTaskReconciliationResult if err = p.Client_().Call(ctx, "triggerImplicitTaskReconciliation", &_args348, &_result349); err != nil { return } return _result349.GetSuccess(), nil }
[ "func", "(", "p", "*", "AuroraAdminClient", ")", "TriggerImplicitTaskReconciliation", "(", "ctx", "context", ".", "Context", ")", "(", "r", "*", "Response", ",", "err", "error", ")", "{", "var", "_args348", "AuroraAdminTriggerImplicitTaskReconciliationArgs", "\n", ...
// Tell scheduler to trigger an implicit task reconciliation.
[ "Tell", "scheduler", "to", "trigger", "an", "implicit", "task", "reconciliation", "." ]
e16e390afe057e029334bbbac63942323d4ea50d
https://github.com/paypal/gorealis/blob/e16e390afe057e029334bbbac63942323d4ea50d/gen-go/apache/aurora/auroraAPI.go#L24681-L24688
16,107
paypal/gorealis
response/response.go
JobUpdateKey
func JobUpdateKey(resp *aurora.Response) *aurora.JobUpdateKey { return resp.GetResult_().GetStartJobUpdateResult_().GetKey() }
go
func JobUpdateKey(resp *aurora.Response) *aurora.JobUpdateKey { return resp.GetResult_().GetStartJobUpdateResult_().GetKey() }
[ "func", "JobUpdateKey", "(", "resp", "*", "aurora", ".", "Response", ")", "*", "aurora", ".", "JobUpdateKey", "{", "return", "resp", ".", "GetResult_", "(", ")", ".", "GetStartJobUpdateResult_", "(", ")", ".", "GetKey", "(", ")", "\n", "}" ]
// Get key from a response created by a StartJobUpdate call
[ "Get", "key", "from", "a", "response", "created", "by", "a", "StartJobUpdate", "call" ]
e16e390afe057e029334bbbac63942323d4ea50d
https://github.com/paypal/gorealis/blob/e16e390afe057e029334bbbac63942323d4ea50d/response/response.go#L26-L28
16,108
wantedly/gorm-zap
logger.go
Println
func (l *Logger) Println(values []interface{}) { l.zap.Info("gorm", createLog(values).toZapFields()...) }
go
func (l *Logger) Println(values []interface{}) { l.zap.Info("gorm", createLog(values).toZapFields()...) }
[ "func", "(", "l", "*", "Logger", ")", "Println", "(", "values", "[", "]", "interface", "{", "}", ")", "{", "l", ".", "zap", ".", "Info", "(", "\"", "\"", ",", "createLog", "(", "values", ")", ".", "toZapFields", "(", ")", "...", ")", "\n", "}" ...
// Println format & print log
[ "Println", "format", "&", "print", "log" ]
372d3517a8765add76f351e583b651f841366859
https://github.com/wantedly/gorm-zap/blob/372d3517a8765add76f351e583b651f841366859/logger.go#L25-L27
16,109
chrj/smtpd
smtpd.go
ListenAndServe
func (srv *Server) ListenAndServe(addr string) error { srv.configureDefaults() l, err := net.Listen("tcp", addr) if err != nil { return err } return srv.Serve(l) }
go
func (srv *Server) ListenAndServe(addr string) error { srv.configureDefaults() l, err := net.Listen("tcp", addr) if err != nil { return err } return srv.Serve(l) }
[ "func", "(", "srv", "*", "Server", ")", "ListenAndServe", "(", "addr", "string", ")", "error", "{", "srv", ".", "configureDefaults", "(", ")", "\n\n", "l", ",", "err", ":=", "net", ".", "Listen", "(", "\"", "\"", ",", "addr", ")", "\n", "if", "err"...
// ListenAndServe starts the SMTP server and listens on the address provided
[ "ListenAndServe", "starts", "the", "SMTP", "server", "and", "listens", "on", "the", "address", "provided" ]
9c93a62f1a3d83fd7931846d8276fbccdbc7a96a
https://github.com/chrj/smtpd/blob/9c93a62f1a3d83fd7931846d8276fbccdbc7a96a/smtpd.go#L136-L146
16,110
chrj/smtpd
smtpd.go
Serve
func (srv *Server) Serve(l net.Listener) error { srv.configureDefaults() defer l.Close() var limiter chan struct{} if srv.MaxConnections > 0 { limiter = make(chan struct{}, srv.MaxConnections) } else { limiter = nil } for { conn, e := l.Accept() if e != nil { if ne, ok := e.(net.Error); ok && ne.Temporary() { time.Sleep(time.Second) continue } return e } session := srv.newSession(conn) if limiter != nil { go func() { select { case limiter <- struct{}{}: session.serve() <-limiter default: session.reject() } }() } else { go session.serve() } } }
go
func (srv *Server) Serve(l net.Listener) error { srv.configureDefaults() defer l.Close() var limiter chan struct{} if srv.MaxConnections > 0 { limiter = make(chan struct{}, srv.MaxConnections) } else { limiter = nil } for { conn, e := l.Accept() if e != nil { if ne, ok := e.(net.Error); ok && ne.Temporary() { time.Sleep(time.Second) continue } return e } session := srv.newSession(conn) if limiter != nil { go func() { select { case limiter <- struct{}{}: session.serve() <-limiter default: session.reject() } }() } else { go session.serve() } } }
[ "func", "(", "srv", "*", "Server", ")", "Serve", "(", "l", "net", ".", "Listener", ")", "error", "{", "srv", ".", "configureDefaults", "(", ")", "\n\n", "defer", "l", ".", "Close", "(", ")", "\n\n", "var", "limiter", "chan", "struct", "{", "}", "\n...
// Serve starts the SMTP server and listens on the Listener provided
[ "Serve", "starts", "the", "SMTP", "server", "and", "listens", "on", "the", "Listener", "provided" ]
9c93a62f1a3d83fd7931846d8276fbccdbc7a96a
https://github.com/chrj/smtpd/blob/9c93a62f1a3d83fd7931846d8276fbccdbc7a96a/smtpd.go#L149-L192
16,111
chrj/smtpd
wrap.go
wrap
func wrap(sl []byte) []byte { length := 0 for i := 0; i < len(sl); i++ { if length > 76 && sl[i] == ' ' { sl = append(sl, 0, 0) copy(sl[i+2:], sl[i:]) sl[i] = '\r' sl[i+1] = '\n' sl[i+2] = '\t' i += 2 length = 0 } if sl[i] == '\n' { length = 0 } length++ } return sl }
go
func wrap(sl []byte) []byte { length := 0 for i := 0; i < len(sl); i++ { if length > 76 && sl[i] == ' ' { sl = append(sl, 0, 0) copy(sl[i+2:], sl[i:]) sl[i] = '\r' sl[i+1] = '\n' sl[i+2] = '\t' i += 2 length = 0 } if sl[i] == '\n' { length = 0 } length++ } return sl }
[ "func", "wrap", "(", "sl", "[", "]", "byte", ")", "[", "]", "byte", "{", "length", ":=", "0", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "sl", ")", ";", "i", "++", "{", "if", "length", ">", "76", "&&", "sl", "[", "i", "]", ...
// Wrap a byte slice paragraph for use in SMTP header
[ "Wrap", "a", "byte", "slice", "paragraph", "for", "use", "in", "SMTP", "header" ]
9c93a62f1a3d83fd7931846d8276fbccdbc7a96a
https://github.com/chrj/smtpd/blob/9c93a62f1a3d83fd7931846d8276fbccdbc7a96a/wrap.go#L4-L22
16,112
chrj/smtpd
envelope.go
AddReceivedLine
func (env *Envelope) AddReceivedLine(peer Peer) { tlsDetails := "" tlsVersions := map[uint16]string{ tls.VersionSSL30: "SSL3.0", tls.VersionTLS10: "TLS1.0", tls.VersionTLS11: "TLS1.1", tls.VersionTLS12: "TLS1.2", } tlsCiphers := map[uint16]string{ tls.TLS_RSA_WITH_RC4_128_SHA: "TLS_RSA_WITH_RC4_128_SHA", tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA: "TLS_RSA_WITH_3DES_EDE_CBC_SHA", tls.TLS_RSA_WITH_AES_128_CBC_SHA: "TLS_RSA_WITH_AES_128_CBC_SHA", tls.TLS_RSA_WITH_AES_256_CBC_SHA: "TLS_RSA_WITH_AES_256_CBC_SHA", tls.TLS_RSA_WITH_AES_128_CBC_SHA256: "TLS_RSA_WITH_AES_128_CBC_SHA256", tls.TLS_RSA_WITH_AES_128_GCM_SHA256: "TLS_RSA_WITH_AES_128_GCM_SHA256", tls.TLS_RSA_WITH_AES_256_GCM_SHA384: "TLS_RSA_WITH_AES_256_GCM_SHA384", tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA: "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA", tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA: "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA: "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA: "TLS_ECDHE_RSA_WITH_RC4_128_SHA", tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA: "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA", tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA: "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA: "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256: "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256: "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256: "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256: "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384: "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384: "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305: "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305", tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305: "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305", tls.TLS_FALLBACK_SCSV: "TLS_FALLBACK_SCSV", } if peer.TLS != nil { version := "unknown" if val, ok := tlsVersions[peer.TLS.Version]; ok { version = val } cipher := fmt.Sprintf("0x%x", peer.TLS.CipherSuite) if val, ok := tlsCiphers[peer.TLS.CipherSuite]; ok { cipher = val } tlsDetails = fmt.Sprintf( "\r\n\t(version=%s cipher=%s);", version, cipher, ) } peerIP := "" if addr, ok := peer.Addr.(*net.TCPAddr); ok { peerIP = addr.IP.String() } line := wrap([]byte(fmt.Sprintf( "Received: from %s ([%s]) by %s with %s;%s\r\n\t%s\r\n", peer.HeloName, peerIP, peer.ServerName, peer.Protocol, tlsDetails, time.Now().Format("Mon, 02 Jan 2006 15:04:05 -0700 (MST)"), ))) env.Data = append(env.Data, line...) // Move the new Received line up front copy(env.Data[len(line):], env.Data[0:len(env.Data)-len(line)]) copy(env.Data, line) }
go
func (env *Envelope) AddReceivedLine(peer Peer) { tlsDetails := "" tlsVersions := map[uint16]string{ tls.VersionSSL30: "SSL3.0", tls.VersionTLS10: "TLS1.0", tls.VersionTLS11: "TLS1.1", tls.VersionTLS12: "TLS1.2", } tlsCiphers := map[uint16]string{ tls.TLS_RSA_WITH_RC4_128_SHA: "TLS_RSA_WITH_RC4_128_SHA", tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA: "TLS_RSA_WITH_3DES_EDE_CBC_SHA", tls.TLS_RSA_WITH_AES_128_CBC_SHA: "TLS_RSA_WITH_AES_128_CBC_SHA", tls.TLS_RSA_WITH_AES_256_CBC_SHA: "TLS_RSA_WITH_AES_256_CBC_SHA", tls.TLS_RSA_WITH_AES_128_CBC_SHA256: "TLS_RSA_WITH_AES_128_CBC_SHA256", tls.TLS_RSA_WITH_AES_128_GCM_SHA256: "TLS_RSA_WITH_AES_128_GCM_SHA256", tls.TLS_RSA_WITH_AES_256_GCM_SHA384: "TLS_RSA_WITH_AES_256_GCM_SHA384", tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA: "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA", tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA: "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA: "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA: "TLS_ECDHE_RSA_WITH_RC4_128_SHA", tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA: "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA", tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA: "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA: "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256: "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256: "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256: "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256: "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384: "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384: "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305: "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305", tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305: "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305", tls.TLS_FALLBACK_SCSV: "TLS_FALLBACK_SCSV", } if peer.TLS != nil { version := "unknown" if val, ok := tlsVersions[peer.TLS.Version]; ok { version = val } cipher := fmt.Sprintf("0x%x", peer.TLS.CipherSuite) if val, ok := tlsCiphers[peer.TLS.CipherSuite]; ok { cipher = val } tlsDetails = fmt.Sprintf( "\r\n\t(version=%s cipher=%s);", version, cipher, ) } peerIP := "" if addr, ok := peer.Addr.(*net.TCPAddr); ok { peerIP = addr.IP.String() } line := wrap([]byte(fmt.Sprintf( "Received: from %s ([%s]) by %s with %s;%s\r\n\t%s\r\n", peer.HeloName, peerIP, peer.ServerName, peer.Protocol, tlsDetails, time.Now().Format("Mon, 02 Jan 2006 15:04:05 -0700 (MST)"), ))) env.Data = append(env.Data, line...) // Move the new Received line up front copy(env.Data[len(line):], env.Data[0:len(env.Data)-len(line)]) copy(env.Data, line) }
[ "func", "(", "env", "*", "Envelope", ")", "AddReceivedLine", "(", "peer", "Peer", ")", "{", "tlsDetails", ":=", "\"", "\"", "\n\n", "tlsVersions", ":=", "map", "[", "uint16", "]", "string", "{", "tls", ".", "VersionSSL30", ":", "\"", "\"", ",", "tls", ...
// AddReceivedLine prepends a Received header to the Data
[ "AddReceivedLine", "prepends", "a", "Received", "header", "to", "the", "Data" ]
9c93a62f1a3d83fd7931846d8276fbccdbc7a96a
https://github.com/chrj/smtpd/blob/9c93a62f1a3d83fd7931846d8276fbccdbc7a96a/envelope.go#L18-L97
16,113
tj/go-kinesis
kinesis.go
New
func New(config Config) *Producer { config.defaults() return &Producer{ Config: config, records: make(chan *k.PutRecordsRequestEntry, config.BacklogSize), done: make(chan struct{}), } }
go
func New(config Config) *Producer { config.defaults() return &Producer{ Config: config, records: make(chan *k.PutRecordsRequestEntry, config.BacklogSize), done: make(chan struct{}), } }
[ "func", "New", "(", "config", "Config", ")", "*", "Producer", "{", "config", ".", "defaults", "(", ")", "\n", "return", "&", "Producer", "{", "Config", ":", "config", ",", "records", ":", "make", "(", "chan", "*", "k", ".", "PutRecordsRequestEntry", ",...
// New producer with the given config.
[ "New", "producer", "with", "the", "given", "config", "." ]
08b17f58cb1b2ace14a61c0619a6bf2e2245ccd6
https://github.com/tj/go-kinesis/blob/08b17f58cb1b2ace14a61c0619a6bf2e2245ccd6/kinesis.go#L31-L38
16,114
tj/go-kinesis
kinesis.go
Put
func (p *Producer) Put(data []byte, partitionKey string) error { if len(data) > maxRecordSize { return ErrRecordSizeExceeded } p.records <- &k.PutRecordsRequestEntry{ Data: data, PartitionKey: &partitionKey, } return nil }
go
func (p *Producer) Put(data []byte, partitionKey string) error { if len(data) > maxRecordSize { return ErrRecordSizeExceeded } p.records <- &k.PutRecordsRequestEntry{ Data: data, PartitionKey: &partitionKey, } return nil }
[ "func", "(", "p", "*", "Producer", ")", "Put", "(", "data", "[", "]", "byte", ",", "partitionKey", "string", ")", "error", "{", "if", "len", "(", "data", ")", ">", "maxRecordSize", "{", "return", "ErrRecordSizeExceeded", "\n", "}", "\n\n", "p", ".", ...
// Put record `data` using `partitionKey`. This method is thread-safe.
[ "Put", "record", "data", "using", "partitionKey", ".", "This", "method", "is", "thread", "-", "safe", "." ]
08b17f58cb1b2ace14a61c0619a6bf2e2245ccd6
https://github.com/tj/go-kinesis/blob/08b17f58cb1b2ace14a61c0619a6bf2e2245ccd6/kinesis.go#L41-L52
16,115
tj/go-kinesis
kinesis.go
Stop
func (p *Producer) Stop() { p.Logger.WithField("backlog", len(p.records)).Info("stopping producer") // drain p.done <- struct{}{} close(p.records) // wait <-p.done p.Logger.Info("stopped producer") }
go
func (p *Producer) Stop() { p.Logger.WithField("backlog", len(p.records)).Info("stopping producer") // drain p.done <- struct{}{} close(p.records) // wait <-p.done p.Logger.Info("stopped producer") }
[ "func", "(", "p", "*", "Producer", ")", "Stop", "(", ")", "{", "p", ".", "Logger", ".", "WithField", "(", "\"", "\"", ",", "len", "(", "p", ".", "records", ")", ")", ".", "Info", "(", "\"", "\"", ")", "\n\n", "// drain", "p", ".", "done", "<-...
// Stop the producer. Flushes any in-flight data.
[ "Stop", "the", "producer", ".", "Flushes", "any", "in", "-", "flight", "data", "." ]
08b17f58cb1b2ace14a61c0619a6bf2e2245ccd6
https://github.com/tj/go-kinesis/blob/08b17f58cb1b2ace14a61c0619a6bf2e2245ccd6/kinesis.go#L60-L71
16,116
tj/go-kinesis
kinesis.go
loop
func (p *Producer) loop() { buf := make([]*k.PutRecordsRequestEntry, 0, p.BufferSize) tick := time.NewTicker(p.FlushInterval) drain := false defer tick.Stop() defer close(p.done) for { select { case record := <-p.records: buf = append(buf, record) if len(buf) >= p.BufferSize { p.flush(buf, "buffer size") buf = nil } if drain && len(p.records) == 0 { p.Logger.Info("drained") return } case <-tick.C: if len(buf) > 0 { p.flush(buf, "interval") buf = nil } case <-p.done: drain = true if len(buf) > 0 { p.flush(buf, "stopping") buf = nil } if len(p.records) == 0 { return } } } }
go
func (p *Producer) loop() { buf := make([]*k.PutRecordsRequestEntry, 0, p.BufferSize) tick := time.NewTicker(p.FlushInterval) drain := false defer tick.Stop() defer close(p.done) for { select { case record := <-p.records: buf = append(buf, record) if len(buf) >= p.BufferSize { p.flush(buf, "buffer size") buf = nil } if drain && len(p.records) == 0 { p.Logger.Info("drained") return } case <-tick.C: if len(buf) > 0 { p.flush(buf, "interval") buf = nil } case <-p.done: drain = true if len(buf) > 0 { p.flush(buf, "stopping") buf = nil } if len(p.records) == 0 { return } } } }
[ "func", "(", "p", "*", "Producer", ")", "loop", "(", ")", "{", "buf", ":=", "make", "(", "[", "]", "*", "k", ".", "PutRecordsRequestEntry", ",", "0", ",", "p", ".", "BufferSize", ")", "\n", "tick", ":=", "time", ".", "NewTicker", "(", "p", ".", ...
// loop and flush at the configured interval, or when the buffer is exceeded.
[ "loop", "and", "flush", "at", "the", "configured", "interval", "or", "when", "the", "buffer", "is", "exceeded", "." ]
08b17f58cb1b2ace14a61c0619a6bf2e2245ccd6
https://github.com/tj/go-kinesis/blob/08b17f58cb1b2ace14a61c0619a6bf2e2245ccd6/kinesis.go#L74-L113
16,117
tj/go-kinesis
kinesis.go
flush
func (p *Producer) flush(records []*k.PutRecordsRequestEntry, reason string) { p.Logger.WithFields(log.Fields{ "records": len(records), "reason": reason, }).Info("flush") out, err := p.Client.PutRecords(&k.PutRecordsInput{ StreamName: &p.StreamName, Records: records, }) if err != nil { p.Logger.WithError(err).Error("flush") p.backoff(len(records)) p.flush(records, "error") return } failed := *out.FailedRecordCount if failed == 0 { p.Backoff.Reset() return } p.backoff(int(failed)) p.flush(failures(records, out.Records), "retry") }
go
func (p *Producer) flush(records []*k.PutRecordsRequestEntry, reason string) { p.Logger.WithFields(log.Fields{ "records": len(records), "reason": reason, }).Info("flush") out, err := p.Client.PutRecords(&k.PutRecordsInput{ StreamName: &p.StreamName, Records: records, }) if err != nil { p.Logger.WithError(err).Error("flush") p.backoff(len(records)) p.flush(records, "error") return } failed := *out.FailedRecordCount if failed == 0 { p.Backoff.Reset() return } p.backoff(int(failed)) p.flush(failures(records, out.Records), "retry") }
[ "func", "(", "p", "*", "Producer", ")", "flush", "(", "records", "[", "]", "*", "k", ".", "PutRecordsRequestEntry", ",", "reason", "string", ")", "{", "p", ".", "Logger", ".", "WithFields", "(", "log", ".", "Fields", "{", "\"", "\"", ":", "len", "(...
// flush records and retry failures if necessary.
[ "flush", "records", "and", "retry", "failures", "if", "necessary", "." ]
08b17f58cb1b2ace14a61c0619a6bf2e2245ccd6
https://github.com/tj/go-kinesis/blob/08b17f58cb1b2ace14a61c0619a6bf2e2245ccd6/kinesis.go#L116-L142
16,118
tj/go-kinesis
kinesis.go
backoff
func (p *Producer) backoff(failed int) { backoff := p.Backoff.Duration() p.Logger.WithFields(log.Fields{ "failures": failed, "backoff": backoff, }).Warn("put failures") time.Sleep(backoff) }
go
func (p *Producer) backoff(failed int) { backoff := p.Backoff.Duration() p.Logger.WithFields(log.Fields{ "failures": failed, "backoff": backoff, }).Warn("put failures") time.Sleep(backoff) }
[ "func", "(", "p", "*", "Producer", ")", "backoff", "(", "failed", "int", ")", "{", "backoff", ":=", "p", ".", "Backoff", ".", "Duration", "(", ")", "\n\n", "p", ".", "Logger", ".", "WithFields", "(", "log", ".", "Fields", "{", "\"", "\"", ":", "f...
// calculates backoff duration and pauses execution
[ "calculates", "backoff", "duration", "and", "pauses", "execution" ]
08b17f58cb1b2ace14a61c0619a6bf2e2245ccd6
https://github.com/tj/go-kinesis/blob/08b17f58cb1b2ace14a61c0619a6bf2e2245ccd6/kinesis.go#L145-L154
16,119
tj/go-kinesis
kinesis.go
failures
func failures(records []*k.PutRecordsRequestEntry, response []*k.PutRecordsResultEntry) (out []*k.PutRecordsRequestEntry) { for i, record := range response { if record.ErrorCode != nil { out = append(out, records[i]) } } return }
go
func failures(records []*k.PutRecordsRequestEntry, response []*k.PutRecordsResultEntry) (out []*k.PutRecordsRequestEntry) { for i, record := range response { if record.ErrorCode != nil { out = append(out, records[i]) } } return }
[ "func", "failures", "(", "records", "[", "]", "*", "k", ".", "PutRecordsRequestEntry", ",", "response", "[", "]", "*", "k", ".", "PutRecordsResultEntry", ")", "(", "out", "[", "]", "*", "k", ".", "PutRecordsRequestEntry", ")", "{", "for", "i", ",", "re...
// failures returns the failed records as indicated in the response.
[ "failures", "returns", "the", "failed", "records", "as", "indicated", "in", "the", "response", "." ]
08b17f58cb1b2ace14a61c0619a6bf2e2245ccd6
https://github.com/tj/go-kinesis/blob/08b17f58cb1b2ace14a61c0619a6bf2e2245ccd6/kinesis.go#L157-L164
16,120
tj/go-kinesis
config.go
defaults
func (c *Config) defaults() { if c.Client == nil { c.Client = k.New(session.New(aws.NewConfig())) } if c.Logger == nil { c.Logger = log.Log } c.Logger = c.Logger.WithFields(log.Fields{ "package": "kinesis", }) if c.StreamName == "" { c.Logger.Fatal("StreamName required") } c.Logger = c.Logger.WithFields(log.Fields{ "stream": c.StreamName, }) if c.BufferSize == 0 { c.BufferSize = maxRecordsPerRequest } if c.BufferSize > maxRecordsPerRequest { c.Logger.Fatal("BufferSize exceeds 500") } if c.BacklogSize == 0 { c.BacklogSize = maxRecordsPerRequest } if c.FlushInterval == 0 { c.FlushInterval = time.Second } }
go
func (c *Config) defaults() { if c.Client == nil { c.Client = k.New(session.New(aws.NewConfig())) } if c.Logger == nil { c.Logger = log.Log } c.Logger = c.Logger.WithFields(log.Fields{ "package": "kinesis", }) if c.StreamName == "" { c.Logger.Fatal("StreamName required") } c.Logger = c.Logger.WithFields(log.Fields{ "stream": c.StreamName, }) if c.BufferSize == 0 { c.BufferSize = maxRecordsPerRequest } if c.BufferSize > maxRecordsPerRequest { c.Logger.Fatal("BufferSize exceeds 500") } if c.BacklogSize == 0 { c.BacklogSize = maxRecordsPerRequest } if c.FlushInterval == 0 { c.FlushInterval = time.Second } }
[ "func", "(", "c", "*", "Config", ")", "defaults", "(", ")", "{", "if", "c", ".", "Client", "==", "nil", "{", "c", ".", "Client", "=", "k", ".", "New", "(", "session", ".", "New", "(", "aws", ".", "NewConfig", "(", ")", ")", ")", "\n", "}", ...
// defaults for configuration.
[ "defaults", "for", "configuration", "." ]
08b17f58cb1b2ace14a61c0619a6bf2e2245ccd6
https://github.com/tj/go-kinesis/blob/08b17f58cb1b2ace14a61c0619a6bf2e2245ccd6/config.go#L42-L78
16,121
alexjlockwood/gcm
message.go
NewMessage
func NewMessage(data map[string]interface{}, regIDs ...string) *Message { return &Message{RegistrationIDs: regIDs, Data: data} }
go
func NewMessage(data map[string]interface{}, regIDs ...string) *Message { return &Message{RegistrationIDs: regIDs, Data: data} }
[ "func", "NewMessage", "(", "data", "map", "[", "string", "]", "interface", "{", "}", ",", "regIDs", "...", "string", ")", "*", "Message", "{", "return", "&", "Message", "{", "RegistrationIDs", ":", "regIDs", ",", "Data", ":", "data", "}", "\n", "}" ]
// NewMessage returns a new Message with the specified payload // and registration IDs.
[ "NewMessage", "returns", "a", "new", "Message", "with", "the", "specified", "payload", "and", "registration", "IDs", "." ]
532ebb3946fe1524432b00b8d04d39867c3d4c53
https://github.com/alexjlockwood/gcm/blob/532ebb3946fe1524432b00b8d04d39867c3d4c53/message.go#L19-L21
16,122
alexjlockwood/gcm
sender.go
updateStatus
func updateStatus(msg *Message, resp *Response, allResults map[string]Result) int { unsentRegIDs := make([]string, 0, resp.Failure) for i := 0; i < len(resp.Results); i++ { regID := msg.RegistrationIDs[i] allResults[regID] = resp.Results[i] if resp.Results[i].Error == "Unavailable" { unsentRegIDs = append(unsentRegIDs, regID) } } msg.RegistrationIDs = unsentRegIDs return len(unsentRegIDs) }
go
func updateStatus(msg *Message, resp *Response, allResults map[string]Result) int { unsentRegIDs := make([]string, 0, resp.Failure) for i := 0; i < len(resp.Results); i++ { regID := msg.RegistrationIDs[i] allResults[regID] = resp.Results[i] if resp.Results[i].Error == "Unavailable" { unsentRegIDs = append(unsentRegIDs, regID) } } msg.RegistrationIDs = unsentRegIDs return len(unsentRegIDs) }
[ "func", "updateStatus", "(", "msg", "*", "Message", ",", "resp", "*", "Response", ",", "allResults", "map", "[", "string", "]", "Result", ")", "int", "{", "unsentRegIDs", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "resp", ".", "Failure", "...
// updateStatus updates the status of the messages sent to devices and // returns the number of recoverable errors that could be retried.
[ "updateStatus", "updates", "the", "status", "of", "the", "messages", "sent", "to", "devices", "and", "returns", "the", "number", "of", "recoverable", "errors", "that", "could", "be", "retried", "." ]
532ebb3946fe1524432b00b8d04d39867c3d4c53
https://github.com/alexjlockwood/gcm/blob/532ebb3946fe1524432b00b8d04d39867c3d4c53/sender.go#L161-L172
16,123
alexjlockwood/gcm
sender.go
checkSender
func checkSender(sender *Sender) error { if sender.ApiKey == "" { return errors.New("the sender's API key must not be empty") } if sender.Http == nil { sender.Http = new(http.Client) } return nil }
go
func checkSender(sender *Sender) error { if sender.ApiKey == "" { return errors.New("the sender's API key must not be empty") } if sender.Http == nil { sender.Http = new(http.Client) } return nil }
[ "func", "checkSender", "(", "sender", "*", "Sender", ")", "error", "{", "if", "sender", ".", "ApiKey", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "sender", ".", "Http", "==", "nil", "{", "s...
// checkSender returns an error if the sender is not well-formed and // initializes a zeroed http.Client if one has not been provided.
[ "checkSender", "returns", "an", "error", "if", "the", "sender", "is", "not", "well", "-", "formed", "and", "initializes", "a", "zeroed", "http", ".", "Client", "if", "one", "has", "not", "been", "provided", "." ]
532ebb3946fe1524432b00b8d04d39867c3d4c53
https://github.com/alexjlockwood/gcm/blob/532ebb3946fe1524432b00b8d04d39867c3d4c53/sender.go#L186-L194
16,124
alexjlockwood/gcm
sender.go
checkMessage
func checkMessage(msg *Message) error { if msg == nil { return errors.New("the message must not be nil") } else if msg.RegistrationIDs == nil { return errors.New("the message's RegistrationIDs field must not be nil") } else if len(msg.RegistrationIDs) == 0 { return errors.New("the message must specify at least one registration ID") } else if len(msg.RegistrationIDs) > 1000 { return errors.New("the message may specify at most 1000 registration IDs") } else if msg.TimeToLive < 0 || 2419200 < msg.TimeToLive { return errors.New("the message's TimeToLive field must be an integer " + "between 0 and 2419200 (4 weeks)") } return nil }
go
func checkMessage(msg *Message) error { if msg == nil { return errors.New("the message must not be nil") } else if msg.RegistrationIDs == nil { return errors.New("the message's RegistrationIDs field must not be nil") } else if len(msg.RegistrationIDs) == 0 { return errors.New("the message must specify at least one registration ID") } else if len(msg.RegistrationIDs) > 1000 { return errors.New("the message may specify at most 1000 registration IDs") } else if msg.TimeToLive < 0 || 2419200 < msg.TimeToLive { return errors.New("the message's TimeToLive field must be an integer " + "between 0 and 2419200 (4 weeks)") } return nil }
[ "func", "checkMessage", "(", "msg", "*", "Message", ")", "error", "{", "if", "msg", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "else", "if", "msg", ".", "RegistrationIDs", "==", "nil", "{", "return", "errors", ...
// checkMessage returns an error if the message is not well-formed.
[ "checkMessage", "returns", "an", "error", "if", "the", "message", "is", "not", "well", "-", "formed", "." ]
532ebb3946fe1524432b00b8d04d39867c3d4c53
https://github.com/alexjlockwood/gcm/blob/532ebb3946fe1524432b00b8d04d39867c3d4c53/sender.go#L197-L211
16,125
TheCreeper/go-notify
notify.go
GetCapabilities
func GetCapabilities() (c Capabilities, err error) { conn, err := dbus.SessionBus() if err != nil { return } obj := conn.Object(DbusInterfacePath, DbusObjectPath) call := obj.Call(CallGetCapabilities, 0) if err = call.Err; err != nil { return } s := []string{} if err = call.Store(&s); err != nil { return } for _, v := range s { switch v { case "action-icons": c.ActionIcons = true break case "actions": c.Actions = true break case "body": c.Body = true break case "body-hyperlinks": c.BodyHyperlinks = true break case "body-images": c.BodyImages = true break case "body-markup": c.BodyMarkup = true break case "icon-multi": c.IconMulti = true break case "icon-static": c.IconStatic = true break case "persistence": c.Persistence = true break case "sound": c.Sound = true break } } return }
go
func GetCapabilities() (c Capabilities, err error) { conn, err := dbus.SessionBus() if err != nil { return } obj := conn.Object(DbusInterfacePath, DbusObjectPath) call := obj.Call(CallGetCapabilities, 0) if err = call.Err; err != nil { return } s := []string{} if err = call.Store(&s); err != nil { return } for _, v := range s { switch v { case "action-icons": c.ActionIcons = true break case "actions": c.Actions = true break case "body": c.Body = true break case "body-hyperlinks": c.BodyHyperlinks = true break case "body-images": c.BodyImages = true break case "body-markup": c.BodyMarkup = true break case "icon-multi": c.IconMulti = true break case "icon-static": c.IconStatic = true break case "persistence": c.Persistence = true break case "sound": c.Sound = true break } } return }
[ "func", "GetCapabilities", "(", ")", "(", "c", "Capabilities", ",", "err", "error", ")", "{", "conn", ",", "err", ":=", "dbus", ".", "SessionBus", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "obj", ":=", "conn", ".",...
// GetCapabilities returns the capabilities of the notification server.
[ "GetCapabilities", "returns", "the", "capabilities", "of", "the", "notification", "server", "." ]
b5cd14745a5c675c08f7d5c3203cf5f0324e85f3
https://github.com/TheCreeper/go-notify/blob/b5cd14745a5c675c08f7d5c3203cf5f0324e85f3/notify.go#L113-L165
16,126
TheCreeper/go-notify
notify.go
GetServerInformation
func GetServerInformation() (i ServerInformation, err error) { conn, err := dbus.SessionBus() if err != nil { return } obj := conn.Object(DbusInterfacePath, DbusObjectPath) call := obj.Call(CallGetServerInformation, 0) if err = call.Err; err != nil { return } err = call.Store(&i.Name, &i.Vendor, &i.Version, &i.SpecVersion) return }
go
func GetServerInformation() (i ServerInformation, err error) { conn, err := dbus.SessionBus() if err != nil { return } obj := conn.Object(DbusInterfacePath, DbusObjectPath) call := obj.Call(CallGetServerInformation, 0) if err = call.Err; err != nil { return } err = call.Store(&i.Name, &i.Vendor, &i.Version, &i.SpecVersion) return }
[ "func", "GetServerInformation", "(", ")", "(", "i", "ServerInformation", ",", "err", "error", ")", "{", "conn", ",", "err", ":=", "dbus", ".", "SessionBus", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "obj", ":=", "con...
// GetServerInformation returns information about the notification server such // as its name and version.
[ "GetServerInformation", "returns", "information", "about", "the", "notification", "server", "such", "as", "its", "name", "and", "version", "." ]
b5cd14745a5c675c08f7d5c3203cf5f0324e85f3
https://github.com/TheCreeper/go-notify/blob/b5cd14745a5c675c08f7d5c3203cf5f0324e85f3/notify.go#L185-L199
16,127
TheCreeper/go-notify
notify.go
NewNotification
func NewNotification(summary, body string) Notification { return Notification{ Summary: summary, Body: body, Timeout: ExpiresDefault, } }
go
func NewNotification(summary, body string) Notification { return Notification{ Summary: summary, Body: body, Timeout: ExpiresDefault, } }
[ "func", "NewNotification", "(", "summary", ",", "body", "string", ")", "Notification", "{", "return", "Notification", "{", "Summary", ":", "summary", ",", "Body", ":", "body", ",", "Timeout", ":", "ExpiresDefault", ",", "}", "\n", "}" ]
// NewNotification creates a new notification object with some basic // information.
[ "NewNotification", "creates", "a", "new", "notification", "object", "with", "some", "basic", "information", "." ]
b5cd14745a5c675c08f7d5c3203cf5f0324e85f3
https://github.com/TheCreeper/go-notify/blob/b5cd14745a5c675c08f7d5c3203cf5f0324e85f3/notify.go#L234-L240
16,128
TheCreeper/go-notify
notify.go
Show
func (n Notification) Show() (id uint32, err error) { conn, err := dbus.SessionBus() if err != nil { return } // We need to convert the interface type of the map to dbus.Variant as // people dont want to have to import the dbus package just to make use // of the notification hints. hints := map[string]dbus.Variant{} for k, v := range n.Hints { hints[k] = dbus.MakeVariant(v) } obj := conn.Object(DbusInterfacePath, DbusObjectPath) call := obj.Call( CallNotify, 0, n.AppName, n.ReplacesID, n.AppIcon, n.Summary, n.Body, n.Actions, hints, n.Timeout) if err = call.Err; err != nil { return } err = call.Store(&id) return }
go
func (n Notification) Show() (id uint32, err error) { conn, err := dbus.SessionBus() if err != nil { return } // We need to convert the interface type of the map to dbus.Variant as // people dont want to have to import the dbus package just to make use // of the notification hints. hints := map[string]dbus.Variant{} for k, v := range n.Hints { hints[k] = dbus.MakeVariant(v) } obj := conn.Object(DbusInterfacePath, DbusObjectPath) call := obj.Call( CallNotify, 0, n.AppName, n.ReplacesID, n.AppIcon, n.Summary, n.Body, n.Actions, hints, n.Timeout) if err = call.Err; err != nil { return } err = call.Store(&id) return }
[ "func", "(", "n", "Notification", ")", "Show", "(", ")", "(", "id", "uint32", ",", "err", "error", ")", "{", "conn", ",", "err", ":=", "dbus", ".", "SessionBus", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "// We n...
// Show sends the information in the notification object to the server to be // displayed.
[ "Show", "sends", "the", "information", "in", "the", "notification", "object", "to", "the", "server", "to", "be", "displayed", "." ]
b5cd14745a5c675c08f7d5c3203cf5f0324e85f3
https://github.com/TheCreeper/go-notify/blob/b5cd14745a5c675c08f7d5c3203cf5f0324e85f3/notify.go#L244-L276
16,129
TheCreeper/go-notify
notify.go
CloseNotification
func CloseNotification(id uint32) (err error) { conn, err := dbus.SessionBus() if err != nil { return } obj := conn.Object(DbusInterfacePath, DbusObjectPath) call := obj.Call(CallCloseNotification, 0, id) err = call.Err return }
go
func CloseNotification(id uint32) (err error) { conn, err := dbus.SessionBus() if err != nil { return } obj := conn.Object(DbusInterfacePath, DbusObjectPath) call := obj.Call(CallCloseNotification, 0, id) err = call.Err return }
[ "func", "CloseNotification", "(", "id", "uint32", ")", "(", "err", "error", ")", "{", "conn", ",", "err", ":=", "dbus", ".", "SessionBus", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "obj", ":=", "conn", ".", "Object...
// CloseNotification closes the notification if it exists using its id.
[ "CloseNotification", "closes", "the", "notification", "if", "it", "exists", "using", "its", "id", "." ]
b5cd14745a5c675c08f7d5c3203cf5f0324e85f3
https://github.com/TheCreeper/go-notify/blob/b5cd14745a5c675c08f7d5c3203cf5f0324e85f3/notify.go#L279-L289
16,130
xlab/closer
closer.go
Fatalln
func Fatalln(v ...interface{}) { out := log.New(os.Stderr, "", log.Flags()) out.Output(2, fmt.Sprintln(v...)) c.closeErr() }
go
func Fatalln(v ...interface{}) { out := log.New(os.Stderr, "", log.Flags()) out.Output(2, fmt.Sprintln(v...)) c.closeErr() }
[ "func", "Fatalln", "(", "v", "...", "interface", "{", "}", ")", "{", "out", ":=", "log", ".", "New", "(", "os", ".", "Stderr", ",", "\"", "\"", ",", "log", ".", "Flags", "(", ")", ")", "\n", "out", ".", "Output", "(", "2", ",", "fmt", ".", ...
// Fatalln works the same as log.Fatalln but respects the closer's logic.
[ "Fatalln", "works", "the", "same", "as", "log", ".", "Fatalln", "but", "respects", "the", "closer", "s", "logic", "." ]
03326addb7c265ee27cd5d5d145362165d8195a8
https://github.com/xlab/closer/blob/03326addb7c265ee27cd5d5d145362165d8195a8/closer.go#L161-L165
16,131
xlab/closer
closer.go
Fatalf
func Fatalf(format string, v ...interface{}) { out := log.New(os.Stderr, "", log.Flags()) out.Output(2, fmt.Sprintf(format, v...)) c.closeErr() }
go
func Fatalf(format string, v ...interface{}) { out := log.New(os.Stderr, "", log.Flags()) out.Output(2, fmt.Sprintf(format, v...)) c.closeErr() }
[ "func", "Fatalf", "(", "format", "string", ",", "v", "...", "interface", "{", "}", ")", "{", "out", ":=", "log", ".", "New", "(", "os", ".", "Stderr", ",", "\"", "\"", ",", "log", ".", "Flags", "(", ")", ")", "\n", "out", ".", "Output", "(", ...
// Fatalf works the same as log.Fatalf but respects the closer's logic.
[ "Fatalf", "works", "the", "same", "as", "log", ".", "Fatalf", "but", "respects", "the", "closer", "s", "logic", "." ]
03326addb7c265ee27cd5d5d145362165d8195a8
https://github.com/xlab/closer/blob/03326addb7c265ee27cd5d5d145362165d8195a8/closer.go#L168-L172
16,132
xlab/closer
closer.go
Bind
func Bind(cleanup func()) { c.sem.Lock() // store in the reverse order s := make([]func(), 0, 1+len(c.cleanups)) s = append(s, cleanup) c.cleanups = append(s, c.cleanups...) c.sem.Unlock() }
go
func Bind(cleanup func()) { c.sem.Lock() // store in the reverse order s := make([]func(), 0, 1+len(c.cleanups)) s = append(s, cleanup) c.cleanups = append(s, c.cleanups...) c.sem.Unlock() }
[ "func", "Bind", "(", "cleanup", "func", "(", ")", ")", "{", "c", ".", "sem", ".", "Lock", "(", ")", "\n", "// store in the reverse order", "s", ":=", "make", "(", "[", "]", "func", "(", ")", ",", "0", ",", "1", "+", "len", "(", "c", ".", "clean...
// Bind will register the cleanup function that will be called when closer will get a close request. // All the callbacks will be called in the reverse order they were bound, that's similar to how `defer` works.
[ "Bind", "will", "register", "the", "cleanup", "function", "that", "will", "be", "called", "when", "closer", "will", "get", "a", "close", "request", ".", "All", "the", "callbacks", "will", "be", "called", "in", "the", "reverse", "order", "they", "were", "bo...
03326addb7c265ee27cd5d5d145362165d8195a8
https://github.com/xlab/closer/blob/03326addb7c265ee27cd5d5d145362165d8195a8/closer.go#L232-L239
16,133
xlab/closer
closer.go
Checked
func Checked(target func() error, logging bool) { defer func() { // check if there was a panic if x := recover(); x != nil { if logging { log.Printf("run time panic: %v", x) } // close with an error c.closeErr() } }() if err := target(); err != nil { if logging { log.Println("error:", err) } // close with an error c.closeErr() } }
go
func Checked(target func() error, logging bool) { defer func() { // check if there was a panic if x := recover(); x != nil { if logging { log.Printf("run time panic: %v", x) } // close with an error c.closeErr() } }() if err := target(); err != nil { if logging { log.Println("error:", err) } // close with an error c.closeErr() } }
[ "func", "Checked", "(", "target", "func", "(", ")", "error", ",", "logging", "bool", ")", "{", "defer", "func", "(", ")", "{", "// check if there was a panic", "if", "x", ":=", "recover", "(", ")", ";", "x", "!=", "nil", "{", "if", "logging", "{", "l...
// Checked runs the target function and checks for panics and errors it may yield. In case of panic or error, closer // will terminate the app with an error code, but either case it will call all the bound callbacks beforehand. // One can use this instead of `defer` if you need to care about errors and panics that always may happen. // This function optionally can emit log messages via standard `log` package.
[ "Checked", "runs", "the", "target", "function", "and", "checks", "for", "panics", "and", "errors", "it", "may", "yield", ".", "In", "case", "of", "panic", "or", "error", "closer", "will", "terminate", "the", "app", "with", "an", "error", "code", "but", "...
03326addb7c265ee27cd5d5d145362165d8195a8
https://github.com/xlab/closer/blob/03326addb7c265ee27cd5d5d145362165d8195a8/closer.go#L245-L263
16,134
Unknwon/i18n
i18n.go
Get
func (d *localeStore) Get(lang, section, format string) (string, bool) { if locale, ok := d.store[lang]; ok { if key, err := locale.message.Section(section).GetKey(format); err == nil { return key.Value(), true } } if len(d.defaultLang) > 0 && lang != d.defaultLang { return d.Get(d.defaultLang, section, format) } return "", false }
go
func (d *localeStore) Get(lang, section, format string) (string, bool) { if locale, ok := d.store[lang]; ok { if key, err := locale.message.Section(section).GetKey(format); err == nil { return key.Value(), true } } if len(d.defaultLang) > 0 && lang != d.defaultLang { return d.Get(d.defaultLang, section, format) } return "", false }
[ "func", "(", "d", "*", "localeStore", ")", "Get", "(", "lang", ",", "section", ",", "format", "string", ")", "(", "string", ",", "bool", ")", "{", "if", "locale", ",", "ok", ":=", "d", ".", "store", "[", "lang", "]", ";", "ok", "{", "if", "key"...
// Get target language string
[ "Get", "target", "language", "string" ]
b64d336589669d317928070e70ba0ae558f16633
https://github.com/Unknwon/i18n/blob/b64d336589669d317928070e70ba0ae558f16633/i18n.go#L48-L60
16,135
Unknwon/i18n
i18n.go
ListLangs
func ListLangs() []string { langs := make([]string, len(locales.langs)) copy(langs, locales.langs) return langs }
go
func ListLangs() []string { langs := make([]string, len(locales.langs)) copy(langs, locales.langs) return langs }
[ "func", "ListLangs", "(", ")", "[", "]", "string", "{", "langs", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "locales", ".", "langs", ")", ")", "\n", "copy", "(", "langs", ",", "locales", ".", "langs", ")", "\n", "return", "langs", "\...
// ListLangs returns list of all locale languages.
[ "ListLangs", "returns", "list", "of", "all", "locale", "languages", "." ]
b64d336589669d317928070e70ba0ae558f16633
https://github.com/Unknwon/i18n/blob/b64d336589669d317928070e70ba0ae558f16633/i18n.go#L111-L115
16,136
Unknwon/i18n
i18n.go
IsExist
func IsExist(lang string) bool { _, ok := locales.store[lang] return ok }
go
func IsExist(lang string) bool { _, ok := locales.store[lang] return ok }
[ "func", "IsExist", "(", "lang", "string", ")", "bool", "{", "_", ",", "ok", ":=", "locales", ".", "store", "[", "lang", "]", "\n", "return", "ok", "\n", "}" ]
// IsExist returns true if given language locale exists.
[ "IsExist", "returns", "true", "if", "given", "language", "locale", "exists", "." ]
b64d336589669d317928070e70ba0ae558f16633
https://github.com/Unknwon/i18n/blob/b64d336589669d317928070e70ba0ae558f16633/i18n.go#L124-L127
16,137
Unknwon/i18n
i18n.go
IndexLang
func IndexLang(lang string) int { if lc, ok := locales.store[lang]; ok { return lc.id } return -1 }
go
func IndexLang(lang string) int { if lc, ok := locales.store[lang]; ok { return lc.id } return -1 }
[ "func", "IndexLang", "(", "lang", "string", ")", "int", "{", "if", "lc", ",", "ok", ":=", "locales", ".", "store", "[", "lang", "]", ";", "ok", "{", "return", "lc", ".", "id", "\n", "}", "\n", "return", "-", "1", "\n", "}" ]
// IndexLang returns index of language locale, // it returns -1 if locale not exists.
[ "IndexLang", "returns", "index", "of", "language", "locale", "it", "returns", "-", "1", "if", "locale", "not", "exists", "." ]
b64d336589669d317928070e70ba0ae558f16633
https://github.com/Unknwon/i18n/blob/b64d336589669d317928070e70ba0ae558f16633/i18n.go#L131-L136
16,138
Unknwon/i18n
i18n.go
GetLangByIndex
func GetLangByIndex(index int) string { if index < 0 || index >= len(locales.langs) { return "" } return locales.langs[index] }
go
func GetLangByIndex(index int) string { if index < 0 || index >= len(locales.langs) { return "" } return locales.langs[index] }
[ "func", "GetLangByIndex", "(", "index", "int", ")", "string", "{", "if", "index", "<", "0", "||", "index", ">=", "len", "(", "locales", ".", "langs", ")", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "locales", ".", "langs", "[", "index", ...
// GetLangByIndex return language by given index.
[ "GetLangByIndex", "return", "language", "by", "given", "index", "." ]
b64d336589669d317928070e70ba0ae558f16633
https://github.com/Unknwon/i18n/blob/b64d336589669d317928070e70ba0ae558f16633/i18n.go#L139-L144
16,139
Unknwon/i18n
i18n.go
SetMessage
func SetMessage(lang string, localeFile interface{}, otherLocaleFiles ...interface{}) error { return SetMessageWithDesc(lang, lang, localeFile, otherLocaleFiles...) }
go
func SetMessage(lang string, localeFile interface{}, otherLocaleFiles ...interface{}) error { return SetMessageWithDesc(lang, lang, localeFile, otherLocaleFiles...) }
[ "func", "SetMessage", "(", "lang", "string", ",", "localeFile", "interface", "{", "}", ",", "otherLocaleFiles", "...", "interface", "{", "}", ")", "error", "{", "return", "SetMessageWithDesc", "(", "lang", ",", "lang", ",", "localeFile", ",", "otherLocaleFiles...
// SetMessage sets the message file for localization.
[ "SetMessage", "sets", "the", "message", "file", "for", "localization", "." ]
b64d336589669d317928070e70ba0ae558f16633
https://github.com/Unknwon/i18n/blob/b64d336589669d317928070e70ba0ae558f16633/i18n.go#L178-L180
16,140
bronze1man/goStrongswanVici
stats.go
Stats
func (c *ClientConn) Stats() (msg map[string]interface{}, err error) { msg, err = c.Request("stats", nil) return }
go
func (c *ClientConn) Stats() (msg map[string]interface{}, err error) { msg, err = c.Request("stats", nil) return }
[ "func", "(", "c", "*", "ClientConn", ")", "Stats", "(", ")", "(", "msg", "map", "[", "string", "]", "interface", "{", "}", ",", "err", "error", ")", "{", "msg", ",", "err", "=", "c", ".", "Request", "(", "\"", "\"", ",", "nil", ")", "\n", "re...
// Stats returns IKE daemon statistics and load information.
[ "Stats", "returns", "IKE", "daemon", "statistics", "and", "load", "information", "." ]
92d3927c899e00fc3686202dd606f79afdb8bf71
https://github.com/bronze1man/goStrongswanVici/blob/92d3927c899e00fc3686202dd606f79afdb8bf71/stats.go#L4-L7
16,141
bronze1man/goStrongswanVici
shared.go
LoadShared
func (c *ClientConn) LoadShared(key *Key) error { requestMap := &map[string]interface{}{} err := ConvertToGeneral(key, requestMap) if err != nil { return fmt.Errorf("error creating request: %v", err) } msg, err := c.Request("load-shared", *requestMap) if msg["success"] != "yes" { return fmt.Errorf("unsuccessful loadSharedKey: %v", msg["errmsg"]) } return nil }
go
func (c *ClientConn) LoadShared(key *Key) error { requestMap := &map[string]interface{}{} err := ConvertToGeneral(key, requestMap) if err != nil { return fmt.Errorf("error creating request: %v", err) } msg, err := c.Request("load-shared", *requestMap) if msg["success"] != "yes" { return fmt.Errorf("unsuccessful loadSharedKey: %v", msg["errmsg"]) } return nil }
[ "func", "(", "c", "*", "ClientConn", ")", "LoadShared", "(", "key", "*", "Key", ")", "error", "{", "requestMap", ":=", "&", "map", "[", "string", "]", "interface", "{", "}", "{", "}", "\n\n", "err", ":=", "ConvertToGeneral", "(", "key", ",", "request...
// load a shared secret into the IKE daemon
[ "load", "a", "shared", "secret", "into", "the", "IKE", "daemon" ]
92d3927c899e00fc3686202dd606f79afdb8bf71
https://github.com/bronze1man/goStrongswanVici/blob/92d3927c899e00fc3686202dd606f79afdb8bf71/shared.go#L25-L40
16,142
bronze1man/goStrongswanVici
shared.go
GetShared
func (c *ClientConn) GetShared() ([]string, error) { msg, err := c.Request("get-shared", nil) if err != nil { fmt.Errorf("Error making request: %v", err) return nil, err } keys := &keyList{} err = ConvertFromGeneral(msg, keys) if err != nil { fmt.Errorf("Error converting data: %v", err) } return keys.Keys, err }
go
func (c *ClientConn) GetShared() ([]string, error) { msg, err := c.Request("get-shared", nil) if err != nil { fmt.Errorf("Error making request: %v", err) return nil, err } keys := &keyList{} err = ConvertFromGeneral(msg, keys) if err != nil { fmt.Errorf("Error converting data: %v", err) } return keys.Keys, err }
[ "func", "(", "c", "*", "ClientConn", ")", "GetShared", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "msg", ",", "err", ":=", "c", ".", "Request", "(", "\"", "\"", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "fmt", ".",...
// get a the names of the shared secrets currently loaded
[ "get", "a", "the", "names", "of", "the", "shared", "secrets", "currently", "loaded" ]
92d3927c899e00fc3686202dd606f79afdb8bf71
https://github.com/bronze1man/goStrongswanVici/blob/92d3927c899e00fc3686202dd606f79afdb8bf71/shared.go#L61-L76
16,143
bronze1man/goStrongswanVici
msg.go
readKeyList
func readKeyList(r *bufio.Reader) (key string, msg []string, err error) { key, err = readString1(r) if err != nil { return } msg = []string{} for { var c byte c, err = r.ReadByte() if err != nil { return } switch elementType(c) { case etLIST_ITEM: value, err := readString2(r) if err != nil { return "", nil, err } msg = append(msg, value) case etLIST_END: //end of outer list return key, msg, nil default: return "", nil, fmt.Errorf("[readKeyList] protocol error 2") } } return }
go
func readKeyList(r *bufio.Reader) (key string, msg []string, err error) { key, err = readString1(r) if err != nil { return } msg = []string{} for { var c byte c, err = r.ReadByte() if err != nil { return } switch elementType(c) { case etLIST_ITEM: value, err := readString2(r) if err != nil { return "", nil, err } msg = append(msg, value) case etLIST_END: //end of outer list return key, msg, nil default: return "", nil, fmt.Errorf("[readKeyList] protocol error 2") } } return }
[ "func", "readKeyList", "(", "r", "*", "bufio", ".", "Reader", ")", "(", "key", "string", ",", "msg", "[", "]", "string", ",", "err", "error", ")", "{", "key", ",", "err", "=", "readString1", "(", "r", ")", "\n", "if", "err", "!=", "nil", "{", "...
//LIST_START has been read already.
[ "LIST_START", "has", "been", "read", "already", "." ]
92d3927c899e00fc3686202dd606f79afdb8bf71
https://github.com/bronze1man/goStrongswanVici/blob/92d3927c899e00fc3686202dd606f79afdb8bf71/msg.go#L264-L290
16,144
bronze1man/goStrongswanVici
msg.go
readKeyString
func readKeyString(r *bufio.Reader) (key string, msg string, err error) { key, err = readString1(r) if err != nil { return } msg, err = readString2(r) if err != nil { return } return }
go
func readKeyString(r *bufio.Reader) (key string, msg string, err error) { key, err = readString1(r) if err != nil { return } msg, err = readString2(r) if err != nil { return } return }
[ "func", "readKeyString", "(", "r", "*", "bufio", ".", "Reader", ")", "(", "key", "string", ",", "msg", "string", ",", "err", "error", ")", "{", "key", ",", "err", "=", "readString1", "(", "r", ")", "\n", "if", "err", "!=", "nil", "{", "return", "...
//KEY_VALUE has been read already.
[ "KEY_VALUE", "has", "been", "read", "already", "." ]
92d3927c899e00fc3686202dd606f79afdb8bf71
https://github.com/bronze1man/goStrongswanVici/blob/92d3927c899e00fc3686202dd606f79afdb8bf71/msg.go#L293-L303
16,145
bronze1man/goStrongswanVici
msg.go
getNewKeyToHandleDuplicates
func getNewKeyToHandleDuplicates(key string, msg map[string]interface{}) string { if _, ok := msg[key]; !ok { return key } for i := 0; ; i++ { newKey := key + "##" + strconv.Itoa(i) if _, ok := msg[newKey]; !ok { return newKey } } }
go
func getNewKeyToHandleDuplicates(key string, msg map[string]interface{}) string { if _, ok := msg[key]; !ok { return key } for i := 0; ; i++ { newKey := key + "##" + strconv.Itoa(i) if _, ok := msg[newKey]; !ok { return newKey } } }
[ "func", "getNewKeyToHandleDuplicates", "(", "key", "string", ",", "msg", "map", "[", "string", "]", "interface", "{", "}", ")", "string", "{", "if", "_", ",", "ok", ":=", "msg", "[", "key", "]", ";", "!", "ok", "{", "return", "key", "\n", "}", "\n\...
// Since the original key chosen can have duplicates, // this function is used to map the original key to a new one // to make them unique.
[ "Since", "the", "original", "key", "chosen", "can", "have", "duplicates", "this", "function", "is", "used", "to", "map", "the", "original", "key", "to", "a", "new", "one", "to", "make", "them", "unique", "." ]
92d3927c899e00fc3686202dd606f79afdb8bf71
https://github.com/bronze1man/goStrongswanVici/blob/92d3927c899e00fc3686202dd606f79afdb8bf71/msg.go#L308-L319
16,146
bronze1man/goStrongswanVici
listSas.go
ListSas
func (c *ClientConn) ListSas(ike string, ike_id string) (sas []map[string]IkeSa, err error) { sas = []map[string]IkeSa{} var eventErr error //register event err = c.RegisterEvent("list-sa", func(response map[string]interface{}) { sa := &map[string]IkeSa{} err = ConvertFromGeneral(response, sa) if err != nil { fmt.Printf("list-sa event error: %s\n", err) eventErr = err return } sas = append(sas, *sa) //fmt.Printf("event %#v\n", response) }) if err != nil { return } if eventErr != nil { return } inMap := map[string]interface{}{} if ike != "" { inMap["ike"] = ike } if ike_id != "" { inMap["ike_id"] = ike_id } _, err = c.Request("list-sas", inMap) if err != nil { return } //fmt.Printf("request finish %#v\n", sas) err = c.UnregisterEvent("list-sa") if err != nil { return } return }
go
func (c *ClientConn) ListSas(ike string, ike_id string) (sas []map[string]IkeSa, err error) { sas = []map[string]IkeSa{} var eventErr error //register event err = c.RegisterEvent("list-sa", func(response map[string]interface{}) { sa := &map[string]IkeSa{} err = ConvertFromGeneral(response, sa) if err != nil { fmt.Printf("list-sa event error: %s\n", err) eventErr = err return } sas = append(sas, *sa) //fmt.Printf("event %#v\n", response) }) if err != nil { return } if eventErr != nil { return } inMap := map[string]interface{}{} if ike != "" { inMap["ike"] = ike } if ike_id != "" { inMap["ike_id"] = ike_id } _, err = c.Request("list-sas", inMap) if err != nil { return } //fmt.Printf("request finish %#v\n", sas) err = c.UnregisterEvent("list-sa") if err != nil { return } return }
[ "func", "(", "c", "*", "ClientConn", ")", "ListSas", "(", "ike", "string", ",", "ike_id", "string", ")", "(", "sas", "[", "]", "map", "[", "string", "]", "IkeSa", ",", "err", "error", ")", "{", "sas", "=", "[", "]", "map", "[", "string", "]", "...
// To be simple, list all clients that are connecting to this server . // A client is a sa. // Lists currently active IKE_SAs
[ "To", "be", "simple", "list", "all", "clients", "that", "are", "connecting", "to", "this", "server", ".", "A", "client", "is", "a", "sa", ".", "Lists", "currently", "active", "IKE_SAs" ]
92d3927c899e00fc3686202dd606f79afdb8bf71
https://github.com/bronze1man/goStrongswanVici/blob/92d3927c899e00fc3686202dd606f79afdb8bf71/listSas.go#L83-L122
16,147
bronze1man/goStrongswanVici
listSas.go
ListAllVpnConnInfo
func (c *ClientConn) ListAllVpnConnInfo() (list []VpnConnInfo, err error) { sasList, err := c.ListSas("", "") if err != nil { return } list = make([]VpnConnInfo, len(sasList)) for i, sa := range sasList { info := VpnConnInfo{} if len(sa) != 1 { fmt.Printf("[vici.ListAllVpnConnInfo] warning: len(sa)[%d]!=1\n", len(sa)) } for ikeSaName, ikeSa := range sa { info.IkeSaName = ikeSaName info.IkeSa = ikeSa //if len(ikeSa.Child_sas) != 1 { // fmt.Println("[vici.ListAllVpnConnInfo] warning: len(ikeSa.Child_sas)[%d]!=1", len(ikeSa.Child_sas)) //} for childSaName, childSa := range ikeSa.Child_sas { info.ChildSaName = childSaName info.Child_sas = childSa break } break } if len(info.IkeSa.Child_sas) == 1 { info.IkeSa.Child_sas = nil } list[i] = info } return }
go
func (c *ClientConn) ListAllVpnConnInfo() (list []VpnConnInfo, err error) { sasList, err := c.ListSas("", "") if err != nil { return } list = make([]VpnConnInfo, len(sasList)) for i, sa := range sasList { info := VpnConnInfo{} if len(sa) != 1 { fmt.Printf("[vici.ListAllVpnConnInfo] warning: len(sa)[%d]!=1\n", len(sa)) } for ikeSaName, ikeSa := range sa { info.IkeSaName = ikeSaName info.IkeSa = ikeSa //if len(ikeSa.Child_sas) != 1 { // fmt.Println("[vici.ListAllVpnConnInfo] warning: len(ikeSa.Child_sas)[%d]!=1", len(ikeSa.Child_sas)) //} for childSaName, childSa := range ikeSa.Child_sas { info.ChildSaName = childSaName info.Child_sas = childSa break } break } if len(info.IkeSa.Child_sas) == 1 { info.IkeSa.Child_sas = nil } list[i] = info } return }
[ "func", "(", "c", "*", "ClientConn", ")", "ListAllVpnConnInfo", "(", ")", "(", "list", "[", "]", "VpnConnInfo", ",", "err", "error", ")", "{", "sasList", ",", "err", ":=", "c", ".", "ListSas", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "e...
// a helper method to avoid complex data struct in ListSas // if it only have one child_sas ,it will put it into info.Child_sas
[ "a", "helper", "method", "to", "avoid", "complex", "data", "struct", "in", "ListSas", "if", "it", "only", "have", "one", "child_sas", "it", "will", "put", "it", "into", "info", ".", "Child_sas" ]
92d3927c899e00fc3686202dd606f79afdb8bf71
https://github.com/bronze1man/goStrongswanVici/blob/92d3927c899e00fc3686202dd606f79afdb8bf71/listSas.go#L144-L174
16,148
bronze1man/goStrongswanVici
terminate.go
Terminate
func (c *ClientConn) Terminate(r *TerminateRequest) (err error) { err = handlePanic(func() (err error) { reqMap := &map[string]interface{}{} ConvertToGeneral(r, reqMap) msg, err := c.Request("terminate", *reqMap) if err != nil { return } if msg["success"] != "yes" { return fmt.Errorf("[Terminate] %s", msg["errmsg"]) } return }) return }
go
func (c *ClientConn) Terminate(r *TerminateRequest) (err error) { err = handlePanic(func() (err error) { reqMap := &map[string]interface{}{} ConvertToGeneral(r, reqMap) msg, err := c.Request("terminate", *reqMap) if err != nil { return } if msg["success"] != "yes" { return fmt.Errorf("[Terminate] %s", msg["errmsg"]) } return }) return }
[ "func", "(", "c", "*", "ClientConn", ")", "Terminate", "(", "r", "*", "TerminateRequest", ")", "(", "err", "error", ")", "{", "err", "=", "handlePanic", "(", "func", "(", ")", "(", "err", "error", ")", "{", "reqMap", ":=", "&", "map", "[", "string"...
// To be simple, kill a client that is connecting to this server. A client is a sa. //Terminates an SA while streaming control-log events.
[ "To", "be", "simple", "kill", "a", "client", "that", "is", "connecting", "to", "this", "server", ".", "A", "client", "is", "a", "sa", ".", "Terminates", "an", "SA", "while", "streaming", "control", "-", "log", "events", "." ]
92d3927c899e00fc3686202dd606f79afdb8bf71
https://github.com/bronze1man/goStrongswanVici/blob/92d3927c899e00fc3686202dd606f79afdb8bf71/terminate.go#L18-L32
16,149
projecteru2/core
versioninfo/versioninfo.go
VersionString
func VersionString() string { version := "" version += fmt.Sprintf("Version: %s\n", VERSION) version += fmt.Sprintf("Git hash: %s\n", REVISION) version += fmt.Sprintf("Built: %s\n", BUILTAT) version += fmt.Sprintf("Golang version: %s\n", runtime.Version()) version += fmt.Sprintf("OS/Arch: %s/%s\n", runtime.GOOS, runtime.GOARCH) return version }
go
func VersionString() string { version := "" version += fmt.Sprintf("Version: %s\n", VERSION) version += fmt.Sprintf("Git hash: %s\n", REVISION) version += fmt.Sprintf("Built: %s\n", BUILTAT) version += fmt.Sprintf("Golang version: %s\n", runtime.Version()) version += fmt.Sprintf("OS/Arch: %s/%s\n", runtime.GOOS, runtime.GOARCH) return version }
[ "func", "VersionString", "(", ")", "string", "{", "version", ":=", "\"", "\"", "\n", "version", "+=", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "VERSION", ")", "\n", "version", "+=", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "RE...
// VersionString show version thing
[ "VersionString", "show", "version", "thing" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/versioninfo/versioninfo.go#L20-L28
16,150
projecteru2/core
cluster/calcium/helper.go
ensureReaderClosed
func ensureReaderClosed(stream io.ReadCloser) { if stream == nil { return } io.Copy(ioutil.Discard, stream) stream.Close() }
go
func ensureReaderClosed(stream io.ReadCloser) { if stream == nil { return } io.Copy(ioutil.Discard, stream) stream.Close() }
[ "func", "ensureReaderClosed", "(", "stream", "io", ".", "ReadCloser", ")", "{", "if", "stream", "==", "nil", "{", "return", "\n", "}", "\n", "io", ".", "Copy", "(", "ioutil", ".", "Discard", ",", "stream", ")", "\n", "stream", ".", "Close", "(", ")",...
// As the name says, // blocks until the stream is empty, until we meet EOF
[ "As", "the", "name", "says", "blocks", "until", "the", "stream", "is", "empty", "until", "we", "meet", "EOF" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/cluster/calcium/helper.go#L20-L26
16,151
projecteru2/core
cluster/calcium/helper.go
pullImage
func pullImage(ctx context.Context, node *types.Node, image string) error { log.Infof("[pullImage] Pulling image %s", image) if image == "" { return types.ErrNoImage } // check local exists := false digests, err := node.Engine.ImageLocalDigests(ctx, image) if err != nil { log.Errorf("[pullImage] Check image failed %v", err) } else { log.Debug("[pullImage] Local Image exists") exists = true } if exists && distributionInspect(ctx, node, image, digests) { log.Debug("[pullImage] Image cached, skip pulling") return nil } log.Info("[pullImage] Image not cached, pulling") outStream, err := node.Engine.ImagePull(ctx, image, false) if err != nil { log.Errorf("[pullImage] Error during pulling image %s: %v", image, err) return err } ensureReaderClosed(outStream) log.Infof("[pullImage] Done pulling image %s", image) return nil }
go
func pullImage(ctx context.Context, node *types.Node, image string) error { log.Infof("[pullImage] Pulling image %s", image) if image == "" { return types.ErrNoImage } // check local exists := false digests, err := node.Engine.ImageLocalDigests(ctx, image) if err != nil { log.Errorf("[pullImage] Check image failed %v", err) } else { log.Debug("[pullImage] Local Image exists") exists = true } if exists && distributionInspect(ctx, node, image, digests) { log.Debug("[pullImage] Image cached, skip pulling") return nil } log.Info("[pullImage] Image not cached, pulling") outStream, err := node.Engine.ImagePull(ctx, image, false) if err != nil { log.Errorf("[pullImage] Error during pulling image %s: %v", image, err) return err } ensureReaderClosed(outStream) log.Infof("[pullImage] Done pulling image %s", image) return nil }
[ "func", "pullImage", "(", "ctx", "context", ".", "Context", ",", "node", "*", "types", ".", "Node", ",", "image", "string", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "image", ")", "\n", "if", "image", "==", "\"", "\"", "{", "r...
// Pull an image
[ "Pull", "an", "image" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/cluster/calcium/helper.go#L113-L143
16,152
projecteru2/core
store/etcdv3/pod.go
RemovePod
func (m *Mercury) RemovePod(ctx context.Context, podname string) error { key := fmt.Sprintf(podInfoKey, podname) ns, err := m.GetNodesByPod(ctx, podname) if err != nil { return err } if l := len(ns); l != 0 { return types.NewDetailedErr(types.ErrPodHasNodes, fmt.Sprintf("pod %s still has %d nodes, delete them first", podname, l)) } _, err = m.Delete(ctx, key) return err }
go
func (m *Mercury) RemovePod(ctx context.Context, podname string) error { key := fmt.Sprintf(podInfoKey, podname) ns, err := m.GetNodesByPod(ctx, podname) if err != nil { return err } if l := len(ns); l != 0 { return types.NewDetailedErr(types.ErrPodHasNodes, fmt.Sprintf("pod %s still has %d nodes, delete them first", podname, l)) } _, err = m.Delete(ctx, key) return err }
[ "func", "(", "m", "*", "Mercury", ")", "RemovePod", "(", "ctx", "context", ".", "Context", ",", "podname", "string", ")", "error", "{", "key", ":=", "fmt", ".", "Sprintf", "(", "podInfoKey", ",", "podname", ")", "\n\n", "ns", ",", "err", ":=", "m", ...
// RemovePod if the pod has no nodes left, otherwise return an error
[ "RemovePod", "if", "the", "pod", "has", "no", "nodes", "left", "otherwise", "return", "an", "error" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/store/etcdv3/pod.go#L54-L69
16,153
projecteru2/core
cluster/calcium/network.go
ListNetworks
func (c *Calcium) ListNetworks(ctx context.Context, podname string, driver string) ([]*enginetypes.Network, error) { networks := []*enginetypes.Network{} nodes, err := c.ListPodNodes(ctx, podname, false) if err != nil { return networks, err } if len(nodes) == 0 { return networks, types.NewDetailedErr(types.ErrPodNoNodes, podname) } drivers := []string{} if driver != "" { drivers = append(drivers, driver) } node := nodes[0] return node.Engine.NetworkList(ctx, drivers) }
go
func (c *Calcium) ListNetworks(ctx context.Context, podname string, driver string) ([]*enginetypes.Network, error) { networks := []*enginetypes.Network{} nodes, err := c.ListPodNodes(ctx, podname, false) if err != nil { return networks, err } if len(nodes) == 0 { return networks, types.NewDetailedErr(types.ErrPodNoNodes, podname) } drivers := []string{} if driver != "" { drivers = append(drivers, driver) } node := nodes[0] return node.Engine.NetworkList(ctx, drivers) }
[ "func", "(", "c", "*", "Calcium", ")", "ListNetworks", "(", "ctx", "context", ".", "Context", ",", "podname", "string", ",", "driver", "string", ")", "(", "[", "]", "*", "enginetypes", ".", "Network", ",", "error", ")", "{", "networks", ":=", "[", "]...
// ListNetworks by podname // get one node from a pod // and list networks // only get those driven by network driver
[ "ListNetworks", "by", "podname", "get", "one", "node", "from", "a", "pod", "and", "list", "networks", "only", "get", "those", "driven", "by", "network", "driver" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/cluster/calcium/network.go#L14-L32
16,154
projecteru2/core
engine/docker/helper.go
FuckDockerStream
func FuckDockerStream(stream dockertypes.HijackedResponse) io.ReadCloser { outr := mergeStream(ioutil.NopCloser(stream.Reader)) return fuckDockerStream{stream.Conn, outr} }
go
func FuckDockerStream(stream dockertypes.HijackedResponse) io.ReadCloser { outr := mergeStream(ioutil.NopCloser(stream.Reader)) return fuckDockerStream{stream.Conn, outr} }
[ "func", "FuckDockerStream", "(", "stream", "dockertypes", ".", "HijackedResponse", ")", "io", ".", "ReadCloser", "{", "outr", ":=", "mergeStream", "(", "ioutil", ".", "NopCloser", "(", "stream", ".", "Reader", ")", ")", "\n", "return", "fuckDockerStream", "{",...
// FuckDockerStream will copy docker stream to stdout and err
[ "FuckDockerStream", "will", "copy", "docker", "stream", "to", "stdout", "and", "err" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/engine/docker/helper.go#L71-L74
16,155
projecteru2/core
engine/docker/helper.go
CreateTarStream
func CreateTarStream(path string) (io.ReadCloser, error) { tarOpts := &archive.TarOptions{ ExcludePatterns: []string{}, IncludeFiles: []string{"."}, Compression: archive.Uncompressed, NoLchown: true, } tar, err := archive.TarWithOptions(path, tarOpts) if err != nil { return nil, err } return buildContext{path, tar}, nil }
go
func CreateTarStream(path string) (io.ReadCloser, error) { tarOpts := &archive.TarOptions{ ExcludePatterns: []string{}, IncludeFiles: []string{"."}, Compression: archive.Uncompressed, NoLchown: true, } tar, err := archive.TarWithOptions(path, tarOpts) if err != nil { return nil, err } return buildContext{path, tar}, nil }
[ "func", "CreateTarStream", "(", "path", "string", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "tarOpts", ":=", "&", "archive", ".", "TarOptions", "{", "ExcludePatterns", ":", "[", "]", "string", "{", "}", ",", "IncludeFiles", ":", "[", "...
// CreateTarStream create a tar stream
[ "CreateTarStream", "create", "a", "tar", "stream" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/engine/docker/helper.go#L233-L245
16,156
projecteru2/core
engine/docker/helper.go
GetIP
func GetIP(daemonHost string) string { u, err := url.Parse(daemonHost) if err != nil { log.Errorf("[GetIP] GetIP %s failed %v", daemonHost, err) return "" } return u.Hostname() }
go
func GetIP(daemonHost string) string { u, err := url.Parse(daemonHost) if err != nil { log.Errorf("[GetIP] GetIP %s failed %v", daemonHost, err) return "" } return u.Hostname() }
[ "func", "GetIP", "(", "daemonHost", "string", ")", "string", "{", "u", ",", "err", ":=", "url", ".", "Parse", "(", "daemonHost", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Errorf", "(", "\"", "\"", ",", "daemonHost", ",", "err", ")", ...
// GetIP Get hostIP
[ "GetIP", "Get", "hostIP" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/engine/docker/helper.go#L248-L255
16,157
projecteru2/core
store/etcdv3/node.go
DeleteNode
func (m *Mercury) DeleteNode(ctx context.Context, node *types.Node) { if node == nil { return } m.doDeleteNode(ctx, node.Podname, node.Name, node.Endpoint) }
go
func (m *Mercury) DeleteNode(ctx context.Context, node *types.Node) { if node == nil { return } m.doDeleteNode(ctx, node.Podname, node.Name, node.Endpoint) }
[ "func", "(", "m", "*", "Mercury", ")", "DeleteNode", "(", "ctx", "context", ".", "Context", ",", "node", "*", "types", ".", "Node", ")", "{", "if", "node", "==", "nil", "{", "return", "\n", "}", "\n", "m", ".", "doDeleteNode", "(", "ctx", ",", "n...
// DeleteNode delete a node
[ "DeleteNode", "delete", "a", "node" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/store/etcdv3/node.go#L72-L77
16,158
projecteru2/core
store/etcdv3/node.go
GetAllNodes
func (m *Mercury) GetAllNodes(ctx context.Context) ([]*types.Node, error) { pods, err := m.GetAllPods(ctx) if err != nil { return []*types.Node{}, err } nodes := []*types.Node{} for _, pod := range pods { ns, err := m.GetNodesByPod(ctx, pod.Name) if err != nil { return nodes, err } nodes = append(nodes, ns...) } return nodes, err }
go
func (m *Mercury) GetAllNodes(ctx context.Context) ([]*types.Node, error) { pods, err := m.GetAllPods(ctx) if err != nil { return []*types.Node{}, err } nodes := []*types.Node{} for _, pod := range pods { ns, err := m.GetNodesByPod(ctx, pod.Name) if err != nil { return nodes, err } nodes = append(nodes, ns...) } return nodes, err }
[ "func", "(", "m", "*", "Mercury", ")", "GetAllNodes", "(", "ctx", "context", ".", "Context", ")", "(", "[", "]", "*", "types", ".", "Node", ",", "error", ")", "{", "pods", ",", "err", ":=", "m", ".", "GetAllPods", "(", "ctx", ")", "\n", "if", "...
// GetAllNodes get all nodes from etcd // any error will break and return immediately
[ "GetAllNodes", "get", "all", "nodes", "from", "etcd", "any", "error", "will", "break", "and", "return", "immediately" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/store/etcdv3/node.go#L137-L152
16,159
projecteru2/core
store/etcdv3/node.go
UpdateNodeResource
func (m *Mercury) UpdateNodeResource(ctx context.Context, node *types.Node, cpu types.CPUMap, quota float64, mem int64, action string) error { switch action { case store.ActionIncr: node.CPU.Add(cpu) node.SetCPUUsed(quota, types.DecrUsage) node.MemCap += mem case store.ActionDecr: node.CPU.Sub(cpu) node.SetCPUUsed(quota, types.IncrUsage) node.MemCap -= mem default: return types.ErrUnknownControlType } go metrics.Client.SendNodeInfo(node) return m.UpdateNode(ctx, node) }
go
func (m *Mercury) UpdateNodeResource(ctx context.Context, node *types.Node, cpu types.CPUMap, quota float64, mem int64, action string) error { switch action { case store.ActionIncr: node.CPU.Add(cpu) node.SetCPUUsed(quota, types.DecrUsage) node.MemCap += mem case store.ActionDecr: node.CPU.Sub(cpu) node.SetCPUUsed(quota, types.IncrUsage) node.MemCap -= mem default: return types.ErrUnknownControlType } go metrics.Client.SendNodeInfo(node) return m.UpdateNode(ctx, node) }
[ "func", "(", "m", "*", "Mercury", ")", "UpdateNodeResource", "(", "ctx", "context", ".", "Context", ",", "node", "*", "types", ".", "Node", ",", "cpu", "types", ".", "CPUMap", ",", "quota", "float64", ",", "mem", "int64", ",", "action", "string", ")", ...
// UpdateNodeResource update cpu and mem on a node, either add or subtract
[ "UpdateNodeResource", "update", "cpu", "and", "mem", "on", "a", "node", "either", "add", "or", "subtract" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/store/etcdv3/node.go#L170-L186
16,160
projecteru2/core
cluster/calcium/replace.go
ReplaceContainer
func (c *Calcium) ReplaceContainer(ctx context.Context, opts *types.ReplaceOptions) (chan *types.ReplaceContainerMessage, error) { if len(opts.IDs) == 0 { oldContainers, err := c.ListContainers(ctx, &types.ListContainersOptions{ Appname: opts.Name, Entrypoint: opts.Entrypoint.Name, Nodename: opts.Nodename, }) if err != nil { return nil, err } for _, container := range oldContainers { opts.IDs = append(opts.IDs, container.ID) } } ch := make(chan *types.ReplaceContainerMessage) go func() { defer close(ch) // ๅนถๅ‘ๆŽงๅˆถ step := opts.Count wg := sync.WaitGroup{} defer wg.Wait() for index, ID := range opts.IDs { container, containerJSON, containerLock, err := c.doLockAndGetContainer(ctx, ID) if err != nil { log.Errorf("[ReplaceContainer] Get container %s failed %v", ID, err) continue } if opts.Podname != "" && container.Podname != opts.Podname { log.Warnf("[ReplaceContainer] Skip not in pod container %s", container.ID) c.doUnlock(containerLock, container.ID) continue } log.Infof("[ReplaceContainer] Replace old container %s", container.ID) wg.Add(1) go func(replaceOpts types.ReplaceOptions, container *types.Container, containerJSON *enginetypes.VirtualizationInfo, containerLock lock.DistributedLock, index int) { defer wg.Done() defer c.doUnlock(containerLock, container.ID) // ไฝฟ็”จๅคๅˆถไน‹ๅŽ็š„้…็ฝฎ // ๅœ่€็š„๏ผŒ่ตทๆ–ฐ็š„ replaceOpts.Memory = container.Memory replaceOpts.CPUQuota = container.Quota replaceOpts.SoftLimit = container.SoftLimit // ่ฆ†็›– podname ๅฆ‚ๆžœๅšๅ…จ้‡ๆ›ดๆ–ฐ็š„่ฏ replaceOpts.Podname = container.Podname // ็ปงๆ‰ฟ็ฝ‘็ปœ้…็ฝฎ if replaceOpts.NetworkInherit { log.Infof("[ReplaceContainer] Inherit old container network configuration mode %v", containerJSON.Networks) replaceOpts.NetworkMode = "" replaceOpts.Networks = containerJSON.Networks } createMessage, removeMessage, err := c.doReplaceContainer( ctx, container, containerJSON, &replaceOpts, index, ) ch <- &types.ReplaceContainerMessage{ Create: createMessage, Remove: removeMessage, Error: err, } if err != nil { log.Errorf("[ReplaceContainer] Replace and remove failed %v, old container restarted", err) return } log.Infof("[ReplaceContainer] Replace and remove success %s", container.ID) // ไผ  opts ็š„ๅ€ผ๏ผŒไบง็”Ÿไธ€ๆฌกๅคๅˆถ }(*opts, container, containerJSON, containerLock, index) if (index+1)%step == 0 { wg.Wait() } } }() return ch, nil }
go
func (c *Calcium) ReplaceContainer(ctx context.Context, opts *types.ReplaceOptions) (chan *types.ReplaceContainerMessage, error) { if len(opts.IDs) == 0 { oldContainers, err := c.ListContainers(ctx, &types.ListContainersOptions{ Appname: opts.Name, Entrypoint: opts.Entrypoint.Name, Nodename: opts.Nodename, }) if err != nil { return nil, err } for _, container := range oldContainers { opts.IDs = append(opts.IDs, container.ID) } } ch := make(chan *types.ReplaceContainerMessage) go func() { defer close(ch) // ๅนถๅ‘ๆŽงๅˆถ step := opts.Count wg := sync.WaitGroup{} defer wg.Wait() for index, ID := range opts.IDs { container, containerJSON, containerLock, err := c.doLockAndGetContainer(ctx, ID) if err != nil { log.Errorf("[ReplaceContainer] Get container %s failed %v", ID, err) continue } if opts.Podname != "" && container.Podname != opts.Podname { log.Warnf("[ReplaceContainer] Skip not in pod container %s", container.ID) c.doUnlock(containerLock, container.ID) continue } log.Infof("[ReplaceContainer] Replace old container %s", container.ID) wg.Add(1) go func(replaceOpts types.ReplaceOptions, container *types.Container, containerJSON *enginetypes.VirtualizationInfo, containerLock lock.DistributedLock, index int) { defer wg.Done() defer c.doUnlock(containerLock, container.ID) // ไฝฟ็”จๅคๅˆถไน‹ๅŽ็š„้…็ฝฎ // ๅœ่€็š„๏ผŒ่ตทๆ–ฐ็š„ replaceOpts.Memory = container.Memory replaceOpts.CPUQuota = container.Quota replaceOpts.SoftLimit = container.SoftLimit // ่ฆ†็›– podname ๅฆ‚ๆžœๅšๅ…จ้‡ๆ›ดๆ–ฐ็š„่ฏ replaceOpts.Podname = container.Podname // ็ปงๆ‰ฟ็ฝ‘็ปœ้…็ฝฎ if replaceOpts.NetworkInherit { log.Infof("[ReplaceContainer] Inherit old container network configuration mode %v", containerJSON.Networks) replaceOpts.NetworkMode = "" replaceOpts.Networks = containerJSON.Networks } createMessage, removeMessage, err := c.doReplaceContainer( ctx, container, containerJSON, &replaceOpts, index, ) ch <- &types.ReplaceContainerMessage{ Create: createMessage, Remove: removeMessage, Error: err, } if err != nil { log.Errorf("[ReplaceContainer] Replace and remove failed %v, old container restarted", err) return } log.Infof("[ReplaceContainer] Replace and remove success %s", container.ID) // ไผ  opts ็š„ๅ€ผ๏ผŒไบง็”Ÿไธ€ๆฌกๅคๅˆถ }(*opts, container, containerJSON, containerLock, index) if (index+1)%step == 0 { wg.Wait() } } }() return ch, nil }
[ "func", "(", "c", "*", "Calcium", ")", "ReplaceContainer", "(", "ctx", "context", ".", "Context", ",", "opts", "*", "types", ".", "ReplaceOptions", ")", "(", "chan", "*", "types", ".", "ReplaceContainerMessage", ",", "error", ")", "{", "if", "len", "(", ...
// ReplaceContainer replace containers with same resource
[ "ReplaceContainer", "replace", "containers", "with", "same", "resource" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/cluster/calcium/replace.go#L16-L89
16,161
projecteru2/core
cluster/calcium/build.go
BuildImage
func (c *Calcium) BuildImage(ctx context.Context, opts *enginetypes.BuildOptions) (chan *types.BuildImageMessage, error) { // Disable build API if scm not set if c.source == nil { return nil, types.ErrSCMNotSet } // select nodes node, err := c.selectBuildNode(ctx) if err != nil { return nil, err } log.Infof("[BuildImage] Building image at pod %s node %s", node.Podname, node.Name) // get refs refs := node.Engine.BuildRefs(ctx, opts.Name, opts.Tags) // support raw build buildContent := opts.Tar if opts.Builds != nil { buildContent, err = node.Engine.BuildContent(ctx, c.source, opts) if err != nil { return nil, err } } return c.doBuildImage(ctx, buildContent, node, refs) }
go
func (c *Calcium) BuildImage(ctx context.Context, opts *enginetypes.BuildOptions) (chan *types.BuildImageMessage, error) { // Disable build API if scm not set if c.source == nil { return nil, types.ErrSCMNotSet } // select nodes node, err := c.selectBuildNode(ctx) if err != nil { return nil, err } log.Infof("[BuildImage] Building image at pod %s node %s", node.Podname, node.Name) // get refs refs := node.Engine.BuildRefs(ctx, opts.Name, opts.Tags) // support raw build buildContent := opts.Tar if opts.Builds != nil { buildContent, err = node.Engine.BuildContent(ctx, c.source, opts) if err != nil { return nil, err } } return c.doBuildImage(ctx, buildContent, node, refs) }
[ "func", "(", "c", "*", "Calcium", ")", "BuildImage", "(", "ctx", "context", ".", "Context", ",", "opts", "*", "enginetypes", ".", "BuildOptions", ")", "(", "chan", "*", "types", ".", "BuildImageMessage", ",", "error", ")", "{", "// Disable build API if scm n...
// BuildImage will build image
[ "BuildImage", "will", "build", "image" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/cluster/calcium/build.go#L15-L38
16,162
projecteru2/core
auth/simple/credential.go
GetRequestMetadata
func (c BasicCredential) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { return map[string]string{ c.username: c.password, }, nil }
go
func (c BasicCredential) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { return map[string]string{ c.username: c.password, }, nil }
[ "func", "(", "c", "BasicCredential", ")", "GetRequestMetadata", "(", "ctx", "context", ".", "Context", ",", "uri", "...", "string", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "return", "map", "[", "string", "]", "string", "{...
// GetRequestMetadata for basic auth
[ "GetRequestMetadata", "for", "basic", "auth" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/auth/simple/credential.go#L17-L21
16,163
projecteru2/core
cluster/calcium/copy.go
Copy
func (c *Calcium) Copy(ctx context.Context, opts *types.CopyOptions) (chan *types.CopyMessage, error) { ch := make(chan *types.CopyMessage) go func() { defer close(ch) wg := sync.WaitGroup{} log.Infof("[Copy] Copy %d containers files", len(opts.Targets)) // container one by one for cid, paths := range opts.Targets { wg.Add(1) go func(cid string, paths []string) { defer wg.Done() container, err := c.GetContainer(ctx, cid) if err != nil { log.Errorf("[Copy] Error when get container %s, err %v", cid, err) ch <- makeCopyMessage(cid, cluster.CopyFailed, "", "", err, nil) return } for _, path := range paths { wg.Add(1) go func(path string) { defer wg.Done() resp, name, err := container.Engine.VirtualizationCopyFrom(ctx, container.ID, path) if err != nil { log.Errorf("[Copy] Error during CopyFromContainer: %v", err) ch <- makeCopyMessage(cid, cluster.CopyFailed, "", path, err, nil) return } ch <- makeCopyMessage(cid, cluster.CopyOK, name, path, nil, resp) }(path) } }(cid, paths) } wg.Wait() }() return ch, nil }
go
func (c *Calcium) Copy(ctx context.Context, opts *types.CopyOptions) (chan *types.CopyMessage, error) { ch := make(chan *types.CopyMessage) go func() { defer close(ch) wg := sync.WaitGroup{} log.Infof("[Copy] Copy %d containers files", len(opts.Targets)) // container one by one for cid, paths := range opts.Targets { wg.Add(1) go func(cid string, paths []string) { defer wg.Done() container, err := c.GetContainer(ctx, cid) if err != nil { log.Errorf("[Copy] Error when get container %s, err %v", cid, err) ch <- makeCopyMessage(cid, cluster.CopyFailed, "", "", err, nil) return } for _, path := range paths { wg.Add(1) go func(path string) { defer wg.Done() resp, name, err := container.Engine.VirtualizationCopyFrom(ctx, container.ID, path) if err != nil { log.Errorf("[Copy] Error during CopyFromContainer: %v", err) ch <- makeCopyMessage(cid, cluster.CopyFailed, "", path, err, nil) return } ch <- makeCopyMessage(cid, cluster.CopyOK, name, path, nil, resp) }(path) } }(cid, paths) } wg.Wait() }() return ch, nil }
[ "func", "(", "c", "*", "Calcium", ")", "Copy", "(", "ctx", "context", ".", "Context", ",", "opts", "*", "types", ".", "CopyOptions", ")", "(", "chan", "*", "types", ".", "CopyMessage", ",", "error", ")", "{", "ch", ":=", "make", "(", "chan", "*", ...
// Copy uses VirtualizationCopyFrom cp to copy specified things and send to remote
[ "Copy", "uses", "VirtualizationCopyFrom", "cp", "to", "copy", "specified", "things", "and", "send", "to", "remote" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/cluster/calcium/copy.go#L13-L48
16,164
projecteru2/core
store/etcdv3/container.go
UpdateContainer
func (m *Mercury) UpdateContainer(ctx context.Context, container *types.Container) error { return m.doOpsContainer(ctx, container, false) }
go
func (m *Mercury) UpdateContainer(ctx context.Context, container *types.Container) error { return m.doOpsContainer(ctx, container, false) }
[ "func", "(", "m", "*", "Mercury", ")", "UpdateContainer", "(", "ctx", "context", ".", "Context", ",", "container", "*", "types", ".", "Container", ")", "error", "{", "return", "m", ".", "doOpsContainer", "(", "ctx", ",", "container", ",", "false", ")", ...
// UpdateContainer update a container
[ "UpdateContainer", "update", "a", "container" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/store/etcdv3/container.go#L26-L28
16,165
projecteru2/core
store/etcdv3/container.go
RemoveContainer
func (m *Mercury) RemoveContainer(ctx context.Context, container *types.Container) error { if l := len(container.ID); l != 64 { return types.NewDetailedErr(types.ErrBadContainerID, fmt.Sprintf("containerID: %s, length: %d", container.ID, len(container.ID))) } appname, entrypoint, _, err := utils.ParseContainerName(container.Name) if err != nil { return err } return m.CleanContainerData(ctx, container.ID, appname, entrypoint, container.Nodename) }
go
func (m *Mercury) RemoveContainer(ctx context.Context, container *types.Container) error { if l := len(container.ID); l != 64 { return types.NewDetailedErr(types.ErrBadContainerID, fmt.Sprintf("containerID: %s, length: %d", container.ID, len(container.ID))) } appname, entrypoint, _, err := utils.ParseContainerName(container.Name) if err != nil { return err } return m.CleanContainerData(ctx, container.ID, appname, entrypoint, container.Nodename) }
[ "func", "(", "m", "*", "Mercury", ")", "RemoveContainer", "(", "ctx", "context", ".", "Context", ",", "container", "*", "types", ".", "Container", ")", "error", "{", "if", "l", ":=", "len", "(", "container", ".", "ID", ")", ";", "l", "!=", "64", "{...
// RemoveContainer remove a container // container id must be in full length
[ "RemoveContainer", "remove", "a", "container", "container", "id", "must", "be", "in", "full", "length" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/store/etcdv3/container.go#L32-L44
16,166
projecteru2/core
store/etcdv3/container.go
CleanContainerData
func (m *Mercury) CleanContainerData(ctx context.Context, ID, appname, entrypoint, nodename string) error { keys := []string{ fmt.Sprintf(containerInfoKey, ID), filepath.Join(containerDeployPrefix, appname, entrypoint, nodename, ID), fmt.Sprintf(nodeContainersKey, nodename, ID), } _, err := m.BatchDelete(ctx, keys) return err }
go
func (m *Mercury) CleanContainerData(ctx context.Context, ID, appname, entrypoint, nodename string) error { keys := []string{ fmt.Sprintf(containerInfoKey, ID), filepath.Join(containerDeployPrefix, appname, entrypoint, nodename, ID), fmt.Sprintf(nodeContainersKey, nodename, ID), } _, err := m.BatchDelete(ctx, keys) return err }
[ "func", "(", "m", "*", "Mercury", ")", "CleanContainerData", "(", "ctx", "context", ".", "Context", ",", "ID", ",", "appname", ",", "entrypoint", ",", "nodename", "string", ")", "error", "{", "keys", ":=", "[", "]", "string", "{", "fmt", ".", "Sprintf"...
// CleanContainerData clean container data
[ "CleanContainerData", "clean", "container", "data" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/store/etcdv3/container.go#L47-L55
16,167
projecteru2/core
store/etcdv3/container.go
ContainerDeployed
func (m *Mercury) ContainerDeployed(ctx context.Context, ID, appname, entrypoint, nodename, data string) error { key := filepath.Join(containerDeployPrefix, appname, entrypoint, nodename, ID) //Only update when it exist _, err := m.Update(ctx, key, data) return err }
go
func (m *Mercury) ContainerDeployed(ctx context.Context, ID, appname, entrypoint, nodename, data string) error { key := filepath.Join(containerDeployPrefix, appname, entrypoint, nodename, ID) //Only update when it exist _, err := m.Update(ctx, key, data) return err }
[ "func", "(", "m", "*", "Mercury", ")", "ContainerDeployed", "(", "ctx", "context", ".", "Context", ",", "ID", ",", "appname", ",", "entrypoint", ",", "nodename", ",", "data", "string", ")", "error", "{", "key", ":=", "filepath", ".", "Join", "(", "cont...
// ContainerDeployed store deployed container info
[ "ContainerDeployed", "store", "deployed", "container", "info" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/store/etcdv3/container.go#L98-L103
16,168
projecteru2/core
store/etcdv3/container.go
WatchDeployStatus
func (m *Mercury) WatchDeployStatus(ctx context.Context, appname, entrypoint, nodename string) chan *types.DeployStatus { if appname == "" { entrypoint = "" } if entrypoint == "" { nodename = "" } // ๆ˜พๅผๅŠ ไธช / ไฟ่ฏ prefix ๅ”ฏไธ€ key := filepath.Join(containerDeployPrefix, appname, entrypoint, nodename) + "/" ch := make(chan *types.DeployStatus) go func() { defer close(ch) for resp := range m.Watch(ctx, key, clientv3.WithPrefix()) { msg := &types.DeployStatus{} if resp.Err() != nil { if !resp.Canceled { msg.Err = resp.Err() ch <- msg } return } for _, ev := range resp.Events { appname, entrypoint, nodename, id := parseStatusKey(string(ev.Kv.Key)) msg.Data = string(ev.Kv.Value) msg.Action = ev.Type.String() msg.Appname = appname msg.Entrypoint = entrypoint msg.Nodename = nodename msg.ID = id log.Debugf("[WatchDeployStatus] app %s_%s event, id %s, action %s", appname, entrypoint, utils.ShortID(msg.ID), msg.Action) if msg.Data != "" { log.Debugf("[WatchDeployStatus] data %s", msg.Data) } ch <- msg } } }() return ch }
go
func (m *Mercury) WatchDeployStatus(ctx context.Context, appname, entrypoint, nodename string) chan *types.DeployStatus { if appname == "" { entrypoint = "" } if entrypoint == "" { nodename = "" } // ๆ˜พๅผๅŠ ไธช / ไฟ่ฏ prefix ๅ”ฏไธ€ key := filepath.Join(containerDeployPrefix, appname, entrypoint, nodename) + "/" ch := make(chan *types.DeployStatus) go func() { defer close(ch) for resp := range m.Watch(ctx, key, clientv3.WithPrefix()) { msg := &types.DeployStatus{} if resp.Err() != nil { if !resp.Canceled { msg.Err = resp.Err() ch <- msg } return } for _, ev := range resp.Events { appname, entrypoint, nodename, id := parseStatusKey(string(ev.Kv.Key)) msg.Data = string(ev.Kv.Value) msg.Action = ev.Type.String() msg.Appname = appname msg.Entrypoint = entrypoint msg.Nodename = nodename msg.ID = id log.Debugf("[WatchDeployStatus] app %s_%s event, id %s, action %s", appname, entrypoint, utils.ShortID(msg.ID), msg.Action) if msg.Data != "" { log.Debugf("[WatchDeployStatus] data %s", msg.Data) } ch <- msg } } }() return ch }
[ "func", "(", "m", "*", "Mercury", ")", "WatchDeployStatus", "(", "ctx", "context", ".", "Context", ",", "appname", ",", "entrypoint", ",", "nodename", "string", ")", "chan", "*", "types", ".", "DeployStatus", "{", "if", "appname", "==", "\"", "\"", "{", ...
// WatchDeployStatus watch deployed status
[ "WatchDeployStatus", "watch", "deployed", "status" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/store/etcdv3/container.go#L154-L192
16,169
projecteru2/core
scheduler/complex/fill.go
FillPlan
func FillPlan(nodesInfo []types.NodeInfo, need, limit int) ([]types.NodeInfo, error) { log.Debugf("[FillPlan] need %d limit %d", need, limit) nodesInfoLength := len(nodesInfo) sort.Slice(nodesInfo, func(i, j int) bool { return nodesInfo[i].Count > nodesInfo[j].Count }) p := sort.Search(nodesInfoLength, func(i int) bool { return nodesInfo[i].Count < need }) if p == nodesInfoLength { return nil, types.ErrAlreadyFilled } nodesInfo = nodesInfo[p:] if limit > 0 && len(nodesInfo) > limit { nodesInfo = nodesInfo[:limit] } for i := range nodesInfo { diff := need - nodesInfo[i].Count if nodesInfo[i].Capacity < diff { return nil, types.NewDetailedErr(types.ErrInsufficientRes, fmt.Sprintf("node %s cannot alloc a fill node plan", nodesInfo[i].Name)) } nodesInfo[i].Deploy = diff nodesInfo[i].Capacity -= diff } log.Debugf("[FillPlan] nodesInfo: %v", nodesInfo) return nodesInfo, nil }
go
func FillPlan(nodesInfo []types.NodeInfo, need, limit int) ([]types.NodeInfo, error) { log.Debugf("[FillPlan] need %d limit %d", need, limit) nodesInfoLength := len(nodesInfo) sort.Slice(nodesInfo, func(i, j int) bool { return nodesInfo[i].Count > nodesInfo[j].Count }) p := sort.Search(nodesInfoLength, func(i int) bool { return nodesInfo[i].Count < need }) if p == nodesInfoLength { return nil, types.ErrAlreadyFilled } nodesInfo = nodesInfo[p:] if limit > 0 && len(nodesInfo) > limit { nodesInfo = nodesInfo[:limit] } for i := range nodesInfo { diff := need - nodesInfo[i].Count if nodesInfo[i].Capacity < diff { return nil, types.NewDetailedErr(types.ErrInsufficientRes, fmt.Sprintf("node %s cannot alloc a fill node plan", nodesInfo[i].Name)) } nodesInfo[i].Deploy = diff nodesInfo[i].Capacity -= diff } log.Debugf("[FillPlan] nodesInfo: %v", nodesInfo) return nodesInfo, nil }
[ "func", "FillPlan", "(", "nodesInfo", "[", "]", "types", ".", "NodeInfo", ",", "need", ",", "limit", "int", ")", "(", "[", "]", "types", ".", "NodeInfo", ",", "error", ")", "{", "log", ".", "Debugf", "(", "\"", "\"", ",", "need", ",", "limit", ")...
// FillPlan deploy container each node
[ "FillPlan", "deploy", "container", "each", "node" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/scheduler/complex/fill.go#L12-L35
16,170
projecteru2/core
cluster/calcium/calcium.go
New
func New(config types.Config, embededStorage bool) (*Calcium, error) { // set store store, err := etcdv3.New(config, embededStorage) if err != nil { return nil, err } // set scheduler scheduler, err := complexscheduler.New(config) if err != nil { return nil, err } // set scm var scm source.Source scmtype := strings.ToLower(config.Git.SCMType) switch scmtype { case cluster.Gitlab: scm = gitlab.New(config) case cluster.Github: scm = github.New(config) default: log.Warn("[Calcium] SCM not set, build API disable") } return &Calcium{store: store, config: config, scheduler: scheduler, source: scm}, nil }
go
func New(config types.Config, embededStorage bool) (*Calcium, error) { // set store store, err := etcdv3.New(config, embededStorage) if err != nil { return nil, err } // set scheduler scheduler, err := complexscheduler.New(config) if err != nil { return nil, err } // set scm var scm source.Source scmtype := strings.ToLower(config.Git.SCMType) switch scmtype { case cluster.Gitlab: scm = gitlab.New(config) case cluster.Github: scm = github.New(config) default: log.Warn("[Calcium] SCM not set, build API disable") } return &Calcium{store: store, config: config, scheduler: scheduler, source: scm}, nil }
[ "func", "New", "(", "config", "types", ".", "Config", ",", "embededStorage", "bool", ")", "(", "*", "Calcium", ",", "error", ")", "{", "// set store", "store", ",", "err", ":=", "etcdv3", ".", "New", "(", "config", ",", "embededStorage", ")", "\n", "if...
// New returns a new cluster config
[ "New", "returns", "a", "new", "cluster", "config" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/cluster/calcium/calcium.go#L27-L53
16,171
projecteru2/core
engine/docker/network.go
NetworkConnect
func (e *Engine) NetworkConnect(ctx context.Context, network, target, ipv4, ipv6 string) error { config, err := e.makeIPV4EndpointSetting(ipv4) if err != nil { return err } return e.client.NetworkConnect(ctx, network, target, config) }
go
func (e *Engine) NetworkConnect(ctx context.Context, network, target, ipv4, ipv6 string) error { config, err := e.makeIPV4EndpointSetting(ipv4) if err != nil { return err } return e.client.NetworkConnect(ctx, network, target, config) }
[ "func", "(", "e", "*", "Engine", ")", "NetworkConnect", "(", "ctx", "context", ".", "Context", ",", "network", ",", "target", ",", "ipv4", ",", "ipv6", "string", ")", "error", "{", "config", ",", "err", ":=", "e", ".", "makeIPV4EndpointSetting", "(", "...
// NetworkConnect connect to a network
[ "NetworkConnect", "connect", "to", "a", "network" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/engine/docker/network.go#L32-L38
16,172
projecteru2/core
engine/docker/network.go
NetworkDisconnect
func (e *Engine) NetworkDisconnect(ctx context.Context, network, target string, force bool) error { return e.client.NetworkDisconnect(ctx, network, target, force) }
go
func (e *Engine) NetworkDisconnect(ctx context.Context, network, target string, force bool) error { return e.client.NetworkDisconnect(ctx, network, target, force) }
[ "func", "(", "e", "*", "Engine", ")", "NetworkDisconnect", "(", "ctx", "context", ".", "Context", ",", "network", ",", "target", "string", ",", "force", "bool", ")", "error", "{", "return", "e", ".", "client", ".", "NetworkDisconnect", "(", "ctx", ",", ...
// NetworkDisconnect disconnect from a network
[ "NetworkDisconnect", "disconnect", "from", "a", "network" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/engine/docker/network.go#L41-L43
16,173
projecteru2/core
engine/docker/network.go
NetworkList
func (e *Engine) NetworkList(ctx context.Context, drivers []string) ([]*enginetypes.Network, error) { networks := []*enginetypes.Network{} filters := dockerfilters.NewArgs() for _, driver := range drivers { filters.Add("driver", driver) } ns, err := e.client.NetworkList(ctx, dockertypes.NetworkListOptions{Filters: filters}) if err != nil { return networks, err } for _, n := range ns { subnets := []string{} for _, config := range n.IPAM.Config { subnets = append(subnets, config.Subnet) } networks = append(networks, &enginetypes.Network{Name: n.Name, Subnets: subnets}) } return networks, nil }
go
func (e *Engine) NetworkList(ctx context.Context, drivers []string) ([]*enginetypes.Network, error) { networks := []*enginetypes.Network{} filters := dockerfilters.NewArgs() for _, driver := range drivers { filters.Add("driver", driver) } ns, err := e.client.NetworkList(ctx, dockertypes.NetworkListOptions{Filters: filters}) if err != nil { return networks, err } for _, n := range ns { subnets := []string{} for _, config := range n.IPAM.Config { subnets = append(subnets, config.Subnet) } networks = append(networks, &enginetypes.Network{Name: n.Name, Subnets: subnets}) } return networks, nil }
[ "func", "(", "e", "*", "Engine", ")", "NetworkList", "(", "ctx", "context", ".", "Context", ",", "drivers", "[", "]", "string", ")", "(", "[", "]", "*", "enginetypes", ".", "Network", ",", "error", ")", "{", "networks", ":=", "[", "]", "*", "engine...
// NetworkList show all networks
[ "NetworkList", "show", "all", "networks" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/engine/docker/network.go#L46-L66
16,174
projecteru2/core
types/helper.go
HookOutput
func HookOutput(outputs []*bytes.Buffer) []byte { r := []byte{} for _, m := range outputs { r = append(r, m.Bytes()...) } return r }
go
func HookOutput(outputs []*bytes.Buffer) []byte { r := []byte{} for _, m := range outputs { r = append(r, m.Bytes()...) } return r }
[ "func", "HookOutput", "(", "outputs", "[", "]", "*", "bytes", ".", "Buffer", ")", "[", "]", "byte", "{", "r", ":=", "[", "]", "byte", "{", "}", "\n", "for", "_", ",", "m", ":=", "range", "outputs", "{", "r", "=", "append", "(", "r", ",", "m",...
// HookOutput output hooks output
[ "HookOutput", "output", "hooks", "output" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/types/helper.go#L14-L20
16,175
projecteru2/core
rpc/rpc.go
AddPod
func (v *Vibranium) AddPod(ctx context.Context, opts *pb.AddPodOptions) (*pb.Pod, error) { p, err := v.cluster.AddPod(ctx, opts.Name, opts.Favor, opts.Desc) if err != nil { return nil, err } return toRPCPod(p), nil }
go
func (v *Vibranium) AddPod(ctx context.Context, opts *pb.AddPodOptions) (*pb.Pod, error) { p, err := v.cluster.AddPod(ctx, opts.Name, opts.Favor, opts.Desc) if err != nil { return nil, err } return toRPCPod(p), nil }
[ "func", "(", "v", "*", "Vibranium", ")", "AddPod", "(", "ctx", "context", ".", "Context", ",", "opts", "*", "pb", ".", "AddPodOptions", ")", "(", "*", "pb", ".", "Pod", ",", "error", ")", "{", "p", ",", "err", ":=", "v", ".", "cluster", ".", "A...
// AddPod saves a pod, and returns it to client
[ "AddPod", "saves", "a", "pod", "and", "returns", "it", "to", "client" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/rpc/rpc.go#L29-L36
16,176
projecteru2/core
rpc/rpc.go
AddNode
func (v *Vibranium) AddNode(ctx context.Context, opts *pb.AddNodeOptions) (*pb.Node, error) { n, err := v.cluster.AddNode( ctx, opts.Nodename, opts.Endpoint, opts.Podname, opts.Ca, opts.Cert, opts.Key, int(opts.Cpu), int(opts.Share), opts.Memory, opts.Labels, ) if err != nil { return nil, err } return toRPCNode(ctx, n), nil }
go
func (v *Vibranium) AddNode(ctx context.Context, opts *pb.AddNodeOptions) (*pb.Node, error) { n, err := v.cluster.AddNode( ctx, opts.Nodename, opts.Endpoint, opts.Podname, opts.Ca, opts.Cert, opts.Key, int(opts.Cpu), int(opts.Share), opts.Memory, opts.Labels, ) if err != nil { return nil, err } return toRPCNode(ctx, n), nil }
[ "func", "(", "v", "*", "Vibranium", ")", "AddNode", "(", "ctx", "context", ".", "Context", ",", "opts", "*", "pb", ".", "AddNodeOptions", ")", "(", "*", "pb", ".", "Node", ",", "error", ")", "{", "n", ",", "err", ":=", "v", ".", "cluster", ".", ...
// AddNode saves a node and returns it to client // Method must be called synchronously, or nothing will be returned
[ "AddNode", "saves", "a", "node", "and", "returns", "it", "to", "client", "Method", "must", "be", "called", "synchronously", "or", "nothing", "will", "be", "returned" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/rpc/rpc.go#L40-L59
16,177
projecteru2/core
rpc/rpc.go
RemovePod
func (v *Vibranium) RemovePod(ctx context.Context, opts *pb.RemovePodOptions) (*pb.Empty, error) { err := v.cluster.RemovePod(ctx, opts.Name) if err != nil { return nil, err } return &pb.Empty{}, nil }
go
func (v *Vibranium) RemovePod(ctx context.Context, opts *pb.RemovePodOptions) (*pb.Empty, error) { err := v.cluster.RemovePod(ctx, opts.Name) if err != nil { return nil, err } return &pb.Empty{}, nil }
[ "func", "(", "v", "*", "Vibranium", ")", "RemovePod", "(", "ctx", "context", ".", "Context", ",", "opts", "*", "pb", ".", "RemovePodOptions", ")", "(", "*", "pb", ".", "Empty", ",", "error", ")", "{", "err", ":=", "v", ".", "cluster", ".", "RemoveP...
// RemovePod removes a pod only if it's empty
[ "RemovePod", "removes", "a", "pod", "only", "if", "it", "s", "empty" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/rpc/rpc.go#L62-L68
16,178
projecteru2/core
rpc/rpc.go
RemoveNode
func (v *Vibranium) RemoveNode(ctx context.Context, opts *pb.RemoveNodeOptions) (*pb.Pod, error) { p, err := v.cluster.RemoveNode(ctx, opts.Nodename, opts.Podname) if err != nil { return nil, err } return toRPCPod(p), nil }
go
func (v *Vibranium) RemoveNode(ctx context.Context, opts *pb.RemoveNodeOptions) (*pb.Pod, error) { p, err := v.cluster.RemoveNode(ctx, opts.Nodename, opts.Podname) if err != nil { return nil, err } return toRPCPod(p), nil }
[ "func", "(", "v", "*", "Vibranium", ")", "RemoveNode", "(", "ctx", "context", ".", "Context", ",", "opts", "*", "pb", ".", "RemoveNodeOptions", ")", "(", "*", "pb", ".", "Pod", ",", "error", ")", "{", "p", ",", "err", ":=", "v", ".", "cluster", "...
// RemoveNode removes the node from etcd
[ "RemoveNode", "removes", "the", "node", "from", "etcd" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/rpc/rpc.go#L71-L78
16,179
projecteru2/core
rpc/rpc.go
ListPods
func (v *Vibranium) ListPods(ctx context.Context, _ *pb.Empty) (*pb.Pods, error) { ps, err := v.cluster.ListPods(ctx) if err != nil { return nil, err } pods := []*pb.Pod{} for _, p := range ps { pods = append(pods, toRPCPod(p)) } return &pb.Pods{Pods: pods}, nil }
go
func (v *Vibranium) ListPods(ctx context.Context, _ *pb.Empty) (*pb.Pods, error) { ps, err := v.cluster.ListPods(ctx) if err != nil { return nil, err } pods := []*pb.Pod{} for _, p := range ps { pods = append(pods, toRPCPod(p)) } return &pb.Pods{Pods: pods}, nil }
[ "func", "(", "v", "*", "Vibranium", ")", "ListPods", "(", "ctx", "context", ".", "Context", ",", "_", "*", "pb", ".", "Empty", ")", "(", "*", "pb", ".", "Pods", ",", "error", ")", "{", "ps", ",", "err", ":=", "v", ".", "cluster", ".", "ListPods...
// ListPods returns a list of pods
[ "ListPods", "returns", "a", "list", "of", "pods" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/rpc/rpc.go#L81-L94
16,180
projecteru2/core
rpc/rpc.go
ListPodNodes
func (v *Vibranium) ListPodNodes(ctx context.Context, opts *pb.ListNodesOptions) (*pb.Nodes, error) { ns, err := v.cluster.ListPodNodes(ctx, opts.Podname, opts.All) if err != nil { return nil, err } nodes := []*pb.Node{} for _, n := range ns { nodes = append(nodes, toRPCNode(ctx, n)) } return &pb.Nodes{Nodes: nodes}, nil }
go
func (v *Vibranium) ListPodNodes(ctx context.Context, opts *pb.ListNodesOptions) (*pb.Nodes, error) { ns, err := v.cluster.ListPodNodes(ctx, opts.Podname, opts.All) if err != nil { return nil, err } nodes := []*pb.Node{} for _, n := range ns { nodes = append(nodes, toRPCNode(ctx, n)) } return &pb.Nodes{Nodes: nodes}, nil }
[ "func", "(", "v", "*", "Vibranium", ")", "ListPodNodes", "(", "ctx", "context", ".", "Context", ",", "opts", "*", "pb", ".", "ListNodesOptions", ")", "(", "*", "pb", ".", "Nodes", ",", "error", ")", "{", "ns", ",", "err", ":=", "v", ".", "cluster",...
// ListPodNodes returns a list of node for pod
[ "ListPodNodes", "returns", "a", "list", "of", "node", "for", "pod" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/rpc/rpc.go#L97-L108
16,181
projecteru2/core
rpc/rpc.go
ListContainers
func (v *Vibranium) ListContainers(ctx context.Context, opts *pb.ListContainersOptions) (*pb.Containers, error) { lsopts := &types.ListContainersOptions{ Appname: opts.Appname, Entrypoint: opts.Entrypoint, Nodename: opts.Nodename, } containers, err := v.cluster.ListContainers(ctx, lsopts) if err != nil { return nil, err } return &pb.Containers{Containers: toRPCContainers(ctx, containers, opts.Labels)}, nil }
go
func (v *Vibranium) ListContainers(ctx context.Context, opts *pb.ListContainersOptions) (*pb.Containers, error) { lsopts := &types.ListContainersOptions{ Appname: opts.Appname, Entrypoint: opts.Entrypoint, Nodename: opts.Nodename, } containers, err := v.cluster.ListContainers(ctx, lsopts) if err != nil { return nil, err } return &pb.Containers{Containers: toRPCContainers(ctx, containers, opts.Labels)}, nil }
[ "func", "(", "v", "*", "Vibranium", ")", "ListContainers", "(", "ctx", "context", ".", "Context", ",", "opts", "*", "pb", ".", "ListContainersOptions", ")", "(", "*", "pb", ".", "Containers", ",", "error", ")", "{", "lsopts", ":=", "&", "types", ".", ...
// ListContainers by appname with optional entrypoint and nodename
[ "ListContainers", "by", "appname", "with", "optional", "entrypoint", "and", "nodename" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/rpc/rpc.go#L111-L123
16,182
projecteru2/core
rpc/rpc.go
ListNodeContainers
func (v *Vibranium) ListNodeContainers(ctx context.Context, opts *pb.GetNodeOptions) (*pb.Containers, error) { containers, err := v.cluster.ListNodeContainers(ctx, opts.Nodename) if err != nil { return nil, err } return &pb.Containers{Containers: toRPCContainers(ctx, containers, nil)}, nil }
go
func (v *Vibranium) ListNodeContainers(ctx context.Context, opts *pb.GetNodeOptions) (*pb.Containers, error) { containers, err := v.cluster.ListNodeContainers(ctx, opts.Nodename) if err != nil { return nil, err } return &pb.Containers{Containers: toRPCContainers(ctx, containers, nil)}, nil }
[ "func", "(", "v", "*", "Vibranium", ")", "ListNodeContainers", "(", "ctx", "context", ".", "Context", ",", "opts", "*", "pb", ".", "GetNodeOptions", ")", "(", "*", "pb", ".", "Containers", ",", "error", ")", "{", "containers", ",", "err", ":=", "v", ...
// ListNodeContainers list node containers
[ "ListNodeContainers", "list", "node", "containers" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/rpc/rpc.go#L126-L132
16,183
projecteru2/core
rpc/rpc.go
ListNetworks
func (v *Vibranium) ListNetworks(ctx context.Context, opts *pb.ListNetworkOptions) (*pb.Networks, error) { networks, err := v.cluster.ListNetworks(ctx, opts.Podname, opts.Driver) if err != nil { return nil, err } ns := []*pb.Network{} for _, n := range networks { ns = append(ns, toRPCNetwork(n)) } return &pb.Networks{Networks: ns}, nil }
go
func (v *Vibranium) ListNetworks(ctx context.Context, opts *pb.ListNetworkOptions) (*pb.Networks, error) { networks, err := v.cluster.ListNetworks(ctx, opts.Podname, opts.Driver) if err != nil { return nil, err } ns := []*pb.Network{} for _, n := range networks { ns = append(ns, toRPCNetwork(n)) } return &pb.Networks{Networks: ns}, nil }
[ "func", "(", "v", "*", "Vibranium", ")", "ListNetworks", "(", "ctx", "context", ".", "Context", ",", "opts", "*", "pb", ".", "ListNetworkOptions", ")", "(", "*", "pb", ".", "Networks", ",", "error", ")", "{", "networks", ",", "err", ":=", "v", ".", ...
// ListNetworks list networks for pod
[ "ListNetworks", "list", "networks", "for", "pod" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/rpc/rpc.go#L135-L146
16,184
projecteru2/core
rpc/rpc.go
GetPod
func (v *Vibranium) GetPod(ctx context.Context, opts *pb.GetPodOptions) (*pb.Pod, error) { p, err := v.cluster.GetPod(ctx, opts.Name) if err != nil { return nil, err } return toRPCPod(p), nil }
go
func (v *Vibranium) GetPod(ctx context.Context, opts *pb.GetPodOptions) (*pb.Pod, error) { p, err := v.cluster.GetPod(ctx, opts.Name) if err != nil { return nil, err } return toRPCPod(p), nil }
[ "func", "(", "v", "*", "Vibranium", ")", "GetPod", "(", "ctx", "context", ".", "Context", ",", "opts", "*", "pb", ".", "GetPodOptions", ")", "(", "*", "pb", ".", "Pod", ",", "error", ")", "{", "p", ",", "err", ":=", "v", ".", "cluster", ".", "G...
// GetPod show a pod
[ "GetPod", "show", "a", "pod" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/rpc/rpc.go#L149-L156
16,185
projecteru2/core
rpc/rpc.go
GetPodResource
func (v *Vibranium) GetPodResource(ctx context.Context, opts *pb.GetPodOptions) (*pb.PodResource, error) { r, err := v.cluster.PodResource(ctx, opts.Name) if err != nil { return nil, err } return toRPCPodResource(r), nil }
go
func (v *Vibranium) GetPodResource(ctx context.Context, opts *pb.GetPodOptions) (*pb.PodResource, error) { r, err := v.cluster.PodResource(ctx, opts.Name) if err != nil { return nil, err } return toRPCPodResource(r), nil }
[ "func", "(", "v", "*", "Vibranium", ")", "GetPodResource", "(", "ctx", "context", ".", "Context", ",", "opts", "*", "pb", ".", "GetPodOptions", ")", "(", "*", "pb", ".", "PodResource", ",", "error", ")", "{", "r", ",", "err", ":=", "v", ".", "clust...
// GetPodResource get pod nodes resource usage
[ "GetPodResource", "get", "pod", "nodes", "resource", "usage" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/rpc/rpc.go#L159-L165
16,186
projecteru2/core
rpc/rpc.go
GetContainer
func (v *Vibranium) GetContainer(ctx context.Context, id *pb.ContainerID) (*pb.Container, error) { container, err := v.cluster.GetContainer(ctx, id.Id) if err != nil { return nil, err } return toRPCContainer(ctx, container) }
go
func (v *Vibranium) GetContainer(ctx context.Context, id *pb.ContainerID) (*pb.Container, error) { container, err := v.cluster.GetContainer(ctx, id.Id) if err != nil { return nil, err } return toRPCContainer(ctx, container) }
[ "func", "(", "v", "*", "Vibranium", ")", "GetContainer", "(", "ctx", "context", ".", "Context", ",", "id", "*", "pb", ".", "ContainerID", ")", "(", "*", "pb", ".", "Container", ",", "error", ")", "{", "container", ",", "err", ":=", "v", ".", "clust...
// GetContainer get a container // More information will be shown
[ "GetContainer", "get", "a", "container", "More", "information", "will", "be", "shown" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/rpc/rpc.go#L179-L186
16,187
projecteru2/core
rpc/rpc.go
GetContainers
func (v *Vibranium) GetContainers(ctx context.Context, cids *pb.ContainerIDs) (*pb.Containers, error) { containers, err := v.cluster.GetContainers(ctx, cids.GetIds()) if err != nil { return nil, err } return &pb.Containers{Containers: toRPCContainers(ctx, containers, nil)}, nil }
go
func (v *Vibranium) GetContainers(ctx context.Context, cids *pb.ContainerIDs) (*pb.Containers, error) { containers, err := v.cluster.GetContainers(ctx, cids.GetIds()) if err != nil { return nil, err } return &pb.Containers{Containers: toRPCContainers(ctx, containers, nil)}, nil }
[ "func", "(", "v", "*", "Vibranium", ")", "GetContainers", "(", "ctx", "context", ".", "Context", ",", "cids", "*", "pb", ".", "ContainerIDs", ")", "(", "*", "pb", ".", "Containers", ",", "error", ")", "{", "containers", ",", "err", ":=", "v", ".", ...
// GetContainers get lots containers // like GetContainer, information should be returned
[ "GetContainers", "get", "lots", "containers", "like", "GetContainer", "information", "should", "be", "returned" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/rpc/rpc.go#L190-L197
16,188
projecteru2/core
rpc/rpc.go
SetNodeAvailable
func (v *Vibranium) SetNodeAvailable(ctx context.Context, opts *pb.NodeAvailable) (*pb.Node, error) { n, err := v.cluster.SetNodeAvailable(ctx, opts.Podname, opts.Nodename, opts.Available) if err != nil { return nil, err } return toRPCNode(ctx, n), nil }
go
func (v *Vibranium) SetNodeAvailable(ctx context.Context, opts *pb.NodeAvailable) (*pb.Node, error) { n, err := v.cluster.SetNodeAvailable(ctx, opts.Podname, opts.Nodename, opts.Available) if err != nil { return nil, err } return toRPCNode(ctx, n), nil }
[ "func", "(", "v", "*", "Vibranium", ")", "SetNodeAvailable", "(", "ctx", "context", ".", "Context", ",", "opts", "*", "pb", ".", "NodeAvailable", ")", "(", "*", "pb", ".", "Node", ",", "error", ")", "{", "n", ",", "err", ":=", "v", ".", "cluster", ...
// SetNodeAvailable set node availability
[ "SetNodeAvailable", "set", "node", "availability" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/rpc/rpc.go#L200-L206
16,189
projecteru2/core
rpc/rpc.go
Copy
func (v *Vibranium) Copy(opts *pb.CopyOptions, stream pb.CoreRPC_CopyServer) error { v.taskAdd("Copy", true) defer v.taskDone("Copy", true) copyOpts := toCoreCopyOptions(opts) ch, err := v.cluster.Copy(stream.Context(), copyOpts) if err != nil { return err } //4K buffer bsize := 4 * 1024 for m := range ch { var copyError string if m.Error != nil { copyError = fmt.Sprintf("%v", m.Error) if err := stream.Send(&pb.CopyMessage{ Id: m.ID, Status: m.Status, Name: m.Name, Path: m.Path, Error: copyError, Data: []byte{}, }); err != nil { v.logUnsentMessages("Copy", m) } continue } r, w := io.Pipe() go func() { defer w.Close() defer m.Data.Close() buffer := bufio.NewWriterSize(w, bsize) defer buffer.Flush() gw := gzip.NewWriter(buffer) defer gw.Close() _, err = io.Copy(gw, m.Data) if err != nil { log.Errorf("[Copy] Error during copy resp: %v", err) } }() for { p := make([]byte, bsize) n, err := r.Read(p) if err != nil { if err != io.EOF { log.Errorf("[Copy] Error during buffer resp: %v", err) } break } if err = stream.Send(&pb.CopyMessage{ Id: m.ID, Status: m.Status, Name: m.Name, Path: m.Path, Error: copyError, Data: p[:n], }); err != nil { v.logUnsentMessages("Copy", m) } } } return nil }
go
func (v *Vibranium) Copy(opts *pb.CopyOptions, stream pb.CoreRPC_CopyServer) error { v.taskAdd("Copy", true) defer v.taskDone("Copy", true) copyOpts := toCoreCopyOptions(opts) ch, err := v.cluster.Copy(stream.Context(), copyOpts) if err != nil { return err } //4K buffer bsize := 4 * 1024 for m := range ch { var copyError string if m.Error != nil { copyError = fmt.Sprintf("%v", m.Error) if err := stream.Send(&pb.CopyMessage{ Id: m.ID, Status: m.Status, Name: m.Name, Path: m.Path, Error: copyError, Data: []byte{}, }); err != nil { v.logUnsentMessages("Copy", m) } continue } r, w := io.Pipe() go func() { defer w.Close() defer m.Data.Close() buffer := bufio.NewWriterSize(w, bsize) defer buffer.Flush() gw := gzip.NewWriter(buffer) defer gw.Close() _, err = io.Copy(gw, m.Data) if err != nil { log.Errorf("[Copy] Error during copy resp: %v", err) } }() for { p := make([]byte, bsize) n, err := r.Read(p) if err != nil { if err != io.EOF { log.Errorf("[Copy] Error during buffer resp: %v", err) } break } if err = stream.Send(&pb.CopyMessage{ Id: m.ID, Status: m.Status, Name: m.Name, Path: m.Path, Error: copyError, Data: p[:n], }); err != nil { v.logUnsentMessages("Copy", m) } } } return nil }
[ "func", "(", "v", "*", "Vibranium", ")", "Copy", "(", "opts", "*", "pb", ".", "CopyOptions", ",", "stream", "pb", ".", "CoreRPC_CopyServer", ")", "error", "{", "v", ".", "taskAdd", "(", "\"", "\"", ",", "true", ")", "\n", "defer", "v", ".", "taskDo...
// Copy copy files from multiple containers
[ "Copy", "copy", "files", "from", "multiple", "containers" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/rpc/rpc.go#L209-L275
16,190
projecteru2/core
rpc/rpc.go
BuildImage
func (v *Vibranium) BuildImage(opts *pb.BuildImageOptions, stream pb.CoreRPC_BuildImageServer) error { v.taskAdd("BuildImage", true) defer v.taskDone("BuildImage", true) buildOpts, err := toCoreBuildOptions(opts) if err != nil { return err } // TODO VM BRANCH ch, err := v.cluster.BuildImage(stream.Context(), buildOpts) if err != nil { return err } for m := range ch { if err = stream.Send(toRPCBuildImageMessage(m)); err != nil { v.logUnsentMessages("BuildImage", m) } } return err }
go
func (v *Vibranium) BuildImage(opts *pb.BuildImageOptions, stream pb.CoreRPC_BuildImageServer) error { v.taskAdd("BuildImage", true) defer v.taskDone("BuildImage", true) buildOpts, err := toCoreBuildOptions(opts) if err != nil { return err } // TODO VM BRANCH ch, err := v.cluster.BuildImage(stream.Context(), buildOpts) if err != nil { return err } for m := range ch { if err = stream.Send(toRPCBuildImageMessage(m)); err != nil { v.logUnsentMessages("BuildImage", m) } } return err }
[ "func", "(", "v", "*", "Vibranium", ")", "BuildImage", "(", "opts", "*", "pb", ".", "BuildImageOptions", ",", "stream", "pb", ".", "CoreRPC_BuildImageServer", ")", "error", "{", "v", ".", "taskAdd", "(", "\"", "\"", ",", "true", ")", "\n", "defer", "v"...
// BuildImage streamed returned functions
[ "BuildImage", "streamed", "returned", "functions" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/rpc/rpc.go#L278-L298
16,191
projecteru2/core
rpc/rpc.go
CacheImage
func (v *Vibranium) CacheImage(opts *pb.CacheImageOptions, stream pb.CoreRPC_CacheImageServer) error { v.taskAdd("CacheImage", true) defer v.taskDone("CacheImage", true) ch, err := v.cluster.CacheImage(stream.Context(), opts.Podname, opts.Nodename, opts.Images, int(opts.Step)) if err != nil { return err } for m := range ch { if err = stream.Send(toRPCCacheImageMessage(m)); err != nil { v.logUnsentMessages("CacheImage", m) } } return err }
go
func (v *Vibranium) CacheImage(opts *pb.CacheImageOptions, stream pb.CoreRPC_CacheImageServer) error { v.taskAdd("CacheImage", true) defer v.taskDone("CacheImage", true) ch, err := v.cluster.CacheImage(stream.Context(), opts.Podname, opts.Nodename, opts.Images, int(opts.Step)) if err != nil { return err } for m := range ch { if err = stream.Send(toRPCCacheImageMessage(m)); err != nil { v.logUnsentMessages("CacheImage", m) } } return err }
[ "func", "(", "v", "*", "Vibranium", ")", "CacheImage", "(", "opts", "*", "pb", ".", "CacheImageOptions", ",", "stream", "pb", ".", "CoreRPC_CacheImageServer", ")", "error", "{", "v", ".", "taskAdd", "(", "\"", "\"", ",", "true", ")", "\n", "defer", "v"...
// CacheImage cache image
[ "CacheImage", "cache", "image" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/rpc/rpc.go#L301-L316
16,192
projecteru2/core
rpc/rpc.go
RemoveImage
func (v *Vibranium) RemoveImage(opts *pb.RemoveImageOptions, stream pb.CoreRPC_RemoveImageServer) error { v.taskAdd("RemoveImage", true) defer v.taskDone("RemoveImage", true) ch, err := v.cluster.RemoveImage(stream.Context(), opts.Podname, opts.Nodename, opts.Images, int(opts.Step), opts.Prune) if err != nil { return err } for m := range ch { if err = stream.Send(toRPCRemoveImageMessage(m)); err != nil { v.logUnsentMessages("RemoveImage", m) } } return err }
go
func (v *Vibranium) RemoveImage(opts *pb.RemoveImageOptions, stream pb.CoreRPC_RemoveImageServer) error { v.taskAdd("RemoveImage", true) defer v.taskDone("RemoveImage", true) ch, err := v.cluster.RemoveImage(stream.Context(), opts.Podname, opts.Nodename, opts.Images, int(opts.Step), opts.Prune) if err != nil { return err } for m := range ch { if err = stream.Send(toRPCRemoveImageMessage(m)); err != nil { v.logUnsentMessages("RemoveImage", m) } } return err }
[ "func", "(", "v", "*", "Vibranium", ")", "RemoveImage", "(", "opts", "*", "pb", ".", "RemoveImageOptions", ",", "stream", "pb", ".", "CoreRPC_RemoveImageServer", ")", "error", "{", "v", ".", "taskAdd", "(", "\"", "\"", ",", "true", ")", "\n", "defer", ...
// RemoveImage remove image
[ "RemoveImage", "remove", "image" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/rpc/rpc.go#L319-L334
16,193
projecteru2/core
rpc/rpc.go
DeployStatus
func (v *Vibranium) DeployStatus(opts *pb.DeployStatusOptions, stream pb.CoreRPC_DeployStatusServer) error { log.Infof("[rpc] DeployStatus start %s", opts.Appname) defer log.Infof("[rpc] DeployStatus stop %s", opts.Appname) ch := v.cluster.DeployStatusStream(stream.Context(), opts.Appname, opts.Entrypoint, opts.Nodename) for { select { case m, ok := <-ch: if !ok { return nil } if m.Err != nil { return m.Err } if err := stream.Send(&pb.DeployStatusMessage{ Action: m.Action, Appname: m.Appname, Entrypoint: m.Entrypoint, Nodename: m.Nodename, Id: m.ID, Data: []byte(m.Data), }); err != nil { v.logUnsentMessages("DeployStatus", m) } case <-v.rpcch: return nil } } }
go
func (v *Vibranium) DeployStatus(opts *pb.DeployStatusOptions, stream pb.CoreRPC_DeployStatusServer) error { log.Infof("[rpc] DeployStatus start %s", opts.Appname) defer log.Infof("[rpc] DeployStatus stop %s", opts.Appname) ch := v.cluster.DeployStatusStream(stream.Context(), opts.Appname, opts.Entrypoint, opts.Nodename) for { select { case m, ok := <-ch: if !ok { return nil } if m.Err != nil { return m.Err } if err := stream.Send(&pb.DeployStatusMessage{ Action: m.Action, Appname: m.Appname, Entrypoint: m.Entrypoint, Nodename: m.Nodename, Id: m.ID, Data: []byte(m.Data), }); err != nil { v.logUnsentMessages("DeployStatus", m) } case <-v.rpcch: return nil } } }
[ "func", "(", "v", "*", "Vibranium", ")", "DeployStatus", "(", "opts", "*", "pb", ".", "DeployStatusOptions", ",", "stream", "pb", ".", "CoreRPC_DeployStatusServer", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "opts", ".", "Appname", ")"...
// DeployStatus watch and show deployed status
[ "DeployStatus", "watch", "and", "show", "deployed", "status" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/rpc/rpc.go#L337-L365
16,194
projecteru2/core
rpc/rpc.go
RunAndWait
func (v *Vibranium) RunAndWait(stream pb.CoreRPC_RunAndWaitServer) error { v.taskAdd("RunAndWait", true) defer v.taskDone("RunAndWait", true) RunAndWaitOptions, err := stream.Recv() if err != nil { return err } if RunAndWaitOptions.DeployOptions == nil { return types.ErrNoDeployOpts } opts := RunAndWaitOptions.DeployOptions stdinReader, stdinWriter := io.Pipe() defer stdinReader.Close() deployOpts, err := toCoreDeployOptions(opts) if err != nil { return err } ch, err := v.cluster.RunAndWait(stream.Context(), deployOpts, stdinReader) if err != nil { // `ch` is nil now log.Errorf("[RunAndWait] Start run and wait failed %s", err) return err } if opts.OpenStdin { go func() { defer stdinWriter.Write([]byte("exit\n")) stdinWriter.Write([]byte("echo 'Welcom to NERV...\n'\n")) cli := []byte("echo \"`pwd`> \"\n") stdinWriter.Write(cli) for { RunAndWaitOptions, err := stream.Recv() if RunAndWaitOptions == nil || err != nil { log.Errorf("[RunAndWait] Recv command error: %v", err) break } log.Debugf("[RunAndWait] Recv command: %s", bytes.TrimRight(RunAndWaitOptions.Cmd, "\n")) if _, err := stdinWriter.Write(RunAndWaitOptions.Cmd); err != nil { log.Errorf("[RunAndWait] Write command error: %v", err) break } stdinWriter.Write(cli) } }() } for m := range ch { if err = stream.Send(toRPCRunAndWaitMessage(m)); err != nil { v.logUnsentMessages("RunAndWait", m) } } return cleanDeployOptionsDataFile(deployOpts) }
go
func (v *Vibranium) RunAndWait(stream pb.CoreRPC_RunAndWaitServer) error { v.taskAdd("RunAndWait", true) defer v.taskDone("RunAndWait", true) RunAndWaitOptions, err := stream.Recv() if err != nil { return err } if RunAndWaitOptions.DeployOptions == nil { return types.ErrNoDeployOpts } opts := RunAndWaitOptions.DeployOptions stdinReader, stdinWriter := io.Pipe() defer stdinReader.Close() deployOpts, err := toCoreDeployOptions(opts) if err != nil { return err } ch, err := v.cluster.RunAndWait(stream.Context(), deployOpts, stdinReader) if err != nil { // `ch` is nil now log.Errorf("[RunAndWait] Start run and wait failed %s", err) return err } if opts.OpenStdin { go func() { defer stdinWriter.Write([]byte("exit\n")) stdinWriter.Write([]byte("echo 'Welcom to NERV...\n'\n")) cli := []byte("echo \"`pwd`> \"\n") stdinWriter.Write(cli) for { RunAndWaitOptions, err := stream.Recv() if RunAndWaitOptions == nil || err != nil { log.Errorf("[RunAndWait] Recv command error: %v", err) break } log.Debugf("[RunAndWait] Recv command: %s", bytes.TrimRight(RunAndWaitOptions.Cmd, "\n")) if _, err := stdinWriter.Write(RunAndWaitOptions.Cmd); err != nil { log.Errorf("[RunAndWait] Write command error: %v", err) break } stdinWriter.Write(cli) } }() } for m := range ch { if err = stream.Send(toRPCRunAndWaitMessage(m)); err != nil { v.logUnsentMessages("RunAndWait", m) } } return cleanDeployOptionsDataFile(deployOpts) }
[ "func", "(", "v", "*", "Vibranium", ")", "RunAndWait", "(", "stream", "pb", ".", "CoreRPC_RunAndWaitServer", ")", "error", "{", "v", ".", "taskAdd", "(", "\"", "\"", ",", "true", ")", "\n", "defer", "v", ".", "taskDone", "(", "\"", "\"", ",", "true",...
// RunAndWait is lambda
[ "RunAndWait", "is", "lambda" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/rpc/rpc.go#L368-L425
16,195
projecteru2/core
rpc/rpc.go
CreateContainer
func (v *Vibranium) CreateContainer(opts *pb.DeployOptions, stream pb.CoreRPC_CreateContainerServer) error { v.taskAdd("CreateContainer", true) defer v.taskDone("CreateContainer", true) deployOpts, err := toCoreDeployOptions(opts) if err != nil { return nil } //่ฟ™้‡Œ่€ƒ่™‘็”จๅ…จๅฑ€ Background ch, err := v.cluster.CreateContainer(context.Background(), deployOpts) if err != nil { return err } for m := range ch { if err = stream.Send(toRPCCreateContainerMessage(m)); err != nil { v.logUnsentMessages("CreateContainer", m) } } return cleanDeployOptionsDataFile(deployOpts) }
go
func (v *Vibranium) CreateContainer(opts *pb.DeployOptions, stream pb.CoreRPC_CreateContainerServer) error { v.taskAdd("CreateContainer", true) defer v.taskDone("CreateContainer", true) deployOpts, err := toCoreDeployOptions(opts) if err != nil { return nil } //่ฟ™้‡Œ่€ƒ่™‘็”จๅ…จๅฑ€ Background ch, err := v.cluster.CreateContainer(context.Background(), deployOpts) if err != nil { return err } for m := range ch { if err = stream.Send(toRPCCreateContainerMessage(m)); err != nil { v.logUnsentMessages("CreateContainer", m) } } return cleanDeployOptionsDataFile(deployOpts) }
[ "func", "(", "v", "*", "Vibranium", ")", "CreateContainer", "(", "opts", "*", "pb", ".", "DeployOptions", ",", "stream", "pb", ".", "CoreRPC_CreateContainerServer", ")", "error", "{", "v", ".", "taskAdd", "(", "\"", "\"", ",", "true", ")", "\n", "defer",...
// CreateContainer create containers
[ "CreateContainer", "create", "containers" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/rpc/rpc.go#L428-L449
16,196
projecteru2/core
rpc/rpc.go
ReplaceContainer
func (v *Vibranium) ReplaceContainer(opts *pb.ReplaceOptions, stream pb.CoreRPC_ReplaceContainerServer) error { v.taskAdd("ReplaceContainer", true) defer v.taskDone("ReplaceContainer", true) replaceOpts, err := toCoreReplaceOptions(opts) if err != nil { return err } //่ฟ™้‡Œ่€ƒ่™‘็”จๅ…จๅฑ€ Background ch, err := v.cluster.ReplaceContainer(context.Background(), replaceOpts) if err != nil { return err } for m := range ch { if err = stream.Send(toRPCReplaceContainerMessage(m)); err != nil { v.logUnsentMessages("ReplaceContainer", m) } } return cleanDeployOptionsDataFile(&replaceOpts.DeployOptions) }
go
func (v *Vibranium) ReplaceContainer(opts *pb.ReplaceOptions, stream pb.CoreRPC_ReplaceContainerServer) error { v.taskAdd("ReplaceContainer", true) defer v.taskDone("ReplaceContainer", true) replaceOpts, err := toCoreReplaceOptions(opts) if err != nil { return err } //่ฟ™้‡Œ่€ƒ่™‘็”จๅ…จๅฑ€ Background ch, err := v.cluster.ReplaceContainer(context.Background(), replaceOpts) if err != nil { return err } for m := range ch { if err = stream.Send(toRPCReplaceContainerMessage(m)); err != nil { v.logUnsentMessages("ReplaceContainer", m) } } return cleanDeployOptionsDataFile(&replaceOpts.DeployOptions) }
[ "func", "(", "v", "*", "Vibranium", ")", "ReplaceContainer", "(", "opts", "*", "pb", ".", "ReplaceOptions", ",", "stream", "pb", ".", "CoreRPC_ReplaceContainerServer", ")", "error", "{", "v", ".", "taskAdd", "(", "\"", "\"", ",", "true", ")", "\n", "defe...
// ReplaceContainer replace containers
[ "ReplaceContainer", "replace", "containers" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/rpc/rpc.go#L452-L474
16,197
projecteru2/core
rpc/rpc.go
RemoveContainer
func (v *Vibranium) RemoveContainer(opts *pb.RemoveContainerOptions, stream pb.CoreRPC_RemoveContainerServer) error { v.taskAdd("RemoveContainer", true) defer v.taskDone("RemoveContainer", true) ids := opts.GetIds() force := opts.GetForce() if len(ids) == 0 { return types.ErrNoContainerIDs } //่ฟ™้‡Œไธ่ƒฝ่ฎฉ client ๆ‰“ๆ–ญ remove ch, err := v.cluster.RemoveContainer(context.Background(), ids, force) if err != nil { return err } for m := range ch { if err = stream.Send(toRPCRemoveContainerMessage(m)); err != nil { v.logUnsentMessages("RemoveContainer", m) } } return err }
go
func (v *Vibranium) RemoveContainer(opts *pb.RemoveContainerOptions, stream pb.CoreRPC_RemoveContainerServer) error { v.taskAdd("RemoveContainer", true) defer v.taskDone("RemoveContainer", true) ids := opts.GetIds() force := opts.GetForce() if len(ids) == 0 { return types.ErrNoContainerIDs } //่ฟ™้‡Œไธ่ƒฝ่ฎฉ client ๆ‰“ๆ–ญ remove ch, err := v.cluster.RemoveContainer(context.Background(), ids, force) if err != nil { return err } for m := range ch { if err = stream.Send(toRPCRemoveContainerMessage(m)); err != nil { v.logUnsentMessages("RemoveContainer", m) } } return err }
[ "func", "(", "v", "*", "Vibranium", ")", "RemoveContainer", "(", "opts", "*", "pb", ".", "RemoveContainerOptions", ",", "stream", "pb", ".", "CoreRPC_RemoveContainerServer", ")", "error", "{", "v", ".", "taskAdd", "(", "\"", "\"", ",", "true", ")", "\n", ...
// RemoveContainer remove containers
[ "RemoveContainer", "remove", "containers" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/rpc/rpc.go#L477-L501
16,198
projecteru2/core
rpc/rpc.go
ControlContainer
func (v *Vibranium) ControlContainer(opts *pb.ControlContainerOptions, stream pb.CoreRPC_ControlContainerServer) error { v.taskAdd("ControlContainer", true) defer v.taskDone("ControlContainer", true) ids := opts.GetIds() t := opts.GetType() if len(ids) == 0 { return types.ErrNoContainerIDs } ch, err := v.cluster.ControlContainer(stream.Context(), ids, t) if err != nil { return err } for m := range ch { if err = stream.Send(toRPCControlContainerMessage(m)); err != nil { v.logUnsentMessages("ControlContainer", m) } } return err }
go
func (v *Vibranium) ControlContainer(opts *pb.ControlContainerOptions, stream pb.CoreRPC_ControlContainerServer) error { v.taskAdd("ControlContainer", true) defer v.taskDone("ControlContainer", true) ids := opts.GetIds() t := opts.GetType() if len(ids) == 0 { return types.ErrNoContainerIDs } ch, err := v.cluster.ControlContainer(stream.Context(), ids, t) if err != nil { return err } for m := range ch { if err = stream.Send(toRPCControlContainerMessage(m)); err != nil { v.logUnsentMessages("ControlContainer", m) } } return err }
[ "func", "(", "v", "*", "Vibranium", ")", "ControlContainer", "(", "opts", "*", "pb", ".", "ControlContainerOptions", ",", "stream", "pb", ".", "CoreRPC_ControlContainerServer", ")", "error", "{", "v", ".", "taskAdd", "(", "\"", "\"", ",", "true", ")", "\n"...
// ControlContainer control containers
[ "ControlContainer", "control", "containers" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/rpc/rpc.go#L504-L527
16,199
projecteru2/core
rpc/rpc.go
ReallocResource
func (v *Vibranium) ReallocResource(opts *pb.ReallocOptions, stream pb.CoreRPC_ReallocResourceServer) error { v.taskAdd("ReallocResource", true) defer v.taskDone("ReallocResource", true) ids := opts.GetIds() if len(ids) == 0 { return types.ErrNoContainerIDs } //่ฟ™้‡Œไธ่ƒฝ่ฎฉ client ๆ‰“ๆ–ญ remove ch, err := v.cluster.ReallocResource(context.Background(), ids, opts.Cpu, opts.Mem) if err != nil { return err } for m := range ch { if err = stream.Send(toRPCReallocResourceMessage(m)); err != nil { v.logUnsentMessages("ReallocResource", m) } } return err }
go
func (v *Vibranium) ReallocResource(opts *pb.ReallocOptions, stream pb.CoreRPC_ReallocResourceServer) error { v.taskAdd("ReallocResource", true) defer v.taskDone("ReallocResource", true) ids := opts.GetIds() if len(ids) == 0 { return types.ErrNoContainerIDs } //่ฟ™้‡Œไธ่ƒฝ่ฎฉ client ๆ‰“ๆ–ญ remove ch, err := v.cluster.ReallocResource(context.Background(), ids, opts.Cpu, opts.Mem) if err != nil { return err } for m := range ch { if err = stream.Send(toRPCReallocResourceMessage(m)); err != nil { v.logUnsentMessages("ReallocResource", m) } } return err }
[ "func", "(", "v", "*", "Vibranium", ")", "ReallocResource", "(", "opts", "*", "pb", ".", "ReallocOptions", ",", "stream", "pb", ".", "CoreRPC_ReallocResourceServer", ")", "error", "{", "v", ".", "taskAdd", "(", "\"", "\"", ",", "true", ")", "\n", "defer"...
// ReallocResource realloc res for containers
[ "ReallocResource", "realloc", "res", "for", "containers" ]
b12208b63ff460ec82327f36d39a2cee786f4dbb
https://github.com/projecteru2/core/blob/b12208b63ff460ec82327f36d39a2cee786f4dbb/rpc/rpc.go#L530-L550